diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 7d1af899db7..4427df88735 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -510,9 +510,15 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $afterversionarray = explode('.', '18.0.9'); $beforeversionarray = explode('.', '19.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_contractdet_rank(); } */ + + // Scripts for 20.0 + $afterversionarray = explode('.', '19.0.9'); + $beforeversionarray = explode('.', '20.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_productlot_path(); + } } @@ -4380,6 +4386,50 @@ function migrate_reload_menu($db, $langs, $conf) return 1; } +/** + * Migrate file from old path to new one for lot path + * + * @return void + */ +function migrate_productlot_path() +{ + global $conf, $db, $langs, $user; + + print ''; + + print ''.$langs->trans('MigrationProductLotPath')."
\n"; + + $sql = "SELECT rowid , entity, batch, fk_product from ".MAIN_DB_PREFIX."product_lot"; + $resql = $db->query($sql); + if ($resql) { + $modulepart="product_batch"; + while ($obj = $db->fetch_object($resql)) { + $entity = (empty($obj->entity) ? 1 : $obj->entity); + if ($entity > 1) { + $dir = DOL_DATA_ROOT.'/'.$entity.'/'.$conf->productbatch->multidir_output[$entity]; + } else { + $dir = $conf->productbatch->multidir_output[$entity]; + } + + $lot = new Productlot($db); + $res = $lot->fetch($obj->rowid, $obj->fk_product, $obj->batch); + + if ($dir && $res > 0) { + $lot->ref = $obj->batch; + $origin = $dir . '/' . get_exdir(0, 0, 0, 1, $lot, $modulepart); + + $lot->fetch($obj->rowid, $obj->fk_product, $obj->batch); + $destin = $dir . '/' . get_exdir(0, 0, 0, 1, $lot, $modulepart); + + if (dol_is_dir($origin) && !dol_is_dir($destin)) { + dol_move_dir($origin, $destin, 0); + } + } + } + } + print ''; +} + /** * Migrate file from old path to new one for users * diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index 21b58f4c4d9..23f9d86e957 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -217,3 +217,4 @@ FunctionTest=Function test NodoUpgradeAfterDB=No action requested by external modules after upgrade of database NodoUpgradeAfterFiles=No action requested by external modules after upgrade of files or directories MigrationContractLineRank=Migrate Contract Line to use Rank (and enable Reorder) +MigrationProductLotPath=Migrate Product Batch files path diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 361b2bb6222..53e07ae1c73 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -60,7 +60,12 @@ $batch = GETPOST('batch', 'alpha'); $productid = GETPOSTINT('productid'); $ref = GETPOST('ref', 'alpha'); // ref is productid_batch + +$modulepart = 'product_batch'; + + // Initialize a technical objects + $object = new Productlot($db); $extrafields = new ExtraFields($db); $hookmanager->initHooks(array('productlotcard', 'globalcard')); // Note that conf->hooks_modules contains array @@ -103,13 +108,8 @@ if ($id || $ref) { $batch = $tmp[1]; } $object->fetch($id, $productid, $batch); - $object->ref = $object->batch; // Old system for document management ( it uses $object->ref) $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart); $filearray = dol_dir_list($upload_dir, "files"); - if (empty($filearray)) { - // If no files linked yet, use new system on lot id. (Batch is not unique and can be same on different product) - $object->fetch($id, $productid, $batch); - } } // Initialize a technical object to manage hooks of modules. Note that conf->hooks_modules contains array array @@ -602,7 +602,7 @@ if ($action != 'presend') { // Documents if ($includedocgeneration) { $objref = dol_sanitizeFileName($object->ref); - $relativepath = $objref.'/'.$objref.'.pdf'; + $relativepath = $object->id.'/'.$objref.'.pdf'; $filedir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product_batch'); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $usercanread; // If you can read, you can build the PDF to read content diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index e67a29f77d7..54813e16de1 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -94,16 +94,10 @@ if ($id || $ref) { $batch = $tmp[1]; } $object->fetch($id, $productid, $batch); - $object->ref = $object->batch; // Old system for document management ( it uses $object->ref) if (isModEnabled('productbatch')) { $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart); $filearray = dol_dir_list($upload_dir, "files"); - if (empty($filearray)) { - // If no files linked yet, use new system on lot id. (Batch is not unique and can be same on different product) - $object->fetch($id, $productid, $batch); - $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart); - } } } diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index 7929a4ab5c7..881c8bd16e5 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -290,7 +290,7 @@ if (getDolGlobalString('TAKEPOS_SHOW_DATE_OF_PRINING')) { trans("TotalVAT").''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n"; - } ?> + } ?> total_localtax1, 'MU') || $mysoc->useLocalTax(1)) { ?> trans("TotalLT1").''.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency)."\n"; - } ?> + } ?> total_localtax2, 'MU') || $mysoc->useLocalTax(2)) { ?> trans("TotalLT2").''.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency)."\n"; - } ?> + } ?> trans("TotalTTC").''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n"; - } ?> + } ?> currency != $_SESSION["takeposcustomercurrency"]) {