dolibarr  18.0.6
invoice.php
Go to the documentation of this file.
1 <?php
26 // if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language
27 // if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language
28 // if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
29 // if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
30 
31 if (!defined('NOTOKENRENEWAL')) {
32  define('NOTOKENRENEWAL', '1');
33 }
34 if (!defined('NOREQUIREMENU')) {
35  define('NOREQUIREMENU', '1');
36 }
37 if (!defined('NOREQUIREHTML')) {
38  define('NOREQUIREHTML', '1');
39 }
40 if (!defined('NOREQUIREAJAX')) {
41  define('NOREQUIREAJAX', '1');
42 }
43 
44 // Load Dolibarr environment
45 if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
46  require '../main.inc.php';
47 }
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';
52 
53 $hookmanager->initHooks(array('takeposinvoice'));
54 
55 $langs->loadLangs(array("companies", "commercial", "bills", "cashdesk", "stocks", "banks"));
56 
57 $action = GETPOST('action', 'aZ09');
58 $idproduct = GETPOST('idproduct', 'int');
59 $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is id of table for Bar or Restaurant
60 $placeid = 0; // $placeid is ID of invoice
61 $mobilepage = GETPOST('mobilepage', 'alpha');
62 
63 // Terminal is stored into $_SESSION["takeposterminal"];
64 
65 if (empty($user->rights->takepos->run) && !defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
67 }
68 
69 if ((getDolGlobalString('TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->layout == 'phone') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
70  // DIRECT LINK TO THIS PAGE FROM MOBILE AND NO TERMINAL SELECTED
71  if ($_SESSION["takeposterminal"] == "") {
72  if (getDolGlobalString('TAKEPOS_NUM_TERMINALS') == "1") {
73  $_SESSION["takeposterminal"] = 1;
74  } else {
75  header("Location: ".DOL_URL_ROOT."/takepos/index.php");
76  exit;
77  }
78  }
79 }
80 
81 
88 function fail($message)
89 {
90  header($_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error', true, 500);
91  die($message);
92 }
93 
94 
95 
96 $number = GETPOST('number', 'alpha');
97 $idline = GETPOST('idline', 'int');
98 $selectedline = GETPOST('selectedline', 'int');
99 $desc = GETPOST('desc', 'alphanohtml');
100 $pay = GETPOST('pay', 'aZ09');
101 $amountofpayment = price2num(GETPOST('amount', 'alpha'));
102 
103 $invoiceid = GETPOST('invoiceid', 'int');
104 
105 $paycode = $pay;
106 if ($pay == 'cash') {
107  $paycode = 'LIQ'; // For backward compatibility
108 }
109 if ($pay == 'card') {
110  $paycode = 'CB'; // For backward compatibility
111 }
112 if ($pay == 'cheque') {
113  $paycode = 'CHQ'; // For backward compatibility
114 }
115 
116 // Retrieve paiementid
117 $paiementid = 0;
118 if ($paycode) {
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);
123  if ($resql) {
124  $obj = $db->fetch_object($resql);
125  if ($obj) {
126  $paiementid = $obj->id;
127  }
128  }
129 }
130 
131 $invoice = new Facture($db);
132 if ($invoiceid > 0) {
133  $ret = $invoice->fetch($invoiceid);
134 } else {
135  $ret = $invoice->fetch('', '(PROV-POS'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '') .'-'.$place.')');
136 }
137 if ($ret > 0) {
138  $placeid = $invoice->id;
139 }
140 
141 $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '');
142 
143 $soc = new Societe($db);
144 if ($invoice->socid > 0) {
145  $soc->fetch($invoice->socid);
146 } else {
147  $soc->fetch(getDolGlobalString("$constforcompanyid"));
148 }
149 
150 // Change the currency of invoice if it was modified
151 if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency"])) {
152  if ($invoice->multicurrency_code != $_SESSION["takeposcustomercurrency"]) {
153  $invoice->setMulticurrencyCode($_SESSION["takeposcustomercurrency"]);
154  }
155 }
156 
157 
158 /*
159  * Actions
160  */
161 
162 $parameters=array();
163 $reshook=$hookmanager->executeHooks('doActions', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
164 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
165 
166 if (empty($reshook)) {
167  // Action to record a payment on a TakePOS invoice
168  if ($action == 'valid' && $user->hasRight('facture', 'creer')) {
169  $bankaccount = 0;
170  $error = 0;
171 
172  if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) {
173  $bankaccount = GETPOST('accountid', 'int');
174  } else {
175  if ($pay == 'LIQ') {
176  $bankaccount = getDolGlobalString('CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]); // For backward compatibility
177  } elseif ($pay == "CHQ") {
178  $bankaccount = getDolGlobalString('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]); // For backward compatibility
179  } else {
180  $accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"];
181  $bankaccount = getDolGlobalString($accountname);
182  }
183  }
184 
185  if ($bankaccount <= 0 && $pay != "delayed" && isModEnabled("banque")) {
186  $errormsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount"));
187  $error++;
188  }
189 
190  $now = dol_now();
191  $res = 0;
192 
193  $invoice = new Facture($db);
194  $invoice->fetch($placeid);
195 
196  if ($invoice->total_ttc < 0) {
197  $invoice->type = $invoice::TYPE_CREDIT_NOTE;
198 
199  $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture";
200  $sql .= " WHERE entity IN (".getEntity('invoice').")";
201  $sql .= " AND fk_soc = ".((int) $invoice->socid);
202  $sql .= " AND type <> ".Facture::TYPE_CREDIT_NOTE;
203  $sql .= " AND fk_statut >= ".$invoice::STATUS_VALIDATED;
204  $sql .= " ORDER BY rowid DESC";
205 
206  $resql = $db->query($sql);
207  if ($resql) {
208  $obj = $db->fetch_object($resql);
209  $fk_source = $obj->rowid;
210  if ($fk_source == null) {
211  fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer"));
212  }
213  } else {
214  fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer"));
215  }
216  $invoice->fk_facture_source = $fk_source;
217  $invoice->update($user);
218  }
219 
220  $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"];
221  if ($error) {
222  dol_htmloutput_errors($errormsg, null, 1);
223  } elseif ($invoice->statut != Facture::STATUS_DRAFT) {
224  //If invoice is validated but it is not fully paid is not error and make the payment
225  if ($invoice->getRemainToPay() > 0) {
226  $res = 1;
227  } else {
228  dol_syslog("Sale already validated");
229  dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1);
230  }
231  } elseif (count($invoice->lines) == 0) {
232  $error++;
233  dol_syslog('Sale without lines');
234  dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1);
235  } elseif (isModEnabled('stock') && $conf->global->$constantforkey != "1") {
236  $savconst = $conf->global->STOCK_CALCULATE_ON_BILL;
237 
238  if (isModEnabled('productbatch') && !getDolGlobalInt('CASHDESK_FORCE_DECREASE_STOCK')) {
239  $conf->global->STOCK_CALCULATE_ON_BILL = 0; // To not change the stock (not yet compatible with batch management)
240  } else {
241  $conf->global->STOCK_CALCULATE_ON_BILL = 1; // To force the change of stock
242  }
243 
244  $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
245  dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey);
246  $batch_rule = 0;
247  if (isModEnabled('productbatch') && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) {
248  require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
250  }
251  $res = $invoice->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule);
252 
253  $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
254  } else {
255  $res = $invoice->validate($user);
256  if ($res < 0) {
257  $error++;
258  $langs->load("admin");
259  dol_htmloutput_errors($invoice->error == 'NotConfigured' ? $langs->trans("NotConfigured").' (TakePos numbering module)': $invoice->error, $invoice->errors, 1);
260  }
261  }
262 
263  // Restore save values
264  //if (!empty($sav_FACTURE_ADDON))
265  //{
266  // $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON;
267  //}
268 
269  // Add the payment
270  if (!$error && $res >= 0) {
271  $remaintopay = $invoice->getRemainToPay();
272  if ($remaintopay > 0) {
273  $payment = new Paiement($db);
274  $payment->datepaye = $now;
275  $payment->fk_account = $bankaccount;
276  $payment->amounts[$invoice->id] = $amountofpayment;
277  if ($pay == 'LIQ') {
278  $payment->pos_change = price2num(GETPOST('excess', 'alpha'));
279  }
280 
281  // If user has not used change control, add total invoice payment
282  // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay
283  if ($amountofpayment <= 0 || $amountofpayment > $remaintopay) {
284  $payment->amounts[$invoice->id] = $remaintopay;
285  }
286 
287  $payment->paiementid = $paiementid;
288  $payment->num_payment = $invoice->ref;
289 
290  if ($pay != "delayed") {
291  $payment->create($user);
292  $res = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
293  if ($res < 0) {
294  $error++;
295  dol_htmloutput_errors($langs->trans('ErrorNoPaymentDefined'), $payment->errors, 1);
296  }
297  $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded
298  } elseif (getDolGlobalInt("TAKEPOS_DELAYED_TERMS")) {
299  $invoice->setPaymentTerms(getDolGlobalInt("TAKEPOS_DELAYED_TERMS"));
300  }
301  }
302 
303  if ($remaintopay == 0) {
304  dol_syslog("Invoice is paid, so we set it to status Paid");
305  $result = $invoice->setPaid($user);
306  if ($result > 0) {
307  $invoice->paye = 1;
308  }
309  // set payment method
310  $invoice->setPaymentMethods($paiementid);
311  } else {
312  dol_syslog("Invoice is not paid, remain to pay = ".$remaintopay);
313  }
314  } else {
315  dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
316  }
317  }
318 
319  if ($action == 'creditnote' && $user->hasRight('facture', 'creer')) {
320  $creditnote = new Facture($db);
321  $creditnote->socid = $invoice->socid;
322  $creditnote->date = dol_now();
323  $creditnote->module_source = 'takepos';
324  $creditnote->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ;
325  $creditnote->type = Facture::TYPE_CREDIT_NOTE;
326  $creditnote->fk_facture_source = $placeid;
327  $creditnote->remise_absolue = $invoice->remise_absolue;
328  $creditnote->remise_percent = $invoice->remise_percent;
329  $creditnote->create($user);
330 
331  foreach ($invoice->lines as $line) {
332  // Extrafields
333  if (method_exists($line, 'fetch_optionals')) {
334  // load extrafields
335  $line->fetch_optionals();
336  }
337  // Reset fk_parent_line for no child products and special product
338  if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
339  $fk_parent_line = 0;
340  }
341 
342  if (getDolGlobalInt('INVOICE_USE_SITUATION')) {
343  if (!empty($invoice->situation_counter)) {
344  $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id
345  $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from
346  if (!empty($invoice->tab_previous_situation_invoice)) {
347  // search the last standard invoice in cycle and the possible credit note between this last and invoice
348  // TODO Move this out of loop of $invoice->lines
349  $tab_jumped_credit_notes = array();
350  $lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
351  $searchPreviousInvoice = true;
352  while ($searchPreviousInvoice) {
353  if ($invoice->tab_previous_situation_invoice[$lineIndex]->situation_cycle_ref || $lineIndex < 1) {
354  $searchPreviousInvoice = false; // find, exit;
355  break;
356  } else {
357  if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) {
358  $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id;
359  }
360  $lineIndex--; // go to previous invoice in cycle
361  }
362  }
363 
364  $maxPrevSituationPercent = 0;
365  foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
366  if ($prevLine->id == $source_fk_prev_id) {
367  $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
368 
369  //$line->subprice = $line->subprice - $prevLine->subprice;
370  $line->total_ht = $line->total_ht - $prevLine->total_ht;
371  $line->total_tva = $line->total_tva - $prevLine->total_tva;
372  $line->total_ttc = $line->total_ttc - $prevLine->total_ttc;
373  $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1;
374  $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2;
375 
376  $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice;
377  $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht;
378  $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva;
379  $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc;
380  }
381  }
382 
383  // prorata
384  $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
385 
386  //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'<br>';
387 
388  // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta)
389  $maxPrevSituationPercent = 0;
390  foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
391  foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) {
392  if ($prevLine->fk_prev_id == $source_fk_prev_id) {
393  $maxPrevSituationPercent = $prevLine->situation_percent;
394 
395  $line->total_ht -= $prevLine->total_ht;
396  $line->total_tva -= $prevLine->total_tva;
397  $line->total_ttc -= $prevLine->total_ttc;
398  $line->total_localtax1 -= $prevLine->total_localtax1;
399  $line->total_localtax2 -= $prevLine->total_localtax2;
400 
401  $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
402  $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
403  $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
404  $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
405  }
406  }
407  }
408 
409  // prorata
410  $line->situation_percent += $maxPrevSituationPercent;
411 
412  //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'<br>';
413  }
414  }
415  }
416 
417  $line->fk_facture = $creditnote->id;
418  $line->fk_parent_line = $fk_parent_line;
419 
420  $line->subprice = -$line->subprice; // invert price for object
421  $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here
422  $line->total_ht = -$line->total_ht;
423  $line->total_tva = -$line->total_tva;
424  $line->total_ttc = -$line->total_ttc;
425  $line->total_localtax1 = -$line->total_localtax1;
426  $line->total_localtax2 = -$line->total_localtax2;
427 
428  $line->multicurrency_subprice = -$line->multicurrency_subprice;
429  $line->multicurrency_total_ht = -$line->multicurrency_total_ht;
430  $line->multicurrency_total_tva = -$line->multicurrency_total_tva;
431  $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
432 
433  $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked
434 
435  $creditnote->lines[] = $line; // insert new line in current object
436 
437  // Defined the new fk_parent_line
438  if ($result > 0 && $line->product_type == 9) {
439  $fk_parent_line = $result;
440  }
441  }
442  $creditnote->update_price(1);
443 
444  $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"];
445  if (isModEnabled('stock') && $conf->global->$constantforkey != "1") {
446  $savconst = $conf->global->STOCK_CALCULATE_ON_BILL;
447  $conf->global->STOCK_CALCULATE_ON_BILL = 1;
448  $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
449  dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey);
450  $batch_rule = 0;
451  if (isModEnabled('productbatch') && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) {
452  require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
454  }
455  $res = $creditnote->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule);
456  $conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
457  } else {
458  $res = $creditnote->validate($user);
459  }
460  }
461 
462  if ($action == 'history' || $action == 'creditnote') {
463  if ($action == 'creditnote') {
464  $placeid = $creditnote->id;
465  } else {
466  $placeid = (int) GETPOST('placeid', 'int');
467  }
468  $invoice = new Facture($db);
469  $invoice->fetch($placeid);
470  }
471 
472  // If we add a line and no invoice yet, we create the invoice
473  if (($action == "addline" || $action == "freezone") && $placeid == 0) {
474  $invoice->socid = getDolGlobalString($constforcompanyid);
475  $invoice->date = dol_now('tzuserrel'); // We use the local date, only the day will be saved.
476  $invoice->module_source = 'takepos';
477  $invoice->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ;
478  $invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity;
479 
480  if ($invoice->socid <= 0) {
481  $langs->load('errors');
482  dol_htmloutput_errors($langs->trans("ErrorModuleSetupNotComplete", "TakePos"), null, 1);
483  } else {
484  // Create invoice
485  $placeid = $invoice->create($user);
486  if ($placeid < 0) {
487  dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
488  }
489  $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid = ".((int) $placeid);
490  $db->query($sql);
491  }
492  }
493 
494  if ($action == "addline") {
495  $prod = new Product($db);
496  $prod->fetch($idproduct);
497 
498  $customer = new Societe($db);
499  $customer->fetch($invoice->socid);
500 
501  $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
502 
503  $qty = GETPOSTISSET('qty') ? GETPOST('qty', 'int') : 1;
504  $price = $datapriceofproduct['pu_ht'];
505  $price_ttc = $datapriceofproduct['pu_ttc'];
506  //$price_min = $datapriceofproduct['price_min'];
507  $price_base_type = empty($datapriceofproduct['price_base_type']) ? 'HT' : $datapriceofproduct['price_base_type'];
508  $tva_tx = $datapriceofproduct['tva_tx'];
509  $tva_npr = $datapriceofproduct['tva_npr'];
510 
511  // Local Taxes
512  $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
513  $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
514 
515  if (!empty($conf->global->TAKEPOS_SUPPLEMENTS)) {
516  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
517  $cat = new Categorie($db);
518  $categories = $cat->containing($idproduct, 'product');
519  $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories, 'id')));
520  if ($found !== false) { // If this product is a supplement
521  $sql = "SELECT fk_parent_line FROM ".MAIN_DB_PREFIX."facturedet where rowid=$selectedline";
522  $resql = $db->query($sql);
523  $row = $db->fetch_array($resql);
524  if ($row[0] == null) {
525  $parent_line = $selectedline;
526  } else {
527  $parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product
528  }
529  }
530  }
531 
532  $idoflineadded = 0;
533  // Group if enabled. Skip group if line already sent to the printer
534  if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT)) {
535  foreach ($invoice->lines as $line) {
536  if ($line->product_ref == $prod->ref) {
537  if ($line->special_code==4) continue; // If this line is sended to printer create new line
538  $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty + $qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
539  if ($result < 0) {
540  dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
541  } else {
542  $idoflineadded = $line->id;
543  }
544  break;
545  }
546  }
547  }
548  if ($idoflineadded <= 0) {
549  $invoice->fetch_thirdparty();
550  $array_options = array();
551 
552  $line = array('description' => $prod->description, 'price' => $price, 'tva_tx' => $tva_tx, 'localtax1_tx' => $localtax1_tx, 'localtax2_tx' => $localtax2_tx, 'remise_percent' => $customer->remise_percent, 'price_ttc' => $price_ttc, 'array_options' => $array_options);
553 
554  /* setup of margin calculation */
555  if (isset($conf->global->MARGIN_TYPE)) {
556  if ($conf->global->MARGIN_TYPE == 'pmp' && !empty($prod->pmp)) {
557  $line['fk_fournprice'] = null;
558  $line['pa_ht'] = $prod->pmp;
559  } elseif ($conf->global->MARGIN_TYPE == 'costprice' && !empty($prod->cost_price)) {
560  $line['fk_fournprice'] = null;
561  $line['pa_ht'] = $prod->cost_price;
562  } else {
563  // default is fournprice
564  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
565  $pf = new ProductFournisseur($db);
566  if ($pf->find_min_price_product_fournisseur($idproduct, $qty) > 0) {
567  $line['fk_fournprice'] = $pf->product_fourn_price_id;
568  $line['pa_ht'] = $pf->fourn_unitprice_with_discount;
569  if (getDolGlobalString('PRODUCT_CHARGES') && $pf->fourn_charges > 0)
570  $line['pa_ht'] += $pf->fourn_charges / $pf->fourn_qty;
571  }
572  }
573  }
574 
575  // complete line by hook
576  $parameters = array('prod' => $prod, 'line' => $line);
577  $reshook=$hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action); // Note that $action and $line may have been modified by some hooks
578  if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
579 
580 
581  if (empty($reshook)) {
582  if (!empty($hookmanager->resArray)) {
583  $line = $hookmanager->resArray;
584  }
585 
586  $idoflineadded = $invoice->addline($line['description'], $line['price'], $qty, $line['tva_tx'], $line['localtax1_tx'], $line['localtax2_tx'], $idproduct, $line['remise_percent'], '', 0, 0, 0, '', $price_base_type, $line['price_ttc'], $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', $line['fk_fournprice'], $line['pa_ht'], '', $line['array_options'], 100, '', null, 0);
587  }
588 
589  if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
590  $CUSTOMER_DISPLAY_line1 = $prod->label;
591  $CUSTOMER_DISPLAY_line2 = price($price_ttc);
592  }
593  }
594 
595  $invoice->fetch($placeid);
596  }
597 
598  if ($action == "freezone") {
599  $customer = new Societe($db);
600  $customer->fetch($invoice->socid);
601 
602  $tva_tx = GETPOST('tva_tx', 'alpha');
603  if ($tva_tx != '') {
604  if (!preg_match('/\‍((.*)\‍)/', $tva_tx)) {
605  $tva_tx = price2num($tva_tx);
606  }
607  } else {
608  $tva_tx = get_default_tva($mysoc, $customer);
609  }
610 
611  // Local Taxes
612  $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
613  $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
614 
615  $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', getDolGlobalInt('TAKEPOS_DISCOUNT_TTC') ? ($number >= 0 ? 'HT' : 'TTC') : (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') ? 'HT' : 'TTC'), $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0);
616  $invoice->fetch($placeid);
617  }
618 
619  if ($action == "addnote") {
620  $desc = GETPOST('addnote', 'alpha');
621  if ($idline==0) {
622  $invoice->update_note($desc, '_public');
623  } else foreach ($invoice->lines as $line) {
624  if ($line->id == $idline) {
625  $result = $invoice->updateline($line->id, $desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
626  }
627  }
628  $invoice->fetch($placeid);
629  }
630 
631  if ($action == "deleteline") {
632  if ($idline > 0 and $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected.
633  $invoice->deleteline($idline);
634  $invoice->fetch($placeid);
635  } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line.
636  $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture = ".((int) $placeid)." ORDER BY rowid DESC";
637  $resql = $db->query($sql);
638  $row = $db->fetch_array($resql);
639  $deletelineid = $row[0];
640  $invoice->deleteline($deletelineid);
641  $invoice->fetch($placeid);
642  }
643  if (count($invoice->lines) == 0) {
644  $invoice->delete($user);
645  header("Location: ".DOL_URL_ROOT."/takepos/invoice.php");
646  exit;
647  }
648  }
649 
650  // Action to delete or discard an invoice
651  if ($action == "delete") {
652  // $placeid is the invoice id (it differs from place) and is defined if the place is set and the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')', so the fetch at begining of page works.
653  if ($placeid > 0) {
654  $result = $invoice->fetch($placeid);
655 
656  if ($result > 0 && $invoice->statut == Facture::STATUS_DRAFT) {
657  $db->begin();
658 
659  // We delete the lines
660  $resdeletelines = 1;
661  foreach ($invoice->lines as $line) {
662  $tmpres = $invoice->deleteline($line->id);
663  if ($tmpres < 0) {
664  $resdeletelines = 0;
665  break;
666  }
667  }
668 
669  $sql = "UPDATE ".MAIN_DB_PREFIX."facture";
670  $varforconst = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
671  $sql .= " SET fk_soc = ".((int) $conf->global->$varforconst).", ";
672  $sql .= " datec = '".$db->idate(dol_now())."'";
673  $sql .= " WHERE entity IN (".getEntity('invoice').")";
674  $sql .= " AND ref = '(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'";
675  $resql1 = $db->query($sql);
676 
677  if ($resdeletelines && $resql1) {
678  $db->commit();
679  } else {
680  $db->rollback();
681  }
682 
683  $invoice->fetch($placeid);
684  }
685  }
686  }
687 
688  if ($action == "updateqty") {
689  foreach ($invoice->lines as $line) {
690  if ($line->id == $idline) {
691  if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code == "4")) {
692  dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1);
693  } else {
694  $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
695  }
696  }
697  }
698 
699  $invoice->fetch($placeid);
700  }
701 
702  if ($action == "updateprice") {
703  $customer = new Societe($db);
704  $customer->fetch($invoice->socid);
705 
706  foreach ($invoice->lines as $line) {
707  if ($line->id == $idline) {
708  $prod = new Product($db);
709  $prod->fetch($line->fk_product);
710  $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
711  $price_min = $datapriceofproduct['price_min'];
712  $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
713  $pu_ht = price2num($number / (1 + ($line->tva_tx / 100)), 'MU');
714  //Check min price
715  if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($line->remise_percent) / 100) < price2num($price_min)))) {
716  $langs->load("products");
717  dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
718  //echo $langs->trans("CantBeLessThanMinPrice");
719  } else {
720  if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) {
721  dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1);
722  } elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) {
723  $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
724  } else {
725  $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
726  }
727  }
728  }
729  }
730 
731  // Reload data
732  $invoice->fetch($placeid);
733  }
734 
735  if ($action == "updatereduction") {
736  $customer = new Societe($db);
737  $customer->fetch($invoice->socid);
738 
739  foreach ($invoice->lines as $line) {
740  if ($line->id == $idline) {
741  dol_syslog("updatereduction Process line ".$line->id.' to apply discount of '.$number.'%');
742 
743  $prod = new Product($db);
744  $prod->fetch($line->fk_product);
745 
746  $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0);
747  $price_min = $datapriceofproduct['price_min'];
748  $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
749 
750  $pu_ht = price2num($line->subprice / (1 + ($line->tva_tx / 100)), 'MU');
751 
752  // Check min price
753  if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($line->subprice) * (1 - price2num($number) / 100) < price2num($price_min)))) {
754  $langs->load("products");
755  dol_htmloutput_errors($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)));
756  } else {
757  if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) {
758  dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1);
759  } else {
760  $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
761  }
762  }
763  }
764  }
765 
766  // Reload data
767  $invoice->fetch($placeid);
768  } elseif ($action == 'update_reduction_global') {
769  foreach ($invoice->lines as $line) {
770  $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
771  }
772 
773  $invoice->fetch($placeid);
774  }
775 
776  if ($action == "order" and $placeid != 0) {
777  include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
778  if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") {
779  require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
780  $printer = new dolReceiptPrinter($db);
781  }
782 
783  $sql = "SELECT label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place);
784  $resql = $db->query($sql);
785  $row = $db->fetch_object($resql);
786  $headerorder = '<html><br><b>'.$langs->trans('Place').' '.$row->label.'<br><table width="65%"><thead><tr><th class="left">'.$langs->trans("Label").'</th><th class="right">'.$langs->trans("Qty").'</th></tr></thead><tbody>';
787  $footerorder = '</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>';
788  $order_receipt_printer1 = "";
789  $order_receipt_printer2 = "";
790  $order_receipt_printer3 = "";
791  $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1);
792  $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2);
793  $catsprinter3 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3);
794  $linestoprint = 0;
795  foreach ($invoice->lines as $line) {
796  if ($line->special_code == "4") {
797  continue;
798  }
799  $c = new Categorie($db);
800  $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
801  $result = array_intersect($catsprinter1, $existing);
802  $count = count($result);
803  if (!$line->fk_product) {
804  $count++; // Print Free-text item (Unassigned printer) to Printer 1
805  }
806  if ($count > 0) {
807  $linestoprint++;
808  $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1
809  $db->query($sql);
810  $order_receipt_printer1 .= '<tr><td class="left">';
811  if ($line->fk_product) {
812  $order_receipt_printer1 .= $line->product_label;
813  } else {
814  $order_receipt_printer1 .= $line->description;
815  }
816  $order_receipt_printer1 .= '</td><td class="right">'.$line->qty;
817  if (!empty($line->array_options['options_order_notes'])) {
818  $order_receipt_printer1 .= "<br>(".$line->array_options['options_order_notes'].")";
819  }
820  $order_receipt_printer1 .= '</td></tr>';
821  }
822  }
823  if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) {
824  $invoice->fetch($placeid); //Reload object before send to printer
825  $printer->orderprinter = 1;
826  echo "<script>";
827  echo "var orderprinter1esc='";
828  $ret = $printer->sendToPrinter($invoice, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]), getDolGlobalInt('TAKEPOS_ORDER_PRINTER1_TO_USE'.$_SESSION["takeposterminal"])); // PRINT TO PRINTER 1
829  echo "';</script>";
830  }
831  $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed
832  $db->query($sql);
833  $invoice->fetch($placeid); //Reload object after set lines as printed
834  $linestoprint = 0;
835 
836  foreach ($invoice->lines as $line) {
837  if ($line->special_code == "4") {
838  continue;
839  }
840  $c = new Categorie($db);
841  $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
842  $result = array_intersect($catsprinter2, $existing);
843  $count = count($result);
844  if ($count > 0) {
845  $linestoprint++;
846  $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2
847  $db->query($sql);
848  $order_receipt_printer2 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty;
849  if (!empty($line->array_options['options_order_notes'])) {
850  $order_receipt_printer2 .= "<br>(".$line->array_options['options_order_notes'].")";
851  }
852  $order_receipt_printer2 .= '</td></tr>';
853  }
854  }
855  if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) {
856  $invoice->fetch($placeid); //Reload object before send to printer
857  $printer->orderprinter = 2;
858  echo "<script>";
859  echo "var orderprinter2esc='";
860  $ret = $printer->sendToPrinter($invoice, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]), getDolGlobalInt('TAKEPOS_ORDER_PRINTER2_TO_USE'.$_SESSION["takeposterminal"])); // PRINT TO PRINTER 2
861  echo "';</script>";
862  }
863  $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed
864  $db->query($sql);
865  $invoice->fetch($placeid); //Reload object after set lines as printed
866  $linestoprint = 0;
867 
868  foreach ($invoice->lines as $line) {
869  if ($line->special_code == "4") {
870  continue;
871  }
872  $c = new Categorie($db);
873  $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
874  $result = array_intersect($catsprinter3, $existing);
875  $count = count($result);
876  if ($count > 0) {
877  $linestoprint++;
878  $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=".$line->id; //Set to print on printer 3
879  $db->query($sql);
880  $order_receipt_printer3 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty;
881  if (!empty($line->array_options['options_order_notes'])) {
882  $order_receipt_printer3 .= "<br>(".$line->array_options['options_order_notes'].")";
883  }
884  $order_receipt_printer3 .= '</td></tr>';
885  }
886  }
887  if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) {
888  $invoice->fetch($placeid); //Reload object before send to printer
889  $printer->orderprinter = 3;
890  echo "<script>";
891  echo "var orderprinter3esc='";
892  $ret = $printer->sendToPrinter($invoice, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]), getDolGlobalInt('TAKEPOS_ORDER_PRINTER3_TO_USE'.$_SESSION["takeposterminal"])); // PRINT TO PRINTER 3
893  echo "';</script>";
894  }
895  $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id; // Set as printed
896  $db->query($sql);
897  $invoice->fetch($placeid); //Reload object after set lines as printed
898  }
899 
900  $sectionwithinvoicelink = '';
901  if ($action == "valid" || $action == "history" || $action == 'creditnote') {
902  $sectionwithinvoicelink .= '<!-- Section with invoice link -->'."\n";
903  $sectionwithinvoicelink .= '<span style="font-size:120%;" class="center">';
904  $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - ";
905  $remaintopay = $invoice->getRemainToPay();
906  if ($remaintopay > 0) {
907  $sectionwithinvoicelink .= $langs->trans('RemainToPay').': <span class="amountremaintopay" style="font-size: unset">'.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
908  } else {
909  if ($invoice->paye) {
910  $sectionwithinvoicelink .= '<span class="amountpaymentcomplete" style="font-size: unset">'.$langs->trans("Paid").'</span>';
911  } else {
912  $sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated');
913  }
914  }
915  $sectionwithinvoicelink .= '</span><br>';
916  if (getDolGlobalInt('TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
917  $sectionwithinvoicelink .= ' <a target="_blank" class="button" href="' . DOL_URL_ROOT . '/document.php?token=' . newToken() . '&modulepart=facture&file=' . $invoice->ref . '/' . $invoice->ref . '.pdf">Invoice</a>';
918  } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
919  if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
920  $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="TakeposConnector('.$placeid.')">'.$langs->trans('PrintTicket').'</button>';
921  } else {
922  $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="TakeposPrinting('.$placeid.')">'.$langs->trans('PrintTicket').'</button>';
923  }
924  } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") {
925  $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="DolibarrTakeposPrinting('.$placeid.')">'.$langs->trans('PrintTicket').'</button>';
926  } else {
927  $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="Print('.$placeid.')">'.$langs->trans('PrintTicket').'</button>';
928  if (getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) {
929  $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="PrintBox('.$placeid.', \'without_details\')">'.$langs->trans('PrintWithoutDetails').'</button>';
930  }
931  if (getDolGlobalString('TAKEPOS_GIFT_RECEIPT')) {
932  $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="Print('.$placeid.', 1)">'.$langs->trans('GiftReceipt').'</button>';
933  }
934  }
935  if (getDolGlobalString('TAKEPOS_EMAIL_TEMPLATE_INVOICE') && $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) {
936  $sectionwithinvoicelink .= ' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.')">'.$langs->trans('SendTicket').'</button>';
937  }
938 
939  if ($remaintopay <= 0 && getDolGlobalString('TAKEPOS_AUTO_PRINT_TICKETS') && $action != "history") {
940  $sectionwithinvoicelink .= '<script type="text/javascript">$("#buttonprint").click();</script>';
941  }
942  }
943 }
944 
945 /*
946  * View
947  */
948 
949 $form = new Form($db);
950 
951 // llxHeader
952 if ((getDolGlobalString('TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->layout == 'phone') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
953  $title = 'TakePOS - Dolibarr '.DOL_VERSION;
954  if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
955  $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
956  }
957  $head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/>
958  <meta name="apple-mobile-web-app-capable" content="yes">
959  <meta name="mobile-web-app-capable" content="yes">
960  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
961  $arrayofcss = array(
962  '/takepos/css/pos.css.php',
963  );
964  $arrayofjs = array('/takepos/js/jquery.colorbox-min.js');
965  $disablejs = 0;
966  $disablehead = 0;
967  top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
968 
969  print '<body>'."\n";
970 } else {
971  top_httphead('text/html', 1);
972 }
973 
974 ?>
975 <!-- invoice.php -->
976 <script type="text/javascript">
977 var selectedline=0;
978 var selectedtext="";
979 <?php if ($action=="valid") echo "var place=0;";?> // Set to default place after close sale
980 var placeid=<?php echo ($placeid > 0 ? $placeid : 0); ?>;
981 $(document).ready(function() {
982  var idoflineadded = <?php echo (empty($idoflineadded) ? 0 : $idoflineadded); ?>;
983 
984  $('.posinvoiceline').click(function(){
985  console.log("Click done on "+this.id);
986  $('.posinvoiceline').removeClass("selected");
987  $(this).addClass("selected");
988  if (selectedline==this.id) return; // If is already selected
989  else selectedline=this.id;
990  selectedtext=$('#'+selectedline).find("td:first").html();
991  <?php
992  if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
993  print '$("#phonediv1").load("auto_order.php?action=editline&token='.newToken().'&placeid="+placeid+"&selectedline="+selectedline, function() {
994  });';
995  }
996  ?>
997  });
998 
999  /* Autoselect the line */
1000  if (idoflineadded > 0)
1001  {
1002  console.log("Auto select "+idoflineadded);
1003  $('.posinvoiceline#'+idoflineadded).click();
1004  }
1005 <?php
1006 
1007 if ($action == "order" && !empty($order_receipt_printer1)) {
1008  if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1009  ?>
1010  $.ajax({
1011  type: "POST",
1012  url: '<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php',
1013  data: 'invoice='+orderprinter1esc
1014  });
1015  <?php
1016  } else {
1017  ?>
1018  $.ajax({
1019  type: "POST",
1020  url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
1021  data: '<?php
1022  print $headerorder.$order_receipt_printer1.$footerorder; ?>'
1023  });
1024  <?php
1025  }
1026 }
1027 
1028 if ($action == "order" && !empty($order_receipt_printer2)) {
1029  if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1030  ?>
1031  $.ajax({
1032  type: "POST",
1033  url: '<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=2',
1034  data: 'invoice='+orderprinter2esc
1035  });
1036  <?php
1037  } else {
1038  ?>
1039  $.ajax({
1040  type: "POST",
1041  url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print2',
1042  data: '<?php
1043  print $headerorder.$order_receipt_printer2.$footerorder; ?>'
1044  });
1045  <?php
1046  }
1047 }
1048 
1049 if ($action == "order" && !empty($order_receipt_printer3)) {
1050  if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
1051  ?>
1052  $.ajax({
1053  type: "POST",
1054  url: '<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=3',
1055  data: 'invoice='+orderprinter3esc
1056  });
1057  <?php
1058  }
1059 }
1060 
1061 // Set focus to search field
1062 if ($action == "search" || $action == "valid") {
1063  ?>
1064  parent.setFocusOnSearchField();
1065  <?php
1066 }
1067 
1068 
1069 if ($action == "temp" && !empty($ticket_printer1)) {
1070  ?>
1071  $.ajax({
1072  type: "POST",
1073  url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
1074  data: '<?php
1075  print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>'
1076  });
1077  <?php
1078 }
1079 
1080 if ($action == "search") {
1081  ?>
1082  $('#search').focus();
1083  <?php
1084 }
1085 
1086 ?>
1087 
1088 });
1089 
1090 function SendTicket(id)
1091 {
1092  console.log("Open box to select the Print/Send form");
1093  $.colorbox({href:"send.php?facid="+id, width:"70%", height:"30%", transition:"none", iframe:"true", title:'<?php echo dol_escape_js($langs->trans("SendTicket")); ?>'});
1094  return true;
1095 }
1096 
1097 function PrintBox(id, action) {
1098  console.log("Open box before printing");
1099  $.colorbox({href:"printbox.php?facid="+id+"&action="+action+"&token=<?php echo newToken(); ?>", width:"80%", height:"200px", transition:"none", iframe:"true", title:"<?php echo $langs->trans("PrintWithoutDetails"); ?>"});
1100  return true;
1101 }
1102 
1103 function Print(id, gift){
1104  console.log("Call Print() to generate the receipt.");
1105  $.colorbox({href:"receipt.php?facid="+id+"&gift="+gift, width:"40%", height:"90%", transition:"none", iframe:"true", title:'<?php echo dol_escape_js($langs->trans("PrintTicket")); ?>'});
1106  return true;
1107 }
1108 
1109 function TakeposPrinting(id){
1110  var receipt;
1111  console.log("TakeposPrinting" + id);
1112  $.get("receipt.php?facid="+id, function(data, status) {
1113  receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '');
1114  $.ajax({
1115  type: "POST",
1116  url: 'http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print',
1117  data: receipt
1118  });
1119  });
1120  return true;
1121 }
1122 
1123 function TakeposConnector(id){
1124  console.log("TakeposConnector" + id);
1125  $.get("<?php echo DOL_URL_ROOT; ?>/takepos/ajax/ajax.php?action=printinvoiceticket&token=<?php echo newToken(); ?>&term=<?php echo urlencode(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : ''); ?>&id="+id+"&token=<?php echo currentToken(); ?>", function(data, status) {
1126  $.ajax({
1127  type: "POST",
1128  url: '<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>/printer/index.php',
1129  data: 'invoice='+data
1130  });
1131  });
1132  return true;
1133 }
1134 
1135 function DolibarrTakeposPrinting(id) {
1136  console.log("DolibarrTakeposPrinting Printing invoice ticket " + id)
1137  $.ajax({
1138  type: "GET",
1139  data: { token: '<?php echo currentToken(); ?>' },
1140  url: "<?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=printinvoiceticket&token='.newToken().'&term='.urlencode(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '').'&id='; ?>" + id,
1141  });
1142  return true;
1143 }
1144 
1145 function CreditNote() {
1146  $("#poslines").load("invoice.php?action=creditnote&token=<?php echo newToken() ?>&invoiceid="+placeid, function() { });
1147  return true;
1148 }
1149 
1150 function SetNote() {
1151  $("#poslines").load("invoice.php?action=addnote&token=<?php echo newToken() ?>&invoiceid="+placeid+"&idline="+selectedline, { "addnote": $("#textinput").val() });
1152  return true;
1153 }
1154 
1155 
1156 $( document ).ready(function() {
1157  console.log("Set customer info and sales in header placeid=<?php echo $placeid; ?> status=<?php echo $invoice->statut; ?>");
1158 
1159  <?php
1160  $s = $langs->trans("Customer");
1161  if ($invoice->id > 0 && ($invoice->socid != getDolGlobalString($constforcompanyid))) {
1162  $s = $soc->name;
1163  }
1164  ?>
1165 
1166  $("#customerandsales").html('');
1167  $("#shoppingcart").html('');
1168 
1169  $("#customerandsales").append('<a class="valignmiddle tdoverflowmax125 minwidth100" id="customer" onclick="Customer();" title="<?php print dol_escape_js(dol_escape_htmltag($s)); ?>"><span class="fas fa-building paddingrightonly"></span><?php print dol_escape_js($s); ?></a>');
1170 
1171  <?php
1172  $sql = "SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX."facture";
1173  $sql .= " WHERE entity IN (".getEntity('invoice').")";
1174  if (empty($conf->global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) {
1175  // By default, only invoices with a ref not already defined can in list of open invoice we can edit.
1176  $sql .= " AND ref LIKE '(PROV-POS".$db->escape(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '')."-0%'";
1177  } else {
1178  // If TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED set, we show also draft invoice that already has a reference defined
1179  $sql .= " AND pos_source = '".$db->escape($_SESSION["takeposterminal"])."'";
1180  $sql .= " AND module_source = 'takepos'";
1181  }
1182 
1183  $sql .= $db->order('datec', 'ASC');
1184  $resql = $db->query($sql);
1185  if ($resql) {
1186  $max_sale = 0;
1187  while ($obj = $db->fetch_object($resql)) {
1188  echo '$("#shoppingcart").append(\'';
1189  echo '<a class="valignmiddle" title="'.dol_escape_js($langs->trans("SaleStartedAt", dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser')).' - '.$obj->ref).'" onclick="place=\\\'';
1190  $num_sale = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref));
1191  echo $num_sale;
1192  if (str_replace("-", "", $num_sale) > $max_sale) {
1193  $max_sale = str_replace("-", "", $num_sale);
1194  }
1195  echo '\\\'; invoiceid=\\\'';
1196  echo $obj->rowid;
1197  echo '\\\'; Refresh();">';
1198  if ($placeid == $obj->rowid) {
1199  echo '<span class="basketselected">';
1200  } else {
1201  echo '<span class="basketnotselected">';
1202  }
1203  echo '<span class="fa fa-shopping-cart paddingright"></span>'.dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser');
1204  echo '</span>';
1205  echo '</a>\');';
1206  }
1207  echo '$("#shoppingcart").append(\'<a onclick="place=\\\'0-';
1208  echo $max_sale + 1;
1209  echo '\\\'; invoiceid=0; Refresh();"><div><span class="fa fa-plus" title="'.dol_escape_htmltag($langs->trans("StartAParallelSale")).'"><span class="fa fa-shopping-cart"></span></div></a>\');';
1210  } else {
1211  dol_print_error($db);
1212  }
1213 
1214  $s = '';
1215 
1216  $idwarehouse = 0;
1217  $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '');
1218  if (isModEnabled('stock')) {
1219  if (getDolGlobalString("$constantforkey") != "1") {
1220  $constantforkey = 'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '');
1221  $idwarehouse = getDolGlobalString($constantforkey);
1222  if ($idwarehouse > 0) {
1223  $s = '<span class="small">';
1224  $warehouse = new Entrepot($db);
1225  $warehouse->fetch($idwarehouse);
1226  $s .= '<span class="hideonsmartphone">'.$langs->trans("Warehouse").'<br></span>'.$warehouse->ref;
1227  if ($warehouse->statut == Entrepot::STATUS_CLOSED) {
1228  $s .= ' ('.$langs->trans("Closed").')';
1229  }
1230  $s .= '</span>';
1231  print "$('#infowarehouse').html('".dol_escape_js($s)."');";
1232  print '$("#infowarehouse").css("display", "inline-block");';
1233  } else {
1234  $s = '<span class="small hideonsmartphone">';
1235  $s .= $langs->trans("StockChangeDisabled").'<br>'.$langs->trans("NoWarehouseDefinedForTerminal");
1236  $s .= '</span>';
1237  print "$('#infowarehouse').html('".dol_escape_js($s)."');";
1238  if (!empty($conf->dol_optimize_smallscreen)) {
1239  print '$("#infowarehouse").css("display", "none");';
1240  }
1241  }
1242  } else {
1243  $s = '<span class="small hideonsmartphone">'.$langs->trans("StockChangeDisabled").'</span>';
1244  print "$('#infowarehouse').html('".dol_escape_js($s)."');";
1245  if (!empty($conf->dol_optimize_smallscreen)) {
1246  print '$("#infowarehouse").css("display", "none");';
1247  }
1248  }
1249  }
1250 
1251 
1252  // Module Adherent
1253  $s = '';
1254  if (isModEnabled('adherent') && $invoice->socid > 0 && $invoice->socid != $conf->global->$constforcompanyid) {
1255  $s = '<span class="small">';
1256  require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
1257  $langs->load("members");
1258  $s .= $langs->trans("Member").': ';
1259  $adh = new Adherent($db);
1260  $result = $adh->fetch('', '', $invoice->socid);
1261  if ($result > 0) {
1262  $adh->ref = $adh->getFullName($langs);
1263  if (empty($adh->statut) || $adh->statut == Adherent::STATUS_EXCLUDED ) {
1264  $s .= "<s>";
1265  }
1266  $s .= $adh->getFullName($langs);
1267  $s .= ' - '.$adh->type;
1268  if ($adh->datefin) {
1269  $s .= '<br>'.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day');
1270  if ($adh->hasDelay()) {
1271  $s .= " ".img_warning($langs->trans("Late"));
1272  }
1273  } else {
1274  $s .= '<br>'.$langs->trans("SubscriptionNotReceived");
1275  if ($adh->statut > 0) {
1276  $s .= " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
1277  }
1278  }
1279  if (empty($adh->statut) || $adh->statut == Adherent::STATUS_EXCLUDED) {
1280  $s .= "</s>";
1281  }
1282  } else {
1283  $s .= '<br>'.$langs->trans("ThirdpartyNotLinkedToMember");
1284  }
1285  $s .= '</span>';
1286  }
1287  ?>
1288  $("#moreinfo").html('<?php print dol_escape_js($s); ?>');
1289 
1290 });
1291 
1292 
1293 <?php
1294 if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
1295  echo "function CustomerDisplay(){";
1296  echo "var line1='".$CUSTOMER_DISPLAY_line1."'.substring(0,20);";
1297  echo "line1=line1.padEnd(20);";
1298  echo "var line2='".$CUSTOMER_DISPLAY_line2."'.substring(0,20);";
1299  echo "line2=line2.padEnd(20);";
1300  echo "$.ajax({
1301  type: 'GET',
1302  data: { text: line1+line2 },
1303  url: '".getDolGlobalString('TAKEPOS_PRINT_SERVER')."/display/index.php',
1304  });";
1305  echo "}";
1306 }
1307 ?>
1308 
1309 </script>
1310 
1311 <?php
1312 // Add again js for footer because this content is injected into index.php page so all init
1313 // for tooltip and other js beautifiers must be reexecuted too.
1314 if (!empty($conf->use_javascript_ajax)) {
1315  print "\n".'<!-- Includes JS Footer of Dolibarr -->'."\n";
1316  print '<script src="'.DOL_URL_ROOT.'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.'"></script>'."\n";
1317 }
1318 
1319 print '<!-- invoice.php place='.(int) $place.' invoice='.$invoice->ref.' mobilepage='.(empty($mobilepage) ? '' : $mobilepage).' $_SESSION["basiclayout"]='.(empty($_SESSION["basiclayout"])?'':$_SESSION["basiclayout"]).' conf->global->TAKEPOS_BAR_RESTAURANT='.getDolGlobalString('TAKEPOS_BAR_RESTAURANT').' -->'."\n";
1320 print '<div class="div-table-responsive-no-min invoice">';
1321 print '<table id="tablelines" class="noborder noshadow postablelines centpercent">';
1322 if ($sectionwithinvoicelink && ($mobilepage == "invoice" || $mobilepage == "")) {
1323  if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
1324  print '<tr><td colspan="5">'.$sectionwithinvoicelink.'</td></tr>';
1325  } else {
1326  print '<tr><td colspan="4">'.$sectionwithinvoicelink.'</td></tr>';
1327  }
1328 }
1329 print '<tr class="liste_titre nodrag nodrop">';
1330 print '<td class="linecoldescription">';
1331 // In phone version only show when it is invoice page
1332 if (empty($mobilepage) || $mobilepage == "invoice") {
1333  print '<!-- hidden var used by some js functions -->';
1334  print '<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.'">';
1335  print '<input type="hidden" name="thirdpartyid" id="thirdpartyid" value="'.$invoice->socid.'">';
1336 }
1337 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
1338  $sql = "SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place);
1339  $resql = $db->query($sql);
1340  $obj = $db->fetch_object($resql);
1341  if ($obj) {
1342  $label = $obj->label;
1343  $floor = $obj->floor;
1344  }
1345  if ($mobilepage == "invoice" || $mobilepage == "") {
1346  // If not on smartphone version or if it is the invoice page
1347  //print 'mobilepage='.$mobilepage;
1348  print '<span class="opacitymedium">'.$langs->trans('Place')."</span> <b>".(empty($label) ? '?' : $label)."</b><br>";
1349  print '<span class="opacitymedium">'.$langs->trans('Floor')."</span> <b>".(empty($floor) ? '?' : $floor)."</b>";
1350  } elseif (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1351  print $mysoc->name;
1352  } elseif ($mobilepage == "cats") {
1353  print $langs->trans('Category');
1354  } elseif ($mobilepage == "products") {
1355  print $langs->trans('Label');
1356  }
1357 } else {
1358  print $langs->trans("Products");
1359 }
1360 print '</td>';
1361 
1362 // complete header by hook
1363 $parameters=array();
1364 $reshook=$hookmanager->executeHooks('completeTakePosInvoiceHeader', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
1365 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1366 print $hookmanager->resPrint;
1367 
1368 if (empty($_SESSION["basiclayout"]) || $_SESSION["basiclayout"] != 1) {
1369  print '<td class="linecolqty right">'.$langs->trans('ReductionShort').'</td>';
1370  print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
1371  if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
1372  print '<td class="linecolht right nowraponall">';
1373  print '<span class="opacitymedium small">' . $langs->trans('TotalHTShort') . '</span><br>';
1374  // In phone version only show when it is invoice page
1375  if (empty($mobilepage) || $mobilepage == "invoice") {
1376  print '<span id="linecolht-span-total" style="font-size:1.3em; font-weight: bold;">' . price($invoice->total_ht, 1, '', 1, -1, -1, $conf->currency) . '</span>';
1377  if (isModEnabled('multicurrency') && $_SESSION["takeposcustomercurrency"] != "" && $conf->currency != $_SESSION["takeposcustomercurrency"]) {
1378  //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
1379  include_once DOL_DOCUMENT_ROOT . '/multicurrency/class/multicurrency.class.php';
1380  $multicurrency = new MultiCurrency($db);
1381  $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]);
1382  print '<br><span id="linecolht-span-total" style="font-size:0.9em; font-style:italic;">(' . price($invoice->total_ht * $multicurrency->rate->rate) . ' ' . $_SESSION["takeposcustomercurrency"] . ')</span>';
1383  }
1384  print '</td>';
1385  }
1386  print '</td>';
1387  }
1388  print '<td class="linecolht right nowraponall">';
1389  print '<span class="opacitymedium small">'.$langs->trans('TotalTTCShort').'</span><br>';
1390  // In phone version only show when it is invoice page
1391  if (empty($mobilepage) || $mobilepage == "invoice") {
1392  print '<span id="linecolht-span-total" style="font-size:1.3em; font-weight: bold;">'.price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency).'</span>';
1393  if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency"]) && $conf->currency != $_SESSION["takeposcustomercurrency"]) {
1394  //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
1395  include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
1396  $multicurrency = new MultiCurrency($db);
1397  $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]);
1398  print '<br><span id="linecolht-span-total" style="font-size:0.9em; font-style:italic;">('.price($invoice->total_ttc * $multicurrency->rate->rate).' '.$_SESSION["takeposcustomercurrency"].')</span>';
1399  }
1400  print '</td>';
1401  }
1402  print '</td>';
1403 } elseif ($mobilepage == "invoice") {
1404  print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
1405 }
1406 print "</tr>\n";
1407 
1408 
1409 if (!empty($_SESSION["basiclayout"]) && $_SESSION["basiclayout"] == 1) {
1410  if ($mobilepage == "cats") {
1411  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1412  $categorie = new Categorie($db);
1413  $categories = $categorie->get_full_arbo('product');
1414  $htmlforlines = '';
1415  foreach ($categories as $row) {
1416  if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1417  $htmlforlines .= '<div class="leftcat';
1418  } else {
1419  $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
1420  }
1421  $htmlforlines .= '" onclick="LoadProducts('.$row['id'].');">';
1422  if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1423  $htmlforlines .= '<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.'/takepos/public/auto_order.php?genimg=cat&query=cat&id='.$row['id'].'"><br>';
1424  } else {
1425  $htmlforlines .= '<td class="left">';
1426  }
1427  $htmlforlines .= $row['label'];
1428  if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1429  $htmlforlines .= '</div>'."\n";
1430  } else {
1431  $htmlforlines .= '</td></tr>'."\n";
1432  }
1433  }
1434  $htmlforlines .= '</table>';
1435  $htmlforlines .= '</table>';
1436  print $htmlforlines;
1437  }
1438 
1439  if ($mobilepage == "products") {
1440  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1441  $object = new Categorie($db);
1442  $catid = GETPOST('catid', 'int');
1443  $result = $object->fetch($catid);
1444  $prods = $object->getObjectsInCateg("product");
1445  $htmlforlines = '';
1446  foreach ($prods as $row) {
1447  if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1448  $htmlforlines .= '<div class="leftcat';
1449  } else {
1450  $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
1451  }
1452  $htmlforlines .= '" onclick="AddProduct(\''.$place.'\', '.$row->id.')">';
1453  if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1454  $htmlforlines .= '<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.'/takepos/public/auto_order.php?genimg=pro&query=pro&id='.$row->id.'"><br>';
1455  $htmlforlines .= $row->label.' '.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency);
1456  $htmlforlines .= '</div>'."\n";
1457  } else {
1458  $htmlforlines .= '<td class="left">';
1459  $htmlforlines .= $row->label;
1460  $htmlforlines .= '<div class="right">'.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).'</div>';
1461  $htmlforlines .= '</tr>'."\n";
1462  }
1463  }
1464  $htmlforlines .= '</table>';
1465  print $htmlforlines;
1466  }
1467 
1468  if ($mobilepage == "places") {
1469  $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables";
1470  $resql = $db->query($sql);
1471  $rows = array();
1472  $htmlforlines = '';
1473  while ($row = $db->fetch_array($resql)) {
1474  $rows[] = $row;
1475  $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
1476  $htmlforlines .= '" onclick="LoadPlace(\''.$row['label'].'\')">';
1477  $htmlforlines .= '<td class="left">';
1478  $htmlforlines .= $row['label'];
1479  $htmlforlines .= '</td>';
1480  $htmlforlines .= '</tr>'."\n";
1481  }
1482  $htmlforlines .= '</table>';
1483  print $htmlforlines;
1484  }
1485 }
1486 
1487 if ($placeid > 0) {
1488  //In Phone basic layout hide some content depends situation
1489  if (!empty($_SESSION["basiclayout"]) && $_SESSION["basiclayout"] == 1 && $mobilepage != "invoice" && $action != "order") {
1490  return;
1491  }
1492 
1493  if (is_array($invoice->lines) && count($invoice->lines)) {
1494  print '<!-- invoice.php show lines of invoices -->'."\n";
1495  $tmplines = array_reverse($invoice->lines);
1496  $htmlsupplements = array();
1497  foreach ($tmplines as $line) {
1498  if ($line->fk_parent_line != false) {
1499  $htmlsupplements[$line->fk_parent_line] .= '<tr class="drag drop oddeven posinvoiceline';
1500  if ($line->special_code == "4") {
1501  $htmlsupplements[$line->fk_parent_line] .= ' order';
1502  }
1503  $htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'"';
1504  if ($line->special_code == "4") {
1505  $htmlsupplements[$line->fk_parent_line] .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
1506  }
1507  $htmlsupplements[$line->fk_parent_line] .= '>';
1508  $htmlsupplements[$line->fk_parent_line] .= '<td class="left">';
1509  $htmlsupplements[$line->fk_parent_line] .= img_picto('', 'rightarrow');
1510  if ($line->product_label) {
1511  $htmlsupplements[$line->fk_parent_line] .= $line->product_label;
1512  }
1513  if ($line->product_label && $line->desc) {
1514  $htmlsupplements[$line->fk_parent_line] .= '<br>';
1515  }
1516  if ($line->product_label != $line->desc) {
1517  $firstline = dolGetFirstLineOfText($line->desc);
1518  if ($firstline != $line->desc) {
1519  $htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
1520  } else {
1521  $htmlsupplements[$line->fk_parent_line] .= $line->desc;
1522  }
1523  }
1524  $htmlsupplements[$line->fk_parent_line] .= '</td>';
1525 
1526  // complete line by hook
1527  $parameters=array('line' => $line);
1528  $reshook=$hookmanager->executeHooks('completeTakePosInvoiceParentLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
1529  if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1530  $htmlsupplements[$line->fk_parent_line] .= $hookmanager->resPrint;
1531 
1532  if (empty($_SESSION["basiclayout"]) || $_SESSION["basiclayout"] != 1) {
1533  $htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.vatrate($line->remise_percent, true).'</td>';
1534  $htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.$line->qty.'</td>';
1535  $htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.price($line->total_ttc).'</td>';
1536  }
1537  $htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n";
1538  continue;
1539  }
1540  $htmlforlines = '';
1541 
1542  $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
1543  if ($line->special_code == "4") {
1544  $htmlforlines .= ' order';
1545  }
1546  $htmlforlines .= '" id="'.$line->id.'"';
1547  if ($line->special_code == "4") {
1548  $htmlforlines .= ' title="'.dol_escape_htmltag($langs->trans("AlreadyPrinted")).'"';
1549  }
1550  $htmlforlines .= '>';
1551  $htmlforlines .= '<td class="left">';
1552  if (!empty($_SESSION["basiclayout"]) && $_SESSION["basiclayout"] == 1) {
1553  $htmlforlines .= '<span class="phoneqty">'.$line->qty."</span> x ";
1554  }
1555  if (isset($line->product_type)) {
1556  if (empty($line->product_type)) {
1557  $htmlforlines .= img_object('', 'product').' ';
1558  } else {
1559  $htmlforlines .= img_object('', 'service').' ';
1560  }
1561  }
1562  if (empty($conf->global->TAKEPOS_SHOW_N_FIRST_LINES)) {
1563  $tooltiptext = '';
1564  if ($line->product_ref) {
1565  $tooltiptext .= '<b>'.$langs->trans("Ref").'</b> : '.$line->product_ref.'<br>';
1566  $tooltiptext .= '<b>'.$langs->trans("Label").'</b> : '.$line->product_label.'<br>';
1567  if ($line->product_label != $line->desc) {
1568  if ($line->desc) {
1569  $tooltiptext .= '<br>';
1570  }
1571  $tooltiptext .= $line->desc;
1572  }
1573  }
1574  if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
1575  $htmlforlines .= $form->textwithpicto($line->product_label ? '<b>' . $line->product_ref . '</b> - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
1576  } else {
1577  $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
1578  }
1579  } else {
1580  if ($line->product_label) {
1581  $htmlforlines .= $line->product_label;
1582  }
1583  if ($line->product_label != $line->desc) {
1584  if ($line->product_label && $line->desc) {
1585  $htmlforlines .= '<br>';
1586  }
1587  $firstline = dolGetFirstLineOfText($line->desc, $conf->global->TAKEPOS_SHOW_N_FIRST_LINES);
1588  if ($firstline != $line->desc) {
1589  $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
1590  } else {
1591  $htmlforlines .= $line->desc;
1592  }
1593  }
1594  }
1595  if (!empty($line->array_options['options_order_notes'])) {
1596  $htmlforlines .= "<br>(".$line->array_options['options_order_notes'].")";
1597  }
1598  if (!empty($_SESSION["basiclayout"]) && $_SESSION["basiclayout"] == 1) {
1599  $htmlforlines .= '</td><td class="right phonetable"><button type="button" onclick="SetQty(place, '.$line->rowid.', '.($line->qty - 1).');" class="publicphonebutton2 phonered">-</button>&nbsp;&nbsp;<button type="button" onclick="SetQty(place, '.$line->rowid.', '.($line->qty + 1).');" class="publicphonebutton2 phonegreen">+</button>';
1600  }
1601  if (empty($_SESSION["basiclayout"]) || $_SESSION["basiclayout"] != 1) {
1602  $moreinfo = '';
1603  $moreinfo .= $langs->transcountry("TotalHT", $mysoc->country_code).': '.price($line->total_ht);
1604  if ($line->vat_src_code) {
1605  $moreinfo .= '<br>'.$langs->trans("VATCode").': '.$line->vat_src_code;
1606  }
1607  $moreinfo .= '<br>'.$langs->transcountry("TotalVAT", $mysoc->country_code).': '.price($line->total_tva);
1608  $moreinfo .= '<br>'.$langs->transcountry("TotalLT1", $mysoc->country_code).': '.price($line->total_localtax1);
1609  $moreinfo .= '<br>'.$langs->transcountry("TotalLT2", $mysoc->country_code).': '.price($line->total_localtax2);
1610  $moreinfo .= '<hr>';
1611  $moreinfo .= $langs->transcountry("TotalTTC", $mysoc->country_code).': '.price($line->total_ttc);
1612  //$moreinfo .= $langs->trans("TotalHT").': '.$line->total_ht;
1613  if ($line->date_start || $line->date_end) {
1614  $htmlforlines .= '<br><div class="clearboth nowraponall">'.get_date_range($line->date_start, $line->date_end).'</div>';
1615  }
1616  $htmlforlines .= '</td>';
1617 
1618  // complete line by hook
1619  $parameters=array('line' => $line);
1620  $reshook=$hookmanager->executeHooks('completeTakePosInvoiceLine', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks
1621  if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1622  $htmlforlines .= $hookmanager->resPrint;
1623 
1624  $htmlforlines .= '<td class="right">'.vatrate($line->remise_percent, true).'</td>';
1625  $htmlforlines .= '<td class="right">';
1626  if (isModEnabled('stock') && !empty($user->rights->stock->mouvement->lire)) {
1627  $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
1628  if (!empty($conf->global->$constantforkey) && $line->fk_product > 0 && empty($conf->global->TAKEPOS_HIDE_STOCK_ON_LINE)) {
1629  $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp";
1630  $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
1631  $sql .= " ".MAIN_DB_PREFIX."product_stock as ps";
1632  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product";
1633  $sql .= " WHERE ps.reel != 0";
1634  $sql .= " AND ps.fk_entrepot = ".((int) $conf->global->$constantforkey);
1635  $sql .= " AND e.entity IN (".getEntity('stock').")";
1636  $sql .= " AND ps.fk_product = ".((int) $line->fk_product);
1637  $resql = $db->query($sql);
1638  if ($resql) {
1639  $obj = $db->fetch_object($resql);
1640  $stock_real = price2num($obj->reel, 'MS');
1641  $htmlforlines .= $line->qty;
1642  if ($line->qty && $line->qty > $stock_real) {
1643  $htmlforlines .= '<span style="color: var(--amountremaintopaycolor)">';
1644  }
1645  $htmlforlines .= ' <span class="posstocktoolow">('.$langs->trans("Stock").' '.$stock_real.')</span>';
1646  if ($line->qty && $line->qty > $stock_real) {
1647  $htmlforlines .= "</span>";
1648  }
1649  } else {
1650  dol_print_error($db);
1651  }
1652  } else {
1653  $htmlforlines .= $line->qty;
1654  }
1655  } else {
1656  $htmlforlines .= $line->qty;
1657  }
1658 
1659  $htmlforlines .= '</td>';
1660  if (getDolGlobalString('TAKEPOS_SHOW_HT')) {
1661  $htmlforlines .= '<td class="right classfortooltip" title="'.$moreinfo.'">';
1662  $htmlforlines .= price($line->total_ht, 1, '', 1, -1, -1, $conf->currency);
1663  if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency"]) && $conf->currency != $_SESSION["takeposcustomercurrency"]) {
1664  //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
1665  include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
1666  $multicurrency = new MultiCurrency($db);
1667  $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]);
1668  $htmlforlines .= '<br><span id="linecolht-span-total" style="font-size:0.9em; font-style:italic;">('.price($line->total_ht * $multicurrency->rate->rate).' '.$_SESSION["takeposcustomercurrency"].')</span>';
1669  }
1670  $htmlforlines .= '</td>';
1671  }
1672  $htmlforlines .= '<td class="right classfortooltip" title="'.$moreinfo.'">';
1673  $htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency);
1674  if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency"]) && $conf->currency != $_SESSION["takeposcustomercurrency"]) {
1675  //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
1676  include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
1677  $multicurrency = new MultiCurrency($db);
1678  $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]);
1679  $htmlforlines .= '<br><span id="linecolht-span-total" style="font-size:0.9em; font-style:italic;">('.price($line->total_ttc * $multicurrency->rate->rate).' '.$_SESSION["takeposcustomercurrency"].')</span>';
1680  }
1681  $htmlforlines .= '</td>';
1682  }
1683  $htmlforlines .= '</tr>'."\n";
1684  $htmlforlines .= empty($htmlsupplements[$line->id]) ? '' : $htmlsupplements[$line->id];
1685 
1686  print $htmlforlines;
1687  }
1688  } else {
1689  print '<tr class="drag drop oddeven"><td class="left"><span class="opacitymedium">'.$langs->trans("Empty").'</span></td><td></td><td></td><td></td>';
1690  if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
1691  print '<td></td>';
1692  }
1693  print '</tr>';
1694  }
1695 } else { // No invoice generated yet
1696  print '<tr class="drag drop oddeven"><td class="left"><span class="opacitymedium">'.$langs->trans("Empty").'</span></td><td></td><td></td><td></td>';
1697 
1698  if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
1699  print '<td></td>';
1700  }
1701  print '</tr>';
1702 }
1703 
1704 print '</table>';
1705 
1706 if (($action == "valid" || $action == "history") && $invoice->type != Facture::TYPE_CREDIT_NOTE && empty($conf->global->TAKEPOS_NO_CREDITNOTE)) {
1707  print '<button id="buttonprint" type="button" onclick="ModalBox(\'ModalCreditNote\')">'.$langs->trans('CreateCreditNote').'</button>';
1708  if (getDolGlobalInt('TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) {
1709  print ' <a target="_blank" class="button" href="' . DOL_URL_ROOT . '/document.php?token=' . newToken() . '&modulepart=facture&file=' . $invoice->ref . '/' . $invoice->ref . '.pdf">Invoice</a>';
1710  }
1711 }
1712 
1713 
1714 if ($action == "search") {
1715  print '<center>
1716  <input type="text" id="search" class="input-search-takepos" name="search" onkeyup="Search2(\'\', null);" style="width: 80%; font-size: 150%;" placeholder="'.dol_escape_htmltag($langs->trans('Search')).'">
1717  </center>';
1718 }
1719 
1720 print '</div>';
1721 
1722 // llxFooter
1723 if ((getDolGlobalString('TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->layout == 'phone') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
1724  print '</body></html>';
1725 }
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 generation of HTML components Only common components must be here.
Class Currency.
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.
Definition: index.php:746
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formated error messages to output (Used to show messages on html output).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(empty($user->rights->takepos->run) &&!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) if((getDolGlobalString('TAKEPOS_PHONE_BASIC_LAYOUT')==1 && $conf->browser->layout=='phone')||defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) fail($message)
Abort invoice creationg with a given error message.
Definition: invoice.php:88
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.
Definition: main.inc.php:1510
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
Definition: main.inc.php:1641
table tableforfield button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
Definition: style.css.php:853
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:120
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.