37 if (empty($object) || !is_object($object)) {
 
   38   print 
"Error, template page can't be called as URL";
 
   44 if (
isModEnabled(
'margin') && !empty($object->element) && in_array($object->element, array(
'facture', 
'facturerec', 
'propal', 
'commande'))) {
 
   48 global $forceall, $senderissupplier, $inputalsopricewithtax, $canchangeproduct;
 
   49 if (empty($dateSelector)) {
 
   52 if (empty($forceall)) {
 
   55 if (empty($senderissupplier)) {
 
   56   $senderissupplier = 0;
 
   58 if (empty($inputalsopricewithtax)) {
 
   59   $inputalsopricewithtax = 0;
 
   61 if (empty($canchangeproduct)) {
 
   62   $canchangeproduct = 0;
 
   67 if (!empty($inputalsopricewithtax)) {
 
   70 if (in_array($object->element, array(
'propal', 
'supplier_proposal', 
'facture', 
'facturerec', 
'invoice', 
'commande', 
'order', 
'order_supplier', 
'invoice_supplier', 
'invoice_supplier_rec'))) {
 
   73 if (
isModEnabled(
"multicurrency") && $this->multicurrency_code != $conf->currency) {
 
   76 if (
isModEnabled(
'asset') && $object->element == 
'invoice_supplier') {
 
   82 print 
"<!-- BEGIN PHP TEMPLATE objectline_edit.tpl.php -->\n";
 
   86 <tr 
class=
"oddeven tredited">
 
   87 <?php 
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
 
   88     <td 
class=
"linecolnum center"><?php $coldisplay++; ?><?php echo ($i + 1); ?></td>
 
   93   <td 
class=
"linecoldesc minwidth250onall">
 
   94   <div 
id=
"line_<?php echo $line->id; ?>"></div>
 
   96   <input 
type=
"hidden" name=
"lineid" value=
"<?php echo $line->id; ?>">
 
   97   <input 
type=
"hidden" id=
"product_type" name=
"type" value=
"<?php echo $line->product_type; ?>">
 
   98   <input 
type=
"hidden" id=
"special_code" name=
"special_code" value=
"<?php echo $line->special_code; ?>">
 
   99   <input 
type=
"hidden" id=
"fk_parent_line" name=
"fk_parent_line" value=
"<?php echo $line->fk_parent_line; ?>">
 
  101   <?php 
if ($line->fk_product > 0) { ?>
 
  103     if (empty($canchangeproduct)) {
 
  104       if ($line->fk_parent_line > 0) {
 
  108       <a href=
"<?php echo DOL_URL_ROOT.'/product/card.php?id='.$line->fk_product; ?>">
 
  110       if ($line->product_type == 1) {
 
  111         echo 
img_object($langs->trans(
'ShowService'), 
'service');
 
  113         print 
img_object($langs->trans(
'ShowProduct'), 
'product');
 
  119       echo 
' - '.nl2br($line->product_label);
 
  120       print 
'<input type="hidden" id="product_id" name="productid" value="'.(!empty($line->fk_product) ? $line->fk_product : 0).
'">';
 
  122       if ($senderissupplier) {
 
  123         $form->select_produits_fournisseurs(!empty($line->fk_product) ? $line->fk_product : 0, 
'productid');
 
  125         print 
$form->select_produits(!empty($line->fk_product) ? $line->fk_product : 0, 
'productid');
 
  133   if (is_object($hookmanager)) {
 
  134     $fk_parent_line = (
GETPOST(
'fk_parent_line') ? 
GETPOST(
'fk_parent_line', 
'int') : $line->fk_parent_line);
 
  135     $parameters = array(
'line'=>$line, 
'fk_parent_line'=>$fk_parent_line, 
'var'=>$var, 
'dateSelector'=>$dateSelector, 
'seller'=>$seller, 
'buyer'=>$buyer);
 
  136     $reshook = $hookmanager->executeHooks(
'formEditProductOptions', $parameters, $this, $action);
 
  139   $situationinvoicelinewithparent = 0;
 
  140   if ($line->fk_prev_id != 
null && in_array($object->element, array(
'facture', 
'facturedet'))) {
 
  141     if ($object->type == $object::TYPE_SITUATION) { 
 
  143       $situationinvoicelinewithparent = 1;
 
  148   if (!$situationinvoicelinewithparent) {
 
  150     require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
 
  152     if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
 
  153       $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
 
  155     $enable = (isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
 
  156     $toolbarname = 
'dolibarr_details';
 
  157     if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) {
 
  158       $toolbarname = 
'dolibarr_notes';
 
  160     $doleditor = 
new DolEditor(
'product_desc', 
GETPOSTISSET(
'product_desc') ? 
GETPOST(
'product_desc', 
'restricthtml') : $line->description, 
'', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT) ? 164 : $conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, 
'', 
false, 
true, $enable, $nbrows, 
'98%');
 
  161     $doleditor->Create();
 
  163     print 
'<textarea id="product_desc" class="flat" name="product_desc" readonly style="width: 200px; height:80px;">';
 
  169   if (!empty($extrafields)) {
 
  170     $temps = $line->showOptionals($extrafields, 
'edit', array(
'class'=>
'tredited'), 
'', 
'', 1, 
'line');
 
  171     if (!empty($temps)) {
 
  172       print 
'<div style="padding-top: 10px" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
 
  179   if (
isModEnabled(
"service") && $line->product_type == 1 && ($line->element == 
'facturedetrec' || $line->element == 
'invoice_supplier_det_rec')) {
 
  180     if ($line->element == 
'invoice_supplier_det_rec') {
 
  181       $line->date_start_fill = $line->date_start;
 
  182       $line->date_end_fill = $line->date_end;
 
  185     echo $langs->trans(
'AutoFillDateFrom').
' ';
 
  186     echo 
$form->selectyesno(
'date_start_fill', 
GETPOSTISSET(
'date_start_fill') ? 
GETPOST(
'date_start_fill', 
'int') : $line->date_start_fill, 1);
 
  188     echo $langs->trans(
'AutoFillDateTo').
' ';
 
  189     echo 
$form->selectyesno(
'date_end_fill', 
GETPOSTISSET(
'date_end_fill') ? 
GETPOST(
'date_end_fill', 
'int') : $line->date_end_fill, 1);
 
  196   if ($object->element == 
'supplier_proposal' || $object->element == 
'order_supplier' || $object->element == 
'invoice_supplier' || $object->element == 
'invoice_supplier_rec') {  
 
  199     <td 
class=
"right linecolrefsupplier"><input 
id=
"fourn_ref" name=
"fourn_ref" class=
"flat minwidth50 maxwidth100 maxwidth125onsmartphone" value=
"<?php echo GETPOSTISSET('fourn_ref') ? GETPOST('fourn_ref') : ($line->ref_supplier ? $line->ref_supplier : $line->ref_fourn); ?>"></td>
 
  201     print 
'<input type="hidden" id="fournprice" name="fournprice"  class="" value="'.$line->fk_fournprice.
'">';
 
  206   if (!$situationinvoicelinewithparent) {
 
  207     print 
'<td class="right">';
 
  208     print 
$form->load_tva(
'tva_tx', 
GETPOSTISSET(
'tva_tx') ? 
GETPOST(
'tva_tx', 
'alpha') : ($line->tva_tx.($line->vat_src_code ? (
' ('.$line->vat_src_code.
')') : 
'')), $seller, $buyer, 0, $line->info_bits, $line->product_type, 
false, 1);
 
  211     print 
'<td class="right"><input size="1" type="text" class="flat right" name="tva_tx" value="'.price($line->tva_tx).
'" readonly />%</td>';
 
  215   print 
'<td class="right"><input type="text" class="flat right" size="5" id="price_ht" name="price_ht" value="'.(GETPOSTISSET(
'price_ht') ? 
GETPOST(
'price_ht', 
'alpha') : (isset($line->pu_ht) ? 
price($line->pu_ht, 0, 
'', 0) : 
price($line->subprice, 0, 
'', 0))).
'"';
 
  216   if ($situationinvoicelinewithparent) {
 
  221   if (
isModEnabled(
"multicurrency") && $this->multicurrency_code != $conf->currency) {
 
  223     print 
'<td class="right"><input rel="'.$object->multicurrency_tx.
'" type="text" class="flat right" size="5" id="multicurrency_subprice" name="multicurrency_subprice" value="'.(
GETPOSTISSET(
'multicurrency_subprice') ? 
GETPOST(
'multicurrency_subprice', 
'alpha') : 
price($line->multicurrency_subprice)).
'" /></td>';
 
  226   if ($inputalsopricewithtax) {
 
  228     print 
'<td class="right"><input type="text" class="flat right" size="5" id="price_ttc" name="price_ttc" value="'.(GETPOSTISSET(
'price_ttc') ? 
GETPOST(
'price_ttc') : (isset($line->pu_ttc) ? 
price($line->pu_ttc, 0, 
'', 0) : 
'')).
'"';
 
  229     if ($line->fk_prev_id != 
null) {
 
  237   if (($line->info_bits & 2) != 2) {
 
  242     print 
'<input size="3" type="text" class="flat right" name="qty" id="qty" value="'.(GETPOSTISSET(
'qty') ? 
GETPOST(
'qty') : $line->qty).
'"';
 
  243     if ($situationinvoicelinewithparent) {  
 
  253   if (!empty($conf->global->PRODUCT_USE_UNITS)) {
 
  256     if (!empty($line->fk_unit) && empty($conf->global->MAIN_EDIT_LINE_ALLOW_ALL_UNIT_TYPE)) {
 
  257       include_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
 
  258       $cUnit = 
new CUnits($line->db);
 
  259       if ($cUnit->fetch($line->fk_unit) > 0) {
 
  260         if (!empty($cUnit->unit_type)) {
 
  261           $unit_type = $cUnit->unit_type;
 
  266     print 
'<td class="left">';
 
  272   <td 
class=
"nowraponall right linecoldiscount">
 
  276   if (($line->info_bits & 2) != 2) {
 
  277     print 
'<input type="text" class="flat right width40" name="remise_percent" id="remise_percent" value="'.(GETPOSTISSET(
'remise_percent') ? 
GETPOST(
'remise_percent') : ($line->remise_percent ? $line->remise_percent : 
'')).
'"';
 
  278     if ($situationinvoicelinewithparent) {
 
  281     print 
'><span class="hideonsmartphone opacitymedium">%</span>';
 
  289   if ($this->situation_cycle_ref) {
 
  291     print 
'<td class="nowrap right linecolcycleref"><input class="right" type="text" size="1" value="'.(GETPOSTISSET(
'progress') ? 
GETPOST(
'progress') : $line->situation_percent).
'" name="progress">%</td>';
 
  296   if (!empty($usemargins)) {
 
  297     if (!empty($user->rights->margins->creer)) {
 
  300     <td 
class=
"margininfos right">
 
  301       <!-- For predef product -->
 
  303       <select 
id=
"fournprice_predef" name=
"fournprice_predef" class=
"flat minwidth75imp right" style=
"display: none;"></select>
 
  305       <!-- For free product -->
 
  306       <input 
class=
"flat maxwidth75 right" type=
"text" id=
"buying_price" name=
"buying_price" class=
"hideobject" value=
"<?php echo (GETPOSTISSET('buying_price') ? GETPOST('buying_price') : price($line->pa_ht, 0, '', 0)); ?>">
 
  310     if ($user->rights->margins->creer) {
 
  311       if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
 
  312         $margin_rate = (
GETPOSTISSET(
"np_marginRate") ? 
GETPOST(
"np_marginRate", 
"alpha", 2) : (($line->pa_ht == 0) ? 
'' : 
price($line->marge_tx)));
 
  314         if ($line->subprice < 0) {
 
  315           echo 
'<td class="right nowrap margininfos">'.$margin_rate.
'<span class="opacitymedium hideonsmartphone">%</span></td>';
 
  317           echo 
'<td class="right nowrap margininfos"><input class="right maxwidth40" type="text" name="np_marginRate" value="'.$margin_rate.
'"><span class="opacitymedium hideonsmartphone">%</span></td>';
 
  321       if (!empty($conf->global->DISPLAY_MARK_RATES)) {
 
  324         if ($line->subprice < 0) {
 
  325           echo 
'<td class="right nowrap margininfos">'.$mark_rate.
'<span class="opacitymedium hideonsmartphone">%</span></td>';
 
  327           echo 
'<td class="right nowrap margininfos"><input class="right maxwidth40" type="text" name="np_markRate" value="'.$mark_rate.
'"><span class="opacitymedium hideonsmartphone">%</span></td>';
 
  335   <!-- colspan 
for this td because it replace total_ht+3 td 
for buttons+... -->
 
  336   <td 
class=
"center valignmiddle" colspan=
"<?php echo $colspan; ?>"><?php $coldisplay += $colspan; ?>
 
  337     <input 
type=
"submit" class=
"reposition button buttongen marginbottomonly button-save" id=
"savelinebutton marginbottomonly" name=
"save" value=
"<?php echo $langs->trans("Save
"); ?>"><br>
 
  338     <input 
type=
"submit" class=
"reposition button buttongen marginbottomonly button-cancel" id=
"cancellinebutton" name=
"cancel" value=
"<?php echo $langs->trans("Cancel
"); ?>">
 
  342 <?php 
if (
isModEnabled(
"service") && $line->product_type == 1 && $dateSelector) { ?>
 
  343 <tr 
id=
"service_duration_area" class=
"treditedlinefordate">
 
  344   <?php 
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
 
  345     <td 
class=
"linecolnum center"></td>
 
  347   <td colspan=
"<?php echo $coldisplay - (empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? 0 : 1) ?>"><?php echo $langs->trans(
'ServiceLimitedDuration').
' '.$langs->trans(
'From').
' '; ?>
 
  349   $hourmin = (isset($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : 
'');
 
  350   print 
$form->selectDate($line->date_start, 
'date_start', $hourmin, $hourmin, $line->date_start ? 0 : 1, 
"updateline", 1, 0);
 
  351   print 
' '.$langs->trans(
'to').
' ';
 
  352   print 
$form->selectDate($line->date_end, 
'date_end', $hourmin, $hourmin, $line->date_end ? 0 : 1, 
"updateline", 1, 0);
 
  354   if (!$line->date_start) {
 
  355     if (isset($conf->global->MAIN_DEFAULT_DATE_START_HOUR)) {
 
  356       print 
'jQuery("#date_starthour").val("'.$conf->global->MAIN_DEFAULT_DATE_START_HOUR.
'");';
 
  360     if (isset($conf->global->MAIN_DEFAULT_DATE_START_MIN)) {
 
  361       print 
'jQuery("#date_startmin").val("'.$conf->global->MAIN_DEFAULT_DATE_START_MIN.
'");';
 
  364     $res = $line->fetch_product();
 
  366       if ( $line->product->isMandatoryPeriod() && $line->product->isService()) {
 
  367         print  
'jQuery("#date_start").addClass("error");';
 
  371   if (!$line->date_end) {
 
  372     if (isset($conf->global->MAIN_DEFAULT_DATE_END_HOUR)) {
 
  373       print 
'jQuery("#date_endhour").val("'.$conf->global->MAIN_DEFAULT_DATE_END_HOUR.
'");';
 
  375     if (isset($conf->global->MAIN_DEFAULT_DATE_END_MIN)) {
 
  376       print 
'jQuery("#date_endmin").val("'.$conf->global->MAIN_DEFAULT_DATE_END_MIN.
'");';
 
  379     $res = $line->fetch_product();
 
  382       if ($line->product->isMandatoryperiod() && $line->product->isService()) {
 
  383         print  
'jQuery("#date_end").addClass("error");';
 
  398 if (!empty($usemargins) && $user->rights->margins->creer) {
 
  401   jQuery(document).ready(
function() {
 
  403   if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
 
  405       $(
"input[name='np_marginRate']:first").blur(function(e) {
 
  406         return checkFreeLine(e, 
"np_marginRate");
 
  410   if (!empty($conf->global->DISPLAY_MARK_RATES)) {
 
  412       $(
"input[name='np_markRate']:first").blur(
function(e) {
 
  413         return checkFreeLine(e, 
"np_markRate");
 
  421   function checkFreeLine(e, npRate)
 
  423     var buying_price = $(
"input[name='buying_price']:first");
 
  424     var remise = $(
"input[name='remise_percent']:first");
 
  426     var rate = $(
"input[name='"+npRate+
"']:first");
 
  427     if (rate.val() == 
'')
 
  431     if (! $.isNumeric(ratejs))
 
  433       alert(
'<?php echo dol_escape_js($langs->transnoentities("rateMustBeNumeric")); ?>');
 
  435       setTimeout(
function () { rate.focus() }, 50);
 
  438     if (npRate == 
"np_markRate" && rate.val() >= 100)
 
  440       alert(
'<?php echo dol_escape_js($langs->transnoentities("markRateShouldBeLesserThan100")); ?>');
 
  442       setTimeout(
function () { rate.focus() }, 50);
 
  451       if (remisejs == 
'') remisejs=0;
 
  456       if (npRate == 
"np_marginRate")
 
  457         price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
 
  458       else if (npRate == 
"np_markRate")
 
  459         price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
 
  461     $(
"input[name='price_ht']:first").val(
price); 
 
  469 jQuery(document).ready(
function()
 
  471   jQuery(
"#price_ht").keyup(
function(event) {
 
  473     if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery(
"#price_ht").val() != 
'') {
 
  474       jQuery(
"#price_ttc").val(
'');
 
  475       jQuery(
"#multicurrency_subprice").val(
'');
 
  478   jQuery(
"#price_ttc").keyup(
function(event) {
 
  480     if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery(
"#price_ttc").val() != 
'') {
 
  481       jQuery(
"#price_ht").val(
'');
 
  482       jQuery(
"#multicurrency_subprice").val(
'');
 
  485   jQuery(
"#multicurrency_subprice").keyup(
function(event) {
 
  487     if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery(
"#price_ttc").val() != 
'') {
 
  488       jQuery(
"#price_ht").val(
'');
 
  489       jQuery(
"#price_ttc").val(
'');
 
  493   <?php 
if (in_array($this->table_element_line, array(
'propaldet', 
'commandedet', 
'facturedet'))) { ?>
 
  494   $(
"#date_start, #date_end").focusout(
function() {
 
  495     if ( $(
this).val() == 
''  && !$(
this).hasClass(
'inputmandatory') ) {
 
  496       $(
this).addClass(
'inputmandatory');
 
  498       $(
this).removeClass(
'inputmandatory');
 
  507     jQuery(
"#tva_tx").click(
function() {            
 
  508       jQuery(
"input[name='np_marginRate']:first").val(
'');
 
  509       jQuery(
"input[name='np_markRate']:first").val(
'');
 
  511     jQuery(
"#tva_tx").keyup(
function() {            
 
  512       jQuery(
"input[name='np_marginRate']:first").val(
'');
 
  513       jQuery(
"input[name='np_markRate']:first").val(
'');
 
  515     jQuery(
"#price_ht").keyup(
function() {
 
  516       jQuery(
"input[name='np_marginRate']:first").val(
'');
 
  517       jQuery(
"input[name='np_markRate']:first").val(
'');
 
  519     jQuery(
"#qty").keyup(
function() {
 
  520       jQuery(
"input[name='np_marginRate']:first").val(
'');
 
  521       jQuery(
"input[name='np_markRate']:first").val(
'');
 
  523     jQuery(
"#remise_percent").keyup(
function() {
 
  524       jQuery(
"input[name='np_marginRate']:first").val(
'');
 
  525       jQuery(
"input[name='np_markRate']:first").val(
'');
 
  527     jQuery(
"#buying_price").keyup(
function() {
 
  528       jQuery(
"input[name='np_marginRate']:first").val(
'');
 
  529       jQuery(
"input[name='np_markRate']:first").val(
'');
 
  533     var token = 
'<?php echo currentToken(); ?>';    
 
  534     $.post(
'<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {
'idprod': <?php echo $line->fk_product ? $line->fk_product : 0; ?>, 
'token': token }, 
function(data) {
 
  535       if (data && data.length > 0) {
 
  538       $(data).each(
function() {
 
  539         options += 
'<option value="'+this.
id+
'" price="'+this.price+
'"';
 
  540         <?php 
if ($line->fk_fournprice > 0) { ?>
 
  541         if (this.
id == <?php echo $line->fk_fournprice; ?>) {
 
  542           options += 
' selected';
 
  543           $(
"#buying_price").val(this.price);
 
  547         options += 
'>'+this.label+
'</option>';
 
  549       options += 
'<option value=null'+(trouve?
'':
' selected')+
'><?php echo $langs->trans("InputPrice"); ?></option>';
 
  550       $(
"#fournprice").html(options);
 
  552         $(
"#buying_price").hide();
 
  553         $(
"#fournprice").show();
 
  555         $(
"#buying_price").show();
 
  557       $(
"#fournprice").change(
function() {
 
  558         var selval = $(
this).find(
'option:selected').attr(
"price");
 
  560           $(
"#buying_price").val(selval).hide();
 
  562           $(
'#buying_price').show();
 
  565       $(
"#fournprice").hide();
 
  566       $(
'#buying_price').show();
 
  575 <!-- END PHP TEMPLATE objectline_edit.tpl.php -->
 
Class of dictionary type of thirdparty (used by imports)
Class to manage a WYSIWYG editor.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
price2numjs(amount)
Function similar to PHP price2num()
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.