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