diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 15a7385f891..c2ed2ca6705 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -145,6 +145,35 @@ if (empty($reshook)) $action = ''; } } + + // Add line + if ($action == 'updateline' && $user->rights->bom->write) + { + $langs->load('errors'); + $error = 0; + + // Set if we used free entry or predefined product + $qty=GETPOST('qty', 'int'); + $efficiency=GETPOST('efficiency', 'int'); + + if ($qty == '') { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); + $error++; + } + + $bomline = new BOMLine($db); + $bomline->fetch($lineid); + $bomline->qty = $qty; + $bomline->efficiency = $efficiency; + + $result = $bomline->update($user); + if ($result <= 0) + { + setEventMessages($bomline->error, $bomline->errors, 'errors'); + $action = ''; + } + } + } diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index e7083e767a2..731136fb7f4 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -203,6 +203,8 @@ class BOM extends CommonObject */ public function create(User $user, $notrigger = false) { + if ($this->efficiency < 0 || $this->efficiency > 1) $this->efficiency = 1; + return $this->createCommon($user, $notrigger); } @@ -411,6 +413,8 @@ class BOM extends CommonObject */ public function update(User $user, $notrigger = false) { + if ($this->efficiency < 0 || $this->efficiency > 1) $this->efficiency = 1; + return $this->updateCommon($user, $notrigger); } @@ -1100,6 +1104,8 @@ class BOMLine extends CommonObject */ public function create(User $user, $notrigger = false) { + if ($this->efficiency < 0 || $this->efficiency > 1) $this->efficiency = 1; + return $this->createCommon($user, $notrigger); } @@ -1201,6 +1207,8 @@ class BOMLine extends CommonObject */ public function update(User $user, $notrigger = false) { + if ($this->efficiency < 0 || $this->efficiency > 1) $this->efficiency = 1; + return $this->updateCommon($user, $notrigger); } @@ -1230,8 +1238,6 @@ class BOMLine extends CommonObject public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $db, $conf, $langs, $hookmanager; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 0101024df40..e266c142480 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -26,10 +26,7 @@ * $object (invoice, order, ...) * $conf * $langs - * $dateSelector * $forceall (0 by default, 1 for supplier invoices/orders) - * $senderissupplier (0 by default, 1 or 2 for supplier invoices/orders) - * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) */ // Protection to avoid direct call of template @@ -39,20 +36,13 @@ if (empty($object) || ! is_object($object)) { } -if (! isset($dateSelector)) global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine) -global $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax; +global $forceall, $forcetoshowtitlelines; -if (! isset($dateSelector)) $dateSelector=1; // For backward compatibility -elseif (empty($dateSelector)) $dateSelector=0; if (empty($forceall)) $forceall=0; -if (empty($senderissupplier)) $senderissupplier=0; -if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; // Define colspan for the button 'Add' $colspan = 3; // Columns: total ht + col edit + col delete -if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan++;//Add column for Total (currency) if required -if (in_array($object->element, array('propal','commande','order','facture','facturerec','invoice','supplier_proposal','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button //print $object->element; // Lines for extrafield @@ -135,11 +125,6 @@ if ($nolinesbefore) { print $form->selectUnits($line->fk_unit, "units"); print ''; } - $remise_percent = $buyer->remise_percent; - if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') - { - $remise_percent = $seller->remise_supplier_percent; - } $coldisplay++; ?> diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index 3763b771854..2c099ab89f8 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -39,18 +39,16 @@ if (empty($object) || ! is_object($object)) } -global $forceall, $senderissupplier, $inputalsopricewithtax; -if (empty($dateSelector)) $dateSelector=0; +global $forceall; + if (empty($forceall)) $forceall=0; -if (empty($senderissupplier)) $senderissupplier=0; -if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; // Define colspan for the button 'Add' -$colspan = 3; // Col total ht + col edit + col delete -if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc -if (in_array($object->element, array('propal','supplier_proposal','facture','facturerec','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button -if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan+=2; +$colspan = 3; // Columns: total ht + col edit + col delete + +// Lines for extrafield +$objectline = new BOMLine($this->db); ?> @@ -59,7 +57,9 @@ if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf- $coldisplay=0; ?>