Merge pull request #4 from jekkos/master

Merge with source proyect
This commit is contained in:
Jorge Colmenarez
2016-11-18 12:22:13 -04:00
committed by GitHub
71 changed files with 1170 additions and 979 deletions

1
.gitignore vendored
View File

@@ -19,7 +19,6 @@ git-svn-diff.py
*.swp
*.rej
*.orig
*.bak
*~
*.~
*.log

View File

@@ -5,29 +5,56 @@ Options +ExecCGI +Includes +IncludesNOEXEC +SymLinksIfOwnerMatch -Indexes
# prevent folder listing
IndexIgnore *
# secure htaccess file
<Files .htaccess>
Order allow,deny
Deny from all
</Files>
# Apache 2.4
<IfModule authz_core_module>
# secure htaccess file
<Files .htaccess>
Require all denied
</Files>
# prevent access to PHP error log
<Files error_log>
Order allow,deny
Deny from all
Satisfy all
</Files>
# prevent access to PHP error log
<Files error_log>
Require all denied
</Files>
# prevent access to LICENSE
<Files LICENSE>
Order allow,deny
Deny from all
Satisfy all
</Files>
# prevent access to LICENSE
<Files LICENSE>
Require all denied
</Files>
# prevent access to csv and txt files
<FilesMatch "\.(csv|txt)$">
Order allow,deny
Deny from all
Satisfy all
</FilesMatch>
# prevent access to csv, txt and md files
<FilesMatch "\.(csv|txt|md|yml|json|lock)$">
Require all denied
</FilesMatch>
</IfModule>
# Apache 2.2
<IfModule !authz_core_module>
# secure htaccess file
<Files .htaccess>
Order allow,deny
Deny from all
Satisfy all
</Files>
# prevent access to PHP error log
<Files error_log>
Order allow,deny
Deny from all
Satisfy all
</Files>
# prevent access to LICENSE
<Files LICENSE>
Order allow,deny
Deny from all
Satisfy all
</Files>
# prevent access to csv, txt and md files
<FilesMatch "\.(csv|txt|md|yml|json|lock)$">
Order allow,deny
Deny from all
Satisfy all
</FilesMatch>
</IfModule>

View File

@@ -10,6 +10,7 @@ Copyright (c) 2015-2016 FrancescoUK (aka daN4cat)
Copyright (c) 2015 Aamir Shahzad (aka asakpke), RoshanTech.com
Copyright (c) 2015 Toni Haryanto (aka yllumi)
Copyright (c) 2016 Ramkrishna Mondal (aka RamkrishnaMondal)
Copyright (c) 2016 rnld26
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

View File

