dolibarr  17.0.4
accountancyexport.class.php
Go to the documentation of this file.
1 <?php
2 /*
3  * Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
5  * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
6  * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
7  * Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
8  * Copyright (C) 2016-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 
295  public function getMimeType($formatexportset)
296  {
297  $mime = 'text/csv';
298 
299  switch ($formatexportset) {
300  case self::$EXPORT_TYPE_FEC:
301  $mime = 'text/tab-separated-values';
302  break;
303  default:
304  $mime = 'text/csv';
305  break;
306  }
307 
308  return $mime;
309  }
310 
318  public function export(&$TData, $formatexportset)
319  {
320  global $conf, $langs;
321  global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php
322 
323  // Define name of file to save
324  $filename = 'general_ledger-'.$this->getFormatCode($formatexportset);
325  $type_export = 'general_ledger';
326 
327  global $db; // The tpl file use $db
328  include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
329 
330 
331  switch ($formatexportset) {
332  case self::$EXPORT_TYPE_CONFIGURABLE:
333  $this->exportConfigurable($TData);
334  break;
335  case self::$EXPORT_TYPE_CEGID:
336  $this->exportCegid($TData);
337  break;
338  case self::$EXPORT_TYPE_COALA:
339  $this->exportCoala($TData);
340  break;
341  case self::$EXPORT_TYPE_BOB50:
342  $this->exportBob50($TData);
343  break;
344  case self::$EXPORT_TYPE_CIEL:
345  $this->exportCiel($TData);
346  break;
347  case self::$EXPORT_TYPE_QUADRATUS:
348  $this->exportQuadratus($TData);
349  break;
350  case self::$EXPORT_TYPE_WINFIC:
351  $this->exportWinfic($TData);
352  break;
353  case self::$EXPORT_TYPE_EBP:
354  $this->exportEbp($TData);
355  break;
356  case self::$EXPORT_TYPE_COGILOG:
357  $this->exportCogilog($TData);
358  break;
359  case self::$EXPORT_TYPE_AGIRIS:
360  $this->exportAgiris($TData);
361  break;
362  case self::$EXPORT_TYPE_OPENCONCERTO:
363  $this->exportOpenConcerto($TData);
364  break;
365  case self::$EXPORT_TYPE_SAGE50_SWISS:
366  $this->exportSAGE50SWISS($TData);
367  break;
368  case self::$EXPORT_TYPE_CHARLEMAGNE:
369  $this->exportCharlemagne($TData);
370  break;
371  case self::$EXPORT_TYPE_LDCOMPTA:
372  $this->exportLDCompta($TData);
373  break;
374  case self::$EXPORT_TYPE_LDCOMPTA10:
375  $this->exportLDCompta10($TData);
376  break;
377  case self::$EXPORT_TYPE_GESTIMUMV3:
378  $this->exportGestimumV3($TData);
379  break;
380  case self::$EXPORT_TYPE_GESTIMUMV5:
381  $this->exportGestimumV5($TData);
382  break;
383  case self::$EXPORT_TYPE_FEC:
384  $this->exportFEC($TData);
385  break;
386  case self::$EXPORT_TYPE_FEC2:
387  $this->exportFEC2($TData);
388  break;
389  case self::$EXPORT_TYPE_ISUITEEXPERT :
390  $this->exportiSuiteExpert($TData);
391  break;
392  default:
393  global $hookmanager;
394  $parameters = array('format' => $formatexportset);
395  // file contents will be created in the hooked function via print
396  $reshook = $hookmanager->executeHooks('export', $parameters, $TData);
397  if ($reshook != 1) {
398  $this->errors[] = $langs->trans('accountancy_error_modelnotfound');
399  }
400  break;
401  }
402  }
403 
404 
411  public function exportCegid($objectLines)
412  {
413  foreach ($objectLines as $line) {
414  $date = dol_print_date($line->doc_date, '%d%m%Y');
415  $separator = ";";
416  $end_line = "\n";
417 
418  print $date.$separator;
419  print $line->code_journal.$separator;
420  print length_accountg($line->numero_compte).$separator;
421  print length_accounta($line->subledger_account).$separator;
422  print $line->sens.$separator;
423  print price2fec(abs($line->debit - $line->credit)).$separator;
424  print dol_string_unaccent($line->label_operation).$separator;
425  print dol_string_unaccent($line->doc_ref);
426  print $end_line;
427  }
428  }
429 
436  public function exportCogilog($objectLines)
437  {
438  foreach ($objectLines as $line) {
439  $date = dol_print_date($line->doc_date, '%d%m%Y');
440  $separator = ";";
441  $end_line = "\n";
442 
443  print $line->code_journal.$separator;
444  print $date.$separator;
445  print $line->piece_num.$separator;
446  print length_accountg($line->numero_compte).$separator;
447  print ''.$separator;
448  print $line->label_operation.$separator;
449  print $date.$separator;
450  if ($line->sens == 'D') {
451  print price($line->debit).$separator;
452  print ''.$separator;
453  } elseif ($line->sens == 'C') {
454  print ''.$separator;
455  print price($line->credit).$separator;
456  }
457  print $line->doc_ref.$separator;
458  print $line->label_operation.$separator;
459  print $end_line;
460  }
461  }
462 
469  public function exportCoala($objectLines)
470  {
471  // Coala export
472  $separator = ";";
473  $end_line = "\n";
474 
475  foreach ($objectLines as $line) {
476  $date = dol_print_date($line->doc_date, '%d/%m/%Y');
477 
478  print $date.$separator;
479  print $line->code_journal.$separator;
480  print length_accountg($line->numero_compte).$separator;
481  print $line->piece_num.$separator;
482  print $line->doc_ref.$separator;
483  print price($line->debit).$separator;
484  print price($line->credit).$separator;
485  print 'E'.$separator;
486  print length_accounta($line->subledger_account).$separator;
487  print $end_line;
488  }
489  }
490 
497  public function exportBob50($objectLines)
498  {
499 
500  // Bob50
501  $separator = ";";
502  $end_line = "\n";
503 
504  foreach ($objectLines as $line) {
505  print $line->piece_num.$separator;
506  $date = dol_print_date($line->doc_date, '%d/%m/%Y');
507  print $date.$separator;
508 
509  if (empty($line->subledger_account)) {
510  print 'G'.$separator;
511  print length_accounta($line->numero_compte).$separator;
512  } else {
513  if (substr($line->numero_compte, 0, 3) == '411') {
514  print 'C'.$separator;
515  }
516  if (substr($line->numero_compte, 0, 3) == '401') {
517  print 'F'.$separator;
518  }
519  print length_accountg($line->subledger_account).$separator;
520  }
521 
522  print price($line->debit).$separator;
523  print price($line->credit).$separator;
524  print dol_trunc($line->label_operation, 32).$separator;
525  print $end_line;
526  }
527  }
528 
543  public function exportCiel(&$TData)
544  {
545  $end_line = "\r\n";
546 
547  $i = 1;
548 
549  foreach ($TData as $data) {
550  $code_compta = length_accountg($data->numero_compte);
551  if (!empty($data->subledger_account)) {
552  $code_compta = length_accounta($data->subledger_account);
553  }
554 
555  $date_document = dol_print_date($data->doc_date, '%Y%m%d');
556  $date_echeance = dol_print_date($data->date_lim_reglement, '%Y%m%d');
557 
558  $Tab = array();
559  $Tab['num_ecriture'] = str_pad($data->piece_num, 5);
560  $Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
561  $Tab['date_ecriture'] = str_pad($date_document, 8, ' ', STR_PAD_LEFT);
562  $Tab['date_echeance'] = str_pad($date_echeance, 8, ' ', STR_PAD_LEFT);
563  $Tab['num_piece'] = str_pad(self::trunc($data->doc_ref, 12), 12);
564  $Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11);
565  $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).dol_string_unaccent($data->label_operation), 25), 25);
566  $Tab['montant'] = str_pad(price2fec(abs($data->debit - $data->credit)), 13, ' ', STR_PAD_LEFT);
567  $Tab['type_montant'] = str_pad($data->sens, 1);
568  $Tab['vide'] = str_repeat(' ', 18); // Analytical accounting - Not managed in Dolibarr
569  $Tab['intitule_compte'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 34), 34);
570  $Tab['end'] = 'O2003'; // 0 = EUR | 2003 = Format Ciel
571 
572  $Tab['end_line'] = $end_line;
573 
574  print implode($Tab);
575  $i++;
576  }
577  }
578 
590  public function exportQuadratus(&$TData)
591  {
592  global $conf, $db;
593 
594  $end_line = "\r\n";
595 
596  // We should use dol_now function not time however this is wrong date to transfert in accounting
597  // $date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
598  // $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
599  foreach ($TData as $data) {
600  // Clean some data
601  $data->doc_ref = dol_string_unaccent($data->doc_ref);
602 
603  $data->label_operation = str_replace(array("\t", "\n", "\r"), " ", $data->label_operation);
604  $data->label_operation = str_replace(array("- ", "…", "..."), "", $data->label_operation);
605  $data->label_operation = dol_string_unaccent($data->label_operation);
606 
607  $data->numero_compte = dol_string_unaccent($data->numero_compte);
608  $data->label_compte = dol_string_unaccent($data->label_compte);
609  $data->subledger_account = dol_string_unaccent($data->subledger_account);
610 
611  $data->subledger_label = dol_string_unaccent($data->subledger_label);
612  $data->subledger_label = str_replace(array("- ", "…", "..."), "", $data->subledger_label);
613  $data->subledger_label = dol_string_unaccent($data->subledger_label);
614 
615  $code_compta = $data->numero_compte;
616  if (!empty($data->subledger_account)) {
617  $code_compta = $data->subledger_account;
618  }
619 
620  $Tab = array();
621 
622  if (!empty($data->subledger_account)) {
623  $Tab['type_ligne'] = 'C';
624  $Tab['num_compte'] = str_pad(self::trunc($data->subledger_account, 8), 8);
625  $Tab['lib_compte'] = str_pad(self::trunc($data->subledger_label, 30), 30);
626 
627  if ($data->doc_type == 'customer_invoice') {
628  $Tab['lib_alpha'] = strtoupper(str_pad('C'.self::trunc($data->subledger_label, 6), 7));
629  $Tab['filler'] = str_repeat(' ', 52);
630  $Tab['coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, 8), 8);
631  } elseif ($data->doc_type == 'supplier_invoice') {
632  $Tab['lib_alpha'] = strtoupper(str_pad('F'.self::trunc($data->subledger_label, 6), 7));
633  $Tab['filler'] = str_repeat(' ', 52);
634  $Tab['coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, 8), 8);
635  } else {
636  $Tab['filler'] = str_repeat(' ', 59);
637  $Tab['coll_compte'] = str_pad(' ', 8);
638  }
639 
640  $Tab['filler2'] = str_repeat(' ', 110);
641  $Tab['Maj'] = 2; // Partial update (alpha key, label, address, collectif, RIB)
642 
643  if ($data->doc_type == 'customer_invoice') {
644  $Tab['type_compte'] = 'C';
645  } elseif ($data->doc_type == 'supplier_invoice') {
646  $Tab['type_compte'] = 'F';
647  } else {
648  $Tab['type_compte'] = 'G';
649  }
650 
651  $Tab['filler3'] = str_repeat(' ', 235);
652 
653  $Tab['end_line'] = $end_line;
654 
655  print implode($Tab);
656  }
657 
658  $Tab = array();
659  $Tab['type_ligne'] = 'M';
660  $Tab['num_compte'] = str_pad(self::trunc($code_compta, 8), 8);
661  $Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
662  $Tab['folio'] = '000';
663 
664  // We use invoice date $data->doc_date not $date_ecriture which is the transfert date
665  // maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ?
666  //$Tab['date_ecriture'] = $date_ecriture;
667  $Tab['date_ecriture'] = dol_print_date($data->doc_date, '%d%m%y');
668  $Tab['filler'] = ' ';
669  $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref.' '.$data->label_operation, 20), 20);
670 
671  // Credit invoice - invert sens
672  /*
673  if ($data->montant < 0) {
674  if ($data->sens == 'C') {
675  $Tab['sens'] = 'D';
676  } else {
677  $Tab['sens'] = 'C';
678  }
679  $Tab['signe_montant'] = '-';
680  } else {
681  $Tab['sens'] = $data->sens; // C or D
682  $Tab['signe_montant'] = '+';
683  }*/
684  $Tab['sens'] = $data->sens; // C or D
685  $Tab['signe_montant'] = '+';
686 
687  // The amount must be in centimes without decimal points.
688  $Tab['montant'] = str_pad(abs(($data->debit - $data->credit) * 100), 12, '0', STR_PAD_LEFT);
689  $Tab['contrepartie'] = str_repeat(' ', 8);
690 
691  // Force date format : %d%m%y
692  if (!empty($data->date_lim_reglement)) {
693  //$Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, $conf->global->ACCOUNTING_EXPORT_DATE);
694  $Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, '%d%m%y'); // Format must be ddmmyy
695  } else {
696  $Tab['date_echeance'] = '000000';
697  }
698 
699  // Please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5)
700  // $Tab['lettrage'] = str_repeat(' ', 5);
701  $Tab['lettrage'] = str_repeat(' ', 2);
702  $Tab['codestat'] = str_repeat(' ', 3);
703  $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5);
704 
705  // Keep correct quadra named field instead of anon filler
706  // $Tab['filler2'] = str_repeat(' ', 20);
707  $Tab['affaire'] = str_repeat(' ', 10);
708  $Tab['quantity1'] = str_repeat(' ', 10);
709  $Tab['num_piece2'] = str_pad(self::trunc($data->piece_num, 8), 8);
710  $Tab['devis'] = str_pad($conf->currency, 3);
711  $Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3);
712  $Tab['filler3'] = str_repeat(' ', 3);
713 
714  // Keep correct quadra named field instead of anon filler libelle_ecriture2 is 30 char not 32 !!!!
715  // 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
716  // TODO: we should filter more than only accent to avoid wrong line size
717  // TODO: remove invoice number doc_ref in libelle,
718  // TODO: we should offer an option for customer to build the libelle using invoice number / name / date in accounting software
719  //$Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_operation, 30), 30);
720  $Tab['libelle_ecriture2'] = str_pad(self::trunc($data->label_operation, 30), 30);
721  $Tab['codetva'] = str_repeat(' ', 2);
722 
723  // We need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part
724  // $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10);
725  $Tab['num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10);
726  $Tab['filler4'] = str_repeat(' ', 73);
727 
728  $Tab['end_line'] = $end_line;
729 
730  print implode($Tab);
731  }
732  }
733 
744  public function exportWinfic(&$TData)
745  {
746  global $conf;
747 
748  $end_line = "\r\n";
749  $index = 1;
750 
751  //We should use dol_now function not time however this is wrong date to transfert in accounting
752  //$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
753  //$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
754 
755  // Warning ! When truncation is necessary, no dot because 3 dots = three characters. The columns are shifted
756 
757  foreach ($TData as $data) {
758  $code_compta = $data->numero_compte;
759  if (!empty($data->subledger_account)) {
760  $code_compta = $data->subledger_account;
761  }
762 
763  $Tab = array();
764  //$Tab['type_ligne'] = 'M';
765  $Tab['code_journal'] = str_pad(dol_trunc($data->code_journal, 2, 'right', 'UTF-8', 1), 2);
766 
767  //We use invoice date $data->doc_date not $date_ecriture which is the transfert date
768  //maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ?
769  //$Tab['date_ecriture'] = $date_ecriture;
770  $Tab['date_operation'] = dol_print_date($data->doc_date, '%d%m%Y');
771 
772  $Tab['folio'] = ' 1';
773 
774  $Tab['num_ecriture'] = str_pad(dol_trunc($index, 6, 'right', 'UTF-8', 1), 6, ' ', STR_PAD_LEFT);
775 
776  $Tab['jour_ecriture'] = dol_print_date($data->doc_date, '%d%m%y');
777 
778  $Tab['num_compte'] = str_pad(dol_trunc($code_compta, 6, 'right', 'UTF-8', 1), 6, '0');
779 
780  if ($data->sens == 'D') {
781  $Tab['montant_debit'] = str_pad(number_format($data->debit, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
782 
783  $Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
784  } else {
785  $Tab['montant_debit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
786 
787  $Tab['montant_crebit'] = str_pad(number_format($data->credit, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
788  }
789 
790  $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);
791 
792  $Tab['lettrage'] = str_repeat(dol_trunc($data->lettering_code, 2, 'left', 'UTF-8', 1), 2);
793 
794  $Tab['code_piece'] = str_pad(dol_trunc($data->piece_num, 5, 'left', 'UTF-8', 1), 5, ' ', STR_PAD_LEFT);
795 
796  $Tab['code_stat'] = str_repeat(' ', 4);
797 
798  if (!empty($data->date_lim_reglement)) {
799  //$Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, $conf->global->ACCOUNTING_EXPORT_DATE);
800  $Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, '%d%m%Y');
801  } else {
802  $Tab['date_echeance'] = dol_print_date($data->doc_date, '%d%m%Y');
803  }
804 
805  $Tab['monnaie'] = '1';
806 
807  $Tab['filler'] = ' ';
808 
809  $Tab['ind_compteur'] = ' ';
810 
811  $Tab['quantite'] = '0,000000000';
812 
813  $Tab['code_pointage'] = str_repeat(' ', 2);
814 
815  $Tab['end_line'] = $end_line;
816 
817  print implode('|', $Tab);
818 
819  $index++;
820  }
821  }
822 
823 
830  public function exportEbp($objectLines)
831  {
832 
833  $separator = ',';
834  $end_line = "\n";
835 
836  foreach ($objectLines as $line) {
837  $date = dol_print_date($line->doc_date, '%d%m%Y');
838 
839  print $line->id.$separator;
840  print $date.$separator;
841  print $line->code_journal.$separator;
842  if (empty($line->subledger_account)) {
843  print $line->numero_compte.$separator;
844  } else {
845  print $line->subledger_account.$separator;
846  }
847  //print substr(length_accountg($line->numero_compte), 0, 2) . $separator;
848  print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator;
849  print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator;
850  print price2num(abs($line->debit - $line->credit)).$separator;
851  print $line->sens.$separator;
852  print $date.$separator;
853  //print 'EUR';
854  print $end_line;
855  }
856  }
857 
858 
865  public function exportAgiris($objectLines)
866  {
867 
868  $separator = ';';
869  $end_line = "\n";
870 
871  foreach ($objectLines as $line) {
872  $date = dol_print_date($line->doc_date, '%d%m%Y');
873 
874  print $line->piece_num.$separator;
875  print self::toAnsi($line->label_operation).$separator;
876  print $date.$separator;
877  print self::toAnsi($line->label_operation).$separator;
878 
879  if (empty($line->subledger_account)) {
880  print length_accountg($line->numero_compte).$separator;
881  print self::toAnsi($line->label_compte).$separator;
882  } else {
883  print length_accounta($line->subledger_account).$separator;
884  print self::toAnsi($line->subledger_label).$separator;
885  }
886 
887  print self::toAnsi($line->doc_ref).$separator;
888  print price($line->debit).$separator;
889  print price($line->credit).$separator;
890  print price(abs($line->debit - $line->credit)).$separator;
891  print $line->sens.$separator;
892  print $line->lettering_code.$separator;
893  print $line->code_journal;
894  print $end_line;
895  }
896  }
897 
904  public function exportOpenConcerto($objectLines)
905  {
906 
907  $separator = ';';
908  $end_line = "\n";
909 
910  foreach ($objectLines as $line) {
911  $date = dol_print_date($line->doc_date, '%d/%m/%Y');
912 
913  print $date.$separator;
914  print $line->code_journal.$separator;
915  if (empty($line->subledger_account)) {
916  print length_accountg($line->numero_compte).$separator;
917  } else {
918  print length_accounta($line->subledger_account).$separator;
919  }
920  print $line->doc_ref.$separator;
921  print $line->label_operation.$separator;
922  print price($line->debit).$separator;
923  print price($line->credit).$separator;
924 
925  print $end_line;
926  }
927  }
928 
935  public function exportConfigurable($objectLines)
936  {
937  global $conf;
938 
939  $separator = $this->separator;
940 
941  foreach ($objectLines as $line) {
942  $tab = array();
943  // export configurable
944  $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
945  $tab[] = $line->piece_num;
946  $tab[] = $date;
947  $tab[] = $line->doc_ref;
948  $tab[] = preg_match('/'.$separator.'/', $line->label_operation) ? "'".$line->label_operation."'" : $line->label_operation;
949  $tab[] = length_accountg($line->numero_compte);
950  $tab[] = length_accounta($line->subledger_account);
951  $tab[] = price2num($line->debit);
952  $tab[] = price2num($line->credit);
953  $tab[] = price2num($line->debit - $line->credit);
954  $tab[] = $line->code_journal;
955 
956  print implode($separator, $tab).$this->end_line;
957  }
958  }
959 
966  public function exportFEC($objectLines)
967  {
968  global $langs;
969 
970  $separator = "\t";
971  $end_line = "\r\n";
972 
973  print "JournalCode".$separator;
974  print "JournalLib".$separator;
975  print "EcritureNum".$separator;
976  print "EcritureDate".$separator;
977  print "CompteNum".$separator;
978  print "CompteLib".$separator;
979  print "CompAuxNum".$separator;
980  print "CompAuxLib".$separator;
981  print "PieceRef".$separator;
982  print "PieceDate".$separator;
983  print "EcritureLib".$separator;
984  print "Debit".$separator;
985  print "Credit".$separator;
986  print "EcritureLet".$separator;
987  print "DateLet".$separator;
988  print "ValidDate".$separator;
989  print "Montantdevise".$separator;
990  print "Idevise".$separator;
991  print "DateLimitReglmt".$separator;
992  print "NumFacture";
993  print $end_line;
994 
995  foreach ($objectLines as $line) {
996  if ($line->debit == 0 && $line->credit == 0) {
997  //unset($array[$line]);
998  } else {
999  $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
1000  $date_document = dol_print_date($line->doc_date, '%Y%m%d');
1001  $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
1002  $date_validation = dol_print_date($line->date_validation, '%Y%m%d');
1003  $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
1004 
1005  $refInvoice = '';
1006  if ($line->doc_type == 'customer_invoice') {
1007  // Customer invoice
1008  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1009  $invoice = new Facture($this->db);
1010  $invoice->fetch($line->fk_doc);
1011 
1012  $refInvoice = $invoice->ref;
1013  } elseif ($line->doc_type == 'supplier_invoice') {
1014  // Supplier invoice
1015  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1016  $invoice = new FactureFournisseur($this->db);
1017  $invoice->fetch($line->fk_doc);
1018 
1019  $refInvoice = $invoice->ref_supplier;
1020  }
1021 
1022  // FEC:JournalCode
1023  print $line->code_journal . $separator;
1024 
1025  // FEC:JournalLib
1026  $labeljournal = dol_string_unaccent($langs->transnoentities($line->journal_label));
1027  $labeljournal = dol_string_nospecial($labeljournal, ' ');
1028  print $labeljournal . $separator;
1029 
1030  // FEC:EcritureNum
1031  print $line->piece_num . $separator;
1032 
1033  // FEC:EcritureDate
1034  print $date_document . $separator;
1035 
1036  // FEC:CompteNum
1037  print length_accountg($line->numero_compte) . $separator;
1038 
1039  // FEC:CompteLib
1040  print dol_string_unaccent($line->label_compte) . $separator;
1041 
1042  // FEC:CompAuxNum
1043  print length_accounta($line->subledger_account) . $separator;
1044 
1045  // FEC:CompAuxLib
1046  print dol_string_unaccent($line->subledger_label) . $separator;
1047 
1048  // FEC:PieceRef
1049  print $line->doc_ref . $separator;
1050 
1051  // FEC:PieceDate
1052  print dol_string_unaccent($date_creation) . $separator;
1053 
1054  // FEC:EcritureLib
1055  // Clean label operation to prevent problem on export with tab separator & other character
1056  $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
1057  print dol_string_unaccent($line->label_operation) . $separator;
1058 
1059  // FEC:Debit
1060  print price2fec($line->debit) . $separator;
1061 
1062  // FEC:Credit
1063  print price2fec($line->credit) . $separator;
1064 
1065  // FEC:EcritureLet
1066  print $line->lettering_code . $separator;
1067 
1068  // FEC:DateLet
1069  print $date_lettering . $separator;
1070 
1071  // FEC:ValidDate
1072  print $date_validation . $separator;
1073 
1074  // FEC:Montantdevise
1075  print $line->multicurrency_amount . $separator;
1076 
1077  // FEC:Idevise
1078  print $line->multicurrency_code . $separator;
1079 
1080  // FEC_suppl:DateLimitReglmt
1081  print $date_limit_payment . $separator;
1082 
1083  // FEC_suppl:NumFacture
1084  // Clean ref invoice to prevent problem on export with tab separator & other character
1085  $refInvoice = str_replace(array("\t", "\n", "\r"), " ", $refInvoice);
1086  print dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1);
1087 
1088  print $end_line;
1089  }
1090  }
1091  }
1092 
1099  public function exportFEC2($objectLines)
1100  {
1101  global $langs;
1102 
1103  $separator = "\t";
1104  $end_line = "\r\n";
1105 
1106  print "JournalCode".$separator;
1107  print "JournalLib".$separator;
1108  print "EcritureNum".$separator;
1109  print "EcritureDate".$separator;
1110  print "CompteNum".$separator;
1111  print "CompteLib".$separator;
1112  print "CompAuxNum".$separator;
1113  print "CompAuxLib".$separator;
1114  print "PieceRef".$separator;
1115  print "PieceDate".$separator;
1116  print "EcritureLib".$separator;
1117  print "Debit".$separator;
1118  print "Credit".$separator;
1119  print "EcritureLet".$separator;
1120  print "DateLet".$separator;
1121  print "ValidDate".$separator;
1122  print "Montantdevise".$separator;
1123  print "Idevise".$separator;
1124  print "DateLimitReglmt".$separator;
1125  print "NumFacture";
1126  print $end_line;
1127 
1128  foreach ($objectLines as $line) {
1129  if ($line->debit == 0 && $line->credit == 0) {
1130  //unset($array[$line]);
1131  } else {
1132  $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
1133  $date_document = dol_print_date($line->doc_date, '%Y%m%d');
1134  $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
1135  $date_validation = dol_print_date($line->date_validation, '%Y%m%d');
1136  $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
1137 
1138  $refInvoice = '';
1139  if ($line->doc_type == 'customer_invoice') {
1140  // Customer invoice
1141  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1142  $invoice = new Facture($this->db);
1143  $invoice->fetch($line->fk_doc);
1144 
1145  $refInvoice = $invoice->ref;
1146  } elseif ($line->doc_type == 'supplier_invoice') {
1147  // Supplier invoice
1148  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1149  $invoice = new FactureFournisseur($this->db);
1150  $invoice->fetch($line->fk_doc);
1151 
1152  $refInvoice = $invoice->ref_supplier;
1153  }
1154 
1155  // FEC:JournalCode
1156  print $line->code_journal . $separator;
1157 
1158  // FEC:JournalLib
1159  $labeljournal = dol_string_unaccent($langs->transnoentities($line->journal_label));
1160  $labeljournal = dol_string_nospecial($labeljournal, ' ');
1161  print $labeljournal . $separator;
1162 
1163  // FEC:EcritureNum
1164  print $line->piece_num . $separator;
1165 
1166  // FEC:EcritureDate
1167  print $date_creation . $separator;
1168 
1169  // FEC:CompteNum
1170  print length_accountg($line->numero_compte) . $separator;
1171 
1172  // FEC:CompteLib
1173  print dol_string_unaccent($line->label_compte) . $separator;
1174 
1175  // FEC:CompAuxNum
1176  print length_accounta($line->subledger_account) . $separator;
1177 
1178  // FEC:CompAuxLib
1179  print dol_string_unaccent($line->subledger_label) . $separator;
1180 
1181  // FEC:PieceRef
1182  print $line->doc_ref . $separator;
1183 
1184  // FEC:PieceDate
1185  print $date_document . $separator;
1186 
1187  // FEC:EcritureLib
1188  // Clean label operation to prevent problem on export with tab separator & other character
1189  $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
1190  print dol_string_unaccent($line->label_operation) . $separator;
1191 
1192  // FEC:Debit
1193  print price2fec($line->debit) . $separator;
1194 
1195  // FEC:Credit
1196  print price2fec($line->credit) . $separator;
1197 
1198  // FEC:EcritureLet
1199  print $line->lettering_code . $separator;
1200 
1201  // FEC:DateLet
1202  print $date_lettering . $separator;
1203 
1204  // FEC:ValidDate
1205  print $date_validation . $separator;
1206 
1207  // FEC:Montantdevise
1208  print $line->multicurrency_amount . $separator;
1209 
1210  // FEC:Idevise
1211  print $line->multicurrency_code . $separator;
1212 
1213  // FEC_suppl:DateLimitReglmt
1214  print $date_limit_payment . $separator;
1215 
1216  // FEC_suppl:NumFacture
1217  // Clean ref invoice to prevent problem on export with tab separator & other character
1218  $refInvoice = str_replace(array("\t", "\n", "\r"), " ", $refInvoice);
1219  print dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1);
1220 
1221 
1222  print $end_line;
1223  }
1224  }
1225  }
1226 
1237  public function exportSAGE50SWISS($objectLines)
1238  {
1239  // SAGE50SWISS
1240  $this->separator = ',';
1241  $this->end_line = "\r\n";
1242 
1243  // Print header line
1244  print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag";
1245  print $this->end_line;
1246  $thisPieceNum = "";
1247  $thisPieceAccountNr = "";
1248  $aSize = count($objectLines);
1249  foreach ($objectLines as $aIndex => $line) {
1250  $sammelBuchung = false;
1251  if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) {
1252  $sammelBuchung = true;
1253  } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) {
1254  $sammelBuchung = true;
1255  } elseif ($aIndex + 1 < $aSize
1256  && $objectLines[$aIndex + 1]->piece_num == $line->piece_num
1257  && $aIndex - 1 < $aSize
1258  && $objectLines[$aIndex - 1]->piece_num == $line->piece_num
1259  ) {
1260  $sammelBuchung = true;
1261  }
1262 
1263  //Blg
1264  print $line->piece_num.$this->separator;
1265 
1266  // Datum
1267  $date = dol_print_date($line->doc_date, '%d.%m.%Y');
1268  print $date.$this->separator;
1269 
1270  // Kto
1271  print length_accountg($line->numero_compte).$this->separator;
1272  // S/H
1273  if ($line->sens == 'D') {
1274  print 'S'.$this->separator;
1275  } else {
1276  print 'H'.$this->separator;
1277  }
1278  //Grp
1279  print self::trunc($line->code_journal, 1).$this->separator;
1280  // GKto
1281  if (empty($line->code_tiers)) {
1282  if ($line->piece_num == $thisPieceNum) {
1283  print length_accounta($thisPieceAccountNr).$this->separator;
1284  } else {
1285  print "div".$this->separator;
1286  }
1287  } else {
1288  print length_accounta($line->code_tiers).$this->separator;
1289  }
1290  //SId
1291  print $this->separator;
1292  //SIdx
1293  print "0".$this->separator;
1294  //KIdx
1295  print "0".$this->separator;
1296  //BTyp
1297  print "0".$this->separator;
1298 
1299  //MTyp 1=Fibu Einzelbuchung 2=Sammebuchung
1300  if ($sammelBuchung) {
1301  print "2".$this->separator;
1302  } else {
1303  print "1".$this->separator;
1304  }
1305  // Code
1306  print '""'.$this->separator;
1307  // Netto
1308  print abs($line->debit - $line->credit).$this->separator;
1309  // Steuer
1310  print "0.00".$this->separator;
1311  // FW-Betrag
1312  print "0.00".$this->separator;
1313  // Tx1
1314  $line1 = self::toAnsi($line->label_compte, 29);
1315  if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) {
1316  $line1 = "";
1317  }
1318  $line2 = self::toAnsi($line->doc_ref, 29);
1319  if (strlen($line1) == 0) {
1320  $line1 = $line2;
1321  $line2 = "";
1322  }
1323  if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) {
1324  $line1 = $line1.' / '.$line2;
1325  $line2 = "";
1326  }
1327 
1328  print '"'.self::toAnsi($line1).'"'.$this->separator;
1329  // Tx2
1330  print '"'.self::toAnsi($line2).'"'.$this->separator;
1331  //PkKey
1332  print "0".$this->separator;
1333  //OpId
1334  print $this->separator;
1335 
1336  // Flag
1337  print "0";
1338 
1339  print $this->end_line;
1340 
1341  if ($line->piece_num !== $thisPieceNum) {
1342  $thisPieceNum = $line->piece_num;
1343  $thisPieceAccountNr = $line->numero_compte;
1344  }
1345  }
1346  }
1347 
1356  public function exportLDCompta($objectLines)
1357  {
1358 
1359  $separator = ';';
1360  $end_line = "\r\n";
1361 
1362  foreach ($objectLines as $line) {
1363  $date_document = dol_print_date($line->doc_date, '%Y%m%d');
1364  $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
1365  $date_lim_reglement = dol_print_date($line->date_lim_reglement, '%Y%m%d');
1366 
1367  // TYPE
1368  $type_enregistrement = 'E'; // For write movement
1369  print $type_enregistrement.$separator;
1370  // JNAL
1371  print substr($line->code_journal, 0, 2).$separator;
1372  // NECR
1373  print $line->id.$separator;
1374  // NPIE
1375  print $line->piece_num.$separator;
1376  // DATP
1377  print $date_document.$separator;
1378  // LIBE
1379  print $line->label_operation.$separator;
1380  // DATH
1381  print $date_lim_reglement.$separator;
1382  // CNPI
1383  if ($line->doc_type == 'supplier_invoice') {
1384  if (($line->debit - $line->credit) > 0) {
1385  $nature_piece = 'AF';
1386  } else {
1387  $nature_piece = 'FF';
1388  }
1389  } elseif ($line->doc_type == 'customer_invoice') {
1390  if (($line->debit - $line->credit) < 0) {
1391  $nature_piece = 'AC';
1392  } else {
1393  $nature_piece = 'FC';
1394  }
1395  } else {
1396  $nature_piece = '';
1397  }
1398  print $nature_piece.$separator;
1399  // RACI
1400  // if (!empty($line->subledger_account)) {
1401  // if ($line->doc_type == 'supplier_invoice') {
1402  // $racine_subledger_account = '40';
1403  // } elseif ($line->doc_type == 'customer_invoice') {
1404  // $racine_subledger_account = '41';
1405  // } else {
1406  // $racine_subledger_account = '';
1407  // }
1408  // } else {
1409  $racine_subledger_account = ''; // for records of type E leave this field blank
1410  // }
1411 
1412  print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead
1413  // MONT
1414  print price(abs($line->debit - $line->credit), 0, '', 1, 2, 2).$separator;
1415  // CODC
1416  print $line->sens.$separator;
1417  // CPTG
1418  print length_accountg($line->numero_compte).$separator;
1419  // DATE
1420  print $date_creation.$separator;
1421  // CLET
1422  print $line->lettering_code.$separator;
1423  // DATL
1424  print $line->date_lettering.$separator;
1425  // CPTA
1426  if (!empty($line->subledger_account)) {
1427  print length_accounta($line->subledger_account).$separator;
1428  } else {
1429  print $separator;
1430  }
1431  // CNAT
1432  if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) {
1433  print 'F'.$separator;
1434  } elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) {
1435  print 'C'.$separator;
1436  } else {
1437  print $separator;
1438  }
1439  // SECT
1440  print $separator;
1441  // CTRE
1442  print $separator;
1443  // NORL
1444  print $separator;
1445  // DATV
1446  print $separator;
1447  // REFD
1448  print $line->doc_ref.$separator;
1449  // CODH
1450  print $separator;
1451  // NSEQ
1452  print $separator;
1453  // MTDV
1454  print '0'.$separator;
1455  // CODV
1456  print $separator;
1457  // TXDV
1458  print '0'.$separator;
1459  // MOPM
1460  print $separator;
1461  // BONP
1462  print $separator;
1463  // BQAF
1464  print $separator;
1465  // ECES
1466  print $separator;
1467  // TXTL
1468  print $separator;
1469  // ECRM
1470  print $separator;
1471  // DATK
1472  print $separator;
1473  // HEUK
1474  print $separator;
1475 
1476  print $end_line;
1477  }
1478  }
1479 
1490  public function exportLDCompta10($objectLines)
1491  {
1492  require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
1493 
1494  $separator = ';';
1495  $end_line = "\r\n";
1496  $last_codeinvoice = '';
1497 
1498  foreach ($objectLines as $line) {
1499  // TYPE C
1500  if ($last_codeinvoice != $line->doc_ref) {
1501  //recherche societe en fonction de son code client
1502  $sql = "SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX."societe";
1503  $sql .= " WHERE code_client = '".$this->db->escape($line->thirdparty_code)."'";
1504  $resql = $this->db->query($sql);
1505 
1506  if ($resql && $this->db->num_rows($resql) > 0) {
1507  $soc = $this->db->fetch_object($resql);
1508 
1509  $address = array('', '', '');
1510  if (strpos($soc->address, "\n") !== false) {
1511  $address = explode("\n", $soc->address);
1512  if (is_array($address) && count($address) > 0) {
1513  foreach ($address as $key => $data) {
1514  $address[$key] = str_replace(array("\t", "\n", "\r"), "", $data);
1515  $address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1);
1516  }
1517  }
1518  } else {
1519  $address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40);
1520  $address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40);
1521  $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40);
1522  }
1523 
1524  $type_enregistrement = 'C';
1525  //TYPE
1526  print $type_enregistrement.$separator;
1527  //NOCL
1528  print $soc->code_client.$separator;
1529  //NMCM
1530  print $separator;
1531  //LIBI
1532  print $separator;
1533  //TITR
1534  print $separator;
1535  //RSSO
1536  print $soc->nom.$separator;
1537  //CAD1
1538  print $address[0].$separator;
1539  //CAD2
1540  print $address[1].$separator;
1541  //CAD3
1542  print $address[2].$separator;
1543  //COPO
1544  print $soc->zip.$separator;
1545  //BUDI
1546  print substr($soc->town, 0, 40).$separator;
1547  //CPAY
1548  print $separator;
1549  //PAYS
1550  print substr(getCountry($soc->fk_pays), 0, 40).$separator;
1551  //NTEL
1552  print $soc->phone.$separator;
1553  //TLEX
1554  print $separator;
1555  //TLPO
1556  print $separator;
1557  //TLCY
1558  print $separator;
1559  //NINT
1560  print $separator;
1561  //COMM
1562  print $separator;
1563  //SIRE
1564  print str_replace(" ", "", $soc->siret).$separator;
1565  //RIBP
1566  print $separator;
1567  //DOBQ
1568  print $separator;
1569  //IBBQ
1570  print $separator;
1571  //COBQ
1572  print $separator;
1573  //GUBQ
1574  print $separator;
1575  //CPBQ
1576  print $separator;
1577  //CLBQ
1578  print $separator;
1579  //BIBQ
1580  print $separator;
1581  //MOPM
1582  print $separator;
1583  //DJPM
1584  print $separator;
1585  //DMPM
1586  print $separator;
1587  //REFM
1588  print $separator;
1589  //SLVA
1590  print $separator;
1591  //PLCR
1592  print $separator;
1593  //ECFI
1594  print $separator;
1595  //CREP
1596  print $separator;
1597  //NREP
1598  print $separator;
1599  //TREP
1600  print $separator;
1601  //MREP
1602  print $separator;
1603  //GRRE
1604  print $separator;
1605  //LTTA
1606  print $separator;
1607  //CACT
1608  print $separator;
1609  //CODV
1610  print $separator;
1611  //GRTR
1612  print $separator;
1613  //NOFP
1614  print $separator;
1615  //BQAF
1616  print $separator;
1617  //BONP
1618  print $separator;
1619  //CESC
1620  print $separator;
1621 
1622  print $end_line;
1623  }
1624  }
1625 
1626  $date_document = dol_print_date($line->doc_date, '%Y%m%d');
1627  $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
1628  $date_lim_reglement = dol_print_date($line->date_lim_reglement, '%Y%m%d');
1629 
1630  // TYPE E
1631  $type_enregistrement = 'E'; // For write movement
1632  print $type_enregistrement.$separator;
1633  // JNAL
1634  print substr($line->code_journal, 0, 2).$separator;
1635  // NECR
1636  print $line->id.$separator;
1637  // NPIE
1638  print $line->piece_num.$separator;
1639  // DATP
1640  print $date_document.$separator;
1641  // LIBE
1642  print dol_trunc($line->label_operation, 25, 'right', 'UTF-8', 1).$separator;
1643  // DATH
1644  print $date_lim_reglement.$separator;
1645  // CNPI
1646  if ($line->doc_type == 'supplier_invoice') {
1647  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.
1648  $nature_piece = 'AF';
1649  } else {
1650  $nature_piece = 'FF';
1651  }
1652  } elseif ($line->doc_type == 'customer_invoice') {
1653  if (($line->amount) < 0) {
1654  $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.
1655  } else {
1656  $nature_piece = 'FC';
1657  }
1658  } else {
1659  $nature_piece = '';
1660  }
1661  print $nature_piece.$separator;
1662  // RACI
1663  // if (!empty($line->subledger_account)) {
1664  // if ($line->doc_type == 'supplier_invoice') {
1665  // $racine_subledger_account = '40';
1666  // } elseif ($line->doc_type == 'customer_invoice') {
1667  // $racine_subledger_account = '41';
1668  // } else {
1669  // $racine_subledger_account = '';
1670  // }
1671  // } else {
1672  $racine_subledger_account = ''; // for records of type E leave this field blank
1673  // }
1674 
1675  print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead
1676  // MONT
1677  print price(abs($line->debit - $line->credit), 0, '', 1, 2).$separator;
1678  // CODC
1679  print $line->sens.$separator;
1680  // CPTG
1681  print length_accountg($line->numero_compte).$separator;
1682  // DATE
1683  print $date_document.$separator;
1684  // CLET
1685  print $line->lettering_code.$separator;
1686  // DATL
1687  print $line->date_lettering.$separator;
1688  // CPTA
1689  if (!empty($line->subledger_account)) {
1690  print length_accounta($line->subledger_account).$separator;
1691  } else {
1692  print $separator;
1693  }
1694  // CNAT
1695  if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) {
1696  print 'F'.$separator;
1697  } elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) {
1698  print 'C'.$separator;
1699  } else {
1700  print $separator;
1701  }
1702  // CTRE
1703  print $separator;
1704  // NORL
1705  print $separator;
1706  // DATV
1707  print $separator;
1708  // REFD
1709  print $line->doc_ref.$separator;
1710  // NECA
1711  print '0'.$separator;
1712  // CSEC
1713  print $separator;
1714  // CAFF
1715  print $separator;
1716  // CDES
1717  print $separator;
1718  // QTUE
1719  print $separator;
1720  // MTDV
1721  print '0'.$separator;
1722  // CODV
1723  print $separator;
1724  // TXDV
1725  print '0'.$separator;
1726  // MOPM
1727  print $separator;
1728  // BONP
1729  print $separator;
1730  // BQAF
1731  print $separator;
1732  // ECES
1733  print $separator;
1734  // TXTL
1735  print $separator;
1736  // ECRM
1737  print $separator;
1738  // DATK
1739  print $separator;
1740  // HEUK
1741  print $separator;
1742 
1743  print $end_line;
1744 
1745  $last_codeinvoice = $line->doc_ref;
1746  }
1747  }
1748 
1755  public function exportCharlemagne($objectLines)
1756  {
1757  global $langs;
1758  $langs->load('compta');
1759 
1760  $separator = "\t";
1761  $end_line = "\n";
1762 
1763  /*
1764  * Charlemagne export need header
1765  */
1766  print $langs->transnoentitiesnoconv('Date').$separator;
1767  print self::trunc($langs->transnoentitiesnoconv('Journal'), 6).$separator;
1768  print self::trunc($langs->transnoentitiesnoconv('Account'), 15).$separator;
1769  print self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60).$separator;
1770  print self::trunc($langs->transnoentitiesnoconv('Piece'), 20).$separator;
1771  print self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60).$separator;
1772  print $langs->transnoentitiesnoconv('Amount').$separator;
1773  print 'S'.$separator;
1774  print self::trunc($langs->transnoentitiesnoconv('Analytic').' 1', 15).$separator;
1775  print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 1', 60).$separator;
1776  print self::trunc($langs->transnoentitiesnoconv('Analytic').' 2', 15).$separator;
1777  print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 2', 60).$separator;
1778  print self::trunc($langs->transnoentitiesnoconv('Analytic').' 3', 15).$separator;
1779  print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 3', 60).$separator;
1780  print $end_line;
1781 
1782  foreach ($objectLines as $line) {
1783  $date = dol_print_date($line->doc_date, '%Y%m%d');
1784  print $date.$separator; //Date
1785 
1786  print self::trunc($line->code_journal, 6).$separator; //Journal code
1787 
1788  if (!empty($line->subledger_account)) {
1789  $account = $line->subledger_account;
1790  } else {
1791  $account = $line->numero_compte;
1792  }
1793  print self::trunc($account, 15).$separator; //Account number
1794 
1795  print self::trunc($line->label_compte, 60).$separator; //Account label
1796  print self::trunc($line->doc_ref, 20).$separator; //Piece
1797  // Clean label operation to prevent problem on export with tab separator & other character
1798  $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
1799  print self::trunc($line->label_operation, 60).$separator; //Operation label
1800  print price(abs($line->debit - $line->credit)).$separator; //Amount
1801  print $line->sens.$separator; //Direction
1802  print $separator; //Analytic
1803  print $separator; //Analytic
1804  print $separator; //Analytic
1805  print $separator; //Analytic
1806  print $separator; //Analytic
1807  print $separator; //Analytic
1808  print $end_line;
1809  }
1810  }
1811 
1819  public function exportGestimumV3($objectLines)
1820  {
1821  global $langs;
1822 
1823  $this->separator = ',';
1824 
1825  $invoices_infos = array();
1826  $supplier_invoices_infos = array();
1827  foreach ($objectLines as $line) {
1828  if ($line->debit == 0 && $line->credit == 0) {
1829  //unset($array[$line]);
1830  } else {
1831  $date = dol_print_date($line->doc_date, '%d/%m/%Y');
1832 
1833  $invoice_ref = $line->doc_ref;
1834  $company_name = "";
1835 
1836  if (($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice') && $line->fk_doc > 0) {
1837  if (($line->doc_type == 'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) ||
1838  ($line->doc_type == 'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) {
1839  if ($line->doc_type == 'customer_invoice') {
1840  // Get new customer invoice ref and company name
1841  $sql = 'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f';
1842  $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid';
1843  $sql .= ' WHERE f.rowid = '.((int) $line->fk_doc);
1844  $resql = $this->db->query($sql);
1845  if ($resql) {
1846  if ($obj = $this->db->fetch_object($resql)) {
1847  // Save invoice infos
1848  $invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom);
1849  $invoice_ref = $obj->ref;
1850  $company_name = $obj->nom;
1851  }
1852  }
1853  } else {
1854  // Get new supplier invoice ref and company name
1855  $sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff';
1856  $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid';
1857  $sql .= ' WHERE ff.rowid = '.((int) $line->fk_doc);
1858  $resql = $this->db->query($sql);
1859  if ($resql) {
1860  if ($obj = $this->db->fetch_object($resql)) {
1861  // Save invoice infos
1862  $supplier_invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom);
1863  $invoice_ref = $obj->ref;
1864  $company_name = $obj->nom;
1865  }
1866  }
1867  }
1868  } elseif ($line->doc_type == 'customer_invoice') {
1869  // Retrieve invoice infos
1870  $invoice_ref = $invoices_infos[$line->fk_doc]['ref'];
1871  $company_name = $invoices_infos[$line->fk_doc]['company_name'];
1872  } else {
1873  // Retrieve invoice infos
1874  $invoice_ref = $supplier_invoices_infos[$line->fk_doc]['ref'];
1875  $company_name = $supplier_invoices_infos[$line->fk_doc]['company_name'];
1876  }
1877  }
1878 
1879  print $line->id . $this->separator;
1880  print $date . $this->separator;
1881  print substr($line->code_journal, 0, 4) . $this->separator;
1882 
1883  if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) {
1884  print length_accountg($line->subledger_account) . $this->separator;
1885  } else {
1886  print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator;
1887  }
1888  //Libellé Auto
1889  print $this->separator;
1890  //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator;
1891  //Libellé manuel
1892  print dol_trunc(str_replace('"', '', $invoice_ref . (!empty($company_name) ? ' - ' : '') . $company_name), 40, 'right', 'UTF-8', 1) . $this->separator;
1893  //Numéro de pièce
1894  print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator;
1895  //Devise
1896  print 'EUR' . $this->separator;
1897  //Amount
1898  print price2num(abs($line->debit - $line->credit)) . $this->separator;
1899  //Sens
1900  print $line->sens . $this->separator;
1901  //Code lettrage
1902  print $this->separator;
1903  //Date Echéance
1904  print $date;
1905  print $this->end_line;
1906  }
1907  }
1908  }
1909 
1917  public function exportGestimumV5($objectLines)
1918  {
1919 
1920  $this->separator = ',';
1921 
1922  foreach ($objectLines as $line) {
1923  if ($line->debit == 0 && $line->credit == 0) {
1924  //unset($array[$line]);
1925  } else {
1926  $date = dol_print_date($line->doc_date, '%d%m%Y');
1927 
1928  print $line->id . $this->separator;
1929  print $date . $this->separator;
1930  print substr($line->code_journal, 0, 4) . $this->separator;
1931  if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { // TODO No hard code value
1932  print length_accountg($line->subledger_account) . $this->separator;
1933  } else {
1934  print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator;
1935  }
1936  print $this->separator;
1937  //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator;
1938  print '"' . dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1) . '"' . $this->separator;
1939  print '"' . dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . '"' . $this->separator;
1940  print price2num(abs($line->debit - $line->credit)) . $this->separator;
1941  print $line->sens . $this->separator;
1942  print $date . $this->separator;
1943  print $this->separator;
1944  print $this->separator;
1945  print 'EUR';
1946  print $this->end_line;
1947  }
1948  }
1949  }
1950 
1960  public function exportiSuiteExpert($objectLines)
1961  {
1962  $this->separator = ';';
1963  $this->end_line = "\r\n";
1964 
1965 
1966  foreach ($objectLines as $line) {
1967  $tab = array();
1968 
1969  $date = dol_print_date($line->doc_date, '%d/%m/%Y');
1970 
1971  $tab[] = $line->piece_num;
1972  $tab[] = $date;
1973  $tab[] = substr($date, 6, 4);
1974  $tab[] = substr($date, 3, 2);
1975  $tab[] = substr($date, 0, 2);
1976  $tab[] = $line->doc_ref;
1977  //Conversion de chaine UTF8 en Latin9
1978  $tab[] = mb_convert_encoding(str_replace(' - Compte auxiliaire', '', $line->label_operation), "Windows-1252", 'UTF-8');
1979 
1980  //Calcul de la longueur des numéros de comptes
1981  $taille_numero = strlen(length_accountg($line->numero_compte));
1982 
1983  //Création du numéro de client générique
1984  $numero_cpt_client = '411';
1985  for ($i = 1; $i <= ($taille_numero - 3); $i++) {
1986  $numero_cpt_client .= '0';
1987  }
1988 
1989  //Création des comptes auxiliaire des clients
1990  if (length_accountg($line->numero_compte) == $numero_cpt_client) {
1991  $tab[] = rtrim(length_accounta($line->subledger_account), "0");
1992  } else {
1993  $tab[] = length_accountg($line->numero_compte);
1994  }
1995  $nom_client = explode(" - ", $line->label_operation);
1996  $tab[] = mb_convert_encoding($nom_client[0], "Windows-1252", 'UTF-8');
1997  $tab[] = price($line->debit);
1998  $tab[] = price($line->credit);
1999  $tab[] = price($line->montant);
2000  $tab[] = $line->code_journal;
2001 
2002  $separator = $this->separator;
2003  print implode($separator, $tab) . $this->end_line;
2004  }
2005  }
2006 
2014  public static function trunc($str, $size)
2015  {
2016  return dol_trunc($str, $size, 'right', 'UTF-8', 1);
2017  }
2018 
2026  public static function toAnsi($str, $size = -1)
2027  {
2028  $retVal = dol_string_nohtmltag($str, 1, 'Windows-1251');
2029  if ($retVal >= 0 && $size >= 0) {
2030  $retVal = mb_substr($retVal, 0, $size, 'Windows-1251');
2031  }
2032  return $retVal;
2033  }
2034 }
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
Manage the different format accountancy export.
exportAgiris($objectLines)
Export format : Agiris Isacompta.
exportWinfic(&$TData)
Export format : WinFic - eWinfic - WinSis Compta Last review for this format : 2022-11-01 Alexandre S...
exportEbp($objectLines)
Export format : EBP.
exportCiel(&$TData)
Export format : CIEL (Format XIMPORT) Format since 2003 compatible CIEL version > 2002 / Sage50 Last ...
getTypeConfig()
Array with all export type available (key + label) and parameters for config.
exportBob50($objectLines)
Export format : BOB50.
exportGestimumV5($objectLines)
Export format : Gestimum V5.
static trunc($str, $size)
trunc
exportLDCompta10($objectLines)
Export format : LD Compta version 10 & higher Last review for this format : 08-15-2021 Alexandre Span...
exportConfigurable($objectLines)
Export format : Configurable CSV.
exportCegid($objectLines)
Export format : CEGID.
static toAnsi($str, $size=-1)
toAnsi
getType()
Array with all export type available (key + label)
static getFormatCode($type)
Return string to summarize the format (Used to generated export filename)
exportLDCompta($objectLines)
Export format : LD Compta version 9 http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Docu...
exportCoala($objectLines)
Export format : COALA.
exportCogilog($objectLines)
Export format : COGILOG.
exportCharlemagne($objectLines)
Export format : Charlemagne.
exportFEC($objectLines)
Export format : FEC.
exportFEC2($objectLines)
Export format : FEC2.
__construct(DoliDB $db)
Constructor.
exportQuadratus(&$TData)
Export format : Quadratus (Format ASCII) Format since 2015 compatible QuadraCOMPTA Last review for th...
getMimeType($formatexportset)
Return the MIME type of a file.
exportSAGE50SWISS($objectLines)
Export format : SAGE50SWISS.
exportGestimumV3($objectLines)
Export format : Gestimum V3.
exportiSuiteExpert($objectLines)
Export format : iSuite Expert.
exportOpenConcerto($objectLines)
Export format : OpenConcerto.
export(&$TData, $formatexportset)
Function who chose which export to use with the default config, and make the export into a file.
Class to manage Dolibarr database access.
Class to manage suppliers invoices.
Class to manage invoices.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
price2fec($amount)
Function to format a value into a defined format for French administration (no thousand separator & d...
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='')
Clean a string from all punctuation characters to use it as a ref or login.
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.
$conf db
API class for accounts.
Definition: inc.php:41