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';
50 public static $EXPORT_TYPE_CONFIGURABLE = 1;
51 public static $EXPORT_TYPE_AGIRIS = 10;
52 public static $EXPORT_TYPE_EBP = 15;
53 public static $EXPORT_TYPE_CEGID = 20;
54 public static $EXPORT_TYPE_COGILOG = 25;
55 public static $EXPORT_TYPE_COALA = 30;
56 public static $EXPORT_TYPE_BOB50 = 35;
57 public static $EXPORT_TYPE_CIEL = 40;
58 public static $EXPORT_TYPE_SAGE50_SWISS = 45;
59 public static $EXPORT_TYPE_CHARLEMAGNE = 50;
60 public static $EXPORT_TYPE_QUADRATUS = 60;
61 public static $EXPORT_TYPE_WINFIC = 70;
62 public static $EXPORT_TYPE_OPENCONCERTO = 100;
63 public static $EXPORT_TYPE_LDCOMPTA = 110;
64 public static $EXPORT_TYPE_LDCOMPTA10 = 120;
65 public static $EXPORT_TYPE_GESTIMUMV3 = 130;
66 public static $EXPORT_TYPE_GESTIMUMV5 = 135;
67 public static $EXPORT_TYPE_ISUITEEXPERT = 200;
69 public static $EXPORT_TYPE_FEC = 1000;
70 public static $EXPORT_TYPE_FEC2 = 1010;
80 public $errors = array();
86 public $separator =
'';
92 public $end_line =
'';
101 global $conf, $hookmanager;
104 $this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
105 $this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ?
"\n" : ($conf->global->ACCOUNTING_EXPORT_ENDLINE == 1 ?
"\n" :
"\r\n");
107 $hookmanager->initHooks(array(
'accountancyexport'));
117 global $langs, $hookmanager;
119 $listofexporttypes = array(
120 self::$EXPORT_TYPE_CONFIGURABLE => $langs->trans(
'Modelcsv_configurable'),
121 self::$EXPORT_TYPE_CEGID => $langs->trans(
'Modelcsv_CEGID'),
122 self::$EXPORT_TYPE_COALA => $langs->trans(
'Modelcsv_COALA'),
123 self::$EXPORT_TYPE_BOB50 => $langs->trans(
'Modelcsv_bob50'),
124 self::$EXPORT_TYPE_CIEL => $langs->trans(
'Modelcsv_ciel'),
125 self::$EXPORT_TYPE_QUADRATUS => $langs->trans(
'Modelcsv_quadratus'),
126 self::$EXPORT_TYPE_WINFIC => $langs->trans(
'Modelcsv_winfic'),
127 self::$EXPORT_TYPE_EBP => $langs->trans(
'Modelcsv_ebp'),
128 self::$EXPORT_TYPE_COGILOG => $langs->trans(
'Modelcsv_cogilog'),
129 self::$EXPORT_TYPE_AGIRIS => $langs->trans(
'Modelcsv_agiris'),
130 self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans(
'Modelcsv_openconcerto'),
131 self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans(
'Modelcsv_Sage50_Swiss'),
132 self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans(
'Modelcsv_charlemagne'),
133 self::$EXPORT_TYPE_LDCOMPTA => $langs->trans(
'Modelcsv_LDCompta'),
134 self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans(
'Modelcsv_LDCompta10'),
135 self::$EXPORT_TYPE_GESTIMUMV3 => $langs->trans(
'Modelcsv_Gestinumv3'),
136 self::$EXPORT_TYPE_GESTIMUMV5 => $langs->trans(
'Modelcsv_Gestinumv5'),
137 self::$EXPORT_TYPE_FEC => $langs->trans(
'Modelcsv_FEC'),
138 self::$EXPORT_TYPE_FEC2 => $langs->trans(
'Modelcsv_FEC2'),
139 self::$EXPORT_TYPE_ISUITEEXPERT =>
'Export iSuite Expert',
143 $parameters = array();
144 $reshook = $hookmanager->executeHooks(
'getType', $parameters, $listofexporttypes);
146 ksort($listofexporttypes, SORT_NUMERIC);
148 return $listofexporttypes;
160 self::$EXPORT_TYPE_CONFIGURABLE =>
'csv',
161 self::$EXPORT_TYPE_CEGID =>
'cegid',
162 self::$EXPORT_TYPE_COALA =>
'coala',
163 self::$EXPORT_TYPE_BOB50 =>
'bob50',
164 self::$EXPORT_TYPE_CIEL =>
'ciel',
165 self::$EXPORT_TYPE_QUADRATUS =>
'quadratus',
166 self::$EXPORT_TYPE_WINFIC =>
'winfic',
167 self::$EXPORT_TYPE_EBP =>
'ebp',
168 self::$EXPORT_TYPE_COGILOG =>
'cogilog',
169 self::$EXPORT_TYPE_AGIRIS =>
'agiris',
170 self::$EXPORT_TYPE_OPENCONCERTO =>
'openconcerto',
171 self::$EXPORT_TYPE_SAGE50_SWISS =>
'sage50ch',
172 self::$EXPORT_TYPE_CHARLEMAGNE =>
'charlemagne',
173 self::$EXPORT_TYPE_LDCOMPTA =>
'ldcompta',
174 self::$EXPORT_TYPE_LDCOMPTA10 =>
'ldcompta10',
175 self::$EXPORT_TYPE_GESTIMUMV3 =>
'gestimumv3',
176 self::$EXPORT_TYPE_GESTIMUMV5 =>
'gestimumv5',
177 self::$EXPORT_TYPE_FEC =>
'fec',
178 self::$EXPORT_TYPE_FEC2 =>
'fec2',
179 self::$EXPORT_TYPE_ISUITEEXPERT =>
'isuiteexpert',
183 $code = $formatcode[$type];
184 $parameters = array(
'type' => $type);
185 $reshook = $hookmanager->executeHooks(
'getFormatCode', $parameters, $code);
197 global $conf, $langs;
199 $exporttypes = array(
201 self::$EXPORT_TYPE_CONFIGURABLE => array(
202 'label' => $langs->trans(
'Modelcsv_configurable'),
203 'ACCOUNTING_EXPORT_FORMAT' => empty($conf->global->ACCOUNTING_EXPORT_FORMAT) ?
'txt' : $conf->global->ACCOUNTING_EXPORT_FORMAT,
204 'ACCOUNTING_EXPORT_SEPARATORCSV' => empty($conf->global->ACCOUNTING_EXPORT_SEPARATORCSV) ?
',' : $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV,
205 'ACCOUNTING_EXPORT_ENDLINE' => empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? 1 : $conf->global->ACCOUNTING_EXPORT_ENDLINE,
208 self::$EXPORT_TYPE_CEGID => array(
209 'label' => $langs->trans(
'Modelcsv_CEGID'),
211 self::$EXPORT_TYPE_COALA => array(
212 'label' => $langs->trans(
'Modelcsv_COALA'),
214 self::$EXPORT_TYPE_BOB50 => array(
215 'label' => $langs->trans(
'Modelcsv_bob50'),
217 self::$EXPORT_TYPE_CIEL => array(
218 'label' => $langs->trans(
'Modelcsv_ciel'),
219 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
221 self::$EXPORT_TYPE_QUADRATUS => array(
222 'label' => $langs->trans(
'Modelcsv_quadratus'),
223 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
225 self::$EXPORT_TYPE_WINFIC => array(
226 'label' => $langs->trans(
'Modelcsv_winfic'),
227 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
229 self::$EXPORT_TYPE_EBP => array(
230 'label' => $langs->trans(
'Modelcsv_ebp'),
232 self::$EXPORT_TYPE_COGILOG => array(
233 'label' => $langs->trans(
'Modelcsv_cogilog'),
235 self::$EXPORT_TYPE_AGIRIS => array(
236 'label' => $langs->trans(
'Modelcsv_agiris'),
238 self::$EXPORT_TYPE_OPENCONCERTO => array(
239 'label' => $langs->trans(
'Modelcsv_openconcerto'),
241 self::$EXPORT_TYPE_SAGE50_SWISS => array(
242 'label' => $langs->trans(
'Modelcsv_Sage50_Swiss'),
244 self::$EXPORT_TYPE_CHARLEMAGNE => array(
245 'label' => $langs->trans(
'Modelcsv_charlemagne'),
246 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
248 self::$EXPORT_TYPE_LDCOMPTA => array(
249 'label' => $langs->trans(
'Modelcsv_LDCompta'),
251 self::$EXPORT_TYPE_LDCOMPTA10 => array(
252 'label' => $langs->trans(
'Modelcsv_LDCompta10'),
254 self::$EXPORT_TYPE_GESTIMUMV3 => array(
255 'label' => $langs->trans(
'Modelcsv_Gestinumv3'),
256 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
258 self::$EXPORT_TYPE_GESTIMUMV5 => array(
259 'label' => $langs->trans(
'Modelcsv_Gestinumv5'),
260 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
262 self::$EXPORT_TYPE_FEC => array(
263 'label' => $langs->trans(
'Modelcsv_FEC'),
264 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
266 self::$EXPORT_TYPE_FEC2 => array(
267 'label' => $langs->trans(
'Modelcsv_FEC2'),
268 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
270 self::$EXPORT_TYPE_ISUITEEXPERT => array(
271 'label' =>
'iSuite Expert',
272 'ACCOUNTING_EXPORT_FORMAT' =>
'csv',
276 '1' => $langs->trans(
"Unix"),
277 '2' => $langs->trans(
"Windows")
280 'csv' => $langs->trans(
"csv"),
281 'txt' => $langs->trans(
"txt")
286 $parameters = array();
287 $reshook = $hookmanager->executeHooks(
'getTypeConfig', $parameters, $exporttypes);
302 switch ($formatexportset) {
303 case self::$EXPORT_TYPE_FEC:
304 $mime =
'text/tab-separated-values';
322 public function export(&$TData, $formatexportset, $withAttachment = 0)
324 global $conf, $langs;
325 global $search_date_end;
328 $filename =
'general_ledger-'.$this->getFormatCode($formatexportset);
329 $type_export =
'general_ledger';
332 $completefilename =
'';
334 $exportFileName =
'';
335 $exportFilePath =
'';
336 $archiveFileList = array();
337 if ($withAttachment == 1) {
339 if (!extension_loaded(
'zip')) {
340 $langs->load(
'install');
341 $this->errors[] = $langs->trans(
'ErrorPHPDoesNotSupport',
'ZIP');
348 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
349 if ($withAttachment == 1 && !empty($completefilename)) {
351 $tmpDir = !empty($conf->accounting->multidir_temp[$conf->entity]) ? $conf->accounting->multidir_temp[$conf->entity] : $conf->accounting->dir_temp;
352 $exportFileFullName = $completefilename;
353 $exportFileBaseName = basename($exportFileFullName);
354 $exportFileName = pathinfo($exportFileBaseName, PATHINFO_FILENAME);
355 $exportFilePath = $tmpDir.
'/'.$exportFileFullName;
356 $exportFile = fopen($exportFilePath,
'w');
358 $this->errors[] = $langs->trans(
'ErrorFileNotFound', $exportFilePath);
361 $archiveFileList[0] = array(
362 'path' => $exportFilePath,
363 'name' => $exportFileFullName,
367 $archiveFullName = $exportFileName.
'.zip';
368 $archivePath = $tmpDir.
'/'.$archiveFullName;
371 switch ($formatexportset) {
372 case self::$EXPORT_TYPE_CONFIGURABLE:
375 case self::$EXPORT_TYPE_CEGID:
378 case self::$EXPORT_TYPE_COALA:
381 case self::$EXPORT_TYPE_BOB50:
384 case self::$EXPORT_TYPE_CIEL:
387 case self::$EXPORT_TYPE_QUADRATUS:
388 $archiveFileList = $this->
exportQuadratus($TData, $exportFile, $archiveFileList, $withAttachment);
390 case self::$EXPORT_TYPE_WINFIC:
393 case self::$EXPORT_TYPE_EBP:
396 case self::$EXPORT_TYPE_COGILOG:
399 case self::$EXPORT_TYPE_AGIRIS:
402 case self::$EXPORT_TYPE_OPENCONCERTO:
405 case self::$EXPORT_TYPE_SAGE50_SWISS:
408 case self::$EXPORT_TYPE_CHARLEMAGNE:
411 case self::$EXPORT_TYPE_LDCOMPTA:
414 case self::$EXPORT_TYPE_LDCOMPTA10:
417 case self::$EXPORT_TYPE_GESTIMUMV3:
420 case self::$EXPORT_TYPE_GESTIMUMV5:
423 case self::$EXPORT_TYPE_FEC:
426 case self::$EXPORT_TYPE_FEC2:
429 case self::$EXPORT_TYPE_ISUITEEXPERT :
434 $parameters = array(
'format' => $formatexportset);
436 $reshook = $hookmanager->executeHooks(
'export', $parameters, $TData);
438 $this->errors[] = $langs->trans(
'accountancy_error_modelnotfound');
444 if ($withAttachment == 1) {
452 if (!empty($archiveFullName) && !empty($archivePath) && !empty($archiveFileList)) {
454 $downloadFileMimeType =
'application/zip';
455 $downloadFileFullName = $archiveFullName;
456 $downloadFilePath = $archivePath;
459 $archive =
new ZipArchive();
460 $res = $archive->open($archivePath, ZipArchive::OVERWRITE | ZipArchive::CREATE);
463 $this->errors[] = $langs->trans(
'ErrorFileNotFound', $archivePath);
467 foreach ($archiveFileList as $archiveFileArr) {
468 $res = $archive->addFile($archiveFileArr[
'path'], $archiveFileArr[
'name']);
471 $this->errors[] = $langs->trans(
'ErrorArchiveAddFile', $archiveFileArr[
'name']);
480 } elseif (!empty($exportFileFullName) && !empty($exportFilePath)) {
482 $downloadFileMimeType =
'text/csv';
483 $downloadFileFullName = $exportFileFullName;
484 $downloadFilePath = $exportFilePath;
489 if (!empty($downloadFileMimeType) && !empty($downloadFileFullName) && !empty($downloadFilePath)) {
490 header(
'Content-Type: '.$downloadFileMimeType);
491 header(
'Content-Disposition: attachment; filename='.$downloadFileFullName);
492 header(
'Cache-Control: Public, must-revalidate');
493 header(
'Pragma: public');
494 header(
'Content-Length: '.
dol_filesize($downloadFilePath));
516 foreach ($objectLines as $line) {
521 print $date.$separator;
522 print $line->code_journal.$separator;
525 print $line->sens.$separator;
526 print
price2fec(abs($line->debit - $line->credit)).$separator;
541 foreach ($objectLines as $line) {
546 print $line->code_journal.$separator;
547 print $date.$separator;
548 print $line->piece_num.$separator;
551 print $line->label_operation.$separator;
552 print $date.$separator;
553 if ($line->sens ==
'D') {
554 print
price($line->debit).$separator;
556 } elseif ($line->sens ==
'C') {
558 print
price($line->credit).$separator;
560 print $line->doc_ref.$separator;
561 print $line->label_operation.$separator;
578 foreach ($objectLines as $line) {
581 print $date.$separator;
582 print $line->code_journal.$separator;
584 print $line->piece_num.$separator;
585 print $line->doc_ref.$separator;
586 print
price($line->debit).$separator;
587 print
price($line->credit).$separator;
588 print
'E'.$separator;
607 foreach ($objectLines as $line) {
608 print $line->piece_num.$separator;
610 print $date.$separator;
612 if (empty($line->subledger_account)) {
613 print
'G'.$separator;
616 if (substr($line->numero_compte, 0, 3) ==
'411') {
617 print
'C'.$separator;
619 if (substr($line->numero_compte, 0, 3) ==
'401') {
620 print
'F'.$separator;
625 print
price($line->debit).$separator;
626 print
price($line->credit).$separator;
627 print
dol_trunc($line->label_operation, 32).$separator;
652 foreach ($TData as $data) {
654 if (!empty($data->subledger_account)) {
659 $date_echeance =
dol_print_date($data->date_lim_reglement,
'%Y%m%d');
662 $Tab[
'num_ecriture'] = str_pad($data->piece_num, 5);
663 $Tab[
'code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
664 $Tab[
'date_ecriture'] = str_pad($date_document, 8,
' ', STR_PAD_LEFT);
665 $Tab[
'date_echeance'] = str_pad($date_echeance, 8,
' ', STR_PAD_LEFT);
666 $Tab[
'num_piece'] = str_pad(self::trunc($data->doc_ref, 12), 12);
667 $Tab[
'num_compte'] = str_pad(self::trunc($code_compta, 11), 11);
668 $Tab[
'libelle_ecriture'] = str_pad(self::trunc(
dol_string_unaccent($data->doc_ref).dol_string_unaccent($data->label_operation), 25), 25);
669 $Tab[
'montant'] = str_pad(
price2fec(abs($data->debit - $data->credit)), 13,
' ', STR_PAD_LEFT);
670 $Tab[
'type_montant'] = str_pad($data->sens, 1);
671 $Tab[
'vide'] = str_repeat(
' ', 18);
672 $Tab[
'intitule_compte'] = str_pad(self::trunc(
dol_string_unaccent($data->label_operation), 34), 34);
673 $Tab[
'end'] =
'O2003';
675 $Tab[
'end_line'] = $end_line;
696 public function exportQuadratus(&$TData, $exportFile =
null, $archiveFileList = array(), $withAttachment = 0)
705 foreach ($TData as $data) {
714 $code_compta = $data->numero_compte;
715 if (!empty($data->subledger_account)) {
716 $code_compta = $data->subledger_account;
721 if (!empty($data->subledger_account)) {
722 $Tab[
'type_ligne'] =
'C';
723 $Tab[
'num_compte'] = str_pad(self::trunc($data->subledger_account, 8), 8);
724 $Tab[
'lib_compte'] = str_pad(self::trunc($data->subledger_label, 30), 30);
726 if ($data->doc_type ==
'customer_invoice') {
727 $Tab[
'lib_alpha'] = strtoupper(str_pad(
'C'.self::trunc($data->subledger_label, 6), 6));
728 $Tab[
'filler'] = str_repeat(
' ', 52);
729 $Tab[
'coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, 8), 8);
730 } elseif ($data->doc_type ==
'supplier_invoice') {
731 $Tab[
'lib_alpha'] = strtoupper(str_pad(
'F'.self::trunc($data->subledger_label, 6), 6));
732 $Tab[
'filler'] = str_repeat(
' ', 52);
733 $Tab[
'coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, 8), 8);
735 $Tab[
'filler'] = str_repeat(
' ', 59);
736 $Tab[
'coll_compte'] = str_pad(
' ', 8);
739 $Tab[
'filler2'] = str_repeat(
' ', 110);
742 if ($data->doc_type ==
'customer_invoice') {
743 $Tab[
'type_compte'] =
'C';
744 } elseif ($data->doc_type ==
'supplier_invoice') {
745 $Tab[
'type_compte'] =
'F';
747 $Tab[
'type_compte'] =
'G';
750 $Tab[
'filler3'] = str_repeat(
' ', 235);
752 $Tab[
'end_line'] = $end_line;
755 fwrite($exportFile, implode($Tab));
762 $Tab[
'type_ligne'] =
'M';
763 $Tab[
'num_compte'] = str_pad(self::trunc($code_compta, 8), 8);
764 $Tab[
'code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
765 $Tab[
'folio'] =
'000';
770 $Tab[
'date_ecriture'] =
dol_print_date($data->doc_date,
'%d%m%y');
771 $Tab[
'filler'] =
' ';
772 $Tab[
'libelle_ecriture'] = str_pad(self::trunc($data->doc_ref.
' '.$data->label_operation, 20), 20);
787 $Tab[
'sens'] = $data->sens;
788 $Tab[
'signe_montant'] =
'+';
791 $Tab[
'montant'] = str_pad(abs(($data->debit - $data->credit) * 100), 12,
'0', STR_PAD_LEFT);
792 $Tab[
'contrepartie'] = str_repeat(
' ', 8);
795 if (!empty($data->date_lim_reglement)) {
797 $Tab[
'date_echeance'] =
dol_print_date($data->date_lim_reglement,
'%d%m%y');
799 $Tab[
'date_echeance'] =
'000000';
804 $Tab[
'lettrage'] = str_repeat(
' ', 2);
805 $Tab[
'codestat'] = str_repeat(
' ', 3);
806 $Tab[
'num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5);
810 $Tab[
'affaire'] = str_repeat(
' ', 10);
811 $Tab[
'quantity1'] = str_repeat(
' ', 10);
812 $Tab[
'num_piece2'] = str_pad(self::trunc($data->piece_num, 8), 8);
813 $Tab[
'devis'] = str_pad($conf->currency, 3);
814 $Tab[
'code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3);
815 $Tab[
'filler3'] = str_repeat(
' ', 3);
823 $Tab[
'libelle_ecriture2'] = str_pad(self::trunc($data->label_operation, 30), 30);
824 $Tab[
'codetva'] = str_repeat(
' ', 2);
828 $Tab[
'num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10);
829 $Tab[
'reserved'] = str_repeat(
' ', 10);
830 $Tab[
'currency_amount'] = str_repeat(
' ', 13);
832 $attachmentFileName =
'';
833 if ($withAttachment == 1) {
834 $attachmentFileKey = trim($data->piece_num);
836 if (!isset($archiveFileList[$attachmentFileKey])) {
839 if ($data->doc_type ==
'customer_invoice') {
840 $objectDirPath = !empty($conf->facture->multidir_output[$conf->entity]) ? $conf->facture->multidir_output[$conf->entity] : $conf->facture->dir_output;
841 } elseif ($data->doc_type ==
'expense_report') {
842 $objectDirPath = !empty($conf->expensereport->multidir_output[$conf->entity]) ? $conf->expensereport->multidir_output[$conf->entity] : $conf->factureexpensereport->dir_output;
843 } elseif ($data->doc_type ==
'supplier_invoice') {
844 $objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output;
846 $arrayofinclusion = array();
847 $arrayofinclusion[] =
'^'.preg_quote($objectFileName,
'/').
'\.pdf$';
848 $fileFoundList =
dol_dir_list($objectDirPath.
'/'.$objectFileName,
'files', 0, implode(
'|', $arrayofinclusion),
'(\.meta|_preview.*\.png)$',
'date', SORT_DESC, 0,
true);
849 if (!empty($fileFoundList)) {
850 $attachmentFileNameTrunc = str_pad(self::trunc($data->piece_num, 8), 8,
'0', STR_PAD_LEFT);
851 foreach ($fileFoundList as $fileFound) {
852 if (strstr($fileFound[
'name'], $objectFileName)) {
853 $fileFoundPath = $objectDirPath.
'/'.$objectFileName.
'/'.$fileFound[
'name'];
854 if (file_exists($fileFoundPath)) {
855 $archiveFileList[$attachmentFileKey] = array(
856 'path' => $fileFoundPath,
857 'name' => $attachmentFileNameTrunc.
'.pdf',
866 if (isset($archiveFileList[$attachmentFileKey])) {
867 $attachmentFileName = $archiveFileList[$attachmentFileKey][
'name'];
871 $Tab[
'attachment'] = $attachmentFileName;
873 $Tab[
'attachment'] = str_repeat(
' ', 12);
875 $Tab[
'filler4'] = str_repeat(
' ', 38);
876 $Tab[
'end_line'] = $end_line;
879 fwrite($exportFile, implode($Tab));
885 return $archiveFileList;
911 foreach ($TData as $data) {
912 $code_compta = $data->numero_compte;
913 if (!empty($data->subledger_account)) {
914 $code_compta = $data->subledger_account;
919 $Tab[
'code_journal'] = str_pad(
dol_trunc($data->code_journal, 2,
'right',
'UTF-8', 1), 2);
924 $Tab[
'date_operation'] =
dol_print_date($data->doc_date,
'%d%m%Y');
926 $Tab[
'folio'] =
' 1';
928 $Tab[
'num_ecriture'] = str_pad(
dol_trunc($index, 6,
'right',
'UTF-8', 1), 6,
' ', STR_PAD_LEFT);
930 $Tab[
'jour_ecriture'] =
dol_print_date($data->doc_date,
'%d%m%y');
932 $Tab[
'num_compte'] = str_pad(
dol_trunc($code_compta, 6,
'right',
'UTF-8', 1), 6,
'0');
934 if ($data->sens ==
'D') {
935 $Tab[
'montant_debit'] = str_pad(number_format($data->debit, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
937 $Tab[
'montant_crebit'] = str_pad(number_format(0, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
939 $Tab[
'montant_debit'] = str_pad(number_format(0, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
941 $Tab[
'montant_crebit'] = str_pad(number_format($data->credit, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
946 $Tab[
'lettrage'] = str_repeat(
dol_trunc($data->lettering_code, 2,
'left',
'UTF-8', 1), 2);
948 $Tab[
'code_piece'] = str_pad(
dol_trunc($data->piece_num, 5,
'left',
'UTF-8', 1), 5,
' ', STR_PAD_LEFT);
950 $Tab[
'code_stat'] = str_repeat(
' ', 4);
952 if (!empty($data->date_lim_reglement)) {
954 $Tab[
'date_echeance'] =
dol_print_date($data->date_lim_reglement,
'%d%m%Y');
956 $Tab[
'date_echeance'] =
dol_print_date($data->doc_date,
'%d%m%Y');
959 $Tab[
'monnaie'] =
'1';
961 $Tab[
'filler'] =
' ';
963 $Tab[
'ind_compteur'] =
' ';
965 $Tab[
'quantite'] =
'0,000000000';
967 $Tab[
'code_pointage'] = str_repeat(
' ', 2);
969 $Tab[
'end_line'] = $end_line;
971 print implode(
'|', $Tab);
990 foreach ($objectLines as $line) {
993 print $line->id.$separator;
994 print $date.$separator;
995 print $line->code_journal.$separator;
996 if (empty($line->subledger_account)) {
997 print $line->numero_compte.$separator;
999 print $line->subledger_account.$separator;
1002 print
'"'.dol_trunc($line->label_operation, 40,
'right',
'UTF-8', 1).
'"'.$separator;
1003 print
'"'.dol_trunc($line->piece_num, 15,
'right',
'UTF-8', 1).
'"'.$separator;
1004 print
price2num(abs($line->debit - $line->credit)).$separator;
1005 print $line->sens.$separator;
1006 print $date.$separator;
1025 foreach ($objectLines as $line) {
1028 print $line->piece_num.$separator;
1030 print $date.$separator;
1033 if (empty($line->subledger_account)) {
1042 print
price($line->debit).$separator;
1043 print
price($line->credit).$separator;
1044 print
price(abs($line->debit - $line->credit)).$separator;
1045 print $line->sens.$separator;
1046 print $line->lettering_code.$separator;
1047 print $line->code_journal;
1064 foreach ($objectLines as $line) {
1067 print $date.$separator;
1068 print $line->code_journal.$separator;
1069 if (empty($line->subledger_account)) {
1074 print $line->doc_ref.$separator;
1075 print $line->label_operation.$separator;
1076 print
price($line->debit).$separator;
1077 print
price($line->credit).$separator;
1093 $separator = $this->separator;
1095 foreach ($objectLines as $line) {
1098 $date =
dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
1099 $tab[] = $line->piece_num;
1101 $tab[] = $line->doc_ref;
1102 $tab[] = preg_match(
'/'.$separator.
'/', $line->label_operation) ?
"'".$line->label_operation.
"'" : $line->label_operation;
1107 $tab[] =
price2num($line->debit - $line->credit);
1108 $tab[] = $line->code_journal;
1110 print implode($separator, $tab).$this->end_line;
1127 print
"JournalCode".$separator;
1128 print
"JournalLib".$separator;
1129 print
"EcritureNum".$separator;
1130 print
"EcritureDate".$separator;
1131 print
"CompteNum".$separator;
1132 print
"CompteLib".$separator;
1133 print
"CompAuxNum".$separator;
1134 print
"CompAuxLib".$separator;
1135 print
"PieceRef".$separator;
1136 print
"PieceDate".$separator;
1137 print
"EcritureLib".$separator;
1138 print
"Debit".$separator;
1139 print
"Credit".$separator;
1140 print
"EcritureLet".$separator;
1141 print
"DateLet".$separator;
1142 print
"ValidDate".$separator;
1143 print
"Montantdevise".$separator;
1144 print
"Idevise".$separator;
1145 print
"DateLimitReglmt".$separator;
1149 foreach ($objectLines as $line) {
1150 if ($line->debit == 0 && $line->credit == 0) {
1155 $date_lettering =
dol_print_date($line->date_lettering,
'%Y%m%d');
1156 $date_validation =
dol_print_date($line->date_validation,
'%Y%m%d');
1157 $date_limit_payment =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1160 if ($line->doc_type ==
'customer_invoice') {
1162 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1164 $invoice->fetch($line->fk_doc);
1166 $refInvoice = $invoice->ref;
1167 } elseif ($line->doc_type ==
'supplier_invoice') {
1169 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1171 $invoice->fetch($line->fk_doc);
1173 $refInvoice = $invoice->ref_supplier;
1177 print $line->code_journal . $separator;
1182 print $labeljournal . $separator;
1185 print $line->piece_num . $separator;
1188 print $date_document . $separator;
1191 print $line->numero_compte . $separator;
1197 print $line->subledger_account . $separator;
1203 print $line->doc_ref . $separator;
1210 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1214 print
price2fec($line->debit) . $separator;
1217 print
price2fec($line->credit) . $separator;
1220 print $line->lettering_code . $separator;
1223 print $date_lettering . $separator;
1226 print $date_validation . $separator;
1229 print $line->multicurrency_amount . $separator;
1232 print $line->multicurrency_code . $separator;
1235 print $date_limit_payment . $separator;
1239 $refInvoice = str_replace(array(
"\t",
"\n",
"\r"),
" ", $refInvoice);
1240 print
dol_trunc(self::toAnsi($refInvoice), 17,
'right',
'UTF-8', 1);
1260 print
"JournalCode".$separator;
1261 print
"JournalLib".$separator;
1262 print
"EcritureNum".$separator;
1263 print
"EcritureDate".$separator;
1264 print
"CompteNum".$separator;
1265 print
"CompteLib".$separator;
1266 print
"CompAuxNum".$separator;
1267 print
"CompAuxLib".$separator;
1268 print
"PieceRef".$separator;
1269 print
"PieceDate".$separator;
1270 print
"EcritureLib".$separator;
1271 print
"Debit".$separator;
1272 print
"Credit".$separator;
1273 print
"EcritureLet".$separator;
1274 print
"DateLet".$separator;
1275 print
"ValidDate".$separator;
1276 print
"Montantdevise".$separator;
1277 print
"Idevise".$separator;
1278 print
"DateLimitReglmt".$separator;
1282 foreach ($objectLines as $line) {
1283 if ($line->debit == 0 && $line->credit == 0) {
1288 $date_lettering =
dol_print_date($line->date_lettering,
'%Y%m%d');
1289 $date_validation =
dol_print_date($line->date_validation,
'%Y%m%d');
1290 $date_limit_payment =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1293 if ($line->doc_type ==
'customer_invoice') {
1295 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1297 $invoice->fetch($line->fk_doc);
1299 $refInvoice = $invoice->ref;
1300 } elseif ($line->doc_type ==
'supplier_invoice') {
1302 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1304 $invoice->fetch($line->fk_doc);
1306 $refInvoice = $invoice->ref_supplier;
1310 print $line->code_journal . $separator;
1315 print $labeljournal . $separator;
1318 print $line->piece_num . $separator;
1321 print $date_creation . $separator;
1336 print $line->doc_ref . $separator;
1339 print $date_document . $separator;
1343 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1347 print
price2fec($line->debit) . $separator;
1350 print
price2fec($line->credit) . $separator;
1353 print $line->lettering_code . $separator;
1356 print $date_lettering . $separator;
1359 print $date_validation . $separator;
1362 print $line->multicurrency_amount . $separator;
1365 print $line->multicurrency_code . $separator;
1368 print $date_limit_payment . $separator;
1372 $refInvoice = str_replace(array(
"\t",
"\n",
"\r"),
" ", $refInvoice);
1373 print
dol_trunc(self::toAnsi($refInvoice), 17,
'right',
'UTF-8', 1);
1394 $this->separator =
',';
1395 $this->end_line =
"\r\n";
1398 print
"Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag";
1399 print $this->end_line;
1401 $thisPieceAccountNr =
"";
1402 $aSize = count($objectLines);
1403 foreach ($objectLines as $aIndex => $line) {
1404 $sammelBuchung =
false;
1405 if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) {
1406 $sammelBuchung =
true;
1407 } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) {
1408 $sammelBuchung =
true;
1409 } elseif ($aIndex + 1 < $aSize
1410 && $objectLines[$aIndex + 1]->piece_num == $line->piece_num
1411 && $aIndex - 1 < $aSize
1412 && $objectLines[$aIndex - 1]->piece_num == $line->piece_num
1414 $sammelBuchung =
true;
1418 print $line->piece_num.$this->separator;
1422 print $date.$this->separator;
1427 if ($line->sens ==
'D') {
1428 print
'S'.$this->separator;
1430 print
'H'.$this->separator;
1433 print
self::trunc($line->code_journal, 1).$this->separator;
1435 if (empty($line->code_tiers)) {
1436 if ($line->piece_num == $thisPieceNum) {
1439 print
"div".$this->separator;
1445 print $this->separator;
1447 print
"0".$this->separator;
1449 print
"0".$this->separator;
1451 print
"0".$this->separator;
1454 if ($sammelBuchung) {
1455 print
"2".$this->separator;
1457 print
"1".$this->separator;
1460 print
'""'.$this->separator;
1462 print abs($line->debit - $line->credit).$this->separator;
1464 print
"0.00".$this->separator;
1466 print
"0.00".$this->separator;
1469 if ($line1 ==
"LIQ" || $line1 ==
"LIQ Beleg ok" || strlen($line1) <= 3) {
1473 if (strlen($line1) == 0) {
1477 if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) {
1478 $line1 = $line1.
' / '.$line2;
1482 print
'"'.self::toAnsi($line1).
'"'.$this->separator;
1484 print
'"'.self::toAnsi($line2).
'"'.$this->separator;
1486 print
"0".$this->separator;
1488 print $this->separator;
1493 print $this->end_line;
1495 if ($line->piece_num !== $thisPieceNum) {
1496 $thisPieceNum = $line->piece_num;
1497 $thisPieceAccountNr = $line->numero_compte;
1516 foreach ($objectLines as $line) {
1519 $date_lim_reglement =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1522 $type_enregistrement =
'E';
1523 print $type_enregistrement.$separator;
1525 print substr($line->code_journal, 0, 2).$separator;
1527 print $line->id.$separator;
1529 print $line->piece_num.$separator;
1531 print $date_document.$separator;
1533 print $line->label_operation.$separator;
1535 print $date_lim_reglement.$separator;
1537 if ($line->doc_type ==
'supplier_invoice') {
1538 if (($line->debit - $line->credit) > 0) {
1539 $nature_piece =
'AF';
1541 $nature_piece =
'FF';
1543 } elseif ($line->doc_type ==
'customer_invoice') {
1544 if (($line->debit - $line->credit) < 0) {
1545 $nature_piece =
'AC';
1547 $nature_piece =
'FC';
1552 print $nature_piece.$separator;
1563 $racine_subledger_account =
'';
1566 print $racine_subledger_account.$separator;
1568 print
price(abs($line->debit - $line->credit), 0,
'', 1, 2, 2).$separator;
1570 print $line->sens.$separator;
1574 print $date_creation.$separator;
1576 print $line->lettering_code.$separator;
1578 print $line->date_lettering.$separator;
1580 if (!empty($line->subledger_account)) {
1586 if ($line->doc_type ==
'supplier_invoice' && !empty($line->subledger_account)) {
1587 print
'F'.$separator;
1588 } elseif ($line->doc_type ==
'customer_invoice' && !empty($line->subledger_account)) {
1589 print
'C'.$separator;
1602 print $line->doc_ref.$separator;
1608 print
'0'.$separator;
1612 print
'0'.$separator;
1646 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
1650 $last_codeinvoice =
'';
1652 foreach ($objectLines as $line) {
1654 if ($last_codeinvoice != $line->doc_ref) {
1656 $sql =
"SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX.
"societe";
1657 $sql .=
" WHERE code_client = '".$this->db->escape($line->thirdparty_code).
"'";
1658 $resql = $this->
db->query(
$sql);
1660 if ($resql && $this->
db->num_rows($resql) > 0) {
1661 $soc = $this->
db->fetch_object($resql);
1663 $address = array(
'',
'',
'');
1664 if (strpos($soc->address,
"\n") !==
false) {
1665 $address = explode(
"\n", $soc->address);
1666 if (is_array($address) && count($address) > 0) {
1667 foreach ($address as $key => $data) {
1668 $address[$key] = str_replace(array(
"\t",
"\n",
"\r"),
"", $data);
1669 $address[$key] =
dol_trunc($address[$key], 40,
'right',
'UTF-8', 1);
1673 $address[0] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 0, 40);
1674 $address[1] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 41, 40);
1675 $address[2] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 82, 40);
1678 $type_enregistrement =
'C';
1680 print $type_enregistrement.$separator;
1682 print $soc->code_client.$separator;
1690 print $soc->nom.$separator;
1692 print $address[0].$separator;
1694 print $address[1].$separator;
1696 print $address[2].$separator;
1698 print $soc->zip.$separator;
1700 print substr($soc->town, 0, 40).$separator;
1704 print substr(
getCountry($soc->fk_pays), 0, 40).$separator;
1706 print $soc->phone.$separator;
1718 print str_replace(
" ",
"", $soc->siret).$separator;
1782 $date_lim_reglement =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1785 $type_enregistrement =
'E';
1786 print $type_enregistrement.$separator;
1788 print substr($line->code_journal, 0, 2).$separator;
1790 print $line->id.$separator;
1792 print $line->piece_num.$separator;
1794 print $date_document.$separator;
1796 print
dol_trunc($line->label_operation, 25,
'right',
'UTF-8', 1).$separator;
1798 print $date_lim_reglement.$separator;
1800 if ($line->doc_type ==
'supplier_invoice') {
1801 if (($line->amount) < 0) {
1802 $nature_piece =
'AF';
1804 $nature_piece =
'FF';
1806 } elseif ($line->doc_type ==
'customer_invoice') {
1807 if (($line->amount) < 0) {
1808 $nature_piece =
'AC';
1810 $nature_piece =
'FC';
1815 print $nature_piece.$separator;
1826 $racine_subledger_account =
'';
1829 print $racine_subledger_account.$separator;
1831 print
price(abs($line->debit - $line->credit), 0,
'', 1, 2).$separator;
1833 print $line->sens.$separator;
1837 print $date_document.$separator;
1839 print $line->lettering_code.$separator;
1841 print $line->date_lettering.$separator;
1843 if (!empty($line->subledger_account)) {
1849 if ($line->doc_type ==
'supplier_invoice' && !empty($line->subledger_account)) {
1850 print
'F'.$separator;
1851 } elseif ($line->doc_type ==
'customer_invoice' && !empty($line->subledger_account)) {
1852 print
'C'.$separator;
1863 print $line->doc_ref.$separator;
1865 print
'0'.$separator;
1875 print
'0'.$separator;
1879 print
'0'.$separator;
1899 $last_codeinvoice = $line->doc_ref;
1912 $langs->load(
'compta');
1920 print $langs->transnoentitiesnoconv(
'Date').$separator;
1921 print
self::trunc($langs->transnoentitiesnoconv(
'Journal'), 6).$separator;
1922 print
self::trunc($langs->transnoentitiesnoconv(
'Account'), 15).$separator;
1923 print
self::trunc($langs->transnoentitiesnoconv(
'LabelAccount'), 60).$separator;
1924 print
self::trunc($langs->transnoentitiesnoconv(
'Piece'), 20).$separator;
1925 print
self::trunc($langs->transnoentitiesnoconv(
'LabelOperation'), 60).$separator;
1926 print $langs->transnoentitiesnoconv(
'Amount').$separator;
1927 print
'S'.$separator;
1928 print
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 1', 15).$separator;
1929 print
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 1', 60).$separator;
1930 print
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 2', 15).$separator;
1931 print
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 2', 60).$separator;
1932 print
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 3', 15).$separator;
1933 print
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 3', 60).$separator;
1936 foreach ($objectLines as $line) {
1938 print $date.$separator;
1940 print
self::trunc($line->code_journal, 6).$separator;
1942 if (!empty($line->subledger_account)) {
1943 $account = $line->subledger_account;
1945 $account = $line->numero_compte;
1949 print
self::trunc($line->label_compte, 60).$separator;
1952 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1953 print
self::trunc($line->label_operation, 60).$separator;
1954 print
price(abs($line->debit - $line->credit)).$separator;
1955 print $line->sens.$separator;
1977 $this->separator =
',';
1979 $invoices_infos = array();
1980 $supplier_invoices_infos = array();
1981 foreach ($objectLines as $line) {
1982 if ($line->debit == 0 && $line->credit == 0) {
1987 $invoice_ref = $line->doc_ref;
1990 if (($line->doc_type ==
'customer_invoice' || $line->doc_type ==
'supplier_invoice') && $line->fk_doc > 0) {
1991 if (($line->doc_type ==
'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) ||
1992 ($line->doc_type ==
'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) {
1993 if ($line->doc_type ==
'customer_invoice') {
1995 $sql =
'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX .
'facture as f';
1996 $sql .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe AS s ON f.fk_soc = s.rowid';
1997 $sql .=
' WHERE f.rowid = '.((int) $line->fk_doc);
1998 $resql = $this->
db->query(
$sql);
2000 if ($obj = $this->
db->fetch_object($resql)) {
2002 $invoices_infos[$line->fk_doc] = array(
'ref' => $obj->ref,
'company_name' => $obj->nom);
2003 $invoice_ref = $obj->ref;
2004 $company_name = $obj->nom;
2009 $sql =
'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX .
'facture_fourn as ff';
2010 $sql .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe AS s ON ff.fk_soc = s.rowid';
2011 $sql .=
' WHERE ff.rowid = '.((int) $line->fk_doc);
2012 $resql = $this->
db->query(
$sql);
2014 if ($obj = $this->
db->fetch_object($resql)) {
2016 $supplier_invoices_infos[$line->fk_doc] = array(
'ref' => $obj->ref,
'company_name' => $obj->nom);
2017 $invoice_ref = $obj->ref;
2018 $company_name = $obj->nom;
2022 } elseif ($line->doc_type ==
'customer_invoice') {
2024 $invoice_ref = $invoices_infos[$line->fk_doc][
'ref'];
2025 $company_name = $invoices_infos[$line->fk_doc][
'company_name'];
2028 $invoice_ref = $supplier_invoices_infos[$line->fk_doc][
'ref'];
2029 $company_name = $supplier_invoices_infos[$line->fk_doc][
'company_name'];
2033 print $line->id . $this->separator;
2034 print $date . $this->separator;
2035 print substr($line->code_journal, 0, 4) . $this->separator;
2037 if ((substr($line->numero_compte, 0, 3) ==
'411') || (substr($line->numero_compte, 0, 3) ==
'401')) {
2040 print substr(
length_accountg($line->numero_compte), 0, 15) . $this->separator;
2043 print $this->separator;
2046 print
dol_trunc(str_replace(
'"',
'', $invoice_ref . (!empty($company_name) ?
' - ' :
'') . $company_name), 40,
'right',
'UTF-8', 1) . $this->separator;
2048 print
dol_trunc(str_replace(
'"',
'', $line->piece_num), 10,
'right',
'UTF-8', 1) . $this->separator;
2050 print
'EUR' . $this->separator;
2052 print
price2num(abs($line->debit - $line->credit)) . $this->separator;
2054 print $line->sens . $this->separator;
2056 print $this->separator;
2059 print $this->end_line;
2074 $this->separator =
',';
2076 foreach ($objectLines as $line) {
2077 if ($line->debit == 0 && $line->credit == 0) {
2082 print $line->id . $this->separator;
2083 print $date . $this->separator;
2084 print substr($line->code_journal, 0, 4) . $this->separator;
2085 if ((substr($line->numero_compte, 0, 3) ==
'411') || (substr($line->numero_compte, 0, 3) ==
'401')) {
2088 print substr(
length_accountg($line->numero_compte), 0, 15) . $this->separator;
2090 print $this->separator;
2092 print
'"' .
dol_trunc(str_replace(
'"',
'', $line->doc_ref), 40,
'right',
'UTF-8', 1) .
'"' . $this->separator;
2093 print
'"' .
dol_trunc(str_replace(
'"',
'', $line->piece_num), 10,
'right',
'UTF-8', 1) .
'"' . $this->separator;
2094 print
price2num(abs($line->debit - $line->credit)) . $this->separator;
2095 print $line->sens . $this->separator;
2096 print $date . $this->separator;
2097 print $this->separator;
2098 print $this->separator;
2100 print $this->end_line;
2116 $this->separator =
';';
2117 $this->end_line =
"\r\n";
2120 foreach ($objectLines as $line) {
2125 $tab[] = $line->piece_num;
2127 $tab[] = substr($date, 6, 4);
2128 $tab[] = substr($date, 3, 2);
2129 $tab[] = substr($date, 0, 2);
2130 $tab[] = $line->doc_ref;
2132 $tab[] = mb_convert_encoding(str_replace(
' - Compte auxiliaire',
'', $line->label_operation),
"Windows-1252",
'UTF-8');
2138 $numero_cpt_client =
'411';
2139 $numero_cpt_fourn =
'401';
2140 for ($i = 1; $i <= ($taille_numero - 3); $i++) {
2141 $numero_cpt_client .=
'0';
2142 $numero_cpt_fourn .=
'0';
2151 $nom_client = explode(
" - ", $line->label_operation);
2152 $tab[] = mb_convert_encoding($nom_client[0],
"Windows-1252",
'UTF-8');
2153 $tab[] =
price($line->debit);
2154 $tab[] =
price($line->credit);
2155 $tab[] =
price($line->montant);
2156 $tab[] = $line->code_journal;
2158 $separator = $this->separator;
2159 print implode($separator, $tab) . $this->end_line;
2170 public static function trunc($str, $size)
2172 return dol_trunc($str, $size,
'right',
'UTF-8', 1);
2182 public static function toAnsi($str, $size = -1)
2185 if ($retVal >= 0 && $size >= 0) {
2186 $retVal = mb_substr($retVal, 0, $size,
'Windows-1251');