194 public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
197 $selectlabel = array();
198 foreach ($array_selected_sorted as $code => $value) {
199 if (strpos($code,
' as ') == 0) {
200 $alias = str_replace(array(
'.',
'-',
'(',
')'),
'_', $code);
202 $alias = substr($code, strpos($code,
' as ') + 4);
205 dol_syslog(
'Bad value for field with code='.$code.
'. Try to redefine export.', LOG_WARNING);
209 $newvalue = $array_export_fields_label[$code];
211 $newvalue = $outputlangs->transnoentitiesnoconv($newvalue);
217 $decodedlabel = $newvalue;
220 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
223 fwrite($this->handle, $newvalue.$this->separator);
224 $typefield = isset($array_types[$code]) ? $array_types[$code] :
'';
226 if (preg_match(
'/^Select:/i', $typefield) && $typefield = substr($typefield, 7)) {
229 $selectlabel[$code.
"_label"] =
csvClean($decodedlabel.
"_label", $outputlangs->charset_output, $this->separator);
233 foreach ($selectlabel as $key => $value) {
234 fwrite($this->handle, $value.$this->separator);
236 fwrite($this->handle,
"\n");
251 public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
260 $selectlabelvalues = array();
261 foreach ($array_selected_sorted as $code => $value) {
262 if (strpos($code,
' as ') == 0) {
263 $alias = str_replace(array(
'.',
'-',
'(',
')'),
'_', $code);
265 $alias = substr($code, strpos($code,
' as ') + 4);
268 dol_syslog(
'Bad value for field with code='.$code.
'. Try to redefine export.', LOG_WARNING);
272 $newvalue = $objp->$alias;
273 $typefield = isset($array_types[$code]) ? $array_types[$code] :
'';
276 if ($newvalue !==
null && preg_match(
'/^\((.*)\)$/i', (
string) $newvalue, $reg)) {
277 $newvalue = $outputlangs->transnoentities($reg[1]);
279 $rawvalue = (string) $newvalue;
282 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
283 $newvalue =
csvClean($rawvalue, $outputlangs->charset_output, $this->separator);
285 if (preg_match(
'/^Select:/i', $typefield) && $typefield = substr($typefield, 7)) {
287 if (is_array($array) && $rawvalue !==
'') {
288 $options = (isset($array[
'options']) && is_array($array[
'options'])) ? $array[
'options'] : array();
289 $selectlabelvalues[$code.
"_label"] =
csvClean(isset($options[$rawvalue]) ? (
string) $options[$rawvalue] :
'', $outputlangs->charset_output, $this->separator);
291 $selectlabelvalues[$code.
"_label"] =
"";
295 fwrite($this->handle, $newvalue.$this->separator);
298 foreach ($selectlabelvalues as $key => $value) {
299 fwrite($this->handle, $value.$this->separator);
303 fwrite($this->handle,
"\n");