Invoice number can now be enabled/disabled

Invoice unique constraint only applies when enabling invoice
Correct several HTML structure errors in sale and order modules
Make the top module bar a bit wider
Fix payment details css when hiding/showing invoice number field
This commit is contained in:
jekkos-t520
2014-12-04 22:01:40 +01:00
parent 1c1b89db21
commit 64f1b4191a
6 changed files with 195 additions and 266 deletions

View File

@@ -59,6 +59,11 @@ class Sales extends Secure_area
$this->sale_lib->set_invoice_number($this->input->post('sales_invoice_number'));
}
function set_invoice_number_enabled()
{
$this->sale_lib->set_invoice_number_enabled($this->input->post('sales_invoice_number_enabled'));
}
function set_email_receipt()
{
$this->sale_lib->set_email_receipt($this->input->post('email_receipt'));
@@ -210,11 +215,11 @@ class Sales extends Secure_area
$data['total']=$this->sale_lib->get_total();
$data['receipt_title']=$this->lang->line('sales_receipt');
$data['transaction_time']= date('m/d/Y h:i:s a');
$stock_locations = $this->Stock_locations->get_undeleted_all()->result_array();
$data['show_stock_locations'] = count($stock_locations) > 1;
$stock_locations=$this->Stock_locations->get_undeleted_all()->result_array();
$data['show_stock_locations']=count($stock_locations) > 1;
$customer_id=$this->sale_lib->get_customer();
$employee_id=$this->Employee->get_logged_in_employee_info()->person_id;
$comment = $this->sale_lib->get_comment();
$comment=$this->sale_lib->get_comment();
$emp_info=$this->Employee->get_info($employee_id);
$data['payments']=$this->sale_lib->get_payments();
$data['amount_change']=to_currency($this->sale_lib->get_amount_due() * -1);
@@ -226,15 +231,15 @@ class Sales extends Secure_area
$data['customer']=$cust_info->first_name.' '.$cust_info->last_name;
}
$invoice_number=$this->_substitute_invoice_number($cust_info);
if ($this->Sale->invoice_number_exists($invoice_number))
if ($this->sale_lib->is_invoice_number_enabled() && $this->Sale->invoice_number_exists($invoice_number))
{
$data['error']=$this->lang->line('sales_invoice_number_duplicate');
$this->_reload($data);
}
else
{
$invoice_number = $this->sale_lib->is_invoice_number_enabled() ? $invoice_number : NULL;
$data['invoice_number']=$invoice_number;
//SAVE sale to database
$data['sale_id']='POS '.$this->Sale->save($data['cart'], $customer_id,$employee_id,$comment,$invoice_number,$data['payments']);
if ($data['sale_id'] == 'POS -1')
{
@@ -443,7 +448,8 @@ class Sales extends Secure_area
$data['customer_email']=$cust_info->email;
}
$data['invoice_number']=$this->_substitute_invoice_number($cust_info);
$data['payments_cover_total'] = $this->_payments_cover_total();
$data['invoice_number_enabled']=$this->sale_lib->is_invoice_number_enabled();
$data['payments_cover_total']=$this->_payments_cover_total();
$this->load->view("sales/register",$data);
$this->_remove_duplicate_cookies();
}

View File

@@ -67,6 +67,23 @@ class Sale_lib
$this->CI->session->unset_userdata('sales_invoice_number');
}
function is_invoice_number_enabled()
{
return $this->CI->session->userdata('sales_invoice_number_enabled') == 'true' ||
$this->CI->session->userdata('sales_invoice_number_enabled') == '1';
}
function set_invoice_number_enabled($invoice_number_enabled)
{
return $this->CI->session->set_userdata('sales_invoice_number_enabled', $invoice_number_enabled);
}
function clear_invoice_number_enabled()
{
$enable = $this->CI->config->config['sales_invoice_enable'];
$this->set_invoice_number_enabled($enable);
}
function get_email_receipt()
{
return $this->CI->session->userdata('email_receipt');
@@ -470,6 +487,7 @@ class Sale_lib
$this->clear_comment();
$this->clear_email_receipt();
$this->clear_invoice_number();
$this->clear_invoice_number_enabled();
$this->empty_payments();
$this->remove_customer();
}

