NEW Show badge with nbr of shipment on shimpen tab of order
NEW Add button cancel on shipment creation
This commit is contained in:
parent
cd8acf8f12
commit
cfacfab6cf
@ -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;
|
||||||
|
|||||||
@ -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++;
|
||||||
|
|||||||
@ -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;
|
||||||
@ -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 ' ';
|
||||||
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
@ -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();
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2485,8 +2485,6 @@ class ExpeditionLigne extends CommonObjectLine
|
|||||||
|
|
||||||
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,7 +2494,7 @@ 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)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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 ' ';
|
else print ' ';
|
||||||
print '</td></tr></table>';
|
print '</td></tr></table>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
@ -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; }
|
||||||
|
|||||||
@ -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; }
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user