diff --git a/Dockerfile b/Dockerfile index d536ef467..0f27b870b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:5-apache +FROM php:7.0.15-apache MAINTAINER jekkos RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ php5-apcu \ @@ -7,7 +7,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ libmcrypt-dev RUN a2enmod rewrite -RUN docker-php-ext-install mysql mysqli bcmath intl gd sockets mbstring mcrypt +RUN docker-php-ext-install mysqli bcmath intl gd sockets mbstring mcrypt RUN echo "date.timezone = \"\${PHP_TIMEZONE}\"" > /usr/local/etc/php/conf.d/timezone.ini RUN echo -e “$(hostname -i)\t$(hostname) $(hostname).localhost” >> /etc/hosts diff --git a/application/libraries/Sale_lib.php b/application/libraries/Sale_lib.php index 575dad69c..a3d04586a 100644 --- a/application/libraries/Sale_lib.php +++ b/application/libraries/Sale_lib.php @@ -3,6 +3,7 @@ class Sale_lib { private $CI; + private $line_sequence_options = array('0' => 'Standard', '1' => 'Entry', '2' => 'Group by Type', '3' => 'Group by Category'); public function __construct() { @@ -327,7 +328,8 @@ class Sale_lib $insertkey = 0; //Key to use for new entry. $updatekey = 0; //Key to use to update(quantity) - foreach ($items as $item) { + foreach($items as $item) + { //We primed the loop so maxkey is 0 the first time. //Also, we have stored the key in the element itself so we can compare. @@ -338,7 +340,8 @@ class Sale_lib if ($item['item_id'] == $item_id && $item['item_location'] == $item_location) { $itemalreadyinsale = TRUE; $updatekey = $item['line']; - if (!$item_info->is_serialized) { + if(!$item_info->is_serialized) + { $quantity = bcadd($quantity, $items[$updatekey]['quantity']); } } @@ -380,7 +383,8 @@ class Sale_lib 'total' => $total, 'discounted_total' => $discounted_total, 'print_option' => $print_option - )); + ) + ); //add to existing array $items += $item; } diff --git a/application/models/Receiving.php b/application/models/Receiving.php index 325782d28..20ba13aa4 100644 --- a/application/models/Receiving.php +++ b/application/models/Receiving.php @@ -106,8 +106,8 @@ class Receiving extends CI_Model //Update stock quantity $item_quantity = $this->Item_quantity->get_item_quantity($item['item_id'], $item['item_location']); - $this->Item_quantity->save(array('quantity' => $item_quantity->quantity + $items_received, 'item_id' => $item['item_id'], - 'location_id' => $item['item_location']), $item['item_id'], $item['item_location']); + $this->Item_quantity->save(array('quantity' => $item_quantity->quantity + $items_received, 'item_id' => $item['item_id'], + 'location_id' => $item['item_location']), $item['item_id'], $item['item_location']); $recv_remarks = 'RECV ' . $receiving_id; $inv_data = array( diff --git a/application/models/Sale.php b/application/models/Sale.php index 5914ace57..618e14ad9 100644 --- a/application/models/Sale.php +++ b/application/models/Sale.php @@ -222,13 +222,13 @@ class Sale extends CI_Model } if($filters['sale_type'] == 'sales') - { - $this->db->where('sales_items.quantity_purchased > 0'); - } - elseif($filters['sale_type'] == 'returns') - { - $this->db->where('sales_items.quantity_purchased < 0'); - } + { + $this->db->where('sales_items.quantity_purchased > 0'); + } + elseif($filters['sale_type'] == 'returns') + { + $this->db->where('sales_items.quantity_purchased < 0'); + } if($filters['only_invoices'] != FALSE) { @@ -550,6 +550,7 @@ class Sale extends CI_Model } // if an items was deleted but later returned it's restored with this rule + if($item['quantity'] < 0) { $this->Item->undelete($item['item_id']); @@ -622,20 +623,24 @@ class Sale extends CI_Model $items = $this->get_sale_items($sale_id)->result_array(); foreach($items as $item) { - // create query to update inventory tracking - $inv_data = array( - 'trans_date' => date('Y-m-d H:i:s'), - 'trans_items' => $item['item_id'], - 'trans_user' => $employee_id, - 'trans_comment' => 'Deleting sale ' . $sale_id, - 'trans_location' => $item['item_location'], - 'trans_inventory' => $item['quantity_purchased'] - ); - // update inventory - $this->Inventory->insert($inv_data); + $cur_item_info = $this->Item->get_info($item['item_id']); - // update quantities - $this->Item_quantity->change_quantity($item['item_id'], $item['item_location'], $item['quantity_purchased']); + if ($cur_item_info->stock_type === '0') { + // create query to update inventory tracking + $inv_data = array( + 'trans_date' => date('Y-m-d H:i:s'), + 'trans_items' => $item['item_id'], + 'trans_user' => $employee_id, + 'trans_comment' => 'Deleting sale ' . $sale_id, + 'trans_location' => $item['item_location'], + 'trans_inventory' => $item['quantity_purchased'] + ); + // update inventory + $this->Inventory->insert($inv_data); + + // update quantities + $this->Item_quantity->change_quantity($item['item_id'], $item['item_location'], $item['quantity_purchased']); + } } } @@ -674,7 +679,10 @@ class Sale extends CI_Model item_unit_price, discount_percent, item_location, +<<<<<<< HEAD print_option, +======= +>>>>>>> upstream/item-kit items.name as name, category, item_type'); @@ -682,13 +690,22 @@ class Sale extends CI_Model $this->db->join('items as items', 'sales_items.item_id = items.item_id'); $this->db->where('sale_id', $sale_id); +<<<<<<< HEAD // Entry sequence (this will also render kits in the expected sequence) if($this->config->item('line_sequence') == '0') +======= + // Entry sequence (this will render kits in the expected sequence) + if($this->config->item('line_sequence') == '1') +>>>>>>> upstream/item-kit { $this->db->order_by('line', 'asc'); } // Group by Stock Type (nonstock first - type 1, stock next - type 0) +<<<<<<< HEAD elseif($this->config->item('line_sequence') == '1') +======= + elseif($this->config->item('line_sequence') == '2') +>>>>>>> upstream/item-kit { $this->db->order_by('stock_type', 'desc'); $this->db->order_by('sales_items.description', 'asc'); @@ -696,14 +713,22 @@ class Sale extends CI_Model } // Group by Item Category +<<<<<<< HEAD elseif($this->config->item('line_sequence') == '2') +======= + elseif($this->config->item('line_sequence') == '3') +>>>>>>> upstream/item-kit { $this->db->order_by('category', 'asc'); $this->db->order_by('sales_items.description', 'asc'); $this->db->order_by('items.name', 'asc'); } +<<<<<<< HEAD // Group by reverse entry sequence in descending sequence (the Standard) +======= + // Group by entry sequence in descending sequence (the Standard) +>>>>>>> upstream/item-kit else { $this->db->order_by('line', 'desc'); diff --git a/application/models/reports/Detailed_receivings.php b/application/models/reports/Detailed_receivings.php index 1b58e7915..aba669d80 100644 --- a/application/models/reports/Detailed_receivings.php +++ b/application/models/reports/Detailed_receivings.php @@ -26,8 +26,8 @@ class Detailed_receivings extends Report array('supplier_name' => $this->lang->line('reports_supplied_by')), array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'), array('payment_type' => $this->lang->line('reports_payment_type')), - array('reference' => $this->lang->line('receivings_reference')), - array('comment' => $this->lang->line('reports_comments'))), + array('comment' => $this->lang->line('reports_comments')), + array('reference' => $this->lang->line('receivings_reference'))), 'details' => array( $this->lang->line('reports_item_number'), $this->lang->line('reports_name'), @@ -42,11 +42,22 @@ class Detailed_receivings extends Report public function getDataByReceivingId($receiving_id) { - $this->db->select('receiving_id, receiving_date, SUM(quantity_purchased) AS items_purchased, CONCAT(employee.first_name, " ", employee.last_name) AS employee_name, supplier.company_name AS supplier_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(profit) AS profit, payment_type, comment, reference'); + $this->db->select('receiving_id, + MAX(receiving_date) as receiving_date, + SUM(quantity_purchased) AS items_purchased, + MAX(CONCAT(employee.first_name, " ", employee.last_name)) AS employee_name, + MAX(supplier.company_name) AS supplier_name, + SUM(subtotal) AS subtotal, + SUM(total) AS total, + SUM(profit) AS profit, + MAX(payment_type) as payment_type, + MAX(comment) as comment, + MAX(reference) as reference'); $this->db->from('receivings_items_temp'); $this->db->join('people AS employee', 'receivings_items_temp.employee_id = employee.person_id'); $this->db->join('suppliers AS supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left'); $this->db->where('receiving_id', $receiving_id); + $this->db->group_by('receiving_id'); return $this->db->get()->row_array(); } @@ -83,8 +94,8 @@ class Detailed_receivings extends Report { $this->db->having('items_purchased = 0'); } - $this->db->group_by('receiving_id'); - $this->db->order_by('receiving_date'); + $this->db->group_by('receiving_id', 'receiving_date'); + $this->db->order_by('receiving_id'); $data = array(); $data['summary'] = $this->db->get()->result_array(); diff --git a/application/models/reports/Specific_employee.php b/application/models/reports/Specific_employee.php index 5128bc790..e36f7ae6d 100644 --- a/application/models/reports/Specific_employee.php +++ b/application/models/reports/Specific_employee.php @@ -85,13 +85,13 @@ class Specific_employee extends Report $this->db->where('employee_id', $inputs['employee_id']); if ($inputs['sale_type'] == 'sales') - { - $this->db->where('quantity_purchased > 0'); - } - elseif ($inputs['sale_type'] == 'returns') - { - $this->db->where('quantity_purchased < 0'); - } + { + $this->db->where('quantity_purchased > 0'); + } + elseif ($inputs['sale_type'] == 'returns') + { + $this->db->where('quantity_purchased < 0'); + } return $this->db->get()->row_array(); } diff --git a/application/views/configs/invoice_config.php b/application/views/configs/invoice_config.php index adf8b09dd..98871c107 100644 --- a/application/views/configs/invoice_config.php +++ b/application/views/configs/invoice_config.php @@ -66,6 +66,13 @@ +