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;
 
  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->
const[$r][0] = 
"SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH";
 
  124     $this->
const[$r][1] = 
"chaine";
 
  125     $this->
const[$r][2] = 
"";
 
  126     $this->
const[$r][3] = 
"";
 
  127     $this->
const[$r][4] = 0;
 
  131     $this->boxes = array(
 
  132       0=>array(
'file'=>
'box_graph_invoices_supplier_permonth.php', 
'enabledbydefaulton'=>
'Home'),
 
  133       1=>array(
'file'=>
'box_graph_orders_supplier_permonth.php', 
'enabledbydefaulton'=>
'Home'),
 
  134       2=>array(
'file'=>
'box_fournisseurs.php', 
'enabledbydefaulton'=>
'Home'),
 
  135       3=>array(
'file'=>
'box_factures_fourn_imp.php', 
'enabledbydefaulton'=>
'Home'),
 
  136       4=>array(
'file'=>
'box_factures_fourn.php', 
'enabledbydefaulton'=>
'Home'),
 
  137       5=>array(
'file'=>
'box_supplier_orders.php', 
'enabledbydefaulton'=>
'Home'),
 
  138       6=>array(
'file'=>
'box_supplier_orders_awaiting_reception.php', 
'enabledbydefaulton'=>
'Home'),
 
  142     $datestart = 
dol_mktime(23, 0, 0, $arraydate[
'mon'], $arraydate[
'mday'], $arraydate[
'year']);
 
  143     $this->cronjobs = array(
 
  145         'label'=>
'RecurringSupplierInvoicesJob',
 
  147         'class'=>
'fourn/class/fournisseur.facture-rec.class.php',
 
  148         'objectname'=>
'FactureFournisseurRec',
 
  149         'method'=>
'createRecurringInvoices',
 
  151         'comment'=>
'Generate recurring supplier invoices',
 
  153         'unitfrequency'=>3600 * 24,
 
  156         'datestart'=>$datestart
 
  161     $this->rights = array();
 
  162     $this->rights_class = 
'fournisseur';
 
  166     $this->rights[$r][0] = 1181;
 
  167     $this->rights[$r][1] = 
'Consulter les fournisseurs';
 
  168     $this->rights[$r][2] = 
'r';
 
  169     $this->rights[$r][3] = 0;
 
  170     $this->rights[$r][4] = 
'lire';
 
  173     $this->rights[$r][0] = 1182;
 
  174     $this->rights[$r][1] = 
'Consulter les commandes fournisseur';
 
  175     $this->rights[$r][2] = 
'r';
 
  176     $this->rights[$r][3] = 0;
 
  177     $this->rights[$r][4] = 
'commande';
 
  178     $this->rights[$r][5] = 
'lire';
 
  181     $this->rights[$r][0] = 1183;
 
  182     $this->rights[$r][1] = 
'Creer une commande fournisseur';
 
  183     $this->rights[$r][2] = 
'w';
 
  184     $this->rights[$r][3] = 0;
 
  185     $this->rights[$r][4] = 
'commande';
 
  186     $this->rights[$r][5] = 
'creer';
 
  189     $this->rights[$r][0] = 1184;
 
  190     $this->rights[$r][1] = 
'Valider une commande fournisseur';
 
  191     $this->rights[$r][2] = 
'w';
 
  192     $this->rights[$r][3] = 0;
 
  193     $this->rights[$r][4] = 
'supplier_order_advance';
 
  194     $this->rights[$r][5] = 
'validate';
 
  197     $this->rights[$r][0] = 1185;
 
  198     $this->rights[$r][1] = 
'Approuver une commande fournisseur';
 
  199     $this->rights[$r][2] = 
'w';
 
  200     $this->rights[$r][3] = 0;
 
  201     $this->rights[$r][4] = 
'commande';
 
  202     $this->rights[$r][5] = 
'approuver';
 
  205     $this->rights[$r][0] = 1186;
 
  206     $this->rights[$r][1] = 
'Commander une commande fournisseur';
 
  207     $this->rights[$r][2] = 
'w';
 
  208     $this->rights[$r][3] = 0;
 
  209     $this->rights[$r][4] = 
'commande';
 
  210     $this->rights[$r][5] = 
'commander';
 
  213     $this->rights[$r][0] = 1187;
 
  214     $this->rights[$r][1] = 
'Receptionner une commande fournisseur';
 
  215     $this->rights[$r][2] = 
'd';
 
  216     $this->rights[$r][3] = 0;
 
  217     $this->rights[$r][4] = 
'commande';
 
  218     $this->rights[$r][5] = 
'receptionner';
 
  221     $this->rights[$r][0] = 1189;
 
  222     $this->rights[$r][1] = 
'Check/Uncheck a supplier order reception';
 
  223     $this->rights[$r][2] = 
'w';
 
  224     $this->rights[$r][3] = 0;
 
  225     $this->rights[$r][4] = 
'commande_advance';
 
  226     $this->rights[$r][5] = 
'check';
 
  229     $this->rights[$r][0] = 1188;
 
  230     $this->rights[$r][1] = 
'Supprimer une commande fournisseur';
 
  231     $this->rights[$r][2] = 
'd';
 
  232     $this->rights[$r][3] = 0;
 
  233     $this->rights[$r][4] = 
'commande';
 
  234     $this->rights[$r][5] = 
'supprimer';
 
  236     if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) {
 
  238       $this->rights[$r][0] = 1190;
 
  239       $this->rights[$r][1] = 
'Approve supplier order (second level)'; 
 
  240       $this->rights[$r][2] = 
'w';
 
  241       $this->rights[$r][3] = 0;
 
  242       $this->rights[$r][4] = 
'commande';
 
  243       $this->rights[$r][5] = 
'approve2';
 
  247     $this->rights[$r][0] = 1191;
 
  248     $this->rights[$r][1] = 
'Exporter les commande fournisseurs, attributs';
 
  249     $this->rights[$r][2] = 
'r';
 
  250     $this->rights[$r][3] = 0;
 
  251     $this->rights[$r][4] = 
'commande';
 
  252     $this->rights[$r][5] = 
'export';
 
  255     $this->rights[$r][0] = 1231;
 
  256     $this->rights[$r][1] = 
'Consulter les factures fournisseur';
 
  257     $this->rights[$r][2] = 
'r';
 
  258     $this->rights[$r][3] = 0;
 
  259     $this->rights[$r][4] = 
'facture';
 
  260     $this->rights[$r][5] = 
'lire';
 
  263     $this->rights[$r][0] = 1232;
 
  264     $this->rights[$r][1] = 
'Creer une facture fournisseur';
 
  265     $this->rights[$r][2] = 
'w';
 
  266     $this->rights[$r][3] = 0;
 
  267     $this->rights[$r][4] = 
'facture';
 
  268     $this->rights[$r][5] = 
'creer';
 
  271     $this->rights[$r][0] = 1233;
 
  272     $this->rights[$r][1] = 
'Valider une facture fournisseur';
 
  273     $this->rights[$r][2] = 
'w';
 
  274     $this->rights[$r][3] = 0;
 
  275     $this->rights[$r][4] = 
'supplier_invoice_advance';
 
  276     $this->rights[$r][5] = 
'validate';
 
  279     $this->rights[$r][0] = 1234;
 
  280     $this->rights[$r][1] = 
'Supprimer une facture fournisseur';
 
  281     $this->rights[$r][2] = 
'd';
 
  282     $this->rights[$r][3] = 0;
 
  283     $this->rights[$r][4] = 
'facture';
 
  284     $this->rights[$r][5] = 
'supprimer';
 
  287     $this->rights[$r][0] = 1235;
 
  288     $this->rights[$r][1] = 
'Envoyer les factures par mail';
 
  289     $this->rights[$r][2] = 
'a';
 
  290     $this->rights[$r][3] = 0;
 
  291     $this->rights[$r][4] = 
'supplier_invoice_advance';
 
  292     $this->rights[$r][5] = 
'send';
 
  295     $this->rights[$r][0] = 1236;
 
  296     $this->rights[$r][1] = 
'Exporter les factures fournisseurs, attributs et reglements';
 
  297     $this->rights[$r][2] = 
'r';
 
  298     $this->rights[$r][3] = 0;
 
  299     $this->rights[$r][4] = 
'facture';
 
  300     $this->rights[$r][5] = 
'export';
 
  313     $this->export_code[$r] = $this->rights_class.
'_'.$r;
 
  314     $this->export_label[$r] = 
'Vendor invoices and lines of invoices';
 
  315     $this->export_icon[$r] = 
'invoice';
 
  316     $this->export_permission[$r] = array(array(
"fournisseur", 
"facture", 
"export"));
 
  317     $this->export_fields_array[$r] = array(
 
  318       's.rowid'=>
"IdCompany", 
's.nom'=>
'CompanyName', 
'ps.nom'=>
'ParentCompany', 
's.address'=>
'Address', 
's.zip'=>
'Zip', 
's.town'=>
'Town', 
'c.code'=>
'CountryCode', 
's.phone'=>
'Phone',
 
  319       's.siren'=>
'ProfId1', 
's.siret'=>
'ProfId2', 
's.ape'=>
'ProfId3', 
's.idprof4'=>
'ProfId4', 
's.idprof5'=>
'ProfId5', 
's.idprof6'=>
'ProfId6',
 
  320       's.code_compta'=>
'CustomerAccountancyCode', 
's.code_compta_fournisseur'=>
'SupplierAccountancyCode', 
's.tva_intra'=>
'VATIntra',
 
  321       'f.rowid'=>
"InvoiceId", 
'f.ref'=>
"InvoiceRef", 
'f.ref_supplier'=>
"RefSupplier", 
'f.datec'=>
"InvoiceDateCreation", 
'f.datef'=>
"DateInvoice", 
'f.date_lim_reglement'=>
'DateMaxPayment',
 
  322       'f.total_ht'=>
"TotalHT", 
'f.total_ttc'=>
"TotalTTC", 
'f.total_tva'=>
"TotalVAT", 
'f.paye'=>
"InvoicePaid", 
'f.fk_statut'=>
'InvoiceStatus', 
'f.note_public'=>
"InvoiceNote",
 
  323       'fd.rowid'=>
'LineId', 
'fd.description'=>
"LineDescription", 
'fd.tva_tx'=>
"LineVATRate", 
'fd.qty'=>
"LineQty", 
'fd.remise_percent'=>
"Discount", 
'fd.total_ht'=>
"LineTotalHT",
 
  324       'fd.total_ttc'=>
"LineTotalTTC", 
'fd.tva'=>
"LineTotalVAT", 
'fd.date_start'=>
"DateStart", 
'fd.date_end'=>
"DateEnd", 
'fd.special_code'=>
'SpecialCode',
 
  325       'fd.product_type'=>
'TypeOfLineServiceOrProduct', 
'fd.fk_product'=>
'ProductId',
 
  326       'p.ref'=>
'ProductRef', 
'p.label'=>
'ProductLabel', 
'p.accountancy_code_buy'=>
'ProductAccountancyBuyCode', 
'project.rowid'=>
'ProjectId',
 
  327       'project.ref'=>
'ProjectRef', 
'project.title'=>
'ProjectLabel' 
  330       $this->export_fields_array[$r][
'f.multicurrency_code'] = 
'Currency';
 
  331       $this->export_fields_array[$r][
'f.multicurrency_tx'] = 
'CurrencyRate';
 
  332       $this->export_fields_array[$r][
'f.multicurrency_total_ht'] = 
'MulticurrencyAmountHT';
 
  333       $this->export_fields_array[$r][
'f.multicurrency_total_tva'] = 
'MulticurrencyAmountVAT';
 
  334       $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] = 
'MulticurrencyAmountTTC';
 
  342     $this->export_TypeFields_array[$r] = array(
 
  343       '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',
 
  344       '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',
 
  345       '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",
 
  346       '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",
 
  347       'fd.product_type'=>
'Numeric', 
'fd.fk_product'=>
'List:product:label',
 
  348       'p.ref'=>
'Text', 
'p.label'=>
'Text', 
'project.ref'=>
'Text', 
'project.title'=>
'Text' 
  350     $this->export_entities_array[$r] = array(
 
  351       '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',
 
  352       '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",
 
  353       '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",
 
  354       '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",
 
  355       '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",
 
  356       'fd.product_type'=>
'invoice_line', 
'fd.fk_product'=>
'product',
 
  357       'p.ref'=>
'product', 
'p.label'=>
'product', 
'p.accountancy_code_buy'=>
'product', 
'project.rowid'=>
'project', 
'project.ref'=>
'project', 
'project.title'=>
'project' 
  359     $this->export_dependencies_array[$r] = array(
'invoice_line'=>
'fd.rowid', 
'product'=>
'fd.rowid'); 
 
  361     $keyforselect = 
'facture_fourn';
 
  362     $keyforelement = 
'invoice';
 
  363     $keyforaliasextra = 
'extra';
 
  364     include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
 
  365     $keyforselect = 
'facture_fourn_det';
 
  366     $keyforelement = 
'invoice_line';
 
  367     $keyforaliasextra = 
'extraline';
 
  368     include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
 
  370     $this->export_sql_start[$r] = 
'SELECT DISTINCT ';
 
  371     $this->export_sql_end[$r]  = 
' FROM '.MAIN_DB_PREFIX.
'societe as s';
 
  372     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON ps.rowid = s.parent';
 
  373     if (is_object($user) && empty($user->rights->societe->client->voir)) {
 
  374       $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
 
  376     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
 
  377     $this->export_sql_end[$r] .= 
' '.MAIN_DB_PREFIX.
'facture_fourn as f';
 
  378     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
 
  379     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
 
  380     $this->export_sql_end[$r] .= 
' , '.MAIN_DB_PREFIX.
'facture_fourn_det as fd';
 
  381     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
 
  382     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
 
  383     $this->export_sql_end[$r] .= 
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
 
  384     $this->export_sql_end[$r] .= 
' AND f.entity IN ('.getEntity(
'supplier_invoice').
')';
 
  385     if (is_object($user) && empty($user->rights->societe->client->voir)) {
 
  386       $this->export_sql_end[$r] .= 
' AND sc.fk_user = '.((int) $user->id);
 
  390     $this->export_code[$r] = $this->rights_class.
'_'.$r;
 
  391     $this->export_label[$r] = 
'Factures fournisseurs et reglements';
 
  392     $this->export_icon[$r] = 
'invoice';
 
  393     $this->export_permission[$r] = array(array(
"fournisseur", 
"facture", 
"export"));
 
  394     $this->export_fields_array[$r] = array(
 
  395       's.rowid'=>
"IdCompany", 
's.nom'=>
'CompanyName', 
's.address'=>
'Address', 
's.zip'=>
'Zip', 
's.town'=>
'Town', 
'c.code'=>
'CountryCode', 
's.phone'=>
'Phone',
 
  396       's.siren'=>
'ProfId1', 
's.siret'=>
'ProfId2', 
's.ape'=>
'ProfId3', 
's.idprof4'=>
'ProfId4', 
's.idprof5'=>
'ProfId5', 
's.idprof6'=>
'ProfId6',
 
  397       's.code_compta'=>
'CustomerAccountancyCode', 
's.code_compta_fournisseur'=>
'SupplierAccountancyCode', 
's.tva_intra'=>
'VATIntra',
 
  398       'f.rowid'=>
"InvoiceId", 
'f.ref'=>
"InvoiceRef", 
'f.ref_supplier'=>
"RefSupplier", 
'f.datec'=>
"InvoiceDateCreation",
 
  399       'f.datef'=>
"DateInvoice", 
'f.total_ht'=>
"TotalHT", 
'f.total_ttc'=>
"TotalTTC", 
'f.total_tva'=>
"TotalVAT", 
'f.paye'=>
"InvoicePaid",
 
  400       'f.fk_statut'=>
'InvoiceStatus', 
'f.note_public'=>
"InvoiceNote", 
'p.rowid'=>
'PaymentId', 
'pf.amount'=>
'AmountPayment',
 
  401       'p.datep'=>
'DatePayment', 
'p.num_paiement'=>
'PaymentNumber', 
'p.fk_bank'=>
'IdTransaction', 
'project.rowid'=>
'ProjectId', 
'project.ref'=>
'ProjectRef', 
'project.title'=>
'ProjectLabel' 
  404       $this->export_fields_array[$r][
'f.multicurrency_code'] = 
'Currency';
 
  405       $this->export_fields_array[$r][
'f.multicurrency_tx'] = 
'CurrencyRate';
 
  406       $this->export_fields_array[$r][
'f.multicurrency_total_ht'] = 
'MulticurrencyAmountHT';
 
  407       $this->export_fields_array[$r][
'f.multicurrency_total_tva'] = 
'MulticurrencyAmountVAT';
 
  408       $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] = 
'MulticurrencyAmountTTC';
 
  416     $this->export_TypeFields_array[$r] = array(
 
  417       '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',
 
  418       '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",
 
  419       'f.total_ttc'=>
"Numeric", 
'f.total_tva'=>
"Numeric", 
'f.paye'=>
"Boolean", 
'f.fk_statut'=>
'Status', 
'f.note_public'=>
"Text", 
'pf.amount'=>
'Numeric',
 
  420       'p.datep'=>
'Date', 
'p.num_paiement'=>
'Numeric', 
'p.fk_bank'=>
'Numeric', 
'project.ref'=>
'Text', 
'project.title'=>
'Text' 
  422     $this->export_entities_array[$r] = array(
 
  423       's.rowid'=>
"company", 
's.nom'=>
'company', 
's.address'=>
'company', 
's.zip'=>
'company', 
's.town'=>
'company', 
'c.code'=>
'company', 
's.phone'=>
'company',
 
  424       's.siren'=>
'company', 
's.siret'=>
'company', 
's.ape'=>
'company', 
's.idprof4'=>
'company', 
's.idprof5'=>
'company', 
's.idprof6'=>
'company',
 
  425       's.code_compta'=>
'company', 
's.code_compta_fournisseur'=>
'company', 
's.tva_intra'=>
'company',
 
  426       'f.rowid'=>
"invoice", 
'f.ref'=>
"invoice", 
'f.ref_supplier'=>
"invoice", 
'f.datec'=>
"invoice", 
'f.datef'=>
"invoice", 
'f.total_ht'=>
"invoice",
 
  427       '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',
 
  428       'p.datep'=>
'payment', 
'p.num_paiement'=>
'payment', 
'p.fk_bank'=>
'account', 
'project.rowid'=>
'project', 
'project.ref'=>
'project', 
'project.title'=>
'project');
 
  429     $this->export_dependencies_array[$r] = array(
'payment'=>
'p.rowid'); 
 
  431     $keyforselect = 
'facture_fourn';
 
  432     $keyforelement = 
'invoice';
 
  433     $keyforaliasextra = 
'extra';
 
  434     include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
 
  436     $this->export_sql_start[$r] = 
'SELECT DISTINCT ';
 
  437     $this->export_sql_end[$r]  = 
' FROM '.MAIN_DB_PREFIX.
'societe as s';
 
  438     if (is_object($user) && empty($user->rights->societe->client->voir)) {
 
  439       $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
 
  441     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
 
  442     $this->export_sql_end[$r] .= 
' '.MAIN_DB_PREFIX.
'facture_fourn as f';
 
  443     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
 
  444     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
 
  445     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
 
  446     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
 
  447     $this->export_sql_end[$r] .= 
' WHERE f.fk_soc = s.rowid';
 
  448     $this->export_sql_end[$r] .= 
' AND f.entity IN ('.getEntity(
'supplier_invoice').
')';
 
  449     if (is_object($user) && empty($user->rights->societe->client->voir)) {
 
  450       $this->export_sql_end[$r] .= 
' AND sc.fk_user = '.((int) $user->id);
 
  455     $this->export_code[$r] = $this->rights_class.
'_'.$r;
 
  456     $this->export_label[$r] = 
'Purchase Orders and lines of purchase orders';
 
  457     $this->export_icon[$r] = 
'order';
 
  458     $this->export_permission[$r] = array(array(
"fournisseur", 
"commande", 
"export"));
 
  459     $this->export_fields_array[$r] = array(
 
  460       's.rowid'=>
"IdCompany", 
's.nom'=>
'CompanyName', 
'ps.nom'=>
'ParentCompany', 
's.address'=>
'Address', 
's.zip'=>
'Zip', 
's.town'=>
'Town', 
'c.code'=>
'CountryCode', 
's.phone'=>
'Phone',
 
  461       's.siren'=>
'ProfId1', 
's.siret'=>
'ProfId2', 
's.ape'=>
'ProfId3', 
's.idprof4'=>
'ProfId4', 
's.idprof5'=>
'ProfId5', 
's.idprof6'=>
'ProfId6', 
's.tva_intra'=>
'VATIntra',
 
  462       'f.rowid'=>
"OrderId", 
'f.ref'=>
"Ref", 
'f.ref_supplier'=>
"RefSupplier", 
'f.date_creation'=>
"DateCreation", 
'f.date_commande'=>
"OrderDate", 
'f.date_livraison'=>
"DateDeliveryPlanned",
 
  463       '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',
 
  464       'f.note_public'=>
"NotePublic", 
'f.note_private'=>
"NotePrivate", 
'uv.login'=>
'UserValidation', 
'ua1.login'=>
'ApprovedBy', 
'ua2.login'=>
'ApprovedBy2', 
'fd.rowid'=>
'LineId', 
'fd.description'=>
"LineDescription",
 
  465       'fd.tva_tx'=>
"LineVATRate", 
'fd.qty'=>
"LineQty", 
'fd.remise_percent'=>
"Discount", 
'fd.total_ht'=>
"LineTotalHT", 
'fd.total_ttc'=>
"LineTotalTTC",
 
  466       'fd.total_tva'=>
"LineTotalVAT", 
'fd.date_start'=>
"DateStart", 
'fd.date_end'=>
"DateEnd", 
'fd.special_code'=>
'SpecialCode',
 
  467       'fd.product_type'=>
'TypeOfLineServiceOrProduct', 
'fd.ref'=>
'RefSupplier', 
'fd.fk_product'=>
'ProductId',
 
  468       'p.ref'=>
'ProductRef', 
'p.label'=>
'ProductLabel', 
'project.rowid'=>
'ProjectId', 
'project.ref'=>
'ProjectRef', 
'project.title'=>
'ProjectLabel' 
  471       $this->export_fields_array[$r][
'f.multicurrency_code'] = 
'Currency';
 
  472       $this->export_fields_array[$r][
'f.multicurrency_tx'] = 
'CurrencyRate';
 
  473       $this->export_fields_array[$r][
'f.multicurrency_total_ht'] = 
'MulticurrencyAmountHT';
 
  474       $this->export_fields_array[$r][
'f.multicurrency_total_tva'] = 
'MulticurrencyAmountVAT';
 
  475       $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] = 
'MulticurrencyAmountTTC';
 
  477     if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) {
 
  478       unset($this->export_fields_array[
'f.date_approve2']);
 
  479       unset($this->export_fields_array[
'ua2.login']);
 
  481     $this->export_TypeFields_array[$r] = array(
 
  482       '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',
 
  483       '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",
 
  484       'f.date_creation'=>
"Date", 
'f.date_commande'=>
"Date", 
'f.date_livraison'=>
"Date", 
'f.total_ht'=>
"Numeric", 
'f.total_ttc'=>
"Numeric", 
'f.total_tva'=>
"Numeric",
 
  485       '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",
 
  486       'fd.tva_tx'=>
"Numeric", 
'fd.qty'=>
"Numeric", 
'fd.remise_percent'=>
"Numeric", 
'fd.total_ht'=>
"Numeric", 
'fd.total_ttc'=>
"Numeric", 
'fd.total_tva'=>
"Numeric",
 
  487       'fd.date_start'=>
"Date", 
'fd.date_end'=>
"Date", 
'fd.special_code'=>
"Numeric",
 
  488       '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' 
  490     $this->export_entities_array[$r] = array(
 
  491       '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',
 
  492       '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',
 
  493       '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",
 
  494       '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",
 
  495       'fd.product_type'=>
'order_line', 
'fd.ref'=>
'order_line', 
'fd.fk_product'=>
'product',
 
  496       'p.ref'=>
'product', 
'p.label'=>
'product', 
'project.rowid'=>
'project', 
'project.ref'=>
'project', 
'project.title'=>
'project' 
  498     $this->export_dependencies_array[$r] = array(
'order_line'=>
'fd.rowid', 
'product'=>
'fd.rowid'); 
 
  500     $keyforselect = 
'commande_fournisseur';
 
  501     $keyforelement = 
'order';
 
  502     $keyforaliasextra = 
'extra';
 
  503     include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
 
  506     $keyforselect = 
'commande_fournisseurdet';
 
  507     $keyforelement = 
'order_line';
 
  508     $keyforaliasextra = 
'extraline';
 
  509     include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
 
  511     $this->export_sql_start[$r] = 
'SELECT DISTINCT ';
 
  512     $this->export_sql_end[$r]  = 
' FROM '.MAIN_DB_PREFIX.
'societe as s';
 
  513     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON ps.rowid = s.parent';
 
  514     if (is_object($user) && empty($user->rights->societe->client->voir)) {
 
  515       $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
 
  517     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid,';
 
  518     $this->export_sql_end[$r] .= 
' '.MAIN_DB_PREFIX.
'commande_fournisseur as f';
 
  519     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as project on (f.fk_projet = project.rowid)';
 
  520     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uv ON uv.rowid = f.fk_user_valid';
 
  521     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as ua1 ON ua1.rowid = f.fk_user_approve';
 
  522     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as ua2 ON ua2.rowid = f.fk_user_approve2';
 
  523     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
 
  524     $this->export_sql_end[$r] .= 
' '.MAIN_DB_PREFIX.
'commande_fournisseurdet as fd';
 
  525     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
 
  526     $this->export_sql_end[$r] .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
 
  527     $this->export_sql_end[$r] .= 
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
 
  528     $this->export_sql_end[$r] .= 
' AND f.entity IN ('.getEntity(
'supplier_order').
')';
 
  529     if (is_object($user) && empty($user->rights->societe->client->voir)) {
 
  530       $this->export_sql_end[$r] .= 
' AND sc.fk_user = '.((int) $user->id);
 
  538     $this->import_code[$r] = $this->rights_class.
'_'.$r;
 
  539     $this->import_label[$r] = 
"SupplierInvoices"; 
 
  540     $this->import_icon[$r] = $this->picto;
 
  541     $this->import_entities_array[$r] = array(); 
 
  542     $this->import_tables_array[$r] = array(
'f' => MAIN_DB_PREFIX.
'facture_fourn', 
'extra' => MAIN_DB_PREFIX.
'facture_fourn_extrafields');
 
  543     $this->import_tables_creator_array[$r] = array(
'f' => 
'fk_user_author'); 
 
  544     $this->import_fields_array[$r] = array(
 
  545       'f.ref' => 
'InvoiceRef*',
 
  546       'f.ref_supplier' => 
'RefSupplier',
 
  548       'f.fk_soc' => 
'Supplier/Vendor*',
 
  549       'f.datec' => 
'InvoiceDateCreation',
 
  550       'f.datef' => 
'DateInvoice',
 
  551       'f.date_lim_reglement' => 
'DateMaxPayment',
 
  552       'f.total_ht' => 
'TotalHT',
 
  553       'f.total_ttc' => 
'TotalTTC',
 
  554       'f.total_tva' => 
'TotalVAT',
 
  555       'f.paye' => 
'InvoicePaid',
 
  556       'f.fk_statut' => 
'InvoiceStatus',
 
  557       'f.fk_user_modif' => 
'Modifier Id',
 
  558       'f.fk_user_valid' => 
'Validator Id',
 
  559       'f.fk_facture_source' => 
'Invoice Source Id',
 
  560       'f.fk_projet' => 
'Project Id',
 
  561       'f.fk_account' => 
'Bank Account*',
 
  562       'f.note_public' => 
'InvoiceNote',
 
  563       'f.note_private' => 
'NotePrivate',
 
  564       'f.fk_cond_reglement' => 
'Payment Condition',
 
  565       'f.fk_mode_reglement' => 
'Payment Mode',
 
  566       'f.model_pdf' => 
'Model',
 
  567       'f.date_valid' => 
'Validation Date' 
  570       $this->import_fields_array[$r][
'f.multicurrency_code'] = 
'Currency';
 
  571       $this->import_fields_array[$r][
'f.multicurrency_tx'] = 
'CurrencyRate';
 
  572       $this->import_fields_array[$r][
'f.multicurrency_total_ht'] = 
'MulticurrencyAmountHT';
 
  573       $this->import_fields_array[$r][
'f.multicurrency_total_tva'] = 
'MulticurrencyAmountVAT';
 
  574       $this->import_fields_array[$r][
'f.multicurrency_total_ttc'] = 
'MulticurrencyAmountTTC';
 
  577     $import_extrafield_sample = array();
 
  578     $sql = 
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.
")";
 
  581       while ($obj = $this->
db->fetch_object(
$resql)) {
 
  582         $fieldname = 
'extra.'.$obj->name;
 
  583         $fieldlabel = ucfirst($obj->label);
 
  584         $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? 
'*' : 
'');
 
  585         $import_extrafield_sample[$fieldname] = $fieldlabel;
 
  589     $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' => 
'lastrowid-'.MAIN_DB_PREFIX.
'facture_fourn');
 
  590     if (empty($conf->multicurrency->enabled)) {
 
  591       $this->import_fieldshidden_array[$r][
'f.multicurrency_code'] = 
'const-'.$conf->currency;
 
  593     $this->import_regex_array[$r] = array(
'f.ref' => 
'(SI\d{4}-\d{4}|PROV.{1,32}$)', 
'f.multicurrency_code' => 
'code@'.MAIN_DB_PREFIX.
'multicurrency');
 
  594     $import_sample = array(
 
  595       'f.ref' => 
'(PROV001)',
 
  596       'f.ref_supplier' => 
'Supplier1',
 
  598       'f.fk_soc' => 
'Vendor1',
 
  599       'f.datec' => 
'2021-01-01',
 
  601       'f.date_lim_reglement' => 
'2021-01-30',
 
  602       'f.total_ht' => 
'1000',
 
  603       'f.total_ttc' => 
'1000',
 
  604       'f.total_tva' => 
'0',
 
  606       'f.fk_statut' => 
'0',
 
  607       'f.fk_user_modif' => 
'',
 
  608       'f.fk_user_valid' => 
'',
 
  609       'f.fk_facture_source' => 
'',
 
  611       'f.fk_account' => 
'BANK1',
 
  612       'f.note_public' => 
'Note: ',
 
  613       'f.note_private' => 
'',
 
  614       'f.fk_cond_reglement' => 
'1',
 
  615       'f.fk_mode_reglement' => 
'2',
 
  616       'f.model_pdf' => 
'crab',
 
  617       'f.date_valid' => 
'',
 
  618       'f.multicurrency_code' => 
'USD',
 
  619       'f.multicurrency_tx' => 
'1',
 
  620       'f.multicurrency_total_ht' => 
'1000',
 
  621       'f.multicurrency_total_tva' => 
'0',
 
  622       'f.multicurrency_total_ttc' => 
'1000' 
  624     $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
 
  625     $this->import_updatekeys_array[$r] = array(
'f.ref' => 
'Ref');
 
  626     $this->import_convertvalue_array[$r] = array(
 
  628         'rule'=>
'getrefifauto',
 
  629         'class'=>(empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) ? 
'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER),
 
  630         'path'=>
"/core/modules/supplier_invoice/".(empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) ? 
'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER).
'.php',
 
  631         'classobject'=>
'FactureFournisseur',
 
  632         'pathobject'=>
'/fourn/class/fournisseur.facture.class.php',
 
  634       'f.fk_soc' => array(
'rule' => 
'fetchidfromref', 
'file' => 
'/societe/class/societe.class.php', 
'class' => 
'Societe', 
'method' => 
'fetch', 
'element' => 
'ThirdParty'),
 
  635       'f.fk_account' => array(
'rule' => 
'fetchidfromref', 
'file' => 
'/compta/bank/class/account.class.php', 
'class' => 
'Account', 
'method' => 
'fetch', 
'element' => 
'bank_account'),
 
  640     $this->import_code[$r] = $this->rights_class.
'_'.$r;
 
  641     $this->import_label[$r] = 
"SupplierInvoiceLines"; 
 
  642     $this->import_icon[$r] = $this->picto;
 
  643     $this->import_entities_array[$r] = array(); 
 
  644     $this->import_tables_array[$r] = array(
'fd' => MAIN_DB_PREFIX.
'facture_fourn_det', 
'extra' => MAIN_DB_PREFIX.
'facture_fourn_det_extrafields');
 
  645     $this->import_fields_array[$r] = array(
 
  646       'fd.fk_facture_fourn' => 
'InvoiceRef*',
 
  647       'fd.fk_parent_line' => 
'ParentLine',
 
  648       'fd.fk_product' => 
'IdProduct',
 
  649       'fd.description' => 
'LineDescription',
 
  650       'fd.pu_ht' => 
'PriceUHT',
 
  651       'fd.pu_ttc' => 
'PriceUTTC',
 
  652       'fd.qty' => 
'LineQty',
 
  653       'fd.remise_percent' => 
'Reduc.',
 
  654       'fd.vat_src_code' => 
'Vat Source Code',
 
  655       'fd.product_type' => 
'TypeOfLineServiceOrProduct',
 
  656       'fd.tva_tx' => 
'LineVATRate',
 
  657       'fd.total_ht' => 
'LineTotalHT',
 
  658       'fd.tva' => 
'LineTotalVAT',
 
  659       'fd.total_ttc' => 
'LineTotalTTC',
 
  660       'fd.date_start' => 
'Start Date',
 
  661       'fd.date_end' => 
'End Date',
 
  662       'fd.fk_unit' => 
'Unit' 
  665       $this->import_fields_array[$r][
'fd.multicurrency_code'] = 
'Currency';
 
  666       $this->import_fields_array[$r][
'fd.multicurrency_subprice'] = 
'CurrencyRate';
 
  667       $this->import_fields_array[$r][
'fd.multicurrency_total_ht'] = 
'MulticurrencyAmountHT';
 
  668       $this->import_fields_array[$r][
'fd.multicurrency_total_tva'] = 
'MulticurrencyAmountVAT';
 
  669       $this->import_fields_array[$r][
'fd.multicurrency_total_ttc'] = 
'MulticurrencyAmountTTC';
 
  672     $import_extrafield_sample = array();
 
  673     $sql = 
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.
")";
 
  676       while ($obj = $this->
db->fetch_object(
$resql)) {
 
  677         $fieldname = 
'extra.'.$obj->name;
 
  678         $fieldlabel = ucfirst($obj->label);
 
  679         $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? 
'*' : 
'');
 
  680         $import_extrafield_sample[$fieldname] = $fieldlabel;
 
  684     $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' => 
'lastrowid-'.MAIN_DB_PREFIX.
'facture_fourn_det');
 
  685     $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');
 
  686     $import_sample = array(
 
  687       'fd.fk_facture_fourn' => 
'(PROV001)',
 
  688       'fd.fk_parent_line' => 
'',
 
  689       'fd.fk_product' => 
'',
 
  690       'fd.description' => 
'Test Product',
 
  691       'fd.pu_ht' => 
'50000',
 
  692       'fd.pu_ttc' => 
'50000',
 
  694       'fd.remise_percent' => 
'0',
 
  695       'fd.vat_src_code' => 
'',
 
  696       'fd.product_type' => 
'0',
 
  698       'fd.total_ht' => 
'50000',
 
  700       'fd.total_ttc' => 
'50000',
 
  701       'fd.date_start' => 
'',
 
  704       'fd.multicurrency_code' => 
'USD',
 
  705       'fd.multicurrency_tx' => 
'0',
 
  706       'fd.multicurrency_total_ht' => 
'50000',
 
  707       'fd.multicurrency_total_tva' => 
'0',
 
  708       'fd.multicurrency_total_ttc' => 
'50000' 
  710     $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
 
  711     $this->import_updatekeys_array[$r] = array(
'fd.rowid' => 
'Row Id', 
'fd.fk_facture_fourn' => 
'Invoice Id', 
'fd.fk_product' => 
'Product Id');
 
  712     $this->import_convertvalue_array[$r] = array(
 
  713       'fd.fk_facture_fourn' => array(
'rule' => 
'fetchidfromref', 
'file' => 
'/fourn/class/fournisseur.facture.class.php', 
'class' => 
'FactureFournisseur', 
'method' => 
'fetch'),
 
  718     $this->import_code[$r] = 
'commande_fournisseur_'.$r;
 
  719     $this->import_label[$r] = 
'SuppliersOrders';
 
  720     $this->import_icon[$r] = $this->picto;
 
  721     $this->import_entities_array[$r] = array();
 
  722     $this->import_tables_array[$r] = array(
'c' => MAIN_DB_PREFIX.
'commande_fournisseur', 
'extra' => MAIN_DB_PREFIX.
'commande_fournisseur_extrafields');
 
  723     $this->import_tables_creator_array[$r] = array(
'c' => 
'fk_user_author'); 
 
  724     $this->import_fields_array[$r] = array(
 
  726       'c.ref_supplier'      => 
'RefSupplier',
 
  727       'c.fk_soc'            => 
'ThirdPartyName*',
 
  728       'c.fk_projet'         => 
'ProjectId',
 
  729       'c.date_creation'     => 
'DateCreation',
 
  730       'c.date_valid'        => 
'DateValid',
 
  731       'c.date_approve'      => 
'DateApprove',
 
  732       'c.date_commande'     => 
'DateOrder',
 
  733       'c.fk_user_modif'     => 
'ModifiedById',
 
  734       'c.fk_user_valid'     => 
'ValidatedById',
 
  735       'c.fk_user_approve'   => 
'ApprovedById',
 
  736       'c.source'            => 
'Source',
 
  737       'c.fk_statut'         => 
'Status*',
 
  738       'c.billed'            => 
'Billed(0/1)',
 
  739       'c.total_tva'         => 
'TotalTVA',
 
  740       'c.total_ht'          => 
'TotalHT',
 
  741       'c.total_ttc'         => 
'TotalTTC',
 
  742       'c.note_private'      => 
'NotePrivate',
 
  743       'c.note_public'       => 
'Note',
 
  744       'c.date_livraison'    => 
'DeliveryDate',
 
  745       'c.fk_cond_reglement' => 
'Payment Condition',
 
  746       'c.fk_mode_reglement' => 
'Payment Mode',
 
  747       'c.model_pdf'         => 
'Model' 
  751       $this->import_fields_array[$r][
'c.multicurrency_code']      = 
'Currency';
 
  752       $this->import_fields_array[$r][
'c.multicurrency_tx']        = 
'CurrencyRate';
 
  753       $this->import_fields_array[$r][
'c.multicurrency_total_ht']  = 
'MulticurrencyAmountHT';
 
  754       $this->import_fields_array[$r][
'c.multicurrency_total_tva'] = 
'MulticurrencyAmountVAT';
 
  755       $this->import_fields_array[$r][
'c.multicurrency_total_ttc'] = 
'MulticurrencyAmountTTC';
 
  759     $import_extrafield_sample = array();
 
  760     $sql = 
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.
")";
 
  764       while ($obj = $this->
db->fetch_object(
$resql)) {
 
  765         $fieldname = 
'extra.'.$obj->name;
 
  766         $fieldlabel = ucfirst($obj->label);
 
  767         $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? 
'*' : 
'');
 
  768         $import_extrafield_sample[$fieldname] = $fieldlabel;
 
  773     $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' => 
'lastrowid-'.MAIN_DB_PREFIX.
'commande_fournisseur');
 
  774     $this->import_regex_array[$r] = array(
 
  775       'c.multicurrency_code' => 
'code@'.MAIN_DB_PREFIX.
'multicurrency' 
  778     $this->import_updatekeys_array[$r] = array(
'c.ref' => 
'Ref');
 
  779     $this->import_convertvalue_array[$r] = array(
 
  781         'rule'=>
'getrefifauto',
 
  782         'class'=>(empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) ? 
'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER),
 
  783         'path'=>
"/core/modules/supplier_order/".(empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) ? 
'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER).
'.php',
 
  784         'classobject'=>
'CommandeFournisseur',
 
  785         'pathobject'=>
'/fourn/class/fournisseur.commande.class.php',
 
  788         'rule'    => 
'fetchidfromref',
 
  789         'file'    => 
'/societe/class/societe.class.php',
 
  790         'class'   => 
'Societe',
 
  792         'element' => 
'ThirdParty' 
  794       'c.fk_mode_reglement' => array(
 
  795         'rule' => 
'fetchidfromcodeorlabel',
 
  796         'file' => 
'/compta/paiement/class/cpaiement.class.php',
 
  797         'class' => 
'Cpaiement',
 
  799         'element' => 
'cpayment' 
  801       'c.source' => array(
'rule' => 
'zeroifnull'),
 
  806     $this->import_code[$r] = 
'commande_fournisseurdet_'.$r;
 
  807     $this->import_label[$r] = 
'PurchaseOrderLines';
 
  808     $this->import_icon[$r] = $this->picto;
 
  809     $this->import_entities_array[$r] = array();
 
  810     $this->import_tables_array[$r] = array(
'cd' => MAIN_DB_PREFIX.
'commande_fournisseurdet', 
'extra' => MAIN_DB_PREFIX.
'commande_fournisseurdet_extrafields');
 
  811     $this->import_fields_array[$r] = array(
 
  812       'cd.fk_commande'    => 
'PurchaseOrder*',
 
  813       'cd.fk_parent_line' => 
'ParentLine',
 
  814       'cd.fk_product'     => 
'IdProduct',
 
  815       'cd.description'    => 
'LineDescription',
 
  816       'cd.tva_tx'         => 
'LineVATRate',
 
  817       'cd.qty'            => 
'LineQty',
 
  818       'cd.remise_percent' => 
'Reduc. Percent',
 
  819       'cd.subprice'       => 
'Sub Price',
 
  820       'cd.total_ht'       => 
'LineTotalHT',
 
  821       'cd.total_tva'      => 
'LineTotalVAT',
 
  822       'cd.total_ttc'      => 
'LineTotalTTC',
 
  823       'cd.product_type'   => 
'TypeOfLineServiceOrProduct',
 
  824       'cd.date_start'     => 
'Start Date',
 
  825       'cd.date_end'       => 
'End Date',
 
  826       'cd.info_bits'      => 
'InfoBits',
 
  827       'cd.special_code'   => 
'Special Code',
 
  828       'cd.rang'           => 
'LinePosition',
 
  829       'cd.fk_unit'        => 
'Unit' 
  833       $this->import_fields_array[$r][
'cd.multicurrency_code'] = 
'Currency';
 
  834       $this->import_fields_array[$r][
'cd.multicurrency_subprice'] = 
'CurrencyRate';
 
  835       $this->import_fields_array[$r][
'cd.multicurrency_total_ht'] = 
'MulticurrencyAmountHT';
 
  836       $this->import_fields_array[$r][
'cd.multicurrency_total_tva'] = 
'MulticurrencyAmountVAT';
 
  837       $this->import_fields_array[$r][
'cd.multicurrency_total_ttc'] = 
'MulticurrencyAmountTTC';
 
  841     $sql = 
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.
")";
 
  844       while ($obj = $this->
db->fetch_object(
$resql)) {
 
  845         $fieldname = 
'extra.'.$obj->name;
 
  846         $fieldlabel = ucfirst($obj->label);
 
  847         $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? 
'*' : 
'');
 
  852     $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' => 
'lastrowid-'.MAIN_DB_PREFIX.
'commande_fournisseurdet');
 
  853     $this->import_regex_array[$r] = array(
 
  854       'cd.product_type'       => 
'[0|1]$',
 
  855       'cd.fk_product'         => 
'rowid@'.MAIN_DB_PREFIX.
'product',
 
  856       'cd.multicurrency_code' => 
'code@'.MAIN_DB_PREFIX.
'multicurrency' 
  858     $this->import_updatekeys_array[$r] = array(
'cd.fk_commande' => 
'Purchase Order Id');
 
  859     $this->import_convertvalue_array[$r] = array(
 
  860       'cd.fk_commande' => array(
 
  861         'rule'    => 
'fetchidfromref',
 
  862         'file'    => 
'/fourn/class/fournisseur.commande.class.php',
 
  863         'class'   => 
'CommandeFournisseur',
 
  865         'element' => 
'order_supplier' 
  867       'cd.info_bits' => array(
'rule' => 
'zeroifnull'),
 
  868       'cd.special_code' => array(
'rule' => 
'zeroifnull'),
 
  881   public function init($options = 
'')
 
  883     global $conf, $langs;
 
  885     $this->
remove($options);
 
  888     $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/supplier_orders/template_supplier_order.odt';
 
  889     $dirodt = DOL_DATA_ROOT.
'/doctemplates/supplier_orders';
 
  890     $dest = $dirodt.
'/template_supplier_order.odt';
 
  892     if (file_exists($src) && !file_exists($dest)) {
 
  893       require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
 
  895       $result = 
dol_copy($src, $dest, 0, 0);
 
  897         $langs->load(
"errors");
 
  898         $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
 
  904        "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),
 
  905        "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2]).
"', 'order_supplier', ".((
int) $conf->entity).
")",
 
  909     $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/supplier_invoices/template_supplier_invoices.odt';
 
  910     $dirodt = DOL_DATA_ROOT.
'/doctemplates/supplier_invoices';
 
  911     $dest = $dirodt.
'/template_supplier_invoices.odt';
 
  913     if (file_exists($src) && !file_exists($dest)) {
 
  914       require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
 
  916       $result = 
dol_copy($src, $dest, 0, 0);
 
  918         $langs->load(
"errors");
 
  919         $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
 
  935     return $this->
_init($sql, $options);
 
_init($array_sql, $options='')
Enables a module.
 
Description and activation class for module Fournisseur.
 
init($options='')
Function called when module is enabled.
 
__construct($db)
Constructor.
 
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
 
print *****$script_file(".$version.") pid 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)
Copy a file to another file.
 
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
 
dol_now($mode='auto')
Return date for now.
 
isModEnabled($module)
Is Dolibarr module enabled.
 
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.
 
$conf db
API class for accounts.