2012-08-23 13:45:51 +02:00
< ? php
2012-12-30 15:13:49 +01:00
/* Copyright ( C ) 2010 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
2012-08-23 13:45:51 +02:00
* Copyright ( C ) 2010 - 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2012 Christophe Battarel < christophe . battarel @ altairis . fr >
2014-11-14 16:43:49 +01:00
* Copyright ( C ) 2012 Cédric Salvador < csalvador @ gpcsolutions . fr >
* Copyright ( C ) 2012 - 2014 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
2013-06-10 16:05:41 +02:00
* Copyright ( C ) 2013 Florian Henry < florian . henry @ open - concept . pro >
2012-08-23 13:45:51 +02:00
*
* 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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2012-08-23 13:45:51 +02:00
* ( 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 :
2014-05-12 12:53:10 +02:00
* $object ( invoice , order , ... )
2012-08-23 13:45:51 +02:00
* $conf
* $langs
2015-09-06 14:54:25 +02:00
* $seller , $buyer
2012-08-23 13:45:51 +02:00
* $dateSelector
2014-05-12 12:53:10 +02:00
* $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 )
2012-08-23 13:45:51 +02:00
*/
2014-05-12 12:53:10 +02:00
$usemargins = 0 ;
2015-11-15 18:23:42 +01:00
if ( ! empty ( $conf -> margin -> enabled ) && ! empty ( $object -> element ) && in_array ( $object -> element , array ( 'facture' , 'propal' , 'commande' ))) $usemargins = 1 ;
2014-05-12 12:53:10 +02:00
2014-07-04 14:48:27 +02:00
global $forceall , $senderissupplier , $inputalsopricewithtax ;
2014-05-12 12:53:10 +02:00
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
2015-11-15 18:23:42 +01:00
if ( in_array ( $object -> element , array ( 'propal' , 'supplier_proposal' , 'facture' , 'invoice' , 'commande' , 'order' , 'order_supplier' , 'invoice_supplier' ))) $colspan ++ ; // With this, there is a column move button
2012-08-23 13:45:51 +02:00
?>
<!-- BEGIN PHP TEMPLATE objectline_edit . tpl . php -->
2013-11-17 23:25:25 +01:00
< ? php
2014-03-07 11:58:30 +01:00
$coldisplay =- 1 ; // We remove first td
?>
2012-08-23 13:45:51 +02:00
< tr < ? php echo $bc [ $var ]; ?> >
2014-03-07 11:58:30 +01:00
< td < ? php echo ( ! empty ( $conf -> global -> MAIN_VIEW_LINE_NUMBER ) ? ' colspan="2"' : '' ); ?> ><?php $coldisplay+=(! empty($conf->global->MAIN_VIEW_LINE_NUMBER))?2:1; ?>
2013-11-17 23:25:25 +01:00
< div id = " line_<?php echo $line->id ; ?> " ></ div >
< input type = " hidden " name = " lineid " value = " <?php echo $line->id ; ?> " >
< input type = " hidden " id = " product_type " name = " type " value = " <?php echo $line->product_type ; ?> " >
< input type = " hidden " id = " product_id " name = " productid " value = " <?php echo (! empty( $line->fk_product )? $line->fk_product :0); ?> " />
2013-12-16 00:07:50 +01:00
< input type = " hidden " id = " special_code " name = " special_code " value = " <?php echo $line->special_code ; ?> " >
2012-08-23 13:45:51 +02:00
2014-05-12 12:53:10 +02:00
< ? php if ( $line -> fk_product > 0 ) { ?>
2012-08-23 13:45:51 +02:00
2014-09-18 21:18:25 +02:00
< a href = " <?php echo DOL_URL_ROOT.'/product/card.php?id='. $line->fk_product ; ?> " >
2012-09-07 10:03:25 +02:00
< ? php
if ( $line -> product_type == 1 ) echo img_object ( $langs -> trans ( 'ShowService' ), 'service' );
else print img_object ( $langs -> trans ( 'ShowProduct' ), 'product' );
echo ' ' . $line -> ref ;
?>
</ a >
< ? php
echo ' - ' . nl2br ( $line -> product_label );
?>
2012-08-27 19:11:44 +02:00
2012-09-08 00:58:14 +02:00
< br >
2012-09-07 18:16:05 +02:00
2012-09-08 00:58:14 +02:00
< ? php } ?>
2012-08-23 13:45:51 +02:00
< ? php
if ( is_object ( $hookmanager ))
{
$fk_parent_line = ( GETPOST ( 'fk_parent_line' ) ? GETPOST ( 'fk_parent_line' ) : $line -> fk_parent_line );
$parameters = array ( 'line' => $line , 'fk_parent_line' => $fk_parent_line , 'var' => $var , 'dateSelector' => $dateSelector , 'seller' => $seller , 'buyer' => $buyer );
$reshook = $hookmanager -> executeHooks ( 'formEditProductOptions' , $parameters , $this , $action );
}
2014-11-14 16:43:49 +01:00
// Do not allow editing during a situation cycle
2015-03-13 17:46:31 +01:00
if ( empty ( $this -> situation_cycle_ref ) || $this -> situation_counter == 1 )
{
2014-11-14 16:43:49 +01:00
// editeur wysiwyg
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
$nbrows = ROWS_2 ;
if ( ! empty ( $conf -> global -> MAIN_INPUT_DESC_HEIGHT )) $nbrows = $conf -> global -> MAIN_INPUT_DESC_HEIGHT ;
$enable = ( isset ( $conf -> global -> FCKEDITOR_ENABLE_DETAILS ) ? $conf -> global -> FCKEDITOR_ENABLE_DETAILS : 0 );
2015-03-13 17:46:31 +01:00
$toolbarname = 'dolibarr_details' ;
if ( ! empty ( $conf -> global -> FCKEDITOR_ENABLE_DETAILS_FULL )) $toolbarname = 'dolibarr_notes' ;
$doleditor = new DolEditor ( 'product_desc' , $line -> description , '' , 164 , $toolbarname , '' , false , true , $enable , $nbrows , '98%' );
2014-11-14 16:43:49 +01:00
$doleditor -> Create ();
} else {
2015-05-12 15:09:23 +02:00
print '<textarea id="desc" class="flat" name="desc" readonly style="width: 200px; height:80px;">' . $line -> description . '</textarea>' ;
2014-11-14 16:43:49 +01:00
}
2012-08-23 13:45:51 +02:00
?>
</ td >
2015-11-15 18:23:42 +01:00
< ? php if ( $object -> element == 'supplier_proposal' ) { ?>
2015-02-02 17:50:33 +01:00
< td align = " right " >< input id = " fourn_ref " name = " fourn_ref " class = " flat " value = " <?php echo $line->ref_fourn ; ?> " size = " 12 " ></ td >
< ? php } ?>
2015-03-04 17:54:43 +01:00
2014-11-14 16:43:49 +01:00
< ? php
$coldisplay ++ ;
if ( $this -> situation_counter == 1 || ! $this -> situation_cycle_ref ) {
2015-11-14 15:28:25 +01:00
print '<td align="right">' . $form -> load_tva ( 'tva_tx' , $line -> tva_tx , $seller , $buyer , 0 , $line -> info_bits , $line -> product_type , false , 1 ) . '</td>' ;
2014-11-14 16:43:49 +01:00
} else {
2015-05-12 15:09:23 +02:00
print '<td align="right"><input size="1" type="text" class="flat" name="tva_tx" value="' . price ( $line -> tva_tx ) . '" readonly />%</td>' ;
2014-11-14 16:43:49 +01:00
}
2012-08-23 13:45:51 +02:00
2014-11-14 16:43:49 +01:00
$coldisplay ++ ;
2015-02-28 18:10:31 +01:00
print '<td align="right"><input type="text" class="flat" size="8" id="price_ht" name="price_ht" value="' . ( isset ( $line -> pu_ht ) ? price ( $line -> pu_ht , 0 , '' , 0 ) : price ( $line -> subprice , 0 , '' , 0 )) . '"' ;
2015-05-12 15:09:23 +02:00
if ( $this -> situation_counter > 1 ) print ' readonly' ;
2014-11-14 16:43:49 +01:00
print '></td>' ;
2015-02-28 18:10:31 +01:00
if ( $inputalsopricewithtax )
{
2014-11-14 16:43:49 +01:00
$coldisplay ++ ;
2015-02-28 18:10:31 +01:00
print '<td align="right"><input type="text" class="flat" size="8" id="price_ttc" name="price_ttc" value="' . ( isset ( $line -> pu_ttc ) ? price ( $line -> pu_ttc , 0 , '' , 0 ) : '' ) . '"' ;
2015-05-12 15:09:23 +02:00
if ( $this -> situation_counter > 1 ) print ' readonly' ;
2014-11-14 16:43:49 +01:00
print '></td>' ;
2015-02-28 18:10:31 +01:00
}
?>
2013-06-10 16:05:41 +02:00
< td align = " right " >< ? php $coldisplay ++ ; ?>
2012-10-06 23:13:46 +02:00
< ? php if (( $line -> 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;"')." ";
2015-02-28 18:10:31 +01:00
print '<input size="3" type="text" class="flat" name="qty" id="qty" value="' . $line -> qty . '"' ;
2015-05-12 15:09:23 +02:00
if ( $this -> situation_counter > 1 ) print ' readonly' ;
2015-02-28 18:10:31 +01:00
print '>' ;
2014-11-14 16:43:49 +01:00
} else { ?>
2012-08-23 13:45:51 +02:00
& nbsp ;
< ? php } ?>
</ td >
2015-02-26 14:15:33 +01:00
< ? php
if ( $conf -> global -> PRODUCT_USE_UNITS )
{
print '<td align="left">' ;
2015-04-21 15:49:58 +02:00
print $form -> selectUnits ( $line -> fk_unit , " units " );
2015-02-26 14:15:33 +01:00
print '</td>' ;
}
?>
2015-05-12 15:37:35 +02:00
< td align = " right " class = " nowrap " >< ? php $coldisplay ++ ; ?>
2014-11-14 16:43:49 +01:00
< ? php if (( $line -> info_bits & 2 ) != 2 ) {
2015-02-28 18:10:31 +01:00
print '<input size="1" type="text" class="flat" name="remise_percent" id="remise_percent" value="' . $line -> remise_percent . '"' ;
2015-05-12 15:09:23 +02:00
if ( $this -> situation_counter > 1 ) print ' readonly' ;
2015-02-28 18:10:31 +01:00
print '>%' ;
2014-11-14 16:43:49 +01:00
} else { ?>
2012-08-23 13:45:51 +02:00
& nbsp ;
< ? php } ?>
</ td >
2014-05-12 13:25:36 +02:00
< ? php
2014-11-14 16:43:49 +01:00
if ( $this -> situation_cycle_ref ) {
$coldisplay ++ ;
2015-05-12 15:37:35 +02:00
print '<td align="right" class="nowrap"><input type="text" size="1" value="' . $line -> situation_percent . '" name="progress">%</td>' ;
2014-11-14 16:43:49 +01:00
}
2014-05-12 13:25:36 +02:00
if ( ! empty ( $usemargins ))
{
?>
2014-11-05 17:03:53 +01:00
< td align = " right " class = " margininfos " >< ? php $coldisplay ++ ; ?>
2014-05-12 13:25:36 +02:00
<!-- For predef product -->
< ? php if ( ! empty ( $conf -> product -> enabled ) || ! empty ( $conf -> service -> enabled )) { ?>
2015-09-18 20:43:10 +02:00
< select id = " fournprice_predef " name = " fournprice_predef " class = " flat " data - role = " none " style = " display: none; " ></ select >
2014-05-12 13:25:36 +02:00
< ? php } ?>
<!-- For free product -->
2013-08-22 11:39:55 +02:00
< input type = " text " size = " 5 " id = " buying_price " name = " buying_price " class = " hideobject " value = " <?php echo price( $line->pa_ht ,0,'',0); ?> " >
</ td >
< ? php if ( $user -> rights -> margins -> creer ) {
if ( ! empty ( $conf -> global -> DISPLAY_MARGIN_RATES ))
{
2014-03-07 11:58:30 +01:00
$margin_rate = ( isset ( $_POST [ " np_marginRate " ]) ? $_POST [ " np_marginRate " ] : (( $line -> pa_ht == 0 ) ? '' : price ( $line -> marge_tx )));
2013-09-24 17:49:56 +02:00
// if credit note, dont allow to modify margin
if ( $line -> subprice < 0 )
2014-11-05 17:03:53 +01:00
echo '<td align="right" class="nowrap margininfos">' . $margin_rate . '<span class="hideonsmartphone">%</span></td>' ;
2013-09-24 17:49:56 +02:00
else
2014-11-05 17:03:53 +01:00
echo '<td align="right" class="nowrap margininfos"><input type="text" size="2" name="np_marginRate" value="' . $margin_rate . '"><span class="hideonsmartphone">%</span></td>' ;
2013-08-22 11:39:55 +02:00
$coldisplay ++ ;
}
2013-08-22 11:45:27 +02:00
elseif ( ! empty ( $conf -> global -> DISPLAY_MARK_RATES ))
2013-08-22 11:39:55 +02:00
{
2014-03-07 11:58:30 +01:00
$mark_rate = ( isset ( $_POST [ " np_markRate " ]) ? $_POST [ " np_markRate " ] : price ( $line -> marque_tx ));
2013-09-24 17:49:56 +02:00
// if credit note, dont allow to modify margin
if ( $line -> subprice < 0 )
2014-11-05 17:03:53 +01:00
echo '<td align="right" class="nowrap margininfos">' . $mark_rate . '<span class="hideonsmartphone">%</span></td>' ;
2013-09-24 17:49:56 +02:00
else
2014-11-05 17:03:53 +01:00
echo '<td align="right" class="nowrap margininfos"><input type="text" size="2" name="np_markRate" value="' . $mark_rate . '"><span class="hideonsmartphone">%</span></td>' ;
2013-08-22 11:39:55 +02:00
$coldisplay ++ ;
}
}
2015-02-28 18:10:31 +01:00
}
?>
2012-08-23 13:45:51 +02:00
2014-03-07 11:58:30 +01:00
<!-- colspan = 4 for this td because it replace total_ht + 3 td for buttons -->
2014-05-12 12:53:10 +02:00
< td align = " center " colspan = " <?php echo $colspan ; ?> " valign = " middle " >< ? php $coldisplay += 4 ; ?>
2012-08-23 13:45:51 +02:00
< 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 >
2013-06-10 16:05:41 +02:00
< ? php
//Line extrafield
2015-02-27 18:05:12 +01:00
if ( ! empty ( $extrafieldsline ))
{
2013-06-10 16:05:41 +02:00
print $line -> showOptionals ( $extrafieldsline , 'edit' , array ( 'style' => $bc [ $var ], 'colspan' => $coldisplay ));
}
?>
2012-08-23 13:45:51 +02:00
</ tr >
2012-09-19 12:02:06 +02:00
< ? php if ( ! empty ( $conf -> service -> enabled ) && $line -> product_type == 1 && $dateSelector ) { ?>
2012-08-23 13:45:51 +02:00
< tr id = " service_duration_area " < ? php echo $bc [ $var ]; ?> >
< td colspan = " 11 " >< ? php echo $langs -> trans ( 'ServiceLimitedDuration' ) . ' ' . $langs -> trans ( 'From' ) . ' ' ; ?>
< ? php
2012-09-07 11:40:59 +02:00
$hourmin = ( isset ( $conf -> global -> MAIN_USE_HOURMIN_IN_DATE_RANGE ) ? $conf -> global -> MAIN_USE_HOURMIN_IN_DATE_RANGE : '' );
2015-07-12 12:50:24 +02:00
echo $form -> select_date ( $line -> date_start , 'date_start' , $hourmin , $hourmin , $line -> date_start ? 0 : 1 , " updateligne " , 1 , 0 , 1 );
2012-08-23 13:45:51 +02:00
echo ' ' . $langs -> trans ( 'to' ) . ' ' ;
2015-07-12 12:50:24 +02:00
echo $form -> select_date ( $line -> date_end , 'date_end' , $hourmin , $hourmin , $line -> date_end ? 0 : 1 , " updateligne " , 1 , 0 , 1 );
2012-08-23 13:45:51 +02:00
?>
</ td >
</ tr >
< ? php } ?>
< script type = " text/javascript " >
2013-11-17 23:25:25 +01:00
< ? php
if ( ! empty ( $conf -> margin -> enabled ))
{
?>
jQuery ( document ) . ready ( function ()
{
2015-08-31 13:06:53 +02:00
/* Add rule to clear margin when we change some data, so when we change sell or buy price, margin will be recalculated after submitting form */
jQuery ( " #tva_tx " ) . click ( function () { /* somtimes field is a text, sometimes a combo */
jQuery ( " input[name='np_marginRate']:first " ) . val ( '' );
jQuery ( " input[name='np_markRate']:first " ) . val ( '' );
});
jQuery ( " #tva_tx " ) . keyup ( function () { /* somtimes field is a text, sometimes a combo */
jQuery ( " input[name='np_marginRate']:first " ) . val ( '' );
jQuery ( " input[name='np_markRate']:first " ) . val ( '' );
});
2014-03-07 11:58:30 +01:00
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 */
2013-11-17 23:25:25 +01:00
$ . post ( '<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php' , { 'idprod' : < ? php echo $line -> fk_product ? $line -> fk_product : 0 ; ?> }, function(data) {
2015-09-06 15:06:13 +02:00
if ( data && data . length > 0 ) {
2012-08-23 13:45:51 +02:00
var options = '' ;
var trouve = false ;
$ ( data ) . each ( function () {
options += '<option value="' + this . id + '" price="' + this . price + '"' ;
< ? php if ( $line -> fk_fournprice > 0 ) { ?>
if ( this . id == < ? php echo $line -> fk_fournprice ; ?> ) {
options += ' selected' ;
$ ( " #buying_price " ) . val ( this . price );
trouve = true ;
}
< ? php } ?>
options += '>' + this . label + '</option>' ;
});
options += '<option value=null' + ( trouve ? '' : ' selected' ) + '><?php echo $langs->trans("InputPrice"); ?></option>' ;
$ ( " #fournprice " ) . html ( options );
if ( trouve ) {
$ ( " #buying_price " ) . hide ();
$ ( " #fournprice " ) . show ();
} else {
$ ( " #buying_price " ) . show ();
}
$ ( " #fournprice " ) . change ( function () {
var selval = $ ( this ) . find ( 'option:selected' ) . attr ( " price " );
if ( selval )
$ ( " #buying_price " ) . val ( selval ) . hide ();
else
$ ( '#buying_price' ) . show ();
});
} else {
$ ( " #fournprice " ) . hide ();
$ ( '#buying_price' ) . show ();
}
2013-11-17 23:25:25 +01:00
}, 'json' );
2013-08-22 11:39:55 +02:00
2014-03-07 11:58:30 +01:00
/* Add rules to reset price_ht from margin info */
2013-11-17 23:25:25 +01:00
< ? php
if ( ! empty ( $conf -> global -> DISPLAY_MARGIN_RATES ))
{
?>
$ ( '#savelinebutton' ) . click ( function ( e ) {
2015-06-13 11:46:35 +02:00
return checkEditLine ( e , " np_marginRate " );
2013-11-17 23:25:25 +01:00
});
2015-09-06 14:54:25 +02:00
/* Disabled . We must be able to click on button 'cancel' . Check must be done only on button 'save' .
2013-11-17 23:25:25 +01:00
$ ( " input[name='np_marginRate']:first " ) . blur ( function ( e ) {
2015-06-13 11:46:35 +02:00
return checkEditLine ( e , " np_marginRate " );
2015-09-06 14:54:25 +02:00
}); */
2013-11-17 23:25:25 +01:00
< ? php
}
if ( ! empty ( $conf -> global -> DISPLAY_MARK_RATES ))
{
?>
$ ( '#savelinebutton' ) . click ( function ( e ) {
2015-06-13 11:46:35 +02:00
return checkEditLine ( e , " np_markRate " );
2013-11-17 23:25:25 +01:00
});
2015-09-06 14:54:25 +02:00
/* Disabled . We must be able to click on button 'cancel' . Check must be done only on button 'save' .
2013-11-17 23:25:25 +01:00
$ ( " input[name='np_markRate']:first " ) . blur ( function ( e ) {
2015-06-13 11:46:35 +02:00
return checkEditLine ( e , " np_markRate " );
2015-09-06 14:54:25 +02:00
}); */
2013-11-17 23:25:25 +01:00
< ? php
}
?>
2013-08-22 11:39:55 +02:00
});
2014-03-07 11:58:30 +01:00
/* If margin rate field empty, do nothing. */
2015-09-06 14:54:25 +02:00
/* Force content of price_ht to 0 or if a discount is set, recalculate it from margin rate */
2013-11-17 23:25:25 +01:00
function checkEditLine ( e , npRate )
2013-08-22 11:39:55 +02:00
{
2013-11-17 23:25:25 +01:00
var buying_price = $ ( " input[name='buying_price']:first " );
var remise = $ ( " input[name='remise_percent']:first " );
2013-08-22 11:39:55 +02:00
2013-11-17 23:25:25 +01:00
var rate = $ ( " input[name=' " + npRate + " ']:first " );
2015-08-20 03:38:21 +02:00
if ( rate . val () == '' || ( typeof rate . val ()) == 'undefined' ) return true ;
2014-03-07 11:58:30 +01:00
2015-09-06 14:54:25 +02:00
if ( ! $ . isNumeric ( rate . val () . replace ( ' ' , '' ) . replace ( ',' , '.' )))
2013-11-17 23:25:25 +01:00
{
2015-09-06 14:54:25 +02:00
alert ( '<?php echo $langs->transnoentitiesnoconv("rateMustBeNumeric"); ?>' );
2013-11-17 23:25:25 +01:00
e . stopPropagation ();
setTimeout ( function () { rate . focus () }, 50 );
return false ;
}
2015-08-20 03:38:21 +02:00
if ( npRate == " np_markRate " && rate . val () >= 100 )
2013-11-17 23:25:25 +01:00
{
2015-09-06 14:54:25 +02:00
alert ( '<?php echo $langs->transnoentitiesnoconv("markRateShouldBeLesserThan100"); ?>' );
2013-11-17 23:25:25 +01:00
e . stopPropagation ();
setTimeout ( function () { rate . focus () }, 50 );
return false ;
}
var price = 0 ;
2014-02-16 19:42:43 +01:00
remisejs = price2numjs ( remise . val ());
if ( remisejs != 100 )
2013-11-17 23:25:25 +01:00
{
2014-02-16 19:26:41 +01:00
bpjs = price2numjs ( buying_price . val ());
ratejs = price2numjs ( rate . val ());
2015-08-20 03:38:21 +02:00
/* console.log(npRate+" - "+bpjs+" - "+ratejs); */
if ( npRate == " np_marginRate " )
2015-09-06 14:54:25 +02:00
price = (( bpjs * ( 1 + ( ratejs / 100 ))) / ( 1 - remisejs / 100 ));
2015-08-20 03:38:21 +02:00
else if ( npRate == " np_markRate " )
2015-09-06 14:54:25 +02:00
{
if ( ratejs != 100 )
{
price = (( bpjs / ( 1 - ( ratejs / 100 ))) / ( 1 - remisejs / 100 ));
}
else price = $ ( " input[name='price_ht']:first " ) . val ();
}
2013-08-22 11:39:55 +02:00
}
2015-09-06 14:54:25 +02:00
/* console.log("new price ht = "+price); */
2014-02-16 19:26:41 +01:00
$ ( " input[name='price_ht']:first " ) . val ( price ); // TODO Must use a function like php price to have here a formated value
2013-11-17 23:25:25 +01:00
return true ;
2013-08-22 11:39:55 +02:00
}
2013-11-17 23:25:25 +01:00
< ? php
2013-08-22 11:39:55 +02:00
}
2013-11-17 23:25:25 +01:00
?>
2013-08-22 11:39:55 +02:00
2012-08-23 13:45:51 +02:00
</ script >
<!-- END PHP TEMPLATE objectline_edit . tpl . php -->