29 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
52 $this->family =
"srm";
53 $this->module_position =
'12';
55 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
59 $this->version =
'dolibarr';
61 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
62 $this->picto =
'company';
67 "/fournisseur/commande",
68 "/fournisseur/commande/temp",
69 "/fournisseur/facture",
70 "/fournisseur/facture/temp"
74 $this->depends = array(
"modSociete");
75 $this->requiredby = array(
"modSupplierProposal");
76 $this->langfiles = array(
'bills',
'companies',
'suppliers',
'orders',
'sendings');
79 $this->config_page_url = array(
"supplier_order.php");
82 $this->
const = array();
85 $this->
const[$r][0] =
"COMMANDE_SUPPLIER_ADDON_PDF";
86 $this->
const[$r][1] =
"chaine";
87 $this->
const[$r][2] =
"muscadet";
88 $this->
const[$r][3] =
'Nom du gestionnaire de generation des bons de commande en PDF';
89 $this->
const[$r][4] = 0;
92 $this->
const[$r][0] =
"COMMANDE_SUPPLIER_ADDON_NUMBER";
93 $this->
const[$r][1] =
"chaine";
94 $this->
const[$r][2] =
"mod_commande_fournisseur_muguet";
95 $this->
const[$r][3] =
'Nom du gestionnaire de numerotation des commandes fournisseur';
96 $this->
const[$r][4] = 0;
108 $this->
const[$r][0] =
"INVOICE_SUPPLIER_ADDON_NUMBER";
109 $this->
const[$r][1] =
"chaine";
110 $this->
const[$r][2] =
"mod_facture_fournisseur_cactus";
111 $this->
const[$r][3] =
'Nom du gestionnaire de numerotation des factures fournisseur';
112 $this->
const[$r][4] = 0;
115 $this->
const[$r][0] =
"SUPPLIER_ORDER_ADDON_PDF_ODT_PATH";
116 $this->
const[$r][1] =
"chaine";
117 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/supplier_orders";
118 $this->
const[$r][3] =
'';
119 $this->
const[$r][4] = 0;
123 $this->boxes = array(
124 0=>array(
'file'=>
'box_graph_invoices_supplier_permonth.php',
'enabledbydefaulton'=>
'Home'),
125 1=>array(
'file'=>
'box_graph_orders_supplier_permonth.php',
'enabledbydefaulton'=>
'Home'),
126 2=>array(
'file'=>
'box_fournisseurs.php',
'enabledbydefaulton'=>
'Home'),
127 3=>array(
'file'=>
'box_factures_fourn_imp.php',
'enabledbydefaulton'=>
'Home'),
128 4=>array(
'file'=>
'box_factures_fourn.php',
'enabledbydefaulton'=>
'Home'),
129 5=>array(
'file'=>
'box_supplier_orders.php',
'enabledbydefaulton'=>
'Home'),
130 6=>array(
'file'=>
'box_supplier_orders_awaiting_reception.php',
'enabledbydefaulton'=>
'Home'),
134 $this->rights = array();
135 $this->rights_class =
'fournisseur';
139 $this->rights[$r][0] = 1181;
140 $this->rights[$r][1] =
'Consulter les fournisseurs';
141 $this->rights[$r][2] =
'r';
142 $this->rights[$r][3] = 0;
143 $this->rights[$r][4] =
'lire';
146 $this->rights[$r][0] = 1182;
147 $this->rights[$r][1] =
'Consulter les commandes fournisseur';
148 $this->rights[$r][2] =
'r';
149 $this->rights[$r][3] = 0;
150 $this->rights[$r][4] =
'commande';
151 $this->rights[$r][5] =
'lire';
154 $this->rights[$r][0] = 1183;
155 $this->rights[$r][1] =
'Creer une commande fournisseur';
156 $this->rights[$r][2] =
'w';
157 $this->rights[$r][3] = 0;
158 $this->rights[$r][4] =
'commande';
159 $this->rights[$r][5] =
'creer';
162 $this->rights[$r][0] = 1184;
163 $this->rights[$r][1] =
'Valider une commande fournisseur';
164 $this->rights[$r][2] =
'w';
165 $this->rights[$r][3] = 0;
166 $this->rights[$r][4] =
'supplier_order_advance';
167 $this->rights[$r][5] =
'validate';
170 $this->rights[$r][0] = 1185;
171 $this->rights[$r][1] =
'Approuver une commande fournisseur';
172 $this->rights[$r][2] =
'w';
173 $this->rights[$r][3] = 0;
174 $this->rights[$r][4] =
'commande';
175 $this->rights[$r][5] =
'approuver';
178 $this->rights[$r][0] = 1186;
179 $this->rights[$r][1] =
'Commander une commande fournisseur';
180 $this->rights[$r][2] =
'w';
181 $this->rights[$r][3] = 0;
182 $this->rights[$r][4] =
'commande';
183 $this->rights[$r][5] =
'commander';
186 $this->rights[$r][0] = 1187;
187 $this->rights[$r][1] =
'Receptionner une commande fournisseur';
188 $this->rights[$r][2] =
'd';
189 $this->rights[$r][3] = 0;
190 $this->rights[$r][4] =
'commande';
191 $this->rights[$r][5] =
'receptionner';
194 $this->rights[$r][0] = 1189;
195 $this->rights[$r][1] =
'Check/Uncheck a supplier order reception';
196 $this->rights[$r][2] =
'w';
197 $this->rights[$r][3] = 0;
198 $this->rights[$r][4] =
'commande_advance';
199 $this->rights[$r][5] =
'check';
202 $this->rights[$r][0] = 1188;
203 $this->rights[$r][1] =
'Supprimer une commande fournisseur';
204 $this->rights[$r][2] =
'd';
205 $this->rights[$r][3] = 0;
206 $this->rights[$r][4] =
'commande';
207 $this->rights[$r][5] =
'supprimer';
209 if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
212 $this->rights[$r][0] = 1190;
213 $this->rights[$r][1] =
'Approve supplier order (second level)';
214 $this->rights[$r][2] =
'w';
215 $this->rights[$r][3] = 0;
216 $this->rights[$r][4] =
'commande';
217 $this->rights[$r][5] =
'approve2';
221 $this->rights[$r][0] = 1191;
222 $this->rights[$r][1] =
'Exporter les commande fournisseurs, attributs';
223 $this->rights[$r][2] =
'r';
224 $this->rights[$r][3] = 0;
225 $this->rights[$r][4] =
'commande';
226 $this->rights[$r][5] =
'export';
229 $this->rights[$r][0] = 1231;
230 $this->rights[$r][1] =
'Consulter les factures fournisseur';
231 $this->rights[$r][2] =
'r';
232 $this->rights[$r][3] = 0;
233 $this->rights[$r][4] =
'facture';
234 $this->rights[$r][5] =
'lire';
237 $this->rights[$r][0] = 1232;
238 $this->rights[$r][1] =
'Creer une facture fournisseur';
239 $this->rights[$r][2] =
'w';
240 $this->rights[$r][3] = 0;
241 $this->rights[$r][4] =
'facture';
242 $this->rights[$r][5] =
'creer';
245 $this->rights[$r][0] = 1233;
246 $this->rights[$r][1] =
'Valider une facture fournisseur';
247 $this->rights[$r][2] =
'w';
248 $this->rights[$r][3] = 0;
249 $this->rights[$r][4] =
'supplier_invoice_advance';
250 $this->rights[$r][5] =
'validate';
253 $this->rights[$r][0] = 1234;
254 $this->rights[$r][1] =
'Supprimer une facture fournisseur';
255 $this->rights[$r][2] =
'd';
256 $this->rights[$r][3] = 0;
257 $this->rights[$r][4] =
'facture';
258 $this->rights[$r][5] =
'supprimer';
261 $this->rights[$r][0] = 1235;
262 $this->rights[$r][1] =
'Envoyer les factures par mail';
263 $this->rights[$r][2] =
'a';
264 $this->rights[$r][3] = 0;
265 $this->rights[$r][4] =
'supplier_invoice_advance';
266 $this->rights[$r][5] =
'send';
269 $this->rights[$r][0] = 1236;
270 $this->rights[$r][1] =
'Exporter les factures fournisseurs, attributs et reglements';
271 $this->rights[$r][2] =
'r';
272 $this->rights[$r][3] = 0;
273 $this->rights[$r][4] =
'facture';
274 $this->rights[$r][5] =
'export';
287 $this->export_code[$r] = $this->rights_class.
'_'.$r;
288 $this->export_label[$r] =
'Vendor invoices and lines of invoices';
289 $this->export_icon[$r] =
'bill';
290 $this->export_permission[$r] = array(array(
"fournisseur",
"facture",
"export"));
291 $this->export_fields_array[$r] = array(
292 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
293 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
294 's.code_compta'=>
'CustomerAccountancyCode',
's.code_compta_fournisseur'=>
'SupplierAccountancyCode',
's.tva_intra'=>
'VATIntra',
295 'f.rowid'=>
"InvoiceId",
'f.ref'=>
"InvoiceRef",
'f.ref_supplier'=>
"RefSupplier",
'f.datec'=>
"InvoiceDateCreation",
'f.datef'=>
"DateInvoice",
'f.date_lim_reglement'=>
'DateMaxPayment',
296 'f.total_ht'=>
"TotalHT",
'f.total_ttc'=>
"TotalTTC",
'f.total_tva'=>
"TotalVAT",
'f.paye'=>
"InvoicePaid",
'f.fk_statut'=>
'InvoiceStatus',
'f.note_public'=>
"InvoiceNote",
297 'fd.rowid'=>
'LineId',
'fd.description'=>
"LineDescription",
'fd.tva_tx'=>
"LineVATRate",
'fd.qty'=>
"LineQty",
'fd.remise_percent'=>
"Discount",
'fd.total_ht'=>
"LineTotalHT",
298 'fd.total_ttc'=>
"LineTotalTTC",
'fd.tva'=>
"LineTotalVAT",
'fd.product_type'=>
'TypeOfLineServiceOrProduct',
'fd.fk_product'=>
'ProductId',
299 'p.ref'=>
'ProductRef',
'p.label'=>
'ProductLabel',
'p.accountancy_code_buy'=>
'ProductAccountancyBuyCode',
'project.rowid'=>
'ProjectId',
300 'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
302 if (!empty($conf->multicurrency->enabled))
304 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
305 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
306 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
307 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
308 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
316 $this->export_TypeFields_array[$r] = array(
317 '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',
's.idprof4'=>
'Text',
's.idprof5'=>
'Text',
's.idprof6'=>
'Text',
318 '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',
319 '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",
320 'fd.qty'=>
"Numeric",
'fd.total_ht'=>
"Numeric",
'fd.total_ttc'=>
"Numeric",
'fd.tva'=>
"Numeric",
'fd.product_type'=>
'Numeric',
'fd.fk_product'=>
'List:product:label',
321 'p.ref'=>
'Text',
'p.label'=>
'Text',
'project.ref'=>
'Text',
'project.title'=>
'Text'
323 $this->export_entities_array[$r] = array(
324 's.rowid'=>
"company",
's.nom'=>
'company',
's.address'=>
'company',
's.zip'=>
'company',
's.town'=>
'company',
'c.code'=>
'company',
's.phone'=>
'company',
's.siren'=>
'company',
's.siret'=>
'company',
325 '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",
326 '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",
327 '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",
328 'fd.remise_percent'=>
"invoice_line",
'fd.total_ht'=>
"invoice_line",
'fd.total_ttc'=>
"invoice_line",
'fd.tva'=>
"invoice_line",
'fd.product_type'=>
'invoice_line',
'fd.fk_product'=>
'product',
329 'p.ref'=>
'product',
'p.label'=>
'product',
'p.accountancy_code_buy'=>
'product',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project'
331 $this->export_dependencies_array[$r] = array(
'invoice_line'=>
'fd.rowid',
'product'=>
'fd.rowid');
333 $sql =
"SELECT name, label, type, param FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.
")";
337 while ($obj = $this->
db->fetch_object(
$resql))
339 $fieldname =
'extra.'.$obj->name;
340 $fieldlabel = ucfirst($obj->label);
341 $typeFilter =
"Text";
347 $typeFilter =
"Numeric";
351 $typeFilter =
"Date";
354 $typeFilter =
"Boolean";
358 $tmpparam = unserialize($obj->param);
359 if ($tmpparam[
'options'] && is_array($tmpparam[
'options'])) {
360 $var = array_keys($tmpparam[
'options']);
361 $tmp = array_shift($var);
363 if (preg_match(
'/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter =
"List:".$tmp;
366 $this->export_fields_array[$r][$fieldname] = $fieldlabel;
367 $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
368 $this->export_entities_array[$r][$fieldname] =
'invoice';
373 $sql =
"SELECT name, label, type, param FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.
")";
377 while ($obj = $this->
db->fetch_object(
$resql))
379 $fieldname =
'extraline.'.$obj->name;
380 $fieldlabel = ucfirst($obj->label);
381 $typeFilter =
"Text";
387 $typeFilter =
"Numeric";
391 $typeFilter =
"Date";
394 $typeFilter =
"Boolean";
398 $tmpparam = unserialize($obj->param);
399 if ($tmpparam[
'options'] && is_array($tmpparam[
'options'])) $tmp = array_shift(array_keys($tmpparam[
'options']));
400 if (preg_match(
'/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter =
"List:".$tmp;
403 $this->export_fields_array[$r][$fieldname] = $fieldlabel;
404 $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
405 $this->export_entities_array[$r][$fieldname] =
'invoice_line';
409 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
410 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
411 if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
412 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
413 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture_fourn as f';
414 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
415 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
416 $this->export_sql_end[$r] .=
' , '.MAIN_DB_PREFIX.
'facture_fourn_det as fd';
417 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
418 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
419 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
420 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_invoice').
')';
421 if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=
' AND sc.fk_user = '.$user->id;
424 $this->export_code[$r] = $this->rights_class.
'_'.$r;
425 $this->export_label[$r] =
'Factures fournisseurs et reglements';
426 $this->export_icon[$r] =
'bill';
427 $this->export_permission[$r] = array(array(
"fournisseur",
"facture",
"export"));
428 $this->export_fields_array[$r] = array(
429 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
430 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
431 's.code_compta'=>
'CustomerAccountancyCode',
's.code_compta_fournisseur'=>
'SupplierAccountancyCode',
's.tva_intra'=>
'VATIntra',
432 'f.rowid'=>
"InvoiceId",
'f.ref'=>
"InvoiceRef",
'f.ref_supplier'=>
"RefSupplier",
'f.datec'=>
"InvoiceDateCreation",
433 'f.datef'=>
"DateInvoice",
'f.total_ht'=>
"TotalHT",
'f.total_ttc'=>
"TotalTTC",
'f.total_tva'=>
"TotalVAT",
'f.paye'=>
"InvoicePaid",
434 'f.fk_statut'=>
'InvoiceStatus',
'f.note_public'=>
"InvoiceNote",
'p.rowid'=>
'PaymentId',
'pf.amount'=>
'AmountPayment',
435 'p.datep'=>
'DatePayment',
'p.num_paiement'=>
'PaymentNumber',
'p.fk_bank'=>
'IdTransaction',
'project.rowid'=>
'ProjectId',
'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
437 if (!empty($conf->multicurrency->enabled))
439 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
440 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
441 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
442 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
443 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
451 $this->export_TypeFields_array[$r] = array(
452 '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',
453 '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",
454 'f.total_ttc'=>
"Numeric",
'f.total_tva'=>
"Numeric",
'f.paye'=>
"Boolean",
'f.fk_statut'=>
'Status',
'f.note_public'=>
"Text",
'pf.amount'=>
'Numeric',
455 'p.datep'=>
'Date',
'p.num_paiement'=>
'Numeric',
'p.fk_bank'=>
'Numeric',
'project.ref'=>
'Text',
'project.title'=>
'Text'
457 $this->export_entities_array[$r] = array(
458 's.rowid'=>
"company",
's.nom'=>
'company',
's.address'=>
'company',
's.zip'=>
'company',
's.town'=>
'company',
'c.code'=>
'company',
's.phone'=>
'company',
459 's.siren'=>
'company',
's.siret'=>
'company',
's.ape'=>
'company',
's.idprof4'=>
'company',
's.idprof5'=>
'company',
's.idprof6'=>
'company',
460 's.code_compta'=>
'company',
's.code_compta_fournisseur'=>
'company',
's.tva_intra'=>
'company',
461 'f.rowid'=>
"invoice",
'f.ref'=>
"invoice",
'f.ref_supplier'=>
"invoice",
'f.datec'=>
"invoice",
'f.datef'=>
"invoice",
'f.total_ht'=>
"invoice",
462 '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',
463 'p.datep'=>
'payment',
'p.num_paiement'=>
'payment',
'p.fk_bank'=>
'account',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project');
464 $this->export_dependencies_array[$r] = array(
'payment'=>
'p.rowid');
466 $sql =
"SELECT name, label, type, param FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.
")";
470 while ($obj = $this->
db->fetch_object(
$resql))
472 $fieldname =
'extra.'.$obj->name;
473 $fieldlabel = ucfirst($obj->label);
474 $typeFilter =
"Text";
480 $typeFilter =
"Numeric";
484 $typeFilter =
"Date";
487 $typeFilter =
"Boolean";
491 $tmpparam = unserialize($obj->param);
492 if ($tmpparam[
'options'] && is_array($tmpparam[
'options'])) $tmp = array_shift(array_keys($tmpparam[
'options']));
493 if (preg_match(
'/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter =
"List:".$tmp;
496 $this->export_fields_array[$r][$fieldname] = $fieldlabel;
497 $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
498 $this->export_entities_array[$r][$fieldname] =
'invoice';
502 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
503 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
504 if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
505 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
506 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture_fourn as f';
507 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
508 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
509 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
510 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
511 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid';
512 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_invoice').
')';
513 if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=
' AND sc.fk_user = '.$user->id;
517 $this->export_code[$r] = $this->rights_class.
'_'.$r;
518 $this->export_label[$r] =
'Purchase Orders and lines of purchase orders';
519 $this->export_icon[$r] =
'order';
520 $this->export_permission[$r] = array(array(
"fournisseur",
"commande",
"export"));
521 $this->export_fields_array[$r] = array(
522 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
's.phone'=>
'Phone',
523 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
's.idprof6'=>
'ProfId6',
's.tva_intra'=>
'VATIntra',
524 'f.rowid'=>
"OrderId",
'f.ref'=>
"Ref",
'f.ref_supplier'=>
"RefSupplier",
'f.date_creation'=>
"DateCreation",
'f.date_commande'=>
"OrderDate",
'f.date_livraison'=>
"DateDeliveryPlanned",
525 'f.total_ht'=>
"TotalHT",
'f.total_ttc'=>
"TotalTTC",
'f.tva'=>
"TotalVAT",
'f.fk_statut'=>
'Status',
'f.date_approve'=>
'DateApprove',
'f.date_approve2'=>
'DateApprove2',
526 'f.note_public'=>
"NotePublic",
'f.note_private'=>
"NotePrivate",
'ua1.login'=>
'ApprovedBy',
'ua2.login'=>
'ApprovedBy2',
'fd.rowid'=>
'LineId',
'fd.description'=>
"LineDescription",
527 'fd.tva_tx'=>
"LineVATRate",
'fd.qty'=>
"LineQty",
'fd.remise_percent'=>
"Discount",
'fd.total_ht'=>
"LineTotalHT",
'fd.total_ttc'=>
"LineTotalTTC",
528 'fd.total_tva'=>
"LineTotalVAT",
'fd.product_type'=>
'TypeOfLineServiceOrProduct',
'fd.ref'=>
'RefSupplier',
'fd.fk_product'=>
'ProductId',
529 'p.ref'=>
'ProductRef',
'p.label'=>
'ProductLabel',
'project.rowid'=>
'ProjectId',
'project.ref'=>
'ProjectRef',
'project.title'=>
'ProjectLabel'
531 if (!empty($conf->multicurrency->enabled))
533 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
534 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
535 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
536 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
537 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
539 if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
541 unset($this->export_fields_array[
'f.date_approve2']);
542 unset($this->export_fields_array[
'ua2.login']);
544 $this->export_TypeFields_array[$r] = array(
545 's.rowid'=>
"company",
's.nom'=>
'Text',
's.address'=>
'Text',
's.cp'=>
'Text',
's.ville'=>
'Text',
'c.code'=>
'Text',
's.tel'=>
'Text',
's.siren'=>
'Text',
546 '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",
547 'f.date_creation'=>
"Date",
'f.date_commande'=>
"Date",
'f.date_livraison'=>
"Date",
'f.total_ht'=>
"Numeric",
'f.total_ttc'=>
"Numeric",
'f.tva'=>
"Numeric",
548 'f.fk_statut'=>
'Status',
'f.date_approve'=>
'Date',
'f.date_approve2'=>
'Date',
'f.note_public'=>
"Text",
'f.note_private'=>
"Text",
'fd.description'=>
"Text",
549 'fd.tva_tx'=>
"Numeric",
'fd.qty'=>
"Numeric",
'fd.remise_percent'=>
"Numeric",
'fd.total_ht'=>
"Numeric",
'fd.total_ttc'=>
"Numeric",
'fd.total_tva'=>
"Numeric",
550 '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'
552 $this->export_entities_array[$r] = array(
553 's.rowid'=>
"company",
's.nom'=>
'company',
's.address'=>
'company',
's.zip'=>
'company',
's.town'=>
'company',
'c.code'=>
'company',
's.phone'=>
'company',
's.siren'=>
'company',
554 's.siret'=>
'company',
's.ape'=>
'company',
's.idprof4'=>
'company',
's.idprof5'=>
'company',
's.idprof6'=>
'company',
's.tva_intra'=>
'company',
'ua1.login'=>
'user',
555 '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",
556 'fd.total_ht'=>
"order_line",
'fd.total_ttc'=>
"order_line",
'fd.total_tva'=>
"order_line",
'fd.product_type'=>
'order_line',
'fd.ref'=>
'order_line',
'fd.fk_product'=>
'product',
557 'p.ref'=>
'product',
'p.label'=>
'product',
'project.rowid'=>
'project',
'project.ref'=>
'project',
'project.title'=>
'project'
559 $this->export_dependencies_array[$r] = array(
'order_line'=>
'fd.rowid',
'product'=>
'fd.rowid');
561 $sql =
"SELECT name, label, type, param FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.
")";
565 while ($obj = $this->
db->fetch_object(
$resql))
567 $fieldname =
'extra.'.$obj->name;
568 $fieldlabel = ucfirst($obj->label);
569 $typeFilter =
"Text";
575 $typeFilter =
"Numeric";
579 $typeFilter =
"Date";
582 $typeFilter =
"Boolean";
586 $tmpparam = unserialize($obj->param);
587 $tmpkey = array_keys($tmpparam[
'options']);
588 if ($tmpparam[
'options'] && is_array($tmpparam[
'options'])) $tmp = array_shift($tmpkey);
589 if (preg_match(
'/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter =
"List:".$tmp;
592 $this->export_fields_array[$r][$fieldname] = $fieldlabel;
593 $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
594 $this->export_entities_array[$r][$fieldname] =
'order';
599 $sql =
"SELECT name, label, type, param FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.
")";
603 while ($obj = $this->
db->fetch_object(
$resql))
605 $fieldname =
'extraline.'.$obj->name;
606 $fieldlabel = ucfirst($obj->label);
607 $typeFilter =
"Text";
613 $typeFilter =
"Numeric";
617 $typeFilter =
"Date";
620 $typeFilter =
"Boolean";
624 $tmpparam = unserialize($obj->param);
626 if ($tmpparam[
'options'] && is_array($tmpparam[
'options'])) {
627 $tmpparam_param_key = array_keys($tmpparam[
'options']);
628 $tmp = array_shift($tmpparam_param_key);
630 if (preg_match(
'/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter =
"List:".$tmp;
633 $this->export_fields_array[$r][$fieldname] = $fieldlabel;
634 $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
635 $this->export_entities_array[$r][$fieldname] =
'order_line';
639 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
640 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
641 if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
642 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
643 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'commande_fournisseur as f';
644 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
645 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as ua1 ON ua1.rowid = f.fk_user_approve';
646 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as ua2 ON ua2.rowid = f.fk_user_approve2';
647 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
648 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'commande_fournisseurdet as fd';
649 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
650 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
651 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
652 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'supplier_order').
')';
653 if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=
' AND sc.fk_user = '.$user->id;
660 $this->import_code[$r] = $this->rights_class.
'_'.$r;
661 $this->import_label[$r] =
"Supplier Invoice";
662 $this->import_icon[$r] = $this->picto;
663 $this->import_entities_array[$r] = [];
664 $this->import_tables_array[$r] = [
'f' => MAIN_DB_PREFIX.
'facture_fourn',
'extra' => MAIN_DB_PREFIX.
'facture_fourn_extrafields'];
665 $this->import_tables_creator_array[$r] = [
'f' =>
'fk_user_author'];
666 $this->import_fields_array[$r] = [
667 'f.ref' =>
'InvoiceRef*',
668 'f.ref_supplier' =>
'RefSupplier',
670 'f.fk_soc' =>
'Supplier/Vendor*',
671 'f.datec' =>
'InvoiceDateCreation',
672 'f.datef' =>
'DateInvoice',
673 'f.date_lim_reglement' =>
'DateMaxPayment',
674 'f.total_ht' =>
'TotalHT',
675 'f.total_ttc' =>
'TotalTTC',
676 'f.total_tva' =>
'TotalVAT',
677 'f.paye' =>
'InvoicePaid',
678 'f.fk_statut' =>
'InvoiceStatus',
679 'f.fk_user_modif' =>
'Modifier Id',
680 'f.fk_user_valid' =>
'Validator Id',
681 'f.fk_facture_source' =>
'Invoice Source Id',
682 'f.fk_projet' =>
'Project Id',
683 'f.fk_account' =>
'Bank Account*',
684 'f.note_public' =>
'InvoiceNote',
685 'f.note_private' =>
'NotePrivate',
686 'f.fk_cond_reglement' =>
'Payment Condition',
687 'f.fk_mode_reglement' =>
'Payment Mode',
688 'f.model_pdf' =>
'Model',
689 'f.date_valid' =>
'Validation Date'
691 if (!empty($conf->multicurrency->enabled)) {
692 $this->import_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
693 $this->import_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
694 $this->import_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
695 $this->import_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
696 $this->import_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
699 $import_extrafield_sample = [];
700 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.
")";
703 while ($obj = $this->
db->fetch_object(
$resql)) {
704 $fieldname =
'extra.'.$obj->name;
705 $fieldlabel = ucfirst($obj->label);
706 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
707 $import_extrafield_sample[$fieldname] = $fieldlabel;
711 $this->import_fieldshidden_array[$r] = [
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facture_fourn'];
712 $this->import_regex_array[$r] = [
'f.ref' =>
'(SI\d{4}-\d{4}|PROV.{1,32}$)',
'f.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'];
714 'f.ref' =>
'(PROV001)',
715 'f.ref_supplier' =>
'Supplier1',
717 'f.fk_soc' =>
'Vendor1',
718 'f.datec' =>
'2021-01-01',
720 'f.date_lim_reglement' =>
'2021-01-30',
721 'f.total_ht' =>
'1000',
722 'f.total_ttc' =>
'1000',
723 'f.total_tva' =>
'0',
725 'f.fk_statut' =>
'0',
726 'f.fk_user_modif' =>
'',
727 'f.fk_user_valid' =>
'',
728 'f.fk_facture_source' =>
'',
730 'f.fk_account' =>
'BANK1',
731 'f.note_public' =>
'Note: ',
732 'f.note_private' =>
'',
733 'f.fk_cond_reglement' =>
'1',
734 'f.fk_mode_reglement' =>
'2',
735 'f.model_pdf' =>
'crab',
736 'f.date_valid' =>
'',
737 'f.multicurrency_code' =>
'USD',
738 'f.multicurrency_tx' =>
'1',
739 'f.multicurrency_total_ht' =>
'1000',
740 'f.multicurrency_total_tva' =>
'0',
741 'f.multicurrency_total_ttc' =>
'1000'
743 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
744 $this->import_updatekeys_array[$r] = [
'f.ref' =>
'Ref'];
745 $this->import_convertvalue_array[$r] = [
747 'f.fk_soc' => [
'rule' =>
'fetchidfromref',
'file' =>
'/societe/class/societe.class.php',
'class' =>
'Societe',
'method' =>
'fetch',
'element' =>
'ThirdParty'],
748 'f.fk_account' => [
'rule' =>
'fetchidfromref',
'file' =>
'/compta/bank/class/account.class.php',
'class' =>
'Account',
'method' =>
'fetch',
'element' =>
'bank_account'],
753 $this->import_code[$r] = $this->rights_class.
'_'.$r;
754 $this->import_label[$r] =
"Supplier Invoice Lines";
755 $this->import_icon[$r] = $this->picto;
756 $this->import_entities_array[$r] = [];
757 $this->import_tables_array[$r] = [
'fd' => MAIN_DB_PREFIX.
'facture_fourn_det',
'extra' => MAIN_DB_PREFIX.
'facture_fourn_det_extrafields'];
758 $this->import_fields_array[$r] = [
759 'fd.fk_facture_fourn' =>
'InvoiceRef*',
760 'fd.fk_parent_line' =>
'FacParentLine',
761 'fd.fk_product' =>
'IdProduct',
762 'fd.label' =>
'Label',
763 'fd.description' =>
'LineDescription',
764 'fd.pu_ht' =>
'PriceUHT',
765 'fd.pu_ttc' =>
'PriceUTTC',
766 'fd.qty' =>
'LineQty',
767 'fd.remise_percent' =>
'Reduc.',
768 'fd.vat_src_code' =>
'Vat Source Code',
769 'fd.product_type' =>
'TypeOfLineServiceOrProduct',
770 'fd.tva_tx' =>
'LineVATRate',
771 'fd.total_ht' =>
'LineTotalHT',
772 'fd.tva' =>
'LineTotalVAT',
773 'fd.total_ttc' =>
'LineTotalTTC',
774 'fd.date_start' =>
'Start Date',
775 'fd.date_end' =>
'End Date',
776 'fd.fk_unit' =>
'Unit'
778 if (!empty($conf->multicurrency->enabled)) {
779 $this->import_fields_array[$r][
'fd.multicurrency_code'] =
'Currency';
780 $this->import_fields_array[$r][
'fd.multicurrency_subprice'] =
'CurrencyRate';
781 $this->import_fields_array[$r][
'fd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
782 $this->import_fields_array[$r][
'fd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
783 $this->import_fields_array[$r][
'fd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
786 $import_extrafield_sample = [];
787 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.
")";
790 while ($obj = $this->
db->fetch_object(
$resql)) {
791 $fieldname =
'extra.'.$obj->name;
792 $fieldlabel = ucfirst($obj->label);
793 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
794 $import_extrafield_sample[$fieldname] = $fieldlabel;
798 $this->import_fieldshidden_array[$r] = [
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facture_fourn_det'];
799 $this->import_regex_array[$r] = [
'fd.product_type' =>
'[0|1]$',
'fd.fk_product' =>
'rowid@'.MAIN_DB_PREFIX.
'product',
'fd.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'];
801 'fd.fk_facture_fourn' =>
'(PROV001)',
802 'fd.fk_parent_line' =>
'',
803 'fd.fk_product' =>
'',
805 'fd.description' =>
'Test Product',
806 'fd.pu_ht' =>
'50000',
807 'fd.pu_ttc' =>
'50000',
809 'fd.remise_percent' =>
'0',
810 'fd.vat_src_code' =>
'',
811 'fd.product_type' =>
'0',
813 'fd.total_ht' =>
'50000',
815 'fd.total_ttc' =>
'50000',
816 'fd.date_start' =>
'',
819 'fd.multicurrency_code' =>
'USD',
820 'fd.multicurrency_tx' =>
'0',
821 'fd.multicurrency_total_ht' =>
'50000',
822 'fd.multicurrency_total_tva' =>
'0',
823 'fd.multicurrency_total_ttc' =>
'50000'
825 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
826 $this->import_updatekeys_array[$r] = [
'fd.rowid' =>
'Row Id',
'fd.fk_facture_fourn' =>
'Invoice Id',
'fd.fk_product' =>
'Product Id'];
827 $this->import_convertvalue_array[$r] = [
828 'fd.fk_facture_fourn' => [
'rule' =>
'fetchidfromref',
'file' =>
'/fourn/class/fournisseur.facture.class.php',
'class' =>
'FactureFournisseur',
'method' =>
'fetch'],
833 $this->import_code[$r] =
'commande_fournisseur_'.$r;
834 $this->import_label[$r] =
'Purchase Orders';
835 $this->import_icon[$r] = $this->picto;
836 $this->import_entities_array[$r] = [];
837 $this->import_tables_array[$r] = [
'c' => MAIN_DB_PREFIX.
'commande_fournisseur',
'extra' => MAIN_DB_PREFIX.
'commande_fournisseur_extrafields'];
838 $this->import_tables_creator_array[$r] = [
'c' =>
'fk_user_author'];
839 $this->import_fields_array[$r] = [
840 'c.ref' =>
'Document Ref*',
841 'c.ref_supplier' =>
'RefSupplier',
842 'c.fk_soc' =>
'ThirdPartyName*',
843 'c.fk_projet' =>
'ProjectId',
844 'c.date_creation' =>
'DateCreation',
845 'c.date_valid' =>
'DateValid',
846 'c.date_approve' =>
'DateApprove',
847 'c.date_commande' =>
'DateOrder',
848 'c.fk_user_modif' =>
'ModifiedById',
849 'c.fk_user_valid' =>
'ValidatedById',
850 'c.fk_user_approve' =>
'ApprovedById',
851 'c.source' =>
'Source',
852 'c.fk_statut' =>
'Status*',
853 'c.billed' =>
'Billed(0/1)',
854 'c.remise_percent' =>
'GlobalDiscount',
855 'c.tva' =>
'TotalTVA',
856 'c.total_ht' =>
'TotalHT',
857 'c.total_ttc' =>
'TotalTTC',
858 'c.note_private' =>
'NotePrivate',
859 'c.note_public' =>
'Note',
860 'c.date_livraison' =>
'DeliveryDate',
861 'c.fk_cond_reglement' =>
'Payment Condition',
862 'c.fk_mode_reglement' =>
'Payment Mode',
863 'c.model_pdf' =>
'Model'
866 if (!empty($conf->multicurrency->enabled)) {
867 $this->import_fields_array[$r][
'c.multicurrency_code'] =
'Currency';
868 $this->import_fields_array[$r][
'c.multicurrency_tx'] =
'CurrencyRate';
869 $this->import_fields_array[$r][
'c.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
870 $this->import_fields_array[$r][
'c.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
871 $this->import_fields_array[$r][
'c.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
875 $import_extrafield_sample = [];
876 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.
")";
880 while ($obj = $this->
db->fetch_object(
$resql)) {
881 $fieldname =
'extra.'.$obj->name;
882 $fieldlabel = ucfirst($obj->label);
883 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
884 $import_extrafield_sample[$fieldname] = $fieldlabel;
889 $this->import_fieldshidden_array[$r] = [
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'commande_fournisseur'];
890 $this->import_regex_array[$r] = [
891 'c.ref' =>
'(PO\d{4}-\d{4}|PORDER.{1,32}$|PROV.{1,32}$)',
892 'c.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'
895 $this->import_updatekeys_array[$r] = [
'c.ref' =>
'Ref'];
896 $this->import_convertvalue_array[$r] = [
898 'rule' =>
'fetchidfromref',
899 'file' =>
'/societe/class/societe.class.php',
900 'class' =>
'Societe',
902 'element' =>
'ThirdParty'
904 'c.fk_mode_reglement' => [
905 'rule' =>
'fetchidfromcodeorlabel',
906 'file' =>
'/compta/paiement/class/cpaiement.class.php',
907 'class' =>
'Cpaiement',
909 'element' =>
'cpayment'
911 'c.source' => [
'rule' =>
'zeroifnull'],
916 $this->import_code[$r] =
'commande_fournisseurdet_'.$r;
917 $this->import_label[$r] =
'PO Lines';
918 $this->import_icon[$r] = $this->picto;
919 $this->import_entities_array[$r] = [];
920 $this->import_tables_array[$r] = [
'cd' => MAIN_DB_PREFIX.
'commande_fournisseurdet',
'extra' => MAIN_DB_PREFIX.
'commande_fournisseurdet_extrafields'];
921 $this->import_fields_array[$r] = [
922 'cd.fk_commande' =>
'Document Ref*',
923 'cd.fk_parent_line' =>
'PrParentLine',
924 'cd.fk_product' =>
'IdProduct',
925 'cd.label' =>
'Label',
926 'cd.description' =>
'LineDescription',
927 'cd.tva_tx' =>
'LineVATRate',
928 'cd.qty' =>
'LineQty',
929 'cd.remise_percent' =>
'Reduc. Percent',
930 'cd.remise' =>
'Reduc.',
931 'cd.subprice' =>
'Sub Price',
932 'cd.total_ht' =>
'LineTotalHT',
933 'cd.total_tva' =>
'LineTotalVAT',
934 'cd.total_ttc' =>
'LineTotalTTC',
935 'cd.product_type' =>
'TypeOfLineServiceOrProduct',
936 'cd.date_start' =>
'Start Date',
937 'cd.date_end' =>
'End Date',
938 'cd.info_bits' =>
'InfoBits',
939 'cd.special_code' =>
'Special Code',
940 'cd.rang' =>
'LinePosition',
941 'cd.fk_unit' =>
'Unit'
944 if (!empty($conf->multicurrency->enabled)) {
945 $this->import_fields_array[$r][
'cd.multicurrency_code'] =
'Currency';
946 $this->import_fields_array[$r][
'cd.multicurrency_subprice'] =
'CurrencyRate';
947 $this->import_fields_array[$r][
'cd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
948 $this->import_fields_array[$r][
'cd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
949 $this->import_fields_array[$r][
'cd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
953 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.
")";
956 while ($obj = $this->
db->fetch_object(
$resql)) {
957 $fieldname =
'extra.'.$obj->name;
958 $fieldlabel = ucfirst($obj->label);
959 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
964 $this->import_fieldshidden_array[$r] = [
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'commande_fournisseurdet'];
965 $this->import_regex_array[$r] = [
966 'cd.product_type' =>
'[0|1]$',
967 'cd.fk_product' =>
'rowid@'.MAIN_DB_PREFIX.
'product',
968 'cd.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'
970 $this->import_updatekeys_array[$r] = [
'cd.fk_commande' =>
'Purchase Order Id'];
971 $this->import_convertvalue_array[$r] = [
972 'cd.fk_commande' => [
973 'rule' =>
'fetchidfromref',
974 'file' =>
'/fourn/class/fournisseur.commande.class.php',
975 'class' =>
'CommandeFournisseur',
977 'element' =>
'order_supplier'
979 'cd.info_bits' => [
'rule' =>
'zeroifnull'],
980 'cd.special_code' => [
'rule' =>
'zeroifnull'],
993 public function init($options =
'')
995 global $conf, $langs;
997 $this->
remove($options);
1000 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/supplier_orders/template_supplier_order.odt';
1001 $dirodt = DOL_DATA_ROOT.
'/doctemplates/supplier_orders';
1002 $dest = $dirodt.
'/template_supplier_order.odt';
1004 if (file_exists($src) && !file_exists($dest))
1006 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1008 $result =
dol_copy($src, $dest, 0, 0);
1011 $langs->load(
"errors");
1012 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
1018 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = '".$this->db->escape($this->const[0][2]).
"' AND type = 'order_supplier' AND entity = ".$conf->entity,
1019 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('".$this->
db->escape($this->
const[0][2]).
"','order_supplier',".$conf->entity.
")",
1022 return $this->
_init($sql, $options);
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
__construct($db)
Constructor.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.
init($options= '')
Function called when module is enabled.
Description and activation class for module Fournisseur.
_init($array_sql, $options= '')
Enables a module.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)