| Conditions | 107 | 
| Total Lines | 809 | 
| Code Lines | 608 | 
| 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  | 
            ||
| 49 | public function __construct($db)  | 
            ||
| 50 |     { | 
            ||
| 51 | global $conf, $mysoc;  | 
            ||
| 52 | |||
| 53 | $this->db = $db;  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 54 | $this->numero = 53;  | 
            ||
| 55 | |||
| 56 | $this->family = "products";  | 
            ||
| 57 | $this->module_position = '29';  | 
            ||
| 58 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)  | 
            ||
| 59 |         $this->name = preg_replace('/^mod/i', '', get_class($this)); | 
            ||
| 60 | $this->description = "Service management";  | 
            ||
| 61 | |||
| 62 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version  | 
            ||
| 63 | $this->version = 'dolibarr';  | 
            ||
| 64 | |||
| 65 | $this->const_name = 'MAIN_MODULE_' . static::getNameOf($this->name); // strtoupper($this->name);  | 
            ||
| 66 | $this->picto = 'service';  | 
            ||
| 67 | |||
| 68 | // Data directories to create when module is enabled  | 
            ||
| 69 |         $this->dirs = array("/product/temp"); | 
            ||
| 70 | |||
| 71 | // Dependencies  | 
            ||
| 72 | $this->hidden = false; // A condition to hide module  | 
            ||
| 73 | $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled  | 
            ||
| 74 | $this->requiredby = array(); // List of module ids to disable if this one is disabled  | 
            ||
| 75 | $this->conflictwith = array(); // List of module class names as string this module is in conflict with  | 
            ||
| 76 | $this->phpmin = array(7, 0); // Minimum version of PHP required by module  | 
            ||
| 77 | |||
| 78 | // Config pages  | 
            ||
| 79 |         $this->config_page_url = array("product.php@product"); | 
            ||
| 80 |         $this->langfiles = array("products", "companies", "stocks", "bills"); | 
            ||
| 81 | |||
| 82 | // Constants  | 
            ||
| 83 | $this->const = array();  | 
            ||
| 84 | |||
| 85 | // Boxes  | 
            ||
| 86 | $this->boxes = array(  | 
            ||
| 87 |             0 => array('file' => 'box_services_contracts.php', 'enabledbydefaulton' => 'Home'), | 
            ||
| 88 |             1 => array('file' => 'box_graph_product_distribution.php', 'enabledbydefaulton' => 'Home') | 
            ||
| 89 | );  | 
            ||
| 90 | |||
| 91 | // Permissions  | 
            ||
| 92 | $this->rights = array();  | 
            ||
| 93 | $this->rights_class = 'service';  | 
            ||
| 94 | $r = 0;  | 
            ||
| 95 | |||
| 96 | $this->rights[$r][0] = 531; // id de la permission  | 
            ||
| 97 | $this->rights[$r][1] = 'Read services'; // libelle de la permission  | 
            ||
| 98 | $this->rights[$r][2] = 'r'; // type de la permission (deprecated)  | 
            ||
| 99 | $this->rights[$r][3] = 0; // La permission est-elle une permission par default  | 
            ||
| 100 | $this->rights[$r][4] = 'lire';  | 
            ||
| 101 | $r++;  | 
            ||
| 102 | |||
| 103 | $this->rights[$r][0] = 532; // id de la permission  | 
            ||
| 104 | $this->rights[$r][1] = 'Create/modify services'; // libelle de la permission  | 
            ||
| 105 | $this->rights[$r][2] = 'w'; // type de la permission (deprecated)  | 
            ||
| 106 | $this->rights[$r][3] = 0; // La permission est-elle une permission par default  | 
            ||
| 107 | $this->rights[$r][4] = 'creer';  | 
            ||
| 108 | $r++;  | 
            ||
| 109 | |||
| 110 | $this->rights[$r][0] = 533; // id de la permission  | 
            ||
| 111 | $this->rights[$r][1] = 'Read prices services'; // libelle de la permission  | 
            ||
| 112 | $this->rights[$r][2] = 'w'; // type de la permission (deprecated)  | 
            ||
| 113 | $this->rights[$r][3] = 0; // La permission est-elle une permission par default  | 
            ||
| 114 | $this->rights[$r][4] = 'service_advance';  | 
            ||
| 115 | $this->rights[$r][5] = 'read_prices';  | 
            ||
| 116 | $r++;  | 
            ||
| 117 | |||
| 118 | $this->rights[$r][0] = 534; // id de la permission  | 
            ||
| 119 | $this->rights[$r][1] = 'Delete les services'; // libelle de la permission  | 
            ||
| 120 | $this->rights[$r][2] = 'd'; // type de la permission (deprecated)  | 
            ||
| 121 | $this->rights[$r][3] = 0; // La permission est-elle une permission par default  | 
            ||
| 122 | $this->rights[$r][4] = 'supprimer';  | 
            ||
| 123 | $r++;  | 
            ||
| 124 | |||
| 125 | $this->rights[$r][0] = 538; // Must be same permission than in product module  | 
            ||
| 126 | $this->rights[$r][1] = 'Export services';  | 
            ||
| 127 | $this->rights[$r][2] = 'r';  | 
            ||
| 128 | $this->rights[$r][3] = 0;  | 
            ||
| 129 | $this->rights[$r][4] = 'export';  | 
            ||
| 130 | $r++;  | 
            ||
| 131 | |||
| 132 | // Menus  | 
            ||
| 133 | //-------  | 
            ||
| 134 | $this->menu = 1; // This module add menu entries. They are coded into menu manager.  | 
            ||
| 135 | /* We can't enable this here because it must be enabled in both product and service module and this creates duplicate inserts  | 
            ||
| 136 | $r=0;  | 
            ||
| 137 | $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode  | 
            ||
| 138 | 'type'=>'left', // This is a Left menu entry  | 
            ||
| 139 | 'titre'=>'ProductVatMassChange',  | 
            ||
| 140 | 'url'=>'/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools',  | 
            ||
| 141 | 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.  | 
            ||
| 142 | 'position'=>300,  | 
            ||
| 143 |          'enabled'=>'isModEnabled("product") && preg_match(\'/^(admintools|all)/\',$leftmenu)',   // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. | 
            ||
| 144 |          'perms'=>'1',                          // Use 'perms'=>'$user->hasRight("mymodule","level1","level2")' if you want your menu with a permission rules | 
            ||
| 145 | 'target'=>'',  | 
            ||
| 146 | 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both  | 
            ||
| 147 | $r++;  | 
            ||
| 148 | */  | 
            ||
| 149 | |||
| 150 | $usenpr = 0;  | 
            ||
| 151 |         if (is_object($mysoc)) { | 
            ||
| 152 | $usenpr = $mysoc->useNPR();  | 
            ||
| 153 | }  | 
            ||
| 154 | |||
| 155 | // Exports  | 
            ||
| 156 | //--------  | 
            ||
| 157 | $r = 0;  | 
            ||
| 158 | |||
| 159 |         $alias_product_perentity = !getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED') ? "p" : "ppe"; | 
            ||
| 160 | |||
| 161 | $r++;  | 
            ||
| 162 | $this->export_code[$r] = $this->rights_class . '_' . $r;  | 
            ||
| 163 | $this->export_label[$r] = "Services"; // Translation key (used only if key ExportDataset_xxx_z not found)  | 
            ||
| 164 |         $this->export_permission[$r] = array(array("service", "export")); | 
            ||
