Skip to content

Commit

Permalink
Add Order Notes to TakePOS
Browse files Browse the repository at this point in the history
  • Loading branch information
andreubisquerra committed Mar 3, 2019
1 parent 1931f43 commit b1e9a0f
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 13 deletions.
3 changes: 2 additions & 1 deletion htdocs/langs/en_US/cashdesk.lang
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ Paymentnumpad=Payment Num Pad
Numberspad=Numbers Pad
BillsCoinsPad=Bills and Coins Pad
DolistorePosCategory=TakePOS modules and other POS solutions for Dolibarr
TakeposNeedsCategories=TakePOS needs product categories to work
TakeposNeedsCategories=TakePOS needs product categories to work
OrderNotes=Order Notes
13 changes: 13 additions & 0 deletions htdocs/takepos/admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,16 @@
$res = dolibarr_set_const($db, "TAKEPOS_BAR_RESTAURANT", GETPOST('TAKEPOS_BAR_RESTAURANT', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_PRINT_SERVER", GETPOST('TAKEPOS_PRINT_SERVER', 'alpha'), 'chaine', 0, '', $conf->entity);
$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_HEADER", GETPOST('TAKEPOS_HEADER', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity);

if ($conf->global->TAKEPOS_ORDER_NOTES==1)
{
$extrafields = new ExtraFields($db);
$extrafields->addExtraField('order_notes', 'Order notes', 'varchar', 0, 255, 'facturedet', 0, 0, '', '', 0, '', 0, 1);
}

dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));

Expand Down Expand Up @@ -142,6 +149,12 @@
print '<td colspan="2">';
print $form->selectyesno("TAKEPOS_ORDER_PRINTERS", $conf->global->TAKEPOS_ORDER_PRINTERS, 1);
print '</td></tr>';

print '<tr class="oddeven value"><td>';
print $langs->trans("OrderNotes");
print '<td colspan="2">';
print $form->selectyesno("TAKEPOS_ORDER_NOTES", $conf->global->TAKEPOS_ORDER_NOTES, 1);
print '</td></tr>';
}

// Payment numpad
Expand Down
14 changes: 11 additions & 3 deletions htdocs/takepos/freezone.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
$langs->loadLangs(array("bills", "cashdesk"));

$place = GETPOST('place', 'int');

$idline = GETPOST('idline', 'int');
$action = GETPOST('action');

/*
* View
Expand All @@ -41,16 +42,23 @@
?>
<script>
function Save(){
$.get( "invoice.php", { action: "freezone", place: "<?php echo $place;?>", desc:$('#desc').val(), number:$('#price').val()} );
$.get( "invoice.php", { action: "<?php echo $action;?>", place: "<?php echo $place;?>", desc:$('#desc').val(), number:$('#number').val()} );
parent.$.colorbox.close();
}

$( document ).ready(function() {
$('#desc').focus()
});
</script>
</head>
<body>
<br>
<center>
<input type="text" id="desc" name="desc" style="width:40%;font-size: 200%;" placeholder="<?php echo $langs->trans('Description');?>">
<input type="text" id="price" name="price" style="width:15%;font-size: 200%;" placeholder="<?php echo $langs->trans('Price');?>">
<?php
if ($action=="freezone") echo '<input type="text" id="number" name="number" style="width:15%;font-size: 200%;" placeholder="'.$langs->trans('Price').'">';
if ($action=="addnote") echo '<input type="hidden" id="number" name="number" value="'.$idline.'">';
?>
<input type="hidden" name="place" value="<?php echo $place;?>">
<input type="button" style="width:15%;font-size: 200%;" value="OK" onclick="Save();">
</center>
Expand Down
7 changes: 2 additions & 5 deletions htdocs/takepos/genimg/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
* View
*/

header('Cache-Control: max-age=604800, public, must-revalidate');
header('Pragma: cache');

