33if (!defined(
'NOTOKENRENEWAL')) {
34 define(
'NOTOKENRENEWAL',
'1');
36if (!defined(
'NOREQUIREMENU')) {
37 define(
'NOREQUIREMENU',
'1');
39if (!defined(
'NOREQUIREHTML')) {
40 define(
'NOREQUIREHTML',
'1');
42if (!defined(
'NOREQUIREAJAX')) {
43 define(
'NOREQUIREAJAX',
'1');
47if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
48 require
'../main.inc.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
64$hookmanager->initHooks(array(
'takeposinvoice'));
66$langs->loadLangs(array(
"companies",
"commercial",
"bills",
"cashdesk",
"stocks",
"banks"));
68$action =
GETPOST(
'action',
'aZ09');
72$mobilepage =
GETPOST(
'mobilepage',
'alpha');
77if (!$user->hasRight(
'takepos',
'run') && !defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
81if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
83 if ($_SESSION[
"takeposterminal"] ==
"") {
85 $_SESSION[
"takeposterminal"] = 1;
87 header(
"Location: ".DOL_URL_ROOT.
"/takepos/index.php");
94$takeposterminal = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'';
97if (empty($takeposterminal)) {
99 $_SESSION[
"takeposterminal"] = 1;
100 $takeposterminal = 1;
101 } elseif (!empty($_COOKIE[
"takeposterminal"])) {
102 $_SESSION[
"takeposterminal"] = preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $_COOKIE[
"takeposterminal"]);
103 $takeposterminal = $_SESSION[
"takeposterminal"];
106<script language=
"javascript">
107 $( document ).ready(
function() {
108 ModalBox(
'ModalTerminal');
125 header($_SERVER[
'SERVER_PROTOCOL'].
' 500 Internal Server Error',
true, 500);
136function takeposDeleteLineWithChildren($invoice, $lineid)
138 $lineid = (int) $lineid;
143 $childrenbyparent = array();
144 if (is_array($invoice->lines)) {
145 foreach ($invoice->lines as $line) {
146 $parentid = (int) $line->fk_parent_line;
148 $childrenbyparent[$parentid][] = (int) $line->id;
153 $linestodelete = array();
154 $stack = array($lineid);
155 while (!empty($stack)) {
156 $currentlineid = array_pop($stack);
157 if (in_array($currentlineid, $linestodelete,
true)) {
161 $linestodelete[] = $currentlineid;
162 if (!empty($childrenbyparent[$currentlineid])) {
163 foreach ($childrenbyparent[$currentlineid] as $childlineid) {
164 $stack[] = $childlineid;
170 foreach (array_reverse($linestodelete) as $deletelineid) {
171 $result = $invoice->deleteLine($deletelineid);
182$number = (float)
GETPOST(
'number',
'alpha');
185$desc =
GETPOST(
'desc',
'alphanohtml');
198if ($pay ==
'cheque') {
205 $sql =
"SELECT id, code FROM ".MAIN_DB_PREFIX.
"c_paiement";
206 $sql .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
207 $sql .=
" AND code = '".$db->escape($paycode).
"'";
208 $resql =
$db->query($sql);
210 $obj =
$db->fetch_object($resql);
212 $paiementid = $obj->id;
219 $ret = $invoice->fetch($invoiceid);
221 $ret = $invoice->fetch(0,
'(PROV-POS'.$takeposterminal.
'-'.$place.
')');
224 $placeid = $invoice->id;
227$constforcompanyid =
'CASHDESK_ID_THIRDPARTY'.$takeposterminal;
230if ($invoice->socid > 0) {
231 $soc->fetch($invoice->socid);
238 $invoice->fk_project =
getDolGlobalInt(
"CASHDESK_ID_PROJECT".$takeposterminal);
242if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"])) {
243 if ($invoice->multicurrency_code != $_SESSION[
"takeposcustomercurrency"]) {
244 $invoice->setMulticurrencyCode($_SESSION[
"takeposcustomercurrency"]);
248$term = empty($_SESSION[
"takeposterminal"]) ? 1 : $_SESSION[
"takeposterminal"];
255$parameters = array();
256$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $invoice, $action);
262$sectionwithinvoicelink =
'';
263$CUSTOMER_DISPLAY_line1 =
'';
264$CUSTOMER_DISPLAY_line2 =
'';
273if (in_array($action, array(
'deleteline',
'updateqty',
'updateprice',
'updatereduction',
'update_reduction_global')) && !$user->hasRight(
'takepos',
'editlines')) {
279if (empty($reshook)) {
283 $sql =
"SELECT MIN(ref) as firstref FROM ".MAIN_DB_PREFIX.
"pos_cash_fence";
284 $sql .=
" WHERE posnumber = ".((int) $takeposterminal);
285 $sql .=
" AND year_close = ".((int) $tmpcurrentday[
'year']);
287 $sql .=
" (month_close IS NULL AND day_close IS NULL)";
288 $sql .=
" OR (month_close = ".((int) $tmpcurrentday[
'mon']).
" AND day_close IS NULL)";
289 $sql .=
" OR (month_close = ".((int) $tmpcurrentday[
'mon']).
" AND day_close = ".((int) $tmpcurrentday[
'mday']).
")";
291 $sql .=
" AND status = 1";
294 $resql =
$db->query($sql);
296 $obj =
$db->fetch_object($resql);
298 $refcashcontrol = $obj->firstref;
302 if ($refcashcontrol) {
304 $langs->load(
'errors');
305 dol_htmloutput_errors($langs->trans(
"ACashControlHasBeenclosedForCurrentDay", $refcashcontrol), [], 1);
310 if ($action ==
'valid' && $user->hasRight(
'facture',
'creer')) {
318 $bankaccount =
getDolGlobalInt(
'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION[
"takeposterminal"]);
319 } elseif ($pay ==
"CHQ") {
320 $bankaccount =
getDolGlobalInt(
'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION[
"takeposterminal"]);
322 $accountname =
"CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION[
"takeposterminal"];
327 if ($bankaccount <= 0 && $pay !=
"delayed" &&
isModEnabled(
"bank")) {
328 $errormsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount"));
336 $invoice->fetch($placeid);
338 $invoice->oldcopy =
dol_clone($invoice, 2);
342 if ($invoice->total_ttc < 0) {
343 $invoice->type = $invoice::TYPE_CREDIT_NOTE;
345 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
346 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
347 $sql .=
" AND fk_soc = ".((int) $invoice->socid);
348 $sql .=
" AND type <> ".Facture::TYPE_CREDIT_NOTE;
349 $sql .=
" AND fk_statut >= ".$invoice::STATUS_VALIDATED;
350 $sql .=
" ORDER BY rowid DESC";
353 $resql =
$db->query($sql);
355 $obj =
$db->fetch_object($resql);
356 $fk_source = $obj->rowid;
357 if ((
int) $fk_source == 0) {
358 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
361 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
363 $invoice->fk_facture_source = $fk_source;
364 $invoice->update($user);
367 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
374 $remaintopay = $invoice->getRemainToPay();
381 } elseif (count($invoice->lines) == 0) {
390 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
392 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
393 dol_syslog(
"Validate invoice with stock change. Warehouse defined into constant ".$constantforkey.
" = ".
getDolGlobalString($constantforkey));
398 $res = $invoice->validate($user,
'',
getDolGlobalInt($constantforkey), 0, $batch_rule);
401 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
404 dol_syslog(
"Call validate on invoice ".$invoice->ref, LOG_DEBUG);
405 $res = $invoice->validate($user);
408 $langs->load(
"admin");
409 dol_htmloutput_errors($invoice->error ==
'NotConfigured' ? $langs->trans(
"NotConfigured").
' (TakePos numbering module)' : $invoice->error, $invoice->errors, 1);
414 if (!$error && $res >= 0) {
415 $remaintopay = $invoice->getRemainToPay();
420 $payment->datepaye = $now;
421 $payment->fk_account = $bankaccount;
426 $payment->amounts[$invoice->id] = $amountofpayment;
429 if ($amountofpayment <= 0 || $amountofpayment > $remaintopay) {
430 $payment->amounts[$invoice->id] = $remaintopay;
434 $payment->paiementid = $paiementid;
435 $payment->paiementcode = $paycode;
436 $payment->num_payment =
'';
438 if ($pay !=
"delayed") {
439 $res = $payment->create($user);
446 if (!empty($payment->warnings)) {
450 $res = $payment->addPaymentToBank($user,
'payment',
'(CustomerInvoicePayment)', $bankaccount,
'',
'');
453 dol_htmloutput_mesg($langs->trans(
'ErrorNoPaymentDefined').
' '.$payment->error, $payment->errors,
'error', 1);
456 $remaintopay = $invoice->getRemainToPay();
462 if ($remaintopay == 0) {
463 dol_syslog(
"Invoice is paid, so we set it to status Paid");
464 $result = $invoice->setPaid($user);
467 $invoice->status = $invoice::STATUS_CLOSED;
468 $invoice->close_code =
'';
471 $invoice->setPaymentMethods($paiementid);
473 dol_syslog(
"Invoice is not paid, remain to pay = ".$remaintopay);
482 if (!$error && $res >= 0) {
485 dol_syslog(
"Now we record the stock movement for each qualified line");
488 require_once DOL_DOCUMENT_ROOT .
"/product/stock/class/mouvementstock.class.php";
489 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
492 $labeltakeposmovement =
'TakePOS - '.$langs->trans(
"Invoice").
' '.$invoice->ref;
494 foreach ($invoice->lines as $line) {
496 $warehouseid = ($line->fk_warehouse ? $line->fk_warehouse :
getDolGlobalInt($constantforkey));
499 if ($line->batch !=
'' && $warehouseid > 0) {
501 $prod_batch->find(0,
'',
'', $line->batch, $warehouseid, (
int) $line->fk_product);
504 $mouvP->setOrigin($invoice->element, $invoice->id);
506 $res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'', $prod_batch->batch, $prod_batch->id, $inventorycode);
513 $mouvP->setOrigin($invoice->element, $invoice->id);
515 $res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'',
'', 0, $inventorycode);
525 if (!$error && $res >= 0) {
528 $invoice->ref = $invoice->oldcopy->ref;
529 $invoice->paye = $invoice->oldcopy->paye;
530 $invoice->status = $invoice->oldcopy->status;
531 $invoice->statut = $invoice->oldcopy->statut;
538 if ($action ==
'creditnote' && $user->hasRight(
'facture',
'creer')) {
542 $creditnote->socid = $invoice->socid;
544 $creditnote->module_source =
'takepos';
545 $creditnote->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
547 $creditnote->fk_facture_source = $placeid;
549 $creditnote->create($user);
553 foreach ($invoice->lines as $line) {
555 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
560 if (!empty($invoice->situation_counter)) {
561 $source_fk_prev_id = $line->fk_prev_id;
562 $line->fk_prev_id = $line->id;
563 if (!empty($invoice->tab_previous_situation_invoice)) {
566 $tab_jumped_credit_notes = array();
567 $lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
568 $searchPreviousInvoice =
true;
569 while ($searchPreviousInvoice) {
570 if ($invoice->tab_previous_situation_invoice[$lineIndex]->situation_cycle_ref || $lineIndex < 1) {
571 $searchPreviousInvoice =
false;
575 $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id;
581 $maxPrevSituationPercent = 0;
582 foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
583 if ($prevLine->id == $source_fk_prev_id) {
584 $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
587 $line->total_ht -= $prevLine->total_ht;
588 $line->total_tva -= $prevLine->total_tva;
589 $line->total_ttc -= $prevLine->total_ttc;
590 $line->total_localtax1 -= $prevLine->total_localtax1;
591 $line->total_localtax2 -= $prevLine->total_localtax2;
593 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
594 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
595 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
596 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
601 $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
606 $maxPrevSituationPercent = 0;
607 foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
608 foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) {
609 if ($prevLine->fk_prev_id == $source_fk_prev_id) {
610 $maxPrevSituationPercent = $prevLine->situation_percent;
612 $line->total_ht -= $prevLine->total_ht;
613 $line->total_tva -= $prevLine->total_tva;
614 $line->total_ttc -= $prevLine->total_ttc;
615 $line->total_localtax1 -= $prevLine->total_localtax1;
616 $line->total_localtax2 -= $prevLine->total_localtax2;
618 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
619 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
620 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
621 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
627 $line->situation_percent += $maxPrevSituationPercent;
635 $line->fk_facture = $creditnote->id;
636 $line->fk_parent_line = $fk_parent_line;
638 $line->subprice = -$line->subprice;
640 $line->total_ht = -$line->total_ht;
641 $line->total_tva = -$line->total_tva;
642 $line->total_ttc = -$line->total_ttc;
643 $line->total_localtax1 = -$line->total_localtax1;
644 $line->total_localtax2 = -$line->total_localtax2;
646 $line->multicurrency_subprice = -$line->multicurrency_subprice;
647 $line->multicurrency_total_ht = -$line->multicurrency_total_ht;
648 $line->multicurrency_total_tva = -$line->multicurrency_total_tva;
649 $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
651 $result = $line->insert(0, 1);
653 $creditnote->lines[] = $line;
656 if ($result > 0 && $line->product_type == 9) {
657 $fk_parent_line = $result;
660 $creditnote->update_price(1);
664 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
671 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
673 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
676 dol_syslog(
"Validate invoice with stock change into warehouse defined into constant ".$constantforkey.
" = ".
getDolGlobalString($constantforkey).
" or warehouseid= ".$warehouseid.
" if defined.");
681 $res = $creditnote->validate($user,
'', $warehouseid, 0, $batch_rule);
688 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
690 $res = $creditnote->validate($user);
694 if (!$error && $res >= 0) {
697 dol_syslog(
"Now we record the stock movement for each qualified line");
700 require_once DOL_DOCUMENT_ROOT .
"/product/stock/class/mouvementstock.class.php";
701 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
704 $labeltakeposmovement =
'TakePOS - '.$langs->trans(
"CreditNote").
' '.$creditnote->ref;
706 foreach ($creditnote->lines as $line) {
708 $warehouseid = ($line->fk_warehouse ? $line->fk_warehouse :
getDolGlobalInt($constantforkey));
711 if ($line->batch !=
'' && $warehouseid > 0) {
716 $mouvP->setOrigin($creditnote->element, $creditnote->id);
718 $res = $mouvP->reception($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'', $line->batch,
'', 0, $inventorycode);
725 $mouvP->setOrigin($creditnote->element, $creditnote->id);
727 $res = $mouvP->reception($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'',
'', 0, $inventorycode);
737 if (!$error && $res >= 0) {
740 $creditnote->id = $placeid;
745 if (($action ==
'history' || $action ==
'creditnote') && $user->hasRight(
'takepos',
'run')) {
746 if ($action ==
'creditnote' && $creditnote !==
null && $creditnote->id > 0) {
747 $placeid = $creditnote->id;
753 $invoice->fetch($placeid);
757 if (($action ==
"addline" || $action ==
"freezone") && $placeid == 0 && ($user->hasRight(
'takepos',
'run') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
760 $dolnowtzuserrel =
dol_now(
'tzuserrel');
764 $dateinvoice =
dol_mktime(0, 0, 0, (
int) $monthuser, (
int) $dayuser, (
int) $yearuser,
'tzserver');
766 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
767 $invoice->date = $dateinvoice;
781 $invoice->module_source =
'takepos';
782 $invoice->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
783 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] :
$conf->entity;
785 if ($invoice->socid <= 0) {
786 $langs->load(
'errors');
792 $placeid = $invoice->create($user);
798 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture";
799 $sql .=
" SET ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
800 $sql .=
" WHERE rowid = ".((int) $placeid);
801 $resql =
$db->query($sql);
817 if ($action ==
"addline" && ($user->hasRight(
'takepos',
'run') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
819 $prod->fetch($idproduct);
822 $customer->fetch($invoice->socid);
824 $datapriceofproduct =
$prod->getSellPrice(
$mysoc, $customer, 0);
827 $price = $datapriceofproduct[
'pu_ht'];
828 $price_ttc = $datapriceofproduct[
'pu_ttc'];
830 $price_base_type = empty($datapriceofproduct[
'price_base_type']) ?
'HT' : $datapriceofproduct[
'price_base_type'];
831 $tva_tx = $datapriceofproduct[
'tva_tx'];
832 $tva_npr = (int) $datapriceofproduct[
'tva_npr'];
840 $batch =
GETPOST(
'batch',
'alpha');
842 if (!empty($batch)) {
843 $action =
"setbatch";
844 } elseif (
$prod->status_batch > 0) {
849 $prod->load_stock(
'warehouseopen');
851 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
855 foreach (
$prod->stock_warehouse as $tmpwarehouseid => $tmpval) {
860 if (!empty(
$prod->stock_warehouse[$tmpwarehouseid]) && is_array(
$prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
861 if (is_object(
$prod->stock_warehouse[$tmpwarehouseid]) && count(
$prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
862 foreach (
$prod->stock_warehouse[$tmpwarehouseid]->detail_batch as $dbatch) {
871 echo
"function addbatch(batch, warehouseid) {\n";
872 echo
"console.log('We add batch '+batch+' from warehouse id '+warehouseid);\n";
873 echo
'$("#poslines").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?action=addline&batch="+encodeURI(batch)+"&warehouseid="+warehouseid+"&place='.$place.
'&idproduct='.$idproduct.
'&token='.
newToken().
'", function() {});'.
"\n";
878 echo
"<center>".$langs->trans(
"SearchIntoBatch").
": <b> $nbofsuggested </b></center><br><table>";
879 foreach (
$prod->stock_warehouse as $tmpwarehouseid => $tmpval) {
884 if (!empty(
$prod->stock_warehouse[$tmpwarehouseid]) && is_array(
$prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
885 foreach (
$prod->stock_warehouse[$tmpwarehouseid]->detail_batch as $dbatch) {
886 $batchStock = + $dbatch->qty;
887 $quantityToBeDelivered = 1;
888 $deliverableQty = min($quantityToBeDelivered, $batchStock);
890 print
'<!-- subj='.$suggestednb.
'/'.$nbofsuggested.
' -->';
891 print
'<!-- Show details of lot/serial in warehouseid='.$tmpwarehouseid.
' -->';
892 print
'<td class="left">';
894 $detail .=
'<span class="opacitymedium">'.$langs->trans(
"LotSerial").
':</span> '.$dbatch->batch;
901 $detail .=
'</td><td>';
902 $detail .=
'<span class="opacitymedium">'.$langs->trans(
"Qty").
':</span> '.$dbatch->qty;
903 $detail .=
'</td><td>';
904 $detail .=
' <button class="marginleftonly" onclick="addbatch(\''.dol_escape_js($dbatch->batch).
'\',
'.$tmpwarehouseid.')
">'.$langs->trans("Select
")."</
button>
";
908 $quantityToBeDelivered -= $deliverableQty;
909 if ($quantityToBeDelivered < 0) {
910 $quantityToBeDelivered = 0;
919 print '</body></html>';
925 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
926 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
927 $cat = new Categorie($db);
928 $categories = $cat->containing($idproduct, 'product');
929 $found = (array_search(getDolGlobalInt('TAKEPOS_SUPPLEMENTS_CATEGORY'), array_column($categories, 'id')));
930 if ($found !== false) { // If this product is a supplement
931 $sql = "SELECT fk_parent_line FROM
".MAIN_DB_PREFIX."facturedet where rowid =
".((int) $selectedline);
932 $resql = $db->query($sql);
933 $row = $db->fetch_array($resql);
934 if ($row[0] == null) {
935 $parent_line = $selectedline;
937 $parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product
943 // Group if enabled. Skip group if line already sent to the printer
944 if (getDolGlobalString('TAKEPOS_GROUP_SAME_PRODUCT')) {
945 foreach ($invoice->lines as $line) {
946 if ($line->product_ref == $prod->ref) {
947 if ($line->special_code == 4) {
949 } // If this line is sended to printer create new line
950 // check if qty in stock
951 if (getDolGlobalString('TAKEPOS_QTY_IN_STOCK') && (($line->qty + $qty) > $prod->stock_reel)) {
952 $invoice->error = $langs->trans("ErrorStockIsNotEnough
");
953 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
957 $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);
959 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
961 $idoflineadded = $line->id;
967 if ($idoflineadded <= 0 && empty($err)) {
968 $invoice->fetch_thirdparty();
969 $array_options = array();
971 $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);
973 /* setup of margin calculation */
974 if (getDolGlobalString('MARGIN_TYPE')) {
975 if (getDolGlobalString('MARGIN_TYPE') == 'pmp' && !empty($prod->pmp)) {
976 $line['fk_fournprice'] = null;
977 $line['pa_ht'] = $prod->pmp;
978 } elseif (getDolGlobalString('MARGIN_TYPE') == 'costprice' && !empty($prod->cost_price)) {
979 $line['fk_fournprice'] = null;
980 $line['pa_ht'] = $prod->cost_price;
982 // default is fournprice
983 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
984 $pf = new ProductFournisseur($db);
985 if ($pf->find_min_price_product_fournisseur($idproduct, $qty) > 0) {
986 $line['fk_fournprice'] = $pf->product_fourn_price_id;
987 $line['pa_ht'] = $pf->fourn_unitprice_with_discount;
988 if (getDolGlobalString('PRODUCT_CHARGES') && $pf->fourn_charges > 0) {
989 $line['pa_ht'] += (float) $pf->fourn_charges / $pf->fourn_qty;
995 // complete line by hook
996 $parameters = array('prod' => $prod, 'line' => $line);
997 $reshook = $hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action); // Note that $action and $line may have been modified by some hooks
999 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1003 if (empty($reshook)) {
1004 if (!empty($hookmanager->resArray)) {
1005 $line = $hookmanager->resArray;
1008 // check if qty in stock
1009 if (getDolGlobalString('TAKEPOS_QTY_IN_STOCK') && $qty > $prod->stock_reel) {
1010 $invoice->error = $langs->trans("ErrorStockIsNotEnough
");
1011 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
1016 $idoflineadded = $invoice->addline($line['description'], $line['price'], $qty, $line['tva_tx'], $line['localtax1_tx'], $line['localtax2_tx'], $idproduct, (float) $line['remise_percent'], '', 0, 0, 0, 0, $price_base_type, $line['price_ttc'], $prod->type, -1, 0, '', 0, (empty($parent_line) ? '' : $parent_line), (empty($line['fk_fournprice']) ? 0 : $line['fk_fournprice']), (empty($line['pa_ht']) ? '' : $line['pa_ht']), '', $line['array_options'], 100, 0, $prod->fk_unit, 0);
1020 if (getDolGlobalString('TAKEPOS_CUSTOMER_DISPLAY')) {
1021 $CUSTOMER_DISPLAY_line1 = $prod->label;
1022 $CUSTOMER_DISPLAY_line2 = price($price_ttc);
1026 $invoice->fetch($placeid);
1029 // If we add a line by submitting freezone form (invoice exists here because it was created just before if it didn't exist)
1030 if ($action == "freezone
" && $user->hasRight('takepos', 'run')) {
1031 $customer = new Societe($db);
1032 $customer->fetch($invoice->socid);
1034 $tva_tx = GETPOST('tva_tx', 'alpha');
1035 if ($tva_tx != '') {
1036 if (!preg_match('/\((.*)\)/', $tva_tx)) {
1037 $tva_tx = price2num($tva_tx);
1040 $tva_tx = get_default_tva($mysoc, $customer);
1044 $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
1045 $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
1047 $res = $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 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, 0, 0, '', array(), 100, 0, null, 0);
1049 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
1051 $invoice->fetch($placeid);
1054 if ($action == "addnote
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1055 $desc = GETPOST('addnote', 'alpha');
1057 $invoice->update_note($desc, '_public');
1059 foreach ($invoice->lines as $line) {
1060 if ($line->id == $idline) {
1061 $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);
1065 $invoice->fetch($placeid);
1068 if ($action == "deleteline
" && ($user->hasRight('takepos', 'editlines') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1070 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1071 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1072 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1073 $permissiontoupdateline = true;
1074 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1075 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1080 if ($idline > 0 && $placeid > 0) { // If invoice exists and a line is selected.
1081 $result = takeposDeleteLineWithChildren($invoice, $idline);
1083 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
1085 $invoice->fetch($placeid);
1086 } elseif ($placeid > 0) { // If invoice exists but no line selected (delete from another device or with no line selected), proceed to delete the last line.
1087 $sql = "SELECT rowid FROM
".MAIN_DB_PREFIX."facturedet where fk_facture =
".((int) $placeid)." ORDER BY rowid DESC
";
1088 $resql = $db->query($sql);
1089 $obj = $db->fetch_object($resql);
1091 $deletelineid = $obj->rowid;
1092 $result = takeposDeleteLineWithChildren($invoice, $deletelineid);
1094 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
1097 $invoice->fetch($placeid);
1102 if (count($invoice->lines) == 0) {
1103 // Keep an empty draft invoice alive when a non-default customer was
1104 // already attached so deleting the last line does not silently lose
1105 // the customer that was just selected (#38219). Only drop the invoice
1106 // when it is still on the default cashdesk thirdparty (or none).
1107 $defaultsocid = (int) getDolGlobalString('CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal
"]);
1108 $invoicesocid = (int) $invoice->socid;
1109 if ($invoicesocid === 0 || $invoicesocid === $defaultsocid) {
1110 $invoice->delete($user);
1112 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1113 header("Location:
".DOL_URL_ROOT."/takepos/public/auto_order.php
");
1115 header("Location:
".DOL_URL_ROOT."/takepos/invoice.php
");
1122 // Action to delete or discard an invoice
1123 if ($action == "delete
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1124 // $placeid is the invoice id (it differs from place) and is defined if the place is set and
1125 // the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal
"].'-'.$place.')', so the fetch at beginning of page works.
1127 $result = $invoice->fetch($placeid);
1129 if ($result > 0 && $invoice->status == Facture::STATUS_DRAFT) {
1132 // We delete the lines
1133 $resdeletelines = 1;
1134 foreach ($invoice->lines as $line) {
1135 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1136 $tmpres = $invoice->deleteLine($line->id);
1138 $resdeletelines = 0;
1143 $sql = "UPDATE
".MAIN_DB_PREFIX."facture
";
1144 $varforconst = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal
"];
1145 $sql .= " SET fk_soc =
".((int) getDolGlobalString($varforconst)).",
";
1146 $sql .= " datec =
'".$db->idate(dol_now())."'";
1147 $sql .= " WHERE entity IN (
".getEntity('invoice').")
";
1148 $sql .= " AND
ref =
'(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'";
1149 $resql1 = $db->query($sql);
1151 if ($resdeletelines && $resql1) {
1157 $invoice->fetch($placeid);
1162 if ($action == "updateqty
") { // Test on permission is done later
1163 foreach ($invoice->lines as $line) {
1164 if ($line->id == $idline) {
1165 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1166 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1167 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1168 $permissiontoupdateline = true;
1169 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1170 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1173 if (!$permissiontoupdateline) {
1174 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
").' - No permission to updateqty', [], 1);
1176 $vatratecode = $line->tva_tx;
1177 if ($line->vat_src_code) {
1178 $vatratecode .= ' ('.$line->vat_src_code.')';
1181 $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $vatratecode, $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);
1186 $invoice->fetch($placeid);
1189 if ($action == "updateprice
") { // Test on permission is done later
1190 $customer = new Societe($db);
1191 $customer->fetch($invoice->socid);
1193 foreach ($invoice->lines as $line) {
1194 if ($line->id == $idline) {
1195 $prod = new Product($db);
1196 $prod->fetch($line->fk_product);
1197 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
1198 $price_min = $datapriceofproduct['price_min'];
1199 $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS'));
1201 $vatratecleaned = $line->tva_tx;
1203 if (preg_match('/^(.*)\s*\((.*)\)$/', (string) $line->tva_tx, $reg)) { // If vat is "xx (yy)
"
1204 $vatratecleaned = trim($reg[1]);
1205 //$vatratecode = $reg[2];
1208 $pu_ht = price2num((float) price2num($number, 'MU') / (1 + ((float) $vatratecleaned / 100)), 'MU');
1210 if ($usercanproductignorepricemin && (!empty($price_min) && ((float) price2num($pu_ht) * (1 - (float) price2num($line->remise_percent) / 100) < price2num($price_min)))) {
1211 $langs->load("products
");
1212 dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice
", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
1213 // echo $langs->trans("CantBeLessThanMinPrice
");
1215 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1216 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1217 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1218 $permissiontoupdateline = true;
1219 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1220 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1224 $vatratecode = $line->tva_tx;
1225 if ($line->vat_src_code) {
1226 $vatratecode .= ' ('.$line->vat_src_code.')';
1229 if (!$permissiontoupdateline) {
1230 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
").' - No permission to updateprice', [], 1);
1231 } elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) {
1232 $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $vatratecode, $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);
1234 $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $vatratecode, $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);
1241 $invoice->fetch($placeid);
1244 if ($action == "updatereduction
") { // Test on permission is done later
1245 $customer = new Societe($db);
1246 $customer->fetch($invoice->socid);
1248 foreach ($invoice->lines as $line) {
1249 if ($line->id == $idline) {
1250 dol_syslog("updatereduction Process line
".$line->id.' to apply discount of '.$number.'%');
1252 $prod = new Product($db);
1253 $prod->fetch($line->fk_product);
1255 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
1256 $price_min = $datapriceofproduct['price_min'];
1257 $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS'));
1259 $pu_ht = price2num($line->subprice / (1 + ($line->tva_tx / 100)), 'MU');
1262 if ($usercanproductignorepricemin && (!empty($price_min) && ((float) price2num($line->subprice) * (1 - (float) price2num($number) / 100) < (float) price2num($price_min)))) {
1263 $langs->load("products
");
1264 dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice
", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
1266 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1267 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1268 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1269 $permissiontoupdateline = true;
1270 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1271 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1274 if (!$permissiontoupdateline) {
1275 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
"), [], 1);
1277 $vatratecode = $line->tva_tx;
1278 if ($line->vat_src_code) {
1279 $vatratecode .= ' ('.$line->vat_src_code.')';
1281 $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $vatratecode, $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);
1288 $invoice->fetch($placeid);
1289 } elseif ($action == 'update_reduction_global' && $user->hasRight('takepos', 'editlines')) {
1290 foreach ($invoice->lines as $line) {
1291 $vatratecode = $line->tva_tx;
1292 if ($line->vat_src_code) {
1293 $vatratecode .= ' ('.$line->vat_src_code.')';
1295 $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $vatratecode, $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);
1298 $invoice->fetch($placeid);
1301 if ($action == "setbatch
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1302 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
1303 $warehouseid = (GETPOSTINT('warehouseid') > 0 ? GETPOSTINT('warehouseid') : getDolGlobalInt($constantforkey)); // Get the warehouse id from GETPOSTINT('warehouseid'), otherwise use default setup.
1304 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet SET batch =
'".$db->escape($batch)."', fk_warehouse =
".((int) $warehouseid);
1305 $sql .= " WHERE rowid =
".((int) $idoflineadded);
1309 if ($action == "order
" && $placeid != 0 && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1310 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1311 if ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1312 require_once DOL_DOCUMENT_ROOT.'/takepos/class/dolreceiptprinter.class.php';
1313 $printer = new dolReceiptPrinter($db);
1316 $sql = "SELECT label FROM
".MAIN_DB_PREFIX."takepos_floor_tables where rowid =
".((int) $place);
1317 $resql = $db->query($sql);
1318 $row = $db->fetch_object($resql);
1319 $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>';
1320 $footerorder = '</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>';
1321 $order_receipt_printer1 = "";
1322 $order_receipt_printer2 = "";
1323 $order_receipt_printer3 = "";
1324 $catsprinter1 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_1'));
1325 $catsprinter2 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_2'));
1326 $catsprinter3 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_3'));
1328 foreach ($invoice->lines as $line) {
1329 if ($line->special_code == "4
") {
1332 $c = new Categorie($db);
1333 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1334 $result = array_intersect($catsprinter1, $existing);
1335 $count = count($result);
1336 if (!$line->fk_product) {
1337 $count++; // Print Free-text item (Unassigned printer) to Printer 1
1341 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet set special_code=
'1' where rowid =
".((int) $line->id); //Set to print on printer 1
1343 $order_receipt_printer1 .= '<tr><td class="left
">';
1344 if ($line->fk_product) {
1345 $order_receipt_printer1 .= $line->product_label;
1347 $order_receipt_printer1 .= $line->description;
1349 $order_receipt_printer1 .= '</td><td class="right
">'.$line->qty;
1350 if (!empty($line->array_options['options_order_notes'])) {
1351 $order_receipt_printer1 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1353 $order_receipt_printer1 .= '</td></tr>';
1356 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0 && $printer !== null) {
1357 $invoice->fetch($placeid); //Reload object before send to printer
1358 $printer->orderprinter = 1;
1360 echo "var orderprinter1esc=
'";
1361 $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
1364 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'1' and fk_facture =
".((int) $invoice->id); // Set as printed
1366 $invoice->fetch($placeid); //Reload object after set lines as printed
1369 foreach ($invoice->lines as $line) {
1370 if ($line->special_code == "4
") {
1373 $c = new Categorie($db);
1374 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1375 $result = array_intersect($catsprinter2, $existing);
1376 $count = count($result);
1379 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'2' where rowid =
".((int) $line->id); //Set to print on printer 2
1381 $order_receipt_printer2 .= '<tr>'.$line->product_label.'<td class="right
">'.$line->qty;
1382 if (!empty($line->array_options['options_order_notes'])) {
1383 $order_receipt_printer2 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1385 $order_receipt_printer2 .= '</td></tr>';
1388 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0) {
1389 $invoice->fetch($placeid); //Reload object before send to printer
1390 $printer->orderprinter = 2;
1392 echo "var orderprinter2esc=
'";
1393 $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
1396 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'2' and fk_facture =
".((int) $invoice->id); // Set as printed
1398 $invoice->fetch($placeid); //Reload object after set lines as printed
1401 foreach ($invoice->lines as $line) {
1402 if ($line->special_code == "4
") {
1405 $c = new Categorie($db);
1406 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1407 $result = array_intersect($catsprinter3, $existing);
1408 $count = count($result);
1411 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'3' where rowid =
".((int) $line->id); //Set to print on printer 3
1413 $order_receipt_printer3 .= '<tr>'.$line->product_label.'<td class="right
">'.$line->qty;
1414 if (!empty($line->array_options['options_order_notes'])) {
1415 $order_receipt_printer3 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1417 $order_receipt_printer3 .= '</td></tr>';
1420 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0 && $printer !== null) {
1421 $invoice->fetch($placeid); //Reload object before send to printer
1422 $printer->orderprinter = 3;
1424 echo "var orderprinter3esc=
'";
1425 $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
1428 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'3' and fk_facture =
".((int) $invoice->id); // Set as printed
1430 $invoice->fetch($placeid); //Reload object after set lines as printed
1433 $sectionwithinvoicelink = '';
1434 if (($action == "valid
" || $action == "history
" || $action == 'creditnote' || ($action == 'addline' && $invoice->status == $invoice::STATUS_CLOSED)) && $user->hasRight('takepos', 'run')) {
1435 $sectionwithinvoicelink .= '<!-- Section with invoice link -->'."\n
";
1436 $sectionwithinvoicelink .= '<span style="font-size:120%;
" class="center
inline-block marginbottomonly
">';
1437 if ($invoice->status == $invoice::STATUS_DRAFT) {
1438 $sectionwithinvoicelink .= $invoice->ref;
1440 $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice');
1442 $sectionwithinvoicelink .= " -
";
1443 $remaintopay = $invoice->getRemainToPay();
1444 if ($remaintopay > 0) {
1445 $sectionwithinvoicelink .= $langs->trans('RemainToPay').': <span class="amountremaintopay
" style="font-size: unset
">'.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
1447 $sectionwithinvoicelink .= $invoice->getLibStatut(2);
1450 $sectionwithinvoicelink .= '</span><br>';
1452 $customprinterallowed = false;
1453 $customprinttemplateallowed = true;
1455 // BAR RESTAURANT specific menu
1456 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1457 // Button to print receipt before payment
1458 $customprinterallowed = true;
1459 $customprinttemplateallowed = true;
1462 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
1463 if (isALNERunningVersion()) {
1464 // Custom printer may be allowed if mandatory information in template are guaranteed. For the moment, we prefer not allow this.
1465 $customprinttemplateallowed = false;
1468 if ($invoice->status == $invoice::STATUS_CLOSED) {
1469 if (getDolGlobalInt('TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
1470 $sectionwithinvoicelink .= ' <a target="_blank
" class="button" href="' . DOL_URL_ROOT . '/document.php?token=
' . newToken() . '&modulepart=facture&file=
' . $invoice->ref . '/
' . $invoice->ref . '.pdf
">'.$langs->trans("Invoice
").'</a>';
1472 // This section should be same than into index.php
1473 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1474 // Used when the external addon takeposconnector is installed. Deprecated.
1475 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
1476 // If TAKEPOS_PRINT_SERVER is an URL
1477 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintByESCPOSOld(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1479 // If TAKEPOS_PRINT_SERVER is an IP
1480 // Print by calling the receipt.php to get HTML content and send the HTML content to TAKEPOS_PRINT_SERVER:8111/print
1481 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintHTMLToSlashPrint(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1483 } elseif ($customprinterallowed && $customprinttemplateallowed && (isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") { // @phpstan-ignore-line
1484 // Button Print Receipt on special custom printer using custom template
1485 $nameOfPrinter = dol_getIdFromCode($db, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term), 'printer_receipt', 'rowid', 'name', 1);
1486 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintByESCPOS(
'.$placeid.')
" title="'.dolPrintHTMLForAttribute($langs->trans("SentToPrinter").' '.$nameOfPrinter).'">'.$langs->trans('PrintTicket').'</button>';
1488 // Button Print Receipt on browser
1489 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintByBrowser(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1491 // Additional buttons
1492 if ($customprinttemplateallowed && getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) {
1493 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintBox(
'.$placeid.', \
'without_details\')">'.$langs->trans(
'PrintWithoutDetails').
'</button>';
1496 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="PrintByBrowser('.$placeid.
', 1)">'.$langs->trans(
'GiftReceipt').
'</button>';
1501 $sectionwithinvoicelink .=
' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.
')">'.$langs->trans(
'SendTicket').
'</button>';
1504 if ($remaintopay <= 0 &&
getDolGlobalString(
'TAKEPOS_AUTO_PRINT_TICKETS') && $action !=
"history") {
1505 $sectionwithinvoicelink .=
'<script type="text/javascript">console.log("Emulate click on #buttonprint"); $("#buttonprint").click();</script>';
1519if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1520 $title =
'TakePOS - Dolibarr '.DOL_VERSION;
1524 $head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
1525 <meta name="apple-mobile-web-app-capable" content="yes">
1526 <meta name="mobile-web-app-capable" content="yes">
1527 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
1528 $arrayofcss = array(
1529 '/takepos/css/pos.css.php',
1531 $arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
1534 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
1536 print
'<body>'.
"\n";
1543<script
type=
"text/javascript">
1546<?php
if ($action ==
"valid") {
1547 echo
"var place=0;";
1549var placeid=<?php echo($placeid > 0 ? $placeid : 0); ?>;
1550$(document).ready(
function() {
1551 var idoflineadded = <?php echo(empty($idoflineadded) ? 0 : $idoflineadded); ?>;
1553 $(
'.posinvoiceline').click(
function(){
1554 console.log(
"Click done on "+this.
id);
1555 $(
'.posinvoiceline').removeClass(
"selected");
1556 $(
this).addClass(
"selected");
1560 if (selectedline == this.
id) {
1563 selectedline = this.id;
1565 selectedtext=$(
'#'+selectedline).find(
"td:first").html();
1567 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1568 print
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?action=editline&token='.
newToken().
'&placeid="+placeid+"&selectedline="+selectedline, function() {
1575 if (idoflineadded > 0)
1577 console.log(
"Auto select "+idoflineadded);
1578 $(
'.posinvoiceline#'+idoflineadded).click();
1582if ($action ==
"order" && !empty($order_receipt_printer1)) {
1583 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1587 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php',
1588 data:
'invoice='+orderprinter1esc
1595 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1597 print $headerorder.$order_receipt_printer1.$footerorder; ?>'
1603if ($action ==
"order" && !empty($order_receipt_printer2)) {
1604 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1608 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php?printer=2',
1609 data:
'invoice='+orderprinter2esc
1616 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print2',
1618 print $headerorder.$order_receipt_printer2.$footerorder; ?>'
1624if ($action ==
"order" && !empty($order_receipt_printer3)) {
1625 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1629 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php?printer=3',
1630 data:
'invoice='+orderprinter3esc
1637if ($action ==
"search" || $action ==
"valid") {
1639 parent.ClearSearch(
true);
1644if ($action ==
"temp" && !empty($ticket_printer1)) {
1648 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1650 print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>'
1655if ($action ==
"search") {
1657 $(
'#search').focus();
1665function SendTicket(
id)
1667 console.log(
"Open box to select the Print/Send form");
1668 $.colorbox({href:
"send.php?facid="+id, width:
"70%", height:
"30%", transition:
"none", iframe:
"true", title:
'<?php echo dol_escape_js($langs->trans("SendTicket")); ?>'});
1673function PrintBox(
id, action) {
1674 console.log(
"Open box before printing");
1675 $.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
"); ?>"});
1680function PrintByBrowser(
id, gift) {
1681 console.log(
"Call PrintByBrowser() to generate the receipt.");
1682 $.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")); ?>'});
1687function PrintHTMLToSlashPrint(
id){
1689 console.log(
"PrintHTMLToSlashPrint" +
id);
1690 $.get(
"receipt.php?facid="+
id,
function(data,
status) {
1691 receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,
'');
1694 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1702function PrintByESCPOSOld(
id){
1703 console.log(
"PrintByESCPOSOld id=" +
id);
1704 $.get(
"<?php echo DOL_URL_ROOT; ?>/takepos/ajax/ajax.php?action=printinvoiceticket&token=<?php echo currentToken(); ?>&term=<?php echo urlencode(isset($_SESSION["takeposterminal
"]) ? $_SESSION["takeposterminal
"] : ''); ?>&id="+
id,
function(data,
status) {
1707 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php',
1708 data:
'invoice='+data
1719function PrintByESCPOS(
id) {
1720 console.log(
"PrintByESCPOS Printing invoice ticket by calling takepos/aja/ajax.php id=" +
id);
1724 data: { token:
'<?php echo currentToken(); ?>' },
1725 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=printinvoiceticket&token='.currentToken().'&term='.urlencode(isset($_SESSION["takeposterminal
"]) ? $_SESSION["takeposterminal
"] : '').'&id='; ?>" + id,
1726 success:
function(){
1727 showPrintResultPopup(
'<?php echo dol_escape_js($langs->trans("SentToPrinter").' '.$nameOfPrinter); ?>', 2000);
1730 showPrintResultPopup(
"<?php echo dol_escape_js($langs->trans("FailedToSendToPrinter
")); ?>", 2000);
1737function showPrintResultPopup(message, duration) {
1738 $(
"#dialogforpopuptakepos").show().text(message).fadeIn();
1740 setTimeout(
function(){
1741 $(
"#dialogforpopuptakepos").fadeOut().hide();
1748function CreditNote() {
1749 $(
"#poslines").load(
"<?php print DOL_URL_ROOT; ?>/takepos/invoice.php?action=creditnote&token=<?php echo newToken() ?>&invoiceid="+placeid,
function() { });
1755 $(
"#poslines").load(
"<?php print DOL_URL_ROOT; ?>/takepos/invoice.php?action=addnote&token=<?php echo newToken() ?>&invoiceid="+placeid+
"&idline="+selectedline, {
"addnote": $(
"#textinput").val() });
1760$( document ).ready(
function() {
1761 console.log(
"Set customer info and sales in header placeid=<?php echo $placeid; ?> status=<?php echo $invoice->statut; ?>");
1764 $s = $langs->trans(
"Customer");
1765 if ($invoice->id > 0 && ($invoice->socid !=
getDolGlobalString($constforcompanyid))) {
1768 $contactids = $invoice->getIdContact(
'external',
'BILLING');
1769 $contactid = $contactids[0];
1770 if ($contactid > 0) {
1772 $contact->fetch($contactid);
1773 $s .=
" - " . $contact->getFullName($langs);
1777 print
'$("#idcustomer").val("");';
1781 $(
"#customerandsales").html(
'');
1782 $(
"#shoppingcart").html(
'');
1785 $(
"#customerandsales").append(
'<a class="valignmiddle tdoverflowmax100 minwidth100" id="customer" onclick="Customer();" title="<?php print dol_escape_js(dol_escape_htmltag((string) $s)); ?>"><span class="fas fa-building paddingrightonly"></span><?php print dol_escape_js((string) $s); ?></a>');
1787 $(
"#customerandsales").append(
'<a class="valignmiddle tdoverflowmax300 minwidth100" id="contact" onclick="Contact();" title="<?php print dol_escape_js(dol_escape_htmltag((string) $s)); ?>"><span class="fas fa-building paddingrightonly"></span><?php print dol_escape_js((string) $s); ?></a>');
1791 $sql =
"SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX.
"facture";
1792 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
1795 $sql .=
" AND ref LIKE '(PROV-POS".$db->escape(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'').
"-0%'";
1798 $sql .=
" AND pos_source = '".$db->escape((
string) $_SESSION[
"takeposterminal"]).
"'";
1799 $sql .=
" AND module_source = 'takepos'";
1802 $sql .=
$db->order(
'datec',
'ASC');
1803 $resql =
$db->query($sql);
1806 while ($obj =
$db->fetch_object($resql)) {
1807 echo
'$("#shoppingcart").append(\'';
1808 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=\\\'';
1809 $num_sale = str_replace(
")",
"", str_replace(
"(PROV-POS".$_SESSION[
"takeposterminal"].
"-",
"", $obj->ref));
1811 if (str_replace(
"-",
"", $num_sale) > $max_sale) {
1812 $max_sale = str_replace(
"-",
"", $num_sale);
1814 echo
'\\\'; invoiceid=\\\'';
1816 echo
'\\\'; Refresh();">';
1817 if ($placeid == $obj->rowid) {
1818 echo
'<span class="basketselected">';
1820 echo
'<span class="basketnotselected">';
1822 echo
'<span class="fa fa-shopping-cart paddingright"></span>'.dol_print_date(
$db->jdate($obj->datec),
'%H:%M',
'tzuser');
1826 echo
'$("#shoppingcart").append(\'<a onclick="place=\\\'0-';
1828 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>\');';
1836 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1839 $constantforkey =
'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1841 if ($idwarehouse > 0) {
1842 $s =
'<span class="small">';
1844 $warehouse->fetch($idwarehouse);
1845 $s .=
'<span class="hideonsmartphone">'.$langs->trans(
"Warehouse").
'<br></span>'.$warehouse->ref;
1847 $s .=
' ('.$langs->trans(
"Closed").
')';
1850 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1851 print
'$("#infowarehouse").css("display", "inline-block");';
1853 $s =
'<span class="small hideonsmartphone">';
1854 $s .= $langs->trans(
"StockChangeDisabled").
'<br>'.$langs->trans(
"NoWarehouseDefinedForTerminal");
1856 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1857 if (!empty(
$conf->dol_optimize_smallscreen)) {
1858 print
'$("#infowarehouse").css("display", "none");';
1862 $s =
'<span class="small hideonsmartphone">'.$langs->trans(
"StockChangeDisabled").
'</span>';
1863 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1864 if (!empty(
$conf->dol_optimize_smallscreen)) {
1865 print
'$("#infowarehouse").css("display", "none");';
1874 $s =
'<span class="small">';
1875 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1876 $langs->load(
"members");
1877 $s .= $langs->trans(
"Member").
': ';
1879 $result = $adh->fetch(0,
'', $invoice->socid);
1881 $adh->ref = $adh->getFullName($langs);
1885 $s .= $adh->getFullName($langs);
1886 $s .=
' - '.$adh->type;
1887 if ($adh->datefin) {
1888 $s .=
'<br>'.$langs->trans(
"SubscriptionEndDate").
': '.
dol_print_date($adh->datefin,
'day');
1889 if ($adh->hasDelay()) {
1890 $s .=
" ".img_warning($langs->trans(
"Late"));
1893 $s .=
'<br>'.$langs->trans(
"SubscriptionNotReceived");
1894 if ($adh->status > 0) {
1895 $s .=
" ".img_warning($langs->trans(
"Late"));
1902 $s .=
'<br>'.$langs->trans(
"ThirdpartyNotLinkedToMember");
1907 $(
"#moreinfo").html(
'<?php print dol_escape_js($s); ?>');
1914 echo
"function CustomerDisplay(){";
1915 echo
"var line1='".$CUSTOMER_DISPLAY_line1.
"'.substring(0,20);";
1916 echo
"line1=line1.padEnd(20);";
1917 echo
"var line2='".$CUSTOMER_DISPLAY_line2.
"'.substring(0,20);";
1918 echo
"line2=line2.padEnd(20);";
1920 echo
'webSocketCustomerDisplay.send(line1);';
1921 echo
'webSocketCustomerDisplay.send(line2);';
1925 data: { text: line1+line2 },
1926 url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER').
"/display/index.php',
1938if (!empty(
$conf->use_javascript_ajax)) {
1939 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
1940 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.
'"></script>'.
"\n";
1943$usediv = (
GETPOST(
'format') ==
'div');
1945print
'<!-- invoice.php place='.(int) $place.
' invoice='.$invoice->ref.
' usediv='.json_encode($usediv).
', mobilepage='.(empty($mobilepage) ?
'' : $mobilepage).
' $_SESSION["basiclayout"]='.(empty($_SESSION[
"basiclayout"]) ?
'' : $_SESSION[
"basiclayout"]).
' conf TAKEPOS_BAR_RESTAURANT='.
getDolGlobalString(
'TAKEPOS_BAR_RESTAURANT').
' -->'.
"\n";
1946print
'<div class="div-table-responsive-no-min invoice">';
1948 print
'<div id="tablelines">';
1950 print
'<table id="tablelines" class="noborder noshadow postablelines centpercent">';
1953$buttontocreatecreditnote =
'';
1954if (($action ==
"valid" || $action ==
"history" || $action ==
"addline")
1956 $buttontocreatecreditnote .=
' <!-- Show button to create a credit note -->'.
"\n";
1957 $buttontocreatecreditnote .=
'<button id="buttonprint" type="button" onclick="ModalBox(\'ModalCreditNote\')">'.$langs->trans(
'CreateCreditNote').
'</button>';
1958 if (
getDolGlobalInt(
'TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
1959 $buttontocreatecreditnote .=
' <a target="_blank" class="button" href="' . DOL_URL_ROOT .
'/document.php?token=' .
newToken() .
'&modulepart=facture&file=' . urlencode($invoice->ref .
'/' . $invoice->ref .
'.pdf').
'">'.$langs->trans(
"Invoice").
'</a>';
1964if ($sectionwithinvoicelink && ($mobilepage ==
"invoice" || $mobilepage ==
"")) {
1965 print
'<!-- Print table line with link to invoice ref -->';
1967 print
'<tr><td colspan="5" class="paddingtopimp paddingbottomimp" style="padding-top: 10px !important; padding-bottom: 10px !important;">';
1968 print $sectionwithinvoicelink;
1969 print $buttontocreatecreditnote;
1972 print
'<tr><td colspan="4" class="paddingtopimp paddingbottomimp" style="padding-top: 10px !important; padding-bottom: 10px !important;">';
1973 print $sectionwithinvoicelink;
1974 print $buttontocreatecreditnote;
1981 print
'<tr class="liste_titre nodrag nodrop">';
1982 print
'<td class="linecoldescription">';
1985if (empty($mobilepage) || $mobilepage ==
"invoice") {
1986 print
'<!-- hidden var used by some js functions -->';
1987 print
'<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.
'">';
1988 print
'<input type="hidden" name="thirdpartyid" id="thirdpartyid" value="'.$invoice->socid.
'">';
1992 $sql =
"SELECT floor, label FROM ".MAIN_DB_PREFIX.
"takepos_floor_tables where rowid = ".((int) $place);
1993 $resql =
$db->query($sql);
1994 $obj =
$db->fetch_object($resql);
1996 $label = $obj->label;
1997 $floor = $obj->floor;
1999 if ($mobilepage ==
"invoice" || $mobilepage ==
"") {
2002 print
'<span class="opacitymedium">'.$langs->trans(
'Place').
"</span> <b>".(empty($label) ?
'?' : $label).
"</b><br>";
2003 print
'<span class="opacitymedium">'.$langs->trans(
'Floor').
"</span> <b>".(empty($floor) ?
'?' : $floor).
"</b>";
2010$parameters = array();
2011$reshook = $hookmanager->executeHooks(
'completeTakePosInvoiceHeader', $parameters, $invoice, $action);
2015print $hookmanager->resPrint;
2017if (empty($_SESSION[
"basiclayout"]) || $_SESSION[
"basiclayout"] != 1) {
2019 print
'<td class="linecolqty right">'.$langs->trans(
'PriceUHT').
'</td>';
2021 print
'<td class="linecolqty right">'.$langs->trans(
'ReductionShort').
'</td>';
2022 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
2024 print
'<td class="linecolht right nowraponall">';
2025 print
'<span class="opacitymedium small">' . $langs->trans(
'TotalHTShort') .
'</span><br>';
2027 if (empty($mobilepage) || $mobilepage ==
"invoice") {
2028 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>';
2029 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"]) &&
$conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
2031 include_once DOL_DOCUMENT_ROOT .
'/multicurrency/class/multicurrency.class.php';
2033 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
2034 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>';
2039 print
'<td class="linecolht right nowraponall">';
2040 print
'<span class="opacitymedium small">'.$langs->trans(
'TotalTTCShort').
'</span><br>';
2042 if (empty($mobilepage) || $mobilepage ==
"invoice") {
2043 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>';
2044 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"]) &&
$conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
2046 include_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
2048 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
2049 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>';
2053} elseif ($mobilepage ==
"invoice") {
2054 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
2060if (!empty($_SESSION[
"basiclayout"]) && $_SESSION[
"basiclayout"] == 1) {
2061 if ($mobilepage ==
"cats") {
2062 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2064 $categories = $categorie->get_full_arbo(
'product');
2066 foreach ($categories as $row) {
2067 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2068 $htmlforlines .=
'<div class="leftcat"';
2070 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline"';
2072 $htmlforlines .=
' onclick="LoadProducts('.$row[
'id'].
');">';
2073 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2074 $htmlforlines .=
'<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=cat&query=cat&id='.$row[
'id'].
'"><br>';
2076 $htmlforlines .=
'<td class="left">';
2078 $htmlforlines .= $row[
'label'];
2079 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2080 $htmlforlines .=
'</div>'.
"\n";
2082 $htmlforlines .=
'</td></tr>'.
"\n";
2085 print $htmlforlines;
2088 if ($mobilepage ==
"products") {
2089 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2092 $result =
$object->fetch($catid);
2093 $prods =
$object->getObjectsInCateg(
"product");
2095 '@phan-var-force Product[] $prods';
2097 foreach ($prods as $row) {
2098 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2099 $htmlforlines .=
'<div class="leftcat"';
2101 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline"';
2103 $htmlforlines .=
' onclick="AddProduct(\''.$place.
'\',
'.$row->id.')
"';
2104 $htmlforlines .= '>';
2105 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2106 $htmlforlines .= '<img class="imgwrapper
" width="33%
" src="'.DOL_URL_ROOT.'/takepos/
public/auto_order.php?genimg=pro&query=pro&
id=
'.$row->id.'"><br>';
2107 $htmlforlines .= $row->label.' '.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency);
2108 $htmlforlines .= '</div>'."\n
";
2110 $htmlforlines .= '<td class="left
">';
2111 $htmlforlines .= $row->label;
2112 $htmlforlines .= '<div class="right
">'.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).'</div>';
2113 $htmlforlines .= '</td>';
2114 $htmlforlines .= '</tr>'."\n
";
2117 print $htmlforlines;
2120 if ($mobilepage == "places
") {
2121 $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM
".MAIN_DB_PREFIX."takepos_floor_tables
";
2122 $resql = $db->query($sql);
2126 while ($row = $db->fetch_array($resql)) {
2128 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
2129 $htmlforlines .= '" onclick="LoadPlace(\
''.$row[
'label'].
'\')
">';
2130 $htmlforlines .= '<td class="left
">';
2131 $htmlforlines .= $row['label'];
2132 $htmlforlines .= '</td>';
2133 $htmlforlines .= '</tr>'."\n
";
2135 print $htmlforlines;
2140 //In Phone basic layout hide some content depends situation
2141 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1 && $mobilepage != "invoice
" && $action != "order
") {
2145 // Loop on each lines on invoice
2146 if (is_array($invoice->lines) && count($invoice->lines)) {
2147 print '<!-- invoice.php show lines of invoices -->'."\n
";
2148 $tmplines = array_reverse($invoice->lines);
2149 $htmlsupplements = array();
2150 foreach ($tmplines as $line) {
2151 if ($line->fk_parent_line != false) {
2152 if (!isset($htmlsupplements[$line->fk_parent_line])) {
2153 $htmlsupplements[$line->fk_parent_line] = '';
2155 $htmlsupplements[$line->fk_parent_line] .= '<tr class="drag drop oddeven posinvoiceline
';
2156 if ($line->special_code == "4") {
2157 $htmlsupplements[$line->fk_parent_line] .= ' order
';
2159 $htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'"';
2160 if ($line->special_code == "4
") {
2161 $htmlsupplements[$line->fk_parent_line] .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
2163 $htmlsupplements[$line->fk_parent_line] .= '>';
2164 $htmlsupplements[$line->fk_parent_line] .= '<td class="left
">';
2165 $htmlsupplements[$line->fk_parent_line] .= img_picto('', 'rightarrow.png');
2166 if ($line->product_label) {
2167 $htmlsupplements[$line->fk_parent_line] .= $line->product_label;
2169 if ($line->product_label && $line->desc) {
2170 $htmlsupplements[$line->fk_parent_line] .= '<br>';
2172 if ($line->product_label != $line->desc) {
2173 $firstline = dolGetFirstLineOfText($line->desc);
2174 if ($firstline != $line->desc) {
2175 $htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
2177 $htmlsupplements[$line->fk_parent_line] .= $line->desc;
2180 $htmlsupplements[$line->fk_parent_line] .= '</td>';
2182 // complete line by hook
2183 $parameters = array('line' => $line);
2184 $reshook = $hookmanager->executeHooks('completeTakePosInvoiceParentLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
2186 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2188 $htmlsupplements[$line->fk_parent_line] .= $hookmanager->resPrint;
2190 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2191 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.vatrate(price2num($line->remise_percent), true).'</td>';
2192 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.$line->qty.'</td>';
2193 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.price($line->total_ttc).'</td>';
2195 $htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n
";
2200 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
2201 if ($line->special_code == "4") {
2202 $htmlforlines .= ' order
';
2204 $htmlforlines .= '" id="'.$line->id.'"';
2205 if ($line->special_code == "4
") {
2206 $htmlforlines .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
2208 $htmlforlines .= '>';
2209 $htmlforlines .= '<td class="left
">';
2210 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
2211 $htmlforlines .= '<span class="phoneqty
">'.$line->qty."</span> x
";
2213 if (isset($line->product_type)) {
2214 if (empty($line->product_type)) {
2215 $htmlforlines .= img_object('', 'product').' ';
2217 $htmlforlines .= img_object('', 'service').' ';
2221 if (!getDolGlobalString('TAKEPOS_SHOW_N_FIRST_LINES')) {
2222 if ($line->product_ref) {
2223 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
2224 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
2225 if (!empty($line->batch)) {
2226 $tooltiptext .= '<br><b>'.$langs->trans("LotSerial
").'</b> : '.$line->batch.'<br>';
2228 if (!empty($line->fk_warehouse)) {
2229 $tooltiptext .= '<b>'.$langs->trans("Warehouse
").'</b> : '.$line->fk_warehouse.'<br>';
2231 if ($line->product_label != $line->desc) {
2233 $tooltiptext .= '<br>';
2235 $tooltiptext .= $line->desc;
2238 if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
2239 $htmlforlines .= $form->textwithpicto($line->product_label ? '<b>' . $line->product_ref . '</b> - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
2240 } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) {
2241 $htmlforlines .= $form->textwithpicto($line->product_ref ? '<b>'.$line->product_ref.'<b>' : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
2243 $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
2246 if ($line->product_ref) {
2247 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
2248 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
2250 if (!empty($line->batch)) {
2251 $tooltiptext .= '<br><b>'.$langs->trans("LotSerial
").'</b> : '.$line->batch.'<br>';
2253 if (!empty($line->fk_warehouse)) {
2254 $tooltiptext .= '<b>'.$langs->trans("Warehouse
").'</b> : '.$line->fk_warehouse.'<br>';
2257 if ($line->product_label) {
2258 $htmlforlines .= $line->product_label;
2260 if ($line->product_label != $line->desc) {
2261 if ($line->product_label && $line->desc) {
2262 $htmlforlines .= '<br>';
2264 $firstline = dolGetFirstLineOfText($line->desc, getDolGlobalInt('TAKEPOS_SHOW_N_FIRST_LINES'));
2265 if ($firstline != $line->desc) {
2266 $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
2268 $htmlforlines .= $line->desc;
2272 if (!empty($line->array_options['options_order_notes'])) {
2273 $htmlforlines .= "<br>(
".$line->array_options['options_order_notes'].")
";
2275 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
2276 $htmlforlines .= '</td><td class="right phonetable
"><button type="button" onclick="SetQty(place,
'.$line->rowid.',
'.($line->qty - 1).');
" class="publicphonebutton2 phonered
">-</button> <button type="button" onclick="SetQty(place,
'.$line->rowid.',
'.($line->qty + 1).');
" class="publicphonebutton2 phonegreen
">+</button>';
2278 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2279 // Set the content of tooltip
2281 $moreinfo .= $langs->trans("VATRate
").': '.price($line->tva_tx).' %<br>';
2282 $moreinfo .= $langs->trans("UnitPrice
").': '.price($line->subprice).'<br>';
2283 $moreinfo .= '<br>';
2284 $moreinfo .= $langs->transcountry("TotalHT
", $mysoc->country_code).': '.price($line->total_ht);
2285 if ($line->vat_src_code) {
2286 $moreinfo .= '<br>'.$langs->trans("VATCode
").': '.$line->vat_src_code;
2288 $moreinfo .= '<br>'.$langs->trans("TotalVAT
").': '.price($line->total_tva);
2289 if ($mysoc->useLocalTax(1, 1, $mysoc)) {
2290 $moreinfo .= '<br>'.$langs->transcountry("TotalLT1
", $mysoc->country_code).': '.price($line->total_localtax1);
2292 if ($mysoc->useLocalTax(2, 1, $mysoc)) {
2293 $moreinfo .= '<br>'.$langs->transcountry("TotalLT2
", $mysoc->country_code).': '.price($line->total_localtax2);
2295 $moreinfo .= '<hr>';
2296 $moreinfo .= $langs->transcountry("TotalTTC
", $mysoc->country_code).': '.price($line->total_ttc);
2297 //$moreinfo .= $langs->trans("TotalHT
").': '.$line->total_ht;
2298 if ($line->date_start || $line->date_end) {
2299 $htmlforlines .= '<br><div class="clearboth nowraponall
">'.get_date_range($line->date_start, $line->date_end).'</div>';
2301 $htmlforlines .= '</td>';
2303 // complete line by hook
2304 $parameters = array('line' => $line);
2305 $reshook = $hookmanager->executeHooks('completeTakePosInvoiceLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
2307 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2309 $htmlforlines .= $hookmanager->resPrint;
2311 if (getDolGlobalInt("TAKEPOS_SHOW_SUBPRICE
")) {
2312 $htmlforlines .= '<td class="right
">'.price($line->subprice).'</td>';
2314 $htmlforlines .= '<td class="right
">'.vatrate(price2num($line->remise_percent), true).'</td>';
2315 $htmlforlines .= '<td class="right
">';
2316 $htmlforlines .= $line->qty;
2317 if (isModEnabled('stock') && $user->hasRight('stock', 'mouvement', 'lire')) {
2318 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
2319 if (getDolGlobalString($constantforkey) && $line->fk_product > 0 && !getDolGlobalString('TAKEPOS_HIDE_STOCK_ON_LINE')) {
2320 $productChildrenNb = 0;
2321 if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
2322 if (empty($line->product) || !($line->product->id > 0)) {
2323 $line->fetch_product();
2325 if (!empty($line->product)) {
2326 $productChildrenNb = $line->product->hasFatherOrChild(1);
2329 if ($productChildrenNb == 0) {
2330 $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp
";
2331 $sql .= " FROM
".MAIN_DB_PREFIX."entrepot as e,
";
2332 $sql .= " ".MAIN_DB_PREFIX."product_stock as ps
";
2333 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product
";
2334 $sql .= " WHERE ps.reel != 0
";
2335 $sql .= " AND ps.fk_entrepot =
".((int) getDolGlobalString($constantforkey));
2336 $sql .= " AND e.entity IN (
".getEntity('stock').")
";
2337 $sql .= " AND ps.fk_product =
".((int) $line->fk_product);
2338 $resql = $db->query($sql);
2341 $obj = $db->fetch_object($resql);
2343 $stock_real = price2num($obj->reel, 'MS');
2345 $htmlforlines .= ' ';
2346 $htmlforlines .= '<span class="opacitylow
" title="'.$langs->trans("Stock").' '.price($stock_real, 1, '', 1, 0).'">';
2347 $htmlforlines .= '(';
2348 if ($line->qty && $line->qty > $stock_real) {
2349 $htmlforlines .= '<span style="color: var(--amountremaintopaycolor)
">';
2351 $htmlforlines .= img_picto('', 'stock', 'class="pictofixedwidth
"').price($stock_real, 1, '', 1, 0);
2352 if ($line->qty && $line->qty > $stock_real) {
2353 $htmlforlines .= "</span>
";
2355 $htmlforlines .= ')';
2356 $htmlforlines .= '</span>';
2358 dol_print_error($db);
2364 $htmlforlines .= '</td>';
2365 if (getDolGlobalInt('TAKEPOS_SHOW_HT')) {
2366 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
2367 $htmlforlines .= price($line->total_ht, 1, '', 1, -1, -1, $conf->currency);
2368 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
2369 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
2370 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
2371 $multicurrency = new MultiCurrency($db);
2372 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
2373 $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>';
2375 $htmlforlines .= '</td>';
2377 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
2378 $htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency);
2379 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
2380 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
2381 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
2382 $multicurrency = new MultiCurrency($db);
2383 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
2384 $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>';
2386 $htmlforlines .= '</td>';
2388 $htmlforlines .= '</tr>'."\n
";
2389 $htmlforlines .= empty($htmlsupplements[$line->id]) ? '' : $htmlsupplements[$line->id];
2391 print $htmlforlines;
2394 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td>';
2395 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2396 print '<td></td><td></td>';
2397 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
2403} else { // No invoice generated yet
2404 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td>';
2405 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2406 print '<td></td><td></td>';
2407 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
2420if ($action == "search
") {
2422 <input type="text
" id="search
" class="input-nobottom
" name="search
" onkeyup="Search2(\
'\',
null);
" style="width: 80%; font-size: 150%;
" placeholder="'.dol_escape_htmltag($langs->trans('Search
')).'">
2429if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2430 print '</body></html>';
if(! $sortfield) if(! $sortorder) $object
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 stock movements.
Class to manage payments of customer invoices.
Class to manage products or services.
Manage record for batch number management.
Class to manage third parties objects (customers, suppliers, prospects...)
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formatted error messages to output (Used to show messages on html output).
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular VAT rate, when selling a product with vat $vatrate,...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
treeview li table
No Email.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
if(empty( $takeposterminal)) fail($message)
Abort invoice creation with a given error message.