29 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
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] =
"muscadet";
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;
114 $this->
const[$r][0] =
"SUPPLIER_ORDER_ADDON_PDF_ODT_PATH";
115 $this->
const[$r][1] =
"chaine";
116 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/supplier_orders";
117 $this->
const[$r][3] =
'';
118 $this->
const[$r][4] = 0;
122 $this->boxes = array(
123 0=>array(
'file'=>
'box_graph_invoices_supplier_permonth.php',
'enabledbydefaulton'=>
'Home'),
124 1=>array(
'file'=>
'box_graph_orders_supplier_permonth.php',
'enabledbydefaulton'=>
'Home'),
125 2=>array(
'file'=>
'box_fournisseurs.php',
'enabledbydefaulton'=>
'Home'),
126 3=>array(
'file'=>
'box_factures_fourn_imp.php',
'enabledbydefaulton'=>
'Home'),
127 4=>array(
'file'=>
'box_factures_fourn.php',
'enabledbydefaulton'=>
'Home'),
128 5=>array(
'file'=>
'box_supplier_orders.php',
'enabledbydefaulton'=>
'Home'),
129 6=>array(
'file'=>
'box_supplier_orders_awaiting_reception.php',
'enabledbydefaulton'=>
'Home'),
133 $datestart =
dol_mktime(23, 0, 0, $arraydate[
'mon'], $arraydate[
'mday'], $arraydate[
'year']);
134 $this->cronjobs = array(
136 'label'=>
'RecurringSupplierInvoicesJob',
138 'class'=>
'fourn/class/fournisseur.facture-rec.class.php',
139 'objectname'=>
'FactureFournisseurRec',
140 'method'=>
'createRecurringInvoices',
142 'comment'=>
'Generate recurring supplier invoices',
144 'unitfrequency'=>3600 * 24,
147 'datestart'=>$datestart
152 $this->rights = array();
153 $this->rights_class =
'fournisseur';
157 $this->rights[$r][0] = 1181;
158 $this->rights[$r][1] =
'Consulter les fournisseurs';
159 $this->rights[$r][2] =
'r';
160 $this->rights[$r][3] = 0;
161 $this->rights[$r][4] =
'lire';
164 $this->rights[$r][0] = 1182;
165 $this->rights[$r][1] =
'Consulter les commandes fournisseur';
166 $this->rights[$r][2] =
'r';
167 $this->rights[$r][3] = 0;
168 $this->rights[$r][4] =
'commande';
169 $this->rights[$r][5] =
'lire';
172 $this->rights[$r][0] = 1183;
173 $this->rights[$r][1] =
'Creer une commande fournisseur';
174 $this->rights[$r][2] =
'w';
175 $this->rights[$r][3] = 0;
176 $this->rights[$r][4] =
'commande';
177 $this->rights[$r][5] =
'creer';
180 $this->rights[$r][0] = 1184;
181 $this->rights[$r][1] =
'Valider une commande fournisseur';
182 $this->rights[$r][2] =
'w';
183 $this->rights[$r][3] = 0;
184 $this->rights[$r][4] =
'supplier_order_advance';
185 $this->rights[$r][5] =
'validate';
188 $this->rights[$r][0] = 1185;
189 $this->rights[$r][1] =
'Approuver une commande fournisseur';
190 $this->rights[$r][2] =
'w';
191 $this->rights[$r][3] = 0;
192 $this->rights[$r][4] =
'commande';
193 $this->rights[$r][5] =
'approuver';
196 $this->rights[$r][0] = 1186;
197 $this->rights[$r][1] =
'Commander une commande fournisseur';
198 $this->rights[$r][2] =
'w';
199 $this->rights[$r][3] = 0;
200 $this->rights[$r][4] =
'commande';
201 $this->rights[$r][5] =
'commander';
204 $this->rights[$r][0] = 1187;
205 $this->rights[$r][1] =
'Receptionner une commande fournisseur';
206 $this->rights[$r][2] =
'd';
207 $this->rights[$r][3] = 0;
208 $this->rights[$r][4] =
'commande';
209 $this->rights[$r][5] =
'receptionner';
212 $this->rights[$r][0] = 1189;
213 $this->rights[$r][1] =
'Check/Uncheck a supplier order reception';
214 $this->rights[$r][2] =
'w';
215 $this->rights[$r][3] = 0;
216 $this->rights[$r][4] =
'commande_advance';
217 $this->rights[$r][5] =
'check';
220 $this->rights[$r][0] = 1188;
221 $this->rights[$r][1] =
'Supprimer une commande fournisseur';
222 $this->rights[$r][2] =
'd';
223 $this->rights[$r][3] = 0;
224 $this->rights[$r][4] =
'commande';
225 $this->rights[$r][5] =
'supprimer';
227 if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) {
229 $this->rights[$r][0] = 1190;
230 $this->rights[$r][1] =
'Approve supplier order (second level)';
231 $this->rights[$r][2] =
'w';
232 $this->rights[$r][3] = 0;
233 $this->rights[$r][4] =
'commande';
234 $this->rights[$r][5] =
'approve2';
238 $this->rights[$r][0] = 1191;
239 $this->rights[$r][1] =
'Exporter les commande fournisseurs, attributs';
240 $this->rights[$r][2] =
'r';
241 $this->rights[$r][3] = 0;
242 $this->rights[$r][4] =
'commande';
243 $this->rights[$r][5] =
'export';
246 $this->rights[$r][0] = 1231;
247 $this->rights[$r][1] =
'Consulter les factures fournisseur';
248 $this->rights[$r][2] =
'r';
249 $this->rights[$r][3] = 0;
250 $this->rights[$r][4] =
'facture';
251 $this->rights[$r][5] =
'lire';
254 $this->rights[$r][0] = 1232;
255 $this->rights[$r][1] =
'Creer une facture fournisseur';
256 $this->rights[$r][2] =
'w';
257 $this->rights[$r][3] = 0;
258 $this->rights[$r][4] =
'facture';
259 $this->rights[$r][5] =
'creer';
262 $this->rights[$r][0] = 1233;
263 $this->rights[$r][1] =
'Valider une facture fournisseur';
264 $this->rights[$r][2] =
'w';
265 $this->rights[$r][3] = 0;
266 $this->rights[$r][4] =
'supplier_invoice_advance';
267 $this->rights[$r][5] =
'validate';
270 $this->rights[$r][0] = 1234;
271 $this->rights[$r][1] =
'Supprimer une facture fournisseur';
272 $this->rights[$r][2] =
'd';
273 $this->rights[$r][3] = 0;
274 $this->rights[$r][4] =
'facture';
275 $this->rights[$r][5] =
'supprimer';
278 $this->rights[$r][0] = 1235;
279 $this->rights[$r][1] =
'Envoyer les factures par mail';
280 $this->rights[$r][2] =
'a';
281 $this->rights[$r][3] = 0;
282 $this->rights[$r][4] =
'supplier_invoice_advance';
283 $this->rights[$r][5] =
'send';
286 $this->rights[$r][0] = 1236;
287 $this->rights[$r][1] =
'Exporter les factures fournisseurs, attributs et reglements';
288 $this->rights[$r][2] =
'r';
289 $this->rights[$r][3] = 0;
290 $this->rights[$r][4] =
'facture';
291 $this->rights[$r][5] =
'export';
304 $this->export_code[$r] = $this->rights_class.
'_'.$r;
305 $this->export_label[$r] =
'Vendor invoices and lines of invoices';
306 $this->export_icon[$r] =
'invoice';
307 $this->export_permission[$r] = array(array(
"fournisseur",
"facture",
"export"));
308 $this->export_fields_array[$r] = array(
309 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
'ps.nom'=>
'ParentCompany',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
310 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
311 's.code_compta'=>
'CustomerAccountancyCode',
's.code_compta_fournisseur'=>
'SupplierAccountancyCode',
's.tva_intra'=>
'VATIntra',
312 'f.rowid'=>
"InvoiceId",
'f.ref'=>
"InvoiceRef",
'f.ref_supplier'=>
"RefSupplier",
'f.datec'=>
"InvoiceDateCreation",
'f.datef'=>
"DateInvoice",
'f.date_lim_reglement'=>
'DateMaxPayment',
313 'f.total_ht'=>
"TotalHT",
'f.total_ttc'=>
"TotalTTC",
'f.total_tva'=>
"TotalVAT",
'f.paye'=>
"InvoicePaid",
'f.fk_statut'=>
'InvoiceStatus',
'f.note_public'=>
"InvoiceNote",
314 'fd.rowid'=>
'LineId',
'fd.description'=>
"LineDescription",
'fd.tva_tx'=>
"LineVATRate",
'fd.qty'=>
"LineQty",
'fd.remise_percent'=>
"Discount",
'fd.total_ht'=>
"LineTotalHT",
315 'fd.total_ttc'=>
"LineTotalTTC",
'fd.tva'=>
"LineTotalVAT",
'fd.date_start'=>
"DateStart",
'fd.date_end'=>
"DateEnd",
'fd.special_code'=>
'SpecialCode',
316 'fd.product_type'=>
'TypeOfLineServiceOrProduct',
'fd.fk_product'=>
'ProductId',
317 'p.ref'=>
'ProductRef',
'p.label'=>
'ProductLabel',
'p.accountancy_code_buy'=>
'ProductAccountancyBuyCode',
'project.rowid'=>
'ProjectId',
318 'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
320 if (!empty($conf->multicurrency->enabled)) {
321 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
322 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
323 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
324 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
325 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
333 $this->export_TypeFields_array[$r] = array(
334 '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',
335 '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',
336 '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",
337 '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",
338 'fd.product_type'=>
'Numeric',
'fd.fk_product'=>
'List:product:label',
339 'p.ref'=>
'Text',
'p.label'=>
'Text',
'project.ref'=>
'Text',
'project.title'=>
'Text'
341 $this->export_entities_array[$r] = array(
342 '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',
343 '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",
344 '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",
345 '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",
346 '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",
347 'fd.product_type'=>
'invoice_line',
'fd.fk_product'=>
'product',
348 'p.ref'=>
'product',
'p.label'=>
'product',
'p.accountancy_code_buy'=>
'product',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project'
350 $this->export_dependencies_array[$r] = array(
'invoice_line'=>
'fd.rowid',
'product'=>
'fd.rowid');
352 $keyforselect =
'facture_fourn';
353 $keyforelement =
'invoice';
354 $keyforaliasextra =
'extra';
355 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
356 $keyforselect =
'facture_fourn_det';
357 $keyforelement =
'invoice_line';
358 $keyforaliasextra =
'extraline';
359 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
361 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
362 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
363 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON ps.rowid = s.parent';
364 if (is_object($user) && empty($user->rights->societe->client->voir)) {
365 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
367 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
368 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture_fourn as f';
369 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
370 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
371 $this->export_sql_end[$r] .=
' , '.MAIN_DB_PREFIX.
'facture_fourn_det as fd';
372 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
373 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
374 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
375 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_invoice').
')';
376 if (is_object($user) && empty($user->rights->societe->client->voir)) {
377 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.((int) $user->id);
381 $this->export_code[$r] = $this->rights_class.
'_'.$r;
382 $this->export_label[$r] =
'Factures fournisseurs et reglements';
383 $this->export_icon[$r] =
'invoice';
384 $this->export_permission[$r] = array(array(
"fournisseur",
"facture",
"export"));
385 $this->export_fields_array[$r] = array(
386 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
387 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
388 's.code_compta'=>
'CustomerAccountancyCode',
's.code_compta_fournisseur'=>
'SupplierAccountancyCode',
's.tva_intra'=>
'VATIntra',
389 'f.rowid'=>
"InvoiceId",
'f.ref'=>
"InvoiceRef",
'f.ref_supplier'=>
"RefSupplier",
'f.datec'=>
"InvoiceDateCreation",
390 'f.datef'=>
"DateInvoice",
'f.total_ht'=>
"TotalHT",
'f.total_ttc'=>
"TotalTTC",
'f.total_tva'=>
"TotalVAT",
'f.paye'=>
"InvoicePaid",
391 'f.fk_statut'=>
'InvoiceStatus',
'f.note_public'=>
"InvoiceNote",
'p.rowid'=>
'PaymentId',
'pf.amount'=>
'AmountPayment',
392 'p.datep'=>
'DatePayment',
'p.num_paiement'=>
'PaymentNumber',
'p.fk_bank'=>
'IdTransaction',
'project.rowid'=>
'ProjectId',
'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
394 if (!empty($conf->multicurrency->enabled)) {
395 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
396 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
397 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
398 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
399 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
407 $this->export_TypeFields_array[$r] = array(
408 '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',
409 '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",
410 'f.total_ttc'=>
"Numeric",
'f.total_tva'=>
"Numeric",
'f.paye'=>
"Boolean",
'f.fk_statut'=>
'Status',
'f.note_public'=>
"Text",
'pf.amount'=>
'Numeric',
411 'p.datep'=>
'Date',
'p.num_paiement'=>
'Numeric',
'p.fk_bank'=>
'Numeric',
'project.ref'=>
'Text',
'project.title'=>
'Text'
413 $this->export_entities_array[$r] = array(
414 's.rowid'=>
"company",
's.nom'=>
'company',
's.address'=>
'company',
's.zip'=>
'company',
's.town'=>
'company',
'c.code'=>
'company',
's.phone'=>
'company',
415 's.siren'=>
'company',
's.siret'=>
'company',
's.ape'=>
'company',
's.idprof4'=>
'company',
's.idprof5'=>
'company',
's.idprof6'=>
'company',
416 's.code_compta'=>
'company',
's.code_compta_fournisseur'=>
'company',
's.tva_intra'=>
'company',
417 'f.rowid'=>
"invoice",
'f.ref'=>
"invoice",
'f.ref_supplier'=>
"invoice",
'f.datec'=>
"invoice",
'f.datef'=>
"invoice",
'f.total_ht'=>
"invoice",
418 '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',
419 'p.datep'=>
'payment',
'p.num_paiement'=>
'payment',
'p.fk_bank'=>
'account',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project');
420 $this->export_dependencies_array[$r] = array(
'payment'=>
'p.rowid');
422 $keyforselect =
'facture_fourn';
423 $keyforelement =
'invoice';
424 $keyforaliasextra =
'extra';
425 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
427 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
428 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
429 if (is_object($user) && empty($user->rights->societe->client->voir)) {
430 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
432 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
433 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture_fourn as f';
434 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
435 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
436 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
437 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
438 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid';
439 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_invoice').
')';
440 if (is_object($user) && empty($user->rights->societe->client->voir)) {
441 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.((int) $user->id);
446 $this->export_code[$r] = $this->rights_class.
'_'.$r;
447 $this->export_label[$r] =
'Purchase Orders and lines of purchase orders';
448 $this->export_icon[$r] =
'order';
449 $this->export_permission[$r] = array(array(
"fournisseur",
"commande",
"export"));
450 $this->export_fields_array[$r] = array(
451 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
'ps.nom'=>
'ParentCompany',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
452 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
's.tva_intra'=>
'VATIntra',
453 'f.rowid'=>
"OrderId",
'f.ref'=>
"Ref",
'f.ref_supplier'=>
"RefSupplier",
'f.date_creation'=>
"DateCreation",
'f.date_commande'=>
"OrderDate",
'f.date_livraison'=>
"DateDeliveryPlanned",
454 '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',
455 'f.note_public'=>
"NotePublic",
'f.note_private'=>
"NotePrivate",
'uv.login'=>
'UserValidation',
'ua1.login'=>
'ApprovedBy',
'ua2.login'=>
'ApprovedBy2',
'fd.rowid'=>
'LineId',
'fd.description'=>
"LineDescription",
456 'fd.tva_tx'=>
"LineVATRate",
'fd.qty'=>
"LineQty",
'fd.remise_percent'=>
"Discount",
'fd.total_ht'=>
"LineTotalHT",
'fd.total_ttc'=>
"LineTotalTTC",
457 'fd.total_tva'=>
"LineTotalVAT",
'fd.date_start'=>
"DateStart",
'fd.date_end'=>
"DateEnd",
'fd.special_code'=>
'SpecialCode',
458 'fd.product_type'=>
'TypeOfLineServiceOrProduct',
'fd.ref'=>
'RefSupplier',
'fd.fk_product'=>
'ProductId',
459 'p.ref'=>
'ProductRef',
'p.label'=>
'ProductLabel',
'project.rowid'=>
'ProjectId',
'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
461 if (!empty($conf->multicurrency->enabled)) {
462 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
463 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
464 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
465 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
466 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
468 if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) {
469 unset($this->export_fields_array[
'f.date_approve2']);
470 unset($this->export_fields_array[
'ua2.login']);
472 $this->export_TypeFields_array[$r] = array(
473 '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',
474 '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",
475 'f.date_creation'=>
"Date",
'f.date_commande'=>
"Date",
'f.date_livraison'=>
"Date",
'f.total_ht'=>
"Numeric",
'f.total_ttc'=>
"Numeric",
'f.total_tva'=>
"Numeric",
476 '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",
477 'fd.tva_tx'=>
"Numeric",
'fd.qty'=>
"Numeric",
'fd.remise_percent'=>
"Numeric",
'fd.total_ht'=>
"Numeric",
'fd.total_ttc'=>
"Numeric",
'fd.total_tva'=>
"Numeric",
478 'fd.date_start'=>
"Date",
'fd.date_end'=>
"Date",
'fd.special_code'=>
"Numeric",
479 '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'
481 $this->export_entities_array[$r] = array(
482 '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',
483 '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',
484 '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",
485 '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",
486 'fd.product_type'=>
'order_line',
'fd.ref'=>
'order_line',
'fd.fk_product'=>
'product',
487 'p.ref'=>
'product',
'p.label'=>
'product',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project'
489 $this->export_dependencies_array[$r] = array(
'order_line'=>
'fd.rowid',
'product'=>
'fd.rowid');
491 $keyforselect =
'commande_fournisseur';
492 $keyforelement =
'order';
493 $keyforaliasextra =
'extra';
494 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
497 $keyforselect =
'commande_fournisseurdet';
498 $keyforelement =
'order_line';
499 $keyforaliasextra =
'extraline';
500 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
502 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
503 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
504 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON ps.rowid = s.parent';
505 if (is_object($user) && empty($user->rights->societe->client->voir)) {
506 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
508 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
509 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'commande_fournisseur as f';
510 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
511 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uv ON uv.rowid = f.fk_user_valid';
512 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as ua1 ON ua1.rowid = f.fk_user_approve';
513 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as ua2 ON ua2.rowid = f.fk_user_approve2';
514 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
515 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'commande_fournisseurdet as fd';
516 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
517 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
518 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
519 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_order').
')';
520 if (is_object($user) && empty($user->rights->societe->client->voir)) {
521 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.((int) $user->id);
529 $this->import_code[$r] = $this->rights_class.
'_'.$r;
530 $this->import_label[$r] =
"SupplierInvoices";
531 $this->import_icon[$r] = $this->picto;
532 $this->import_entities_array[$r] = array();
533 $this->import_tables_array[$r] = array(
'f' => MAIN_DB_PREFIX.
'facture_fourn',
'extra' => MAIN_DB_PREFIX.
'facture_fourn_extrafields');
534 $this->import_tables_creator_array[$r] = array(
'f' =>
'fk_user_author');
535 $this->import_fields_array[$r] = array(
536 'f.ref' =>
'InvoiceRef*',
537 'f.ref_supplier' =>
'RefSupplier',
539 'f.fk_soc' =>
'Supplier/Vendor*',
540 'f.datec' =>
'InvoiceDateCreation',
541 'f.datef' =>
'DateInvoice',
542 'f.date_lim_reglement' =>
'DateMaxPayment',
543 'f.total_ht' =>
'TotalHT',
544 'f.total_ttc' =>
'TotalTTC',
545 'f.total_tva' =>
'TotalVAT',
546 'f.paye' =>
'InvoicePaid',
547 'f.fk_statut' =>
'InvoiceStatus',
548 'f.fk_user_modif' =>
'Modifier Id',
549 'f.fk_user_valid' =>
'Validator Id',
550 'f.fk_facture_source' =>
'Invoice Source Id',
551 'f.fk_projet' =>
'Project Id',
552 'f.fk_account' =>
'Bank Account*',
553 'f.note_public' =>
'InvoiceNote',
554 'f.note_private' =>
'NotePrivate',
555 'f.fk_cond_reglement' =>
'Payment Condition',
556 'f.fk_mode_reglement' =>
'Payment Mode',
557 'f.model_pdf' =>
'Model',
558 'f.date_valid' =>
'Validation Date'
560 if (!empty($conf->multicurrency->enabled)) {
561 $this->import_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
562 $this->import_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
563 $this->import_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
564 $this->import_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
565 $this->import_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
568 $import_extrafield_sample = array();
569 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.
")";
572 while ($obj = $this->
db->fetch_object(
$resql)) {
573 $fieldname =
'extra.'.$obj->name;
574 $fieldlabel = ucfirst($obj->label);
575 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
576 $import_extrafield_sample[$fieldname] = $fieldlabel;
580 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facture_fourn');
581 $this->import_regex_array[$r] = array(
'f.ref' =>
'(SI\d{4}-\d{4}|PROV.{1,32}$)',
'f.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency');
582 $import_sample = array(
583 'f.ref' =>
'(PROV001)',
584 'f.ref_supplier' =>
'Supplier1',
586 'f.fk_soc' =>
'Vendor1',
587 'f.datec' =>
'2021-01-01',
589 'f.date_lim_reglement' =>
'2021-01-30',
590 'f.total_ht' =>
'1000',
591 'f.total_ttc' =>
'1000',
592 'f.total_tva' =>
'0',
594 'f.fk_statut' =>
'0',
595 'f.fk_user_modif' =>
'',
596 'f.fk_user_valid' =>
'',
597 'f.fk_facture_source' =>
'',
599 'f.fk_account' =>
'BANK1',
600 'f.note_public' =>
'Note: ',
601 'f.note_private' =>
'',
602 'f.fk_cond_reglement' =>
'1',
603 'f.fk_mode_reglement' =>
'2',
604 'f.model_pdf' =>
'crab',
605 'f.date_valid' =>
'',
606 'f.multicurrency_code' =>
'USD',
607 'f.multicurrency_tx' =>
'1',
608 'f.multicurrency_total_ht' =>
'1000',
609 'f.multicurrency_total_tva' =>
'0',
610 'f.multicurrency_total_ttc' =>
'1000'
612 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
613 $this->import_updatekeys_array[$r] = array(
'f.ref' =>
'Ref');
614 $this->import_convertvalue_array[$r] = array(
616 'rule'=>
'getrefifauto',
617 'class'=>(empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) ?
'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER),
618 'path'=>
"/core/modules/supplier_invoice/".(empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) ?
'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER).
'.php',
619 'classobject'=>
'FactureFournisseur',
620 'pathobject'=>
'/fourn/class/fournisseur.facture.class.php',
622 'f.fk_soc' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/societe/class/societe.class.php',
'class' =>
'Societe',
'method' =>
'fetch',
'element' =>
'ThirdParty'),
623 'f.fk_account' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/compta/bank/class/account.class.php',
'class' =>
'Account',
'method' =>
'fetch',
'element' =>
'bank_account'),
628 $this->import_code[$r] = $this->rights_class.
'_'.$r;
629 $this->import_label[$r] =
"SupplierInvoiceLines";
630 $this->import_icon[$r] = $this->picto;
631 $this->import_entities_array[$r] = array();
632 $this->import_tables_array[$r] = array(
'fd' => MAIN_DB_PREFIX.
'facture_fourn_det',
'extra' => MAIN_DB_PREFIX.
'facture_fourn_det_extrafields');
633 $this->import_fields_array[$r] = array(
634 'fd.fk_facture_fourn' =>
'InvoiceRef*',
635 'fd.fk_parent_line' =>
'ParentLine',
636 'fd.fk_product' =>
'IdProduct',
637 'fd.description' =>
'LineDescription',
638 'fd.pu_ht' =>
'PriceUHT',
639 'fd.pu_ttc' =>
'PriceUTTC',
640 'fd.qty' =>
'LineQty',
641 'fd.remise_percent' =>
'Reduc.',
642 'fd.vat_src_code' =>
'Vat Source Code',
643 'fd.product_type' =>
'TypeOfLineServiceOrProduct',
644 'fd.tva_tx' =>
'LineVATRate',
645 'fd.total_ht' =>
'LineTotalHT',
646 'fd.tva' =>
'LineTotalVAT',
647 'fd.total_ttc' =>
'LineTotalTTC',
648 'fd.date_start' =>
'Start Date',
649 'fd.date_end' =>
'End Date',
650 'fd.fk_unit' =>
'Unit'
652 if (!empty($conf->multicurrency->enabled)) {
653 $this->import_fields_array[$r][
'fd.multicurrency_code'] =
'Currency';
654 $this->import_fields_array[$r][
'fd.multicurrency_subprice'] =
'CurrencyRate';
655 $this->import_fields_array[$r][
'fd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
656 $this->import_fields_array[$r][
'fd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
657 $this->import_fields_array[$r][
'fd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
660 $import_extrafield_sample = array();
661 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.
")";
664 while ($obj = $this->
db->fetch_object(
$resql)) {
665 $fieldname =
'extra.'.$obj->name;
666 $fieldlabel = ucfirst($obj->label);
667 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
668 $import_extrafield_sample[$fieldname] = $fieldlabel;
672 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facture_fourn_det');
673 $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');
674 $import_sample = array(
675 'fd.fk_facture_fourn' =>
'(PROV001)',
676 'fd.fk_parent_line' =>
'',
677 'fd.fk_product' =>
'',
678 'fd.description' =>
'Test Product',
679 'fd.pu_ht' =>
'50000',
680 'fd.pu_ttc' =>
'50000',
682 'fd.remise_percent' =>
'0',
683 'fd.vat_src_code' =>
'',
684 'fd.product_type' =>
'0',
686 'fd.total_ht' =>
'50000',
688 'fd.total_ttc' =>
'50000',
689 'fd.date_start' =>
'',
692 'fd.multicurrency_code' =>
'USD',
693 'fd.multicurrency_tx' =>
'0',
694 'fd.multicurrency_total_ht' =>
'50000',
695 'fd.multicurrency_total_tva' =>
'0',
696 'fd.multicurrency_total_ttc' =>
'50000'
698 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
699 $this->import_updatekeys_array[$r] = array(
'fd.rowid' =>
'Row Id',
'fd.fk_facture_fourn' =>
'Invoice Id',
'fd.fk_product' =>
'Product Id');
700 $this->import_convertvalue_array[$r] = array(
701 'fd.fk_facture_fourn' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/fourn/class/fournisseur.facture.class.php',
'class' =>
'FactureFournisseur',
'method' =>
'fetch'),
706 $this->import_code[$r] =
'commande_fournisseur_'.$r;
707 $this->import_label[$r] =
'SuppliersOrders';
708 $this->import_icon[$r] = $this->picto;
709 $this->import_entities_array[$r] = array();
710 $this->import_tables_array[$r] = array(
'c' => MAIN_DB_PREFIX.
'commande_fournisseur',
'extra' => MAIN_DB_PREFIX.
'commande_fournisseur_extrafields');
711 $this->import_tables_creator_array[$r] = array(
'c' =>
'fk_user_author');
712 $this->import_fields_array[$r] = array(
714 'c.ref_supplier' =>
'RefSupplier',
715 'c.fk_soc' =>
'ThirdPartyName*',
716 'c.fk_projet' =>
'ProjectId',
717 'c.date_creation' =>
'DateCreation',
718 'c.date_valid' =>
'DateValid',
719 'c.date_approve' =>
'DateApprove',
720 'c.date_commande' =>
'DateOrder',
721 'c.fk_user_modif' =>
'ModifiedById',
722 'c.fk_user_valid' =>
'ValidatedById',
723 'c.fk_user_approve' =>
'ApprovedById',
724 'c.source' =>
'Source',
725 'c.fk_statut' =>
'Status*',
726 'c.billed' =>
'Billed(0/1)',
727 'c.total_tva' =>
'TotalTVA',
728 'c.total_ht' =>
'TotalHT',
729 'c.total_ttc' =>
'TotalTTC',
730 'c.note_private' =>
'NotePrivate',
731 'c.note_public' =>
'Note',
732 'c.date_livraison' =>
'DeliveryDate',
733 'c.fk_cond_reglement' =>
'Payment Condition',
734 'c.fk_mode_reglement' =>
'Payment Mode',
735 'c.model_pdf' =>
'Model'
738 if (!empty($conf->multicurrency->enabled)) {
739 $this->import_fields_array[$r][
'c.multicurrency_code'] =
'Currency';
740 $this->import_fields_array[$r][
'c.multicurrency_tx'] =
'CurrencyRate';
741 $this->import_fields_array[$r][
'c.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
742 $this->import_fields_array[$r][
'c.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
743 $this->import_fields_array[$r][
'c.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
747 $import_extrafield_sample = array();
748 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.
")";
752 while ($obj = $this->
db->fetch_object(
$resql)) {
753 $fieldname =
'extra.'.$obj->name;
754 $fieldlabel = ucfirst($obj->label);
755 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
756 $import_extrafield_sample[$fieldname] = $fieldlabel;
761 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'commande_fournisseur');
762 $this->import_regex_array[$r] = array(
763 'c.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'
766 $this->import_updatekeys_array[$r] = array(
'c.ref' =>
'Ref');
767 $this->import_convertvalue_array[$r] = array(
769 'rule'=>
'getrefifauto',
770 'class'=>(empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) ?
'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER),
771 'path'=>
"/core/modules/supplier_order/".(empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) ?
'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER).
'.php',
772 'classobject'=>
'CommandeFournisseur',
773 'pathobject'=>
'/fourn/class/fournisseur.commande.class.php',
776 'rule' =>
'fetchidfromref',
777 'file' =>
'/societe/class/societe.class.php',
778 'class' =>
'Societe',
780 'element' =>
'ThirdParty'
782 'c.fk_mode_reglement' => array(
783 'rule' =>
'fetchidfromcodeorlabel',
784 'file' =>
'/compta/paiement/class/cpaiement.class.php',
785 'class' =>
'Cpaiement',
787 'element' =>
'cpayment'
789 'c.source' => array(
'rule' =>
'zeroifnull'),
794 $this->import_code[$r] =
'commande_fournisseurdet_'.$r;
795 $this->import_label[$r] =
'PurchaseOrderLines';
796 $this->import_icon[$r] = $this->picto;
797 $this->import_entities_array[$r] = array();
798 $this->import_tables_array[$r] = array(
'cd' => MAIN_DB_PREFIX.
'commande_fournisseurdet',
'extra' => MAIN_DB_PREFIX.
'commande_fournisseurdet_extrafields');
799 $this->import_fields_array[$r] = array(
800 'cd.fk_commande' =>
'PurchaseOrder*',
801 'cd.fk_parent_line' =>
'ParentLine',
802 'cd.fk_product' =>
'IdProduct',
803 'cd.description' =>
'LineDescription',
804 'cd.tva_tx' =>
'LineVATRate',
805 'cd.qty' =>
'LineQty',
806 'cd.remise_percent' =>
'Reduc. Percent',
807 'cd.subprice' =>
'Sub Price',
808 'cd.total_ht' =>
'LineTotalHT',
809 'cd.total_tva' =>
'LineTotalVAT',
810 'cd.total_ttc' =>
'LineTotalTTC',
811 'cd.product_type' =>
'TypeOfLineServiceOrProduct',
812 'cd.date_start' =>
'Start Date',
813 'cd.date_end' =>
'End Date',
814 'cd.info_bits' =>
'InfoBits',
815 'cd.special_code' =>
'Special Code',
816 'cd.rang' =>
'LinePosition',
817 'cd.fk_unit' =>
'Unit'
820 if (!empty($conf->multicurrency->enabled)) {
821 $this->import_fields_array[$r][
'cd.multicurrency_code'] =
'Currency';
822 $this->import_fields_array[$r][
'cd.multicurrency_subprice'] =
'CurrencyRate';
823 $this->import_fields_array[$r][
'cd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
824 $this->import_fields_array[$r][
'cd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
825 $this->import_fields_array[$r][
'cd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
829 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.
")";
832 while ($obj = $this->
db->fetch_object(
$resql)) {
833 $fieldname =
'extra.'.$obj->name;
834 $fieldlabel = ucfirst($obj->label);
835 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
840 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'commande_fournisseurdet');
841 $this->import_regex_array[$r] = array(
842 'cd.product_type' =>
'[0|1]$',
843 'cd.fk_product' =>
'rowid@'.MAIN_DB_PREFIX.
'product',
844 'cd.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'
846 $this->import_updatekeys_array[$r] = array(
'cd.fk_commande' =>
'Purchase Order Id');
847 $this->import_convertvalue_array[$r] = array(
848 'cd.fk_commande' => array(
849 'rule' =>
'fetchidfromref',
850 'file' =>
'/fourn/class/fournisseur.commande.class.php',
851 'class' =>
'CommandeFournisseur',
853 'element' =>
'order_supplier'
855 'cd.info_bits' => array(
'rule' =>
'zeroifnull'),
856 'cd.special_code' => array(
'rule' =>
'zeroifnull'),
869 public function init($options =
'')
871 global $conf, $langs;
873 $this->
remove($options);
876 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/supplier_orders/template_supplier_order.odt';
877 $dirodt = DOL_DATA_ROOT.
'/doctemplates/supplier_orders';
878 $dest = $dirodt.
'/template_supplier_order.odt';
880 if (file_exists($src) && !file_exists($dest)) {
881 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
883 $result =
dol_copy($src, $dest, 0, 0);
885 $langs->load(
"errors");
886 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
892 "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),
893 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2]).
"', 'order_supplier', ".((
int) $conf->entity).
")",
896 return $this->
_init($sql, $options);