dolibarr  16.0.5
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-2023 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  // Clean some data
579  $data->doc_ref = dol_string_unaccent($data->doc_ref);
580  $data->label_operation = dol_string_unaccent($data->label_operation);
581  $data->numero_compte = dol_string_unaccent($data->numero_compte);
582  $data->label_compte = dol_string_unaccent($data->label_compte);
583  $data->subledger_account = dol_string_unaccent($data->subledger_account);
584  $data->subledger_label = dol_string_unaccent($data->subledger_label);
585 
586  $code_compta = $data->numero_compte;
587  if (!empty($data->subledger_account)) {
588  $code_compta = $data->subledger_account;
589  }
590 
591  $Tab = array();
592 
593  if (!empty($data->subledger_account)) {
594  $Tab['type_ligne'] = 'C';
595  $Tab['num_compte'] = str_pad(self::trunc($data->subledger_account, 8), 8);
596  $Tab['lib_compte'] = str_pad(self::trunc($data->subledger_label, 30), 30);
597 
598  if ($data->doc_type == 'customer_invoice') {
599  $Tab['lib_alpha'] = strtoupper(str_pad('C'.self::trunc($data->subledger_label, 6), 6));
600  $Tab['filler'] = str_repeat(' ', 52);
601  $Tab['coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, 8), 8);
602  } elseif ($data->doc_type == 'supplier_invoice') {
603  $Tab['lib_alpha'] = strtoupper(str_pad('F'.self::trunc($data->subledger_label, 6), 6));
604  $Tab['filler'] = str_repeat(' ', 52);
605  $Tab['coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, 8), 8);
606  } else {
607  $Tab['filler'] = str_repeat(' ', 59);
608  $Tab['coll_compte'] = str_pad(' ', 8);
609  }
610 
611  $Tab['filler2'] = str_repeat(' ', 110);
612  $Tab['Maj'] = 2; // Partial update (alpha key, label, address, collectif, RIB)
613 
614  if ($data->doc_type == 'customer_invoice') {
615  $Tab['type_compte'] = 'C';
616  } elseif ($data->doc_type == 'supplier_invoice') {
617  $Tab['type_compte'] = 'F';
618  } else {
619  $Tab['type_compte'] = 'G';
620  }
621 
622  $Tab['filler3'] = str_repeat(' ', 235);
623 
624  $Tab['end_line'] = $end_line;
625 
626  print implode($Tab);
627  }
628 
629  $Tab = array();
630  $Tab['type_ligne'] = 'M';
631  $Tab['num_compte'] = str_pad(self::trunc($code_compta, 8), 8);
632  $Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
633  $Tab['folio'] = '000';
634 
635  // We use invoice date $data->doc_date not $date_ecriture which is the transfert date
636  // maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ?
637  //$Tab['date_ecriture'] = $date_ecriture;
638  $Tab['date_ecriture'] = dol_print_date($data->doc_date, '%d%m%y');
639  $Tab['filler'] = ' ';
640  $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref.' '.$data->label_operation, 20), 20);
641 
642  // Credit invoice - invert sens
643  /*
644  if ($data->montant < 0) {
645  if ($data->sens == 'C') {
646  $Tab['sens'] = 'D';
647  } else {
648  $Tab['sens'] = 'C';
649  }
650  $Tab['signe_montant'] = '-';
651  } else {
652  $Tab['sens'] = $data->sens; // C or D
653  $Tab['signe_montant'] = '+';
654  }*/
655  $Tab['sens'] = $data->sens; // C or D
656  $Tab['signe_montant'] = '+';
657 
658  // The amount must be in centimes without decimal points.
659  $Tab['montant'] = str_pad(abs(($data->debit - $data->credit) * 100), 12, '0', STR_PAD_LEFT);
660  $Tab['contrepartie'] = str_repeat(' ', 8);
661 
662  // Force date format : %d%m%y
663  if (!empty($data->date_lim_reglement)) {
664  //$Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, $conf->global->ACCOUNTING_EXPORT_DATE);
665  $Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, '%d%m%y'); // Format must be ddmmyy
666  } else {
667  $Tab['date_echeance'] = '000000';
668  }
669 
670  // Please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5)
671  // $Tab['lettrage'] = str_repeat(' ', 5);
672  $Tab['lettrage'] = str_repeat(' ', 2);
673  $Tab['codestat'] = str_repeat(' ', 3);
674  $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5);
675 
676  // Keep correct quadra named field instead of anon filler
677  // $Tab['filler2'] = str_repeat(' ', 20);
678  $Tab['affaire'] = str_repeat(' ', 10);
679  $Tab['quantity1'] = str_repeat(' ', 10);
680  $Tab['num_piece2'] = str_pad(self::trunc($data->piece_num, 8), 8);
681  $Tab['devis'] = str_pad($conf->currency, 3);
682  $Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3);
683  $Tab['filler3'] = str_repeat(' ', 3);
684 
685  // Keep correct quadra named field instead of anon filler libelle_ecriture2 is 30 char not 32 !!!!
686  // 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
687  // TODO: we should filter more than only accent to avoid wrong line size
688  // TODO: remove invoice number doc_ref in libelle,
689  // TODO: we should offer an option for customer to build the libelle using invoice number / name / date in accounting software
690  //$Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_operation, 30), 30);
691  $Tab['libelle_ecriture2'] = str_pad(self::trunc($data->label_operation, 30), 30);
692  $Tab['codetva'] = str_repeat(' ', 2);
693 
694  // We need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part
695  // $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10);
696  $Tab['num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10);
697  $Tab['filler4'] = str_repeat(' ', 73);
698 
699  $Tab['end_line'] = $end_line;
700 
701  print implode($Tab);
702  }
703  }
704 
715  public function exportWinfic(&$TData)
716  {
717  global $conf;
718 
719  $end_line = "\r\n";
720  $index = 1;
721 
722  //We should use dol_now function not time however this is wrong date to transfert in accounting
723  //$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
724  //$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
725 
726  // Warning ! When truncation is necessary, no dot because 3 dots = three characters. The columns are shifted
727 
728  foreach ($TData as $data) {
729  $code_compta = $data->numero_compte;
730  if (!empty($data->subledger_account)) {
731  $code_compta = $data->subledger_account;
732  }
733 
734  $Tab = array();
735  //$Tab['type_ligne'] = 'M';
736  $Tab['code_journal'] = str_pad(dol_trunc($data->code_journal, 2, 'right', 'UTF-8', 1), 2);
737 
738  //We use invoice date $data->doc_date not $date_ecriture which is the transfert date
739  //maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ?
740  //$Tab['date_ecriture'] = $date_ecriture;
741  $Tab['date_operation'] = dol_print_date($data->doc_date, '%d%m%Y');
742 
743  $Tab['folio'] = ' 1';
744 
745  $Tab['num_ecriture'] = str_pad(dol_trunc($index, 6, 'right', 'UTF-8', 1), 6, ' ', STR_PAD_LEFT);
746 
747  $Tab['jour_ecriture'] = dol_print_date($data->doc_date, '%d%m%y');
748 
749  $Tab['num_compte'] = str_pad(dol_trunc($code_compta, 6, 'right', 'UTF-8', 1), 6, '0');
750 
751  if ($data->sens == 'D') {
752  $Tab['montant_debit'] = str_pad(number_format($data->debit, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
753 
754  $Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
755  } else {
756  $Tab['montant_debit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
757 
758  $Tab['montant_crebit'] = str_pad(number_format($data->credit, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
759  }
760 
761  $Tab['libelle_ecriture'] = str_pad(dol_trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 30, 'right', 'UTF-8', 1), 30);
762 
763  $Tab['lettrage'] = str_repeat(dol_trunc($data->lettering_code, 2, 'left', 'UTF-8', 1), 2);
764 
765  $Tab['code_piece'] = str_pad(dol_trunc($data->piece_num, 5, 'left', 'UTF-8', 1), 5, ' ', STR_PAD_LEFT);
766 
767  $Tab['code_stat'] = str_repeat(' ', 4);
768 
769  if (!empty($data->date_lim_reglement)) {
770  //$Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, $conf->global->ACCOUNTING_EXPORT_DATE);
771  $Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, '%d%m%Y');
772  } else {
773  $Tab['date_echeance'] = dol_print_date($data->doc_date, '%d%m%Y');
774  }
775 
776  $Tab['monnaie'] = '1';
777 
778  $Tab['filler'] = ' ';
779 
780  $Tab['ind_compteur'] = ' ';
781 
782  $Tab['quantite'] = '0,000000000';
783 
784  $Tab['code_pointage'] = str_repeat(' ', 2);
785 
786  $Tab['end_line'] = $end_line;
787 
788  print implode('|', $Tab);
789 
790  $index++;
791  }
792  }
793 
794 
801  public function exportEbp($objectLines)
802  {
803 
804  $separator = ',';
805  $end_line = "\n";
806 
807  foreach ($objectLines as $line) {
808  $date = dol_print_date($line->doc_date, '%d%m%Y');
809 
810  print $line->id.$separator;
811  print $date.$separator;
812  print $line->code_journal.$separator;
813  if (empty($line->subledger_account)) {
814  print $line->numero_compte.$separator;
815  } else {
816  print $line->subledger_account.$separator;
817  }
818  //print substr(length_accountg($line->numero_compte), 0, 2) . $separator;
819  print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator;
820  print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator;
821  print price2num(abs($line->debit - $line->credit)).$separator;
822  print $line->sens.$separator;
823  print $date.$separator;
824  //print 'EUR';
825  print $end_line;
826  }
827  }
828 
829 
836  public function exportAgiris($objectLines)
837  {
838 
839  $separator = ';';
840  $end_line = "\n";
841 
842  foreach ($objectLines as $line) {
843  $date = dol_print_date($line->doc_date, '%d%m%Y');
844 
845  print $line->piece_num.$separator;
846  print self::toAnsi($line->label_operation).$separator;
847  print $date.$separator;
848  print self::toAnsi($line->label_operation).$separator;
849 
850  if (empty($line->subledger_account)) {
851  print length_accountg($line->numero_compte).$separator;
852  print self::toAnsi($line->label_compte).$separator;
853  } else {
854  print length_accounta($line->subledger_account).$separator;
855  print self::toAnsi($line->subledger_label).$separator;
856  }
857 
858  print self::toAnsi($line->doc_ref).$separator;
859  print price($line->debit).$separator;
860  print price($line->credit).$separator;
861  print price(abs($line->debit - $line->credit)).$separator;
862  print $line->sens.$separator;
863  print $line->lettering_code.$separator;
864  print $line->code_journal;
865  print $end_line;
866  }
867  }
868 
875  public function exportOpenConcerto($objectLines)
876  {
877 
878  $separator = ';';
879  $end_line = "\n";
880 
881  foreach ($objectLines as $line) {
882  $date = dol_print_date($line->doc_date, '%d/%m/%Y');
883 
884  print $date.$separator;
885  print $line->code_journal.$separator;
886  if (empty($line->subledger_account)) {
887  print length_accountg($line->numero_compte).$separator;
888  } else {
889  print length_accounta($line->subledger_account).$separator;
890  }
891  print $line->doc_ref.$separator;
892  print $line->label_operation.$separator;
893  print price($line->debit).$separator;
894  print price($line->credit).$separator;
895 
896  print $end_line;
897  }
898  }
899 
906  public function exportConfigurable($objectLines)
907  {
908  global $conf;
909 
910  $separator = $this->separator;
911 
912  foreach ($objectLines as $line) {
913  $tab = array();
914  // export configurable
915  $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
916  $tab[] = $line->piece_num;
917  $tab[] = $date;
918  $tab[] = $line->doc_ref;
919  $tab[] = preg_match('/'.$separator.'/', $line->label_operation) ? "'".$line->label_operation."'" : $line->label_operation;
920  $tab[] = length_accountg($line->numero_compte);
921  $tab[] = length_accounta($line->subledger_account);
922  $tab[] = price2num($line->debit);
923  $tab[] = price2num($line->credit);
924  $tab[] = price2num($line->debit - $line->credit);
925  $tab[] = $line->code_journal;
926 
927  print implode($separator, $tab).$this->end_line;
928  }
929  }
930 
937  public function exportFEC($objectLines)
938  {
939  global $langs;
940 
941  $separator = "\t";
942  $end_line = "\r\n";
943 
944  print "JournalCode".$separator;
945  print "JournalLib".$separator;
946  print "EcritureNum".$separator;
947  print "EcritureDate".$separator;
948  print "CompteNum".$separator;
949  print "CompteLib".$separator;
950  print "CompAuxNum".$separator;
951  print "CompAuxLib".$separator;
952  print "PieceRef".$separator;
953  print "PieceDate".$separator;
954  print "EcritureLib".$separator;
955  print "Debit".$separator;
956  print "Credit".$separator;
957  print "EcritureLet".$separator;
958  print "DateLet".$separator;
959  print "ValidDate".$separator;
960  print "Montantdevise".$separator;
961  print "Idevise".$separator;
962  print "DateLimitReglmt".$separator;
963  print "NumFacture";
964  print $end_line;
965 
966  foreach ($objectLines as $line) {
967  if ($line->debit == 0 && $line->credit == 0) {
968  //unset($array[$line]);
969  } else {
970  $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
971  $date_document = dol_print_date($line->doc_date, '%Y%m%d');
972  $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
973  $date_validation = dol_print_date($line->date_validation, '%Y%m%d');
974  $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
975 
976  $refInvoice = '';
977  if ($line->doc_type == 'customer_invoice') {
978  // Customer invoice
979  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
980  $invoice = new Facture($this->db);
981  $invoice->fetch($line->fk_doc);
982 
983  $refInvoice = $invoice->ref;
984  } elseif ($line->doc_type == 'supplier_invoice') {
985  // Supplier invoice
986  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
987  $invoice = new FactureFournisseur($this->db);
988  $invoice->fetch($line->fk_doc);
989 
990  $refInvoice = $invoice->ref_supplier;
991  }
992 
993  // FEC:JournalCode
994  print $line->code_journal . $separator;
995 
996  // FEC:JournalLib
997  print dol_string_unaccent($langs->transnoentities($line->journal_label)) . $separator;
998 
999  // FEC:EcritureNum
1000  print $line->piece_num . $separator;
1001 
1002  // FEC:EcritureDate
1003  print $date_document . $separator;
1004 
1005  // FEC:CompteNum
1006  print $line->numero_compte . $separator;
1007 
1008  // FEC:CompteLib
1009  print dol_string_unaccent($line->label_compte) . $separator;
1010 
1011  // FEC:CompAuxNum
1012  print $line->subledger_account . $separator;
1013 
1014  // FEC:CompAuxLib
1015  print dol_string_unaccent($line->subledger_label) . $separator;
1016 
1017  // FEC:PieceRef
1018  print $line->doc_ref . $separator;
1019 
1020  // FEC:PieceDate
1021  print dol_string_unaccent($date_creation) . $separator;
1022 
1023  // FEC:EcritureLib
1024  // Clean label operation to prevent problem on export with tab separator & other character
1025  $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
1026  print dol_string_unaccent($line->label_operation) . $separator;
1027 
1028  // FEC:Debit
1029  print price2fec($line->debit) . $separator;
1030 
1031  // FEC:Credit
1032  print price2fec($line->credit) . $separator;
1033 
1034  // FEC:EcritureLet
1035  print $line->lettering_code . $separator;
1036 
1037  // FEC:DateLet
1038  print $date_lettering . $separator;
1039 
1040  // FEC:ValidDate
1041  print $date_validation . $separator;
1042 
1043  // FEC:Montantdevise
1044  print $line->multicurrency_amount . $separator;
1045 
1046  // FEC:Idevise
1047  print $line->multicurrency_code . $separator;
1048 
1049  // FEC_suppl:DateLimitReglmt
1050  print $date_limit_payment . $separator;
1051 
1052  // FEC_suppl:NumFacture
1053  // Clean ref invoice to prevent problem on export with tab separator & other character
1054  $refInvoice = str_replace(array("\t", "\n", "\r"), " ", $refInvoice);
1055  print dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1);
1056 
1057  print $end_line;
1058  }
1059  }
1060  }
1061 
1068  public function exportFEC2($objectLines)
1069  {
1070  global $langs;
1071 
1072  $separator = "\t";
1073  $end_line = "\r\n";
1074 
1075  print "JournalCode".$separator;
1076  print "JournalLib".$separator;
1077  print "EcritureNum".$separator;
1078  print "EcritureDate".$separator;
1079  print "CompteNum".$separator;
1080  print "CompteLib".$separator;
1081  print "CompAuxNum".$separator;
1082  print "CompAuxLib".$separator;
1083  print "PieceRef".$separator;
1084  print "PieceDate".$separator;
1085  print "EcritureLib".$separator;
1086  print "Debit".$separator;
1087  print "Credit".$separator;
1088  print "EcritureLet".$separator;
1089  print "DateLet".$separator;
1090  print "ValidDate".$separator;
1091  print "Montantdevise".$separator;
1092  print "Idevise".$separator;
1093  print "DateLimitReglmt".$separator;
1094  print "NumFacture";
1095  print $end_line;
1096 
1097  foreach ($objectLines as $line) {
1098  if ($line->debit == 0 && $line->credit == 0) {
1099  //unset($array[$line]);
1100  } else {
1101  $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
1102  $date_document = dol_print_date($line->doc_date, '%Y%m%d');
1103  $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
1104  $date_validation = dol_print_date($line->date_validation, '%Y%m%d');
1105  $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
1106 
1107  $refInvoice = '';
1108  if ($line->doc_type == 'customer_invoice') {
1109  // Customer invoice
1110  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1111  $invoice = new Facture($this->db);
1112  $invoice->fetch($line->fk_doc);
1113 
1114  $refInvoice = $invoice->ref;
1115  } elseif ($line->doc_type == 'supplier_invoice') {
1116  // Supplier invoice
1117  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1118  $invoice = new FactureFournisseur($this->db);
1119  $invoice->fetch($line->fk_doc);
1120 
1121  $refInvoice = $invoice->ref_supplier;
1122  }
1123 
1124  // FEC:JournalCode
1125  print $line->code_journal . $separator;
1126 
1127  // FEC:JournalLib
1128  print dol_string_unaccent($langs->transnoentities($line->journal_label)) . $separator;
1129 
1130  // FEC:EcritureNum
1131  print $line->piece_num . $separator;
1132 
1133  // FEC:EcritureDate
1134  print $date_creation . $separator;
1135 
1136  // FEC:CompteNum
1137  print length_accountg($line->numero_compte) . $separator;
1138 
1139  // FEC:CompteLib
1140  print dol_string_unaccent($line->label_compte) . $separator;
1141 
1142  // FEC:CompAuxNum
1143  print length_accounta($line->subledger_account) . $separator;
1144 
1145  // FEC:CompAuxLib
1146  print dol_string_unaccent($line->subledger_label) . $separator;
1147 
1148  // FEC:PieceRef
1149  print $line->doc_ref . $separator;
1150 
1151  // FEC:PieceDate
1152  print $date_document . $separator;
1153 
1154  // FEC:EcritureLib
1155  // Clean label operation to prevent problem on export with tab separator & other character
1156  $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
1157  print dol_string_unaccent($line->label_operation) . $separator;
1158 
1159  // FEC:Debit
1160  print price2fec($line->debit) . $separator;
1161 
1162  // FEC:Credit
1163  print price2fec($line->credit) . $separator;
1164 
1165  // FEC:EcritureLet
1166  print $line->lettering_code . $separator;
1167 
1168  // FEC:DateLet
1169  print $date_lettering . $separator;
1170 
1171  // FEC:ValidDate
1172  print $date_validation . $separator;
1173 
1174  // FEC:Montantdevise
1175  print $line->multicurrency_amount . $separator;
1176 
1177  // FEC:Idevise
1178  print $line->multicurrency_code . $separator;
1179 
1180  // FEC_suppl:DateLimitReglmt
1181  print $date_limit_payment . $separator;
1182 
1183  // FEC_suppl:NumFacture
1184  // Clean ref invoice to prevent problem on export with tab separator & other character
1185  $refInvoice = str_replace(array("\t", "\n", "\r"), " ", $refInvoice);
1186  print dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1);
1187 
1188 
1189  print $end_line;
1190  }
1191  }
1192  }
1193 
1204  public function exportSAGE50SWISS($objectLines)
1205  {
1206  // SAGE50SWISS
1207  $this->separator = ',';
1208  $this->end_line = "\r\n";
1209 
1210  // Print header line
1211  print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag";
1212  print $this->end_line;
1213  $thisPieceNum = "";
1214  $thisPieceAccountNr = "";
1215  $aSize = count($objectLines);
1216  foreach ($objectLines as $aIndex => $line) {
1217  $sammelBuchung = false;
1218  if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) {
1219  $sammelBuchung = true;
1220  } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) {
1221  $sammelBuchung = true;
1222  } elseif ($aIndex + 1 < $aSize
1223  && $objectLines[$aIndex + 1]->piece_num == $line->piece_num
1224  && $aIndex - 1 < $aSize
1225  && $objectLines[$aIndex - 1]->piece_num == $line->piece_num
1226  ) {
1227  $sammelBuchung = true;
1228  }
1229 
1230  //Blg
1231  print $line->piece_num.$this->separator;
1232 
1233  // Datum
1234  $date = dol_print_date($line->doc_date, '%d.%m.%Y');
1235  print $date.$this->separator;
1236 
1237  // Kto
1238  print length_accountg($line->numero_compte).$this->separator;
1239  // S/H
1240  if ($line->sens == 'D') {
1241  print 'S'.$this->separator;
1242  } else {
1243  print 'H'.$this->separator;
1244  }
1245  //Grp
1246  print self::trunc($line->code_journal, 1).$this->separator;
1247  // GKto
1248  if (empty($line->code_tiers)) {
1249  if ($line->piece_num == $thisPieceNum) {
1250  print length_accounta($thisPieceAccountNr).$this->separator;
1251  } else {
1252  print "div".$this->separator;
1253  }
1254  } else {
1255  print length_accounta($line->code_tiers).$this->separator;
1256  }
1257  //SId
1258  print $this->separator;
1259  //SIdx
1260  print "0".$this->separator;
1261  //KIdx
1262  print "0".$this->separator;
1263  //BTyp
1264  print "0".$this->separator;
1265 
1266  //MTyp 1=Fibu Einzelbuchung 2=Sammebuchung
1267  if ($sammelBuchung) {
1268  print "2".$this->separator;
1269  } else {
1270  print "1".$this->separator;
1271  }
1272  // Code
1273  print '""'.$this->separator;
1274  // Netto
1275  print abs($line->debit - $line->credit).$this->separator;
1276  // Steuer
1277  print "0.00".$this->separator;
1278  // FW-Betrag
1279  print "0.00".$this->separator;
1280  // Tx1
1281  $line1 = self::toAnsi($line->label_compte, 29);
1282  if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) {
1283  $line1 = "";
1284  }
1285  $line2 = self::toAnsi($line->doc_ref, 29);
1286  if (strlen($line1) == 0) {
1287  $line1 = $line2;
1288  $line2 = "";
1289  }
1290  if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) {
1291  $line1 = $line1.' / '.$line2;
1292  $line2 = "";
1293  }
1294 
1295  print '"'.self::toAnsi($line1).'"'.$this->separator;
1296  // Tx2
1297  print '"'.self::toAnsi($line2).'"'.$this->separator;
1298  //PkKey
1299  print "0".$this->separator;
1300  //OpId
1301  print $this->separator;
1302 
1303  // Flag
1304  print "0";
1305 
1306  print $this->end_line;
1307 
1308  if ($line->piece_num !== $thisPieceNum) {
1309  $thisPieceNum = $line->piece_num;
1310  $thisPieceAccountNr = $line->numero_compte;
1311  }
1312  }
1313  }
1314 
1323  public function exportLDCompta($objectLines)
1324  {
1325 
1326  $separator = ';';
1327  $end_line = "\r\n";
1328 
1329  foreach ($objectLines as $line) {
1330  $date_document = dol_print_date($line->doc_date, '%Y%m%d');
1331  $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
1332  $date_lim_reglement = dol_print_date($line->date_lim_reglement, '%Y%m%d');
1333 
1334  // TYPE
1335  $type_enregistrement = 'E'; // For write movement
1336  print $type_enregistrement.$separator;
1337  // JNAL
1338  print substr($line->code_journal, 0, 2).$separator;
1339  // NECR
1340  print $line->id.$separator;
1341  // NPIE
1342  print $line->piece_num.$separator;
1343  // DATP
1344  print $date_document.$separator;
1345  // LIBE
1346  print $line->label_operation.$separator;
1347  // DATH
1348  print $date_lim_reglement.$separator;
1349  // CNPI
1350  if ($line->doc_type == 'supplier_invoice') {
1351  if (($line->debit - $line->credit) > 0) {
1352  $nature_piece = 'AF';
1353  } else {
1354  $nature_piece = 'FF';
1355  }
1356  } elseif ($line->doc_type == 'customer_invoice') {
1357  if (($line->debit - $line->credit) < 0) {
1358  $nature_piece = 'AC';
1359  } else {
1360  $nature_piece = 'FC';
1361  }
1362  } else {
1363  $nature_piece = '';
1364  }
1365  print $nature_piece.$separator;
1366  // RACI
1367  // if (! empty($line->subledger_account)) {
1368  // if ($line->doc_type == 'supplier_invoice') {
1369  // $racine_subledger_account = '40';
1370  // } elseif ($line->doc_type == 'customer_invoice') {
1371  // $racine_subledger_account = '41';
1372  // } else {
1373  // $racine_subledger_account = '';
1374  // }
1375  // } else {
1376  $racine_subledger_account = ''; // for records of type E leave this field blank
1377  // }
1378 
1379  print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead
1380  // MONT
1381  print price(abs($line->debit - $line->credit), 0, '', 1, 2, 2).$separator;
1382  // CODC
1383  print $line->sens.$separator;
1384  // CPTG
1385  print length_accountg($line->numero_compte).$separator;
1386  // DATE
1387  print $date_creation.$separator;
1388  // CLET
1389  print $line->lettering_code.$separator;
1390  // DATL
1391  print $line->date_lettering.$separator;
1392  // CPTA
1393  if (!empty($line->subledger_account)) {
1394  print length_accounta($line->subledger_account).$separator;
1395  } else {
1396  print $separator;
1397  }
1398  // CNAT
1399  if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) {
1400  print 'F'.$separator;
1401  } elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) {
1402  print 'C'.$separator;
1403  } else {
1404  print $separator;
1405  }
1406  // SECT
1407  print $separator;
1408  // CTRE
1409  print $separator;
1410  // NORL
1411  print $separator;
1412  // DATV
1413  print $separator;
1414  // REFD
1415  print $line->doc_ref.$separator;
1416  // CODH
1417  print $separator;
1418  // NSEQ
1419  print $separator;
1420  // MTDV
1421  print '0'.$separator;
1422  // CODV
1423  print $separator;
1424  // TXDV
1425  print '0'.$separator;
1426  // MOPM
1427  print $separator;
1428  // BONP
1429  print $separator;
1430  // BQAF
1431  print $separator;
1432  // ECES
1433  print $separator;
1434  // TXTL
1435  print $separator;
1436  // ECRM
1437  print $separator;
1438  // DATK
1439  print $separator;
1440  // HEUK
1441  print $separator;
1442 
1443  print $end_line;
1444  }
1445  }
1446 
1457  public function exportLDCompta10($objectLines)
1458  {
1459  require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
1460 
1461  $separator = ';';
1462  $end_line = "\r\n";
1463  $last_codeinvoice = '';
1464 
1465  foreach ($objectLines as $line) {
1466  // TYPE C
1467  if ($last_codeinvoice != $line->doc_ref) {
1468  //recherche societe en fonction de son code client
1469  $sql = "SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX."societe";
1470  $sql .= " WHERE code_client = '".$this->db->escape($line->thirdparty_code)."'";
1471  $resql = $this->db->query($sql);
1472 
1473  if ($resql && $this->db->num_rows($resql) > 0) {
1474  $soc = $this->db->fetch_object($resql);
1475 
1476  $address = array('', '', '');
1477  if (strpos($soc->address, "\n") !== false) {
1478  $address = explode("\n", $soc->address);
1479  if (is_array($address) && count($address) > 0) {
1480  foreach ($address as $key => $data) {
1481  $address[$key] = str_replace(array("\t", "\n", "\r"), "", $data);
1482  $address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1);
1483  }
1484  }
1485  } else {
1486  $address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40);
1487  $address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40);
1488  $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40);
1489  }
1490 
1491  $type_enregistrement = 'C';
1492  //TYPE
1493  print $type_enregistrement.$separator;
1494  //NOCL
1495  print $soc->code_client.$separator;
1496  //NMCM
1497  print $separator;
1498  //LIBI
1499  print $separator;
1500  //TITR
1501  print $separator;
1502  //RSSO
1503  print $soc->nom.$separator;
1504  //CAD1
1505  print $address[0].$separator;
1506  //CAD2
1507  print $address[1].$separator;
1508  //CAD3
1509  print $address[2].$separator;
1510  //COPO
1511  print $soc->zip.$separator;
1512  //BUDI
1513  print substr($soc->town, 0, 40).$separator;
1514  //CPAY
1515  print $separator;
1516  //PAYS
1517  print substr(getCountry($soc->fk_pays), 0, 40).$separator;
1518  //NTEL
1519  print $soc->phone.$separator;
1520  //TLEX
1521  print $separator;
1522  //TLPO
1523  print $separator;
1524  //TLCY
1525  print $separator;
1526  //NINT
1527  print $separator;
1528  //COMM
1529  print $separator;
1530  //SIRE
1531  print str_replace(" ", "", $soc->siret).$separator;
1532  //RIBP
1533  print $separator;
1534  //DOBQ
1535  print $separator;
1536  //IBBQ
1537  print $separator;
1538  //COBQ
1539  print $separator;
1540  //GUBQ
1541  print $separator;
1542  //CPBQ
1543  print $separator;
1544  //CLBQ
1545  print $separator;
1546  //BIBQ
1547  print $separator;
1548  //MOPM
1549  print $separator;
1550  //DJPM
1551  print $separator;
1552  //DMPM
1553  print $separator;
1554  //REFM
1555  print $separator;
1556  //SLVA
1557  print $separator;
1558  //PLCR
1559  print $separator;
1560  //ECFI
1561  print $separator;
1562  //CREP
1563  print $separator;
1564  //NREP
1565  print $separator;
1566  //TREP
1567  print $separator;
1568  //MREP
1569  print $separator;
1570  //GRRE
1571  print $separator;
1572  //LTTA
1573  print $separator;
1574  //CACT
1575  print $separator;
1576  //CODV
1577  print $separator;
1578  //GRTR
1579  print $separator;
1580  //NOFP
1581  print $separator;
1582  //BQAF
1583  print $separator;
1584  //BONP
1585  print $separator;
1586  //CESC
1587  print $separator;
1588 
1589  print $end_line;
1590  }
1591  }
1592 
1593  $date_document = dol_print_date($line->doc_date, '%Y%m%d');
1594  $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
1595  $date_lim_reglement = dol_print_date($line->date_lim_reglement, '%Y%m%d');
1596 
1597  // TYPE E
1598  $type_enregistrement = 'E'; // For write movement
1599  print $type_enregistrement.$separator;
1600  // JNAL
1601  print substr($line->code_journal, 0, 2).$separator;
1602  // NECR
1603  print $line->id.$separator;
1604  // NPIE
1605  print $line->piece_num.$separator;
1606  // DATP
1607  print $date_document.$separator;
1608  // LIBE
1609  print dol_trunc($line->label_operation, 25, 'right', 'UTF-8', 1).$separator;
1610  // DATH
1611  print $date_lim_reglement.$separator;
1612  // CNPI
1613  if ($line->doc_type == 'supplier_invoice') {
1614  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.
1615  $nature_piece = 'AF';
1616  } else {
1617  $nature_piece = 'FF';
1618  }
1619  } elseif ($line->doc_type == 'customer_invoice') {
1620  if (($line->amount) < 0) {
1621  $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.
1622  } else {
1623  $nature_piece = 'FC';
1624  }
1625  } else {
1626  $nature_piece = '';
1627  }
1628  print $nature_piece.$separator;
1629  // RACI
1630  // if (! empty($line->subledger_account)) {
1631  // if ($line->doc_type == 'supplier_invoice') {
1632  // $racine_subledger_account = '40';
1633  // } elseif ($line->doc_type == 'customer_invoice') {
1634  // $racine_subledger_account = '41';
1635  // } else {
1636  // $racine_subledger_account = '';
1637  // }
1638  // } else {
1639  $racine_subledger_account = ''; // for records of type E leave this field blank
1640  // }
1641 
1642  print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead
1643  // MONT
1644  print price(abs($line->debit - $line->credit), 0, '', 1, 2).$separator;
1645  // CODC
1646  print $line->sens.$separator;
1647  // CPTG
1648  print length_accountg($line->numero_compte).$separator;
1649  // DATE
1650  print $date_document.$separator;
1651  // CLET
1652  print $line->lettering_code.$separator;
1653  // DATL
1654  print $line->date_lettering.$separator;
1655  // CPTA
1656  if (!empty($line->subledger_account)) {
1657  print length_accounta($line->subledger_account).$separator;
1658  } else {
1659  print $separator;
1660  }
1661  // CNAT
1662  if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) {
1663  print 'F'.$separator;
1664  } elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) {
1665  print 'C'.$separator;
1666  } else {
1667  print $separator;
1668  }
1669  // CTRE
1670  print $separator;
1671  // NORL
1672  print $separator;
1673  // DATV
1674  print $separator;
1675  // REFD
1676  print $line->doc_ref.$separator;
1677  // NECA
1678  print '0'.$separator;
1679  // CSEC
1680  print $separator;
1681  // CAFF
1682  print $separator;
1683  // CDES
1684  print $separator;
1685  // QTUE
1686  print $separator;
1687  // MTDV
1688  print '0'.$separator;
1689  // CODV
1690  print $separator;
1691  // TXDV
1692  print '0'.$separator;
1693  // MOPM
1694  print $separator;
1695  // BONP
1696  print $separator;
1697  // BQAF
1698  print $separator;
1699  // ECES
1700  print $separator;
1701  // TXTL
1702  print $separator;
1703  // ECRM
1704  print $separator;
1705  // DATK
1706  print $separator;
1707  // HEUK
1708  print $separator;
1709 
1710  print $end_line;
1711 
1712  $last_codeinvoice = $line->doc_ref;
1713  }
1714  }
1715 
1722  public function exportCharlemagne($objectLines)
1723  {
1724  global $langs;
1725  $langs->load('compta');
1726 
1727  $separator = "\t";
1728  $end_line = "\n";
1729 
1730  /*
1731  * Charlemagne export need header
1732  */
1733  print $langs->transnoentitiesnoconv('Date').$separator;
1734  print self::trunc($langs->transnoentitiesnoconv('Journal'), 6).$separator;
1735  print self::trunc($langs->transnoentitiesnoconv('Account'), 15).$separator;
1736  print self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60).$separator;
1737  print self::trunc($langs->transnoentitiesnoconv('Piece'), 20).$separator;
1738  print self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60).$separator;
1739  print $langs->transnoentitiesnoconv('Amount').$separator;
1740  print 'S'.$separator;
1741  print self::trunc($langs->transnoentitiesnoconv('Analytic').' 1', 15).$separator;
1742  print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 1', 60).$separator;
1743  print self::trunc($langs->transnoentitiesnoconv('Analytic').' 2', 15).$separator;
1744  print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 2', 60).$separator;
1745  print self::trunc($langs->transnoentitiesnoconv('Analytic').' 3', 15).$separator;
1746  print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 3', 60).$separator;
1747  print $end_line;
1748 
1749  foreach ($objectLines as $line) {
1750  $date = dol_print_date($line->doc_date, '%Y%m%d');
1751  print $date.$separator; //Date
1752 
1753  print self::trunc($line->code_journal, 6).$separator; //Journal code
1754 
1755  if (!empty($line->subledger_account)) {
1756  $account = $line->subledger_account;
1757  } else {
1758  $account = $line->numero_compte;
1759  }
1760  print self::trunc($account, 15).$separator; //Account number
1761 
1762  print self::trunc($line->label_compte, 60).$separator; //Account label
1763  print self::trunc($line->doc_ref, 20).$separator; //Piece
1764  // Clean label operation to prevent problem on export with tab separator & other character
1765  $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
1766  print self::trunc($line->label_operation, 60).$separator; //Operation label
1767  print price(abs($line->debit - $line->credit)).$separator; //Amount
1768  print $line->sens.$separator; //Direction
1769  print $separator; //Analytic
1770  print $separator; //Analytic
1771  print $separator; //Analytic
1772  print $separator; //Analytic
1773  print $separator; //Analytic
1774  print $separator; //Analytic
1775  print $end_line;
1776  }
1777  }
1778 
1786  public function exportGestimumV3($objectLines)
1787  {
1788  global $langs;
1789 
1790  $this->separator = ',';
1791 
1792  $invoices_infos = array();
1793  $supplier_invoices_infos = array();
1794  foreach ($objectLines as $line) {
1795  if ($line->debit == 0 && $line->credit == 0) {
1796  //unset($array[$line]);
1797  } else {
1798  $date = dol_print_date($line->doc_date, '%d/%m/%Y');
1799 
1800  $invoice_ref = $line->doc_ref;
1801  $company_name = "";
1802 
1803  if (($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice') && $line->fk_doc > 0) {
1804  if (($line->doc_type == 'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) ||
1805  ($line->doc_type == 'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) {
1806  if ($line->doc_type == 'customer_invoice') {
1807  // Get new customer invoice ref and company name
1808  $sql = 'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f';
1809  $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid';
1810  $sql .= ' WHERE f.rowid = '.((int) $line->fk_doc);
1811  $resql = $this->db->query($sql);
1812  if ($resql) {
1813  if ($obj = $this->db->fetch_object($resql)) {
1814  // Save invoice infos
1815  $invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom);
1816  $invoice_ref = $obj->ref;
1817  $company_name = $obj->nom;
1818  }
1819  }
1820  } else {
1821  // Get new supplier invoice ref and company name
1822  $sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff';
1823  $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid';
1824  $sql .= ' WHERE ff.rowid = '.((int) $line->fk_doc);
1825  $resql = $this->db->query($sql);
1826  if ($resql) {
1827  if ($obj = $this->db->fetch_object($resql)) {
1828  // Save invoice infos
1829  $supplier_invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom);
1830  $invoice_ref = $obj->ref;
1831  $company_name = $obj->nom;
1832  }
1833  }
1834  }
1835  } elseif ($line->doc_type == 'customer_invoice') {
1836  // Retrieve invoice infos
1837  $invoice_ref = $invoices_infos[$line->fk_doc]['ref'];
1838  $company_name = $invoices_infos[$line->fk_doc]['company_name'];
1839  } else {
1840  // Retrieve invoice infos
1841  $invoice_ref = $supplier_invoices_infos[$line->fk_doc]['ref'];
1842  $company_name = $supplier_invoices_infos[$line->fk_doc]['company_name'];
1843  }
1844  }
1845 
1846  print $line->id . $this->separator;
1847  print $date . $this->separator;
1848  print substr($line->code_journal, 0, 4) . $this->separator;
1849 
1850  if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) {
1851  print length_accountg($line->subledger_account) . $this->separator;
1852  } else {
1853  print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator;
1854  }
1855  //Libellé Auto
1856  print $this->separator;
1857  //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator;
1858  //Libellé manuel
1859  print dol_trunc(str_replace('"', '', $invoice_ref . (!empty($company_name) ? ' - ' : '') . $company_name), 40, 'right', 'UTF-8', 1) . $this->separator;
1860  //Numéro de pièce
1861  print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator;
1862  //Devise
1863  print 'EUR' . $this->separator;
1864  //Amount
1865  print price2num(abs($line->debit - $line->credit)) . $this->separator;
1866  //Sens
1867  print $line->sens . $this->separator;
1868  //Code lettrage
1869  print $this->separator;
1870  //Date Echéance
1871  print $date;
1872  print $this->end_line;
1873  }
1874  }
1875  }
1876 
1884  public function exportGestimumV5($objectLines)
1885  {
1886 
1887  $this->separator = ',';
1888 
1889  foreach ($objectLines as $line) {
1890  if ($line->debit == 0 && $line->credit == 0) {
1891  //unset($array[$line]);
1892  } else {
1893  $date = dol_print_date($line->doc_date, '%d%m%Y');
1894 
1895  print $line->id . $this->separator;
1896  print $date . $this->separator;
1897  print substr($line->code_journal, 0, 4) . $this->separator;
1898  if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { // TODO No hard code value
1899  print length_accountg($line->subledger_account) . $this->separator;
1900  } else {
1901  print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator;
1902  }
1903  print $this->separator;
1904  //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator;
1905  print '"' . dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1) . '"' . $this->separator;
1906  print '"' . dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . '"' . $this->separator;
1907  print price2num(abs($line->debit - $line->credit)) . $this->separator;
1908  print $line->sens . $this->separator;
1909  print $date . $this->separator;
1910  print $this->separator;
1911  print $this->separator;
1912  print 'EUR';
1913  print $this->end_line;
1914  }
1915  }
1916  }
1917 
1927  public function exportiSuiteExpert($objectLines)
1928  {
1929  $this->separator = ';';
1930  $this->end_line = "\r\n";
1931 
1932 
1933  foreach ($objectLines as $line) {
1934  $tab = array();
1935 
1936  $date = dol_print_date($line->doc_date, '%d/%m/%Y');
1937 
1938  $tab[] = $line->piece_num;
1939  $tab[] = $date;
1940  $tab[] = substr($date, 6, 4);
1941  $tab[] = substr($date, 3, 2);
1942  $tab[] = substr($date, 0, 2);
1943  $tab[] = $line->doc_ref;
1944  //Conversion de chaine UTF8 en Latin9
1945  $tab[] = mb_convert_encoding(str_replace(' - Compte auxiliaire', '', $line->label_operation), "Windows-1252", 'UTF-8');
1946 
1947  //Calcul de la longueur des numéros de comptes
1948  $taille_numero = strlen(length_accountg($line->numero_compte));
1949 
1950  //Création du numéro de client générique
1951  $numero_cpt_client = '411';
1952  for ($i = 1; $i <= ($taille_numero - 3); $i++) {
1953  $numero_cpt_client .= '0';
1954  }
1955 
1956  //Création des comptes auxiliaire des clients
1957  if (length_accountg($line->numero_compte) == $numero_cpt_client) {
1958  $tab[] = rtrim(length_accounta($line->subledger_account), "0");
1959  } else {
1960  $tab[] = length_accountg($line->numero_compte);
1961  }
1962  $nom_client = explode(" - ", $line->label_operation);
1963  $tab[] = mb_convert_encoding($nom_client[0], "Windows-1252", 'UTF-8');
1964  $tab[] = price($line->debit);
1965  $tab[] = price($line->credit);
1966  $tab[] = price($line->montant);
1967  $tab[] = $line->code_journal;
1968 
1969  $separator = $this->separator;
1970  print implode($separator, $tab) . $this->end_line;
1971  }
1972  }
1973 
1981  public static function trunc($str, $size)
1982  {
1983  return dol_trunc($str, $size, 'right', 'UTF-8', 1);
1984  }
1985 
1993  public static function toAnsi($str, $size = -1)
1994  {
1995  $retVal = dol_string_nohtmltag($str, 1, 'Windows-1251');
1996  if ($retVal >= 0 && $size >= 0) {
1997  $retVal = mb_substr($retVal, 0, $size, 'Windows-1251');
1998  }
1999  return $retVal;
2000  }
2001 }
length_accounta
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
Definition: accounting.lib.php:133
db
$conf db
API class for accounts.
Definition: inc.php:41
dol_trunc
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.
Definition: functions.lib.php:3791
AccountancyExport\exportQuadratus
exportQuadratus(&$TData)
Export format : Quadratus (Format ASCII) Format since 2015 compatible QuadraCOMPTA Last review for th...
Definition: accountancyexport.class.php:568
AccountancyExport\exportGestimumV5
exportGestimumV5($objectLines)
Export format : Gestimum V5.
Definition: accountancyexport.class.php:1884
DoliDB
Class to manage Dolibarr database access.
Definition: DoliDB.class.php:30
AccountancyExport\exportCogilog
exportCogilog($objectLines)
Export format : COGILOG.
Definition: accountancyexport.class.php:414
AccountancyExport\export
export(&$TData, $formatexportset)
Function who chose which export to use with the default config, and make the export into a file.
Definition: accountancyexport.class.php:296
FactureFournisseur
Class to manage suppliers invoices.
Definition: fournisseur.facture.class.php:53
AccountancyExport\getType
getType()
Array with all export type available (key + label)
Definition: accountancyexport.class.php:112
AccountancyExport\exportCoala
exportCoala($objectLines)
Export format : COALA.
Definition: accountancyexport.class.php:447
AccountancyExport\exportOpenConcerto
exportOpenConcerto($objectLines)
Export format : OpenConcerto.
Definition: accountancyexport.class.php:875
AccountancyExport\getTypeConfig
getTypeConfig()
Array with all export type available (key + label) and parameters for config.
Definition: accountancyexport.class.php:192
AccountancyExport\trunc
static trunc($str, $size)
trunc
Definition: accountancyexport.class.php:1981
AccountancyExport\exportLDCompta
exportLDCompta($objectLines)
Export format : LD Compta version 9 http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Docu...
Definition: accountancyexport.class.php:1323
AccountancyExport\getFormatCode
static getFormatCode($type)
Return string to summarize the format (Used to generated export filename)
Definition: accountancyexport.class.php:154
AccountancyExport\exportGestimumV3
exportGestimumV3($objectLines)
Export format : Gestimum V3.
Definition: accountancyexport.class.php:1786
Facture
Class to manage invoices.
Definition: facture.class.php:60
AccountancyExport\exportCegid
exportCegid($objectLines)
Export format : CEGID.
Definition: accountancyexport.class.php:389
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5647
AccountancyExport\exportWinfic
exportWinfic(&$TData)
Export format : WinFic - eWinfic - WinSis Compta Last review for this format : 2022-11-01 Alexandre S...
Definition: accountancyexport.class.php:715
AccountancyExport\exportFEC2
exportFEC2($objectLines)
Export format : FEC2.
Definition: accountancyexport.class.php:1068
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2500
AccountancyExport\exportFEC
exportFEC($objectLines)
Export format : FEC.
Definition: accountancyexport.class.php:937
AccountancyExport\exportBob50
exportBob50($objectLines)
Export format : BOB50.
Definition: accountancyexport.class.php:475
AccountancyExport
Manage the different format accountancy export.
Definition: accountancyexport.class.php:44
AccountancyExport\exportLDCompta10
exportLDCompta10($objectLines)
Export format : LD Compta version 10 & higher Last review for this format : 08-15-2021 Alexandre Span...
Definition: accountancyexport.class.php:1457
dol_string_unaccent
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
Definition: functions.lib.php:1295
AccountancyExport\exportCharlemagne
exportCharlemagne($objectLines)
Export format : Charlemagne.
Definition: accountancyexport.class.php:1722
AccountancyExport\exportCiel
exportCiel(&$TData)
Export format : CIEL (Format XIMPORT) Format since 2003 compatible CIEL version > 2002 / Sage50 Last ...
Definition: accountancyexport.class.php:521
length_accountg
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
Definition: accounting.lib.php:94
AccountancyExport\exportConfigurable
exportConfigurable($objectLines)
Export format : Configurable CSV.
Definition: accountancyexport.class.php:906
dol_string_nohtmltag
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
Definition: functions.lib.php:6680
price2fec
price2fec($amount)
Function to format a value into a defined format for French administration (no thousand separator & d...
Definition: functions2.lib.php:2730
AccountancyExport\exportAgiris
exportAgiris($objectLines)
Export format : Agiris Isacompta.
Definition: accountancyexport.class.php:836
AccountancyExport\exportiSuiteExpert
exportiSuiteExpert($objectLines)
Export format : iSuite Expert.
Definition: accountancyexport.class.php:1927
AccountancyExport\toAnsi
static toAnsi($str, $size=-1)
toAnsi
Definition: accountancyexport.class.php:1993
$resql
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
AccountancyExport\__construct
__construct(DoliDB $db)
Constructor.
Definition: accountancyexport.class.php:96
AccountancyExport\exportEbp
exportEbp($objectLines)
Export format : EBP.
Definition: accountancyexport.class.php:801
price
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.
Definition: functions.lib.php:5527
getCountry
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
Definition: company.lib.php:489
AccountancyExport\exportSAGE50SWISS
exportSAGE50SWISS($objectLines)
Export format : SAGE50SWISS.
Definition: accountancyexport.class.php:1204