NEW Show badge with nbr of shipment on shimpen tab of order

NEW Add button cancel on shipment creation
This commit is contained in:
Laurent Destailleur 2017-11-02 12:38:36 +01:00
parent cd8acf8f12
commit cfacfab6cf
7 changed files with 109 additions and 200 deletions

View File

@ -1906,6 +1906,40 @@ class Commande extends CommonOrder
return $nb; return $nb;
} }
/**
* Count numbe rof shipments for this order
*
* @return int <0 if KO, Nb of shipment found if OK
*/
function getNbOfShipments()
{
$nb = 0;
$sql = 'SELECT COUNT(DISTINCT ed.fk_expedition) as nb';
$sql.= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,';
$sql.= ' '.MAIN_DB_PREFIX.'commandedet as cd';
$sql.= ' WHERE';
$sql.= ' ed.fk_origin_line = cd.rowid';
$sql.= ' AND cd.fk_commande =' .$this->id;
//print $sql;
dol_syslog(get_class($this)."::getNbOfShipments", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
if ($obj) $nb = $obj->nb;
$this->db->free($resql);
return $nb;
}
else
{
$this->error=$this->db->lasterror();
return -1;
}
}
/** /**
* Load array this->expeditions of lines of shipments with nb of products sent for each order line * Load array this->expeditions of lines of shipments with nb of products sent for each order line
* Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order * Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order
@ -1932,18 +1966,18 @@ class Commande extends CommonOrder
//print $sql; //print $sql;
dol_syslog(get_class($this)."::loadExpeditions", LOG_DEBUG); dol_syslog(get_class($this)."::loadExpeditions", LOG_DEBUG);
$result = $this->db->query($sql); $resql = $this->db->query($sql);
if ($result) if ($resql)
{ {
$num = $this->db->num_rows($result); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($resql);
$this->expeditions[$obj->rowid] = $obj->qty; $this->expeditions[$obj->rowid] = $obj->qty;
$i++; $i++;
} }
$this->db->free(); $this->db->free($resql);
return $num; return $num;
} }
else else
@ -1951,7 +1985,6 @@ class Commande extends CommonOrder
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
return -1; return -1;
} }
} }
/** /**
@ -2002,18 +2035,18 @@ class Commande extends CommonOrder
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
$sql.= " WHERE ps.fk_product IN (".join(',',$array_of_product).")"; $sql.= " WHERE ps.fk_product IN (".join(',',$array_of_product).")";
$sql.= ' GROUP BY fk_product '; $sql.= ' GROUP BY fk_product ';
$result = $this->db->query($sql); $resql = $this->db->query($sql);
if ($result) if ($resql)
{ {
$num = $this->db->num_rows($result); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($resql);
$this->stocks[$obj->fk_product] = $obj->total; $this->stocks[$obj->fk_product] = $obj->total;
$i++; $i++;
} }
$this->db->free(); $this->db->free($resql);
} }
} }
return 0; return 0;

View File

@ -61,10 +61,13 @@ function commande_prepare_head(Commande $object)
if (($conf->expedition_bon->enabled && $user->rights->expedition->lire) if (($conf->expedition_bon->enabled && $user->rights->expedition->lire)
|| ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire))
{ {
$nbShipments=$object->getNbOfShipments(); $nbReceiption=0;
$head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id;
if ($conf->expedition_bon->enabled) $text=$langs->trans("Shipments"); if ($conf->expedition_bon->enabled) $text=$langs->trans("Shipments");
if ($nbShipments > 0) $text.= ' <span class="badge">'.$nbShipments.'</span>';
if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/'; if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/';
if ($conf->livraison_bon->enabled) $text.=$langs->trans("Receivings"); if ($conf->livraison_bon->enabled) $text.=$langs->trans("Receivings");
if ($nbReceiption > 0) $text.= ' <span class="badge">'.$nbReceiption.'</span>';
$head[$h][1] = $text; $head[$h][1] = $text;
$head[$h][2] = 'shipping'; $head[$h][2] = 'shipping';
$h++; $h++;

View File

@ -607,13 +607,13 @@ if (empty($reshook))
$object->fetch($id); $object->fetch($id);
$lines = $object->lines; $lines = $object->lines;
$line = new ExpeditionLigne($db); $line = new ExpeditionLigne($db);
$num_prod = count($lines); $num_prod = count($lines);
for ($i = 0 ; $i < $num_prod ; $i++) for ($i = 0 ; $i < $num_prod ; $i++)
{ {
if ($lines[$i]->id == $line_id) if ($lines[$i]->id == $line_id)
{ {
if (count($lines[$i]->details_entrepot) > 1) if (count($lines[$i]->details_entrepot) > 1)
{ {
// delete multi warehouse lines // delete multi warehouse lines
foreach ($lines[$i]->details_entrepot as $details_entrepot) { foreach ($lines[$i]->details_entrepot as $details_entrepot) {
@ -624,7 +624,7 @@ if (empty($reshook))
} }
} }
} }
else else
{ {
// delete single warehouse line // delete single warehouse line
$line->id = $line_id; $line->id = $line_id;
@ -636,12 +636,12 @@ if (empty($reshook))
} }
unset($_POST["lineid"]); unset($_POST["lineid"]);
} }
if(! $error) { if(! $error) {
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
exit(); exit();
} }
else else
{ {
setEventMessages($line->error, $line->errors, 'errors'); setEventMessages($line->error, $line->errors, 'errors');
} }
@ -657,12 +657,12 @@ if (empty($reshook))
$qty=0; $qty=0;
$entrepot_id = 0; $entrepot_id = 0;
$batch_id = 0; $batch_id = 0;
$lines = $object->lines; $lines = $object->lines;
$num_prod = count($lines); $num_prod = count($lines);
for ($i = 0 ; $i < $num_prod ; $i++) for ($i = 0 ; $i < $num_prod ; $i++)
{ {
if ($lines[$i]->id == $line_id) if ($lines[$i]->id == $line_id)
{ {
// line to update // line to update
$line = new ExpeditionLigne($db); $line = new ExpeditionLigne($db);
@ -680,7 +680,7 @@ if (empty($reshook))
if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0)
{ {
// line with lot // line with lot
foreach ($lines[$i]->detail_batch as $detail_batch) foreach ($lines[$i]->detail_batch as $detail_batch)
{ {
$lotStock = new Productbatch($db); $lotStock = new Productbatch($db);
$batch="batchl".$detail_batch->fk_expeditiondet."_".$detail_batch->fk_origin_stock; $batch="batchl".$detail_batch->fk_expeditiondet."_".$detail_batch->fk_origin_stock;
@ -689,13 +689,17 @@ if (empty($reshook))
$batch_qty = GETPOST($qty, 'int'); $batch_qty = GETPOST($qty, 'int');
if (! empty($batch_id) && ($batch_id != $detail_batch->fk_origin_stock || $batch_qty != $detail_batch->dluo_qty)) if (! empty($batch_id) && ($batch_id != $detail_batch->fk_origin_stock || $batch_qty != $detail_batch->dluo_qty))
{ {
if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0) if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0) // $line is ExpeditionLine
{ {
if ($lines[$i]->entrepot_id != 0) if ($lines[$i]->entrepot_id != 0)
{ {
// allow update line entrepot_id if not multi warehouse shipping // allow update line entrepot_id if not multi warehouse shipping
$line->entrepot_id = $lotStock->warehouseid; $line->entrepot_id = $lotStock->warehouseid;
} }
// detail_batch can be an object with keys, or an array of ExpeditionLineBatch
if (empty($line->detail_batch)) $line->detail_batch=new stdClass();
$line->detail_batch->fk_origin_stock = $batch_id; $line->detail_batch->fk_origin_stock = $batch_id;
$line->detail_batch->batch = $lotStock->batch; $line->detail_batch->batch = $lotStock->batch;
$line->detail_batch->id = $detail_batch->id; $line->detail_batch->id = $detail_batch->id;
@ -706,7 +710,7 @@ if (empty($reshook))
$error++; $error++;
} }
} }
else else
{ {
setEventMessages($lotStock->error, $lotStock->errors, 'errors'); setEventMessages($lotStock->error, $lotStock->errors, 'errors');
$error++; $error++;
@ -716,7 +720,7 @@ if (empty($reshook))
unset($_POST[$qty]); unset($_POST[$qty]);
} }
} }
else else
{ {
// line without lot // line without lot
if ($lines[$i]->entrepot_id > 0) if ($lines[$i]->entrepot_id > 0)
@ -782,7 +786,7 @@ if (empty($reshook))
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
} }
else else
{ {
header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition
exit(); exit();
@ -1526,7 +1530,13 @@ if ($action == 'create')
print "</table>"; print "</table>";
print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></div>'; print '<br>';
print '<div class="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Create").'">';
print ' &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>'; print '</form>';
@ -1977,7 +1987,7 @@ else if ($id || $ref)
} }
print '</td>'; print '</td>';
} }
else else
{ {
if ($object->statut <= 1) if ($object->statut <= 1)
{ {
@ -1991,7 +2001,7 @@ else if ($id || $ref)
{ {
print '<td align="left">'.$langs->trans("WarehouseSource").'</td>'; print '<td align="left">'.$langs->trans("WarehouseSource").'</td>';
} }
if (! empty($conf->productbatch->enabled)) if (! empty($conf->productbatch->enabled))
{ {
print '<td align="left">'.$langs->trans("Batch").'</td>'; print '<td align="left">'.$langs->trans("Batch").'</td>';
@ -2166,7 +2176,7 @@ else if ($id || $ref)
if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0)
{ {
$line = new ExpeditionLigne($db); $line = new ExpeditionLigne($db);
foreach ($lines[$i]->detail_batch as $detail_batch) foreach ($lines[$i]->detail_batch as $detail_batch)
{ {
print '<tr>'; print '<tr>';
// Qty to ship or shipped // Qty to ship or shipped
@ -2320,7 +2330,7 @@ else if ($id || $ref)
{ {
print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked);
} }
else else
{ {
print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked);
} }
@ -2480,136 +2490,6 @@ else if ($id || $ref)
$trackid = 'shi'.$object->id; $trackid = 'shi'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
/*
if ($action == 'presend')
{
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file=$fileparams['fullname'];
// Define output language
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
$newlang = $_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
$newlang = $object->thirdparty->default_lang;
if (!empty($newlang))
{
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($newlang);
$outputlangs->load('sendings');
}
// Build document if it not exists
if (! $file || ! is_readable($file))
{
$result = $object->generateDocument(GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0)
{
dol_print_error($db,$object->error,$object->errors);
exit;
}
$fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file=$fileparams['fullname'];
}
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print '<div class="clearboth"></div>';
print '<br>';
print load_fiche_titre($langs->trans('SendShippingByEMail'));
dol_fiche_head('');
// Cree l'objet formulaire mail
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang);
$formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
if($formmail->fromtype === 'user'){
$formmail->fromid = $user->id;
}
$formmail->trackid='shi'.$object->id;
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
{
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'shi'.$object->id);
}
$formmail->withfrom=1;
$liste=array();
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value;
$formmail->withto=GETPOST("sendto")?GETPOST("sendto"):$liste;
$formmail->withtocc=$liste;
$formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
$formmail->withtopic=$outputlangs->trans('SendShippingRef','__SHIPPINGREF__');
$formmail->withfile=2;
$formmail->withbody=1;
$formmail->withdeliveryreceipt=1;
$formmail->withcancel=1;
// Tableau des substitutions
$formmail->setSubstitFromObject($object, $outputlangs);
$formmail->substit['__SHIPPINGREF__']=$object->ref;
$formmail->substit['__SHIPPINGTRACKNUM__']=$object->tracking_number;
$formmail->substit['__SHIPPINGTRACKNUMURL__']=$object->tracking_url;
//Find the good contact adress
if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled)) {
$objectsrc=new Commande($db);
$objectsrc->fetch($object->$typeobject->id);
}
if ($typeobject == 'propal' && $object->$typeobject->id && ! empty($conf->propal->enabled)) {
$objectsrc=new Propal($db);
$objectsrc->fetch($object->$typeobject->id);
}
$custcontact='';
$contactarr=array();
if (is_object($objectsrc)) // For the case the shipment was created without orders
{
$contactarr=$objectsrc->liste_contact(-1,'external');
}
if (is_array($contactarr) && count($contactarr)>0) {
foreach($contactarr as $contact) {
if ($contact['libelle']==$langs->trans('TypeContact_commande_external_CUSTOMER')) {
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
$contactstatic=new Contact($db);
$contactstatic->fetch($contact['id']);
$custcontact=$contactstatic->getFullName($langs,1);
}
}
if (!empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__']=$custcontact;
}
}
// Tableau des parametres complementaires
$formmail->param['action']='send';
$formmail->param['models']='shipping_send';
$formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['shippingid']=$object->id;
$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
// Init list of files
if (GETPOST("mode")=='init')
{
$formmail->clear_attached_files();
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
}
// Show form
print $formmail->get_form();
dol_fiche_end();
}*/
} }

