39 if (empty($object) || !is_object($object)) {
40 print
"Error: this template page cannot be called directly as an URL";
44 if (
isModEnabled(
'margin') && !empty($object->element) && in_array($object->element, array(
'facture',
'facturerec',
'propal',
'commande'))) {
47 if (!isset($dateSelector)) {
50 global $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax;
52 if (!isset($dateSelector)) {
54 } elseif (empty($dateSelector)) {
57 if (empty($forceall)) {
60 if (empty($senderissupplier)) {
61 $senderissupplier = 0;
63 if (empty($inputalsopricewithtax)) {
64 $inputalsopricewithtax = 0;
68 if (
isModEnabled(
"multicurrency") && $this->multicurrency_code != $conf->currency) {
71 if (in_array($object->element, array(
'propal',
'commande',
'order',
'facture',
'facturerec',
'invoice',
'supplier_proposal',
'order_supplier',
'invoice_supplier',
'invoice_supplier_rec'))) {
74 if (
isModEnabled(
'asset') && $object->element ==
'invoice_supplier') {
81 if (!empty($extrafields)) {
82 if ($this->table_element_line ==
'commandedet') {
84 } elseif ($this->table_element_line ==
'propaldet') {
86 } elseif ($this->table_element_line ==
'supplier_proposaldet') {
88 } elseif ($this->table_element_line ==
'facturedet') {
90 } elseif ($this->table_element_line ==
'contratdet') {
92 } elseif ($this->table_element_line ==
'commande_fournisseurdet') {
94 } elseif ($this->table_element_line ==
'facture_fourn_det') {
96 } elseif ($this->table_element_line ==
'facturedet_rec') {
98 } elseif ($this->table_element_line ==
'facture_fourn_det_rec') {
102 print
"<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->\n";
103 $nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines);
104 if ($nolinesbefore) {
106 <tr
class=
"liste_titre<?php echo (($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_add_') ?> nodrag nodrop">
107 <?php
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
108 <td
class=
"linecolnum center"></td>
110 <td
class=
"linecoldescription minwidth400imp">
111 <div
id=
"add"></div><span
class=
"hideonsmartphone"><?php echo $langs->trans(
'AddNewLine'); ?></span>
114 if ($object->element ==
'supplier_proposal' || $object->element ==
'order_supplier' || $object->element ==
'invoice_supplier' || $object->element ==
'invoice_supplier_rec') {
116 <td
class=
"linecolrefsupplier"><span
id=
"title_fourn_ref"><?php echo $langs->trans(
'SupplierRef'); ?></span></td>
120 <td
class=
"linecolvat right"><span
id=
"title_vat"><?php echo $langs->trans(
'VAT'); ?></span></td>
121 <td
class=
"linecoluht right"><span
id=
"title_up_ht"><?php echo $langs->trans(
'PriceUHT'); ?></span></td>
122 <?php
if (
isModEnabled(
"multicurrency") && $this->multicurrency_code != $conf->currency) { ?>
123 <td
class=
"linecoluht_currency right"><span
id=
"title_up_ht_currency"><?php echo $langs->trans(
'PriceUHTCurrency'); ?></span></td>
125 <?php
if (!empty($inputalsopricewithtax)) { ?>
126 <td
class=
"linecoluttc right"><span
id=
"title_up_ttc"><?php echo $langs->trans(
'PriceUTTC'); ?></span></td>
128 <td
class=
"linecolqty right"><?php echo $langs->trans(
'Qty'); ?></td>
131 print
'<td class="linecoluseunit left">';
132 print
'<span id="title_units">';
133 print $langs->trans(
'Unit');
134 print
'</span></td>';
137 <td
class=
"linecoldiscount right"><?php echo $langs->trans(
'ReductionShort'); ?></td>
140 if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) {
141 print
'<td class="linecolcycleref right">'.$langs->trans(
'Progress').
'</td>';
142 print
'<td class="linecolcycleref2 right"></td>';
144 if (!empty($usemargins)) {
145 if (empty($user->rights->margins->creer)) {
148 print
'<td class="margininfos linecolmargin1 right">';
149 if ($conf->global->MARGIN_TYPE ==
"1") {
150 echo $langs->trans(
'BuyingPrice');
152 echo $langs->trans(
'CostPrice');
155 if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
156 echo
'<td class="margininfos linecolmargin2 right"><span class="np_marginRate">'.$langs->trans(
'MarginRate').
'</span></td>';
158 if (!empty($conf->global->DISPLAY_MARK_RATES)) {
159 echo
'<td class="margininfos linecolmargin2 right"><span class="np_markRate">'.$langs->trans(
'MarkRate').
'</span></td>';
164 <td
class=
"linecoledit" colspan=
"<?php echo $colspan; ?>"> </td>
169 <tr
class=
"pair nodrag nodrop nohoverpair<?php echo ($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_create'; ?>">
173 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
175 echo
'<td class="nobottom linecolnum center"></td>';
179 <td
class=
"nobottom linecoldescription minwidth400imp">
182 if (empty($conf->global->MAIN_DISABLE_FREE_LINES)) {
185 if ($object->element ==
'contrat') {
188 } elseif (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) {
193 echo
'<span class="prod_entry_mode_free">';
196 echo
'<label for="prod_entry_mode_free">';
197 echo
'<input type="radio" class="prod_entry_mode_free" name="prod_entry_mode" id="prod_entry_mode_free" value="free"';
199 echo ((
GETPOST(
'prod_entry_mode',
'alpha') ==
'free' || !empty($conf->global->MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT)) ?
' checked' :
'');
202 echo
'<span class="textradioforitem">'.$langs->trans(
"FreeLineOfType").
'</span>';
206 echo
'<input type="hidden" id="prod_entry_mode_free" name="prod_entry_mode" value="free">';
208 if ($forceall >= 0) {
210 echo $langs->trans(
"Type");
212 echo $langs->trans(
"FreeLineOfType");
222 if ($forceall >= 0 && $freelines) {
223 echo
'<br><span class="prod_entry_mode_predef paddingtop">';
225 echo
'<span class="prod_entry_mode_predef">';
227 echo
'<label for="prod_entry_mode_predef">';
228 echo
'<input type="radio" class="prod_entry_mode_predef" name="prod_entry_mode" id="prod_entry_mode_predef" value="predef"'.(GETPOST(
'prod_entry_mode') ==
'predef' ?
' checked' :
'').
'> ';
230 if (empty($conf->dol_optimize_smallscreen)) {
231 if (empty($senderissupplier)) {
233 $labelforradio = $langs->trans(
'PredefinedProductsToSell');
234 } elseif ((!
isModEnabled(
'product') &&
isModEnabled(
'service')) || ($object->element ==
'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS))) {
235 $labelforradio = $langs->trans(
'PredefinedServicesToSell');
237 $labelforradio = $langs->trans(
'PredefinedProductsAndServicesToSell');
241 $labelforradio = $langs->trans(
'PredefinedProductsToPurchase');
243 $labelforradio = $langs->trans(
'PredefinedServicesToPurchase');
245 $labelforradio = $langs->trans(
'PredefinedProductsAndServicesToPurchase');
249 $labelforradio = $langs->trans(
'PredefinedItem');
251 print
'<span class="textradioforitem">'.$labelforradio.
'</span>';
255 if (!empty($object->element) && $object->element ==
'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) {
258 if (empty($senderissupplier)) {
260 $statuswarehouse =
'warehouseopen,warehouseinternal';
261 if (!empty($conf->global->ENTREPOT_WAREHOUSEINTERNAL_NOT_SELL)) $statuswarehouse =
'warehouseopen';
262 if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) {
264 $form->select_produits(
GETPOST(
'idprod'),
'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2,
'', 1, array(), $buyer->id,
'1', 0,
'maxwidth500', 0, $statuswarehouse,
GETPOST(
'combinations',
'array'));
266 $form->select_produits(
GETPOST(
'idprod'),
'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2,
'', 1, array(), $buyer->id,
'1', 0,
'maxwidth500', 0,
'',
GETPOST(
'combinations',
'array'));
268 if (!empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) {
271 $(document).ready(
function(){
273 $(document).on(
'focus',
'.select2-selection.select2-selection--single',
function (e) {
274 console.log(
'focus on a select2');
275 if ($(
this).attr(
'aria-labelledby') ==
'select2-idprod-container')
277 console.log(
'open combo');
278 $(
'#idprod').select2(
'open');
287 if ($senderissupplier != 2) {
288 $ajaxoptions = array(
289 'update' => array(
'qty'=>
'qty',
'remise_percent' =>
'discount',
'idprod' =>
'idprod'),
290 'option_disabled' =>
'idthatdoesnotexists',
291 'warning' => $langs->trans(
"NoPriceDefinedForThisSupplier")
293 $alsoproductwithnosupplierprice = 0;
295 $ajaxoptions = array(
300 $alsoproductwithnosupplierprice = 1;
302 $form->select_produits_fournisseurs($object->socid,
GETPOST(
'idprodfournprice'),
'idprodfournprice',
'',
'', $ajaxoptions, 1, $alsoproductwithnosupplierprice,
'minwidth300imp maxwidth500');
303 if (!empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS)) {
306 $(document).ready(
function(){
308 $(document).on(
'focus',
'.select2-selection.select2-selection--single',
function (e) {
310 if ($(
this).attr(
'aria-labelledby') ==
'select2-idprodfournprice-container')
312 $(
'#idprodfournprice').select2(
'open');
320 echo
'<input type="hidden" name="pbq" id="pbq" value="">';
324 if (!empty($conf->global->MAIN_ADD_LINE_AT_POSITION)) {
325 echo
'<br>'.$langs->trans(
'AddLineOnPosition').
' : <input type="number" name="rank" step="1" min="0" style="width: 5em;">';
328 if (is_object($hookmanager) && empty($senderissupplier)) {
329 $parameters = array(
'fk_parent_line'=>
GETPOST(
'fk_parent_line',
'int'));
330 $reshook = $hookmanager->executeHooks(
'formCreateProductOptions', $parameters, $object, $action);
331 if (!empty($hookmanager->resPrint)) {
332 print $hookmanager->resPrint;
335 if (is_object($hookmanager) && !empty($senderissupplier)) {
336 $parameters = array(
'htmlname'=>
'addproduct');
337 $reshook = $hookmanager->executeHooks(
'formCreateProductSupplierOptions', $parameters, $object, $action);
338 if (!empty($hookmanager->resPrint)) {
339 print $hookmanager->resPrint;
345 echo
'<div id="attributes_box"></div>';
349 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
351 $enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
352 if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
353 $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
355 $toolbarname =
'dolibarr_details';
356 if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) {
357 $toolbarname =
'dolibarr_notes';
359 $doleditor =
new DolEditor(
'dp_desc',
GETPOST(
'dp_desc',
'restricthtml'),
'', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT) ? 100 : $conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname,
'',
false,
true, $enabled, $nbrows,
'98%');
360 $doleditor->Create();
362 if (
isModEnabled(
"service") && ($object->element ==
'facturerec' || $object->element ==
'invoice_supplier_rec')) {
363 echo
'<div class="divlinefordates"><br>';
364 echo $langs->trans(
'AutoFillDateFrom').
' ';
365 if (!empty($conf->global->INVOICE_REC_DATE_TO_YES)) {
366 $line->date_start_fill = 1;
367 $line->date_end_fill = 1;
369 echo
$form->selectyesno(
'date_start_fill', $line->date_start_fill, 1);
371 echo $langs->trans(
'AutoFillDateTo').
' ';
372 echo
$form->selectyesno(
'date_end_fill', $line->date_end_fill, 1);
375 if (is_object($objectline)) {
376 $temps = $objectline->showOptionals($extrafields,
'create', array(),
'',
'', 1,
'line');
378 if (!empty($temps)) {
379 print
'<div style="padding-top: 10px" id="extrafield_lines_area_create" name="extrafield_lines_area_create">';
385 if ($object->element ==
'supplier_proposal' || $object->element ==
'order_supplier' || $object->element ==
'invoice_supplier' || $object->element ==
'invoice_supplier_rec') {
388 <td
class=
"nobottom linecolrefsupplier"><input
id=
"fourn_ref" name=
"fourn_ref" class=
"flat minwidth50 maxwidth100 maxwidth125onsmartphone" value=
"<?php echo (GETPOSTISSET("fourn_ref
") ? GETPOST("fourn_ref
", 'alpha', 2) : ''); ?>"></td>
390 print
'<td class="nobottom linecolvat right">';
392 if ($seller->tva_assuj ==
"0") {
393 echo
'<input type="hidden" name="tva_tx" id="tva_tx" value="0">'.vatrate(0,
true);
395 echo
$form->load_tva(
'tva_tx', (
GETPOSTISSET(
"tva_tx") ?
GETPOST(
"tva_tx",
'alpha', 2) : -1), $seller, $buyer, 0, 0,
'',
false, 1);
400 <td
class=
"nobottom linecoluht right"><?php $coldisplay++; ?>
401 <input
type=
"text" size=
"5" name=
"price_ht" id=
"price_ht" class=
"flat right" value=
"<?php echo (GETPOSTISSET("price_ht
") ? GETPOST("price_ht
", 'alpha', 2) : ''); ?>">
405 if (
isModEnabled(
"multicurrency") && $this->multicurrency_code != $conf->currency) {
408 <td
class=
"nobottom linecoluht_currency right">
409 <input
type=
"text" size=
"5" name=
"multicurrency_price_ht" id=
"multicurrency_price_ht" class=
"flat right" value=
"<?php echo (GETPOSTISSET("multicurrency_price_ht
") ? GETPOST("multicurrency_price_ht
", 'alpha', 2) : ''); ?>">
413 if (!empty($inputalsopricewithtax)) {
416 <td
class=
"nobottom linecoluttc right">
417 <input
type=
"text" size=
"5" name=
"price_ttc" id=
"price_ttc" class=
"flat right" value=
"<?php echo (GETPOSTISSET("price_ttc
") ? GETPOST("price_ttc
", 'alpha', 2) : ''); ?>">
423 <td
class=
"nobottom linecolqty right">
424 <input
type=
"text" name=
"qty" id=
"qty" class=
"flat width40 right" value=
"<?php echo (GETPOSTISSET("qty
") ? GETPOST("qty
", 'alpha', 2) : 1); ?>">
429 print
'<td class="nobottom linecoluseunit left">';
430 print
$form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit,
"units");
433 $remise_percent = $buyer->remise_percent;
434 if ($object->element ==
'supplier_proposal' || $object->element ==
'order_supplier' || $object->element ==
'invoice_supplier') {
435 $remise_percent = $seller->remise_supplier_percent;
440 <td
class=
"nobottom nowrap linecoldiscount right"><input
type=
"text" name=
"remise_percent" id=
"remise_percent" class=
"flat width40 right" value=
"<?php echo (GETPOSTISSET("remise_percent
") ? GETPOST("remise_percent
", 'alpha', 2) : ($remise_percent ? $remise_percent : '')); ?>"><span
class=
"opacitymedium hideonsmartphone">%</span></td>
442 if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) {
444 print
'<td class="nobottom nowrap right"><input class="falt right" type="text" size="1" value="" name="progress"><span class="opacitymedium hideonsmartphone">%</span></td>';
448 if (!empty($usemargins)) {
449 if (!empty($user->rights->margins->creer)) {
452 <td
class=
"nobottom margininfos linecolmargin right">
453 <!-- For predef product -->
455 <select
id=
"fournprice_predef" name=
"fournprice_predef" class=
"flat minwidth75imp maxwidth150" style=
"display: none;"></select>
457 <!-- For free product -->
458 <input
type=
"text" id=
"buying_price" name=
"buying_price" class=
"flat maxwidth75 right" value=
"<?php echo (GETPOSTISSET("buying_price
") ? GETPOST("buying_price
", 'alpha', 2) : ''); ?>">
461 if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
462 echo
'<td class="nobottom nowraponall margininfos right"><input class="flat right width40" type="text" id="np_marginRate" name="np_marginRate" value="'.(GETPOSTISSET(
"np_marginRate") ?
GETPOST(
"np_marginRate",
'alpha', 2) :
'').
'"><span class="np_marginRate opacitymedium hideonsmartphone">%</span></td>';
465 if (!empty($conf->global->DISPLAY_MARK_RATES)) {
466 echo
'<td class="nobottom nowraponall margininfos right"><input class="flat right width40" type="text" id="np_markRate" name="np_markRate" value="'.(GETPOSTISSET(
"np_markRate") ?
GETPOST(
"np_markRate",
'alpha', 2) :
'').
'"><span class="np_markRate opacitymedium hideonsmartphone">%</span></td>';
471 $coldisplay += $colspan;
473 <td
class=
"nobottom linecoledit center valignmiddle" colspan=
"<?php echo $colspan; ?>">
474 <input
type=
"submit" class=
"button reposition" value=
"<?php echo $langs->trans('Add'); ?>" name=
"addline" id=
"addline">
479 if ((
isModEnabled(
"service") || ($object->element ==
'contrat')) && $dateSelector &&
GETPOST(
'type') !=
'0') {
480 print
'<tr id="trlinefordates" class="oddeven">'.
"\n";
481 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
484 print
'<td colspan="'.($coldisplay - (empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? 0 : 1)).
'">';
488 $prefillDates =
false;
490 if (!empty($conf->global->MAIN_FILL_SERVICE_DATES_FROM_LAST_SERVICE_LINE) && !empty($object->lines)) {
491 for ($i = count($object->lines) - 1; $i >= 0; $i--) {
492 $lastline = $object->lines[$i];
494 if ($lastline->product_type ==
Product::TYPE_SERVICE && (!empty($lastline->date_start) || !empty($lastline->date_end))) {
495 $date_start_prefill = $lastline->date_start;
496 $date_end_prefill = $lastline->date_end;
498 $prefillDates =
true;
504 if (!empty($object->element) && $object->element ==
'contrat') {
505 print $langs->trans(
"DateStartPlanned").
' ';
506 print
$form->selectDate($date_start,
"date_start", $usehm, $usehm, 1,
"addproduct");
507 print
' '.$langs->trans(
"DateEndPlanned").
' ';
508 print
$form->selectDate($date_end,
"date_end", $usehm, $usehm, 1,
"addproduct");
510 print $langs->trans(
'ServiceLimitedDuration').
' '.$langs->trans(
'From').
' ';
511 print
$form->selectDate($date_start,
'date_start', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1,
"addproduct", 1, 0);
512 print
' '.$langs->trans(
'to').
' ';
513 print
$form->selectDate($date_end,
'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1,
"addproduct", 1, 0);
517 echo
' <span class="small"><a href="#" id="prefill_service_dates">'.$langs->trans(
'FillWithLastServiceDates').
'</a></span>';
524 function prefill_service_dates()
526 $(
'#date_start').val(
"<?php echo dol_escape_js(dol_print_date($date_start_prefill, 'day')); ?>").trigger(
'change');
527 $(
'#date_end').val(
"<?php echo dol_escape_js(dol_print_date($date_end_prefill, 'day')); ?>").trigger(
'change');
532 $(document).ready(
function()
534 $(
'#prefill_service_dates').click(prefill_service_dates);
541 if (isset($conf->global->MAIN_DEFAULT_DATE_START_HOUR)) {
542 print
'jQuery("#date_starthour").val("'.$conf->global->MAIN_DEFAULT_DATE_START_HOUR.
'");';
544 if (isset($conf->global->MAIN_DEFAULT_DATE_START_MIN)) {
545 print
'jQuery("#date_startmin").val("'.$conf->global->MAIN_DEFAULT_DATE_START_MIN.
'");';
549 if (isset($conf->global->MAIN_DEFAULT_DATE_END_HOUR)) {
550 print
'jQuery("#date_endhour").val("'.$conf->global->MAIN_DEFAULT_DATE_END_HOUR.
'");';
552 if (isset($conf->global->MAIN_DEFAULT_DATE_END_MIN)) {
553 print
'jQuery("#date_endmin").val("'.$conf->global->MAIN_DEFAULT_DATE_END_MIN.
'");';
563 if (!empty($usemargins) && $user->rights->margins->creer) {
566 jQuery(document).ready(
function() {
568 if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
569 $(
"input[name='np_marginRate']:first").blur(function(e) {
570 return checkFreeLine(e,
"np_marginRate");
574 if (!empty($conf->global->DISPLAY_MARK_RATES)) { ?>
575 $(
"input[name='np_markRate']:first").blur(
function(e) {
576 return checkFreeLine(e,
"np_markRate");
584 function checkFreeLine(e, npRate)
586 var buying_price = $(
"input[name='buying_price']:first");
587 var remise = $(
"input[name='remise_percent']:first");
589 var rate = $(
"input[name='"+npRate+
"']:first");
590 if (rate.val() ==
'')
593 if (! $.isNumeric(rate.val().replace(
',',
'.')))
595 alert(
'<?php echo dol_escape_js($langs->trans("rateMustBeNumeric")); ?>');
597 setTimeout(
function () { rate.focus() }, 50);
600 if (npRate ==
"np_markRate" && rate.val() >= 100)
602 alert(
'<?php echo dol_escape_js($langs->trans("markRateShouldBeLesserThan100")); ?>');
604 setTimeout(
function () { rate.focus() }, 50);
613 if (remisejs ==
'') remisejs=0;
618 if (npRate ==
"np_marginRate")
619 price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
620 else if (npRate ==
"np_markRate")
621 price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
624 $(
"input[name='price_ht']:first").val(
price);
634 jQuery(document).ready(
function() {
635 jQuery(
"#price_ht").keyup(
function(event) {
637 if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery(
"#price_ht").val() !=
'') {
638 jQuery(
"#price_ttc").val(
'');
639 jQuery(
"#multicurrency_subprice").val(
'');
642 jQuery(
"#price_ttc").keyup(
function(event) {
644 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery(
"#price_ttc").val() !=
'') {
645 jQuery(
"#price_ht").val(
'');
646 jQuery(
"#multicurrency_subprice").val(
'');
649 jQuery(
"#multicurrency_subprice").keyup(
function(event) {
651 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery(
"#price_ttc").val() !=
'') {
652 jQuery(
"#price_ht").val(
'');
653 jQuery(
"#price_ttc").val(
'');
657 $(
"#prod_entry_mode_free").on(
"click",
function() {
660 $(
"#select_type").change(
function()
664 if (jQuery(
'#select_type').val() >= 0) {
665 console.log(
"Set focus on description field");
667 jQuery(
'#dp_desc').focus();
669 if (typeof CKEDITOR ==
"object" && typeof CKEDITOR.instances !=
"undefined") {
670 var editor = CKEDITOR.instances[
'dp_desc'];
677 console.log(
"Hide/show date according to product type");
678 if (jQuery(
'#select_type').val() ==
'0')
680 jQuery(
'#trlinefordates').hide();
681 jQuery(
'.divlinefordates').hide();
685 jQuery(
'#trlinefordates').show();
686 jQuery(
'.divlinefordates').show();
690 $(
"#prod_entry_mode_predef").on(
"click",
function() {
691 console.log(
"click prod_entry_mode_predef");
693 jQuery(
'#trlinefordates').show();
697 if (!$freelines) { ?>
698 $(
"#prod_entry_mode_predef").click();
702 if (in_array($this->table_element_line, array(
'propaldet',
'commandedet',
'facturedet'))) { ?>
703 $(
"#date_start, #date_end").focusout(
function() {
704 let
type = $(
this).attr(
'type');
705 let mandatoryP = $(
this).attr(
'mandatoryperiod');
706 if (
type == 1 && mandatoryP == 1) {
707 if ($(
this).val() ==
'' && !$(
this).hasClass(
'inputmandatory')) {
708 $(
this).addClass(
'inputmandatory');
710 $(
this).removeClass(
'inputmandatory');
717 $(
"#idprod, #idprodfournprice").change(
function()
719 console.log(
"objectline_create.tpl Call method change() after change on #idprod or #idprodfournprice (senderissupplier=<?php echo $senderissupplier; ?>). this.val = "+$(
this).val());
723 jQuery(
'#trlinefordates').show();
726 if (empty($conf->global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT) && empty($senderissupplier)) {
728 var pbq = parseInt($(
'option:selected',
this).attr(
'data-pbq'));
729 if (isNaN(pbq)) { pbq = jQuery(
'#idprod').attr(
'data-pbq'); }
731 if ((jQuery(
'#idprod').val() > 0 || jQuery(
'#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0)
733 console.log(
"objectline_create.tpl We are in a price per qty context, we do not call ajax/product, init of fields is done few lines later");
735 <?php
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { ?>
736 if (isNaN(pbq)) { console.log(
"We use experimental option PRODUIT_CUSTOMER_PRICES_BY_QTY or PRODUIT_CUSTOMER_PRICES_BY_QTY but we could not get the id of pbq from product combo list, so load of price may be 0 if product has differet prices"); }
739 console.log(
"Load unit price without tax and set it into #price_ht for product id="+$(
this).val()+
" socid=<?php print $object->socid; ?>");
740 $.post(
'<?php echo DOL_URL_ROOT; ?>/product/ajax/products.php?action=fetch',
741 {
'id': $(
this).val(),
'socid': <?php print $object->socid; ?>,
'token':
'<?php print currentToken(); ?>' },
743 console.log(
"objectline_create.tpl Load unit price end, we got value ht="+data.price_ht+
" ttc="+data.price_ttc+
" pricebasetype="+data.pricebasetype);
745 $(
'#date_start').removeAttr(
'type');
746 $(
'#date_end').removeAttr(
'type');
747 $(
'#date_start').attr(
'type', data.type);
748 $(
'#date_end').attr(
'type', data.type);
750 $(
'#date_start').removeAttr(
'mandatoryperiod');
751 $(
'#date_end').removeAttr(
'mandatoryperiod');
752 $(
'#date_start').attr(
'mandatoryperiod', data.mandatory_period);
753 $(
'#date_end').attr(
'mandatoryperiod', data.mandatory_period);
756 if (data.mandatory_period == 1 && data.type == 1) {
757 jQuery(
'#date_start').addClass(
'inputmandatory');
758 jQuery(
'#date_end').addClass(
'inputmandatory');
760 jQuery(
'#date_start').removeClass(
'inputmandatory');
761 jQuery(
'#date_end').removeClass(
'inputmandatory');
764 if (<?php echo (
int) $inputalsopricewithtax; ?> == 1 && data.pricebasetype ==
'TTC') {
765 console.log(
"objectline_create.tpl set content of price_ttc");
766 jQuery(
"#price_ttc").val(data.price_ttc);
768 console.log(
"objectline_create.tpl set content of price_ht");
769 jQuery(
"#price_ht").val(data.price_ht);
772 var tva_tx = data.tva_tx;
773 var default_vat_code = data.default_vat_code;
776 var stringforvatrateselection = tva_tx;
777 if (typeof default_vat_code !=
'undefined' && default_vat_code !=
null && default_vat_code !=
'') {
778 stringforvatrateselection = stringforvatrateselection+
' ('+default_vat_code+
')';
781 $(
'#tva_tx').val(tva_tx);
784 $(
'#tva_tx option').removeAttr(
'selected');
785 console.log(
"stringforvatrateselection="+stringforvatrateselection+
" -> value of option label for this key="+$(
'#tva_tx option[value="'+stringforvatrateselection+
'"]').val());
786 $(
'#tva_tx option[value="'+stringforvatrateselection+
'"]').prop(
'selected',
true);
789 if (!empty($conf->global->PRODUIT_AUTOFILL_DESC) && $conf->global->PRODUIT_AUTOFILL_DESC == 1) {
790 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { ?>
791 var proddesc = data.desc_trans;
794 var proddesc = data.desc;
797 console.log(
"objectline_create.tpl Load desciption into text area : "+proddesc);
799 if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?>
800 if (typeof CKEDITOR ==
"object" && typeof CKEDITOR.instances !=
"undefined")
802 var editor = CKEDITOR.instances[
'dp_desc'];
804 editor.setData(proddesc);
809 jQuery(
'#dp_desc').text(proddesc);
815 if (!empty($conf->global->PRODUCT_LOAD_EXTRAFIELD_INTO_OBJECTLINES)) { ?>
816 jQuery.each(data.array_options,
function( key, value ) {
817 jQuery(
'div[class*="det'+key.replace(
'options_',
'_extras_')+
'"] > #'+key).val(value);
828 if (!empty($usemargins) && $user->rights->margins->creer) {
829 $langs->load(
'stocks');
833 $(
"#fournprice_predef").find(
"option").remove();
834 $(
"#fournprice_predef").hide();
835 $(
"#buying_price").val(
"").show();
838 var token =
'<?php echo currentToken(); ?>';
839 $.post(
'<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php?bestpricefirst=1', {
'idprod': $(
this).val(),
'token': token },
function(data) {
840 if (data && data.length > 0)
842 var options =
''; var defaultkey =
''; var defaultprice =
''; var bestpricefound = 0;
844 var bestpriceid = 0; var bestpricevalue = 0;
845 var pmppriceid = 0; var pmppricevalue = 0;
846 var costpriceid = 0; var costpricevalue = 0;
849 var defaultbuyprice =
'<?php
850 if (isset($conf->global->MARGIN_TYPE)) {
851 if ($conf->global->MARGIN_TYPE == '1
') {
852 print 'bestsupplierprice
';
854 if ($conf->global->MARGIN_TYPE == 'pmp
') {
857 if ($conf->global->MARGIN_TYPE == 'costprice
') {
861 console.log(
"objectline_create.tpl we will set the field for margin. defaultbuyprice="+defaultbuyprice);
864 $(data).each(
function() {
866 if (this.
id !=
'pmpprice' && this.
id !=
'costprice')
869 this.price = parseFloat(this.price);
872 if (bestpricefound == 0 && this.price > 0) { defaultkey = this.id; defaultprice = this.
price; bestpriceid = this.id; bestpricevalue = this.
price; bestpricefound=1; }
874 if (this.
id ==
'pmpprice')
877 console.log(
"id="+this.
id+
"-price="+this.price);
878 if (
'pmp' == defaultbuyprice ||
'costprice' == defaultbuyprice)
880 if (this.price > 0) {
881 defaultkey = this.id; defaultprice = this.
price; pmppriceid = this.id; pmppricevalue = this.
price;
886 if (this.
id ==
'costprice')
889 console.log(
"id="+this.
id+
"-price="+this.price+
"-pmppricevalue="+pmppricevalue);
890 if (
'costprice' == defaultbuyprice)
892 if (this.price > 0) { defaultkey = this.id; defaultprice = this.
price; costpriceid = this.id; costpricevalue = this.
price; }
893 else if (pmppricevalue > 0) { defaultkey =
'pmpprice'; defaultprice = pmppricevalue; }
896 options +=
'<option value="'+this.
id+
'" price="'+this.price+
'">'+this.label+
'</option>';
898 options +=
'<option value="inputprice" price="'+defaultprice+
'"><?php echo $langs->trans("InputPrice").'...
'; ?></option>';
900 console.log(
"finally selected defaultkey="+defaultkey+
" defaultprice for buying price="+defaultprice);
902 $(
"#fournprice_predef").html(options).show();
903 if (defaultkey !=
'')
905 $(
"#fournprice_predef").val(defaultkey);
909 $(
"#buying_price").hide();
912 var defaultprice = $(
"#fournprice_predef").find(
'option:selected').attr(
"price");
913 $(
"#buying_price").val(defaultprice);
915 $(
"#fournprice_predef").change(
function() {
916 console.log(
"change on fournprice_predef");
918 var linevalue=$(
this).find(
'option:selected').val();
919 var pricevalue = $(
this).find(
'option:selected').attr(
"price");
920 if (linevalue !=
'inputprice' && linevalue !=
'pmpprice') {
921 $(
"#buying_price").val(pricevalue).hide();
923 if (linevalue ==
'inputprice') {
924 $(
'#buying_price').show();
926 if (linevalue ==
'pmpprice') {
927 $(
"#buying_price").val(pricevalue);
928 $(
'#buying_price').hide();
940 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
943 var pbq = parseInt($(
'option:selected',
this).attr(
'data-pbq'));
944 if (isNaN(pbq)) { pbq = jQuery(
'#idprod').attr(
'data-pbq'); }
945 var pbqup = parseFloat($(
'option:selected',
this).attr(
'data-pbqup'));
946 if (isNaN(pbqup)) { pbqup = jQuery(
'#idprod').attr(
'data-pbqup'); }
947 var pbqbase = $(
'option:selected',
this).attr(
'data-pbqbase');
948 if (isNaN(pbqbase)) { pbqbase = jQuery(
'#idprod').attr(
'data-pbqbase'); }
949 var pbqqty = parseFloat($(
'option:selected',
this).attr(
'data-pbqqty'));
950 if (isNaN(pbqqty)) { pbqqty = jQuery(
'#idprod').attr(
'data-pbqqty'); }
951 var pbqpercent = parseFloat($(
'option:selected',
this).attr(
'data-pbqpercent'));
952 if (isNaN(pbqpercent)) { pbqpercent = jQuery(
'#idprod').attr(
'data-pbqpercent'); }
954 if ((jQuery(
'#idprod').val() > 0) && ! isNaN(pbq) && pbq > 0)
958 console.log(
"We choose a price by quanty price_by_qty id = "+pbq+
" price_by_qty upht = "+pbqupht+
" price_by_qty qty = "+pbqqty+
" price_by_qty percent = "+pbqpercent);
959 jQuery(
"#pbq").val(pbq);
960 jQuery(
"#price_ht").val(pbqupht);
961 if (jQuery(
"#qty").val() < pbqqty)
963 jQuery(
"#qty").val(pbqqty);
965 if (jQuery(
"#remise_percent").val() < pbqpercent)
967 jQuery(
"#remise_percent").val(pbqpercent);
969 }
else { jQuery(
"#pbq").val(
''); }
976 if (jQuery(
'#idprodfournprice').val() > 0)
978 console.log(
"objectline_create.tpl #idprodfournprice is is an ID > 0, so we set some properties into page");
980 var up = parseFloat($(
'option:selected',
this).attr(
'data-up'));
981 if (isNaN(up)) { up = parseFloat(jQuery(
'#idprodfournprice').attr(
'data-up'));}
983 var up_locale = $(
'option:selected',
this).attr(
'data-up-locale');
984 if (typeof up_locale ===
'undefined') { up_locale = jQuery(
'#idprodfournprice').attr(
'data-up-locale');}
986 var qty = parseFloat($(
'option:selected',
this).attr(
'data-qty'));
987 if (isNaN(qty)) { qty = parseFloat(jQuery(
'#idprodfournprice').attr(
'data-qty'));}
989 var discount = parseFloat($(
'option:selected',
this).attr(
'data-discount'));
990 if (isNaN(discount)) { discount = parseFloat(jQuery(
'#idprodfournprice').attr(
'data-discount'));}
992 var tva_tx = parseFloat($(
'option:selected',
this).attr(
'data-tvatx'));
993 if (isNaN(tva_tx)) { tva_tx = parseFloat(jQuery(
'#idprodfournprice').attr(
'data-tvatx'));}
995 var default_vat_code = $(
'option:selected',
this).attr(
'data-default-vat-code');
996 if (typeof default_vat_code ===
'undefined') { default_vat_code = jQuery(
'#idprodfournprice').attr(
'data-default-vat-code');}
998 var stringforvatrateselection = tva_tx;
999 if (typeof default_vat_code !=
'undefined' && default_vat_code !=
null && default_vat_code !=
'') {
1000 stringforvatrateselection = stringforvatrateselection+
' ('+default_vat_code+
')';
1003 console.log(
"objectline_create.tpl We find supplier price : up = "+up+
", up_locale = "+up_locale+
", qty = "+qty+
", tva_tx = "+tva_tx+
", default_vat_code = "+default_vat_code+
", stringforvatrateselection="+stringforvatrateselection+
", discount = "+discount+
" for product supplier ref id = "+jQuery(
'#idprodfournprice').val());
1005 if (typeof up_locale ===
'undefined') {
1006 jQuery(
"#price_ht").val(up);
1008 jQuery(
"#price_ht").val(up_locale);
1012 $(
'#tva_tx').val(tva_tx);
1015 $(
'#tva_tx option').removeAttr(
'selected');
1016 console.log(
"stringforvatrateselection="+stringforvatrateselection+
" -> value of option label for this key="+$(
'#tva_tx option[value="'+stringforvatrateselection+
'"]').val());
1017 $(
'#tva_tx option[value="'+stringforvatrateselection+
'"]').prop(
'selected',
true);
1019 if (jQuery(
"#qty").val() < qty) {
1020 jQuery(
"#qty").val(qty);
1022 if (jQuery(
"#remise_percent").val() < discount) {
1023 jQuery(
"#remise_percent").val(discount);
1029 var
description = $(
'option:selected',
this).attr(
'data-description');
1030 if (typeof
description ==
'undefined') {
description = jQuery(
'#idprodfournprice').attr(
'data-description'); }
1032 console.log(
"Load desciption into text area : "+
description);
1034 if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) {
1036 if (typeof CKEDITOR ==
"object" && typeof CKEDITOR.instances !=
"undefined")
1038 var editor = CKEDITOR.instances[
'dp_desc'];
1051 }
else if (jQuery(
'#idprodfournprice').length > 0) {
1052 console.log(
"objectline_create.tpl #idprodfournprice is not an int but is a string so we set only few properties into page");
1054 var tva_tx = parseFloat($(
'option:selected',
this).attr(
'data-tvatx'));
1055 if (isNaN(tva_tx)) { tva_tx = parseFloat(jQuery(
'#idprodfournprice').attr(
'data-tvatx'));}
1057 var default_vat_code = $(
'option:selected',
this).attr(
'data-default-vat-code');
1058 if (typeof default_vat_code ===
'undefined') { default_vat_code = jQuery(
'#idprodfournprice').attr(
'data-default-vat-code');}
1060 var stringforvatrateselection = tva_tx;
1061 if (typeof default_vat_code !=
'undefined' && default_vat_code !=
null && default_vat_code !=
'') {
1062 stringforvatrateselection = stringforvatrateselection+
' ('+default_vat_code+
')';
1065 console.log(
"objectline_create.tpl We find data for price : tva_tx = "+tva_tx+
", default_vat_code = "+default_vat_code+
", stringforvatrateselection="+stringforvatrateselection+
" for product id = "+jQuery(
'#idprodfournprice').val());
1068 $(
'#tva_tx').val(tva_tx);
1071 $(
'#tva_tx option').removeAttr(
'selected');
1072 console.log(
"stringforvatrateselection="+stringforvatrateselection+
" -> value of option label for this key="+$(
'#tva_tx option[value="'+stringforvatrateselection+
'"]').val());
1073 $(
'#tva_tx option[value="'+stringforvatrateselection+
'"]').prop(
'selected',
true);
1077 if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) {
1079 if (typeof CKEDITOR ==
"object" && typeof CKEDITOR.instances !=
"undefined")
1081 var editor = CKEDITOR.instances[
'dp_desc'];
1089 jQuery(
'#dp_desc').text(
'');
1098 if (jQuery(
'#idprod').val() > 0 || jQuery(
'#idprodfournprice').val() > 0)
1101 jQuery(
'#dp_desc').focus();
1103 if (typeof CKEDITOR ==
"object" && typeof CKEDITOR.instances !=
"undefined")
1105 var editor = CKEDITOR.instances[
'dp_desc'];
1106 if (editor) { editor.focus(); }
1111 <?php
if (
GETPOST(
'prod_entry_mode') ==
'predef') {
1117 function setforfree() {
1118 console.log(
"objectline_create.tpl::setforfree. We show most fields");
1119 jQuery(
"#idprodfournprice").val(
'0');
1120 jQuery(
"#prod_entry_mode_free").prop(
'checked',
true).change();
1121 jQuery(
"#prod_entry_mode_predef").prop(
'checked',
false).change();
1122 jQuery(
"#search_idprod, #idprod, #search_idprodfournprice, #buying_price").val(
'');
1123 jQuery(
"#price_ht, #multicurrency_price_ht, #price_ttc, #multicurrency_price_ttc, #fourn_ref, #tva_tx, #buying_price, #title_fourn_ref, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").show();
1124 jQuery(
"#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show();
1125 jQuery(
"#fournprice_predef").hide();
1128 function setforpredef() {
1129 console.log(
"objectline_create.tpl::setforpredef We hide some fields, show dates");
1130 jQuery(
"#select_type").val(-1);
1131 jQuery(
"#prod_entry_mode_free").prop(
'checked',
false).change();
1132 jQuery(
"#prod_entry_mode_predef").prop(
'checked',
true).change();
1133 <?php
if (empty($conf->global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT)) { ?>
1134 jQuery(
"#price_ht").val(
'').show();
1135 jQuery(
"#multicurrency_price_ht").val(
'').show();
1136 jQuery(
"#title_up_ht, #title_up_ht_currency").show();
1139 jQuery(
"#multicurrency_price_ht").val(
'').hide();
1140 jQuery(
"#title_up_ht, #title_up_ht_currency").hide();
1142 <?php
if (empty($conf->global->MAIN_DISABLE_EDIT_PREDEF_PRICETTC)) { ?>
1143 jQuery(
"#price_ttc").val(
'').show();
1144 jQuery(
"#multicurrency_price_ttc").val(
'').show();
1145 jQuery(
"#title_up_ttc, #title_up_ttc_currency").show();
1147 jQuery(
"#price_ttc").val(
'').hide();
1148 jQuery(
"#multicurrency_price_ttc").val(
'').hide();
1149 jQuery(
"#title_up_ttc, #title_up_ttc_currency").hide();
1151 jQuery(
"#tva_tx, #title_vat").hide();
1153 jQuery(
"#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide();
1154 jQuery(
"#buying_price").show();
1155 jQuery(
'#trlinefordates, .divlinefordates').show();
1162 print
"<!-- END PHP TEMPLATE objectline_create.tpl.php -->\n";
Class to manage line orders.
Class to manage lines of contracts.
Class to manage a WYSIWYG editor.
Class to manage supplier invoice lines of templates.
Class to manage invoice lines.
Class to manage invoice lines of templates.
Class to manage order lines.
const TYPE_SERVICE
Service.
Class to manage commercial proposal lines.
Class to manage line invoices.
Class to manage supplier_proposal lines.
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.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
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.
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.
$conf db
API class for accounts.