dolibarr 24.0.0-beta
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 '/public/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
112 '/public/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js',
113);
114$arrayofcss = array('/public/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>';
193print '<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>';
228print '<br><br>';
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: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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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.