dolibarr  16.0.5
objectline_edit.tpl.php
1 <?php
2 /* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
3  * Copyright (C) 2010-2020 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
5  * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
6  * Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
7  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
8  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
9  * Copyright (C) 2022 OpenDSI <support@open-dsi.fr>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <https://www.gnu.org/licenses/>.
23  *
24  * Need to have following variables defined:
25  * $object (invoice, order, ...)
26  * $conf
27  * $langs
28  * $seller, $buyer
29  * $dateSelector
30  * $forceall (0 by default, 1 for supplier invoices/orders)
31  * $senderissupplier (0 by default, 1 for supplier invoices/orders)
32  * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
33  * $canchangeproduct (0 by default, 1 to allow to change the product if it is a predefined product)
34  */
35 
36 // Protection to avoid direct call of template
37 if (empty($object) || !is_object($object)) {
38  print "Error, template page can't be called as URL";
39  exit;
40 }
41 
42 
43 $usemargins = 0;
44 if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande'))) {
45  $usemargins = 1;
46 }
47 
48 global $forceall, $senderissupplier, $inputalsopricewithtax, $canchangeproduct;
49 if (empty($dateSelector)) {
50  $dateSelector = 0;
51 }
52 if (empty($forceall)) {
53  $forceall = 0;
54 }
55 if (empty($senderissupplier)) {
56  $senderissupplier = 0;
57 }
58 if (empty($inputalsopricewithtax)) {
59  $inputalsopricewithtax = 0;
60 }
61 if (empty($canchangeproduct)) {
62  $canchangeproduct = 0;
63 }
64 
65 // Define colspan for the button 'Add'
66 $colspan = 3; // Col total ht + col edit + col delete
67 if (!empty($inputalsopricewithtax)) {
68  $colspan++; // We add 1 if col total ttc
69 }
70 if (in_array($object->element, array('propal', 'supplier_proposal', 'facture', 'facturerec', 'invoice', 'commande', 'order', 'order_supplier', 'invoice_supplier', 'invoice_supplier_rec'))) {
71  $colspan++; // With this, there is a column move button
72 }
73 if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) {
74  $colspan += 2;
75 }
76 if (!empty($conf->asset->enabled) && $object->element == 'invoice_supplier') {
77  $colspan++;
78 }
79 
80 
81 
82 print "<!-- BEGIN PHP TEMPLATE objectline_edit.tpl.php -->\n";
83 
84 $coldisplay = 0;
85 ?>
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>
89 <?php }
90 
91 $coldisplay++;
92 ?>
93  <td class="linecoldesc minwidth250onall">
94  <div id="line_<?php echo $line->id; ?>"></div>
95 
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; ?>">
100 
101  <?php if ($line->fk_product > 0) { ?>
102  <?php
103  if (empty($canchangeproduct)) {
104  if ($line->fk_parent_line > 0) {
105  echo img_picto('', 'rightarrow');
106  }
107  ?>
108  <a href="<?php echo DOL_URL_ROOT.'/product/card.php?id='.$line->fk_product; ?>">
109  <?php
110  if ($line->product_type == 1) {
111  echo img_object($langs->trans('ShowService'), 'service');
112  } else {
113  print img_object($langs->trans('ShowProduct'), 'product');
114  }
115  echo ' '.$line->ref;
116  ?>
117  </a>
118  <?php
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).'">';
121  } else {
122  if ($senderissupplier) {
123  print $form->select_produits_fournisseurs(!empty($line->fk_product) ? $line->fk_product : 0, 'productid');
124  } else {
125  print $form->select_produits(!empty($line->fk_product) ? $line->fk_product : 0, 'productid');
126  }
127  }
128  ?>
129  <br><br>
130  <?php } ?>
131 
132  <?php
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);
137  }
138 
139  $situationinvoicelinewithparent = 0;
140  if ($line->fk_prev_id != null && in_array($object->element, array('facture', 'facturedet'))) {
141  if ($object->type == $object::TYPE_SITUATION) { // The constant TYPE_SITUATION exists only for object invoice
142  // Set constant to disallow editing during a situation cycle
143  $situationinvoicelinewithparent = 1;
144  }
145  }
146 
147  // Do not allow editing during a situation cycle
148  if (!$situationinvoicelinewithparent) {
149  // editor wysiwyg
150  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
151  $nbrows = ROWS_2;
152  if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
153  $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
154  }
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';
159  }
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();
162  } else {
163  print '<textarea id="product_desc" class="flat" name="product_desc" readonly style="width: 200px; height:80px;">';
164  print GETPOSTISSET('product_desc') ? GETPOST('product_desc', 'restricthtml') : $line->description;
165  print '</textarea>';
166  }
167 
168  //Line extrafield
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">';
173  print $temps;
174  print '</div>';
175  }
176  }
177 
178  // Show autofill date for recuring invoices
179  if (!empty($conf->service->enabled) && $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;
183  }
184  echo '<br>';
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);
187  echo ' - ';
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);
190  }
191 
192  ?>
193  </td>
194 
195  <?php
196  if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier' || $object->element == 'invoice_supplier_rec') { // We must have same test in printObjectLines
197  $coldisplay++;
198  ?>
199  <td class="right linecolrefsupplier"><input id="fourn_ref" name="fourn_ref" class="flat minwidth50 maxwidth125 maxwidth125onsmartphone" value="<?php echo GETPOSTISSET('fourn_ref') ? GETPOST('fourn_ref') : ($line->ref_supplier ? $line->ref_supplier : $line->ref_fourn); ?>"></td>
200  <?php
201  }
202 
203  $coldisplay++;
204  if (!$situationinvoicelinewithparent) {
205  print '<td class="right">'.$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).'</td>';
206  } else {
207  print '<td class="right"><input size="1" type="text" class="flat right" name="tva_tx" value="'.price($line->tva_tx).'" readonly />%</td>';
208  }
209 
210  $coldisplay++;
211  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))).'"';
212  if ($situationinvoicelinewithparent) {
213  print ' readonly';
214  }
215  print '></td>';
216 
217  if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) {
218  $coldisplay++;
219  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>';
220  }
221 
222  if ($inputalsopricewithtax) {
223  $coldisplay++;
224  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) : '')).'"';
225  if ($line->fk_prev_id != null) {
226  print ' readonly';
227  }
228  print '></td>';
229  }
230  ?>
231  <td class="right">
232  <?php $coldisplay++;
233  if (($line->info_bits & 2) != 2) {
234  // I comment warning of stock because it shows the info even when it should not.
235  // 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
236  // must also not be output for most entities (proposal, intervention, ...)
237  //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." ";
238  print '<input size="3" type="text" class="flat right" name="qty" id="qty" value="'.(GETPOSTISSET('qty') ? GETPOST('qty') : $line->qty).'"';
239  if ($situationinvoicelinewithparent) { // Do not allow editing during a situation cycle
240  print ' readonly';
241  }
242  print '>';
243  } else { ?>
244  &nbsp;
245  <?php } ?>
246  </td>
247 
248  <?php
249  if (!empty($conf->global->PRODUCT_USE_UNITS)) {
250  $unit_type = false;
251  // limit unit select to unit type
252  if (!empty($line->fk_unit) && empty($conf->global->MAIN_EDIT_LINE_ALLOW_ALL_UNIT_TYPE)) {
253  include_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
254  $cUnit = new CUnits($line->db);
255  if ($cUnit->fetch($line->fk_unit) > 0) {
256  if (!empty($cUnit->unit_type)) {
257  $unit_type = $cUnit->unit_type;
258  }
259  }
260  }
261  $coldisplay++;
262  print '<td class="left">';
263  print $form->selectUnits(GETPOSTISSET('units') ? GETPOST('units') : $line->fk_unit, "units", 0, $unit_type);
264  print '</td>';
265  }
266  ?>
267 
268  <td class="nowraponall right linecoldiscount">
269  <?php $coldisplay++;
270  if (($line->info_bits & 2) != 2) {
271  print '<input size="1" type="text" class="flat right" name="remise_percent" id="remise_percent" value="'.(GETPOSTISSET('remise_percent') ? GETPOST('remise_percent') : $line->remise_percent).'"';
272  if ($situationinvoicelinewithparent) {
273  print ' readonly';
274  }
275  print '>%';
276  } else { ?>
277  &nbsp;
278  <?php } ?>
279  </td>
280  <?php
281  if ($this->situation_cycle_ref) {
282  $coldisplay++;
283  print '<td class="nowrap right linecolcycleref"><input class="right" type="text" size="1" value="'.(GETPOSTISSET('progress') ? GETPOST('progress') : $line->situation_percent).'" name="progress">%</td>';
284  $coldisplay++;
285  print '<td></td>';
286  }
287  if (!empty($usemargins)) {
288  if (!empty($user->rights->margins->creer)) {
289  $coldisplay++;
290  ?>
291  <td class="margininfos right">
292  <!-- For predef product -->
293  <?php if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { ?>
294  <select id="fournprice_predef" name="fournprice_predef" class="flat minwidth75imp right" style="display: none;"></select>
295  <?php } ?>
296  <!-- For free product -->
297  <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)); ?>">
298  </td>
299  <?php }
300 
301  if ($user->rights->margins->creer) {
302  if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
303  $margin_rate = (GETPOSTISSET("np_marginRate") ? GETPOST("np_marginRate", "alpha", 2) : (($line->pa_ht == 0) ? '' : price($line->marge_tx)));
304  // if credit note, dont allow to modify margin
305  if ($line->subprice < 0) {
306  echo '<td class="right nowrap margininfos">'.$margin_rate.'<span class="hideonsmartphone">%</span></td>';
307  } else {
308  echo '<td class="right nowrap margininfos"><input class="right maxwidth75" type="text" name="np_marginRate" value="'.$margin_rate.'"><span class="hideonsmartphone">%</span></td>';
309  }
310  $coldisplay++;
311  }
312  if (!empty($conf->global->DISPLAY_MARK_RATES)) {
313  $mark_rate = (GETPOSTISSET("np_markRate") ? GETPOST("np_markRate", 'alpha', 2) : price($line->marque_tx));
314  // if credit note, dont allow to modify margin
315  if ($line->subprice < 0) {
316  echo '<td class="right nowrap margininfos">'.$mark_rate.'<span class="hideonsmartphone">%</span></td>';
317  } else {
318  echo '<td class="right nowrap margininfos"><input class="right maxwidth75" type="text" name="np_markRate" value="'.$mark_rate.'"><span class="hideonsmartphone">%</span></td>';
319  }
320  $coldisplay++;
321  }
322  }
323  }
324  ?>
325 
326  <!-- colspan for this td because it replace total_ht+3 td for buttons+... -->
327  <td class="center valignmiddle" colspan="<?php echo $colspan; ?>"><?php $coldisplay += $colspan; ?>
328  <input type="submit" class="button buttongen marginbottomonly button-save" id="savelinebutton marginbottomonly" name="save" value="<?php echo $langs->trans("Save"); ?>"><br>
329  <input type="submit" class="button buttongen marginbottomonly button-cancel" id="cancellinebutton" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>">
330  </td>
331 </tr>
332 
333 <?php if (!empty($conf->service->enabled) && $line->product_type == 1 && $dateSelector) { ?>
334 <tr id="service_duration_area" class="treditedlinefordate">
335  <?php if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
336  <td class="linecolnum center"></td>
337  <?php } ?>
338  <td colspan="<?php echo $coldisplay - (empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? 0 : 1) ?>"><?php echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?>
339  <?php
340  $hourmin = (isset($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : '');
341  print $form->selectDate($line->date_start, 'date_start', $hourmin, $hourmin, $line->date_start ? 0 : 1, "updateline", 1, 0);
342  print ' '.$langs->trans('to').' ';
343  print $form->selectDate($line->date_end, 'date_end', $hourmin, $hourmin, $line->date_end ? 0 : 1, "updateline", 1, 0);
344  print '<script>';
345  if (!$line->date_start) {
346  if (isset($conf->global->MAIN_DEFAULT_DATE_START_HOUR)) {
347  print 'jQuery("#date_starthour").val("'.$conf->global->MAIN_DEFAULT_DATE_START_HOUR.'");';
348  }
349 
350 
351  if (isset($conf->global->MAIN_DEFAULT_DATE_START_MIN)) {
352  print 'jQuery("#date_startmin").val("'.$conf->global->MAIN_DEFAULT_DATE_START_MIN.'");';
353  }
354 
355  $res = $line->fetch_product();
356  if ($res > 0 ) {
357  if ( $line->product->isMandatoryPeriod() && $line->product->isService()) {
358  print 'jQuery("#date_start").addClass("error");';
359  }
360  }
361  }
362  if (!$line->date_end) {
363  if (isset($conf->global->MAIN_DEFAULT_DATE_END_HOUR)) {
364  print 'jQuery("#date_endhour").val("'.$conf->global->MAIN_DEFAULT_DATE_END_HOUR.'");';
365  }
366  if (isset($conf->global->MAIN_DEFAULT_DATE_END_MIN)) {
367  print 'jQuery("#date_endmin").val("'.$conf->global->MAIN_DEFAULT_DATE_END_MIN.'");';
368  }
369 
370  $res = $line->fetch_product();
371  // on doit fetch le product là !!! pour connaître le type
372  if ($res > 0 ) {
373  if ($line->product->isMandatoryperiod() && $line->product->isService()) {
374  print 'jQuery("#date_end").addClass("error");';
375  }
376  }
377  }
378  print '</script>'
379  ?>
380  </td>
381 </tr>
382 <?php }
383 ?>
384 
385 
386 <script>
387 
388 <?php
389 if (!empty($usemargins) && $user->rights->margins->creer) {
390  ?>
391  /* Some js test when we click on button "Add" */
392  jQuery(document).ready(function() {
393  <?php
394  if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
395  ?>
396  $("input[name='np_marginRate']:first").blur(function(e) {
397  return checkFreeLine(e, "np_marginRate");
398  });
399  <?php
400  }
401  if (!empty($conf->global->DISPLAY_MARK_RATES)) {
402  ?>
403  $("input[name='np_markRate']:first").blur(function(e) {
404  return checkFreeLine(e, "np_markRate");
405  });
406  <?php
407  }
408  ?>
409  });
410 
411  /* TODO This does not work for number with thousand separator that is , */
412  function checkFreeLine(e, npRate)
413  {
414  var buying_price = $("input[name='buying_price']:first");
415  var remise = $("input[name='remise_percent']:first");
416 
417  var rate = $("input[name='"+npRate+"']:first");
418  if (rate.val() == '')
419  return true;
420 
421  var ratejs = price2numjs(rate.val());
422  if (! $.isNumeric(ratejs))
423  {
424  alert('<?php echo dol_escape_js($langs->transnoentities("rateMustBeNumeric")); ?>');
425  e.stopPropagation();
426  setTimeout(function () { rate.focus() }, 50);
427  return false;
428  }
429  if (npRate == "np_markRate" && rate.val() >= 100)
430  {
431  alert('<?php echo dol_escape_js($langs->transnoentities("markRateShouldBeLesserThan100")); ?>');
432  e.stopPropagation();
433  setTimeout(function () { rate.focus() }, 50);
434  return false;
435  }
436 
437  var price = 0;
438  remisejs=price2numjs(remise.val());
439 
440  if (remisejs != 100) // If a discount not 100 or no discount
441  {
442  if (remisejs == '') remisejs=0;
443 
444  bpjs=price2numjs(buying_price.val());
445  ratejs=price2numjs(rate.val());
446 
447  if (npRate == "np_marginRate")
448  price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
449  else if (npRate == "np_markRate")
450  price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
451  }
452  $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value
453 
454  return true;
455  }
456  <?php
457 }
458 ?>
459 
460 jQuery(document).ready(function()
461 {
462  jQuery("#price_ht").keyup(function(event) {
463  // console.log(event.which); // discard event tag and arrows
464  if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') {
465  jQuery("#price_ttc").val('');
466  jQuery("#multicurrency_subprice").val('');
467  }
468  });
469  jQuery("#price_ttc").keyup(function(event) {
470  // console.log(event.which); // discard event tag and arrows
471  if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') {
472  jQuery("#price_ht").val('');
473  jQuery("#multicurrency_subprice").val('');
474  }
475  });
476  jQuery("#multicurrency_subprice").keyup(function(event) {
477  // console.log(event.which); // discard event tag and arrows
478  if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') {
479  jQuery("#price_ht").val('');
480  jQuery("#price_ttc").val('');
481  }
482  });
483 
484  <?php if (in_array($this->table_element_line, array('propaldet', 'commandedet', 'facturedet'))) { ?>
485  $("#date_start, #date_end").focusout(function() {
486  if ( $(this).val() == '' && !$(this).hasClass('inputmandatory') ) {
487  $(this).addClass('inputmandatory');
488  } else {
489  $(this).removeClass('inputmandatory');
490  }
491  });
492  <?php
493  }
494 
495  if (!empty($conf->margin->enabled)) {
496  ?>
497  /* 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 */
498  jQuery("#tva_tx").click(function() { /* somtimes field is a text, sometimes a combo */
499  jQuery("input[name='np_marginRate']:first").val('');
500  jQuery("input[name='np_markRate']:first").val('');
501  });
502  jQuery("#tva_tx").keyup(function() { /* somtimes field is a text, sometimes a combo */
503  jQuery("input[name='np_marginRate']:first").val('');
504  jQuery("input[name='np_markRate']:first").val('');
505  });
506  jQuery("#price_ht").keyup(function() {
507  jQuery("input[name='np_marginRate']:first").val('');
508  jQuery("input[name='np_markRate']:first").val('');
509  });
510  jQuery("#qty").keyup(function() {
511  jQuery("input[name='np_marginRate']:first").val('');
512  jQuery("input[name='np_markRate']:first").val('');
513  });
514  jQuery("#remise_percent").keyup(function() {
515  jQuery("input[name='np_marginRate']:first").val('');
516  jQuery("input[name='np_markRate']:first").val('');
517  });
518  jQuery("#buying_price").keyup(function() {
519  jQuery("input[name='np_marginRate']:first").val('');
520  jQuery("input[name='np_markRate']:first").val('');
521  });
522 
523  /* Init field buying_price and fournprice */
524  var token = '<?php echo currentToken(); ?>'; // For AJAX Call we use old 'token' and not 'newtoken'
525  $.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': <?php echo $line->fk_product ? $line->fk_product : 0; ?>, 'token': token }, function(data) {
526  if (data && data.length > 0) {
527  var options = '';
528  var trouve=false;
529  $(data).each(function() {
530  options += '<option value="'+this.id+'" price="'+this.price+'"';
531  <?php if ($line->fk_fournprice > 0) { ?>
532  if (this.id == <?php echo $line->fk_fournprice; ?>) {
533  options += ' selected';
534  $("#buying_price").val(this.price);
535  trouve = true;
536  }
537  <?php } ?>
538  options += '>'+this.label+'</option>';
539  });
540  options += '<option value=null'+(trouve?'':' selected')+'><?php echo $langs->trans("InputPrice"); ?></option>';
541  $("#fournprice").html(options);
542  if (trouve) {
543  $("#buying_price").hide();
544  $("#fournprice").show();
545  } else {
546  $("#buying_price").show();
547  }
548  $("#fournprice").change(function() {
549  var selval = $(this).find('option:selected').attr("price");
550  if (selval)
551  $("#buying_price").val(selval).hide();
552  else
553  $('#buying_price').show();
554  });
555  } else {
556  $("#fournprice").hide();
557  $('#buying_price').show();
558  }
559  }, 'json');
560  <?php
561  }
562  ?>
563 });
564 
565 </script>
566 <!-- END PHP TEMPLATE objectline_edit.tpl.php -->
description
print *****$script_file(".$version.") pid cd cd cd description as description
Definition: email_expire_services_to_customers.php:83
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
name
$conf db name
Definition: repair.php:122
price2numjs
price2numjs(amount)
Function similar to PHP price2num()
Definition: lib_head.js.php:1222
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
CUnits
Class of dictionary type of thirdparty (used by imports)
Definition: cunits.class.php:28
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4211
price
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.
Definition: functions.lib.php:5541
type
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119
DolEditor
Class to manage a WYSIWYG editor.
Definition: doleditor.class.php:30