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,
206 'ACCOUNTING_EXPORT_DATE' => empty($conf->global->ACCOUNTING_EXPORT_DATE) ?
'%d%m%Y' : $conf->global->ACCOUNTING_EXPORT_DATE,
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) {
706 $code_compta = $data->numero_compte;
707 if (!empty($data->subledger_account)) {
708 $code_compta = $data->subledger_account;
713 if (!empty($data->subledger_account)) {
714 $Tab[
'type_ligne'] =
'C';
715 $Tab[
'num_compte'] = str_pad(self::trunc($data->subledger_account, 8), 8);
716 $Tab[
'lib_compte'] = str_pad(self::trunc($data->subledger_label, 30), 30);
718 if ($data->doc_type ==
'customer_invoice') {
719 $Tab[
'lib_alpha'] = strtoupper(str_pad(
'C'.self::trunc($data->subledger_label, 6), 6));
720 $Tab[
'filler'] = str_repeat(
' ', 52);
721 $Tab[
'coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, 8), 8);
722 } elseif ($data->doc_type ==
'supplier_invoice') {
723 $Tab[
'lib_alpha'] = strtoupper(str_pad(
'F'.self::trunc($data->subledger_label, 6), 6));
724 $Tab[
'filler'] = str_repeat(
' ', 52);
725 $Tab[
'coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, 8), 8);
727 $Tab[
'filler'] = str_repeat(
' ', 59);
728 $Tab[
'coll_compte'] = str_pad(
' ', 8);
731 $Tab[
'filler2'] = str_repeat(
' ', 110);
734 if ($data->doc_type ==
'customer_invoice') {
735 $Tab[
'type_compte'] =
'C';
736 } elseif ($data->doc_type ==
'supplier_invoice') {
737 $Tab[
'coll_compte'] =
'F';
739 $Tab[
'coll_compte'] =
'G';
742 $Tab[
'filler3'] = str_repeat(
' ', 235);
744 $Tab[
'end_line'] = $end_line;
747 fwrite($exportFile, implode($Tab));
754 $Tab[
'type_ligne'] =
'M';
755 $Tab[
'num_compte'] = str_pad(self::trunc($code_compta, 8), 8);
756 $Tab[
'code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
757 $Tab[
'folio'] =
'000';
762 $Tab[
'date_ecriture'] =
dol_print_date($data->doc_date,
'%d%m%y');
763 $Tab[
'filler'] =
' ';
779 $Tab[
'sens'] = $data->sens;
780 $Tab[
'signe_montant'] =
'+';
783 $Tab[
'montant'] = str_pad(abs(($data->debit - $data->credit) * 100), 12,
'0', STR_PAD_LEFT);
784 $Tab[
'contrepartie'] = str_repeat(
' ', 8);
787 if (!empty($data->date_lim_reglement)) {
789 $Tab[
'date_echeance'] =
dol_print_date($data->date_lim_reglement,
'%d%m%y');
791 $Tab[
'date_echeance'] =
'000000';
796 $Tab[
'lettrage'] = str_repeat(
' ', 2);
797 $Tab[
'codestat'] = str_repeat(
' ', 3);
798 $Tab[
'num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5);
802 $Tab[
'affaire'] = str_repeat(
' ', 10);
803 $Tab[
'quantity1'] = str_repeat(
' ', 10);
804 $Tab[
'num_piece2'] = str_pad(self::trunc($data->piece_num, 8), 8);
805 $Tab[
'devis'] = str_pad($conf->currency, 3);
806 $Tab[
'code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3);
807 $Tab[
'filler3'] = str_repeat(
' ', 3);
815 $Tab[
'libelle_ecriture2'] = str_pad(self::trunc(
dol_string_unaccent($data->label_operation), 30), 30);
816 $Tab[
'codetva'] = str_repeat(
' ', 2);
820 $Tab[
'num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10);
821 $Tab[
'reserved'] = str_repeat(
' ', 10);
822 $Tab[
'currency_amount'] = str_repeat(
' ', 13);
824 $attachmentFileName =
'';
825 if ($withAttachment == 1) {
826 $attachmentFileKey = trim($data->piece_num);
828 if (!isset($archiveFileList[$attachmentFileKey])) {
831 if ($data->doc_type ==
'customer_invoice') {
832 $objectDirPath = !empty($conf->facture->multidir_output[$conf->entity]) ? $conf->facture->multidir_output[$conf->entity] : $conf->facture->dir_output;
833 } elseif ($data->doc_type ==
'expense_report') {
834 $objectDirPath = !empty($conf->expensereport->multidir_output[$conf->entity]) ? $conf->expensereport->multidir_output[$conf->entity] : $conf->factureexpensereport->dir_output;
835 } elseif ($data->doc_type ==
'supplier_invoice') {
836 $objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output;
838 $arrayofinclusion = array();
839 $arrayofinclusion[] =
'^'.preg_quote($objectFileName,
'/').
'\.pdf$';
840 $fileFoundList =
dol_dir_list($objectDirPath.
'/'.$objectFileName,
'files', 0, implode(
'|', $arrayofinclusion),
'(\.meta|_preview.*\.png)$',
'date', SORT_DESC, 0,
true);
841 if (!empty($fileFoundList)) {
842 $attachmentFileNameTrunc = str_pad(self::trunc($data->piece_num, 8), 8,
'0', STR_PAD_LEFT);
843 foreach ($fileFoundList as $fileFound) {
844 if (strstr($fileFound[
'name'], $objectFileName)) {
845 $fileFoundPath = $objectDirPath.
'/'.$objectFileName.
'/'.$fileFound[
'name'];
846 if (file_exists($fileFoundPath)) {
847 $archiveFileList[$attachmentFileKey] = array(
848 'path' => $fileFoundPath,
849 'name' => $attachmentFileNameTrunc.
'.pdf',
858 if (isset($archiveFileList[$attachmentFileKey])) {
859 $attachmentFileName = $archiveFileList[$attachmentFileKey][
'name'];
863 $Tab[
'attachment'] = $attachmentFileName;
865 $Tab[
'attachment'] = str_repeat(
' ', 12);
867 $Tab[
'filler4'] = str_repeat(
' ', 38);
868 $Tab[
'end_line'] = $end_line;
871 fwrite($exportFile, implode($Tab));
877 return $archiveFileList;
903 foreach ($TData as $data) {
904 $code_compta = $data->numero_compte;
905 if (!empty($data->subledger_account)) {
906 $code_compta = $data->subledger_account;
911 $Tab[
'code_journal'] = str_pad(
dol_trunc($data->code_journal, 2,
'right',
'UTF-8', 1), 2);
916 $Tab[
'date_operation'] =
dol_print_date($data->doc_date,
'%d%m%Y');
918 $Tab[
'folio'] =
' 1';
920 $Tab[
'num_ecriture'] = str_pad(
dol_trunc($index, 6,
'right',
'UTF-8', 1), 6,
' ', STR_PAD_LEFT);
922 $Tab[
'jour_ecriture'] =
dol_print_date($data->doc_date,
'%d%m%y');
924 $Tab[
'num_compte'] = str_pad(
dol_trunc($code_compta, 6,
'right',
'UTF-8', 1), 6,
'0');
926 if ($data->sens ==
'D') {
927 $Tab[
'montant_debit'] = str_pad(number_format($data->debit, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
929 $Tab[
'montant_crebit'] = str_pad(number_format(0, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
931 $Tab[
'montant_debit'] = str_pad(number_format(0, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
933 $Tab[
'montant_crebit'] = str_pad(number_format($data->credit, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
938 $Tab[
'lettrage'] = str_repeat(
dol_trunc($data->lettering_code, 2,
'left',
'UTF-8', 1), 2);
940 $Tab[
'code_piece'] = str_pad(
dol_trunc($data->piece_num, 5,
'left',
'UTF-8', 1), 5,
' ', STR_PAD_LEFT);
942 $Tab[
'code_stat'] = str_repeat(
' ', 4);
944 if (!empty($data->date_lim_reglement)) {
946 $Tab[
'date_echeance'] =
dol_print_date($data->date_lim_reglement,
'%d%m%Y');
948 $Tab[
'date_echeance'] =
dol_print_date($data->doc_date,
'%d%m%Y');
951 $Tab[
'monnaie'] =
'1';
953 $Tab[
'filler'] =
' ';
955 $Tab[
'ind_compteur'] =
' ';
957 $Tab[
'quantite'] =
'0,000000000';
959 $Tab[
'code_pointage'] = str_repeat(
' ', 2);
961 $Tab[
'end_line'] = $end_line;
963 print implode(
'|', $Tab);
982 foreach ($objectLines as $line) {
985 print $line->id.$separator;
986 print $date.$separator;
987 print $line->code_journal.$separator;
988 if (empty($line->subledger_account)) {
989 print $line->numero_compte.$separator;
991 print $line->subledger_account.$separator;
994 print
'"'.dol_trunc($line->label_operation, 40,
'right',
'UTF-8', 1).
'"'.$separator;
995 print
'"'.dol_trunc($line->piece_num, 15,
'right',
'UTF-8', 1).
'"'.$separator;
996 print
price2num(abs($line->debit - $line->credit)).$separator;
997 print $line->sens.$separator;
998 print $date.$separator;
1017 foreach ($objectLines as $line) {
1020 print $line->piece_num.$separator;
1022 print $date.$separator;
1025 if (empty($line->subledger_account)) {
1034 print
price($line->debit).$separator;
1035 print
price($line->credit).$separator;
1036 print
price(abs($line->debit - $line->credit)).$separator;
1037 print $line->sens.$separator;
1038 print $line->lettering_code.$separator;
1039 print $line->code_journal;
1056 foreach ($objectLines as $line) {
1059 print $date.$separator;
1060 print $line->code_journal.$separator;
1061 if (empty($line->subledger_account)) {
1066 print $line->doc_ref.$separator;
1067 print $line->label_operation.$separator;
1068 print
price($line->debit).$separator;
1069 print
price($line->credit).$separator;
1085 $separator = $this->separator;
1087 foreach ($objectLines as $line) {
1090 $date =
dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
1091 $tab[] = $line->piece_num;
1093 $tab[] = $line->doc_ref;
1094 $tab[] = preg_match(
'/'.$separator.
'/', $line->label_operation) ?
"'".$line->label_operation.
"'" : $line->label_operation;
1099 $tab[] =
price2num($line->debit - $line->credit);
1100 $tab[] = $line->code_journal;
1102 print implode($separator, $tab).$this->end_line;
1119 print
"JournalCode".$separator;
1120 print
"JournalLib".$separator;
1121 print
"EcritureNum".$separator;
1122 print
"EcritureDate".$separator;
1123 print
"CompteNum".$separator;
1124 print
"CompteLib".$separator;
1125 print
"CompAuxNum".$separator;
1126 print
"CompAuxLib".$separator;
1127 print
"PieceRef".$separator;
1128 print
"PieceDate".$separator;
1129 print
"EcritureLib".$separator;
1130 print
"Debit".$separator;
1131 print
"Credit".$separator;
1132 print
"EcritureLet".$separator;
1133 print
"DateLet".$separator;
1134 print
"ValidDate".$separator;
1135 print
"Montantdevise".$separator;
1136 print
"Idevise".$separator;
1137 print
"DateLimitReglmt".$separator;
1141 foreach ($objectLines as $line) {
1142 if ($line->debit == 0 && $line->credit == 0) {
1147 $date_lettering =
dol_print_date($line->date_lettering,
'%Y%m%d');
1148 $date_validation =
dol_print_date($line->date_validation,
'%Y%m%d');
1149 $date_limit_payment =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1152 if ($line->doc_type ==
'customer_invoice') {
1154 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1156 $invoice->fetch($line->fk_doc);
1158 $refInvoice = $invoice->ref;
1159 } elseif ($line->doc_type ==
'supplier_invoice') {
1161 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1163 $invoice->fetch($line->fk_doc);
1165 $refInvoice = $invoice->ref_supplier;
1169 print $line->code_journal . $separator;
1175 print $line->piece_num . $separator;
1178 print $date_document . $separator;
1181 print $line->numero_compte . $separator;
1187 print $line->subledger_account . $separator;
1193 print $line->doc_ref . $separator;
1200 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1204 print
price2fec($line->debit) . $separator;
1207 print
price2fec($line->credit) . $separator;
1210 print $line->lettering_code . $separator;
1213 print $date_lettering . $separator;
1216 print $date_validation . $separator;
1219 print $line->multicurrency_amount . $separator;
1222 print $line->multicurrency_code . $separator;
1225 print $date_limit_payment . $separator;
1229 $refInvoice = str_replace(array(
"\t",
"\n",
"\r"),
" ", $refInvoice);
1230 print
dol_trunc(self::toAnsi($refInvoice), 17,
'right',
'UTF-8', 1);
1250 print
"JournalCode".$separator;
1251 print
"JournalLib".$separator;
1252 print
"EcritureNum".$separator;
1253 print
"EcritureDate".$separator;
1254 print
"CompteNum".$separator;
1255 print
"CompteLib".$separator;
1256 print
"CompAuxNum".$separator;
1257 print
"CompAuxLib".$separator;
1258 print
"PieceRef".$separator;
1259 print
"PieceDate".$separator;
1260 print
"EcritureLib".$separator;
1261 print
"Debit".$separator;
1262 print
"Credit".$separator;
1263 print
"EcritureLet".$separator;
1264 print
"DateLet".$separator;
1265 print
"ValidDate".$separator;
1266 print
"Montantdevise".$separator;
1267 print
"Idevise".$separator;
1268 print
"DateLimitReglmt".$separator;
1272 foreach ($objectLines as $line) {
1273 if ($line->debit == 0 && $line->credit == 0) {
1278 $date_lettering =
dol_print_date($line->date_lettering,
'%Y%m%d');
1279 $date_validation =
dol_print_date($line->date_validation,
'%Y%m%d');
1280 $date_limit_payment =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1283 if ($line->doc_type ==
'customer_invoice') {
1285 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1287 $invoice->fetch($line->fk_doc);
1289 $refInvoice = $invoice->ref;
1290 } elseif ($line->doc_type ==
'supplier_invoice') {
1292 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1294 $invoice->fetch($line->fk_doc);
1296 $refInvoice = $invoice->ref_supplier;
1300 print $line->code_journal . $separator;
1306 print $line->piece_num . $separator;
1309 print $date_creation . $separator;
1324 print $line->doc_ref . $separator;
1327 print $date_document . $separator;
1331 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1335 print
price2fec($line->debit) . $separator;
1338 print
price2fec($line->credit) . $separator;
1341 print $line->lettering_code . $separator;
1344 print $date_lettering . $separator;
1347 print $date_validation . $separator;
1350 print $line->multicurrency_amount . $separator;
1353 print $line->multicurrency_code . $separator;
1356 print $date_limit_payment . $separator;
1360 $refInvoice = str_replace(array(
"\t",
"\n",
"\r"),
" ", $refInvoice);
1361 print
dol_trunc(self::toAnsi($refInvoice), 17,
'right',
'UTF-8', 1);
1382 $this->separator =
',';
1383 $this->end_line =
"\r\n";
1386 print
"Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag";
1387 print $this->end_line;
1389 $thisPieceAccountNr =
"";
1390 $aSize = count($objectLines);
1391 foreach ($objectLines as $aIndex => $line) {
1392 $sammelBuchung =
false;
1393 if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) {
1394 $sammelBuchung =
true;
1395 } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) {
1396 $sammelBuchung =
true;
1397 } elseif ($aIndex + 1 < $aSize
1398 && $objectLines[$aIndex + 1]->piece_num == $line->piece_num
1399 && $aIndex - 1 < $aSize
1400 && $objectLines[$aIndex - 1]->piece_num == $line->piece_num
1402 $sammelBuchung =
true;
1406 print $line->piece_num.$this->separator;
1410 print $date.$this->separator;
1415 if ($line->sens ==
'D') {
1416 print
'S'.$this->separator;
1418 print
'H'.$this->separator;
1421 print
self::trunc($line->code_journal, 1).$this->separator;
1423 if (empty($line->code_tiers)) {
1424 if ($line->piece_num == $thisPieceNum) {
1427 print
"div".$this->separator;
1433 print $this->separator;
1435 print
"0".$this->separator;
1437 print
"0".$this->separator;
1439 print
"0".$this->separator;
1442 if ($sammelBuchung) {
1443 print
"2".$this->separator;
1445 print
"1".$this->separator;
1448 print
'""'.$this->separator;
1450 print abs($line->debit - $line->credit).$this->separator;
1452 print
"0.00".$this->separator;
1454 print
"0.00".$this->separator;
1457 if ($line1 ==
"LIQ" || $line1 ==
"LIQ Beleg ok" || strlen($line1) <= 3) {
1461 if (strlen($line1) == 0) {
1465 if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) {
1466 $line1 = $line1.
' / '.$line2;
1470 print
'"'.self::toAnsi($line1).
'"'.$this->separator;
1472 print
'"'.self::toAnsi($line2).
'"'.$this->separator;
1474 print
"0".$this->separator;
1476 print $this->separator;
1481 print $this->end_line;
1483 if ($line->piece_num !== $thisPieceNum) {
1484 $thisPieceNum = $line->piece_num;
1485 $thisPieceAccountNr = $line->numero_compte;
1504 foreach ($objectLines as $line) {
1507 $date_lim_reglement =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1510 $type_enregistrement =
'E';
1511 print $type_enregistrement.$separator;
1513 print substr($line->code_journal, 0, 2).$separator;
1515 print $line->id.$separator;
1517 print $line->piece_num.$separator;
1519 print $date_document.$separator;
1521 print $line->label_operation.$separator;
1523 print $date_lim_reglement.$separator;
1525 if ($line->doc_type ==
'supplier_invoice') {
1526 if (($line->debit - $line->credit) > 0) {
1527 $nature_piece =
'AF';
1529 $nature_piece =
'FF';
1531 } elseif ($line->doc_type ==
'customer_invoice') {
1532 if (($line->debit - $line->credit) < 0) {
1533 $nature_piece =
'AC';
1535 $nature_piece =
'FC';
1540 print $nature_piece.$separator;
1551 $racine_subledger_account =
'';
1554 print $racine_subledger_account.$separator;
1556 print
price(abs($line->debit - $line->credit), 0,
'', 1, 2, 2).$separator;
1558 print $line->sens.$separator;
1562 print $date_creation.$separator;
1564 print $line->lettering_code.$separator;
1566 print $line->date_lettering.$separator;
1568 if (!empty($line->subledger_account)) {
1574 if ($line->doc_type ==
'supplier_invoice' && !empty($line->subledger_account)) {
1575 print
'F'.$separator;
1576 } elseif ($line->doc_type ==
'customer_invoice' && !empty($line->subledger_account)) {
1577 print
'C'.$separator;
1590 print $line->doc_ref.$separator;
1596 print
'0'.$separator;
1600 print
'0'.$separator;
1634 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
1638 $last_codeinvoice =
'';
1640 foreach ($objectLines as $line) {
1642 if ($last_codeinvoice != $line->doc_ref) {
1644 $sql =
"SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX.
"societe";
1645 $sql .=
" WHERE code_client = '".$this->db->escape($line->thirdparty_code).
"'";
1649 $soc = $this->
db->fetch_object(
$resql);
1651 $address = array(
'',
'',
'');
1652 if (strpos($soc->address,
"\n") !==
false) {
1653 $address = explode(
"\n", $soc->address);
1654 if (is_array($address) && count($address) > 0) {
1655 foreach ($address as $key => $data) {
1656 $address[$key] = str_replace(array(
"\t",
"\n",
"\r"),
"", $data);
1657 $address[$key] =
dol_trunc($address[$key], 40,
'right',
'UTF-8', 1);
1661 $address[0] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 0, 40);
1662 $address[1] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 41, 40);
1663 $address[2] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 82, 40);
1666 $type_enregistrement =
'C';
1668 print $type_enregistrement.$separator;
1670 print $soc->code_client.$separator;
1678 print $soc->nom.$separator;
1680 print $address[0].$separator;
1682 print $address[1].$separator;
1684 print $address[2].$separator;
1686 print $soc->zip.$separator;
1688 print substr($soc->town, 0, 40).$separator;
1692 print substr(
getCountry($soc->fk_pays), 0, 40).$separator;
1694 print $soc->phone.$separator;
1706 print str_replace(
" ",
"", $soc->siret).$separator;
1770 $date_lim_reglement =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1773 $type_enregistrement =
'E';
1774 print $type_enregistrement.$separator;
1776 print substr($line->code_journal, 0, 2).$separator;
1778 print $line->id.$separator;
1780 print $line->piece_num.$separator;
1782 print $date_document.$separator;
1784 print
dol_trunc($line->label_operation, 25,
'right',
'UTF-8', 1).$separator;
1786 print $date_lim_reglement.$separator;
1788 if ($line->doc_type ==
'supplier_invoice') {
1789 if (($line->amount) < 0) {
1790 $nature_piece =
'AF';
1792 $nature_piece =
'FF';
1794 } elseif ($line->doc_type ==
'customer_invoice') {
1795 if (($line->amount) < 0) {
1796 $nature_piece =
'AC';
1798 $nature_piece =
'FC';
1803 print $nature_piece.$separator;
1814 $racine_subledger_account =
'';
1817 print $racine_subledger_account.$separator;
1819 print
price(abs($line->debit - $line->credit), 0,
'', 1, 2).$separator;
1821 print $line->sens.$separator;
1825 print $date_document.$separator;
1827 print $line->lettering_code.$separator;
1829 print $line->date_lettering.$separator;
1831 if (!empty($line->subledger_account)) {
1837 if ($line->doc_type ==
'supplier_invoice' && !empty($line->subledger_account)) {
1838 print
'F'.$separator;
1839 } elseif ($line->doc_type ==
'customer_invoice' && !empty($line->subledger_account)) {
1840 print
'C'.$separator;
1851 print $line->doc_ref.$separator;
1853 print
'0'.$separator;
1863 print
'0'.$separator;
1867 print
'0'.$separator;
1887 $last_codeinvoice = $line->doc_ref;
1900 $langs->load(
'compta');
1908 print $langs->transnoentitiesnoconv(
'Date').$separator;
1909 print
self::trunc($langs->transnoentitiesnoconv(
'Journal'), 6).$separator;
1910 print
self::trunc($langs->transnoentitiesnoconv(
'Account'), 15).$separator;
1911 print
self::trunc($langs->transnoentitiesnoconv(
'LabelAccount'), 60).$separator;
1912 print
self::trunc($langs->transnoentitiesnoconv(
'Piece'), 20).$separator;
1913 print
self::trunc($langs->transnoentitiesnoconv(
'LabelOperation'), 60).$separator;
1914 print $langs->transnoentitiesnoconv(
'Amount').$separator;
1915 print
'S'.$separator;
1916 print
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 1', 15).$separator;
1917 print
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 1', 60).$separator;
1918 print
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 2', 15).$separator;
1919 print
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 2', 60).$separator;
1920 print
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 3', 15).$separator;
1921 print
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 3', 60).$separator;
1924 foreach ($objectLines as $line) {
1926 print $date.$separator;
1928 print
self::trunc($line->code_journal, 6).$separator;
1930 if (!empty($line->subledger_account)) {
1931 $account = $line->subledger_account;
1933 $account = $line->numero_compte;
1937 print
self::trunc($line->label_compte, 60).$separator;
1940 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1941 print
self::trunc($line->label_operation, 60).$separator;
1942 print
price(abs($line->debit - $line->credit)).$separator;
1943 print $line->sens.$separator;
1965 $this->separator =
',';
1967 $invoices_infos = array();
1968 $supplier_invoices_infos = array();
1969 foreach ($objectLines as $line) {
1970 if ($line->debit == 0 && $line->credit == 0) {
1975 $invoice_ref = $line->doc_ref;
1978 if (($line->doc_type ==
'customer_invoice' || $line->doc_type ==
'supplier_invoice') && $line->fk_doc > 0) {
1979 if (($line->doc_type ==
'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) ||
1980 ($line->doc_type ==
'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) {
1981 if ($line->doc_type ==
'customer_invoice') {
1983 $sql =
'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX .
'facture as f';
1984 $sql .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe AS s ON f.fk_soc = s.rowid';
1985 $sql .=
' WHERE f.rowid = '.((int) $line->fk_doc);
1988 if ($obj = $this->
db->fetch_object(
$resql)) {
1990 $invoices_infos[$line->fk_doc] = array(
'ref' => $obj->ref,
'company_name' => $obj->nom);
1991 $invoice_ref = $obj->ref;
1992 $company_name = $obj->nom;
1997 $sql =
'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX .
'facture_fourn as ff';
1998 $sql .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe AS s ON ff.fk_soc = s.rowid';
1999 $sql .=
' WHERE ff.rowid = '.((int) $line->fk_doc);
2002 if ($obj = $this->
db->fetch_object(
$resql)) {
2004 $supplier_invoices_infos[$line->fk_doc] = array(
'ref' => $obj->ref,
'company_name' => $obj->nom);
2005 $invoice_ref = $obj->ref;
2006 $company_name = $obj->nom;
2010 } elseif ($line->doc_type ==
'customer_invoice') {
2012 $invoice_ref = $invoices_infos[$line->fk_doc][
'ref'];
2013 $company_name = $invoices_infos[$line->fk_doc][
'company_name'];
2016 $invoice_ref = $supplier_invoices_infos[$line->fk_doc][
'ref'];
2017 $company_name = $supplier_invoices_infos[$line->fk_doc][
'company_name'];
2021 print $line->id . $this->separator;
2022 print $date . $this->separator;
2023 print substr($line->code_journal, 0, 4) . $this->separator;
2025 if ((substr($line->numero_compte, 0, 3) ==
'411') || (substr($line->numero_compte, 0, 3) ==
'401')) {
2028 print substr(
length_accountg($line->numero_compte), 0, 15) . $this->separator;
2031 print $this->separator;
2034 print
dol_trunc(str_replace(
'"',
'', $invoice_ref . (!empty($company_name) ?
' - ' :
'') . $company_name), 40,
'right',
'UTF-8', 1) . $this->separator;
2036 print
dol_trunc(str_replace(
'"',
'', $line->piece_num), 10,
'right',
'UTF-8', 1) . $this->separator;
2038 print
'EUR' . $this->separator;
2040 print
price2num(abs($line->debit - $line->credit)) . $this->separator;
2042 print $line->sens . $this->separator;
2044 print $this->separator;
2047 print $this->end_line;
2062 $this->separator =
',';
2064 foreach ($objectLines as $line) {
2065 if ($line->debit == 0 && $line->credit == 0) {
2070 print $line->id . $this->separator;
2071 print $date . $this->separator;
2072 print substr($line->code_journal, 0, 4) . $this->separator;
2073 if ((substr($line->numero_compte, 0, 3) ==
'411') || (substr($line->numero_compte, 0, 3) ==
'401')) {
2076 print substr(
length_accountg($line->numero_compte), 0, 15) . $this->separator;
2078 print $this->separator;
2080 print
'"' .
dol_trunc(str_replace(
'"',
'', $line->doc_ref), 40,
'right',
'UTF-8', 1) .
'"' . $this->separator;
2081 print
'"' .
dol_trunc(str_replace(
'"',
'', $line->piece_num), 10,
'right',
'UTF-8', 1) .
'"' . $this->separator;
2082 print
price2num(abs($line->debit - $line->credit)) . $this->separator;
2083 print $line->sens . $this->separator;
2084 print $date . $this->separator;
2085 print $this->separator;
2086 print $this->separator;
2088 print $this->end_line;
2104 $this->separator =
';';
2105 $this->end_line =
"\r\n";
2108 foreach ($objectLines as $line) {
2113 $tab[] = $line->piece_num;
2115 $tab[] = substr($date, 6, 4);
2116 $tab[] = substr($date, 3, 2);
2117 $tab[] = substr($date, 0, 2);
2118 $tab[] = $line->doc_ref;
2120 $tab[] = mb_convert_encoding(str_replace(
' - Compte auxiliaire',
'', $line->label_operation),
"Windows-1252",
'UTF-8');
2126 $numero_cpt_client =
'411';
2127 for ($i = 1; $i <= ($taille_numero - 3); $i++) {
2128 $numero_cpt_client .=
'0';
2137 $nom_client = explode(
" - ", $line->label_operation);
2138 $tab[] = mb_convert_encoding($nom_client[0],
"Windows-1252",
'UTF-8');
2139 $tab[] =
price($line->debit);
2140 $tab[] =
price($line->credit);
2141 $tab[] =
price($line->montant);
2142 $tab[] = $line->code_journal;
2144 $separator = $this->separator;
2145 print implode($separator, $tab) . $this->end_line;
2156 public static function trunc($str, $size)
2158 return dol_trunc($str, $size,
'right',
'UTF-8', 1);
2168 public static function toAnsi($str, $size = -1)
2171 if ($retVal >= 0 && $size >= 0) {
2172 $retVal = mb_substr($retVal, 0, $size,
'Windows-1251');
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
Manage the different format accountancy export.
exportAgiris($objectLines)
Export format : Agiris Isacompta.
exportWinfic(&$TData)
Export format : WinFic - eWinfic - WinSis Compta Last review for this format : 2022-11-01 Alexandre S...
exportEbp($objectLines)
Export format : EBP.
exportCiel(&$TData)
Export format : CIEL (Format XIMPORT) Format since 2003 compatible CIEL version > 2002 / Sage50 Last ...
getTypeConfig()
Array with all export type available (key + label) and parameters for config.
exportBob50($objectLines)
Export format : BOB50.
exportGestimumV5($objectLines)
Export format : Gestimum V5.
static trunc($str, $size)
trunc
exportLDCompta10($objectLines)
Export format : LD Compta version 10 & higher Last review for this format : 08-15-2021 Alexandre Span...
exportConfigurable($objectLines)
Export format : Configurable CSV.
exportCegid($objectLines)
Export format : CEGID.
static toAnsi($str, $size=-1)
toAnsi
getType()
Array with all export type available (key + label)
export(&$TData, $formatexportset, $withAttachment=0)
Function who chose which export to use with the default config, and make the export into a file.
static getFormatCode($type)
Return string to summarize the format (Used to generated export filename)
exportLDCompta($objectLines)
Export format : LD Compta version 9 http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Docu...
exportCoala($objectLines)
Export format : COALA.
exportCogilog($objectLines)
Export format : COGILOG.
exportCharlemagne($objectLines)
Export format : Charlemagne.
exportFEC($objectLines)
Export format : FEC.
exportFEC2($objectLines)
Export format : FEC2.
__construct(DoliDB $db)
Constructor.
getMimeType($formatexportset)
Return the MIME type of a file.
exportSAGE50SWISS($objectLines)
Export format : SAGE50SWISS.
exportGestimumV3($objectLines)
Export format : Gestimum V3.
exportQuadratus(&$TData, $exportFile=null, $archiveFileList=array(), $withAttachment=0)
Export format : Quadratus (Format ASCII) Format since 2015 compatible QuadraCOMPTA Last review for th...
exportiSuiteExpert($objectLines)
Export format : iSuite Expert.
exportOpenConcerto($objectLines)
Export format : OpenConcerto.
Class to manage Dolibarr database access.
Class to manage suppliers invoices.
Class to manage invoices.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_filesize($pathoffile)
Return size of a file.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
price2fec($amount)
Function to format a value into a defined format for French administration (no thousand separator & d...
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
readfileLowMemory($fullpath_original_file_osencoded, $method=-1)
Return a file on output using a low memory.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
$conf db
API class for accounts.