dolibarr  13.0.2
freezone.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
3  * Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
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 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
26 //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
27 //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
28 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
29 if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
30 if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
31 if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
32 if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
33 if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
34 
35 require '../main.inc.php'; // Load $user and permissions
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
37 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
39 
40 global $mysoc;
41 
42 $langs->loadLangs(array("bills", "cashdesk"));
43 
44 $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'); // $place is id of table for Bar or Restaurant
45 
46 $idline = GETPOST('idline', 'int');
47 $action = GETPOST('action', 'aZ09');
48 
49 if (empty($user->rights->takepos->run)) {
51 }
52 
53 // get invoice
54 $invoice = new Facture($db);
55 if ($place > 0) {
56  $invoice->fetch($place);
57 } else {
58  $invoice->fetch('', '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$place.')');
59 }
60 
61 // get default vat rate
62 $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION['takeposterminal'];
63 $soc = new Societe($db);
64 if ($invoice->socid > 0) $soc->fetch($invoice->socid);
65 else $soc->fetch($conf->global->$constforcompanyid);
66 $vatRateDefault = get_default_tva($mysoc, $soc);
67 
68 /*
69  * View
70  */
71 
72 $arrayofcss = array('/takepos/css/pos.css.php');
73 $arrayofjs = array();
74 
75 top_htmlhead($head, '', 0, 0, $arrayofjs, $arrayofcss);
76 ?>
77 <script>
78  var vatRate = '<?php echo dol_escape_js($vatRateDefault); ?>';
79 
86  function ApplyVATRate(id, rate) {
87  console.log("Save selected VAT Rate into vatRate variable with value "+rate);
88  vatRate = rate;
89  jQuery('button.vat_rate').removeClass('selected');
90  jQuery('#vat_rate_'+id).addClass('selected');
91  }
92 
96  function Save() {
97  console.log("We click so we call page invoice.php with place=<?php echo $place; ?> tva_tx="+vatRate);
98  $.get( "invoice.php", { action: "<?php echo $action; ?>", place: "<?php echo $place; ?>", desc:$('#desc').val(), number:$('#number').val(), tva_tx: vatRate} );
99  parent.$.colorbox.close();
100  }
101 
102  $( document ).ready(function() {
103  $('#desc').focus()
104  });
105 </script>
106 </head>
107 <body>
108 <br>
109 <center>
110 <input type="text" id="desc" name="desc" class="takepospay" style="width:40%;" placeholder="<?php echo $langs->trans('Description'); ?>">
111 <?php
112 if ($action == "freezone") echo '<input type="text" id="number" name="number" class="takepospay" style="width:15%;" placeholder="'.$langs->trans('Price').'">';
113 if ($action == "addnote") echo '<input type="hidden" id="number" name="number" value="'.$idline.'">';
114 ?>
115 <input type="hidden" name="place" class="takepospay" value="<?php echo $place; ?>">
116 <input type="button" class="button takepospay clearboth" value="OK" onclick="Save();">
117 <?php
118 if ($action == 'freezone') {
119  require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
120 
121  $form = new Form($db);
122  $num = $form->load_cache_vatrates("'".$mysoc->country_code."'");
123  if ($num > 0) {
124  print '<br><br>';
125  print $langs->trans('VAT').' : ';
126  foreach ($form->cache_vatrates as $rate) {
127  print '<button type="button" class="button item_value vat_rate'.($rate['txtva'] == $vatRateDefault ? ' selected' : '').'" id="vat_rate_'.$rate['rowid'].'" onclick="ApplyVATRate(\''.$rate['rowid'].'\', \''.$rate['txtva'].'\');">'.$rate['txtva'].' %</button>';
128  }
129  }
130 }
131 ?>
132 </center>
133 
134 </body>
135 </html>
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
top_htmlhead($head, $title= '', $disablejs=0, $disablehead=0, $arrayofjs= '', $arrayofcss= '', $disablejmobile=0, $disablenofollow=0)
Ouput html header of a page.
Definition: main.inc.php:1280
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
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
Draft customers invoices.
Definition: index.php:89
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) Si ...
Class to manage invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105