if ($query=="cat")
{
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
Expand All @@ -63,7 +60,7 @@
{
$filename=$obj['photo'];
}
$file=DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$filename);
$file=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$filename);
header('Location: '.$file);
exit;
}
Expand All @@ -80,7 +77,7 @@
preg_match('@src="([^"]+)"@', $image, $match);
$file = array_pop($match);
if ($file=="") header('Location: ../../public/theme/common/nophoto.png');
else header('Location: '.$file);
else header('Location: '.$file.'&cache=1');
}
else
{
Expand Down
24 changes: 21 additions & 3 deletions htdocs/takepos/invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@
$invoice->fetch($placeid);
}

if ($action == "addnote") {
foreach($invoice->lines as $line)
{
if ($line->id == $number)
{
$line->array_options['order_notes'] = $desc;
$result = $invoice->updateline($line->id, $line->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);
}
}
$invoice->fetch($placeid);
}

if ($action == "deleteline") {
if ($idline > 0 and $placeid > 0) { //If exist invoice and line, to avoid errors if deleted from other device or no line selected
$invoice->deleteline($idline);
Expand Down Expand Up @@ -185,7 +197,9 @@
if ($count > 0) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "facturedet set special_code='3' where rowid=$line->rowid";
$db->query($sql);
$order_receipt_printer1.= '<tr>' . $line->product_label . '<td align="right">' . $line->qty . '</td></tr>';
$order_receipt_printer1.= '<tr>' . $line->product_label . '<td align="right">' . $line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer1.="<br>(".$line->array_options['options_order_notes'].")";
$order_receipt_printer1.='</td></tr>';
}
}

Expand All @@ -200,7 +214,9 @@
if ($count > 0) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "facturedet set special_code='3' where rowid=$line->rowid";
$db->query($sql);
$order_receipt_printer2.= '<tr>' . $line->product_label . '<td align="right">' . $line->qty . '</td></tr>';
$order_receipt_printer2.= '<tr>' . $line->product_label . '<td align="right">' . $line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer2.="<br>(".$line->array_options['options_order_notes'].")";
$order_receipt_printer2.='</td></tr>';
}
}

Expand Down Expand Up @@ -325,7 +341,9 @@ function TakeposPrinting(id){
print ' order';
}
print '" id="' . $line->rowid . '">';
print '<td align="left">' . $line->product_label . $line->desc . '</td>';
print '<td align="left">' . $line->product_label . $line->desc;
if (!empty($line->array_options['options_order_notes'])) echo "<br>(".$line->array_options['options_order_notes'].")";
print '</td>';
print '<td align="right">' . $line->qty . '</td>';
print '<td align="right">' . price($line->total_ttc) . '</td>';
print '</tr>';
Expand Down
10 changes: 9 additions & 1 deletion htdocs/takepos/takepos.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,11 @@ function Floors(){
}

function FreeZone(){
$.colorbox({href:"freezone.php?place="+place, onClosed: function () { Refresh(); },width:"80%", height:"30%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("FreeZone");?>"});
$.colorbox({href:"freezone.php?action=freezone&place="+place, onClosed: function () { Refresh(); },width:"80%", height:"30%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("FreeZone");?>"});
}

function TakeposOrderNotes(){
$.colorbox({href:"freezone.php?action=addnote&place="+place+"&idline="+selectedline, onClosed: function () { Refresh(); },width:"80%", height:"30%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("OrderNotes");?>"});
}

function Refresh(){
Expand Down Expand Up @@ -457,6 +461,10 @@ function MoreActions(totalactions){
if ($conf->global->TAKEPOSCONNECTOR) $menus[$r++]=array('title'=>$langs->trans("Receipt"),'action'=>'TakeposPrinting(placeid);');
else $menus[$r++]=array('title'=>$langs->trans("Receipt"),'action'=>'Print(placeid);');
}
if ($conf->global->TAKEPOSCONNECTOR && $conf->global->TAKEPOS_ORDER_NOTES==1){
$menus[$r++]=array('title'=>$langs->trans("OrderNotes"),
'action'=>'TakeposOrderNotes();');
}
}

if ($conf->global->TAKEPOSCONNECTOR){
Expand Down

0 comments on commit b1e9a0f

Please sign in to comment.