Skip to content

Commit a82c64e

Browse files
author
Shaun Kutch
committed
Added print totals
1 parent 241c210 commit a82c64e

File tree

10 files changed

+89
-5
lines changed

10 files changed

+89
-5
lines changed

application/controllers/home.php

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function index()
1212
$this->load->view("home");
1313
}
1414

15-
function logout()
15+
function close()
1616
{
1717
$this->load->model('reports/Detailed_sales');
1818

@@ -21,8 +21,42 @@ function logout()
2121

2222
$data['sales_totals'] = $this->Detailed_sales->getTypeSummaryData(array('start_date'=>$start_date, 'end_date'=>$end_date));
2323

24+
$final_total = 0;
25+
foreach($data['sales_totals'] as $sales_total) {
26+
$final_total += $sales_total['total'];
27+
}
28+
29+
$data['final_total'] = $final_total;
30+
2431
$this->load->view("close", $data);
25-
//$this->Employee->logout();
32+
}
33+
34+
function print_totals()
35+
{
36+
$this->load->model('reports/Detailed_sales');
37+
38+
//Start at the beginning of the dau
39+
$start_date = date('Y-m-d') . " 00:00:00";
40+
$end_date = date('Y-m-d H:i:s');
41+
$sale_type = 'all';
42+
43+
$data['sales_totals'] = $this->Detailed_sales->getTypeSummaryData(array('start_date'=>$start_date, 'end_date'=>$end_date, 'sale_type'=>$sale_type));
44+
45+
if(!$this->Employee->has_permission("reports", $this->Employee->get_logged_in_employee_info()->person_id))
46+
{
47+
unset($data['sales_totals']['profit']);
48+
}
49+
50+
$report_data = $this->Detailed_sales->getData(array('start_date'=>$start_date, 'end_date'=>$end_date, 'sale_type'=>$sale_type));
51+
52+
$data['summary_data'] = $report_data['summary'];
53+
54+
$this->Receipt->print_totals($data);
55+
}
56+
57+
function logout()
58+
{
59+
$this->Employee->logout();
2660
}
2761
}
2862
?>

application/controllers/sales.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ function delete_customer()
174174

175175
function complete()
176176
{
177+
$data['is_transaction'] = true;
177178
$data['cart']=$this->sale_lib->get_cart();
178179
$data['subtotal']=$this->sale_lib->get_subtotal();
179180
$data['taxes']=$this->sale_lib->get_taxes();

application/language/english/common_lang.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@
5050
$lang['common_mailchimp_dashboard_lists_helper']='Select a list to view your subscribers';
5151
$lang['common_mailchimp_dashboard_listbuttons']='Your Lists';
5252
$lang['common_address']='Address';
53+
$lang['common_print_totals']='Print Totals';
5354
?>

application/language/english/sales_lang.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
$lang['sales_unsuspend_and_delete'] = 'Unsuspend and Delete';
7878
$lang['sales_unsuspend'] = 'Unsuspend';
7979
$lang['sales_successfully_suspended_sale'] = 'Your sale has been successfully suspended';
80+
$lang['sales_no_sales'] = 'Sorry, no sales were found.';
81+
$lang['sales_new_sale'] = 'New Sale';
8082
$lang['payments'] = 'Payments';
8183
$lang['totals'] = 'Totals';
8284
$lang['items'] = 'Items';

application/models/receipt.php

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,44 @@ function print_receipt($data)
8181
$message .= new_line();
8282

8383
$this->write_receipt($message);
84-
//$this->send_receipt($receipt_path);
84+
$this->send_receipt();
8585
}
8686

