29if (!defined(
'NOTOKENRENEWAL')) {
30 define(
'NOTOKENRENEWAL',
'1');
32if (!defined(
'NOREQUIREMENU')) {
33 define(
'NOREQUIREMENU',
'1');
35if (!defined(
'NOREQUIREHTML')) {
36 define(
'NOREQUIREHTML',
'1');
38if (!defined(
'NOREQUIREAJAX')) {
39 define(
'NOREQUIREAJAX',
'1');
43require
'../main.inc.php';
44require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
50if (!$user->hasRight(
'takepos',
'run')) {
61 $invoice->fetch($invoiceid);
63 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture where ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
64 $resql = $db->query($sql);
65 $obj = $db->fetch_object($resql);
67 $invoiceid = $obj->rowid;
72 $invoice->fetch($invoiceid);
77$arrayofcss = array(
'/takepos/css/pos.css.php');
82$langs->loadLangs(array(
'main',
'bills',
'cashdesk'));
84if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) ||
getDolGlobalString(
'TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
85 $htmlReductionPercent =
'<span class="fa fa-2x fa-percent"></span>';
86 $htmlReductionAmount =
'<span class="fa fa-2x fa-money"></span><br>'.$langs->trans(
'Amount');
88 $htmlReductionPercent = $langs->trans(
'ReductionShort').
'<br>%';
89 $htmlReductionAmount = $langs->trans(
'ReductionShort').
'<br>'.$langs->trans(
'Amount');
92<link rel=
"stylesheet" href=
"css/pos.css.php">
98 var reductionType =
'';
99 var reductionTotal =
'';
102 var htmlBtnOK =
'<span style="font-size: 14pt;">OK</span>';
103 var htmlReductionPercent =
'<?php echo dol_escape_js($htmlReductionPercent); ?>';
104 var htmlReductionAmount =
'<?php echo dol_escape_js($htmlReductionAmount); ?>';
115 jQuery(
'#reduction_total').val(reductionTotal);
116 jQuery(
"#reduction_type_percent").html(htmlReductionPercent);
117 jQuery(
'#reduction_type_amount').html(htmlReductionAmount);
125 function Edit(number)
127 console.log(
'Edit ' + number);
129 if (number ===
'p') {
130 if (editAction ===
'p' && reductionType ===
'percent'){
135 reductionType =
'percent';
136 }
else if (number ===
'a') {
137 if (editAction ===
'a' && reductionType ===
'amount'){
142 reductionType =
'amount';
145 if (editAction ===
'p'){
146 jQuery(
'#reduction_type_percent').html(htmlBtnOK);
147 jQuery(
'#reduction_type_amount').html(htmlReductionAmount);
148 }
else if (editAction ===
'a'){
149 jQuery(
'#reduction_type_amount').html(htmlBtnOK);
150 jQuery(
"#reduction_type_percent").html(htmlReductionPercent);
152 jQuery(
'#reduction_type_percent').html(htmlReductionPercent);
153 jQuery(
'#reduction_type_amount').html(htmlReductionAmount);
156 $(
"#reduction_total").focus();
164 function AddReduction(reductionNumber)
166 console.log(
'AddReduction ' + reductionNumber);
168 reductionTotal += String(reductionNumber);
169 jQuery(
'#reduction_total').val(reductionTotal);
175 function ValidateReduction()
177 console.log(
'ValidateReduction');
178 reductionTotal = jQuery(
'#reduction_total').val();
180 reductionTotal = $(
"#reduction_total").val();
182 if (reductionTotal.length <= 0) {
183 console.error(
'Error no reduction');
187 var reductionNumber = parseFloat(reductionTotal);
188 if (isNaN(reductionNumber)) {
189 console.error(
'Error not a valid number :', reductionNumber);
193 if (reductionType ===
'percent') {
194 var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
195 parent.$(
"#poslines").load(
"invoice.php?action=update_reduction_global&token=<?php echo newToken(); ?>&place=<?php echo $place; ?>&number="+reductionNumber+
"&invoiceid="+invoiceid,
function() {
197 parent.$.colorbox.close();
199 }
else if (reductionType ===
'amount') {
200 var desc =
"<?php echo dol_escape_js($langs->transnoentities('Reduction')); ?>";
201 parent.$(
"#poslines").load(
"invoice.php?action=freezone&token=<?php echo newToken(); ?>&place=<?php echo $place; ?>&number=-"+reductionNumber+
"&desc="+desc,
function() {
203 parent.$.colorbox.close();
206 console.error(
'Error bad reduction type :', reductionType);
214 function formvalid(
type) {
215 reductionType =
type;
216 if (reductionType !=
"") {
217 return ValidateReduction();
226<div style=
"position:absolute; top:2%; left:5%; width:91%;">
229print
'<input type="text" class="takepospay width125" id="reduction_total" name="reduction_total" placeholder="'.$langs->trans(
'Reduction').
'" autofocus>';
231 print
'<input type="button" class="butAction" value="'.$langs->trans(
'AmountTTC').
'" onclick="return formvalid(\'amount\');">';
232 print
'<input type="button" class="butAction" value="'.$langs->trans(
'Percentage').
'" onclick="return formvalid(\'percent\');">';
238<div style=
"position:absolute; top:33%; left:5%; height:52%; width:92%;">
241print
'<button type="button" class="calcbutton" onclick="AddReduction(\'7\');">7</button>';
242print
'<button type="button" class="calcbutton" onclick="AddReduction(\'8\');">8</button>';
243print
'<button type="button" class="calcbutton" onclick="AddReduction(\'9\');">9</button>';
244print
'<button type="button" class="calcbutton2" id="reduction_type_percent" onclick="Edit(\'p\');">'.$htmlReductionPercent.
'</button>';
245print
'<button type="button" class="calcbutton" onclick="AddReduction(\'4\');">4</button>';
246print
'<button type="button" class="calcbutton" onclick="AddReduction(\'5\');">5</button>';
247print
'<button type="button" class="calcbutton" onclick="AddReduction(\'6\');">6</button>';
248print
'<button type="button" class="calcbutton2" id="reduction_type_amount" onclick="Edit(\'a\');">'.$htmlReductionAmount.
'</button>';
249print
'<button type="button" class="calcbutton" onclick="AddReduction(\'1\');">1</button>';
250print
'<button type="button" class="calcbutton" onclick="AddReduction(\'2\');">2</button>';
251print
'<button type="button" class="calcbutton" onclick="AddReduction(\'3\');">3</button>';
252print
'<button type="button" class="calcbutton3 poscolorblue" onclick="Reset();"><span id="printtext" style="font-weight: bold; font-size: 18pt;">C</span></button>';
253print
'<button type="button" class="calcbutton" onclick="AddReduction(\'0\');">0</button>';
254print
'<button type="button" class="calcbutton" onclick="AddReduction(\'.\');">.</button>';
255print
'<button type="button" class="calcbutton"> </button>';
256print
'<button type="button" class="calcbutton3 poscolordelete" onclick="parent.$.colorbox.close();"><span id="printtext" style="font-weight: bold; font-size: 18pt;">X</span></button>';
Class to manage invoices.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.