dolibarr  7.0.0-beta
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 $langs->load("admin");
42 $langs->load("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">'.$langs->trans("BackToModuleList").'</a>';
89 print load_fiche_titre($langs->trans("CashDeskSetup"),$linkback,'title_setup');
90 print '<br>';
91 
92 
93 // Mode
94 $var=true;
95 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
96 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
97 print '<input type="hidden" name="action" value="set">';
98 
99 print '<table class="noborder" width="100%">';
100 print '<tr class="liste_titre">';
101 print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
102 print "</tr>\n";
103 
104 print '<tr class="oddeven"><td width=\"50%\">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
105 print '<td colspan="2">';
106 print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY,'socid','s.client in (1,3) AND s.status = 1',1,0,1,array(),0);
107 print '</td></tr>';
108 if (! empty($conf->banque->enabled))
109 {
110 
111  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
112  print '<td colspan="2">';
113  $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CASH,'CASHDESK_ID_BANKACCOUNT_CASH',0,"courant=2",1);
114  print '</td></tr>';
115 
116 
117  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
118  print '<td colspan="2">';
119  $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE,'CASHDESK_ID_BANKACCOUNT_CHEQUE',0,"courant=1",1);
120  print '</td></tr>';
121 
122 
123  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCB").'</td>';
124  print '<td colspan="2">';
125  $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CB,'CASHDESK_ID_BANKACCOUNT_CB',0,"courant=1",1);
126  print '</td></tr>';
127 }
128 
129 if (! empty($conf->stock->enabled))
130 {
131 
132  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDoNotDecreaseStock").'</td>'; // Force warehouse (this is not a default value)
133  print '<td colspan="2">';
134  if (empty($conf->productbatch->enabled)) {
135  print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK',$conf->global->CASHDESK_NO_DECREASE_STOCK,1);
136  }
137  else
138  {
139  if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) {
140  $res = dolibarr_set_const($db,"CASHDESK_NO_DECREASE_STOCK",1,'chaine',0,'',$conf->entity);
141  }
142  print $langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch');
143  }
144  print '</td></tr>';
145 
146  $disabled=$conf->global->CASHDESK_NO_DECREASE_STOCK;
147 
148 
149  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskIdWareHouse").'</td>'; // Force warehouse (this is not a default value)
150  print '<td colspan="2">';
151  if (! $disabled)
152  {
153  print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE,'CASHDESK_ID_WAREHOUSE','',1,$disabled);
154  print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">('.$langs->trans("Create").')</a>';
155  }
156  else
157  {
158  print $langs->trans("StockDecreaseForPointOfSaleDisabled");
159  }
160  print '</td></tr>';
161 }
162 
163 if (! empty($conf->service->enabled))
164 {
165  $var=! $var;
166  print '<tr class="oddeven"><td>';
167  print $langs->trans("CashdeskShowServices");
168  print '<td colspan="2">';
169  print $form->selectyesno("CASHDESK_SERVICES",$conf->global->CASHDESK_SERVICES,1);
170  print "</td></tr>\n";
171 }
172 
173 // Use Dolibarr Receipt Printer
174 if (! empty($conf->receiptprinter->enabled))
175 {
176  $var=! $var;
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" value="'.$langs->trans("Save").'"></div>';
188 
189 print "</form>\n";
190 
191 llxFooter();
192 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
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:485
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
print
Draft customers invoices.
Definition: index.php:91