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);
211$sectionwithinvoicelink =
'';
212$CUSTOMER_DISPLAY_line1 =
'';
213$CUSTOMER_DISPLAY_line2 =
'';
222if (in_array($action, array(
'deleteline',
'updateqty',
'updateprice',
'updatereduction',
'update_reduction_global')) && !$user->hasRight(
'takepos',
'editlines')) {
228if (empty($reshook)) {
230 if ($action ==
'valid' && $user->hasRight(
'facture',
'creer')) {
238 $bankaccount =
getDolGlobalInt(
'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION[
"takeposterminal"]);
239 } elseif ($pay ==
"CHQ") {
240 $bankaccount =
getDolGlobalInt(
'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION[
"takeposterminal"]);
242 $accountname =
"CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION[
"takeposterminal"];
247 if ($bankaccount <= 0 && $pay !=
"delayed" &&
isModEnabled(
"bank")) {
248 $errormsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount"));
256 $invoice->fetch($placeid);
258 $invoice->oldcopy =
dol_clone($invoice, 2);
262 if ($invoice->total_ttc < 0) {
263 $invoice->type = $invoice::TYPE_CREDIT_NOTE;
265 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
266 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
267 $sql .=
" AND fk_soc = ".((int) $invoice->socid);
268 $sql .=
" AND type <> ".Facture::TYPE_CREDIT_NOTE;
269 $sql .=
" AND fk_statut >= ".$invoice::STATUS_VALIDATED;
270 $sql .=
" ORDER BY rowid DESC";
273 $resql = $db->query($sql);
275 $obj = $db->fetch_object($resql);
276 $fk_source = $obj->rowid;
277 if ((
int) $fk_source == 0) {
278 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
281 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
283 $invoice->fk_facture_source = $fk_source;
284 $invoice->update($user);
287 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
294 $remaintopay = $invoice->getRemainToPay();
301 } elseif (count($invoice->lines) == 0) {
310 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
312 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
313 dol_syslog(
"Validate invoice with stock change. Warehouse defined into constant ".$constantforkey.
" = ".
getDolGlobalString($constantforkey));
318 $res = $invoice->validate($user,
'',
getDolGlobalInt($constantforkey), 0, $batch_rule);
321 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
324 dol_syslog(
"Call validate on invoice ".$invoice->ref, LOG_DEBUG);
325 $res = $invoice->validate($user);
328 $langs->load(
"admin");
329 dol_htmloutput_errors($invoice->error ==
'NotConfigured' ? $langs->trans(
"NotConfigured").
' (TakePos numbering module)' : $invoice->error, $invoice->errors, 1);
334 if (!$error && $res >= 0) {
335 $remaintopay = $invoice->getRemainToPay();
340 $payment->datepaye = $now;
341 $payment->fk_account = $bankaccount;
346 $payment->amounts[$invoice->id] = $amountofpayment;
349 if ($amountofpayment <= 0 || $amountofpayment > $remaintopay) {
350 $payment->amounts[$invoice->id] = $remaintopay;
354 $payment->paiementid = $paiementid;
355 $payment->paiementcode = $paycode;
356 $payment->num_payment =
'';
358 if ($pay !=
"delayed") {
359 $res = $payment->create($user);
366 if (!empty($payment->warnings)) {
370 $res = $payment->addPaymentToBank($user,
'payment',
'(CustomerInvoicePayment)', $bankaccount,
'',
'');
373 dol_htmloutput_mesg($langs->trans(
'ErrorNoPaymentDefined').
' '.$payment->error, $payment->errors,
'error', 1);
376 $remaintopay = $invoice->getRemainToPay();
382 if ($remaintopay == 0) {
383 dol_syslog(
"Invoice is paid, so we set it to status Paid");
384 $result = $invoice->setPaid($user);
387 $invoice->status = $invoice::STATUS_CLOSED;
388 $invoice->close_code =
'';
391 $invoice->setPaymentMethods($paiementid);
393 dol_syslog(
"Invoice is not paid, remain to pay = ".$remaintopay);
402 if (!$error && $res >= 0) {
405 dol_syslog(
"Now we record the stock movement for each qualified line");
408 require_once DOL_DOCUMENT_ROOT .
"/product/stock/class/mouvementstock.class.php";
409 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
412 $labeltakeposmovement =
'TakePOS - '.$langs->trans(
"Invoice").
' '.$invoice->ref;
414 foreach ($invoice->lines as $line) {
416 $warehouseid = ($line->fk_warehouse ? $line->fk_warehouse :
getDolGlobalInt($constantforkey));
419 if ($line->batch !=
'' && $warehouseid > 0) {
421 $prod_batch->find(0,
'',
'', $line->batch, $warehouseid, (
int) $line->fk_product);
424 $mouvP->setOrigin($invoice->element, $invoice->id);
426 $res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'', $prod_batch->batch, $prod_batch->id, $inventorycode);
433 $mouvP->setOrigin($invoice->element, $invoice->id);
435 $res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'',
'', 0, $inventorycode);
445 if (!$error && $res >= 0) {
448 $invoice->ref = $invoice->oldcopy->ref;
449 $invoice->paye = $invoice->oldcopy->paye;
450 $invoice->status = $invoice->oldcopy->status;
451 $invoice->statut = $invoice->oldcopy->statut;
457 if ($action ==
'creditnote' && $user->hasRight(
'facture',
'creer')) {
460 $creditnote =
new Facture($db);
461 $creditnote->socid = $invoice->socid;
463 $creditnote->module_source =
'takepos';
464 $creditnote->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
466 $creditnote->fk_facture_source = $placeid;
469 $creditnote->create($user);
473 foreach ($invoice->lines as $line) {
475 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
480 if (!empty($invoice->situation_counter)) {
481 $source_fk_prev_id = $line->fk_prev_id;
482 $line->fk_prev_id = $line->id;
483 if (!empty($invoice->tab_previous_situation_invoice)) {
486 $tab_jumped_credit_notes = array();
487 $lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
488 $searchPreviousInvoice =
true;
489 while ($searchPreviousInvoice) {
490 if ($invoice->tab_previous_situation_invoice[$lineIndex]->situation_cycle_ref || $lineIndex < 1) {
491 $searchPreviousInvoice =
false;
495 $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id;
501 $maxPrevSituationPercent = 0;
502 foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
503 if ($prevLine->id == $source_fk_prev_id) {
504 $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
507 $line->total_ht -= $prevLine->total_ht;
508 $line->total_tva -= $prevLine->total_tva;
509 $line->total_ttc -= $prevLine->total_ttc;
510 $line->total_localtax1 -= $prevLine->total_localtax1;
511 $line->total_localtax2 -= $prevLine->total_localtax2;
513 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
514 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
515 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
516 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
521 $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
526 $maxPrevSituationPercent = 0;
527 foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
528 foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) {
529 if ($prevLine->fk_prev_id == $source_fk_prev_id) {
530 $maxPrevSituationPercent = $prevLine->situation_percent;
532 $line->total_ht -= $prevLine->total_ht;
533 $line->total_tva -= $prevLine->total_tva;
534 $line->total_ttc -= $prevLine->total_ttc;
535 $line->total_localtax1 -= $prevLine->total_localtax1;
536 $line->total_localtax2 -= $prevLine->total_localtax2;
538 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
539 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
540 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
541 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
547 $line->situation_percent += $maxPrevSituationPercent;
555 $line->fk_facture = $creditnote->id;
556 $line->fk_parent_line = $fk_parent_line;
558 $line->subprice = -$line->subprice;
560 $line->total_ht = -$line->total_ht;
561 $line->total_tva = -$line->total_tva;
562 $line->total_ttc = -$line->total_ttc;
563 $line->total_localtax1 = -$line->total_localtax1;
564 $line->total_localtax2 = -$line->total_localtax2;
566 $line->multicurrency_subprice = -$line->multicurrency_subprice;
567 $line->multicurrency_total_ht = -$line->multicurrency_total_ht;
568 $line->multicurrency_total_tva = -$line->multicurrency_total_tva;
569 $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
571 $result = $line->insert(0, 1);
573 $creditnote->lines[] = $line;
576 if ($result > 0 && $line->product_type == 9) {
577 $fk_parent_line = $result;
580 $creditnote->update_price(1);
584 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
591 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
593 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
595 dol_syslog(
"Validate invoice with stock change into warehouse defined into constant ".$constantforkey.
" = ".
getDolGlobalString($constantforkey).
" or warehouseid= ".$warehouseid.
" if defined.");
600 $res = $creditnote->validate($user,
'',
getDolGlobalInt($constantforkey), 0, $batch_rule);
607 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
609 $res = $creditnote->validate($user);
613 if (!$error && $res >= 0) {
616 dol_syslog(
"Now we record the stock movement for each qualified line");
619 require_once DOL_DOCUMENT_ROOT .
"/product/stock/class/mouvementstock.class.php";
620 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
623 $labeltakeposmovement =
'TakePOS - '.$langs->trans(
"CreditNote").
' '.$creditnote->ref;
625 foreach ($creditnote->lines as $line) {
627 $warehouseid = ($line->fk_warehouse ? $line->fk_warehouse :
getDolGlobalInt($constantforkey));
630 if ($line->batch !=
'' && $warehouseid > 0) {
635 $mouvP->setOrigin($creditnote->element, $creditnote->id);
637 $res = $mouvP->reception($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'', $line->batch,
'', 0, $inventorycode);
644 $mouvP->setOrigin($creditnote->element, $creditnote->id);
646 $res = $mouvP->reception($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement,
'',
'',
'',
'', 0, $inventorycode);
656 if (!$error && $res >= 0) {
659 $creditnote->id = $placeid;
664 if (($action ==
'history' || $action ==
'creditnote') && $user->hasRight(
'takepos',
'run')) {
665 if ($action ==
'creditnote' && $creditnote !==
null && $creditnote->id > 0) {
666 $placeid = $creditnote->id;
672 $invoice->fetch($placeid);
676 if (($action ==
"addline" || $action ==
"freezone") && $placeid == 0 && ($user->hasRight(
'takepos',
'run') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
679 $dolnowtzuserrel =
dol_now(
'tzuserrel');
683 $dateinvoice =
dol_mktime(0, 0, 0, (
int) $monthuser, (
int) $dayuser, (
int) $yearuser,
'tzserver');
685 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
686 $invoice->date = $dateinvoice;
700 $invoice->module_source =
'takepos';
701 $invoice->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
702 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] : $conf->entity;
704 if ($invoice->socid <= 0) {
705 $langs->load(
'errors');
711 $placeid = $invoice->create($user);
716 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture";
717 $sql .=
" SET ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
718 $sql .=
" WHERE rowid = ".((int) $placeid);
719 $resql = $db->query($sql);
734 if ($action ==
"addline" && ($user->hasRight(
'takepos',
'run') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
736 $prod->fetch($idproduct);
739 $customer->fetch($invoice->socid);
741 $datapriceofproduct = $prod->getSellPrice(
$mysoc, $customer, 0);
744 $price = $datapriceofproduct[
'pu_ht'];
745 $price_ttc = $datapriceofproduct[
'pu_ttc'];
747 $price_base_type = empty($datapriceofproduct[
'price_base_type']) ?
'HT' : $datapriceofproduct[
'price_base_type'];
748 $tva_tx = $datapriceofproduct[
'tva_tx'];
749 $tva_npr = (int) $datapriceofproduct[
'tva_npr'];
757 $batch =
GETPOST(
'batch',
'alpha');
759 if (!empty($batch)) {
760 $action =
"setbatch";
761 } elseif ($prod->status_batch > 0) {
766 $prod->load_stock(
'warehouseopen');
768 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
772 foreach ($prod->stock_warehouse as $tmpwarehouseid => $tmpval) {
777 if (!empty($prod->stock_warehouse[$tmpwarehouseid]) && is_array($prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
778 if (is_object($prod->stock_warehouse[$tmpwarehouseid]) && count($prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
779 foreach ($prod->stock_warehouse[$tmpwarehouseid]->detail_batch as $dbatch) {
788 echo
"function addbatch(batch, warehouseid) {\n";
789 echo
"console.log('We add batch '+batch+' from warehouse id '+warehouseid);\n";
790 echo
'$("#poslines").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?action=addline&batch="+encodeURI(batch)+"&warehouseid="+warehouseid+"&place='.$place.
'&idproduct='.$idproduct.
'&token='.
newToken().
'", function() {});'.
"\n";
795 echo
"<center>".$langs->trans(
"SearchIntoBatch").
": <b> $nbofsuggested </b></center><br><table>";
796 foreach ($prod->stock_warehouse as $tmpwarehouseid => $tmpval) {
801 if (!empty($prod->stock_warehouse[$tmpwarehouseid]) && is_array($prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
802 foreach ($prod->stock_warehouse[$tmpwarehouseid]->detail_batch as $dbatch) {
803 $batchStock = + $dbatch->qty;
804 $quantityToBeDelivered = 1;
805 $deliverableQty = min($quantityToBeDelivered, $batchStock);
807 print
'<!-- subj='.$suggestednb.
'/'.$nbofsuggested.
' -->';
808 print
'<!-- Show details of lot/serial in warehouseid='.$tmpwarehouseid.
' -->';
809 print
'<td class="left">';
811 $detail .=
'<span class="opacitymedium">'.$langs->trans(
"LotSerial").
':</span> '.$dbatch->batch;
818 $detail .=
'</td><td>';
819 $detail .=
'<span class="opacitymedium">'.$langs->trans(
"Qty").
':</span> '.$dbatch->qty;
820 $detail .=
'</td><td>';
821 $detail .=
' <button class="marginleftonly" onclick="addbatch(\''.dol_escape_js($dbatch->batch).
'\',
'.$tmpwarehouseid.')
">'.$langs->trans("Select
")."</
button>
";
825 $quantityToBeDelivered -= $deliverableQty;
826 if ($quantityToBeDelivered < 0) {
827 $quantityToBeDelivered = 0;
836 print '</body></html>';
842 if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) {
843 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
844 $cat = new Categorie($db);
845 $categories = $cat->containing($idproduct, 'product');
846 $found = (array_search(getDolGlobalInt('TAKEPOS_SUPPLEMENTS_CATEGORY'), array_column($categories, 'id')));
847 if ($found !== false) { // If this product is a supplement
848 $sql = "SELECT fk_parent_line FROM
".MAIN_DB_PREFIX."facturedet where rowid =
".((int) $selectedline);
849 $resql = $db->query($sql);
850 $row = $db->fetch_array($resql);
851 if ($row[0] == null) {
852 $parent_line = $selectedline;
854 $parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product
860 // Group if enabled. Skip group if line already sent to the printer
861 if (getDolGlobalString('TAKEPOS_GROUP_SAME_PRODUCT')) {
862 foreach ($invoice->lines as $line) {
863 if ($line->product_ref == $prod->ref) {
864 if ($line->special_code == 4) {
866 } // If this line is sended to printer create new line
867 // check if qty in stock
868 if (getDolGlobalString('TAKEPOS_QTY_IN_STOCK') && (($line->qty + $qty) > $prod->stock_reel)) {
869 $invoice->error = $langs->trans("ErrorStockIsNotEnough
");
870 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
874 $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);
876 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
878 $idoflineadded = $line->id;
884 if ($idoflineadded <= 0 && empty($err)) {
885 $invoice->fetch_thirdparty();
886 $array_options = array();
888 $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);
890 /* setup of margin calculation */
891 if (getDolGlobalString('MARGIN_TYPE')) {
892 if (getDolGlobalString('MARGIN_TYPE') == 'pmp' && !empty($prod->pmp)) {
893 $line['fk_fournprice'] = null;
894 $line['pa_ht'] = $prod->pmp;
895 } elseif (getDolGlobalString('MARGIN_TYPE') == 'costprice' && !empty($prod->cost_price)) {
896 $line['fk_fournprice'] = null;
897 $line['pa_ht'] = $prod->cost_price;
899 // default is fournprice
900 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
901 $pf = new ProductFournisseur($db);
902 if ($pf->find_min_price_product_fournisseur($idproduct, $qty) > 0) {
903 $line['fk_fournprice'] = $pf->product_fourn_price_id;
904 $line['pa_ht'] = $pf->fourn_unitprice_with_discount;
905 if (getDolGlobalString('PRODUCT_CHARGES') && $pf->fourn_charges > 0) {
906 $line['pa_ht'] += (float) $pf->fourn_charges / $pf->fourn_qty;
912 // complete line by hook
913 $parameters = array('prod' => $prod, 'line' => $line);
914 $reshook = $hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action); // Note that $action and $line may have been modified by some hooks
916 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
920 if (empty($reshook)) {
921 if (!empty($hookmanager->resArray)) {
922 $line = $hookmanager->resArray;
925 // check if qty in stock
926 if (getDolGlobalString('TAKEPOS_QTY_IN_STOCK') && $qty > $prod->stock_reel) {
927 $invoice->error = $langs->trans("ErrorStockIsNotEnough
");
928 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
933 $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);
937 if (getDolGlobalString('TAKEPOS_CUSTOMER_DISPLAY')) {
938 $CUSTOMER_DISPLAY_line1 = $prod->label;
939 $CUSTOMER_DISPLAY_line2 = price($price_ttc);
943 $invoice->fetch($placeid);
946 // If we add a line by submitting freezone form (invoice exists here because it was created just before if it didn't exist)
947 if ($action == "freezone
" && $user->hasRight('takepos', 'run')) {
948 $customer = new Societe($db);
949 $customer->fetch($invoice->socid);
951 $tva_tx = GETPOST('tva_tx', 'alpha');
953 if (!preg_match('/\((.*)\)/', $tva_tx)) {
954 $tva_tx = price2num($tva_tx);
957 $tva_tx = get_default_tva($mysoc, $customer);
961 $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
962 $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
964 $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);
966 dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
968 $invoice->fetch($placeid);
971 if ($action == "addnote
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
972 $desc = GETPOST('addnote', 'alpha');
974 $invoice->update_note($desc, '_public');
976 foreach ($invoice->lines as $line) {
977 if ($line->id == $idline) {
978 $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);
982 $invoice->fetch($placeid);
985 if ($action == "deleteline
" && ($user->hasRight('takepos', 'editlines') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
987 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
988 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
989 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
990 $permissiontoupdateline = true;
991 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
992 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
996 if ($idline > 0 && $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected.
997 $invoice->deleteLine($idline);
998 $invoice->fetch($placeid);
999 } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line.
1000 $sql = "SELECT rowid FROM
".MAIN_DB_PREFIX."facturedet where fk_facture =
".((int) $placeid)." ORDER BY rowid DESC
";
1001 $resql = $db->query($sql);
1002 $row = $db->fetch_array($resql);
1003 $deletelineid = $row[0];
1004 $invoice->deleteLine($deletelineid);
1005 $invoice->fetch($placeid);
1008 if (count($invoice->lines) == 0) {
1009 // Keep an empty draft invoice alive when a non-default customer was
1010 // already attached so deleting the last line does not silently lose
1011 // the customer that was just selected (#38219). Only drop the invoice
1012 // when it is still on the default cashdesk thirdparty (or none).
1013 $defaultsocid = (int) getDolGlobalString('CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal
"]);
1014 $invoicesocid = (int) $invoice->socid;
1015 if ($invoicesocid === 0 || $invoicesocid === $defaultsocid) {
1016 $invoice->delete($user);
1018 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1019 header("Location:
".DOL_URL_ROOT."/takepos/public/auto_order.php
");
1021 header("Location:
".DOL_URL_ROOT."/takepos/invoice.php
");
1028 // Action to delete or discard an invoice
1029 if ($action == "delete
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1030 // $placeid is the invoice id (it differs from place) and is defined if the place is set and
1031 // the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal
"].'-'.$place.')', so the fetch at beginning of page works.
1033 $result = $invoice->fetch($placeid);
1035 if ($result > 0 && $invoice->status == Facture::STATUS_DRAFT) {
1038 // We delete the lines
1039 $resdeletelines = 1;
1040 foreach ($invoice->lines as $line) {
1041 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1042 $tmpres = $invoice->deleteLine($line->id);
1044 $resdeletelines = 0;
1049 $sql = "UPDATE
".MAIN_DB_PREFIX."facture
";
1050 $varforconst = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal
"];
1051 $sql .= " SET fk_soc =
".((int) getDolGlobalString($varforconst)).",
";
1052 $sql .= " datec =
'".$db->idate(dol_now())."'";
1053 $sql .= " WHERE entity IN (
".getEntity('invoice').")
";
1054 $sql .= " AND
ref =
'(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'";
1055 $resql1 = $db->query($sql);
1057 if ($resdeletelines && $resql1) {
1063 $invoice->fetch($placeid);
1068 if ($action == "updateqty
") { // Test on permission is done later
1069 foreach ($invoice->lines as $line) {
1070 if ($line->id == $idline) {
1071 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1072 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1073 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1074 $permissiontoupdateline = true;
1075 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1076 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1079 if (!$permissiontoupdateline) {
1080 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
").' - No permission to updateqty', [], 1);
1082 $vatratecode = $line->tva_tx;
1083 if ($line->vat_src_code) {
1084 $vatratecode .= ' ('.$line->vat_src_code.')';
1087 $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);
1092 $invoice->fetch($placeid);
1095 if ($action == "updateprice
") { // Test on permission is done later
1096 $customer = new Societe($db);
1097 $customer->fetch($invoice->socid);
1099 foreach ($invoice->lines as $line) {
1100 if ($line->id == $idline) {
1101 $prod = new Product($db);
1102 $prod->fetch($line->fk_product);
1103 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
1104 $price_min = $datapriceofproduct['price_min'];
1105 $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS'));
1107 $vatratecleaned = $line->tva_tx;
1109 if (preg_match('/^(.*)\s*\((.*)\)$/', (string) $line->tva_tx, $reg)) { // If vat is "xx (yy)
"
1110 $vatratecleaned = trim($reg[1]);
1111 //$vatratecode = $reg[2];
1114 $pu_ht = price2num((float) price2num($number, 'MU') / (1 + ((float) $vatratecleaned / 100)), 'MU');
1116 if ($usercanproductignorepricemin && (!empty($price_min) && ((float) price2num($pu_ht) * (1 - (float) price2num($line->remise_percent) / 100) < price2num($price_min)))) {
1117 $langs->load("products
");
1118 dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice
", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
1119 // echo $langs->trans("CantBeLessThanMinPrice
");
1121 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1122 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1123 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1124 $permissiontoupdateline = true;
1125 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1126 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1130 $vatratecode = $line->tva_tx;
1131 if ($line->vat_src_code) {
1132 $vatratecode .= ' ('.$line->vat_src_code.')';
1135 if (!$permissiontoupdateline) {
1136 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
").' - No permission to updateprice', [], 1);
1137 } elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) {
1138 $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);
1140 $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);
1147 $invoice->fetch($placeid);
1150 if ($action == "updatereduction
") { // Test on permission is done later
1151 $customer = new Societe($db);
1152 $customer->fetch($invoice->socid);
1154 foreach ($invoice->lines as $line) {
1155 if ($line->id == $idline) {
1156 dol_syslog("updatereduction Process line
".$line->id.' to apply discount of '.$number.'%');
1158 $prod = new Product($db);
1159 $prod->fetch($line->fk_product);
1161 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
1162 $price_min = $datapriceofproduct['price_min'];
1163 $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS'));
1165 $pu_ht = price2num($line->subprice / (1 + ($line->tva_tx / 100)), 'MU');
1168 if ($usercanproductignorepricemin && (!empty($price_min) && ((float) price2num($line->subprice) * (1 - (float) price2num($number) / 100) < (float) price2num($price_min)))) {
1169 $langs->load("products
");
1170 dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice
", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
1172 $permissiontoupdateline = ($user->hasRight('takepos', 'editlines') && ($user->hasRight('takepos', 'editorderedlines') || $line->special_code != "4
"));
1173 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1174 if ($invoice->status == $invoice::STATUS_DRAFT && $invoice->pos_source && $invoice->module_source == 'takepos') {
1175 $permissiontoupdateline = true;
1176 // TODO Add also a test on $_SESSION('publicobjectid'] defined at creation of object
1177 // TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the table ID
1180 if (!$permissiontoupdateline) {
1181 dol_htmloutput_errors($langs->trans("NotEnoughPermissions
", "TakePos
"), [], 1);
1183 $vatratecode = $line->tva_tx;
1184 if ($line->vat_src_code) {
1185 $vatratecode .= ' ('.$line->vat_src_code.')';
1187 $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);
1194 $invoice->fetch($placeid);
1195 } elseif ($action == 'update_reduction_global' && $user->hasRight('takepos', 'editlines')) {
1196 foreach ($invoice->lines as $line) {
1197 $vatratecode = $line->tva_tx;
1198 if ($line->vat_src_code) {
1199 $vatratecode .= ' ('.$line->vat_src_code.')';
1201 $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);
1204 $invoice->fetch($placeid);
1207 if ($action == "setbatch
" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1208 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
1209 $warehouseid = (GETPOSTINT('warehouseid') > 0 ? GETPOSTINT('warehouseid') : getDolGlobalInt($constantforkey)); // Get the warehouse id from GETPOSTINT('warehouseid'), otherwise use default setup.
1210 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet SET batch =
'".$db->escape($batch)."', fk_warehouse =
".((int) $warehouseid);
1211 $sql .= " WHERE rowid=
".((int) $idoflineadded);
1215 if ($action == "order
" && $placeid != 0 && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
1216 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1217 if ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1218 require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
1219 $printer = new dolReceiptPrinter($db);
1222 $sql = "SELECT label FROM
".MAIN_DB_PREFIX."takepos_floor_tables where rowid=
".((int) $place);
1223 $resql = $db->query($sql);
1224 $row = $db->fetch_object($resql);
1225 $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>';
1226 $footerorder = '</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>';
1227 $order_receipt_printer1 = "";
1228 $order_receipt_printer2 = "";
1229 $order_receipt_printer3 = "";
1230 $catsprinter1 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_1'));
1231 $catsprinter2 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_2'));
1232 $catsprinter3 = explode(';', getDolGlobalString('TAKEPOS_PRINTED_CATEGORIES_3'));
1234 foreach ($invoice->lines as $line) {
1235 if ($line->special_code == "4
") {
1238 $c = new Categorie($db);
1239 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1240 $result = array_intersect($catsprinter1, $existing);
1241 $count = count($result);
1242 if (!$line->fk_product) {
1243 $count++; // Print Free-text item (Unassigned printer) to Printer 1
1247 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet set special_code=
'1' where rowid=
".$line->id; //Set to print on printer 1
1249 $order_receipt_printer1 .= '<tr><td class="left
">';
1250 if ($line->fk_product) {
1251 $order_receipt_printer1 .= $line->product_label;
1253 $order_receipt_printer1 .= $line->description;
1255 $order_receipt_printer1 .= '</td><td class="right
">'.$line->qty;
1256 if (!empty($line->array_options['options_order_notes'])) {
1257 $order_receipt_printer1 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1259 $order_receipt_printer1 .= '</td></tr>';
1262 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0 && $printer !== null) {
1263 $invoice->fetch($placeid); //Reload object before send to printer
1264 $printer->orderprinter = 1;
1266 echo "var orderprinter1esc=
'";
1267 $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
1270 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'1' and fk_facture=
".$invoice->id; // Set as printed
1272 $invoice->fetch($placeid); //Reload object after set lines as printed
1275 foreach ($invoice->lines as $line) {
1276 if ($line->special_code == "4
") {
1279 $c = new Categorie($db);
1280 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1281 $result = array_intersect($catsprinter2, $existing);
1282 $count = count($result);
1285 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'2' where rowid=
".$line->id; //Set to print on printer 2
1287 $order_receipt_printer2 .= '<tr>'.$line->product_label.'<td class="right
">'.$line->qty;
1288 if (!empty($line->array_options['options_order_notes'])) {
1289 $order_receipt_printer2 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1291 $order_receipt_printer2 .= '</td></tr>';
1294 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0) {
1295 $invoice->fetch($placeid); //Reload object before send to printer
1296 $printer->orderprinter = 2;
1298 echo "var orderprinter2esc=
'";
1299 $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
1302 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'2' and fk_facture=
".$invoice->id; // Set as printed
1304 $invoice->fetch($placeid); //Reload object after set lines as printed
1307 foreach ($invoice->lines as $line) {
1308 if ($line->special_code == "4
") {
1311 $c = new Categorie($db);
1312 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
1313 $result = array_intersect($catsprinter3, $existing);
1314 $count = count($result);
1317 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'3' where rowid=
".$line->id; //Set to print on printer 3
1319 $order_receipt_printer3 .= '<tr>'.$line->product_label.'<td class="right
">'.$line->qty;
1320 if (!empty($line->array_options['options_order_notes'])) {
1321 $order_receipt_printer3 .= "<br>(
".$line->array_options['options_order_notes'].")
";
1323 $order_receipt_printer3 .= '</td></tr>';
1326 if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") && $linestoprint > 0 && $printer !== null) {
1327 $invoice->fetch($placeid); //Reload object before send to printer
1328 $printer->orderprinter = 3;
1330 echo "var orderprinter3esc=
'";
1331 $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
1334 $sql = "UPDATE
".MAIN_DB_PREFIX."facturedet
set special_code=
'4' where special_code=
'3' and fk_facture=
".$invoice->id; // Set as printed
1336 $invoice->fetch($placeid); //Reload object after set lines as printed
1339 $sectionwithinvoicelink = '';
1340 if (($action == "valid
" || $action == "history
" || $action == 'creditnote' || ($action == 'addline' && $invoice->status == $invoice::STATUS_CLOSED)) && $user->hasRight('takepos', 'run')) {
1341 $sectionwithinvoicelink .= '<!-- Section with invoice link -->'."\n
";
1342 $sectionwithinvoicelink .= '<span style="font-size:120%;
" class="center
inline-block marginbottomonly
">';
1343 $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." -
";
1344 $remaintopay = $invoice->getRemainToPay();
1345 if ($remaintopay > 0) {
1346 $sectionwithinvoicelink .= $langs->trans('RemainToPay').': <span class="amountremaintopay
" style="font-size: unset
">'.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
1348 $sectionwithinvoicelink .= $invoice->getLibStatut(2);
1351 $sectionwithinvoicelink .= '</span><br>';
1353 $customprinterallowed = true;
1354 $customprinttemplateallowed = true;
1355 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
1356 if (isALNERunningVersion()) { // No need to show this option because it has no effect when isALNERunningVersion is true.
1357 $customprinttemplateallowed = false; // Custom printer may be allowed if mandatory information in template are guaranteed. For the moment, we prefer not allow this.
1360 if ($invoice->status == $invoice::STATUS_CLOSED) {
1361 if (getDolGlobalInt('TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
1362 $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>';
1363 } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector
") {
1364 // Used when the external addon takeposconnector is installed. Deprecated.
1365 if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
1366 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="TakeposConnector(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1368 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="TakeposPrinting(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1370 } elseif ($customprinterallowed && (isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter
") { // @phpstan-ignore-line
1371 // If we set to use a specific receipt printer
1372 $nameOfPrinter = dol_getIdFromCode($db, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term), 'printer_receipt', 'rowid', 'name', 1);
1373 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="DolibarrTakeposPrinting(
'.$placeid.')
" title="'.dolPrintHTMLForAttribute($langs->trans("SentToPrinter").' '.$nameOfPrinter).'">'.$langs->trans('PrintTicket').'</button>';
1375 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="Print(
'.$placeid.')
">'.$langs->trans('PrintTicket').'</button>';
1376 if ($customprinttemplateallowed && getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) {
1377 $sectionwithinvoicelink .= ' <button id="buttonprint
" type="button" onclick="PrintBox(
'.$placeid.', \
'without_details\')">'.$langs->trans(
'PrintWithoutDetails').
'</button>';
1380 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="Print('.$placeid.
', 1)">'.$langs->trans(
'GiftReceipt').
'</button>';
1384 $sectionwithinvoicelink .=
' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.
')">'.$langs->trans(
'SendTicket').
'</button>';
1387 if ($remaintopay <= 0 &&
getDolGlobalString(
'TAKEPOS_AUTO_PRINT_TICKETS') && $action !=
"history") {
1388 $sectionwithinvoicelink .=
'<script type="text/javascript">console.log("Emulate click on #buttonprint"); $("#buttonprint").click();</script>';
1399$form =
new Form($db);
1402if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1403 $title =
'TakePOS - Dolibarr '.DOL_VERSION;
1407 $head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
1408 <meta name="apple-mobile-web-app-capable" content="yes">
1409 <meta name="mobile-web-app-capable" content="yes">
1410 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
1411 $arrayofcss = array(
1412 '/takepos/css/pos.css.php',
1414 $arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
1417 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
1419 print
'<body>'.
"\n";
1426<script
type=
"text/javascript">
1429<?php
if ($action ==
"valid") {
1430 echo
"var place=0;";
1432var placeid=<?php echo($placeid > 0 ? $placeid : 0); ?>;
1433$(document).ready(
function() {
1434 var idoflineadded = <?php echo(empty($idoflineadded) ? 0 : $idoflineadded); ?>;
1436 $(
'.posinvoiceline').click(
function(){
1437 console.log(
"Click done on "+this.
id);
1438 $(
'.posinvoiceline').removeClass(
"selected");
1439 $(
this).addClass(
"selected");
1443 if (selectedline == this.
id) {
1446 selectedline = this.id;
1448 selectedtext=$(
'#'+selectedline).find(
"td:first").html();
1450 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1451 print
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?action=editline&token='.
newToken().
'&placeid="+placeid+"&selectedline="+selectedline, function() {
1458 if (idoflineadded > 0)
1460 console.log(
"Auto select "+idoflineadded);
1461 $(
'.posinvoiceline#'+idoflineadded).click();
1465if ($action ==
"order" && !empty($order_receipt_printer1)) {
1466 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1470 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php',
1471 data:
'invoice='+orderprinter1esc
1478 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1480 print $headerorder.$order_receipt_printer1.$footerorder; ?>'
1486if ($action ==
"order" && !empty($order_receipt_printer2)) {
1487 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1491 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php?printer=2',
1492 data:
'invoice='+orderprinter2esc
1499 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print2',
1501 print $headerorder.$order_receipt_printer2.$footerorder; ?>'
1507if ($action ==
"order" && !empty($order_receipt_printer3)) {
1508 if (filter_var(
getDolGlobalString(
'TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) ==
true) {
1512 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php?printer=3',
1513 data:
'invoice='+orderprinter3esc
1520if ($action ==
"search" || $action ==
"valid") {
1522 parent.ClearSearch(
true);
1527if ($action ==
"temp" && !empty($ticket_printer1)) {
1531 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1533 print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>'
1538if ($action ==
"search") {
1540 $(
'#search').focus();
1548function SendTicket(
id)
1550 console.log(
"Open box to select the Print/Send form");
1551 $.colorbox({href:
"send.php?facid="+id, width:
"70%", height:
"30%", transition:
"none", iframe:
"true", title:
'<?php echo dol_escape_js($langs->trans("SendTicket")); ?>'});
1556function PrintBox(
id, action) {
1557 console.log(
"Open box before printing");
1558 $.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
"); ?>"});
1563function Print(
id, gift) {
1567 console.log(
"Call Print() to generate the receipt.");
1568 $.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")); ?>'});
1573function TakeposPrinting(
id){
1575 console.log(
"TakeposPrinting" +
id);
1576 $.get(
"receipt.php?facid="+
id,
function(data,
status) {
1577 receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,
'');
1580 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1587function TakeposConnector(
id){
1588 console.log(
"TakeposConnector" +
id);
1589 $.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) {
1592 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php',
1593 data:
'invoice='+data
1604function DolibarrTakeposPrinting(
id) {
1605 console.log(
"DolibarrTakeposPrinting Printing invoice ticket by calling takepos/aja/ajax.php" +
id);
1609 data: { token:
'<?php echo currentToken(); ?>' },
1610 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=printinvoiceticket&token='.newToken().'&term='.urlencode(isset($_SESSION["takeposterminal
"]) ? $_SESSION["takeposterminal
"] : '').'&id='; ?>" + id,
1611 success:
function(){
1612 showPrintResultPopup(
'<?php echo dol_escape_js($langs->trans("SentToPrinter").' '.$nameOfPrinter); ?>', 2000);
1615 showPrintResultPopup(
"<?php echo dol_escape_js($langs->trans("FailedToSendToPrinter
")); ?>", 2000);
1622function showPrintResultPopup(message, duration) {
1623 $(
"#dialogforpopuptakepos").show().text(message).fadeIn();
1625 setTimeout(
function(){
1626 $(
"#dialogforpopuptakepos").fadeOut().hide();
1633function CreditNote() {
1634 $(
"#poslines").load(
"<?php print DOL_URL_ROOT; ?>/takepos/invoice.php?action=creditnote&token=<?php echo newToken() ?>&invoiceid="+placeid,
function() { });
1640 $(
"#poslines").load(
"<?php print DOL_URL_ROOT; ?>/takepos/invoice.php?action=addnote&token=<?php echo newToken() ?>&invoiceid="+placeid+
"&idline="+selectedline, {
"addnote": $(
"#textinput").val() });
1645$( document ).ready(
function() {
1646 console.log(
"Set customer info and sales in header placeid=<?php echo $placeid; ?> status=<?php echo $invoice->statut; ?>");
1649 $s = $langs->trans(
"Customer");
1650 if ($invoice->id > 0 && ($invoice->socid !=
getDolGlobalString($constforcompanyid))) {
1653 $contactids = $invoice->getIdContact(
'external',
'BILLING');
1654 $contactid = $contactids[0];
1655 if ($contactid > 0) {
1657 $contact->fetch($contactid);
1658 $s .=
" - " . $contact->getFullName($langs);
1662 print
'$("#idcustomer").val("");';
1666 $(
"#customerandsales").html(
'');
1667 $(
"#shoppingcart").html(
'');
1670 $(
"#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>');
1672 $(
"#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>');
1676 $sql =
"SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX.
"facture";
1677 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
1680 $sql .=
" AND ref LIKE '(PROV-POS".$db->escape(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'').
"-0%'";
1683 $sql .=
" AND pos_source = '".$db->escape((
string) $_SESSION[
"takeposterminal"]).
"'";
1684 $sql .=
" AND module_source = 'takepos'";
1687 $sql .= $db->order(
'datec',
'ASC');
1688 $resql = $db->query($sql);
1691 while ($obj = $db->fetch_object($resql)) {
1692 echo
'$("#shoppingcart").append(\'';
1693 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=\\\'';
1694 $num_sale = str_replace(
")",
"", str_replace(
"(PROV-POS".$_SESSION[
"takeposterminal"].
"-",
"", $obj->ref));
1696 if (str_replace(
"-",
"", $num_sale) > $max_sale) {
1697 $max_sale = str_replace(
"-",
"", $num_sale);
1699 echo
'\\\'; invoiceid=\\\'';
1701 echo
'\\\'; Refresh();">';
1702 if ($placeid == $obj->rowid) {
1703 echo
'<span class="basketselected">';
1705 echo
'<span class="basketnotselected">';
1707 echo
'<span class="fa fa-shopping-cart paddingright"></span>'.dol_print_date($db->jdate($obj->datec),
'%H:%M',
'tzuser');
1711 echo
'$("#shoppingcart").append(\'<a onclick="place=\\\'0-';
1713 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>\');';
1721 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1724 $constantforkey =
'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1726 if ($idwarehouse > 0) {
1727 $s =
'<span class="small">';
1729 $warehouse->fetch($idwarehouse);
1730 $s .=
'<span class="hideonsmartphone">'.$langs->trans(
"Warehouse").
'<br></span>'.$warehouse->ref;
1732 $s .=
' ('.$langs->trans(
"Closed").
')';
1735 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1736 print
'$("#infowarehouse").css("display", "inline-block");';
1738 $s =
'<span class="small hideonsmartphone">';
1739 $s .= $langs->trans(
"StockChangeDisabled").
'<br>'.$langs->trans(
"NoWarehouseDefinedForTerminal");
1741 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1742 if (!empty($conf->dol_optimize_smallscreen)) {
1743 print
'$("#infowarehouse").css("display", "none");';
1747 $s =
'<span class="small hideonsmartphone">'.$langs->trans(
"StockChangeDisabled").
'</span>';
1748 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1749 if (!empty($conf->dol_optimize_smallscreen)) {
1750 print
'$("#infowarehouse").css("display", "none");';
1759 $s =
'<span class="small">';
1760 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1761 $langs->load(
"members");
1762 $s .= $langs->trans(
"Member").
': ';
1764 $result = $adh->fetch(0,
'', $invoice->socid);
1766 $adh->ref = $adh->getFullName($langs);
1770 $s .= $adh->getFullName($langs);
1771 $s .=
' - '.$adh->type;
1772 if ($adh->datefin) {
1773 $s .=
'<br>'.$langs->trans(
"SubscriptionEndDate").
': '.
dol_print_date($adh->datefin,
'day');
1774 if ($adh->hasDelay()) {
1775 $s .=
" ".img_warning($langs->trans(
"Late"));
1778 $s .=
'<br>'.$langs->trans(
"SubscriptionNotReceived");
1779 if ($adh->status > 0) {
1780 $s .=
" ".img_warning($langs->trans(
"Late"));
1787 $s .=
'<br>'.$langs->trans(
"ThirdpartyNotLinkedToMember");
1792 $(
"#moreinfo").html(
'<?php print dol_escape_js($s); ?>');
1799 echo
"function CustomerDisplay(){";
1800 echo
"var line1='".$CUSTOMER_DISPLAY_line1.
"'.substring(0,20);";
1801 echo
"line1=line1.padEnd(20);";
1802 echo
"var line2='".$CUSTOMER_DISPLAY_line2.
"'.substring(0,20);";
1803 echo
"line2=line2.padEnd(20);";
1806 data: { text: line1+line2 },
1807 url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER').
"/display/index.php',
1818if (!empty($conf->use_javascript_ajax)) {
1819 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
1820 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.
'"></script>'.
"\n";
1823$usediv = (
GETPOST(
'format') ==
'div');
1825print
'<!-- 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";
1826print
'<div class="div-table-responsive-no-min invoice">';
1828 print
'<div id="tablelines">';
1830 print
'<table id="tablelines" class="noborder noshadow postablelines centpercent">';
1833$buttontocreatecreditnote =
'';
1834if (($action ==
"valid" || $action ==
"history" || ($action ==
"addline" && $invoice->status == $invoice::STATUS_CLOSED)) && $invoice->type !=
Facture::TYPE_CREDIT_NOTE && !
getDolGlobalString(
'TAKEPOS_NO_CREDITNOTE')) {
1835 $buttontocreatecreditnote .=
' <!-- Show button to create a credit note -->'.
"\n";
1836 $buttontocreatecreditnote .=
'<button id="buttonprint" type="button" onclick="ModalBox(\'ModalCreditNote\')">'.$langs->trans(
'CreateCreditNote').
'</button>';
1837 if (
getDolGlobalInt(
'TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
1838 $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>';
1843if ($sectionwithinvoicelink && ($mobilepage ==
"invoice" || $mobilepage ==
"")) {
1844 print
'<!-- Print table line with link to invoice ref -->';
1846 print
'<tr><td colspan="5" class="paddingtopimp paddingbottomimp" style="padding-top: 10px !important; padding-bottom: 10px !important;">';
1847 print $sectionwithinvoicelink;
1848 print $buttontocreatecreditnote;
1851 print
'<tr><td colspan="4" class="paddingtopimp paddingbottomimp" style="padding-top: 10px !important; padding-bottom: 10px !important;">';
1852 print $sectionwithinvoicelink;
1853 print $buttontocreatecreditnote;
1860 print
'<tr class="liste_titre nodrag nodrop">';
1861 print
'<td class="linecoldescription">';
1864if (empty($mobilepage) || $mobilepage ==
"invoice") {
1865 print
'<!-- hidden var used by some js functions -->';
1866 print
'<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.
'">';
1867 print
'<input type="hidden" name="thirdpartyid" id="thirdpartyid" value="'.$invoice->socid.
'">';
1871 $sql =
"SELECT floor, label FROM ".MAIN_DB_PREFIX.
"takepos_floor_tables where rowid=".((int) $place);
1872 $resql = $db->query($sql);
1873 $obj = $db->fetch_object($resql);
1875 $label = $obj->label;
1876 $floor = $obj->floor;
1878 if ($mobilepage ==
"invoice" || $mobilepage ==
"") {
1881 print
'<span class="opacitymedium">'.$langs->trans(
'Place').
"</span> <b>".(empty($label) ?
'?' : $label).
"</b><br>";
1882 print
'<span class="opacitymedium">'.$langs->trans(
'Floor').
"</span> <b>".(empty($floor) ?
'?' : $floor).
"</b>";
1889$parameters = array();
1890$reshook = $hookmanager->executeHooks(
'completeTakePosInvoiceHeader', $parameters, $invoice, $action);
1894print $hookmanager->resPrint;
1896if (empty($_SESSION[
"basiclayout"]) || $_SESSION[
"basiclayout"] != 1) {
1898 print
'<td class="linecolqty right">'.$langs->trans(
'PriceUHT').
'</td>';
1900 print
'<td class="linecolqty right">'.$langs->trans(
'ReductionShort').
'</td>';
1901 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
1903 print
'<td class="linecolht right nowraponall">';
1904 print
'<span class="opacitymedium small">' . $langs->trans(
'TotalHTShort') .
'</span><br>';
1906 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1907 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>';
1908 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"]) && $conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
1910 include_once DOL_DOCUMENT_ROOT .
'/multicurrency/class/multicurrency.class.php';
1912 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
1913 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>';
1918 print
'<td class="linecolht right nowraponall">';
1919 print
'<span class="opacitymedium small">'.$langs->trans(
'TotalTTCShort').
'</span><br>';
1921 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1922 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>';
1923 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"]) && $conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
1925 include_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
1927 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
1928 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>';
1932} elseif ($mobilepage ==
"invoice") {
1933 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
1939if (!empty($_SESSION[
"basiclayout"]) && $_SESSION[
"basiclayout"] == 1) {
1940 if ($mobilepage ==
"cats") {
1941 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1943 $categories = $categorie->get_full_arbo(
'product');
1945 foreach ($categories as $row) {
1946 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1947 $htmlforlines .=
'<div class="leftcat"';
1949 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline"';
1951 $htmlforlines .=
' onclick="LoadProducts('.$row[
'id'].
');">';
1952 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1953 $htmlforlines .=
'<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=cat&query=cat&id='.$row[
'id'].
'"><br>';
1955 $htmlforlines .=
'<td class="left">';
1957 $htmlforlines .= $row[
'label'];
1958 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1959 $htmlforlines .=
'</div>'.
"\n";
1961 $htmlforlines .=
'</td></tr>'.
"\n";
1964 print $htmlforlines;
1967 if ($mobilepage ==
"products") {
1968 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1971 $result =
$object->fetch($catid);
1972 $prods =
$object->getObjectsInCateg(
"product");
1974 '@phan-var-force Product[] $prods';
1976 foreach ($prods as $row) {
1977 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1978 $htmlforlines .=
'<div class="leftcat"';
1980 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline"';
1982 $htmlforlines .=
' onclick="AddProduct(\''.$place.
'\',
'.$row->id.')
"';
1983 $htmlforlines .= '>';
1984 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1985 $htmlforlines .= '<img class="imgwrapper
" width="33%
" src="'.DOL_URL_ROOT.'/takepos/
public/auto_order.php?genimg=pro&query=pro&
id=
'.$row->id.'"><br>';
1986 $htmlforlines .= $row->label.' '.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency);
1987 $htmlforlines .= '</div>'."\n
";
1989 $htmlforlines .= '<td class="left
">';
1990 $htmlforlines .= $row->label;
1991 $htmlforlines .= '<div class="right
">'.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).'</div>';
1992 $htmlforlines .= '</td>';
1993 $htmlforlines .= '</tr>'."\n
";
1996 print $htmlforlines;
1999 if ($mobilepage == "places
") {
2000 $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM
".MAIN_DB_PREFIX."takepos_floor_tables
";
2001 $resql = $db->query($sql);
2005 while ($row = $db->fetch_array($resql)) {
2007 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
2008 $htmlforlines .= '" onclick="LoadPlace(\
''.$row[
'label'].
'\')
">';
2009 $htmlforlines .= '<td class="left
">';
2010 $htmlforlines .= $row['label'];
2011 $htmlforlines .= '</td>';
2012 $htmlforlines .= '</tr>'."\n
";
2014 print $htmlforlines;
2019 //In Phone basic layout hide some content depends situation
2020 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1 && $mobilepage != "invoice
" && $action != "order
") {
2024 // Loop on each lines on invoice
2025 if (is_array($invoice->lines) && count($invoice->lines)) {
2026 print '<!-- invoice.php show lines of invoices -->'."\n
";
2027 $tmplines = array_reverse($invoice->lines);
2028 $htmlsupplements = array();
2029 foreach ($tmplines as $line) {
2030 if ($line->fk_parent_line != false) {
2031 if (!isset($htmlsupplements[$line->fk_parent_line])) {
2032 $htmlsupplements[$line->fk_parent_line] = '';
2034 $htmlsupplements[$line->fk_parent_line] .= '<tr class="drag drop oddeven posinvoiceline
';
2035 if ($line->special_code == "4") {
2036 $htmlsupplements[$line->fk_parent_line] .= ' order
';
2038 $htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'"';
2039 if ($line->special_code == "4
") {
2040 $htmlsupplements[$line->fk_parent_line] .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
2042 $htmlsupplements[$line->fk_parent_line] .= '>';
2043 $htmlsupplements[$line->fk_parent_line] .= '<td class="left
">';
2044 $htmlsupplements[$line->fk_parent_line] .= img_picto('', 'rightarrow.png');
2045 if ($line->product_label) {
2046 $htmlsupplements[$line->fk_parent_line] .= $line->product_label;
2048 if ($line->product_label && $line->desc) {
2049 $htmlsupplements[$line->fk_parent_line] .= '<br>';
2051 if ($line->product_label != $line->desc) {
2052 $firstline = dolGetFirstLineOfText($line->desc);
2053 if ($firstline != $line->desc) {
2054 $htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
2056 $htmlsupplements[$line->fk_parent_line] .= $line->desc;
2059 $htmlsupplements[$line->fk_parent_line] .= '</td>';
2061 // complete line by hook
2062 $parameters = array('line' => $line);
2063 $reshook = $hookmanager->executeHooks('completeTakePosInvoiceParentLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
2065 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2067 $htmlsupplements[$line->fk_parent_line] .= $hookmanager->resPrint;
2069 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2070 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.vatrate(price2num($line->remise_percent), true).'</td>';
2071 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.$line->qty.'</td>';
2072 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.price($line->total_ttc).'</td>';
2074 $htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n
";
2079 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
2080 if ($line->special_code == "4") {
2081 $htmlforlines .= ' order
';
2083 $htmlforlines .= '" id="'.$line->id.'"';
2084 if ($line->special_code == "4
") {
2085 $htmlforlines .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
2087 $htmlforlines .= '>';
2088 $htmlforlines .= '<td class="left
">';
2089 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
2090 $htmlforlines .= '<span class="phoneqty
">'.$line->qty."</span> x
";
2092 if (isset($line->product_type)) {
2093 if (empty($line->product_type)) {
2094 $htmlforlines .= img_object('', 'product').' ';
2096 $htmlforlines .= img_object('', 'service').' ';
2100 if (!getDolGlobalString('TAKEPOS_SHOW_N_FIRST_LINES')) {
2101 if ($line->product_ref) {
2102 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
2103 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
2104 if (!empty($line->batch)) {
2105 $tooltiptext .= '<br><b>'.$langs->trans("LotSerial
").'</b> : '.$line->batch.'<br>';
2107 if (!empty($line->fk_warehouse)) {
2108 $tooltiptext .= '<b>'.$langs->trans("Warehouse
").'</b> : '.$line->fk_warehouse.'<br>';
2110 if ($line->product_label != $line->desc) {
2112 $tooltiptext .= '<br>';
2114 $tooltiptext .= $line->desc;
2117 if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
2118 $htmlforlines .= $form->textwithpicto($line->product_label ? '<b>' . $line->product_ref . '</b> - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
2119 } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) {
2120 $htmlforlines .= $form->textwithpicto($line->product_ref ? '<b>'.$line->product_ref.'<b>' : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
2122 $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
2125 if ($line->product_ref) {
2126 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
2127 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
2129 if (!empty($line->batch)) {
2130 $tooltiptext .= '<br><b>'.$langs->trans("LotSerial
").'</b> : '.$line->batch.'<br>';
2132 if (!empty($line->fk_warehouse)) {
2133 $tooltiptext .= '<b>'.$langs->trans("Warehouse
").'</b> : '.$line->fk_warehouse.'<br>';
2136 if ($line->product_label) {
2137 $htmlforlines .= $line->product_label;
2139 if ($line->product_label != $line->desc) {
2140 if ($line->product_label && $line->desc) {
2141 $htmlforlines .= '<br>';
2143 $firstline = dolGetFirstLineOfText($line->desc, getDolGlobalInt('TAKEPOS_SHOW_N_FIRST_LINES'));
2144 if ($firstline != $line->desc) {
2145 $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
2147 $htmlforlines .= $line->desc;
2151 if (!empty($line->array_options['options_order_notes'])) {
2152 $htmlforlines .= "<br>(
".$line->array_options['options_order_notes'].")
";
2154 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
2155 $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>';
2157 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2159 $moreinfo .= $langs->transcountry("TotalHT
", $mysoc->country_code).': '.price($line->total_ht);
2160 if ($line->vat_src_code) {
2161 $moreinfo .= '<br>'.$langs->trans("VATCode
").': '.$line->vat_src_code;
2163 $moreinfo .= '<br>'.$langs->transcountry("TotalVAT
", $mysoc->country_code).': '.price($line->total_tva);
2164 $moreinfo .= '<br>'.$langs->transcountry("TotalLT1
", $mysoc->country_code).': '.price($line->total_localtax1);
2165 $moreinfo .= '<br>'.$langs->transcountry("TotalLT2
", $mysoc->country_code).': '.price($line->total_localtax2);
2166 $moreinfo .= '<hr>';
2167 $moreinfo .= $langs->transcountry("TotalTTC
", $mysoc->country_code).': '.price($line->total_ttc);
2168 //$moreinfo .= $langs->trans("TotalHT
").': '.$line->total_ht;
2169 if ($line->date_start || $line->date_end) {
2170 $htmlforlines .= '<br><div class="clearboth nowraponall
">'.get_date_range($line->date_start, $line->date_end).'</div>';
2172 $htmlforlines .= '</td>';
2174 // complete line by hook
2175 $parameters = array('line' => $line);
2176 $reshook = $hookmanager->executeHooks('completeTakePosInvoiceLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
2178 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2180 $htmlforlines .= $hookmanager->resPrint;
2182 if (getDolGlobalInt("TAKEPOS_SHOW_SUBPRICE
")) {
2183 $htmlforlines .= '<td class="right
">'.price($line->subprice).'</td>';
2185 $htmlforlines .= '<td class="right
">'.vatrate(price2num($line->remise_percent), true).'</td>';
2186 $htmlforlines .= '<td class="right
">';
2187 $htmlforlines .= $line->qty;
2188 if (isModEnabled('stock') && $user->hasRight('stock', 'mouvement', 'lire')) {
2189 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
2190 if (getDolGlobalString($constantforkey) && $line->fk_product > 0 && !getDolGlobalString('TAKEPOS_HIDE_STOCK_ON_LINE')) {
2191 $productChildrenNb = 0;
2192 if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
2193 if (empty($line->product) || !($line->product->id > 0)) {
2194 $line->fetch_product();
2196 if (!empty($line->product)) {
2197 $productChildrenNb = $line->product->hasFatherOrChild(1);
2200 if ($productChildrenNb == 0) {
2201 $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp
";
2202 $sql .= " FROM
".MAIN_DB_PREFIX."entrepot as e,
";
2203 $sql .= " ".MAIN_DB_PREFIX."product_stock as ps
";
2204 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product
";
2205 $sql .= " WHERE ps.reel != 0
";
2206 $sql .= " AND ps.fk_entrepot =
".((int) getDolGlobalString($constantforkey));
2207 $sql .= " AND e.entity IN (
".getEntity('stock').")
";
2208 $sql .= " AND ps.fk_product =
".((int) $line->fk_product);
2209 $resql = $db->query($sql);
2212 $obj = $db->fetch_object($resql);
2214 $stock_real = price2num($obj->reel, 'MS');
2216 $htmlforlines .= ' ';
2217 $htmlforlines .= '<span class="opacitylow
" title="'.$langs->trans("Stock").' '.price($stock_real, 1, '', 1, 0).'">';
2218 $htmlforlines .= '(';
2219 if ($line->qty && $line->qty > $stock_real) {
2220 $htmlforlines .= '<span style="color: var(--amountremaintopaycolor)
">';
2222 $htmlforlines .= img_picto('', 'stock', 'class="pictofixedwidth
"').price($stock_real, 1, '', 1, 0);
2223 if ($line->qty && $line->qty > $stock_real) {
2224 $htmlforlines .= "</span>
";
2226 $htmlforlines .= ')';
2227 $htmlforlines .= '</span>';
2229 dol_print_error($db);
2235 $htmlforlines .= '</td>';
2236 if (getDolGlobalInt('TAKEPOS_SHOW_HT')) {
2237 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
2238 $htmlforlines .= price($line->total_ht, 1, '', 1, -1, -1, $conf->currency);
2239 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
2240 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
2241 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
2242 $multicurrency = new MultiCurrency($db);
2243 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
2244 $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>';
2246 $htmlforlines .= '</td>';
2248 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
2249 $htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency);
2250 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
2251 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
2252 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
2253 $multicurrency = new MultiCurrency($db);
2254 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
2255 $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>';
2257 $htmlforlines .= '</td>';
2259 $htmlforlines .= '</tr>'."\n
";
2260 $htmlforlines .= empty($htmlsupplements[$line->id]) ? '' : $htmlsupplements[$line->id];
2262 print $htmlforlines;
2265 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td>';
2266 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2267 print '<td></td><td></td>';
2268 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
2274} else { // No invoice generated yet
2275 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td>';
2276 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
2277 print '<td></td><td></td>';
2278 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
2291if ($action == "search
") {
2293 <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
')).'">
2300if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
2301 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.