Fix: When closing shipment, status was not visible until refresh.

This commit is contained in:
Laurent Destailleur 2014-10-18 16:27:15 +02:00
parent 0193b31a37
commit 9c69ab966f
2 changed files with 27 additions and 23 deletions

View File

@ -1042,7 +1042,7 @@ else if ($id || $ref)
}
/*
* Confirmation de l'annulation
*/
*/
if ($action == 'annuler')
{
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('CancelSending'),$langs->trans("ConfirmCancelSending",$object->ref),'confirm_cancel','',0,1);
@ -1434,7 +1434,7 @@ else if ($id || $ref)
$entrepot = new Entrepot($db);
$entrepot->fetch($lines[$i]->entrepot_id);
print $entrepot->getNomUrl(1);
}
}
else if (count($lines[$i]->details_entrepot) > 1)
{
$detail = '';
@ -1539,7 +1539,7 @@ else if ($id || $ref)
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans($label).'</a>';
}
}
if ($user->rights->expedition->supprimer)
{
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';

View File

@ -279,7 +279,7 @@ class Expedition extends CommonObject
{
// Call trigger
$result=$this->call_trigger('SHIPPING_CREATE',$user);
if ($result < 0) { $error++; }
if ($result < 0) { $error++; }
// End call triggers
if (! $error)
@ -599,7 +599,7 @@ class Expedition extends CommonObject
// We use warehouse selected for each line
$result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref));
if ($result < 0) { $error++; break; }
if (! empty($conf->productbatch->enabled)) {
$details=ExpeditionLigneBatch::FetchAll($this->db,$obj->rowid);
foreach ($details as $dbatch) {
@ -657,7 +657,7 @@ class Expedition extends CommonObject
{
// Call trigger
$result=$this->call_trigger('SHIPPING_VALIDATE',$user);
if ($result < 0) { $error++; }
if ($result < 0) { $error++; }
// End call triggers
}
@ -723,25 +723,25 @@ class Expedition extends CommonObject
function addline($entrepot_id, $id, $qty)
{
global $conf, $langs;
$num = count($this->lines);
$line = new ExpeditionLigne($this->db);
$line->entrepot_id = $entrepot_id;
$line->origin_line_id = $id;
$line->qty = $qty;
if($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) {
$orderline = new OrderLine($this->db);
$orderline->fetch($id);
$fk_product = $orderline->fk_product;
if (!empty($orderline->fk_product))
{
$product=new Product($this->db);
$result=$product->fetch($fk_product);
$product_type=$product->type;
if($product_type == 0 && $product->stock_reel < $qty) {
$this->error=$langs->trans('ErrorStockIsNotEnough');
$this->db->rollback();
@ -866,7 +866,7 @@ class Expedition extends CommonObject
{
// Call trigger
$result=$this->call_trigger('SHIPPING_MODIFY',$user);
if ($result < 0) { $error++; }
if ($result < 0) { $error++; }
// End call triggers
}
}
@ -914,7 +914,7 @@ class Expedition extends CommonObject
if ($conf->productbatch->enabled) {
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php';
if ( ExpeditionLigneBatch::deletefromexp($this->db,$this->id)<0)
if ( ExpeditionLigneBatch::deletefromexp($this->db,$this->id)<0)
{$error++;$this->errors[]="Error ".$this->db->lasterror();}
}
// Stock control
@ -980,7 +980,7 @@ class Expedition extends CommonObject
{
// Call trigger
$result=$this->call_trigger('SHIPPING_DELETE',$user);
if ($result < 0) { $error++; }
if ($result < 0) { $error++; }
// End call triggers
if (! $error)
@ -1089,22 +1089,22 @@ class Expedition extends CommonObject
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if ($originline == $obj->fk_origin_line) {
$obj = $this->db->fetch_object($resql);
if ($originline == $obj->fk_origin_line) {
$line->entrepot_id = 0; // entrepod_id in details_entrepot
$line->qty_shipped += $obj->qty_shipped;
$line->qty_shipped += $obj->qty_shipped;
} else {
$line = new ExpeditionLigne($this->db);
$line->entrepot_id = $obj->fk_entrepot;
$line->qty_shipped = $obj->qty_shipped;
}
$detail_entrepot = new stdClass;
$detail_entrepot->entrepot_id = $obj->fk_entrepot;
$detail_entrepot->qty_shipped = $obj->qty_shipped;
$line->details_entrepot[] = $detail_entrepot;
$line->line_id = $obj->line_id;
$line->fk_origin_line = $obj->fk_origin_line;
$line->origin_line_id = $obj->fk_origin_line; // TODO deprecated
@ -1151,7 +1151,7 @@ class Expedition extends CommonObject
// Eat-by date
if (! empty($conf->productbatch->enabled)) {
/* test on conf at begining of file sometimes doesn't include expeditionbatch
* May be conf is not well initialized for dark reason
* May be conf is not well initialized for dark reason
*/
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php';
if ($originline != $obj->fk_origin_line) {
@ -1172,7 +1172,7 @@ class Expedition extends CommonObject
}
$i++;
$originline = $obj->fk_origin_line;
$originline = $obj->fk_origin_line;
}
$this->db->free($resql);
return 1;
@ -1547,10 +1547,14 @@ class Expedition extends CommonObject
global $conf;
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2';
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;';
if ($this->db->query($sql) )
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0';
$resql=$this->db->query($sql);
if ($resql)
{
//TODO: Option to set order billed if 100% of order is shipped
$this->statut=2;
$this->billed=1;
return 1;
}
else