dolibarr 18.0.8
invoice.php
Go to the documentation of this file.
1<?php
26// if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language
27// if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language
28// if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
29// if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
30
31if (!defined('NOTOKENRENEWAL')) {
32 define('NOTOKENRENEWAL', '1');
33}
34if (!defined('NOREQUIREMENU')) {
35 define('NOREQUIREMENU', '1');
36}
37if (!defined('NOREQUIREHTML')) {
38 define('NOREQUIREHTML', '1');
39}
40if (!defined('NOREQUIREAJAX')) {
41 define('NOREQUIREAJAX', '1');
42}
43
44// Load Dolibarr environment
45if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
46 require '../main.inc.php';
47}
48require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
49require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
50require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
51require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
52
53$hookmanager->initHooks(array('takeposinvoice'));
54
55$langs->loadLangs(array("companies", "commercial", "bills", "cashdesk", "stocks", "banks"));
56
57$action = GETPOST('action', 'aZ09');
58$idproduct = GETPOST('idproduct', 'int');
59$place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is id of table for Bar or Restaurant
60$placeid = 0; // $placeid is ID of invoice
61$mobilepage = GETPOST('mobilepage', 'alpha');
62
63// Terminal is stored into $_SESSION["takeposterminal"];
64
65if (empty($user->rights->takepos->run) && !defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
67}
68
69if ((getDolGlobalString('TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->layout == 'phone') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
70 // DIRECT LINK TO THIS PAGE FROM MOBILE AND NO TERMINAL SELECTED
71 if ($_SESSION["takeposterminal"] == "") {
72 if (getDolGlobalString('TAKEPOS_NUM_TERMINALS') == "1") {
73 $_SESSION["takeposterminal"] = 1;
74 } else {
75 header("Location: ".DOL_URL_ROOT."/takepos/index.php");
76 exit;
77 }
78 }
79}
80
81// When session has expired (selected terminal has been lost from session), redirect to the terminal selection.
82if (empty($_SESSION["takeposterminal"])) {
83 if (getDolGlobalInt('TAKEPOS_NUM_TERMINALS') == 1) {
84 $_SESSION["takeposterminal"] = 1; // Use terminal 1 if there is only 1 terminal
85 } elseif (!empty($_COOKIE["takeposterminal"])) {
86 $_SESSION["takeposterminal"] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE["takeposterminal"]); // Restore takeposterminal from previous session
87 } else {
88 print <<<SCRIPT
89<script language="javascript">
90 $( document ).ready(function() {
91 ModalBox('ModalTerminal');
92 });
93</script>
94SCRIPT;
95 exit;
96 }
97}
98
105function fail($message)
106{
107 header($_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error', true, 500);
108 die($message);
109}
110
111
112
113$number = GETPOST('number', 'alpha');
114$idline = GETPOST('idline', 'int');
115$selectedline = GETPOST('selectedline', 'int');
116$desc = GETPOST('desc', 'alphanohtml');
117$pay = GETPOST('pay', 'aZ09');
118$amountofpayment = price2num(GETPOST('amount', 'alpha'));
119
120$invoiceid = GETPOST('invoiceid', 'int');
121
122$paycode = $pay;
123if ($pay == 'cash') {
124 $paycode = 'LIQ'; // For backward compatibility
125}
126if ($pay == 'card') {
127 $paycode = 'CB'; // For backward compatibility
128}
129if ($pay == 'cheque') {
130 $paycode = 'CHQ'; // For backward compatibility
131}
132
133// Retrieve paiementid
134$paiementid = 0;
135if ($paycode) {
136 $sql = "SELECT id FROM ".MAIN_DB_PREFIX."c_paiement";
137 $sql .= " WHERE entity IN (".getEntity('c_paiement').")";
138 $sql .= " AND code = '".$db->escape($paycode)."'";
139 $resql = $db->query($sql);
140 if ($resql) {
141 $obj = $db->fetch_object($resql);
142 if ($obj) {
143 $paiementid = $obj->id;
144 }
145 }
146}
147
148$invoice = new Facture($db);
149if ($invoiceid > 0) {
150 $ret = $invoice->fetch($invoiceid);
151} else {
152 $ret = $invoice->fetch('', '(PROV-POS'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '') .'-'.$place.')');
153}
154if ($ret > 0) {
155 $placeid = $invoice->id;
156}
157
158$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '');
159
160$soc = new Societe($db);
161if ($invoice->socid > 0) {
162 $soc->fetch($invoice->socid);
163} else {
164 $soc->fetch(getDolGlobalString("$constforcompanyid"));
165}
166
167// Change the currency of invoice if it was modified
168if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency"])) {
169 if ($invoice->multicurrency_code != $_SESSION["takeposcustomercurrency"]) {
170 $invoice->setMulticurrencyCode($_SESSION["takeposcustomercurrency"]);
171 }
172}
173
174
175/*
176 * Actions
177 */
178
179$parameters=array();
180$reshook=$hookmanager->executeHooks('doActions', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
181if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
182
183if (empty($reshook)) {
184 // Action to record a payment on a TakePOS invoice
185 if ($action == 'valid' && $user->hasRight('facture', 'creer')) {
186 $bankaccount = 0;
187 $error = 0;
188
189 if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) {
190 $bankaccount = GETPOST('accountid', 'int');
191 } else {
192 if ($pay == 'LIQ') {
193 $bankaccount = getDolGlobalString('CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]); // For backward compatibility
194 } elseif ($pay == "CHQ") {
195 $bankaccount = getDolGlobalString('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]); // For backward compatibility
196 } else {
197 $accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"];
198 $bankaccount = getDolGlobalString($accountname);
199 }
200 }
201
202 if ($bankaccount <= 0 && $pay != "delayed" && isModEnabled("banque")) {
203 $errormsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount"));
204 $error++;
205 }
206
207 $now = dol_now();
208 $res = 0;
209
210 $invoice = new Facture($db);
211 $invoice->fetch($placeid);
212
213 if ($invoice->total_ttc < 0) {
214 $invoice->type = $invoice::TYPE_CREDIT_NOTE;
215
216 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture";
217 $sql .= " WHERE entity IN (".getEntity('invoice').")";
218 $sql .= " AND fk_soc = ".((int) $invoice->socid);
219 $sql .= " AND type <> ".Facture::TYPE_CREDIT_NOTE;
220 $sql .= " AND fk_statut >= ".$invoice::STATUS_VALIDATED;
221 $sql .= " ORDER BY rowid DESC";
222
223 $resql = $db->query($sql);
224 if ($resql) {
225 $obj = $db->fetch_object($resql);
226 $fk_source = $obj->rowid;
227 if ($fk_source == null) {
228 fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer"));
229 }
230 } else {
231 fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer"));
232 }
233 $invoice->fk_facture_source = $fk_source;
234 $invoice->update($user);
235 }
236
237 $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"];
238 if ($error) {
239 dol_htmloutput_errors($errormsg, null, 1);
240 } elseif ($invoice->statut != Facture::STATUS_DRAFT) {
241 //If invoice is validated but it is not fully paid is not error and make the payment
242 if ($invoice->getRemainToPay() > 0) {
243 $res = 1;
244 } else {
245 dol_syslog("Sale already validated");
246 dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1);
247 }
248 } elseif (count($invoice->lines) == 0) {
249 $error++;
250 dol_syslog('Sale without lines');
251 dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1);
252 } elseif (isModEnabled('stock') && $conf->global->$constantforkey != "1") {
253 $savconst = $conf->global->STOCK_CALCULATE_ON_BILL;
254
255 if (isModEnabled('productbatch') && !getDolGlobalInt('CASHDESK_FORCE_DECREASE_STOCK')) {
256 $conf->global->STOCK_CALCULATE_ON_BILL = 0; // To not change the stock (not yet compatible with batch management)
257 } else {
258 $conf->global->STOCK_CALCULATE_ON_BILL = 1; // To force the change of stock
259 }
260
261 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
262 dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey);
263 $batch_rule = 0;
264 if (isModEnabled('productbatch') && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) {
265 require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
267 }
268 $res = $invoice->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule);
269
270 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
271 } else {
272 $res = $invoice->validate($user);
273 if ($res < 0) {
274 $error++;
275 $langs->load("admin");
276 dol_htmloutput_errors($invoice->error == 'NotConfigured' ? $langs->trans("NotConfigured").' (TakePos numbering module)': $invoice->error, $invoice->errors, 1);
277 }
278 }
279
280 // Restore save values
281 //if (!empty($sav_FACTURE_ADDON))
282 //{
283 // $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON;
284 //}
285
286 // Add the payment
287 if (!$error && $res >= 0) {
288 $remaintopay = $invoice->getRemainToPay();
289 if ($remaintopay > 0) {
290 $payment = new Paiement($db);
291 $payment->datepaye = $now;
292 $payment->fk_account = $bankaccount;
293 $payment->amounts[$invoice->id] = $amountofpayment;
294 if ($pay == 'LIQ') {
295 $payment->pos_change = price2num(GETPOST('excess', 'alpha'));
296 }
297
298 // If user has not used change control, add total invoice payment
299 // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay
300 if ($amountofpayment <= 0 || $amountofpayment > $remaintopay) {
301 $payment->amounts[$invoice->id] = $remaintopay;
302 }
303
304 $payment->paiementid = $paiementid;
305 $payment->num_payment = $invoice->ref;
306
307 if ($pay != "delayed") {
308 $payment->create($user);
309 $res = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
310 if ($res < 0) {
311 $error++;
312 dol_htmloutput_errors($langs->trans('ErrorNoPaymentDefined'), $payment->errors, 1);
313 }
314 $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded
315 } elseif (getDolGlobalInt("TAKEPOS_DELAYED_TERMS")) {
316 $invoice->setPaymentTerms(getDolGlobalInt("TAKEPOS_DELAYED_TERMS"));
317 }
318 }
319
320 if ($remaintopay == 0) {
321 dol_syslog("Invoice is paid, so we set it to status Paid");
322 $result = $invoice->setPaid($user);
323 if ($result > 0) {
324 $invoice->paye = 1;
325 }
326 // set payment method
327 $invoice->setPaymentMethods($paiementid);
328 } else {
329 dol_syslog("Invoice is not paid, remain to pay = ".$remaintopay);
330 }
331 } else {
332 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
333 }
334 }
335
336 if ($action == 'creditnote' && $user->hasRight('facture', 'creer')) {
337 $creditnote = new Facture($db);
338 $creditnote->socid = $invoice->socid;
339 $creditnote->date = dol_now();
340 $creditnote->module_source = 'takepos';
341 $creditnote->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ;
342 $creditnote->type = Facture::TYPE_CREDIT_NOTE;
343 $creditnote->fk_facture_source = $placeid;
344 $creditnote->remise_absolue = $invoice->remise_absolue;
345 $creditnote->remise_percent = $invoice->remise_percent;
346 $creditnote->create($user);
347
348 foreach ($invoice->lines as $line) {
349 // Extrafields
350 if (method_exists($line, 'fetch_optionals')) {
351 // load extrafields
352 $line->fetch_optionals();
353 }
354 // Reset fk_parent_line for no child products and special product
355 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
356 $fk_parent_line = 0;
357 }
358
359 if (getDolGlobalInt('INVOICE_USE_SITUATION')) {
360 if (!empty($invoice->situation_counter)) {
361 $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id
362 $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from
363 if (!empty($invoice->tab_previous_situation_invoice)) {
364 // search the last standard invoice in cycle and the possible credit note between this last and invoice
365 // TODO Move this out of loop of $invoice->lines
366 $tab_jumped_credit_notes = array();
367 $lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
368 $searchPreviousInvoice = true;
369 while ($searchPreviousInvoice) {
370 if ($invoice->tab_previous_situation_invoice[$lineIndex]->situation_cycle_ref || $lineIndex < 1) {
371 $searchPreviousInvoice = false; // find, exit;
372 break;
373 } else {
374 if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) {
375 $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id;
376 }
377 $lineIndex--; // go to previous invoice in cycle
378 }
379 }
380
381 $maxPrevSituationPercent = 0;
382 foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
383 if ($prevLine->id == $source_fk_prev_id) {
384 $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
385
386 //$line->subprice = $line->subprice - $prevLine->subprice;
387 $line->total_ht = $line->total_ht - $prevLine->total_ht;
388 $line->total_tva = $line->total_tva - $prevLine->total_tva;
389 $line->total_ttc = $line->total_ttc - $prevLine->total_ttc;
390 $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1;
391 $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2;
392
393 $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice;
394 $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht;
395 $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva;
396 $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc;
397 }
398 }
399
400 // prorata
401 $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
402
403 //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'<br>';
404
405 // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta)
406 $maxPrevSituationPercent = 0;
407 foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
408 foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) {
409 if ($prevLine->fk_prev_id == $source_fk_prev_id) {
410 $maxPrevSituationPercent = $prevLine->situation_percent;
411
412 $line->total_ht -= $prevLine->total_ht;
413 $line->total_tva -= $prevLine->total_tva;
414 $line->total_ttc -= $prevLine->total_ttc;
415 $line->total_localtax1 -= $prevLine->total_localtax1;
416 $line->total_localtax2 -= $prevLine->total_localtax2;
417
418 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
419 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
420 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
421 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
422 }
423 }
424 }
425
426 // prorata
427 $line->situation_percent += $maxPrevSituationPercent;
428
429 //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'<br>';
430 }
431 }
432 }
433
434 $line->fk_facture = $creditnote->id;
435 $line->fk_parent_line = $fk_parent_line;
436
437 $line->subprice = -$line->subprice; // invert price for object
438 $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here
439 $line->total_ht = -$line->total_ht;
440 $line->total_tva = -$line->total_tva;
441 $line->total_ttc = -$line->total_ttc;
442 $line->total_localtax1 = -$line->total_localtax1;
443 $line->total_localtax2 = -$line->total_localtax2;
444
445 $line->multicurrency_subprice = -$line->multicurrency_subprice;
446 $line->multicurrency_total_ht = -$line->multicurrency_total_ht;
447 $line->multicurrency_total_tva = -$line->multicurrency_total_tva;
448 $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
449
450 $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked
451
452 $creditnote->lines[] = $line; // insert new line in current object
453
454 // Defined the new fk_parent_line
455 if ($result > 0 && $line->product_type == 9) {
456 $fk_parent_line = $result;
457 }
458 }
459 $creditnote->update_price(1);
460
461 $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"];
462 if (isModEnabled('stock') && $conf->global->$constantforkey != "1") {
463 $savconst = $conf->global->STOCK_CALCULATE_ON_BILL;
464 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
465 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
466 dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey);
467 $batch_rule = 0;
468 if (isModEnabled('productbatch') && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) {
469 require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
471 }
472 $res = $creditnote->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule);
473 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
474 } else {
475 $res = $creditnote->validate($user);
476 }
477 }
478
479 if ($action == 'history' || $action == 'creditnote') {
480 if ($action == 'creditnote') {
481 $placeid = $creditnote->id;
482 } else {
483 $placeid = (int) GETPOST('placeid', 'int');
484 }
485 $invoice = new Facture($db);
486 $invoice->fetch($placeid);
487 }
488
489 // If we add a line and no invoice yet, we create the invoice
490 if (($action == "addline" || $action == "freezone") && $placeid == 0) {
491 $invoice->socid = getDolGlobalString($constforcompanyid);
492
493 $dolnowtzuserrel = dol_now('tzuserrel'); // If user is 02 january 22:00, we want to store '02 january'
494 $monthuser = dol_print_date($dolnowtzuserrel, '%m', 'gmt');
495 $dayuser = dol_print_date($dolnowtzuserrel, '%d', 'gmt');
496 $yearuser = dol_print_date($dolnowtzuserrel, '%Y', 'gmt');
497 $dateinvoice = dol_mktime(0, 0, 0, (int) $monthuser, (int) $dayuser, (int) $yearuser, 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server
498
499 include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
500 $invoice->date = $dateinvoice; // Invoice::create() needs a date with no hours
501
502 $invoice->module_source = 'takepos';
503 $invoice->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ;
504 $invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity;
505
506 if ($invoice->socid <= 0) {
507 $langs->load('errors');
508 dol_htmloutput_errors($langs->trans("ErrorModuleSetupNotComplete", "TakePos"), null, 1);
509 } else {
510 // Create invoice
511 $placeid = $invoice->create($user);
512 if ($placeid < 0) {
513 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
514 }
515 $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid = ".((int) $placeid);
516 $db->query($sql);
517 }
518 }
519
520 if ($action == "addline") {
521 $prod = new Product($db);
522 $prod->fetch($idproduct);
523
524 $customer = new Societe($db);
525 $customer->fetch($invoice->socid);
526
527 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
528
529 $qty = GETPOSTISSET('qty') ? GETPOST('qty', 'int') : 1;
530 $price = $datapriceofproduct['pu_ht'];
531 $price_ttc = $datapriceofproduct['pu_ttc'];
532 //$price_min = $datapriceofproduct['price_min'];
533 $price_base_type = empty($datapriceofproduct['price_base_type']) ? 'HT' : $datapriceofproduct['price_base_type'];
534 $tva_tx = $datapriceofproduct['tva_tx'];
535 $tva_npr = $datapriceofproduct['tva_npr'];
536
537 // Local Taxes
538 $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
539 $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
540
541 if (!empty($conf->global->TAKEPOS_SUPPLEMENTS)) {
542 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
543 $cat = new Categorie($db);
544 $categories = $cat->containing($idproduct, 'product');
545 $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories, 'id')));
546 if ($found !== false) { // If this product is a supplement
547 $sql = "SELECT fk_parent_line FROM ".MAIN_DB_PREFIX."facturedet where rowid=$selectedline";
548 $resql = $db->query($sql);
549 $row = $db->fetch_array($resql);
550 if ($row[0] == null) {
551 $parent_line = $selectedline;
552 } else {
553 $parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product
554 }
555 }
556 }
557
558 $idoflineadded = 0;
559 // Group if enabled. Skip group if line already sent to the printer
560 if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT)) {
561 foreach ($invoice->lines as $line) {
562 if ($line->product_ref == $prod->ref) {
563 if ($line->special_code==4) continue; // If this line is sended to printer create new line
564 $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty + $qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
565 if ($result < 0) {
566 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
567 } else {
568 $idoflineadded = $line->id;
569 }
570 break;
571 }
572 }
573 }
574 if ($idoflineadded <= 0) {
575 $invoice->fetch_thirdparty();
576 $array_options = array();
577
578 $line = array('description' => $prod->description, 'price' => $price, 'tva_tx' => $tva_tx, 'localtax1_tx' => $localtax1_tx, 'localtax2_tx' => $localtax2_tx, 'remise_percent' => $customer->remise_percent, 'price_ttc' => $price_ttc, 'array_options' => $array_options);
579
580 /* setup of margin calculation */
581 if (isset($conf->global->MARGIN_TYPE)) {
582 if ($conf->global->MARGIN_TYPE == 'pmp' && !empty($prod->pmp)) {
583 $line['fk_fournprice'] = null;
584 $line['pa_ht'] = $prod->pmp;
585 } elseif ($conf->global->MARGIN_TYPE == 'costprice' && !empty($prod->cost_price)) {
586 $line['fk_fournprice'] = null;
587 $line['pa_ht'] = $prod->cost_price;
588 } else {
589 // default is fournprice
590 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
591 $pf = new ProductFournisseur($db);
592 if ($pf->find_min_price_product_fournisseur($idproduct, $qty) > 0) {
593 $line['fk_fournprice'] = $pf->product_fourn_price_id;
594 $line['pa_ht'] = $pf->fourn_unitprice_with_discount;
595 if (getDolGlobalString('PRODUCT_CHARGES') && $pf->fourn_charges > 0)
596 $line['pa_ht'] += $pf->fourn_charges / $pf->fourn_qty;
597 }
598 }
599 }
600
601 // complete line by hook
602 $parameters = array('prod' => $prod, 'line' => $line);
603 $reshook=$hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action); // Note that $action and $line may have been modified by some hooks
604 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
605
606
607 if (empty($reshook)) {
608 if (!empty($hookmanager->resArray)) {
609 $line = $hookmanager->resArray;
610 }
611
612 $idoflineadded = $invoice->addline($line['description'], $line['price'], $qty, $line['tva_tx'], $line['localtax1_tx'], $line['localtax2_tx'], $idproduct, $line['remise_percent'], '', 0, 0, 0, '', $price_base_type, $line['price_ttc'], $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', $line['fk_fournprice'], $line['pa_ht'], '', $line['array_options'], 100, '', null, 0);
613 }
614
615 if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
616 $CUSTOMER_DISPLAY_line1 = $prod->label;
617 $CUSTOMER_DISPLAY_line2 = price($price_ttc);
618 }
619 }
620
621 $invoice->fetch($placeid);
622 }
623
624 if ($action == "freezone") {
625 $customer = new Societe($db);
626 $customer->fetch($invoice->socid);
627
628 $tva_tx = GETPOST('tva_tx', 'alpha');
629 if ($tva_tx != '') {
630 if (!preg_match('/\‍((.*)\‍)/', $tva_tx)) {
631 $tva_tx = price2num($tva_tx);
632 }
633 } else {
634 $tva_tx = get_default_tva($mysoc, $customer);
635 }
636
637 // Local Taxes
638 $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
639 $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
640
641 $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', getDolGlobalInt('TAKEPOS_DISCOUNT_TTC') ? ($number >= 0 ? 'HT' : 'TTC') : (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') ? 'HT' : 'TTC'), $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0);
642 $invoice->fetch($placeid);
643 }
644
645 if ($action == "addnote") {
646 $desc = GETPOST('addnote', 'alpha');
647 if ($idline==0) {
648 $invoice->update_note($desc, '_public');
649 } else foreach ($invoice->lines as $line) {
650 if ($line->id == $idline) {
651 $result = $invoice->updateline($line->id, $desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
652 }
653 }
654 $invoice->fetch($placeid);
655 }
656
657 if ($action == "deleteline") {
658 if ($idline > 0 and $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected.
659 $invoice->deleteline($idline);
660 $invoice->fetch($placeid);
661 } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line.
662 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture = ".((int) $placeid)." ORDER BY rowid DESC";
663 $resql = $db->query($sql);
664 $row = $db->fetch_array($resql);
665 $deletelineid = $row[0];
666 $invoice->deleteline($deletelineid);
667 $invoice->fetch($placeid);
668 }
669 if (count($invoice->lines) == 0) {
670 $invoice->delete($user);
671 header("Location: ".DOL_URL_ROOT."/takepos/invoice.php");
672 exit;
673 }
674 }
675
676 // Action to delete or discard an invoice
677 if ($action == "delete") {
678 // $placeid is the invoice id (it differs from place) and is defined if the place is set and the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')', so the fetch at begining of page works.
679 if ($placeid > 0) {
680 $result = $invoice->fetch($placeid);
681
682 if ($result > 0 && $invoice->statut == Facture::STATUS_DRAFT) {
683 $db->begin();
684
685 // We delete the lines
686 $resdeletelines = 1;
687 foreach ($invoice->lines as $line) {
688 $tmpres = $invoice->deleteline($line->id);
689 if ($tmpres < 0) {
690 $resdeletelines = 0;
691 break;
692 }
693 }
694
695 $sql = "UPDATE ".MAIN_DB_PREFIX."facture";
696 $varforconst = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
697 $sql .= " SET fk_soc = ".((int) $conf->global->$varforconst).", ";
698 $sql .= " datec = '".$db->idate(dol_now())."'";
699 $sql .= " WHERE entity IN (".getEntity('invoice').")";
700 $sql .= " AND ref = '(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'";
701 $resql1 = $db->query($sql);
702
703 if ($resdeletelines && $resql1) {
704 $db->commit();
705 } else {
706 $db->rollback();
707 }
708
709 $invoice->fetch($placeid);
710 }
711 }
712 }
713
714 if ($action == "updateqty") {
715 foreach ($invoice->lines as $line) {
716 if ($line->id == $idline) {
717 if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code == "4")) {
718 dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1);
719 } else {
720 $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
721 }
722 }
723 }
724
725 $invoice->fetch($placeid);
726 }
727
728 if ($action == "updateprice") {
729 $customer = new Societe($db);
730 $customer->fetch($invoice->socid);
731
732 foreach ($invoice->lines as $line) {
733 if ($line->id == $idline) {
734 $prod = new Product($db);
735 $prod->fetch($line->fk_product);
736 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
737 $price_min = $datapriceofproduct['price_min'];
738 $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
739 $pu_ht = price2num($number / (1 + ($line->tva_tx / 100)), 'MU');
740 //Check min price
741 if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($line->remise_percent) / 100) < price2num($price_min)))) {
742 $langs->load("products");
743 dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
744 //echo $langs->trans("CantBeLessThanMinPrice");
745 } else {
746 if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) {
747 dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1);
748 } elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) {
749 $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
750 } else {
751 $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
752 }
753 }
754 }
755 }
756
757 // Reload data
758 $invoice->fetch($placeid);
759 }
760
761 if ($action == "updatereduction") {
762 $customer = new Societe($db);
763 $customer->fetch($invoice->socid);
764
765 foreach ($invoice->lines as $line) {
766 if ($line->id == $idline) {
767 dol_syslog("updatereduction Process line ".$line->id.' to apply discount of '.$number.'%');
768
769 $prod = new Product($db);
770 $prod->fetch($line->fk_product);
771
772 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
773 $price_min = $datapriceofproduct['price_min'];
774 $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
775
776 $pu_ht = price2num($line->subprice / (1 + ($line->tva_tx / 100)), 'MU');
777
778 // Check min price
779 if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($line->subprice) * (1 - price2num($number) / 100) < price2num($price_min)))) {
780 $langs->load("products");
781 dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
782 } else {
783 if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) {
784 dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1);
785 } else {
786 $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
787 }
788 }
789 }
790 }
791
792 // Reload data
793 $invoice->fetch($placeid);
794 } elseif ($action == 'update_reduction_global') {
795 foreach ($invoice->lines as $line) {
796 $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
797 }
798
799 $invoice->fetch($placeid);
800 }
801
802 if ($action == "order" and $placeid != 0) {
803 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
804 if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") {
805 require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
806 $printer = new dolReceiptPrinter($db);
807 }
808
809 $sql = "SELECT label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place);
810 $resql = $db->query($sql);
811 $row = $db->fetch_object($resql);
812 $headerorder = '<html><br><b>'.$langs->trans('Place').' '.$row->label.'<br><table width="65%"><thead><tr><th class="left">'.$langs->trans("Label").'</th><th class="right">'.$langs->trans("Qty").'</th></tr></thead><tbody>';
813 $footerorder = '</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>';
814 $order_receipt_printer1 = "";
815 $order_receipt_printer2 = "";
816 $order_receipt_printer3 = "";
817 $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1);
818 $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2);
819 $catsprinter3 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3);
820 $linestoprint = 0;
821 foreach ($invoice->lines as $line) {
822 if ($line->special_code == "4") {
823 continue;
824 }
825 $c = new Categorie($db);
826 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
827 $result = array_intersect($catsprinter1, $existing);
828 $count = count($result);
829 if (!$line->fk_product) {
830 $count++; // Print Free-text item (Unassigned printer) to Printer 1
831 }
832 if ($count > 0) {
833 $linestoprint++;
834 $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1
835 $db->query($sql);
836 $order_receipt_printer1 .= '<tr><td class="left">';
837 if ($line->fk_product) {
838 $order_receipt_printer1 .= $line->product_label;
839 } else {
840 $order_receipt_printer1 .= $line->description;
841 }
842 $order_receipt_printer1 .= '</td><td class="right">'.$line->qty;
843 if (!empty($line->array_options['options_order_notes'])) {
844 $order_receipt_printer1 .= "<br>(".$line->array_options['options_order_notes'].")";
845 }
846 $order_receipt_printer1 .= '</td></tr>';
847 }
848 }
849 if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) {
850 $invoice->fetch($placeid); //Reload object before send to printer
851 $printer->orderprinter = 1;
852 echo "<script>";
853 echo "var orderprinter1esc='";
854 $ret = $printer->sendToPrinter($invoice, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]), getDolGlobalInt('TAKEPOS_ORDER_PRINTER1_TO_USE'.$_SESSION["takeposterminal"])); // PRINT TO PRINTER 1
855 echo "';</script>";
856 }
857 $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed
858 $db->query($sql);
859 $invoice->fetch($placeid); //Reload object after set lines as printed
860 $linestoprint = 0;
861
862 foreach ($invoice->lines as $line) {
863 if ($line->special_code == "4") {
864 continue;
865 }
866 $c = new Categorie($db);
867 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
868 $result = array_intersect($catsprinter2, $existing);
869 $count = count($result);
870 if ($count > 0) {
871 $linestoprint++;
872 $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2
873 $db->query($sql);
874 $order_receipt_printer2 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty;
875 if (!empty($line->array_options['options_order_notes'])) {
876 $order_receipt_printer2 .= "<br>(".$line->array_options['options_order_notes'].")";
877 }
878 $order_receipt_printer2 .= '</td></tr>';
879 }
880 }
881 if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) {
882 $invoice->fetch($placeid); //Reload object before send to printer
883 $printer->orderprinter = 2;
884 echo "<script>";
885 echo "var orderprinter2esc='";
886 $ret = $printer->sendToPrinter($invoice, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]), getDolGlobalInt('TAKEPOS_ORDER_PRINTER2_TO_USE'.$_SESSION["takeposterminal"])); // PRINT TO PRINTER 2
887 echo "';</script>";
888 }
889 $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed
890 $db->query($sql);
891 $invoice->fetch($placeid); //Reload object after set lines as printed
892 $linestoprint = 0;
893
894 foreach ($invoice->lines as $line) {
895 if ($line->special_code == "4") {
896 continue;
897 }
898 $c = new Categorie($db);
899 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
900 $result = array_intersect($catsprinter3, $existing);
901 $count = count($result);
902 if ($count > 0) {
903 $linestoprint++;
904 $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=".$line->id; //Set to print on printer 3
905 $db->query($sql);
906 $order_receipt_printer3 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty;
907 if (!empty($line->array_options['options_order_notes'])) {
908 $order_receipt_printer3 .= "<br>(".$line->array_options['options_order_notes'].")";
909 }
910 $order_receipt_printer3 .= '</td></tr>';
911 }
912 }
913 if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) {
914 $invoice->fetch($placeid); //Reload object before send to printer
915 $printer->orderprinter = 3;
916 echo "<script>";
917 echo "var orderprinter3esc='";
918 $ret = $printer->sendToPrinter($invoice, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]), getDolGlobalInt('TAKEPOS_ORDER_PRINTER3_TO_USE'.$_SESSION["takeposterminal"])); // PRINT TO PRINTER 3
919 echo "';</script>";
920 }
921 $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id; // Set as printed
922 $db->query($sql);
923 $invoice->fetch($placeid); //Reload object after set lines as printed
924 }
925
926 $sectionwithinvoicelink = '';
927 if ($action == "valid" || $action == "history" || $action == 'creditnote') {
928 $sectionwithinvoicelink .= '<!-- Section with invoice link -->'."\n";
929 $sectionwithinvoicelink .= '<span style="font-size:120%;" class="center">';
930 $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - ";
931 $remaintopay = $invoice->getRemainToPay();
932 if ($remaintopay > 0) {
933 $sectionwithinvoicelink .= $langs->trans('RemainToPay').': <span class="amountremaintopay" style="font-size: unset">'.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
934 } else {
935 if ($invoice->paye) {
936 $sectionwithinvoicelink .= '<span class="amountpaymentcomplete" style="font-size: unset">'.$langs->trans("Paid").'</span>';
937 } else {
938 $sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated');
939 }
940 }
941 $sectionwithinvoicelink .= '</span><br>';
942 if (getDolGlobalInt('TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
943 $sectionwithinvoicelink .= ' <a target="_blank" class="button" href="' . DOL_URL_ROOT . '/document.php?token=' . newToken() . '&modulepart=facture&file=' . $invoice->ref . '/' . $invoice->ref . '.pdf">Invoice</a>';
944 } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
945 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
946 $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="TakeposConnector('.$placeid.')">'.$langs->trans('PrintTicket').'</button>';
947 } else {
948 $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="TakeposPrinting('.$placeid.')">'.$langs->trans('PrintTicket').'</button>';
949 }
950 } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") {
951 $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="DolibarrTakeposPrinting('.$placeid.')">'.$langs->trans('PrintTicket').'</button>';
952 } else {
953 $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="Print('.$placeid.')">'.$langs->trans('PrintTicket').'</button>';
954 if (getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) {
955 $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="PrintBox('.$placeid.', \'without_details\')">'.$langs->trans('PrintWithoutDetails').'</button>';
956 }
957 if (getDolGlobalString('TAKEPOS_GIFT_RECEIPT')) {
958 $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="Print('.$placeid.', 1)">'.$langs->trans('GiftReceipt').'</button>';
959 }
960 }
961 if (getDolGlobalString('TAKEPOS_EMAIL_TEMPLATE_INVOICE') && $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) {
962 $sectionwithinvoicelink .= ' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.')">'.$langs->trans('SendTicket').'</button>';
963 }
964
965 if ($remaintopay <= 0 && getDolGlobalString('TAKEPOS_AUTO_PRINT_TICKETS') && $action != "history") {
966 $sectionwithinvoicelink .= '<script type="text/javascript">$("#buttonprint").click();</script>';
967 }
968 }
969}
970
971/*
972 * View
973 */
974
975$form = new Form($db);
976
977// llxHeader
978if ((getDolGlobalString('TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->layout == 'phone') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
979 $title = 'TakePOS - Dolibarr '.DOL_VERSION;
980 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
981 $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
982 }
983 $head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/>
984 <meta name="apple-mobile-web-app-capable" content="yes">
985 <meta name="mobile-web-app-capable" content="yes">
986 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
987 $arrayofcss = array(
988 '/takepos/css/pos.css.php',
989 );
990 $arrayofjs = array('/takepos/js/jquery.colorbox-min.js');
991 $disablejs = 0;
992 $disablehead = 0;
993 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
994
995 print '<body>'."\n";
996} else {
997 top_httphead('text/html', 1);
998}
999
1000?>
1001<!-- invoice.php -->
1002<script type="text/javascript">
1003var selectedline=0;
1004var selectedtext="";
1005<?php if ($action=="valid") echo "var place=0;";?> // Set to default place after close sale
1006var placeid=<?php echo ($placeid > 0 ? $placeid : 0); ?>;
1007$(document).ready(function() {
1008 var idoflineadded = <?php echo (empty($idoflineadded) ? 0 : $idoflineadded); ?>;
1009
1010 $('.posinvoiceline').click(function(){
1011 console.log("Click done on "+this.id);
1012 $('.posinvoiceline').removeClass("selected");
1013 $(this).addClass("selected");
1014 if (selectedline==this.id) return; // If is already selected
1015 else selectedline=this.id;
1016 selectedtext=$('#'+selectedline).find("td:first").html();
1017 <?php
1018 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1019 print '$("#phonediv1").load("auto_order.php?action=editline&token='.newToken().'&placeid="+placeid+"&selectedline="+selectedline, function() {
1020 });';
1021 }
1022 ?>
1023 });
1024
1025 /* Autoselect the line */
1026 if (idoflineadded > 0)
1027 {
1028 console.log("Auto select "+idoflineadded);
1029 $('.posinvoiceline#'+idoflineadded).click();
1030 }
1031<?php
1032
1033if ($action == "order" && !empty($order_receipt_printer1)) {
1034 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1035 ?>
1036 $.ajax({
1037 type: "POST",
1038 url: '<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php',
1039 data: 'invoice='+orderprinter1esc
1040 });
1041 <?php
1042 } else {
1043 ?>
1044 $.ajax({
1045 type: "POST",
1046 url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
1047 data: '<?php
1048 print $headerorder.$order_receipt_printer1.$footerorder; ?>'
1049 });
1050 <?php
1051 }
1052}
1053
1054if ($action == "order" && !empty($order_receipt_printer2)) {
1055 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1056 ?>
1057 $.ajax({
1058 type: "POST",
1059 url: '<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=2',
1060 data: 'invoice='+orderprinter2esc
1061 });
1062 <?php
1063 } else {
1064 ?>
1065 $.ajax({
1066 type: "POST",
1067 url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print2',
1068 data: '<?php
1069 print $headerorder.$order_receipt_printer2.$footerorder; ?>'
1070 });
1071 <?php
1072 }
1073}
1074
1075if ($action == "order" && !empty($order_receipt_printer3)) {
1076 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1077 ?>
1078 $.ajax({
1079 type: "POST",
1080 url: '<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=3',
1081 data: 'invoice='+orderprinter3esc
1082 });
1083 <?php
1084 }
1085}
1086
1087// Set focus to search field
1088if ($action == "search" || $action == "valid") {
1089 ?>
1090 parent.setFocusOnSearchField();
1091 <?php
1092}
1093
1094
1095if ($action == "temp" && !empty($ticket_printer1)) {
1096 ?>
1097 $.ajax({
1098 type: "POST",
1099 url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
1100 data: '<?php
1101 print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>'
1102 });
1103 <?php
1104}
1105
1106if ($action == "search") {
1107 ?>
1108 $('#search').focus();
1109 <?php
1110}
1111
1112?>
1113
1114});
1115
1116function SendTicket(id)
1117{
1118 console.log("Open box to select the Print/Send form");
1119 $.colorbox({href:"send.php?facid="+id, width:"70%", height:"30%", transition:"none", iframe:"true", title:'<?php echo dol_escape_js($langs->trans("SendTicket")); ?>'});
1120 return true;
1121}
1122
1123function PrintBox(id, action) {
1124 console.log("Open box before printing");
1125 $.colorbox({href:"printbox.php?facid="+id+"&action="+action+"&token=<?php echo newToken(); ?>", width:"80%", height:"200px", transition:"none", iframe:"true", title:"<?php echo $langs->trans("PrintWithoutDetails"); ?>"});
1126 return true;
1127}
1128
1129function Print(id, gift){
1130 console.log("Call Print() to generate the receipt.");
1131 $.colorbox({href:"receipt.php?facid="+id+"&gift="+gift, width:"40%", height:"90%", transition:"none", iframe:"true", title:'<?php echo dol_escape_js($langs->trans("PrintTicket")); ?>'});
1132 return true;
1133}
1134
1135function TakeposPrinting(id){
1136 var receipt;
1137 console.log("TakeposPrinting" + id);
1138 $.get("receipt.php?facid="+id, function(data, status) {
1139 receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '');
1140 $.ajax({
1141 type: "POST",
1142 url: 'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print',
1143 data: receipt
1144 });
1145 });
1146 return true;
1147}
1148
1149function TakeposConnector(id){
1150 console.log("TakeposConnector" + id);
1151 $.get("<?php echo DOL_URL_ROOT; ?>/takepos/ajax/ajax.php?action=printinvoiceticket&token=<?php echo newToken(); ?>&term=<?php echo urlencode(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : ''); ?>&id="+id+"&token=<?php echo currentToken(); ?>", function(data, status) {
1152 $.ajax({
1153 type: "POST",
1154 url: '<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>/printer/index.php',
1155 data: 'invoice='+data
1156 });
1157 });
1158 return true;
1159}
1160
1161function DolibarrTakeposPrinting(id) {
1162 console.log("DolibarrTakeposPrinting Printing invoice ticket " + id)
1163 $.ajax({
1164 type: "GET",
1165 data: { token: '<?php echo currentToken(); ?>' },
1166 url: "<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=printinvoiceticket&token='.newToken().'&term='.urlencode(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '').'&id='; ?>" + id,
1167 });
1168 return true;
1169}
1170
1171function CreditNote() {
1172 $("#poslines").load("invoice.php?action=creditnote&token=<?php echo newToken() ?>&invoiceid="+placeid, function() { });
1173 return true;
1174}
1175
1176function SetNote() {
1177 $("#poslines").load("invoice.php?action=addnote&token=<?php echo newToken() ?>&invoiceid="+placeid+"&idline="+selectedline, { "addnote": $("#textinput").val() });
1178 return true;
1179}
1180
1181
1182$( document ).ready(function() {
1183 console.log("Set customer info and sales in header placeid=<?php echo $placeid; ?> status=<?php echo $invoice->statut; ?>");
1184
1185 <?php
1186 $s = $langs->trans("Customer");
1187 if ($invoice->id > 0 && ($invoice->socid != getDolGlobalString($constforcompanyid))) {
1188 $s = $soc->name;
1189 }
1190 ?>
1191
1192 $("#customerandsales").html('');
1193 $("#shoppingcart").html('');
1194
1195 $("#customerandsales").append('<a class="valignmiddle tdoverflowmax125 minwidth100" id="customer" onclick="Customer();" title="<?php print dol_escape_js(dol_escape_htmltag($s)); ?>"><span class="fas fa-building paddingrightonly"></span><?php print dol_escape_js($s); ?></a>');
1196
1197 <?php
1198 $sql = "SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX."facture";
1199 $sql .= " WHERE entity IN (".getEntity('invoice').")";
1200 if (empty($conf->global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) {
1201 // By default, only invoices with a ref not already defined can in list of open invoice we can edit.
1202 $sql .= " AND ref LIKE '(PROV-POS".$db->escape(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '')."-0%'";
1203 } else {
1204 // If TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED set, we show also draft invoice that already has a reference defined
1205 $sql .= " AND pos_source = '".$db->escape($_SESSION["takeposterminal"])."'";
1206 $sql .= " AND module_source = 'takepos'";
1207 }
1208
1209 $sql .= $db->order('datec', 'ASC');
1210 $resql = $db->query($sql);
1211 if ($resql) {
1212 $max_sale = 0;
1213 while ($obj = $db->fetch_object($resql)) {
1214 echo '$("#shoppingcart").append(\'';
1215 echo '<a class="valignmiddle" title="'.dol_escape_js($langs->trans("SaleStartedAt", dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser')).' - '.$obj->ref).'" onclick="place=\\\'';
1216 $num_sale = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref));
1217 echo $num_sale;
1218 if (str_replace("-", "", $num_sale) > $max_sale) {
1219 $max_sale = str_replace("-", "", $num_sale);
1220 }
1221 echo '\\\'; invoiceid=\\\'';
1222 echo $obj->rowid;
1223 echo '\\\'; Refresh();">';
1224 if ($placeid == $obj->rowid) {
1225 echo '<span class="basketselected">';
1226 } else {
1227 echo '<span class="basketnotselected">';
1228 }
1229 echo '<span class="fa fa-shopping-cart paddingright"></span>'.dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser');
1230 echo '</span>';
1231 echo '</a>\');';
1232 }
1233 echo '$("#shoppingcart").append(\'<a onclick="place=\\\'0-';
1234 echo $max_sale + 1;
1235 echo '\\\'; invoiceid=0; Refresh();"><div><span class="fa fa-plus" title="'.dol_escape_htmltag($langs->trans("StartAParallelSale")).'"><span class="fa fa-shopping-cart"></span></div></a>\');';
1236 } else {
1237 dol_print_error($db);
1238 }
1239
1240 $s = '';
1241
1242 $idwarehouse = 0;
1243 $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '');
1244 if (isModEnabled('stock')) {
1245 if (getDolGlobalString("$constantforkey") != "1") {
1246 $constantforkey = 'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '');
1247 $idwarehouse = getDolGlobalString($constantforkey);
1248 if ($idwarehouse > 0) {
1249 $s = '<span class="small">';
1250 $warehouse = new Entrepot($db);
1251 $warehouse->fetch($idwarehouse);
1252 $s .= '<span class="hideonsmartphone">'.$langs->trans("Warehouse").'<br></span>'.$warehouse->ref;
1253 if ($warehouse->statut == Entrepot::STATUS_CLOSED) {
1254 $s .= ' ('.$langs->trans("Closed").')';
1255 }
1256 $s .= '</span>';
1257 print "$('#infowarehouse').html('".dol_escape_js($s)."');";
1258 print '$("#infowarehouse").css("display", "inline-block");';
1259 } else {
1260 $s = '<span class="small hideonsmartphone">';
1261 $s .= $langs->trans("StockChangeDisabled").'<br>'.$langs->trans("NoWarehouseDefinedForTerminal");
1262 $s .= '</span>';
1263 print "$('#infowarehouse').html('".dol_escape_js($s)."');";
1264 if (!empty($conf->dol_optimize_smallscreen)) {
1265 print '$("#infowarehouse").css("display", "none");';
1266 }
1267 }
1268 } else {
1269 $s = '<span class="small hideonsmartphone">'.$langs->trans("StockChangeDisabled").'</span>';
1270 print "$('#infowarehouse').html('".dol_escape_js($s)."');";
1271 if (!empty($conf->dol_optimize_smallscreen)) {
1272 print '$("#infowarehouse").css("display", "none");';
1273 }
1274 }
1275 }
1276
1277
1278 // Module Adherent
1279 $s = '';
1280 if (isModEnabled('adherent') && $invoice->socid > 0 && $invoice->socid != $conf->global->$constforcompanyid) {
1281 $s = '<span class="small">';
1282 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
1283 $langs->load("members");
1284 $s .= $langs->trans("Member").': ';
1285 $adh = new Adherent($db);
1286 $result = $adh->fetch('', '', $invoice->socid);
1287 if ($result > 0) {
1288 $adh->ref = $adh->getFullName($langs);
1289 if (empty($adh->statut) || $adh->statut == Adherent::STATUS_EXCLUDED ) {
1290 $s .= "<s>";
1291 }
1292 $s .= $adh->getFullName($langs);
1293 $s .= ' - '.$adh->type;
1294 if ($adh->datefin) {
1295 $s .= '<br>'.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day');
1296 if ($adh->hasDelay()) {
1297 $s .= " ".img_warning($langs->trans("Late"));
1298 }
1299 } else {
1300 $s .= '<br>'.$langs->trans("SubscriptionNotReceived");
1301 if ($adh->statut > 0) {
1302 $s .= " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
1303 }
1304 }
1305 if (empty($adh->statut) || $adh->statut == Adherent::STATUS_EXCLUDED) {
1306 $s .= "</s>";
1307 }
1308 } else {
1309 $s .= '<br>'.$langs->trans("ThirdpartyNotLinkedToMember");
1310 }
1311 $s .= '</span>';
1312 }
1313 ?>
1314 $("#moreinfo").html('<?php print dol_escape_js($s); ?>');
1315
1316});
1317
1318
1319<?php
1320if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
1321 echo "function CustomerDisplay(){";
1322 echo "var line1='".$CUSTOMER_DISPLAY_line1."'.substring(0,20);";
1323 echo "line1=line1.padEnd(20);";
1324 echo "var line2='".$CUSTOMER_DISPLAY_line2."'.substring(0,20);";
1325 echo "line2=line2.padEnd(20);";
1326 echo "$.ajax({
1327 type: 'GET',
1328 data: { text: line1+line2 },
1329 url: '".getDolGlobalString('TAKEPOS_PRINT_SERVER')."/display/index.php',
1330 });";
1331 echo "}";
1332}
1333?>
1334
1335</script>
1336
1337<?php
1338// Add again js for footer because this content is injected into index.php page so all init
1339// for tooltip and other js beautifiers must be reexecuted too.
1340if (!empty($conf->use_javascript_ajax)) {
1341 print "\n".'<!-- Includes JS Footer of Dolibarr -->'."\n";
1342 print '<script src="'.DOL_URL_ROOT.'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.'"></script>'."\n";
1343}
1344
1345print '<!-- invoice.php place='.(int) $place.' invoice='.$invoice->ref.' mobilepage='.(empty($mobilepage) ? '' : $mobilepage).' $_SESSION["basiclayout"]='.(empty($_SESSION["basiclayout"])?'':$_SESSION["basiclayout"]).' conf->global->TAKEPOS_BAR_RESTAURANT='.getDolGlobalString('TAKEPOS_BAR_RESTAURANT').' -->'."\n";
1346print '<div class="div-table-responsive-no-min invoice">';
1347print '<table id="tablelines" class="noborder noshadow postablelines centpercent">';
1348if ($sectionwithinvoicelink && ($mobilepage == "invoice" || $mobilepage == "")) {
1349 if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
1350 print '<tr><td colspan="5">'.$sectionwithinvoicelink.'</td></tr>';
1351 } else {
1352 print '<tr><td colspan="4">'.$sectionwithinvoicelink.'</td></tr>';
1353 }
1354}
1355print '<tr class="liste_titre nodrag nodrop">';
1356print '<td class="linecoldescription">';
1357// In phone version only show when it is invoice page
1358if (empty($mobilepage) || $mobilepage == "invoice") {
1359 print '<!-- hidden var used by some js functions -->';
1360 print '<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.'">';
1361 print '<input type="hidden" name="thirdpartyid" id="thirdpartyid" value="'.$invoice->socid.'">';
1362}
1363if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1364 $sql = "SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place);
1365 $resql = $db->query($sql);
1366 $obj = $db->fetch_object($resql);
1367 if ($obj) {
1368 $label = $obj->label;
1369 $floor = $obj->floor;
1370 }
1371 if ($mobilepage == "invoice" || $mobilepage == "") {
1372 // If not on smartphone version or if it is the invoice page
1373 //print 'mobilepage='.$mobilepage;
1374 print '<span class="opacitymedium">'.$langs->trans('Place')."</span> <b>".(empty($label) ? '?' : $label)."</b><br>";
1375 print '<span class="opacitymedium">'.$langs->trans('Floor')."</span> <b>".(empty($floor) ? '?' : $floor)."</b>";
1376 } elseif (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1377 print $mysoc->name;
1378 } elseif ($mobilepage == "cats") {
1379 print $langs->trans('Category');
1380 } elseif ($mobilepage == "products") {
1381 print $langs->trans('Label');
1382 }
1383} else {
1384 print $langs->trans("Products");
1385}
1386print '</td>';
1387
1388// complete header by hook
1389$parameters=array();
1390$reshook=$hookmanager->executeHooks('completeTakePosInvoiceHeader', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
1391if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1392print $hookmanager->resPrint;
1393
1394if (empty($_SESSION["basiclayout"]) || $_SESSION["basiclayout"] != 1) {
1395 print '<td class="linecolqty right">'.$langs->trans('ReductionShort').'</td>';
1396 print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
1397 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
1398 print '<td class="linecolht right nowraponall">';
1399 print '<span class="opacitymedium small">' . $langs->trans('TotalHTShort') . '</span><br>';
1400 // In phone version only show when it is invoice page
1401 if (empty($mobilepage) || $mobilepage == "invoice") {
1402 print '<span id="linecolht-span-total" style="font-size:1.3em; font-weight: bold;">' . price($invoice->total_ht, 1, '', 1, -1, -1, $conf->currency) . '</span>';
1403 if (isModEnabled('multicurrency') && $_SESSION["takeposcustomercurrency"] != "" && $conf->currency != $_SESSION["takeposcustomercurrency"]) {
1404 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
1405 include_once DOL_DOCUMENT_ROOT . '/multicurrency/class/multicurrency.class.php';
1406 $multicurrency = new MultiCurrency($db);
1407 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]);
1408 print '<br><span id="linecolht-span-total" style="font-size:0.9em; font-style:italic;">(' . price($invoice->total_ht * $multicurrency->rate->rate) . ' ' . $_SESSION["takeposcustomercurrency"] . ')</span>';
1409 }
1410 print '</td>';
1411 }
1412 print '</td>';
1413 }
1414 print '<td class="linecolht right nowraponall">';
1415 print '<span class="opacitymedium small">'.$langs->trans('TotalTTCShort').'</span><br>';
1416 // In phone version only show when it is invoice page
1417 if (empty($mobilepage) || $mobilepage == "invoice") {
1418 print '<span id="linecolht-span-total" style="font-size:1.3em; font-weight: bold;">'.price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency).'</span>';
1419 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency"]) && $conf->currency != $_SESSION["takeposcustomercurrency"]) {
1420 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
1421 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
1422 $multicurrency = new MultiCurrency($db);
1423 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]);
1424 print '<br><span id="linecolht-span-total" style="font-size:0.9em; font-style:italic;">('.price($invoice->total_ttc * $multicurrency->rate->rate).' '.$_SESSION["takeposcustomercurrency"].')</span>';
1425 }
1426 print '</td>';
1427 }
1428 print '</td>';
1429} elseif ($mobilepage == "invoice") {
1430 print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
1431}
1432print "</tr>\n";
1433
1434
1435if (!empty($_SESSION["basiclayout"]) && $_SESSION["basiclayout"] == 1) {
1436 if ($mobilepage == "cats") {
1437 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1438 $categorie = new Categorie($db);
1439 $categories = $categorie->get_full_arbo('product');
1440 $htmlforlines = '';
1441 foreach ($categories as $row) {
1442 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1443 $htmlforlines .= '<div class="leftcat';
1444 } else {
1445 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
1446 }
1447 $htmlforlines .= '" onclick="LoadProducts('.$row['id'].');">';
1448 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1449 $htmlforlines .= '<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.'/takepos/public/auto_order.php?genimg=cat&query=cat&id='.$row['id'].'"><br>';
1450 } else {
1451 $htmlforlines .= '<td class="left">';
1452 }
1453 $htmlforlines .= $row['label'];
1454 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1455 $htmlforlines .= '</div>'."\n";
1456 } else {
1457 $htmlforlines .= '</td></tr>'."\n";
1458 }
1459 }
1460 $htmlforlines .= '</table>';
1461 $htmlforlines .= '</table>';
1462 print $htmlforlines;
1463 }
1464
1465 if ($mobilepage == "products") {
1466 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1467 $object = new Categorie($db);
1468 $catid = GETPOST('catid', 'int');
1469 $result = $object->fetch($catid);
1470 $prods = $object->getObjectsInCateg("product");
1471 $htmlforlines = '';
1472 foreach ($prods as $row) {
1473 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1474 $htmlforlines .= '<div class="leftcat';
1475 } else {
1476 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
1477 }
1478 $htmlforlines .= '" onclick="AddProduct(\''.$place.'\', '.$row->id.')">';
1479 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1480 $htmlforlines .= '<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.'/takepos/public/auto_order.php?genimg=pro&query=pro&id='.$row->id.'"><br>';
1481 $htmlforlines .= $row->label.' '.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency);
1482 $htmlforlines .= '</div>'."\n";
1483 } else {
1484 $htmlforlines .= '<td class="left">';
1485 $htmlforlines .= $row->label;
1486 $htmlforlines .= '<div class="right">'.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).'</div>';
1487 $htmlforlines .= '</tr>'."\n";
1488 }
1489 }
1490 $htmlforlines .= '</table>';
1491 print $htmlforlines;
1492 }
1493
1494 if ($mobilepage == "places") {
1495 $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables";
1496 $resql = $db->query($sql);
1497 $rows = array();
1498 $htmlforlines = '';
1499 while ($row = $db->fetch_array($resql)) {
1500 $rows[] = $row;
1501 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
1502 $htmlforlines .= '" onclick="LoadPlace(\''.$row['label'].'\')">';
1503 $htmlforlines .= '<td class="left">';
1504 $htmlforlines .= $row['label'];
1505 $htmlforlines .= '</td>';
1506 $htmlforlines .= '</tr>'."\n";
1507 }
1508 $htmlforlines .= '</table>';
1509 print $htmlforlines;
1510 }
1511}
1512
1513if ($placeid > 0) {
1514 //In Phone basic layout hide some content depends situation
1515 if (!empty($_SESSION["basiclayout"]) && $_SESSION["basiclayout"] == 1 && $mobilepage != "invoice" && $action != "order") {
1516 return;
1517 }
1518
1519 if (is_array($invoice->lines) && count($invoice->lines)) {
1520 print '<!-- invoice.php show lines of invoices -->'."\n";
1521 $tmplines = array_reverse($invoice->lines);
1522 $htmlsupplements = array();
1523 foreach ($tmplines as $line) {
1524 if ($line->fk_parent_line != false) {
1525 $htmlsupplements[$line->fk_parent_line] .= '<tr class="drag drop oddeven posinvoiceline';
1526 if ($line->special_code == "4") {
1527 $htmlsupplements[$line->fk_parent_line] .= ' order';
1528 }
1529 $htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'"';
1530 if ($line->special_code == "4") {
1531 $htmlsupplements[$line->fk_parent_line] .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
1532 }
1533 $htmlsupplements[$line->fk_parent_line] .= '>';
1534 $htmlsupplements[$line->fk_parent_line] .= '<td class="left">';
1535 $htmlsupplements[$line->fk_parent_line] .= img_picto('', 'rightarrow');
1536 if ($line->product_label) {
1537 $htmlsupplements[$line->fk_parent_line] .= $line->product_label;
1538 }
1539 if ($line->product_label && $line->desc) {
1540 $htmlsupplements[$line->fk_parent_line] .= '<br>';
1541 }
1542 if ($line->product_label != $line->desc) {
1543 $firstline = dolGetFirstLineOfText($line->desc);
1544 if ($firstline != $line->desc) {
1545 $htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
1546 } else {
1547 $htmlsupplements[$line->fk_parent_line] .= $line->desc;
1548 }
1549 }
1550 $htmlsupplements[$line->fk_parent_line] .= '</td>';
1551
1552 // complete line by hook
1553 $parameters=array('line' => $line);
1554 $reshook=$hookmanager->executeHooks('completeTakePosInvoiceParentLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
1555 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1556 $htmlsupplements[$line->fk_parent_line] .= $hookmanager->resPrint;
1557
1558 if (empty($_SESSION["basiclayout"]) || $_SESSION["basiclayout"] != 1) {
1559 $htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.vatrate($line->remise_percent, true).'</td>';
1560 $htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.$line->qty.'</td>';
1561 $htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.price($line->total_ttc).'</td>';
1562 }
1563 $htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n";
1564 continue;
1565 }
1566 $htmlforlines = '';
1567
1568 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
1569 if ($line->special_code == "4") {
1570 $htmlforlines .= ' order';
1571 }
1572 $htmlforlines .= '" id="'.$line->id.'"';
1573 if ($line->special_code == "4") {
1574 $htmlforlines .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
1575 }
1576 $htmlforlines .= '>';
1577 $htmlforlines .= '<td class="left">';
1578 if (!empty($_SESSION["basiclayout"]) && $_SESSION["basiclayout"] == 1) {
1579 $htmlforlines .= '<span class="phoneqty">'.$line->qty."</span> x ";
1580 }
1581 if (isset($line->product_type)) {
1582 if (empty($line->product_type)) {
1583 $htmlforlines .= img_object('', 'product').' ';
1584 } else {
1585 $htmlforlines .= img_object('', 'service').' ';
1586 }
1587 }
1588 if (empty($conf->global->TAKEPOS_SHOW_N_FIRST_LINES)) {
1589 $tooltiptext = '';
1590 if ($line->product_ref) {
1591 $tooltiptext .= '<b>'.$langs->trans("Ref").'</b> : '.$line->product_ref.'<br>';
1592 $tooltiptext .= '<b>'.$langs->trans("Label").'</b> : '.$line->product_label.'<br>';
1593 if ($line->product_label != $line->desc) {
1594 if ($line->desc) {
1595 $tooltiptext .= '<br>';
1596 }
1597 $tooltiptext .= $line->desc;
1598 }
1599 }
1600 if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
1601 $htmlforlines .= $form->textwithpicto($line->product_label ? '<b>' . $line->product_ref . '</b> - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
1602 } else {
1603 $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
1604 }
1605 } else {
1606 if ($line->product_label) {
1607 $htmlforlines .= $line->product_label;
1608 }
1609 if ($line->product_label != $line->desc) {
1610 if ($line->product_label && $line->desc) {
1611 $htmlforlines .= '<br>';
1612 }
1613 $firstline = dolGetFirstLineOfText($line->desc, $conf->global->TAKEPOS_SHOW_N_FIRST_LINES);
1614 if ($firstline != $line->desc) {
1615 $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
1616 } else {
1617 $htmlforlines .= $line->desc;
1618 }
1619 }
1620 }
1621 if (!empty($line->array_options['options_order_notes'])) {
1622 $htmlforlines .= "<br>(".$line->array_options['options_order_notes'].")";
1623 }
1624 if (!empty($_SESSION["basiclayout"]) && $_SESSION["basiclayout"] == 1) {
1625 $htmlforlines .= '</td><td class="right phonetable"><button type="button" onclick="SetQty(place, '.$line->rowid.', '.($line->qty - 1).');" class="publicphonebutton2 phonered">-</button>&nbsp;&nbsp;<button type="button" onclick="SetQty(place, '.$line->rowid.', '.($line->qty + 1).');" class="publicphonebutton2 phonegreen">+</button>';
1626 }
1627 if (empty($_SESSION["basiclayout"]) || $_SESSION["basiclayout"] != 1) {
1628 $moreinfo = '';
1629 $moreinfo .= $langs->transcountry("TotalHT", $mysoc->country_code).': '.price($line->total_ht);
1630 if ($line->vat_src_code) {
1631 $moreinfo .= '<br>'.$langs->trans("VATCode").': '.$line->vat_src_code;
1632 }
1633 $moreinfo .= '<br>'.$langs->transcountry("TotalVAT", $mysoc->country_code).': '.price($line->total_tva);
1634 $moreinfo .= '<br>'.$langs->transcountry("TotalLT1", $mysoc->country_code).': '.price($line->total_localtax1);
1635 $moreinfo .= '<br>'.$langs->transcountry("TotalLT2", $mysoc->country_code).': '.price($line->total_localtax2);
1636 $moreinfo .= '<hr>';
1637 $moreinfo .= $langs->transcountry("TotalTTC", $mysoc->country_code).': '.price($line->total_ttc);
1638 //$moreinfo .= $langs->trans("TotalHT").': '.$line->total_ht;
1639 if ($line->date_start || $line->date_end) {
1640 $htmlforlines .= '<br><div class="clearboth nowraponall">'.get_date_range($line->date_start, $line->date_end).'</div>';
1641 }
1642 $htmlforlines .= '</td>';
1643
1644 // complete line by hook
1645 $parameters=array('line' => $line);
1646 $reshook=$hookmanager->executeHooks('completeTakePosInvoiceLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
1647 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1648 $htmlforlines .= $hookmanager->resPrint;
1649
1650 $htmlforlines .= '<td class="right">'.vatrate($line->remise_percent, true).'</td>';
1651 $htmlforlines .= '<td class="right">';
1652 if (isModEnabled('stock') && !empty($user->rights->stock->mouvement->lire)) {
1653 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
1654 if (!empty($conf->global->$constantforkey) && $line->fk_product > 0 && empty($conf->global->TAKEPOS_HIDE_STOCK_ON_LINE)) {
1655 $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp";
1656 $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
1657 $sql .= " ".MAIN_DB_PREFIX."product_stock as ps";
1658 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product";
1659 $sql .= " WHERE ps.reel != 0";
1660 $sql .= " AND ps.fk_entrepot = ".((int) $conf->global->$constantforkey);
1661 $sql .= " AND e.entity IN (".getEntity('stock').")";
1662 $sql .= " AND ps.fk_product = ".((int) $line->fk_product);
1663 $resql = $db->query($sql);
1664 if ($resql) {
1665 $obj = $db->fetch_object($resql);
1666 $stock_real = price2num($obj->reel, 'MS');
1667 $htmlforlines .= $line->qty;
1668 if ($line->qty && $line->qty > $stock_real) {
1669 $htmlforlines .= '<span style="color: var(--amountremaintopaycolor)">';
1670 }
1671 $htmlforlines .= ' <span class="posstocktoolow">('.$langs->trans("Stock").' '.$stock_real.')</span>';
1672 if ($line->qty && $line->qty > $stock_real) {
1673 $htmlforlines .= "</span>";
1674 }
1675 } else {
1676 dol_print_error($db);
1677 }
1678 } else {
1679 $htmlforlines .= $line->qty;
1680 }
1681 } else {
1682 $htmlforlines .= $line->qty;
1683 }
1684
1685 $htmlforlines .= '</td>';
1686 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
1687 $htmlforlines .= '<td class="right classfortooltip" title="'.$moreinfo.'">';
1688 $htmlforlines .= price($line->total_ht, 1, '', 1, -1, -1, $conf->currency);
1689 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency"]) && $conf->currency != $_SESSION["takeposcustomercurrency"]) {
1690 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
1691 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
1692 $multicurrency = new MultiCurrency($db);
1693 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]);
1694 $htmlforlines .= '<br><span id="linecolht-span-total" style="font-size:0.9em; font-style:italic;">('.price($line->total_ht * $multicurrency->rate->rate).' '.$_SESSION["takeposcustomercurrency"].')</span>';
1695 }
1696 $htmlforlines .= '</td>';
1697 }
1698 $htmlforlines .= '<td class="right classfortooltip" title="'.$moreinfo.'">';
1699 $htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency);
1700 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency"]) && $conf->currency != $_SESSION["takeposcustomercurrency"]) {
1701 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
1702 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
1703 $multicurrency = new MultiCurrency($db);
1704 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]);
1705 $htmlforlines .= '<br><span id="linecolht-span-total" style="font-size:0.9em; font-style:italic;">('.price($line->total_ttc * $multicurrency->rate->rate).' '.$_SESSION["takeposcustomercurrency"].')</span>';
1706 }
1707 $htmlforlines .= '</td>';
1708 }
1709 $htmlforlines .= '</tr>'."\n";
1710 $htmlforlines .= empty($htmlsupplements[$line->id]) ? '' : $htmlsupplements[$line->id];
1711
1712 print $htmlforlines;
1713 }
1714 } else {
1715 print '<tr class="drag drop oddeven"><td class="left"><span class="opacitymedium">'.$langs->trans("Empty").'</span></td><td></td><td></td><td></td>';
1716 if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
1717 print '<td></td>';
1718 }
1719 print '</tr>';
1720 }
1721} else { // No invoice generated yet
1722 print '<tr class="drag drop oddeven"><td class="left"><span class="opacitymedium">'.$langs->trans("Empty").'</span></td><td></td><td></td><td></td>';
1723
1724 if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
1725 print '<td></td>';
1726 }
1727 print '</tr>';
1728}
1729
1730print '</table>';
1731
1732if (($action == "valid" || $action == "history") && $invoice->type != Facture::TYPE_CREDIT_NOTE && empty($conf->global->TAKEPOS_NO_CREDITNOTE)) {
1733 print '<button id="buttonprint" type="button" onclick="ModalBox(\'ModalCreditNote\')">'.$langs->trans('CreateCreditNote').'</button>';
1734 if (getDolGlobalInt('TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
1735 print ' <a target="_blank" class="button" href="' . DOL_URL_ROOT . '/document.php?token=' . newToken() . '&modulepart=facture&file=' . $invoice->ref . '/' . $invoice->ref . '.pdf">Invoice</a>';
1736 }
1737}
1738
1739
1740if ($action == "search") {
1741 print '<center>
1742 <input type="text" id="search" class="input-search-takepos" name="search" onkeyup="Search2(\'\', null);" style="width: 80%; font-size: 150%;" placeholder="'.dol_escape_htmltag($langs->trans('Search')).'">
1743 </center>';
1744}
1745
1746print '</div>';
1747
1748// llxFooter
1749if ((getDolGlobalString('TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->layout == 'phone') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1750 print '</body></html>';
1751}
Class to manage members of a foundation.
const STATUS_EXCLUDED
Excluded.
Class to manage categories.
Class to manage warehouses.
const STATUS_CLOSED
Warehouse closed, inactive.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage generation of HTML components Only common components must be here.
Class Currency.
Class to manage payments of customer invoices.
Class to manage predefined suppliers products.
Class to manage products or services.
const BATCH_RULE_SELLBY_EATBY_DATES_FIRST
Batches rules.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Receipt Printers.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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) VAT...
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formated error messages to output (Used to show messages on html output).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall right right takeposterminal SELECT e rowid
Definition invoice.php:1655
if(empty( $user->rights->takepos->run) &&!defined( 'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) if((getDolGlobalString('TAKEPOS_PHONE_BASIC_LAYOUT')==1 && $conf->browser->layout=='phone')||defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) if(empty( $_SESSION["takeposterminal"])) fail($message)
Abort invoice creationg with a given error message.
Definition invoice.php:105
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
ui dialog ui datepicker calendar ui widget content ui state ui datepicker calendar ui widget header ui state ui datepicker calendar ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:120
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.