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"));
57 $action =
GETPOST(
'action',
'aZ09');
58 $idproduct =
GETPOST(
'idproduct',
'int');
59 $place = (
GETPOST(
'place',
'aZ09') ?
GETPOST(
'place',
'aZ09') : 0);
61 $mobilepage =
GETPOST(
'mobilepage',
'alpha');
65 if (empty($user->rights->takepos->run) && !defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
69 if ((
getDolGlobalString(
'TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->layout ==
'phone') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
71 if ($_SESSION[
"takeposterminal"] ==
"") {
73 $_SESSION[
"takeposterminal"] = 1;
75 header(
"Location: ".DOL_URL_ROOT.
"/takepos/index.php");
90 header($_SERVER[
'SERVER_PROTOCOL'].
' 500 Internal Server Error',
true, 500);
96 $number =
GETPOST(
'number',
'alpha');
97 $idline =
GETPOST(
'idline',
'int');
98 $selectedline =
GETPOST(
'selectedline',
'int');
99 $desc =
GETPOST(
'desc',
'alphanohtml');
103 $invoiceid =
GETPOST(
'invoiceid',
'int');
106 if ($pay ==
'cash') {
109 if ($pay ==
'card') {
112 if ($pay ==
'cheque') {
119 $sql =
"SELECT id FROM ".MAIN_DB_PREFIX.
"c_paiement";
120 $sql .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
121 $sql .=
" AND code = '".$db->escape($paycode).
"'";
122 $resql = $db->query(
$sql);
124 $obj = $db->fetch_object($resql);
126 $paiementid = $obj->id;
132 if ($invoiceid > 0) {
133 $ret = $invoice->fetch($invoiceid);
135 $ret = $invoice->fetch(
'',
'(PROV-POS'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'') .
'-'.$place.
')');
138 $placeid = $invoice->id;
141 $constforcompanyid =
'CASHDESK_ID_THIRDPARTY'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
144 if ($invoice->socid > 0) {
145 $soc->fetch($invoice->socid);
151 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"])) {
152 if ($invoice->multicurrency_code != $_SESSION[
"takeposcustomercurrency"]) {
153 $invoice->setMulticurrencyCode($_SESSION[
"takeposcustomercurrency"]);
163 $reshook=$hookmanager->executeHooks(
'doActions', $parameters, $invoice, $action);
164 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
166 if (empty($reshook)) {
168 if ($action ==
'valid' && $user->hasRight(
'facture',
'creer')) {
172 if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) {
173 $bankaccount =
GETPOST(
'accountid',
'int');
176 $bankaccount =
getDolGlobalString(
'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION[
"takeposterminal"]);
177 } elseif ($pay ==
"CHQ") {
178 $bankaccount =
getDolGlobalString(
'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION[
"takeposterminal"]);
180 $accountname =
"CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION[
"takeposterminal"];
185 if ($bankaccount <= 0 && $pay !=
"delayed" &&
isModEnabled(
"banque")) {
186 $errormsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount"));
194 $invoice->fetch($placeid);
196 if ($invoice->total_ttc < 0) {
197 $invoice->type = $invoice::TYPE_CREDIT_NOTE;
199 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
200 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
201 $sql .=
" AND 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;
239 $conf->global->STOCK_CALCULATE_ON_BILL = 0;
241 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
244 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
245 dol_syslog(
"Validate invoice with stock change into warehouse defined into constant ".$constantforkey.
" = ".$conf->global->$constantforkey);
247 if (
isModEnabled(
'productbatch') && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) {
248 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
251 $res = $invoice->validate($user,
'', $conf->global->$constantforkey, 0, $batch_rule);
253 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
255 $res = $invoice->validate($user);
258 $langs->load(
"admin");
259 dol_htmloutput_errors($invoice->error ==
'NotConfigured' ? $langs->trans(
"NotConfigured").
' (TakePos numbering module)': $invoice->error, $invoice->errors, 1);
270 if (!$error && $res >= 0) {
271 $remaintopay = $invoice->getRemainToPay();
272 if ($remaintopay > 0) {
274 $payment->datepaye = $now;
275 $payment->fk_account = $bankaccount;
276 $payment->amounts[$invoice->id] = $amountofpayment;
283 if ($amountofpayment <= 0 || $amountofpayment > $remaintopay) {
284 $payment->amounts[$invoice->id] = $remaintopay;
287 $payment->paiementid = $paiementid;
288 $payment->num_payment = $invoice->ref;
290 if ($pay !=
"delayed") {
291 $payment->create($user);
292 $res = $payment->addPaymentToBank($user,
'payment',
'(CustomerInvoicePayment)', $bankaccount,
'',
'');
297 $remaintopay = $invoice->getRemainToPay();
303 if ($remaintopay == 0) {
304 dol_syslog(
"Invoice is paid, so we set it to status Paid");
305 $result = $invoice->setPaid($user);
310 $invoice->setPaymentMethods($paiementid);
312 dol_syslog(
"Invoice is not paid, remain to pay = ".$remaintopay);
319 if ($action ==
'creditnote' && $user->hasRight(
'facture',
'creer')) {
320 $creditnote =
new Facture($db);
321 $creditnote->socid = $invoice->socid;
323 $creditnote->module_source =
'takepos';
324 $creditnote->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
326 $creditnote->fk_facture_source = $placeid;
327 $creditnote->remise_absolue = $invoice->remise_absolue;
328 $creditnote->remise_percent = $invoice->remise_percent;
329 $creditnote->create($user);
331 foreach ($invoice->lines as $line) {
333 if (method_exists($line,
'fetch_optionals')) {
335 $line->fetch_optionals();
338 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
343 if (!empty($invoice->situation_counter)) {
344 $source_fk_prev_id = $line->fk_prev_id;
345 $line->fk_prev_id = $line->id;
346 if (!empty($invoice->tab_previous_situation_invoice)) {
349 $tab_jumped_credit_notes = array();
350 $lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
351 $searchPreviousInvoice =
true;
352 while ($searchPreviousInvoice) {
353 if ($invoice->tab_previous_situation_invoice[$lineIndex]->situation_cycle_ref || $lineIndex < 1) {
354 $searchPreviousInvoice =
false;
358 $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id;
364 $maxPrevSituationPercent = 0;
365 foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
366 if ($prevLine->id == $source_fk_prev_id) {
367 $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
370 $line->total_ht = $line->total_ht - $prevLine->total_ht;
371 $line->total_tva = $line->total_tva - $prevLine->total_tva;
372 $line->total_ttc = $line->total_ttc - $prevLine->total_ttc;
373 $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1;
374 $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2;
376 $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice;
377 $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht;
378 $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva;
379 $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc;
384 $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
389 $maxPrevSituationPercent = 0;
390 foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
391 foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) {
392 if ($prevLine->fk_prev_id == $source_fk_prev_id) {
393 $maxPrevSituationPercent = $prevLine->situation_percent;
395 $line->total_ht -= $prevLine->total_ht;
396 $line->total_tva -= $prevLine->total_tva;
397 $line->total_ttc -= $prevLine->total_ttc;
398 $line->total_localtax1 -= $prevLine->total_localtax1;
399 $line->total_localtax2 -= $prevLine->total_localtax2;
401 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
402 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
403 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
404 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
410 $line->situation_percent += $maxPrevSituationPercent;
417 $line->fk_facture = $creditnote->id;
418 $line->fk_parent_line = $fk_parent_line;
420 $line->subprice = -$line->subprice;
421 $line->pa_ht = $line->pa_ht;
422 $line->total_ht = -$line->total_ht;
423 $line->total_tva = -$line->total_tva;
424 $line->total_ttc = -$line->total_ttc;
425 $line->total_localtax1 = -$line->total_localtax1;
426 $line->total_localtax2 = -$line->total_localtax2;
428 $line->multicurrency_subprice = -$line->multicurrency_subprice;
429 $line->multicurrency_total_ht = -$line->multicurrency_total_ht;
430 $line->multicurrency_total_tva = -$line->multicurrency_total_tva;
431 $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
433 $result = $line->insert(0, 1);
435 $creditnote->lines[] = $line;
438 if ($result > 0 && $line->product_type == 9) {
439 $fk_parent_line = $result;
442 $creditnote->update_price(1);
444 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.$_SESSION[
"takeposterminal"];
445 if (
isModEnabled(
'stock') && $conf->global->$constantforkey !=
"1") {
446 $savconst = $conf->global->STOCK_CALCULATE_ON_BILL;
447 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
448 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
449 dol_syslog(
"Validate invoice with stock change into warehouse defined into constant ".$constantforkey.
" = ".$conf->global->$constantforkey);
451 if (
isModEnabled(
'productbatch') && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) {
452 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
455 $res = $creditnote->validate($user,
'', $conf->global->$constantforkey, 0, $batch_rule);
456 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
458 $res = $creditnote->validate($user);
462 if ($action ==
'history' || $action ==
'creditnote') {
463 if ($action ==
'creditnote') {
464 $placeid = $creditnote->id;
466 $placeid = (int)
GETPOST(
'placeid',
'int');
469 $invoice->fetch($placeid);
473 if (($action ==
"addline" || $action ==
"freezone") && $placeid == 0) {
475 $invoice->date =
dol_now(
'tzuserrel');
476 $invoice->module_source =
'takepos';
477 $invoice->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
478 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] : $conf->entity;
480 if ($invoice->socid <= 0) {
481 $langs->load(
'errors');
485 $placeid = $invoice->create($user);
489 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture set ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")' where rowid = ".((int) $placeid);
494 if ($action ==
"addline") {
496 $prod->fetch($idproduct);
499 $customer->fetch($invoice->socid);
501 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
504 $price = $datapriceofproduct[
'pu_ht'];
505 $price_ttc = $datapriceofproduct[
'pu_ttc'];
507 $price_base_type = empty($datapriceofproduct[
'price_base_type']) ?
'HT' : $datapriceofproduct[
'price_base_type'];
508 $tva_tx = $datapriceofproduct[
'tva_tx'];
509 $tva_npr = $datapriceofproduct[
'tva_npr'];
512 $localtax1_tx =
get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
513 $localtax2_tx =
get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
515 if (!empty($conf->global->TAKEPOS_SUPPLEMENTS)) {
516 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
518 $categories = $cat->containing($idproduct,
'product');
519 $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories,
'id')));
520 if ($found !==
false) {
521 $sql =
"SELECT fk_parent_line FROM ".MAIN_DB_PREFIX.
"facturedet where rowid=$selectedline";
522 $resql = $db->query(
$sql);
523 $row = $db->fetch_array($resql);
524 if ($row[0] ==
null) {
525 $parent_line = $selectedline;
527 $parent_line = $row[0];
534 if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT)) {
535 foreach ($invoice->lines as $line) {
536 if ($line->product_ref == $prod->ref) {
537 if ($line->special_code==4)
continue;
538 $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);
542 $idoflineadded = $line->id;
548 if ($idoflineadded <= 0) {
549 $invoice->fetch_thirdparty();
550 $array_options = array();
552 $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);
555 if (isset($conf->global->MARGIN_TYPE)) {
556 if ($conf->global->MARGIN_TYPE ==
'pmp' && !empty($prod->pmp)) {
557 $line[
'fk_fournprice'] =
null;
558 $line[
'pa_ht'] = $prod->pmp;
559 } elseif ($conf->global->MARGIN_TYPE ==
'costprice' && !empty($prod->cost_price)) {
560 $line[
'fk_fournprice'] =
null;
561 $line[
'pa_ht'] = $prod->cost_price;
564 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
566 if ($pf->find_min_price_product_fournisseur($idproduct, $qty) > 0) {
567 $line[
'fk_fournprice'] = $pf->product_fourn_price_id;
568 $line[
'pa_ht'] = $pf->fourn_unitprice_with_discount;
570 $line[
'pa_ht'] += $pf->fourn_charges / $pf->fourn_qty;
576 $parameters = array(
'prod' => $prod,
'line' => $line);
577 $reshook=$hookmanager->executeHooks(
'completeTakePosAddLine', $parameters, $invoice, $action);
578 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
581 if (empty($reshook)) {
582 if (!empty($hookmanager->resArray)) {
583 $line = $hookmanager->resArray;
586 $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);
589 if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
590 $CUSTOMER_DISPLAY_line1 = $prod->label;
591 $CUSTOMER_DISPLAY_line2 =
price($price_ttc);
595 $invoice->fetch($placeid);
598 if ($action ==
"freezone") {
600 $customer->fetch($invoice->socid);
602 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
604 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
612 $localtax1_tx =
get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
613 $localtax2_tx =
get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
615 $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 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,
null,
'',
'', 0, 100,
'',
null, 0);
616 $invoice->fetch($placeid);
619 if ($action ==
"addnote") {
620 $desc =
GETPOST(
'addnote',
'alpha');
622 $invoice->update_note($desc,
'_public');
623 }
else foreach ($invoice->lines as $line) {
624 if ($line->id == $idline) {
625 $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);
628 $invoice->fetch($placeid);
631 if ($action ==
"deleteline") {
632 if ($idline > 0 and $placeid > 0) {
633 $invoice->deleteline($idline);
634 $invoice->fetch($placeid);
635 } elseif ($placeid > 0) {
636 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facturedet where fk_facture = ".((int) $placeid).
" ORDER BY rowid DESC";
637 $resql = $db->query(
$sql);
638 $row = $db->fetch_array($resql);
639 $deletelineid = $row[0];
640 $invoice->deleteline($deletelineid);
641 $invoice->fetch($placeid);
643 if (count($invoice->lines) == 0) {
644 $invoice->delete($user);
645 header(
"Location: ".DOL_URL_ROOT.
"/takepos/invoice.php");
651 if ($action ==
"delete") {
654 $result = $invoice->fetch($placeid);
661 foreach ($invoice->lines as $line) {
662 $tmpres = $invoice->deleteline($line->id);
669 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture";
670 $varforconst =
'CASHDESK_ID_THIRDPARTY'.$_SESSION[
"takeposterminal"];
671 $sql .=
" SET fk_soc = ".((int) $conf->global->$varforconst).
", ";
673 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
674 $sql .=
" AND ref = '(PROV-POS".$db->escape($_SESSION[
"takeposterminal"].
"-".$place).
")'";
675 $resql1 = $db->query(
$sql);
677 if ($resdeletelines && $resql1) {
683 $invoice->fetch($placeid);
688 if ($action ==
"updateqty") {
689 foreach ($invoice->lines as $line) {
690 if ($line->id == $idline) {
691 if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code ==
"4")) {
694 $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);
699 $invoice->fetch($placeid);
702 if ($action ==
"updateprice") {
704 $customer->fetch($invoice->socid);
706 foreach ($invoice->lines as $line) {
707 if ($line->id == $idline) {
709 $prod->fetch($line->fk_product);
710 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
711 $price_min = $datapriceofproduct[
'price_min'];
712 $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
713 $pu_ht =
price2num($number / (1 + ($line->tva_tx / 100)),
'MU');
715 if ($usercanproductignorepricemin && (!empty($price_min) && (
price2num($pu_ht) * (1 -
price2num($line->remise_percent) / 100) <
price2num($price_min)))) {
716 $langs->load(
"products");
720 if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code ==
"4")) {
723 $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);
725 $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);
732 $invoice->fetch($placeid);
735 if ($action ==
"updatereduction") {
737 $customer->fetch($invoice->socid);
739 foreach ($invoice->lines as $line) {
740 if ($line->id == $idline) {
741 dol_syslog(
"updatereduction Process line ".$line->id.
' to apply discount of '.$number.
'%');
744 $prod->fetch($line->fk_product);
746 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
747 $price_min = $datapriceofproduct[
'price_min'];
748 $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
750 $pu_ht =
price2num($line->subprice / (1 + ($line->tva_tx / 100)),
'MU');
753 if ($usercanproductignorepricemin && (!empty($price_min) && (
price2num($line->subprice) * (1 -
price2num($number) / 100) <
price2num($price_min)))) {
754 $langs->load(
"products");
757 if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code ==
"4")) {
760 $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);
767 $invoice->fetch($placeid);
768 } elseif ($action ==
'update_reduction_global') {
769 foreach ($invoice->lines as $line) {
770 $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);
773 $invoice->fetch($placeid);
776 if ($action ==
"order" and $placeid != 0) {
777 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
778 if ($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") {
779 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolreceiptprinter.class.php';
783 $sql =
"SELECT label FROM ".MAIN_DB_PREFIX.
"takepos_floor_tables where rowid=".((int) $place);
784 $resql = $db->query(
$sql);
785 $row = $db->fetch_object($resql);
786 $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>';
787 $footerorder =
'</tbody></table>'.dol_print_date(
dol_now(),
'dayhour').
'<br></html>';
788 $order_receipt_printer1 =
"";
789 $order_receipt_printer2 =
"";
790 $order_receipt_printer3 =
"";
791 $catsprinter1 = explode(
';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1);
792 $catsprinter2 = explode(
';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2);
793 $catsprinter3 = explode(
';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3);
795 foreach ($invoice->lines as $line) {
796 if ($line->special_code ==
"4") {
800 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT,
'id');
801 $result = array_intersect($catsprinter1, $existing);
802 $count = count($result);
803 if (!$line->fk_product) {
808 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='1' where rowid=".$line->id;
810 $order_receipt_printer1 .=
'<tr><td class="left">';
811 if ($line->fk_product) {
812 $order_receipt_printer1 .= $line->product_label;
814 $order_receipt_printer1 .= $line->description;
816 $order_receipt_printer1 .=
'</td><td class="right">'.$line->qty;
817 if (!empty($line->array_options[
'options_order_notes'])) {
818 $order_receipt_printer1 .=
"<br>(".$line->array_options[
'options_order_notes'].
")";
820 $order_receipt_printer1 .=
'</td></tr>';
823 if (($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") && $linestoprint > 0) {
824 $invoice->fetch($placeid);
825 $printer->orderprinter = 1;
827 echo
"var orderprinter1esc='";
828 $ret = $printer->sendToPrinter($invoice,
getDolGlobalInt(
'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION[
"takeposterminal"]),
getDolGlobalInt(
'TAKEPOS_ORDER_PRINTER1_TO_USE'.$_SESSION[
"takeposterminal"]));
831 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id;
833 $invoice->fetch($placeid);
836 foreach ($invoice->lines as $line) {
837 if ($line->special_code ==
"4") {
841 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT,
'id');
842 $result = array_intersect($catsprinter2, $existing);
843 $count = count($result);
846 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='2' where rowid=".$line->id;
848 $order_receipt_printer2 .=
'<tr>'.$line->product_label.
'<td class="right">'.$line->qty;
849 if (!empty($line->array_options[
'options_order_notes'])) {
850 $order_receipt_printer2 .=
"<br>(".$line->array_options[
'options_order_notes'].
")";
852 $order_receipt_printer2 .=
'</td></tr>';
855 if (($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") && $linestoprint > 0) {
856 $invoice->fetch($placeid);
857 $printer->orderprinter = 2;
859 echo
"var orderprinter2esc='";
860 $ret = $printer->sendToPrinter($invoice,
getDolGlobalInt(
'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION[
"takeposterminal"]),
getDolGlobalInt(
'TAKEPOS_ORDER_PRINTER2_TO_USE'.$_SESSION[
"takeposterminal"]));
863 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id;
865 $invoice->fetch($placeid);
868 foreach ($invoice->lines as $line) {
869 if ($line->special_code ==
"4") {
873 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT,
'id');
874 $result = array_intersect($catsprinter3, $existing);
875 $count = count($result);
878 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='3' where rowid=".$line->id;
880 $order_receipt_printer3 .=
'<tr>'.$line->product_label.
'<td class="right">'.$line->qty;
881 if (!empty($line->array_options[
'options_order_notes'])) {
882 $order_receipt_printer3 .=
"<br>(".$line->array_options[
'options_order_notes'].
")";
884 $order_receipt_printer3 .=
'</td></tr>';
887 if (($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") && $linestoprint > 0) {
888 $invoice->fetch($placeid);
889 $printer->orderprinter = 3;
891 echo
"var orderprinter3esc='";
892 $ret = $printer->sendToPrinter($invoice,
getDolGlobalInt(
'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION[
"takeposterminal"]),
getDolGlobalInt(
'TAKEPOS_ORDER_PRINTER3_TO_USE'.$_SESSION[
"takeposterminal"]));
895 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id;
897 $invoice->fetch($placeid);
900 $sectionwithinvoicelink =
'';
901 if ($action ==
"valid" || $action ==
"history" || $action ==
'creditnote') {
902 $sectionwithinvoicelink .=
'<!-- Section with invoice link -->'.
"\n";
903 $sectionwithinvoicelink .=
'<span style="font-size:120%;" class="center">';
904 $sectionwithinvoicelink .= $invoice->getNomUrl(1,
'', 0, 0,
'', 0, 0, -1,
'_backoffice').
" - ";
905 $remaintopay = $invoice->getRemainToPay();
906 if ($remaintopay > 0) {
907 $sectionwithinvoicelink .= $langs->trans(
'RemainToPay').
': <span class="amountremaintopay" style="font-size: unset">'.
price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
909 if ($invoice->paye) {
910 $sectionwithinvoicelink .=
'<span class="amountpaymentcomplete" style="font-size: unset">'.$langs->trans(
"Paid").
'</span>';
912 $sectionwithinvoicelink .= $langs->trans(
'BillShortStatusValidated');
915 $sectionwithinvoicelink .=
'</span><br>';
917 $sectionwithinvoicelink .=
' <a target="_blank" class="button" href="' . DOL_URL_ROOT .
'/document.php?token=' .
newToken() .
'&modulepart=facture&file=' . $invoice->ref .
'/' . $invoice->ref .
'.pdf">Invoice</a>';
919 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
920 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="TakeposConnector('.$placeid.
')">'.$langs->trans(
'PrintTicket').
'</button>';
922 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="TakeposPrinting('.$placeid.
')">'.$langs->trans(
'PrintTicket').
'</button>';
925 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="DolibarrTakeposPrinting('.$placeid.
')">'.$langs->trans(
'PrintTicket').
'</button>';
927 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="Print('.$placeid.
')">'.$langs->trans(
'PrintTicket').
'</button>';
929 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="PrintBox('.$placeid.
', \'without_details\')">'.$langs->trans(
'PrintWithoutDetails').
'</button>';
932 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="Print('.$placeid.
', 1)">'.$langs->trans(
'GiftReceipt').
'</button>';
935 if (
getDolGlobalString(
'TAKEPOS_EMAIL_TEMPLATE_INVOICE') && $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) {
936 $sectionwithinvoicelink .=
' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.
')">'.$langs->trans(
'SendTicket').
'</button>';
939 if ($remaintopay <= 0 &&
getDolGlobalString(
'TAKEPOS_AUTO_PRINT_TICKETS') && $action !=
"history") {
940 $sectionwithinvoicelink .=
'<script type="text/javascript">$("#buttonprint").click();</script>';
952 if ((
getDolGlobalString(
'TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->layout ==
'phone') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
953 $title =
'TakePOS - Dolibarr '.DOL_VERSION;
954 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
955 $title =
'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
957 $head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
958 <meta name="apple-mobile-web-app-capable" content="yes">
959 <meta name="mobile-web-app-capable" content="yes">
960 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
962 '/takepos/css/pos.css.php',
964 $arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
967 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
976 <script
type=
"text/javascript">
979 <?php
if ($action==
"valid") echo
"var place=0;";?>
980 var placeid=<?php echo ($placeid > 0 ? $placeid : 0); ?>;
981 $(document).ready(
function() {
982 var idoflineadded = <?php echo (empty($idoflineadded) ? 0 : $idoflineadded); ?>;
984 $(
'.posinvoiceline').click(
function(){
985 console.log(
"Click done on "+this.
id);
986 $(
'.posinvoiceline').removeClass(
"selected");
987 $(
this).addClass(
"selected");
988 if (selectedline==this.
id)
return;
989 else selectedline=this.id;
990 selectedtext=$(
'#'+selectedline).find(
"td:first").html();
992 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
993 print
'$("#phonediv1").load("auto_order.php?action=editline&token='.newToken().
'&placeid="+placeid+"&selectedline="+selectedline, function() {
1000 if (idoflineadded > 0)
1002 console.log(
"Auto select "+idoflineadded);
1003 $(
'.posinvoiceline#'+idoflineadded).click();
1007 if ($action ==
"order" && !empty($order_receipt_printer1)) {
1008 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
1012 url:
'<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php',
1013 data:
'invoice='+orderprinter1esc
1020 url:
'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
1022 print $headerorder.$order_receipt_printer1.$footerorder; ?>'
1028 if ($action ==
"order" && !empty($order_receipt_printer2)) {
1029 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
1033 url:
'<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=2',
1034 data:
'invoice='+orderprinter2esc
1041 url:
'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print2',
1043 print $headerorder.$order_receipt_printer2.$footerorder; ?>'
1049 if ($action ==
"order" && !empty($order_receipt_printer3)) {
1050 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
1054 url:
'<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=3',
1055 data:
'invoice='+orderprinter3esc
1062 if ($action ==
"search" || $action ==
"valid") {
1064 parent.setFocusOnSearchField();
1069 if ($action ==
"temp" && !empty($ticket_printer1)) {
1073 url:
'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
1075 print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>'
1080 if ($action ==
"search") {
1082 $(
'#search').focus();
1090 function SendTicket(
id)
1092 console.log(
"Open box to select the Print/Send form");
1093 $.colorbox({href:
"send.php?facid="+id, width:
"70%", height:
"30%", transition:
"none", iframe:
"true", title:
'<?php echo dol_escape_js($langs->trans("SendTicket")); ?>'});
1097 function PrintBox(
id, action) {
1098 console.log(
"Open box before printing");
1099 $.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
"); ?>"});
1103 function Print(
id, gift){
1104 console.log(
"Call Print() to generate the receipt.");
1105 $.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")); ?>'});
1109 function TakeposPrinting(
id){
1111 console.log(
"TakeposPrinting" +
id);
1112 $.get(
"receipt.php?facid="+
id,
function(data, status) {
1113 receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,
'');
1116 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1123 function TakeposConnector(
id){
1124 console.log(
"TakeposConnector" +
id);
1125 $.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) {
1128 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php',
1129 data:
'invoice='+data
1135 function DolibarrTakeposPrinting(
id) {
1136 console.log(
"DolibarrTakeposPrinting Printing invoice ticket " +
id)
1139 data: { token:
'<?php echo currentToken(); ?>' },
1140 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=printinvoiceticket&token='.newToken().'&term='.urlencode(isset($_SESSION["takeposterminal
"]) ? $_SESSION["takeposterminal
"] : '').'&id='; ?>" + id,
1145 function CreditNote() {
1146 $(
"#poslines").load(
"invoice.php?action=creditnote&token=<?php echo newToken() ?>&invoiceid="+placeid,
function() { });
1150 function SetNote() {
1151 $(
"#poslines").load(
"invoice.php?action=addnote&token=<?php echo newToken() ?>&invoiceid="+placeid+
"&idline="+selectedline, {
"addnote": $(
"#textinput").val() });
1156 $( document ).ready(
function() {
1157 console.log(
"Set customer info and sales in header placeid=<?php echo $placeid; ?> status=<?php echo $invoice->statut; ?>");
1160 $s = $langs->trans(
"Customer");
1161 if ($invoice->id > 0 && ($invoice->socid !=
getDolGlobalString($constforcompanyid))) {
1166 $(
"#customerandsales").html(
'');
1167 $(
"#shoppingcart").html(
'');
1169 $(
"#customerandsales").append(
'<a class="valignmiddle tdoverflowmax125 minwidth100" id="customer" onclick="Customer();" title="<?php print dol_escape_js(dol_escape_htmltag($s)); ?>"><span class="fas fa-building paddingrightonly"></span><?php print dol_escape_js($s); ?></a>');
1172 $sql =
"SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX.
"facture";
1173 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
1174 if (empty($conf->global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) {
1176 $sql .=
" AND ref LIKE '(PROV-POS".$db->escape(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'').
"-0%'";
1179 $sql .=
" AND pos_source = '".$db->escape($_SESSION[
"takeposterminal"]).
"'";
1180 $sql .=
" AND module_source = 'takepos'";
1183 $sql .= $db->order(
'datec',
'ASC');
1184 $resql = $db->query(
$sql);
1187 while ($obj = $db->fetch_object($resql)) {
1188 echo
'$("#shoppingcart").append(\'';
1189 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=\\\'';
1190 $num_sale = str_replace(
")",
"", str_replace(
"(PROV-POS".$_SESSION[
"takeposterminal"].
"-",
"", $obj->ref));
1192 if (str_replace(
"-",
"", $num_sale) > $max_sale) {
1193 $max_sale = str_replace(
"-",
"", $num_sale);
1195 echo
'\\\'; invoiceid=\\\'';
1197 echo
'\\\'; Refresh();">';
1198 if ($placeid == $obj->rowid) {
1199 echo
'<span class="basketselected">';
1201 echo
'<span class="basketnotselected">';
1203 echo
'<span class="fa fa-shopping-cart paddingright"></span>'.dol_print_date($db->jdate($obj->datec),
'%H:%M',
'tzuser');
1207 echo
'$("#shoppingcart").append(\'<a onclick="place=\\\'0-';
1209 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>\');';
1217 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1220 $constantforkey =
'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1222 if ($idwarehouse > 0) {
1223 $s =
'<span class="small">';
1225 $warehouse->fetch($idwarehouse);
1226 $s .=
'<span class="hideonsmartphone">'.$langs->trans(
"Warehouse").
'<br></span>'.$warehouse->ref;
1228 $s .=
' ('.$langs->trans(
"Closed").
')';
1231 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1232 print
'$("#infowarehouse").css("display", "inline-block");';
1234 $s =
'<span class="small hideonsmartphone">';
1235 $s .= $langs->trans(
"StockChangeDisabled").
'<br>'.$langs->trans(
"NoWarehouseDefinedForTerminal");
1237 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1238 if (!empty($conf->dol_optimize_smallscreen)) {
1239 print
'$("#infowarehouse").css("display", "none");';
1243 $s =
'<span class="small hideonsmartphone">'.$langs->trans(
"StockChangeDisabled").
'</span>';
1244 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1245 if (!empty($conf->dol_optimize_smallscreen)) {
1246 print
'$("#infowarehouse").css("display", "none");';
1254 if (
isModEnabled(
'adherent') && $invoice->socid > 0 && $invoice->socid != $conf->global->$constforcompanyid) {
1255 $s =
'<span class="small">';
1256 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1257 $langs->load(
"members");
1258 $s .= $langs->trans(
"Member").
': ';
1260 $result = $adh->fetch(
'',
'', $invoice->socid);
1262 $adh->ref = $adh->getFullName($langs);
1266 $s .= $adh->getFullName($langs);
1267 $s .=
' - '.$adh->type;
1268 if ($adh->datefin) {
1269 $s .=
'<br>'.$langs->trans(
"SubscriptionEndDate").
': '.
dol_print_date($adh->datefin,
'day');
1270 if ($adh->hasDelay()) {
1271 $s .=
" ".img_warning($langs->trans(
"Late"));
1274 $s .=
'<br>'.$langs->trans(
"SubscriptionNotReceived");
1275 if ($adh->statut > 0) {
1276 $s .=
" ".img_warning($langs->trans(
"Late"));
1283 $s .=
'<br>'.$langs->trans(
"ThirdpartyNotLinkedToMember");
1288 $(
"#moreinfo").html(
'<?php print dol_escape_js($s); ?>');
1294 if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
1295 echo
"function CustomerDisplay(){";
1296 echo
"var line1='".$CUSTOMER_DISPLAY_line1.
"'.substring(0,20);";
1297 echo
"line1=line1.padEnd(20);";
1298 echo
"var line2='".$CUSTOMER_DISPLAY_line2.
"'.substring(0,20);";
1299 echo
"line2=line2.padEnd(20);";
1302 data: { text: line1+line2 },
1303 url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER').
"/display/index.php',
1314 if (!empty($conf->use_javascript_ajax)) {
1315 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
1316 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.
'"></script>'.
"\n";
1319 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";
1320 print
'<div class="div-table-responsive-no-min invoice">';
1321 print
'<table id="tablelines" class="noborder noshadow postablelines centpercent">';
1322 if ($sectionwithinvoicelink && ($mobilepage ==
"invoice" || $mobilepage ==
"")) {
1323 if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
1324 print
'<tr><td colspan="5">'.$sectionwithinvoicelink.
'</td></tr>';
1326 print
'<tr><td colspan="4">'.$sectionwithinvoicelink.
'</td></tr>';
1329 print
'<tr class="liste_titre nodrag nodrop">';
1330 print
'<td class="linecoldescription">';
1332 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1333 print
'<!-- hidden var used by some js functions -->';
1334 print
'<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.
'">';
1335 print
'<input type="hidden" name="thirdpartyid" id="thirdpartyid" value="'.$invoice->socid.
'">';
1338 $sql =
"SELECT floor, label FROM ".MAIN_DB_PREFIX.
"takepos_floor_tables where rowid=".((int) $place);
1339 $resql = $db->query(
$sql);
1340 $obj = $db->fetch_object($resql);
1342 $label = $obj->label;
1343 $floor = $obj->floor;
1345 if ($mobilepage ==
"invoice" || $mobilepage ==
"") {
1348 print
'<span class="opacitymedium">'.$langs->trans(
'Place').
"</span> <b>".(empty($label) ?
'?' : $label).
"</b><br>";
1349 print
'<span class="opacitymedium">'.$langs->trans(
'Floor').
"</span> <b>".(empty($floor) ?
'?' : $floor).
"</b>";
1350 } elseif (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1352 } elseif ($mobilepage ==
"cats") {
1353 print $langs->trans(
'Category');
1354 } elseif ($mobilepage ==
"products") {
1355 print $langs->trans(
'Label');
1358 print $langs->trans(
"Products");
1363 $parameters=array();
1364 $reshook=$hookmanager->executeHooks(
'completeTakePosInvoiceHeader', $parameters, $invoice, $action);
1365 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1366 print $hookmanager->resPrint;
1368 if (empty($_SESSION[
"basiclayout"]) || $_SESSION[
"basiclayout"] != 1) {
1369 print
'<td class="linecolqty right">'.$langs->trans(
'ReductionShort').
'</td>';
1370 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
1372 print
'<td class="linecolht right nowraponall">';
1373 print
'<span class="opacitymedium small">' . $langs->trans(
'TotalHTShort') .
'</span><br>';
1375 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1376 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>';
1377 if (
isModEnabled(
'multicurrency') && $_SESSION[
"takeposcustomercurrency"] !=
"" && $conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
1379 include_once DOL_DOCUMENT_ROOT .
'/multicurrency/class/multicurrency.class.php';
1381 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
1382 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>';
1388 print
'<td class="linecolht right nowraponall">';
1389 print
'<span class="opacitymedium small">'.$langs->trans(
'TotalTTCShort').
'</span><br>';
1391 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1392 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>';
1393 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"]) && $conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
1395 include_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
1397 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
1398 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>';
1403 } elseif ($mobilepage ==
"invoice") {
1404 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
1409 if (!empty($_SESSION[
"basiclayout"]) && $_SESSION[
"basiclayout"] == 1) {
1410 if ($mobilepage ==
"cats") {
1411 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1413 $categories = $categorie->get_full_arbo(
'product');
1415 foreach ($categories as $row) {
1416 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1417 $htmlforlines .=
'<div class="leftcat';
1419 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline';
1421 $htmlforlines .=
'" onclick="LoadProducts('.$row[
'id'].
');">';
1422 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1423 $htmlforlines .=
'<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=cat&query=cat&id='.$row[
'id'].
'"><br>';
1425 $htmlforlines .=
'<td class="left">';
1427 $htmlforlines .= $row[
'label'];
1428 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1429 $htmlforlines .=
'</div>'.
"\n";
1431 $htmlforlines .=
'</td></tr>'.
"\n";
1434 $htmlforlines .=
'</table>';
1435 $htmlforlines .=
'</table>';
1436 print $htmlforlines;
1439 if ($mobilepage ==
"products") {
1440 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1442 $catid =
GETPOST(
'catid',
'int');
1443 $result = $object->fetch($catid);
1444 $prods = $object->getObjectsInCateg(
"product");
1446 foreach ($prods as $row) {
1447 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1448 $htmlforlines .=
'<div class="leftcat';
1450 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline';
1452 $htmlforlines .=
'" onclick="AddProduct(\''.$place.
'\',
'.$row->id.')
">';
1453 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1454 $htmlforlines .= '<img class="imgwrapper
" width="33%
" src="'.DOL_URL_ROOT.'/takepos/
public/auto_order.php?genimg=pro&query=pro&
id=
'.$row->id.'"><br>';
1455 $htmlforlines .= $row->label.' '.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency);
1456 $htmlforlines .= '</div>'."\n
";
1458 $htmlforlines .= '<td class="left
">';
1459 $htmlforlines .= $row->label;
1460 $htmlforlines .= '<div class="right
">'.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).'</div>';
1461 $htmlforlines .= '</tr>'."\n
";
1464 $htmlforlines .= '</table>';
1465 print $htmlforlines;
1468 if ($mobilepage == "places
") {
1469 $sql = "SELECT
rowid, entity, label, leftpos, toppos, floor FROM
".MAIN_DB_PREFIX."takepos_floor_tables
";
1470 $resql = $db->query($sql);
1473 while ($row = $db->fetch_array($resql)) {
1475 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
1476 $htmlforlines .= '" onclick="LoadPlace(\
''.$row[
'label'].
'\')
">';
1477 $htmlforlines .= '<td class="left
">';
1478 $htmlforlines .= $row['label'];
1479 $htmlforlines .= '</td>';
1480 $htmlforlines .= '</tr>'."\n
";
1482 $htmlforlines .= '</table>';
1483 print $htmlforlines;
1488 //In Phone basic layout hide some content depends situation
1489 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1 && $mobilepage != "invoice
" && $action != "order
") {
1493 if (is_array($invoice->lines) && count($invoice->lines)) {
1494 print '<!-- invoice.php show lines of invoices -->'."\n
";
1495 $tmplines = array_reverse($invoice->lines);
1496 $htmlsupplements = array();
1497 foreach ($tmplines as $line) {
1498 if ($line->fk_parent_line != false) {
1499 $htmlsupplements[$line->fk_parent_line] .= '<tr class="drag drop oddeven posinvoiceline
';
1500 if ($line->special_code == "4") {
1501 $htmlsupplements[$line->fk_parent_line] .= ' order
';
1503 $htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'"';
1504 if ($line->special_code == "4
") {
1505 $htmlsupplements[$line->fk_parent_line] .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
1507 $htmlsupplements[$line->fk_parent_line] .= '>';
1508 $htmlsupplements[$line->fk_parent_line] .= '<td class="left
">';
1509 $htmlsupplements[$line->fk_parent_line] .= img_picto('', 'rightarrow');
1510 if ($line->product_label) {
1511 $htmlsupplements[$line->fk_parent_line] .= $line->product_label;
1513 if ($line->product_label && $line->desc) {
1514 $htmlsupplements[$line->fk_parent_line] .= '<br>';
1516 if ($line->product_label != $line->desc) {
1517 $firstline = dolGetFirstLineOfText($line->desc);
1518 if ($firstline != $line->desc) {
1519 $htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
1521 $htmlsupplements[$line->fk_parent_line] .= $line->desc;
1524 $htmlsupplements[$line->fk_parent_line] .= '</td>';
1526 // complete line by hook
1527 $parameters=array('line' => $line);
1528 $reshook=$hookmanager->executeHooks('completeTakePosInvoiceParentLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
1529 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1530 $htmlsupplements[$line->fk_parent_line] .= $hookmanager->resPrint;
1532 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
1533 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.vatrate($line->remise_percent, true).'</td>';
1534 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.$line->qty.'</td>';
1535 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.price($line->total_ttc).'</td>';
1537 $htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n
";
1542 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
1543 if ($line->special_code == "4") {
1544 $htmlforlines .= ' order
';
1546 $htmlforlines .= '" id="'.$line->id.'"';
1547 if ($line->special_code == "4
") {
1548 $htmlforlines .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
1550 $htmlforlines .= '>';
1551 $htmlforlines .= '<td class="left
">';
1552 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
1553 $htmlforlines .= '<span class="phoneqty
">'.$line->qty."</span> x
";
1555 if (isset($line->product_type)) {
1556 if (empty($line->product_type)) {
1557 $htmlforlines .= img_object('', 'product').' ';
1559 $htmlforlines .= img_object('', 'service').' ';
1562 if (empty($conf->global->TAKEPOS_SHOW_N_FIRST_LINES)) {
1564 if ($line->product_ref) {
1565 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
1566 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
1567 if ($line->product_label != $line->desc) {
1569 $tooltiptext .= '<br>';
1571 $tooltiptext .= $line->desc;
1574 if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
1575 $htmlforlines .= $form->textwithpicto($line->product_label ? '<b>' . $line->product_ref . '</b> - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
1577 $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
1580 if ($line->product_label) {
1581 $htmlforlines .= $line->product_label;
1583 if ($line->product_label != $line->desc) {
1584 if ($line->product_label && $line->desc) {
1585 $htmlforlines .= '<br>';
1587 $firstline = dolGetFirstLineOfText($line->desc, $conf->global->TAKEPOS_SHOW_N_FIRST_LINES);
1588 if ($firstline != $line->desc) {
1589 $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
1591 $htmlforlines .= $line->desc;
1595 if (!empty($line->array_options['options_order_notes'])) {
1596 $htmlforlines .= "<br>(
".$line->array_options['options_order_notes'].")
";
1598 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
1599 $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>';
1601 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
1603 $moreinfo .= $langs->transcountry("TotalHT
", $mysoc->country_code).': '.price($line->total_ht);
1604 if ($line->vat_src_code) {
1605 $moreinfo .= '<br>'.$langs->trans("VATCode
").': '.$line->vat_src_code;
1607 $moreinfo .= '<br>'.$langs->transcountry("TotalVAT
", $mysoc->country_code).': '.price($line->total_tva);
1608 $moreinfo .= '<br>'.$langs->transcountry("TotalLT1
", $mysoc->country_code).': '.price($line->total_localtax1);
1609 $moreinfo .= '<br>'.$langs->transcountry("TotalLT2
", $mysoc->country_code).': '.price($line->total_localtax2);
1610 $moreinfo .= '<hr>';
1611 $moreinfo .= $langs->transcountry("TotalTTC
", $mysoc->country_code).': '.price($line->total_ttc);
1612 //$moreinfo .= $langs->trans("TotalHT
").': '.$line->total_ht;
1613 if ($line->date_start || $line->date_end) {
1614 $htmlforlines .= '<br><div class="clearboth nowraponall
">'.get_date_range($line->date_start, $line->date_end).'</div>';
1616 $htmlforlines .= '</td>';
1618 // complete line by hook
1619 $parameters=array('line' => $line);
1620 $reshook=$hookmanager->executeHooks('completeTakePosInvoiceLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
1621 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1622 $htmlforlines .= $hookmanager->resPrint;
1624 $htmlforlines .= '<td class="right
">'.vatrate($line->remise_percent, true).'</td>';
1625 $htmlforlines .= '<td class="right
">';
1626 if (isModEnabled('stock') && !empty($user->rights->stock->mouvement->lire)) {
1627 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
1628 if (!empty($conf->global->$constantforkey) && $line->fk_product > 0 && empty($conf->global->TAKEPOS_HIDE_STOCK_ON_LINE)) {
1629 $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp
";
1630 $sql .= " FROM
".MAIN_DB_PREFIX."entrepot as e,
";
1631 $sql .= " ".MAIN_DB_PREFIX."product_stock as ps
";
1632 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product
";
1633 $sql .= " WHERE ps.reel != 0
";
1634 $sql .= " AND ps.fk_entrepot =
".((int) $conf->global->$constantforkey);
1635 $sql .= " AND e.entity IN (
".getEntity('stock').")
";
1636 $sql .= " AND ps.fk_product =
".((int) $line->fk_product);
1637 $resql = $db->query($sql);
1639 $obj = $db->fetch_object($resql);
1640 $stock_real = price2num($obj->reel, 'MS');
1641 $htmlforlines .= $line->qty;
1642 if ($line->qty && $line->qty > $stock_real) {
1643 $htmlforlines .= '<span style="color: var(--amountremaintopaycolor)
">';
1645 $htmlforlines .= ' <span class="posstocktoolow
">('.$langs->trans("Stock
").' '.$stock_real.')</span>';
1646 if ($line->qty && $line->qty > $stock_real) {
1647 $htmlforlines .= "</span>
";
1650 dol_print_error($db);
1653 $htmlforlines .= $line->qty;
1656 $htmlforlines .= $line->qty;
1659 $htmlforlines .= '</td>';
1660 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
1661 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
1662 $htmlforlines .= price($line->total_ht, 1, '', 1, -1, -1, $conf->currency);
1663 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
1664 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
1665 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
1666 $multicurrency = new MultiCurrency($db);
1667 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
1668 $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>';
1670 $htmlforlines .= '</td>';
1672 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
1673 $htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency);
1674 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
1675 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
1676 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
1677 $multicurrency = new MultiCurrency($db);
1678 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
1679 $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>';
1681 $htmlforlines .= '</td>';
1683 $htmlforlines .= '</tr>'."\n
";
1684 $htmlforlines .= empty($htmlsupplements[$line->id]) ? '' : $htmlsupplements[$line->id];
1686 print $htmlforlines;
1689 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td><td></td><td></td>';
1690 if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
1695 } else { // No invoice generated yet
1696 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td><td></td><td></td>';
1698 if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
1706 if (($action == "valid
" || $action == "history
") && $invoice->type != Facture::TYPE_CREDIT_NOTE && empty($conf->global->TAKEPOS_NO_CREDITNOTE)) {
1707 print '<button id="buttonprint
" type="button" onclick="ModalBox(\
'ModalCreditNote\')">'.$langs->trans(
'CreateCreditNote').
'</button>';
1709 print
' <a target="_blank" class="button" href="' . DOL_URL_ROOT .
'/document.php?token=' .
newToken() .
'&modulepart=facture&file=' . $invoice->ref .
'/' . $invoice->ref .
'.pdf">Invoice</a>';
1714 if ($action ==
"search") {
1716 <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')).
'">
1723 if ((
getDolGlobalString(
'TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->layout ==
'phone') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1724 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_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') && $user->hasRight('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') && $user->hasRight('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)) $sql
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...
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.
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( 'CSRFCHECK_WITH_TOKEN'))
if(!defined('NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) 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.