87+
function print_totals($data)
88+
{
89+
$today = date("F j, Y, g:i a");
90+
$message = init();
91+
$message .= $today;
92+
$message .= new_line();
93+
$message .= new_line();
94+
95+
$finalTotal = 0;
96+
97+
foreach($data['summary_data'] as $summary)
98+
{
99+
$message .= "Sale #" . " POS " .$summary['sale_id'] . " | " . to_currency($summary["subtotal"]) . " | " . to_currency($summary["tax"]) . " | " . to_currency($summary["total"]);
100+
$message .= new_line();
101+
}
102+
$message .= new_line();
103+
foreach($data['sales_totals'] as $sales_total) {
104+
$finalTotal += $sales_total['total'];
105+
$message .= $sales_total['payment_type']. ': '.to_currency($sales_total['total']);
106+
$message .= new_line();
107+
}
108+
$message .= "Total: " . to_currency($finalTotal);
109+
$message .= new_line();
110+
$message .= new_line();
111+
$message .= new_line();
112+
$message .= new_line();
113+
$message .= new_line();
114+
$message .= open_drawer();
115+
$message .= new_line();
116+
$message .= new_line();
117+
118+
$this->write_receipt($message);
119+
$this->send_receipt();
120+
redirect('home/close');
121+
}
87122

88123
function write_receipt($message)
89124
{
@@ -95,7 +130,7 @@ function write_receipt($message)
95130
}
96131
}
97132

98-
function send_receipt($path)
133+
function send_receipt()
99134
{
100135
shell_exec("cat ".$this->receipt_path." > /dev/usb/lp0");
101136
}

application/tmp/receipt.txt

75 Bytes
Binary file not shown.

application/views/close.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
<?php foreach($sales_totals as $sales_total) { ?>
66
<li class="list-group-item"><?php echo $sales_total['payment_type']. ': '.to_currency($sales_total['total']); ?></li>
77
<?php }?>
8+
<li class="list-group-item">Total: <?php echo to_currency($final_total); ?></li>
89
</ul>
10+
<div class="panel-body">
11+
<div class="row">
12+
<div class="col-xs-6"><a id="print_btn" href="<?php echo site_url("home/print_totals");?>" type="button" class="btn btn-primary btn-lg btn-block"><?php echo $this->lang->line('common_print_totals'); ?></a></div>
13+
<div class="col-xs-6"><a id="logout_btn" href="<?php echo site_url("home/logout");?>" type="button" class="btn btn-default btn-lg btn-block"><?php echo $this->lang->line('common_logout'); ?></a></div>
14+
</div>
15+
</div>
916
</div>
1017
<?php $this->load->view("partial/footer"); ?>

application/views/partial/header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<ul class="nav navbar-nav navbar-right">
6060
<?php /* <li><?php echo date('F d, Y h:i a') ?></li> */ ?>
6161
<li><a href="<?php echo site_url("config");?>"><span class="glyphicon glyphicon-cog"></span> <?php echo $this->lang->line("module_config") ?></a></li>
62-
<li><a href="<?php echo site_url("home/logout");?>"><span class="glyphicon glyphicon-log-out"></span> <?php echo $this->lang->line("common_logout") ?></a></li>
62+
<li><a href="<?php echo site_url("home/close");?>"><span class="glyphicon glyphicon-log-out"></span> <?php echo $this->lang->line("common_logout") ?></a></li>
6363
</ul>
6464
</div><!--/.nav-collapse -->
6565
</div>

application/views/sales/receipt.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
<?php echo "<img src='index.php/barcode?barcode=$sale_id&text=$sale_id&width=250&height=50' />"; ?>
105105
</div>
106106
</div>
107+
<?php if(isset($is_transaction) && $is_transaction){ ?>
108+
<a href="<?php echo site_url("sales"); ?>" class="btn btn-primary btn-lg btn-block"><?php echo $this->lang->line('sales_new_sale'); ?></a>
109+
<? } ?>
107110
<?php $this->load->view("partial/footer"); ?>
108111

109112
<?php if ($this->Appconfig->get('print_after_sale'))

css/receipt.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
font-family:Arial;
44
width:100%;
5+
margin-bottom:10px;
56
}
67

78
#receipt_header

0 commit comments

Comments
 (0)