38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
51 public static $EXPORT_TYPE_CONFIGURABLE = 1;
52 public static $EXPORT_TYPE_AGIRIS = 10;
53 public static $EXPORT_TYPE_EBP = 15;
54 public static $EXPORT_TYPE_CEGID = 20;
55 public static $EXPORT_TYPE_COGILOG = 25;
56 public static $EXPORT_TYPE_COALA = 30;
57 public static $EXPORT_TYPE_BOB50 = 35;
58 public static $EXPORT_TYPE_CIEL = 40;
59 public static $EXPORT_TYPE_SAGE50_SWISS = 45;
60 public static $EXPORT_TYPE_CHARLEMAGNE = 50;
61 public static $EXPORT_TYPE_QUADRATUS = 60;
62 public static $EXPORT_TYPE_WINFIC = 70;
63 public static $EXPORT_TYPE_OPENCONCERTO = 100;
64 public static $EXPORT_TYPE_LDCOMPTA = 110;
65 public static $EXPORT_TYPE_LDCOMPTA10 = 120;
66 public static $EXPORT_TYPE_GESTIMUMV3 = 130;
67 public static $EXPORT_TYPE_GESTIMUMV5 = 135;
68 public static $EXPORT_TYPE_ISUITEEXPERT = 200;
70 public static $EXPORT_TYPE_FEC = 1000;
71 public static $EXPORT_TYPE_FEC2 = 1010;
81 public $errors = array();
87 public $separator =
'';
93 public $end_line =
'';
102 global $conf, $hookmanager;
105 $this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
106 $this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ?
"\n" : ($conf->global->ACCOUNTING_EXPORT_ENDLINE == 1 ?
"\n" :
"\r\n");
108 $hookmanager->initHooks(array(
'accountancyexport'));
118 global $langs, $hookmanager;
120 $listofexporttypes = array(
121 self::$EXPORT_TYPE_CONFIGURABLE => $langs->trans(
'Modelcsv_configurable'),
122 self::$EXPORT_TYPE_CEGID => $langs->trans(
'Modelcsv_CEGID'),
123 self::$EXPORT_TYPE_COALA => $langs->trans(
'Modelcsv_COALA'),
124 self::$EXPORT_TYPE_BOB50 => $langs->trans(
'Modelcsv_bob50'),
125 self::$EXPORT_TYPE_CIEL => $langs->trans(
'Modelcsv_ciel'),
126 self::$EXPORT_TYPE_QUADRATUS => $langs->trans(
'Modelcsv_quadratus'),
127 self::$EXPORT_TYPE_WINFIC => $langs->trans(
'Modelcsv_winfic'),
128 self::$EXPORT_TYPE_EBP => $langs->trans(
'Modelcsv_ebp'),
129 self::$EXPORT_TYPE_COGILOG => $langs->trans(
'Modelcsv_cogilog'),
130 self::$EXPORT_TYPE_AGIRIS => $langs->trans(
'Modelcsv_agiris'),
131 self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans(
'Modelcsv_openconcerto'),
132 self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans(
'Modelcsv_Sage50_Swiss'),
133 self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans(
'Modelcsv_charlemagne'),
134 self::$EXPORT_TYPE_LDCOMPTA => $langs->trans(
'Modelcsv_LDCompta'),
135 self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans(
'Modelcsv_LDCompta10'),
136 self::$EXPORT_TYPE_GESTIMUMV3 => $langs->trans(
'Modelcsv_Gestinumv3'),
137 self::$EXPORT_TYPE_GESTIMUMV5 => $langs->trans(
'Modelcsv_Gestinumv5'),
138 self::$EXPORT_TYPE_FEC => $langs->trans(
'Modelcsv_FEC'),
139 self::$EXPORT_TYPE_FEC2 => $langs->trans(
'Modelcsv_FEC2'),
140 self::$EXPORT_TYPE_ISUITEEXPERT =>
'Export iSuite Expert',
144 $parameters = array();
145 $reshook = $hookmanager->executeHooks(
'getType', $parameters, $listofexporttypes);
147 ksort($listofexporttypes, SORT_NUMERIC);
149 return $listofexporttypes;
161 self::$EXPORT_TYPE_CONFIGURABLE =>
'csv',
162 self::$EXPORT_TYPE_CEGID =>
'cegid',
163 self::$EXPORT_TYPE_COALA =>
'coala',
164 self::$EXPORT_TYPE_BOB50 =>
'bob50',
165 self::$EXPORT_TYPE_CIEL =>
'ciel',
166 self::$EXPORT_TYPE_QUADRATUS =>
'quadratus',
167 self::$EXPORT_TYPE_WINFIC =>
'winfic',
168 self::$EXPORT_TYPE_EBP =>
'ebp',
169 self::$EXPORT_TYPE_COGILOG =>
'cogilog',
170 self::$EXPORT_TYPE_AGIRIS =>
'agiris',
171 self::$EXPORT_TYPE_OPENCONCERTO =>
'openconcerto',
172 self::$EXPORT_TYPE_SAGE50_SWISS =>
'sage50ch',
173 self::$EXPORT_TYPE_CHARLEMAGNE =>
'charlemagne',
174 self::$EXPORT_TYPE_LDCOMPTA =>
'ldcompta',
175 self::$EXPORT_TYPE_LDCOMPTA10 =>
'ldcompta10',
176 self::$EXPORT_TYPE_GESTIMUMV3 =>
'gestimumv3',
177 self::$EXPORT_TYPE_GESTIMUMV5 =>
'gestimumv5',
178 self::$EXPORT_TYPE_FEC =>
'fec',
179 self::$EXPORT_TYPE_FEC2 =>
'fec2',
180 self::$EXPORT_TYPE_ISUITEEXPERT =>
'isuiteexpert',
184 $code = $formatcode[$type];
185 $parameters = array(
'type' => $type);
186 $reshook = $hookmanager->executeHooks(
'getFormatCode', $parameters, $code);
198 global $conf, $langs;
200 $exporttypes = array(
202 self::$EXPORT_TYPE_CONFIGURABLE => array(
203 'label' => $langs->trans(
'Modelcsv_configurable'),
204 'ACCOUNTING_EXPORT_FORMAT' => empty($conf->global->ACCOUNTING_EXPORT_FORMAT) ?
'txt' : $conf->global->ACCOUNTING_EXPORT_FORMAT,
205 'ACCOUNTING_EXPORT_SEPARATORCSV' => empty($conf->global->ACCOUNTING_EXPORT_SEPARATORCSV) ?
',' : $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV,
206 'ACCOUNTING_EXPORT_ENDLINE' => empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? 1 : $conf->global->ACCOUNTING_EXPORT_ENDLINE,
209 self::$EXPORT_TYPE_CEGID => array(
210 'label' => $langs->trans(
'Modelcsv_CEGID'),
212 self::$EXPORT_TYPE_COALA => array(
213 'label' => $langs->trans(
'Modelcsv_COALA'),
215 self::$EXPORT_TYPE_BOB50 => array(
216 'label' => $langs->trans(
'Modelcsv_bob50'),
218 self::$EXPORT_TYPE_CIEL => array(
219 'label' => $langs->trans(
'Modelcsv_ciel'),
220 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
222 self::$EXPORT_TYPE_QUADRATUS => array(
223 'label' => $langs->trans(
'Modelcsv_quadratus'),
224 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
226 self::$EXPORT_TYPE_WINFIC => array(
227 'label' => $langs->trans(
'Modelcsv_winfic'),
228 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
230 self::$EXPORT_TYPE_EBP => array(
231 'label' => $langs->trans(
'Modelcsv_ebp'),
233 self::$EXPORT_TYPE_COGILOG => array(
234 'label' => $langs->trans(
'Modelcsv_cogilog'),
236 self::$EXPORT_TYPE_AGIRIS => array(
237 'label' => $langs->trans(
'Modelcsv_agiris'),
239 self::$EXPORT_TYPE_OPENCONCERTO => array(
240 'label' => $langs->trans(
'Modelcsv_openconcerto'),
242 self::$EXPORT_TYPE_SAGE50_SWISS => array(
243 'label' => $langs->trans(
'Modelcsv_Sage50_Swiss'),
245 self::$EXPORT_TYPE_CHARLEMAGNE => array(
246 'label' => $langs->trans(
'Modelcsv_charlemagne'),
247 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
249 self::$EXPORT_TYPE_LDCOMPTA => array(
250 'label' => $langs->trans(
'Modelcsv_LDCompta'),
252 self::$EXPORT_TYPE_LDCOMPTA10 => array(
253 'label' => $langs->trans(
'Modelcsv_LDCompta10'),
255 self::$EXPORT_TYPE_GESTIMUMV3 => array(
256 'label' => $langs->trans(
'Modelcsv_Gestinumv3'),
257 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
259 self::$EXPORT_TYPE_GESTIMUMV5 => array(
260 'label' => $langs->trans(
'Modelcsv_Gestinumv5'),
261 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
263 self::$EXPORT_TYPE_FEC => array(
264 'label' => $langs->trans(
'Modelcsv_FEC'),
265 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
267 self::$EXPORT_TYPE_FEC2 => array(
268 'label' => $langs->trans(
'Modelcsv_FEC2'),
269 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
271 self::$EXPORT_TYPE_ISUITEEXPERT => array(
272 'label' =>
'iSuite Expert',
273 'ACCOUNTING_EXPORT_FORMAT' =>
'csv',
277 '1' => $langs->trans(
"Unix"),
278 '2' => $langs->trans(
"Windows")
281 'csv' => $langs->trans(
"csv"),
282 'txt' => $langs->trans(
"txt")
287 $parameters = array();
288 $reshook = $hookmanager->executeHooks(
'getTypeConfig', $parameters, $exporttypes);
303 switch ($formatexportset) {
304 case self::$EXPORT_TYPE_FEC:
305 $mime =
'text/tab-separated-values';
330 public function export(&$TData, $formatexportset, $withAttachment = 0, $downloadMode = 0, $outputMode = 0)
332 global $conf, $langs;
333 global $search_date_end;
336 $filename =
'general_ledger-'.$this->getFormatCode($formatexportset);
337 $type_export =
'general_ledger';
340 $completefilename =
'';
342 $exportFileName =
'';
343 $exportFilePath =
'';
344 $archiveFullName =
'';
346 $archiveFileList = array();
347 if ($withAttachment == 1) {
348 if ($downloadMode == 0) {
351 if ($outputMode == 0) {
356 if (!extension_loaded(
'zip')) {
357 $langs->load(
'install');
358 $this->errors[] = $langs->trans(
'ErrorPHPDoesNotSupport',
'ZIP');
364 if ($downloadMode == 0) {
368 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
369 if ($outputMode == 1 || $outputMode == 2) {
370 if ($outputMode == 1) {
372 if (!empty($conf->accounting->multidir_temp[$conf->entity])) {
373 $outputDir = $conf->accounting->multidir_temp[$conf->entity];
375 $outputDir = $conf->accounting->dir_temp;
379 if (!empty($conf->accounting->multidir_output[$conf->entity])) {
380 $outputDir = $conf->accounting->multidir_output[$conf->entity];
382 $outputDir = $conf->accounting->dir_output;
386 $outputDir .=
'/export';
387 $outputDir .=
'/'.dol_sanitizePathName($formatexportset);
390 $this->errors[] = $langs->trans(
'ErrorCanNotCreateDir', $outputDir);
396 if ($outputDir !=
'') {
398 $langs->load(
'errors');
399 $this->errors[] = $langs->trans(
'ErrorDirNotFound', $outputDir);
403 if (!empty($completefilename)) {
405 $exportFileFullName = $completefilename;
406 $exportFileBaseName = basename($exportFileFullName);
407 $exportFileName = pathinfo($exportFileBaseName, PATHINFO_FILENAME);
408 $exportFilePath = $outputDir .
'/' . $exportFileFullName;
409 $exportFile = fopen($exportFilePath,
'w');
411 $this->errors[] = $langs->trans(
'ErrorFileNotFound', $exportFilePath);
415 if ($withAttachment == 1) {
416 $archiveFileList[0] = array(
417 'path' => $exportFilePath,
418 'name' => $exportFileFullName,
422 $archiveFullName = $exportFileName .
'.zip';
423 $archivePath = $outputDir .
'/' . $archiveFullName;
430 switch ($formatexportset) {
431 case self::$EXPORT_TYPE_CONFIGURABLE:
434 case self::$EXPORT_TYPE_CEGID:
437 case self::$EXPORT_TYPE_COALA:
440 case self::$EXPORT_TYPE_BOB50:
443 case self::$EXPORT_TYPE_CIEL:
446 case self::$EXPORT_TYPE_QUADRATUS:
447 $archiveFileList = $this->
exportQuadratus($TData, $exportFile, $archiveFileList, $withAttachment);
449 case self::$EXPORT_TYPE_WINFIC:
452 case self::$EXPORT_TYPE_EBP:
455 case self::$EXPORT_TYPE_COGILOG:
458 case self::$EXPORT_TYPE_AGIRIS:
461 case self::$EXPORT_TYPE_OPENCONCERTO:
464 case self::$EXPORT_TYPE_SAGE50_SWISS:
467 case self::$EXPORT_TYPE_CHARLEMAGNE:
470 case self::$EXPORT_TYPE_LDCOMPTA:
473 case self::$EXPORT_TYPE_LDCOMPTA10:
476 case self::$EXPORT_TYPE_GESTIMUMV3:
479 case self::$EXPORT_TYPE_GESTIMUMV5:
482 case self::$EXPORT_TYPE_FEC:
485 case self::$EXPORT_TYPE_FEC2:
488 case self::$EXPORT_TYPE_ISUITEEXPERT :
493 $parameters = array(
'format' => $formatexportset);
495 $reshook = $hookmanager->executeHooks(
'export', $parameters, $TData);
497 $this->errors[] = $langs->trans(
'accountancy_error_modelnotfound');
503 if ($outputMode == 1 || $outputMode == 2) {
511 if ($withAttachment == 1) {
513 if (!empty($archiveFullName) && !empty($archivePath) && !empty($archiveFileList)) {
515 $downloadFileMimeType =
'application/zip';
516 $downloadFileFullName = $archiveFullName;
517 $downloadFilePath = $archivePath;
520 $archive =
new ZipArchive();
521 $res = $archive->open($archivePath, ZipArchive::OVERWRITE | ZipArchive::CREATE);
524 $this->errors[] = $langs->trans(
'ErrorFileNotFound', $archivePath);
528 foreach ($archiveFileList as $archiveFileArr) {
529 $res = $archive->addFile($archiveFileArr[
'path'], $archiveFileArr[
'name']);
532 $this->errors[] = $langs->trans(
'ErrorArchiveAddFile', $archiveFileArr[
'name']);
546 if ($downloadMode == 1) {
547 if ($withAttachment == 0) {
549 if (!empty($exportFileFullName) && !empty($exportFilePath)) {
550 $downloadFileMimeType = $mimetype;
551 $downloadFileFullName = $exportFileFullName;
552 $downloadFilePath = $exportFilePath;
557 if (!empty($downloadFileMimeType) && !empty($downloadFileFullName) && !empty($downloadFilePath)) {
558 header(
'Content-Type: ' . $downloadFileMimeType);
559 header(
'Content-Disposition: attachment; filename=' . $downloadFileFullName);
560 header(
'Cache-Control: Public, must-revalidate');
561 header(
'Pragma: public');
562 header(
'Content-Length: ' .
dol_filesize($downloadFilePath));
589 foreach ($objectLines as $line) {
594 $tab[] = $date_document;
595 $tab[] = $line->code_journal;
598 $tab[] = $line->sens;
599 $tab[] =
price2fec(abs($line->debit - $line->credit));
603 $output = implode($separator, $tab).$end_line;
605 fwrite($exportFile, $output);
625 foreach ($objectLines as $line) {
629 if ($line->doc_type ==
'customer_invoice') {
631 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
632 $invoice =
new Facture($this->db);
633 $invoice->fetch($line->fk_doc);
635 $refInvoice = $invoice->ref;
636 } elseif ($line->doc_type ==
'supplier_invoice') {
638 require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.facture.class.php';
640 $invoice->fetch($line->fk_doc);
642 $refInvoice = $invoice->ref_supplier;
647 $tab[] = $line->code_journal;
648 $tab[] = $date_document;
649 $tab[] = $refInvoice;
650 if (empty($line->subledger_account)) {
656 $tab[] = $line->label_operation;
657 $tab[] = $date_document;
658 if ($line->sens ==
'D') {
659 $tab[] =
price($line->debit);
661 } elseif ($line->sens ==
'C') {
663 $tab[] =
price($line->credit);
665 $tab[] = $line->doc_ref;
666 $tab[] = $line->label_operation;
668 $output = implode($separator, $tab).$end_line;
670 fwrite($exportFile, $output);
690 foreach ($objectLines as $line) {
695 $tab[] = $date_document;
696 $tab[] = $line->code_journal;
698 $tab[] = $line->piece_num;
699 $tab[] = $line->doc_ref;
700 $tab[] =
price($line->debit);
701 $tab[] =
price($line->credit);
705 $output = implode($separator, $tab).$end_line;
707 fwrite($exportFile, $output);
727 foreach ($objectLines as $line) {
732 $tab[] = $line->piece_num;
733 $tab[] = $date_document;
735 if (empty($line->subledger_account)) {
739 if (substr($line->numero_compte, 0, 3) ==
'411') {
742 if (substr($line->numero_compte, 0, 3) ==
'401') {
748 $tab[] =
price($line->debit);
749 $tab[] =
price($line->credit);
750 $tab[] =
dol_trunc($line->label_operation, 32);
752 $output = implode($separator, $tab).$end_line;
754 fwrite($exportFile, $output);
782 foreach ($objectLines as $line) {
784 if (!empty($line->subledger_account)) {
789 $date_echeance =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
793 $tab[] = str_pad($line->piece_num, 5);
794 $tab[] = str_pad(self::trunc($line->code_journal, 2), 2);
795 $tab[] = str_pad($date_document, 8,
' ', STR_PAD_LEFT);
796 $tab[] = str_pad($date_echeance, 8,
' ', STR_PAD_LEFT);
797 $tab[] = str_pad(self::trunc($line->doc_ref, 12), 12);
798 $tab[] = str_pad(self::trunc($code_compta, 11), 11);
799 $tab[] = str_pad(self::trunc(
dol_string_unaccent($line->doc_ref).dol_string_unaccent($line->label_operation), 25), 25);
800 $tab[] = str_pad(
price2fec(abs($line->debit - $line->credit)), 13,
' ', STR_PAD_LEFT);
801 $tab[] = str_pad($line->sens, 1);
802 $tab[] = str_repeat(
' ', 18);
806 $output = implode($tab).$end_line;
808 fwrite($exportFile, $output);
830 public function exportQuadratus($objectLines, $exportFile =
null, $archiveFileList = array(), $withAttachment = 0)
839 foreach ($objectLines as $line) {
848 $code_compta = $line->numero_compte;
849 if (!empty($line->subledger_account)) {
850 $code_compta = $line->subledger_account;
855 if (!empty($line->subledger_account)) {
856 $tab[
'type_ligne'] =
'C';
857 $tab[
'num_compte'] = str_pad(self::trunc($line->subledger_account, 8), 8);
858 $tab[
'lib_compte'] = str_pad(self::trunc($line->subledger_label, 30), 30);
860 if ($line->doc_type ==
'customer_invoice') {
861 $tab[
'lib_alpha'] = strtoupper(str_pad(
'C'.self::trunc(
dol_string_unaccent($line->subledger_label), 6), 6));
862 $tab[
'filler'] = str_repeat(
' ', 52);
863 $tab[
'coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, 8), 8);
864 } elseif ($line->doc_type ==
'supplier_invoice') {
865 $tab[
'lib_alpha'] = strtoupper(str_pad(
'F'.self::trunc(
dol_string_unaccent($line->subledger_label), 6), 6));
866 $tab[
'filler'] = str_repeat(
' ', 52);
867 $tab[
'coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, 8), 8);
869 $tab[
'filler'] = str_repeat(
' ', 59);
870 $tab[
'coll_compte'] = str_pad(
' ', 8);
873 $tab[
'filler2'] = str_repeat(
' ', 110);
876 if ($line->doc_type ==
'customer_invoice') {
877 $tab[
'type_compte'] =
'C';
878 } elseif ($line->doc_type ==
'supplier_invoice') {
879 $tab[
'type_compte'] =
'F';
881 $tab[
'type_compte'] =
'G';
884 $tab[
'filler3'] = str_repeat(
' ', 235);
886 $tab[
'end_line'] = $end_line;
889 fwrite($exportFile, implode($tab));
896 $tab[
'type_ligne'] =
'M';
897 $tab[
'num_compte'] = str_pad(self::trunc($code_compta, 8), 8);
898 $tab[
'code_journal'] = str_pad(self::trunc($line->code_journal, 2), 2);
899 $tab[
'folio'] =
'000';
904 $tab[
'date_ecriture'] =
dol_print_date($line->doc_date,
'%d%m%y');
905 $tab[
'filler'] =
' ';
906 $tab[
'libelle_ecriture'] = str_pad(self::trunc($line->doc_ref.
' '.$line->label_operation, 20), 20);
921 $tab[
'sens'] = $line->sens;
922 $tab[
'signe_montant'] =
'+';
925 $tab[
'montant'] = str_pad(abs(($line->debit - $line->credit) * 100), 12,
'0', STR_PAD_LEFT);
926 $tab[
'contrepartie'] = str_repeat(
' ', 8);
929 if (!empty($line->date_lim_reglement)) {
931 $tab[
'date_echeance'] =
dol_print_date($line->date_lim_reglement,
'%d%m%y');
933 $tab[
'date_echeance'] =
'000000';
938 $tab[
'lettrage'] = str_repeat(
' ', 2);
939 $tab[
'codestat'] = str_repeat(
' ', 3);
940 $tab[
'num_piece'] = str_pad(self::trunc($line->piece_num, 5), 5);
944 $tab[
'affaire'] = str_repeat(
' ', 10);
945 $tab[
'quantity1'] = str_repeat(
' ', 10);
946 $tab[
'num_piece2'] = str_pad(self::trunc($line->piece_num, 8), 8);
947 $tab[
'devis'] = str_pad($conf->currency, 3);
948 $tab[
'code_journal2'] = str_pad(self::trunc($line->code_journal, 3), 3);
949 $tab[
'filler3'] = str_repeat(
' ', 3);
957 $tab[
'libelle_ecriture2'] = str_pad(self::trunc($line->label_operation, 30), 30);
958 $tab[
'codetva'] = str_repeat(
' ', 2);
962 $tab[
'num_piece3'] = substr(self::trunc($line->doc_ref, 20), -10);
963 $tab[
'reserved'] = str_repeat(
' ', 10);
964 $tab[
'currency_amount'] = str_repeat(
' ', 13);
966 $attachmentFileName =
'';
967 if ($withAttachment == 1) {
968 $attachmentFileKey = trim($line->piece_num);
970 if (!isset($archiveFileList[$attachmentFileKey])) {
973 if ($line->doc_type ==
'customer_invoice') {
974 $objectDirPath = !empty($conf->facture->multidir_output[$conf->entity]) ? $conf->facture->multidir_output[$conf->entity] : $conf->facture->dir_output;
975 } elseif ($line->doc_type ==
'expense_report') {
976 $objectDirPath = !empty($conf->expensereport->multidir_output[$conf->entity]) ? $conf->expensereport->multidir_output[$conf->entity] : $conf->factureexpensereport->dir_output;
977 } elseif ($line->doc_type ==
'supplier_invoice') {
978 $objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output;
980 $arrayofinclusion = array();
981 $arrayofinclusion[] =
'^'.preg_quote($objectFileName,
'/').
'\.pdf$';
982 $fileFoundList =
dol_dir_list($objectDirPath.
'/'.$objectFileName,
'files', 0, implode(
'|', $arrayofinclusion),
'(\.meta|_preview.*\.png)$',
'date', SORT_DESC, 0,
true);
983 if (!empty($fileFoundList)) {
984 $attachmentFileNameTrunc = str_pad(self::trunc($line->piece_num, 8), 8,
'0', STR_PAD_LEFT);
985 foreach ($fileFoundList as $fileFound) {
986 if (strstr($fileFound[
'name'], $objectFileName)) {
987 $fileFoundPath = $objectDirPath.
'/'.$objectFileName.
'/'.$fileFound[
'name'];
988 if (file_exists($fileFoundPath)) {
989 $archiveFileList[$attachmentFileKey] = array(
990 'path' => $fileFoundPath,
991 'name' => $attachmentFileNameTrunc.
'.pdf',
1000 if (isset($archiveFileList[$attachmentFileKey])) {
1001 $attachmentFileName = $archiveFileList[$attachmentFileKey][
'name'];
1005 $tab[
'attachment'] = $attachmentFileName;
1007 $tab[
'attachment'] = str_repeat(
' ', 12);
1009 $tab[
'filler4'] = str_repeat(
' ', 38);
1010 $tab[
'end_line'] = $end_line;
1013 fwrite($exportFile, implode($tab));
1015 print implode($tab);
1019 return $archiveFileList;
1045 foreach ($objectLines as $line) {
1046 $code_compta = $line->numero_compte;
1047 if (!empty($line->subledger_account)) {
1048 $code_compta = $line->subledger_account;
1053 $tab[
'code_journal'] = str_pad(
dol_trunc($line->code_journal, 2,
'right',
'UTF-8', 1), 2);
1058 $tab[
'date_operation'] =
dol_print_date($line->doc_date,
'%d%m%Y');
1060 $tab[
'folio'] =
' 1';
1062 $tab[
'num_ecriture'] = str_pad(
dol_trunc($index, 6,
'right',
'UTF-8', 1), 6,
' ', STR_PAD_LEFT);
1064 $tab[
'jour_ecriture'] =
dol_print_date($line->doc_date,
'%d%m%y');
1066 $tab[
'num_compte'] = str_pad(
dol_trunc($code_compta, 6,
'right',
'UTF-8', 1), 6,
'0');
1068 if ($line->sens ==
'D') {
1069 $tab[
'montant_debit'] = str_pad(number_format($line->debit, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
1071 $tab[
'montant_crebit'] = str_pad(number_format(0, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
1073 $tab[
'montant_debit'] = str_pad(number_format(0, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
1075 $tab[
'montant_crebit'] = str_pad(number_format($line->credit, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
1080 $tab[
'lettrage'] = str_repeat(
dol_trunc($line->lettering_code, 2,
'left',
'UTF-8', 1), 2);
1082 $tab[
'code_piece'] = str_pad(
dol_trunc($line->piece_num, 5,
'left',
'UTF-8', 1), 5,
' ', STR_PAD_LEFT);
1084 $tab[
'code_stat'] = str_repeat(
' ', 4);
1086 if (!empty($line->date_lim_reglement)) {
1088 $tab[
'date_echeance'] =
dol_print_date($line->date_lim_reglement,
'%d%m%Y');
1090 $tab[
'date_echeance'] =
dol_print_date($line->doc_date,
'%d%m%Y');
1093 $tab[
'monnaie'] =
'1';
1095 $tab[
'filler'] =
' ';
1097 $tab[
'ind_compteur'] =
' ';
1099 $tab[
'quantite'] =
'0,000000000';
1101 $tab[
'code_pointage'] = str_repeat(
' ', 2);
1103 $tab[
'end_line'] = $end_line;
1105 print implode(
'|', $tab);
1125 foreach ($objectLines as $line) {
1131 $tab[] = $date_document;
1132 $tab[] = $line->code_journal;
1133 if (empty($line->subledger_account)) {
1134 $tab[] = $line->numero_compte;
1136 $tab[] = $line->subledger_account;
1139 $tab[] =
'"'.dol_trunc($line->label_operation, 40,
'right',
'UTF-8', 1).
'"';
1140 $tab[] =
'"'.dol_trunc($line->piece_num, 15,
'right',
'UTF-8', 1).
'"';
1141 $tab[] =
price2num(abs($line->debit - $line->credit));
1142 $tab[] = $line->sens;
1143 $tab[] = $date_document;
1146 $output = implode($separator, $tab).$end_line;
1148 fwrite($exportFile, $output);
1168 foreach ($objectLines as $line) {
1173 $tab[] = $line->piece_num;
1175 $tab[] = $date_document;
1178 if (empty($line->subledger_account)) {
1187 $tab[] =
price($line->debit);
1188 $tab[] =
price($line->credit);
1189 $tab[] =
price(abs($line->debit - $line->credit));
1190 $tab[] = $line->sens;
1191 $tab[] = $line->lettering_code;
1192 $tab[] = $line->code_journal;
1194 $output = implode($separator, $tab).$end_line;
1196 fwrite($exportFile, $output);
1215 foreach ($objectLines as $line) {
1220 $tab[] = $date_document;
1221 $tab[] = $line->code_journal;
1222 if (empty($line->subledger_account)) {
1227 $tab[] = $line->doc_ref;
1228 $tab[] = $line->label_operation;
1229 $tab[] =
price($line->debit);
1230 $tab[] =
price($line->credit);
1232 $output = implode($separator, $tab).$end_line;
1234 fwrite($exportFile, $output);
1252 $separator = $this->separator;
1254 foreach ($objectLines as $line) {
1255 $date_document =
dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
1259 $tab[] = $line->piece_num;
1260 $tab[] = $date_document;
1261 $tab[] = $line->doc_ref;
1262 $tab[] = preg_match(
'/'.$separator.
'/', $line->label_operation) ?
"'".$line->label_operation.
"'" : $line->label_operation;
1267 $tab[] =
price2num($line->debit - $line->credit);
1268 $tab[] = $line->code_journal;
1270 $output = implode($separator, $tab).$this->end_line;
1272 fwrite($exportFile, $output);
1294 $tab[] =
"JournalCode";
1295 $tab[] =
"JournalLib";
1296 $tab[] =
"EcritureNum";
1297 $tab[] =
"EcritureDate";
1298 $tab[] =
"CompteNum";
1299 $tab[] =
"CompteLib";
1300 $tab[] =
"CompAuxNum";
1301 $tab[] =
"CompAuxLib";
1302 $tab[] =
"PieceRef";
1303 $tab[] =
"PieceDate";
1304 $tab[] =
"EcritureLib";
1307 $tab[] =
"EcritureLet";
1309 $tab[] =
"ValidDate";
1310 $tab[] =
"Montantdevise";
1312 $tab[] =
"DateLimitReglmt";
1313 $tab[] =
"NumFacture";
1315 $output = implode($separator, $tab).$end_line;
1317 fwrite($exportFile, $output);
1322 foreach ($objectLines as $line) {
1323 if ($line->debit == 0 && $line->credit == 0) {
1328 $date_lettering =
dol_print_date($line->date_lettering,
'%Y%m%d');
1329 $date_validation =
dol_print_date($line->date_validation,
'%Y%m%d');
1330 $date_limit_payment =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1333 if ($line->doc_type ==
'customer_invoice') {
1335 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1336 $invoice =
new Facture($this->db);
1337 $invoice->fetch($line->fk_doc);
1339 $refInvoice = $invoice->ref;
1340 } elseif ($line->doc_type ==
'supplier_invoice') {
1342 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1344 $invoice->fetch($line->fk_doc);
1346 $refInvoice = $invoice->ref_supplier;
1352 $tab[] = $line->code_journal;
1357 $tab[] = $labeljournal;
1360 $tab[] = $line->piece_num;
1363 $tab[] = $date_document;
1378 $tab[] = $line->doc_ref;
1385 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1395 $tab[] = $line->lettering_code;
1398 $tab[] = $date_lettering;
1401 $tab[] = $date_validation;
1404 $tab[] = $line->multicurrency_amount;
1407 $tab[] = $line->multicurrency_code;
1410 $tab[] = $date_limit_payment;
1414 $refInvoice = str_replace(array(
"\t",
"\n",
"\r"),
" ", $refInvoice);
1415 $tab[] =
dol_trunc(self::toAnsi($refInvoice), 17,
'right',
'UTF-8', 1);
1417 $output = implode($separator, $tab).$end_line;
1419 fwrite($exportFile, $output);
1442 $tab[] =
"JournalCode";
1443 $tab[] =
"JournalLib";
1444 $tab[] =
"EcritureNum";
1445 $tab[] =
"EcritureDate";
1446 $tab[] =
"CompteNum";
1447 $tab[] =
"CompteLib";
1448 $tab[] =
"CompAuxNum";
1449 $tab[] =
"CompAuxLib";
1450 $tab[] =
"PieceRef";
1451 $tab[] =
"PieceDate";
1452 $tab[] =
"EcritureLib";
1455 $tab[] =
"EcritureLet";
1457 $tab[] =
"ValidDate";
1458 $tab[] =
"Montantdevise";
1460 $tab[] =
"DateLimitReglmt";
1461 $tab[] =
"NumFacture";
1463 $output = implode($separator, $tab).$end_line;
1465 fwrite($exportFile, $output);
1470 foreach ($objectLines as $line) {
1471 if ($line->debit == 0 && $line->credit == 0) {
1476 $date_lettering =
dol_print_date($line->date_lettering,
'%Y%m%d');
1477 $date_validation =
dol_print_date($line->date_validation,
'%Y%m%d');
1478 $date_limit_payment =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1481 if ($line->doc_type ==
'customer_invoice') {
1483 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1484 $invoice =
new Facture($this->db);
1485 $invoice->fetch($line->fk_doc);
1487 $refInvoice = $invoice->ref;
1488 } elseif ($line->doc_type ==
'supplier_invoice') {
1490 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1492 $invoice->fetch($line->fk_doc);
1494 $refInvoice = $invoice->ref_supplier;
1500 $tab[] = $line->code_journal;
1505 $tab[] = $labeljournal;
1508 $tab[] = $line->piece_num;
1511 $tab[] = $date_creation;
1526 $tab[] = $line->doc_ref;
1529 $tab[] = $date_document;
1533 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1543 $tab[] = $line->lettering_code;
1546 $tab[] = $date_lettering;
1549 $tab[] = $date_validation;
1552 $tab[] = $line->multicurrency_amount;
1555 $tab[] = $line->multicurrency_code;
1558 $tab[] = $date_limit_payment;
1562 $refInvoice = str_replace(array(
"\t",
"\n",
"\r"),
" ", $refInvoice);
1563 $tab[] =
dol_trunc(self::toAnsi($refInvoice), 17,
'right',
'UTF-8', 1);
1565 $output = implode($separator, $tab).$end_line;
1567 fwrite($exportFile, $output);
1608 $tab[] =
"FW-Betrag";
1615 $output = implode($separator, $tab).$end_line;
1617 fwrite($exportFile, $output);
1623 $thisPieceAccountNr =
"";
1624 $aSize = count($objectLines);
1625 foreach ($objectLines as $aIndex => $line) {
1626 $sammelBuchung =
false;
1627 if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) {
1628 $sammelBuchung =
true;
1629 } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) {
1630 $sammelBuchung =
true;
1631 } elseif ($aIndex + 1 < $aSize
1632 && $objectLines[$aIndex + 1]->piece_num == $line->piece_num
1633 && $aIndex - 1 < $aSize
1634 && $objectLines[$aIndex - 1]->piece_num == $line->piece_num
1636 $sammelBuchung =
true;
1642 $tab[] = $line->piece_num;
1646 $tab[] = $date_document;
1651 if ($line->sens ==
'D') {
1659 if (empty($line->code_tiers)) {
1660 if ($line->piece_num == $thisPieceNum) {
1669 $tab[] = $this->separator;
1678 if ($sammelBuchung) {
1686 $tab[] = abs($line->debit - $line->credit);
1693 if ($line1 ==
"LIQ" || $line1 ==
"LIQ Beleg ok" || strlen($line1) <= 3) {
1697 if (strlen($line1) == 0) {
1701 if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) {
1702 $line1 = $line1.
' / '.$line2;
1706 $tab[] =
'"'.self::toAnsi($line1).
'"';
1708 $tab[] =
'"'.self::toAnsi($line2).
'"';
1712 $tab[] = $this->separator;
1717 $output = implode($separator, $tab).$end_line;
1719 fwrite($exportFile, $output);
1724 if ($line->piece_num !== $thisPieceNum) {
1725 $thisPieceNum = $line->piece_num;
1726 $thisPieceAccountNr = $line->numero_compte;
1745 foreach ($objectLines as $line) {
1748 $date_lim_reglement =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1753 $type_enregistrement =
'E';
1754 $tab[] = $type_enregistrement;
1756 $tab[] = substr($line->code_journal, 0, 2);
1760 $tab[] = $line->piece_num;
1762 $tab[] = $date_document;
1764 $tab[] = $line->label_operation;
1766 $tab[] = $date_lim_reglement;
1768 if ($line->doc_type ==
'supplier_invoice') {
1769 if (($line->debit - $line->credit) > 0) {
1770 $nature_piece =
'AF';
1772 $nature_piece =
'FF';
1774 } elseif ($line->doc_type ==
'customer_invoice') {
1775 if (($line->debit - $line->credit) < 0) {
1776 $nature_piece =
'AC';
1778 $nature_piece =
'FC';
1783 $tab[] = $nature_piece;
1794 $racine_subledger_account =
'';
1797 $tab[] = $racine_subledger_account;
1799 $tab[] =
price(abs($line->debit - $line->credit), 0,
'', 1, 2, 2);
1801 $tab[] = $line->sens;
1805 $tab[] = $date_creation;
1807 $tab[] = $line->lettering_code;
1809 $tab[] = $line->date_lettering;
1811 if (!empty($line->subledger_account)) {
1817 if ($line->doc_type ==
'supplier_invoice' && !empty($line->subledger_account)) {
1819 } elseif ($line->doc_type ==
'customer_invoice' && !empty($line->subledger_account)) {
1833 $tab[] = $line->doc_ref;
1861 $output = implode($separator, $tab).$end_line;
1863 fwrite($exportFile, $output);
1882 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
1886 $last_codeinvoice =
'';
1888 foreach ($objectLines as $line) {
1890 if ($last_codeinvoice != $line->doc_ref) {
1892 $sql =
"SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX.
"societe";
1893 $sql .=
" WHERE code_client = '".$this->db->escape($line->thirdparty_code).
"'";
1894 $resql = $this->db->query(
$sql);
1896 if ($resql && $this->db->num_rows($resql) > 0) {
1897 $soc = $this->db->fetch_object($resql);
1899 $address = array(
'',
'',
'');
1900 if (strpos($soc->address,
"\n") !==
false) {
1901 $address = explode(
"\n", $soc->address);
1902 if (is_array($address) && count($address) > 0) {
1903 foreach ($address as $key => $data) {
1904 $address[$key] = str_replace(array(
"\t",
"\n",
"\r"),
"", $data);
1905 $address[$key] =
dol_trunc($address[$key], 40,
'right',
'UTF-8', 1);
1909 $address[0] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 0, 40);
1910 $address[1] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 41, 40);
1911 $address[2] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 82, 40);
1916 $type_enregistrement =
'C';
1918 $tab[] = $type_enregistrement;
1920 $tab[] = $soc->code_client;
1930 $tab[] = $address[0];
1932 $tab[] = $address[1];
1934 $tab[] = $address[2];
1938 $tab[] = substr($soc->town, 0, 40);
1942 $tab[] = substr(
getCountry($soc->fk_pays), 0, 40);
1944 $tab[] = $soc->phone;
1956 $tab[] = str_replace(
" ",
"", $soc->siret);
2014 $output = implode($separator, $tab).$end_line;
2016 fwrite($exportFile, $output);
2027 $date_lim_reglement =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
2030 $type_enregistrement =
'E';
2031 $tab[] = $type_enregistrement;
2033 $tab[] = substr($line->code_journal, 0, 2);
2037 $tab[] = $line->piece_num;
2039 $tab[] = $date_document;
2041 $tab[] =
dol_trunc($line->label_operation, 25,
'right',
'UTF-8', 1);
2043 $tab[] = $date_lim_reglement;
2045 if ($line->doc_type ==
'supplier_invoice') {
2046 if (($line->amount) < 0) {
2047 $nature_piece =
'AF';
2049 $nature_piece =
'FF';
2051 } elseif ($line->doc_type ==
'customer_invoice') {
2052 if (($line->amount) < 0) {
2053 $nature_piece =
'AC';
2055 $nature_piece =
'FC';
2060 $tab[] = $nature_piece;
2071 $racine_subledger_account =
'';
2074 $tab[] = $racine_subledger_account;
2076 $tab[] =
price(abs($line->debit - $line->credit), 0,
'', 1, 2);
2078 $tab[] = $line->sens;
2082 $tab[] = $date_document;
2084 $tab[] = $line->lettering_code;
2086 $tab[] = $line->date_lettering;
2088 if (!empty($line->subledger_account)) {
2094 if ($line->doc_type ==
'supplier_invoice' && !empty($line->subledger_account)) {
2096 } elseif ($line->doc_type ==
'customer_invoice' && !empty($line->subledger_account)) {
2108 $tab[] = $line->doc_ref;
2142 $output = implode($separator, $tab).$end_line;
2144 fwrite($exportFile, $output);
2149 $last_codeinvoice = $line->doc_ref;
2163 $langs->load(
'compta');
2170 $tab[] = $langs->transnoentitiesnoconv(
'Date');
2171 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'Journal'), 6);
2172 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'Account'), 15);
2173 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'LabelAccount'), 60);
2174 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'Piece'), 20);
2175 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'LabelOperation'), 60);
2176 $tab[] = $langs->transnoentitiesnoconv(
'Amount');
2178 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 1', 15);
2179 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 1', 60);
2180 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 2', 15);
2181 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 2', 60);
2182 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 3', 15);
2183 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 3', 60);
2185 $output = implode($separator, $tab).$end_line;
2187 fwrite($exportFile, $output);
2192 foreach ($objectLines as $line) {
2197 $tab[] = $date_document;
2201 if (!empty($line->subledger_account)) {
2202 $account = $line->subledger_account;
2204 $account = $line->numero_compte;
2211 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
2213 $tab[] =
price(abs($line->debit - $line->credit));
2214 $tab[] = $line->sens;
2222 $output = implode($separator, $tab).$end_line;
2224 fwrite($exportFile, $output);
2245 $invoices_infos = array();
2246 $supplier_invoices_infos = array();
2247 foreach ($objectLines as $line) {
2248 if ($line->debit == 0 && $line->credit == 0) {
2252 $date_echeance =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
2254 $invoice_ref = $line->doc_ref;
2257 if (($line->doc_type ==
'customer_invoice' || $line->doc_type ==
'supplier_invoice') && $line->fk_doc > 0) {
2258 if (($line->doc_type ==
'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) ||
2259 ($line->doc_type ==
'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) {
2260 if ($line->doc_type ==
'customer_invoice') {
2262 $sql =
'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX .
'facture as f';
2263 $sql .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe AS s ON f.fk_soc = s.rowid';
2264 $sql .=
' WHERE f.rowid = '.((int) $line->fk_doc);
2265 $resql = $this->db->query(
$sql);
2267 if ($obj = $this->db->fetch_object($resql)) {
2269 $invoices_infos[$line->fk_doc] = array(
'ref' => $obj->ref,
'company_name' => $obj->nom);
2270 $invoice_ref = $obj->ref;
2271 $company_name = $obj->nom;
2276 $sql =
'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX .
'facture_fourn as ff';
2277 $sql .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe AS s ON ff.fk_soc = s.rowid';
2278 $sql .=
' WHERE ff.rowid = '.((int) $line->fk_doc);
2279 $resql = $this->db->query(
$sql);
2281 if ($obj = $this->db->fetch_object($resql)) {
2283 $supplier_invoices_infos[$line->fk_doc] = array(
'ref' => $obj->ref,
'company_name' => $obj->nom);
2284 $invoice_ref = $obj->ref;
2285 $company_name = $obj->nom;
2289 } elseif ($line->doc_type ==
'customer_invoice') {
2291 $invoice_ref = $invoices_infos[$line->fk_doc][
'ref'];
2292 $company_name = $invoices_infos[$line->fk_doc][
'company_name'];
2295 $invoice_ref = $supplier_invoices_infos[$line->fk_doc][
'ref'];
2296 $company_name = $supplier_invoices_infos[$line->fk_doc][
'company_name'];
2303 $tab[] = $date_document;
2304 $tab[] = substr($line->code_journal, 0, 4);
2306 if ((substr($line->numero_compte, 0, 3) ==
'411') || (substr($line->numero_compte, 0, 3) ==
'401')) {
2315 $tab[] =
dol_trunc(str_replace(
'"',
'', $invoice_ref . (!empty($company_name) ?
' - ' :
'') . $company_name), 40,
'right',
'UTF-8', 1);
2317 $tab[] =
dol_trunc(str_replace(
'"',
'', $line->piece_num), 10,
'right',
'UTF-8', 1);
2321 $tab[] =
price2num(abs($line->debit - $line->credit));
2323 $tab[] = $line->sens;
2327 $tab[] = $date_echeance;
2329 $output = implode($separator, $tab).$end_line;
2331 fwrite($exportFile, $output);
2352 foreach ($objectLines as $line) {
2353 if ($line->debit == 0 && $line->credit == 0) {
2361 $tab[] = $date_document;
2362 $tab[] = substr($line->code_journal, 0, 4);
2363 if ((substr($line->numero_compte, 0, 3) ==
'411') || (substr($line->numero_compte, 0, 3) ==
'401')) {
2369 $tab[] =
'"'.dol_trunc(str_replace(
'"',
'', $line->label_operation), 40,
'right',
'UTF-8', 1).
'"';
2370 $tab[] =
'"' .
dol_trunc(str_replace(
'"',
'', $line->doc_ref), 40,
'right',
'UTF-8', 1) .
'"';
2371 $tab[] =
'"' .
dol_trunc(str_replace(
'"',
'', $line->piece_num), 10,
'right',
'UTF-8', 1) .
'"';
2372 $tab[] =
price2num(abs($line->debit - $line->credit));
2373 $tab[] = $line->sens;
2374 $tab[] = $date_document;
2379 $output = implode($separator, $tab).$end_line;
2381 fwrite($exportFile, $output);
2404 foreach ($objectLines as $line) {
2409 $tab[] = $line->piece_num;
2411 $tab[] = substr($date, 6, 4);
2412 $tab[] = substr($date, 3, 2);
2413 $tab[] = substr($date, 0, 2);
2414 $tab[] = $line->doc_ref;
2416 $tab[] = mb_convert_encoding(str_replace(
' - Compte auxiliaire',
'', $line->label_operation),
"Windows-1252",
'UTF-8');
2422 $numero_cpt_client =
'411';
2423 $numero_cpt_fourn =
'401';
2424 for ($i = 1; $i <= ($taille_numero - 3); $i++) {
2425 $numero_cpt_client .=
'0';
2426 $numero_cpt_fourn .=
'0';
2435 $nom_client = explode(
" - ", $line->label_operation);
2436 $tab[] = mb_convert_encoding($nom_client[0],
"Windows-1252",
'UTF-8');
2437 $tab[] =
price($line->debit);
2438 $tab[] =
price($line->credit);
2439 $tab[] =
price($line->montant);
2440 $tab[] = $line->code_journal;
2442 $output = implode($separator, $tab).$end_line;
2444 fwrite($exportFile, $output);
2458 public static function trunc($str, $size)
2460 return dol_trunc($str, $size,
'right',
'UTF-8', 1);
2470 public static function toAnsi($str, $size = -1)
2473 if ($retVal >= 0 && $size >= 0) {
2474 $retVal =
dol_substr($retVal, 0, $size,
'Windows-1251');