| 165 | $this->export_fields_array[$r] = array(  | 
            ||
| 166 | 'p.rowid' => "Id", 'p.ref' => "Ref", 'p.label' => "Label",  | 
            ||
| 167 | 'p.fk_product_type' => 'Type', 'p.tosell' => "OnSell", 'p.tobuy' => "OnBuy",  | 
            ||
| 168 | 'p.description' => "Description", 'p.url' => "PublicUrl",  | 
            ||
| 169 | 'p.customcode' => 'CustomCode', 'p.fk_country' => 'IDCountry',  | 
            ||
| 170 | $alias_product_perentity . '.accountancy_code_sell' => "ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",  | 
            ||
| 171 | $alias_product_perentity . '.accountancy_code_sell_export' => "ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy' => "ProductAccountancyBuyCode",  | 
            ||
| 172 | $alias_product_perentity . '.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode",  | 
            ||
| 173 | 'p.note' => "NotePrivate", 'p.note_public' => 'NotePublic',  | 
            ||
| 174 | 'p.weight' => "Weight", 'p.length' => "Length", 'p.width' => "Width", 'p.height' => "Height", 'p.surface' => "Surface", 'p.volume' => "Volume",  | 
            ||
| 175 | 'p.duration' => "Duration",  | 
            ||
| 176 | 'p.finished' => 'Nature',  | 
            ||
| 177 | 'p.price_base_type' => "PriceBase", 'p.price' => "UnitPriceHT", 'p.price_ttc' => "UnitPriceTTC",  | 
            ||
| 178 | 'p.tva_tx' => 'VATRate',  | 
            ||
| 179 | 'p.datec' => 'DateCreation', 'p.tms' => 'DateModification'  | 
            ||
| 180 | );  | 
            ||
| 181 |         if (is_object($mysoc) && $usenpr) { | 
            ||
| 182 | $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR';  | 
            ||
| 183 | }  | 
            ||
| 184 |         if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { | 
            ||
| 185 |             $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price' => 'CostPrice')); | 
            ||
| 186 | }  | 
            ||
| 187 |         if (isModEnabled('stock')) { | 
            ||
| 188 |             $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock' => 'Stock', 'p.seuil_stock_alerte' => 'StockLimit', 'p.desiredstock' => 'DesiredStock', 'p.pmp' => 'PMPValue')); | 
            ||
| 189 | }  | 
            ||
| 190 |         if (isModEnabled('barcode')) { | 
            ||
| 191 |             $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode' => 'BarCode')); | 
            ||
| 192 | }  | 
            ||
| 193 | $keyforselect = 'product';  | 
            ||
| 194 | $keyforelement = 'product';  | 
            ||
| 195 | $keyforaliasextra = 'extra';  | 
            ||
| 196 | include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php';  | 
            ||
| 197 |         if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { | 
            ||
| 198 |             $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom' => 'Supplier', 'pf.ref_fourn' => 'SupplierRef', 'pf.quantity' => 'QtyMin', 'pf.remise_percent' => 'DiscountQtyMin', 'pf.unitprice' => 'BuyingPrice', 'pf.delivery_time_days' => 'NbDaysToDelivery')); | 
            ||
| 199 | }  | 
            ||
| 200 |         if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) { | 
            ||
| 201 |             $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('group_concat(cat.label)' => 'Categories')); | 
            ||
| 202 | }  | 
            ||
| 203 |         if (getDolGlobalInt('MAIN_MULTILANGS')) { | 
            ||
| 204 |             $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('l.lang' => 'Language', 'l.label' => 'TranslatedLabel', 'l.description' => 'TranslatedDescription', 'l.note' => 'TranslatedNote')); | 
            ||
| 205 | }  | 
            ||
| 206 |         if (getDolGlobalInt('PRODUCT_USE_UNITS')) { | 
            ||
| 207 | $this->export_fields_array[$r]['p.fk_unit'] = 'Unit';  | 
            ||
| 208 | }  | 
            ||
| 209 | $this->export_TypeFields_array[$r] = array(  | 
            ||
| 210 | 'p.ref' => "Text", 'p.label' => "Text",  | 
            ||
| 211 | 'p.fk_product_type' => 'Numeric', 'p.tosell' => "Boolean", 'p.tobuy' => "Boolean",  | 
            ||
| 212 | 'p.description' => "Text", 'p.url' => "Text",  | 
            ||
| 213 | $alias_product_perentity . '.accountancy_code_sell' => "Text", $alias_product_perentity . '.accountancy_code_sell_intra' => "Text", $alias_product_perentity . '.accountancy_code_sell_export' => "Text",  | 
            ||
| 214 | $alias_product_perentity . '.accountancy_code_buy' => "Text", $alias_product_perentity . '.accountancy_code_buy_intra' => "Text", $alias_product_perentity . '.accountancy_code_buy_export' => "Text",  | 
            ||
| 215 | 'p.note' => "Text", 'p.note_public' => "Text",  | 
            ||
| 216 | 'p.weight' => "Numeric", 'p.length' => "Numeric", 'p.width' => "Numeric", 'p.height' => "Numeric", 'p.surface' => "Numeric", 'p.volume' => "Numeric",  | 
            ||
| 217 | 'p.customcode' => 'Text',  | 
            ||
| 218 | 'p.duration' => "Text",  | 
            ||
| 219 | 'p.finished' => 'Numeric',  | 
            ||
| 220 | 'p.price_base_type' => "Text", 'p.price' => "Numeric", 'p.price_ttc' => "Numeric", 'p.tva_tx' => 'Numeric',  | 
            ||
| 221 | 'p.datec' => 'Date', 'p.tms' => 'Date'  | 
            ||
| 222 | );  | 
            ||
| 223 |         if (isModEnabled('stock')) { | 
            ||
| 224 |             $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock' => 'Numeric', 'p.seuil_stock_alerte' => 'Numeric', 'p.desiredstock' => 'Numeric', 'p.pmp' => 'Numeric', 'p.cost_price' => 'Numeric')); | 
            ||
| 225 | }  | 
            ||
| 226 |         if (isModEnabled('barcode')) { | 
            ||
| 227 |             $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode' => 'Text')); | 
            ||
| 228 | }  | 
            ||
| 229 |         if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { | 
            ||
| 230 |             $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom' => 'Text', 'pf.ref_fourn' => 'Text', 'pf.unitprice' => 'Numeric', 'pf.quantity' => 'Numeric', 'pf.remise_percent' => 'Numeric', 'pf.delivery_time_days' => 'Numeric')); | 
            ||
| 231 | }  | 
            ||
| 232 |         if (getDolGlobalInt('MAIN_MULTILANGS')) { | 
            ||
| 233 |             $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('l.lang' => 'Text', 'l.label' => 'Text', 'l.description' => 'Text', 'l.note' => 'Text')); | 
            ||
| 234 | }  | 
            ||
| 235 |         if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) { | 
            ||
| 236 |             $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)" => 'Text')); | 
            ||
| 237 | }  | 
            ||
| 238 | $this->export_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon  | 
            ||
| 239 |         if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) { | 
            ||
| 240 |             $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array("group_concat(cat.label)" => 'category')); | 
            ||
| 241 | }  | 
            ||
| 242 |         if (isModEnabled('stock')) { | 
            ||
| 243 |             $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock' => 'product', 'p.pmp' => 'product')); | 
            ||
| 244 | }  | 
            ||
| 245 |         if (isModEnabled('barcode')) { | 
            ||
| 246 |             $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode' => 'product')); | 
            ||
| 247 | }  | 
            ||
| 248 |         if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { | 
            ||
| 249 |             $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom' => 'product_supplier_ref', 'pf.ref_fourn' => 'product_supplier_ref', 'pf.unitprice' => 'product_supplier_ref', 'pf.quantity' => 'product_supplier_ref', 'pf.remise_percent' => 'product_supplier_ref', 'pf.delivery_time_days' => 'product_supplier_ref')); | 
            ||
| 250 | }  | 
            ||
