44 global $conf, $langs, $user;
51 $this->family =
"srm";
52 $this->module_position =
'12';
54 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
58 $this->version =
'dolibarr';
60 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
61 $this->picto =
'company';
66 "/fournisseur/commande",
67 "/fournisseur/commande/temp",
68 "/fournisseur/facture",
69 "/fournisseur/facture/temp"
73 $this->depends = array(
"modSociete");
74 $this->requiredby = array(
"modSupplierProposal");
75 $this->langfiles = array(
'bills',
'companies',
'suppliers',
'orders',
'sendings');
78 $this->config_page_url = array(
"supplier_order.php");
81 $this->
const = array();
84 $this->
const[$r][0] =
"COMMANDE_SUPPLIER_ADDON_PDF";
85 $this->
const[$r][1] =
"chaine";
86 $this->
const[$r][2] =
"cornas";
87 $this->
const[$r][3] =
'Nom du gestionnaire de generation des bons de commande en PDF';
88 $this->
const[$r][4] = 0;
91 $this->
const[$r][0] =
"COMMANDE_SUPPLIER_ADDON_NUMBER";
92 $this->
const[$r][1] =
"chaine";
93 $this->
const[$r][2] =
"mod_commande_fournisseur_muguet";
94 $this->
const[$r][3] =
'Nom du gestionnaire de numerotation des commandes fournisseur';
95 $this->
const[$r][4] = 0;
107 $this->
const[$r][0] =
"INVOICE_SUPPLIER_ADDON_NUMBER";
108 $this->
const[$r][1] =
"chaine";
109 $this->
const[$r][2] =
"mod_facture_fournisseur_cactus";
110 $this->
const[$r][3] =
'Nom du gestionnaire de numerotation des factures fournisseur';
111 $this->
const[$r][4] = 0;
115 $this->
const[$r][0] =
"SUPPLIER_ORDER_ADDON_PDF_ODT_PATH";
116 $this->
const[$r][1] =
"chaine";
117 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/supplier_orders";
118 $this->
const[$r][3] =
'';
119 $this->
const[$r][4] = 0;
123 $this->
const[$r][0] =
"SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH";
124 $this->
const[$r][1] =
"chaine";
125 $this->
const[$r][2] =
"";
126 $this->
const[$r][3] =
"";
127 $this->
const[$r][4] = 0;
131 $this->boxes = array(
132 0=>array(
'file'=>
'box_graph_invoices_supplier_permonth.php',
'enabledbydefaulton'=>
'Home'),
133 1=>array(
'file'=>
'box_graph_orders_supplier_permonth.php',
'enabledbydefaulton'=>
'Home'),
134 2=>array(
'file'=>
'box_fournisseurs.php',
'enabledbydefaulton'=>
'Home'),
135 3=>array(
'file'=>
'box_factures_fourn_imp.php',
'enabledbydefaulton'=>
'Home'),
136 4=>array(
'file'=>
'box_factures_fourn.php',
'enabledbydefaulton'=>
'Home'),
137 5=>array(
'file'=>
'box_supplier_orders.php',
'enabledbydefaulton'=>
'Home'),
138 6=>array(
'file'=>
'box_supplier_orders_awaiting_reception.php',
'enabledbydefaulton'=>
'Home'),
142 $datestart =
dol_mktime(23, 0, 0, $arraydate[
'mon'], $arraydate[
'mday'], $arraydate[
'year']);
143 $this->cronjobs = array(
145 'label'=>
'RecurringSupplierInvoicesJob',
147 'class'=>
'fourn/class/fournisseur.facture-rec.class.php',
148 'objectname'=>
'FactureFournisseurRec',
149 'method'=>
'createRecurringInvoices',
151 'comment'=>
'Generate recurring supplier invoices',
153 'unitfrequency'=>3600 * 24,
156 'datestart'=>$datestart
161 $this->rights = array();
162 $this->rights_class =
'fournisseur';
166 $this->rights[$r][0] = 1181;
167 $this->rights[$r][1] =
'Consulter les fournisseurs';
168 $this->rights[$r][2] =
'r';
169 $this->rights[$r][3] = 0;
170 $this->rights[$r][4] =
'lire';
173 $this->rights[$r][0] = 1182;
174 $this->rights[$r][1] =
'Consulter les commandes fournisseur';
175 $this->rights[$r][2] =
'r';
176 $this->rights[$r][3] = 0;
177 $this->rights[$r][4] =
'commande';
178 $this->rights[$r][5] =
'lire';
181 $this->rights[$r][0] = 1183;
182 $this->rights[$r][1] =
'Creer une commande fournisseur';
183 $this->rights[$r][2] =
'w';
184 $this->rights[$r][3] = 0;
185 $this->rights[$r][4] =
'commande';
186 $this->rights[$r][5] =
'creer';
189 $this->rights[$r][0] = 1184;
190 $this->rights[$r][1] =
'Valider une commande fournisseur';
191 $this->rights[$r][2] =
'w';
192 $this->rights[$r][3] = 0;
193 $this->rights[$r][4] =
'supplier_order_advance';
194 $this->rights[$r][5] =
'validate';
197 $this->rights[$r][0] = 1185;
198 $this->rights[$r][1] =
'Approuver une commande fournisseur';
199 $this->rights[$r][2] =
'w';
200 $this->rights[$r][3] = 0;
201 $this->rights[$r][4] =
'commande';
202 $this->rights[$r][5] =
'approuver';
205 $this->rights[$r][0] = 1186;
206 $this->rights[$r][1] =
'Commander une commande fournisseur';
207 $this->rights[$r][2] =
'w';
208 $this->rights[$r][3] = 0;
209 $this->rights[$r][4] =
'commande';
210 $this->rights[$r][5] =
'commander';
213 $this->rights[$r][0] = 1187;
214 $this->rights[$r][1] =
'Receptionner une commande fournisseur';
215 $this->rights[$r][2] =
'd';
216 $this->rights[$r][3] = 0;
217 $this->rights[$r][4] =
'commande';
218 $this->rights[$r][5] =
'receptionner';
221 $this->rights[$r][0] = 1189;
222 $this->rights[$r][1] =
'Check/Uncheck a supplier order reception';
223 $this->rights[$r][2] =
'w';
224 $this->rights[$r][3] = 0;
225 $this->rights[$r][4] =
'commande_advance';
226 $this->rights[$r][5] =
'check';
229 $this->rights[$r][0] = 1188;
230 $this->rights[$r][1] =
'Supprimer une commande fournisseur';
231 $this->rights[$r][2] =
'd';
232 $this->rights[$r][3] = 0;
233 $this->rights[$r][4] =
'commande';
234 $this->rights[$r][5] =
'supprimer';
236 if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) {
238 $this->rights[$r][0] = 1190;
239 $this->rights[$r][1] =
'Approve supplier order (second level)';
240 $this->rights[$r][2] =
'w';
241 $this->rights[$r][3] = 0;
242 $this->rights[$r][4] =
'commande';
243 $this->rights[$r][5] =
'approve2';
247 $this->rights[$r][0] = 1191;
248 $this->rights[$r][1] =
'Exporter les commande fournisseurs, attributs';
249 $this->rights[$r][2] =
'r';
250 $this->rights[$r][3] = 0;
251 $this->rights[$r][4] =
'commande';
252 $this->rights[$r][5] =
'export';
255 $this->rights[$r][0] = 1231;
256 $this->rights[$r][1] =
'Consulter les factures fournisseur';
257 $this->rights[$r][2] =
'r';
258 $this->rights[$r][3] = 0;
259 $this->rights[$r][4] =
'facture';
260 $this->rights[$r][5] =
'lire';
263 $this->rights[$r][0] = 1232;
264 $this->rights[$r][1] =
'Creer une facture fournisseur';
265 $this->rights[$r][2] =
'w';
266 $this->rights[$r][3] = 0;
267 $this->rights[$r][4] =
'facture';
268 $this->rights[$r][5] =
'creer';
271 $this->rights[$r][0] = 1233;
272 $this->rights[$r][1] =
'Valider une facture fournisseur';
273 $this->rights[$r][2] =
'w';
274 $this->rights[$r][3] = 0;
275 $this->rights[$r][4] =
'supplier_invoice_advance';
276 $this->rights[$r][5] =
'validate';
279 $this->rights[$r][0] = 1234;
280 $this->rights[$r][1] =
'Supprimer une facture fournisseur';
281 $this->rights[$r][2] =
'd';
282 $this->rights[$r][3] = 0;
283 $this->rights[$r][4] =
'facture';
284 $this->rights[$r][5] =
'supprimer';
287 $this->rights[$r][0] = 1235;
288 $this->rights[$r][1] =
'Envoyer les factures par mail';
289 $this->rights[$r][2] =
'a';
290 $this->rights[$r][3] = 0;
291 $this->rights[$r][4] =
'supplier_invoice_advance';
292 $this->rights[$r][5] =
'send';
295 $this->rights[$r][0] = 1236;
296 $this->rights[$r][1] =
'Exporter les factures fournisseurs, attributs et reglements';
297 $this->rights[$r][2] =
'r';
298 $this->rights[$r][3] = 0;
299 $this->rights[$r][4] =
'facture';
300 $this->rights[$r][5] =
'export';
312 $langs->loadLangs(array(
"suppliers",
"multicurrency"));
315 $this->export_code[$r] = $this->rights_class.
'_'.$r;
316 $this->export_label[$r] =
'Vendor invoices and lines of invoices';
317 $this->export_icon[$r] =
'invoice';
318 $this->export_permission[$r] = array(array(
"fournisseur",
"facture",
"export"));
319 $this->export_fields_array[$r] = array(
320 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
'ps.nom'=>
'ParentCompany',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
321 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
322 's.code_compta'=>
'CustomerAccountancyCode',
's.code_compta_fournisseur'=>
'SupplierAccountancyCode',
's.tva_intra'=>
'VATIntra',
323 'f.rowid'=>
"InvoiceId",
'f.ref'=>
"InvoiceRef",
'f.ref_supplier'=>
"RefSupplier",
'f.datec'=>
"InvoiceDateCreation",
'f.datef'=>
"DateInvoice",
'f.date_lim_reglement'=>
'DateMaxPayment',
324 'f.total_ht'=>
"TotalHT",
'f.total_ttc'=>
"TotalTTC",
'f.total_tva'=>
"TotalVAT",
'f.paye'=>
"InvoicePaid",
'f.fk_statut'=>
'InvoiceStatus',
'f.note_public'=>
"InvoiceNote",
325 'fd.rowid'=>
'LineId',
'fd.description'=>
"LineDescription",
'fd.tva_tx'=>
"LineVATRate",
'fd.qty'=>
"LineQty",
'fd.remise_percent'=>
"Discount",
'fd.total_ht'=>
"LineTotalHT",
326 'fd.total_ttc'=>
"LineTotalTTC",
'fd.tva'=>
"LineTotalVAT",
'fd.date_start'=>
"DateStart",
'fd.date_end'=>
"DateEnd",
'fd.special_code'=>
'SpecialCode',
327 'fd.product_type'=>
'TypeOfLineServiceOrProduct',
'fd.fk_product'=>
'ProductId',
328 'p.ref'=>
'ProductRef',
'p.label'=>
'ProductLabel',
'p.accountancy_code_buy'=>
'ProductAccountancyBuyCode',
'project.rowid'=>
'ProjectId',
329 'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
331 if (isModEnabled(
"multicurrency")) {
332 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
333 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
334 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
335 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
336 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
344 $this->export_TypeFields_array[$r] = array(
345 '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',
346 's.code_compta'=>
'Text',
's.code_compta_fournisseur'=>
'Text',
's.tva_intra'=>
'Text',
'f.ref'=>
"Text",
'f.ref_supplier'=>
"Text",
'f.datec'=>
"Date",
'f.datef'=>
"Date",
'f.date_lim_reglement'=>
'Date',
347 'f.total_ht'=>
"Numeric",
'f.total_ttc'=>
"Numeric",
'f.total_tva'=>
"Numeric",
'f.paye'=>
"Boolean",
'f.fk_statut'=>
'Status',
'f.note_public'=>
"Text",
'fd.description'=>
"Text",
'fd.tva_tx'=>
"Text",
348 'fd.qty'=>
"Numeric",
'fd.total_ht'=>
"Numeric",
'fd.total_ttc'=>
"Numeric",
'fd.tva'=>
"Numeric",
'fd.date_start'=>
"Date",
'fd.date_end'=>
"Date",
'fd.special_code'=>
"Numeric",
349 'fd.product_type'=>
'Numeric',
'fd.fk_product'=>
'List:product:label',
350 'p.ref'=>
'Text',
'p.label'=>
'Text',
'project.ref'=>
'Text',
'project.title'=>
'Text'
352 $this->export_entities_array[$r] = array(
353 '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',
354 '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",
355 'f.ref'=>
"invoice",
'f.ref_supplier'=>
"invoice",
'f.datec'=>
"invoice",
'f.datef'=>
"invoice",
'f.date_lim_reglement'=>
'invoice',
'f.total_ht'=>
"invoice",
'f.total_ttc'=>
"invoice",
'f.total_tva'=>
"invoice",
356 'f.paye'=>
"invoice",
'f.fk_statut'=>
'invoice',
'f.note_public'=>
"invoice",
'fd.rowid'=>
'invoice_line',
'fd.description'=>
"invoice_line",
'fd.tva_tx'=>
"invoice_line",
'fd.qty'=>
"invoice_line",
357 'fd.remise_percent'=>
"invoice_line",
'fd.total_ht'=>
"invoice_line",
'fd.total_ttc'=>
"invoice_line",
'fd.tva'=>
"invoice_line",
'fd.date_start'=>
"invoice_line",
'fd.date_end'=>
"invoice_line",
'fd.special_code'=>
"invoice_line",
358 'fd.product_type'=>
'invoice_line',
'fd.fk_product'=>
'product',
359 'p.ref'=>
'product',
'p.label'=>
'product',
'p.accountancy_code_buy'=>
'product',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project'
361 $this->export_dependencies_array[$r] = array(
'invoice_line'=>
'fd.rowid',
'product'=>
'fd.rowid');
363 $keyforselect =
'facture_fourn';
364 $keyforelement =
'invoice';
365 $keyforaliasextra =
'extra';
366 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
367 $keyforselect =
'facture_fourn_det';
368 $keyforelement =
'invoice_line';
369 $keyforaliasextra =
'extraline';
370 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
372 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
373 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
374 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON ps.rowid = s.parent';
375 if (is_object($user) && empty($user->rights->societe->client->voir)) {
376 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
378 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
379 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture_fourn as f';
380 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
381 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
382 $this->export_sql_end[$r] .=
' , '.MAIN_DB_PREFIX.
'facture_fourn_det as fd';
383 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
384 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
385 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
386 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_invoice').
')';
387 if (is_object($user) && empty($user->rights->societe->client->voir)) {
388 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.((int) $user->id);
392 $this->export_code[$r] = $this->rights_class.
'_'.$r;
393 $this->export_label[$r] =
'Factures fournisseurs et reglements';
394 $this->export_icon[$r] =
'invoice';
395 $this->export_permission[$r] = array(array(
"fournisseur",
"facture",
"export"));
396 $this->export_fields_array[$r] = array(
397 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
398 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
399 's.code_compta'=>
'CustomerAccountancyCode',
's.code_compta_fournisseur'=>
'SupplierAccountancyCode',
's.tva_intra'=>
'VATIntra',
400 'f.rowid'=>
"InvoiceId",
'f.ref'=>
"InvoiceRef",
'f.ref_supplier'=>
"RefSupplier",
'f.datec'=>
"InvoiceDateCreation",
401 'f.datef'=>
"DateInvoice",
'f.total_ht'=>
"TotalHT",
'f.total_ttc'=>
"TotalTTC",
'f.total_tva'=>
"TotalVAT",
'f.paye'=>
"InvoicePaid",
402 'f.fk_statut'=>
'InvoiceStatus',
'f.note_public'=>
"InvoiceNote",
'p.rowid'=>
'PaymentId',
'pf.amount'=>
'AmountPayment',
403 'p.datep'=>
'DatePayment',
'p.num_paiement'=>
'PaymentNumber',
'p.fk_bank'=>
'IdTransaction',
'project.rowid'=>
'ProjectId',
'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
405 if (isModEnabled(
"multicurrency")) {
406 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
407 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
408 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
409 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
410 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
418 $this->export_TypeFields_array[$r] = array(
419 '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',
420 's.idprof4'=>
'Text',
's.code_compta'=>
'Text',
's.code_compta_fournisseur'=>
'Text',
's.tva_intra'=>
'Text',
'f.ref'=>
"Text",
'f.ref_supplier'=>
"Text",
'f.datec'=>
"Date",
'f.datef'=>
"Date",
'f.total_ht'=>
"Numeric",
421 'f.total_ttc'=>
"Numeric",
'f.total_tva'=>
"Numeric",
'f.paye'=>
"Boolean",
'f.fk_statut'=>
'Status',
'f.note_public'=>
"Text",
'pf.amount'=>
'Numeric',
422 'p.datep'=>
'Date',
'p.num_paiement'=>
'Numeric',
'p.fk_bank'=>
'Numeric',
'project.ref'=>
'Text',
'project.title'=>
'Text'
424 $this->export_entities_array[$r] = array(
425 's.rowid'=>
"company",
's.nom'=>
'company',
's.address'=>
'company',
's.zip'=>
'company',
's.town'=>
'company',
'c.code'=>
'company',
's.phone'=>
'company',
426 's.siren'=>
'company',
's.siret'=>
'company',
's.ape'=>
'company',
's.idprof4'=>
'company',
's.idprof5'=>
'company',
's.idprof6'=>
'company',
427 's.code_compta'=>
'company',
's.code_compta_fournisseur'=>
'company',
's.tva_intra'=>
'company',
428 'f.rowid'=>
"invoice",
'f.ref'=>
"invoice",
'f.ref_supplier'=>
"invoice",
'f.datec'=>
"invoice",
'f.datef'=>
"invoice",
'f.total_ht'=>
"invoice",
429 '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',
430 'p.datep'=>
'payment',
'p.num_paiement'=>
'payment',
'p.fk_bank'=>
'account',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project');
431 $this->export_dependencies_array[$r] = array(
'payment'=>
'p.rowid');
433 $keyforselect =
'facture_fourn';
434 $keyforelement =
'invoice';
435 $keyforaliasextra =
'extra';
436 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
438 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
439 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
440 if (is_object($user) && empty($user->rights->societe->client->voir)) {
441 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
443 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
444 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture_fourn as f';
445 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
446 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
447 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
448 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
449 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid';
450 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_invoice').
')';
451 if (is_object($user) && empty($user->rights->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] =
'Purchase Orders and lines of purchase orders';
459 $this->export_icon[$r] =
'order';
460 $this->export_permission[$r] = array(array(
"fournisseur",
"commande",
"export"));
461 $this->export_fields_array[$r] = array(
462 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
'ps.nom'=>
'ParentCompany',
'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',
's.tva_intra'=>
'VATIntra',
464 'f.rowid'=>
"OrderId",
'f.ref'=>
"Ref",
'f.ref_supplier'=>
"RefSupplier",
'f.date_creation'=>
"DateCreation",
'f.date_commande'=>
"OrderDate",
'f.date_livraison'=>
"DateDeliveryPlanned",
465 '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',
466 'f.note_public'=>
"NotePublic",
'f.note_private'=>
"NotePrivate",
'uv.login'=>
'UserValidation',
'ua1.login'=>
'ApprovedBy',
'ua2.login'=>
'ApprovedBy2',
'fd.rowid'=>
'LineId',
'fd.description'=>
"LineDescription",
467 'fd.tva_tx'=>
"LineVATRate",
'fd.qty'=>
"LineQty",
'fd.remise_percent'=>
"Discount",
'fd.total_ht'=>
"LineTotalHT",
'fd.total_ttc'=>
"LineTotalTTC",
468 'fd.total_tva'=>
"LineTotalVAT",
'fd.date_start'=>
"DateStart",
'fd.date_end'=>
"DateEnd",
'fd.special_code'=>
'SpecialCode',
469 'fd.product_type'=>
'TypeOfLineServiceOrProduct',
'fd.ref'=>
'SupplierRef',
'fd.fk_product'=>
'ProductId',
470 'p.ref'=>
'ProductRef',
'p.label'=>
'ProductLabel',
'project.rowid'=>
'ProjectId',
'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
472 if (isModEnabled(
"multicurrency")) {
473 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
474 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
475 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
476 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
477 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
479 if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) {
480 unset($this->export_fields_array[
'f.date_approve2']);
481 unset($this->export_fields_array[
'ua2.login']);
483 $this->export_TypeFields_array[$r] = array(
484 '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',
485 '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",
486 'f.date_creation'=>
"Date",
'f.date_commande'=>
"Date",
'f.date_livraison'=>
"Date",
'f.total_ht'=>
"Numeric",
'f.total_ttc'=>
"Numeric",
'f.total_tva'=>
"Numeric",
487 '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",
488 'fd.tva_tx'=>
"Numeric",
'fd.qty'=>
"Numeric",
'fd.remise_percent'=>
"Numeric",
'fd.total_ht'=>
"Numeric",
'fd.total_ttc'=>
"Numeric",
'fd.total_tva'=>
"Numeric",
489 'fd.date_start'=>
"Date",
'fd.date_end'=>
"Date",
'fd.special_code'=>
"Numeric",
490 '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'
492 $this->export_entities_array[$r] = array(
493 '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',
494 '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',
495 '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",
496 '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",
497 'fd.product_type'=>
'order_line',
'fd.ref'=>
'order_line',
'fd.fk_product'=>
'product',
498 'p.ref'=>
'product',
'p.label'=>
'product',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project'
500 $this->export_dependencies_array[$r] = array(
'order_line'=>
'fd.rowid',
'product'=>
'fd.rowid');
502 $keyforselect =
'commande_fournisseur';
503 $keyforelement =
'order';
504 $keyforaliasextra =
'extra';
505 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
508 $keyforselect =
'commande_fournisseurdet';
509 $keyforelement =
'order_line';
510 $keyforaliasextra =
'extraline';
511 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
513 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
514 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
515 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON ps.rowid = s.parent';
516 if (is_object($user) && empty($user->rights->societe->client->voir)) {
517 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
519 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
520 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'commande_fournisseur as f';
521 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
522 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uv ON uv.rowid = f.fk_user_valid';
523 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as ua1 ON ua1.rowid = f.fk_user_approve';
524 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as ua2 ON ua2.rowid = f.fk_user_approve2';
525 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
526 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'commande_fournisseurdet as fd';
527 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
528 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
529 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
530 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_order').
')';
531 if (is_object($user) && empty($user->rights->societe->client->voir)) {
532 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.((int) $user->id);
540 $this->import_code[$r] = $this->rights_class.
'_'.$r;
541 $this->import_label[$r] =
"SupplierInvoices";
542 $this->import_icon[$r] = $this->picto;
543 $this->import_entities_array[$r] = array();
544 $this->import_tables_array[$r] = array(
'f' => MAIN_DB_PREFIX.
'facture_fourn',
'extra' => MAIN_DB_PREFIX.
'facture_fourn_extrafields');
545 $this->import_tables_creator_array[$r] = array(
'f' =>
'fk_user_author');
546 $this->import_fields_array[$r] = array(
547 'f.ref' =>
'InvoiceRef*',
548 'f.ref_supplier' =>
'RefSupplier',
550 'f.fk_soc' =>
'Supplier/Vendor*',
551 'f.datec' =>
'InvoiceDateCreation',
552 'f.datef' =>
'DateInvoice',
553 'f.date_lim_reglement' =>
'DateMaxPayment',
554 'f.total_ht' =>
'TotalHT',
555 'f.total_ttc' =>
'TotalTTC',
556 'f.total_tva' =>
'TotalVAT',
557 'f.paye' =>
'InvoicePaid',
558 'f.fk_statut' =>
'InvoiceStatus',
559 'f.fk_user_modif' =>
'Modifier Id',
560 'f.fk_user_valid' =>
'Validator Id',
561 'f.fk_facture_source' =>
'Invoice Source Id',
562 'f.fk_projet' =>
'Project Id',
563 'f.fk_account' =>
'Bank Account*',
564 'f.note_public' =>
'InvoiceNote',
565 'f.note_private' =>
'NotePrivate',
566 'f.fk_cond_reglement' =>
'Payment Condition',
567 'f.fk_mode_reglement' =>
'Payment Mode',
568 'f.model_pdf' =>
'Model',
569 'f.date_valid' =>
'Validation Date'
571 if (isModEnabled(
"multicurrency")) {
572 $this->import_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
573 $this->import_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
574 $this->import_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
575 $this->import_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
576 $this->import_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
579 $import_extrafield_sample = array();
580 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.
")";
581 $resql = $this->db->query($sql);
583 while ($obj = $this->db->fetch_object($resql)) {
584 $fieldname =
'extra.'.$obj->name;
585 $fieldlabel = ucfirst($obj->label);
586 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
587 $import_extrafield_sample[$fieldname] = $fieldlabel;
591 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facture_fourn');
592 if (empty($conf->multicurrency->enabled)) {
593 $this->import_fieldshidden_array[$r][
'f.multicurrency_code'] =
'const-'.$conf->currency;
595 $this->import_regex_array[$r] = array(
'f.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency');
596 $import_sample = array(
597 'f.ref' =>
'(PROV001)',
598 'f.ref_supplier' =>
'Supplier1',
600 'f.fk_soc' =>
'Vendor1',
601 'f.datec' =>
'2021-01-01',
603 'f.date_lim_reglement' =>
'2021-01-30',
604 'f.total_ht' =>
'1000',
605 'f.total_ttc' =>
'1000',
606 'f.total_tva' =>
'0',
608 'f.fk_statut' =>
'0',
609 'f.fk_user_modif' =>
'',
610 'f.fk_user_valid' =>
'',
611 'f.fk_facture_source' =>
'',
613 'f.fk_account' =>
'BANK1',
614 'f.note_public' =>
'Note: ',
615 'f.note_private' =>
'',
616 'f.fk_cond_reglement' =>
'1',
617 'f.fk_mode_reglement' =>
'2',
618 'f.model_pdf' =>
'crab',
619 'f.date_valid' =>
'',
620 'f.multicurrency_code' =>
'USD',
621 'f.multicurrency_tx' =>
'1',
622 'f.multicurrency_total_ht' =>
'1000',
623 'f.multicurrency_total_tva' =>
'0',
624 'f.multicurrency_total_ttc' =>
'1000'
626 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
627 $this->import_updatekeys_array[$r] = array(
'f.ref' =>
'Ref');
628 $this->import_convertvalue_array[$r] = array(
630 'rule'=>
'getrefifauto',
631 'class'=>(empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) ?
'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER),
632 'path'=>
"/core/modules/supplier_invoice/".(empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) ?
'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER).
'.php',
633 'classobject'=>
'FactureFournisseur',
634 'pathobject'=>
'/fourn/class/fournisseur.facture.class.php',
636 'f.fk_soc' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/societe/class/societe.class.php',
'class' =>
'Societe',
'method' =>
'fetch',
'element' =>
'ThirdParty'),
637 'f.fk_account' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/compta/bank/class/account.class.php',
'class' =>
'Account',
'method' =>
'fetch',
'element' =>
'bank_account'),
642 $this->import_code[$r] = $this->rights_class.
'_'.$r;
643 $this->import_label[$r] =
"SupplierInvoiceLines";
644 $this->import_icon[$r] = $this->picto;
645 $this->import_entities_array[$r] = array();
646 $this->import_tables_array[$r] = array(
'fd' => MAIN_DB_PREFIX.
'facture_fourn_det',
'extra' => MAIN_DB_PREFIX.
'facture_fourn_det_extrafields');
647 $this->import_fields_array[$r] = array(
648 'fd.fk_facture_fourn' =>
'InvoiceRef*',
649 'fd.fk_parent_line' =>
'ParentLine',
650 'fd.fk_product' =>
'IdProduct',
651 'fd.description' =>
'LineDescription',
652 'fd.pu_ht' =>
'PriceUHT',
653 'fd.pu_ttc' =>
'PriceUTTC',
654 'fd.qty' =>
'LineQty',
655 'fd.remise_percent' =>
'Reduc.',
656 'fd.vat_src_code' =>
'Vat Source Code',
657 'fd.product_type' =>
'TypeOfLineServiceOrProduct',
658 'fd.tva_tx' =>
'LineVATRate',
659 'fd.total_ht' =>
'LineTotalHT',
660 'fd.tva' =>
'LineTotalVAT',
661 'fd.total_ttc' =>
'LineTotalTTC',
662 'fd.date_start' =>
'Start Date',
663 'fd.date_end' =>
'End Date',
664 'fd.fk_unit' =>
'Unit'
666 if (isModEnabled(
"multicurrency")) {
667 $this->import_fields_array[$r][
'fd.multicurrency_code'] =
'Currency';
668 $this->import_fields_array[$r][
'fd.multicurrency_subprice'] =
'CurrencyRate';
669 $this->import_fields_array[$r][
'fd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
670 $this->import_fields_array[$r][
'fd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
671 $this->import_fields_array[$r][
'fd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
674 $import_extrafield_sample = array();
675 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.
")";
676 $resql = $this->db->query($sql);
678 while ($obj = $this->db->fetch_object($resql)) {
679 $fieldname =
'extra.'.$obj->name;
680 $fieldlabel = ucfirst($obj->label);
681 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
682 $import_extrafield_sample[$fieldname] = $fieldlabel;
686 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facture_fourn_det');
687 $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');
688 $import_sample = array(
689 'fd.fk_facture_fourn' =>
'(PROV001)',
690 'fd.fk_parent_line' =>
'',
691 'fd.fk_product' =>
'',
692 'fd.description' =>
'Test Product',
693 'fd.pu_ht' =>
'50000',
694 'fd.pu_ttc' =>
'50000',
696 'fd.remise_percent' =>
'0',
697 'fd.vat_src_code' =>
'',
698 'fd.product_type' =>
'0',
700 'fd.total_ht' =>
'50000',
702 'fd.total_ttc' =>
'50000',
703 'fd.date_start' =>
'',
706 'fd.multicurrency_code' =>
'USD',
707 'fd.multicurrency_tx' =>
'0',
708 'fd.multicurrency_total_ht' =>
'50000',
709 'fd.multicurrency_total_tva' =>
'0',
710 'fd.multicurrency_total_ttc' =>
'50000'
712 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
713 $this->import_updatekeys_array[$r] = array(
'fd.rowid' =>
'Row Id',
'fd.fk_facture_fourn' =>
'Invoice Id',
'fd.fk_product' =>
'Product Id');
714 $this->import_convertvalue_array[$r] = array(
715 'fd.fk_facture_fourn' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/fourn/class/fournisseur.facture.class.php',
'class' =>
'FactureFournisseur',
'method' =>
'fetch'),
720 $this->import_code[$r] =
'commande_fournisseur_'.$r;
721 $this->import_label[$r] =
'SuppliersOrders';
722 $this->import_icon[$r] = $this->picto;
723 $this->import_entities_array[$r] = array();
724 $this->import_tables_array[$r] = array(
'c' => MAIN_DB_PREFIX.
'commande_fournisseur',
'extra' => MAIN_DB_PREFIX.
'commande_fournisseur_extrafields');
725 $this->import_tables_creator_array[$r] = array(
'c' =>
'fk_user_author');
726 $this->import_fields_array[$r] = array(
728 'c.ref_supplier' =>
'RefSupplier',
729 'c.fk_soc' =>
'ThirdPartyName*',
730 'c.fk_projet' =>
'ProjectId',
731 'c.date_creation' =>
'DateCreation',
732 'c.date_valid' =>
'DateValid',
733 'c.date_approve' =>
'DateApprove',
734 'c.date_commande' =>
'DateOrder',
735 'c.fk_user_modif' =>
'ModifiedById',
736 'c.fk_user_valid' =>
'ValidatedById',
737 'c.fk_user_approve' =>
'ApprovedById',
738 'c.source' =>
'Source',
739 'c.fk_statut' =>
'Status*',
740 'c.billed' =>
'Billed(0/1)',
741 'c.total_tva' =>
'TotalTVA',
742 'c.total_ht' =>
'TotalHT',
743 'c.total_ttc' =>
'TotalTTC',
744 'c.note_private' =>
'NotePrivate',
745 'c.note_public' =>
'Note',
746 'c.date_livraison' =>
'DeliveryDate',
747 'c.fk_cond_reglement' =>
'Payment Condition',
748 'c.fk_mode_reglement' =>
'Payment Mode',
749 'c.model_pdf' =>
'Model'
752 if (isModEnabled(
"multicurrency")) {
753 $this->import_fields_array[$r][
'c.multicurrency_code'] =
'Currency';
754 $this->import_fields_array[$r][
'c.multicurrency_tx'] =
'CurrencyRate';
755 $this->import_fields_array[$r][
'c.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
756 $this->import_fields_array[$r][
'c.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
757 $this->import_fields_array[$r][
'c.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
761 $import_extrafield_sample = array();
762 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.
")";
763 $resql = $this->db->query($sql);
766 while ($obj = $this->db->fetch_object($resql)) {
767 $fieldname =
'extra.'.$obj->name;
768 $fieldlabel = ucfirst($obj->label);
769 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
770 $import_extrafield_sample[$fieldname] = $fieldlabel;
775 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'commande_fournisseur');
776 $this->import_regex_array[$r] = array(
777 'c.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'
780 $this->import_updatekeys_array[$r] = array(
'c.ref' =>
'Ref');
781 $this->import_convertvalue_array[$r] = array(
783 'rule'=>
'getrefifauto',
784 'class'=>(empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) ?
'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER),
785 'path'=>
"/core/modules/supplier_order/".(empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) ?
'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER).
'.php',
786 'classobject'=>
'CommandeFournisseur',
787 'pathobject'=>
'/fourn/class/fournisseur.commande.class.php',
790 'rule' =>
'fetchidfromref',
791 'file' =>
'/societe/class/societe.class.php',
792 'class' =>
'Societe',
794 'element' =>
'ThirdParty'
796 'c.fk_mode_reglement' => array(
797 'rule' =>
'fetchidfromcodeorlabel',
798 'file' =>
'/compta/paiement/class/cpaiement.class.php',
799 'class' =>
'Cpaiement',
801 'element' =>
'cpayment'
803 'c.source' => array(
'rule' =>
'zeroifnull'),
808 $this->import_code[$r] =
'commande_fournisseurdet_'.$r;
809 $this->import_label[$r] =
'PurchaseOrderLines';
810 $this->import_icon[$r] = $this->picto;
811 $this->import_entities_array[$r] = array();
812 $this->import_tables_array[$r] = array(
'cd' => MAIN_DB_PREFIX.
'commande_fournisseurdet',
'extra' => MAIN_DB_PREFIX.
'commande_fournisseurdet_extrafields');
813 $this->import_fields_array[$r] = array(
814 'cd.fk_commande' =>
'PurchaseOrder*',
815 'cd.fk_parent_line' =>
'ParentLine',
816 'cd.fk_product' =>
'IdProduct',
817 'cd.ref' =>
'SupplierRef',
818 'cd.description' =>
'LineDescription',
819 'cd.tva_tx' =>
'LineVATRate',
820 'cd.qty' =>
'LineQty',
821 'cd.remise_percent' =>
'Reduc. Percent',
822 'cd.subprice' =>
'Sub Price',
823 'cd.total_ht' =>
'LineTotalHT',
824 'cd.total_tva' =>
'LineTotalVAT',
825 'cd.total_ttc' =>
'LineTotalTTC',
826 'cd.product_type' =>
'TypeOfLineServiceOrProduct',
827 'cd.date_start' =>
'Start Date',
828 'cd.date_end' =>
'End Date',
829 'cd.info_bits' =>
'InfoBits',
830 'cd.special_code' =>
'Special Code',
831 'cd.rang' =>
'LinePosition',
832 'cd.fk_unit' =>
'Unit'
835 if (isModEnabled(
"multicurrency")) {
836 $this->import_fields_array[$r][
'cd.multicurrency_code'] =
'Currency';
837 $this->import_fields_array[$r][
'cd.multicurrency_subprice'] =
'CurrencyRate';
838 $this->import_fields_array[$r][
'cd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
839 $this->import_fields_array[$r][
'cd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
840 $this->import_fields_array[$r][
'cd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
844 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.
")";
845 $resql = $this->db->query($sql);
847 while ($obj = $this->db->fetch_object($resql)) {
848 $fieldname =
'extra.'.$obj->name;
849 $fieldlabel = ucfirst($obj->label);
850 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
855 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'commande_fournisseurdet');
856 $this->import_regex_array[$r] = array(
857 'cd.product_type' =>
'[0|1]$',
858 'cd.fk_product' =>
'rowid@'.MAIN_DB_PREFIX.
'product',
859 'cd.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'
861 $this->import_updatekeys_array[$r] = array(
'cd.fk_commande' =>
'Purchase Order Id');
862 $this->import_convertvalue_array[$r] = array(
863 'cd.fk_commande' => array(
864 'rule' =>
'fetchidfromref',
865 'file' =>
'/fourn/class/fournisseur.commande.class.php',
866 'class' =>
'CommandeFournisseur',
868 'element' =>
'order_supplier'
870 'cd.info_bits' => array(
'rule' =>
'zeroifnull'),
871 'cd.special_code' => array(
'rule' =>
'zeroifnull'),