Fix exceptions in invoice and receipt emails (#1325)

This commit is contained in:
FrancescoUK
2017-07-14 11:28:08 +01:00
parent fe05845bd4
commit dc0d580d05
5 changed files with 120 additions and 110 deletions

View File

@@ -1,7 +1,7 @@
<?php $this->load->view("partial/header"); ?>
<?php
if (isset($error_message))
if(isset($error_message))
{
echo "<div class='alert alert-dismissible alert-danger'>".$error_message."</div>";
exit;
@@ -68,7 +68,7 @@ $(document).ready(function()
?>
<div>&nbsp</div>
<?php
if ($this->Appconfig->get('receipt_show_company_name'))
if($this->Appconfig->get('receipt_show_company_name'))
{
?>
<div id="company_name"><?php echo $this->config->item('company'); ?></div>
@@ -219,9 +219,9 @@ $(document).ready(function()
$(window).on("load", function()
{
// install firefox addon in order to use this plugin
if (window.jsPrintSetup)
if(window.jsPrintSetup)
{
<?php if (!$this->Appconfig->get('print_header'))
<?php if(!$this->Appconfig->get('print_header'))
{
?>
// set page header
@@ -231,7 +231,7 @@ $(window).on("load", function()
<?php
}
if (!$this->Appconfig->get('print_footer'))
if(!$this->Appconfig->get('print_footer'))
{
?>
// set empty page footer

View File

@@ -1,4 +1,4 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
@@ -7,7 +7,7 @@
<body>
<?php
if (isset($error_message))
if(isset($error_message))
{
echo "<div class='alert alert-dismissible alert-danger'>".$error_message."</div>";
exit;
@@ -19,10 +19,10 @@ if (isset($error_message))
<table id="info">
<tr>
<td id="logo">
<?php if($this->config->item('company_logo') != '')
{
<?php if($this->config->item('company_logo') != '')
{
?>
<img id="image" src="<?php echo 'uploads/' . $this->config->item('company_logo'); ?>" alt="company_logo" />
<img id="image" src="<?php echo 'uploads/' . $this->config->item('company_logo'); ?>" alt="company_logo" />
<?php
}
?>
@@ -46,14 +46,14 @@ if (isset($error_message))
<td class="meta-head"><?php echo $this->lang->line('common_date'); ?></td>
<td><div><?php echo $transaction_date; ?></div></td>
</tr>
<?php if ($amount_due > 0)
<?php if($amount_due > 0)
{
?>
<tr>
<td class="meta-head"><?php echo $this->lang->line('sales_amount_due'); ?></td>
<td><div class="due"><?php echo to_currency($total); ?></div></td>
</tr>
<?php
<?php
}
?>
</table>
@@ -62,16 +62,15 @@ if (isset($error_message))
</table>
<table id="items">
<tr>
<th><?php echo $this->lang->line('sales_item_number'); ?></th>
<th><?php echo $this->lang->line('sales_item_name'); ?></th>
<th><?php echo $this->lang->line('sales_quantity'); ?></th>
<th><?php echo $this->lang->line('sales_price'); ?></th>
<th><?php echo $this->lang->line('sales_discount'); ?></th>
<th><?php echo $this->lang->line('sales_total'); ?></th>
</tr>
<?php
<tr>
<th><?php echo $this->lang->line('sales_item_number'); ?></th>
<th><?php echo $this->lang->line('sales_item_name'); ?></th>
<th><?php echo $this->lang->line('sales_quantity'); ?></th>
<th><?php echo $this->lang->line('sales_price'); ?></th>
<th><?php echo $this->lang->line('sales_discount'); ?></th>
<th><?php echo $this->lang->line('sales_total'); ?></th>
</tr>
<?php
foreach($cart as $line=>$item)
{
?>
@@ -89,26 +88,31 @@ if (isset($error_message))
<tr>
<td colspan="6" align="center"><?php echo '&nbsp;'; ?></td>
</tr>
<tr>
<td colspan="3" class="blank"> </td>
<td colspan="2" class="total-line"><?php echo $this->lang->line('sales_sub_total'); ?></td>
<td id="subtotal" class="total-value"><?php echo to_currency($tax_exclusive_subtotal); ?></td>
</tr>
<?php foreach($taxes as $name=>$value) { ?>
<tr>
<td colspan="3" class="blank"> </td>
<td colspan="2" class="total-line"><?php echo $name; ?></td>
<td id="taxes" class="total-value"><?php echo to_currency_tax($value); ?></td>
</tr>
<?php }; ?>
<tr>
<td colspan="3" class="blank"> </td>
<td colspan="2" class="total-line"><?php echo $this->lang->line('sales_total'); ?></td>
<td id="total" class="total-value"><?php echo to_currency($total); ?></td>
</tr>
<tr>
<td colspan="3" class="blank"> </td>
<td colspan="2" class="total-line"><?php echo $this->lang->line('sales_sub_total'); ?></td>
<td id="subtotal" class="total-value"><?php echo to_currency($subtotal); ?></td>
</tr>
<?php
foreach($taxes as $tax_group_index=>$sales_tax)
{
?>
<tr>
<td colspan="3" class="blank"> </td>
<td colspan="2" class="total-line"><?php echo $sales_tax['tax_group']; ?></td>
<td id="taxes" class="total-value"><?php echo to_currency_tax($sales_tax['sale_tax_amount']); ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="3" class="blank"> </td>
<td colspan="2" class="total-line"><?php echo $this->lang->line('sales_total'); ?></td>
<td id="total" class="total-value"><?php echo to_currency($total); ?></td>
</tr>
</table>
<div id="terms">
<div id="sale_return_policy">
<h5>

View File

@@ -1,17 +1,19 @@
<div id="receipt_wrapper">
<div id="receipt_header">
<?php
if ($this->config->item('company_logo') != '')
{
if($this->config->item('company_logo') != '')
{
?>
<div id="company_name"><img id="image" src="<?php echo base_url('uploads/' . $this->config->item('company_logo')); ?>" alt="company_logo" /></div>
<div id="company_name">
<img id="image" src="<?php echo base_url('uploads/' . $this->config->item('company_logo')); ?>" alt="company_logo" />
</div>
<?php
}
?>
<?php
if ($this->config->item('receipt_show_company_name'))
{
if($this->config->item('receipt_show_company_name'))
{
?>
<div id="company_name"><?php echo $this->config->item('company'); ?></div>
<?php
@@ -33,15 +35,15 @@
<?php
}
?>
<div id="sale_id"><?php echo $this->lang->line('sales_id').": ".$sale_id; ?></div>
<?php
if (!empty($invoice_number))
if(!empty($invoice_number))
{
?>
<div id="invoice_number"><?php echo $this->lang->line('sales_invoice_number').": ".$invoice_number; ?></div>
<?php
<div id="invoice_number"><?php echo $this->lang->line('sales_invoice_number').": ".$invoice_number; ?></div>
<?php
}
?>
@@ -84,7 +86,7 @@
?>
</tr>
<?php
if ($item['discount'] > 0)
if($item['discount'] > 0)
{
?>
<tr>
@@ -97,11 +99,11 @@
<?php
}
?>
<?php
if ($this->config->item('receipt_show_total_discount') && $discount > 0)
if($this->config->item('receipt_show_total_discount') && $discount > 0)
{
?>
?>
<tr>
<td colspan="3" style='text-align:right;border-top:2px solid #000000;'><?php echo $this->lang->line('sales_sub_total'); ?></td>
<td style='text-align:right;border-top:2px solid #000000;'><?php echo to_currency($prediscount_subtotal); ?></td>
@@ -115,9 +117,9 @@
?>
<?php
if ($this->config->item('receipt_show_taxes'))
if($this->config->item('receipt_show_taxes'))
{
?>
?>
<tr>
<td colspan="3" style='text-align:right;border-top:2px solid #000000;'><?php echo $this->lang->line('sales_sub_total'); ?></td>
<td style='text-align:right;border-top:2px solid #000000;'><?php echo to_currency($subtotal); ?></td>
@@ -139,8 +141,8 @@
<tr>
</tr>
<?php $border = (!$this->config->item('receipt_show_taxes') && !($this->config->item('receipt_show_total_discount') && $discount > 0)); ?>
<?php $border = (!$this->config->item('receipt_show_taxes') && !($this->config->item('receipt_show_total_discount') && $discount > 0)); ?>
<tr>
<td colspan="3" style="text-align:right;<?php echo $border? 'border-top: 2px solid black;' :''; ?>"><?php echo $this->lang->line('sales_total'); ?></td>
<td style="text-align:right;<?php echo $border? 'border-top: 2px solid black;' :''; ?>"><?php echo to_currency($total); ?></td>
@@ -154,7 +156,7 @@
$only_sale_check = FALSE;
$show_giftcard_remainder = FALSE;
foreach($payments as $payment_id=>$payment)
{
{
$only_sale_check |= $payment['payment_type'] == $this->lang->line('sales_check');
$splitpayment = explode(':', $payment['payment_type']);
$show_giftcard_remainder |= $splitpayment[0] == $this->lang->line('sales_giftcard');
@@ -171,15 +173,15 @@
<td colspan="4">&nbsp;</td>
</tr>
<?php
if (isset($cur_giftcard_value) && $show_giftcard_remainder)
<?php
if(isset($cur_giftcard_value) && $show_giftcard_remainder)
{
?>
<tr>
<td colspan="3" style="text-align:right;"><?php echo $this->lang->line('sales_giftcard_balance'); ?></td>
<td class="total-value"><?php echo to_currency($cur_giftcard_value); ?></td>
</tr>
<?php
<?php
}
?>
<tr>

View File

@@ -1,17 +1,19 @@
<div id="receipt_wrapper" style="width:100%;">
<div id="receipt_header" style="text-align:center;">
<?php
if ($this->config->item('company_logo') != '')
{
if($this->config->item('company_logo') != '')
{
?>
<div id="company_name"><img id="image" src="<?php echo base_url('uploads/' . $this->config->item('company_logo')); ?>" alt="company_logo" /></div>
<div id="company_name">
<img id="image" src="data:image/png;base64,<?php echo base64_encode(file_get_contents('uploads/' . $this->config->item('company_logo'))); ?>" alt="company_logo" />
</div>
<?php
}
?>
<?php
if ($this->config->item('receipt_show_company_name'))
{
if($this->config->item('receipt_show_company_name'))
{
?>
<div id="company_name" style="font-size:150%; font-weight:bold;"><?php echo $this->config->item('company'); ?></div>
<?php
@@ -24,7 +26,7 @@
<div id="sale_receipt"><?php echo $receipt_title; ?></div>
<div id="sale_time"><?php echo $transaction_time ?></div>
</div>
<br>
<div id="receipt_general_info" style="text-align:left;">
@@ -40,7 +42,7 @@
<div id="sale_id"><?php echo $this->lang->line('sales_id').": ".$sale_id; ?></div>
<div id="employee"><?php echo $this->lang->line('employees_employee').": ".$employee; ?></div>
</div>
<br>
<table id="receipt_items" style="text-align:left;width:100%;">
@@ -51,7 +53,7 @@
<th style="width:20%;text-align:right;"><?php echo $this->lang->line('sales_total'); ?></th>
</tr>
<?php
foreach(array_reverse($cart, TRUE) as $line=>$item)
foreach($cart as $line=>$item)
{
?>
<tr>
@@ -79,7 +81,7 @@
?>
</tr>
<?php
if ($item['discount'] > 0)
if($item['discount'] > 0)
{
?>
<tr>
@@ -92,11 +94,11 @@
<?php
}
?>
<?php
if ($this->config->item('receipt_show_total_discount') && $discount > 0)
if($this->config->item('receipt_show_total_discount') && $discount > 0)
{
?>
?>
<tr>
<td colspan="3" style="text-align:right;border-top:2px solid #000000;"><?php echo $this->lang->line('sales_sub_total'); ?></td>
<td style="text-align:right;border-top:2px solid #000000;"><?php echo to_currency($subtotal); ?></td>
@@ -110,20 +112,20 @@
?>
<?php
if ($this->config->item('receipt_show_taxes'))
if($this->config->item('receipt_show_taxes'))
{
?>
?>
<tr>
<td colspan="3" style='text-align:right;border-top:2px solid #000000;'><?php echo $this->lang->line('sales_sub_total'); ?></td>
<td style="text-align:right;border-top:2px solid #000000;"><?php echo to_currency($this->config->item('tax_included') ? $tax_exclusive_subtotal : $discounted_subtotal); ?></td>
<td style="text-align:right;border-top:2px solid #000000;"><?php echo to_currency($subtotal); ?></td>
</tr>
<?php
foreach($taxes as $name=>$value)
foreach($taxes as $tax_group_index=>$sales_tax)
{
?>
<tr>
<td colspan="3" style="text-align:right;"><?php echo $name; ?>:</td>
<td style="text-align:right;"><?php echo to_currency_tax($value); ?></td>
<td colspan="3" style="text-align:right;"><?php echo $sales_tax['tax_group']; ?>:</td>
<td style="text-align:right;"><?php echo to_currency_tax($sales_tax['sale_tax_amount']); ?></td>
</tr>
<?php
}
@@ -134,8 +136,8 @@
<tr>
</tr>
<?php $border = (!$this->config->item('receipt_show_taxes') && !($this->config->item('receipt_show_total_discount') && $discount > 0)); ?>
<?php $border = (!$this->config->item('receipt_show_taxes') && !($this->config->item('receipt_show_total_discount') && $discount > 0)); ?>
<tr>
<td colspan="3" style="<?php echo $border? 'border-top: 2px solid black;' :''; ?>text-align:right;"><?php echo $this->lang->line('sales_total'); ?></td>
<td style="<?php echo $border? 'border-top: 2px solid black;' :''; ?>text-align:right"><?php echo to_currency($total); ?></td>
@@ -149,7 +151,7 @@
$only_sale_check = FALSE;
$show_giftcard_remainder = FALSE;
foreach($payments as $payment_id=>$payment)
{
{
$only_sale_check |= $payment['payment_type'] == $this->lang->line('sales_check');
$splitpayment = explode(':', $payment['payment_type']);
$show_giftcard_remainder |= $splitpayment[0] == $this->lang->line('sales_giftcard');
@@ -166,22 +168,22 @@
<td colspan="4">&nbsp;</td>
</tr>
<?php
if (isset($cur_giftcard_value) && $show_giftcard_remainder)
<?php
if(isset($cur_giftcard_value) && $show_giftcard_remainder)
{
?>
<tr>
<td colspan="3" style="text-align:right;"><?php echo $this->lang->line('sales_giftcard_balance'); ?></td>
<td style="text-align:right"><?php echo to_currency($cur_giftcard_value); ?></td>
</tr>
<?php
<?php
}
?>
<tr>
<td colspan="3" style="text-align:right;"> <?php echo $this->lang->line($amount_change >= 0 ? ($only_sale_check ? 'sales_check_balance' : 'sales_change_due') : 'sales_amount_due') ; ?> </td>
<td style="text-align:right"><?php echo to_currency($amount_change); ?></td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
@@ -192,7 +194,7 @@
</div>
<br>
<div id="barcode" style="text-align:center">
<img src='data:image/png;base64,<?php echo $barcode; ?>' /><br>
<?php echo $sale_id; ?>

View File

@@ -1,17 +1,19 @@
<div id="receipt_wrapper">
<div id="receipt_header">
<?php
if ($this->config->item('company_logo') != '')
{
if($this->config->item('company_logo') != '')
{
?>
<div id="company_name"><img id="image" src="<?php echo base_url('uploads/' . $this->config->item('company_logo')); ?>" alt="company_logo" /></div>
<div id="company_name">
<img id="image" src="<?php echo base_url('uploads/' . $this->config->item('company_logo')); ?>" alt="company_logo" />
</div>
<?php
}
?>
<?php
if ($this->config->item('receipt_show_company_name'))
{
if($this->config->item('receipt_show_company_name'))
{
?>
<div id="company_name"><?php echo $this->config->item('company'); ?></div>
<?php
@@ -33,15 +35,15 @@
<?php
}
?>
<div id="sale_id"><?php echo $this->lang->line('sales_id').": ".$sale_id; ?></div>
<?php
if (!empty($invoice_number))
if(!empty($invoice_number))
{
?>
<div id="invoice_number"><?php echo $this->lang->line('sales_invoice_number').": ".$invoice_number; ?></div>
<?php
<?php
}
?>
@@ -55,7 +57,7 @@
<th colspan="4" style="width:25%;" class="total-value"><?php echo $this->lang->line('sales_total'); ?></th>
</tr>
<?php
foreach(array_reverse($cart, TRUE) as $line=>$item)
foreach($cart as $line=>$item)
{
?>
<tr>
@@ -85,7 +87,7 @@
?>
</tr>
<?php
if ($item['discount'] > 0)
if($item['discount'] > 0)
{
?>
<tr>
@@ -98,11 +100,11 @@
<?php
}
?>
<?php
if ($this->config->item('receipt_show_total_discount') && $discount > 0)
if($this->config->item('receipt_show_total_discount') && $discount > 0)
{
?>
?>
<tr>
<td colspan="2" style='text-align:right;border-top:2px solid #000000;'><?php echo $this->lang->line('sales_sub_total'); ?></td>
<td style='text-align:right;border-top:2px solid #000000;'><?php echo to_currency($subtotal); ?></td>
@@ -116,12 +118,12 @@
?>
<?php
if ($this->config->item('receipt_show_taxes'))
if($this->config->item('receipt_show_taxes'))
{
?>
?>
<tr>
<td colspan="2" style='text-align:right;border-top:2px solid #000000;'><?php echo $this->lang->line('sales_sub_total'); ?></td>
<td style='text-align:right;border-top:2px solid #000000;'><?php echo to_currency($this->config->item('tax_included') ? $tax_exclusive_subtotal : $discounted_subtotal); ?></td>
<td style='text-align:right;border-top:2px solid #000000;'><?php echo to_currency($subtotal); ?></td>
</tr>
<?php
foreach($taxes as $tax_group_index=>$sales_tax)
@@ -140,8 +142,8 @@
<tr>
</tr>
<?php $border = (!$this->config->item('receipt_show_taxes') && !($this->config->item('receipt_show_total_discount') && $discount > 0)); ?>
<?php $border = (!$this->config->item('receipt_show_taxes') && !($this->config->item('receipt_show_total_discount') && $discount > 0)); ?>
<tr>
<td colspan="2" style="text-align:right;<?php echo $border? 'border-top: 2px solid black;' :''; ?>"><?php echo $this->lang->line('sales_total'); ?></td>
<td style="text-align:right;<?php echo $border? 'border-top: 2px solid black;' :''; ?>"><?php echo to_currency($total); ?></td>
@@ -152,7 +154,7 @@
$only_sale_check = FALSE;
$show_giftcard_remainder = FALSE;
foreach($payments as $payment_id=>$payment)
{
{
$only_sale_check |= $payment['payment_type'] == $this->lang->line('sales_check');
$splitpayment = explode(':', $payment['payment_type']);
$show_giftcard_remainder |= $splitpayment[0] == $this->lang->line('sales_giftcard');
@@ -165,15 +167,15 @@
}
?>
<?php
if (isset($cur_giftcard_value) && $show_giftcard_remainder)
<?php
if(isset($cur_giftcard_value) && $show_giftcard_remainder)
{
?>
<tr>
<td colspan="2" style="text-align:right;"><?php echo $this->lang->line('sales_giftcard_balance'); ?></td>
<td class="total-value"><?php echo to_currency($cur_giftcard_value); ?></td>
</tr>
<?php
<?php
}
?>
<tr>