38require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
43require_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);
392 $this->errors[] = $langs->trans(
'ErrorCanNotCreateDir', $outputDir);
397 if ($outputDir !=
'') {
399 $langs->load(
'errors');
400 $this->errors[] = $langs->trans(
'ErrorDirNotFound', $outputDir);
404 if (!empty($completefilename)) {
406 $exportFileFullName = $completefilename;
407 $exportFileBaseName = basename($exportFileFullName);
408 $exportFileName = pathinfo($exportFileBaseName, PATHINFO_FILENAME);
409 $exportFilePath = $outputDir .
'/' . $exportFileFullName;
410 $exportFile = fopen($exportFilePath,
'w');
412 $this->errors[] = $langs->trans(
'ErrorFileNotFound', $exportFilePath);
416 if ($withAttachment == 1) {
417 $archiveFileList[0] = array(
418 'path' => $exportFilePath,
419 'name' => $exportFileFullName,
423 $archiveFullName = $exportFileName .
'.zip';
424 $archivePath = $outputDir .
'/' . $archiveFullName;
431 switch ($formatexportset) {
432 case self::$EXPORT_TYPE_CONFIGURABLE:
435 case self::$EXPORT_TYPE_CEGID:
438 case self::$EXPORT_TYPE_COALA:
441 case self::$EXPORT_TYPE_BOB50:
444 case self::$EXPORT_TYPE_CIEL:
447 case self::$EXPORT_TYPE_QUADRATUS:
448 $archiveFileList = $this->
exportQuadratus($TData, $exportFile, $archiveFileList, $withAttachment);
450 case self::$EXPORT_TYPE_WINFIC:
453 case self::$EXPORT_TYPE_EBP:
456 case self::$EXPORT_TYPE_COGILOG:
459 case self::$EXPORT_TYPE_AGIRIS:
462 case self::$EXPORT_TYPE_OPENCONCERTO:
465 case self::$EXPORT_TYPE_SAGE50_SWISS:
468 case self::$EXPORT_TYPE_CHARLEMAGNE:
471 case self::$EXPORT_TYPE_LDCOMPTA:
474 case self::$EXPORT_TYPE_LDCOMPTA10:
477 case self::$EXPORT_TYPE_GESTIMUMV3:
480 case self::$EXPORT_TYPE_GESTIMUMV5:
483 case self::$EXPORT_TYPE_FEC:
486 case self::$EXPORT_TYPE_FEC2:
489 case self::$EXPORT_TYPE_ISUITEEXPERT :
494 $parameters = array(
'format' => $formatexportset);
496 $reshook = $hookmanager->executeHooks(
'export', $parameters, $TData);
498 $this->errors[] = $langs->trans(
'accountancy_error_modelnotfound');
504 if ($outputMode == 1 || $outputMode == 2) {
512 if ($withAttachment == 1) {
514 if (!empty($archiveFullName) && !empty($archivePath) && !empty($archiveFileList)) {
516 $downloadFileMimeType =
'application/zip';
517 $downloadFileFullName = $archiveFullName;
518 $downloadFilePath = $archivePath;
521 $archive =
new ZipArchive();
522 $res = $archive->open($archivePath, ZipArchive::OVERWRITE | ZipArchive::CREATE);
525 $this->errors[] = $langs->trans(
'ErrorFileNotFound', $archivePath);
529 foreach ($archiveFileList as $archiveFileArr) {
530 $res = $archive->addFile($archiveFileArr[
'path'], $archiveFileArr[
'name']);
533 $this->errors[] = $langs->trans(
'ErrorArchiveAddFile', $archiveFileArr[
'name']);
547 if ($downloadMode == 1) {
548 if ($withAttachment == 0) {
550 if (!empty($exportFileFullName) && !empty($exportFilePath)) {
551 $downloadFileMimeType = $mimetype;
552 $downloadFileFullName = $exportFileFullName;
553 $downloadFilePath = $exportFilePath;
558 if (!empty($downloadFileMimeType) && !empty($downloadFileFullName) && !empty($downloadFilePath)) {
559 header(
'Content-Type: ' . $downloadFileMimeType);
560 header(
'Content-Disposition: attachment; filename=' . $downloadFileFullName);
561 header(
'Cache-Control: Public, must-revalidate');
562 header(
'Pragma: public');
563 header(
'Content-Length: ' .
dol_filesize($downloadFilePath));
590 foreach ($objectLines as $line) {
595 $tab[] = $date_document;
596 $tab[] = $line->code_journal;
599 $tab[] = $line->sens;
600 $tab[] =
price2fec(abs($line->debit - $line->credit));
604 $output = implode($separator, $tab).$end_line;
606 fwrite($exportFile, $output);
626 foreach ($objectLines as $line) {
630 if ($line->doc_type ==
'customer_invoice') {
632 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
633 $invoice =
new Facture($this->db);
634 $invoice->fetch($line->fk_doc);
636 $refInvoice = $invoice->ref;
637 } elseif ($line->doc_type ==
'supplier_invoice') {
639 require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.facture.class.php';
641 $invoice->fetch($line->fk_doc);
643 $refInvoice = $invoice->ref_supplier;
648 $tab[] = $line->code_journal;
649 $tab[] = $date_document;
650 $tab[] = $refInvoice;
651 if (empty($line->subledger_account)) {
657 $tab[] = $line->label_operation;
658 $tab[] = $date_document;
659 if ($line->sens ==
'D') {
660 $tab[] =
price($line->debit);
662 } elseif ($line->sens ==
'C') {
664 $tab[] =
price($line->credit);
666 $tab[] = $line->doc_ref;
667 $tab[] = $line->label_operation;
669 $output = implode($separator, $tab).$end_line;
671 fwrite($exportFile, $output);
691 foreach ($objectLines as $line) {
696 $tab[] = $date_document;
697 $tab[] = $line->code_journal;
699 $tab[] = $line->piece_num;
700 $tab[] = $line->doc_ref;
701 $tab[] =
price($line->debit);
702 $tab[] =
price($line->credit);
706 $output = implode($separator, $tab).$end_line;
708 fwrite($exportFile, $output);
728 foreach ($objectLines as $line) {
733 $tab[] = $line->piece_num;
734 $tab[] = $date_document;
736 if (empty($line->subledger_account)) {
740 if (substr($line->numero_compte, 0, 3) ==
'411') {
743 if (substr($line->numero_compte, 0, 3) ==
'401') {
749 $tab[] =
price($line->debit);
750 $tab[] =
price($line->credit);
751 $tab[] =
dol_trunc($line->label_operation, 32);
753 $output = implode($separator, $tab).$end_line;
755 fwrite($exportFile, $output);
783 foreach ($objectLines as $line) {
785 if (!empty($line->subledger_account)) {
790 $date_echeance =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
794 $tab[] = str_pad($line->piece_num, 5);
795 $tab[] = str_pad(self::trunc($line->code_journal, 2), 2);
796 $tab[] = str_pad($date_document, 8,
' ', STR_PAD_LEFT);
797 $tab[] = str_pad($date_echeance, 8,
' ', STR_PAD_LEFT);
798 $tab[] = str_pad(self::trunc($line->doc_ref, 12), 12);
799 $tab[] = str_pad(self::trunc($code_compta, 11), 11);
800 $tab[] = str_pad(self::trunc(
dol_string_unaccent($line->doc_ref).dol_string_unaccent($line->label_operation), 25), 25);
801 $tab[] = str_pad(
price2fec(abs($line->debit - $line->credit)), 13,
' ', STR_PAD_LEFT);
802 $tab[] = str_pad($line->sens, 1);
803 $tab[] = str_repeat(
' ', 18);
807 $output = implode($tab).$end_line;
809 fwrite($exportFile, $output);
831 public function exportQuadratus($objectLines, $exportFile =
null, $archiveFileList = array(), $withAttachment = 0)
840 foreach ($objectLines as $line) {
844 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
845 $line->label_operation = str_replace(array(
"- ",
"…",
"..."),
"", $line->label_operation);
852 $line->subledger_label = str_replace(array(
"- ",
"…",
"..."),
"", $line->subledger_label);
855 $code_compta = $line->numero_compte;
856 if (!empty($line->subledger_account)) {
857 $code_compta = $line->subledger_account;
862 if (!empty($line->subledger_account)) {
863 $tab[
'type_ligne'] =
'C';
864 $tab[
'num_compte'] = str_pad(self::trunc($line->subledger_account, 8), 8);
865 $tab[
'lib_compte'] = str_pad(self::trunc($line->subledger_label, 30), 30);
867 if ($line->doc_type ==
'customer_invoice') {
868 $tab[
'lib_alpha'] = strtoupper(str_pad(
'C'.self::trunc(
dol_string_unaccent($line->subledger_label), 6), 7));
869 $tab[
'filler'] = str_repeat(
' ', 52);
870 $tab[
'coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, 8), 8);
871 } elseif ($line->doc_type ==
'supplier_invoice') {
872 $tab[
'lib_alpha'] = strtoupper(str_pad(
'F'.self::trunc(
dol_string_unaccent($line->subledger_label), 6), 7));
873 $tab[
'filler'] = str_repeat(
' ', 52);
874 $tab[
'coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, 8), 8);
876 $tab[
'filler'] = str_repeat(
' ', 59);
877 $tab[
'coll_compte'] = str_pad(
' ', 8);
880 $tab[
'filler2'] = str_repeat(
' ', 110);
883 if ($line->doc_type ==
'customer_invoice') {
884 $tab[
'type_compte'] =
'C';
885 } elseif ($line->doc_type ==
'supplier_invoice') {
886 $tab[
'type_compte'] =
'F';
888 $tab[
'type_compte'] =
'G';
891 $tab[
'filler3'] = str_repeat(
' ', 235);
893 $tab[
'end_line'] = $end_line;
896 fwrite($exportFile, implode($tab));
903 $tab[
'type_ligne'] =
'M';
904 $tab[
'num_compte'] = str_pad(self::trunc($code_compta, 8), 8);
905 $tab[
'code_journal'] = str_pad(self::trunc($line->code_journal, 2), 2);
906 $tab[
'folio'] =
'000';
911 $tab[
'date_ecriture'] =
dol_print_date($line->doc_date,
'%d%m%y');
912 $tab[
'filler'] =
' ';
913 $tab[
'libelle_ecriture'] = str_pad(self::trunc($line->doc_ref.
' '.$line->label_operation, 20), 20);
928 $tab[
'sens'] = $line->sens;
929 $tab[
'signe_montant'] =
'+';
932 $tab[
'montant'] = str_pad(abs(($line->debit - $line->credit) * 100), 12,
'0', STR_PAD_LEFT);
933 $tab[
'contrepartie'] = str_repeat(
' ', 8);
936 if (!empty($line->date_lim_reglement)) {
938 $tab[
'date_echeance'] =
dol_print_date($line->date_lim_reglement,
'%d%m%y');
940 $tab[
'date_echeance'] =
'000000';
945 $tab[
'lettrage'] = str_repeat(
' ', 2);
946 $tab[
'codestat'] = str_repeat(
' ', 3);
947 $tab[
'num_piece'] = str_pad(self::trunc($line->piece_num, 5), 5);
951 $tab[
'affaire'] = str_repeat(
' ', 10);
952 $tab[
'quantity1'] = str_repeat(
' ', 10);
953 $tab[
'num_piece2'] = str_pad(self::trunc($line->piece_num, 8), 8);
954 $tab[
'devis'] = str_pad($conf->currency, 3);
955 $tab[
'code_journal2'] = str_pad(self::trunc($line->code_journal, 3), 3);
956 $tab[
'filler3'] = str_repeat(
' ', 3);
964 $tab[
'libelle_ecriture2'] = str_pad(self::trunc($line->label_operation, 30), 30);
965 $tab[
'codetva'] = str_repeat(
' ', 2);
969 $tab[
'num_piece3'] = substr(self::trunc($line->doc_ref, 20), -10);
970 $tab[
'reserved'] = str_repeat(
' ', 10);
971 $tab[
'currency_amount'] = str_repeat(
' ', 13);
973 $attachmentFileName =
'';
974 if ($withAttachment == 1) {
975 $attachmentFileKey = trim($line->piece_num);
977 if (!isset($archiveFileList[$attachmentFileKey])) {
980 if ($line->doc_type ==
'customer_invoice') {
981 $objectDirPath = !empty($conf->facture->multidir_output[$conf->entity]) ? $conf->facture->multidir_output[$conf->entity] : $conf->facture->dir_output;
982 } elseif ($line->doc_type ==
'expense_report') {
983 $objectDirPath = !empty($conf->expensereport->multidir_output[$conf->entity]) ? $conf->expensereport->multidir_output[$conf->entity] : $conf->factureexpensereport->dir_output;
984 } elseif ($line->doc_type ==
'supplier_invoice') {
985 $objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output;
987 $arrayofinclusion = array();
988 $arrayofinclusion[] =
'^'.preg_quote($objectFileName,
'/').
'\.pdf$';
989 $fileFoundList =
dol_dir_list($objectDirPath.
'/'.$objectFileName,
'files', 0, implode(
'|', $arrayofinclusion),
'(\.meta|_preview.*\.png)$',
'date', SORT_DESC, 0,
true);
990 if (!empty($fileFoundList)) {
991 $attachmentFileNameTrunc = str_pad(self::trunc($line->piece_num, 8), 8,
'0', STR_PAD_LEFT);
992 foreach ($fileFoundList as $fileFound) {
993 if (strstr($fileFound[
'name'], $objectFileName)) {
994 $fileFoundPath = $objectDirPath.
'/'.$objectFileName.
'/'.$fileFound[
'name'];
995 if (file_exists($fileFoundPath)) {
996 $archiveFileList[$attachmentFileKey] = array(
997 'path' => $fileFoundPath,
998 'name' => $attachmentFileNameTrunc.
'.pdf',
1007 if (isset($archiveFileList[$attachmentFileKey])) {
1008 $attachmentFileName = $archiveFileList[$attachmentFileKey][
'name'];
1012 $tab[
'attachment'] = $attachmentFileName;
1014 $tab[
'attachment'] = str_repeat(
' ', 12);
1016 $tab[
'filler4'] = str_repeat(
' ', 38);
1017 $tab[
'end_line'] = $end_line;
1020 fwrite($exportFile, implode($tab));
1022 print implode($tab);
1026 return $archiveFileList;
1052 foreach ($objectLines as $line) {
1053 $code_compta = $line->numero_compte;
1054 if (!empty($line->subledger_account)) {
1055 $code_compta = $line->subledger_account;
1060 $tab[
'code_journal'] = str_pad(
dol_trunc($line->code_journal, 2,
'right',
'UTF-8', 1), 2);
1065 $tab[
'date_operation'] =
dol_print_date($line->doc_date,
'%d%m%Y');
1067 $tab[
'folio'] =
' 1';
1069 $tab[
'num_ecriture'] = str_pad(
dol_trunc($index, 6,
'right',
'UTF-8', 1), 6,
' ', STR_PAD_LEFT);
1071 $tab[
'jour_ecriture'] =
dol_print_date($line->doc_date,
'%d%m%y');
1073 $tab[
'num_compte'] = str_pad(
dol_trunc($code_compta, 6,
'right',
'UTF-8', 1), 6,
'0');
1075 if ($line->sens ==
'D') {
1076 $tab[
'montant_debit'] = str_pad(number_format($line->debit, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
1078 $tab[
'montant_crebit'] = str_pad(number_format(0, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
1080 $tab[
'montant_debit'] = str_pad(number_format(0, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
1082 $tab[
'montant_crebit'] = str_pad(number_format($line->credit, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
1087 $tab[
'lettrage'] = str_repeat(
dol_trunc($line->lettering_code, 2,
'left',
'UTF-8', 1), 2);
1089 $tab[
'code_piece'] = str_pad(
dol_trunc($line->piece_num, 5,
'left',
'UTF-8', 1), 5,
' ', STR_PAD_LEFT);
1091 $tab[
'code_stat'] = str_repeat(
' ', 4);
1093 if (!empty($line->date_lim_reglement)) {
1095 $tab[
'date_echeance'] =
dol_print_date($line->date_lim_reglement,
'%d%m%Y');
1097 $tab[
'date_echeance'] =
dol_print_date($line->doc_date,
'%d%m%Y');
1100 $tab[
'monnaie'] =
'1';
1102 $tab[
'filler'] =
' ';
1104 $tab[
'ind_compteur'] =
' ';
1106 $tab[
'quantite'] =
'0,000000000';
1108 $tab[
'code_pointage'] = str_repeat(
' ', 2);
1110 $tab[
'end_line'] = $end_line;
1112 print implode(
'|', $tab);
1132 foreach ($objectLines as $line) {
1138 $tab[] = $date_document;
1139 $tab[] = $line->code_journal;
1140 if (empty($line->subledger_account)) {
1141 $tab[] = $line->numero_compte;
1143 $tab[] = $line->subledger_account;
1146 $tab[] =
'"'.dol_trunc($line->label_operation, 40,
'right',
'UTF-8', 1).
'"';
1147 $tab[] =
'"'.dol_trunc($line->piece_num, 15,
'right',
'UTF-8', 1).
'"';
1148 $tab[] =
price2num(abs($line->debit - $line->credit));
1149 $tab[] = $line->sens;
1150 $tab[] = $date_document;
1153 $output = implode($separator, $tab).$end_line;
1155 fwrite($exportFile, $output);
1175 foreach ($objectLines as $line) {
1180 $tab[] = $line->piece_num;
1182 $tab[] = $date_document;
1185 if (empty($line->subledger_account)) {
1194 $tab[] =
price($line->debit);
1195 $tab[] =
price($line->credit);
1196 $tab[] =
price(abs($line->debit - $line->credit));
1197 $tab[] = $line->sens;
1198 $tab[] = $line->lettering_code;
1199 $tab[] = $line->code_journal;
1201 $output = implode($separator, $tab).$end_line;
1203 fwrite($exportFile, $output);
1222 foreach ($objectLines as $line) {
1227 $tab[] = $date_document;
1228 $tab[] = $line->code_journal;
1229 if (empty($line->subledger_account)) {
1234 $tab[] = $line->doc_ref;
1235 $tab[] = $line->label_operation;
1236 $tab[] =
price($line->debit);
1237 $tab[] =
price($line->credit);
1239 $output = implode($separator, $tab).$end_line;
1241 fwrite($exportFile, $output);
1259 $separator = $this->separator;
1261 foreach ($objectLines as $line) {
1262 $date_document =
dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
1266 $tab[] = $line->piece_num;
1267 $tab[] = $date_document;
1268 $tab[] = $line->doc_ref;
1269 $tab[] = preg_match(
'/'.$separator.
'/', $line->label_operation) ?
"'".$line->label_operation.
"'" : $line->label_operation;
1274 $tab[] =
price2num($line->debit - $line->credit);
1275 $tab[] = $line->code_journal;
1277 $output = implode($separator, $tab).$this->end_line;
1279 fwrite($exportFile, $output);
1301 $tab[] =
"JournalCode";
1302 $tab[] =
"JournalLib";
1303 $tab[] =
"EcritureNum";
1304 $tab[] =
"EcritureDate";
1305 $tab[] =
"CompteNum";
1306 $tab[] =
"CompteLib";
1307 $tab[] =
"CompAuxNum";
1308 $tab[] =
"CompAuxLib";
1309 $tab[] =
"PieceRef";
1310 $tab[] =
"PieceDate";
1311 $tab[] =
"EcritureLib";
1314 $tab[] =
"EcritureLet";
1316 $tab[] =
"ValidDate";
1317 $tab[] =
"Montantdevise";
1319 $tab[] =
"DateLimitReglmt";
1320 $tab[] =
"NumFacture";
1322 $output = implode($separator, $tab).$end_line;
1324 fwrite($exportFile, $output);
1329 foreach ($objectLines as $line) {
1330 if ($line->debit == 0 && $line->credit == 0) {
1335 $date_lettering =
dol_print_date($line->date_lettering,
'%Y%m%d');
1336 $date_validation =
dol_print_date($line->date_validation,
'%Y%m%d');
1337 $date_limit_payment =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1340 if ($line->doc_type ==
'customer_invoice') {
1342 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1343 $invoice =
new Facture($this->db);
1344 $invoice->fetch($line->fk_doc);
1346 $refInvoice = $invoice->ref;
1347 } elseif ($line->doc_type ==
'supplier_invoice') {
1349 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1351 $invoice->fetch($line->fk_doc);
1353 $refInvoice = $invoice->ref_supplier;
1359 $tab[] = $line->code_journal;
1364 $tab[] = $labeljournal;
1367 $tab[] = $line->piece_num;
1370 $tab[] = $date_document;
1385 $tab[] = $line->doc_ref;
1392 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1402 $tab[] = $line->lettering_code;
1405 $tab[] = $date_lettering;
1408 $tab[] = $date_validation;
1411 $tab[] = $line->multicurrency_amount;
1414 $tab[] = $line->multicurrency_code;
1417 $tab[] = $date_limit_payment;
1421 $refInvoice = str_replace(array(
"\t",
"\n",
"\r"),
" ", $refInvoice);
1422 $tab[] =
dol_trunc(self::toAnsi($refInvoice), 17,
'right',
'UTF-8', 1);
1424 $output = implode($separator, $tab).$end_line;
1426 fwrite($exportFile, $output);
1449 $tab[] =
"JournalCode";
1450 $tab[] =
"JournalLib";
1451 $tab[] =
"EcritureNum";
1452 $tab[] =
"EcritureDate";
1453 $tab[] =
"CompteNum";
1454 $tab[] =
"CompteLib";
1455 $tab[] =
"CompAuxNum";
1456 $tab[] =
"CompAuxLib";
1457 $tab[] =
"PieceRef";
1458 $tab[] =
"PieceDate";
1459 $tab[] =
"EcritureLib";
1462 $tab[] =
"EcritureLet";
1464 $tab[] =
"ValidDate";
1465 $tab[] =
"Montantdevise";
1467 $tab[] =
"DateLimitReglmt";
1468 $tab[] =
"NumFacture";
1470 $output = implode($separator, $tab).$end_line;
1472 fwrite($exportFile, $output);
1477 foreach ($objectLines as $line) {
1478 if ($line->debit == 0 && $line->credit == 0) {
1483 $date_lettering =
dol_print_date($line->date_lettering,
'%Y%m%d');
1484 $date_validation =
dol_print_date($line->date_validation,
'%Y%m%d');
1485 $date_limit_payment =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1488 if ($line->doc_type ==
'customer_invoice') {
1490 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1491 $invoice =
new Facture($this->db);
1492 $invoice->fetch($line->fk_doc);
1494 $refInvoice = $invoice->ref;
1495 } elseif ($line->doc_type ==
'supplier_invoice') {
1497 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1499 $invoice->fetch($line->fk_doc);
1501 $refInvoice = $invoice->ref_supplier;
1507 $tab[] = $line->code_journal;
1512 $tab[] = $labeljournal;
1515 $tab[] = $line->piece_num;
1518 $tab[] = $date_creation;
1533 $tab[] = $line->doc_ref;
1536 $tab[] = $date_document;
1540 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1550 $tab[] = $line->lettering_code;
1553 $tab[] = $date_lettering;
1556 $tab[] = $date_validation;
1559 $tab[] = $line->multicurrency_amount;
1562 $tab[] = $line->multicurrency_code;
1565 $tab[] = $date_limit_payment;
1569 $refInvoice = str_replace(array(
"\t",
"\n",
"\r"),
" ", $refInvoice);
1570 $tab[] =
dol_trunc(self::toAnsi($refInvoice), 17,
'right',
'UTF-8', 1);
1572 $output = implode($separator, $tab).$end_line;
1574 fwrite($exportFile, $output);
1615 $tab[] =
"FW-Betrag";
1622 $output = implode($separator, $tab).$end_line;
1624 fwrite($exportFile, $output);
1630 $thisPieceAccountNr =
"";
1631 $aSize = count($objectLines);
1632 foreach ($objectLines as $aIndex => $line) {
1633 $sammelBuchung =
false;
1634 if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) {
1635 $sammelBuchung =
true;
1636 } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) {
1637 $sammelBuchung =
true;
1638 } elseif ($aIndex + 1 < $aSize
1639 && $objectLines[$aIndex + 1]->piece_num == $line->piece_num
1640 && $aIndex - 1 < $aSize
1641 && $objectLines[$aIndex - 1]->piece_num == $line->piece_num
1643 $sammelBuchung =
true;
1649 $tab[] = $line->piece_num;
1653 $tab[] = $date_document;
1658 if ($line->sens ==
'D') {
1666 if (empty($line->code_tiers)) {
1667 if ($line->piece_num == $thisPieceNum) {
1676 $tab[] = $this->separator;
1685 if ($sammelBuchung) {
1693 $tab[] = abs($line->debit - $line->credit);
1700 if ($line1 ==
"LIQ" || $line1 ==
"LIQ Beleg ok" || strlen($line1) <= 3) {
1704 if (strlen($line1) == 0) {
1708 if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) {
1709 $line1 = $line1.
' / '.$line2;
1713 $tab[] =
'"'.self::toAnsi($line1).
'"';
1715 $tab[] =
'"'.self::toAnsi($line2).
'"';
1719 $tab[] = $this->separator;
1724 $output = implode($separator, $tab).$end_line;
1726 fwrite($exportFile, $output);
1731 if ($line->piece_num !== $thisPieceNum) {
1732 $thisPieceNum = $line->piece_num;
1733 $thisPieceAccountNr = $line->numero_compte;
1752 foreach ($objectLines as $line) {
1755 $date_lim_reglement =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1760 $type_enregistrement =
'E';
1761 $tab[] = $type_enregistrement;
1763 $tab[] = substr($line->code_journal, 0, 2);
1767 $tab[] = $line->piece_num;
1769 $tab[] = $date_document;
1771 $tab[] = $line->label_operation;
1773 $tab[] = $date_lim_reglement;
1775 if ($line->doc_type ==
'supplier_invoice') {
1776 if (($line->debit - $line->credit) > 0) {
1777 $nature_piece =
'AF';
1779 $nature_piece =
'FF';
1781 } elseif ($line->doc_type ==
'customer_invoice') {
1782 if (($line->debit - $line->credit) < 0) {
1783 $nature_piece =
'AC';
1785 $nature_piece =
'FC';
1790 $tab[] = $nature_piece;
1801 $racine_subledger_account =
'';
1804 $tab[] = $racine_subledger_account;
1806 $tab[] =
price(abs($line->debit - $line->credit), 0,
'', 1, 2, 2);
1808 $tab[] = $line->sens;
1812 $tab[] = $date_creation;
1814 $tab[] = $line->lettering_code;
1816 $tab[] = $line->date_lettering;
1818 if (!empty($line->subledger_account)) {
1824 if ($line->doc_type ==
'supplier_invoice' && !empty($line->subledger_account)) {
1826 } elseif ($line->doc_type ==
'customer_invoice' && !empty($line->subledger_account)) {
1840 $tab[] = $line->doc_ref;
1868 $output = implode($separator, $tab).$end_line;
1870 fwrite($exportFile, $output);
1889 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
1893 $last_codeinvoice =
'';
1895 foreach ($objectLines as $line) {
1897 if ($last_codeinvoice != $line->doc_ref) {
1899 $sql =
"SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX.
"societe";
1900 $sql .=
" WHERE code_client = '".$this->db->escape($line->thirdparty_code).
"'";
1901 $resql = $this->db->query($sql);
1903 if ($resql && $this->db->num_rows($resql) > 0) {
1904 $soc = $this->db->fetch_object($resql);
1906 $address = array(
'',
'',
'');
1907 if (strpos($soc->address,
"\n") !==
false) {
1908 $address = explode(
"\n", $soc->address);
1909 if (is_array($address) && count($address) > 0) {
1910 foreach ($address as $key => $data) {
1911 $address[$key] = str_replace(array(
"\t",
"\n",
"\r"),
"", $data);
1912 $address[$key] =
dol_trunc($address[$key], 40,
'right',
'UTF-8', 1);
1916 $address[0] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 0, 40);
1917 $address[1] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 41, 40);
1918 $address[2] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 82, 40);
1923 $type_enregistrement =
'C';
1925 $tab[] = $type_enregistrement;
1927 $tab[] = $soc->code_client;
1937 $tab[] = $address[0];
1939 $tab[] = $address[1];
1941 $tab[] = $address[2];
1945 $tab[] = substr($soc->town, 0, 40);
1949 $tab[] = substr(
getCountry($soc->fk_pays), 0, 40);
1951 $tab[] = $soc->phone;
1963 $tab[] = str_replace(
" ",
"", $soc->siret);
2021 $output = implode($separator, $tab).$end_line;
2023 fwrite($exportFile, $output);
2034 $date_lim_reglement =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
2037 $type_enregistrement =
'E';
2038 $tab[] = $type_enregistrement;
2040 $tab[] = substr($line->code_journal, 0, 2);
2044 $tab[] = $line->piece_num;
2046 $tab[] = $date_document;
2048 $tab[] =
dol_trunc($line->label_operation, 25,
'right',
'UTF-8', 1);
2050 $tab[] = $date_lim_reglement;
2052 if ($line->doc_type ==
'supplier_invoice') {
2053 if (($line->amount) < 0) {
2054 $nature_piece =
'AF';
2056 $nature_piece =
'FF';
2058 } elseif ($line->doc_type ==
'customer_invoice') {
2059 if (($line->amount) < 0) {
2060 $nature_piece =
'AC';
2062 $nature_piece =
'FC';
2067 $tab[] = $nature_piece;
2078 $racine_subledger_account =
'';
2081 $tab[] = $racine_subledger_account;
2083 $tab[] =
price(abs($line->debit - $line->credit), 0,
'', 1, 2);
2085 $tab[] = $line->sens;
2089 $tab[] = $date_document;
2091 $tab[] = $line->lettering_code;
2093 $tab[] = $line->date_lettering;
2095 if (!empty($line->subledger_account)) {
2101 if ($line->doc_type ==
'supplier_invoice' && !empty($line->subledger_account)) {
2103 } elseif ($line->doc_type ==
'customer_invoice' && !empty($line->subledger_account)) {
2115 $tab[] = $line->doc_ref;
2149 $output = implode($separator, $tab).$end_line;
2151 fwrite($exportFile, $output);
2156 $last_codeinvoice = $line->doc_ref;
2170 $langs->load(
'compta');
2177 $tab[] = $langs->transnoentitiesnoconv(
'Date');
2178 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'Journal'), 6);
2179 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'Account'), 15);
2180 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'LabelAccount'), 60);
2181 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'Piece'), 20);
2182 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'LabelOperation'), 60);
2183 $tab[] = $langs->transnoentitiesnoconv(
'Amount');
2185 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 1', 15);
2186 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 1', 60);
2187 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 2', 15);
2188 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 2', 60);
2189 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 3', 15);
2190 $tab[] =
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 3', 60);
2192 $output = implode($separator, $tab).$end_line;
2194 fwrite($exportFile, $output);
2199 foreach ($objectLines as $line) {
2204 $tab[] = $date_document;
2208 if (!empty($line->subledger_account)) {
2209 $account = $line->subledger_account;
2211 $account = $line->numero_compte;
2218 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
2220 $tab[] =
price(abs($line->debit - $line->credit));
2221 $tab[] = $line->sens;
2229 $output = implode($separator, $tab).$end_line;
2231 fwrite($exportFile, $output);
2252 $invoices_infos = array();
2253 $supplier_invoices_infos = array();
2254 foreach ($objectLines as $line) {
2255 if ($line->debit == 0 && $line->credit == 0) {
2259 $date_echeance =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
2261 $invoice_ref = $line->doc_ref;
2264 if (($line->doc_type ==
'customer_invoice' || $line->doc_type ==
'supplier_invoice') && $line->fk_doc > 0) {
2265 if (($line->doc_type ==
'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) ||
2266 ($line->doc_type ==
'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) {
2267 if ($line->doc_type ==
'customer_invoice') {
2269 $sql =
'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX .
'facture as f';
2270 $sql .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe AS s ON f.fk_soc = s.rowid';
2271 $sql .=
' WHERE f.rowid = '.((int) $line->fk_doc);
2272 $resql = $this->db->query($sql);
2274 if ($obj = $this->db->fetch_object($resql)) {
2276 $invoices_infos[$line->fk_doc] = array(
'ref' => $obj->ref,
'company_name' => $obj->nom);
2277 $invoice_ref = $obj->ref;
2278 $company_name = $obj->nom;
2283 $sql =
'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX .
'facture_fourn as ff';
2284 $sql .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe AS s ON ff.fk_soc = s.rowid';
2285 $sql .=
' WHERE ff.rowid = '.((int) $line->fk_doc);
2286 $resql = $this->db->query($sql);
2288 if ($obj = $this->db->fetch_object($resql)) {
2290 $supplier_invoices_infos[$line->fk_doc] = array(
'ref' => $obj->ref,
'company_name' => $obj->nom);
2291 $invoice_ref = $obj->ref;
2292 $company_name = $obj->nom;
2296 } elseif ($line->doc_type ==
'customer_invoice') {
2298 $invoice_ref = $invoices_infos[$line->fk_doc][
'ref'];
2299 $company_name = $invoices_infos[$line->fk_doc][
'company_name'];
2302 $invoice_ref = $supplier_invoices_infos[$line->fk_doc][
'ref'];
2303 $company_name = $supplier_invoices_infos[$line->fk_doc][
'company_name'];
2310 $tab[] = $date_document;
2311 $tab[] = substr($line->code_journal, 0, 4);
2313 if ((substr($line->numero_compte, 0, 3) ==
'411') || (substr($line->numero_compte, 0, 3) ==
'401')) {
2322 $tab[] =
dol_trunc(str_replace(
'"',
'', $invoice_ref . (!empty($company_name) ?
' - ' :
'') . $company_name), 40,
'right',
'UTF-8', 1);
2324 $tab[] =
dol_trunc(str_replace(
'"',
'', $line->piece_num), 10,
'right',
'UTF-8', 1);
2328 $tab[] =
price2num(abs($line->debit - $line->credit));
2330 $tab[] = $line->sens;
2334 $tab[] = $date_echeance;
2336 $output = implode($separator, $tab).$end_line;
2338 fwrite($exportFile, $output);
2359 foreach ($objectLines as $line) {
2360 if ($line->debit == 0 && $line->credit == 0) {
2368 $tab[] = $date_document;
2369 $tab[] = substr($line->code_journal, 0, 4);
2370 if ((substr($line->numero_compte, 0, 3) ==
'411') || (substr($line->numero_compte, 0, 3) ==
'401')) {
2376 $tab[] =
'"'.dol_trunc(str_replace(
'"',
'', $line->label_operation), 40,
'right',
'UTF-8', 1).
'"';
2377 $tab[] =
'"' .
dol_trunc(str_replace(
'"',
'', $line->doc_ref), 40,
'right',
'UTF-8', 1) .
'"';
2378 $tab[] =
'"' .
dol_trunc(str_replace(
'"',
'', $line->piece_num), 10,
'right',
'UTF-8', 1) .
'"';
2379 $tab[] =
price2num(abs($line->debit - $line->credit));
2380 $tab[] = $line->sens;
2381 $tab[] = $date_document;
2386 $output = implode($separator, $tab).$end_line;
2388 fwrite($exportFile, $output);
2411 foreach ($objectLines as $line) {
2416 $tab[] = $line->piece_num;
2418 $tab[] = substr($date, 6, 4);
2419 $tab[] = substr($date, 3, 2);
2420 $tab[] = substr($date, 0, 2);
2421 $tab[] = $line->doc_ref;
2423 $tab[] = mb_convert_encoding(str_replace(
' - Compte auxiliaire',
'', $line->label_operation),
"Windows-1252",
'UTF-8');
2429 $numero_cpt_client =
'411';
2430 $numero_cpt_fourn =
'401';
2431 for ($i = 1; $i <= ($taille_numero - 3); $i++) {
2432 $numero_cpt_client .=
'0';
2433 $numero_cpt_fourn .=
'0';
2442 $nom_client = explode(
" - ", $line->label_operation);
2443 $tab[] = mb_convert_encoding($nom_client[0],
"Windows-1252",
'UTF-8');
2444 $tab[] =
price($line->debit);
2445 $tab[] =
price($line->credit);
2446 $tab[] =
price($line->montant);
2447 $tab[] = $line->code_journal;
2449 $output = implode($separator, $tab).$end_line;
2451 fwrite($exportFile, $output);
2465 public static function trunc($str, $size)
2467 return dol_trunc($str, $size,
'right',
'UTF-8', 1);
2477 public static function toAnsi($str, $size = -1)
2480 if ($retVal >= 0 && $size >= 0) {
2481 $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.
exportCogilog($objectLines, $exportFile=null)
Export format : COGILOG Last review for this format : 2022-07-12 Alexandre Spangaro (aspangaro@open-d...
exportAgiris($objectLines, $exportFile=null)
Export format : Agiris Isacompta.
exportFEC2($objectLines, $exportFile=null)
Export format : FEC2.
exportQuadratus($objectLines, $exportFile=null, $archiveFileList=array(), $withAttachment=0)
Export format : Quadratus (Format ASCII) Format since 2015 compatible QuadraCOMPTA Last review for th...
exportWinfic($objectLines, $exportFile=null)
Export format : WinFic - eWinfic - WinSis Compta Last review for this format : 2022-11-01 Alexandre S...
exportSAGE50SWISS($objectLines, $exportFile=null)
Export format : SAGE50SWISS.
exportOpenConcerto($objectLines, $exportFile=null)
Export format : OpenConcerto.
exportEbp($objectLines, $exportFile=null)
Export format : EBP.
exportLDCompta10($objectLines, $exportFile=null)
Export format : LD Compta version 10 & higher Last review for this format : 08-15-2021 Alexandre Span...
exportFEC($objectLines, $exportFile=null)
Export format : FEC.
exportCharlemagne($objectLines, $exportFile=null)
Export format : Charlemagne.
getTypeConfig()
Array with all export type available (key + label) and parameters for config.
exportLDCompta($objectLines, $exportFile=null)
Export format : LD Compta version 9 http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Docu...
exportBob50($objectLines, $exportFile=null)
Export format : BOB50.
export(&$TData, $formatexportset, $withAttachment=0, $downloadMode=0, $outputMode=0)
Function who chose which export to use with the default config, and make the export into a file.
exportGestimumV3($objectLines, $exportFile=null)
Export format : Gestimum V3.
static trunc($str, $size)
trunc
exportiSuiteExpert($objectLines, $exportFile=null)
Export format : iSuite Expert.
exportCiel($objectLines, $exportFile=null)
Export format : CIEL (Format XIMPORT) Format since 2003 compatible CIEL version > 2002 / Sage50 Last ...
static toAnsi($str, $size=-1)
toAnsi
getType()
Array with all export type available (key + label)
exportConfigurable($objectLines, $exportFile=null)
Export format : Configurable CSV.
static getFormatCode($type)
Return string to summarize the format (Used to generated export filename)
__construct(DoliDB $db)
Constructor.
exportCegid($objectLines, $exportFile=null)
Export format : CEGID.
exportCoala($objectLines, $exportFile=null)
Export format : COALA.
getMimeType($formatexportset)
Return the MIME type of a file.
exportGestimumV5($objectLines, $exportFile=null)
Export format : Gestimum V5.
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.
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.
dol_is_dir($folder)
Test if filename is a directory.
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_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.