47 global $conf, $langs, $user, $mysoc;
54 $this->family =
"srm";
55 $this->module_position =
'12';
57 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
61 $this->version =
'dolibarr';
63 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
64 $this->picto =
'company';
69 "/fournisseur/commande",
70 "/fournisseur/commande/temp",
71 "/fournisseur/facture",
72 "/fournisseur/facture/temp"
76 $this->depends = array(
"modSociete");
77 $this->requiredby = array(
"modSupplierProposal");
78 $this->langfiles = array(
'bills',
'companies',
'suppliers',
'orders',
'sendings');
81 $this->config_page_url = array(
"supplier_order.php");
84 $this->
const = array();
87 $this->
const[$r][0] =
"COMMANDE_SUPPLIER_ADDON_PDF";
88 $this->
const[$r][1] =
"chaine";
89 $this->
const[$r][2] =
"cornas";
90 $this->
const[$r][3] =
'Nom du gestionnaire de generation des bons de commande en PDF';
91 $this->
const[$r][4] = 0;
94 $this->
const[$r][0] =
"COMMANDE_SUPPLIER_ADDON_NUMBER";
95 $this->
const[$r][1] =
"chaine";
96 $this->
const[$r][2] =
"mod_commande_fournisseur_muguet";
97 $this->
const[$r][3] =
'Nom du gestionnaire de numerotation des commandes fournisseur';
98 $this->
const[$r][4] = 0;
110 $this->
const[$r][0] =
"INVOICE_SUPPLIER_ADDON_NUMBER";
111 $this->
const[$r][1] =
"chaine";
112 $this->
const[$r][2] =
"mod_facture_fournisseur_cactus";
113 $this->
const[$r][3] =
'Nom du gestionnaire de numerotation des factures fournisseur';
114 $this->
const[$r][4] = 0;
118 $this->
const[$r][0] =
"SUPPLIER_ORDER_ADDON_PDF_ODT_PATH";
119 $this->
const[$r][1] =
"chaine";
120 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/supplier_orders";
121 $this->
const[$r][3] =
'';
122 $this->
const[$r][4] = 0;
126 $this->
const[$r][0] =
"SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH";
127 $this->
const[$r][1] =
"chaine";
128 $this->
const[$r][2] =
"";
129 $this->
const[$r][3] =
"";
130 $this->
const[$r][4] = 0;
134 $this->boxes = array(
135 0 => array(
'file' =>
'box_graph_invoices_supplier_permonth.php',
'enabledbydefaulton' =>
'Home'),
136 1 => array(
'file' =>
'box_graph_orders_supplier_permonth.php',
'enabledbydefaulton' =>
'Home'),
137 2 => array(
'file' =>
'box_fournisseurs.php',
'enabledbydefaulton' =>
'Home'),
138 3 => array(
'file' =>
'box_factures_fourn_imp.php',
'enabledbydefaulton' =>
'Home'),
139 4 => array(
'file' =>
'box_factures_fourn.php',
'enabledbydefaulton' =>
'Home'),
140 5 => array(
'file' =>
'box_supplier_orders.php',
'enabledbydefaulton' =>
'Home'),
141 6 => array(
'file' =>
'box_supplier_orders_awaiting_reception.php',
'enabledbydefaulton' =>
'Home'),
145 $datestart =
dol_mktime(23, 0, 0, $arraydate[
'mon'], $arraydate[
'mday'], $arraydate[
'year']);
146 $this->cronjobs = array(
148 'label' =>
'RecurringSupplierInvoicesJob',
149 'jobtype' =>
'method',
150 'class' =>
'fourn/class/fournisseur.facture-rec.class.php',
151 'objectname' =>
'FactureFournisseurRec',
152 'method' =>
'createRecurringInvoices',
154 'comment' =>
'Generate recurring supplier invoices',
156 'unitfrequency' => 3600 * 24,
159 'test' =>
'isModEnabled("supplier_invoice")',
160 'datestart' => $datestart
163 'label' =>
'SendEmailsRemindersOnSupplierInvoiceDueDate',
164 'jobtype' =>
'method',
165 'class' =>
'fourn/class/fournisseur.facture.class.php',
166 'objectname' =>
'FactureFournisseur',
167 'method' =>
'sendEmailsRemindersOnSupplierInvoiceDueDate',
168 'parameters' =>
'10,all,EmailTemplateCode,duedate',
169 'comment' =>
'Send an email when we reach the supplier invoice due date (or supplier invoice date) - n days. First param is n, the number of days before due date (or supplier 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 supplier invoice). The fourth parameter is the string "duedate" (default) or "invoicedate" to define which date of the supplier invoice to use.',
171 'unitfrequency' => 3600 * 24,
174 'test' =>
'isModEnabled("supplier_invoice")',
175 'datestart' => $datestart
180 $this->rights = array();
181 $this->rights_class =
'fournisseur';
185 $this->rights[$r][0] = 1181;
186 $this->rights[$r][1] =
'Consulter les fournisseurs';
187 $this->rights[$r][2] =
'r';
188 $this->rights[$r][3] = 0;
189 $this->rights[$r][4] =
'lire';
192 $this->rights[$r][0] = 1182;
193 $this->rights[$r][1] =
'Consulter les commandes fournisseur';
194 $this->rights[$r][2] =
'r';
195 $this->rights[$r][3] = 0;
196 $this->rights[$r][4] =
'commande';
197 $this->rights[$r][5] =
'lire';
200 $this->rights[$r][0] = 1183;
201 $this->rights[$r][1] =
'Creer une commande fournisseur';
202 $this->rights[$r][2] =
'w';
203 $this->rights[$r][3] = 0;
204 $this->rights[$r][4] =
'commande';
205 $this->rights[$r][5] =
'creer';
208 $this->rights[$r][0] = 1184;
209 $this->rights[$r][1] =
'Valider une commande fournisseur';
210 $this->rights[$r][2] =
'w';
211 $this->rights[$r][3] = 0;
212 $this->rights[$r][4] =
'supplier_order_advance';
213 $this->rights[$r][5] =
'validate';
216 $this->rights[$r][0] = 1185;
217 $this->rights[$r][1] =
'Approuver une commande fournisseur';
218 $this->rights[$r][2] =
'w';
219 $this->rights[$r][3] = 0;
220 $this->rights[$r][4] =
'commande';
221 $this->rights[$r][5] =
'approuver';
224 $this->rights[$r][0] = 1186;
225 $this->rights[$r][1] =
'Commander une commande fournisseur';
226 $this->rights[$r][2] =
'w';
227 $this->rights[$r][3] = 0;
228 $this->rights[$r][4] =
'commande';
229 $this->rights[$r][5] =
'commander';
232 $this->rights[$r][0] = 1187;
233 $this->rights[$r][1] =
'Receptionner une commande fournisseur';
234 $this->rights[$r][2] =
'd';
235 $this->rights[$r][3] = 0;
236 $this->rights[$r][4] =
'commande';
237 $this->rights[$r][5] =
'receptionner';
240 $this->rights[$r][0] = 1189;
241 $this->rights[$r][1] =
'Check/Uncheck a supplier order reception';
242 $this->rights[$r][2] =
'w';
243 $this->rights[$r][3] = 0;
244 $this->rights[$r][4] =
'commande_advance';
245 $this->rights[$r][5] =
'check';
248 $this->rights[$r][0] = 1188;
249 $this->rights[$r][1] =
'Supprimer une commande fournisseur';
250 $this->rights[$r][2] =
'd';
251 $this->rights[$r][3] = 0;
252 $this->rights[$r][4] =
'commande';
253 $this->rights[$r][5] =
'supprimer';
257 $this->rights[$r][0] = 1190;
258 $this->rights[$r][1] =
'Approve supplier order (second level)';
259 $this->rights[$r][2] =
'w';
260 $this->rights[$r][3] = 0;
261 $this->rights[$r][4] =
'commande';
262 $this->rights[$r][5] =
'approve2';
266 $this->rights[$r][0] = 1191;
267 $this->rights[$r][1] =
'Exporter les commande fournisseurs, attributs';
268 $this->rights[$r][2] =
'r';
269 $this->rights[$r][3] = 0;
270 $this->rights[$r][4] =
'commande';
271 $this->rights[$r][5] =
'export';
274 $this->rights[$r][0] = 1231;
275 $this->rights[$r][1] =
'Consulter les factures fournisseur';
276 $this->rights[$r][2] =
'r';
277 $this->rights[$r][3] = 0;
278 $this->rights[$r][4] =
'facture';
279 $this->rights[$r][5] =
'lire';
282 $this->rights[$r][0] = 1232;
283 $this->rights[$r][1] =
'Creer une facture fournisseur';
284 $this->rights[$r][2] =
'w';
285 $this->rights[$r][3] = 0;
286 $this->rights[$r][4] =
'facture';
287 $this->rights[$r][5] =
'creer';
290 $this->rights[$r][0] = 1233;
291 $this->rights[$r][1] =
'Valider une facture fournisseur';
292 $this->rights[$r][2] =
'w';
293 $this->rights[$r][3] = 0;
294 $this->rights[$r][4] =
'supplier_invoice_advance';
295 $this->rights[$r][5] =
'validate';
298 $this->rights[$r][0] = 1234;
299 $this->rights[$r][1] =
'Supprimer une facture fournisseur';
300 $this->rights[$r][2] =
'd';
301 $this->rights[$r][3] = 0;
302 $this->rights[$r][4] =
'facture';
303 $this->rights[$r][5] =
'supprimer';
306 $this->rights[$r][0] = 1235;
307 $this->rights[$r][1] =
'Envoyer les factures par mail';
308 $this->rights[$r][2] =
'a';
309 $this->rights[$r][3] = 0;
310 $this->rights[$r][4] =
'supplier_invoice_advance';
311 $this->rights[$r][5] =
'send';
314 $this->rights[$r][0] = 1236;
315 $this->rights[$r][1] =
'Exporter les factures fournisseurs, attributes et reglements';
316 $this->rights[$r][2] =
'r';
317 $this->rights[$r][3] = 0;
318 $this->rights[$r][4] =
'facture';
319 $this->rights[$r][5] =
'export';
329 $uselocaltax1 = (is_object($mysoc) && $mysoc->localtax1_assuj) ? $mysoc->localtax1_assuj : 0;
330 $uselocaltax2 = (is_object($mysoc) && $mysoc->localtax2_assuj) ? $mysoc->localtax2_assuj : 0;
334 $langs->loadLangs(array(
"suppliers",
"compta",
"multicurrency",
"bills"));
336 $alias_product_perentity = !
getDolGlobalString(
'MAIN_PRODUCT_PERENTITY_SHARED') ?
"p" :
"ppe";
339 $this->export_code[$r] = $this->rights_class.
'_'.$r;
340 $this->export_label[$r] =
'Vendor invoices and lines of invoices';
341 $this->export_icon[$r] =
'invoice';
342 $this->export_permission[$r] = array(array(
"fournisseur",
"facture",
"export"));
343 $this->export_fields_array[$r] = array(
344 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
'ps.nom'=>
'ParentCompany',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
345 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
346 's.code_compta'=>
'CustomerAccountancyCode',
's.code_compta_fournisseur'=>
'SupplierAccountancyCode',
's.tva_intra'=>
'VATIntra',
347 'f.rowid'=>
"InvoiceId",
'f.ref'=>
"InvoiceRef",
'f.ref_supplier'=>
"RefSupplier",
'f.datec'=>
"InvoiceDateCreation",
'f.datef'=>
"DateInvoice",
'f.date_lim_reglement'=>
'DateMaxPayment',
348 'f.fk_cond_reglement'=>
'IdPaymentTerm',
'f.fk_mode_reglement'=>
'IdPaymentMode',
349 'f.total_ht'=>
"TotalHT",
'f.total_ttc'=>
"TotalTTC",
'f.total_tva'=>
"TotalVAT",
350 'f.localtax1'=>
"TotalLT1",
'f.localtax2'=>
"TotalLT2",
351 'f.paye'=>
"InvoicePaid",
'f.fk_statut'=>
'InvoiceStatus',
'f.note_public'=>
"InvoiceNote",
352 'fd.rowid'=>
'LineId',
'fd.description'=>
"LineDescription",
'fd.qty'=>
"LineQty",
'fd.remise_percent'=>
"Discount",
353 'fd.tva_tx'=>
"LineVATRate",
'fd.total_ht'=>
"LineTotalHT",
'fd.total_ttc'=>
"LineTotalTTC",
'fd.tva'=>
"LineTotalVAT",
354 'fd.localtax1_tx'=>
"LineLT1Rate",
'fd.localtax1_type'=>
"LineLT1Type",
'fd.total_localtax1'=>
"LineTotalLT1",
355 'fd.localtax2_tx'=>
"LineLT2Rate",
'fd.localtax2_type'=>
"LineLT2Type",
'fd.total_localtax2'=>
"LineTotalLT2",
356 'fd.date_start'=>
"DateStart",
'fd.date_end'=>
"DateEnd",
'fd.special_code'=>
'SpecialCode',
357 'fd.product_type'=>
'TypeOfLineServiceOrProduct',
'fd.fk_product'=>
'ProductId',
358 'p.ref'=>
'ProductRef',
'p.label'=>
'ProductLabel', $alias_product_perentity.
'.accountancy_code_buy'=>
'ProductAccountancyBuyCode',
'project.rowid'=>
'ProjectId',
359 'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
361 if (!$uselocaltax1) {
362 unset($this->export_fields_array[$r][
'fd.localtax1_tx']);
363 unset($this->export_fields_array[$r][
'fd.localtax1_type']);
364 unset($this->export_fields_array[$r][
'fd.total_localtax1']);
366 if (!$uselocaltax2) {
367 unset($this->export_fields_array[$r][
'fd.localtax2_tx']);
368 unset($this->export_fields_array[$r][
'fd.localtax2_type']);
369 unset($this->export_fields_array[$r][
'fd.total_localtax2']);
372 if (isModEnabled(
"multicurrency")) {
373 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
374 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
375 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
376 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
377 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
379 if (!$uselocaltax1) {
380 unset($this->export_fields_array[$r][
'f.localtax1']);
382 if (!$uselocaltax2) {
383 unset($this->export_fields_array[$r][
'f.localtax2']);
392 $this->export_TypeFields_array[$r] = array(
393 's.rowid' =>
'Numeric',
's.nom'=>
'Text',
'ps.nom'=>
'Text',
's.address'=>
'Text',
's.zip'=>
'Text',
's.town'=>
'Text',
'c.code'=>
'Text',
's.phone'=>
'Text',
's.siren'=>
'Text',
's.siret'=>
'Text',
's.ape'=>
'Text',
's.idprof4'=>
'Text',
's.idprof5'=>
'Text',
's.idprof6'=>
'Text',
394 's.code_compta'=>
'Text',
's.code_compta_fournisseur'=>
'Text',
's.tva_intra'=>
'Text',
395 'f.rowid'=>
'Numeric',
'f.ref'=>
"Text",
'f.ref_supplier'=>
"Text",
'f.datec'=>
"Date",
'f.datef'=>
"Date",
'f.date_lim_reglement'=>
'Date',
396 'f.fk_cond_reglement'=>
'Numeric',
'f.fk_mode_reglement'=>
'Numeric',
397 'f.total_ht'=>
"Numeric",
'f.total_ttc'=>
"Numeric",
'f.total_tva'=>
"Numeric",
'f.localtax1'=>
"Numeric",
'f.localtax2'=>
"Numeric",
398 'f.paye'=>
"Boolean",
'f.fk_statut'=>
'Status',
'f.note_public'=>
"Text",
399 'fd.rowid'=>
'Numeric',
'fd.description'=>
"Text",
'fd.tva_tx'=>
"Text",
400 'fd.qty'=>
"Numeric",
'fd.remise_percent'=>
"Numeric",
401 'fd.total_ht'=>
"Numeric",
'fd.total_ttc'=>
"Numeric",
'fd.tva'=>
"Numeric",
'fd.total_localtax1'=>
"Numeric",
'fd.total_localtax2'=>
"Numeric",
402 'fd.localtax1_tx'=>
'Numeric',
'fd.localtax2_tx'=>
'Numeric',
'fd.localtax1_type'=>
'Numeric',
'fd.localtax2_type'=>
'Numeric',
403 'fd.date_start'=>
"Date",
'fd.date_end'=>
"Date",
'fd.special_code'=>
"Numeric",
404 'fd.product_type'=>
'Numeric',
'fd.fk_product'=>
'List:product:label', $alias_product_perentity .
'.accountancy_code_buy'=>
'Text',
405 'p.ref'=>
'Text',
'p.label'=>
'Text',
'project.ref'=>
'Text',
'project.title'=>
'Text',
406 'f.multicurrency_code' =>
'Text',
407 'f.multicurrency_tx' =>
'Number',
'f.multicurrency_total_ht' =>
'Number',
'f.multicurrency_total_tva' =>
'Number',
'f.multicurrency_total_ttc' =>
'Number'
409 $this->export_entities_array[$r] = array(
410 's.rowid'=>
"company",
's.nom'=>
'company',
'ps.nom'=>
'company',
's.address'=>
'company',
's.zip'=>
'company',
's.town'=>
'company',
'c.code'=>
'company',
's.phone'=>
'company',
's.siren'=>
'company',
's.siret'=>
'company',
411 's.ape'=>
'company',
's.idprof4'=>
'company',
's.idprof5'=>
'company',
's.idprof6'=>
'company',
's.code_compta'=>
'company',
's.code_compta_fournisseur'=>
'company',
's.tva_intra'=>
'company',
'f.rowid'=>
"invoice",
412 'f.ref'=>
"invoice",
'f.ref_supplier'=>
"invoice",
'f.datec'=>
"invoice",
'f.datef'=>
"invoice",
'f.date_lim_reglement'=>
'invoice',
413 'f.fk_cond_reglement'=>
'invoice',
'f.fk_mode_reglement'=>
'invoice',
414 'f.total_ht'=>
"invoice",
'f.total_ttc'=>
"invoice",
'f.total_tva'=>
"invoice",
415 'f.paye'=>
"invoice",
'f.fk_statut'=>
'invoice',
'f.note_public'=>
"invoice",
'fd.rowid'=>
'invoice_line',
'fd.description'=>
"invoice_line",
'fd.qty'=>
"invoice_line",
416 'fd.total_ht'=>
"invoice_line",
'fd.tva'=>
"invoice_line",
'fd.total_ttc'=>
"invoice_line",
'fd.total_localtax1'=>
"invoice_line",
'fd.total_localtax2'=>
"invoice_line",
417 '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",
418 'fd.remise_percent'=>
"invoice_line",
419 'fd.date_start'=>
"invoice_line",
'fd.date_end'=>
"invoice_line",
'fd.special_code'=>
"invoice_line",
420 'fd.product_type'=>
'invoice_line',
'fd.fk_product'=>
'product',
421 'p.ref'=>
'product',
'p.label'=>
'product', $alias_product_perentity.
'.accountancy_code_buy'=>
'product',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project'
423 $this->export_dependencies_array[$r] = array(
'invoice_line' =>
'fd.rowid',
'product' =>
'fd.rowid');
425 $keyforselect =
'facture_fourn';
426 $keyforelement =
'invoice';
427 $keyforaliasextra =
'extra';
428 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
429 $keyforselect =
'facture_fourn_det';
430 $keyforelement =
'invoice_line';
431 $keyforaliasextra =
'extraline';
432 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
434 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
435 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
436 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON ps.rowid = s.parent';
437 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
438 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
440 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
441 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture_fourn as f';
442 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
443 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
444 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as cp ON f.fk_mode_reglement = cp.id';
445 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_payment_term as cpt ON f.fk_cond_reglement = cpt.rowid,';
446 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture_fourn_det as fd';
447 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
448 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
449 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
450 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_invoice').
')';
451 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
452 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.((int) $user->id);
457 $this->export_code[$r] = $this->rights_class.
'_'.$r;
458 $this->export_label[$r] =
'Factures fournisseurs et reglements';
459 $this->export_icon[$r] =
'invoice';
460 $this->export_permission[$r] = array(array(
"fournisseur",
"facture",
"export"));
461 $this->export_fields_array[$r] = array(
462 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
463 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
464 's.code_compta'=>
'CustomerAccountancyCode',
's.code_compta_fournisseur'=>
'SupplierAccountancyCode',
's.tva_intra'=>
'VATIntra',
465 'f.rowid'=>
"InvoiceId",
'f.ref'=>
"InvoiceRef",
'f.ref_supplier'=>
"RefSupplier",
'f.datec'=>
"InvoiceDateCreation",
'f.datef'=>
"DateInvoice",
'f.date_lim_reglement'=>
"DateMaxPayment",
466 'f.fk_cond_reglement'=>
'IdPaymentTerm',
'f.fk_mode_reglement'=>
'IdPaymentMode',
467 'f.total_ht'=>
"TotalHT",
'f.total_ttc'=>
"TotalTTC",
'f.total_tva'=>
"TotalVAT",
468 'f.localtax1'=>
"TotalLT1",
'f.localtax2'=>
"TotalLT2",
469 'f.paye'=>
"InvoicePaid",
470 'f.fk_statut'=>
'InvoiceStatus',
'f.note_public'=>
"InvoiceNote",
'p.rowid'=>
'PaymentId',
'pf.amount'=>
'AmountPayment',
471 'p.datep'=>
'DatePayment',
'p.num_paiement'=>
'PaymentNumber',
'p.fk_bank'=>
'IdTransaction',
'project.rowid'=>
'ProjectId',
'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
473 if (!$uselocaltax1) {
474 unset($this->export_fields_array[$r][
'f.localtax1']);
476 if (!$uselocaltax2) {
477 unset($this->export_fields_array[$r][
'f.localtax2']);
479 if (isModEnabled(
"multicurrency")) {
480 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
481 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
482 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
483 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
484 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
492 $this->export_TypeFields_array[$r] = array(
493 's.rowid'=>
'Numeric',
's.nom'=>
'Text',
's.address'=>
'Text',
's.zip'=>
'Text',
's.town'=>
'Text',
'c.code'=>
'Text',
's.phone'=>
'Text',
's.siren'=>
'Text',
's.siret'=>
'Text',
's.ape'=>
'Text',
494 's.idprof4'=>
'Text',
's.idprof5'=>
'Text',
's.idprof6'=>
'Text',
's.code_compta'=>
'Text',
's.code_compta_fournisseur'=>
'Text',
's.tva_intra'=>
'Text',
495 'f.rowid'=>
'Numeric',
'f.ref'=>
"Text",
'f.ref_supplier'=>
"Text",
496 'f.datec'=>
"Date",
'f.datef'=>
"Date",
'f.date_lim_reglement'=>
'Date',
497 'f.fk_cond_reglement'=>
'Numeric',
'f.fk_mode_reglement'=>
'Numeric',
498 'f.total_ht'=>
"Numeric",
'f.total_ttc'=>
"Numeric",
'f.total_tva'=>
"Numeric",
'f.localtax1'=>
"Numeric",
'f.localtax2'=>
"Numeric",
499 'f.paye'=>
"Boolean",
'f.fk_statut'=>
'Status',
'f.note_public'=>
"Text",
'pf.amount'=>
'Numeric',
500 'p.rowid'=>
'Numeric',
'p.datep'=>
'Date',
'p.num_paiement'=>
'Numeric',
'p.fk_bank'=>
'Numeric',
'project.rowid'=>
'Numeric',
'project.ref'=>
'Text',
'project.title'=>
'Text',
501 'f.multicurrency_code' =>
'Text',
502 'f.multicurrency_tx' =>
'Number',
'f.multicurrency_total_ht' =>
'Number',
'f.multicurrency_total_tva' =>
'Number',
'f.multicurrency_total_ttc' =>
'Number'
504 $this->export_entities_array[$r] = array(
505 's.rowid' =>
"company",
's.nom' =>
'company',
's.address' =>
'company',
's.zip' =>
'company',
's.town' =>
'company',
'c.code' =>
'company',
's.phone' =>
'company',
506 's.siren' =>
'company',
's.siret' =>
'company',
's.ape' =>
'company',
's.idprof4' =>
'company',
's.idprof5' =>
'company',
's.idprof6' =>
'company',
507 's.code_compta' =>
'company',
's.code_compta_fournisseur' =>
'company',
's.tva_intra' =>
'company',
508 'f.rowid' =>
"invoice",
'f.ref' =>
"invoice",
'f.ref_supplier' =>
"invoice",
'f.datec' =>
"invoice",
'f.datef' =>
"invoice",
'f.date_lim_reglement' =>
'invoice',
509 'f.fk_cond_reglement' =>
'invoice',
'f.fk_mode_reglement' =>
'invoice',
510 'f.total_ht' =>
"invoice",
'f.total_ttc' =>
"invoice",
'f.total_tva' =>
"invoice",
'f.paye' =>
"invoice",
'f.fk_statut' =>
'invoice',
'f.note_public' =>
"invoice",
'p.rowid' =>
'payment',
'pf.amount' =>
'payment',
511 'p.datep' =>
'payment',
'p.num_paiement' =>
'payment',
'p.fk_bank' =>
'account',
'project.rowid' =>
'project',
'project.ref' =>
'project',
'project.title' =>
'project');
512 $this->export_dependencies_array[$r] = array(
'payment' =>
'p.rowid');
514 $keyforselect =
'facture_fourn';
515 $keyforelement =
'invoice';
516 $keyforaliasextra =
'extra';
517 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
519 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
520 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
521 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
522 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
524 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
525 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture_fourn as f';
526 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
527 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
528 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
529 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
530 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as cp ON f.fk_mode_reglement = cp.id';
531 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_payment_term as cpt ON f.fk_cond_reglement = cpt.rowid';
532 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid';
533 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_invoice').
')';
534 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
535 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.((int) $user->id);
540 $this->export_code[$r] = $this->rights_class.
'_'.$r;
541 $this->export_label[$r] =
'Purchase Orders and lines of purchase orders';
542 $this->export_icon[$r] =
'order';
543 $this->export_permission[$r] = array(array(
"fournisseur",
"commande",
"export"));
544 $this->export_fields_array[$r] = array(
545 's.rowid' =>
"IdCompany",
's.nom' =>
'CompanyName',
'ps.nom' =>
'ParentCompany',
's.address' =>
'Address',
's.zip' =>
'Zip',
's.town' =>
'Town',
'c.code' =>
'CountryCode',
's.phone' =>
'Phone',
546 's.siren' =>
'ProfId1',
's.siret' =>
'ProfId2',
's.ape' =>
'ProfId3',
's.idprof4' =>
'ProfId4',
's.idprof5' =>
'ProfId5',
's.idprof6' =>
'ProfId6',
's.tva_intra' =>
'VATIntra',
547 'f.rowid' =>
"OrderId",
'f.ref' =>
"Ref",
'f.ref_supplier' =>
"RefSupplier",
'f.date_creation' =>
"DateCreation",
'f.date_commande' =>
"OrderDate",
'f.date_livraison' =>
"DateDeliveryPlanned",
548 'f.total_ht' =>
"TotalHT",
'f.total_ttc' =>
"TotalTTC",
'f.total_tva' =>
"TotalVAT",
'f.fk_statut' =>
'Status',
'f.date_valid' =>
'DateValidation',
'f.date_approve' =>
'DateApprove',
'f.date_approve2' =>
'DateApprove2',
549 'f.note_public' =>
"NotePublic",
'f.note_private' =>
"NotePrivate",
'uv.login' =>
'UserValidation',
'ua1.login' =>
'ApprovedBy',
'ua2.login' =>
'ApprovedBy2',
'fd.rowid' =>
'LineId',
'fd.description' =>
"LineDescription",
550 'fd.tva_tx' =>
"LineVATRate",
'fd.qty' =>
"LineQty",
'fd.remise_percent' =>
"Discount",
'fd.total_ht' =>
"LineTotalHT",
'fd.total_ttc' =>
"LineTotalTTC",
551 'fd.total_tva' =>
"LineTotalVAT",
'fd.date_start' =>
"DateStart",
'fd.date_end' =>
"DateEnd",
'fd.special_code' =>
'SpecialCode',
552 'fd.product_type' =>
'TypeOfLineServiceOrProduct',
'fd.ref' =>
'SupplierRef',
'fd.fk_product' =>
'ProductId',
553 'p.ref' =>
'ProductRef',
'p.label' =>
'ProductLabel',
'project.rowid' =>
'ProjectId',
'project.ref' =>
'ProjectRef',
'project.title' =>
'ProjectLabel'
555 if (isModEnabled(
"multicurrency")) {
556 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
557 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
558 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
559 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
560 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
563 unset($this->export_fields_array[
'f.date_approve2']);
564 unset($this->export_fields_array[
'ua2.login']);
566 $this->export_TypeFields_array[$r] = array(
567 's.rowid' =>
"company",
's.nom' =>
'Text',
'ps.nom' =>
'Text',
's.address' =>
'Text',
's.cp' =>
'Text',
's.ville' =>
'Text',
'c.code' =>
'Text',
's.tel' =>
'Text',
's.siren' =>
'Text',
568 's.siret' =>
'Text',
's.ape' =>
'Text',
's.idprof4' =>
'Text',
's.idprof5' =>
'Text',
's.idprof6' =>
'Text',
's.tva_intra' =>
'Text',
'f.ref' =>
"Text",
'f.ref_supplier' =>
"Text",
569 'f.date_creation' =>
"Date",
'f.date_commande' =>
"Date",
'f.date_livraison' =>
"Date",
'f.total_ht' =>
"Numeric",
'f.total_ttc' =>
"Numeric",
'f.total_tva' =>
"Numeric",
570 'f.fk_statut' =>
'Status',
'f.date_valid' =>
'Date',
'f.date_approve' =>
'Date',
'f.date_approve2' =>
'Date',
'f.note_public' =>
"Text",
'f.note_private' =>
"Text",
'fd.description' =>
"Text",
571 'fd.tva_tx' =>
"Numeric",
'fd.qty' =>
"Numeric",
'fd.remise_percent' =>
"Numeric",
'fd.total_ht' =>
"Numeric",
'fd.total_ttc' =>
"Numeric",
'fd.total_tva' =>
"Numeric",
572 'fd.date_start' =>
"Date",
'fd.date_end' =>
"Date",
'fd.special_code' =>
"Numeric",
573 'fd.product_type' =>
'Numeric',
'fd.ref' =>
'Text',
'fd.fk_product' =>
'List:product:label',
'p.ref' =>
'Text',
'p.label' =>
'Text',
'project.ref' =>
'Text',
'project.title' =>
'Text'
575 $this->export_entities_array[$r] = array(
576 's.rowid' =>
"company",
's.nom' =>
'company',
'ps.nom' =>
'company',
's.address' =>
'company',
's.zip' =>
'company',
's.town' =>
'company',
'c.code' =>
'company',
's.phone' =>
'company',
's.siren' =>
'company',
577 's.siret' =>
'company',
's.ape' =>
'company',
's.idprof4' =>
'company',
's.idprof5' =>
'company',
's.idprof6' =>
'company',
's.tva_intra' =>
'company',
'uv.login' =>
'user',
'ua1.login' =>
'user',
578 'ua2.login' =>
'user',
'fd.rowid' =>
'order_line',
'fd.description' =>
"order_line",
'fd.tva_tx' =>
"order_line",
'fd.qty' =>
"order_line",
'fd.remise_percent' =>
"order_line",
579 'fd.total_ht' =>
"order_line",
'fd.total_ttc' =>
"order_line",
'fd.total_tva' =>
"order_line",
'fd.date_start' =>
"order_line",
'fd.date_end' =>
"order_line",
'fd.special_code' =>
"order_line",
580 'fd.product_type' =>
'order_line',
'fd.ref' =>
'order_line',
'fd.fk_product' =>
'product',
581 'p.ref' =>
'product',
'p.label' =>
'product',
'project.rowid' =>
'project',
'project.ref' =>
'project',
'project.title' =>
'project'
583 $this->export_dependencies_array[$r] = array(
'order_line' =>
'fd.rowid',
'product' =>
'fd.rowid');
585 $keyforselect =
'commande_fournisseur';
586 $keyforelement =
'order';
587 $keyforaliasextra =
'extra';
588 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
591 $keyforselect =
'commande_fournisseurdet';
592 $keyforelement =
'order_line';
593 $keyforaliasextra =
'extraline';
594 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
596 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
597 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
598 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON ps.rowid = s.parent';
599 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
600 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
602 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
603 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'commande_fournisseur as f';
604 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
605 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uv ON uv.rowid = f.fk_user_valid';
606 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as ua1 ON ua1.rowid = f.fk_user_approve';
607 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as ua2 ON ua2.rowid = f.fk_user_approve2';
608 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
609 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'commande_fournisseurdet as fd';
610 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
611 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
612 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
613 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_order').
')';
614 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
615 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.((int) $user->id);
623 $this->import_code[$r] = $this->rights_class.
'_'.$r;
624 $this->import_label[$r] =
"SupplierInvoices";
625 $this->import_icon[$r] = $this->picto;
626 $this->import_entities_array[$r] = array();
627 $this->import_tables_array[$r] = array(
'f' => MAIN_DB_PREFIX.
'facture_fourn',
'extra' => MAIN_DB_PREFIX.
'facture_fourn_extrafields');
628 $this->import_tables_creator_array[$r] = array(
'f' =>
'fk_user_author');
629 $this->import_fields_array[$r] = array(
630 'f.ref' =>
'InvoiceRef*',
631 'f.ref_supplier' =>
'RefSupplier',
633 'f.fk_soc' =>
'Supplier/Vendor*',
634 'f.datec' =>
'InvoiceDateCreation',
635 'f.datef' =>
'DateInvoice',
636 'f.date_lim_reglement' =>
'DateMaxPayment',
637 'f.total_ht' =>
'TotalHT',
638 'f.total_ttc' =>
'TotalTTC',
639 'f.total_tva' =>
'TotalVAT',
640 'f.paye' =>
'InvoicePaid',
641 'f.fk_statut' =>
'InvoiceStatus',
642 'f.fk_user_modif' =>
'Modifier Id',
643 'f.fk_user_valid' =>
'Validator Id',
644 'f.fk_facture_source' =>
'Invoice Source Id',
645 'f.fk_projet' =>
'Project Id',
646 'f.fk_account' =>
'Bank Account*',
647 'f.note_public' =>
'InvoiceNote',
648 'f.note_private' =>
'NotePrivate',
649 'f.fk_cond_reglement' =>
'PaymentTerm',
650 'f.fk_mode_reglement' =>
'PaymentMode',
651 'f.model_pdf' =>
'Model',
652 'f.date_valid' =>
'DateValidation'
654 if (isModEnabled(
"multicurrency")) {
655 $this->import_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
656 $this->import_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
657 $this->import_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
658 $this->import_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
659 $this->import_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
662 $import_extrafield_sample = array();
663 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.
")";
664 $resql = $this->db->query($sql);
666 while ($obj = $this->db->fetch_object($resql)) {
667 $fieldname =
'extra.'.$obj->name;
668 $fieldlabel = ucfirst($obj->label);
669 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
670 $import_extrafield_sample[$fieldname] = $fieldlabel;
674 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facture_fourn');
675 if (empty($conf->multicurrency->enabled)) {
676 $this->import_fieldshidden_array[$r][
'f.multicurrency_code'] =
'const-'.$conf->currency;
678 $this->import_regex_array[$r] = array(
'f.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency');
679 $import_sample = array(
680 'f.ref' =>
'(PROV001)',
681 'f.ref_supplier' =>
'Supplier1',
683 'f.fk_soc' =>
'Vendor1',
684 'f.datec' =>
'2021-01-01',
686 'f.date_lim_reglement' =>
'2021-01-30',
687 'f.total_ht' =>
'1000',
688 'f.total_ttc' =>
'1000',
689 'f.total_tva' =>
'0',
691 'f.fk_statut' =>
'0',
692 'f.fk_user_modif' =>
'',
693 'f.fk_user_valid' =>
'',
694 'f.fk_facture_source' =>
'',
696 'f.fk_account' =>
'BANK1',
697 'f.note_public' =>
'Note: ',
698 'f.note_private' =>
'',
699 'f.fk_cond_reglement' =>
'1',
700 'f.fk_mode_reglement' =>
'2',
701 'f.model_pdf' =>
'crab',
702 'f.date_valid' =>
'',
703 'f.multicurrency_code' =>
'USD',
704 'f.multicurrency_tx' =>
'1',
705 'f.multicurrency_total_ht' =>
'1000',
706 'f.multicurrency_total_tva' =>
'0',
707 'f.multicurrency_total_ttc' =>
'1000'
709 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
710 $this->import_updatekeys_array[$r] = array(
'f.ref' =>
'Ref');
711 $this->import_convertvalue_array[$r] = array(
713 'rule' =>
'getrefifauto',
714 'class' => (!
getDolGlobalString(
'INVOICE_SUPPLIER_ADDON_NUMBER') ?
'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER),
715 'path' =>
"/core/modules/supplier_invoice/".(!
getDolGlobalString(
'INVOICE_SUPPLIER_ADDON_NUMBER') ?
'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER).
'.php',
716 'classobject' =>
'FactureFournisseur',
717 'pathobject' =>
'/fourn/class/fournisseur.facture.class.php',
719 'f.fk_soc' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/societe/class/societe.class.php',
'class' =>
'Societe',
'method' =>
'fetch',
'element' =>
'ThirdParty'),
720 'f.fk_account' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/compta/bank/class/account.class.php',
'class' =>
'Account',
'method' =>
'fetch',
'element' =>
'bank_account'),
725 $this->import_code[$r] = $this->rights_class.
'_'.$r;
726 $this->import_label[$r] =
"SupplierInvoiceLines";
727 $this->import_icon[$r] = $this->picto;
728 $this->import_entities_array[$r] = array();
729 $this->import_tables_array[$r] = array(
'fd' => MAIN_DB_PREFIX.
'facture_fourn_det',
'extra' => MAIN_DB_PREFIX.
'facture_fourn_det_extrafields');
730 $this->import_fields_array[$r] = array(
731 'fd.fk_facture_fourn' =>
'InvoiceRef*',
732 'fd.fk_parent_line' =>
'ParentLine',
733 'fd.fk_product' =>
'IdProduct',
734 'fd.description' =>
'LineDescription',
735 'fd.pu_ht' =>
'PriceUHT',
736 'fd.pu_ttc' =>
'PriceUTTC',
737 'fd.qty' =>
'LineQty',
738 'fd.remise_percent' =>
'Reduc.',
739 'fd.vat_src_code' =>
'Vat Source Code',
740 'fd.product_type' =>
'TypeOfLineServiceOrProduct',
741 'fd.tva_tx' =>
'LineVATRate',
742 'fd.total_ht' =>
'LineTotalHT',
743 'fd.tva' =>
'LineTotalVAT',
744 'fd.total_ttc' =>
'LineTotalTTC',
745 'fd.date_start' =>
'Start Date',
746 'fd.date_end' =>
'End Date',
747 'fd.fk_unit' =>
'Unit'
749 if (isModEnabled(
"multicurrency")) {
750 $this->import_fields_array[$r][
'fd.multicurrency_code'] =
'Currency';
751 $this->import_fields_array[$r][
'fd.multicurrency_subprice'] =
'CurrencyRate';
752 $this->import_fields_array[$r][
'fd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
753 $this->import_fields_array[$r][
'fd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
754 $this->import_fields_array[$r][
'fd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
757 $import_extrafield_sample = array();
758 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.
")";
759 $resql = $this->db->query($sql);
761 while ($obj = $this->db->fetch_object($resql)) {
762 $fieldname =
'extra.'.$obj->name;
763 $fieldlabel = ucfirst($obj->label);
764 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
765 $import_extrafield_sample[$fieldname] = $fieldlabel;
769 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facture_fourn_det');
770 $this->import_regex_array[$r] = array(
'fd.product_type' =>
'[0|1]$',
'fd.fk_product' =>
'rowid@'.MAIN_DB_PREFIX.
'product',
'fd.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency');
771 $import_sample = array(
772 'fd.fk_facture_fourn' =>
'(PROV001)',
773 'fd.fk_parent_line' =>
'',
774 'fd.fk_product' =>
'',
775 'fd.description' =>
'Test Product',
776 'fd.pu_ht' =>
'50000',
777 'fd.pu_ttc' =>
'50000',
779 'fd.remise_percent' =>
'0',
780 'fd.vat_src_code' =>
'',
781 'fd.product_type' =>
'0',
783 'fd.total_ht' =>
'50000',
785 'fd.total_ttc' =>
'50000',
786 'fd.date_start' =>
'',
789 'fd.multicurrency_code' =>
'USD',
790 'fd.multicurrency_tx' =>
'0',
791 'fd.multicurrency_total_ht' =>
'50000',
792 'fd.multicurrency_total_tva' =>
'0',
793 'fd.multicurrency_total_ttc' =>
'50000'
795 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
796 $this->import_updatekeys_array[$r] = array(
'fd.rowid' =>
'Row Id',
'fd.fk_facture_fourn' =>
'Invoice Id',
'fd.fk_product' =>
'Product Id');
797 $this->import_convertvalue_array[$r] = array(
798 'fd.fk_facture_fourn' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/fourn/class/fournisseur.facture.class.php',
'class' =>
'FactureFournisseur',
'method' =>
'fetch'),
803 $this->import_code[$r] =
'commande_fournisseur_'.$r;
804 $this->import_label[$r] =
'SuppliersOrders';
805 $this->import_icon[$r] = $this->picto;
806 $this->import_entities_array[$r] = array();
807 $this->import_tables_array[$r] = array(
'c' => MAIN_DB_PREFIX.
'commande_fournisseur',
'extra' => MAIN_DB_PREFIX.
'commande_fournisseur_extrafields');
808 $this->import_tables_creator_array[$r] = array(
'c' =>
'fk_user_author');
809 $this->import_fields_array[$r] = array(
811 'c.ref_supplier' =>
'RefSupplier',
812 'c.fk_soc' =>
'ThirdPartyName*',
813 'c.fk_projet' =>
'ProjectId',
814 'c.date_creation' =>
'DateCreation',
815 'c.date_valid' =>
'DateValidation',
816 'c.date_approve' =>
'DateApprove',
817 'c.date_commande' =>
'DateOrder',
818 'c.fk_user_modif' =>
'ModifiedById',
819 'c.fk_user_valid' =>
'ValidatedById',
820 'c.fk_user_approve' =>
'ApprovedById',
821 'c.source' =>
'Source',
822 'c.fk_statut' =>
'Status*',
823 'c.billed' =>
'Billed',
824 'c.total_tva' =>
'TotalTVA',
825 'c.total_ht' =>
'TotalHT',
826 'c.total_ttc' =>
'TotalTTC',
827 'c.note_private' =>
'NotePrivate',
828 'c.note_public' =>
'Note',
829 'c.date_livraison' =>
'DeliveryDate',
830 'c.fk_cond_reglement' =>
'Payment Condition',
831 'c.fk_mode_reglement' =>
'Payment Mode',
832 'c.model_pdf' =>
'Model'
835 if (isModEnabled(
"multicurrency")) {
836 $this->import_fields_array[$r][
'c.multicurrency_code'] =
'Currency';
837 $this->import_fields_array[$r][
'c.multicurrency_tx'] =
'CurrencyRate';
838 $this->import_fields_array[$r][
'c.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
839 $this->import_fields_array[$r][
'c.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
840 $this->import_fields_array[$r][
'c.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
844 $import_extrafield_sample = array();
845 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.
")";
846 $resql = $this->db->query($sql);
849 while ($obj = $this->db->fetch_object($resql)) {
850 $fieldname =
'extra.'.$obj->name;
851 $fieldlabel = ucfirst($obj->label);
852 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
853 $import_extrafield_sample[$fieldname] = $fieldlabel;
858 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'commande_fournisseur');
859 $this->import_regex_array[$r] = array(
860 'c.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'
863 $this->import_updatekeys_array[$r] = array(
'c.ref' =>
'Ref');
864 $this->import_convertvalue_array[$r] = array(
866 'rule' =>
'getrefifauto',
867 'class' => (!
getDolGlobalString(
'COMMANDE_SUPPLIER_ADDON_NUMBER') ?
'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER),
868 'path' =>
"/core/modules/supplier_order/".(!
getDolGlobalString(
'COMMANDE_SUPPLIER_ADDON_NUMBER') ?
'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER).
'.php',
869 'classobject' =>
'CommandeFournisseur',
870 'pathobject' =>
'/fourn/class/fournisseur.commande.class.php',
873 'rule' =>
'fetchidfromref',
874 'file' =>
'/societe/class/societe.class.php',
875 'class' =>
'Societe',
877 'element' =>
'ThirdParty'
879 'c.fk_mode_reglement' => array(
880 'rule' =>
'fetchidfromcodeorlabel',
881 'file' =>
'/compta/paiement/class/cpaiement.class.php',
882 'class' =>
'Cpaiement',
884 'element' =>
'cpayment'
886 'c.source' => array(
'rule' =>
'zeroifnull'),
891 $this->import_code[$r] =
'commande_fournisseurdet_'.$r;
892 $this->import_label[$r] =
'PurchaseOrderLines';
893 $this->import_icon[$r] = $this->picto;
894 $this->import_entities_array[$r] = array();
895 $this->import_tables_array[$r] = array(
'cd' => MAIN_DB_PREFIX.
'commande_fournisseurdet',
'extra' => MAIN_DB_PREFIX.
'commande_fournisseurdet_extrafields');
896 $this->import_fields_array[$r] = array(
897 'cd.fk_commande' =>
'PurchaseOrder*',
898 'cd.fk_parent_line' =>
'ParentLine',
899 'cd.fk_product' =>
'IdProduct',
900 'cd.ref' =>
'SupplierRef',
901 'cd.description' =>
'LineDescription',
902 'cd.tva_tx' =>
'LineVATRate',
903 'cd.qty' =>
'LineQty',
904 'cd.remise_percent' =>
'Reduc. Percent',
905 'cd.subprice' =>
'Sub Price',
906 'cd.total_ht' =>
'LineTotalHT',
907 'cd.total_tva' =>
'LineTotalVAT',
908 'cd.total_ttc' =>
'LineTotalTTC',
909 'cd.product_type' =>
'TypeOfLineServiceOrProduct',
910 'cd.date_start' =>
'Start Date',
911 'cd.date_end' =>
'End Date',
912 'cd.info_bits' =>
'InfoBits',
913 'cd.special_code' =>
'Special Code',
914 'cd.rang' =>
'LinePosition',
915 'cd.fk_unit' =>
'Unit'
918 if (isModEnabled(
"multicurrency")) {
919 $this->import_fields_array[$r][
'cd.multicurrency_code'] =
'Currency';
920 $this->import_fields_array[$r][
'cd.multicurrency_subprice'] =
'CurrencyRate';
921 $this->import_fields_array[$r][
'cd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
922 $this->import_fields_array[$r][
'cd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
923 $this->import_fields_array[$r][
'cd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
927 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.
")";
928 $resql = $this->db->query($sql);
930 while ($obj = $this->db->fetch_object($resql)) {
931 $fieldname =
'extra.'.$obj->name;
932 $fieldlabel = ucfirst($obj->label);
933 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
938 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'commande_fournisseurdet');
939 $this->import_regex_array[$r] = array(
940 'cd.product_type' =>
'[0|1]$',
941 'cd.fk_product' =>
'rowid@'.MAIN_DB_PREFIX.
'product',
942 'cd.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'
944 $this->import_updatekeys_array[$r] = array(
'cd.fk_commande' =>
'Purchase Order Id');
945 $this->import_convertvalue_array[$r] = array(
946 'cd.fk_commande' => array(
947 'rule' =>
'fetchidfromref',
948 'file' =>
'/fourn/class/fournisseur.commande.class.php',
949 'class' =>
'CommandeFournisseur',
951 'element' =>
'order_supplier'
953 'cd.info_bits' => array(
'rule' =>
'zeroifnull'),
954 'cd.special_code' => array(
'rule' =>
'zeroifnull'),