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