diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang
index e33d1112deb40..964bd7c436c21 100644
--- a/htdocs/langs/en_US/cashdesk.lang
+++ b/htdocs/langs/en_US/cashdesk.lang
@@ -79,3 +79,5 @@ InvoiceIsAlreadyValidated=Invoice is already validated
NoLinesToBill=No lines to bill
CustomReceipt=Custom Receipt
ReceiptName=Receipt Name
+ProductSupplements=Product Supplements
+SupplementCategory=Supplement category
diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php
index 895b82ac03334..ebd0e0659e4c0 100644
--- a/htdocs/takepos/admin/setup.php
+++ b/htdocs/takepos/admin/setup.php
@@ -75,6 +75,8 @@
$res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTERS", GETPOST('TAKEPOS_ORDER_PRINTERS', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_ORDER_NOTES", GETPOST('TAKEPOS_ORDER_NOTES', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_PHONE_BASIC_LAYOUT", GETPOST('TAKEPOS_PHONE_BASIC_LAYOUT', 'alpha'), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS", GETPOST('TAKEPOS_SUPPLEMENTS', 'alpha'), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_AUTO_PRINT_TICKETS", GETPOST('TAKEPOS_AUTO_PRINT_TICKETS', 'int'), 'int', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity);
@@ -222,6 +224,22 @@
print '
';
print $form->selectyesno("TAKEPOS_PHONE_BASIC_LAYOUT", $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT, 1);
print ' | ';
+
+ print '';
+ print $langs->trans("ProductSupplements");
+ print ' | ';
+ print $form->selectyesno("TAKEPOS_SUPPLEMENTS", $conf->global->TAKEPOS_SUPPLEMENTS, 1);
+ print ' |
';
+
+ if ($conf->global->TAKEPOS_SUPPLEMENTS)
+ {
+ print '';
+ print $langs->trans("SupplementCategory");
+ print ' | ';
+ print $form->select_all_categories(Categorie::TYPE_PRODUCT, $conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, 'TAKEPOS_SUPPLEMENTS_CATEGORY', 64, 0, 0);
+ print ajax_combobox('TAKEPOS_SUPPLEMENTS_CATEGORY');
+ print " |
\n";
+ }
}
print '';
diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php
index 7e3049f9f6e43..74b24d785703d 100644
--- a/htdocs/takepos/ajax/ajax.php
+++ b/htdocs/takepos/ajax/ajax.php
@@ -45,6 +45,7 @@
if ($action == 'getProducts') {
$object = new Categorie($db);
+ if ($category=="supplements") $category=$conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY;
$result = $object->fetch($category);
if ($result > 0)
{
diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php
index 23bc09a726862..0b7ebff85480b 100644
--- a/htdocs/takepos/invoice.php
+++ b/htdocs/takepos/invoice.php
@@ -87,6 +87,7 @@ function fail($message)
$number = GETPOST('number', 'alpha');
$idline = GETPOST('idline', 'int');
+$selectedline = GETPOST('selectedline', 'int');
$desc = GETPOST('desc', 'alpha');
$pay = GETPOST('pay', 'alpha');
$amountofpayment = price2num(GETPOST('amount', 'alpha'));
@@ -276,7 +277,23 @@ function fail($message)
$price_base_type = $prod->multiprices_base_type[$customer->price_level];
}
- $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $prod->localtax1_tx, $prod->localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0);
+ if ($conf->global->TAKEPOS_SUPPLEMENTS)
+ {
+ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+ $cat = new Categorie($db);
+ $categories = $cat->containing($idproduct, 'product');
+ $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories, 'id')));
+ if ($found !== false) // If this product is a supplement
+ {
+ $sql = "SELECT fk_parent_line FROM ".MAIN_DB_PREFIX."facturedet where rowid=$selectedline";
+ $resql = $db->query($sql);
+ $row = $db->fetch_array($resql);
+ if ($row[0]==null) $parent_line=$selectedline;
+ else $parent_line=$row[0]; //If the parent line is already a supplement, add the supplement to the main product
+ }
+ }
+
+ $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $prod->localtax1_tx, $prod->localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, $parent_line, null, 0, '', 0, 100, '', null, 0);
$invoice->fetch($placeid);
}
@@ -689,6 +706,37 @@ function DolibarrTakeposPrinting(id) {
$tmplines = array_reverse($invoice->lines);
foreach ($tmplines as $line)
{
+ if ($line->fk_parent_line!=false)
+ {
+ $htmlsupplements[$line->fk_parent_line].=' |
fk_parent_line].=' order';
+ $htmlsupplements[$line->fk_parent_line].= '" id="'.$line->id.'">';
+ $htmlsupplements[$line->fk_parent_line].= '';
+ $htmlsupplements[$line->fk_parent_line].= img_picto('', 'rightarrow');
+ if ($line->product_label) $htmlsupplements[$line->fk_parent_line] .= $line->product_label;
+ if ($line->product_label && $line->desc) $htmlsupplements[$line->fk_parent_line] .= ' ';
+ if ($line->product_label != $line->desc)
+ {
+ $firstline = dolGetFirstLineOfText($line->desc);
+ if ($firstline != $line->desc)
+ {
+ $htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
+ }
+ else
+ {
+ $htmlsupplements[$line->fk_parent_line] .= $line->desc;
+ }
+ }
+ $htmlsupplements[$line->fk_parent_line] .= ' | ';
+ if ($_SESSION["basiclayout"] != 1)
+ {
+ $htmlsupplements[$line->fk_parent_line] .= ''.vatrate($line->remise_percent, true).' | ';
+ $htmlsupplements[$line->fk_parent_line] .= ''.$line->qty.' | ';
+ $htmlsupplements[$line->fk_parent_line] .= ''.price($line->total_ttc).' | ';
+ }
+ $htmlsupplements[$line->fk_parent_line] .= '
'."\n";
+ continue;
+ }
$htmlforlines = '';
$htmlforlines .= ''.price($line->total_ttc).'';
}
$htmlforlines .= '
'."\n";
+ $htmlforlines .= $htmlsupplements[$line->id];
print $htmlforlines;
}
diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php
index fed82019d62f6..ba9f231850851 100644
--- a/htdocs/takepos/takepos.php
+++ b/htdocs/takepos/takepos.php
@@ -233,10 +233,14 @@ function LoadProducts(position, issubcat) {
console.log("LoadProducts");
var maxproduct = ;
- $('#catimg'+position).animate({opacity: '0.5'}, 1);
- $('#catimg'+position).animate({opacity: '1'}, 100);
- if (issubcat==true) currentcat=$('#prodiv'+position).data('rowid');
- else currentcat=$('#catdiv'+position).data('rowid');
+ if (position=="supplements") currentcat="supplements";
+ else
+ {
+ $('#catimg'+position).animate({opacity: '0.5'}, 1);
+ $('#catimg'+position).animate({opacity: '1'}, 100);
+ if (issubcat==true) currentcat=$('#prodiv'+position).data('rowid');
+ else currentcat=$('#catdiv'+position).data('rowid');
+ }
if (currentcat == undefined) return;
pageproducts=0;
ishow=0; //product to show counter
@@ -353,7 +357,7 @@ function ClickProduct(position) {
console.log("Click on product at position "+position+" for idproduct "+idproduct);
if (idproduct=="") return;
// Call page invoice.php to generate the section with product lines
- $("#poslines").load("invoice.php?action=addline&place="+place+"&idproduct="+idproduct, function() {
+ $("#poslines").load("invoice.php?action=addline&place="+place+"&idproduct="+idproduct+"&selectedline="+selectedline, function() {
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
});
}
@@ -723,6 +727,10 @@ function DirectPayment(){
{
$menus[$r++]=array('title'=>''.$langs->trans("OrderNotes").'
', 'action'=>'TakeposOrderNotes();');
}
+ if ($conf->global->TAKEPOS_SUPPLEMENTS)
+ {
+ $menus[$r++]=array('title'=>''.$langs->trans("ProductSupplements").'
', 'action'=>'LoadProducts(\'supplements\');');
+ }
}
if ($conf->global->TAKEPOSCONNECTOR) {