mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-28 19:10:11 -04:00
Add invoice number duplication check in receivings screen
Add invoice number duplication check in receivings detailed report
This commit is contained in:
@@ -617,9 +617,9 @@ class Items extends Secure_area implements iData_controller
|
||||
if ($this->Item->get_item_id($item_number) != FALSE)
|
||||
{
|
||||
$this->form_validation->set_message('item_number_check', $this->lang->line('items_item_number_exists'));
|
||||
echo json_encode(array('success'=>true,'message'=>$this->lang->line('items_successful_adding'));
|
||||
echo json_encode(array('success'=>false,'message'=>$this->lang->line('items_error_adding')));
|
||||
}
|
||||
echo json_encode(array('success'=>false,'message'=>$this->lang->line('items_error_adding'));
|
||||
echo json_encode(array('success'=>true,'message'=>$this->lang->line('items_successful_adding')));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -193,18 +193,26 @@ class Receivings extends Secure_area
|
||||
$data['supplier']=$suppl_info->first_name.' '.$suppl_info->last_name;
|
||||
}
|
||||
$invoice_number=$this->_substitute_invoice_number($suppl_info);
|
||||
$data['invoice_number']=$invoice_number;
|
||||
$data['payment_type']=$this->input->post('payment_type');
|
||||
//SAVE receiving to database
|
||||
$data['receiving_id']='RECV '.$this->Receiving->save($data['cart'], $supplier_id,$employee_id,$comment,$payment_type,$data['stock_location'],$invoice_number);
|
||||
|
||||
if ($data['receiving_id'] == 'RECV -1')
|
||||
if ($this->Receiving->invoice_number_exists($invoice_number))
|
||||
{
|
||||
$data['error_message'] = $this->lang->line('receivings_transaction_failed');
|
||||
$data['error']=$this->lang->line('recvs_invoice_number_constraint');
|
||||
$this->_reload($data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['invoice_number']=$invoice_number;
|
||||
$data['payment_type']=$this->input->post('payment_type');
|
||||
//SAVE receiving to database
|
||||
$data['receiving_id']='RECV '.$this->Receiving->save($data['cart'], $supplier_id,$employee_id,$comment,$payment_type,$data['stock_location'],$invoice_number);
|
||||
|
||||
if ($data['receiving_id'] == 'RECV -1')
|
||||
{
|
||||
$data['error_message'] = $this->lang->line('receivings_transaction_failed');
|
||||
}
|
||||
|
||||
$this->load->view("receivings/receipt",$data);
|
||||
$this->receiving_lib->clear_all();
|
||||
}
|
||||
|
||||
$this->load->view("receivings/receipt",$data);
|
||||
$this->receiving_lib->clear_all();
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
@@ -356,6 +364,14 @@ class Receivings extends Secure_area
|
||||
$this->receiving_lib->clear_all();
|
||||
$this->_reload();
|
||||
}
|
||||
|
||||
function check_invoice_number()
|
||||
{
|
||||
$receiving_id=$this->input->post('receiving_id');
|
||||
$invoice_number=$this->input->post('invoice_number');
|
||||
$exists=!empty($invoice_number) && $this->Receiving->invoice_number_exists($invoice_number,$receiving_id);
|
||||
echo json_encode(array('success'=>!$exists,'message'=>$this->lang->line('recvs_invoice_number_duplicate')));
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -24,6 +24,7 @@ class Secure_area extends CI_Controller
|
||||
$logged_in_employee_info=$this->Employee->get_logged_in_employee_info();
|
||||
$data['allowed_modules']=$this->Module->get_allowed_modules($logged_in_employee_info->person_id);
|
||||
$data['user_info']=$logged_in_employee_info;
|
||||
$data['controller_name']=$module_id;
|
||||
$this->load->vars($data);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,4 +55,5 @@ $lang['recvs_receipt']='Receivings Receipt';
|
||||
$lang['recvs_date_required']='A correct date needs to be filled in';
|
||||
$lang['recvs_date_type']='Date field is required';
|
||||
$lang['recvs_delete_confirmation'] = 'Are you sure you want to delete this receiving, this action cannot be undone';
|
||||
?>
|
||||
$lang['recvs_invoice_number_duplicate'] = 'Please enter an unique invoice number';
|
||||
?>
|
||||
@@ -168,6 +168,18 @@ class Receiving extends CI_Model
|
||||
return $this->Supplier->get_info($this->db->get()->row()->supplier_id);
|
||||
}
|
||||
|
||||
function invoice_number_exists($invoice_number,$receiving_id='')
|
||||
{
|
||||
$this->db->from('receivings');
|
||||
$this->db->where('invoice_number', $invoice_number);
|
||||
if (!empty($receiving_id))
|
||||
{
|
||||
$this->db->where('receiving_id !=', $receiving_id);
|
||||
}
|
||||
$query=$this->db->get();
|
||||
return ($query->num_rows()==1);
|
||||
}
|
||||
|
||||
//We create a temp table that allows us to do easy report/receiving queries
|
||||
public function create_receivings_items_temp_table()
|
||||
{
|
||||
|
||||
@@ -74,6 +74,24 @@
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
$.validator.addMethod("invoice_number", function(value, element)
|
||||
{
|
||||
var id = $("input[name='receiving_id']").val();
|
||||
|
||||
return JSON.parse($.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
url: '<?php echo site_url($controller_name . "/check_invoice_number")?>',
|
||||
data: {'receiving_id' : id, 'invoice_number' : $(element).val() },
|
||||
success: function(response)
|
||||
{
|
||||
success=response.success;
|
||||
},
|
||||
async:false,
|
||||
dataType: 'json'
|
||||
}).response).success;
|
||||
}, '<?php echo $this->lang->line("recvs_invoice_number_duplicate"); ?>');
|
||||
|
||||
$('#date').datePicker({startDate: '<?php echo date("%Y/%M/%d");?>'});
|
||||
$("#recvs_delete_form").submit(function()
|
||||
{
|
||||
@@ -83,7 +101,8 @@ $(document).ready(function()
|
||||
}
|
||||
});
|
||||
|
||||
var format_item = function(row) {
|
||||
var format_item = function(row)
|
||||
{
|
||||
var result = [row[0], "|", row[1]].join("");
|
||||
// if more than one occurence
|
||||
if (row[2] > 1 && row[3] && row[3].toString().trim()) {
|
||||
@@ -92,7 +111,8 @@ $(document).ready(function()
|
||||
}
|
||||
return result;
|
||||
};
|
||||
var autocompleter = $("#supplier_id").autocomplete('<?php echo site_url("receivings/supplier_search"); ?>', {
|
||||
var autocompleter = $("#supplier_id").autocomplete('<?php echo site_url("receivings/supplier_search"); ?>',
|
||||
{
|
||||
minChars:0,
|
||||
delay:15,
|
||||
max:100,
|
||||
@@ -102,7 +122,8 @@ $(document).ready(function()
|
||||
});
|
||||
|
||||
// declare submitHandler as an object.. will be reused
|
||||
var submit_form = function(selected_supplier) {
|
||||
var submit_form = function(selected_supplier)
|
||||
{
|
||||
$(this).ajaxSubmit({
|
||||
success:function(response)
|
||||
{
|
||||
@@ -110,13 +131,14 @@ $(document).ready(function()
|
||||
post_form_submit(response);
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
selected_customer && autocompleter.val(selected_supplier);
|
||||
selected_supplier && autocompleter.val(selected_supplier);
|
||||
post_form_submit({message: errorThrown});
|
||||
},
|
||||
dataType:'json'
|
||||
});
|
||||
};
|
||||
$('#recvs_edit_form').validate({
|
||||
$('#recvs_edit_form').validate(
|
||||
{
|
||||
submitHandler : function(form)
|
||||
{
|
||||
var selected_supplier = autocompleter.val();
|
||||
@@ -131,6 +153,9 @@ $(document).ready(function()
|
||||
date: {
|
||||
required:true,
|
||||
date:true
|
||||
},
|
||||
invoice_number: {
|
||||
invoice_number: true
|
||||
}
|
||||
},
|
||||
messages:
|
||||
@@ -141,9 +166,11 @@ $(document).ready(function()
|
||||
}
|
||||
}
|
||||
});
|
||||
$('#recvs_delete_form').submit(function() {
|
||||
$('#recvs_delete_form').submit(function()
|
||||
{
|
||||
var id = $("input[name='receiving_id']").val();
|
||||
$(this).ajaxSubmit({
|
||||
$(this).ajaxSubmit(
|
||||
{
|
||||
success:function(response)
|
||||
{
|
||||
tb_remove();
|
||||
|
||||
@@ -76,7 +76,8 @@ $(document).ready(function()
|
||||
}
|
||||
});
|
||||
|
||||
var format_item = function(row) {
|
||||
var format_item = function(row)
|
||||
{
|
||||
var result = [row[0], "|", row[1]].join("");
|
||||
// if more than one occurence
|
||||
if (row[2] > 1 && row[3] && row[3].toString().trim()) {
|
||||
@@ -85,7 +86,8 @@ $(document).ready(function()
|
||||
}
|
||||
return result;
|
||||
};
|
||||
var autocompleter = $("#customer_id").autocomplete('<?php echo site_url("sales/customer_search"); ?>', {
|
||||
var autocompleter = $("#customer_id").autocomplete('<?php echo site_url("sales/customer_search"); ?>',
|
||||
{
|
||||
minChars:0,
|
||||
delay:15,
|
||||
max:100,
|
||||
@@ -95,21 +97,25 @@ $(document).ready(function()
|
||||
});
|
||||
|
||||
// declare submitHandler as an object.. will be reused
|
||||
var submit_form = function(selected_customer) {
|
||||
$(this).ajaxSubmit({
|
||||
var submit_form = function(selected_customer)
|
||||
{
|
||||
$(this).ajaxSubmit(
|
||||
{
|
||||
success:function(response)
|
||||
{
|
||||
tb_remove();
|
||||
post_form_submit(response);
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
error: function(jqXHR, textStatus, errorThrown)
|
||||
{
|
||||
selected_customer && autocompleter.val(selected_customer);
|
||||
post_form_submit({message: errorThrown});
|
||||
},
|
||||
dataType:'json'
|
||||
});
|
||||
};
|
||||
$('#sales_edit_form').validate({
|
||||
$('#sales_edit_form').validate(
|
||||
{
|
||||
submitHandler : function(form)
|
||||
{
|
||||
var selected_customer = autocompleter.val();
|
||||
@@ -121,20 +127,23 @@ $(document).ready(function()
|
||||
wrapper: "li",
|
||||
rules:
|
||||
{
|
||||
date: {
|
||||
date:
|
||||
{
|
||||
required:true,
|
||||
date:true
|
||||
}
|
||||
},
|
||||
messages:
|
||||
{
|
||||
date: {
|
||||
date:
|
||||
{
|
||||
required: "<?= $this->lang->line('sales_date_required'); ?>",
|
||||
date: "<?= $this->lang->line('sales_date_type'); ?>"
|
||||
}
|
||||
}
|
||||
});
|
||||
$('#sales_delete_form').submit(function() {
|
||||
$('#sales_delete_form').submit(function()
|
||||
{
|
||||
var id = $("input[name='sale_id']").val();
|
||||
$(this).ajaxSubmit({
|
||||
success:function(response)
|
||||
|
||||
Reference in New Issue
Block a user