dolibarr  19.0.0-dev
objectline_edit.tpl.php
1 <?php
2 /* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
3  * Copyright (C) 2010-2022 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 (isModEnabled('margin') && !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 (isModEnabled("multicurrency") && $object->multicurrency_code != $conf->currency) {
74  $colspan += 2;
75 }
76 if (isModEnabled('asset') && $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  $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  // but in some situations that is required (update legal informations for example)
149  if (!empty($conf->global->INVOICE_SITUATION_CAN_FORCE_UPDATE_DESCRIPTION)) {
150  $situationinvoicelinewithparent = 0;
151  }
152 
153  if (!$situationinvoicelinewithparent) {
154  // editor wysiwyg
155  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
156  $nbrows = ROWS_2;
157  if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
158  $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
159  }
160  $enable = (isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
161  $toolbarname = 'dolibarr_details';
162  if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) {
163  $toolbarname = 'dolibarr_notes';
164  }
165  $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%');
166  $doleditor->Create();
167  } else {
168  print '<textarea id="product_desc" class="flat" name="product_desc" readonly style="width: 200px; height:80px;">';
169  print GETPOSTISSET('product_desc') ? GETPOST('product_desc', 'restricthtml') : $line->description;
170  print '</textarea>';
171  }
172 
173  //Line extrafield
174  if (!empty($extrafields)) {
175  $temps = $line->showOptionals($extrafields, 'edit', array('class'=>'tredited'), '', '', 1, 'line');
176  if (!empty($temps)) {
177  print '<div style="padding-top: 10px" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
178  print $temps;
179  print '</div>';
180  }
181  }
182 
183  // Show autofill date for recuring invoices
184  if (isModEnabled("service") && $line->product_type == 1 && ($line->element == 'facturedetrec' || $line->element == 'invoice_supplier_det_rec')) {
185  if ($line->element == 'invoice_supplier_det_rec') {
186  $line->date_start_fill = $line->date_start;
187  $line->date_end_fill = $line->date_end;
188  }
189  echo '<br>';
190  echo $langs->trans('AutoFillDateFrom').' ';
191  echo $form->selectyesno('date_start_fill', GETPOSTISSET('date_start_fill') ? GETPOST('date_start_fill', 'int') : $line->date_start_fill, 1);
192  echo ' - ';
193  echo $langs->trans('AutoFillDateTo').' ';
194  echo $form->selectyesno('date_end_fill', GETPOSTISSET('date_end_fill') ? GETPOST('date_end_fill', 'int') : $line->date_end_fill, 1);
195  }
196 
197  ?>
198  </td>
199 
200  <?php
201  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
202  $coldisplay++;
203  ?>
204  <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>
205  <?php
206  print '<input type="hidden" id="fournprice" name="fournprice" class="" value="'.$line->fk_fournprice.'">';
207  }
208 
209  // VAT Rate
210  $coldisplay++;
211  if (!$situationinvoicelinewithparent) {
212  print '<td class="right">';
213  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);
214  print '</td>';
215  } else {
216  print '<td class="right"><input size="1" type="text" class="flat right" name="tva_tx" value="'.price($line->tva_tx).'" readonly />%</td>';
217  }
218 
219  $coldisplay++;
220  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))).'"';
221  if ($situationinvoicelinewithparent) {
222  print ' readonly';
223  }
224  print '></td>';
225 
226  if (isModEnabled("multicurrency") && $object->multicurrency_code != $conf->currency) {
227  $coldisplay++;
228  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>';
229  }
230 
231  if (!empty($inputalsopricewithtax) && !getDolGlobalInt('MAIN_NO_INPUT_PRICE_WITH_TAX')) {
232  $coldisplay++;
233  $upinctax = isset($line->pu_ttc) ? $line->pu_ttc : null;
234  if (getDolGlobalInt('MAIN_UNIT_PRICE_WITH_TAX_IS_FOR_ALL_TAXES')) {
235  $upinctax = price2num($line->total_ttc / $line->qty, 'MU');
236  }
237  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($upinctax) ? price($upinctax, 0, '', 0) : '')).'"';
238  if ($situationinvoicelinewithparent) {
239  print ' readonly';
240  }
241  print '></td>';
242  }
243  ?>
244  <td class="right">
245  <?php $coldisplay++;
246  if (($line->info_bits & 2) != 2) {
247  // I comment warning of stock because it shows the info even when it should not.
248  // 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
249  // must also not be output for most entities (proposal, intervention, ...)
250  //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." ";
251  print '<input size="3" type="text" class="flat right" name="qty" id="qty" value="'.(GETPOSTISSET('qty') ? GETPOST('qty') : $line->qty).'"';
252  if ($situationinvoicelinewithparent) { // Do not allow editing during a situation cycle
253  print ' readonly';
254  }
255  print '>';
256  } else { ?>
257  &nbsp;
258  <?php } ?>
259  </td>
260 
261  <?php
262  if (!empty($conf->global->PRODUCT_USE_UNITS)) {
263  $unit_type = false;
264  // limit unit select to unit type
265  if (!empty($line->fk_unit) && empty($conf->global->MAIN_EDIT_LINE_ALLOW_ALL_UNIT_TYPE)) {
266  include_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
267  $cUnit = new CUnits($line->db);
268  if ($cUnit->fetch($line->fk_unit) > 0) {
269  if (!empty($cUnit->unit_type)) {
270  $unit_type = $cUnit->unit_type;
271  }
272  }
273  }
274  $coldisplay++;
275  print '<td class="left">';
276  print $form->selectUnits(GETPOSTISSET('units') ? GETPOST('units') : $line->fk_unit, "units", 0, $unit_type);
277  print '</td>';
278  }
279  ?>
280 
281  <td class="nowraponall right linecoldiscount">
282  <?php
283  // Discount
284  $coldisplay++;
285  if (($line->info_bits & 2) != 2) {
286  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 : '')).'"';
287  if ($situationinvoicelinewithparent) {
288  print ' readonly';
289  }
290  print '><span class="hideonsmartphone opacitymedium">%</span>';
291  } else { ?>
292  &nbsp;
293  <?php } ?>
294  </td>
295 
296  <?php
297  // Progession for situation invoices
298  if ($object->situation_cycle_ref) {
299  $coldisplay++;
300  print '<td class="nowrap right linecolcycleref"><input class="right" type="text" size="1" value="'.(GETPOSTISSET('progress') ? GETPOST('progress') : $line->situation_percent).'" name="progress">%</td>';
301  $coldisplay++;
302  print '<td></td>';
303  }
304 
305  if (!empty($usemargins)) {
306  if (!empty($user->rights->margins->creer)) {
307  $coldisplay++;
308  ?>
309  <td class="margininfos right">
310  <!-- For predef product -->
311  <?php if (isModEnabled("product") || isModEnabled("service")) { ?>
312  <select id="fournprice_predef" name="fournprice_predef" class="flat minwidth75imp right" style="display: none;"></select>
313  <?php } ?>
314  <!-- For free product -->
315  <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)); ?>">
316  </td>
317  <?php }
318 
319  if ($user->rights->margins->creer) {
320  if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
321  $margin_rate = (GETPOSTISSET("np_marginRate") ? GETPOST("np_marginRate", "alpha", 2) : (($line->pa_ht == 0) ? '' : price($line->marge_tx)));
322  // if credit note, dont allow to modify margin
323  if ($line->subprice < 0) {
324  echo '<td class="right nowrap margininfos">'.$margin_rate.'<span class="opacitymedium hideonsmartphone">%</span></td>';
325  } else {
326  echo '<td class="right nowrap margininfos"><input class="right maxwidth40" type="text" name="np_marginRate" value="'.$margin_rate.'"><span class="opacitymedium hideonsmartphone">%</span></td>';
327  }
328  $coldisplay++;
329  }
330  if (!empty($conf->global->DISPLAY_MARK_RATES)) {
331  $mark_rate = (GETPOSTISSET("np_markRate") ? GETPOST("np_markRate", 'alpha', 2) : price($line->marque_tx));
332  // if credit note, dont allow to modify margin
333  if ($line->subprice < 0) {
334  echo '<td class="right nowrap margininfos">'.$mark_rate.'<span class="opacitymedium hideonsmartphone">%</span></td>';
335  } else {
336  echo '<td class="right nowrap margininfos"><input class="right maxwidth40" type="text" name="np_markRate" value="'.$mark_rate.'"><span class="opacitymedium hideonsmartphone">%</span></td>';
337  }
338  $coldisplay++;
339  }
340  }
341  }
342  ?>
343 
344  <!-- colspan for this td because it replace total_ht+3 td for buttons+... -->
345  <td class="center valignmiddle" colspan="<?php echo $colspan; ?>"><?php $coldisplay += $colspan; ?>
346  <input type="submit" class="reposition button buttongen marginbottomonly button-save" id="savelinebutton marginbottomonly" name="save" value="<?php echo $langs->trans("Save"); ?>"><br>
347  <input type="submit" class="reposition button buttongen marginbottomonly button-cancel" id="cancellinebutton" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>">
348  </td>
349 </tr>
350 
351 <?php if (isModEnabled("service") && $line->product_type == 1 && $dateSelector) { ?>
352 <tr id="service_duration_area" class="treditedlinefordate">
353  <?php if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
354  <td class="linecolnum center"></td>
355  <?php } ?>
356  <td colspan="<?php echo $coldisplay - (empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? 0 : 1) ?>"><?php echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?>
357  <?php
358  $hourmin = (isset($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : '');
359  print $form->selectDate($line->date_start, 'date_start', $hourmin, $hourmin, $line->date_start ? 0 : 1, "updateline", 1, 0);
360  print ' '.$langs->trans('to').' ';
361  print $form->selectDate($line->date_end, 'date_end', $hourmin, $hourmin, $line->date_end ? 0 : 1, "updateline", 1, 0);
362  print '<script>';
363  if (!$line->date_start) {
364  if (isset($conf->global->MAIN_DEFAULT_DATE_START_HOUR)) {
365  print 'jQuery("#date_starthour").val("'.$conf->global->MAIN_DEFAULT_DATE_START_HOUR.'");';
366  }
367 
368 
369  if (isset($conf->global->MAIN_DEFAULT_DATE_START_MIN)) {
370  print 'jQuery("#date_startmin").val("'.$conf->global->MAIN_DEFAULT_DATE_START_MIN.'");';
371  }
372 
373  $res = $line->fetch_product();
374  if ($res > 0 ) {
375  if ( $line->product->isMandatoryPeriod() && $line->product->isService()) {
376  print 'jQuery("#date_start").addClass("error");';
377  }
378  }
379  }
380  if (!$line->date_end) {
381  if (isset($conf->global->MAIN_DEFAULT_DATE_END_HOUR)) {
382  print 'jQuery("#date_endhour").val("'.$conf->global->MAIN_DEFAULT_DATE_END_HOUR.'");';
383  }
384  if (isset($conf->global->MAIN_DEFAULT_DATE_END_MIN)) {
385  print 'jQuery("#date_endmin").val("'.$conf->global->MAIN_DEFAULT_DATE_END_MIN.'");';
386  }
387 
388  $res = $line->fetch_product();
389  // on doit fetch le product là !!! pour connaître le type
390  if ($res > 0 ) {
391  if ($line->product->isMandatoryperiod() && $line->product->isService()) {
392  print 'jQuery("#date_end").addClass("error");';
393  }
394  }
395  }
396  print '</script>'
397  ?>
398  </td>
399 </tr>
400 <?php }
401 ?>
402 
403 
404 <script>
405 
406 <?php
407 if (!empty($usemargins) && $user->rights->margins->creer) {
408  ?>
409  /* Some js test when we click on button "Add" */
410  jQuery(document).ready(function() {
411  <?php
412  if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
413  ?>
414  $("input[name='np_marginRate']:first").blur(function(e) {
415  return checkFreeLine(e, "np_marginRate");
416  });
417  <?php
418  }
419  if (!empty($conf->global->DISPLAY_MARK_RATES)) {
420  ?>
421  $("input[name='np_markRate']:first").blur(function(e) {
422  return checkFreeLine(e, "np_markRate");
423  });
424  <?php
425  }
426  ?>
427  });
428 
429  /* TODO This does not work for number with thousand separator that is , */
430  function checkFreeLine(e, npRate)
431  {
432  var buying_price = $("input[name='buying_price']:first");
433  var remise = $("input[name='remise_percent']:first");
434 
435  var rate = $("input[name='"+npRate+"']:first");
436  if (rate.val() == '')
437  return true;
438 
439  var ratejs = price2numjs(rate.val());
440  if (! $.isNumeric(ratejs))
441  {
442  alert('<?php echo dol_escape_js($langs->transnoentities("rateMustBeNumeric")); ?>');
443  e.stopPropagation();
444  setTimeout(function () { rate.focus() }, 50);
445  return false;
446  }
447  if (npRate == "np_markRate" && rate.val() >= 100)
448  {
449  alert('<?php echo dol_escape_js($langs->transnoentities("markRateShouldBeLesserThan100")); ?>');
450  e.stopPropagation();
451  setTimeout(function () { rate.focus() }, 50);
452  return false;
453  }
454 
455  var price = 0;
456  remisejs = price2numjs(remise.val());
457 
458  if (remisejs != 100) { // If a discount not 100 or no discount
459  if (remisejs == '') {
460  remisejs = 0;
461  }
462 
463  bpjs=price2numjs(buying_price.val());
464  ratejs=price2numjs(rate.val());
465 
466  if (npRate == "np_marginRate")
467  price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
468  else if (npRate == "np_markRate")
469  price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
470  }
471  $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value
472 
473  return true;
474  }
475  <?php
476 }
477 ?>
478 
479 jQuery(document).ready(function()
480 {
481  jQuery("#price_ht").keyup(function(event) {
482  // console.log(event.which); // discard event tag and arrows
483  if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') {
484  jQuery("#price_ttc").val('');
485  jQuery("#multicurrency_subprice").val('');
486  }
487  });
488  jQuery("#price_ttc").keyup(function(event) {
489  // console.log(event.which); // discard event tag and arrows
490  if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') {
491  jQuery("#price_ht").val('');
492  jQuery("#multicurrency_subprice").val('');
493  }
494  });
495  jQuery("#multicurrency_subprice").keyup(function(event) {
496  // console.log(event.which); // discard event tag and arrows
497  if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') {
498  jQuery("#price_ht").val('');
499  jQuery("#price_ttc").val('');
500  }
501  });
502 
503  <?php if (in_array($object->table_element_line, array('propaldet', 'commandedet', 'facturedet'))) { ?>
504  $("#date_start, #date_end").focusout(function() {
505  if ( $(this).val() == '' && !$(this).hasClass('inputmandatory') ) {
506  $(this).addClass('inputmandatory');
507  } else {
508  $(this).removeClass('inputmandatory');
509  }
510  });
511  <?php
512  }
513 
514  if (isModEnabled('margin')) {
515  ?>
516  /* 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 */
517  jQuery("#tva_tx").click(function() { /* somtimes field is a text, sometimes a combo */
518  jQuery("input[name='np_marginRate']:first").val('');
519  jQuery("input[name='np_markRate']:first").val('');
520  });
521  jQuery("#tva_tx").keyup(function() { /* somtimes field is a text, sometimes a combo */
522  jQuery("input[name='np_marginRate']:first").val('');
523  jQuery("input[name='np_markRate']:first").val('');
524  });
525  jQuery("#price_ht").keyup(function() {
526  jQuery("input[name='np_marginRate']:first").val('');
527  jQuery("input[name='np_markRate']:first").val('');
528  });
529  jQuery("#qty").keyup(function() {
530  jQuery("input[name='np_marginRate']:first").val('');
531  jQuery("input[name='np_markRate']:first").val('');
532  });
533  jQuery("#remise_percent").keyup(function() {
534  jQuery("input[name='np_marginRate']:first").val('');
535  jQuery("input[name='np_markRate']:first").val('');
536  });
537  jQuery("#buying_price").keyup(function() {
538  jQuery("input[name='np_marginRate']:first").val('');
539  jQuery("input[name='np_markRate']:first").val('');
540  });
541 
542  /* Init field buying_price and fournprice */
543  var token = '<?php echo currentToken(); ?>'; // For AJAX Call we use old 'token' and not 'newtoken'
544  $.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': <?php echo $line->fk_product ? $line->fk_product : 0; ?>, 'token': token }, function(data) {
545  if (data && data.length > 0) {
546  var options = '';
547  var trouve=false;
548  $(data).each(function() {
549  options += '<option value="'+this.id+'" price="'+this.price+'"';
550  <?php if ($line->fk_fournprice > 0) { ?>
551  if (this.id == <?php echo $line->fk_fournprice; ?>) {
552  options += ' selected';
553  $("#buying_price").val(this.price);
554  trouve = true;
555  }
556  <?php } ?>
557  options += '>'+this.label+'</option>';
558  });
559  options += '<option value=null'+(trouve?'':' selected')+'><?php echo $langs->trans("InputPrice"); ?></option>';
560  $("#fournprice").html(options);
561  if (trouve) {
562  $("#buying_price").hide();
563  $("#fournprice").show();
564  } else {
565  $("#buying_price").show();
566  }
567  $("#fournprice").change(function() {
568  var selval = $(this).find('option:selected').attr("price");
569  if (selval)
570  $("#buying_price").val(selval).hide();
571  else
572  $('#buying_price').show();
573  });
574  } else {
575  $("#fournprice").hide();
576  $('#buying_price').show();
577  }
578  }, 'json');
579  <?php
580  }
581  ?>
582 });
583 
584 </script>
585 <!-- 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.
Definition: card.php:143
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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
Definition: repair.php:120
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:123