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 WHERE";
200 $sql .=
" fk_soc = ".((int) $invoice->socid);
201 $sql .=
" AND type <> ".Facture::TYPE_CREDIT_NOTE;
202 $sql .=
" AND fk_statut >= ".$invoice::STATUS_VALIDATED;
203 $sql .=
" ORDER BY rowid DESC";
205 $resql = $db->query(
$sql);
207 $obj = $db->fetch_object($resql);
208 $fk_source = $obj->rowid;
209 if ($fk_source ==
null) {
210 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
213 fail($langs->transnoentitiesnoconv(
"NoPreviousBillForCustomer"));
215 $invoice->fk_facture_source = $fk_source;
216 $invoice->update($user);
219 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.$_SESSION[
"takeposterminal"];
224 if ($invoice->getRemainToPay() > 0) {
230 } elseif (count($invoice->lines) == 0) {
234 } elseif (
isModEnabled(
'stock') && $conf->global->$constantforkey !=
"1") {
235 $savconst = $conf->global->STOCK_CALCULATE_ON_BILL;
236 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
238 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
239 dol_syslog(
"Validate invoice with stock change into warehouse defined into constant ".$constantforkey.
" = ".$conf->global->$constantforkey);
241 if (
isModEnabled(
'productbatch') && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) {
242 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
245 $res = $invoice->validate($user,
'', $conf->global->$constantforkey, 0, $batch_rule);
247 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
249 $res = $invoice->validate($user);
252 $langs->load(
"admin");
253 dol_htmloutput_errors($invoice->error ==
'NotConfigured' ? $langs->trans(
"NotConfigured").
' (TakePos numbering module)': $invoice->error, $invoice->errors, 1);
264 if (!$error && $res >= 0) {
265 $remaintopay = $invoice->getRemainToPay();
266 if ($remaintopay > 0) {
268 $payment->datepaye = $now;
269 $payment->fk_account = $bankaccount;
270 $payment->amounts[$invoice->id] = $amountofpayment;
277 if ($amountofpayment <= 0 || $amountofpayment > $remaintopay) {
278 $payment->amounts[$invoice->id] = $remaintopay;
281 $payment->paiementid = $paiementid;
282 $payment->num_payment = $invoice->ref;
284 if ($pay !=
"delayed") {
285 $payment->create($user);
286 $payment->addPaymentToBank($user,
'payment',
'(CustomerInvoicePayment)', $bankaccount,
'',
'');
287 $remaintopay = $invoice->getRemainToPay();
293 if ($remaintopay == 0) {
294 dol_syslog(
"Invoice is paid, so we set it to status Paid");
295 $result = $invoice->setPaid($user);
300 $invoice->setPaymentMethods($paiementid);
302 dol_syslog(
"Invoice is not paid, remain to pay = ".$remaintopay);
309 if ($action ==
'creditnote' && $user->hasRight(
'facture',
'creer')) {
310 $creditnote =
new Facture($db);
311 $creditnote->socid = $invoice->socid;
313 $creditnote->module_source =
'takepos';
314 $creditnote->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
316 $creditnote->fk_facture_source = $placeid;
317 $creditnote->remise_absolue = $invoice->remise_absolue;
318 $creditnote->remise_percent = $invoice->remise_percent;
319 $creditnote->create($user);
321 foreach ($invoice->lines as $line) {
323 if (method_exists($line,
'fetch_optionals')) {
325 $line->fetch_optionals();
328 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
333 if (!empty($invoice->situation_counter)) {
334 $source_fk_prev_id = $line->fk_prev_id;
335 $line->fk_prev_id = $line->id;
336 if (!empty($invoice->tab_previous_situation_invoice)) {
339 $tab_jumped_credit_notes = array();
340 $lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
341 $searchPreviousInvoice =
true;
342 while ($searchPreviousInvoice) {
343 if ($invoice->tab_previous_situation_invoice[$lineIndex]->situation_cycle_ref || $lineIndex < 1) {
344 $searchPreviousInvoice =
false;
348 $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id;
354 $maxPrevSituationPercent = 0;
355 foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
356 if ($prevLine->id == $source_fk_prev_id) {
357 $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
360 $line->total_ht = $line->total_ht - $prevLine->total_ht;
361 $line->total_tva = $line->total_tva - $prevLine->total_tva;
362 $line->total_ttc = $line->total_ttc - $prevLine->total_ttc;
363 $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1;
364 $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2;
366 $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice;
367 $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht;
368 $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva;
369 $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc;
374 $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
379 $maxPrevSituationPercent = 0;
380 foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
381 foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) {
382 if ($prevLine->fk_prev_id == $source_fk_prev_id) {
383 $maxPrevSituationPercent = $prevLine->situation_percent;
385 $line->total_ht -= $prevLine->total_ht;
386 $line->total_tva -= $prevLine->total_tva;
387 $line->total_ttc -= $prevLine->total_ttc;
388 $line->total_localtax1 -= $prevLine->total_localtax1;
389 $line->total_localtax2 -= $prevLine->total_localtax2;
391 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
392 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
393 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
394 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
400 $line->situation_percent += $maxPrevSituationPercent;
407 $line->fk_facture = $creditnote->id;
408 $line->fk_parent_line = $fk_parent_line;
410 $line->subprice = -$line->subprice;
411 $line->pa_ht = $line->pa_ht;
412 $line->total_ht = -$line->total_ht;
413 $line->total_tva = -$line->total_tva;
414 $line->total_ttc = -$line->total_ttc;
415 $line->total_localtax1 = -$line->total_localtax1;
416 $line->total_localtax2 = -$line->total_localtax2;
418 $line->multicurrency_subprice = -$line->multicurrency_subprice;
419 $line->multicurrency_total_ht = -$line->multicurrency_total_ht;
420 $line->multicurrency_total_tva = -$line->multicurrency_total_tva;
421 $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
423 $result = $line->insert(0, 1);
425 $creditnote->lines[] = $line;
428 if ($result > 0 && $line->product_type == 9) {
429 $fk_parent_line = $result;
432 $creditnote->update_price(1);
434 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'.$_SESSION[
"takeposterminal"];
435 if (
isModEnabled(
'stock') && $conf->global->$constantforkey !=
"1") {
436 $savconst = $conf->global->STOCK_CALCULATE_ON_BILL;
437 $conf->global->STOCK_CALCULATE_ON_BILL = 1;
438 $constantforkey =
'CASHDESK_ID_WAREHOUSE'.$_SESSION[
"takeposterminal"];
439 dol_syslog(
"Validate invoice with stock change into warehouse defined into constant ".$constantforkey.
" = ".$conf->global->$constantforkey);
441 if (
isModEnabled(
'productbatch') && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) {
442 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
445 $res = $creditnote->validate($user,
'', $conf->global->$constantforkey, 0, $batch_rule);
446 $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
448 $res = $creditnote->validate($user);
452 if ($action ==
'history' || $action ==
'creditnote') {
453 if ($action ==
'creditnote') {
454 $placeid = $creditnote->id;
456 $placeid = (int)
GETPOST(
'placeid',
'int');
459 $invoice->fetch($placeid);
463 if (($action ==
"addline" || $action ==
"freezone") && $placeid == 0) {
465 $invoice->date =
dol_now(
'tzuserrel');
466 $invoice->module_source =
'takepos';
467 $invoice->pos_source = isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'' ;
468 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] : $conf->entity;
470 if ($invoice->socid <= 0) {
471 $langs->load(
'errors');
475 $placeid = $invoice->create($user);
479 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture set ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")' where rowid = ".((int) $placeid);
484 if ($action ==
"addline") {
486 $prod->fetch($idproduct);
489 $customer->fetch($invoice->socid);
491 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
494 $price = $datapriceofproduct[
'pu_ht'];
495 $price_ttc = $datapriceofproduct[
'pu_ttc'];
497 $price_base_type = $datapriceofproduct[
'price_base_type'];
498 $tva_tx = $datapriceofproduct[
'tva_tx'];
499 $tva_npr = $datapriceofproduct[
'tva_npr'];
502 $localtax1_tx =
get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
503 $localtax2_tx =
get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
505 if (!empty($conf->global->TAKEPOS_SUPPLEMENTS)) {
506 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
508 $categories = $cat->containing($idproduct,
'product');
509 $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories,
'id')));
510 if ($found !==
false) {
511 $sql =
"SELECT fk_parent_line FROM ".MAIN_DB_PREFIX.
"facturedet where rowid=$selectedline";
512 $resql = $db->query(
$sql);
513 $row = $db->fetch_array($resql);
514 if ($row[0] ==
null) {
515 $parent_line = $selectedline;
517 $parent_line = $row[0];
524 if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT)) {
525 foreach ($invoice->lines as $line) {
526 if ($line->product_ref == $prod->ref) {
527 if ($line->special_code==4)
continue;
528 $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);
532 $idoflineadded = $line->id;
538 if ($idoflineadded <= 0) {
539 $invoice->fetch_thirdparty();
540 $array_options = array();
542 $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);
545 if (isset($conf->global->MARGIN_TYPE)) {
546 if ($conf->global->MARGIN_TYPE ==
'pmp' && !empty($prod->pmp)) {
547 $line[
'fk_fournprice'] =
null;
548 $line[
'pa_ht'] = $prod->pmp;
549 } elseif ($conf->global->MARGIN_TYPE ==
'costprice' && !empty($prod->cost_price)) {
550 $line[
'fk_fournprice'] =
null;
551 $line[
'pa_ht'] = $prod->cost_price;
554 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
556 if ($pf->find_min_price_product_fournisseur($idproduct, $qty) > 0) {
557 $line[
'fk_fournprice'] = $pf->product_fourn_price_id;
558 $line[
'pa_ht'] = $pf->fourn_unitprice_with_discount;
560 $line[
'pa_ht'] += $pf->fourn_charges / $pf->fourn_qty;
566 $parameters = array(
'prod' => $prod,
'line' => $line);
567 $reshook=$hookmanager->executeHooks(
'completeTakePosAddLine', $parameters, $invoice, $action);
568 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
571 if (empty($reshook)) {
572 if (!empty($hookmanager->resArray)) {
573 $line = $hookmanager->resArray;
576 $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);
579 if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
580 $CUSTOMER_DISPLAY_line1 = $prod->label;
581 $CUSTOMER_DISPLAY_line2 =
price($price_ttc);
585 $invoice->fetch($placeid);
588 if ($action ==
"freezone") {
590 $customer->fetch($invoice->socid);
592 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
594 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
602 $localtax1_tx =
get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
603 $localtax2_tx =
get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
605 $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);
606 $invoice->fetch($placeid);
609 if ($action ==
"addnote") {
610 $desc =
GETPOST(
'addnote',
'alpha');
612 $invoice->update_note($desc,
'_public');
613 }
else foreach ($invoice->lines as $line) {
614 if ($line->id == $idline) {
615 $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);
618 $invoice->fetch($placeid);
621 if ($action ==
"deleteline") {
622 if ($idline > 0 and $placeid > 0) {
623 $invoice->deleteline($idline);
624 $invoice->fetch($placeid);
625 } elseif ($placeid > 0) {
626 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facturedet where fk_facture = ".((int) $placeid).
" ORDER BY rowid DESC";
627 $resql = $db->query(
$sql);
628 $row = $db->fetch_array($resql);
629 $deletelineid = $row[0];
630 $invoice->deleteline($deletelineid);
631 $invoice->fetch($placeid);
633 if (count($invoice->lines) == 0) {
634 $invoice->delete($user);
635 header(
"Location: ".DOL_URL_ROOT.
"/takepos/invoice.php");
641 if ($action ==
"delete") {
644 $result = $invoice->fetch($placeid);
651 foreach ($invoice->lines as $line) {
652 $tmpres = $invoice->deleteline($line->id);
659 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture";
660 $varforconst =
'CASHDESK_ID_THIRDPARTY'.$_SESSION[
"takeposterminal"];
661 $sql .=
" SET fk_soc = ".((int) $conf->global->$varforconst).
", ";
663 $sql .=
" WHERE ref = '(PROV-POS".$db->escape($_SESSION[
"takeposterminal"].
"-".$place).
")'";
664 $resql1 = $db->query(
$sql);
666 if ($resdeletelines && $resql1) {
672 $invoice->fetch($placeid);
677 if ($action ==
"updateqty") {
678 foreach ($invoice->lines as $line) {
679 if ($line->id == $idline) {
680 if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code ==
"4")) {
683 $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);
688 $invoice->fetch($placeid);
691 if ($action ==
"updateprice") {
693 $customer->fetch($invoice->socid);
695 foreach ($invoice->lines as $line) {
696 if ($line->id == $idline) {
698 $prod->fetch($line->fk_product);
699 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
700 $price_min = $datapriceofproduct[
'price_min'];
701 $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
702 $pu_ht =
price2num($number / (1 + ($line->tva_tx / 100)),
'MU');
704 if ($usercanproductignorepricemin && (!empty($price_min) && (
price2num($pu_ht) * (1 -
price2num($line->remise_percent) / 100) <
price2num($price_min)))) {
705 $langs->load(
"products");
709 if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code ==
"4")) {
712 $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);
714 $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);
721 $invoice->fetch($placeid);
724 if ($action ==
"updatereduction") {
726 $customer->fetch($invoice->socid);
728 foreach ($invoice->lines as $line) {
729 if ($line->id == $idline) {
730 dol_syslog(
"updatereduction Process line ".$line->id.
' to apply discount of '.$number.
'%');
733 $prod->fetch($line->fk_product);
735 $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
736 $price_min = $datapriceofproduct[
'price_min'];
737 $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
739 $pu_ht =
price2num($line->subprice / (1 + ($line->tva_tx / 100)),
'MU');
742 if ($usercanproductignorepricemin && (!empty($price_min) && (
price2num($line->subprice) * (1 -
price2num($number) / 100) <
price2num($price_min)))) {
743 $langs->load(
"products");
746 if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code ==
"4")) {
749 $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx,
'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
756 $invoice->fetch($placeid);
757 } elseif ($action ==
'update_reduction_global') {
758 foreach ($invoice->lines as $line) {
759 $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);
762 $invoice->fetch($placeid);
765 if ($action ==
"order" and $placeid != 0) {
766 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
767 if ($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") {
768 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolreceiptprinter.class.php';
772 $sql =
"SELECT label FROM ".MAIN_DB_PREFIX.
"takepos_floor_tables where rowid=".((int) $place);
773 $resql = $db->query(
$sql);
774 $row = $db->fetch_object($resql);
775 $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>';
776 $footerorder =
'</tbody></table>'.dol_print_date(
dol_now(),
'dayhour').
'<br></html>';
777 $order_receipt_printer1 =
"";
778 $order_receipt_printer2 =
"";
779 $order_receipt_printer3 =
"";
780 $catsprinter1 = explode(
';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1);
781 $catsprinter2 = explode(
';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2);
782 $catsprinter3 = explode(
';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3);
784 foreach ($invoice->lines as $line) {
785 if ($line->special_code ==
"4") {
789 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT,
'id');
790 $result = array_intersect($catsprinter1, $existing);
791 $count = count($result);
792 if (!$line->fk_product) {
797 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='1' where rowid=".$line->id;
799 $order_receipt_printer1 .=
'<tr><td class="left">';
800 if ($line->fk_product) {
801 $order_receipt_printer1 .= $line->product_label;
803 $order_receipt_printer1 .= $line->description;
805 $order_receipt_printer1 .=
'</td><td class="right">'.$line->qty;
806 if (!empty($line->array_options[
'options_order_notes'])) {
807 $order_receipt_printer1 .=
"<br>(".$line->array_options[
'options_order_notes'].
")";
809 $order_receipt_printer1 .=
'</td></tr>';
812 if (($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") && $linestoprint > 0) {
813 $invoice->fetch($placeid);
814 $printer->orderprinter = 1;
816 echo
"var orderprinter1esc='";
817 $ret = $printer->sendToPrinter($invoice,
getDolGlobalInt(
'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION[
"takeposterminal"]),
getDolGlobalInt(
'TAKEPOS_ORDER_PRINTER1_TO_USE'.$_SESSION[
"takeposterminal"]));
820 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id;
822 $invoice->fetch($placeid);
825 foreach ($invoice->lines as $line) {
826 if ($line->special_code ==
"4") {
830 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT,
'id');
831 $result = array_intersect($catsprinter2, $existing);
832 $count = count($result);
835 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='2' where rowid=".$line->id;
837 $order_receipt_printer2 .=
'<tr>'.$line->product_label.
'<td class="right">'.$line->qty;
838 if (!empty($line->array_options[
'options_order_notes'])) {
839 $order_receipt_printer2 .=
"<br>(".$line->array_options[
'options_order_notes'].
")";
841 $order_receipt_printer2 .=
'</td></tr>';
844 if (($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") && $linestoprint > 0) {
845 $invoice->fetch($placeid);
846 $printer->orderprinter = 2;
848 echo
"var orderprinter2esc='";
849 $ret = $printer->sendToPrinter($invoice,
getDolGlobalInt(
'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION[
"takeposterminal"]),
getDolGlobalInt(
'TAKEPOS_ORDER_PRINTER2_TO_USE'.$_SESSION[
"takeposterminal"]));
852 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id;
854 $invoice->fetch($placeid);
857 foreach ($invoice->lines as $line) {
858 if ($line->special_code ==
"4") {
862 $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT,
'id');
863 $result = array_intersect($catsprinter3, $existing);
864 $count = count($result);
867 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='3' where rowid=".$line->id;
869 $order_receipt_printer3 .=
'<tr>'.$line->product_label.
'<td class="right">'.$line->qty;
870 if (!empty($line->array_options[
'options_order_notes'])) {
871 $order_receipt_printer3 .=
"<br>(".$line->array_options[
'options_order_notes'].
")";
873 $order_receipt_printer3 .=
'</td></tr>';
876 if (($conf->global->TAKEPOS_PRINT_METHOD ==
"receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") && $linestoprint > 0) {
877 $invoice->fetch($placeid);
878 $printer->orderprinter = 3;
880 echo
"var orderprinter3esc='";
881 $ret = $printer->sendToPrinter($invoice,
getDolGlobalInt(
'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION[
"takeposterminal"]),
getDolGlobalInt(
'TAKEPOS_ORDER_PRINTER3_TO_USE'.$_SESSION[
"takeposterminal"]));
884 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id;
886 $invoice->fetch($placeid);
889 $sectionwithinvoicelink =
'';
890 if ($action ==
"valid" || $action ==
"history" || $action ==
'creditnote') {
891 $sectionwithinvoicelink .=
'<!-- Section with invoice link -->'.
"\n";
892 $sectionwithinvoicelink .=
'<span style="font-size:120%;" class="center">';
893 $sectionwithinvoicelink .= $invoice->getNomUrl(1,
'', 0, 0,
'', 0, 0, -1,
'_backoffice').
" - ";
894 $remaintopay = $invoice->getRemainToPay();
895 if ($remaintopay > 0) {
896 $sectionwithinvoicelink .= $langs->trans(
'RemainToPay').
': <span class="amountremaintopay" style="font-size: unset">'.
price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
898 if ($invoice->paye) {
899 $sectionwithinvoicelink .=
'<span class="amountpaymentcomplete" style="font-size: unset">'.$langs->trans(
"Paid").
'</span>';
901 $sectionwithinvoicelink .= $langs->trans(
'BillShortStatusValidated');
904 $sectionwithinvoicelink .=
'</span><br>';
906 $sectionwithinvoicelink .=
' <a target="_blank" class="button" href="' . DOL_URL_ROOT .
'/document.php?token=' .
newToken() .
'&modulepart=facture&file=' . $invoice->ref .
'/' . $invoice->ref .
'.pdf">Invoice</a>';
908 if (
getDolGlobalString(
'TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
909 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="TakeposConnector('.$placeid.
')">'.$langs->trans(
'PrintTicket').
'</button>';
911 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="TakeposPrinting('.$placeid.
')">'.$langs->trans(
'PrintTicket').
'</button>';
914 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="DolibarrTakeposPrinting('.$placeid.
')">'.$langs->trans(
'PrintTicket').
'</button>';
916 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="Print('.$placeid.
')">'.$langs->trans(
'PrintTicket').
'</button>';
918 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="PrintBox('.$placeid.
', \'without_details\')">'.$langs->trans(
'PrintWithoutDetails').
'</button>';
921 $sectionwithinvoicelink .=
' <button id="buttonprint" type="button" onclick="Print('.$placeid.
', 1)">'.$langs->trans(
'GiftReceipt').
'</button>';
924 if (
getDolGlobalString(
'TAKEPOS_EMAIL_TEMPLATE_INVOICE') && $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) {
925 $sectionwithinvoicelink .=
' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.
')">'.$langs->trans(
'SendTicket').
'</button>';
928 if ($remaintopay <= 0 &&
getDolGlobalString(
'TAKEPOS_AUTO_PRINT_TICKETS') && $action !=
"history") {
929 $sectionwithinvoicelink .=
'<script type="text/javascript">$("#buttonprint").click();</script>';
941 if ((
getDolGlobalString(
'TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->layout ==
'phone') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
942 $title =
'TakePOS - Dolibarr '.DOL_VERSION;
943 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
944 $title =
'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
946 $head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
947 <meta name="apple-mobile-web-app-capable" content="yes">
948 <meta name="mobile-web-app-capable" content="yes">
949 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
951 '/takepos/css/pos.css.php',
953 $arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
956 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
965 <script
type=
"text/javascript">
968 <?php
if ($action==
"valid") echo
"var place=0;";?>
969 var placeid=<?php echo ($placeid > 0 ? $placeid : 0); ?>;
970 $(document).ready(
function() {
971 var idoflineadded = <?php echo (empty($idoflineadded) ? 0 : $idoflineadded); ?>;
973 $(
'.posinvoiceline').click(
function(){
974 console.log(
"Click done on "+this.
id);
975 $(
'.posinvoiceline').removeClass(
"selected");
976 $(
this).addClass(
"selected");
977 if (selectedline==this.
id)
return;
978 else selectedline=this.id;
979 selectedtext=$(
'#'+selectedline).find(
"td:first").html();
981 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
982 print
'$("#phonediv1").load("auto_order.php?action=editline&token='.newToken().
'&placeid="+placeid+"&selectedline="+selectedline, function() {
989 if (idoflineadded > 0)
991 console.log(
"Auto select "+idoflineadded);
992 $(
'.posinvoiceline#'+idoflineadded).click();
996 if ($action ==
"order" && !empty($order_receipt_printer1)) {
997 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
1001 url:
'<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php',
1002 data:
'invoice='+orderprinter1esc
1009 url:
'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
1011 print $headerorder.$order_receipt_printer1.$footerorder; ?>'
1017 if ($action ==
"order" && !empty($order_receipt_printer2)) {
1018 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
1022 url:
'<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=2',
1023 data:
'invoice='+orderprinter2esc
1030 url:
'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print2',
1032 print $headerorder.$order_receipt_printer2.$footerorder; ?>'
1038 if ($action ==
"order" && !empty($order_receipt_printer3)) {
1039 if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) ==
true) {
1043 url:
'<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=3',
1044 data:
'invoice='+orderprinter3esc
1051 if ($action ==
"search" || $action ==
"valid") {
1053 parent.setFocusOnSearchField();
1058 if ($action ==
"temp" && !empty($ticket_printer1)) {
1062 url:
'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
1064 print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>'
1069 if ($action ==
"search") {
1071 $(
'#search').focus();
1079 function SendTicket(
id)
1081 console.log(
"Open box to select the Print/Send form");
1082 $.colorbox({href:
"send.php?facid="+id, width:
"70%", height:
"30%", transition:
"none", iframe:
"true", title:
'<?php echo dol_escape_js($langs->trans("SendTicket")); ?>'});
1086 function PrintBox(
id, action) {
1087 console.log(
"Open box before printing");
1088 $.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
"); ?>"});
1092 function Print(
id, gift){
1093 console.log(
"Call Print() to generate the receipt.");
1094 $.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")); ?>'});
1098 function TakeposPrinting(
id){
1100 console.log(
"TakeposPrinting" +
id);
1101 $.get(
"receipt.php?facid="+
id,
function(data, status) {
1102 receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,
'');
1105 url:
'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>:8111/print',
1112 function TakeposConnector(
id){
1113 console.log(
"TakeposConnector" +
id);
1114 $.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) {
1117 url:
'<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER
'); ?>/printer/index.php',
1118 data:
'invoice='+data
1124 function DolibarrTakeposPrinting(
id) {
1125 console.log(
"DolibarrTakeposPrinting Printing invoice ticket " +
id)
1128 data: { token:
'<?php echo currentToken(); ?>' },
1129 url:
"<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=printinvoiceticket&token='.newToken().'&term='.urlencode(isset($_SESSION["takeposterminal
"]) ? $_SESSION["takeposterminal
"] : '').'&id='; ?>" + id,
1134 function CreditNote() {
1135 $(
"#poslines").load(
"invoice.php?action=creditnote&token=<?php echo newToken() ?>&invoiceid="+placeid,
function() { });
1139 function SetNote() {
1140 $(
"#poslines").load(
"invoice.php?action=addnote&token=<?php echo newToken() ?>&invoiceid="+placeid+
"&idline="+selectedline, {
"addnote": $(
"#textinput").val() });
1145 $( document ).ready(
function() {
1146 console.log(
"Set customer info and sales in header placeid=<?php echo $placeid; ?> status=<?php echo $invoice->statut; ?>");
1149 $s = $langs->trans(
"Customer");
1150 if ($invoice->id > 0 && ($invoice->socid !=
getDolGlobalString($constforcompanyid))) {
1155 $(
"#customerandsales").html(
'');
1156 $(
"#shoppingcart").html(
'');
1158 $(
"#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>');
1161 $sql =
"SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX.
"facture";
1162 if (empty($conf->global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) {
1164 $sql .=
" WHERE ref LIKE '(PROV-POS".$db->escape(isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'').
"-0%' AND entity IN (".
getEntity(
'invoice').
")";
1167 $sql .=
" WHERE pos_source = '".$db->escape($_SESSION[
"takeposterminal"]).
"'";
1168 $sql .=
" AND module_source = 'takepos'";
1169 $sql .=
" AND entity IN (".getEntity(
'invoice').
")";
1172 $sql .= $db->order(
'datec',
'ASC');
1173 $resql = $db->query(
$sql);
1176 while ($obj = $db->fetch_object($resql)) {
1177 echo
'$("#shoppingcart").append(\'';
1178 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=\\\'';
1179 $num_sale = str_replace(
")",
"", str_replace(
"(PROV-POS".$_SESSION[
"takeposterminal"].
"-",
"", $obj->ref));
1181 if (str_replace(
"-",
"", $num_sale) > $max_sale) {
1182 $max_sale = str_replace(
"-",
"", $num_sale);
1184 echo
'\\\'; invoiceid=\\\'';
1186 echo
'\\\'; Refresh();">';
1187 if ($placeid == $obj->rowid) {
1188 echo
'<span class="basketselected">';
1190 echo
'<span class="basketnotselected">';
1192 echo
'<span class="fa fa-shopping-cart paddingright"></span>'.dol_print_date($db->jdate($obj->datec),
'%H:%M',
'tzuser');
1196 echo
'$("#shoppingcart").append(\'<a onclick="place=\\\'0-';
1198 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>\');';
1206 $constantforkey =
'CASHDESK_NO_DECREASE_STOCK'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1209 $constantforkey =
'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION[
"takeposterminal"]) ? $_SESSION[
"takeposterminal"] :
'');
1211 if ($idwarehouse > 0) {
1212 $s =
'<span class="small">';
1214 $warehouse->fetch($idwarehouse);
1215 $s .=
'<span class="hideonsmartphone">'.$langs->trans(
"Warehouse").
'<br></span>'.$warehouse->ref;
1217 $s .=
' ('.$langs->trans(
"Closed").
')';
1220 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1221 print
'$("#infowarehouse").css("display", "inline-block");';
1223 $s =
'<span class="small hideonsmartphone">';
1224 $s .= $langs->trans(
"StockChangeDisabled").
'<br>'.$langs->trans(
"NoWarehouseDefinedForTerminal");
1226 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1227 if (!empty($conf->dol_optimize_smallscreen)) {
1228 print
'$("#infowarehouse").css("display", "none");';
1232 $s =
'<span class="small hideonsmartphone">'.$langs->trans(
"StockChangeDisabled").
'</span>';
1233 print
"$('#infowarehouse').html('".dol_escape_js($s).
"');";
1234 if (!empty($conf->dol_optimize_smallscreen)) {
1235 print
'$("#infowarehouse").css("display", "none");';
1243 if (
isModEnabled(
'adherent') && $invoice->socid > 0 && $invoice->socid != $conf->global->$constforcompanyid) {
1244 $s =
'<span class="small">';
1245 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1246 $langs->load(
"members");
1247 $s .= $langs->trans(
"Member").
': ';
1249 $result = $adh->fetch(
'',
'', $invoice->socid);
1251 $adh->ref = $adh->getFullName($langs);
1255 $s .= $adh->getFullName($langs);
1256 $s .=
' - '.$adh->type;
1257 if ($adh->datefin) {
1258 $s .=
'<br>'.$langs->trans(
"SubscriptionEndDate").
': '.
dol_print_date($adh->datefin,
'day');
1259 if ($adh->hasDelay()) {
1260 $s .=
" ".img_warning($langs->trans(
"Late"));
1263 $s .=
'<br>'.$langs->trans(
"SubscriptionNotReceived");
1264 if ($adh->statut > 0) {
1265 $s .=
" ".img_warning($langs->trans(
"Late"));
1272 $s .=
'<br>'.$langs->trans(
"ThirdpartyNotLinkedToMember");
1277 $(
"#moreinfo").html(
'<?php print dol_escape_js($s); ?>');
1283 if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
1284 echo
"function CustomerDisplay(){";
1285 echo
"var line1='".$CUSTOMER_DISPLAY_line1.
"'.substring(0,20);";
1286 echo
"line1=line1.padEnd(20);";
1287 echo
"var line2='".$CUSTOMER_DISPLAY_line2.
"'.substring(0,20);";
1288 echo
"line2=line2.padEnd(20);";
1291 data: { text: line1+line2 },
1292 url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER').
"/display/index.php',
1303 if (!empty($conf->use_javascript_ajax)) {
1304 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
1305 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.
'"></script>'.
"\n";
1308 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";
1309 print
'<div class="div-table-responsive-no-min invoice">';
1310 print
'<table id="tablelines" class="noborder noshadow postablelines centpercent">';
1311 if ($sectionwithinvoicelink && ($mobilepage ==
"invoice" || $mobilepage ==
"")) {
1312 if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
1313 print
'<tr><td colspan="5">'.$sectionwithinvoicelink.
'</td></tr>';
1315 print
'<tr><td colspan="4">'.$sectionwithinvoicelink.
'</td></tr>';
1318 print
'<tr class="liste_titre nodrag nodrop">';
1319 print
'<td class="linecoldescription">';
1321 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1322 print
'<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.
'">';
1325 $sql =
"SELECT floor, label FROM ".MAIN_DB_PREFIX.
"takepos_floor_tables where rowid=".((int) $place);
1326 $resql = $db->query(
$sql);
1327 $obj = $db->fetch_object($resql);
1329 $label = $obj->label;
1330 $floor = $obj->floor;
1332 if ($mobilepage ==
"invoice" || $mobilepage ==
"") {
1335 print
'<span class="opacitymedium">'.$langs->trans(
'Place').
"</span> <b>".(empty($label) ?
'?' : $label).
"</b><br>";
1336 print
'<span class="opacitymedium">'.$langs->trans(
'Floor').
"</span> <b>".(empty($floor) ?
'?' : $floor).
"</b>";
1337 } elseif (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1339 } elseif ($mobilepage ==
"cats") {
1340 print $langs->trans(
'Category');
1341 } elseif ($mobilepage ==
"products") {
1342 print $langs->trans(
'Label');
1345 print $langs->trans(
"Products");
1350 $parameters=array();
1351 $reshook=$hookmanager->executeHooks(
'completeTakePosInvoiceHeader', $parameters, $invoice, $action);
1352 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1353 print $hookmanager->resPrint;
1355 if (empty($_SESSION[
"basiclayout"]) || $_SESSION[
"basiclayout"] != 1) {
1356 print
'<td class="linecolqty right">'.$langs->trans(
'ReductionShort').
'</td>';
1357 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
1359 print
'<td class="linecolht right nowraponall">';
1360 print
'<span class="opacitymedium small">' . $langs->trans(
'TotalHTShort') .
'</span><br>';
1362 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1363 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>';
1364 if (
isModEnabled(
'multicurrency') && $_SESSION[
"takeposcustomercurrency"] !=
"" && $conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
1366 include_once DOL_DOCUMENT_ROOT .
'/multicurrency/class/multicurrency.class.php';
1368 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
1369 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>';
1375 print
'<td class="linecolht right nowraponall">';
1376 print
'<span class="opacitymedium small">'.$langs->trans(
'TotalTTCShort').
'</span><br>';
1378 if (empty($mobilepage) || $mobilepage ==
"invoice") {
1379 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>';
1380 if (
isModEnabled(
'multicurrency') && !empty($_SESSION[
"takeposcustomercurrency"]) && $conf->currency != $_SESSION[
"takeposcustomercurrency"]) {
1382 include_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
1384 $multicurrency->fetch(0, $_SESSION[
"takeposcustomercurrency"]);
1385 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>';
1390 } elseif ($mobilepage ==
"invoice") {
1391 print
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
1396 if (!empty($_SESSION[
"basiclayout"]) && $_SESSION[
"basiclayout"] == 1) {
1397 if ($mobilepage ==
"cats") {
1398 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1400 $categories = $categorie->get_full_arbo(
'product');
1402 foreach ($categories as $row) {
1403 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1404 $htmlforlines .=
'<div class="leftcat';
1406 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline';
1408 $htmlforlines .=
'" onclick="LoadProducts('.$row[
'id'].
');">';
1409 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1410 $htmlforlines .=
'<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=cat&query=cat&id='.$row[
'id'].
'"><br>';
1412 $htmlforlines .=
'<td class="left">';
1414 $htmlforlines .= $row[
'label'];
1415 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1416 $htmlforlines .=
'</div>'.
"\n";
1418 $htmlforlines .=
'</td></tr>'.
"\n";
1421 $htmlforlines .=
'</table>';
1422 $htmlforlines .=
'</table>';
1423 print $htmlforlines;
1426 if ($mobilepage ==
"products") {
1427 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1429 $catid =
GETPOST(
'catid',
'int');
1430 $result = $object->fetch($catid);
1431 $prods = $object->getObjectsInCateg(
"product");
1433 foreach ($prods as $row) {
1434 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1435 $htmlforlines .=
'<div class="leftcat';
1437 $htmlforlines .=
'<tr class="drag drop oddeven posinvoiceline';
1439 $htmlforlines .=
'" onclick="AddProduct(\''.$place.
'\',
'.$row->id.')
">';
1440 if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1441 $htmlforlines .= '<img class="imgwrapper
" width="33%
" src="'.DOL_URL_ROOT.'/takepos/
public/auto_order.php?genimg=pro&query=pro&
id=
'.$row->id.'"><br>';
1442 $htmlforlines .= $row->label.' '.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency);
1443 $htmlforlines .= '</div>'."\n
";
1445 $htmlforlines .= '<td class="left
">';
1446 $htmlforlines .= $row->label;
1447 $htmlforlines .= '<div class="right
">'.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).'</div>';
1448 $htmlforlines .= '</tr>'."\n
";
1451 $htmlforlines .= '</table>';
1452 print $htmlforlines;
1455 if ($mobilepage == "places
") {
1456 $sql = "SELECT
rowid, entity, label, leftpos, toppos, floor FROM
".MAIN_DB_PREFIX."takepos_floor_tables
";
1457 $resql = $db->query($sql);
1460 while ($row = $db->fetch_array($resql)) {
1462 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
1463 $htmlforlines .= '" onclick="LoadPlace(\
''.$row[
'label'].
'\')
">';
1464 $htmlforlines .= '<td class="left
">';
1465 $htmlforlines .= $row['label'];
1466 $htmlforlines .= '</td>';
1467 $htmlforlines .= '</tr>'."\n
";
1469 $htmlforlines .= '</table>';
1470 print $htmlforlines;
1475 //In Phone basic layout hide some content depends situation
1476 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1 && $mobilepage != "invoice
" && $action != "order
") {
1480 if (is_array($invoice->lines) && count($invoice->lines)) {
1481 print '<!-- invoice.php show lines of invoices -->'."\n
";
1482 $tmplines = array_reverse($invoice->lines);
1483 $htmlsupplements = array();
1484 foreach ($tmplines as $line) {
1485 if ($line->fk_parent_line != false) {
1486 $htmlsupplements[$line->fk_parent_line] .= '<tr class="drag drop oddeven posinvoiceline
';
1487 if ($line->special_code == "4") {
1488 $htmlsupplements[$line->fk_parent_line] .= ' order
';
1490 $htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'"';
1491 if ($line->special_code == "4
") {
1492 $htmlsupplements[$line->fk_parent_line] .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
1494 $htmlsupplements[$line->fk_parent_line] .= '>';
1495 $htmlsupplements[$line->fk_parent_line] .= '<td class="left
">';
1496 $htmlsupplements[$line->fk_parent_line] .= img_picto('', 'rightarrow');
1497 if ($line->product_label) {
1498 $htmlsupplements[$line->fk_parent_line] .= $line->product_label;
1500 if ($line->product_label && $line->desc) {
1501 $htmlsupplements[$line->fk_parent_line] .= '<br>';
1503 if ($line->product_label != $line->desc) {
1504 $firstline = dolGetFirstLineOfText($line->desc);
1505 if ($firstline != $line->desc) {
1506 $htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
1508 $htmlsupplements[$line->fk_parent_line] .= $line->desc;
1511 $htmlsupplements[$line->fk_parent_line] .= '</td>';
1513 // complete line by hook
1514 $parameters=array('line' => $line);
1515 $reshook=$hookmanager->executeHooks('completeTakePosInvoiceParentLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
1516 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1517 $htmlsupplements[$line->fk_parent_line] .= $hookmanager->resPrint;
1519 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
1520 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.vatrate($line->remise_percent, true).'</td>';
1521 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.$line->qty.'</td>';
1522 $htmlsupplements[$line->fk_parent_line] .= '<td class="right
">'.price($line->total_ttc).'</td>';
1524 $htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n
";
1529 $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline
';
1530 if ($line->special_code == "4") {
1531 $htmlforlines .= ' order
';
1533 $htmlforlines .= '" id="'.$line->id.'"';
1534 if ($line->special_code == "4
") {
1535 $htmlforlines .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
1537 $htmlforlines .= '>';
1538 $htmlforlines .= '<td class="left
">';
1539 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
1540 $htmlforlines .= '<span class="phoneqty
">'.$line->qty."</span> x
";
1542 if (isset($line->product_type)) {
1543 if (empty($line->product_type)) {
1544 $htmlforlines .= img_object('', 'product').' ';
1546 $htmlforlines .= img_object('', 'service').' ';
1549 if (empty($conf->global->TAKEPOS_SHOW_N_FIRST_LINES)) {
1551 if ($line->product_ref) {
1552 $tooltiptext .= '<b>'.$langs->trans("Ref
").'</b> : '.$line->product_ref.'<br>';
1553 $tooltiptext .= '<b>'.$langs->trans("Label
").'</b> : '.$line->product_label.'<br>';
1554 if ($line->product_label != $line->desc) {
1556 $tooltiptext .= '<br>';
1558 $tooltiptext .= $line->desc;
1561 if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
1562 $htmlforlines .= $form->textwithpicto($line->product_label ? '<b>' . $line->product_ref . '</b> - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
1564 $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
1567 if ($line->product_label) {
1568 $htmlforlines .= $line->product_label;
1570 if ($line->product_label != $line->desc) {
1571 if ($line->product_label && $line->desc) {
1572 $htmlforlines .= '<br>';
1574 $firstline = dolGetFirstLineOfText($line->desc, $conf->global->TAKEPOS_SHOW_N_FIRST_LINES);
1575 if ($firstline != $line->desc) {
1576 $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
1578 $htmlforlines .= $line->desc;
1582 if (!empty($line->array_options['options_order_notes'])) {
1583 $htmlforlines .= "<br>(
".$line->array_options['options_order_notes'].")
";
1585 if (!empty($_SESSION["basiclayout
"]) && $_SESSION["basiclayout
"] == 1) {
1586 $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>';
1588 if (empty($_SESSION["basiclayout
"]) || $_SESSION["basiclayout
"] != 1) {
1590 $moreinfo .= $langs->transcountry("TotalHT
", $mysoc->country_code).': '.price($line->total_ht);
1591 if ($line->vat_src_code) {
1592 $moreinfo .= '<br>'.$langs->trans("VATCode
").': '.$line->vat_src_code;
1594 $moreinfo .= '<br>'.$langs->transcountry("TotalVAT
", $mysoc->country_code).': '.price($line->total_tva);
1595 $moreinfo .= '<br>'.$langs->transcountry("TotalLT1
", $mysoc->country_code).': '.price($line->total_localtax1);
1596 $moreinfo .= '<br>'.$langs->transcountry("TotalLT2
", $mysoc->country_code).': '.price($line->total_localtax2);
1597 $moreinfo .= '<hr>';
1598 $moreinfo .= $langs->transcountry("TotalTTC
", $mysoc->country_code).': '.price($line->total_ttc);
1599 //$moreinfo .= $langs->trans("TotalHT
").': '.$line->total_ht;
1600 if ($line->date_start || $line->date_end) {
1601 $htmlforlines .= '<br><div class="clearboth nowraponall
">'.get_date_range($line->date_start, $line->date_end).'</div>';
1603 $htmlforlines .= '</td>';
1605 // complete line by hook
1606 $parameters=array('line' => $line);
1607 $reshook=$hookmanager->executeHooks('completeTakePosInvoiceLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
1608 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1609 $htmlforlines .= $hookmanager->resPrint;
1611 $htmlforlines .= '<td class="right
">'.vatrate($line->remise_percent, true).'</td>';
1612 $htmlforlines .= '<td class="right
">';
1613 if (isModEnabled('stock') && !empty($user->rights->stock->mouvement->lire)) {
1614 $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal
"];
1615 if (!empty($conf->global->$constantforkey) && $line->fk_product > 0 && empty($conf->global->TAKEPOS_HIDE_STOCK_ON_LINE)) {
1616 $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp
";
1617 $sql .= " FROM
".MAIN_DB_PREFIX."entrepot as e,
";
1618 $sql .= " ".MAIN_DB_PREFIX."product_stock as ps
";
1619 $sql .= " LEFT JOIN
".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product
";
1620 $sql .= " WHERE ps.reel != 0
";
1621 $sql .= " AND ps.fk_entrepot =
".((int) $conf->global->$constantforkey);
1622 $sql .= " AND e.entity IN (
".getEntity('stock').")
";
1623 $sql .= " AND ps.fk_product =
".((int) $line->fk_product);
1624 $resql = $db->query($sql);
1626 $obj = $db->fetch_object($resql);
1627 $stock_real = price2num($obj->reel, 'MS');
1628 $htmlforlines .= $line->qty;
1629 if ($line->qty && $line->qty > $stock_real) {
1630 $htmlforlines .= '<span style="color: var(--amountremaintopaycolor)
">';
1632 $htmlforlines .= ' <span class="posstocktoolow
">('.$langs->trans("Stock
").' '.$stock_real.')</span>';
1633 if ($line->qty && $line->qty > $stock_real) {
1634 $htmlforlines .= "</span>
";
1637 dol_print_error($db);
1640 $htmlforlines .= $line->qty;
1643 $htmlforlines .= $line->qty;
1646 $htmlforlines .= '</td>';
1647 if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
1648 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
1649 $htmlforlines .= price($line->total_ht, 1, '', 1, -1, -1, $conf->currency);
1650 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
1651 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
1652 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
1653 $multicurrency = new MultiCurrency($db);
1654 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
1655 $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>';
1657 $htmlforlines .= '</td>';
1659 $htmlforlines .= '<td class="right classfortooltip
" title="'.$moreinfo.'">';
1660 $htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency);
1661 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency
"]) && $conf->currency != $_SESSION["takeposcustomercurrency
"]) {
1662 //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
1663 include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
1664 $multicurrency = new MultiCurrency($db);
1665 $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency
"]);
1666 $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>';
1668 $htmlforlines .= '</td>';
1670 $htmlforlines .= '</tr>'."\n
";
1671 $htmlforlines .= empty($htmlsupplements[$line->id]) ? '' : $htmlsupplements[$line->id];
1673 print $htmlforlines;
1676 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td><td></td><td></td>';
1677 if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
1682 } else { // No invoice generated yet
1683 print '<tr class="drag drop oddeven
"><td class="left
"><span class="opacitymedium
">'.$langs->trans("Empty
").'</span></td><td></td><td></td><td></td>';
1685 if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
1693 if (($action == "valid
" || $action == "history
") && $invoice->type != Facture::TYPE_CREDIT_NOTE && empty($conf->global->TAKEPOS_NO_CREDITNOTE)) {
1694 print '<button id="buttonprint
" type="button" onclick="ModalBox(\
'ModalCreditNote\')">'.$langs->trans(
'CreateCreditNote').
'</button>';
1696 print
' <a target="_blank" class="button" href="' . DOL_URL_ROOT .
'/document.php?token=' .
newToken() .
'&modulepart=facture&file=' . $invoice->ref .
'/' . $invoice->ref .
'.pdf">Invoice</a>';
1701 if ($action ==
"search") {
1703 <input type="text" id="search" class="input-nobottom" name="search" onkeyup="Search2(\'\', null);" style="width: 80%; font-size: 150%;" placeholder="'.dol_escape_htmltag($langs->trans(
'Search')).
'">
1710 if ((
getDolGlobalString(
'TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->layout ==
'phone') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1711 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.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
if(empty($user->rights->takepos->run) &&!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) if((getDolGlobalString('TAKEPOS_PHONE_BASIC_LAYOUT')==1 && $conf->browser->layout=='phone')||defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) fail($message)
Abort invoice creationg with a given error message.
if(!defined( '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.