@@ -25,7 +25,7 @@ The main features are:
The software is written in PHP language, it uses MySQL or MariaDB as data storage back-end and has a simple but intuitive user interface.
The latest version 3.0.0 is a complete overhaul of the original software.
The latest version 3.0.1 is a complete overhaul of the original software.
It is now based on Bootstrap 3.x using Bootswatch themes, and still uses CodeIgniter 3.x as framework.
It also has improved functionality and security.
@@ -68,10 +68,12 @@ Server Requirements
-------------------
PHP version 5.5 or newer is recommended but PHP 7.x is not fully supported yet.
PHP needs to have `php-gd`, `php-bcmath`, `php-intl` and `php-sockets` installed and enabled.
PHP needs to have `php-gd`, `php-bcmath`, `php-intl`, `php-sockets` and `php-mcrypt` installed and enabled.
MySQL 5.5 or 5.6 are fine but MySQL 5.7 is not supported yet.
Apache 2.2 and 2.4 are working both fine.
Local install
-------------
1. Create/locate a new mysql database to install open source point of sale into
@@ -127,9 +129,8 @@ More info [on maintaining a docker](https://github.com/jekkos/opensourcepos/wiki
Reporting Bugs
--------------
Since OSPOS 3.0.0 is a version under development, please make sure you always run the latest 2.4_to_3.0.sql database upgrade script.
Please DO NOT post issues if you have not done that before running OSPOS 3.0.
Please also make sure you have updated all the files from latest master.
If you are taking a release candidate code please make sure you always run the latest database upgrade script and you took the latest code from master.
Please DO NOT post issues if you have not done those step.
Bug reports must follow this schema:
@@ -163,3 +164,5 @@ FAQ
* If you installed your OSPOS under a web server subdir, please edit public/.htaccess and go to the lines with comment `if in web root` and `if in subdir comment above line, uncomment below one and replace <OSPOS path> with your path` and follow the instruction on the second comment line. If you face more issues please read [issue #920](https://github.com/jekkos/opensourcepos/issues/920) for more help
* If the avatar pictures are not shown in Items or at Item save time you get an error, please make sure your public and subdirs are assigned to the correct owner and the access permission is set to 755
* If you have problems with the encryption support or you get an error please make sure `php5-mcrypt` is installed

View File

@@ -1,3 +1,17 @@
Version 3.0.1
-----------
+ *CodeIgniter 3.1.2 Upgrade*
+ *Substantial database performance improvements*
+ *Improved security: email and sms passwords encryption, removed phpinfo.php*
+ Set code to be production and not development in index.php
+ Better Apache 2.4 support in .htaccess
+ Updates to language translations
+ Fixed excel template download links
+ Fixed employee name in Sale receipt and invoice reprinting
+ Fixed 2.3.2_to_2.3.3.sql database upgrade script mistake
+ Fixed phppos to ospos database migration script
+ Minor bugfixes and some general code clean up
Version 3.0.0
-----------
+ *CodeIgniter 3.1 Upgrade*

View File

@@ -58,7 +58,7 @@ $autoload['packages'] = array();
|
| $autoload['libraries'] = array('user_agent' => 'ua');
*/
$autoload['libraries'] = array('database', 'form_validation', 'session', 'user_agent', 'pagination');
$autoload['libraries'] = array('database', 'form_validation', 'session', 'user_agent', 'pagination', 'encryption');
/*
| -------------------------------------------------------------------

View File

@@ -183,7 +183,9 @@ class Config extends Secure_Controller
$themes[$dirinfo->getFileName()] = $dirinfo->getFileName();
}
}
asort($themes);
return $themes;
}
@@ -191,7 +193,7 @@ class Config extends Secure_Controller
{
$data['stock_locations'] = $this->Stock_location->get_all()->result_array();
$data['support_barcode'] = $this->barcode_lib->get_list_barcodes();
$data['logo_exists'] = $this->Appconfig->get('company_logo') != '';
$data['logo_exists'] = $this->config->item('company_logo') != '';
$data = $this->xss_clean($data);
@@ -313,12 +315,19 @@ class Config extends Secure_Controller
public function save_email()
{
$password = '';
if($this->_check_encryption())
{
$password = $this->encryption->encrypt($this->input->post('smtp_pass'));
}
$batch_save_data = array(
'protocol' => $this->input->post('protocol'),
'mailpath' => $this->input->post('mailpath'),
'smtp_host' => $this->input->post('smtp_host'),
'smtp_user' => $this->input->post('smtp_user'),
'smtp_pass' => $this->input->post('smtp_pass'),
'smtp_pass' => $password,
'smtp_port' => $this->input->post('smtp_port'),
'smtp_timeout' => $this->input->post('smtp_timeout'),
'smtp_crypto' => $this->input->post('smtp_crypto')
@@ -332,10 +341,17 @@ class Config extends Secure_Controller
public function save_message()
{
$password = '';
if($this->_check_encryption())
{
$password = $this->encryption->encrypt($this->input->post('msg_pwd'));
}
$batch_save_data = array(
'msg_msg' => $this->input->post('msg_msg'),
'msg_uid' => $this->input->post('msg_uid'),
'msg_pwd' => $this->input->post('msg_pwd'),
'msg_pwd' => $password,
'msg_src' => $this->input->post('msg_src')
);
@@ -484,7 +500,62 @@ class Config extends Secure_Controller
$this->upload->do_upload('company_logo');
return strlen($this->upload->display_errors()) == 0 || !strcmp($this->upload->display_errors(), '<p>'.$this->lang->line('upload_no_file_selected').'</p>');
}
}
private function _check_encryption()
{
$encryption_key = $this->config->item('encryption_key');
// check if the encryption_key config item is the default one
if($encryption_key == '' || $encryption_key == 'YOUR KEY')
{
// Config path
$config_path = APPPATH . 'config/config.php';
// Open the file
$config = file_get_contents($config_path);
// $key will be assigned a 32-byte (256-bit) hex-encoded random key
$key = bin2hex($this->encryption->create_key(32));
// replace the empty placeholder with a real randomly generated encryption key
if($encryption_key == '')
{
$config = str_replace("['encryption_key'] = '';", "['encryption_key'] = '" . $key . "';", $config);
}
else
{
$config = str_replace("['encryption_key'] = 'YOUR KEY';", "['encryption_key'] = '" . $key . "';", $config);
}
// set the encryption key in the config item
$this->config->set_item('encryption_key', $key);
// Write the new config.php file
$handle = fopen($config_path, 'w+');
// Chmod the file
@chmod($config_path, 0777);
$result = FALSE;
// Verify file permissions
if(is_writable($config_path))
{
// Write the file
$result = (fwrite($handle, $config) === FALSE) ? FALSE : TRUE;
}
// Chmod the file
@chmod($config_path, 0444);
fclose($handle);
return $result;
}
return TRUE;
}
public function backup_db()
{

View File

@@ -16,9 +16,9 @@ class Home extends Secure_Controller
public function logout()
{
$this->Employee->logout();
$this->track_page('logout', 'logout');
$this->Employee->logout();
}
}
?>

View File

@@ -172,8 +172,8 @@ class Items extends Secure_Controller
if($item_id == -1)
{
$data['default_tax_1_rate'] = $this->Appconfig->get('default_tax_1_rate');
$data['default_tax_2_rate'] = $this->Appconfig->get('default_tax_2_rate');
$data['default_tax_1_rate'] = $this->config->item('default_tax_1_rate');
$data['default_tax_2_rate'] = $this->config->item('default_tax_2_rate');
$item_info->receiving_quantity = 0;
$item_info->reorder_level = 0;
@@ -269,7 +269,7 @@ class Items extends Secure_Controller
$item = $this->xss_clean($item);
// update the UPC/EAN/ISBN field if empty / NULL with the newly generated barcode
if(empty($item['item_number']) && $this->Appconfig->get('barcode_generate_if_empty'))
if(empty($item['item_number']) && $this->config->item('barcode_generate_if_empty'))
{
// get the newly generated barcode
$barcode_instance = Barcode_lib::barcode_instance($item, $config);

View File

@@ -83,11 +83,11 @@ class Receivings extends Secure_Controller
$quantity = ($mode == 'receive' || $mode == 'requisition') ? 1 : -1;
$item_location = $this->receiving_lib->get_stock_source();
if($mode == 'return' && $this->receiving_lib->is_valid_receipt($item_id_or_number_or_item_kit_or_receipt))
if($mode == 'return' && $this->Receiving->is_valid_receipt($item_id_or_number_or_item_kit_or_receipt))
{
$this->receiving_lib->return_entire_receiving($item_id_or_number_or_item_kit_or_receipt);
}
elseif($this->receiving_lib->is_valid_item_kit($item_id_or_number_or_item_kit_or_receipt))
elseif($this->Item_kit->is_valid_item_kit($item_id_or_number_or_item_kit_or_receipt))
{
$this->receiving_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt, $item_location);
}

View File

@@ -40,10 +40,13 @@ class Reports extends Secure_Controller
//Summary sales report
public function summary_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);
$this->load->model('reports/Summary_sales');
$model = $this->Summary_sales;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$tabular_data = array();
foreach($report_data as $row)
@@ -63,7 +66,7 @@ class Reports extends Secure_Controller
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
'summary_data' => $summary
);
$this->load->view('reports/tabular', $data);
@@ -72,10 +75,13 @@ class Reports extends Secure_Controller
//Summary categories report
public function summary_categories($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);
$this->load->model('reports/Summary_categories');
$model = $this->Summary_categories;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$tabular_data = array();
foreach($report_data as $row)
@@ -95,7 +101,7 @@ class Reports extends Secure_Controller
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
'summary_data' => $summary
);
$this->load->view('reports/tabular', $data);
@@ -104,10 +110,13 @@ class Reports extends Secure_Controller
//Summary customers report
public function summary_customers($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);
$this->load->model('reports/Summary_customers');
$model = $this->Summary_customers;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$tabular_data = array();
foreach($report_data as $row)
@@ -127,7 +136,7 @@ class Reports extends Secure_Controller
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
'summary_data' => $summary
);
$this->load->view('reports/tabular', $data);
@@ -136,10 +145,13 @@ class Reports extends Secure_Controller
//Summary suppliers report
public function summary_suppliers($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);
$this->load->model('reports/Summary_suppliers');
$model = $this->Summary_suppliers;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$tabular_data = array();
foreach($report_data as $row)
@@ -159,7 +171,7 @@ class Reports extends Secure_Controller
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
'summary_data' => $summary
);
$this->load->view('reports/tabular', $data);
@@ -168,10 +180,13 @@ class Reports extends Secure_Controller
//Summary items report
public function summary_items($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);
$this->load->model('reports/Summary_items');
$model = $this->Summary_items;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$tabular_data = array();
foreach($report_data as $row)
@@ -191,7 +206,7 @@ class Reports extends Secure_Controller
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
'summary_data' => $summary
);
$this->load->view('reports/tabular', $data);
@@ -200,10 +215,13 @@ class Reports extends Secure_Controller
//Summary employees report
public function summary_employees($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);
$this->load->model('reports/Summary_employees');
$model = $this->Summary_employees;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$tabular_data = array();
foreach($report_data as $row)
@@ -223,7 +241,7 @@ class Reports extends Secure_Controller
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
'summary_data' => $summary
);
$this->load->view('reports/tabular', $data);
@@ -232,10 +250,13 @@ class Reports extends Secure_Controller
//Summary taxes report
public function summary_taxes($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);
$this->load->model('reports/Summary_taxes');
$model = $this->Summary_taxes;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$tabular_data = array();
foreach($report_data as $row)
@@ -253,7 +274,7 @@ class Reports extends Secure_Controller
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
'summary_data' => $summary
);
$this->load->view('reports/tabular', $data);
@@ -262,10 +283,13 @@ class Reports extends Secure_Controller
//Summary discounts report
public function summary_discounts($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);
$this->load->model('reports/Summary_discounts');
$model = $this->Summary_discounts;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$tabular_data = array();
foreach($report_data as $row)
@@ -280,7 +304,7 @@ class Reports extends Secure_Controller
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
'summary_data' => $summary
);
$this->load->view('reports/tabular', $data);
@@ -289,10 +313,13 @@ class Reports extends Secure_Controller
//Summary payments report
public function summary_payments($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);
$this->load->model('reports/Summary_payments');
$model = $this->Summary_payments;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$tabular_data = array();
foreach($report_data as $row)
@@ -308,7 +335,7 @@ class Reports extends Secure_Controller
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
'summary_data' => $summary
);
$this->load->view('reports/tabular', $data);
@@ -352,10 +379,13 @@ class Reports extends Secure_Controller
//Graphical summary sales report
public function graphical_summary_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);
$this->load->model('reports/Summary_sales');
$model = $this->Summary_sales;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$labels = array();
$series = array();
@@ -374,7 +404,7 @@ class Reports extends Secure_Controller
'chart_type' => 'reports/graphs/line',
'labels_1' => $labels,
'series_data_1' => $series,
'summary_data_1' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))),
'summary_data_1' => $summary,
'yaxis_title' => $this->lang->line('reports_revenue'),
'xaxis_title' => $this->lang->line('reports_date'),
'show_currency' => TRUE
@@ -386,10 +416,13 @@ class Reports extends Secure_Controller
//Graphical summary items report
public function graphical_summary_items($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);
$this->load->model('reports/Summary_items');
$model = $this->Summary_items;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$labels = array();
$series = array();
@@ -407,7 +440,7 @@ class Reports extends Secure_Controller
'chart_type' => 'reports/graphs/hbar',
'labels_1' => $labels,
'series_data_1' => $series,
'summary_data_1' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))),
'summary_data_1' => $summary,
'yaxis_title' => $this->lang->line('reports_items'),
'xaxis_title' => $this->lang->line('reports_revenue'),
'show_currency' => TRUE
@@ -419,11 +452,13 @@ class Reports extends Secure_Controller
//Graphical summary customers report
public function graphical_summary_categories($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);
$this->load->model('reports/Summary_categories');
$model = $this->Summary_categories;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$labels = array();
$series = array();
@@ -451,11 +486,13 @@ class Reports extends Secure_Controller
//Graphical summary suppliers report
public function graphical_summary_suppliers($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);
$this->load->model('reports/Summary_suppliers');
$model = $this->Summary_suppliers;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$labels = array();
$series = array();
@@ -483,11 +520,13 @@ class Reports extends Secure_Controller
//Graphical summary employees report
public function graphical_summary_employees($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);
$this->load->model('reports/Summary_employees');
$model = $this->Summary_employees;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$labels = array();
$series = array();
@@ -515,11 +554,13 @@ class Reports extends Secure_Controller
//Graphical summary taxes report
public function graphical_summary_taxes($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);
$this->load->model('reports/Summary_taxes');
$model = $this->Summary_taxes;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$labels = array();
$series = array();
@@ -547,10 +588,13 @@ class Reports extends Secure_Controller
//Graphical summary customers report
public function graphical_summary_customers($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);
$this->load->model('reports/Summary_customers');
$model = $this->Summary_customers;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$labels = array();
$series = array();
@@ -568,7 +612,7 @@ class Reports extends Secure_Controller
'chart_type' => 'reports/graphs/hbar',
'labels_1' => $labels,
'series_data_1' => $series,
'summary_data_1' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))),
'summary_data_1' => $summary,
'yaxis_title' => $this->lang->line('reports_customers'),
'xaxis_title' => $this->lang->line('reports_revenue'),
'show_currency' => TRUE
@@ -580,10 +624,13 @@ class Reports extends Secure_Controller
//Graphical summary discounts report
public function graphical_summary_discounts($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);
$this->load->model('reports/Summary_discounts');
$model = $this->Summary_discounts;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$labels = array();
$series = array();
@@ -601,7 +648,7 @@ class Reports extends Secure_Controller
'chart_type' => 'reports/graphs/bar',
'labels_1' => $labels,
'series_data_1' => $series,
'summary_data_1' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))),
'summary_data_1' => $summary,
'yaxis_title' => $this->lang->line('reports_count'),
'xaxis_title' => $this->lang->line('reports_discount_percent'),
'show_currency' => FALSE
@@ -613,11 +660,13 @@ class Reports extends Secure_Controller
//Graphical summary payments report
public function graphical_summary_payments($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);
$this->load->model('reports/Summary_payments');
$model = $this->Summary_payments;
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)));
$report_data = $model->getData($inputs);
$summary = $this->xss_clean($model->getSummaryData($inputs));
$labels = array();
$series = array();
@@ -659,11 +708,15 @@ class Reports extends Secure_Controller
public function specific_customer($start_date, $end_date, $customer_id, $sale_type)
{
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'customer_id' => $customer_id, 'sale_type' => $sale_type);
$this->load->model('reports/Specific_customer');
$model = $this->Specific_customer;
$model->create($inputs);
$headers = $this->xss_clean($model->getDataColumns());
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'customer_id' => $customer_id, 'sale_type' => $sale_type));
$report_data = $model->getData($inputs);
$summary_data = array();
$details_data = array();
@@ -685,7 +738,7 @@ class Reports extends Secure_Controller
'headers' => $headers,
'summary_data' => $summary_data,
'details_data' => $details_data,
'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'customer_id' => $customer_id, 'sale_type' => $sale_type)))
'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
);
$this->load->view('reports/tabular_details', $data);
@@ -708,11 +761,15 @@ class Reports extends Secure_Controller
public function specific_employee($start_date, $end_date, $employee_id, $sale_type)
{
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'employee_id' => $employee_id, 'sale_type' => $sale_type);
$this->load->model('reports/Specific_employee');
$model = $this->Specific_employee;
$model->create($inputs);
$headers = $this->xss_clean($model->getDataColumns());
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'employee_id' => $employee_id, 'sale_type' => $sale_type));
$report_data = $model->getData($inputs);
$summary_data = array();
$details_data = array();
@@ -734,7 +791,7 @@ class Reports extends Secure_Controller
'headers' => $headers,
'summary_data' => $summary_data,
'details_data' => $details_data,
'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date,'employee_id' => $employee_id, 'sale_type' => $sale_type)))
'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
);
$this->load->view('reports/tabular_details', $data);
@@ -759,11 +816,15 @@ class Reports extends Secure_Controller
public function specific_discount($start_date, $end_date, $discount, $sale_type)
{
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'discount' => $discount, 'sale_type' => $sale_type);
$this->load->model('reports/Specific_discount');
$model = $this->Specific_discount;
$model->create($inputs);
$headers = $this->xss_clean($model->getDataColumns());
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'discount' => $discount, 'sale_type' => $sale_type));
$report_data = $model->getData($inputs);
$summary_data = array();
$details_data = array();
@@ -784,7 +845,7 @@ class Reports extends Secure_Controller
'headers' => $headers,
'summary_data' => $summary_data,
'details_data' => $details_data,
'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date,'discount' => $discount, 'sale_type' => $sale_type)))
'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
);
$this->load->view('reports/tabular_details', $data);
@@ -792,9 +853,13 @@ class Reports extends Secure_Controller
public function get_detailed_sales_row($sale_id)
{
$inputs = array('sale_id' => $sale_id);
$this->load->model('reports/Detailed_sales');
$model = $this->Detailed_sales;
$model->create($inputs);
$report_data = $model->getDataBySaleId($sale_id);
$summary_data = $this->xss_clean(array(
@@ -820,11 +885,15 @@ 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);
$this->load->model('reports/Detailed_sales');
$model = $this->Detailed_sales;
$model->create($inputs);
$headers = $this->xss_clean($model->getDataColumns());
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
$report_data = $model->getData($inputs);
$summary_data = array();
$details_data = array();
@@ -869,7 +938,7 @@ class Reports extends Secure_Controller
'editable' => 'sales',
'summary_data' => $summary_data,
'details_data' => $details_data,
'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
);
$this->load->view('reports/tabular_details', $data);
@@ -877,8 +946,12 @@ class Reports extends Secure_Controller
public function get_detailed_receivings_row($receiving_id)
{
$inputs = array('receiving_id' => $receiving_id);
$this->load->model('reports/Detailed_receivings');
$model = $this->Detailed_receivings;
$model->create($inputs);
$report_data = $model->getDataByReceivingId($receiving_id);
@@ -902,11 +975,15 @@ 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);
$this->load->model('reports/Detailed_receivings');
$model = $this->Detailed_receivings;
$model->create($inputs);
$headers = $this->xss_clean($model->getDataColumns());
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'receiving_type' => $receiving_type, 'location_id' => $location_id));
$report_data = $model->getData($inputs);
$summary_data = array();
$details_data = array();
@@ -948,7 +1025,7 @@ class Reports extends Secure_Controller
'editable' => 'receivings',
'summary_data' => $summary_data,
'details_data' => $details_data,
'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'receiving_type' => $receiving_type, 'location_id' => $location_id)))
'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
);
$this->load->view('reports/tabular_details', $data);
@@ -956,10 +1033,12 @@ class Reports extends Secure_Controller
public function inventory_low()
{
$inputs = array();
$this->load->model('reports/Inventory_low');
$model = $this->Inventory_low;
$report_data = $model->getData(array());
$report_data = $model->getData($inputs);
$tabular_data = array();
foreach($report_data as $row)
@@ -977,7 +1056,7 @@ class Reports extends Secure_Controller
'subtitle' => '',
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $this->xss_clean($model->getSummaryData(array()))
'summary_data' => $this->xss_clean($model->getSummaryData($inputs))
);
$this->load->view('reports/tabular', $data);
@@ -1000,10 +1079,12 @@ class Reports extends Secure_Controller
public function inventory_summary($location_id = 'all', $item_count = 'all')
{
$inputs = array('location_id' => $location_id, 'item_count' => $item_count);
$this->load->model('reports/Inventory_summary');
$model = $this->Inventory_summary;
$report_data = $model->getData(array('location_id' => $location_id, 'item_count' => $item_count));
$report_data = $model->getData($inputs);
$tabular_data = array();
foreach($report_data as $row)

View File

@@ -47,8 +47,6 @@ class Sales extends Secure_Controller
public function get_row($row_id)
{
$this->Sale->create_temp_table();
$sale_info = $this->Sale->get_info($row_id)->row();
$data_row = $this->xss_clean(get_sale_data_row($sale_info, $this));
@@ -57,23 +55,19 @@ class Sales extends Secure_Controller
public function search()
{
$this->Sale->create_temp_table();
$search = $this->input->get('search');
$limit = $this->input->get('limit');
$offset = $this->input->get('offset');
$sort = $this->input->get('sort');
$order = $this->input->get('order');
$is_valid_receipt = !empty($search) ? $this->sale_lib->is_valid_receipt($search) : FALSE;
$filters = array('sale_type' => 'all',
'location_id' => 'all',
'start_date' => $this->input->get('start_date'),
'end_date' => $this->input->get('end_date'),
'only_cash' => FALSE,
'only_invoices' => $this->config->item('invoice_enable') && $this->input->get('only_invoices'),
'is_valid_receipt' => $is_valid_receipt);
'is_valid_receipt' => $this->Sale->is_valid_receipt($search));
// check if any filter is set in the multiselect dropdown
$filledup = array_fill_keys($this->input->get('filters'), TRUE);
@@ -103,7 +97,7 @@ class Sales extends Secure_Controller
$suggestions = array();
$receipt = $search = $this->input->get('term') != '' ? $this->input->get('term') : NULL;
if($this->sale_lib->get_mode() == 'return' && $this->sale_lib->is_valid_receipt($receipt))
if($this->sale_lib->get_mode() == 'return' && $this->Sale->is_valid_receipt($receipt))
{
// if a valid receipt or invoice was found the search term will be replaced with a receipt number (POS #)
$suggestions[] = $receipt;
@@ -280,11 +274,11 @@ class Sales extends Secure_Controller
$item_location = $this->sale_lib->get_sale_location();
$item_id_or_number_or_item_kit_or_receipt = $this->input->post('item');
if($mode == 'return' && $this->sale_lib->is_valid_receipt($item_id_or_number_or_item_kit_or_receipt))
if($mode == 'return' && $this->Sale->is_valid_receipt($item_id_or_number_or_item_kit_or_receipt))
{
$this->sale_lib->return_entire_sale($item_id_or_number_or_item_kit_or_receipt);
}
elseif($this->sale_lib->is_valid_item_kit($item_id_or_number_or_item_kit_or_receipt))
elseif($this->Item_kit->is_valid_item_kit($item_id_or_number_or_item_kit_or_receipt))
{
if(!$this->sale_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt, $item_location, $discount))
{
@@ -382,7 +376,7 @@ class Sales extends Secure_Controller
$customer_info = $this->_load_customer_data($customer_id, $data);
$invoice_number = $this->_substitute_invoice_number($customer_info);
if($this->sale_lib->is_invoice_number_enabled() && $this->Sale->invoice_number_exists($invoice_number))
if($this->sale_lib->is_invoice_number_enabled() && $this->Sale->check_invoice_number_exists($invoice_number))
{
$data['error'] = $this->lang->line('sales_invoice_number_duplicate');
@@ -595,8 +589,6 @@ class Sales extends Secure_Controller
private function _load_sale_data($sale_id)
{
$this->Sale->create_temp_table();
$this->sale_lib->clear_all();
$sale_info = $this->Sale->get_info($sale_id)->row_array();
$this->sale_lib->copy_entire_sale($sale_id);
@@ -615,7 +607,7 @@ class Sales extends Secure_Controller
$data['show_stock_locations'] = $this->Stock_location->show_locations('sales');
$data['amount_change'] = $this->sale_lib->get_amount_due() * -1;
$data['amount_due'] = $this->sale_lib->get_amount_due();
$employee_info = $this->Employee->get_info($this->Employee->get_logged_in_employee_info()->person_id);
$employee_info = $this->Employee->get_info($this->sale_lib->get_employee());
$data['employee'] = $employee_info->first_name . ' ' . $employee_info->last_name;
$this->_load_customer_data($this->sale_lib->get_customer(), $data);
@@ -699,8 +691,6 @@ class Sales extends Secure_Controller
$data['employees'][$employee->person_id] = $employee->first_name . ' ' . $employee->last_name;
}
$this->Sale->create_temp_table();
$sale_info = $this->xss_clean($this->Sale->get_info($sale_id)->row_array());
$data['selected_customer_name'] = $sale_info['customer_name'];
$data['selected_customer_id'] = $sale_info['customer_id'];
@@ -851,7 +841,7 @@ class Sales extends Secure_Controller
{
$sale_id = $this->input->post('sale_id');
$invoice_number = $this->input->post('invoice_number');
$exists = !empty($invoice_number) && $this->Sale->invoice_number_exists($invoice_number, $sale_id);
$exists = !empty($invoice_number) && $this->Sale->check_invoice_number_exists($invoice_number, $sale_id);
echo !$exists ? 'true' : 'false';
}

View File

@@ -74,10 +74,10 @@ function get_sale_data_row($sale, $controller)
}
$row['receipt'] = anchor($controller_name."/receipt/$sale->sale_id", '<span class="glyphicon glyphicon-usd"></span>',
array('title'=>$CI->lang->line('sales_show_receipt'))
array('title' => $CI->lang->line('sales_show_receipt'))
);
$row['edit'] = anchor($controller_name."/edit/$sale->sale_id", '<span class="glyphicon glyphicon-edit"></span>',
array('class'=>"modal-dlg print_hide", 'data-btn-delete' => $CI->lang->line('common_delete'), 'data-btn-submit' => $CI->lang->line('common_submit'), 'title' => $CI->lang->line($controller_name.'_update'))
array('class' => 'modal-dlg print_hide', 'data-btn-delete' => $CI->lang->line('common_delete'), 'data-btn-submit' => $CI->lang->line('common_submit'), 'title' => $CI->lang->line($controller_name.'_update'))
);
return $row;

View File

@@ -8,7 +8,7 @@ function db_log_queries()
if($CI->config->item('db_log_enabled'))
{
// Creating Query Log file with today's date in application/logs folder
$filepath = APPPATH . 'logs/Query-log-' . date('Y-m-d') . '.log';
$filepath = APPPATH . 'logs/Query-log-' . date('Y-m-d') . '.php';
// Opening file with pointer at the end of the file
$handle = fopen($filepath, "a+");

View File

@@ -19,9 +19,9 @@ $lang["common_fields_required_message"] = "Bagian yang ditandai warna merah waji
$lang["common_first_name"] = "Nama Depan";
$lang["common_first_name_required"] = "Nama depan wajib diisi.";
$lang["common_first_page"] = "First";
$lang["common_gender"] = "Gender";
$lang["common_gender"] = "Jenis Kelamin";
$lang["common_gender_female"] = "V";
$lang["common_gender_male"] = "M";
$lang["common_gender_male"] = "L";
$lang["common_inv"] = "Persediaan";
$lang["common_last_name"] = "Nama Belakang";
$lang["common_last_name_required"] = "Nama belakang wajib diisi.";

View File

@@ -13,7 +13,7 @@ $lang["common_delete"] = "ลบ";
$lang["common_print"] = "พิมพ์";
$lang["common_det"] = "สรุป";
$lang["common_edit"] = "แก้ไข";
$lang["common_email"] = "Email";
$lang["common_email"] = "อีเมล์";
$lang["common_email_invalid_format"] = "email address ไม่ถูกต้อง";
$lang["common_fields_required_message"] = "ช่องสีแดงต้องกรอก";
$lang["common_first_name"] = "ชื่อ";

View File

@@ -2,7 +2,7 @@
$lang["config_address"] = "ที่อยู่";
$lang["config_address_required"] = "ที่อยู่ต้องกรอก";
$lang["config_apostrophe"] = "apostrophe";
$lang["config_apostrophe"] = "อัญประกาศเดี่ยว '";
$lang["config_backup_button"] = "สำรองข้อมูล";
$lang["config_backup_database"] = "สำรองฐานข้อมูล";
$lang["config_barcode"] = "ตั้งค่าระบบบาร์โค้ด";
@@ -77,7 +77,7 @@ $lang["config_default_tax_rate_number"] = "อัตราภาษีเริ
$lang["config_default_tax_rate_required"] = "อัตราภาษีเริ่มต้นต้องกรอก";
$lang["config_default_tax_name_required"] = "The default tax name is a required field";
$lang["config_dot"] = "dot";
$lang["config_email"] = "Email";
$lang["config_email"] = "อีเมล์";
$lang["config_email_configuration"] = "Email Configuration";
$lang["config_email_protocol"] = "Protocol";
$lang["config_email_mailpath"] = "Path to Sendmail";
@@ -153,18 +153,18 @@ $lang["config_receipt_show_taxes"] = "Show Taxes";
$lang["config_receipt_show_total_discount"] = "Show Total Discount";
$lang["config_receipt_show_description"] = "Show Description";
$lang["config_receipt_show_serialnumber"] = "Show Serial Number";
$lang["config_receipt_template"] = "Receipt Template";
$lang["config_receipt_default"] = "Default";
$lang["config_receipt_short"] = "Short";
$lang["config_receiving_calculate_average_price"] = "Calc avg. Price (Receiving)";
$lang["config_receipt_template"] = "ต้นแบบใบเสร็จ";
$lang["config_receipt_default"] = "ค่าปริยาย";
$lang["config_receipt_short"] = "สั้น";
$lang["config_receiving_calculate_average_price"] = "คำนวณราคาเฉลี่ย (รับมา)";
$lang["config_recv_invoice_format"] = "ใบส่งของ";
$lang["config_return_policy_required"] = "ต้องกรอกเงื่อนไขการคืนสินค้า";
$lang["config_right"] = "Right";
$lang["config_right"] = "ถูกต้อง";
$lang["config_sales_invoice_format"] = "รหัสใบเสร็จ";
$lang["config_saved_successfully"] = "บันทึกข้อมูลร้านค้าเรียบร้อยแล้ว";
$lang["config_saved_unsuccessfully"] = "บันทึกข้อมูลร้านค้าไม่สำเร็จ";
$lang["config_statistics"] = "Send statistics";
$lang["config_statistics_tooltip"] = "Send statistics for development and feature improvement purposes";
$lang["config_statistics"] = "ส่งยอดสถิติ";
$lang["config_statistics_tooltip"] = "ส่งข้อมูลสถิติเพื่อการพัฒนาและปรับปรุงความสามารถ";
$lang["config_stock_location"] = "สถานที่เก็บ";
$lang["config_stock_location_duplicate"] = "";
$lang["config_stock_location_invalid_chars"] = "ชื่อสต๊อกสถานที่เก็บสินค้าต้องไม่มีอักษรพิเศษ '_'";

View File

@@ -38,14 +38,14 @@ $lang["receivings_return"] = "คืนสินค้า";
$lang["receivings_select_supplier"] = "เลือกผู้ผลิต (ทางเลือก)";
$lang["receivings_start_typing_supplier_name"] = "เริ่มต้นพิมพ์ชื่อผู้ผลิต...";
$lang["receivings_stock_destination"] = "Stock destination";
$lang["receivings_stock_locaiton"] = "Stock location";
$lang["receivings_stock_locaiton"] = "สถานที่เก็บสินค้า";
$lang["receivings_stock_source"] = "Stock source";
$lang["receivings_successfully_deleted"] = "You have successfully deleted";
$lang["receivings_successfully_updated"] = "Receiving successfully updated";
$lang["receivings_supplier"] = "ผู้ผลิต";
$lang["receivings_supplier_email"] = "Email";
$lang["receivings_supplier_address"] = "Address";
$lang["receivings_supplier_location"] = "Location";
$lang["receivings_supplier_email"] = "อีเมล์";
$lang["receivings_supplier_address"] = "ที่อยู่";
$lang["receivings_supplier_location"] = "ที่อยู่";
$lang["receivings_total"] = "รวม";
$lang["receivings_unable_to_add_item"] = "ไม่สามารถเพิ่มสินค้าได้";
$lang["receivings_unsuccessfully_updated"] = "Receiving unsuccessfully updated";

View File

@@ -7,12 +7,12 @@ $lang["sales_cancel_sale"] = "ยกเลิกการขาย";
$lang["sales_cash"] = "เงินสด";
$lang["sales_change_due"] = "เงินทอน";
$lang["sales_check"] = "เช็ค";
$lang["sales_check_balance"] = "Check remainder";
$lang["sales_check_balance"] = "เช็คยอดคงเหลือ";
$lang["sales_comment"] = "หมายเหตุ";
$lang["sales_comments"] = "หมายเหตุ";
$lang["sales_complete_sale"] = "จบการขาย";
$lang["sales_confirm_cancel_sale"] = "แน่ใจหรือไม่ที่จะล้างรายการขาย? สินค้าทุกอย่างจะถูกลบจากบอร์ด.";
$lang["sales_confirm_delete"] = "Are you sure you want to delete the selected sales?";
$lang["sales_confirm_delete"] = "โปรดยืนยันการลบรายการขายที่เลือกไว้";
$lang["sales_credit"] = "เครดิตการ์ด";
$lang["sales_customer"] = "ลูกค้า";
$lang["sales_customer_email"] = "Customer Email";

View File

@@ -24,28 +24,28 @@ class Barcode_lib
public function get_barcode_config()
{
$data['company'] = $this->CI->Appconfig->get('company');
$data['barcode_content'] = $this->CI->Appconfig->get('barcode_content');
$data['barcode_type'] = $this->CI->Appconfig->get('barcode_type');
$data['barcode_font'] = $this->CI->Appconfig->get('barcode_font');
$data['barcode_font_size'] = $this->CI->Appconfig->get('barcode_font_size');
$data['barcode_height'] = $this->CI->Appconfig->get('barcode_height');
$data['barcode_width'] = $this->CI->Appconfig->get('barcode_width');
$data['barcode_quality'] = $this->CI->Appconfig->get('barcode_quality');
$data['barcode_first_row'] = $this->CI->Appconfig->get('barcode_first_row');
$data['barcode_second_row'] = $this->CI->Appconfig->get('barcode_second_row');
$data['barcode_third_row'] = $this->CI->Appconfig->get('barcode_third_row');
$data['barcode_num_in_row'] = $this->CI->Appconfig->get('barcode_num_in_row');
$data['barcode_page_width'] = $this->CI->Appconfig->get('barcode_page_width');
$data['barcode_page_cellspacing'] = $this->CI->Appconfig->get('barcode_page_cellspacing');
$data['barcode_generate_if_empty'] = $this->CI->Appconfig->get('barcode_generate_if_empty');
$data['company'] = $this->CI->config->item('company');
$data['barcode_content'] = $this->CI->config->item('barcode_content');
$data['barcode_type'] = $this->CI->config->item('barcode_type');
$data['barcode_font'] = $this->CI->config->item('barcode_font');
$data['barcode_font_size'] = $this->CI->config->item('barcode_font_size');
$data['barcode_height'] = $this->CI->config->item('barcode_height');
$data['barcode_width'] = $this->CI->config->item('barcode_width');
$data['barcode_quality'] = $this->CI->config->item('barcode_quality');
$data['barcode_first_row'] = $this->CI->config->item('barcode_first_row');
$data['barcode_second_row'] = $this->CI->config->item('barcode_second_row');
$data['barcode_third_row'] = $this->CI->config->item('barcode_third_row');
$data['barcode_num_in_row'] = $this->CI->config->item('barcode_num_in_row');
$data['barcode_page_width'] = $this->CI->config->item('barcode_page_width');
$data['barcode_page_cellspacing'] = $this->CI->config->item('barcode_page_cellspacing');
$data['barcode_generate_if_empty'] = $this->CI->config->item('barcode_generate_if_empty');
return $data;
}
public function validate_barcode($barcode)
{
$barcode_type = $this->CI->Appconfig->get('barcode_type');
$barcode_type = $this->CI->config->item('barcode_type');
$barcode_instance = $this->get_barcode_instance($barcode_type);
return $barcode_instance->validate($barcode);
}

View File

@@ -18,7 +18,7 @@ class Email_lib
'mailpath' => $this->CI->config->item('mailpath'),
'smtp_host' => $this->CI->config->item('smtp_host'),
'smtp_user' => $this->CI->config->item('smtp_user'),
'smtp_pass' => $this->CI->config->item('smtp_pass'),
'smtp_pass' => $this->CI->encryption->decrypt($this->CI->config->item('smtp_pass')),
'smtp_port' => $this->CI->config->item('smtp_port'),
'smtp_timeout' => $this->CI->config->item('smtp_timeout'),
'smtp_crypto' => $this->CI->config->item('smtp_crypto')

View File

@@ -263,36 +263,6 @@ class Receiving_lib
$this->set_cart($items);
}
public function is_valid_receipt($receipt_receiving_id)
{
//RECV #
$pieces = explode(' ', $receipt_receiving_id);
if(count($pieces) == 2 && preg_match('/(RECV|KIT)/', $pieces[1]))
{
return $this->CI->Receiving->exists($pieces[1]);
}
else
{
return $this->CI->Receiving->get_receiving_by_reference($receipt_receiving_id)->num_rows() > 0;
}
return FALSE;
}
public function is_valid_item_kit($item_kit_id)
{
//KIT #
$pieces = explode(' ',$item_kit_id);
if(count($pieces) == 2)
{
return $this->CI->Item_kit->exists($pieces[1]);
}
return FALSE;
}
public function return_entire_receiving($receipt_receiving_id)
{
//RECV #

View File

@@ -214,6 +214,26 @@ class Sale_lib
{
$this->CI->session->unset_userdata('sales_customer');
}
public function get_employee()
{
if(!$this->CI->session->userdata('sales_employee'))
{
$this->set_employee(-1);
}
return $this->CI->session->userdata('sales_employee');
}
public function set_employee($employee_id)
{
$this->CI->session->set_userdata('sales_employee', $employee_id);
}
public function remove_employee()
{
$this->CI->session->unset_userdata('sales_employee');
}
public function get_mode()
{
@@ -439,42 +459,6 @@ class Sale_lib
$this->set_cart($items);
}
public function is_valid_receipt(&$receipt_sale_id)
{
//POS #
$pieces = explode(' ', $receipt_sale_id);
if(count($pieces) == 2 && strtolower($pieces[0]) == 'pos')
{
return $this->CI->Sale->exists($pieces[1]);
}
elseif($this->CI->config->item('invoice_enable') == TRUE)
{
$sale_info = $this->CI->Sale->get_sale_by_invoice_number($receipt_sale_id);
if($sale_info->num_rows() > 0)
{
$receipt_sale_id = 'POS ' . $sale_info->row()->sale_id;
return TRUE;
}
}
return FALSE;
}
public function is_valid_item_kit($item_kit_id)
{
//KIT #
$pieces = explode(' ', $item_kit_id);
if(count($pieces) == 2)
{
return $this->CI->Item_kit->exists($pieces[1]);
}
return FALSE;
}
public function return_entire_sale($receipt_sale_id)
{
//POS #
@@ -523,6 +507,7 @@ class Sale_lib
}
$this->set_customer($this->CI->Sale->get_customer($sale_id)->person_id);
$this->set_employee($this->CI->Sale->get_employee($sale_id)->person_id);
}
public function copy_entire_suspended_sale($sale_id)

View File

@@ -16,7 +16,7 @@ class Sms_lib
public function sendSMS($phone, $message)
{
$username = $this->CI->config->item('msg_uid');
$password = $this->CI->config->item('msg_pwd');
$password = $this->CI->encryption->decrypt($this->CI->config->item('msg_pwd'));
$originator = $this->CI->config->item('msg_src');
$response = FALSE;
@@ -27,7 +27,7 @@ class Sms_lib
//echo $username . ' ' . $password . ' ' . $phone . ' ' . $message . ' ' . $originator;
}
else
{
{
$response = TRUE;
// make sure passed string is url encoded

View File

@@ -298,7 +298,6 @@ class Employee extends Person
*/
public function login($username, $password)
{
$query = $this->db->get_where('employees', array('username' => $username, 'deleted' => 0), 1);
if($query->num_rows() == 1)
@@ -332,6 +331,7 @@ class Employee extends Person
public function logout()
{
$this->session->sess_destroy();
redirect('login');
}

View File

@@ -514,7 +514,7 @@ class Item extends CI_Model
* $old_price (optional) : the current-cost-price
*
* used in receiving-process to update cost-price if changed
* caution: must be used there before item_quantities gets updated, otherwise average price is wrong!
* caution: must be used before item_quantities gets updated, otherwise the average price is wrong!
*
*/
public function change_cost_price($item_id, $items_received, $new_price, $old_price = null)
@@ -539,32 +539,5 @@ class Item extends CI_Model
return $this->save($data, $item_id);
}
//We create a temp table that allows us to do easy report queries
public function create_temp_table()
{
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('items_temp') .
' (INDEX(quantity), INDEX(location_id))
(
SELECT
items.name,
items.item_number,
items.description,
items.reorder_level,
item_quantities.quantity,
stock_locations.location_name,
stock_locations.location_id,
items.cost_price,
items.unit_price,
(items.cost_price * item_quantities.quantity) AS sub_total_value
FROM ' . $this->db->dbprefix('items') . ' AS items
INNER JOIN ' . $this->db->dbprefix('item_quantities') . ' AS item_quantities
ON items.item_id = item_quantities.item_id
INNER JOIN ' . $this->db->dbprefix('stock_locations') . ' AS stock_locations
ON item_quantities.location_id = stock_locations.location_id
WHERE items.deleted = 0 AND stock_locations.deleted = 0
)'
);
}
}
?>

