dolibarr 21.0.0-beta
objectline_create.tpl.php
1<?php
2/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2010-2014 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
5 * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
6 * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
7 * Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
8 * Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
9 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
10 * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
11 * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
12 * Copyright (C) 2022 OpenDSI <support@open-dsi.fr>
13 * Copyright (C) 2022 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
14 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program. If not, see <https://www.gnu.org/licenses/>.
28 *
29 * Need to have the following variables defined:
30 * $object (invoice, order, ...)
31 * $conf
32 * $langs
33 * $dateSelector
34 * $forceall (0 by default, 1 for supplier invoices/orders)
35 * $senderissupplier (0 by default, 1 or 2 for supplier invoices/orders)
36 * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
37 */
47// Protection to avoid direct call of template
48if (empty($object) || !is_object($object)) {
49 print "Error: this template page cannot be called directly as an URL";
50 exit;
51}
52
53'@phan-var-force CommonObject $this
54 @phan-var-force CommonObject $object';
55
56$usemargins = 0;
57if (isModEnabled('margin') && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande'))) {
58 $usemargins = 1;
59}
60if (!isset($dateSelector)) {
61 global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine)
62}
63global $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax;
64global $mysoc;
65
66if (!isset($dateSelector)) {
67 $dateSelector = 1; // For backward compatibility
68} elseif (empty($dateSelector)) {
69 $dateSelector = 0;
70}
71if (empty($forceall)) {
72 $forceall = 0;
73}
74if (empty($senderissupplier)) {
75 $senderissupplier = 0;
76}
77if (empty($inputalsopricewithtax)) {
78 $inputalsopricewithtax = 0;
79}
80// Define colspan for the button 'Add'
81$colspan = 3; // Columns: total ht + col edit + col delete
82if (isModEnabled("multicurrency") && $this->multicurrency_code != $conf->currency) {
83 $colspan++; //Add column for Total (currency) if required
84}
85if (in_array($object->element, array('propal', 'commande', 'order', 'facture', 'facturerec', 'invoice', 'supplier_proposal', 'order_supplier', 'invoice_supplier', 'invoice_supplier_rec'))) {
86 $colspan++; // With this, there is a column move button
87}
88if (isModEnabled('asset') && $object->element == 'invoice_supplier') {
89 $colspan++;
90}
91
92//print $object->element;
93// Lines for extrafield
94$objectline = null;
95if (!empty($extrafields)) {
96 if ($this->table_element_line == 'commandedet') {
97 $objectline = new OrderLine($this->db);
98 } elseif ($this->table_element_line == 'propaldet') {
99 $objectline = new PropaleLigne($this->db);
100 } elseif ($this->table_element_line == 'supplier_proposaldet') {
101 $objectline = new SupplierProposalLine($this->db);
102 } elseif ($this->table_element_line == 'facturedet') {
103 $objectline = new FactureLigne($this->db);
104 } elseif ($this->table_element_line == 'contratdet') {
105 $objectline = new ContratLigne($this->db);
106 } elseif ($this->table_element_line == 'commande_fournisseurdet') {
107 $objectline = new CommandeFournisseurLigne($this->db);
108 } elseif ($this->table_element_line == 'facture_fourn_det') {
109 $objectline = new SupplierInvoiceLine($this->db);
110 } elseif ($this->table_element_line == 'facturedet_rec') {
111 $objectline = new FactureLigneRec($this->db);
112 } elseif ($this->table_element_line == 'facture_fourn_det_rec') {
113 $objectline = new FactureFournisseurLigneRec($this->db);
114 }
115}
116print "<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->\n";
117$nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines);
118if ($nolinesbefore) {
119 ?>
120 <tr class="liste_titre<?php echo(($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_add_') ?> nodrag nodrop">
121 <?php if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) { ?>
122 <td class="linecolnum center"></td>
123 <?php } ?>
124 <td class="linecoldescription minwidth400imp">
125 <div id="add"></div><span class="hideonsmartphone"><?php echo $langs->trans('AddNewLine'); ?></span>
126 </td>
127 <?php
128 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
129 ?>
130 <td class="linecolrefsupplier"><span id="title_fourn_ref"><?php echo $langs->trans('SupplierRef'); ?></span></td>
131 <?php
132 } ?>
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>
137 <?php } ?>
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>
140 <?php } ?>
141 <td class="linecolqty right"><?php echo $langs->trans('Qty'); ?></td>
142 <?php
143 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
144 print '<td class="linecoluseunit left">';
145 print '<span id="title_units">';
146 print $langs->trans('Unit');
147 print '</span></td>';
148 } ?>
149 <td class="linecoldiscount right"><?php echo $langs->trans('ReductionShort'); ?></td>
150 <?php
151 // Fields for situation invoice
152 if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) {
153 print '<td class="linecolcycleref right">'.$langs->trans('Progress').'</td>';
154 if (getDolGlobalInt('INVOICE_USE_SITUATION') == 2) {
155 print '<td class="nobottom nowrap right"></td>';
156 }
157 print '<td class="linecolcycleref2 right"></td>';
158 }
159 if (!empty($usemargins)) {
160 if (!$user->hasRight('margins', 'creer')) {
161 $colspan++;
162 } else {
163 print '<td class="margininfos linecolmargin1 right">';
164 if (getDolGlobalString('MARGIN_TYPE') == "1") {
165 echo $langs->trans('BuyingPrice');
166 } else {
167 echo $langs->trans('CostPrice');
168 }
169 echo '</td>';
170 if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
171 echo '<td class="margininfos linecolmargin2 right"><span class="np_marginRate">'.$langs->trans('MarginRate').'</span></td>';
172 }
173 if (getDolGlobalString('DISPLAY_MARK_RATES')) {
174 echo '<td class="margininfos linecolmark1 right"><span class="np_markRate">'.$langs->trans('MarkRate').'</span></td>';
175 }
176 }
177 } ?>
178 <td class="linecoledit" colspan="<?php echo $colspan; ?>">&nbsp;</td>
179 </tr>
180 <?php
181}
182?>
183<tr class="pair nodrag nodrop nohoverpair<?php echo ($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_create'; ?>">
184 <?php
185 $coldisplay = 0;
186 // Adds a line numbering column
187 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
188 $coldisplay++;
189 echo '<td class="nobottom linecolnum center"></td>';
190 }
191 $coldisplay++;
192 ?>
193 <td class="nobottom linecoldescription minwidth400imp">
194 <?php
195 $freelines = false;
196 if (!getDolGlobalString('MAIN_DISABLE_FREE_LINES')) {
197 $freelines = true;
198 $forceall = 1; // We always force all type for free lines (module product or service means we use predefined product or service)
199 if ($object->element == 'contrat') {
200 if (!isModEnabled('product') && !isModEnabled('service') && !getDolGlobalString('CONTRACT_SUPPORT_PRODUCTS')) {
201 $forceall = -1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set
202 } elseif (!getDolGlobalString('CONTRACT_SUPPORT_PRODUCTS')) {
203 $forceall = 3;
204 }
205 }
206
207 // Select type of free line
208 $labelforempty = 1;
209 print '<span class="prod_entry_mode_free nowraponall">';
210 // Show radio for the non predefined product
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"';
214 //echo (GETPOST('prod_entry_mode')=='free' ? ' checked' : ((empty($forceall) && (!isModEnabled('product') || !isModEnabled('service')))?' checked':'') );
215 print((GETPOST('prod_entry_mode', 'alpha') == 'free' || getDolGlobalString('MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT')) ? ' checked' : '');
216 print '> ';
217 // Show type selector
218 $labelforempty = $langs->trans("FreeLineOfType").'...';
219 print '</label>';
220 } else {
221 echo '<input type="hidden" id="prod_entry_mode_free" name="prod_entry_mode" value="free">';
222 // Show type selector
223 if ($forceall >= 0) {
224 if (!isModEnabled('product') || !isModEnabled('service')) {
225 $labelforempty = $langs->trans("Type");
226 } else {
227 $labelforempty = $langs->trans("FreeLineOfType");
228 }
229 }
230 }
231
232 $form->select_type_of_lines(GETPOSTISSET("type") ? GETPOST("type", 'alpha', 2) : -1, 'type', $labelforempty, 1, $forceall, 'minwidth200', 0);
233 print '</span>';
234 }
235 // Predefined product/service
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">';
240 } else {
241 print '<span class="prod_entry_mode_predef">';
242 }
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' : '').'> ';
245 $labelforradio = '';
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');
251 } else {
252 $labelforradio = $langs->trans('PredefinedProductsAndServices');
253 }
254 } else {
255 $labelforradio = $langs->trans('PredefinedItem');
256 }
257 if (empty($senderissupplier)) { // TODO Move this into the placeholder
258 //print '<span class="textradioforitem">'.$labelforradio.'</span>';
259 }
260 print '</label>';
261 //print ' ';
262 $filtertype = '';
263 if (!empty($object->element) && $object->element == 'contrat' && !getDolGlobalString('CONTRACT_SUPPORT_PRODUCTS')) {
264 $filtertype = '1';
265 }
266 if (empty($senderissupplier)) {
267 $statustoshow = 1;
268 $statuswarehouse = 'warehouseopen,warehouseinternal';
269 if (getDolGlobalString('ENTREPOT_WAREHOUSEINTERNAL_NOT_SELL')) {
270 $statuswarehouse = 'warehouseopen';
271 }
272 if (getDolGlobalString('ENTREPOT_EXTRA_STATUS')) {
273 // hide products in closed warehouse, but show products for internal transfer
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'));
275 } else {
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'));
277 }
278 if (getDolGlobalString('MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS')) {
279 ?>
280 <script>
281 $(document).ready(function() {
282 // On first focus on a select2 combo, auto open the menu (this allow to use the keyboard only)
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')
286 {
287 console.log('open combo');
288 $('#idprod').select2('open');
289 }
290 });
291 });
292 </script>
293 <?php
294 }
295 } else {
296 // $senderissupplier=2 is the same as 1 but disables test on minimum qty, disable autofill qty with minimum and autofill unit price
297 if ($senderissupplier != 2) {
298 $ajaxoptions = array(
299 'update' => array('qty' => 'qty', 'remise_percent' => 'discount', 'idprod' => 'idprod'), // html id tags that will be edited with each ajax json response key
300 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done
301 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo)
302 );
303 $alsoproductwithnosupplierprice = 0;
304 } else {
305 $ajaxoptions = array(
306 // Disabled: This is useless because setting discount and price_ht after a selection is already managed
307 // by this page itself with a .change on the combolist '#idprodfournprice'
308 //'update' => array('remise_percent' => 'discount', 'price_ht' => 'price_ht') // html id tags that will be edited with each ajax json response key
309 );
310 $alsoproductwithnosupplierprice = 1;
311 }
312
313 $form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'minwidth100 maxwidth500 widthcentpercentminusx', $labelforradio);
314
315 if (getDolGlobalString('MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS')) {
316 ?>
317 <script>
318 $(document).ready(function(){
319 // On first focus on a select2 combo, auto open the menu (this allow to use the keyboard only)
320 $(document).on('focus', '.select2-selection.select2-selection--single', function (e) {
321 //console.log('focus on a select2 because of MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS');
322 if ($(this).attr('aria-labelledby') == 'select2-idprodfournprice-container')
323 {
324 $('#idprodfournprice').select2('open');
325 }
326 });
327 });
328 </script>
329 <?php
330 }
331 }
332
333 $parentId = GETPOSTINT('parentId');
334
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>';
342 echo '</a>';
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>';
346 echo '</div>';
347 echo '</div>';
348 } else {
349 if ($addproducton) {
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>';
352 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
353 // @FIXME Not working yet
354 $tmpbacktopagejsfields = 'addproduct:id,search_id';
355 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
356 print dolButtonToOpenUrlInDialogPopup('addproduct', $langs->transnoentitiesnoconv('AddProduct'), $newbutton, $url, '', '', $tmpbacktopagejsfields);
357 } else {
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>';
359 }
360 }
361 if ($addserviceon) {
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>';
364 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
365 // @FIXME Not working yet
366 $tmpbacktopagejsfields = 'addproduct:id,search_id';
367 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
368 print dolButtonToOpenUrlInDialogPopup('addproduct', $langs->transnoentitiesnoconv('AddService'), $newbutton, $url, '', '', $tmpbacktopagejsfields);
369 } else {
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>';
371 }
372 }
373 }
374 }
375 print '</span>';
376 ?>
377 <script>
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");
383 });
384 });
385 </script>
386 <?php
387
388 echo '<input type="hidden" name="pbq" id="pbq" value="">';
389 echo '</span>';
390 }
391
392 if (getDolGlobalString('MAIN_ADD_LINE_AT_POSITION')) {
393 echo '<br>'.$langs->trans('AddLineOnPosition').' : <input type="number" name="rank" step="1" min="0" style="width: 5em;">';
394 }
395
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;
401 }
402 }
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;
408 }
409 }
410 if (isModEnabled("product") || isModEnabled("service")) {
411 echo '<br>';
412 if (isModEnabled('variants')) {
413 echo '<div id="attributes_box"></div>';
414 }
415 }
416 // Editor wysiwyg
417 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
418 $nbrows = ROWS_2;
419 $enabled = getDolGlobalString('FCKEDITOR_ENABLE_DETAILS', '0');
420 if (getDolGlobalString('MAIN_INPUT_DESC_HEIGHT')) {
421 $nbrows = getDolGlobalString('MAIN_INPUT_DESC_HEIGHT');
422 }
423 $toolbarname = 'dolibarr_details';
424 if (getDolGlobalString('FCKEDITOR_ENABLE_DETAILS_FULL')) {
425 $toolbarname = 'dolibarr_notes';
426 }
427 $doleditor = new DolEditor('dp_desc', GETPOST('dp_desc', 'restricthtml'), '', getDolGlobalInt('MAIN_DOLEDITOR_HEIGHT', 100), $toolbarname, '', false, true, $enabled, $nbrows, '98%');
428 $doleditor->Create();
429 // Show autofill date for recurring invoices
430 if (isModEnabled("service") && ($object->element == 'facturerec' || $object->element == 'invoice_supplier_rec')) {
431 echo '<div class="divlinefordates"><br>';
432 echo $langs->trans('AutoFillDateFrom').' ';
433 if (getDolGlobalString('INVOICE_REC_DATE_TO_YES')) {
434 $line->date_start_fill = 1;
435 $line->date_end_fill = 1;
436 }
437 echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1);
438 echo ' - ';
439 echo $langs->trans('AutoFillDateTo').' ';
440 echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1);
441 echo '</div>';
442 }
443 if (is_object($objectline)) {
444 $temps = $objectline->showOptionals($extrafields, 'create', array(), '', '', 1, 'line');
445
446 if (!empty($temps)) {
447 print '<div style="padding-top: 10px" id="extrafield_lines_area_create" name="extrafield_lines_area_create">';
448 print $temps;
449 print '</div>';
450 }
451 }
452 echo '</td>';
453 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
454 $coldisplay++; ?>
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>
456 <?php
457 }
458 print '<td class="nobottom linecolvat right">';
459 $coldisplay++;
460 if ($object->element == 'propal' || $object->element == 'commande' || $object->element == 'facture' || $object->element == 'facturerec') {
461 $type_tva = 1;
462 } elseif ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier' || $object->element == 'invoice_supplier_rec') {
463 $type_tva = 2;
464 }
465 if ($seller->tva_assuj == "0") {
466 echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">'.vatrate('0', true);
467 } else {
468 echo $form->load_tva('tva_tx', (GETPOSTISSET("tva_tx") ? GETPOST("tva_tx", 'alpha', 2) : -1), $seller, $buyer, 0, 0, '', false, 1, $type_tva);
469 }
470 ?>
471 </td>
472
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) : ''); ?>">
475 </td>
476
477 <?php
478 if (isModEnabled("multicurrency") && $this->multicurrency_code != $conf->currency) {
479 $coldisplay++; ?>
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) : ''); ?>">
482 </td>
483 <?php
484 }
485 if (!empty($inputalsopricewithtax) && !getDolGlobalInt('MAIN_NO_INPUT_PRICE_WITH_TAX')) {
486 $coldisplay++; ?>
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) : ''); ?>">
489 </td>
490 <?php
491 }
492 $coldisplay++;
493 ?>
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); ?>">
497 </td>
498 <?php
499 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
500 $coldisplay++;
501 print '<td class="nobottom linecoluseunit left">';
502 print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, "units");
503 print '</td>';
504 }
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;
508 }
509 $coldisplay++;
510 ?>
511
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>
513 <?php
514 if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) {
515 $coldisplay++;
516 print '<td class="nobottom nowrap right"><input class="flat right" type="text" size="1" value="" name="progress"><span class="opacitymedium hideonsmartphone">%</span></td>';
517 if (getDolGlobalInt('INVOICE_USE_SITUATION') == 2) {
518 $coldisplay++;
519 print '<td class="nobottom nowrap right"></td>';
520 }
521 $coldisplay++;
522 print '<td></td>';
523 }
524 if (!empty($usemargins)) {
525 if ($user->hasRight('margins', 'creer')) {
526 $coldisplay++; ?>
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>
531 <?php } ?>
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) : ''); ?>">
534 </td>
535 <?php
536 if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
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>';
538 $coldisplay++;
539 }
540 if (getDolGlobalString('DISPLAY_MARK_RATES')) {
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>';
542 $coldisplay++;
543 }
544 }
545 }
546 $coldisplay += $colspan;
547 ?>
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">
550 </td>
551</tr>
552
553<?php
554if ((isModEnabled("service") || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') { // We show date field if required
555 print '<tr id="trlinefordates" class="oddeven">'."\n";
556 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
557 print '<td></td>';
558 }
559 print '<td colspan="'.($coldisplay - (!getDolGlobalString('MAIN_VIEW_LINE_NUMBER') ? 0 : 1)).'">';
560 $date_start = dol_mktime(GETPOSTINT('date_starthour'), GETPOSTINT('date_startmin'), 0, GETPOSTINT('date_startmonth'), GETPOSTINT('date_startday'), GETPOSTINT('date_startyear'));
561 $date_end = dol_mktime(GETPOSTINT('date_starthour'), GETPOSTINT('date_startmin'), 0, GETPOSTINT('date_endmonth'), GETPOSTINT('date_endday'), GETPOSTINT('date_endyear'));
562
563 $prefillDates = false;
564
565 if (getDolGlobalString('MAIN_FILL_SERVICE_DATES_FROM_LAST_SERVICE_LINE') && !empty($object->lines)) {
566 for ($i = count($object->lines) - 1; $i >= 0; $i--) {
567 $lastline = $object->lines[$i];
568
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;
572
573 $prefillDates = true;
574 break;
575 }
576 }
577 }
578
579 if (!empty($object->element) && $object->element == 'contrat') {
580 print $langs->trans("DateStartPlanned").' ';
581 print $form->selectDate($date_start, "date_start", $usehm, $usehm, 1, "addproduct");
582 print ' &nbsp; '.$langs->trans("DateEndPlanned").' ';
583 print $form->selectDate($date_end, "date_end", $usehm, $usehm, 1, "addproduct");
584 } else {
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);
589 }
590
591 if ($prefillDates) {
592 echo ' <span class="small"><a href="#" id="prefill_service_dates">'.$langs->trans('FillWithLastServiceDates').'</a></span>';
593 }
594
595 print '<script>';
596
597 if ($prefillDates) {
598 ?>
599 function prefill_service_dates()
600 {
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');
603
604 return false; // Prevent default link behaviour (which is go to href URL)
605 }
606
607 $(document).ready(function()
608 {
609 $('#prefill_service_dates').click(prefill_service_dates);
610 });
611
612 <?php
613 }
614
615 if (!$date_start) {
616 if (isset($conf->global->MAIN_DEFAULT_DATE_START_HOUR)) {
617 print 'jQuery("#date_starthour").val("' . getDolGlobalString('MAIN_DEFAULT_DATE_START_HOUR').'");';
618 }
619 if (isset($conf->global->MAIN_DEFAULT_DATE_START_MIN)) {
620 print 'jQuery("#date_startmin").val("' . getDolGlobalString('MAIN_DEFAULT_DATE_START_MIN').'");';
621 }
622 }
623 if (!$date_end) {
624 if (isset($conf->global->MAIN_DEFAULT_DATE_END_HOUR)) {
625 print 'jQuery("#date_endhour").val("' . getDolGlobalString('MAIN_DEFAULT_DATE_END_HOUR').'");';
626 }
627 if (isset($conf->global->MAIN_DEFAULT_DATE_END_MIN)) {
628 print 'jQuery("#date_endmin").val("' . getDolGlobalString('MAIN_DEFAULT_DATE_END_MIN').'");';
629 }
630 }
631 print '</script>';
632 print '</td>';
633 print '</tr>'."\n";
634}
635
636
637print "<script>\n";
638
639if (!empty($usemargins) && $user->hasRight('margins', 'creer')) {
640 ?>
641 /* Some js test when we click on button "Add" */
642 jQuery(document).ready(function() {
643 <?php
644 if (getDolGlobalString('DISPLAY_MARGIN_RATES')) { ?>
645 $("input[name='np_marginRate']:first").blur(function(e) {
646 console.log("np_marginRate blur");
647 return checkFreeLine(e, "np_marginRate");
648 });
649 <?php
650 }
651 if (getDolGlobalString('DISPLAY_MARK_RATES')) { ?>
652 $("input[name='np_markRate']:first").blur(function(e) {
653 console.log("np_markRate blur");
654 return checkFreeLine(e, "np_markRate");
655 });
656 <?php
657 } ?>
658 });
659
660 /* TODO This does not work for number with thousand separator that is , */
661 function checkFreeLine(e, npRate)
662 {
663 var buying_price = $("input[name='buying_price']:first");
664 var remise = $("input[name='remise_percent']:first");
665
666 var rate = $("input[name='"+npRate+"']:first");
667 if (rate.val() == '')
668 return true;
669
670 if (! $.isNumeric(rate.val().replace(',','.')))
671 {
672 alert('<?php echo dol_escape_js($langs->trans("rateMustBeNumeric")); ?>');
673 e.stopPropagation();
674 setTimeout(function () { rate.focus() }, 50);
675 return false;
676 }
677 if (npRate == "np_markRate" && rate.val() >= 100)
678 {
679 alert('<?php echo dol_escape_js($langs->trans("markRateShouldBeLesserThan100")); ?>');
680 e.stopPropagation();
681 setTimeout(function () { rate.focus() }, 50);
682 return false;
683 }
684
685 var price = 0;
686 remisejs=price2numjs(remise.val());
687
688 if (remisejs != 100) // If a discount not 100 or no discount
689 {
690 if (remisejs == '') remisejs=0;
691
692 bpjs=price2numjs(buying_price.val());
693 ratejs=price2numjs(rate.val());
694
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));
699 }
700
701 $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formatted value
702
703 return true;
704 }
705
706 <?php
707}
708?>
709
710 /* Function to set focus on description */
711 function setFocusOnDescription() {
712 console.log("Set focus on description field");
713 /* this focus code works on a standard textarea but not if field was replaced with CKEDITOR */
714 jQuery('#dp_desc').focus();
715 /* this focus code works for CKEDITOR */
716 if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined") {
717 var editor = CKEDITOR.instances['dp_desc'];
718 if (editor) {
719 editor.focus();
720 }
721 }
722 }
723
724
725 /* JQuery for product free or predefined select */
726 jQuery(document).ready(function() {
727 jQuery("#price_ht").keyup(function(event) {
728 // console.log(event.which); // discard event tag and arrows
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('');
733 }
734 });
735
736 jQuery("#price_ttc").keyup(function(event) {
737 // console.log(event.which); // discard event tag and arrows
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('');
742 }
743 });
744 jQuery("#multicurrency_subprice").keyup(function(event) {
745 // console.log(event.which); // discard event tag and arrows
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('');
749 }
750 });
751 jQuery("#multicurrency_price_ht").keyup(function(event) {
752 // console.log(event.which); // discard event tag and arrows
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('');
756 }
757 });
758
759 $("#select_type").change(function()
760 {
761 setforfree();
762
763 console.log("Hide/show date according to product type select_type="+jQuery('#select_type').val());
764 if (jQuery('#select_type').val() == '0')
765 {
766 jQuery('#trlinefordates').hide();
767 jQuery('.divlinefordates').hide();
768 }
769 else
770 {
771 jQuery('#trlinefordates').show();
772 jQuery('.divlinefordates').show();
773 }
774
775 if (jQuery("#select_type").val() != '-1') {
776 console.log("we remove class");
777 jQuery("#select_type").removeClass("placeholder");
778 setFocusOnDescription();
779 } else {
780 console.log("we add class");
781 jQuery("#select_type").addClass("placeholder");
782 }
783 });
784
785 $("#prod_entry_mode_free").on( "click", function() {
786 setforfree();
787 });
788
789 $("#prod_entry_mode_predef").on( "click", function() {
790 console.log("click prod_entry_mode_predef");
791 jQuery("#select_type").addClass("placeholder");
792 setforpredef();
793 jQuery('#trlinefordates').show();
794 });
795
796 <?php
797 if (!$freelines) { ?>
798 jQuery("#prod_entry_mode_predef").click();
799 <?php
800 } else { ?>
801 jQuery("#select_type").addClass("placeholder");
802 <?php
803 }
804
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');
813 }else{
814 $(this).removeClass('inputmandatory');
815 }
816 }
817 });
818 <?php
819 } ?>
820
821 /* When changing predefined product, we reload list of supplier prices required for margin combo */
822 $("#idprod, #idprodfournprice").change(function()
823 {
824 console.log("objectline_create.tpl Call method change() after change on #idprod or #idprodfournprice (senderissupplier=<?php echo $senderissupplier; ?>). this.val = "+$(this).val());
825
826 setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva(product)
827
828 jQuery('#trlinefordates').show();
829
830 <?php
831 if (!getDolGlobalString('MAIN_DISABLE_EDIT_PREDEF_PRICEHT') && empty($senderissupplier)) {
832 ?>
833 var pbq = parseInt($('option:selected', this).attr('data-pbq')); /* If product was selected with a HTML select */
834 if (isNaN(pbq)) { pbq = jQuery('#idprod').attr('data-pbq'); } /* If product was selected with a HTML input with autocomplete */
835
836 if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0)
837 {
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");
839 } else {
840 <?php if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) { ?>
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"); }
842 <?php } ?>
843 // Get the price for the product and display it
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 },
847 function(data) {
848 console.log("objectline_create.tpl Load unit price ends, we got value ht="+data.price_ht+" ttc="+data.price_ttc+" pricebasetype="+data.pricebasetype);
849
850 $('#date_start').removeAttr('type');
851 $('#date_end').removeAttr('type');
852 $('#date_start').attr('type', data.type);
853 $('#date_end').attr('type', data.type);
854
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);
859
860 // service and we set mandatory_period to true
861 if (data.mandatory_period == 1 && data.type == 1) {
862 jQuery('#date_start').addClass('inputmandatory');
863 jQuery('#date_end').addClass('inputmandatory');
864 } else {
865 jQuery('#date_start').removeClass('inputmandatory');
866 jQuery('#date_end').removeClass('inputmandatory');
867 }
868
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);
872 } else {
873 console.log("objectline_create.tpl set content of price_ht");
874 jQuery("#price_ht").val(data.price_ht);
875 }
876
877 // Set values for any fields in the form options_SOMETHING
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]);
884 }
885 }
886 }
887
888 var tva_tx = data.tva_tx;
889 var default_vat_code = data.default_vat_code;
890
891 // Now set the VAT
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+')';
895 <?php
896 // Special case for India
897 if (getDolGlobalString('MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA')) {
898 ?>
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;
902 <?php
903 if ($mysoc->country_code == 'IN' && !empty($object->thirdparty) && $object->thirdparty->country_code == 'IN' && $mysoc->state_code == $object->thirdparty->state_code) {
904 // We are in India and states are same, we revert the vat code "I-x" into "CS-x"
905 ?>
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-');
908 <?php
909 } elseif ($mysoc->country_code == 'IN' && !empty($object->thirdparty) && $object->thirdparty->country_code == 'IN' && $mysoc->state_code != $object->thirdparty->state_code) {
910 // We are in India and states differs, we revert the vat code "CS-x" into "I-x"
911 ?>
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-');
914 <?php
915 } ?>
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();
919 }
920 <?php
921 } ?>
922 }
923 // Set vat rate if field is an input box
924 $('#tva_tx').val(tva_tx);
925 // Set vat rate by selecting the combo
926 //$('#tva_tx option').val(tva_tx); // This is bugged, it replaces the vat key of all options
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);
930
931 <?php
932 if (getDolGlobalInt('PRODUIT_AUTOFILL_DESC') == 1) {
933 if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) { ?>
934 var proddesc = data.desc_trans;
935 <?php
936 } else { ?>
937 var proddesc = data.desc;
938 <?php
939 } ?>
940 console.log("objectline_create.tpl Load description into text area : "+proddesc);
941 <?php
942 if (getDolGlobalString('FCKEDITOR_ENABLE_DETAILS')) { ?>
943 if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
944 {
945 var editor = CKEDITOR.instances['dp_desc'];
946 if (editor) {
947 editor.setData(proddesc);
948 }
949 }
950 <?php
951 } else { ?>
952 jQuery('#dp_desc').text(proddesc);
953 <?php
954 } ?>
955 <?php
956 } ?>
957 <?php
958 if (getDolGlobalString('PRODUCT_LOAD_EXTRAFIELD_INTO_OBJECTLINES')) { ?>
959 jQuery.each(data.array_options, function( key, value ) {
960 jQuery('div[class*="det'+key.replace('options_','_extras_')+'"] > #'+key).val(value);
961 });
962 <?php
963 } ?>
964 },
965 'json'
966 );
967 }
968 <?php
969 }
970
971 if (!empty($usemargins) && $user->hasRight('margins', 'creer')) {
972 $langs->load('stocks'); ?>
973
974 /* Code for margin */
975 $("#fournprice_predef").find("option").remove();
976 $("#fournprice_predef").hide();
977 $("#buying_price").val("").show();
978
979 /* Call post to load content of combo list fournprice_predef */
980 var token = '<?php echo currentToken(); ?>'; // For AJAX Call we use old 'token' and not 'newtoken'
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)
983 {
984 var options = ''; var defaultkey = ''; var defaultprice = ''; var bestpricefound = 0;
985
986 var bestpriceid = 0; var bestpricevalue = 0;
987 var pmppriceid = 0; var pmppricevalue = 0;
988 var costpriceid = 0; var costpricevalue = 0;
989
990 /* setup of margin calculation */
991 var defaultbuyprice = '<?php
992 if (isset($conf->global->MARGIN_TYPE)) {
993 if (getDolGlobalString('MARGIN_TYPE') == '1') {
994 print 'bestsupplierprice';
995 }
996 if (getDolGlobalString('MARGIN_TYPE') == 'pmp') {
997 print 'pmp';
998 }
999 if (getDolGlobalString('MARGIN_TYPE') == 'costprice') {
1000 print 'costprice';
1001 }
1002 } ?>';
1003 console.log("objectline_create.tpl we will set the field for margin. defaultbuyprice="+defaultbuyprice);
1004
1005 var i = 0;
1006 $(data).each(function() {
1007 /* Warning: Lines must be processed in order: best supplier price, then pmpprice line then costprice */
1008 if (this.id != 'pmpprice' && this.id != 'costprice')
1009 {
1010 i++;
1011 this.price = parseFloat(this.price); // to fix when this.price >0
1012 // If margin is calculated on best supplier price, we set it by default (but only if value is not 0)
1013 //console.log("id="+this.id+"-price="+this.price+"-"+(this.price > 0));
1014 if (bestpricefound == 0 && this.price > 0) { defaultkey = this.id; defaultprice = this.price; bestpriceid = this.id; bestpricevalue = this.price; bestpricefound=1; } // bestpricefound is used to take the first price > 0
1015 }
1016 if (this.id == 'pmpprice')
1017 {
1018 // If margin is calculated on PMP, we set it by default (but only if value is not 0)
1019 console.log("id="+this.id+"-price="+this.price);
1020 if ('pmp' == defaultbuyprice || 'costprice' == defaultbuyprice)
1021 {
1022 if (this.price > 0) {
1023 defaultkey = this.id; defaultprice = this.price; pmppriceid = this.id; pmppricevalue = this.price;
1024 //console.log("pmppricevalue="+pmppricevalue);
1025 }
1026 }
1027 }
1028 if (this.id == 'costprice')
1029 {
1030 // If margin is calculated on Cost price, we set it by default (but only if value is not 0)
1031 console.log("id="+this.id+"-price="+this.price+"-pmppricevalue="+pmppricevalue);
1032 if ('costprice' == defaultbuyprice)
1033 {
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; }
1036 }
1037 }
1038 options += '<option value="'+this.id+'" price="'+this.price+'">'+this.label+'</option>';
1039 });
1040 options += '<option value="inputprice" price="'+defaultprice+'"><?php echo dol_escape_js($langs->trans("InputPrice").'...'); ?></option>';
1041
1042 console.log("finally selected defaultkey="+defaultkey+" defaultprice for buying price="+defaultprice);
1043
1044 $("#fournprice_predef").html(options).show();
1045 if (defaultkey != '')
1046 {
1047 $("#fournprice_predef").val(defaultkey);
1048 }
1049
1050 /* At loading, no product are yet selected, so we hide field of buying_price */
1051 $("#buying_price").hide();
1052
1053 /* Define default price at loading */
1054 var defaultprice = $("#fournprice_predef").find('option:selected').attr("price");
1055 $("#buying_price").val(defaultprice);
1056
1057 $("#fournprice_predef").change(function() {
1058 console.log("change on fournprice_predef");
1059 /* Hide field buying_price according to choice into list (if 'inputprice' or not) */
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(); /* We set value then hide field */
1064 }
1065 if (linevalue == 'inputprice') {
1066 $('#buying_price').show();
1067 }
1068 if (linevalue == 'pmpprice') {
1069 $("#buying_price").val(pricevalue);
1070 $('#buying_price').hide();
1071 }
1072 });
1073 }
1074 },
1075 'json');
1076
1077 <?php
1078 }
1079 ?>
1080
1081 <?php
1082 if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
1083 ?>
1084 /* To process customer price per quantity (PRODUIT_CUSTOMER_PRICES_BY_QTY works only if combo product is not an ajax after x key pressed) */
1085 var pbq = parseInt($('option:selected', this).attr('data-pbq')); // When select is done from HTML select
1086 if (isNaN(pbq)) { pbq = jQuery('#idprod').attr('data-pbq'); } // When select is done from HTML input with autocomplete
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'); }
1095
1096 if ((jQuery('#idprod').val() > 0) && ! isNaN(pbq) && pbq > 0)
1097 {
1098 var pbqupht = pbqup; /* TODO support of price per qty TTC not yet available */
1099
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)
1104 {
1105 jQuery("#qty").val(pbqqty);
1106 }
1107 if (jQuery("#remise_percent").val() < pbqpercent)
1108 {
1109 jQuery("#remise_percent").val(pbqpercent);
1110 }
1111 } else { jQuery("#pbq").val(''); }
1112 <?php
1113 }
1114 ?>
1115
1116
1117 // Deal with supplier ref price (idprodfournprice = int)
1118 if (jQuery('#idprodfournprice').val() > 0)
1119 {
1120 console.log("objectline_create.tpl #idprodfournprice is an ID > 0, so we set some properties into page");
1121
1122 var up = parseFloat($('option:selected', this).attr('data-up')); // When select is done from HTML select
1123 if (isNaN(up)) { up = parseFloat(jQuery('#idprodfournprice').attr('data-up'));} // When select is done from HTML input with ajax autocomplete
1124
1125 var up_locale = $('option:selected', this).attr('data-up-locale'); // When select is done from HTML select
1126 if (typeof up_locale === 'undefined') { up_locale = jQuery('#idprodfournprice').attr('data-up-locale');} // When select is done from HTML input with ajax autocomplete
1127
1128 var qty = parseFloat($('option:selected', this).attr('data-qty'));
1129 if (isNaN(qty)) { qty = parseFloat(jQuery('#idprodfournprice').attr('data-qty'));}
1130
1131 var discount = parseFloat($('option:selected', this).attr('data-discount'));
1132 if (isNaN(discount)) { discount = parseFloat(jQuery('#idprodfournprice').attr('data-discount'));}
1133
1134 var tva_tx = parseFloat($('option:selected', this).attr('data-tvatx')); // When select is done from HTML select
1135 if (isNaN(tva_tx)) { tva_tx = parseFloat(jQuery('#idprodfournprice').attr('data-tvatx'));} // When select is done from HTML input with ajax autocomplete
1136
1137 var default_vat_code = $('option:selected', this).attr('data-default-vat-code'); // When select is done from HTML select
1138 if (typeof default_vat_code === 'undefined') { default_vat_code = jQuery('#idprodfournprice').attr('data-default-vat-code');} // When select is done from HTML input with ajax autocomplete
1139
1140 var supplier_ref = $('option:selected', this).attr('data-supplier-ref'); // When select is done from HTML select
1141 if (typeof supplier_ref === 'undefined') { supplier_ref = jQuery('#idprodfournprice').attr('data-supplier-ref'); } // When select is done from HTML input with ajax autocomplete
1142
1143 <?php if (($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier' || $object->element == 'invoice_supplier_rec') && !$seller->tva_assuj) { ?>
1144 if (tva_tx != .0) {
1145 tva_tx = .0;
1146 default_vat_code = null;
1147 }
1148 <?php } ?>
1149
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+')';
1153 }
1154
1155 var has_multicurrency_up = false;
1156 <?php
1157 if (isModEnabled('multicurrency') && $object->multicurrency_code != $conf->currency) {
1158 ?>
1159 var object_multicurrency_code = '<?php print dol_escape_js($object->multicurrency_code); ?>';
1160
1161 var multicurrency_code = $('option:selected', this).attr('data-multicurrency-code'); // When select is done from HTML select
1162 if (multicurrency_code == undefined) { multicurrency_code = jQuery('#idprodfournprice').attr('data-multicurrency-code'); } // When select is done from HTML input with ajax autocomplete
1163
1164 var multicurrency_up = parseFloat($('option:selected', this).attr('data-multicurrency-unitprice')); // When select is done from HTML select
1165 if (isNaN(multicurrency_up)) { multicurrency_up = parseFloat(jQuery('#idprodfournprice').attr('data-multicurrency-unitprice')); } // When select is done from HTML input with ajax autocomplete
1166
1167 if (multicurrency_code == object_multicurrency_code) {
1168 has_multicurrency_up = true;
1169 jQuery("#multicurrency_price_ht").val(multicurrency_up);
1170 }
1171
1172 console.log("objectline_create.tpl Multicurrency values : object_multicurrency_code = "+object_multicurrency_code+", multicurrency_code = "+multicurrency_code+", multicurrency_up = "+multicurrency_up);
1173 <?php
1174 }
1175 ?>
1176
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());
1178
1179 if (has_multicurrency_up === false) {
1180 if (typeof up_locale === 'undefined') {
1181 jQuery("#price_ht").val(up);
1182 } else {
1183 jQuery("#price_ht").val(up_locale);
1184 }
1185 }
1186
1187 // Set supplier_ref
1188 $('#fourn_ref').val(supplier_ref);
1189 // Set vat rate if field is an input box
1190 $('#tva_tx').val(tva_tx);
1191 // Set vat rate by selecting the combo
1192 //$('#tva_tx option').val(tva_tx); // This is bugged, it replaces the vat key of all options
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);
1196
1197 if (jQuery("#qty").val() < qty) {
1198 jQuery("#qty").val(qty);
1199 }
1200 if (jQuery("#remise_percent").val() < discount) {
1201 jQuery("#remise_percent").val(discount);
1202 }
1203
1204 <?php
1205 if (getDolGlobalInt('PRODUIT_AUTOFILL_DESC') == 1) {
1206 ?>
1207 var description = $('option:selected', this).attr('data-description');
1208 if (typeof description == 'undefined') { description = jQuery('#idprodfournprice').attr('data-description'); }
1209
1210 console.log("Load description into text area : "+description);
1211 <?php
1212 if (getDolGlobalString('FCKEDITOR_ENABLE_DETAILS')) {
1213 ?>
1214 if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
1215 {
1216 var editor = CKEDITOR.instances['dp_desc'];
1217 if (editor) {
1218 editor.setData(description);
1219 }
1220 }
1221 <?php
1222 } else {
1223 ?>
1224 jQuery('#dp_desc').text(description);
1225 <?php
1226 }
1227 }
1228 ?>
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");
1231
1232 var tva_tx = parseFloat($('option:selected', this).attr('data-tvatx')); // When select is done from HTML select
1233 if (isNaN(tva_tx)) { tva_tx = parseFloat(jQuery('#idprodfournprice').attr('data-tvatx'));} // When select is done from HTML input with ajax autocomplete
1234
1235 var default_vat_code = $('option:selected', this).attr('data-default-vat-code'); // When select is done from HTML select
1236 if (typeof default_vat_code === 'undefined') { default_vat_code = jQuery('#idprodfournprice').attr('data-default-vat-code');} // When select is done from HTML input with ajax autocomplete
1237
1238 var supplier_ref = $('option:selected', this).attr('data-supplier-ref'); // When select is done from HTML select
1239 if (typeof supplier_ref === 'undefined') { supplier_ref = jQuery('#idprodfournprice').attr('data-supplier-ref'); } // When select is done from HTML input with ajax autocomplete
1240
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+')';
1244 }
1245
1246
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());
1248
1249 // Set supplier_ref
1250 $('#fourn_ref').val(supplier_ref);
1251 // Set vat rate if field is an input box
1252 $('#tva_tx').val(tva_tx);
1253 // Set vat rate by selecting the combo
1254 //$('#tva_tx option').val(tva_tx); // This is bugged, it replaces the vat key of all options
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);
1258 <?php
1259 if (getDolGlobalInt('PRODUIT_AUTOFILL_DESC') == 1) {
1260 if (getDolGlobalString('FCKEDITOR_ENABLE_DETAILS')) {
1261 ?>
1262 if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
1263 {
1264 var editor = CKEDITOR.instances['dp_desc'];
1265 if (editor) {
1266 editor.setData('');
1267 }
1268 }
1269 <?php
1270 } else {
1271 ?>
1272 jQuery('#dp_desc').text('');
1273 <?php
1274 }
1275 }
1276 ?>
1277 }
1278
1279
1280 /* To set focus */
1281 if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0)
1282 {
1283 console.log("Try to set focus on desc");
1284 /* this focus code works on a standard textarea but not if field was replaced with CKEDITOR */
1285 jQuery('#dp_desc').focus();
1286 /* this focus code works for CKEDITOR */
1287 if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
1288 {
1289 var editor = CKEDITOR.instances['dp_desc'];
1290 if (editor) {
1291 editor.focus();
1292 }
1293 }
1294 }
1295 });
1296
1297 <?php if (GETPOST('prod_entry_mode') == 'predef') { // When we submit with a predef product and it fails we must start with predef?>
1298 setforpredef();
1299 <?php } ?>
1300
1301 });
1302
1303 /* Function to set fields visibility after selecting a free product */
1304 function setforfree() {
1305 console.log("objectline_create.tpl::setforfree. We show most fields");
1306 jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product
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();
1313 }
1314
1315 function setforpredef() {
1316 console.log("objectline_create.tpl::setforpredef We hide some fields, show dates");
1317
1318 jQuery("#select_type").val(-1);
1319 jQuery("#select_type").addClass("placeholder");
1320 /* jQuery("#select_type").trigger("change"); // Disabled. This create troubles. Never mind if the rester of combo is not done when using an ajax select_type combo. We don't use it because we are not able to call a focus on a change event of this combo. */
1321
1322 jQuery("#prod_entry_mode_free").prop('checked',false).change();
1323 jQuery("#prod_entry_mode_predef").prop('checked',true).change();
1324 <?php if (!getDolGlobalString('MAIN_DISABLE_EDIT_PREDEF_PRICEHT')) { ?>
1325 jQuery("#price_ht").val('').show();
1326 jQuery("#multicurrency_price_ht").val('').show();
1327 jQuery("#title_up_ht, #title_up_ht_currency").show();
1328 <?php } else { ?>
1329 //jQuery("#price_ht").val('').hide();
1330 jQuery("#multicurrency_price_ht").val('').hide();
1331 jQuery("#title_up_ht, #title_up_ht_currency").hide();
1332 <?php } ?>
1333 <?php if (!getDolGlobalString('MAIN_DISABLE_EDIT_PREDEF_PRICETTC')) { ?>
1334 jQuery("#price_ttc").val('').show();
1335 jQuery("#multicurrency_price_ttc").val('').show();
1336 jQuery("#title_up_ttc, #title_up_ttc_currency").show();
1337 <?php } else { ?>
1338 jQuery("#price_ttc").val('').hide();
1339 jQuery("#multicurrency_price_ttc").val('').hide();
1340 jQuery("#title_up_ttc, #title_up_ttc_currency").hide();
1341 <?php } ?>
1342 /* jQuery("#tva_tx, #title_vat").hide(); */
1343 /* jQuery("#title_fourn_ref").hide(); */
1344 <?php if (!getDolGlobalString('DISPLAY_MARGIN_RATES')) { ?>
1345 jQuery("#np_marginRate, .np_marginRate").hide();
1346 <?php } ?>
1347 <?php if (!getDolGlobalString('DISPLAY_MARK_RATES')) { ?>
1348 jQuery("#np_markRate, .np_markRate").hide();
1349 <?php } ?>
1350 jQuery("#units, #title_units").hide();
1351 jQuery("#buying_price").show();
1352 jQuery('#trlinefordates, .divlinefordates').show();
1353 }
1354
1355<?php
1356
1357print '</script>';
1358
1359//print '<span onclick="setFocusOnDescription();">Click</span>';
1360
1361print "<!-- END PHP TEMPLATE objectline_create.tpl.php -->\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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...
Definition member.php:79
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:149
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:152