30if (!defined(
'NOTOKENRENEWAL')) {
31 define(
'NOTOKENRENEWAL',
'1');
33if (!defined(
'NOREQUIREMENU')) {
34 define(
'NOREQUIREMENU',
'1');
36if (!defined(
'NOREQUIREHTML')) {
37 define(
'NOREQUIREHTML',
'1');
39if (!defined(
'NOREQUIREAJAX')) {
40 define(
'NOREQUIREAJAX',
'1');
44require
'../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
59if (!$user->hasRight(
'takepos',
'run')) {
70 $invoice->fetch($invoiceid);
72 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
73 $sql .=
" WHERE ref = '(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
74 $sql .=
" AND entity IN (".getEntity(
'invoice').
")";
76 $resql = $db->query($sql);
77 $obj = $db->fetch_object($resql);
79 $invoiceid = $obj->rowid;
84 $invoice->fetch($invoiceid);
89$arrayofcss = array(
'/takepos/css/pos.css.php');
94$langs->loadLangs(array(
'main',
'bills',
'cashdesk'));
96if (!isset(
$conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) ||
getDolGlobalString(
'TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
97 $htmlReductionPercent =
'<span class="fa fa-2x fa-percent"></span>';
98 $htmlReductionAmount =
'<span class="fa fa-2x fa-money"></span><br>'.$langs->trans(
'Amount');
100 $htmlReductionPercent = $langs->trans(
'ReductionShort').
'<br>%';
101 $htmlReductionAmount = $langs->trans(
'ReductionShort').
'<br>'.$langs->trans(
'Amount');
104<link rel=
"stylesheet" href=
"css/pos.css.php">
110 var reductionType =
'';
111 var reductionTotal =
'';
114 var htmlBtnOK =
'<span style="font-size: 14pt;">OK</span>';
115 var htmlReductionPercent =
'<?php echo dol_escape_js($htmlReductionPercent); ?>';
116 var htmlReductionAmount =
'<?php echo dol_escape_js($htmlReductionAmount); ?>';
127 jQuery(
'#reduction_total').val(reductionTotal);
128 jQuery(
"#reduction_type_percent").html(htmlReductionPercent);
129 jQuery(
'#reduction_type_amount').html(htmlReductionAmount);
137 function Edit(number)
139 console.log(
'Edit ' + number);
141 if (number ===
'p') {
142 if (editAction ===
'p' && reductionType ===
'percent'){
147 reductionType =
'percent';
148 }
else if (number ===
'a') {
149 if (editAction ===
'a' && reductionType ===
'amount'){
154 reductionType =
'amount';
157 if (editAction ===
'p'){
158 jQuery(
'#reduction_type_percent').html(htmlBtnOK);
159 jQuery(
'#reduction_type_amount').html(htmlReductionAmount);
160 }
else if (editAction ===
'a'){
161 jQuery(
'#reduction_type_amount').html(htmlBtnOK);
162 jQuery(
"#reduction_type_percent").html(htmlReductionPercent);
164 jQuery(
'#reduction_type_percent').html(htmlReductionPercent);
165 jQuery(
'#reduction_type_amount').html(htmlReductionAmount);
168 $(
"#reduction_total").focus();
176 function AddReduction(reductionNumber)
178 console.log(
'AddReduction ' + reductionNumber);
180 reductionTotal += String(reductionNumber);
181 jQuery(
'#reduction_total').val(reductionTotal);
187 function ValidateReduction()
189 console.log(
'ValidateReduction');
190 reductionTotal = jQuery(
'#reduction_total').val();
192 reductionTotal = $(
"#reduction_total").val();
194 if (reductionTotal.length <= 0) {
195 console.error(
'Error no reduction');
199 var reductionNumber = parseFloat(reductionTotal);
200 if (isNaN(reductionNumber)) {
201 console.error(
'Error not a valid number :', reductionNumber);
205 if (reductionType ===
'percent') {
206 var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
207 parent.$(
"#poslines").load(
"invoice.php?action=update_reduction_global&token=<?php echo newToken(); ?>&place=<?php echo $place; ?>&number="+reductionNumber+
"&invoiceid="+invoiceid,
function() {
209 parent.$.colorbox.close();
211 }
else if (reductionType ===
'amount') {
212 var desc =
"<?php echo dol_escape_js($langs->transnoentities('Reduction')); ?>";
213 parent.$(
"#poslines").load(
"invoice.php?action=freezone&token=<?php echo newToken(); ?>&place=<?php echo $place; ?>&number=-"+reductionNumber+
"&desc="+desc,
function() {
215 parent.$.colorbox.close();
218 console.error(
'Error bad reduction type :', reductionType);
226 function formvalid(
type) {
227 reductionType =
type;
228 if (reductionType !=
"") {
229 return ValidateReduction();
238<div style=
"position:absolute; top:2%; left:5%; width:91%;">
241print
'<input type="text" class="takepospay width125" id="reduction_total" name="reduction_total" placeholder="'.$langs->trans(
'Reduction').
'" autofocus>';
243 print
'<input type="button" class="butAction" value="'.$langs->trans(
'AmountTTC').
'" onclick="return formvalid(\'amount\');">';
244 print
'<input type="button" class="butAction" value="'.$langs->trans(
'Percentage').
'" onclick="return formvalid(\'percent\');">';
250<div style=
"position:absolute; top:33%; left:5%; height:52%; width:92%;">
253print
'<button type="button" class="calcbutton" onclick="AddReduction(\'7\');">7</button>';
254print
'<button type="button" class="calcbutton" onclick="AddReduction(\'8\');">8</button>';
255print
'<button type="button" class="calcbutton" onclick="AddReduction(\'9\');">9</button>';
256print
'<button type="button" class="calcbutton2" id="reduction_type_percent" onclick="Edit(\'p\');">'.$htmlReductionPercent.
'</button>';
257print
'<button type="button" class="calcbutton" onclick="AddReduction(\'4\');">4</button>';
258print
'<button type="button" class="calcbutton" onclick="AddReduction(\'5\');">5</button>';
259print
'<button type="button" class="calcbutton" onclick="AddReduction(\'6\');">6</button>';
260print
'<button type="button" class="calcbutton2" id="reduction_type_amount" onclick="Edit(\'a\');">'.$htmlReductionAmount.
'</button>';
261print
'<button type="button" class="calcbutton" onclick="AddReduction(\'1\');">1</button>';
262print
'<button type="button" class="calcbutton" onclick="AddReduction(\'2\');">2</button>';
263print
'<button type="button" class="calcbutton" onclick="AddReduction(\'3\');">3</button>';
264print
'<button type="button" class="calcbutton3 poscolorblue" onclick="Reset();"><span id="printtext" style="font-weight: bold; font-size: 18pt;">C</span></button>';
265print
'<button type="button" class="calcbutton" onclick="AddReduction(\'0\');">0</button>';
266print
'<button type="button" class="calcbutton" onclick="AddReduction(\'.\');">.</button>';
267print
'<button type="button" class="calcbutton"> </button>';
268print
'<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 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.