View File

@@ -12,6 +12,25 @@ class Item_kit extends CI_Model
return ($this->db->get()->num_rows() == 1);
}
/*
Check if a given item_id is an item kit
*/
public function is_valid_item_kit($item_kit_id)
{
if(!empty($item_kit_id))
{
//KIT #
$pieces = explode(' ', $item_kit_id);
if(count($pieces) == 2 && preg_match('/(KIT)/', $pieces[0]))
{
return $this->exists($pieces[1]);
}
}
return FALSE;
}
/*
Gets total of rows
*/

View File

@@ -19,6 +19,26 @@ class Receiving extends CI_Model
return $this->db->get();
}
public function is_valid_receipt($receipt_receiving_id)
{
if(!empty($receipt_receiving_id))
{
//RECV #
$pieces = explode(' ', $receipt_receiving_id);
if(count($pieces) == 2 && preg_match('/(RECV|KIT)/', $pieces[0]))
{
return $this->exists($pieces[1]);
}
else
{
return $this->get_receiving_by_reference($receipt_receiving_id)->num_rows() > 0;
}
}
return FALSE;
}
public function exists($receiving_id)
{
$this->db->from('receivings');
@@ -203,8 +223,17 @@ class Receiving extends CI_Model
/*
We create a temp table that allows us to do easy report/receiving queries
*/
public function create_temp_table()
public function create_temp_table(array $inputs)
{
if(empty($input['receiving_id']))
{
$where = 'WHERE DATE(receiving_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
}
else
{
$where = 'WHERE receivings_items.receiving_id = ' . $this->db->escape($inputs['receiving_id']);
}
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('receivings_items_temp') .
' (INDEX(receiving_date), INDEX(receiving_id))
(
@@ -236,6 +265,9 @@ class Receiving extends CI_Model
ON receivings_items.receiving_id = receivings.receiving_id
INNER JOIN ' . $this->db->dbprefix('items') . ' AS items
ON receivings_items.item_id = items.item_id
' . "
$where
" . '
GROUP BY receivings_items.receiving_id, items.item_id, receivings_items.line
)'
);

View File

@@ -3,14 +3,69 @@ class Sale extends CI_Model
{
public function get_info($sale_id)
{
$this->db->select('customer_id, customer_name, customer_first_name AS first_name, customer_last_name AS last_name, customer_email AS email, customer_comments AS comments,
sale_payment_amount AS amount_tendered, SUM(total) AS amount_due, (sale_payment_amount - SUM(total)) AS change_due, payment_type,
sale_id, sale_date, sale_time, comment, invoice_number, employee_id');
$this->db->from('sales_items_temp');
if($this->config->item('tax_included'))
{
$total = '1';
$subtotal = '(1 - (SUM(1 - 100 / (100 + sales_items_taxes.percent))))';
$tax = '(SUM(1 - 100 / (100 + sales_items_taxes.percent)))';
}
else
{
$tax = '(SUM(sales_items_taxes.percent) / 100)';
$total = '(1 + (SUM(sales_items_taxes.percent / 100)))';
$subtotal = '1';
}
$this->db->where('sale_id', $sale_id);
$this->db->group_by('sale_id');
$this->db->order_by('sale_time', 'asc');
$sale_total = 'SUM(sales_items.item_unit_price * sales_items.quantity_purchased - sales_items.item_unit_price * sales_items.quantity_purchased * sales_items.discount_percent / 100)';
$sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
$decimals = totals_decimals();
// create payments temp table to speed up the sales listing
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
' (PRIMARY KEY(sale_id), INDEX(sale_id))
(
SELECT payments.sale_id AS sale_id,
IFNULL(SUM(payments.payment_amount), 0) AS sale_payment_amount,
GROUP_CONCAT(CONCAT(payments.payment_type, " ", payments.payment_amount) SEPARATOR ", ") AS payment_type
FROM ' . $this->db->dbprefix('sales_payments') . ' AS payments
INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
ON sales.sale_id = payments.sale_id
WHERE sales.sale_id = ' . $this->db->escape($sale_id) . '
GROUP BY sale_id
)'
);
$this->db->select('
sales.sale_id AS sale_id,
DATE(sales.sale_time) AS sale_date,
sales.sale_time AS sale_time,
sales.comment AS comment,
sales.invoice_number AS invoice_number,
sales.employee_id AS employee_id,
sales.customer_id AS customer_id,
CONCAT(customer_p.first_name, " ", customer_p.last_name) AS customer_name,
customer_p.first_name AS first_name,
customer_p.last_name AS last_name,
customer_p.email AS email,
customer_p.comments AS comments,
payments.sale_payment_amount AS amount_tendered,
' . "
IFNULL(ROUND($sale_total * $total, $decimals), ROUND($sale_total * $subtotal, $decimals)) AS amount_due,
" . '
payments.payment_type AS payment_type
');
$this->db->from('sales_items AS sales_items');
$this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
$this->db->join('people AS customer_p', 'sales.customer_id = customer_p.person_id', 'left');
$this->db->join('customers AS customer', 'sales.customer_id = customer.person_id', 'left');
$this->db->join('sales_payments_temp AS payments', 'sales.sale_id = payments.sale_id', 'left outer');
$this->db->join('sales_items_taxes AS sales_items_taxes', 'sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id AND sales_items.line = sales_items_taxes.line', 'left outer');
$this->db->where('sales.sale_id', $sale_id);
$this->db->group_by('sales.sale_id');
$this->db->order_by('sales.sale_time', 'asc');
return $this->db->get();
}
@@ -28,61 +83,119 @@ class Sale extends CI_Model
*/
public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = 'sale_date', $order = 'desc')
{
$this->db->select('sale_id, sale_date, sale_time, SUM(quantity_purchased) AS items_purchased,
customer_name, customer_company_name AS company_name,
SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit,
sale_payment_amount AS amount_tendered, SUM(total) AS amount_due, (sale_payment_amount - SUM(total)) AS change_due,
payment_type, invoice_number');
$this->db->from('sales_items_temp');
if($this->config->item('tax_included'))
{
$total = '1';
$subtotal = '(1 - (SUM(1 - 100 / (100 + sales_items_taxes.percent))))';
$tax = '(SUM(1 - 100 / (100 + sales_items_taxes.percent)))';
}
else
{
$tax = '(SUM(sales_items_taxes.percent) / 100)';
$total = '(1 + (SUM(sales_items_taxes.percent / 100)))';
$subtotal = '1';
}
$this->db->where('sale_date BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']));
$sale_total = 'SUM(sales_items.item_unit_price * sales_items.quantity_purchased - sales_items.item_unit_price * sales_items.quantity_purchased * sales_items.discount_percent / 100)';
$sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
$decimals = totals_decimals();
// create payments temp table to speed up the sales listing
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
' (PRIMARY KEY(sale_id), INDEX(sale_id))
(
SELECT payments.sale_id AS sale_id,
IFNULL(SUM(payments.payment_amount), 0) AS sale_payment_amount,
GROUP_CONCAT(CONCAT(payments.payment_type, " ", payments.payment_amount) SEPARATOR ", ") AS payment_type
FROM ' . $this->db->dbprefix('sales_payments') . ' AS payments
INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
ON sales.sale_id = payments.sale_id
WHERE DATE(sales.sale_time) BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']) . '
GROUP BY sale_id
)'
);
$this->db->select('
sales.sale_id AS sale_id,
DATE(sales.sale_time) AS sale_date,
sales.sale_time AS sale_time,
SUM(sales_items.quantity_purchased) AS items_purchased,
CONCAT(customer_p.first_name, " ", customer_p.last_name) AS customer_name,
customer.company_name AS company_name,
' . "
ROUND($sale_total * $subtotal, $decimals) AS subtotal,
IFNULL(ROUND($sale_total * $total, $decimals), ROUND($sale_total * $subtotal, $decimals)) AS total,
IFNULL(ROUND($sale_total * $tax, $decimals), 0) AS tax,
ROUND($sale_total - $sale_cost, $decimals) AS profit,
ROUND($sale_cost, $decimals) AS cost,
IFNULL(ROUND($sale_total * $total, $decimals), ROUND($sale_total * $subtotal, $decimals)) AS amount_due,
(payments.sale_payment_amount - IFNULL(ROUND($sale_total * $total, $decimals), ROUND($sale_total * $subtotal, $decimals))) AS change_due,
" . '
payments.sale_payment_amount AS amount_tendered,
payments.payment_type AS payment_type,
sales.invoice_number AS invoice_number
');
$this->db->from('sales_items AS sales_items');
$this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
$this->db->join('people AS customer_p', 'sales.customer_id = customer_p.person_id', 'left');
$this->db->join('customers AS customer', 'sales.customer_id = customer.person_id', 'left');
$this->db->join('sales_payments_temp AS payments', 'sales.sale_id = payments.sale_id', 'left outer');
$this->db->join('sales_items_taxes AS sales_items_taxes', 'sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id AND sales_items.line = sales_items_taxes.line', 'left outer');
$this->db->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']));
if(!empty($search))
{
if($filters['is_valid_receipt'] != FALSE)
{
$pieces = explode(' ', $search);
$this->db->where('sale_id', $pieces[1]);
$this->db->where('sales.sale_id', $pieces[1]);
}
else
{
{
$this->db->group_start();
$this->db->like('customer_last_name', $search);
$this->db->or_like('customer_first_name', $search);
$this->db->or_like('customer_name', $search);
$this->db->or_like('customer_company_name', $search);
// customer last name
$this->db->like('customer_p.last_name', $search);
// customer first name
$this->db->or_like('customer_p.first_name', $search);
// customer first and last name
$this->db->or_like('CONCAT(customer_p.first_name, " ", customer_p.last_name)', $search);
// customer company name
$this->db->or_like('customer.company_name', $search);
$this->db->group_end();
}
}
if($filters['location_id'] != 'all')
{
$this->db->where('item_location', $filters['location_id']);
$this->db->where('sales_items.item_location', $filters['location_id']);
}
if($filters['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
$this->db->where('sales_items.quantity_purchased > 0');
}
elseif($filters['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
$this->db->where('sales_items.quantity_purchased < 0');
}
if($filters['only_invoices'] != FALSE)
{
$this->db->where('invoice_number IS NOT NULL');
$this->db->where('sales.invoice_number IS NOT NULL');
}
if($filters['only_cash'] != FALSE)
{
$this->db->group_start();
$this->db->like('payment_type', $this->lang->line('sales_cash'), 'after');
$this->db->or_where('payment_type IS NULL');
$this->db->like('payments.payment_type', $this->lang->line('sales_cash'), 'after');
$this->db->or_where('payments.payment_type IS NULL');
$this->db->group_end();
}
$this->db->group_by('sale_id');
$this->db->group_by('sales.sale_id');
$this->db->order_by($sort, $order);
if($rows > 0)
@@ -102,7 +215,8 @@ class Sale extends CI_Model
$this->db->select('payment_type, count(*) AS count, SUM(payment_amount) AS payment_amount');
$this->db->from('sales');
$this->db->join('sales_payments', 'sales_payments.sale_id = sales.sale_id');
$this->db->join('people', 'people.person_id = sales.customer_id', 'left');
$this->db->join('people AS customer_p', 'sales.customer_id = customer_p.person_id', 'left');
$this->db->join('customers AS customer', 'sales.customer_id = customer.person_id', 'left');
$this->db->where('DATE(sale_time) BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']));
@@ -116,9 +230,14 @@ class Sale extends CI_Model
else
{
$this->db->group_start();
$this->db->like('last_name', $search);
$this->db->or_like('first_name', $search);
$this->db->or_like('CONCAT(first_name, " ", last_name)', $search);
// customer last name
$this->db->like('customer_p.last_name', $search);
// customer first name
$this->db->or_like('customer_p.first_name', $search);
// customer first and last name
$this->db->or_like('CONCAT(customer_p.first_name, " ", customer_p.last_name)', $search);
// customer company name
$this->db->or_like('customer.company_name', $search);
$this->db->group_end();
}
}
@@ -161,7 +280,7 @@ class Sale extends CI_Model
}
}
if( $gift_card_count > 0 )
if($gift_card_count > 0)
{
$payments[] = array('payment_type' => $this->lang->line('sales_giftcard'), 'count' => $gift_card_count, 'payment_amount' => $gift_card_amount);
}
@@ -183,7 +302,7 @@ class Sale extends CI_Model
{
$suggestions = array();
if(!$this->sale_lib->is_valid_receipt($search))
if(!$this->is_valid_receipt($search))
{
$this->db->distinct();
$this->db->select('first_name, last_name');
@@ -238,6 +357,32 @@ class Sale extends CI_Model
return ($start_from + $result['invoice_number_year']);
}
public function is_valid_receipt(&$receipt_sale_id)
{
if(!empty($receipt_sale_id))
{
//POS #
$pieces = explode(' ', $receipt_sale_id);
if(count($pieces) == 2 && preg_match('/(POS)/', $pieces[0]))
{
return $this->exists($pieces[1]);
}
elseif($this->config->item('invoice_enable') == TRUE)
{
$sale_info = $this->get_sale_by_invoice_number($receipt_sale_id);
if($sale_info->num_rows() > 0)
{
$receipt_sale_id = 'POS ' . $sale_info->row()->sale_id;
return TRUE;
}
}
}
return FALSE;
}
public function exists($sale_id)
{
@@ -503,7 +648,15 @@ class Sale extends CI_Model
return $this->Customer->get_info($this->db->get()->row()->customer_id);
}
public function invoice_number_exists($invoice_number, $sale_id = '')
public function get_employee($sale_id)
{
$this->db->from('sales');
$this->db->where('sale_id', $sale_id);
return $this->Employee->get_info($this->db->get()->row()->employee_id);
}
public function check_invoice_number_exists($invoice_number, $sale_id = '')
{
$this->db->from('sales');
$this->db->where('invoice_number', $invoice_number);
@@ -529,34 +682,49 @@ class Sale extends CI_Model
}
//We create a temp table that allows us to do easy report/sales queries
public function create_temp_table()
public function create_temp_table(array $inputs)
{
if($this->config->item('tax_included'))
{
$total = '1';
$subtotal = '(1 - (SUM(1 - 100 / (100 + sales_items_taxes.percent))))';
$tax = '(SUM(1 - 100 / (100 + sales_items_taxes.percent)))';
$sale_total = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100))';
$sale_subtotal = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (100 / (100 + SUM(sales_items_taxes.percent))))';
$sale_tax = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (1 - 100 / (100 + SUM(sales_items_taxes.percent))))';
}
else
{
$tax = '(SUM(sales_items_taxes.percent) / 100)';
$total = '(1 + (SUM(sales_items_taxes.percent / 100)))';
$subtotal = '1';
$sale_total = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (1 + (SUM(sales_items_taxes.percent) / 100)))';
$sale_subtotal = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100))';
$sale_tax = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (SUM(sales_items_taxes.percent) / 100))';
}
$sale_total = '(sales_items.item_unit_price * sales_items.quantity_purchased - sales_items.item_unit_price * sales_items.quantity_purchased * sales_items.discount_percent / 100)';
$sale_cost = '(sales_items.item_cost_price * sales_items.quantity_purchased)';
$decimals = totals_decimals();
// increase the rounding of two decimals on top of the selected ones to avoid accumulative rounding errors in the totals
$decimals = totals_decimals() + 2;
if(empty($input['sale_id']))
{
$where = 'WHERE DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
}
else
{
$where = 'WHERE sales.sale_id = ' . $this->db->escape($inputs['sale_id']);
}
// create a temporary table to contain all the payment types and amount
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
' (PRIMARY KEY(sale_id), INDEX(sale_id))
(
SELECT sale_id,
IFNULL(SUM(payment_amount), 0) AS sale_payment_amount,
GROUP_CONCAT(CONCAT(payment_type, " ", payment_amount) SEPARATOR ", ") AS payment_type
FROM ' . $this->db->dbprefix('sales_payments') . '
GROUP BY sale_id
SELECT payments.sale_id AS sale_id,
IFNULL(SUM(payments.payment_amount), 0) AS sale_payment_amount,
GROUP_CONCAT(CONCAT(payments.payment_type, " ", payments.payment_amount) SEPARATOR ", ") AS payment_type
FROM ' . $this->db->dbprefix('sales_payments') . ' AS payments
INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
ON sales.sale_id = payments.sale_id
' . "
$where
" . '
GROUP BY payments.sale_id
)'
);
@@ -594,11 +762,11 @@ class Sale extends CI_Model
payments.sale_payment_amount,
IFNULL(SUM(sales_items_taxes.percent), 0) AS item_tax_percent,
' . "
IFNULL(ROUND($sale_total * $total, $decimals), ROUND($sale_total * $subtotal, $decimals)) AS total,
IFNULL(ROUND($sale_total * $tax, $decimals), 0) AS tax,
ROUND($sale_total * $subtotal, $decimals) AS subtotal,
ROUND($sale_total - $sale_cost, $decimals) AS profit,
ROUND($sale_cost, $decimals) AS cost
ROUND($sale_subtotal, $decimals) AS subtotal,
IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS total,
IFNULL(ROUND($sale_tax, $decimals), 0) AS tax,
ROUND($sale_cost, $decimals) AS cost,
ROUND($sale_total - IFNULL($sale_tax, 0) - $sale_cost, $decimals) AS profit
" . '
FROM ' . $this->db->dbprefix('sales_items') . ' AS sales_items
INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
@@ -617,9 +785,15 @@ class Sale extends CI_Model
ON sales.employee_id = employee.person_id
LEFT OUTER JOIN ' . $this->db->dbprefix('sales_items_taxes') . ' AS sales_items_taxes
ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id AND sales_items.line = sales_items_taxes.line
' . "
$where
" . '
GROUP BY sales.sale_id, items.item_id, sales_items.line
)'
);
// drop the temporary table to contain memory consumption as it's no longer required
$this->db->query('DROP TEMPORARY TABLE IF EXISTS ' . $this->db->dbprefix('sales_payments_temp'));
}
}
?>