| 251 |         if (getDolGlobalInt('MAIN_MULTILANGS')) { | 
            ||
| 252 |             $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang' => 'translation', 'l.label' => 'translation', 'l.description' => 'translation', 'l.note' => 'translation')); | 
            ||
| 253 | }  | 
            ||
| 254 |         if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) { | 
            ||
| 255 |             $this->export_dependencies_array[$r] = array('category' => 'p.rowid'); | 
            ||
| 256 | }  | 
            ||
| 257 |         if (isModEnabled('stock')) { | 
            ||
| 258 |             $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock' => 'product', 'p.pmp' => 'product')); | 
            ||
| 259 | }  | 
            ||
| 260 |         if (isModEnabled('barcode')) { | 
            ||
| 261 |             $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode' => 'product')); | 
            ||
| 262 | }  | 
            ||
| 263 |         if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { | 
            ||
| 264 |             $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom' => 'product_supplier_ref', 'pf.ref_fourn' => 'product_supplier_ref', 'pf.unitprice' => 'product_supplier_ref', 'pf.quantity' => 'product_supplier_ref', 'pf.remise_percent' => 'product_supplier_ref', 'pf.delivery_time_days' => 'product_supplier_ref')); | 
            ||
| 265 | }  | 
            ||
| 266 |         if (getDolGlobalInt('MAIN_MULTILANGS')) { | 
            ||
| 267 |             $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang' => 'translation', 'l.label' => 'translation', 'l.description' => 'translation', 'l.note' => 'translation')); | 
            ||
| 268 | }  | 
            ||
| 269 |         if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) { | 
            ||
| 270 |             $this->export_dependencies_array[$r] = array('category' => 'p.rowid'); | 
            ||
| 271 | }  | 
            ||
| 272 | $this->export_sql_start[$r] = 'SELECT DISTINCT ';  | 
            ||
| 273 | $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'product as p';  | 
            ||
| 274 |         if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { | 
            ||
| 275 | $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int)$conf->entity);  | 
            ||
| 276 | }  | 
            ||
| 277 |         if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) { | 
            ||
| 278 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie as cat ON cp.fk_categorie = cat.rowid';  | 
            ||
| 279 | }  | 
            ||
| 280 |         if (getDolGlobalInt('MAIN_MULTILANGS')) { | 
            ||
| 281 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_lang as l ON l.fk_product = p.rowid';  | 
            ||
| 282 | }  | 
            ||
| 283 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_extrafields as extra ON p.rowid = extra.fk_object';  | 
            ||
| 284 |         if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { | 
            ||
| 285 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN ' . MAIN_DB_PREFIX . 'societe s ON s.rowid = pf.fk_soc';  | 
            ||
| 286 | }  | 
            ||
| 287 |         $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 1 AND p.entity IN (' . getEntity('product') . ')'; | 
            ||
| 288 |         if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) { | 
            ||
| 289 | $this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields"  | 
            ||
| 290 | }  | 
            ||
| 291 | |||
| 292 |         if (!isModEnabled("product")) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries) | 
            ||
| 293 |             if (getDolGlobalString('PRODUIT_MULTIPRICES')) { | 
            ||
| 294 | // Exports product multiprice  | 
            ||
| 295 | $r++;  | 
            ||
| 296 | $this->export_code[$r] = $this->rights_class . '_' . $r;  | 
            ||
| 297 | $this->export_label[$r] = "ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found)  | 
            ||
| 298 |                 $this->export_permission[$r] = array(array("service", "export")); | 
            ||
| 299 |                 $this->export_fields_array[$r] = array('p.rowid' => "Id", 'p.ref' => "Ref", | 
            ||
| 300 | 'pr.price_base_type' => "PriceBase", 'pr.price_level' => "PriceLevel",  | 
            ||
| 301 | 'pr.price' => "PriceLevelUnitPriceHT", 'pr.price_ttc' => "PriceLevelUnitPriceTTC",  | 
            ||
| 302 | 'pr.price_min' => "MinPriceLevelUnitPriceHT", 'pr.price_min_ttc' => "MinPriceLevelUnitPriceTTC",  | 
            ||
| 303 | 'pr.tva_tx' => 'PriceLevelVATRate',  | 
            ||
| 304 | 'pr.date_price' => 'DateCreation');  | 
            ||
| 305 |                 if (is_object($mysoc) && $usenpr) { | 
            ||
| 306 | $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';  | 
            ||
| 307 | }  | 
            ||
| 308 | //$this->export_TypeFields_array[$r]=array(  | 
            ||
| 309 | // 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",  | 
            ||
| 310 | // 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text',  | 
            ||
| 311 | // 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",  | 
            ||
| 312 | // 'p.datec'=>'Date','p.tms'=>'Date'  | 
            ||
| 313 | //);  | 
            ||
| 314 |                 $this->export_entities_array[$r] = array('p.rowid' => "product", 'p.ref' => "product", | 
            ||
| 315 | 'pr.price_base_type' => "product", 'pr.price_level' => "product", 'pr.price' => "product",  | 
            ||
| 316 | 'pr.price_ttc' => "product",  | 
            ||
| 317 | 'pr.price_min' => "product", 'pr.price_min_ttc' => "product",  | 
            ||
| 318 | 'pr.tva_tx' => 'product',  | 
            ||
| 319 | 'pr.recuperableonly' => 'product',  | 
            ||
| 320 | 'pr.date_price' => "product");  | 
            ||
| 321 | $this->export_sql_start[$r] = 'SELECT DISTINCT ';  | 
            ||
| 322 | $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'product as p';  | 
            ||
| 323 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = ' . $conf->entity; // export prices only for the current entity  | 
            ||
| 324 |                 $this->export_sql_end[$r] .= ' WHERE p.entity IN (' . getEntity('product') . ')'; // For product and service profile | 
            ||
| 325 | }  | 
            ||
| 326 | |||
| 327 |             if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES')) { | 
            ||
| 328 | // Exports product multiprice  | 
            ||
| 329 | $r++;  | 
            ||
| 330 | $this->export_code[$r] = $this->rights_class . '_' . $r;  | 
            ||
| 331 | $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found)  | 
            ||
| 332 |                 $this->export_permission[$r] = array(array("service", "export")); | 
            ||
| 333 |                 $this->export_fields_array[$r] = array('p.rowid' => "Id", 'p.ref' => "Ref", | 
            ||
| 334 | 's.nom' => 'ThirdParty',  | 
            ||
| 335 | 'pr.price_base_type' => "PriceBase",  | 
            ||
| 336 | 'pr.price' => "PriceUnitPriceHT", 'pr.price_ttc' => "PriceUnitPriceTTC",  | 
            ||
| 337 | 'pr.price_min' => "MinPriceUnitPriceHT", 'pr.price_min_ttc' => "MinPriceUnitPriceTTC",  | 
            ||
| 338 | 'pr.tva_tx' => 'PriceVATRate',  | 
            ||
| 339 | 'pr.default_vat_code' => 'PriceVATCode',  | 
            ||
| 340 | 'pr.datec' => 'DateCreation');  | 
            ||
| 341 |                 if (is_object($mysoc) && $usenpr) { | 
            ||
| 342 | $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';  | 
            ||
| 343 | }  | 
            ||
| 344 |                 $this->export_entities_array[$r] = array('p.rowid' => "product", 'p.ref' => "product", | 
            ||
| 345 | 's.nom' => 'company',  | 
            ||
| 346 | 'pr.price_base_type' => "product", 'pr.price' => "product",  | 
            ||
| 347 | 'pr.price_ttc' => "product",  | 
            ||
| 348 | 'pr.price_min' => "product", 'pr.price_min_ttc' => "product",  | 
            ||
| 349 | 'pr.tva_tx' => 'product',  | 
            ||
| 350 | 'pr.default_vat_code' => 'product',  | 
            ||
| 351 | 'pr.recuperableonly' => 'product',  | 
            ||
| 352 | 'pr.datec' => "product");  | 
            ||
