29 if (!defined(
'NOCSRFCHECK')) { define(
'NOCSRFCHECK',
'1'); }
30 if (!defined(
'NOTOKENRENEWAL')) { define(
'NOTOKENRENEWAL',
'1'); }
31 if (!defined(
'NOREQUIREMENU')) { define(
'NOREQUIREMENU',
'1'); }
32 if (!defined(
'NOREQUIREHTML')) { define(
'NOREQUIREHTML',
'1'); }
33 if (!defined(
'NOREQUIREAJAX')) { define(
'NOREQUIREAJAX',
'1'); }
35 if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) require
'../main.inc.php';
36 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
42 $langs->loadLangs(array(
"companies",
"commercial",
"bills",
"cashdesk",
"stocks",
"banks"));
45 $action =
GETPOST(
'action',
'aZ09');
46 $idproduct =
GETPOST(
'idproduct',
'int');
47 $place = (
GETPOST(
'place',
'aZ09') ?
GETPOST(
'place',
'aZ09') : 0);
51 if (empty($user->rights->takepos->run) && !defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
60 if (($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1 && $conf->browser->layout ==
'phone') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))
63 if ($_SESSION[
"takeposterminal"] ==
"")
65 if ($conf->global->TAKEPOS_NUM_TERMINALS ==
"1") $_SESSION[
"takeposterminal"] = 1;
67 header(
"Location: ".DOL_URL_ROOT.
"/takepos/index.php");
71 $mobilepage =
GETPOST(
'mobilepage',
'alpha');
72 $title =
'TakePOS - Dolibarr '.DOL_VERSION;
73 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title =
'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
74 $head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
75 <meta name="apple-mobile-web-app-capable" content="yes">
76 <meta name="mobile-web-app-capable" content="yes">
77 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
79 '/takepos/css/pos.css.php',
80 '/takepos/js/jquery.colorbox-min.js'
82 $arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
83 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
94 header(
$_SERVER[
'SERVER_PROTOCOL'].
' 500 Internal Server Error',
true, 500);
100 $number =
GETPOST(
'number',
'alpha');
101 $idline =
GETPOST(
'idline',
'int');
102 $selectedline =
GETPOST(
'selectedline',
'int');
103 $desc =
GETPOST(
'desc',
'alphanohtml');
107 $invoiceid =
GETPOST(
'invoiceid',
'int');
110 if ($pay ==
'cash') $paycode =
'LIQ';
111 if ($pay ==
'card') $paycode =
'CB';
112 if ($pay ==
'cheque') $paycode =
'CHQ';
115 $sql =
"SELECT id FROM ".MAIN_DB_PREFIX.
"c_paiement";
116 $sql .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
117 $sql .=
" AND code = '".$db->escape($paycode).
"'";
118 $resql = $db->query($sql);
119 $obj = $db->fetch_object(
$resql);
120 $paiementid = $obj->id;
125 $ret = $invoice->fetch($invoiceid);
127 $ret = $invoice->fetch(
'',
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-'.$place.
')');
131 $placeid = $invoice->id;
134 $constforcompanyid =
'CASHDESK_ID_THIRDPARTY'.$_SESSION[
"takeposterminal"];
137 if ($invoice->socid > 0) $soc->fetch($invoice->socid);
138 else $soc->fetch($conf->global->$constforcompanyid);
146 if ($action ==
'valid' && $user->rights->facture->creer)
151 if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) {
152 $bankaccount =
GETPOST(
'accountid',
'int');
154 if ($pay ==
"cash") $bankaccount = $conf->global->{
'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION[
"takeposterminal"]};
155 elseif ($pay ==
"card") $bankaccount = $conf->global->{
'CASHDESK_ID_BANKACCOUNT_CB'.$_SESSION[
"takeposterminal"]};
156 elseif ($pay ==
"cheque") $bankaccount = $conf->global->{
'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION[
"takeposterminal"]};
158 $accountname =
"CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION[
"takeposterminal"];
159 $bankaccount = $conf->global->$accountname;
163 if ($bankaccount <= 0 && $pay !=
"delayed") {
164 $errormsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount"));
172 $invoice->fetch($placeid);
174 if ($invoice->total_ttc < 0) {
175 $invoice->type = $invoice::TYPE_CREDIT_NOTE;
177 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture WHERE";
178 $sql .=
" fk_soc = ".((int) $invoice->socid);
179 $sql .=
" AND type <> ".Facture::TYPE_CREDIT_NOTE;
180 $sql .=
" AND fk_statut >= ".$invoice::STATUS_VALIDATED;
181 $sql .=
" ORDER BY rowid DESC";
183 $resql = $db->query($sql);
185 $obj = $db->fetch_object(
$resql);
186 $fk_source = $obj->rowid;
187 if ($fk_source == null) {
188 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
191 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
193 $invoice->fk_facture_source = $fk_source;
194 $invoice->update($user);
204 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.$_SESSION[
"takeposterminal"];
209 if ($invoice->getRemainToPay() > 0) {
215 } elseif (count($invoice->lines) == 0) {
219 } elseif (!empty($conf->stock->enabled) && $conf->global->$constantforkey !=
"1") {
220 $savconst = $conf->global->STOCK_CALCULATE_ON_BILL;
221 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
223 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
224 dol_syslog(
"Validate invoice with stock change into warehouse defined into constant ".$constantforkey.
" = ".$conf->global->$constantforkey);
226 if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) {
227 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
230 $res = $invoice->validate($user,
'', $conf->global->$constantforkey, 0, $batch_rule);
232 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
234 $res = $invoice->validate($user);
248 if (!$error && $res >= 0) {
249 $remaintopay = $invoice->getRemainToPay();
250 if ($remaintopay > 0) {
252 $payment->datepaye = $now;
253 $payment->fk_account = $bankaccount;
254 $payment->amounts[$invoice->id] = $amountofpayment;
255 if ($pay ==
'cash') $payment->pos_change =
price2num(
GETPOST(
'excess',
'alpha'));
259 if ($amountofpayment == 0 || $amountofpayment > $remaintopay) $payment->amounts[$invoice->id] = $remaintopay;
261 $payment->paiementid = $paiementid;
262 $payment->num_payment = $invoice->ref;
264 if ($pay !=
"delayed") {
265 $payment->create($user);
266 $payment->addPaymentToBank($user,
'payment',
'(CustomerInvoicePayment)', $bankaccount,
'',
'');
267 $remaintopay = $invoice->getRemainToPay();
271 if ($remaintopay == 0) {
272 dol_syslog(
"Invoice is paid, so we set it to status Paid");
273 $result = $invoice->set_paid($user);
274 if ($result > 0) $invoice->paye = 1;
276 $invoice->setPaymentMethods($paiementid);
278 dol_syslog(
"Invoice is not paid, remain to pay = ".$remaintopay);
285 if ($action ==
'creditnote')
287 $creditnote =
new Facture($db);
288 $creditnote->socid = $invoice->socid;
291 $creditnote->fk_facture_source = $placeid;
292 $creditnote->remise_absolue = $invoice->remise_absolue;
293 $creditnote->remise_percent = $invoice->remise_percent;
294 $creditnote->create($user);
296 foreach ($invoice->lines as $line)
299 if (method_exists($line,
'fetch_optionals')) {
301 $line->fetch_optionals();
304 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
309 $source_fk_prev_id = $line->fk_prev_id;
310 $line->fk_prev_id = $line->id;
311 if (!empty($invoice->tab_previous_situation_invoice))
315 $tab_jumped_credit_notes = array();
316 $lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
317 $searchPreviousInvoice =
true;
318 while ($searchPreviousInvoice)
322 $searchPreviousInvoice =
false;
326 $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id;
332 $maxPrevSituationPercent = 0;
333 foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine)
335 if ($prevLine->id == $source_fk_prev_id)
337 $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
340 $line->total_ht = $line->total_ht - $prevLine->total_ht;
341 $line->total_tva = $line->total_tva - $prevLine->total_tva;
342 $line->total_ttc = $line->total_ttc - $prevLine->total_ttc;
343 $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1;
344 $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2;
346 $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice;
347 $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht;
348 $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva;
349 $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc;
354 $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
359 $maxPrevSituationPercent = 0;
360 foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
361 foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine)
363 if ($prevLine->fk_prev_id == $source_fk_prev_id)
365 $maxPrevSituationPercent = $prevLine->situation_percent;
367 $line->total_ht -= $prevLine->total_ht;
368 $line->total_tva -= $prevLine->total_tva;
369 $line->total_ttc -= $prevLine->total_ttc;
370 $line->total_localtax1 -= $prevLine->total_localtax1;
371 $line->total_localtax2 -= $prevLine->total_localtax2;
373 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
374 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
375 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
376 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
382 $line->situation_percent += $maxPrevSituationPercent;
388 $line->fk_facture = $creditnote->id;
389 $line->fk_parent_line = $fk_parent_line;
391 $line->subprice = -$line->subprice;
392 $line->pa_ht = $line->pa_ht;
393 $line->total_ht = -$line->total_ht;
394 $line->total_tva = -$line->total_tva;
395 $line->total_ttc = -$line->total_ttc;
396 $line->total_localtax1 = -$line->total_localtax1;
397 $line->total_localtax2 = -$line->total_localtax2;
399 $line->multicurrency_subprice = -$line->multicurrency_subprice;
400 $line->multicurrency_total_ht = -$line->multicurrency_total_ht;
401 $line->multicurrency_total_tva = -$line->multicurrency_total_tva;
402 $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
404 $result = $line->insert(0, 1);
406 $creditnote->lines[] = $line;
409 if ($result > 0 && $line->product_type == 9) {
410 $fk_parent_line = $result;
413 $creditnote->update_price(1);
415 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.$_SESSION[
"takeposterminal"];
416 if (!empty($conf->stock->enabled) && $conf->global->$constantforkey !=
"1") {
417 $savconst = $conf->global->STOCK_CALCULATE_ON_BILL;
418 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
419 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
420 dol_syslog(
"Validate invoice with stock change into warehouse defined into constant ".$constantforkey.
" = ".$conf->global->$constantforkey);
422 if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) {
423 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
426 $res = $creditnote->validate($user,
'', $conf->global->$constantforkey, 0, $batch_rule);
427 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
429 $res = $creditnote->validate($user);
433 if ($action ==
'history' || $action ==
'creditnote')
435 if ($action ==
'creditnote') $placeid = $creditnote->id;
436 else $placeid = (int)
GETPOST(
'placeid',
'int');
438 $invoice->fetch($placeid);
441 if (!empty($conf->multicurrency->enabled) && $_SESSION[
"takeposcustomercurrency"] !=
"") {
442 $invoice->setMulticurrencyCode($_SESSION[
"takeposcustomercurrency"]);
445 if (($action ==
"addline" || $action ==
"freezone") && $placeid == 0)
447 $invoice->socid = $conf->global->$constforcompanyid;
449 $invoice->module_source =
'takepos';
450 $invoice->pos_source = $_SESSION[
"takeposterminal"];
451 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] : $conf->entity;
453 if ($invoice->socid <= 0)
455 $langs->load(
'errors');
458 $placeid = $invoice->create($user);
463 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture set ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")' where rowid=".$placeid;
468 if ($action ==
"addline")
471 $prod->fetch($idproduct);
474 $customer->fetch($invoice->socid);
476 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
478 $price = $datapriceofproduct[
'pu_ht'];
479 $price_ttc = $datapriceofproduct[
'pu_ttc'];
481 $price_base_type = $datapriceofproduct[
'price_base_type'];
482 $tva_tx = $datapriceofproduct[
'tva_tx'];
483 $tva_npr = $datapriceofproduct[
'tva_npr'];
486 $localtax1_tx =
get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
487 $localtax2_tx =
get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
489 if (!empty($conf->global->TAKEPOS_SUPPLEMENTS))
491 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
493 $categories = $cat->containing($idproduct,
'product');
494 $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories,
'id')));
495 if ($found !==
false)
497 $sql =
"SELECT fk_parent_line FROM ".MAIN_DB_PREFIX.
"facturedet where rowid=$selectedline";
498 $resql = $db->query($sql);
499 $row = $db->fetch_array(
$resql);
500 if ($row[0] == null) $parent_line = $selectedline;
501 else $parent_line = $row[0];
506 if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT)) {
507 foreach ($invoice->lines as $line) {
508 if ($line->product_ref == $prod->ref) {
509 $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty + 1, $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);
513 $idoflineadded = $line->id;
519 if ($idoflineadded <= 0) {
520 $invoice->fetch_thirdparty();
521 $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent,
'', 0, 0, 0,
'', $price_base_type, $price_ttc, $prod->type, -1, 0,
'', 0, $parent_line, null,
'',
'', 0, 100,
'', null, 0);
524 $invoice->fetch($placeid);
527 if ($action ==
"freezone") {
529 $customer->fetch($invoice->socid);
531 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
533 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
541 $localtax1_tx =
get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
542 $localtax2_tx =
get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
544 $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0,
'', 0, 0, 0,
'',
'TTC', $number, 0, -1, 0,
'', 0, 0, null,
'',
'', 0, 100,
'', null, 0);
545 $invoice->fetch($placeid);
548 if ($action ==
"addnote") {
549 foreach ($invoice->lines as $line)
551 if ($line->id == $number)
553 $line->array_options[
'order_notes'] = $desc;
554 $result = $invoice->updateline($line->id, $line->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);
557 $invoice->fetch($placeid);
560 if ($action ==
"deleteline") {
561 if ($idline > 0 and $placeid > 0) {
562 $invoice->deleteline($idline);
563 $invoice->fetch($placeid);
564 } elseif ($placeid > 0) {
565 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facturedet where fk_facture = ".((int) $placeid).
" ORDER BY rowid DESC";
566 $resql = $db->query($sql);
567 $row = $db->fetch_array(
$resql);
568 $deletelineid = $row[0];
569 $invoice->deleteline($deletelineid);
570 $invoice->fetch($placeid);
572 if (count($invoice->lines) == 0) {
573 $invoice->delete($user);
574 header(
"Location: ".DOL_URL_ROOT.
"/takepos/invoice.php");
580 if ($action ==
"delete") {
583 $result = $invoice->fetch($placeid);
591 foreach ($invoice->lines as $line) {
592 $tmpres = $invoice->deleteline($line->id);
599 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture";
600 $sql .=
" SET fk_soc=".$conf->global->{
'CASHDESK_ID_THIRDPARTY'.$_SESSION[
"takeposterminal"]}.
", ";
601 $sql .=
" datec = '".$db->idate(
dol_now()).
"'";
602 $sql .=
" WHERE ref='(PROV-POS".$db->escape($_SESSION[
"takeposterminal"].
"-".$place).
")'";
603 $resql1 = $db->query($sql);
605 if ($resdeletelines && $resql1) {
611 $invoice->fetch($placeid);
616 if ($action ==
"updateqty")
618 foreach ($invoice->lines as $line)
620 if ($line->id == $idline)
622 $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);
626 $invoice->fetch($placeid);
629 if ($action ==
"updateprice")
631 foreach ($invoice->lines as $line)
633 if ($line->id == $idline)
636 $prod->fetch($line->fk_product);
638 $customer->fetch($invoice->socid);
639 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
640 $price_min = $datapriceofproduct[
'price_min'];
641 $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
642 $pu_ht =
price2num($number / (1 + ($line->tva_tx / 100)),
'MU');
644 if ($usercanproductignorepricemin && (!empty($price_min) && (
price2num($pu_ht) * (1 -
price2num($line->remise_percent) / 100) <
price2num($price_min))))
646 echo $langs->trans(
"CantBeLessThanMinPrice");
647 }
else $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);
650 $invoice->fetch($placeid);
653 if ($action ==
"updatereduction")
655 foreach ($invoice->lines as $line)
657 if ($line->id == $idline)
660 $prod->fetch($line->fk_product);
662 $customer->fetch($invoice->socid);
663 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
664 $price_min = $datapriceofproduct[
'price_min'];
665 $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
666 $pu_ht =
price2num($line->multicurrency_subprice / (1 + ($line->tva_tx / 100)),
'MU');
668 if ($usercanproductignorepricemin && (!empty($price_min) && (
price2num($line->multicurrency_subprice) * (1 -
price2num($number) / 100) <
price2num($price_min))))
670 echo $langs->trans(
"CantBeLessThanMinPrice");
671 }
else $result = $invoice->updateline($line->id, $line->desc, $line->multicurrency_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);
674 $invoice->fetch($placeid);
675 } elseif ($action ==
'update_reduction_global') {
676 foreach ($invoice->lines as $line) {
677 $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);
680 $invoice->fetch($placeid);
683 if ($action ==
"order" and $placeid != 0)
685 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
686 if ($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") {
687 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolreceiptprinter.class.php';
691 $sql =
"SELECT label FROM ".MAIN_DB_PREFIX.
"takepos_floor_tables where rowid=".((int) $place);
692 $resql = $db->query($sql);
693 $row = $db->fetch_object(
$resql);
694 $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>';
695 $footerorder =
'</tbody></table>'.dol_print_date(
dol_now(),
'dayhour').
'<br></html>';
696 $order_receipt_printer1 =
"";
697 $order_receipt_printer2 =
"";
698 $order_receipt_printer3 =
"";
699 $catsprinter1 = explode(
';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1);
700 $catsprinter2 = explode(
';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2);
701 $catsprinter3 = explode(
';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3);
702 foreach ($invoice->lines as $line)
704 if ($line->special_code ==
"4") {
708 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT,
'id');
709 $result = array_intersect($catsprinter1, $existing);
710 $count = count($result);
711 if (!$line->fk_product) $count++;
714 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='1' where rowid=".$line->id;
716 $order_receipt_printer1 .=
'<tr><td class="left">';
717 if ($line->fk_product) $order_receipt_printer1 .= $line->product_label;
718 else $order_receipt_printer1 .= $line->description;
719 $order_receipt_printer1 .=
'</td><td class="right">'.$line->qty;
720 if (!empty($line->array_options[
'options_order_notes'])) $order_receipt_printer1 .=
"<br>(".$line->array_options[
'options_order_notes'].
")";
721 $order_receipt_printer1 .=
'</td></tr>';
724 if (($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") && $linestoprint > 0) {
725 $invoice->fetch($placeid);
726 $printer->orderprinter = 1;
728 echo
"var orderprinter1esc='";
729 $ret = $printer->sendToPrinter($invoice, $conf->global->{
'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION[
"takeposterminal"]}, $conf->global->{
'TAKEPOS_ORDER_PRINTER1_TO_USE'.$_SESSION[
"takeposterminal"]});
732 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id;
734 $invoice->fetch($placeid);
737 foreach ($invoice->lines as $line)
739 if ($line->special_code ==
"4") {
743 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT,
'id');
744 $result = array_intersect($catsprinter2, $existing);
745 $count = count($result);
748 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='2' where rowid=".$line->id;
750 $order_receipt_printer2 .=
'<tr>'.$line->product_label.
'<td class="right">'.$line->qty;
751 if (!empty($line->array_options[
'options_order_notes'])) $order_receipt_printer2 .=
"<br>(".$line->array_options[
'options_order_notes'].
")";
752 $order_receipt_printer2 .=
'</td></tr>';
755 if (($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") && $linestoprint > 0) {
756 $invoice->fetch($placeid);
757 $printer->orderprinter = 2;
759 echo
"var orderprinter2esc='";
760 $ret = $printer->sendToPrinter($invoice, $conf->global->{
'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION[
"takeposterminal"]}, $conf->global->{
'TAKEPOS_ORDER_PRINTER2_TO_USE'.$_SESSION[
"takeposterminal"]});
763 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id;
765 $invoice->fetch($placeid);
768 foreach ($invoice->lines as $line)
770 if ($line->special_code ==
"4") {
774 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT,
'id');
775 $result = array_intersect($catsprinter3, $existing);
776 $count = count($result);
779 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='3' where rowid=".$line->id;
781 $order_receipt_printer3 .=
'<tr>'.$line->product_label.
'<td class="right">'.$line->qty;
782 if (!empty($line->array_options[
'options_order_notes'])) $order_receipt_printer3 .=
"<br>(".$line->array_options[
'options_order_notes'].
")";
783 $order_receipt_printer3 .=
'</td></tr>';
786 if (($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") && $linestoprint > 0) {
787 $invoice->fetch($placeid);
788 $printer->orderprinter = 3;
790 echo
"var orderprinter3esc='";
791 $ret = $printer->sendToPrinter($invoice, $conf->global->{
'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION[
"takeposterminal"]}, $conf->global->{
'TAKEPOS_ORDER_PRINTER3_TO_USE'.$_SESSION[
"takeposterminal"]});
794 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id;
796 $invoice->fetch($placeid);
799 $sectionwithinvoicelink =
'';
800 if ($action ==
"valid" || $action ==
"history" || $action ==
'creditnote')
802 $sectionwithinvoicelink .=
'<!-- Section with invoice link -->'.
"\n";
803 $sectionwithinvoicelink .=
'<span style="font-size:120%;" class="center">';
804 $sectionwithinvoicelink .= $invoice->getNomUrl(1,
'', 0, 0,
'', 0, 0, -1,
'_backoffice').
" - ";
805 $remaintopay = $invoice->getRemainToPay();
806 if ($remaintopay > 0)
808 $sectionwithinvoicelink .= $langs->trans(
'RemainToPay').
': <span class="amountremaintopay" style="font-size: unset">'.
price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
810 if ($invoice->paye) $sectionwithinvoicelink .=
'<span class="amountpaymentcomplete" style="font-size: unset">'.$langs->trans(
"Paid").
'</span>';
811 else $sectionwithinvoicelink .= $langs->trans(
'BillShortStatusValidated');
813 $sectionwithinvoicelink .=
'</span><br>';
814 if ($conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") {
815 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="TakeposConnector('.$placeid.
');">'.$langs->trans(
'PrintTicket').
'</button>';
816 else $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="TakeposPrinting('.$placeid.
');">'.$langs->trans(
'PrintTicket').
'</button>';
817 } elseif ($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter") {
818 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="DolibarrTakeposPrinting('.$placeid.
');">'.$langs->trans(
'PrintTicket').
'</button>';
820 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="Print('.$placeid.
');">'.$langs->trans(
'PrintTicket').
'</button>';
821 if ($conf->global->TAKEPOS_GIFT_RECEIPT) {
822 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="Print('.$placeid.
', 1);">'.$langs->trans(
'GiftReceipt').
'</button>';
825 if ($conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0)
827 $sectionwithinvoicelink .=
' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.
');">'.$langs->trans(
'SendTicket').
'</button>';
830 if ($remaintopay <= 0 && $conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink .=
'<script language="javascript">$("#buttonprint").click();</script>';
837 $form =
new Form($db);
840 <script language=
"javascript">
843 var placeid=<?php echo ($placeid > 0 ? $placeid : 0); ?>;
844 $(document).ready(
function() {
845 var idoflineadded = <?php echo ($idoflineadded ? $idoflineadded : 0); ?>;
847 $(
'.posinvoiceline').click(
function(){
848 console.log(
"Click done on "+this.
id);
849 $(
'.posinvoiceline').removeClass(
"selected");
850 $(
this).addClass(
"selected");
851 if (selectedline==this.
id)
return;
852 else selectedline=this.id;
853 selectedtext=$(
'#'+selectedline).find(
"td:first").html();
855 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
856 print '$("#phonediv1").load("auto_order.php?action=editline&placeid="+placeid+"&selectedline="+selectedline, function() {
863 if (idoflineadded > 0)
865 console.log(
"Auto select "+idoflineadded);
866 $(
'.posinvoiceline#'+idoflineadded).click();
870 if ($action ==
"order" and $order_receipt_printer1 !=
"") {
871 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
875 url:
'<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php',
876 data:
'invoice='+orderprinter1esc
884 url:
'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
886 print $headerorder.$order_receipt_printer1.$footerorder; ?>'
892 if ($action ==
"order" and $order_receipt_printer2 !=
"") {
893 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
897 url:
'<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=2',
898 data:
'invoice='+orderprinter2esc
906 url:
'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print2',
908 print $headerorder.$order_receipt_printer2.$footerorder; ?>'
914 if ($action ==
"order" and $order_receipt_printer3 !=
"") {
915 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
919 url:
'<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=3',
920 data:
'invoice='+orderprinter3esc
927 if ($action ==
"search" || $action ==
"valid") {
929 parent.setFocusOnSearchField();
934 if ($action ==
"temp" and $ticket_printer1 !=
"") {
938 url:
'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
940 print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>'
945 if ($action ==
"search") {
947 $(
'#search').focus();
955 function SendTicket(
id)
957 console.log(
"Open box to select the Print/Send form");
958 $.colorbox({href:
"send.php?facid="+id, width:
"70%", height:
"30%", transition:
"none", iframe:
"true", title:
"<?php echo $langs->trans("SendTicket
"); ?>"});
961 function Print(
id, gift){
962 $.colorbox({href:
"receipt.php?facid="+
id+
"&gift="+gift, width:
"40%", height:
"90%", transition:
"none", iframe:
"true", title:
"<?php
963 echo $langs->trans("PrintTicket
"); ?>"});
966 function TakeposPrinting(
id){
968 console.log(
"TakeposPrinting" +
id);
969 $.get(
"receipt.php?facid="+
id,
function(data, status){
970 receipt=data.replace(/([^>\r\
n]?)(\r\n|\n\r|\r|\n)/g,
'');
973 url:
'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
979 function TakeposConnector(
id){
980 console.log(
"TakeposConnector" +
id);
981 $.get(
"ajax/ajax.php?action=printinvoiceticket&term=<?php echo $_SESSION["takeposterminal
"]; ?>&id="+
id,
function(data, status){
984 url:
'<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php',
985 data:
'invoice='+data
990 function DolibarrTakeposPrinting(
id) {
991 console.log(
"DolibarrTakeposPrinting Printing invoice ticket " +
id)
994 url:
"<?php print dol_buildpath('/takepos/ajax/ajax.php', 1).'?action=printinvoiceticket&term='.$_SESSION["takeposterminal
"].'&id='; ?>" + id,
998 function CreditNote() {
999 $(
"#poslines").load(
"invoice.php?action=creditnote&invoiceid="+placeid,
function() {
1004 $( document ).ready(
function() {
1005 console.log(
"Set customer info and sales in header placeid=<?php echo $placeid; ?> status=<?php echo $invoice->statut; ?>");
1008 $s = $langs->trans(
"Customer");
1009 if ($invoice->id > 0 && ($invoice->socid != $conf->global->$constforcompanyid)) {
1014 $(
"#customerandsales").html(
'');
1016 $(
"#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>');
1019 $sql =
"SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX.
"facture";
1020 if (empty($conf->global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) {
1022 $sql .=
" WHERE ref LIKE '(PROV-POS".$db->escape($_SESSION[
"takeposterminal"]).
"-0%' AND entity IN (".
getEntity(
'invoice').
")";
1025 $sql .=
" WHERE pos_source = '".$db->escape($_SESSION[
"takeposterminal"]).
"'";
1026 $sql .=
" AND module_source = 'takepos'";
1027 $sql .=
" AND entity IN (".getEntity(
'invoice').
")";
1030 $sql .= $db->order(
'datec',
'ASC');
1031 $resql = $db->query($sql);
1033 while ($obj = $db->fetch_object(
$resql)) {
1034 echo
'$("#customerandsales").append(\'';
1035 echo
'<a class="valignmiddle" title="'.dol_escape_js($langs->trans(
"SaleStartedAt",
dol_print_date($db->jdate($obj->datec),
'%H:%M',
'tzuser'))).
'" onclick="place=\\\'';
1036 $num_sale = str_replace(
")",
"", str_replace(
"(PROV-POS".$_SESSION[
"takeposterminal"].
"-",
"", $obj->ref));
1038 if (str_replace(
"-",
"", $num_sale) > $max_sale) $max_sale = str_replace(
"-",
"", $num_sale);
1039 echo
'\\\'; invoiceid=\\\'';
1041 echo
'\\\'; Refresh();">';
1042 if ($placeid == $obj->rowid) echo
"<b>";
1044 if ($placeid == $obj->rowid) echo
"</b>";
1047 echo
'$("#customerandsales").append(\'<a onclick="place=\\\'0-';
1049 echo
'\\\'; invoiceid=0; Refresh();"><span class="fa fa-plus-square" title="'.dol_escape_htmltag($langs->trans(
"StartAParallelSale")).
'"></a>\');';
1056 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.$_SESSION[
"takeposterminal"];
1057 if (!empty($conf->stock->enabled) && $conf->global->$constantforkey !=
"1")
1059 $s =
'<span class="small">';
1060 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
1062 $warehouse->fetch($conf->global->$constantforkey);
1063 $s .= $langs->trans(
"Warehouse").
'<br>'.$warehouse->ref;
1068 $(
"#infowarehouse").html(
'<?php print dol_escape_js($s); ?>');
1073 if (!empty($conf->adherent->enabled) && $invoice->socid > 0 && $invoice->socid != $conf->global->$constforcompanyid)
1075 $s =
'<span class="small">';
1076 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1077 $langs->load(
"members");
1078 $s .= $langs->trans(
"Member").
': ';
1080 $result = $adh->fetch(
'',
'', $invoice->socid);
1083 $adh->ref = $adh->getFullName($langs);
1084 if (empty($adh->statut)) { $s .=
"<s>"; }
1085 $s .= $adh->getFullName($langs);
1086 $s .=
' - '.$adh->type;
1089 $s .=
'<br>'.$langs->trans(
"SubscriptionEndDate").
': '.
dol_print_date($adh->datefin,
'day');
1090 if ($adh->hasDelay()) {
1091 $s .=
" ".img_warning($langs->trans(
"Late"));
1094 $s .=
'<br>'.$langs->trans(
"SubscriptionNotReceived");
1095 if ($adh->statut > 0) $s .=
" ".img_warning($langs->trans(
"Late"));
1097 if (empty($adh->statut)) { $s .=
"</s>"; }
1099 $s .=
'<br>'.$langs->trans(
"ThirdpartyNotLinkedToMember");
1104 $(
"#moreinfo").html(
'<?php print dol_escape_js($s); ?>');
1113 if (!empty($conf->use_javascript_ajax))
1115 print "\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
1116 print '<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.($ext ?
'&'.$ext :
'').
'"></script>'.
"\n";
1119 print '<!-- invoice.php place='.(int) $place.
' invoice='.$invoice->ref.
' mobilepage='.$mobilepage.
' $_SESSION["basiclayout"]='.$_SESSION[
"basiclayout"].
' conf->global->TAKEPOS_BAR_RESTAURANT='.$conf->global->TAKEPOS_BAR_RESTAURANT.
' -->'.
"\n";
1120 print '<div class="div-table-responsive-no-min invoice">';
1121 print '<table id="tablelines" class="noborder noshadow postablelines" width="100%">';
1122 if ($sectionwithinvoicelink && ($mobilepage ==
"invoice" || $mobilepage ==
"")) {
1123 print '<tr><td colspan="4">'.$sectionwithinvoicelink.
'</td></tr>';
1125 print '<tr class="liste_titre nodrag nodrop">';
1126 print '<td class="linecoldescription">';
1128 if ($mobilepage ==
"invoice" || $mobilepage ==
"") {
1129 print '<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.
'">';
1131 if ($conf->global->TAKEPOS_BAR_RESTAURANT)
1133 $sql =
"SELECT floor, label FROM ".MAIN_DB_PREFIX.
"takepos_floor_tables where rowid=".((int) $place);
1134 $resql = $db->query($sql);
1135 $obj = $db->fetch_object(
$resql);
1138 $label = $obj->label;
1139 $floor = $obj->floor;
1142 if ($mobilepage ==
"invoice" || $mobilepage ==
"") {
1143 print '<span class="opacitymedium">'.$langs->trans(
'Place').
"</span> <b>".$label.
"</b><br>";
1144 print '<span class="opacitymedium">'.$langs->trans(
'Floor').
"</span> <b>".$floor.
"</b>";
1146 elseif (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))
print $mysoc->
name;
1147 elseif ($mobilepage == "cats")
print $langs->trans('Category');
1148 elseif ($mobilepage == "products")
print $langs->trans('Label');
1150 print $langs->trans(
"Products");
1153 if ($_SESSION[
"basiclayout"] != 1)
1155 print '<td class="linecolqty right">'.$langs->trans(
'ReductionShort').
'</td>';
1156 print '<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
1157 print '<td class="linecolht right nowraponall">';
1158 print '<span class="opacitymedium small">'.$langs->trans(
'TotalTTCShort').
'</span><br>';
1160 if ($mobilepage ==
"invoice" || $mobilepage ==
"") {
1161 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>';
1162 if (!empty($conf->multicurrency->enabled) && $_SESSION[
"takeposcustomercurrency"] !=
"" && $conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
1164 include_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
1166 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
1167 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>';
1173 elseif ($mobilepage ==
"invoice")
print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
1177 if ($_SESSION["basiclayout"] == 1)
1179 if ($mobilepage ==
"cats")
1181 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1183 $categories = $categorie->get_full_arbo(
'product');
1185 foreach ($categories as $row) {
1186 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) $htmlforlines .=
'<div class="leftcat';
1187 else $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline';
1188 $htmlforlines .=
'" onclick="LoadProducts('.$row[
'id'].
');">';
1189 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) $htmlforlines .=
'<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=cat&query=cat&id='.$row[
'id'].
'"><br>';
1190 else $htmlforlines .=
'<td class="left">';
1191 $htmlforlines .= $row[
'label'];
1192 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) $htmlforlines .=
'</div>'.
"\n";
1193 else $htmlforlines .=
'</td></tr>'.
"\n";
1195 $htmlforlines .=
'</table>';
1196 $htmlforlines .=
'</table>';
1197 print $htmlforlines;
1200 if ($mobilepage ==
"products")
1202 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1204 $catid =
GETPOST(
'catid',
'int');
1205 $result = $object->fetch($catid);
1206 $prods = $object->getObjectsInCateg(
"product");
1208 foreach ($prods as $row) {
1209 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) $htmlforlines .=
'<div class="leftcat';
1210 else $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline';
1211 $htmlforlines .=
'" onclick="AddProduct(\''.$place.
'\',
'.$row->id.')
">';
1212 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1213 $htmlforlines .= '<img class="imgwrapper
" width="33%
" src="'.DOL_URL_ROOT.'/takepos/
public/auto_order.php?genimg=pro&query=pro&
id=
'.$row->id.'"><br>';
1214 $htmlforlines .= $row->label.''.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency);
1215 $htmlforlines .= '</div>'."\n
";
1218 $htmlforlines .= '<td class="left
">';
1219 $htmlforlines .= $row->label;
1220 $htmlforlines .= '<div class="right
">'.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).'</div>';
1221 $htmlforlines .= '</tr>'."\n
";
1224 $htmlforlines .= '</table>';
1225 print $htmlforlines;
1228 if ($mobilepage == "places
")
1230 $sql = "SELECT
rowid, entity, label, leftpos, toppos, floor FROM
".MAIN_DB_PREFIX."takepos_floor_tables
";
1231 $resql = $db->query($sql);
1234 while ($row = $db->fetch_array($resql)) {
1236 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
1237 $htmlforlines .= '" onclick="LoadPlace(\
''.$row[
'label'].
'\')
">';
1238 $htmlforlines .= '<td class="left
">';
1239 $htmlforlines .= $row['label'];
1240 $htmlforlines .= '</td>';
1241 $htmlforlines .= '</tr>'."\n";
1243 $htmlforlines .= '</table>';
1244 print $htmlforlines;
1250 //In Phone basic layout hide some content depends situation
1251 if ($_SESSION["basiclayout
"] == 1 && $mobilepage != "invoice
" && $action != "order
") return;
1253 if (is_array($invoice->lines) && count($invoice->lines))
1255 print '<!-- invoice.php show lines of invoices -->'."\n";
1256 $tmplines = array_reverse($invoice->lines);
1257 foreach ($tmplines as $line)
1259 if ($line->fk_parent_line != false)
1261 $htmlsupplements[$line->fk_parent_line] .= '<tr class="drag drop oddeven posinvoiceline
';
1262 if ($line->special_code == "4") $htmlsupplements[$line->fk_parent_line] .= ' order
';
1263 $htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'">';
1264 $htmlsupplements[$line->fk_parent_line] .= '<td class="left
">';
1265 $htmlsupplements[$line->fk_parent_line] .= img_picto('', 'rightarrow');
1266 if ($line->product_label) $htmlsupplements[$line->fk_parent_line] .= $line->product_label;
1267 if ($line->product_label && $line->desc) $htmlsupplements[$line->fk_parent_line] .= '<br>';
1268 if ($line->product_label != $line->desc)
1270 $firstline = dolGetFirstLineOfText($line->desc);
1271 if ($firstline != $line->desc)
1273 $htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
1275 $htmlsupplements[$line->fk_parent_line] .= $line->desc;
1278 $htmlsupplements[$line->fk_parent_line] .= '</td>';
1279 if ($_SESSION["basiclayout
"] != 1)
1281 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.vatrate($line->remise_percent, true).'</td>';
1282 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.$line->qty.'</td>';
1283 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.price($line->total_ttc).'</td>';
1285 $htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n";
1290 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
1291 if ($line->special_code == "4") {
1292 $htmlforlines .= ' order
';
1294 $htmlforlines .= '" id="'.$line->id.'">';
1295 $htmlforlines .= '<td class="left
">';
1296 if ($_SESSION["basiclayout
"] == 1) $htmlforlines .= '<span class="phoneqty
">'.$line->qty."</span> x
";
1297 if (isset($line->product_type))
1299 if (empty($line->product_type)) $htmlforlines .= img_object('', 'product').' ';
1300 else $htmlforlines .= img_object('', 'service').' ';
1302 if (empty($conf->global->TAKEPOS_SHOW_N_FIRST_LINES)) {
1304 if ($line->product_ref) {
1305 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
1306 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
1307 if ($line->product_label != $line->desc) {
1308 if ($line->desc) $tooltiptext .= '<br>';
1309 $tooltiptext .= $line->desc;
1312 $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
1314 if ($line->product_label) $htmlforlines .= $line->product_label;
1315 if ($line->product_label != $line->desc)
1317 if ($line->product_label && $line->desc) $htmlforlines .= '<br>';
1318 $firstline = dolGetFirstLineOfText($line->desc, $conf->global->TAKEPOS_SHOW_N_FIRST_LINES);
1319 if ($firstline != $line->desc)
1321 $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
1323 $htmlforlines .= $line->desc;
1327 if (!empty($line->array_options['options_order_notes'])) $htmlforlines .= "<br>(
".$line->array_options['options_order_notes'].")
";
1328 if ($_SESSION["basiclayout
"] == 1) {
1329 $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>';
1331 if ($_SESSION["basiclayout
"] != 1)
1334 $moreinfo .= $langs->transcountry("TotalHT
", $mysoc->country_code).': '.price($line->total_ht);
1335 if ($line->vat_src_code) $moreinfo .= '<br>'.$langs->trans("VATCode
").': '.$line->vat_src_code;
1336 $moreinfo .= '<br>'.$langs->transcountry("TotalVAT
", $mysoc->country_code).': '.price($line->total_tva);
1337 $moreinfo .= '<br>'.$langs->transcountry("TotalLT1
", $mysoc->country_code).': '.price($line->total_localtax1);
1338 $moreinfo .= '<br>'.$langs->transcountry("TotalLT2
", $mysoc->country_code).': '.price($line->total_localtax2);
1339 $moreinfo .= '<br>'.$langs->transcountry("TotalTTC
", $mysoc->country_code).': '.price($line->total_ttc);
1340 //$moreinfo .= $langs->trans("TotalHT
").': '.$line->total_ht;
1341 if ($line->date_start || $line->date_end) $htmlforlines .= '<br><div class="clearboth nowraponall
">'.get_date_range($line->date_start, $line->date_end).'</div>';
1342 $htmlforlines .= '</td>';
1343 $htmlforlines .= '<td class="right
">'.vatrate($line->remise_percent, true).'</td>';
1344 $htmlforlines .= '<td class="right
">';
1345 if (!empty($conf->stock->enabled) && !empty($user->rights->stock->mouvement->lire))
1347 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
1348 if (!empty($conf->global->$constantforkey) && $line->fk_product > 0) {
1349 $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp
";
1350 $sql .= " FROM
".MAIN_DB_PREFIX."entrepot as e,
";
1351 $sql .= " ".MAIN_DB_PREFIX."product_stock as ps
";
1352 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product
";
1353 $sql .= " WHERE ps.reel != 0
";
1354 $sql .= " AND ps.fk_entrepot =
".$conf->global->$constantforkey;
1355 $sql .= " AND e.entity IN (
".getEntity('stock').")
";
1356 $sql .= " AND ps.fk_product =
".$line->fk_product;
1357 $resql = $db->query($sql);
1359 $obj = $db->fetch_object($resql);
1360 $stock_real = price2num($obj->reel, 'MS');
1361 $htmlforlines .= $line->qty;
1362 if ($line->qty && $line->qty > $stock_real) $htmlforlines .= '<span style="color: var(--amountremaintopaycolor)
">';
1363 $htmlforlines .= ' <span class="posstocktoolow
">('.$langs->trans("Stock
").' '.$stock_real.')</span>';
1364 if ($line->qty && $line->qty > $stock_real) $htmlforlines .= "</span>
";
1366 dol_print_error($db);
1369 $htmlforlines .= $line->qty;
1372 $htmlforlines .= $line->qty;
1375 $htmlforlines .= '</td>';
1376 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
1377 $htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency);
1378 if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency
"] != "" && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
1379 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
1380 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
1381 $multicurrency = new MultiCurrency($db);
1382 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
1383 $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>';
1385 $htmlforlines .= '</td>';
1387 $htmlforlines .= '</tr>'."\n";
1388 $htmlforlines .= $htmlsupplements[$line->id];
1390 print $htmlforlines;
1393 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td><td></td><td></td></tr>';
1395 } else { // No invoice generated yet
1396 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td><td></td><td></td></tr>';
1401 if (($action == "valid
" || $action == "history
") && $invoice->type != Facture::TYPE_CREDIT_NOTE) {
1402 print '<button id="buttonprint
" type="button
" onclick="ModalBox(\
'ModalCreditNote\')">'.$langs->trans(
'CreateCreditNote').
'</button>';
1406 if ($action ==
"search")
1409 <input type="text" id="search" name="search" onkeyup="Search2();" name="search" style="width:80%;font-size: 150%;" placeholder=' . $langs->trans(
'Search').
'
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
</td >< tdcolspan="3">< spanclass="opacitymedium"></span ></td ></tr >< trclass="liste_total"> CREANCES DETTES< tdcolspan="3"class="right"></td >< tdcolspan="3"class="right"></td ></tr > CREANCES DETTES RECETTES DEPENSES trips CREANCES DETTES Y m expensereport p date_valid Y m expensereport pe datep $db idate($date_start)."' AND $column < p rowid
Class to manage products or services.
dol_now($mode= 'auto')
Return date for now.
top_htmlhead($head, $title= '', $disablejs=0, $disablehead=0, $arrayofjs= '', $arrayofcss= '', $disablejmobile=0, $disablenofollow=0)
Ouput html header of a page.
$conf db name
Only used if Module[ID]Name translation string is not found.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate, from a $thirdparty_buyer to a $thirdparty_seller Note: This function applies same rules than get_default_tva.
const BATCH_RULE_SELLBY_EATBY_DATES_FIRST
Batches rules.
const TYPE_SITUATION
Situation invoice.
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...
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage third parties objects (customers, suppliers, prospects...)
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Class to manage categories.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
if(empty($user->rights->takepos->run)&&!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) if(($conf->global->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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
const STATUS_DRAFT
Draft status.
Class to manage payments of customer invoices.
Class to manage members of a foundation.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
Class to manage Receipt Printers.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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) Si ...
print $_SERVER["PHP_SELF"] n
Edit parameters.
Class to manage invoices.
dol_htmloutput_errors($mesgstring= '', $mesgarray=array(), $keepembedded=0)
Print formated error messages to output (Used to show messages on html output).
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Class to manage warehouses.