Fix comments in receivings

This commit is contained in:
jekkos-t520
2014-10-03 17:41:39 +02:00
parent e994cd5444
commit 5a4ac8dde3
6 changed files with 44 additions and 9 deletions

View File

@@ -51,6 +51,11 @@ class Receivings extends Secure_area
}
$this->_reload();
}
function set_comment()
{
$this->receiving_lib->set_comment($this->input->post('comment'));
}
function add()
{
@@ -251,6 +256,7 @@ class Receivings extends Secure_area
$data['total']=$this->receiving_lib->get_total();
$data['items_module_allowed'] = $this->Employee->has_permission('items', $person_info->person_id);
$data['comment']=$this->receiving_lib->get_comment();
$data['payment_options']=array(
$this->lang->line('sales_cash') => $this->lang->line('sales_cash'),
$this->lang->line('sales_check') => $this->lang->line('sales_check'),

View File

@@ -13,9 +13,7 @@ class Item_lib
{
if(!$this->CI->session->userdata('item_location'))
{
$stock_locations = $this->CI->Stock_locations->get_allowed_locations();
$key=current(array_keys($stock_locations));
$location_name = $stock_locations[$key]['location_id'];
$location_name = $this->Stock_locations->get_default_location();
$this->set_item_location($location_name);
}
return $this->CI->session->userdata('item_location');

View File

@@ -52,12 +52,26 @@ class Receiving_lib
{
if(!$this->CI->session->userdata('recv_stock_source'))
{
$stock_locations = $this->CI->Stock_locations->get_undeleted_all()->result_array();
$location_name = $stock_locations[0]['location_id'];
$location_name = $this->Stock_locations->get_default_location();
$this->set_stock_source($location_name);
}
return $this->CI->session->userdata('recv_stock_source');
}
function get_comment()
{
return $this->CI->session->userdata('comment');
}
function set_comment($comment)
{
$this->CI->session->set_userdata('comment', $comment);
}
function clear_comment()
{
$this->CI->session->unset_userdata('comment');
}
function set_stock_source($stock_source)
{
@@ -294,6 +308,7 @@ class Receiving_lib
$this->clear_mode();
$this->empty_cart();
$this->delete_supplier();
$this->clear_comment();
}
function get_item_total($quantity, $price, $discount_percentage)

View File

@@ -172,8 +172,7 @@ class Sale_lib
{
if(!$this->CI->session->userdata('sale_location'))
{
$stock_locations = $this->CI->Stock_locations->get_undeleted_all()->result_array();
$location_name = $stock_locations[0]['location_id'];
$location_name = $this->Stock_locations->get_default_location();
$this->set_sale_location($location_name);
}
return $this->CI->session->userdata('sale_location');

View File

@@ -61,6 +61,18 @@ class Stock_locations extends CI_Model
return $stock_locations;
}
function get_default_location_name()
{
$this->db->from('stock_locations');
// TODO replace with extra join on ospos_grants
$this->db->join('modules', 'modules.module_id=concat(\'items_stock\', location_id)');
$this->db->join('permissions', 'permissions.module_id=modules.module_id');
$this->db->where('person_id', $this->session->userdata('person_id'));
$this->db->where('deleted',0);
$this->db->limit(1);
return $this->db->get()->row()->location_name;
}
function get_location_name($location_id)
{
$this->db->from('stock_locations');

View File

@@ -196,7 +196,7 @@ else
<?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','value'=>'','rows'=>'4','cols'=>'23'));?>
<?php echo form_textarea(array('name'=>'comment','id'=>'comment','value'=>$comment,'rows'=>'4','cols'=>'23'));?>
<br /><br />
<?php echo "<div class='small_button' id='finish_sale_button' style='float:right;margin-top:5px;'><span>".$this->lang->line('recvs_complete_receiving')."</span></div>";
@@ -218,7 +218,7 @@ else
<?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','value'=>'','rows'=>'4','cols'=>'23'));?>
<?php echo form_textarea(array('name'=>'comment','id'=>'comment','value'=>$comment,'rows'=>'4','cols'=>'23'));?>
<br /><br />
<table width="100%"><tr><td>
<?php
@@ -317,6 +317,11 @@ $(document).ready(function()
$(this).attr('value',"<?php echo $this->lang->line('recvs_start_typing_supplier_name'); ?>");
});
$('#comment').change(function()
{
$.post('<?php echo site_url("receivings/set_comment");?>', {comment: $('#comment').val()});
});
$("#finish_sale_button").click(function()
{
if (confirm('<?php echo $this->lang->line("recvs_confirm_finish_receiving"); ?>'))