Merge pull request #12659 from andreubisquerra/master
NEW: Takepos supplements
This commit is contained in:
commit
fc49825eaa
@ -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
|
||||
|
||||
@ -75,6 +75,8 @@ if (GETPOST('action', 'alpha') == 'set')
|
||||
$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 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT)
|
||||
print '<td colspan="2">';
|
||||
print $form->selectyesno("TAKEPOS_PHONE_BASIC_LAYOUT", $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr class="oddeven value"><td>';
|
||||
print $langs->trans("ProductSupplements");
|
||||
print '<td colspan="2">';
|
||||
print $form->selectyesno("TAKEPOS_SUPPLEMENTS", $conf->global->TAKEPOS_SUPPLEMENTS, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
if ($conf->global->TAKEPOS_SUPPLEMENTS)
|
||||
{
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("SupplementCategory");
|
||||
print '<td colspan="2">';
|
||||
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 "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
|
||||
@ -45,6 +45,7 @@ $id = GETPOST('id', 'int');
|
||||
|
||||
if ($action == 'getProducts') {
|
||||
$object = new Categorie($db);
|
||||
if ($category=="supplements") $category=$conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY;
|
||||
$result = $object->fetch($category);
|
||||
if ($result > 0)
|
||||
{
|
||||
|
||||
@ -87,6 +87,7 @@ $placeid = 0; // $placeid is id of invoice
|
||||
|
||||
$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 @@ if ($action == "addline")
|
||||
$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 @@ if ($placeid > 0)
|
||||
$tmplines = array_reverse($invoice->lines);
|
||||
foreach ($tmplines as $line)
|
||||
{
|
||||
if ($line->fk_parent_line!=false)
|
||||
{
|
||||
$htmlsupplements[$line->fk_parent_line].='<tr class="drag drop oddeven posinvoiceline';
|
||||
if ($line->special_code == "4") $htmlsupplements[$line->fk_parent_line].=' order';
|
||||
$htmlsupplements[$line->fk_parent_line].= '" id="'.$line->id.'">';
|
||||
$htmlsupplements[$line->fk_parent_line].= '<td class="left">';
|
||||
$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] .= '<br>';
|
||||
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] .= '</td>';
|
||||
if ($_SESSION["basiclayout"] != 1)
|
||||
{
|
||||
$htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.vatrate($line->remise_percent, true).'</td>';
|
||||
$htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.$line->qty.'</td>';
|
||||
$htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.price($line->total_ttc).'</td>';
|
||||
}
|
||||
$htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n";
|
||||
continue;
|
||||
}
|
||||
$htmlforlines = '';
|
||||
|
||||
$htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
|
||||
@ -726,6 +774,7 @@ if ($placeid > 0)
|
||||
$htmlforlines .= '<td class="right">'.price($line->total_ttc).'</td>';
|
||||
}
|
||||
$htmlforlines .= '</tr>'."\n";
|
||||
$htmlforlines .= $htmlsupplements[$line->id];
|
||||
|
||||
print $htmlforlines;
|
||||
}
|
||||
|
||||
@ -233,10 +233,14 @@ function LoadProducts(position, issubcat) {
|
||||
console.log("LoadProducts");
|
||||
var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
|
||||
|
||||
$('#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 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT)
|
||||
{
|
||||
$menus[$r++]=array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("OrderNotes").'</div>', 'action'=>'TakeposOrderNotes();');
|
||||
}
|
||||
if ($conf->global->TAKEPOS_SUPPLEMENTS)
|
||||
{
|
||||
$menus[$r++]=array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("ProductSupplements").'</div>', 'action'=>'LoadProducts(\'supplements\');');
|
||||
}
|
||||
}
|
||||
|
||||
if ($conf->global->TAKEPOSCONNECTOR) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user