dolibarr  16.0.1
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-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
9  * Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com>
10  * Copyright (C) 2017 Elarifr. Ari Elbaz <github@accedinfo.com>
11  * Copyright (C) 2017-2019 Frédéric France <frederic.france@netlogic.fr>
12  * Copyright (C) 2017 André Schild <a.schild@aarboard.ch>
13  * Copyright (C) 2020 Guillaume Alexandre <guillaume@tag-info.fr>
14  * Copyright (C) 2022 Joachim Kueter <jkueter@gmx.de>
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program. If not, see <https://www.gnu.org/licenses/>.
28  */
29 
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
39 
40 
45 {
46  // Type of export. Used into $conf->global->ACCOUNTING_EXPORT_MODELCSV
47  public static $EXPORT_TYPE_CONFIGURABLE = 1; // CSV
48  public static $EXPORT_TYPE_AGIRIS = 10;
49  public static $EXPORT_TYPE_EBP = 15;
50  public static $EXPORT_TYPE_CEGID = 20;
51  public static $EXPORT_TYPE_COGILOG = 25;
52  public static $EXPORT_TYPE_COALA = 30;
53  public static $EXPORT_TYPE_BOB50 = 35;
54  public static $EXPORT_TYPE_CIEL = 40;
55  public static $EXPORT_TYPE_SAGE50_SWISS = 45;
56  public static $EXPORT_TYPE_CHARLEMAGNE = 50;
57  public static $EXPORT_TYPE_QUADRATUS = 60;
58  public static $EXPORT_TYPE_WINFIC = 70;
59  public static $EXPORT_TYPE_OPENCONCERTO = 100;
60  public static $EXPORT_TYPE_LDCOMPTA = 110;
61  public static $EXPORT_TYPE_LDCOMPTA10 = 120;
62  public static $EXPORT_TYPE_GESTIMUMV3 = 130;
63  public static $EXPORT_TYPE_GESTIMUMV5 = 135;
64  public static $EXPORT_TYPE_ISUITEEXPERT = 200;
65  // Generic FEC after that
66  public static $EXPORT_TYPE_FEC = 1000;
67  public static $EXPORT_TYPE_FEC2 = 1010;
68 
72  public $db;
73 
77  public $errors = array();
78 
83  public $separator = '';
84 
89  public $end_line = '';
90 
96  public function __construct(DoliDB $db)
97  {
98  global $conf, $hookmanager;
99 
100  $this->db = $db;
101  $this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
102  $this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? "\n" : ($conf->global->ACCOUNTING_EXPORT_ENDLINE == 1 ? "\n" : "\r\n");
103 
104  $hookmanager->initHooks(array('accountancyexport'));
105  }
106 
112  public function getType()
113  {
114  global $langs, $hookmanager;
115 
116  $listofexporttypes = array(
117  self::$EXPORT_TYPE_CONFIGURABLE => $langs->trans('Modelcsv_configurable'),
118  self::$EXPORT_TYPE_CEGID => $langs->trans('Modelcsv_CEGID'),
119  self::$EXPORT_TYPE_COALA => $langs->trans('Modelcsv_COALA'),
120  self::$EXPORT_TYPE_BOB50 => $langs->trans('Modelcsv_bob50'),
121  self::$EXPORT_TYPE_CIEL => $langs->trans('Modelcsv_ciel'),
122  self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus'),
123  self::$EXPORT_TYPE_WINFIC => $langs->trans('Modelcsv_winfic'),
124  self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'),
125  self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'),
126  self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'),
127  self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'),
128  self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'),
129  self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'),
130  self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'),
131  self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans('Modelcsv_LDCompta10'),
132  self::$EXPORT_TYPE_GESTIMUMV3 => $langs->trans('Modelcsv_Gestinumv3'),
133  self::$EXPORT_TYPE_GESTIMUMV5 => $langs->trans('Modelcsv_Gestinumv5'),
134  self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'),
135  self::$EXPORT_TYPE_FEC2 => $langs->trans('Modelcsv_FEC2'),
136  self::$EXPORT_TYPE_ISUITEEXPERT => 'Export iSuite Expert',
137  );
138 
139  // allow modules to define export formats
140  $parameters = array();
141  $reshook = $hookmanager->executeHooks('getType', $parameters, $listofexporttypes);
142 
143  ksort($listofexporttypes, SORT_NUMERIC);
144 
145  return $listofexporttypes;
146  }
147 
154  public static function getFormatCode($type)
155  {
156  $formatcode = array(
157  self::$EXPORT_TYPE_CONFIGURABLE => 'csv',
158  self::$EXPORT_TYPE_CEGID => 'cegid',
159  self::$EXPORT_TYPE_COALA => 'coala',
160  self::$EXPORT_TYPE_BOB50 => 'bob50',
161  self::$EXPORT_TYPE_CIEL => 'ciel',
162  self::$EXPORT_TYPE_QUADRATUS => 'quadratus',
163  self::$EXPORT_TYPE_WINFIC => 'winfic',
164  self::$EXPORT_TYPE_EBP => 'ebp',
165  self::$EXPORT_TYPE_COGILOG => 'cogilog',
166  self::$EXPORT_TYPE_AGIRIS => 'agiris',
167  self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto',
168  self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch',
169  self::$EXPORT_TYPE_CHARLEMAGNE => 'charlemagne',
170  self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta',
171  self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10',
172  self::$EXPORT_TYPE_GESTIMUMV3 => 'gestimumv3',
173  self::$EXPORT_TYPE_GESTIMUMV5 => 'gestimumv5',
174  self::$EXPORT_TYPE_FEC => 'fec',
175  self::$EXPORT_TYPE_FEC2 => 'fec2',
176  self::$EXPORT_TYPE_ISUITEEXPERT => 'isuiteexpert',
177  );
178 
179  global $hookmanager;
180  $code = $formatcode[$type];
181  $parameters = array('type' => $type);
182  $reshook = $hookmanager->executeHooks('getFormatCode', $parameters, $code);
183 
184  return $code;
185  }
186 
192  public function getTypeConfig()
193  {
194  global $conf, $langs;
195 
196  $exporttypes = array(
197  'param' => array(
198  self::$EXPORT_TYPE_CONFIGURABLE => array(
199  'label' => $langs->trans('Modelcsv_configurable'),
200  'ACCOUNTING_EXPORT_FORMAT' => empty($conf->global->ACCOUNTING_EXPORT_FORMAT) ? 'txt' : $conf->global->ACCOUNTING_EXPORT_FORMAT,
201  'ACCOUNTING_EXPORT_SEPARATORCSV' => empty($conf->global->ACCOUNTING_EXPORT_SEPARATORCSV) ? ',' : $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV,
202  'ACCOUNTING_EXPORT_ENDLINE' => empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? 1 : $conf->global->ACCOUNTING_EXPORT_ENDLINE,
203  'ACCOUNTING_EXPORT_DATE' => empty($conf->global->ACCOUNTING_EXPORT_DATE) ? '%d%m%Y' : $conf->global->ACCOUNTING_EXPORT_DATE,
204  ),
205  self::$EXPORT_TYPE_CEGID => array(
206  'label' => $langs->trans('Modelcsv_CEGID'),
207  ),
208  self::$EXPORT_TYPE_COALA => array(
209  'label' => $langs->trans('Modelcsv_COALA'),
210  ),
211  self::$EXPORT_TYPE_BOB50 => array(
212  'label' => $langs->trans('Modelcsv_bob50'),
213  ),
214  self::$EXPORT_TYPE_CIEL => array(
215  'label' => $langs->trans('Modelcsv_ciel'),
216  'ACCOUNTING_EXPORT_FORMAT' => 'txt',
217  ),
218  self::$EXPORT_TYPE_QUADRATUS => array(
219  'label' => $langs->trans('Modelcsv_quadratus'),
220  'ACCOUNTING_EXPORT_FORMAT' => 'txt',
221  ),
222  self::$EXPORT_TYPE_WINFIC => array(
223  'label' => $langs->trans('Modelcsv_winfic'),
224  'ACCOUNTING_EXPORT_FORMAT' => 'txt',
225  ),
226  self::$EXPORT_TYPE_EBP => array(
227  'label' => $langs->trans('Modelcsv_ebp'),
228  ),
229  self::$EXPORT_TYPE_COGILOG => array(
230  'label' => $langs->trans('Modelcsv_cogilog'),
231  ),
232  self::$EXPORT_TYPE_AGIRIS => array(
233  'label' => $langs->trans('Modelcsv_agiris'),
234  ),
235  self::$EXPORT_TYPE_OPENCONCERTO => array(
236  'label' => $langs->trans('Modelcsv_openconcerto'),
237  ),
238  self::$EXPORT_TYPE_SAGE50_SWISS => array(
239  'label' => $langs->trans('Modelcsv_Sage50_Swiss'),
240  ),
241  self::$EXPORT_TYPE_CHARLEMAGNE => array(
242  'label' => $langs->trans('Modelcsv_charlemagne'),
243  'ACCOUNTING_EXPORT_FORMAT' => 'txt',
244  ),
245  self::$EXPORT_TYPE_LDCOMPTA => array(
246  'label' => $langs->trans('Modelcsv_LDCompta'),
247  ),
248  self::$EXPORT_TYPE_LDCOMPTA10 => array(
249  'label' => $langs->trans('Modelcsv_LDCompta10'),
250  ),
251  self::$EXPORT_TYPE_GESTIMUMV3 => array(
252  'label' => $langs->trans('Modelcsv_Gestinumv3'),
253  'ACCOUNTING_EXPORT_FORMAT' => 'txt',
254  ),
255  self::$EXPORT_TYPE_GESTIMUMV5 => array(
256  'label' => $langs->trans('Modelcsv_Gestinumv5'),
257  'ACCOUNTING_EXPORT_FORMAT' => 'txt',
258  ),
259  self::$EXPORT_TYPE_FEC => array(
260  'label' => $langs->trans('Modelcsv_FEC'),
261  'ACCOUNTING_EXPORT_FORMAT' => 'txt',
262  ),
263  self::$EXPORT_TYPE_FEC2 => array(
264  'label' => $langs->trans('Modelcsv_FEC2'),
265  'ACCOUNTING_EXPORT_FORMAT' => 'txt',
266  ),
267  self::$EXPORT_TYPE_ISUITEEXPERT => array(
268  'label' => 'iSuite Expert',
269  'ACCOUNTING_EXPORT_FORMAT' => 'csv',
270  ),
271  ),
272  'cr'=> array(
273  '1' => $langs->trans("Unix"),
274  '2' => $langs->trans("Windows")
275  ),
276  'format' => array(
277  'csv' => $langs->trans("csv"),
278  'txt' => $langs->trans("txt")
279  ),
280  );
281 
282  global $hookmanager;
283  $parameters = array();
284  $reshook = $hookmanager->executeHooks('getTypeConfig', $parameters, $exporttypes);
285  return $exporttypes;
286  }
287 
288 
296  public function export(&$TData, $formatexportset)
297  {
298  global $conf, $langs;
299  global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php
300 
301  // Define name of file to save
302  $filename = 'general_ledger-'.$this->getFormatCode($formatexportset);
303  $type_export = 'general_ledger';
304 
305  global $db; // The tpl file use $db
306  include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
307 
308 
309  switch ($formatexportset) {
310  case self::$EXPORT_TYPE_CONFIGURABLE:
311  $this->exportConfigurable($TData);
312  break;
313  case self::$EXPORT_TYPE_CEGID:
314  $this->exportCegid($TData);
315  break;
316  case self::$EXPORT_TYPE_COALA:
317  $this->exportCoala($TData);
318  break;
319  case self::$EXPORT_TYPE_BOB50:
320  $this->exportBob50($TData);
321  break;
322  case self::$EXPORT_TYPE_CIEL:
323  $this->exportCiel($TData);
324  break;
325  case self::$EXPORT_TYPE_QUADRATUS:
326  $this->exportQuadratus($TData);
327  break;
328  case self::$EXPORT_TYPE_WINFIC:
329  $this->exportWinfic($TData);
330  break;
331  case self::$EXPORT_TYPE_EBP:
332  $this->exportEbp($TData);
333  break;
334  case self::$EXPORT_TYPE_COGILOG:
335  $this->exportCogilog($TData);
336  break;
337  case self::$EXPORT_TYPE_AGIRIS:
338  $this->exportAgiris($TData);
339  break;
340  case self::$EXPORT_TYPE_OPENCONCERTO:
341  $this->exportOpenConcerto($TData);
342  break;
343  case self::$EXPORT_TYPE_SAGE50_SWISS:
344  $this->exportSAGE50SWISS($TData);
345  break;
346  case self::$EXPORT_TYPE_CHARLEMAGNE:
347  $this->exportCharlemagne($TData);
348  break;
349  case self::$EXPORT_TYPE_LDCOMPTA:
350  $this->exportLDCompta($TData);
351  break;
352  case self::$EXPORT_TYPE_LDCOMPTA10:
353  $this->exportLDCompta10($TData);
354  break;
355  case self::$EXPORT_TYPE_GESTIMUMV3:
356  $this->exportGestimumV3($TData);
357  break;
358  case self::$EXPORT_TYPE_GESTIMUMV5:
359  $this->exportGestimumV5($TData);
360  break;
361  case self::$EXPORT_TYPE_FEC:
362  $this->exportFEC($TData);
363  break;
364  case self::$EXPORT_TYPE_FEC2:
365  $this->exportFEC2($TData);
366  break;
367  case self::$EXPORT_TYPE_ISUITEEXPERT :
368  $this->exportiSuiteExpert($TData);
369  break;
370  default:
371  global $hookmanager;
372  $parameters = array('format' => $formatexportset);
373  // file contents will be created in the hooked function via print
374  $reshook = $hookmanager->executeHooks('export', $parameters, $TData);
375  if ($reshook != 1) {
376  $this->errors[] = $langs->trans('accountancy_error_modelnotfound');
377  }
378  break;
379  }
380  }
381 
382 
389  public function exportCegid($objectLines)
390  {
391  foreach ($objectLines as $line) {
392  $date = dol_print_date($line->doc_date, '%d%m%Y');
393  $separator = ";";
394  $end_line = "\n";
395 
396  print $date.$separator;
397  print $line->code_journal.$separator;
398  print length_accountg($line->numero_compte).$separator;
399  print length_accounta($line->subledger_account).$separator;
400  print $line->sens.$separator;
401  print price2fec(abs($line->debit - $line->credit)).$separator;
402  print dol_string_unaccent($line->label_operation).$separator;
403  print dol_string_unaccent($line->doc_ref);
404  print $end_line;
405  }
406  }
407 
414  public function exportCogilog($objectLines)
415  {
416  foreach ($objectLines as $line) {
417  $date = dol_print_date($line->doc_date, '%d%m%Y');
418  $separator = ";";
419  $end_line = "\n";
420 
421  print $line->code_journal.$separator;
422  print $date.$separator;
423  print $line->piece_num.$separator;
424  print length_accountg($line->numero_compte).$separator;
425  print ''.$separator;
426  print $line->label_operation.$separator;
427  print $date.$separator;
428  if ($line->sens == 'D') {
429  print price($line->debit).$separator;
430  print ''.$separator;
431  } elseif ($line->sens == 'C') {
432  print ''.$separator;
433  print price($line->credit).$separator;
434  }
435  print $line->doc_ref.$separator;
436  print $line->label_operation.$separator;
437  print $end_line;
438  }
439  }
440 
447  public function exportCoala($objectLines)
448  {
449  // Coala export
450  $separator = ";";
451  $end_line = "\n";
452 
453  foreach ($objectLines as $line) {
454  $date = dol_print_date($line->doc_date, '%d/%m/%Y');
455 
456  print $date.$separator;
457  print $line->code_journal.$separator;
458  print length_accountg($line->numero_compte).$separator;
459  print $line->piece_num.$separator;
460  print $line->doc_ref.$separator;
461  print price($line->debit).$separator;
462  print price($line->credit).$separator;
463  print 'E'.$separator;
464  print length_accounta($line->subledger_account).$separator;
465  print $end_line;
466  }
467  }
468 
475  public function exportBob50($objectLines)
476  {
477 
478  // Bob50
479  $separator = ";";
480  $end_line = "\n";
481 
482  foreach ($objectLines as $line) {
483  print $line->piece_num.$separator;
484  $date = dol_print_date($line->doc_date, '%d/%m/%Y');
485  print $date.$separator;
486 
487  if (empty($line->subledger_account)) {
488  print 'G'.$separator;
489  print length_accounta($line->numero_compte).$separator;
490  } else {
491  if (substr($line->numero_compte, 0, 3) == '411') {
492  print 'C'.$separator;
493  }
494  if (substr($line->numero_compte, 0, 3) == '401') {
495  print 'F'.$separator;
496  }
497  print length_accountg($line->subledger_account).$separator;
498  }
499 
500  print price($line->debit).$separator;
501  print price($line->credit).$separator;
502  print dol_trunc($line->label_operation, 32).$separator;
503  print $end_line;
504  }
505  }
506 
521  public function exportCiel(&$TData)
522  {
523  $end_line = "\r\n";
524 
525  $i = 1;
526 
527  foreach ($TData as $data) {
528  $code_compta = length_accountg($data->numero_compte);
529  if (!empty($data->subledger_account)) {
530  $code_compta = length_accounta($data->subledger_account);
531  }
532 
533  $date_document = dol_print_date($data->doc_date, '%Y%m%d');
534  $date_echeance = dol_print_date($data->date_lim_reglement, '%Y%m%d');
535 
536  $Tab = array();
537  $Tab['num_ecriture'] = str_pad($data->piece_num, 5);
538  $Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
539  $Tab['date_ecriture'] = str_pad($date_document, 8, ' ', STR_PAD_LEFT);
540  $Tab['date_echeance'] = str_pad($date_echeance, 8, ' ', STR_PAD_LEFT);
541  $Tab['num_piece'] = str_pad(self::trunc($data->doc_ref, 12), 12);
542  $Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11);
543  $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).dol_string_unaccent($data->label_operation), 25), 25);
544  $Tab['montant'] = str_pad(price2fec(abs($data->debit - $data->credit)), 13, ' ', STR_PAD_LEFT);
545  $Tab['type_montant'] = str_pad($data->sens, 1);
546  $Tab['vide'] = str_repeat(' ', 18); // Analytical accounting - Not managed in Dolibarr
547  $Tab['intitule_compte'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 34), 34);
548  $Tab['end'] = 'O2003'; // 0 = EUR | 2003 = Format Ciel
549 
550  $Tab['end_line'] = $end_line;
551 
552  print implode($Tab);
553  $i++;
554  }
555  }
556 
568  public function exportQuadratus(&$TData)
569  {
570  global $conf, $db;
571 
572  $end_line = "\r\n";
573 
574  // We should use dol_now function not time however this is wrong date to transfert in accounting
575  // $date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
576  // $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
577  foreach ($TData as $data) {
578  $code_compta = $data->numero_compte;
579  if (!empty($data->subledger_account)) {
580  $code_compta = $data->subledger_account;
581  }
582 
583  $Tab = array();
584 
585  if (!empty($data->subledger_account)) {
586  $Tab['type_ligne'] = 'C';
587  $Tab['num_compte'] = str_pad(self::trunc($data->subledger_account, 8), 8);
588  $Tab['lib_compte'] = str_pad(self::trunc($data->subledger_label, 30), 30);
589 
590  if ($data->doc_type == 'customer_invoice') {
591  $Tab['lib_alpha'] = strtoupper(str_pad('C'.self::trunc($data->subledger_label, 6), 6));
592  $Tab['filler'] = str_repeat(' ', 52);
593  $Tab['coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, 8), 8);
594  } elseif ($data->doc_type == 'supplier_invoice') {
595  $Tab['lib_alpha'] = strtoupper(str_pad('F'.self::trunc($data->subledger_label, 6), 6));
596  $Tab['filler'] = str_repeat(' ', 52);
597  $Tab['coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, 8), 8);
598  } else {
599  $Tab['filler'] = str_repeat(' ', 59);
600  $Tab['coll_compte'] = str_pad(' ', 8);
601  }
602 
603  $Tab['filler2'] = str_repeat(' ', 110);
604  $Tab['Maj'] = 2; // Partial update (alpha key, label, address, collectif, RIB)
605 
606  if ($data->doc_type == 'customer_invoice') {
607  $Tab['type_compte'] = 'C';
608  } elseif ($data->doc_type == 'supplier_invoice') {
609  $Tab['coll_compte'] = 'F';
610  } else {
611  $Tab['coll_compte'] = 'G';
612  }
613 
614  $Tab['filler3'] = str_repeat(' ', 235);
615 
616  $Tab['end_line'] = $end_line;
617 
618  print implode($Tab);
619  }
620 
621  $Tab = array();
622  $Tab['type_ligne'] = 'M';
623  $Tab['num_compte'] = str_pad(self::trunc($code_compta, 8), 8);
624  $Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
625  $Tab['folio'] = '000';
626 
627  // We use invoice date $data->doc_date not $date_ecriture which is the transfert date
628  // maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ?
629  //$Tab['date_ecriture'] = $date_ecriture;
630  $Tab['date_ecriture'] = dol_print_date($data->doc_date, '%d%m%y');
631  $Tab['filler'] = ' ';
632  $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20);
633 
634  // Credit invoice - invert sens
635  /*
636  if ($data->montant < 0) {
637  if ($data->sens == 'C') {
638  $Tab['sens'] = 'D';
639  } else {
640  $Tab['sens'] = 'C';
641  }
642  $Tab['signe_montant'] = '-';
643  } else {
644  $Tab['sens'] = $data->sens; // C or D
645  $Tab['signe_montant'] = '+';
646  }*/
647  $Tab['sens'] = $data->sens; // C or D
648  $Tab['signe_montant'] = '+';
649 
650  // The amount must be in centimes without decimal points.
651  $Tab['montant'] = str_pad(abs(($data->debit - $data->credit) * 100), 12, '0', STR_PAD_LEFT);
652  $Tab['contrepartie'] = str_repeat(' ', 8);
653 
654  // Force date format : %d%m%y
655  if (!empty($data->date_lim_reglement)) {
656  //$Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, $conf->global->ACCOUNTING_EXPORT_DATE);
657  $Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, '%d%m%y'); // Format must be ddmmyy
658  } else {
659  $Tab['date_echeance'] = '000000';
660  }
661 
662  // Please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5)
663  // $Tab['lettrage'] = str_repeat(' ', 5);
664  $Tab['lettrage'] = str_repeat(' ', 2);
665  $Tab['codestat'] = str_repeat(' ', 3);
666  $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5);
667 
668  // Keep correct quadra named field instead of anon filler
669  // $Tab['filler2'] = str_repeat(' ', 20);
670  $Tab['affaire'] = str_repeat(' ', 10);
671  $Tab['quantity1'] = str_repeat(' ', 10);
672  $Tab['num_piece2'] = str_pad(self::trunc($data->piece_num, 8), 8);
673  $Tab['devis'] = str_pad($conf->currency, 3);
674  $Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3);
675  $Tab['filler3'] = str_repeat(' ', 3);
676 
677  // Keep correct quadra named field instead of anon filler libelle_ecriture2 is 30 char not 32 !!!!
678  // 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
679  // TODO: we should filter more than only accent to avoid wrong line size
680  // TODO: remove invoice number doc_ref in libelle,
681  // TODO: we should offer an option for customer to build the libelle using invoice number / name / date in accounting software
682  //$Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref) . ' ' . dol_string_unaccent($data->label_operation), 30), 30);
683  $Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 30), 30);
684  $Tab['codetva'] = str_repeat(' ', 2);
685 
686  // We need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part
687  // $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10);
688  $Tab['num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10);
689  $Tab['filler4'] = str_repeat(' ', 73);
690 
691  $Tab['end_line'] = $end_line;
692 
693  print implode($Tab);
694  }
695  }
696 
704  public function exportWinfic(&$TData)
705  {
706  global $conf;
707 
708  $end_line = "\r\n";
709 
710  //We should use dol_now function not time however this is wrong date to transfert in accounting
711  //$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
712  //$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
713  foreach ($TData as $data) {
714  $code_compta = $data->numero_compte;
715  if (!empty($data->subledger_account)) {
716  $code_compta = $data->subledger_account;
717  }
718 
719  $Tab = array();
720  //$Tab['type_ligne'] = 'M';
721  $Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
722 
723  //We use invoice date $data->doc_date not $date_ecriture which is the transfert date
724  //maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ?
725  //$Tab['date_ecriture'] = $date_ecriture;
726  $Tab['date_operation'] = dol_print_date($data->doc_date, '%d%m%Y');
727 
728  $Tab['folio'] = ' 1';
729 
730  $Tab['num_ecriture'] = str_pad(self::trunc($data->piece_num, 6), 6, ' ', STR_PAD_LEFT);
731 
732  $Tab['jour_ecriture'] = dol_print_date($data->doc_date, '%d%m%y');
733 
734  $Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0');
735 
736  if ($data->sens == 'D') {
737  $Tab['montant_debit'] = str_pad(number_format($data->debit, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
738 
739  $Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
740  } else {
741  $Tab['montant_debit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
742 
743  $Tab['montant_crebit'] = str_pad(number_format($data->credit, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
744  }
745 
746  $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 30), 30);
747 
748  $Tab['lettrage'] = str_repeat(' ', 2);
749 
750  $Tab['code_piece'] = str_repeat(' ', 5);
751 
752  $Tab['code_stat'] = str_repeat(' ', 4);
753 
754  if (!empty($data->date_lim_reglement)) {
755  //$Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, $conf->global->ACCOUNTING_EXPORT_DATE);
756  $Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, '%d%m%Y');
757  } else {
758  $Tab['date_echeance'] = dol_print_date($data->doc_date, '%d%m%Y');
759  }
760 
761  $Tab['monnaie'] = '1';
762 
763  $Tab['filler'] = ' ';
764 
765  $Tab['ind_compteur'] = ' ';
766 
767  $Tab['quantite'] = '0,000000000';
768 
769  $Tab['code_pointage'] = str_repeat(' ', 2);
770 
771  $Tab['end_line'] = $end_line;
772 
773  print implode('|', $Tab);
774  }
775  }
776 
777 
784  public function exportEbp($objectLines)
785  {
786 
787  $separator = ',';
788  $end_line = "\n";
789 
790  foreach ($objectLines as $line) {
791  $date = dol_print_date($line->doc_date, '%d%m%Y');
792 
793  print $line->id.$separator;
794  print $date.$separator;
795  print $line->code_journal.$separator;
796  if (empty($line->subledger_account)) {
797  print $line->numero_compte.$separator;
798  } else {
799  print $line->subledger_account.$separator;
800  }
801  //print substr(length_accountg($line->numero_compte), 0, 2) . $separator;
802  print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator;
803  print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator;
804  print price2num(abs($line->debit - $line->credit)).$separator;
805  print $line->sens.$separator;
806  print $date.$separator;
807  //print 'EUR';
808  print $end_line;
809  }
810  }
811 
812 
819  public function exportAgiris($objectLines)
820  {
821 
822  $separator = ';';
823  $end_line = "\n";
824 
825  foreach ($objectLines as $line) {
826  $date = dol_print_date($line->doc_date, '%d%m%Y');
827 
828  print $line->piece_num.$separator;
829  print self::toAnsi($line->label_operation).$separator;
830  print $date.$separator;
831  print self::toAnsi($line->label_operation).$separator;
832 
833  if (empty($line->subledger_account)) {
834  print length_accountg($line->numero_compte).$separator;
835  print self::toAnsi($line->label_compte).$separator;
836  } else {
837  print length_accounta($line->subledger_account).$separator;
838  print self::toAnsi($line->subledger_label).$separator;
839  }
840 
841  print self::toAnsi($line->doc_ref).$separator;
842  print price($line->debit).$separator;
843  print price($line->credit).$separator;
844  print price(abs($line->debit - $line->credit)).$separator;
845  print $line->sens.$separator;
846  print $line->lettering_code.$separator;
847  print $line->code_journal;
848  print $end_line;
849  }
850  }
851 
858  public function exportOpenConcerto($objectLines)
859  {
860 
861  $separator = ';';
862  $end_line = "\n";
863 
864  foreach ($objectLines as $line) {
865  $date = dol_print_date($line->doc_date, '%d/%m/%Y');
866 
867  print $date.$separator;
868  print $line->code_journal.$separator;
869  if (empty($line->subledger_account)) {
870  print length_accountg($line->numero_compte).$separator;
871  } else {
872  print length_accounta($line->subledger_account).$separator;
873  }
874  print $line->doc_ref.$separator;
875  print $line->label_operation.$separator;
876  print price($line->debit).$separator;
877  print price($line->credit).$separator;
878 
879  print $end_line;
880  }
881  }
882 
889  public function exportConfigurable($objectLines)
890  {
891  global $conf;
892 
893  $separator = $this->separator;
894 
895  foreach ($objectLines as $line) {
896  $tab = array();
897  // export configurable
898  $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
899  $tab[] = $line->piece_num;
900  $tab[] = $date;
901  $tab[] = $line->doc_ref;
902  $tab[] = preg_match('/'.$separator.'/', $line->label_operation) ? "'".$line->label_operation."'" : $line->label_operation;
903  $tab[] = length_accountg($line->numero_compte);
904  $tab[] = length_accounta($line->subledger_account);
905  $tab[] = price2num($line->debit);
906  $tab[] = price2num($line->credit);
907  $tab[] = price2num($line->debit - $line->credit);
908  $tab[] = $line->code_journal;
909 
910  print implode($separator, $tab).$this->end_line;
911  }
912  }
913 
920  public function exportFEC($objectLines)
921  {
922  global $langs;
923 
924  $separator = "\t";
925  $end_line = "\r\n";
926 
927  print "JournalCode".$separator;
928  print "JournalLib".$separator;
929  print "EcritureNum".$separator;
930  print "EcritureDate".$separator;
931  print "CompteNum".$separator;
932  print "CompteLib".$separator;
933  print "CompAuxNum".$separator;
934  print "CompAuxLib".$separator;
935  print "PieceRef".$separator;
936  print "PieceDate".$separator;
937  print "EcritureLib".$separator;
938  print "Debit".$separator;
939  print "Credit".$separator;
940  print "EcritureLet".$separator;
941  print "DateLet".$separator;
942  print "ValidDate".$separator;
943  print "Montantdevise".$separator;
944  print "Idevise".$separator;
945  print "DateLimitReglmt".$separator;
946  print "NumFacture";
947  print $end_line;
948 
949  foreach ($objectLines as $line) {
950  if ($line->debit == 0 && $line->credit == 0) {
951  //unset($array[$line]);
952  } else {
953  $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
954  $date_document = dol_print_date($line->doc_date, '%Y%m%d');
955  $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
956  $date_validation = dol_print_date($line->date_validation, '%Y%m%d');
957  $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
958 
959  $refInvoice = '';
960  if ($line->doc_type == 'customer_invoice') {
961  // Customer invoice
962  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
963  $invoice = new Facture($this->db);
964  $invoice->fetch($line->fk_doc);
965 
966  $refInvoice = $invoice->ref;
967  } elseif ($line->doc_type == 'supplier_invoice') {
968  // Supplier invoice
969  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
970  $invoice = new FactureFournisseur($this->db);
971  $invoice->fetch($line->fk_doc);
972 
973  $refInvoice = $invoice->ref_supplier;
974  }
975 
976  // FEC:JournalCode
977  print $line->code_journal . $separator;
978 
979  // FEC:JournalLib
980  print dol_string_unaccent($langs->transnoentities($line->journal_label)) . $separator;
981 
982  // FEC:EcritureNum
983  print $line->piece_num . $separator;
984 
985  // FEC:EcritureDate
986  print $date_document . $separator;
987 
988  // FEC:CompteNum
989  print $line->numero_compte . $separator;
990 
991  // FEC:CompteLib
992  print dol_string_unaccent($line->label_compte) . $separator;
993 
994  // FEC:CompAuxNum
995  print $line->subledger_account . $separator;
996 
997  // FEC:CompAuxLib
998  print dol_string_unaccent($line->subledger_label) . $separator;
999 
1000  // FEC:PieceRef
1001  print $line->doc_ref . $separator;
1002 
1003  // FEC:PieceDate
1004  print dol_string_unaccent($date_creation) . $separator;
1005 
1006  // FEC:EcritureLib
1007  // Clean label operation to prevent problem on export with tab separator & other character
1008  $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
1009  print dol_string_unaccent($line->label_operation) . $separator;
1010 
1011  // FEC:Debit
1012  print price2fec($line->debit) . $separator;
1013 
1014  // FEC:Credit
1015  print price2fec($line->credit) . $separator;
1016 
1017  // FEC:EcritureLet
1018  print $line->lettering_code . $separator;
1019 
1020  // FEC:DateLet
1021  print $date_lettering . $separator;
1022 
1023  // FEC:ValidDate
1024  print $date_validation . $separator;
1025 
1026  // FEC:Montantdevise
1027  print $line->multicurrency_amount . $separator;
1028 
1029  // FEC:Idevise
1030  print $line->multicurrency_code . $separator;
1031 
1032  // FEC_suppl:DateLimitReglmt
1033  print $date_limit_payment . $separator;
1034 
1035  // FEC_suppl:NumFacture
1036  // Clean ref invoice to prevent problem on export with tab separator & other character
1037  $refInvoice = str_replace(array("\t", "\n", "\r"), " ", $refInvoice);
1038  print dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1);
1039 
1040  print $end_line;
1041  }
1042  }
1043  }
1044 
1051  public function exportFEC2($objectLines)
1052  {
1053  global $langs;
1054 
1055  $separator = "\t";
1056  $end_line = "\r\n";
1057 
1058  print "JournalCode".$separator;
1059  print "JournalLib".$separator;
1060  print "EcritureNum".$separator;
1061  print "EcritureDate".$separator;
1062  print "CompteNum".$separator;
1063  print "CompteLib".$separator;
1064  print "CompAuxNum".$separator;
1065  print "CompAuxLib".$separator;
1066  print "PieceRef".$separator;
1067  print "PieceDate".$separator;
1068  print "EcritureLib".$separator;
1069  print "Debit".$separator;
1070  print "Credit".$separator;
1071  print "EcritureLet".$separator;
1072  print "DateLet".$separator;
1073  print "ValidDate".$separator;
1074  print "Montantdevise".$separator;
1075  print "Idevise".$separator;
1076  print "DateLimitReglmt".$separator;
1077  print "NumFacture";
1078  print $end_line;
1079 
1080  foreach ($objectLines as $line) {
1081  if ($line->debit == 0 && $line->credit == 0) {
1082  //unset($array[$line]);
1083  } else {
1084  $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
1085  $date_document = dol_print_date($line->doc_date, '%Y%m%d');
1086  $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
1087  $date_validation = dol_print_date($line->date_validation, '%Y%m%d');
1088  $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
1089 
1090  $refInvoice = '';
1091  if ($line->doc_type == 'customer_invoice') {
1092  // Customer invoice
1093  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1094  $invoice = new Facture($this->db);
1095  $invoice->fetch($line->fk_doc);
1096 
1097  $refInvoice = $invoice->ref;
1098  } elseif ($line->doc_type == 'supplier_invoice') {
1099  // Supplier invoice
1100  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1101  $invoice = new FactureFournisseur($this->db);
1102  $invoice->fetch($line->fk_doc);
1103 
1104  $refInvoice = $invoice->ref_supplier;
1105  }
1106 
1107  // FEC:JournalCode
1108  print $line->code_journal . $separator;
1109 
1110  // FEC:JournalLib
1111  print dol_string_unaccent($langs->transnoentities($line->journal_label)) . $separator;
1112 
1113  // FEC:EcritureNum
1114  print $line->piece_num . $separator;
1115 
1116  // FEC:EcritureDate
1117  print $date_creation . $separator;
1118 
1119  // FEC:CompteNum
1120  print length_accountg($line->numero_compte) . $separator;
1121 
1122  // FEC:CompteLib
1123  print dol_string_unaccent($line->label_compte) . $separator;
1124 
1125  // FEC:CompAuxNum
1126  print length_accounta($line->subledger_account) . $separator;
1127 
1128  // FEC:CompAuxLib
1129  print dol_string_unaccent($line->subledger_label) . $separator;
1130 
1131  // FEC:PieceRef
1132  print $line->doc_ref . $separator;
1133 
1134  // FEC:PieceDate
1135  print $date_document . $separator;
1136 
1137  // FEC:EcritureLib
1138  // Clean label operation to prevent problem on export with tab separator & other character
1139  $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
1140  print dol_string_unaccent($line->label_operation) . $separator;
1141 
1142  // FEC:Debit
1143  print price2fec($line->debit) . $separator;
1144 
1145  // FEC:Credit
1146  print price2fec($line->credit) . $separator;
1147 
1148  // FEC:EcritureLet
1149  print $line->lettering_code . $separator;
1150 
1151  // FEC:DateLet
1152  print $date_lettering . $separator;
1153 
1154  // FEC:ValidDate
1155  print $date_validation . $separator;
1156 
1157  // FEC:Montantdevise
1158  print $line->multicurrency_amount . $separator;
1159 
1160  // FEC:Idevise
1161  print $line->multicurrency_code . $separator;
1162 
1163  // FEC_suppl:DateLimitReglmt
1164  print $date_limit_payment . $separator;
1165 
1166  // FEC_suppl:NumFacture
1167  // Clean ref invoice to prevent problem on export with tab separator & other character
1168  $refInvoice = str_replace(array("\t", "\n", "\r"), " ", $refInvoice);
1169  print dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1);
1170 
1171 
1172  print $end_line;
1173  }
1174  }
1175  }
1176 
1187  public function exportSAGE50SWISS($objectLines)
1188  {
1189  // SAGE50SWISS
1190  $this->separator = ',';
1191  $this->end_line = "\r\n";
1192 
1193  // Print header line
1194  print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag";
1195  print $this->end_line;
1196  $thisPieceNum = "";
1197  $thisPieceAccountNr = "";
1198  $aSize = count($objectLines);
1199  foreach ($objectLines as $aIndex => $line) {
1200  $sammelBuchung = false;
1201  if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) {
1202  $sammelBuchung = true;
1203  } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) {
1204  $sammelBuchung = true;
1205  } elseif ($aIndex + 1 < $aSize
1206  && $objectLines[$aIndex + 1]->piece_num == $line->piece_num
1207  && $aIndex - 1 < $aSize
1208  && $objectLines[$aIndex - 1]->piece_num == $line->piece_num
1209  ) {
1210  $sammelBuchung = true;
1211  }
1212 
1213  //Blg
1214  print $line->piece_num.$this->separator;
1215 
1216  // Datum
1217  $date = dol_print_date($line->doc_date, '%d.%m.%Y');
1218  print $date.$this->separator;
1219 
1220  // Kto
1221  print length_accountg($line->numero_compte).$this->separator;
1222  // S/H
1223  if ($line->sens == 'D') {
1224  print 'S'.$this->separator;
1225  } else {
1226  print 'H'.$this->separator;
1227  }
1228  //Grp
1229  print self::trunc($line->code_journal, 1).$this->separator;
1230  // GKto
1231  if (empty($line->code_tiers)) {
1232  if ($line->piece_num == $thisPieceNum) {
1233  print length_accounta($thisPieceAccountNr).$this->separator;
1234  } else {
1235  print "div".$this->separator;
1236  }
1237  } else {
1238  print length_accounta($line->code_tiers).$this->separator;
1239  }
1240  //SId
1241  print $this->separator;
1242  //SIdx
1243  print "0".$this->separator;
1244  //KIdx
1245  print "0".$this->separator;
1246  //BTyp
1247  print "0".$this->separator;
1248 
1249  //MTyp 1=Fibu Einzelbuchung 2=Sammebuchung
1250  if ($sammelBuchung) {
1251  print "2".$this->separator;
1252  } else {
1253  print "1".$this->separator;
1254  }
1255  // Code
1256  print '""'.$this->separator;
1257  // Netto
1258  print abs($line->debit - $line->credit).$this->separator;
1259  // Steuer
1260  print "0.00".$this->separator;
1261  // FW-Betrag
1262  print "0.00".$this->separator;
1263  // Tx1
1264  $line1 = self::toAnsi($line->label_compte, 29);
1265  if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) {
1266  $line1 = "";
1267  }
1268  $line2 = self::toAnsi($line->doc_ref, 29);
1269  if (strlen($line1) == 0) {
1270  $line1 = $line2;
1271  $line2 = "";
1272  }
1273  if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) {
1274  $line1 = $line1.' / '.$line2;
1275  $line2 = "";
1276  }
1277 
1278  print '"'.self::toAnsi($line1).'"'.$this->separator;
1279  // Tx2
1280  print '"'.self::toAnsi($line2).'"'.$this->separator;
1281  //PkKey
1282  print "0".$this->separator;
1283  //OpId
1284  print $this->separator;
1285 
1286  // Flag
1287  print "0";
1288 
1289  print $this->end_line;
1290 
1291  if ($line->piece_num !== $thisPieceNum) {
1292  $thisPieceNum = $line->piece_num;
1293  $thisPieceAccountNr = $line->numero_compte;
1294  }
1295  }
1296  }
1297 
1306  public function exportLDCompta($objectLines)
1307  {
1308 
1309  $separator = ';';
1310  $end_line = "\r\n";
1311 
1312  foreach ($objectLines as $line) {
1313  $date_document = dol_print_date($line->doc_date, '%Y%m%d');
1314  $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
1315  $date_lim_reglement = dol_print_date($line->date_lim_reglement, '%Y%m%d');
1316 
1317  // TYPE
1318  $type_enregistrement = 'E'; // For write movement
1319  print $type_enregistrement.$separator;
1320  // JNAL
1321  print substr($line->code_journal, 0, 2).$separator;
1322  // NECR
1323  print $line->id.$separator;
1324  // NPIE
1325  print $line->piece_num.$separator;
1326  // DATP
1327  print $date_document.$separator;
1328  // LIBE
1329  print $line->label_operation.$separator;
1330  // DATH
1331  print $date_lim_reglement.$separator;
1332  // CNPI
1333  if ($line->doc_type == 'supplier_invoice') {
1334  if (($line->debit - $line->credit) > 0) {
1335  $nature_piece = 'AF';
1336  } else {
1337  $nature_piece = 'FF';
1338  }
1339  } elseif ($line->doc_type == 'customer_invoice') {
1340  if (($line->debit - $line->credit) < 0) {
1341  $nature_piece = 'AC';
1342  } else {
1343  $nature_piece = 'FC';
1344  }
1345  } else {
1346  $nature_piece = '';
1347  }
1348  print $nature_piece.$separator;
1349  // RACI
1350  // if (! empty($line->subledger_account)) {
1351  // if ($line->doc_type == 'supplier_invoice') {
1352  // $racine_subledger_account = '40';
1353  // } elseif ($line->doc_type == 'customer_invoice') {
1354  // $racine_subledger_account = '41';
1355  // } else {
1356  // $racine_subledger_account = '';
1357  // }
1358  // } else {
1359  $racine_subledger_account = ''; // for records of type E leave this field blank
1360  // }
1361 
1362  print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead
1363  // MONT
1364  print price(abs($line->debit - $line->credit), 0, '', 1, 2, 2).$separator;
1365  // CODC
1366  print $line->sens.$separator;
1367  // CPTG
1368  print length_accountg($line->numero_compte).$separator;
1369  // DATE
1370  print $date_creation.$separator;
1371  // CLET
1372  print $line->lettering_code.$separator;
1373  // DATL
1374  print $line->date_lettering.$separator;
1375  // CPTA
1376  if (!empty($line->subledger_account)) {
1377  print length_accounta($line->subledger_account).$separator;
1378  } else {
1379  print $separator;
1380  }
1381  // CNAT
1382  if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) {
1383  print 'F'.$separator;
1384  } elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) {
1385  print 'C'.$separator;
1386  } else {
1387  print $separator;
1388  }
1389  // SECT
1390  print $separator;
1391  // CTRE
1392  print $separator;
1393  // NORL
1394  print $separator;
1395  // DATV
1396  print $separator;
1397  // REFD
1398  print $line->doc_ref.$separator;
1399  // CODH
1400  print $separator;
1401  // NSEQ
1402  print $separator;
1403  // MTDV
1404  print '0'.$separator;
1405  // CODV
1406  print $separator;
1407  // TXDV
1408  print '0'.$separator;
1409  // MOPM
1410  print $separator;
1411  // BONP
1412  print $separator;
1413  // BQAF
1414  print $separator;
1415  // ECES
1416  print $separator;
1417  // TXTL
1418  print $separator;
1419  // ECRM
1420  print $separator;
1421  // DATK
1422  print $separator;
1423  // HEUK
1424  print $separator;
1425 
1426  print $end_line;
1427  }
1428  }
1429 
1440  public function exportLDCompta10($objectLines)
1441  {
1442  require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
1443 
1444  $separator = ';';
1445  $end_line = "\r\n";
1446  $last_codeinvoice = '';
1447 
1448  foreach ($objectLines as $line) {
1449  // TYPE C
1450  if ($last_codeinvoice != $line->doc_ref) {
1451  //recherche societe en fonction de son code client
1452  $sql = "SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX."societe";
1453  $sql .= " WHERE code_client = '".$this->db->escape($line->thirdparty_code)."'";
1454  $resql = $this->db->query($sql);
1455 
1456  if ($resql && $this->db->num_rows($resql) > 0) {
1457  $soc = $this->db->fetch_object($resql);
1458 
1459  $address = array('', '', '');
1460  if (strpos($soc->address, "\n") !== false) {
1461  $address = explode("\n", $soc->address);
1462  if (is_array($address) && count($address) > 0) {
1463  foreach ($address as $key => $data) {
1464  $address[$key] = str_replace(array("\t", "\n", "\r"), "", $data);
1465  $address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1);
1466  }
1467  }
1468  } else {
1469  $address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40);
1470  $address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40);
1471  $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40);
1472  }
1473 
1474  $type_enregistrement = 'C';
1475  //TYPE
1476  print $type_enregistrement.$separator;
1477  //NOCL
1478  print $soc->code_client.$separator;
1479  //NMCM
1480  print $separator;
1481  //LIBI
1482  print $separator;
1483  //TITR
1484  print $separator;
1485  //RSSO
1486  print $soc->nom.$separator;
1487  //CAD1
1488  print $address[0].$separator;
1489  //CAD2
1490  print $address[1].$separator;
1491  //CAD3
1492  print $address[2].$separator;
1493  //COPO
1494  print $soc->zip.$separator;
1495  //BUDI
1496  print substr($soc->town, 0, 40).$separator;
1497  //CPAY
1498  print $separator;
1499  //PAYS
1500  print substr(getCountry($soc->fk_pays), 0, 40).$separator;
1501  //NTEL
1502  print $soc->phone.$separator;
1503  //TLEX
1504  print $separator;
1505  //TLPO
1506  print $separator;
1507  //TLCY
1508  print $separator;
1509  //NINT
1510  print $separator;
1511  //COMM
1512  print $separator;
1513  //SIRE
1514  print str_replace(" ", "", $soc->siret).$separator;
1515  //RIBP
1516  print $separator;
1517  //DOBQ
1518  print $separator;
1519  //IBBQ
1520  print $separator;
1521  //COBQ
1522  print $separator;
1523  //GUBQ
1524  print $separator;
1525  //CPBQ
1526  print $separator;
1527  //CLBQ
1528  print $separator;
1529  //BIBQ
1530  print $separator;
1531  //MOPM
1532  print $separator;
1533  //DJPM
1534  print $separator;
1535  //DMPM
1536  print $separator;
1537  //REFM
1538  print $separator;
1539  //SLVA
1540  print $separator;
1541  //PLCR
1542  print $separator;
1543  //ECFI
1544  print $separator;
1545  //CREP
1546  print $separator;
1547  //NREP
1548  print $separator;
1549  //TREP
1550  print $separator;
1551  //MREP
1552  print $separator;
1553  //GRRE
1554  print $separator;
1555  //LTTA
1556  print $separator;
1557  //CACT
1558  print $separator;
1559  //CODV
1560  print $separator;
1561  //GRTR
1562  print $separator;
1563  //NOFP
1564  print $separator;
1565  //BQAF
1566  print $separator;
1567  //BONP
1568  print $separator;
1569  //CESC
1570  print $separator;
1571 
1572  print $end_line;
1573  }
1574  }
1575 
1576  $date_document = dol_print_date($line->doc_date, '%Y%m%d');
1577  $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
1578  $date_lim_reglement = dol_print_date($line->date_lim_reglement, '%Y%m%d');
1579 
1580  // TYPE E
1581  $type_enregistrement = 'E'; // For write movement
1582  print $type_enregistrement.$separator;
1583  // JNAL
1584  print substr($line->code_journal, 0, 2).$separator;
1585  // NECR
1586  print $line->id.$separator;
1587  // NPIE
1588  print $line->piece_num.$separator;
1589  // DATP
1590  print $date_document.$separator;
1591  // LIBE
1592  print dol_trunc($line->label_operation, 25, 'right', 'UTF-8', 1).$separator;
1593  // DATH
1594  print $date_lim_reglement.$separator;
1595  // CNPI
1596  if ($line->doc_type == 'supplier_invoice') {
1597  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.
1598  $nature_piece = 'AF';
1599  } else {
1600  $nature_piece = 'FF';
1601  }
1602  } elseif ($line->doc_type == 'customer_invoice') {
1603  if (($line->amount) < 0) {
1604  $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.
1605  } else {
1606  $nature_piece = 'FC';
1607  }
1608  } else {
1609  $nature_piece = '';
1610  }
1611  print $nature_piece.$separator;
1612  // RACI
1613  // if (! empty($line->subledger_account)) {
1614  // if ($line->doc_type == 'supplier_invoice') {
1615  // $racine_subledger_account = '40';
1616  // } elseif ($line->doc_type == 'customer_invoice') {
1617  // $racine_subledger_account = '41';
1618  // } else {
1619  // $racine_subledger_account = '';
1620  // }
1621  // } else {
1622  $racine_subledger_account = ''; // for records of type E leave this field blank
1623  // }
1624 
1625  print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead
1626  // MONT
1627  print price(abs($line->debit - $line->credit), 0, '', 1, 2).$separator;
1628  // CODC
1629  print $line->sens.$separator;
1630  // CPTG
1631  print length_accountg($line->numero_compte).$separator;
1632  // DATE
1633  print $date_document.$separator;
1634  // CLET
1635  print $line->lettering_code.$separator;
1636  // DATL
1637  print $line->date_lettering.$separator;
1638  // CPTA
1639  if (!empty($line->subledger_account)) {
1640  print length_accounta($line->subledger_account).$separator;
1641  } else {
1642  print $separator;
1643  }
1644  // CNAT
1645  if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) {
1646  print 'F'.$separator;
1647  } elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) {
1648  print 'C'.$separator;
1649  } else {
1650  print $separator;
1651  }
1652  // CTRE
1653  print $separator;
1654  // NORL
1655  print $separator;
1656  // DATV
1657  print $separator;
1658  // REFD
1659  print $line->doc_ref.$separator;
1660  // NECA
1661  print '0'.$separator;
1662  // CSEC
1663  print $separator;
1664  // CAFF
1665  print $separator;
1666  // CDES
1667  print $separator;
1668  // QTUE
1669  print $separator;
1670  // MTDV
1671  print '0'.$separator;
1672  // CODV
1673  print $separator;
1674  // TXDV
1675  print '0'.$separator;
1676  // MOPM
1677  print $separator;
1678  // BONP
1679  print $separator;
1680  // BQAF
1681  print $separator;
1682  // ECES
1683  print $separator;
1684  // TXTL
1685  print $separator;
1686  // ECRM
1687  print $separator;
1688  // DATK
1689  print $separator;
1690  // HEUK
1691  print $separator;
1692 
1693  print $end_line;
1694 
1695  $last_codeinvoice = $line->doc_ref;
1696  }
1697  }
1698 
1705  public function exportCharlemagne($objectLines)
1706  {
1707  global $langs;
1708  $langs->load('compta');
1709 
1710  $separator = "\t";
1711  $end_line = "\n";
1712 
1713  /*
1714  * Charlemagne export need header
1715  */
1716  print $langs->transnoentitiesnoconv('Date').$separator;
1717  print self::trunc($langs->transnoentitiesnoconv('Journal'), 6).$separator;
1718  print self::trunc($langs->transnoentitiesnoconv('Account'), 15).$separator;
1719  print self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60).$separator;
1720  print self::trunc($langs->transnoentitiesnoconv('Piece'), 20).$separator;
1721  print self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60).$separator;
1722  print $langs->transnoentitiesnoconv('Amount').$separator;
1723  print 'S'.$separator;
1724  print self::trunc($langs->transnoentitiesnoconv('Analytic').' 1', 15).$separator;
1725  print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 1', 60).$separator;
1726  print self::trunc($langs->transnoentitiesnoconv('Analytic').' 2', 15).$separator;
1727  print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 2', 60).$separator;
1728  print self::trunc($langs->transnoentitiesnoconv('Analytic').' 3', 15).$separator;
1729  print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 3', 60).$separator;
1730  print $end_line;
1731 
1732  foreach ($objectLines as $line) {
1733  $date = dol_print_date($line->doc_date, '%Y%m%d');
1734  print $date.$separator; //Date
1735 
1736  print self::trunc($line->code_journal, 6).$separator; //Journal code
1737 
1738  if (!empty($line->subledger_account)) {
1739  $account = $line->subledger_account;
1740  } else {
1741  $account = $line->numero_compte;
1742  }
1743  print self::trunc($account, 15).$separator; //Account number
1744 
1745  print self::trunc($line->label_compte, 60).$separator; //Account label
1746  print self::trunc($line->doc_ref, 20).$separator; //Piece
1747  // Clean label operation to prevent problem on export with tab separator & other character
1748  $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
1749  print self::trunc($line->label_operation, 60).$separator; //Operation label
1750  print price(abs($line->debit - $line->credit)).$separator; //Amount
1751  print $line->sens.$separator; //Direction
1752  print $separator; //Analytic
1753  print $separator; //Analytic
1754  print $separator; //Analytic
1755  print $separator; //Analytic
1756  print $separator; //Analytic
1757  print $separator; //Analytic
1758  print $end_line;
1759  }
1760  }
1761 
1769  public function exportGestimumV3($objectLines)
1770  {
1771  global $langs;
1772 
1773  $this->separator = ',';
1774 
1775  $invoices_infos = array();
1776  $supplier_invoices_infos = array();
1777  foreach ($objectLines as $line) {
1778  if ($line->debit == 0 && $line->credit == 0) {
1779  //unset($array[$line]);
1780  } else {
1781  $date = dol_print_date($line->doc_date, '%d/%m/%Y');
1782 
1783  $invoice_ref = $line->doc_ref;
1784  $company_name = "";
1785 
1786  if (($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice') && $line->fk_doc > 0) {
1787  if (($line->doc_type == 'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) ||
1788  ($line->doc_type == 'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) {
1789  if ($line->doc_type == 'customer_invoice') {
1790  // Get new customer invoice ref and company name
1791  $sql = 'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f';
1792  $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid';
1793  $sql .= ' WHERE f.rowid = '.((int) $line->fk_doc);
1794  $resql = $this->db->query($sql);
1795  if ($resql) {
1796  if ($obj = $this->db->fetch_object($resql)) {
1797  // Save invoice infos
1798  $invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom);
1799  $invoice_ref = $obj->ref;
1800  $company_name = $obj->nom;
1801  }
1802  }
1803  } else {
1804  // Get new supplier invoice ref and company name
1805  $sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff';
1806  $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid';
1807  $sql .= ' WHERE ff.rowid = '.((int) $line->fk_doc);
1808  $resql = $this->db->query($sql);
1809  if ($resql) {
1810  if ($obj = $this->db->fetch_object($resql)) {
1811  // Save invoice infos
1812  $supplier_invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom);
1813  $invoice_ref = $obj->ref;
1814  $company_name = $obj->nom;
1815  }
1816  }
1817  }
1818  } elseif ($line->doc_type == 'customer_invoice') {
1819  // Retrieve invoice infos
1820  $invoice_ref = $invoices_infos[$line->fk_doc]['ref'];
1821  $company_name = $invoices_infos[$line->fk_doc]['company_name'];
1822  } else {
1823  // Retrieve invoice infos
1824  $invoice_ref = $supplier_invoices_infos[$line->fk_doc]['ref'];
1825  $company_name = $supplier_invoices_infos[$line->fk_doc]['company_name'];
1826  }
1827  }
1828 
1829  print $line->id . $this->separator;
1830  print $date . $this->separator;
1831  print substr($line->code_journal, 0, 4) . $this->separator;
1832 
1833  if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) {
1834  print length_accountg($line->subledger_account) . $this->separator;
1835  } else {
1836  print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator;
1837  }
1838  //Libellé Auto
1839  print $this->separator;
1840  //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator;
1841  //Libellé manuel
1842  print dol_trunc(str_replace('"', '', $invoice_ref . (!empty($company_name) ? ' - ' : '') . $company_name), 40, 'right', 'UTF-8', 1) . $this->separator;
1843  //Numéro de pièce
1844  print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator;
1845  //Devise
1846  print 'EUR' . $this->separator;
1847  //Amount
1848  print price2num(abs($line->debit - $line->credit)) . $this->separator;
1849  //Sens
1850  print $line->sens . $this->separator;
1851  //Code lettrage
1852  print $this->separator;
1853  //Date Echéance
1854  print $date;
1855  print $this->end_line;
1856  }
1857  }
1858  }
1859 
1867  public function exportGestimumV5($objectLines)
1868  {
1869 
1870  $this->separator = ',';
1871 
1872  foreach ($objectLines as $line) {
1873  if ($line->debit == 0 && $line->credit == 0) {
1874  //unset($array[$line]);
1875  } else {
1876  $date = dol_print_date($line->doc_date, '%d%m%Y');
1877 
1878  print $line->id . $this->separator;
1879  print $date . $this->separator;
1880  print substr($line->code_journal, 0, 4) . $this->separator;
1881  if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { // TODO No hard code value
1882  print length_accountg($line->subledger_account) . $this->separator;
1883  } else {
1884  print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator;
1885  }
1886  print $this->separator;
1887  //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator;
1888  print '"' . dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1) . '"' . $this->separator;
1889  print '"' . dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . '"' . $this->separator;
1890  print price2num(abs($line->debit - $line->credit)) . $this->separator;
1891  print $line->sens . $this->separator;
1892  print $date . $this->separator;
1893  print $this->separator;
1894  print $this->separator;
1895  print 'EUR';
1896  print $this->end_line;
1897  }
1898  }
1899  }
1900 
1910  public function exportiSuiteExpert($objectLines)
1911  {
1912  $this->separator = ';';
1913  $this->end_line = "\r\n";
1914 
1915 
1916  foreach ($objectLines as $line) {
1917  $tab = array();
1918 
1919  $date = dol_print_date($line->doc_date, '%d/%m/%Y');
1920 
1921  $tab[] = $line->piece_num;
1922  $tab[] = $date;
1923  $tab[] = substr($date, 6, 4);
1924  $tab[] = substr($date, 3, 2);
1925  $tab[] = substr($date, 0, 2);
1926  $tab[] = $line->doc_ref;
1927  //Conversion de chaine UTF8 en Latin9
1928  $tab[] = mb_convert_encoding(str_replace(' - Compte auxiliaire', '', $line->label_operation), "Windows-1252", 'UTF-8');
1929 
1930  //Calcul de la longueur des numéros de comptes
1931  $taille_numero = strlen(length_accountg($line->numero_compte));
1932 
1933  //Création du numéro de client générique
1934  $numero_cpt_client = '411';
1935  for ($i = 1; $i <= ($taille_numero - 3); $i++) {
1936  $numero_cpt_client .= '0';
1937  }
1938 
1939  //Création des comptes auxiliaire des clients
1940  if (length_accountg($line->numero_compte) == $numero_cpt_client) {
1941  $tab[] = rtrim(length_accounta($line->subledger_account), "0");
1942  } else {
1943  $tab[] = length_accountg($line->numero_compte);
1944  }
1945  $nom_client = explode(" - ", $line->label_operation);
1946  $tab[] = mb_convert_encoding($nom_client[0], "Windows-1252", 'UTF-8');
1947  $tab[] = price($line->debit);
1948  $tab[] = price($line->credit);
1949  $tab[] = price($line->montant);
1950  $tab[] = $line->code_journal;
1951 
1952  $separator = $this->separator;
1953  print implode($separator, $tab) . $this->end_line;
1954  }
1955  }
1956 
1964  public static function trunc($str, $size)
1965  {
1966  return dol_trunc($str, $size, 'right', 'UTF-8', 1);
1967  }
1968 
1976  public static function toAnsi($str, $size = -1)
1977  {
1978  $retVal = dol_string_nohtmltag($str, 1, 'Windows-1251');
1979  if ($retVal >= 0 && $size >= 0) {
1980  $retVal = mb_substr($retVal, 0, $size, 'Windows-1251');
1981  }
1982  return $retVal;
1983  }
1984 }
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
static getFormatCode($type)
Return string to summarize the format (Used to generated export filename)
exportiSuiteExpert($objectLines)
Export format : iSuite Expert.
$conf db
API class for accounts.
Definition: inc.php:41
exportCharlemagne($objectLines)
Export format : Charlemagne.
exportGestimumV3($objectLines)
Export format : Gestimum V3.
Class to manage Dolibarr database access.
static trunc($str, $size)
trunc
export(&$TData, $formatexportset)
Function who chose which export to use with the default config, and make the export into a file...
getTypeConfig()
Array with all export type available (key + label) and parameters for config.
exportLDCompta($objectLines)
Export format : LD Compta version 9 http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Docu...
price2fec($amount)
Function to format a value into a defined format for French administration (no thousand separator &amp; d...
exportCoala($objectLines)
Export format : COALA.
Class to manage suppliers invoices.
exportBob50($objectLines)
Export format : BOB50.
exportFEC2($objectLines)
Export format : FEC2.
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...
exportOpenConcerto($objectLines)
Export format : OpenConcerto.
exportCogilog($objectLines)
Export format : COGILOG.
getType()
Array with all export type available (key + label)
__construct(DoliDB $db)
Constructor.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
exportQuadratus(&$TData)
Export format : Quadratus (Format ASCII) Format since 2015 compatible QuadraCOMPTA Last review for th...
exportGestimumV5($objectLines)
Export format : Gestimum V5.
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
exportAgiris($objectLines)
Export format : Agiris Isacompta.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
exportCegid($objectLines)
Export format : CEGID.
exportWinfic(&$TData)
Export format : WinFic - eWinfic - WinSis Compta.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
exportConfigurable($objectLines)
Export format : Configurable CSV.
exportFEC($objectLines)
Export format : FEC.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Manage the different format accountancy export.
static toAnsi($str, $size=-1)
toAnsi
exportLDCompta10($objectLines)
Export format : LD Compta version 10 &amp; higher Last review for this format : 08-15-2021 Alexandre Span...
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding &#39;…&#39; if string larger than length. ...
exportCiel(&$TData)
Export format : CIEL (Format XIMPORT) Format since 2003 compatible CIEL version &gt; 2002 / Sage50 Last ...
Class to manage invoices.
exportEbp($objectLines)
Export format : EBP.
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous) ...
exportSAGE50SWISS($objectLines)
Export format : SAGE50SWISS.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.