31if (!defined(
'NOTOKENRENEWAL')) {
32 define(
'NOTOKENRENEWAL',
'1');
34if (!defined(
'NOREQUIREMENU')) {
35 define(
'NOREQUIREMENU',
'1');
37if (!defined(
'NOREQUIREHTML')) {
38 define(
'NOREQUIREHTML',
'1');
40if (!defined(
'NOREQUIREAJAX')) {
41 define(
'NOREQUIREAJAX',
'1');
45require
'../main.inc.php';
46require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
60if (!$user->hasRight(
'takepos',
'run')) {
71 $invoice->fetch($invoiceid);
73 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
74 $sql .=
" WHERE ref = '(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
75 $sql .=
" AND entity IN (".getEntity(
'invoice').
")";
77 $resql = $db->query($sql);
78 $obj = $db->fetch_object($resql);
80 $invoiceid = $obj->rowid;
85 $invoice->fetch($invoiceid);
90$arrayofcss = array(
'/takepos/css/pos.css.php');
95$langs->loadLangs(array(
'main',
'bills',
'cashdesk'));
97if (!isset(
$conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) ||
getDolGlobalString(
'TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
98 $htmlReductionPercent =
'<span class="fa fa-2x fa-percent"></span>';
99 $htmlReductionAmount =
'<span class="fa fa-2x fa-money"></span><br>'.$langs->trans(
'Amount');
101 $htmlReductionPercent = $langs->trans(
'ReductionShort').
'<br>%';
102 $htmlReductionAmount = $langs->trans(
'ReductionShort').
'<br>'.$langs->trans(
'Amount');
105<link rel=
"stylesheet" href=
"css/pos.css.php">
111 var reductionType =
'';
112 var reductionTotal =
'';
115 var htmlBtnOK =
'<span style="font-size: 14pt;">OK</span>';
116 var htmlReductionPercent = <?php echo
"'".dol_escape_js($htmlReductionPercent).
"'" ; ?>;
117 var htmlReductionAmount = <?php echo
"'".dol_escape_js($htmlReductionAmount).
"'" ; ?>;
128 jQuery(
'#reduction_total').val(reductionTotal);
129 jQuery(
"#reduction_type_percent").html(htmlReductionPercent);
130 jQuery(
'#reduction_type_amount').html(htmlReductionAmount);
138 function Edit(number)
140 console.log(
'Edit ' + number);
142 if (number ===
'p') {
143 if (editAction ===
'p' && reductionType ===
'percent'){
148 reductionType =
'percent';
149 }
else if (number ===
'a') {
150 if (editAction ===
'a' && reductionType ===
'amount'){
155 reductionType =
'amount';
158 if (editAction ===
'p'){
159 jQuery(
'#reduction_type_percent').html(htmlBtnOK);
160 jQuery(
'#reduction_type_amount').html(htmlReductionAmount);
161 }
else if (editAction ===
'a'){
162 jQuery(
'#reduction_type_amount').html(htmlBtnOK);
163 jQuery(
"#reduction_type_percent").html(htmlReductionPercent);
165 jQuery(
'#reduction_type_percent').html(htmlReductionPercent);
166 jQuery(
'#reduction_type_amount').html(htmlReductionAmount);
169 $(
"#reduction_total").focus();
177 function AddReduction(reductionNumber)
179 console.log(
'AddReduction ' + reductionNumber);
181 reductionTotal += String(reductionNumber);
182 jQuery(
'#reduction_total').val(reductionTotal);
188 function ValidateReduction()
190 console.log(
'ValidateReduction');
191 reductionTotal = jQuery(
'#reduction_total').val();
193 reductionTotal = $(
"#reduction_total").val();
195 if (reductionTotal.length <= 0) {
196 console.error(
'Error no reduction');
200 var reductionNumber = parseFloat(reductionTotal);
201 if (isNaN(reductionNumber)) {
202 console.error(
'Error not a valid number :', reductionNumber);
206 if (reductionType ===
'percent') {
207 var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
208 parent.$(
"#poslines").load(
"invoice.php?action=update_reduction_global&token=<?php echo newToken(); ?>&place=<?php echo $place; ?>&number="+reductionNumber+
"&invoiceid="+invoiceid,
function() {
210 parent.$.colorbox.close();
212 }
else if (reductionType ===
'amount') {
213 var desc = <?php echo
"'".dol_escape_js($langs->transnoentities(
'Reduction')).
"'" ; ?>;
214 parent.$(
"#poslines").load(
"invoice.php?action=freezone&token=<?php echo newToken(); ?>&place=<?php echo $place; ?>&number=-"+reductionNumber+
"&desc="+desc,
function() {
216 parent.$.colorbox.close();
219 console.error(
'Error bad reduction type :', reductionType);
227 function formvalid(
type) {
228 reductionType =
type;
229 if (reductionType !=
"") {
230 return ValidateReduction();
239<div style=
"position:absolute; top:2%; left:5%; width:91%;">
242print
'<input type="text" class="takepospay width125" id="reduction_total" name="reduction_total" placeholder="'.$langs->trans(
'Reduction').
'" autofocus>';
244 print
'<input type="button" class="butAction" value="'.$langs->trans(
'AmountTTC').
'" onclick="return formvalid(\'amount\');">';
245 print
'<input type="button" class="butAction" value="'.$langs->trans(
'Percentage').
'" onclick="return formvalid(\'percent\');">';
251<div style=
"position:absolute; top:33%; left:5%; height:52%; width:92%;">
254print
'<button type="button" class="calcbutton" onclick="AddReduction(\'7\');">7</button>';
255print
'<button type="button" class="calcbutton" onclick="AddReduction(\'8\');">8</button>';
256print
'<button type="button" class="calcbutton" onclick="AddReduction(\'9\');">9</button>';
257print
'<button type="button" class="calcbutton2" id="reduction_type_percent" onclick="Edit(\'p\');">'.$htmlReductionPercent.
'</button>';
258print
'<button type="button" class="calcbutton" onclick="AddReduction(\'4\');">4</button>';
259print
'<button type="button" class="calcbutton" onclick="AddReduction(\'5\');">5</button>';
260print
'<button type="button" class="calcbutton" onclick="AddReduction(\'6\');">6</button>';
261print
'<button type="button" class="calcbutton2" id="reduction_type_amount" onclick="Edit(\'a\');">'.$htmlReductionAmount.
'</button>';
262print
'<button type="button" class="calcbutton" onclick="AddReduction(\'1\');">1</button>';
263print
'<button type="button" class="calcbutton" onclick="AddReduction(\'2\');">2</button>';
264print
'<button type="button" class="calcbutton" onclick="AddReduction(\'3\');">3</button>';
265print
'<button type="button" class="calcbutton3 poscolorblue" onclick="Reset();"><span id="printtext" style="font-weight: bold; font-size: 18pt;">C</span></button>';
266print
'<button type="button" class="calcbutton" onclick="AddReduction(\'0\');">0</button>';
267print
'<button type="button" class="calcbutton" onclick="AddReduction(\'.\');">.</button>';
268print
'<button type="button" class="calcbutton"> </button>';
269print
'<button type="button" class="calcbutton3 poscolordelete" onclick="parent.$.colorbox.close();"><span id="printtext" style="font-weight: bold; font-size: 18pt;">X</span></button>';
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Class to manage invoices.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalString($key, $default='')
Return a 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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.