dolibarr  16.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  *
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 require '../../main.inc.php'; // Load $user and permissions
30 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
34 
35 $langs->loadLangs(array("main"), "categories", "takepos", "printing");
36 
37 if (!$user->rights->categorie->lire) {
39 }
40 
41 $id = GETPOST('id', 'int');
42 $type = (GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT);
43 $catname = GETPOST('catname', 'alpha');
44 $action = GETPOST('action', 'aZ09');
45 $printer1 = GETPOST('printer1', 'alpha');
46 $printer2 = GETPOST('printer2', 'alpha');
47 $printer3 = GETPOST('printer3', 'alpha');
48 
49 if (is_numeric($type)) {
50  $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
51 }
52 
53 /*
54  * Actions
55  */
56 if ($action == "SavePrinter1") {
57  $printedcategories = ";";
58  if (is_array($printer1)) {
59  foreach ($printer1 as $cat) {
60  $printedcategories = $printedcategories.$cat.";";
61  }
62  }
63  dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_1", $printedcategories, 'chaine', 0, '', $conf->entity);
64 }
65 
66 if ($action == "SavePrinter2") {
67  $printedcategories = ";";
68  if (is_array($printer2)) {
69  foreach ($printer2 as $cat) {
70  $printedcategories = $printedcategories.$cat.";";
71  }
72  }
73  dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_2", $printedcategories, 'chaine', 0, '', $conf->entity);
74 }
75 
76 if ($action == "SavePrinter3") {
77  $printedcategories = ";";
78  if (is_array($printer3)) {
79  foreach ($printer3 as $cat) {
80  $printedcategories = $printedcategories.$cat.";";
81  }
82  }
83  dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_3", $printedcategories, 'chaine', 0, '', $conf->entity);
84 }
85 
86 
87 /*
88  * View
89  */
90 
91 $categstatic = new Categorie($db);
92 $form = new Form($db);
93 
94 if ($type == Categorie::TYPE_PRODUCT) {
95  $title = $langs->trans("ProductsCategoriesArea");
96  $typetext = 'product';
97 } elseif ($type == Categorie::TYPE_SUPPLIER) {
98  $title = $langs->trans("SuppliersCategoriesArea");
99  $typetext = 'supplier';
100 } elseif ($type == Categorie::TYPE_CUSTOMER) {
101  $title = $langs->trans("CustomersCategoriesArea");
102  $typetext = 'customer';
103 } elseif ($type == Categorie::TYPE_MEMBER) {
104  $title = $langs->trans("MembersCategoriesArea");
105  $typetext = 'member';
106 } elseif ($type == Categorie::TYPE_CONTACT) {
107  $title = $langs->trans("ContactsCategoriesArea");
108  $typetext = 'contact';
109 } elseif ($type == Categorie::TYPE_ACCOUNT) {
110  $title = $langs->trans("AccountsCategoriesArea");
111  $typetext = 'bank_account';
112 } elseif ($type == Categorie::TYPE_PROJECT) {
113  $title = $langs->trans("ProjectsCategoriesArea");
114  $typetext = 'project';
115 } elseif ($type == Categorie::TYPE_USER) {
116  $title = $langs->trans("UsersCategoriesArea");
117  $typetext = 'user';
118 } else {
119  $title = $langs->trans("CategoriesArea");
120  $typetext = 'unknown';
121 }
122 
123 $arrayofjs = array(
124  '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
125  '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js',
126 );
127 $arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
128 
129 llxHeader('', $title, '', '', 0, 0, $arrayofjs, $arrayofcss);
130 
131 
132 print load_fiche_titre($langs->trans("OrderPrinters"));
133 
134 //print '<table border="0" width="100%" class="notopnoleftnoright">';
135 //print '<tr><td valign="top" width="30%" class="notopnoleft">';
136 print '<div class="fichecenter"><div class="fichethirdleft">';
137 
138 print '</div><div class="fichetwothirdright">';
139 
140 print '</div></div>';
141 
142 
143 print '<div class="fichecenter"><br>';
144 
145 
146 // Charge tableau des categories
147 $cate_arbo = $categstatic->get_full_arbo($typetext);
148 
149 // Define fulltree array
150 $fulltree = $cate_arbo;
151 
152 // Define data (format for treeview)
153 $data = array();
154 $data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>'');
155 foreach ($fulltree as $key => $val) {
156  $categstatic->id = $val['id'];
157  $categstatic->ref = $val['label'];
158  $categstatic->color = $val['color'];
159  $categstatic->type = $type;
160  $li = $categstatic->getNomUrl(1, '', 60);
161  $desc = dol_htmlcleanlastbr($val['description']);
162 
163  $data[] = array(
164  'rowid'=>$val['rowid'],
165  'fk_menu'=>$val['fk_menu'],
166  'fk_menu'=>$val['fk_parent'],
167  'label'=>$val['label']
168  );
169 }
170 
171 //Printer1
172 print '<table class="liste nohover" width="100%">';
173 print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 1</td><td></td><td class="right">';
174 print '</td></tr>';
175 $nbofentries = (count($data) - 1);
176 print '<form action="orderprinters.php">';
177 if ($nbofentries > 0) {
178  print '<tr class="pair"><td colspan="3">';
179  print '<input type="hidden" name="action" value="SavePrinter1">';
180  foreach ($data as $row) {
181  if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_1, ';'.$row["rowid"].';') !== false) {
182  $checked = 'checked';
183  } else {
184  $checked = '';
185  }
186  if ($row["fk_menu"] == 0) {
187  print '<input type="checkbox" name="printer1[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
188  }
189  }
190  print '</td></tr>';
191 } else {
192  print '<tr class="pair">';
193  print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
194  print '<td valign="middle">';
195  print $langs->trans("NoCategoryYet");
196  print '</td>';
197  print '<td>&nbsp;</td>';
198  print '</table></td>';
199  print '</tr>';
200 }
201 print "</table>";
202 print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form><br><br>';
203 
204 //Printer2
205 print '<table class="liste nohover" width="100%">';
206 print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 2</td><td></td><td class="right">';
207 print '</td></tr>';
208 $nbofentries = (count($data) - 1);
209 print '<form action="orderprinters.php">';
210 if ($nbofentries > 0) {
211  print '<tr class="pair"><td colspan="3">';
212  print '<input type="hidden" name="action" value="SavePrinter2">';
213  foreach ($data as $row) {
214  if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_2, ';'.$row["rowid"].';') !== false) {
215  $checked = 'checked';
216  } else {
217  $checked = '';
218  }
219  if ($row["fk_menu"] == 0) {
220  print '<input type="checkbox" name="printer2[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
221  }
222  }
223  print '</td></tr>';
224 } else {
225  print '<tr class="pair">';
226  print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
227  print '<td valign="middle">';
228  print $langs->trans("NoCategoryYet");
229  print '</td>';
230  print '<td>&nbsp;</td>';
231  print '</table></td>';
232  print '</tr>';
233 }
234 print "</table>";
235 print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form>';
236 
237 //Printer3
238 print '<table class="liste nohover" width="100%">';
239 print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 3</td><td></td><td class="right">';
240 print '</td></tr>';
241 $nbofentries = (count($data) - 1);
242 print '<form action="orderprinters.php">';
243 if ($nbofentries > 0) {
244  print '<tr class="pair"><td colspan="3">';
245  print '<input type="hidden" name="action" value="SavePrinter3">';
246  foreach ($data as $row) {
247  if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_3, ';'.$row["rowid"].';') !== false) {
248  $checked = 'checked';
249  } else {
250  $checked = '';
251  }
252  if ($row["fk_menu"] == 0) {
253  print '<input type="checkbox" name="printer3[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
254  }
255  }
256  print '</td></tr>';
257 } else {
258  print '<tr class="pair">';
259  print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
260  print '<td valign="middle">';
261  print $langs->trans("NoCategoryYet");
262  print '</td>';
263  print '<td>&nbsp;</td>';
264  print '</table></td>';
265  print '</tr>';
266 }
267 
268 print "</table>";
269 print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form>';
270 
271 print '</div>';
272 
273 llxFooter();
274 
275 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
Categorie
Class to manage categories.
Definition: categorie.class.php:47
dol_htmlcleanlastbr
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
Definition: functions.lib.php:7036
dolibarr_set_const
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).
Definition: admin.lib.php:627
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59