33include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
55 $this->family =
"srm";
56 $this->module_position =
'12';
58 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
62 $this->version =
'dolibarr';
64 $this->const_name =
'MAIN_MODULE_' . strtoupper($this->
name);
65 $this->picto =
'company';
70 "/fournisseur/commande",
71 "/fournisseur/commande/temp",
72 "/fournisseur/facture",
73 "/fournisseur/facture/temp"
77 $this->depends = array(
"modSociete");
78 $this->requiredby = array(
"modSupplierProposal");
79 $this->langfiles = array(
'bills',
'companies',
'suppliers',
'orders',
'sendings');
82 $this->config_page_url = array(
"supplier_order.php@supplier_order");
94 "COMMANDE_SUPPLIER_ADDON_PDF",
97 'Nom du gestionnaire de generation des bons de commande en PDF',
101 "COMMANDE_SUPPLIER_ADDON_NUMBER",
103 "mod_commande_fournisseur_muguet",
104 'Nom du gestionnaire de numerotation des commandes fournisseur',
108 "INVOICE_SUPPLIER_ADDON_NUMBER",
110 "mod_facture_fournisseur_cactus",
111 'Nom du gestionnaire de numerotation des factures fournisseur',
116 "SUPPLIER_ORDER_ADDON_PDF_ODT_PATH",
118 "DOL_DATA_ROOT" . ($conf->entity > 1 ?
'/' .
$conf->entity :
'') .
"/doctemplates/supplier_orders",
124 "SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH",
126 "DOL_DATA_ROOT" . (
$conf->entity > 1 ?
'/' .
$conf->entity :
'') .
"/doctemplates/supplier_invoices",
143 [
'file' =>
'box_graph_invoices_supplier_permonth.php',
'enabledbydefaulton' =>
'Home'],
144 [
'file' =>
'box_graph_orders_supplier_permonth.php',
'enabledbydefaulton' =>
'Home'],
145 [
'file' =>
'box_fournisseurs.php',
'enabledbydefaulton' =>
'Home'],
146 [
'file' =>
'box_factures_fourn_imp.php',
'enabledbydefaulton' =>
'Home'],
147 [
'file' =>
'box_factures_fourn.php',
'enabledbydefaulton' =>
'Home'],
148 [
'file' =>
'box_supplier_orders.php',
'enabledbydefaulton' =>
'Home'],
149 [
'file' =>
'box_supplier_orders_awaiting_reception.php',
'enabledbydefaulton' =>
'Home'],
153 $datestart =
dol_mktime(23, 0, 0, $arraydate[
'mon'], $arraydate[
'mday'], $arraydate[
'year']);
154 $this->cronjobs = array(
156 'label' =>
'RecurringSupplierInvoicesJob',
157 'jobtype' =>
'method',
158 'class' =>
'fourn/class/fournisseur.facture-rec.class.php',
159 'objectname' =>
'FactureFournisseurRec',
160 'method' =>
'createRecurringInvoices',
162 'comment' =>
'Generate recurring supplier invoices',
164 'unitfrequency' => 3600 * 24,
167 'test' =>
'isModEnabled("supplier_invoice")',
168 'datestart' => $datestart
171 'label' =>
'SendEmailsRemindersOnSupplierInvoiceDueDate',
172 'jobtype' =>
'method',
173 'class' =>
'fourn/class/fournisseur.facture.class.php',
174 'objectname' =>
'FactureFournisseur',
175 'method' =>
'sendEmailsRemindersOnSupplierInvoiceDueDate',
176 'parameters' =>
'10,all,EmailTemplateCode,duedate',
177 'comment' =>
'Send an email when we reach the supplier invoice due date (or supplier invoice date) - n days. First param is n, the number of days before due date (or supplier invoice date) to send the remind (or after if value is negative), second parameter is "all" or a payment mode code, third parameter is the code of the email template to use (an email template with the EmailTemplateCode must exists. The version of the email template in the language of the thirdparty will be used in priority. Language of the thirdparty will be also used to update the PDF of the sent supplier invoice). The fourth parameter is the string "duedate" (default) or "invoicedate" to define which date of the supplier invoice to use.',
179 'unitfrequency' => 3600 * 24,
182 'test' =>
'isModEnabled("supplier_invoice")',
183 'datestart' => $datestart
188 $this->rights = array();
189 $this->rights_class =
'fournisseur';
193 $this->rights[$r][0] = 1181;
194 $this->rights[$r][1] =
'Consulter les fournisseurs';
195 $this->rights[$r][2] =
'r';
196 $this->rights[$r][3] = 0;
197 $this->rights[$r][4] =
'lire';
200 $this->rights[$r][0] = 1182;
201 $this->rights[$r][1] =
'Consulter les commandes fournisseur';
202 $this->rights[$r][2] =
'r';
203 $this->rights[$r][3] = 0;
204 $this->rights[$r][4] =
'commande';
205 $this->rights[$r][5] =
'lire';
208 $this->rights[$r][0] = 1183;
209 $this->rights[$r][1] =
'Creer une commande fournisseur';
210 $this->rights[$r][2] =
'w';
211 $this->rights[$r][3] = 0;
212 $this->rights[$r][4] =
'commande';
213 $this->rights[$r][5] =
'creer';
216 $this->rights[$r][0] = 1184;
217 $this->rights[$r][1] =
'Valider une commande fournisseur';
218 $this->rights[$r][2] =
'w';
219 $this->rights[$r][3] = 0;
220 $this->rights[$r][4] =
'supplier_order_advance';
221 $this->rights[$r][5] =
'validate';
224 $this->rights[$r][0] = 1185;
225 $this->rights[$r][1] =
'Approuver une commande fournisseur';
226 $this->rights[$r][2] =
'w';
227 $this->rights[$r][3] = 0;
228 $this->rights[$r][4] =
'commande';
229 $this->rights[$r][5] =
'approuver';
232 $this->rights[$r][0] = 1186;
233 $this->rights[$r][1] =
'Commander une commande fournisseur';
234 $this->rights[$r][2] =
'w';
235 $this->rights[$r][3] = 0;
236 $this->rights[$r][4] =
'commande';
237 $this->rights[$r][5] =
'commander';
240 $this->rights[$r][0] = 1187;
241 $this->rights[$r][1] =
'Receptionner une commande fournisseur';
242 $this->rights[$r][2] =
'd';
243 $this->rights[$r][3] = 0;
244 $this->rights[$r][4] =
'commande';
245 $this->rights[$r][5] =
'receptionner';
248 $this->rights[$r][0] = 1189;
249 $this->rights[$r][1] =
'Check/Uncheck a supplier order reception';
250 $this->rights[$r][2] =
'w';
251 $this->rights[$r][3] = 0;
252 $this->rights[$r][4] =
'commande_advance';
253 $this->rights[$r][5] =
'check';
256 $this->rights[$r][0] = 1188;
257 $this->rights[$r][1] =
'Supprimer une commande fournisseur';
258 $this->rights[$r][2] =
'd';
259 $this->rights[$r][3] = 0;
260 $this->rights[$r][4] =
'commande';
261 $this->rights[$r][5] =
'supprimer';
265 $this->rights[$r][0] = 1190;
266 $this->rights[$r][1] =
'Approve supplier order (second level)';
267 $this->rights[$r][2] =
'w';
268 $this->rights[$r][3] = 0;
269 $this->rights[$r][4] =
'commande';
270 $this->rights[$r][5] =
'approve2';
274 $this->rights[$r][0] = 1191;
275 $this->rights[$r][1] =
'Exporter les commande fournisseurs, attributs';
276 $this->rights[$r][2] =
'r';
277 $this->rights[$r][3] = 0;
278 $this->rights[$r][4] =
'commande';
279 $this->rights[$r][5] =
'export';
282 $this->rights[$r][0] = 1231;
283 $this->rights[$r][1] =
'Consulter les factures fournisseur';
284 $this->rights[$r][2] =
'r';
285 $this->rights[$r][3] = 0;
286 $this->rights[$r][4] =
'facture';
287 $this->rights[$r][5] =
'lire';
290 $this->rights[$r][0] = 1232;
291 $this->rights[$r][1] =
'Creer une facture fournisseur';
292 $this->rights[$r][2] =
'w';
293 $this->rights[$r][3] = 0;
294 $this->rights[$r][4] =
'facture';
295 $this->rights[$r][5] =
'creer';
298 $this->rights[$r][0] = 1233;
299 $this->rights[$r][1] =
'Valider une facture fournisseur';
300 $this->rights[$r][2] =
'w';
301 $this->rights[$r][3] = 0;
302 $this->rights[$r][4] =
'supplier_invoice_advance';
303 $this->rights[$r][5] =
'validate';
306 $this->rights[$r][0] = 1234;
307 $this->rights[$r][1] =
'Supprimer une facture fournisseur';
308 $this->rights[$r][2] =
'd';
309 $this->rights[$r][3] = 0;
310 $this->rights[$r][4] =
'facture';
311 $this->rights[$r][5] =
'supprimer';
314 $this->rights[$r][0] = 1235;
315 $this->rights[$r][1] =
'Envoyer les factures par mail';
316 $this->rights[$r][2] =
'a';
317 $this->rights[$r][3] = 0;
318 $this->rights[$r][4] =
'supplier_invoice_advance';
319 $this->rights[$r][5] =
'send';
322 $this->rights[$r][0] = 1236;
323 $this->rights[$r][1] =
'Exporter les factures fournisseurs, attributes et reglements';
324 $this->rights[$r][2] =
'r';
325 $this->rights[$r][3] = 0;
326 $this->rights[$r][4] =
'facture';
327 $this->rights[$r][5] =
'export';
337 $uselocaltax1 = (is_object(
$mysoc) &&
$mysoc->localtax1_assuj) ?
$mysoc->localtax1_assuj : 0;
338 $uselocaltax2 = (is_object(
$mysoc) &&
$mysoc->localtax2_assuj) ?
$mysoc->localtax2_assuj : 0;
342 $langs->loadLangs(array(
"suppliers",
"compta",
"multicurrency",
"bills"));
344 $alias_product_perentity = !
getDolGlobalString(
'MAIN_PRODUCT_PERENTITY_SHARED') ?
"p" :
"ppe";
347 $this->export_code[$r] = $this->rights_class .
'_' . $r;
348 $this->export_label[$r] =
'Vendor invoices and lines of invoices';
349 $this->export_icon[$r] =
'invoice';
350 $this->export_permission[$r] = array(array(
"fournisseur",
"facture",
"export"));
351 $this->export_fields_array[$r] = array(
352 's.rowid' =>
"IdCompany",
's.nom' =>
'CompanyName',
'ps.nom' =>
'ParentCompany',
's.address' =>
'Address',
's.zip' =>
'Zip',
's.town' =>
'Town',
'c.code' =>
'CountryCode',
's.phone' =>
'Phone',
353 's.siren' =>
'ProfId1',
's.siret' =>
'ProfId2',
's.ape' =>
'ProfId3',
's.idprof4' =>
'ProfId4',
's.idprof5' =>
'ProfId5',
's.idprof6' =>
'ProfId6',
354 's.code_compta' =>
'CustomerAccountancyCode',
's.code_compta_fournisseur' =>
'SupplierAccountancyCode',
's.tva_intra' =>
'VATIntra',
355 'f.rowid' =>
"InvoiceId",
'f.ref' =>
"InvoiceRef",
'f.ref_supplier' =>
"RefSupplier",
'f.datec' =>
"InvoiceDateCreation",
'f.datef' =>
"DateInvoice",
'f.date_lim_reglement' =>
'DateMaxPayment',
356 'f.fk_cond_reglement' =>
'IdPaymentTerm',
'f.fk_mode_reglement' =>
'IdPaymentMode',
357 'f.total_ht' =>
"TotalHT",
'f.total_ttc' =>
"TotalTTC",
'f.total_tva' =>
"TotalVAT",
358 'f.localtax1' =>
"TotalLT1",
'f.localtax2' =>
"TotalLT2",
359 'f.paye' =>
"InvoicePaid",
'f.fk_statut' =>
'InvoiceStatus',
'f.note_public' =>
"InvoiceNote",
360 'fd.rowid' =>
'LineId',
'fd.description' =>
"LineDescription",
'fd.qty' =>
"LineQty",
'fd.remise_percent' =>
"Discount",
361 'fd.tva_tx' =>
"LineVATRate",
'fd.total_ht' =>
"LineTotalHT",
'fd.total_ttc' =>
"LineTotalTTC",
'fd.tva' =>
"LineTotalVAT",
362 'fd.localtax1_tx' =>
"LineLT1Rate",
'fd.localtax1_type' =>
"LineLT1Type",
'fd.total_localtax1' =>
"LineTotalLT1",
363 'fd.localtax2_tx' =>
"LineLT2Rate",
'fd.localtax2_type' =>
"LineLT2Type",
'fd.total_localtax2' =>
"LineTotalLT2",
364 'fd.date_start' =>
"DateStart",
'fd.date_end' =>
"DateEnd",
'fd.special_code' =>
'SpecialCode',
365 'fd.product_type' =>
'TypeOfLineServiceOrProduct',
'fd.fk_product' =>
'ProductId',
366 'p.ref' =>
'ProductRef',
'p.label' =>
'ProductLabel', $alias_product_perentity .
'.accountancy_code_buy' =>
'ProductAccountancyBuyCode',
'project.rowid' =>
'ProjectId',
367 'project.ref' =>
'ProjectRef',
'project.title' =>
'ProjectLabel'
369 if (!$uselocaltax1) {
370 unset($this->export_fields_array[$r][
'fd.localtax1_tx']);
371 unset($this->export_fields_array[$r][
'fd.localtax1_type']);
372 unset($this->export_fields_array[$r][
'fd.total_localtax1']);
374 if (!$uselocaltax2) {
375 unset($this->export_fields_array[$r][
'fd.localtax2_tx']);
376 unset($this->export_fields_array[$r][
'fd.localtax2_type']);
377 unset($this->export_fields_array[$r][
'fd.total_localtax2']);
381 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
382 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
383 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
384 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
385 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
387 if (!$uselocaltax1) {
388 unset($this->export_fields_array[$r][
'f.localtax1']);
390 if (!$uselocaltax2) {
391 unset($this->export_fields_array[$r][
'f.localtax2']);
400 $this->export_TypeFields_array[$r] = array(
401 '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',
402 's.code_compta' =>
'Text',
's.code_compta_fournisseur' =>
'Text',
's.tva_intra' =>
'Text',
403 'f.rowid' =>
'Numeric',
'f.ref' =>
"Text",
'f.ref_supplier' =>
"Text",
'f.datec' =>
"Date",
'f.datef' =>
"Date",
'f.date_lim_reglement' =>
'Date',
404 'f.fk_cond_reglement' =>
'Numeric',
'f.fk_mode_reglement' =>
'Numeric',
405 'f.total_ht' =>
"Numeric",
'f.total_ttc' =>
"Numeric",
'f.total_tva' =>
"Numeric",
'f.localtax1' =>
"Numeric",
'f.localtax2' =>
"Numeric",
406 'f.paye' =>
"Boolean",
'f.fk_statut' =>
'Status',
'f.note_public' =>
"Text",
407 'fd.rowid' =>
'Numeric',
'fd.description' =>
"Text",
'fd.tva_tx' =>
"Text",
408 'fd.qty' =>
"Numeric",
'fd.remise_percent' =>
"Numeric",
409 'fd.total_ht' =>
"Numeric",
'fd.total_ttc' =>
"Numeric",
'fd.tva' =>
"Numeric",
'fd.total_localtax1' =>
"Numeric",
'fd.total_localtax2' =>
"Numeric",
410 'fd.localtax1_tx' =>
'Numeric',
'fd.localtax2_tx' =>
'Numeric',
'fd.localtax1_type' =>
'Numeric',
'fd.localtax2_type' =>
'Numeric',
411 'fd.date_start' =>
"Date",
'fd.date_end' =>
"Date",
'fd.special_code' =>
"Numeric",
412 'fd.product_type' =>
'Numeric',
'fd.fk_product' =>
'List:product:label', $alias_product_perentity .
'.accountancy_code_buy' =>
'Text',
413 'p.ref' =>
'Text',
'p.label' =>
'Text',
'project.ref' =>
'Text',
'project.title' =>
'Text',
414 'f.multicurrency_code' =>
'Text',
415 'f.multicurrency_tx' =>
'Number',
'f.multicurrency_total_ht' =>
'Number',
'f.multicurrency_total_tva' =>
'Number',
'f.multicurrency_total_ttc' =>
'Number'
417 $this->export_entities_array[$r] = array(
418 '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',
419 '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",
420 'f.ref' =>
"invoice",
'f.ref_supplier' =>
"invoice",
'f.datec' =>
"invoice",
'f.datef' =>
"invoice",
'f.date_lim_reglement' =>
'invoice',
421 'f.fk_cond_reglement' =>
'invoice',
'f.fk_mode_reglement' =>
'invoice',
422 'f.total_ht' =>
"invoice",
'f.total_ttc' =>
"invoice",
'f.total_tva' =>
"invoice",
423 'f.paye' =>
"invoice",
'f.fk_statut' =>
'invoice',
'f.note_public' =>
"invoice",
'fd.rowid' =>
'invoice_line',
'fd.description' =>
"invoice_line",
'fd.qty' =>
"invoice_line",
424 'fd.total_ht' =>
"invoice_line",
'fd.tva' =>
"invoice_line",
'fd.total_ttc' =>
"invoice_line",
'fd.total_localtax1' =>
"invoice_line",
'fd.total_localtax2' =>
"invoice_line",
425 '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",
426 'fd.remise_percent' =>
"invoice_line",
427 'fd.date_start' =>
"invoice_line",
'fd.date_end' =>
"invoice_line",
'fd.special_code' =>
"invoice_line",
428 'fd.product_type' =>
'invoice_line',
'fd.fk_product' =>
'product',
429 'p.ref' =>
'product',
'p.label' =>
'product', $alias_product_perentity .
'.accountancy_code_buy' =>
'product',
'project.rowid' =>
'project',
'project.ref' =>
'project',
'project.title' =>
'project'
431 $this->export_dependencies_array[$r] = array(
'invoice_line' =>
'fd.rowid',
'product' =>
'fd.rowid');
433 $keyforselect =
'facture_fourn';
434 $keyforelement =
'invoice';
435 $keyforaliasextra =
'extra';
436 include DOL_DOCUMENT_ROOT .
'/core/extrafieldsinexport.inc.php';
437 $keyforselect =
'facture_fourn_det';
438 $keyforelement =
'invoice_line';
439 $keyforaliasextra =
'extraline';
440 include DOL_DOCUMENT_ROOT .
'/core/extrafieldsinexport.inc.php';
442 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
443 $this->export_sql_end[$r] =
' FROM ' . MAIN_DB_PREFIX .
'societe as s';
444 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe as ps ON ps.rowid = s.parent';
445 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
446 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
448 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'c_country as c ON s.fk_pays = c.rowid,';
449 $this->export_sql_end[$r] .=
' ' . MAIN_DB_PREFIX .
'facture_fourn as f';
450 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'projet as project on (f.fk_projet = project.rowid)';
451 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
452 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'c_paiement as cp ON f.fk_mode_reglement = cp.id';
453 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'c_payment_term as cpt ON f.fk_cond_reglement = cpt.rowid,';
454 $this->export_sql_end[$r] .=
' ' . MAIN_DB_PREFIX .
'facture_fourn_det as fd';
455 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
456 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'product as p on (fd.fk_product = p.rowid)';
457 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
458 $this->export_sql_end[$r] .=
' AND f.entity IN (' .
getEntity(
'supplier_invoice') .
')';
459 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
460 $this->export_sql_end[$r] .=
' AND sc.fk_user = ' . ( (int) $user->id);
465 $this->export_code[$r] = $this->rights_class .
'_' . $r;
466 $this->export_label[$r] =
'Factures fournisseurs et reglements';
467 $this->export_icon[$r] =
'invoice';
468 $this->export_permission[$r] = array(array(
"fournisseur",
"facture",
"export"));
469 $this->export_fields_array[$r] = array(
470 's.rowid' =>
"IdCompany",
's.nom' =>
'CompanyName',
's.address' =>
'Address',
's.zip' =>
'Zip',
's.town' =>
'Town',
'c.code' =>
'CountryCode',
's.phone' =>
'Phone',
471 's.siren' =>
'ProfId1',
's.siret' =>
'ProfId2',
's.ape' =>
'ProfId3',
's.idprof4' =>
'ProfId4',
's.idprof5' =>
'ProfId5',
's.idprof6' =>
'ProfId6',
472 's.code_compta' =>
'CustomerAccountancyCode',
's.code_compta_fournisseur' =>
'SupplierAccountancyCode',
's.tva_intra' =>
'VATIntra',
473 'f.rowid' =>
"InvoiceId",
'f.ref' =>
"InvoiceRef",
'f.ref_supplier' =>
"RefSupplier",
'f.datec' =>
"InvoiceDateCreation",
'f.datef' =>
"DateInvoice",
'f.date_lim_reglement' =>
"DateMaxPayment",
474 'f.fk_cond_reglement' =>
'IdPaymentTerm',
'f.fk_mode_reglement' =>
'IdPaymentMode',
475 'f.total_ht' =>
"TotalHT",
'f.total_ttc' =>
"TotalTTC",
'f.total_tva' =>
"TotalVAT",
476 'f.localtax1' =>
"TotalLT1",
'f.localtax2' =>
"TotalLT2",
477 'f.paye' =>
"InvoicePaid",
478 'f.fk_statut' =>
'InvoiceStatus',
'f.note_public' =>
"InvoiceNote",
'p.rowid' =>
'PaymentId',
'pf.amount' =>
'AmountPayment',
479 'p.datep' =>
'DatePayment',
'p.num_paiement' =>
'PaymentNumber',
'p.fk_bank' =>
'IdTransaction',
'project.rowid' =>
'ProjectId',
'project.ref' =>
'ProjectRef',
'project.title' =>
'ProjectLabel'
481 if (!$uselocaltax1) {
482 unset($this->export_fields_array[$r][
'f.localtax1']);
484 if (!$uselocaltax2) {
485 unset($this->export_fields_array[$r][
'f.localtax2']);
488 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
489 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
490 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
491 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
492 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
500 $this->export_TypeFields_array[$r] = array(
501 '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',
502 's.idprof4' =>
'Text',
's.idprof5' =>
'Text',
's.idprof6' =>
'Text',
's.code_compta' =>
'Text',
's.code_compta_fournisseur' =>
'Text',
's.tva_intra' =>
'Text',
503 'f.rowid' =>
'Numeric',
'f.ref' =>
"Text",
'f.ref_supplier' =>
"Text",
504 'f.datec' =>
"Date",
'f.datef' =>
"Date",
'f.date_lim_reglement' =>
'Date',
505 'f.fk_cond_reglement' =>
'Numeric',
'f.fk_mode_reglement' =>
'Numeric',
506 'f.total_ht' =>
"Numeric",
'f.total_ttc' =>
"Numeric",
'f.total_tva' =>
"Numeric",
'f.localtax1' =>
"Numeric",
'f.localtax2' =>
"Numeric",
507 'f.paye' =>
"Boolean",
'f.fk_statut' =>
'Status',
'f.note_public' =>
"Text",
'pf.amount' =>
'Numeric',
508 'p.rowid' =>
'Numeric',
'p.datep' =>
'Date',
'p.num_paiement' =>
'Numeric',
'p.fk_bank' =>
'Numeric',
'project.rowid' =>
'Numeric',
'project.ref' =>
'Text',
'project.title' =>
'Text',
509 'f.multicurrency_code' =>
'Text',
510 'f.multicurrency_tx' =>
'Number',
'f.multicurrency_total_ht' =>
'Number',
'f.multicurrency_total_tva' =>
'Number',
'f.multicurrency_total_ttc' =>
'Number'
512 $this->export_entities_array[$r] = array(
513 's.rowid' =>
"company",
's.nom' =>
'company',
's.address' =>
'company',
's.zip' =>
'company',
's.town' =>
'company',
'c.code' =>
'company',
's.phone' =>
'company',
514 's.siren' =>
'company',
's.siret' =>
'company',
's.ape' =>
'company',
's.idprof4' =>
'company',
's.idprof5' =>
'company',
's.idprof6' =>
'company',
515 's.code_compta' =>
'company',
's.code_compta_fournisseur' =>
'company',
's.tva_intra' =>
'company',
516 'f.rowid' =>
"invoice",
'f.ref' =>
"invoice",
'f.ref_supplier' =>
"invoice",
'f.datec' =>
"invoice",
'f.datef' =>
"invoice",
'f.date_lim_reglement' =>
'invoice',
517 'f.fk_cond_reglement' =>
'invoice',
'f.fk_mode_reglement' =>
'invoice',
518 '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',
519 'p.datep' =>
'payment',
'p.num_paiement' =>
'payment',
'p.fk_bank' =>
'account',
'project.rowid' =>
'project',
'project.ref' =>
'project',
'project.title' =>
'project');
520 $this->export_dependencies_array[$r] = array(
'payment' =>
'p.rowid');
522 $keyforselect =
'facture_fourn';
523 $keyforelement =
'invoice';
524 $keyforaliasextra =
'extra';
525 include DOL_DOCUMENT_ROOT .
'/core/extrafieldsinexport.inc.php';
527 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
528 $this->export_sql_end[$r] =
' FROM ' . MAIN_DB_PREFIX .
'societe as s';
529 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
530 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
532 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'c_country as c ON s.fk_pays = c.rowid,';
533 $this->export_sql_end[$r] .=
' ' . MAIN_DB_PREFIX .
'facture_fourn as f';
534 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'projet as project on (f.fk_projet = project.rowid)';
535 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
536 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
537 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
538 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'c_paiement as cp ON f.fk_mode_reglement = cp.id';
539 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'c_payment_term as cpt ON f.fk_cond_reglement = cpt.rowid';
540 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid';
541 $this->export_sql_end[$r] .=
' AND f.entity IN (' .
getEntity(
'supplier_invoice') .
')';
542 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
543 $this->export_sql_end[$r] .=
' AND sc.fk_user = ' . ( (int) $user->id);
548 $this->export_code[$r] = $this->rights_class .
'_' . $r;
549 $this->export_label[$r] =
'Purchase Orders and lines of purchase orders';
550 $this->export_icon[$r] =
'supplier_order';
551 $this->export_permission[$r] = array(array(
"fournisseur",
"commande",
"export"));
552 $this->export_fields_array[$r] = array(
553 's.rowid' =>
"IdCompany",
's.nom' =>
'CompanyName',
'ps.nom' =>
'ParentCompany',
's.address' =>
'Address',
's.zip' =>
'Zip',
's.town' =>
'Town',
'c.code' =>
'CountryCode',
's.phone' =>
'Phone',
554 's.siren' =>
'ProfId1',
's.siret' =>
'ProfId2',
's.ape' =>
'ProfId3',
's.idprof4' =>
'ProfId4',
's.idprof5' =>
'ProfId5',
's.idprof6' =>
'ProfId6',
's.tva_intra' =>
'VATIntra',
555 'f.rowid' =>
"OrderId",
'f.ref' =>
"Ref",
'f.ref_supplier' =>
"RefSupplier",
'f.date_creation' =>
"DateCreation",
'f.date_commande' =>
"OrderDate",
'f.date_livraison' =>
"DateDeliveryPlanned",
556 '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',
557 'f.note_public' =>
"NotePublic",
'f.note_private' =>
"NotePrivate",
'uv.login' =>
'UserValidation',
'ua1.login' =>
'ApprovedBy',
'ua2.login' =>
'ApprovedBy2',
'f.source' =>
'Source',
'fd.rowid' =>
'LineId',
'fd.description' =>
"LineDescription",
558 'fd.tva_tx' =>
"LineVATRate",
'fd.qty' =>
"LineQty",
'fd.remise_percent' =>
"Discount",
'fd.total_ht' =>
"LineTotalHT",
'fd.total_ttc' =>
"LineTotalTTC",
559 'fd.total_tva' =>
"LineTotalVAT",
'fd.date_start' =>
"DateStart",
'fd.date_end' =>
"DateEnd",
'fd.special_code' =>
'SpecialCode',
560 'fd.product_type' =>
'TypeOfLineServiceOrProduct',
'fd.ref' =>
'SupplierRef',
'fd.fk_product' =>
'ProductId',
561 'p.ref' =>
'ProductRef',
'p.label' =>
'ProductLabel',
'project.rowid' =>
'ProjectId',
'project.ref' =>
'ProjectRef',
'project.title' =>
'ProjectLabel'
564 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
565 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
566 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
567 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
568 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
571 unset($this->export_fields_array[
'f.date_approve2']);
572 unset($this->export_fields_array[
'ua2.login']);
574 $this->export_TypeFields_array[$r] = array(
575 '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',
576 '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",
577 'f.date_creation' =>
"Date",
'f.date_commande' =>
"Date",
'f.date_livraison' =>
"Date",
'f.total_ht' =>
"Numeric",
'f.total_ttc' =>
"Numeric",
'f.total_tva' =>
"Numeric",
578 'f.fk_statut' =>
'Status',
'f.date_valid' =>
'Date',
'f.date_approve' =>
'Date',
'f.date_approve2' =>
'Date',
'f.note_public' =>
"Text",
'f.note_private' =>
"Text",
'f.source' =>
'Numeric',
'fd.description' =>
"Text",
579 'fd.tva_tx' =>
"Numeric",
'fd.qty' =>
"Numeric",
'fd.remise_percent' =>
"Numeric",
'fd.total_ht' =>
"Numeric",
'fd.total_ttc' =>
"Numeric",
'fd.total_tva' =>
"Numeric",
580 'fd.date_start' =>
"Date",
'fd.date_end' =>
"Date",
'fd.special_code' =>
"Numeric",
581 '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'
583 $this->export_entities_array[$r] = array(
584 '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',
585 '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',
586 'ua2.login' =>
'user',
'f.source' =>
'order',
'fd.rowid' =>
'order_line',
'fd.description' =>
"order_line",
'fd.tva_tx' =>
"order_line",
'fd.qty' =>
"order_line",
'fd.remise_percent' =>
"order_line",
587 '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",
588 'fd.product_type' =>
'order_line',
'fd.ref' =>
'order_line',
'fd.fk_product' =>
'product',
589 'p.ref' =>
'product',
'p.label' =>
'product',
'project.rowid' =>
'project',
'project.ref' =>
'project',
'project.title' =>
'project'
591 $this->export_dependencies_array[$r] = array(
'order_line' =>
'fd.rowid',
'product' =>
'fd.rowid');
593 $keyforselect =
'commande_fournisseur';
594 $keyforelement =
'order';
595 $keyforaliasextra =
'extra';
596 include DOL_DOCUMENT_ROOT .
'/core/extrafieldsinexport.inc.php';
599 $keyforselect =
'commande_fournisseurdet';
600 $keyforelement =
'order_line';
601 $keyforaliasextra =
'extraline';
602 include DOL_DOCUMENT_ROOT .
'/core/extrafieldsinexport.inc.php';
604 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
605 $this->export_sql_end[$r] =
' FROM ' . MAIN_DB_PREFIX .
'societe as s';
606 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe as ps ON ps.rowid = s.parent';
607 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
608 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
610 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'c_country as c ON s.fk_pays = c.rowid,';
611 $this->export_sql_end[$r] .=
' ' . MAIN_DB_PREFIX .
'commande_fournisseur as f';
612 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'projet as project on (f.fk_projet = project.rowid)';
613 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'user as uv ON uv.rowid = f.fk_user_valid';
614 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'user as ua1 ON ua1.rowid = f.fk_user_approve';
615 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'user as ua2 ON ua2.rowid = f.fk_user_approve2';
616 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
617 $this->export_sql_end[$r] .=
' ' . MAIN_DB_PREFIX .
'commande_fournisseurdet as fd';
618 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
619 $this->export_sql_end[$r] .=
' LEFT JOIN ' . MAIN_DB_PREFIX .
'product as p on (fd.fk_product = p.rowid)';
620 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
621 $this->export_sql_end[$r] .=
' AND f.entity IN (' .
getEntity(
'supplier_order') .
')';
622 if (is_object($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
623 $this->export_sql_end[$r] .=
' AND sc.fk_user = ' . ( (int) $user->id);
631 $this->import_code[$r] = $this->rights_class .
'_' . $r;
632 $this->import_label[$r] =
"SupplierInvoices";
633 $this->import_icon[$r] =
'supplier_invoice';
634 $this->import_entities_array[$r] = array();
635 $this->import_tables_array[$r] = array(
'f' => MAIN_DB_PREFIX .
'facture_fourn',
'extra' => MAIN_DB_PREFIX .
'facture_fourn_extrafields');
636 $this->import_tables_creator_array[$r] = array(
'f' =>
'fk_user_author');
637 $this->import_fields_array[$r] = array(
638 'f.ref' =>
'InvoiceRef*',
639 'f.ref_supplier' =>
'RefSupplier',
641 'f.fk_soc' =>
'Supplier/Vendor*',
642 'f.datec' =>
'InvoiceDateCreation',
643 'f.datef' =>
'DateInvoice',
644 'f.date_lim_reglement' =>
'DateMaxPayment',
645 'f.total_ht' =>
'TotalHT',
646 'f.total_ttc' =>
'TotalTTC',
647 'f.total_tva' =>
'TotalVAT',
648 'f.paye' =>
'InvoicePaid',
649 'f.fk_statut' =>
'InvoiceStatus',
650 'f.fk_user_modif' =>
'Modifier Id',
651 'f.fk_user_valid' =>
'Validator Id',
652 'f.fk_facture_source' =>
'Invoice Source Id',
653 'f.fk_projet' =>
'Project Id',
654 'f.fk_account' =>
'Bank Account*',
655 'f.note_public' =>
'InvoiceNote',
656 'f.note_private' =>
'NotePrivate',
657 'f.fk_cond_reglement' =>
'PaymentTerm',
658 'f.fk_mode_reglement' =>
'PaymentMode',
659 'f.model_pdf' =>
'Model',
660 'f.date_valid' =>
'DateValidation'
663 $this->import_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
664 $this->import_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
665 $this->import_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
666 $this->import_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
667 $this->import_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
670 $import_extrafield_sample = array();
671 $sql =
"SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX .
"extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn' AND entity IN (0, " .
$conf->entity .
")";
672 $resql = $this->db->query($sql);
674 while ($obj = $this->db->fetch_object($resql)) {
675 $fieldname =
'extra.' . $obj->name;
676 $fieldlabel = ucfirst($obj->label);
677 $this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ?
'*' :
'');
678 $import_extrafield_sample[$fieldname] = $fieldlabel;
682 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-' . MAIN_DB_PREFIX .
'facture_fourn');
683 if (empty(
$conf->multicurrency->enabled)) {
684 $this->import_fieldshidden_array[$r][
'f.multicurrency_code'] =
'const-' .
$conf->currency;
686 $this->import_regex_array[$r] = array(
'f.multicurrency_code' =>
'code@' . MAIN_DB_PREFIX .
'multicurrency');
687 $import_sample = array(
688 'f.ref' =>
'(PROV001)',
689 'f.ref_supplier' =>
'Supplier1',
691 'f.fk_soc' =>
'Vendor1',
692 'f.datec' =>
'2021-01-01',
694 'f.date_lim_reglement' =>
'2021-01-30',
695 'f.total_ht' =>
'1000',
696 'f.total_ttc' =>
'1000',
697 'f.total_tva' =>
'0',
699 'f.fk_statut' =>
'0',
700 'f.fk_user_modif' =>
'',
701 'f.fk_user_valid' =>
'',
702 'f.fk_facture_source' =>
'',
704 'f.fk_account' =>
'BANK1',
705 'f.note_public' =>
'Note: ',
706 'f.note_private' =>
'',
707 'f.fk_cond_reglement' =>
'1',
708 'f.fk_mode_reglement' =>
'2',
709 'f.model_pdf' =>
'crab',
710 'f.date_valid' =>
'',
711 'f.multicurrency_code' =>
'USD',
712 'f.multicurrency_tx' =>
'1',
713 'f.multicurrency_total_ht' =>
'1000',
714 'f.multicurrency_total_tva' =>
'0',
715 'f.multicurrency_total_ttc' =>
'1000'
717 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
718 $this->import_updatekeys_array[$r] = array(
'f.ref' =>
'Ref');
719 $this->import_convertvalue_array[$r] = array(
721 'rule' =>
'getrefifauto',
722 'class' => (!
getDolGlobalString(
'INVOICE_SUPPLIER_ADDON_NUMBER') ?
'mod_facture_fournisseur_cactus' :
$conf->global->INVOICE_SUPPLIER_ADDON_NUMBER),
723 'path' =>
"/core/modules/supplier_invoice/" . (!
getDolGlobalString(
'INVOICE_SUPPLIER_ADDON_NUMBER') ?
'mod_facture_fournisseur_cactus' :
$conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) .
'.php',
724 'classobject' =>
'FactureFournisseur',
725 'pathobject' =>
'/fourn/class/fournisseur.facture.class.php',
727 'f.fk_soc' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/societe/class/societe.class.php',
'class' =>
'Societe',
'method' =>
'fetch',
'element' =>
'ThirdParty'),
728 'f.fk_account' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/compta/bank/class/account.class.php',
'class' =>
'Account',
'method' =>
'fetch',
'element' =>
'bank_account'),
733 $this->import_code[$r] = $this->rights_class .
'_' . $r;
734 $this->import_label[$r] =
"SupplierInvoiceLines";
735 $this->import_icon[$r] =
'supplier_invoice';
736 $this->import_entities_array[$r] = array();
737 $this->import_tables_array[$r] = array(
'fd' => MAIN_DB_PREFIX .
'facture_fourn_det',
'extra' => MAIN_DB_PREFIX .
'facture_fourn_det_extrafields');
738 $this->import_fields_array[$r] = array(
739 'fd.fk_facture_fourn' =>
'InvoiceRef*',
740 'fd.fk_parent_line' =>
'ParentLine',
741 'fd.fk_product' =>
'IdProduct',
742 'fd.description' =>
'LineDescription',
743 'fd.pu_ht' =>
'PriceUHT',
744 'fd.pu_ttc' =>
'PriceUTTC',
745 'fd.qty' =>
'LineQty',
746 'fd.remise_percent' =>
'Reduc.',
747 'fd.vat_src_code' =>
'Vat Source Code',
748 'fd.product_type' =>
'TypeOfLineServiceOrProduct',
749 'fd.tva_tx' =>
'LineVATRate',
750 'fd.total_ht' =>
'LineTotalHT',
751 'fd.tva' =>
'LineTotalVAT',
752 'fd.total_ttc' =>
'LineTotalTTC',
753 'fd.date_start' =>
'Start Date',
754 'fd.date_end' =>
'End Date',
755 'fd.fk_unit' =>
'Unit'
758 $this->import_fields_array[$r][
'fd.multicurrency_code'] =
'Currency';
759 $this->import_fields_array[$r][
'fd.multicurrency_subprice'] =
'CurrencyRate';
760 $this->import_fields_array[$r][
'fd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
761 $this->import_fields_array[$r][
'fd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
762 $this->import_fields_array[$r][
'fd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
765 $import_extrafield_sample = array();
766 $sql =
"SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX .
"extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn_det' AND entity IN (0, " .
$conf->entity .
")";
767 $resql = $this->db->query($sql);
769 while ($obj = $this->db->fetch_object($resql)) {
770 $fieldname =
'extra.' . $obj->name;
771 $fieldlabel = ucfirst($obj->label);
772 $this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ?
'*' :
'');
773 $import_extrafield_sample[$fieldname] = $fieldlabel;
777 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-' . MAIN_DB_PREFIX .
'facture_fourn_det');
778 $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');
779 $import_sample = array(
780 'fd.fk_facture_fourn' =>
'(PROV001)',
781 'fd.fk_parent_line' =>
'',
782 'fd.fk_product' =>
'',
783 'fd.description' =>
'Test Product',
784 'fd.pu_ht' =>
'50000',
785 'fd.pu_ttc' =>
'50000',
787 'fd.remise_percent' =>
'0',
788 'fd.vat_src_code' =>
'',
789 'fd.product_type' =>
'0',
791 'fd.total_ht' =>
'50000',
793 'fd.total_ttc' =>
'50000',
794 'fd.date_start' =>
'',
797 'fd.multicurrency_code' =>
'USD',
798 'fd.multicurrency_tx' =>
'0',
799 'fd.multicurrency_total_ht' =>
'50000',
800 'fd.multicurrency_total_tva' =>
'0',
801 'fd.multicurrency_total_ttc' =>
'50000'
803 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
804 $this->import_updatekeys_array[$r] = array(
'fd.rowid' =>
'Row Id',
'fd.fk_facture_fourn' =>
'Invoice Id',
'fd.fk_product' =>
'Product Id');
805 $this->import_convertvalue_array[$r] = array(
806 'fd.fk_facture_fourn' => array(
'rule' =>
'fetchidfromref',
'file' =>
'/fourn/class/fournisseur.facture.class.php',
'class' =>
'FactureFournisseur',
'method' =>
'fetch'),
811 $this->import_code[$r] =
'commande_fournisseur_' . $r;
812 $this->import_label[$r] =
'SuppliersOrders';
813 $this->import_icon[$r] =
'supplier_order';
814 $this->import_entities_array[$r] = array();
815 $this->import_tables_array[$r] = array(
'c' => MAIN_DB_PREFIX .
'commande_fournisseur',
'extra' => MAIN_DB_PREFIX .
'commande_fournisseur_extrafields');
816 $this->import_tables_creator_array[$r] = array(
'c' =>
'fk_user_author');
817 $this->import_fields_array[$r] = array(
819 'c.ref_supplier' =>
'RefSupplier',
820 'c.fk_soc' =>
'ThirdPartyName*',
821 'c.fk_projet' =>
'ProjectId',
822 'c.date_creation' =>
'DateCreation',
823 'c.date_valid' =>
'DateValidation',
824 'c.date_approve' =>
'DateApprove',
825 'c.date_commande' =>
'DateOrder',
826 'c.fk_user_modif' =>
'ModifiedById',
827 'c.fk_user_valid' =>
'ValidatedById',
828 'c.fk_user_approve' =>
'ApprovedById',
829 'c.source' =>
'Source',
830 'c.fk_statut' =>
'Status*',
831 'c.billed' =>
'Billed',
832 'c.total_tva' =>
'TotalTVA',
833 'c.total_ht' =>
'TotalHT',
834 'c.total_ttc' =>
'TotalTTC',
835 'c.note_private' =>
'NotePrivate',
836 'c.note_public' =>
'Note',
837 'c.date_livraison' =>
'DeliveryDate',
838 'c.fk_cond_reglement' =>
'Payment Condition',
839 'c.fk_mode_reglement' =>
'Payment Mode',
840 'c.model_pdf' =>
'Model'
844 $this->import_fields_array[$r][
'c.multicurrency_code'] =
'Currency';
845 $this->import_fields_array[$r][
'c.multicurrency_tx'] =
'CurrencyRate';
846 $this->import_fields_array[$r][
'c.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
847 $this->import_fields_array[$r][
'c.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
848 $this->import_fields_array[$r][
'c.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
852 $import_extrafield_sample = array();
853 $sql =
"SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX .
"extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseur' AND entity IN (0, " .
$conf->entity .
")";
854 $resql = $this->db->query($sql);
857 while ($obj = $this->db->fetch_object($resql)) {
858 $fieldname =
'extra.' . $obj->name;
859 $fieldlabel = ucfirst($obj->label);
860 $this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ?
'*' :
'');
861 $import_extrafield_sample[$fieldname] = $fieldlabel;
866 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-' . MAIN_DB_PREFIX .
'commande_fournisseur');
867 $this->import_regex_array[$r] = array(
868 'c.multicurrency_code' =>
'code@' . MAIN_DB_PREFIX .
'multicurrency'
871 $this->import_updatekeys_array[$r] = array(
'c.ref' =>
'Ref');
872 $this->import_convertvalue_array[$r] = array(
874 'rule' =>
'getrefifauto',
875 'class' => (!
getDolGlobalString(
'COMMANDE_SUPPLIER_ADDON_NUMBER') ?
'mod_commande_fournisseur_muguet' :
$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER),
876 'path' =>
"/core/modules/supplier_order/" . (!
getDolGlobalString(
'COMMANDE_SUPPLIER_ADDON_NUMBER') ?
'mod_commande_fournisseur_muguet' :
$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) .
'.php',
877 'classobject' =>
'CommandeFournisseur',
878 'pathobject' =>
'/fourn/class/fournisseur.commande.class.php',
881 'rule' =>
'fetchidfromref',
882 'file' =>
'/societe/class/societe.class.php',
883 'class' =>
'Societe',
885 'element' =>
'ThirdParty'
887 'c.fk_mode_reglement' => array(
888 'rule' =>
'fetchidfromcodeorlabel',
889 'file' =>
'/compta/paiement/class/cpaiement.class.php',
890 'class' =>
'Cpaiement',
892 'element' =>
'cpayment'
894 'c.source' => array(
'rule' =>
'zeroifnull'),
899 $this->import_code[$r] =
'commande_fournisseurdet_' . $r;
900 $this->import_label[$r] =
'PurchaseOrderLines';
901 $this->import_icon[$r] =
'supplier_order';
902 $this->import_entities_array[$r] = array();
903 $this->import_tables_array[$r] = array(
'cd' => MAIN_DB_PREFIX .
'commande_fournisseurdet',
'extra' => MAIN_DB_PREFIX .
'commande_fournisseurdet_extrafields');
904 $this->import_fields_array[$r] = array(
905 'cd.fk_commande' =>
'PurchaseOrder*',
906 'cd.fk_parent_line' =>
'ParentLine',
907 'cd.fk_product' =>
'IdProduct',
908 'cd.ref' =>
'SupplierRef',
909 'cd.description' =>
'LineDescription',
910 'cd.tva_tx' =>
'LineVATRate',
911 'cd.qty' =>
'LineQty',
912 'cd.remise_percent' =>
'Reduc. Percent',
913 'cd.subprice' =>
'Sub Price',
914 'cd.total_ht' =>
'LineTotalHT',
915 'cd.total_tva' =>
'LineTotalVAT',
916 'cd.total_ttc' =>
'LineTotalTTC',
917 'cd.product_type' =>
'TypeOfLineServiceOrProduct',
918 'cd.date_start' =>
'Start Date',
919 'cd.date_end' =>
'End Date',
920 'cd.info_bits' =>
'InfoBits',
921 'cd.special_code' =>
'Special Code',
922 'cd.rang' =>
'LinePosition',
923 'cd.fk_unit' =>
'Unit'
927 $this->import_fields_array[$r][
'cd.multicurrency_code'] =
'Currency';
928 $this->import_fields_array[$r][
'cd.multicurrency_subprice'] =
'CurrencyRate';
929 $this->import_fields_array[$r][
'cd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
930 $this->import_fields_array[$r][
'cd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
931 $this->import_fields_array[$r][
'cd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
935 $sql =
"SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX .
"extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseurdet' AND entity IN (0, " .
$conf->entity .
")";
936 $resql = $this->db->query($sql);
938 while ($obj = $this->db->fetch_object($resql)) {
939 $fieldname =
'extra.' . $obj->name;
940 $fieldlabel = ucfirst($obj->label);
941 $this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ?
'*' :
'');
946 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-' . MAIN_DB_PREFIX .
'commande_fournisseurdet');
947 $this->import_regex_array[$r] = array(
948 'cd.product_type' =>
'[0|1]$',
949 'cd.fk_product' =>
'rowid@' . MAIN_DB_PREFIX .
'product',
950 'cd.multicurrency_code' =>
'code@' . MAIN_DB_PREFIX .
'multicurrency'
952 $this->import_updatekeys_array[$r] = array(
'cd.fk_commande' =>
'Purchase Order Id',
'cd.rang' =>
'LinePosition');
953 $this->import_convertvalue_array[$r] = array(
954 'cd.fk_commande' => array(
955 'rule' =>
'fetchidfromref',
956 'file' =>
'/fourn/class/fournisseur.commande.class.php',
957 'class' =>
'CommandeFournisseur',
959 'element' =>
'order_supplier'
961 'cd.info_bits' => array(
'rule' =>
'zeroifnull'),
962 'cd.special_code' => array(
'rule' =>
'zeroifnull'),
975 public function init($options =
'')
977 global
$conf, $langs;
979 $this->
remove($options);
982 $src = DOL_DOCUMENT_ROOT .
'/install/doctemplates/supplier_orders/template_supplier_order.odt';
983 $dirodt = DOL_DATA_ROOT . (
$conf->entity > 1 ?
'/' .
$conf->entity :
'') .
'/doctemplates/supplier_orders';
984 $dest = $dirodt .
'/template_supplier_order.odt';
986 if (file_exists($src) && !file_exists($dest)) {
987 require_once DOL_DOCUMENT_ROOT .
'/core/lib/files.lib.php';
989 $result =
dol_copy($src, $dest,
'0', 0);
991 $langs->load(
"errors");
992 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
998 "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),
999 "INSERT INTO " . MAIN_DB_PREFIX .
"document_model (nom, type, entity) VALUES('" . $this->db->escape($this->const[0][2]) .
"', 'order_supplier', " . ( (
int)
$conf->entity) .
")",
1003 $src = DOL_DOCUMENT_ROOT .
'/install/doctemplates/supplier_invoices/template_supplier_invoices.odt';
1004 $dirodt = DOL_DATA_ROOT . (
$conf->entity > 1 ?
'/' .
$conf->entity :
'') .
'/doctemplates/supplier_invoices';
1005 $dest = $dirodt .
'/template_supplier_invoices.odt';
1007 if (file_exists($src) && !file_exists($dest)) {
1008 require_once DOL_DOCUMENT_ROOT .
'/core/lib/files.lib.php';
1010 $result =
dol_copy($src, $dest,
'0', 0);
1012 $langs->load(
"errors");
1013 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
1029 return $this->
_init($sql, $options);
_init($array_sql, $options='')
Enables a module.
__construct($db)
Constructor.
init($options='')
Function called when module is enabled.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_copy($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.