View File

@@ -161,18 +161,6 @@ class Sale_suspended extends CI_Model
return $this->db->get();
}
public function invoice_number_exists($invoice_number, $sale_id = '')
{
$this->db->from('sales_suspended');
$this->db->where('invoice_number', $invoice_number);
if(!empty($sale_id))
{
$this->db->where('sale_id !=', $sale_id);
}
return ($this->db->get()->num_rows() == 1);
}
public function get_comment($sale_id)
{

View File

@@ -5,9 +5,12 @@ class Detailed_receivings extends Report
function __construct()
{
parent::__construct();
}
public function create(array $inputs)
{
//Create our temp tables to work with the data in our report
$this->Receiving->create_temp_table();
$this->Receiving->create_temp_table($inputs);
}
public function getDataColumns()
@@ -53,21 +56,20 @@ class Detailed_receivings extends Report
$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_date BETWEEN '. $this->db->escape($inputs['start_date']). ' AND '. $this->db->escape($inputs['end_date']));
if ($inputs['location_id'] != 'all')
if($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['receiving_type'] == 'receiving')
if($inputs['receiving_type'] == 'receiving')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['receiving_type'] == 'returns')
elseif($inputs['receiving_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
elseif ($inputs['receiving_type'] == 'requisitions')
elseif($inputs['receiving_type'] == 'requisitions')
{
$this->db->having('items_purchased = 0');
}
@@ -80,8 +82,7 @@ class Detailed_receivings extends Report
foreach($data['summary'] as $key=>$value)
{
$this->db->select('name, item_number, category, quantity_purchased, serialnumber,total, discount_percent, item_location');
$this->db->select($this->db->dbprefix('receivings_items_temp').".receiving_quantity");
$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');
$this->db->where('receiving_id = '.$value['receiving_id']);
@@ -95,21 +96,20 @@ class Detailed_receivings extends Report
{
$this->db->select('SUM(total) AS total');
$this->db->from('receivings_items_temp');
$this->db->where('receiving_date BETWEEN '. $this->db->escape($inputs['start_date']). ' AND '. $this->db->escape($inputs['end_date']));
if ($inputs['location_id'] != 'all')
if($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['receiving_type'] == 'receiving')
if($inputs['receiving_type'] == 'receiving')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['receiving_type'] == 'returns')
elseif($inputs['receiving_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
elseif ($inputs['receiving_type'] == 'requisitions')
elseif($inputs['receiving_type'] == 'requisitions')
{
$this->db->where('quantity_purchased = 0');
}

View File

@@ -5,11 +5,14 @@ class Detailed_sales extends Report
function __construct()
{
parent::__construct();
//Create our temp tables to work with the data in our report
$this->Sale->create_temp_table();
}
public function create(array $inputs)
{
//Create our temp tables to work with the data in our report
$this->Sale->create_temp_table($inputs);
}
public function getDataColumns()
{
return array(
@@ -27,21 +30,21 @@ class Detailed_sales extends Report
'payment_type' => $this->lang->line('sales_amount_tendered'),
'comment' => $this->lang->line('reports_comments'),
'edit' => ''),
'details' => array(
$this->lang->line('reports_name'),
$this->lang->line('reports_category'),
$this->lang->line('reports_serial_number'),
$this->lang->line('reports_description'),
$this->lang->line('reports_quantity'),
$this->lang->line('reports_subtotal'),
$this->lang->line('reports_total'),
$this->lang->line('reports_tax'),
$this->lang->line('reports_cost'),
$this->lang->line('reports_profit'),
$this->lang->line('reports_discount'))
'details' => array(
$this->lang->line('reports_name'),
$this->lang->line('reports_category'),
$this->lang->line('reports_serial_number'),
$this->lang->line('reports_description'),
$this->lang->line('reports_quantity'),
$this->lang->line('reports_subtotal'),
$this->lang->line('reports_total'),
$this->lang->line('reports_tax'),
$this->lang->line('reports_cost'),
$this->lang->line('reports_profit'),
$this->lang->line('reports_discount'))
);
}
public function getDataBySaleId($sale_id)
{
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
@@ -50,23 +53,22 @@ class Detailed_sales extends Report
return $this->db->get()->row_array();
}
public function getData(array $inputs)
{
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
$this->db->from('sales_items_temp');
$this->db->where('sale_date BETWEEN '. $this->db->escape($inputs['start_date']). ' AND '. $this->db->escape($inputs['end_date']));
if ($inputs['location_id'] != 'all')
if($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['sale_type'] == 'sales')
if($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
elseif($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
@@ -77,7 +79,7 @@ class Detailed_sales extends Report
$data = array();
$data['summary'] = $this->db->get()->result_array();
$data['details'] = array();
foreach($data['summary'] as $key=>$value)
{
$this->db->select('name, category, quantity_purchased, item_location, serialnumber, description, subtotal, total, tax, cost, profit, discount_percent');
@@ -85,26 +87,25 @@ class Detailed_sales extends Report
$this->db->where('sale_id', $value['sale_id']);
$data['details'][$key] = $this->db->get()->result_array();
}
return $data;
}
public function getSummaryData(array $inputs)
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where('sale_date BETWEEN '. $this->db->escape($inputs['start_date']). ' AND '. $this->db->escape($inputs['end_date']));
if ($inputs['location_id'] != 'all')
if($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['sale_type'] == 'sales')
if($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
elseif($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}

View File

@@ -5,11 +5,8 @@ class Inventory_low extends Report
function __construct()
{
parent::__construct();
//Create our temp tables to work with the data in our report
$this->Item->create_temp_table();
}
public function getDataColumns()
{
return array($this->lang->line('reports_item_name'),
@@ -21,10 +18,14 @@ class Inventory_low extends Report
public function getData(array $inputs)
{
$this->db->select('name, item_number, quantity, reorder_level, location_name');
$this->db->from('items_temp');
$this->db->where('quantity <= reorder_level');
$this->db->order_by('name');
$this->db->select('items.name, items.item_number, item_quantities.quantity, items.reorder_level, stock_locations.location_name');
$this->db->from('items');
$this->db->join('item_quantities', 'items.item_id = item_quantities.item_id');
$this->db->join('stock_locations', 'item_quantities.location_id = stock_locations.location_id');
$this->db->where('items.deleted', 0);
$this->db->where('stock_locations.deleted', 0);
$this->db->where('item_quantities.quantity <= items.reorder_level');
$this->db->order_by('items.name');
return $this->db->get()->result_array();
}

View File

@@ -5,9 +5,6 @@ class Inventory_summary extends Report
function __construct()
{
parent::__construct();
//Create our temp tables to work with the data in our report
$this->Item->create_temp_table();
}
public function getDataColumns()
@@ -23,26 +20,30 @@ class Inventory_summary extends Report
}
public function getData(array $inputs)
{
$this->db->select('name, item_number, quantity, reorder_level, location_name, cost_price, unit_price, sub_total_value');
$this->db->from('items_temp');
{
$this->db->select('items.name, items.item_number, item_quantities.quantity, items.reorder_level, stock_locations.location_name, items.cost_price, items.unit_price, (items.cost_price * item_quantities.quantity) AS sub_total_value');
$this->db->from('items AS items');
$this->db->join('item_quantities AS item_quantities', 'items.item_id = item_quantities.item_id');
$this->db->join('stock_locations AS stock_locations', 'item_quantities.location_id = stock_locations.location_id');
$this->db->where('items.deleted', 0);
$this->db->where('stock_locations.deleted', 0);
// should be corresponding to values Inventory_summary::getItemCountDropdownArray() returns...
if($inputs['item_count'] == 'zero_and_less')
{
$this->db->where('quantity <= 0');
$this->db->where('item_quantities.quantity <= 0');
}
elseif($inputs['item_count'] == 'more_than_zero')
{
$this->db->where('quantity > 0');
$this->db->where('item_quantities.quantity > 0');
}
if($inputs['location_id'] != 'all')
{
$this->db->where('location_id', $inputs['location_id']);
$this->db->where('stock_locations.location_id', $inputs['location_id']);
}
$this->db->order_by('name');
$this->db->order_by('items.name');
return $this->db->get()->result_array();
}

View File

@@ -11,14 +11,14 @@ abstract class Report extends CI_Model
$this->output->set_header('Cache-Control: post-check=0, pre-check=0', FALSE);
$this->output->set_header('Pragma: no-cache');
}
//Returns the column names used for the report
// Returns the column names used for the report
public abstract function getDataColumns();
//Returns all the data to be populated into the report
// Returns all the data to be populated into the report
public abstract function getData(array $inputs);
//Returns key=>value pairing of summary data for the report
// Returns key=>value pairing of summary data for the report
public abstract function getSummaryData(array $inputs);
}
?>

View File

@@ -5,9 +5,12 @@ class Specific_customer extends Report
function __construct()
{
parent::__construct();
}
public function create(array $inputs)
{
//Create our temp tables to work with the data in our report
$this->Sale->create_temp_table();
$this->Sale->create_temp_table($inputs);
}
public function getDataColumns()
@@ -21,7 +24,7 @@ class Specific_customer extends Report
{
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " AND customer_id=" . $this->db->escape($inputs['customer_id']));
$this->db->where('customer_id', $inputs['customer_id']);
if ($inputs['sale_type'] == 'sales')
{
@@ -54,7 +57,7 @@ class Specific_customer extends Report
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " AND customer_id=" . $this->db->escape($inputs['customer_id']));
$this->db->where('customer_id', $inputs['customer_id']);
if ($inputs['sale_type'] == 'sales')
{

View File

@@ -5,9 +5,12 @@ class Specific_discount extends Report
function __construct()
{
parent::__construct();
}
public function create(array $inputs)
{
//Create our temp tables to work with the data in our report
$this->Sale->create_temp_table();
$this->Sale->create_temp_table($inputs);
}
public function getDataColumns()
@@ -21,8 +24,8 @@ class Specific_discount extends Report
{
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " AND discount_percent >=" . $this->db->escape($inputs['discount']));
$this->db->where('discount_percent >=', $inputs['discount']);
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -44,7 +47,6 @@ class Specific_discount extends Report
$this->db->select('name, serialnumber, category, description, quantity_purchased, subtotal, total, tax, cost, profit, discount_percent');
$this->db->from('sales_items_temp');
$this->db->where('sale_id', $value['sale_id']);
$this->db->where('discount_percent >= ', $inputs['discount']);
$data['details'][$key] = $this->db->get()->result_array();
}
@@ -55,8 +57,8 @@ class Specific_discount extends Report
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " AND discount_percent >=" . $this->db->escape($inputs['discount']));
$this->db->where('discount_percent >=', $inputs['discount']);
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');

View File

@@ -5,9 +5,12 @@ class Specific_employee extends Report
function __construct()
{
parent::__construct();
}
public function create(array $inputs)
{
//Create our temp tables to work with the data in our report
$this->Sale->create_temp_table();
$this->Sale->create_temp_table($inputs);
}
public function getDataColumns()
@@ -21,7 +24,7 @@ class Specific_employee extends Report
{
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " AND employee_id=" . $this->db->escape($inputs['employee_id']));
$this->db->where('employee_id', $inputs['employee_id']);
if ($inputs['sale_type'] == 'sales')
{
@@ -54,7 +57,7 @@ class Specific_employee extends Report
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " AND employee_id=" . $this->db->escape($inputs['employee_id']));
$this->db->where('employee_id', $inputs['employee_id']);
if ($inputs['sale_type'] == 'sales')
{

View File

@@ -1,67 +1,36 @@
<?php
require_once("Report.php");
class Summary_categories extends Report
require_once("Summary_report.php");
class Summary_categories extends Summary_report
{
function __construct()
{
parent::__construct();
//Create our temp tables to work with the data in our report
$this->Sale->create_temp_table();
}
public function getDataColumns()
{
return array($this->lang->line('reports_category'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
}
public function getData(array $inputs)
{
$this->db->select('category, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
$this->commonSelect($inputs);
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
$this->db->select('
items.category AS category,
SUM(sales_items.quantity_purchased) AS quantity_purchased
');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
$this->commonFrom();
$this->db->join('items AS items', 'sales_items.item_id = items.item_id', 'inner');
$this->commonWhere($inputs);
$this->db->group_by('category');
$this->db->order_by('category');
return $this->db->get()->result_array();
}
public function getSummaryData(array $inputs)
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
return $this->db->get()->row_array();
}
}
?>

View File

@@ -1,67 +1,36 @@
<?php
require_once("Report.php");
class Summary_customers extends Report
require_once("Summary_report.php");
class Summary_customers extends Summary_report
{
function __construct()
{
parent::__construct();
//Create our temp tables to work with the data in our report
$this->Sale->create_temp_table();
}
public function getDataColumns()
{
return array($this->lang->line('reports_customer'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
}
public function getData(array $inputs)
{
$this->db->select('customer_name AS customer, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
$this->commonSelect($inputs);
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
$this->db->select('
CONCAT(customer_p.first_name, " ", customer_p.last_name) AS customer,
SUM(sales_items.quantity_purchased) AS quantity_purchased
');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
$this->commonFrom();
$this->db->group_by('customer_id');
$this->db->order_by('customer_last_name');
$this->db->join('people AS customer_p', 'sales.customer_id = customer_p.person_id');
$this->commonWhere($inputs);
$this->db->group_by('sales.customer_id');
$this->db->order_by('customer_p.last_name');
return $this->db->get()->result_array();
}
public function getSummaryData(array $inputs)
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
return $this->db->get()->row_array();
}
}
?>

View File

@@ -1,13 +1,10 @@
<?php
require_once("Report.php");
class Summary_discounts extends Report
require_once("Summary_report.php");
class Summary_discounts extends Summary_report
{
function __construct()
{
parent::__construct();
//Create our temp tables to work with the data in our report
$this->Sale->create_temp_table();
}
public function getDataColumns()
@@ -17,52 +14,18 @@ class Summary_discounts extends Report
public function getData(array $inputs)
{
$this->db->select('CONCAT(discount_percent, "%") AS discount_percent, count(*) AS count');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
$this->db->select('CONCAT(sales_items.discount_percent, "%") AS discount_percent, count(*) AS count');
$this->db->from('sales_items AS sales_items');
$this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
$this->db->where('discount_percent > 0');
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
$this->commonWhere($inputs);
$this->db->group_by('sales_items_temp.discount_percent');
$this->db->order_by('discount_percent');
$this->db->group_by('sales_items.discount_percent');
$this->db->order_by('sales_items.discount_percent');
return $this->db->get()->result_array();
}
public function getSummaryData(array $inputs)
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
return $this->db->get()->row_array();
}
}
?>

View File

@@ -1,13 +1,10 @@
<?php
require_once("Report.php");
class Summary_employees extends Report
require_once("Summary_report.php");
class Summary_employees extends Summary_report
{
function __construct()
{
parent::__construct();
//Create our temp tables to work with the data in our report
$this->Sale->create_temp_table();
}
public function getDataColumns()
@@ -17,51 +14,23 @@ class Summary_employees extends Report
public function getData(array $inputs)
{
$this->db->select('employee_name AS employee, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
$this->commonSelect($inputs);
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
$this->db->select('
CONCAT(employee_p.first_name, " ", employee_p.last_name) AS employee,
SUM(sales_items.quantity_purchased) AS quantity_purchased
');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
$this->commonFrom();
$this->db->group_by('employee_id');
$this->db->order_by('employee_name');
$this->db->join('people AS employee_p', 'sales.employee_id = employee_p.person_id');
$this->commonWhere($inputs);
$this->db->group_by('sales.employee_id');
$this->db->order_by('employee_p.last_name');
return $this->db->get()->result_array();
}
public function getSummaryData(array $inputs)
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
return $this->db->get()->row_array();
}
}
?>

View File

@@ -1,15 +1,12 @@
<?php
require_once("Report.php");
class Summary_items extends Report
require_once("Summary_report.php");
class Summary_items extends Summary_report
{
function __construct()
{
parent::__construct();
//Create our temp tables to work with the data in our report
$this->Sale->create_temp_table();
}
public function getDataColumns()
{
return array($this->lang->line('reports_item'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
@@ -17,51 +14,23 @@ class Summary_items extends Report
public function getData(array $inputs)
{
$this->db->select('name, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
$this->commonSelect($inputs);
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
$this->db->select('
items.name AS name,
SUM(sales_items.quantity_purchased) AS quantity_purchased
');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
$this->commonFrom();
$this->db->group_by('item_id');
$this->db->order_by('name');
$this->db->join('items AS items', 'sales_items.item_id = items.item_id', 'inner');
$this->commonWhere($inputs);
$this->db->group_by('items.item_id');
$this->db->order_by('items.name');
return $this->db->get()->result_array();
}
public function getSummaryData(array $inputs)
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
return $this->db->get()->row_array();
}
}
?>

View File

@@ -1,13 +1,10 @@
<?php
require_once("Report.php");
class Summary_payments extends Report
require_once("Summary_report.php");
class Summary_payments extends Summary_report
{
function __construct()
{
parent::__construct();
//Create our temp tables to work with the data in our report
$this->Sale->create_temp_table();
}
public function getDataColumns()
@@ -19,22 +16,9 @@ class Summary_payments extends Report
{
$this->db->select('sales_payments.payment_type, count(*) AS count, SUM(payment_amount) AS payment_amount');
$this->db->from('sales_payments');
$this->db->join('sales', 'sales.sale_id=sales_payments.sale_id');
$this->db->where("date(sale_time) BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
$this->db->join('sales AS sales', 'sales.sale_id = sales_payments.sale_id');
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('payment_amount > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('payment_amount < 0');
}
$this->commonWhere($inputs);
$this->db->group_by("payment_type");
@@ -62,28 +46,5 @@ class Summary_payments extends Report
return $payments;
}
public function getSummaryData(array $inputs)
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
return $this->db->get()->row_array();
}
}
?>

View File

@@ -0,0 +1,92 @@
<?php
require_once("Report.php");
abstract class Summary_report extends Report
{
function __construct()
{
parent::__construct();
}
protected function commonSelect(array $inputs)
{
// create a temporary table to contain all the payment types and amount
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp') .
' (INDEX(sale_id), INDEX(item_id))
(
SELECT sales_items_taxes.sale_id AS sale_id,
sales_items_taxes.item_id AS item_id,
SUM(sales_items_taxes.percent) AS percent
FROM ' . $this->db->dbprefix('sales_items_taxes') . ' AS sales_items_taxes
INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
ON sales.sale_id = sales_items_taxes.sale_id
INNER JOIN ' . $this->db->dbprefix('sales_items') . ' AS sales_items
ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.line = sales_items_taxes.line
WHERE DATE(sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']) . '
GROUP BY sales_items_taxes.sale_id, sales_items_taxes.item_id
)'
);
if($this->config->item('tax_included'))
{
$sale_total = 'SUM(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100))';
$sale_subtotal = 'SUM(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (100 / (100 + sales_items_taxes.percent)))';
$sale_tax = 'SUM(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (1 - 100 / (100 + sales_items_taxes.percent)))';
}
else
{
$sale_total = 'SUM(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (1 + (sales_items_taxes.percent / 100)))';
$sale_subtotal = 'SUM(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100))';
$sale_tax = 'SUM(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (sales_items_taxes.percent / 100))';
}
$sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
$decimals = totals_decimals();
$this->db->select("
ROUND($sale_subtotal, $decimals) AS subtotal,
IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS total,
IFNULL(ROUND($sale_tax, $decimals), 0) AS tax,
ROUND($sale_cost, $decimals) AS cost,
ROUND($sale_total - IFNULL($sale_tax, 0) - $sale_cost, $decimals) AS profit
");
}
protected function commonFrom()
{
$this->db->from('sales_items AS sales_items');
$this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
$this->db->join('sales_items_taxes_temp AS sales_items_taxes', 'sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id', 'left outer');
}
protected function commonWhere(array $inputs)
{
$this->db->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']));
if($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
public function getSummaryData(array $inputs)
{
$this->commonSelect($inputs);
$this->commonFrom();
$this->commonWhere($inputs);
return $this->db->get()->row_array();
}
}
?>

View File

@@ -1,68 +1,34 @@
<?php
require_once("Report.php");
class Summary_sales extends Report
require_once("Summary_report.php");
class Summary_sales extends Summary_report
{
function __construct()
{
parent::__construct();
//Create our temp tables to work with the data in our report
$this->Sale->create_temp_table();
}
public function getDataColumns()
{
return array($this->lang->line('reports_date'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
}
public function getData(array $inputs)
{
$this->db->select('sale_date, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
{
$this->commonSelect($inputs);
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
$this->db->select('
DATE(sales.sale_time) AS sale_date,
SUM(sales_items.quantity_purchased) AS quantity_purchased
');
$this->commonFrom();
$this->commonWhere($inputs);
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
$this->db->group_by('sale_date');
$this->db->order_by('sale_date');
return $this->db->get()->result_array();
}
public function getSummaryData(array $inputs)
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
return $this->db->get()->row_array();
}
}
?>

View File

@@ -1,71 +1,38 @@
<?php
require_once("Report.php");
class Summary_suppliers extends Report
require_once("Summary_report.php");
class Summary_suppliers extends Summary_report
{
function __construct()
{
parent::__construct();
//Create our temp tables to work with the data in our report
$this->Sale->create_temp_table();
}
public function getDataColumns()
{
return array($this->lang->line('reports_supplier'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
}
public function getData(array $inputs)
{
$this->db->select('CONCAT(company_name, " (", first_name, " ", last_name, ")") AS supplier, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->join('suppliers', 'suppliers.person_id = sales_items_temp.supplier_id');
$this->db->join('people', 'suppliers.person_id = people.person_id');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
$this->commonSelect($inputs);
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
$this->db->select('
CONCAT(supplier_c.company_name, " (", supplier_p.first_name, " ", supplier_p.last_name, ")") AS supplier,
SUM(sales_items.quantity_purchased) AS quantity_purchased
');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
$this->commonFrom();
$this->db->group_by('supplier_id');
$this->db->order_by('last_name');
$this->db->join('items AS items', 'sales_items.item_id = items.item_id', 'inner');
$this->db->join('suppliers AS supplier_c', 'supplier_c.person_id = items.supplier_id');
$this->db->join('people AS supplier_p', 'supplier_c.person_id = supplier_p.person_id');
$this->commonWhere($inputs);
$this->db->group_by('items.supplier_id');
$this->db->order_by('supplier_p.last_name');
return $this->db->get()->result_array();
}
public function getSummaryData(array $inputs)
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->join('suppliers', 'suppliers.person_id = sales_items_temp.supplier_id');
$this->db->join('people', 'suppliers.person_id = people.person_id');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
return $this->db->get()->row_array();
}
}
?>

View File

@@ -1,90 +1,67 @@
<?php
require_once("Report.php");
class Summary_taxes extends Report
require_once("Summary_report.php");
class Summary_taxes extends Summary_report
{
function __construct()
{
parent::__construct();
//Create our temp tables to work with the data in our report
$this->Sale->create_temp_table();
}
public function getDataColumns()
{
return array($this->lang->line('reports_tax_percent'), $this->lang->line('reports_count'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'));
}
public function getData(array $inputs)
{
$quantity_cond = '';
if ($inputs['sale_type'] == 'sales')
{
$quantity_cond = 'and quantity_purchased > 0';
$quantity_cond = 'AND quantity_purchased > 0';
}
elseif ($inputs['sale_type'] == 'returns')
{
$quantity_cond = 'and quantity_purchased < 0';
$quantity_cond = 'AND quantity_purchased < 0';
}
if ($inputs['location_id'] != 'all')
{
$quantity_cond .= 'and item_location = '. $this->db->escape($inputs['location_id']);
$quantity_cond .= 'AND item_location = '. $this->db->escape($inputs['location_id']);
}
if ($this->config->item('tax_included'))
if($this->config->item('tax_included'))
{
$total = "1";
$subtotal = "(100/(100+percent))";
$tax = "(1 - (100/(100 +percent)))";
$sale_total = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100))';
$sale_subtotal = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (100 / (100 + sales_items_taxes.percent)))';
$sale_tax = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (1 - 100 / (100 + sales_items_taxes.percent)))';
}
else
{
$tax = "(percent/100)";
$total = "(1+(percent/100))";
$subtotal = "1";
$sale_total = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (1 + (sales_items_taxes.percent / 100)))';
$sale_subtotal = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100))';
$sale_tax = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (sales_items_taxes.percent / 100))';
}
$decimals = totals_decimals();
$query = $this->db->query("SELECT percent, count(*) AS count, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax
FROM (SELECT name, CONCAT(ROUND(percent, $decimals), '%') AS percent,
ROUND((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100) * $subtotal, $decimals) AS subtotal,
ROUND((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100) * $total, $decimals) AS total,
ROUND((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100) * $tax, $decimals) AS tax
FROM ".$this->db->dbprefix('sales_items_taxes')."
JOIN ".$this->db->dbprefix('sales_items')." ON "
.$this->db->dbprefix('sales_items').'.sale_id='.$this->db->dbprefix('sales_items_taxes').'.sale_id'." AND "
.$this->db->dbprefix('sales_items').'.item_id='.$this->db->dbprefix('sales_items_taxes').'.item_id'." AND "
.$this->db->dbprefix('sales_items').'.line='.$this->db->dbprefix('sales_items_taxes').'.line'
." JOIN ".$this->db->dbprefix('sales')." ON ".$this->db->dbprefix('sales_items_taxes').".sale_id=".$this->db->dbprefix('sales').".sale_id
WHERE date(sale_time) BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " $quantity_cond) AS temp_taxes
GROUP BY percent");
$query = $this->db->query("SELECT percent, count(*) AS count, ROUND(SUM(subtotal), $decimals) AS subtotal, ROUND(SUM(total), $decimals) AS total, ROUND(SUM(tax), $decimals) AS tax
FROM (
SELECT
CONCAT(IFNULL(ROUND(percent, $decimals), 0), '%') AS percent,
$sale_subtotal AS subtotal,
IFNULL($sale_total, $sale_subtotal) AS total,
IFNULL($sale_tax, 0) AS tax
FROM " . $this->db->dbprefix('sales_items') . ' AS sales_items
INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
ON sales_items.sale_id = sales.sale_id
LEFT OUTER JOIN ' . $this->db->dbprefix('sales_items_taxes') . ' AS sales_items_taxes
ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id AND sales_items.line = sales_items_taxes.line
WHERE DATE(sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']) . " $quantity_cond
) AS temp_taxes
GROUP BY percent"
);
return $query->result_array();
}
public function getSummaryData(array $inputs)
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
}
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
return $this->db->get()->row_array();
}
}
?>

View File

@@ -25,7 +25,7 @@
<div class="fileinput-new thumbnail" style="width: 200px; height: 200px;"></div>
<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 200px;">
<img data-src="holder.js/100%x100%" alt="<?php echo $this->lang->line('config_company_logo'); ?>"
src="<?php if($logo_exists) echo base_url('uploads/' . $this->Appconfig->get('company_logo')); else echo ''; ?>"
src="<?php if($logo_exists) echo base_url('uploads/' . $this->config->item('company_logo')); else echo ''; ?>"
style="max-height: 100%; max-width: 100%;">
</div>
<div>

View File

@@ -59,7 +59,7 @@ $(document).ready(function()
<div id="title_bar" class="btn-toolbar print_hide">
<button class='btn btn-info btn-sm pull-right modal-dlg' data-btn-submit='<?php echo $this->lang->line('common_submit') ?>' data-href='<?php echo site_url($controller_name."/excel_import"); ?>'
title='<?php echo $this->lang->line('customers_import_items_excel'); ?>'>
title='<?php echo $this->lang->line('items_import_items_excel'); ?>'>
<span class="glyphicon glyphicon-import">&nbsp</span><?php echo $this->lang->line('common_import_excel'); ?>
</button>

View File

@@ -54,6 +54,7 @@
<script src="bower_components/chartist-plugin-axistitle/dist/chartist-plugin-axistitle.min.js"></script>
<script src="bower_components/chartist-plugin-pointlabels/dist/chartist-plugin-pointlabels.min.js"></script>
<script src="bower_components/chartist-plugin-tooltip/dist/chartist-plugin-tooltip.min.js"></script>
<script src="bower_components/chartist-plugin-barlabels/dist/chartist-plugin-barlabels.min.js"></script>
<script src="bower_components/remarkable-bootstrap-notify/bootstrap-notify.js"></script>
<script src="bower_components/js-cookie/src/js.cookie.js"></script>
<script src="bower_components/blockUI/jquery.blockUI.js"></script>
@@ -69,11 +70,11 @@
<![endif]-->
<!-- start mincss template tags -->
<link rel="stylesheet" type="text/css" href="dist/jquery-ui.css"/>
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=d5b9522f2f"/>
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=838e46d56e"/>
<link rel="stylesheet" type="text/css" href="dist/style.css"/>
<!-- end mincss template tags -->
<!-- start minjs template tags -->
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=9a77ed1ae9"></script>
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=c84a0bb15a"></script>
<!-- end minjs template tags -->
<?php endif; ?>

View File

@@ -8,12 +8,12 @@ function printdoc()
if (window.jsPrintSetup)
{
// set top margins in millimeters
jsPrintSetup.setOption('marginTop', '<?php echo $this->Appconfig->get('print_top_margin'); ?>');
jsPrintSetup.setOption('marginLeft', '<?php echo $this->Appconfig->get('print_left_margin'); ?>');
jsPrintSetup.setOption('marginBottom', '<?php echo $this->Appconfig->get('print_bottom_margin'); ?>');
jsPrintSetup.setOption('marginRight', '<?php echo $this->Appconfig->get('print_right_margin'); ?>');
jsPrintSetup.setOption('marginTop', '<?php echo $this->config->item('print_top_margin'); ?>');
jsPrintSetup.setOption('marginLeft', '<?php echo $this->config->item('print_left_margin'); ?>');
jsPrintSetup.setOption('marginBottom', '<?php echo $this->config->item('print_bottom_margin'); ?>');
jsPrintSetup.setOption('marginRight', '<?php echo $this->config->item('print_right_margin'); ?>');
<?php if (!$this->Appconfig->get('print_header'))
<?php if (!$this->config->item('print_header'))
{
?>
// set page header
@@ -22,7 +22,7 @@ function printdoc()
jsPrintSetup.setOption('headerStrRight', '');
<?php
}
if (!$this->Appconfig->get('print_footer'))
if (!$this->config->item('print_footer'))
{
?>
// set empty page footer
@@ -44,7 +44,7 @@ function printdoc()
// clears user preferences always silent print value
// to enable using 'printSilent' option
jsPrintSetup.clearSilentPrint();
<?php if (!$this->Appconfig->get('print_silently'))
<?php if (!$this->config->item('print_silently'))
{
?>
// Suppress print dialog (for this context only)

View File

@@ -18,7 +18,7 @@ if (isset($error_message))
<div id="receipt_wrapper">
<div id="receipt_header">
<?php
if ($this->Appconfig->get('company_logo') == '')
if ($this->config->item('company_logo') == '')
{
?>
<div id="company_name"><?php echo $this->config->item('company'); ?></div>
@@ -27,7 +27,7 @@ if (isset($error_message))
else
{
?>
<div id="company_name"><img id="image" src="<?php echo base_url('uploads/' . $this->Appconfig->get('company_logo')); ?>" alt="company_logo" /></div>
<div id="company_name"><img id="image" src="<?php echo base_url('uploads/' . $this->config->item('company_logo')); ?>" alt="company_logo" /></div>
<?php
}
?>

View File

@@ -87,6 +87,8 @@
}
}),
Chartist.plugins.ctBarLabels(),
Chartist.plugins.ctPointLabels({
textAnchor: 'middle'
})

View File

@@ -90,6 +90,8 @@
}
}),
Chartist.plugins.ctBarLabels(),
Chartist.plugins.ctPointLabels({
textAnchor: 'middle'
})

View File

@@ -33,13 +33,23 @@
axisX: {
// Lets offset the chart a bit from the labels
offset: 120,
position: 'end'
position: 'end',
// offset the labels a bit from the axis to avoid overlaps
labelOffset: {
x: 0,
y: 20
}
},
// Y-Axis specific configuration
axisY: {
// Lets offset the chart a bit from the labels
offset: 60,
offset: 80,
// offset the labels a bit from the axis to avoid overlaps
labelOffset: {
x: -20,
y: 0
},
// The label interpolation function enables you to modify the values
// used for the labels on each axis.
labelInterpolationFnc: function(value) {

View File

@@ -19,10 +19,10 @@ if (isset($error_message))
<table id="info">
<tr>
<td id="logo">
<?php if($this->Appconfig->get('company_logo') != '')
<?php if($this->config->item('company_logo') != '')
{
?>
<img id="image" src="<?php echo 'uploads/' . $this->Appconfig->get('company_logo'); ?>" alt="company_logo" />
<img id="image" src="<?php echo 'uploads/' . $this->config->item('company_logo'); ?>" alt="company_logo" />
<?php
}
?>

View File

@@ -1,10 +1,10 @@
<div id="receipt_wrapper">
<div id="receipt_header">
<?php
if ($this->Appconfig->get('company_logo') != '')
if ($this->config->item('company_logo') != '')
{
?>
<div id="company_name"><img id="image" src="<?php echo base_url('uploads/' . $this->Appconfig->get('company_logo')); ?>" alt="company_logo" /></div>
<div id="company_name"><img id="image" src="<?php echo base_url('uploads/' . $this->config->item('company_logo')); ?>" alt="company_logo" /></div>
<?php
}
?>
@@ -55,11 +55,11 @@
<td><?php echo ucfirst($item['name']); ?></td>
<td><?php echo to_currency($item['price']); ?></td>
<td><?php echo to_quantity_decimals($item['quantity']); ?></td>
<td class="total-value"><?php echo to_currency($item[($this->Appconfig->get('receipt_show_total_discount') ? 'total' : 'discounted_total')]); ?></td>
<td class="total-value"><?php echo to_currency($item[($this->config->item('receipt_show_total_discount') ? 'total' : 'discounted_total')]); ?></td>
</tr>
<tr>
<?php
if($this->Appconfig->get('receipt_show_description'))
if($this->config->item('receipt_show_description'))
{
?>
<td colspan="2"><?php echo $item['description']; ?></td>
@@ -67,7 +67,7 @@
}
?>
<?php
if($this->Appconfig->get('receipt_show_serialnumber'))
if($this->config->item('receipt_show_serialnumber'))
{
?>
<td><?php echo $item['serialnumber']; ?></td>
@@ -91,7 +91,7 @@
?>
<?php
if ($this->Appconfig->get('receipt_show_total_discount') && $discount > 0)
if ($this->config->item('receipt_show_total_discount') && $discount > 0)
{
?>
<tr>
@@ -107,7 +107,7 @@
?>
<?php
if ($this->Appconfig->get('receipt_show_taxes'))
if ($this->config->item('receipt_show_taxes'))
{
?>
<tr>
@@ -132,7 +132,7 @@
<tr>
</tr>
<?php $border = (!$this->Appconfig->get('receipt_show_taxes') && !($this->Appconfig->get('receipt_show_total_discount') && $discount > 0)); ?>
<?php $border = (!$this->config->item('receipt_show_taxes') && !($this->config->item('receipt_show_total_discount') && $discount > 0)); ?>
<tr>
<td colspan="3" style="text-align:right;<?php echo $border? 'border-top: 2px solid black;' :''; ?>"><?php echo $this->lang->line('sales_total'); ?></td>
<td style="text-align:right;<?php echo $border? 'border-top: 2px solid black;' :''; ?>"><?php echo to_currency($total); ?></td>

View File

@@ -1,10 +1,10 @@
<div id="receipt_wrapper" style="width:100%;">
<div id="receipt_header" style="text-align:center;">
<?php
if ($this->Appconfig->get('company_logo') != '')
if ($this->config->item('company_logo') != '')
{
?>
<div id="company_name"><img id="image" src="<?php echo base_url('uploads/' . $this->Appconfig->get('company_logo')); ?>" alt="company_logo" /></div>
<div id="company_name"><img id="image" src="<?php echo base_url('uploads/' . $this->config->item('company_logo')); ?>" alt="company_logo" /></div>
<?php
}
?>
@@ -50,11 +50,11 @@
<td><?php echo ucfirst($item['name']); ?></td>
<td><?php echo to_currency($item['price']); ?></td>
<td><?php echo to_quantity_decimals($item['quantity']); ?></td>
<td style="text-align:right;"><?php echo to_currency($item[($this->Appconfig->get('receipt_show_total_discount') ? 'total' : 'discounted_total')]); ?></td>
<td style="text-align:right;"><?php echo to_currency($item[($this->config->item('receipt_show_total_discount') ? 'total' : 'discounted_total')]); ?></td>
</tr>
<tr>
<?php
if($this->Appconfig->get('receipt_show_description'))
if($this->config->item('receipt_show_description'))
{
?>
<td colspan="2"><?php echo $item['description']; ?></td>
@@ -62,7 +62,7 @@
}
?>
<?php
if($this->Appconfig->get('receipt_show_serialnumber'))
if($this->config->item('receipt_show_serialnumber'))
{
?>
<td><?php echo $item['serialnumber']; ?></td>
@@ -86,7 +86,7 @@
?>
<?php
if ($this->Appconfig->get('receipt_show_total_discount') && $discount > 0)
if ($this->config->item('receipt_show_total_discount') && $discount > 0)
{
?>
<tr>
@@ -102,7 +102,7 @@
?>
<?php
if ($this->Appconfig->get('receipt_show_taxes'))
if ($this->config->item('receipt_show_taxes'))
{
?>
<tr>
@@ -127,7 +127,7 @@
<tr>
</tr>
<?php $border = (!$this->Appconfig->get('receipt_show_taxes') && !($this->Appconfig->get('receipt_show_total_discount') && $discount > 0)); ?>
<?php $border = (!$this->config->item('receipt_show_taxes') && !($this->config->item('receipt_show_total_discount') && $discount > 0)); ?>
<tr>
<td colspan="3" style="<?php echo $border? 'border-top: 2px solid black;' :''; ?>text-align:right;"><?php echo $this->lang->line('sales_total'); ?></td>
<td style="<?php echo $border? 'border-top: 2px solid black;' :''; ?>text-align:right"><?php echo to_currency($total); ?></td>

View File

@@ -1,10 +1,10 @@
<div id="receipt_wrapper">
<div id="receipt_header">
<?php
if ($this->Appconfig->get('company_logo') != '')
if ($this->config->item('company_logo') != '')
{
?>
<div id="company_name"><img id="image" src="<?php echo base_url('uploads/' . $this->Appconfig->get('company_logo')); ?>" alt="company_logo" /></div>
<div id="company_name"><img id="image" src="<?php echo base_url('uploads/' . $this->config->item('company_logo')); ?>" alt="company_logo" /></div>
<?php
}
?>
@@ -56,11 +56,11 @@
<tr>
<td><?php echo to_currency($item['price']); ?></td>
<td><?php echo to_quantity_decimals($item['quantity']); ?></td>
<td class="total-value"><?php echo to_currency($item[($this->Appconfig->get('receipt_show_total_discount') ? 'total' : 'discounted_total')]); ?></td>
<td class="total-value"><?php echo to_currency($item[($this->config->item('receipt_show_total_discount') ? 'total' : 'discounted_total')]); ?></td>
</tr>
<tr>
<?php
if($this->Appconfig->get('receipt_show_description'))
if($this->config->item('receipt_show_description'))
{
?>
<td colspan="2"><?php echo $item['description']; ?></td>
@@ -68,7 +68,7 @@
}
?>
<?php
if($this->Appconfig->get('receipt_show_serialnumber'))
if($this->config->item('receipt_show_serialnumber'))
{
?>
<td><?php echo $item['serialnumber']; ?></td>
@@ -92,7 +92,7 @@
?>
<?php
if ($this->Appconfig->get('receipt_show_total_discount') && $discount > 0)
if ($this->config->item('receipt_show_total_discount') && $discount > 0)
{
?>
<tr>
@@ -108,7 +108,7 @@
?>
<?php
if ($this->Appconfig->get('receipt_show_taxes'))
if ($this->config->item('receipt_show_taxes'))
{
?>
<tr>
@@ -133,7 +133,7 @@
<tr>
</tr>
<?php $border = (!$this->Appconfig->get('receipt_show_taxes') && !($this->Appconfig->get('receipt_show_total_discount') && $discount > 0)); ?>
<?php $border = (!$this->config->item('receipt_show_taxes') && !($this->config->item('receipt_show_total_discount') && $discount > 0)); ?>
<tr>
<td colspan="2" style="text-align:right;<?php echo $border? 'border-top: 2px solid black;' :''; ?>"><?php echo $this->lang->line('sales_total'); ?></td>
<td style="text-align:right;<?php echo $border? 'border-top: 2px solid black;' :''; ?>"><?php echo to_currency($total); ?></td>

View File

@@ -2,15 +2,15 @@
"name": "OpenSourcePOS",
"description": "Open Source Point of Sale is a web based POS system written in the PHP language. It uses MySQL as backend and has a simple user interface",
"version": "3.0.1",
"license": "MIT",
"authors": [
"jekkos <jeroen.peelaerts - at - gmail.com>",
"FrancescoUK <francesco.lodolo.uk - at - gmail.com>"
],
"keywords": [
"point-of-sale",
"POS"
"POS"
],
"license": "MIT",
"homepage": "https://github.com/jekkos/opensourcepos",
"private": true,
"moduleType": [
@@ -40,6 +40,7 @@
"chartist-plugin-axistitle": "^0.1.0",
"chartist-plugin-pointlabels": "^0.0.4",
"chartist-plugin-tooltip": "^0.0.13",
"chartist-plugin-barlabels": "https://github.com/mtgibbs/chartist-plugin-barlabels.git#^0.0.5",
"remarkable-bootstrap-notify": "^3.1.3",
"js-cookie": "^2.1.3",
"blockUI": "*"

View File

@@ -853,8 +853,8 @@ SELECT `receiving_time`, `supplier_id`, `employee_id`, `comment`, `receiving_id`
-- Copy data to table `ospos_receivings_items`
--
INSERT INTO `ospos_receivings_items` (`receiving_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent`)
SELECT `receiving_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent` FROM `phppos`.phppos_receivings_items;
INSERT INTO `ospos_receivings_items` (`receiving_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent`, `item_location`)
SELECT `receiving_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent`, 1 FROM `phppos`.phppos_receivings_items;
--
-- Copy data to table `ospos_sales`

View File

@@ -118,8 +118,8 @@ SELECT `receiving_time`, `supplier_id`, `employee_id`, `comment`, `receiving_id`
-- Copy data to table `ospos_receivings_items`
--
INSERT INTO `ospos_receivings_items` (`receiving_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent`)
SELECT `receiving_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent` FROM `phppos`.phppos_receivings_items;
INSERT INTO `ospos_receivings_items` (`receiving_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent`, `item_location`)
SELECT `receiving_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent`, 1 FROM `phppos`.phppos_receivings_items;
--
-- Copy data to table `ospos_sales`

View File

@@ -1,8 +1,13 @@
{
"name": "opensourcepos",
"version": "3.0.0",
"name": "OpenSourcePOS",
"version": "3.0.1",
"description": "Open Source Point of Sale is a web based point of sale system written in the PHP language. It uses MySQL as the data storage back-end and has a simple user interface.",
"main": "index.php",
"license": "MIT",
"authors": [
"jekkos <jeroen.peelaerts - at - gmail.com>",
"FrancescoUK <francesco.lodolo.uk - at - gmail.com>"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
@@ -14,8 +19,6 @@
"point-of-sale",
"POS"
],
"author": "jekkos",
"license": "MIT",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-bower": "^0.21.0",

View File

@@ -24,11 +24,36 @@ RewriteRule ^(.*)$ index.php?/$1 [L]
#Options All -Indexes
Options +ExecCGI +Includes +IncludesNOEXEC +SymLinksIfOwnerMatch -Indexes
# secure htaccess file
<Files .htaccess>
Order allow,deny
Deny from all
</Files>
# prevent folder listing
IndexIgnore *
# Apache 2.4
<IfModule authz_core_module>
# secure htaccess file
<Files .htaccess>
Require all denied
</Files>
# prevent access to PHP error log
<Files error_log>
Require all denied
</Files>
</IfModule>
# Apache 2.2
<IfModule !authz_core_module>
# secure htaccess file
<Files .htaccess>
Order allow,deny
Deny from all
Satisfy all
</Files>
# prevent access to PHP error log
<Files error_log>
Order allow,deny
Deny from all
Satisfy all
</Files>
</IfModule>
<IfModule mod_expires.c>
<FilesMatch "\.(jpe?g|png|gif|js|css)$">

View File

File diff suppressed because one or more lines are too long

View File

File diff suppressed because one or more lines are too long

View File

@@ -53,7 +53,7 @@
*
* NOTE: If you change these, also change the error_reporting() code below
*/
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production');
/*
*---------------------------------------------------------------

View File

@@ -10,6 +10,7 @@ Copyright (c) 2015-2016 FrancescoUK (aka daN4cat)
Copyright (c) 2015 Aamir Shahzad (aka asakpke), RoshanTech.com
Copyright (c) 2015 Toni Haryanto (aka yllumi)
Copyright (c) 2016 Ramkrishna Mondal (aka RamkrishnaMondal)
Copyright (c) 2016 rnld26
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

View File

@@ -5,10 +5,6 @@
],
"homepage": "https://github.com/Globegitter/chartist-plugin-tooltip"
},
"chartist@0.9.8": {
"licenses": "UNKNOWN",
"homepage": "https://github.com/gionkunz/chartist-js"
},
"bootswatch@3.3.7": {
"licenses": [
"MIT"
@@ -25,6 +21,18 @@
],
"homepage": "https://github.com/hhurz/tableExport.jquery.plugin"
},
"chartist-plugin-pointlabels@0.0.4": {
"licenses": [
"WTF*"
],
"homepage": "https://github.com/gionkunz/chartist-plugin-pointlabels"
},
"bootstrap3-dialog@1.35.3": {
"licenses": [
"MIT"
],
"homepage": "http://nakupanda.github.io/bootstrap3-dialog/"
},
"jquery-form@3.46.0": {
"licenses": "UNKNOWN",
"homepage": "https://github.com/malsup/form"
@@ -35,75 +43,51 @@
],
"homepage": "https://github.com/Teleborder/FileSaver.js"
},
"chartist-plugin-pointlabels@0.0.4": {
"licenses": [
"WTF*"
],
"homepage": "https://github.com/gionkunz/chartist-plugin-pointlabels"
},
"chartist-plugin-axistitle@0.1.0": {
"licenses": [
"WTF*"
],
"homepage": "https://github.com/alexstanbury/chartist-plugin-axistitle"
},
"blockUI@undefined": {
"licenses": [
"MIT*"
],
"homepage": "http://jquery.malsup.com/block/"
},
"bootstrap-select@1.11.2": {
"licenses": [
"MIT"
],
"homepage": "http://silviomoreto.github.io/bootstrap-select"
},
"jquery@1.12.4": {
"licenses": [
"MIT"
],
"homepage": "https://github.com/jquery/jquery-dist"
},
"bootstrap3-dialog@1.35.3": {
"licenses": [
"MIT"
],
"homepage": "http://nakupanda.github.io/bootstrap3-dialog/"
},
"js-cookie@2.1.3": {
"licenses": [
"MIT"
],
"homepage": "https://github.com/js-cookie/js-cookie"
},
"jspdf@1.0.272": {
"licenses": [
"MIT"
],
"homepage": "https://github.com/mrrio/jspdf"
},
"remarkable-bootstrap-notify@3.1.3": {
"moment@2.16.0": {
"licenses": [
"MIT"
],
"homepage": "http://bootstrap-notify.remabledesigns.com/",
"repository": "https://github.com/mouse0270/bootstrap-notify"
"homepage": "https://github.com/moment/moment"
},
"jasny-bootstrap@3.1.3": {
"licenses": [
"Apache-2.0",
"Apache*"
],
"homepage": "https://github.com/jasny/bootstrap",
"repository": "git+https://github.com/jasny/bootstrap"
"chartist@0.9.8": {
"licenses": "UNKNOWN",
"homepage": "https://github.com/gionkunz/chartist-js"
},
"jquery-validation@1.13.1": {
"jquery@1.12.4": {
"licenses": [
"MIT"
],
"repository": "https://github.com/jzaefferer/jquery-validation",
"homepage": "http://jqueryvalidation.org/"
"homepage": "https://github.com/jquery/jquery-dist"
},
"bootstrap-select@1.11.2": {
"licenses": [
"MIT"
],
"homepage": "http://silviomoreto.github.io/bootstrap-select"
},
"js-cookie@2.1.3": {
"licenses": [
"MIT"
],
"homepage": "https://github.com/js-cookie/js-cookie"
},
"blockUI@undefined": {
"licenses": [
"MIT*"
],
"homepage": "http://jquery.malsup.com/block/"
},
"smalot-bootstrap-datetimepicker@2.3.11": {
"licenses": [
@@ -113,11 +97,48 @@
"homepage": "https://github.com/smalot/bootstrap-datetimepicker",
"repository": "https://github.com/smalot/bootstrap-datetimepicker"
},
"moment@2.15.1": {
"remarkable-bootstrap-notify@3.1.3": {
"licenses": [
"MIT"
],
"homepage": "https://github.com/moment/moment"
"homepage": "http://bootstrap-notify.remabledesigns.com/",
"repository": "https://github.com/mouse0270/bootstrap-notify"
},
"jquery-validation@1.13.1": {
"licenses": [
"MIT"
],
"repository": "https://github.com/jzaefferer/jquery-validation",
"homepage": "http://jqueryvalidation.org/"
},
"html2canvas@0.4.1": {
"licenses": [
"MIT"
],
"homepage": "https://github.com/niklasvh/html2canvas",
"repository": "git+ssh://git@github.com/niklasvh/html2canvas"
},
"jasny-bootstrap@3.1.3": {
"licenses": [
"Apache-2.0",
"Apache*"
],
"homepage": "https://github.com/jasny/bootstrap",
"repository": "git+https://github.com/jasny/bootstrap"
},
"bootstrap-daterangepicker@2.1.24": {
"licenses": [
"MIT"
],
"homepage": "https://github.com/dangrossman/bootstrap-daterangepicker",
"repository": "git+https://github.com/dangrossman/bootstrap-daterangepicker"
},
"jspdf-autotable@2.0.14": {
"licenses": [
"MIT"
],
"homepage": "https://github.com/simonbengtsson/jspdf-autotable",
"repository": "git+https://github.com/simonbengtsson/jsPDF-AutoTable"
},
"bootstrap-table@undefined": {
"licenses": [
@@ -133,26 +154,11 @@
"homepage": "http://getbootstrap.com",
"repository": "git+https://github.com/twbs/bootstrap"
},
"html2canvas@0.4.1": {
"chartist-plugin-barlabels@0.0.5": {
"licenses": [
"MIT"
"WTF*"
],
"homepage": "https://github.com/niklasvh/html2canvas",
"repository": "git+ssh://git@github.com/niklasvh/html2canvas"
},
"jspdf-autotable@2.0.14": {
"licenses": [
"MIT"
],
"homepage": "https://github.com/simonbengtsson/jspdf-autotable",
"repository": "git+https://github.com/simonbengtsson/jsPDF-AutoTable"
},
"bootstrap-daterangepicker@2.1.24": {
"licenses": [
"MIT"
],
"homepage": "https://github.com/dangrossman/bootstrap-daterangepicker",
"repository": "git+https://github.com/dangrossman/bootstrap-daterangepicker"
"homepage": "https://github.com/mtgibbs/chartist-plugin-barlabels"
},
"jquery-ui@1.11.4": {
"licenses": [

View File

@@ -1 +0,0 @@
<?php echo phpinfo();