49 print
"Error: this template page cannot be called directly as an URL";
53'@phan-var-force CommonObject $this
54 @phan-var-force CommonObject $object';
57if (isModEnabled(
'margin') && !empty(
$object->element) && in_array(
$object->element, array(
'facture',
'facturerec',
'propal',
'commande'))) {
60if (!isset($dateSelector)) {
63global $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax;
66if (!isset($dateSelector)) {
68} elseif (empty($dateSelector)) {
71if (empty($forceall)) {
74if (empty($senderissupplier)) {
75 $senderissupplier = 0;
77if (empty($inputalsopricewithtax)) {
78 $inputalsopricewithtax = 0;
82if (isModEnabled(
"multicurrency") && $this->multicurrency_code !=
$conf->currency) {
85if (in_array(
$object->element, array(
'propal',
'commande',
'order',
'facture',
'facturerec',
'invoice',
'supplier_proposal',
'order_supplier',
'invoice_supplier',
'invoice_supplier_rec'))) {
88if (isModEnabled(
'asset') &&
$object->element ==
'invoice_supplier') {
95if (!empty($extrafields)) {
96 if ($this->table_element_line ==
'commandedet') {
98 } elseif ($this->table_element_line ==
'propaldet') {
100 } elseif ($this->table_element_line ==
'supplier_proposaldet') {
102 } elseif ($this->table_element_line ==
'facturedet') {
104 } elseif ($this->table_element_line ==
'contratdet') {
106 } elseif ($this->table_element_line ==
'commande_fournisseurdet') {
108 } elseif ($this->table_element_line ==
'facture_fourn_det') {
110 } elseif ($this->table_element_line ==
'facturedet_rec') {
112 } elseif ($this->table_element_line ==
'facture_fourn_det_rec') {
116print
"<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->\n";
117$nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines);
120 <tr
class=
"liste_titre<?php echo(($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_add_') ?> nodrag nodrop">
122 <td
class=
"linecolnum center"></td>
124 <td
class=
"linecoldescription minwidth400imp">
125 <div
id=
"add"></div><span
class=
"hideonsmartphone"><?php echo $langs->trans(
'AddNewLine'); ?></span>
128 if (
$object->element ==
'supplier_proposal' ||
$object->element ==
'order_supplier' ||
$object->element ==
'invoice_supplier' ||
$object->element ==
'invoice_supplier_rec') {
130 <td
class=
"linecolrefsupplier"><span
id=
"title_fourn_ref"><?php echo $langs->trans(
'SupplierRef'); ?></span></td>
133 <td
class=
"linecolvat right"><span
id=
"title_vat"><?php echo $langs->trans(
'VAT'); ?></span></td>
134 <td
class=
"linecoluht right"><span
id=
"title_up_ht"><?php echo $langs->trans(
'PriceUHT'); ?></span></td>
135 <?php
if (isModEnabled(
"multicurrency") && $this->multicurrency_code !=
$conf->currency) { ?>
136 <td
class=
"linecoluht_currency right"><span
id=
"title_up_ht_currency"><?php echo $langs->trans(
'PriceUHTCurrency'); ?></span></td>
138 <?php
if (!empty($inputalsopricewithtax) && !
getDolGlobalInt(
'MAIN_NO_INPUT_PRICE_WITH_TAX')) { ?>
139 <td
class=
"linecoluttc right"><span
id=
"title_up_ttc"><?php echo $langs->trans(
'PriceUTTC'); ?></span></td>
141 <td
class=
"linecolqty right"><?php echo $langs->trans(
'Qty'); ?></td>
144 print
'<td class="linecoluseunit left">';
145 print
'<span id="title_units">';
146 print $langs->trans(
'Unit');
147 print
'</span></td>';
149 <td
class=
"linecoldiscount right"><?php echo $langs->trans(
'ReductionShort'); ?></td>
152 if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) {
153 print
'<td class="linecolcycleref right">'.$langs->trans(
'Progress').
'</td>';
155 print
'<td class="nobottom nowrap right"></td>';
157 print
'<td class="linecolcycleref2 right"></td>';
159 if (!empty($usemargins)) {
160 if (!$user->hasRight(
'margins',
'creer')) {
163 print
'<td class="margininfos linecolmargin1 right">';
165 echo $langs->trans(
'BuyingPrice');
167 echo $langs->trans(
'CostPrice');
171 echo
'<td class="margininfos linecolmargin2 right"><span class="np_marginRate">'.$langs->trans(
'MarginRate').
'</span></td>';
174 echo
'<td class="margininfos linecolmark1 right"><span class="np_markRate">'.$langs->trans(
'MarkRate').
'</span></td>';
178 <td
class=
"linecoledit" colspan=
"<?php echo $colspan; ?>"> </td>
183<tr
class=
"pair nodrag nodrop nohoverpair<?php echo ($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_create'; ?>">
189 echo
'<td class="nobottom linecolnum center"></td>';
193 <td
class=
"nobottom linecoldescription minwidth400imp">
199 if (
$object->element ==
'contrat') {
200 if (!isModEnabled(
'product') && !isModEnabled(
'service') && !
getDolGlobalString(
'CONTRACT_SUPPORT_PRODUCTS')) {
209 print
'<span class="prod_entry_mode_free nowraponall">';
211 if ($forceall >= 0 && (isModEnabled(
"product") || isModEnabled(
"service"))) {
212 print
'<label for="prod_entry_mode_free">';
213 print
'<input type="radio" class="prod_entry_mode_free" name="prod_entry_mode" id="prod_entry_mode_free" value="free"';
215 print((
GETPOST(
'prod_entry_mode',
'alpha') ==
'free' ||
getDolGlobalString(
'MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT')) ?
' checked' :
'');
218 $labelforempty = $langs->trans(
"FreeLineOfType").
'...';
221 echo
'<input type="hidden" id="prod_entry_mode_free" name="prod_entry_mode" value="free">';
223 if ($forceall >= 0) {
224 if (!isModEnabled(
'product') || !isModEnabled(
'service')) {
225 $labelforempty = $langs->trans(
"Type");
227 $labelforempty = $langs->trans(
"FreeLineOfType");
232 $form->select_type_of_lines(GETPOSTISSET(
"type") ?
GETPOST(
"type",
'alpha', 2) : -1,
'type', $labelforempty, 1, $forceall,
'minwidth200', 0);
236 if (isModEnabled(
"product") || isModEnabled(
"service")) {
237 print
'<span class="nowraponall">';
238 if ($forceall >= 0 && $freelines) {
239 print
'<br><span class="prod_entry_mode_predef paddingtop">';
241 print
'<span class="prod_entry_mode_predef">';
243 print
'<label for="prod_entry_mode_predef">';
244 print
'<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' :
'').
'> ';
246 if (empty(
$conf->dol_optimize_smallscreen)) {
247 if (isModEnabled(
"product") && !isModEnabled(
'service')) {
248 $labelforradio = $langs->trans(
'PredefinedProducts');
249 } elseif ((!isModEnabled(
'product') && isModEnabled(
'service')) || (
$object->element ==
'contrat' && !
getDolGlobalString(
'CONTRACT_SUPPORT_PRODUCTS'))) {
250 $labelforradio = $langs->trans(
'PredefinedServices');
252 $labelforradio = $langs->trans(
'PredefinedProductsAndServices');
255 $labelforradio = $langs->trans(
'PredefinedItem');
257 if (empty($senderissupplier)) {
266 if (empty($senderissupplier)) {
268 $statuswarehouse =
'warehouseopen,warehouseinternal';
270 $statuswarehouse =
'warehouseopen';
274 $form->select_produits(
GETPOST(
'idprod'),
'idprod', $filtertype,
getDolGlobalInt(
'PRODUIT_LIMIT_SIZE'), $buyer->price_level, $statustoshow, 2,
'', 1, array(), $buyer->id, $labelforradio, 0,
'maxwidth500 widthcentpercentminusx', 0, $statuswarehouse,
GETPOST(
'combinations',
'array'));
276 $form->select_produits(
GETPOST(
'idprod'),
'idprod', $filtertype,
getDolGlobalInt(
'PRODUIT_LIMIT_SIZE'), $buyer->price_level, $statustoshow, 2,
'', 1, array(), $buyer->id, $labelforradio, 0,
'maxwidth500 widthcentpercentminusx', 0,
'',
GETPOST(
'combinations',
'array'));
281 $(document).ready(
function() {
283 $(document).on(
'focus',
'.select2-selection.select2-selection--single',
function (e) {
284 console.log(
"focus on a select2 because of MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS");
285 if ($(
this).attr(
'aria-labelledby') ==
'select2-idprod-container')
287 console.log(
'open combo');
288 $(
'#idprod').select2(
'open');
297 if ($senderissupplier != 2) {
298 $ajaxoptions = array(
299 'update' => array(
'qty' =>
'qty',
'remise_percent' =>
'discount',
'idprod' =>
'idprod'),
300 'option_disabled' =>
'idthatdoesnotexists',
301 'warning' => $langs->trans(
"NoPriceDefinedForThisSupplier")
303 $alsoproductwithnosupplierprice = 0;
305 $ajaxoptions = array(
310 $alsoproductwithnosupplierprice = 1;
313 $form->select_produits_fournisseurs(
$object->socid,
GETPOST(
'idprodfournprice'),
'idprodfournprice',
'',
'', $ajaxoptions, 1, $alsoproductwithnosupplierprice,
'minwidth100 maxwidth500 widthcentpercentminusx', $labelforradio);
318 $(document).ready(
function(){
320 $(document).on(
'focus',
'.select2-selection.select2-selection--single',
function (e) {
322 if ($(
this).attr(
'aria-labelledby') ==
'select2-idprodfournprice-container')
324 $(
'#idprodfournprice').select2(
'open');
335 $addproducton = (isModEnabled(
'product') && $user->hasRight(
'produit',
'creer'));
336 $addserviceon = (isModEnabled(
'service') && $user->hasRight(
'service',
'creer'));
337 if ($addproducton || $addserviceon) {
338 if ($addproducton && $addserviceon) {
339 echo
'<div id="dropdownAddProductAndService" class="dropdown inline-block">';
340 echo
'<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" id="dropdownAddProductAndServiceLink" aria-haspopup="true" aria-expanded="false">';
341 echo
'<span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
343 echo
'<div class="dropdown-menu" aria-labelledby="dropdownAddProductAndServiceLink" style="top:auto; left:auto;">';
344 echo
'<a class="dropdown-item" href="'.DOL_URL_ROOT.
'/product/card.php?action=create&type=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.
$object->id).
'"> '.$langs->trans(
"NewProduct").
'</a>';
345 echo
'<a class="dropdown-item" href="'.DOL_URL_ROOT.
'/product/card.php?action=create&type=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.
$object->id).
'"> '.$langs->trans(
"NewService").
'</a>';
350 $url =
'/product/card.php?leftmenu=product&action=create&type=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"]);
351 $newbutton =
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"NewProduct").
'"></span>';
354 $tmpbacktopagejsfields =
'addproduct:id,search_id';
358 print
'<a href="'.DOL_URL_ROOT.
'/product/card.php?action=create&type=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.
$object->id).
'" title="'.
dol_escape_htmltag($langs->trans(
"NewProduct")).
'"><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
362 $url =
'/product/card.php?leftmenu=product&action=create&type=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"]);
363 $newbutton =
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"NewService").
'"></span>';
366 $tmpbacktopagejsfields =
'addproduct:id,search_id';
370 print
'<a href="'.DOL_URL_ROOT.
'/product/card.php?action=create&type=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.
$object->id).
'" title="'.
dol_escape_htmltag($langs->trans(
"NewService")).
'"><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
378 $(document).ready(
function(){
379 $(
"#dropdownAddProductAndService .dropdown-toggle").on(
"click",
function(event) {
380 console.log(
"toggle addproduct dropdown");
381 event.preventDefault();
382 $(
"#dropdownAddProductAndService").toggleClass(
"open");
388 echo
'<input type="hidden" name="pbq" id="pbq" value="">';
393 echo
'<br>'.$langs->trans(
'AddLineOnPosition').
' : <input type="number" name="rank" step="1" min="0" style="width: 5em;">';
396 if (is_object($hookmanager) && empty($senderissupplier)) {
397 $parameters = array(
'fk_parent_line' =>
GETPOSTINT(
'fk_parent_line'));
398 $reshook = $hookmanager->executeHooks(
'formCreateProductOptions', $parameters,
$object, $action);
399 if (!empty($hookmanager->resPrint)) {
400 print $hookmanager->resPrint;
403 if (is_object($hookmanager) && !empty($senderissupplier)) {
404 $parameters = array(
'htmlname' =>
'addproduct');
405 $reshook = $hookmanager->executeHooks(
'formCreateProductSupplierOptions', $parameters,
$object, $action);
406 if (!empty($hookmanager->resPrint)) {
407 print $hookmanager->resPrint;
410 if (isModEnabled(
"product") || isModEnabled(
"service")) {
412 if (isModEnabled(
'variants')) {
413 echo
'<div id="attributes_box"></div>';
417 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
423 $toolbarname =
'dolibarr_details';
425 $toolbarname =
'dolibarr_notes';
427 $doleditor =
new DolEditor(
'dp_desc',
GETPOST(
'dp_desc',
'restricthtml'),
'',
getDolGlobalInt(
'MAIN_DOLEDITOR_HEIGHT', 100), $toolbarname,
'',
false,
true, $enabled, $nbrows,
'98%');
428 $doleditor->Create();
430 if (isModEnabled(
"service") && (
$object->element ==
'facturerec' ||
$object->element ==
'invoice_supplier_rec')) {
431 echo
'<div class="divlinefordates"><br>';
432 echo $langs->trans(
'AutoFillDateFrom').
' ';
434 $line->date_start_fill = 1;
435 $line->date_end_fill = 1;
437 echo $form->selectyesno(
'date_start_fill', $line->date_start_fill, 1);
439 echo $langs->trans(
'AutoFillDateTo').
' ';
440 echo $form->selectyesno(
'date_end_fill', $line->date_end_fill, 1);
443 if (is_object($objectline)) {
444 $temps = $objectline->showOptionals($extrafields,
'create', array(),
'',
'', 1,
'line');
446 if (!empty($temps)) {
447 print
'<div style="padding-top: 10px" id="extrafield_lines_area_create" name="extrafield_lines_area_create">';
453 if (
$object->element ==
'supplier_proposal' ||
$object->element ==
'order_supplier' ||
$object->element ==
'invoice_supplier' ||
$object->element ==
'invoice_supplier_rec') {
455 <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>
458 print
'<td class="nobottom linecolvat right">';
460 if (
$object->element ==
'propal' ||
$object->element ==
'commande' ||
$object->element ==
'facture' ||
$object->element ==
'facturerec') {
462 } elseif (
$object->element ==
'supplier_proposal' ||
$object->element ==
'order_supplier' ||
$object->element ==
'invoice_supplier' ||
$object->element ==
'invoice_supplier_rec') {
465 if ($seller->tva_assuj ==
"0") {
466 echo
'<input type="hidden" name="tva_tx" id="tva_tx" value="0">'.vatrate(
'0',
true);
468 echo $form->load_tva(
'tva_tx', (GETPOSTISSET(
"tva_tx") ?
GETPOST(
"tva_tx",
'alpha', 2) : -1), $seller, $buyer, 0, 0,
'', false, 1, $type_tva);
473 <td
class=
"nobottom linecoluht right"><?php $coldisplay++; ?>
474 <input
type=
"text" name=
"price_ht" id=
"price_ht" class=
"flat right width50" value=
"<?php echo(GETPOSTISSET("price_ht
") ? GETPOST("price_ht
", 'alpha', 2) : ''); ?>">
478 if (isModEnabled(
"multicurrency") && $this->multicurrency_code !=
$conf->currency) {
480 <td
class=
"nobottom linecoluht_currency right">
481 <input
type=
"text" name=
"multicurrency_price_ht" id=
"multicurrency_price_ht" class=
"flat right width50" value=
"<?php echo(GETPOSTISSET("multicurrency_price_ht
") ? GETPOST("multicurrency_price_ht
", 'alpha', 2) : ''); ?>">
485 if (!empty($inputalsopricewithtax) && !
getDolGlobalInt(
'MAIN_NO_INPUT_PRICE_WITH_TAX')) {
487 <td
class=
"nobottom linecoluttc right">
488 <input
type=
"text" name=
"price_ttc" id=
"price_ttc" class=
"flat right width50" value=
"<?php echo(GETPOSTISSET("price_ttc
") ? GETPOST("price_ttc
", 'alpha', 2) : ''); ?>">
494 <td
class=
"nobottom linecolqty right">
495 <?php $default_qty = (!
getDolGlobalString(
'MAIN_OBJECTLINE_CREATE_EMPTY_QTY_BY_DEFAULT') ? 1 :
''); ?>
496 <input
type=
"text" name=
"qty" id=
"qty" class=
"flat width40 right" value=
"<?php echo(GETPOSTISSET("qty
") ? GETPOST("qty
", 'alpha', 2) : $default_qty); ?>">
501 print
'<td class="nobottom linecoluseunit left">';
502 print $form->selectUnits(empty($line->fk_unit) ?
$conf->global->PRODUCT_USE_UNITS : $line->fk_unit,
"units");
505 $remise_percent = $buyer->remise_percent;
506 if (
$object->element ==
'supplier_proposal' ||
$object->element ==
'order_supplier' ||
$object->element ==
'invoice_supplier') {
507 $remise_percent = $seller->remise_supplier_percent;
512 <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>
514 if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) {
516 print
'<td class="nobottom nowrap right"><input class="flat right" type="text" size="1" value="" name="progress"><span class="opacitymedium hideonsmartphone">%</span></td>';
519 print
'<td class="nobottom nowrap right"></td>';
524 if (!empty($usemargins)) {
525 if ($user->hasRight(
'margins',
'creer')) {
527 <td
class=
"nobottom margininfos linecolmargin right">
528 <!-- For predef product -->
529 <?php
if (isModEnabled(
"product") || isModEnabled(
"service")) { ?>
530 <select
id=
"fournprice_predef" name=
"fournprice_predef" class=
"flat minwidth75imp maxwidth150" style=
"display: none;"></select>
532 <!-- For free product -->
533 <input
type=
"text" id=
"buying_price" name=
"buying_price" class=
"flat maxwidth75 right" value=
"<?php echo(GETPOSTISSET("buying_price
") ? GETPOST("buying_price
", 'alpha', 2) : ''); ?>">
537 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>';
541 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>';
546 $coldisplay += $colspan;
548 <td
class=
"nobottom linecoledit center valignmiddle" colspan=
"<?php echo $colspan; ?>">
549 <input
type=
"submit" class=
"button reposition" value=
"<?php echo $langs->trans('Add'); ?>" name=
"addline" id=
"addline">
554if ((isModEnabled(
"service") || (
$object->element ==
'contrat')) && $dateSelector &&
GETPOST(
'type') !=
'0') {
555 print
'<tr id="trlinefordates" class="oddeven">'.
"\n";
559 print
'<td colspan="'.($coldisplay - (!
getDolGlobalString(
'MAIN_VIEW_LINE_NUMBER') ? 0 : 1)).
'">';
563 $prefillDates =
false;
566 for ($i = count(
$object->lines) - 1; $i >= 0; $i--) {
567 $lastline =
$object->lines[$i];
569 if ($lastline->product_type ==
Product::TYPE_SERVICE && (!empty($lastline->date_start) || !empty($lastline->date_end))) {
570 $date_start_prefill = $lastline->date_start;
571 $date_end_prefill = $lastline->date_end;
573 $prefillDates =
true;
580 print $langs->trans(
"DateStartPlanned").
' ';
581 print $form->selectDate($date_start,
"date_start", $usehm, $usehm, 1,
"addproduct");
582 print
' '.$langs->trans(
"DateEndPlanned").
' ';
583 print $form->selectDate($date_end,
"date_end", $usehm, $usehm, 1,
"addproduct");
585 print $langs->trans(
'ServiceLimitedDuration').
' '.$langs->trans(
'From').
' ';
586 print $form->selectDate($date_start,
'date_start', !
getDolGlobalString(
'MAIN_USE_HOURMIN_IN_DATE_RANGE') ? 0 : 1, !
getDolGlobalString(
'MAIN_USE_HOURMIN_IN_DATE_RANGE') ? 0 : 1, 1,
"addproduct", 1, 0);
587 print
' '.$langs->trans(
'to').
' ';
588 print $form->selectDate($date_end,
'date_end', !
getDolGlobalString(
'MAIN_USE_HOURMIN_IN_DATE_RANGE') ? 0 : 1, !
getDolGlobalString(
'MAIN_USE_HOURMIN_IN_DATE_RANGE') ? 0 : 1, 1,
"addproduct", 1, 0);
592 echo
' <span class="small"><a href="#" id="prefill_service_dates">'.$langs->trans(
'FillWithLastServiceDates').
'</a></span>';
599 function prefill_service_dates()
601 $(
'#date_start').val(
"<?php echo dol_escape_js(dol_print_date($date_start_prefill, 'day')); ?>").trigger(
'change');
602 $(
'#date_end').val(
"<?php echo dol_escape_js(dol_print_date($date_end_prefill, 'day')); ?>").trigger(
'change');
607 $(document).ready(
function()
609 $(
'#prefill_service_dates').click(prefill_service_dates);
616 if (isset(
$conf->global->MAIN_DEFAULT_DATE_START_HOUR)) {
617 print
'jQuery("#date_starthour").val("' .
getDolGlobalString(
'MAIN_DEFAULT_DATE_START_HOUR').
'");';
619 if (isset(
$conf->global->MAIN_DEFAULT_DATE_START_MIN)) {
620 print
'jQuery("#date_startmin").val("' .
getDolGlobalString(
'MAIN_DEFAULT_DATE_START_MIN').
'");';
624 if (isset(
$conf->global->MAIN_DEFAULT_DATE_END_HOUR)) {
625 print
'jQuery("#date_endhour").val("' .
getDolGlobalString(
'MAIN_DEFAULT_DATE_END_HOUR').
'");';
627 if (isset(
$conf->global->MAIN_DEFAULT_DATE_END_MIN)) {
628 print
'jQuery("#date_endmin").val("' .
getDolGlobalString(
'MAIN_DEFAULT_DATE_END_MIN').
'");';
639if (!empty($usemargins) && $user->hasRight(
'margins',
'creer')) {
642 jQuery(document).ready(
function() {
645 $(
"input[name='np_marginRate']:first").blur(
function(e) {
646 console.log(
"np_marginRate blur");
647 return checkFreeLine(e,
"np_marginRate");
652 $(
"input[name='np_markRate']:first").blur(
function(e) {
653 console.log(
"np_markRate blur");
654 return checkFreeLine(e,
"np_markRate");
661 function checkFreeLine(e, npRate)
663 var buying_price = $(
"input[name='buying_price']:first");
664 var remise = $(
"input[name='remise_percent']:first");
666 var rate = $(
"input[name='"+npRate+
"']:first");
667 if (rate.val() ==
'')
670 if (! $.isNumeric(rate.val().replace(
',',
'.')))
672 alert(
'<?php echo dol_escape_js($langs->trans("rateMustBeNumeric")); ?>');
674 setTimeout(
function () { rate.focus() }, 50);
677 if (npRate ==
"np_markRate" && rate.val() >= 100)
679 alert(
'<?php echo dol_escape_js($langs->trans("markRateShouldBeLesserThan100")); ?>');
681 setTimeout(
function () { rate.focus() }, 50);
690 if (remisejs ==
'') remisejs=0;
695 if (npRate ==
"np_marginRate")
696 price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
697 else if (npRate ==
"np_markRate")
698 price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
701 $(
"input[name='price_ht']:first").val(
price);
711 function setFocusOnDescription() {
712 console.log(
"Set focus on description field");
714 jQuery(
'#dp_desc').focus();
716 if (typeof CKEDITOR ==
"object" && typeof CKEDITOR.instances !=
"undefined") {
717 var editor = CKEDITOR.instances[
'dp_desc'];
726 jQuery(document).ready(
function() {
727 jQuery(
"#price_ht").keyup(
function(event) {
729 if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery(
"#price_ht").val() !=
'') {
730 jQuery(
"#price_ttc").val(
'');
731 jQuery(
"#multicurrency_subprice").val(
'');
732 jQuery(
"#multicurrency_price_ht").val(
'');
736 jQuery(
"#price_ttc").keyup(
function(event) {
738 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery(
"#price_ttc").val() !=
'') {
739 jQuery(
"#price_ht").val(
'');
740 jQuery(
"#multicurrency_subprice").val(
'');
741 jQuery(
"#multicurrency_price_ht").val(
'');
744 jQuery(
"#multicurrency_subprice").keyup(
function(event) {
746 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery(
"#multicurrency_subprice").val() !=
'') {
747 jQuery(
"#price_ht").val(
'');
748 jQuery(
"#price_ttc").val(
'');
751 jQuery(
"#multicurrency_price_ht").keyup(
function(event) {
753 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery(
"#multicurrency_price_ht").val() !=
'') {
754 jQuery(
"#price_ht").val(
'');
755 jQuery(
"#price_ttc").val(
'');
759 $(
"#select_type").change(
function()
763 console.log(
"Hide/show date according to product type select_type="+jQuery(
'#select_type').val());
764 if (jQuery(
'#select_type').val() ==
'0')
766 jQuery(
'#trlinefordates').hide();
767 jQuery(
'.divlinefordates').hide();
771 jQuery(
'#trlinefordates').show();
772 jQuery(
'.divlinefordates').show();
775 if (jQuery(
"#select_type").val() !=
'-1') {
776 console.log(
"we remove class");
777 jQuery(
"#select_type").removeClass(
"placeholder");
778 setFocusOnDescription();
780 console.log(
"we add class");
781 jQuery(
"#select_type").addClass(
"placeholder");
785 $(
"#prod_entry_mode_free").on(
"click",
function() {
789 $(
"#prod_entry_mode_predef").on(
"click",
function() {
790 console.log(
"click prod_entry_mode_predef");
791 jQuery(
"#select_type").addClass(
"placeholder");
793 jQuery(
'#trlinefordates').show();
797 if (!$freelines) { ?>
798 jQuery(
"#prod_entry_mode_predef").click();
801 jQuery(
"#select_type").addClass(
"placeholder");
805 if (in_array($this->table_element_line, array(
'propaldet',
'commandedet',
'facturedet'))) { ?>
806 $(
"#date_start, #date_end").focusout(
function() {
807 console.log(
"focusout of date");
808 let
type = $(
this).attr(
'type');
809 let mandatoryP = $(
this).attr(
'mandatoryperiod');
810 if (
type == 1 && mandatoryP == 1) {
811 if ($(
this).val() ==
'' && !$(
this).hasClass(
'inputmandatory')) {
812 $(
this).addClass(
'inputmandatory');
814 $(
this).removeClass(
'inputmandatory');
822 $(
"#idprod, #idprodfournprice").change(
function()
824 console.log(
"objectline_create.tpl Call method change() after change on #idprod or #idprodfournprice (senderissupplier=<?php echo $senderissupplier; ?>). this.val = "+$(
this).val());
828 jQuery(
'#trlinefordates').show();
831 if (!
getDolGlobalString(
'MAIN_DISABLE_EDIT_PREDEF_PRICEHT') && empty($senderissupplier)) {
833 var pbq = parseInt($(
'option:selected',
this).attr(
'data-pbq'));
834 if (isNaN(pbq)) { pbq = jQuery(
'#idprod').attr(
'data-pbq'); }
836 if ((jQuery(
'#idprod').val() > 0 || jQuery(
'#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0)
838 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");
841 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 different prices"); }
844 console.log(
"Load unit price and set it into #price_ht or #price_ttc for product id="+$(
this).val()+
" socid=<?php print $object->socid; ?>");
845 $.post(
'<?php echo DOL_URL_ROOT; ?>/product/ajax/products.php?action=fetch',
846 {
'id': $(
this).val(),
'socid': <?php print
$object->socid; ?>,
'token':
'<?php print currentToken(); ?>',
'addalsovatforthirdpartyid': 1 },
848 console.log(
"objectline_create.tpl Load unit price ends, we got value ht="+data.price_ht+
" ttc="+data.price_ttc+
" pricebasetype="+data.pricebasetype);
850 $(
'#date_start').removeAttr(
'type');
851 $(
'#date_end').removeAttr(
'type');
852 $(
'#date_start').attr(
'type', data.type);
853 $(
'#date_end').attr(
'type', data.type);
855 $(
'#date_start').removeAttr(
'mandatoryperiod');
856 $(
'#date_end').removeAttr(
'mandatoryperiod');
857 $(
'#date_start').attr(
'mandatoryperiod', data.mandatory_period);
858 $(
'#date_end').attr(
'mandatoryperiod', data.mandatory_period);
861 if (data.mandatory_period == 1 && data.type == 1) {
862 jQuery(
'#date_start').addClass(
'inputmandatory');
863 jQuery(
'#date_end').addClass(
'inputmandatory');
865 jQuery(
'#date_start').removeClass(
'inputmandatory');
866 jQuery(
'#date_end').removeClass(
'inputmandatory');
869 if (<?php echo (
int) $inputalsopricewithtax; ?> == 1 && data.pricebasetype ==
'TTC' && <?php print
getDolGlobalInt(
'MAIN_NO_INPUT_PRICE_WITH_TAX') ?
'false' :
'true'; ?>) {
870 console.log(
"objectline_create.tpl set content of price_ttc");
871 jQuery(
"#price_ttc").val(data.price_ttc);
873 console.log(
"objectline_create.tpl set content of price_ht");
874 jQuery(
"#price_ht").val(data.price_ht);
878 for (var key in data.array_options) {
879 if (data.array_options.hasOwnProperty(key)) {
880 var field = jQuery(
"#" + key);
881 if(field.length > 0){
882 console.log(
"objectline_create.tpl set content of options_" + key);
883 field.val(data.array_options[key]);
888 var tva_tx = data.tva_tx;
889 var default_vat_code = data.default_vat_code;
892 var stringforvatrateselection = tva_tx;
893 if (typeof default_vat_code !=
'undefined' && default_vat_code !=
null && default_vat_code !=
'') {
894 stringforvatrateselection = stringforvatrateselection+
' ('+default_vat_code+
')';
899 console.log(
"MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA is on so we check if we need to autoswith the vat code");
900 console.log(
"mysoc->country_code=<?php echo $mysoc->country_code; ?> thirdparty->country_code=<?php echo $object->thirdparty->country_code; ?>");
901 new_default_vat_code = default_vat_code;
903 if ($mysoc->country_code ==
'IN' && !empty(
$object->thirdparty) &&
$object->thirdparty->country_code ==
'IN' && $mysoc->state_code ==
$object->thirdparty->state_code) {
906 console.log(
"Countries are both IN and states are same, so we revert I into CS in default_vat_code="+default_vat_code);
907 new_default_vat_code = default_vat_code.replace(/^I\-/,
'C+S-');
909 } elseif ($mysoc->country_code ==
'IN' && !empty(
$object->thirdparty) &&
$object->thirdparty->country_code ==
'IN' && $mysoc->state_code !=
$object->thirdparty->state_code) {
912 console.log(
"Countries are both IN and states differs, so we revert CS into I in default_vat_code="+default_vat_code);
913 new_default_vat_code = default_vat_code.replace(/^C\+S\-/,
'I-');
916 if (new_default_vat_code != default_vat_code && jQuery(
'#tva_tx option:contains("'+new_default_vat_code+
'")').val()) {
917 console.log(
"We found en entry into VAT with new default_vat_code, we will use it");
918 stringforvatrateselection = jQuery(
'#tva_tx option:contains("'+new_default_vat_code+
'")').val();
924 $(
'#tva_tx').val(tva_tx);
927 $(
'#tva_tx option').removeAttr(
'selected');
928 console.log(
"stringforvatrateselection="+stringforvatrateselection+
" -> value of option label for this key="+$(
'#tva_tx option[value="'+stringforvatrateselection+
'"]').val());
929 $(
'#tva_tx option[value="'+stringforvatrateselection+
'"]').prop(
'selected',
true);
934 var proddesc = data.desc_trans;
937 var proddesc = data.desc;
940 console.log(
"objectline_create.tpl Load description into text area : "+proddesc);
943 if (typeof CKEDITOR ==
"object" && typeof CKEDITOR.instances !=
"undefined")
945 var editor = CKEDITOR.instances[
'dp_desc'];
947 editor.setData(proddesc);
952 jQuery(
'#dp_desc').text(proddesc);
959 jQuery.each(data.array_options,
function( key, value ) {
960 jQuery(
'div[class*="det'+key.replace(
'options_',
'_extras_')+
'"] > #'+key).val(value);
971 if (!empty($usemargins) && $user->hasRight(
'margins',
'creer')) {
972 $langs->load(
'stocks'); ?>
975 $(
"#fournprice_predef").find(
"option").remove();
976 $(
"#fournprice_predef").hide();
977 $(
"#buying_price").val(
"").show();
980 var token =
'<?php echo currentToken(); ?>';
981 $.post(
'<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php?bestpricefirst=1', {
'idprod': $(
this).val(),
'token': token },
function(data) {
982 if (data && data.length > 0)
984 var options =
''; var defaultkey =
''; var defaultprice =
''; var bestpricefound = 0;
986 var bestpriceid = 0; var bestpricevalue = 0;
987 var pmppriceid = 0; var pmppricevalue = 0;
988 var costpriceid = 0; var costpricevalue = 0;
991 var defaultbuyprice =
'<?php
992 if (isset($conf->global->MARGIN_TYPE)) {
993 if (getDolGlobalString('MARGIN_TYPE
') == '1
') {
994 print 'bestsupplierprice
';
996 if (getDolGlobalString('MARGIN_TYPE
') == 'pmp
') {
999 if (getDolGlobalString('MARGIN_TYPE
') == 'costprice
') {
1003 console.log(
"objectline_create.tpl we will set the field for margin. defaultbuyprice="+defaultbuyprice);
1006 $(data).each(
function() {
1008 if (this.
id !=
'pmpprice' && this.
id !=
'costprice')
1011 this.price = parseFloat(this.price);
1014 if (bestpricefound == 0 && this.price > 0) { defaultkey = this.id; defaultprice = this.
price; bestpriceid = this.id; bestpricevalue = this.
price; bestpricefound=1; }
1016 if (this.
id ==
'pmpprice')
1019 console.log(
"id="+this.
id+
"-price="+this.price);
1020 if (
'pmp' == defaultbuyprice ||
'costprice' == defaultbuyprice)
1022 if (this.price > 0) {
1023 defaultkey = this.id; defaultprice = this.
price; pmppriceid = this.id; pmppricevalue = this.
price;
1028 if (this.
id ==
'costprice')
1031 console.log(
"id="+this.
id+
"-price="+this.price+
"-pmppricevalue="+pmppricevalue);
1032 if (
'costprice' == defaultbuyprice)
1034 if (this.price > 0) { defaultkey = this.id; defaultprice = this.
price; costpriceid = this.id; costpricevalue = this.
price; }
1035 else if (pmppricevalue > 0) { defaultkey =
'pmpprice'; defaultprice = pmppricevalue; }
1038 options +=
'<option value="'+this.
id+
'" price="'+this.price+
'">'+this.label+
'</option>';
1040 options +=
'<option value="inputprice" price="'+defaultprice+
'"><?php echo dol_escape_js($langs->trans("InputPrice").'...
'); ?></option>';
1042 console.log(
"finally selected defaultkey="+defaultkey+
" defaultprice for buying price="+defaultprice);
1044 $(
"#fournprice_predef").html(options).show();
1045 if (defaultkey !=
'')
1047 $(
"#fournprice_predef").val(defaultkey);
1051 $(
"#buying_price").hide();
1054 var defaultprice = $(
"#fournprice_predef").find(
'option:selected').attr(
"price");
1055 $(
"#buying_price").val(defaultprice);
1057 $(
"#fournprice_predef").change(
function() {
1058 console.log(
"change on fournprice_predef");
1060 var linevalue=$(
this).find(
'option:selected').val();
1061 var pricevalue = $(
this).find(
'option:selected').attr(
"price");
1062 if (linevalue !=
'inputprice' && linevalue !=
'pmpprice') {
1063 $(
"#buying_price").val(pricevalue).hide();
1065 if (linevalue ==
'inputprice') {
1066 $(
'#buying_price').show();
1068 if (linevalue ==
'pmpprice') {
1069 $(
"#buying_price").val(pricevalue);
1070 $(
'#buying_price').hide();
1085 var pbq = parseInt($(
'option:selected',
this).attr(
'data-pbq'));
1086 if (isNaN(pbq)) { pbq = jQuery(
'#idprod').attr(
'data-pbq'); }
1087 var pbqup = parseFloat($(
'option:selected',
this).attr(
'data-pbqup'));
1088 if (isNaN(pbqup)) { pbqup = jQuery(
'#idprod').attr(
'data-pbqup'); }
1089 var pbqbase = $(
'option:selected',
this).attr(
'data-pbqbase');
1090 if (isNaN(pbqbase)) { pbqbase = jQuery(
'#idprod').attr(
'data-pbqbase'); }
1091 var pbqqty = parseFloat($(
'option:selected',
this).attr(
'data-pbqqty'));
1092 if (isNaN(pbqqty)) { pbqqty = jQuery(
'#idprod').attr(
'data-pbqqty'); }
1093 var pbqpercent = parseFloat($(
'option:selected',
this).attr(
'data-pbqpercent'));
1094 if (isNaN(pbqpercent)) { pbqpercent = jQuery(
'#idprod').attr(
'data-pbqpercent'); }
1096 if ((jQuery(
'#idprod').val() > 0) && ! isNaN(pbq) && pbq > 0)
1098 var pbqupht = pbqup;
1100 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);
1101 jQuery(
"#pbq").val(pbq);
1102 jQuery(
"#price_ht").val(pbqupht);
1103 if (jQuery(
"#qty").val() < pbqqty)
1105 jQuery(
"#qty").val(pbqqty);
1107 if (jQuery(
"#remise_percent").val() < pbqpercent)
1109 jQuery(
"#remise_percent").val(pbqpercent);
1111 }
else { jQuery(
"#pbq").val(
''); }
1118 if (jQuery(
'#idprodfournprice').val() > 0)
1120 console.log(
"objectline_create.tpl #idprodfournprice is an ID > 0, so we set some properties into page");
1122 var up = parseFloat($(
'option:selected',
this).attr(
'data-up'));
1123 if (isNaN(up)) { up = parseFloat(jQuery(
'#idprodfournprice').attr(
'data-up'));}
1125 var up_locale = $(
'option:selected',
this).attr(
'data-up-locale');
1126 if (typeof up_locale ===
'undefined') { up_locale = jQuery(
'#idprodfournprice').attr(
'data-up-locale');}
1128 var qty = parseFloat($(
'option:selected',
this).attr(
'data-qty'));
1129 if (isNaN(qty)) { qty = parseFloat(jQuery(
'#idprodfournprice').attr(
'data-qty'));}
1131 var discount = parseFloat($(
'option:selected',
this).attr(
'data-discount'));
1132 if (isNaN(discount)) { discount = parseFloat(jQuery(
'#idprodfournprice').attr(
'data-discount'));}
1134 var tva_tx = parseFloat($(
'option:selected',
this).attr(
'data-tvatx'));
1135 if (isNaN(tva_tx)) { tva_tx = parseFloat(jQuery(
'#idprodfournprice').attr(
'data-tvatx'));}
1137 var default_vat_code = $(
'option:selected',
this).attr(
'data-default-vat-code');
1138 if (typeof default_vat_code ===
'undefined') { default_vat_code = jQuery(
'#idprodfournprice').attr(
'data-default-vat-code');}
1140 var supplier_ref = $(
'option:selected',
this).attr(
'data-supplier-ref');
1141 if (typeof supplier_ref ===
'undefined') { supplier_ref = jQuery(
'#idprodfournprice').attr(
'data-supplier-ref'); }
1143 <?php
if ((
$object->element ==
'supplier_proposal' ||
$object->element ==
'order_supplier' ||
$object->element ==
'invoice_supplier' ||
$object->element ==
'invoice_supplier_rec') && !$seller->tva_assuj) { ?>
1146 default_vat_code =
null;
1150 var stringforvatrateselection = tva_tx;
1151 if (typeof default_vat_code !=
'undefined' && default_vat_code !=
null && default_vat_code !=
'') {
1152 stringforvatrateselection = stringforvatrateselection+
' ('+default_vat_code+
')';
1155 var has_multicurrency_up =
false;
1157 if (isModEnabled(
'multicurrency') &&
$object->multicurrency_code !=
$conf->currency) {
1159 var object_multicurrency_code =
'<?php print dol_escape_js($object->multicurrency_code); ?>';
1161 var multicurrency_code = $(
'option:selected',
this).attr(
'data-multicurrency-code');
1162 if (multicurrency_code == undefined) { multicurrency_code = jQuery(
'#idprodfournprice').attr(
'data-multicurrency-code'); }
1164 var multicurrency_up = parseFloat($(
'option:selected',
this).attr(
'data-multicurrency-unitprice'));
1165 if (isNaN(multicurrency_up)) { multicurrency_up = parseFloat(jQuery(
'#idprodfournprice').attr(
'data-multicurrency-unitprice')); }
1167 if (multicurrency_code == object_multicurrency_code) {
1168 has_multicurrency_up =
true;
1169 jQuery(
"#multicurrency_price_ht").val(multicurrency_up);
1172 console.log(
"objectline_create.tpl Multicurrency values : object_multicurrency_code = "+object_multicurrency_code+
", multicurrency_code = "+multicurrency_code+
", multicurrency_up = "+multicurrency_up);
1177 console.log(
"objectline_create.tpl We find supplier price : up = "+up+
", up_locale = "+up_locale+
", has_multicurrency_up = "+has_multicurrency_up+
", supplier_ref = "+supplier_ref+
" qty = "+qty+
", tva_tx = "+tva_tx+
", default_vat_code = "+default_vat_code+
", stringforvatrateselection="+stringforvatrateselection+
", discount = "+discount+
" for product supplier ref id = "+jQuery(
'#idprodfournprice').val());
1179 if (has_multicurrency_up ===
false) {
1180 if (typeof up_locale ===
'undefined') {
1181 jQuery(
"#price_ht").val(up);
1183 jQuery(
"#price_ht").val(up_locale);
1188 $(
'#fourn_ref').val(supplier_ref);
1190 $(
'#tva_tx').val(tva_tx);
1193 $(
'#tva_tx option').removeAttr(
'selected');
1194 console.log(
"stringforvatrateselection="+stringforvatrateselection+
" -> value of option label for this key="+$(
'#tva_tx option[value="'+stringforvatrateselection+
'"]').val());
1195 $(
'#tva_tx option[value="'+stringforvatrateselection+
'"]').prop(
'selected',
true);
1197 if (jQuery(
"#qty").val() < qty) {
1198 jQuery(
"#qty").val(qty);
1200 if (jQuery(
"#remise_percent").val() < discount) {
1201 jQuery(
"#remise_percent").val(discount);
1207 var
description = $(
'option:selected',
this).attr(
'data-description');
1208 if (typeof
description ==
'undefined') {
description = jQuery(
'#idprodfournprice').attr(
'data-description'); }
1210 console.log(
"Load description into text area : "+
description);
1214 if (typeof CKEDITOR ==
"object" && typeof CKEDITOR.instances !=
"undefined")
1216 var editor = CKEDITOR.instances[
'dp_desc'];
1229 }
else if (jQuery(
'#idprodfournprice').length > 0) {
1230 console.log(
"objectline_create.tpl #idprodfournprice is not an int but is a string so we set only few properties into page");
1232 var tva_tx = parseFloat($(
'option:selected',
this).attr(
'data-tvatx'));
1233 if (isNaN(tva_tx)) { tva_tx = parseFloat(jQuery(
'#idprodfournprice').attr(
'data-tvatx'));}
1235 var default_vat_code = $(
'option:selected',
this).attr(
'data-default-vat-code');
1236 if (typeof default_vat_code ===
'undefined') { default_vat_code = jQuery(
'#idprodfournprice').attr(
'data-default-vat-code');}
1238 var supplier_ref = $(
'option:selected',
this).attr(
'data-supplier-ref');
1239 if (typeof supplier_ref ===
'undefined') { supplier_ref = jQuery(
'#idprodfournprice').attr(
'data-supplier-ref'); }
1241 var stringforvatrateselection = tva_tx;
1242 if (typeof default_vat_code !=
'undefined' && default_vat_code !=
null && default_vat_code !=
'') {
1243 stringforvatrateselection = stringforvatrateselection+
' ('+default_vat_code+
')';
1247 console.log(
"objectline_create.tpl We find data for price : tva_tx = "+tva_tx+
", default_vat_code = "+default_vat_code+
", supplier_ref = "+supplier_ref+
", stringforvatrateselection="+stringforvatrateselection+
" for product id = "+jQuery(
'#idprodfournprice').val());
1250 $(
'#fourn_ref').val(supplier_ref);
1252 $(
'#tva_tx').val(tva_tx);
1255 $(
'#tva_tx option').removeAttr(
'selected');
1256 console.log(
"stringforvatrateselection="+stringforvatrateselection+
" -> value of option label for this key="+$(
'#tva_tx option[value="'+stringforvatrateselection+
'"]').val());
1257 $(
'#tva_tx option[value="'+stringforvatrateselection+
'"]').prop(
'selected',
true);
1262 if (typeof CKEDITOR ==
"object" && typeof CKEDITOR.instances !=
"undefined")
1264 var editor = CKEDITOR.instances[
'dp_desc'];
1272 jQuery(
'#dp_desc').text(
'');
1281 if (jQuery(
'#idprod').val() > 0 || jQuery(
'#idprodfournprice').val() > 0)
1283 console.log(
"Try to set focus on desc");
1285 jQuery(
'#dp_desc').focus();
1287 if (typeof CKEDITOR ==
"object" && typeof CKEDITOR.instances !=
"undefined")
1289 var editor = CKEDITOR.instances[
'dp_desc'];
1297 <?php
if (
GETPOST(
'prod_entry_mode') ==
'predef') {
1304 function setforfree() {
1305 console.log(
"objectline_create.tpl::setforfree. We show most fields");
1306 jQuery(
"#idprodfournprice").val(
'0');
1307 jQuery(
"#prod_entry_mode_free").prop(
'checked',
true).change();
1308 jQuery(
"#prod_entry_mode_predef").prop(
'checked',
false).change();
1309 jQuery(
"#search_idprod, #idprod, #search_idprodfournprice, #buying_price").val(
'');
1310 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();
1311 jQuery(
"#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show();
1312 jQuery(
"#fournprice_predef").hide();
1315 function setforpredef() {
1316 console.log(
"objectline_create.tpl::setforpredef We hide some fields, show dates");
1318 jQuery(
"#select_type").val(-1);
1319 jQuery(
"#select_type").addClass(
"placeholder");
1322 jQuery(
"#prod_entry_mode_free").prop(
'checked',
false).change();
1323 jQuery(
"#prod_entry_mode_predef").prop(
'checked',
true).change();
1325 jQuery(
"#price_ht").val(
'').show();
1326 jQuery(
"#multicurrency_price_ht").val(
'').show();
1327 jQuery(
"#title_up_ht, #title_up_ht_currency").show();
1330 jQuery(
"#multicurrency_price_ht").val(
'').hide();
1331 jQuery(
"#title_up_ht, #title_up_ht_currency").hide();
1334 jQuery(
"#price_ttc").val(
'').show();
1335 jQuery(
"#multicurrency_price_ttc").val(
'').show();
1336 jQuery(
"#title_up_ttc, #title_up_ttc_currency").show();
1338 jQuery(
"#price_ttc").val(
'').hide();
1339 jQuery(
"#multicurrency_price_ttc").val(
'').hide();
1340 jQuery(
"#title_up_ttc, #title_up_ttc_currency").hide();
1345 jQuery(
"#np_marginRate, .np_marginRate").hide();
1348 jQuery(
"#np_markRate, .np_markRate").hide();
1350 jQuery(
"#units, #title_units").hide();
1351 jQuery(
"#buying_price").show();
1352 jQuery(
'#trlinefordates, .divlinefordates').show();
1361print
"<!-- END PHP TEMPLATE objectline_create.tpl.php -->\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
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.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
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.
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 a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
price2numjs(amount)
Function similar to PHP price2num()
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.