Merge branch '3.8' of git@github.com:Dolibarr/dolibarr.git into 3.8
This commit is contained in:
commit
8b62e562e5
@ -1041,9 +1041,9 @@ class ActionComm extends CommonObject
|
||||
* Use $this->id, $this->type_code, $this->label and $this->type_label
|
||||
*
|
||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
||||
* @param int $maxlength Nombre de caracteres max dans libelle
|
||||
* @param int $maxlength Max number of charaters into label. If negative, use the ref as label.
|
||||
* @param string $classname Force style class on a link
|
||||
* @param string $option ''=Link to action,'birthday'=Link to contact
|
||||
* @param string $option ''=Link to action, 'birthday'=Link to contact
|
||||
* @param int $overwritepicto 1=Overwrite picto
|
||||
* @return string Chaine avec URL
|
||||
*/
|
||||
@ -1075,7 +1075,8 @@ class ActionComm extends CommonObject
|
||||
{
|
||||
$libelle=(empty($this->libelle)?$label:$this->libelle.(($label && $label != $this->libelle)?' '.$label:''));
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle=($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code)?$langs->transnoentities("Action".$this->type_code):$this->type_label;
|
||||
$libelleshort=dol_trunc($libelle,$maxlength);
|
||||
if ($maxlength < 0) $libelleshort=$this->ref;
|
||||
else $libelleshort=dol_trunc($libelle,$maxlength);
|
||||
}
|
||||
|
||||
if ($withpicto)
|
||||
|
||||
@ -3277,12 +3277,12 @@ abstract class CommonObject
|
||||
* Need $this->element & $this->id
|
||||
*
|
||||
* @param int $resource_id Resource id
|
||||
* @param string $resource_element Resource element
|
||||
* @param string $resource_type 'resource'
|
||||
* @param int $busy Busy or not
|
||||
* @param int $mandatory Mandatory or not
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
function add_element_resource($resource_id,$resource_element,$busy=0,$mandatory=0)
|
||||
function add_element_resource($resource_id, $resource_type, $busy=0, $mandatory=0)
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
@ -3295,7 +3295,7 @@ abstract class CommonObject
|
||||
$sql.= ", mandatory";
|
||||
$sql.= ") VALUES (";
|
||||
$sql.= $resource_id;
|
||||
$sql.= ", '".$resource_element."'";
|
||||
$sql.= ", '".$resource_type."'";
|
||||
$sql.= ", '".$this->id."'";
|
||||
$sql.= ", '".$this->element."'";
|
||||
$sql.= ", '".$busy."'";
|
||||
|
||||
@ -179,7 +179,7 @@ class FormActions
|
||||
elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter');
|
||||
else $title=$langs->trans("Actions");
|
||||
|
||||
print_titre($title);
|
||||
print load_fiche_titre($title,'','');
|
||||
|
||||
$total = 0; $var=true;
|
||||
print '<table class="noborder" width="100%">';
|
||||
@ -196,10 +196,7 @@ class FormActions
|
||||
|
||||
foreach($listofactions as $action)
|
||||
{
|
||||
$savlabel=$action->label;
|
||||
$action->label=$action->ref;
|
||||
$ref=$action->getNomUrl(1);
|
||||
$action->label=$savlabel;
|
||||
$ref=$action->getNomUrl(1,-1);
|
||||
$label=$action->getNomUrl(0,38);
|
||||
|
||||
$var=!$var;
|
||||
|
||||
@ -2730,8 +2730,8 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m
|
||||
*
|
||||
* @param string $title Title to show
|
||||
* @return string Title to show
|
||||
* @deprecated Use print_fiche_titre instead
|
||||
* @see print_fiche_titre
|
||||
* @deprecated Use load_fiche_titre instead
|
||||
* @see print_fiche_titre, load_fiche_titre
|
||||
*/
|
||||
function print_titre($title)
|
||||
{
|
||||
|
||||
@ -1791,10 +1791,10 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent)
|
||||
|
||||
/**
|
||||
* Get an array with properties of an element
|
||||
*
|
||||
* @param string $element_type Element type. ex : project_task or object@modulext or object_under@module
|
||||
* @return array (module, classpath, element, subelement, classfile, classname)
|
||||
*/
|
||||
*
|
||||
* @param string $element_type Element type: 'action', 'facture', 'project_task' or 'object@modulext'...
|
||||
* @return array (module, classpath, element, subelement, classfile, classname)
|
||||
*/
|
||||
function getElementProperties($element_type)
|
||||
{
|
||||
// Parse element/subelement (ex: project_task)
|
||||
@ -1887,15 +1887,15 @@ function getElementProperties($element_type)
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch an object with element_type and its id
|
||||
* Fetch an object from its id and element_type
|
||||
* Inclusion classes is automatic
|
||||
*
|
||||
* @param int $element_id Element id
|
||||
* @param string $element_type Element type
|
||||
* @return object || 0 || -1 if error
|
||||
* @param int $element_id Element id
|
||||
* @param string $element_type Element type
|
||||
* @return int|object object || 0 || -1 if error
|
||||
*/
|
||||
function fetchObjectByElement($element_id,$element_type) {
|
||||
|
||||
function fetchObjectByElement($element_id, $element_type)
|
||||
{
|
||||
global $conf;
|
||||
global $db,$conf;
|
||||
|
||||
|
||||
@ -222,7 +222,7 @@ if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file
|
||||
<?php if (! empty($_SESSION['dol_loginmesg']))
|
||||
{
|
||||
?>
|
||||
<div class="center login_main_message" style="max-width: 500px; margin-left: 10px; margin-right: 10px;"><div class="error">
|
||||
<div class="center login_main_message" style="max-width: 520px"><div class="error">
|
||||
<?php echo $_SESSION['dol_loginmesg']; ?>
|
||||
</div></div>
|
||||
<?php
|
||||
|
||||
@ -151,7 +151,7 @@ if (! empty($hookmanager->resArray['options'])) {
|
||||
</form>
|
||||
|
||||
|
||||
<div class="center login_main_home" style="max-width: 680px; margin-left: 10px; margin-right: 10px;">
|
||||
<div class="center login_main_home" style="max-width: 80%">
|
||||
<?php if ($mode == 'dolibarr' || ! $disabled) { ?>
|
||||
<font style="font-size: 12px;">
|
||||
<?php echo $langs->trans('SendNewPasswordDesc'); ?>
|
||||
@ -167,7 +167,7 @@ if (! empty($hookmanager->resArray['options'])) {
|
||||
<br>
|
||||
|
||||
<?php if ($message) { ?>
|
||||
<div class="center login_main_message" style="max-width: 680px; margin-left: 10px; margin-right: 10px;">
|
||||
<div class="center login_main_message" style="max-width: 520px">
|
||||
<?php echo dol_htmloutput_mesg($message,'','',1); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
@ -14,7 +14,7 @@ $out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$out .= '<input type="hidden" name="action" value="add_element_resource">';
|
||||
$out .= '<input type="hidden" name="element" value="'.$element.'">';
|
||||
$out .= '<input type="hidden" name="element_id" value="'.$element_id.'">';
|
||||
$out .= '<input type="hidden" name="resource_type" value="'.$resource_type.'">';
|
||||
$out .= '<input type="hidden" name="resource_type" value="'.(empty($resource_type) ? 'resource' : $resource_type).'">';
|
||||
|
||||
|
||||
// Place
|
||||
@ -37,4 +37,4 @@ $out .= '<br />';
|
||||
|
||||
print $out;
|
||||
|
||||
// FIN DU TPL
|
||||
// END BEGIN TPL RESOURCE_ADD.TPL.PHP
|
||||
|
||||
@ -678,10 +678,10 @@ class InterfaceActionsAuto extends DolibarrTriggers
|
||||
// Add entry in event table
|
||||
$now=dol_now();
|
||||
|
||||
if(isset($_SESSION['listofnames']))
|
||||
if (isset($_SESSION['listofnames']))
|
||||
{
|
||||
$attachs=$_SESSION['listofnames'];
|
||||
if($attachs && strpos($action,'SENTBYMAIL'))
|
||||
if ($attachs && strpos($action,'SENTBYMAIL'))
|
||||
{
|
||||
$object->actionmsg.="\n".$langs->transnoentities("AttachedFiles").': '.$attachs;
|
||||
}
|
||||
@ -719,6 +719,9 @@ class InterfaceActionsAuto extends DolibarrTriggers
|
||||
$actioncomm->elementtype = $object->element;
|
||||
|
||||
$ret=$actioncomm->add($user); // User qui saisit l'action
|
||||
|
||||
unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse vallue of first action.
|
||||
|
||||
if ($ret > 0)
|
||||
{
|
||||
$_SESSION['LAST_ACTION_CREATED'] = $ret;
|
||||
|
||||
@ -76,7 +76,7 @@ $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($co
|
||||
|
||||
$object = new Expedition($db);
|
||||
|
||||
// Load object
|
||||
// Load object. Make an object->fetch
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not includ_once
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
@ -160,6 +160,7 @@ if (empty($reshook))
|
||||
|
||||
$num=count($objectsrc->lines);
|
||||
$totalqty=0;
|
||||
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
{
|
||||
$idl="idl".$i;
|
||||
@ -178,11 +179,12 @@ if (empty($reshook))
|
||||
while (isset($_POST[$batch]))
|
||||
{
|
||||
// save line of detail into sub_qty
|
||||
$sub_qty[$j]['q']=GETPOST($qty,'int');
|
||||
$sub_qty[$j]['id_batch']=GETPOST($batch,'int');
|
||||
|
||||
$sub_qty[$j]['q']=GETPOST($qty,'int'); // the qty we want to move for this stock record
|
||||
$sub_qty[$j]['id_batch']=GETPOST($batch,'int'); // the id into llx_product_batch of stock record to move
|
||||
$subtotalqty+=$sub_qty[$j]['q'];
|
||||
|
||||
|
||||
//var_dump($qty);var_dump($batch);var_dump($sub_qty[$j]['q']);var_dump($sub_qty[$j]['id_batch']);
|
||||
|
||||
$j++;
|
||||
$batch="batchl".$i."_".$j;
|
||||
$qty = "qtyl".$i.'_'.$j;
|
||||
@ -200,6 +202,8 @@ if (empty($reshook))
|
||||
if (GETPOST($qty,'int') > 0) $totalqty+=GETPOST($qty,'int');
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($batch_line[2]);
|
||||
|
||||
if ($totalqty > 0) // There is at least one thing to ship
|
||||
{
|
||||
@ -208,7 +212,8 @@ if (empty($reshook))
|
||||
{
|
||||
$qty = "qtyl".$i;
|
||||
if (! isset($batch_line[$i]))
|
||||
{ // not batch mode
|
||||
{
|
||||
// not batch mode
|
||||
if (GETPOST($qty,'int') > 0 || (GETPOST($qty,'int') == 0 && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS))
|
||||
{
|
||||
$ent = "entl".$i;
|
||||
@ -225,7 +230,8 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // batch mode
|
||||
{
|
||||
// batch mode
|
||||
if ($batch_line[$i]['qty']>0)
|
||||
{
|
||||
$ret=$object->addline_batch($batch_line[$i]);
|
||||
@ -669,9 +675,10 @@ if ($action == 'create')
|
||||
print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyToShip");
|
||||
if (empty($conf->productbatch->enabled)) {
|
||||
print ' <br>(<a href="#" id="autofill">'.$langs->trans("Fill").'</a>';
|
||||
print ' / <a href="#" id="autoreset">'.$langs->trans("Reset").'</a>)';
|
||||
if (empty($conf->productbatch->enabled))
|
||||
{
|
||||
print ' <br>(<a href="#" id="autofill">'.$langs->trans("Fill").'</a>';
|
||||
print ' / <a href="#" id="autoreset">'.$langs->trans("Reset").'</a>)';
|
||||
}
|
||||
print '</td>';
|
||||
if (! empty($conf->stock->enabled))
|
||||
@ -848,31 +855,45 @@ if ($action == 'create')
|
||||
else
|
||||
{
|
||||
print '<td></td><td></td></tr>'; // end line and start a new one for lot/serial
|
||||
|
||||
$staticwarehouse=new Entrepot($db);
|
||||
$staticwarehouse->fetch($warehouse_id);
|
||||
|
||||
$subj=0;
|
||||
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">';
|
||||
foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch)
|
||||
if (count($product->stock_warehouse[$warehouse_id]->detail_batch))
|
||||
{
|
||||
//var_dump($dbatch);
|
||||
$substock=$dbatch->qty +0 ;
|
||||
print '<tr><td colspan="3" ></td><td align="center">';
|
||||
print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="'.min($defaultqty,$substock).'">';
|
||||
print '</td>';
|
||||
|
||||
print '<td align="left">';
|
||||
|
||||
$staticwarehouse=new Entrepot($db);
|
||||
$staticwarehouse->fetch($warehouse_id);
|
||||
print $staticwarehouse->getNomUrl(0).' / ';
|
||||
|
||||
print '<!-- Show details of lot -->';
|
||||
print '<input name="batchl'.$indiceAsked.'_'.$subj.'" type="hidden" value="'.$dbatch->id.'">';
|
||||
print $langs->trans("DetailBatchFormat", $dbatch->batch, dol_print_date($dbatch->eatby,"day"), dol_print_date($dbatch->sellby,"day"), $dbatch->qty);
|
||||
if ($defaultqty<=0) {
|
||||
$defaultqty=0;
|
||||
} else {
|
||||
$defaultqty -=min($defaultqty,$substock);
|
||||
foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch)
|
||||
{
|
||||
//var_dump($dbatch);
|
||||
$substock=$dbatch->qty +0 ; // To get a numeric
|
||||
print '<tr><td colspan="3" ></td><td align="center">';
|
||||
print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="'.($substock > 0 ? min($defaultqty,$substock) : '0').'">';
|
||||
print '</td>';
|
||||
|
||||
print '<td align="left">';
|
||||
|
||||
print $staticwarehouse->getNomUrl(0).' / ';
|
||||
|
||||
print '<!-- Show details of lot -->';
|
||||
print '<input name="batchl'.$indiceAsked.'_'.$subj.'" type="hidden" value="'.$dbatch->id.'">';
|
||||
print $langs->trans("DetailBatchFormat", $dbatch->batch, dol_print_date($dbatch->eatby,"day"), dol_print_date($dbatch->sellby,"day"), $dbatch->qty);
|
||||
if ($defaultqty<=0) {
|
||||
$defaultqty=0;
|
||||
} else {
|
||||
$defaultqty -= min($defaultqty,$substock);
|
||||
}
|
||||
$subj++;
|
||||
}
|
||||
$subj++;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td colspan="3" ></td><td align="center">';
|
||||
print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0" disabled="disabled"> ';
|
||||
print '</td>';
|
||||
|
||||
print '<td align="left">';
|
||||
print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1242,8 +1263,8 @@ else if ($id || $ref)
|
||||
print "</table>\n";
|
||||
|
||||
/*
|
||||
* Lignes produits
|
||||
*/
|
||||
* Lines of products
|
||||
*/
|
||||
print '<br><table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
|
||||
@ -1402,12 +1423,19 @@ else if ($id || $ref)
|
||||
if (isset($lines[$i]->detail_batch))
|
||||
{
|
||||
print '<td>';
|
||||
$detail = '';
|
||||
foreach ($lines[$i]->detail_batch as $dbatch)
|
||||
if ($lines[$i]->product_tobatch)
|
||||
{
|
||||
$detail.= $langs->trans("DetailBatchFormat",$dbatch->batch,dol_print_date($dbatch->eatby,"day"),dol_print_date($dbatch->sellby,"day"),$dbatch->dluo_qty).'<br/>';
|
||||
$detail = '';
|
||||
foreach ($lines[$i]->detail_batch as $dbatch)
|
||||
{
|
||||
$detail.= $langs->trans("DetailBatchFormat",$dbatch->batch,dol_print_date($dbatch->eatby,"day"),dol_print_date($dbatch->sellby,"day"),$dbatch->dluo_qty).'<br/>';
|
||||
}
|
||||
print $form->textwithtooltip($langs->trans("DetailBatchNumber"),$detail);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("NA");
|
||||
}
|
||||
print $form->textwithtooltip($langs->trans("DetailBatchNumber"),$detail);
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td></td>';
|
||||
|
||||
@ -391,7 +391,7 @@ class Expedition extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* Create a expedition line with eat-by date
|
||||
* Create the detail (eat-by date) of the expedition line
|
||||
*
|
||||
* @param object $line_ext full line informations
|
||||
* @return int <0 if KO, >0 if OK
|
||||
@ -626,9 +626,12 @@ class Expedition extends CommonObject
|
||||
|
||||
// Loop on each product line to add a stock movement
|
||||
// TODO possibilite d'expedier a partir d'une propale ou autre origine
|
||||
$sql = "SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot, ed.rowid";
|
||||
$sql = "SELECT cd.fk_product, cd.subprice,";
|
||||
$sql.= " ed.rowid, ed.qty, ed.fk_entrepot,";
|
||||
$sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty, edb.fk_origin_stock";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."expeditiondet as ed";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid";
|
||||
$sql.= " WHERE ed.fk_expedition = ".$this->id;
|
||||
$sql.= " AND cd.rowid = ed.fk_origin_line";
|
||||
|
||||
@ -640,27 +643,38 @@ class Expedition extends CommonObject
|
||||
for ($i = 0; $i < $cpt; $i++)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if($obj->qty <= 0) continue;
|
||||
dol_syslog(get_class($this)."::valid movement index ".$i);
|
||||
if ($obj->qty <= 0) continue;
|
||||
dol_syslog(get_class($this)."::valid movement index ".$i." ed.rowid=".$obj->rowid." edb.rowid=".$obj->edbrowid);
|
||||
|
||||
//var_dump($this->lines[$i]);
|
||||
$mouvS = new MouvementStock($this->db);
|
||||
$mouvS->origin = &$this;
|
||||
// We decrement stock of product (and sub-products)
|
||||
// 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))
|
||||
|
||||
if (empty($obj->edbrowid))
|
||||
{
|
||||
$details=ExpeditionLineBatch::fetchAll($this->db,$obj->rowid);
|
||||
if (! empty($details))
|
||||
// line without batch detail
|
||||
|
||||
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
|
||||
$result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref));
|
||||
if ($result < 0) {
|
||||
$error++; break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// line with batch detail
|
||||
|
||||
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
|
||||
$result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch);
|
||||
if ($result < 0) {
|
||||
$error++; break;
|
||||
}
|
||||
|
||||
// We update content of table llx_product_batch (will be rename into llx_product_stock_batch inantoher version)
|
||||
if (! empty($conf->productbatch->enabled))
|
||||
{
|
||||
foreach ($details as $dbatch)
|
||||
{
|
||||
$result=$mouvS->livraison_batch($dbatch->fk_origin_stock,$dbatch->dluo_qty);
|
||||
if ($result < 0) { $error++; $this->errors[]=$mouvS->$error; break 2; }
|
||||
}
|
||||
$result=$mouvS->livraison_batch($obj->fk_origin_stock, $obj->qty); // ->fk_origin_stock = id into table llx_product_batch (will be rename into llx_product_stock_batch in another version)
|
||||
if ($result < 0) { $error++; $this->errors[]=$mouvS->error; break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -672,7 +686,7 @@ class Expedition extends CommonObject
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! $error && ! $notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
@ -843,6 +857,10 @@ class Expedition extends CommonObject
|
||||
{
|
||||
if ($value['q']>0)
|
||||
{
|
||||
// $value['q']=qty to move
|
||||
// $value['id_batch']=id into llx_product_batch of record to move
|
||||
//var_dump($value);
|
||||
|
||||
$linebatch = new ExpeditionLineBatch($this->db);
|
||||
$ret=$linebatch->fetchFromStock($value['id_batch']); // load serial, sellby, eatby
|
||||
if ($ret<0)
|
||||
@ -857,13 +875,16 @@ class Expedition extends CommonObject
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
//var_dump($linebatch);
|
||||
}
|
||||
}
|
||||
$line->entrepot_id = $linebatch->entrepot_id;
|
||||
$line->origin_line_id = $dbatch['ix_l'];
|
||||
$line->qty = $dbatch['qty'];
|
||||
$line->detail_batch=$tab;
|
||||
|
||||
//var_dump($line);
|
||||
$this->lines[$num] = $line;
|
||||
}
|
||||
}
|
||||
@ -1146,9 +1167,9 @@ class Expedition extends CommonObject
|
||||
$sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked";
|
||||
$sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva";
|
||||
$sql.= ", cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.price, cd.subprice, cd.remise_percent";
|
||||
$sql.= ", ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot";
|
||||
$sql.= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot";
|
||||
$sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type";
|
||||
$sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, ed.rowid as line_id";
|
||||
$sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch";
|
||||
$sql.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."commandedet as cd)";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product";
|
||||
@ -1202,6 +1223,7 @@ class Expedition extends CommonObject
|
||||
$line->product_ref = $obj->product_ref;
|
||||
$line->product_label = $obj->product_label;
|
||||
$line->libelle = $obj->product_label; // TODO deprecated
|
||||
$line->product_tobatch = $obj->product_tobatch;
|
||||
$line->label = $obj->custom_label;
|
||||
$line->description = $obj->description;
|
||||
$line->qty_asked = $obj->qty_asked;
|
||||
|
||||
@ -1612,9 +1612,10 @@ if ($action=='create')
|
||||
print "</form>\n";
|
||||
|
||||
// Show origin lines
|
||||
if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) {
|
||||
if (! empty($origin) && ! empty($originid) && is_object($objectsrc))
|
||||
{
|
||||
$title = $langs->trans('ProductsAndServices');
|
||||
print_titre($title);
|
||||
print load_fiche_titre($title,'','');
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
@ -2395,7 +2396,7 @@ elseif (! empty($object->id))
|
||||
'entity'=>''
|
||||
);
|
||||
|
||||
print_titre($langs->trans('CreateRemoteOrder'));
|
||||
print load_fiche_titre($langs->trans('CreateRemoteOrder'),'');
|
||||
|
||||
//Is everything filled?
|
||||
if (empty($ws_url) || empty($ws_key)) {
|
||||
|
||||
@ -69,6 +69,7 @@ ProductQtyInCustomersOrdersRunning=Product quantity into opened customers orders
|
||||
ProductQtyInSuppliersOrdersRunning=Product quantity into opened suppliers orders
|
||||
ProductQtyInShipmentAlreadySent=Product quantity from opened customer order already sent
|
||||
ProductQtyInSuppliersShipmentAlreadyRecevied=Product quantity from opened supplier order already received
|
||||
NoProductToShipFoundIntoStock=No product to ship found into warehouse <b>%s</b>. Correct sotck or go back to choose another warehouse.
|
||||
|
||||
# Sending methods
|
||||
SendingMethodCATCH=Catch by customer
|
||||
|
||||
@ -135,7 +135,7 @@ class Productbatch extends CommonObject
|
||||
/**
|
||||
* Load object in memory from the database
|
||||
*
|
||||
* @param int $id Id object
|
||||
* @param int $id Id object
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch($id)
|
||||
@ -201,6 +201,12 @@ class Productbatch extends CommonObject
|
||||
// Clean parameters
|
||||
$this->clean_param();
|
||||
|
||||
// TODO Check qty is ok for stock move. Negative may not be allowed.
|
||||
if ($this->qty < 0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.self::$_table_element." SET";
|
||||
$sql.= " fk_product_stock=".(isset($this->fk_product_stock)?$this->fk_product_stock:"null").",";
|
||||
@ -389,11 +395,12 @@ class Productbatch extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean fields (triming)
|
||||
* Clean fields (triming)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function clean_param() {
|
||||
private function clean_param()
|
||||
{
|
||||
if (isset($this->fk_product_stock)) $this->fk_product_stock=(int) trim($this->fk_product_stock);
|
||||
if (isset($this->batch)) $this->batch=trim($this->batch);
|
||||
if (isset($this->qty)) $this->qty=(float) trim($this->qty);
|
||||
@ -403,11 +410,11 @@ class Productbatch extends CommonObject
|
||||
/**
|
||||
* Find first detail record that match eather eat-by or sell-by or batch within given warehouse
|
||||
*
|
||||
* @param int $fk_product_stock id product_stock for objet
|
||||
* @param date $eatby eat-by date for objet
|
||||
* @param date $sellby sell-by date for objet
|
||||
* @param int $fk_product_stock id product_stock for objet
|
||||
* @param date $eatby eat-by date for objet
|
||||
* @param date $sellby sell-by date for objet
|
||||
* @param string $batch_number batch number for objet
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function find($fk_product_stock=0, $eatby='',$sellby='',$batch_number='')
|
||||
{
|
||||
|
||||
@ -229,8 +229,8 @@ class MouvementStock extends CommonObject
|
||||
$num = 0;
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "SELECT rowid, reel, pmp FROM ".MAIN_DB_PREFIX."product_stock";
|
||||
$sql.= " WHERE fk_entrepot = ".$entrepot_id." AND fk_product = ".$fk_product;
|
||||
$sql = "SELECT rowid, reel FROM ".MAIN_DB_PREFIX."product_stock";
|
||||
$sql.= " WHERE fk_entrepot = ".$entrepot_id." AND fk_product = ".$fk_product; // This is a unique key
|
||||
|
||||
dol_syslog(get_class($this)."::_create", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
@ -327,7 +327,7 @@ class MouvementStock extends CommonObject
|
||||
$this->errors[]=$this->db->lasterror();
|
||||
$error = -3;
|
||||
}
|
||||
else if(empty($fk_product_stock))
|
||||
else if (empty($fk_product_stock))
|
||||
{
|
||||
$fk_product_stock = $this->db->last_insert_id(MAIN_DB_PREFIX."product_stock");
|
||||
}
|
||||
@ -452,19 +452,22 @@ class MouvementStock extends CommonObject
|
||||
* @param int $price Price
|
||||
* @param string $label Label of stock movement
|
||||
* @param string $datem Force date of movement
|
||||
* @param date $eatby eat-by date
|
||||
* @param date $sellby sell-by date
|
||||
* @param string $batch batch number
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function livraison($user, $fk_product, $entrepot_id, $qty, $price=0, $label='', $datem='')
|
||||
function livraison($user, $fk_product, $entrepot_id, $qty, $price=0, $label='', $datem='', $eatby='', $sellby='', $batch='')
|
||||
{
|
||||
return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label, '', $datem,'','','',true);
|
||||
return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label, '', $datem, $eatby, $sellby, $batch, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease stock for batch record
|
||||
*
|
||||
* @param int $id_stock_dluo Id product_dluo
|
||||
* @param int $qty Quantity
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param int $qty Quantity
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function livraison_batch($id_stock_dluo, $qty)
|
||||
{
|
||||
@ -543,10 +546,12 @@ class MouvementStock extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Create or update batch record
|
||||
* Create or update batch record (update table llx_product_batch)
|
||||
*
|
||||
* @param variant $dluo Could be either int if id of product_batch or array with at leat fk_product_stock
|
||||
* @param int $qty Quantity of product with batch number
|
||||
* @param array|int $dluo Could be either
|
||||
* - int if id of product_batch
|
||||
* - or complete array('fk_product_stock'=>, 'eatby'=>, 'sellby'=> , 'batchnumber'=>)
|
||||
* @param int $qty Quantity of product with batch number. May be a negative amount.
|
||||
* @return int <0 if KO, else return productbatch id
|
||||
*/
|
||||
function _create_batch($dluo, $qty)
|
||||
@ -555,44 +560,63 @@ class MouvementStock extends CommonObject
|
||||
|
||||
$result=0;
|
||||
|
||||
// Try to find an existing record with batch same batch number or id
|
||||
if (is_numeric($dluo)) {
|
||||
// Try to find an existing record with same batch number or id
|
||||
if (is_numeric($dluo))
|
||||
{
|
||||
$result=$pdluo->fetch($dluo);
|
||||
} else if (is_array($dluo)) {
|
||||
if (isset($dluo['fk_product_stock'])) {
|
||||
if (empty($pdluo->id))
|
||||
{
|
||||
// We didn't find the line. May be it was deleted before by a previous move in same transaction.
|
||||
$this->error = 'Error. You ask a move on a record for a serial that does not exists anymore. May be you take the same serial on samewarehouse several times in same shipment or it was used by another shipment. Remove this shipment and prepare another one.';
|
||||
$this->errors[] = $this->error;
|
||||
$result = -2;
|
||||
}
|
||||
}
|
||||
else if (is_array($dluo))
|
||||
{
|
||||
if (isset($dluo['fk_product_stock']))
|
||||
{
|
||||
$vfk_product_stock=$dluo['fk_product_stock'];
|
||||
$veatby = $dluo['eatby'];
|
||||
$vsellby = $dluo['sellby'];
|
||||
$vbatchnumber = $dluo['batchnumber'];
|
||||
|
||||
$result = $pdluo->find($vfk_product_stock,$veatby,$vsellby,$vbatchnumber);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog(get_class($this)."::_create_batch array param dluo must contain at least key fk_product_stock".$error, LOG_ERR);
|
||||
$result = -1;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog(get_class($this)."::_create_batch error invalid param dluo".$error, LOG_ERR);
|
||||
$result = -1;
|
||||
}
|
||||
|
||||
// Batch record found so we update it
|
||||
if ($result>0)
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($pdluo->id >0)
|
||||
// No error
|
||||
if ($pdluo->id > 0) // product_batch record found
|
||||
{
|
||||
$pdluo->qty +=$qty;
|
||||
if ($pdluo->qty == 0) {
|
||||
//print "Avant ".$pdluo->qty." Apres ".($pdluo->qty + $qty)."<br>";
|
||||
$pdluo->qty += $qty;
|
||||
if ($pdluo->qty == 0)
|
||||
{
|
||||
$result=$pdluo->delete(0,1);
|
||||
} else {
|
||||
$result=$pdluo->update(0,1);
|
||||
}
|
||||
}
|
||||
else
|
||||
else // product_batch record not found
|
||||
{
|
||||
$pdluo->fk_product_stock=$vfk_product_stock;
|
||||
$pdluo->qty = $qty;
|
||||
$pdluo->eatby = $veatby;
|
||||
$pdluo->sellby = $vsellby;
|
||||
$pdluo->batch = $vbatchnumber;
|
||||
|
||||
$result=$pdluo->create(0,1);
|
||||
if ($result < 0)
|
||||
{
|
||||
@ -600,11 +624,9 @@ class MouvementStock extends CommonObject
|
||||
$this->errors=$pdluo->errors;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -44,6 +44,7 @@ $id = GETPOST('id','int');
|
||||
$action = GETPOST('action','alpha');
|
||||
$ref = GETPOST('ref');
|
||||
$description = GETPOST('description');
|
||||
$confirm = GETPOST('confirm');
|
||||
$fk_code_type_resource = GETPOST('fk_code_type_resource','alpha');
|
||||
|
||||
// Protection if external user
|
||||
@ -111,6 +112,29 @@ if (empty($reshook))
|
||||
$action='edit';
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_delete_resource' && $user->rights->resource->delete && $confirm === 'yes')
|
||||
{
|
||||
$res = $object->fetch($id);
|
||||
if($res > 0)
|
||||
{
|
||||
$result = $object->delete($id);
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
setEventMessage($langs->trans('RessourceSuccessfullyDeleted'));
|
||||
Header('Location: '.DOL_URL_ROOT.'/resource/list.php');
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
setEventMessage($object->error,'errors');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($object->error,'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ class Resource extends CommonObject
|
||||
|
||||
|
||||
// Insert request
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."resource(";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."(";
|
||||
|
||||
$sql.= " entity,";
|
||||
$sql.= "ref,";
|
||||
@ -114,7 +114,7 @@ class Resource extends CommonObject
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."place");
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
|
||||
|
||||
if (! $notrigger)
|
||||
{
|
||||
@ -164,7 +164,7 @@ class Resource extends CommonObject
|
||||
$sql.= " t.note_private,";
|
||||
$sql.= " t.tms,";
|
||||
$sql.= " ty.label as type_label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."resource as t";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
|
||||
$sql.= " WHERE t.rowid = ".$this->db->escape($id);
|
||||
|
||||
@ -216,7 +216,7 @@ class Resource extends CommonObject
|
||||
if (isset($this->description)) $this->description=trim($this->description);
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."resource SET";
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
|
||||
$sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").",";
|
||||
$sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").",";
|
||||
$sql.= " fk_code_type_resource=".(isset($this->fk_code_type_resource)?"'".$this->db->escape($this->fk_code_type_resource)."'":"null").",";
|
||||
@ -340,7 +340,7 @@ class Resource extends CommonObject
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."resource";
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql.= " WHERE rowid =".$rowid;
|
||||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
@ -386,7 +386,7 @@ class Resource extends CommonObject
|
||||
$sql.= " t.fk_code_type_resource,";
|
||||
$sql.= " t.tms,";
|
||||
$sql.= " ty.label as type_label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."resource as t";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
|
||||
$sql.= " WHERE t.entity IN (".getEntity('resource',1).")";
|
||||
|
||||
|
||||
@ -34,16 +34,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
$langs->load("resource");
|
||||
$langs->load("other");
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id','int');
|
||||
$action = GETPOST('action','alpha');
|
||||
$mode = GETPOST('mode','alpha');
|
||||
$lineid = GETPOST('lineid','int');
|
||||
$element = GETPOST('element','alpha');
|
||||
$element_id = GETPOST('element_id','int');
|
||||
$resource_id = GETPOST('resource_id','int');
|
||||
$resource_type = GETPOST('resource_type','alpha');
|
||||
|
||||
/*
|
||||
$sortorder = GETPOST('sortorder','alpha');
|
||||
$sortfield = GETPOST('sortfield','alpha');
|
||||
@ -63,25 +53,29 @@ $id = GETPOST('id','int');
|
||||
$action = GETPOST('action','alpha');
|
||||
$mode = GETPOST('mode','alpha');
|
||||
$lineid = GETPOST('lineid','int');
|
||||
$element = GETPOST('element','alpha');
|
||||
$element = GETPOST('element','alpha'); // element_type
|
||||
$element_id = GETPOST('element_id','int');
|
||||
$resource_id = GETPOST('fk_resource','int');
|
||||
$resource_type = GETPOST('resource_type','alpha');
|
||||
$busy = GETPOST('busy','int');
|
||||
$mandatory = GETPOST('mandatory','int');
|
||||
$cancel = GETPOST('cancel','alpha');
|
||||
$confirm = GETPOST('confirm','alpha');
|
||||
$confirm = GETPOST('confirm','alpha');
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if($action == 'add_element_resource' && ! $cancel)
|
||||
if ($action == 'add_element_resource' && ! $cancel)
|
||||
{
|
||||
$objstat = fetchObjectByElement($element_id,$element);
|
||||
$res = $objstat->add_element_resource($resource_id,$resource_type,$busy,$mandatory);
|
||||
if($res > 0)
|
||||
$objstat = fetchObjectByElement($element_id, $element);
|
||||
$res = 0;
|
||||
if ($resource_id > 0)
|
||||
{
|
||||
$res = $objstat->add_element_resource($resource_id, $resource_type, $busy, $mandatory);
|
||||
}
|
||||
if ($res > 0)
|
||||
{
|
||||
setEventMessage($langs->trans('ResourceLinkedWithSuccess'),'mesgs');
|
||||
header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$element_id);
|
||||
@ -89,7 +83,7 @@ if($action == 'add_element_resource' && ! $cancel)
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($langs->trans('ErrorWhenLinkingResource'),'errors');
|
||||
setEventMessage($langs->trans('ErrorWhenLinkingResource') . " " . $objstat->error, 'errors');
|
||||
header("Location: ".$_SERVER['PHP_SELF'].'?mode=add&resource_type='.$resource_type.'&element='.$element.'&element_id='.$element_id);
|
||||
exit;
|
||||
}
|
||||
@ -142,7 +136,7 @@ if ($action == 'confirm_delete_linked_resource' && $user->rights->resource->dele
|
||||
}
|
||||
}
|
||||
|
||||
$parameters=array('resource_id'=>resource_id);
|
||||
$parameters=array('resource_id'=>$resource_id);
|
||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
@ -254,16 +248,13 @@ else
|
||||
|
||||
|
||||
|
||||
foreach ($object->available_resources as $modresources => $resources)
|
||||
foreach ($object->available_resources as $modresources => $resources)
|
||||
{
|
||||
$resources=(array) $resources; // To be sure $resources is an array
|
||||
foreach($resources as $resource_obj)
|
||||
{
|
||||
$element_prop = getElementProperties($resource_obj);
|
||||
|
||||
|
||||
|
||||
|
||||
//print '/'.$modresources.'/class/'.$resource_obj.'.class.php<br />';
|
||||
|
||||
$path = '';
|
||||
|
||||
@ -948,18 +948,13 @@ form#login {
|
||||
-webkit-box-shadow: 3px 2px 20px #CCC;
|
||||
box-shadow: 3px 2px 20px #CCC;*/
|
||||
|
||||
border-radius: 8px;
|
||||
border-radius: 5px;
|
||||
border:solid 1px rgba(80,80,80,.4);
|
||||
|
||||
border-top:solid 1px f8f8f8;
|
||||
/*
|
||||
background-color: #f8f8f8;
|
||||
background-image: -o-linear-gradient(top, rgba(250,250,250,.6) 0%, rgba(192,192,192,.3) 100%);
|
||||
background-image: -moz-linear-gradient(top, rgba(250,250,250,.6) 0%, rgba(192,192,192,.3) 100%);
|
||||
background-image: -webkit-linear-gradient(top, rgba(250,250,250,.6) 0%, rgba(192,192,192,.3) 100%);
|
||||
background-image: -ms-linear-gradient(top, rgba(250,250,250,.6) 0%, rgba(192,192,192,.3) 100%);
|
||||
background-image: linear-gradient(top, rgba(250,250,250,.6) 0%, rgba(192,192,192,.3) 100%);
|
||||
*/
|
||||
}
|
||||
.login_main_message {
|
||||
text-align: center;
|
||||
}
|
||||
div#login_left, div#login_right {
|
||||
display: inline-block;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user