Skip to content

Commit

Permalink
Merge pull request #12659 from andreubisquerra/master
Browse files Browse the repository at this point in the history
NEW: Takepos supplements
  • Loading branch information
eldy committed Dec 30, 2019
2 parents 945296b + acbd8ef commit fc49825
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 6 deletions.
2 changes: 2 additions & 0 deletions htdocs/langs/en_US/cashdesk.lang
Expand Up @@ -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
18 changes: 18 additions & 0 deletions htdocs/takepos/admin/setup.php
Expand Up @@ -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);
Expand Down Expand Up @@ -222,6 +224,22 @@
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>';
Expand Down
1 change: 1 addition & 0 deletions htdocs/takepos/ajax/ajax.php
Expand Up @@ -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)
{
Expand Down
51 changes: 50 additions & 1 deletion htdocs/takepos/invoice.php
Expand Up @@ -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'));
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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].='<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';
Expand Down Expand Up @@ -726,6 +774,7 @@ function DolibarrTakeposPrinting(id) {
$htmlforlines .= '<td class="right">'.price($line->total_ttc).'</td>';
}
$htmlforlines .= '</tr>'."\n";
$htmlforlines .= $htmlsupplements[$line->id];

print $htmlforlines;
}
Expand Down
18 changes: 13 additions & 5 deletions htdocs/takepos/takepos.php
Expand Up @@ -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
Expand Down Expand Up @@ -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);
});
}
Expand Down Expand Up @@ -723,6 +727,10 @@ function DirectPayment(){
{
$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) {
Expand Down

0 comments on commit fc49825

Please sign in to comment.