| 353 | $this->export_sql_start[$r] = 'SELECT DISTINCT ';  | 
            ||
| 354 | $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'product as p';  | 
            ||
| 355 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = ' . $conf->entity; // export prices only for the current entity  | 
            ||
| 356 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON pr.fk_soc = s.rowid';  | 
            ||
| 357 |                 $this->export_sql_end[$r] .= ' WHERE p.entity IN (' . getEntity('product') . ')'; // For product and service profile | 
            ||
| 358 | }  | 
            ||
| 359 | |||
| 360 |             if (getDolGlobalString('PRODUIT_SOUSPRODUITS')) { | 
            ||
| 361 | // Exports virtual products  | 
            ||
| 362 | $r++;  | 
            ||
| 363 | $this->export_code[$r] = $this->rights_class . '_' . $r;  | 
            ||
| 364 | $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found)  | 
            ||
| 365 |                 $this->export_permission[$r] = array(array("service", "export")); | 
            ||
| 366 | $this->export_fields_array[$r] = array(  | 
            ||
| 367 | 'p.rowid' => "Id", 'p.ref' => "Ref", 'p.label' => "Label", 'p.description' => "Description", 'p.url' => "PublicUrl",  | 
            ||
| 368 | $alias_product_perentity . '.accountancy_code_sell' => "ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",  | 
            ||
| 369 | $alias_product_perentity . '.accountancy_code_sell_export' => "ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy' => "ProductAccountancyBuyCode",  | 
            ||
| 370 | $alias_product_perentity . '.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode",  | 
            ||
| 371 | 'p.note' => "NotePrivate", 'p.note_public' => 'NotePublic',  | 
            ||
| 372 | 'p.weight' => "Weight", 'p.length' => "Length", 'p.surface' => "Surface", 'p.volume' => "Volume", 'p.customcode' => 'CustomCode',  | 
            ||
| 373 | 'p.price_base_type' => "PriceBase", 'p.price' => "UnitPriceHT", 'p.price_ttc' => "UnitPriceTTC", 'p.tva_tx' => 'VATRate', 'p.tosell' => "OnSell",  | 
            ||
| 374 | 'p.tobuy' => "OnBuy", 'p.datec' => 'DateCreation', 'p.tms' => 'DateModification'  | 
            ||
| 375 | );  | 
            ||
| 376 |                 if (isModEnabled('stock')) { | 
            ||
| 377 |                     $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock' => 'Stock', 'p.seuil_stock_alerte' => 'StockLimit', 'p.desiredstock' => 'DesiredStock', 'p.pmp' => 'PMPValue')); | 
            ||
| 378 | }  | 
            ||
| 379 |                 if (isModEnabled('barcode')) { | 
            ||
| 380 |                     $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode' => 'BarCode')); | 
            ||
| 381 | }  | 
            ||
| 382 |                 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty' => 'Qty', 'pa.incdec' => 'ComposedProductIncDecStock')); | 
            ||
| 383 | $this->export_TypeFields_array[$r] = array(  | 
            ||
| 384 | 'p.ref' => "Text", 'p.label' => "Text", 'p.description' => "Text", 'p.url' => "Text",  | 
            ||
| 385 | $alias_product_perentity . 'p.accountancy_code_sell' => "Text", $alias_product_perentity . '.accountancy_code_sell_intra' => "Text", $alias_product_perentity . '.accountancy_code_sell_export' => "Text",  | 
            ||
| 386 | $alias_product_perentity . 'p.accountancy_code_buy' => "Text", $alias_product_perentity . '.accountancy_code_buy_intra' => "Text", $alias_product_perentity . '.accountancy_code_buy_export' => "Text",  | 
            ||
| 387 | 'p.note' => "Text", 'p.note_public' => "Text",  | 
            ||
| 388 | 'p.weight' => "Numeric", 'p.length' => "Numeric", 'p.surface' => "Numeric", 'p.volume' => "Numeric", 'p.customcode' => 'Text',  | 
            ||
| 389 | 'p.price_base_type' => "Text", 'p.price' => "Numeric", 'p.price_ttc' => "Numeric", 'p.tva_tx' => 'Numeric', 'p.tosell' => "Boolean", 'p.tobuy' => "Boolean",  | 
            ||
| 390 | 'p.datec' => 'Date', 'p.tms' => 'Date'  | 
            ||
| 391 | );  | 
            ||
| 392 |                 if (isModEnabled('stock')) { | 
            ||
| 393 |                     $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock' => 'Numeric', 'p.seuil_stock_alerte' => 'Numeric', 'p.desiredstock' => 'Numeric', 'p.pmp' => 'Numeric', 'p.cost_price' => 'Numeric')); | 
            ||
| 394 | }  | 
            ||
| 395 |                 if (isModEnabled('barcode')) { | 
            ||
| 396 |                     $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode' => 'Text')); | 
            ||
| 397 | }  | 
            ||
| 398 |                 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty' => 'Numeric')); | 
            ||
| 399 | $this->export_entities_array[$r] = array(  | 
            ||
| 400 | 'p.rowid' => "virtualproduct", 'p.ref' => "virtualproduct", 'p.label' => "virtualproduct", 'p.description' => "virtualproduct", 'p.url' => "virtualproduct",  | 
            ||
| 401 | $alias_product_perentity . '.accountancy_code_sell' => 'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_intra' => 'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_export' => 'virtualproduct',  | 
            ||
| 402 | $alias_product_perentity . '.accountancy_code_buy' => 'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_intra' => 'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_export' => 'virtualproduct',  | 
            ||
| 403 | 'p.note' => "virtualproduct", 'p.length' => "virtualproduct",  | 
            ||
| 404 | 'p.surface' => "virtualproduct", 'p.volume' => "virtualproduct", 'p.weight' => "virtualproduct", 'p.customcode' => 'virtualproduct',  | 
            ||
| 405 | 'p.price_base_type' => "virtualproduct", 'p.price' => "virtualproduct", 'p.price_ttc' => "virtualproduct", 'p.tva_tx' => "virtualproduct",  | 
            ||
| 406 | 'p.tosell' => "virtualproduct", 'p.tobuy' => "virtualproduct", 'p.datec' => "virtualproduct", 'p.tms' => "virtualproduct"  | 
            ||
| 407 | );  | 
            ||
| 408 |                 if (isModEnabled('stock')) { | 
            ||
| 409 |                     $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock' => 'virtualproduct', 'p.seuil_stock_alerte' => 'virtualproduct', 'p.desiredstock' => 'virtualproduct', 'p.pmp' => 'virtualproduct')); | 
            ||
| 410 | }  | 
            ||
| 411 |                 if (isModEnabled('barcode')) { | 
            ||
| 412 |                     $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode' => 'virtualproduct')); | 
            ||
| 413 | }  | 
            ||
| 414 |                 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty' => "subproduct", 'pa.incdec' => 'subproduct')); | 
            ||
| 415 | $keyforselect = 'product';  | 
            ||
| 416 | $keyforelement = 'product';  | 
            ||
| 417 | $keyforaliasextra = 'extra';  | 
            ||
| 418 | include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php';  | 
            ||
| 419 |                 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid' => "Id", 'p2.ref' => "Ref", 'p2.label' => "Label", 'p2.description' => "Description")); | 
            ||
| 420 |                 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid' => "subproduct", 'p2.ref' => "subproduct", 'p2.label' => "subproduct", 'p2.description' => "subproduct")); | 
            ||
