FIX Can't create a stock transfer from product card

This commit is contained in:
Laurent Destailleur 2016-04-28 11:05:34 +02:00
parent 77fcbd3884
commit 608c93702d

View File

@ -185,7 +185,7 @@ if ($action == "correct_stock" && ! $cancel)
// Transfer stock from a warehouse to another warehouse // Transfer stock from a warehouse to another warehouse
if ($action == "transfert_stock" && ! $cancel) if ($action == "transfert_stock" && ! $cancel)
{ {
if (! (GETPOST("id_entrepot_source",'int') > 0) || ! (GETPOST("id_entrepot_destination",'int') > 0)) if (! (GETPOST("id_entrepot",'int') > 0) || ! (GETPOST("id_entrepot_destination",'int') > 0))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
$error++; $error++;
@ -197,7 +197,7 @@ if ($action == "transfert_stock" && ! $cancel)
$error++; $error++;
$action='transfert'; $action='transfert';
} }
if (GETPOST("id_entrepot_source",'int') == GETPOST("id_entrepot_destination",'int')) if (GETPOST("id_entrepot",'int') == GETPOST("id_entrepot_destination",'int'))
{ {
setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors');
$error++; $error++;
@ -255,7 +255,7 @@ if ($action == "transfert_stock" && ! $cancel)
} }
else else
{ {
$srcwarehouseid=GETPOST('id_entrepot_source','int'); $srcwarehouseid=GETPOST('id_entrepot','int');
$batch=GETPOST('batch_number'); $batch=GETPOST('batch_number');
$eatby=$d_eatby; $eatby=$d_eatby;
$sellby=$d_sellby; $sellby=$d_sellby;
@ -292,7 +292,7 @@ if ($action == "transfert_stock" && ! $cancel)
// Remove stock // Remove stock
$result1=$object->correct_stock( $result1=$object->correct_stock(
$user, $user,
GETPOST("id_entrepot_source"), GETPOST("id_entrepot"),
GETPOST("nbpiece"), GETPOST("nbpiece"),
1, 1,
GETPOST("label"), GETPOST("label"),
@ -391,6 +391,7 @@ if ($id > 0 || $ref)
{ {
$object = new Product($db); $object = new Product($db);
$result = $object->fetch($id,$ref); $result = $object->fetch($id,$ref);
$object->load_stock(); $object->load_stock();
$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
@ -677,7 +678,7 @@ if ((! empty($conf->productbatch->enabled)) && $object->hasbatch())
print '</tr>'; print '</tr>';
} }
$sql = "SELECT e.rowid, e.label, e.lieu, ps.reel, ps.pmp, ps.rowid as product_stock_id"; $sql = "SELECT e.rowid, e.label, e.lieu, ps.reel, ps.rowid as product_stock_id, p.pmp";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
$sql.= " ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= " ".MAIN_DB_PREFIX."product_stock as ps";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product";
@ -703,9 +704,10 @@ if ($resql)
$entrepotstatic->id=$obj->rowid; $entrepotstatic->id=$obj->rowid;
$entrepotstatic->libelle=$obj->label; $entrepotstatic->libelle=$obj->label;
$entrepotstatic->lieu=$obj->lieu; $entrepotstatic->lieu=$obj->lieu;
$stock_real = round($obj->reel, 10);
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td colspan="4">'.$entrepotstatic->getNomUrl(1).'</td>'; print '<td colspan="4">'.$entrepotstatic->getNomUrl(1).'</td>';
print '<td align="right">'.$obj->reel.($obj->reel<0?' '.img_warning():'').'</td>'; print '<td align="right">'.$stock_real.($stock_real < 0 ?' '.img_warning():'').'</td>';
// PMP // PMP
print '<td align="right">'.(price2num($object->pmp)?price2num($object->pmp,'MU'):'').'</td>'; print '<td align="right">'.(price2num($object->pmp)?price2num($object->pmp,'MU'):'').'</td>';
// Value purchase // Value purchase