dolibarr  9.0.0
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 <http://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  }
72  else
73  {
74  $db->rollback();
75  setEventMessages($langs->trans("Error"), null, 'errors');
76  }
77 }
78 
79 /*
80  * View
81  */
82 
83 $form=new Form($db);
84 $formproduct=new FormProduct($db);
85 
86 llxHeader('',$langs->trans("CashDeskSetup"));
87 
88 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
89 print load_fiche_titre($langs->trans("CashDeskSetup").' (SimplePOS)',$linkback,'title_setup');
90 print '<br>';
91 
92 
93 // Mode
94 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
95 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
96 print '<input type="hidden" name="action" value="set">';
97 
98 if (! empty($conf->service->enabled))
99 {
100  print '<table class="noborder" width="100%">';
101  print '<tr class="liste_titre">';
102  print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
103  print "</tr>\n";
104 
105  print '<tr class="oddeven"><td>';
106  print $langs->trans("CashdeskShowServices");
107  print '<td colspan="2">';
108  print $form->selectyesno("CASHDESK_SERVICES",$conf->global->CASHDESK_SERVICES,1);
109  print "</td></tr>\n";
110 
111  print '</table>';
112 
113  print '<br>';
114 }
115 
116 
117 print '<table class="noborder" width="100%">';
118 print '<tr class="liste_titre">';
119 print '<td>'.$langs->trans("Terminal").' 0</td><td>'.$langs->trans("Value").'</td>';
120 print "</tr>\n";
121 
122 print '<tr class="oddeven"><td width=\"50%\">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
123 print '<td colspan="2">';
124 print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY,'socid','s.client in (1,3) AND s.status = 1', 1, 0, 0, array(), 0);
125 print '</td></tr>';
126 if (! empty($conf->banque->enabled))
127 {
128 
129  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
130  print '<td colspan="2">';
131  $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CASH,'CASHDESK_ID_BANKACCOUNT_CASH',0,"courant=2",1);
132  print '</td></tr>';
133 
134 
135  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
136  print '<td colspan="2">';
137  $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE,'CASHDESK_ID_BANKACCOUNT_CHEQUE',0,"courant=1",1);
138  print '</td></tr>';
139 
140 
141  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCB").'</td>';
142  print '<td colspan="2">';
143  $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CB,'CASHDESK_ID_BANKACCOUNT_CB',0,"courant=1",1);
144  print '</td></tr>';
145 }
146 
147 if (! empty($conf->stock->enabled))
148 {
149 
150  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDoNotDecreaseStock").'</td>'; // Force warehouse (this is not a default value)
151  print '<td colspan="2">';
152  if (empty($conf->productbatch->enabled)) {
153  print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK',$conf->global->CASHDESK_NO_DECREASE_STOCK,1);
154  }
155  else
156  {
157  if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) {
158  $res = dolibarr_set_const($db,"CASHDESK_NO_DECREASE_STOCK",1,'chaine',0,'',$conf->entity);
159  }
160  print $langs->trans("Yes").'<br>';
161  print '<span class="opacitymedium">'.$langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch').'</span>';
162  }
163  print '</td></tr>';
164 
165  $disabled=$conf->global->CASHDESK_NO_DECREASE_STOCK;
166 
167 
168  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskIdWareHouse").'</td>'; // Force warehouse (this is not a default value)
169  print '<td colspan="2">';
170  if (! $disabled)
171  {
172  print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE,'CASHDESK_ID_WAREHOUSE','',1,$disabled);
173  print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">('.$langs->trans("Create").')</a>';
174  }
175  else
176  {
177  print '<span class="opacitymedium">'.$langs->trans("StockDecreaseForPointOfSaleDisabled").'</span>';
178  }
179  print '</td></tr>';
180 }
181 
182 // Use Dolibarr Receipt Printer
183 if (! empty($conf->receiptprinter->enabled))
184 {
185  print '<tr class="oddeven"><td>';
186  print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')';
187  print '<td colspan="2">';
188  print $form->selectyesno("CASHDESK_DOLIBAR_RECEIPT_PRINTER",$conf->global->CASHDESK_DOLIBAR_RECEIPT_PRINTER,1);
189  print "</td></tr>\n";
190 }
191 
192 print '</table>';
193 print '<br>';
194 
195 print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
196 
197 print "</form>\n";
198 
199 // End of page
200 llxFooter();
201 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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:510
Class with static methods for building HTML components related to products Only components common to ...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
llxHeader()
Empty header.
Definition: wrapper.php:44