/** * Si $level == 0 alors on ajoute tous les sous-totaux restants */ function _addSousTotaux(&$langs, &$object, &$TLastLevelTitleAdded, $level = 0) { $lastIndex = count($TLastLevelTitleAdded) - 1; if ($lastIndex < 0) { $lastIndex = 0; } if ($level <= $TLastLevelTitleAdded[$lastIndex]) { for ($i = $lastIndex; $i >= 0; $i--) { if (is_null($TLastLevelTitleAdded[$i])) { continue; } if ($level > $TLastLevelTitleAdded[$i]) { break; } // Add sous-total TSubtotal::addSubTotalLine($object, $langs->trans('SubTotal'), 100 - $TLastLevelTitleAdded[$i]); $TLastLevelTitleAdded[$i] = null; // Nettoyage du tableau } } }
$default_tva = 0; if (!empty($conf->global->IMPORTPROPAL_FORCE_TVA)) { $default_tva = $conf->global->IMPORTPROPAL_FORCE_TVA; } $TLastLevelTitleAdded = array(); // Tableau pour empiler et dépiller les niveaux de titre pour ensuite ajouter les sous-totaux $TData = $_REQUEST['TData']; $last_line_id = null; $last_line_product = null; foreach ($TData as $k => $row) { if (empty($row['to_import'])) { continue; } elseif (!empty($conf->subtotal->enabled) && $row['type'] == 'title') { _addSousTotaux($langs, $object, $TLastLevelTitleAdded, $row['level']); // Add title ou sub-title TSubtotal::addSubTotalLine($object, $row['label'], 0 + $row['level']); $TLastLevelTitleAdded[] = $row['level']; } else { if (!empty($conf->nomenclature->enabled) && ($row['type'] == 'nomenclature' || $row['type'] == 'workstation')) { //var_dump($last_line_product,$last_line_id);exit; if ($last_line_id > 0) { $nomenclature = new TNomenclature(); $workstation = new TWorkstation(); if ($last_line_product > 0 && !empty($conf->global->CREATE_PRODUCT_FROM_IMPORT)) { $nomenclature->loadByObjectId($PDOdb, $last_line_product, 'product'); $nomenclature->fk_object = $last_line_product; $nomenclature->fk_nomenclature_parent = 0; $nomenclature->is_default = 0; $nomenclature->object_type = 'product'; $nomenclature->save($PDOdb); } else {