31 if (!defined(
'NOTOKENRENEWAL')) {
32 define(
'NOTOKENRENEWAL',
'1');
34 if (!defined(
'NOREQUIREMENU')) {
35 define(
'NOREQUIREMENU',
'1');
37 if (!defined(
'NOREQUIREHTML')) {
38 define(
'NOREQUIREHTML',
'1');
40 if (!defined(
'NOREQUIREAJAX')) {
41 define(
'NOREQUIREAJAX',
'1');
45 if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
46 require
'../main.inc.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
53 $hookmanager->initHooks(array(
'takeposinvoice'));
55 $langs->loadLangs(array(
"companies",
"commercial",
"bills",
"cashdesk",
"stocks",
"banks"));
58 $action =
GETPOST(
'action',
'aZ09');
59 $idproduct =
GETPOST(
'idproduct',
'int');
60 $place = (
GETPOST(
'place',
'aZ09') ?
GETPOST(
'place',
'aZ09') : 0);
62 $mobilepage =
GETPOST(
'mobilepage',
'alpha');
66 if (empty($user->rights->takepos->run) && !defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
70 if ((
getDolGlobalString(
'TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->layout ==
'phone') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
72 if ($_SESSION[
"takeposterminal"] ==
"") {
74 $_SESSION[
"takeposterminal"] = 1;
76 header(
"Location: ".DOL_URL_ROOT.
"/takepos/index.php");
91 header($_SERVER[
'SERVER_PROTOCOL'].
' 500 Internal Server Error',
true, 500);
97 $number =
GETPOST(
'number',
'alpha');
98 $idline =
GETPOST(
'idline',
'int');
99 $selectedline =
GETPOST(
'selectedline',
'int');
100 $desc =
GETPOST(
'desc',
'alphanohtml');
104 $invoiceid =
GETPOST(
'invoiceid',
'int');
107 if ($pay ==
'cash') {
110 if ($pay ==
'card') {
113 if ($pay ==
'cheque') {
120 $sql =
"SELECT id FROM ".MAIN_DB_PREFIX.
"c_paiement";
121 $sql .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
122 $sql .=
" AND code = '".$db->escape($paycode).
"'";
123 $resql = $db->query($sql);
125 $obj = $db->fetch_object(
$resql);
127 $paiementid = $obj->id;
133 if ($invoiceid > 0) {
134 $ret = $invoice->fetch($invoiceid);
136 $ret = $invoice->fetch(
'',
'(PROV-POS'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'') .
'-'.$place.
')');
139 $placeid = $invoice->id;
142 $constforcompanyid =
'CASHDESK_ID_THIRDPARTY'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
145 if ($invoice->socid > 0) {
146 $soc->fetch($invoice->socid);
152 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"])) {
153 if ($invoice->multicurrency_code != $_SESSION[
"takeposcustomercurrency"]) {
154 $invoice->setMulticurrencyCode($_SESSION[
"takeposcustomercurrency"]);
164 $reshook=$hookmanager->executeHooks(
'doActions', $parameters, $invoice, $action);
165 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
167 if (empty($reshook)) {
169 if ($action ==
'valid' && $user->rights->facture->creer) {
173 if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) {
174 $bankaccount =
GETPOST(
'accountid',
'int');
177 $bankaccount =
getDolGlobalString(
'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION[
"takeposterminal"]);
178 } elseif ($pay ==
"CHQ") {
179 $bankaccount =
getDolGlobalString(
'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION[
"takeposterminal"]);
181 $accountname =
"CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION[
"takeposterminal"];
186 if ($bankaccount <= 0 && $pay !=
"delayed" &&
isModEnabled(
"banque")) {
187 $errormsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount"));
195 $invoice->fetch($placeid);
197 if ($invoice->total_ttc < 0) {
198 $invoice->type = $invoice::TYPE_CREDIT_NOTE;
200 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture WHERE";
201 $sql .=
" fk_soc = ".((int) $invoice->socid);
202 $sql .=
" AND type <> ".Facture::TYPE_CREDIT_NOTE;
203 $sql .=
" AND fk_statut >= ".$invoice::STATUS_VALIDATED;
204 $sql .=
" ORDER BY rowid DESC";
206 $resql = $db->query($sql);
208 $obj = $db->fetch_object(
$resql);
209 $fk_source = $obj->rowid;
210 if ($fk_source ==
null) {
211 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
214 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
216 $invoice->fk_facture_source = $fk_source;
217 $invoice->update($user);
220 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.$_SESSION[
"takeposterminal"];
225 if ($invoice->getRemainToPay() > 0) {
231 } elseif (count($invoice->lines) == 0) {
235 } elseif (
isModEnabled(
'stock') && $conf->global->$constantforkey !=
"1") {
236 $savconst = $conf->global->STOCK_CALCULATE_ON_BILL;
237 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
239 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
240 dol_syslog(
"Validate invoice with stock change into warehouse defined into constant ".$constantforkey.
" = ".$conf->global->$constantforkey);
242 if (
isModEnabled(
'productbatch') && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) {
243 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
246 $res = $invoice->validate($user,
'', $conf->global->$constantforkey, 0, $batch_rule);
248 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
250 $res = $invoice->validate($user);
253 $langs->load(
"admin");
254 dol_htmloutput_errors($invoice->error ==
'NotConfigured' ? $langs->trans(
"NotConfigured").
' (TakePos numbering module)': $invoice->error, $invoice->errors, 1);
265 if (!$error && $res >= 0) {
266 $remaintopay = $invoice->getRemainToPay();
267 if ($remaintopay > 0) {
269 $payment->datepaye = $now;
270 $payment->fk_account = $bankaccount;
271 $payment->amounts[$invoice->id] = $amountofpayment;
278 if ($amountofpayment == 0 || $amountofpayment > $remaintopay) {
279 $payment->amounts[$invoice->id] = $remaintopay;
282 $payment->paiementid = $paiementid;
283 $payment->num_payment = $invoice->ref;
285 if ($pay !=
"delayed") {
286 $payment->create($user);
287 $payment->addPaymentToBank($user,
'payment',
'(CustomerInvoicePayment)', $bankaccount,
'',
'');
288 $remaintopay = $invoice->getRemainToPay();
292 if ($remaintopay == 0) {
293 dol_syslog(
"Invoice is paid, so we set it to status Paid");
294 $result = $invoice->setPaid($user);
299 $invoice->setPaymentMethods($paiementid);
301 dol_syslog(
"Invoice is not paid, remain to pay = ".$remaintopay);
308 if ($action ==
'creditnote' && $user->rights->facture->creer) {
309 $creditnote =
new Facture($db);
310 $creditnote->socid = $invoice->socid;
312 $creditnote->module_source =
'takepos';
313 $creditnote->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
315 $creditnote->fk_facture_source = $placeid;
316 $creditnote->remise_absolue = $invoice->remise_absolue;
317 $creditnote->remise_percent = $invoice->remise_percent;
318 $creditnote->create($user);
320 foreach ($invoice->lines as $line) {
322 if (method_exists($line,
'fetch_optionals')) {
324 $line->fetch_optionals();
327 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
331 $source_fk_prev_id = $line->fk_prev_id;
332 $line->fk_prev_id = $line->id;
333 if (!empty($invoice->tab_previous_situation_invoice)) {
336 $tab_jumped_credit_notes = array();
337 $lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
338 $searchPreviousInvoice =
true;
339 while ($searchPreviousInvoice) {
341 $searchPreviousInvoice =
false;
345 $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id;
351 $maxPrevSituationPercent = 0;
352 foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
353 if ($prevLine->id == $source_fk_prev_id) {
354 $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
357 $line->total_ht = $line->total_ht - $prevLine->total_ht;
358 $line->total_tva = $line->total_tva - $prevLine->total_tva;
359 $line->total_ttc = $line->total_ttc - $prevLine->total_ttc;
360 $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1;
361 $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2;
363 $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice;
364 $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht;
365 $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva;
366 $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc;
371 $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
376 $maxPrevSituationPercent = 0;
377 foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
378 foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) {
379 if ($prevLine->fk_prev_id == $source_fk_prev_id) {
380 $maxPrevSituationPercent = $prevLine->situation_percent;
382 $line->total_ht -= $prevLine->total_ht;
383 $line->total_tva -= $prevLine->total_tva;
384 $line->total_ttc -= $prevLine->total_ttc;
385 $line->total_localtax1 -= $prevLine->total_localtax1;
386 $line->total_localtax2 -= $prevLine->total_localtax2;
388 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
389 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
390 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
391 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
397 $line->situation_percent += $maxPrevSituationPercent;
403 $line->fk_facture = $creditnote->id;
404 $line->fk_parent_line = $fk_parent_line;
406 $line->subprice = -$line->subprice;
407 $line->pa_ht = $line->pa_ht;
408 $line->total_ht = -$line->total_ht;
409 $line->total_tva = -$line->total_tva;
410 $line->total_ttc = -$line->total_ttc;
411 $line->total_localtax1 = -$line->total_localtax1;
412 $line->total_localtax2 = -$line->total_localtax2;
414 $line->multicurrency_subprice = -$line->multicurrency_subprice;
415 $line->multicurrency_total_ht = -$line->multicurrency_total_ht;
416 $line->multicurrency_total_tva = -$line->multicurrency_total_tva;
417 $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
419 $result = $line->insert(0, 1);
421 $creditnote->lines[] = $line;
424 if ($result > 0 && $line->product_type == 9) {
425 $fk_parent_line = $result;
428 $creditnote->update_price(1);
430 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.$_SESSION[
"takeposterminal"];
431 if (
isModEnabled(
'stock') && $conf->global->$constantforkey !=
"1") {
432 $savconst = $conf->global->STOCK_CALCULATE_ON_BILL;
433 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
434 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
435 dol_syslog(
"Validate invoice with stock change into warehouse defined into constant ".$constantforkey.
" = ".$conf->global->$constantforkey);
437 if (
isModEnabled(
'productbatch') && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) {
438 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
441 $res = $creditnote->validate($user,
'', $conf->global->$constantforkey, 0, $batch_rule);
442 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
444 $res = $creditnote->validate($user);
448 if ($action ==
'history' || $action ==
'creditnote') {
449 if ($action ==
'creditnote') {
450 $placeid = $creditnote->id;
452 $placeid = (int)
GETPOST(
'placeid',
'int');
455 $invoice->fetch($placeid);
458 if (($action ==
"addline" || $action ==
"freezone") && $placeid == 0) {
461 $invoice->module_source =
'takepos';
462 $invoice->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
463 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] : $conf->entity;
465 if ($invoice->socid <= 0) {
466 $langs->load(
'errors');
469 $placeid = $invoice->create($user);
473 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture set ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")' where rowid = ".((int) $placeid);
478 if ($action ==
"addline") {
480 $prod->fetch($idproduct);
483 $customer->fetch($invoice->socid);
485 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
488 $price = $datapriceofproduct[
'pu_ht'];
489 $price_ttc = $datapriceofproduct[
'pu_ttc'];
491 $price_base_type = $datapriceofproduct[
'price_base_type'];
492 $tva_tx = $datapriceofproduct[
'tva_tx'];
493 $tva_npr = $datapriceofproduct[
'tva_npr'];
496 $localtax1_tx =
get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
497 $localtax2_tx =
get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
499 if (!empty($conf->global->TAKEPOS_SUPPLEMENTS)) {
500 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
502 $categories = $cat->containing($idproduct,
'product');
503 $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories,
'id')));
504 if ($found !==
false) {
505 $sql =
"SELECT fk_parent_line FROM ".MAIN_DB_PREFIX.
"facturedet where rowid=$selectedline";
506 $resql = $db->query($sql);
507 $row = $db->fetch_array(
$resql);
508 if ($row[0] ==
null) {
509 $parent_line = $selectedline;
511 $parent_line = $row[0];
518 if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT)) {
519 foreach ($invoice->lines as $line) {
520 if ($line->product_ref == $prod->ref) {
521 if ($line->special_code==4)
continue;
522 $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);
526 $idoflineadded = $line->id;
532 if ($idoflineadded <= 0) {
533 $invoice->fetch_thirdparty();
534 $array_options = array();
536 $line = array(
'description' => $prod->description,
'price' => $price,
'tva_tx' => $tva_tx,
'locatax1_tx' => $localtax1_tx,
'locatax2_tx' => $localtax2_tx,
'remise_percent' => $customer->remise_percent,
'price_ttc' => $price_ttc,
'array_options' => $array_options);
539 if (isset($conf->global->MARGIN_TYPE)) {
540 if ($conf->global->MARGIN_TYPE ==
'pmp' && !empty($prod->pmp)) {
541 $line[
'fk_fournprice'] =
null;
542 $line[
'pa_ht'] = $prod->pmp;
543 } elseif ($conf->global->MARGIN_TYPE ==
'costprice' && !empty($prod->cost_price)) {
544 $line[
'fk_fournprice'] =
null;
545 $line[
'pa_ht'] = $prod->cost_price;
548 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
550 if ($pf->find_min_price_product_fournisseur($idproduct, $qty) > 0) {
551 $line[
'fk_fournprice'] = $pf->product_fourn_price_id;
552 $line[
'pa_ht'] = $pf->fourn_unitprice_with_discount;
553 if ($pf->fourn_charges > 0)
554 $line[
'pa_ht'] += $pf->fourn_charges / $pf->fourn_qty;
560 $parameters = array(
'prod' => $prod,
'line' => $line);
561 $reshook=$hookmanager->executeHooks(
'completeTakePosAddLine', $parameters, $invoice, $action);
562 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
565 if (empty($reshook)) {
566 if (!empty($hookmanager->resArray)) {
567 $line = $hookmanager->resArray;
570 $idoflineadded = $invoice->addline($line[
'description'], $line[
'price'], $qty, $line[
'tva_tx'], $line[
'localtax1_tx'], $line[
'localtax2_tx'], $idproduct, $line[
'remise_percent'],
'', 0, 0, 0,
'', $price_base_type, $line[
'price_ttc'], $prod->type, -1, 0,
'', 0, (!empty($parent_line)) ? $parent_line :
'', $line[
'fk_fournprice'], $line[
'pa_ht'],
'', $line[
'array_options'], 100,
'',
null, 0);
573 if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
574 $CUSTOMER_DISPLAY_line1 = $prod->label;
575 $CUSTOMER_DISPLAY_line2 =
price($price_ttc);
579 $invoice->fetch($placeid);
582 if ($action ==
"freezone") {
584 $customer->fetch($invoice->socid);
586 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
588 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
596 $localtax1_tx =
get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
597 $localtax2_tx =
get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
599 $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0,
'', 0, 0, 0,
'',
getDolGlobalInt(
'TAKEPOS_CHANGE_PRICE_HT') ?
'HT' :
'TTC', $number, 0, -1, 0,
'', 0, 0,
null,
'',
'', 0, 100,
'',
null, 0);
600 $invoice->fetch($placeid);
603 if ($action ==
"addnote") {
604 $desc =
GETPOST(
'addnote',
'alpha');
606 $invoice->update_note($desc,
'_public');
607 }
else foreach ($invoice->lines as $line) {
608 if ($line->id == $idline) {
609 $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);
612 $invoice->fetch($placeid);
615 if ($action ==
"deleteline") {
616 if ($idline > 0 and $placeid > 0) {
617 $invoice->deleteline($idline);
618 $invoice->fetch($placeid);
619 } elseif ($placeid > 0) {
620 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facturedet where fk_facture = ".((int) $placeid).
" ORDER BY rowid DESC";
621 $resql = $db->query($sql);
622 $row = $db->fetch_array(
$resql);
623 $deletelineid = $row[0];
624 $invoice->deleteline($deletelineid);
625 $invoice->fetch($placeid);
627 if (count($invoice->lines) == 0) {
628 $invoice->delete($user);
629 header(
"Location: ".DOL_URL_ROOT.
"/takepos/invoice.php");
635 if ($action ==
"delete") {
638 $result = $invoice->fetch($placeid);
645 foreach ($invoice->lines as $line) {
646 $tmpres = $invoice->deleteline($line->id);
653 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture";
654 $varforconst =
'CASHDESK_ID_THIRDPARTY'.$_SESSION[
"takeposterminal"];
655 $sql .=
" SET fk_soc = ".((int) $conf->global->$varforconst).
", ";
656 $sql .=
" datec = '".$db->idate(
dol_now()).
"'";
657 $sql .=
" WHERE ref = '(PROV-POS".$db->escape($_SESSION[
"takeposterminal"].
"-".$place).
")'";
658 $resql1 = $db->query($sql);
660 if ($resdeletelines && $resql1) {
666 $invoice->fetch($placeid);
671 if ($action ==
"updateqty") {
672 foreach ($invoice->lines as $line) {
673 if ($line->id == $idline) {
674 if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code ==
"4")) {
677 $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $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);
682 $invoice->fetch($placeid);
685 if ($action ==
"updateprice") {
687 $customer->fetch($invoice->socid);
689 foreach ($invoice->lines as $line) {
690 if ($line->id == $idline) {
692 $prod->fetch($line->fk_product);
693 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
694 $price_min = $datapriceofproduct[
'price_min'];
695 $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
696 $pu_ht =
price2num($number / (1 + ($line->tva_tx / 100)),
'MU');
698 if ($usercanproductignorepricemin && (!empty($price_min) && (
price2num($pu_ht) * (1 -
price2num($line->remise_percent) / 100) <
price2num($price_min)))) {
699 $langs->load(
"products");
703 if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code ==
"4")) {
706 $result = $invoice->updateline($line->id, $line->desc, $number, $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);
708 $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $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);
715 $invoice->fetch($placeid);
718 if ($action ==
"updatereduction") {
720 $customer->fetch($invoice->socid);
722 foreach ($invoice->lines as $line) {
723 if ($line->id == $idline) {
724 dol_syslog(
"updatereduction Process line ".$line->id.
' to apply discount of '.$number.
'%');
727 $prod->fetch($line->fk_product);
729 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
730 $price_min = $datapriceofproduct[
'price_min'];
731 $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
733 $pu_ht =
price2num($line->subprice / (1 + ($line->tva_tx / 100)),
'MU');
736 if ($usercanproductignorepricemin && (!empty($price_min) && (
price2num($line->subprice) * (1 -
price2num($number) / 100) <
price2num($price_min)))) {
737 $langs->load(
"products");
740 if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code ==
"4")) {
743 $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $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);
750 $invoice->fetch($placeid);
751 } elseif ($action ==
'update_reduction_global') {
752 foreach ($invoice->lines as $line) {
753 $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $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);
756 $invoice->fetch($placeid);
759 if ($action ==
"order" and $placeid != 0) {
760 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
761 if ($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") {
762 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolreceiptprinter.class.php';
766 $sql =
"SELECT label FROM ".MAIN_DB_PREFIX.
"takepos_floor_tables where rowid=".((int) $place);
767 $resql = $db->query($sql);
768 $row = $db->fetch_object(
$resql);
769 $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>';
770 $footerorder =
'</tbody></table>'.dol_print_date(
dol_now(),
'dayhour').
'<br></html>';
771 $order_receipt_printer1 =
"";
772 $order_receipt_printer2 =
"";
773 $order_receipt_printer3 =
"";
774 $catsprinter1 = explode(
';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1);
775 $catsprinter2 = explode(
';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2);
776 $catsprinter3 = explode(
';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3);
778 foreach ($invoice->lines as $line) {
779 if ($line->special_code ==
"4") {
783 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT,
'id');
784 $result = array_intersect($catsprinter1, $existing);
785 $count = count($result);
786 if (!$line->fk_product) {
791 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='1' where rowid=".$line->id;
793 $order_receipt_printer1 .=
'<tr><td class="left">';
794 if ($line->fk_product) {
795 $order_receipt_printer1 .= $line->product_label;
797 $order_receipt_printer1 .= $line->description;
799 $order_receipt_printer1 .=
'</td><td class="right">'.$line->qty;
800 if (!empty($line->array_options[
'options_order_notes'])) {
801 $order_receipt_printer1 .=
"<br>(".$line->array_options[
'options_order_notes'].
")";
803 $order_receipt_printer1 .=
'</td></tr>';
806 if (($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") && $linestoprint > 0) {
807 $invoice->fetch($placeid);
808 $printer->orderprinter = 1;
810 echo
"var orderprinter1esc='";
811 $ret = $printer->sendToPrinter($invoice,
getDolGlobalInt(
'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION[
"takeposterminal"]),
getDolGlobalInt(
'TAKEPOS_ORDER_PRINTER1_TO_USE'.$_SESSION[
"takeposterminal"]));
814 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id;
816 $invoice->fetch($placeid);
819 foreach ($invoice->lines as $line) {
820 if ($line->special_code ==
"4") {
824 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT,
'id');
825 $result = array_intersect($catsprinter2, $existing);
826 $count = count($result);
829 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='2' where rowid=".$line->id;
831 $order_receipt_printer2 .=
'<tr>'.$line->product_label.
'<td class="right">'.$line->qty;
832 if (!empty($line->array_options[
'options_order_notes'])) {
833 $order_receipt_printer2 .=
"<br>(".$line->array_options[
'options_order_notes'].
")";
835 $order_receipt_printer2 .=
'</td></tr>';
838 if (($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") && $linestoprint > 0) {
839 $invoice->fetch($placeid);
840 $printer->orderprinter = 2;
842 echo
"var orderprinter2esc='";
843 $ret = $printer->sendToPrinter($invoice,
getDolGlobalInt(
'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION[
"takeposterminal"]),
getDolGlobalInt(
'TAKEPOS_ORDER_PRINTER2_TO_USE'.$_SESSION[
"takeposterminal"]));
846 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id;
848 $invoice->fetch($placeid);
851 foreach ($invoice->lines as $line) {
852 if ($line->special_code ==
"4") {
856 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT,
'id');
857 $result = array_intersect($catsprinter3, $existing);
858 $count = count($result);
861 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='3' where rowid=".$line->id;
863 $order_receipt_printer3 .=
'<tr>'.$line->product_label.
'<td class="right">'.$line->qty;
864 if (!empty($line->array_options[
'options_order_notes'])) {
865 $order_receipt_printer3 .=
"<br>(".$line->array_options[
'options_order_notes'].
")";
867 $order_receipt_printer3 .=
'</td></tr>';
870 if (($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") && $linestoprint > 0) {
871 $invoice->fetch($placeid);
872 $printer->orderprinter = 3;
874 echo
"var orderprinter3esc='";
875 $ret = $printer->sendToPrinter($invoice,
getDolGlobalInt(
'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION[
"takeposterminal"]),
getDolGlobalInt(
'TAKEPOS_ORDER_PRINTER3_TO_USE'.$_SESSION[
"takeposterminal"]));
878 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id;
880 $invoice->fetch($placeid);
883 $sectionwithinvoicelink =
'';
884 if ($action ==
"valid" || $action ==
"history" || $action ==
'creditnote') {
885 $sectionwithinvoicelink .=
'<!-- Section with invoice link -->'.
"\n";
886 $sectionwithinvoicelink .=
'<span style="font-size:120%;" class="center">';
887 $sectionwithinvoicelink .= $invoice->getNomUrl(1,
'', 0, 0,
'', 0, 0, -1,
'_backoffice').
" - ";
888 $remaintopay = $invoice->getRemainToPay();
889 if ($remaintopay > 0) {
890 $sectionwithinvoicelink .= $langs->trans(
'RemainToPay').
': <span class="amountremaintopay" style="font-size: unset">'.
price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
892 if ($invoice->paye) {
893 $sectionwithinvoicelink .=
'<span class="amountpaymentcomplete" style="font-size: unset">'.$langs->trans(
"Paid").
'</span>';
895 $sectionwithinvoicelink .= $langs->trans(
'BillShortStatusValidated');
898 $sectionwithinvoicelink .=
'</span><br>';
900 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
901 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="TakeposConnector('.$placeid.
');">'.$langs->trans(
'PrintTicket').
'</button>';
903 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="TakeposPrinting('.$placeid.
');">'.$langs->trans(
'PrintTicket').
'</button>';
906 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="DolibarrTakeposPrinting('.$placeid.
');">'.$langs->trans(
'PrintTicket').
'</button>';
908 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="Print('.$placeid.
');">'.$langs->trans(
'PrintTicket').
'</button>';
910 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="PrintBox('.$placeid.
', \'without_details\');">'.$langs->trans(
'PrintWithoutDetails').
'</button>';
913 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="Print('.$placeid.
', 1);">'.$langs->trans(
'GiftReceipt').
'</button>';
916 if (
getDolGlobalString(
'TAKEPOS_EMAIL_TEMPLATE_INVOICE') && $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) {
917 $sectionwithinvoicelink .=
' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.
');">'.$langs->trans(
'SendTicket').
'</button>';
920 if ($remaintopay <= 0 &&
getDolGlobalString(
'TAKEPOS_AUTO_PRINT_TICKETS') && $action !=
"history") {
921 $sectionwithinvoicelink .=
'<script type="text/javascript">$("#buttonprint").click();</script>';
933 if ((
getDolGlobalString(
'TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->layout ==
'phone') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
934 $title =
'TakePOS - Dolibarr '.DOL_VERSION;
935 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
936 $title =
'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
938 $head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
939 <meta name="apple-mobile-web-app-capable" content="yes">
940 <meta name="mobile-web-app-capable" content="yes">
941 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
943 '/takepos/css/pos.css.php',
945 $arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
948 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
957 <script
type=
"text/javascript">
960 <?php
if ($action==
"valid") echo
"var place=0;";?>
961 var placeid=<?php echo ($placeid > 0 ? $placeid : 0); ?>;
962 $(document).ready(
function() {
963 var idoflineadded = <?php echo (empty($idoflineadded) ? 0 : $idoflineadded); ?>;
965 $(
'.posinvoiceline').click(
function(){
966 console.log(
"Click done on "+this.
id);
967 $(
'.posinvoiceline').removeClass(
"selected");
968 $(
this).addClass(
"selected");
969 if (selectedline==this.
id)
return;
970 else selectedline=this.id;
971 selectedtext=$(
'#'+selectedline).find(
"td:first").html();
973 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
974 print
'$("#phonediv1").load("auto_order.php?action=editline&token='.newToken().
'&placeid="+placeid+"&selectedline="+selectedline, function() {
981 if (idoflineadded > 0)
983 console.log(
"Auto select "+idoflineadded);
984 $(
'.posinvoiceline#'+idoflineadded).click();
988 if ($action ==
"order" && !empty($order_receipt_printer1)) {
989 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
993 url:
'<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php',
994 data:
'invoice='+orderprinter1esc
1001 url:
'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
1003 print $headerorder.$order_receipt_printer1.$footerorder; ?>'
1009 if ($action ==
"order" && !empty($order_receipt_printer2)) {
1010 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
1014 url:
'<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=2',
1015 data:
'invoice='+orderprinter2esc
1022 url:
'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print2',
1024 print $headerorder.$order_receipt_printer2.$footerorder; ?>'
1030 if ($action ==
"order" && !empty($order_receipt_printer3)) {
1031 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
1035 url:
'<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=3',
1036 data:
'invoice='+orderprinter3esc
1043 if ($action ==
"search" || $action ==
"valid") {
1045 parent.setFocusOnSearchField();
1050 if ($action ==
"temp" && !empty($ticket_printer1)) {
1054 url:
'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
1056 print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>'
1061 if ($action ==
"search") {
1063 $(
'#search').focus();
1071 function SendTicket(
id)
1073 console.log(
"Open box to select the Print/Send form");
1074 $.colorbox({href:
"send.php?facid="+id, width:
"70%", height:
"30%", transition:
"none", iframe:
"true", title:
'<?php echo dol_escape_js($langs->trans("SendTicket")); ?>'});
1077 function PrintBox(
id, action) {
1078 console.log(
"Open box before printing");
1079 $.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
"); ?>"});
1082 function Print(
id, gift){
1083 console.log(
"Call Print() to generate the receipt.");
1084 $.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")); ?>'});
1087 function TakeposPrinting(
id){
1089 console.log(
"TakeposPrinting" +
id);
1090 $.get(
"receipt.php?facid="+
id,
function(data, status) {
1091 receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,
'');
1094 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1100 function TakeposConnector(
id){
1101 console.log(
"TakeposConnector" +
id);
1102 $.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) {
1105 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php',
1106 data:
'invoice='+data
1111 function DolibarrTakeposPrinting(
id) {
1112 console.log(
"DolibarrTakeposPrinting Printing invoice ticket " +
id)
1115 data: { token:
'<?php echo currentToken(); ?>' },
1116 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=printinvoiceticket&token='.newToken().'&term='.urlencode(isset($_SESSION["takeposterminal
"]) ? $_SESSION["takeposterminal
"] : '').'&id='; ?>" + id,
1120 function CreditNote() {
1121 $(
"#poslines").load(
"invoice.php?action=creditnote&token=<?php echo newToken() ?>&invoiceid="+placeid,
function() {
1125 function SetNote() {
1126 $(
"#poslines").load(
"invoice.php?action=addnote&token=<?php echo newToken() ?>&invoiceid="+placeid+
"&idline="+selectedline, {
"addnote": $(
"#textinput").val() });
1130 $( document ).ready(
function() {
1131 console.log(
"Set customer info and sales in header placeid=<?php echo $placeid; ?> status=<?php echo $invoice->statut; ?>");
1134 $s = $langs->trans(
"Customer");
1135 if ($invoice->id > 0 && ($invoice->socid != $conf->global->$constforcompanyid)) {
1140 $(
"#customerandsales").html(
'');
1141 $(
"#shoppingcart").html(
'');
1143 $(
"#customerandsales").append(
'<a class="valignmiddle tdoverflowmax100 minwidth100" id="customer" onclick="Customer();" title="<?php print dol_escape_js($s); ?>"><span class="fas fa-building paddingrightonly"></span><?php print dol_escape_js($s); ?></a>');
1146 $sql =
"SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX.
"facture";
1147 if (empty($conf->global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) {
1149 $sql .=
" WHERE ref LIKE '(PROV-POS".$db->escape(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'').
"-0%' AND entity IN (".
getEntity(
'invoice').
")";
1152 $sql .=
" WHERE pos_source = '".$db->escape($_SESSION[
"takeposterminal"]).
"'";
1153 $sql .=
" AND module_source = 'takepos'";
1154 $sql .=
" AND entity IN (".getEntity(
'invoice').
")";
1157 $sql .= $db->order(
'datec',
'ASC');
1158 $resql = $db->query($sql);
1161 while ($obj = $db->fetch_object(
$resql)) {
1162 echo
'$("#shoppingcart").append(\'';
1163 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=\\\'';
1164 $num_sale = str_replace(
")",
"", str_replace(
"(PROV-POS".$_SESSION[
"takeposterminal"].
"-",
"", $obj->ref));
1166 if (str_replace(
"-",
"", $num_sale) > $max_sale) {
1167 $max_sale = str_replace(
"-",
"", $num_sale);
1169 echo
'\\\'; invoiceid=\\\'';
1171 echo
'\\\'; Refresh();">';
1172 if ($placeid == $obj->rowid) {
1173 echo
'<span class="basketselected">';
1175 echo
'<span class="basketnotselected">';
1177 echo
'<span class="fa fa-shopping-cart paddingright"></span>'.dol_print_date($db->jdate($obj->datec),
'%H:%M',
'tzuser');
1181 echo
'$("#shoppingcart").append(\'<a onclick="place=\\\'0-';
1183 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>\');';
1191 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1194 $constantforkey =
'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1196 if ($idwarehouse > 0) {
1197 $s =
'<span class="small">';
1199 $warehouse->fetch($idwarehouse);
1200 $s .=
'<span class="hideonsmartphone">'.$langs->trans(
"Warehouse").
'<br></span>'.$warehouse->ref;
1202 $s .=
' ('.$langs->trans(
"Closed").
')';
1205 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1206 print
'$("#infowarehouse").css("display", "inline-block");';
1208 $s =
'<span class="small hideonsmartphone">';
1209 $s .= $langs->trans(
"StockChangeDisabled").
'<br>'.$langs->trans(
"NoWarehouseDefinedForTerminal");
1211 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1212 if (!empty($conf->dol_optimize_smallscreen)) {
1213 print
'$("#infowarehouse").css("display", "none");';
1217 $s =
'<span class="small hideonsmartphone">'.$langs->trans(
"StockChangeDisabled").
'</span>';
1218 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1219 if (!empty($conf->dol_optimize_smallscreen)) {
1220 print
'$("#infowarehouse").css("display", "none");';
1228 if (
isModEnabled(
'adherent') && $invoice->socid > 0 && $invoice->socid != $conf->global->$constforcompanyid) {
1229 $s =
'<span class="small">';
1230 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1231 $langs->load(
"members");
1232 $s .= $langs->trans(
"Member").
': ';
1234 $result = $adh->fetch(
'',
'', $invoice->socid);
1236 $adh->ref = $adh->getFullName($langs);
1240 $s .= $adh->getFullName($langs);
1241 $s .=
' - '.$adh->type;
1242 if ($adh->datefin) {
1243 $s .=
'<br>'.$langs->trans(
"SubscriptionEndDate").
': '.
dol_print_date($adh->datefin,
'day');
1244 if ($adh->hasDelay()) {
1245 $s .=
" ".img_warning($langs->trans(
"Late"));
1248 $s .=
'<br>'.$langs->trans(
"SubscriptionNotReceived");
1249 if ($adh->statut > 0) {
1250 $s .=
" ".img_warning($langs->trans(
"Late"));
1257 $s .=
'<br>'.$langs->trans(
"ThirdpartyNotLinkedToMember");
1262 $(
"#moreinfo").html(
'<?php print dol_escape_js($s); ?>');
1268 if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
1269 echo
"function CustomerDisplay(){";
1270 echo
"var line1='".$CUSTOMER_DISPLAY_line1.
"'.substring(0,20);";
1271 echo
"line1=line1.padEnd(20);";
1272 echo
"var line2='".$CUSTOMER_DISPLAY_line2.
"'.substring(0,20);";
1273 echo
"line2=line2.padEnd(20);";
1276 data: { text: line1+line2 },
1277 url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER').
"/display/index.php',
1288 if (!empty($conf->use_javascript_ajax)) {
1289 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
1290 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.
'"></script>'.
"\n";
1293 print
'<!-- invoice.php place='.(int) $place.
' invoice='.$invoice->ref.
' mobilepage='.(empty($mobilepage) ?
'' : $mobilepage).
' $_SESSION["basiclayout"]='.(empty($_SESSION[
"basiclayout"])?
'':$_SESSION[
"basiclayout"]).
' conf->global->TAKEPOS_BAR_RESTAURANT='.
getDolGlobalString(
'TAKEPOS_BAR_RESTAURANT').
' -->'.
"\n";
1294 print
'<div class="div-table-responsive-no-min invoice">';
1295 print
'<table id="tablelines" class="noborder noshadow postablelines" width="100%">';
1296 if ($sectionwithinvoicelink && ($mobilepage ==
"invoice" || $mobilepage ==
"")) {
1297 if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
1298 print
'<tr><td colspan="5">'.$sectionwithinvoicelink.
'</td></tr>';
1300 print
'<tr><td colspan="4">'.$sectionwithinvoicelink.
'</td></tr>';
1303 print
'<tr class="liste_titre nodrag nodrop">';
1304 print
'<td class="linecoldescription">';
1306 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1307 print
'<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.
'">';
1310 $sql =
"SELECT floor, label FROM ".MAIN_DB_PREFIX.
"takepos_floor_tables where rowid=".((int) $place);
1311 $resql = $db->query($sql);
1312 $obj = $db->fetch_object(
$resql);
1314 $label = $obj->label;
1315 $floor = $obj->floor;
1317 if ($mobilepage ==
"invoice" || $mobilepage ==
"") {
1320 print
'<span class="opacitymedium">'.$langs->trans(
'Place').
"</span> <b>".(empty($label) ?
'?' : $label).
"</b><br>";
1321 print
'<span class="opacitymedium">'.$langs->trans(
'Floor').
"</span> <b>".(empty($floor) ?
'?' : $floor).
"</b>";
1322 } elseif (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1324 } elseif ($mobilepage ==
"cats") {
1325 print $langs->trans(
'Category');
1326 } elseif ($mobilepage ==
"products") {
1327 print $langs->trans(
'Label');
1330 print $langs->trans(
"Products");
1335 $parameters=array();
1336 $reshook=$hookmanager->executeHooks(
'completeTakePosInvoiceHeader', $parameters, $invoice, $action);
1337 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1338 print $hookmanager->resPrint;
1340 if (empty($_SESSION[
"basiclayout"]) || $_SESSION[
"basiclayout"] != 1) {
1341 print
'<td class="linecolqty right">'.$langs->trans(
'ReductionShort').
'</td>';
1342 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
1344 print
'<td class="linecolht right nowraponall">';
1345 print
'<span class="opacitymedium small">' . $langs->trans(
'TotalHTShort') .
'</span><br>';
1347 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1348 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>';
1349 if (
isModEnabled(
'multicurrency') && $_SESSION[
"takeposcustomercurrency"] !=
"" && $conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
1351 include_once DOL_DOCUMENT_ROOT .
'/multicurrency/class/multicurrency.class.php';
1353 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
1354 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>';
1360 print
'<td class="linecolht right nowraponall">';
1361 print
'<span class="opacitymedium small">'.$langs->trans(
'TotalTTCShort').
'</span><br>';
1363 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1364 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>';
1365 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"]) && $conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
1367 include_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
1369 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
1370 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>';
1375 } elseif ($mobilepage ==
"invoice") {
1376 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
1381 if (!empty($_SESSION[
"basiclayout"]) && $_SESSION[
"basiclayout"] == 1) {
1382 if ($mobilepage ==
"cats") {
1383 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1385 $categories = $categorie->get_full_arbo(
'product');
1387 foreach ($categories as $row) {
1388 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1389 $htmlforlines .=
'<div class="leftcat';
1391 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline';
1393 $htmlforlines .=
'" onclick="LoadProducts('.$row[
'id'].
');">';
1394 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1395 $htmlforlines .=
'<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=cat&query=cat&id='.$row[
'id'].
'"><br>';
1397 $htmlforlines .=
'<td class="left">';
1399 $htmlforlines .= $row[
'label'];
1400 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1401 $htmlforlines .=
'</div>'.
"\n";
1403 $htmlforlines .=
'</td></tr>'.
"\n";
1406 $htmlforlines .=
'</table>';
1407 $htmlforlines .=
'</table>';
1408 print $htmlforlines;
1411 if ($mobilepage ==
"products") {
1412 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1414 $catid =
GETPOST(
'catid',
'int');
1415 $result = $object->fetch($catid);
1416 $prods = $object->getObjectsInCateg(
"product");
1418 foreach ($prods as $row) {
1419 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1420 $htmlforlines .=
'<div class="leftcat';
1422 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline';
1424 $htmlforlines .=
'" onclick="AddProduct(\''.$place.
'\',
'.$row->id.')
">';
1425 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1426 $htmlforlines .= '<img class="imgwrapper
" width="33%
" src="'.DOL_URL_ROOT.'/takepos/
public/auto_order.php?genimg=pro&query=pro&
id=
'.$row->id.'"><br>';
1427 $htmlforlines .= $row->label.' '.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency);
1428 $htmlforlines .= '</div>'."\n
";
1430 $htmlforlines .= '<td class="left
">';
1431 $htmlforlines .= $row->label;
1432 $htmlforlines .= '<div class="right
">'.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).'</div>';
1433 $htmlforlines .= '</tr>'."\n
";
1436 $htmlforlines .= '</table>';
1437 print $htmlforlines;
1440 if ($mobilepage == "places
") {
1441 $sql = "SELECT
rowid, entity, label, leftpos, toppos, floor FROM
".MAIN_DB_PREFIX."takepos_floor_tables
";
1442 $resql = $db->query($sql);
1445 while ($row = $db->fetch_array($resql)) {
1447 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
1448 $htmlforlines .= '" onclick="LoadPlace(\
''.$row[
'label'].
'\')
">';
1449 $htmlforlines .= '<td class="left
">';
1450 $htmlforlines .= $row['label'];
1451 $htmlforlines .= '</td>';
1452 $htmlforlines .= '</tr>'."\n
";
1454 $htmlforlines .= '</table>';
1455 print $htmlforlines;
1460 //In Phone basic layout hide some content depends situation
1461 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1 && $mobilepage != "invoice
" && $action != "order
") {
1465 if (is_array($invoice->lines) && count($invoice->lines)) {
1466 print '<!-- invoice.php show lines of invoices -->'."\n
";
1467 $tmplines = array_reverse($invoice->lines);
1468 $htmlsupplements = array();
1469 foreach ($tmplines as $line) {
1470 if ($line->fk_parent_line != false) {
1471 $htmlsupplements[$line->fk_parent_line] .= '<tr class="drag drop oddeven posinvoiceline
';
1472 if ($line->special_code == "4") {
1473 $htmlsupplements[$line->fk_parent_line] .= ' order
';
1475 $htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'"';
1476 if ($line->special_code == "4
") {
1477 $htmlsupplements[$line->fk_parent_line] .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
1479 $htmlsupplements[$line->fk_parent_line] .= '>';
1480 $htmlsupplements[$line->fk_parent_line] .= '<td class="left
">';
1481 $htmlsupplements[$line->fk_parent_line] .= img_picto('', 'rightarrow');
1482 if ($line->product_label) {
1483 $htmlsupplements[$line->fk_parent_line] .= $line->product_label;
1485 if ($line->product_label && $line->desc) {
1486 $htmlsupplements[$line->fk_parent_line] .= '<br>';
1488 if ($line->product_label != $line->desc) {
1489 $firstline = dolGetFirstLineOfText($line->desc);
1490 if ($firstline != $line->desc) {
1491 $htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
1493 $htmlsupplements[$line->fk_parent_line] .= $line->desc;
1496 $htmlsupplements[$line->fk_parent_line] .= '</td>';
1498 // complete line by hook
1499 $parameters=array('line' => $line);
1500 $reshook=$hookmanager->executeHooks('completeTakePosInvoiceParentLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
1501 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1502 $htmlsupplements[$line->fk_parent_line] .= $hookmanager->resPrint;
1504 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
1505 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.vatrate($line->remise_percent, true).'</td>';
1506 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.$line->qty.'</td>';
1507 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.price($line->total_ttc).'</td>';
1509 $htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n
";
1514 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
1515 if ($line->special_code == "4") {
1516 $htmlforlines .= ' order
';
1518 $htmlforlines .= '" id="'.$line->id.'"';
1519 if ($line->special_code == "4
") {
1520 $htmlforlines .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
1522 $htmlforlines .= '>';
1523 $htmlforlines .= '<td class="left
">';
1524 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
1525 $htmlforlines .= '<span class="phoneqty
">'.$line->qty."</span> x
";
1527 if (isset($line->product_type)) {
1528 if (empty($line->product_type)) {
1529 $htmlforlines .= img_object('', 'product').' ';
1531 $htmlforlines .= img_object('', 'service').' ';
1534 if (empty($conf->global->TAKEPOS_SHOW_N_FIRST_LINES)) {
1536 if ($line->product_ref) {
1537 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
1538 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
1539 if ($line->product_label != $line->desc) {
1541 $tooltiptext .= '<br>';
1543 $tooltiptext .= $line->desc;
1546 if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
1547 $htmlforlines .= $form->textwithpicto($line->product_label ? '<b>' . $line->product_ref . '</b> - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
1549 $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
1552 if ($line->product_label) {
1553 $htmlforlines .= $line->product_label;
1555 if ($line->product_label != $line->desc) {
1556 if ($line->product_label && $line->desc) {
1557 $htmlforlines .= '<br>';
1559 $firstline = dolGetFirstLineOfText($line->desc, $conf->global->TAKEPOS_SHOW_N_FIRST_LINES);
1560 if ($firstline != $line->desc) {
1561 $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
1563 $htmlforlines .= $line->desc;
1567 if (!empty($line->array_options['options_order_notes'])) {
1568 $htmlforlines .= "<br>(
".$line->array_options['options_order_notes'].")
";
1570 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
1571 $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>';
1573 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
1575 $moreinfo .= $langs->transcountry("TotalHT
", $mysoc->country_code).': '.price($line->total_ht);
1576 if ($line->vat_src_code) {
1577 $moreinfo .= '<br>'.$langs->trans("VATCode
").': '.$line->vat_src_code;
1579 $moreinfo .= '<br>'.$langs->transcountry("TotalVAT
", $mysoc->country_code).': '.price($line->total_tva);
1580 $moreinfo .= '<br>'.$langs->transcountry("TotalLT1
", $mysoc->country_code).': '.price($line->total_localtax1);
1581 $moreinfo .= '<br>'.$langs->transcountry("TotalLT2
", $mysoc->country_code).': '.price($line->total_localtax2);
1582 $moreinfo .= '<hr>';
1583 $moreinfo .= $langs->transcountry("TotalTTC
", $mysoc->country_code).': '.price($line->total_ttc);
1584 //$moreinfo .= $langs->trans("TotalHT
").': '.$line->total_ht;
1585 if ($line->date_start || $line->date_end) {
1586 $htmlforlines .= '<br><div class="clearboth nowraponall
">'.get_date_range($line->date_start, $line->date_end).'</div>';
1588 $htmlforlines .= '</td>';
1590 // complete line by hook
1591 $parameters=array('line' => $line);
1592 $reshook=$hookmanager->executeHooks('completeTakePosInvoiceLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
1593 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1594 $htmlforlines .= $hookmanager->resPrint;
1596 $htmlforlines .= '<td class="right
">'.vatrate($line->remise_percent, true).'</td>';
1597 $htmlforlines .= '<td class="right
">';
1598 if (isModEnabled('stock') && !empty($user->rights->stock->mouvement->lire)) {
1599 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
1600 if (!empty($conf->global->$constantforkey) && $line->fk_product > 0 && empty($conf->global->TAKEPOS_HIDE_STOCK_ON_LINE)) {
1601 $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp
";
1602 $sql .= " FROM
".MAIN_DB_PREFIX."entrepot as e,
";
1603 $sql .= " ".MAIN_DB_PREFIX."product_stock as ps
";
1604 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product
";
1605 $sql .= " WHERE ps.reel != 0
";
1606 $sql .= " AND ps.fk_entrepot =
".((int) $conf->global->$constantforkey);
1607 $sql .= " AND e.entity IN (
".getEntity('stock').")
";
1608 $sql .= " AND ps.fk_product =
".((int) $line->fk_product);
1609 $resql = $db->query($sql);
1611 $obj = $db->fetch_object($resql);
1612 $stock_real = price2num($obj->reel, 'MS');
1613 $htmlforlines .= $line->qty;
1614 if ($line->qty && $line->qty > $stock_real) {
1615 $htmlforlines .= '<span style="color: var(--amountremaintopaycolor)
">';
1617 $htmlforlines .= ' <span class="posstocktoolow
">('.$langs->trans("Stock
").' '.$stock_real.')</span>';
1618 if ($line->qty && $line->qty > $stock_real) {
1619 $htmlforlines .= "</span>
";
1622 dol_print_error($db);
1625 $htmlforlines .= $line->qty;
1628 $htmlforlines .= $line->qty;
1631 $htmlforlines .= '</td>';
1632 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
1633 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
1634 $htmlforlines .= price($line->total_ht, 1, '', 1, -1, -1, $conf->currency);
1635 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
1636 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
1637 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
1638 $multicurrency = new MultiCurrency($db);
1639 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
1640 $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>';
1642 $htmlforlines .= '</td>';
1644 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
1645 $htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency);
1646 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
1647 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
1648 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
1649 $multicurrency = new MultiCurrency($db);
1650 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
1651 $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>';
1653 $htmlforlines .= '</td>';
1655 $htmlforlines .= '</tr>'."\n
";
1656 $htmlforlines .= empty($htmlsupplements[$line->id]) ? '' : $htmlsupplements[$line->id];
1658 print $htmlforlines;
1661 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td><td></td><td></td>';
1662 if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
1667 } else { // No invoice generated yet
1668 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td><td></td><td></td>';
1670 if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
1678 if (($action == "valid
" || $action == "history
") && $invoice->type != Facture::TYPE_CREDIT_NOTE) {
1679 print '<button id="buttonprint
" type="button" onclick="ModalBox(\
'ModalCreditNote\')">'.$langs->trans(
'CreateCreditNote').
'</button>';
1683 if ($action ==
"search") {
1685 <input type="text" id="search" class="input-search-takepos" name="search" onkeyup="Search2(\'\', null);" style="width: 80%; font-size: 150%;" placeholder="'.dol_escape_htmltag($langs->trans(
'Search')).
'">
1692 if ((
getDolGlobalString(
'TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->layout ==
'phone') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1693 print
'</body></html>';
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_SITUATION
Situation invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage payments of customer invoices.
Class to manage predefined suppliers products.
Class to manage products or services.
const BATCH_RULE_SELLBY_EATBY_DATES_FIRST
Batches rules.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Receipt Printers.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formated error messages to output (Used to show messages on html output).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
if(empty($user->rights->takepos->run) &&!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) if((getDolGlobalString('TAKEPOS_PHONE_BASIC_LAYOUT')==1 && $conf->browser->layout=='phone')||defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) fail($message)
Abort invoice creationg with a given error message.
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
table tableforfield button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.