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');
123function fail($message)
125 header($_SERVER[
'SERVER_PROTOCOL'].
' 500 Internal Server Error',
true, 500);
131$number = (float)
GETPOST(
'number',
'alpha');
134$desc =
GETPOST(
'desc',
'alphanohtml');
147if ($pay ==
'cheque') {
154 $sql =
"SELECT id, code FROM ".MAIN_DB_PREFIX.
"c_paiement";
155 $sql .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
156 $sql .=
" AND code = '".$db->escape($paycode).
"'";
157 $resql =
$db->query($sql);
159 $obj =
$db->fetch_object($resql);
161 $paiementid = $obj->id;
168 $ret = $invoice->fetch($invoiceid);
170 $ret = $invoice->fetch(0,
'(PROV-POS'.$takeposterminal.
'-'.$place.
')');
173 $placeid = $invoice->id;
176$constforcompanyid =
'CASHDESK_ID_THIRDPARTY'.$takeposterminal;
179if ($invoice->socid > 0) {
180 $soc->fetch($invoice->socid);
187 $invoice->fk_project =
getDolGlobalInt(
"CASHDESK_ID_PROJECT".$takeposterminal);
191if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"])) {
192 if ($invoice->multicurrency_code != $_SESSION[
"takeposcustomercurrency"]) {
193 $invoice->setMulticurrencyCode($_SESSION[
"takeposcustomercurrency"]);
197$term = empty($_SESSION[
"takeposterminal"]) ? 1 : $_SESSION[
"takeposterminal"];
204$parameters = array();
205$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $invoice, $action);
210$sectionwithinvoicelink =
'';
211$CUSTOMER_DISPLAY_line1 =
'';
212$CUSTOMER_DISPLAY_line2 =
'';
217if (empty($reshook)) {
221 $sql =
"SELECT MIN(ref) as firstref FROM ".MAIN_DB_PREFIX.
"pos_cash_fence";
222 $sql .=
" WHERE posnumber = ".((int) $takeposterminal);
223 $sql .=
" AND year_close = ".((int) $tmpcurrentday[
'year']);
225 $sql .=
" (month_close IS NULL AND day_close IS NULL)";
226 $sql .=
" OR (month_close = ".((int) $tmpcurrentday[
'mon']).
" AND day_close IS NULL)";
227 $sql .=
" OR (month_close = ".((int) $tmpcurrentday[
'mon']).
" AND day_close = ".((int) $tmpcurrentday[
'mday']).
")";
229 $sql .=
" AND status = 1";
232 $resql =
$db->query($sql);
234 $obj =
$db->fetch_object($resql);
236 $refcashcontrol = $obj->firstref;
240 if ($refcashcontrol) {
242 $langs->load(
'errors');
243 dol_htmloutput_errors($langs->trans(
"ACashControlHasBeenclosedForCurrentDay", $refcashcontrol), [], 1);
248 if ($action ==
'valid' && $user->hasRight(
'facture',
'creer')) {
256 $bankaccount =
getDolGlobalInt(
'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION[
"takeposterminal"]);
257 } elseif ($pay ==
"CHQ") {
258 $bankaccount =
getDolGlobalInt(
'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION[
"takeposterminal"]);
260 $accountname =
"CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION[
"takeposterminal"];
265 if ($bankaccount <= 0 && $pay !=
"delayed" &&
isModEnabled(
"bank")) {
266 $errormsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount"));
274 $invoice->fetch($placeid);
276 $invoice->oldcopy =
dol_clone($invoice, 2);
280 if ($invoice->total_ttc < 0) {
281 $invoice->type = $invoice::TYPE_CREDIT_NOTE;
283 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
284 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
285 $sql .=
" AND fk_soc = ".((int) $invoice->socid);
286 $sql .=
" AND type <> ".Facture::TYPE_CREDIT_NOTE;
287 $sql .=
" AND fk_statut >= ".$invoice::STATUS_VALIDATED;
288 $sql .=
" ORDER BY rowid DESC";
291 $resql =
$db->query($sql);
293 $obj =
$db->fetch_object($resql);
294 $fk_source = $obj->rowid;
295 if ((
int) $fk_source == 0) {
296 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
299 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
301 $invoice->fk_facture_source = $fk_source;
302 $invoice->update($user);
305 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
312 $remaintopay = $invoice->getRemainToPay();
319 } elseif (count($invoice->lines) == 0) {
328 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
330 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
331 dol_syslog(
"Validate invoice with stock change. Warehouse defined into constant ".$constantforkey.
" = ".
getDolGlobalString($constantforkey));
336 $res = $invoice->validate($user,
'',
getDolGlobalInt($constantforkey), 0, $batch_rule);
339 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
342 dol_syslog(
"Call validate on invoice ".$invoice->ref, LOG_DEBUG);
343 $res = $invoice->validate($user);
346 $langs->load(
"admin");
347 dol_htmloutput_errors($invoice->error ==
'NotConfigured' ? $langs->trans(
"NotConfigured").
' (TakePos numbering module)' : $invoice->error, $invoice->errors, 1);
352 if (!$error && $res >= 0) {
353 $remaintopay = $invoice->getRemainToPay();
358 $payment->datepaye = $now;
359 $payment->fk_account = $bankaccount;
364 $payment->amounts[$invoice->id] = $amountofpayment;
367 if ($amountofpayment <= 0 || $amountofpayment > $remaintopay) {
368 $payment->amounts[$invoice->id] = $remaintopay;
372 $payment->paiementid = $paiementid;
373 $payment->paiementcode = $paycode;
374 $payment->num_payment =
'';
376 if ($pay !=
"delayed") {
377 $res = $payment->create($user);
384 if (!empty($payment->warnings)) {
388 $res = $payment->addPaymentToBank($user,
'payment',
'(CustomerInvoicePayment)', $bankaccount,
'',
'');
391 dol_htmloutput_mesg($langs->trans(
'ErrorNoPaymentDefined').
' '.$payment->error, $payment->errors,
'error', 1);
394 $remaintopay = $invoice->getRemainToPay();
400 if ($remaintopay == 0) {
401 dol_syslog(
"Invoice is paid, so we set it to status Paid");
402 $result = $invoice->setPaid($user);
405 $invoice->status = $invoice::STATUS_CLOSED;
406 $invoice->close_code =
'';
409 $invoice->setPaymentMethods($paiementid);
411 dol_syslog(
"Invoice is not paid, remain to pay = ".$remaintopay);
420 if (!$error && $res >= 0) {
423 dol_syslog(
"Now we record the stock movement for each qualified line");
426 require_once DOL_DOCUMENT_ROOT .
"/product/stock/class/mouvementstock.class.php";
427 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
430 $labeltakeposmovement =
'TakePOS - '.$langs->trans(
"Invoice").
' '.$invoice->ref;
432 foreach ($invoice->lines as $line) {
434 $warehouseid = ($line->fk_warehouse ? $line->fk_warehouse :
getDolGlobalInt($constantforkey));
437 if ($line->batch !=
'' && $warehouseid > 0) {
439 $prod_batch->find(0,
'',
'', $line->batch, $warehouseid, (
int) $line->fk_product);
442 $mouvP->setOrigin($invoice->element, $invoice->id);
444 $res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'', $prod_batch->batch, $prod_batch->id, $inventorycode);
451 $mouvP->setOrigin($invoice->element, $invoice->id);
453 $res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'',
'', 0, $inventorycode);
463 if (!$error && $res >= 0) {
466 $invoice->ref = $invoice->oldcopy->ref;
467 $invoice->paye = $invoice->oldcopy->paye;
468 $invoice->status = $invoice->oldcopy->status;
469 $invoice->statut = $invoice->oldcopy->statut;
476 if ($action ==
'creditnote' && $user->hasRight(
'facture',
'creer')) {
480 $creditnote->socid = $invoice->socid;
482 $creditnote->module_source =
'takepos';
483 $creditnote->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
485 $creditnote->fk_facture_source = $placeid;
487 $creditnote->create($user);
491 foreach ($invoice->lines as $line) {
493 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
498 if (!empty($invoice->situation_counter)) {
499 $source_fk_prev_id = $line->fk_prev_id;
500 $line->fk_prev_id = $line->id;
501 if (!empty($invoice->tab_previous_situation_invoice)) {
504 $tab_jumped_credit_notes = array();
505 $lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
506 $searchPreviousInvoice =
true;
507 while ($searchPreviousInvoice) {
508 if ($invoice->tab_previous_situation_invoice[$lineIndex]->situation_cycle_ref || $lineIndex < 1) {
509 $searchPreviousInvoice =
false;
513 $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id;
519 $maxPrevSituationPercent = 0;
520 foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
521 if ($prevLine->id == $source_fk_prev_id) {
522 $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
525 $line->total_ht -= $prevLine->total_ht;
526 $line->total_tva -= $prevLine->total_tva;
527 $line->total_ttc -= $prevLine->total_ttc;
528 $line->total_localtax1 -= $prevLine->total_localtax1;
529 $line->total_localtax2 -= $prevLine->total_localtax2;
531 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
532 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
533 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
534 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
539 $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
544 $maxPrevSituationPercent = 0;
545 foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
546 foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) {
547 if ($prevLine->fk_prev_id == $source_fk_prev_id) {
548 $maxPrevSituationPercent = $prevLine->situation_percent;
550 $line->total_ht -= $prevLine->total_ht;
551 $line->total_tva -= $prevLine->total_tva;
552 $line->total_ttc -= $prevLine->total_ttc;
553 $line->total_localtax1 -= $prevLine->total_localtax1;
554 $line->total_localtax2 -= $prevLine->total_localtax2;
556 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
557 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
558 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
559 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
565 $line->situation_percent += $maxPrevSituationPercent;
573 $line->fk_facture = $creditnote->id;
574 $line->fk_parent_line = $fk_parent_line;
576 $line->subprice = -$line->subprice;
578 $line->total_ht = -$line->total_ht;
579 $line->total_tva = -$line->total_tva;
580 $line->total_ttc = -$line->total_ttc;
581 $line->total_localtax1 = -$line->total_localtax1;
582 $line->total_localtax2 = -$line->total_localtax2;
584 $line->multicurrency_subprice = -$line->multicurrency_subprice;
585 $line->multicurrency_total_ht = -$line->multicurrency_total_ht;
586 $line->multicurrency_total_tva = -$line->multicurrency_total_tva;
587 $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
589 $result = $line->insert(0, 1);
591 $creditnote->lines[] = $line;
594 if ($result > 0 && $line->product_type == 9) {
595 $fk_parent_line = $result;
598 $creditnote->update_price(1);
602 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
609 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
611 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
614 dol_syslog(
"Validate invoice with stock change into warehouse defined into constant ".$constantforkey.
" = ".
getDolGlobalString($constantforkey).
" or warehouseid= ".$warehouseid.
" if defined.");
619 $res = $creditnote->validate($user,
'', $warehouseid, 0, $batch_rule);
626 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
628 $res = $creditnote->validate($user);
632 if (!$error && $res >= 0) {
635 dol_syslog(
"Now we record the stock movement for each qualified line");
638 require_once DOL_DOCUMENT_ROOT .
"/product/stock/class/mouvementstock.class.php";
639 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
642 $labeltakeposmovement =
'TakePOS - '.$langs->trans(
"CreditNote").
' '.$creditnote->ref;
644 foreach ($creditnote->lines as $line) {
646 $warehouseid = ($line->fk_warehouse ? $line->fk_warehouse :
getDolGlobalInt($constantforkey));
649 if ($line->batch !=
'' && $warehouseid > 0) {
654 $mouvP->setOrigin($creditnote->element, $creditnote->id);
656 $res = $mouvP->reception($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'', $line->batch,
'', 0, $inventorycode);
663 $mouvP->setOrigin($creditnote->element, $creditnote->id);
665 $res = $mouvP->reception($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'',
'', 0, $inventorycode);
675 if (!$error && $res >= 0) {
678 $creditnote->id = $placeid;
683 if (($action ==
'history' || $action ==
'creditnote') && $user->hasRight(
'takepos',
'run')) {
684 if ($action ==
'creditnote' && $creditnote !==
null && $creditnote->id > 0) {
685 $placeid = $creditnote->id;
691 $invoice->fetch($placeid);
695 if (($action ==
"addline" || $action ==
"freezone") && $placeid == 0 && ($user->hasRight(
'takepos',
'run') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
698 $dolnowtzuserrel =
dol_now(
'tzuserrel');
702 $dateinvoice =
dol_mktime(0, 0, 0, (
int) $monthuser, (
int) $dayuser, (
int) $yearuser,
'tzserver');
704 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
705 $invoice->date = $dateinvoice;
719 $invoice->module_source =
'takepos';
720 $invoice->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
721 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] :
$conf->entity;
723 if ($invoice->socid <= 0) {
724 $langs->load(
'errors');
730 $placeid = $invoice->create($user);
736 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture";
737 $sql .=
" SET ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
738 $sql .=
" WHERE rowid = ".((int) $placeid);
739 $resql =
$db->query($sql);
755 if ($action ==
"addline" && ($user->hasRight(
'takepos',
'run') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
757 $prod->fetch($idproduct);
760 $customer->fetch($invoice->socid);
762 $datapriceofproduct =
$prod->getSellPrice(
$mysoc, $customer, 0);
765 $price = $datapriceofproduct[
'pu_ht'];
766 $price_ttc = $datapriceofproduct[
'pu_ttc'];
768 $price_base_type = empty($datapriceofproduct[
'price_base_type']) ?
'HT' : $datapriceofproduct[
'price_base_type'];
769 $tva_tx = $datapriceofproduct[
'tva_tx'];
770 $tva_npr = (int) $datapriceofproduct[
'tva_npr'];
778 $batch =
GETPOST(
'batch',
'alpha');
780 if (!empty($batch)) {
781 $action =
"setbatch";
782 } elseif (
$prod->status_batch > 0) {
787 $prod->load_stock(
'warehouseopen');
789 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
793 foreach (
$prod->stock_warehouse as $tmpwarehouseid => $tmpval) {
798 if (!empty(
$prod->stock_warehouse[$tmpwarehouseid]) && is_array(
$prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
799 if (is_object(
$prod->stock_warehouse[$tmpwarehouseid]) && count(
$prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
800 foreach (
$prod->stock_warehouse[$tmpwarehouseid]->detail_batch as $dbatch) {
809 echo
"function addbatch(batch, warehouseid) {\n";
810 echo
"console.log('We add batch '+batch+' from warehouse id '+warehouseid);\n";
811 echo
'$("#poslines").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?action=addline&batch="+encodeURI(batch)+"&warehouseid="+warehouseid+"&place='.$place.
'&idproduct='.$idproduct.
'&token='.newToken().
'", function() {});'.
"\n";
816 echo
"<center>".$langs->trans(
"SearchIntoBatch").
": <b> $nbofsuggested </b></center><br><table>";
817 foreach (
$prod->stock_warehouse as $tmpwarehouseid => $tmpval) {
822 if (!empty(
$prod->stock_warehouse[$tmpwarehouseid]) && is_array(
$prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
823 foreach (
$prod->stock_warehouse[$tmpwarehouseid]->detail_batch as $dbatch) {
824 $batchStock = + $dbatch->qty;
825 $quantityToBeDelivered = 1;
826 $deliverableQty = min($quantityToBeDelivered, $batchStock);
828 print
'<!-- subj='.$suggestednb.
'/'.$nbofsuggested.
' -->';
829 print
'<!-- Show details of lot/serial in warehouseid='.$tmpwarehouseid.
' -->';
830 print
'<td class="left">';
832 $detail .=
'<span class="opacitymedium">'.$langs->trans(
"LotSerial").
':</span> '.$dbatch->batch;
839 $detail .=
'</td><td>';
840 $detail .=
'<span class="opacitymedium">'.$langs->trans(
"Qty").
':</span> '.$dbatch->qty;
841 $detail .=
'</td><td>';
842 $detail .=
' <button class="marginleftonly" onclick="addbatch(\''.dol_escape_js($dbatch->batch).
'\',
'.$tmpwarehouseid.')
">'.$langs->trans("Select
")."</
button>
";
846 $quantityToBeDelivered -= $deliverableQty;
847 if ($quantityToBeDelivered < 0) {
848 $quantityToBeDelivered = 0;
857 print '</body></html>';
863 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
864 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
865 $cat = new Categorie($db);
866 $categories = $cat->containing($idproduct, 'product');
867 $found = (array_search(getDolGlobalInt('TAKEPOS_SUPPLEMENTS_CATEGORY'), array_column($categories, 'id')));
868 if ($found !== false) { // If this product is a supplement
869 $sql = "SELECT fk_parent_line FROM
".MAIN_DB_PREFIX."facturedet where rowid =
".((int) $selectedline);
870 $resql = $db->query($sql);
871 $row = $db->fetch_array($resql);
872 if ($row[0] == null) {
873 $parent_line = $selectedline;
875 $parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product
881 // Group if enabled. Skip group if line already sent to the printer
882 if (getDolGlobalString('TAKEPOS_GROUP_SAME_PRODUCT')) {
883 foreach ($invoice->lines as $line) {
884 if ($line->product_ref == $prod->ref) {
885 if ($line->special_code == 4) {
887 } // If this line is sended to printer create new line
888 // check if qty in stock
889 if (getDolGlobalString('TAKEPOS_QTY_IN_STOCK') && (($line->qty + $qty) > $prod->stock_reel)) {
890 $invoice->error = $langs->trans("ErrorStockIsNotEnough
");
891 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
895 $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);
897 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
899 $idoflineadded = $line->id;
905 if ($idoflineadded <= 0 && empty($err)) {
906 $invoice->fetch_thirdparty();
907 $array_options = array();
909 $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);
911 /* setup of margin calculation */
912 if (getDolGlobalString('MARGIN_TYPE')) {
913 if (getDolGlobalString('MARGIN_TYPE') == 'pmp' && !empty($prod->pmp)) {
914 $line['fk_fournprice'] = null;
915 $line['pa_ht'] = $prod->pmp;
916 } elseif (getDolGlobalString('MARGIN_TYPE') == 'costprice' && !empty($prod->cost_price)) {
917 $line['fk_fournprice'] = null;
918 $line['pa_ht'] = $prod->cost_price;
920 // default is fournprice
921 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
922 $pf = new ProductFournisseur($db);
923 if ($pf->find_min_price_product_fournisseur($idproduct, $qty) > 0) {
924 $line['fk_fournprice'] = $pf->product_fourn_price_id;
925 $line['pa_ht'] = $pf->fourn_unitprice_with_discount;
926 if (getDolGlobalString('PRODUCT_CHARGES') && $pf->fourn_charges > 0) {
927 $line['pa_ht'] += (float) $pf->fourn_charges / $pf->fourn_qty;
933 // complete line by hook
934 $parameters = array('prod' => $prod, 'line' => $line);
935 $reshook = $hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action); // Note that $action and $line may have been modified by some hooks
937 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
941 if (empty($reshook)) {
942 if (!empty($hookmanager->resArray)) {
943 $line = $hookmanager->resArray;
946 // check if qty in stock
947 if (getDolGlobalString('TAKEPOS_QTY_IN_STOCK') && $qty > $prod->stock_reel) {
948 $invoice->error = $langs->trans("ErrorStockIsNotEnough
");
949 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
954 $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);
958 if (getDolGlobalString('TAKEPOS_CUSTOMER_DISPLAY')) {
959 $CUSTOMER_DISPLAY_line1 = $prod->label;
960 $CUSTOMER_DISPLAY_line2 = price($price_ttc);
964 $invoice->fetch($placeid);
967 // If we add a line by submitting freezone form (invoice exists here because it was created just before if it didn't exist)
968 if ($action == "freezone
" && $user->hasRight('takepos', 'run')) {
969 $customer = new Societe($db);
970 $customer->fetch($invoice->socid);
972 $tva_tx = GETPOST('tva_tx', 'alpha');
974 if (!preg_match('/\((.*)\)/', $tva_tx)) {
975 $tva_tx = price2num($tva_tx);
978 $tva_tx = get_default_tva($mysoc, $customer);
982 $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
983 $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
985 $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);
987 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
989 $invoice->fetch($placeid);
992 if ($action == "addnote
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
993 $desc = GETPOST('addnote', 'alpha');
995 $invoice->update_note($desc, '_public');
997 foreach ($invoice->lines as $line) {
998 if ($line->id == $idline) {
999 $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);
1003 $invoice->fetch($placeid);
1006 if ($action == "deleteline
" && ($user->hasRight('takepos', 'editlines') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1008 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1009 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1010 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1011 $permissiontoupdateline = true;
1012 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1013 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1018 if ($idline > 0 && $placeid > 0) { // If invoice exists and a line is selected.
1019 $invoice->deleteLine($idline);
1020 $invoice->fetch($placeid);
1021 } 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.
1022 $sql = "SELECT rowid FROM
".MAIN_DB_PREFIX."facturedet where fk_facture =
".((int) $placeid)." ORDER BY rowid DESC
";
1023 $resql = $db->query($sql);
1024 $obj = $db->fetch_object($resql);
1026 $deletelineid = $obj->rowid;
1027 $invoice->deleteLine($deletelineid);
1029 $invoice->fetch($placeid);
1034 if (count($invoice->lines) == 0) {
1035 // Keep an empty draft invoice alive when a non-default customer was
1036 // already attached so deleting the last line does not silently lose
1037 // the customer that was just selected (#38219). Only drop the invoice
1038 // when it is still on the default cashdesk thirdparty (or none).
1039 $defaultsocid = (int) getDolGlobalString('CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal
"]);
1040 $invoicesocid = (int) $invoice->socid;
1041 if ($invoicesocid === 0 || $invoicesocid === $defaultsocid) {
1042 $invoice->delete($user);
1044 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1045 header("Location:
".DOL_URL_ROOT."/takepos/public/auto_order.php
");
1047 header("Location:
".DOL_URL_ROOT."/takepos/invoice.php
");
1054 // Action to delete or discard an invoice
1055 if ($action == "delete
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1056 // $placeid is the invoice id (it differs from place) and is defined if the place is set and
1057 // the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal
"].'-'.$place.')', so the fetch at beginning of page works.
1059 $result = $invoice->fetch($placeid);
1061 if ($result > 0 && $invoice->status == Facture::STATUS_DRAFT) {
1064 // We delete the lines
1065 $resdeletelines = 1;
1066 foreach ($invoice->lines as $line) {
1067 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1068 $tmpres = $invoice->deleteLine($line->id);
1070 $resdeletelines = 0;
1075 $sql = "UPDATE
".MAIN_DB_PREFIX."facture
";
1076 $varforconst = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal
"];
1077 $sql .= " SET fk_soc =
".((int) getDolGlobalString($varforconst)).",
";
1078 $sql .= " datec =
'".$db->idate(dol_now())."'";
1079 $sql .= " WHERE entity IN (
".getEntity('invoice').")
";
1080 $sql .= " AND
ref =
'(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'";
1081 $resql1 = $db->query($sql);
1083 if ($resdeletelines && $resql1) {
1089 $invoice->fetch($placeid);
1094 if ($action == "updateqty
") { // Test on permission is done later
1095 foreach ($invoice->lines as $line) {
1096 if ($line->id == $idline) {
1097 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1098 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1099 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1100 $permissiontoupdateline = true;
1101 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1102 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1105 if (!$permissiontoupdateline) {
1106 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
").' - No permission to updateqty', [], 1);
1108 $vatratecode = $line->tva_tx;
1109 if ($line->vat_src_code) {
1110 $vatratecode .= ' ('.$line->vat_src_code.')';
1113 $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);
1118 $invoice->fetch($placeid);
1121 if ($action == "updateprice
") { // Test on permission is done later
1122 $customer = new Societe($db);
1123 $customer->fetch($invoice->socid);
1125 foreach ($invoice->lines as $line) {
1126 if ($line->id == $idline) {
1127 $prod = new Product($db);
1128 $prod->fetch($line->fk_product);
1129 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
1130 $price_min = $datapriceofproduct['price_min'];
1131 $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS'));
1133 $vatratecleaned = $line->tva_tx;
1135 if (preg_match('/^(.*)\s*\((.*)\)$/', (string) $line->tva_tx, $reg)) { // If vat is "xx (yy)
"
1136 $vatratecleaned = trim($reg[1]);
1137 //$vatratecode = $reg[2];
1140 $pu_ht = price2num((float) price2num($number, 'MU') / (1 + ((float) $vatratecleaned / 100)), 'MU');
1142 if ($usercanproductignorepricemin && (!empty($price_min) && ((float) price2num($pu_ht) * (1 - (float) price2num($line->remise_percent) / 100) < price2num($price_min)))) {
1143 $langs->load("products
");
1144 dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice
", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
1145 // echo $langs->trans("CantBeLessThanMinPrice
");
1147 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1148 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1149 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1150 $permissiontoupdateline = true;
1151 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1152 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1156 $vatratecode = $line->tva_tx;
1157 if ($line->vat_src_code) {
1158 $vatratecode .= ' ('.$line->vat_src_code.')';
1161 if (!$permissiontoupdateline) {
1162 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
").' - No permission to updateprice', [], 1);
1163 } elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) {
1164 $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);
1166 $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);
1173 $invoice->fetch($placeid);
1176 if ($action == "updatereduction
") { // Test on permission is done later
1177 $customer = new Societe($db);
1178 $customer->fetch($invoice->socid);
1180 foreach ($invoice->lines as $line) {
1181 if ($line->id == $idline) {
1182 dol_syslog("updatereduction Process line
".$line->id.' to apply discount of '.$number.'%');
1184 $prod = new Product($db);
1185 $prod->fetch($line->fk_product);
1187 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
1188 $price_min = $datapriceofproduct['price_min'];
1189 $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS'));
1191 $pu_ht = price2num($line->subprice / (1 + ($line->tva_tx / 100)), 'MU');
1194 if ($usercanproductignorepricemin && (!empty($price_min) && ((float) price2num($line->subprice) * (1 - (float) price2num($number) / 100) < (float) price2num($price_min)))) {
1195 $langs->load("products
");
1196 dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice
", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
1198 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1199 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1200 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1201 $permissiontoupdateline = true;
1202 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1203 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1206 if (!$permissiontoupdateline) {
1207 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
"), [], 1);
1209 $vatratecode = $line->tva_tx;
1210 if ($line->vat_src_code) {
1211 $vatratecode .= ' ('.$line->vat_src_code.')';
1213 $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);
1220 $invoice->fetch($placeid);
1221 } elseif ($action == 'update_reduction_global' && $user->hasRight('takepos', 'editlines')) {
1222 foreach ($invoice->lines as $line) {
1223 $vatratecode = $line->tva_tx;
1224 if ($line->vat_src_code) {
1225 $vatratecode .= ' ('.$line->vat_src_code.')';
1227 $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);
1230 $invoice->fetch($placeid);
1233 if ($action == "setbatch
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1234 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
1235 $warehouseid = (GETPOSTINT('warehouseid') > 0 ? GETPOSTINT('warehouseid') : getDolGlobalInt($constantforkey)); // Get the warehouse id from GETPOSTINT('warehouseid'), otherwise use default setup.
1236 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet SET batch =
'".$db->escape($batch)."', fk_warehouse =
".((int) $warehouseid);
1237 $sql .= " WHERE rowid =
".((int) $idoflineadded);
1241 if ($action == "order
" && $placeid != 0 && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1242 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1243 if ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1244 require_once DOL_DOCUMENT_ROOT.'/takepos/class/dolreceiptprinter.class.php';
1245 $printer = new dolReceiptPrinter($db);
1248 $sql = "SELECT label FROM
".MAIN_DB_PREFIX."takepos_floor_tables where rowid =
".((int) $place);
1249 $resql = $db->query($sql);
1250 $row = $db->fetch_object($resql);
1251 $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>';
1252 $footerorder = '</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>';
1253 $order_receipt_printer1 = "";
1254 $order_receipt_printer2 = "";
1255 $order_receipt_printer3 = "";
1256 $catsprinter1 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_1'));
1257 $catsprinter2 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_2'));
1258 $catsprinter3 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_3'));
1260 foreach ($invoice->lines as $line) {
1261 if ($line->special_code == "4
") {
1264 $c = new Categorie($db);
1265 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1266 $result = array_intersect($catsprinter1, $existing);
1267 $count = count($result);
1268 if (!$line->fk_product) {
1269 $count++; // Print Free-text item (Unassigned printer) to Printer 1
1273 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet set special_code=
'1' where rowid =
".((int) $line->id); //Set to print on printer 1
1275 $order_receipt_printer1 .= '<tr><td class="left
">';
1276 if ($line->fk_product) {
1277 $order_receipt_printer1 .= $line->product_label;
1279 $order_receipt_printer1 .= $line->description;
1281 $order_receipt_printer1 .= '</td><td class="right
">'.$line->qty;
1282 if (!empty($line->array_options['options_order_notes'])) {
1283 $order_receipt_printer1 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1285 $order_receipt_printer1 .= '</td></tr>';
1288 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0 && $printer !== null) {
1289 $invoice->fetch($placeid); //Reload object before send to printer
1290 $printer->orderprinter = 1;
1292 echo "var orderprinter1esc=
'";
1293 $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
1296 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'1' and fk_facture =
".((int) $invoice->id); // Set as printed
1298 $invoice->fetch($placeid); //Reload object after set lines as printed
1301 foreach ($invoice->lines as $line) {
1302 if ($line->special_code == "4
") {
1305 $c = new Categorie($db);
1306 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1307 $result = array_intersect($catsprinter2, $existing);
1308 $count = count($result);
1311 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'2' where rowid =
".((int) $line->id); //Set to print on printer 2
1313 $order_receipt_printer2 .= '<tr>'.$line->product_label.'<td class="right
">'.$line->qty;
1314 if (!empty($line->array_options['options_order_notes'])) {
1315 $order_receipt_printer2 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1317 $order_receipt_printer2 .= '</td></tr>';
1320 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0) {
1321 $invoice->fetch($placeid); //Reload object before send to printer
1322 $printer->orderprinter = 2;
1324 echo "var orderprinter2esc=
'";
1325 $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
1328 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'2' and fk_facture =
".((int) $invoice->id); // Set as printed
1330 $invoice->fetch($placeid); //Reload object after set lines as printed
1333 foreach ($invoice->lines as $line) {
1334 if ($line->special_code == "4
") {
1337 $c = new Categorie($db);
1338 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1339 $result = array_intersect($catsprinter3, $existing);
1340 $count = count($result);
1343 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'3' where rowid =
".((int) $line->id); //Set to print on printer 3
1345 $order_receipt_printer3 .= '<tr>'.$line->product_label.'<td class="right
">'.$line->qty;
1346 if (!empty($line->array_options['options_order_notes'])) {
1347 $order_receipt_printer3 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1349 $order_receipt_printer3 .= '</td></tr>';
1352 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0 && $printer !== null) {
1353 $invoice->fetch($placeid); //Reload object before send to printer
1354 $printer->orderprinter = 3;
1356 echo "var orderprinter3esc=
'";
1357 $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
1360 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'3' and fk_facture =
".((int) $invoice->id); // Set as printed
1362 $invoice->fetch($placeid); //Reload object after set lines as printed
1365 $sectionwithinvoicelink = '';
1366 if (($action == "valid
" || $action == "history
" || $action == 'creditnote' || ($action == 'addline' && $invoice->status == $invoice::STATUS_CLOSED)) && $user->hasRight('takepos', 'run')) {
1367 $sectionwithinvoicelink .= '<!-- Section with invoice link -->'."\n
";
1368 $sectionwithinvoicelink .= '<span style="font-size:120%;
" class="center
inline-block marginbottomonly
">';
1369 if ($invoice->status == $invoice::STATUS_DRAFT) {
1370 $sectionwithinvoicelink .= $invoice->ref;
1372 $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice');
1374 $sectionwithinvoicelink .= " -
";
1375 $remaintopay = $invoice->getRemainToPay();
1376 if ($remaintopay > 0) {
1377 $sectionwithinvoicelink .= $langs->trans('RemainToPay').': <span class="amountremaintopay
" style="font-size: unset
">'.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
1379 $sectionwithinvoicelink .= $invoice->getLibStatut(2);
1382 $sectionwithinvoicelink .= '</span><br>';
1384 $customprinterallowed = false;
1385 $customprinttemplateallowed = true;
1387 // BAR RESTAURANT specific menu
1388 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1389 // Button to print receipt before payment
1390 $customprinterallowed = true;
1391 $customprinttemplateallowed = true;
1394 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
1395 if (isALNERunningVersion()) {
1396 // Custom printer may be allowed if mandatory information in template are guaranteed. For the moment, we prefer not allow this.
1397 $customprinttemplateallowed = false;
1400 if ($invoice->status == $invoice::STATUS_CLOSED) {
1401 if (getDolGlobalInt('TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
1402 $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>';
1404 // This section should be same than into index.php
1405 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1406 // Used when the external addon takeposconnector is installed. Deprecated.
1407 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
1408 // If TAKEPOS_PRINT_SERVER is an URL
1409 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintByESCPOSOld(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1411 // If TAKEPOS_PRINT_SERVER is an IP
1412 // Print by calling the receipt.php to get HTML content and send the HTML content to TAKEPOS_PRINT_SERVER:8111/print
1413 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintHTMLToSlashPrint(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1415 } elseif ($customprinterallowed && $customprinttemplateallowed && (isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") { // @phpstan-ignore-line
1416 // Button Print Receipt on special custom printer using custom template
1417 $nameOfPrinter = dol_getIdFromCode($db, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term), 'printer_receipt', 'rowid', 'name', 1);
1418 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintByESCPOS(
'.$placeid.')
" title="'.dolPrintHTMLForAttribute($langs->trans("SentToPrinter").' '.$nameOfPrinter).'">'.$langs->trans('PrintTicket').'</button>';
1420 // Button Print Receipt on browser
1421 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintByBrowser(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1423 // Additional buttons
1424 if ($customprinttemplateallowed && getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) {
1425 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintBox(
'.$placeid.', \
'without_details\')">'.$langs->trans(
'PrintWithoutDetails').
'</button>';
1428 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="PrintByBrowser('.$placeid.
', 1)">'.$langs->trans(
'GiftReceipt').
'</button>';
1433 $sectionwithinvoicelink .=
' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.
')">'.$langs->trans(
'SendTicket').
'</button>';
1436 if ($remaintopay <= 0 &&
getDolGlobalString(
'TAKEPOS_AUTO_PRINT_TICKETS') && $action !=
"history") {
1437 $sectionwithinvoicelink .=
'<script type="text/javascript">console.log("Emulate click on #buttonprint"); $("#buttonprint").click();</script>';
1451if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1452 $title =
'TakePOS - Dolibarr '.DOL_VERSION;
1456 $head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
1457 <meta name="apple-mobile-web-app-capable" content="yes">
1458 <meta name="mobile-web-app-capable" content="yes">
1459 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
1460 $arrayofcss = array(
1461 '/takepos/css/pos.css.php',
1463 $arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
1466 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
1468 print
'<body>'.
"\n";
1475<script
type=
"text/javascript">
1478<?php
if ($action ==
"valid") {
1479 echo
"var place=0;";
1481var placeid=<?php echo($placeid > 0 ? $placeid : 0); ?>;
1482$(document).ready(
function() {
1483 var idoflineadded = <?php echo(empty($idoflineadded) ? 0 : $idoflineadded); ?>;
1485 $(
'.posinvoiceline').click(
function(){
1486 console.log(
"Click done on "+this.
id);
1487 $(
'.posinvoiceline').removeClass(
"selected");
1488 $(
this).addClass(
"selected");
1492 if (selectedline == this.
id) {
1495 selectedline = this.id;
1497 selectedtext=$(
'#'+selectedline).find(
"td:first").html();
1499 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1500 print
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?action=editline&token='.newToken().
'&placeid="+placeid+"&selectedline="+selectedline, function() {
1507 if (idoflineadded > 0)
1509 console.log(
"Auto select "+idoflineadded);
1510 $(
'.posinvoiceline#'+idoflineadded).click();
1514if ($action ==
"order" && !empty($order_receipt_printer1)) {
1515 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1519 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php',
1520 data:
'invoice='+orderprinter1esc
1527 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1529 print $headerorder.$order_receipt_printer1.$footerorder; ?>'
1535if ($action ==
"order" && !empty($order_receipt_printer2)) {
1536 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1540 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php?printer=2',
1541 data:
'invoice='+orderprinter2esc
1548 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print2',
1550 print $headerorder.$order_receipt_printer2.$footerorder; ?>'
1556if ($action ==
"order" && !empty($order_receipt_printer3)) {
1557 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1561 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php?printer=3',
1562 data:
'invoice='+orderprinter3esc
1569if ($action ==
"search" || $action ==
"valid") {
1571 parent.ClearSearch(
true);
1576if ($action ==
"temp" && !empty($ticket_printer1)) {
1580 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1582 print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>'
1587if ($action ==
"search") {
1589 $(
'#search').focus();
1597function SendTicket(
id)
1599 console.log(
"Open box to select the Print/Send form");
1600 $.colorbox({href:
"send.php?facid="+id, width:
"70%", height:
"30%", transition:
"none", iframe:
"true", title:
'<?php echo dol_escape_js($langs->trans("SendTicket")); ?>'});
1605function PrintBox(
id, action) {
1606 console.log(
"Open box before printing");
1607 $.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
"); ?>"});
1612function PrintByBrowser(
id, gift) {
1613 console.log(
"Call PrintByBrowser() to generate the receipt.");
1614 $.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")); ?>'});
1619function PrintHTMLToSlashPrint(
id){
1621 console.log(
"PrintHTMLToSlashPrint" +
id);
1622 $.get(
"receipt.php?facid="+
id,
function(data,
status) {
1623 receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,
'');
1626 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1634function PrintByESCPOSOld(
id){
1635 console.log(
"PrintByESCPOSOld id=" +
id);
1636 $.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) {
1639 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php',
1640 data:
'invoice='+data
1651function PrintByESCPOS(
id) {
1652 console.log(
"PrintByESCPOS Printing invoice ticket by calling takepos/aja/ajax.php id=" +
id);
1656 data: { token:
'<?php echo currentToken(); ?>' },
1657 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=printinvoiceticket&token='.currentToken().'&term='.urlencode(isset($_SESSION["takeposterminal
"]) ? $_SESSION["takeposterminal
"] : '').'&id='; ?>" + id,
1658 success:
function(){
1659 showPrintResultPopup(
'<?php echo dol_escape_js($langs->trans("SentToPrinter").' '.$nameOfPrinter); ?>', 2000);
1662 showPrintResultPopup(
"<?php echo dol_escape_js($langs->trans("FailedToSendToPrinter
")); ?>", 2000);
1669function showPrintResultPopup(message, duration) {
1670 $(
"#dialogforpopuptakepos").show().text(message).fadeIn();
1672 setTimeout(
function(){
1673 $(
"#dialogforpopuptakepos").fadeOut().hide();
1680function CreditNote() {
1681 $(
"#poslines").load(
"<?php print DOL_URL_ROOT; ?>/takepos/invoice.php?action=creditnote&token=<?php echo newToken() ?>&invoiceid="+placeid,
function() { });
1687 $(
"#poslines").load(
"<?php print DOL_URL_ROOT; ?>/takepos/invoice.php?action=addnote&token=<?php echo newToken() ?>&invoiceid="+placeid+
"&idline="+selectedline, {
"addnote": $(
"#textinput").val() });
1692$( document ).ready(
function() {
1693 console.log(
"Set customer info and sales in header placeid=<?php echo $placeid; ?> status=<?php echo $invoice->statut; ?>");
1696 $s = $langs->trans(
"Customer");
1697 if ($invoice->id > 0 && ($invoice->socid !=
getDolGlobalString($constforcompanyid))) {
1700 $contactids = $invoice->getIdContact(
'external',
'BILLING');
1701 $contactid = $contactids[0];
1702 if ($contactid > 0) {
1704 $contact->fetch($contactid);
1705 $s .=
" - " . $contact->getFullName($langs);
1709 print
'$("#idcustomer").val("");';
1713 $(
"#customerandsales").html(
'');
1714 $(
"#shoppingcart").html(
'');
1717 $(
"#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>');
1719 $(
"#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>');
1723 $sql =
"SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX.
"facture";
1724 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
1727 $sql .=
" AND ref LIKE '(PROV-POS".$db->escape(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'').
"-0%'";
1730 $sql .=
" AND pos_source = '".$db->escape((
string) $_SESSION[
"takeposterminal"]).
"'";
1731 $sql .=
" AND module_source = 'takepos'";
1734 $sql .=
$db->order(
'datec',
'ASC');
1735 $resql =
$db->query($sql);
1738 while ($obj =
$db->fetch_object($resql)) {
1739 echo
'$("#shoppingcart").append(\'';
1740 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=\\\'';
1741 $num_sale = str_replace(
")",
"", str_replace(
"(PROV-POS".$_SESSION[
"takeposterminal"].
"-",
"", $obj->ref));
1743 if (str_replace(
"-",
"", $num_sale) > $max_sale) {
1744 $max_sale = str_replace(
"-",
"", $num_sale);
1746 echo
'\\\'; invoiceid=\\\'';
1748 echo
'\\\'; Refresh();">';
1749 if ($placeid == $obj->rowid) {
1750 echo
'<span class="basketselected">';
1752 echo
'<span class="basketnotselected">';
1754 echo
'<span class="fa fa-shopping-cart paddingright"></span>'.dol_print_date(
$db->jdate($obj->datec),
'%H:%M',
'tzuser');
1758 echo
'$("#shoppingcart").append(\'<a onclick="place=\\\'0-';
1760 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>\');';
1768 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1771 $constantforkey =
'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1773 if ($idwarehouse > 0) {
1774 $s =
'<span class="small">';
1776 $warehouse->fetch($idwarehouse);
1777 $s .=
'<span class="hideonsmartphone">'.$langs->trans(
"Warehouse").
'<br></span>'.$warehouse->ref;
1779 $s .=
' ('.$langs->trans(
"Closed").
')';
1782 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1783 print
'$("#infowarehouse").css("display", "inline-block");';
1785 $s =
'<span class="small hideonsmartphone">';
1786 $s .= $langs->trans(
"StockChangeDisabled").
'<br>'.$langs->trans(
"NoWarehouseDefinedForTerminal");
1788 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1789 if (!empty(
$conf->dol_optimize_smallscreen)) {
1790 print
'$("#infowarehouse").css("display", "none");';
1794 $s =
'<span class="small hideonsmartphone">'.$langs->trans(
"StockChangeDisabled").
'</span>';
1795 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1796 if (!empty(
$conf->dol_optimize_smallscreen)) {
1797 print
'$("#infowarehouse").css("display", "none");';
1806 $s =
'<span class="small">';
1807 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1808 $langs->load(
"members");
1809 $s .= $langs->trans(
"Member").
': ';
1811 $result = $adh->fetch(0,
'', $invoice->socid);
1813 $adh->ref = $adh->getFullName($langs);
1817 $s .= $adh->getFullName($langs);
1818 $s .=
' - '.$adh->type;
1819 if ($adh->datefin) {
1820 $s .=
'<br>'.$langs->trans(
"SubscriptionEndDate").
': '.
dol_print_date($adh->datefin,
'day');
1821 if ($adh->hasDelay()) {
1822 $s .=
" ".img_warning($langs->trans(
"Late"));
1825 $s .=
'<br>'.$langs->trans(
"SubscriptionNotReceived");
1826 if ($adh->status > 0) {
1827 $s .=
" ".img_warning($langs->trans(
"Late"));
1834 $s .=
'<br>'.$langs->trans(
"ThirdpartyNotLinkedToMember");
1839 $(
"#moreinfo").html(
'<?php print dol_escape_js($s); ?>');
1846 echo
"function CustomerDisplay(){";
1847 echo
"var line1='".$CUSTOMER_DISPLAY_line1.
"'.substring(0,20);";
1848 echo
"line1=line1.padEnd(20);";
1849 echo
"var line2='".$CUSTOMER_DISPLAY_line2.
"'.substring(0,20);";
1850 echo
"line2=line2.padEnd(20);";
1852 echo
'webSocketCustomerDisplay.send(line1);';
1853 echo
'webSocketCustomerDisplay.send(line2);';
1857 data: { text: line1+line2 },
1858 url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER').
"/display/index.php',
1870if (!empty(
$conf->use_javascript_ajax)) {
1871 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
1872 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.
'"></script>'.
"\n";
1875$usediv = (
GETPOST(
'format') ==
'div');
1877print
'<!-- 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";
1878print
'<div class="div-table-responsive-no-min invoice">';
1880 print
'<div id="tablelines">';
1882 print
'<table id="tablelines" class="noborder noshadow postablelines centpercent">';
1885$buttontocreatecreditnote =
'';
1886if (($action ==
"valid" || $action ==
"history" || $action ==
"addline")
1888 $buttontocreatecreditnote .=
' <!-- Show button to create a credit note -->'.
"\n";
1889 $buttontocreatecreditnote .=
'<button id="buttonprint" type="button" onclick="ModalBox(\'ModalCreditNote\')">'.$langs->trans(
'CreateCreditNote').
'</button>';
1890 if (
getDolGlobalInt(
'TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
1891 $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>';
1896if ($sectionwithinvoicelink && ($mobilepage ==
"invoice" || $mobilepage ==
"")) {
1897 print
'<!-- Print table line with link to invoice ref -->';
1899 print
'<tr><td colspan="5" class="paddingtopimp paddingbottomimp" style="padding-top: 10px !important; padding-bottom: 10px !important;">';
1900 print $sectionwithinvoicelink;
1901 print $buttontocreatecreditnote;
1904 print
'<tr><td colspan="4" class="paddingtopimp paddingbottomimp" style="padding-top: 10px !important; padding-bottom: 10px !important;">';
1905 print $sectionwithinvoicelink;
1906 print $buttontocreatecreditnote;
1913 print
'<tr class="liste_titre nodrag nodrop">';
1914 print
'<td class="linecoldescription">';
1917if (empty($mobilepage) || $mobilepage ==
"invoice") {
1918 print
'<!-- hidden var used by some js functions -->';
1919 print
'<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.
'">';
1920 print
'<input type="hidden" name="thirdpartyid" id="thirdpartyid" value="'.$invoice->socid.
'">';
1924 $sql =
"SELECT floor, label FROM ".MAIN_DB_PREFIX.
"takepos_floor_tables where rowid = ".((int) $place);
1925 $resql =
$db->query($sql);
1926 $obj =
$db->fetch_object($resql);
1928 $label = $obj->label;
1929 $floor = $obj->floor;
1931 if ($mobilepage ==
"invoice" || $mobilepage ==
"") {
1934 print
'<span class="opacitymedium">'.$langs->trans(
'Place').
"</span> <b>".(empty($label) ?
'?' : $label).
"</b><br>";
1935 print
'<span class="opacitymedium">'.$langs->trans(
'Floor').
"</span> <b>".(empty($floor) ?
'?' : $floor).
"</b>";
1942$parameters = array();
1943$reshook = $hookmanager->executeHooks(
'completeTakePosInvoiceHeader', $parameters, $invoice, $action);
1947print $hookmanager->resPrint;
1949if (empty($_SESSION[
"basiclayout"]) || $_SESSION[
"basiclayout"] != 1) {
1951 print
'<td class="linecolqty right">'.$langs->trans(
'PriceUHT').
'</td>';
1953 print
'<td class="linecolqty right">'.$langs->trans(
'ReductionShort').
'</td>';
1954 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
1956 print
'<td class="linecolht right nowraponall">';
1957 print
'<span class="opacitymedium small">' . $langs->trans(
'TotalHTShort') .
'</span><br>';
1959 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1960 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>';
1961 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"]) &&
$conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
1963 include_once DOL_DOCUMENT_ROOT .
'/multicurrency/class/multicurrency.class.php';
1965 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
1966 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>';
1971 print
'<td class="linecolht right nowraponall">';
1972 print
'<span class="opacitymedium small">'.$langs->trans(
'TotalTTCShort').
'</span><br>';
1974 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1975 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>';
1976 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"]) &&
$conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
1978 include_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
1980 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
1981 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>';
1985} elseif ($mobilepage ==
"invoice") {
1986 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
1992if (!empty($_SESSION[
"basiclayout"]) && $_SESSION[
"basiclayout"] == 1) {
1993 if ($mobilepage ==
"cats") {
1994 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1996 $categories = $categorie->get_full_arbo(
'product');
1998 foreach ($categories as $row) {
1999 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2000 $htmlforlines .=
'<div class="leftcat"';
2002 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline"';
2004 $htmlforlines .=
' onclick="LoadProducts('.$row[
'id'].
');">';
2005 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2006 $htmlforlines .=
'<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=cat&query=cat&id='.$row[
'id'].
'"><br>';
2008 $htmlforlines .=
'<td class="left">';
2010 $htmlforlines .= $row[
'label'];
2011 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2012 $htmlforlines .=
'</div>'.
"\n";
2014 $htmlforlines .=
'</td></tr>'.
"\n";
2017 print $htmlforlines;
2020 if ($mobilepage ==
"products") {
2021 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2024 $result =
$object->fetch($catid);
2025 $prods =
$object->getObjectsInCateg(
"product");
2027 '@phan-var-force Product[] $prods';
2029 foreach ($prods as $row) {
2030 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2031 $htmlforlines .=
'<div class="leftcat"';
2033 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline"';
2035 $htmlforlines .=
' onclick="AddProduct(\''.$place.
'\',
'.$row->id.')
"';
2036 $htmlforlines .= '>';
2037 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2038 $htmlforlines .= '<img class="imgwrapper
" width="33%
" src="'.DOL_URL_ROOT.'/takepos/
public/auto_order.php?genimg=pro&query=pro&
id=
'.$row->id.'"><br>';
2039 $htmlforlines .= $row->label.' '.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency);
2040 $htmlforlines .= '</div>'."\n
";
2042 $htmlforlines .= '<td class="left
">';
2043 $htmlforlines .= $row->label;
2044 $htmlforlines .= '<div class="right
">'.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).'</div>';
2045 $htmlforlines .= '</td>';
2046 $htmlforlines .= '</tr>'."\n
";
2049 print $htmlforlines;
2052 if ($mobilepage == "places
") {
2053 $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM
".MAIN_DB_PREFIX."takepos_floor_tables
";
2054 $resql = $db->query($sql);
2058 while ($row = $db->fetch_array($resql)) {
2060 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
2061 $htmlforlines .= '" onclick="LoadPlace(\
''.$row[
'label'].
'\')
">';
2062 $htmlforlines .= '<td class="left
">';
2063 $htmlforlines .= $row['label'];
2064 $htmlforlines .= '</td>';
2065 $htmlforlines .= '</tr>'."\n
";
2067 print $htmlforlines;
2072 //In Phone basic layout hide some content depends situation
2073 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1 && $mobilepage != "invoice
" && $action != "order
") {
2077 // Loop on each lines on invoice
2078 if (is_array($invoice->lines) && count($invoice->lines)) {
2079 print '<!-- invoice.php show lines of invoices -->'."\n
";
2080 $tmplines = array_reverse($invoice->lines);
2081 $htmlsupplements = array();
2082 foreach ($tmplines as $line) {
2083 if ($line->fk_parent_line != false) {
2084 $htmlsupplements[$line->fk_parent_line] .= '<tr class="drag drop oddeven posinvoiceline
';
2085 if ($line->special_code == "4") {
2086 $htmlsupplements[$line->fk_parent_line] .= ' order
';
2088 $htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'"';
2089 if ($line->special_code == "4
") {
2090 $htmlsupplements[$line->fk_parent_line] .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
2092 $htmlsupplements[$line->fk_parent_line] .= '>';
2093 $htmlsupplements[$line->fk_parent_line] .= '<td class="left
">';
2094 $htmlsupplements[$line->fk_parent_line] .= img_picto('', 'rightarrow.png');
2095 if ($line->product_label) {
2096 $htmlsupplements[$line->fk_parent_line] .= $line->product_label;
2098 if ($line->product_label && $line->desc) {
2099 $htmlsupplements[$line->fk_parent_line] .= '<br>';
2101 if ($line->product_label != $line->desc) {
2102 $firstline = dolGetFirstLineOfText($line->desc);
2103 if ($firstline != $line->desc) {
2104 $htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
2106 $htmlsupplements[$line->fk_parent_line] .= $line->desc;
2109 $htmlsupplements[$line->fk_parent_line] .= '</td>';
2111 // complete line by hook
2112 $parameters = array('line' => $line);
2113 $reshook = $hookmanager->executeHooks('completeTakePosInvoiceParentLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
2115 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2117 $htmlsupplements[$line->fk_parent_line] .= $hookmanager->resPrint;
2119 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2120 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.vatrate(price2num($line->remise_percent), true).'</td>';
2121 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.$line->qty.'</td>';
2122 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.price($line->total_ttc).'</td>';
2124 $htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n
";
2129 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
2130 if ($line->special_code == "4") {
2131 $htmlforlines .= ' order
';
2133 $htmlforlines .= '" id="'.$line->id.'"';
2134 if ($line->special_code == "4
") {
2135 $htmlforlines .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
2137 $htmlforlines .= '>';
2138 $htmlforlines .= '<td class="left
">';
2139 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
2140 $htmlforlines .= '<span class="phoneqty
">'.$line->qty."</span> x
";
2142 if (isset($line->product_type)) {
2143 if (empty($line->product_type)) {
2144 $htmlforlines .= img_object('', 'product').' ';
2146 $htmlforlines .= img_object('', 'service').' ';
2150 if (!getDolGlobalString('TAKEPOS_SHOW_N_FIRST_LINES')) {
2151 if ($line->product_ref) {
2152 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
2153 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
2154 if (!empty($line->batch)) {
2155 $tooltiptext .= '<br><b>'.$langs->trans("LotSerial
").'</b> : '.$line->batch.'<br>';
2157 if (!empty($line->fk_warehouse)) {
2158 $tooltiptext .= '<b>'.$langs->trans("Warehouse
").'</b> : '.$line->fk_warehouse.'<br>';
2160 if ($line->product_label != $line->desc) {
2162 $tooltiptext .= '<br>';
2164 $tooltiptext .= $line->desc;
2167 if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
2168 $htmlforlines .= $form->textwithpicto($line->product_label ? '<b>' . $line->product_ref . '</b> - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
2169 } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) {
2170 $htmlforlines .= $form->textwithpicto($line->product_ref ? '<b>'.$line->product_ref.'<b>' : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
2172 $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
2175 if ($line->product_ref) {
2176 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
2177 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
2179 if (!empty($line->batch)) {
2180 $tooltiptext .= '<br><b>'.$langs->trans("LotSerial
").'</b> : '.$line->batch.'<br>';
2182 if (!empty($line->fk_warehouse)) {
2183 $tooltiptext .= '<b>'.$langs->trans("Warehouse
").'</b> : '.$line->fk_warehouse.'<br>';
2186 if ($line->product_label) {
2187 $htmlforlines .= $line->product_label;
2189 if ($line->product_label != $line->desc) {
2190 if ($line->product_label && $line->desc) {
2191 $htmlforlines .= '<br>';
2193 $firstline = dolGetFirstLineOfText($line->desc, getDolGlobalInt('TAKEPOS_SHOW_N_FIRST_LINES'));
2194 if ($firstline != $line->desc) {
2195 $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
2197 $htmlforlines .= $line->desc;
2201 if (!empty($line->array_options['options_order_notes'])) {
2202 $htmlforlines .= "<br>(
".$line->array_options['options_order_notes'].")
";
2204 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
2205 $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>';
2207 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2208 // Set the content of tooltip
2210 $moreinfo .= $langs->trans("VATRate
").': '.price($line->tva_tx).' %<br>';
2211 $moreinfo .= $langs->trans("UnitPrice
").': '.price($line->subprice).'<br>';
2212 $moreinfo .= '<br>';
2213 $moreinfo .= $langs->transcountry("TotalHT
", $mysoc->country_code).': '.price($line->total_ht);
2214 if ($line->vat_src_code) {
2215 $moreinfo .= '<br>'.$langs->trans("VATCode
").': '.$line->vat_src_code;
2217 $moreinfo .= '<br>'.$langs->trans("TotalVAT
").': '.price($line->total_tva);
2218 if ($mysoc->useLocalTax(1, 1, $mysoc)) {
2219 $moreinfo .= '<br>'.$langs->transcountry("TotalLT1
", $mysoc->country_code).': '.price($line->total_localtax1);
2221 if ($mysoc->useLocalTax(2, 1, $mysoc)) {
2222 $moreinfo .= '<br>'.$langs->transcountry("TotalLT2
", $mysoc->country_code).': '.price($line->total_localtax2);
2224 $moreinfo .= '<hr>';
2225 $moreinfo .= $langs->transcountry("TotalTTC
", $mysoc->country_code).': '.price($line->total_ttc);
2226 //$moreinfo .= $langs->trans("TotalHT
").': '.$line->total_ht;
2227 if ($line->date_start || $line->date_end) {
2228 $htmlforlines .= '<br><div class="clearboth nowraponall
">'.get_date_range($line->date_start, $line->date_end).'</div>';
2230 $htmlforlines .= '</td>';
2232 // complete line by hook
2233 $parameters = array('line' => $line);
2234 $reshook = $hookmanager->executeHooks('completeTakePosInvoiceLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
2236 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2238 $htmlforlines .= $hookmanager->resPrint;
2240 if (getDolGlobalInt("TAKEPOS_SHOW_SUBPRICE
")) {
2241 $htmlforlines .= '<td class="right
">'.price($line->subprice).'</td>';
2243 $htmlforlines .= '<td class="right
">'.vatrate(price2num($line->remise_percent), true).'</td>';
2244 $htmlforlines .= '<td class="right
">';
2245 $htmlforlines .= $line->qty;
2246 if (isModEnabled('stock') && $user->hasRight('stock', 'mouvement', 'lire')) {
2247 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
2248 if (getDolGlobalString($constantforkey) && $line->fk_product > 0 && !getDolGlobalString('TAKEPOS_HIDE_STOCK_ON_LINE')) {
2249 $productChildrenNb = 0;
2250 if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
2251 if (empty($line->product) || !($line->product->id > 0)) {
2252 $line->fetch_product();
2254 if (!empty($line->product)) {
2255 $productChildrenNb = $line->product->hasFatherOrChild(1);
2258 if ($productChildrenNb == 0) {
2259 $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp
";
2260 $sql .= " FROM
".MAIN_DB_PREFIX."entrepot as e,
";
2261 $sql .= " ".MAIN_DB_PREFIX."product_stock as ps
";
2262 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product
";
2263 $sql .= " WHERE ps.reel != 0
";
2264 $sql .= " AND ps.fk_entrepot =
".((int) getDolGlobalString($constantforkey));
2265 $sql .= " AND e.entity IN (
".getEntity('stock').")
";
2266 $sql .= " AND ps.fk_product =
".((int) $line->fk_product);
2267 $resql = $db->query($sql);
2270 $obj = $db->fetch_object($resql);
2272 $stock_real = price2num($obj->reel, 'MS');
2274 $htmlforlines .= ' ';
2275 $htmlforlines .= '<span class="opacitylow
" title="'.$langs->trans("Stock").' '.price($stock_real, 1, '', 1, 0).'">';
2276 $htmlforlines .= '(';
2277 if ($line->qty && $line->qty > $stock_real) {
2278 $htmlforlines .= '<span style="color: var(--amountremaintopaycolor)
">';
2280 $htmlforlines .= img_picto('', 'stock', 'class="pictofixedwidth
"').price($stock_real, 1, '', 1, 0);
2281 if ($line->qty && $line->qty > $stock_real) {
2282 $htmlforlines .= "</span>
";
2284 $htmlforlines .= ')';
2285 $htmlforlines .= '</span>';
2287 dol_print_error($db);
2293 $htmlforlines .= '</td>';
2294 if (getDolGlobalInt('TAKEPOS_SHOW_HT')) {
2295 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
2296 $htmlforlines .= price($line->total_ht, 1, '', 1, -1, -1, $conf->currency);
2297 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
2298 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
2299 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
2300 $multicurrency = new MultiCurrency($db);
2301 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
2302 $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>';
2304 $htmlforlines .= '</td>';
2306 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
2307 $htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency);
2308 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
2309 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
2310 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
2311 $multicurrency = new MultiCurrency($db);
2312 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
2313 $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>';
2315 $htmlforlines .= '</td>';
2317 $htmlforlines .= '</tr>'."\n
";
2318 $htmlforlines .= empty($htmlsupplements[$line->id]) ? '' : $htmlsupplements[$line->id];
2320 print $htmlforlines;
2323 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td>';
2324 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2325 print '<td></td><td></td>';
2326 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
2332} else { // No invoice generated yet
2333 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td>';
2334 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2335 print '<td></td><td></td>';
2336 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
2349if ($action == "search
") {
2351 <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
')).'">
2358if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2359 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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
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.