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';
47 public static $EXPORT_TYPE_CONFIGURABLE = 1;
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;
66 public static $EXPORT_TYPE_FEC = 1000;
67 public static $EXPORT_TYPE_FEC2 = 1010;
77 public $errors = array();
83 public $separator =
'';
89 public $end_line =
'';
98 global $conf, $hookmanager;
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");
104 $hookmanager->initHooks(array(
'accountancyexport'));
114 global $langs, $hookmanager;
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',
140 $parameters = array();
141 $reshook = $hookmanager->executeHooks(
'getType', $parameters, $listofexporttypes);
143 ksort($listofexporttypes, SORT_NUMERIC);
145 return $listofexporttypes;
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',
180 $code = $formatcode[$type];
181 $parameters = array(
'type' => $type);
182 $reshook = $hookmanager->executeHooks(
'getFormatCode', $parameters, $code);
194 global $conf, $langs;
196 $exporttypes = 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,
205 self::$EXPORT_TYPE_CEGID => array(
206 'label' => $langs->trans(
'Modelcsv_CEGID'),
208 self::$EXPORT_TYPE_COALA => array(
209 'label' => $langs->trans(
'Modelcsv_COALA'),
211 self::$EXPORT_TYPE_BOB50 => array(
212 'label' => $langs->trans(
'Modelcsv_bob50'),
214 self::$EXPORT_TYPE_CIEL => array(
215 'label' => $langs->trans(
'Modelcsv_ciel'),
216 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
218 self::$EXPORT_TYPE_QUADRATUS => array(
219 'label' => $langs->trans(
'Modelcsv_quadratus'),
220 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
222 self::$EXPORT_TYPE_WINFIC => array(
223 'label' => $langs->trans(
'Modelcsv_winfic'),
224 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
226 self::$EXPORT_TYPE_EBP => array(
227 'label' => $langs->trans(
'Modelcsv_ebp'),
229 self::$EXPORT_TYPE_COGILOG => array(
230 'label' => $langs->trans(
'Modelcsv_cogilog'),
232 self::$EXPORT_TYPE_AGIRIS => array(
233 'label' => $langs->trans(
'Modelcsv_agiris'),
235 self::$EXPORT_TYPE_OPENCONCERTO => array(
236 'label' => $langs->trans(
'Modelcsv_openconcerto'),
238 self::$EXPORT_TYPE_SAGE50_SWISS => array(
239 'label' => $langs->trans(
'Modelcsv_Sage50_Swiss'),
241 self::$EXPORT_TYPE_CHARLEMAGNE => array(
242 'label' => $langs->trans(
'Modelcsv_charlemagne'),
243 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
245 self::$EXPORT_TYPE_LDCOMPTA => array(
246 'label' => $langs->trans(
'Modelcsv_LDCompta'),
248 self::$EXPORT_TYPE_LDCOMPTA10 => array(
249 'label' => $langs->trans(
'Modelcsv_LDCompta10'),
251 self::$EXPORT_TYPE_GESTIMUMV3 => array(
252 'label' => $langs->trans(
'Modelcsv_Gestinumv3'),
253 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
255 self::$EXPORT_TYPE_GESTIMUMV5 => array(
256 'label' => $langs->trans(
'Modelcsv_Gestinumv5'),
257 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
259 self::$EXPORT_TYPE_FEC => array(
260 'label' => $langs->trans(
'Modelcsv_FEC'),
261 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
263 self::$EXPORT_TYPE_FEC2 => array(
264 'label' => $langs->trans(
'Modelcsv_FEC2'),
265 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
267 self::$EXPORT_TYPE_ISUITEEXPERT => array(
268 'label' =>
'iSuite Expert',
269 'ACCOUNTING_EXPORT_FORMAT' =>
'csv',
273 '1' => $langs->trans(
"Unix"),
274 '2' => $langs->trans(
"Windows")
277 'csv' => $langs->trans(
"csv"),
278 'txt' => $langs->trans(
"txt")
283 $parameters = array();
284 $reshook = $hookmanager->executeHooks(
'getTypeConfig', $parameters, $exporttypes);
296 public function export(&$TData, $formatexportset)
298 global $conf, $langs;
299 global $search_date_end;
302 $filename =
'general_ledger-'.$this->getFormatCode($formatexportset);
303 $type_export =
'general_ledger';
306 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
309 switch ($formatexportset) {
310 case self::$EXPORT_TYPE_CONFIGURABLE:
313 case self::$EXPORT_TYPE_CEGID:
316 case self::$EXPORT_TYPE_COALA:
319 case self::$EXPORT_TYPE_BOB50:
322 case self::$EXPORT_TYPE_CIEL:
325 case self::$EXPORT_TYPE_QUADRATUS:
328 case self::$EXPORT_TYPE_WINFIC:
331 case self::$EXPORT_TYPE_EBP:
334 case self::$EXPORT_TYPE_COGILOG:
337 case self::$EXPORT_TYPE_AGIRIS:
340 case self::$EXPORT_TYPE_OPENCONCERTO:
343 case self::$EXPORT_TYPE_SAGE50_SWISS:
346 case self::$EXPORT_TYPE_CHARLEMAGNE:
349 case self::$EXPORT_TYPE_LDCOMPTA:
352 case self::$EXPORT_TYPE_LDCOMPTA10:
355 case self::$EXPORT_TYPE_GESTIMUMV3:
358 case self::$EXPORT_TYPE_GESTIMUMV5:
361 case self::$EXPORT_TYPE_FEC:
364 case self::$EXPORT_TYPE_FEC2:
367 case self::$EXPORT_TYPE_ISUITEEXPERT :
372 $parameters = array(
'format' => $formatexportset);
374 $reshook = $hookmanager->executeHooks(
'export', $parameters, $TData);
376 $this->errors[] = $langs->trans(
'accountancy_error_modelnotfound');
391 foreach ($objectLines as $line) {
396 print $date.$separator;
397 print $line->code_journal.$separator;
400 print $line->sens.$separator;
401 print
price2fec(abs($line->debit - $line->credit)).$separator;
416 foreach ($objectLines as $line) {
421 print $line->code_journal.$separator;
422 print $date.$separator;
423 print $line->piece_num.$separator;
426 print $line->label_operation.$separator;
427 print $date.$separator;
428 if ($line->sens ==
'D') {
429 print
price($line->debit).$separator;
431 } elseif ($line->sens ==
'C') {
433 print
price($line->credit).$separator;
435 print $line->doc_ref.$separator;
436 print $line->label_operation.$separator;
453 foreach ($objectLines as $line) {
456 print $date.$separator;
457 print $line->code_journal.$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;
482 foreach ($objectLines as $line) {
483 print $line->piece_num.$separator;
485 print $date.$separator;
487 if (empty($line->subledger_account)) {
488 print
'G'.$separator;
491 if (substr($line->numero_compte, 0, 3) ==
'411') {
492 print
'C'.$separator;
494 if (substr($line->numero_compte, 0, 3) ==
'401') {
495 print
'F'.$separator;
500 print
price($line->debit).$separator;
501 print
price($line->credit).$separator;
502 print
dol_trunc($line->label_operation, 32).$separator;
527 foreach ($TData as $data) {
529 if (!empty($data->subledger_account)) {
534 $date_echeance =
dol_print_date($data->date_lim_reglement,
'%Y%m%d');
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);
547 $Tab[
'intitule_compte'] = str_pad(self::trunc(
dol_string_unaccent($data->label_operation), 34), 34);
548 $Tab[
'end'] =
'O2003';
550 $Tab[
'end_line'] = $end_line;
577 foreach ($TData as $data) {
581 $data->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $data->label_operation);
582 $data->label_operation = str_replace(array(
"- ",
"…",
"..."),
"", $data->label_operation);
590 $data->subledger_label = str_replace(array(
"- ",
"…",
"..."),
"", $data->subledger_label);
593 $code_compta = $data->numero_compte;
594 if (!empty($data->subledger_account)) {
595 $code_compta = $data->subledger_account;
600 if (!empty($data->subledger_account)) {
601 $Tab[
'type_ligne'] =
'C';
602 $Tab[
'num_compte'] = str_pad(self::trunc($data->subledger_account, 8), 8);
603 $Tab[
'lib_compte'] = str_pad(self::trunc($data->subledger_label, 30), 30);
605 if ($data->doc_type ==
'customer_invoice') {
606 $Tab[
'lib_alpha'] = strtoupper(str_pad(
'C'.self::trunc($data->subledger_label, 6), 7));
607 $Tab[
'filler'] = str_repeat(
' ', 52);
608 $Tab[
'coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, 8), 8);
609 } elseif ($data->doc_type ==
'supplier_invoice') {
610 $Tab[
'lib_alpha'] = strtoupper(str_pad(
'F'.self::trunc($data->subledger_label, 6), 7));
611 $Tab[
'filler'] = str_repeat(
' ', 52);
612 $Tab[
'coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, 8), 8);
614 $Tab[
'filler'] = str_repeat(
' ', 59);
615 $Tab[
'coll_compte'] = str_pad(
' ', 8);
618 $Tab[
'filler2'] = str_repeat(
' ', 110);
621 if ($data->doc_type ==
'customer_invoice') {
622 $Tab[
'type_compte'] =
'C';
623 } elseif ($data->doc_type ==
'supplier_invoice') {
624 $Tab[
'type_compte'] =
'F';
626 $Tab[
'type_compte'] =
'G';
629 $Tab[
'filler3'] = str_repeat(
' ', 235);
631 $Tab[
'end_line'] = $end_line;
637 $Tab[
'type_ligne'] =
'M';
638 $Tab[
'num_compte'] = str_pad(self::trunc($code_compta, 8), 8);
639 $Tab[
'code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
640 $Tab[
'folio'] =
'000';
645 $Tab[
'date_ecriture'] =
dol_print_date($data->doc_date,
'%d%m%y');
646 $Tab[
'filler'] =
' ';
647 $Tab[
'libelle_ecriture'] = str_pad(self::trunc($data->doc_ref.
' '.$data->label_operation, 20), 20);
662 $Tab[
'sens'] = $data->sens;
663 $Tab[
'signe_montant'] =
'+';
666 $Tab[
'montant'] = str_pad(abs(($data->debit - $data->credit) * 100), 12,
'0', STR_PAD_LEFT);
667 $Tab[
'contrepartie'] = str_repeat(
' ', 8);
670 if (!empty($data->date_lim_reglement)) {
672 $Tab[
'date_echeance'] =
dol_print_date($data->date_lim_reglement,
'%d%m%y');
674 $Tab[
'date_echeance'] =
'000000';
679 $Tab[
'lettrage'] = str_repeat(
' ', 2);
680 $Tab[
'codestat'] = str_repeat(
' ', 3);
681 $Tab[
'num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5);
685 $Tab[
'affaire'] = str_repeat(
' ', 10);
686 $Tab[
'quantity1'] = str_repeat(
' ', 10);
687 $Tab[
'num_piece2'] = str_pad(self::trunc($data->piece_num, 8), 8);
688 $Tab[
'devis'] = str_pad($conf->currency, 3);
689 $Tab[
'code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3);
690 $Tab[
'filler3'] = str_repeat(
' ', 3);
698 $Tab[
'libelle_ecriture2'] = str_pad(self::trunc($data->label_operation, 30), 30);
699 $Tab[
'codetva'] = str_repeat(
' ', 2);
703 $Tab[
'num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10);
704 $Tab[
'filler4'] = str_repeat(
' ', 73);
706 $Tab[
'end_line'] = $end_line;
735 foreach ($TData as $data) {
736 $code_compta = $data->numero_compte;
737 if (!empty($data->subledger_account)) {
738 $code_compta = $data->subledger_account;
743 $Tab[
'code_journal'] = str_pad(
dol_trunc($data->code_journal, 2,
'right',
'UTF-8', 1), 2);
748 $Tab[
'date_operation'] =
dol_print_date($data->doc_date,
'%d%m%Y');
750 $Tab[
'folio'] =
' 1';
752 $Tab[
'num_ecriture'] = str_pad(
dol_trunc($index, 6,
'right',
'UTF-8', 1), 6,
' ', STR_PAD_LEFT);
754 $Tab[
'jour_ecriture'] =
dol_print_date($data->doc_date,
'%d%m%y');
756 $Tab[
'num_compte'] = str_pad(
dol_trunc($code_compta, 6,
'right',
'UTF-8', 1), 6,
'0');
758 if ($data->sens ==
'D') {
759 $Tab[
'montant_debit'] = str_pad(number_format($data->debit, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
761 $Tab[
'montant_crebit'] = str_pad(number_format(0, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
763 $Tab[
'montant_debit'] = str_pad(number_format(0, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
765 $Tab[
'montant_crebit'] = str_pad(number_format($data->credit, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
770 $Tab[
'lettrage'] = str_repeat(
dol_trunc($data->lettering_code, 2,
'left',
'UTF-8', 1), 2);
772 $Tab[
'code_piece'] = str_pad(
dol_trunc($data->piece_num, 5,
'left',
'UTF-8', 1), 5,
' ', STR_PAD_LEFT);
774 $Tab[
'code_stat'] = str_repeat(
' ', 4);
776 if (!empty($data->date_lim_reglement)) {
778 $Tab[
'date_echeance'] =
dol_print_date($data->date_lim_reglement,
'%d%m%Y');
780 $Tab[
'date_echeance'] =
dol_print_date($data->doc_date,
'%d%m%Y');
783 $Tab[
'monnaie'] =
'1';
785 $Tab[
'filler'] =
' ';
787 $Tab[
'ind_compteur'] =
' ';
789 $Tab[
'quantite'] =
'0,000000000';
791 $Tab[
'code_pointage'] = str_repeat(
' ', 2);
793 $Tab[
'end_line'] = $end_line;
795 print implode(
'|', $Tab);
814 foreach ($objectLines as $line) {
817 print $line->id.$separator;
818 print $date.$separator;
819 print $line->code_journal.$separator;
820 if (empty($line->subledger_account)) {
821 print $line->numero_compte.$separator;
823 print $line->subledger_account.$separator;
826 print
'"'.dol_trunc($line->label_operation, 40,
'right',
'UTF-8', 1).
'"'.$separator;
827 print
'"'.dol_trunc($line->piece_num, 15,
'right',
'UTF-8', 1).
'"'.$separator;
828 print
price2num(abs($line->debit - $line->credit)).$separator;
829 print $line->sens.$separator;
830 print $date.$separator;
849 foreach ($objectLines as $line) {
852 print $line->piece_num.$separator;
854 print $date.$separator;
857 if (empty($line->subledger_account)) {
866 print
price($line->debit).$separator;
867 print
price($line->credit).$separator;
868 print
price(abs($line->debit - $line->credit)).$separator;
869 print $line->sens.$separator;
870 print $line->lettering_code.$separator;
871 print $line->code_journal;
888 foreach ($objectLines as $line) {
891 print $date.$separator;
892 print $line->code_journal.$separator;
893 if (empty($line->subledger_account)) {
898 print $line->doc_ref.$separator;
899 print $line->label_operation.$separator;
900 print
price($line->debit).$separator;
901 print
price($line->credit).$separator;
917 $separator = $this->separator;
919 foreach ($objectLines as $line) {
922 $date =
dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
923 $tab[] = $line->piece_num;
925 $tab[] = $line->doc_ref;
926 $tab[] = preg_match(
'/'.$separator.
'/', $line->label_operation) ?
"'".$line->label_operation.
"'" : $line->label_operation;
931 $tab[] =
price2num($line->debit - $line->credit);
932 $tab[] = $line->code_journal;
934 print implode($separator, $tab).$this->end_line;
951 print
"JournalCode".$separator;
952 print
"JournalLib".$separator;
953 print
"EcritureNum".$separator;
954 print
"EcritureDate".$separator;
955 print
"CompteNum".$separator;
956 print
"CompteLib".$separator;
957 print
"CompAuxNum".$separator;
958 print
"CompAuxLib".$separator;
959 print
"PieceRef".$separator;
960 print
"PieceDate".$separator;
961 print
"EcritureLib".$separator;
962 print
"Debit".$separator;
963 print
"Credit".$separator;
964 print
"EcritureLet".$separator;
965 print
"DateLet".$separator;
966 print
"ValidDate".$separator;
967 print
"Montantdevise".$separator;
968 print
"Idevise".$separator;
969 print
"DateLimitReglmt".$separator;
973 foreach ($objectLines as $line) {
974 if ($line->debit == 0 && $line->credit == 0) {
979 $date_lettering =
dol_print_date($line->date_lettering,
'%Y%m%d');
980 $date_validation =
dol_print_date($line->date_validation,
'%Y%m%d');
981 $date_limit_payment =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
984 if ($line->doc_type ==
'customer_invoice') {
986 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
988 $invoice->fetch($line->fk_doc);
990 $refInvoice = $invoice->ref;
991 } elseif ($line->doc_type ==
'supplier_invoice') {
993 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
995 $invoice->fetch($line->fk_doc);
997 $refInvoice = $invoice->ref_supplier;
1001 print $line->code_journal . $separator;
1007 print $line->piece_num . $separator;
1010 print $date_document . $separator;
1025 print $line->doc_ref . $separator;
1032 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1036 print
price2fec($line->debit) . $separator;
1039 print
price2fec($line->credit) . $separator;
1042 print $line->lettering_code . $separator;
1045 print $date_lettering . $separator;
1048 print $date_validation . $separator;
1051 print $line->multicurrency_amount . $separator;
1054 print $line->multicurrency_code . $separator;
1057 print $date_limit_payment . $separator;
1061 $refInvoice = str_replace(array(
"\t",
"\n",
"\r"),
" ", $refInvoice);
1062 print
dol_trunc(self::toAnsi($refInvoice), 17,
'right',
'UTF-8', 1);
1082 print
"JournalCode".$separator;
1083 print
"JournalLib".$separator;
1084 print
"EcritureNum".$separator;
1085 print
"EcritureDate".$separator;
1086 print
"CompteNum".$separator;
1087 print
"CompteLib".$separator;
1088 print
"CompAuxNum".$separator;
1089 print
"CompAuxLib".$separator;
1090 print
"PieceRef".$separator;
1091 print
"PieceDate".$separator;
1092 print
"EcritureLib".$separator;
1093 print
"Debit".$separator;
1094 print
"Credit".$separator;
1095 print
"EcritureLet".$separator;
1096 print
"DateLet".$separator;
1097 print
"ValidDate".$separator;
1098 print
"Montantdevise".$separator;
1099 print
"Idevise".$separator;
1100 print
"DateLimitReglmt".$separator;
1104 foreach ($objectLines as $line) {
1105 if ($line->debit == 0 && $line->credit == 0) {
1110 $date_lettering =
dol_print_date($line->date_lettering,
'%Y%m%d');
1111 $date_validation =
dol_print_date($line->date_validation,
'%Y%m%d');
1112 $date_limit_payment =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1115 if ($line->doc_type ==
'customer_invoice') {
1117 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1119 $invoice->fetch($line->fk_doc);
1121 $refInvoice = $invoice->ref;
1122 } elseif ($line->doc_type ==
'supplier_invoice') {
1124 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1126 $invoice->fetch($line->fk_doc);
1128 $refInvoice = $invoice->ref_supplier;
1132 print $line->code_journal . $separator;
1138 print $line->piece_num . $separator;
1141 print $date_creation . $separator;
1156 print $line->doc_ref . $separator;
1159 print $date_document . $separator;
1163 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1167 print
price2fec($line->debit) . $separator;
1170 print
price2fec($line->credit) . $separator;
1173 print $line->lettering_code . $separator;
1176 print $date_lettering . $separator;
1179 print $date_validation . $separator;
1182 print $line->multicurrency_amount . $separator;
1185 print $line->multicurrency_code . $separator;
1188 print $date_limit_payment . $separator;
1192 $refInvoice = str_replace(array(
"\t",
"\n",
"\r"),
" ", $refInvoice);
1193 print
dol_trunc(self::toAnsi($refInvoice), 17,
'right',
'UTF-8', 1);
1214 $this->separator =
',';
1215 $this->end_line =
"\r\n";
1218 print
"Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag";
1219 print $this->end_line;
1221 $thisPieceAccountNr =
"";
1222 $aSize = count($objectLines);
1223 foreach ($objectLines as $aIndex => $line) {
1224 $sammelBuchung =
false;
1225 if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) {
1226 $sammelBuchung =
true;
1227 } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) {
1228 $sammelBuchung =
true;
1229 } elseif ($aIndex + 1 < $aSize
1230 && $objectLines[$aIndex + 1]->piece_num == $line->piece_num
1231 && $aIndex - 1 < $aSize
1232 && $objectLines[$aIndex - 1]->piece_num == $line->piece_num
1234 $sammelBuchung =
true;
1238 print $line->piece_num.$this->separator;
1242 print $date.$this->separator;
1247 if ($line->sens ==
'D') {
1248 print
'S'.$this->separator;
1250 print
'H'.$this->separator;
1253 print
self::trunc($line->code_journal, 1).$this->separator;
1255 if (empty($line->code_tiers)) {
1256 if ($line->piece_num == $thisPieceNum) {
1259 print
"div".$this->separator;
1265 print $this->separator;
1267 print
"0".$this->separator;
1269 print
"0".$this->separator;
1271 print
"0".$this->separator;
1274 if ($sammelBuchung) {
1275 print
"2".$this->separator;
1277 print
"1".$this->separator;
1280 print
'""'.$this->separator;
1282 print abs($line->debit - $line->credit).$this->separator;
1284 print
"0.00".$this->separator;
1286 print
"0.00".$this->separator;
1289 if ($line1 ==
"LIQ" || $line1 ==
"LIQ Beleg ok" || strlen($line1) <= 3) {
1293 if (strlen($line1) == 0) {
1297 if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) {
1298 $line1 = $line1.
' / '.$line2;
1302 print
'"'.self::toAnsi($line1).
'"'.$this->separator;
1304 print
'"'.self::toAnsi($line2).
'"'.$this->separator;
1306 print
"0".$this->separator;
1308 print $this->separator;
1313 print $this->end_line;
1315 if ($line->piece_num !== $thisPieceNum) {
1316 $thisPieceNum = $line->piece_num;
1317 $thisPieceAccountNr = $line->numero_compte;
1336 foreach ($objectLines as $line) {
1339 $date_lim_reglement =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1342 $type_enregistrement =
'E';
1343 print $type_enregistrement.$separator;
1345 print substr($line->code_journal, 0, 2).$separator;
1347 print $line->id.$separator;
1349 print $line->piece_num.$separator;
1351 print $date_document.$separator;
1353 print $line->label_operation.$separator;
1355 print $date_lim_reglement.$separator;
1357 if ($line->doc_type ==
'supplier_invoice') {
1358 if (($line->debit - $line->credit) > 0) {
1359 $nature_piece =
'AF';
1361 $nature_piece =
'FF';
1363 } elseif ($line->doc_type ==
'customer_invoice') {
1364 if (($line->debit - $line->credit) < 0) {
1365 $nature_piece =
'AC';
1367 $nature_piece =
'FC';
1372 print $nature_piece.$separator;
1383 $racine_subledger_account =
'';
1386 print $racine_subledger_account.$separator;
1388 print
price(abs($line->debit - $line->credit), 0,
'', 1, 2, 2).$separator;
1390 print $line->sens.$separator;
1394 print $date_creation.$separator;
1396 print $line->lettering_code.$separator;
1398 print $line->date_lettering.$separator;
1400 if (!empty($line->subledger_account)) {
1406 if ($line->doc_type ==
'supplier_invoice' && !empty($line->subledger_account)) {
1407 print
'F'.$separator;
1408 } elseif ($line->doc_type ==
'customer_invoice' && !empty($line->subledger_account)) {
1409 print
'C'.$separator;
1422 print $line->doc_ref.$separator;
1428 print
'0'.$separator;
1432 print
'0'.$separator;
1466 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
1470 $last_codeinvoice =
'';
1472 foreach ($objectLines as $line) {
1474 if ($last_codeinvoice != $line->doc_ref) {
1476 $sql =
"SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX.
"societe";
1477 $sql .=
" WHERE code_client = '".$this->db->escape($line->thirdparty_code).
"'";
1481 $soc = $this->
db->fetch_object(
$resql);
1483 $address = array(
'',
'',
'');
1484 if (strpos($soc->address,
"\n") !==
false) {
1485 $address = explode(
"\n", $soc->address);
1486 if (is_array($address) && count($address) > 0) {
1487 foreach ($address as $key => $data) {
1488 $address[$key] = str_replace(array(
"\t",
"\n",
"\r"),
"", $data);
1489 $address[$key] =
dol_trunc($address[$key], 40,
'right',
'UTF-8', 1);
1493 $address[0] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 0, 40);
1494 $address[1] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 41, 40);
1495 $address[2] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 82, 40);
1498 $type_enregistrement =
'C';
1500 print $type_enregistrement.$separator;
1502 print $soc->code_client.$separator;
1510 print $soc->nom.$separator;
1512 print $address[0].$separator;
1514 print $address[1].$separator;
1516 print $address[2].$separator;
1518 print $soc->zip.$separator;
1520 print substr($soc->town, 0, 40).$separator;
1524 print substr(
getCountry($soc->fk_pays), 0, 40).$separator;
1526 print $soc->phone.$separator;
1538 print str_replace(
" ",
"", $soc->siret).$separator;
1602 $date_lim_reglement =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1605 $type_enregistrement =
'E';
1606 print $type_enregistrement.$separator;
1608 print substr($line->code_journal, 0, 2).$separator;
1610 print $line->id.$separator;
1612 print $line->piece_num.$separator;
1614 print $date_document.$separator;
1616 print
dol_trunc($line->label_operation, 25,
'right',
'UTF-8', 1).$separator;
1618 print $date_lim_reglement.$separator;
1620 if ($line->doc_type ==
'supplier_invoice') {
1621 if (($line->amount) < 0) {
1622 $nature_piece =
'AF';
1624 $nature_piece =
'FF';
1626 } elseif ($line->doc_type ==
'customer_invoice') {
1627 if (($line->amount) < 0) {
1628 $nature_piece =
'AC';
1630 $nature_piece =
'FC';
1635 print $nature_piece.$separator;
1646 $racine_subledger_account =
'';
1649 print $racine_subledger_account.$separator;
1651 print
price(abs($line->debit - $line->credit), 0,
'', 1, 2).$separator;
1653 print $line->sens.$separator;
1657 print $date_document.$separator;
1659 print $line->lettering_code.$separator;
1661 print $line->date_lettering.$separator;
1663 if (!empty($line->subledger_account)) {
1669 if ($line->doc_type ==
'supplier_invoice' && !empty($line->subledger_account)) {
1670 print
'F'.$separator;
1671 } elseif ($line->doc_type ==
'customer_invoice' && !empty($line->subledger_account)) {
1672 print
'C'.$separator;
1683 print $line->doc_ref.$separator;
1685 print
'0'.$separator;
1695 print
'0'.$separator;
1699 print
'0'.$separator;
1719 $last_codeinvoice = $line->doc_ref;
1732 $langs->load(
'compta');
1740 print $langs->transnoentitiesnoconv(
'Date').$separator;
1741 print
self::trunc($langs->transnoentitiesnoconv(
'Journal'), 6).$separator;
1742 print
self::trunc($langs->transnoentitiesnoconv(
'Account'), 15).$separator;
1743 print
self::trunc($langs->transnoentitiesnoconv(
'LabelAccount'), 60).$separator;
1744 print
self::trunc($langs->transnoentitiesnoconv(
'Piece'), 20).$separator;
1745 print
self::trunc($langs->transnoentitiesnoconv(
'LabelOperation'), 60).$separator;
1746 print $langs->transnoentitiesnoconv(
'Amount').$separator;
1747 print
'S'.$separator;
1748 print
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 1', 15).$separator;
1749 print
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 1', 60).$separator;
1750 print
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 2', 15).$separator;
1751 print
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 2', 60).$separator;
1752 print
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 3', 15).$separator;
1753 print
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 3', 60).$separator;
1756 foreach ($objectLines as $line) {
1758 print $date.$separator;
1760 print
self::trunc($line->code_journal, 6).$separator;
1762 if (!empty($line->subledger_account)) {
1763 $account = $line->subledger_account;
1765 $account = $line->numero_compte;
1769 print
self::trunc($line->label_compte, 60).$separator;
1772 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1773 print
self::trunc($line->label_operation, 60).$separator;
1774 print
price(abs($line->debit - $line->credit)).$separator;
1775 print $line->sens.$separator;
1797 $this->separator =
',';
1799 $invoices_infos = array();
1800 $supplier_invoices_infos = array();
1801 foreach ($objectLines as $line) {
1802 if ($line->debit == 0 && $line->credit == 0) {
1807 $invoice_ref = $line->doc_ref;
1810 if (($line->doc_type ==
'customer_invoice' || $line->doc_type ==
'supplier_invoice') && $line->fk_doc > 0) {
1811 if (($line->doc_type ==
'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) ||
1812 ($line->doc_type ==
'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) {
1813 if ($line->doc_type ==
'customer_invoice') {
1815 $sql =
'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX .
'facture as f';
1816 $sql .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe AS s ON f.fk_soc = s.rowid';
1817 $sql .=
' WHERE f.rowid = '.((int) $line->fk_doc);
1820 if ($obj = $this->
db->fetch_object(
$resql)) {
1822 $invoices_infos[$line->fk_doc] = array(
'ref' => $obj->ref,
'company_name' => $obj->nom);
1823 $invoice_ref = $obj->ref;
1824 $company_name = $obj->nom;
1829 $sql =
'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX .
'facture_fourn as ff';
1830 $sql .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe AS s ON ff.fk_soc = s.rowid';
1831 $sql .=
' WHERE ff.rowid = '.((int) $line->fk_doc);
1834 if ($obj = $this->
db->fetch_object(
$resql)) {
1836 $supplier_invoices_infos[$line->fk_doc] = array(
'ref' => $obj->ref,
'company_name' => $obj->nom);
1837 $invoice_ref = $obj->ref;
1838 $company_name = $obj->nom;
1842 } elseif ($line->doc_type ==
'customer_invoice') {
1844 $invoice_ref = $invoices_infos[$line->fk_doc][
'ref'];
1845 $company_name = $invoices_infos[$line->fk_doc][
'company_name'];
1848 $invoice_ref = $supplier_invoices_infos[$line->fk_doc][
'ref'];
1849 $company_name = $supplier_invoices_infos[$line->fk_doc][
'company_name'];
1853 print $line->id . $this->separator;
1854 print $date . $this->separator;
1855 print substr($line->code_journal, 0, 4) . $this->separator;
1857 if ((substr($line->numero_compte, 0, 3) ==
'411') || (substr($line->numero_compte, 0, 3) ==
'401')) {
1860 print substr(
length_accountg($line->numero_compte), 0, 15) . $this->separator;
1863 print $this->separator;
1866 print
dol_trunc(str_replace(
'"',
'', $invoice_ref . (!empty($company_name) ?
' - ' :
'') . $company_name), 40,
'right',
'UTF-8', 1) . $this->separator;
1868 print
dol_trunc(str_replace(
'"',
'', $line->piece_num), 10,
'right',
'UTF-8', 1) . $this->separator;
1870 print
'EUR' . $this->separator;
1872 print
price2num(abs($line->debit - $line->credit)) . $this->separator;
1874 print $line->sens . $this->separator;
1876 print $this->separator;
1879 print $this->end_line;
1894 $this->separator =
',';
1896 foreach ($objectLines as $line) {
1897 if ($line->debit == 0 && $line->credit == 0) {
1902 print $line->id . $this->separator;
1903 print $date . $this->separator;
1904 print substr($line->code_journal, 0, 4) . $this->separator;
1905 if ((substr($line->numero_compte, 0, 3) ==
'411') || (substr($line->numero_compte, 0, 3) ==
'401')) {
1908 print substr(
length_accountg($line->numero_compte), 0, 15) . $this->separator;
1910 print $this->separator;
1912 print
'"' .
dol_trunc(str_replace(
'"',
'', $line->doc_ref), 40,
'right',
'UTF-8', 1) .
'"' . $this->separator;
1913 print
'"' .
dol_trunc(str_replace(
'"',
'', $line->piece_num), 10,
'right',
'UTF-8', 1) .
'"' . $this->separator;
1914 print
price2num(abs($line->debit - $line->credit)) . $this->separator;
1915 print $line->sens . $this->separator;
1916 print $date . $this->separator;
1917 print $this->separator;
1918 print $this->separator;
1920 print $this->end_line;
1936 $this->separator =
';';
1937 $this->end_line =
"\r\n";
1940 foreach ($objectLines as $line) {
1945 $tab[] = $line->piece_num;
1947 $tab[] = substr($date, 6, 4);
1948 $tab[] = substr($date, 3, 2);
1949 $tab[] = substr($date, 0, 2);
1950 $tab[] = $line->doc_ref;
1952 $tab[] = mb_convert_encoding(str_replace(
' - Compte auxiliaire',
'', $line->label_operation),
"Windows-1252",
'UTF-8');
1958 $numero_cpt_client =
'411';
1959 for ($i = 1; $i <= ($taille_numero - 3); $i++) {
1960 $numero_cpt_client .=
'0';
1969 $nom_client = explode(
" - ", $line->label_operation);
1970 $tab[] = mb_convert_encoding($nom_client[0],
"Windows-1252",
'UTF-8');
1971 $tab[] =
price($line->debit);
1972 $tab[] =
price($line->credit);
1973 $tab[] =
price($line->montant);
1974 $tab[] = $line->code_journal;
1976 $separator = $this->separator;
1977 print implode($separator, $tab) . $this->end_line;
1988 public static function trunc($str, $size)
1990 return dol_trunc($str, $size,
'right',
'UTF-8', 1);
2000 public static function toAnsi($str, $size = -1)
2003 if ($retVal >= 0 && $size >= 0) {
2004 $retVal = mb_substr($retVal, 0, $size,
'Windows-1251');