View File

@ -2220,7 +2220,7 @@ class ExpeditionLigne extends CommonObjectLine
*/ */
public $fk_expedition; public $fk_expedition;
var $db; var $db;
// From llx_expeditiondet // From llx_expeditiondet
var $qty; var $qty;
@ -2232,7 +2232,7 @@ class ExpeditionLigne extends CommonObjectLine
* @var int * @var int
*/ */
public $entrepot_id; public $entrepot_id;
// From llx_commandedet or llx_propaldet // From llx_commandedet or llx_propaldet
var $qty_asked; var $qty_asked;
@ -2249,7 +2249,7 @@ class ExpeditionLigne extends CommonObjectLine
var $total_localtax1; // Total Local tax 1 var $total_localtax1; // Total Local tax 1
var $total_localtax2; // Total Local tax 2 var $total_localtax2; // Total Local tax 2
// Deprecated // Deprecated
/** /**
@ -2395,7 +2395,7 @@ class ExpeditionLigne extends CommonObjectLine
/** /**
* Delete shipment line. * Delete shipment line.
* *
* @param User $user User that modify * @param User $user User that modify
* @param int $notrigger 0=launch triggers after, 1=disable triggers * @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
@ -2407,7 +2407,7 @@ class ExpeditionLigne extends CommonObjectLine
$error=0; $error=0;
$this->db->begin(); $this->db->begin();
// delete batch expedition line // delete batch expedition line
if ($conf->productbatch->enabled) if ($conf->productbatch->enabled)
{ {
@ -2420,7 +2420,7 @@ class ExpeditionLigne extends CommonObjectLine
$error++; $error++;
} }
} }
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet";
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
@ -2436,7 +2436,7 @@ class ExpeditionLigne extends CommonObjectLine
$error++; $error++;
} }
} }
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('LINESHIPPING_DELETE',$user); $result=$this->call_trigger('LINESHIPPING_DELETE',$user);
@ -2458,7 +2458,7 @@ class ExpeditionLigne extends CommonObjectLine
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
else else
{ {
foreach($this->errors as $errmsg) foreach($this->errors as $errmsg)
{ {
@ -2469,10 +2469,10 @@ class ExpeditionLigne extends CommonObjectLine
return -1*$error; return -1*$error;
} }
} }
/** /**
* Update a line in database * Update a line in database
* *
* @param User $user User that modify * @param User $user User that modify
* @param int $notrigger 1 = disable triggers * @param int $notrigger 1 = disable triggers
* @return int < 0 if KO, > 0 if OK * @return int < 0 if KO, > 0 if OK
@ -2480,13 +2480,11 @@ class ExpeditionLigne extends CommonObjectLine
function update($user = null, $notrigger = 0) function update($user = null, $notrigger = 0)
{ {
global $conf; global $conf;
$error=0; $error=0;
dol_syslog(get_class($this)."::update id=$this->id, entrepot_id=$this->entrepot_id, product_id=$this->fk_product, qty=$this->qty"); dol_syslog(get_class($this)."::update id=$this->id, entrepot_id=$this->entrepot_id, product_id=$this->fk_product, qty=$this->qty");
$this->db->begin(); $this->db->begin();
// Clean parameters // Clean parameters
@ -2496,9 +2494,9 @@ class ExpeditionLigne extends CommonObjectLine
$batch = null; $batch = null;
$batch_id = null; $batch_id = null;
$expedition_batch_id = null; $expedition_batch_id = null;
if (is_array($this->detail_batch)) if (is_array($this->detail_batch)) // array of ExpeditionLineBatch
{ {
if (count($this->detail_batch) > 1) if (count($this->detail_batch) > 1)
{ {
dol_syslog(get_class($this).'::update only possible for one batch', LOG_ERR); dol_syslog(get_class($this).'::update only possible for one batch', LOG_ERR);
$this->errors[]='ErrorBadParameters'; $this->errors[]='ErrorBadParameters';
@ -2545,8 +2543,8 @@ class ExpeditionLigne extends CommonObjectLine
if (! empty($batch) && $conf->productbatch->enabled) if (! empty($batch) && $conf->productbatch->enabled)
{ {
dol_syslog(get_class($this)."::update expedition batch id=$expedition_batch_id, batch_id=$batch_id, batch=$batch"); dol_syslog(get_class($this)."::update expedition batch id=$expedition_batch_id, batch_id=$batch_id, batch=$batch");
if (empty($batch_id) || empty($expedition_batch_id) || empty($this->fk_product)) { if (empty($batch_id) || empty($expedition_batch_id) || empty($this->fk_product)) {
dol_syslog(get_class($this).'::update missing fk_origin_stock (batch_id) and/or fk_product', LOG_ERR); dol_syslog(get_class($this).'::update missing fk_origin_stock (batch_id) and/or fk_product', LOG_ERR);
$this->errors[]='ErrorMandatoryParametersNotProvided'; $this->errors[]='ErrorMandatoryParametersNotProvided';
@ -2560,24 +2558,24 @@ class ExpeditionLigne extends CommonObjectLine
$this->errors[]=$this->db->lasterror()." - ExpeditionLineBatch::fetchAll"; $this->errors[]=$this->db->lasterror()." - ExpeditionLineBatch::fetchAll";
$error++; $error++;
} }
else else
{ {
// caculate new total line qty // caculate new total line qty
foreach ($lotArray as $lot) foreach ($lotArray as $lot)
{ {
if ($expedition_batch_id != $lot->id) if ($expedition_batch_id != $lot->id)
{ {
$remainingQty += $lot->dluo_qty; $remainingQty += $lot->dluo_qty;
} }
} }
$qty += $remainingQty; $qty += $remainingQty;
//fetch lot details //fetch lot details
// fetch from product_lot // fetch from product_lot
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
$lot = new Productlot($this->db); $lot = new Productlot($this->db);
if ($lot->fetch(0,$this->fk_product,$batch) < 0) if ($lot->fetch(0,$this->fk_product,$batch) < 0)
{ {
$this->errors[] = $lot->errors; $this->errors[] = $lot->errors;
$error++; $error++;
@ -2588,15 +2586,15 @@ class ExpeditionLigne extends CommonObjectLine
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet_batch"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet_batch";
$sql.= " WHERE fk_expeditiondet = ".$this->id; $sql.= " WHERE fk_expeditiondet = ".$this->id;
$sql.= " AND rowid = ".$expedition_batch_id; $sql.= " AND rowid = ".$expedition_batch_id;
if (!$this->db->query($sql)) if (!$this->db->query($sql))
{ {
$this->errors[]=$this->db->lasterror()." - sql=$sql"; $this->errors[]=$this->db->lasterror()." - sql=$sql";
$error++; $error++;
} }
else if ($qty > 0) else if ($qty > 0)
{ {
if (isset($lot->id)) if (isset($lot->id))
{ {
$shipmentLot = new ExpeditionLineBatch($this->db); $shipmentLot = new ExpeditionLineBatch($this->db);
$shipmentLot->batch = $lot->batch; $shipmentLot->batch = $lot->batch;
@ -2605,7 +2603,7 @@ class ExpeditionLigne extends CommonObjectLine
$shipmentLot->entrepot_id = $this->detail_batch->entrepot_id; $shipmentLot->entrepot_id = $this->detail_batch->entrepot_id;
$shipmentLot->dluo_qty = $this->detail_batch->dluo_qty; $shipmentLot->dluo_qty = $this->detail_batch->dluo_qty;
$shipmentLot->fk_origin_stock = $batch_id; $shipmentLot->fk_origin_stock = $batch_id;
if ($shipmentLot->create($this->id) < 0) if ($shipmentLot->create($this->id) < 0)
{ {
$this->errors[]=$shipmentLot->errors; $this->errors[]=$shipmentLot->errors;
$error++; $error++;
@ -2622,8 +2620,8 @@ class ExpeditionLigne extends CommonObjectLine
$sql.= " fk_entrepot = ".$this->entrepot_id; $sql.= " fk_entrepot = ".$this->entrepot_id;
$sql.= " , qty = ".$qty; $sql.= " , qty = ".$qty;
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
if (!$this->db->query($sql)) if (!$this->db->query($sql))
{ {
$this->errors[]=$this->db->lasterror()." - sql=$sql"; $this->errors[]=$this->db->lasterror()." - sql=$sql";
$error++; $error++;
@ -2641,7 +2639,7 @@ class ExpeditionLigne extends CommonObjectLine
} }
} }
} }
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('LINESHIPPING_UPDATE',$user); $result=$this->call_trigger('LINESHIPPING_UPDATE',$user);
@ -2656,7 +2654,7 @@ class ExpeditionLigne extends CommonObjectLine
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
else else
{ {
foreach($this->errors as $errmsg) foreach($this->errors as $errmsg)
{ {

View File

@ -39,13 +39,7 @@ if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/st
if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$langs->load('orders'); $langs->loadLangs(array('orders',"companies","bills",'propal','deliveries','stocks',"productbatch",'incoterm'));
$langs->load("companies");
$langs->load("bills");
$langs->load('propal');
$langs->load('deliveries');
$langs->load('stocks');
$langs->load("productbatch");
$id=GETPOST('id','int'); // id of order $id=GETPOST('id','int'); // id of order
$ref= GETPOST('ref','alpha'); $ref= GETPOST('ref','alpha');
@ -528,7 +522,7 @@ if ($id > 0 || ! empty($ref))
print '<table width="100%" class="nobordernopadding"><tr><td>'; print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel'); print $langs->trans('IncotermLabel');
print '<td><td align="right">'; print '<td><td align="right">';
if ($user->rights->commande->creer) print '<a href="'.DOL_URL_ROOT.'/commande/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>'; if ($user->rights->commande->creer) print '<a href="'.$_SERVER['PHP_SELF'].'/expedition/shipment.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;'; else print '&nbsp;';
print '</td></tr></table>'; print '</td></tr></table>';
print '</td>'; print '</td>';

View File

@ -447,7 +447,7 @@ input:-webkit-autofill {
::-moz-placeholder { color:#bbb; } /* firefox 19+ */ ::-moz-placeholder { color:#bbb; } /* firefox 19+ */
:-ms-input-placeholder { color:#ccc; } /* ie */ :-ms-input-placeholder { color:#ccc; } /* ie */
input:-moz-placeholder { color:#ccc; } input:-moz-placeholder { color:#ccc; }
input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight] { margin-right: 6px; } input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], select[name=incoterm_id] { margin-right: 6px; }
input[name=surface] { margin-right: 4px; } input[name=surface] { margin-right: 4px; }
fieldset { border: 1px solid #AAAAAA !important; } fieldset { border: 1px solid #AAAAAA !important; }
.legendforfieldsetstep { padding-bottom: 10px; } .legendforfieldsetstep { padding-bottom: 10px; }

View File

@ -457,7 +457,8 @@ input:-webkit-autofill {
::-moz-placeholder { color:#bbb; } /* firefox 19+ */ ::-moz-placeholder { color:#bbb; } /* firefox 19+ */
:-ms-input-placeholder { color:#ccc; } /* ie */ :-ms-input-placeholder { color:#ccc; } /* ie */
input:-moz-placeholder { color:#ccc; } input:-moz-placeholder { color:#ccc; }
input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], select[name=incoterm_id] { margin-right: 6px; }
input[name=surface] { margin-right: 4px; }
fieldset { border: 1px solid #AAAAAA !important; } fieldset { border: 1px solid #AAAAAA !important; }
.legendforfieldsetstep { padding-bottom: 10px; } .legendforfieldsetstep { padding-bottom: 10px; }