35if (!defined(
'NOTOKENRENEWAL')) {
36 define(
'NOTOKENRENEWAL',
'1');
38if (!defined(
'NOREQUIREMENU')) {
39 define(
'NOREQUIREMENU',
'1');
41if (!defined(
'NOREQUIREHTML')) {
42 define(
'NOREQUIREHTML',
'1');
44if (!defined(
'NOREQUIREAJAX')) {
45 define(
'NOREQUIREAJAX',
'1');
49if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
50 require
'../main.inc.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
66$hookmanager->initHooks(array(
'takeposinvoice'));
68$langs->loadLangs(array(
"companies",
"commercial",
"bills",
"cashdesk",
"stocks",
"banks"));
70$action =
GETPOST(
'action',
'aZ09');
74$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');
124function fail($message)
126 header($_SERVER[
'SERVER_PROTOCOL'].
' 500 Internal Server Error',
true, 500);
135$desc =
GETPOST(
'desc',
'alphanohtml');
148if ($pay ==
'cheque') {
155 $sql =
"SELECT id, code FROM ".MAIN_DB_PREFIX.
"c_paiement";
156 $sql .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
157 $sql .=
" AND code = '".$db->escape($paycode).
"'";
158 $resql = $db->query($sql);
160 $obj = $db->fetch_object($resql);
162 $paiementid = $obj->id;
169 $ret = $invoice->fetch($invoiceid);
171 $ret = $invoice->fetch(0,
'(PROV-POS'.$takeposterminal.
'-'.$place.
')');
174 $placeid = $invoice->id;
177$constforcompanyid =
'CASHDESK_ID_THIRDPARTY'.$takeposterminal;
180if ($invoice->socid > 0) {
181 $soc->fetch($invoice->socid);
188 $invoice->fk_project =
getDolGlobalInt(
"CASHDESK_ID_PROJECT".$takeposterminal);
192if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"])) {
193 if ($invoice->multicurrency_code != $_SESSION[
"takeposcustomercurrency"]) {
194 $invoice->setMulticurrencyCode($_SESSION[
"takeposcustomercurrency"]);
198$term = empty($_SESSION[
"takeposterminal"]) ? 1 : $_SESSION[
"takeposterminal"];
205$parameters = array();
206$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $invoice, $action);
212$sectionwithinvoicelink =
'';
213$CUSTOMER_DISPLAY_line1 =
'';
214$CUSTOMER_DISPLAY_line2 =
'';
223if (in_array($action, array(
'deleteline',
'updateqty',
'updateprice',
'updatereduction',
'update_reduction_global')) && !$user->hasRight(
'takepos',
'editlines')) {
229if (empty($reshook)) {
231 if ($action ==
'valid' && $user->hasRight(
'facture',
'creer')) {
239 $bankaccount =
getDolGlobalInt(
'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION[
"takeposterminal"]);
240 } elseif ($pay ==
"CHQ") {
241 $bankaccount =
getDolGlobalInt(
'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION[
"takeposterminal"]);
243 $accountname =
"CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION[
"takeposterminal"];
248 if ($bankaccount <= 0 && $pay !=
"delayed" &&
isModEnabled(
"bank")) {
249 $errormsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount"));
257 $invoice->fetch($placeid);
263 $invoice->oldcopy =
dol_clone($invoice, 2);
267 if ($invoice->total_ttc < 0) {
268 $invoice->type = $invoice::TYPE_CREDIT_NOTE;
270 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
271 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
272 $sql .=
" AND fk_soc = ".((int) $invoice->socid);
273 $sql .=
" AND type <> ".Facture::TYPE_CREDIT_NOTE;
274 $sql .=
" AND fk_statut >= ".$invoice::STATUS_VALIDATED;
275 $sql .=
" ORDER BY rowid DESC";
278 $resql = $db->query($sql);
280 $obj = $db->fetch_object($resql);
281 $fk_source = $obj->rowid;
282 if ((
int) $fk_source == 0) {
283 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
286 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
288 $invoice->fk_facture_source = $fk_source;
289 $invoice->update($user);
292 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
299 $remaintopay = $invoice->getRemainToPay();
306 } elseif (count($invoice->lines) == 0) {
315 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
317 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
318 dol_syslog(
"Validate invoice with stock change. Warehouse defined into constant ".$constantforkey.
" = ".
getDolGlobalString($constantforkey));
323 $res = $invoice->validate($user,
'',
getDolGlobalInt($constantforkey), 0, $batch_rule);
326 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
329 dol_syslog(
"Call validate on invoice ".$invoice->ref, LOG_DEBUG);
330 $res = $invoice->validate($user);
333 $langs->load(
"admin");
334 dol_htmloutput_errors($invoice->error ==
'NotConfigured' ? $langs->trans(
"NotConfigured").
' (TakePos numbering module)' : $invoice->error, $invoice->errors, 1);
339 if (!$error && $res >= 0) {
340 $remaintopay = $invoice->getRemainToPay();
345 $payment->datepaye = $now;
346 $payment->fk_account = $bankaccount;
351 $payment->amounts[$invoice->id] = $amountofpayment;
354 if ($amountofpayment <= 0 || $amountofpayment > $remaintopay) {
355 $payment->amounts[$invoice->id] = $remaintopay;
359 $payment->paiementid = $paiementid;
360 $payment->paiementcode = $paycode;
361 $payment->num_payment =
'';
363 if ($pay !=
"delayed") {
364 $res = $payment->create($user);
371 if (!empty($payment->warnings)) {
375 $res = $payment->addPaymentToBank($user,
'payment',
'(CustomerInvoicePayment)', $bankaccount,
'',
'');
378 dol_htmloutput_mesg($langs->trans(
'ErrorNoPaymentDefined').
' '.$payment->error, $payment->errors,
'error', 1);
381 $remaintopay = $invoice->getRemainToPay();
387 if ($remaintopay == 0) {
388 dol_syslog(
"Invoice is paid, so we set it to status Paid");
389 $result = $invoice->setPaid($user);
392 $invoice->status = $invoice::STATUS_CLOSED;
393 $invoice->close_code =
'';
396 $invoice->setPaymentMethods($paiementid);
398 dol_syslog(
"Invoice is not paid, remain to pay = ".$remaintopay);
407 if (!$error && $res >= 0) {
410 dol_syslog(
"Now we record the stock movement for each qualified line");
413 require_once DOL_DOCUMENT_ROOT .
"/product/stock/class/mouvementstock.class.php";
414 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
417 $labeltakeposmovement =
'TakePOS - '.$langs->trans(
"Invoice").
' '.$invoice->ref;
419 foreach ($invoice->lines as $line) {
421 $warehouseid = ($line->fk_warehouse ? $line->fk_warehouse :
getDolGlobalInt($constantforkey));
424 if ($line->batch !=
'' && $warehouseid > 0) {
426 $prod_batch->find(0,
'',
'', $line->batch, $warehouseid, (
int) $line->fk_product);
429 $mouvP->setOrigin($invoice->element, $invoice->id);
431 $res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'', $prod_batch->batch, $prod_batch->id, $inventorycode);
438 $mouvP->setOrigin($invoice->element, $invoice->id);
440 $res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'',
'', 0, $inventorycode);
450 if (!$error && $res >= 0) {
453 $invoice->ref = $invoice->oldcopy->ref;
454 $invoice->paye = $invoice->oldcopy->paye;
455 $invoice->status = $invoice->oldcopy->status;
456 $invoice->statut = $invoice->oldcopy->statut;
462 if ($action ==
'creditnote' && $user->hasRight(
'facture',
'creer')) {
465 $creditnote =
new Facture($db);
466 $creditnote->socid = $invoice->socid;
468 $creditnote->module_source =
'takepos';
469 $creditnote->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
471 $creditnote->fk_facture_source = $placeid;
474 $creditnote->create($user);
478 foreach ($invoice->lines as $line) {
480 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
485 if (!empty($invoice->situation_counter)) {
486 $source_fk_prev_id = $line->fk_prev_id;
487 $line->fk_prev_id = $line->id;
488 if (!empty($invoice->tab_previous_situation_invoice)) {
491 $tab_jumped_credit_notes = array();
492 $lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
493 $searchPreviousInvoice =
true;
494 while ($searchPreviousInvoice) {
495 if ($invoice->tab_previous_situation_invoice[$lineIndex]->situation_cycle_ref || $lineIndex < 1) {
496 $searchPreviousInvoice =
false;
500 $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id;
506 $maxPrevSituationPercent = 0;
507 foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
508 if ($prevLine->id == $source_fk_prev_id) {
509 $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
512 $line->total_ht -= $prevLine->total_ht;
513 $line->total_tva -= $prevLine->total_tva;
514 $line->total_ttc -= $prevLine->total_ttc;
515 $line->total_localtax1 -= $prevLine->total_localtax1;
516 $line->total_localtax2 -= $prevLine->total_localtax2;
518 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
519 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
520 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
521 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
526 $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
531 $maxPrevSituationPercent = 0;
532 foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
533 foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) {
534 if ($prevLine->fk_prev_id == $source_fk_prev_id) {
535 $maxPrevSituationPercent = $prevLine->situation_percent;
537 $line->total_ht -= $prevLine->total_ht;
538 $line->total_tva -= $prevLine->total_tva;
539 $line->total_ttc -= $prevLine->total_ttc;
540 $line->total_localtax1 -= $prevLine->total_localtax1;
541 $line->total_localtax2 -= $prevLine->total_localtax2;
543 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
544 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
545 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
546 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
552 $line->situation_percent += $maxPrevSituationPercent;
560 $line->fk_facture = $creditnote->id;
561 $line->fk_parent_line = $fk_parent_line;
563 $line->subprice = -$line->subprice;
565 $line->total_ht = -$line->total_ht;
566 $line->total_tva = -$line->total_tva;
567 $line->total_ttc = -$line->total_ttc;
568 $line->total_localtax1 = -$line->total_localtax1;
569 $line->total_localtax2 = -$line->total_localtax2;
571 $line->multicurrency_subprice = -$line->multicurrency_subprice;
572 $line->multicurrency_total_ht = -$line->multicurrency_total_ht;
573 $line->multicurrency_total_tva = -$line->multicurrency_total_tva;
574 $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
576 $result = $line->insert(0, 1);
578 $creditnote->lines[] = $line;
581 if ($result > 0 && $line->product_type == 9) {
582 $fk_parent_line = $result;
585 $creditnote->update_price(1);
589 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
596 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
598 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
600 dol_syslog(
"Validate invoice with stock change into warehouse defined into constant ".$constantforkey.
" = ".
getDolGlobalString($constantforkey).
" or warehouseid= ".$warehouseid.
" if defined.");
605 $res = $creditnote->validate($user,
'',
getDolGlobalInt($constantforkey), 0, $batch_rule);
612 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
614 $res = $creditnote->validate($user);
618 if (!$error && $res >= 0) {
621 dol_syslog(
"Now we record the stock movement for each qualified line");
624 require_once DOL_DOCUMENT_ROOT .
"/product/stock/class/mouvementstock.class.php";
625 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
628 $labeltakeposmovement =
'TakePOS - '.$langs->trans(
"CreditNote").
' '.$creditnote->ref;
630 foreach ($creditnote->lines as $line) {
632 $warehouseid = ($line->fk_warehouse ? $line->fk_warehouse :
getDolGlobalInt($constantforkey));
635 if ($line->batch !=
'' && $warehouseid > 0) {
640 $mouvP->setOrigin($creditnote->element, $creditnote->id);
642 $res = $mouvP->reception($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'', $line->batch,
'', 0, $inventorycode);
649 $mouvP->setOrigin($creditnote->element, $creditnote->id);
651 $res = $mouvP->reception($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'',
'', 0, $inventorycode);
661 if (!$error && $res >= 0) {
664 $creditnote->id = $placeid;
669 if (($action ==
'history' || $action ==
'creditnote') && $user->hasRight(
'takepos',
'run')) {
670 if ($action ==
'creditnote' && $creditnote !==
null && $creditnote->id > 0) {
671 $placeid = $creditnote->id;
677 $invoice->fetch($placeid);
681 if ($invoice->socid > 0) {
682 $soc->fetch($invoice->socid);
689 if (($action ==
"addline" || $action ==
"freezone") && $placeid == 0 && ($user->hasRight(
'takepos',
'run') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
692 $dolnowtzuserrel =
dol_now(
'tzuserrel');
696 $dateinvoice =
dol_mktime(0, 0, 0, (
int) $monthuser, (
int) $dayuser, (
int) $yearuser,
'tzserver');
698 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
699 $invoice->date = $dateinvoice;
713 $invoice->module_source =
'takepos';
714 $invoice->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
715 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] : $conf->entity;
717 if ($invoice->socid <= 0) {
718 $langs->load(
'errors');
724 $placeid = $invoice->create($user);
729 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture";
730 $sql .=
" SET ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
731 $sql .=
" WHERE rowid = ".((int) $placeid);
732 $resql = $db->query($sql);
747 if ($action ==
"addline" && ($user->hasRight(
'takepos',
'run') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
749 $prod->fetch($idproduct);
752 $customer->fetch($invoice->socid);
754 $datapriceofproduct = $prod->getSellPrice(
$mysoc, $customer, 0);
757 $price = $datapriceofproduct[
'pu_ht'];
758 $price_ttc = $datapriceofproduct[
'pu_ttc'];
760 $price_base_type = empty($datapriceofproduct[
'price_base_type']) ?
'HT' : $datapriceofproduct[
'price_base_type'];
761 $tva_tx = $datapriceofproduct[
'tva_tx'];
762 $tva_npr = (int) $datapriceofproduct[
'tva_npr'];
770 $batch =
GETPOST(
'batch',
'alpha');
772 if (!empty($batch)) {
773 $action =
"setbatch";
774 } elseif ($prod->status_batch > 0) {
779 $prod->load_stock(
'warehouseopen');
781 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
785 foreach ($prod->stock_warehouse as $tmpwarehouseid => $tmpval) {
790 if (!empty($prod->stock_warehouse[$tmpwarehouseid]) && is_array($prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
791 if (is_object($prod->stock_warehouse[$tmpwarehouseid]) && count($prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
792 foreach ($prod->stock_warehouse[$tmpwarehouseid]->detail_batch as $dbatch) {
801 echo
"function addbatch(batch, warehouseid) {\n";
802 echo
"console.log('We add batch '+batch+' from warehouse id '+warehouseid);\n";
803 echo
'$("#poslines").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?action=addline&batch="+encodeURI(batch)+"&warehouseid="+warehouseid+"&place='.$place.
'&idproduct='.$idproduct.
'&token='.
newToken().
'", function() {});'.
"\n";
808 echo
"<center>".$langs->trans(
"SearchIntoBatch").
": <b> $nbofsuggested </b></center><br><table>";
809 foreach ($prod->stock_warehouse as $tmpwarehouseid => $tmpval) {
814 if (!empty($prod->stock_warehouse[$tmpwarehouseid]) && is_array($prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
815 foreach ($prod->stock_warehouse[$tmpwarehouseid]->detail_batch as $dbatch) {
816 $batchStock = + $dbatch->qty;
817 $quantityToBeDelivered = 1;
818 $deliverableQty = min($quantityToBeDelivered, $batchStock);
820 print
'<!-- subj='.$suggestednb.
'/'.$nbofsuggested.
' -->';
821 print
'<!-- Show details of lot/serial in warehouseid='.$tmpwarehouseid.
' -->';
822 print
'<td class="left">';
824 $detail .=
'<span class="opacitymedium">'.$langs->trans(
"LotSerial").
':</span> '.$dbatch->batch;
831 $detail .=
'</td><td>';
832 $detail .=
'<span class="opacitymedium">'.$langs->trans(
"Qty").
':</span> '.$dbatch->qty;
833 $detail .=
'</td><td>';
834 $detail .=
' <button class="marginleftonly" onclick="addbatch(\''.dol_escape_js($dbatch->batch).
'\',
'.$tmpwarehouseid.')
">'.$langs->trans("Select
")."</
button>
";
838 $quantityToBeDelivered -= $deliverableQty;
839 if ($quantityToBeDelivered < 0) {
840 $quantityToBeDelivered = 0;
849 print '</body></html>';
855 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
856 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
857 $cat = new Categorie($db);
858 $categories = $cat->containing($idproduct, 'product');
859 $found = (array_search(getDolGlobalInt('TAKEPOS_SUPPLEMENTS_CATEGORY'), array_column($categories, 'id')));
860 if ($found !== false) { // If this product is a supplement
861 $sql = "SELECT fk_parent_line FROM
".MAIN_DB_PREFIX."facturedet where rowid =
".((int) $selectedline);
862 $resql = $db->query($sql);
863 $row = $db->fetch_array($resql);
864 if ($row[0] == null) {
865 $parent_line = $selectedline;
867 $parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product
873 // Group if enabled. Skip group if line already sent to the printer
874 if (getDolGlobalString('TAKEPOS_GROUP_SAME_PRODUCT')) {
875 foreach ($invoice->lines as $line) {
876 if ($line->product_ref == $prod->ref) {
877 if ($line->special_code == 4) {
879 } // If this line is sended to printer create new line
880 // check if qty in stock
881 if (getDolGlobalString('TAKEPOS_QTY_IN_STOCK') && (($line->qty + $qty) > $prod->stock_reel)) {
882 $invoice->error = $langs->trans("ErrorStockIsNotEnough
");
883 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
887 $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);
889 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
891 $idoflineadded = $line->id;
897 if ($idoflineadded <= 0 && empty($err)) {
898 $invoice->fetch_thirdparty();
899 $array_options = array();
901 $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);
903 /* setup of margin calculation */
904 if (getDolGlobalString('MARGIN_TYPE')) {
905 if (getDolGlobalString('MARGIN_TYPE') == 'pmp' && !empty($prod->pmp)) {
906 $line['fk_fournprice'] = null;
907 $line['pa_ht'] = $prod->pmp;
908 } elseif (getDolGlobalString('MARGIN_TYPE') == 'costprice' && !empty($prod->cost_price)) {
909 $line['fk_fournprice'] = null;
910 $line['pa_ht'] = $prod->cost_price;
912 // default is fournprice
913 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
914 $pf = new ProductFournisseur($db);
915 if ($pf->find_min_price_product_fournisseur($idproduct, $qty) > 0) {
916 $line['fk_fournprice'] = $pf->product_fourn_price_id;
917 $line['pa_ht'] = $pf->fourn_unitprice_with_discount;
918 if (getDolGlobalString('PRODUCT_CHARGES') && $pf->fourn_charges > 0) {
919 $line['pa_ht'] += (float) $pf->fourn_charges / $pf->fourn_qty;
925 // complete line by hook
926 $parameters = array('prod' => $prod, 'line' => $line);
927 $reshook = $hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action); // Note that $action and $line may have been modified by some hooks
929 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
933 if (empty($reshook)) {
934 if (!empty($hookmanager->resArray)) {
935 $line = $hookmanager->resArray;
938 // check if qty in stock
939 if (getDolGlobalString('TAKEPOS_QTY_IN_STOCK') && $qty > $prod->stock_reel) {
940 $invoice->error = $langs->trans("ErrorStockIsNotEnough
");
941 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
946 $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, null, 0);
950 if (getDolGlobalString('TAKEPOS_CUSTOMER_DISPLAY')) {
951 $CUSTOMER_DISPLAY_line1 = $prod->label;
952 $CUSTOMER_DISPLAY_line2 = price($price_ttc);
956 $invoice->fetch($placeid);
959 // If we add a line by submitting freezone form (invoice exists here because it was created just before if it didn't exist)
960 if ($action == "freezone
" && $user->hasRight('takepos', 'run')) {
961 $customer = new Societe($db);
962 $customer->fetch($invoice->socid);
964 $tva_tx = GETPOST('tva_tx', 'alpha');
966 if (!preg_match('/\((.*)\)/', $tva_tx)) {
967 $tva_tx = price2num($tva_tx);
970 $tva_tx = get_default_tva($mysoc, $customer);
974 $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
975 $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
977 $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);
979 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
981 $invoice->fetch($placeid);
984 if ($action == "addnote
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
985 $desc = GETPOST('addnote', 'alpha');
987 $invoice->update_note($desc, '_public');
989 foreach ($invoice->lines as $line) {
990 if ($line->id == $idline) {
991 $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);
995 $invoice->fetch($placeid);
998 if ($action == "deleteline
" && ($user->hasRight('takepos', 'editlines') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1000 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1001 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1002 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1003 $permissiontoupdateline = true;
1004 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1005 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1009 if ($idline > 0 && $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected.
1010 $invoice->deleteLine($idline);
1011 $invoice->fetch($placeid);
1012 } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line.
1013 $sql = "SELECT rowid FROM
".MAIN_DB_PREFIX."facturedet where fk_facture =
".((int) $placeid)." ORDER BY rowid DESC
";
1014 $resql = $db->query($sql);
1015 $row = $db->fetch_array($resql);
1016 $deletelineid = $row[0];
1017 $invoice->deleteLine($deletelineid);
1018 $invoice->fetch($placeid);
1021 if (count($invoice->lines) == 0) {
1022 // Keep an empty draft invoice alive when a non-default customer was
1023 // already attached so deleting the last line does not silently lose
1024 // the customer that was just selected (#38219). Only drop the invoice
1025 // when it is still on the default cashdesk thirdparty (or none).
1026 $defaultsocid = (int) getDolGlobalString('CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal
"]);
1027 $invoicesocid = (int) $invoice->socid;
1028 if ($invoicesocid === 0 || $invoicesocid === $defaultsocid) {
1029 $invoice->delete($user);
1031 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1032 header("Location:
".DOL_URL_ROOT."/takepos/public/auto_order.php
");
1034 header("Location:
".DOL_URL_ROOT."/takepos/invoice.php
");
1041 // Action to delete or discard an invoice
1042 if ($action == "delete
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1043 // $placeid is the invoice id (it differs from place) and is defined if the place is set and
1044 // the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal
"].'-'.$place.')', so the fetch at beginning of page works.
1046 $result = $invoice->fetch($placeid);
1048 if ($result > 0 && $invoice->status == Facture::STATUS_DRAFT) {
1051 // We delete the lines
1052 $resdeletelines = 1;
1053 foreach ($invoice->lines as $line) {
1054 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1055 $tmpres = $invoice->deleteLine($line->id);
1057 $resdeletelines = 0;
1062 $sql = "UPDATE
".MAIN_DB_PREFIX."facture
";
1063 $varforconst = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal
"];
1064 $sql .= " SET fk_soc =
".((int) getDolGlobalString($varforconst)).",
";
1065 $sql .= " datec =
'".$db->idate(dol_now())."'";
1066 $sql .= " WHERE entity IN (
".getEntity('invoice').")
";
1067 $sql .= " AND
ref =
'(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'";
1068 $resql1 = $db->query($sql);
1070 if ($resdeletelines && $resql1) {
1076 $invoice->fetch($placeid);
1081 if ($action == "updateqty
") { // Test on permission is done later
1082 foreach ($invoice->lines as $line) {
1083 if ($line->id == $idline) {
1084 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1085 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1086 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1087 $permissiontoupdateline = true;
1088 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1089 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1092 if (!$permissiontoupdateline) {
1093 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
").' - No permission to updateqty', [], 1);
1095 $vatratecode = $line->tva_tx;
1096 if ($line->vat_src_code) {
1097 $vatratecode .= ' ('.$line->vat_src_code.')';
1100 $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);
1105 $invoice->fetch($placeid);
1108 if ($action == "updateprice
") { // Test on permission is done later
1109 $customer = new Societe($db);
1110 $customer->fetch($invoice->socid);
1112 foreach ($invoice->lines as $line) {
1113 if ($line->id == $idline) {
1114 $prod = new Product($db);
1115 $prod->fetch($line->fk_product);
1116 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
1117 $price_min = $datapriceofproduct['price_min'];
1118 $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS'));
1120 $vatratecleaned = $line->tva_tx;
1122 if (preg_match('/^(.*)\s*\((.*)\)$/', (string) $line->tva_tx, $reg)) { // If vat is "xx (yy)
"
1123 $vatratecleaned = trim($reg[1]);
1124 //$vatratecode = $reg[2];
1127 $pu_ht = price2num((float) price2num($number, 'MU') / (1 + ((float) $vatratecleaned / 100)), 'MU');
1129 if ($usercanproductignorepricemin && (!empty($price_min) && ((float) price2num($pu_ht) * (1 - (float) price2num($line->remise_percent) / 100) < price2num($price_min)))) {
1130 $langs->load("products
");
1131 dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice
", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
1132 // echo $langs->trans("CantBeLessThanMinPrice
");
1134 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1135 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1136 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1137 $permissiontoupdateline = true;
1138 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1139 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1143 $vatratecode = $line->tva_tx;
1144 if ($line->vat_src_code) {
1145 $vatratecode .= ' ('.$line->vat_src_code.')';
1148 if (!$permissiontoupdateline) {
1149 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
").' - No permission to updateprice', [], 1);
1150 } elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) {
1151 $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);
1153 $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);
1160 $invoice->fetch($placeid);
1163 if ($action == "updatereduction
") { // Test on permission is done later
1164 $customer = new Societe($db);
1165 $customer->fetch($invoice->socid);
1167 foreach ($invoice->lines as $line) {
1168 if ($line->id == $idline) {
1169 dol_syslog("updatereduction Process line
".$line->id.' to apply discount of '.$number.'%');
1171 $prod = new Product($db);
1172 $prod->fetch($line->fk_product);
1174 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
1175 $price_min = $datapriceofproduct['price_min'];
1176 $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS'));
1178 $pu_ht = price2num($line->subprice / (1 + ($line->tva_tx / 100)), 'MU');
1181 if ($usercanproductignorepricemin && (!empty($price_min) && ((float) price2num($line->subprice) * (1 - (float) price2num($number) / 100) < (float) price2num($price_min)))) {
1182 $langs->load("products
");
1183 dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice
", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
1185 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1186 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1187 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1188 $permissiontoupdateline = true;
1189 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1190 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1193 if (!$permissiontoupdateline) {
1194 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
"), [], 1);
1196 $vatratecode = $line->tva_tx;
1197 if ($line->vat_src_code) {
1198 $vatratecode .= ' ('.$line->vat_src_code.')';
1200 $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);
1207 $invoice->fetch($placeid);
1208 } elseif ($action == 'update_reduction_global' && $user->hasRight('takepos', 'editlines')) {
1209 foreach ($invoice->lines as $line) {
1210 $vatratecode = $line->tva_tx;
1211 if ($line->vat_src_code) {
1212 $vatratecode .= ' ('.$line->vat_src_code.')';
1214 $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);
1217 $invoice->fetch($placeid);
1220 if ($action == "setbatch
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1221 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
1222 $warehouseid = (GETPOSTINT('warehouseid') > 0 ? GETPOSTINT('warehouseid') : getDolGlobalInt($constantforkey)); // Get the warehouse id from GETPOSTINT('warehouseid'), otherwise use default setup.
1223 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet SET batch =
'".$db->escape($batch)."', fk_warehouse =
".((int) $warehouseid);
1224 $sql .= " WHERE rowid=
".((int) $idoflineadded);
1228 if ($action == "order
" && $placeid != 0 && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1229 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1230 if ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1231 require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
1232 $printer = new dolReceiptPrinter($db);
1235 $sql = "SELECT label FROM
".MAIN_DB_PREFIX."takepos_floor_tables where rowid=
".((int) $place);
1236 $resql = $db->query($sql);
1237 $row = $db->fetch_object($resql);
1238 $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>';
1239 $footerorder = '</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>';
1240 $order_receipt_printer1 = "";
1241 $order_receipt_printer2 = "";
1242 $order_receipt_printer3 = "";
1243 $catsprinter1 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_1'));
1244 $catsprinter2 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_2'));
1245 $catsprinter3 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_3'));
1247 foreach ($invoice->lines as $line) {
1248 if ($line->special_code == "4
") {
1251 $c = new Categorie($db);
1252 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1253 $result = array_intersect($catsprinter1, $existing);
1254 $count = count($result);
1255 if (!$line->fk_product) {
1256 $count++; // Print Free-text item (Unassigned printer) to Printer 1
1260 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet set special_code=
'1' where rowid=
".$line->id; //Set to print on printer 1
1262 $order_receipt_printer1 .= '<tr><td class="left
">';
1263 if ($line->fk_product) {
1264 $order_receipt_printer1 .= $line->product_label;
1266 $order_receipt_printer1 .= $line->description;
1268 $order_receipt_printer1 .= '</td><td class="right
">'.$line->qty;
1269 if (!empty($line->array_options['options_order_notes'])) {
1270 $order_receipt_printer1 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1272 $order_receipt_printer1 .= '</td></tr>';
1275 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0 && $printer !== null) {
1276 $invoice->fetch($placeid); //Reload object before send to printer
1277 $printer->orderprinter = 1;
1279 echo "var orderprinter1esc=
'";
1280 $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
1283 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'1' and fk_facture=
".$invoice->id; // Set as printed
1285 $invoice->fetch($placeid); //Reload object after set lines as printed
1288 foreach ($invoice->lines as $line) {
1289 if ($line->special_code == "4
") {
1292 $c = new Categorie($db);
1293 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1294 $result = array_intersect($catsprinter2, $existing);
1295 $count = count($result);
1298 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'2' where rowid=
".$line->id; //Set to print on printer 2
1300 $order_receipt_printer2 .= '<tr>'.$line->product_label.'<td class="right
">'.$line->qty;
1301 if (!empty($line->array_options['options_order_notes'])) {
1302 $order_receipt_printer2 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1304 $order_receipt_printer2 .= '</td></tr>';
1307 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0) {
1308 $invoice->fetch($placeid); //Reload object before send to printer
1309 $printer->orderprinter = 2;
1311 echo "var orderprinter2esc=
'";
1312 $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
1315 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'2' and fk_facture=
".$invoice->id; // Set as printed
1317 $invoice->fetch($placeid); //Reload object after set lines as printed
1320 foreach ($invoice->lines as $line) {
1321 if ($line->special_code == "4
") {
1324 $c = new Categorie($db);
1325 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1326 $result = array_intersect($catsprinter3, $existing);
1327 $count = count($result);
1330 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'3' where rowid=
".$line->id; //Set to print on printer 3
1332 $order_receipt_printer3 .= '<tr>'.$line->product_label.'<td class="right
">'.$line->qty;
1333 if (!empty($line->array_options['options_order_notes'])) {
1334 $order_receipt_printer3 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1336 $order_receipt_printer3 .= '</td></tr>';
1339 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0 && $printer !== null) {
1340 $invoice->fetch($placeid); //Reload object before send to printer
1341 $printer->orderprinter = 3;
1343 echo "var orderprinter3esc=
'";
1344 $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
1347 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'3' and fk_facture=
".$invoice->id; // Set as printed
1349 $invoice->fetch($placeid); //Reload object after set lines as printed
1352 $sectionwithinvoicelink = '';
1353 if (($action == "valid
" || $action == "history
" || $action == 'creditnote' || ($action == 'addline' && $invoice->status == $invoice::STATUS_CLOSED)) && $user->hasRight('takepos', 'run')) {
1354 $sectionwithinvoicelink .= '<!-- Section with invoice link -->'."\n
";
1355 $sectionwithinvoicelink .= '<span style="font-size:120%;
" class="center
inline-block marginbottomonly
">';
1356 $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." -
";
1357 $remaintopay = $invoice->getRemainToPay();
1358 if ($remaintopay > 0) {
1359 $sectionwithinvoicelink .= $langs->trans('RemainToPay').': <span class="amountremaintopay
" style="font-size: unset
">'.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
1361 $sectionwithinvoicelink .= $invoice->getLibStatut(2);
1364 $sectionwithinvoicelink .= '</span><br>';
1366 $customprinterallowed = true;
1367 $customprinttemplateallowed = true;
1368 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
1369 if (isALNERunningVersion()) { // No need to show this option because it has no effect when isALNERunningVersion is true.
1370 $customprinttemplateallowed = false; // Custom printer may be allowed if mandatory information in template are guaranteed. For the moment, we prefer not allow this.
1373 if ($invoice->status == $invoice::STATUS_CLOSED) {
1374 if (getDolGlobalInt('TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
1375 $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>';
1376 } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1377 // Used when the external addon takeposconnector is installed. Deprecated.
1378 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
1379 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="TakeposConnector(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1381 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="TakeposPrinting(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1383 } elseif ($customprinterallowed && (isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") { // @phpstan-ignore-line
1384 // If we set to use a specific receipt printer
1385 $nameOfPrinter = dol_getIdFromCode($db, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term), 'printer_receipt', 'rowid', 'name', 1);
1386 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="DolibarrTakeposPrinting(
'.$placeid.')
" title="'.dolPrintHTMLForAttribute($langs->trans("SentToPrinter").' '.$nameOfPrinter).'">'.$langs->trans('PrintTicket').'</button>';
1388 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="Print(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1389 if ($customprinttemplateallowed && getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) {
1390 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintBox(
'.$placeid.', \
'without_details\')">'.$langs->trans(
'PrintWithoutDetails').
'</button>';
1393 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="Print('.$placeid.
', 1)">'.$langs->trans(
'GiftReceipt').
'</button>';
1397 $sectionwithinvoicelink .=
' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.
')">'.$langs->trans(
'SendTicket').
'</button>';
1400 if ($remaintopay <= 0 &&
getDolGlobalString(
'TAKEPOS_AUTO_PRINT_TICKETS') && $action !=
"history") {
1401 $sectionwithinvoicelink .=
'<script type="text/javascript">console.log("Emulate click on #buttonprint"); $("#buttonprint").click();</script>';
1412$form =
new Form($db);
1415if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1416 $title =
'TakePOS - Dolibarr '.DOL_VERSION;
1420 $head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
1421 <meta name="apple-mobile-web-app-capable" content="yes">
1422 <meta name="mobile-web-app-capable" content="yes">
1423 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
1424 $arrayofcss = array(
1425 '/takepos/css/pos.css.php',
1427 $arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
1430 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
1432 print
'<body>'.
"\n";
1439<script
type=
"text/javascript">
1442<?php
if ($action ==
"valid") {
1443 echo
"var place=0;";
1445var placeid=<?php echo($placeid > 0 ? $placeid : 0); ?>;
1446$(document).ready(
function() {
1447 var idoflineadded = <?php echo(empty($idoflineadded) ? 0 : $idoflineadded); ?>;
1449 $(
'.posinvoiceline').click(
function(){
1450 console.log(
"Click done on "+this.
id);
1451 $(
'.posinvoiceline').removeClass(
"selected");
1452 $(
this).addClass(
"selected");
1456 if (selectedline == this.
id) {
1459 selectedline = this.id;
1461 selectedtext=$(
'#'+selectedline).find(
"td:first").html();
1463 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1464 print
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?action=editline&token='.
newToken().
'&placeid="+placeid+"&selectedline="+selectedline, function() {
1471 if (idoflineadded > 0)
1473 console.log(
"Auto select "+idoflineadded);
1474 $(
'.posinvoiceline#'+idoflineadded).click();
1478if ($action ==
"order" && !empty($order_receipt_printer1)) {
1479 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1483 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php',
1484 data:
'invoice='+orderprinter1esc
1491 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1493 print $headerorder.$order_receipt_printer1.$footerorder; ?>'
1499if ($action ==
"order" && !empty($order_receipt_printer2)) {
1500 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1504 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php?printer=2',
1505 data:
'invoice='+orderprinter2esc
1512 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print2',
1514 print $headerorder.$order_receipt_printer2.$footerorder; ?>'
1520if ($action ==
"order" && !empty($order_receipt_printer3)) {
1521 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1525 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php?printer=3',
1526 data:
'invoice='+orderprinter3esc
1533if ($action ==
"search" || $action ==
"valid") {
1535 parent.ClearSearch(
true);
1540if ($action ==
"temp" && !empty($ticket_printer1)) {
1544 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1546 print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>'
1551if ($action ==
"search") {
1553 $(
'#search').focus();
1561function SendTicket(
id)
1563 console.log(
"Open box to select the Print/Send form");
1564 $.colorbox({href:
"send.php?facid="+id, width:
"70%", height:
"30%", transition:
"none", iframe:
"true", title:
'<?php echo dol_escape_js($langs->trans("SendTicket")); ?>'});
1569function PrintBox(
id, action) {
1570 console.log(
"Open box before printing");
1571 $.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
"); ?>"});
1576function Print(
id, gift) {
1580 console.log(
"Call Print() to generate the receipt.");
1581 $.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")); ?>'});
1586function TakeposPrinting(
id){
1588 console.log(
"TakeposPrinting" +
id);
1589 $.get(
"receipt.php?facid="+
id,
function(data,
status) {
1590 receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,
'');
1593 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1600function TakeposConnector(
id){
1601 console.log(
"TakeposConnector" +
id);
1602 $.get(
"<?php echo DOL_URL_ROOT; ?>/takepos/ajax/ajax.php?action=printinvoiceticket&token=<?php echo newToken(); ?>&term=<?php echo urlencode(isset($_SESSION["takeposterminal
"]) ? $_SESSION["takeposterminal
"] : ''); ?>&id="+
id+
"&token=<?php echo currentToken(); ?>",
function(data,
status) {
1605 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php',
1606 data:
'invoice='+data
1617function DolibarrTakeposPrinting(
id) {
1618 console.log(
"DolibarrTakeposPrinting Printing invoice ticket by calling takepos/aja/ajax.php" +
id);
1622 data: { token:
'<?php echo currentToken(); ?>' },
1623 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=printinvoiceticket&token='.newToken().'&term='.urlencode(isset($_SESSION["takeposterminal
"]) ? $_SESSION["takeposterminal
"] : '').'&id='; ?>" + id,
1624 success:
function(){
1625 showPrintResultPopup(
'<?php echo dol_escape_js($langs->trans("SentToPrinter").' '.$nameOfPrinter); ?>', 2000);
1628 showPrintResultPopup(
"<?php echo dol_escape_js($langs->trans("FailedToSendToPrinter
")); ?>", 2000);
1635function showPrintResultPopup(message, duration) {
1636 $(
"#dialogforpopuptakepos").show().text(message).fadeIn();
1638 setTimeout(
function(){
1639 $(
"#dialogforpopuptakepos").fadeOut().hide();
1646function CreditNote() {
1647 $(
"#poslines").load(
"<?php print DOL_URL_ROOT; ?>/takepos/invoice.php?action=creditnote&token=<?php echo newToken() ?>&invoiceid="+placeid,
function() { });
1653 $(
"#poslines").load(
"<?php print DOL_URL_ROOT; ?>/takepos/invoice.php?action=addnote&token=<?php echo newToken() ?>&invoiceid="+placeid+
"&idline="+selectedline, {
"addnote": $(
"#textinput").val() });
1658$( document ).ready(
function() {
1659 console.log(
"Set customer info and sales in header placeid=<?php echo $placeid; ?> status=<?php echo $invoice->statut; ?>");
1662 $s = $langs->trans(
"Customer");
1663 if ($invoice->id > 0 && ($invoice->socid !=
getDolGlobalString($constforcompanyid))) {
1666 $contactids = $invoice->getIdContact(
'external',
'BILLING');
1667 $contactid = $contactids[0];
1668 if ($contactid > 0) {
1670 $contact->fetch($contactid);
1671 $s .=
" - " . $contact->getFullName($langs);
1675 print
'$("#idcustomer").val("");';
1679 $(
"#customerandsales").html(
'');
1680 $(
"#shoppingcart").html(
'');
1683 $(
"#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>');
1685 $(
"#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>');
1689 $sql =
"SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX.
"facture";
1690 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
1693 $sql .=
" AND ref LIKE '(PROV-POS".$db->escape(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'').
"-0%'";
1696 $sql .=
" AND pos_source = '".$db->escape((
string) $_SESSION[
"takeposterminal"]).
"'";
1697 $sql .=
" AND module_source = 'takepos'";
1700 $sql .= $db->order(
'datec',
'ASC');
1701 $resql = $db->query($sql);
1704 while ($obj = $db->fetch_object($resql)) {
1705 echo
'$("#shoppingcart").append(\'';
1706 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=\\\'';
1707 $num_sale = str_replace(
")",
"", str_replace(
"(PROV-POS".$_SESSION[
"takeposterminal"].
"-",
"", $obj->ref));
1709 if (str_replace(
"-",
"", $num_sale) > $max_sale) {
1710 $max_sale = str_replace(
"-",
"", $num_sale);
1712 echo
'\\\'; invoiceid=\\\'';
1714 echo
'\\\'; Refresh();">';
1715 if ($placeid == $obj->rowid) {
1716 echo
'<span class="basketselected">';
1718 echo
'<span class="basketnotselected">';
1720 echo
'<span class="fa fa-shopping-cart paddingright"></span>'.dol_print_date($db->jdate($obj->datec),
'%H:%M',
'tzuser');
1724 echo
'$("#shoppingcart").append(\'<a onclick="place=\\\'0-';
1726 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>\');';
1734 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1737 $constantforkey =
'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1739 if ($idwarehouse > 0) {
1740 $s =
'<span class="small">';
1742 $warehouse->fetch($idwarehouse);
1743 $s .=
'<span class="hideonsmartphone">'.$langs->trans(
"Warehouse").
'<br></span>'.$warehouse->ref;
1745 $s .=
' ('.$langs->trans(
"Closed").
')';
1748 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1749 print
'$("#infowarehouse").css("display", "inline-block");';
1751 $s =
'<span class="small hideonsmartphone">';
1752 $s .= $langs->trans(
"StockChangeDisabled").
'<br>'.$langs->trans(
"NoWarehouseDefinedForTerminal");
1754 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1755 if (!empty($conf->dol_optimize_smallscreen)) {
1756 print
'$("#infowarehouse").css("display", "none");';
1760 $s =
'<span class="small hideonsmartphone">'.$langs->trans(
"StockChangeDisabled").
'</span>';
1761 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1762 if (!empty($conf->dol_optimize_smallscreen)) {
1763 print
'$("#infowarehouse").css("display", "none");';
1772 $s =
'<span class="small">';
1773 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1774 $langs->load(
"members");
1775 $s .= $langs->trans(
"Member").
': ';
1777 $result = $adh->fetch(0,
'', $invoice->socid);
1779 $adh->ref = $adh->getFullName($langs);
1783 $s .= $adh->getFullName($langs);
1784 $s .=
' - '.$adh->type;
1785 if ($adh->datefin) {
1786 $s .=
'<br>'.$langs->trans(
"SubscriptionEndDate").
': '.
dol_print_date($adh->datefin,
'day');
1787 if ($adh->hasDelay()) {
1788 $s .=
" ".img_warning($langs->trans(
"Late"));
1791 $s .=
'<br>'.$langs->trans(
"SubscriptionNotReceived");
1792 if ($adh->status > 0) {
1793 $s .=
" ".img_warning($langs->trans(
"Late"));
1800 $s .=
'<br>'.$langs->trans(
"ThirdpartyNotLinkedToMember");
1805 $(
"#moreinfo").html(
'<?php print dol_escape_js($s); ?>');
1812 echo
"function CustomerDisplay(){";
1813 echo
"var line1='".$CUSTOMER_DISPLAY_line1.
"'.substring(0,20);";
1814 echo
"line1=line1.padEnd(20);";
1815 echo
"var line2='".$CUSTOMER_DISPLAY_line2.
"'.substring(0,20);";
1816 echo
"line2=line2.padEnd(20);";
1819 data: { text: line1+line2 },
1820 url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER').
"/display/index.php',
1831if (!empty($conf->use_javascript_ajax)) {
1832 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
1833 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.
'"></script>'.
"\n";
1836$usediv = (
GETPOST(
'format') ==
'div');
1838print
'<!-- 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";
1839print
'<div class="div-table-responsive-no-min invoice">';
1841 print
'<div id="tablelines">';
1843 print
'<table id="tablelines" class="noborder noshadow postablelines centpercent">';
1846$buttontocreatecreditnote =
'';
1847if (($action ==
"valid" || $action ==
"history" || ($action ==
"addline" && $invoice->status == $invoice::STATUS_CLOSED)) && $invoice->type !=
Facture::TYPE_CREDIT_NOTE && !
getDolGlobalString(
'TAKEPOS_NO_CREDITNOTE')) {
1848 $buttontocreatecreditnote .=
' <!-- Show button to create a credit note -->'.
"\n";
1849 $buttontocreatecreditnote .=
'<button id="buttonprint" type="button" onclick="ModalBox(\'ModalCreditNote\')">'.$langs->trans(
'CreateCreditNote').
'</button>';
1850 if (
getDolGlobalInt(
'TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
1851 $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>';
1856if ($sectionwithinvoicelink && ($mobilepage ==
"invoice" || $mobilepage ==
"")) {
1857 print
'<!-- Print table line with link to invoice ref -->';
1859 print
'<tr><td colspan="5" class="paddingtopimp paddingbottomimp" style="padding-top: 10px !important; padding-bottom: 10px !important;">';
1860 print $sectionwithinvoicelink;
1861 print $buttontocreatecreditnote;
1864 print
'<tr><td colspan="4" class="paddingtopimp paddingbottomimp" style="padding-top: 10px !important; padding-bottom: 10px !important;">';
1865 print $sectionwithinvoicelink;
1866 print $buttontocreatecreditnote;
1873 print
'<tr class="liste_titre nodrag nodrop">';
1874 print
'<td class="linecoldescription">';
1877if (empty($mobilepage) || $mobilepage ==
"invoice") {
1878 print
'<!-- hidden var used by some js functions -->';
1879 print
'<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.
'">';
1880 print
'<input type="hidden" name="thirdpartyid" id="thirdpartyid" value="'.$invoice->socid.
'">';
1884 $sql =
"SELECT floor, label FROM ".MAIN_DB_PREFIX.
"takepos_floor_tables where rowid=".((int) $place);
1885 $resql = $db->query($sql);
1886 $obj = $db->fetch_object($resql);
1888 $label = $obj->label;
1889 $floor = $obj->floor;
1891 if ($mobilepage ==
"invoice" || $mobilepage ==
"") {
1894 print
'<span class="opacitymedium">'.$langs->trans(
'Place').
"</span> <b>".(empty($label) ?
'?' : $label).
"</b><br>";
1895 print
'<span class="opacitymedium">'.$langs->trans(
'Floor').
"</span> <b>".(empty($floor) ?
'?' : $floor).
"</b>";
1902$parameters = array();
1903$reshook = $hookmanager->executeHooks(
'completeTakePosInvoiceHeader', $parameters, $invoice, $action);
1907print $hookmanager->resPrint;
1909if (empty($_SESSION[
"basiclayout"]) || $_SESSION[
"basiclayout"] != 1) {
1911 print
'<td class="linecolqty right">'.$langs->trans(
'PriceUHT').
'</td>';
1913 print
'<td class="linecolqty right">'.$langs->trans(
'ReductionShort').
'</td>';
1914 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
1916 print
'<td class="linecolht right nowraponall">';
1917 print
'<span class="opacitymedium small">' . $langs->trans(
'TotalHTShort') .
'</span><br>';
1919 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1920 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>';
1921 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"]) && $conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
1923 include_once DOL_DOCUMENT_ROOT .
'/multicurrency/class/multicurrency.class.php';
1925 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
1926 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>';
1931 print
'<td class="linecolht right nowraponall">';
1932 print
'<span class="opacitymedium small">'.$langs->trans(
'TotalTTCShort').
'</span><br>';
1934 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1935 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>';
1936 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"]) && $conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
1938 include_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
1940 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
1941 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>';
1945} elseif ($mobilepage ==
"invoice") {
1946 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
1952if (!empty($_SESSION[
"basiclayout"]) && $_SESSION[
"basiclayout"] == 1) {
1953 if ($mobilepage ==
"cats") {
1954 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1956 $categories = $categorie->get_full_arbo(
'product');
1958 foreach ($categories as $row) {
1959 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1960 $htmlforlines .=
'<div class="leftcat"';
1962 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline"';
1964 $htmlforlines .=
' onclick="LoadProducts('.$row[
'id'].
');">';
1965 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1966 $htmlforlines .=
'<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=cat&query=cat&id='.$row[
'id'].
'"><br>';
1968 $htmlforlines .=
'<td class="left">';
1970 $htmlforlines .= $row[
'label'];
1971 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1972 $htmlforlines .=
'</div>'.
"\n";
1974 $htmlforlines .=
'</td></tr>'.
"\n";
1977 print $htmlforlines;
1980 if ($mobilepage ==
"products") {
1981 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1984 $result =
$object->fetch($catid);
1985 $prods =
$object->getObjectsInCateg(
"product");
1987 '@phan-var-force Product[] $prods';
1989 foreach ($prods as $row) {
1990 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1991 $htmlforlines .=
'<div class="leftcat"';
1993 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline"';
1995 $htmlforlines .=
' onclick="AddProduct(\''.$place.
'\',
'.$row->id.')
"';
1996 $htmlforlines .= '>';
1997 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1998 $htmlforlines .= '<img class="imgwrapper
" width="33%
" src="'.DOL_URL_ROOT.'/takepos/
public/auto_order.php?genimg=pro&query=pro&
id=
'.$row->id.'"><br>';
1999 $htmlforlines .= $row->label.' '.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency);
2000 $htmlforlines .= '</div>'."\n
";
2002 $htmlforlines .= '<td class="left
">';
2003 $htmlforlines .= $row->label;
2004 $htmlforlines .= '<div class="right
">'.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).'</div>';
2005 $htmlforlines .= '</td>';
2006 $htmlforlines .= '</tr>'."\n
";
2009 print $htmlforlines;
2012 if ($mobilepage == "places
") {
2013 $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM
".MAIN_DB_PREFIX."takepos_floor_tables
";
2014 $resql = $db->query($sql);
2018 while ($row = $db->fetch_array($resql)) {
2020 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
2021 $htmlforlines .= '" onclick="LoadPlace(\
''.$row[
'label'].
'\')
">';
2022 $htmlforlines .= '<td class="left
">';
2023 $htmlforlines .= $row['label'];
2024 $htmlforlines .= '</td>';
2025 $htmlforlines .= '</tr>'."\n
";
2027 print $htmlforlines;
2032 //In Phone basic layout hide some content depends situation
2033 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1 && $mobilepage != "invoice
" && $action != "order
") {
2037 // Loop on each lines on invoice
2038 if (is_array($invoice->lines) && count($invoice->lines)) {
2039 print '<!-- invoice.php show lines of invoices -->'."\n
";
2040 $tmplines = array_reverse($invoice->lines);
2041 $htmlsupplements = array();
2042 foreach ($tmplines as $line) {
2043 if ($line->fk_parent_line != false) {
2044 if (!isset($htmlsupplements[$line->fk_parent_line])) {
2045 $htmlsupplements[$line->fk_parent_line] = '';
2047 $htmlsupplements[$line->fk_parent_line] .= '<tr class="drag drop oddeven posinvoiceline
';
2048 if ($line->special_code == "4") {
2049 $htmlsupplements[$line->fk_parent_line] .= ' order
';
2051 $htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'"';
2052 if ($line->special_code == "4
") {
2053 $htmlsupplements[$line->fk_parent_line] .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
2055 $htmlsupplements[$line->fk_parent_line] .= '>';
2056 $htmlsupplements[$line->fk_parent_line] .= '<td class="left
">';
2057 $htmlsupplements[$line->fk_parent_line] .= img_picto('', 'rightarrow.png');
2058 if ($line->product_label) {
2059 $htmlsupplements[$line->fk_parent_line] .= $line->product_label;
2061 if ($line->product_label && $line->desc) {
2062 $htmlsupplements[$line->fk_parent_line] .= '<br>';
2064 if ($line->product_label != $line->desc) {
2065 $firstline = dolGetFirstLineOfText($line->desc);
2066 if ($firstline != $line->desc) {
2067 $htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
2069 $htmlsupplements[$line->fk_parent_line] .= $line->desc;
2072 $htmlsupplements[$line->fk_parent_line] .= '</td>';
2074 // complete line by hook
2075 $parameters = array('line' => $line);
2076 $reshook = $hookmanager->executeHooks('completeTakePosInvoiceParentLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
2078 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2080 $htmlsupplements[$line->fk_parent_line] .= $hookmanager->resPrint;
2082 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2083 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.vatrate(price2num($line->remise_percent), true).'</td>';
2084 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.$line->qty.'</td>';
2085 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.price($line->total_ttc).'</td>';
2087 $htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n
";
2092 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
2093 if ($line->special_code == "4") {
2094 $htmlforlines .= ' order
';
2096 $htmlforlines .= '" id="'.$line->id.'"';
2097 if ($line->special_code == "4
") {
2098 $htmlforlines .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
2100 $htmlforlines .= '>';
2101 $htmlforlines .= '<td class="left
">';
2102 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
2103 $htmlforlines .= '<span class="phoneqty
">'.$line->qty."</span> x
";
2105 if (isset($line->product_type)) {
2106 if (empty($line->product_type)) {
2107 $htmlforlines .= img_object('', 'product').' ';
2109 $htmlforlines .= img_object('', 'service').' ';
2113 if (!getDolGlobalString('TAKEPOS_SHOW_N_FIRST_LINES')) {
2114 if ($line->product_ref) {
2115 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
2116 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
2117 if (!empty($line->batch)) {
2118 $tooltiptext .= '<br><b>'.$langs->trans("LotSerial
").'</b> : '.$line->batch.'<br>';
2120 if (!empty($line->fk_warehouse)) {
2121 $tooltiptext .= '<b>'.$langs->trans("Warehouse
").'</b> : '.$line->fk_warehouse.'<br>';
2123 if ($line->product_label != $line->desc) {
2125 $tooltiptext .= '<br>';
2127 $tooltiptext .= $line->desc;
2130 if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
2131 $htmlforlines .= $form->textwithpicto($line->product_label ? '<b>' . $line->product_ref . '</b> - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
2132 } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) {
2133 $htmlforlines .= $form->textwithpicto($line->product_ref ? '<b>'.$line->product_ref.'<b>' : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
2135 $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
2138 if ($line->product_ref) {
2139 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
2140 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
2142 if (!empty($line->batch)) {
2143 $tooltiptext .= '<br><b>'.$langs->trans("LotSerial
").'</b> : '.$line->batch.'<br>';
2145 if (!empty($line->fk_warehouse)) {
2146 $tooltiptext .= '<b>'.$langs->trans("Warehouse
").'</b> : '.$line->fk_warehouse.'<br>';
2149 if ($line->product_label) {
2150 $htmlforlines .= $line->product_label;
2152 if ($line->product_label != $line->desc) {
2153 if ($line->product_label && $line->desc) {
2154 $htmlforlines .= '<br>';
2156 $firstline = dolGetFirstLineOfText($line->desc, getDolGlobalInt('TAKEPOS_SHOW_N_FIRST_LINES'));
2157 if ($firstline != $line->desc) {
2158 $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
2160 $htmlforlines .= $line->desc;
2164 if (!empty($line->array_options['options_order_notes'])) {
2165 $htmlforlines .= "<br>(
".$line->array_options['options_order_notes'].")
";
2167 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
2168 $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>';
2170 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2172 $moreinfo .= $langs->transcountry("TotalHT
", $mysoc->country_code).': '.price($line->total_ht);
2173 if ($line->vat_src_code) {
2174 $moreinfo .= '<br>'.$langs->trans("VATCode
").': '.$line->vat_src_code;
2176 $moreinfo .= '<br>'.$langs->transcountry("TotalVAT
", $mysoc->country_code).': '.price($line->total_tva);
2177 $moreinfo .= '<br>'.$langs->transcountry("TotalLT1
", $mysoc->country_code).': '.price($line->total_localtax1);
2178 $moreinfo .= '<br>'.$langs->transcountry("TotalLT2
", $mysoc->country_code).': '.price($line->total_localtax2);
2179 $moreinfo .= '<hr>';
2180 $moreinfo .= $langs->transcountry("TotalTTC
", $mysoc->country_code).': '.price($line->total_ttc);
2181 //$moreinfo .= $langs->trans("TotalHT
").': '.$line->total_ht;
2182 if ($line->date_start || $line->date_end) {
2183 $htmlforlines .= '<br><div class="clearboth nowraponall
">'.get_date_range($line->date_start, $line->date_end).'</div>';
2185 $htmlforlines .= '</td>';
2187 // complete line by hook
2188 $parameters = array('line' => $line);
2189 $reshook = $hookmanager->executeHooks('completeTakePosInvoiceLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
2191 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2193 $htmlforlines .= $hookmanager->resPrint;
2195 if (getDolGlobalInt("TAKEPOS_SHOW_SUBPRICE
")) {
2196 $htmlforlines .= '<td class="right
">'.price($line->subprice).'</td>';
2198 $htmlforlines .= '<td class="right
">'.vatrate(price2num($line->remise_percent), true).'</td>';
2199 // nowraponall keeps the qty and its '(stock)' block on one line: on narrow layouts
2200 // the native display otherwise wraps over three lines inside the qty column.
2201 $htmlforlines .= '<td class="right nowraponall
">';
2202 $htmlforlines .= $line->qty;
2203 if (isModEnabled('stock') && $user->hasRight('stock', 'mouvement', 'lire')) {
2204 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
2205 if (getDolGlobalString($constantforkey) && $line->fk_product > 0 && !getDolGlobalString('TAKEPOS_HIDE_STOCK_ON_LINE')) {
2206 $productChildrenNb = 0;
2207 if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
2208 if (empty($line->product) || !($line->product->id > 0)) {
2209 $line->fetch_product();
2211 if (!empty($line->product)) {
2212 $productChildrenNb = $line->product->hasFatherOrChild(1);
2215 if ($productChildrenNb == 0) {
2216 $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp
";
2217 $sql .= " FROM
".MAIN_DB_PREFIX."entrepot as e,
";
2218 $sql .= " ".MAIN_DB_PREFIX."product_stock as ps
";
2219 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product
";
2220 $sql .= " WHERE ps.reel != 0
";
2221 $sql .= " AND ps.fk_entrepot =
".((int) getDolGlobalString($constantforkey));
2222 $sql .= " AND e.entity IN (
".getEntity('stock').")
";
2223 $sql .= " AND ps.fk_product =
".((int) $line->fk_product);
2224 $resql = $db->query($sql);
2227 $obj = $db->fetch_object($resql);
2229 $stock_real = price2num($obj->reel, 'MS');
2231 $htmlforlines .= ' ';
2232 $htmlforlines .= '<span class="opacitylow
" title="'.$langs->trans("Stock").' '.price($stock_real, 1, '', 1, 0).'">';
2233 $htmlforlines .= '(';
2234 if ($line->qty && $line->qty > $stock_real) {
2235 $htmlforlines .= '<span style="color: var(--amountremaintopaycolor)
">';
2237 $htmlforlines .= img_picto('', 'stock', 'class="pictofixedwidth
"').price($stock_real, 1, '', 1, 0);
2238 if ($line->qty && $line->qty > $stock_real) {
2239 $htmlforlines .= "</span>
";
2241 $htmlforlines .= ')';
2242 $htmlforlines .= '</span>';
2244 dol_print_error($db);
2250 $htmlforlines .= '</td>';
2251 if (getDolGlobalInt('TAKEPOS_SHOW_HT')) {
2252 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
2253 $htmlforlines .= price($line->total_ht, 1, '', 1, -1, -1, $conf->currency);
2254 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
2255 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
2256 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
2257 $multicurrency = new MultiCurrency($db);
2258 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
2259 $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>';
2261 $htmlforlines .= '</td>';
2263 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
2264 $htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency);
2265 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
2266 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
2267 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
2268 $multicurrency = new MultiCurrency($db);
2269 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
2270 $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>';
2272 $htmlforlines .= '</td>';
2274 $htmlforlines .= '</tr>'."\n
";
2275 $htmlforlines .= empty($htmlsupplements[$line->id]) ? '' : $htmlsupplements[$line->id];
2277 print $htmlforlines;
2280 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td>';
2281 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2282 print '<td></td><td></td>';
2283 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
2289} else { // No invoice generated yet
2290 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td>';
2291 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2292 print '<td></td><td></td>';
2293 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
2306if ($action == "search
") {
2308 <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
')).'">
2315if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2316 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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
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.