setup.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <?php
  2. /* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/takepos/admin/setup.php
  20. * \ingroup takepos
  21. * \brief Setup page for TakePos module
  22. */
  23. require '../../main.inc.php'; // Load $user and permissions
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
  26. // If socid provided by ajax company selector
  27. if (! empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id']))
  28. {
  29. $_GET['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id','alpha');
  30. $_POST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id','alpha');
  31. $_REQUEST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id','alpha');
  32. }
  33. // Security check
  34. if (!$user->admin) accessforbidden();
  35. $langs->loadLangs(array("admin", "cashdesk"));
  36. /*
  37. * Actions
  38. */
  39. if (GETPOST('action','alpha') == 'set')
  40. {
  41. $db->begin();
  42. if (GETPOST('socid','int') < 0) $_POST["socid"]='';
  43. $res = dolibarr_set_const($db,"CASHDESK_ID_THIRDPARTY",(GETPOST('socid','int') > 0 ? GETPOST('socid','int') : ''),'chaine',0,'',$conf->entity);
  44. $res = dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CASH",(GETPOST('CASHDESK_ID_BANKACCOUNT_CASH','alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH','alpha') : ''),'chaine',0,'',$conf->entity);
  45. $res = dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CHEQUE",(GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE','alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE','alpha') : ''),'chaine',0,'',$conf->entity);
  46. $res = dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CB",(GETPOST('CASHDESK_ID_BANKACCOUNT_CB','alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CB','alpha') : ''),'chaine',0,'',$conf->entity);
  47. $res = dolibarr_set_const($db,"CASHDESK_ID_WAREHOUSE",(GETPOST('CASHDESK_ID_WAREHOUSE','alpha') > 0 ? GETPOST('CASHDESK_ID_WAREHOUSE','alpha') : ''),'chaine',0,'',$conf->entity);
  48. $res = dolibarr_set_const($db,"CASHDESK_NO_DECREASE_STOCK",GETPOST('CASHDESK_NO_DECREASE_STOCK','alpha'),'chaine',0,'',$conf->entity);
  49. $res = dolibarr_set_const($db,"CASHDESK_SERVICES", GETPOST('CASHDESK_SERVICES','alpha'),'chaine',0,'',$conf->entity);
  50. $res = dolibarr_set_const($db,"TAKEPOSCONNECTOR", GETPOST('TAKEPOSCONNECTOR','alpha'),'chaine',0,'',$conf->entity);
  51. $res = dolibarr_set_const($db,"TAKEPOS_BAR_RESTAURANT", GETPOST('TAKEPOS_BAR_RESTAURANT','alpha'),'chaine',0,'',$conf->entity);
  52. $res = dolibarr_set_const($db,"TAKEPOS_PRINT_SERVER", GETPOST('TAKEPOS_PRINT_SERVER','alpha'),'chaine',0,'',$conf->entity);
  53. $res = dolibarr_set_const($db,"TAKEPOS_ORDER_PRINTERS", GETPOST('TAKEPOS_ORDER_PRINTERS','alpha'),'chaine',0,'',$conf->entity);
  54. dol_syslog("admin/cashdesk: level ".GETPOST('level','alpha'));
  55. if (! $res > 0) $error++;
  56. if (! $error)
  57. {
  58. $db->commit();
  59. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  60. }
  61. else
  62. {
  63. $db->rollback();
  64. setEventMessages($langs->trans("Error"), null, 'errors');
  65. }
  66. }
  67. /*
  68. * View
  69. */
  70. $form=new Form($db);
  71. $formproduct=new FormProduct($db);
  72. llxHeader('',$langs->trans("CashDeskSetup"));
  73. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  74. print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)',$linkback,'title_setup');
  75. print '<br>';
  76. // Mode
  77. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  78. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  79. print '<input type="hidden" name="action" value="set">';
  80. if (! empty($conf->service->enabled))
  81. {
  82. print '<table class="noborder" width="100%">';
  83. print '<tr class="liste_titre">';
  84. print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
  85. print "</tr>\n";
  86. print '<tr class="oddeven"><td>';
  87. print $langs->trans("CashdeskShowServices");
  88. print '<td colspan="2">';
  89. print $form->selectyesno("CASHDESK_SERVICES",$conf->global->CASHDESK_SERVICES,1);
  90. print "</td></tr>\n";
  91. // Use Takepos printing
  92. print '<tr class="oddeven"><td>';
  93. print $langs->trans("DolibarrReceiptPrinter").' (<a href="http://en.takepos.com/connector">'.$langs->trans("TakeposConnectorNecesary").'</a>)';
  94. print '<td colspan="2">';
  95. print $form->selectyesno("TAKEPOSCONNECTOR",$conf->global->TAKEPOSCONNECTOR,1);
  96. print "</td></tr>\n";
  97. if ($conf->global->TAKEPOSCONNECTOR){
  98. print '<tr class="oddeven value"><td>';
  99. print $langs->trans("IPAddress").' (<a href="http://en.takepos.com/connector">'.$langs->trans("TakeposConnectorNecesary").'</a>)';
  100. print '<td colspan="2">';
  101. print '<input type="text" size="20" id="TAKEPOS_PRINT_SERVER" name="TAKEPOS_PRINT_SERVER" value="'.$conf->global->TAKEPOS_PRINT_SERVER.'">';
  102. print '</td></tr>';
  103. }
  104. // Bar Restaurant mode
  105. print '<tr class="oddeven"><td>';
  106. print 'Bar Restaurant';
  107. print '<td colspan="2">';
  108. print $form->selectyesno("TAKEPOS_BAR_RESTAURANT",$conf->global->TAKEPOS_BAR_RESTAURANT,1);
  109. print "</td></tr>\n";
  110. if ($conf->global->TAKEPOS_BAR_RESTAURANT and $conf->global->TAKEPOSCONNECTOR){
  111. print '<tr class="oddeven value"><td>';
  112. print $langs->trans("OrderPrinters").' (<a href="orderprinters.php?leftmenu=setup">'.$langs->trans("Setup").'</a>)';
  113. print '<td colspan="2">';
  114. print $form->selectyesno("TAKEPOS_ORDER_PRINTERS",$conf->global->TAKEPOS_ORDER_PRINTERS,1);
  115. print '</td></tr>';
  116. }
  117. print '</table>';
  118. print '<br>';
  119. }
  120. print '<table class="noborder" width="100%">';
  121. print '<tr class="liste_titre">';
  122. print '<td>'.$langs->trans("Terminal").' 0</td><td>'.$langs->trans("Value").'</td>';
  123. print "</tr>\n";
  124. print '<tr class="oddeven"><td width=\"50%\">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
  125. print '<td colspan="2">';
  126. print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY, 'socid', 's.client in (1,3) AND s.status = 1', 1, 0, 0, array(), 0);
  127. print '</td></tr>';
  128. if (! empty($conf->banque->enabled))
  129. {
  130. print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
  131. print '<td colspan="2">';
  132. $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CASH,'CASHDESK_ID_BANKACCOUNT_CASH',0,"courant=2",1);
  133. print '</td></tr>';
  134. print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
  135. print '<td colspan="2">';
  136. $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE,'CASHDESK_ID_BANKACCOUNT_CHEQUE',0,"courant=1",1);
  137. print '</td></tr>';
  138. print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCB").'</td>';
  139. print '<td colspan="2">';
  140. $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CB,'CASHDESK_ID_BANKACCOUNT_CB',0,"courant=1",1);
  141. print '</td></tr>';
  142. }
  143. if (! empty($conf->stock->enabled))
  144. {
  145. print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDoNotDecreaseStock").'</td>'; // Force warehouse (this is not a default value)
  146. print '<td colspan="2">';
  147. if (empty($conf->productbatch->enabled)) {
  148. print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK',$conf->global->CASHDESK_NO_DECREASE_STOCK,1);
  149. }
  150. else
  151. {
  152. if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) {
  153. $res = dolibarr_set_const($db,"CASHDESK_NO_DECREASE_STOCK",1,'chaine',0,'',$conf->entity);
  154. }
  155. print $langs->trans("Yes").'<br>';
  156. print '<span class="opacitymedium">'.$langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch').'</span>';
  157. }
  158. print '</td></tr>';
  159. $disabled=$conf->global->CASHDESK_NO_DECREASE_STOCK;
  160. print '<tr class="oddeven"><td>'.$langs->trans("CashDeskIdWareHouse").'</td>'; // Force warehouse (this is not a default value)
  161. print '<td colspan="2">';
  162. if (! $disabled)
  163. {
  164. print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE,'CASHDESK_ID_WAREHOUSE','',1,$disabled);
  165. print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">('.$langs->trans("Create").')</a>';
  166. }
  167. else
  168. {
  169. print '<span class="opacitymedium">'.$langs->trans("StockDecreaseForPointOfSaleDisabled").'</span>';
  170. }
  171. print '</td></tr>';
  172. }
  173. print '</table>';
  174. print '<br>';
  175. print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
  176. print "</form>\n";
  177. print '<br><br>';
  178. // Marketplace
  179. print "<table summary=\"list_of_modules\" class=\"noborder\" width=\"100%\">\n";
  180. print "<tr class=\"liste_titre\">\n";
  181. print '<td colspan="2">TakePOS Marketplace</td>';
  182. print '<td>'.$langs->trans("URL").'</td>';
  183. print '</tr>';
  184. print "<tr class=\"oddeven\">\n";
  185. $url='https://www.dolistore.com/en/modules/980-TakePOS-7-mobile.html';
  186. print '<td align="left"><a href="'.$url.'" target="_blank" rel="external"><img border="0" class="imgautosize imgmaxwidth180" src="../img/marketplace/takeposmobile.jpg"></a></td>';
  187. print '<td>TakePOS for mobile devices</td>';
  188. print '<td><a href="'.$url.'" target="_blank" rel="external">'.$url.'</a></td>';
  189. print '</tr>';
  190. print "</table>\n";
  191. print '<br>';
  192. // Support
  193. print "<table summary=\"list_of_modules\" class=\"noborder\" width=\"100%\">\n";
  194. print "<tr class=\"liste_titre\">\n";
  195. print '<td colspan="2">TakePOS Support</td>';
  196. print '<td>'.$langs->trans("URL").'</td>';
  197. print '</tr>';
  198. print "<tr class=\"oddeven\">\n";
  199. $url='http://www.takepos.com';
  200. print '<td align="left"><a href="'.$url.'" target="_blank" rel="external"><img border="0" class="imgautosize imgmaxwidth180" src="../img/takepos.png"></a></td>';
  201. print '<td>TakePOS original developers</td>';
  202. print '<td><a href="'.$url.'" target="_blank" rel="external">'.$url.'</a></td>';
  203. print '</tr>';
  204. print "</table>\n";
  205. print '<br>';
  206. llxFooter();
  207. $db->close();