34if (!defined(
'NOTOKENRENEWAL')) {
35 define(
'NOTOKENRENEWAL',
'1');
37if (!defined(
'NOREQUIREMENU')) {
38 define(
'NOREQUIREMENU',
'1');
40if (!defined(
'NOREQUIREHTML')) {
41 define(
'NOREQUIREHTML',
'1');
43if (!defined(
'NOREQUIREAJAX')) {
44 define(
'NOREQUIREAJAX',
'1');
48if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
49 require
'../main.inc.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
65$hookmanager->initHooks(array(
'takeposinvoice'));
67$langs->loadLangs(array(
"companies",
"commercial",
"bills",
"cashdesk",
"stocks",
"banks"));
69$action =
GETPOST(
'action',
'aZ09');
73$mobilepage =
GETPOST(
'mobilepage',
'alpha');
78if (!$user->hasRight(
'takepos',
'run') && !defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
82if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
84 if ($_SESSION[
"takeposterminal"] ==
"") {
86 $_SESSION[
"takeposterminal"] = 1;
88 header(
"Location: ".DOL_URL_ROOT.
"/takepos/index.php");
95$takeposterminal = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'';
98if (empty($takeposterminal)) {
100 $_SESSION[
"takeposterminal"] = 1;
101 $takeposterminal = 1;
102 } elseif (!empty($_COOKIE[
"takeposterminal"])) {
103 $_SESSION[
"takeposterminal"] = preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $_COOKIE[
"takeposterminal"]);
104 $takeposterminal = $_SESSION[
"takeposterminal"];
107<script language=
"javascript">
108 $( document ).ready(
function() {
109 ModalBox(
'ModalTerminal');
126 header($_SERVER[
'SERVER_PROTOCOL'].
' 500 Internal Server Error',
true, 500);
137function takeposDeleteLineWithChildren($invoice, $lineid)
139 $lineid = (int) $lineid;
144 $childrenbyparent = array();
145 if (is_array($invoice->lines)) {
146 foreach ($invoice->lines as $line) {
147 $parentid = (int) $line->fk_parent_line;
149 $childrenbyparent[$parentid][] = (int) $line->id;
154 $linestodelete = array();
155 $stack = array($lineid);
156 while (!empty($stack)) {
157 $currentlineid = array_pop($stack);
158 if (in_array($currentlineid, $linestodelete,
true)) {
162 $linestodelete[] = $currentlineid;
163 if (!empty($childrenbyparent[$currentlineid])) {
164 foreach ($childrenbyparent[$currentlineid] as $childlineid) {
165 $stack[] = $childlineid;
171 foreach (array_reverse($linestodelete) as $deletelineid) {
172 $result = $invoice->deleteLine($deletelineid);
183$number = (float)
GETPOST(
'number',
'alpha');
186$desc =
GETPOST(
'desc',
'alphanohtml');
199if ($pay ==
'cheque') {
206 $sql =
"SELECT id, code FROM ".MAIN_DB_PREFIX.
"c_paiement";
207 $sql .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
208 $sql .=
" AND code = '".$db->escape($paycode).
"'";
209 $resql =
$db->query($sql);
211 $obj =
$db->fetch_object($resql);
213 $paiementid = $obj->id;
220 $ret = $invoice->fetch($invoiceid);
222 $ret = $invoice->fetch(0,
'(PROV-POS'.$takeposterminal.
'-'.$place.
')');
225 $placeid = $invoice->id;
228$constforcompanyid =
'CASHDESK_ID_THIRDPARTY'.$takeposterminal;
231if ($invoice->socid > 0) {
232 $soc->fetch($invoice->socid);
239 $invoice->fk_project =
getDolGlobalInt(
"CASHDESK_ID_PROJECT".$takeposterminal);
243if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"])) {
244 if ($invoice->multicurrency_code != $_SESSION[
"takeposcustomercurrency"]) {
245 $invoice->setMulticurrencyCode($_SESSION[
"takeposcustomercurrency"]);
249$term = empty($_SESSION[
"takeposterminal"]) ? 1 : $_SESSION[
"takeposterminal"];
256$parameters = array();
257$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $invoice, $action);
263$sectionwithinvoicelink =
'';
264$CUSTOMER_DISPLAY_line1 =
'';
265$CUSTOMER_DISPLAY_line2 =
'';
274if (in_array($action, array(
'deleteline',
'updateqty',
'updateprice',
'updatereduction',
'update_reduction_global')) && !$user->hasRight(
'takepos',
'editlines')) {
280if (empty($reshook)) {
284 $sql =
"SELECT MIN(ref) as firstref FROM ".MAIN_DB_PREFIX.
"pos_cash_fence";
285 $sql .=
" WHERE entity = ".((int)
$conf->entity);
286 $sql .=
" AND posnumber = ".((int) $takeposterminal);
287 $sql .=
" AND year_close = ".((int) $tmpcurrentday[
'year']);
289 $sql .=
" (month_close IS NULL AND day_close IS NULL)";
290 $sql .=
" OR (month_close = ".((int) $tmpcurrentday[
'mon']).
" AND day_close IS NULL)";
291 $sql .=
" OR (month_close = ".((int) $tmpcurrentday[
'mon']).
" AND day_close = ".((int) $tmpcurrentday[
'mday']).
")";
293 $sql .=
" AND status = 1";
296 $resql =
$db->query($sql);
298 $obj =
$db->fetch_object($resql);
300 $refcashcontrol = $obj->firstref;
304 if ($refcashcontrol) {
306 $langs->load(
'errors');
307 dol_htmloutput_errors($langs->trans(
"ACashControlHasBeenclosedForCurrentDay", $refcashcontrol), [], 1);
312 if ($action ==
'valid' && $user->hasRight(
'facture',
'creer')) {
320 $bankaccount =
getDolGlobalInt(
'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION[
"takeposterminal"]);
321 } elseif ($pay ==
"CHQ") {
322 $bankaccount =
getDolGlobalInt(
'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION[
"takeposterminal"]);
324 $accountname =
"CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION[
"takeposterminal"];
329 if ($bankaccount <= 0 && $pay !=
"delayed" &&
isModEnabled(
"bank")) {
330 $errormsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount"));
338 $invoice->fetch($placeid);
340 $invoice->oldcopy =
dol_clone($invoice, 2);
344 if ($invoice->total_ttc < 0) {
345 $invoice->type = $invoice::TYPE_CREDIT_NOTE;
347 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
348 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
349 $sql .=
" AND fk_soc = ".((int) $invoice->socid);
350 $sql .=
" AND type <> ".Facture::TYPE_CREDIT_NOTE;
351 $sql .=
" AND fk_statut >= ".$invoice::STATUS_VALIDATED;
352 $sql .=
" ORDER BY rowid DESC";
355 $resql =
$db->query($sql);
357 $obj =
$db->fetch_object($resql);
358 $fk_source = $obj->rowid;
359 if ((
int) $fk_source == 0) {
360 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
363 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
365 $invoice->fk_facture_source = $fk_source;
366 $invoice->update($user);
369 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
376 $remaintopay = $invoice->getRemainToPay();
383 } elseif (count($invoice->lines) == 0) {
392 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
394 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
395 dol_syslog(
"Validate invoice with stock change. Warehouse defined into constant ".$constantforkey.
" = ".
getDolGlobalString($constantforkey));
400 $res = $invoice->validate($user,
'',
getDolGlobalInt($constantforkey), 0, $batch_rule);
403 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
406 dol_syslog(
"Call validate on invoice ".$invoice->ref, LOG_DEBUG);
407 $res = $invoice->validate($user);
410 $langs->load(
"admin");
411 dol_htmloutput_errors($invoice->error ==
'NotConfigured' ? $langs->trans(
"NotConfigured").
' (TakePos numbering module)' : $invoice->error, $invoice->errors, 1);
416 if (!$error && $res >= 0) {
417 $remaintopay = $invoice->getRemainToPay();
422 $payment->datepaye = $now;
423 $payment->fk_account = $bankaccount;
428 $payment->amounts[$invoice->id] = $amountofpayment;
431 if ($amountofpayment <= 0 || $amountofpayment > $remaintopay) {
432 $payment->amounts[$invoice->id] = $remaintopay;
436 $payment->paiementid = $paiementid;
437 $payment->paiementcode = $paycode;
438 $payment->num_payment =
'';
440 if ($pay !=
"delayed") {
441 $res = $payment->create($user);
448 if (!empty($payment->warnings)) {
452 $res = $payment->addPaymentToBank($user,
'payment',
'(CustomerInvoicePayment)', $bankaccount,
'',
'');
455 dol_htmloutput_mesg($langs->trans(
'ErrorNoPaymentDefined').
' '.$payment->error, $payment->errors,
'error', 1);
458 $remaintopay = $invoice->getRemainToPay();
464 if ($remaintopay == 0) {
465 dol_syslog(
"Invoice is paid, so we set it to status Paid");
466 $result = $invoice->setPaid($user);
469 $invoice->status = $invoice::STATUS_CLOSED;
470 $invoice->close_code =
'';
473 $invoice->setPaymentMethods($paiementid);
475 dol_syslog(
"Invoice is not paid, remain to pay = ".$remaintopay);
484 if (!$error && $res >= 0) {
487 dol_syslog(
"Now we record the stock movement for each qualified line");
490 require_once DOL_DOCUMENT_ROOT .
"/product/stock/class/mouvementstock.class.php";
491 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
494 $labeltakeposmovement =
'TakePOS - '.$langs->trans(
"Invoice").
' '.$invoice->ref;
496 foreach ($invoice->lines as $line) {
498 $warehouseid = ($line->fk_warehouse ? $line->fk_warehouse :
getDolGlobalInt($constantforkey));
501 if ($line->batch !=
'' && $warehouseid > 0) {
503 $prod_batch->find(0,
'',
'', $line->batch, $warehouseid, (
int) $line->fk_product);
506 $mouvP->setOrigin($invoice->element, $invoice->id);
509 $res = $mouvP->reception($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'', $line->batch,
'', 0, $inventorycode);
511 $res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'', $prod_batch->batch, $prod_batch->id, $inventorycode);
520 $mouvP->setOrigin($invoice->element, $invoice->id);
523 $res = $mouvP->reception($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'',
'', 0, $inventorycode);
525 $res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'',
'', 0, $inventorycode);
537 if (!$error && $res >= 0) {
540 $invoice->ref = $invoice->oldcopy->ref;
541 $invoice->paye = $invoice->oldcopy->paye;
542 $invoice->status = $invoice->oldcopy->status;
543 $invoice->statut = $invoice->oldcopy->statut;
550 if ($action ==
'creditnote' && $user->hasRight(
'facture',
'creer')) {
554 $creditnote->socid = $invoice->socid;
556 $creditnote->module_source =
'takepos';
557 $creditnote->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
559 $creditnote->fk_facture_source = $placeid;
561 $creditnote->create($user);
565 foreach ($invoice->lines as $line) {
567 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
572 if (!empty($invoice->situation_counter)) {
573 $source_fk_prev_id = $line->fk_prev_id;
574 $line->fk_prev_id = $line->id;
575 if (!empty($invoice->tab_previous_situation_invoice)) {
578 $tab_jumped_credit_notes = array();
579 $lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
580 $searchPreviousInvoice =
true;
581 while ($searchPreviousInvoice) {
582 if ($invoice->tab_previous_situation_invoice[$lineIndex]->situation_cycle_ref || $lineIndex < 1) {
583 $searchPreviousInvoice =
false;
587 $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id;
593 $maxPrevSituationPercent = 0;
594 foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
595 if ($prevLine->id == $source_fk_prev_id) {
596 $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
599 $line->total_ht -= $prevLine->total_ht;
600 $line->total_tva -= $prevLine->total_tva;
601 $line->total_ttc -= $prevLine->total_ttc;
602 $line->total_localtax1 -= $prevLine->total_localtax1;
603 $line->total_localtax2 -= $prevLine->total_localtax2;
605 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
606 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
607 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
608 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
613 $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
618 $maxPrevSituationPercent = 0;
619 foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
620 foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) {
621 if ($prevLine->fk_prev_id == $source_fk_prev_id) {
622 $maxPrevSituationPercent = $prevLine->situation_percent;
624 $line->total_ht -= $prevLine->total_ht;
625 $line->total_tva -= $prevLine->total_tva;
626 $line->total_ttc -= $prevLine->total_ttc;
627 $line->total_localtax1 -= $prevLine->total_localtax1;
628 $line->total_localtax2 -= $prevLine->total_localtax2;
630 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
631 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
632 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
633 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
639 $line->situation_percent += $maxPrevSituationPercent;
647 $line->fk_facture = $creditnote->id;
648 $line->fk_parent_line = $fk_parent_line;
650 $line->subprice = -$line->subprice;
652 $line->total_ht = -$line->total_ht;
653 $line->total_tva = -$line->total_tva;
654 $line->total_ttc = -$line->total_ttc;
655 $line->total_localtax1 = -$line->total_localtax1;
656 $line->total_localtax2 = -$line->total_localtax2;
658 $line->multicurrency_subprice = -$line->multicurrency_subprice;
659 $line->multicurrency_total_ht = -$line->multicurrency_total_ht;
660 $line->multicurrency_total_tva = -$line->multicurrency_total_tva;
661 $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
663 $result = $line->insert(0, 1);
665 $creditnote->lines[] = $line;
668 if ($result > 0 && $line->product_type == 9) {
669 $fk_parent_line = $result;
672 $creditnote->update_price(1);
680 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
685 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
687 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
690 dol_syslog(
"Validate invoice with stock change into warehouse defined into constant ".$constantforkey.
" = ".
getDolGlobalString($constantforkey).
" or warehouseid= ".$warehouseid.
" if defined.");
693 $res = $creditnote->validate($user,
'', $warehouseid, 0, $batch_rule);
700 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
702 $res = $creditnote->validate($user);
706 if (!$error && $res >= 0) {
708 dol_syslog(
"Now we record the stock movement for each qualified line");
710 require_once DOL_DOCUMENT_ROOT .
"/product/stock/class/mouvementstock.class.php";
711 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
713 $labeltakeposmovement =
'TakePOS - '.$langs->trans(
"CreditNote").
' '.$creditnote->ref;
715 foreach ($creditnote->lines as $line) {
717 $warehouseid = ($line->fk_warehouse ? $line->fk_warehouse :
getDolGlobalInt($constantforkey));
720 $mouvP->setOrigin($creditnote->element, $creditnote->id);
722 $batch_to_use = ($line->batch !=
'' && $warehouseid > 0) ? $line->batch :
'';
724 $res = $mouvP->reception($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'', $batch_to_use,
'', 0, $inventorycode);
737 $creditnote->id = $placeid;
742 if (($action ==
'history' || $action ==
'creditnote') && $user->hasRight(
'takepos',
'run')) {
743 if ($action ==
'creditnote' && $creditnote !==
null && $creditnote->id > 0) {
744 $placeid = $creditnote->id;
750 $invoice->fetch($placeid);
754 if (($action ==
"addline" || $action ==
"freezone") && $placeid == 0 && ($user->hasRight(
'takepos',
'run') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
757 $dolnowtzuserrel =
dol_now(
'tzuserrel');
761 $dateinvoice =
dol_mktime(0, 0, 0, (
int) $monthuser, (
int) $dayuser, (
int) $yearuser,
'tzserver');
763 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
764 $invoice->date = $dateinvoice;
778 $invoice->module_source =
'takepos';
779 $invoice->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
780 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] :
$conf->entity;
782 if ($invoice->socid <= 0) {
783 $langs->load(
'errors');
789 $placeid = $invoice->create($user);
795 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture";
796 $sql .=
" SET ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
797 $sql .=
" WHERE rowid = ".((int) $placeid);
798 $resql =
$db->query($sql);
814 if ($action ==
"addline" && ($user->hasRight(
'takepos',
'run') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
816 $prod->fetch($idproduct);
819 $customer->fetch($invoice->socid);
821 $datapriceofproduct =
$prod->getSellPrice(
$mysoc, $customer, 0);
824 $price = $datapriceofproduct[
'pu_ht'];
825 $price_ttc = $datapriceofproduct[
'pu_ttc'];
827 $price_base_type = empty($datapriceofproduct[
'price_base_type']) ?
'HT' : $datapriceofproduct[
'price_base_type'];
828 $tva_tx = $datapriceofproduct[
'tva_tx'];
829 $tva_npr = (int) $datapriceofproduct[
'tva_npr'];
837 $batch =
GETPOST(
'batch',
'alpha');
839 if (!empty($batch)) {
840 $action =
"setbatch";
841 } elseif (
$prod->status_batch > 0) {
846 $prod->load_stock(
'warehouseopen');
848 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
852 foreach (
$prod->stock_warehouse as $tmpwarehouseid => $tmpval) {
857 if (!empty(
$prod->stock_warehouse[$tmpwarehouseid]) && is_array(
$prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
858 if (is_object(
$prod->stock_warehouse[$tmpwarehouseid]) && count(
$prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
859 foreach (
$prod->stock_warehouse[$tmpwarehouseid]->detail_batch as $dbatch) {
868 echo
"function addbatch(batch, warehouseid) {\n";
869 echo
"console.log('We add batch '+batch+' from warehouse id '+warehouseid);\n";
870 echo
'$("#poslines").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?action=addline&batch="+encodeURI(batch)+"&warehouseid="+warehouseid+"&place='.$place.
'&idproduct='.$idproduct.
'&token='.
newToken().
'", function() {});'.
"\n";
875 echo
"<center>".$langs->trans(
"SearchIntoBatch").
": <b> $nbofsuggested </b></center><br><table>";
876 foreach (
$prod->stock_warehouse as $tmpwarehouseid => $tmpval) {
881 if (!empty(
$prod->stock_warehouse[$tmpwarehouseid]) && is_array(
$prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
882 foreach (
$prod->stock_warehouse[$tmpwarehouseid]->detail_batch as $dbatch) {
883 $batchStock = + $dbatch->qty;
884 $quantityToBeDelivered = 1;
885 $deliverableQty = min($quantityToBeDelivered, $batchStock);
887 print
'<!-- subj='.$suggestednb.
'/'.$nbofsuggested.
' -->';
888 print
'<!-- Show details of lot/serial in warehouseid='.$tmpwarehouseid.
' -->';
889 print
'<td class="left">';
891 $detail .=
'<span class="opacitymedium">'.$langs->trans(
"LotSerial").
':</span> '.$dbatch->batch;
898 $detail .=
'</td><td>';
899 $detail .=
'<span class="opacitymedium">'.$langs->trans(
"Qty").
':</span> '.$dbatch->qty;
900 $detail .=
'</td><td>';
901 $detail .=
' <button class="marginleftonly" onclick="addbatch(\''.dol_escape_js($dbatch->batch).
'\',
'.$tmpwarehouseid.')
">'.$langs->trans("Select
")."</
button>
";
905 $quantityToBeDelivered -= $deliverableQty;
906 if ($quantityToBeDelivered < 0) {
907 $quantityToBeDelivered = 0;
916 print '</body></html>';
922 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
923 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
924 $cat = new Categorie($db);
925 $categories = $cat->containing($idproduct, 'product');
926 $found = (array_search(getDolGlobalInt('TAKEPOS_SUPPLEMENTS_CATEGORY'), array_column($categories, 'id')));
927 if ($found !== false) { // If this product is a supplement
928 $sql = "SELECT fk_parent_line FROM
".MAIN_DB_PREFIX."facturedet where rowid =
".((int) $selectedline);
929 $resql = $db->query($sql);
930 $row = $db->fetch_array($resql);
931 if ($row[0] == null) {
932 $parent_line = $selectedline;
934 $parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product
940 // Group if enabled. Skip group if line already sent to the printer
941 if (getDolGlobalString('TAKEPOS_GROUP_SAME_PRODUCT')) {
942 foreach ($invoice->lines as $line) {
943 if ($line->product_ref == $prod->ref) {
944 if ($line->special_code == 4) {
946 } // If this line is sended to printer create new line
947 // check if qty in stock
948 if (getDolGlobalString('TAKEPOS_QTY_IN_STOCK') && (($line->qty + $qty) > $prod->stock_reel)) {
949 $invoice->error = $langs->trans("ErrorStockIsNotEnough
");
950 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
954 $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);
956 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
958 $idoflineadded = $line->id;
964 if ($idoflineadded <= 0 && empty($err)) {
965 $invoice->fetch_thirdparty();
966 $array_options = array();
968 $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);
970 /* setup of margin calculation */
971 if (getDolGlobalString('MARGIN_TYPE')) {
972 if (getDolGlobalString('MARGIN_TYPE') == 'pmp' && !empty($prod->pmp)) {
973 $line['fk_fournprice'] = null;
974 $line['pa_ht'] = $prod->pmp;
975 } elseif (getDolGlobalString('MARGIN_TYPE') == 'costprice' && !empty($prod->cost_price)) {
976 $line['fk_fournprice'] = null;
977 $line['pa_ht'] = $prod->cost_price;
979 // default is fournprice
980 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
981 $pf = new ProductFournisseur($db);
982 if ($pf->find_min_price_product_fournisseur($idproduct, $qty) > 0) {
983 $line['fk_fournprice'] = $pf->product_fourn_price_id;
984 $line['pa_ht'] = $pf->fourn_unitprice_with_discount;
985 if (getDolGlobalString('PRODUCT_CHARGES') && $pf->fourn_charges > 0) {
986 $line['pa_ht'] += (float) $pf->fourn_charges / $pf->fourn_qty;
992 // complete line by hook
993 $parameters = array('prod' => $prod, 'line' => $line);
994 $reshook = $hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action); // Note that $action and $line may have been modified by some hooks
996 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1000 if (empty($reshook)) {
1001 if (!empty($hookmanager->resArray)) {
1002 $line = $hookmanager->resArray;
1005 // check if qty in stock
1006 if (getDolGlobalString('TAKEPOS_QTY_IN_STOCK') && $qty > $prod->stock_reel) {
1007 $invoice->error = $langs->trans("ErrorStockIsNotEnough
");
1008 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
1013 $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);
1017 if (getDolGlobalString('TAKEPOS_CUSTOMER_DISPLAY')) {
1018 $CUSTOMER_DISPLAY_line1 = $prod->label;
1019 $CUSTOMER_DISPLAY_line2 = price($price_ttc);
1023 $invoice->fetch($placeid);
1026 // If we add a line by submitting freezone form (invoice exists here because it was created just before if it didn't exist)
1027 if ($action == "freezone
" && $user->hasRight('takepos', 'run')) {
1028 $customer = new Societe($db);
1029 $customer->fetch($invoice->socid);
1031 $tva_tx = GETPOST('tva_tx', 'alpha');
1032 if ($tva_tx != '') {
1033 if (!preg_match('/\((.*)\)/', $tva_tx)) {
1034 $tva_tx = price2num($tva_tx);
1037 $tva_tx = get_default_tva($mysoc, $customer);
1041 $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
1042 $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
1044 $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);
1046 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
1048 $invoice->fetch($placeid);
1051 if ($action == "addnote
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1052 $desc = GETPOST('addnote', 'alpha');
1054 $invoice->update_note($desc, '_public');
1056 foreach ($invoice->lines as $line) {
1057 if ($line->id == $idline) {
1058 $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);
1062 $invoice->fetch($placeid);
1065 if ($action == "deleteline
" && ($user->hasRight('takepos', 'editlines') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1067 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1068 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1069 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1070 $permissiontoupdateline = true;
1071 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1072 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1077 if ($idline > 0 && $placeid > 0) { // If invoice exists and a line is selected.
1078 $result = takeposDeleteLineWithChildren($invoice, $idline);
1080 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
1082 $invoice->fetch($placeid);
1083 } 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.
1084 $sql = "SELECT rowid FROM
".MAIN_DB_PREFIX."facturedet where fk_facture =
".((int) $placeid)." ORDER BY rowid DESC
";
1085 $resql = $db->query($sql);
1086 $obj = $db->fetch_object($resql);
1088 $deletelineid = $obj->rowid;
1089 $result = takeposDeleteLineWithChildren($invoice, $deletelineid);
1091 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
1094 $invoice->fetch($placeid);
1099 if (count($invoice->lines) == 0) {
1100 // Keep an empty draft invoice alive when a non-default customer was
1101 // already attached so deleting the last line does not silently lose
1102 // the customer that was just selected (#38219). Only drop the invoice
1103 // when it is still on the default cashdesk thirdparty (or none).
1104 $defaultsocid = (int) getDolGlobalString('CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal
"]);
1105 $invoicesocid = (int) $invoice->socid;
1106 if ($invoicesocid === 0 || $invoicesocid === $defaultsocid) {
1107 $invoice->delete($user);
1109 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1110 header("Location:
".DOL_URL_ROOT."/takepos/public/auto_order.php
");
1112 header("Location:
".DOL_URL_ROOT."/takepos/invoice.php
");
1119 // Action to delete or discard an invoice
1120 if ($action == "delete
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1121 // $placeid is the invoice id (it differs from place) and is defined if the place is set and
1122 // the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal
"].'-'.$place.')', so the fetch at beginning of page works.
1124 $result = $invoice->fetch($placeid);
1126 if ($result > 0 && $invoice->status == Facture::STATUS_DRAFT) {
1129 // We delete the lines
1130 $resdeletelines = 1;
1131 foreach ($invoice->lines as $line) {
1132 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1133 $tmpres = $invoice->deleteLine($line->id);
1135 $resdeletelines = 0;
1140 $sql = "UPDATE
".MAIN_DB_PREFIX."facture
";
1141 $varforconst = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal
"];
1142 $sql .= " SET fk_soc =
".((int) getDolGlobalString($varforconst)).",
";
1143 $sql .= " datec =
'".$db->idate(dol_now())."'";
1144 $sql .= " WHERE entity IN (
".getEntity('invoice').")
";
1145 $sql .= " AND
ref =
'(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'";
1146 $resql1 = $db->query($sql);
1148 if ($resdeletelines && $resql1) {
1154 $invoice->fetch($placeid);
1159 // Action to fully remove (discard) the current sale: delete the draft invoice so its tab disappears
1160 // (the "delete
" action above only empties and resets the cart).
1161 if ($action == "discardsale
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1163 $result = $invoice->fetch($placeid);
1164 if ($result > 0 && $invoice->status == Facture::STATUS_DRAFT) {
1165 $invoice->delete($user);
1171 if ($action == "updateqty
") { // Test on permission is done later
1172 foreach ($invoice->lines as $line) {
1173 if ($line->id == $idline) {
1174 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1175 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1176 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1177 $permissiontoupdateline = true;
1178 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1179 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1182 if (!$permissiontoupdateline) {
1183 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
").' - No permission to updateqty', [], 1);
1186 $result = takeposDeleteLineWithChildren($invoice, $line->id);
1188 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
1191 $vatratecode = $line->tva_tx;
1192 if ($line->vat_src_code) {
1193 $vatratecode .= ' ('.$line->vat_src_code.')';
1196 $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);
1202 $invoice->fetch($placeid);
1205 if ($action == "updateprice
") { // Test on permission is done later
1206 $customer = new Societe($db);
1207 $customer->fetch($invoice->socid);
1209 foreach ($invoice->lines as $line) {
1210 if ($line->id == $idline) {
1211 $prod = new Product($db);
1212 $prod->fetch($line->fk_product);
1213 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
1214 $price_min = $datapriceofproduct['price_min'];
1215 $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS'));
1217 $vatratecleaned = $line->tva_tx;
1219 if (preg_match('/^(.*)\s*\((.*)\)$/', (string) $line->tva_tx, $reg)) { // If vat is "xx (yy)
"
1220 $vatratecleaned = trim($reg[1]);
1221 //$vatratecode = $reg[2];
1224 $pu_ht = price2num((float) price2num($number, 'MU') / (1 + ((float) $vatratecleaned / 100)), 'MU');
1226 if ($usercanproductignorepricemin && (!empty($price_min) && ((float) price2num($pu_ht) * (1 - (float) price2num($line->remise_percent) / 100) < price2num($price_min)))) {
1227 $langs->load("products
");
1228 dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice
", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
1229 // echo $langs->trans("CantBeLessThanMinPrice
");
1231 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1232 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1233 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1234 $permissiontoupdateline = true;
1235 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1236 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1240 $vatratecode = $line->tva_tx;
1241 if ($line->vat_src_code) {
1242 $vatratecode .= ' ('.$line->vat_src_code.')';
1245 if (!$permissiontoupdateline) {
1246 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
").' - No permission to updateprice', [], 1);
1247 } elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) {
1248 $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);
1250 $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);
1257 $invoice->fetch($placeid);
1260 if ($action == "updatereduction
") { // Test on permission is done later
1261 $customer = new Societe($db);
1262 $customer->fetch($invoice->socid);
1264 foreach ($invoice->lines as $line) {
1265 if ($line->id == $idline) {
1266 dol_syslog("updatereduction Process line
".$line->id.' to apply discount of '.$number.'%');
1268 $prod = new Product($db);
1269 $prod->fetch($line->fk_product);
1271 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
1272 $price_min = $datapriceofproduct['price_min'];
1273 $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS'));
1275 $pu_ht = price2num($line->subprice / (1 + ($line->tva_tx / 100)), 'MU');
1278 if ($usercanproductignorepricemin && (!empty($price_min) && ((float) price2num($line->subprice) * (1 - (float) price2num($number) / 100) < (float) price2num($price_min)))) {
1279 $langs->load("products
");
1280 dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice
", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
1282 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1283 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1284 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1285 $permissiontoupdateline = true;
1286 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1287 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1290 if (!$permissiontoupdateline) {
1291 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
"), [], 1);
1293 $vatratecode = $line->tva_tx;
1294 if ($line->vat_src_code) {
1295 $vatratecode .= ' ('.$line->vat_src_code.')';
1297 $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);
1304 $invoice->fetch($placeid);
1305 } elseif ($action == 'update_reduction_global' && $user->hasRight('takepos', 'editlines')) {
1306 foreach ($invoice->lines as $line) {
1307 $vatratecode = $line->tva_tx;
1308 if ($line->vat_src_code) {
1309 $vatratecode .= ' ('.$line->vat_src_code.')';
1311 $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);
1314 $invoice->fetch($placeid);
1317 if ($action == "setbatch
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1318 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
1319 $warehouseid = (GETPOSTINT('warehouseid') > 0 ? GETPOSTINT('warehouseid') : getDolGlobalInt($constantforkey)); // Get the warehouse id from GETPOSTINT('warehouseid'), otherwise use default setup.
1320 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet SET batch =
'".$db->escape($batch)."', fk_warehouse =
".((int) $warehouseid);
1321 $sql .= " WHERE rowid =
".((int) $idoflineadded);
1325 if ($action == "order
" && $placeid != 0 && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1326 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1327 if ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1328 require_once DOL_DOCUMENT_ROOT.'/takepos/class/dolreceiptprinter.class.php';
1329 $printer = new dolReceiptPrinter($db);
1332 $sql = "SELECT label FROM
".MAIN_DB_PREFIX."takepos_floor_tables where rowid =
".((int) $place);
1333 $resql = $db->query($sql);
1334 $row = $db->fetch_object($resql);
1335 $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>';
1336 $footerorder = '</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>';
1337 $order_receipt_printer1 = "";
1338 $order_receipt_printer2 = "";
1339 $order_receipt_printer3 = "";
1340 $catsprinter1 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_1'));
1341 $catsprinter2 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_2'));
1342 $catsprinter3 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_3'));
1344 foreach ($invoice->lines as $line) {
1345 if ($line->special_code == "4
") {
1348 $c = new Categorie($db);
1349 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1350 $result = array_intersect($catsprinter1, $existing);
1351 $count = count($result);
1352 if (!$line->fk_product) {
1353 $count++; // Print Free-text item (Unassigned printer) to Printer 1
1357 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet set special_code=
'1' where rowid =
".((int) $line->id); //Set to print on printer 1
1359 $order_receipt_printer1 .= '<tr><td class="left
">';
1360 if ($line->fk_product) {
1361 $order_receipt_printer1 .= $line->product_label;
1363 $order_receipt_printer1 .= $line->description;
1365 $order_receipt_printer1 .= '</td><td class="right
">'.$line->qty;
1366 if (!empty($line->array_options['options_order_notes'])) {
1367 $order_receipt_printer1 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1369 $order_receipt_printer1 .= '</td></tr>';
1372 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0 && $printer !== null) {
1373 $invoice->fetch($placeid); //Reload object before send to printer
1374 $printer->orderprinter = 1;
1376 echo "var orderprinter1esc=
'";
1377 $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
1380 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'1' and fk_facture =
".((int) $invoice->id); // Set as printed
1382 $invoice->fetch($placeid); //Reload object after set lines as printed
1385 foreach ($invoice->lines as $line) {
1386 if ($line->special_code == "4
") {
1389 $c = new Categorie($db);
1390 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1391 $result = array_intersect($catsprinter2, $existing);
1392 $count = count($result);
1395 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'2' where rowid =
".((int) $line->id); //Set to print on printer 2
1397 $order_receipt_printer2 .= '<tr>'.$line->product_label.'<td class="right
">'.$line->qty;
1398 if (!empty($line->array_options['options_order_notes'])) {
1399 $order_receipt_printer2 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1401 $order_receipt_printer2 .= '</td></tr>';
1404 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0) {
1405 $invoice->fetch($placeid); //Reload object before send to printer
1406 $printer->orderprinter = 2;
1408 echo "var orderprinter2esc=
'";
1409 $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
1412 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'2' and fk_facture =
".((int) $invoice->id); // Set as printed
1414 $invoice->fetch($placeid); //Reload object after set lines as printed
1417 foreach ($invoice->lines as $line) {
1418 if ($line->special_code == "4
") {
1421 $c = new Categorie($db);
1422 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1423 $result = array_intersect($catsprinter3, $existing);
1424 $count = count($result);
1427 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'3' where rowid =
".((int) $line->id); //Set to print on printer 3
1429 $order_receipt_printer3 .= '<tr>'.$line->product_label.'<td class="right
">'.$line->qty;
1430 if (!empty($line->array_options['options_order_notes'])) {
1431 $order_receipt_printer3 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1433 $order_receipt_printer3 .= '</td></tr>';
1436 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0 && $printer !== null) {
1437 $invoice->fetch($placeid); //Reload object before send to printer
1438 $printer->orderprinter = 3;
1440 echo "var orderprinter3esc=
'";
1441 $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
1444 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'3' and fk_facture =
".((int) $invoice->id); // Set as printed
1446 $invoice->fetch($placeid); //Reload object after set lines as printed
1449 $sectionwithinvoicelink = '';
1450 if (($action == "valid
" || $action == "history
" || $action == 'creditnote' || ($action == 'addline' && $invoice->status == $invoice::STATUS_CLOSED)) && $user->hasRight('takepos', 'run')) {
1451 $sectionwithinvoicelink .= '<!-- Section with invoice link -->'."\n
";
1452 $sectionwithinvoicelink .= '<span style="font-size:120%;
" class="center
inline-block marginbottomonly
">';
1453 if ($invoice->status == $invoice::STATUS_DRAFT) {
1454 $sectionwithinvoicelink .= $invoice->ref;
1456 $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice');
1458 $sectionwithinvoicelink .= " -
";
1459 $remaintopay = $invoice->getRemainToPay();
1460 if ($remaintopay > 0) {
1461 $sectionwithinvoicelink .= $langs->trans('RemainToPay').': <span class="amountremaintopay
" style="font-size: unset
">'.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
1463 $sectionwithinvoicelink .= $invoice->getLibStatut(2);
1466 $sectionwithinvoicelink .= '</span><br>';
1468 $customprinterallowed = false;
1469 $customprinttemplateallowed = true;
1471 // BAR RESTAURANT specific menu
1472 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1473 // Button to print receipt before payment
1474 $customprinterallowed = true;
1475 $customprinttemplateallowed = true;
1478 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
1479 if (isALNERunningVersion()) {
1480 // Custom printer may be allowed if mandatory information in template are guaranteed. For the moment, we prefer not allow this.
1481 $customprinttemplateallowed = false;
1484 if ($invoice->status == $invoice::STATUS_CLOSED) {
1485 if (getDolGlobalInt('TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
1486 $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>';
1488 // This section should be same than into index.php
1489 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1490 // Used when the external addon takeposconnector is installed. Deprecated.
1491 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
1492 // If TAKEPOS_PRINT_SERVER is an URL
1493 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintByESCPOSOld(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1495 // If TAKEPOS_PRINT_SERVER is an IP
1496 // Print by calling the receipt.php to get HTML content and send the HTML content to TAKEPOS_PRINT_SERVER:8111/print
1497 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintHTMLToSlashPrint(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1499 } elseif ($customprinterallowed && $customprinttemplateallowed && (isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") { // @phpstan-ignore-line
1500 // Button Print Receipt on special custom printer using custom template
1501 $nameOfPrinter = dol_getIdFromCode($db, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term), 'printer_receipt', 'rowid', 'name', 1);
1502 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintByESCPOS(
'.$placeid.')
" title="'.dolPrintHTMLForAttribute($langs->trans("SentToPrinter").' '.$nameOfPrinter).'">'.$langs->trans('PrintTicket').'</button>';
1504 // Button Print Receipt on browser
1505 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintByBrowser(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1507 // Additional buttons
1508 if ($customprinttemplateallowed && getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) {
1509 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintBox(
'.$placeid.', \
'without_details\')">'.$langs->trans(
'PrintWithoutDetails').
'</button>';
1512 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="PrintByBrowser('.$placeid.
', 1)">'.$langs->trans(
'GiftReceipt').
'</button>';
1517 $sectionwithinvoicelink .=
' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.
')">'.$langs->trans(
'SendTicket').
'</button>';
1520 if ($remaintopay <= 0 &&
getDolGlobalString(
'TAKEPOS_AUTO_PRINT_TICKETS') && $action !=
"history") {
1521 $sectionwithinvoicelink .=
'<script type="text/javascript">console.log("Emulate click on #buttonprint"); $("#buttonprint").click();</script>';
1535if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1536 $title =
'TakePOS - Dolibarr '.DOL_VERSION;
1540 $head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
1541 <meta name="apple-mobile-web-app-capable" content="yes">
1542 <meta name="mobile-web-app-capable" content="yes">
1543 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
1544 $arrayofcss = array(
1545 '/takepos/css/pos.css.php',
1547 $arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
1550 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
1552 print
'<body>'.
"\n";
1559<script
type=
"text/javascript">
1562<?php
if ($action ==
"valid") {
1563 echo
"var place=0;";
1565var placeid=<?php echo($placeid > 0 ? $placeid : 0); ?>;
1566$(document).ready(
function() {
1567 var idoflineadded = <?php echo(empty($idoflineadded) ? 0 : $idoflineadded); ?>;
1569 $(
'.posinvoiceline').click(
function(){
1570 console.log(
"Click done on "+this.
id);
1571 $(
'.posinvoiceline').removeClass(
"selected");
1572 $(
this).addClass(
"selected");
1576 if (selectedline == this.
id) {
1579 selectedline = this.id;
1581 selectedtext=$(
'#'+selectedline).find(
"td:first").html();
1583 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1584 print
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?action=editline&token='.
newToken().
'&placeid="+placeid+"&selectedline="+selectedline, function() {
1591 if (idoflineadded > 0)
1593 console.log(
"Auto select "+idoflineadded);
1594 $(
'.posinvoiceline#'+idoflineadded).click();
1598if ($action ==
"order" && !empty($order_receipt_printer1)) {
1599 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1603 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php',
1604 data:
'invoice='+orderprinter1esc
1611 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1613 print $headerorder.$order_receipt_printer1.$footerorder; ?>'
1619if ($action ==
"order" && !empty($order_receipt_printer2)) {
1620 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1624 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php?printer=2',
1625 data:
'invoice='+orderprinter2esc
1632 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print2',
1634 print $headerorder.$order_receipt_printer2.$footerorder; ?>'
1640if ($action ==
"order" && !empty($order_receipt_printer3)) {
1641 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1645 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php?printer=3',
1646 data:
'invoice='+orderprinter3esc
1653if ($action ==
"search" || $action ==
"valid") {
1655 parent.ClearSearch(
true);
1660if ($action ==
"temp" && !empty($ticket_printer1)) {
1664 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1666 print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>'
1671if ($action ==
"search") {
1673 $(
'#search').focus();
1681function SendTicket(
id)
1683 console.log(
"Open box to select the Print/Send form");
1684 $.colorbox({href:
"send.php?facid="+id, width:
"70%", height:
"30%", transition:
"none", iframe:
"true", title:
'<?php echo dol_escape_js($langs->trans("SendTicket")); ?>'});
1689function PrintBox(
id, action) {
1690 console.log(
"Open box before printing");
1691 $.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
"); ?>"});
1696function PrintByBrowser(
id, gift) {
1697 console.log(
"Call PrintByBrowser() to generate the receipt.");
1698 $.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")); ?>'});
1703function PrintHTMLToSlashPrint(
id){
1705 console.log(
"PrintHTMLToSlashPrint" +
id);
1706 $.get(
"receipt.php?facid="+
id,
function(data,
status) {
1707 receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,
'');
1710 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1718function PrintByESCPOSOld(
id){
1719 console.log(
"PrintByESCPOSOld id=" +
id);
1720 $.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) {
1723 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php',
1724 data:
'invoice='+data
1735function PrintByESCPOS(
id) {
1736 console.log(
"PrintByESCPOS Printing invoice ticket by calling takepos/aja/ajax.php id=" +
id);
1740 data: { token:
'<?php echo currentToken(); ?>' },
1741 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=printinvoiceticket&token='.currentToken().'&term='.urlencode(isset($_SESSION["takeposterminal
"]) ? $_SESSION["takeposterminal
"] : '').'&id='; ?>" + id,
1742 success:
function(){
1743 showPrintResultPopup(
'<?php echo dol_escape_js($langs->trans("SentToPrinter").' '.$nameOfPrinter); ?>', 2000);
1746 showPrintResultPopup(
"<?php echo dol_escape_js($langs->trans("FailedToSendToPrinter
")); ?>", 2000);
1753function showPrintResultPopup(message, duration) {
1754 $(
"#dialogforpopuptakepos").show().text(message).fadeIn();
1756 setTimeout(
function(){
1757 $(
"#dialogforpopuptakepos").fadeOut().hide();
1764function CreditNote() {
1765 $(
"#poslines").load(
"<?php print DOL_URL_ROOT; ?>/takepos/invoice.php?action=creditnote&token=<?php echo newToken() ?>&invoiceid="+placeid,
function() { });
1771 $(
"#poslines").load(
"<?php print DOL_URL_ROOT; ?>/takepos/invoice.php?action=addnote&token=<?php echo newToken() ?>&invoiceid="+placeid+
"&idline="+selectedline, {
"addnote": $(
"#textinput").val() });
1776$( document ).ready(
function() {
1777 console.log(
"Set customer info and sales in header placeid=<?php echo $placeid; ?> status=<?php echo $invoice->statut; ?>");
1780 $s = $langs->trans(
"Customer");
1781 if ($invoice->id > 0 && ($invoice->socid !=
getDolGlobalString($constforcompanyid))) {
1784 $contactids = $invoice->getIdContact(
'external',
'BILLING');
1785 $contactid = $contactids[0];
1786 if ($contactid > 0) {
1788 $contact->fetch($contactid);
1789 $s .=
" - " . $contact->getFullName($langs);
1793 print
'$("#idcustomer").val("");';
1797 $(
"#customerandsales").html(
'');
1798 $(
"#shoppingcart").html(
'');
1801 $(
"#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>');
1803 $(
"#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>');
1807 $sql =
"SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX.
"facture";
1808 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
1811 $sql .=
" AND ref LIKE '(PROV-POS".$db->escape(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'').
"-0%'";
1814 $sql .=
" AND pos_source = '".$db->escape((
string) $_SESSION[
"takeposterminal"]).
"'";
1815 $sql .=
" AND module_source = 'takepos'";
1818 $sql .=
$db->order(
'datec',
'ASC');
1819 $resql =
$db->query($sql);
1822 while ($obj =
$db->fetch_object($resql)) {
1823 echo
'$("#shoppingcart").append(\'';
1824 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=\\\'';
1825 $num_sale = str_replace(
")",
"", str_replace(
"(PROV-POS".$_SESSION[
"takeposterminal"].
"-",
"", $obj->ref));
1827 if (str_replace(
"-",
"", $num_sale) > $max_sale) {
1828 $max_sale = str_replace(
"-",
"", $num_sale);
1830 echo
'\\\'; invoiceid=\\\'';
1832 echo
'\\\'; Refresh();">';
1833 if ($placeid == $obj->rowid) {
1834 echo
'<span class="basketselected">';
1836 echo
'<span class="basketnotselected">';
1838 echo
'<span class="fa fa-shopping-cart paddingright"></span>'.dol_print_date(
$db->jdate($obj->datec),
'%H:%M',
'tzuser');
1842 echo
'$("#shoppingcart").append(\'<a onclick="place=\\\'0-';
1844 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>\');';
1852 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1855 $constantforkey =
'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1857 if ($idwarehouse > 0) {
1858 $s =
'<span class="small">';
1860 $warehouse->fetch($idwarehouse);
1861 $s .=
'<span class="hideonsmartphone">'.$langs->trans(
"Warehouse").
'<br></span>'.$warehouse->ref;
1863 $s .=
' ('.$langs->trans(
"Closed").
')';
1866 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1867 print
'$("#infowarehouse").css("display", "inline-block");';
1869 $s =
'<span class="small hideonsmartphone">';
1870 $s .= $langs->trans(
"StockChangeDisabled").
'<br>'.$langs->trans(
"NoWarehouseDefinedForTerminal");
1872 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1873 if (!empty(
$conf->dol_optimize_smallscreen)) {
1874 print
'$("#infowarehouse").css("display", "none");';
1878 $s =
'<span class="small hideonsmartphone">'.$langs->trans(
"StockChangeDisabled").
'</span>';
1879 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1880 if (!empty(
$conf->dol_optimize_smallscreen)) {
1881 print
'$("#infowarehouse").css("display", "none");';
1890 $s =
'<span class="small">';
1891 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1892 $langs->load(
"members");
1893 $s .= $langs->trans(
"Member").
': ';
1895 $result = $adh->fetch(0,
'', $invoice->socid);
1897 $adh->ref = $adh->getFullName($langs);
1901 $s .= $adh->getFullName($langs);
1902 $s .=
' - '.$adh->type;
1903 if ($adh->datefin) {
1904 $s .=
'<br>'.$langs->trans(
"SubscriptionEndDate").
': '.
dol_print_date($adh->datefin,
'day');
1905 if ($adh->hasDelay()) {
1906 $s .=
" ".img_warning($langs->trans(
"Late"));
1909 $s .=
'<br>'.$langs->trans(
"SubscriptionNotReceived");
1910 if ($adh->status > 0) {
1911 $s .=
" ".img_warning($langs->trans(
"Late"));
1918 $s .=
'<br>'.$langs->trans(
"ThirdpartyNotLinkedToMember");
1923 $(
"#moreinfo").html(
'<?php print dol_escape_js($s); ?>');
1930 echo
"function CustomerDisplay(){";
1931 echo
"var line1='".$CUSTOMER_DISPLAY_line1.
"'.substring(0,20);";
1932 echo
"line1=line1.padEnd(20);";
1933 echo
"var line2='".$CUSTOMER_DISPLAY_line2.
"'.substring(0,20);";
1934 echo
"line2=line2.padEnd(20);";
1936 echo
'webSocketCustomerDisplay.send(line1);';
1937 echo
'webSocketCustomerDisplay.send(line2);';
1941 data: { text: line1+line2 },
1942 url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER').
"/display/index.php',
1954if (!empty(
$conf->use_javascript_ajax)) {
1955 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
1956 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.
'"></script>'.
"\n";
1959$usediv = (
GETPOST(
'format') ==
'div');
1961print
'<!-- 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";
1962print
'<div class="div-table-responsive-no-min invoice">';
1964 print
'<div id="tablelines">';
1966 print
'<table id="tablelines" class="noborder noshadow postablelines centpercent">';
1969$buttontocreatecreditnote =
'';
1970if (($action ==
"valid" || $action ==
"history" || $action ==
"addline")
1972 $buttontocreatecreditnote .=
' <!-- Show button to create a credit note -->'.
"\n";
1973 $buttontocreatecreditnote .=
'<button id="buttonprint" type="button" onclick="ModalBox(\'ModalCreditNote\')">'.$langs->trans(
'CreateCreditNote').
'</button>';
1974 if (
getDolGlobalInt(
'TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
1975 $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>';
1980if ($sectionwithinvoicelink && ($mobilepage ==
"invoice" || $mobilepage ==
"")) {
1981 print
'<!-- Print table line with link to invoice ref -->';
1983 print
'<tr><td colspan="5" class="paddingtopimp paddingbottomimp" style="padding-top: 10px !important; padding-bottom: 10px !important;">';
1984 print $sectionwithinvoicelink;
1985 print $buttontocreatecreditnote;
1988 print
'<tr><td colspan="4" class="paddingtopimp paddingbottomimp" style="padding-top: 10px !important; padding-bottom: 10px !important;">';
1989 print $sectionwithinvoicelink;
1990 print $buttontocreatecreditnote;
1997 print
'<tr class="liste_titre nodrag nodrop">';
1998 print
'<td class="linecoldescription">';
2001if (empty($mobilepage) || $mobilepage ==
"invoice") {
2002 print
'<!-- hidden var used by some js functions -->';
2003 print
'<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.
'">';
2004 print
'<input type="hidden" name="thirdpartyid" id="thirdpartyid" value="'.$invoice->socid.
'">';
2008 $sql =
"SELECT floor, label FROM ".MAIN_DB_PREFIX.
"takepos_floor_tables where rowid = ".((int) $place);
2009 $resql =
$db->query($sql);
2010 $obj =
$db->fetch_object($resql);
2012 $label = $obj->label;
2013 $floor = $obj->floor;
2015 if ($mobilepage ==
"invoice" || $mobilepage ==
"") {
2018 print
'<span class="opacitymedium">'.$langs->trans(
'Place').
"</span> <b>".(empty($label) ?
'?' : $label).
"</b><br>";
2019 print
'<span class="opacitymedium">'.$langs->trans(
'Floor').
"</span> <b>".(empty($floor) ?
'?' : $floor).
"</b>";
2026$parameters = array();
2027$reshook = $hookmanager->executeHooks(
'completeTakePosInvoiceHeader', $parameters, $invoice, $action);
2031print $hookmanager->resPrint;
2033if (empty($_SESSION[
"basiclayout"]) || $_SESSION[
"basiclayout"] != 1) {
2035 print
'<td class="linecolqty right">'.$langs->trans(
'PriceUHT').
'</td>';
2037 print
'<td class="linecolqty right">'.$langs->trans(
'ReductionShort').
'</td>';
2038 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
2040 print
'<td class="linecolht right nowraponall">';
2041 print
'<span class="opacitymedium small">' . $langs->trans(
'TotalHTShort') .
'</span><br>';
2043 if (empty($mobilepage) || $mobilepage ==
"invoice") {
2044 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>';
2045 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"]) &&
$conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
2047 include_once DOL_DOCUMENT_ROOT .
'/multicurrency/class/multicurrency.class.php';
2049 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
2050 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>';
2055 print
'<td class="linecolht right nowraponall">';
2056 print
'<span class="opacitymedium small">'.$langs->trans(
'TotalTTCShort').
'</span><br>';
2058 if (empty($mobilepage) || $mobilepage ==
"invoice") {
2059 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>';
2060 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"]) &&
$conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
2062 include_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
2064 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
2065 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>';
2069} elseif ($mobilepage ==
"invoice") {
2070 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
2076if (!empty($_SESSION[
"basiclayout"]) && $_SESSION[
"basiclayout"] == 1) {
2077 if ($mobilepage ==
"cats") {
2078 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2080 $categories = $categorie->get_full_arbo(
'product');
2082 foreach ($categories as $row) {
2083 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2084 $htmlforlines .=
'<div class="leftcat"';
2086 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline"';
2088 $htmlforlines .=
' onclick="LoadProducts('.$row[
'id'].
');">';
2089 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2090 $htmlforlines .=
'<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=cat&query=cat&id='.$row[
'id'].
'"><br>';
2092 $htmlforlines .=
'<td class="left">';
2094 $htmlforlines .= $row[
'label'];
2095 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2096 $htmlforlines .=
'</div>'.
"\n";
2098 $htmlforlines .=
'</td></tr>'.
"\n";
2101 print $htmlforlines;
2104 if ($mobilepage ==
"products") {
2105 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2108 $result =
$object->fetch($catid);
2109 $prods =
$object->getObjectsInCateg(
"product");
2111 '@phan-var-force Product[] $prods';
2113 foreach ($prods as $row) {
2114 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2115 $htmlforlines .=
'<div class="leftcat"';
2117 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline"';
2119 $htmlforlines .=
' onclick="AddProduct(\''.$place.
'\',
'.$row->id.')
"';
2120 $htmlforlines .= '>';
2121 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2122 $htmlforlines .= '<img class="imgwrapper
" width="33%
" src="'.DOL_URL_ROOT.'/takepos/
public/auto_order.php?genimg=pro&query=pro&
id=
'.$row->id.'"><br>';
2123 $htmlforlines .= $row->label.' '.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency);
2124 $htmlforlines .= '</div>'."\n
";
2126 $htmlforlines .= '<td class="left
">';
2127 $htmlforlines .= $row->label;
2128 $htmlforlines .= '<div class="right
">'.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).'</div>';
2129 $htmlforlines .= '</td>';
2130 $htmlforlines .= '</tr>'."\n
";
2133 print $htmlforlines;
2136 if ($mobilepage == "places
") {
2137 $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM
".MAIN_DB_PREFIX."takepos_floor_tables
";
2138 $resql = $db->query($sql);
2142 while ($row = $db->fetch_array($resql)) {
2144 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
2145 $htmlforlines .= '" onclick="LoadPlace(\
''.$row[
'label'].
'\')
">';
2146 $htmlforlines .= '<td class="left
">';
2147 $htmlforlines .= $row['label'];
2148 $htmlforlines .= '</td>';
2149 $htmlforlines .= '</tr>'."\n
";
2151 print $htmlforlines;
2156 //In Phone basic layout hide some content depends situation
2157 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1 && $mobilepage != "invoice
" && $action != "order
") {
2161 // Loop on each lines on invoice
2162 if (is_array($invoice->lines) && count($invoice->lines)) {
2163 print '<!-- invoice.php show lines of invoices -->'."\n
";
2164 $tmplines = array_reverse($invoice->lines);
2165 $htmlsupplements = array();
2166 foreach ($tmplines as $line) {
2167 if ($line->fk_parent_line != false) {
2168 if (!isset($htmlsupplements[$line->fk_parent_line])) {
2169 $htmlsupplements[$line->fk_parent_line] = '';
2171 $htmlsupplements[$line->fk_parent_line] .= '<tr class="drag drop oddeven posinvoiceline
';
2172 if ($line->special_code == "4") {
2173 $htmlsupplements[$line->fk_parent_line] .= ' order
';
2175 $htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'"';
2176 if ($line->special_code == "4
") {
2177 $htmlsupplements[$line->fk_parent_line] .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
2179 $htmlsupplements[$line->fk_parent_line] .= '>';
2180 $htmlsupplements[$line->fk_parent_line] .= '<td class="left
">';
2181 $htmlsupplements[$line->fk_parent_line] .= img_picto('', 'rightarrow.png');
2182 if ($line->product_label) {
2183 $htmlsupplements[$line->fk_parent_line] .= $line->product_label;
2185 if ($line->product_label && $line->desc) {
2186 $htmlsupplements[$line->fk_parent_line] .= '<br>';
2188 if ($line->product_label != $line->desc) {
2189 $firstline = dolGetFirstLineOfText($line->desc);
2190 if ($firstline != $line->desc) {
2191 $htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
2193 $htmlsupplements[$line->fk_parent_line] .= $line->desc;
2196 $htmlsupplements[$line->fk_parent_line] .= '</td>';
2198 // complete line by hook
2199 $parameters = array('line' => $line);
2200 $reshook = $hookmanager->executeHooks('completeTakePosInvoiceParentLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
2202 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2204 $htmlsupplements[$line->fk_parent_line] .= $hookmanager->resPrint;
2206 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2207 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.vatrate(price2num($line->remise_percent), true).'</td>';
2208 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.$line->qty.'</td>';
2209 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.price($line->total_ttc).'</td>';
2211 $htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n
";
2216 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
2217 if ($line->special_code == "4") {
2218 $htmlforlines .= ' order
';
2220 $htmlforlines .= '" id="'.$line->id.'"';
2221 if ($line->special_code == "4
") {
2222 $htmlforlines .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
2224 $htmlforlines .= '>';
2225 $htmlforlines .= '<td class="left
">';
2226 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
2227 $htmlforlines .= '<span class="phoneqty
">'.$line->qty."</span> x
";
2229 if (isset($line->product_type)) {
2230 if (empty($line->product_type)) {
2231 $htmlforlines .= img_object('', 'product').' ';
2233 $htmlforlines .= img_object('', 'service').' ';
2237 if (!getDolGlobalString('TAKEPOS_SHOW_N_FIRST_LINES')) {
2238 if ($line->product_ref) {
2239 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
2240 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
2241 if (!empty($line->batch)) {
2242 $tooltiptext .= '<br><b>'.$langs->trans("LotSerial
").'</b> : '.$line->batch.'<br>';
2244 if (!empty($line->fk_warehouse)) {
2245 $tooltiptext .= '<b>'.$langs->trans("Warehouse
").'</b> : '.$line->fk_warehouse.'<br>';
2247 if ($line->product_label != $line->desc) {
2249 $tooltiptext .= '<br>';
2251 $tooltiptext .= $line->desc;
2254 if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
2255 $htmlforlines .= $form->textwithpicto($line->product_label ? '<b>' . $line->product_ref . '</b> - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
2256 } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) {
2257 $htmlforlines .= $form->textwithpicto($line->product_ref ? '<b>'.$line->product_ref.'<b>' : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
2259 $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
2262 if ($line->product_ref) {
2263 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
2264 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
2266 if (!empty($line->batch)) {
2267 $tooltiptext .= '<br><b>'.$langs->trans("LotSerial
").'</b> : '.$line->batch.'<br>';
2269 if (!empty($line->fk_warehouse)) {
2270 $tooltiptext .= '<b>'.$langs->trans("Warehouse
").'</b> : '.$line->fk_warehouse.'<br>';
2273 if ($line->product_label) {
2274 $htmlforlines .= $line->product_label;
2276 if ($line->product_label != $line->desc) {
2277 if ($line->product_label && $line->desc) {
2278 $htmlforlines .= '<br>';
2280 $firstline = dolGetFirstLineOfText($line->desc, getDolGlobalInt('TAKEPOS_SHOW_N_FIRST_LINES'));
2281 if ($firstline != $line->desc) {
2282 $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
2284 $htmlforlines .= $line->desc;
2288 if (!empty($line->array_options['options_order_notes'])) {
2289 $htmlforlines .= "<br>(
".$line->array_options['options_order_notes'].")
";
2291 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
2292 $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>';
2294 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2295 // Set the content of tooltip
2297 $moreinfo .= $langs->trans("VATRate
").': '.price($line->tva_tx).' %<br>';
2298 $moreinfo .= $langs->trans("UnitPrice
").': '.price($line->subprice).'<br>';
2299 $moreinfo .= '<br>';
2300 $moreinfo .= $langs->transcountry("TotalHT
", $mysoc->country_code).': '.price($line->total_ht);
2301 if ($line->vat_src_code) {
2302 $moreinfo .= '<br>'.$langs->trans("VATCode
").': '.$line->vat_src_code;
2304 $moreinfo .= '<br>'.$langs->trans("TotalVAT
").': '.price($line->total_tva);
2305 if ($mysoc->useLocalTax(1, 1, $mysoc)) {
2306 $moreinfo .= '<br>'.$langs->transcountry("TotalLT1
", $mysoc->country_code).': '.price($line->total_localtax1);
2308 if ($mysoc->useLocalTax(2, 1, $mysoc)) {
2309 $moreinfo .= '<br>'.$langs->transcountry("TotalLT2
", $mysoc->country_code).': '.price($line->total_localtax2);
2311 $moreinfo .= '<hr>';
2312 $moreinfo .= $langs->transcountry("TotalTTC
", $mysoc->country_code).': '.price($line->total_ttc);
2313 //$moreinfo .= $langs->trans("TotalHT
").': '.$line->total_ht;
2314 if ($line->date_start || $line->date_end) {
2315 $htmlforlines .= '<br><div class="clearboth nowraponall
">'.get_date_range($line->date_start, $line->date_end).'</div>';
2317 $htmlforlines .= '</td>';
2319 // complete line by hook
2320 $parameters = array('line' => $line);
2321 $reshook = $hookmanager->executeHooks('completeTakePosInvoiceLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
2323 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2325 $htmlforlines .= $hookmanager->resPrint;
2327 if (getDolGlobalInt("TAKEPOS_SHOW_SUBPRICE
")) {
2328 $htmlforlines .= '<td class="right
">'.price($line->subprice).'</td>';
2330 $htmlforlines .= '<td class="right
">'.vatrate(price2num($line->remise_percent), true).'</td>';
2331 // nowraponall keeps the qty and its '(stock)' block on one line: on narrow layouts
2332 // the native display otherwise wraps over three lines inside the qty column.
2333 $htmlforlines .= '<td class="right nowraponall
">';
2334 $htmlforlines .= $line->qty;
2335 if (isModEnabled('stock') && $user->hasRight('stock', 'mouvement', 'lire')) {
2336 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
2337 if (getDolGlobalString($constantforkey) && $line->fk_product > 0 && !getDolGlobalString('TAKEPOS_HIDE_STOCK_ON_LINE')) {
2338 $productChildrenNb = 0;
2339 if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
2340 if (empty($line->product) || !($line->product->id > 0)) {
2341 $line->fetch_product();
2343 if (!empty($line->product)) {
2344 $productChildrenNb = $line->product->hasFatherOrChild(1);
2347 if ($productChildrenNb == 0) {
2348 $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp
";
2349 $sql .= " FROM
".MAIN_DB_PREFIX."entrepot as e,
";
2350 $sql .= " ".MAIN_DB_PREFIX."product_stock as ps
";
2351 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product
";
2352 $sql .= " WHERE ps.reel != 0
";
2353 $sql .= " AND ps.fk_entrepot =
".((int) getDolGlobalString($constantforkey));
2354 $sql .= " AND e.entity IN (
".getEntity('stock').")
";
2355 $sql .= " AND ps.fk_product =
".((int) $line->fk_product);
2356 $resql = $db->query($sql);
2359 $obj = $db->fetch_object($resql);
2361 $stock_real = price2num($obj->reel, 'MS');
2363 $htmlforlines .= ' ';
2364 $htmlforlines .= '<span class="opacitylow
" title="'.$langs->trans("Stock").' '.price($stock_real, 1, '', 1, 0).'">';
2365 $htmlforlines .= '(';
2366 if ($line->qty && $line->qty > $stock_real) {
2367 $htmlforlines .= '<span style="color: var(--amountremaintopaycolor)
">';
2369 $htmlforlines .= img_picto('', 'stock', 'class="pictofixedwidth
"').price($stock_real, 1, '', 1, 0);
2370 if ($line->qty && $line->qty > $stock_real) {
2371 $htmlforlines .= "</span>
";
2373 $htmlforlines .= ')';
2374 $htmlforlines .= '</span>';
2376 dol_print_error($db);
2382 $htmlforlines .= '</td>';
2383 if (getDolGlobalInt('TAKEPOS_SHOW_HT')) {
2384 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
2385 $htmlforlines .= price($line->total_ht, 1, '', 1, -1, -1, $conf->currency);
2386 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
2387 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
2388 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
2389 $multicurrency = new MultiCurrency($db);
2390 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
2391 $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>';
2393 $htmlforlines .= '</td>';
2395 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
2396 $htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency);
2397 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
2398 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
2399 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
2400 $multicurrency = new MultiCurrency($db);
2401 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
2402 $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>';
2404 $htmlforlines .= '</td>';
2406 $htmlforlines .= '</tr>'."\n
";
2407 $htmlforlines .= empty($htmlsupplements[$line->id]) ? '' : $htmlsupplements[$line->id];
2409 print $htmlforlines;
2412 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td>';
2413 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2414 print '<td></td><td></td>';
2415 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
2421} else { // No invoice generated yet
2422 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td>';
2423 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2424 print '<td></td><td></td>';
2425 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
2438if ($action == "search
") {
2440 <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
')).'">
2447if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2448 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.
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).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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...
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formatted error messages to output (Used to show messages on html output).
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.