53 $this->family =
"financial";
54 $this->module_position =
'11';
56 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
60 $this->version =
'dolibarr';
62 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
63 $this->picto =
'bill';
66 $this->dirs = array(
"/facture/temp");
69 $this->depends = array(
'always' =>
"modSociete");
70 $this->requiredby = array(
"modComptabilite",
"modAccounting");
71 $this->conflictwith = array();
72 $this->langfiles = array(
"bills",
"companies",
"compta",
"products");
73 $this->warnings_activation = array();
74 $this->warnings_activation_ext = array();
77 $this->config_page_url = array(
"invoice.php");
85 'Name of numbering numerotation rules of invoice',
92 'Name of PDF model of invoice',
96 "FACTURE_ADDON_PDF_ODT_PATH",
98 "DOL_DATA_ROOT".($conf->entity > 1 ?
'/'.$conf->entity :
'').
"/doctemplates/invoices",
106 $this->boxes = array(
107 0 => array(
'file' =>
'box_factures_imp.php',
'enabledbydefaulton' =>
'Home'),
108 1 => array(
'file' =>
'box_factures.php',
'enabledbydefaulton' =>
'Home'),
109 2 => array(
'file' =>
'box_graph_invoices_permonth.php',
'enabledbydefaulton' =>
'Home'),
110 3 => array(
'file' =>
'box_customers_outstanding_bill_reached.php',
'enabledbydefaulton' =>
'Home'),
111 4 => array(
'file' =>
'box_invoices_dispute.php',
'enabledbydefaulton' =>
'Home')
116 $datestart =
dol_mktime(23, 0, 0, $arraydate[
'mon'], $arraydate[
'mday'], $arraydate[
'year']);
117 $this->cronjobs = array(
119 'label' =>
'RecurringInvoicesJob',
120 'jobtype' =>
'method',
121 'class' =>
'compta/facture/class/facture-rec.class.php',
122 'objectname' =>
'FactureRec',
123 'method' =>
'createRecurringInvoices',
125 'comment' =>
'Generate recurring invoices.',
127 'unitfrequency' => 3600 * 24,
130 'test' =>
'isModEnabled("invoice")',
131 'datestart' => $datestart
134 'label' =>
'SendEmailsRemindersOnInvoiceDueDate',
135 'jobtype' =>
'method',
136 'class' =>
'compta/facture/class/facture.class.php',
137 'objectname' =>
'Facture',
138 'method' =>
'sendEmailsRemindersOnInvoiceDueDate',
139 'parameters' =>
"10,all,EmailTemplateCode,duedate",
140 'comment' =>
'Send an email when we reach the invoice due date (or invoice date) - n days. First param is n, the number of days before due date (or invoice date) to send the remind (or after if value is negative), second parameter is "all" or a payment mode code, third parameter is the code of the email template to use (an email template with the EmailTemplateCode must exists. The version of the email template in the language of the thirdparty will be used in priority. Language of the thirdparty will be also used to update the PDF of the sent invoice). The fourth parameter is the string "duedate" (default) or "invoicedate" to define which date of the invoice to use.',
142 'unitfrequency' => 3600 * 24,
145 'test' =>
'isModEnabled("invoice")',
146 'datestart' => $datestart
151 $this->rights = array();
152 $this->rights_class =
'facture';
156 $this->rights[$r][0] = 11;
157 $this->rights[$r][1] =
'Read invoices';
158 $this->rights[$r][2] =
'a';
159 $this->rights[$r][3] = 0;
160 $this->rights[$r][4] =
'lire';
163 $this->rights[$r][0] = 12;
164 $this->rights[$r][1] =
'Create and update invoices';
165 $this->rights[$r][2] =
'a';
166 $this->rights[$r][3] = 0;
167 $this->rights[$r][4] =
'creer';
171 $this->rights[$r][0] = 13;
172 $this->rights[$r][1] =
'Devalidate invoices';
173 $this->rights[$r][2] =
'a';
174 $this->rights[$r][3] = 0;
175 $this->rights[$r][4] =
'invoice_advance';
176 $this->rights[$r][5] =
'unvalidate';
179 $this->rights[$r][0] = 14;
180 $this->rights[$r][1] =
'Validate invoices';
181 $this->rights[$r][2] =
'a';
182 $this->rights[$r][3] = 0;
183 $this->rights[$r][4] =
'invoice_advance';
184 $this->rights[$r][5] =
'validate';
187 $this->rights[$r][0] = 15;
188 $this->rights[$r][1] =
'Send invoices by email';
189 $this->rights[$r][2] =
'a';
190 $this->rights[$r][3] = 0;
191 $this->rights[$r][4] =
'invoice_advance';
192 $this->rights[$r][5] =
'send';
195 $this->rights[$r][0] = 16;
196 $this->rights[$r][1] =
'Issue payments on invoices';
197 $this->rights[$r][2] =
'a';
198 $this->rights[$r][3] = 0;
199 $this->rights[$r][4] =
'paiement';
202 $this->rights[$r][0] = 19;
203 $this->rights[$r][1] =
'Delete invoices';
204 $this->rights[$r][2] =
'a';
205 $this->rights[$r][3] = 0;
206 $this->rights[$r][4] =
'supprimer';
209 $this->rights[$r][0] = 1321;
210 $this->rights[$r][1] =
'Export customer invoices, attributes and payments';
211 $this->rights[$r][2] =
'r';
212 $this->rights[$r][3] = 0;
213 $this->rights[$r][4] =
'facture';
214 $this->rights[$r][5] =
'export';
217 $this->rights[$r][0] = 1322;
218 $this->rights[$r][1] =
'Re-open a fully paid invoice';
219 $this->rights[$r][2] =
'r';
220 $this->rights[$r][3] = 0;
221 $this->rights[$r][4] =
'invoice_advance';
222 $this->rights[$r][5] =
'reopen';
236 $this->import_code[$r] = $this->rights_class.
'_'.$r;
237 $this->import_label[$r] =
"Invoices";
238 $this->import_icon[$r] = $this->picto;
239 $this->import_entities_array[$r] = array();
240 $this->import_tables_array[$r] = array(
'f' => MAIN_DB_PREFIX.
'facture',
'extra' => MAIN_DB_PREFIX.
'facture_extrafields');
241 $this->import_tables_creator_array[$r] = array(
'f' =>
'fk_user_author');
242 $this->import_fields_array[$r] = array(
243 'f.ref' =>
'InvoiceRef*',
244 'f.ref_ext' =>
'ExternalRef',
245 'f.ref_client' =>
'RefCustomer',
247 'f.fk_soc' =>
'Customer*',
248 'f.datec' =>
'InvoiceDateCreation',
249 'f.datef' =>
'DateInvoice',
250 'f.date_valid' =>
'Validation Date',
251 'f.paye' =>
'InvoicePaid',
252 'f.total_tva' =>
'TotalVAT',
253 'f.total_ht' =>
'TotalHT',
254 'f.total_ttc' =>
'TotalTTC',
255 'f.fk_statut' =>
'InvoiceStatus',
256 'f.fk_user_modif' =>
'Modifier Id',
257 'f.fk_user_valid' =>
'Validator Id',
258 'f.fk_user_closing' =>
'Closer Id',
259 'f.fk_facture_source' =>
'Invoice Source Id',
260 'f.fk_projet' =>
'Project Id',
261 'f.fk_account' =>
'Bank Account',
262 'f.fk_currency' =>
'Currency*',
263 'f.fk_cond_reglement' =>
'PaymentTerm',
264 'f.fk_mode_reglement' =>
'PaymentMode',
265 'f.date_lim_reglement' =>
'DateMaxPayment',
266 'f.note_public' =>
'InvoiceNote',
267 'f.note_private' =>
'NotePrivate',
268 'f.model_pdf' =>
'Model'
271 $this->import_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
272 $this->import_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
273 $this->import_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
274 $this->import_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
275 $this->import_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
278 $import_extrafield_sample = array();
279 $keyforselect =
'facture';
280 $keyforelement =
'bill';
281 $keyforaliasextra =
'extra';
282 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinimport.inc.php';
283 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facture');
284 $this->import_regex_array[$r] = array(
'f.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency');
285 $import_sample = array(
286 'f.ref' =>
'(PROV0001)',
288 'f.ref_client' =>
'',
290 'f.fk_soc' =>
'80LIMIT',
291 'f.datec' =>
'2021-11-24',
292 'f.datef' =>
'2021-11-24',
293 'f.date_valid' =>
'2021-11-24',
295 'f.total_tva' =>
'21',
296 'f.total_ht' =>
'100',
297 'f.total_ttc' =>
'121',
298 'f.fk_statut' =>
'1',
299 'f.fk_user_modif' =>
'',
300 'f.fk_user_valid' =>
'',
301 'f.fk_user_closing' =>
'',
302 'f.fk_facture_source' =>
'',
304 'f.fk_account' =>
'',
305 'f.fk_currency' =>
'EUR',
306 'f.fk_cond_reglement' =>
'30D',
307 'f.fk_mode_reglement' =>
'VIR',
308 'f.date_lim_reglement' =>
'2021-12-24',
309 'f.note_public' =>
'',
310 'f.note_private' =>
'',
311 'f.model_pdf' =>
'sponge',
312 'f.multicurrency_code' =>
'EUR',
313 'f.multicurrency_tx' =>
'1',
314 'f.multicurrency_total_ht' =>
'100',
315 'f.multicurrency_total_tva' =>
'21',
316 'f.multicurrency_total_ttc' =>
'121'
318 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
319 $this->import_updatekeys_array[$r] = array(
'f.ref' =>
'Ref');
320 $this->import_convertvalue_array[$r] = array(
322 'rule' =>
'fetchidfromref',
323 'file' =>
'/societe/class/societe.class.php',
324 'class' =>
'Societe',
326 'element' =>
'ThirdParty'
328 'f.fk_projet' => array(
329 'rule' =>
'fetchidfromref',
330 'file' =>
'/projet/class/project.class.php',
331 'class' =>
'Project',
333 'element' =>
'facture'
335 'f.fk_cond_reglement' => array(
336 'rule' =>
'fetchidfromcodeorlabel',
337 'file' =>
'/compta/facture/class/paymentterm.class.php',
338 'class' =>
'PaymentTerm',
340 'element' =>
'c_payment_term'
346 $this->import_code[$r] = $this->rights_class.
'_'.$r;
347 $this->import_label[$r] =
"InvoiceLine";
348 $this->import_icon[$r] = $this->picto;
349 $this->import_entities_array[$r] = array();
350 $this->import_tables_array[$r] = array(
'fd' => MAIN_DB_PREFIX.
'facturedet',
'extra' => MAIN_DB_PREFIX.
'facturedet_extrafields');
351 $this->import_fields_array[$r] = array(
352 'fd.fk_facture' =>
'InvoiceRef*',
353 'fd.fk_parent_line' =>
'FacParentLine',
354 'fd.fk_product' =>
'ProductOrService',
355 'fd.label' =>
'Label',
356 'fd.description' =>
'LineDescription*',
357 'fd.vat_src_code' =>
'Vat Source Code',
358 'fd.tva_tx' =>
'LineVATRate*',
363 'fd.qty' =>
'LineQty',
364 'fd.remise_percent' =>
'Reduc. (%)',
367 'fd.subprice' =>
'UnitPriceHT',
369 'fd.total_ht' =>
'LineTotalHT',
370 'fd.total_tva' =>
'LineTotalVAT',
373 'fd.total_ttc' =>
'LineTotalTTC',
374 'fd.product_type' =>
'TypeOfLineServiceOrProduct',
375 'fd.date_start' =>
'Start Date',
376 'fd.date_end' =>
'End Date',
383 'fd.fk_unit' =>
'Unit',
392 $this->import_fields_array[$r][
'fd.multicurrency_code'] =
'Currency';
393 $this->import_fields_array[$r][
'fd.multicurrency_subprice'] =
'CurrencyRate';
394 $this->import_fields_array[$r][
'fd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
395 $this->import_fields_array[$r][
'fd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
396 $this->import_fields_array[$r][
'fd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
399 $import_extrafield_sample = array();
400 $keyforselect =
'facture_det';
401 $keyforelement =
'bill';
402 $keyforaliasextra =
'extra';
403 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinimport.inc.php';
404 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facturedet');
405 $this->import_regex_array[$r] = array(
406 'fd.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'
408 $import_sample = array(
409 'fd.fk_facture' =>
'(PROV00001)',
410 'fd.fk_parent_line' =>
'',
411 'fd.fk_product' =>
'ref:PRODUCT_REF or id:123456',
413 'fd.description' =>
'Test product',
414 'fd.vat_src_code' =>
'',
421 'fd.remise_percent' =>
'0',
424 'fd.subprice' =>
'100',
426 'fd.total_ht' =>
'100',
427 'fd.total_tva' =>
'21',
430 'fd.total_ttc' =>
'121',
431 'fd.product_type' =>
'0',
432 'fd.date_start' =>
'',
447 'fd.multicurrency_code' =>
'EUR',
448 'fd.multicurrency_tx' =>
'21',
449 'fd.multicurrency_total_ht' =>
'100',
450 'fd.multicurrency_total_tva' =>
'21',
451 'fd.multicurrency_total_ttc' =>
'121'
453 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
454 $this->import_updatekeys_array[$r] = array(
455 'fd.rowid' =>
'Row Id',
456 'fd.fk_facture' =>
'Invoice Id',
457 'fd.fk_product' =>
'ProductRef'
459 $this->import_convertvalue_array[$r] = array(
460 'fd.fk_facture' => array(
461 'rule' =>
'fetchidfromref',
462 'file' =>
'/compta/facture/class/facture.class.php',
463 'class' =>
'Facture',
465 'element' =>
'facture'
467 'fd.fk_product' => array(
468 'rule' =>
'fetchidfromref',
469 'classfile' =>
'/product/class/product.class.php',
470 'class' =>
'Product',
472 'element' =>
'Product'
474 'fd.fk_projet' => array(
475 'rule' =>
'fetchidfromref',
476 'file' =>
'/projet/class/project.class.php',
477 'class' =>
'Project',
479 'element' =>
'facture'
486 $uselocaltax1 = (is_object(
$mysoc) &&
$mysoc->localtax1_assuj) ?
$mysoc->localtax1_assuj : 0;
487 $uselocaltax2 = (is_object(
$mysoc) &&
$mysoc->localtax2_assuj) ?
$mysoc->localtax2_assuj : 0;
491 $langs->loadLangs(array(
"suppliers",
"multicurrency",
"bills"));
493 $uselocaltax1 =
$mysoc->localtax1_assuj ?? 0;
494 $uselocaltax2 =
$mysoc->localtax2_assuj ?? 0;
496 $alias_product_perentity = !
getDolGlobalString(
'MAIN_PRODUCT_PERENTITY_SHARED') ?
"p" :
"ppe";
499 $this->export_code[$r] = $this->rights_class.
'_'.$r;
500 $this->export_label[$r] =
'CustomersInvoicesAndInvoiceLines';
501 $this->export_icon[$r] =
'invoice';
502 $this->export_permission[$r] = array(array(
"facture",
"facture",
"export",
"other"));
504 $this->export_fields_array[$r] = array(
505 's.rowid' =>
"IdCompany",
's.nom' =>
'CompanyName',
's.name_alias' =>
'AliasNameShort',
'ps.nom' =>
'ParentCompany',
's.code_client' =>
'CustomerCode',
's.address' =>
'Address',
's.zip' =>
'Zip',
's.town' =>
'Town',
'c.code' =>
'CountryCode',
'cd.nom' =>
'State',
506 's.phone' =>
'Phone',
507 's.siren' =>
'ProfId1',
's.siret' =>
'ProfId2',
's.ape' =>
'ProfId3',
's.idprof4' =>
'ProfId4',
508 's.code_compta' =>
'CustomerAccountancyCode',
509 's.code_compta_fournisseur' =>
'SupplierAccountancyCode',
510 's.tva_intra' =>
'VATIntra',
511 't.libelle' =>
"ThirdPartyType",
512 'f.rowid' =>
"InvoiceId",
'f.ref' =>
"InvoiceRef",
'f.ref_client' =>
'RefCustomer',
'f.fk_facture_source' =>
'SourceInvoiceId',
513 'f.type' =>
"Type",
'f.datec' =>
"InvoiceDateCreation",
'f.datef' =>
"DateInvoice",
'f.date_lim_reglement' =>
"DateDue",
514 'f.fk_cond_reglement' =>
'IdPaymentTerm',
'f.fk_mode_reglement' =>
'IdPaymentMode',
515 'f.total_ht' =>
"TotalHT",
'f.total_ttc' =>
"TotalTTC",
'f.total_tva' =>
"TotalVAT",
516 'f.localtax1' =>
"TotalLT1",
'f.localtax2' =>
"TotalLT2",
517 'f.paye' =>
"InvoicePaidCompletely",
'f.fk_statut' =>
'InvoiceStatus',
'f.close_code' =>
'EarlyClosingReason',
'f.close_note' =>
'EarlyClosingComment',
518 'none.rest' =>
'Rest',
519 'f.note_private' =>
"NotePrivate",
'f.note_public' =>
"NotePublic"
521 if (!$uselocaltax1) {
522 unset($this->export_fields_array[$r][
'f.localtax1']);
524 if (!$uselocaltax2) {
525 unset($this->export_fields_array[$r][
'f.localtax2']);
530 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
531 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
532 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
533 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
534 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
538 $this->export_fields_array[$r][
'f.module_source'] =
'Module';
539 $this->export_fields_array[$r][
'f.pos_source'] =
'POSTerminal';
541 $this->export_fields_array[$r] += array(
542 'f.fk_user_author' =>
'CreatedById',
'uc.login' =>
'CreatedByLogin',
543 'f.fk_user_valid' =>
'ValidatedById',
'uv.login' =>
'ValidatedByLogin',
544 'pj.ref' =>
'ProjectRef',
'pj.title' =>
'ProjectLabel'
548 $nbofallowedentities = count(explode(
',',
getEntity(
'invoice')));
549 if (
isModEnabled(
'multicompany') && $nbofallowedentities > 1) {
550 $this->export_fields_array[$r][
'f.entity'] =
'Entity';
553 $this->export_fields_array[$r] += array(
554 'fd.rowid' =>
'LineId',
'fd.description' =>
"LineDescription",
555 'fd.subprice' =>
"LineUnitPrice",
'fd.qty' =>
"LineQty",
556 'fd.tva_tx' =>
"LineVATRate",
557 'fd.total_ht' =>
"LineTotalHT",
'fd.total_tva' =>
"LineTotalVAT",
'fd.total_ttc' =>
"LineTotalTTC",
558 'fd.localtax1_tx' =>
"LineLT1Rate",
'fd.localtax1_type' =>
"LineLT1Type",
'fd.total_localtax1' =>
"LineTotalLT1",
559 'fd.localtax2_tx' =>
"LineLT2Rate",
'fd.localtax2_type' =>
"LineLT2Type",
'fd.total_localtax2' =>
"LineTotalLT2",
560 'fd.buy_price_ht' =>
'BuyingPrice',
'fd.date_start' =>
"DateStart",
'fd.date_end' =>
"DateEnd",
'fd.special_code' =>
'SpecialCode',
561 'fd.product_type' =>
"TypeOfLineServiceOrProduct",
'fd.fk_product' =>
'ProductId',
'p.ref' =>
'ProductRef',
'p.label' =>
'ProductLabel',
562 $alias_product_perentity .
'.accountancy_code_sell' =>
'ProductAccountancySellCode',
563 'aa.account_number' =>
'AccountingAffectation'
565 if (!$uselocaltax1) {
566 unset($this->export_fields_array[$r][
'fd.localtax1_tx']);
567 unset($this->export_fields_array[$r][
'fd.localtax1_type']);
568 unset($this->export_fields_array[$r][
'fd.total_localtax1']);
570 if (!$uselocaltax2) {
571 unset($this->export_fields_array[$r][
'fd.localtax2_tx']);
572 unset($this->export_fields_array[$r][
'fd.localtax2_type']);
573 unset($this->export_fields_array[$r][
'fd.total_localtax2']);
576 $this->export_TypeFields_array[$r] = array(
577 's.rowid' =>
'Numeric',
's.nom' =>
'Text',
's.name_alias' =>
'Text',
'ps.nom' =>
'Text',
's.code_client' =>
'Text',
's.address' =>
'Text',
's.zip' =>
'Text',
's.town' =>
'Text',
'c.code' =>
'Text',
'cd.nom' =>
'Text',
's.phone' =>
'Text',
's.siren' =>
'Text',
578 's.siret' =>
'Text',
's.ape' =>
'Text',
's.idprof4' =>
'Text',
's.code_compta' =>
'Text',
's.code_compta_fournisseur' =>
'Text',
's.tva_intra' =>
'Text',
579 't.libelle' =>
"Text",
580 'f.rowid' =>
'Numeric',
'f.ref' =>
"Text",
'f.ref_client' =>
'Text',
'f.fk_facture_source' =>
'Numeric',
'f.type' =>
"Numeric",
'f.datec' =>
"Date",
'f.datef' =>
"Date",
'f.date_lim_reglement' =>
"Date",
581 'f.fk_cond_reglement' =>
'Numeric',
'f.fk_mode_reglement' =>
'Numeric',
582 'f.total_ht' =>
"Numeric",
'f.total_ttc' =>
"Numeric",
'f.total_tva' =>
"Numeric",
'f.localtax1' =>
'Numeric',
'f.localtax2' =>
'Numeric',
'f.paye' =>
"Boolean",
'f.fk_statut' =>
'Numeric',
'f.close_code' =>
'Text',
'f.close_note' =>
'Text',
583 'none.rest' =>
"NumericCompute",
584 'f.note_private' =>
"Text",
'f.note_public' =>
"Text",
585 'f.module_source' =>
'Text',
586 'f.pos_source' =>
'Text',
587 'f.entity' =>
'List:entity:label:rowid',
588 'f.fk_user_author' =>
'Numeric',
'uc.login' =>
'Text',
'f.fk_user_valid' =>
'Numeric',
'uv.login' =>
'Text',
589 'pj.ref' =>
'Text',
'pj.title' =>
'Text',
'fd.rowid' =>
'Numeric',
'fd.description' =>
"Text",
'fd.subprice' =>
"Numeric",
'fd.tva_tx' =>
"Numeric",
590 'fd.qty' =>
"Numeric",
'fd.buy_price_ht' =>
"Numeric",
'fd.date_start' =>
"Date",
'fd.date_end' =>
"Date",
591 'fd.total_ht' =>
"Numeric",
'fd.total_tva' =>
"Numeric",
'fd.total_ttc' =>
"Numeric",
'fd.total_localtax1' =>
"Numeric",
'fd.total_localtax2' =>
"Numeric",
592 'fd.localtax1_tx' =>
'Numeric',
'fd.localtax2_tx' =>
'Numeric',
'fd.localtax1_type' =>
'Numeric',
'fd.localtax2_type' =>
'Numeric',
593 'fd.special_code' =>
'Numeric',
'fd.product_type' =>
"Numeric",
'fd.fk_product' =>
'List:product:label',
'p.ref' =>
'Text',
'p.label' =>
'Text',
594 $alias_product_perentity .
'.accountancy_code_sell' =>
'Text',
595 'aa.account_number' =>
'Text',
596 'f.multicurrency_code' =>
'Text',
597 'f.multicurrency_tx' =>
'Number',
'f.multicurrency_total_ht' =>
'Number',
'f.multicurrency_total_tva' =>
'Number',
'f.multicurrency_total_ttc' =>
'Number'
599 $this->export_entities_array[$r] = array(
600 's.rowid' =>
"company",
's.nom' =>
'company',
's.name_alias' =>
'company',
'ps.nom' =>
'company',
's.code_client' =>
'company',
's.address' =>
'company',
's.zip' =>
'company',
's.town' =>
'company',
'c.code' =>
'company',
'cd.nom' =>
'company',
's.phone' =>
'company',
601 's.siren' =>
'company',
's.siret' =>
'company',
's.ape' =>
'company',
's.idprof4' =>
'company',
's.code_compta' =>
'company',
's.code_compta_fournisseur' =>
'company',
's.tva_intra' =>
'company',
602 't.libelle' =>
'company',
603 'pj.ref' =>
'project',
'pj.title' =>
'project',
'fd.rowid' =>
'invoice_line',
'fd.description' =>
"invoice_line",
604 'fd.subprice' =>
"invoice_line",
'fd.buy_price_ht' =>
'invoice_line',
605 'fd.total_ht' =>
"invoice_line",
'fd.total_tva' =>
"invoice_line",
'fd.total_ttc' =>
"invoice_line",
'fd.total_localtax1' =>
"invoice_line",
'fd.total_localtax2' =>
"invoice_line",
606 'fd.tva_tx' =>
"invoice_line",
'fd.localtax1_tx' =>
"invoice_line",
'fd.localtax2_tx' =>
"invoice_line",
'fd.localtax1_type' =>
"invoice_line",
'fd.localtax2_type' =>
"invoice_line",
607 'fd.qty' =>
"invoice_line",
'fd.date_start' =>
"invoice_line",
'fd.date_end' =>
"invoice_line",
'fd.special_code' =>
'invoice_line',
608 'fd.product_type' =>
'invoice_line',
'fd.fk_product' =>
'product',
'p.ref' =>
'product',
'p.label' =>
'product', $alias_product_perentity .
'.accountancy_code_sell' =>
'product',
609 'f.fk_user_author' =>
'user',
'uc.login' =>
'user',
'f.fk_user_valid' =>
'user',
'uv.login' =>
'user',
610 'aa.account_number' =>
"invoice_line",
612 $this->export_help_array[$r] = array(
'fd.buy_price_ht' =>
'CostPriceUsage');
613 $this->export_special_array[$r] = array(
'none.rest' =>
'getRemainToPay');
614 $this->export_dependencies_array[$r] = array(
'invoice_line' =>
'fd.rowid',
'product' =>
'fd.rowid',
'none.rest' => array(
'f.rowid',
'f.total_ttc',
'f.close_code'));
615 $keyforselect =
'facture';
616 $keyforelement =
'invoice';
617 $keyforaliasextra =
'extra';
618 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
619 $keyforselect =
'facturedet';
620 $keyforelement =
'invoice_line';
621 $keyforaliasextra =
'extra2';
622 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
623 $keyforselect =
'product';
624 $keyforelement =
'product';
625 $keyforaliasextra =
'extra3';
626 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
627 $keyforselect =
'societe';
628 $keyforelement =
'company';
629 $keyforaliasextra =
'extra4';
630 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
631 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
632 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
633 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_extrafields as extra4 ON s.rowid = extra4.fk_object';
634 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON ps.rowid = s.parent';
635 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_typent as t ON s.fk_typent = t.id';
636 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
637 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
639 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c on s.fk_pays = c.rowid';
640 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as cd on s.fk_departement = cd.rowid,';
641 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture as f';
642 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as pj ON f.fk_projet = pj.rowid';
643 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uc ON f.fk_user_author = uc.rowid';
644 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uv ON f.fk_user_valid = uv.rowid';
645 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_extrafields as extra ON f.rowid = extra.fk_object';
646 $this->export_sql_end[$r] .=
' , '.MAIN_DB_PREFIX.
'facturedet as fd';
647 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facturedet_extrafields as extra2 on fd.rowid = extra2.fk_object';
648 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
650 $this->export_sql_end[$r] .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int)
$conf->entity);
652 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extra3 on p.rowid = extra3.fk_object';
653 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'accounting_account as aa on fd.fk_code_ventilation = aa.rowid';
654 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
655 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
656 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
657 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.(empty($user) ? 0 : ((int) $user->id));
662 $this->export_code[$r] = $this->rights_class.
'_'.$r;
663 $this->export_label[$r] =
'CustomersInvoicesAndPayments';
664 $this->export_icon[$r] =
'invoice';
665 $this->export_permission[$r] = array(array(
"facture",
"facture",
"export"));
666 $this->export_fields_array[$r] = array(
667 's.rowid' =>
"IdCompany",
's.nom' =>
'CompanyName',
's.name_alias' =>
'AliasNameShort',
's.code_client' =>
'CustomerCode',
's.address' =>
'Address',
's.zip' =>
'Zip',
's.town' =>
'Town',
'c.code' =>
'CountryCode',
'cd.nom' =>
'State',
668 's.phone' =>
'Phone',
669 's.siren' =>
'ProfId1',
's.siret' =>
'ProfId2',
's.ape' =>
'ProfId3',
's.idprof4' =>
'ProfId4',
's.code_compta' =>
'CustomerAccountancyCode',
670 's.code_compta_fournisseur' =>
'SupplierAccountancyCode',
's.tva_intra' =>
'VATIntra',
671 'f.rowid' =>
"InvoiceId",
'f.ref' =>
"InvoiceRef",
'f.ref_client' =>
'RefCustomer',
'f.fk_facture_source' =>
'SourceInvoiceId',
672 'f.type' =>
"Type",
'f.datec' =>
"InvoiceDateCreation",
'f.datef' =>
"DateInvoice",
'f.date_lim_reglement' =>
"DateDue",
673 'f.fk_cond_reglement' =>
'IdPaymentTerm',
'f.fk_mode_reglement' =>
'IdPaymentMode',
674 'f.total_ht' =>
"TotalHT",
'f.total_ttc' =>
"TotalTTC",
'f.total_tva' =>
"TotalVAT",
'f.localtax1' =>
'LT1',
'f.localtax2' =>
'LT2',
'f.paye' =>
"InvoicePaidCompletely",
'f.fk_statut' =>
'InvoiceStatus',
'f.close_code' =>
'EarlyClosingReason',
'f.close_note' =>
'EarlyClosingComment',
675 'none.rest' =>
'Rest',
676 'f.note_private' =>
"NotePrivate",
'f.note_public' =>
"NotePublic",
'f.fk_user_author' =>
'CreatedById',
'uc.login' =>
'CreatedByLogin',
677 'f.fk_user_valid' =>
'ValidatedById',
'uv.login' =>
'ValidatedByLogin',
'pj.ref' =>
'ProjectRef',
'pj.title' =>
'ProjectLabel',
'p.rowid' =>
'PaymentId',
'p.ref' =>
'PaymentRef',
678 'p.amount' =>
'AmountPayment',
'pf.amount' =>
'AmountPaymentDistributedOnInvoice',
'p.datep' =>
'DatePayment',
'p.num_paiement' =>
'PaymentNumber',
679 'pt.code' =>
'CodePaymentMode',
'pt.libelle' =>
'LabelPaymentMode',
'p.note' =>
'PaymentNote',
'p.fk_bank' =>
'IdTransaction',
'ba.ref' =>
'AccountRef'
681 if (!$uselocaltax1) {
682 unset($this->export_fields_array[$r][
'f.localtax1']);
684 if (!$uselocaltax2) {
685 unset($this->export_fields_array[$r][
'f.localtax2']);
688 $this->export_help_array[$r] = array(
'f.paye' =>
'InvoicePaidCompletelyHelp');
690 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
691 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
692 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
693 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
694 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
695 $this->export_examplevalues_array[$r][
'f.multicurrency_code'] =
'EUR';
698 $this->export_fields_array[$r][
'f.module_source'] =
'POSModule';
699 $this->export_fields_array[$r][
'f.pos_source'] =
'POSTerminal';
701 $this->export_TypeFields_array[$r] = array(
702 's.rowid' =>
'Numeric',
's.nom' =>
'Text',
's.name_alias' =>
'Text',
's.code_client' =>
'Text',
's.address' =>
'Text',
's.zip' =>
'Text',
's.town' =>
'Text',
'c.code' =>
'Text',
'cd.nom' =>
'Text',
's.phone' =>
'Text',
's.siren' =>
'Text',
703 's.siret' =>
'Text',
's.ape' =>
'Text',
's.idprof4' =>
'Text',
's.code_compta' =>
'Text',
's.code_compta_fournisseur' =>
'Text',
's.tva_intra' =>
'Text',
704 'f.rowid' =>
"Numeric",
'f.ref' =>
"Text",
'f.ref_client' =>
'Text',
'f.fk_facture_source' =>
'Numeric',
'f.type' =>
"Numeric",
'f.datec' =>
"Date",
'f.datef' =>
"Date",
'f.date_lim_reglement' =>
"Date",
705 'f.fk_cond_reglement' =>
'Numeric',
'f.fk_mode_reglement' =>
'Numeric',
706 'f.total_ht' =>
"Numeric",
'f.total_ttc' =>
"Numeric",
'f.total_tva' =>
"Numeric",
'f.localtax1' =>
'Numeric',
'f.localtax2' =>
'Numeric',
'f.paye' =>
"Boolean",
'f.fk_statut' =>
'Status',
'f.close_code' =>
'Text',
'f.close_note' =>
'Text',
707 'none.rest' =>
'NumericCompute',
708 'f.note_private' =>
"Text",
'f.note_public' =>
"Text",
'f.fk_user_author' =>
'Numeric',
'uc.login' =>
'Text',
'f.fk_user_valid' =>
'Numeric',
'uv.login' =>
'Text',
709 'pj.ref' =>
'Text',
'pj.title' =>
'Text',
'p.amount' =>
'Numeric',
'pf.amount' =>
'Numeric',
'p.rowid' =>
'Numeric',
'p.ref' =>
'Text',
'p.title' =>
'Text',
'p.datep' =>
'Date',
'p.num_paiement' =>
'Numeric',
710 'p.fk_bank' =>
'Numeric',
'p.note' =>
'Text',
'pt.code' =>
'Text',
'pt.libelle' =>
'Text',
'ba.ref' =>
'Text'
713 $this->export_fields_array[$r][
'f.module_source'] =
'POSModule';
714 $this->export_fields_array[$r][
'f.pos_source'] =
'POSTerminal';
716 $this->export_entities_array[$r] = array(
717 's.rowid' =>
"company",
's.nom' =>
'company',
's.name_alias' =>
'company',
's.code_client' =>
'company',
's.address' =>
'company',
's.zip' =>
'company',
's.town' =>
'company',
'c.code' =>
'company',
'cd.nom' =>
'company',
's.phone' =>
'company',
718 's.siren' =>
'company',
's.siret' =>
'company',
's.ape' =>
'company',
's.idprof4' =>
'company',
's.code_compta' =>
'company',
's.code_compta_fournisseur' =>
'company',
719 's.tva_intra' =>
'company',
'pj.ref' =>
'project',
'pj.title' =>
'project',
'p.rowid' =>
'payment',
'p.ref' =>
'payment',
'p.amount' =>
'payment',
'pf.amount' =>
'payment',
'p.datep' =>
'payment',
720 'p.num_paiement' =>
'payment',
'pt.code' =>
'payment',
'pt.libelle' =>
'payment',
'p.note' =>
'payment',
'f.fk_user_author' =>
'user',
'uc.login' =>
'user',
721 'f.fk_user_valid' =>
'user',
'uv.login' =>
'user',
'p.fk_bank' =>
'account',
'ba.ref' =>
'account'
723 $this->export_special_array[$r] = array(
'none.rest' =>
'getRemainToPay');
724 $this->export_dependencies_array[$r] = array(
'payment' =>
'p.rowid',
'none.rest' => array(
'f.rowid',
'f.total_ttc',
'f.close_code'));
725 $keyforselect =
'facture';
726 $keyforelement =
'invoice';
727 $keyforaliasextra =
'extra';
728 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
729 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
730 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
731 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
732 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
734 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c on s.fk_pays = c.rowid';
735 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as cd on s.fk_departement = cd.rowid,';
736 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture as f';
737 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as pj ON f.fk_projet = pj.rowid';
738 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uc ON f.fk_user_author = uc.rowid';
739 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uv ON f.fk_user_valid = uv.rowid';
740 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_extrafields as extra ON f.rowid = extra.fk_object';
741 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement_facture as pf ON pf.fk_facture = f.rowid';
742 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement as p ON pf.fk_paiement = p.rowid';
743 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as pt ON pt.id = p.fk_paiement';
744 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON b.rowid = p.fk_bank';
745 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON ba.rowid = b.fk_account';
746 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid';
747 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
748 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
749 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.(empty($user) ? 0 : ((int) $user->id));