diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index bc5bf9da9e3..b4336936181 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -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) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 69f1c6df145..58597862f8c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -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."'"; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 9322680a682..60fbdc0c467 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -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 ''; @@ -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; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5f45496b950..e0a7ec1b9f2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -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) { diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index de3b112e37f..9c77729ac5a 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -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; diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index e82650eda83..c0af2a25b74 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -222,7 +222,7 @@ if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file -
+ resArray['options'])) { -
'; print ''; print ''; if (! empty($conf->stock->enabled)) @@ -848,31 +855,45 @@ if ($action == 'create') else { print ''; // end line and start a new one for lot/serial + + $staticwarehouse=new Entrepot($db); + $staticwarehouse->fetch($warehouse_id); + $subj=0; print ''; - 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 ''; - - print ''; + + print ''; + + print '
'.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("QtyToShip"); - if (empty($conf->productbatch->enabled)) { - print '
('.$langs->trans("Fill").''; - print ' / '.$langs->trans("Reset").')'; + if (empty($conf->productbatch->enabled)) + { + print '
('.$langs->trans("Fill").''; + print ' / '.$langs->trans("Reset").')'; } print '
'; - print ''; - print ''; - - $staticwarehouse=new Entrepot($db); - $staticwarehouse->fetch($warehouse_id); - print $staticwarehouse->getNomUrl(0).' / '; - - print ''; - print ''; - 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 '
'; + print ''; + print ''; + + print $staticwarehouse->getNomUrl(0).' / '; + + print ''; + print ''; + 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 '
'; + print ' '; + print ''; + print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle); } } @@ -1242,8 +1263,8 @@ else if ($id || $ref) print "
\n"; /* - * Lignes produits - */ + * Lines of products + */ print '
'; print ''; if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) @@ -1402,12 +1423,19 @@ else if ($id || $ref) if (isset($lines[$i]->detail_batch)) { print ''; } else { print ''; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 3699399bdca..5863161a995 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -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; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 9ca609c154c..9b0001e79d6 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1612,9 +1612,10 @@ if ($action=='create') print "\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 '
'; - $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).'
'; + $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).'
'; + } + print $form->textwithtooltip($langs->trans("DetailBatchNumber"),$detail); + } + else + { + print $langs->trans("NA"); } - print $form->textwithtooltip($langs->trans("DetailBatchNumber"),$detail); print '
'; @@ -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)) { diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 4d4aca48cd9..53a4e4dae7a 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -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 %s. Correct sotck or go back to choose another warehouse. # Sending methods SendingMethodCATCH=Catch by customer diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 5495584ea5f..8eac443c244 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -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='') { diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 2e9fcfab68e..52c69b16ec6 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -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)."
"; + $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; } /** diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 93c61edfa19..009ffbfec75 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -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'); + } + } } diff --git a/htdocs/resource/class/resource.class.php b/htdocs/resource/class/resource.class.php index cac917fa85b..3c3f0ee6e49 100644 --- a/htdocs/resource/class/resource.class.php +++ b/htdocs/resource/class/resource.class.php @@ -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).")"; diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 123673654c9..782b117d1f8 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -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
'; $path = ''; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index ca69347cc33..a001677ca55 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -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;