| 421 | $this->export_sql_start[$r] = 'SELECT DISTINCT ';  | 
            ||
| 422 | $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'product as p';  | 
            ||
| 423 |                 if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { | 
            ||
| 424 | $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pac ON pac.fk_product = p.rowid AND pac.entity = " . ((int)$conf->entity);  | 
            ||
| 425 | }  | 
            ||
| 426 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_extrafields as extra ON p.rowid = extra.fk_object,';  | 
            ||
| 427 | $this->export_sql_end[$r] .= ' ' . MAIN_DB_PREFIX . 'product_association as pa, ' . MAIN_DB_PREFIX . 'product as p2';  | 
            ||
| 428 |                 $this->export_sql_end[$r] .= ' WHERE p.entity IN (' . getEntity('product') . ')'; // For product and service profile | 
            ||
| 429 | $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils';  | 
            ||
| 430 | }  | 
            ||
| 431 | }  | 
            ||
| 432 | |||
| 433 | // Imports  | 
            ||
| 434 | //--------  | 
            ||
| 435 | $r = 0;  | 
            ||
| 436 | |||
| 437 | // Import list of services  | 
            ||
| 438 | |||
| 439 | $r++;  | 
            ||
| 440 | $this->import_code[$r] = $this->rights_class . '_' . $r;  | 
            ||
| 441 | $this->import_label[$r] = "Products"; // Translation key  | 
            ||
| 442 | $this->import_icon[$r] = $this->picto;  | 
            ||
| 443 | $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon  | 
            ||
| 444 |         $this->import_tables_array[$r] = array('p' => MAIN_DB_PREFIX . 'product', 'extra' => MAIN_DB_PREFIX . 'product_extrafields'); | 
            ||
| 445 |         $this->import_tables_creator_array[$r] = array('p' => 'fk_user_author'); // Fields to store import user id | 
            ||
| 446 | $this->import_fields_array[$r] = array(  | 
            ||
| 447 | 'p.ref' => "Ref*",  | 
            ||
| 448 | 'p.label' => "Label*",  | 
            ||
| 449 | 'p.fk_product_type' => "Type*",  | 
            ||
| 450 | 'p.tosell' => "OnSell*",  | 
            ||
| 451 | 'p.tobuy' => "OnBuy*",  | 
            ||
| 452 | 'p.description' => "Description",  | 
            ||
| 453 | 'p.url' => "PublicUrl",  | 
            ||
| 454 | 'p.customcode' => 'CustomCode',  | 
            ||
| 455 | 'p.fk_country' => 'CountryCode',  | 
            ||
| 456 | 'p.accountancy_code_sell' => "ProductAccountancySellCode",  | 
            ||
| 457 | 'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",  | 
            ||
| 458 | 'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode",  | 
            ||
| 459 | 'p.accountancy_code_buy' => "ProductAccountancyBuyCode",  | 
            ||
| 460 | 'p.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode",  | 
            ||
| 461 | 'p.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode",  | 
            ||
| 462 | 'p.note_public' => "NotePublic",  | 
            ||
| 463 | 'p.note' => "NotePrivate",  | 
            ||
| 464 | 'p.weight' => "Weight",  | 
            ||
| 465 | 'p.weight_units' => "WeightUnits",  | 
            ||
| 466 | 'p.length' => "Length",  | 
            ||
| 467 | 'p.length_units' => "LengthUnits",  | 
            ||
| 468 | 'p.width' => "Width",  | 
            ||
| 469 | 'p.width_units' => "WidthUnits",  | 
            ||
| 470 | 'p.height' => "Height",  | 
            ||
| 471 | 'p.height_units' => "HeightUnits",  | 
            ||
| 472 | 'p.surface' => "Surface",  | 
            ||
| 473 | 'p.surface_units' => "SurfaceUnits",  | 
            ||
| 474 | 'p.volume' => "Volume",  | 
            ||
| 475 | 'p.volume_units' => "VolumeUnits",  | 
            ||
| 476 | 'p.duration' => "Duration", //duration of service  | 
            ||
| 477 | 'p.finished' => 'Nature',  | 
            ||
| 478 | 'p.price' => "SellingPriceHT", //without  | 
            ||
| 479 | 'p.price_min' => "MinPrice",  | 
            ||
| 480 | 'p.price_ttc' => "SellingPriceTTC", //with tax  | 
            ||
| 481 | 'p.price_min_ttc' => "SellingMinPriceTTC",  | 
            ||
| 482 | 'p.price_base_type' => "PriceBaseType", //price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card  | 
            ||
| 483 | 'p.tva_tx' => 'VATRate',  | 
            ||
| 484 | 'p.datec' => 'DateCreation',  | 
            ||
| 485 | 'p.cost_price' => "CostPrice",  | 
            ||
| 486 | );  | 
            ||
| 487 | |||
| 488 | $this->import_convertvalue_array[$r] = array(  | 
            ||
| 489 | 'p.weight_units' => array(  | 
            ||
| 490 | 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table  | 
            ||
| 491 | 'classfile' => '/core/class/cunits.class.php',  | 
            ||
| 492 | 'class' => 'CUnits',  | 
            ||
| 493 | 'method' => 'fetch',  | 
            ||
| 494 | 'units' => 'weight',  | 
            ||
| 495 | 'dict' => 'DictionaryMeasuringUnits'  | 
            ||
| 496 | ),  | 
            ||
| 497 | 'p.length_units' => array(  | 
            ||
| 498 | 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table  | 
            ||
| 499 | 'classfile' => '/core/class/cunits.class.php',  | 
            ||
| 500 | 'class' => 'CUnits',  | 
            ||
| 501 | 'method' => 'fetch',  | 
            ||
| 502 | 'units' => 'size',  | 
            ||
| 503 | 'dict' => 'DictionaryMeasuringUnits'  | 
            ||
| 504 | ),  | 
            ||
| 505 | 'p.width_units' => array(  | 
            ||
| 506 | 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table  | 
            ||
| 507 | 'classfile' => '/core/class/cunits.class.php',  | 
            ||
| 508 | 'class' => 'CUnits',  | 
            ||
| 509 | 'method' => 'fetch',  | 
            ||
| 510 | 'units' => 'size',  | 
            ||
| 511 | 'dict' => 'DictionaryMeasuringUnits'  | 
            ||
| 512 | ),  | 
            ||
| 513 | 'p.height_units' => array(  | 
            ||
| 514 | 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table  | 
            ||
| 515 | 'classfile' => '/core/class/cunits.class.php',  | 
            ||
| 516 | 'class' => 'CUnits',  | 
            ||
| 517 | 'method' => 'fetch',  | 
            ||
| 518 | 'units' => 'size',  | 
            ||
| 519 | 'dict' => 'DictionaryMeasuringUnits'  | 
            ||
| 520 | ),  | 
            ||
| 521 | 'p.surface_units' => array(  | 
            ||
| 522 | 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table  | 
            ||
| 523 | 'classfile' => '/core/class/cunits.class.php',  | 
            ||
| 524 | 'class' => 'CUnits',  | 
            ||
| 525 | 'method' => 'fetch',  | 
            ||
| 526 | 'units' => 'surface',  | 
            ||
| 527 | 'dict' => 'DictionaryMeasuringUnits'  | 
            ||
| 528 | ),  | 
            ||
| 529 | 'p.volume_units' => array(  | 
            ||
| 530 | 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table  | 
            ||
| 531 | 'classfile' => '/core/class/cunits.class.php',  | 
            ||
| 532 | 'class' => 'CUnits',  | 
            ||
| 533 | 'method' => 'fetch',  | 
            ||
| 534 | 'units' => 'volume',  | 
            ||
| 535 | 'dict' => 'DictionaryMeasuringUnits'  | 
            ||
| 536 | ),  | 
            ||
| 537 | 'p.fk_country' => array(  | 
            ||
| 538 | 'rule' => 'fetchidfromcodeid',  | 
            ||
| 539 | 'classfile' => '/core/class/ccountry.class.php',  | 
            ||
| 540 | 'class' => 'Ccountry',  | 
            ||
| 541 | 'method' => 'fetch',  | 
            ||
| 542 | 'dict' => 'DictionaryCountry'  | 
            ||
| 543 | )  | 
            ||
| 544 | );  | 
            ||
