dolibarr 21.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
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$catname = GETPOST('catname', 'alpha');
51$action = GETPOST('action', 'aZ09');
52$printer1 = GETPOST('printer1', 'alpha');
53$printer2 = GETPOST('printer2', 'alpha');
54$printer3 = GETPOST('printer3', 'alpha');
55
56if (is_numeric($type)) {
57 $type = Categorie::$MAP_ID_TO_CODE[(int) $type]; // 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
107if ($type == Categorie::TYPE_PRODUCT) {
108 $title = $langs->trans("ProductsCategoriesArea");
109 $typetext = 'product';
110} elseif ($type == Categorie::TYPE_SUPPLIER) {
111 $title = $langs->trans("SuppliersCategoriesArea");
112 $typetext = 'supplier';
113} elseif ($type == Categorie::TYPE_CUSTOMER) {
114 $title = $langs->trans("CustomersCategoriesArea");
115 $typetext = 'customer';
116} elseif ($type == Categorie::TYPE_MEMBER) {
117 $title = $langs->trans("MembersCategoriesArea");
118 $typetext = 'member';
119} elseif ($type == Categorie::TYPE_CONTACT) {
120 $title = $langs->trans("ContactsCategoriesArea");
121 $typetext = 'contact';
122} elseif ($type == Categorie::TYPE_ACCOUNT) {
123 $title = $langs->trans("AccountsCategoriesArea");
124 $typetext = 'bank_account';
125} elseif ($type == Categorie::TYPE_PROJECT) {
126 $title = $langs->trans("ProjectsCategoriesArea");
127 $typetext = 'project';
128} elseif ($type == Categorie::TYPE_USER) {
129 $title = $langs->trans("UsersCategoriesArea");
130 $typetext = 'user';
131} else {
132 $title = $langs->trans("CategoriesArea");
133 $typetext = 'unknown';
134}
135
136$arrayofjs = array(
137 '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
138 '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js',
139);
140$arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
141
142llxHeader('', $title, '', '', 0, 0, $arrayofjs, $arrayofcss, '', 'mod-takepos page-admin_orderprinters');
143
144
145print load_fiche_titre($langs->trans("OrderPrinters"));
146
147//print '<table border="0" width="100%" class="notopnoleftnoright">';
148//print '<tr><td valign="top" width="30%" class="notopnoleft">';
149print '<div class="fichecenter"><div class="fichethirdleft">';
150
151print '</div><div class="fichetwothirdright">';
152
153print '</div></div>';
154
155
156print '<div class="fichecenter"><br>';
157
158
159// Charge tableau des categories
160$cate_arbo = $categstatic->get_full_arbo($typetext);
161
162// Define fulltree array
163$fulltree = $cate_arbo;
164
165// Define data (format for treeview)
166$data = array();
167$data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => "racine", 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => '');
168foreach ($fulltree as $key => $val) {
169 $categstatic->id = $val['id'];
170 $categstatic->ref = $val['label'];
171 $categstatic->color = $val['color'];
172 $categstatic->type = $type;
173
174 $li = $categstatic->getNomUrl(1, '', 60);
175
176 $desc = dol_htmlcleanlastbr($val['description']);
177
178 $data[] = array(
179 'rowid' => $val['rowid'],
180 'fk_menu' => empty($val['fk_menu']) ? 0 : $val['fk_menu'],
181 'fk_parent' => $val['fk_parent'],
182 'label' => $val['label']
183 );
184}
185
186//Printer1
187print '<table class="liste nohover" width="100%">';
188print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 1</td><td></td><td class="right">';
189print '</td></tr>';
190$nbofentries = (count($data) - 1);
191print '<form action="orderprinters.php">';
192print '<input type="hidden" name="token" value="'.newToken().'">';
193if ($nbofentries > 0) {
194 print '<tr class="pair"><td colspan="3">';
195 print '<input type="hidden" name="action" value="SavePrinter1">';
196 foreach ($data as $row) {
197 if (strpos(getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_1'), ';'.$row["rowid"].';') !== false) {
198 $checked = 'checked';
199 } else {
200 $checked = '';
201 }
202 if ($row["fk_menu"] >= 0) {
203 print '<input type="checkbox" name="printer1[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
204 }
205 }
206 print '</td></tr>';
207} else {
208 print '<tr class="pair">';
209 print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
210 print '<td valign="middle">';
211 print $langs->trans("NoCategoryYet");
212 print '</td>';
213 print '<td>&nbsp;</td>';
214 print '</table></td>';
215 print '</tr>';
216}
217print "</table>";
218print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form><br><br>';
219
220//Printer2
221print '<table class="liste nohover" width="100%">';
222print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 2</td><td></td><td class="right">';
223print '</td></tr>';
224$nbofentries = (count($data) - 1);
225print '<form action="orderprinters.php">';
226print '<input type="hidden" name="token" value="'.newToken().'">';
227if ($nbofentries > 0) {
228 print '<tr class="pair"><td colspan="3">';
229 print '<input type="hidden" name="action" value="SavePrinter2">';
230 foreach ($data as $row) {
231 if (strpos(getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_2'), ';'.$row["rowid"].';') !== false) {
232 $checked = 'checked';
233 } else {
234 $checked = '';
235 }
236 if ($row["fk_menu"] >= 0) {
237 print '<input type="checkbox" name="printer2[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
238 }
239 }
240 print '</td></tr>';
241} else {
242 print '<tr class="pair">';
243 print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
244 print '<td valign="middle">';
245 print $langs->trans("NoCategoryYet");
246 print '</td>';
247 print '<td>&nbsp;</td>';
248 print '</table></td>';
249 print '</tr>';
250}
251print "</table>";
252print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form>';
253
254//Printer3
255print '<table class="liste nohover" width="100%">';
256print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 3</td><td></td><td class="right">';
257print '</td></tr>';
258$nbofentries = (count($data) - 1);
259print '<form action="orderprinters.php">';
260print '<input type="hidden" name="token" value="'.newToken().'">';
261if ($nbofentries > 0) {
262 print '<tr class="pair"><td colspan="3">';
263 print '<input type="hidden" name="action" value="SavePrinter3">';
264 foreach ($data as $row) {
265 if (strpos(getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_3'), ';'.$row["rowid"].';') !== false) {
266 $checked = 'checked';
267 } else {
268 $checked = '';
269 }
270 if ($row["fk_menu"] >= 0) {
271 print '<input type="checkbox" name="printer3[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
272 }
273 }
274 print '</td></tr>';
275} else {
276 print '<tr class="pair">';
277 print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
278 print '<td valign="middle">';
279 print $langs->trans("NoCategoryYet");
280 print '</td>';
281 print '<td>&nbsp;</td>';
282 print '</table></td>';
283 print '</tr>';
284}
285
286print "</table>";
287print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form>';
288
289print '</div>';
290
291llxFooter();
292
293$db->close();
$id
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).
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:71
Class to manage categories.
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
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.