dolibarr 24.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) 2024 Vincent Maury <vmaury@timgroup.fr>
12 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
13 * Copyright (C) 2025 Nick Fragoulis
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <https://www.gnu.org/licenses/>.
27 *
28 * Need to have the following variables defined:
29 * $object (invoice, order, ...)
30 * $conf
31 * $langs
32 * $forceall (0 by default, 1 for supplier invoices/orders)
33 */
34
35require_once DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php";
36
45// Protection to avoid direct call of template
46if (empty($object) || !is_object($object)) {
47 print "Error: this template page cannot be called directly as an URL";
48 exit;
49}
50
51'
52@phan-var-force CommonObject $this
53@phan-var-force CommonObject $object
54@phan-var-force Societe $buyer
55';
56
57global $forceall, $forcetoshowtitlelines, $filtertype;
58
59if (empty($forceall)) {
60 $forceall = 0;
61}
62
63if (empty($filtertype)) {
64 $filtertype = 0;
65}
66
67$formproduct = new FormProduct($object->db);
68
69// Define colspan for the button 'Add'
70$colspan = 3;
71
72
73// Lines for extrafield
74$objectline = new ReceptionLineBatch($this->db);
75
76print "<!-- BEGIN PHP TEMPLATE reception/tpl/objectline_create.tpl.php -->\n";
77
78$nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines);
79
80if ($nolinesbefore) {
81 print '<tr class="liste_titre nodrag nodrop">';
82 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
83 print '<td class="linecolnum center"></td>';
84 }
85 print '<td class="linecoldescription minwidth500imp">';
86 print '<div id="add"></div><span class="hideonsmartphone">'.$langs->trans('AddNewLine').'</span>';
87 print '</td>';
88 print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
89
90 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
91 print '<td class="linecoluseunit left">';
92 print '<span id="title_units">';
93 print $langs->trans('Unit');
94 print '</span></td>';
95 }
96
97 print '</tr>';
98}
99
100print '<tr class="pair nodrag nodrop nohoverpair'.(($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_create').'">';
101$coldisplay = 0;
102
103// Adds a line numbering column
104if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
105 $coldisplay++;
106 echo '<td class="bordertop nobottom linecolnum center"></td>';
107}
108
109// Product
110$coldisplay++;
111print '<td class="bordertop nobottom linecoldescription line minwidth500imp">';
112
113// Predefined product/service
114if (isModEnabled("product")) {
115 if ($filtertype == 1) {
116 print $langs->trans("Service");
117 } else {
118 print $langs->trans("Product");
119 }
120
121 echo '<span class="prod_entry_mode_predef nowraponall">';
122
123 $statustoshow = -1;
124
125 echo '</span>';
126}
127
128
129if (!empty($extrafields)) {
130 $temps = $objectline->showOptionals($extrafields, 'create', array(), '', '', '1', 'line');
131
132 if (!empty($temps)) {
133 print '<div style="padding-top: 10px" id="extrafield_lines_area_create" name="extrafield_lines_area_create">';
134 print $temps;
135 print '</div>';
136 }
137}
138print '</td>';
139
140// Qty
141$coldisplay++;
142print '<td class="bordertop nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="'.(GETPOSTISSET("qty") ? GETPOST("qty", 'alpha', 2) : 1).'">';
143print '</td>';
144
145// Unit
146if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
147 $coldisplay++;
148 print '<td class="nobottom linecoluseunit">';
149 print '</td>';
150}
151
152$coldisplay += $colspan;
153print '<td class="bordertop nobottom linecoledit right valignmiddle" colspan="' . $colspan . '">';
154print '<input type="submit" class="button button-add small" name="addline" id="addline" value="' . $langs->trans('Add') . '">';
155print '</td>';
156print '</tr>';
157
158?>
159
160<script>
161
162/* JQuery for product free or predefined select */
163jQuery(document).ready(function() {
164 /* When changing predefined product, we reload list of supplier prices required for margin combo */
165 $("#idprod").change(function()
166 {
167 console.log("#idprod change triggered");
168
169 /* To set focus */
170 if (jQuery('#idprod').val() > 0)
171 {
172 /* focus work on a standard textarea but not if field was replaced with CKEDITOR */
173 jQuery('#dp_desc').focus();
174 /* focus if CKEDITOR */
175 if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
176 {
177 var editor = CKEDITOR.instances['dp_desc'];
178 if (editor) { editor.focus(); }
179 }
180 }
181 });
182});
183
184</script>
185
186<!-- END PHP TEMPLATE objectline_create.tpl.php -->
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class with static methods for building HTML components related to products Only components common to ...
Class to manage table commandefournisseurdispatch.
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.
isModEnabled($module)
Is Dolibarr module enabled.