fix/feat: ProductLot document folder have to be the rowid (#29859)
* fix/feat: ProductLot docuement folder have to be ID as batch is not unique * fix/feat: ProductLot docuement folder have to be ID as batch is not unique * add translation * fix travis * fix travis * fix CI* * fix CI * fix: travis CI * reset from develop * reset from develop * reset from develop * reset from develop --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
8c9a1c2bfc
commit
ba46e7dfd5
5 changed files with 62 additions and 17 deletions
|
|
@ -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 '<tr><td colspan="4">';
|
||||
|
||||
print '<b>'.$langs->trans('MigrationProductLotPath')."</b><br>\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 '</td></tr>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate file from old path to new one for users
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ if (getDolGlobalString('TAKEPOS_SHOW_DATE_OF_PRINING')) {
|
|||
<tr>
|
||||
<th class="right"><?php if ($gift != 1) {
|
||||
echo $langs->trans("TotalVAT").'</th><td class="right">'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n";
|
||||
} ?></td>
|
||||
} ?></th>
|
||||
</tr>
|
||||
<?php }
|
||||
|
||||
|
|
@ -300,20 +300,20 @@ if (price2num($object->total_localtax1, 'MU') || $mysoc->useLocalTax(1)) { ?>
|
|||
<tr>
|
||||
<th class="right"><?php if ($gift != 1) {
|
||||
echo ''.$langs->trans("TotalLT1").'</th><td class="right">'.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency)."\n";
|
||||
} ?></td>
|
||||
} ?></th>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php if (price2num($object->total_localtax2, 'MU') || $mysoc->useLocalTax(2)) { ?>
|
||||
<tr>
|
||||
<th class="right"><?php if ($gift != 1) {
|
||||
echo ''.$langs->trans("TotalLT2").'</th><td class="right">'.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency)."\n";
|
||||
} ?></td>
|
||||
} ?></th>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<th class="right"><?php if ($gift != 1) {
|
||||
echo ''.$langs->trans("TotalTTC").'</th><td class="right">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n";
|
||||
} ?></td>
|
||||
} ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency"]) && $_SESSION["takeposcustomercurrency"] != "" && $conf->currency != $_SESSION["takeposcustomercurrency"]) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue