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; ?> - global->MAIN_VIEW_LINE_NUMBER)) { ?> + global->MAIN_VIEW_LINE_NUMBER)) { ?> special_code; ?>"> - fk_product > 0) { ?> - - fk_parent_line > 0) echo img_picto('', 'rightarrow'); - ?> - - product_type==1) echo img_object($langs->trans('ShowService'), 'service'); - else print img_object($langs->trans('ShowProduct'), 'product'); - echo ' '.$line->ref; - ?> - - product_label); - ?> - -

- - - fk_product > 0) { + $tmpproduct = new Product($object->db); + $tmpproduct->fetch($line->fk_product); + print $tmpproduct->getNomUrl(1); + } + if (is_object($hookmanager)) { $fk_parent_line = (GETPOST('fk_parent_line') ? GETPOST('fk_parent_line') : $line->fk_parent_line); @@ -106,220 +93,53 @@ $coldisplay=0; element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines + /*if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines { $coldisplay++; ?> fk_prev_id == null) { - print '' . $form->load_tva('tva_tx', $line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), $seller, $buyer, 0, $line->info_bits, $line->product_type, false, 1) . ''; - } else { - print '%'; - } - - $coldisplay++; - print 'fk_prev_id != null) print ' readonly'; - print '>'; - - if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { - $coldisplay++; - print ''; - } - - if ($inputalsopricewithtax) - { - $coldisplay++; - print 'fk_prev_id != null) print ' readonly'; - print '>'; - } ?> - + info_bits & 2) != 2) { // I comment this because it shows info even when not required // for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated // must also not be output for most entities (proposal, intervention, ...) //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." "; - print 'fk_prev_id != null ) print ' readonly'; - print '>'; - } else { ?> -   - + print ''; + } + ?> global->PRODUCT_USE_UNITS) { $coldisplay++; - print ''; + print ''; print $form->selectUnits($line->fk_unit, "units"); print ''; } + + $coldisplay++; ?> + + - info_bits & 2) != 2) { - print 'fk_prev_id != null ) print ' readonly'; - print '>%'; - } else { ?> -   - - - - - + $coldisplay+=$colspan; + ?> + ">
"> showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var],'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); +if (is_object($objectline)) { + print $objectline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } ?> -service->enabled) && $line->product_type == 1 && $dateSelector) { ?> - - global->MAIN_VIEW_LINE_NUMBER)) { ?> - - - trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> - global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:''); - print $form->selectDate($line->date_start, 'date_start', $hourmin, $hourmin, $line->date_start?0:1, "updateline", 1, 0); - print ' '.$langs->trans('to').' '; - print $form->selectDate($line->date_end, 'date_end', $hourmin, $hourmin, $line->date_end?0:1, "updateline", 1, 0); - print '' - ?> - - - - - -