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