31 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
46 global $conf, $langs, $user;
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';
238 if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) {
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';
314 $langs->loadLangs(array(
"suppliers",
"multicurrency"));
317 $this->export_code[$r] = $this->rights_class.
'_'.$r;
318 $this->export_label[$r] =
'Vendor invoices and lines of invoices';
319 $this->export_icon[$r] =
'invoice';
320 $this->export_permission[$r] = array(array(
"fournisseur",
"facture",
"export"));
321 $this->export_fields_array[$r] = array(
322 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
'ps.nom'=>
'ParentCompany',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
323 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
324 's.code_compta'=>
'CustomerAccountancyCode',
's.code_compta_fournisseur'=>
'SupplierAccountancyCode',
's.tva_intra'=>
'VATIntra',
325 'f.rowid'=>
"InvoiceId",
'f.ref'=>
"InvoiceRef",
'f.ref_supplier'=>
"RefSupplier",
'f.datec'=>
"InvoiceDateCreation",
'f.datef'=>
"DateInvoice",
'f.date_lim_reglement'=>
'DateMaxPayment',
326 'f.total_ht'=>
"TotalHT",
'f.total_ttc'=>
"TotalTTC",
'f.total_tva'=>
"TotalVAT",
'f.paye'=>
"InvoicePaid",
'f.fk_statut'=>
'InvoiceStatus',
'f.note_public'=>
"InvoiceNote",
327 'fd.rowid'=>
'LineId',
'fd.description'=>
"LineDescription",
'fd.tva_tx'=>
"LineVATRate",
'fd.qty'=>
"LineQty",
'fd.remise_percent'=>
"Discount",
'fd.total_ht'=>
"LineTotalHT",
328 'fd.total_ttc'=>
"LineTotalTTC",
'fd.tva'=>
"LineTotalVAT",
'fd.date_start'=>
"DateStart",
'fd.date_end'=>
"DateEnd",
'fd.special_code'=>
'SpecialCode',
329 'fd.product_type'=>
'TypeOfLineServiceOrProduct',
'fd.fk_product'=>
'ProductId',
330 'p.ref'=>
'ProductRef',
'p.label'=>
'ProductLabel',
'p.accountancy_code_buy'=>
'ProductAccountancyBuyCode',
'project.rowid'=>
'ProjectId',
331 'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
334 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
335 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
336 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
337 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
338 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
346 $this->export_TypeFields_array[$r] = array(
347 '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',
348 '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',
349 '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",
350 '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",
351 'fd.product_type'=>
'Numeric',
'fd.fk_product'=>
'List:product:label',
352 'p.ref'=>
'Text',
'p.label'=>
'Text',
'project.ref'=>
'Text',
'project.title'=>
'Text'
354 $this->export_entities_array[$r] = array(
355 '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',
356 '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",
357 '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",
358 '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",
359 '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",
360 'fd.product_type'=>
'invoice_line',
'fd.fk_product'=>
'product',
361 'p.ref'=>
'product',
'p.label'=>
'product',
'p.accountancy_code_buy'=>
'product',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project'
363 $this->export_dependencies_array[$r] = array(
'invoice_line'=>
'fd.rowid',
'product'=>
'fd.rowid');
365 $keyforselect =
'facture_fourn';
366 $keyforelement =
'invoice';
367 $keyforaliasextra =
'extra';
368 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
369 $keyforselect =
'facture_fourn_det';
370 $keyforelement =
'invoice_line';
371 $keyforaliasextra =
'extraline';
372 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
374 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
375 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
376 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON ps.rowid = s.parent';
377 if (is_object($user) && empty($user->rights->societe->client->voir)) {
378 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
380 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
381 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture_fourn as f';
382 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
383 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
384 $this->export_sql_end[$r] .=
' , '.MAIN_DB_PREFIX.
'facture_fourn_det as fd';
385 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
386 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
387 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
388 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_invoice').
')';
389 if (is_object($user) && empty($user->rights->societe->client->voir)) {
390 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.((int) $user->id);
394 $this->export_code[$r] = $this->rights_class.
'_'.$r;
395 $this->export_label[$r] =
'Factures fournisseurs et reglements';
396 $this->export_icon[$r] =
'invoice';
397 $this->export_permission[$r] = array(array(
"fournisseur",
"facture",
"export"));
398 $this->export_fields_array[$r] = array(
399 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
400 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
401 's.code_compta'=>
'CustomerAccountancyCode',
's.code_compta_fournisseur'=>
'SupplierAccountancyCode',
's.tva_intra'=>
'VATIntra',
402 'f.rowid'=>
"InvoiceId",
'f.ref'=>
"InvoiceRef",
'f.ref_supplier'=>
"RefSupplier",
'f.datec'=>
"InvoiceDateCreation",
403 'f.datef'=>
"DateInvoice",
'f.total_ht'=>
"TotalHT",
'f.total_ttc'=>
"TotalTTC",
'f.total_tva'=>
"TotalVAT",
'f.paye'=>
"InvoicePaid",
404 'f.fk_statut'=>
'InvoiceStatus',
'f.note_public'=>
"InvoiceNote",
'p.rowid'=>
'PaymentId',
'pf.amount'=>
'AmountPayment',
405 'p.datep'=>
'DatePayment',
'p.num_paiement'=>
'PaymentNumber',
'p.fk_bank'=>
'IdTransaction',
'project.rowid'=>
'ProjectId',
'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
408 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
409 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
410 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
411 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
412 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
420 $this->export_TypeFields_array[$r] = array(
421 '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',
422 '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",
423 'f.total_ttc'=>
"Numeric",
'f.total_tva'=>
"Numeric",
'f.paye'=>
"Boolean",
'f.fk_statut'=>
'Status',
'f.note_public'=>
"Text",
'pf.amount'=>
'Numeric',
424 'p.datep'=>
'Date',
'p.num_paiement'=>
'Numeric',
'p.fk_bank'=>
'Numeric',
'project.ref'=>
'Text',
'project.title'=>
'Text'
426 $this->export_entities_array[$r] = array(
427 's.rowid'=>
"company",
's.nom'=>
'company',
's.address'=>
'company',
's.zip'=>
'company',
's.town'=>
'company',
'c.code'=>
'company',
's.phone'=>
'company',
428 's.siren'=>
'company',
's.siret'=>
'company',
's.ape'=>
'company',
's.idprof4'=>
'company',
's.idprof5'=>
'company',
's.idprof6'=>
'company',
429 's.code_compta'=>
'company',
's.code_compta_fournisseur'=>
'company',
's.tva_intra'=>
'company',
430 'f.rowid'=>
"invoice",
'f.ref'=>
"invoice",
'f.ref_supplier'=>
"invoice",
'f.datec'=>
"invoice",
'f.datef'=>
"invoice",
'f.total_ht'=>
"invoice",
431 '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',
432 'p.datep'=>
'payment',
'p.num_paiement'=>
'payment',
'p.fk_bank'=>
'account',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project');
433 $this->export_dependencies_array[$r] = array(
'payment'=>
'p.rowid');
435 $keyforselect =
'facture_fourn';
436 $keyforelement =
'invoice';
437 $keyforaliasextra =
'extra';
438 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
440 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
441 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
442 if (is_object($user) && empty($user->rights->societe->client->voir)) {
443 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
445 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
446 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture_fourn as f';
447 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
448 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
449 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
450 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
451 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid';
452 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_invoice').
')';
453 if (is_object($user) && empty($user->rights->societe->client->voir)) {
454 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.((int) $user->id);
459 $this->export_code[$r] = $this->rights_class.
'_'.$r;
460 $this->export_label[$r] =
'Purchase Orders and lines of purchase orders';
461 $this->export_icon[$r] =
'order';
462 $this->export_permission[$r] = array(array(
"fournisseur",
"commande",
"export"));
463 $this->export_fields_array[$r] = array(
464 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
'ps.nom'=>
'ParentCompany',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
465 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
's.tva_intra'=>
'VATIntra',
466 'f.rowid'=>
"OrderId",
'f.ref'=>
"Ref",
'f.ref_supplier'=>
"RefSupplier",
'f.date_creation'=>
"DateCreation",
'f.date_commande'=>
"OrderDate",
'f.date_livraison'=>
"DateDeliveryPlanned",
467 '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',
468 'f.note_public'=>
"NotePublic",
'f.note_private'=>
"NotePrivate",
'uv.login'=>
'UserValidation',
'ua1.login'=>
'ApprovedBy',
'ua2.login'=>
'ApprovedBy2',
'fd.rowid'=>
'LineId',
'fd.description'=>
"LineDescription",
469 'fd.tva_tx'=>
"LineVATRate",
'fd.qty'=>
"LineQty",
'fd.remise_percent'=>
"Discount",
'fd.total_ht'=>
"LineTotalHT",
'fd.total_ttc'=>
"LineTotalTTC",
470 'fd.total_tva'=>
"LineTotalVAT",
'fd.date_start'=>
"DateStart",
'fd.date_end'=>
"DateEnd",
'fd.special_code'=>
'SpecialCode',
471 'fd.product_type'=>
'TypeOfLineServiceOrProduct',
'fd.ref'=>
'SupplierRef',
'fd.fk_product'=>
'ProductId',
472 'p.ref'=>
'ProductRef',
'p.label'=>
'ProductLabel',
'project.rowid'=>
'ProjectId',
'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
475 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
476 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
477 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
478 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
479 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
481 if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) {
482 unset($this->export_fields_array[
'f.date_approve2']);
483 unset($this->export_fields_array[
'ua2.login']);
485 $this->export_TypeFields_array[$r] = array(
486 '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',
487 '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",
488 'f.date_creation'=>
"Date",
'f.date_commande'=>
"Date",
'f.date_livraison'=>
"Date",
'f.total_ht'=>
"Numeric",
'f.total_ttc'=>
"Numeric",
'f.total_tva'=>
"Numeric",
489 '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",
490 'fd.tva_tx'=>
"Numeric",
'fd.qty'=>
"Numeric",
'fd.remise_percent'=>
"Numeric",
'fd.total_ht'=>
"Numeric",
'fd.total_ttc'=>
"Numeric",
'fd.total_tva'=>
"Numeric",
491 'fd.date_start'=>
"Date",
'fd.date_end'=>
"Date",
'fd.special_code'=>
"Numeric",
492 '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'
494 $this->export_entities_array[$r] = array(
495 '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',
496 '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',
497 '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",
498 '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",
499 'fd.product_type'=>
'order_line',
'fd.ref'=>
'order_line',
'fd.fk_product'=>
'product',
500 'p.ref'=>
'product',
'p.label'=>
'product',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project'
502 $this->export_dependencies_array[$r] = array(
'order_line'=>
'fd.rowid',
'product'=>
'fd.rowid');
504 $keyforselect =
'commande_fournisseur';
505 $keyforelement =
'order';
506 $keyforaliasextra =
'extra';
507 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
510 $keyforselect =
'commande_fournisseurdet';
511 $keyforelement =
'order_line';
512 $keyforaliasextra =
'extraline';
513 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
515 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
516 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
517 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON ps.rowid = s.parent';
518 if (is_object($user) && empty($user->rights->societe->client->voir)) {
519 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
521 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
522 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'commande_fournisseur as f';
523 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
524 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uv ON uv.rowid = f.fk_user_valid';
525 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as ua1 ON ua1.rowid = f.fk_user_approve';
526 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as ua2 ON ua2.rowid = f.fk_user_approve2';
527 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
528 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'commande_fournisseurdet as fd';
529 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
530 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
531 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
532 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_order').
')';
533 if (is_object($user) && empty($user->rights->societe->client->voir)) {
534 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.((int) $user->id);
542 $this->import_code[$r] = $this->rights_class.
'_'.$r;
543 $this->import_label[$r] =
"SupplierInvoices";
544 $this->import_icon[$r] = $this->picto;
545 $this->import_entities_array[$r] = array();
546 $this->import_tables_array[$r] = array(
'f' => MAIN_DB_PREFIX.
'facture_fourn',
'extra' => MAIN_DB_PREFIX.
'facture_fourn_extrafields');
547 $this->import_tables_creator_array[$r] = array(
'f' =>
'fk_user_author');
548 $this->import_fields_array[$r] = array(
549 'f.ref' =>
'InvoiceRef*',
550 'f.ref_supplier' =>
'RefSupplier',
552 'f.fk_soc' =>
'Supplier/Vendor*',
553 'f.datec' =>
'InvoiceDateCreation',
554 'f.datef' =>
'DateInvoice',
555 'f.date_lim_reglement' =>
'DateMaxPayment',
556 'f.total_ht' =>
'TotalHT',
557 'f.total_ttc' =>
'TotalTTC',
558 'f.total_tva' =>
'TotalVAT',
559 'f.paye' =>
'InvoicePaid',
560 'f.fk_statut' =>
'InvoiceStatus',
561 'f.fk_user_modif' =>
'Modifier Id',
562 'f.fk_user_valid' =>
'Validator Id',
563 'f.fk_facture_source' =>
'Invoice Source Id',
564 'f.fk_projet' =>
'Project Id',
565 'f.fk_account' =>
'Bank Account*',
566 'f.note_public' =>
'InvoiceNote',
567 'f.note_private' =>
'NotePrivate',
568 'f.fk_cond_reglement' =>
'Payment Condition',
569 'f.fk_mode_reglement' =>
'Payment Mode',
570 'f.model_pdf' =>
'Model',
571 'f.date_valid' =>
'Validation Date'
574 $this->import_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
575 $this->import_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
576 $this->import_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
577 $this->import_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
578 $this->import_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
581 $import_extrafield_sample = array();
582 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.
")";
583 $resql = $this->db->query(
$sql);
585 while ($obj = $this->db->fetch_object($resql)) {
586 $fieldname =
'extra.'.$obj->name;
587 $fieldlabel = ucfirst($obj->label);
588 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
589 $import_extrafield_sample[$fieldname] = $fieldlabel;
593 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facture_fourn');
594 if (empty($conf->multicurrency->enabled)) {
595 $this->import_fieldshidden_array[$r][
'f.multicurrency_code'] =
'const-'.$conf->currency;
597 $this->import_regex_array[$r] = array(
'f.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency');
598 $import_sample = array(
599 'f.ref' =>
'(PROV001)',
600 'f.ref_supplier' =>
'Supplier1',
602 'f.fk_soc' =>
'Vendor1',
603 'f.datec' =>
'2021-01-01',
605 'f.date_lim_reglement' =>
'2021-01-30',
606 'f.total_ht' =>
'1000',
607 'f.total_ttc' =>
'1000',
608 'f.total_tva' =>
'0',
610 'f.fk_statut' =>
'0',
611 'f.fk_user_modif' =>
'',
612 'f.fk_user_valid' =>
'',
613 'f.fk_facture_source' =>
'',
615 'f.fk_account' =>
'BANK1',
616 'f.note_public' =>
'Note: ',
617 'f.note_private' =>
'',
618 'f.fk_cond_reglement' =>
'1',
619 'f.fk_mode_reglement' =>
'2',
620 'f.model_pdf' =>
'crab',
621 'f.date_valid' =>
'',
622 'f.multicurrency_code' =>
'USD',
623 'f.multicurrency_tx' =>
'1',
624 'f.multicurrency_total_ht' =>
'1000',
625 'f.multicurrency_total_tva' =>
'0',
626 'f.multicurrency_total_ttc' =>
'1000'
628 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
629 $this->import_updatekeys_array[$r] = array(
'f.ref' =>
'Ref');
630 $this->import_convertvalue_array[$r] = array(
632 'rule'=>
'getrefifauto',
633 'class'=>(empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) ?
'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER),
634 'path'=>
"/core/modules/supplier_invoice/".(empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) ?
'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER).
'.php',
635 'classobject'=>
'FactureFournisseur',
636 'pathobject'=>
'/fourn/class/fournisseur.facture.class.php',
638 'f.fk_soc' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/societe/class/societe.class.php',
'class' =>
'Societe',
'method' =>
'fetch',
'element' =>
'ThirdParty'),
639 'f.fk_account' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/compta/bank/class/account.class.php',
'class' =>
'Account',
'method' =>
'fetch',
'element' =>
'bank_account'),
644 $this->import_code[$r] = $this->rights_class.
'_'.$r;
645 $this->import_label[$r] =
"SupplierInvoiceLines";
646 $this->import_icon[$r] = $this->picto;
647 $this->import_entities_array[$r] = array();
648 $this->import_tables_array[$r] = array(
'fd' => MAIN_DB_PREFIX.
'facture_fourn_det',
'extra' => MAIN_DB_PREFIX.
'facture_fourn_det_extrafields');
649 $this->import_fields_array[$r] = array(
650 'fd.fk_facture_fourn' =>
'InvoiceRef*',
651 'fd.fk_parent_line' =>
'ParentLine',
652 'fd.fk_product' =>
'IdProduct',
653 'fd.description' =>
'LineDescription',
654 'fd.pu_ht' =>
'PriceUHT',
655 'fd.pu_ttc' =>
'PriceUTTC',
656 'fd.qty' =>
'LineQty',
657 'fd.remise_percent' =>
'Reduc.',
658 'fd.vat_src_code' =>
'Vat Source Code',
659 'fd.product_type' =>
'TypeOfLineServiceOrProduct',
660 'fd.tva_tx' =>
'LineVATRate',
661 'fd.total_ht' =>
'LineTotalHT',
662 'fd.tva' =>
'LineTotalVAT',
663 'fd.total_ttc' =>
'LineTotalTTC',
664 'fd.date_start' =>
'Start Date',
665 'fd.date_end' =>
'End Date',
666 'fd.fk_unit' =>
'Unit'
669 $this->import_fields_array[$r][
'fd.multicurrency_code'] =
'Currency';
670 $this->import_fields_array[$r][
'fd.multicurrency_subprice'] =
'CurrencyRate';
671 $this->import_fields_array[$r][
'fd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
672 $this->import_fields_array[$r][
'fd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
673 $this->import_fields_array[$r][
'fd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
676 $import_extrafield_sample = array();
677 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.
")";
678 $resql = $this->db->query(
$sql);
680 while ($obj = $this->db->fetch_object($resql)) {
681 $fieldname =
'extra.'.$obj->name;
682 $fieldlabel = ucfirst($obj->label);
683 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
684 $import_extrafield_sample[$fieldname] = $fieldlabel;
688 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facture_fourn_det');
689 $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');
690 $import_sample = array(
691 'fd.fk_facture_fourn' =>
'(PROV001)',
692 'fd.fk_parent_line' =>
'',
693 'fd.fk_product' =>
'',
694 'fd.description' =>
'Test Product',
695 'fd.pu_ht' =>
'50000',
696 'fd.pu_ttc' =>
'50000',
698 'fd.remise_percent' =>
'0',
699 'fd.vat_src_code' =>
'',
700 'fd.product_type' =>
'0',
702 'fd.total_ht' =>
'50000',
704 'fd.total_ttc' =>
'50000',
705 'fd.date_start' =>
'',
708 'fd.multicurrency_code' =>
'USD',
709 'fd.multicurrency_tx' =>
'0',
710 'fd.multicurrency_total_ht' =>
'50000',
711 'fd.multicurrency_total_tva' =>
'0',
712 'fd.multicurrency_total_ttc' =>
'50000'
714 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
715 $this->import_updatekeys_array[$r] = array(
'fd.rowid' =>
'Row Id',
'fd.fk_facture_fourn' =>
'Invoice Id',
'fd.fk_product' =>
'Product Id');
716 $this->import_convertvalue_array[$r] = array(
717 'fd.fk_facture_fourn' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/fourn/class/fournisseur.facture.class.php',
'class' =>
'FactureFournisseur',
'method' =>
'fetch'),
722 $this->import_code[$r] =
'commande_fournisseur_'.$r;
723 $this->import_label[$r] =
'SuppliersOrders';
724 $this->import_icon[$r] = $this->picto;
725 $this->import_entities_array[$r] = array();
726 $this->import_tables_array[$r] = array(
'c' => MAIN_DB_PREFIX.
'commande_fournisseur',
'extra' => MAIN_DB_PREFIX.
'commande_fournisseur_extrafields');
727 $this->import_tables_creator_array[$r] = array(
'c' =>
'fk_user_author');
728 $this->import_fields_array[$r] = array(
730 'c.ref_supplier' =>
'RefSupplier',
731 'c.fk_soc' =>
'ThirdPartyName*',
732 'c.fk_projet' =>
'ProjectId',
733 'c.date_creation' =>
'DateCreation',
734 'c.date_valid' =>
'DateValid',
735 'c.date_approve' =>
'DateApprove',
736 'c.date_commande' =>
'DateOrder',
737 'c.fk_user_modif' =>
'ModifiedById',
738 'c.fk_user_valid' =>
'ValidatedById',
739 'c.fk_user_approve' =>
'ApprovedById',
740 'c.source' =>
'Source',
741 'c.fk_statut' =>
'Status*',
742 'c.billed' =>
'Billed(0/1)',
743 'c.total_tva' =>
'TotalTVA',
744 'c.total_ht' =>
'TotalHT',
745 'c.total_ttc' =>
'TotalTTC',
746 'c.note_private' =>
'NotePrivate',
747 'c.note_public' =>
'Note',
748 'c.date_livraison' =>
'DeliveryDate',
749 'c.fk_cond_reglement' =>
'Payment Condition',
750 'c.fk_mode_reglement' =>
'Payment Mode',
751 'c.model_pdf' =>
'Model'
755 $this->import_fields_array[$r][
'c.multicurrency_code'] =
'Currency';
756 $this->import_fields_array[$r][
'c.multicurrency_tx'] =
'CurrencyRate';
757 $this->import_fields_array[$r][
'c.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
758 $this->import_fields_array[$r][
'c.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
759 $this->import_fields_array[$r][
'c.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
763 $import_extrafield_sample = array();
764 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.
")";
765 $resql = $this->db->query(
$sql);
768 while ($obj = $this->db->fetch_object($resql)) {
769 $fieldname =
'extra.'.$obj->name;
770 $fieldlabel = ucfirst($obj->label);
771 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
772 $import_extrafield_sample[$fieldname] = $fieldlabel;
777 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'commande_fournisseur');
778 $this->import_regex_array[$r] = array(
779 'c.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'
782 $this->import_updatekeys_array[$r] = array(
'c.ref' =>
'Ref');
783 $this->import_convertvalue_array[$r] = array(
785 'rule'=>
'getrefifauto',
786 'class'=>(empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) ?
'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER),
787 'path'=>
"/core/modules/supplier_order/".(empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) ?
'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER).
'.php',
788 'classobject'=>
'CommandeFournisseur',
789 'pathobject'=>
'/fourn/class/fournisseur.commande.class.php',
792 'rule' =>
'fetchidfromref',
793 'file' =>
'/societe/class/societe.class.php',
794 'class' =>
'Societe',
796 'element' =>
'ThirdParty'
798 'c.fk_mode_reglement' => array(
799 'rule' =>
'fetchidfromcodeorlabel',
800 'file' =>
'/compta/paiement/class/cpaiement.class.php',
801 'class' =>
'Cpaiement',
803 'element' =>
'cpayment'
805 'c.source' => array(
'rule' =>
'zeroifnull'),
810 $this->import_code[$r] =
'commande_fournisseurdet_'.$r;
811 $this->import_label[$r] =
'PurchaseOrderLines';
812 $this->import_icon[$r] = $this->picto;
813 $this->import_entities_array[$r] = array();
814 $this->import_tables_array[$r] = array(
'cd' => MAIN_DB_PREFIX.
'commande_fournisseurdet',
'extra' => MAIN_DB_PREFIX.
'commande_fournisseurdet_extrafields');
815 $this->import_fields_array[$r] = array(
816 'cd.fk_commande' =>
'PurchaseOrder*',
817 'cd.fk_parent_line' =>
'ParentLine',
818 'cd.fk_product' =>
'IdProduct',
819 'cd.ref' =>
'SupplierRef',
820 'cd.description' =>
'LineDescription',
821 'cd.tva_tx' =>
'LineVATRate',
822 'cd.qty' =>
'LineQty',
823 'cd.remise_percent' =>
'Reduc. Percent',
824 'cd.subprice' =>
'Sub Price',
825 'cd.total_ht' =>
'LineTotalHT',
826 'cd.total_tva' =>
'LineTotalVAT',
827 'cd.total_ttc' =>
'LineTotalTTC',
828 'cd.product_type' =>
'TypeOfLineServiceOrProduct',
829 'cd.date_start' =>
'Start Date',
830 'cd.date_end' =>
'End Date',
831 'cd.info_bits' =>
'InfoBits',
832 'cd.special_code' =>
'Special Code',
833 'cd.rang' =>
'LinePosition',
834 'cd.fk_unit' =>
'Unit'
838 $this->import_fields_array[$r][
'cd.multicurrency_code'] =
'Currency';
839 $this->import_fields_array[$r][
'cd.multicurrency_subprice'] =
'CurrencyRate';
840 $this->import_fields_array[$r][
'cd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
841 $this->import_fields_array[$r][
'cd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
842 $this->import_fields_array[$r][
'cd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
846 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.
")";
847 $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 ?
'*' :
'');
857 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'commande_fournisseurdet');
858 $this->import_regex_array[$r] = array(
859 'cd.product_type' =>
'[0|1]$',
860 'cd.fk_product' =>
'rowid@'.MAIN_DB_PREFIX.
'product',
861 'cd.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'
863 $this->import_updatekeys_array[$r] = array(
'cd.fk_commande' =>
'Purchase Order Id');
864 $this->import_convertvalue_array[$r] = array(
865 'cd.fk_commande' => array(
866 'rule' =>
'fetchidfromref',
867 'file' =>
'/fourn/class/fournisseur.commande.class.php',
868 'class' =>
'CommandeFournisseur',
870 'element' =>
'order_supplier'
872 'cd.info_bits' => array(
'rule' =>
'zeroifnull'),
873 'cd.special_code' => array(
'rule' =>
'zeroifnull'),
886 public function init($options =
'')
888 global $conf, $langs;
890 $this->
remove($options);
893 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/supplier_orders/template_supplier_order.odt';
894 $dirodt = DOL_DATA_ROOT.
'/doctemplates/supplier_orders';
895 $dest = $dirodt.
'/template_supplier_order.odt';
897 if (file_exists($src) && !file_exists($dest)) {
898 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
900 $result =
dol_copy($src, $dest, 0, 0);
902 $langs->load(
"errors");
903 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
909 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = '".$this->db->escape($this->const[0][2]).
"' AND type = 'order_supplier' AND entity = ".((
int) $conf->entity),
910 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2]).
"', 'order_supplier', ".((
int) $conf->entity).
")",
914 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/supplier_invoices/template_supplier_invoices.odt';
915 $dirodt = DOL_DATA_ROOT.
'/doctemplates/supplier_invoices';
916 $dest = $dirodt.
'/template_supplier_invoices.odt';
918 if (file_exists($src) && !file_exists($dest)) {
919 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
921 $result =
dol_copy($src, $dest, 0, 0);
923 $langs->load(
"errors");
924 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);