diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 58ce0e6481f..d48abbc0aa1 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -30,14 +30,10 @@ global->MAIN_VIEW_LINE_NUMBER)) { - $coldisplay=2; -} else { - $coldisplay=0; -} - ?> +$coldisplay=-1; // We remove first td +?> > - global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> + global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>global->MAIN_VIEW_LINE_NUMBER))?2:1; ?>
@@ -138,28 +134,29 @@ if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { rights->margins->creer) { if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { - $margin_rate = (isset($_POST["marginRate"])?$_POST["marginRate"]:(($line->pa_ht == 0)?'':price($line->marge_tx))); + $margin_rate = (isset($_POST["np_marginRate"])?$_POST["np_marginRate"]:(($line->pa_ht == 0)?'':price($line->marge_tx))); // if credit note, dont allow to modify margin if ($line->subprice < 0) echo ''.$margin_rate.'%'; else - echo '%'; + echo '%'; $coldisplay++; } elseif (! empty($conf->global->DISPLAY_MARK_RATES)) { - $mark_rate = (isset($_POST["markRate"])?$_POST["markRate"]:price($line->marque_tx)); + $mark_rate = (isset($_POST["np_markRate"])?$_POST["np_markRate"]:price($line->marque_tx)); // if credit note, dont allow to modify margin if ($line->subprice < 0) echo ''.$mark_rate.'%'; else - echo '%'; + echo '%'; $coldisplay++; } } } ?> - + + ">
"> @@ -383,6 +380,17 @@ if (! empty($conf->margin->enabled)) ?> jQuery(document).ready(function() { + /* Add rule to clear margin when we change price_ht or buying_price, so when we change sell or buy price, margin will be recalculated after submitting form */ + jQuery("#price_ht").keyup(function() { + jQuery("input[name='np_marginRate']:first").val(''); + jQuery("input[name='np_markRate']:first").val(''); + }); + jQuery("#buying_price").keyup(function() { + jQuery("input[name='np_marginRate']:first").val(''); + jQuery("input[name='np_markRate']:first").val(''); + }); + + /* Init field buying_price and fournprice */ $.post('/fourn/ajax/getSupplierPrices.php', {'idprod': fk_product?$line->fk_product:0; ?>}, function(data) { if (data && data.length > 0) { var options = ''; @@ -419,6 +427,7 @@ if (! empty($conf->margin->enabled)) } }, 'json'); + /* Add rules to reset price_ht from margin info */ global->DISPLAY_MARGIN_RATES)) { @@ -446,15 +455,16 @@ if (! empty($conf->margin->enabled)) }); - // TODO This works for french numbers only + /* If margin rate field empty, do nothing. */ + /* Force content of price_ht to 0 or if a discount is set recalculate it from margin rate */ function checkEditLine(e, npRate) { var buying_price = $("input[name='buying_price']:first"); var remise = $("input[name='remise_percent']:first"); var rate = $("input[name='"+npRate+"']:first"); - if (rate.val() == '') - return true; + if (rate.val() == '') return true; + if (! $.isNumeric(rate.val().replace(',','.'))) { alert('trans("rateMustBeNumeric"); ?>'); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 095b123b963..7e689d3d535 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1203,15 +1203,19 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs { print ''."\n"; $pathckeditor=DOL_URL_ROOT.'/includes/ckeditor/'; - if (constant('JS_CKEDITOR')) $pathckeditor=JS_CKEDITOR; // To use external ckeditor js lib + $jsckeditor='ckeditor_basic.js'; + if (constant('JS_CKEDITOR')) // To use external ckeditor 4 js lib + { + $pathckeditor=constant('JS_CKEDITOR'); + $jsckeditor='ckeditor.js'; + } print ''."\n"; - //print ''."\n"; - print ''."\n"; + print ''."\n"; } // Global js function diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1aebe0307eb..a84aa8adc5c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -359,7 +359,7 @@ class Product extends CommonObject $sql.= ", '".$this->accountancy_code_buy."'"; $sql.= ", '".$this->accountancy_code_sell."'"; $sql.= ", '".$this->canvas."'"; - $sql.= ", ".((! isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'null' : $this->finished); + $sql.= ", ".((! isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'null' : (int) $this->finished); $sql.= ", ".((empty($this->status_batch) || $this->status_batch < 0)? '0':$this->status_batch); $sql.= ")"; @@ -598,7 +598,7 @@ class Product extends CommonObject $sql.= ", tosell = " . $this->status; $sql.= ", tobuy = " . $this->status_buy; $sql.= ", tobatch = " . ((empty($this->status_batch) || $this->status_batch < 0) ? '0' : $this->status_batch); - $sql.= ", finished = " . ((! isset($this->finished) || $this->finished < 0) ? "null" : $this->finished); + $sql.= ", finished = " . ((! isset($this->finished) || $this->finished < 0) ? "null" : (int) $this->finished); $sql.= ", weight = " . ($this->weight!='' ? "'".$this->weight."'" : 'null'); $sql.= ", weight_units = " . ($this->weight_units!='' ? "'".$this->weight_units."'": 'null'); $sql.= ", length = " . ($this->length!='' ? "'".$this->length."'" : 'null'); @@ -2643,7 +2643,7 @@ class Product extends CommonObject */ function getLibStatut($mode=0, $type=0) { - switch ($type) + switch ($type) { case 0: return $this->LibStatut($this->status,$mode,$type); @@ -2673,7 +2673,7 @@ class Product extends CommonObject if ($type == 2) { - switch ($mode) + switch ($mode) { case 0: return ($status == 0 ? $langs->trans('ProductStatusNotOnBatch') : $langs->trans('ProductStatusOnBatch')); @@ -2682,7 +2682,7 @@ class Product extends CommonObject case 2: return $this->LibStatut($status,3,2).' '.$this->LibStatut($status,1,2); case 3: - if ($status == 0 ) + if ($status == 0 ) { return img_picto($langs->trans('ProductStatusNotOnBatch'),'statut5'); } diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 794a1198c35..b423abe25c4 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -314,7 +314,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->socie // planned workload print ''.$langs->trans("PlannedWorkload").''; - print $form->select_duration('planned_workload',$object->planned_workload,0,'text'); + print $form->select_duration('planned_workload', $planned_workload?$planned_workload : $object->planned_workload,0,'text'); print ''; // Progress