dolibarr  13.0.2
cashdesk.php
Go to the documentation of this file.
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 <https://www.gnu.org/licenses/>.
17  */
18 
25 require '../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
27 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
28 
29 // If socid provided by ajax company selector
30 if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id']))
31 {
32  $_GET['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha');
33  $_POST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha');
34  $_REQUEST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha');
35 }
36 
37 // Security check
38 if (!$user->admin)
40 
41 // Load translation files required by the page
42 $langs->loadLangs(array("admin", "cashdesk"));
43 
44 
45 /*
46  * Actions
47  */
48 if (GETPOST('action', 'alpha') == 'set')
49 {
50  $db->begin();
51 
52  if (GETPOST('socid', 'int') < 0) $_POST["socid"] = '';
53 
54  $res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY", (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity);
55  $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);
56  $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);
57  $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);
58  $res = dolibarr_set_const($db, "CASHDESK_ID_WAREHOUSE", (GETPOST('CASHDESK_ID_WAREHOUSE', 'alpha') > 0 ? GETPOST('CASHDESK_ID_WAREHOUSE', 'alpha') : ''), 'chaine', 0, '', $conf->entity);
59  $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", GETPOST('CASHDESK_NO_DECREASE_STOCK', 'alpha'), 'chaine', 0, '', $conf->entity);
60  $res = dolibarr_set_const($db, "CASHDESK_SERVICES", GETPOST('CASHDESK_SERVICES', 'alpha'), 'chaine', 0, '', $conf->entity);
61  $res = dolibarr_set_const($db, "CASHDESK_DOLIBAR_RECEIPT_PRINTER", GETPOST('CASHDESK_DOLIBAR_RECEIPT_PRINTER', 'alpha'), 'chaine', 0, '', $conf->entity);
62 
63  dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
64 
65  if (!($res > 0)) $error++;
66 
67  if (!$error)
68  {
69  $db->commit();
70  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
71  } else {
72  $db->rollback();
73  setEventMessages($langs->trans("Error"), null, 'errors');
74  }
75 }
76 
77 /*
78  * View
79  */
80 
81 $form = new Form($db);
82 $formproduct = new FormProduct($db);
83 
84 llxHeader('', $langs->trans("CashDeskSetup"));
85 
86 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
87 print load_fiche_titre($langs->trans("CashDeskSetup").' (SimplePOS)', $linkback, 'title_setup');
88 print '<br>';
89 
90 
91 // Mode
92 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
93 print '<input type="hidden" name="token" value="'.newToken().'">';
94 print '<input type="hidden" name="action" value="set">';
95 
96 if (!empty($conf->service->enabled))
97 {
98  print '<table class="noborder centpercent">';
99  print '<tr class="liste_titre">';
100  print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
101  print "</tr>\n";
102 
103  print '<tr class="oddeven"><td>';
104  print $langs->trans("CashdeskShowServices");
105  print '<td colspan="2">';
106  print $form->selectyesno("CASHDESK_SERVICES", $conf->global->CASHDESK_SERVICES, 1);
107  print "</td></tr>\n";
108 
109  print '</table>';
110 
111  print '<br>';
112 }
113 
114 
115 print '<table class="noborder centpercent">';
116 print '<tr class="liste_titre">';
117 print '<td>'.$langs->trans("Terminal").' 0</td><td>'.$langs->trans("Value").'</td>';
118 print "</tr>\n";
119 
120 print '<tr class="oddeven"><td width=\"50%\">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
121 print '<td colspan="2">';
122 print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY, 'socid', '(s.client in (1,3) AND s.status = 1)', 1, 0, 0, array(), 0);
123 print '</td></tr>';
124 if (!empty($conf->banque->enabled))
125 {
126  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
127  print '<td colspan="2">';
128  $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CASH, 'CASHDESK_ID_BANKACCOUNT_CASH', 0, "courant=2", 1);
129  print '</td></tr>';
130 
131 
132  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
133  print '<td colspan="2">';
134  $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE, 'CASHDESK_ID_BANKACCOUNT_CHEQUE', 0, "courant=1", 1);
135  print '</td></tr>';
136 
137 
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 
144 if (!empty($conf->stock->enabled))
145 {
146  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDoNotDecreaseStock").'</td>'; // Force warehouse (this is not a default value)
147  print '<td colspan="2">';
148  if (empty($conf->productbatch->enabled)) {
149  print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK', $conf->global->CASHDESK_NO_DECREASE_STOCK, 1);
150  } else {
151  if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) {
152  $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity);
153  }
154  print $langs->trans("Yes").'<br>';
155  print '<span class="opacitymedium">'.$langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch').'</span>';
156  }
157  print '</td></tr>';
158 
159  $disabled = $conf->global->CASHDESK_NO_DECREASE_STOCK;
160 
161 
162  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskIdWareHouse").'</td>'; // Force warehouse (this is not a default value)
163  print '<td colspan="2">';
164  if (!$disabled)
165  {
166  print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE, 'CASHDESK_ID_WAREHOUSE', '', 1, $disabled);
167  print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">('.$langs->trans("Create").')</a>';
168  } else {
169  print '<span class="opacitymedium">'.$langs->trans("StockDecreaseForPointOfSaleDisabled").'</span>';
170  }
171  print '</td></tr>';
172 }
173 
174 // Use Dolibarr Receipt Printer
175 if (!empty($conf->receiptprinter->enabled))
176 {
177  print '<tr class="oddeven"><td>';
178  print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')';
179  print '<td colspan="2">';
180  print $form->selectyesno("CASHDESK_DOLIBAR_RECEIPT_PRINTER", $conf->global->CASHDESK_DOLIBAR_RECEIPT_PRINTER, 1);
181  print "</td></tr>\n";
182 }
183 
184 print '</table>';
185 print '<br>';
186 
187 print '<div class="center"><input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></div>';
188 
189 print "</form>\n";
190 
191 // End of page
192 llxFooter();
193 $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
Class with static methods for building HTML components related to products Only components common to ...
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
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 $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
Definition: index.php:89
llxFooter()
Empty footer.
Definition: wrapper.php:59