orderprinters.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. /**
  23. * \file htdocs/takepos/admin/orderprinters.php
  24. * \ingroup takepos
  25. * \brief Home page of category area
  26. */
  27. // Load Dolibarr environment
  28. require '../../main.inc.php'; // Load $user and permissions
  29. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  33. $langs->loadLangs(array("main", "categories", "takepos", "printing"));
  34. $id = GETPOST('id', 'int');
  35. $type = (GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT);
  36. $catname = GETPOST('catname', 'alpha');
  37. $action = GETPOST('action', 'aZ09');
  38. $printer1 = GETPOST('printer1', 'alpha');
  39. $printer2 = GETPOST('printer2', 'alpha');
  40. $printer3 = GETPOST('printer3', 'alpha');
  41. if (is_numeric($type)) {
  42. $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
  43. }
  44. if (!$user->hasRight('categorie', 'lire')) {
  45. accessforbidden();
  46. }
  47. /*
  48. * Actions
  49. */
  50. if ($action == "SavePrinter1") {
  51. $printedcategories = ";";
  52. if (is_array($printer1)) {
  53. foreach ($printer1 as $cat) {
  54. $printedcategories = $printedcategories.$cat.";";
  55. }
  56. }
  57. dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_1", $printedcategories, 'chaine', 0, '', $conf->entity);
  58. }
  59. if ($action == "SavePrinter2") {
  60. $printedcategories = ";";
  61. if (is_array($printer2)) {
  62. foreach ($printer2 as $cat) {
  63. $printedcategories = $printedcategories.$cat.";";
  64. }
  65. }
  66. dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_2", $printedcategories, 'chaine', 0, '', $conf->entity);
  67. }
  68. if ($action == "SavePrinter3") {
  69. $printedcategories = ";";
  70. if (is_array($printer3)) {
  71. foreach ($printer3 as $cat) {
  72. $printedcategories = $printedcategories.$cat.";";
  73. }
  74. }
  75. dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_3", $printedcategories, 'chaine', 0, '', $conf->entity);
  76. }
  77. /*
  78. * View
  79. */
  80. $categstatic = new Categorie($db);
  81. $form = new Form($db);
  82. if ($type == Categorie::TYPE_PRODUCT) {
  83. $title = $langs->trans("ProductsCategoriesArea");
  84. $typetext = 'product';
  85. } elseif ($type == Categorie::TYPE_SUPPLIER) {
  86. $title = $langs->trans("SuppliersCategoriesArea");
  87. $typetext = 'supplier';
  88. } elseif ($type == Categorie::TYPE_CUSTOMER) {
  89. $title = $langs->trans("CustomersCategoriesArea");
  90. $typetext = 'customer';
  91. } elseif ($type == Categorie::TYPE_MEMBER) {
  92. $title = $langs->trans("MembersCategoriesArea");
  93. $typetext = 'member';
  94. } elseif ($type == Categorie::TYPE_CONTACT) {
  95. $title = $langs->trans("ContactsCategoriesArea");
  96. $typetext = 'contact';
  97. } elseif ($type == Categorie::TYPE_ACCOUNT) {
  98. $title = $langs->trans("AccountsCategoriesArea");
  99. $typetext = 'bank_account';
  100. } elseif ($type == Categorie::TYPE_PROJECT) {
  101. $title = $langs->trans("ProjectsCategoriesArea");
  102. $typetext = 'project';
  103. } elseif ($type == Categorie::TYPE_USER) {
  104. $title = $langs->trans("UsersCategoriesArea");
  105. $typetext = 'user';
  106. } else {
  107. $title = $langs->trans("CategoriesArea");
  108. $typetext = 'unknown';
  109. }
  110. $arrayofjs = array(
  111. '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
  112. '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js',
  113. );
  114. $arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
  115. llxHeader('', $title, '', '', 0, 0, $arrayofjs, $arrayofcss);
  116. print load_fiche_titre($langs->trans("OrderPrinters"));
  117. //print '<table border="0" width="100%" class="notopnoleftnoright">';
  118. //print '<tr><td valign="top" width="30%" class="notopnoleft">';
  119. print '<div class="fichecenter"><div class="fichethirdleft">';
  120. print '</div><div class="fichetwothirdright">';
  121. print '</div></div>';
  122. print '<div class="fichecenter"><br>';
  123. // Charge tableau des categories
  124. $cate_arbo = $categstatic->get_full_arbo($typetext);
  125. // Define fulltree array
  126. $fulltree = $cate_arbo;
  127. // Define data (format for treeview)
  128. $data = array();
  129. $data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>'');
  130. foreach ($fulltree as $key => $val) {
  131. $categstatic->id = $val['id'];
  132. $categstatic->ref = $val['label'];
  133. $categstatic->color = $val['color'];
  134. $categstatic->type = $type;
  135. $li = $categstatic->getNomUrl(1, '', 60);
  136. $desc = dol_htmlcleanlastbr($val['description']);
  137. $data[] = array(
  138. 'rowid'=>$val['rowid'],
  139. 'fk_menu'=>$val['fk_menu'],
  140. 'fk_parent'=>$val['fk_parent'],
  141. 'label'=>$val['label']
  142. );
  143. }
  144. //Printer1
  145. print '<table class="liste nohover" width="100%">';
  146. print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 1</td><td></td><td class="right">';
  147. print '</td></tr>';
  148. $nbofentries = (count($data) - 1);
  149. print '<form action="orderprinters.php">';
  150. print '<input type="hidden" name="token" value="'.newToken().'">';
  151. if ($nbofentries > 0) {
  152. print '<tr class="pair"><td colspan="3">';
  153. print '<input type="hidden" name="action" value="SavePrinter1">';
  154. foreach ($data as $row) {
  155. if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_1, ';'.$row["rowid"].';') !== false) {
  156. $checked = 'checked';
  157. } else {
  158. $checked = '';
  159. }
  160. if ($row["fk_menu"] >= 0) {
  161. print '<input type="checkbox" name="printer1[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
  162. }
  163. }
  164. print '</td></tr>';
  165. } else {
  166. print '<tr class="pair">';
  167. print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
  168. print '<td valign="middle">';
  169. print $langs->trans("NoCategoryYet");
  170. print '</td>';
  171. print '<td>&nbsp;</td>';
  172. print '</table></td>';
  173. print '</tr>';
  174. }
  175. print "</table>";
  176. print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form><br><br>';
  177. //Printer2
  178. print '<table class="liste nohover" width="100%">';
  179. print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 2</td><td></td><td class="right">';
  180. print '</td></tr>';
  181. $nbofentries = (count($data) - 1);
  182. print '<form action="orderprinters.php">';
  183. print '<input type="hidden" name="token" value="'.newToken().'">';
  184. if ($nbofentries > 0) {
  185. print '<tr class="pair"><td colspan="3">';
  186. print '<input type="hidden" name="action" value="SavePrinter2">';
  187. foreach ($data as $row) {
  188. if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_2, ';'.$row["rowid"].';') !== false) {
  189. $checked = 'checked';
  190. } else {
  191. $checked = '';
  192. }
  193. if ($row["fk_menu"] >= 0) {
  194. print '<input type="checkbox" name="printer2[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
  195. }
  196. }
  197. print '</td></tr>';
  198. } else {
  199. print '<tr class="pair">';
  200. print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
  201. print '<td valign="middle">';
  202. print $langs->trans("NoCategoryYet");
  203. print '</td>';
  204. print '<td>&nbsp;</td>';
  205. print '</table></td>';
  206. print '</tr>';
  207. }
  208. print "</table>";
  209. print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form>';
  210. //Printer3
  211. print '<table class="liste nohover" width="100%">';
  212. print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 3</td><td></td><td class="right">';
  213. print '</td></tr>';
  214. $nbofentries = (count($data) - 1);
  215. print '<form action="orderprinters.php">';
  216. print '<input type="hidden" name="token" value="'.newToken().'">';
  217. if ($nbofentries > 0) {
  218. print '<tr class="pair"><td colspan="3">';
  219. print '<input type="hidden" name="action" value="SavePrinter3">';
  220. foreach ($data as $row) {
  221. if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_3, ';'.$row["rowid"].';') !== false) {
  222. $checked = 'checked';
  223. } else {
  224. $checked = '';
  225. }
  226. if ($row["fk_menu"] >= 0) {
  227. print '<input type="checkbox" name="printer3[]" 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. }
  241. print "</table>";
  242. print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></form>';
  243. print '</div>';
  244. llxFooter();
  245. $db->close();