View File

@@ -13,30 +13,14 @@ if(isset($error))
<div id="register_wrapper">
<?php echo form_open("receivings/change_mode",array('id'=>'mode_form')); ?>
<span><?php echo $this->lang->line('recvs_mode') ?></span>
<span><?php echo $this->lang->line('recvs_mode') ?></span>
<?php echo form_dropdown('mode',$modes,$mode,'onchange="$(\'#mode_form\').submit();"'); ?>
<?php
if ($show_stock_locations)
{
?>
<span><?php echo $this->lang->line('recvs_stock_source') ?></span>
<?php echo form_dropdown('stock_source',$stock_locations,$stock_source,'onchange="$(\'#mode_form\').submit();"'); ?>
<?php
if($mode=='requisition')
{
?>
<span><?php echo $this->lang->line('recvs_stock_destination') ?></span>
<?php echo form_dropdown('stock_destination',$stock_locations,$stock_destination,'onchange="$(\'#mode_form\').submit();"');
}
}
?>
</form>
<?php echo form_open("receivings/add",array('id'=>'add_item_form')); ?>
<label id="item_label" for="item">
<?php
if($mode=='receive' or $mode=='requisition')
if($mode=='receive')
{
echo $this->lang->line('recvs_find_or_scan_item');
}
@@ -61,14 +45,14 @@ if(isset($error))
<table id="register">
<thead>
<tr>
<th style="width:11%;"><?php echo $this->lang->line('common_delete'); ?></th>
<th style="width:30%;"><?php echo $this->lang->line('recvs_item_name'); ?></th>
<th style="width:11%;"><?php echo $this->lang->line('recvs_cost'); ?></th>
<th style="width:5%;"><?php echo $this->lang->line('recvs_quantity'); ?></th>
<th style="width:6%;"></th>
<th style="width:11%;"><?php echo $this->lang->line('recvs_discount'); ?></th>
<th style="width:15%;"><?php echo $this->lang->line('recvs_total'); ?></th>
<th style="width:11%;"><?php echo $this->lang->line('recvs_edit'); ?></th>
<th style="width:11%;"><?php echo $this->lang->line('common_delete'); ?></th>
<th style="width:30%;"><?php echo $this->lang->line('recvs_item_name'); ?></th>
<th style="width:11%;"><?php echo $this->lang->line('recvs_cost'); ?></th>
<th style="width:11%;"><?php echo $this->lang->line('recvs_quantity'); ?></th>
<th style="width:11%;"><?php echo $this->lang->line('recvs_discount'); ?></th>
<th style="width:15%;"><?php echo $this->lang->line('recvs_total'); ?></th>
<th style="width:11%;"><?php echo $this->lang->line('recvs_edit'); ?></th>
</tr>
</thead>
<tbody id="cart_contents">
@@ -76,7 +60,7 @@ if(isset($error))
if(count($cart)==0)
{
?>
<tr><td colspan='8'>
<tr><td colspan='7'>
<div class='warning_message' style='padding:7px;'><?php echo $this->lang->line('sales_no_items_in_cart'); ?></div>
</tr></tr>
<?php
@@ -90,67 +74,70 @@ else
?>
<tr>
<td><?php echo anchor("receivings/delete_item/$line",'['.$this->lang->line('common_delete').']');?></td>
<td style="align:center;"><?php echo $item['name']; ?><br /> [<?php echo $item['in_stock']; ?> in <?php echo $item['stock_name']; ?>]</td>
<?php echo form_hidden('location', $item['item_location']); ?>
<td style="align:center;"><?php echo $item['name']; ?><br /> [<?php echo $item['in_stock']; ?> in <?php echo $item['stock_name']; ?>]
<?php echo form_hidden('location', $item['item_location']); ?></td>
<?php
echo $item['description'];
echo form_hidden('description',$item['description']);
?>
<?php if ($items_module_allowed)
{
?>
<td><?php echo form_input(array('name'=>'price','value'=>$item['price'],'size'=>'6'));?></td>
<?php
}
else
{
?>
<td><?php echo $item['price']; ?></td>
<?php echo form_hidden('price',$item['price']); ?>
<?php
}
?>
<td>
<?php
echo form_input(array('name'=>'quantity','value'=>$item['quantity'],'size'=>'2'));
?>
</td>
<?php if ($items_module_allowed && !$mode=='requisition')
{
?>
<td><?php echo form_input(array('name'=>'price','value'=>$item['price'],'size'=>'6'));?></td>
<?php
}
else
{
?>
<td><?php echo $item['price']; ?></td>
<?php echo form_hidden('price',$item['price']); ?>
<?php
}
?>
<td>
<?php
echo form_input(array('name'=>'quantity','value'=>$item['quantity'],'size'=>'2'));
if ($item['receiving_quantity'] > 1)
<td><?php echo form_input(array('name'=>'discount','value'=>$item['discount'],'size'=>'3'));?></td>
<td><?php echo to_currency($item['price']*$item['quantity']-$item['price']*$item['quantity']*$item['discount']/100); ?></td>
<td><?php echo form_submit("edit_item", $this->lang->line('sales_edit_item'));?></td>
</tr>
<tr>
<?php
if($item['allow_alt_description']==1)
{
?>
<td>x <?php echo $item['receiving_quantity']; ?></td>
<?php
}
else
{
?>
<td></td>
<?php
}
?>
</td>
<?php if ($items_module_allowed && $mode!='requisition')
{
?>
<td><?php echo form_input(array('name'=>'discount','value'=>$item['discount'],'size'=>'3'));?></td>
<?php
}
else
{
?>
<td><?php echo $item['discount']; ?></td>
<?php echo form_hidden('discount',$item['discount']); ?>
<?php
}
?>
<td><?php echo to_currency($item['price']*$item['quantity']-$item['price']*$item['quantity']*$item['receiving_quantity']*$item['discount']/100); ?></td>
<td><?php echo form_submit("edit_item", $this->lang->line('sales_edit_item'));?></td>
</tr>
</form>
<?php
}
?>
<td style="color: #2F4F4F;"><?php echo $this->lang->line('sales_description_abbrv').':';?></td>
<?php
}
?>
<td colspan=2 style="text-align: left;">
<?php
if($item['allow_alt_description']==1)
{
echo form_input(array('name'=>'description','value'=>$item['description'],'size'=>'20'));
}
else
{
if ($item['description']!='')
{
echo $item['description'];
echo form_hidden('description',$item['description']);
}
else
{
echo $this->lang->line('sales_no_description');
echo form_hidden('description','');
}
}
?>
</td>
<td colspan="4"></td>
</tr>
</form>
<?php
}
}
?>
</tbody>
@@ -184,86 +171,26 @@ else
}
?>
<?php
if($mode != 'requisition')
{
?>
<div id='sale_details'>
<div class="float_left" style='width:55%;'><?php echo $this->lang->line('sales_total'); ?>:</div>
<div class="float_left" style="width:45%;font-weight:bold;"><?php echo to_currency($total); ?></div>
</div>
<?php
}
?>
<?php
if(count($cart) > 0)
{
if($mode == 'requisition')
{
?>
<div style='border-top:2px solid #000;' />
<div id="finish_sale">
<?php echo form_open("receivings/requisition_complete",array('id'=>'finish_sale_form')); ?>
<br />
<label id="comment_label" for="comment"><?php echo $this->lang->line('common_comments'); ?>:</label>
<?php echo form_textarea(array('name'=>'comment','id'=>'comment','value'=>$comment,'rows'=>'4','cols'=>'23'));?>
<br /><br />
<div class='small_button' id='finish_sale_button' style='float:right;margin-top:5px;'>
<span><?php echo $this->lang->line('recvs_complete_receiving') ?></span>
</div>
</form>
<?php echo form_open("receivings/cancel_receiving",array('id'=>'cancel_sale_form')); ?>
<div class='small_button' id='cancel_sale_button' style='float:left;margin-top:5px;'>
<span><?php echo $this->lang->line('recvs_cancel_receving')?></span>
</div>
</form>
</div>
<?php
}
else
{
?>
<div id="finish_sale">
<?php echo form_open("receivings/complete",array('id'=>'finish_sale_form')); ?>
<br />
<label id="comment_label" for="comment"><?php echo $this->lang->line('common_comments'); ?>:</label>
<?php echo form_textarea(array('name'=>'comment','id'=>'comment','value'=>$comment,'rows'=>'4','cols'=>'23'));?>
<?php echo form_textarea(array('name'=>'comment','value'=>'','rows'=>'4','cols'=>'23'));?>
<br /><br />
<table width="100%">
<?php if ($mode == "receive")
{
?>
<tr>
<td>
<?php echo $this->lang->line('recvs_invoice_enable'); ?>
</td>
<td>
<?php echo form_checkbox(array('name'=>'recv_invoice_enable','id'=>'recv_invoice_enable','size'=>10,'checked'=>$this->config->item('recv_invoice_enable')));?>
</td>
</tr>
<tr>
<td>
<?php echo $this->lang->line('recvs_invoice_number').': ';?>
</td>
<td>
<?php echo form_input(array('name'=>'recv_invoice_number','id'=>'recv_invoice_number','value'=>$invoice_number,'size'=>10));?>
</td>
</tr>
<?php
}
?>
<tr>
<td>
<?php echo $this->lang->line('sales_payment').': ';?>
</td>
<td>
<?php echo form_dropdown('payment_type',$payment_options);?>
<table width="100%"><tr><td>
<?php
echo $this->lang->line('sales_payment').': ';?>
</td><td>
<?php
echo form_dropdown('payment_type',$payment_options);?>
</td>
</tr>
@@ -280,30 +207,22 @@ else
</table>
<br />
<div class='small_button' id='finish_sale_button' style='float:right;margin-top:5px;'>
<span><?php echo $this->lang->line('recvs_complete_receiving') ?></span>
</div>
<div class="small_button" id="finish_sale_button" style="float:right;margin-top:5px;"><span><?php echo $this->lang->line('recvs_complete_receiving');?></span></div>
</form>
<?php echo form_open("receivings/cancel_receiving",array('id'=>'cancel_sale_form')); ?>
<div class='small_button' id='cancel_sale_button' style='float:left;margin-top:5px;'>
<span><?php echo $this->lang->line('recvs_cancel_receiving')?></span>
<span>Cancel </span>
</div>
</form>
</div>
<?php
}
}
?>
</div>
<div class="clearfix" style="margin-bottom:30px;">&nbsp;</div>
<?php $this->load->view("partial/footer"); ?>
<script type="text/javascript" language="javascript">
$(document).ready(function()
{
@@ -323,8 +242,6 @@ $(document).ready(function()
$("#add_item_form").submit();
});
$('#item').focus();
$('#item').blur(function()
{
$(this).attr('value',"<?php echo $this->lang->line('sales_start_typing_item_name'); ?>");
@@ -355,32 +272,6 @@ $(document).ready(function()
$(this).attr('value',"<?php echo $this->lang->line('recvs_start_typing_supplier_name'); ?>");
});
$('#comment').keyup(function()
{
$.post('<?php echo site_url("receivings/set_comment");?>', {comment: $('#comment').val()});
});
$('#recv_invoice_number').keyup(function()
{
$.post('<?php echo site_url("receivings/set_invoice_number");?>', {recv_invoice_number: $('#recv_invoice_number').val()});
});
var enable_invoice_number = function()
{
if ($("#recv_invoice_enable").is(":checked"))
{
$("#recv_invoice_number").removeAttr("disabled").parents('tr').show();
}
else
{
$("#recv_invoice_number").attr("disabled", "disabled").parents('tr').hide();
}
}
enable_invoice_number();
$("#recv_invoice_enable").change(enable_invoice_number);
$("#finish_sale_button").click(function()
{
if (confirm('<?php echo $this->lang->line("recvs_confirm_finish_receiving"); ?>'))
@@ -418,4 +309,5 @@ function post_person_form_submit(response)
}
}
</script>
</script>
<?php $this->load->view("partial/footer"); ?>

View File

@@ -116,62 +116,66 @@ else
?>
</td>
<td><?php echo form_input(array('name'=>'discount','value'=>$item['discount'],'size'=>'3'));?></td>
<td><?php echo to_currency($item['price']*$item['quantity']-$item['price']*$item['quantity']*$item['discount']/100); ?></td>
<td><?php echo form_submit("edit_item", $this->lang->line('sales_edit_item'));?></td>
</tr>
<tr>
<td style="color: #2F4F4F";><?php echo $this->lang->line('sales_description_abbrv').':';?></td>
<td colspan=2 style="text-align: left;">
<?php
if($item['allow_alt_description']==1)
{
echo form_input(array('name'=>'description','value'=>$item['description'],'size'=>'20'));
}
else
{
if ($item['description']!='')
{
echo $item['description'];
echo form_hidden('description',$item['description']);
}
else
{
echo $this->lang->line('sales_no_description');
echo form_hidden('description','');
}
}
?>
</td>
<td>&nbsp;</td>
<td style="color: #2F4F4F";>
<?php
if($item['is_serialized']==1)
{
echo $this->lang->line('sales_serial').':';
}
?>
</td>
<td colspan=3 style="text-align: left;">
<?php
if($item['is_serialized']==1)
{
echo form_input(array('name'=>'serialnumber','value'=>$item['serialnumber'],'size'=>'20'));
}
else
<td><?php echo form_input(array('name'=>'discount','value'=>$item['discount'],'size'=>'3'));?></td>
<td><?php echo to_currency($item['price']*$item['quantity']-$item['price']*$item['quantity']*$item['discount']/100); ?></td>
<td><?php echo form_submit("edit_item", $this->lang->line('sales_edit_item'));?></td>
</tr>
<tr>
<?php
if($item['allow_alt_description']==1)
{
echo form_hidden('serialnumber', '');
?>
<td style="color: #2F4F4F;"><?php echo $this->lang->line('sales_description_abbrv').':';?></td>
<?php
}
?>
</td>
</tr>
<tr style="height: 3px">
<td colspan=8 style="background-color: white"></td>
</tr>
</form>
?>
<td colspan=2 style="text-align: left;">
<?php
if($item['allow_alt_description']==1)
{
echo form_input(array('name'=>'description','value'=>$item['description'],'size'=>'20'));
}
else
{
if ($item['description']!='')
{
echo $item['description'];
echo form_hidden('description',$item['description']);
}
else
{
echo $this->lang->line('sales_no_description');
echo form_hidden('description','');
}
}
?>
</td>
<td>&nbsp;</td>
<td style="color: #2F4F4F;">
<?php
if($item['is_serialized']==1)
{
echo $this->lang->line('sales_serial').':';
}
?>
</td>
<td colspan="4" style="text-align: left;">
<?php
if($item['is_serialized']==1)
{
echo form_input(array('name'=>'serialnumber','value'=>$item['serialnumber'],'size'=>'20'));
}
else
{
echo form_hidden('serialnumber', '');
}
?>
</td>
</tr>
<tr style="height: 3px">
<td colspan=8 style="background-color: white"></td>
</tr>
</form>
<?php
}
}
@@ -289,9 +293,9 @@ else
</tr>
</table>
<div id="Payment_Types">
<div id="payment_details">
<div style="height: 100px;">
<div>
<?php echo form_open("sales/add_payment",array('id'=>'add_payment_form')); ?>
<table width="100%">
@@ -303,7 +307,15 @@ else
<?php echo $this->lang->line('sales_invoice_enable'); ?>
</td>
<td>
<?php echo form_checkbox(array('name'=>'sales_invoice_enable','id'=>'sales_invoice_enable','size'=>10,'checked'=>$this->config->item('sales_invoice_enable')));?>
<?php if ($invoice_number_enabled)
{
echo form_checkbox(array('name'=>'sales_invoice_enable','id'=>'sales_invoice_enable','size'=>10,'checked'=>'checked'));
}
else
{
echo form_checkbox(array('name'=>'sales_invoice_enable','id'=>'sales_invoice_enable','size'=>10));
}
?>
</td>
</tr>
<tr>
@@ -337,8 +349,8 @@ else
style='float: left; margin-top: 5px;'>
<span><?php echo $this->lang->line('sales_add_payment'); ?></span>
</div>
</div>
</form>
</div>
<?php
// Only show this part if there is at least one payment entered.
@@ -390,9 +402,6 @@ else
</div>
<div class="clearfix" style="margin-bottom: 30px;">&nbsp;</div>
<?php $this->load->view("partial/footer"); ?>
<script type="text/javascript" language="javascript">
$(document).ready(function()
{
@@ -412,8 +421,6 @@ $(document).ready(function()
$("#add_item_form").submit();
});
$('#item').focus();
$('#item').blur(function()
{
$(this).val("<?php echo $this->lang->line('sales_start_typing_item_name'); ?>");
@@ -460,7 +467,8 @@ $(document).ready(function()
var enable_invoice_number = function()
{
if ($("#sales_invoice_enable").is(":checked"))
var enabled = $("#sales_invoice_enable").is(":checked");
if (enabled)
{
$("#sales_invoice_number").removeAttr("disabled").parents('tr').show();
}
@@ -468,11 +476,15 @@ $(document).ready(function()
{
$("#sales_invoice_number").attr("disabled", "disabled").parents('tr').hide();
}
return enabled;
}
enable_invoice_number();
$("#sales_invoice_enable").change(enable_invoice_number);
$("#sales_invoice_enable").change(function() {
var enabled = enable_invoice_number();
$.post('<?php echo site_url("sales/set_invoice_number_enabled");?>', {sales_invoice_number_enabled: enabled});
});
$('#email_receipt').change(function()
{
@@ -510,7 +522,7 @@ $(document).ready(function()
$('#add_payment_form').submit();
});
$("#payment_types").change(checkPaymentTypeGiftcard).ready(checkPaymentTypeGiftcard)
$("#payment_types").change(check_payment_type_gifcard).ready(check_payment_type_gifcard)
});
function post_item_form_submit(response)
@@ -532,7 +544,7 @@ function post_person_form_submit(response)
}
}
function checkPaymentTypeGiftcard()
function check_payment_type_gifcard()
{
if ($("#payment_types").val() == "<?php echo $this->lang->line('sales_giftcard'); ?>")
{
@@ -547,3 +559,4 @@ function checkPaymentTypeGiftcard()
}
</script>
<?php $this->load->view("partial/footer"); ?>

View File

@@ -16,7 +16,7 @@
{
position:relative;
margin:0 auto;
width:875px;
width:960px;
text-align:left;
}

View File

@@ -105,7 +105,7 @@
position:relative;
}
#Payment_Types
#payment_details
{
float:left;
width:100%;