CHANGELOG.txt | 24 +
TODO.txt | 5
config/settings/general.ini | 1
config/users/admin.ini | 8
config/users/guest.ini | 8
config/users/index.html | 10
db-update.txt | 6
system/application/assets/css/admin-style.css | 16
system/application/assets/css/printreport.css | 27 +
system/application/assets/css/style.css | 18
system/application/assets/css/tables.css | 26 +
system/application/assets/images/icons/ajax.gif |binary
system/application/config/config.php | 10
system/application/controllers/admin/create.php | 6
system/application/controllers/admin/initialize.sql | 4
system/application/controllers/admin/manage.php | 24 -
system/application/controllers/admin/schema.sql | 3
system/application/controllers/admin/setting.php | 16
system/application/controllers/admin/status.php | 4
system/application/controllers/admin/user.php | 387 ++++++++++++++++++
system/application/controllers/admin/welcome.php | 132 ------
system/application/controllers/group.php | 78 ++-
system/application/controllers/ledger.php | 117 ++++-
system/application/controllers/log.php | 42 --
system/application/controllers/report.php | 415 ++++++++++++++++----
system/application/controllers/setting.php | 74 ++-
system/application/controllers/tag.php | 65 ++-
system/application/controllers/user.php | 115 ++---
system/application/controllers/voucher.php | 231 ++++++-----
system/application/controllers/welcome.php | 7
system/application/helpers/MY_date_helper.php | 8
system/application/helpers/MY_form_helper.php | 2
system/application/libraries/General.php | 176 ++++++++
system/application/libraries/Logger.php | 17
system/application/libraries/MY_Form_validation.php | 44 +-
system/application/libraries/Startup.php | 114 -----
system/application/libraries/Statuscheck.php | 38 +
system/application/models/group_model.php | 9
system/application/models/ledger_model.php | 124 +++++
system/application/models/setting_model.php | 3
system/application/models/tag_model.php | 27 -
system/application/models/voucher_model.php | 24 -
system/application/views/admin/manage/index.php | 5
system/application/views/admin/setting.php | 4
system/application/views/admin/user/add.php | 45 ++
system/application/views/admin/user/edit.php | 45 ++
system/application/views/admin/user/index.php | 76 +++
system/application/views/admin/welcome.php | 12
system/application/views/admin_template.php | 38 +
system/application/views/help/index.php | 18
system/application/views/ledger/add.php | 14
system/application/views/ledger/edit.php | 14
system/application/views/log/index.php | 8
system/application/views/report/ledgerst.php | 74 ---
system/application/views/report/profitandloss.php | 12
system/application/views/report/reconciliation.php | 195 +++++++++
system/application/views/setting/account.php | 7
system/application/views/tag/index.php | 3
system/application/views/template.php | 34 -
system/application/views/user/login.php | 4
system/application/views/user/profile.php | 27 +
system/application/views/user_template.php | 4
system/application/views/voucher/add.php | 15
system/application/views/voucher/edit.php | 10
system/application/views/voucher/view.php | 5
system/application/views/welcome.php | 13
todo.txt | 5
67 files changed, 2366 insertions(+), 786 deletions(-)
New commits:
commit 1d6a0d373a6be20e57ec555b25748cb7ce23c2cc
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sat Jan 22 19:38:43 2011 +0530
Updated CHANGELOG.txt
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 9bee40a..577d262 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,3 +1,8 @@
+Webzash Version 1.0 2011-01-22
+------------------------------
+
+ * Code refactoring
+
Webzash Version 1.0-beta3 2011-01-19
------------------------------------
commit 5d983ddcbb6301e933a2ec129dc4f631a94d93bc
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sat Jan 22 11:28:28 2011 +0530
Updated user selection of accounts
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/admin/user.php b/system/application/controllers/admin/user.php
index 8b0a592..40558e9 100644
--- a/system/application/controllers/admin/user.php
+++ b/system/application/controllers/admin/user.php
@@ -84,11 +84,10 @@ class User extends Controller {
$data['user_status'] = TRUE;
/* Accounts Form fields */
- $data['accounts_all'] = TRUE;
- $data['accounts_active'] = array();
+ $data['accounts_active'] = array('(All Accounts)');
/* Getting list of files in the config - accounts directory */
$accounts_list = get_filenames($this->config->item('config_path') . 'accounts');
- $data['accounts'] = array();
+ $data['accounts'] = array('(All Accounts)' => '(All Accounts)');
if ($accounts_list)
{
foreach ($accounts_list as $row)
@@ -110,7 +109,6 @@ class User extends Controller {
$data['user_email']['value'] = $this->input->post('user_email', TRUE);
$data['active_user_role'] = $this->input->post('user_role', TRUE);
$data['user_status'] = $this->input->post('user_status', TRUE);
- $data['accounts_all'] = $this->input->post('accounts_all', TRUE);
$data['accounts_active'] = $this->input->post('accounts', TRUE);
}
@@ -120,7 +118,6 @@ class User extends Controller {
$this->form_validation->set_rules('user_email', 'Email', 'trim|required|valid_email');
$this->form_validation->set_rules('user_role', 'Role', 'trim|required');
$this->form_validation->set_rules('user_status', 'Active', 'trim');
- $this->form_validation->set_rules('accounts_all', 'All Accounts', 'trim');
/* Validating form */
if ($this->form_validation->run() == FALSE)
@@ -140,20 +137,19 @@ class User extends Controller {
$data_user_status = 1;
else
$data_user_status = 0;
- $data_accounts_all = $this->input->post('accounts_all', TRUE);
$data_accounts = $this->input->post('accounts', TRUE);
/* Forming account querry string */
$data_accounts_string = '';
- if ($data_accounts_all == 1)
+ if ( ! $data_accounts)
{
- $data_accounts_string = '*';
+ $this->messages->add('Please select account.', 'error');
+ $this->template->load('admin_template', 'admin/user/add', $data);
+ return;
} else {
- if ( ! $data_accounts)
+ if (in_array('(All Accounts)', $data_accounts))
{
- $this->messages->add('Please select account.', 'error');
- $this->template->load('admin_template', 'admin/user/add', $data);
- return;
+ $data_accounts_string = '*';
} else {
/* Filtering out bogus accounts */
$data_accounts_valid = array_intersect($data['accounts'], $data_accounts);
@@ -226,11 +222,10 @@ class User extends Controller {
$data['user_status'] = TRUE;
/* Accounts Form fields */
- $data['accounts_all'] = TRUE;
- $data['accounts_active'] = array();
+ $data['accounts_active'] = array('(All Accounts)');
/* Getting list of files in the config - accounts directory */
$accounts_list = get_filenames($this->config->item('config_path') . 'accounts');
- $data['accounts'] = array();
+ $data['accounts'] = array('(All Accounts)' => '(All Accounts)');
if ($accounts_list)
{
foreach ($accounts_list as $row)
@@ -251,7 +246,6 @@ class User extends Controller {
$data['user_email']['value'] = $this->input->post('user_email', TRUE);
$data['active_user_role'] = $this->input->post('user_role', TRUE);
$data['user_status'] = $this->input->post('user_status', TRUE);
- $data['accounts_all'] = $this->input->post('accounts_all', TRUE);
$data['accounts_active'] = $this->input->post('accounts', TRUE);
} else {
/* Check if user ini file exists */
@@ -297,10 +291,8 @@ class User extends Controller {
{
if ($active_users['accounts'] == "*")
{
- $data['accounts_all'] = TRUE;
- $data['accounts_active'] = array();
+ $data['accounts_active'] = array('(All Accounts)');
} else {
- $data['accounts_all'] = FALSE;
$data['accounts_active'] = explode(",", $active_users['accounts']);
}
} else {
@@ -315,7 +307,6 @@ class User extends Controller {
$this->form_validation->set_rules('user_email', 'Email', 'trim|required|valid_email');
$this->form_validation->set_rules('user_role', 'Role', 'trim|required');
$this->form_validation->set_rules('user_status', 'Active', 'trim');
- $this->form_validation->set_rules('accounts_all', 'All Accounts', 'trim');
/* Validating form */
if ($this->form_validation->run() == FALSE)
@@ -334,20 +325,19 @@ class User extends Controller {
$data_user_status = 1;
else
$data_user_status = 0;
- $data_accounts_all = $this->input->post('accounts_all', TRUE);
$data_accounts = $this->input->post('accounts', TRUE);
/* Forming account querry string */
$data_accounts_string = '';
- if ($data_accounts_all == 1)
+ if ( ! $data_accounts)
{
- $data_accounts_string = '*';
+ $this->messages->add('Please select account.', 'error');
+ $this->template->load('admin_template', 'admin/user/edit', $data);
+ return;
} else {
- if ( ! $data_accounts)
+ if (in_array('(All Accounts)', $data_accounts))
{
- $this->messages->add('Please select account.', 'error');
- $this->template->load('admin_template', 'admin/user/edit', $data);
- return;
+ $data_accounts_string = '*';
} else {
/* Filtering out bogus accounts */
$data_accounts_valid = array_intersect($data['accounts'], $data_accounts);
diff --git a/system/application/views/admin/user/add.php b/system/application/views/admin/user/add.php
index e456a3e..874dbb0 100644
--- a/system/application/views/admin/user/add.php
+++ b/system/application/views/admin/user/add.php
@@ -30,7 +30,7 @@
echo "</p>";
echo "<p>";
- echo form_checkbox('accounts_all', 1, $accounts_all) . " All Accounts or Select accounts";
+ echo form_label('Select accounts', 'accounts[]');
echo "<br />";
echo form_multiselect('accounts[]', $accounts, $accounts_active);
echo "</p>";
diff --git a/system/application/views/admin/user/edit.php b/system/application/views/admin/user/edit.php
index 6956333..458a4e1 100644
--- a/system/application/views/admin/user/edit.php
+++ b/system/application/views/admin/user/edit.php
@@ -30,7 +30,7 @@
echo "</p>";
echo "<p>";
- echo form_checkbox('accounts_all', 1, $accounts_all) . " All Accounts or Select accounts";
+ echo form_label('Select accounts', 'accounts[]');
echo "<br />";
echo form_multiselect('accounts[]', $accounts, $accounts_active);
echo "</p>";
commit d5f94b5d3ee274a90c136c797ee982d57650bc71
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Jan 21 18:40:56 2011 +0530
Moved user file check to separate library
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/user.php b/system/application/controllers/user.php
index e9b2890..410170c 100644
--- a/system/application/controllers/user.php
+++ b/system/application/controllers/user.php
@@ -10,6 +10,7 @@ class User extends Controller {
function login()
{
$this->template->set('page_title', 'Login');
+ $this->load->library('general');
/* If user already logged in then redirect to profile page */
if ($this->session->userdata('user_name'))
@@ -53,75 +54,36 @@ class User extends Controller {
$data_user_name = $this->input->post('user_name', TRUE);
$data_user_password = $this->input->post('user_password', TRUE);
- /* User validation */
- $ini_file = $this->config->item('config_path') . "users/" . $data_user_name . ".ini";
-
- /* Check if user ini file exists */
- if ( ! get_file_info($ini_file))
+ /* Check user ini file */
+ if ( ! $active_user = $this->general->check_user($data_user_name))
{
- $this->messages->add('User does not exists.', 'error');
$this->template->load('user_template', 'user/login', $data);
return;
- } else {
- /* Parsing user ini file */
- $active_users = parse_ini_file($ini_file);
- if ( ! $active_users)
- {
- $this->messages->add('Invalid user file.', 'error');
- $this->template->load('user_template', 'user/login', $data);
- return;
- } else {
- /* Status check */
- if (isset($active_users['status']))
- {
- if ($active_users['status'] != 1)
- {
- $this->messages->add('User disabled.', 'error');
- $this->template->load('user_template', 'user/login', $data);
- return;
- }
- } else {
- $this->messages->add('Invalid status.', 'error');
- $this->template->load('user_template', 'user/login', $data);
- return;
- }
-
- /* Password check */
- if (isset($active_users['password']))
- {
- $password = $active_users['password'];
+ }
- /* Role check */
- if (isset($active_users['role']))
- {
- $data_user_role = $active_users['role'];
- } else {
- $this->messages->add('Invalid role. Defaulting to "guest" role.', 'success');
- $data_user_role = 'guest';
- }
+ /* Check user status */
+ if ($active_user['status'] != 1)
+ {
+ $this->messages->add('User disabled.', 'error');
+ $this->template->load('user_template', 'user/login', $data);
+ return;
+ }
- /* Password verify */
- if ($password == $data_user_password)
- {
- $this->messages->add('Logged in as ' . $data_user_name . '.', 'success');
- $this->session->set_userdata('user_name', $data_user_name);
- $this->session->set_userdata('user_role', $data_user_role);
- redirect('');
- return;
- } else {
- $this->session->unset_userdata('user_name');
- $this->session->unset_userdata('user_role');
- $this->session->unset_userdata('active_account');
- $this->messages->add('Authentication failed.', 'error');
- $this->template->load('user_template', 'user/login', $data);
- return;
- }
- } else {
- $this->messages->add('Password missing from user file.', 'error');
- $this->template->load('user_template', 'user/login', $data);
- return;
- }
- }
+ /* Password verify */
+ if ($active_user['password'] == $data_user_password)
+ {
+ $this->messages->add('Logged in as ' . $data_user_name . '.', 'success');
+ $this->session->set_userdata('user_name', $data_user_name);
+ $this->session->set_userdata('user_role', $active_user['role']);
+ redirect('');
+ return;
+ } else {
+ $this->session->unset_userdata('user_name');
+ $this->session->unset_userdata('user_role');
+ $this->session->unset_userdata('active_account');
+ $this->messages->add('Authentication failed.', 'error');
+ $this->template->load('user_template', 'user/login', $data);
+ return;
}
}
return;
@@ -159,9 +121,6 @@ class User extends Controller {
/* Currently active account */
$data['active_account'] = $this->session->userdata('active_account');
- /* User validation */
- $ini_file = $this->config->item('config_path') . "users/" . $this->session->userdata('user_name') . ".ini";
-
/* Getting list of files in the config - accounts directory */
$accounts_list = get_filenames($this->config->item('config_path') . 'accounts');
$data['accounts'] = array();
@@ -178,35 +137,18 @@ class User extends Controller {
}
}
- /* Check if user ini file exists */
- if ( ! get_file_info($ini_file))
+ /* Check user ini file */
+ if ( ! $active_user = $this->general->check_user($this->session->userdata('user_name')))
{
- $this->messages->add('User does not exists.', 'error');
redirect('user/profile');
return;
- } else {
- /* Parsing user ini file */
- $active_users = parse_ini_file($ini_file);
- if ( ! $active_users)
- {
- $this->messages->add('Invalid user file.', 'error');
- redirect('user/profile');
- return;
- } else {
- /* Account check */
- if (isset($active_users['accounts']))
- {
- if ($active_users['accounts'] != '*')
- {
- $valid_accounts = explode(",", $active_users['accounts']);
- $data['accounts'] = array_intersect($data['accounts'], $valid_accounts);
- }
- } else {
- $this->messages->add('Invalid accounts in user file.', 'error');
- redirect('user/profile');
- return;
- }
- }
+ }
+
+ /* Filter user access to accounts */
+ if ($active_user['accounts'] != '*')
+ {
+ $valid_accounts = explode(",", $active_user['accounts']);
+ $data['accounts'] = array_intersect($data['accounts'], $valid_accounts);
}
/* Form validations */
diff --git a/system/application/libraries/General.php b/system/application/libraries/General.php
index 20e9f5c..b581273 100644
--- a/system/application/libraries/General.php
+++ b/system/application/libraries/General.php
@@ -121,6 +121,55 @@ class General {
}
}
}
+
+ function check_user($user_name)
+ {
+ $CI =& get_instance();
+
+ /* User validation */
+ $ini_file = $CI->config->item('config_path') . "users/" . $user_name . ".ini";
+
+ /* Check if user ini file exists */
+ if ( ! get_file_info($ini_file))
+ {
+ $CI->messages->add('User does not exists.', 'error');
+ return FALSE;
+ }
+
+ /* Parsing user ini file */
+ $user_data = parse_ini_file($ini_file);
+ if ( ! $user_data)
+ {
+ $CI->messages->add('Invalid user file.', 'error');
+ return FALSE;
+ }
+
+ if ( ! isset($user_data['username']))
+ {
+ $CI->messages->add('Username missing from user file.', 'error');
+ return FALSE;
+ }
+ if ( ! isset($user_data['password']))
+ {
+ $CI->messages->add('Password missing from user file.', 'error');
+ return FALSE;
+ }
+ if ( ! isset($user_data['status']))
+ {
+ $CI->messages->add('Status missing from user file.', 'error');
+ return FALSE;
+ }
+ if ( ! isset($user_data['role']))
+ {
+ $CI->messages->add('Role missing from user file. Defaulting to "guest" role.', 'error');
+ $user_data['role'] = 'guest';
+ }
+ if ( ! isset($user_data['accounts']))
+ {
+ $CI->messages->add('Accounts missing from user file.', 'error');
+ }
+ return $user_data;
+ }
}
/* End of file General.php */
commit aa424f9a20ea0db0805e249e137ccc112b2acc52
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Jan 21 17:36:14 2011 +0530
Moved account file check to separate library
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/user.php b/system/application/controllers/user.php
index 9867c07..e9b2890 100644
--- a/system/application/controllers/user.php
+++ b/system/application/controllers/user.php
@@ -140,6 +140,7 @@ class User extends Controller {
function account()
{
$this->template->set('page_title', 'Change Account');
+ $this->load->library('general');
/* Show manage accounts links if user has permission */
if (check_access('administer'))
@@ -234,60 +235,15 @@ class User extends Controller {
return;
}
- $ini_file = $this->config->item('config_path') . "accounts/" . $data_active_account . ".ini";
-
- /* Check if database ini file exists */
- if ( ! get_file_info($ini_file))
- {
- $this->messages->add('Account settings file is missing.', 'error');
- $this->template->load('user_template', 'user/account', $data);
- return;
- }
-
- /* Parsing database ini file */
- $current_account = parse_ini_file($ini_file);
- if ( ! $current_account)
- {
- $this->messages->add('Invalid account settings file.', 'error');
- $this->template->load('user_template', 'user/account', $data);
- return;
- }
-
- /* Check if all needed variables are set in ini file */
- if ( ! isset($current_account['db_hostname']))
- {
- $this->messages->add('Hostname missing from account settings file.', 'error');
- $this->template->load('user_template', 'user/account', $data);
- return;
- }
- if ( ! isset($current_account['db_port']))
- {
- $this->messages->add('Port missing from account settings file.', 'error');
- $this->template->load('user_template', 'user/account', $data);
- return;
- }
- if ( ! isset($current_account['db_name']))
- {
- $this->messages->add('Database name missing from account settings file.', 'error');
- $this->template->load('user_template', 'user/account', $data);
- return;
- }
- if ( ! isset($current_account['db_username']))
- {
- $this->messages->add('Database username missing from account settings file.', 'error');
- $this->template->load('user_template', 'user/account', $data);
- return;
- }
- if ( ! isset($current_account['db_password']))
+ if ( ! $this->general->check_account($data_active_account))
{
- $this->messages->add('Database password missing from account settings file.', 'error');
$this->template->load('user_template', 'user/account', $data);
return;
}
/* Setting new account database details in session */
$this->session->set_userdata('active_account', $data_active_account);
- $this->messages->add('Active account changed.', 'success');
+ $this->messages->add('Account changed.', 'success');
redirect('');
}
return;
diff --git a/system/application/libraries/General.php b/system/application/libraries/General.php
new file mode 100644
index 0000000..20e9f5c
--- /dev/null
+++ b/system/application/libraries/General.php
@@ -0,0 +1,127 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+class General {
+ var $error_messages = array();
+
+ function General()
+ {
+ return;
+ }
+
+ /* Check format of config/accounts ini files */
+ function check_account($account_name)
+ {
+ $CI =& get_instance();
+
+ $ini_file = $CI->config->item('config_path') . "accounts/" . $account_name . ".ini";
+
+ /* Check if database ini file exists */
+ if ( ! get_file_info($ini_file))
+ {
+ $CI->messages->add('Account settings file is missing.', 'error');
+ return FALSE;
+ }
+
+ /* Parsing database ini file */
+ $account_data = parse_ini_file($ini_file);
+ if ( ! $account_data)
+ {
+ $CI->messages->add('Invalid account settings.', 'error');
+ return FALSE;
+ }
+
+ /* Check if all needed variables are set in ini file */
+ if ( ! isset($account_data['db_hostname']))
+ {
+ $CI->messages->add('Hostname missing from account settings file.', 'error');
+ return FALSE;
+ }
+ if ( ! isset($account_data['db_port']))
+ {
+ $CI->messages->add('Port missing from account setting file. Default MySQL port is 3306.', 'error');
+ return FALSE;
+ }
+ if ( ! isset($account_data['db_name']))
+ {
+ $CI->messages->add('Database name missing from account setting file.', 'error');
+ return FALSE;
+ }
+ if ( ! isset($account_data['db_username']))
+ {
+ $CI->messages->add('Database username missing from account setting file.', 'error');
+ return FALSE;
+ }
+ if ( ! isset($account_data['db_password']))
+ {
+ $CI->messages->add('Database password missing from account setting file.', 'error');
+ return FALSE;
+ }
+ return $account_data;
+ }
+
+ /* Check for valid account database */
+ function check_database()
+ {
+ $CI =& get_instance();
+
+ /* Checking for valid database connection */
+ if ($CI->db->conn_id)
+ {
+ /* Checking for valid database name, username, password */
+ if ($CI->db->query("SHOW TABLES"))
+ {
+ /* Check for valid webzash database */
+ $table_names = array('groups', 'ledgers', 'vouchers', 'voucher_items', 'tags', 'logs', 'settings');
+ foreach ($table_names as $id => $tbname)
+ {
+ $valid_db_q = mysql_query('DESC ' . $tbname);
+ if ( ! $valid_db_q)
+ {
+ $CI->messages->add('Invalid account database. Table "' . $tbname . '" missing.', 'error');
+ return FALSE;
+ }
+ }
+ } else {
+ $CI->messages->add('Invalid database connection settings. Check whether the provided database name, username and password are valid.', 'error');
+ return FALSE;
+ }
+ } else {
+ $CI->messages->add('Cannot connect to database server. Check whether database server is running.', 'error');
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /* Check config/settings/general.ini file */
+ function check_setting()
+ {
+ $CI =& get_instance();
+
+ $setting_ini_file = $CI->config->item('config_path') . "settings/general.ini";
+
+ /* Set default values */
+ $CI->config->set_item('row_count', "20");
+ $CI->config->set_item('log', "1");
+
+ /* Check if general application settings ini file exists */
+ if (get_file_info($setting_ini_file))
+ {
+ /* Parsing general application settings ini file */
+ $cur_setting = parse_ini_file($setting_ini_file);
+ if ($cur_setting)
+ {
+ if (isset($cur_setting['row_count']))
+ {
+ $CI->config->set_item('row_count', $cur_setting['row_count']);
+ }
+ if (isset($cur_setting['log']))
+ {
+ $CI->config->set_item('log', $cur_setting['log']);
+ }
+ }
+ }
+ }
+}
+
+/* End of file General.php */
+/* Location: ./system/application/libraries/General.php */
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index 7b6a36a..2700873 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -14,6 +14,7 @@ class Startup
{
$CI =& get_instance();
$CI->db->trans_strict(FALSE);
+ $CI->load->library('general');
/* Skip checking if accessing admin section*/
if ($CI->uri->segment(1) == "admin")
@@ -33,65 +34,20 @@ class Startup
/* Reading database settings ini file */
if ($CI->session->userdata('active_account'))
{
- /* Fetching database label details from session */
- $current_account = $CI->session->userdata('active_account');
- $ini_file = $CI->config->item('config_path') . "accounts/" . $current_account . ".ini";
-
- /* Check if database ini file exists */
- if ( ! get_file_info($ini_file))
- {
- $CI->messages->add('Account settings file is missing.', 'error');
- redirect('admin');
- return;
- }
-
- /* Parsing database ini file */
- $active_accounts = parse_ini_file($ini_file);
- if ( ! $active_accounts)
- {
- $CI->messages->add('Invalid account settings.', 'error');
- redirect('admin');
- return;
- }
-
- /* Check if all needed variables are set in ini file */
- if ( ! isset($active_accounts['db_hostname']))
- {
- $CI->messages->add('Hostname missing from account settings file.', 'error');
- redirect('admin');
- return;
- }
- if ( ! isset($active_accounts['db_port']))
- {
- $CI->messages->add('Port missing from account setting file. Default MySQL port is 3306.', 'error');
- redirect('admin');
- return;
- }
- if ( ! isset($active_accounts['db_name']))
- {
- $CI->messages->add('Database name missing from account setting file.', 'error');
- redirect('admin');
- return;
- }
- if ( ! isset($active_accounts['db_username']))
- {
- $CI->messages->add('Database username missing from account setting file.', 'error');
- redirect('admin');
- return;
- }
- if ( ! isset($active_accounts['db_password']))
+ /* Fetching database label details from session and checking the database ini file */
+ if ( ! $active_account = $CI->general->check_account($CI->session->userdata('active_account')))
{
- $CI->messages->add('Database password missing from account setting file.', 'error');
- redirect('admin');
+ $CI->session->unset_userdata('active_account');
+ redirect('user/account');
return;
}
/* Preparing database settings */
- $db_config['hostname'] = $active_accounts['db_hostname'];
- $db_config['hostname'] .= ":" . $active_accounts['db_port'];
- $db_config['database'] = $active_accounts['db_name'];
- $db_config['username'] = $active_accounts['db_username'];
- $db_config['password'] = $active_accounts['db_password'];
+ $db_config['hostname'] = $active_account['db_hostname'];
+ $db_config['hostname'] .= ":" . $active_account['db_port'];
+ $db_config['database'] = $active_account['db_name'];
+ $db_config['username'] = $active_account['db_username'];
+ $db_config['password'] = $active_account['db_password'];
$db_config['dbdriver'] = "mysql";
$db_config['dbprefix'] = "";
$db_config['pconnect'] = FALSE;
@@ -108,31 +64,10 @@ class Startup
}
/* Checking for valid database connection */
- if ($CI->db->conn_id)
+ if ( ! $CI->general->check_database())
{
- /* Checking for valid database name, username, password */
- if ($CI->db->query("SHOW TABLES"))
- {
- /* Check for valid webzash database */
- $table_names = array('groups', 'ledgers', 'vouchers', 'voucher_items', 'tags', 'logs', 'settings');
- foreach ($table_names as $id => $tbname)
- {
- $valid_db_q = mysql_query('DESC ' . $tbname);
- if ( ! $valid_db_q)
- {
- $CI->messages->add('Invalid account database. Table "' . $tbname . '" missing.', 'error');
- redirect('admin');
- return;
- }
- }
- } else {
- $CI->messages->add('Invalid database connection settings. Check whether the provided database name, username and password are valid.', 'error');
- redirect('admin');
- return;
- }
- } else {
- $CI->messages->add('Cannot connect to database server. Check whether database server is running.', 'error');
- redirect('admin');
+ $CI->session->unset_userdata('active_account');
+ redirect('user/account');
return;
}
@@ -141,7 +76,8 @@ class Startup
if ( ! ($account_d = $account_q->row()))
{
$CI->messages->add('Invalid account settings.', 'error');
- redirect('admin');
+ redirect('user/account');
+ return;
}
$CI->config->set_item('account_name', $account_d->name);
$CI->config->set_item('account_address', $account_d->address);
@@ -158,27 +94,9 @@ class Startup
$CI->config->set_item('account_journal_prefix', $account_d->journal_voucher_prefix);
$CI->config->set_item('account_database_version', $account_d->database_version);
- /************** Load general application settings *************/
- $setting_ini_file = $CI->config->item('config_path') . "settings/general.ini";
- $CI->config->set_item('row_count', 20);
+ /* Load general application settings */
+ $CI->general->check_setting();
- /* Check if general application settings ini file exists */
- if (get_file_info($setting_ini_file))
- {
- /* Parsing general application settings ini file */
- $cur_setting = parse_ini_file($setting_ini_file);
- if ($cur_setting)
- {
- if (isset($cur_setting['row_count']))
- {
- $CI->config->set_item('row_count', $cur_setting['row_count']);
- }
- if (isset($cur_setting['log']))
- {
- $CI->config->set_item('log', $cur_setting['log']);
- }
- }
- }
return;
}
}
commit 14cb66bae9943c788315630ca540b65c7d217a40
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 19 17:32:53 2011 +0530
Updated CHANGELOG.txt
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 7e1e346..9bee40a 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,3 +1,8 @@
+Webzash Version 1.0-beta3 2011-01-19
+------------------------------------
+
+ * Reconciliation
+
Webzash Version 1.0-beta2 2011-01-12
------------------------------------
commit cce3994998f18b4604dbd3d951c7d3369280e050
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 19 16:56:32 2011 +0530
Fixed styling issues
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/views/template.php b/system/application/views/template.php
index 30d4e9a..aff4f43 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -51,7 +51,9 @@ $(document).ready(function() {
maxWidth:27,
extraWidth: 1
}).superfish(); // call supersubs first, then superfish, so that subs are
- $('.datepicker').datepick({dateFormat: '<?php echo $this->config->item('account_date_format'); ?>'});
+ $('.datepicker').datepick({
+ dateFormat: '<?php echo $this->config->item('account_date_format'); ?>',
+ });
$('.datepicker-restrict').datepick({
dateFormat: '<?php echo $this->config->item('account_date_format'); ?>',
minDate: '<?php echo date_mysql_to_php($this->config->item('account_fy_start')); ?>',
commit a6b1d590e19889756071536119de5d83b4f699e6
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 19 16:41:47 2011 +0530
Fixed styling issues
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/assets/css/admin-style.css b/system/application/assets/css/admin-style.css
index a8ce886..a76da31 100644
--- a/system/application/assets/css/admin-style.css
+++ b/system/application/assets/css/admin-style.css
@@ -55,7 +55,7 @@ body {
#content #main #main-title {
font-size:19px;
- padding:10px 0 10px 0;
+ padding:8px 0 8px 0;
}
#content #main #main-content {
@@ -115,24 +115,30 @@ body {
border:solid 1px #787878;
background:#F0F0F0;
color:#222222;
- margin:10px 0 10px 0;
+ margin:5px 0 12px 0px;
text-align:left;
+ display:block;
+ padding-right:20px;
}
#error-box {
border:solid 1px #C34A2C;
background:#FFBABA;
color:#222222;
- margin:10px 0 10px 0;
+ margin:5px 0 12px 0px;
text-align:left;
+ display:block;
+ padding-right:20px;
}
#success-box {
border:solid 1px #FFEC8B;
background:#FFF8C6;
color:#222222;
- margin:10px 0 10px 0;
+ margin:5px 0 12px 0px;
text-align:left;
+ display:block;
+ padding-right:20px;
}
/* COMMON */
diff --git a/system/application/assets/css/style.css b/system/application/assets/css/style.css
index 05026a9..31bb9ff 100644
--- a/system/application/assets/css/style.css
+++ b/system/application/assets/css/style.css
@@ -68,7 +68,7 @@ body {
#content #main #main-title {
font-size:19px;
- padding:10px 0 10px 0;
+ padding:8px 0 8px 0;
}
#content #main #main-content {
@@ -121,24 +121,30 @@ body {
border:solid 1px #787878;
background:#F0F0F0;
color:#222222;
- margin:10px 0 10px 0;
+ margin:5px 0 12px 0px;
text-align:left;
+ display:block;
+ padding-right:20px;
}
#error-box {
border:solid 1px #C34A2C;
background:#FFBABA;
color:#222222;
- margin:10px 0 10px 0;
+ margin:5px 0 12px 0px;
text-align:left;
+ display:block;
+ padding-right:20px;
}
#success-box {
border:solid 1px #FFEC8B;
background:#FFF8C6;
color:#222222;
- margin:10px 0 10px 0;
+ margin:5px 0 12px 0px;
text-align:left;
+ display:block;
+ padding-right:20px;
}
/* COMMON */
diff --git a/system/application/views/admin_template.php b/system/application/views/admin_template.php
index 12a93e1..d6c86d9 100644
--- a/system/application/views/admin_template.php
+++ b/system/application/views/admin_template.php
@@ -64,15 +64,15 @@ $(document).ready(function(){
<div id="main-title">
<?php if (isset($page_title)) echo $page_title; ?>
</div>
- <div id="main-links">
- <?php if (isset($nav_links)) {
- echo "<ul id=\"main-links-nav\">";
- foreach ($nav_links as $link => $title) {
- echo "<li>" . anchor($link, $title, array('title' => $title, 'class' => 'nav-links-item', 'style' => 'background-image:url(\'' . asset_url() . 'images/buttons/navlink.png\');')) . "</li>";
- }
- echo "</ul>";
- } ?>
- </div>
+ <?php if (isset($nav_links)) {
+ echo "<div id=\"main-links\">";
+ echo "<ul id=\"main-links-nav\">";
+ foreach ($nav_links as $link => $title) {
+ echo "<li>" . anchor($link, $title, array('title' => $title, 'class' => 'nav-links-item', 'style' => 'background-image:url(\'' . asset_url() . 'images/buttons/navlink.png\');')) . "</li>";
+ }
+ echo "</ul>";
+ echo "</div>";
+ } ?>
<div class="clear">
</div>
<div id="main-content">
diff --git a/system/application/views/template.php b/system/application/views/template.php
index f3d31f2..30d4e9a 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -140,18 +140,18 @@ $(document).ready(function() {
<div id="main-title">
<?php if (isset($page_title)) echo $page_title; ?>
</div>
- <div id="main-links">
- <?php if (isset($nav_links)) {
- echo "<ul id=\"main-links-nav\">";
- foreach ($nav_links as $link => $title) {
- if ($title == "Print Preview")
- echo "<li>" . anchor_popup($link, $title, array('title' => $title, 'class' => 'nav-links-item', 'style' => 'background-image:url(\'' . asset_url() . 'images/buttons/navlink.png\');', 'width' => '1024')) . "</li>";
- else
- echo "<li>" . anchor($link, $title, array('title' => $title, 'class' => 'nav-links-item', 'style' => 'background-image:url(\'' . asset_url() . 'images/buttons/navlink.png\');')) . "</li>";
- }
- echo "</ul>";
- } ?>
- </div>
+ <?php if (isset($nav_links)) {
+ echo "<div id=\"main-links\">";
+ echo "<ul id=\"main-links-nav\">";
+ foreach ($nav_links as $link => $title) {
+ if ($title == "Print Preview")
+ echo "<li>" . anchor_popup($link, $title, array('title' => $title, 'class' => 'nav-links-item', 'style' => 'background-image:url(\'' . asset_url() . 'images/buttons/navlink.png\');', 'width' => '1024')) . "</li>";
+ else
+ echo "<li>" . anchor($link, $title, array('title' => $title, 'class' => 'nav-links-item', 'style' => 'background-image:url(\'' . asset_url() . 'images/buttons/navlink.png\');')) . "</li>";
+ }
+ echo "</ul>";
+ echo "</div>";
+ } ?>
<div class="clear">
</div>
<div id="main-content">
commit a9ee2c0dd5b1b76be1a5d69a8f7d93d3135c58c4
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 19 10:32:22 2011 +0530
Notify user of previous reconciliations on voucher update
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/voucher.php b/system/application/controllers/voucher.php
index 824a6cb..2602ac2 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -650,6 +650,7 @@ class Voucher extends Controller {
$data['voucher_download'] = FALSE;
$data['voucher_tag'] = $cur_voucher->tag_id;
$data['voucher_tags'] = $this->Tag_model->get_all_tags();
+ $data['has_reconciliation'] = FALSE;
/* Load current ledger details if not $_POST */
if ( ! $_POST)
@@ -673,6 +674,8 @@ class Voucher extends Controller {
$data['dr_amount'][$counter] = "";
$data['cr_amount'][$counter] = $row->amount;
}
+ if ($row->reconciliation_date)
+ $data['has_reconciliation'] = TRUE;
$counter++;
}
/* Two extra rows */
@@ -714,6 +717,7 @@ class Voucher extends Controller {
$data['voucher_email'] = $this->input->post('voucher_email', TRUE);
$data['voucher_download'] = $this->input->post('voucher_download', TRUE);
$data['voucher_tag'] = $this->input->post('voucher_tag', TRUE);
+ $data['has_reconciliation'] = $this->input->post('has_reconciliation', TRUE);
$data['ledger_dc'] = $this->input->post('ledger_dc', TRUE);
$data['ledger_id'] = $this->input->post('ledger_id', TRUE);
@@ -830,6 +834,7 @@ class Voucher extends Controller {
case "journal": $data_type = 4; break;
}
$data_date = date_php_to_mysql($data_date); // Converting date to MySQL
+ $data_has_reconciliation = $this->input->post('has_reconciliation', TRUE);
$this->db->trans_start();
$update_data = array(
@@ -942,6 +947,10 @@ class Voucher extends Controller {
$this->messages->add('Updated ' . ucfirst($voucher_type) . ' Voucher number ' . voucher_number_prefix($voucher_type) . $data_number . ". " . $voucher_success_links, 'success');
$this->logger->write_message("success", "Updated " . ucfirst($voucher_type) . " Voucher number " . voucher_number_prefix($voucher_type) . $data_number . " [id:" . $voucher_id . "]");
+
+ if ($data_has_reconciliation)
+ $this->messages->add('Previous reconciliations for this voucher are no longer valid. You need to redo the reconciliations for this voucher.', 'success');
+
redirect('voucher/show/' . $voucher_type);
return;
}
diff --git a/system/application/views/voucher/edit.php b/system/application/views/voucher/edit.php
index c063ff0..0cda23a 100644
--- a/system/application/views/voucher/edit.php
+++ b/system/application/views/voucher/edit.php
@@ -280,6 +280,8 @@ $(document).ready(function() {
echo form_dropdown('voucher_tag', $voucher_tags, $voucher_tag);
echo "</p>";
+ echo form_hidden('has_reconciliation', $has_reconciliation);
+
echo "<p>";
echo form_submit('submit', 'Update');
echo " ";
commit 6cfeb538e20d750c8a33ba057080ab9e7f879cc2
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 18 12:18:23 2011 +0530
Added ajax loading image for adding ledger row in vouchers
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/assets/images/icons/ajax.gif b/system/application/assets/images/icons/ajax.gif
new file mode 100644
index 0000000..f2a1bc0
Binary files /dev/null and b/system/application/assets/images/icons/ajax.gif differ
diff --git a/system/application/views/voucher/add.php b/system/application/views/voucher/add.php
index bc1dbd9..030c740 100644
--- a/system/application/views/voucher/add.php
+++ b/system/application/views/voucher/add.php
@@ -173,10 +173,13 @@ $(document).ready(function() {
/* Add ledger row */
$('table td .addrow').live('click', function() {
var cur_obj = this;
+ var add_image_url = $(cur_obj).attr('src');
+ $(cur_obj).attr('src', <?php echo '\'' . asset_url() . 'images/icons/ajax.gif' . '\''; ?>);
$.ajax({
url: <?php echo '\'' . site_url('voucher/addrow/' . $add_type) . '\''; ?>,
success: function(data) {
$(cur_obj).parent().parent().after(data);
+ $(cur_obj).attr('src', add_image_url);
}
});
});
diff --git a/system/application/views/voucher/edit.php b/system/application/views/voucher/edit.php
index a8aedc1..c063ff0 100644
--- a/system/application/views/voucher/edit.php
+++ b/system/application/views/voucher/edit.php
@@ -173,10 +173,13 @@ $(document).ready(function() {
/* Add ledger row */
$('table td .addrow').live('click', function() {
var cur_obj = this;
+ var add_image_url = $(cur_obj).attr('src');
+ $(cur_obj).attr('src', <?php echo '\'' . asset_url() . 'images/icons/ajax.gif' . '\''; ?>);
$.ajax({
url: <?php echo '\'' . site_url('voucher/addrow/' . $add_type) . '\''; ?>,
success: function(data) {
$(cur_obj).parent().parent().after(data);
+ $(cur_obj).attr('src', add_image_url);
}
});
});
commit 3fb9cde842166002ce967323a0d4cf2835cf60ab
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 18 11:09:54 2011 +0530
Comment out the buggy error message and add it to TODO
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/voucher.php b/system/application/controllers/voucher.php
index 7ae1cdc..824a6cb 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -59,7 +59,7 @@ class Voucher extends Controller {
$data['voucher_type'] = "";
break;
default :
- $this->messages->add('Invalid Voucher type(1).', 'error');
+ /* TODO $this->messages->add('Invalid Voucher type(1).', 'error'); */
redirect('voucher/show/all');
return;
break;
commit 81c6282e85a210fdb81b46fb90c778f9bed0a454
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 18 11:04:44 2011 +0530
Added download csv for reconciliation statement
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/report.php b/system/application/controllers/report.php
index 990d8c6..c02ce68 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -109,12 +109,12 @@ class Report extends Controller {
$data['reconciliation_type'] = 'all';
$data['show_all'] = TRUE;
if ($ledger_id > 0)
- $this->template->set('nav_links', array('report/printpreview/reconciliation/' . $ledger_id . '/all' => 'Print Preview'));
+ $this->template->set('nav_links', array('report/download/reconciliation/' . $ledger_id . '/all' => 'Download CSV', 'report/printpreview/reconciliation/' . $ledger_id . '/all' => 'Print Preview'));
} else if ($reconciliation_type == 'pending') {
$data['reconciliation_type'] = 'pending';
$data['show_all'] = FALSE;
if ($ledger_id > 0)
- $this->template->set('nav_links', array('report/printpreview/reconciliation/' . $ledger_id . '/pending' => 'Print Preview'));
+ $this->template->set('nav_links', array('report/download/reconciliation/' . $ledger_id . '/pending' => 'Download CSV', 'report/printpreview/reconciliation/' . $ledger_id . '/pending' => 'Print Preview'));
} else {
$this->messages->add('Invalid path.', 'error');
redirect('report/reconciliation/pending');
@@ -430,6 +430,139 @@ class Report extends Controller {
echo array_to_csv($ledgerst, "ledgerst.csv");
return;
}
+
+ /********************** RECONCILIATION ************************/
+ if ($statement == "reconciliation")
+ {
+ $ledger_id = (int)$this->uri->segment(4);
+ $reconciliation_type = $this->uri->segment(5);
+
+ if ($ledger_id < 1)
+ return;
+ if ( ! (($reconciliation_type == 'all') or ($reconciliation_type == 'pending')))
+ return;
+
+ $this->load->model('Ledger_model');
+ $cur_balance = 0;
+ $counter = 0;
+ $ledgerst = array();
+
+ $ledgerst[$counter] = array ("", "", "RECONCILIATION STATEMENT FOR " . strtoupper($this->Ledger_model->get_name($ledger_id)), "", "", "", "", "", "", "", "");
+ $counter++;
+ $ledgerst[$counter] = array ("", "", "FY " . date_mysql_to_php($this->config->item('account_fy_start')) . " - " . date_mysql_to_php($this->config->item('account_fy_end')), "", "", "", "", "", "", "", "");
+ $counter++;
+
+ $ledgerst[$counter][0]= "Date";
+ $ledgerst[$counter][1]= "Number";
+ $ledgerst[$counter][2]= "Ledger Name";
+ $ledgerst[$counter][4]= "Type";
+ $ledgerst[$counter][5]= "";
+ $ledgerst[$counter][6]= "Dr Amount";
+ $ledgerst[$counter][7]= "";
+ $ledgerst[$counter][8]= "Cr Amount";
+ $ledgerst[$counter][9]= "Reconciliation Date";
+ $counter++;
+
+ /* Opening Balance */
+ list ($opbalance, $optype) = $this->Ledger_model->get_op_balance($ledger_id);
+
+ $this->db->select('vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc, voucher_items.reconciliation_date as lreconciliation');
+ if ($reconciliation_type == 'all')
+ $this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->order_by('vouchers.date', 'asc')->order_by('vouchers.number', 'asc');
+ else
+ $this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->where('voucher_items.reconciliation_date', NULL)->order_by('vouchers.date', 'asc')->order_by('vouchers.number', 'asc');
+ $ledgerst_q = $this->db->get();
+ foreach ($ledgerst_q->result() as $row)
+ {
+ $ledgerst[$counter][0] = date_mysql_to_php($row->vdate);
+ $ledgerst[$counter][1] = voucher_number_prefix(n_to_v($row->vtype)) . $row->vnumber;
+
+ /* Opposite voucher name */
+ $ledgerst[$counter][2] = $this->Ledger_model->get_opp_ledger_name($row->vid, $row->vtype, $row->ldc, 'text');
+
+ $ledgerst[$counter][3] = ucfirst(n_to_v($row->vtype));
+
+ if ($row->ldc == "D")
+ {
+ $ledgerst[$counter][4] = convert_dc($row->ldc);
+ $ledgerst[$counter][5] = $row->lamount;
+ $ledgerst[$counter][6] = "";
+ $ledgerst[$counter][7] = "";
+
+ } else {
+ $ledgerst[$counter][4] = "";
+ $ledgerst[$counter][5] = "";
+ $ledgerst[$counter][6] = convert_dc($row->ldc);
+ $ledgerst[$counter][7] = $row->lamount;
+ }
+
+ if ($row->lreconciliation)
+ {
+ $ledgerst[$counter][8] = date_mysql_to_php($row->lreconciliation);
+ } else {
+ $ledgerst[$counter][8] = "";
+ }
+ $counter++;
+ }
+
+ $counter++;
+ $ledgerst[$counter] = array ("", "", "", "", "", "", "", "", "", "");
+ $counter++;
+
+ /* Final Opening and Closing Balance */
+ $clbalance = $this->Ledger_model->get_ledger_balance($ledger_id);
+
+ $ledgerst[$counter] = array ("Opening Balance", convert_dc($optype), $opbalance, "", "", "", "", "", "", "");
+ $counter++;
+
+ if ($clbalance == 0)
+ $ledgerst[$counter] = array ("Closing Balance", "", 0, "", "", "", "", "", "", "");
+ else if ($clbalance < 0)
+ $ledgerst[$counter] = array ("Closing Balance", "Cr", convert_cur(-$clbalance), "", "", "", "", "", "", "");
+ else
+ $ledgerst[$counter] = array ("Closing Balance", "Dr", convert_cur($clbalance), "", "", "", "", "", "", "");
+
+ /************* Final Reconciliation Balance ***********/
+
+ /* Reconciliation Balance - Dr */
+ $this->db->select_sum('amount', 'drtotal')->from('voucher_items')->join('vouchers', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->where('voucher_items.dc', 'D')->where('voucher_items.reconciliation_date IS NOT NULL');
+ $dr_total_q = $this->db->get();
+ if ($dr_total = $dr_total_q->row())
+ $reconciliation_dr_total = $dr_total->drtotal;
+ else
+ $reconciliation_dr_total = 0;
+
+ /* Reconciliation Balance - Cr */
+ $this->db->select_sum('amount', 'crtotal')->from('voucher_items')->join('vouchers', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->where('voucher_items.dc', 'C')->where('voucher_items.reconciliation_date IS NOT NULL');
+ $cr_total_q = $this->db->get();
+ if ($cr_total = $cr_total_q->row())
+ $reconciliation_cr_total = $cr_total->crtotal;
+ else
+ $reconciliation_cr_total = 0;
+
+ $reconciliation_total = $reconciliation_dr_total - $reconciliation_cr_total;
+ $reconciliation_pending = $clbalance - $reconciliation_total;
+
+ $counter++;
+ if ($reconciliation_pending == 0)
+ $ledgerst[$counter] = array ("Reconciliation Pending", "", 0, "", "", "", "", "", "", "");
+ else if ($reconciliation_pending < 0)
+ $ledgerst[$counter] = array ("Reconciliation Pending", "Cr", convert_cur(-$reconciliation_pending), "", "", "", "", "", "", "");
+ else
+ $ledgerst[$counter] = array ("Reconciliation Pending", "Dr", convert_cur($reconciliation_pending), "", "", "", "", "", "", "");
+
+ $counter++;
+ if ($reconciliation_total == 0)
+ $ledgerst[$counter] = array ("Reconciliation Total", "", 0, "", "", "", "", "", "", "");
+ else if ($reconciliation_total < 0)
+ $ledgerst[$counter] = array ("Reconciliation Total", "Cr", convert_cur(-$reconciliation_total), "", "", "", "", "", "", "");
+ else
+ $ledgerst[$counter] = array ("Reconciliation Total", "Dr", convert_cur($reconciliation_total), "", "", "", "", "", "", "");
+
+ $this->load->helper('csv');
+ echo array_to_csv($ledgerst, "reconciliation.csv");
+ return;
+ }
/************************ BALANCE SHEET ***********************/
if ($statement == "balancesheet")
commit 3a5f575d66d2b9ca7169ad6193970a05185c7239
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 17 11:50:19 2011 +0530
Renamed some initial groups
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/admin/initialize.sql b/system/application/controllers/admin/initialize.sql
index 3cfce90..2e5f8f3 100644
--- a/system/application/controllers/admin/initialize.sql
+++ b/system/application/controllers/admin/initialize.sql
@@ -2,8 +2,8 @@ INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (1, 0, 'Assets',
INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (2, 0, 'Liabilities', 0);
INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (3, 0, 'Incomes', 0);
INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (4, 0, 'Expenses', 0);
-INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (5, 1, 'Fixed assets', 0);
-INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (6, 1, 'Current assets', 0);
+INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (5, 1, 'Fixed Assets', 0);
+INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (6, 1, 'Current Assets', 0);
INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (7, 1, 'Investments', 0);
INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (8, 2, 'Capital A/C', 0);
INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (9, 2, 'Current Liabilities', 0);
commit 305d91ea4aad95195ae808efedd97adb140ae3c2
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 17 11:33:43 2011 +0530
Added application version
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/config/config.php b/system/application/config/config.php
index 96245f0..265cbf0 100644
--- a/system/application/config/config.php
+++ b/system/application/config/config.php
@@ -368,5 +368,15 @@ $config['config_path'] = 'config/';
*/
$config['backup_path'] = 'backups/';
+/*
+|--------------------------------------------------------------------------
+| Custom : Application Version
+|--------------------------------------------------------------------------
+|
+| Sets the current application version
+|
+*/
+$config['application_version'] = '1.0-beta3';
+
/* End of file config.php */
/* Location: ./system/application/config/config.php */
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index 2ea8b30..7b6a36a 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -156,6 +156,7 @@ class Startup
$CI->config->set_item('account_payment_prefix', $account_d->payment_voucher_prefix);
$CI->config->set_item('account_contra_prefix', $account_d->contra_voucher_prefix);
$CI->config->set_item('account_journal_prefix', $account_d->journal_voucher_prefix);
+ $CI->config->set_item('account_database_version', $account_d->database_version);
/************** Load general application settings *************/
$setting_ini_file = $CI->config->item('config_path') . "settings/general.ini";
diff --git a/system/application/views/user/profile.php b/system/application/views/user/profile.php
index f17c4b6..d74793c 100644
--- a/system/application/views/user/profile.php
+++ b/system/application/views/user/profile.php
@@ -21,3 +21,7 @@
echo anchor('user/account', 'Change', array('title' => 'Change Account', 'class' => 'anchor-link-a'));
echo ")";
echo "</p>";
+
+ echo "<p>";
+ echo "Application version is: " . "<strong>" . $this->config->item('application_version') . "</strong>";
+ echo "</p>";
commit 64baa65a136df4b4d107294a9244554d6754207f
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 17 11:18:05 2011 +0530
Updated opposite voucher name as Ledger model method
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/report.php b/system/application/controllers/report.php
index 4248f49..990d8c6 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -358,35 +358,7 @@ class Report extends Controller {
$ledgerst[$counter][1] = voucher_number_prefix(n_to_v($row->vtype)) . $row->vnumber;
/* Opposite voucher name */
- if ($row->ldc == "D")
- {
- $this->db->from('voucher_items')->where('voucher_id', $row->vid)->where('dc', 'C');
- $opp_voucher_name_q = $this->db->get();
- if ($opp_voucher_name_d = $opp_voucher_name_q->row())
- {
- $opp_ledger_name = $this->Ledger_model->get_name($opp_voucher_name_d->ledger_id);
- if ($opp_voucher_name_q->num_rows() > 1)
- {
- $ledgerst[$counter][2] = "(" . $opp_ledger_name . ")";
- } else {
- $ledgerst[$counter][2] = $opp_ledger_name;
- }
- }
- } else {
- $this->db->from('voucher_items')->where('voucher_id', $row->vid)->where('dc', 'D');
- $opp_voucher_name_q = $this->db->get();
- if ($opp_voucher_name_d = $opp_voucher_name_q->row())
- {
- $opp_ledger_name = $this->Ledger_model->get_name($opp_voucher_name_d->ledger_id);
- if ($opp_voucher_name_q->num_rows() > 1)
- {
- $ledgerst[$counter][2] = "(" . $opp_ledger_name . ")";
- } else {
- $ledgerst[$counter][2] = $opp_ledger_name;
- }
- }
-
- }
+ $ledgerst[$counter][2] = $this->Ledger_model->get_opp_ledger_name($row->vid, $row->vtype, $row->ldc, 'text');
$ledgerst[$counter][3] = ucfirst(n_to_v($row->vtype));
diff --git a/system/application/models/ledger_model.php b/system/application/models/ledger_model.php
index 029c903..ec1bea2 100644
--- a/system/application/models/ledger_model.php
+++ b/system/application/models/ledger_model.php
@@ -94,6 +94,34 @@ class Ledger_model extends Model {
return;
}
+ function get_opp_ledger_name($voucher_id, $voucher_type, $ledger_type, $output_type)
+ {
+ $output = '';
+ if ($ledger_type == 'D')
+ $opp_ledger_type = 'C';
+ else
+ $opp_ledger_type = 'D';
+ $this->db->from('voucher_items')->where('voucher_id', $voucher_id)->where('dc', $opp_ledger_type);
+ $opp_voucher_name_q = $this->db->get();
+ if ($opp_voucher_name_d = $opp_voucher_name_q->row())
+ {
+ $opp_ledger_name = $this->get_name($opp_voucher_name_d->ledger_id);
+ if ($opp_voucher_name_q->num_rows() > 1)
+ {
+ if ($output_type == 'html')
+ $output = anchor('voucher/view/' . n_to_v($voucher_type) . '/' . $voucher_id, "(" . $opp_ledger_name . ")", array('title' => 'View ' . ' Voucher', 'class' => 'anchor-link-a'));
+ else
+ $output = "(" . $opp_ledger_name . ")";
+ } else {
+ if ($output_type == 'html')
+ $output = anchor('voucher/view/' . n_to_v($voucher_type) . '/' . $voucher_id, $opp_ledger_name, array('title' => 'View ' . ' Voucher', 'class' => 'anchor-link-a'));
+ else
+ $output = $opp_ledger_name;
+ }
+ }
+ return $output;
+ }
+
function get_ledger_balance($ledger_id)
{
list ($op_bal, $op_bal_type) = $this->get_op_balance($ledger_id);
diff --git a/system/application/views/report/ledgerst.php b/system/application/views/report/ledgerst.php
index 4c0aa55..5c017a4 100644
--- a/system/application/views/report/ledgerst.php
+++ b/system/application/views/report/ledgerst.php
@@ -126,35 +126,7 @@
/* Getting opposite Ledger name */
echo "<td>";
- if ($row->ldc == "D")
- {
- $this->db->from('voucher_items')->where('voucher_id', $row->vid)->where('dc', 'C');
- $opp_voucher_name_q = $this->db->get();
- if ($opp_voucher_name_d = $opp_voucher_name_q->row())
- {
- $opp_ledger_name = $this->Ledger_model->get_name($opp_voucher_name_d->ledger_id);
- if ($opp_voucher_name_q->num_rows() > 1)
- {
- echo anchor('voucher/view/' . n_to_v($row->vtype) . '/' . $row->vid, "(" . $opp_ledger_name . ")", array('title' => 'View ' . ' Voucher', 'class' => 'anchor-link-a'));
- } else {
- echo anchor('voucher/view/' . n_to_v($row->vtype) . '/' . $row->vid, $opp_ledger_name, array('title' => 'View ' . ' Voucher', 'class' => 'anchor-link-a'));
- }
- }
- } else {
- $this->db->from('voucher_items')->where('voucher_id', $row->vid)->where('dc', 'D');
- $opp_voucher_name_q = $this->db->get();
- if ($opp_voucher_name_d = $opp_voucher_name_q->row())
- {
- $opp_ledger_name = $this->Ledger_model->get_name($opp_voucher_name_d->ledger_id);
- if ($opp_voucher_name_q->num_rows() > 1)
- {
- echo anchor('voucher/view/' . n_to_v($row->vtype) . '/' . $row->vid, "(" . $opp_ledger_name . ")", array('title' => 'View ' . ' Voucher', 'class' => 'anchor-link-a'));
- } else {
- echo anchor('voucher/view/' . n_to_v($row->vtype) . '/' . $row->vid, $opp_ledger_name, array('title' => 'View ' . ' Voucher', 'class' => 'anchor-link-a'));
- }
- }
-
- }
+ echo $this->Ledger_model->get_opp_ledger_name($row->vid, $row->vtype, $row->ldc, 'html');
echo "</td>";
echo "<td>";
diff --git a/system/application/views/report/reconciliation.php b/system/application/views/report/reconciliation.php
index e31c502..7fed6eb 100644
--- a/system/application/views/report/reconciliation.php
+++ b/system/application/views/report/reconciliation.php
@@ -133,35 +133,7 @@
/* Getting opposite Ledger name */
echo "<td>";
- if ($row->ldc == "D")
- {
- $this->db->from('voucher_items')->where('voucher_id', $row->vid)->where('dc', 'C');
- $opp_voucher_name_q = $this->db->get();
- if ($opp_voucher_name_d = $opp_voucher_name_q->row())
- {
- $opp_ledger_name = $this->Ledger_model->get_name($opp_voucher_name_d->ledger_id);
- if ($opp_voucher_name_q->num_rows() > 1)
- {
- echo anchor('voucher/view/' . n_to_v($row->vtype) . '/' . $row->vid, "(" . $opp_ledger_name . ")", array('title' => 'View ' . ' Voucher', 'class' => 'anchor-link-a'));
- } else {
- echo anchor('voucher/view/' . n_to_v($row->vtype) . '/' . $row->vid, $opp_ledger_name, array('title' => 'View ' . ' Voucher', 'class' => 'anchor-link-a'));
- }
- }
- } else {
- $this->db->from('voucher_items')->where('voucher_id', $row->vid)->where('dc', 'D');
- $opp_voucher_name_q = $this->db->get();
- if ($opp_voucher_name_d = $opp_voucher_name_q->row())
- {
- $opp_ledger_name = $this->Ledger_model->get_name($opp_voucher_name_d->ledger_id);
- if ($opp_voucher_name_q->num_rows() > 1)
- {
- echo anchor('voucher/view/' . n_to_v($row->vtype) . '/' . $row->vid, "(" . $opp_ledger_name . ")", array('title' => 'View ' . ' Voucher', 'class' => 'anchor-link-a'));
- } else {
- echo anchor('voucher/view/' . n_to_v($row->vtype) . '/' . $row->vid, $opp_ledger_name, array('title' => 'View ' . ' Voucher', 'class' => 'anchor-link-a'));
- }
- }
-
- }
+ echo $this->Ledger_model->get_opp_ledger_name($row->vid, $row->vtype, $row->ldc, 'html');
echo "</td>";
echo "<td>";
commit 6e182a84892022145c05a21f1a6b7a1364e07223
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 17 10:36:23 2011 +0530
Updated voucher name as Ledger model method
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/voucher.php b/system/application/controllers/voucher.php
index 78e082f..7ae1cdc 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -158,11 +158,7 @@ class Voucher extends Controller {
$html .= "<td>";
$html .= $this->Tag_model->show_voucher_tag($row->tag_id);
- if ($ledger)
- if ($ledger_multiple)
- $html .= anchor('voucher/view/' . strtolower($html_voucher_type) . "/" . $row->id, "(" . $ledger->name . ")", array('title' => 'View ' . ucfirst($html_voucher_type) . ' Voucher', 'class' => 'anchor-link-a'));
- else
- $html .= anchor('voucher/view/' . strtolower($html_voucher_type) . "/" . $row->id, $ledger->name, array('title' => 'View ' . ucfirst($html_voucher_type) . ' Voucher', 'class' => 'anchor-link-a'));
+ $html .= $this->Ledger_model->get_voucher_name($row->id, $row->type);
$html .= "</td>";
$html .= "<td>" . ucfirst($html_voucher_type) . "</td>";
diff --git a/system/application/models/ledger_model.php b/system/application/models/ledger_model.php
index f250a71..029c903 100644
--- a/system/application/models/ledger_model.php
+++ b/system/application/models/ledger_model.php
@@ -69,6 +69,31 @@ class Ledger_model extends Model {
return "(Error)";
}
+ function get_voucher_name($voucher_id, $voucher_type)
+ {
+ /* If receipt voucher (1) then select the credit ledger */
+ if ($voucher_type == 1)
+ $ledger_type = 'C';
+ else
+ $ledger_type = 'D';
+ $this->db->select('ledgers.name as name');
+ $this->db->from('voucher_items')->join('ledgers', 'voucher_items.ledger_id = ledgers.id')->where('voucher_items.voucher_id', $voucher_id)->where('voucher_items.dc', $ledger_type);
+ $ledger_q = $this->db->get();
+ if ( ! $ledger = $ledger_q->row())
+ {
+ return "(Invalid)";
+ } else {
+ $ledger_multiple = ($ledger_q->num_rows() > 1) ? TRUE : FALSE;
+ $html = '';
+ if ($ledger_multiple)
+ $html .= anchor('voucher/view/' . n_to_v($voucher_type) . "/" . $voucher_id, "(" . $ledger->name . ")", array('title' => 'View ' . ucfirst(n_to_v($voucher_type)) . ' Voucher', 'class' => 'anchor-link-a'));
+ else
+ $html .= anchor('voucher/view/' . n_to_v($voucher_type) . "/" . $voucher_id, $ledger->name, array('title' => 'View ' . ucfirst(n_to_v($voucher_type)) . ' Voucher', 'class' => 'anchor-link-a'));
+ return $html;
+ }
+ return;
+ }
+
function get_ledger_balance($ledger_id)
{
list ($op_bal, $op_bal_type) = $this->get_op_balance($ledger_id);
commit b6a5a5afc6e9e7fdada1ac348298b6d4c9c3fd67
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Jan 16 21:20:22 2011 +0530
Added Print Preview for reconciliation
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/assets/css/printreport.css b/system/application/assets/css/printreport.css
index 1c31462..237de9a 100644
--- a/system/application/assets/css/printreport.css
+++ b/system/application/assets/css/printreport.css
@@ -138,6 +138,33 @@ table.ledgerst-table td.td-group {
font-weight:bold;
}
+/**************************** RECONCILIATION ST *******************************/
+table.reconciliation-table {
+ border:1px solid #000000;
+ border-collapse: collapse;
+}
+
+table.reconciliation-table tr th {
+ text-align:left;
+ border:1px solid #000000;
+ padding:5px 30px 5px 5px;
+ background-color:#EEEEEE;
+}
+
+table.reconciliation-table tr td {
+ border:1px solid #000000;
+ padding:5px 30px 5px 5px;
+}
+
+table.reconciliation-total-table {
+ border:1px solid #000000;
+ background-color:#EEEEEE;
+}
+
+table.reconciliation-table .tr-reconcilied {
+ font-weight:bold;
+}
+
@media print {
.hide-print {
display: none;
diff --git a/system/application/controllers/report.php b/system/application/controllers/report.php
index 02d84fa..4248f49 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -108,9 +108,13 @@ class Report extends Controller {
{
$data['reconciliation_type'] = 'all';
$data['show_all'] = TRUE;
+ if ($ledger_id > 0)
+ $this->template->set('nav_links', array('report/printpreview/reconciliation/' . $ledger_id . '/all' => 'Print Preview'));
} else if ($reconciliation_type == 'pending') {
$data['reconciliation_type'] = 'pending';
$data['show_all'] = FALSE;
+ if ($ledger_id > 0)
+ $this->template->set('nav_links', array('report/printpreview/reconciliation/' . $ledger_id . '/pending' => 'Print Preview'));
} else {
$this->messages->add('Invalid path.', 'error');
redirect('report/reconciliation/pending');
@@ -756,6 +760,48 @@ class Report extends Controller {
$this->load->view('report/report_template', $data);
return;
}
+
+ if ($statement == "reconciliation")
+ {
+ $data['show_all'] = FALSE;
+ $data['ledger_id'] = $this->uri->segment(4);
+
+ /* Check if path is 'all' or 'pending' */
+ if ($this->uri->segment(5) == 'all')
+ {
+ $data['reconciliation_type'] = 'all';
+ $data['show_all'] = TRUE;
+ } else if ($this->uri->segment(5) == 'pending') {
+ $data['reconciliation_type'] = 'pending';
+ $data['show_all'] = FALSE;
+ } else {
+ $this->messages->add('Invalid path.', 'error');
+ redirect('report/reconciliation/pending');
+ return;
+ }
+
+ /* Checking for valid ledger id and reconciliation status */
+ if ($data['ledger_id'] > 0)
+ {
+ $this->db->from('ledgers')->where('id', $data['ledger_id'])->where('reconciliation', 1)->limit(1);
+ if ($this->db->get()->num_rows() < 1)
+ {
+ $this->messages->add('Invalid Ledger A/C or Reconciliation is not enabled for the Ledger A/C.', 'error');
+ redirect('report/reconciliation/' . $reconciliation_type);
+ return;
+ }
+ } else if ($data['ledger_id'] < 0) {
+ $this->messages->add('Invalid Ledger A/C.', 'error');
+ redirect('report/reconciliation/' . $reconciliation_type);
+ return;
+ }
+
+ $data['report'] = "report/reconciliation";
+ $data['title'] = "Reconciliation Statement for '" . $this->Ledger_model->get_name($data['ledger_id']) . "'";
+ $data['print_preview'] = TRUE;
+ $this->load->view('report/report_template', $data);
+ return;
+ }
return;
}
}
diff --git a/system/application/views/report/reconciliation.php b/system/application/views/report/reconciliation.php
index 3e214c7..e31c502 100644
--- a/system/application/views/report/reconciliation.php
+++ b/system/application/views/report/reconciliation.php
@@ -91,7 +91,8 @@
echo "</table>";
echo "<br />";
- if ( ! $print_preview) {
+ if ( ! $print_preview)
+ {
$this->db->select('vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.id as lid, voucher_items.amount as lamount, voucher_items.dc as ldc, voucher_items.reconciliation_date as lreconciliation');
if ($reconciliation_type == 'all')
$this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->order_by('vouchers.date', 'asc')->order_by('vouchers.number', 'asc')->limit($pagination_counter, $page_count);
@@ -101,11 +102,17 @@
} else {
$page_count = 0;
$this->db->select('vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.id as lid, voucher_items.amount as lamount, voucher_items.dc as ldc, voucher_items.reconciliation_date as lreconciliation');
- $this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->order_by('vouchers.date', 'asc')->order_by('vouchers.number', 'asc');
+ if ($reconciliation_type == 'all')
+ $this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->order_by('vouchers.date', 'asc')->order_by('vouchers.number', 'asc');
+ else
+ $this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->where('voucher_items.reconciliation_date', NULL)->order_by('vouchers.date', 'asc')->order_by('vouchers.number', 'asc');
$ledgerst_q = $this->db->get();
}
- echo form_open('report/reconciliation/' . $reconciliation_type . '/' . $ledger_id . "/" . $page_count);
+ if ( ! $print_preview)
+ {
+ echo form_open('report/reconciliation/' . $reconciliation_type . '/' . $ledger_id . "/" . $page_count);
+ }
echo "<table border=0 cellpadding=5 class=\"simple-table reconciliation-table\">";
echo "<thead><tr><th>Date</th><th>No.</th><th>Ledger Name</th><th>Type</th><th>Dr Amount</th><th>Cr Amount</th><th>Reconciliation Date</th></tr></thead>";
@@ -176,27 +183,39 @@
echo $row->lamount;
echo "</td>";
}
+
echo "<td>";
- $reconciliation_date = array(
- 'name' => 'reconciliation_date[' . $row->lid . ']',
- 'id' => 'reconciliation_date',
- 'maxlength' => '11',
- 'size' => '11',
- 'value' => '',
- );
- if ($row->lreconciliation)
- $reconciliation_date['value'] = date_mysql_to_php($row->lreconciliation);
- echo form_input_date_restrict($reconciliation_date);
+ if ( ! $print_preview)
+ {
+ $reconciliation_date = array(
+ 'name' => 'reconciliation_date[' . $row->lid . ']',
+ 'id' => 'reconciliation_date',
+ 'maxlength' => '11',
+ 'size' => '11',
+ 'value' => '',
+ );
+ if ($row->lreconciliation)
+ $reconciliation_date['value'] = date_mysql_to_php($row->lreconciliation);
+ echo form_input_date_restrict($reconciliation_date);
+ } else {
+ if ($row->lreconciliation)
+ echo date_mysql_to_php($row->lreconciliation);
+ else
+ echo "-";
+ }
echo "</td>";
echo "</tr>";
$odd_even = ($odd_even == "odd") ? "even" : "odd";
}
echo "</table>";
- echo "<p>";
- echo form_submit('submit', 'Update');
- echo "</p>";
- echo form_close();
+ if ( ! $print_preview)
+ {
+ echo "<p>";
+ echo form_submit('submit', 'Update');
+ echo "</p>";
+ echo form_close();
+ }
}
?>
<?php if ( ! $print_preview) { ?>
commit 9f1aec3a9bf68079e8a04c5ffd077cedd5331ab4
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Jan 16 14:52:52 2011 +0530
Updated reconciliation summary
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/views/report/reconciliation.php b/system/application/views/report/reconciliation.php
index e6de0bf..3e214c7 100644
--- a/system/application/views/report/reconciliation.php
+++ b/system/application/views/report/reconciliation.php
@@ -73,20 +73,20 @@
else
$reconciliation_cr_total = 0;
- $reconciliation_balance = $reconciliation_dr_total - $reconciliation_cr_total;
- $reconciliation_balance_pending = $clbalance - $reconciliation_balance;
+ $reconciliation_total = $reconciliation_dr_total - $reconciliation_cr_total;
+ $reconciliation_pending = $clbalance - $reconciliation_total;
/* Ledger and Reconciliation Summary */
echo "<table class=\"reconciliation-summary\">";
echo "<tr>";
echo "<td><b>Opening Balance</b></td><td>" . convert_opening($opbalance, $optype) . "</td>";
echo "<td width=\"20px\"></td>";
- echo "<td><b>Reconciliation Balance</b></td><td>" . convert_amount_dc($reconciliation_balance) . "</td>";
+ echo "<td><b>Reconciliation Pending</b></td><td>" . convert_amount_dc($reconciliation_pending) . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td><b>Closing Balance</b></td><td>" . convert_amount_dc($clbalance) . "</td>";
echo "<td width=\"20px\"></td>";
- echo "<td><b>Pending Reconciliation Balance</b></td><td>" . convert_amount_dc($reconciliation_balance_pending) . "</td>";
+ echo "<td><b>Reconciliation Total</b></td><td>" . convert_amount_dc($reconciliation_total) . "</td>";
echo "</tr>";
echo "</table>";
commit 9eceeb95b0415e9000b0623895f197bcbcec139d
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Jan 16 14:42:39 2011 +0530
Added Ledger account reconciliation
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/assets/css/tables.css b/system/application/assets/css/tables.css
index c20dc6b..6ebba75 100644
--- a/system/application/assets/css/tables.css
+++ b/system/application/assets/css/tables.css
@@ -203,6 +203,26 @@ tr.total-area {
padding: 8px 8px 8px 8px;
}
+.reconciliation-table .tr-reconciled {
+ background-color:#FFFFE6;
+}
+
+.reconciliation-summary {
+ font-size:14px;
+ border-collapse: collapse;
+ text-align: left;
+ border: 1px solid #BBBBBB;
+ background-color:#FFFFCC;
+}
+
+.reconciliation-summary tr {
+ border: 1px solid #BBBBBB;
+}
+
+.reconciliation-summary td {
+ padding: 8px 8px 8px 8px;
+}
+
.manage-account-table td {
padding-right: 20px;
}
diff --git a/system/application/controllers/report.php b/system/application/controllers/report.php
index cda73a4..02d84fa 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -135,6 +135,7 @@ class Report extends Controller {
if ($_POST)
{
+ /* Check if Ledger A/C is changed or reconciliation is updated */
if ($_POST['submit'] == 'Submit')
{
$ledger_id = $this->input->post('ledger_id', TRUE);
@@ -147,10 +148,53 @@ class Report extends Controller {
return;
}
} else if ($_POST['submit'] == 'Update') {
- $this->messages->add('Reconciliation updated.', 'success');
+
+ $data_reconciliation_date = $this->input->post('reconciliation_date', TRUE);
+
+ /* Form validations */
+ foreach ($data_reconciliation_date as $id => $row)
+ {
+ /* If reconciliation date is present then check for valid date else only trim */
+ if ($row)
+ $this->form_validation->set_rules('reconciliation_date[' . $id . ']', 'Reconciliation date', 'trim|required|is_date|is_date_within_range_reconcil');
+ else
+ $this->form_validation->set_rules('reconciliation_date[' . $id . ']', 'Reconciliation date', 'trim');
+ }
+
+ if ($this->form_validation->run() == FALSE)
+ {
+ $this->messages->add(validation_errors(), 'error');
+ $this->template->load('template', 'report/reconciliation', $data);
+ return;
+ } else {
+ /* Updating reconciliation date */
+ foreach ($data_reconciliation_date as $id => $row)
+ {
+ $this->db->trans_start();
+ if ($row)
+ {
+ $update_data = array(
+ 'reconciliation_date' => date_php_to_mysql($row),
+ );
+ } else {
+ $update_data = array(
+ 'reconciliation_date' => NULL,
+ );
+ }
+ if ( ! $this->db->where('id', $id)->update('voucher_items', $update_data))
+ {
+ $this->db->trans_rollback();
+ $this->messages->add('Error updating reconciliation.', 'error');
+ $this->logger->write_message("error", "Error updating reconciliation for voucher item [id:" . $id . "]");
+ } else {
+ $this->db->trans_complete();
+ }
+ }
+ $this->messages->add('Updated reconciliation.', 'success');
+ $this->logger->write_message("success", 'Updated reconciliation.');
+ }
}
}
-
$this->template->load('template', 'report/reconciliation', $data);
return;
}
diff --git a/system/application/views/report/reconciliation.php b/system/application/views/report/reconciliation.php
index 5fbc39d..e6de0bf 100644
--- a/system/application/views/report/reconciliation.php
+++ b/system/application/views/report/reconciliation.php
@@ -57,18 +57,42 @@
list ($opbalance, $optype) = $this->Ledger_model->get_op_balance($ledger_id); /* Opening Balance */
$clbalance = $this->Ledger_model->get_ledger_balance($ledger_id); /* Final Closing Balance */
- /* Ledger Summary */
- echo "<table class=\"ledger-summary\">";
+ /* Reconciliation Balance - Dr */
+ $this->db->select_sum('amount', 'drtotal')->from('voucher_items')->join('vouchers', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->where('voucher_items.dc', 'D')->where('voucher_items.reconciliation_date IS NOT NULL');
+ $dr_total_q = $this->db->get();
+ if ($dr_total = $dr_total_q->row())
+ $reconciliation_dr_total = $dr_total->drtotal;
+ else
+ $reconciliation_dr_total = 0;
+
+ /* Reconciliation Balance - Cr */
+ $this->db->select_sum('amount', 'crtotal')->from('voucher_items')->join('vouchers', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->where('voucher_items.dc', 'C')->where('voucher_items.reconciliation_date IS NOT NULL');
+ $cr_total_q = $this->db->get();
+ if ($cr_total = $cr_total_q->row())
+ $reconciliation_cr_total = $cr_total->crtotal;
+ else
+ $reconciliation_cr_total = 0;
+
+ $reconciliation_balance = $reconciliation_dr_total - $reconciliation_cr_total;
+ $reconciliation_balance_pending = $clbalance - $reconciliation_balance;
+
+ /* Ledger and Reconciliation Summary */
+ echo "<table class=\"reconciliation-summary\">";
echo "<tr>";
echo "<td><b>Opening Balance</b></td><td>" . convert_opening($opbalance, $optype) . "</td>";
+ echo "<td width=\"20px\"></td>";
+ echo "<td><b>Reconciliation Balance</b></td><td>" . convert_amount_dc($reconciliation_balance) . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td><b>Closing Balance</b></td><td>" . convert_amount_dc($clbalance) . "</td>";
+ echo "<td width=\"20px\"></td>";
+ echo "<td><b>Pending Reconciliation Balance</b></td><td>" . convert_amount_dc($reconciliation_balance_pending) . "</td>";
echo "</tr>";
echo "</table>";
+
echo "<br />";
if ( ! $print_preview) {
- $this->db->select('vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc, voucher_items.reconciliation_date as lreconciliation');
+ $this->db->select('vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.id as lid, voucher_items.amount as lamount, voucher_items.dc as ldc, voucher_items.reconciliation_date as lreconciliation');
if ($reconciliation_type == 'all')
$this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->order_by('vouchers.date', 'asc')->order_by('vouchers.number', 'asc')->limit($pagination_counter, $page_count);
else
@@ -76,13 +100,13 @@
$ledgerst_q = $this->db->get();
} else {
$page_count = 0;
- $this->db->select('vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc, voucher_items.reconciliation_date as lreconciliation');
+ $this->db->select('vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.id as lid, voucher_items.amount as lamount, voucher_items.dc as ldc, voucher_items.reconciliation_date as lreconciliation');
$this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->order_by('vouchers.date', 'asc')->order_by('vouchers.number', 'asc');
$ledgerst_q = $this->db->get();
}
- echo form_open('report/reconciliation/' . $ledger_id);
- echo "<table border=0 cellpadding=5 class=\"simple-table ledgerst-table\">";
+ echo form_open('report/reconciliation/' . $reconciliation_type . '/' . $ledger_id . "/" . $page_count);
+ echo "<table border=0 cellpadding=5 class=\"simple-table reconciliation-table\">";
echo "<thead><tr><th>Date</th><th>No.</th><th>Ledger Name</th><th>Type</th><th>Dr Amount</th><th>Cr Amount</th><th>Reconciliation Date</th></tr></thead>";
$odd_even = "odd";
@@ -91,7 +115,7 @@
{
echo "<tr class=\"tr-" . $odd_even;
if ($row->lreconciliation)
- echo " tr-group";
+ echo " tr-reconciled";
echo "\">";
echo "<td>";
echo date_mysql_to_php_display($row->vdate);
@@ -154,7 +178,7 @@
}
echo "<td>";
$reconciliation_date = array(
- 'name' => 'reconciliation_date[' . $row->vid . ']',
+ 'name' => 'reconciliation_date[' . $row->lid . ']',
'id' => 'reconciliation_date',
'maxlength' => '11',
'size' => '11',
commit 18e789c2562b991b74458d4cf5ee31535fd45ba4
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Jan 16 12:37:40 2011 +0530
Added custom date helpers and date validation for reconciliation
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/helpers/MY_date_helper.php b/system/application/helpers/MY_date_helper.php
index 2d982b6..532439b 100644
--- a/system/application/helpers/MY_date_helper.php
+++ b/system/application/helpers/MY_date_helper.php
@@ -80,6 +80,14 @@ if ( ! function_exists('date_mysql_to_php'))
}
}
+if ( ! function_exists('date_mysql_to_timestamp'))
+{
+ function date_mysql_to_timestamp($dt)
+ {
+ return strtotime($dt);
+ }
+}
+
if ( ! function_exists('date_mysql_to_php_display'))
{
function date_mysql_to_php_display($dt)
diff --git a/system/application/libraries/MY_Form_validation.php b/system/application/libraries/MY_Form_validation.php
index bf74495..08053dd 100644
--- a/system/application/libraries/MY_Form_validation.php
+++ b/system/application/libraries/MY_Form_validation.php
@@ -21,7 +21,7 @@ class MY_Form_validation extends CI_Form_validation {
$CI =& get_instance();
list ($table, $column) = explode('.', $field, 2);
- $CI->form_validation->set_message('unique', 'The %s that you requested is already in use');
+ $CI->form_validation->set_message('unique', 'The %s that you requested is already in use.');
$query = $CI->db->query("SELECT COUNT(*) AS dupe FROM $table WHERE $column = '$str'");
$row = $query->row();
@@ -32,7 +32,7 @@ class MY_Form_validation extends CI_Form_validation {
{
$CI =& get_instance();
- $CI->form_validation->set_message('uniquevoucherno', 'The %s that you requested is already in use');
+ $CI->form_validation->set_message('uniquevoucherno', 'The %s that you requested is already in use.');
$query = $CI->db->query("SELECT COUNT(*) AS dupe FROM vouchers WHERE number = ? AND type = ?", array((int)$str, (int)$type));
$row = $query->row();
@@ -44,7 +44,7 @@ class MY_Form_validation extends CI_Form_validation {
$CI =& get_instance();
list ($type, $id) = explode('.', $field, 2);
- $CI->form_validation->set_message('uniquevouchernowithid', 'The %s that you requested is already in use');
+ $CI->form_validation->set_message('uniquevouchernowithid', 'The %s that you requested is already in use.');
$query = $CI->db->query("SELECT COUNT(*) AS dupe FROM vouchers WHERE number = ? AND type = ? AND id != ?", array((int)$str, (int)$type, $id));
$row = $query->row();
@@ -56,7 +56,7 @@ class MY_Form_validation extends CI_Form_validation {
$CI =& get_instance();
list($table, $column, $id) = explode('.', $field, 3);
- $CI->form_validation->set_message('uniquewithid', 'The %s that you requested is already in use');
+ $CI->form_validation->set_message('uniquewithid', 'The %s that you requested is already in use.');
$query = $CI->db->query("SELECT COUNT(*) AS dupe FROM $table WHERE $column = '$str' AND id != ?", array($id));
$row = $query->row();
@@ -67,7 +67,7 @@ class MY_Form_validation extends CI_Form_validation {
{
$CI =& get_instance();
- $CI->form_validation->set_message('is_dc', '%s can only be "Dr" or "Cr"');
+ $CI->form_validation->set_message('is_dc', '%s can only be "Dr" or "Cr".');
return ($str == "D" || $str == "C") ? TRUE : FALSE;
}
@@ -76,7 +76,7 @@ class MY_Form_validation extends CI_Form_validation {
$CI =& get_instance();
if (preg_match('/^[\-]/', $str))
{
- $CI->form_validation->set_message('currency', '%s cannot be negative');
+ $CI->form_validation->set_message('currency', '%s cannot be negative.');
return FALSE;
}
@@ -84,7 +84,7 @@ class MY_Form_validation extends CI_Form_validation {
{
return TRUE;
} else {
- $CI->form_validation->set_message('currency', '%s must be a valid amount. Maximum 2 decimal places is allowed');
+ $CI->form_validation->set_message('currency', '%s must be a valid amount. Maximum 2 decimal places is allowed.');
return FALSE;
}
}
@@ -93,7 +93,7 @@ class MY_Form_validation extends CI_Form_validation {
{
$CI =& get_instance();
- $CI->form_validation->set_message('is_date', 'The %s is a invalid date');
+ $CI->form_validation->set_message('is_date', 'The %s is a invalid date.');
$current_date_format = $CI->config->item('account_date_format');
list($d, $m, $y) = array(0, 0, 0);
@@ -124,11 +124,33 @@ class MY_Form_validation extends CI_Form_validation {
if ($cur_date < $start_date)
{
- $CI->form_validation->set_message('is_date_within_range', 'The %s is less than start of current financial year');
+ $CI->form_validation->set_message('is_date_within_range', 'The %s is less than start of current financial year.');
return FALSE;
} else if ($cur_date > $end_date)
{
- $CI->form_validation->set_message('is_date_within_range', 'The %s is more than end of current financial year');
+ $CI->form_validation->set_message('is_date_within_range', 'The %s is more than end of current financial year.');
+ return FALSE;
+ } else {
+ return TRUE;
+ }
+ }
+
+ function is_date_within_range_reconcil($str)
+ {
+ $CI =& get_instance();
+ $cur_date = date_php_to_mysql($str);
+ $start_date = $CI->config->item('account_fy_start');
+ $end_date_orig = $CI->config->item('account_fy_end');
+ $end_date_ts = date_mysql_to_timestamp($end_date_orig);
+ $end_date = date("Y-m-d H:i:s", $end_date_ts + (30 * 24 * 60 * 60)); /* Adding one extra month for reconciliation */
+
+ if ($cur_date < $start_date)
+ {
+ $CI->form_validation->set_message('is_date_within_range_reconcil', 'The %s is less than start of current financial year.');
+ return FALSE;
+ } else if ($cur_date > $end_date)
+ {
+ $CI->form_validation->set_message('is_date_within_range_reconcil', 'The %s is more than end of current financial year plus one month.');
return FALSE;
} else {
return TRUE;
@@ -139,7 +161,7 @@ class MY_Form_validation extends CI_Form_validation {
{
$CI =& get_instance();
- $CI->form_validation->set_message('is_hex', 'The %s is a invalid value');
+ $CI->form_validation->set_message('is_hex', 'The %s is a invalid value.');
if (preg_match('/^[0-9A-Fa-f]*$/', $str))
return TRUE;
commit 6b718c656520cc63dd3bcea3de5b0404830dcc9b
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sat Jan 15 19:16:25 2011 +0530
Added basic reconciliation structure
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/report.php b/system/application/controllers/report.php
index 9230ef0..cda73a4 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -83,12 +83,78 @@ class Report extends Controller {
redirect('report/ledgerst');
return;
}
+ } else if ($data['ledger_id'] < 0) {
+ $this->messages->add('Invalid Ledger A/C.', 'error');
+ redirect('report/ledgerst');
+ return;
}
$this->template->load('template', 'report/ledgerst', $data);
return;
}
+ function reconciliation($reconciliation_type = '', $ledger_id = 0)
+ {
+ /* Pagination setup */
+ $this->load->library('pagination');
+
+ $this->template->set('page_title', 'Reconciliation');
+
+ /* Check if path is 'all' or 'pending' */
+ $data['show_all'] = FALSE;
+ $data['print_preview'] = FALSE;
+ $data['ledger_id'] = $ledger_id;
+ if ($reconciliation_type == 'all')
+ {
+ $data['reconciliation_type'] = 'all';
+ $data['show_all'] = TRUE;
+ } else if ($reconciliation_type == 'pending') {
+ $data['reconciliation_type'] = 'pending';
+ $data['show_all'] = FALSE;
+ } else {
+ $this->messages->add('Invalid path.', 'error');
+ redirect('report/reconciliation/pending');
+ return;
+ }
+
+ /* Checking for valid ledger id and reconciliation status */
+ if ($data['ledger_id'] > 0)
+ {
+ $this->db->from('ledgers')->where('id', $data['ledger_id'])->where('reconciliation', 1)->limit(1);
+ if ($this->db->get()->num_rows() < 1)
+ {
+ $this->messages->add('Invalid Ledger A/C or Reconciliation is not enabled for the Ledger A/C.', 'error');
+ redirect('report/reconciliation/' . $reconciliation_type);
+ return;
+ }
+ } else if ($data['ledger_id'] < 0) {
+ $this->messages->add('Invalid Ledger A/C.', 'error');
+ redirect('report/reconciliation/' . $reconciliation_type);
+ return;
+ }
+
+ if ($_POST)
+ {
+ if ($_POST['submit'] == 'Submit')
+ {
+ $ledger_id = $this->input->post('ledger_id', TRUE);
+ if ($this->input->post('show_all', TRUE))
+ {
+ redirect('report/reconciliation/all/' . $ledger_id);
+ return;
+ } else {
+ redirect('report/reconciliation/pending/' . $ledger_id);
+ return;
+ }
+ } else if ($_POST['submit'] == 'Update') {
+ $this->messages->add('Reconciliation updated.', 'success');
+ }
+ }
+
+ $this->template->load('template', 'report/reconciliation', $data);
+ return;
+ }
+
function download($statement, $id = NULL)
{
/********************** TRIAL BALANCE *************************/
diff --git a/system/application/views/report/reconciliation.php b/system/application/views/report/reconciliation.php
new file mode 100644
index 0000000..5fbc39d
--- /dev/null
+++ b/system/application/views/report/reconciliation.php
@@ -0,0 +1,180 @@
+<?php
+ $this->load->model('Ledger_model');
+ if ( ! $print_preview)
+ {
+ echo form_open('report/reconciliation/' . $reconciliation_type . '/' . $ledger_id);
+ echo "<p>";
+ echo form_input_ledger('ledger_id', $ledger_id, '', $type = 'reconciliation');
+ echo "</p>";
+ echo "<p>";
+ echo form_checkbox('show_all', 1, $show_all) . " Show All Vouchers";
+ echo "</p>";
+ echo "<p>";
+ echo form_submit('submit', 'Submit');
+ echo "</p>";
+ echo form_close();
+ }
+
+ /* Pagination configuration */
+ if ( ! $print_preview)
+ {
+ $pagination_counter = $this->config->item('row_count');
+ $page_count = (int)$this->uri->segment(5);
+ $page_count = $this->input->xss_clean($page_count);
+ if ( ! $page_count)
+ $page_count = "0";
+ $config['base_url'] = site_url('report/reconciliation/' . $reconciliation_type . '/' . $ledger_id);
+ $config['num_links'] = 10;
+ $config['per_page'] = $pagination_counter;
+ $config['uri_segment'] = 5;
+ if ($reconciliation_type == 'all')
+ $config['total_rows'] = (int)$this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->count_all_results();
+ else
+ $config['total_rows'] = (int)$this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->where('voucher_items.reconciliation_date', NULL)->count_all_results();
+ $config['full_tag_open'] = '<ul id="pagination-flickr">';
+ $config['full_close_open'] = '</ul>';
+ $config['num_tag_open'] = '<li>';
+ $config['num_tag_close'] = '</li>';
+ $config['cur_tag_open'] = '<li class="active">';
+ $config['cur_tag_close'] = '</li>';
+ $config['next_link'] = 'Next »';
+ $config['next_tag_open'] = '<li class="next">';
+ $config['next_tag_close'] = '</li>';
+ $config['prev_link'] = '« Previous';
+ $config['prev_tag_open'] = '<li class="previous">';
+ $config['prev_tag_close'] = '</li>';
+ $config['first_link'] = 'First';
+ $config['first_tag_open'] = '<li class="first">';
+ $config['first_tag_close'] = '</li>';
+ $config['last_link'] = 'Last';
+ $config['last_tag_open'] = '<li class="last">';
+ $config['last_tag_close'] = '</li>';
+ $this->pagination->initialize($config);
+ }
+
+ if ($ledger_id != 0)
+ {
+ list ($opbalance, $optype) = $this->Ledger_model->get_op_balance($ledger_id); /* Opening Balance */
+ $clbalance = $this->Ledger_model->get_ledger_balance($ledger_id); /* Final Closing Balance */
+
+ /* Ledger Summary */
+ echo "<table class=\"ledger-summary\">";
+ echo "<tr>";
+ echo "<td><b>Opening Balance</b></td><td>" . convert_opening($opbalance, $optype) . "</td>";
+ echo "</tr>";
+ echo "<tr>";
+ echo "<td><b>Closing Balance</b></td><td>" . convert_amount_dc($clbalance) . "</td>";
+ echo "</tr>";
+ echo "</table>";
+ echo "<br />";
+ if ( ! $print_preview) {
+ $this->db->select('vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc, voucher_items.reconciliation_date as lreconciliation');
+ if ($reconciliation_type == 'all')
+ $this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->order_by('vouchers.date', 'asc')->order_by('vouchers.number', 'asc')->limit($pagination_counter, $page_count);
+ else
+ $this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->where('voucher_items.reconciliation_date', NULL)->order_by('vouchers.date', 'asc')->order_by('vouchers.number', 'asc')->limit($pagination_counter, $page_count);
+ $ledgerst_q = $this->db->get();
+ } else {
+ $page_count = 0;
+ $this->db->select('vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc, voucher_items.reconciliation_date as lreconciliation');
+ $this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->order_by('vouchers.date', 'asc')->order_by('vouchers.number', 'asc');
+ $ledgerst_q = $this->db->get();
+ }
+
+ echo form_open('report/reconciliation/' . $ledger_id);
+ echo "<table border=0 cellpadding=5 class=\"simple-table ledgerst-table\">";
+
+ echo "<thead><tr><th>Date</th><th>No.</th><th>Ledger Name</th><th>Type</th><th>Dr Amount</th><th>Cr Amount</th><th>Reconciliation Date</th></tr></thead>";
+ $odd_even = "odd";
+
+ foreach ($ledgerst_q->result() as $row)
+ {
+ echo "<tr class=\"tr-" . $odd_even;
+ if ($row->lreconciliation)
+ echo " tr-group";
+ echo "\">";
+ echo "<td>";
+ echo date_mysql_to_php_display($row->vdate);
+ echo "</td>";
+ echo "<td>";
+ echo anchor('voucher/view/' . n_to_v($row->vtype) . '/' . $row->vid, voucher_number_prefix(n_to_v($row->vtype)) . $row->vnumber, array('title' => 'View ' . ' Voucher', 'class' => 'anchor-link-a'));
+ echo "</td>";
+
+ /* Getting opposite Ledger name */
+ echo "<td>";
+ if ($row->ldc == "D")
+ {
+ $this->db->from('voucher_items')->where('voucher_id', $row->vid)->where('dc', 'C');
+ $opp_voucher_name_q = $this->db->get();
+ if ($opp_voucher_name_d = $opp_voucher_name_q->row())
+ {
+ $opp_ledger_name = $this->Ledger_model->get_name($opp_voucher_name_d->ledger_id);
+ if ($opp_voucher_name_q->num_rows() > 1)
+ {
+ echo anchor('voucher/view/' . n_to_v($row->vtype) . '/' . $row->vid, "(" . $opp_ledger_name . ")", array('title' => 'View ' . ' Voucher', 'class' => 'anchor-link-a'));
+ } else {
+ echo anchor('voucher/view/' . n_to_v($row->vtype) . '/' . $row->vid, $opp_ledger_name, array('title' => 'View ' . ' Voucher', 'class' => 'anchor-link-a'));
+ }
+ }
+ } else {
+ $this->db->from('voucher_items')->where('voucher_id', $row->vid)->where('dc', 'D');
+ $opp_voucher_name_q = $this->db->get();
+ if ($opp_voucher_name_d = $opp_voucher_name_q->row())
+ {
+ $opp_ledger_name = $this->Ledger_model->get_name($opp_voucher_name_d->ledger_id);
+ if ($opp_voucher_name_q->num_rows() > 1)
+ {
+ echo anchor('voucher/view/' . n_to_v($row->vtype) . '/' . $row->vid, "(" . $opp_ledger_name . ")", array('title' => 'View ' . ' Voucher', 'class' => 'anchor-link-a'));
+ } else {
+ echo anchor('voucher/view/' . n_to_v($row->vtype) . '/' . $row->vid, $opp_ledger_name, array('title' => 'View ' . ' Voucher', 'class' => 'anchor-link-a'));
+ }
+ }
+
+ }
+ echo "</td>";
+
+ echo "<td>";
+ echo ucfirst(n_to_v($row->vtype));
+ echo "</td>";
+ if ($row->ldc == "D")
+ {
+ echo "<td>";
+ echo convert_dc($row->ldc);
+ echo " ";
+ echo $row->lamount;
+ echo "</td>";
+ echo "<td></td>";
+ } else {
+ echo "<td></td>";
+ echo "<td>";
+ echo convert_dc($row->ldc);
+ echo " ";
+ echo $row->lamount;
+ echo "</td>";
+ }
+ echo "<td>";
+ $reconciliation_date = array(
+ 'name' => 'reconciliation_date[' . $row->vid . ']',
+ 'id' => 'reconciliation_date',
+ 'maxlength' => '11',
+ 'size' => '11',
+ 'value' => '',
+ );
+ if ($row->lreconciliation)
+ $reconciliation_date['value'] = date_mysql_to_php($row->lreconciliation);
+ echo form_input_date_restrict($reconciliation_date);
+ echo "</td>";
+ echo "</tr>";
+ $odd_even = ($odd_even == "odd") ? "even" : "odd";
+ }
+
+ echo "</table>";
+ echo "<p>";
+ echo form_submit('submit', 'Update');
+ echo "</p>";
+ echo form_close();
+ }
+?>
+<?php if ( ! $print_preview) { ?>
+<div id="pagination-container"><?php echo $this->pagination->create_links(); ?></div>
+<?php } ?>
diff --git a/system/application/views/template.php b/system/application/views/template.php
index 5627f8c..f3d31f2 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -121,6 +121,7 @@ $(document).ready(function() {
<li><?php echo anchor('report/profitandloss', 'Profit & Loss', array('title' => 'Profit & Loss')); ?></li>
<li><?php echo anchor('report/trialbalance', 'Trial Balance', array('title' => 'Trial Balance')); ?></li>
<li><?php echo anchor('report/ledgerst', 'Ledger Statement', array('title' => 'Ledger Statement')); ?></li>
+ <li><?php echo anchor('report/reconciliation/pending', 'Reconciliation', array('title' => 'Reconciliation')); ?></li>
</ul>
</li>
<li>
commit 166a6119f28ee2ebca3f92b11b800e6aa2f54134
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sat Jan 15 18:09:29 2011 +0530
Added ledger model methods and form helpers for reconciliation
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/helpers/MY_form_helper.php b/system/application/helpers/MY_form_helper.php
index 06f7c39..786a38c 100644
--- a/system/application/helpers/MY_form_helper.php
+++ b/system/application/helpers/MY_form_helper.php
@@ -64,6 +64,8 @@ if ( ! function_exists('form_input_ledger'))
$options = $CI->Ledger_model->get_all_ledgers_bankcash();
else if ($type == 'nobankcash')
$options = $CI->Ledger_model->get_all_ledgers_nobankcash();
+ else if ($type == 'reconciliation')
+ $options = $CI->Ledger_model->get_all_ledgers_reconciliation();
else
$options = $CI->Ledger_model->get_all_ledgers();
diff --git a/system/application/models/ledger_model.php b/system/application/models/ledger_model.php
index b2109ed..f250a71 100644
--- a/system/application/models/ledger_model.php
+++ b/system/application/models/ledger_model.php
@@ -46,6 +46,19 @@ class Ledger_model extends Model {
return $options;
}
+ function get_all_ledgers_reconciliation()
+ {
+ $options = array();
+ $options[0] = "(Please Select)";
+ $this->db->from('ledgers')->where('reconciliation', 1)->order_by('name', 'asc');
+ $ledger_q = $this->db->get();
+ foreach ($ledger_q->result() as $row)
+ {
+ $options[$row->id] = $row->name;
+ }
+ return $options;
+ }
+
function get_name($ledger_id)
{
$this->db->from('ledgers')->where('id', $ledger_id)->limit(1);
@@ -124,11 +137,10 @@ class Ledger_model extends Model {
/* Delete reconciliation entries for a Ledger A/C */
function delete_reconciliation($ledger_id)
{
- $this->db->select('reconciliation.id as reconid');
- $this->db->from('reconciliation')->join('voucher_items', 'reconciliation.voucher_item_id = voucher_items.id')->where('voucher_items.ledger_id', $ledger_id);
- $reconciliation_id_q = $this->db->get();
- foreach ($reconciliation_id_q->result() as $row)
- $this->db->delete('reconciliation', array('id' => $row->reconid));
+ $update_data = array(
+ 'reconciliation_date' => NULL,
+ );
+ $this->db->where('ledger_id', $ledger_id)->update('voucher_items', $update_data);
return;
}
}
commit e7fef856ea32ea4324568651a30bf739a52b3ede
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sat Jan 15 18:07:55 2011 +0530
Using reconciliation column instead of separate table
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/db-update.txt b/db-update.txt
index 8e9c055..2e193fc 100644
--- a/db-update.txt
+++ b/db-update.txt
@@ -1,10 +1,6 @@
//--------------------------------- VERSION 2 ----------------------------------
-CREATE TABLE reconciliation (
-id INT(11) NOT NULL AUTO_INCREMENT,
-voucher_item_id INT(11) NOT NULL,
-bank_date DATETIME NOT NULL,
-PRIMARY KEY (id)
-) ENGINE = InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
+
+ALTER TABLE voucher_items ADD reconciliation_date DATETIME NULL;
ALTER TABLE ledgers ADD reconciliation INT(1) NOT NULL;
diff --git a/system/application/controllers/admin/schema.sql b/system/application/controllers/admin/schema.sql
index 0b5e0b8..1f2789a 100644
--- a/system/application/controllers/admin/schema.sql
+++ b/system/application/controllers/admin/schema.sql
@@ -35,6 +35,7 @@ CREATE TABLE IF NOT EXISTS voucher_items (
ledger_id int(11) NOT NULL,
amount decimal(15,2) NOT NULL DEFAULT '0.00',
dc char(1) NOT NULL,
+ reconciliation_date datetime NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
@@ -59,13 +60,6 @@ CREATE TABLE IF NOT EXISTS logs (
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
-CREATE TABLE IF NOT EXISTS reconciliation (
- id int(11) NOT NULL AUTO_INCREMENT,
- voucher_item_id int(11) NOT NULL,
- bank_date datetime NOT NULL,
- PRIMARY KEY (id)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
-
CREATE TABLE IF NOT EXISTS settings (
id int(1) NOT NULL,
name varchar(100) NOT NULL,
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index 1021cef..2ea8b30 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -114,7 +114,7 @@ class Startup
if ($CI->db->query("SHOW TABLES"))
{
/* Check for valid webzash database */
- $table_names = array('groups', 'ledgers', 'vouchers', 'voucher_items', 'reconciliation', 'tags', 'logs', 'settings');
+ $table_names = array('groups', 'ledgers', 'vouchers', 'voucher_items', 'tags', 'logs', 'settings');
foreach ($table_names as $id => $tbname)
{
$valid_db_q = mysql_query('DESC ' . $tbname);
commit 548e548c823ef83b539fa1920879ee11b7ff172e
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Jan 14 15:39:02 2011 +0530
Deleting reconciliation data if not required
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/ledger.php b/system/application/controllers/ledger.php
index 0c2693e..221a3fb 100644
--- a/system/application/controllers/ledger.php
+++ b/system/application/controllers/ledger.php
@@ -292,6 +292,11 @@ class Ledger extends Controller {
$this->template->load('template', 'ledger/edit', $data);
return;
} else {
+ /* Deleting reconciliation data if reconciliation disabled */
+ if (($ledger_data->reconciliation == 1) AND ($data_reconciliation == 0))
+ {
+ $this->Ledger_model->delete_reconciliation($data_id);
+ }
$this->db->trans_complete();
$this->messages->add('Updated Ledger A/C - ' . $data_name . '.', 'success');
$this->logger->write_message("success", "Updated Ledger A/C named " . $data_name . " [id:" . $data_id . "]");
@@ -359,6 +364,8 @@ class Ledger extends Controller {
redirect('account');
return;
} else {
+ /* Deleting reconciliation data if present */
+ $this->Ledger_model->delete_reconciliation($id);
$this->db->trans_complete();
$this->messages->add('Deleted Ledger A/C - ' . $ledger_data->name . '.', 'success');
$this->logger->write_message("success", "Deleted Ledger A/C named " . $ledger_data->name . " [id:" . $id . "]");
diff --git a/system/application/models/ledger_model.php b/system/application/models/ledger_model.php
index 72194fe..b2109ed 100644
--- a/system/application/models/ledger_model.php
+++ b/system/application/models/ledger_model.php
@@ -120,4 +120,15 @@ class Ledger_model extends Model {
else
return 0;
}
+
+ /* Delete reconciliation entries for a Ledger A/C */
+ function delete_reconciliation($ledger_id)
+ {
+ $this->db->select('reconciliation.id as reconid');
+ $this->db->from('reconciliation')->join('voucher_items', 'reconciliation.voucher_item_id = voucher_items.id')->where('voucher_items.ledger_id', $ledger_id);
+ $reconciliation_id_q = $this->db->get();
+ foreach ($reconciliation_id_q->result() as $row)
+ $this->db->delete('reconciliation', array('id' => $row->reconid));
+ return;
+ }
}
commit b134fe22f961b14f28e0b55de231d213f6315de6
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Jan 14 15:15:10 2011 +0530
Added reconciliation option to Ledger controller
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/ledger.php b/system/application/controllers/ledger.php
index 0482a2c..0c2693e 100644
--- a/system/application/controllers/ledger.php
+++ b/system/application/controllers/ledger.php
@@ -55,6 +55,7 @@ class Ledger extends Controller {
$data['ledger_group_active'] = 0;
$data['op_balance_dc'] = "D";
$data['ledger_type_cashbank'] = FALSE;
+ $data['reconciliation'] = FALSE;
/* Form validations */
$this->form_validation->set_rules('ledger_name', 'Ledger name', 'trim|required|min_length[2]|max_length[100]|unique[ledgers.name]');
@@ -70,6 +71,7 @@ class Ledger extends Controller {
$data['ledger_group_active'] = $this->input->post('ledger_group_id', TRUE);
$data['op_balance_dc'] = $this->input->post('op_balance_dc', TRUE);
$data['ledger_type_cashbank'] = $this->input->post('ledger_type_cashbank', TRUE);
+ $data['reconciliation'] = $this->input->post('reconciliation', TRUE);
}
if ($this->form_validation->run() == FALSE)
@@ -85,7 +87,7 @@ class Ledger extends Controller {
$data_op_balance = $this->input->post('op_balance', TRUE);
$data_op_balance_dc = $this->input->post('op_balance_dc', TRUE);
$data_ledger_type_cashbank_value = $this->input->post('ledger_type_cashbank', TRUE);
- $data_ledger_type_cashbank = "N";
+ $data_reconciliation = $this->input->post('reconciliation', TRUE);
if ($data_group_id < 5)
{
@@ -106,6 +108,15 @@ class Ledger extends Controller {
if ($data_ledger_type_cashbank_value == "1")
{
$data_ledger_type_cashbank = "B";
+ } else {
+ $data_ledger_type_cashbank = "N";
+ }
+
+ if ($data_reconciliation == "1")
+ {
+ $data_reconciliation = 1;
+ } else {
+ $data_reconciliation = 0;
}
$this->db->trans_start();
@@ -115,6 +126,7 @@ class Ledger extends Controller {
'op_balance' => $data_op_balance,
'op_balance_dc' => $data_op_balance_dc,
'type' => $data_ledger_type_cashbank,
+ 'reconciliation' => $data_reconciliation,
);
if ( ! $this->db->insert('ledgers', $insert_data))
{
@@ -198,6 +210,7 @@ class Ledger extends Controller {
$data['ledger_type_cashbank'] = TRUE;
else
$data['ledger_type_cashbank'] = FALSE;
+ $data['reconciliation'] = $ledger_data->reconciliation;
/* Form validations */
$this->form_validation->set_rules('ledger_name', 'Ledger name', 'trim|required|min_length[2]|max_length[100]|uniquewithid[ledgers.name.' . $id . ']');
@@ -213,6 +226,7 @@ class Ledger extends Controller {
$data['op_balance']['value'] = $this->input->post('op_balance', TRUE);
$data['op_balance_dc'] = $this->input->post('op_balance_dc', TRUE);
$data['ledger_type_cashbank'] = $this->input->post('ledger_type_cashbank', TRUE);
+ $data['reconciliation'] = $this->input->post('reconciliation', TRUE);
}
if ($this->form_validation->run() == FALSE)
@@ -229,7 +243,7 @@ class Ledger extends Controller {
$data_op_balance_dc = $this->input->post('op_balance_dc', TRUE);
$data_id = $id;
$data_ledger_type_cashbank_value = $this->input->post('ledger_type_cashbank', TRUE);
- $data_ledger_type_cashbank = "N";
+ $data_reconciliation = $this->input->post('reconciliation', TRUE);
if ($data_group_id < 5)
{
@@ -250,6 +264,15 @@ class Ledger extends Controller {
if ($data_ledger_type_cashbank_value == "1")
{
$data_ledger_type_cashbank = "B";
+ } else {
+ $data_ledger_type_cashbank = "N";
+ }
+
+ if ($data_reconciliation == "1")
+ {
+ $data_reconciliation = 1;
+ } else {
+ $data_reconciliation = 0;
}
$this->db->trans_start();
@@ -259,6 +282,7 @@ class Ledger extends Controller {
'op_balance' => $data_op_balance,
'op_balance_dc' => $data_op_balance_dc,
'type' => $data_ledger_type_cashbank,
+ 'reconciliation' => $data_reconciliation,
);
if ( ! $this->db->where('id', $data_id)->update('ledgers', $update_data))
{
diff --git a/system/application/views/ledger/add.php b/system/application/views/ledger/add.php
index 106a9ad..caab430 100644
--- a/system/application/views/ledger/add.php
+++ b/system/application/views/ledger/add.php
@@ -32,6 +32,13 @@
echo "</p>";
echo "<p>";
+ echo "<span id=\"tooltip-target-3\">";
+ echo form_checkbox('reconciliation', 1, $reconciliation) . " Reconciliation";
+ echo "</span>";
+ echo "<span id=\"tooltip-content-3\">If enabled account can be reconciled from Reports > Reconciliation</span>";
+ echo "</p>";
+
+ echo "<p>";
echo form_submit('submit', 'Create');
echo " ";
echo anchor('account', 'Back', 'Back to Chart of Accounts');
diff --git a/system/application/views/ledger/edit.php b/system/application/views/ledger/edit.php
index 2a38808..c54cca9 100644
--- a/system/application/views/ledger/edit.php
+++ b/system/application/views/ledger/edit.php
@@ -32,6 +32,13 @@
echo "</p>";
echo "<p>";
+ echo "<span id=\"tooltip-target-3\">";
+ echo form_checkbox('reconciliation', 1, $reconciliation) . " Reconciliation";
+ echo "</span>";
+ echo "<span id=\"tooltip-content-3\">If enabled account can be reconciled from Reports > Reconciliation</span>";
+ echo "</p>";
+
+ echo "<p>";
echo form_hidden('ledger_id', $ledger_id);
echo form_submit('submit', 'Update');
echo " ";
commit 70e45c4ad347a2f954b5c5bb85487941f732cccf
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Jan 14 10:24:28 2011 +0530
Added reconciliation database table
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/db-update.txt b/db-update.txt
new file mode 100644
index 0000000..8e9c055
--- /dev/null
+++ b/db-update.txt
@@ -0,0 +1,10 @@
+//--------------------------------- VERSION 2 ----------------------------------
+CREATE TABLE reconciliation (
+id INT(11) NOT NULL AUTO_INCREMENT,
+voucher_item_id INT(11) NOT NULL,
+bank_date DATETIME NOT NULL,
+PRIMARY KEY (id)
+) ENGINE = InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
+
+ALTER TABLE ledgers ADD reconciliation INT(1) NOT NULL;
+
diff --git a/system/application/controllers/admin/create.php b/system/application/controllers/admin/create.php
index f3759e7..9b16864 100644
--- a/system/application/controllers/admin/create.php
+++ b/system/application/controllers/admin/create.php
@@ -308,7 +308,7 @@ class Create extends Controller {
/* Adding account settings */
$newacc->trans_start();
- if ( ! $newacc->query("INSERT INTO settings (id, name, address, email, fy_start, fy_end, currency_symbol, date_format, timezone, account_locked, database_version) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array(1, $data_account_name, $data_account_address, $data_account_email, $data_fy_start, $data_fy_end, $data_account_currency, $data_account_date, $data_account_timezone, 0, 1)))
+ if ( ! $newacc->query("INSERT INTO settings (id, name, address, email, fy_start, fy_end, currency_symbol, date_format, timezone, account_locked, database_version) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array(1, $data_account_name, $data_account_address, $data_account_email, $data_fy_start, $data_fy_end, $data_account_currency, $data_account_date, $data_account_timezone, 0, 2)))
{
$newacc->trans_rollback();
$this->messages->add('Error adding account settings.', 'error');
diff --git a/system/application/controllers/admin/schema.sql b/system/application/controllers/admin/schema.sql
index 8382b72..0b5e0b8 100644
--- a/system/application/controllers/admin/schema.sql
+++ b/system/application/controllers/admin/schema.sql
@@ -13,6 +13,7 @@ CREATE TABLE IF NOT EXISTS ledgers (
op_balance decimal(15,2) NOT NULL DEFAULT '0.00',
op_balance_dc char(1) NOT NULL,
type char(1) NOT NULL,
+ reconciliation int(1) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=1;
@@ -58,6 +59,13 @@ CREATE TABLE IF NOT EXISTS logs (
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
+CREATE TABLE IF NOT EXISTS reconciliation (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ voucher_item_id int(11) NOT NULL,
+ bank_date datetime NOT NULL,
+ PRIMARY KEY (id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
+
CREATE TABLE IF NOT EXISTS settings (
id int(1) NOT NULL,
name varchar(100) NOT NULL,
diff --git a/system/application/controllers/setting.php b/system/application/controllers/setting.php
index 02d0cea..d6794b9 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -414,7 +414,7 @@ class Setting extends Controller {
/* Adding account settings */
$newacc->trans_start();
- if ( ! $newacc->query("INSERT INTO settings (id, name, address, email, fy_start, fy_end, currency_symbol, date_format, timezone, account_locked, email_protocol, email_host, email_port, email_username, email_password, database_version) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array(1, $data_account_name, $data_account_address, $data_account_email, $data_fy_start, $data_fy_end, $data_account_currency, $data_account_date, $data_account_timezone, 0, $data_account_email_protocol, $data_account_email_host, $data_account_email_port, $data_account_email_username, $data_account_email_password, 1)))
+ if ( ! $newacc->query("INSERT INTO settings (id, name, address, email, fy_start, fy_end, currency_symbol, date_format, timezone, account_locked, email_protocol, email_host, email_port, email_username, email_password, database_version) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array(1, $data_account_name, $data_account_address, $data_account_email, $data_fy_start, $data_fy_end, $data_account_currency, $data_account_date, $data_account_timezone, 0, $data_account_email_protocol, $data_account_email_host, $data_account_email_port, $data_account_email_username, $data_account_email_password, 2)))
{
$newacc->trans_rollback();
$this->messages->add('Error adding account settings.', 'error');
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index 348aacd..1021cef 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -114,13 +114,13 @@ class Startup
if ($CI->db->query("SHOW TABLES"))
{
/* Check for valid webzash database */
- $table_names = array('settings', 'groups', 'ledgers', 'vouchers', 'voucher_items', 'tags', 'logs');
+ $table_names = array('groups', 'ledgers', 'vouchers', 'voucher_items', 'reconciliation', 'tags', 'logs', 'settings');
foreach ($table_names as $id => $tbname)
{
$valid_db_q = mysql_query('DESC ' . $tbname);
if ( ! $valid_db_q)
{
- $CI->messages->add('Invalid account database.', 'error');
+ $CI->messages->add('Invalid account database. Table "' . $tbname . '" missing.', 'error');
redirect('admin');
return;
}
commit f1c5308c633d174274e082895b4ddbdcca20ffef
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 12 19:27:00 2011 +0530
Updated CHANGELOG.txt file
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index e69de29..7e1e346 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -0,0 +1,14 @@
+Webzash Version 1.0-beta2 2011-01-12
+------------------------------------
+
+ * Added user authentication
+ * Added role based permissions
+ * Added voucher auto numbering
+ * Added Account Locked
+ * Added Help
+ * Added Tooltips
+ * Added jQuery colorpicker plugin
+ * Added Status report
+ * Updated normal SQL queries with active record queries
+ * Updated status messages
+ * Removed support for draft vouchers
commit aaaee27a6179da2917b9b39ce729eb3339886a39
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 12 17:16:13 2011 +0530
Added Ledger id check for Ledger St
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/report.php b/system/application/controllers/report.php
index a7613a3..9230ef0 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -72,6 +72,19 @@ class Report extends Controller {
}
$data['print_preview'] = FALSE;
$data['ledger_id'] = $ledger_id;
+
+ /* Checking for valid ledger id */
+ if ($data['ledger_id'] > 0)
+ {
+ $this->db->from('ledgers')->where('id', $data['ledger_id'])->limit(1);
+ if ($this->db->get()->num_rows() < 1)
+ {
+ $this->messages->add('Invalid Ledger A/C.', 'error');
+ redirect('report/ledgerst');
+ return;
+ }
+ }
+
$this->template->load('template', 'report/ledgerst', $data);
return;
}
@@ -618,6 +631,14 @@ class Report extends Controller {
{
$this->messages->add('Invalid Ledger A/C.', 'error');
redirect('report/ledgerst');
+ return;
+ }
+ $this->db->from('ledgers')->where('id', $data['ledger_id'])->limit(1);
+ if ($this->db->get()->num_rows() < 1)
+ {
+ $this->messages->add('Invalid Ledger A/C.', 'error');
+ redirect('report/ledgerst');
+ return;
}
$data['report'] = "report/ledgerst";
$data['title'] = "Ledger Statement for '" . $this->Ledger_model->get_name($data['ledger_id']) . "'";
commit fa2ac23b4fcf4d79db8eb836d7fb6cd18723e211
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 12 17:15:50 2011 +0530
Updated Status messages
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/group.php b/system/application/controllers/group.php
index 12a8154..5b33e58 100644
--- a/system/application/controllers/group.php
+++ b/system/application/controllers/group.php
@@ -101,13 +101,13 @@ class Group extends Controller {
if ( ! $this->db->insert('groups', $insert_data))
{
$this->db->trans_rollback();
- $this->messages->add('Error addding ' . $data_name . ' - Group A/C.', 'error');
+ $this->messages->add('Error addding Group A/C - ' . $data_name . '.', 'error');
$this->logger->write_message("error", "Error adding Group A/C named " . $data_name);
$this->template->load('template', 'group/add', $data);
return;
} else {
$this->db->trans_complete();
- $this->messages->add('Added ' . $data_name . ' - Group A/C.', 'success');
+ $this->messages->add('Added Group A/C - ' . $data_name . '.', 'success');
$this->logger->write_message("success", "Added Group A/C named " . $data_name);
redirect('account');
return;
@@ -237,13 +237,13 @@ class Group extends Controller {
if ( ! $this->db->where('id', $data_id)->update('groups', $update_data))
{
$this->db->trans_rollback();
- $this->messages->add('Error updating ' . $data_name . ' - Group A/C.', 'error');
+ $this->messages->add('Error updating Group A/C - ' . $data_name . '.', 'error');
$this->logger->write_message("error", "Error updating Group A/C named " . $data_name . " [id:" . $data_id . "]");
$this->template->load('template', 'group/edit', $data);
return;
} else {
$this->db->trans_complete();
- $this->messages->add('Updated ' . $data_name . ' - Group A/C.', 'success');
+ $this->messages->add('Updated Group A/C - ' . $data_name . '.', 'success');
$this->logger->write_message("success", "Updated Group A/C named " . $data_name . " [id:" . $data_id . "]");
redirect('account');
return;
@@ -315,13 +315,13 @@ class Group extends Controller {
if ( ! $this->db->delete('groups', array('id' => $id)))
{
$this->db->trans_rollback();
- $this->messages->add('Error deleting ' . $group_data->name . ' - Group A/C.', 'error');
+ $this->messages->add('Error deleting Group A/C - ' . $group_data->name . '.', 'error');
$this->logger->write_message("error", "Error deleting Group A/C named " . $group_data->name . " [id:" . $id . "]");
redirect('account');
return;
} else {
$this->db->trans_complete();
- $this->messages->add('Deleted ' . $group_data->name . ' - Group A/C.', 'success');
+ $this->messages->add('Deleted Group A/C - ' . $group_data->name . '.', 'success');
$this->logger->write_message("success", "Deleted Group A/C named " . $group_data->name . " [id:" . $id . "]");
redirect('account');
return;
diff --git a/system/application/controllers/ledger.php b/system/application/controllers/ledger.php
index be0fad7..0482a2c 100644
--- a/system/application/controllers/ledger.php
+++ b/system/application/controllers/ledger.php
@@ -89,7 +89,7 @@ class Ledger extends Controller {
if ($data_group_id < 5)
{
- $this->messages->add('Invalid parent group.', 'error');
+ $this->messages->add('Invalid Parent group.', 'error');
$this->template->load('template', 'ledger/add', $data);
return;
}
@@ -119,13 +119,13 @@ class Ledger extends Controller {
if ( ! $this->db->insert('ledgers', $insert_data))
{
$this->db->trans_rollback();
- $this->messages->add('Error addding ' . $data_name . ' - Ledger A/C.', 'error');
+ $this->messages->add('Error addding Ledger A/C - ' . $data_name . '.', 'error');
$this->logger->write_message("error", "Error adding Ledger A/C named " . $data_name);
$this->template->load('template', 'group/add', $data);
return;
} else {
$this->db->trans_complete();
- $this->messages->add('Added ' . $data_name . ' - Ledger A/C.', 'success');
+ $this->messages->add('Added Ledger A/C - ' . $data_name . '.', 'success');
$this->logger->write_message("success", "Added Ledger A/C named " . $data_name);
redirect('account');
return;
@@ -233,7 +233,7 @@ class Ledger extends Controller {
if ($data_group_id < 5)
{
- $this->messages->add('Invalid parent group.', 'error');
+ $this->messages->add('Invalid Parent group.', 'error');
$this->template->load('template', 'ledger/edit', $data);
return;
}
@@ -263,13 +263,13 @@ class Ledger extends Controller {
if ( ! $this->db->where('id', $data_id)->update('ledgers', $update_data))
{
$this->db->trans_rollback();
- $this->messages->add('Error updating ' . $data_name . ' - Ledger A/C.', 'error');
+ $this->messages->add('Error updating Ledger A/C - ' . $data_name . '.', 'error');
$this->logger->write_message("error", "Error updating Ledger A/C named " . $data_name . " [id:" . $data_id . "]");
$this->template->load('template', 'ledger/edit', $data);
return;
} else {
$this->db->trans_complete();
- $this->messages->add('Updated ' . $data_name . ' - Ledger A/C.', 'success');
+ $this->messages->add('Updated Ledger A/C - ' . $data_name . '.', 'success');
$this->logger->write_message("success", "Updated Ledger A/C named " . $data_name . " [id:" . $data_id . "]");
redirect('account');
return;
@@ -330,13 +330,13 @@ class Ledger extends Controller {
if ( ! $this->db->delete('ledgers', array('id' => $id)))
{
$this->db->trans_rollback();
- $this->messages->add('Error deleting ' . $ledger_data->name . ' - Ledger A/C.', 'error');
+ $this->messages->add('Error deleting Ledger A/C - ' . $ledger_data->name . '.', 'error');
$this->logger->write_message("error", "Error deleting Ledger A/C named " . $ledger_data->name . " [id:" . $id . "]");
redirect('account');
return;
} else {
$this->db->trans_complete();
- $this->messages->add('Deleted ' . $ledger_data->name . ' - Ledger A/C.', 'success');
+ $this->messages->add('Deleted Ledger A/C - ' . $ledger_data->name . '.', 'success');
$this->logger->write_message("success", "Deleted Ledger A/C named " . $ledger_data->name . " [id:" . $id . "]");
redirect('account');
return;
diff --git a/system/application/controllers/setting.php b/system/application/controllers/setting.php
index 5050139..02d0cea 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -435,7 +435,7 @@ class Setting extends Controller {
{
if ( ! $newacc->query("INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (?, ?, ?, ?)", array($row->id, $row->parent_id, $row->name, $row->affects_gross)))
{
- $this->messages->add('Failed to add group ' . $row->name . '.', 'error');
+ $this->messages->add('Failed to add Group A/C - ' . $row->name . '.', 'error');
$cf_status = FALSE;
}
}
@@ -467,13 +467,13 @@ class Setting extends Controller {
}
if ( ! $newacc->query("INSERT INTO ledgers (id, group_id, name, op_balance, op_balance_dc, type) VALUES (?, ?, ?, ?, ?, ?)", array($row->id, $row->group_id, $row->name, $op_balance, $op_balance_dc, $row->type)))
{
- $this->messages->add('Failed to add ledger ' . $row->name . '.', 'error');
+ $this->messages->add('Failed to add Ledger A/C - ' . $row->name . '.', 'error');
$cf_status = FALSE;
}
} else {
if ( ! $newacc->query("INSERT INTO ledgers (id, group_id, name, op_balance, op_balance_dc, type) VALUES (?, ?, ?, ?, ?, ?)", array($row->id, $row->group_id, $row->name, 0, "D", $row->type)))
{
- $this->messages->add('Failed to add ledger ' . $row->name . '.', 'error');
+ $this->messages->add('Failed to add Ledger A/C - ' . $row->name . '.', 'error');
$cf_status = FALSE;
}
}
@@ -486,7 +486,7 @@ class Setting extends Controller {
{
if ( ! $newacc->query("INSERT INTO tags (id, title, color, background) VALUES (?, ?, ?, ?)", array($row->id, $row->title, $row->color, $row->background)))
{
- $this->messages->add('Failed to add tag ' . $row->title . '.', 'error');
+ $this->messages->add('Failed to add Tag - ' . $row->title . '.', 'error');
$cf_status = FALSE;
}
}
diff --git a/system/application/controllers/tag.php b/system/application/controllers/tag.php
index 2bd2f52..99680d5 100644
--- a/system/application/controllers/tag.php
+++ b/system/application/controllers/tag.php
@@ -109,13 +109,13 @@ class Tag extends Controller {
if ( ! $this->db->insert('tags', $insert_data))
{
$this->db->trans_rollback();
- $this->messages->add('Error addding ' . $data_tag_title . ' - Tag.', 'error');
+ $this->messages->add('Error addding Tag - ' . $data_tag_title . '.', 'error');
$this->logger->write_message("error", "Error adding tag named " . $data_tag_title);
$this->template->load('template', 'tag/add', $data);
return;
} else {
$this->db->trans_complete();
- $this->messages->add('Added ' . $data_tag_title . ' - Tag.', 'success');
+ $this->messages->add('Added Tag - ' . $data_tag_title . '.', 'success');
$this->logger->write_message("success", "Added tag named " . $data_tag_title);
redirect('tag');
return;
@@ -238,13 +238,13 @@ class Tag extends Controller {
if ( ! $this->db->where('id', $id)->update('tags', $update_data))
{
$this->db->trans_rollback();
- $this->messages->add('Error updating ' . $data_tag_title . ' - Tag.', 'error');
+ $this->messages->add('Error updating Tag - ' . $data_tag_title . '.', 'error');
$this->logger->write_message("error", "Error updating tag named " . $data_tag_title . " [id:" . $id . "]");
$this->template->load('template', 'tag/edit', $data);
return;
} else {
$this->db->trans_complete();
- $this->messages->add('Updated ' . $data_tag_title . ' - Tag.', 'success');
+ $this->messages->add('Updated Tag - ' . $data_tag_title . '.', 'success');
$this->logger->write_message("success", "Updated tag named " . $data_tag_title . " [id:" . $id . "]");
redirect('tag');
return;
diff --git a/system/application/controllers/user.php b/system/application/controllers/user.php
index cebebff..9867c07 100644
--- a/system/application/controllers/user.php
+++ b/system/application/controllers/user.php
@@ -262,7 +262,7 @@ class User extends Controller {
}
if ( ! isset($current_account['db_port']))
{
- $this->messages->add('Port missing from account settings file. Default MySQL port is 3306.', 'error');
+ $this->messages->add('Port missing from account settings file.', 'error');
$this->template->load('user_template', 'user/account', $data);
return;
}
diff --git a/system/application/controllers/voucher.php b/system/application/controllers/voucher.php
index 4e37fb6..78e082f 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -59,7 +59,7 @@ class Voucher extends Controller {
$data['voucher_type'] = "";
break;
default :
- $this->messages->add('Invalid voucher type(1).', 'error');
+ $this->messages->add('Invalid Voucher type(1).', 'error');
redirect('voucher/show/all');
return;
break;
@@ -114,7 +114,7 @@ class Voucher extends Controller {
if (($voucher_type_int < 0) || ($voucher_type_int > 4))
{
- $this->messages->add('Invalid voucher type(2).', 'error');
+ $this->messages->add('Invalid Voucher type(2).', 'error');
redirect('voucher/show/all');
return;
} else if ($voucher_type == "tag") {
@@ -208,7 +208,7 @@ class Voucher extends Controller {
$this->template->set('page_title', 'View Journal Voucher');
break;
default :
- $this->messages->add('Invalid voucher type(3).', 'error');
+ $this->messages->add('Invalid Voucher type(3).', 'error');
redirect('voucher/show/all');
return;
break;
@@ -226,7 +226,7 @@ class Voucher extends Controller {
$cur_voucher_ledgers = $this->db->get();
if ($cur_voucher_ledgers->num_rows() < 1)
{
- $this->messages->add('Voucher has no associated ledger data.', 'error');
+ $this->messages->add('Voucher has no associated Ledger A/C\'s.', 'error');
}
$data['cur_voucher'] = $cur_voucher;
$data['cur_voucher_ledgers'] = $cur_voucher_ledgers;
@@ -268,7 +268,7 @@ class Voucher extends Controller {
$this->template->set('page_title', 'New Journal Voucher');
break;
default :
- $this->messages->add('Invalid voucher type(4).', 'error');
+ $this->messages->add('Invalid Voucher type(4).', 'error');
redirect('voucher/show/all');
return;
break;
@@ -425,7 +425,7 @@ class Voucher extends Controller {
$this->template->load('template', 'voucher/add', $data);
return;
} else if ($dr_total == 0 && $cr_total == 0) {
- $this->messages->add('Cannot save empty voucher.', 'error');
+ $this->messages->add('Cannot save empty Voucher.', 'error');
$this->template->load('template', 'voucher/add', $data);
return;
}
@@ -434,7 +434,7 @@ class Voucher extends Controller {
{
if ( ! $bank_cash_present)
{
- $this->messages->add('Need to Debit atleast one Bank or Cash A/C', 'error');
+ $this->messages->add('Need to Debit atleast one Bank or Cash A/C.', 'error');
$this->template->load('template', 'voucher/add', $data);
return;
}
@@ -442,7 +442,7 @@ class Voucher extends Controller {
{
if ( ! $bank_cash_present)
{
- $this->messages->add('Need to Credit atleast one Bank or Cash A/C', 'error');
+ $this->messages->add('Need to Credit atleast one Bank or Cash A/C.', 'error');
$this->template->load('template', 'voucher/add', $data);
return;
}
@@ -519,7 +519,7 @@ class Voucher extends Controller {
if ( ! $this->db->insert('voucher_items', $insert_ledger_data))
{
$this->db->trans_rollback();
- $this->messages->add('Error addding Ledger A/C ' . $data_ledger_id . '.', 'error');
+ $this->messages->add('Error adding Ledger A/C - ' . $data_ledger_id . ' to Voucher.', 'error');
$this->logger->write_message("error", "Error adding " . ucfirst($voucher_type) . " Voucher number " . voucher_number_prefix($voucher_type) . $data_number . " since failed inserting voucher ledger items " . "[id:" . $data_ledger_id . "]");
$this->template->load('template', 'voucher/add', $data);
return;
@@ -534,7 +534,7 @@ class Voucher extends Controller {
if ( ! $this->db->where('id', $voucher_id)->update('vouchers', $update_data))
{
$this->db->trans_rollback();
- $this->messages->add('Error updating voucher total.', 'error');
+ $this->messages->add('Error updating Voucher total.', 'error');
$this->logger->write_message("error", "Error adding " . ucfirst($voucher_type) . " Voucher number " . voucher_number_prefix($voucher_type) . $data_number . " since failed updating debit and credit total");
$this->template->load('template', 'voucher/add', $data);
return;
@@ -611,7 +611,7 @@ class Voucher extends Controller {
$this->template->set('page_title', 'Edit Journal Voucher');
break;
default :
- $this->messages->add('Invalid voucher type(5).', 'error');
+ $this->messages->add('Invalid Voucher type(5).', 'error');
redirect('voucher/show/all');
return;
break;
@@ -797,7 +797,7 @@ class Voucher extends Controller {
$this->template->load('template', 'voucher/edit', $data);
return;
} else if ($dr_total == 0 && $cr_total == 0) {
- $this->messages->add('Cannot save empty voucher.', 'error');
+ $this->messages->add('Cannot save empty Voucher.', 'error');
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -806,7 +806,7 @@ class Voucher extends Controller {
{
if ( ! $bank_cash_present)
{
- $this->messages->add('Need to Debit atleast one Bank or Cash A/C', 'error');
+ $this->messages->add('Need to Debit atleast one Bank or Cash A/C.', 'error');
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -814,7 +814,7 @@ class Voucher extends Controller {
{
if ( ! $bank_cash_present)
{
- $this->messages->add('Need to Credit atleast one Bank or Cash A/C', 'error');
+ $this->messages->add('Need to Credit atleast one Bank or Cash A/C.', 'error');
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -855,7 +855,7 @@ class Voucher extends Controller {
if ( ! $this->db->delete('voucher_items', array('voucher_id' => $voucher_id)))
{
$this->db->trans_rollback();
- $this->messages->add('Error deleting old Ledger A/C\'s', 'error');
+ $this->messages->add('Error deleting previous Ledger A/C\'s from Voucher.', 'error');
$this->logger->write_message("error", "Error updating old voucher items for " . ucfirst($voucher_type) . " Voucher number " . voucher_number_prefix($voucher_type) . $data_number . " [id:" . $voucher_id . "]");
$this->template->load('template', 'voucher/edit', $data);
return;
@@ -894,7 +894,7 @@ class Voucher extends Controller {
if ( ! $this->db->insert('voucher_items', $insert_ledger_data))
{
$this->db->trans_rollback();
- $this->messages->add('Error updating Ledger A/C ' . $data_ledger_id . '.', 'error');
+ $this->messages->add('Error adding Ledger A/C - ' . $data_ledger_id . ' to Voucher.', 'error');
$this->logger->write_message("error", "Error updating new voucher item [id:" . $data_ledger_id . "] for " . ucfirst($voucher_type) . " Voucher number " . voucher_number_prefix($voucher_type) . $data_number . " [id:" . $voucher_id . "]");
$this->template->load('template', 'voucher/edit', $data);
return;
@@ -909,7 +909,7 @@ class Voucher extends Controller {
if ( ! $this->db->where('id', $voucher_id)->update('vouchers', $update_data))
{
$this->db->trans_rollback();
- $this->messages->add('Error updating voucher total.', 'error');
+ $this->messages->add('Error updating Voucher total.', 'error');
$this->logger->write_message("error", "Error updating voucher total for " . ucfirst($voucher_type) . " Voucher number " . voucher_number_prefix($voucher_type) . $data_number . " [id:" . $voucher_id . "]");
$this->template->load('template', 'voucher/edit', $data);
return;
@@ -982,7 +982,7 @@ class Voucher extends Controller {
if ( ! $this->db->delete('voucher_items', array('voucher_id' => $voucher_id)))
{
$this->db->trans_rollback();
- $this->messages->add('Error deleting Voucher - Ledgers entry.', 'error');
+ $this->messages->add('Error deleting Voucher - Ledger A/C\'s.', 'error');
$this->logger->write_message("error", "Error deleting ledger entries for " . ucfirst($voucher_type) . " Voucher number " . voucher_number_prefix($voucher_type) . $cur_voucher->number . " [id:" . $voucher_id . "]");
redirect('voucher/' . $voucher_type . '/' . $voucher_id);
return;
commit ac5cf0c826177ab636b861d05b05ab5084a12172
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 12 14:48:11 2011 +0530
Converted pending voucher controller to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/voucher.php b/system/application/controllers/voucher.php
index b1b7def..4e37fb6 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -118,13 +118,16 @@ class Voucher extends Controller {
redirect('voucher/show/all');
return;
} else if ($voucher_type == "tag") {
- $voucher_q = $this->db->query("SELECT * FROM vouchers WHERE tag_id = ? ORDER BY date DESC, number DESC LIMIT ${page_count}, ${pagination_counter}", array($tag_id));
- $config['total_rows'] = $this->db->query("SELECT * FROM vouchers WHERE tag_id = ?", array($tag_id))->num_rows();
+ $this->db->from('vouchers')->where('tag_id', $tag_id)->order_by('date', 'desc')->order_by('number', 'desc')->limit($pagination_counter, $page_count);
+ $voucher_q = $this->db->get();
+ $config['total_rows'] = $this->db->from('vouchers')->where('tag_id', $tag_id)->get()->num_rows();
} else if ($voucher_type_int > 0) {
- $voucher_q = $this->db->query("SELECT * FROM vouchers WHERE type = ? ORDER BY date DESC, number DESC LIMIT ${page_count}, ${pagination_counter}", array($voucher_type_int));
- $config['total_rows'] = $this->db->query("SELECT * FROM vouchers WHERE type = ?", array($voucher_type_int))->num_rows();
+ $this->db->from('vouchers')->where('type', $voucher_type_int)->order_by('date', 'desc')->order_by('number', 'desc')->limit($pagination_counter, $page_count);
+ $voucher_q = $this->db->get();
+ $config['total_rows'] = $this->db->from('vouchers')->where('type', $voucher_type_int)->get()->num_rows();
} else {
- $voucher_q = $this->db->query("SELECT * FROM vouchers ORDER BY date DESC, number DESC LIMIT ${page_count}, ${pagination_counter}");
+ $this->db->from('vouchers')->order_by('date', 'desc')->order_by('number', 'desc')->limit($pagination_counter, $page_count);
+ $voucher_q = $this->db->get();
$config['total_rows'] = $this->db->count_all('vouchers');
}
commit 7dbc081a6fba80466d5818dc87bd90b14dfeb0fc
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 12 14:32:33 2011 +0530
Converted voucher controller to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/voucher.php b/system/application/controllers/voucher.php
index 22b5cf1..b1b7def 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -142,7 +142,9 @@ class Voucher extends Controller {
/* Showing the credit ledger name for payment and debit for other voucher types */
$ledger_type = ($row->type == 2) ? "C" : "D";
- $ledger_q = $this->db->query("SELECT ledgers.name as name FROM voucher_items join ledgers on voucher_items.ledger_id = ledgers.id WHERE voucher_items.voucher_id = ? AND voucher_items.dc = ?", array($row->id, $ledger_type));
+ $this->db->select('ledgers.name as name');
+ $this->db->from('voucher_items')->join('ledgers', 'voucher_items.ledger_id = ledgers.id')->where('voucher_items.voucher_id', $row->id)->where('voucher_items.dc', $ledger_type);
+ $ledger_q = $this->db->get();
$ledger_multiple = ($ledger_q->num_rows() > 1) ? TRUE : FALSE;
$ledger = $ledger_q->row();
@@ -217,7 +219,9 @@ class Voucher extends Controller {
return;
}
/* Load current voucher details */
- if ( ! $cur_voucher_ledgers = $this->db->query("SELECT * FROM voucher_items WHERE voucher_id = ? ORDER BY id ASC", array($voucher_id)))
+ $this->db->from('voucher_items')->where('voucher_id', $voucher_id)->order_by('id', 'asc');
+ $cur_voucher_ledgers = $this->db->get();
+ if ($cur_voucher_ledgers->num_rows() < 1)
{
$this->messages->add('Voucher has no associated ledger data.', 'error');
}
@@ -364,7 +368,8 @@ class Voucher extends Controller {
continue;
/* Check for valid ledger id */
- $valid_ledger_q = $this->db->query("SELECT id, type FROM ledgers WHERE id = ?", array($data_all_ledger_id[$id]));
+ $this->db->from('ledgers')->where('id', $data_all_ledger_id[$id]);
+ $valid_ledger_q = $this->db->get();
if ($valid_ledger_q->num_rows() < 1)
{
$this->messages->add('Invalid Ledger A/C.', 'error');
@@ -461,7 +466,14 @@ class Voucher extends Controller {
$voucher_id = NULL;
$this->db->trans_start();
- if ( ! $this->db->query("INSERT INTO vouchers (number, date, narration, type, tag_id) VALUES (?, ?, ?, ?, ?)", array($data_number, $data_date, $data_narration, $data_type, $data_tag)))
+ $insert_data = array(
+ 'number' => $data_number,
+ 'date' => $data_date,
+ 'narration' => $data_narration,
+ 'type' => $data_type,
+ 'tag_id' => $data_tag,
+ );
+ if ( ! $this->db->insert('vouchers', $insert_data))
{
$this->db->trans_rollback();
$this->messages->add('Error addding Voucher.', 'error');
@@ -495,8 +507,13 @@ class Voucher extends Controller {
$data_amount = $data_all_cr_amount[$id];
$cr_total += $data_all_cr_amount[$id];
}
-
- if ( ! $this->db->query("INSERT INTO voucher_items (voucher_id, ledger_id, amount, dc) VALUES (?, ?, ?, ?)", array($voucher_id, $data_ledger_id, $data_amount, $data_ledger_dc)))
+ $insert_ledger_data = array(
+ 'voucher_id' => $voucher_id,
+ 'ledger_id' => $data_ledger_id,
+ 'amount' => $data_amount,
+ 'dc' => $data_ledger_dc,
+ );
+ if ( ! $this->db->insert('voucher_items', $insert_ledger_data))
{
$this->db->trans_rollback();
$this->messages->add('Error addding Ledger A/C ' . $data_ledger_id . '.', 'error');
@@ -507,7 +524,11 @@ class Voucher extends Controller {
}
/* Updating Debit and Credit Total in vouchers table */
- if ( ! $this->db->query("UPDATE vouchers SET dr_total = ?, cr_total = ? WHERE id = ?", array($dr_total, $cr_total, $voucher_id)))
+ $update_data = array(
+ 'dr_total' => $dr_total,
+ 'cr_total' => $cr_total,
+ );
+ if ( ! $this->db->where('id', $voucher_id)->update('vouchers', $update_data))
{
$this->db->trans_rollback();
$this->messages->add('Error updating voucher total.', 'error');
@@ -634,7 +655,8 @@ class Voucher extends Controller {
/* Load current ledger details if not $_POST */
if ( ! $_POST)
{
- $cur_ledgers_q = $this->db->query("SELECT * FROM voucher_items WHERE voucher_id = ?", array($voucher_id));
+ $this->db->from('voucher_items')->where('voucher_id', $voucher_id);
+ $cur_ledgers_q = $this->db->get();
if ($cur_ledgers_q->num_rows <= 0)
{
$this->messages->add('No Ledger A/C\'s found!', 'error');
@@ -719,7 +741,8 @@ class Voucher extends Controller {
continue;
/* Check for valid ledger id */
- $valid_ledger_q = $this->db->query("SELECT id, type FROM ledgers WHERE id = ?", array($data_all_ledger_id[$id]));
+ $this->db->from('ledgers')->where('id', $data_all_ledger_id[$id]);
+ $valid_ledger_q = $this->db->get();
if ($valid_ledger_q->num_rows() < 1)
{
$this->messages->add('Invalid Ledger A/C.', 'error');
@@ -810,7 +833,13 @@ class Voucher extends Controller {
$data_date = date_php_to_mysql($data_date); // Converting date to MySQL
$this->db->trans_start();
- if ( ! $this->db->query("UPDATE vouchers SET number = ?, date = ?, narration = ?, tag_id = ? WHERE id = ?", array($data_number, $data_date, $data_narration, $data_tag, $voucher_id)))
+ $update_data = array(
+ 'number' => $data_number,
+ 'date' => $data_date,
+ 'narration' => $data_narration,
+ 'tag_id' => $data_tag,
+ );
+ if ( ! $this->db->where('id', $voucher_id)->update('vouchers', $update_data))
{
$this->db->trans_rollback();
$this->messages->add('Error updating Voucher A/C.', 'error');
@@ -820,7 +849,7 @@ class Voucher extends Controller {
}
/* TODO : Deleting all old ledger data, Bad solution */
- if ( ! $this->db->query("DELETE FROM voucher_items WHERE voucher_id = ?", array($voucher_id)))
+ if ( ! $this->db->delete('voucher_items', array('voucher_id' => $voucher_id)))
{
$this->db->trans_rollback();
$this->messages->add('Error deleting old Ledger A/C\'s', 'error');
@@ -853,7 +882,13 @@ class Voucher extends Controller {
$cr_total += $data_all_cr_amount[$id];
}
- if ( ! $this->db->query("INSERT INTO voucher_items (voucher_id, ledger_id, amount, dc) VALUES (?, ?, ?, ?)", array($voucher_id, $data_ledger_id, $data_amount, $data_ledger_dc)))
+ $insert_ledger_data = array(
+ 'voucher_id' => $voucher_id,
+ 'ledger_id' => $data_ledger_id,
+ 'amount' => $data_amount,
+ 'dc' => $data_ledger_dc,
+ );
+ if ( ! $this->db->insert('voucher_items', $insert_ledger_data))
{
$this->db->trans_rollback();
$this->messages->add('Error updating Ledger A/C ' . $data_ledger_id . '.', 'error');
@@ -864,7 +899,11 @@ class Voucher extends Controller {
}
/* Updating Debit and Credit Total in vouchers table */
- if ( ! $this->db->query("UPDATE vouchers SET dr_total = ?, cr_total = ? WHERE id = ?", array($dr_total, $cr_total, $voucher_id)))
+ $update_data = array(
+ 'dr_total' => $dr_total,
+ 'cr_total' => $cr_total,
+ );
+ if ( ! $this->db->where('id', $voucher_id)->update('vouchers', $update_data))
{
$this->db->trans_rollback();
$this->messages->add('Error updating voucher total.', 'error');
@@ -937,7 +976,7 @@ class Voucher extends Controller {
}
$this->db->trans_start();
- if ( ! $this->db->query("DELETE FROM voucher_items WHERE voucher_id = ?", array($voucher_id)))
+ if ( ! $this->db->delete('voucher_items', array('voucher_id' => $voucher_id)))
{
$this->db->trans_rollback();
$this->messages->add('Error deleting Voucher - Ledgers entry.', 'error');
@@ -945,7 +984,7 @@ class Voucher extends Controller {
redirect('voucher/' . $voucher_type . '/' . $voucher_id);
return;
}
- if ( ! $this->db->query("DELETE FROM vouchers WHERE id = ?", array($voucher_id)))
+ if ( ! $this->db->delete('vouchers', array('id' => $voucher_id)))
{
$this->db->trans_rollback();
$this->messages->add('Error deleting Voucher entry.', 'error');
@@ -992,8 +1031,8 @@ class Voucher extends Controller {
$data['voucher_narration'] = $cur_voucher->narration;
/* Getting Ledger details */
- $ledger_q = $this->db->query("SELECT * FROM voucher_items WHERE voucher_id = ? ORDER BY dc DESC", $voucher_id);
-
+ $this->db->from('voucher_items')->where('voucher_id', $voucher_id)->order_by('dc', 'desc');
+ $ledger_q = $this->db->get();
$counter = 0;
$data['ledger_data'] = array();
if ($ledger_q->num_rows() > 0)
@@ -1048,8 +1087,8 @@ class Voucher extends Controller {
$data['voucher_narration'] = $cur_voucher->narration;
/* Getting Ledger details */
- $ledger_q = $this->db->query("SELECT * FROM voucher_items WHERE voucher_id = ? ORDER BY dc DESC", $voucher_id);
-
+ $this->db->from('voucher_items')->where('voucher_id', $voucher_id)->order_by('dc', 'desc');
+ $ledger_q = $this->db->get();
$counter = 0;
$data['ledger_data'] = array();
if ($ledger_q->num_rows() > 0)
@@ -1128,8 +1167,8 @@ class Voucher extends Controller {
$voucher_data['voucher_narration'] = $cur_voucher->narration;
/* Getting Ledger details */
- $ledger_q = $this->db->query("SELECT * FROM voucher_items WHERE voucher_id = ? ORDER BY dc DESC", $voucher_id);
-
+ $this->db->from('voucher_items')->where('voucher_id', $voucher_id)->order_by('dc', 'desc');
+ $ledger_q = $this->db->get();
$counter = 0;
$voucher_data['ledger_data'] = array();
if ($ledger_q->num_rows() > 0)
commit 9cdca44098cdbd3fad9d0cdd1524a47ce9eeefdc
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 12 11:54:11 2011 +0530
Converted welcome controller to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/welcome.php b/system/application/controllers/welcome.php
index 8e6ec62..df0c301 100644
--- a/system/application/controllers/welcome.php
+++ b/system/application/controllers/welcome.php
@@ -17,7 +17,8 @@ class Welcome extends Controller {
$this->template->set('add_javascript', array("js/raphael.js", "js/jquery.enumerable.js", "js/jquery.tufte-graph.js"));
/* Bank and Cash Ledger accounts */
- $bank_q = $this->db->query("SELECT * FROM ledgers WHERE type = ?", array('B'));
+ $this->db->from('ledgers')->where('type', 'B');
+ $bank_q = $this->db->get();
if ($bank_q->num_rows() > 0)
{
foreach ($bank_q->result() as $row)
commit 5482641f04f98faaa256f00223fab8da3e63b0b6
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 12 11:52:31 2011 +0530
Converted report controller to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/report.php b/system/application/controllers/report.php
index 3c243e6..a7613a3 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -222,7 +222,9 @@ class Report extends Controller {
$cur_balance -= $opbalance;
$counter++;
- $ledgerst_q = $this->db->query("SELECT vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc FROM vouchers join voucher_items on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? ORDER BY vouchers.date ASC, vouchers.number ASC", array($ledger_id));
+ $this->db->select('vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc');
+ $this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->order_by('vouchers.date', 'asc')->order_by('vouchers.number', 'asc');
+ $ledgerst_q = $this->db->get();
foreach ($ledgerst_q->result() as $row)
{
$ledgerst[$counter][0] = date_mysql_to_php($row->vdate);
@@ -231,10 +233,10 @@ class Report extends Controller {
/* Opposite voucher name */
if ($row->ldc == "D")
{
-
- if ($opp_voucher_name_q = $this->db->query("SELECT * FROM voucher_items WHERE voucher_id = ? AND dc = ?", array($row->vid, "C")))
+ $this->db->from('voucher_items')->where('voucher_id', $row->vid)->where('dc', 'C');
+ $opp_voucher_name_q = $this->db->get();
+ if ($opp_voucher_name_d = $opp_voucher_name_q->row())
{
- $opp_voucher_name_d = $opp_voucher_name_q->row();
$opp_ledger_name = $this->Ledger_model->get_name($opp_voucher_name_d->ledger_id);
if ($opp_voucher_name_q->num_rows() > 1)
{
@@ -244,9 +246,10 @@ class Report extends Controller {
}
}
} else {
- if ($opp_voucher_name_q = $this->db->query("SELECT * FROM voucher_items WHERE voucher_id = ? AND dc = ?", array($row->vid, "D")))
+ $this->db->from('voucher_items')->where('voucher_id', $row->vid)->where('dc', 'D');
+ $opp_voucher_name_q = $this->db->get();
+ if ($opp_voucher_name_d = $opp_voucher_name_q->row())
{
- $opp_voucher_name_d = $opp_voucher_name_q->row();
$opp_ledger_name = $this->Ledger_model->get_name($opp_voucher_name_d->ledger_id);
if ($opp_voucher_name_q->num_rows() > 1)
{
@@ -431,7 +434,8 @@ class Report extends Controller {
/* Gross P/L : Expenses */
$gross_expense_total = 0;
- $gross_expense_list_q = $this->db->query("SELECT * FROM groups WHERE parent_id = 4 AND affects_gross = 1");
+ $this->db->from('groups')->where('parent_id', 4)->where('affects_gross', 1);
+ $gross_expense_list_q = $this->db->get();
foreach ($gross_expense_list_q->result() as $row)
{
$gross_expense = new Accountlist();
@@ -444,7 +448,8 @@ class Report extends Controller {
/* Gross P/L : Incomes */
$gross_income_total = 0;
- $gross_income_list_q = $this->db->query("SELECT * FROM groups WHERE parent_id = 3 AND affects_gross = 1");
+ $this->db->from('groups')->where('parent_id', 3)->where('affects_gross', 1);
+ $gross_income_list_q = $this->db->get();
foreach ($gross_income_list_q->result() as $row)
{
$gross_income = new Accountlist();
@@ -493,8 +498,8 @@ class Report extends Controller {
/* Net P/L : Expenses */
$net_expense_total = 0;
- $net_expense_list_q = $this->db->query("SELECT * FROM groups WHERE parent_id = 4 AND affects_gross != 1");
-
+ $this->db->from('groups')->where('parent_id', 4)->where('affects_gross !=', 1);
+ $net_expense_list_q = $this->db->get();
foreach ($net_expense_list_q->result() as $row)
{
$net_expense = new Accountlist();
@@ -507,7 +512,8 @@ class Report extends Controller {
/* Net P/L : Incomes */
$net_income_total = 0;
- $net_income_list_q = $this->db->query("SELECT * FROM groups WHERE parent_id = 3 AND affects_gross != 1");
+ $this->db->from('groups')->where('parent_id', 3)->where('affects_gross !=', 1);
+ $net_income_list_q = $this->db->get();
foreach ($net_income_list_q->result() as $row)
{
$net_income = new Accountlist();
commit 89d3cad6272e125f711389e8ccf132967663a703
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 12 11:29:47 2011 +0530
Converted ledger controller to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/ledger.php b/system/application/controllers/ledger.php
index 50a53c5..be0fad7 100644
--- a/system/application/controllers/ledger.php
+++ b/system/application/controllers/ledger.php
@@ -95,7 +95,8 @@ class Ledger extends Controller {
}
/* Check if parent group id present */
- if ($this->db->query("SELECT id FROM groups WHERE id = ?", array($data_group_id))->num_rows() < 1)
+ $this->db->select('id')->from('groups')->where('id', $data_group_id);
+ if ($this->db->get()->num_rows() < 1)
{
$this->messages->add('Invalid Parent group.', 'error');
$this->template->load('template', 'ledger/add', $data);
@@ -108,7 +109,14 @@ class Ledger extends Controller {
}
$this->db->trans_start();
- if ( ! $this->db->query("INSERT INTO ledgers (name, group_id, op_balance, op_balance_dc, type) VALUES (?, ?, ?, ?, ?)", array($data_name, $data_group_id, $data_op_balance, $data_op_balance_dc, $data_ledger_type_cashbank)))
+ $insert_data = array(
+ 'name' => $data_name,
+ 'group_id' => $data_group_id,
+ 'op_balance' => $data_op_balance,
+ 'op_balance_dc' => $data_op_balance_dc,
+ 'type' => $data_ledger_type_cashbank,
+ );
+ if ( ! $this->db->insert('ledgers', $insert_data))
{
$this->db->trans_rollback();
$this->messages->add('Error addding ' . $data_name . ' - Ledger A/C.', 'error');
@@ -157,7 +165,8 @@ class Ledger extends Controller {
}
/* Loading current group */
- $ledger_data_q = $this->db->query("SELECT * FROM ledgers WHERE id = ?", array($id));
+ $this->db->from('ledgers')->where('id', $id);
+ $ledger_data_q = $this->db->get();
if ($ledger_data_q->num_rows() < 1)
{
$this->messages->add('Invalid Ledger A/C.', 'error');
@@ -230,7 +239,8 @@ class Ledger extends Controller {
}
/* Check if parent group id present */
- if ($this->db->query("SELECT id FROM groups WHERE id = ?", array($data_group_id))->num_rows() < 1)
+ $this->db->select('id')->from('groups')->where('id', $data_group_id);
+ if ($this->db->get()->num_rows() < 1)
{
$this->messages->add('Invalid Parent group.', 'error');
$this->template->load('template', 'ledger/edit', $data);
@@ -243,7 +253,14 @@ class Ledger extends Controller {
}
$this->db->trans_start();
- if ( ! $this->db->query("UPDATE ledgers SET name = ?, group_id = ?, op_balance = ?, op_balance_dc = ?, type = ? WHERE id = ?", array($data_name, $data_group_id, $data_op_balance, $data_op_balance_dc, $data_ledger_type_cashbank, $data_id)))
+ $update_data = array(
+ 'name' => $data_name,
+ 'group_id' => $data_group_id,
+ 'op_balance' => $data_op_balance,
+ 'op_balance_dc' => $data_op_balance_dc,
+ 'type' => $data_ledger_type_cashbank,
+ );
+ if ( ! $this->db->where('id', $data_id)->update('ledgers', $update_data))
{
$this->db->trans_rollback();
$this->messages->add('Error updating ' . $data_name . ' - Ledger A/C.', 'error');
@@ -288,8 +305,8 @@ class Ledger extends Controller {
redirect('account');
return;
}
- $data_present_q = $this->db->query("SELECT * FROM voucher_items WHERE ledger_id = ?", array($id));
- if ($data_present_q->num_rows() > 0)
+ $this->db->from('voucher_items')->where('ledger_id', $id);
+ if ($this->db->get()->num_rows() > 0)
{
$this->messages->add('Cannot delete non-empty Ledger A/C.', 'error');
redirect('account');
@@ -297,7 +314,8 @@ class Ledger extends Controller {
}
/* Get the ledger details */
- $ledger_q = $this->db->query("SELECT * FROM ledgers WHERE id = ?", array($id));
+ $this->db->from('ledgers')->where('id', $id);
+ $ledger_q = $this->db->get();
if ($ledger_q->num_rows() < 1)
{
$this->messages->add('Invalid Ledger A/C.', 'error');
@@ -309,7 +327,7 @@ class Ledger extends Controller {
/* Deleting ledger */
$this->db->trans_start();
- if ( ! $this->db->query("DELETE FROM ledgers WHERE id = ?", array($id)))
+ if ( ! $this->db->delete('ledgers', array('id' => $id)))
{
$this->db->trans_rollback();
$this->messages->add('Error deleting ' . $ledger_data->name . ' - Ledger A/C.', 'error');
commit 6588186a837f3921ec14a174b7a9b273c838b8c1
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 11 23:10:54 2011 +0530
Converted pending tag controller to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/tag.php b/system/application/controllers/tag.php
index 86c66c3..2bd2f52 100644
--- a/system/application/controllers/tag.php
+++ b/system/application/controllers/tag.php
@@ -168,7 +168,8 @@ class Tag extends Controller {
}
/* Loading current group */
- $tag_data_q = $this->db->query("SELECT * FROM tags WHERE id = ?", array($id));
+ $this->db->from('tags')->where('id', $id);
+ $tag_data_q = $this->db->get();
if ($tag_data_q->num_rows() < 1)
{
$this->messages->add('Invalid Tag.', 'error');
commit 6dc297b7d050d86c28dd1526e12e6ac5eee05720
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 11 23:05:46 2011 +0530
Converted tag controller to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/tag.php b/system/application/controllers/tag.php
index 34d4095..86c66c3 100644
--- a/system/application/controllers/tag.php
+++ b/system/application/controllers/tag.php
@@ -101,7 +101,12 @@ class Tag extends Controller {
$data_tag_background = strtoupper($data_tag_background);
$this->db->trans_start();
- if ( ! $this->db->query("INSERT INTO tags (title, color, background) VALUES (?, ?, ?)", array($data_tag_title, $data_tag_color, $data_tag_background)))
+ $insert_data = array(
+ 'title' => $data_tag_title,
+ 'color' => $data_tag_color,
+ 'background' => $data_tag_background,
+ );
+ if ( ! $this->db->insert('tags', $insert_data))
{
$this->db->trans_rollback();
$this->messages->add('Error addding ' . $data_tag_title . ' - Tag.', 'error');
@@ -224,7 +229,12 @@ class Tag extends Controller {
$data_tag_background = strtoupper($data_tag_background);
$this->db->trans_start();
- if ( ! $this->db->query("UPDATE tags SET title = ?, color = ?, background = ? WHERE id = ?", array($data_tag_title, $data_tag_color, $data_tag_background, $id)))
+ $update_data = array(
+ 'title' => $data_tag_title,
+ 'color' => $data_tag_color,
+ 'background' => $data_tag_background,
+ );
+ if ( ! $this->db->where('id', $id)->update('tags', $update_data))
{
$this->db->trans_rollback();
$this->messages->add('Error updating ' . $data_tag_title . ' - Tag.', 'error');
@@ -269,7 +279,8 @@ class Tag extends Controller {
redirect('tag');
return;
}
- $data_valid_q = $this->db->query("SELECT * FROM tags WHERE id = ?", array($id));
+ $this->db->from('tags')->where('id', $id);
+ $data_valid_q = $this->db->get();
if ($data_valid_q->num_rows() < 1)
{
$this->messages->add('Invalid Tag.', 'error');
@@ -280,7 +291,10 @@ class Tag extends Controller {
/* Deleting Tag */
$this->db->trans_start();
- if ( ! $this->db->query("UPDATE vouchers SET tag_id = 0 WHERE tag_id = ?", array($id)))
+ $update_data = array(
+ 'tag_id' => 0,
+ );
+ if ( ! $this->db->where('tag_id', $id)->update('vouchers', $update_data))
{
$this->db->trans_rollback();
$this->messages->add('Error deleting Tag from Vouchers.', 'error');
@@ -288,7 +302,7 @@ class Tag extends Controller {
redirect('tag');
return;
} else {
- if ( ! $this->db->query("DELETE FROM tags WHERE id = ?", array($id)))
+ if ( ! $this->db->delete('tags', array('id' => $id)))
{
$this->db->trans_rollback();
$this->messages->add('Error deleting Tag.', 'error');
commit c8d1ee943c19655081da4044b07f5a2af941e4af
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 11 22:50:05 2011 +0530
Converted log controller to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/log.php b/system/application/controllers/log.php
index 3746d74..c334cbf 100644
--- a/system/application/controllers/log.php
+++ b/system/application/controllers/log.php
@@ -36,7 +36,7 @@ class Log extends Controller {
return;
}
- if ($this->db->query('DELETE FROM logs'))
+ if ($this->db->truncate('logs'))
{
$this->messages->add('Log cleared.', 'success');
redirect('log');
commit 24a8df7ecef6641b8036e55ffcaef27403c61b5b
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 11 22:44:27 2011 +0530
Converted setting controller to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/setting.php b/system/application/controllers/setting.php
index 2100918..5050139 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -150,7 +150,16 @@ class Setting extends Controller {
/* Update settings */
$this->db->trans_start();
- if ( ! $this->db->query("UPDATE settings SET name = ?, address = ?, email = ?, currency_symbol = ?, date_format = ?, timezone = ?, account_locked = ? WHERE id = 1", array($data_account_name, $data_account_address, $data_account_email, $data_account_currency, $data_account_date, $data_account_timezone, $data_account_locked)))
+ $update_data = array(
+ 'name' => $data_account_name,
+ 'address' => $data_account_address,
+ 'email' => $data_account_email,
+ 'currency_symbol' => $data_account_currency,
+ 'date_format' => $data_account_date,
+ 'timezone' => $data_account_timezone,
+ 'account_locked' => $data_account_locked,
+ );
+ if ( ! $this->db->where('id', 1)->update('settings', $update_data))
{
$this->db->trans_rollback();
$this->messages->add('Error updating account settings.', 'error');
@@ -420,7 +429,8 @@ class Setting extends Controller {
$cf_status = TRUE;
/* Importing Groups */
- $group_q = $this->db->query("SELECT * FROM groups ORDER BY id");
+ $this->db->from('groups')->order_by('id', 'asc');
+ $group_q = $this->db->get();
foreach ($group_q->result() as $row)
{
if ( ! $newacc->query("INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (?, ?, ?, ?)", array($row->id, $row->parent_id, $row->name, $row->affects_gross)))
@@ -438,7 +448,8 @@ class Setting extends Controller {
$cf_ledgers = array_merge($assets->get_ledger_ids(), $liability->get_ledger_ids());
/* Importing Ledgers */
- $ledger_q = $this->db->query("SELECT * FROM ledgers ORDER BY id");
+ $this->db->from('ledgers')->order_by('id', 'asc');
+ $ledger_q = $this->db->get();
foreach ($ledger_q->result() as $row)
{
/* CF only Assets and Liability with Closing Balance */
@@ -469,7 +480,8 @@ class Setting extends Controller {
}
/* Importing Tags */
- $tag_q = $this->db->query("SELECT * FROM tags ORDER BY id");
+ $this->db->from('tags')->order_by('id', 'asc');
+ $tag_q = $this->db->get();
foreach ($tag_q->result() as $row)
{
if ( ! $newacc->query("INSERT INTO tags (id, title, color, background) VALUES (?, ?, ?, ?)", array($row->id, $row->title, $row->color, $row->background)))
@@ -592,7 +604,14 @@ class Setting extends Controller {
/* Update settings */
$this->db->trans_start();
- if ( ! $this->db->query("UPDATE settings SET email_protocol = ?, email_host = ?, email_port = ?, email_username = ?, email_password = ? WHERE id = 1", array($data_email_protocol, $data_email_host, $data_email_port, $data_email_username, $data_email_password)))
+ $update_data = array(
+ 'email_protocol' => $data_email_protocol,
+ 'email_host' => $data_email_host,
+ 'email_port' => $data_email_port,
+ 'email_username' => $data_email_username,
+ 'email_password' => $data_email_password,
+ );
+ if ( ! $this->db->where('id', 1)->update('settings', $update_data))
{
$this->db->trans_rollback();
$this->messages->add('Error updating email settings.', 'error');
@@ -784,7 +803,17 @@ class Setting extends Controller {
/* Update settings */
$this->db->trans_start();
- if ( ! $this->db->query("UPDATE settings SET print_paper_height = ?, print_paper_width = ?, print_margin_top = ?, print_margin_bottom = ?, print_margin_left = ?, print_margin_right = ?, print_orientation = ?, print_page_format = ? WHERE id = 1", array($data_paper_height, $data_paper_width, $data_margin_top, $data_margin_bottom, $data_margin_left, $data_margin_right, $data_orientation, $data_output_format)))
+ $update_data = array(
+ 'print_paper_height' => $data_paper_height,
+ 'print_paper_width' => $data_paper_width,
+ 'print_margin_top' => $data_margin_top,
+ 'print_margin_bottom' => $data_margin_bottom,
+ 'print_margin_left' => $data_margin_left,
+ 'print_margin_right' => $data_margin_right,
+ 'print_orientation' => $data_orientation,
+ 'print_page_format' => $data_output_format,
+ );
+ if ( ! $this->db->where('id', 1)->update('settings', $update_data))
{
$this->db->trans_rollback();
$this->messages->add('Error updating printer settings.', 'error');
@@ -906,7 +935,13 @@ class Setting extends Controller {
/* Update settings */
$this->db->trans_start();
- if ( ! $this->db->query("UPDATE settings SET receipt_voucher_prefix = ?, payment_voucher_prefix = ?, contra_voucher_prefix = ?, journal_voucher_prefix = ? WHERE id = 1", array($data_receipt_prefix, $data_payment_prefix, $data_contra_prefix, $data_journal_prefix)))
+ $update_data = array(
+ 'receipt_voucher_prefix' => $data_receipt_prefix,
+ 'payment_voucher_prefix' => $data_payment_prefix,
+ 'contra_voucher_prefix' => $data_contra_prefix,
+ 'journal_voucher_prefix' => $data_journal_prefix,
+ );
+ if ( ! $this->db->where('id', 1)->update('settings', $update_data))
{
$this->db->trans_rollback();
$this->messages->add('Error updating voucher settings.', 'error');
commit 3af115cdfa46bee667a00096c377f049613838a9
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 11 19:52:35 2011 +0530
Converted group controller to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/group.php b/system/application/controllers/group.php
index 3ecf548..12a8154 100644
--- a/system/application/controllers/group.php
+++ b/system/application/controllers/group.php
@@ -72,7 +72,8 @@ class Group extends Controller {
$data_parent_id = $this->input->post('group_parent', TRUE);
/* Check if parent group id present */
- if ($this->db->query("SELECT id FROM groups WHERE id = ?", array($data_parent_id))->num_rows() < 1)
+ $this->db->select('id')->from('groups')->where('id', $data_parent_id);
+ if ($this->db->get()->num_rows() < 1)
{
$this->messages->add('Invalid Parent group.', 'error');
$this->template->load('template', 'group/add', $data);
@@ -92,7 +93,12 @@ class Group extends Controller {
}
$this->db->trans_start();
- if ( ! $this->db->query("INSERT INTO groups (name, parent_id, affects_gross) VALUES (?, ?, ?)", array($data_name, $data_parent_id, $data_affects_gross)))
+ $insert_data = array(
+ 'name' => $data_name,
+ 'parent_id' => $data_parent_id,
+ 'affects_gross' => $data_affects_gross,
+ );
+ if ( ! $this->db->insert('groups', $insert_data))
{
$this->db->trans_rollback();
$this->messages->add('Error addding ' . $data_name . ' - Group A/C.', 'error');
@@ -145,7 +151,8 @@ class Group extends Controller {
}
/* Loading current group */
- $group_data_q = $this->db->query("SELECT * FROM groups WHERE id = ?", array($id));
+ $this->db->from('groups')->where('id', $id);
+ $group_data_q = $this->db->get();
if ($group_data_q->num_rows() < 1)
{
$this->messages->add('Invalid Group A/C.', 'error');
@@ -193,7 +200,8 @@ class Group extends Controller {
$data_id = $id;
/* Check if parent group id present */
- if ($this->db->query("SELECT id FROM groups WHERE id = ?", array($data_parent_id))->num_rows() < 1)
+ $this->db->select('id')->from('groups')->where('id', $data_parent_id);
+ if ($this->db->get()->num_rows() < 1)
{
$this->messages->add('Invalid Parent group.', 'error');
$this->template->load('template', 'group/edit', $data);
@@ -221,7 +229,12 @@ class Group extends Controller {
}
$this->db->trans_start();
- if ( ! $this->db->query("UPDATE groups SET name = ?, parent_id = ?, affects_gross = ? WHERE id = ?", array($data_name, $data_parent_id, $data_affects_gross, $data_id)))
+ $update_data = array(
+ 'name' => $data_name,
+ 'parent_id' => $data_parent_id,
+ 'affects_gross' => $data_affects_gross,
+ );
+ if ( ! $this->db->where('id', $data_id)->update('groups', $update_data))
{
$this->db->trans_rollback();
$this->messages->add('Error updating ' . $data_name . ' - Group A/C.', 'error');
@@ -270,15 +283,15 @@ class Group extends Controller {
redirect('account');
return;
}
- $data_present_q = $this->db->query("SELECT * FROM groups WHERE parent_id = ?", array($id));
- if ($data_present_q->num_rows() > 0)
+ $this->db->from('groups')->where('parent_id', $id);
+ if ($this->db->get()->num_rows() > 0)
{
$this->messages->add('Cannot delete non-empty Group A/C.', 'error');
redirect('account');
return;
}
- $data_present_q = $this->db->query("SELECT * FROM ledgers WHERE group_id = ?", array($id));
- if ($data_present_q->num_rows() > 0)
+ $this->db->from('ledgers')->where('group_id', $id);
+ if ($this->db->get()->num_rows() > 0)
{
$this->messages->add('Cannot delete non-empty Group A/C.', 'error');
redirect('account');
@@ -286,7 +299,8 @@ class Group extends Controller {
}
/* Get the group details */
- $group_q = $this->db->query("SELECT * FROM groups WHERE id = ?", array($id));
+ $this->db->from('groups')->where('id', $id);
+ $group_q = $this->db->get();
if ($group_q->num_rows() < 1)
{
$this->messages->add('Invalid Group A/C.', 'error');
@@ -298,7 +312,7 @@ class Group extends Controller {
/* Deleting group */
$this->db->trans_start();
- if ( ! $this->db->query("DELETE FROM groups WHERE id = ?", array($id)))
+ if ( ! $this->db->delete('groups', array('id' => $id)))
{
$this->db->trans_rollback();
$this->messages->add('Error deleting ' . $group_data->name . ' - Group A/C.', 'error');
diff --git a/system/application/controllers/log.php b/system/application/controllers/log.php
index bd8f8e5..3746d74 100644
--- a/system/application/controllers/log.php
+++ b/system/application/controllers/log.php
@@ -15,7 +15,6 @@ class Log extends Controller {
redirect('');
return;
}
-
return;
}
commit dc6102b0ba418906461f458d14287d4eb761ae8e
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 11 15:21:33 2011 +0530
Converted all views to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/views/log/index.php b/system/application/views/log/index.php
index 26bb9ba..a011271 100644
--- a/system/application/views/log/index.php
+++ b/system/application/views/log/index.php
@@ -1,5 +1,6 @@
<?php
- $logs_q = $this->db->query('SELECT * FROM logs ORDER BY id DESC');
+ $this->db->from('logs')->order_by('id', 'desc');
+ $logs_q = $this->db->get();
echo "<table border=0 class=\"simple-table\">";
echo "<thead><tr><th width=\"90\">Date</th><th>Host IP</th><th>User</th><th>Message</th><th width=\"30\">URL</th><th>Browser</th></tr></thead>";
foreach ($logs_q->result() as $row)
diff --git a/system/application/views/report/ledgerst.php b/system/application/views/report/ledgerst.php
index 67a6969..4c0aa55 100644
--- a/system/application/views/report/ledgerst.php
+++ b/system/application/views/report/ledgerst.php
@@ -23,7 +23,7 @@
$config['num_links'] = 10;
$config['per_page'] = $pagination_counter;
$config['uri_segment'] = 4;
- $config['total_rows'] = $this->db->query('SELECT * FROM vouchers join voucher_items on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ?', array($ledger_id))->num_rows();
+ $config['total_rows'] = (int)$this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->count_all_results();
$config['full_tag_open'] = '<ul id="pagination-flickr">';
$config['full_close_open'] = '</ul>';
$config['num_tag_open'] = '<li>';
@@ -61,10 +61,14 @@
echo "</table>";
echo "<br />";
if ( ! $print_preview) {
- $ledgerst_q = $this->db->query("SELECT vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc FROM vouchers join voucher_items on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? ORDER BY vouchers.date ASC, vouchers.number ASC LIMIT ${page_count}, ${pagination_counter}", array($ledger_id));
+ $this->db->select('vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc');
+ $this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->order_by('vouchers.date', 'asc')->order_by('vouchers.number', 'asc')->limit($pagination_counter, $page_count);
+ $ledgerst_q = $this->db->get();
} else {
$page_count = 0;
- $ledgerst_q = $this->db->query("SELECT vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc FROM vouchers join voucher_items on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? ORDER BY vouchers.date ASC, vouchers.number ASC", array($ledger_id));
+ $this->db->select('vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc');
+ $this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->order_by('vouchers.date', 'asc')->order_by('vouchers.number', 'asc');
+ $ledgerst_q = $this->db->get();
}
echo "<table border=0 cellpadding=5 class=\"simple-table ledgerst-table\">";
@@ -95,8 +99,9 @@
}
/* Calculating previous balance */
- $prevbal_q = $this->db->query("SELECT vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc FROM vouchers join voucher_items on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? ORDER BY vouchers.date ASC, vouchers.number ASC LIMIT 0, ${page_count}", array($ledger_id));
-
+ $this->db->select('vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc');
+ $this->db->from('vouchers')->join('voucher_items', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->order_by('vouchers.date', 'asc')->order_by('vouchers.number', 'asc')->limit($page_count, 0);
+ $prevbal_q = $this->db->get();
foreach ($prevbal_q->result() as $row )
{
if ($row->ldc == "D")
@@ -123,10 +128,10 @@
echo "<td>";
if ($row->ldc == "D")
{
-
- if ($opp_voucher_name_q = $this->db->query("SELECT * FROM voucher_items WHERE voucher_id = ? AND dc = ?", array($row->vid, "C")))
+ $this->db->from('voucher_items')->where('voucher_id', $row->vid)->where('dc', 'C');
+ $opp_voucher_name_q = $this->db->get();
+ if ($opp_voucher_name_d = $opp_voucher_name_q->row())
{
- $opp_voucher_name_d = $opp_voucher_name_q->row();
$opp_ledger_name = $this->Ledger_model->get_name($opp_voucher_name_d->ledger_id);
if ($opp_voucher_name_q->num_rows() > 1)
{
@@ -136,9 +141,10 @@
}
}
} else {
- if ($opp_voucher_name_q = $this->db->query("SELECT * FROM voucher_items WHERE voucher_id = ? AND dc = ?", array($row->vid, "D")))
+ $this->db->from('voucher_items')->where('voucher_id', $row->vid)->where('dc', 'D');
+ $opp_voucher_name_q = $this->db->get();
+ if ($opp_voucher_name_d = $opp_voucher_name_q->row())
{
- $opp_voucher_name_d = $opp_voucher_name_q->row();
$opp_ledger_name = $this->Ledger_model->get_name($opp_voucher_name_d->ledger_id);
if ($opp_voucher_name_q->num_rows() > 1)
{
diff --git a/system/application/views/report/profitandloss.php b/system/application/views/report/profitandloss.php
index 8e71052..af734ef 100644
--- a/system/application/views/report/profitandloss.php
+++ b/system/application/views/report/profitandloss.php
@@ -9,7 +9,8 @@
/* Gross P/L : Expenses */
$gross_expense_total = 0;
- $gross_expense_list_q = $this->db->query("SELECT * FROM groups WHERE parent_id = 4 AND affects_gross = 1");
+ $this->db->from('groups')->where('parent_id', 4)->where('affects_gross', 1);
+ $gross_expense_list_q = $this->db->get();
echo "<td width=\"" . $left_width . "\">";
echo "<table border=0 cellpadding=5 class=\"simple-table profit-loss-table\" width=\"100%\">";
echo "<thead><tr><th>Expenses (Gross)</th><th align=\"right\">Amount</th></tr></thead>";
@@ -25,7 +26,8 @@
/* Gross P/L : Incomes */
$gross_income_total = 0;
- $gross_income_list_q = $this->db->query("SELECT * FROM groups WHERE parent_id = 3 AND affects_gross = 1");
+ $this->db->from('groups')->where('parent_id', 3)->where('affects_gross' , 1);
+ $gross_income_list_q = $this->db->get();
echo "<td width=\"" . $right_width . "\">";
echo "<table border=0 cellpadding=5 class=\"simple-table profit-loss-table\" width=\"100%\">";
echo "<thead><tr><th>Incomes (Gross)</th><th align=\"right\">Amount</th></tr></thead>";
@@ -112,7 +114,8 @@
/* Net P/L : Expenses */
$net_expense_total = 0;
- $net_expense_list_q = $this->db->query("SELECT * FROM groups WHERE parent_id = 4 AND affects_gross != 1");
+ $this->db->from('groups')->where('parent_id', 4)->where('affects_gross !=', 1);
+ $net_expense_list_q = $this->db->get();
echo "<tr valign=\"top\">";
echo "<td>";
echo "<table border=0 cellpadding=5 class=\"simple-table profit-loss-table\" width=\"100%\">";
@@ -129,7 +132,8 @@
/* Net P/L : Incomes */
$net_income_total = 0;
- $net_income_list_q = $this->db->query("SELECT * FROM groups WHERE parent_id = 3 AND affects_gross != 1");
+ $this->db->from('groups')->where('parent_id', 3)->where('affects_gross !=', 1);
+ $net_income_list_q = $this->db->get();
echo "<td>";
echo "<table border=0 cellpadding=5 class=\"simple-table profit-loss-table\" width=\"100%\">";
echo "<thead><tr><th>Incomes (Net)</th><th align=\"right\">Amount</th></tr></thead>";
diff --git a/system/application/views/tag/index.php b/system/application/views/tag/index.php
index a67ea9f..307e7d9 100644
--- a/system/application/views/tag/index.php
+++ b/system/application/views/tag/index.php
@@ -1,5 +1,6 @@
<?php
- $tags_q = $this->db->query("SELECT * FROM tags ORDER BY title ASC");
+ $this->db->from('tags')->order_by('title', 'asc');
+ $tags_q = $this->db->get();
echo "<table border=0 cellpadding=5 class=\"simple-table tag-table\">";
echo "<thead><tr><th>Title</th><th>Color</th><th></th></tr></thead>";
echo "<tbody>";
commit fefa12e2681ce4adc0ac0cfc29c1698e26384625
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 11 12:30:58 2011 +0530
Converted voucher model to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/models/voucher_model.php b/system/application/models/voucher_model.php
index 595b438..56d7ee8 100644
--- a/system/application/models/voucher_model.php
+++ b/system/application/models/voucher_model.php
@@ -10,17 +10,23 @@ class Voucher_model extends Model {
function next_voucher_number($type_string)
{
$type_number = v_to_n($type_string);
- $last_no_q = $this->db->query('SELECT MAX(number) AS lastno FROM vouchers WHERE type = ?', $type_number);
- $row = $last_no_q->row();
- $last_no = (int)$row->lastno;
- $last_no++;
- return $last_no;
+ $this->db->select_max('number', 'lastno')->from('vouchers')->where('type', $type_number);
+ $last_no_q = $this->db->get();
+ if ($row = $last_no_q->row())
+ {
+ $last_no = (int)$row->lastno;
+ $last_no++;
+ return $last_no;
+ } else {
+ return 1;
+ }
}
- function get_voucher($voucher_id, $voucher_type_string)
+ function get_voucher($voucher_id, $type_string)
{
- $voucher_q = $this->db->query('SELECT * FROM vouchers WHERE id = ? AND type = ? LIMIT 1', array($voucher_id, v_to_n($voucher_type_string)));
- $row = $voucher_q->row();
- return $row;
+ $type_number = v_to_n($type_string);
+ $this->db->from('vouchers')->where('id', $voucher_id)->where('type', $type_number)->limit(1);
+ $voucher_q = $this->db->get();
+ return $voucher_q->row();
}
}
commit e37e1c8ba9edb5a91434eec9025213979cc8b5bf
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 11 12:30:23 2011 +0530
Converted setting model to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/models/setting_model.php b/system/application/models/setting_model.php
index 97e1214..4d11ce5 100644
--- a/system/application/models/setting_model.php
+++ b/system/application/models/setting_model.php
@@ -9,7 +9,8 @@ class Setting_model extends Model {
function get_current()
{
- $account_q = $this->db->query('SELECT * FROM settings WHERE id = 1');
+ $this->db->from('settings')->where('id', 1);
+ $account_q = $this->db->get();
return $account_q->row();
}
}
commit fd0033582f92de60dd55b99cdd6193149a36d01d
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 11 11:56:25 2011 +0530
Converted tag model to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/models/tag_model.php b/system/application/models/tag_model.php
index 15d1510..3ddf978 100644
--- a/system/application/models/tag_model.php
+++ b/system/application/models/tag_model.php
@@ -12,7 +12,8 @@ class Tag_model extends Model {
$options = array();
if ($allow_none)
$options[0] = "(None)";
- $tag_q = $this->db->query('SELECT * FROM tags ORDER BY title ASC');
+ $this->db->from('tags')->order_by('title', 'asc');
+ $tag_q = $this->db->get();
foreach ($tag_q->result() as $row)
{
$options[$row->id] = $row->title;
@@ -24,35 +25,35 @@ class Tag_model extends Model {
{
if ($tag_id < 1)
return "";
- $tag_q = $this->db->query("SELECT * FROM tags WHERE id = ?", array($tag_id));
+ $this->db->from('tags')->where('id', $tag_id)->limit(1);
+ $tag_q = $this->db->get();
if ($tag = $tag_q->row())
- {
return "<span class=\"tags\" style=\"color:#" . $tag->color . "; background-color:#" . $tag->background . "\">" . $tag->title . "</span>";
- }
- return "";
+ else
+ return "";
}
function show_voucher_tag_link($tag_id)
{
if ($tag_id < 1)
return "";
- $tag_q = $this->db->query("SELECT * FROM tags WHERE id = ?", array($tag_id));
+ $this->db->from('tags')->where('id', $tag_id)->limit(1);
+ $tag_q = $this->db->get();
if ($tag = $tag_q->row())
- {
return "<span class=\"tags\" style=\"color:#" . $tag->color . "; background-color:#" . $tag->background . "\">" . anchor("voucher/show/tag/" . $tag->id , $tag->title, array('style' => 'text-decoration:none;color:#' . $tag->color . ';')) . "</span>";
- }
- return "";
+ else
+ return "";
}
function tag_name($tag_id)
{
if ($tag_id < 1)
return "";
- $tag_q = $this->db->query("SELECT * FROM tags WHERE id = ?", array($tag_id));
+ $this->db->from('tags')->where('id', $tag_id)->limit(1);
+ $tag_q = $this->db->get();
if ($tag = $tag_q->row())
- {
return $tag->title;
- }
- return "";
+ else
+ return "";
}
}
commit a4798e9b2a30fd3b5832bbefbc00a5480718cff9
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 11 11:49:17 2011 +0530
Converted ledger model to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/models/ledger_model.php b/system/application/models/ledger_model.php
index c562935..72194fe 100644
--- a/system/application/models/ledger_model.php
+++ b/system/application/models/ledger_model.php
@@ -11,7 +11,8 @@ class Ledger_model extends Model {
{
$options = array();
$options[0] = "(Please Select)";
- $ledger_q = $this->db->query('SELECT * FROM ledgers ORDER BY name ASC');
+ $this->db->from('ledgers')->order_by('name', 'asc');
+ $ledger_q = $this->db->get();
foreach ($ledger_q->result() as $row)
{
$options[$row->id] = $row->name;
@@ -23,7 +24,8 @@ class Ledger_model extends Model {
{
$options = array();
$options[0] = "(Please Select)";
- $ledger_q = $this->db->query('SELECT * FROM ledgers WHERE type = ? ORDER BY name ASC', array('B'));
+ $this->db->from('ledgers')->where('type', 'B')->order_by('name', 'asc');
+ $ledger_q = $this->db->get();
foreach ($ledger_q->result() as $row)
{
$options[$row->id] = $row->name;
@@ -35,7 +37,8 @@ class Ledger_model extends Model {
{
$options = array();
$options[0] = "(Please Select)";
- $ledger_q = $this->db->query('SELECT * FROM ledgers WHERE type != ? ORDER BY name ASC', array('B'));
+ $this->db->from('ledgers')->where('type !=', 'B')->order_by('name', 'asc');
+ $ledger_q = $this->db->get();
foreach ($ledger_q->result() as $row)
{
$options[$row->id] = $row->name;
@@ -45,9 +48,12 @@ class Ledger_model extends Model {
function get_name($ledger_id)
{
- $ledger_q = $this->db->query('SELECT name FROM ledgers WHERE id = ? LIMIT 1', array($ledger_id));
- $ledger = $ledger_q->row();
- return $ledger->name;
+ $this->db->from('ledgers')->where('id', $ledger_id)->limit(1);
+ $ledger_q = $this->db->get();
+ if ($ledger = $ledger_q->row())
+ return $ledger->name;
+ else
+ return "(Error)";
}
function get_ledger_balance($ledger_id)
@@ -66,20 +72,20 @@ class Ledger_model extends Model {
function get_op_balance($ledger_id)
{
- if ($op_bal_q = $this->db->query('SELECT * FROM ledgers WHERE id = ? LIMIT 1', $ledger_id))
- {
- $op_bal = $op_bal_q->row();
+ $this->db->from('ledgers')->where('id', $ledger_id)->limit(1);
+ $op_bal_q = $this->db->get();
+ if ($op_bal = $op_bal_q->row())
return array($op_bal->op_balance, $op_bal->op_balance_dc);
- } else {
+ else
return array(0, "D");
- }
}
function get_diff_op_balance()
{
/* Calculating difference in Opening Balance */
$total_op = 0;
- $ledgers_q = $this->db->query("SELECT * FROM ledgers ORDER BY id");
+ $this->db->from('ledgers')->order_by('id', 'asc');
+ $ledgers_q = $this->db->get();
foreach ($ledgers_q->result() as $row)
{
list ($opbalance, $optype) = $this->get_op_balance($row->id);
@@ -96,16 +102,22 @@ class Ledger_model extends Model {
/* Return debit total as positive value */
function get_dr_total($ledger_id)
{
- $dr_total_q = $this->db->query('SELECT SUM(amount) AS drtotal FROM voucher_items join vouchers on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? AND voucher_items.dc = "D"', $ledger_id);
- $dr_total = $dr_total_q->row();
- return $dr_total->drtotal;
+ $this->db->select_sum('amount', 'drtotal')->from('voucher_items')->join('vouchers', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->where('voucher_items.dc', 'D');
+ $dr_total_q = $this->db->get();
+ if ($dr_total = $dr_total_q->row())
+ return $dr_total->drtotal;
+ else
+ return 0;
}
/* Return credit total as positive value */
function get_cr_total($ledger_id)
{
- $cr_total_q = $this->db->query('SELECT SUM(amount) AS crtotal FROM voucher_items join vouchers on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? AND voucher_items.dc = "C"', $ledger_id);
- $cr_total = $cr_total_q->row();
- return $cr_total->crtotal;
+ $this->db->select_sum('amount', 'crtotal')->from('voucher_items')->join('vouchers', 'vouchers.id = voucher_items.voucher_id')->where('voucher_items.ledger_id', $ledger_id)->where('voucher_items.dc', 'C');
+ $cr_total_q = $this->db->get();
+ if ($cr_total = $cr_total_q->row())
+ return $cr_total->crtotal;
+ else
+ return 0;
}
}
commit 2b8faff7a8d13d2cddab5d905f4c1e67c5aeda64
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 11 11:23:37 2011 +0530
Converted group model to active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/models/group_model.php b/system/application/models/group_model.php
index 4befdb1..bf67a14 100644
--- a/system/application/models/group_model.php
+++ b/system/application/models/group_model.php
@@ -11,10 +11,10 @@ class Group_model extends Model {
{
$options = array();
if ($id == NULL)
- $group_parent_q = $this->db->query('SELECT * FROM groups WHERE id > 0 ORDER BY name');
+ $this->db->from('groups')->where('id >', 0)->order_by('name', 'asc');
else
- $group_parent_q = $this->db->query('SELECT * FROM groups WHERE id > 0 AND id != ? ORDER BY name', array($id));
-
+ $this->db->from('groups')->where('id >', 0)->where('id !=', $id)->order_by('name', 'asc');
+ $group_parent_q = $this->db->get();
foreach ($group_parent_q->result() as $row)
{
$options[$row->id] = $row->name;
@@ -25,7 +25,8 @@ class Group_model extends Model {
function get_ledger_groups()
{
$options = array();
- $group_parent_q = $this->db->query('SELECT * FROM groups WHERE id > 4 ORDER BY name');
+ $this->db->from('groups')->where('id >', 4)->order_by('name', 'asc');
+ $group_parent_q = $this->db->get();
foreach ($group_parent_q->result() as $row)
{
$options[$row->id] = $row->name;
commit b8004c27bca85477c9912c5b575bb52c9b5a9c44
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 10 14:17:09 2011 +0530
Removed RSS Feeds
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/log.php b/system/application/controllers/log.php
index 1071d78..bd8f8e5 100644
--- a/system/application/controllers/log.php
+++ b/system/application/controllers/log.php
@@ -47,31 +47,6 @@ class Log extends Controller {
}
return;
}
-
- function feed()
- {
- $this->load->helper('xml');
- $this->load->helper('text');
-
- /* Check access */
- if ( ! check_access('view log'))
- {
- $this->messages->add('Permission denied.', 'error');
- redirect('');
- return;
- }
-
- $data['feed_name'] = $this->config->item('account_name');
- $data['feed_url'] = base_url();
- $data['page_description'] = 'Accounting feed for ' . $data['feed_name'];
- $data['page_language'] = 'en-en';
- $data['creator_email'] = $this->config->item('account_email');
-
- $data['feed_data'] = $this->db->query('SELECT * FROM logs ORDER BY id DESC');
-
- header("Content-Type: application/rss+xml");
- $this->load->view('rss', $data);
- }
}
/* End of file log.php */
diff --git a/system/application/views/welcome.php b/system/application/views/welcome.php
index 6c43ae4..6198805 100644
--- a/system/application/views/welcome.php
+++ b/system/application/views/welcome.php
@@ -169,7 +169,7 @@ jQuery(document).ready(function () {
<?php if (check_access('view log')) { ?>
<div id="dashboard-log">
<div id="dashboard-recent-log" class="dashboard-log-item">
- <div class="dashboard-log-title">Recent Activity <span class="float-right"><?php echo anchor('log/feed', img(array('src'=> asset_url() . "images/icons/rss.png", 'border' => '0', 'alt' => 'Log Feed', 'width' => '16px',))); ?></span></div>
+ <div class="dashboard-log-title">Recent Activity</div>
<div class="dashboard-log-content">
<?php
if ($logs)
commit d1d0332ea3638570db2ab5891a4c4e90d863ffa0
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 10 14:14:43 2011 +0530
Added numbers to Invalid voucher type messages
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/voucher.php b/system/application/controllers/voucher.php
index 5854a4f..22b5cf1 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -59,7 +59,7 @@ class Voucher extends Controller {
$data['voucher_type'] = "";
break;
default :
- $this->messages->add('Invalid voucher type.', 'error');
+ $this->messages->add('Invalid voucher type(1).', 'error');
redirect('voucher/show/all');
return;
break;
@@ -114,7 +114,7 @@ class Voucher extends Controller {
if (($voucher_type_int < 0) || ($voucher_type_int > 4))
{
- $this->messages->add('Invalid voucher type.', 'error');
+ $this->messages->add('Invalid voucher type(2).', 'error');
redirect('voucher/show/all');
return;
} else if ($voucher_type == "tag") {
@@ -203,7 +203,7 @@ class Voucher extends Controller {
$this->template->set('page_title', 'View Journal Voucher');
break;
default :
- $this->messages->add('Invalid voucher type.', 'error');
+ $this->messages->add('Invalid voucher type(3).', 'error');
redirect('voucher/show/all');
return;
break;
@@ -261,7 +261,7 @@ class Voucher extends Controller {
$this->template->set('page_title', 'New Journal Voucher');
break;
default :
- $this->messages->add('Invalid voucher type.', 'error');
+ $this->messages->add('Invalid voucher type(4).', 'error');
redirect('voucher/show/all');
return;
break;
@@ -587,7 +587,7 @@ class Voucher extends Controller {
$this->template->set('page_title', 'Edit Journal Voucher');
break;
default :
- $this->messages->add('Invalid voucher type.', 'error');
+ $this->messages->add('Invalid voucher type(5).', 'error');
redirect('voucher/show/all');
return;
break;
commit fcae4d2167543d50966b15f5e2bad414abf05390
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 10 12:28:07 2011 +0530
Added Help question for account locked
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/views/help/index.php b/system/application/views/help/index.php
index 9ef9d4d..381741e 100644
--- a/system/application/views/help/index.php
+++ b/system/application/views/help/index.php
@@ -2,6 +2,7 @@
<li><span class="qa-heading">General</span>
<ul>
<li><a href="#general-1" class="anchor-link-a">How do I enable / disable logging ?</a></li>
+ <li><a href="#general-2" class="anchor-link-a">What is account lock and how do I enable / disable it ?</a></li>
</ul>
</li>
<li><span class="qa-heading">Printing</span>
@@ -25,6 +26,12 @@
<div class="qa-answer">You need "administrator" permissions to do this. After logging with "administrator" permissions click on "Administer" link on the top of the page. Then go to "General Settings" and check / uncheck the "Log Messages" option and click on "Update".<br /><br />Note: You can do this manually by opening the "config/settings/general.ini" in a text editor and changing the value of log = "1" or log = "0" to enable or disable logging respectively.</div>
</div>
+<div class="qa-section" id="general-2">
+ <a name="print-1"></a>
+ <div class="qa-question">Q. What is account lock and how do I enable / disable it ?</div>
+ <div class="qa-answer">Once a account is locked it cannot be modified any further, it becomes read-only. Click on "Settings" in Main Menu and then select "Account Settings". You need to check / uncheck the option called "Account Locked" (in the bottom) to enable or disable the account lock respectively.<br /><br />Note: If account is locked you can see a messages 'Account is currently locked to prevent any further modifications.' in the account dashboard.</div>
+</div>
+
<div class="qa-section" id="print-1">
<a name="print-1"></a>
<div class="qa-question">Q. How do I modify the voucher print format ?</div>
diff --git a/system/application/views/welcome.php b/system/application/views/welcome.php
index a34de58..6c43ae4 100644
--- a/system/application/views/welcome.php
+++ b/system/application/views/welcome.php
@@ -94,7 +94,7 @@ jQuery(document).ready(function () {
</tr>
<?php if ($this->config->item('account_locked') == 1) { ?>
<tr>
- <td><div>Account is currently <strong>locked</strong> to prevent any further modification.</div></td>
+ <td><div>Account is currently <strong>locked</strong> to prevent any further modifications.</div></td>
</tr>
<?php } ?>
</tbody>
commit 778f4f7f34eee6cfc9dae0a8c85c8b13f4f5a698
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 10 11:59:08 2011 +0530
Implement the account locked feature
- Added account locked feature to all controllers to prevent
any changes to the account once the lock is active
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/admin/create.php b/system/application/controllers/admin/create.php
index d98a268..f3759e7 100644
--- a/system/application/controllers/admin/create.php
+++ b/system/application/controllers/admin/create.php
@@ -308,7 +308,7 @@ class Create extends Controller {
/* Adding account settings */
$newacc->trans_start();
- if ( ! $newacc->query("INSERT INTO settings (id, name, address, email, fy_start, fy_end, currency_symbol, date_format, timezone, database_version) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array(1, $data_account_name, $data_account_address, $data_account_email, $data_fy_start, $data_fy_end, $data_account_currency, $data_account_date, $data_account_timezone, 1)))
+ if ( ! $newacc->query("INSERT INTO settings (id, name, address, email, fy_start, fy_end, currency_symbol, date_format, timezone, account_locked, database_version) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array(1, $data_account_name, $data_account_address, $data_account_email, $data_fy_start, $data_fy_end, $data_account_currency, $data_account_date, $data_account_timezone, 0, 1)))
{
$newacc->trans_rollback();
$this->messages->add('Error adding account settings.', 'error');
diff --git a/system/application/controllers/group.php b/system/application/controllers/group.php
index 4638937..3ecf548 100644
--- a/system/application/controllers/group.php
+++ b/system/application/controllers/group.php
@@ -28,6 +28,14 @@ class Group extends Controller {
return;
}
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('account');
+ return;
+ }
+
/* Form fields */
$data['group_name'] = array(
'name' => 'group_name',
@@ -114,6 +122,14 @@ class Group extends Controller {
return;
}
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('account');
+ return;
+ }
+
/* Checking for valid data */
$id = $this->input->xss_clean($id);
$id = (int)$id;
@@ -233,6 +249,14 @@ class Group extends Controller {
return;
}
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('account');
+ return;
+ }
+
/* Checking for valid data */
$id = $this->input->xss_clean($id);
$id = (int)$id;
diff --git a/system/application/controllers/ledger.php b/system/application/controllers/ledger.php
index 08244ac..50a53c5 100644
--- a/system/application/controllers/ledger.php
+++ b/system/application/controllers/ledger.php
@@ -28,6 +28,14 @@ class Ledger extends Controller {
return;
}
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('account');
+ return;
+ }
+
/* Form fields */
$data['ledger_name'] = array(
'name' => 'ledger_name',
@@ -130,6 +138,14 @@ class Ledger extends Controller {
return;
}
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('account');
+ return;
+ }
+
/* Checking for valid data */
$id = $this->input->xss_clean($id);
$id = (int)$id;
@@ -255,6 +271,14 @@ class Ledger extends Controller {
return;
}
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('account');
+ return;
+ }
+
/* Checking for valid data */
$id = $this->input->xss_clean($id);
$id = (int)$id;
diff --git a/system/application/controllers/log.php b/system/application/controllers/log.php
index c6160ed..1071d78 100644
--- a/system/application/controllers/log.php
+++ b/system/application/controllers/log.php
@@ -25,7 +25,15 @@ class Log extends Controller {
if ( ! check_access('clear log'))
{
$this->messages->add('Permission denied.', 'error');
- redirect('');
+ redirect('log');
+ return;
+ }
+
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('log');
return;
}
diff --git a/system/application/controllers/setting.php b/system/application/controllers/setting.php
index 9579515..2100918 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -405,7 +405,7 @@ class Setting extends Controller {
/* Adding account settings */
$newacc->trans_start();
- if ( ! $newacc->query("INSERT INTO settings (id, name, address, email, fy_start, fy_end, currency_symbol, date_format, timezone, email_protocol, email_host, email_port, email_username, email_password, database_version) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array(1, $data_account_name, $data_account_address, $data_account_email, $data_fy_start, $data_fy_end, $data_account_currency, $data_account_date, $data_account_timezone, $data_account_email_protocol, $data_account_email_host, $data_account_email_port, $data_account_email_username, $data_account_email_password, 1)))
+ if ( ! $newacc->query("INSERT INTO settings (id, name, address, email, fy_start, fy_end, currency_symbol, date_format, timezone, account_locked, email_protocol, email_host, email_port, email_username, email_password, database_version) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array(1, $data_account_name, $data_account_address, $data_account_email, $data_fy_start, $data_fy_end, $data_account_currency, $data_account_date, $data_account_timezone, 0, $data_account_email_protocol, $data_account_email_host, $data_account_email_port, $data_account_email_username, $data_account_email_password, 1)))
{
$newacc->trans_rollback();
$this->messages->add('Error adding account settings.', 'error');
diff --git a/system/application/controllers/tag.php b/system/application/controllers/tag.php
index 56eb158..34d4095 100644
--- a/system/application/controllers/tag.php
+++ b/system/application/controllers/tag.php
@@ -29,6 +29,14 @@ class Tag extends Controller {
return;
}
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('tag');
+ return;
+ }
+
/* Colorpicker JS and CSS */
$this->template->set('add_css', array(
"plugins/colorpicker/css/colorpicker.css",
@@ -124,6 +132,14 @@ class Tag extends Controller {
return;
}
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('tag');
+ return;
+ }
+
/* Colorpicker JS and CSS */
$this->template->set('add_css', array(
"plugins/colorpicker/css/colorpicker.css",
@@ -237,6 +253,14 @@ class Tag extends Controller {
return;
}
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('tag');
+ return;
+ }
+
/* Checking for valid data */
$id = $this->input->xss_clean($id);
$id = (int)$id;
diff --git a/system/application/controllers/voucher.php b/system/application/controllers/voucher.php
index ceac851..5854a4f 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -238,6 +238,14 @@ class Voucher extends Controller {
return;
}
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('voucher/show/' . $voucher_type);
+ return;
+ }
+
switch ($voucher_type)
{
case 'receipt' :
@@ -556,6 +564,14 @@ class Voucher extends Controller {
return;
}
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('voucher/show/' . $voucher_type);
+ return;
+ }
+
switch ($voucher_type)
{
case 'receipt' :
@@ -904,6 +920,14 @@ class Voucher extends Controller {
return;
}
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('voucher/show/' . $voucher_type);
+ return;
+ }
+
/* Load current voucher details */
if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id, $voucher_type))
{
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index 9742d99..348aacd 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -151,6 +151,7 @@ class Startup
$CI->config->set_item('account_currency_symbol', $account_d->currency_symbol);
$CI->config->set_item('account_date_format', $account_d->date_format);
$CI->config->set_item('account_timezone', $account_d->timezone);
+ $CI->config->set_item('account_locked', $account_d->account_locked);
$CI->config->set_item('account_receipt_prefix', $account_d->receipt_voucher_prefix);
$CI->config->set_item('account_payment_prefix', $account_d->payment_voucher_prefix);
$CI->config->set_item('account_contra_prefix', $account_d->contra_voucher_prefix);
diff --git a/system/application/views/setting/account.php b/system/application/views/setting/account.php
index de8a9fe..21d9c37 100644
--- a/system/application/views/setting/account.php
+++ b/system/application/views/setting/account.php
@@ -53,7 +53,7 @@
echo "<span id=\"tooltip-target-1\">";
echo form_checkbox('account_locked', 1, $account_locked) . " Account Locked";
echo "</span>";
- echo "<span id=\"tooltip-content-1\">If enabled prevents any future modifications to the account. Makes the account read-only.</span>";
+ echo "<span id=\"tooltip-content-1\">If enabled prevents any further modifications to the account. Makes the account read-only.</span>";
echo "</p>";
echo "<p>";
diff --git a/system/application/views/welcome.php b/system/application/views/welcome.php
index fe3188d..a34de58 100644
--- a/system/application/views/welcome.php
+++ b/system/application/views/welcome.php
@@ -87,8 +87,16 @@ jQuery(document).ready(function () {
<table class="dashboard-summary-table">
<tbody>
<tr>
- <td><div>Welcome back, <strong><?php echo $this->config->item('account_name');?> !</strong></div></td>
+ <td><div>Welcome back, <strong><?php echo $this->config->item('account_name'); ?> !</strong></div></td>
</tr>
+ <tr>
+ <td><div>Account for Financial Year <strong><?php echo date_mysql_to_php_display($this->config->item('account_fy_start')) . " - " . date_mysql_to_php_display($this->config->item('account_fy_end')); ?></strong></div></td>
+ </tr>
+ <?php if ($this->config->item('account_locked') == 1) { ?>
+ <tr>
+ <td><div>Account is currently <strong>locked</strong> to prevent any further modification.</div></td>
+ </tr>
+ <?php } ?>
</tbody>
</table>
</div>
commit a0f2ee97f1ec8fa5bfd1b83ff151db1a149600cb
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 10 11:27:02 2011 +0530
Added account locked to account settings
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/setting.php b/system/application/controllers/setting.php
index 1383c07..9579515 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -81,6 +81,7 @@ class Setting extends Controller {
);
$data['account_date'] = 'dd/mm/yyyy';
$data['account_timezone'] = 'UTC';
+ $data['account_locked'] = FALSE;
/* Current account settings */
if ($account_data)
@@ -93,6 +94,7 @@ class Setting extends Controller {
$data['account_timezone'] = print_value($account_data->timezone);
$data['fy_start'] = date_mysql_to_php(print_value($account_data->fy_start));
$data['fy_end'] = date_mysql_to_php(print_value($account_data->fy_end));
+ $data['account_locked'] = print_value($account_data->account_locked);
}
/* Form validations */
@@ -102,6 +104,7 @@ class Setting extends Controller {
$this->form_validation->set_rules('account_currency', 'Currency', 'trim|max_length[10]');
$this->form_validation->set_rules('account_date', 'Date', 'trim|max_length[10]');
$this->form_validation->set_rules('account_timezone', 'Timezone', 'trim|max_length[6]');
+ $this->form_validation->set_rules('account_locked', 'Account Locked', 'trim');
/* Repopulating form */
if ($_POST)
@@ -112,6 +115,7 @@ class Setting extends Controller {
$data['account_currency']['value'] = $this->input->post('account_currency', TRUE);
$data['account_date'] = $this->input->post('account_date', TRUE);
$data['account_timezone'] = $this->input->post('account_timezone', TRUE);
+ $data['account_locked'] = $this->input->post('account_locked', TRUE);
}
/* Validating form */
@@ -137,11 +141,16 @@ class Setting extends Controller {
$data_account_date = "yyyy/mm/dd";
else
$data_account_date = "dd/mm/yyyy";
+
$data_account_timezone = $this->input->post('timezones', TRUE);
+ $data_account_locked = $this->input->post('account_locked', TRUE);
+ if ($data_account_locked != 1)
+ $data_account_locked = 0;
+
/* Update settings */
$this->db->trans_start();
- if ( ! $this->db->query("UPDATE settings SET name = ?, address = ?, email = ?, currency_symbol = ?, date_format = ?, timezone = ? WHERE id = 1", array($data_account_name, $data_account_address, $data_account_email, $data_account_currency, $data_account_date, $data_account_timezone)))
+ if ( ! $this->db->query("UPDATE settings SET name = ?, address = ?, email = ?, currency_symbol = ?, date_format = ?, timezone = ?, account_locked = ? WHERE id = 1", array($data_account_name, $data_account_address, $data_account_email, $data_account_currency, $data_account_date, $data_account_timezone, $data_account_locked)))
{
$this->db->trans_rollback();
$this->messages->add('Error updating account settings.', 'error');
diff --git a/system/application/views/setting/account.php b/system/application/views/setting/account.php
index 496a34b..de8a9fe 100644
--- a/system/application/views/setting/account.php
+++ b/system/application/views/setting/account.php
@@ -50,6 +50,13 @@
echo "</p>";
echo "<p>";
+ echo "<span id=\"tooltip-target-1\">";
+ echo form_checkbox('account_locked', 1, $account_locked) . " Account Locked";
+ echo "</span>";
+ echo "<span id=\"tooltip-content-1\">If enabled prevents any future modifications to the account. Makes the account read-only.</span>";
+ echo "</p>";
+
+ echo "<p>";
echo form_submit('submit', 'Update');
echo " ";
echo anchor('setting', 'Back', 'Back to Settings');
commit adfabbaa44b698783585814ab38b55e44946c872
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Jan 9 19:50:30 2011 +0530
Removed all references to draft vouchers
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/assets/css/tables.css b/system/application/assets/css/tables.css
index 0e9a903..c20dc6b 100644
--- a/system/application/assets/css/tables.css
+++ b/system/application/assets/css/tables.css
@@ -23,7 +23,7 @@
padding:8px 8px 8px 8px;
}
-.simple-table tr.tr-draft {
+.simple-table tr.tr-active {
background-color:#FFFFE6;
}
@@ -108,7 +108,7 @@ tr.total-area {
}
.balance-sheet-table tr.tr-group td {
- background-color:#FFFFF0;
+ background-color:#FFFFE6;
}
.balance-sheet-total-table {
@@ -133,7 +133,7 @@ tr.total-area {
}
.profit-loss-table tr.tr-group td {
- background-color:#FFFFF0;
+ background-color:#FFFFE6;
}
.profit-loss-total-table {
diff --git a/system/application/controllers/admin/schema.sql b/system/application/controllers/admin/schema.sql
index 6d97e7c..8382b72 100644
--- a/system/application/controllers/admin/schema.sql
+++ b/system/application/controllers/admin/schema.sql
@@ -24,7 +24,6 @@ CREATE TABLE IF NOT EXISTS vouchers (
dr_total decimal(15,2) NOT NULL DEFAULT '0.00',
cr_total decimal(15,2) NOT NULL DEFAULT '0.00',
narration text NOT NULL,
- draft int(1) NOT NULL,
type int(2) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
diff --git a/system/application/controllers/report.php b/system/application/controllers/report.php
index 3dd7e1d..3c243e6 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -204,7 +204,6 @@ class Report extends Controller {
$ledgerst[$counter][0]= "Date";
$ledgerst[$counter][1]= "Number";
$ledgerst[$counter][2]= "Ledger Name";
- $ledgerst[$counter][3]= "Status";
$ledgerst[$counter][4]= "Type";
$ledgerst[$counter][5]= "";
$ledgerst[$counter][6]= "Dr Amount";
@@ -216,14 +215,14 @@ class Report extends Controller {
/* Opening Balance */
list ($opbalance, $optype) = $this->Ledger_model->get_op_balance($ledger_id);
- $ledgerst[$counter] = array ("Opening Balance", "", "", "", "", "", "", "", "", convert_dc($optype), $opbalance);
+ $ledgerst[$counter] = array ("Opening Balance", "", "", "", "", "", "", "", convert_dc($optype), $opbalance);
if ($optype == "D")
$cur_balance += $opbalance;
else
$cur_balance -= $opbalance;
$counter++;
- $ledgerst_q = $this->db->query("SELECT vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.draft as vdraft, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc FROM vouchers join voucher_items on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? ORDER BY vouchers.date ASC, vouchers.number ASC", array($ledger_id));
+ $ledgerst_q = $this->db->query("SELECT vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc FROM vouchers join voucher_items on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? ORDER BY vouchers.date ASC, vouchers.number ASC", array($ledger_id));
foreach ($ledgerst_q->result() as $row)
{
$ledgerst[$counter][0] = date_mysql_to_php($row->vdate);
@@ -259,43 +258,34 @@ class Report extends Controller {
}
- $ledgerst[$counter][3] = ($row->vdraft == 1) ? "Draft" : "Active";
- $ledgerst[$counter][4] = ucfirst(n_to_v($row->vtype));
+ $ledgerst[$counter][3] = ucfirst(n_to_v($row->vtype));
if ($row->ldc == "D")
{
- if ($row->vdraft == 0)
- $cur_balance += $row->lamount;
- $ledgerst[$counter][5] = convert_dc($row->ldc);
- $ledgerst[$counter][6] = $row->lamount;
+ $cur_balance += $row->lamount;
+ $ledgerst[$counter][4] = convert_dc($row->ldc);
+ $ledgerst[$counter][5] = $row->lamount;
+ $ledgerst[$counter][6] = "";
$ledgerst[$counter][7] = "";
- $ledgerst[$counter][8] = "";
} else {
- if ($row->vdraft == 0)
- $cur_balance -= $row->lamount;
+ $cur_balance -= $row->lamount;
+ $ledgerst[$counter][4] = "";
$ledgerst[$counter][5] = "";
- $ledgerst[$counter][6] = "";
- $ledgerst[$counter][7] = convert_dc($row->ldc);
- $ledgerst[$counter][8] = $row->lamount;
+ $ledgerst[$counter][6] = convert_dc($row->ldc);
+ $ledgerst[$counter][7] = $row->lamount;
}
- if ($row->vdraft == 0)
+ if ($cur_balance == 0)
{
- if ($cur_balance == 0)
- {
- $ledgerst[$counter][9] = "";
- $ledgerst[$counter][10] = 0;
- } else if ($cur_balance < 0) {
- $ledgerst[$counter][9] = "Cr";
- $ledgerst[$counter][10] = convert_cur(-$cur_balance);
- } else {
- $ledgerst[$counter][9] = "Dr";
- $ledgerst[$counter][10] = convert_cur($cur_balance);
- }
+ $ledgerst[$counter][8] = "";
+ $ledgerst[$counter][9] = 0;
+ } else if ($cur_balance < 0) {
+ $ledgerst[$counter][8] = "Cr";
+ $ledgerst[$counter][9] = convert_cur(-$cur_balance);
} else {
- $ledgerst[$counter][9] = "";
- $ledgerst[$counter][10] = "";
+ $ledgerst[$counter][8] = "Dr";
+ $ledgerst[$counter][9] = convert_cur($cur_balance);
}
$counter++;
}
@@ -304,7 +294,6 @@ class Report extends Controller {
$ledgerst[$counter][1]= "";
$ledgerst[$counter][2]= "";
$ledgerst[$counter][3]= "";
- $ledgerst[$counter][4]= "";
$ledgerst[$counter][5]= "";
$ledgerst[$counter][6]= "";
$ledgerst[$counter][7]= "";
@@ -319,21 +308,21 @@ class Report extends Controller {
}
$counter++;
- $ledgerst[$counter] = array ("", "", "", "", "", "", "", "", "", "", "");
+ $ledgerst[$counter] = array ("", "", "", "", "", "", "", "", "", "");
$counter++;
/* Final Opening and Closing Balance */
$clbalance = $this->Ledger_model->get_ledger_balance($ledger_id);
- $ledgerst[$counter] = array ("Opening Balance", convert_dc($optype), $opbalance, "", "", "", "", "", "", "", "");
+ $ledgerst[$counter] = array ("Opening Balance", convert_dc($optype), $opbalance, "", "", "", "", "", "", "");
$counter++;
if ($clbalance == 0)
- $ledgerst[$counter] = array ("Closing Balance", "", 0, "", "", "", "", "", "", "", "");
+ $ledgerst[$counter] = array ("Closing Balance", "", 0, "", "", "", "", "", "", "");
else if ($clbalance < 0)
- $ledgerst[$counter] = array ("Closing Balance", "Cr", convert_cur(-$clbalance), "", "", "", "", "", "", "", "");
+ $ledgerst[$counter] = array ("Closing Balance", "Cr", convert_cur(-$clbalance), "", "", "", "", "", "", "");
else
- $ledgerst[$counter] = array ("Closing Balance", "Dr", convert_cur($clbalance), "", "", "", "", "", "", "", "");
+ $ledgerst[$counter] = array ("Closing Balance", "Dr", convert_cur($clbalance), "", "", "", "", "", "", "");
$this->load->helper('csv');
echo array_to_csv($ledgerst, "ledgerst.csv");
diff --git a/system/application/controllers/voucher.php b/system/application/controllers/voucher.php
index 1802ba0..ceac851 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -53,10 +53,6 @@ class Voucher extends Controller {
$this->template->set('nav_links', array('voucher/add/journal' => 'New Journal Voucher'));
$data['voucher_type'] = "journal";
break;
- case 'draft' :
- $this->template->set('page_title', 'Draft Vouchers');
- $data['voucher_type'] = "";
- break;
case 'tag' :
$tag_name = $this->Tag_model->tag_name($tag_id);
$this->template->set('page_title', 'Vouchers Tagged "' . $tag_name . '"');
@@ -121,10 +117,7 @@ class Voucher extends Controller {
$this->messages->add('Invalid voucher type.', 'error');
redirect('voucher/show/all');
return;
- } else if ($voucher_type == "draft") {
- $voucher_q = $this->db->query("SELECT * FROM vouchers WHERE draft = 1 ORDER BY date DESC, number DESC LIMIT ${page_count}, ${pagination_counter}");
- $config['total_rows'] = $this->db->query("SELECT * FROM vouchers WHERE draft = 1")->num_rows();
- } else if ($voucher_type == "tag") {
+ } else if ($voucher_type == "tag") {
$voucher_q = $this->db->query("SELECT * FROM vouchers WHERE tag_id = ? ORDER BY date DESC, number DESC LIMIT ${page_count}, ${pagination_counter}", array($tag_id));
$config['total_rows'] = $this->db->query("SELECT * FROM vouchers WHERE tag_id = ?", array($tag_id))->num_rows();
} else if ($voucher_type_int > 0) {
@@ -139,7 +132,7 @@ class Voucher extends Controller {
$this->pagination->initialize($config);
$html = "<table border=0 cellpadding=5 class=\"simple-table\">";
- $html .= "<thead><tr><th>Date</th><th>No</th><th>Ledger A/C</th><th>Type</th><th>Status</th><th>DR Amount</th><th>CR Amount</th><th></th></tr></thead>";
+ $html .= "<thead><tr><th>Date</th><th>No</th><th>Ledger A/C</th><th>Type</th><th>DR Amount</th><th>CR Amount</th><th></th></tr></thead>";
$html .= "<tbody>";
$odd_even = "odd";
@@ -153,9 +146,7 @@ class Voucher extends Controller {
$ledger_multiple = ($ledger_q->num_rows() > 1) ? TRUE : FALSE;
$ledger = $ledger_q->row();
- $html .= "<tr class=\"tr-" . $odd_even;
- $html .= ($row->draft == 1) ? " tr-draft " : "";
- $html .= "\">";
+ $html .= "<tr class=\"tr-" . $odd_even . "\">";
$html .= "<td>" . date_mysql_to_php_display($row->date) . "</td>";
$html .= "<td>" . anchor('voucher/view/' . strtolower($html_voucher_type) . "/" . $row->id, voucher_number_prefix($html_voucher_type) . $row->number, array('title' => 'View ' . ucfirst($html_voucher_type) . ' Voucher', 'class' => 'anchor-link-a')) . "</td>";
@@ -170,10 +161,6 @@ class Voucher extends Controller {
$html .= "</td>";
$html .= "<td>" . ucfirst($html_voucher_type) . "</td>";
- if ($row->draft == 0)
- $html .= "<td>Active</td>";
- else
- $html .= "<td>Draft</td>";
$html .= "<td>" . $row->dr_total . "</td>";
$html .= "<td>" . $row->cr_total . "</td>";
@@ -295,7 +282,6 @@ class Voucher extends Controller {
'value' => '',
);
$data['voucher_type'] = $voucher_type;
- $data['voucher_draft'] = FALSE;
$data['voucher_print'] = FALSE;
$data['voucher_email'] = FALSE;
$data['voucher_download'] = FALSE;
@@ -324,7 +310,6 @@ class Voucher extends Controller {
$data['voucher_number']['value'] = $this->input->post('voucher_number', TRUE);
$data['voucher_date']['value'] = $this->input->post('voucher_date', TRUE);
$data['voucher_narration']['value'] = $this->input->post('voucher_narration', TRUE);
- $data['voucher_draft'] = $this->input->post('voucher_draft', TRUE);
$data['voucher_print'] = $this->input->post('voucher_print', TRUE);
$data['voucher_email'] = $this->input->post('voucher_email', TRUE);
$data['voucher_download'] = $this->input->post('voucher_download', TRUE);
@@ -456,13 +441,6 @@ class Voucher extends Controller {
$data_date = $this->input->post('voucher_date', TRUE);
$data_narration = $this->input->post('voucher_narration', TRUE);
$data_tag = $this->input->post('voucher_tag', TRUE);
-
- $data_draft = $this->input->post('voucher_draft', TRUE);
- if ($data_draft == "1")
- $data_draft = "1";
- else
- $data_draft = "0";
-
$data_type = 0;
switch ($voucher_type)
{
@@ -475,7 +453,7 @@ class Voucher extends Controller {
$voucher_id = NULL;
$this->db->trans_start();
- if ( ! $this->db->query("INSERT INTO vouchers (number, date, narration, draft, type, tag_id) VALUES (?, ?, ?, ?, ?, ?)", array($data_number, $data_date, $data_narration, $data_draft, $data_type, $data_tag)))
+ if ( ! $this->db->query("INSERT INTO vouchers (number, date, narration, type, tag_id) VALUES (?, ?, ?, ?, ?)", array($data_number, $data_date, $data_narration, $data_type, $data_tag)))
{
$this->db->trans_rollback();
$this->messages->add('Error addding Voucher.', 'error');
@@ -631,7 +609,6 @@ class Voucher extends Controller {
);
$data['voucher_type'] = $voucher_type;
$data['voucher_id'] = $voucher_id;
- $data['voucher_draft'] = ($cur_voucher->draft == 0) ? FALSE : TRUE;
$data['voucher_print'] = FALSE;
$data['voucher_email'] = FALSE;
$data['voucher_download'] = FALSE;
@@ -696,7 +673,6 @@ class Voucher extends Controller {
$data['voucher_number']['value'] = $this->input->post('voucher_number', TRUE);
$data['voucher_date']['value'] = $this->input->post('voucher_date', TRUE);
$data['voucher_narration']['value'] = $this->input->post('voucher_narration', TRUE);
- $data['voucher_draft'] = $this->input->post('voucher_draft', TRUE);
$data['voucher_print'] = $this->input->post('voucher_print', TRUE);
$data['voucher_email'] = $this->input->post('voucher_email', TRUE);
$data['voucher_download'] = $this->input->post('voucher_download', TRUE);
@@ -807,13 +783,6 @@ class Voucher extends Controller {
$data_date = $this->input->post('voucher_date', TRUE);
$data_narration = $this->input->post('voucher_narration', TRUE);
$data_tag = $this->input->post('voucher_tag', TRUE);
-
- $data_draft = $this->input->post('voucher_draft', TRUE);
- if ($data_draft == "1")
- $data_draft = "1";
- else
- $data_draft = "0";
-
$data_type = 0;
switch ($voucher_type)
{
@@ -825,7 +794,7 @@ class Voucher extends Controller {
$data_date = date_php_to_mysql($data_date); // Converting date to MySQL
$this->db->trans_start();
- if ( ! $this->db->query("UPDATE vouchers SET number = ?, date = ?, narration = ?, draft = ?, tag_id = ? WHERE id = ?", array($data_number, $data_date, $data_narration, $data_draft, $data_tag, $voucher_id)))
+ if ( ! $this->db->query("UPDATE vouchers SET number = ?, date = ?, narration = ?, tag_id = ? WHERE id = ?", array($data_number, $data_date, $data_narration, $data_tag, $voucher_id)))
{
$this->db->trans_rollback();
$this->messages->add('Error updating Voucher A/C.', 'error');
@@ -997,7 +966,6 @@ class Voucher extends Controller {
$data['voucher_dr_total'] = $cur_voucher->dr_total;
$data['voucher_cr_total'] = $cur_voucher->cr_total;
$data['voucher_narration'] = $cur_voucher->narration;
- $data['voucher_draft'] = $cur_voucher->draft;
/* Getting Ledger details */
$ledger_q = $this->db->query("SELECT * FROM voucher_items WHERE voucher_id = ? ORDER BY dc DESC", $voucher_id);
@@ -1054,7 +1022,6 @@ class Voucher extends Controller {
$data['voucher_dr_total'] = $cur_voucher->dr_total;
$data['voucher_cr_total'] = $cur_voucher->cr_total;
$data['voucher_narration'] = $cur_voucher->narration;
- $data['voucher_draft'] = $cur_voucher->draft;
/* Getting Ledger details */
$ledger_q = $this->db->query("SELECT * FROM voucher_items WHERE voucher_id = ? ORDER BY dc DESC", $voucher_id);
@@ -1135,7 +1102,6 @@ class Voucher extends Controller {
$voucher_data['voucher_dr_total'] = $cur_voucher->dr_total;
$voucher_data['voucher_cr_total'] = $cur_voucher->cr_total;
$voucher_data['voucher_narration'] = $cur_voucher->narration;
- $voucher_data['voucher_draft'] = $cur_voucher->draft;
/* Getting Ledger details */
$ledger_q = $this->db->query("SELECT * FROM voucher_items WHERE voucher_id = ? ORDER BY dc DESC", $voucher_id);
diff --git a/system/application/controllers/welcome.php b/system/application/controllers/welcome.php
index 633df35..8e6ec62 100644
--- a/system/application/controllers/welcome.php
+++ b/system/application/controllers/welcome.php
@@ -16,10 +16,6 @@ class Welcome extends Controller {
$this->template->set('add_css', array("css/tufte-graph.css"));
$this->template->set('add_javascript', array("js/raphael.js", "js/jquery.enumerable.js", "js/jquery.tufte-graph.js"));
- /* Draft voucher count */
- $draft_q = $this->db->query("SELECT * FROM vouchers WHERE draft = 1");
- $data['draft_count'] = $draft_q->num_rows();
-
/* Bank and Cash Ledger accounts */
$bank_q = $this->db->query("SELECT * FROM ledgers WHERE type = ?", array('B'));
if ($bank_q->num_rows() > 0)
diff --git a/system/application/models/ledger_model.php b/system/application/models/ledger_model.php
index 82075a8..c562935 100644
--- a/system/application/models/ledger_model.php
+++ b/system/application/models/ledger_model.php
@@ -96,7 +96,7 @@ class Ledger_model extends Model {
/* Return debit total as positive value */
function get_dr_total($ledger_id)
{
- $dr_total_q = $this->db->query('SELECT SUM(amount) AS drtotal FROM voucher_items join vouchers on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? AND vouchers.draft = 0 AND voucher_items.dc = "D"', $ledger_id);
+ $dr_total_q = $this->db->query('SELECT SUM(amount) AS drtotal FROM voucher_items join vouchers on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? AND voucher_items.dc = "D"', $ledger_id);
$dr_total = $dr_total_q->row();
return $dr_total->drtotal;
}
@@ -104,7 +104,7 @@ class Ledger_model extends Model {
/* Return credit total as positive value */
function get_cr_total($ledger_id)
{
- $cr_total_q = $this->db->query('SELECT SUM(amount) AS crtotal FROM voucher_items join vouchers on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? AND vouchers.draft = 0 AND voucher_items.dc = "C"', $ledger_id);
+ $cr_total_q = $this->db->query('SELECT SUM(amount) AS crtotal FROM voucher_items join vouchers on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? AND voucher_items.dc = "C"', $ledger_id);
$cr_total = $cr_total_q->row();
return $cr_total->crtotal;
}
diff --git a/system/application/views/admin/manage/index.php b/system/application/views/admin/manage/index.php
index 54eb59e..4cdf7da 100644
--- a/system/application/views/admin/manage/index.php
+++ b/system/application/views/admin/manage/index.php
@@ -28,7 +28,7 @@ foreach ($accounts as $label)
echo "<tr class=\"tr-" . $odd_even;
if ($this->session->userdata('active_account') == $label)
- echo " tr-draft";
+ echo " tr-active";
echo "\">";
echo "<td>";
echo $label;
diff --git a/system/application/views/admin/user/index.php b/system/application/views/admin/user/index.php
index d748c97..0018aaa 100644
--- a/system/application/views/admin/user/index.php
+++ b/system/application/views/admin/user/index.php
@@ -28,7 +28,7 @@ foreach ($users as $row)
echo "<tr class=\"tr-" . $odd_even;
if ($this->session->userdata('user_name') == $row)
- echo " tr-draft";
+ echo " tr-active";
echo "\">";
echo "<td>" . $username . "</td>";
echo "<td>" . $email . "</td>";
diff --git a/system/application/views/report/ledgerst.php b/system/application/views/report/ledgerst.php
index 6c0007d..67a6969 100644
--- a/system/application/views/report/ledgerst.php
+++ b/system/application/views/report/ledgerst.php
@@ -61,15 +61,15 @@
echo "</table>";
echo "<br />";
if ( ! $print_preview) {
- $ledgerst_q = $this->db->query("SELECT vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.draft as vdraft, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc FROM vouchers join voucher_items on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? ORDER BY vouchers.date ASC, vouchers.number ASC LIMIT ${page_count}, ${pagination_counter}", array($ledger_id));
+ $ledgerst_q = $this->db->query("SELECT vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc FROM vouchers join voucher_items on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? ORDER BY vouchers.date ASC, vouchers.number ASC LIMIT ${page_count}, ${pagination_counter}", array($ledger_id));
} else {
$page_count = 0;
- $ledgerst_q = $this->db->query("SELECT vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.draft as vdraft, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc FROM vouchers join voucher_items on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? ORDER BY vouchers.date ASC, vouchers.number ASC", array($ledger_id));
+ $ledgerst_q = $this->db->query("SELECT vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc FROM vouchers join voucher_items on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? ORDER BY vouchers.date ASC, vouchers.number ASC", array($ledger_id));
}
echo "<table border=0 cellpadding=5 class=\"simple-table ledgerst-table\">";
- echo "<thead><tr><th>Date</th><th>No.</th><th>Ledger Name</th><th>Status</th><th>Type</th><th>Dr Amount</th><th>Cr Amount</th><th>Balance</th></tr></thead>";
+ echo "<thead><tr><th>Date</th><th>No.</th><th>Ledger Name</th><th>Type</th><th>Dr Amount</th><th>Cr Amount</th><th>Balance</th></tr></thead>";
$odd_even = "odd";
$cur_balance = 0;
@@ -79,10 +79,10 @@
/* Opening balance */
if ($optype == "D")
{
- echo "<tr class=\"tr-balance\"><td colspan=7>Opening Balance</td><td>" . convert_opening($opbalance, $optype) . "</td></tr>";
+ echo "<tr class=\"tr-balance\"><td colspan=6>Opening Balance</td><td>" . convert_opening($opbalance, $optype) . "</td></tr>";
$cur_balance += $opbalance;
} else {
- echo "<tr class=\"tr-balance\"><td colspan=7>Opening Balance</td><td>" . convert_opening($opbalance, $optype) . "</td></tr>";
+ echo "<tr class=\"tr-balance\"><td colspan=6>Opening Balance</td><td>" . convert_opening($opbalance, $optype) . "</td></tr>";
$cur_balance -= $opbalance;
}
} else {
@@ -95,12 +95,10 @@
}
/* Calculating previous balance */
- $prevbal_q = $this->db->query("SELECT vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.draft as vdraft, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc FROM vouchers join voucher_items on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? ORDER BY vouchers.date ASC, vouchers.number ASC LIMIT 0, ${page_count}", array($ledger_id));
+ $prevbal_q = $this->db->query("SELECT vouchers.id as vid, vouchers.number as vnumber, vouchers.date as vdate, vouchers.type as vtype, voucher_items.amount as lamount, voucher_items.dc as ldc FROM vouchers join voucher_items on vouchers.id = voucher_items.voucher_id WHERE voucher_items.ledger_id = ? ORDER BY vouchers.date ASC, vouchers.number ASC LIMIT 0, ${page_count}", array($ledger_id));
foreach ($prevbal_q->result() as $row )
{
- if ($row->vdraft == 1)
- continue;
if ($row->ldc == "D")
$cur_balance += $row->lamount;
else
@@ -108,14 +106,12 @@
}
/* Show new current total */
- echo "<tr class=\"tr-balance\"><td colspan=7>Opening</td><td>" . convert_amount_dc($cur_balance) . "</td></tr>";
+ echo "<tr class=\"tr-balance\"><td colspan=6>Opening</td><td>" . convert_amount_dc($cur_balance) . "</td></tr>";
}
foreach ($ledgerst_q->result() as $row)
{
- echo "<tr class=\"tr-" . $odd_even;
- echo ($row->vdraft == 1) ? " tr-draft " : "";
- echo "\">";
+ echo "<tr class=\"tr-" . $odd_even . "\">";
echo "<td>";
echo date_mysql_to_php_display($row->vdate);
echo "</td>";
@@ -156,15 +152,11 @@
echo "</td>";
echo "<td>";
- echo ($row->vdraft == 1) ? "Draft" : "Active";
- echo "</td>";
- echo "<td>";
echo ucfirst(n_to_v($row->vtype));
echo "</td>";
if ($row->ldc == "D")
{
- if ($row->vdraft == 0)
- $cur_balance += $row->lamount;
+ $cur_balance += $row->lamount;
echo "<td>";
echo convert_dc($row->ldc);
echo " ";
@@ -172,8 +164,7 @@
echo "</td>";
echo "<td></td>";
} else {
- if ($row->vdraft == 0)
- $cur_balance -= $row->lamount;
+ $cur_balance -= $row->lamount;
echo "<td></td>";
echo "<td>";
echo convert_dc($row->ldc);
@@ -182,17 +173,14 @@
echo "</td>";
}
echo "<td>";
- if ($row->vdraft == 0)
- echo convert_amount_dc($cur_balance);
- else
- echo "-";
+ echo convert_amount_dc($cur_balance);
echo "</td>";
echo "</tr>";
$odd_even = ($odd_even == "odd") ? "even" : "odd";
}
/* Current Page Closing Balance */
- echo "<tr class=\"tr-balance\"><td colspan=7>Closing</td><td>" . convert_amount_dc($cur_balance) . "</td></tr>";
+ echo "<tr class=\"tr-balance\"><td colspan=6>Closing</td><td>" . convert_amount_dc($cur_balance) . "</td></tr>";
echo "</table>";
}
?>
diff --git a/system/application/views/template.php b/system/application/views/template.php
index 0bc833e..5627f8c 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -112,7 +112,6 @@ $(document).ready(function() {
<li><?php echo anchor('voucher/show/payment', 'Payment', array('title' => 'Payment Vouchers')); ?></li>
<li><?php echo anchor('voucher/show/contra', 'Contra', array('title' => 'Contra Vouchers')); ?></li>
<li><?php echo anchor('voucher/show/journal', 'Journal', array('title' => 'Journal Vouchers')); ?></li>
- <li><?php // echo anchor('voucher/show/draft', 'Draft', array('title' => 'Draft Vouchers')); ?></li>
</ul>
</li>
<li>
diff --git a/system/application/views/voucher/add.php b/system/application/views/voucher/add.php
index 6d0f9a3..bc1dbd9 100644
--- a/system/application/views/voucher/add.php
+++ b/system/application/views/voucher/add.php
@@ -265,11 +265,6 @@ $(document).ready(function() {
echo "<p>";
echo form_fieldset('Options', array('class' => "fieldset-auto-width"));
- echo "<span id=\"tooltip-target-3\" class=\"hidden-element\">";
- echo form_checkbox('voucher_draft', 1, $voucher_draft) . "Draft";
- echo "</span>";
- echo "<span id=\"tooltip-content-3\">Draft vouchers do not affect any accouting caluculations.</span>";
- echo "<br /><br />";
echo form_checkbox('voucher_print', 1, $voucher_print) . "Print";
echo " ";
echo form_checkbox('voucher_email', 1, $voucher_email) . "Email";
diff --git a/system/application/views/voucher/edit.php b/system/application/views/voucher/edit.php
index 0dfbd4e..a8aedc1 100644
--- a/system/application/views/voucher/edit.php
+++ b/system/application/views/voucher/edit.php
@@ -262,11 +262,6 @@ $(document).ready(function() {
echo "<p>";
echo form_fieldset('Options', array('class' => "fieldset-auto-width"));
- echo "<span id=\"tooltip-target-2\" class=\"hidden-element\">";
- echo form_checkbox('voucher_draft', 1, $voucher_draft) . "Draft";
- echo "</span>";
- echo "<span id=\"tooltip-content-2\">Draft vouchers do not affect any accouting caluculations.</span>";
- echo "<br /><br />";
echo form_checkbox('voucher_print', 1, $voucher_print) . "Print";
echo " ";
echo form_checkbox('voucher_email', 1, $voucher_email) . "Email";
diff --git a/system/application/views/voucher/view.php b/system/application/views/voucher/view.php
index 35c3da0..7d865c1 100644
--- a/system/application/views/voucher/view.php
+++ b/system/application/views/voucher/view.php
@@ -40,14 +40,11 @@ if ($cur_voucher->dr_total != $cur_voucher->cr_total)
<span class="bold"><?php echo $cur_voucher->narration; ?></span>
</p>
<p>
-Status : <span class="bold"><?php echo ($cur_voucher->draft == 0) ? "Active" : "Draft"; ?></span>
-</p>
-<p>
Tag :
<?php
$cur_voucher_tag = $this->Tag_model->show_voucher_tag($cur_voucher->tag_id);
if ($cur_voucher_tag == "")
- echo "None";
+ echo "(None)";
else
echo $cur_voucher_tag;
?>
diff --git a/system/application/views/welcome.php b/system/application/views/welcome.php
index 46e6fba..fe3188d 100644
--- a/system/application/views/welcome.php
+++ b/system/application/views/welcome.php
@@ -82,16 +82,13 @@ jQuery(document).ready(function () {
</script>
<div id="dashboard-summary">
<div id="dashboard-welcome-back" class="dashboard-item">
- <div class="dashboard-title">Account Summary</div>
+ <div class="dashboard-title">Account Details</div>
<div class="dashboard-content">
<table class="dashboard-summary-table">
<tbody>
<tr>
<td><div>Welcome back, <strong><?php echo $this->config->item('account_name');?> !</strong></div></td>
</tr>
- <tr class="hidden-element">
- <td><div id="dashboard-draft">You have <?php echo anchor("voucher/show/draft", $draft_count . " draft", array('class' => 'anchor-link-a')); ?> voucher(s)</div></td>
- </tr>
</tbody>
</table>
</div>
commit b7cbdc49474373a2b34a8eb4d2d4caf235c8e434
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Jan 9 12:42:43 2011 +0530
Fixed a UI issue
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/views/admin/manage/index.php b/system/application/views/admin/manage/index.php
index 43471ac..54eb59e 100644
--- a/system/application/views/admin/manage/index.php
+++ b/system/application/views/admin/manage/index.php
@@ -41,9 +41,8 @@ foreach ($accounts as $label)
echo "<td>";
if ($this->session->userdata('active_account') == $label)
echo "Active";
- else
- echo anchor("admin/active/index/" . $label, "Activate", array('title' => 'Activate ' . ucfirst($label) . ' Account', 'class' => 'red-link'));
echo "</td>";
+
echo "<td>";
echo anchor("admin/manage/edit/" . $label, "Edit", array('title' => 'Edit ' . ucfirst($label) . ' Account', 'class' => 'red-link'));
echo " " . anchor('admin/manage/delete/' . $label, img(array('src' => asset_url() . "images/icons/delete.png", 'border' => '0', 'alt' => 'Delete Account Settings', 'class' => "confirmClick", 'title' => "Delete Account Settings")), array('title' => 'Delete Account Settings')) . " ";
commit 8a687edb8d4e6a5544eda1f32b06f7691ad68536
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Jan 9 12:11:49 2011 +0530
Added voucher auto numbering when adding voucher
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/voucher.php b/system/application/controllers/voucher.php
index e5b44c6..1802ba0 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -278,7 +278,7 @@ class Voucher extends Controller {
'id' => 'voucher_number',
'maxlength' => '11',
'size' => '11',
- 'value' => $this->Voucher_model->next_voucher_number($voucher_type),
+ 'value' => '',
);
$data['voucher_date'] = array(
'name' => 'voucher_date',
@@ -303,7 +303,7 @@ class Voucher extends Controller {
$data['voucher_tag'] = 0;
/* Form validations */
- $this->form_validation->set_rules('voucher_number', 'Voucher Number', 'trim|required|is_natural_no_zero|uniquevoucherno[' . v_to_n($voucher_type) . ']');
+ $this->form_validation->set_rules('voucher_number', 'Voucher Number', 'trim|is_natural_no_zero|uniquevoucherno[' . v_to_n($voucher_type) . ']');
$this->form_validation->set_rules('voucher_date', 'Voucher Date', 'trim|required|is_date|is_date_within_range');
$this->form_validation->set_rules('voucher_narration', 'trim');
$this->form_validation->set_rules('voucher_tag', 'Tag', 'trim|is_natural');
@@ -448,7 +448,11 @@ class Voucher extends Controller {
}
/* Adding main voucher */
- $data_number = $this->input->post('voucher_number', TRUE);
+ if ($this->input->post('voucher_number', TRUE))
+ $data_number = $this->input->post('voucher_number', TRUE);
+ else
+ $data_number = $this->Voucher_model->next_voucher_number($voucher_type);
+
$data_date = $this->input->post('voucher_date', TRUE);
$data_narration = $this->input->post('voucher_narration', TRUE);
$data_tag = $this->input->post('voucher_tag', TRUE);
diff --git a/system/application/views/voucher/add.php b/system/application/views/voucher/add.php
index 677c696..6d0f9a3 100644
--- a/system/application/views/voucher/add.php
+++ b/system/application/views/voucher/add.php
@@ -193,16 +193,19 @@ $(document).ready(function() {
<?php
echo form_open('voucher/add/' . $voucher_type);
echo "<p>";
+ echo "<span id=\"tooltip-target-1\">";
echo form_label('Voucher Number', 'voucher_number');
echo " ";
echo voucher_number_prefix($voucher_type) . form_input($voucher_number);
+ echo "</span>";
+ echo "<span id=\"tooltip-content-1\">Leave Voucher Number empty for auto numbering</span>";
echo " ";
- echo "<span id=\"tooltip-target-1\">";
+ echo "<span id=\"tooltip-target-2\">";
echo form_label('Voucher Date', 'voucher_date');
echo " ";
echo form_input_date_restrict($voucher_date);
echo "</span>";
- echo "<span id=\"tooltip-content-1\">Date format is " . $this->config->item('account_date_format') . ".</span>";
+ echo "<span id=\"tooltip-content-2\">Date format is " . $this->config->item('account_date_format') . ".</span>";
echo "</p>";
echo "<table class=\"voucher-table\">";
@@ -262,10 +265,10 @@ $(document).ready(function() {
echo "<p>";
echo form_fieldset('Options', array('class' => "fieldset-auto-width"));
- echo "<span id=\"tooltip-target-2\" class=\"hidden-element\">";
+ echo "<span id=\"tooltip-target-3\" class=\"hidden-element\">";
echo form_checkbox('voucher_draft', 1, $voucher_draft) . "Draft";
echo "</span>";
- echo "<span id=\"tooltip-content-2\">Draft vouchers do not affect any accouting caluculations.</span>";
+ echo "<span id=\"tooltip-content-3\">Draft vouchers do not affect any accouting caluculations.</span>";
echo "<br /><br />";
echo form_checkbox('voucher_print', 1, $voucher_print) . "Print";
echo " ";
commit b78c9836d2a89e7a9b9fece9dd0af321902eb6e3
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Jan 9 11:40:10 2011 +0530
Temporary Removed support for Draft voucher
- Temporary hidding all elements related to Draft vouchers
- After more testing will finalized on whether to keep or
remove Draft vouchers
- Miscellaneous UI fixes
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/assets/css/admin-style.css b/system/application/assets/css/admin-style.css
index d93301c..a8ce886 100644
--- a/system/application/assets/css/admin-style.css
+++ b/system/application/assets/css/admin-style.css
@@ -37,7 +37,7 @@ body {
background:none repeat scroll 0 0 #E5F1F4;
padding:0 15px 5px 15px;
-moz-border-radius:0 0 5px 5px;
- margin:0 0 0 500px;
+ margin:0 0 0 350px;
}
#content #main {
diff --git a/system/application/assets/css/style.css b/system/application/assets/css/style.css
index 027492b..05026a9 100644
--- a/system/application/assets/css/style.css
+++ b/system/application/assets/css/style.css
@@ -37,7 +37,7 @@ body {
background:none repeat scroll 0 0 #E5F1F4;
padding:0 15px 5px 15px;
-moz-border-radius:0 0 5px 5px;
- margin:0 0 0 500px;
+ margin:0 0 0 350px;
}
#header #info {
@@ -45,7 +45,7 @@ body {
display:block;
position:absolute;
right:18px;
- top:10px;
+ top:20px;
background:none repeat scroll 0 0 #EEEEEE;
padding:10px;
font-size:15px;
diff --git a/system/application/views/admin_template.php b/system/application/views/admin_template.php
index ea9c1e2..12a93e1 100644
--- a/system/application/views/admin_template.php
+++ b/system/application/views/admin_template.php
@@ -35,11 +35,22 @@ $(document).ready(function(){
<div id="logo">
<?php echo anchor('admin', 'Webzash', array('class' => 'anchor-link-b')); ?> <span id="admin-area">Admin area</span>
</div>
- <div id="admin">
- <?php echo anchor('', 'Back to Accounts', array('title' => "Back to accounts", 'class' => 'anchor-link-b')); ?> |
- <?php echo anchor('user/profile', 'Profile', array('title' => "Profile", 'class' => 'anchor-link-b')); ?> |
- <?php echo anchor('user/logout', 'Logout', array('title' => "Logout", 'class' => 'anchor-link-b')); ?>
- </div>
+ <?php
+ if ($this->session->userdata('user_name')) {
+ echo "<div id=\"admin\">";
+ echo anchor('', 'Accounts', array('title' => "Accounts", 'class' => 'anchor-link-b'));
+ echo " | ";
+ /* Check if allowed administer rights */
+ if (check_access('administer')) {
+ echo anchor('admin', 'Administer', array('title' => "Administer", 'class' => 'anchor-link-b'));
+ echo " | ";
+ }
+ echo anchor('user/profile', 'Profile', array('title' => "Profile", 'class' => 'anchor-link-b'));
+ echo " | ";
+ echo anchor('user/logout', 'Logout', array('title' => "Logout", 'class' => 'anchor-link-b'));
+ echo "</div>";
+ }
+ ?>
<div id="info">
</div>
</div>
diff --git a/system/application/views/template.php b/system/application/views/template.php
index c4441e0..0bc833e 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -70,6 +70,8 @@ $(document).ready(function() {
<?php
if ($this->session->userdata('user_name')) {
echo "<div id=\"admin\">";
+ echo anchor('', 'Accounts', array('title' => "Accounts", 'class' => 'anchor-link-b'));
+ echo " | ";
/* Check if allowed administer rights */
if (check_access('administer')) {
echo anchor('admin', 'Administer', array('title' => "Administer", 'class' => 'anchor-link-b'));
@@ -110,7 +112,7 @@ $(document).ready(function() {
<li><?php echo anchor('voucher/show/payment', 'Payment', array('title' => 'Payment Vouchers')); ?></li>
<li><?php echo anchor('voucher/show/contra', 'Contra', array('title' => 'Contra Vouchers')); ?></li>
<li><?php echo anchor('voucher/show/journal', 'Journal', array('title' => 'Journal Vouchers')); ?></li>
- <li><?php echo anchor('voucher/show/draft', 'Draft', array('title' => 'Draft Vouchers')); ?></li>
+ <li><?php // echo anchor('voucher/show/draft', 'Draft', array('title' => 'Draft Vouchers')); ?></li>
</ul>
</li>
<li>
diff --git a/system/application/views/user_template.php b/system/application/views/user_template.php
index 2f6fdf3..3d74d19 100644
--- a/system/application/views/user_template.php
+++ b/system/application/views/user_template.php
@@ -30,6 +30,8 @@
<?php
if ($this->session->userdata('user_name')) {
echo "<div id=\"admin\">";
+ echo anchor('', 'Accounts', array('title' => "Accounts", 'class' => 'anchor-link-b'));
+ echo " | ";
/* Check if allowed administer rights */
if (check_access('administer')) {
echo anchor('admin', 'Administer', array('title' => "Administer", 'class' => 'anchor-link-b'));
diff --git a/system/application/views/voucher/add.php b/system/application/views/voucher/add.php
index 78e0f32..677c696 100644
--- a/system/application/views/voucher/add.php
+++ b/system/application/views/voucher/add.php
@@ -262,7 +262,7 @@ $(document).ready(function() {
echo "<p>";
echo form_fieldset('Options', array('class' => "fieldset-auto-width"));
- echo "<span id=\"tooltip-target-2\">";
+ echo "<span id=\"tooltip-target-2\" class=\"hidden-element\">";
echo form_checkbox('voucher_draft', 1, $voucher_draft) . "Draft";
echo "</span>";
echo "<span id=\"tooltip-content-2\">Draft vouchers do not affect any accouting caluculations.</span>";
diff --git a/system/application/views/voucher/edit.php b/system/application/views/voucher/edit.php
index bbef785..0dfbd4e 100644
--- a/system/application/views/voucher/edit.php
+++ b/system/application/views/voucher/edit.php
@@ -262,7 +262,7 @@ $(document).ready(function() {
echo "<p>";
echo form_fieldset('Options', array('class' => "fieldset-auto-width"));
- echo "<span id=\"tooltip-target-2\">";
+ echo "<span id=\"tooltip-target-2\" class=\"hidden-element\">";
echo form_checkbox('voucher_draft', 1, $voucher_draft) . "Draft";
echo "</span>";
echo "<span id=\"tooltip-content-2\">Draft vouchers do not affect any accouting caluculations.</span>";
diff --git a/system/application/views/welcome.php b/system/application/views/welcome.php
index b87769a..46e6fba 100644
--- a/system/application/views/welcome.php
+++ b/system/application/views/welcome.php
@@ -89,7 +89,7 @@ jQuery(document).ready(function () {
<tr>
<td><div>Welcome back, <strong><?php echo $this->config->item('account_name');?> !</strong></div></td>
</tr>
- <tr>
+ <tr class="hidden-element">
<td><div id="dashboard-draft">You have <?php echo anchor("voucher/show/draft", $draft_count . " draft", array('class' => 'anchor-link-a')); ?> voucher(s)</div></td>
</tr>
</tbody>
commit 0511c87f8db54c9c9c947db9ab5675f15904a5da
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Jan 9 11:24:56 2011 +0530
Added CHANGELOG.txt file
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
new file mode 100644
index 0000000..e69de29
diff --git a/TODO.txt b/TODO.txt
new file mode 100644
index 0000000..0cb0a0c
--- /dev/null
+++ b/TODO.txt
@@ -0,0 +1,5 @@
+Priority - Task - Person responsible
+
+It is now available online at
+
+http://codaset.com/pshahmumbai/webzash/wiki/Project-Plan
diff --git a/todo.txt b/todo.txt
deleted file mode 100644
index 0cb0a0c..0000000
--- a/todo.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-Priority - Task - Person responsible
-
-It is now available online at
-
-http://codaset.com/pshahmumbai/webzash/wiki/Project-Plan
commit 13a59514e7d2cbfacd37355fdb3844cf7c0d28dd
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Jan 7 19:50:53 2011 +0530
Added user profile and account check
- Only allow user to access accounts as defined in the user
config file
- Added profile action to user controller
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/user.php b/system/application/controllers/user.php
index 9d31579..cebebff 100644
--- a/system/application/controllers/user.php
+++ b/system/application/controllers/user.php
@@ -11,6 +11,10 @@ class User extends Controller {
{
$this->template->set('page_title', 'Login');
+ /* If user already logged in then redirect to profile page */
+ if ($this->session->userdata('user_name'))
+ redirect('user/profile');
+
/* Form fields */
$data['user_name'] = array(
'name' => 'user_name',
@@ -154,6 +158,9 @@ class User extends Controller {
/* Currently active account */
$data['active_account'] = $this->session->userdata('active_account');
+ /* User validation */
+ $ini_file = $this->config->item('config_path') . "users/" . $this->session->userdata('user_name') . ".ini";
+
/* Getting list of files in the config - accounts directory */
$accounts_list = get_filenames($this->config->item('config_path') . 'accounts');
$data['accounts'] = array();
@@ -170,6 +177,37 @@ class User extends Controller {
}
}
+ /* Check if user ini file exists */
+ if ( ! get_file_info($ini_file))
+ {
+ $this->messages->add('User does not exists.', 'error');
+ redirect('user/profile');
+ return;
+ } else {
+ /* Parsing user ini file */
+ $active_users = parse_ini_file($ini_file);
+ if ( ! $active_users)
+ {
+ $this->messages->add('Invalid user file.', 'error');
+ redirect('user/profile');
+ return;
+ } else {
+ /* Account check */
+ if (isset($active_users['accounts']))
+ {
+ if ($active_users['accounts'] != '*')
+ {
+ $valid_accounts = explode(",", $active_users['accounts']);
+ $data['accounts'] = array_intersect($data['accounts'], $valid_accounts);
+ }
+ } else {
+ $this->messages->add('Invalid accounts in user file.', 'error');
+ redirect('user/profile');
+ return;
+ }
+ }
+ }
+
/* Form validations */
$this->form_validation->set_rules('account', 'Account', 'trim|required');
@@ -187,6 +225,15 @@ class User extends Controller {
return;
} else {
$data_active_account = $this->input->post('account', TRUE);
+
+ /* Check for valid account */
+ if ( ! array_key_exists($data_active_account, $data['accounts']))
+ {
+ $this->messages->add('Invalid account selected.', 'error');
+ $this->template->load('user_template', 'user/account', $data);
+ return;
+ }
+
$ini_file = $this->config->item('config_path') . "accounts/" . $data_active_account . ".ini";
/* Check if database ini file exists */
@@ -245,6 +292,22 @@ class User extends Controller {
}
return;
}
+
+ function profile()
+ {
+ $this->template->set('page_title', 'User Profile');
+
+ /* Check access */
+ if ( ! ($this->session->userdata('user_name')))
+ {
+ $this->messages->add('Permission denied.', 'error');
+ redirect('');
+ return;
+ }
+
+ $this->template->load('user_template', 'user/profile');
+ return;
+ }
}
/* End of file user.php */
diff --git a/system/application/views/admin_template.php b/system/application/views/admin_template.php
index 67e360c..ea9c1e2 100644
--- a/system/application/views/admin_template.php
+++ b/system/application/views/admin_template.php
@@ -37,6 +37,7 @@ $(document).ready(function(){
</div>
<div id="admin">
<?php echo anchor('', 'Back to Accounts', array('title' => "Back to accounts", 'class' => 'anchor-link-b')); ?> |
+ <?php echo anchor('user/profile', 'Profile', array('title' => "Profile", 'class' => 'anchor-link-b')); ?> |
<?php echo anchor('user/logout', 'Logout', array('title' => "Logout", 'class' => 'anchor-link-b')); ?>
</div>
<div id="info">
diff --git a/system/application/views/template.php b/system/application/views/template.php
index 554ea63..c4441e0 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -75,6 +75,8 @@ $(document).ready(function() {
echo anchor('admin', 'Administer', array('title' => "Administer", 'class' => 'anchor-link-b'));
echo " | ";
}
+ echo anchor('user/profile', 'Profile', array('title' => "Profile", 'class' => 'anchor-link-b'));
+ echo " | ";
echo anchor('user/logout', 'Logout', array('title' => "Logout", 'class' => 'anchor-link-b'));
echo "</div>";
}
diff --git a/system/application/views/user/profile.php b/system/application/views/user/profile.php
new file mode 100644
index 0000000..f17c4b6
--- /dev/null
+++ b/system/application/views/user/profile.php
@@ -0,0 +1,23 @@
+<?php
+ echo "<p>";
+ echo "You are currently logged in as: " . "<strong>" . $this->session->userdata('user_name') . "</strong>";
+ echo " (";
+ echo anchor('user/logout', 'Logout', array('title' => 'Logout', 'class' => 'anchor-link-a'));
+ echo ")";
+ echo "</p>";
+
+ echo "<p>";
+ echo "Your current role is: " . "<strong>" . $this->session->userdata('user_role') . "</strong>";
+ echo "</p>";
+
+ echo "<p>";
+ echo "Currently active account is: " . "<strong>";
+ if ($this->session->userdata('active_account'))
+ echo $this->session->userdata('active_account');
+ else
+ echo "(None)";
+ echo "</strong>";
+ echo " (";
+ echo anchor('user/account', 'Change', array('title' => 'Change Account', 'class' => 'anchor-link-a'));
+ echo ")";
+ echo "</p>";
diff --git a/system/application/views/user_template.php b/system/application/views/user_template.php
index 31dda8e..2f6fdf3 100644
--- a/system/application/views/user_template.php
+++ b/system/application/views/user_template.php
@@ -35,6 +35,8 @@
echo anchor('admin', 'Administer', array('title' => "Administer", 'class' => 'anchor-link-b'));
echo " | ";
}
+ echo anchor('user/profile', 'Profile', array('title' => "Profile", 'class' => 'anchor-link-b'));
+ echo " | ";
echo anchor('user/logout', 'Logout', array('title' => "Logout", 'class' => 'anchor-link-b'));
echo "</div>";
}
commit 45dc8752ae1643595729af66b3de26981bc0df3a
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Jan 7 14:38:36 2011 +0530
Filtering out bogus accounts received in $_POST
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/admin/user.php b/system/application/controllers/admin/user.php
index 7d83a04..8b0a592 100644
--- a/system/application/controllers/admin/user.php
+++ b/system/application/controllers/admin/user.php
@@ -155,7 +155,9 @@ class User extends Controller {
$this->template->load('admin_template', 'admin/user/add', $data);
return;
} else {
- $data_accounts_string = implode(",", $data_accounts);
+ /* Filtering out bogus accounts */
+ $data_accounts_valid = array_intersect($data['accounts'], $data_accounts);
+ $data_accounts_string = implode(",", $data_accounts_valid);
}
}
@@ -347,7 +349,9 @@ class User extends Controller {
$this->template->load('admin_template', 'admin/user/edit', $data);
return;
} else {
- $data_accounts_string = implode(",", $data_accounts);
+ /* Filtering out bogus accounts */
+ $data_accounts_valid = array_intersect($data['accounts'], $data_accounts);
+ $data_accounts_string = implode(",", $data_accounts_valid);
}
}
commit a4a66529d9fad83fa5432faffc588a9b723a0624
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Jan 7 14:27:16 2011 +0530
Check user status during user login
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/user.php b/system/application/controllers/user.php
index a0d94a4..9d31579 100644
--- a/system/application/controllers/user.php
+++ b/system/application/controllers/user.php
@@ -67,6 +67,21 @@ class User extends Controller {
$this->template->load('user_template', 'user/login', $data);
return;
} else {
+ /* Status check */
+ if (isset($active_users['status']))
+ {
+ if ($active_users['status'] != 1)
+ {
+ $this->messages->add('User disabled.', 'error');
+ $this->template->load('user_template', 'user/login', $data);
+ return;
+ }
+ } else {
+ $this->messages->add('Invalid status.', 'error');
+ $this->template->load('user_template', 'user/login', $data);
+ return;
+ }
+
/* Password check */
if (isset($active_users['password']))
{
commit 64e22684fac8f39b498fbc8b6eae3439d0d6ec7f
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Jan 7 14:15:26 2011 +0530
Added 'accounts' string to user config files
- if 'accounts' = "*" then allow access to all accounts
- if 'accounts' = "a,b,c" then allow access to
only a, b, c accounts
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/config/users/admin.ini b/config/users/admin.ini
index 325a281..003b6b0 100644
--- a/config/users/admin.ini
+++ b/config/users/admin.ini
@@ -4,4 +4,5 @@ password = "admin"
email = "pshah.mumbai(a)gmail.com"
role = "administrator"
status = "1"
+accounts = "*"
diff --git a/config/users/guest.ini b/config/users/guest.ini
index 948a505..e8cdf4e 100644
--- a/config/users/guest.ini
+++ b/config/users/guest.ini
@@ -4,4 +4,5 @@ password = "guest"
email = "pshah.mumbai(a)gmail.com"
role = "guest"
status = "1"
+accounts = "*"
diff --git a/system/application/controllers/admin/user.php b/system/application/controllers/admin/user.php
index 46e1a0e..7d83a04 100644
--- a/system/application/controllers/admin/user.php
+++ b/system/application/controllers/admin/user.php
@@ -83,6 +83,25 @@ class User extends Controller {
$data['active_user_role'] = "administrator";
$data['user_status'] = TRUE;
+ /* Accounts Form fields */
+ $data['accounts_all'] = TRUE;
+ $data['accounts_active'] = array();
+ /* Getting list of files in the config - accounts directory */
+ $accounts_list = get_filenames($this->config->item('config_path') . 'accounts');
+ $data['accounts'] = array();
+ if ($accounts_list)
+ {
+ foreach ($accounts_list as $row)
+ {
+ /* Only include file ending with .ini */
+ if (substr($row, -4) == ".ini")
+ {
+ $ini_label = substr($row, 0, -4);
+ $data['accounts'][$ini_label] = $ini_label;
+ }
+ }
+ }
+
/* Repopulating form */
if ($_POST)
{
@@ -91,6 +110,8 @@ class User extends Controller {
$data['user_email']['value'] = $this->input->post('user_email', TRUE);
$data['active_user_role'] = $this->input->post('user_role', TRUE);
$data['user_status'] = $this->input->post('user_status', TRUE);
+ $data['accounts_all'] = $this->input->post('accounts_all', TRUE);
+ $data['accounts_active'] = $this->input->post('accounts', TRUE);
}
/* Form validations */
@@ -99,6 +120,7 @@ class User extends Controller {
$this->form_validation->set_rules('user_email', 'Email', 'trim|required|valid_email');
$this->form_validation->set_rules('user_role', 'Role', 'trim|required');
$this->form_validation->set_rules('user_status', 'Active', 'trim');
+ $this->form_validation->set_rules('accounts_all', 'All Accounts', 'trim');
/* Validating form */
if ($this->form_validation->run() == FALSE)
@@ -118,6 +140,24 @@ class User extends Controller {
$data_user_status = 1;
else
$data_user_status = 0;
+ $data_accounts_all = $this->input->post('accounts_all', TRUE);
+ $data_accounts = $this->input->post('accounts', TRUE);
+
+ /* Forming account querry string */
+ $data_accounts_string = '';
+ if ($data_accounts_all == 1)
+ {
+ $data_accounts_string = '*';
+ } else {
+ if ( ! $data_accounts)
+ {
+ $this->messages->add('Please select account.', 'error');
+ $this->template->load('admin_template', 'admin/user/add', $data);
+ return;
+ } else {
+ $data_accounts_string = implode(",", $data_accounts);
+ }
+ }
$ini_file = $this->config->item('config_path') . "users/" . $data_user_name . ".ini";
@@ -129,8 +169,8 @@ class User extends Controller {
return;
}
- $user_details = "[user]" . "\r\n" . "username = \"" . $data_user_name . "\"" . "\r\n" . "password = \"" . $data_user_password . "\"" . "\r\n" . "email = \"" . $data_user_email . "\"" . "\r\n" . "role = \"" . $data_user_role . "\"" . "\r\n" . "status = \"" . $data_user_status . "\"" . "\r\n";
- $user_details_html = "[user]" . "<br />" . "username = \"" . $data_user_name . "\"" . "<br />" . "password = \"" . $data_user_password . "\"" . "<br />" . "email = \"" . $data_user_email . "\"" . "<br />" . "role = \"" . $data_user_role . "\"" . "<br />" . "status = \"" . $data_user_status . "\"" . "<br />";
+ $user_details = "[user]" . "\r\n" . "username = \"" . $data_user_name . "\"" . "\r\n" . "password = \"" . $data_user_password . "\"" . "\r\n" . "email = \"" . $data_user_email . "\"" . "\r\n" . "role = \"" . $data_user_role . "\"" . "\r\n" . "status = \"" . $data_user_status . "\"" . "\r\n" . "accounts = \"" . $data_accounts_string . "\"" . "\r\n";
+ $user_details_html = "[user]" . "<br />" . "username = \"" . $data_user_name . "\"" . "<br />" . "password = \"" . $data_user_password . "\"" . "<br />" . "email = \"" . $data_user_email . "\"" . "<br />" . "role = \"" . $data_user_role . "\"" . "<br />" . "status = \"" . $data_user_status . "\"" . "<br />" . "accounts = \"" . $data_accounts_string . "\"" . "<br />";
/* Writing the connection string to end of file - writing in 'a' append mode */
if ( ! write_file($ini_file, $user_details))
@@ -183,6 +223,25 @@ class User extends Controller {
$data['active_user_role'] = "";
$data['user_status'] = TRUE;
+ /* Accounts Form fields */
+ $data['accounts_all'] = TRUE;
+ $data['accounts_active'] = array();
+ /* Getting list of files in the config - accounts directory */
+ $accounts_list = get_filenames($this->config->item('config_path') . 'accounts');
+ $data['accounts'] = array();
+ if ($accounts_list)
+ {
+ foreach ($accounts_list as $row)
+ {
+ /* Only include file ending with .ini */
+ if (substr($row, -4) == ".ini")
+ {
+ $ini_label = substr($row, 0, -4);
+ $data['accounts'][$ini_label] = $ini_label;
+ }
+ }
+ }
+
/* Repopulating form */
if ($_POST)
{
@@ -190,6 +249,8 @@ class User extends Controller {
$data['user_email']['value'] = $this->input->post('user_email', TRUE);
$data['active_user_role'] = $this->input->post('user_role', TRUE);
$data['user_status'] = $this->input->post('user_status', TRUE);
+ $data['accounts_all'] = $this->input->post('accounts_all', TRUE);
+ $data['accounts_active'] = $this->input->post('accounts', TRUE);
} else {
/* Check if user ini file exists */
if ( ! get_file_info($ini_file))
@@ -229,6 +290,20 @@ class User extends Controller {
$data['user_status'] = $active_users['status'];
else
$this->messages->add('Status missing from user file.', 'error');
+
+ if (isset($active_users['accounts']))
+ {
+ if ($active_users['accounts'] == "*")
+ {
+ $data['accounts_all'] = TRUE;
+ $data['accounts_active'] = array();
+ } else {
+ $data['accounts_all'] = FALSE;
+ $data['accounts_active'] = explode(",", $active_users['accounts']);
+ }
+ } else {
+ $this->messages->add('Accounts missing from user file.', 'error');
+ }
}
}
}
@@ -238,6 +313,7 @@ class User extends Controller {
$this->form_validation->set_rules('user_email', 'Email', 'trim|required|valid_email');
$this->form_validation->set_rules('user_role', 'Role', 'trim|required');
$this->form_validation->set_rules('user_status', 'Active', 'trim');
+ $this->form_validation->set_rules('accounts_all', 'All Accounts', 'trim');
/* Validating form */
if ($this->form_validation->run() == FALSE)
@@ -256,11 +332,29 @@ class User extends Controller {
$data_user_status = 1;
else
$data_user_status = 0;
+ $data_accounts_all = $this->input->post('accounts_all', TRUE);
+ $data_accounts = $this->input->post('accounts', TRUE);
+
+ /* Forming account querry string */
+ $data_accounts_string = '';
+ if ($data_accounts_all == 1)
+ {
+ $data_accounts_string = '*';
+ } else {
+ if ( ! $data_accounts)
+ {
+ $this->messages->add('Please select account.', 'error');
+ $this->template->load('admin_template', 'admin/user/edit', $data);
+ return;
+ } else {
+ $data_accounts_string = implode(",", $data_accounts);
+ }
+ }
$ini_file = $this->config->item('config_path') . "users/" . $user_name . ".ini";
- $user_details = "[user]" . "\r\n" . "username = \"" . $user_name . "\"" . "\r\n" . "password = \"" . $data_user_password . "\"" . "\r\n" . "email = \"" . $data_user_email . "\"" . "\r\n" . "role = \"" . $data_user_role . "\"" . "\r\n" . "status = \"" . $data_user_status . "\"" . "\r\n";
- $user_details_html = "[user]" . "<br />" . "username = \"" . $user_name . "\"" . "<br />" . "password = \"" . $data_user_password . "\"" . "<br />" . "email = \"" . $data_user_email . "\"" . "<br />" . "role = \"" . $data_user_role . "\"" . "<br />" . "status = \"" . $data_user_status . "\"" . "<br />";
+ $user_details = "[user]" . "\r\n" . "username = \"" . $user_name . "\"" . "\r\n" . "password = \"" . $data_user_password . "\"" . "\r\n" . "email = \"" . $data_user_email . "\"" . "\r\n" . "role = \"" . $data_user_role . "\"" . "\r\n" . "status = \"" . $data_user_status . "\"" . "\r\n" . "accounts = \"" . $data_accounts_string . "\"" . "\r\n";
+ $user_details_html = "[user]" . "<br />" . "username = \"" . $user_name . "\"" . "<br />" . "password = \"" . $data_user_password . "\"" . "<br />" . "email = \"" . $data_user_email . "\"" . "<br />" . "role = \"" . $data_user_role . "\"" . "<br />" . "status = \"" . $data_user_status . "\"" . "<br />" . "accounts = \"" . $data_accounts_string . "\"" . "<br />";
/* Writing the connection string to end of file - writing in 'a' append mode */
if ( ! write_file($ini_file, $user_details))
diff --git a/system/application/views/admin/user/add.php b/system/application/views/admin/user/add.php
index 9fe806a..e456a3e 100644
--- a/system/application/views/admin/user/add.php
+++ b/system/application/views/admin/user/add.php
@@ -26,7 +26,13 @@
echo "</p>";
echo "<p>";
- echo form_checkbox('user_status', 1, $user_status) . "Active";
+ echo form_checkbox('user_status', 1, $user_status) . " Active";
+ echo "</p>";
+
+ echo "<p>";
+ echo form_checkbox('accounts_all', 1, $accounts_all) . " All Accounts or Select accounts";
+ echo "<br />";
+ echo form_multiselect('accounts[]', $accounts, $accounts_active);
echo "</p>";
echo "<p>";
diff --git a/system/application/views/admin/user/edit.php b/system/application/views/admin/user/edit.php
index be623aa..6956333 100644
--- a/system/application/views/admin/user/edit.php
+++ b/system/application/views/admin/user/edit.php
@@ -30,6 +30,12 @@
echo "</p>";
echo "<p>";
+ echo form_checkbox('accounts_all', 1, $accounts_all) . " All Accounts or Select accounts";
+ echo "<br />";
+ echo form_multiselect('accounts[]', $accounts, $accounts_active);
+ echo "</p>";
+
+ echo "<p>";
echo form_submit('submit', 'Update');
echo " ";
echo anchor('admin/user', 'Back', array('title' => 'Back to user list'));
commit f1b7a819db6370bfca7e10d07360c74b0d81664b
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Jan 6 15:52:20 2011 +0530
Updated messages
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/admin/create.php b/system/application/controllers/admin/create.php
index d6b5f53..d98a268 100644
--- a/system/application/controllers/admin/create.php
+++ b/system/application/controllers/admin/create.php
@@ -9,7 +9,7 @@ class Create extends Controller {
/* Check access */
if ( ! check_access('administer'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('');
return;
}
@@ -20,7 +20,7 @@ class Create extends Controller {
function index()
{
$this->load->helper('file');
- $this->template->set('page_title', 'Create new webzash account');
+ $this->template->set('page_title', 'Create account');
/* Form fields */
$default_start = '01/04/';
diff --git a/system/application/controllers/admin/manage.php b/system/application/controllers/admin/manage.php
index bdf0fa6..e4d7de2 100644
--- a/system/application/controllers/admin/manage.php
+++ b/system/application/controllers/admin/manage.php
@@ -9,7 +9,7 @@ class Manage extends Controller {
/* Check access */
if ( ! check_access('administer'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('');
return;
}
@@ -20,7 +20,7 @@ class Manage extends Controller {
function index()
{
$this->load->helper('file');
- $this->template->set('page_title', 'Manage webzash accounts');
+ $this->template->set('page_title', 'Manage accounts');
$this->template->set('nav_links', array('admin/manage/add' => 'New account'));
/* Getting list of files in the config - accounts directory */
@@ -45,7 +45,7 @@ class Manage extends Controller {
function add()
{
- $this->template->set('page_title', 'Add a webzash account');
+ $this->template->set('page_title', 'Add account');
/* Form fields */
$data['database_label'] = array(
@@ -160,7 +160,7 @@ class Manage extends Controller {
function edit($database_label)
{
- $this->template->set('page_title', 'Edit a webzash account');
+ $this->template->set('page_title', 'Edit account');
$ini_file = $this->config->item('config_path') . "accounts/" . $database_label . ".ini";
@@ -297,7 +297,7 @@ class Manage extends Controller {
function delete($database_label)
{
- $this->template->set('page_title', 'Delete a webzash account');
+ $this->template->set('page_title', 'Delete account');
$ini_file = $this->config->item('config_path') . "accounts/" . $database_label . ".ini";
$this->messages->add('Delete ' . $ini_file . ' file manually.', 'error');
diff --git a/system/application/controllers/admin/setting.php b/system/application/controllers/admin/setting.php
index d29d078..79a8b42 100644
--- a/system/application/controllers/admin/setting.php
+++ b/system/application/controllers/admin/setting.php
@@ -9,7 +9,7 @@ class Setting extends Controller {
/* Check access */
if ( ! check_access('administer'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('');
return;
}
diff --git a/system/application/controllers/admin/status.php b/system/application/controllers/admin/status.php
index 9b25bb9..27e7413 100644
--- a/system/application/controllers/admin/status.php
+++ b/system/application/controllers/admin/status.php
@@ -9,7 +9,7 @@ class Status extends Controller {
/* Check access */
if ( ! check_access('administer'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('');
return;
}
diff --git a/system/application/controllers/admin/welcome.php b/system/application/controllers/admin/welcome.php
index cc93d5b..613ad8e 100644
--- a/system/application/controllers/admin/welcome.php
+++ b/system/application/controllers/admin/welcome.php
@@ -9,7 +9,7 @@ class Welcome extends Controller {
/* Check access */
if ( ! check_access('administer'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('');
return;
}
diff --git a/system/application/controllers/group.php b/system/application/controllers/group.php
index 83dc0e3..4638937 100644
--- a/system/application/controllers/group.php
+++ b/system/application/controllers/group.php
@@ -23,7 +23,7 @@ class Group extends Controller {
/* Check access */
if ( ! check_access('create group'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('account');
return;
}
@@ -109,7 +109,7 @@ class Group extends Controller {
/* Check access */
if ( ! check_access('edit group'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('account');
return;
}
@@ -228,7 +228,7 @@ class Group extends Controller {
/* Check access */
if ( ! check_access('delete group'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('account');
return;
}
diff --git a/system/application/controllers/ledger.php b/system/application/controllers/ledger.php
index 7a86132..08244ac 100644
--- a/system/application/controllers/ledger.php
+++ b/system/application/controllers/ledger.php
@@ -23,7 +23,7 @@ class Ledger extends Controller {
/* Check access */
if ( ! check_access('create ledger'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('account');
return;
}
@@ -125,7 +125,7 @@ class Ledger extends Controller {
/* Check access */
if ( ! check_access('edit ledger'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('account');
return;
}
@@ -250,7 +250,7 @@ class Ledger extends Controller {
/* Check access */
if ( ! check_access('delete ledger'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('account');
return;
}
diff --git a/system/application/controllers/log.php b/system/application/controllers/log.php
index 2785969..c6160ed 100644
--- a/system/application/controllers/log.php
+++ b/system/application/controllers/log.php
@@ -11,7 +11,7 @@ class Log extends Controller {
/* Check access */
if ( ! check_access('view log'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('');
return;
}
@@ -24,7 +24,7 @@ class Log extends Controller {
/* Check access */
if ( ! check_access('clear log'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('');
return;
}
@@ -48,7 +48,7 @@ class Log extends Controller {
/* Check access */
if ( ! check_access('view log'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('');
return;
}
diff --git a/system/application/controllers/report.php b/system/application/controllers/report.php
index d6048b6..3dd7e1d 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -11,7 +11,7 @@ class Report extends Controller {
/* Check access */
if ( ! check_access('view reports'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('');
return;
}
diff --git a/system/application/controllers/setting.php b/system/application/controllers/setting.php
index 0dc5788..1383c07 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -10,7 +10,7 @@ class Setting extends Controller {
/* Check access */
if ( ! check_access('change account settings'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('');
return;
}
@@ -170,7 +170,7 @@ class Setting extends Controller {
/* Check access */
if ( ! check_access('cf account'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('setting');
return;
}
@@ -801,7 +801,7 @@ class Setting extends Controller {
/* Check access */
if ( ! check_access('backup account'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('setting');
return;
}
diff --git a/system/application/controllers/tag.php b/system/application/controllers/tag.php
index ccd49d8..56eb158 100644
--- a/system/application/controllers/tag.php
+++ b/system/application/controllers/tag.php
@@ -24,7 +24,7 @@ class Tag extends Controller {
/* Check access */
if ( ! check_access('create tag'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('tag');
return;
}
@@ -119,7 +119,7 @@ class Tag extends Controller {
/* Check access */
if ( ! check_access('edit tag'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('tag');
return;
}
@@ -232,7 +232,7 @@ class Tag extends Controller {
/* Check access */
if ( ! check_access('delete tag'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('tag');
return;
}
diff --git a/system/application/controllers/voucher.php b/system/application/controllers/voucher.php
index 91fcbf2..e5b44c6 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -246,7 +246,7 @@ class Voucher extends Controller {
/* Check access */
if ( ! check_access('create voucher'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('voucher/show/' . $voucher_type);
return;
}
@@ -569,7 +569,7 @@ class Voucher extends Controller {
/* Check access */
if ( ! check_access('edit voucher'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('voucher/show/' . $voucher_type);
return;
}
@@ -926,7 +926,7 @@ class Voucher extends Controller {
/* Check access */
if ( ! check_access('delete voucher'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('voucher/show/' . $voucher_type);
return;
}
@@ -972,7 +972,7 @@ class Voucher extends Controller {
/* Check access */
if ( ! check_access('download voucher'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('voucher/show/' . $voucher_type);
return;
}
@@ -1029,7 +1029,7 @@ class Voucher extends Controller {
/* Check access */
if ( ! check_access('print voucher'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('voucher/show/' . $voucher_type);
return;
}
@@ -1084,7 +1084,7 @@ class Voucher extends Controller {
/* Check access */
if ( ! check_access('email voucher'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('voucher/show/' . $voucher_type);
return;
}
commit 596899e0b12e257a039c6268a3b9d2408c4b08a8
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Jan 6 15:37:15 2011 +0530
Using the real user login procedure
- Removed the dummy user login procedure
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/admin/user.php b/system/application/controllers/admin/user.php
index f27f89e..46e1a0e 100644
--- a/system/application/controllers/admin/user.php
+++ b/system/application/controllers/admin/user.php
@@ -9,7 +9,7 @@ class User extends Controller {
/* Check access */
if ( ! check_access('administer'))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('');
return;
}
@@ -202,33 +202,33 @@ class User extends Controller {
$active_users = parse_ini_file($ini_file);
if ( ! $active_users)
{
- $this->messages->add('Invalid user file', 'error');
+ $this->messages->add('Invalid user file.', 'error');
} else {
/* Check if all needed variables are set in ini file */
if (isset($active_users['username']))
$data['user_name'] = $user_name;
else
- $this->messages->add('Username missing from user file', 'error');
+ $this->messages->add('Username missing from user file.', 'error');
if (isset($active_users['password']))
$data['user_password']['value'] = $active_users['password'];
else
- $this->messages->add('Password missing from user file', 'error');
+ $this->messages->add('Password missing from user file.', 'error');
if (isset($active_users['email']))
$data['user_email']['value'] = $active_users['email'];
else
- $this->messages->add('Email missing from user file', 'error');
+ $this->messages->add('Email missing from user file.', 'error');
if (isset($active_users['role']))
$data['active_user_role'] = $active_users['role'];
else
- $this->messages->add('Role missing from user file', 'error');
+ $this->messages->add('Role missing from user file.', 'error');
if (isset($active_users['status']))
$data['user_status'] = $active_users['status'];
else
- $this->messages->add('Status missing from user file', 'error');
+ $this->messages->add('Status missing from user file.', 'error');
}
}
}
@@ -284,7 +284,7 @@ class User extends Controller {
if ($this->session->userdata('user_name') == $user_name)
{
- $this->messages->add('Cannot delete currently logged in user', 'error');
+ $this->messages->add('Cannot delete currently logged in user.', 'error');
redirect('admin/user');
return;
}
diff --git a/system/application/controllers/user.php b/system/application/controllers/user.php
index 67cf567..a0d94a4 100644
--- a/system/application/controllers/user.php
+++ b/system/application/controllers/user.php
@@ -49,30 +49,63 @@ class User extends Controller {
$data_user_name = $this->input->post('user_name', TRUE);
$data_user_password = $this->input->post('user_password', TRUE);
- /* Dummy accounts */
- if ($data_user_name == "admin" && $data_user_password = "admin")
- {
- $this->messages->add('Logged in as ' . 'admin' . '.', 'success');
- $this->session->set_userdata('user_name', 'admin');
- $this->session->set_userdata('user_role', 'administrator');
- redirect('');
- return;
- } else if ($data_user_name == "guest" && $data_user_password = "guest")
+ /* User validation */
+ $ini_file = $this->config->item('config_path') . "users/" . $data_user_name . ".ini";
+
+ /* Check if user ini file exists */
+ if ( ! get_file_info($ini_file))
{
- $this->messages->add('Logged in as ' . 'guest' . '.', 'success');
- $this->session->set_userdata('user_name', 'guest');
- $this->session->set_userdata('user_role', 'guest');
- redirect('');
- return;
- } else {
- $this->session->unset_userdata('user_name');
- $this->session->unset_userdata('user_role');
- $this->session->unset_userdata('active_account');
- $this->messages->add('Invalid User name or Password.', 'error');
+ $this->messages->add('User does not exists.', 'error');
$this->template->load('user_template', 'user/login', $data);
return;
+ } else {
+ /* Parsing user ini file */
+ $active_users = parse_ini_file($ini_file);
+ if ( ! $active_users)
+ {
+ $this->messages->add('Invalid user file.', 'error');
+ $this->template->load('user_template', 'user/login', $data);
+ return;
+ } else {
+ /* Password check */
+ if (isset($active_users['password']))
+ {
+ $password = $active_users['password'];
+
+ /* Role check */
+ if (isset($active_users['role']))
+ {
+ $data_user_role = $active_users['role'];
+ } else {
+ $this->messages->add('Invalid role. Defaulting to "guest" role.', 'success');
+ $data_user_role = 'guest';
+ }
+
+ /* Password verify */
+ if ($password == $data_user_password)
+ {
+ $this->messages->add('Logged in as ' . $data_user_name . '.', 'success');
+ $this->session->set_userdata('user_name', $data_user_name);
+ $this->session->set_userdata('user_role', $data_user_role);
+ redirect('');
+ return;
+ } else {
+ $this->session->unset_userdata('user_name');
+ $this->session->unset_userdata('user_role');
+ $this->session->unset_userdata('active_account');
+ $this->messages->add('Authentication failed.', 'error');
+ $this->template->load('user_template', 'user/login', $data);
+ return;
+ }
+ } else {
+ $this->messages->add('Password missing from user file.', 'error');
+ $this->template->load('user_template', 'user/login', $data);
+ return;
+ }
+ }
}
}
+ return;
}
function logout()
@@ -98,7 +131,7 @@ class User extends Controller {
/* Check access */
if ( ! ($this->session->userdata('user_name')))
{
- $this->messages->add('Permission denied', 'error');
+ $this->messages->add('Permission denied.', 'error');
redirect('');
return;
}
diff --git a/system/application/views/user/login.php b/system/application/views/user/login.php
index db9f576..f4be483 100644
--- a/system/application/views/user/login.php
+++ b/system/application/views/user/login.php
@@ -14,11 +14,11 @@
echo "</p>";
echo "<p>";
- echo form_submit('submit', 'Login');
+ echo "<span class=\"form-help-text\">Hint : You may login with user name as 'admin' and password as 'admin'</span>";
echo "</p>";
echo "<p>";
- echo "<span class=\"form-help-text\">Hint : You may login with user name as 'admin' and password as 'admin'</span>";
+ echo form_submit('submit', 'Login');
echo "</p>";
echo form_close();
commit 5cd1b66336a925a242ea53ae72c66ce0fadc51ad
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Jan 6 15:01:36 2011 +0530
Removed account details from admin welcome controller
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/admin/welcome.php b/system/application/controllers/admin/welcome.php
index 7fca9df..cc93d5b 100644
--- a/system/application/controllers/admin/welcome.php
+++ b/system/application/controllers/admin/welcome.php
@@ -21,133 +21,7 @@ class Welcome extends Controller {
{
$this->template->set('page_title', 'Administer Webzash');
- $data['current_account'] = "";
-
- /* Reading database settings ini file */
- $is_label_set = FALSE;
- if ($this->session->userdata('active_account'))
- {
- $is_label_set = TRUE;
-
- /* Fetching database label details from session */
- $current_account = $this->session->userdata('active_account');
- $ini_file = $this->config->item('config_path') . "accounts/" . $current_account . ".ini";
-
- /* Check if database ini file exists */
- if ( ! get_file_info($ini_file))
- {
- $this->messages->add('Account settings file is missing.', 'error');
- } else {
- /* Parsing database ini file */
- $active_accounts = parse_ini_file($ini_file);
- if ( ! $active_accounts)
- {
- $this->messages->add('Invalid account settings file.', 'error');
- } else {
- /* Check if all needed variables are set in ini file */
- $ini_ok = TRUE;
- if ( ! isset($active_accounts['db_hostname']))
- {
- $ini_ok = FALSE;
- $this->messages->add('Hostname missing from account settings file.', 'error');
- }
- if ( ! isset($active_accounts['db_port']))
- {
- $ini_ok = FALSE;
- $this->messages->add('Port missing from account settings file. Default MySQL port is 3306.', 'error');
- }
- if ( ! isset($active_accounts['db_name']))
- {
- $ini_ok = FALSE;
- $this->messages->add('Database name missing from account settings file.', 'error');
- }
- if ( ! isset($active_accounts['db_username']))
- {
- $ini_ok = FALSE;
- $this->messages->add('Database username missing from account settings file.', 'error');
- }
- if ( ! isset($active_accounts['db_password']))
- {
- $ini_ok = FALSE;
- $this->messages->add('Database password missing from account settings file.', 'error');
- }
-
- if ($ini_ok)
- {
- /* Preparing database settings */
- $db_config['hostname'] = $active_accounts['db_hostname'];
- $db_config['hostname'] .= ":" . $active_accounts['db_port'];
- $db_config['database'] = $active_accounts['db_name'];
- $db_config['username'] = $active_accounts['db_username'];
- $db_config['password'] = $active_accounts['db_password'];
- $db_config['dbdriver'] = "mysql";
- $db_config['dbprefix'] = "";
- $db_config['pconnect'] = FALSE;
- $db_config['db_debug'] = FALSE;
- $db_config['cache_on'] = FALSE;
- $db_config['cachedir'] = "";
- $db_config['char_set'] = "utf8";
- $db_config['dbcollat'] = "utf8_general_ci";
- $this->load->database($db_config, FALSE, TRUE);
- }
- }
- }
- } else {
- $is_label_set = FALSE;
- }
-
- if ($is_label_set)
- {
- /* Checking for valid database connection */
- if ($this->db->conn_id)
- {
- /* Checking for valid database name, username, password */
- if ($this->db->query("SHOW TABLES"))
- {
- $valid_webzash_db = TRUE;
- /* Check for valid webzash database */
- $table_names = array('settings', 'groups', 'ledgers', 'vouchers', 'voucher_items', 'tags', 'logs');
- foreach ($table_names as $id => $tbname)
- {
- $valid_db_q = mysql_query('DESC ' . $tbname);
- if ( ! $valid_db_q)
- {
- $valid_webzash_db = FALSE;
- $this->messages->add('Invalid account database.', 'error');
- break;
- }
- }
-
- /* Loading account data */
- if ($valid_webzash_db)
- {
- $valid_db_q = mysql_query('DESC settings');
- if ($valid_db_q)
- {
- $account_q = $this->db->query('SELECT * FROM settings WHERE id = 1');
- if ($account_d = $account_q->row())
- {
- $this->config->set_item('account_date_format', $account_d->date_format);
- $data['current_account'] .= "Currently active account is ";
- $data['current_account'] .= "<b>" . $account_d->name . "</b>";
- $data['current_account'] .= " from " . "<b>" . date_mysql_to_php_display($account_d->fy_start) . "</b>";
- $data['current_account'] .= " to " . "<b>" . date_mysql_to_php_display($account_d->fy_end) . "</b>";
- $data['current_account'] .= " ( " . anchor('admin/active', 'change active account', array('title' => 'Activate a existing account', 'style' => 'color:#000000')) . " )";
- }
- }
- }
- } else {
- $this->messages->add('Invalid database connection settings. Verify whether the provided database name, username and password is valid.', 'error');
- }
- } else {
- $this->messages->add('Cannot connect to database server. Verify whether database server is running.', 'error');
- }
- }
-
- if ($data['current_account'] == "")
- $data['current_account'] = "No account is currently active. You can " . anchor('admin/create', 'create', array('title' => 'Create a new account', 'style' => 'color:#000000')) . " a new account or " . anchor('user/account', 'activate', array('title' => 'Activate a existing account', 'style' => 'color:#000000')) . " an existing account";
-
- /* check status report */
+ /* Check status report */
$this->load->library('statuscheck');
$statuscheck = new Statuscheck();
$statuscheck->check_permissions();
@@ -156,7 +30,7 @@ class Welcome extends Controller {
$this->messages->add('One or more problems were detected with your installation. Check the ' . anchor('admin/status', 'Status report', array('title' => 'Check Status report', 'class' => 'anchor-link-a')) . ' for more information.', 'error');
}
- $this->template->load('admin_template', 'admin/welcome', $data);
+ $this->template->load('admin_template', 'admin/welcome');
return;
}
}
diff --git a/system/application/views/admin/welcome.php b/system/application/views/admin/welcome.php
index b233482..997ddd6 100644
--- a/system/application/views/admin/welcome.php
+++ b/system/application/views/admin/welcome.php
@@ -1,8 +1,4 @@
<div>
- <div id="current-active-account">
- <?php echo $current_account; ?>
- </div>
-
<div id="left-col">
<div class="settings-container">
<div class="settings-title">
commit b21bdbd8010605b903eaf85f7b0936fefd665362
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Jan 6 12:30:43 2011 +0530
Added Help for enabling or disabling logging
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/views/help/index.php b/system/application/views/help/index.php
index ce75d2d..9ef9d4d 100644
--- a/system/application/views/help/index.php
+++ b/system/application/views/help/index.php
@@ -1,4 +1,9 @@
<ul id="qa-list">
+<li><span class="qa-heading">General</span>
+ <ul>
+ <li><a href="#general-1" class="anchor-link-a">How do I enable / disable logging ?</a></li>
+ </ul>
+</li>
<li><span class="qa-heading">Printing</span>
<ul>
<li><a href="#print-1" class="anchor-link-a">How do I modify the voucher print format ?</a></li>
@@ -14,6 +19,12 @@
<br /><br />
+<div class="qa-section" id="general-1">
+ <a name="print-1"></a>
+ <div class="qa-question">Q. How do I enable / disable logging ?</div>
+ <div class="qa-answer">You need "administrator" permissions to do this. After logging with "administrator" permissions click on "Administer" link on the top of the page. Then go to "General Settings" and check / uncheck the "Log Messages" option and click on "Update".<br /><br />Note: You can do this manually by opening the "config/settings/general.ini" in a text editor and changing the value of log = "1" or log = "0" to enable or disable logging respectively.</div>
+</div>
+
<div class="qa-section" id="print-1">
<a name="print-1"></a>
<div class="qa-question">Q. How do I modify the voucher print format ?</div>
commit b45e734c94f9dbc398da4752be62b4586bda9875
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Jan 6 12:17:33 2011 +0530
Include logged in username to logs
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/libraries/Logger.php b/system/application/libraries/Logger.php
index aecd806..be4beb7 100644
--- a/system/application/libraries/Logger.php
+++ b/system/application/libraries/Logger.php
@@ -34,6 +34,7 @@ class Logger
default: $data['level'] = 0; break;
}
$data['host_ip'] = $CI->input->ip_address();
+ $data['user'] = $CI->session->userdata('user_name');
$data['url'] = uri_string();
$data['user_agent'] = $CI->input->user_agent();
$data['message_title'] = $title;
diff --git a/system/application/views/log/index.php b/system/application/views/log/index.php
index 99d9b66..26bb9ba 100644
--- a/system/application/views/log/index.php
+++ b/system/application/views/log/index.php
@@ -1,15 +1,16 @@
<?php
$logs_q = $this->db->query('SELECT * FROM logs ORDER BY id DESC');
echo "<table border=0 class=\"simple-table\">";
- echo "<thead><tr><th width=\"90\">Date</th><th>Host IP</th><th>Message</th><th width=\"30\">URL</th><th>Browser</th></tr></thead>";
+ echo "<thead><tr><th width=\"90\">Date</th><th>Host IP</th><th>User</th><th>Message</th><th width=\"30\">URL</th><th>Browser</th></tr></thead>";
foreach ($logs_q->result() as $row)
{
echo "<tr>";
echo "<td>" . date_mysql_to_php_display($row->date) . "</td>";
echo "<td>" . $row->host_ip . "</td>";
+ echo "<td>" . $row->user . "</td>";
echo "<td>" . $row->message_title . "</td>";
echo "<td>" . anchor($row->url, "Link", array('title' => 'Link to action', 'class' => 'anchor-link-a')) . "</td>";
- echo "<td>" . character_limiter($row->user_agent, 25) . "</td>";
+ echo "<td>" . character_limiter($row->user_agent, 30) . "</td>";
echo "</tr>";
}
echo "</table>";
commit 1475d36b76d2799c61aa86ecd3bed36588740ba3
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Jan 6 12:10:28 2011 +0530
Added settings to enable or disable logging
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/config/settings/general.ini b/config/settings/general.ini
index 037e2ae..fe5a1da 100644
--- a/config/settings/general.ini
+++ b/config/settings/general.ini
@@ -1,3 +1,4 @@
[general]
row_count = "10"
+log = "1"
diff --git a/system/application/controllers/admin/setting.php b/system/application/controllers/admin/setting.php
index 329b594..d29d078 100644
--- a/system/application/controllers/admin/setting.php
+++ b/system/application/controllers/admin/setting.php
@@ -23,6 +23,7 @@ class Setting extends Controller {
/* Default settings */
$data['row_count'] = 20;
+ $data['log'] = 1;
/* Loading settings from ini file */
$ini_file = $this->config->item('config_path') . "settings/general.ini";
@@ -35,6 +36,7 @@ class Setting extends Controller {
if ($cur_setting)
{
$data['row_count'] = isset($cur_setting['row_count']) ? $cur_setting['row_count'] : "20";
+ $data['log'] = isset($cur_setting['log']) ? $cur_setting['log'] : "1";
}
}
@@ -49,11 +51,13 @@ class Setting extends Controller {
/* Form validations */
$this->form_validation->set_rules('row_count', 'Row Count', 'trim|required|is_natural_no_zero');
+ $this->form_validation->set_rules('log', 'Log Messages', 'trim');
/* Repopulating form */
if ($_POST)
{
$data['row_count'] = $this->input->post('row_count', TRUE);
+ $data['log'] = $this->input->post('log', TRUE);
}
/* Validating form */
@@ -66,6 +70,7 @@ class Setting extends Controller {
else
{
$data_row_count = $this->input->post('row_count', TRUE);
+ $data_log = $this->input->post('log', TRUE);
if ($data_row_count < 0 || $data_row_count > 200)
{
@@ -74,9 +79,14 @@ class Setting extends Controller {
return;
}
- $new_setting = "[general]" . "\r\n" . "row_count = \"" . $data_row_count . "\"" . "\r\n";
+ if ($data_log == 1)
+ $data_log = 1;
+ else
+ $data_log = 0;
- $new_setting_html = '[general]<br />row_count = "' . $data_row_count . '"<br />';
+ $new_setting = "[general]" . "\r\n" . "row_count = \"" . $data_row_count . "\"" . "\r\n" . "log = \"" . $data_log . "\"" . "\r\n";
+
+ $new_setting_html = '[general]<br />row_count = "' . $data_row_count . '"<br />' . "log = \"" . $data_log . "\"" . "<br />";
/* Writing the connection string to end of file - writing in 'a' append mode */
if ( ! write_file($ini_file, $new_setting))
diff --git a/system/application/libraries/Logger.php b/system/application/libraries/Logger.php
index 8adb7da..aecd806 100644
--- a/system/application/libraries/Logger.php
+++ b/system/application/libraries/Logger.php
@@ -18,15 +18,20 @@ class Logger
function write_message($level = "debug", $title = "", $desc = "")
{
$CI =& get_instance();
+
+ /* Check if logging is enabled. Skip if it is not enabled */
+ if ($CI->config->item('log') != "1")
+ return;
+
$data['date'] = date("Y-m-d H:i:s");
$data['level'] = 3;
switch ($level)
{
- case "error": $data['level'] = 0; break;
- case "success": $data['level'] = 1; break;
- case "info": $data['level'] = 2; break;
- case "debug": $data['level'] = 3; break;
- default: $data['level'] = 0; break;
+ case "error": $data['level'] = 0; break;
+ case "success": $data['level'] = 1; break;
+ case "info": $data['level'] = 2; break;
+ case "debug": $data['level'] = 3; break;
+ default: $data['level'] = 0; break;
}
$data['host_ip'] = $CI->input->ip_address();
$data['url'] = uri_string();
@@ -34,6 +39,7 @@ class Logger
$data['message_title'] = $title;
$data['message_desc'] = $desc;
$CI->db->insert('logs', $data);
+ return;
}
function read_recent_messages()
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index a751f73..9742d99 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -171,6 +171,10 @@ class Startup
{
$CI->config->set_item('row_count', $cur_setting['row_count']);
}
+ if (isset($cur_setting['log']))
+ {
+ $CI->config->set_item('log', $cur_setting['log']);
+ }
}
}
return;
diff --git a/system/application/views/admin/setting.php b/system/application/views/admin/setting.php
index f365f0a..afd037c 100644
--- a/system/application/views/admin/setting.php
+++ b/system/application/views/admin/setting.php
@@ -8,6 +8,10 @@
echo "</p>";
echo "<p>";
+ echo form_checkbox('log', 1, $log) . " Log Messages";
+ echo "</p>";
+
+ echo "<p>";
echo form_submit('submit', 'Update');
echo " ";
echo anchor('admin', 'Back', array('title' => 'Back to admin'));
commit 497ac1bb4989bcc9a1cb64f7c1bc6a2f76c440bc
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Jan 6 11:52:58 2011 +0530
Added users directory status checks
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/admin/status.php b/system/application/controllers/admin/status.php
index cdf1da7..9b25bb9 100644
--- a/system/application/controllers/admin/status.php
+++ b/system/application/controllers/admin/status.php
@@ -16,7 +16,7 @@ class Status extends Controller {
return;
}
-
+
function index()
{
$this->load->library('statuscheck');
diff --git a/system/application/libraries/Statuscheck.php b/system/application/libraries/Statuscheck.php
index f81acf0..0ef1a39 100644
--- a/system/application/libraries/Statuscheck.php
+++ b/system/application/libraries/Statuscheck.php
@@ -11,24 +11,32 @@ class Statuscheck {
function check_permissions()
{
$CI =& get_instance();
+
+ /* Writable check */
$check_path = $CI->config->item('config_path') . "settings/";
if (! is_writable($check_path))
{
- $this->error_messages[] = 'Application settings directory "' . $check_path . '" is not writable. You will not able to save or edit any application related settings.';
+ $this->error_messages[] = 'Application settings directory "' . $check_path . '" is not writable. You will not able to edit any application related settings.';
}
-
+
$check_path = $CI->config->item('config_path') . "accounts/";
if (! is_writable($check_path))
{
- $this->error_messages[] = 'Account settings directory "' . $check_path . '" is not writable. You will not able to save or edit any account related settings.';
+ $this->error_messages[] = 'Account settings directory "' . $check_path . '" is not writable. You will not able to add or edit any account related settings.';
}
-
+
+ $check_path = $CI->config->item('config_path') . "users/";
+ if (! is_writable($check_path))
+ {
+ $this->error_messages[] = 'User directory "' . $check_path . '" is not writable. You will not able to add or edit any users.';
+ }
+
$check_path = $CI->config->item('backup_path');
if (! is_writable($check_path))
{
$this->error_messages[] = 'Backup directory "' . $check_path . '" is not writable. You will not able to save or download any backups.';
}
-
+
/* Security checks */
$check_path = $CI->config->item('config_path');
if (substr(symbolic_permissions(fileperms($check_path)), -3, 1) == "r")
@@ -39,7 +47,7 @@ class Statuscheck {
{
$this->error_messages[] = 'Security Risk ! The application config directory "' . $check_path . '" is world writeable.';
}
-
+
$check_path = $CI->config->item('config_path') . "accounts/";
if (substr(symbolic_permissions(fileperms($check_path)), -3, 1) == "r")
{
@@ -49,7 +57,17 @@ class Statuscheck {
{
$this->error_messages[] = 'Security Risk ! The application accounts directory "' . $check_path . '" is world writeable.';
}
-
+
+ $check_path = $CI->config->item('config_path') . "users/";
+ if (substr(symbolic_permissions(fileperms($check_path)), -3, 1) == "r")
+ {
+ $this->error_messages[] = 'Security Risk ! The users directory "' . $check_path . '" is world readable.';
+ }
+ if (substr(symbolic_permissions(fileperms($check_path)), -2, 1) == "W")
+ {
+ $this->error_messages[] = 'Security Risk ! The users directory "' . $check_path . '" is world writeable.';
+ }
+
$check_path = $CI->config->item('config_path') . "settings/";
if (substr(symbolic_permissions(fileperms($check_path)), -3, 1) == "r")
{
@@ -59,7 +77,7 @@ class Statuscheck {
{
$this->error_messages[] = 'Security Risk ! The application settings directory "' . $check_path . '" is world writeable.';
}
-
+
$check_path = $CI->config->item('backup_path');
if (substr(symbolic_permissions(fileperms($check_path)), -3, 1) == "r")
{
@@ -72,5 +90,5 @@ class Statuscheck {
}
}
-/* End of file Template.php */
-/* Location: ./system/application/libraries/Template.php */
+/* End of file Statuscheck.php */
+/* Location: ./system/application/libraries/Statuscheck.php */
commit 80a7b68b6d50f6a1be39a0cd8d25e2e08cc94dd9
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 5 20:07:02 2011 +0530
Added User management
- User addition
- User updation
- User deletion
- Added the config/user directory to store user accounts
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/config/users/admin.ini b/config/users/admin.ini
new file mode 100644
index 0000000..325a281
--- /dev/null
+++ b/config/users/admin.ini
@@ -0,0 +1,7 @@
+[user]
+username = "admin"
+password = "admin"
+email = "pshah.mumbai(a)gmail.com"
+role = "administrator"
+status = "1"
+
diff --git a/config/users/guest.ini b/config/users/guest.ini
new file mode 100644
index 0000000..948a505
--- /dev/null
+++ b/config/users/guest.ini
@@ -0,0 +1,7 @@
+[user]
+username = "guest"
+password = "guest"
+email = "pshah.mumbai(a)gmail.com"
+role = "guest"
+status = "1"
+
diff --git a/config/users/index.html b/config/users/index.html
new file mode 100644
index 0000000..c942a79
--- /dev/null
+++ b/config/users/index.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+ <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/system/application/controllers/admin/manage.php b/system/application/controllers/admin/manage.php
index 1c62ba8..bdf0fa6 100644
--- a/system/application/controllers/admin/manage.php
+++ b/system/application/controllers/admin/manage.php
@@ -219,6 +219,8 @@ class Manage extends Controller {
if ( ! get_file_info($ini_file))
{
$this->messages->add('Account settings file labeled ' . $database_label . ' does not exists.', 'error');
+ redirect('admin/manage');
+ return;
} else {
/* Parsing database ini file */
$active_accounts = parse_ini_file($ini_file);
@@ -300,18 +302,6 @@ class Manage extends Controller {
$ini_file = $this->config->item('config_path') . "accounts/" . $database_label . ".ini";
$this->messages->add('Delete ' . $ini_file . ' file manually.', 'error');
$this->messages->add('Only the settings file will be delete. Account database will have to be deleted manually.', 'status');
- /*
- if ( ! get_file_info($ini_file))
- {
- $this->messages->add("Cannot delete account settings. Account setting file labeled " . $database_label . " does not exists.", 'error');
- } else {
- if (unlink($ini_file))
- {
- $this->messages->add("Account settings file delete", 'success');
- } else {
- $this->messages->add("Cannot delete account settings. Please delete " . $ini_file . " file manually.", 'error');
- }
- } */
redirect('admin/manage');
return;
}
diff --git a/system/application/controllers/admin/user.php b/system/application/controllers/admin/user.php
new file mode 100644
index 0000000..f27f89e
--- /dev/null
+++ b/system/application/controllers/admin/user.php
@@ -0,0 +1,299 @@
+<?php
+
+class User extends Controller {
+
+ function User()
+ {
+ parent::Controller();
+
+ /* Check access */
+ if ( ! check_access('administer'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('');
+ return;
+ }
+
+ return;
+ }
+
+ function index()
+ {
+ $this->load->helper('file');
+ $this->template->set('page_title', 'Manage users');
+ $this->template->set('nav_links', array('admin/user/add' => 'Add user'));
+
+ /* Getting list of files in the config - users directory */
+ $users_list = get_filenames($this->config->item('config_path') . 'users');
+ $data['users'] = array();
+ if ($users_list)
+ {
+ foreach ($users_list as $row)
+ {
+ /* Only include file ending with .ini */
+ if (substr($row, -4) == ".ini")
+ {
+ $ini_label = substr($row, 0, -4);
+ $data['users'][$ini_label] = $ini_label;
+ }
+ }
+ }
+
+ $this->template->load('admin_template', 'admin/user/index', $data);
+ return;
+ }
+
+ function add()
+ {
+ $this->template->set('page_title', 'Add user');
+
+ /* Form fields */
+ $data['user_name'] = array(
+ 'name' => 'user_name',
+ 'id' => 'user_name',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '',
+ );
+
+ $data['user_password'] = array(
+ 'name' => 'user_password',
+ 'id' => 'user_password',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '',
+ );
+
+ $data['user_email'] = array(
+ 'name' => 'user_email',
+ 'id' => 'user_email',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '',
+ );
+
+ $data['user_roles'] = array(
+ "administrator" => "administrator",
+ "manager"=> "manager",
+ "accountant" => "accountant",
+ "dataentry" => "dataentry",
+ "guest" => "guest",
+ );
+
+ $data['active_user_role'] = "administrator";
+ $data['user_status'] = TRUE;
+
+ /* Repopulating form */
+ if ($_POST)
+ {
+ $data['user_name']['value'] = $this->input->post('user_name', TRUE);
+ $data['user_password']['value'] = $this->input->post('user_password', TRUE);
+ $data['user_email']['value'] = $this->input->post('user_email', TRUE);
+ $data['active_user_role'] = $this->input->post('user_role', TRUE);
+ $data['user_status'] = $this->input->post('user_status', TRUE);
+ }
+
+ /* Form validations */
+ $this->form_validation->set_rules('user_name', 'Username', 'trim|required|min_length[2]|max_length[30]|alpha_numeric');
+ $this->form_validation->set_rules('user_password', 'Password', 'trim|required');
+ $this->form_validation->set_rules('user_email', 'Email', 'trim|required|valid_email');
+ $this->form_validation->set_rules('user_role', 'Role', 'trim|required');
+ $this->form_validation->set_rules('user_status', 'Active', 'trim');
+
+ /* Validating form */
+ if ($this->form_validation->run() == FALSE)
+ {
+ $this->messages->add(validation_errors(), 'error');
+ $this->template->load('admin_template', 'admin/user/add', $data);
+ return;
+ }
+ else
+ {
+ $data_user_name = $this->input->post('user_name', TRUE);
+ $data_user_password = $this->input->post('user_password', TRUE);
+ $data_user_email = $this->input->post('user_email', TRUE);
+ $data_user_role = $this->input->post('user_role', TRUE);
+ $data_user_status = $this->input->post('user_status', TRUE);
+ if ($data_user_status == 1)
+ $data_user_status = 1;
+ else
+ $data_user_status = 0;
+
+ $ini_file = $this->config->item('config_path') . "users/" . $data_user_name . ".ini";
+
+ /* Check if user ini file exists */
+ if (get_file_info($ini_file))
+ {
+ $this->messages->add('Username already exists.', 'error');
+ $this->template->load('admin_template', 'admin/user/add', $data);
+ return;
+ }
+
+ $user_details = "[user]" . "\r\n" . "username = \"" . $data_user_name . "\"" . "\r\n" . "password = \"" . $data_user_password . "\"" . "\r\n" . "email = \"" . $data_user_email . "\"" . "\r\n" . "role = \"" . $data_user_role . "\"" . "\r\n" . "status = \"" . $data_user_status . "\"" . "\r\n";
+ $user_details_html = "[user]" . "<br />" . "username = \"" . $data_user_name . "\"" . "<br />" . "password = \"" . $data_user_password . "\"" . "<br />" . "email = \"" . $data_user_email . "\"" . "<br />" . "role = \"" . $data_user_role . "\"" . "<br />" . "status = \"" . $data_user_status . "\"" . "<br />";
+
+ /* Writing the connection string to end of file - writing in 'a' append mode */
+ if ( ! write_file($ini_file, $user_details))
+ {
+ $this->messages->add('Failed to add user. Check if "' . $ini_file . '" file is writable.', 'error');
+ $this->messages->add('You can manually create a text file "' . $ini_file . '" with the following content :<br /><br />' . $user_details_html, 'error');
+ $this->template->load('admin_template', 'admin/user/add', $data);
+ return;
+ } else {
+ $this->messages->add('Added user.', 'success');
+ redirect('admin/user');
+ return;
+ }
+ }
+ return;
+ }
+
+ function edit($user_name)
+ {
+ $this->template->set('page_title', 'Edit user');
+
+ $ini_file = $this->config->item('config_path') . "users/" . $user_name . ".ini";
+
+ /* Form fields */
+ $data['user_password'] = array(
+ 'name' => 'user_password',
+ 'id' => 'user_password',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '',
+ );
+
+ $data['user_email'] = array(
+ 'name' => 'user_email',
+ 'id' => 'user_email',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '',
+ );
+
+ $data['user_roles'] = array(
+ "administrator" => "administrator",
+ "manager"=> "manager",
+ "accountant" => "accountant",
+ "dataentry" => "dataentry",
+ "guest" => "guest",
+ );
+
+ $data['user_name'] = $user_name;
+ $data['active_user_role'] = "";
+ $data['user_status'] = TRUE;
+
+ /* Repopulating form */
+ if ($_POST)
+ {
+ $data['user_password']['value'] = $this->input->post('user_password', TRUE);
+ $data['user_email']['value'] = $this->input->post('user_email', TRUE);
+ $data['active_user_role'] = $this->input->post('user_role', TRUE);
+ $data['user_status'] = $this->input->post('user_status', TRUE);
+ } else {
+ /* Check if user ini file exists */
+ if ( ! get_file_info($ini_file))
+ {
+ $this->messages->add('User file "' . $ini_file . '" does not exists.', 'error');
+ redirect('admin/user');
+ return;
+ } else {
+ /* Parsing user ini file */
+ $active_users = parse_ini_file($ini_file);
+ if ( ! $active_users)
+ {
+ $this->messages->add('Invalid user file', 'error');
+ } else {
+ /* Check if all needed variables are set in ini file */
+ if (isset($active_users['username']))
+ $data['user_name'] = $user_name;
+ else
+ $this->messages->add('Username missing from user file', 'error');
+
+ if (isset($active_users['password']))
+ $data['user_password']['value'] = $active_users['password'];
+ else
+ $this->messages->add('Password missing from user file', 'error');
+
+ if (isset($active_users['email']))
+ $data['user_email']['value'] = $active_users['email'];
+ else
+ $this->messages->add('Email missing from user file', 'error');
+
+ if (isset($active_users['role']))
+ $data['active_user_role'] = $active_users['role'];
+ else
+ $this->messages->add('Role missing from user file', 'error');
+
+ if (isset($active_users['status']))
+ $data['user_status'] = $active_users['status'];
+ else
+ $this->messages->add('Status missing from user file', 'error');
+ }
+ }
+ }
+
+ /* Form validations */
+ $this->form_validation->set_rules('user_password', 'Password', 'trim|required');
+ $this->form_validation->set_rules('user_email', 'Email', 'trim|required|valid_email');
+ $this->form_validation->set_rules('user_role', 'Role', 'trim|required');
+ $this->form_validation->set_rules('user_status', 'Active', 'trim');
+
+ /* Validating form */
+ if ($this->form_validation->run() == FALSE)
+ {
+ $this->messages->add(validation_errors(), 'error');
+ $this->template->load('admin_template', 'admin/user/edit', $data);
+ return;
+ }
+ else
+ {
+ $data_user_password = $this->input->post('user_password', TRUE);
+ $data_user_email = $this->input->post('user_email', TRUE);
+ $data_user_role = $this->input->post('user_role', TRUE);
+ $data_user_status = $this->input->post('user_status', TRUE);
+ if ($data_user_status == 1)
+ $data_user_status = 1;
+ else
+ $data_user_status = 0;
+
+ $ini_file = $this->config->item('config_path') . "users/" . $user_name . ".ini";
+
+ $user_details = "[user]" . "\r\n" . "username = \"" . $user_name . "\"" . "\r\n" . "password = \"" . $data_user_password . "\"" . "\r\n" . "email = \"" . $data_user_email . "\"" . "\r\n" . "role = \"" . $data_user_role . "\"" . "\r\n" . "status = \"" . $data_user_status . "\"" . "\r\n";
+ $user_details_html = "[user]" . "<br />" . "username = \"" . $user_name . "\"" . "<br />" . "password = \"" . $data_user_password . "\"" . "<br />" . "email = \"" . $data_user_email . "\"" . "<br />" . "role = \"" . $data_user_role . "\"" . "<br />" . "status = \"" . $data_user_status . "\"" . "<br />";
+
+ /* Writing the connection string to end of file - writing in 'a' append mode */
+ if ( ! write_file($ini_file, $user_details))
+ {
+ $this->messages->add('Failed to edit user. Check if "' . $ini_file . '" file is writable.', 'error');
+ $this->messages->add('You can manually edit the text file "' . $ini_file . '" with the following content :<br /><br />' . $user_details_html, 'error');
+ $this->template->load('admin_template', 'admin/user/edit', $data);
+ return;
+ } else {
+ $this->messages->add('Updated user.', 'success');
+ redirect('admin/user');
+ return;
+ }
+ }
+ return;
+ }
+
+ function delete($user_name)
+ {
+ $this->template->set('page_title', 'Delete user');
+
+ if ($this->session->userdata('user_name') == $user_name)
+ {
+ $this->messages->add('Cannot delete currently logged in user', 'error');
+ redirect('admin/user');
+ return;
+ }
+ $ini_file = $this->config->item('config_path') . "users/" . $user_name . ".ini";
+ $this->messages->add('Delete ' . $ini_file . ' file manually.', 'error');
+ redirect('admin/user');
+ return;
+ }
+}
+
+/* End of file user.php */
+/* Location: ./system/application/controllers/admin/user.php */
diff --git a/system/application/views/admin/user/add.php b/system/application/views/admin/user/add.php
new file mode 100644
index 0000000..9fe806a
--- /dev/null
+++ b/system/application/views/admin/user/add.php
@@ -0,0 +1,39 @@
+<?php
+ echo form_open('admin/user/add');
+
+ echo "<p>";
+ echo form_label('Username', 'user_name');
+ echo "<br />";
+ echo form_input($user_name);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Password', 'user_password');
+ echo "<br />";
+ echo form_password($user_password);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Email', 'user_email');
+ echo "<br />";
+ echo form_input($user_email);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Role', 'user_role');
+ echo "<br />";
+ echo form_dropdown('user_role', $user_roles, $active_user_role);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_checkbox('user_status', 1, $user_status) . "Active";
+ echo "</p>";
+
+ echo "<p>";
+ echo form_submit('submit', 'Add');
+ echo " ";
+ echo anchor('admin/user', 'Back', array('title' => 'Back to user list'));
+ echo "</p>";
+
+ echo form_close();
+
diff --git a/system/application/views/admin/user/edit.php b/system/application/views/admin/user/edit.php
new file mode 100644
index 0000000..be623aa
--- /dev/null
+++ b/system/application/views/admin/user/edit.php
@@ -0,0 +1,39 @@
+<?php
+ echo form_open('admin/user/edit/' . $user_name);
+
+ echo "<p>";
+ echo 'Username';
+ echo "<br />";
+ echo $user_name;
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Password', 'user_password');
+ echo "<br />";
+ echo form_password($user_password);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Email', 'user_email');
+ echo "<br />";
+ echo form_input($user_email);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Role', 'user_role');
+ echo "<br />";
+ echo form_dropdown('user_role', $user_roles, $active_user_role);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_checkbox('user_status', 1, $user_status) . "Active";
+ echo "</p>";
+
+ echo "<p>";
+ echo form_submit('submit', 'Update');
+ echo " ";
+ echo anchor('admin/user', 'Back', array('title' => 'Back to user list'));
+ echo "</p>";
+
+ echo form_close();
+
diff --git a/system/application/views/admin/user/index.php b/system/application/views/admin/user/index.php
new file mode 100644
index 0000000..d748c97
--- /dev/null
+++ b/system/application/views/admin/user/index.php
@@ -0,0 +1,76 @@
+<?php
+echo "<p>";
+echo "<b>You are logged in as : </b>";
+echo $this->session->userdata('user_name');
+echo "</p>";
+
+echo "<table border=0 cellpadding=5 class=\"simple-table manage-account-table\">";
+echo "<thead><tr><th>Username</th><th>Email</th><th>Role</th><th>Status</th><th></th></tr></thead>";
+echo "<tbody>";
+$odd_even = "odd";
+foreach ($users as $row)
+{
+ $ini_file = $this->config->item('config_path') . "users/" . $row . ".ini";
+
+ /* Check if database ini file exists */
+ if (get_file_info($ini_file))
+ {
+ /* Parsing database ini file */
+ $active_users = parse_ini_file($ini_file);
+ if ($active_users)
+ {
+ $username = isset($active_users['username']) ? $active_users['username'] : "-";
+ $email = isset($active_users['email']) ? $active_users['email'] : "-";
+ $role = isset($active_users['role']) ? $active_users['role'] : "-";
+ $status = isset($active_users['status']) ? $active_users['status'] : "-";
+ }
+ }
+
+ echo "<tr class=\"tr-" . $odd_even;
+ if ($this->session->userdata('user_name') == $row)
+ echo " tr-draft";
+ echo "\">";
+ echo "<td>" . $username . "</td>";
+ echo "<td>" . $email . "</td>";
+
+ echo "<td>";
+ switch ($role)
+ {
+ case "administrator": echo "administrator"; break;
+ case "manager": echo "manager"; break;
+ case "accountant": echo "accountant"; break;
+ case "dataentry": echo "dataentry"; break;
+ case "guest": echo "guest"; break;
+ default: echo "(unknown)"; break;
+ }
+ echo "</td>";
+
+ echo "<td>";
+ switch ($status)
+ {
+ case 0: echo "Disabled"; break;
+ case 1: echo "Active"; break;
+ default: echo "(unknown)"; break;
+ }
+ echo "</td>";
+
+ if ($this->session->userdata('user_name') == $row)
+ {
+ echo "<td>";
+ echo anchor("admin/user/edit/" . $row, "Edit", array('title' => 'Edit User', 'class' => 'red-link'));
+ echo "</td>";
+ } else {
+ echo "<td>";
+ echo anchor("admin/user/edit/" . $row, "Edit", array('title' => 'Edit User', 'class' => 'red-link'));
+ echo " " . anchor('admin/user/delete/' . $row, img(array('src' => asset_url() . "images/icons/delete.png", 'border' => '0', 'alt' => 'Delete User', 'class' => "confirmClick", 'title' => "Delete User")), array('title' => 'Delete User')) . " ";
+ echo "</td>";
+ }
+
+ echo "</tr>";
+ $odd_even = ($odd_even == "odd") ? "even" : "odd";
+}
+echo "</tbody>";
+echo "</table>";
+echo "<br />";
+echo anchor('admin', 'Back', array('title' => 'Back to admin'));
+
diff --git a/system/application/views/admin/welcome.php b/system/application/views/admin/welcome.php
index 77253a5..b233482 100644
--- a/system/application/views/admin/welcome.php
+++ b/system/application/views/admin/welcome.php
@@ -20,6 +20,14 @@
Manage existing accounts
</div>
</div>
+ <div class="settings-container">
+ <div class="settings-title">
+ <?php echo anchor('admin/user', 'Manage Users', array('title' => 'Manage users')); ?>
+ </div>
+ <div class="settings-desc">
+ Manage users and permissions
+ </div>
+ </div>
</div>
<div id="right-col">
<div class="settings-container">
diff --git a/system/application/views/ledger/edit.php b/system/application/views/ledger/edit.php
index 2400ff4..2a38808 100644
--- a/system/application/views/ledger/edit.php
+++ b/system/application/views/ledger/edit.php
@@ -16,16 +16,19 @@
echo "<p>";
echo form_label('Opening balance', 'op_balance');
echo "<br />";
+ echo "<span id=\"tooltip-target-1\">";
echo form_dropdown_dc('op_balance_dc', $op_balance_dc);
echo " ";
echo form_input($op_balance);
+ echo "</span>";
+ echo "<span id=\"tooltip-content-1\"> Assets / Expenses => Dr. Balance<br />Liabilities / Incomes => Cr. Balance</span>";
echo "</p>";
echo "<p>";
- echo "<span id=\"tooltip-target-1\">";
+ echo "<span id=\"tooltip-target-2\">";
echo form_checkbox('ledger_type_cashbank', 1, $ledger_type_cashbank) . " Cash / Bank Account";
echo "</span>";
- echo "<span id=\"tooltip-content-1\">Select if Ledger A/C is a Bank A/C or a Cash A/C.</span>";
+ echo "<span id=\"tooltip-content-2\">Select if Ledger A/C is a Bank A/C or a Cash A/C.</span>";
echo "</p>";
echo "<p>";
commit fcafd130dad1bca92deaef0e2e69b7a5fa0e8dc5
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 5 13:31:51 2011 +0530
Added Ledger Balance type tooltip hint
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/admin/welcome.php b/system/application/controllers/admin/welcome.php
index eda73ab..7fca9df 100644
--- a/system/application/controllers/admin/welcome.php
+++ b/system/application/controllers/admin/welcome.php
@@ -145,7 +145,7 @@ class Welcome extends Controller {
}
if ($data['current_account'] == "")
- $data['current_account'] = "No account is currently active. You can " . anchor('admin/create', 'create', array('title' => 'Create a new account', 'style' => 'color:#000000')) . " a new account or " . anchor('admin/active', 'activate', array('title' => 'Activate a existing account', 'style' => 'color:#000000')) . " an existing account";
+ $data['current_account'] = "No account is currently active. You can " . anchor('admin/create', 'create', array('title' => 'Create a new account', 'style' => 'color:#000000')) . " a new account or " . anchor('user/account', 'activate', array('title' => 'Activate a existing account', 'style' => 'color:#000000')) . " an existing account";
/* check status report */
$this->load->library('statuscheck');
diff --git a/system/application/views/ledger/add.php b/system/application/views/ledger/add.php
index 249611b..106a9ad 100644
--- a/system/application/views/ledger/add.php
+++ b/system/application/views/ledger/add.php
@@ -16,16 +16,19 @@
echo "<p>";
echo form_label('Opening balance', 'op_balance');
echo "<br />";
+ echo "<span id=\"tooltip-target-1\">";
echo form_dropdown_dc('op_balance_dc', $op_balance_dc);
echo " ";
echo form_input($op_balance);
+ echo "</span>";
+ echo "<span id=\"tooltip-content-1\"> Assets / Expenses => Dr. Balance<br />Liabilities / Incomes => Cr. Balance</span>";
echo "</p>";
echo "<p>";
- echo "<span id=\"tooltip-target-1\">";
+ echo "<span id=\"tooltip-target-2\">";
echo form_checkbox('ledger_type_cashbank', 1, $ledger_type_cashbank) . " Cash / Bank Account";
echo "</span>";
- echo "<span id=\"tooltip-content-1\">Select if Ledger A/C is a Bank A/C or a Cash A/C.</span>";
+ echo "<span id=\"tooltip-content-2\">Select if Ledger A/C is a Bank A/C or a Cash A/C.</span>";
echo "</p>";
echo "<p>";