35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
45 public static $EXPORT_TYPE_CONFIGURABLE = 1;
46 public static $EXPORT_TYPE_AGIRIS = 10;
47 public static $EXPORT_TYPE_EBP = 15;
48 public static $EXPORT_TYPE_CEGID = 20;
49 public static $EXPORT_TYPE_COGILOG = 25;
50 public static $EXPORT_TYPE_COALA = 30;
51 public static $EXPORT_TYPE_BOB50 = 35;
52 public static $EXPORT_TYPE_CIEL = 40;
53 public static $EXPORT_TYPE_SAGE50_SWISS = 45;
54 public static $EXPORT_TYPE_CHARLEMAGNE = 50;
55 public static $EXPORT_TYPE_QUADRATUS = 60;
56 public static $EXPORT_TYPE_WINFIC = 70;
57 public static $EXPORT_TYPE_OPENCONCERTO = 100;
58 public static $EXPORT_TYPE_LDCOMPTA = 110;
59 public static $EXPORT_TYPE_LDCOMPTA10 = 120;
60 public static $EXPORT_TYPE_GESTIMUMV3 = 130;
61 public static $EXPORT_TYPE_GESTIMUMV5 = 135;
62 public static $EXPORT_TYPE_FEC = 1000;
63 public static $EXPORT_TYPE_FEC2 = 1010;
69 public $errors = array();
75 public $separator =
'';
81 public $end_line =
'';
93 $this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
94 $this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ?
"\n" : ($conf->global->ACCOUNTING_EXPORT_ENDLINE == 1 ?
"\n" :
"\r\n");
106 $listofexporttypes = array(
107 self::$EXPORT_TYPE_CONFIGURABLE => $langs->trans(
'Modelcsv_configurable'),
108 self::$EXPORT_TYPE_CEGID => $langs->trans(
'Modelcsv_CEGID'),
109 self::$EXPORT_TYPE_COALA => $langs->trans(
'Modelcsv_COALA'),
110 self::$EXPORT_TYPE_BOB50 => $langs->trans(
'Modelcsv_bob50'),
111 self::$EXPORT_TYPE_CIEL => $langs->trans(
'Modelcsv_ciel'),
112 self::$EXPORT_TYPE_QUADRATUS => $langs->trans(
'Modelcsv_quadratus'),
113 self::$EXPORT_TYPE_WINFIC => $langs->trans(
'Modelcsv_winfic'),
114 self::$EXPORT_TYPE_EBP => $langs->trans(
'Modelcsv_ebp'),
115 self::$EXPORT_TYPE_COGILOG => $langs->trans(
'Modelcsv_cogilog'),
116 self::$EXPORT_TYPE_AGIRIS => $langs->trans(
'Modelcsv_agiris'),
117 self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans(
'Modelcsv_openconcerto'),
118 self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans(
'Modelcsv_Sage50_Swiss'),
119 self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans(
'Modelcsv_charlemagne'),
120 self::$EXPORT_TYPE_LDCOMPTA => $langs->trans(
'Modelcsv_LDCompta'),
121 self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans(
'Modelcsv_LDCompta10'),
122 self::$EXPORT_TYPE_GESTIMUMV3 => $langs->trans(
'Modelcsv_Gestinum_v3'),
123 self::$EXPORT_TYPE_GESTIMUMV5 => $langs->trans(
'Modelcsv_Gestinum_v5'),
124 self::$EXPORT_TYPE_FEC => $langs->trans(
'Modelcsv_FEC'),
125 self::$EXPORT_TYPE_FEC2 => $langs->trans(
'Modelcsv_FEC2'),
128 ksort($listofexporttypes, SORT_NUMERIC);
130 return $listofexporttypes;
142 self::$EXPORT_TYPE_CONFIGURABLE =>
'csv',
143 self::$EXPORT_TYPE_CEGID =>
'cegid',
144 self::$EXPORT_TYPE_COALA =>
'coala',
145 self::$EXPORT_TYPE_BOB50 =>
'bob50',
146 self::$EXPORT_TYPE_CIEL =>
'ciel',
147 self::$EXPORT_TYPE_QUADRATUS =>
'quadratus',
148 self::$EXPORT_TYPE_WINFIC =>
'winfic',
149 self::$EXPORT_TYPE_EBP =>
'ebp',
150 self::$EXPORT_TYPE_COGILOG =>
'cogilog',
151 self::$EXPORT_TYPE_AGIRIS =>
'agiris',
152 self::$EXPORT_TYPE_OPENCONCERTO =>
'openconcerto',
153 self::$EXPORT_TYPE_SAGE50_SWISS =>
'sage50ch',
154 self::$EXPORT_TYPE_CHARLEMAGNE =>
'charlemagne',
155 self::$EXPORT_TYPE_LDCOMPTA =>
'ldcompta',
156 self::$EXPORT_TYPE_LDCOMPTA10 =>
'ldcompta10',
157 self::$EXPORT_TYPE_GESTIMUMV3 =>
'gestimumv3',
158 self::$EXPORT_TYPE_GESTIMUMV5 =>
'gestimumv5',
159 self::$EXPORT_TYPE_FEC =>
'fec',
160 self::$EXPORT_TYPE_FEC2 =>
'fec2',
163 return $formatcode[$type];
173 global $conf, $langs;
177 self::$EXPORT_TYPE_CONFIGURABLE => array(
178 'label' => $langs->trans(
'Modelcsv_configurable'),
179 'ACCOUNTING_EXPORT_FORMAT' => empty($conf->global->ACCOUNTING_EXPORT_FORMAT) ?
'txt' : $conf->global->ACCOUNTING_EXPORT_FORMAT,
180 'ACCOUNTING_EXPORT_SEPARATORCSV' => empty($conf->global->ACCOUNTING_EXPORT_SEPARATORCSV) ?
',' : $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV,
181 'ACCOUNTING_EXPORT_ENDLINE' => empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? 1 : $conf->global->ACCOUNTING_EXPORT_ENDLINE,
182 'ACCOUNTING_EXPORT_DATE' => empty($conf->global->ACCOUNTING_EXPORT_DATE) ?
'%d%m%Y' : $conf->global->ACCOUNTING_EXPORT_DATE,
184 self::$EXPORT_TYPE_CEGID => array(
185 'label' => $langs->trans(
'Modelcsv_CEGID'),
187 self::$EXPORT_TYPE_COALA => array(
188 'label' => $langs->trans(
'Modelcsv_COALA'),
190 self::$EXPORT_TYPE_BOB50 => array(
191 'label' => $langs->trans(
'Modelcsv_bob50'),
193 self::$EXPORT_TYPE_CIEL => array(
194 'label' => $langs->trans(
'Modelcsv_ciel'),
195 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
197 self::$EXPORT_TYPE_QUADRATUS => array(
198 'label' => $langs->trans(
'Modelcsv_quadratus'),
199 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
201 self::$EXPORT_TYPE_WINFIC => array(
202 'label' => $langs->trans(
'Modelcsv_winfic'),
203 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
205 self::$EXPORT_TYPE_EBP => array(
206 'label' => $langs->trans(
'Modelcsv_ebp'),
208 self::$EXPORT_TYPE_COGILOG => array(
209 'label' => $langs->trans(
'Modelcsv_cogilog'),
211 self::$EXPORT_TYPE_AGIRIS => array(
212 'label' => $langs->trans(
'Modelcsv_agiris'),
214 self::$EXPORT_TYPE_OPENCONCERTO => array(
215 'label' => $langs->trans(
'Modelcsv_openconcerto'),
217 self::$EXPORT_TYPE_SAGE50_SWISS => array(
218 'label' => $langs->trans(
'Modelcsv_Sage50_Swiss'),
220 self::$EXPORT_TYPE_CHARLEMAGNE => array(
221 'label' => $langs->trans(
'Modelcsv_charlemagne'),
222 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
224 self::$EXPORT_TYPE_LDCOMPTA => array(
225 'label' => $langs->trans(
'Modelcsv_LDCompta'),
227 self::$EXPORT_TYPE_LDCOMPTA10 => array(
228 'label' => $langs->trans(
'Modelcsv_LDCompta10'),
230 self::$EXPORT_TYPE_GESTIMUMV3 => array(
231 'label' => $langs->trans(
'Modelcsv_Gestinumv3'),
232 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
234 self::$EXPORT_TYPE_GESTIMUMV5 => array(
235 'label' => $langs->trans(
'Modelcsv_Gestinumv5'),
236 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
238 self::$EXPORT_TYPE_FEC => array(
239 'label' => $langs->trans(
'Modelcsv_FEC'),
240 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
242 self::$EXPORT_TYPE_FEC2 => array(
243 'label' => $langs->trans(
'Modelcsv_FEC2'),
244 'ACCOUNTING_EXPORT_FORMAT' =>
'txt',
248 '1' => $langs->trans(
"Unix"),
249 '2' => $langs->trans(
"Windows")
252 'csv' => $langs->trans(
"csv"),
253 'txt' => $langs->trans(
"txt")
266 public function export(&$TData, $formatexportset)
268 global $conf, $langs;
269 global $search_date_end;
272 $filename =
'general_ledger-'.$this->getFormatCode($formatexportset);
273 $type_export =
'general_ledger';
276 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
279 switch ($formatexportset) {
280 case self::$EXPORT_TYPE_CONFIGURABLE :
283 case self::$EXPORT_TYPE_CEGID :
286 case self::$EXPORT_TYPE_COALA :
289 case self::$EXPORT_TYPE_BOB50 :
292 case self::$EXPORT_TYPE_CIEL :
295 case self::$EXPORT_TYPE_QUADRATUS :
298 case self::$EXPORT_TYPE_WINFIC :
301 case self::$EXPORT_TYPE_EBP :
304 case self::$EXPORT_TYPE_COGILOG :
307 case self::$EXPORT_TYPE_AGIRIS :
310 case self::$EXPORT_TYPE_OPENCONCERTO :
313 case self::$EXPORT_TYPE_SAGE50_SWISS :
316 case self::$EXPORT_TYPE_CHARLEMAGNE :
319 case self::$EXPORT_TYPE_LDCOMPTA :
322 case self::$EXPORT_TYPE_LDCOMPTA10 :
325 case self::$EXPORT_TYPE_GESTIMUMV3 :
328 case self::$EXPORT_TYPE_GESTIMUMV5 :
331 case self::$EXPORT_TYPE_FEC :
334 case self::$EXPORT_TYPE_FEC2 :
338 $this->errors[] = $langs->trans(
'accountancy_error_modelnotfound');
352 foreach ($objectLines as $line) {
357 print $date.$separator;
358 print $line->code_journal.$separator;
361 print $line->sens.$separator;
377 foreach ($objectLines as $line) {
382 print $line->code_journal.$separator;
383 print $date.$separator;
384 print $line->piece_num.$separator;
387 print $line->label_operation.$separator;
388 print $date.$separator;
389 if ($line->sens ==
'D') {
392 } elseif ($line->sens ==
'C') {
396 print $line->doc_ref.$separator;
397 print $line->label_operation.$separator;
414 foreach ($objectLines as $line) {
417 print $date.$separator;
418 print $line->code_journal.$separator;
420 print $line->piece_num.$separator;
421 print $line->doc_ref.$separator;
424 print 'E'.$separator;
443 foreach ($objectLines as $line) {
444 print $line->piece_num.$separator;
446 print $date.$separator;
448 if (empty($line->subledger_account)) {
449 print 'G'.$separator;
452 if (substr($line->numero_compte, 0, 3) ==
'411') {
453 print 'C'.$separator;
455 if (substr($line->numero_compte, 0, 3) ==
'401') {
456 print 'F'.$separator;
482 foreach ($TData as $data) {
483 $code_compta = $data->numero_compte;
484 if (!empty($data->subledger_account))
485 $code_compta = $data->subledger_account;
488 $Tab[
'num_ecriture'] = str_pad($i, 5);
489 $Tab[
'code_journal'] = str_pad($data->code_journal, 2);
490 $Tab[
'date_ecriture'] = $date_ecriture;
491 $Tab[
'date_ope'] =
dol_print_date($data->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
492 $Tab[
'num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12);
493 $Tab[
'num_compte'] = str_pad(self::trunc($code_compta, 11), 11);
494 $Tab[
'libelle_ecriture'] = str_pad(self::trunc(
dol_string_unaccent($data->doc_ref).dol_string_unaccent($data->label_operation), 25), 25);
495 $Tab[
'montant'] = str_pad(abs($data->debit - $data->credit), 13,
' ', STR_PAD_LEFT);
496 $Tab[
'type_montant'] = str_pad($data->sens, 1);
497 $Tab[
'vide'] = str_repeat(
' ', 18);
498 $Tab[
'intitule_compte'] = str_pad(self::trunc(
dol_string_unaccent($data->label_operation), 34), 34);
499 $Tab[
'end'] =
'O2003';
501 $Tab[
'end_line'] = $end_line;
523 foreach ($TData as $data) {
524 $code_compta = $data->numero_compte;
525 if (!empty($data->subledger_account))
526 $code_compta = $data->subledger_account;
529 $Tab[
'type_ligne'] =
'M';
530 $Tab[
'num_compte'] = str_pad(self::trunc($code_compta, 8), 8);
531 $Tab[
'code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
532 $Tab[
'folio'] =
'000';
537 $Tab[
'date_ecriture'] =
dol_print_date($data->doc_date,
'%d%m%y');
538 $Tab[
'filler'] =
' ';
554 $Tab[
'sens'] = $data->sens;
555 $Tab[
'signe_montant'] =
'+';
558 $Tab[
'montant'] = str_pad(abs(($data->debit - $abs->credit) * 100), 12,
'0', STR_PAD_LEFT);
559 $Tab[
'contrepartie'] = str_repeat(
' ', 8);
562 if (!empty($data->date_echeance)) {
564 $Tab[
'date_echeance'] =
dol_print_date($data->date_echeance,
'%d%m%y');
566 $Tab[
'date_echeance'] =
'000000';
571 $Tab[
'lettrage'] = str_repeat(
' ', 2);
572 $Tab[
'codestat'] = str_repeat(
' ', 3);
573 $Tab[
'num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5);
577 $Tab[
'affaire'] = str_repeat(
' ', 10);
578 $Tab[
'quantity1'] = str_repeat(
' ', 10);
579 $Tab[
'num_piece2'] = str_pad(self::trunc($data->piece_num, 8), 8);
580 $Tab[
'devis'] = str_pad($conf->currency, 3);
581 $Tab[
'code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3);
582 $Tab[
'filler3'] = str_repeat(
' ', 3);
590 $Tab[
'libelle_ecriture2'] = str_pad(self::trunc(
dol_string_unaccent($data->label_operation), 30), 30);
591 $Tab[
'codetva'] = str_repeat(
' ', 2);
595 $Tab[
'num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10);
596 $Tab[
'filler4'] = str_repeat(
' ', 73);
598 $Tab[
'end_line'] = $end_line;
620 foreach ($TData as $data) {
621 $code_compta = $data->numero_compte;
622 if (!empty($data->subledger_account))
623 $code_compta = $data->subledger_account;
627 $Tab[
'code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
632 $Tab[
'date_operation'] =
dol_print_date($data->doc_date,
'%d%m%Y');
634 $Tab[
'folio'] =
' 1';
636 $Tab[
'num_ecriture'] = str_pad(self::trunc($data->piece_num, 6), 6,
' ', STR_PAD_LEFT);
638 $Tab[
'jour_ecriture'] =
dol_print_date($data->doc_date,
'%d%m%y');
640 $Tab[
'num_compte'] = str_pad(self::trunc($code_compta, 6), 6,
'0');
642 if ($data->sens ==
'D') {
643 $Tab[
'montant_debit'] = str_pad(number_format($data->debit, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
645 $Tab[
'montant_crebit'] = str_pad(number_format(0, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
647 $Tab[
'montant_debit'] = str_pad(number_format(0, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
649 $Tab[
'montant_crebit'] = str_pad(number_format($data->credit, 2,
',',
''), 13,
' ', STR_PAD_LEFT);
654 $Tab[
'lettrage'] = str_repeat(
' ', 2);
656 $Tab[
'code_piece'] = str_repeat(
' ', 5);
658 $Tab[
'code_stat'] = str_repeat(
' ', 4);
660 if (!empty($data->date_echeance)) {
662 $Tab[
'date_echeance'] =
dol_print_date($data->date_echeance,
'%d%m%Y');
664 $Tab[
'date_echeance'] =
dol_print_date($data->doc_date,
'%d%m%Y');
667 $Tab[
'monnaie'] =
'1';
669 $Tab[
'filler'] =
' ';
671 $Tab[
'ind_compteur'] =
' ';
673 $Tab[
'quantite'] =
'0,000000000';
675 $Tab[
'code_pointage'] = str_repeat(
' ', 2);
677 $Tab[
'end_line'] = $end_line;
679 print implode(
'|', $Tab);
696 foreach ($objectLines as $line) {
699 print $line->id.$separator;
700 print $date.$separator;
701 print $line->code_journal.$separator;
702 if (empty($line->subledger_account)) {
703 print $line->numero_compte.$separator;
705 print $line->subledger_account.$separator;
708 print '"'.dol_trunc($line->label_operation, 40,
'right',
'UTF-8', 1).
'"'.$separator;
709 print '"'.dol_trunc($line->piece_num, 15,
'right',
'UTF-8', 1).
'"'.$separator;
711 print $line->sens.$separator;
712 print $date.$separator;
731 foreach ($objectLines as $line) {
734 print $line->piece_num.$separator;
735 print self::toAnsi($line->label_operation).$separator;
736 print $date.$separator;
737 print self::toAnsi($line->label_operation).$separator;
739 if (empty($line->subledger_account)) {
741 print self::toAnsi($line->label_compte).$separator;
744 print self::toAnsi($line->subledger_label).$separator;
747 print self::toAnsi($line->doc_ref).$separator;
750 print price(abs($line->debit - $line->credit)).$separator;
751 print $line->sens.$separator;
752 print $line->lettering_code.$separator;
753 print $line->code_journal;
770 foreach ($objectLines as $line) {
773 print $date.$separator;
774 print $line->code_journal.$separator;
775 if (empty($line->subledger_account)) {
780 print $line->doc_ref.$separator;
781 print $line->label_operation.$separator;
799 $separator = $this->separator;
801 foreach ($objectLines as $line) {
804 $date =
dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
805 $tab[] = $line->piece_num;
807 $tab[] = $line->doc_ref;
808 $tab[] = preg_match(
'/'.$separator.
'/', $line->label_operation) ?
"'".$line->label_operation.
"'" : $line->label_operation;
813 $tab[] =
price2num($line->debit - $line->credit);
814 $tab[] = $line->code_journal;
816 print implode($separator, $tab).$this->end_line;
833 print "JournalCode".$separator;
834 print "JournalLib".$separator;
835 print "EcritureNum".$separator;
836 print "EcritureDate".$separator;
837 print "CompteNum".$separator;
838 print "CompteLib".$separator;
839 print "CompAuxNum".$separator;
840 print "CompAuxLib".$separator;
841 print "PieceRef".$separator;
842 print "PieceDate".$separator;
843 print "EcritureLib".$separator;
844 print "Debit".$separator;
845 print "Credit".$separator;
846 print "EcritureLet".$separator;
847 print "DateLet".$separator;
848 print "ValidDate".$separator;
849 print "Montantdevise".$separator;
853 foreach ($objectLines as $line) {
854 if ($line->debit == 0 && $line->credit == 0) {
859 $date_lettering =
dol_print_date($line->date_lettering,
'%Y%m%d');
860 $date_validation =
dol_print_date($line->date_validated,
'%Y%m%d');
863 print $line->code_journal . $separator;
869 print $line->piece_num . $separator;
872 print $date_document . $separator;
875 print $line->numero_compte . $separator;
881 print $line->subledger_account . $separator;
887 print $line->doc_ref . $separator;
902 print $line->lettering_code . $separator;
905 print $date_lettering . $separator;
908 print $date_validation . $separator;
911 print $line->multicurrency_amount . $separator;
914 print $line->multicurrency_code;
934 print "JournalCode".$separator;
935 print "JournalLib".$separator;
936 print "EcritureNum".$separator;
937 print "EcritureDate".$separator;
938 print "CompteNum".$separator;
939 print "CompteLib".$separator;
940 print "CompAuxNum".$separator;
941 print "CompAuxLib".$separator;
942 print "PieceRef".$separator;
943 print "PieceDate".$separator;
944 print "EcritureLib".$separator;
945 print "Debit".$separator;
946 print "Credit".$separator;
947 print "EcritureLet".$separator;
948 print "DateLet".$separator;
949 print "ValidDate".$separator;
950 print "Montantdevise".$separator;
954 foreach ($objectLines as $line) {
955 if ($line->debit == 0 && $line->credit == 0) {
960 $date_lettering =
dol_print_date($line->date_lettering,
'%Y%m%d');
961 $date_validation =
dol_print_date($line->date_validated,
'%Y%m%d');
964 print $line->code_journal . $separator;
970 print $line->piece_num . $separator;
973 print $date_creation . $separator;
976 print $line->numero_compte . $separator;
982 print $line->subledger_account . $separator;
988 print $line->doc_ref . $separator;
991 print $date_document . $separator;
1003 print $line->lettering_code . $separator;
1006 print $date_lettering . $separator;
1009 print $date_validation . $separator;
1012 print $line->multicurrency_amount . $separator;
1015 print $line->multicurrency_code;
1035 $this->separator =
',';
1036 $this->end_line =
"\r\n";
1039 print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag";
1040 print $this->end_line;
1042 $thisPieceAccountNr =
"";
1043 $aSize = count($objectLines);
1044 foreach ($objectLines as $aIndex=>$line)
1046 $sammelBuchung =
false;
1047 if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num)
1049 $sammelBuchung =
true;
1050 } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num)
1052 $sammelBuchung =
true;
1053 } elseif ($aIndex + 1 < $aSize
1054 && $objectLines[$aIndex + 1]->piece_num == $line->piece_num
1055 && $aIndex - 1 < $aSize
1056 && $objectLines[$aIndex - 1]->piece_num == $line->piece_num
1059 $sammelBuchung =
true;
1063 print $line->piece_num.$this->separator;
1067 print $date.$this->separator;
1072 if ($line->sens ==
'D')
1074 print 'S'.$this->separator;
1076 print 'H'.$this->separator;
1079 print self::trunc($line->code_journal, 1).$this->separator;
1081 if (empty($line->code_tiers))
1083 if ($line->piece_num == $thisPieceNum)
1087 print "div".$this->separator;
1093 print $this->separator;
1095 print "0".$this->separator;
1097 print "0".$this->separator;
1099 print "0".$this->separator;
1104 print "2".$this->separator;
1106 print "1".$this->separator;
1109 print '""'.$this->separator;
1111 print abs($line->debit - $line->credit).$this->separator;
1113 print "0.00".$this->separator;
1115 print "0.00".$this->separator;
1117 $line1 = self::toAnsi($line->label_compte, 29);
1118 if ($line1 ==
"LIQ" || $line1 ==
"LIQ Beleg ok" || strlen($line1) <= 3)
1122 $line2 = self::toAnsi($line->doc_ref, 29);
1123 if (strlen($line1) == 0)
1128 if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27)
1130 $line1 = $line1.
' / '.$line2;
1134 print '"'.self::toAnsi($line1).
'"'.$this->separator;
1136 print '"'.self::toAnsi($line2).
'"'.$this->separator;
1138 print "0".$this->separator;
1140 print $this->separator;
1145 print $this->end_line;
1147 if ($line->piece_num !== $thisPieceNum)
1149 $thisPieceNum = $line->piece_num;
1150 $thisPieceAccountNr = $line->numero_compte;
1169 foreach ($objectLines as $line) {
1172 $date_lim_reglement =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1175 $type_enregistrement =
'E';
1176 print $type_enregistrement.$separator;
1178 print substr($line->code_journal, 0, 2).$separator;
1180 print $line->id.$separator;
1182 print $line->piece_num.$separator;
1184 print $date_document.$separator;
1186 print $line->label_operation.$separator;
1188 print $date_lim_reglement.$separator;
1190 if ($line->doc_type ==
'supplier_invoice') {
1191 if (($line->debit - $line->credit) > 0) {
1192 $nature_piece =
'AF';
1194 $nature_piece =
'FF';
1196 } elseif ($line->doc_type ==
'customer_invoice') {
1197 if (($line->debit - $line->credit) < 0) {
1198 $nature_piece =
'AC';
1200 $nature_piece =
'FC';
1205 print $nature_piece.$separator;
1216 $racine_subledger_account =
'';
1219 print $racine_subledger_account.$separator;
1221 print price(abs($line->debit - $line->credit), 0,
'', 1, 2, 2).$separator;
1223 print $line->sens.$separator;
1227 print $date_creation.$separator;
1229 print $line->lettering_code.$separator;
1231 print $line->date_lettering.$separator;
1233 if (!empty($line->subledger_account)) {
1239 if ($line->doc_type ==
'supplier_invoice' && !empty($line->subledger_account)) {
1240 print 'F'.$separator;
1241 } elseif ($line->doc_type ==
'customer_invoice' && !empty($line->subledger_account)) {
1242 print 'C'.$separator;
1255 print $line->doc_ref.$separator;
1261 print '0'.$separator;
1265 print '0'.$separator;
1297 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
1301 $last_codeinvoice =
'';
1303 foreach ($objectLines as $line) {
1305 if ($last_codeinvoice != $line->doc_ref) {
1307 $sql =
"SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX.
"societe";
1308 $sql .=
" WHERE code_client = '".$this->db->escape($line->thirdparty_code).
"'";
1313 $soc = $this->
db->fetch_object(
$resql);
1315 $address = array(
'',
'',
'');
1316 if (strpos($soc->address,
"\n") !==
false) {
1317 $address = explode(
"\n", $soc->address);
1318 if (is_array($address) && count($address) > 0) {
1319 foreach ($address as $key=>$data) {
1320 $address[$key] = str_replace(array(
"\t",
"\n",
"\r"),
"", $data);
1321 $address[$key] =
dol_trunc($address[$key], 40,
'right',
'UTF-8', 1);
1325 $address[0] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 0, 40);
1326 $address[1] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 41, 40);
1327 $address[2] = substr(str_replace(array(
"\t",
"\r"),
" ", $soc->address), 82, 40);
1330 $type_enregistrement =
'C';
1332 print $type_enregistrement.$separator;
1334 print $soc->code_client.$separator;
1342 print $soc->nom.$separator;
1344 print $address[0].$separator;
1346 print $address[1].$separator;
1348 print $address[2].$separator;
1350 print $soc->zip.$separator;
1352 print substr($soc->town, 0, 40).$separator;
1358 print $soc->phone.$separator;
1370 print str_replace(
" ",
"", $soc->siret).$separator;
1434 $date_lim_reglement =
dol_print_date($line->date_lim_reglement,
'%Y%m%d');
1437 $type_enregistrement =
'E';
1438 print $type_enregistrement.$separator;
1440 print substr($line->code_journal, 0, 2).$separator;
1442 print $line->id.$separator;
1444 print $line->piece_num.$separator;
1446 print $date_document.$separator;
1448 print dol_trunc($line->label_operation, 25,
'right',
'UTF-8', 1).$separator;
1450 print $date_lim_reglement.$separator;
1452 if ($line->doc_type ==
'supplier_invoice') {
1453 if (($line->debit - $line->credit) > 0) {
1454 $nature_piece =
'AF';
1456 $nature_piece =
'FF';
1458 } elseif ($line->doc_type ==
'customer_invoice') {
1459 if (($line->debit - $line->credit) < 0) {
1460 $nature_piece =
'AC';
1462 $nature_piece =
'FC';
1467 print $nature_piece.$separator;
1478 $racine_subledger_account =
'';
1481 print $racine_subledger_account.$separator;
1483 print price(abs($line->debit - $line->credit), 0,
'', 1, 2).$separator;
1485 print $line->sens.$separator;
1489 print $date_document.$separator;
1491 print $line->lettering_code.$separator;
1493 print $line->date_lettering.$separator;
1495 if (!empty($line->subledger_account)) {
1501 if ($line->doc_type ==
'supplier_invoice' && !empty($line->subledger_account)) {
1502 print 'F'.$separator;
1503 } elseif ($line->doc_type ==
'customer_invoice' && !empty($line->subledger_account)) {
1504 print 'C'.$separator;
1515 print $line->doc_ref.$separator;
1517 print '0'.$separator;
1527 print '0'.$separator;
1531 print '0'.$separator;
1551 $last_codeinvoice = $line->doc_ref;
1564 $langs->load(
'compta');
1572 print $langs->transnoentitiesnoconv(
'Date').$separator;
1573 print self::trunc($langs->transnoentitiesnoconv(
'Journal'), 6).$separator;
1574 print self::trunc($langs->transnoentitiesnoconv(
'Account'), 15).$separator;
1575 print self::trunc($langs->transnoentitiesnoconv(
'LabelAccount'), 60).$separator;
1576 print self::trunc($langs->transnoentitiesnoconv(
'Piece'), 20).$separator;
1577 print self::trunc($langs->transnoentitiesnoconv(
'LabelOperation'), 60).$separator;
1578 print $langs->transnoentitiesnoconv(
'Amount').$separator;
1579 print 'S'.$separator;
1580 print self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 1', 15).$separator;
1581 print self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 1', 60).$separator;
1582 print self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 2', 15).$separator;
1583 print self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 2', 60).$separator;
1584 print self::trunc($langs->transnoentitiesnoconv(
'Analytic').
' 3', 15).$separator;
1585 print self::trunc($langs->transnoentitiesnoconv(
'AnalyticLabel').
' 3', 60).$separator;
1588 foreach ($objectLines as $line) {
1590 print $date.$separator;
1592 print self::trunc($line->code_journal, 6).$separator;
1594 if (!empty($line->subledger_account)) $account = $line->subledger_account;
1596 $account = $line->numero_compte;
1598 print self::trunc($account, 15).$separator;
1600 print self::trunc($line->label_compte, 60).$separator;
1601 print self::trunc($line->doc_ref, 20).$separator;
1602 print self::trunc($line->label_operation, 60).$separator;
1603 print price(abs($line->debit - $line->credit)).$separator;
1604 print $line->sens.$separator;
1626 $this->separator =
',';
1628 $invoices_infos = array();
1629 $supplier_invoices_infos = array();
1630 foreach ($objectLines as $line) {
1631 if ($line->debit == 0 && $line->credit == 0) {
1636 $invoice_ref = $line->doc_ref;
1639 if (($line->doc_type ==
'customer_invoice' || $line->doc_type ==
'supplier_invoice') && $line->fk_doc > 0) {
1640 if (($line->doc_type ==
'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) ||
1641 ($line->doc_type ==
'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) {
1642 if ($line->doc_type ==
'customer_invoice') {
1644 $sql =
'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX .
'facture as f';
1645 $sql .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe AS s ON f.fk_soc = s.rowid';
1646 $sql .=
' WHERE f.rowid = ' . $line->fk_doc;
1649 if ($obj = $this->
db->fetch_object(
$resql)) {
1651 $invoices_infos[$line->fk_doc] = array(
'ref' => $obj->ref,
'company_name' => $obj->nom);
1652 $invoice_ref = $obj->ref;
1653 $company_name = $obj->nom;
1658 $sql =
'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX .
'facture_fourn as ff';
1659 $sql .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe AS s ON ff.fk_soc = s.rowid';
1660 $sql .=
' WHERE ff.rowid = ' . $line->fk_doc;
1663 if ($obj = $this->
db->fetch_object(
$resql)) {
1665 $supplier_invoices_infos[$line->fk_doc] = array(
'ref' => $obj->ref,
'company_name' => $obj->nom);
1666 $invoice_ref = $obj->ref;
1667 $company_name = $obj->nom;
1671 } elseif ($line->doc_type ==
'customer_invoice') {
1673 $invoice_ref = $invoices_infos[$line->fk_doc][
'ref'];
1674 $company_name = $invoices_infos[$line->fk_doc][
'company_name'];
1677 $invoice_ref = $supplier_invoices_infos[$line->fk_doc][
'ref'];
1678 $company_name = $supplier_invoices_infos[$line->fk_doc][
'company_name'];
1682 print $line->id . $this->separator;
1683 print $date . $this->separator;
1684 print substr($line->code_journal, 0, 4) . $this->separator;
1686 if ((substr($line->numero_compte, 0, 3) ==
'411') || (substr($line->numero_compte, 0, 3) ==
'401')) {
1692 print $this->separator;
1695 print dol_trunc(str_replace(
'"',
'', $invoice_ref . (!empty($company_name) ?
' - ' :
'') . $company_name), 40,
'right',
'UTF-8', 1) . $this->separator;
1697 print dol_trunc(str_replace(
'"',
'', $line->piece_num), 10,
'right',
'UTF-8', 1) . $this->separator;
1699 print 'EUR' . $this->separator;
1701 print price2num(abs($line->debit - $line->credit)) . $this->separator;
1703 print $line->sens . $this->separator;
1705 print $this->separator;
1708 print $this->end_line;
1723 $this->separator =
',';
1725 foreach ($objectLines as $line) {
1726 if ($line->debit == 0 && $line->credit == 0) {
1731 print $line->id . $this->separator;
1732 print $date . $this->separator;
1733 print substr($line->code_journal, 0, 4) . $this->separator;
1734 if ((substr($line->numero_compte, 0, 3) ==
'411') || (substr($line->numero_compte, 0, 3) ==
'401')) {
1739 print $this->separator;
1741 print '"' .
dol_trunc(str_replace(
'"',
'', $line->doc_ref), 40,
'right',
'UTF-8', 1) .
'"' . $this->separator;
1742 print '"' .
dol_trunc(str_replace(
'"',
'', $line->piece_num), 10,
'right',
'UTF-8', 1) .
'"' . $this->separator;
1743 print price2num(abs($line->debit - $line->credit)) . $this->separator;
1744 print $line->sens . $this->separator;
1745 print $date . $this->separator;
1746 print $this->separator;
1747 print $this->separator;
1749 print $this->end_line;
1761 public static function trunc($str, $size)
1763 return dol_trunc($str, $size,
'right',
'UTF-8', 1);
1773 public static function toAnsi($str, $size = -1)
1776 if ($retVal >= 0 && $size >= 0)
1778 $retVal = mb_substr($retVal, 0, $size,
'Windows-1251');
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
static getFormatCode($type)
Return string to summarize the format (Used to generated export filename)
exportCharlemagne($objectLines)
Export format : Charlemagne.
static getTypeConfig()
Array with all export type available (key + label) and parameters for config.
dol_now($mode= 'auto')
Return date for now.
exportGestimumV3($objectLines)
Export format : Gestimum V3.
Class to manage Dolibarr database access.
static trunc($str, $size)
trunc
export(&$TData, $formatexportset)
Function who chose which export to use with the default config, and make the export into a file...
__construct(DoliDB &$db)
Constructor.
exportLDCompta($objectLines)
Export format : LD Compta version 9 http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Docu...
price2fec($amount)
Function to format a value into a defined format for French administration (no thousand separator & d...
exportCoala($objectLines)
Export format : COALA.
exportBob50($objectLines)
Export format : BOB50.
$conf db
API class for accounts.
exportFEC2($objectLines)
Export format : FEC2.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
exportOpenConcerto($objectLines)
Export format : OpenConcerto.
exportCogilog($objectLines)
Export format : COGILOG.
static getType()
Array with all export type available (key + label)
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
exportQuadratus(&$TData)
Export format : Quadratus.
exportGestimumV5($objectLines)
Export format : Gestimum V5.
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
exportAgiris($objectLines)
Export format : Agiris Isacompta.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
exportCegid($objectLines)
Export format : CEGID.
exportWinfic(&$TData)
Export format : WinFic - eWinfic - WinSis Compta.
exportConfigurable($objectLines)
Export format : Configurable CSV.
exportFEC($objectLines)
Export format : FEC.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Manage the different format accountancy export.
static toAnsi($str, $size=-1)
toAnsi
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
exportLDCompta10($objectLines)
Export format : LD Compta version 10 & higher http://www.ldsysteme.fr/fileadmin/telechargement/np/ldc...
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.
exportCiel(&$TData)
Export format : CIEL.
exportEbp($objectLines)
Export format : EBP.
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous) ...
exportSAGE50SWISS($objectLines)
Export format : SAGE50SWISS.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.