| 545 | |||
| 546 | $this->import_regex_array[$r] = array(  | 
            ||
| 547 | 'p.ref' => '[^ ]',  | 
            ||
| 548 | 'p.price_base_type' => '\AHT\z|\ATTC\z',  | 
            ||
| 549 | 'p.tosell' => '^[0|1]$',  | 
            ||
| 550 | 'p.tobuy' => '^[0|1]$',  | 
            ||
| 551 | 'p.fk_product_type' => '^[0|1]$',  | 
            ||
| 552 | 'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',  | 
            ||
| 553 | 'p.recuperableonly' => '^[0|1]$',  | 
            ||
| 554 | );  | 
            ||
| 555 | |||
| 556 |         if (isModEnabled('stock')) {//if Stock module enabled | 
            ||
| 557 | $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(  | 
            ||
| 558 | 'p.fk_default_warehouse' => 'DefaultWarehouse',  | 
            ||
| 559 | 'p.tobatch' => 'ManageLotSerial',  | 
            ||
| 560 | 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning  | 
            ||
| 561 | 'p.pmp' => 'PMPValue', //weighted average price  | 
            ||
| 562 | 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature  | 
            ||
| 563 | ));  | 
            ||
| 564 | |||
| 565 | $this->import_regex_array[$r] = array_merge($this->import_regex_array[$r], array(  | 
            ||
| 566 | 'p.tobatch' => '^[0|1|2]$'  | 
            ||
| 567 | ));  | 
            ||
| 568 | |||
| 569 | $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(  | 
            ||
| 570 | 'p.fk_default_warehouse' => array(  | 
            ||
| 571 | 'rule' => 'fetchidfromref',  | 
            ||
| 572 | 'classfile' => '/product/stock/class/entrepot.class.php',  | 
            ||
| 573 | 'class' => 'Entrepot',  | 
            ||
| 574 | 'method' => 'fetch',  | 
            ||
| 575 | 'element' => 'Warehouse'  | 
            ||
| 576 | )  | 
            ||
| 577 | ));  | 
            ||
| 578 | }  | 
            ||
| 579 | |||
| 580 |         if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { | 
            ||
| 581 |             $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price' => 'CostPrice')); | 
            ||
| 582 | }  | 
            ||
| 583 |         if (is_object($mysoc) && $usenpr) { | 
            ||
| 584 |             $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly' => 'NPR')); | 
            ||
| 585 | }  | 
            ||
| 586 |         if (is_object($mysoc) && $mysoc->useLocalTax(1)) { | 
            ||
| 587 |             $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx' => 'LT1', 'p.localtax1_type' => 'LT1Type')); | 
            ||
| 588 | }  | 
            ||
| 589 |         if (is_object($mysoc) && $mysoc->useLocalTax(2)) { | 
            ||
| 590 |             $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx' => 'LT2', 'p.localtax2_type' => 'LT2Type')); | 
            ||
| 591 | }  | 
            ||
| 592 |         if (isModEnabled('barcode')) { | 
            ||
| 593 |             $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode' => 'BarCode')); | 
            ||
| 594 | }  | 
            ||
| 595 |         if (getDolGlobalInt('PRODUCT_USE_UNITS')) { | 
            ||
| 596 | $this->import_fields_array[$r]['p.fk_unit'] = 'Unit';  | 
            ||
| 597 | }  | 
            ||
| 598 | // Add extra fields  | 
            ||
| 599 | $import_extrafield_sample = array();  | 
            ||
| 600 | $sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE type <> 'separate' AND elementtype = 'product' AND entity IN (0," . $conf->entity . ")";  | 
            ||
| 601 | $resql = $this->db->query($sql);  | 
            ||
| 602 |         if ($resql) {    // This can fail when class is used on old database (during migration for example) | 
            ||
| 603 |             while ($obj = $this->db->fetch_object($resql)) { | 
            ||
| 604 | $fieldname = 'extra.' . $obj->name;  | 
            ||
| 605 | $fieldlabel = ucfirst($obj->label);  | 
            ||
| 606 | $this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : '');  | 
            ||
| 607 | $import_extrafield_sample[$fieldname] = $fieldlabel;  | 
            ||
| 608 | }  | 
            ||
| 609 | }  | 
            ||
| 610 | // End add extra fields  | 
            ||
| 611 |         $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) | 
            ||
| 612 | $this->import_regex_array[$r] = array(  | 
            ||
| 613 | 'p.ref' => '[^ ]',  | 
            ||
| 614 | 'p.price_base_type' => 'HT|TTC',  | 
            ||
| 615 | 'p.tosell' => '^[0|1]$',  | 
            ||
| 616 | 'p.tobuy' => '^[0|1]$',  | 
            ||
| 617 | 'p.fk_product_type' => '^[0|1]$',  | 
            ||
| 618 | 'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',  | 
            ||
| 619 | 'p.recuperableonly' => '^[0|1]$',  | 
            ||
| 620 | 'p.finished' => '^[0|1]$'  | 
            ||
| 621 | );  | 
            ||
| 622 | // field order as per structure of table llx_product  | 
            ||
| 623 | $import_sample = array(  | 
            ||
| 624 | 'p.ref' => "ref:PREF123456",  | 
            ||
| 625 | 'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'),  | 
            ||
| 626 | 'p.label' => "Product name in default language",  | 
            ||
| 627 | 'p.description' => "Product description in default language",  | 
            ||
| 628 | 'p.note_public' => "a public note (free text)",  | 
            ||
| 629 | 'p.note' => "a private note (free text)",  | 
            ||
| 630 | 'p.customcode' => 'customs code',  | 
            ||
| 631 | 'p.fk_country' => 'FR',  | 
            ||
| 632 | 'p.price' => "100",  | 
            ||
| 633 | 'p.price_min' => "100",  | 
            ||
| 634 | 'p.price_ttc' => "110",  | 
            ||
| 635 | 'p.price_min_ttc' => "110",  | 
            ||
| 636 | 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)",  | 
            ||
| 637 | 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country'  | 
            ||
| 638 | 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)",  | 
            ||
| 639 | 'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)",  | 
            ||
| 640 | 'p.fk_product_type' => "0 (product) / 1 (service)",  | 
            ||
| 641 | 'p.duration' => "eg. 365d/12m/1y",  | 
            ||
| 642 | 'p.url' => 'link to product (no https)',  | 
            ||
| 643 | 'p.accountancy_code_sell' => "",  | 
            ||
| 644 | 'p.accountancy_code_sell_intra' => "",  | 
            ||
| 645 | 'p.accountancy_code_sell_export' => "",  | 
            ||
| 646 | 'p.accountancy_code_buy' => "",  | 
            ||
| 647 | 'p.accountancy_code_buy_intra' => "",  | 
            ||
| 648 | 'p.accountancy_code_buy_export' => "",  | 
            ||
| 649 | 'p.weight' => "",  | 
            ||
| 650 | 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units',  | 
            ||
| 651 | 'p.length' => "",  | 
            ||
| 652 | 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units',  | 
            ||
| 653 | 'p.width' => "",  | 
            ||
| 654 | 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units',  | 
            ||
| 655 | 'p.height' => "",  | 
            ||
| 656 | 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units',  | 
            ||
