mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-10-25 09:38:42 -04:00
Added autocompletion for the customer field in the sale editing screen
This commit is contained in:
1 parent
a6bd5c6f0f
commit
264248b381
3 files changed
+26
-5
No files matched your search
@@ -269,8 +269,10 @@ class Sales extends Secure_area
|
||||
$data['employees'][$employee->person_id] = $employee->first_name . ' '. $employee->last_name;
|
||||
}
|
||||
|
||||
$data['sale_info'] = $this->Sale->get_info($sale_id)->row_array();
|
||||
|
||||
$sale_info = $this->Sale->get_info($sale_id)->row_array();
|
||||
$person_name = $sale_info['first_name'] . " " . $sale_info['last_name'];
|
||||
$data['selected_customer'] = !empty($sale_info['customer_id']) ? $sale_info['customer_id'] . "|" . $person_name : "";
|
||||
$data['sale_info'] = $sale_info;
|
||||
|
||||
$this->load->view('sales/edit', $data);
|
||||
}
|
||||
@@ -428,4 +430,4 @@ class Sales extends Secure_area
|
||||
$this->_reload();
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
@@ -3,7 +3,10 @@ class Sale extends CI_Model
|
||||
{
|
||||
public function get_info($sale_id)
|
||||
{
|
||||
$this->db->select('sales.*', FALSE);
|
||||
$this->db->select('people.*', FALSE);
|
||||
$this->db->from('sales');
|
||||
$this->db->join('people', 'people.person_id = sales.customer_id', 'LEFT');
|
||||
$this->db->where('sale_id',$sale_id);
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<div class="field_row clearfix">
|
||||
<?php echo form_label($this->lang->line('sales_customer').':', 'customer'); ?>
|
||||
<div class='form_field'>
|
||||
<?php echo form_dropdown('customer_id', $customers, $sale_info['customer_id'], 'id="customer_id"');?>
|
||||
<?php echo form_input(array('name' => 'customer_id', 'value' => $selected_customer, 'id' => 'customer_id'));?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -75,16 +75,32 @@ $(document).ready(function()
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
var formatItem = function(row) {
|
||||
return [row[0], "|", row[1]].join("");
|
||||
};
|
||||
var autoCompleter = $("#customer_id").autocomplete('<?php echo site_url("sales/customer_search"); ?>', {
|
||||
minChars:0,
|
||||
delay:15,
|
||||
max:100,
|
||||
cacheLength: 1,
|
||||
formatItem: formatItem,
|
||||
formatResult : formatItem
|
||||
});
|
||||
|
||||
$('#sales_edit_form').validate({
|
||||
submitHandler:function(form)
|
||||
{
|
||||
var selectedCustomer = autoCompleter.val();
|
||||
var selectedCustomerId = selectedCustomer.replace(/(\w)\|.*/, "$1");
|
||||
selectedCustomerId && autoCompleter.val(selectedCustomerId);
|
||||
$(form).ajaxSubmit({
|
||||
success:function(response)
|
||||
{
|
||||
if(response.success)
|
||||
{
|
||||
set_feedback(response.message,'success_message',false);
|
||||
autoCompleter.val(selectedCustomer);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -106,4 +122,4 @@ $(document).ready(function()
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
Reference in new issue
Block a user