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) {
586 $code_compta = $data->numero_compte;
587 if (!empty($data->subledger_account)) {
588 $code_compta = $data->subledger_account;
593 if (!empty($data->subledger_account)) {
594 $Tab[
'type_ligne'] =
'C';
595 $Tab[
'num_compte'] = str_pad(self::trunc($data->subledger_account, 8), 8);
596 $Tab[
'lib_compte'] = str_pad(self::trunc($data->subledger_label, 30), 30);
598 if ($data->doc_type ==
'customer_invoice') {
599 $Tab[
'lib_alpha'] = strtoupper(str_pad(
'C'.self::trunc($data->subledger_label, 6), 6));
600 $Tab[
'filler'] = str_repeat(
' ', 52);
601 $Tab[
'coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, 8), 8);
602 } elseif ($data->doc_type ==
'supplier_invoice') {
603 $Tab[
'lib_alpha'] = strtoupper(str_pad(
'F'.self::trunc($data->subledger_label, 6), 6));
604 $Tab[
'filler'] = str_repeat(
' ', 52);
605 $Tab[
'coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, 8), 8);
607 $Tab[
'filler'] = str_repeat(
' ', 59);
608 $Tab[
'coll_compte'] = str_pad(
' ', 8);
611 $Tab[
'filler2'] = str_repeat(
' ', 110);
614 if ($data->doc_type ==
'customer_invoice') {
615 $Tab[
'type_compte'] =
'C';
616 } elseif ($data->doc_type ==
'supplier_invoice') {
617 $Tab[
'type_compte'] =
'F';
619 $Tab[
'type_compte'] =
'G';
622 $Tab[
'filler3'] = str_repeat(
' ', 235);
624 $Tab[
'end_line'] = $end_line;
630 $Tab[
'type_ligne'] =
'M';
631 $Tab[
'num_compte'] = str_pad(self::trunc($code_compta, 8), 8);
632 $Tab[
'code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
633 $Tab[
'folio'] =
'000';
638 $Tab[
'date_ecriture'] =
dol_print_date($data->doc_date,
'%d%m%y');
639 $Tab[
'filler'] =
' ';
640 $Tab[
'libelle_ecriture'] = str_pad(self::trunc($data->doc_ref.
' '.$data->label_operation, 20), 20);
655 $Tab[
'sens'] = $data->sens;
656 $Tab[
'signe_montant'] =
'+';
659 $Tab[
'montant'] = str_pad(abs(($data->debit - $data->credit) * 100), 12,
'0', STR_PAD_LEFT);
660 $Tab[
'contrepartie'] = str_repeat(
' ', 8);
663 if (!empty($data->date_lim_reglement)) {
665 $Tab[
'date_echeance'] =
dol_print_date($data->date_lim_reglement,
'%d%m%y');
667 $Tab[
'date_echeance'] =
'000000';
672 $Tab[
'lettrage'] = str_repeat(
' ', 2);
673 $Tab[
'codestat'] = str_repeat(
' ', 3);
674 $Tab[
'num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5);
678 $Tab[
'affaire'] = str_repeat(
' ', 10);
679 $Tab[
'quantity1'] = str_repeat(
' ', 10);
680 $Tab[
'num_piece2'] = str_pad(self::trunc($data->piece_num, 8), 8);
681 $Tab[
'devis'] = str_pad($conf->currency, 3);
682 $Tab[
'code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3);
683 $Tab[
'filler3'] = str_repeat(
' ', 3);
691 $Tab[
'libelle_ecriture2'] = str_pad(self::trunc($data->label_operation, 30), 30);
692 $Tab[
'codetva'] = str_repeat(
' ', 2);
696 $Tab[
'num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10);
697 $Tab[
'filler4'] = str_repeat(
' ', 73);
699 $Tab[
'end_line'] = $end_line;
728 foreach ($TData as $data) {
729 $code_compta = $data->numero_compte;
730 if (!empty($data->subledger_account)) {
731 $code_compta = $data->subledger_account;
736 $Tab[
'code_journal'] = str_pad(
dol_trunc($data->code_journal, 2,
'right',
'UTF-8', 1), 2);
741 $Tab[
'date_operation'] =
dol_print_date($data->doc_date,
'%d%m%Y');
743 $Tab[
'folio'] =
' 1';
745 $Tab[
'num_ecriture'] = str_pad(
dol_trunc($index, 6,
'right',
'UTF-8', 1), 6,
' ', STR_PAD_LEFT);
747 $Tab[
'jour_ecriture'] =
dol_print_date($data->doc_date,
'%d%m%y');
749 $Tab[
'num_compte'] = str_pad(
dol_trunc($code_compta, 6,
'right',
'UTF-8', 1), 6,
'0');
751 if ($data->sens ==
'D') {
752 $Tab[
'montant_debit'] = str_pad(number_format($data->debit, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
754 $Tab[
'montant_crebit'] = str_pad(number_format(0, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
756 $Tab[
'montant_debit'] = str_pad(number_format(0, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
758 $Tab[
'montant_crebit'] = str_pad(number_format($data->credit, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
763 $Tab[
'lettrage'] = str_repeat(
dol_trunc($data->lettering_code, 2,
'left',
'UTF-8', 1), 2);
765 $Tab[
'code_piece'] = str_pad(
dol_trunc($data->piece_num, 5,
'left',
'UTF-8', 1), 5,
' ', STR_PAD_LEFT);
767 $Tab[
'code_stat'] = str_repeat(
' ', 4);
769 if (!empty($data->date_lim_reglement)) {
771 $Tab[
'date_echeance'] =
dol_print_date($data->date_lim_reglement,
'%d%m%Y');
773 $Tab[
'date_echeance'] =
dol_print_date($data->doc_date,
'%d%m%Y');
776 $Tab[
'monnaie'] =
'1';
778 $Tab[
'filler'] =
' ';
780 $Tab[
'ind_compteur'] =
' ';
782 $Tab[
'quantite'] =
'0,000000000';
784 $Tab[
'code_pointage'] = str_repeat(
' ', 2);
786 $Tab[
'end_line'] = $end_line;
788 print implode(
'|', $Tab);
807 foreach ($objectLines as $line) {
810 print $line->id.$separator;
811 print $date.$separator;
812 print $line->code_journal.$separator;
813 if (empty($line->subledger_account)) {
814 print $line->numero_compte.$separator;
816 print $line->subledger_account.$separator;
819 print
'"'.dol_trunc($line->label_operation, 40,
'right',
'UTF-8', 1).
'"'.$separator;
820 print
'"'.dol_trunc($line->piece_num, 15,
'right',
'UTF-8', 1).
'"'.$separator;
821 print
price2num(abs($line->debit - $line->credit)).$separator;
822 print $line->sens.$separator;
823 print $date.$separator;
842 foreach ($objectLines as $line) {
845 print $line->piece_num.$separator;
847 print $date.$separator;
850 if (empty($line->subledger_account)) {
859 print
price($line->debit).$separator;
860 print
price($line->credit).$separator;
861 print
price(abs($line->debit - $line->credit)).$separator;
862 print $line->sens.$separator;
863 print $line->lettering_code.$separator;
864 print $line->code_journal;
881 foreach ($objectLines as $line) {
884 print $date.$separator;
885 print $line->code_journal.$separator;
886 if (empty($line->subledger_account)) {
891 print $line->doc_ref.$separator;
892 print $line->label_operation.$separator;
893 print
price($line->debit).$separator;
894 print
price($line->credit).$separator;
910 $separator = $this->separator;
912 foreach ($objectLines as $line) {
915 $date =
dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
916 $tab[] = $line->piece_num;
918 $tab[] = $line->doc_ref;
919 $tab[] = preg_match(
'/'.$separator.
'/', $line->label_operation) ?
"'".$line->label_operation.
"'" : $line->label_operation;
924 $tab[] =
price2num($line->debit - $line->credit);
925 $tab[] = $line->code_journal;
927 print implode($separator, $tab).$this->end_line;
944 print
"JournalCode".$separator;
945 print
"JournalLib".$separator;
946 print
"EcritureNum".$separator;
947 print
"EcritureDate".$separator;
948 print
"CompteNum".$separator;
949 print
"CompteLib".$separator;
950 print
"CompAuxNum".$separator;
951 print
"CompAuxLib".$separator;
952 print
"PieceRef".$separator;
953 print
"PieceDate".$separator;
954 print
"EcritureLib".$separator;
955 print
"Debit".$separator;
956 print
"Credit".$separator;
957 print
"EcritureLet".$separator;
958 print
"DateLet".$separator;
959 print
"ValidDate".$separator;
960 print
"Montantdevise".$separator;
961 print
"Idevise".$separator;
962 print
"DateLimitReglmt".$separator;
966 foreach ($objectLines as $line) {
967 if ($line->debit == 0 && $line->credit == 0) {
972 $date_lettering =
dol_print_date($line->date_lettering,
'%Y%m%d');
973 $date_validation =
dol_print_date($line->date_validation,
'%Y%m%d');
974 $date_limit_payment =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
977 if ($line->doc_type ==
'customer_invoice') {
979 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
981 $invoice->fetch($line->fk_doc);
983 $refInvoice = $invoice->ref;
984 } elseif ($line->doc_type ==
'supplier_invoice') {
986 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
988 $invoice->fetch($line->fk_doc);
990 $refInvoice = $invoice->ref_supplier;
994 print $line->code_journal . $separator;
1000 print $line->piece_num . $separator;
1003 print $date_document . $separator;
1006 print $line->numero_compte . $separator;
1012 print $line->subledger_account . $separator;
1018 print $line->doc_ref . $separator;
1025 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1029 print
price2fec($line->debit) . $separator;
1032 print
price2fec($line->credit) . $separator;
1035 print $line->lettering_code . $separator;
1038 print $date_lettering . $separator;
1041 print $date_validation . $separator;
1044 print $line->multicurrency_amount . $separator;
1047 print $line->multicurrency_code . $separator;
1050 print $date_limit_payment . $separator;
1054 $refInvoice = str_replace(array(
"\t",
"\n",
"\r"),
" ", $refInvoice);
1055 print
dol_trunc(self::toAnsi($refInvoice), 17,
'right',
'UTF-8', 1);
1075 print
"JournalCode".$separator;
1076 print
"JournalLib".$separator;
1077 print
"EcritureNum".$separator;
1078 print
"EcritureDate".$separator;
1079 print
"CompteNum".$separator;
1080 print
"CompteLib".$separator;
1081 print
"CompAuxNum".$separator;
1082 print
"CompAuxLib".$separator;
1083 print
"PieceRef".$separator;
1084 print
"PieceDate".$separator;
1085 print
"EcritureLib".$separator;
1086 print
"Debit".$separator;
1087 print
"Credit".$separator;
1088 print
"EcritureLet".$separator;
1089 print
"DateLet".$separator;
1090 print
"ValidDate".$separator;
1091 print
"Montantdevise".$separator;
1092 print
"Idevise".$separator;
1093 print
"DateLimitReglmt".$separator;
1097 foreach ($objectLines as $line) {
1098 if ($line->debit == 0 && $line->credit == 0) {
1103 $date_lettering =
dol_print_date($line->date_lettering,
'%Y%m%d');
1104 $date_validation =
dol_print_date($line->date_validation,
'%Y%m%d');
1105 $date_limit_payment =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1108 if ($line->doc_type ==
'customer_invoice') {
1110 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1112 $invoice->fetch($line->fk_doc);
1114 $refInvoice = $invoice->ref;
1115 } elseif ($line->doc_type ==
'supplier_invoice') {
1117 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1119 $invoice->fetch($line->fk_doc);
1121 $refInvoice = $invoice->ref_supplier;
1125 print $line->code_journal . $separator;
1131 print $line->piece_num . $separator;
1134 print $date_creation . $separator;
1149 print $line->doc_ref . $separator;
1152 print $date_document . $separator;
1156 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1160 print
price2fec($line->debit) . $separator;
1163 print
price2fec($line->credit) . $separator;
1166 print $line->lettering_code . $separator;
1169 print $date_lettering . $separator;
1172 print $date_validation . $separator;
1175 print $line->multicurrency_amount . $separator;
1178 print $line->multicurrency_code . $separator;
1181 print $date_limit_payment . $separator;
1185 $refInvoice = str_replace(array(
"\t",
"\n",
"\r"),
" ", $refInvoice);
1186 print
dol_trunc(self::toAnsi($refInvoice), 17,
'right',
'UTF-8', 1);
1207 $this->separator =
',';
1208 $this->end_line =
"\r\n";
1211 print
"Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag";
1212 print $this->end_line;
1214 $thisPieceAccountNr =
"";
1215 $aSize = count($objectLines);
1216 foreach ($objectLines as $aIndex => $line) {
1217 $sammelBuchung =
false;
1218 if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) {
1219 $sammelBuchung =
true;
1220 } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) {
1221 $sammelBuchung =
true;
1222 } elseif ($aIndex + 1 < $aSize
1223 && $objectLines[$aIndex + 1]->piece_num == $line->piece_num
1224 && $aIndex - 1 < $aSize
1225 && $objectLines[$aIndex - 1]->piece_num == $line->piece_num
1227 $sammelBuchung =
true;
1231 print $line->piece_num.$this->separator;
1235 print $date.$this->separator;
1240 if ($line->sens ==
'D') {
1241 print
'S'.$this->separator;
1243 print
'H'.$this->separator;
1246 print
self::trunc($line->code_journal, 1).$this->separator;
1248 if (empty($line->code_tiers)) {
1249 if ($line->piece_num == $thisPieceNum) {
1252 print
"div".$this->separator;
1258 print $this->separator;
1260 print
"0".$this->separator;
1262 print
"0".$this->separator;
1264 print
"0".$this->separator;
1267 if ($sammelBuchung) {
1268 print
"2".$this->separator;
1270 print
"1".$this->separator;
1273 print
'""'.$this->separator;
1275 print abs($line->debit - $line->credit).$this->separator;
1277 print
"0.00".$this->separator;
1279 print
"0.00".$this->separator;
1282 if ($line1 ==
"LIQ" || $line1 ==
"LIQ Beleg ok" || strlen($line1) <= 3) {
1286 if (strlen($line1) == 0) {
1290 if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) {
1291 $line1 = $line1.
' / '.$line2;
1295 print
'"'.self::toAnsi($line1).
'"'.$this->separator;
1297 print
'"'.self::toAnsi($line2).
'"'.$this->separator;
1299 print
"0".$this->separator;
1301 print $this->separator;
1306 print $this->end_line;
1308 if ($line->piece_num !== $thisPieceNum) {
1309 $thisPieceNum = $line->piece_num;
1310 $thisPieceAccountNr = $line->numero_compte;
1329 foreach ($objectLines as $line) {
1332 $date_lim_reglement =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1335 $type_enregistrement =
'E';
1336 print $type_enregistrement.$separator;
1338 print substr($line->code_journal, 0, 2).$separator;
1340 print $line->id.$separator;
1342 print $line->piece_num.$separator;
1344 print $date_document.$separator;
1346 print $line->label_operation.$separator;
1348 print $date_lim_reglement.$separator;
1350 if ($line->doc_type ==
'supplier_invoice') {
1351 if (($line->debit - $line->credit) > 0) {
1352 $nature_piece =
'AF';
1354 $nature_piece =
'FF';
1356 } elseif ($line->doc_type ==
'customer_invoice') {
1357 if (($line->debit - $line->credit) < 0) {
1358 $nature_piece =
'AC';
1360 $nature_piece =
'FC';
1365 print $nature_piece.$separator;
1376 $racine_subledger_account =
'';
1379 print $racine_subledger_account.$separator;
1381 print
price(abs($line->debit - $line->credit), 0,
'', 1, 2, 2).$separator;
1383 print $line->sens.$separator;
1387 print $date_creation.$separator;
1389 print $line->lettering_code.$separator;
1391 print $line->date_lettering.$separator;
1393 if (!empty($line->subledger_account)) {
1399 if ($line->doc_type ==
'supplier_invoice' && !empty($line->subledger_account)) {
1400 print
'F'.$separator;
1401 } elseif ($line->doc_type ==
'customer_invoice' && !empty($line->subledger_account)) {
1402 print
'C'.$separator;
1415 print $line->doc_ref.$separator;
1421 print
'0'.$separator;
1425 print
'0'.$separator;
1459 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
1463 $last_codeinvoice =
'';
1465 foreach ($objectLines as $line) {
1467 if ($last_codeinvoice != $line->doc_ref) {
1469 $sql =
"SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX.
"societe";
1470 $sql .=
" WHERE code_client = '".$this->db->escape($line->thirdparty_code).
"'";
1474 $soc = $this->
db->fetch_object(
$resql);
1476 $address = array(
'',
'',
'');
1477 if (strpos($soc->address,
"\n") !==
false) {
1478 $address = explode(
"\n", $soc->address);
1479 if (is_array($address) && count($address) > 0) {
1480 foreach ($address as $key => $data) {
1481 $address[$key] = str_replace(array(
"\t",
"\n",
"\r"),
"", $data);
1482 $address[$key] =
dol_trunc($address[$key], 40,
'right',
'UTF-8', 1);
1486 $address[0] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 0, 40);
1487 $address[1] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 41, 40);
1488 $address[2] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 82, 40);
1491 $type_enregistrement =
'C';
1493 print $type_enregistrement.$separator;
1495 print $soc->code_client.$separator;
1503 print $soc->nom.$separator;
1505 print $address[0].$separator;
1507 print $address[1].$separator;
1509 print $address[2].$separator;
1511 print $soc->zip.$separator;
1513 print substr($soc->town, 0, 40).$separator;
1517 print substr(
getCountry($soc->fk_pays), 0, 40).$separator;
1519 print $soc->phone.$separator;
1531 print str_replace(
" ",
"", $soc->siret).$separator;
1595 $date_lim_reglement =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1598 $type_enregistrement =
'E';
1599 print $type_enregistrement.$separator;
1601 print substr($line->code_journal, 0, 2).$separator;
1603 print $line->id.$separator;
1605 print $line->piece_num.$separator;
1607 print $date_document.$separator;
1609 print
dol_trunc($line->label_operation, 25,
'right',
'UTF-8', 1).$separator;
1611 print $date_lim_reglement.$separator;
1613 if ($line->doc_type ==
'supplier_invoice') {
1614 if (($line->amount) < 0) {
1615 $nature_piece =
'AF';
1617 $nature_piece =
'FF';
1619 } elseif ($line->doc_type ==
'customer_invoice') {
1620 if (($line->amount) < 0) {
1621 $nature_piece =
'AC';
1623 $nature_piece =
'FC';
1628 print $nature_piece.$separator;
1639 $racine_subledger_account =
'';
1642 print $racine_subledger_account.$separator;
1644 print
price(abs($line->debit - $line->credit), 0,
'', 1, 2).$separator;
1646 print $line->sens.$separator;
1650 print $date_document.$separator;
1652 print $line->lettering_code.$separator;
1654 print $line->date_lettering.$separator;
1656 if (!empty($line->subledger_account)) {
1662 if ($line->doc_type ==
'supplier_invoice' && !empty($line->subledger_account)) {
1663 print
'F'.$separator;
1664 } elseif ($line->doc_type ==
'customer_invoice' && !empty($line->subledger_account)) {
1665 print
'C'.$separator;
1676 print $line->doc_ref.$separator;
1678 print
'0'.$separator;
1688 print
'0'.$separator;
1692 print
'0'.$separator;
1712 $last_codeinvoice = $line->doc_ref;
1725 $langs->load(
'compta');
1733 print $langs->transnoentitiesnoconv(
'Date').$separator;
1734 print
self::trunc($langs->transnoentitiesnoconv(
'Journal'), 6).$separator;
1735 print
self::trunc($langs->transnoentitiesnoconv(
'Account'), 15).$separator;
1736 print
self::trunc($langs->transnoentitiesnoconv(
'LabelAccount'), 60).$separator;
1737 print
self::trunc($langs->transnoentitiesnoconv(
'Piece'), 20).$separator;
1738 print
self::trunc($langs->transnoentitiesnoconv(
'LabelOperation'), 60).$separator;
1739 print $langs->transnoentitiesnoconv(
'Amount').$separator;
1740 print
'S'.$separator;
1741 print
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 1', 15).$separator;
1742 print
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 1', 60).$separator;
1743 print
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 2', 15).$separator;
1744 print
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 2', 60).$separator;
1745 print
self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 3', 15).$separator;
1746 print
self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 3', 60).$separator;
1749 foreach ($objectLines as $line) {
1751 print $date.$separator;
1753 print
self::trunc($line->code_journal, 6).$separator;
1755 if (!empty($line->subledger_account)) {
1756 $account = $line->subledger_account;
1758 $account = $line->numero_compte;
1762 print
self::trunc($line->label_compte, 60).$separator;
1765 $line->label_operation = str_replace(array(
"\t",
"\n",
"\r"),
" ", $line->label_operation);
1766 print
self::trunc($line->label_operation, 60).$separator;
1767 print
price(abs($line->debit - $line->credit)).$separator;
1768 print $line->sens.$separator;
1790 $this->separator =
',';
1792 $invoices_infos = array();
1793 $supplier_invoices_infos = array();
1794 foreach ($objectLines as $line) {
1795 if ($line->debit == 0 && $line->credit == 0) {
1800 $invoice_ref = $line->doc_ref;
1803 if (($line->doc_type ==
'customer_invoice' || $line->doc_type ==
'supplier_invoice') && $line->fk_doc > 0) {
1804 if (($line->doc_type ==
'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) ||
1805 ($line->doc_type ==
'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) {
1806 if ($line->doc_type ==
'customer_invoice') {
1808 $sql =
'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX .
'facture as f';
1809 $sql .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe AS s ON f.fk_soc = s.rowid';
1810 $sql .=
' WHERE f.rowid = '.((int) $line->fk_doc);
1813 if ($obj = $this->
db->fetch_object(
$resql)) {
1815 $invoices_infos[$line->fk_doc] = array(
'ref' => $obj->ref,
'company_name' => $obj->nom);
1816 $invoice_ref = $obj->ref;
1817 $company_name = $obj->nom;
1822 $sql =
'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX .
'facture_fourn as ff';
1823 $sql .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe AS s ON ff.fk_soc = s.rowid';
1824 $sql .=
' WHERE ff.rowid = '.((int) $line->fk_doc);
1827 if ($obj = $this->
db->fetch_object(
$resql)) {
1829 $supplier_invoices_infos[$line->fk_doc] = array(
'ref' => $obj->ref,
'company_name' => $obj->nom);
1830 $invoice_ref = $obj->ref;
1831 $company_name = $obj->nom;
1835 } elseif ($line->doc_type ==
'customer_invoice') {
1837 $invoice_ref = $invoices_infos[$line->fk_doc][
'ref'];
1838 $company_name = $invoices_infos[$line->fk_doc][
'company_name'];
1841 $invoice_ref = $supplier_invoices_infos[$line->fk_doc][
'ref'];
1842 $company_name = $supplier_invoices_infos[$line->fk_doc][
'company_name'];
1846 print $line->id . $this->separator;
1847 print $date . $this->separator;
1848 print substr($line->code_journal, 0, 4) . $this->separator;
1850 if ((substr($line->numero_compte, 0, 3) ==
'411') || (substr($line->numero_compte, 0, 3) ==
'401')) {
1853 print substr(
length_accountg($line->numero_compte), 0, 15) . $this->separator;
1856 print $this->separator;
1859 print
dol_trunc(str_replace(
'"',
'', $invoice_ref . (!empty($company_name) ?
' - ' :
'') . $company_name), 40,
'right',
'UTF-8', 1) . $this->separator;
1861 print
dol_trunc(str_replace(
'"',
'', $line->piece_num), 10,
'right',
'UTF-8', 1) . $this->separator;
1863 print
'EUR' . $this->separator;
1865 print
price2num(abs($line->debit - $line->credit)) . $this->separator;
1867 print $line->sens . $this->separator;
1869 print $this->separator;
1872 print $this->end_line;
1887 $this->separator =
',';
1889 foreach ($objectLines as $line) {
1890 if ($line->debit == 0 && $line->credit == 0) {
1895 print $line->id . $this->separator;
1896 print $date . $this->separator;
1897 print substr($line->code_journal, 0, 4) . $this->separator;
1898 if ((substr($line->numero_compte, 0, 3) ==
'411') || (substr($line->numero_compte, 0, 3) ==
'401')) {
1901 print substr(
length_accountg($line->numero_compte), 0, 15) . $this->separator;
1903 print $this->separator;
1905 print
'"' .
dol_trunc(str_replace(
'"',
'', $line->doc_ref), 40,
'right',
'UTF-8', 1) .
'"' . $this->separator;
1906 print
'"' .
dol_trunc(str_replace(
'"',
'', $line->piece_num), 10,
'right',
'UTF-8', 1) .
'"' . $this->separator;
1907 print
price2num(abs($line->debit - $line->credit)) . $this->separator;
1908 print $line->sens . $this->separator;
1909 print $date . $this->separator;
1910 print $this->separator;
1911 print $this->separator;
1913 print $this->end_line;
1929 $this->separator =
';';
1930 $this->end_line =
"\r\n";
1933 foreach ($objectLines as $line) {
1938 $tab[] = $line->piece_num;
1940 $tab[] = substr($date, 6, 4);
1941 $tab[] = substr($date, 3, 2);
1942 $tab[] = substr($date, 0, 2);
1943 $tab[] = $line->doc_ref;
1945 $tab[] = mb_convert_encoding(str_replace(
' - Compte auxiliaire',
'', $line->label_operation),
"Windows-1252",
'UTF-8');
1951 $numero_cpt_client =
'411';
1952 for ($i = 1; $i <= ($taille_numero - 3); $i++) {
1953 $numero_cpt_client .=
'0';
1962 $nom_client = explode(
" - ", $line->label_operation);
1963 $tab[] = mb_convert_encoding($nom_client[0],
"Windows-1252",
'UTF-8');
1964 $tab[] =
price($line->debit);
1965 $tab[] =
price($line->credit);
1966 $tab[] =
price($line->montant);
1967 $tab[] = $line->code_journal;
1969 $separator = $this->separator;
1970 print implode($separator, $tab) . $this->end_line;
1981 public static function trunc($str, $size)
1983 return dol_trunc($str, $size,
'right',
'UTF-8', 1);
1993 public static function toAnsi($str, $size = -1)
1996 if ($retVal >= 0 && $size >= 0) {
1997 $retVal = mb_substr($retVal, 0, $size,
'Windows-1251');