34if (!defined(
'NOTOKENRENEWAL')) {
35 define(
'NOTOKENRENEWAL',
'1');
37if (!defined(
'NOREQUIREMENU')) {
38 define(
'NOREQUIREMENU',
'1');
40if (!defined(
'NOREQUIREHTML')) {
41 define(
'NOREQUIREHTML',
'1');
43if (!defined(
'NOREQUIREAJAX')) {
44 define(
'NOREQUIREAJAX',
'1');
48if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
49 require
'../main.inc.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
65$hookmanager->initHooks(array(
'takeposinvoice'));
67$langs->loadLangs(array(
"companies",
"commercial",
"bills",
"cashdesk",
"stocks",
"banks"));
69$action =
GETPOST(
'action',
'aZ09');
73$mobilepage =
GETPOST(
'mobilepage',
'alpha');
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)) {
219 if ($action ==
'valid' && $user->hasRight(
'facture',
'creer')) {
227 $bankaccount =
getDolGlobalInt(
'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION[
"takeposterminal"]);
228 } elseif ($pay ==
"CHQ") {
229 $bankaccount =
getDolGlobalInt(
'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION[
"takeposterminal"]);
231 $accountname =
"CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION[
"takeposterminal"];
236 if ($bankaccount <= 0 && $pay !=
"delayed" &&
isModEnabled(
"bank")) {
237 $errormsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount"));
245 $invoice->fetch($placeid);
247 $invoice->oldcopy =
dol_clone($invoice, 2);
251 if ($invoice->total_ttc < 0) {
252 $invoice->type = $invoice::TYPE_CREDIT_NOTE;
254 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
255 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
256 $sql .=
" AND fk_soc = ".((int) $invoice->socid);
257 $sql .=
" AND type <> ".Facture::TYPE_CREDIT_NOTE;
258 $sql .=
" AND fk_statut >= ".$invoice::STATUS_VALIDATED;
259 $sql .=
" ORDER BY rowid DESC";
262 $resql = $db->query($sql);
264 $obj = $db->fetch_object($resql);
265 $fk_source = $obj->rowid;
266 if ((
int) $fk_source == 0) {
267 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
270 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
272 $invoice->fk_facture_source = $fk_source;
273 $invoice->update($user);
276 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
283 $remaintopay = $invoice->getRemainToPay();
290 } elseif (count($invoice->lines) == 0) {
299 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
301 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
302 dol_syslog(
"Validate invoice with stock change. Warehouse defined into constant ".$constantforkey.
" = ".
getDolGlobalString($constantforkey));
307 $res = $invoice->validate($user,
'',
getDolGlobalInt($constantforkey), 0, $batch_rule);
310 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
313 dol_syslog(
"Call validate on invoice ".$invoice->ref, LOG_DEBUG);
314 $res = $invoice->validate($user);
317 $langs->load(
"admin");
318 dol_htmloutput_errors($invoice->error ==
'NotConfigured' ? $langs->trans(
"NotConfigured").
' (TakePos numbering module)' : $invoice->error, $invoice->errors, 1);
323 if (!$error && $res >= 0) {
324 $remaintopay = $invoice->getRemainToPay();
329 $payment->datepaye = $now;
330 $payment->fk_account = $bankaccount;
335 $payment->amounts[$invoice->id] = $amountofpayment;
338 if ($amountofpayment <= 0 || $amountofpayment > $remaintopay) {
339 $payment->amounts[$invoice->id] = $remaintopay;
343 $payment->paiementid = $paiementid;
344 $payment->paiementcode = $paycode;
345 $payment->num_payment =
'';
347 if ($pay !=
"delayed") {
348 $res = $payment->create($user);
355 if (!empty($payment->warnings)) {
359 $res = $payment->addPaymentToBank($user,
'payment',
'(CustomerInvoicePayment)', $bankaccount,
'',
'');
362 dol_htmloutput_mesg($langs->trans(
'ErrorNoPaymentDefined').
' '.$payment->error, $payment->errors,
'error', 1);
365 $remaintopay = $invoice->getRemainToPay();
371 if ($remaintopay == 0) {
372 dol_syslog(
"Invoice is paid, so we set it to status Paid");
373 $result = $invoice->setPaid($user);
376 $invoice->status = $invoice::STATUS_CLOSED;
377 $invoice->close_code =
'';
380 $invoice->setPaymentMethods($paiementid);
382 dol_syslog(
"Invoice is not paid, remain to pay = ".$remaintopay);
391 if (!$error && $res >= 0) {
394 dol_syslog(
"Now we record the stock movement for each qualified line");
397 require_once DOL_DOCUMENT_ROOT .
"/product/stock/class/mouvementstock.class.php";
398 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
401 $labeltakeposmovement =
'TakePOS - '.$langs->trans(
"Invoice").
' '.$invoice->ref;
403 foreach ($invoice->lines as $line) {
405 $warehouseid = ($line->fk_warehouse ? $line->fk_warehouse :
getDolGlobalInt($constantforkey));
408 if ($line->batch !=
'' && $warehouseid > 0) {
410 $prod_batch->find(0,
'',
'', $line->batch, $warehouseid, (
int) $line->fk_product);
413 $mouvP->setOrigin($invoice->element, $invoice->id);
415 $res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'', $prod_batch->batch, $prod_batch->id, $inventorycode);
422 $mouvP->setOrigin($invoice->element, $invoice->id);
424 $res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'',
'', 0, $inventorycode);
434 if (!$error && $res >= 0) {
437 $invoice->ref = $invoice->oldcopy->ref;
438 $invoice->paye = $invoice->oldcopy->paye;
439 $invoice->status = $invoice->oldcopy->status;
440 $invoice->statut = $invoice->oldcopy->statut;
446 if ($action ==
'creditnote' && $user->hasRight(
'facture',
'creer')) {
449 $creditnote =
new Facture($db);
450 $creditnote->socid = $invoice->socid;
452 $creditnote->module_source =
'takepos';
453 $creditnote->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
455 $creditnote->fk_facture_source = $placeid;
458 $creditnote->create($user);
462 foreach ($invoice->lines as $line) {
464 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
469 if (!empty($invoice->situation_counter)) {
470 $source_fk_prev_id = $line->fk_prev_id;
471 $line->fk_prev_id = $line->id;
472 if (!empty($invoice->tab_previous_situation_invoice)) {
475 $tab_jumped_credit_notes = array();
476 $lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
477 $searchPreviousInvoice =
true;
478 while ($searchPreviousInvoice) {
479 if ($invoice->tab_previous_situation_invoice[$lineIndex]->situation_cycle_ref || $lineIndex < 1) {
480 $searchPreviousInvoice =
false;
484 $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id;
490 $maxPrevSituationPercent = 0;
491 foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
492 if ($prevLine->id == $source_fk_prev_id) {
493 $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
496 $line->total_ht -= $prevLine->total_ht;
497 $line->total_tva -= $prevLine->total_tva;
498 $line->total_ttc -= $prevLine->total_ttc;
499 $line->total_localtax1 -= $prevLine->total_localtax1;
500 $line->total_localtax2 -= $prevLine->total_localtax2;
502 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
503 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
504 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
505 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
510 $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
515 $maxPrevSituationPercent = 0;
516 foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
517 foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) {
518 if ($prevLine->fk_prev_id == $source_fk_prev_id) {
519 $maxPrevSituationPercent = $prevLine->situation_percent;
521 $line->total_ht -= $prevLine->total_ht;
522 $line->total_tva -= $prevLine->total_tva;
523 $line->total_ttc -= $prevLine->total_ttc;
524 $line->total_localtax1 -= $prevLine->total_localtax1;
525 $line->total_localtax2 -= $prevLine->total_localtax2;
527 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
528 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
529 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
530 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
536 $line->situation_percent += $maxPrevSituationPercent;
544 $line->fk_facture = $creditnote->id;
545 $line->fk_parent_line = $fk_parent_line;
547 $line->subprice = -$line->subprice;
549 $line->total_ht = -$line->total_ht;
550 $line->total_tva = -$line->total_tva;
551 $line->total_ttc = -$line->total_ttc;
552 $line->total_localtax1 = -$line->total_localtax1;
553 $line->total_localtax2 = -$line->total_localtax2;
555 $line->multicurrency_subprice = -$line->multicurrency_subprice;
556 $line->multicurrency_total_ht = -$line->multicurrency_total_ht;
557 $line->multicurrency_total_tva = -$line->multicurrency_total_tva;
558 $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
560 $result = $line->insert(0, 1);
562 $creditnote->lines[] = $line;
565 if ($result > 0 && $line->product_type == 9) {
566 $fk_parent_line = $result;
569 $creditnote->update_price(1);
573 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
580 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
582 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
584 dol_syslog(
"Validate invoice with stock change into warehouse defined into constant ".$constantforkey.
" = ".
getDolGlobalString($constantforkey).
" or warehouseid= ".$warehouseid.
" if defined.");
589 $res = $creditnote->validate($user,
'',
getDolGlobalInt($constantforkey), 0, $batch_rule);
596 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
598 $res = $creditnote->validate($user);
602 if (!$error && $res >= 0) {
605 dol_syslog(
"Now we record the stock movement for each qualified line");
608 require_once DOL_DOCUMENT_ROOT .
"/product/stock/class/mouvementstock.class.php";
609 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
612 $labeltakeposmovement =
'TakePOS - '.$langs->trans(
"CreditNote").
' '.$creditnote->ref;
614 foreach ($creditnote->lines as $line) {
616 $warehouseid = ($line->fk_warehouse ? $line->fk_warehouse :
getDolGlobalInt($constantforkey));
619 if ($line->batch !=
'' && $warehouseid > 0) {
624 $mouvP->setOrigin($creditnote->element, $creditnote->id);
626 $res = $mouvP->reception($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'', $line->batch,
'', 0, $inventorycode);
633 $mouvP->setOrigin($creditnote->element, $creditnote->id);
635 $res = $mouvP->reception($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'',
'', 0, $inventorycode);
645 if (!$error && $res >= 0) {
648 $creditnote->id = $placeid;
653 if (($action ==
'history' || $action ==
'creditnote') && $user->hasRight(
'takepos',
'run')) {
654 if ($action ==
'creditnote' && $creditnote !==
null && $creditnote->id > 0) {
655 $placeid = $creditnote->id;
661 $invoice->fetch($placeid);
665 if (($action ==
"addline" || $action ==
"freezone") && $placeid == 0 && ($user->hasRight(
'takepos',
'run') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
668 $dolnowtzuserrel =
dol_now(
'tzuserrel');
672 $dateinvoice =
dol_mktime(0, 0, 0, (
int) $monthuser, (
int) $dayuser, (
int) $yearuser,
'tzserver');
674 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
675 $invoice->date = $dateinvoice;
689 $invoice->module_source =
'takepos';
690 $invoice->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
691 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] : $conf->entity;
693 if ($invoice->socid <= 0) {
694 $langs->load(
'errors');
700 $placeid = $invoice->create($user);
705 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture";
706 $sql .=
" SET ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
707 $sql .=
" WHERE rowid = ".((int) $placeid);
708 $resql = $db->query($sql);
723 if ($action ==
"addline" && ($user->hasRight(
'takepos',
'run') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
725 $prod->fetch($idproduct);
728 $customer->fetch($invoice->socid);
730 $datapriceofproduct = $prod->getSellPrice(
$mysoc, $customer, 0);
733 $price = $datapriceofproduct[
'pu_ht'];
734 $price_ttc = $datapriceofproduct[
'pu_ttc'];
736 $price_base_type = empty($datapriceofproduct[
'price_base_type']) ?
'HT' : $datapriceofproduct[
'price_base_type'];
737 $tva_tx = $datapriceofproduct[
'tva_tx'];
738 $tva_npr = (int) $datapriceofproduct[
'tva_npr'];
746 $batch =
GETPOST(
'batch',
'alpha');
748 if (!empty($batch)) {
749 $action =
"setbatch";
750 } elseif ($prod->status_batch > 0) {
755 $prod->load_stock(
'warehouseopen');
757 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
761 foreach ($prod->stock_warehouse as $tmpwarehouseid => $tmpval) {
766 if (!empty($prod->stock_warehouse[$tmpwarehouseid]) && is_array($prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
767 if (is_object($prod->stock_warehouse[$tmpwarehouseid]) && count($prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
768 foreach ($prod->stock_warehouse[$tmpwarehouseid]->detail_batch as $dbatch) {
777 echo
"function addbatch(batch, warehouseid) {\n";
778 echo
"console.log('We add batch '+batch+' from warehouse id '+warehouseid);\n";
779 echo
'$("#poslines").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?action=addline&batch="+encodeURI(batch)+"&warehouseid="+warehouseid+"&place='.$place.
'&idproduct='.$idproduct.
'&token='.
newToken().
'", function() {});'.
"\n";
784 echo
"<center>".$langs->trans(
"SearchIntoBatch").
": <b> $nbofsuggested </b></center><br><table>";
785 foreach ($prod->stock_warehouse as $tmpwarehouseid => $tmpval) {
790 if (!empty($prod->stock_warehouse[$tmpwarehouseid]) && is_array($prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
791 foreach ($prod->stock_warehouse[$tmpwarehouseid]->detail_batch as $dbatch) {
792 $batchStock = + $dbatch->qty;
793 $quantityToBeDelivered = 1;
794 $deliverableQty = min($quantityToBeDelivered, $batchStock);
796 print
'<!-- subj='.$suggestednb.
'/'.$nbofsuggested.
' -->';
797 print
'<!-- Show details of lot/serial in warehouseid='.$tmpwarehouseid.
' -->';
798 print
'<td class="left">';
800 $detail .=
'<span class="opacitymedium">'.$langs->trans(
"LotSerial").
':</span> '.$dbatch->batch;
807 $detail .=
'</td><td>';
808 $detail .=
'<span class="opacitymedium">'.$langs->trans(
"Qty").
':</span> '.$dbatch->qty;
809 $detail .=
'</td><td>';
810 $detail .=
' <button class="marginleftonly" onclick="addbatch(\''.dol_escape_js($dbatch->batch).
'\',
'.$tmpwarehouseid.')
">'.$langs->trans("Select
")."</
button>
";
814 $quantityToBeDelivered -= $deliverableQty;
815 if ($quantityToBeDelivered < 0) {
816 $quantityToBeDelivered = 0;
825 print '</body></html>';
831 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
832 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
833 $cat = new Categorie($db);
834 $categories = $cat->containing($idproduct, 'product');
835 $found = (array_search(getDolGlobalInt('TAKEPOS_SUPPLEMENTS_CATEGORY'), array_column($categories, 'id')));
836 if ($found !== false) { // If this product is a supplement
837 $sql = "SELECT fk_parent_line FROM
".MAIN_DB_PREFIX."facturedet where rowid =
".((int) $selectedline);
838 $resql = $db->query($sql);
839 $row = $db->fetch_array($resql);
840 if ($row[0] == null) {
841 $parent_line = $selectedline;
843 $parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product
849 // Group if enabled. Skip group if line already sent to the printer
850 if (getDolGlobalString('TAKEPOS_GROUP_SAME_PRODUCT')) {
851 foreach ($invoice->lines as $line) {
852 if ($line->product_ref == $prod->ref) {
853 if ($line->special_code == 4) {
855 } // If this line is sended to printer create new line
856 // check if qty in stock
857 if (getDolGlobalString('TAKEPOS_QTY_IN_STOCK') && (($line->qty + $qty) > $prod->stock_reel)) {
858 $invoice->error = $langs->trans("ErrorStockIsNotEnough
");
859 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
863 $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);
865 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
867 $idoflineadded = $line->id;
873 if ($idoflineadded <= 0 && empty($err)) {
874 $invoice->fetch_thirdparty();
875 $array_options = array();
877 $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);
879 /* setup of margin calculation */
880 if (getDolGlobalString('MARGIN_TYPE')) {
881 if (getDolGlobalString('MARGIN_TYPE') == 'pmp' && !empty($prod->pmp)) {
882 $line['fk_fournprice'] = null;
883 $line['pa_ht'] = $prod->pmp;
884 } elseif (getDolGlobalString('MARGIN_TYPE') == 'costprice' && !empty($prod->cost_price)) {
885 $line['fk_fournprice'] = null;
886 $line['pa_ht'] = $prod->cost_price;
888 // default is fournprice
889 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
890 $pf = new ProductFournisseur($db);
891 if ($pf->find_min_price_product_fournisseur($idproduct, $qty) > 0) {
892 $line['fk_fournprice'] = $pf->product_fourn_price_id;
893 $line['pa_ht'] = $pf->fourn_unitprice_with_discount;
894 if (getDolGlobalString('PRODUCT_CHARGES') && $pf->fourn_charges > 0) {
895 $line['pa_ht'] += (float) $pf->fourn_charges / $pf->fourn_qty;
901 // complete line by hook
902 $parameters = array('prod' => $prod, 'line' => $line);
903 $reshook = $hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action); // Note that $action and $line may have been modified by some hooks
905 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
909 if (empty($reshook)) {
910 if (!empty($hookmanager->resArray)) {
911 $line = $hookmanager->resArray;
914 // check if qty in stock
915 if (getDolGlobalString('TAKEPOS_QTY_IN_STOCK') && $qty > $prod->stock_reel) {
916 $invoice->error = $langs->trans("ErrorStockIsNotEnough
");
917 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
922 $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);
926 if (getDolGlobalString('TAKEPOS_CUSTOMER_DISPLAY')) {
927 $CUSTOMER_DISPLAY_line1 = $prod->label;
928 $CUSTOMER_DISPLAY_line2 = price($price_ttc);
932 $invoice->fetch($placeid);
935 // If we add a line by submitting freezone form (invoice exists here because it was created just before if it didn't exist)
936 if ($action == "freezone
" && $user->hasRight('takepos', 'run')) {
937 $customer = new Societe($db);
938 $customer->fetch($invoice->socid);
940 $tva_tx = GETPOST('tva_tx', 'alpha');
942 if (!preg_match('/\((.*)\)/', $tva_tx)) {
943 $tva_tx = price2num($tva_tx);
946 $tva_tx = get_default_tva($mysoc, $customer);
950 $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
951 $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
953 $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);
955 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
957 $invoice->fetch($placeid);
960 if ($action == "addnote
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
961 $desc = GETPOST('addnote', 'alpha');
963 $invoice->update_note($desc, '_public');
965 foreach ($invoice->lines as $line) {
966 if ($line->id == $idline) {
967 $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);
971 $invoice->fetch($placeid);
974 if ($action == "deleteline
" && ($user->hasRight('takepos', 'editlines') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
976 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
977 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
978 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
979 $permissiontoupdateline = true;
980 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
981 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
985 if ($idline > 0 && $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected.
986 $invoice->deleteLine($idline);
987 $invoice->fetch($placeid);
988 } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line.
989 $sql = "SELECT rowid FROM
".MAIN_DB_PREFIX."facturedet where fk_facture =
".((int) $placeid)." ORDER BY rowid DESC
";
990 $resql = $db->query($sql);
991 $row = $db->fetch_array($resql);
992 $deletelineid = $row[0];
993 $invoice->deleteLine($deletelineid);
994 $invoice->fetch($placeid);
997 if (count($invoice->lines) == 0) {
998 // Keep an empty draft invoice alive when a non-default customer was
999 // already attached so deleting the last line does not silently lose
1000 // the customer that was just selected (#38219). Only drop the invoice
1001 // when it is still on the default cashdesk thirdparty (or none).
1002 $defaultsocid = (int) getDolGlobalString('CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal
"]);
1003 $invoicesocid = (int) $invoice->socid;
1004 if ($invoicesocid === 0 || $invoicesocid === $defaultsocid) {
1005 $invoice->delete($user);
1007 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1008 header("Location:
".DOL_URL_ROOT."/takepos/public/auto_order.php
");
1010 header("Location:
".DOL_URL_ROOT."/takepos/invoice.php
");
1017 // Action to delete or discard an invoice
1018 if ($action == "delete
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1019 // $placeid is the invoice id (it differs from place) and is defined if the place is set and
1020 // the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal
"].'-'.$place.')', so the fetch at beginning of page works.
1022 $result = $invoice->fetch($placeid);
1024 if ($result > 0 && $invoice->status == Facture::STATUS_DRAFT) {
1027 // We delete the lines
1028 $resdeletelines = 1;
1029 foreach ($invoice->lines as $line) {
1030 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1031 $tmpres = $invoice->deleteLine($line->id);
1033 $resdeletelines = 0;
1038 $sql = "UPDATE
".MAIN_DB_PREFIX."facture
";
1039 $varforconst = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal
"];
1040 $sql .= " SET fk_soc =
".((int) getDolGlobalString($varforconst)).",
";
1041 $sql .= " datec =
'".$db->idate(dol_now())."'";
1042 $sql .= " WHERE entity IN (
".getEntity('invoice').")
";
1043 $sql .= " AND
ref =
'(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'";
1044 $resql1 = $db->query($sql);
1046 if ($resdeletelines && $resql1) {
1052 $invoice->fetch($placeid);
1057 if ($action == "updateqty
") { // Test on permission is done later
1058 foreach ($invoice->lines as $line) {
1059 if ($line->id == $idline) {
1060 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1061 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1062 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1063 $permissiontoupdateline = true;
1064 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1065 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1068 if (!$permissiontoupdateline) {
1069 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
").' - No permission to updateqty', [], 1);
1071 $vatratecode = $line->tva_tx;
1072 if ($line->vat_src_code) {
1073 $vatratecode .= ' ('.$line->vat_src_code.')';
1076 $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);
1081 $invoice->fetch($placeid);
1084 if ($action == "updateprice
") { // Test on permission is done later
1085 $customer = new Societe($db);
1086 $customer->fetch($invoice->socid);
1088 foreach ($invoice->lines as $line) {
1089 if ($line->id == $idline) {
1090 $prod = new Product($db);
1091 $prod->fetch($line->fk_product);
1092 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
1093 $price_min = $datapriceofproduct['price_min'];
1094 $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS'));
1096 $vatratecleaned = $line->tva_tx;
1098 if (preg_match('/^(.*)\s*\((.*)\)$/', (string) $line->tva_tx, $reg)) { // If vat is "xx (yy)
"
1099 $vatratecleaned = trim($reg[1]);
1100 //$vatratecode = $reg[2];
1103 $pu_ht = price2num((float) price2num($number, 'MU') / (1 + ((float) $vatratecleaned / 100)), 'MU');
1105 if ($usercanproductignorepricemin && (!empty($price_min) && ((float) price2num($pu_ht) * (1 - (float) price2num($line->remise_percent) / 100) < price2num($price_min)))) {
1106 $langs->load("products
");
1107 dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice
", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
1108 // echo $langs->trans("CantBeLessThanMinPrice
");
1110 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1111 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1112 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1113 $permissiontoupdateline = true;
1114 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1115 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1119 $vatratecode = $line->tva_tx;
1120 if ($line->vat_src_code) {
1121 $vatratecode .= ' ('.$line->vat_src_code.')';
1124 if (!$permissiontoupdateline) {
1125 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
").' - No permission to updateprice', [], 1);
1126 } elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) {
1127 $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);
1129 $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);
1136 $invoice->fetch($placeid);
1139 if ($action == "updatereduction
") { // Test on permission is done later
1140 $customer = new Societe($db);
1141 $customer->fetch($invoice->socid);
1143 foreach ($invoice->lines as $line) {
1144 if ($line->id == $idline) {
1145 dol_syslog("updatereduction Process line
".$line->id.' to apply discount of '.$number.'%');
1147 $prod = new Product($db);
1148 $prod->fetch($line->fk_product);
1150 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
1151 $price_min = $datapriceofproduct['price_min'];
1152 $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS'));
1154 $pu_ht = price2num($line->subprice / (1 + ($line->tva_tx / 100)), 'MU');
1157 if ($usercanproductignorepricemin && (!empty($price_min) && ((float) price2num($line->subprice) * (1 - (float) price2num($number) / 100) < (float) price2num($price_min)))) {
1158 $langs->load("products
");
1159 dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice
", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
1161 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1162 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1163 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1164 $permissiontoupdateline = true;
1165 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1166 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1169 if (!$permissiontoupdateline) {
1170 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
"), [], 1);
1172 $vatratecode = $line->tva_tx;
1173 if ($line->vat_src_code) {
1174 $vatratecode .= ' ('.$line->vat_src_code.')';
1176 $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);
1183 $invoice->fetch($placeid);
1184 } elseif ($action == 'update_reduction_global' && $user->hasRight('takepos', 'editlines')) {
1185 foreach ($invoice->lines as $line) {
1186 $vatratecode = $line->tva_tx;
1187 if ($line->vat_src_code) {
1188 $vatratecode .= ' ('.$line->vat_src_code.')';
1190 $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);
1193 $invoice->fetch($placeid);
1196 if ($action == "setbatch
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1197 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
1198 $warehouseid = (GETPOSTINT('warehouseid') > 0 ? GETPOSTINT('warehouseid') : getDolGlobalInt($constantforkey)); // Get the warehouse id from GETPOSTINT('warehouseid'), otherwise use default setup.
1199 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet SET batch =
'".$db->escape($batch)."', fk_warehouse =
".((int) $warehouseid);
1200 $sql .= " WHERE rowid=
".((int) $idoflineadded);
1204 if ($action == "order
" && $placeid != 0 && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1205 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1206 if ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1207 require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
1208 $printer = new dolReceiptPrinter($db);
1211 $sql = "SELECT label FROM
".MAIN_DB_PREFIX."takepos_floor_tables where rowid=
".((int) $place);
1212 $resql = $db->query($sql);
1213 $row = $db->fetch_object($resql);
1214 $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>';
1215 $footerorder = '</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>';
1216 $order_receipt_printer1 = "";
1217 $order_receipt_printer2 = "";
1218 $order_receipt_printer3 = "";
1219 $catsprinter1 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_1'));
1220 $catsprinter2 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_2'));
1221 $catsprinter3 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_3'));
1223 foreach ($invoice->lines as $line) {
1224 if ($line->special_code == "4
") {
1227 $c = new Categorie($db);
1228 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1229 $result = array_intersect($catsprinter1, $existing);
1230 $count = count($result);
1231 if (!$line->fk_product) {
1232 $count++; // Print Free-text item (Unassigned printer) to Printer 1
1236 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet set special_code=
'1' where rowid=
".$line->id; //Set to print on printer 1
1238 $order_receipt_printer1 .= '<tr><td class="left
">';
1239 if ($line->fk_product) {
1240 $order_receipt_printer1 .= $line->product_label;
1242 $order_receipt_printer1 .= $line->description;
1244 $order_receipt_printer1 .= '</td><td class="right
">'.$line->qty;
1245 if (!empty($line->array_options['options_order_notes'])) {
1246 $order_receipt_printer1 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1248 $order_receipt_printer1 .= '</td></tr>';
1251 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0 && $printer !== null) {
1252 $invoice->fetch($placeid); //Reload object before send to printer
1253 $printer->orderprinter = 1;
1255 echo "var orderprinter1esc=
'";
1256 $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
1259 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'1' and fk_facture=
".$invoice->id; // Set as printed
1261 $invoice->fetch($placeid); //Reload object after set lines as printed
1264 foreach ($invoice->lines as $line) {
1265 if ($line->special_code == "4
") {
1268 $c = new Categorie($db);
1269 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1270 $result = array_intersect($catsprinter2, $existing);
1271 $count = count($result);
1274 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'2' where rowid=
".$line->id; //Set to print on printer 2
1276 $order_receipt_printer2 .= '<tr>'.$line->product_label.'<td class="right
">'.$line->qty;
1277 if (!empty($line->array_options['options_order_notes'])) {
1278 $order_receipt_printer2 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1280 $order_receipt_printer2 .= '</td></tr>';
1283 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0) {
1284 $invoice->fetch($placeid); //Reload object before send to printer
1285 $printer->orderprinter = 2;
1287 echo "var orderprinter2esc=
'";
1288 $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
1291 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'2' and fk_facture=
".$invoice->id; // Set as printed
1293 $invoice->fetch($placeid); //Reload object after set lines as printed
1296 foreach ($invoice->lines as $line) {
1297 if ($line->special_code == "4
") {
1300 $c = new Categorie($db);
1301 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1302 $result = array_intersect($catsprinter3, $existing);
1303 $count = count($result);
1306 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'3' where rowid=
".$line->id; //Set to print on printer 3
1308 $order_receipt_printer3 .= '<tr>'.$line->product_label.'<td class="right
">'.$line->qty;
1309 if (!empty($line->array_options['options_order_notes'])) {
1310 $order_receipt_printer3 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1312 $order_receipt_printer3 .= '</td></tr>';
1315 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0 && $printer !== null) {
1316 $invoice->fetch($placeid); //Reload object before send to printer
1317 $printer->orderprinter = 3;
1319 echo "var orderprinter3esc=
'";
1320 $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
1323 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'3' and fk_facture=
".$invoice->id; // Set as printed
1325 $invoice->fetch($placeid); //Reload object after set lines as printed
1328 $sectionwithinvoicelink = '';
1329 if (($action == "valid
" || $action == "history
" || $action == 'creditnote' || ($action == 'addline' && $invoice->status == $invoice::STATUS_CLOSED)) && $user->hasRight('takepos', 'run')) {
1330 $sectionwithinvoicelink .= '<!-- Section with invoice link -->'."\n
";
1331 $sectionwithinvoicelink .= '<span style="font-size:120%;
" class="center
inline-block marginbottomonly
">';
1332 $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." -
";
1333 $remaintopay = $invoice->getRemainToPay();
1334 if ($remaintopay > 0) {
1335 $sectionwithinvoicelink .= $langs->trans('RemainToPay').': <span class="amountremaintopay
" style="font-size: unset
">'.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
1337 $sectionwithinvoicelink .= $invoice->getLibStatut(2);
1340 $sectionwithinvoicelink .= '</span><br>';
1342 $customprinterallowed = true;
1343 $customprinttemplateallowed = true;
1344 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
1345 if (isALNERunningVersion()) { // No need to show this option because it has no effect when isALNERunningVersion is true.
1346 $customprinttemplateallowed = false; // Custom printer may be allowed if mandatory information in template are guaranteed. For the moment, we prefer not allow this.
1349 if ($invoice->status == $invoice::STATUS_CLOSED) {
1350 if (getDolGlobalInt('TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
1351 $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>';
1352 } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1353 // Used when the external addon takeposconnector is installed. Deprecated.
1354 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
1355 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="TakeposConnector(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1357 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="TakeposPrinting(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1359 } elseif ($customprinterallowed && (isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") { // @phpstan-ignore-line
1360 // If we set to use a specific receipt printer
1361 $nameOfPrinter = dol_getIdFromCode($db, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term), 'printer_receipt', 'rowid', 'name', 1);
1362 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="DolibarrTakeposPrinting(
'.$placeid.')
" title="'.dolPrintHTMLForAttribute($langs->trans("SentToPrinter").' '.$nameOfPrinter).'">'.$langs->trans('PrintTicket').'</button>';
1364 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="Print(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1365 if ($customprinttemplateallowed && getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) {
1366 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintBox(
'.$placeid.', \
'without_details\')">'.$langs->trans(
'PrintWithoutDetails').
'</button>';
1369 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="Print('.$placeid.
', 1)">'.$langs->trans(
'GiftReceipt').
'</button>';
1373 $sectionwithinvoicelink .=
' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.
')">'.$langs->trans(
'SendTicket').
'</button>';
1376 if ($remaintopay <= 0 &&
getDolGlobalString(
'TAKEPOS_AUTO_PRINT_TICKETS') && $action !=
"history") {
1377 $sectionwithinvoicelink .=
'<script type="text/javascript">console.log("Emulate click on #buttonprint"); $("#buttonprint").click();</script>';
1388$form =
new Form($db);
1391if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1392 $title =
'TakePOS - Dolibarr '.DOL_VERSION;
1396 $head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
1397 <meta name="apple-mobile-web-app-capable" content="yes">
1398 <meta name="mobile-web-app-capable" content="yes">
1399 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
1400 $arrayofcss = array(
1401 '/takepos/css/pos.css.php',
1403 $arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
1406 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
1408 print
'<body>'.
"\n";
1415<script
type=
"text/javascript">
1418<?php
if ($action ==
"valid") {
1419 echo
"var place=0;";
1421var placeid=<?php echo($placeid > 0 ? $placeid : 0); ?>;
1422$(document).ready(
function() {
1423 var idoflineadded = <?php echo(empty($idoflineadded) ? 0 : $idoflineadded); ?>;
1425 $(
'.posinvoiceline').click(
function(){
1426 console.log(
"Click done on "+this.
id);
1427 $(
'.posinvoiceline').removeClass(
"selected");
1428 $(
this).addClass(
"selected");
1432 if (selectedline == this.
id) {
1435 selectedline = this.id;
1437 selectedtext=$(
'#'+selectedline).find(
"td:first").html();
1439 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1440 print
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?action=editline&token='.
newToken().
'&placeid="+placeid+"&selectedline="+selectedline, function() {
1447 if (idoflineadded > 0)
1449 console.log(
"Auto select "+idoflineadded);
1450 $(
'.posinvoiceline#'+idoflineadded).click();
1454if ($action ==
"order" && !empty($order_receipt_printer1)) {
1455 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1459 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php',
1460 data:
'invoice='+orderprinter1esc
1467 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1469 print $headerorder.$order_receipt_printer1.$footerorder; ?>'
1475if ($action ==
"order" && !empty($order_receipt_printer2)) {
1476 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1480 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php?printer=2',
1481 data:
'invoice='+orderprinter2esc
1488 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print2',
1490 print $headerorder.$order_receipt_printer2.$footerorder; ?>'
1496if ($action ==
"order" && !empty($order_receipt_printer3)) {
1497 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1501 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php?printer=3',
1502 data:
'invoice='+orderprinter3esc
1509if ($action ==
"search" || $action ==
"valid") {
1511 parent.ClearSearch(
true);
1516if ($action ==
"temp" && !empty($ticket_printer1)) {
1520 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1522 print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>'
1527if ($action ==
"search") {
1529 $(
'#search').focus();
1537function SendTicket(
id)
1539 console.log(
"Open box to select the Print/Send form");
1540 $.colorbox({href:
"send.php?facid="+id, width:
"70%", height:
"30%", transition:
"none", iframe:
"true", title:
'<?php echo dol_escape_js($langs->trans("SendTicket")); ?>'});
1545function PrintBox(
id, action) {
1546 console.log(
"Open box before printing");
1547 $.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
"); ?>"});
1552function Print(
id, gift) {
1556 console.log(
"Call Print() to generate the receipt.");
1557 $.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")); ?>'});
1562function TakeposPrinting(
id){
1564 console.log(
"TakeposPrinting" +
id);
1565 $.get(
"receipt.php?facid="+
id,
function(data,
status) {
1566 receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,
'');
1569 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1576function TakeposConnector(
id){
1577 console.log(
"TakeposConnector" +
id);
1578 $.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) {
1581 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php',
1582 data:
'invoice='+data
1593function DolibarrTakeposPrinting(
id) {
1594 console.log(
"DolibarrTakeposPrinting Printing invoice ticket by calling takepos/aja/ajax.php" +
id);
1598 data: { token:
'<?php echo currentToken(); ?>' },
1599 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=printinvoiceticket&token='.newToken().'&term='.urlencode(isset($_SESSION["takeposterminal
"]) ? $_SESSION["takeposterminal
"] : '').'&id='; ?>" + id,
1600 success:
function(){
1601 showPrintResultPopup(
'<?php echo dol_escape_js($langs->trans("SentToPrinter").' '.$nameOfPrinter); ?>', 2000);
1604 showPrintResultPopup(
"<?php echo dol_escape_js($langs->trans("FailedToSendToPrinter
")); ?>", 2000);
1611function showPrintResultPopup(message, duration) {
1612 $(
"#dialogforpopuptakepos").show().text(message).fadeIn();
1614 setTimeout(
function(){
1615 $(
"#dialogforpopuptakepos").fadeOut().hide();
1622function CreditNote() {
1623 $(
"#poslines").load(
"<?php print DOL_URL_ROOT; ?>/takepos/invoice.php?action=creditnote&token=<?php echo newToken() ?>&invoiceid="+placeid,
function() { });
1629 $(
"#poslines").load(
"<?php print DOL_URL_ROOT; ?>/takepos/invoice.php?action=addnote&token=<?php echo newToken() ?>&invoiceid="+placeid+
"&idline="+selectedline, {
"addnote": $(
"#textinput").val() });
1634$( document ).ready(
function() {
1635 console.log(
"Set customer info and sales in header placeid=<?php echo $placeid; ?> status=<?php echo $invoice->statut; ?>");
1638 $s = $langs->trans(
"Customer");
1639 if ($invoice->id > 0 && ($invoice->socid !=
getDolGlobalString($constforcompanyid))) {
1642 $contactids = $invoice->getIdContact(
'external',
'BILLING');
1643 $contactid = $contactids[0];
1644 if ($contactid > 0) {
1646 $contact->fetch($contactid);
1647 $s .=
" - " . $contact->getFullName($langs);
1651 print
'$("#idcustomer").val("");';
1655 $(
"#customerandsales").html(
'');
1656 $(
"#shoppingcart").html(
'');
1659 $(
"#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>');
1661 $(
"#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>');
1665 $sql =
"SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX.
"facture";
1666 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
1669 $sql .=
" AND ref LIKE '(PROV-POS".$db->escape(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'').
"-0%'";
1672 $sql .=
" AND pos_source = '".$db->escape((
string) $_SESSION[
"takeposterminal"]).
"'";
1673 $sql .=
" AND module_source = 'takepos'";
1676 $sql .= $db->order(
'datec',
'ASC');
1677 $resql = $db->query($sql);
1680 while ($obj = $db->fetch_object($resql)) {
1681 echo
'$("#shoppingcart").append(\'';
1682 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=\\\'';
1683 $num_sale = str_replace(
")",
"", str_replace(
"(PROV-POS".$_SESSION[
"takeposterminal"].
"-",
"", $obj->ref));
1685 if (str_replace(
"-",
"", $num_sale) > $max_sale) {
1686 $max_sale = str_replace(
"-",
"", $num_sale);
1688 echo
'\\\'; invoiceid=\\\'';
1690 echo
'\\\'; Refresh();">';
1691 if ($placeid == $obj->rowid) {
1692 echo
'<span class="basketselected">';
1694 echo
'<span class="basketnotselected">';
1696 echo
'<span class="fa fa-shopping-cart paddingright"></span>'.dol_print_date($db->jdate($obj->datec),
'%H:%M',
'tzuser');
1700 echo
'$("#shoppingcart").append(\'<a onclick="place=\\\'0-';
1702 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>\');';
1710 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1713 $constantforkey =
'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1715 if ($idwarehouse > 0) {
1716 $s =
'<span class="small">';
1718 $warehouse->fetch($idwarehouse);
1719 $s .=
'<span class="hideonsmartphone">'.$langs->trans(
"Warehouse").
'<br></span>'.$warehouse->ref;
1721 $s .=
' ('.$langs->trans(
"Closed").
')';
1724 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1725 print
'$("#infowarehouse").css("display", "inline-block");';
1727 $s =
'<span class="small hideonsmartphone">';
1728 $s .= $langs->trans(
"StockChangeDisabled").
'<br>'.$langs->trans(
"NoWarehouseDefinedForTerminal");
1730 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1731 if (!empty($conf->dol_optimize_smallscreen)) {
1732 print
'$("#infowarehouse").css("display", "none");';
1736 $s =
'<span class="small hideonsmartphone">'.$langs->trans(
"StockChangeDisabled").
'</span>';
1737 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1738 if (!empty($conf->dol_optimize_smallscreen)) {
1739 print
'$("#infowarehouse").css("display", "none");';
1748 $s =
'<span class="small">';
1749 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1750 $langs->load(
"members");
1751 $s .= $langs->trans(
"Member").
': ';
1753 $result = $adh->fetch(0,
'', $invoice->socid);
1755 $adh->ref = $adh->getFullName($langs);
1759 $s .= $adh->getFullName($langs);
1760 $s .=
' - '.$adh->type;
1761 if ($adh->datefin) {
1762 $s .=
'<br>'.$langs->trans(
"SubscriptionEndDate").
': '.
dol_print_date($adh->datefin,
'day');
1763 if ($adh->hasDelay()) {
1764 $s .=
" ".img_warning($langs->trans(
"Late"));
1767 $s .=
'<br>'.$langs->trans(
"SubscriptionNotReceived");
1768 if ($adh->status > 0) {
1769 $s .=
" ".img_warning($langs->trans(
"Late"));
1776 $s .=
'<br>'.$langs->trans(
"ThirdpartyNotLinkedToMember");
1781 $(
"#moreinfo").html(
'<?php print dol_escape_js($s); ?>');
1788 echo
"function CustomerDisplay(){";
1789 echo
"var line1='".$CUSTOMER_DISPLAY_line1.
"'.substring(0,20);";
1790 echo
"line1=line1.padEnd(20);";
1791 echo
"var line2='".$CUSTOMER_DISPLAY_line2.
"'.substring(0,20);";
1792 echo
"line2=line2.padEnd(20);";
1795 data: { text: line1+line2 },
1796 url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER').
"/display/index.php',
1807if (!empty($conf->use_javascript_ajax)) {
1808 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
1809 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.
'"></script>'.
"\n";
1812$usediv = (
GETPOST(
'format') ==
'div');
1814print
'<!-- 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";
1815print
'<div class="div-table-responsive-no-min invoice">';
1817 print
'<div id="tablelines">';
1819 print
'<table id="tablelines" class="noborder noshadow postablelines centpercent">';
1822$buttontocreatecreditnote =
'';
1823if (($action ==
"valid" || $action ==
"history" || ($action ==
"addline" && $invoice->status == $invoice::STATUS_CLOSED)) && $invoice->type !=
Facture::TYPE_CREDIT_NOTE && !
getDolGlobalString(
'TAKEPOS_NO_CREDITNOTE')) {
1824 $buttontocreatecreditnote .=
' <!-- Show button to create a credit note -->'.
"\n";
1825 $buttontocreatecreditnote .=
'<button id="buttonprint" type="button" onclick="ModalBox(\'ModalCreditNote\')">'.$langs->trans(
'CreateCreditNote').
'</button>';
1826 if (
getDolGlobalInt(
'TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
1827 $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>';
1832if ($sectionwithinvoicelink && ($mobilepage ==
"invoice" || $mobilepage ==
"")) {
1833 print
'<!-- Print table line with link to invoice ref -->';
1835 print
'<tr><td colspan="5" class="paddingtopimp paddingbottomimp" style="padding-top: 10px !important; padding-bottom: 10px !important;">';
1836 print $sectionwithinvoicelink;
1837 print $buttontocreatecreditnote;
1840 print
'<tr><td colspan="4" class="paddingtopimp paddingbottomimp" style="padding-top: 10px !important; padding-bottom: 10px !important;">';
1841 print $sectionwithinvoicelink;
1842 print $buttontocreatecreditnote;
1849 print
'<tr class="liste_titre nodrag nodrop">';
1850 print
'<td class="linecoldescription">';
1853if (empty($mobilepage) || $mobilepage ==
"invoice") {
1854 print
'<!-- hidden var used by some js functions -->';
1855 print
'<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.
'">';
1856 print
'<input type="hidden" name="thirdpartyid" id="thirdpartyid" value="'.$invoice->socid.
'">';
1860 $sql =
"SELECT floor, label FROM ".MAIN_DB_PREFIX.
"takepos_floor_tables where rowid=".((int) $place);
1861 $resql = $db->query($sql);
1862 $obj = $db->fetch_object($resql);
1864 $label = $obj->label;
1865 $floor = $obj->floor;
1867 if ($mobilepage ==
"invoice" || $mobilepage ==
"") {
1870 print
'<span class="opacitymedium">'.$langs->trans(
'Place').
"</span> <b>".(empty($label) ?
'?' : $label).
"</b><br>";
1871 print
'<span class="opacitymedium">'.$langs->trans(
'Floor').
"</span> <b>".(empty($floor) ?
'?' : $floor).
"</b>";
1878$parameters = array();
1879$reshook = $hookmanager->executeHooks(
'completeTakePosInvoiceHeader', $parameters, $invoice, $action);
1883print $hookmanager->resPrint;
1885if (empty($_SESSION[
"basiclayout"]) || $_SESSION[
"basiclayout"] != 1) {
1887 print
'<td class="linecolqty right">'.$langs->trans(
'PriceUHT').
'</td>';
1889 print
'<td class="linecolqty right">'.$langs->trans(
'ReductionShort').
'</td>';
1890 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
1892 print
'<td class="linecolht right nowraponall">';
1893 print
'<span class="opacitymedium small">' . $langs->trans(
'TotalHTShort') .
'</span><br>';
1895 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1896 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>';
1897 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"]) && $conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
1899 include_once DOL_DOCUMENT_ROOT .
'/multicurrency/class/multicurrency.class.php';
1901 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
1902 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>';
1907 print
'<td class="linecolht right nowraponall">';
1908 print
'<span class="opacitymedium small">'.$langs->trans(
'TotalTTCShort').
'</span><br>';
1910 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1911 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>';
1912 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"]) && $conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
1914 include_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
1916 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
1917 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>';
1921} elseif ($mobilepage ==
"invoice") {
1922 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
1928if (!empty($_SESSION[
"basiclayout"]) && $_SESSION[
"basiclayout"] == 1) {
1929 if ($mobilepage ==
"cats") {
1930 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1932 $categories = $categorie->get_full_arbo(
'product');
1934 foreach ($categories as $row) {
1935 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1936 $htmlforlines .=
'<div class="leftcat"';
1938 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline"';
1940 $htmlforlines .=
' onclick="LoadProducts('.$row[
'id'].
');">';
1941 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1942 $htmlforlines .=
'<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=cat&query=cat&id='.$row[
'id'].
'"><br>';
1944 $htmlforlines .=
'<td class="left">';
1946 $htmlforlines .= $row[
'label'];
1947 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1948 $htmlforlines .=
'</div>'.
"\n";
1950 $htmlforlines .=
'</td></tr>'.
"\n";
1953 print $htmlforlines;
1956 if ($mobilepage ==
"products") {
1957 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1960 $result =
$object->fetch($catid);
1961 $prods =
$object->getObjectsInCateg(
"product");
1963 '@phan-var-force Product[] $prods';
1965 foreach ($prods as $row) {
1966 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1967 $htmlforlines .=
'<div class="leftcat"';
1969 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline"';
1971 $htmlforlines .=
' onclick="AddProduct(\''.$place.
'\',
'.$row->id.')
"';
1972 $htmlforlines .= '>';
1973 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1974 $htmlforlines .= '<img class="imgwrapper
" width="33%
" src="'.DOL_URL_ROOT.'/takepos/
public/auto_order.php?genimg=pro&query=pro&
id=
'.$row->id.'"><br>';
1975 $htmlforlines .= $row->label.' '.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency);
1976 $htmlforlines .= '</div>'."\n
";
1978 $htmlforlines .= '<td class="left
">';
1979 $htmlforlines .= $row->label;
1980 $htmlforlines .= '<div class="right
">'.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).'</div>';
1981 $htmlforlines .= '</td>';
1982 $htmlforlines .= '</tr>'."\n
";
1985 print $htmlforlines;
1988 if ($mobilepage == "places
") {
1989 $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM
".MAIN_DB_PREFIX."takepos_floor_tables
";
1990 $resql = $db->query($sql);
1994 while ($row = $db->fetch_array($resql)) {
1996 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
1997 $htmlforlines .= '" onclick="LoadPlace(\
''.$row[
'label'].
'\')
">';
1998 $htmlforlines .= '<td class="left
">';
1999 $htmlforlines .= $row['label'];
2000 $htmlforlines .= '</td>';
2001 $htmlforlines .= '</tr>'."\n
";
2003 print $htmlforlines;
2008 //In Phone basic layout hide some content depends situation
2009 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1 && $mobilepage != "invoice
" && $action != "order
") {
2013 // Loop on each lines on invoice
2014 if (is_array($invoice->lines) && count($invoice->lines)) {
2015 print '<!-- invoice.php show lines of invoices -->'."\n
";
2016 $tmplines = array_reverse($invoice->lines);
2017 $htmlsupplements = array();
2018 foreach ($tmplines as $line) {
2019 if ($line->fk_parent_line != false) {
2020 $htmlsupplements[$line->fk_parent_line] .= '<tr class="drag drop oddeven posinvoiceline
';
2021 if ($line->special_code == "4") {
2022 $htmlsupplements[$line->fk_parent_line] .= ' order
';
2024 $htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'"';
2025 if ($line->special_code == "4
") {
2026 $htmlsupplements[$line->fk_parent_line] .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
2028 $htmlsupplements[$line->fk_parent_line] .= '>';
2029 $htmlsupplements[$line->fk_parent_line] .= '<td class="left
">';
2030 $htmlsupplements[$line->fk_parent_line] .= img_picto('', 'rightarrow.png');
2031 if ($line->product_label) {
2032 $htmlsupplements[$line->fk_parent_line] .= $line->product_label;
2034 if ($line->product_label && $line->desc) {
2035 $htmlsupplements[$line->fk_parent_line] .= '<br>';
2037 if ($line->product_label != $line->desc) {
2038 $firstline = dolGetFirstLineOfText($line->desc);
2039 if ($firstline != $line->desc) {
2040 $htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
2042 $htmlsupplements[$line->fk_parent_line] .= $line->desc;
2045 $htmlsupplements[$line->fk_parent_line] .= '</td>';
2047 // complete line by hook
2048 $parameters = array('line' => $line);
2049 $reshook = $hookmanager->executeHooks('completeTakePosInvoiceParentLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
2051 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2053 $htmlsupplements[$line->fk_parent_line] .= $hookmanager->resPrint;
2055 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2056 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.vatrate(price2num($line->remise_percent), true).'</td>';
2057 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.$line->qty.'</td>';
2058 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.price($line->total_ttc).'</td>';
2060 $htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n
";
2065 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
2066 if ($line->special_code == "4") {
2067 $htmlforlines .= ' order
';
2069 $htmlforlines .= '" id="'.$line->id.'"';
2070 if ($line->special_code == "4
") {
2071 $htmlforlines .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
2073 $htmlforlines .= '>';
2074 $htmlforlines .= '<td class="left
">';
2075 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
2076 $htmlforlines .= '<span class="phoneqty
">'.$line->qty."</span> x
";
2078 if (isset($line->product_type)) {
2079 if (empty($line->product_type)) {
2080 $htmlforlines .= img_object('', 'product').' ';
2082 $htmlforlines .= img_object('', 'service').' ';
2086 if (!getDolGlobalString('TAKEPOS_SHOW_N_FIRST_LINES')) {
2087 if ($line->product_ref) {
2088 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
2089 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
2090 if (!empty($line->batch)) {
2091 $tooltiptext .= '<br><b>'.$langs->trans("LotSerial
").'</b> : '.$line->batch.'<br>';
2093 if (!empty($line->fk_warehouse)) {
2094 $tooltiptext .= '<b>'.$langs->trans("Warehouse
").'</b> : '.$line->fk_warehouse.'<br>';
2096 if ($line->product_label != $line->desc) {
2098 $tooltiptext .= '<br>';
2100 $tooltiptext .= $line->desc;
2103 if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
2104 $htmlforlines .= $form->textwithpicto($line->product_label ? '<b>' . $line->product_ref . '</b> - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
2105 } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) {
2106 $htmlforlines .= $form->textwithpicto($line->product_ref ? '<b>'.$line->product_ref.'<b>' : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
2108 $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
2111 if ($line->product_ref) {
2112 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
2113 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
2115 if (!empty($line->batch)) {
2116 $tooltiptext .= '<br><b>'.$langs->trans("LotSerial
").'</b> : '.$line->batch.'<br>';
2118 if (!empty($line->fk_warehouse)) {
2119 $tooltiptext .= '<b>'.$langs->trans("Warehouse
").'</b> : '.$line->fk_warehouse.'<br>';
2122 if ($line->product_label) {
2123 $htmlforlines .= $line->product_label;
2125 if ($line->product_label != $line->desc) {
2126 if ($line->product_label && $line->desc) {
2127 $htmlforlines .= '<br>';
2129 $firstline = dolGetFirstLineOfText($line->desc, getDolGlobalInt('TAKEPOS_SHOW_N_FIRST_LINES'));
2130 if ($firstline != $line->desc) {
2131 $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
2133 $htmlforlines .= $line->desc;
2137 if (!empty($line->array_options['options_order_notes'])) {
2138 $htmlforlines .= "<br>(
".$line->array_options['options_order_notes'].")
";
2140 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
2141 $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>';
2143 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2145 $moreinfo .= $langs->transcountry("TotalHT
", $mysoc->country_code).': '.price($line->total_ht);
2146 if ($line->vat_src_code) {
2147 $moreinfo .= '<br>'.$langs->trans("VATCode
").': '.$line->vat_src_code;
2149 $moreinfo .= '<br>'.$langs->transcountry("TotalVAT
", $mysoc->country_code).': '.price($line->total_tva);
2150 $moreinfo .= '<br>'.$langs->transcountry("TotalLT1
", $mysoc->country_code).': '.price($line->total_localtax1);
2151 $moreinfo .= '<br>'.$langs->transcountry("TotalLT2
", $mysoc->country_code).': '.price($line->total_localtax2);
2152 $moreinfo .= '<hr>';
2153 $moreinfo .= $langs->transcountry("TotalTTC
", $mysoc->country_code).': '.price($line->total_ttc);
2154 //$moreinfo .= $langs->trans("TotalHT
").': '.$line->total_ht;
2155 if ($line->date_start || $line->date_end) {
2156 $htmlforlines .= '<br><div class="clearboth nowraponall
">'.get_date_range($line->date_start, $line->date_end).'</div>';
2158 $htmlforlines .= '</td>';
2160 // complete line by hook
2161 $parameters = array('line' => $line);
2162 $reshook = $hookmanager->executeHooks('completeTakePosInvoiceLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
2164 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2166 $htmlforlines .= $hookmanager->resPrint;
2168 if (getDolGlobalInt("TAKEPOS_SHOW_SUBPRICE
")) {
2169 $htmlforlines .= '<td class="right
">'.price($line->subprice).'</td>';
2171 $htmlforlines .= '<td class="right
">'.vatrate(price2num($line->remise_percent), true).'</td>';
2172 $htmlforlines .= '<td class="right
">';
2173 $htmlforlines .= $line->qty;
2174 if (isModEnabled('stock') && $user->hasRight('stock', 'mouvement', 'lire')) {
2175 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
2176 if (getDolGlobalString($constantforkey) && $line->fk_product > 0 && !getDolGlobalString('TAKEPOS_HIDE_STOCK_ON_LINE')) {
2177 $productChildrenNb = 0;
2178 if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
2179 if (empty($line->product) || !($line->product->id > 0)) {
2180 $line->fetch_product();
2182 if (!empty($line->product)) {
2183 $productChildrenNb = $line->product->hasFatherOrChild(1);
2186 if ($productChildrenNb == 0) {
2187 $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp
";
2188 $sql .= " FROM
".MAIN_DB_PREFIX."entrepot as e,
";
2189 $sql .= " ".MAIN_DB_PREFIX."product_stock as ps
";
2190 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product
";
2191 $sql .= " WHERE ps.reel != 0
";
2192 $sql .= " AND ps.fk_entrepot =
".((int) getDolGlobalString($constantforkey));
2193 $sql .= " AND e.entity IN (
".getEntity('stock').")
";
2194 $sql .= " AND ps.fk_product =
".((int) $line->fk_product);
2195 $resql = $db->query($sql);
2198 $obj = $db->fetch_object($resql);
2200 $stock_real = price2num($obj->reel, 'MS');
2202 $htmlforlines .= ' ';
2203 $htmlforlines .= '<span class="opacitylow
" title="'.$langs->trans("Stock").' '.price($stock_real, 1, '', 1, 0).'">';
2204 $htmlforlines .= '(';
2205 if ($line->qty && $line->qty > $stock_real) {
2206 $htmlforlines .= '<span style="color: var(--amountremaintopaycolor)
">';
2208 $htmlforlines .= img_picto('', 'stock', 'class="pictofixedwidth
"').price($stock_real, 1, '', 1, 0);
2209 if ($line->qty && $line->qty > $stock_real) {
2210 $htmlforlines .= "</span>
";
2212 $htmlforlines .= ')';
2213 $htmlforlines .= '</span>';
2215 dol_print_error($db);
2221 $htmlforlines .= '</td>';
2222 if (getDolGlobalInt('TAKEPOS_SHOW_HT')) {
2223 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
2224 $htmlforlines .= price($line->total_ht, 1, '', 1, -1, -1, $conf->currency);
2225 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
2226 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
2227 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
2228 $multicurrency = new MultiCurrency($db);
2229 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
2230 $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>';
2232 $htmlforlines .= '</td>';
2234 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
2235 $htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency);
2236 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
2237 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
2238 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
2239 $multicurrency = new MultiCurrency($db);
2240 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
2241 $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>';
2243 $htmlforlines .= '</td>';
2245 $htmlforlines .= '</tr>'."\n
";
2246 $htmlforlines .= empty($htmlsupplements[$line->id]) ? '' : $htmlsupplements[$line->id];
2248 print $htmlforlines;
2251 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td>';
2252 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2253 print '<td></td><td></td>';
2254 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
2260} else { // No invoice generated yet
2261 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td>';
2262 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2263 print '<td></td><td></td>';
2264 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
2277if ($action == "search
") {
2279 <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
')).'">
2286if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2287 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.