dolibarr 23.0.3
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
40require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
44
45$langs->loadLangs(array("main", "categories", "takepos", "printing"));
46
47$id = GETPOSTINT('id');
48$type = (GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT);
49$action = GETPOST('action', 'aZ09');
50$printer1 = GETPOST('printer1', 'alpha');
51$printer2 = GETPOST('printer2', 'alpha');
52$printer3 = GETPOST('printer3', 'alpha');
53
54$categstatic = new Categorie($db);
55
56if (is_numeric($type)) {
57 $type = array_search($type, $categstatic->MAP_ID); // For backward compatibility
58}
59
60if (!$user->hasRight('categorie', 'lire')) {
62}
63
64
65/*
66 * Actions
67 */
68
69if ($action == "SavePrinter1") {
70 $printedcategories = ";";
71 if (is_array($printer1)) {
72 foreach ($printer1 as $cat) {
73 $printedcategories = $printedcategories.$cat.";";
74 }
75 }
76 dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_1", $printedcategories, 'chaine', 0, '', $conf->entity);
77}
78
79if ($action == "SavePrinter2") {
80 $printedcategories = ";";
81 if (is_array($printer2)) {
82 foreach ($printer2 as $cat) {
83 $printedcategories = $printedcategories.$cat.";";
84 }
85 }
86 dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_2", $printedcategories, 'chaine', 0, '', $conf->entity);
87}
88
89if ($action == "SavePrinter3") {
90 $printedcategories = ";";
91 if (is_array($printer3)) {
92 foreach ($printer3 as $cat) {
93 $printedcategories = $printedcategories.$cat.";";
94 }
95 }
96 dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_3", $printedcategories, 'chaine', 0, '', $conf->entity);
97}
98
99
100/*
101 * View
102 */
103
104$categstatic = new Categorie($db);
105$form = new Form($db);
106
107$title = $langs->trans("Categories");
108$title .= ' ('.$langs->trans(empty(Categorie::$MAP_TYPE_TITLE_AREA[$type]) ? ucfirst($type) : Categorie::$MAP_TYPE_TITLE_AREA[$type]).')';
109
110$arrayofjs = array(
111 '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
112 '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js',
113);
114$arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
115
116llxHeader('', $title, '', '', 0, 0, $arrayofjs, $arrayofcss, '', 'mod-takepos page-admin_orderprinters');
117
118
119print load_fiche_titre($langs->trans("OrderPrinters"));
120
121//print '<table border="0" width="100%" class="notopnoleftnoright">';
122//print '<tr><td valign="top" width="30%" class="notopnoleft">';
123print '<div class="fichecenter"><div class="fichethirdleft">';
124
125print '</div><div class="fichetwothirdright">';
126
127print '</div></div>';
128
129
130print '<div class="fichecenter"><br>';
131
132
133// Charge tableau des categories
134$cate_arbo = $categstatic->get_full_arbo($type);
135
136// Define fulltree array
137$fulltree = $cate_arbo;
138
139// Define data (format for treeview)
140$data = array();
141$data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => "racine", 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => '');
142foreach ($fulltree as $key => $val) {
143 $categstatic->id = $val['id'];
144 $categstatic->ref = $val['label'];
145 $categstatic->color = $val['color'];
146 $categstatic->type = $type;
147
148 $li = $categstatic->getNomUrl(1, '', 60);
149
150 $desc = dol_htmlcleanlastbr($val['description']);
151
152 $data[] = array(
153 'rowid' => $val['rowid'],
154 'fk_menu' => empty($val['fk_menu']) ? 0 : $val['fk_menu'],
155 'fk_parent' => $val['fk_parent'],
156 'label' => $val['label']
157 );
158}
159
160//Printer1
161print '<table class="liste nohover" width="100%">';
162print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 1</td><td></td><td class="right">';
163print '</td></tr>';
164$nbofentries = (count($data) - 1);
165print '<form action="orderprinters.php">';
166print '<input type="hidden" name="token" value="'.newToken().'">';
167if ($nbofentries > 0) {
168 print '<tr class="pair"><td colspan="3">';
169 print '<input type="hidden" name="action" value="SavePrinter1">';
170 foreach ($data as $row) {
171 if (strpos(getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_1'), ';'.$row["rowid"].';') !== false) {
172 $checked = 'checked';
173 } else {
174 $checked = '';
175 }
176 if ($row["fk_menu"] >= 0) {
177 print '<input type="checkbox" name="printer1[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
178 }
179 }
180 print '</td></tr>';
181} else {
182 print '<tr class="pair">';
183 print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
184 print '<td valign="middle">';
185 print $langs->trans("NoCategoryYet");
186 print '</td>';
187 print '<td>&nbsp;</td>';
188 print '</table></td>';
189 print '</tr>';
190}
191print "</table>";
192print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form><br><br>';
193
194//Printer2
195print '<table class="liste nohover" width="100%">';
196print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 2</td><td></td><td class="right">';
197print '</td></tr>';
198$nbofentries = (count($data) - 1);
199print '<form action="orderprinters.php">';
200print '<input type="hidden" name="token" value="'.newToken().'">';
201if ($nbofentries > 0) {
202 print '<tr class="pair"><td colspan="3">';
203 print '<input type="hidden" name="action" value="SavePrinter2">';
204 foreach ($data as $row) {
205 if (strpos(getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_2'), ';'.$row["rowid"].';') !== false) {
206 $checked = 'checked';
207 } else {
208 $checked = '';
209 }
210 if ($row["fk_menu"] >= 0) {
211 print '<input type="checkbox" name="printer2[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
212 }
213 }
214 print '</td></tr>';
215} else {
216 print '<tr class="pair">';
217 print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
218 print '<td valign="middle">';
219 print $langs->trans("NoCategoryYet");
220 print '</td>';
221 print '<td>&nbsp;</td>';
222 print '</table></td>';
223 print '</tr>';
224}
225print "</table>";
226print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form>';
227
228//Printer3
229print '<table class="liste nohover" width="100%">';
230print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 3</td><td></td><td class="right">';
231print '</td></tr>';
232$nbofentries = (count($data) - 1);
233print '<form action="orderprinters.php">';
234print '<input type="hidden" name="token" value="'.newToken().'">';
235if ($nbofentries > 0) {
236 print '<tr class="pair"><td colspan="3">';
237 print '<input type="hidden" name="action" value="SavePrinter3">';
238 foreach ($data as $row) {
239 if (strpos(getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_3'), ';'.$row["rowid"].';') !== false) {
240 $checked = 'checked';
241 } else {
242 $checked = '';
243 }
244 if ($row["fk_menu"] >= 0) {
245 print '<input type="checkbox" name="printer3[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
246 }
247 }
248 print '</td></tr>';
249} else {
250 print '<tr class="pair">';
251 print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
252 print '<td valign="middle">';
253 print $langs->trans("NoCategoryYet");
254 print '</td>';
255 print '<td>&nbsp;</td>';
256 print '</table></td>';
257 print '</tr>';
258}
259
260print "</table>";
261print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form>';
262
263print '</div>';
264
265llxFooter();
266
267$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
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.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.