| 657 | 'p.surface' => "",  | 
            ||
| 658 | 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units',  | 
            ||
| 659 | 'p.volume' => "",  | 
            ||
| 660 | 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units',  | 
            ||
| 661 | 'p.finished' => '0 (raw material) / 1 (finished goods), matches field "code" in dictionary table "' . MAIN_DB_PREFIX . 'c_product_nature"'  | 
            ||
| 662 | );  | 
            ||
| 663 | //clauses copied from import_fields_array  | 
            ||
| 664 |         if (isModEnabled('stock')) { | 
            ||
| 665 | $import_sample = array_merge($import_sample, array(  | 
            ||
| 666 | 'p.seuil_stock_alerte' => '',  | 
            ||
| 667 | 'p.pmp' => '0',  | 
            ||
| 668 | 'p.desiredstock' => ''  | 
            ||
| 669 | ));  | 
            ||
| 670 | }  | 
            ||
| 671 |         if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { | 
            ||
| 672 |             $import_sample = array_merge($import_sample, array('p.cost_price' => '90')); | 
            ||
| 673 | }  | 
            ||
| 674 |         if (is_object($mysoc) && $usenpr) { | 
            ||
| 675 |             $import_sample = array_merge($import_sample, array('p.recuperableonly' => '0')); | 
            ||
| 676 | }  | 
            ||
| 677 |         if (is_object($mysoc) && $mysoc->useLocalTax(1)) { | 
            ||
| 678 |             $import_sample = array_merge($import_sample, array('p.localtax1_tx' => '', 'p.localtax1_type' => '')); | 
            ||
| 679 | }  | 
            ||
| 680 |         if (is_object($mysoc) && $mysoc->useLocalTax(2)) { | 
            ||
| 681 |             $import_sample = array_merge($import_sample, array('p.localtax2_tx' => '', 'p.localtax2_type' => '')); | 
            ||
| 682 | }  | 
            ||
| 683 |         if (isModEnabled('barcode')) { | 
            ||
| 684 |             $import_sample = array_merge($import_sample, array('p.barcode' => '')); | 
            ||
| 685 | }  | 
            ||
| 686 |         if (getDolGlobalInt('PRODUCT_USE_UNITS')) { | 
            ||
| 687 | $import_sample = array_merge(  | 
            ||
| 688 | $import_sample,  | 
            ||
| 689 | array(  | 
            ||
| 690 | 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "' . MAIN_DB_PREFIX . 'c_units"'  | 
            ||
| 691 | )  | 
            ||
| 692 | );  | 
            ||
| 693 | |||
| 694 |             if (!is_array($this->import_convertvalue_array[$r])) { | 
            ||
| 695 | $this->import_convertvalue_array[$r] = array();  | 
            ||
| 696 | }  | 
            ||
| 697 | $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(  | 
            ||
| 698 | 'p.fk_unit' => array(  | 
            ||
| 699 | 'rule' => 'fetchidfromcodeorlabel',  | 
            ||
| 700 | 'classfile' => '/core/class/cunits.class.php',  | 
            ||
| 701 | 'class' => 'CUnits',  | 
            ||
| 702 | 'method' => 'fetch',  | 
            ||
| 703 | 'dict' => 'DictionaryUnits'  | 
            ||
| 704 | )  | 
            ||
| 705 | ));  | 
            ||
| 706 | }  | 
            ||
| 707 | $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);  | 
            ||
| 708 |         $this->import_updatekeys_array[$r] = array('p.ref' => 'Ref'); | 
            ||
| 709 |         if (isModEnabled('barcode')) { | 
            ||
| 710 |             $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode' => 'BarCode')); //only show/allow barcode as update key if Barcode module enabled | 
            ||
| 711 | }  | 
            ||
| 712 | |||
| 713 |         if (!isModEnabled("product")) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries) | 
            ||
| 714 |             if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { | 
            ||
| 715 | // Import suppliers prices (note: this code is duplicated in module Service)  | 
            ||
| 716 | $r++;  | 
            ||
| 717 | $this->import_code[$r] = $this->rights_class . '_supplierprices';  | 
            ||
| 718 | $this->import_label[$r] = "SuppliersPricesOfProductsOrServices"; // Translation key  | 
            ||
| 719 | $this->import_icon[$r] = $this->picto;  | 
            ||
| 720 | $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon  | 
            ||
| 721 |                 $this->import_tables_array[$r] = array('sp' => MAIN_DB_PREFIX . 'product_fournisseur_price'); | 
            ||
| 722 |                 $this->import_tables_creator_array[$r] = array('sp' => 'fk_user'); | 
            ||
| 723 | $this->import_fields_array[$r] = array(//field order as per structure of table llx_product_fournisseur_price, without optional fields  | 
            ||
| 724 | 'sp.fk_product' => "ProductOrService*",  | 
            ||
| 725 | 'sp.fk_soc' => "Supplier*",  | 
            ||
| 726 | 'sp.ref_fourn' => 'SupplierRef*',  | 
            ||
| 727 | 'sp.quantity' => "QtyMin*",  | 
            ||
| 728 | 'sp.tva_tx' => 'VATRate',  | 
            ||
| 729 | 'sp.default_vat_code' => 'VATCode',  | 
            ||
| 730 | 'sp.delivery_time_days' => 'NbDaysToDelivery',  | 
            ||
| 731 | 'sp.supplier_reputation' => 'SupplierReputation'  | 
            ||
| 732 | );  | 
            ||
| 733 |                 if (is_object($mysoc) && $usenpr) { | 
            ||
| 734 |                     $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly' => 'VATNPR')); | 
            ||
| 735 | }  | 
            ||
| 736 |                 if (is_object($mysoc) && $mysoc->useLocalTax(1)) { | 
            ||
| 737 |                     $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx' => 'LT1', 'sp.localtax1_type' => 'LT1Type')); | 
            ||
| 738 | }  | 
            ||
| 739 |                 if (is_object($mysoc) && $mysoc->useLocalTax(2)) { | 
            ||
| 740 |                     $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx' => 'LT2', 'sp.localtax2_type' => 'LT2Type')); | 
            ||
| 741 | }  | 
            ||
| 742 | $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(  | 
            ||
| 743 | 'sp.price' => "PriceQtyMinHT*",  | 
            ||
| 744 | 'sp.unitprice' => 'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty  | 
            ||
| 745 | 'sp.remise_percent' => 'DiscountQtyMin'  | 
            ||
| 746 | ));  | 
            ||
| 747 | |||
| 748 |                 if (isModEnabled("multicurrency")) { | 
            ||
| 749 | $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(  | 
            ||
| 750 | 'sp.fk_multicurrency' => 'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line  | 
            ||
| 751 | 'sp.multicurrency_code' => 'CurrencyCode',  | 
            ||
| 752 | 'sp.multicurrency_tx' => 'CurrencyRate',  | 
            ||
| 753 | 'sp.multicurrency_unitprice' => 'CurrencyUnitPrice',  | 
            ||
| 754 | 'sp.multicurrency_price' => 'CurrencyPrice',  | 
            ||
| 755 | ));  | 
            ||
| 756 | }  | 
            ||
