dolibarr 22.0.5
orderprinters.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
3 * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
4 * Copyright (C) 2006-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
6 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
8 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../../main.inc.php'; // Load $user and permissions
33require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
37
46$langs->loadLangs(array("main", "categories", "takepos", "printing"));
47
48$id = GETPOSTINT('id');
49$type = (GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT);
50$action = GETPOST('action', 'aZ09');
51$printer1 = GETPOST('printer1', 'alpha');
52$printer2 = GETPOST('printer2', 'alpha');
53$printer3 = GETPOST('printer3', 'alpha');
54
55$categstatic = new Categorie($db);
56
57if (is_numeric($type)) {
58 $type = array_search($type, $categstatic->MAP_ID); // For backward compatibility
59}
60
61// Security check
62if (!$user->admin) {
64}
65
66
67/*
68 * Actions
69 */
70
71if ($action == "SavePrinter1") {
72 $printedcategories = ";";
73 if (is_array($printer1)) {
74 foreach ($printer1 as $cat) {
75 $printedcategories = $printedcategories.$cat.";";
76 }
77 }
78 dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_1", $printedcategories, 'chaine', 0, '', $conf->entity);
79}
80
81if ($action == "SavePrinter2") {
82 $printedcategories = ";";
83 if (is_array($printer2)) {
84 foreach ($printer2 as $cat) {
85 $printedcategories = $printedcategories.$cat.";";
86 }
87 }
88 dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_2", $printedcategories, 'chaine', 0, '', $conf->entity);
89}
90
91if ($action == "SavePrinter3") {
92 $printedcategories = ";";
93 if (is_array($printer3)) {
94 foreach ($printer3 as $cat) {
95 $printedcategories = $printedcategories.$cat.";";
96 }
97 }
98 dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_3", $printedcategories, 'chaine', 0, '', $conf->entity);
99}
100
101
102/*
103 * View
104 */
105
106$categstatic = new Categorie($db);
107$form = new Form($db);
108
109$title = $langs->trans("Categories");
110$title .= ' ('.$langs->trans(empty(Categorie::$MAP_TYPE_TITLE_AREA[$type]) ? ucfirst($type) : Categorie::$MAP_TYPE_TITLE_AREA[$type]).')';
111
112$arrayofjs = array(
113 '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
114 '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js',
115);
116$arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
117
118llxHeader('', $title, '', '', 0, 0, $arrayofjs, $arrayofcss, '', 'mod-takepos page-admin_orderprinters');
119
120
121print load_fiche_titre($langs->trans("OrderPrinters"));
122
123//print '<table border="0" width="100%" class="notopnoleftnoright">';
124//print '<tr><td valign="top" width="30%" class="notopnoleft">';
125print '<div class="fichecenter"><div class="fichethirdleft">';
126
127print '</div><div class="fichetwothirdright">';
128
129print '</div></div>';
130
131
132print '<div class="fichecenter"><br>';
133
134
135// Charge tableau des categories
136$cate_arbo = $categstatic->get_full_arbo($type);
137
138// Define fulltree array
139$fulltree = $cate_arbo;
140
141// Define data (format for treeview)
142$data = array();
143$data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => "racine", 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => '');
144foreach ($fulltree as $key => $val) {
145 $categstatic->id = $val['id'];
146 $categstatic->ref = $val['label'];
147 $categstatic->color = $val['color'];
148 $categstatic->type = $type;
149
150 $li = $categstatic->getNomUrl(1, '', 60);
151
152 $desc = dol_htmlcleanlastbr($val['description']);
153
154 $data[] = array(
155 'rowid' => $val['rowid'],
156 'fk_menu' => empty($val['fk_menu']) ? 0 : $val['fk_menu'],
157 'fk_parent' => $val['fk_parent'],
158 'label' => $val['label']
159 );
160}
161
162//Printer1
163print '<table class="liste nohover" width="100%">';
164print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 1</td><td></td><td class="right">';
165print '</td></tr>';
166$nbofentries = (count($data) - 1);
167print '<form action="orderprinters.php">';
168print '<input type="hidden" name="token" value="'.newToken().'">';
169if ($nbofentries > 0) {
170 print '<tr class="pair"><td colspan="3">';
171 print '<input type="hidden" name="action" value="SavePrinter1">';
172 foreach ($data as $row) {
173 if (strpos(getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_1'), ';'.$row["rowid"].';') !== false) {
174 $checked = 'checked';
175 } else {
176 $checked = '';
177 }
178 if ($row["fk_menu"] >= 0) {
179 print '<input type="checkbox" name="printer1[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
180 }
181 }
182 print '</td></tr>';
183} else {
184 print '<tr class="pair">';
185 print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
186 print '<td valign="middle">';
187 print $langs->trans("NoCategoryYet");
188 print '</td>';
189 print '<td>&nbsp;</td>';
190 print '</table></td>';
191 print '</tr>';
192}
193print "</table>";
194print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form><br><br>';
195
196//Printer2
197print '<table class="liste nohover" width="100%">';
198print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 2</td><td></td><td class="right">';
199print '</td></tr>';
200$nbofentries = (count($data) - 1);
201print '<form action="orderprinters.php">';
202print '<input type="hidden" name="token" value="'.newToken().'">';
203if ($nbofentries > 0) {
204 print '<tr class="pair"><td colspan="3">';
205 print '<input type="hidden" name="action" value="SavePrinter2">';
206 foreach ($data as $row) {
207 if (strpos(getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_2'), ';'.$row["rowid"].';') !== false) {
208 $checked = 'checked';
209 } else {
210 $checked = '';
211 }
212 if ($row["fk_menu"] >= 0) {
213 print '<input type="checkbox" name="printer2[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
214 }
215 }
216 print '</td></tr>';
217} else {
218 print '<tr class="pair">';
219 print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
220 print '<td valign="middle">';
221 print $langs->trans("NoCategoryYet");
222 print '</td>';
223 print '<td>&nbsp;</td>';
224 print '</table></td>';
225 print '</tr>';
226}
227print "</table>";
228print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form>';
229
230//Printer3
231print '<table class="liste nohover" width="100%">';
232print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 3</td><td></td><td class="right">';
233print '</td></tr>';
234$nbofentries = (count($data) - 1);
235print '<form action="orderprinters.php">';
236print '<input type="hidden" name="token" value="'.newToken().'">';
237if ($nbofentries > 0) {
238 print '<tr class="pair"><td colspan="3">';
239 print '<input type="hidden" name="action" value="SavePrinter3">';
240 foreach ($data as $row) {
241 if (strpos(getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_3'), ';'.$row["rowid"].';') !== false) {
242 $checked = 'checked';
243 } else {
244 $checked = '';
245 }
246 if ($row["fk_menu"] >= 0) {
247 print '<input type="checkbox" name="printer3[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
248 }
249 }
250 print '</td></tr>';
251} else {
252 print '<tr class="pair">';
253 print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
254 print '<td valign="middle">';
255 print $langs->trans("NoCategoryYet");
256 print '</td>';
257 print '<td>&nbsp;</td>';
258 print '</table></td>';
259 print '</tr>';
260}
261
262print "</table>";
263print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form>';
264
265print '</div>';
266
267llxFooter();
268
269$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage categories.
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.