46 global $conf, $langs, $user, $mysoc;
53 $this->family =
"srm";
54 $this->module_position =
'12';
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 =
'company';
68 "/fournisseur/commande",
69 "/fournisseur/commande/temp",
70 "/fournisseur/facture",
71 "/fournisseur/facture/temp"
75 $this->depends = array(
"modSociete");
76 $this->requiredby = array(
"modSupplierProposal");
77 $this->langfiles = array(
'bills',
'companies',
'suppliers',
'orders',
'sendings');
80 $this->config_page_url = array(
"supplier_order.php");
83 $this->
const = array();
86 $this->
const[$r][0] =
"COMMANDE_SUPPLIER_ADDON_PDF";
87 $this->
const[$r][1] =
"chaine";
88 $this->
const[$r][2] =
"cornas";
89 $this->
const[$r][3] =
'Nom du gestionnaire de generation des bons de commande en PDF';
90 $this->
const[$r][4] = 0;
93 $this->
const[$r][0] =
"COMMANDE_SUPPLIER_ADDON_NUMBER";
94 $this->
const[$r][1] =
"chaine";
95 $this->
const[$r][2] =
"mod_commande_fournisseur_muguet";
96 $this->
const[$r][3] =
'Nom du gestionnaire de numerotation des commandes fournisseur';
97 $this->
const[$r][4] = 0;
109 $this->
const[$r][0] =
"INVOICE_SUPPLIER_ADDON_NUMBER";
110 $this->
const[$r][1] =
"chaine";
111 $this->
const[$r][2] =
"mod_facture_fournisseur_cactus";
112 $this->
const[$r][3] =
'Nom du gestionnaire de numerotation des factures fournisseur';
113 $this->
const[$r][4] = 0;
117 $this->
const[$r][0] =
"SUPPLIER_ORDER_ADDON_PDF_ODT_PATH";
118 $this->
const[$r][1] =
"chaine";
119 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/supplier_orders";
120 $this->
const[$r][3] =
'';
121 $this->
const[$r][4] = 0;
125 $this->
const[$r][0] =
"SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH";
126 $this->
const[$r][1] =
"chaine";
127 $this->
const[$r][2] =
"";
128 $this->
const[$r][3] =
"";
129 $this->
const[$r][4] = 0;
133 $this->boxes = array(
134 0=>array(
'file'=>
'box_graph_invoices_supplier_permonth.php',
'enabledbydefaulton'=>
'Home'),
135 1=>array(
'file'=>
'box_graph_orders_supplier_permonth.php',
'enabledbydefaulton'=>
'Home'),
136 2=>array(
'file'=>
'box_fournisseurs.php',
'enabledbydefaulton'=>
'Home'),
137 3=>array(
'file'=>
'box_factures_fourn_imp.php',
'enabledbydefaulton'=>
'Home'),
138 4=>array(
'file'=>
'box_factures_fourn.php',
'enabledbydefaulton'=>
'Home'),
139 5=>array(
'file'=>
'box_supplier_orders.php',
'enabledbydefaulton'=>
'Home'),
140 6=>array(
'file'=>
'box_supplier_orders_awaiting_reception.php',
'enabledbydefaulton'=>
'Home'),
144 $datestart =
dol_mktime(23, 0, 0, $arraydate[
'mon'], $arraydate[
'mday'], $arraydate[
'year']);
145 $this->cronjobs = array(
147 'label'=>
'RecurringSupplierInvoicesJob',
149 'class'=>
'fourn/class/fournisseur.facture-rec.class.php',
150 'objectname'=>
'FactureFournisseurRec',
151 'method'=>
'createRecurringInvoices',
153 'comment'=>
'Generate recurring supplier invoices',
155 'unitfrequency'=>3600 * 24,
158 'datestart'=>$datestart
163 $this->rights = array();
164 $this->rights_class =
'fournisseur';
168 $this->rights[$r][0] = 1181;
169 $this->rights[$r][1] =
'Consulter les fournisseurs';
170 $this->rights[$r][2] =
'r';
171 $this->rights[$r][3] = 0;
172 $this->rights[$r][4] =
'lire';
175 $this->rights[$r][0] = 1182;
176 $this->rights[$r][1] =
'Consulter les commandes fournisseur';
177 $this->rights[$r][2] =
'r';
178 $this->rights[$r][3] = 0;
179 $this->rights[$r][4] =
'commande';
180 $this->rights[$r][5] =
'lire';
183 $this->rights[$r][0] = 1183;
184 $this->rights[$r][1] =
'Creer une commande fournisseur';
185 $this->rights[$r][2] =
'w';
186 $this->rights[$r][3] = 0;
187 $this->rights[$r][4] =
'commande';
188 $this->rights[$r][5] =
'creer';
191 $this->rights[$r][0] = 1184;
192 $this->rights[$r][1] =
'Valider une commande fournisseur';
193 $this->rights[$r][2] =
'w';
194 $this->rights[$r][3] = 0;
195 $this->rights[$r][4] =
'supplier_order_advance';
196 $this->rights[$r][5] =
'validate';
199 $this->rights[$r][0] = 1185;
200 $this->rights[$r][1] =
'Approuver une commande fournisseur';
201 $this->rights[$r][2] =
'w';
202 $this->rights[$r][3] = 0;
203 $this->rights[$r][4] =
'commande';
204 $this->rights[$r][5] =
'approuver';
207 $this->rights[$r][0] = 1186;
208 $this->rights[$r][1] =
'Commander une commande fournisseur';
209 $this->rights[$r][2] =
'w';
210 $this->rights[$r][3] = 0;
211 $this->rights[$r][4] =
'commande';
212 $this->rights[$r][5] =
'commander';
215 $this->rights[$r][0] = 1187;
216 $this->rights[$r][1] =
'Receptionner une commande fournisseur';
217 $this->rights[$r][2] =
'd';
218 $this->rights[$r][3] = 0;
219 $this->rights[$r][4] =
'commande';
220 $this->rights[$r][5] =
'receptionner';
223 $this->rights[$r][0] = 1189;
224 $this->rights[$r][1] =
'Check/Uncheck a supplier order reception';
225 $this->rights[$r][2] =
'w';
226 $this->rights[$r][3] = 0;
227 $this->rights[$r][4] =
'commande_advance';
228 $this->rights[$r][5] =
'check';
231 $this->rights[$r][0] = 1188;
232 $this->rights[$r][1] =
'Supprimer une commande fournisseur';
233 $this->rights[$r][2] =
'd';
234 $this->rights[$r][3] = 0;
235 $this->rights[$r][4] =
'commande';
236 $this->rights[$r][5] =
'supprimer';
240 $this->rights[$r][0] = 1190;
241 $this->rights[$r][1] =
'Approve supplier order (second level)';
242 $this->rights[$r][2] =
'w';
243 $this->rights[$r][3] = 0;
244 $this->rights[$r][4] =
'commande';
245 $this->rights[$r][5] =
'approve2';
249 $this->rights[$r][0] = 1191;
250 $this->rights[$r][1] =
'Exporter les commande fournisseurs, attributs';
251 $this->rights[$r][2] =
'r';
252 $this->rights[$r][3] = 0;
253 $this->rights[$r][4] =
'commande';
254 $this->rights[$r][5] =
'export';
257 $this->rights[$r][0] = 1231;
258 $this->rights[$r][1] =
'Consulter les factures fournisseur';
259 $this->rights[$r][2] =
'r';
260 $this->rights[$r][3] = 0;
261 $this->rights[$r][4] =
'facture';
262 $this->rights[$r][5] =
'lire';
265 $this->rights[$r][0] = 1232;
266 $this->rights[$r][1] =
'Creer une facture fournisseur';
267 $this->rights[$r][2] =
'w';
268 $this->rights[$r][3] = 0;
269 $this->rights[$r][4] =
'facture';
270 $this->rights[$r][5] =
'creer';
273 $this->rights[$r][0] = 1233;
274 $this->rights[$r][1] =
'Valider une facture fournisseur';
275 $this->rights[$r][2] =
'w';
276 $this->rights[$r][3] = 0;
277 $this->rights[$r][4] =
'supplier_invoice_advance';
278 $this->rights[$r][5] =
'validate';
281 $this->rights[$r][0] = 1234;
282 $this->rights[$r][1] =
'Supprimer une facture fournisseur';
283 $this->rights[$r][2] =
'd';
284 $this->rights[$r][3] = 0;
285 $this->rights[$r][4] =
'facture';
286 $this->rights[$r][5] =
'supprimer';
289 $this->rights[$r][0] = 1235;
290 $this->rights[$r][1] =
'Envoyer les factures par mail';
291 $this->rights[$r][2] =
'a';
292 $this->rights[$r][3] = 0;
293 $this->rights[$r][4] =
'supplier_invoice_advance';
294 $this->rights[$r][5] =
'send';
297 $this->rights[$r][0] = 1236;
298 $this->rights[$r][1] =
'Exporter les factures fournisseurs, attributs et reglements';
299 $this->rights[$r][2] =
'r';
300 $this->rights[$r][3] = 0;
301 $this->rights[$r][4] =
'facture';
302 $this->rights[$r][5] =
'export';
312 $uselocaltax1 = (is_object($mysoc) && $mysoc->localtax1_assuj) ? $mysoc->localtax1_assuj : 0;
313 $uselocaltax2 = (is_object($mysoc) && $mysoc->localtax2_assuj) ? $mysoc->localtax2_assuj : 0;
317 $langs->loadLangs(array(
"suppliers",
"multicurrency"));
319 $alias_product_perentity = !
getDolGlobalString(
'MAIN_PRODUCT_PERENTITY_SHARED') ?
"p" :
"ppe";
322 $this->export_code[$r] = $this->rights_class.
'_'.$r;
323 $this->export_label[$r] =
'Vendor invoices and lines of invoices';
324 $this->export_icon[$r] =
'invoice';
325 $this->export_permission[$r] = array(array(
"fournisseur",
"facture",
"export"));
326 $this->export_fields_array[$r] = array(
327 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
'ps.nom'=>
'ParentCompany',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
328 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
329 's.code_compta'=>
'CustomerAccountancyCode',
's.code_compta_fournisseur'=>
'SupplierAccountancyCode',
's.tva_intra'=>
'VATIntra',
330 'f.rowid'=>
"InvoiceId",
'f.ref'=>
"InvoiceRef",
'f.ref_supplier'=>
"RefSupplier",
'f.datec'=>
"InvoiceDateCreation",
'f.datef'=>
"DateInvoice",
'f.date_lim_reglement'=>
'DateMaxPayment',
331 'f.fk_cond_reglement'=>
'IdPaymentTerm',
'f.fk_mode_reglement'=>
'IdPaymentMode',
332 'f.total_ht'=>
"TotalHT",
'f.total_ttc'=>
"TotalTTC",
'f.total_tva'=>
"TotalVAT",
333 'f.localtax1'=>
"TotalLT1",
'f.localtax2'=>
"TotalLT2",
334 'f.paye'=>
"InvoicePaid",
'f.fk_statut'=>
'InvoiceStatus',
'f.note_public'=>
"InvoiceNote",
335 'fd.rowid'=>
'LineId',
'fd.description'=>
"LineDescription",
'fd.qty'=>
"LineQty",
'fd.remise_percent'=>
"Discount",
336 'fd.tva_tx'=>
"LineVATRate",
'fd.total_ht'=>
"LineTotalHT",
'fd.total_ttc'=>
"LineTotalTTC",
'fd.tva'=>
"LineTotalVAT",
337 'fd.localtax1_tx'=>
"LineLT1Rate",
'fd.localtax1_type'=>
"LineLT1Type",
'fd.total_localtax1'=>
"LineTotalLT1",
338 'fd.localtax2_tx'=>
"LineLT2Rate",
'fd.localtax2_type'=>
"LineLT2Type",
'fd.total_localtax2'=>
"LineTotalLT2",
339 'fd.date_start'=>
"DateStart",
'fd.date_end'=>
"DateEnd",
'fd.special_code'=>
'SpecialCode',
340 'fd.product_type'=>
'TypeOfLineServiceOrProduct',
'fd.fk_product'=>
'ProductId',
341 'p.ref'=>
'ProductRef',
'p.label'=>
'ProductLabel', $alias_product_perentity.
'.accountancy_code_buy'=>
'ProductAccountancyBuyCode',
'project.rowid'=>
'ProjectId',
342 'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
344 if (!$uselocaltax1) {
345 unset($this->export_fields_array[$r][
'fd.localtax1_tx']);
346 unset($this->export_fields_array[$r][
'fd.localtax1_type']);
347 unset($this->export_fields_array[$r][
'fd.total_localtax1']);
349 if (!$uselocaltax2) {
350 unset($this->export_fields_array[$r][
'fd.localtax2_tx']);
351 unset($this->export_fields_array[$r][
'fd.localtax2_type']);
352 unset($this->export_fields_array[$r][
'fd.total_localtax2']);
355 if (isModEnabled(
"multicurrency")) {
356 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
357 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
358 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
359 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
360 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
362 if (!$uselocaltax1) {
363 unset($this->export_fields_array[$r][
'f.localtax1']);
365 if (!$uselocaltax2) {
366 unset($this->export_fields_array[$r][
'f.localtax2']);
375 $this->export_TypeFields_array[$r] = array(
376 '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',
377 's.code_compta'=>
'Text',
's.code_compta_fournisseur'=>
'Text',
's.tva_intra'=>
'Text',
378 'f.rowid'=>
'Numeric',
'f.ref'=>
"Text",
'f.ref_supplier'=>
"Text",
'f.datec'=>
"Date",
'f.datef'=>
"Date",
'f.date_lim_reglement'=>
'Date',
379 'f.fk_cond_reglement'=>
'Numeric',
'f.fk_mode_reglement'=>
'Numeric',
380 'f.total_ht'=>
"Numeric",
'f.total_ttc'=>
"Numeric",
'f.total_tva'=>
"Numeric",
'f.localtax1'=>
"Numeric",
'f.localtax2'=>
"Numeric",
381 'f.paye'=>
"Boolean",
'f.fk_statut'=>
'Status',
'f.note_public'=>
"Text",
382 'fd.rowid'=>
'Numeric',
'fd.description'=>
"Text",
'fd.tva_tx'=>
"Text",
383 'fd.qty'=>
"Numeric",
'fd.remise_percent'=>
"Numeric",
384 'fd.total_ht'=>
"Numeric",
'fd.total_ttc'=>
"Numeric",
'fd.tva'=>
"Numeric",
'fd.total_localtax1'=>
"Numeric",
'fd.total_localtax2'=>
"Numeric",
385 'fd.localtax1_tx'=>
'Numeric',
'fd.localtax2_tx'=>
'Numeric',
'fd.localtax1_type'=>
'Numeric',
'fd.localtax2_type'=>
'Numeric',
386 'fd.date_start'=>
"Date",
'fd.date_end'=>
"Date",
'fd.special_code'=>
"Numeric",
387 'fd.product_type'=>
'Numeric',
'fd.fk_product'=>
'List:product:label', $alias_product_perentity .
'.accountancy_code_buy'=>
'Text',
388 'p.ref'=>
'Text',
'p.label'=>
'Text',
'project.ref'=>
'Text',
'project.title'=>
'Text',
389 'f.multicurrency_code' =>
'Text',
390 'f.multicurrency_tx' =>
'Number',
'f.multicurrency_total_ht' =>
'Number',
'f.multicurrency_total_tva' =>
'Number',
'f.multicurrency_total_ttc' =>
'Number'
392 $this->export_entities_array[$r] = array(
393 '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',
394 '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",
395 'f.ref'=>
"invoice",
'f.ref_supplier'=>
"invoice",
'f.datec'=>
"invoice",
'f.datef'=>
"invoice",
'f.date_lim_reglement'=>
'invoice',
396 'f.fk_cond_reglement'=>
'invoice',
'f.fk_mode_reglement'=>
'invoice',
397 'f.total_ht'=>
"invoice",
'f.total_ttc'=>
"invoice",
'f.total_tva'=>
"invoice",
398 'f.paye'=>
"invoice",
'f.fk_statut'=>
'invoice',
'f.note_public'=>
"invoice",
'fd.rowid'=>
'invoice_line',
'fd.description'=>
"invoice_line",
'fd.qty'=>
"invoice_line",
399 'fd.total_ht'=>
"invoice_line",
'fd.tva'=>
"invoice_line",
'fd.total_ttc'=>
"invoice_line",
'fd.total_localtax1'=>
"invoice_line",
'fd.total_localtax2'=>
"invoice_line",
400 '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",
401 'fd.remise_percent'=>
"invoice_line",
402 'fd.date_start'=>
"invoice_line",
'fd.date_end'=>
"invoice_line",
'fd.special_code'=>
"invoice_line",
403 'fd.product_type'=>
'invoice_line',
'fd.fk_product'=>
'product',
404 'p.ref'=>
'product',
'p.label'=>
'product', $alias_product_perentity.
'.accountancy_code_buy'=>
'product',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project'
406 $this->export_dependencies_array[$r] = array(
'invoice_line'=>
'fd.rowid',
'product'=>
'fd.rowid');
408 $keyforselect =
'facture_fourn';
409 $keyforelement =
'invoice';
410 $keyforaliasextra =
'extra';
411 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
412 $keyforselect =
'facture_fourn_det';
413 $keyforelement =
'invoice_line';
414 $keyforaliasextra =
'extraline';
415 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
417 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
418 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
419 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON ps.rowid = s.parent';
420 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
421 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
423 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
424 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture_fourn as f';
425 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
426 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
427 $this->export_sql_end[$r] .=
' , '.MAIN_DB_PREFIX.
'facture_fourn_det as fd';
428 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
429 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
430 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
431 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_invoice').
')';
432 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
433 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.((int) $user->id);
438 $this->export_code[$r] = $this->rights_class.
'_'.$r;
439 $this->export_label[$r] =
'Factures fournisseurs et reglements';
440 $this->export_icon[$r] =
'invoice';
441 $this->export_permission[$r] = array(array(
"fournisseur",
"facture",
"export"));
442 $this->export_fields_array[$r] = array(
443 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
444 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
445 's.code_compta'=>
'CustomerAccountancyCode',
's.code_compta_fournisseur'=>
'SupplierAccountancyCode',
's.tva_intra'=>
'VATIntra',
446 'f.rowid'=>
"InvoiceId",
'f.ref'=>
"InvoiceRef",
'f.ref_supplier'=>
"RefSupplier",
'f.datec'=>
"InvoiceDateCreation",
'f.datef'=>
"DateInvoice",
'f.date_lim_reglement'=>
"DateMaxPayment",
447 'f.fk_cond_reglement'=>
'IdPaymentTerm',
'f.fk_mode_reglement'=>
'IdPaymentMode',
448 'f.total_ht'=>
"TotalHT",
'f.total_ttc'=>
"TotalTTC",
'f.total_tva'=>
"TotalVAT",
449 'f.localtax1'=>
"TotalLT1",
'f.localtax2'=>
"TotalLT2",
450 'f.paye'=>
"InvoicePaid",
451 'f.fk_statut'=>
'InvoiceStatus',
'f.note_public'=>
"InvoiceNote",
'p.rowid'=>
'PaymentId',
'pf.amount'=>
'AmountPayment',
452 'p.datep'=>
'DatePayment',
'p.num_paiement'=>
'PaymentNumber',
'p.fk_bank'=>
'IdTransaction',
'project.rowid'=>
'ProjectId',
'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
454 if (!$uselocaltax1) {
455 unset($this->export_fields_array[$r][
'f.localtax1']);
457 if (!$uselocaltax2) {
458 unset($this->export_fields_array[$r][
'f.localtax2']);
460 if (isModEnabled(
"multicurrency")) {
461 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
462 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
463 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
464 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
465 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
473 $this->export_TypeFields_array[$r] = array(
474 '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',
475 's.idprof4'=>
'Text',
's.idprof5'=>
'Text',
's.idprof6'=>
'Text',
's.code_compta'=>
'Text',
's.code_compta_fournisseur'=>
'Text',
's.tva_intra'=>
'Text',
476 'f.rowid'=>
'Numeric',
'f.ref'=>
"Text",
'f.ref_supplier'=>
"Text",
477 'f.datec'=>
"Date",
'f.datef'=>
"Date",
'f.date_lim_reglement'=>
'Date',
478 'f.fk_cond_reglement'=>
'Numeric',
'f.fk_mode_reglement'=>
'Numeric',
479 'f.total_ht'=>
"Numeric",
'f.total_ttc'=>
"Numeric",
'f.total_tva'=>
"Numeric",
'f.localtax1'=>
"Numeric",
'f.localtax2'=>
"Numeric",
480 'f.paye'=>
"Boolean",
'f.fk_statut'=>
'Status',
'f.note_public'=>
"Text",
'pf.amount'=>
'Numeric',
481 'p.rowid'=>
'Numeric',
'p.datep'=>
'Date',
'p.num_paiement'=>
'Numeric',
'p.fk_bank'=>
'Numeric',
'project.rowid'=>
'Numeric',
'project.ref'=>
'Text',
'project.title'=>
'Text',
482 'f.multicurrency_code' =>
'Text',
483 'f.multicurrency_tx' =>
'Number',
'f.multicurrency_total_ht' =>
'Number',
'f.multicurrency_total_tva' =>
'Number',
'f.multicurrency_total_ttc' =>
'Number'
485 $this->export_entities_array[$r] = array(
486 's.rowid'=>
"company",
's.nom'=>
'company',
's.address'=>
'company',
's.zip'=>
'company',
's.town'=>
'company',
'c.code'=>
'company',
's.phone'=>
'company',
487 's.siren'=>
'company',
's.siret'=>
'company',
's.ape'=>
'company',
's.idprof4'=>
'company',
's.idprof5'=>
'company',
's.idprof6'=>
'company',
488 's.code_compta'=>
'company',
's.code_compta_fournisseur'=>
'company',
's.tva_intra'=>
'company',
489 'f.rowid'=>
"invoice",
'f.ref'=>
"invoice",
'f.ref_supplier'=>
"invoice",
'f.datec'=>
"invoice",
'f.datef'=>
"invoice",
'f.date_lim_reglement'=>
'invoice',
490 'f.fk_cond_reglement'=>
'invoice',
'f.fk_mode_reglement'=>
'invoice',
491 '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',
492 'p.datep'=>
'payment',
'p.num_paiement'=>
'payment',
'p.fk_bank'=>
'account',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project');
493 $this->export_dependencies_array[$r] = array(
'payment'=>
'p.rowid');
495 $keyforselect =
'facture_fourn';
496 $keyforelement =
'invoice';
497 $keyforaliasextra =
'extra';
498 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
500 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
501 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
502 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
503 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
505 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
506 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture_fourn as f';
507 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
508 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
509 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
510 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
511 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid';
512 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_invoice').
')';
513 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
514 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.((int) $user->id);
519 $this->export_code[$r] = $this->rights_class.
'_'.$r;
520 $this->export_label[$r] =
'Purchase Orders and lines of purchase orders';
521 $this->export_icon[$r] =
'order';
522 $this->export_permission[$r] = array(array(
"fournisseur",
"commande",
"export"));
523 $this->export_fields_array[$r] = array(
524 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
'ps.nom'=>
'ParentCompany',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
525 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
's.tva_intra'=>
'VATIntra',
526 'f.rowid'=>
"OrderId",
'f.ref'=>
"Ref",
'f.ref_supplier'=>
"RefSupplier",
'f.date_creation'=>
"DateCreation",
'f.date_commande'=>
"OrderDate",
'f.date_livraison'=>
"DateDeliveryPlanned",
527 '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',
528 'f.note_public'=>
"NotePublic",
'f.note_private'=>
"NotePrivate",
'uv.login'=>
'UserValidation',
'ua1.login'=>
'ApprovedBy',
'ua2.login'=>
'ApprovedBy2',
'fd.rowid'=>
'LineId',
'fd.description'=>
"LineDescription",
529 'fd.tva_tx'=>
"LineVATRate",
'fd.qty'=>
"LineQty",
'fd.remise_percent'=>
"Discount",
'fd.total_ht'=>
"LineTotalHT",
'fd.total_ttc'=>
"LineTotalTTC",
530 'fd.total_tva'=>
"LineTotalVAT",
'fd.date_start'=>
"DateStart",
'fd.date_end'=>
"DateEnd",
'fd.special_code'=>
'SpecialCode',
531 'fd.product_type'=>
'TypeOfLineServiceOrProduct',
'fd.ref'=>
'SupplierRef',
'fd.fk_product'=>
'ProductId',
532 'p.ref'=>
'ProductRef',
'p.label'=>
'ProductLabel',
'project.rowid'=>
'ProjectId',
'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
534 if (isModEnabled(
"multicurrency")) {
535 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
536 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
537 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
538 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
539 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
542 unset($this->export_fields_array[
'f.date_approve2']);
543 unset($this->export_fields_array[
'ua2.login']);
545 $this->export_TypeFields_array[$r] = array(
546 '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',
547 '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",
548 'f.date_creation'=>
"Date",
'f.date_commande'=>
"Date",
'f.date_livraison'=>
"Date",
'f.total_ht'=>
"Numeric",
'f.total_ttc'=>
"Numeric",
'f.total_tva'=>
"Numeric",
549 '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",
550 'fd.tva_tx'=>
"Numeric",
'fd.qty'=>
"Numeric",
'fd.remise_percent'=>
"Numeric",
'fd.total_ht'=>
"Numeric",
'fd.total_ttc'=>
"Numeric",
'fd.total_tva'=>
"Numeric",
551 'fd.date_start'=>
"Date",
'fd.date_end'=>
"Date",
'fd.special_code'=>
"Numeric",
552 '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'
554 $this->export_entities_array[$r] = array(
555 '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',
556 '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',
557 '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",
558 '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",
559 'fd.product_type'=>
'order_line',
'fd.ref'=>
'order_line',
'fd.fk_product'=>
'product',
560 'p.ref'=>
'product',
'p.label'=>
'product',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project'
562 $this->export_dependencies_array[$r] = array(
'order_line'=>
'fd.rowid',
'product'=>
'fd.rowid');
564 $keyforselect =
'commande_fournisseur';
565 $keyforelement =
'order';
566 $keyforaliasextra =
'extra';
567 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
570 $keyforselect =
'commande_fournisseurdet';
571 $keyforelement =
'order_line';
572 $keyforaliasextra =
'extraline';
573 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
575 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
576 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
577 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON ps.rowid = s.parent';
578 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
579 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
581 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
582 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'commande_fournisseur as f';
583 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
584 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uv ON uv.rowid = f.fk_user_valid';
585 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as ua1 ON ua1.rowid = f.fk_user_approve';
586 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as ua2 ON ua2.rowid = f.fk_user_approve2';
587 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
588 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'commande_fournisseurdet as fd';
589 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
590 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
591 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
592 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_order').
')';
593 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
594 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.((int) $user->id);
602 $this->import_code[$r] = $this->rights_class.
'_'.$r;
603 $this->import_label[$r] =
"SupplierInvoices";
604 $this->import_icon[$r] = $this->picto;
605 $this->import_entities_array[$r] = array();
606 $this->import_tables_array[$r] = array(
'f' => MAIN_DB_PREFIX.
'facture_fourn',
'extra' => MAIN_DB_PREFIX.
'facture_fourn_extrafields');
607 $this->import_tables_creator_array[$r] = array(
'f' =>
'fk_user_author');
608 $this->import_fields_array[$r] = array(
609 'f.ref' =>
'InvoiceRef*',
610 'f.ref_supplier' =>
'RefSupplier',
612 'f.fk_soc' =>
'Supplier/Vendor*',
613 'f.datec' =>
'InvoiceDateCreation',
614 'f.datef' =>
'DateInvoice',
615 'f.date_lim_reglement' =>
'DateMaxPayment',
616 'f.total_ht' =>
'TotalHT',
617 'f.total_ttc' =>
'TotalTTC',
618 'f.total_tva' =>
'TotalVAT',
619 'f.paye' =>
'InvoicePaid',
620 'f.fk_statut' =>
'InvoiceStatus',
621 'f.fk_user_modif' =>
'Modifier Id',
622 'f.fk_user_valid' =>
'Validator Id',
623 'f.fk_facture_source' =>
'Invoice Source Id',
624 'f.fk_projet' =>
'Project Id',
625 'f.fk_account' =>
'Bank Account*',
626 'f.note_public' =>
'InvoiceNote',
627 'f.note_private' =>
'NotePrivate',
628 'f.fk_cond_reglement' =>
'PaymentTerm',
629 'f.fk_mode_reglement' =>
'PaymentMode',
630 'f.model_pdf' =>
'Model',
631 'f.date_valid' =>
'DateValidation'
633 if (isModEnabled(
"multicurrency")) {
634 $this->import_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
635 $this->import_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
636 $this->import_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
637 $this->import_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
638 $this->import_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
641 $import_extrafield_sample = array();
642 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.
")";
643 $resql = $this->db->query($sql);
645 while ($obj = $this->db->fetch_object($resql)) {
646 $fieldname =
'extra.'.$obj->name;
647 $fieldlabel = ucfirst($obj->label);
648 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
649 $import_extrafield_sample[$fieldname] = $fieldlabel;
653 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facture_fourn');
654 if (empty($conf->multicurrency->enabled)) {
655 $this->import_fieldshidden_array[$r][
'f.multicurrency_code'] =
'const-'.$conf->currency;
657 $this->import_regex_array[$r] = array(
'f.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency');
658 $import_sample = array(
659 'f.ref' =>
'(PROV001)',
660 'f.ref_supplier' =>
'Supplier1',
662 'f.fk_soc' =>
'Vendor1',
663 'f.datec' =>
'2021-01-01',
665 'f.date_lim_reglement' =>
'2021-01-30',
666 'f.total_ht' =>
'1000',
667 'f.total_ttc' =>
'1000',
668 'f.total_tva' =>
'0',
670 'f.fk_statut' =>
'0',
671 'f.fk_user_modif' =>
'',
672 'f.fk_user_valid' =>
'',
673 'f.fk_facture_source' =>
'',
675 'f.fk_account' =>
'BANK1',
676 'f.note_public' =>
'Note: ',
677 'f.note_private' =>
'',
678 'f.fk_cond_reglement' =>
'1',
679 'f.fk_mode_reglement' =>
'2',
680 'f.model_pdf' =>
'crab',
681 'f.date_valid' =>
'',
682 'f.multicurrency_code' =>
'USD',
683 'f.multicurrency_tx' =>
'1',
684 'f.multicurrency_total_ht' =>
'1000',
685 'f.multicurrency_total_tva' =>
'0',
686 'f.multicurrency_total_ttc' =>
'1000'
688 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
689 $this->import_updatekeys_array[$r] = array(
'f.ref' =>
'Ref');
690 $this->import_convertvalue_array[$r] = array(
692 'rule'=>
'getrefifauto',
693 'class'=>(!
getDolGlobalString(
'INVOICE_SUPPLIER_ADDON_NUMBER') ?
'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER),
694 'path'=>
"/core/modules/supplier_invoice/".(!
getDolGlobalString(
'INVOICE_SUPPLIER_ADDON_NUMBER') ?
'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER).
'.php',
695 'classobject'=>
'FactureFournisseur',
696 'pathobject'=>
'/fourn/class/fournisseur.facture.class.php',
698 'f.fk_soc' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/societe/class/societe.class.php',
'class' =>
'Societe',
'method' =>
'fetch',
'element' =>
'ThirdParty'),
699 'f.fk_account' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/compta/bank/class/account.class.php',
'class' =>
'Account',
'method' =>
'fetch',
'element' =>
'bank_account'),
704 $this->import_code[$r] = $this->rights_class.
'_'.$r;
705 $this->import_label[$r] =
"SupplierInvoiceLines";
706 $this->import_icon[$r] = $this->picto;
707 $this->import_entities_array[$r] = array();
708 $this->import_tables_array[$r] = array(
'fd' => MAIN_DB_PREFIX.
'facture_fourn_det',
'extra' => MAIN_DB_PREFIX.
'facture_fourn_det_extrafields');
709 $this->import_fields_array[$r] = array(
710 'fd.fk_facture_fourn' =>
'InvoiceRef*',
711 'fd.fk_parent_line' =>
'ParentLine',
712 'fd.fk_product' =>
'IdProduct',
713 'fd.description' =>
'LineDescription',
714 'fd.pu_ht' =>
'PriceUHT',
715 'fd.pu_ttc' =>
'PriceUTTC',
716 'fd.qty' =>
'LineQty',
717 'fd.remise_percent' =>
'Reduc.',
718 'fd.vat_src_code' =>
'Vat Source Code',
719 'fd.product_type' =>
'TypeOfLineServiceOrProduct',
720 'fd.tva_tx' =>
'LineVATRate',
721 'fd.total_ht' =>
'LineTotalHT',
722 'fd.tva' =>
'LineTotalVAT',
723 'fd.total_ttc' =>
'LineTotalTTC',
724 'fd.date_start' =>
'Start Date',
725 'fd.date_end' =>
'End Date',
726 'fd.fk_unit' =>
'Unit'
728 if (isModEnabled(
"multicurrency")) {
729 $this->import_fields_array[$r][
'fd.multicurrency_code'] =
'Currency';
730 $this->import_fields_array[$r][
'fd.multicurrency_subprice'] =
'CurrencyRate';
731 $this->import_fields_array[$r][
'fd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
732 $this->import_fields_array[$r][
'fd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
733 $this->import_fields_array[$r][
'fd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
736 $import_extrafield_sample = array();
737 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.
")";
738 $resql = $this->db->query($sql);
740 while ($obj = $this->db->fetch_object($resql)) {
741 $fieldname =
'extra.'.$obj->name;
742 $fieldlabel = ucfirst($obj->label);
743 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
744 $import_extrafield_sample[$fieldname] = $fieldlabel;
748 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facture_fourn_det');
749 $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');
750 $import_sample = array(
751 'fd.fk_facture_fourn' =>
'(PROV001)',
752 'fd.fk_parent_line' =>
'',
753 'fd.fk_product' =>
'',
754 'fd.description' =>
'Test Product',
755 'fd.pu_ht' =>
'50000',
756 'fd.pu_ttc' =>
'50000',
758 'fd.remise_percent' =>
'0',
759 'fd.vat_src_code' =>
'',
760 'fd.product_type' =>
'0',
762 'fd.total_ht' =>
'50000',
764 'fd.total_ttc' =>
'50000',
765 'fd.date_start' =>
'',
768 'fd.multicurrency_code' =>
'USD',
769 'fd.multicurrency_tx' =>
'0',
770 'fd.multicurrency_total_ht' =>
'50000',
771 'fd.multicurrency_total_tva' =>
'0',
772 'fd.multicurrency_total_ttc' =>
'50000'
774 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
775 $this->import_updatekeys_array[$r] = array(
'fd.rowid' =>
'Row Id',
'fd.fk_facture_fourn' =>
'Invoice Id',
'fd.fk_product' =>
'Product Id');
776 $this->import_convertvalue_array[$r] = array(
777 'fd.fk_facture_fourn' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/fourn/class/fournisseur.facture.class.php',
'class' =>
'FactureFournisseur',
'method' =>
'fetch'),
782 $this->import_code[$r] =
'commande_fournisseur_'.$r;
783 $this->import_label[$r] =
'SuppliersOrders';
784 $this->import_icon[$r] = $this->picto;
785 $this->import_entities_array[$r] = array();
786 $this->import_tables_array[$r] = array(
'c' => MAIN_DB_PREFIX.
'commande_fournisseur',
'extra' => MAIN_DB_PREFIX.
'commande_fournisseur_extrafields');
787 $this->import_tables_creator_array[$r] = array(
'c' =>
'fk_user_author');
788 $this->import_fields_array[$r] = array(
790 'c.ref_supplier' =>
'RefSupplier',
791 'c.fk_soc' =>
'ThirdPartyName*',
792 'c.fk_projet' =>
'ProjectId',
793 'c.date_creation' =>
'DateCreation',
794 'c.date_valid' =>
'DateValid',
795 'c.date_approve' =>
'DateApprove',
796 'c.date_commande' =>
'DateOrder',
797 'c.fk_user_modif' =>
'ModifiedById',
798 'c.fk_user_valid' =>
'ValidatedById',
799 'c.fk_user_approve' =>
'ApprovedById',
800 'c.source' =>
'Source',
801 'c.fk_statut' =>
'Status*',
802 'c.billed' =>
'Billed(0/1)',
803 'c.total_tva' =>
'TotalTVA',
804 'c.total_ht' =>
'TotalHT',
805 'c.total_ttc' =>
'TotalTTC',
806 'c.note_private' =>
'NotePrivate',
807 'c.note_public' =>
'Note',
808 'c.date_livraison' =>
'DeliveryDate',
809 'c.fk_cond_reglement' =>
'Payment Condition',
810 'c.fk_mode_reglement' =>
'Payment Mode',
811 'c.model_pdf' =>
'Model'
814 if (isModEnabled(
"multicurrency")) {
815 $this->import_fields_array[$r][
'c.multicurrency_code'] =
'Currency';
816 $this->import_fields_array[$r][
'c.multicurrency_tx'] =
'CurrencyRate';
817 $this->import_fields_array[$r][
'c.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
818 $this->import_fields_array[$r][
'c.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
819 $this->import_fields_array[$r][
'c.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
823 $import_extrafield_sample = array();
824 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.
")";
825 $resql = $this->db->query($sql);
828 while ($obj = $this->db->fetch_object($resql)) {
829 $fieldname =
'extra.'.$obj->name;
830 $fieldlabel = ucfirst($obj->label);
831 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
832 $import_extrafield_sample[$fieldname] = $fieldlabel;
837 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'commande_fournisseur');
838 $this->import_regex_array[$r] = array(
839 'c.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'
842 $this->import_updatekeys_array[$r] = array(
'c.ref' =>
'Ref');
843 $this->import_convertvalue_array[$r] = array(
845 'rule'=>
'getrefifauto',
846 'class'=>(!
getDolGlobalString(
'COMMANDE_SUPPLIER_ADDON_NUMBER') ?
'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER),
847 'path'=>
"/core/modules/supplier_order/".(!
getDolGlobalString(
'COMMANDE_SUPPLIER_ADDON_NUMBER') ?
'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER).
'.php',
848 'classobject'=>
'CommandeFournisseur',
849 'pathobject'=>
'/fourn/class/fournisseur.commande.class.php',
852 'rule' =>
'fetchidfromref',
853 'file' =>
'/societe/class/societe.class.php',
854 'class' =>
'Societe',
856 'element' =>
'ThirdParty'
858 'c.fk_mode_reglement' => array(
859 'rule' =>
'fetchidfromcodeorlabel',
860 'file' =>
'/compta/paiement/class/cpaiement.class.php',
861 'class' =>
'Cpaiement',
863 'element' =>
'cpayment'
865 'c.source' => array(
'rule' =>
'zeroifnull'),
870 $this->import_code[$r] =
'commande_fournisseurdet_'.$r;
871 $this->import_label[$r] =
'PurchaseOrderLines';
872 $this->import_icon[$r] = $this->picto;
873 $this->import_entities_array[$r] = array();
874 $this->import_tables_array[$r] = array(
'cd' => MAIN_DB_PREFIX.
'commande_fournisseurdet',
'extra' => MAIN_DB_PREFIX.
'commande_fournisseurdet_extrafields');
875 $this->import_fields_array[$r] = array(
876 'cd.fk_commande' =>
'PurchaseOrder*',
877 'cd.fk_parent_line' =>
'ParentLine',
878 'cd.fk_product' =>
'IdProduct',
879 'cd.ref' =>
'SupplierRef',
880 'cd.description' =>
'LineDescription',
881 'cd.tva_tx' =>
'LineVATRate',
882 'cd.qty' =>
'LineQty',
883 'cd.remise_percent' =>
'Reduc. Percent',
884 'cd.subprice' =>
'Sub Price',
885 'cd.total_ht' =>
'LineTotalHT',
886 'cd.total_tva' =>
'LineTotalVAT',
887 'cd.total_ttc' =>
'LineTotalTTC',
888 'cd.product_type' =>
'TypeOfLineServiceOrProduct',
889 'cd.date_start' =>
'Start Date',
890 'cd.date_end' =>
'End Date',
891 'cd.info_bits' =>
'InfoBits',
892 'cd.special_code' =>
'Special Code',
893 'cd.rang' =>
'LinePosition',
894 'cd.fk_unit' =>
'Unit'
897 if (isModEnabled(
"multicurrency")) {
898 $this->import_fields_array[$r][
'cd.multicurrency_code'] =
'Currency';
899 $this->import_fields_array[$r][
'cd.multicurrency_subprice'] =
'CurrencyRate';
900 $this->import_fields_array[$r][
'cd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
901 $this->import_fields_array[$r][
'cd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
902 $this->import_fields_array[$r][
'cd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
906 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.
")";
907 $resql = $this->db->query($sql);
909 while ($obj = $this->db->fetch_object($resql)) {
910 $fieldname =
'extra.'.$obj->name;
911 $fieldlabel = ucfirst($obj->label);
912 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
917 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'commande_fournisseurdet');
918 $this->import_regex_array[$r] = array(
919 'cd.product_type' =>
'[0|1]$',
920 'cd.fk_product' =>
'rowid@'.MAIN_DB_PREFIX.
'product',
921 'cd.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'
923 $this->import_updatekeys_array[$r] = array(
'cd.fk_commande' =>
'Purchase Order Id');
924 $this->import_convertvalue_array[$r] = array(
925 'cd.fk_commande' => array(
926 'rule' =>
'fetchidfromref',
927 'file' =>
'/fourn/class/fournisseur.commande.class.php',
928 'class' =>
'CommandeFournisseur',
930 'element' =>
'order_supplier'
932 'cd.info_bits' => array(
'rule' =>
'zeroifnull'),
933 'cd.special_code' => array(
'rule' =>
'zeroifnull'),