218 public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
221 $selectlabel = array();
222 foreach ($array_selected_sorted as $code => $value) {
223 if (strpos($code,
' as ') == 0) {
224 $alias = str_replace(array(
'.',
'-',
'(',
')'),
'_', $code);
226 $alias = substr($code, strpos($code,
' as ') + 4);
229 dol_syslog(
'Bad value for field with code='.$code.
'. Try to redefine export.', LOG_WARNING);
233 $newvalue = $array_export_fields_label[$code];
235 $newvalue = $outputlangs->transnoentitiesnoconv($newvalue);
240 fwrite($this->handle, $newvalue.$this->separator);
241 $typefield = isset($array_types[$code]) ? $array_types[$code] :
'';
243 if (preg_match(
'/^Select:/i', $typefield) && $typefield = substr($typefield, 7)) {
244 $selectlabel[$code.
"_label"] = $newvalue.
"_label";
247 foreach ($selectlabel as $key => $value) {
248 fwrite($this->handle, $value.$this->separator);
250 fwrite($this->handle,
"\n");
265 public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
274 $selectlabelvalues = array();
275 foreach ($array_selected_sorted as $code => $value) {
276 if (strpos($code,
' as ') == 0) {
277 $alias = str_replace(array(
'.',
'-',
'(',
')'),
'_', $code);
279 $alias = substr($code, strpos($code,
' as ') + 4);
282 dol_syslog(
'Bad value for field with code='.$code.
'. Try to redefine export.', LOG_WARNING);
286 $newvalue = $outputlangs->convToOutputCharset($objp->$alias);
287 $typefield = isset($array_types[$code]) ? $array_types[$code] :
'';
290 if (preg_match(
'/^\((.*)\)$/i', $newvalue, $reg)) {
291 $newvalue = $outputlangs->transnoentities($reg[1]);
294 $newvalue = $this->
tsv_clean($newvalue, $outputlangs->charset_output);
296 if (preg_match(
'/^Select:/i', $typefield) && $typefield = substr($typefield, 7)) {
297 $array = jsonOrUnserialize($typefield);
298 if (is_array($array) && !empty($newvalue)) {
299 $array = $array[
'options'];
300 $selectlabelvalues[$code.
"_label"] = $array[$newvalue];
302 $selectlabelvalues[$code.
"_label"] =
"";
306 fwrite($this->handle, $newvalue.$this->separator);
309 foreach ($selectlabelvalues as $key => $value) {
310 fwrite($this->handle, $value.$this->separator);
314 fwrite($this->handle,
"\n");