mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Start to clean code of templates to input lines
This commit is contained in:
parent
3393b1c5fb
commit
5fa05ee29d
|
|
@ -2718,7 +2718,7 @@ abstract class CommonObject
|
|||
*/
|
||||
function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0)
|
||||
{
|
||||
global $conf,$langs,$user,$hookmanager;
|
||||
global $conf,$langs,$user,$object,$hookmanager;
|
||||
|
||||
print '<tr class="liste_titre nodrag nodrop">';
|
||||
|
||||
|
|
@ -2757,11 +2757,11 @@ abstract class CommonObject
|
|||
// Total HT
|
||||
print '<td align="right" width="50">'.$langs->trans('TotalHTShort').'</td>';
|
||||
|
||||
print '<td width="10"></td>';
|
||||
print '<td></td>'; // No width to allow autodim
|
||||
|
||||
print '<td width="10"></td>';
|
||||
|
||||
print '<td class="nowrap"></td>'; // No width to allow autodim
|
||||
print '<td width="10"></td>';
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
|
|
@ -2816,7 +2816,7 @@ abstract class CommonObject
|
|||
*/
|
||||
function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0)
|
||||
{
|
||||
global $conf,$langs,$user,$hookmanager;
|
||||
global $conf,$langs,$user,$object,$hookmanager;
|
||||
global $form,$bc,$bcdd;
|
||||
|
||||
$element=$this->element;
|
||||
|
|
|
|||
|
|
@ -1,335 +0,0 @@
|
|||
<?php
|
||||
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Need to have following variables defined:
|
||||
* $conf
|
||||
* $langs
|
||||
* $dateSelector
|
||||
* $this (invoice, order, ...)
|
||||
* $line defined
|
||||
*/
|
||||
|
||||
$usemargins=0;
|
||||
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1;
|
||||
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE freeproductline_create.tpl.php -->
|
||||
|
||||
<tr class="liste_titre nodrag nodrop">
|
||||
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
|
||||
<div id="add"></div>
|
||||
<span class="hideonsmartphone"><?php echo $langs->trans('AddNewLine').' - ' ?></span><?php echo $langs->trans("FreeZone"); ?>
|
||||
</td>
|
||||
<td align="right"><?php echo $langs->trans('VAT'); ?></td>
|
||||
<td align="right"><?php echo $langs->trans('PriceUHT'); ?></td>
|
||||
<td align="right"><?php echo $langs->trans('Qty'); ?></td>
|
||||
<td align="right"><?php echo $langs->trans('ReductionShort'); ?></td>
|
||||
<?php
|
||||
$colspan = 4;
|
||||
if (! empty($usemargins))
|
||||
{
|
||||
?>
|
||||
<td align="right">
|
||||
<?php
|
||||
if ($conf->global->MARGIN_TYPE == "1")
|
||||
echo $langs->trans('BuyingPrice');
|
||||
else
|
||||
echo $langs->trans('CostPrice');
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
if ($user->rights->margins->creer)
|
||||
{
|
||||
if(! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
{
|
||||
echo '<td align="right">'.$langs->trans('MarginRate').'</td>';
|
||||
}
|
||||
if(! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
{
|
||||
echo '<td align="right">'.$langs->trans('MarkRate').'</td>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<td colspan="<?php echo $colspan; ?>"> </td>
|
||||
</tr>
|
||||
|
||||
<tr <?php echo $bcnd[$var]; ?>>
|
||||
<?php
|
||||
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
|
||||
$coldisplay=2; }
|
||||
else {
|
||||
$coldisplay=0; }
|
||||
?>
|
||||
|
||||
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
|
||||
<?php
|
||||
|
||||
echo '<span>';
|
||||
echo $form->select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1);
|
||||
echo '</span>';
|
||||
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters=array('fk_parent_line'=>GETPOST('fk_parent_line','int'));
|
||||
$reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action);
|
||||
}
|
||||
|
||||
if ((! empty($conf->product->enabled) && ! empty($conf->service->enabled)) || (empty($conf->product->enabled) && empty($conf->service->enabled))) echo '<br>';
|
||||
|
||||
// Editor wysiwyg
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$nbrows=ROWS_2;
|
||||
$enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
|
||||
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
|
||||
$doleditor=new DolEditor('dp_desc',GETPOST('dp_desc'),'',100,'dolibarr_details','',false,true,$enabled,$nbrows,70);
|
||||
$doleditor->Create();
|
||||
?>
|
||||
</td>
|
||||
|
||||
<td align="right"><?php
|
||||
if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" value="0">0';
|
||||
else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer);
|
||||
?>
|
||||
</td>
|
||||
<td align="right"><input type="text" size="5" name="price_ht" class="flat" value="<?php echo (isset($_POST["price_ht"])?$_POST["price_ht"]:''); ?>"></td>
|
||||
<td align="right"><input type="text" size="2" name="qty" class="flat" value="<?php echo (isset($_POST["qty"])?$_POST["qty"]:1); ?>"></td>
|
||||
<td align="right" class="nowrap"><input type="text" size="1" class="flat" value="<?php echo (isset($_POST["remise_percent"])?$_POST["remise_percent"]:$buyer->remise_client); ?>" name="remise_percent"><span class="hideonsmartphone">%</span></td>
|
||||
<?php
|
||||
$colspan = 4;
|
||||
if (! empty($usemargins))
|
||||
{
|
||||
?>
|
||||
<td align="right">
|
||||
<input type="text" size="5" name="buying_price" class="flat" value="<?php echo (isset($_POST["buying_price"])?$_POST["buying_price"]:''); ?>">
|
||||
</td>
|
||||
<?php
|
||||
$colspan++;
|
||||
$coldisplay++;
|
||||
|
||||
if ($user->rights->margins->creer)
|
||||
{
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
echo '<td align="right" class="nowrap"><input type="text" size="2" name="np_marginRate" value="'.(isset($_POST["np_marginRate"])?$_POST["np_marginRate"]:'').'"><span class="hideonsmartphone">%</span></td>';
|
||||
$colspan++;
|
||||
$coldisplay++;
|
||||
}
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
echo '<td align="right" class="nowrap"><input type="text" size="2" name="np_markRate" value="'.(isset($_POST["np_markRate"])?$_POST["np_markRate"]:'').'"><span class="hideonsmartphone">%</span></td>';
|
||||
$colspan++;
|
||||
$coldisplay++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
$colspan++;
|
||||
$coldisplay++;
|
||||
}
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
$colspan++;
|
||||
$coldisplay++;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<td align="center" valign="middle" colspan="<?php echo $colspan; ?>">
|
||||
<input type="submit" class="button" value="<?php echo $langs->trans('Add'); ?>" name="addline_libre" id="addline_libre">
|
||||
</td>
|
||||
<?php
|
||||
//Line extrafield
|
||||
if (!empty($extrafieldsline)) {
|
||||
if ($this->table_element_line=='commandedet') {
|
||||
$newline = new OrderLine($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='propaldet') {
|
||||
$newline = new PropaleLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='facturedet') {
|
||||
$newline = new FactureLigne($this->db);
|
||||
}
|
||||
if (is_object($newline)) {
|
||||
print $newline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8));
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
if (! empty($conf->service->enabled) && $dateSelector)
|
||||
{
|
||||
if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10;
|
||||
else $colspan = 9;
|
||||
|
||||
if (! empty($usemargins))
|
||||
{
|
||||
$colspan++; // For the buying price
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
||||
}
|
||||
?>
|
||||
|
||||
<tr <?php echo $bcnd[$var]; ?>>
|
||||
<td colspan="<?php echo $colspan; ?>">
|
||||
<?php
|
||||
if (! empty($object->element) && $object->element == 'contrat')
|
||||
{
|
||||
print $langs->trans("DateStartPlanned").' ';
|
||||
$form->select_date('',"date_start",$usehm,$usehm,1,"addline_sl");
|
||||
print ' '.$langs->trans("DateEndPlanned").' ';
|
||||
$form->select_date('',"date_end",$usehm,$usehm,1,"addline_sl");
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
|
||||
echo $form->select_date('','date_start',empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,1,"addproduct");
|
||||
echo ' '.$langs->trans('to').' ';
|
||||
echo $form->select_date('','date_end',empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,1,"addproduct");
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
if (! empty($usemargins) && $user->rights->margins->creer)
|
||||
{
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
<?php
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
|
||||
$('#addline_libre').click(function (e) {
|
||||
return checkFreeLine(e, "np_marginRate");
|
||||
});
|
||||
$("input[name='np_marginRate']:first").blur(function(e) {
|
||||
return checkFreeLine(e, "np_marginRate");
|
||||
});
|
||||
<?php
|
||||
}
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) { ?>
|
||||
$('#addline_libre').click(function (e) {
|
||||
return checkFreeLine(e, "np_markRate");
|
||||
});
|
||||
$("input[name='np_markRate']:first").blur(function(e) {
|
||||
return checkFreeLine(e, "np_markRate");
|
||||
});
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
});
|
||||
|
||||
// TODO This works for french numbers only
|
||||
function checkFreeLine(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 (! $.isNumeric(rate.val().replace(',','.')))
|
||||
{
|
||||
alert('<?php echo dol_escape_js($langs->trans("rateMustBeNumeric")); ?>');
|
||||
e.stopPropagation();
|
||||
setTimeout(function () { rate.focus() }, 50);
|
||||
return false;
|
||||
}
|
||||
if (npRate == "np_markRate" && rate.val() >= 100)
|
||||
{
|
||||
alert('<?php echo dol_escape_js($langs->trans("markRateShouldBeLesserThan100")); ?>');
|
||||
e.stopPropagation();
|
||||
setTimeout(function () { rate.focus() }, 50);
|
||||
return false;
|
||||
}
|
||||
|
||||
var price = 0;
|
||||
remisejs=price2numjs(remise.val());
|
||||
|
||||
if (remisejs != 100)
|
||||
{
|
||||
if (remisejs == '') remisejs=0;
|
||||
|
||||
bpjs=price2numjs(buying_price.val());
|
||||
ratejs=price2numjs(rate.val());
|
||||
if (npRate == "np_marginRate")
|
||||
price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
|
||||
else if (npRate == "np_markRate")
|
||||
price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
|
||||
}
|
||||
$("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Function similar to price2num in PHP */
|
||||
function price2numjs(num)
|
||||
{
|
||||
if (num == '') return '';
|
||||
|
||||
<?php
|
||||
$dec=','; $thousand=' ';
|
||||
if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");
|
||||
if ($langs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->transnoentitiesnoconv("SeparatorThousand");
|
||||
if ($thousand == 'None') $thousand='';
|
||||
print "var dec='".$dec."'; var thousand='".$thousand."';\n";
|
||||
?>
|
||||
|
||||
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
|
||||
var main_rounding_unit = <?php echo $conf->global->MAIN_MAX_DECIMALS_UNIT; ?>;
|
||||
var main_rounding_tot = <?php echo $conf->global->MAIN_MAX_DECIMALS_TOT; ?>;
|
||||
|
||||
var amount = num.toString();
|
||||
|
||||
// rounding for unit price
|
||||
var rounding = main_rounding_unit;
|
||||
var pos = amount.indexOf(dec);
|
||||
var decpart = '';
|
||||
if (pos >= 0) decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale
|
||||
var nbdec = decpart.length;
|
||||
if (nbdec > rounding) rounding = nbdec;
|
||||
// If rounding higher than max shown
|
||||
if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
|
||||
|
||||
if (thousand != ',' && thousand != '.') amount=amount.replace(',','.');
|
||||
amount=amount.replace(' ',''); // To avoid spaces
|
||||
amount=amount.replace(thousand,''); // Replace of thousand before replace of dec to avoid pb if thousand is .
|
||||
amount=amount.replace(dec,'.');
|
||||
|
||||
return parseFloat(amount).toFixed(rounding);
|
||||
}
|
||||
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<!-- END PHP TEMPLATE freeproductline_create.tpl.php -->
|
||||
|
|
@ -41,9 +41,7 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
|
|||
// Define colspan for 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','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move
|
||||
if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
|
||||
if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
||||
if (in_array($object->element,array('propal','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->
|
||||
|
|
@ -390,8 +388,7 @@ if (! empty($usemargins) && $user->rights->margins->creer)
|
|||
$dec=','; $thousand=' ';
|
||||
if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");
|
||||
if ($langs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->transnoentitiesnoconv("SeparatorThousand");
|
||||
if ($thousand == 'None') $thousand='';
|
||||
print "var dec='".$dec."'; var thousand='".$thousand."';\n";
|
||||
print "var dec='".$dec."'; var thousand='".$thousand."';\n"; // Set var in javascript
|
||||
?>
|
||||
|
||||
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
|
||||
|
|
|
|||
|
|
@ -17,14 +17,31 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
* Need to have following variables defined:
|
||||
* $object (invoice, order, ...)
|
||||
* $conf
|
||||
* $langs
|
||||
* $dateSelector
|
||||
* $this (invoice, order, ...)
|
||||
* $line defined
|
||||
* $forceall (0 by default, 1 for supplier invoices/orders)
|
||||
* $senderissupplier (0 by default, 1 for supplier invoices/orders)
|
||||
* $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
|
||||
*/
|
||||
|
||||
|
||||
$usemargins=0;
|
||||
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1;
|
||||
|
||||
global $dateSelector, $forceall, $senderissupplier, $inputalsopricewithtax;
|
||||
if (empty($dateSelector)) $dateSelector=0;
|
||||
if (empty($forceall)) $forceall=0;
|
||||
if (empty($senderissupplier)) $senderissupplier=0;
|
||||
if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
|
||||
|
||||
|
||||
// Define colspan for 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','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE objectline_edit.tpl.php -->
|
||||
|
|
@ -41,29 +58,7 @@ $coldisplay=-1; // We remove first td
|
|||
<input type="hidden" id="product_id" name="productid" value="<?php echo (! empty($line->fk_product)?$line->fk_product:0); ?>" />
|
||||
<input type="hidden" id="special_code" name="special_code" value="<?php echo $line->special_code; ?>">
|
||||
|
||||
<?php
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL > 1)
|
||||
{
|
||||
if ($line->fk_product > 0)
|
||||
{
|
||||
echo $text . ' - ';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $form->select_type_of_lines($line->product_type, 'type', 1, 1);
|
||||
}
|
||||
?>
|
||||
|
||||
<input id="product_label" name="product_label" size="40" value="<?php echo $label; ?>"<?php echo $placeholder . ((! empty($line->fk_product) && empty($line->label)) ? ' disabled="disabled"' : ''); ?>>
|
||||
<input type="hidden" id="origin_label_cache" name="origin_label_cache" value="<?php echo $line->product_label; ?>" />
|
||||
<span id="update_label_area" class="hideobject"><input type="checkbox" id="update_label_checkbox" name="update_label" value="1" />
|
||||
<?php echo $form->textwithtooltip($langs->trans('UpdateOriginalProductLabel'), $langs->trans('HelpUpdateOriginalProductLabel'),1,0,'','',3); ?>
|
||||
</span>
|
||||
<span id="price_base_type" class="hideobject"></span>
|
||||
|
||||
<br>
|
||||
|
||||
<?php } else if ($line->fk_product > 0) { ?>
|
||||
<?php if ($line->fk_product > 0) { ?>
|
||||
|
||||
<a href="<?php echo DOL_URL_ROOT.'/product/fiche.php?id='.$line->fk_product; ?>">
|
||||
<?php
|
||||
|
|
@ -156,7 +151,7 @@ $coldisplay=-1; // We remove first td
|
|||
} ?>
|
||||
|
||||
<!-- colspan=4 for this td because it replace total_ht+3 td for buttons -->
|
||||
<td align="center" colspan="4" valign="middle"><?php $coldisplay+=4; ?>
|
||||
<td align="center" colspan="<?php echo $colspan; ?>" valign="middle"><?php $coldisplay+=4; ?>
|
||||
<input type="submit" class="button" id="savelinebutton" name="save" value="<?php echo $langs->trans("Save"); ?>"><br>
|
||||
<input type="submit" class="button" id="cancellinebutton" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>">
|
||||
</td>
|
||||
|
|
@ -185,193 +180,6 @@ $coldisplay=-1; // We remove first td
|
|||
|
||||
<script type="text/javascript">
|
||||
|
||||
<?php
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL > 1) // TODO A virer
|
||||
{
|
||||
?>
|
||||
jQuery(document).ready(function() {
|
||||
|
||||
|
||||
if ($('#product_type').val() == 0) {
|
||||
$('#service_duration_area').hide();
|
||||
} else if ($('#product_type').val() == 1) {
|
||||
$('#service_duration_area').show();
|
||||
}
|
||||
|
||||
if ($('#product_label').attr('disabled')) {
|
||||
$('#update_label_area').show();
|
||||
}
|
||||
|
||||
$('#update_label_checkbox').change(function() {
|
||||
if ($(this).attr('checked')) {
|
||||
$('#product_label').removeAttr('disabled').focus();
|
||||
} else {
|
||||
$('#product_label')
|
||||
.attr('disabled','disabled')
|
||||
.val($('#origin_label_cache').val());
|
||||
}
|
||||
});
|
||||
|
||||
$('#select_type').change(function() {
|
||||
var type = $(this).val();
|
||||
if (type >= 0) {
|
||||
if (type == 0) {
|
||||
$('#service_duration_area').hide();
|
||||
$('#date_start').val('').trigger('change');
|
||||
$('#date_end').val('').trigger('change');
|
||||
} else if (type == 1) {
|
||||
$('#service_duration_area').show();
|
||||
}
|
||||
var addline=false;
|
||||
if ($('#price_ht').val().length > 0) {
|
||||
if ($('#product_id').val() == 0) {
|
||||
if (typeof CKEDITOR == 'object' && typeof CKEDITOR.instances != 'undefined' && CKEDITOR.instances['product_desc'] != 'undefined') {
|
||||
var content = CKEDITOR.instances['product_desc'].getData();
|
||||
} else {
|
||||
var content = $('#product_desc').val();
|
||||
}
|
||||
if (content.length > 0) {
|
||||
addline=true;
|
||||
}
|
||||
} else {
|
||||
addline=true;
|
||||
}
|
||||
}
|
||||
if (addline) {
|
||||
$('#savelinebutton').removeAttr('disabled');
|
||||
} else {
|
||||
$('#savelinebutton').attr('disabled','disabled');
|
||||
}
|
||||
} else {
|
||||
$('#savelinebutton').attr('disabled','disabled');
|
||||
$('#service_duration_area').hide();
|
||||
$('#date_start').val('').trigger('change');
|
||||
$('#date_end').val('').trigger('change');
|
||||
}
|
||||
});
|
||||
|
||||
$('#price_ht').focusin(function() {
|
||||
$('#price_base_type').val('HT');
|
||||
});
|
||||
|
||||
$('#price_ht').bind('change keyup input', function() {
|
||||
if ($('#price_base_type').val() == 'HT') {
|
||||
update_price('price_ht', 'price_ttc');
|
||||
}
|
||||
});
|
||||
|
||||
$('#price_ttc').focusin(function() {
|
||||
$('#price_base_type').val('TTC');
|
||||
});
|
||||
|
||||
$('#price_ttc').bind('change keyup input', function() {
|
||||
if ($('#price_base_type').val() == 'TTC') {
|
||||
update_price('price_ttc', 'price_ht');
|
||||
}
|
||||
});
|
||||
|
||||
if ($('#tva_tx').val() == 0) {
|
||||
$('#price_ttc').attr('disabled','disabled');
|
||||
}
|
||||
|
||||
$('#tva_tx').change(function() {
|
||||
if ($(this).val() == 0) {
|
||||
$('#price_ttc').attr('disabled','disabled');
|
||||
$('#price_ttc').val('');
|
||||
} else {
|
||||
$('#price_ttc').removeAttr('disabled');
|
||||
if ($('#price_base_type').val() == 'HT') {
|
||||
update_price('price_ht', 'price_ttc');
|
||||
} else if ($('#price_base_type').val() == 'TTC') {
|
||||
update_price('price_ttc', 'price_ht');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// update_price
|
||||
function update_price(input, output)
|
||||
{
|
||||
$.post('<?php echo DOL_URL_ROOT; ?>/core/ajax/price.php', {
|
||||
'amount': $('#' + input).val(),
|
||||
'output': output,
|
||||
'tva_tx': $('#tva_tx').val()
|
||||
},
|
||||
function(data) {
|
||||
var addline=false;
|
||||
if (typeof data[output] != 'undefined') {
|
||||
// Hide price_ttc if no vat
|
||||
if ($('#tva_tx').val() > 0 || ($('#tva_tx').val() == 0 && output == 'price_ht')) {
|
||||
$('#' + output).val(data[output]);
|
||||
}
|
||||
if ($('#product_id').val() == 0 && $('#select_type').val() >= 0) {
|
||||
if (typeof CKEDITOR == 'object' && typeof CKEDITOR.instances != 'undefined' && CKEDITOR.instances['product_desc'] != 'undefined') {
|
||||
var content = CKEDITOR.instances['product_desc'].getData();
|
||||
} else {
|
||||
var content = $('#product_desc').val();
|
||||
}
|
||||
if (content.length > 0) {
|
||||
addline=true;
|
||||
}
|
||||
} else {
|
||||
addline=true;
|
||||
}
|
||||
} else {
|
||||
$('#' + input).val('');
|
||||
$('#' + output).val('');
|
||||
}
|
||||
if (addline) {
|
||||
$('#savelinebutton').removeAttr('disabled');
|
||||
} else {
|
||||
$('#savelinebutton').attr('disabled','disabled');
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
// Check if decription is not empty for free line
|
||||
<?php if (! empty($conf->fckeditor->enabled) && ! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?>
|
||||
CKEDITOR.on('instanceReady', function() {
|
||||
CKEDITOR.instances['product_desc'].on('key', function() {
|
||||
var addline=false;
|
||||
if ($('#product_id').val() == 0 && $('#select_type').val() >= 0 && $('#price_ht').val().length > 0) {
|
||||
var content = CKEDITOR.instances['product_desc'].getData();
|
||||
if (content.length > 0) {
|
||||
addline=true;
|
||||
}
|
||||
} else if ($('#product_id').val() > 0 && $('#price_ht').val().length > 0) {
|
||||
addline=true;
|
||||
}
|
||||
if (addline) {
|
||||
$('#savelinebutton').removeAttr('disabled');
|
||||
} else {
|
||||
$('#savelinebutton').attr('disabled','disabled');
|
||||
}
|
||||
});
|
||||
});
|
||||
<?php } else { ?>
|
||||
$('#product_desc').keyup(function() {
|
||||
var addline=false;
|
||||
if ($('#product_id').val() == 0 && $('#select_type').val() >= 0 && $('#price_ht').val().length > 0) {
|
||||
var content = $('#product_desc').val();
|
||||
if (content.length > 0) {
|
||||
addline=true;
|
||||
}
|
||||
} else if ($('#product_id').val() > 0 && $('#price_ht').val().length > 0) {
|
||||
addline=true;
|
||||
}
|
||||
if (addline) {
|
||||
$('#savelinebutton').removeAttr('disabled');
|
||||
} else {
|
||||
$('#savelinebutton').attr('disabled','disabled');
|
||||
}
|
||||
});
|
||||
<?php } ?>
|
||||
|
||||
});
|
||||
|
||||
<?php } // End MAIN_LEVEL_FEATURES > 1 ?>
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
if (! empty($conf->margin->enabled))
|
||||
{
|
||||
|
|
@ -499,12 +307,13 @@ if (! empty($conf->margin->enabled))
|
|||
/* Function similar to price2num in PHP */
|
||||
function price2numjs(num)
|
||||
{
|
||||
if (num == '') return '';
|
||||
|
||||
<?php
|
||||
$dec=','; $thousand=' ';
|
||||
if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");
|
||||
if ($langs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->transnoentitiesnoconv("SeparatorThousand");
|
||||
if ($thousand == 'None') $thousand='';
|
||||
print "var dec='".$dec."'; var thousand='".$thousand."';\n";
|
||||
print "var dec='".$dec."'; var thousand='".$thousand."';\n"; // Set var in javascript
|
||||
?>
|
||||
|
||||
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
|
||||
|
|
|
|||
|
|
@ -1,375 +0,0 @@
|
|||
<?php
|
||||
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Need to have following variables defined:
|
||||
* $conf
|
||||
* $langs
|
||||
* $dateSelector
|
||||
* $this (invoice, order, ...)
|
||||
* $line defined
|
||||
*/
|
||||
|
||||
$usemargins=0;
|
||||
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1;
|
||||
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE predefinedproductline_create.tpl.php -->
|
||||
|
||||
<tr class="liste_titre nodrag nodrop">
|
||||
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="4"' : ' colspan="3"'); ?>>
|
||||
<?php
|
||||
echo '<span class="hideonsmartphone">'.$langs->trans("AddNewLine").' - </span>';
|
||||
if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('RecordedProducts');
|
||||
else if (empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans('RecordedServices');
|
||||
else echo $langs->trans('RecordedProductsAndServices');
|
||||
?>
|
||||
</td>
|
||||
<td align="right"><?php echo $langs->trans('Qty'); ?></td>
|
||||
<td align="right"><?php echo $langs->trans('ReductionShort'); ?></td>
|
||||
<?php
|
||||
$colspan = 4;
|
||||
if (! empty($usemargins))
|
||||
{
|
||||
?>
|
||||
<td align="right">
|
||||
<?php
|
||||
if ($conf->global->MARGIN_TYPE == "1")
|
||||
echo $langs->trans('BuyingPrice');
|
||||
else
|
||||
echo $langs->trans('CostPrice');
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
if ($user->rights->margins->creer)
|
||||
{
|
||||
if(! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
{
|
||||
echo '<td align="right">'.$langs->trans('MarginRate').'</td>';
|
||||
}
|
||||
if(! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
{
|
||||
echo '<td align="right">'.$langs->trans('MarkRate').'</td>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<td colspan="<?php echo $colspan; ?>"> </td>
|
||||
</tr>
|
||||
|
||||
<tr <?php echo $bcnd[$var]; ?>>
|
||||
<?php
|
||||
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
|
||||
$coldisplay=4; }
|
||||
else {
|
||||
$coldisplay=3; }
|
||||
?>
|
||||
|
||||
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="4"' : ' colspan="3"'); ?>>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
jQuery('#idprod').change(function() {
|
||||
if (jQuery('#idprod').val() > 0) jQuery('#np_desc').focus();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
echo '<span>';
|
||||
$filtertype='';
|
||||
if (! empty($object->element) && $object->element == 'contrat') $filtertype='1';
|
||||
$form->select_produits('','idprod',$filtertype,$conf->product->limit_size,$buyer->price_level, 1, 2, '', 3, array(),$buyer->id);
|
||||
echo '</span>';
|
||||
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters=array('fk_parent_line'=>GETPOST('fk_parent_line','int'));
|
||||
$reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action);
|
||||
}
|
||||
|
||||
echo '<br>';
|
||||
|
||||
// Editor wysiwyg
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$nbrows=ROWS_2;
|
||||
$enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
|
||||
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
|
||||
$doleditor=new DolEditor('np_desc',GETPOST('np_desc"'),'',100,'dolibarr_details','',false,true,$enabled,$nbrows,70);
|
||||
$doleditor->Create();
|
||||
?>
|
||||
</td>
|
||||
|
||||
<td align="right"><input type="hidden" name="price_ht_predef"><input type="text" size="2" name="qty_predef" class="flat" value="1"></td>
|
||||
<td align="right" class="nowrap"><input type="text" size="1" class="flat" name="remise_percent_predef" value="<?php echo $buyer->remise_percent; ?>"><span class="hideonsmartphone">%</span></td>
|
||||
<?php
|
||||
$colspan = 4;
|
||||
if (! empty($usemargins))
|
||||
{
|
||||
?>
|
||||
<td align="right">
|
||||
<select id="fournprice_predef" name="fournprice_predef" class="flat" style="display: none;"></select>
|
||||
<input type="text" size="5" id="buying_price_predef" name="buying_price_predef" class="flat" value="<?php echo (isset($_POST["buying_price_predef"])?$_POST["buying_price_predef"]:''); ?>">
|
||||
</td>
|
||||
<?php
|
||||
$colspan++;
|
||||
$coldisplay++;
|
||||
|
||||
if ($user->rights->margins->creer)
|
||||
{
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
echo '<td align="right"><input type="text" size="2" name="np_marginRate_predef" value="'.(isset($_POST["np_marginRate_predef"])?$_POST["np_marginRate_predef"]:'').'">%</td>';
|
||||
$colspan++;
|
||||
$coldisplay++;
|
||||
}
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
echo '<td align="right"><input type="text" size="2" name="np_markRate_predef" value="'.(isset($_POST["np_markRate_predef"])?$_POST["np_markRate_predef"]:'').'">%</td>';
|
||||
$colspan++;
|
||||
$coldisplay++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
$colspan++;
|
||||
$coldisplay++;
|
||||
}
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
$colspan++;
|
||||
$coldisplay++;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<td align="center" valign="middle" colspan="<?php echo $colspan; ?>">
|
||||
<input type="submit" class="button" value="<?php echo $langs->trans('Add'); ?>" name="addline_predefined" id="addline_predefined">
|
||||
</td>
|
||||
<?php
|
||||
//Line extrafield
|
||||
if (!empty($extrafieldsline)) {
|
||||
if ($this->table_element_line=='commandedet') {
|
||||
$newline = new OrderLine($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='propaldet') {
|
||||
$newline = new PropaleLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='facturedet') {
|
||||
$newline = new FactureLigne($this->db);
|
||||
}
|
||||
if (is_object($newline)) {
|
||||
print $newline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var],'colspan'=>$coldisplay+5), '_predef');
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
if (! empty($conf->service->enabled) && $dateSelector)
|
||||
{
|
||||
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10;
|
||||
else $colspan = 9;
|
||||
if (! empty($usemargins))
|
||||
{
|
||||
$colspan++; // For the buying price
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
||||
}
|
||||
?>
|
||||
|
||||
<tr <?php echo $bcnd[$var]; ?>>
|
||||
<td colspan="<?php echo $colspan; ?>">
|
||||
<?php
|
||||
if (! empty($object->element) && $object->element == 'contrat')
|
||||
{
|
||||
print $langs->trans("DateStartPlanned").' ';
|
||||
$form->select_date('',"date_start_predef",$usehm,$usehm,1,"addline");
|
||||
print ' '.$langs->trans("DateEndPlanned").' ';
|
||||
$form->select_date('',"date_end_predef",$usehm,$usehm,1,"addline");
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
|
||||
echo $form->select_date('','date_start_predef',empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,1,"addpredefinedproduct");
|
||||
echo ' '.$langs->trans('to').' ';
|
||||
echo $form->select_date('','date_end_predef',empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,1,"addpredefinedproduct");
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
if (! empty($usemargins) && $user->rights->margins->creer)
|
||||
{
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
<?php
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
|
||||
$('#addline_predefined').click(function (e) {
|
||||
return checkLine(e, "np_marginRate_predef");
|
||||
});
|
||||
$("input[name='np_marginRate_predef']:last").blur(function(e) {
|
||||
return checkLine(e, "np_marginRate_predef");
|
||||
});
|
||||
<?php
|
||||
}
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
?>
|
||||
$('#addline_predefined').click(function (e) {
|
||||
return checkLine(e, "np_markRate_predef");
|
||||
});
|
||||
$("input[name='np_marginRate_predef']:last").blur(function(e) {
|
||||
return checkLine(e, "np_markRate_predef");
|
||||
});
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
});
|
||||
|
||||
// TODO This works for french numbers only
|
||||
function checkLine(e, npRate)
|
||||
{
|
||||
var buying_price = $("input[name='buying_price_predef']:last");
|
||||
var remise = $("input[name='remise_percent_predef']:last");
|
||||
|
||||
var rate = $("input[name='"+npRate+"']:last");
|
||||
if (rate.val() == '')
|
||||
return true;
|
||||
if (! $.isNumeric(rate.val().replace(',','.')))
|
||||
{
|
||||
alert('<?php echo dol_escape_js($langs->trans("rateMustBeNumeric")); ?>');
|
||||
e.stopPropagation();
|
||||
setTimeout(function () { rate.focus() }, 50);
|
||||
return false;
|
||||
}
|
||||
if (npRate == "np_markRate_predef" && rate.val() >= 100)
|
||||
{
|
||||
alert('<?php echo dol_escape_js($langs->trans("markRateShouldBeLesserThan100")); ?>');
|
||||
e.stopPropagation();
|
||||
setTimeout(function () { rate.focus() }, 50);
|
||||
return false;
|
||||
}
|
||||
|
||||
var price = 0;
|
||||
remisejs=price2numjs(remise.val());
|
||||
|
||||
if (remisejs != 100)
|
||||
{
|
||||
bpjs=price2numjs(buying_price.val());
|
||||
ratejs=price2numjs(rate.val());
|
||||
|
||||
if (npRate == "np_marginRate_predef")
|
||||
price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
|
||||
else if (npRate == "np_markRate_predef")
|
||||
price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
|
||||
}
|
||||
$("input[name='price_ht_predef']:last").val(price); // TODO Must use a function like php price to have here a formated value
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Function similar to price2num in PHP */
|
||||
function price2numjs(num)
|
||||
{
|
||||
if (num == '') return '';
|
||||
|
||||
<?php
|
||||
$dec=','; $thousand=' ';
|
||||
if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");
|
||||
if ($langs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->transnoentitiesnoconv("SeparatorThousand");
|
||||
if ($thousand == 'None') $thousand='';
|
||||
print "var dec='".$dec."'; var thousand='".$thousand."';\n";
|
||||
?>
|
||||
|
||||
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
|
||||
var main_rounding_unit = <?php echo $conf->global->MAIN_MAX_DECIMALS_UNIT; ?>;
|
||||
var main_rounding_tot = <?php echo $conf->global->MAIN_MAX_DECIMALS_TOT; ?>;
|
||||
|
||||
var amount = num.toString();
|
||||
|
||||
// rounding for unit price
|
||||
var rounding = main_rounding_unit;
|
||||
var pos = amount.indexOf(dec);
|
||||
var decpart = '';
|
||||
if (pos >= 0) decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale
|
||||
var nbdec = decpart.length;
|
||||
if (nbdec > rounding) rounding = nbdec;
|
||||
// If rounding higher than max shown
|
||||
if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
|
||||
|
||||
if (thousand != ',' && thousand != '.') amount=amount.replace(',','.');
|
||||
amount=amount.replace(' ',''); // To avoid spaces
|
||||
amount=amount.replace(thousand,''); // Replace of thousand before replace of dec to avoid pb if thousand is .
|
||||
amount=amount.replace(dec,'.');
|
||||
|
||||
return parseFloat(amount).toFixed(rounding);
|
||||
}
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
$("#idprod").change(function()
|
||||
{
|
||||
$("#fournprice_predef options").remove();
|
||||
$("#fournprice_predef").hide();
|
||||
$("#buying_price_predef").val("").show();
|
||||
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', { 'idprod': $(this).val() }, function(data) {
|
||||
if (data && data.length > 0)
|
||||
{
|
||||
var options = '';
|
||||
var i = 0;
|
||||
$(data).each(function() {
|
||||
i++;
|
||||
options += '<option value="'+this.id+'" price="'+this.price+'"';
|
||||
if (i == 1) {
|
||||
options += ' selected';
|
||||
$("#buying_price_predef").val(this.price);
|
||||
}
|
||||
options += '>'+this.label+'</option>';
|
||||
});
|
||||
options += '<option value=""><?php echo $langs->trans("InputPrice"); ?></option>';
|
||||
$("#buying_price_predef").hide();
|
||||
$("#fournprice_predef").html(options).show();
|
||||
$("#fournprice_predef").change(function() {
|
||||
var selval = $(this).find('option:selected').attr("price");
|
||||
if (selval)
|
||||
$("#buying_price_predef").val(selval).hide();
|
||||
else
|
||||
$('#buying_price_predef').show();
|
||||
});
|
||||
}
|
||||
},
|
||||
'json');
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<!-- END PHP TEMPLATE predefinedproductline_create.tpl.php -->
|
||||
Loading…
Reference in New Issue
Block a user