dolibarr 19.0.4
accountancyexport.class.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
6 * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
7 * Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
8 * Copyright (C) 2016-2024 Alexandre Spangaro <aspangaro@open-dsi.fr>
9 * Copyright (C) 2022 Lionel Vessiller <lvessiller@open-dsi.fr>
10 * Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com>
11 * Copyright (C) 2017 Elarifr. Ari Elbaz <github@accedinfo.com>
12 * Copyright (C) 2017-2019 Frédéric France <frederic.france@netlogic.fr>
13 * Copyright (C) 2017 André Schild <a.schild@aarboard.ch>
14 * Copyright (C) 2020 Guillaume Alexandre <guillaume@tag-info.fr>
15 * Copyright (C) 2022 Joachim Kueter <jkueter@gmx.de>
16 * Copyright (C) 2022 Progiseize <a.bisotti@progiseize.fr>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 3 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program. If not, see <https://www.gnu.org/licenses/>.
30 */
31
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';
44
49{
50 // Type of export. Used into $conf->global->ACCOUNTING_EXPORT_MODELCSV
51 public static $EXPORT_TYPE_CONFIGURABLE = 1; // CSV
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;
69 // Generic FEC after that
70 public static $EXPORT_TYPE_FEC = 1000;
71 public static $EXPORT_TYPE_FEC2 = 1010;
72
76 public $db;
77
81 public $errors = array();
82
87 public $separator = '';
88
93 public $end_line = '';
94
100 public function __construct(DoliDB $db)
101 {
102 global $conf, $hookmanager;
103
104 $this->db = $db;
105 $this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
106 $this->end_line = getDolGlobalString('ACCOUNTING_EXPORT_ENDLINE') ? (getDolGlobalInt('ACCOUNTING_EXPORT_ENDLINE') == 1 ? "\n" : "\r\n") : "\n";
107
108 $hookmanager->initHooks(array('accountancyexport'));
109 }
110
116 public function getType()
117 {
118 global $langs, $hookmanager;
119
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',
141 );
142
143 // allow modules to define export formats
144 $parameters = array();
145 $reshook = $hookmanager->executeHooks('getType', $parameters, $listofexporttypes);
146
147 ksort($listofexporttypes, SORT_NUMERIC);
148
149 return $listofexporttypes;
150 }
151
158 public static function getFormatCode($type)
159 {
160 $formatcode = array(
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',
181 );
182
183 global $hookmanager;
184 $code = $formatcode[$type];
185 $parameters = array('type' => $type);
186 $reshook = $hookmanager->executeHooks('getFormatCode', $parameters, $code);
187
188 return $code;
189 }
190
196 public function getTypeConfig()
197 {
198 global $conf, $langs;
199
200 $exporttypes = array(
201 'param' => array(
202 self::$EXPORT_TYPE_CONFIGURABLE => array(
203 'label' => $langs->trans('Modelcsv_configurable'),
204 'ACCOUNTING_EXPORT_FORMAT' => getDolGlobalString('ACCOUNTING_EXPORT_FORMAT', 'txt'),
205 'ACCOUNTING_EXPORT_SEPARATORCSV' => getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV', ','),
206 'ACCOUNTING_EXPORT_ENDLINE' => getDolGlobalString('ACCOUNTING_EXPORT_ENDLINE', 1),
207 'ACCOUNTING_EXPORT_DATE' => getDolGlobalString('ACCOUNTING_EXPORT_DATE', '%Y-%m-%d'),
208 ),
209 self::$EXPORT_TYPE_CEGID => array(
210 'label' => $langs->trans('Modelcsv_CEGID'),
211 ),
212 self::$EXPORT_TYPE_COALA => array(
213 'label' => $langs->trans('Modelcsv_COALA'),
214 ),
215 self::$EXPORT_TYPE_BOB50 => array(
216 'label' => $langs->trans('Modelcsv_bob50'),
217 ),
218 self::$EXPORT_TYPE_CIEL => array(
219 'label' => $langs->trans('Modelcsv_ciel'),
220 'ACCOUNTING_EXPORT_FORMAT' => 'txt',
221 ),
222 self::$EXPORT_TYPE_QUADRATUS => array(
223 'label' => $langs->trans('Modelcsv_quadratus'),
224 'ACCOUNTING_EXPORT_FORMAT' => 'txt',
225 ),
226 self::$EXPORT_TYPE_WINFIC => array(
227 'label' => $langs->trans('Modelcsv_winfic'),
228 'ACCOUNTING_EXPORT_FORMAT' => 'txt',
229 ),
230 self::$EXPORT_TYPE_EBP => array(
231 'label' => $langs->trans('Modelcsv_ebp'),
232 ),
233 self::$EXPORT_TYPE_COGILOG => array(
234 'label' => $langs->trans('Modelcsv_cogilog'),
235 ),
236 self::$EXPORT_TYPE_AGIRIS => array(
237 'label' => $langs->trans('Modelcsv_agiris'),
238 ),
239 self::$EXPORT_TYPE_OPENCONCERTO => array(
240 'label' => $langs->trans('Modelcsv_openconcerto'),
241 ),
242 self::$EXPORT_TYPE_SAGE50_SWISS => array(
243 'label' => $langs->trans('Modelcsv_Sage50_Swiss'),
244 ),
245 self::$EXPORT_TYPE_CHARLEMAGNE => array(
246 'label' => $langs->trans('Modelcsv_charlemagne'),
247 'ACCOUNTING_EXPORT_FORMAT' => 'txt',
248 ),
249 self::$EXPORT_TYPE_LDCOMPTA => array(
250 'label' => $langs->trans('Modelcsv_LDCompta'),
251 ),
252 self::$EXPORT_TYPE_LDCOMPTA10 => array(
253 'label' => $langs->trans('Modelcsv_LDCompta10'),
254 ),
255 self::$EXPORT_TYPE_GESTIMUMV3 => array(
256 'label' => $langs->trans('Modelcsv_Gestinumv3'),
257 'ACCOUNTING_EXPORT_FORMAT' => 'txt',
258 ),
259 self::$EXPORT_TYPE_GESTIMUMV5 => array(
260 'label' => $langs->trans('Modelcsv_Gestinumv5'),
261 'ACCOUNTING_EXPORT_FORMAT' => 'txt',
262 ),
263 self::$EXPORT_TYPE_FEC => array(
264 'label' => $langs->trans('Modelcsv_FEC'),
265 'ACCOUNTING_EXPORT_FORMAT' => 'txt',
266 ),
267 self::$EXPORT_TYPE_FEC2 => array(
268 'label' => $langs->trans('Modelcsv_FEC2'),
269 'ACCOUNTING_EXPORT_FORMAT' => 'txt',
270 ),
271 self::$EXPORT_TYPE_ISUITEEXPERT => array(
272 'label' => 'iSuite Expert',
273 'ACCOUNTING_EXPORT_FORMAT' => 'csv',
274 ),
275 ),
276 'cr'=> array(
277 '1' => $langs->trans("Unix"),
278 '2' => $langs->trans("Windows")
279 ),
280 'format' => array(
281 'csv' => $langs->trans("csv"),
282 'txt' => $langs->trans("txt")
283 ),
284 );
285
286 global $hookmanager;
287 $parameters = array();
288 $reshook = $hookmanager->executeHooks('getTypeConfig', $parameters, $exporttypes);
289 return $exporttypes;
290 }
291
292
299 public function getMimeType($formatexportset)
300 {
301 $mime = 'text/csv';
302
303 switch ($formatexportset) {
304 case self::$EXPORT_TYPE_FEC:
305 $mime = 'text/tab-separated-values';
306 break;
307 default:
308 $mime = 'text/csv';
309 break;
310 }
311
312 return $mime;
313 }
314
330 public function export(&$TData, $formatexportset, $withAttachment = 0, $downloadMode = 0, $outputMode = 0)
331 {
332 global $conf, $langs;
333 global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php
334
335 // Define name of file to save
336 $filename = 'general_ledger-'.$this->getFormatCode($formatexportset);
337 $type_export = 'general_ledger';
338
339 global $db; // The tpl file use $db
340 $completefilename = '';
341 $exportFile = null;
342 $exportFileName = '';
343 $exportFilePath = '';
344 $exportFileFullName ='';
345 $downloadFileMimeType = '';
346 $downloadFileFullName = '';
347 $downloadFilePath = '';
348 $archiveFullName = '';
349 $archivePath = '';
350 $archiveFileList = array();
351 if ($withAttachment == 1) {
352 if ($downloadMode == 0) {
353 $downloadMode = 1; // force to download after writing all files (can't use direct download)
354 }
355 if ($outputMode == 0) {
356 $outputMode = 1; // force to put files in a temp directory (can't use print on screen)
357 }
358
359 // PHP ZIP extension must be enabled
360 if (!extension_loaded('zip')) {
361 $langs->load('install');
362 $this->errors[] = $langs->trans('ErrorPHPDoesNotSupport', 'ZIP');
363 return -1;
364 }
365 }
366
367 $mimetype = $this->getMimeType($formatexportset);
368 if ($downloadMode == 0) {
369 // begin to print header for direct download
370 top_httphead($mimetype, 1);
371 }
372 include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
373 if ($outputMode == 1 || $outputMode == 2) {
374 if ($outputMode == 1) {
375 // uses temp directory by default to write files
376 if (!empty($conf->accounting->multidir_temp[$conf->entity])) {
377 $outputDir = $conf->accounting->multidir_temp[$conf->entity];
378 } else {
379 $outputDir = $conf->accounting->dir_temp;
380 }
381 } else {
382 // uses default export directory "accounting/export"
383 if (!empty($conf->accounting->multidir_output[$conf->entity])) {
384 $outputDir = $conf->accounting->multidir_output[$conf->entity];
385 } else {
386 $outputDir = $conf->accounting->dir_output;
387 }
388
389 // directory already created when module is enabled
390 $outputDir .= '/export';
391 $outputDir .= '/'.dol_sanitizePathName($formatexportset);
392 }
393
394 if (!dol_is_dir($outputDir)) {
395 if (dol_mkdir($outputDir) < 0) {
396 $this->errors[] = $langs->trans('ErrorCanNotCreateDir', $outputDir);
397 return -1;
398 }
399 }
400
401 if ($outputDir != '') {
402 if (!dol_is_dir($outputDir)) {
403 $langs->load('errors');
404 $this->errors[] = $langs->trans('ErrorDirNotFound', $outputDir);
405 return -1;
406 }
407
408 if (!empty($completefilename)) {
409 // create export file
410 $exportFileFullName = $completefilename;
411 $exportFileBaseName = basename($exportFileFullName);
412 $exportFileName = pathinfo($exportFileBaseName, PATHINFO_FILENAME);
413 $exportFilePath = $outputDir . '/' . $exportFileFullName;
414 $exportFile = fopen($exportFilePath, 'w');
415 if (!$exportFile) {
416 $this->errors[] = $langs->trans('ErrorFileNotFound', $exportFilePath);
417 return -1;
418 }
419
420 if ($withAttachment == 1) {
421 $archiveFileList[0] = array(
422 'path' => $exportFilePath,
423 'name' => $exportFileFullName,
424 );
425
426 // archive name and path
427 $archiveFullName = $exportFileName . '.zip';
428 $archivePath = $outputDir . '/' . $archiveFullName;
429 }
430 }
431 }
432 }
433
434 // export file (print on screen or write in a file) and prepare archive list if with attachment is set to 1
435 switch ($formatexportset) {
436 case self::$EXPORT_TYPE_CONFIGURABLE:
437 $this->exportConfigurable($TData, $exportFile);
438 break;
439 case self::$EXPORT_TYPE_CEGID:
440 $this->exportCegid($TData, $exportFile);
441 break;
442 case self::$EXPORT_TYPE_COALA:
443 $this->exportCoala($TData, $exportFile);
444 break;
445 case self::$EXPORT_TYPE_BOB50:
446 $this->exportBob50($TData, $exportFile);
447 break;
448 case self::$EXPORT_TYPE_CIEL:
449 $this->exportCiel($TData, $exportFile);
450 break;
451 case self::$EXPORT_TYPE_QUADRATUS:
452 $archiveFileList = $this->exportQuadratus($TData, $exportFile, $archiveFileList, $withAttachment);
453 break;
454 case self::$EXPORT_TYPE_WINFIC:
455 $this->exportWinfic($TData, $exportFile);
456 break;
457 case self::$EXPORT_TYPE_EBP:
458 $this->exportEbp($TData, $exportFile);
459 break;
460 case self::$EXPORT_TYPE_COGILOG:
461 $this->exportCogilog($TData, $exportFile);
462 break;
463 case self::$EXPORT_TYPE_AGIRIS:
464 $this->exportAgiris($TData, $exportFile);
465 break;
466 case self::$EXPORT_TYPE_OPENCONCERTO:
467 $this->exportOpenConcerto($TData, $exportFile);
468 break;
469 case self::$EXPORT_TYPE_SAGE50_SWISS:
470 $this->exportSAGE50SWISS($TData, $exportFile);
471 break;
472 case self::$EXPORT_TYPE_CHARLEMAGNE:
473 $this->exportCharlemagne($TData, $exportFile);
474 break;
475 case self::$EXPORT_TYPE_LDCOMPTA:
476 $this->exportLDCompta($TData, $exportFile);
477 break;
478 case self::$EXPORT_TYPE_LDCOMPTA10:
479 $this->exportLDCompta10($TData, $exportFile);
480 break;
481 case self::$EXPORT_TYPE_GESTIMUMV3:
482 $this->exportGestimumV3($TData, $exportFile);
483 break;
484 case self::$EXPORT_TYPE_GESTIMUMV5:
485 $this->exportGestimumV5($TData, $exportFile);
486 break;
487 case self::$EXPORT_TYPE_FEC:
488 $archiveFileList = $this->exportFEC($TData, $exportFile, $archiveFileList, $withAttachment);
489 break;
490 case self::$EXPORT_TYPE_FEC2:
491 $archiveFileList = $this->exportFEC2($TData, $exportFile, $archiveFileList, $withAttachment);
492 break;
493 case self::$EXPORT_TYPE_ISUITEEXPERT:
494 $this->exportiSuiteExpert($TData, $exportFile);
495 break;
496 default:
497 global $hookmanager;
498 $parameters = array('format' => $formatexportset);
499 // file contents will be created in the hooked function via print
500 $reshook = $hookmanager->executeHooks('export', $parameters, $TData);
501 if ($reshook != 1) {
502 $this->errors[] = $langs->trans('accountancy_error_modelnotfound');
503 }
504 break;
505 }
506
507 // create and download export file or archive
508 if ($outputMode == 1 || $outputMode == 2) {
509 $error = 0;
510
511 // close export file
512 if ($exportFile) {
513 fclose($exportFile);
514 }
515
516 if ($withAttachment == 1) {
517 // create archive file
518 if (!empty($archiveFullName) && !empty($archivePath) && !empty($archiveFileList)) {
519 // archive files
520 $downloadFileMimeType = 'application/zip';
521 $downloadFileFullName = $archiveFullName;
522 $downloadFilePath = $archivePath;
523
524 // create archive
525 $archive = new ZipArchive();
526 $res = $archive->open($archivePath, ZipArchive::OVERWRITE | ZipArchive::CREATE);
527 if ($res !== true) {
528 $error++;
529 $this->errors[] = $langs->trans('ErrorFileNotFound', $archivePath);
530 }
531 if (!$error) {
532 // add files
533 foreach ($archiveFileList as $archiveFileArr) {
534 $res = $archive->addFile($archiveFileArr['path'], $archiveFileArr['name']);
535 if (!$res) {
536 $error++;
537 $this->errors[] = $langs->trans('ErrorArchiveAddFile', $archiveFileArr['name']);
538 break;
539 }
540 }
541 }
542 if (!$error) {
543 // close archive
544 $archive->close();
545 }
546 }
547 }
548
549 if (!$error) {
550 // download after writing files
551 if ($downloadMode == 1) {
552 if ($withAttachment == 0) {
553 // only download exported file
554 if (!empty($exportFileFullName) && !empty($exportFilePath)) {
555 $downloadFileMimeType = $mimetype;
556 $downloadFileFullName = $exportFileFullName;
557 $downloadFilePath = $exportFilePath;
558 }
559 }
560
561 // download export file or archive
562 if (!empty($downloadFileMimeType) && !empty($downloadFileFullName) && !empty($downloadFilePath)) {
563 header('Content-Type: ' . $downloadFileMimeType);
564 header('Content-Disposition: attachment; filename=' . $downloadFileFullName);
565 header('Cache-Control: Public, must-revalidate');
566 header('Pragma: public');
567 header('Content-Length: ' . dol_filesize($downloadFilePath));
568 readfileLowMemory($downloadFilePath);
569 }
570 }
571 }
572
573 if ($error) {
574 return -1;
575 }
576 }
577
578 return 1;
579 }
580
581
589 public function exportCegid($objectLines, $exportFile = null)
590 {
591 $separator = ";";
592 $end_line = "\n";
593
594 foreach ($objectLines as $line) {
595 $date_document = dol_print_date($line->doc_date, '%d%m%Y');
596
597 $tab = array();
598
599 $tab[] = $date_document;
600 $tab[] = $line->code_journal;
601 $tab[] = length_accountg($line->numero_compte);
602 $tab[] = length_accounta($line->subledger_account);
603 $tab[] = $line->sens;
604 $tab[] = price2fec(abs($line->debit - $line->credit));
605 $tab[] = dol_string_unaccent($line->label_operation);
606 $tab[] = dol_string_unaccent($line->doc_ref);
607
608 $output = implode($separator, $tab).$end_line;
609 if ($exportFile) {
610 fwrite($exportFile, $output);
611 } else {
612 print $output;
613 }
614 }
615 }
616
625 public function exportCogilog($objectLines, $exportFile = null)
626 {
627 $separator = "\t";
628 $end_line = "\n";
629
630 foreach ($objectLines as $line) {
631 $date_document = dol_print_date($line->doc_date, '%d%m%Y');
632
633 $refInvoice = '';
634 if ($line->doc_type == 'customer_invoice') {
635 // Customer invoice
636 require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
637 $invoice = new Facture($this->db);
638 $invoice->fetch($line->fk_doc);
639
640 $refInvoice = $invoice->ref;
641 } elseif ($line->doc_type == 'supplier_invoice') {
642 // Supplier invoice
643 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
644 $invoice = new FactureFournisseur($this->db);
645 $invoice->fetch($line->fk_doc);
646
647 $refInvoice = $invoice->ref_supplier;
648 }
649
650 $tab = array();
651
652 $tab[] = $line->code_journal;
653 $tab[] = $date_document;
654 $tab[] = $refInvoice;
655 if (empty($line->subledger_account)) {
656 $tab[] = length_accountg($line->numero_compte);
657 } else {
658 $tab[] = length_accounta($line->subledger_account);
659 }
660 $tab[] = "";
661 $tab[] = $line->label_operation;
662 $tab[] = $date_document;
663 if ($line->sens == 'D') {
664 $tab[] = price($line->debit);
665 $tab[] = "";
666 } elseif ($line->sens == 'C') {
667 $tab[] = "";
668 $tab[] = price($line->credit);
669 }
670 $tab[] = $line->doc_ref;
671 $tab[] = $line->label_operation;
672
673 $output = implode($separator, $tab).$end_line;
674 if ($exportFile) {
675 fwrite($exportFile, $output);
676 } else {
677 print $output;
678 }
679 }
680 }
681
689 public function exportCoala($objectLines, $exportFile = null)
690 {
691 // Coala export
692 $separator = ";";
693 $end_line = "\n";
694
695 foreach ($objectLines as $line) {
696 $date_document = dol_print_date($line->doc_date, '%d/%m/%Y');
697
698 $tab = array();
699
700 $tab[] = $date_document;
701 $tab[] = $line->code_journal;
702 $tab[] = length_accountg($line->numero_compte);
703 $tab[] = $line->piece_num;
704 $tab[] = $line->doc_ref;
705 $tab[] = price($line->debit);
706 $tab[] = price($line->credit);
707 $tab[] = 'E';
708 $tab[] = length_accounta($line->subledger_account);
709
710 $output = implode($separator, $tab).$end_line;
711 if ($exportFile) {
712 fwrite($exportFile, $output);
713 } else {
714 print $output;
715 }
716 }
717 }
718
726 public function exportBob50($objectLines, $exportFile = null)
727 {
728 // Bob50
729 $separator = ";";
730 $end_line = "\n";
731
732 foreach ($objectLines as $line) {
733 $date_document = dol_print_date($line->doc_date, '%d/%m/%Y');
734
735 $tab = array();
736
737 $tab[] = $line->piece_num;
738 $tab[] = $date_document;
739
740 if (empty($line->subledger_account)) {
741 $tab[] = 'G';
742 $tab[] = length_accountg($line->numero_compte);
743 } else {
744 if (substr($line->numero_compte, 0, 3) == '411') {
745 $tab[] = 'C';
746 }
747 if (substr($line->numero_compte, 0, 3) == '401') {
748 $tab[] = 'F';
749 }
750 $tab[] = length_accounta($line->subledger_account);
751 }
752
753 $tab[] = price($line->debit);
754 $tab[] = price($line->credit);
755 $tab[] = dol_trunc($line->label_operation, 32);
756
757 $output = implode($separator, $tab).$end_line;
758 if ($exportFile) {
759 fwrite($exportFile, $output);
760 } else {
761 print $output;
762 }
763 }
764 }
765
781 public function exportCiel($objectLines, $exportFile = null)
782 {
783 $end_line = "\r\n";
784
785 $i = 1;
786
787 foreach ($objectLines as $line) {
788 $code_compta = length_accountg($line->numero_compte);
789 if (!empty($line->subledger_account)) {
790 $code_compta = length_accounta($line->subledger_account);
791 }
792
793 $date_document = dol_print_date($line->doc_date, '%Y%m%d');
794 $date_echeance = dol_print_date($line->date_lim_reglement, '%Y%m%d');
795
796 $tab = array();
797
798 $tab[] = str_pad($line->piece_num, 5);
799 $tab[] = str_pad(self::trunc($line->code_journal, 2), 2);
800 $tab[] = str_pad($date_document, 8, ' ', STR_PAD_LEFT);
801 $tab[] = str_pad($date_echeance, 8, ' ', STR_PAD_LEFT);
802 $tab[] = str_pad(self::trunc($line->doc_ref, 12), 12);
803 $tab[] = str_pad(self::trunc($code_compta, 11), 11);
804 $tab[] = str_pad(self::trunc(dol_string_unaccent($line->doc_ref).dol_string_unaccent($line->label_operation), 25), 25);
805 $tab[] = str_pad(price2fec(abs($line->debit - $line->credit)), 13, ' ', STR_PAD_LEFT);
806 $tab[] = str_pad($line->sens, 1);
807 $tab[] = str_repeat(' ', 18); // Analytical accounting - Not managed in Dolibarr
808 $tab[] = str_pad(self::trunc(dol_string_unaccent($line->label_operation), 34), 34);
809 $tab[] = 'O2003'; // 0 = EUR | 2003 = Format Ciel
810
811 $output = implode($tab).$end_line;
812 if ($exportFile) {
813 fwrite($exportFile, $output);
814 } else {
815 print $output;
816 }
817 $i++;
818 }
819 }
820
836 public function exportQuadratus($objectLines, $exportFile = null, $archiveFileList = array(), $withAttachment = 0)
837 {
838 global $conf, $db;
839
840 $end_line = "\r\n";
841
842 // We should use dol_now function not time however this is wrong date to transfert in accounting
843 foreach ($objectLines as $line) {
844 // Clean some data
845 $line->doc_ref = dol_string_unaccent($line->doc_ref);
846
847 $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
848 $line->label_operation = str_replace(array("- ", "…", "..."), "", $line->label_operation);
849 $line->label_operation = dol_string_unaccent($line->label_operation);
850
851 $line->numero_compte = dol_string_unaccent($line->numero_compte);
852 $line->label_compte = dol_string_unaccent($line->label_compte);
853 $line->subledger_account = dol_string_unaccent($line->subledger_account);
854
855 $line->subledger_label = str_replace(array("- ", "…", "..."), "", $line->subledger_label);
856 $line->subledger_label = dol_string_unaccent($line->subledger_label);
857
858 $code_compta = $line->numero_compte;
859 if (!empty($line->subledger_account)) {
860 $code_compta = $line->subledger_account;
861 }
862
863 $tab = array();
864
865 if (!empty($line->subledger_account)) {
866 $tab['type_ligne'] = 'C';
867 $tab['num_compte'] = str_pad(self::trunc($line->subledger_account, 8), 8);
868 $tab['lib_compte'] = str_pad(self::trunc($line->subledger_label, 30), 30);
869
870 if ($line->doc_type == 'customer_invoice') {
871 $tab['lib_alpha'] = strtoupper(str_pad('C'.self::trunc(dol_string_unaccent($line->subledger_label), 6), 7));
872 $tab['filler'] = str_repeat(' ', 52);
873 $tab['coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, 8), 8);
874 } elseif ($line->doc_type == 'supplier_invoice') {
875 $tab['lib_alpha'] = strtoupper(str_pad('F'.self::trunc(dol_string_unaccent($line->subledger_label), 6), 7));
876 $tab['filler'] = str_repeat(' ', 52);
877 $tab['coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, 8), 8);
878 } else {
879 $tab['filler'] = str_repeat(' ', 59);
880 $tab['coll_compte'] = str_pad(' ', 8);
881 }
882
883 $tab['filler2'] = str_repeat(' ', 110);
884 $tab['Maj'] = 2; // Partial update (alpha key, label, address, collectif, RIB)
885
886 if ($line->doc_type == 'customer_invoice') {
887 $tab['type_compte'] = 'C';
888 } elseif ($line->doc_type == 'supplier_invoice') {
889 $tab['type_compte'] = 'F';
890 } else {
891 $tab['type_compte'] = 'G';
892 }
893
894 $tab['filler3'] = str_repeat(' ', 235);
895
896 $tab['end_line'] = $end_line;
897
898 if ($exportFile) {
899 fwrite($exportFile, implode($tab));
900 } else {
901 print implode($tab);
902 }
903 }
904
905 $tab = array();
906 $tab['type_ligne'] = 'M';
907 $tab['num_compte'] = str_pad(self::trunc($code_compta, 8), 8);
908 $tab['code_journal'] = str_pad(self::trunc($line->code_journal, 2), 2);
909 $tab['folio'] = '000';
910
911 // We use invoice date $line->doc_date not $date_ecriture which is the transfert date
912 // maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ?
913 //$tab['date_ecriture'] = $date_ecriture;
914 $tab['date_ecriture'] = dol_print_date($line->doc_date, '%d%m%y');
915 $tab['filler'] = ' ';
916 $tab['libelle_ecriture'] = str_pad(self::trunc($line->doc_ref.' '.$line->label_operation, 20), 20);
917
918 // Credit invoice - invert sens
919 /*
920 if ($line->montant < 0) {
921 if ($line->sens == 'C') {
922 $tab['sens'] = 'D';
923 } else {
924 $tab['sens'] = 'C';
925 }
926 $tab['signe_montant'] = '-';
927 } else {
928 $tab['sens'] = $line->sens; // C or D
929 $tab['signe_montant'] = '+';
930 }*/
931 $tab['sens'] = $line->sens; // C or D
932 $tab['signe_montant'] = '+';
933
934 // The amount must be in centimes without decimal points.
935 $tab['montant'] = str_pad(abs(($line->debit - $line->credit) * 100), 12, '0', STR_PAD_LEFT);
936 $tab['contrepartie'] = str_repeat(' ', 8);
937
938 // Force date format : %d%m%y
939 if (!empty($line->date_lim_reglement)) {
940 $tab['date_echeance'] = dol_print_date($line->date_lim_reglement, '%d%m%y'); // Format must be ddmmyy
941 } else {
942 $tab['date_echeance'] = '000000';
943 }
944
945 // Please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5)
946 // $tab['lettrage'] = str_repeat(' ', 5);
947 $tab['lettrage'] = str_repeat(' ', 2);
948 $tab['codestat'] = str_repeat(' ', 3);
949 $tab['num_piece'] = str_pad(self::trunc($line->piece_num, 5), 5);
950
951 // Keep correct quadra named field instead of anon filler
952 // $tab['filler2'] = str_repeat(' ', 20);
953 $tab['affaire'] = str_repeat(' ', 10);
954 $tab['quantity1'] = str_repeat(' ', 10);
955 $tab['num_piece2'] = str_pad(self::trunc($line->piece_num, 8), 8);
956 $tab['devis'] = str_pad($conf->currency, 3);
957 $tab['code_journal2'] = str_pad(self::trunc($line->code_journal, 3), 3);
958 $tab['filler3'] = str_repeat(' ', 3);
959
960 // Keep correct quadra named field instead of anon filler libelle_ecriture2 is 30 char not 32 !!!!
961 // as we use utf8, we must remove accent to have only one ascii char instead of utf8 2 chars for specials that report wrong line size that will exceed import format spec
962 // TODO: we should filter more than only accent to avoid wrong line size
963 // TODO: remove invoice number doc_ref in label,
964 // TODO: we should offer an option for customer to build the label using invoice number / name / date in accounting software
965 //$tab['libelle_ecriture2'] = str_pad(self::trunc($line->doc_ref . ' ' . $line->label_operation, 30), 30);
966 $tab['libelle_ecriture2'] = str_pad(self::trunc($line->label_operation, 30), 30);
967 $tab['codetva'] = str_repeat(' ', 2);
968
969 // We need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part
970 // $tab['num_piece3'] = str_pad(self::trunc($line->piece_num, 10), 10);
971 $tab['num_piece3'] = substr(self::trunc($line->doc_ref, 20), -10);
972 $tab['reserved'] = str_repeat(' ', 10); // position 159
973 $tab['currency_amount'] = str_repeat(' ', 13); // position 169
974 // get document file
975 $attachmentFileName = '';
976 if ($withAttachment == 1) {
977 $attachmentFileKey = trim($line->piece_num);
978
979 if (!isset($archiveFileList[$attachmentFileKey])) {
980 $objectDirPath = '';
981 $objectFileName = dol_sanitizeFileName($line->doc_ref);
982 if ($line->doc_type == 'customer_invoice') {
983 $objectDirPath = !empty($conf->invoice->multidir_output[$conf->entity]) ? $conf->invoice->multidir_output[$conf->entity] : $conf->invoice->dir_output;
984 } elseif ($line->doc_type == 'expense_report') {
985 $objectDirPath = !empty($conf->expensereport->multidir_output[$conf->entity]) ? $conf->expensereport->multidir_output[$conf->entity] : $conf->expensereport->dir_output;
986 } elseif ($line->doc_type == 'supplier_invoice') {
987 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
988 $invoice = new FactureFournisseur($this->db);
989 $invoice->fetch($line->fk_doc);
990 $objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output;
991 $objectDirPath.= '/'.rtrim(get_exdir($invoice->id, 2, 0, 0, $invoice, 'invoice_supplier'), '/');
992 }
993 $arrayofinclusion = array();
994 // If it is a supplier invoice, we want to use last uploaded file
995 $arrayofinclusion[] = '^'.preg_quote($objectFileName, '/').(($line->doc_type == 'supplier_invoice') ? '.+' : '').'\.pdf$';
996 $fileFoundList = dol_dir_list($objectDirPath.'/'.$objectFileName, 'files', 0, implode('|', $arrayofinclusion), '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, true);
997 if (!empty($fileFoundList)) {
998 $attachmentFileNameTrunc = str_pad(self::trunc($line->piece_num, 8), 8, '0', STR_PAD_LEFT);
999 foreach ($fileFoundList as $fileFound) {
1000 if (strstr($fileFound['name'], $objectFileName)) {
1001 // skip native invoice pdfs (canelle)
1002 // We want to retrieve an attachment representative of the supplier invoice, not a fake document generated by Dolibarr.
1003 if ($line->doc_type == 'supplier_invoice') {
1004 if ($fileFound['name'] === $objectFileName.'.pdf') {
1005 continue;
1006 }
1007 } elseif ($fileFound['name'] !== $objectFileName.'.pdf') {
1008 continue;
1009 }
1010 $fileFoundPath = $objectDirPath.'/'.$objectFileName.'/'.$fileFound['name'];
1011 if (file_exists($fileFoundPath)) {
1012 $archiveFileList[$attachmentFileKey] = array(
1013 'path' => $fileFoundPath,
1014 'name' => $attachmentFileNameTrunc.'.pdf',
1015 );
1016 break;
1017 }
1018 }
1019 }
1020 }
1021 }
1022
1023 if (isset($archiveFileList[$attachmentFileKey])) {
1024 $attachmentFileName = $archiveFileList[$attachmentFileKey]['name'];
1025 }
1026 }
1027 if (dol_strlen($attachmentFileName) == 12) {
1028 $tab['attachment'] = $attachmentFileName; // position 182
1029 } else {
1030 $tab['attachment'] = str_repeat(' ', 12); // position 182
1031 }
1032 $tab['filler4'] = str_repeat(' ', 38);
1033 $tab['end_line'] = $end_line;
1034
1035 if ($exportFile) {
1036 fwrite($exportFile, implode($tab));
1037 } else {
1038 print implode($tab);
1039 }
1040 }
1041
1042 return $archiveFileList;
1043 }
1044
1055 public function exportWinfic($objectLines, $exportFile = null)
1056 {
1057 global $conf;
1058
1059 $end_line = "\r\n";
1060 $index = 1;
1061
1062 // Warning ! When truncation is necessary, no dot because 3 dots = three characters. The columns are shifted
1063
1064 foreach ($objectLines as $line) {
1065 $code_compta = $line->numero_compte;
1066 if (!empty($line->subledger_account)) {
1067 $code_compta = $line->subledger_account;
1068 }
1069
1070 $tab = array();
1071 //$tab['type_ligne'] = 'M';
1072 $tab['code_journal'] = str_pad(dol_trunc($line->code_journal, 2, 'right', 'UTF-8', 1), 2);
1073
1074 //We use invoice date $line->doc_date not $date_ecriture which is the transfert date
1075 //maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ?
1076 //$tab['date_ecriture'] = $date_ecriture;
1077 $tab['date_operation'] = dol_print_date($line->doc_date, '%d%m%Y');
1078
1079 $tab['folio'] = ' 1';
1080
1081 $tab['num_ecriture'] = str_pad(dol_trunc($index, 6, 'right', 'UTF-8', 1), 6, ' ', STR_PAD_LEFT);
1082
1083 $tab['jour_ecriture'] = dol_print_date($line->doc_date, '%d%m%y');
1084
1085 $tab['num_compte'] = str_pad(dol_trunc($code_compta, 6, 'right', 'UTF-8', 1), 6, '0');
1086
1087 if ($line->sens == 'D') {
1088 $tab['montant_debit'] = str_pad(number_format($line->debit, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
1089
1090 $tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
1091 } else {
1092 $tab['montant_debit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
1093
1094 $tab['montant_crebit'] = str_pad(number_format($line->credit, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
1095 }
1096
1097 $tab['libelle_ecriture'] = str_pad(dol_trunc(dol_string_unaccent($line->doc_ref).' '.dol_string_unaccent($line->label_operation), 30, 'right', 'UTF-8', 1), 30);
1098
1099 $tab['lettrage'] = str_repeat(dol_trunc($line->lettering_code, 2, 'left', 'UTF-8', 1), 2);
1100
1101 $tab['code_piece'] = str_pad(dol_trunc($line->piece_num, 5, 'left', 'UTF-8', 1), 5, ' ', STR_PAD_LEFT);
1102
1103 $tab['code_stat'] = str_repeat(' ', 4);
1104
1105 if (!empty($line->date_lim_reglement)) {
1106 $tab['date_echeance'] = dol_print_date($line->date_lim_reglement, '%d%m%Y');
1107 } else {
1108 $tab['date_echeance'] = dol_print_date($line->doc_date, '%d%m%Y');
1109 }
1110
1111 $tab['monnaie'] = '1';
1112
1113 $tab['filler'] = ' ';
1114
1115 $tab['ind_compteur'] = ' ';
1116
1117 $tab['quantite'] = '0,000000000';
1118
1119 $tab['code_pointage'] = str_repeat(' ', 2);
1120
1121 $tab['end_line'] = $end_line;
1122
1123 print implode('|', $tab);
1124
1125 $index++;
1126 }
1127 }
1128
1129
1137 public function exportEbp($objectLines, $exportFile = null)
1138 {
1139 $separator = ',';
1140 $end_line = "\n";
1141
1142 foreach ($objectLines as $line) {
1143 $date_document = dol_print_date($line->doc_date, '%d%m%Y');
1144
1145 $tab = array();
1146
1147 $tab[] = $line->id;
1148 $tab[] = $date_document;
1149 $tab[] = $line->code_journal;
1150 if (empty($line->subledger_account)) {
1151 $tab[] = $line->numero_compte;
1152 } else {
1153 $tab[] = $line->subledger_account;
1154 }
1155 //$tab[] = substr(length_accountg($line->numero_compte), 0, 2) . $separator;
1156 $tab[] = '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"';
1157 $tab[] = '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"';
1158 $tab[] = price2num(abs($line->debit - $line->credit));
1159 $tab[] = $line->sens;
1160 $tab[] = $date_document;
1161 //print 'EUR';
1162
1163 $output = implode($separator, $tab).$end_line;
1164 if ($exportFile) {
1165 fwrite($exportFile, $output);
1166 } else {
1167 print $output;
1168 }
1169 }
1170 }
1171
1172
1180 public function exportAgiris($objectLines, $exportFile = null)
1181 {
1182 $separator = ';';
1183 $end_line = "\n";
1184
1185 foreach ($objectLines as $line) {
1186 $date_document = dol_print_date($line->doc_date, '%d%m%Y');
1187
1188 $tab = array();
1189
1190 $tab[] = $line->piece_num;
1191 $tab[] = self::toAnsi($line->label_operation);
1192 $tab[] = $date_document;
1193 $tab[] = self::toAnsi($line->label_operation);
1194
1195 if (empty($line->subledger_account)) {
1196 $tab[] = length_accountg($line->numero_compte);
1197 $tab[] = self::toAnsi($line->label_compte);
1198 } else {
1199 $tab[] = length_accounta($line->subledger_account);
1200 $tab[] = self::toAnsi($line->subledger_label);
1201 }
1202
1203 $tab[] = self::toAnsi($line->doc_ref);
1204 $tab[] = price($line->debit);
1205 $tab[] = price($line->credit);
1206 $tab[] = price(abs($line->debit - $line->credit));
1207 $tab[] = $line->sens;
1208 $tab[] = $line->lettering_code;
1209 $tab[] = $line->code_journal;
1210
1211 $output = implode($separator, $tab).$end_line;
1212 if ($exportFile) {
1213 fwrite($exportFile, $output);
1214 } else {
1215 print $output;
1216 }
1217 }
1218 }
1219
1227 public function exportOpenConcerto($objectLines, $exportFile = null)
1228 {
1229 $separator = ';';
1230 $end_line = "\n";
1231
1232 foreach ($objectLines as $line) {
1233 $date_document = dol_print_date($line->doc_date, '%d/%m/%Y');
1234
1235 $tab = array();
1236
1237 $tab[] = $date_document;
1238 $tab[] = $line->code_journal;
1239 if (empty($line->subledger_account)) {
1240 $tab[] = length_accountg($line->numero_compte);
1241 } else {
1242 $tab[] = length_accounta($line->subledger_account);
1243 }
1244 $tab[] = $line->doc_ref;
1245 $tab[] = $line->label_operation;
1246 $tab[] = price($line->debit);
1247 $tab[] = price($line->credit);
1248
1249 $output = implode($separator, $tab).$end_line;
1250 if ($exportFile) {
1251 fwrite($exportFile, $output);
1252 } else {
1253 print $output;
1254 }
1255 }
1256 }
1257
1265 public function exportConfigurable($objectLines, $exportFile = null)
1266 {
1267 global $conf;
1268
1269 $separator = $this->separator;
1270
1271 foreach ($objectLines as $line) {
1272 $date_document = dol_print_date($line->doc_date, getDolGlobalString('ACCOUNTING_EXPORT_DATE'));
1273
1274 $tab = array();
1275 // export configurable
1276 $tab[] = $line->piece_num;
1277 $tab[] = $date_document;
1278 $tab[] = $line->doc_ref;
1279 $tab[] = preg_match('/'.$separator.'/', $line->label_operation) ? "'".$line->label_operation."'" : $line->label_operation;
1280 $tab[] = length_accountg($line->numero_compte);
1281 $tab[] = length_accounta($line->subledger_account);
1282 $tab[] = price2num($line->debit);
1283 $tab[] = price2num($line->credit);
1284 $tab[] = price2num($line->debit - $line->credit);
1285 $tab[] = $line->code_journal;
1286
1287 $output = implode($separator, $tab).$this->end_line;
1288 if ($exportFile) {
1289 fwrite($exportFile, $output);
1290 } else {
1291 print $output;
1292 }
1293 }
1294 }
1295
1308 public function exportFEC($objectLines, $exportFile = null, $archiveFileList = array(), $withAttachment = 0)
1309 {
1310 global $conf, $langs;
1311
1312 $separator = "\t";
1313 $end_line = "\r\n";
1314
1315 $tab = array();
1316 $tab[] = "JournalCode";
1317 $tab[] = "JournalLib";
1318 $tab[] = "EcritureNum";
1319 $tab[] = "EcritureDate";
1320 $tab[] = "CompteNum";
1321 $tab[] = "CompteLib";
1322 $tab[] = "CompAuxNum";
1323 $tab[] = "CompAuxLib";
1324 $tab[] = "PieceRef";
1325 $tab[] = "PieceDate";
1326 $tab[] = "EcritureLib";
1327 $tab[] = "Debit";
1328 $tab[] = "Credit";
1329 $tab[] = "EcritureLet";
1330 $tab[] = "DateLet";
1331 $tab[] = "ValidDate";
1332 $tab[] = "Montantdevise";
1333 $tab[] = "Idevise";
1334 $tab[] = "DateLimitReglmt";
1335 $tab[] = "NumFacture";
1336 $tab[] = "FichierFacture";
1337
1338 $output = implode($separator, $tab).$end_line;
1339 if ($exportFile) {
1340 fwrite($exportFile, $output);
1341 } else {
1342 print $output;
1343 }
1344
1345 foreach ($objectLines as $line) {
1346 if ($line->debit == 0 && $line->credit == 0) {
1347 //unset($array[$line]);
1348 } else {
1349 $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
1350 $date_document = dol_print_date($line->doc_date, '%Y%m%d');
1351 $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
1352 $date_validation = dol_print_date($line->date_validation, '%Y%m%d');
1353 $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
1354
1355 $refInvoice = '';
1356 if ($line->doc_type == 'customer_invoice') {
1357 // Customer invoice
1358 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1359 $invoice = new Facture($this->db);
1360 $invoice->fetch($line->fk_doc);
1361
1362 $refInvoice = $invoice->ref;
1363 } elseif ($line->doc_type == 'supplier_invoice') {
1364 // Supplier invoice
1365 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1366 $invoice = new FactureFournisseur($this->db);
1367 $invoice->fetch($line->fk_doc);
1368
1369 $refInvoice = $invoice->ref_supplier;
1370 }
1371
1372 $tab = array();
1373
1374 // FEC:JournalCode
1375 $tab[] = $line->code_journal;
1376
1377 // FEC:JournalLib
1378 $labeljournal = dol_string_unaccent($langs->transnoentities($line->journal_label));
1379 $labeljournal = dol_string_nospecial($labeljournal, ' ');
1380 $tab[] = $labeljournal;
1381
1382 // FEC:EcritureNum
1383 $tab[] = $line->piece_num;
1384
1385 // FEC:EcritureDate
1386 $tab[] = $date_document;
1387
1388 // FEC:CompteNum
1389 $tab[] = length_accountg($line->numero_compte);
1390
1391 // FEC:CompteLib
1392 $tab[] = dol_string_unaccent($line->label_compte);
1393
1394 // FEC:CompAuxNum
1395 $tab[] = length_accounta($line->subledger_account);
1396
1397 // FEC:CompAuxLib
1398 $tab[] = dol_string_unaccent($line->subledger_label);
1399
1400 // FEC:PieceRef
1401 $tab[] = $line->doc_ref;
1402
1403 // FEC:PieceDate
1404 $tab[] = dol_string_unaccent($date_creation);
1405
1406 // FEC:EcritureLib
1407 // Clean label operation to prevent problem on export with tab separator & other character
1408 $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
1409 $line->label_operation = str_replace(array("..."), "", $line->label_operation);
1410 $tab[] = dol_string_unaccent($line->label_operation);
1411
1412 // FEC:Debit
1413 $tab[] = price2fec($line->debit);
1414
1415 // FEC:Credit
1416 $tab[] = price2fec($line->credit);
1417
1418 // FEC:EcritureLet
1419 $tab[] = $line->lettering_code;
1420
1421 // FEC:DateLet
1422 $tab[] = $date_lettering;
1423
1424 // FEC:ValidDate
1425 $tab[] = $date_validation;
1426
1427 // FEC:Montantdevise
1428 $tab[] = $line->multicurrency_amount;
1429
1430 // FEC:Idevise
1431 $tab[] = $line->multicurrency_code;
1432
1433 // FEC_suppl:DateLimitReglmt
1434 $tab[] = $date_limit_payment;
1435
1436 // FEC_suppl:NumFacture
1437 // Clean ref invoice to prevent problem on export with tab separator & other character
1438 $refInvoice = str_replace(array("\t", "\n", "\r"), " ", $refInvoice);
1439 $tab[] = dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1);
1440
1441 // FEC_suppl:FichierFacture
1442 // get document file
1443 $attachmentFileName = '';
1444 if ($withAttachment == 1) {
1445 $attachmentFileKey = trim($line->piece_num);
1446
1447 if (!isset($archiveFileList[$attachmentFileKey])) {
1448 $objectDirPath = '';
1449 $objectFileName = dol_sanitizeFileName($line->doc_ref);
1450 if ($line->doc_type == 'customer_invoice') {
1451 $objectDirPath = !empty($conf->invoice->multidir_output[$conf->entity]) ? $conf->invoice->multidir_output[$conf->entity] : $conf->invoice->dir_output;
1452 } elseif ($line->doc_type == 'expense_report') {
1453 $objectDirPath = !empty($conf->expensereport->multidir_output[$conf->entity]) ? $conf->expensereport->multidir_output[$conf->entity] : $conf->expensereport->dir_output;
1454 } elseif ($line->doc_type == 'supplier_invoice') {
1455 $objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output;
1456 $objectDirPath.= '/'.rtrim(get_exdir($invoice->id, 2, 0, 0, $invoice, 'invoice_supplier'), '/');
1457 }
1458 $arrayofinclusion = array();
1459 // If it is a supplier invoice, we want to use last uploaded file
1460 $arrayofinclusion[] = '^'.preg_quote($objectFileName, '/').(($line->doc_type == 'supplier_invoice') ? '.+' : '').'\.pdf$';
1461 $fileFoundList = dol_dir_list($objectDirPath.'/'.$objectFileName, 'files', 0, implode('|', $arrayofinclusion), '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, true);
1462 if (!empty($fileFoundList)) {
1463 $attachmentFileNameTrunc = $line->doc_ref;
1464 foreach ($fileFoundList as $fileFound) {
1465 if (strstr($fileFound['name'], $objectFileName)) {
1466 // skip native invoice pdfs (canelle)
1467 // We want to retrieve an attachment representative of the supplier invoice, not a fake document generated by Dolibarr.
1468 if ($line->doc_type == 'supplier_invoice') {
1469 if ($fileFound['name'] === $objectFileName.'.pdf') {
1470 continue;
1471 }
1472 } elseif ($fileFound['name'] !== $objectFileName.'.pdf') {
1473 continue;
1474 }
1475 $fileFoundPath = $objectDirPath.'/'.$objectFileName.'/'.$fileFound['name'];
1476 if (file_exists($fileFoundPath)) {
1477 $archiveFileList[$attachmentFileKey] = array(
1478 'path' => $fileFoundPath,
1479 'name' => $attachmentFileNameTrunc.'.pdf',
1480 );
1481 break;
1482 }
1483 }
1484 }
1485 }
1486 }
1487
1488 if (isset($archiveFileList[$attachmentFileKey])) {
1489 $attachmentFileName = $archiveFileList[$attachmentFileKey]['name'];
1490 }
1491 }
1492
1493 $tab[] = $attachmentFileName;
1494
1495 $output = implode($separator, $tab).$end_line;
1496 if ($exportFile) {
1497 fwrite($exportFile, $output);
1498 } else {
1499 print $output;
1500 }
1501 }
1502 }
1503
1504 return $archiveFileList;
1505 }
1506
1519 public function exportFEC2($objectLines, $exportFile = null, $archiveFileList = array(), $withAttachment = 0)
1520 {
1521 global $conf, $langs;
1522
1523 $separator = "\t";
1524 $end_line = "\r\n";
1525
1526 $tab = array();
1527 $tab[] = "JournalCode";
1528 $tab[] = "JournalLib";
1529 $tab[] = "EcritureNum";
1530 $tab[] = "EcritureDate";
1531 $tab[] = "CompteNum";
1532 $tab[] = "CompteLib";
1533 $tab[] = "CompAuxNum";
1534 $tab[] = "CompAuxLib";
1535 $tab[] = "PieceRef";
1536 $tab[] = "PieceDate";
1537 $tab[] = "EcritureLib";
1538 $tab[] = "Debit";
1539 $tab[] = "Credit";
1540 $tab[] = "EcritureLet";
1541 $tab[] = "DateLet";
1542 $tab[] = "ValidDate";
1543 $tab[] = "Montantdevise";
1544 $tab[] = "Idevise";
1545 $tab[] = "DateLimitReglmt";
1546 $tab[] = "NumFacture";
1547 $tab[] = "FichierFacture";
1548
1549 $output = implode($separator, $tab).$end_line;
1550 if ($exportFile) {
1551 fwrite($exportFile, $output);
1552 } else {
1553 print $output;
1554 }
1555
1556 foreach ($objectLines as $line) {
1557 if ($line->debit == 0 && $line->credit == 0) {
1558 //unset($array[$line]);
1559 } else {
1560 $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
1561 $date_document = dol_print_date($line->doc_date, '%Y%m%d');
1562 $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
1563 $date_validation = dol_print_date($line->date_validation, '%Y%m%d');
1564 $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
1565
1566 $refInvoice = '';
1567 if ($line->doc_type == 'customer_invoice') {
1568 // Customer invoice
1569 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1570 $invoice = new Facture($this->db);
1571 $invoice->fetch($line->fk_doc);
1572
1573 $refInvoice = $invoice->ref;
1574 } elseif ($line->doc_type == 'supplier_invoice') {
1575 // Supplier invoice
1576 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1577 $invoice = new FactureFournisseur($this->db);
1578 $invoice->fetch($line->fk_doc);
1579
1580 $refInvoice = $invoice->ref_supplier;
1581 }
1582
1583 $tab = array();
1584
1585 // FEC:JournalCode
1586 $tab[] = $line->code_journal;
1587
1588 // FEC:JournalLib
1589 $labeljournal = dol_string_unaccent($langs->transnoentities($line->journal_label));
1590 $labeljournal = dol_string_nospecial($labeljournal, ' ');
1591 $tab[] = $labeljournal;
1592
1593 // FEC:EcritureNum
1594 $tab[] = $line->piece_num;
1595
1596 // FEC:EcritureDate
1597 $tab[] = $date_creation;
1598
1599 // FEC:CompteNum
1600 $tab[] = length_accountg($line->numero_compte);
1601
1602 // FEC:CompteLib
1603 $tab[] = dol_string_unaccent($line->label_compte);
1604
1605 // FEC:CompAuxNum
1606 $tab[] = length_accounta($line->subledger_account);
1607
1608 // FEC:CompAuxLib
1609 $tab[] = dol_string_unaccent($line->subledger_label);
1610
1611 // FEC:PieceRef
1612 $tab[] = $line->doc_ref;
1613
1614 // FEC:PieceDate
1615 $tab[] = $date_document;
1616
1617 // FEC:EcritureLib
1618 // Clean label operation to prevent problem on export with tab separator & other character
1619 $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
1620 $line->label_operation = str_replace(array("..."), "", $line->label_operation);
1621 $tab[] = dol_string_unaccent($line->label_operation);
1622
1623 // FEC:Debit
1624 $tab[] = price2fec($line->debit);
1625
1626 // FEC:Credit
1627 $tab[] = price2fec($line->credit);
1628
1629 // FEC:EcritureLet
1630 $tab[] = $line->lettering_code;
1631
1632 // FEC:DateLet
1633 $tab[] = $date_lettering;
1634
1635 // FEC:ValidDate
1636 $tab[] = $date_validation;
1637
1638 // FEC:Montantdevise
1639 $tab[] = $line->multicurrency_amount;
1640
1641 // FEC:Idevise
1642 $tab[] = $line->multicurrency_code;
1643
1644 // FEC_suppl:DateLimitReglmt
1645 $tab[] = $date_limit_payment;
1646
1647 // FEC_suppl:NumFacture
1648 // Clean ref invoice to prevent problem on export with tab separator & other character
1649 $refInvoice = str_replace(array("\t", "\n", "\r"), " ", $refInvoice);
1650 $tab[] = dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1);
1651
1652 // FEC_suppl:FichierFacture
1653 // get document file
1654 $attachmentFileName = '';
1655 if ($withAttachment == 1) {
1656 $attachmentFileKey = trim($line->piece_num);
1657
1658 if (!isset($archiveFileList[$attachmentFileKey])) {
1659 $objectDirPath = '';
1660 $objectFileName = dol_sanitizeFileName($line->doc_ref);
1661 if ($line->doc_type == 'customer_invoice') {
1662 $objectDirPath = !empty($conf->invoice->multidir_output[$conf->entity]) ? $conf->invoice->multidir_output[$conf->entity] : $conf->invoice->dir_output;
1663 } elseif ($line->doc_type == 'expense_report') {
1664 $objectDirPath = !empty($conf->expensereport->multidir_output[$conf->entity]) ? $conf->expensereport->multidir_output[$conf->entity] : $conf->expensereport->dir_output;
1665 } elseif ($line->doc_type == 'supplier_invoice') {
1666 $objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output;
1667 $objectDirPath.= '/'.rtrim(get_exdir($invoice->id, 2, 0, 0, $invoice, 'invoice_supplier'), '/');
1668 }
1669 $arrayofinclusion = array();
1670 // If it is a supplier invoice, we want to use last uploaded file
1671 $arrayofinclusion[] = '^'.preg_quote($objectFileName, '/').(($line->doc_type == 'supplier_invoice') ? '.+' : '').'\.pdf$';
1672 $fileFoundList = dol_dir_list($objectDirPath.'/'.$objectFileName, 'files', 0, implode('|', $arrayofinclusion), '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, true);
1673 if (!empty($fileFoundList)) {
1674 $attachmentFileNameTrunc = $line->doc_ref;
1675 foreach ($fileFoundList as $fileFound) {
1676 if (strstr($fileFound['name'], $objectFileName)) {
1677 // skip native invoice pdfs (canelle)
1678 // We want to retrieve an attachment representative of the supplier invoice, not a fake document generated by Dolibarr.
1679 if ($line->doc_type == 'supplier_invoice') {
1680 if ($fileFound['name'] === $objectFileName.'.pdf') {
1681 continue;
1682 }
1683 } elseif ($fileFound['name'] !== $objectFileName.'.pdf') {
1684 continue;
1685 }
1686 $fileFoundPath = $objectDirPath.'/'.$objectFileName.'/'.$fileFound['name'];
1687 if (file_exists($fileFoundPath)) {
1688 $archiveFileList[$attachmentFileKey] = array(
1689 'path' => $fileFoundPath,
1690 'name' => $attachmentFileNameTrunc.'.pdf',
1691 );
1692 break;
1693 }
1694 }
1695 }
1696 }
1697 }
1698
1699 if (isset($archiveFileList[$attachmentFileKey])) {
1700 $attachmentFileName = $archiveFileList[$attachmentFileKey]['name'];
1701 }
1702 }
1703
1704 $tab[] = $attachmentFileName;
1705
1706 $output = implode($separator, $tab).$end_line;
1707 if ($exportFile) {
1708 fwrite($exportFile, $output);
1709 } else {
1710 print $output;
1711 }
1712 }
1713 }
1714
1715 return $archiveFileList;
1716 }
1717
1728 public function exportSAGE50SWISS($objectLines, $exportFile = null)
1729 {
1730 // SAGE50SWISS
1731 $separator = ',';
1732 $end_line = "\r\n";
1733
1734 // Print header line
1735 $tab = array();
1736
1737 $tab[] = "Blg";
1738 $tab[] = "Datum";
1739 $tab[] = "Kto";
1740 $tab[] = "S/H";
1741 $tab[] = "Grp";
1742 $tab[] = "GKto";
1743 $tab[] = "SId";
1744 $tab[] = "SIdx";
1745 $tab[] = "KIdx";
1746 $tab[] = "BTyp";
1747 $tab[] = "MTyp";
1748 $tab[] = "Code";
1749 $tab[] = "Netto";
1750 $tab[] = "Steuer";
1751 $tab[] = "FW-Betrag";
1752 $tab[] = "Tx1";
1753 $tab[] = "Tx2";
1754 $tab[] = "PkKey";
1755 $tab[] = "OpId";
1756 $tab[] = "Flag";
1757
1758 $output = implode($separator, $tab).$end_line;
1759 if ($exportFile) {
1760 fwrite($exportFile, $output);
1761 } else {
1762 print $output;
1763 }
1764
1765 $thisPieceNum = "";
1766 $thisPieceAccountNr = "";
1767 $aSize = count($objectLines);
1768 foreach ($objectLines as $aIndex => $line) {
1769 $sammelBuchung = false;
1770 if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) {
1771 $sammelBuchung = true;
1772 } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) {
1773 $sammelBuchung = true;
1774 } elseif ($aIndex + 1 < $aSize
1775 && $objectLines[$aIndex + 1]->piece_num == $line->piece_num
1776 && $aIndex - 1 < $aSize
1777 && $objectLines[$aIndex - 1]->piece_num == $line->piece_num
1778 ) {
1779 $sammelBuchung = true;
1780 }
1781
1782 $tab = array();
1783
1784 //Blg
1785 $tab[] = $line->piece_num;
1786
1787 // Datum
1788 $date_document = dol_print_date($line->doc_date, '%d.%m.%Y');
1789 $tab[] = $date_document;
1790
1791 // Kto
1792 $tab[] = length_accountg($line->numero_compte);
1793 // S/H
1794 if ($line->sens == 'D') {
1795 $tab[] = 'S';
1796 } else {
1797 $tab[] = 'H';
1798 }
1799 // Grp
1800 $tab[] = self::trunc($line->code_journal, 1);
1801 // GKto
1802 if (empty($line->code_tiers)) {
1803 if ($line->piece_num == $thisPieceNum) {
1804 $tab[] = length_accounta($thisPieceAccountNr);
1805 } else {
1806 $tab[] = "div";
1807 }
1808 } else {
1809 $tab[] = length_accounta($line->code_tiers);
1810 }
1811 // SId
1812 $tab[] = $this->separator;
1813 // SIdx
1814 $tab[] = "0";
1815 // KIdx
1816 $tab[] = "0";
1817 // BTyp
1818 $tab[] = "0";
1819
1820 // MTyp 1=Fibu Einzelbuchung 2=Sammebuchung
1821 if ($sammelBuchung) {
1822 $tab[] = "2";
1823 } else {
1824 $tab[] = "1";
1825 }
1826 // Code
1827 $tab[] = '""';
1828 // Netto
1829 $tab[] = abs($line->debit - $line->credit);
1830 // Steuer
1831 $tab[] = "0.00";
1832 // FW-Betrag
1833 $tab[] = "0.00";
1834 // Tx1
1835 $line1 = self::toAnsi($line->label_compte, 29);
1836 if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) {
1837 $line1 = "";
1838 }
1839 $line2 = self::toAnsi($line->doc_ref, 29);
1840 if (strlen($line1) == 0) {
1841 $line1 = $line2;
1842 $line2 = "";
1843 }
1844 if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) {
1845 $line1 = $line1.' / '.$line2;
1846 $line2 = "";
1847 }
1848
1849 $tab[] = '"'.self::toAnsi($line1).'"';
1850 // Tx2
1851 $tab[] = '"'.self::toAnsi($line2).'"';
1852 //PkKey
1853 $tab[] = "0";
1854 //OpId
1855 $tab[] = $this->separator;
1856
1857 // Flag
1858 $tab[] = "0";
1859
1860 $output = implode($separator, $tab).$end_line;
1861 if ($exportFile) {
1862 fwrite($exportFile, $output);
1863 } else {
1864 print $output;
1865 }
1866
1867 if ($line->piece_num !== $thisPieceNum) {
1868 $thisPieceNum = $line->piece_num;
1869 $thisPieceAccountNr = $line->numero_compte;
1870 }
1871 }
1872 }
1873
1882 public function exportLDCompta($objectLines, $exportFile = null)
1883 {
1884 $separator = ';';
1885 $end_line = "\r\n";
1886
1887 foreach ($objectLines as $line) {
1888 $date_document = dol_print_date($line->doc_date, '%Y%m%d');
1889 $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
1890 $date_lim_reglement = dol_print_date($line->date_lim_reglement, '%Y%m%d');
1891
1892 $tab = array();
1893
1894 // TYPE
1895 $type_enregistrement = 'E'; // For write movement
1896 $tab[] = $type_enregistrement;
1897 // JNAL
1898 $tab[] = substr($line->code_journal, 0, 2);
1899 // NECR
1900 $tab[] = $line->id;
1901 // NPIE
1902 $tab[] = $line->piece_num;
1903 // DATP
1904 $tab[] = $date_document;
1905 // LIBE
1906 $tab[] = $line->label_operation;
1907 // DATH
1908 $tab[] = $date_lim_reglement;
1909 // CNPI
1910 if ($line->doc_type == 'supplier_invoice') {
1911 if (($line->debit - $line->credit) > 0) {
1912 $nature_piece = 'AF';
1913 } else {
1914 $nature_piece = 'FF';
1915 }
1916 } elseif ($line->doc_type == 'customer_invoice') {
1917 if (($line->debit - $line->credit) < 0) {
1918 $nature_piece = 'AC';
1919 } else {
1920 $nature_piece = 'FC';
1921 }
1922 } else {
1923 $nature_piece = '';
1924 }
1925 $tab[] = $nature_piece;
1926 // RACI
1927 // if (!empty($line->subledger_account)) {
1928 // if ($line->doc_type == 'supplier_invoice') {
1929 // $racine_subledger_account = '40';
1930 // } elseif ($line->doc_type == 'customer_invoice') {
1931 // $racine_subledger_account = '41';
1932 // } else {
1933 // $racine_subledger_account = '';
1934 // }
1935 // } else {
1936 $racine_subledger_account = ''; // for records of type E leave this field blank
1937 // }
1938
1939 $tab[] = $racine_subledger_account; // deprecated CPTG & CPTA use instead
1940 // MONT
1941 $tab[] = price(abs($line->debit - $line->credit), 0, '', 1, 2, 2);
1942 // CODC
1943 $tab[] = $line->sens;
1944 // CPTG
1945 $tab[] = length_accountg($line->numero_compte);
1946 // DATE
1947 $tab[] = $date_creation;
1948 // CLET
1949 $tab[] = $line->lettering_code;
1950 // DATL
1951 $tab[] = $line->date_lettering;
1952 // CPTA
1953 if (!empty($line->subledger_account)) {
1954 $tab[] = length_accounta($line->subledger_account);
1955 } else {
1956 $tab[] = "";
1957 }
1958 // CNAT
1959 if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) {
1960 $tab[] = 'F';
1961 } elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) {
1962 $tab[] = 'C';
1963 } else {
1964 $tab[] = "";
1965 }
1966 // SECT
1967 $tab[] = "";
1968 // CTRE
1969 $tab[] = "";
1970 // NORL
1971 $tab[] = "";
1972 // DATV
1973 $tab[] = "";
1974 // REFD
1975 $tab[] = $line->doc_ref;
1976 // CODH
1977 $tab[] = "";
1978 // NSEQ
1979 $tab[] = "";
1980 // MTDV
1981 $tab[] = '0';
1982 // CODV
1983 $tab[] = "";
1984 // TXDV
1985 $tab[] = '0';
1986 // MOPM
1987 $tab[] = "";
1988 // BONP
1989 $tab[] = "";
1990 // BQAF
1991 $tab[] = "";
1992 // ECES
1993 $tab[] = "";
1994 // TXTL
1995 $tab[] = "";
1996 // ECRM
1997 $tab[] = "";
1998 // DATK
1999 $tab[] = "";
2000 // HEUK
2001 $tab[] = "";
2002
2003 $output = implode($separator, $tab).$end_line;
2004 if ($exportFile) {
2005 fwrite($exportFile, $output);
2006 } else {
2007 print $output;
2008 }
2009 }
2010 }
2011
2022 public function exportLDCompta10($objectLines, $exportFile = null)
2023 {
2024 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
2025
2026 $separator = ';';
2027 $end_line = "\r\n";
2028 $last_codeinvoice = '';
2029
2030 foreach ($objectLines as $line) {
2031 // TYPE C
2032 if ($last_codeinvoice != $line->doc_ref) {
2033 //recherche societe en fonction de son code client
2034 $sql = "SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX."societe";
2035 $sql .= " WHERE code_client = '".$this->db->escape($line->thirdparty_code)."'";
2036 $resql = $this->db->query($sql);
2037
2038 if ($resql && $this->db->num_rows($resql) > 0) {
2039 $soc = $this->db->fetch_object($resql);
2040
2041 $address = array('', '', '');
2042 if (strpos($soc->address, "\n") !== false) {
2043 $address = explode("\n", $soc->address);
2044 if (is_array($address) && count($address) > 0) {
2045 foreach ($address as $key => $data) {
2046 $address[$key] = str_replace(array("\t", "\n", "\r"), "", $data);
2047 $address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1);
2048 }
2049 }
2050 } else {
2051 $address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40);
2052 $address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40);
2053 $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40);
2054 }
2055
2056 $tab = array();
2057
2058 $type_enregistrement = 'C';
2059 //TYPE
2060 $tab[] = $type_enregistrement;
2061 //NOCL
2062 $tab[] = $soc->code_client;
2063 //NMCM
2064 $tab[] = "";
2065 //LIBI
2066 $tab[] = "";
2067 //TITR
2068 $tab[] = "";
2069 //RSSO
2070 $tab[] = $soc->nom;
2071 //CAD1
2072 $tab[] = $address[0];
2073 //CAD2
2074 $tab[] = $address[1];
2075 //CAD3
2076 $tab[] = $address[2];
2077 //COPO
2078 $tab[] = $soc->zip;
2079 //BUDI
2080 $tab[] = substr($soc->town, 0, 40);
2081 //CPAY
2082 $tab[] = "";
2083 //PAYS
2084 $tab[] = substr(getCountry($soc->fk_pays), 0, 40);
2085 //NTEL
2086 $tab[] = $soc->phone;
2087 //TLEX
2088 $tab[] = "";
2089 //TLPO
2090 $tab[] = "";
2091 //TLCY
2092 $tab[] = "";
2093 //NINT
2094 $tab[] = "";
2095 //COMM
2096 $tab[] = "";
2097 //SIRE
2098 $tab[] = str_replace(" ", "", $soc->siret);
2099 //RIBP
2100 $tab[] = "";
2101 //DOBQ
2102 $tab[] = "";
2103 //IBBQ
2104 $tab[] = "";
2105 //COBQ
2106 $tab[] = "";
2107 //GUBQ
2108 $tab[] = "";
2109 //CPBQ
2110 $tab[] = "";
2111 //CLBQ
2112 $tab[] = "";
2113 //BIBQ
2114 $tab[] = "";
2115 //MOPM
2116 $tab[] = "";
2117 //DJPM
2118 $tab[] = "";
2119 //DMPM
2120 $tab[] = "";
2121 //REFM
2122 $tab[] = "";
2123 //SLVA
2124 $tab[] = "";
2125 //PLCR
2126 $tab[] = "";
2127 //ECFI
2128 $tab[] = "";
2129 //CREP
2130 $tab[] = "";
2131 //NREP
2132 $tab[] = "";
2133 //TREP
2134 $tab[] = "";
2135 //MREP
2136 $tab[] = "";
2137 //GRRE
2138 $tab[] = "";
2139 //LTTA
2140 $tab[] = "";
2141 //CACT
2142 $tab[] = "";
2143 //CODV
2144 $tab[] = "";
2145 //GRTR
2146 $tab[] = "";
2147 //NOFP
2148 $tab[] = "";
2149 //BQAF
2150 $tab[] = "";
2151 //BONP
2152 $tab[] = "";
2153 //CESC
2154 $tab[] = "";
2155
2156 $output = implode($separator, $tab).$end_line;
2157 if ($exportFile) {
2158 fwrite($exportFile, $output);
2159 } else {
2160 print $output;
2161 }
2162 }
2163 }
2164
2165 $tab = array();
2166
2167 $date_document = dol_print_date($line->doc_date, '%Y%m%d');
2168 $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
2169 $date_lim_reglement = dol_print_date($line->date_lim_reglement, '%Y%m%d');
2170
2171 // TYPE E
2172 $type_enregistrement = 'E'; // For write movement
2173 $tab[] = $type_enregistrement;
2174 // JNAL
2175 $tab[] = substr($line->code_journal, 0, 2);
2176 // NECR
2177 $tab[] = $line->id;
2178 // NPIE
2179 $tab[] = $line->piece_num;
2180 // DATP
2181 $tab[] = $date_document;
2182 // LIBE
2183 $tab[] = dol_trunc($line->label_operation, 25, 'right', 'UTF-8', 1);
2184 // DATH
2185 $tab[] = $date_lim_reglement;
2186 // CNPI
2187 if ($line->doc_type == 'supplier_invoice') {
2188 if (($line->amount) < 0) { // Currently, only the sign of amount allows to know the type of invoice (standard or credit note). Other solution is to analyse debit/credit/role of account. TODO Add column doc_type_long or make amount mandatory with rule on sign.
2189 $nature_piece = 'AF';
2190 } else {
2191 $nature_piece = 'FF';
2192 }
2193 } elseif ($line->doc_type == 'customer_invoice') {
2194 if (($line->amount) < 0) {
2195 $nature_piece = 'AC'; // Currently, only the sign of amount allows to know the type of invoice (standard or credit note). Other solution is to analyse debit/credit/role of account. TODO Add column doc_type_long or make amount mandatory with rule on sign.
2196 } else {
2197 $nature_piece = 'FC';
2198 }
2199 } else {
2200 $nature_piece = '';
2201 }
2202 $tab[] = $nature_piece;
2203 // RACI
2204 // if (!empty($line->subledger_account)) {
2205 // if ($line->doc_type == 'supplier_invoice') {
2206 // $racine_subledger_account = '40';
2207 // } elseif ($line->doc_type == 'customer_invoice') {
2208 // $racine_subledger_account = '41';
2209 // } else {
2210 // $racine_subledger_account = '';
2211 // }
2212 // } else {
2213 $racine_subledger_account = ''; // for records of type E leave this field blank
2214 // }
2215
2216 $tab[] = $racine_subledger_account; // deprecated CPTG & CPTA use instead
2217 // MONT
2218 $tab[] = price(abs($line->debit - $line->credit), 0, '', 1, 2);
2219 // CODC
2220 $tab[] = $line->sens;
2221 // CPTG
2222 $tab[] = length_accountg($line->numero_compte);
2223 // DATE
2224 $tab[] = $date_document;
2225 // CLET
2226 $tab[] = $line->lettering_code;
2227 // DATL
2228 $tab[] = $line->date_lettering;
2229 // CPTA
2230 if (!empty($line->subledger_account)) {
2231 $tab[] = length_accounta($line->subledger_account);
2232 } else {
2233 $tab[] = "";
2234 }
2235 // CNAT
2236 if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) {
2237 $tab[] = 'F';
2238 } elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) {
2239 $tab[] = 'C';
2240 } else {
2241 $tab[] = "";
2242 }
2243 // CTRE
2244 $tab[] = "";
2245 // NORL
2246 $tab[] = "";
2247 // DATV
2248 $tab[] = "";
2249 // REFD
2250 $tab[] = $line->doc_ref;
2251 // NECA
2252 $tab[] = '0';
2253 // CSEC
2254 $tab[] = "";
2255 // CAFF
2256 $tab[] = "";
2257 // CDES
2258 $tab[] = "";
2259 // QTUE
2260 $tab[] = "";
2261 // MTDV
2262 $tab[] = '0';
2263 // CODV
2264 $tab[] = "";
2265 // TXDV
2266 $tab[] = '0';
2267 // MOPM
2268 $tab[] = "";
2269 // BONP
2270 $tab[] = "";
2271 // BQAF
2272 $tab[] = "";
2273 // ECES
2274 $tab[] = "";
2275 // TXTL
2276 $tab[] = "";
2277 // ECRM
2278 $tab[] = "";
2279 // DATK
2280 $tab[] = "";
2281 // HEUK
2282 $tab[] = "";
2283
2284 $output = implode($separator, $tab).$end_line;
2285 if ($exportFile) {
2286 fwrite($exportFile, $output);
2287 } else {
2288 print $output;
2289 }
2290
2291 $last_codeinvoice = $line->doc_ref;
2292 }
2293 }
2294
2302 public function exportCharlemagne($objectLines, $exportFile = null)
2303 {
2304 global $langs;
2305 $langs->load('compta');
2306
2307 $separator = "\t";
2308 $end_line = "\n";
2309
2310 $tab = array();
2311
2312 $tab[] = $langs->transnoentitiesnoconv('Date');
2313 $tab[] = self::trunc($langs->transnoentitiesnoconv('Journal'), 6);
2314 $tab[] = self::trunc($langs->transnoentitiesnoconv('Account'), 15);
2315 $tab[] = self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60);
2316 $tab[] = self::trunc($langs->transnoentitiesnoconv('Piece'), 20);
2317 $tab[] = self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60);
2318 $tab[] = $langs->transnoentitiesnoconv('Amount');
2319 $tab[] = 'S';
2320 $tab[] = self::trunc($langs->transnoentitiesnoconv('Analytic').' 1', 15);
2321 $tab[] = self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 1', 60);
2322 $tab[] = self::trunc($langs->transnoentitiesnoconv('Analytic').' 2', 15);
2323 $tab[] = self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 2', 60);
2324 $tab[] = self::trunc($langs->transnoentitiesnoconv('Analytic').' 3', 15);
2325 $tab[] = self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 3', 60);
2326
2327 $output = implode($separator, $tab).$end_line;
2328 if ($exportFile) {
2329 fwrite($exportFile, $output);
2330 } else {
2331 print $output;
2332 }
2333
2334 foreach ($objectLines as $line) {
2335 $date_document = dol_print_date($line->doc_date, '%Y%m%d');
2336
2337 $tab = array();
2338
2339 $tab[] = $date_document; //Date
2340
2341 $tab[] = self::trunc($line->code_journal, 6); //Journal code
2342
2343 if (!empty($line->subledger_account)) {
2344 $account = $line->subledger_account;
2345 } else {
2346 $account = $line->numero_compte;
2347 }
2348 $tab[] = self::trunc($account, 15); //Account number
2349
2350 $tab[] = self::trunc($line->label_compte, 60); //Account label
2351 $tab[] = self::trunc($line->doc_ref, 20); //Piece
2352 // Clean label operation to prevent problem on export with tab separator & other character
2353 $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
2354 $tab[] = self::trunc($line->label_operation, 60); //Operation label
2355 $tab[] = price(abs($line->debit - $line->credit)); //Amount
2356 $tab[] = $line->sens; //Direction
2357 $tab[] = ""; //Analytic
2358 $tab[] = ""; //Analytic
2359 $tab[] = ""; //Analytic
2360 $tab[] = ""; //Analytic
2361 $tab[] = ""; //Analytic
2362 $tab[] = ""; //Analytic
2363
2364 $output = implode($separator, $tab).$end_line;
2365 if ($exportFile) {
2366 fwrite($exportFile, $output);
2367 } else {
2368 print $output;
2369 }
2370 }
2371 }
2372
2380 public function exportGestimumV3($objectLines, $exportFile = null)
2381 {
2382 global $langs;
2383
2384 $separator = ',';
2385 $end_line = "\r\n";
2386
2387 $invoices_infos = array();
2388 $supplier_invoices_infos = array();
2389 foreach ($objectLines as $line) {
2390 if ($line->debit == 0 && $line->credit == 0) {
2391 //unset($array[$line]);
2392 } else {
2393 $date_document = dol_print_date($line->doc_date, '%d/%m/%Y');
2394 $date_echeance = dol_print_date($line->date_lim_reglement, '%Y%m%d');
2395
2396 $invoice_ref = $line->doc_ref;
2397 $company_name = "";
2398
2399 if (($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice') && $line->fk_doc > 0) {
2400 if (($line->doc_type == 'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) ||
2401 ($line->doc_type == 'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) {
2402 if ($line->doc_type == 'customer_invoice') {
2403 // Get new customer invoice ref and company name
2404 $sql = 'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f';
2405 $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid';
2406 $sql .= ' WHERE f.rowid = '.((int) $line->fk_doc);
2407 $resql = $this->db->query($sql);
2408 if ($resql) {
2409 if ($obj = $this->db->fetch_object($resql)) {
2410 // Save invoice infos
2411 $invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom);
2412 $invoice_ref = $obj->ref;
2413 $company_name = $obj->nom;
2414 }
2415 }
2416 } else {
2417 // Get new supplier invoice ref and company name
2418 $sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff';
2419 $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid';
2420 $sql .= ' WHERE ff.rowid = '.((int) $line->fk_doc);
2421 $resql = $this->db->query($sql);
2422 if ($resql) {
2423 if ($obj = $this->db->fetch_object($resql)) {
2424 // Save invoice infos
2425 $supplier_invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom);
2426 $invoice_ref = $obj->ref;
2427 $company_name = $obj->nom;
2428 }
2429 }
2430 }
2431 } elseif ($line->doc_type == 'customer_invoice') {
2432 // Retrieve invoice infos
2433 $invoice_ref = $invoices_infos[$line->fk_doc]['ref'];
2434 $company_name = $invoices_infos[$line->fk_doc]['company_name'];
2435 } else {
2436 // Retrieve invoice infos
2437 $invoice_ref = $supplier_invoices_infos[$line->fk_doc]['ref'];
2438 $company_name = $supplier_invoices_infos[$line->fk_doc]['company_name'];
2439 }
2440 }
2441
2442 $tab = array();
2443
2444 $tab[] = $line->id;
2445 $tab[] = $date_document;
2446 $tab[] = substr($line->code_journal, 0, 4);
2447
2448 if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) {
2449 $tab[] = length_accountg($line->subledger_account);
2450 } else {
2451 $tab[] = substr(length_accountg($line->numero_compte), 0, 15);
2452 }
2453 //Libellé Auto
2454 $tab[] = "";
2455 //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"';
2456 //Libellé manuel
2457 $tab[] = dol_trunc(str_replace('"', '', $invoice_ref . (!empty($company_name) ? ' - ' : '') . $company_name), 40, 'right', 'UTF-8', 1);
2458 //Numéro de pièce
2459 $tab[] = dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1);
2460 //Devise
2461 $tab[] = 'EUR';
2462 //Amount
2463 $tab[] = price2num(abs($line->debit - $line->credit));
2464 //Sens
2465 $tab[] = $line->sens;
2466 //Code lettrage
2467 $tab[] = "";
2468 //Date Echéance
2469 $tab[] = $date_echeance;
2470
2471 $output = implode($separator, $tab).$end_line;
2472 if ($exportFile) {
2473 fwrite($exportFile, $output);
2474 } else {
2475 print $output;
2476 }
2477 }
2478 }
2479 }
2480
2488 public function exportGestimumV5($objectLines, $exportFile = null)
2489 {
2490 $separator = ',';
2491 $end_line = "\r\n";
2492
2493 foreach ($objectLines as $line) {
2494 if ($line->debit == 0 && $line->credit == 0) {
2495 //unset($array[$line]);
2496 } else {
2497 $date_document = dol_print_date($line->doc_date, '%d%m%Y');
2498
2499 $tab = array();
2500
2501 $tab[] = $line->id;
2502 $tab[] = $date_document;
2503 $tab[] = substr($line->code_journal, 0, 4);
2504 if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { // TODO No hard code value
2505 $tab[] = length_accountg($line->subledger_account);
2506 } else {
2507 $tab[] = substr(length_accountg($line->numero_compte), 0, 15);
2508 }
2509 $tab[] = "";
2510 $tab[] = '"'.dol_trunc(str_replace('"', '', $line->label_operation), 40, 'right', 'UTF-8', 1).'"';
2511 $tab[] = '"' . dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1) . '"';
2512 $tab[] = '"' . dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . '"';
2513 $tab[] = price2num(abs($line->debit - $line->credit));
2514 $tab[] = $line->sens;
2515 $tab[] = $date_document;
2516 $tab[] = "";
2517 $tab[] = "";
2518 $tab[] = 'EUR';
2519
2520 $output = implode($separator, $tab).$end_line;
2521 if ($exportFile) {
2522 fwrite($exportFile, $output);
2523 } else {
2524 print $output;
2525 }
2526 }
2527 }
2528 }
2529
2539 public function exportiSuiteExpert($objectLines, $exportFile = null)
2540 {
2541 $separator = ';';
2542 $end_line = "\r\n";
2543
2544
2545 foreach ($objectLines as $line) {
2546 $tab = array();
2547
2548 $date = dol_print_date($line->doc_date, '%d/%m/%Y');
2549
2550 $tab[] = $line->piece_num;
2551 $tab[] = $date;
2552 $tab[] = substr($date, 6, 4);
2553 $tab[] = substr($date, 3, 2);
2554 $tab[] = substr($date, 0, 2);
2555 $tab[] = $line->doc_ref;
2556 //Conversion de chaine UTF8 en Latin9
2557 $tab[] = mb_convert_encoding(str_replace(' - Compte auxiliaire', '', $line->label_operation), "Windows-1252", 'UTF-8');
2558
2559 //Calcul de la longueur des numéros de comptes
2560 $taille_numero = strlen(length_accountg($line->numero_compte));
2561
2562 //Création du numéro de client et fournisseur générique
2563 $numero_cpt_client = '411';
2564 $numero_cpt_fourn = '401';
2565 for ($i = 1; $i <= ($taille_numero - 3); $i++) {
2566 $numero_cpt_client .= '0';
2567 $numero_cpt_fourn .= '0';
2568 }
2569
2570 //Création des comptes auxiliaire des clients et fournisseur
2571 if (length_accountg($line->numero_compte) == $numero_cpt_client || length_accountg($line->numero_compte) == $numero_cpt_fourn) {
2572 $tab[] = rtrim(length_accounta($line->subledger_account), "0");
2573 } else {
2574 $tab[] = length_accountg($line->numero_compte);
2575 }
2576 $nom_client = explode(" - ", $line->label_operation);
2577 $tab[] = mb_convert_encoding($nom_client[0], "Windows-1252", 'UTF-8');
2578 $tab[] = price($line->debit);
2579 $tab[] = price($line->credit);
2580 $tab[] = price($line->montant);
2581 $tab[] = $line->code_journal;
2582
2583 $output = implode($separator, $tab).$end_line;
2584 if ($exportFile) {
2585 fwrite($exportFile, $output);
2586 } else {
2587 print $output;
2588 }
2589 }
2590 }
2591
2599 public static function trunc($str, $size)
2600 {
2601 return dol_trunc($str, $size, 'right', 'UTF-8', 1);
2602 }
2603
2611 public static function toAnsi($str, $size = -1)
2612 {
2613 $retVal = dol_string_nohtmltag($str, 1, 'Windows-1251');
2614 if ($retVal >= 0 && $size >= 0) {
2615 $retVal = dol_substr($retVal, 0, $size, 'Windows-1251');
2616 }
2617 return $retVal;
2618 }
2619}
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.
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...
exportCharlemagne($objectLines, $exportFile=null)
Export format : Charlemagne.
getTypeConfig()
Array with all export type available (key + label) and parameters for config.
exportFEC($objectLines, $exportFile=null, $archiveFileList=array(), $withAttachment=0)
Export format : FEC Last review for this format : 2023/10/12 Alexandre Spangaro (aspangaro@open-dsi....
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)
exportFEC2($objectLines, $exportFile=null, $archiveFileList=array(), $withAttachment=0)
Export format : FEC2 Last review for this format : 2023/10/12 Alexandre Spangaro (aspangaro@open-dsi....
__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.
Definition files.lib.php:62
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).
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
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.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
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.