dolibarr 20.0.0
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 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../../main.inc.php'; // Load $user and permissions
31require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
35
36$langs->loadLangs(array("main", "categories", "takepos", "printing"));
37
38$id = GETPOSTINT('id');
39$type = (GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT);
40$catname = GETPOST('catname', 'alpha');
41$action = GETPOST('action', 'aZ09');
42$printer1 = GETPOST('printer1', 'alpha');
43$printer2 = GETPOST('printer2', 'alpha');
44$printer3 = GETPOST('printer3', 'alpha');
45
46if (is_numeric($type)) {
47 $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
48}
49
50if (!$user->hasRight('categorie', 'lire')) {
52}
53
54
55/*
56 * Actions
57 */
58
59if ($action == "SavePrinter1") {
60 $printedcategories = ";";
61 if (is_array($printer1)) {
62 foreach ($printer1 as $cat) {
63 $printedcategories = $printedcategories.$cat.";";
64 }
65 }
66 dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_1", $printedcategories, 'chaine', 0, '', $conf->entity);
67}
68
69if ($action == "SavePrinter2") {
70 $printedcategories = ";";
71 if (is_array($printer2)) {
72 foreach ($printer2 as $cat) {
73 $printedcategories = $printedcategories.$cat.";";
74 }
75 }
76 dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_2", $printedcategories, 'chaine', 0, '', $conf->entity);
77}
78
79if ($action == "SavePrinter3") {
80 $printedcategories = ";";
81 if (is_array($printer3)) {
82 foreach ($printer3 as $cat) {
83 $printedcategories = $printedcategories.$cat.";";
84 }
85 }
86 dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_3", $printedcategories, 'chaine', 0, '', $conf->entity);
87}
88
89
90/*
91 * View
92 */
93
94$categstatic = new Categorie($db);
95$form = new Form($db);
96
97if ($type == Categorie::TYPE_PRODUCT) {
98 $title = $langs->trans("ProductsCategoriesArea");
99 $typetext = 'product';
100} elseif ($type == Categorie::TYPE_SUPPLIER) {
101 $title = $langs->trans("SuppliersCategoriesArea");
102 $typetext = 'supplier';
103} elseif ($type == Categorie::TYPE_CUSTOMER) {
104 $title = $langs->trans("CustomersCategoriesArea");
105 $typetext = 'customer';
106} elseif ($type == Categorie::TYPE_MEMBER) {
107 $title = $langs->trans("MembersCategoriesArea");
108 $typetext = 'member';
109} elseif ($type == Categorie::TYPE_CONTACT) {
110 $title = $langs->trans("ContactsCategoriesArea");
111 $typetext = 'contact';
112} elseif ($type == Categorie::TYPE_ACCOUNT) {
113 $title = $langs->trans("AccountsCategoriesArea");
114 $typetext = 'bank_account';
115} elseif ($type == Categorie::TYPE_PROJECT) {
116 $title = $langs->trans("ProjectsCategoriesArea");
117 $typetext = 'project';
118} elseif ($type == Categorie::TYPE_USER) {
119 $title = $langs->trans("UsersCategoriesArea");
120 $typetext = 'user';
121} else {
122 $title = $langs->trans("CategoriesArea");
123 $typetext = 'unknown';
124}
125
126$arrayofjs = array(
127 '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
128 '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js',
129);
130$arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
131
132llxHeader('', $title, '', '', 0, 0, $arrayofjs, $arrayofcss, '', 'mod-takepos page-admin_orderprinters');
133
134
135print load_fiche_titre($langs->trans("OrderPrinters"));
136
137//print '<table border="0" width="100%" class="notopnoleftnoright">';
138//print '<tr><td valign="top" width="30%" class="notopnoleft">';
139print '<div class="fichecenter"><div class="fichethirdleft">';
140
141print '</div><div class="fichetwothirdright">';
142
143print '</div></div>';
144
145
146print '<div class="fichecenter"><br>';
147
148
149// Charge tableau des categories
150$cate_arbo = $categstatic->get_full_arbo($typetext);
151
152// Define fulltree array
153$fulltree = $cate_arbo;
154
155// Define data (format for treeview)
156$data = array();
157$data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>'');
158foreach ($fulltree as $key => $val) {
159 $categstatic->id = $val['id'];
160 $categstatic->ref = $val['label'];
161 $categstatic->color = $val['color'];
162 $categstatic->type = $type;
163
164 $li = $categstatic->getNomUrl(1, '', 60);
165
166 $desc = dol_htmlcleanlastbr($val['description']);
167
168 $data[] = array(
169 'rowid' => $val['rowid'],
170 'fk_menu' => empty($val['fk_menu']) ? 0 : $val['fk_menu'],
171 'fk_parent' => $val['fk_parent'],
172 'label' => $val['label']
173 );
174}
175
176//Printer1
177print '<table class="liste nohover" width="100%">';
178print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 1</td><td></td><td class="right">';
179print '</td></tr>';
180$nbofentries = (count($data) - 1);
181print '<form action="orderprinters.php">';
182print '<input type="hidden" name="token" value="'.newToken().'">';
183if ($nbofentries > 0) {
184 print '<tr class="pair"><td colspan="3">';
185 print '<input type="hidden" name="action" value="SavePrinter1">';
186 foreach ($data as $row) {
187 if (strpos(getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_1'), ';'.$row["rowid"].';') !== false) {
188 $checked = 'checked';
189 } else {
190 $checked = '';
191 }
192 if ($row["fk_menu"] >= 0) {
193 print '<input type="checkbox" name="printer1[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
194 }
195 }
196 print '</td></tr>';
197} else {
198 print '<tr class="pair">';
199 print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
200 print '<td valign="middle">';
201 print $langs->trans("NoCategoryYet");
202 print '</td>';
203 print '<td>&nbsp;</td>';
204 print '</table></td>';
205 print '</tr>';
206}
207print "</table>";
208print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form><br><br>';
209
210//Printer2
211print '<table class="liste nohover" width="100%">';
212print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 2</td><td></td><td class="right">';
213print '</td></tr>';
214$nbofentries = (count($data) - 1);
215print '<form action="orderprinters.php">';
216print '<input type="hidden" name="token" value="'.newToken().'">';
217if ($nbofentries > 0) {
218 print '<tr class="pair"><td colspan="3">';
219 print '<input type="hidden" name="action" value="SavePrinter2">';
220 foreach ($data as $row) {
221 if (strpos(getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_2'), ';'.$row["rowid"].';') !== false) {
222 $checked = 'checked';
223 } else {
224 $checked = '';
225 }
226 if ($row["fk_menu"] >= 0) {
227 print '<input type="checkbox" name="printer2[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
228 }
229 }
230 print '</td></tr>';
231} else {
232 print '<tr class="pair">';
233 print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
234 print '<td valign="middle">';
235 print $langs->trans("NoCategoryYet");
236 print '</td>';
237 print '<td>&nbsp;</td>';
238 print '</table></td>';
239 print '</tr>';
240}
241print "</table>";
242print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form>';
243
244//Printer3
245print '<table class="liste nohover" width="100%">';
246print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 3</td><td></td><td class="right">';
247print '</td></tr>';
248$nbofentries = (count($data) - 1);
249print '<form action="orderprinters.php">';
250print '<input type="hidden" name="token" value="'.newToken().'">';
251if ($nbofentries > 0) {
252 print '<tr class="pair"><td colspan="3">';
253 print '<input type="hidden" name="action" value="SavePrinter3">';
254 foreach ($data as $row) {
255 if (strpos(getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_3'), ';'.$row["rowid"].';') !== false) {
256 $checked = 'checked';
257 } else {
258 $checked = '';
259 }
260 if ($row["fk_menu"] >= 0) {
261 print '<input type="checkbox" name="printer3[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
262 }
263 }
264 print '</td></tr>';
265} else {
266 print '<tr class="pair">';
267 print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
268 print '<td valign="middle">';
269 print $langs->trans("NoCategoryYet");
270 print '</td>';
271 print '<td>&nbsp;</td>';
272 print '</table></td>';
273 print '</tr>';
274}
275
276print "</table>";
277print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form>';
278
279print '</div>';
280
281llxFooter();
282
283$db->close();
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()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
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 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.