mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-11 09:14:27 -04:00
Add attributes to detailed sales/receiving reports (#68)
This commit is contained in:
@@ -59,7 +59,10 @@ class Attributes extends Secure_Controller
|
||||
public function save_definition($definition_id = -1)
|
||||
{
|
||||
$definition_flags = 0;
|
||||
foreach($this->input->post('definition_flags') as $flag)
|
||||
|
||||
$flags = (empty($this->input->post('definition_flags'))) ? array() : $this->input->post('definition_flags');
|
||||
|
||||
foreach($flags as $flag)
|
||||
{
|
||||
$definition_flags |= $flag;
|
||||
}
|
||||
|
||||
@@ -1191,14 +1191,19 @@ class Reports extends Secure_Controller
|
||||
|
||||
public function detailed_sales($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
$definition_names = $this->Attribute->get_definitions_by_flags(Attribute::SHOW_IN_SALES);
|
||||
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'definition_ids' => array_keys($definition_names));
|
||||
|
||||
$this->load->model('reports/Detailed_sales');
|
||||
$model = $this->Detailed_sales;
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$headers = $this->xss_clean($model->getDataColumns());
|
||||
$columns = $model->getDataColumns();
|
||||
$columns['details'] = array_merge($columns['details'], $definition_names);
|
||||
|
||||
$headers = $this->xss_clean($columns);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
|
||||
@@ -1313,14 +1318,19 @@ class Reports extends Secure_Controller
|
||||
|
||||
public function detailed_receivings($start_date, $end_date, $receiving_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'receiving_type' => $receiving_type, 'location_id' => $location_id);
|
||||
$definition_names = $this->Attribute->get_definitions_by_flags(Attribute::SHOW_IN_RECEIVINGS);
|
||||
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'receiving_type' => $receiving_type, 'location_id' => $location_id, 'definition_ids' => array_keys($definition_names));
|
||||
|
||||
$this->load->model('reports/Detailed_receivings');
|
||||
$model = $this->Detailed_receivings;
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$headers = $this->xss_clean($model->getDataColumns());
|
||||
$columns = $model->getDataColumns();
|
||||
$columns['details'] = array_merge($columns['details'], $definition_names);
|
||||
|
||||
$headers = $this->xss_clean($columns);
|
||||
$report_data = $model->getData($inputs);
|
||||
|
||||
$summary_data = array();
|
||||
@@ -1353,13 +1363,15 @@ class Reports extends Secure_Controller
|
||||
{
|
||||
$quantity_purchased .= ' [' . $this->Stock_location->get_location_name($drow['item_location']) . ']';
|
||||
}
|
||||
$details_data[$row['receiving_id']][] = $this->xss_clean(array(
|
||||
$details_data[$row['receiving_id']][] = $this->xss_clean(array_merge(array(
|
||||
$drow['item_number'],
|
||||
$drow['name'],
|
||||
$drow['category'],
|
||||
$quantity_purchased,
|
||||
to_currency($drow['total']),
|
||||
($drow['discount_type'] == PERCENT)? $drow['discount'].'%':to_currency($drow['discount'])));
|
||||
($drow['discount_type'] == PERCENT)? $drow['discount'].'%':to_currency($drow['discount'])),
|
||||
explode(',', $drow['attribute_values'])
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ class Receiving_lib
|
||||
'name' => $item_info->name,
|
||||
'description' => $description != NULL ? $description: $item_info->description,
|
||||
'serialnumber' => $serialnumber != NULL ? $serialnumber: '',
|
||||
'attribute_values' => $this->CI->Attribute->get_link_values($item_id, 'receiving_id', $receiving_id, Attribute::SHOW_IN_RECEIVINGS)->attribute_values,
|
||||
'attribute_values' => $this->CI->Attribute->get_link_values($item_id, 'receiving_id', $receiving_id, Attribute::SHOW_IN_RECEIVINGS),
|
||||
'allow_alt_description' => $item_info->allow_alt_description,
|
||||
'is_serialized' => $item_info->is_serialized,
|
||||
'quantity' => $quantity,
|
||||
|
||||
@@ -843,7 +843,7 @@ class Sale_lib
|
||||
'line' => $insertkey,
|
||||
'name' => $item_info->name,
|
||||
'item_number' => $item_info->item_number,
|
||||
'attribute_values' => $this->CI->Attribute->get_link_values($item_id, 'sale_id', $sale_id, Attribute::SHOW_IN_SALES)->attribute_values,
|
||||
'attribute_values' => $this->CI->Attribute->get_link_values($item_id, 'sale_id', $sale_id, Attribute::SHOW_IN_SALES),
|
||||
'description' => $description != NULL ? $description : $item_info->description,
|
||||
'serialnumber' => $serialnumber != NULL ? $serialnumber : '',
|
||||
'allow_alt_description' => $item_info->allow_alt_description,
|
||||
|
||||
@@ -164,6 +164,17 @@ class Attribute extends CI_Model
|
||||
return $this->_to_array($results, 'definition_id', 'definition_name');
|
||||
}
|
||||
|
||||
public function get_definitions_by_flags($definition_flags)
|
||||
{
|
||||
$this->db->from('attribute_definitions');
|
||||
$this->db->where('definition_flags &', $definition_flags);
|
||||
$this->db->where('deleted', 0);
|
||||
$this->db->order_by('definition_id');
|
||||
$results = $this->db->get()->result_array();
|
||||
|
||||
return $this->_to_array($results, 'definition_id', 'definition_name');
|
||||
}
|
||||
|
||||
public function get_definition_names()
|
||||
{
|
||||
$this->db->from('attribute_definitions');
|
||||
@@ -298,11 +309,13 @@ class Attribute extends CI_Model
|
||||
|
||||
public function get_link_values($item_id, $sale_receiving_fk, $id, $definition_flags)
|
||||
{
|
||||
$this->db->select('GROUP_CONCAT(attribute_value SEPARATOR ",") AS attribute_values');
|
||||
$this->db->select('GROUP_CONCAT(attribute_value SEPARATOR ", ") AS attribute_values, GROUP_CONCAT(attribute_datetime SEPARATOR ", ") AS attribute_datetimevalues');
|
||||
$this->db->from('attribute_links');
|
||||
$this->db->join('attribute_values', 'attribute_values.attribute_id = attribute_links.attribute_id');
|
||||
$this->db->join('attribute_definitions', 'attribute_definitions.definition_id = attribute_links.definition_id');
|
||||
$this->db->where('definition_type <>', GROUP);
|
||||
$this->db->where('deleted', 0);
|
||||
|
||||
if(!empty($id))
|
||||
{
|
||||
$this->db->where($sale_receiving_fk, $id);
|
||||
@@ -315,7 +328,23 @@ class Attribute extends CI_Model
|
||||
$this->db->where('item_id', (int) $item_id);
|
||||
$this->db->where('definition_flags & ', $definition_flags);
|
||||
|
||||
return $this->db->get()->row_object();
|
||||
$results = $this->db->get();
|
||||
|
||||
if ($results->num_rows() > 0)
|
||||
{
|
||||
$row_object = $results->row_object();
|
||||
|
||||
$datetime_values = explode(', ', $row_object->attribute_datetimevalues);
|
||||
$attribute_values = array();
|
||||
|
||||
foreach (array_filter($datetime_values) as $datetime_value)
|
||||
{
|
||||
$attribute_values[] = to_datetime(strtotime($datetime_value));
|
||||
}
|
||||
|
||||
return implode(',', $attribute_values) . $row_object->attribute_values;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public function get_attribute_value($item_id, $definition_id)
|
||||
|
||||
@@ -88,7 +88,7 @@ class Receiving extends CI_Model
|
||||
$receivings_items_data = array(
|
||||
'receiving_id' => $receiving_id,
|
||||
'item_id' => $item['item_id'],
|
||||
'line' => $item['line'],
|
||||
'linae' => $item['line'],
|
||||
'description' => $item['description'],
|
||||
'serialnumber' => $item['serialnumber'],
|
||||
'quantity_purchased' => $item['quantity'],
|
||||
|
||||
@@ -100,6 +100,13 @@ class Detailed_receivings extends Report
|
||||
$this->db->select('name, item_number, category, quantity_purchased, serialnumber, total, discount_percent, item_location, receivings_items_temp.receiving_quantity');
|
||||
$this->db->from('receivings_items_temp');
|
||||
$this->db->join('items', 'receivings_items_temp.item_id = items.item_id');
|
||||
if (count($inputs['definition_ids']) > 0)
|
||||
{
|
||||
$this->db->select('GROUP_CONCAT(attribute_value) AS attribute_values');
|
||||
$this->db->join('attribute_links', 'attribute_links.item_id = items.item_id AND attribute_links.receiving_id = receivings_items_temp.receiving_id AND definition_id IN (' . implode(',', $inputs['definition_ids']) . ')', 'left');
|
||||
$this->db->join('attribute_values', 'attribute_values.attribute_id = attribute_links.attribute_id', 'left');
|
||||
$this->db->order_by('definition_id');
|
||||
}
|
||||
$this->db->where('receivings_items_temp.receiving_id', $value['receiving_id']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
@@ -146,7 +146,14 @@ class Detailed_sales extends Report
|
||||
{
|
||||
$this->db->select('name, category, quantity_purchased, item_location, serialnumber, description, subtotal, tax, total, cost, profit, discount, discount_type, sale_status');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('sale_id', $value['sale_id']);
|
||||
if (count($inputs['definition_ids']) > 0)
|
||||
{
|
||||
$this->db->select('GROUP_CONCAT(attribute_value) AS attribute_values');
|
||||
$this->db->join('attribute_links', 'attribute_links.item_id = sales_items_temp.item_id AND attribute_links.sale_id = sales_items_temp.sale_id AND definition_id IN (' . implode(',', $inputs['definition_ids']) . ')', 'left');
|
||||
$this->db->join('attribute_values', 'attribute_values.attribute_id = attribute_links.attribute_id', 'left');
|
||||
$this->db->order_by('definition_id');
|
||||
}
|
||||
$this->db->where('sales_items_temp.sale_id', $value['sale_id']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
$this->db->select('used, earned');
|
||||
$this->db->from('sales_reward_points');
|
||||
|
||||
@@ -33,13 +33,16 @@
|
||||
formatAllRows: function () {
|
||||
return "<?php echo $this->lang->line('tables_all'); ?>";
|
||||
},
|
||||
formatConfirmDelete: function(action) {
|
||||
|
||||
return "<?php echo $this->lang->line((isset($editable) ? $editable : $controller_name). "_confirm_delete")?>" + action;
|
||||
},
|
||||
formatConfirmRestore : function() {
|
||||
return "<?php echo $this->lang->line((isset($editable) ? $editable : $controller_name). "_confirm_restore")?>";
|
||||
}
|
||||
formatConfirmAction: function(action) {
|
||||
if (action == "delete")
|
||||
{
|
||||
return "<?php echo $this->lang->line((isset($editable) ? $editable : $controller_name). "_confirm_delete")?>";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<?php echo $this->lang->line((isset($editable) ? $editable : $controller_name). "_confirm_restore")?>";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales["<?php echo current_language_code();?>"]);
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=88039333a5"/>
|
||||
<!-- end mincss template tags -->
|
||||
<!-- start minjs template tags -->
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=6f7c64242e"></script>
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=4244279c55"></script>
|
||||
<!-- end minjs template tags -->
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
|
||||
var do_action = function(action) {
|
||||
return function (url, ids) {
|
||||
if (confirm($.fn.bootstrapTable.defaults.formatConfirmDelete())) {
|
||||
if (confirm($.fn.bootstrapTable.defaults.formatConfirmAction(action))) {
|
||||
$.post((url || options.resource) + '/' + action, {'ids[]': ids || selected_ids()}, function (response) {
|
||||
//delete was successful, remove checkbox rows
|
||||
if (response.success) {
|
||||
|
||||
Reference in New Issue
Block a user