| 757 | |||
| 758 | $this->import_convertvalue_array[$r] = array(  | 
            ||
| 759 |                     'sp.fk_soc' => array('rule' => 'fetchidfromref', 'classfile' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'), | 
            ||
| 760 |                     'sp.fk_product' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product') | 
            ||
| 761 | );  | 
            ||
| 762 | $this->import_examplevalues_array[$r] = array(  | 
            ||
| 763 | 'sp.fk_product' => "ref:PRODUCT_REF or id:123456",  | 
            ||
| 764 | 'sp.fk_soc' => "My Supplier",  | 
            ||
| 765 | 'sp.ref_fourn' => "XYZ-F123456",  | 
            ||
| 766 | 'sp.quantity' => "5",  | 
            ||
| 767 | 'sp.tva_tx' => '10',  | 
            ||
| 768 | 'sp.price' => "50",  | 
            ||
| 769 | 'sp.unitprice' => '50',  | 
            ||
| 770 | 'sp.remise_percent' => '0',  | 
            ||
| 771 | 'sp.default_vat_code' => '',  | 
            ||
| 772 | 'sp.delivery_time_days' => '5',  | 
            ||
| 773 | 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER'  | 
            ||
| 774 | );  | 
            ||
| 775 |                 if (is_object($mysoc) && $usenpr) { | 
            ||
| 776 |                     $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly' => '')); | 
            ||
| 777 | }  | 
            ||
| 778 |                 if (is_object($mysoc) && $mysoc->useLocalTax(1)) { | 
            ||
| 779 |                     $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx' => 'LT1', 'sp.localtax1_type' => 'LT1Type')); | 
            ||
| 780 | }  | 
            ||
| 781 |                 if (is_object($mysoc) && $mysoc->useLocalTax(2)) { | 
            ||
| 782 |                     $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx' => 'LT2', 'sp.localtax2_type' => 'LT2Type')); | 
            ||
| 783 | }  | 
            ||
| 784 | $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(  | 
            ||
| 785 | 'sp.price' => "50.00",  | 
            ||
| 786 | 'sp.unitprice' => '10',  | 
            ||
| 787 | // TODO Make this field not required and calculate it from price and qty  | 
            ||
| 788 | 'sp.remise_percent' => '20'  | 
            ||
| 789 | ));  | 
            ||
| 790 |                 if (isModEnabled("multicurrency")) { | 
            ||
| 791 | $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(  | 
            ||
| 792 | 'sp.fk_multicurrency' => 'eg: 2, rowid for code of multicurrency currency',  | 
            ||
| 793 | 'sp.multicurrency_code' => 'GBP',  | 
            ||
| 794 | 'sp.multicurrency_tx' => '1.12345',  | 
            ||
| 795 | 'sp.multicurrency_unitprice' => '',  | 
            ||
| 796 | // TODO Make this field not required and calculate it from price and qty  | 
            ||
| 797 | 'sp.multicurrency_price' => ''  | 
            ||
| 798 | ));  | 
            ||
| 799 | }  | 
            ||
| 800 |                 if (getDolGlobalString('PRODUCT_USE_SUPPLIER_PACKAGING')) { | 
            ||
| 801 | $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(  | 
            ||
| 802 | 'sp.packaging' => '10',  | 
            ||
| 803 | ));  | 
            ||
| 804 | }  | 
            ||
| 805 | |||
| 806 |                 $this->import_updatekeys_array[$r] = array('sp.fk_product' => 'ProductOrService', 'sp.ref_fourn' => 'SupplierRef', 'sp.fk_soc' => 'Supplier'); | 
            ||
| 807 | }  | 
            ||
| 808 | |||
| 809 |             if (getDolGlobalString('PRODUIT_MULTIPRICES')) { | 
            ||
| 810 | // Import products multiprices  | 
            ||
| 811 | $r++;  | 
            ||
| 812 | $this->import_code[$r] = $this->rights_class . '_multiprice';  | 
            ||
| 813 | $this->import_label[$r] = "ProductsOrServiceMultiPrice"; // Translation key  | 
            ||
| 814 | $this->import_icon[$r] = $this->picto;  | 
            ||
| 815 | $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon  | 
            ||
| 816 |                 $this->import_tables_array[$r] = array('pr' => MAIN_DB_PREFIX . 'product_price'); | 
            ||
| 817 |                 $this->import_tables_creator_array[$r] = array('pr' => 'fk_user_author'); // Fields to store import user id | 
            ||
| 818 |                 $this->import_fields_array[$r] = array('pr.fk_product' => "ProductOrService*", | 
            ||
| 819 | 'pr.price_base_type' => "PriceBase", 'pr.price_level' => "PriceLevel",  | 
            ||
| 820 | 'pr.price' => "PriceLevelUnitPriceHT", 'pr.price_ttc' => "PriceLevelUnitPriceTTC",  | 
            ||
| 821 | 'pr.price_min' => "MinPriceLevelUnitPriceHT", 'pr.price_min_ttc' => "MinPriceLevelUnitPriceTTC",  | 
            ||
| 822 | 'pr.date_price' => 'DateCreation*');  | 
            ||
| 823 |                 if (getDolGlobalString('PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL')) { | 
            ||
| 824 | $this->import_fields_array[$r]['pr.tva_tx'] = 'VATRate';  | 
            ||
| 825 | }  | 
            ||
| 826 |                 if (is_object($mysoc) && $usenpr) { | 
            ||
| 827 |                     $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly' => 'NPR')); | 
            ||
| 828 | }  | 
            ||
| 829 |                 $this->import_regex_array[$r] = array('pr.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'pr.recuperableonly' => '^[0|1]$'); | 
            ||
| 830 | $this->import_convertvalue_array[$r] = array(  | 
            ||
| 831 |                     'pr.fk_product' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product') | 
            ||
| 832 | );  | 
            ||
| 833 |                 $this->import_examplevalues_array[$r] = array('pr.fk_product' => "ref:SERVICE_REF or id:123456", | 
            ||
| 834 | 'pr.price_base_type' => "HT (for excl tax) or TTC (for inc tax)", 'pr.price_level' => "1",  | 
            ||
| 835 | 'pr.price' => "100", 'pr.price_ttc' => "110",  | 
            ||
| 836 | 'pr.price_min' => "100", 'pr.price_min_ttc' => "110",  | 
            ||
| 837 | 'pr.tva_tx' => '20',  | 
            ||
| 838 | 'pr.recuperableonly' => '0',  | 
            ||
| 839 | 'pr.date_price' => '2013-04-10');  | 
            ||
| 840 | }  | 
            ||
| 841 | |||
| 842 |             if (getDolGlobalInt('MAIN_MULTILANGS')) { | 
            ||
| 843 | // Import translations of product names and descriptions  | 
            ||
| 844 | $r++;  | 
            ||
| 845 | $this->import_code[$r] = $this->rights_class . '_languages';  | 
            ||
| 846 | $this->import_label[$r] = "ProductsOrServicesTranslations";  | 
            ||
| 847 | $this->import_icon[$r] = $this->picto;  | 
            ||
| 848 | $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon  | 
            ||
| 849 |                 $this->import_tables_array[$r] = array('l' => MAIN_DB_PREFIX . 'product_lang'); | 
            ||
| 850 | // multiline translation, one line per translation  | 
            ||
| 851 |                 $this->import_fields_array[$r] = array('l.fk_product' => 'ProductOrService*', 'l.lang' => 'Language*', 'l.label' => 'TranslatedLabel', 'l.description' => 'TranslatedDescription'); | 
            ||
| 852 | //$this->import_fields_array[$r]['l.note']='TranslatedNote';  | 
            ||
| 853 | $this->import_convertvalue_array[$r] = array(  | 
            ||
| 854 |                     'l.fk_product' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product') | 
            ||
| 855 | );  | 
            ||
| 856 |                 $this->import_examplevalues_array[$r] = array('l.fk_product' => 'ref:SERVICE_REF or id:123456', 'l.lang' => 'en_US', 'l.label' => 'Label in en_US', 'l.description' => 'Desc in en_US'); | 
            ||
| 857 |                 $this->import_updatekeys_array[$r] = array('l.fk_product' => 'ProductOrService', 'l.lang' => 'Language'); | 
            ||
| 858 | }  | 
            ||
| 880 | 
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..