| Conditions | 50 |
| Paths | 0 |
| Total Lines | 910 |
| Code Lines | 731 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 50 | public function __construct($db) |
||
| 51 | { |
||
| 52 | global $conf, $langs, $user, $mysoc; |
||
| 53 | |||
| 54 | $this->db = $db; |
||
|
|
|||
| 55 | $this->numero = 40; |
||
| 56 | |||
| 57 | // Family can be 'crm','financial','hr','projects','product','ecm','technic','other' |
||
| 58 | // It is used to group modules in module setup page |
||
| 59 | $this->family = "srm"; |
||
| 60 | $this->module_position = '12'; |
||
| 61 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
||
| 62 | $this->name = preg_replace('/^mod/i', '', get_class($this)); |
||
| 63 | $this->description = "Gestion des fournisseurs"; |
||
| 64 | |||
| 65 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
||
| 66 | $this->version = 'dolibarr'; |
||
| 67 | |||
| 68 | $this->const_name = 'MAIN_MODULE_' . static::getNameOf($this->name); // strtoupper($this->name); |
||
| 69 | $this->picto = 'company'; |
||
| 70 | |||
| 71 | // Data directories to create when module is enabled |
||
| 72 | $this->dirs = array( |
||
| 73 | "/fournisseur/temp", |
||
| 74 | "/fournisseur/commande", |
||
| 75 | "/fournisseur/commande/temp", |
||
| 76 | "/fournisseur/facture", |
||
| 77 | "/fournisseur/facture/temp" |
||
| 78 | ); |
||
| 79 | |||
| 80 | // Dependencies |
||
| 81 | $this->depends = array("modSociete"); |
||
| 82 | $this->requiredby = array("modSupplierProposal"); |
||
| 83 | $this->langfiles = array('bills', 'companies', 'suppliers', 'orders', 'sendings'); |
||
| 84 | |||
| 85 | // Config pages |
||
| 86 | $this->config_page_url = array("supplier_order.php"); |
||
| 87 | |||
| 88 | // Constants |
||
| 89 | $this->const = array(); |
||
| 90 | $r = 0; |
||
| 91 | |||
| 92 | $this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_PDF"; |
||
| 93 | $this->const[$r][1] = "chaine"; |
||
| 94 | $this->const[$r][2] = "cornas"; |
||
| 95 | $this->const[$r][3] = 'Nom du gestionnaire de generation des bons de commande en PDF'; |
||
| 96 | $this->const[$r][4] = 0; |
||
| 97 | $r++; |
||
| 98 | |||
| 99 | $this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_NUMBER"; |
||
| 100 | $this->const[$r][1] = "chaine"; |
||
| 101 | $this->const[$r][2] = "mod_commande_fournisseur_muguet"; |
||
| 102 | $this->const[$r][3] = 'Nom du gestionnaire de numerotation des commandes fournisseur'; |
||
| 103 | $this->const[$r][4] = 0; |
||
| 104 | $r++; |
||
| 105 | |||
| 106 | /* For supplier invoice, we must not have default pdf template on. In most cases, we need to join PDF from supplier, not have a document generated. |
||
| 107 | $this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_PDF"; |
||
| 108 | $this->const[$r][1] = "chaine"; |
||
| 109 | $this->const[$r][2] = "canelle"; |
||
| 110 | $this->const[$r][3] = 'Nom du gestionnaire de generation des factures fournisseur en PDF'; |
||
| 111 | $this->const[$r][4] = 0; |
||
| 112 | $r++; |
||
| 113 | */ |
||
| 114 | |||
| 115 | $this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_NUMBER"; |
||
| 116 | $this->const[$r][1] = "chaine"; |
||
| 117 | $this->const[$r][2] = "mod_facture_fournisseur_cactus"; |
||
| 118 | $this->const[$r][3] = 'Nom du gestionnaire de numerotation des factures fournisseur'; |
||
| 119 | $this->const[$r][4] = 0; |
||
| 120 | $r++; |
||
| 121 | |||
| 122 | // Add ability ODT for Supplier orders |
||
| 123 | $this->const[$r][0] = "SUPPLIER_ORDER_ADDON_PDF_ODT_PATH"; |
||
| 124 | $this->const[$r][1] = "chaine"; |
||
| 125 | $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/supplier_orders"; |
||
| 126 | $this->const[$r][3] = ''; |
||
| 127 | $this->const[$r][4] = 0; |
||
| 128 | $r++; |
||
| 129 | |||
| 130 | // Add ability ODT for Supplier Invoices |
||
| 131 | $this->const[$r][0] = "SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH"; |
||
| 132 | $this->const[$r][1] = "chaine"; |
||
| 133 | $this->const[$r][2] = ""; |
||
| 134 | $this->const[$r][3] = ""; |
||
| 135 | $this->const[$r][4] = 0; |
||
| 136 | $r++; |
||
| 137 | |||
| 138 | // Boxes |
||
| 139 | $this->boxes = array( |
||
| 140 | 0 => array('file' => 'box_graph_invoices_supplier_permonth.php', 'enabledbydefaulton' => 'Home'), |
||
| 141 | 1 => array('file' => 'box_graph_orders_supplier_permonth.php', 'enabledbydefaulton' => 'Home'), |
||
| 142 | 2 => array('file' => 'box_fournisseurs.php', 'enabledbydefaulton' => 'Home'), |
||
| 143 | 3 => array('file' => 'box_factures_fourn_imp.php', 'enabledbydefaulton' => 'Home'), |
||
| 144 | 4 => array('file' => 'box_factures_fourn.php', 'enabledbydefaulton' => 'Home'), |
||
| 145 | 5 => array('file' => 'box_supplier_orders.php', 'enabledbydefaulton' => 'Home'), |
||
| 146 | 6 => array('file' => 'box_supplier_orders_awaiting_reception.php', 'enabledbydefaulton' => 'Home'), |
||
| 147 | ); |
||
| 148 | |||
| 149 | $arraydate = dol_getdate(dol_now()); |
||
| 150 | $datestart = dol_mktime(23, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); |
||
| 151 | $this->cronjobs = array( |
||
| 152 | 0 => array( |
||
| 153 | 'label' => 'RecurringSupplierInvoicesJob', |
||
| 154 | 'jobtype' => 'method', |
||
| 155 | 'class' => 'fourn/class/fournisseur.facture-rec.class.php', |
||
| 156 | 'objectname' => 'FactureFournisseurRec', |
||
| 157 | 'method' => 'createRecurringInvoices', |
||
| 158 | 'parameters' => '', |
||
| 159 | 'comment' => 'Generate recurring supplier invoices', |
||
| 160 | 'frequency' => 1, |
||
| 161 | 'unitfrequency' => 3600 * 24, |
||
| 162 | 'priority' => 51, |
||
| 163 | 'status' => 1, |
||
| 164 | 'test' => 'isModEnabled("supplier_invoice")', |
||
| 165 | 'datestart' => $datestart |
||
| 166 | ), |
||
| 167 | 1 => array( |
||
| 168 | 'label' => 'SendEmailsRemindersOnSupplierInvoiceDueDate', |
||
| 169 | 'jobtype' => 'method', |
||
| 170 | 'class' => 'fourn/class/fournisseur.facture.class.php', |
||
| 171 | 'objectname' => 'FactureFournisseur', |
||
| 172 | 'method' => 'sendEmailsRemindersOnSupplierInvoiceDueDate', |
||
| 173 | 'parameters' => '10,all,EmailTemplateCode,duedate', |
||
| 174 | 'comment' => 'Send an email when we reach the supplier invoice due date (or supplier invoice date) - n days. First param is n, the number of days before due date (or supplier invoice date) to send the remind (or after if value is negative), second parameter is "all" or a payment mode code, third parameter is the code of the email template to use (an email template with the EmailTemplateCode must exists. The version of the email template in the language of the thirdparty will be used in priority. Language of the thirdparty will be also used to update the PDF of the sent supplier invoice). The fourth parameter is the string "duedate" (default) or "invoicedate" to define which date of the supplier invoice to use.', |
||
| 175 | 'frequency' => 1, |
||
| 176 | 'unitfrequency' => 3600 * 24, |
||
| 177 | 'priority' => 50, |
||
| 178 | 'status' => 0, |
||
| 179 | 'test' => 'isModEnabled("supplier_invoice")', |
||
| 180 | 'datestart' => $datestart |
||
| 181 | )); |
||
| 182 | |||
| 183 | |||
| 184 | // Permissions |
||
| 185 | $this->rights = array(); |
||
| 186 | $this->rights_class = 'fournisseur'; |
||
| 187 | $r = 0; |
||
| 188 | |||
| 189 | $r++; |
||
| 190 | $this->rights[$r][0] = 1181; |
||
| 191 | $this->rights[$r][1] = 'Consulter les fournisseurs'; |
||
| 192 | $this->rights[$r][2] = 'r'; |
||
| 193 | $this->rights[$r][3] = 0; |
||
| 194 | $this->rights[$r][4] = 'lire'; |
||
| 195 | |||
| 196 | $r++; |
||
| 197 | $this->rights[$r][0] = 1182; |
||
| 198 | $this->rights[$r][1] = 'Consulter les commandes fournisseur'; |
||
| 199 | $this->rights[$r][2] = 'r'; |
||
| 200 | $this->rights[$r][3] = 0; |
||
| 201 | $this->rights[$r][4] = 'commande'; |
||
| 202 | $this->rights[$r][5] = 'lire'; |
||
| 203 | |||
| 204 | $r++; |
||
| 205 | $this->rights[$r][0] = 1183; |
||
| 206 | $this->rights[$r][1] = 'Creer 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] = 'creer'; |
||
| 211 | |||
| 212 | $r++; |
||
| 213 | $this->rights[$r][0] = 1184; |
||
| 214 | $this->rights[$r][1] = 'Valider une commande fournisseur'; |
||
| 215 | $this->rights[$r][2] = 'w'; |
||
| 216 | $this->rights[$r][3] = 0; |
||
| 217 | $this->rights[$r][4] = 'supplier_order_advance'; |
||
| 218 | $this->rights[$r][5] = 'validate'; |
||
| 219 | |||
| 220 | $r++; |
||
| 221 | $this->rights[$r][0] = 1185; |
||
| 222 | $this->rights[$r][1] = 'Approuver une commande fournisseur'; |
||
| 223 | $this->rights[$r][2] = 'w'; |
||
| 224 | $this->rights[$r][3] = 0; |
||
| 225 | $this->rights[$r][4] = 'commande'; |
||
| 226 | $this->rights[$r][5] = 'approuver'; |
||
| 227 | |||
| 228 | $r++; |
||
| 229 | $this->rights[$r][0] = 1186; |
||
| 230 | $this->rights[$r][1] = 'Commander une commande fournisseur'; |
||
| 231 | $this->rights[$r][2] = 'w'; |
||
| 232 | $this->rights[$r][3] = 0; |
||
| 233 | $this->rights[$r][4] = 'commande'; |
||
| 234 | $this->rights[$r][5] = 'commander'; |
||
| 235 | |||
| 236 | $r++; |
||
| 237 | $this->rights[$r][0] = 1187; |
||
| 238 | $this->rights[$r][1] = 'Receptionner une commande fournisseur'; |
||
| 239 | $this->rights[$r][2] = 'd'; |
||
| 240 | $this->rights[$r][3] = 0; |
||
| 241 | $this->rights[$r][4] = 'commande'; |
||
| 242 | $this->rights[$r][5] = 'receptionner'; |
||
| 243 | |||
| 244 | $r++; |
||
| 245 | $this->rights[$r][0] = 1189; |
||
| 246 | $this->rights[$r][1] = 'Check/Uncheck a supplier order reception'; |
||
| 247 | $this->rights[$r][2] = 'w'; |
||
| 248 | $this->rights[$r][3] = 0; |
||
| 249 | $this->rights[$r][4] = 'commande_advance'; |
||
| 250 | $this->rights[$r][5] = 'check'; |
||
| 251 | |||
| 252 | $r++; |
||
| 253 | $this->rights[$r][0] = 1188; |
||
| 254 | $this->rights[$r][1] = 'Supprimer une commande fournisseur'; |
||
| 255 | $this->rights[$r][2] = 'd'; |
||
| 256 | $this->rights[$r][3] = 0; |
||
| 257 | $this->rights[$r][4] = 'commande'; |
||
| 258 | $this->rights[$r][5] = 'supprimer'; |
||
| 259 | |||
| 260 | if (getDolGlobalString('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED')) { |
||
| 261 | $r++; |
||
| 262 | $this->rights[$r][0] = 1190; |
||
| 263 | $this->rights[$r][1] = 'Approve supplier order (second level)'; // $langs->trans("Permission1190"); |
||
| 264 | $this->rights[$r][2] = 'w'; |
||
| 265 | $this->rights[$r][3] = 0; |
||
| 266 | $this->rights[$r][4] = 'commande'; |
||
| 267 | $this->rights[$r][5] = 'approve2'; |
||
| 268 | } |
||
| 269 | |||
| 270 | $r++; |
||
| 271 | $this->rights[$r][0] = 1191; |
||
| 272 | $this->rights[$r][1] = 'Exporter les commande fournisseurs, attributs'; |
||
| 273 | $this->rights[$r][2] = 'r'; |
||
| 274 | $this->rights[$r][3] = 0; |
||
| 275 | $this->rights[$r][4] = 'commande'; |
||
| 276 | $this->rights[$r][5] = 'export'; |
||
| 277 | |||
| 278 | $r++; |
||
| 279 | $this->rights[$r][0] = 1231; |
||
| 280 | $this->rights[$r][1] = 'Consulter les factures fournisseur'; |
||
| 281 | $this->rights[$r][2] = 'r'; |
||
| 282 | $this->rights[$r][3] = 0; |
||
| 283 | $this->rights[$r][4] = 'facture'; |
||
| 284 | $this->rights[$r][5] = 'lire'; |
||
| 285 | |||
| 286 | $r++; |
||
| 287 | $this->rights[$r][0] = 1232; |
||
| 288 | $this->rights[$r][1] = 'Creer une facture fournisseur'; |
||
| 289 | $this->rights[$r][2] = 'w'; |
||
| 290 | $this->rights[$r][3] = 0; |
||
| 291 | $this->rights[$r][4] = 'facture'; |
||
| 292 | $this->rights[$r][5] = 'creer'; |
||
| 293 | |||
| 294 | $r++; |
||
| 295 | $this->rights[$r][0] = 1233; |
||
| 296 | $this->rights[$r][1] = 'Valider une facture fournisseur'; |
||
| 297 | $this->rights[$r][2] = 'w'; |
||
| 298 | $this->rights[$r][3] = 0; |
||
| 299 | $this->rights[$r][4] = 'supplier_invoice_advance'; |
||
| 300 | $this->rights[$r][5] = 'validate'; |
||
| 301 | |||
| 302 | $r++; |
||
| 303 | $this->rights[$r][0] = 1234; |
||
| 304 | $this->rights[$r][1] = 'Supprimer une facture fournisseur'; |
||
| 305 | $this->rights[$r][2] = 'd'; |
||
| 306 | $this->rights[$r][3] = 0; |
||
| 307 | $this->rights[$r][4] = 'facture'; |
||
| 308 | $this->rights[$r][5] = 'supprimer'; |
||
| 309 | |||
| 310 | $r++; |
||
| 311 | $this->rights[$r][0] = 1235; |
||
| 312 | $this->rights[$r][1] = 'Envoyer les factures par mail'; |
||
| 313 | $this->rights[$r][2] = 'a'; |
||
| 314 | $this->rights[$r][3] = 0; |
||
| 315 | $this->rights[$r][4] = 'supplier_invoice_advance'; |
||
| 316 | $this->rights[$r][5] = 'send'; |
||
| 317 | |||
| 318 | $r++; |
||
| 319 | $this->rights[$r][0] = 1236; |
||
| 320 | $this->rights[$r][1] = 'Exporter les factures fournisseurs, attributes et reglements'; |
||
| 321 | $this->rights[$r][2] = 'r'; |
||
| 322 | $this->rights[$r][3] = 0; |
||
| 323 | $this->rights[$r][4] = 'facture'; |
||
| 324 | $this->rights[$r][5] = 'export'; |
||
| 325 | |||
| 326 | |||
| 327 | // Menus |
||
| 328 | //------- |
||
| 329 | $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
||
| 330 | |||
| 331 | |||
| 332 | // Exports |
||
| 333 | //-------- |
||
| 334 | $uselocaltax1 = (is_object($mysoc) && $mysoc->localtax1_assuj) ? $mysoc->localtax1_assuj : 0; |
||
| 335 | $uselocaltax2 = (is_object($mysoc) && $mysoc->localtax2_assuj) ? $mysoc->localtax2_assuj : 0; |
||
| 336 | |||
| 337 | $r = 0; |
||
| 338 | |||
| 339 | $langs->loadLangs(array("suppliers", "compta", "multicurrency", "bills")); |
||
| 340 | |||
| 341 | $alias_product_perentity = !getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED') ? "p" : "ppe"; |
||
| 342 | |||
| 343 | $r++; |
||
| 344 | $this->export_code[$r] = $this->rights_class . '_' . $r; |
||
| 345 | $this->export_label[$r] = 'Vendor invoices and lines of invoices'; |
||
| 346 | $this->export_icon[$r] = 'invoice'; |
||
| 347 | $this->export_permission[$r] = array(array("fournisseur", "facture", "export")); |
||
| 348 | $this->export_fields_array[$r] = array( |
||
| 349 | 's.rowid' => "IdCompany", 's.nom' => 'CompanyName', 'ps.nom' => 'ParentCompany', 's.address' => 'Address', 's.zip' => 'Zip', 's.town' => 'Town', 'c.code' => 'CountryCode', 's.phone' => 'Phone', |
||
| 350 | 's.siren' => 'ProfId1', 's.siret' => 'ProfId2', 's.ape' => 'ProfId3', 's.idprof4' => 'ProfId4', 's.idprof5' => 'ProfId5', 's.idprof6' => 'ProfId6', |
||
| 351 | 's.code_compta' => 'CustomerAccountancyCode', 's.code_compta_fournisseur' => 'SupplierAccountancyCode', 's.tva_intra' => 'VATIntra', |
||
| 352 | 'f.rowid' => "InvoiceId", 'f.ref' => "InvoiceRef", 'f.ref_supplier' => "RefSupplier", 'f.datec' => "InvoiceDateCreation", 'f.datef' => "DateInvoice", 'f.date_lim_reglement' => 'DateMaxPayment', |
||
| 353 | 'f.fk_cond_reglement' => 'IdPaymentTerm', 'f.fk_mode_reglement' => 'IdPaymentMode', |
||
| 354 | 'f.total_ht' => "TotalHT", 'f.total_ttc' => "TotalTTC", 'f.total_tva' => "TotalVAT", |
||
| 355 | 'f.localtax1' => "TotalLT1", 'f.localtax2' => "TotalLT2", |
||
| 356 | 'f.paye' => "InvoicePaid", 'f.fk_statut' => 'InvoiceStatus', 'f.note_public' => "InvoiceNote", |
||
| 357 | 'fd.rowid' => 'LineId', 'fd.description' => "LineDescription", 'fd.qty' => "LineQty", 'fd.remise_percent' => "Discount", |
||
| 358 | 'fd.tva_tx' => "LineVATRate", 'fd.total_ht' => "LineTotalHT", 'fd.total_ttc' => "LineTotalTTC", 'fd.tva' => "LineTotalVAT", |
||
| 359 | 'fd.localtax1_tx' => "LineLT1Rate", 'fd.localtax1_type' => "LineLT1Type", 'fd.total_localtax1' => "LineTotalLT1", |
||
| 360 | 'fd.localtax2_tx' => "LineLT2Rate", 'fd.localtax2_type' => "LineLT2Type", 'fd.total_localtax2' => "LineTotalLT2", |
||
| 361 | 'fd.date_start' => "DateStart", 'fd.date_end' => "DateEnd", 'fd.special_code' => 'SpecialCode', |
||
| 362 | 'fd.product_type' => 'TypeOfLineServiceOrProduct', 'fd.fk_product' => 'ProductId', |
||
| 363 | 'p.ref' => 'ProductRef', 'p.label' => 'ProductLabel', $alias_product_perentity . '.accountancy_code_buy' => 'ProductAccountancyBuyCode', 'project.rowid' => 'ProjectId', |
||
| 364 | 'project.ref' => 'ProjectRef', 'project.title' => 'ProjectLabel' |
||
| 365 | ); |
||
| 366 | if (!$uselocaltax1) { |
||
| 367 | unset($this->export_fields_array[$r]['fd.localtax1_tx']); |
||
| 368 | unset($this->export_fields_array[$r]['fd.localtax1_type']); |
||
| 369 | unset($this->export_fields_array[$r]['fd.total_localtax1']); |
||
| 370 | } |
||
| 371 | if (!$uselocaltax2) { |
||
| 372 | unset($this->export_fields_array[$r]['fd.localtax2_tx']); |
||
| 373 | unset($this->export_fields_array[$r]['fd.localtax2_type']); |
||
| 374 | unset($this->export_fields_array[$r]['fd.total_localtax2']); |
||
| 375 | } |
||
| 376 | |||
| 377 | if (isModEnabled("multicurrency")) { |
||
| 378 | $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; |
||
| 379 | $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; |
||
| 380 | $this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; |
||
| 381 | $this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; |
||
| 382 | $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; |
||
| 383 | } |
||
| 384 | if (!$uselocaltax1) { |
||
| 385 | unset($this->export_fields_array[$r]['f.localtax1']); |
||
| 386 | } |
||
| 387 | if (!$uselocaltax2) { |
||
| 388 | unset($this->export_fields_array[$r]['f.localtax2']); |
||
| 389 | } |
||
| 390 | |||
| 391 | //$this->export_TypeFields_array[$r]=array( |
||
| 392 | // 's.rowid'=>"Numeric",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text', |
||
| 393 | // 's.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric", |
||
| 394 | // 'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric", |
||
| 395 | // 'fd.tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text' |
||
| 396 | //); |
||
| 397 | $this->export_TypeFields_array[$r] = array( |
||
| 398 | 's.rowid' => 'Numeric', 's.nom' => 'Text', 'ps.nom' => 'Text', 's.address' => 'Text', 's.zip' => 'Text', 's.town' => 'Text', 'c.code' => 'Text', 's.phone' => 'Text', 's.siren' => 'Text', 's.siret' => 'Text', 's.ape' => 'Text', 's.idprof4' => 'Text', 's.idprof5' => 'Text', 's.idprof6' => 'Text', |
||
| 399 | 's.code_compta' => 'Text', 's.code_compta_fournisseur' => 'Text', 's.tva_intra' => 'Text', |
||
| 400 | 'f.rowid' => 'Numeric', 'f.ref' => "Text", 'f.ref_supplier' => "Text", 'f.datec' => "Date", 'f.datef' => "Date", 'f.date_lim_reglement' => 'Date', |
||
| 401 | 'f.fk_cond_reglement' => 'Numeric', 'f.fk_mode_reglement' => 'Numeric', |
||
| 402 | 'f.total_ht' => "Numeric", 'f.total_ttc' => "Numeric", 'f.total_tva' => "Numeric", 'f.localtax1' => "Numeric", 'f.localtax2' => "Numeric", |
||
| 403 | 'f.paye' => "Boolean", 'f.fk_statut' => 'Status', 'f.note_public' => "Text", |
||
| 404 | 'fd.rowid' => 'Numeric', 'fd.description' => "Text", 'fd.tva_tx' => "Text", |
||
| 405 | 'fd.qty' => "Numeric", 'fd.remise_percent' => "Numeric", |
||
| 406 | 'fd.total_ht' => "Numeric", 'fd.total_ttc' => "Numeric", 'fd.tva' => "Numeric", 'fd.total_localtax1' => "Numeric", 'fd.total_localtax2' => "Numeric", |
||
| 407 | 'fd.localtax1_tx' => 'Numeric', 'fd.localtax2_tx' => 'Numeric', 'fd.localtax1_type' => 'Numeric', 'fd.localtax2_type' => 'Numeric', |
||
| 408 | 'fd.date_start' => "Date", 'fd.date_end' => "Date", 'fd.special_code' => "Numeric", |
||
| 409 | 'fd.product_type' => 'Numeric', 'fd.fk_product' => 'List:product:label', $alias_product_perentity . '.accountancy_code_buy' => 'Text', |
||
| 410 | 'p.ref' => 'Text', 'p.label' => 'Text', 'project.ref' => 'Text', 'project.title' => 'Text', |
||
| 411 | 'f.multicurrency_code' => 'Text', |
||
| 412 | 'f.multicurrency_tx' => 'Number', 'f.multicurrency_total_ht' => 'Number', 'f.multicurrency_total_tva' => 'Number', 'f.multicurrency_total_ttc' => 'Number' |
||
| 413 | ); |
||
| 414 | $this->export_entities_array[$r] = array( |
||
| 415 | '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', |
||
| 416 | '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", |
||
| 417 | 'f.ref' => "invoice", 'f.ref_supplier' => "invoice", 'f.datec' => "invoice", 'f.datef' => "invoice", 'f.date_lim_reglement' => 'invoice', |
||
| 418 | 'f.fk_cond_reglement' => 'invoice', 'f.fk_mode_reglement' => 'invoice', |
||
| 419 | 'f.total_ht' => "invoice", 'f.total_ttc' => "invoice", 'f.total_tva' => "invoice", |
||
| 420 | 'f.paye' => "invoice", 'f.fk_statut' => 'invoice', 'f.note_public' => "invoice", 'fd.rowid' => 'invoice_line', 'fd.description' => "invoice_line", 'fd.qty' => "invoice_line", |
||
| 421 | 'fd.total_ht' => "invoice_line", 'fd.tva' => "invoice_line", 'fd.total_ttc' => "invoice_line", 'fd.total_localtax1' => "invoice_line", 'fd.total_localtax2' => "invoice_line", |
||
| 422 | 'fd.tva_tx' => "invoice_line", 'fd.localtax1_tx' => "invoice_line", 'fd.localtax2_tx' => "invoice_line", 'fd.localtax1_type' => "invoice_line", 'fd.localtax2_type' => "invoice_line", |
||
| 423 | 'fd.remise_percent' => "invoice_line", |
||
| 424 | 'fd.date_start' => "invoice_line", 'fd.date_end' => "invoice_line", 'fd.special_code' => "invoice_line", |
||
| 425 | 'fd.product_type' => 'invoice_line', 'fd.fk_product' => 'product', |
||
| 426 | 'p.ref' => 'product', 'p.label' => 'product', $alias_product_perentity . '.accountancy_code_buy' => 'product', 'project.rowid' => 'project', 'project.ref' => 'project', 'project.title' => 'project' |
||
| 427 | ); |
||
| 428 | $this->export_dependencies_array[$r] = array('invoice_line' => 'fd.rowid', 'product' => 'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
||
| 429 | // Add extra fields object |
||
| 430 | $keyforselect = 'facture_fourn'; |
||
| 431 | $keyforelement = 'invoice'; |
||
| 432 | $keyforaliasextra = 'extra'; |
||
| 433 | include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php'; |
||
| 434 | $keyforselect = 'facture_fourn_det'; |
||
| 435 | $keyforelement = 'invoice_line'; |
||
| 436 | $keyforaliasextra = 'extraline'; |
||
| 437 | include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php'; |
||
| 438 | // End add extra fields line |
||
| 439 | $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
||
| 440 | $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'societe as s'; |
||
| 441 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as ps ON ps.rowid = s.parent'; |
||
| 442 | if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) { |
||
| 443 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
||
| 444 | } |
||
| 445 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as c ON s.fk_pays = c.rowid,'; |
||
| 446 | $this->export_sql_end[$r] .= ' ' . MAIN_DB_PREFIX . 'facture_fourn as f'; |
||
| 447 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'projet as project on (f.fk_projet = project.rowid)'; |
||
| 448 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object'; |
||
| 449 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_paiement as cp ON f.fk_mode_reglement = cp.id'; |
||
| 450 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_payment_term as cpt ON f.fk_cond_reglement = cpt.rowid,'; |
||
| 451 | $this->export_sql_end[$r] .= ' ' . MAIN_DB_PREFIX . 'facture_fourn_det as fd'; |
||
| 452 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object'; |
||
| 453 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product as p on (fd.fk_product = p.rowid)'; |
||
| 454 | $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn'; |
||
| 455 | $this->export_sql_end[$r] .= ' AND f.entity IN (' . getEntity('supplier_invoice') . ')'; |
||
| 456 | if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) { |
||
| 457 | $this->export_sql_end[$r] .= ' AND sc.fk_user = ' . ((int)$user->id); |
||
| 458 | } |
||
| 459 | |||
| 460 | // Invoices and payments |
||
| 461 | $r++; |
||
| 462 | $this->export_code[$r] = $this->rights_class . '_' . $r; |
||
| 463 | $this->export_label[$r] = 'Factures fournisseurs et reglements'; |
||
| 464 | $this->export_icon[$r] = 'invoice'; |
||
| 465 | $this->export_permission[$r] = array(array("fournisseur", "facture", "export")); |
||
| 466 | $this->export_fields_array[$r] = array( |
||
| 467 | 's.rowid' => "IdCompany", 's.nom' => 'CompanyName', 's.address' => 'Address', 's.zip' => 'Zip', 's.town' => 'Town', 'c.code' => 'CountryCode', 's.phone' => 'Phone', |
||
| 468 | 's.siren' => 'ProfId1', 's.siret' => 'ProfId2', 's.ape' => 'ProfId3', 's.idprof4' => 'ProfId4', 's.idprof5' => 'ProfId5', 's.idprof6' => 'ProfId6', |
||
| 469 | 's.code_compta' => 'CustomerAccountancyCode', 's.code_compta_fournisseur' => 'SupplierAccountancyCode', 's.tva_intra' => 'VATIntra', |
||
| 470 | 'f.rowid' => "InvoiceId", 'f.ref' => "InvoiceRef", 'f.ref_supplier' => "RefSupplier", 'f.datec' => "InvoiceDateCreation", 'f.datef' => "DateInvoice", 'f.date_lim_reglement' => "DateMaxPayment", |
||
| 471 | 'f.fk_cond_reglement' => 'IdPaymentTerm', 'f.fk_mode_reglement' => 'IdPaymentMode', |
||
| 472 | 'f.total_ht' => "TotalHT", 'f.total_ttc' => "TotalTTC", 'f.total_tva' => "TotalVAT", |
||
| 473 | 'f.localtax1' => "TotalLT1", 'f.localtax2' => "TotalLT2", |
||
| 474 | 'f.paye' => "InvoicePaid", |
||
| 475 | 'f.fk_statut' => 'InvoiceStatus', 'f.note_public' => "InvoiceNote", 'p.rowid' => 'PaymentId', 'pf.amount' => 'AmountPayment', |
||
| 476 | 'p.datep' => 'DatePayment', 'p.num_paiement' => 'PaymentNumber', 'p.fk_bank' => 'IdTransaction', 'project.rowid' => 'ProjectId', 'project.ref' => 'ProjectRef', 'project.title' => 'ProjectLabel' |
||
| 477 | ); |
||
| 478 | if (!$uselocaltax1) { |
||
| 479 | unset($this->export_fields_array[$r]['f.localtax1']); |
||
| 480 | } |
||
| 481 | if (!$uselocaltax2) { |
||
| 482 | unset($this->export_fields_array[$r]['f.localtax2']); |
||
| 483 | } |
||
| 484 | if (isModEnabled("multicurrency")) { |
||
| 485 | $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; |
||
| 486 | $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; |
||
| 487 | $this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; |
||
| 488 | $this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; |
||
| 489 | $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; |
||
| 490 | } |
||
| 491 | //$this->export_TypeFields_array[$r]=array( |
||
| 492 | // 's.rowid'=>"Numeric",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text', |
||
| 493 | // 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date", |
||
| 494 | // 'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text", |
||
| 495 | // 'pf.amount'=>'Numeric','p.datep'=>'Date','p.num_paiement'=>'Numeric' |
||
| 496 | //); |
||
| 497 | $this->export_TypeFields_array[$r] = array( |
||
| 498 | 's.rowid' => 'Numeric', 's.nom' => 'Text', 's.address' => 'Text', 's.zip' => 'Text', 's.town' => 'Text', 'c.code' => 'Text', 's.phone' => 'Text', 's.siren' => 'Text', 's.siret' => 'Text', 's.ape' => 'Text', |
||
| 499 | 's.idprof4' => 'Text', 's.idprof5' => 'Text', 's.idprof6' => 'Text', 's.code_compta' => 'Text', 's.code_compta_fournisseur' => 'Text', 's.tva_intra' => 'Text', |
||
| 500 | 'f.rowid' => 'Numeric', 'f.ref' => "Text", 'f.ref_supplier' => "Text", |
||
| 501 | 'f.datec' => "Date", 'f.datef' => "Date", 'f.date_lim_reglement' => 'Date', |
||
| 502 | 'f.fk_cond_reglement' => 'Numeric', 'f.fk_mode_reglement' => 'Numeric', |
||
| 503 | 'f.total_ht' => "Numeric", 'f.total_ttc' => "Numeric", 'f.total_tva' => "Numeric", 'f.localtax1' => "Numeric", 'f.localtax2' => "Numeric", |
||
| 504 | 'f.paye' => "Boolean", 'f.fk_statut' => 'Status', 'f.note_public' => "Text", 'pf.amount' => 'Numeric', |
||
| 505 | 'p.rowid' => 'Numeric', 'p.datep' => 'Date', 'p.num_paiement' => 'Numeric', 'p.fk_bank' => 'Numeric', 'project.rowid' => 'Numeric', 'project.ref' => 'Text', 'project.title' => 'Text', |
||
| 506 | 'f.multicurrency_code' => 'Text', |
||
| 507 | 'f.multicurrency_tx' => 'Number', 'f.multicurrency_total_ht' => 'Number', 'f.multicurrency_total_tva' => 'Number', 'f.multicurrency_total_ttc' => 'Number' |
||
| 508 | ); |
||
| 509 | $this->export_entities_array[$r] = array( |
||
| 510 | 's.rowid' => "company", 's.nom' => 'company', 's.address' => 'company', 's.zip' => 'company', 's.town' => 'company', 'c.code' => 'company', 's.phone' => 'company', |
||
| 511 | 's.siren' => 'company', 's.siret' => 'company', 's.ape' => 'company', 's.idprof4' => 'company', 's.idprof5' => 'company', 's.idprof6' => 'company', |
||
| 512 | 's.code_compta' => 'company', 's.code_compta_fournisseur' => 'company', 's.tva_intra' => 'company', |
||
| 513 | 'f.rowid' => "invoice", 'f.ref' => "invoice", 'f.ref_supplier' => "invoice", 'f.datec' => "invoice", 'f.datef' => "invoice", 'f.date_lim_reglement' => 'invoice', |
||
| 514 | 'f.fk_cond_reglement' => 'invoice', 'f.fk_mode_reglement' => 'invoice', |
||
| 515 | 'f.total_ht' => "invoice", 'f.total_ttc' => "invoice", 'f.total_tva' => "invoice", 'f.paye' => "invoice", 'f.fk_statut' => 'invoice', 'f.note_public' => "invoice", 'p.rowid' => 'payment', 'pf.amount' => 'payment', |
||
| 516 | 'p.datep' => 'payment', 'p.num_paiement' => 'payment', 'p.fk_bank' => 'account', 'project.rowid' => 'project', 'project.ref' => 'project', 'project.title' => 'project'); |
||
| 517 | $this->export_dependencies_array[$r] = array('payment' => 'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
||
| 518 | // Add extra fields object |
||
| 519 | $keyforselect = 'facture_fourn'; |
||
| 520 | $keyforelement = 'invoice'; |
||
| 521 | $keyforaliasextra = 'extra'; |
||
| 522 | include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php'; |
||
| 523 | // End add extra fields object |
||
| 524 | $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
||
| 525 | $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'societe as s'; |
||
| 526 | if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) { |
||
| 527 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
||
| 528 | } |
||
| 529 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as c ON s.fk_pays = c.rowid,'; |
||
| 530 | $this->export_sql_end[$r] .= ' ' . MAIN_DB_PREFIX . 'facture_fourn as f'; |
||
| 531 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'projet as project on (f.fk_projet = project.rowid)'; |
||
| 532 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object'; |
||
| 533 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; |
||
| 534 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'paiementfourn as p ON pf.fk_paiementfourn = p.rowid'; |
||
| 535 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_paiement as cp ON f.fk_mode_reglement = cp.id'; |
||
| 536 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_payment_term as cpt ON f.fk_cond_reglement = cpt.rowid'; |
||
| 537 | $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid'; |
||
| 538 | $this->export_sql_end[$r] .= ' AND f.entity IN (' . getEntity('supplier_invoice') . ')'; |
||
| 539 | if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) { |
||
| 540 | $this->export_sql_end[$r] .= ' AND sc.fk_user = ' . ((int)$user->id); |
||
| 541 | } |
||
| 542 | |||
| 543 | // Order |
||
| 544 | $r++; |
||
| 545 | $this->export_code[$r] = $this->rights_class . '_' . $r; |
||
| 546 | $this->export_label[$r] = 'Purchase Orders and lines of purchase orders'; |
||
| 547 | $this->export_icon[$r] = 'order'; |
||
| 548 | $this->export_permission[$r] = array(array("fournisseur", "commande", "export")); |
||
| 549 | $this->export_fields_array[$r] = array( |
||
| 550 | 's.rowid' => "IdCompany", 's.nom' => 'CompanyName', 'ps.nom' => 'ParentCompany', 's.address' => 'Address', 's.zip' => 'Zip', 's.town' => 'Town', 'c.code' => 'CountryCode', 's.phone' => 'Phone', |
||
| 551 | 's.siren' => 'ProfId1', 's.siret' => 'ProfId2', 's.ape' => 'ProfId3', 's.idprof4' => 'ProfId4', 's.idprof5' => 'ProfId5', 's.idprof6' => 'ProfId6', 's.tva_intra' => 'VATIntra', |
||
| 552 | 'f.rowid' => "OrderId", 'f.ref' => "Ref", 'f.ref_supplier' => "RefSupplier", 'f.date_creation' => "DateCreation", 'f.date_commande' => "OrderDate", 'f.date_livraison' => "DateDeliveryPlanned", |
||
| 553 | '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', |
||
| 554 | 'f.note_public' => "NotePublic", 'f.note_private' => "NotePrivate", 'uv.login' => 'UserValidation', 'ua1.login' => 'ApprovedBy', 'ua2.login' => 'ApprovedBy2', 'fd.rowid' => 'LineId', 'fd.description' => "LineDescription", |
||
| 555 | 'fd.tva_tx' => "LineVATRate", 'fd.qty' => "LineQty", 'fd.remise_percent' => "Discount", 'fd.total_ht' => "LineTotalHT", 'fd.total_ttc' => "LineTotalTTC", |
||
| 556 | 'fd.total_tva' => "LineTotalVAT", 'fd.date_start' => "DateStart", 'fd.date_end' => "DateEnd", 'fd.special_code' => 'SpecialCode', |
||
| 557 | 'fd.product_type' => 'TypeOfLineServiceOrProduct', 'fd.ref' => 'SupplierRef', 'fd.fk_product' => 'ProductId', |
||
| 558 | 'p.ref' => 'ProductRef', 'p.label' => 'ProductLabel', 'project.rowid' => 'ProjectId', 'project.ref' => 'ProjectRef', 'project.title' => 'ProjectLabel' |
||
| 559 | ); |
||
| 560 | if (isModEnabled("multicurrency")) { |
||
| 561 | $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; |
||
| 562 | $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; |
||
| 563 | $this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; |
||
| 564 | $this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; |
||
| 565 | $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; |
||
| 566 | } |
||
| 567 | if (!getDolGlobalString('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED')) { |
||
| 568 | unset($this->export_fields_array['f.date_approve2']); |
||
| 569 | unset($this->export_fields_array['ua2.login']); |
||
| 570 | } |
||
| 571 | $this->export_TypeFields_array[$r] = array( |
||
| 572 | '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', |
||
| 573 | '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", |
||
| 574 | 'f.date_creation' => "Date", 'f.date_commande' => "Date", 'f.date_livraison' => "Date", 'f.total_ht' => "Numeric", 'f.total_ttc' => "Numeric", 'f.total_tva' => "Numeric", |
||
| 575 | '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", |
||
| 576 | 'fd.tva_tx' => "Numeric", 'fd.qty' => "Numeric", 'fd.remise_percent' => "Numeric", 'fd.total_ht' => "Numeric", 'fd.total_ttc' => "Numeric", 'fd.total_tva' => "Numeric", |
||
| 577 | 'fd.date_start' => "Date", 'fd.date_end' => "Date", 'fd.special_code' => "Numeric", |
||
| 578 | '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' |
||
| 579 | ); |
||
| 580 | $this->export_entities_array[$r] = array( |
||
| 581 | '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', |
||
| 582 | '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', |
||
| 583 | '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", |
||
| 584 | '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", |
||
| 585 | 'fd.product_type' => 'order_line', 'fd.ref' => 'order_line', 'fd.fk_product' => 'product', |
||
| 586 | 'p.ref' => 'product', 'p.label' => 'product', 'project.rowid' => 'project', 'project.ref' => 'project', 'project.title' => 'project' |
||
| 587 | ); |
||
| 588 | $this->export_dependencies_array[$r] = array('order_line' => 'fd.rowid', 'product' => 'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
||
| 589 | // Add extra fields object |
||
| 590 | $keyforselect = 'commande_fournisseur'; |
||
| 591 | $keyforelement = 'order'; |
||
| 592 | $keyforaliasextra = 'extra'; |
||
| 593 | include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php'; |
||
| 594 | // End add extra fields object |
||
| 595 | // Add extra fields line |
||
| 596 | $keyforselect = 'commande_fournisseurdet'; |
||
| 597 | $keyforelement = 'order_line'; |
||
| 598 | $keyforaliasextra = 'extraline'; |
||
| 599 | include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php'; |
||
| 600 | // End add extra fields line |
||
| 601 | $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
||
| 602 | $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'societe as s'; |
||
| 603 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as ps ON ps.rowid = s.parent'; |
||
| 604 | if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) { |
||
| 605 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
||
| 606 | } |
||
| 607 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as c ON s.fk_pays = c.rowid,'; |
||
| 608 | $this->export_sql_end[$r] .= ' ' . MAIN_DB_PREFIX . 'commande_fournisseur as f'; |
||
| 609 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'projet as project on (f.fk_projet = project.rowid)'; |
||
| 610 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'user as uv ON uv.rowid = f.fk_user_valid'; |
||
| 611 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'user as ua1 ON ua1.rowid = f.fk_user_approve'; |
||
| 612 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'user as ua2 ON ua2.rowid = f.fk_user_approve2'; |
||
| 613 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,'; |
||
| 614 | $this->export_sql_end[$r] .= ' ' . MAIN_DB_PREFIX . 'commande_fournisseurdet as fd'; |
||
| 615 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object'; |
||
| 616 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product as p on (fd.fk_product = p.rowid)'; |
||
| 617 | $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande'; |
||
| 618 | $this->export_sql_end[$r] .= ' AND f.entity IN (' . getEntity('supplier_order') . ')'; |
||
| 619 | if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) { |
||
| 620 | $this->export_sql_end[$r] .= ' AND sc.fk_user = ' . ((int)$user->id); |
||
| 621 | } |
||
| 622 | |||
| 623 | //Import Supplier Invoice |
||
| 624 | //-------- |
||
| 625 | $r = 0; |
||
| 626 | |||
| 627 | $r++; |
||
| 628 | $this->import_code[$r] = $this->rights_class . '_' . $r; |
||
| 629 | $this->import_label[$r] = "SupplierInvoices"; // Translation key |
||
| 630 | $this->import_icon[$r] = $this->picto; |
||
| 631 | $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
||
| 632 | $this->import_tables_array[$r] = array('f' => MAIN_DB_PREFIX . 'facture_fourn', 'extra' => MAIN_DB_PREFIX . 'facture_fourn_extrafields'); |
||
| 633 | $this->import_tables_creator_array[$r] = array('f' => 'fk_user_author'); // Fields to store import user id |
||
| 634 | $this->import_fields_array[$r] = array( |
||
| 635 | 'f.ref' => 'InvoiceRef*', |
||
| 636 | 'f.ref_supplier' => 'RefSupplier', |
||
| 637 | 'f.type' => 'Type*', |
||
| 638 | 'f.fk_soc' => 'Supplier/Vendor*', |
||
| 639 | 'f.datec' => 'InvoiceDateCreation', |
||
| 640 | 'f.datef' => 'DateInvoice', |
||
| 641 | 'f.date_lim_reglement' => 'DateMaxPayment', |
||
| 642 | 'f.total_ht' => 'TotalHT', |
||
| 643 | 'f.total_ttc' => 'TotalTTC', |
||
| 644 | 'f.total_tva' => 'TotalVAT', |
||
| 645 | 'f.paye' => 'InvoicePaid', |
||
| 646 | 'f.fk_statut' => 'InvoiceStatus', |
||
| 647 | 'f.fk_user_modif' => 'Modifier Id', |
||
| 648 | 'f.fk_user_valid' => 'Validator Id', |
||
| 649 | 'f.fk_facture_source' => 'Invoice Source Id', |
||
| 650 | 'f.fk_projet' => 'Project Id', |
||
| 651 | 'f.fk_account' => 'Bank Account*', |
||
| 652 | 'f.note_public' => 'InvoiceNote', |
||
| 653 | 'f.note_private' => 'NotePrivate', |
||
| 654 | 'f.fk_cond_reglement' => 'PaymentTerm', |
||
| 655 | 'f.fk_mode_reglement' => 'PaymentMode', |
||
| 656 | 'f.model_pdf' => 'Model', |
||
| 657 | 'f.date_valid' => 'DateValidation' |
||
| 658 | ); |
||
| 659 | if (isModEnabled("multicurrency")) { |
||
| 660 | $this->import_fields_array[$r]['f.multicurrency_code'] = 'Currency'; |
||
| 661 | $this->import_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; |
||
| 662 | $this->import_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; |
||
| 663 | $this->import_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; |
||
| 664 | $this->import_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; |
||
| 665 | } |
||
| 666 | // Add extra fields |
||
| 667 | $import_extrafield_sample = array(); |
||
| 668 | $sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn' AND entity IN (0, " . $conf->entity . ")"; |
||
| 669 | $resql = $this->db->query($sql); |
||
| 670 | if ($resql) { |
||
| 671 | while ($obj = $this->db->fetch_object($resql)) { |
||
| 672 | $fieldname = 'extra.' . $obj->name; |
||
| 673 | $fieldlabel = ucfirst($obj->label); |
||
| 674 | $this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); |
||
| 675 | $import_extrafield_sample[$fieldname] = $fieldlabel; |
||
| 676 | } |
||
| 677 | } |
||
| 678 | // End add extra fields |
||
| 679 | $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'facture_fourn'); |
||
| 680 | if (empty($conf->multicurrency->enabled)) { |
||
| 681 | $this->import_fieldshidden_array[$r]['f.multicurrency_code'] = 'const-' . $conf->currency; |
||
| 682 | } |
||
| 683 | $this->import_regex_array[$r] = array('f.multicurrency_code' => 'code@' . MAIN_DB_PREFIX . 'multicurrency'); |
||
| 684 | $import_sample = array( |
||
| 685 | 'f.ref' => '(PROV001)', |
||
| 686 | 'f.ref_supplier' => 'Supplier1', |
||
| 687 | 'f.type' => '0', |
||
| 688 | 'f.fk_soc' => 'Vendor1', |
||
| 689 | 'f.datec' => '2021-01-01', |
||
| 690 | 'f.datef' => '', |
||
| 691 | 'f.date_lim_reglement' => '2021-01-30', |
||
| 692 | 'f.total_ht' => '1000', |
||
| 693 | 'f.total_ttc' => '1000', |
||
| 694 | 'f.total_tva' => '0', |
||
| 695 | 'f.paye' => '0', |
||
| 696 | 'f.fk_statut' => '0', |
||
| 697 | 'f.fk_user_modif' => '', |
||
| 698 | 'f.fk_user_valid' => '', |
||
| 699 | 'f.fk_facture_source' => '', |
||
| 700 | 'f.fk_projet' => '', |
||
| 701 | 'f.fk_account' => 'BANK1', |
||
| 702 | 'f.note_public' => 'Note: ', |
||
| 703 | 'f.note_private' => '', |
||
| 704 | 'f.fk_cond_reglement' => '1', |
||
| 705 | 'f.fk_mode_reglement' => '2', |
||
| 706 | 'f.model_pdf' => 'crab', |
||
| 707 | 'f.date_valid' => '', |
||
| 708 | 'f.multicurrency_code' => 'USD', |
||
| 709 | 'f.multicurrency_tx' => '1', |
||
| 710 | 'f.multicurrency_total_ht' => '1000', |
||
| 711 | 'f.multicurrency_total_tva' => '0', |
||
| 712 | 'f.multicurrency_total_ttc' => '1000' |
||
| 713 | ); |
||
| 714 | $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); |
||
| 715 | $this->import_updatekeys_array[$r] = array('f.ref' => 'Ref'); |
||
| 716 | $this->import_convertvalue_array[$r] = array( |
||
| 717 | 'f.ref' => array( |
||
| 718 | 'rule' => 'getrefifauto', |
||
| 719 | 'class' => (!getDolGlobalString('INVOICE_SUPPLIER_ADDON_NUMBER') ? 'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER), |
||
| 720 | 'path' => "/core/modules/supplier_invoice/" . (!getDolGlobalString('INVOICE_SUPPLIER_ADDON_NUMBER') ? 'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) . '.php', |
||
| 721 | 'classobject' => 'FactureFournisseur', |
||
| 722 | 'pathobject' => '/fourn/class/fournisseur.facture.class.php', |
||
| 723 | ), |
||
| 724 | 'f.fk_soc' => array('rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'), |
||
| 725 | 'f.fk_account' => array('rule' => 'fetchidfromref', 'file' => '/compta/bank/class/account.class.php', 'class' => 'Account', 'method' => 'fetch', 'element' => 'bank_account'), |
||
| 726 | ); |
||
| 727 | |||
| 728 | //Import Supplier Invoice Lines |
||
| 729 | $r++; |
||
| 730 | $this->import_code[$r] = $this->rights_class . '_' . $r; |
||
| 731 | $this->import_label[$r] = "SupplierInvoiceLines"; // Translation key |
||
| 732 | $this->import_icon[$r] = $this->picto; |
||
| 733 | $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
||
| 734 | $this->import_tables_array[$r] = array('fd' => MAIN_DB_PREFIX . 'facture_fourn_det', 'extra' => MAIN_DB_PREFIX . 'facture_fourn_det_extrafields'); |
||
| 735 | $this->import_fields_array[$r] = array( |
||
| 736 | 'fd.fk_facture_fourn' => 'InvoiceRef*', |
||
| 737 | 'fd.fk_parent_line' => 'ParentLine', |
||
| 738 | 'fd.fk_product' => 'IdProduct', |
||
| 739 | 'fd.description' => 'LineDescription', |
||
| 740 | 'fd.pu_ht' => 'PriceUHT', |
||
| 741 | 'fd.pu_ttc' => 'PriceUTTC', |
||
| 742 | 'fd.qty' => 'LineQty', |
||
| 743 | 'fd.remise_percent' => 'Reduc.', |
||
| 744 | 'fd.vat_src_code' => 'Vat Source Code', |
||
| 745 | 'fd.product_type' => 'TypeOfLineServiceOrProduct', |
||
| 746 | 'fd.tva_tx' => 'LineVATRate', |
||
| 747 | 'fd.total_ht' => 'LineTotalHT', |
||
| 748 | 'fd.tva' => 'LineTotalVAT', |
||
| 749 | 'fd.total_ttc' => 'LineTotalTTC', |
||
| 750 | 'fd.date_start' => 'Start Date', |
||
| 751 | 'fd.date_end' => 'End Date', |
||
| 752 | 'fd.fk_unit' => 'Unit' |
||
| 753 | ); |
||
| 754 | if (isModEnabled("multicurrency")) { |
||
| 755 | $this->import_fields_array[$r]['fd.multicurrency_code'] = 'Currency'; |
||
| 756 | $this->import_fields_array[$r]['fd.multicurrency_subprice'] = 'CurrencyRate'; |
||
| 757 | $this->import_fields_array[$r]['fd.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; |
||
| 758 | $this->import_fields_array[$r]['fd.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; |
||
| 759 | $this->import_fields_array[$r]['fd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; |
||
| 760 | } |
||
| 761 | // Add extra fields |
||
| 762 | $import_extrafield_sample = array(); |
||
| 763 | $sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn_det' AND entity IN (0, " . $conf->entity . ")"; |
||
| 764 | $resql = $this->db->query($sql); |
||
| 765 | if ($resql) { |
||
| 766 | while ($obj = $this->db->fetch_object($resql)) { |
||
| 767 | $fieldname = 'extra.' . $obj->name; |
||
| 768 | $fieldlabel = ucfirst($obj->label); |
||
| 769 | $this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); |
||
| 770 | $import_extrafield_sample[$fieldname] = $fieldlabel; |
||
| 771 | } |
||
| 772 | } |
||
| 773 | // End add extra fields |
||
| 774 | $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'facture_fourn_det'); |
||
| 775 | $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'); |
||
| 776 | $import_sample = array( |
||
| 777 | 'fd.fk_facture_fourn' => '(PROV001)', |
||
| 778 | 'fd.fk_parent_line' => '', |
||
| 779 | 'fd.fk_product' => '', |
||
| 780 | 'fd.description' => 'Test Product', |
||
| 781 | 'fd.pu_ht' => '50000', |
||
| 782 | 'fd.pu_ttc' => '50000', |
||
| 783 | 'fd.qty' => '1', |
||
| 784 | 'fd.remise_percent' => '0', |
||
| 785 | 'fd.vat_src_code' => '', |
||
| 786 | 'fd.product_type' => '0', |
||
| 787 | 'fd.tva_tx' => '0', |
||
| 788 | 'fd.total_ht' => '50000', |
||
| 789 | 'fd.tva' => '0', |
||
| 790 | 'fd.total_ttc' => '50000', |
||
| 791 | 'fd.date_start' => '', |
||
| 792 | 'fd.date_end' => '', |
||
| 793 | 'fd.fk_unit' => '', |
||
| 794 | 'fd.multicurrency_code' => 'USD', |
||
| 795 | 'fd.multicurrency_tx' => '0', |
||
| 796 | 'fd.multicurrency_total_ht' => '50000', |
||
| 797 | 'fd.multicurrency_total_tva' => '0', |
||
| 798 | 'fd.multicurrency_total_ttc' => '50000' |
||
| 799 | ); |
||
| 800 | $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); |
||
| 801 | $this->import_updatekeys_array[$r] = array('fd.rowid' => 'Row Id', 'fd.fk_facture_fourn' => 'Invoice Id', 'fd.fk_product' => 'Product Id'); |
||
| 802 | $this->import_convertvalue_array[$r] = array( |
||
| 803 | 'fd.fk_facture_fourn' => array('rule' => 'fetchidfromref', 'file' => '/fourn/class/fournisseur.facture.class.php', 'class' => 'FactureFournisseur', 'method' => 'fetch'), |
||
| 804 | ); |
||
| 805 | |||
| 806 | //Import Purchase Orders |
||
| 807 | $r++; |
||
| 808 | $this->import_code[$r] = 'commande_fournisseur_' . $r; |
||
| 809 | $this->import_label[$r] = 'SuppliersOrders'; |
||
| 810 | $this->import_icon[$r] = $this->picto; |
||
| 811 | $this->import_entities_array[$r] = array(); |
||
| 812 | $this->import_tables_array[$r] = array('c' => MAIN_DB_PREFIX . 'commande_fournisseur', 'extra' => MAIN_DB_PREFIX . 'commande_fournisseur_extrafields'); |
||
| 813 | $this->import_tables_creator_array[$r] = array('c' => 'fk_user_author'); // Fields to store import user id |
||
| 814 | $this->import_fields_array[$r] = array( |
||
| 815 | 'c.ref' => 'Ref*', |
||
| 816 | 'c.ref_supplier' => 'RefSupplier', |
||
| 817 | 'c.fk_soc' => 'ThirdPartyName*', |
||
| 818 | 'c.fk_projet' => 'ProjectId', |
||
| 819 | 'c.date_creation' => 'DateCreation', |
||
| 820 | 'c.date_valid' => 'DateValidation', |
||
| 821 | 'c.date_approve' => 'DateApprove', |
||
| 822 | 'c.date_commande' => 'DateOrder', |
||
| 823 | 'c.fk_user_modif' => 'ModifiedById', |
||
| 824 | 'c.fk_user_valid' => 'ValidatedById', |
||
| 825 | 'c.fk_user_approve' => 'ApprovedById', |
||
| 826 | 'c.source' => 'Source', |
||
| 827 | 'c.fk_statut' => 'Status*', |
||
| 828 | 'c.billed' => 'Billed', |
||
| 829 | 'c.total_tva' => 'TotalTVA', |
||
| 830 | 'c.total_ht' => 'TotalHT', |
||
| 831 | 'c.total_ttc' => 'TotalTTC', |
||
| 832 | 'c.note_private' => 'NotePrivate', |
||
| 833 | 'c.note_public' => 'Note', |
||
| 834 | 'c.date_livraison' => 'DeliveryDate', |
||
| 835 | 'c.fk_cond_reglement' => 'Payment Condition', |
||
| 836 | 'c.fk_mode_reglement' => 'Payment Mode', |
||
| 837 | 'c.model_pdf' => 'Model' |
||
| 838 | ); |
||
| 839 | |||
| 840 | if (isModEnabled("multicurrency")) { |
||
| 841 | $this->import_fields_array[$r]['c.multicurrency_code'] = 'Currency'; |
||
| 842 | $this->import_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate'; |
||
| 843 | $this->import_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; |
||
| 844 | $this->import_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; |
||
| 845 | $this->import_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; |
||
| 846 | } |
||
| 847 | |||
| 848 | // Add extra fields |
||
| 849 | $import_extrafield_sample = array(); |
||
| 850 | $sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseur' AND entity IN (0, " . $conf->entity . ")"; |
||
| 851 | $resql = $this->db->query($sql); |
||
| 852 | |||
| 853 | if ($resql) { |
||
| 854 | while ($obj = $this->db->fetch_object($resql)) { |
||
| 855 | $fieldname = 'extra.' . $obj->name; |
||
| 856 | $fieldlabel = ucfirst($obj->label); |
||
| 857 | $this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); |
||
| 858 | $import_extrafield_sample[$fieldname] = $fieldlabel; |
||
| 859 | } |
||
| 860 | } |
||
| 861 | // End add extra fields |
||
| 862 | |||
| 863 | $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'commande_fournisseur'); |
||
| 864 | $this->import_regex_array[$r] = array( |
||
| 865 | 'c.multicurrency_code' => 'code@' . MAIN_DB_PREFIX . 'multicurrency' |
||
| 866 | ); |
||
| 867 | |||
| 868 | $this->import_updatekeys_array[$r] = array('c.ref' => 'Ref'); |
||
| 869 | $this->import_convertvalue_array[$r] = array( |
||
| 870 | 'c.ref' => array( |
||
| 871 | 'rule' => 'getrefifauto', |
||
| 872 | 'class' => (!getDolGlobalString('COMMANDE_SUPPLIER_ADDON_NUMBER') ? 'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER), |
||
| 873 | 'path' => "/core/modules/supplier_order/" . (!getDolGlobalString('COMMANDE_SUPPLIER_ADDON_NUMBER') ? 'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) . '.php', |
||
| 874 | 'classobject' => 'CommandeFournisseur', |
||
| 875 | 'pathobject' => '/fourn/class/fournisseur.commande.class.php', |
||
| 876 | ), |
||
| 877 | 'c.fk_soc' => array( |
||
| 878 | 'rule' => 'fetchidfromref', |
||
| 879 | 'file' => '/societe/class/societe.class.php', |
||
| 880 | 'class' => 'Societe', |
||
| 881 | 'method' => 'fetch', |
||
| 882 | 'element' => 'ThirdParty' |
||
| 883 | ), |
||
| 884 | 'c.fk_mode_reglement' => array( |
||
| 885 | 'rule' => 'fetchidfromcodeorlabel', |
||
| 886 | 'file' => '/compta/paiement/class/cpaiement.class.php', |
||
| 887 | 'class' => 'Cpaiement', |
||
| 888 | 'method' => 'fetch', |
||
| 889 | 'element' => 'cpayment' |
||
| 890 | ), |
||
| 891 | 'c.source' => array('rule' => 'zeroifnull'), |
||
| 892 | ); |
||
| 893 | |||
| 894 | // Import PO Lines |
||
| 895 | $r++; |
||
| 896 | $this->import_code[$r] = 'commande_fournisseurdet_' . $r; |
||
| 897 | $this->import_label[$r] = 'PurchaseOrderLines'; |
||
| 898 | $this->import_icon[$r] = $this->picto; |
||
| 899 | $this->import_entities_array[$r] = array(); |
||
| 900 | $this->import_tables_array[$r] = array('cd' => MAIN_DB_PREFIX . 'commande_fournisseurdet', 'extra' => MAIN_DB_PREFIX . 'commande_fournisseurdet_extrafields'); |
||
| 901 | $this->import_fields_array[$r] = array( |
||
| 902 | 'cd.fk_commande' => 'PurchaseOrder*', |
||
| 903 | 'cd.fk_parent_line' => 'ParentLine', |
||
| 904 | 'cd.fk_product' => 'IdProduct', |
||
| 905 | 'cd.ref' => 'SupplierRef', |
||
| 906 | 'cd.description' => 'LineDescription', |
||
| 907 | 'cd.tva_tx' => 'LineVATRate', |
||
| 908 | 'cd.qty' => 'LineQty', |
||
| 909 | 'cd.remise_percent' => 'Reduc. Percent', |
||
| 910 | 'cd.subprice' => 'Sub Price', |
||
| 911 | 'cd.total_ht' => 'LineTotalHT', |
||
| 912 | 'cd.total_tva' => 'LineTotalVAT', |
||
| 913 | 'cd.total_ttc' => 'LineTotalTTC', |
||
| 914 | 'cd.product_type' => 'TypeOfLineServiceOrProduct', |
||
| 915 | 'cd.date_start' => 'Start Date', |
||
| 916 | 'cd.date_end' => 'End Date', |
||
| 917 | 'cd.info_bits' => 'InfoBits', |
||
| 918 | 'cd.special_code' => 'Special Code', |
||
| 919 | 'cd.rang' => 'LinePosition', |
||
| 920 | 'cd.fk_unit' => 'Unit' |
||
| 921 | ); |
||
| 922 | |||
| 923 | if (isModEnabled("multicurrency")) { |
||
| 924 | $this->import_fields_array[$r]['cd.multicurrency_code'] = 'Currency'; |
||
| 925 | $this->import_fields_array[$r]['cd.multicurrency_subprice'] = 'CurrencyRate'; |
||
| 926 | $this->import_fields_array[$r]['cd.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; |
||
| 927 | $this->import_fields_array[$r]['cd.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; |
||
| 928 | $this->import_fields_array[$r]['cd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; |
||
| 929 | } |
||
| 930 | |||
| 931 | // Add extra fields |
||
| 932 | $sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseurdet' AND entity IN (0, " . $conf->entity . ")"; |
||
| 933 | $resql = $this->db->query($sql); |
||
| 934 | if ($resql) { |
||
| 935 | while ($obj = $this->db->fetch_object($resql)) { |
||
| 936 | $fieldname = 'extra.' . $obj->name; |
||
| 937 | $fieldlabel = ucfirst($obj->label); |
||
| 938 | $this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); |
||
| 939 | } |
||
| 940 | } |
||
| 941 | // End add extra fields |
||
| 942 | |||
| 943 | $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'commande_fournisseurdet'); |
||
| 944 | $this->import_regex_array[$r] = array( |
||
| 945 | 'cd.product_type' => '[0|1]$', |
||
| 946 | 'cd.fk_product' => 'rowid@' . MAIN_DB_PREFIX . 'product', |
||
| 947 | 'cd.multicurrency_code' => 'code@' . MAIN_DB_PREFIX . 'multicurrency' |
||
| 948 | ); |
||
| 949 | $this->import_updatekeys_array[$r] = array('cd.fk_commande' => 'Purchase Order Id'); |
||
| 950 | $this->import_convertvalue_array[$r] = array( |
||
| 951 | 'cd.fk_commande' => array( |
||
| 952 | 'rule' => 'fetchidfromref', |
||
| 953 | 'file' => '/fourn/class/fournisseur.commande.class.php', |
||
| 954 | 'class' => 'CommandeFournisseur', |
||
| 955 | 'method' => 'fetch', |
||
| 956 | 'element' => 'order_supplier' |
||
| 957 | ), |
||
| 958 | 'cd.info_bits' => array('rule' => 'zeroifnull'), |
||
| 959 | 'cd.special_code' => array('rule' => 'zeroifnull'), |
||
| 960 | ); |
||
| 1029 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..