system/application
by pshah
system/application/views/admin_template.php | 2 +-
system/application/views/template.php | 2 +-
system/application/views/user_template.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
New commits:
commit b37f69c8c5923ebbdfde56acfbe198d5747514e7
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sat Jan 22 19:48:30 2011 +0530
Updated footer website link to webzash.org
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/views/admin_template.php b/system/application/views/admin_template.php
index d6c86d9..2cc9ce9 100644
--- a/system/application/views/admin_template.php
+++ b/system/application/views/admin_template.php
@@ -122,7 +122,7 @@ $(document).ready(function(){
</div>
<div id="footer">
<?php if (isset($page_footer)) echo $page_footer ?>
- <a href="http://webzash.wordpress.com" target="_blank">Webzash<a/> is licensed under <a href="http://www.gnu.org/licenses/agpl-3.0.txt" target="_blank">GNU Affero General Public License, version 3</a> as published by the Free Software Foundation.
+ <a href="http://webzash.org" target="_blank">Webzash<a/> is licensed under <a href="http://www.gnu.org/licenses/agpl-3.0.txt" target="_blank">GNU Affero General Public License, version 3</a> as published by the Free Software Foundation.
</div>
</body>
</html>
diff --git a/system/application/views/template.php b/system/application/views/template.php
index 6d2579f..31a701c 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -203,7 +203,7 @@ $(document).ready(function() {
</div>
<div id="footer">
<?php if (isset($page_footer)) echo $page_footer ?>
- <a href="http://webzash.wordpress.com" target="_blank">Webzash<a/> is licensed under <a href="http://www.gnu.org/licenses/agpl-3.0.txt" target="_blank">GNU Affero General Public License, version 3</a> as published by the Free Software Foundation.
+ <a href="http://webzash.org" target="_blank">Webzash<a/> is licensed under <a href="http://www.gnu.org/licenses/agpl-3.0.txt" target="_blank">GNU Affero General Public License, version 3</a> as published by the Free Software Foundation.
</div>
</body>
</html>
diff --git a/system/application/views/user_template.php b/system/application/views/user_template.php
index c3b5dc4..e1e0a95 100644
--- a/system/application/views/user_template.php
+++ b/system/application/views/user_template.php
@@ -119,7 +119,7 @@
</div>
<div id="footer">
<?php if (isset($page_footer)) echo $page_footer ?>
- <a href="http://webzash.wordpress.com" target="_blank">Webzash<a/> is licensed under <a href="http://www.gnu.org/licenses/agpl-3.0.txt" target="_blank">GNU Affero General Public License, version 3</a> as published by the Free Software Foundation.
+ <a href="http://webzash.org" target="_blank">Webzash<a/> is licensed under <a href="http://www.gnu.org/licenses/agpl-3.0.txt" target="_blank">GNU Affero General Public License, version 3</a> as published by the Free Software Foundation.
</div>
</body>
</html>
13 years, 3 months
system/application
by pshah
system/application/config/config.php | 2 +-
system/application/views/template.php | 2 +-
system/application/views/user_template.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
New commits:
commit 4cdcdd52fd49bf709f6f7a8d2669cb91dd7409a1
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sat Jan 22 19:45:01 2011 +0530
Removed beta status and updated version number to v1.0
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 265cbf0..cb490bb 100644
--- a/system/application/config/config.php
+++ b/system/application/config/config.php
@@ -376,7 +376,7 @@ $config['backup_path'] = 'backups/';
| Sets the current application version
|
*/
-$config['application_version'] = '1.0-beta3';
+$config['application_version'] = '1.0';
/* End of file config.php */
/* Location: ./system/application/config/config.php */
diff --git a/system/application/views/template.php b/system/application/views/template.php
index aff4f43..6d2579f 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -67,7 +67,7 @@ $(document).ready(function() {
<div id="container">
<div id="header">
<div id="logo">
- <?php echo anchor('', 'Webzash', array('class' => 'anchor-link-b')); ?> <span id="beta-area">(beta)</span>
+ <?php echo anchor('', 'Webzash', array('class' => 'anchor-link-b')); ?>
</div>
<?php
if ($this->session->userdata('user_name')) {
diff --git a/system/application/views/user_template.php b/system/application/views/user_template.php
index 3d74d19..c3b5dc4 100644
--- a/system/application/views/user_template.php
+++ b/system/application/views/user_template.php
@@ -25,7 +25,7 @@
<div id="container">
<div id="header">
<div id="logo">
- <?php echo anchor('', 'Webzash', array('class' => 'anchor-link-b')); ?> <span id="beta-area">(beta)</span>
+ <?php echo anchor('', 'Webzash', array('class' => 'anchor-link-b')); ?>
</div>
<?php
if ($this->session->userdata('user_name')) {
13 years, 3 months
67 commits - CHANGELOG.txt config/settings config/users db-update.txt system/application todo.txt TODO.txt
by pshah
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>";
13 years, 3 months
17 commits - system/application
by pshah
system/application/config/autoload.php | 2
system/application/controllers/admin/active.php | 128 --------------
system/application/controllers/admin/create.php | 9 +
system/application/controllers/admin/manage.php | 9 +
system/application/controllers/admin/setting.php | 9 +
system/application/controllers/admin/status.php | 9 +
system/application/controllers/admin/welcome.php | 16 +
system/application/controllers/group.php | 24 ++
system/application/controllers/ledger.php | 24 ++
system/application/controllers/log.php | 34 +++
system/application/controllers/report.php | 11 +
system/application/controllers/setting.php | 70 ++-----
system/application/controllers/tag.php | 26 ++
system/application/controllers/user.php | 203 +++++++++++++++++++++++
system/application/controllers/voucher.php | 48 +++++
system/application/helpers/access_helper.php | 121 +++++++++++++
system/application/libraries/Startup.php | 22 +-
system/application/views/admin/active.php | 22 --
system/application/views/admin/manage/index.php | 6
system/application/views/admin/welcome.php | 8
system/application/views/admin_template.php | 5
system/application/views/setting/change.php | 34 ---
system/application/views/template.php | 24 +-
system/application/views/user/account.php | 23 ++
system/application/views/user/login.php | 25 ++
system/application/views/user_template.php | 121 +++++++++++++
system/application/views/welcome.php | 50 ++---
27 files changed, 792 insertions(+), 291 deletions(-)
New commits:
commit 1bbd1c32b0b7b0fa5a2e3f68fa2b0ee22b7293ff
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 4 22:06:19 2011 +0530
Changed admin top link from Accounts to 'Back to Accounts'
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/views/admin_template.php b/system/application/views/admin_template.php
index 44e36a8..67e360c 100644
--- a/system/application/views/admin_template.php
+++ b/system/application/views/admin_template.php
@@ -36,7 +36,7 @@ $(document).ready(function(){
<?php echo anchor('admin', 'Webzash', array('class' => 'anchor-link-b')); ?> <span id="admin-area">Admin area</span>
</div>
<div id="admin">
- <?php echo anchor('', 'Accounts', array('title' => "Back to accounts", 'class' => 'anchor-link-b')); ?> |
+ <?php echo anchor('', 'Back to Accounts', array('title' => "Back to accounts", 'class' => 'anchor-link-b')); ?> |
<?php echo anchor('user/logout', 'Logout', array('title' => "Logout", 'class' => 'anchor-link-b')); ?>
</div>
<div id="info">
commit 4caa8967b4cf2d3c97546e578f2c8b4595db2529
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 4 22:04:42 2011 +0530
Removed change accounts from admin section
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/admin/active.php b/system/application/controllers/admin/active.php
deleted file mode 100644
index 9bf812c..0000000
--- a/system/application/controllers/admin/active.php
+++ /dev/null
@@ -1,137 +0,0 @@
-<?php
-
-class Active extends Controller {
-
- function Active()
- {
- parent::Controller();
-
- /* Check access */
- if ( ! check_access('administer'))
- {
- $this->messages->add('Permission denied', 'error');
- redirect('');
- return;
- }
-
- return;
- }
-
- function index($url_label_name = NULL)
- {
- $this->template->set('page_title', 'Change Active Account');
-
- /* If label specified in URL */
- if ($url_label_name)
- {
- $url_label_name = $this->input->xss_clean($url_label_name);
- $data['account'] = $url_label_name;
- } else {
- $data['account'] = "";
- }
-
- /* 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;
- }
- }
- }
-
- /* Form validations */
- if ( ! $url_label_name)
- {
- $this->form_validation->set_rules('account', 'Account', 'trim|required');
- }
-
- /* Repopulating form */
- if ($_POST)
- {
- /* Unsetting all database configutaion */
- $this->session->unset_userdata('active_account');
- $data['account'] = $this->input->post('account', TRUE);
- }
-
- /* Validating form : only if label name is not set from URL */
- if ($this->form_validation->run() == FALSE && ( ! $url_label_name))
- {
- $this->messages->add(validation_errors(), 'error');
- $this->template->load('admin_template', 'admin/active', $data);
- return;
- } else {
- if ($url_label_name)
- {
- $db_label = $this->input->xss_clean($url_label_name);
- } else {
- $db_label = $this->input->post('account', TRUE);
- }
- $ini_file = $this->config->item('config_path') . "accounts/" . $db_label . ".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('admin_template', 'admin/active', $data);
- return;
- }
-
- /* Parsing database ini file */
- $active_accounts = parse_ini_file($ini_file);
- if ( ! $active_accounts)
- {
- $this->messages->add('Invalid account settings file.', 'error');
- $this->template->load('admin_template', 'admin/active', $data);
- return;
- }
-
- /* Check if all needed variables are set in ini file */
- if ( ! isset($active_accounts['db_hostname']))
- {
- $this->messages->add('Hostname missing from account settings file.', 'error');
- $this->template->load('admin_template', 'admin/active', $data);
- return;
- }
- if ( ! isset($active_accounts['db_port']))
- {
- $this->messages->add('Port missing from account settings file. Default MySQL port is 3306.', 'error');
- $this->template->load('admin_template', 'admin/active', $data);
- return;
- }
- if ( ! isset($active_accounts['db_name']))
- {
- $this->messages->add('Database name missing from account settings file.', 'error');
- $this->template->load('admin_template', 'admin/active', $data);
- return;
- }
- if ( ! isset($active_accounts['db_username']))
- {
- $this->messages->add('Database username missing from account settings file.', 'error');
- $this->template->load('admin_template', 'admin/active', $data);
- return;
- }
- if ( ! isset($active_accounts['db_password']))
- {
- $this->messages->add('Database password missing from account settings file.', 'error');
- $this->template->load('admin_template', 'admin/active', $data);
- return;
- }
-
- /* Setting new account database details in session */
- $this->session->set_userdata('active_account', $db_label);
- $this->messages->add('Active account settings changed.', 'success');
- redirect('admin');
- }
- return;
- }
-}
-
-/* End of file active.php */
-/* Location: ./system/application/controllers/admin/active.php */
diff --git a/system/application/controllers/admin/welcome.php b/system/application/controllers/admin/welcome.php
index b6a767e..eda73ab 100644
--- a/system/application/controllers/admin/welcome.php
+++ b/system/application/controllers/admin/welcome.php
@@ -94,7 +94,6 @@ class Welcome extends Controller {
}
} else {
$is_label_set = FALSE;
- $this->messages->add('Select a valid account.', 'error');
}
if ($is_label_set)
diff --git a/system/application/controllers/user.php b/system/application/controllers/user.php
index 3164b40..67cf567 100644
--- a/system/application/controllers/user.php
+++ b/system/application/controllers/user.php
@@ -92,7 +92,7 @@ class User extends Controller {
/* Show manage accounts links if user has permission */
if (check_access('administer'))
{
- $this->template->set('nav_links', array('admin/manage' => 'Manage accounts'));
+ $this->template->set('nav_links', array('admin/create' => 'Create account', 'admin/manage' => 'Manage accounts'));
}
/* Check access */
diff --git a/system/application/views/admin/active.php b/system/application/views/admin/active.php
deleted file mode 100644
index 0b84d55..0000000
--- a/system/application/views/admin/active.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
- echo form_open('admin/active');
-
- echo "<p>";
- echo "<b>Currently active account : </b>";
- echo $this->session->userdata('active_account');
- echo "</p>";
-
- echo "<p>";
- echo "Currently available accounts";
- echo "<br />";
- echo form_dropdown('account', $accounts, $account);
- echo "</p>";
-
- echo "<p>";
- echo form_submit('submit', 'Change');
- echo " ";
- echo anchor('admin', 'Back', array('title' => 'Back to admin'));
- echo "</p>";
-
- echo form_close();
-
diff --git a/system/application/views/admin/welcome.php b/system/application/views/admin/welcome.php
index 625ac24..77253a5 100644
--- a/system/application/views/admin/welcome.php
+++ b/system/application/views/admin/welcome.php
@@ -14,14 +14,6 @@
</div>
<div class="settings-container">
<div class="settings-title">
- <?php echo anchor('admin/active', 'Change Active Account', array('title' => 'Change active account')); ?>
- </div>
- <div class="settings-desc">
- Change existing active account
- </div>
- </div>
- <div class="settings-container">
- <div class="settings-title">
<?php echo anchor('admin/manage', 'Manage Accounts', array('title' => 'Manage existing accounts')); ?>
</div>
<div class="settings-desc">
diff --git a/system/application/views/admin_template.php b/system/application/views/admin_template.php
index dab5ef0..44e36a8 100644
--- a/system/application/views/admin_template.php
+++ b/system/application/views/admin_template.php
@@ -33,7 +33,7 @@ $(document).ready(function(){
<div id="container">
<div id="header">
<div id="logo">
- Webzash <span id="admin-area">Admin area</span>
+ <?php echo anchor('admin', 'Webzash', array('class' => 'anchor-link-b')); ?> <span id="admin-area">Admin area</span>
</div>
<div id="admin">
<?php echo anchor('', 'Accounts', array('title' => "Back to accounts", 'class' => 'anchor-link-b')); ?> |
diff --git a/system/application/views/template.php b/system/application/views/template.php
index adcb620..554ea63 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -65,7 +65,7 @@ $(document).ready(function() {
<div id="container">
<div id="header">
<div id="logo">
- Webzash <span id="beta-area">(beta)</span>
+ <?php echo anchor('', 'Webzash', array('class' => 'anchor-link-b')); ?> <span id="beta-area">(beta)</span>
</div>
<?php
if ($this->session->userdata('user_name')) {
diff --git a/system/application/views/user_template.php b/system/application/views/user_template.php
index 2b676f4..31dda8e 100644
--- a/system/application/views/user_template.php
+++ b/system/application/views/user_template.php
@@ -25,7 +25,7 @@
<div id="container">
<div id="header">
<div id="logo">
- Webzash <span id="beta-area">(beta)</span>
+ <?php echo anchor('', 'Webzash', array('class' => 'anchor-link-b')); ?> <span id="beta-area">(beta)</span>
</div>
<?php
if ($this->session->userdata('user_name')) {
commit cf91d87d0da860fdc23ecc705398787e248c88dc
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 4 21:47:14 2011 +0530
Show manage accounts link
- If user has 'administer' permissions
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 69f0d9c..3164b40 100644
--- a/system/application/controllers/user.php
+++ b/system/application/controllers/user.php
@@ -89,6 +89,12 @@ class User extends Controller {
{
$this->template->set('page_title', 'Change Account');
+ /* Show manage accounts links if user has permission */
+ if (check_access('administer'))
+ {
+ $this->template->set('nav_links', array('admin/manage' => 'Manage accounts'));
+ }
+
/* Check access */
if ( ! ($this->session->userdata('user_name')))
{
commit f5903079e622b9fe0c59ad4ccfd5b6f0390bd8a2
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 4 21:35:53 2011 +0530
Use the new account change form
- Removed the jQuery popup to change account
- All change account go to the new account change form
- Show the page top Logout link only if user is logged in
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 c26a81f..0dc5788 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -914,50 +914,6 @@ class Setting extends Controller {
}
return;
}
-
- /* Change Active Account */
- function change()
- {
- /* Form validations */
- $this->form_validation->set_rules('select_account', 'Select Account', 'trim|required');
-
- /* Validating form : only if label name is not set from URL */
- if ($this->form_validation->run() == FALSE)
- {
- $this->messages->add(validation_errors(), 'error');
- redirect('');
- return;
- } else {
- /* Unsetting all database configutaion */
- $this->session->unset_userdata('active_account');
-
- $data_select_account = $this->input->post('select_account', TRUE);
- $ini_file = $this->config->item('config_path') . "accounts/" . $data_select_account . ".ini";
-
- /* Check if database ini file exists */
- if ( ! get_file_info($ini_file))
- {
- $this->messages->add('Account setting file is missing.', 'error');
- redirect('');
- return;
- }
-
- /* Parsing database ini file */
- $active_accounts = parse_ini_file($ini_file);
- if ( ! $active_accounts)
- {
- $this->messages->add('Invalid account setting file.', 'error');
- redirect('');
- return;
- }
-
- /* Setting new account database details in session */
- $this->session->set_userdata('active_account', $data_select_account);
- $this->messages->add('Active account changed.', 'success');
- redirect('');
- }
- return;
- }
}
/* End of file setting.php */
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index 2cf6b2a..a751f73 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -102,8 +102,9 @@ class Startup
$db_config['dbcollat'] = "utf8_general_ci";
$CI->load->database($db_config, FALSE, TRUE);
} else {
- $CI->messages->add('Select a valid account.', 'error');
- redirect('admin');
+ $CI->messages->add('Select a account.', 'error');
+ redirect('user/account');
+ return;
}
/* Checking for valid database connection */
diff --git a/system/application/views/setting/change.php b/system/application/views/setting/change.php
deleted file mode 100644
index 63e9eda..0000000
--- a/system/application/views/setting/change.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
- /* Getting list of files in the config - accounts directory */
- $accounts_list = get_filenames($this->config->item('config_path') . 'accounts');
- $select_account_options = 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);
- $select_account_options[$ini_label] = $ini_label;
- }
- }
- }
-
- echo form_open('setting/change');
-
- echo "<p>";
- echo form_label('Select account', 'select_account');
- echo "<br />";
- echo form_dropdown('select_account', $select_account_options);
- echo "</p>";
-
- echo "<p>";
- echo form_submit('submit', 'Change');
- echo "</p>";
- echo "<p>";
- echo anchor('admin/manage', 'Manage Accounts', 'Manage Accounts');
- echo "</p>";
-
- echo form_close();
-
diff --git a/system/application/views/template.php b/system/application/views/template.php
index 460acb1..adcb620 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -67,22 +67,23 @@ $(document).ready(function() {
<div id="logo">
Webzash <span id="beta-area">(beta)</span>
</div>
- <div id="admin">
- <?php
+ <?php
+ if ($this->session->userdata('user_name')) {
+ echo "<div id=\"admin\">";
/* Check if allowed administer rights */
- if (check_access('administer'))
- {
+ if (check_access('administer')) {
echo anchor('admin', 'Administer', array('title' => "Administer", 'class' => 'anchor-link-b'));
echo " | ";
}
- ?>
- <?php echo anchor('user/logout', 'Logout', array('title' => "Logout", 'class' => 'anchor-link-b')); ?>
- </div>
+ echo anchor('user/logout', 'Logout', array('title' => "Logout", 'class' => 'anchor-link-b'));
+ echo "</div>";
+ }
+ ?>
<div id="info">
<?php
echo $this->config->item('account_name');
echo " (";
- echo "<a href=\"#TB_inline?height=300&width=300&inlineId=changeActiveAccount\" class=\"thickbox anchor-link-a\" title=\"Change Active Account\">change</a>";
+ echo anchor('user/account', 'change', array('title' => 'Change active account', 'class' => 'anchor-link-a'));
echo ")<br />";
echo "FY : ";
echo date_mysql_to_php_display($this->config->item('account_fy_start'));
@@ -198,10 +199,5 @@ $(document).ready(function() {
<?php if (isset($page_footer)) echo $page_footer ?>
<a href="http://webzash.wordpress.com" target="_blank">Webzash<a/> is licensed under <a href="http://www.gnu.org/licenses/agpl-3.0.txt" target="_blank">GNU Affero General Public License, version 3</a> as published by the Free Software Foundation.
</div>
-<div id="account_change" class="hidden-element">
- <div id="changeActiveAccount">
- <?php $this->load->view("setting/change"); ?>
- </div>
-</div>
</body>
</html>
diff --git a/system/application/views/user_template.php b/system/application/views/user_template.php
index 9fd47a4..2b676f4 100644
--- a/system/application/views/user_template.php
+++ b/system/application/views/user_template.php
@@ -27,6 +27,18 @@
<div id="logo">
Webzash <span id="beta-area">(beta)</span>
</div>
+ <?php
+ if ($this->session->userdata('user_name')) {
+ echo "<div id=\"admin\">";
+ /* Check if allowed administer rights */
+ if (check_access('administer')) {
+ echo anchor('admin', 'Administer', array('title' => "Administer", 'class' => 'anchor-link-b'));
+ echo " | ";
+ }
+ echo anchor('user/logout', 'Logout', array('title' => "Logout", 'class' => 'anchor-link-b'));
+ echo "</div>";
+ }
+ ?>
</div>
<div id="menu">
<ul class="sf-menu">
@@ -105,10 +117,5 @@
<?php if (isset($page_footer)) echo $page_footer ?>
<a href="http://webzash.wordpress.com" target="_blank">Webzash<a/> is licensed under <a href="http://www.gnu.org/licenses/agpl-3.0.txt" target="_blank">GNU Affero General Public License, version 3</a> as published by the Free Software Foundation.
</div>
-<div id="account_change" class="hidden-element">
- <div id="changeActiveAccount">
- <?php $this->load->view("setting/change"); ?>
- </div>
-</div>
</body>
</html>
commit 289dab84209174b66a50b576da7aa98029b86ee2
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 4 21:14:52 2011 +0530
Renamed db_active_label session variable to active_account
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/admin/active.php b/system/application/controllers/admin/active.php
index 7415326..9bf812c 100644
--- a/system/application/controllers/admin/active.php
+++ b/system/application/controllers/admin/active.php
@@ -56,7 +56,7 @@ class Active extends Controller {
if ($_POST)
{
/* Unsetting all database configutaion */
- $this->session->unset_userdata('db_active_label');
+ $this->session->unset_userdata('active_account');
$data['account'] = $this->input->post('account', TRUE);
}
@@ -125,7 +125,7 @@ class Active extends Controller {
}
/* Setting new account database details in session */
- $this->session->set_userdata('db_active_label', $db_label);
+ $this->session->set_userdata('active_account', $db_label);
$this->messages->add('Active account settings changed.', 'success');
redirect('admin');
}
diff --git a/system/application/controllers/admin/welcome.php b/system/application/controllers/admin/welcome.php
index 6a6263e..b6a767e 100644
--- a/system/application/controllers/admin/welcome.php
+++ b/system/application/controllers/admin/welcome.php
@@ -25,13 +25,13 @@ class Welcome extends Controller {
/* Reading database settings ini file */
$is_label_set = FALSE;
- if ($this->session->userdata('db_active_label'))
+ if ($this->session->userdata('active_account'))
{
$is_label_set = TRUE;
/* Fetching database label details from session */
- $db_active_label = $this->session->userdata('db_active_label');
- $ini_file = $this->config->item('config_path') . "accounts/" . $db_active_label . ".ini";
+ $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))
diff --git a/system/application/controllers/setting.php b/system/application/controllers/setting.php
index 0ac8bf8..c26a81f 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -929,7 +929,7 @@ class Setting extends Controller {
return;
} else {
/* Unsetting all database configutaion */
- $this->session->unset_userdata('db_active_label');
+ $this->session->unset_userdata('active_account');
$data_select_account = $this->input->post('select_account', TRUE);
$ini_file = $this->config->item('config_path') . "accounts/" . $data_select_account . ".ini";
@@ -952,7 +952,7 @@ class Setting extends Controller {
}
/* Setting new account database details in session */
- $this->session->set_userdata('db_active_label', $data_select_account);
+ $this->session->set_userdata('active_account', $data_select_account);
$this->messages->add('Active account changed.', 'success');
redirect('');
}
diff --git a/system/application/controllers/user.php b/system/application/controllers/user.php
index 062f7fd..69f0d9c 100644
--- a/system/application/controllers/user.php
+++ b/system/application/controllers/user.php
@@ -67,7 +67,7 @@ class User extends Controller {
} else {
$this->session->unset_userdata('user_name');
$this->session->unset_userdata('user_role');
- $this->session->unset_userdata('db_active_label');
+ $this->session->unset_userdata('active_account');
$this->messages->add('Invalid User name or Password.', 'error');
$this->template->load('user_template', 'user/login', $data);
return;
@@ -79,7 +79,7 @@ class User extends Controller {
{
$this->session->unset_userdata('user_name');
$this->session->unset_userdata('user_role');
- $this->session->unset_userdata('db_active_label');
+ $this->session->unset_userdata('active_account');
$this->session->sess_destroy();
$this->messages->add('Logged out.', 'success');
redirect('user/login');
@@ -98,7 +98,7 @@ class User extends Controller {
}
/* Currently active account */
- $data['active_account'] = $this->session->userdata('db_active_label');
+ $data['active_account'] = $this->session->userdata('active_account');
/* Getting list of files in the config - accounts directory */
$accounts_list = get_filenames($this->config->item('config_path') . 'accounts');
@@ -185,7 +185,7 @@ class User extends Controller {
}
/* Setting new account database details in session */
- $this->session->set_userdata('db_active_label', $data_active_account);
+ $this->session->set_userdata('active_account', $data_active_account);
$this->messages->add('Active account changed.', 'success');
redirect('');
}
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index 26d6f2b..2cf6b2a 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -31,11 +31,11 @@ class Startup
}
/* Reading database settings ini file */
- if ($CI->session->userdata('db_active_label'))
+ if ($CI->session->userdata('active_account'))
{
/* Fetching database label details from session */
- $db_active_label = $CI->session->userdata('db_active_label');
- $ini_file = $CI->config->item('config_path') . "accounts/" . $db_active_label . ".ini";
+ $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))
diff --git a/system/application/views/admin/active.php b/system/application/views/admin/active.php
index efea0c5..0b84d55 100644
--- a/system/application/views/admin/active.php
+++ b/system/application/views/admin/active.php
@@ -3,7 +3,7 @@
echo "<p>";
echo "<b>Currently active account : </b>";
- echo $this->session->userdata('db_active_label');
+ echo $this->session->userdata('active_account');
echo "</p>";
echo "<p>";
diff --git a/system/application/views/admin/manage/index.php b/system/application/views/admin/manage/index.php
index 8c7561e..43471ac 100644
--- a/system/application/views/admin/manage/index.php
+++ b/system/application/views/admin/manage/index.php
@@ -1,7 +1,7 @@
<?php
echo "<p>";
echo "<b>Currently active account : </b>";
-echo $this->session->userdata('db_active_label');
+echo $this->session->userdata('active_account');
echo "</p>";
echo "<table border=0 cellpadding=5 class=\"simple-table manage-account-table\">";
@@ -27,7 +27,7 @@ foreach ($accounts as $label)
}
echo "<tr class=\"tr-" . $odd_even;
- if ($this->session->userdata('db_active_label') == $label)
+ if ($this->session->userdata('active_account') == $label)
echo " tr-draft";
echo "\">";
echo "<td>";
@@ -39,7 +39,7 @@ foreach ($accounts as $label)
echo "<td>" . $db_user . "</td>";
echo "<td>";
- if ($this->session->userdata('db_active_label') == $label)
+ 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'));
diff --git a/system/application/views/user/account.php b/system/application/views/user/account.php
index 25c777f..7d56297 100644
--- a/system/application/views/user/account.php
+++ b/system/application/views/user/account.php
@@ -3,7 +3,7 @@
echo "<p>";
echo "<b>Currently active account : </b>";
- $current_active_account = $this->session->userdata('db_active_label');
+ $current_active_account = $this->session->userdata('active_account');
echo ($current_active_account) ? $current_active_account : "(None)";
echo "</p>";
commit 4ec0a44db39763c12e18eb10daf05d20ac46e221
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 4 21:06:20 2011 +0530
Added change active account action
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 bc4c1c5..062f7fd 100644
--- a/system/application/controllers/user.php
+++ b/system/application/controllers/user.php
@@ -84,6 +84,113 @@ class User extends Controller {
$this->messages->add('Logged out.', 'success');
redirect('user/login');
}
+
+ function account()
+ {
+ $this->template->set('page_title', 'Change Account');
+
+ /* Check access */
+ if ( ! ($this->session->userdata('user_name')))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('');
+ return;
+ }
+
+ /* Currently active account */
+ $data['active_account'] = $this->session->userdata('db_active_label');
+
+ /* 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;
+ }
+ }
+ }
+
+ /* Form validations */
+ $this->form_validation->set_rules('account', 'Account', 'trim|required');
+
+ /* Repopulating form */
+ if ($_POST)
+ {
+ $data['active_account'] = $this->input->post('account', TRUE);
+ }
+
+ /* Validating form : only if label name is not set from URL */
+ if ($this->form_validation->run() == FALSE)
+ {
+ $this->messages->add(validation_errors(), 'error');
+ $this->template->load('user_template', 'user/account', $data);
+ return;
+ } else {
+ $data_active_account = $this->input->post('account', TRUE);
+ $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. Default MySQL port is 3306.', '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']))
+ {
+ $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('db_active_label', $data_active_account);
+ $this->messages->add('Active account changed.', 'success');
+ redirect('');
+ }
+ return;
+ }
}
/* End of file user.php */
diff --git a/system/application/views/user/account.php b/system/application/views/user/account.php
new file mode 100644
index 0000000..25c777f
--- /dev/null
+++ b/system/application/views/user/account.php
@@ -0,0 +1,23 @@
+<?php
+ echo form_open('user/account');
+
+ echo "<p>";
+ echo "<b>Currently active account : </b>";
+ $current_active_account = $this->session->userdata('db_active_label');
+ echo ($current_active_account) ? $current_active_account : "(None)";
+ echo "</p>";
+
+ echo "<p>";
+ echo "Select account";
+ echo "<br />";
+ echo form_dropdown('account', $accounts, $active_account);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_submit('submit', 'Activate');
+ echo " ";
+ echo anchor('', 'Back', array('title' => 'Back to accounts'));
+ echo "</p>";
+
+ echo form_close();
+
commit 568da17b9330bdcd8bce5857d4696d2b53529121
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 4 15:42:18 2011 +0530
Unset all session variables explicitly on logout
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 262bb50..bc4c1c5 100644
--- a/system/application/controllers/user.php
+++ b/system/application/controllers/user.php
@@ -65,7 +65,9 @@ class User extends Controller {
redirect('');
return;
} else {
- $this->session->sess_destroy();
+ $this->session->unset_userdata('user_name');
+ $this->session->unset_userdata('user_role');
+ $this->session->unset_userdata('db_active_label');
$this->messages->add('Invalid User name or Password.', 'error');
$this->template->load('user_template', 'user/login', $data);
return;
@@ -75,6 +77,9 @@ class User extends Controller {
function logout()
{
+ $this->session->unset_userdata('user_name');
+ $this->session->unset_userdata('user_role');
+ $this->session->unset_userdata('db_active_label');
$this->session->sess_destroy();
$this->messages->add('Logged out.', 'success');
redirect('user/login');
commit cc61b7011671c8de0c0ef77a9265bc48aa42fa25
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 4 15:35:34 2011 +0530
Added list of valid permissions strings
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 14e99c0..6a6263e 100644
--- a/system/application/controllers/admin/welcome.php
+++ b/system/application/controllers/admin/welcome.php
@@ -5,6 +5,15 @@ class Welcome extends Controller {
function Welcome()
{
parent::Controller();
+
+ /* Check access */
+ if ( ! check_access('administer'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('');
+ return;
+ }
+
return;
}
diff --git a/system/application/helpers/access_helper.php b/system/application/helpers/access_helper.php
index 2d011af..09ba678 100644
--- a/system/application/helpers/access_helper.php
+++ b/system/application/helpers/access_helper.php
@@ -3,6 +3,32 @@
/*
* Check if the currently logger in user has the necessary permissions
* to permform the given action
+ *
+ * Valid permissions strings are given below :
+ *
+ * 'view voucher'
+ * 'create voucher'
+ * 'edit voucher'
+ * 'delete voucher'
+ * 'print voucher'
+ * 'email voucher'
+ * 'download voucher'
+ * 'create ledger'
+ * 'edit ledger'
+ * 'delete ledger'
+ * 'create group'
+ * 'edit group'
+ * 'delete group'
+ * 'create tag'
+ * 'edit tag'
+ * 'delete tag'
+ * 'view reports'
+ * 'view log'
+ * 'clear log'
+ * 'change account settings'
+ * 'cf account'
+ * 'backup account'
+ * 'administer'
*/
if ( ! function_exists('check_access'))
diff --git a/system/application/views/admin_template.php b/system/application/views/admin_template.php
index ecaa4ab..dab5ef0 100644
--- a/system/application/views/admin_template.php
+++ b/system/application/views/admin_template.php
@@ -36,7 +36,8 @@ $(document).ready(function(){
Webzash <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('', 'Accounts', array('title' => "Back to accounts", 'class' => 'anchor-link-b')); ?> |
+ <?php echo anchor('user/logout', 'Logout', array('title' => "Logout", 'class' => 'anchor-link-b')); ?>
</div>
<div id="info">
</div>
diff --git a/system/application/views/welcome.php b/system/application/views/welcome.php
index 9c0f59b..b87769a 100644
--- a/system/application/views/welcome.php
+++ b/system/application/views/welcome.php
@@ -161,34 +161,36 @@ jQuery(document).ready(function () {
</table>
</div>
</div>
-<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-content">
+<?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-content">
+ <?php
+ if ($logs)
+ {
+ echo "<ul id=\"recent-activity-list\">";
+ foreach ($logs->result() as $row)
+ {
+ echo "<li>" . $row->message_title . "</li>";
+ }
+ echo "</ul>";
+ } else {
+ echo "No Recent Activity";
+ }
+ ?>
+ </div>
<?php
- if ($logs)
- {
- echo "<ul id=\"recent-activity-list\">";
- foreach ($logs->result() as $row)
+ if ($logs)
{
- echo "<li>" . $row->message_title . "</li>";
+ echo "<div class=\"dashboard-log-footer\">";
+ echo "<span>";
+ echo anchor("log", "more...", array('class' => 'anchor-link-a'));
+ echo "</span>";
}
- echo "</ul>";
- } else {
- echo "No Recent Activity";
- }
?>
- </div>
- <?php
- if ($logs)
- {
- echo "<div class=\"dashboard-log-footer\">";
- echo "<span>";
- echo anchor("log", "more...", array('class' => 'anchor-link-a'));
- echo "</span>";
- }
- ?>
+ </div>
</div>
</div>
-</div>
+<?php } ?>
<div class="clear"></div>
commit ad5f2d0d19193abea4d6b0d0698fdb1f54d40f8a
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 4 15:25:11 2011 +0530
Added User login and logout actions
- Check on startup is user is logged in
- Added check_access to Admin section
- Added User controller and user_template template
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/admin/active.php b/system/application/controllers/admin/active.php
index 01a6267..7415326 100644
--- a/system/application/controllers/admin/active.php
+++ b/system/application/controllers/admin/active.php
@@ -5,6 +5,15 @@ class Active extends Controller {
function Active()
{
parent::Controller();
+
+ /* Check access */
+ if ( ! check_access('administer'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('');
+ return;
+ }
+
return;
}
diff --git a/system/application/controllers/admin/create.php b/system/application/controllers/admin/create.php
index 7b864aa..d6b5f53 100644
--- a/system/application/controllers/admin/create.php
+++ b/system/application/controllers/admin/create.php
@@ -5,6 +5,15 @@ class Create extends Controller {
function Create()
{
parent::Controller();
+
+ /* Check access */
+ if ( ! check_access('administer'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('');
+ return;
+ }
+
return;
}
diff --git a/system/application/controllers/admin/manage.php b/system/application/controllers/admin/manage.php
index 550fd5e..1c62ba8 100644
--- a/system/application/controllers/admin/manage.php
+++ b/system/application/controllers/admin/manage.php
@@ -5,6 +5,15 @@ class Manage extends Controller {
function Manage()
{
parent::Controller();
+
+ /* Check access */
+ if ( ! check_access('administer'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('');
+ return;
+ }
+
return;
}
diff --git a/system/application/controllers/admin/setting.php b/system/application/controllers/admin/setting.php
index c1a0070..329b594 100644
--- a/system/application/controllers/admin/setting.php
+++ b/system/application/controllers/admin/setting.php
@@ -5,6 +5,15 @@ class Setting extends Controller {
function Setting()
{
parent::Controller();
+
+ /* Check access */
+ if ( ! check_access('administer'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('');
+ return;
+ }
+
return;
}
diff --git a/system/application/controllers/admin/status.php b/system/application/controllers/admin/status.php
index 5485bcb..cdf1da7 100644
--- a/system/application/controllers/admin/status.php
+++ b/system/application/controllers/admin/status.php
@@ -5,6 +5,15 @@ class Status extends Controller {
function Status()
{
parent::Controller();
+
+ /* Check access */
+ if ( ! check_access('administer'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('');
+ return;
+ }
+
return;
}
diff --git a/system/application/controllers/user.php b/system/application/controllers/user.php
new file mode 100644
index 0000000..262bb50
--- /dev/null
+++ b/system/application/controllers/user.php
@@ -0,0 +1,85 @@
+<?php
+
+class User extends Controller {
+ function index()
+ {
+ redirect('user/login');
+ return;
+ }
+
+ function login()
+ {
+ $this->template->set('page_title', 'Login');
+
+ /* 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' => '',
+ );
+
+ /* Form validations */
+ $this->form_validation->set_rules('user_name', 'User name', 'trim|required|min_length[1]|max_length[100]');
+ $this->form_validation->set_rules('user_password', 'Password', 'trim|required|min_length[1]|max_length[100]');
+
+ /* Re-populating form */
+ if ($_POST)
+ {
+ $data['user_name']['value'] = $this->input->post('user_name', TRUE);
+ $data['user_password']['value'] = $this->input->post('user_password', TRUE);
+ }
+
+ if ($this->form_validation->run() == FALSE)
+ {
+ $this->messages->add(validation_errors(), 'error');
+ $this->template->load('user_template', 'user/login', $data);
+ return;
+ }
+ else
+ {
+ $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")
+ {
+ $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->sess_destroy();
+ $this->messages->add('Invalid User name or Password.', 'error');
+ $this->template->load('user_template', 'user/login', $data);
+ return;
+ }
+ }
+ }
+
+ function logout()
+ {
+ $this->session->sess_destroy();
+ $this->messages->add('Logged out.', 'success');
+ redirect('user/login');
+ }
+}
+
+/* End of file user.php */
+/* Location: ./system/application/controllers/user.php */
diff --git a/system/application/helpers/access_helper.php b/system/application/helpers/access_helper.php
index 1629661..2d011af 100644
--- a/system/application/helpers/access_helper.php
+++ b/system/application/helpers/access_helper.php
@@ -10,7 +10,6 @@ if ( ! function_exists('check_access'))
function check_access($action_name)
{
$CI =& get_instance();
- $CI->session->set_userdata('user_role', 'administrator');
$user_role = $CI->session->userdata('user_role');
$permissions['manager'] = array(
'view voucher',
@@ -75,6 +74,9 @@ if ( ! function_exists('check_access'))
'download voucher',
);
+ if ( ! isset($user_role))
+ return FALSE;
+
/* If user is administrator then always allow access */
if ($user_role == "administrator")
return TRUE;
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index 3e00ad9..26d6f2b 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -19,6 +19,17 @@ class Startup
if ($CI->uri->segment(1) == "admin")
return;
+ /* Skip checking if accessing user section*/
+ if ($CI->uri->segment(1) == "user")
+ return;
+
+ /* Check if user is logged in */
+ if ( ! $CI->session->userdata('user_name'))
+ {
+ redirect('user/login');
+ return;
+ }
+
/* Reading database settings ini file */
if ($CI->session->userdata('db_active_label'))
{
diff --git a/system/application/views/template.php b/system/application/views/template.php
index 018c33a..460acb1 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -68,7 +68,15 @@ $(document).ready(function() {
Webzash <span id="beta-area">(beta)</span>
</div>
<div id="admin">
- <?php echo anchor('admin', 'Administer', array('title' => "Administer", 'class' => 'anchor-link-b')); ?>
+ <?php
+ /* Check if allowed administer rights */
+ if (check_access('administer'))
+ {
+ echo anchor('admin', 'Administer', array('title' => "Administer", 'class' => 'anchor-link-b'));
+ echo " | ";
+ }
+ ?>
+ <?php echo anchor('user/logout', 'Logout', array('title' => "Logout", 'class' => 'anchor-link-b')); ?>
</div>
<div id="info">
<?php
diff --git a/system/application/views/user/login.php b/system/application/views/user/login.php
new file mode 100644
index 0000000..db9f576
--- /dev/null
+++ b/system/application/views/user/login.php
@@ -0,0 +1,25 @@
+<?php
+ echo form_open('user/login');
+
+ echo "<p>";
+ echo form_label('User name', '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_submit('submit', 'Login');
+ 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 "</p>";
+
+ echo form_close();
+
diff --git a/system/application/views/user_template.php b/system/application/views/user_template.php
new file mode 100644
index 0000000..9fd47a4
--- /dev/null
+++ b/system/application/views/user_template.php
@@ -0,0 +1,114 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<title>Webzash<?php if (isset($page_title)) echo ' | ' . $page_title; ?></title>
+
+<?php echo link_tag(asset_url() . 'images/favicon.ico', 'shortcut icon', 'image/ico'); ?>
+
+<link type="text/css" rel="stylesheet" href="<?php echo asset_url(); ?>css/style.css">
+<link type="text/css" rel="stylesheet" href="<?php echo asset_url(); ?>css/tables.css">
+<link type="text/css" rel="stylesheet" href="<?php echo asset_url(); ?>css/custom.css">
+<link type="text/css" rel="stylesheet" href="<?php echo asset_url(); ?>css/menu.css">
+<link type="text/css" rel="stylesheet" href="<?php echo asset_url(); ?>css/jquery.datepick.css">
+<link type="text/css" rel="stylesheet" href="<?php echo asset_url(); ?>css/thickbox.css">
+
+<script type="text/javascript" src="<?php echo asset_url(); ?>js/jquery.min.js"></script>
+<script type="text/javascript" src="<?php echo asset_url(); ?>js/jquery.datepick.js"></script>
+<script type="text/javascript" src="<?php echo asset_url(); ?>js/custom.js"></script>
+<script type="text/javascript" src="<?php echo asset_url(); ?>js/hoverIntent.js"></script>
+<script type="text/javascript" src="<?php echo asset_url(); ?>js/superfish.js"></script>
+<script type="text/javascript" src="<?php echo asset_url(); ?>js/supersubs.js"></script>
+<script type="text/javascript" src="<?php echo asset_url(); ?>js/thickbox-compressed.js"></script>
+<script type="text/javascript" src="<?php echo asset_url(); ?>js/ezpz_tooltip.min.js"></script>
+</head>
+<body>
+<div id="container">
+ <div id="header">
+ <div id="logo">
+ Webzash <span id="beta-area">(beta)</span>
+ </div>
+ </div>
+ <div id="menu">
+ <ul class="sf-menu">
+ <li class="current">
+ </li>
+ </ul>
+ </div>
+ <div id="content">
+ <div id="sidebar">
+ <?php if (isset($page_sidebar)) echo $page_sidebar; ?>
+ </div>
+ <div id="main">
+ <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>
+ <div class="clear">
+ </div>
+ <div id="main-content">
+ <?php
+ $messages = $this->messages->get();
+ if (is_array($messages))
+ {
+ if (count($messages['success']) > 0)
+ {
+ echo "<div id=\"success-box\">";
+ echo "<ul>";
+ foreach ($messages['success'] as $message) {
+ echo ('<li>' . $message . '</li>');
+ }
+ echo "</ul>";
+ echo "</div>";
+ }
+ if (count($messages['error']) > 0)
+ {
+ echo "<div id=\"error-box\">";
+ echo "<ul>";
+ foreach ($messages['error'] as $message) {
+ if (substr($message, 0, 4) == "<li>")
+ echo ($message);
+ else
+ echo ('<li>' . $message . '</li>');
+ }
+ echo "</ul>";
+ echo "</div>";
+ }
+ if (count($messages['message']) > 0)
+ {
+ echo "<div id=\"message-box\">";
+ echo "<ul>";
+ foreach ($messages['message'] as $message) {
+ echo ('<li>' . $message . '</li>');
+ }
+ echo "</ul>";
+ echo "</div>";
+ }
+ }
+ ?>
+ <?php echo $contents; ?>
+ </div>
+ </div>
+ </div>
+</div>
+<div id="footer">
+ <?php if (isset($page_footer)) echo $page_footer ?>
+ <a href="http://webzash.wordpress.com" target="_blank">Webzash<a/> is licensed under <a href="http://www.gnu.org/licenses/agpl-3.0.txt" target="_blank">GNU Affero General Public License, version 3</a> as published by the Free Software Foundation.
+</div>
+<div id="account_change" class="hidden-element">
+ <div id="changeActiveAccount">
+ <?php $this->load->view("setting/change"); ?>
+ </div>
+</div>
+</body>
+</html>
commit bd6f089fe39abe7f622567439918e9156786c260
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Jan 4 14:28:00 2011 +0530
Added check_access to Vouchers
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 4d1345c..91fcbf2 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -243,6 +243,14 @@ class Voucher extends Controller {
function add($voucher_type)
{
+ /* Check access */
+ if ( ! check_access('create voucher'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('voucher/show/' . $voucher_type);
+ return;
+ }
+
switch ($voucher_type)
{
case 'receipt' :
@@ -558,6 +566,14 @@ class Voucher extends Controller {
function edit($voucher_type, $voucher_id = 0)
{
+ /* Check access */
+ if ( ! check_access('edit voucher'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('voucher/show/' . $voucher_type);
+ return;
+ }
+
switch ($voucher_type)
{
case 'receipt' :
@@ -907,6 +923,14 @@ class Voucher extends Controller {
function delete($voucher_type, $voucher_id)
{
+ /* Check access */
+ if ( ! check_access('delete voucher'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('voucher/show/' . $voucher_type);
+ return;
+ }
+
/* Load current voucher details */
if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id, $voucher_type))
{
@@ -945,6 +969,14 @@ class Voucher extends Controller {
$this->load->model('Setting_model');
$this->load->model('Ledger_model');
+ /* Check access */
+ if ( ! check_access('download voucher'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('voucher/show/' . $voucher_type);
+ return;
+ }
+
$account = $this->Setting_model->get_current();
/* Load current voucher details */
@@ -994,6 +1026,14 @@ class Voucher extends Controller {
$this->load->model('Setting_model');
$this->load->model('Ledger_model');
+ /* Check access */
+ if ( ! check_access('print voucher'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('voucher/show/' . $voucher_type);
+ return;
+ }
+
$account = $this->Setting_model->get_current();
/* Load current voucher details */
@@ -1041,6 +1081,14 @@ class Voucher extends Controller {
$this->load->model('Ledger_model');
$this->load->library('email');
+ /* Check access */
+ if ( ! check_access('email voucher'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('voucher/show/' . $voucher_type);
+ return;
+ }
+
$account_data = $this->Setting_model->get_current();
/* Load current voucher details */
diff --git a/system/application/helpers/access_helper.php b/system/application/helpers/access_helper.php
index 3a95995..1629661 100644
--- a/system/application/helpers/access_helper.php
+++ b/system/application/helpers/access_helper.php
@@ -79,6 +79,9 @@ if ( ! function_exists('check_access'))
if ($user_role == "administrator")
return TRUE;
+ if ( ! isset($permissions[$user_role]))
+ return FALSE;
+
if (in_array($action_name, $permissions[$user_role]))
return TRUE;
else
commit 1536233d582eb9287b63185ef123224f86e8a7ec
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 3 21:55:54 2011 +0530
Added check_access to Settings
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 64b02f5..83dc0e3 100644
--- a/system/application/controllers/group.php
+++ b/system/application/controllers/group.php
@@ -24,7 +24,7 @@ class Group extends Controller {
if ( ! check_access('create group'))
{
$this->messages->add('Permission denied', 'error');
- redirect("account");
+ redirect('account');
return;
}
@@ -110,7 +110,7 @@ class Group extends Controller {
if ( ! check_access('edit group'))
{
$this->messages->add('Permission denied', 'error');
- redirect("account");
+ redirect('account');
return;
}
@@ -229,7 +229,7 @@ class Group extends Controller {
if ( ! check_access('delete group'))
{
$this->messages->add('Permission denied', 'error');
- redirect("account");
+ redirect('account');
return;
}
diff --git a/system/application/controllers/ledger.php b/system/application/controllers/ledger.php
index 1ef6d2f..7a86132 100644
--- a/system/application/controllers/ledger.php
+++ b/system/application/controllers/ledger.php
@@ -24,7 +24,7 @@ class Ledger extends Controller {
if ( ! check_access('create ledger'))
{
$this->messages->add('Permission denied', 'error');
- redirect("account");
+ redirect('account');
return;
}
@@ -126,7 +126,7 @@ class Ledger extends Controller {
if ( ! check_access('edit ledger'))
{
$this->messages->add('Permission denied', 'error');
- redirect("account");
+ redirect('account');
return;
}
@@ -251,7 +251,7 @@ class Ledger extends Controller {
if ( ! check_access('delete ledger'))
{
$this->messages->add('Permission denied', 'error');
- redirect("account");
+ redirect('account');
return;
}
diff --git a/system/application/controllers/log.php b/system/application/controllers/log.php
index e697e61..2785969 100644
--- a/system/application/controllers/log.php
+++ b/system/application/controllers/log.php
@@ -12,7 +12,7 @@ class Log extends Controller {
if ( ! check_access('view log'))
{
$this->messages->add('Permission denied', 'error');
- redirect("");
+ redirect('');
return;
}
@@ -25,17 +25,17 @@ class Log extends Controller {
if ( ! check_access('clear log'))
{
$this->messages->add('Permission denied', 'error');
- redirect("");
+ redirect('');
return;
}
if ($this->db->query('DELETE FROM logs'))
{
$this->messages->add('Log cleared.', 'success');
- redirect("log");
+ redirect('log');
} else {
$this->messages->add('Error clearing Log.', 'error');
- redirect("log");
+ redirect('log');
}
return;
}
@@ -49,7 +49,7 @@ class Log extends Controller {
if ( ! check_access('view log'))
{
$this->messages->add('Permission denied', 'error');
- redirect("");
+ redirect('');
return;
}
diff --git a/system/application/controllers/report.php b/system/application/controllers/report.php
index ed5d963..d6048b6 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -12,7 +12,7 @@ class Report extends Controller {
if ( ! check_access('view reports'))
{
$this->messages->add('Permission denied', 'error');
- redirect("");
+ redirect('');
return;
}
@@ -622,7 +622,7 @@ class Report extends Controller {
if ($data['ledger_id'] < 1)
{
$this->messages->add('Invalid Ledger A/C.', 'error');
- redirect("report/ledgerst");
+ redirect('report/ledgerst');
}
$data['report'] = "report/ledgerst";
$data['title'] = "Ledger Statement for '" . $this->Ledger_model->get_name($data['ledger_id']) . "'";
diff --git a/system/application/controllers/setting.php b/system/application/controllers/setting.php
index db3f28b..0ac8bf8 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -6,6 +6,15 @@ class Setting extends Controller {
{
parent::Controller();
$this->load->model('Setting_model');
+
+ /* Check access */
+ if ( ! check_access('change account settings'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('');
+ return;
+ }
+
return;
}
@@ -158,6 +167,14 @@ class Setting extends Controller {
$this->load->model('Setting_model');
$this->template->set('page_title', 'Carry forward account');
+ /* Check access */
+ if ( ! check_access('cf account'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('setting');
+ return;
+ }
+
/* Current settings */
$account_data = $this->Setting_model->get_current();
@@ -780,6 +797,15 @@ class Setting extends Controller {
{
$this->load->dbutil();
$this->load->helper('download');
+
+ /* Check access */
+ if ( ! check_access('backup account'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect('setting');
+ return;
+ }
+
$backup_filename = "backup" . date("dmYHis") . ".gz";
/* Backup your entire database and assign it to a variable */
@@ -899,7 +925,7 @@ class Setting extends Controller {
if ($this->form_validation->run() == FALSE)
{
$this->messages->add(validation_errors(), 'error');
- redirect("");
+ redirect('');
return;
} else {
/* Unsetting all database configutaion */
@@ -912,7 +938,7 @@ class Setting extends Controller {
if ( ! get_file_info($ini_file))
{
$this->messages->add('Account setting file is missing.', 'error');
- redirect("");
+ redirect('');
return;
}
@@ -921,14 +947,14 @@ class Setting extends Controller {
if ( ! $active_accounts)
{
$this->messages->add('Invalid account setting file.', 'error');
- redirect("");
+ redirect('');
return;
}
/* Setting new account database details in session */
$this->session->set_userdata('db_active_label', $data_select_account);
$this->messages->add('Active account changed.', 'success');
- redirect("");
+ redirect('');
}
return;
}
diff --git a/system/application/controllers/tag.php b/system/application/controllers/tag.php
index f663af0..ccd49d8 100644
--- a/system/application/controllers/tag.php
+++ b/system/application/controllers/tag.php
@@ -25,7 +25,7 @@ class Tag extends Controller {
if ( ! check_access('create tag'))
{
$this->messages->add('Permission denied', 'error');
- redirect("tag");
+ redirect('tag');
return;
}
@@ -120,7 +120,7 @@ class Tag extends Controller {
if ( ! check_access('edit tag'))
{
$this->messages->add('Permission denied', 'error');
- redirect("tag");
+ redirect('tag');
return;
}
@@ -233,7 +233,7 @@ class Tag extends Controller {
if ( ! check_access('delete tag'))
{
$this->messages->add('Permission denied', 'error');
- redirect("tag");
+ redirect('tag');
return;
}
diff --git a/system/application/helpers/access_helper.php b/system/application/helpers/access_helper.php
index abbfe92..3a95995 100644
--- a/system/application/helpers/access_helper.php
+++ b/system/application/helpers/access_helper.php
@@ -33,7 +33,8 @@ if ( ! function_exists('check_access'))
'view log',
'clear log',
'change account settings',
- 'backup account database',
+ 'cf account',
+ 'backup account',
);
$permissions['accountant'] = array(
'view voucher',
commit 9f2044750301dea6fd7d4ae8766665d44126f271
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 3 21:42:50 2011 +0530
Added check_access to Tags
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 86b994e..1ef6d2f 100644
--- a/system/application/controllers/ledger.php
+++ b/system/application/controllers/ledger.php
@@ -247,7 +247,6 @@ class Ledger extends Controller {
function delete($id)
{
-
/* Check access */
if ( ! check_access('delete ledger'))
{
diff --git a/system/application/controllers/log.php b/system/application/controllers/log.php
index 90532c7..e697e61 100644
--- a/system/application/controllers/log.php
+++ b/system/application/controllers/log.php
@@ -21,7 +21,6 @@ class Log extends Controller {
function clear()
{
-
/* Check access */
if ( ! check_access('clear log'))
{
diff --git a/system/application/controllers/tag.php b/system/application/controllers/tag.php
index 9fefda0..f663af0 100644
--- a/system/application/controllers/tag.php
+++ b/system/application/controllers/tag.php
@@ -21,6 +21,14 @@ class Tag extends Controller {
{
$this->template->set('page_title', 'New Tag');
+ /* Check access */
+ if ( ! check_access('create tag'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect("tag");
+ return;
+ }
+
/* Colorpicker JS and CSS */
$this->template->set('add_css', array(
"plugins/colorpicker/css/colorpicker.css",
@@ -107,7 +115,15 @@ class Tag extends Controller {
function edit($id = 0)
{
$this->template->set('page_title', 'Edit Tag');
-
+
+ /* Check access */
+ if ( ! check_access('edit tag'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect("tag");
+ return;
+ }
+
/* Colorpicker JS and CSS */
$this->template->set('add_css', array(
"plugins/colorpicker/css/colorpicker.css",
@@ -213,6 +229,14 @@ class Tag extends Controller {
function delete($id)
{
+ /* Check access */
+ if ( ! check_access('delete tag'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect("tag");
+ return;
+ }
+
/* Checking for valid data */
$id = $this->input->xss_clean($id);
$id = (int)$id;
diff --git a/system/application/helpers/access_helper.php b/system/application/helpers/access_helper.php
index dc1fb2c..abbfe92 100644
--- a/system/application/helpers/access_helper.php
+++ b/system/application/helpers/access_helper.php
@@ -26,7 +26,9 @@ if ( ! function_exists('check_access'))
'create group',
'edit group',
'delete group',
- 'manage tag',
+ 'create tag',
+ 'edit tag',
+ 'delete tag',
'view reports',
'view log',
'clear log',
@@ -47,7 +49,9 @@ if ( ! function_exists('check_access'))
'create group',
'edit group',
'delete group',
- 'manage tag',
+ 'create tag',
+ 'edit tag',
+ 'delete tag',
'view reports',
'view log',
'clear log',
commit 40d225ef91a1d71b7f8f49654522ff78c2b19e5e
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 3 21:36:23 2011 +0530
Added check_access to Reports
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 fa8d923..ed5d963 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -7,6 +7,15 @@ class Report extends Controller {
{
parent::Controller();
$this->load->model('Ledger_model');
+
+ /* Check access */
+ if ( ! check_access('view reports'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect("");
+ return;
+ }
+
return;
}
diff --git a/system/application/helpers/access_helper.php b/system/application/helpers/access_helper.php
index 49d800d..dc1fb2c 100644
--- a/system/application/helpers/access_helper.php
+++ b/system/application/helpers/access_helper.php
@@ -27,7 +27,7 @@ if ( ! function_exists('check_access'))
'edit group',
'delete group',
'manage tag',
- 'view report',
+ 'view reports',
'view log',
'clear log',
'change account settings',
@@ -48,7 +48,7 @@ if ( ! function_exists('check_access'))
'edit group',
'delete group',
'manage tag',
- 'view report',
+ 'view reports',
'view log',
'clear log',
);
commit 10f10e920c3beddd94b3072d29916b7e660e8841
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 3 21:33:02 2011 +0530
Added check_access to Logs
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 9d24beb..90532c7 100644
--- a/system/application/controllers/log.php
+++ b/system/application/controllers/log.php
@@ -7,11 +7,29 @@ class Log extends Controller {
$this->template->set('page_title', 'Logs');
$this->template->set('nav_links', array('log/clear' => 'Clear Log'));
$this->template->load('template', 'log/index');
+
+ /* Check access */
+ if ( ! check_access('view log'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect("");
+ return;
+ }
+
return;
}
function clear()
{
+
+ /* Check access */
+ if ( ! check_access('clear log'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect("");
+ return;
+ }
+
if ($this->db->query('DELETE FROM logs'))
{
$this->messages->add('Log cleared.', 'success');
@@ -27,6 +45,15 @@ class Log extends Controller {
{
$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'];
@@ -40,5 +67,5 @@ class Log extends Controller {
}
}
-/* End of file account.php */
-/* Location: ./system/application/controllers/account.php */
+/* End of file log.php */
+/* Location: ./system/application/controllers/log.php */
diff --git a/system/application/helpers/access_helper.php b/system/application/helpers/access_helper.php
index 0ca7c34..49d800d 100644
--- a/system/application/helpers/access_helper.php
+++ b/system/application/helpers/access_helper.php
@@ -10,7 +10,7 @@ if ( ! function_exists('check_access'))
function check_access($action_name)
{
$CI =& get_instance();
- // $CI->session->set_userdata('user_role', 'guest');
+ $CI->session->set_userdata('user_role', 'administrator');
$user_role = $CI->session->userdata('user_role');
$permissions['manager'] = array(
'view voucher',
commit e8a7d3a7d4a2fc0aa298a82e9cbab8c144759253
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 3 21:27:23 2011 +0530
Added check_access to Ledgers
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 20ee0aa..86b994e 100644
--- a/system/application/controllers/ledger.php
+++ b/system/application/controllers/ledger.php
@@ -20,6 +20,14 @@ class Ledger extends Controller {
{
$this->template->set('page_title', 'New Ledger');
+ /* Check access */
+ if ( ! check_access('create ledger'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect("account");
+ return;
+ }
+
/* Form fields */
$data['ledger_name'] = array(
'name' => 'ledger_name',
@@ -114,6 +122,14 @@ class Ledger extends Controller {
{
$this->template->set('page_title', 'Edit Ledger');
+ /* Check access */
+ if ( ! check_access('edit ledger'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect("account");
+ return;
+ }
+
/* Checking for valid data */
$id = $this->input->xss_clean($id);
$id = (int)$id;
@@ -231,6 +247,15 @@ class Ledger extends Controller {
function delete($id)
{
+
+ /* Check access */
+ if ( ! check_access('delete ledger'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect("account");
+ return;
+ }
+
/* Checking for valid data */
$id = $this->input->xss_clean($id);
$id = (int)$id;
commit 155d98aad66fbf53a534cd77acf87486ebcab3b3
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 3 21:24:13 2011 +0530
Added check_access to Groups
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 ffdf439..64b02f5 100644
--- a/system/application/controllers/group.php
+++ b/system/application/controllers/group.php
@@ -106,6 +106,14 @@ class Group extends Controller {
{
$this->template->set('page_title', 'Edit Group');
+ /* Check access */
+ if ( ! check_access('edit group'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect("account");
+ return;
+ }
+
/* Checking for valid data */
$id = $this->input->xss_clean($id);
$id = (int)$id;
@@ -217,6 +225,14 @@ class Group extends Controller {
function delete($id)
{
+ /* Check access */
+ if ( ! check_access('delete group'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect("account");
+ return;
+ }
+
/* Checking for valid data */
$id = $this->input->xss_clean($id);
$id = (int)$id;
commit 8d847c0acb69a30b8748504839ac34a95c81ee54
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 3 21:21:40 2011 +0530
Added user access verification helper
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/config/autoload.php b/system/application/config/autoload.php
index 0d632e2..8cfb4e3 100644
--- a/system/application/config/autoload.php
+++ b/system/application/config/autoload.php
@@ -51,7 +51,7 @@ $autoload['libraries'] = array('database', 'session', 'form_validation', 'messag
| $autoload['helper'] = array('url', 'file');
*/
-$autoload['helper'] = array('url', 'path', 'html', 'form', 'date', 'file', 'custom');
+$autoload['helper'] = array('url', 'path', 'html', 'form', 'date', 'file', 'access', 'custom');
/*
diff --git a/system/application/controllers/group.php b/system/application/controllers/group.php
index f5d24d7..ffdf439 100644
--- a/system/application/controllers/group.php
+++ b/system/application/controllers/group.php
@@ -20,6 +20,14 @@ class Group extends Controller {
$this->load->library('validation');
$this->template->set('page_title', 'New Group');
+ /* Check access */
+ if ( ! check_access('create group'))
+ {
+ $this->messages->add('Permission denied', 'error');
+ redirect("account");
+ return;
+ }
+
/* Form fields */
$data['group_name'] = array(
'name' => 'group_name',
diff --git a/system/application/helpers/access_helper.php b/system/application/helpers/access_helper.php
new file mode 100644
index 0000000..0ca7c34
--- /dev/null
+++ b/system/application/helpers/access_helper.php
@@ -0,0 +1,85 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+/*
+ * Check if the currently logger in user has the necessary permissions
+ * to permform the given action
+ */
+
+if ( ! function_exists('check_access'))
+{
+ function check_access($action_name)
+ {
+ $CI =& get_instance();
+ // $CI->session->set_userdata('user_role', 'guest');
+ $user_role = $CI->session->userdata('user_role');
+ $permissions['manager'] = array(
+ 'view voucher',
+ 'create voucher',
+ 'edit voucher',
+ 'delete voucher',
+ 'print voucher',
+ 'email voucher',
+ 'download voucher',
+ 'create ledger',
+ 'edit ledger',
+ 'delete ledger',
+ 'create group',
+ 'edit group',
+ 'delete group',
+ 'manage tag',
+ 'view report',
+ 'view log',
+ 'clear log',
+ 'change account settings',
+ 'backup account database',
+ );
+ $permissions['accountant'] = array(
+ 'view voucher',
+ 'create voucher',
+ 'edit voucher',
+ 'delete voucher',
+ 'print voucher',
+ 'email voucher',
+ 'download voucher',
+ 'create ledger',
+ 'edit ledger',
+ 'delete ledger',
+ 'create group',
+ 'edit group',
+ 'delete group',
+ 'manage tag',
+ 'view report',
+ 'view log',
+ 'clear log',
+ );
+ $permissions['dataentry'] = array(
+ 'view voucher',
+ 'create voucher',
+ 'edit voucher',
+ 'delete voucher',
+ 'print voucher',
+ 'email voucher',
+ 'download voucher',
+ 'create ledger',
+ 'edit ledger',
+ );
+ $permissions['guest'] = array(
+ 'view voucher',
+ 'print voucher',
+ 'email voucher',
+ 'download voucher',
+ );
+
+ /* If user is administrator then always allow access */
+ if ($user_role == "administrator")
+ return TRUE;
+
+ if (in_array($action_name, $permissions[$user_role]))
+ return TRUE;
+ else
+ return FALSE;
+ }
+}
+
+/* End of file access_helper.php */
+/* Location: ./system/application/helpers/access_helper.php */
13 years, 3 months
24 commits - config/accounts system/application
by pshah
config/accounts/sample.ini | 2
config/accounts/test.ini | 7
system/application/assets/css/admin-style.css | 6
system/application/assets/css/custom.css | 62 +
system/application/assets/css/style.css | 6
system/application/assets/js/custom.js | 3
system/application/assets/js/ezpz_tooltip.min.js | 2
system/application/assets/plugins/colorpicker/css/colorpicker.css | 161 +++
system/application/assets/plugins/colorpicker/css/layout.css | 218 ++++
system/application/assets/plugins/colorpicker/images/blank.gif |binary
system/application/assets/plugins/colorpicker/images/colorpicker_background.png |binary
system/application/assets/plugins/colorpicker/images/colorpicker_hex.png |binary
system/application/assets/plugins/colorpicker/images/colorpicker_hsb_b.png |binary
system/application/assets/plugins/colorpicker/images/colorpicker_hsb_h.png |binary
system/application/assets/plugins/colorpicker/images/colorpicker_hsb_s.png |binary
system/application/assets/plugins/colorpicker/images/colorpicker_indic.gif |binary
system/application/assets/plugins/colorpicker/images/colorpicker_overlay.png |binary
system/application/assets/plugins/colorpicker/images/colorpicker_rgb_b.png |binary
system/application/assets/plugins/colorpicker/images/colorpicker_rgb_g.png |binary
system/application/assets/plugins/colorpicker/images/colorpicker_rgb_r.png |binary
system/application/assets/plugins/colorpicker/images/colorpicker_select.gif |binary
system/application/assets/plugins/colorpicker/images/colorpicker_submit.png |binary
system/application/assets/plugins/colorpicker/images/custom_background.png |binary
system/application/assets/plugins/colorpicker/images/custom_hex.png |binary
system/application/assets/plugins/colorpicker/images/custom_hsb_b.png |binary
system/application/assets/plugins/colorpicker/images/custom_hsb_h.png |binary
system/application/assets/plugins/colorpicker/images/custom_hsb_s.png |binary
system/application/assets/plugins/colorpicker/images/custom_indic.gif |binary
system/application/assets/plugins/colorpicker/images/custom_rgb_b.png |binary
system/application/assets/plugins/colorpicker/images/custom_rgb_g.png |binary
system/application/assets/plugins/colorpicker/images/custom_rgb_r.png |binary
system/application/assets/plugins/colorpicker/images/custom_submit.png |binary
system/application/assets/plugins/colorpicker/images/select.png |binary
system/application/assets/plugins/colorpicker/images/select2.png |binary
system/application/assets/plugins/colorpicker/images/slider.png |binary
system/application/assets/plugins/colorpicker/js/colorpicker.js | 484 ++++++++++
system/application/assets/plugins/colorpicker/js/eye.js | 34
system/application/assets/plugins/colorpicker/js/layout.js | 67 +
system/application/assets/plugins/colorpicker/js/startup.js | 43
system/application/assets/plugins/colorpicker/js/utils.js | 252 +++++
system/application/controllers/account.php | 4
system/application/controllers/admin/active.php | 16
system/application/controllers/admin/carryforward.sql | 93 -
system/application/controllers/admin/create.php | 64 +
system/application/controllers/admin/database.sql | 110 --
system/application/controllers/admin/initialize.sql | 16
system/application/controllers/admin/manage.php | 32
system/application/controllers/admin/schema.sql | 93 +
system/application/controllers/admin/setting.php | 8
system/application/controllers/admin/welcome.php | 22
system/application/controllers/group.php | 32
system/application/controllers/help.php | 13
system/application/controllers/ledger.php | 30
system/application/controllers/report.php | 2
system/application/controllers/setting.php | 125 +-
system/application/controllers/tag.php | 38
system/application/controllers/voucher.php | 230 ++++
system/application/controllers/welcome.php | 6
system/application/helpers/MY_date_helper.php | 20
system/application/helpers/MY_form_helper.php | 10
system/application/helpers/custom_helper.php | 2
system/application/libraries/MY_Form_validation.php | 2
system/application/libraries/Startup.php | 29
system/application/models/ledger_model.php | 24
system/application/views/admin/status.php | 7
system/application/views/group/add.php | 4
system/application/views/group/edit.php | 3
system/application/views/help/index.php | 34
system/application/views/ledger/add.php | 3
system/application/views/ledger/edit.php | 3
system/application/views/report/balancesheet.php | 2
system/application/views/report/profitandloss.php | 5
system/application/views/setting/printer.php | 17
system/application/views/tag/add.php | 4
system/application/views/tag/edit.php | 4
system/application/views/template.php | 8
system/application/views/voucher/add.php | 26
system/application/views/voucher/edit.php | 26
system/application/views/voucher/index.php | 25
system/application/views/welcome.php | 194 ++++
system/application/views/welcome_message.php | 194 ----
81 files changed, 2292 insertions(+), 635 deletions(-)
New commits:
commit 3483017e6ce547668a2b8970250d0e17b7406320
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Jan 2 12:22:26 2011 +0530
Removed unwanted account config file
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/config/accounts/sample.ini b/config/accounts/sample.ini
index 2f8fa22..0fed3c4 100644
--- a/config/accounts/sample.ini
+++ b/config/accounts/sample.ini
@@ -1,7 +1,7 @@
[database]
db_hostname = "localhost"
db_port = "3306"
-db_name = "wz_webzash"
+db_name = "webzash"
db_username = "root"
db_password = ""
diff --git a/config/accounts/test.ini b/config/accounts/test.ini
deleted file mode 100644
index c04d401..0000000
--- a/config/accounts/test.ini
+++ /dev/null
@@ -1,7 +0,0 @@
-[database]
-db_hostname = "localhost"
-db_port = "3306"
-db_name = "testing"
-db_username = "root"
-db_password = ""
-
commit 0b557582bc72c72f8bdd87e30532b4998e66fa7c
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Jan 2 12:13:07 2011 +0530
Added default voucher type to custom helper functions
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 4752758..4d1345c 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -116,7 +116,7 @@ class Voucher extends Controller {
$config['last_tag_open'] = '<li class="last">';
$config['last_tag_close'] = '</li>';
- if ($voucher_type_int > 5)
+ if (($voucher_type_int < 0) || ($voucher_type_int > 4))
{
$this->messages->add('Invalid voucher type.', 'error');
redirect('voucher/show/all');
diff --git a/system/application/helpers/custom_helper.php b/system/application/helpers/custom_helper.php
index 5a3617f..7bb13ce 100644
--- a/system/application/helpers/custom_helper.php
+++ b/system/application/helpers/custom_helper.php
@@ -115,6 +115,7 @@ if ( ! function_exists('n_to_v'))
case 2: return "payment"; break;
case 3: return "contra"; break;
case 4: return "journal"; break;
+ default: return ""; break;
}
}
}
@@ -138,6 +139,7 @@ if ( ! function_exists('v_to_n'))
case "payment": return 2; break;
case "contra": return 3; break;
case "journal": return 4; break;
+ default: return 0; break;
}
}
}
commit dfa9985ddeb0264e4ad7749b35ef5a08056a2931
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Dec 31 19:34:34 2010 +0530
Cleanup of html table alignments
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 ebd9a36..7b864aa 100644
--- a/system/application/controllers/admin/create.php
+++ b/system/application/controllers/admin/create.php
@@ -285,7 +285,7 @@ class Create extends Controller {
{
if (strlen($row) < 5)
continue;
- $newacc->query($row); var_dump($newacc->_error_message());
+ $newacc->query($row);
if ($newacc->_error_message() != "")
{
$newacc->trans_rollback();
diff --git a/system/application/views/report/balancesheet.php b/system/application/views/report/balancesheet.php
index d9b40ad..2330189 100644
--- a/system/application/views/report/balancesheet.php
+++ b/system/application/views/report/balancesheet.php
@@ -42,7 +42,7 @@
$total = $liability_total;
- echo "<tr class=\"total-area\">";
+ echo "<tr valign=\"top\" class=\"total-area\">";
echo "<td>";
echo "<table border=0 cellpadding=5 class=\"balance-sheet-total-table\" width=\"100%\">";
echo "<tr valign=\"top\">";
diff --git a/system/application/views/report/profitandloss.php b/system/application/views/report/profitandloss.php
index e21baf9..8e71052 100644
--- a/system/application/views/report/profitandloss.php
+++ b/system/application/views/report/profitandloss.php
@@ -47,7 +47,7 @@
/* Showing Gross P/L : Expenses */
$grosstotal = $gross_expense_total;
- echo "<tr class=\"total-area\">";
+ echo "<tr valign=\"top\" class=\"total-area\">";
echo "<td>";
echo "<table border=0 cellpadding=5 class=\"simple-table profit-loss-total-table\" width=\"100%\">";
echo "<tr valign=\"top\">";
@@ -113,6 +113,7 @@
/* 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");
+ echo "<tr valign=\"top\">";
echo "<td>";
echo "<table border=0 cellpadding=5 class=\"simple-table profit-loss-table\" width=\"100%\">";
echo "<thead><tr><th>Expenses (Net)</th><th align=\"right\">Amount</th></tr></thead>";
@@ -150,7 +151,7 @@
/* Showing Net P/L : Expenses */
$nettotal = $net_expense_total;
- echo "<tr class=\"total-area\">";
+ echo "<tr valign=\"top\" class=\"total-area\">";
echo "<td>";
echo "<table border=0 cellpadding=5 class=\"simple-table profit-loss-total-table\" width=\"100%\">";
echo "<tr valign=\"top\">";
commit 2fd54d856d2c17b04a917e3da4299b4c262c962c
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Dec 31 18:42:38 2010 +0530
Cleanup of status message and welcome.php view file
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 f85e5af..633df35 100644
--- a/system/application/controllers/welcome.php
+++ b/system/application/controllers/welcome.php
@@ -63,7 +63,7 @@ class Welcome extends Controller {
/* Getting Log Messages */
$data['logs'] = $this->logger->read_recent_messages();
- $this->template->load('template', 'welcome_message', $data);
+ $this->template->load('template', 'welcome', $data);
return;
}
}
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index dd5c724..3e00ad9 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -128,7 +128,7 @@ class Startup
$account_q = $CI->db->query('SELECT * FROM settings WHERE id = 1');
if ( ! ($account_d = $account_q->row()))
{
- $CI->messages->add('Invalid account details.', 'error');
+ $CI->messages->add('Invalid account settings.', 'error');
redirect('admin');
}
$CI->config->set_item('account_name', $account_d->name);
diff --git a/system/application/views/welcome.php b/system/application/views/welcome.php
new file mode 100644
index 0000000..9c0f59b
--- /dev/null
+++ b/system/application/views/welcome.php
@@ -0,0 +1,194 @@
+<style type="text/css">
+ #income-expense-graph-header {
+ width: 200px;
+ text-align: center;
+ padding-bottom:30px;
+ }
+ #income-expense-graph-data {
+ width: 200px;
+ height: 200px;
+ text-align: center;
+ }
+ #asset-liability-graph-header {
+ width: 200px;
+ text-align: center;
+ padding-bottom:30px;
+ }
+ #asset-liability-graph-data {
+ width: 200px;
+ height: 200px;
+ text-align: center;
+ }
+</style>
+
+<script type="text/javascript">
+jQuery(document).ready(function () {
+ jQuery('#income-expense-graph-data').tufteBar({
+ data: [
+ // First element is the y-value
+ // Other elements are arbitary - they are not used by the lib
+ // but are passed back into callback functions
+ [<?php echo -$income_total; ?>, {label: 'Incomes'}],
+ [<?php echo $expense_total; ?>, {label: 'Expenses'}]
+ ],
+
+ // Bar width in arbitrary units, 1.0 means the bars will be snuggled
+ // up next to each other
+ barWidth: 0.5,
+
+ // The label on top of the bar - can contain HTML
+ // formatNumber inserts commas as thousands separators in a number
+ barLabel: function(index) {
+ return $.tufteBar.formatNumber(this[0])
+ },
+
+ // The label on the x-axis - can contain HTML
+ axisLabel: function(index) { return this[1].label },
+
+ // The color of the bar
+ color: function(index) {
+ return ['#33CC66', '#C00000'][index % 2]
+ },
+ });
+
+ jQuery('#asset-liability-graph-data').tufteBar({
+ data: [
+ // First element is the y-value
+ // Other elements are arbitary - they are not used by the lib
+ // but are passed back into callback functions
+ [<?php echo $asset_total; ?>, {label: 'Assets'}],
+ [<?php echo -$liability_total; ?>, {label: 'Liabilities'}]
+ ],
+
+ // Bar width in arbitrary units, 1.0 means the bars will be snuggled
+ // up next to each other
+ barWidth: 0.5,
+
+ // The label on top of the bar - can contain HTML
+ // formatNumber inserts commas as thousands separators in a number
+ barLabel: function(index) {
+ return $.tufteBar.formatNumber(this[0])
+ },
+
+ // The label on the x-axis - can contain HTML
+ axisLabel: function(index) { return this[1].label },
+
+ // The color of the bar
+ color: function(index) {
+ return ['#33CC66', '#C00000'][index % 2]
+ },
+ });
+});
+</script>
+<div id="dashboard-summary">
+ <div id="dashboard-welcome-back" class="dashboard-item">
+ <div class="dashboard-title">Account Summary</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>
+ <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>
+ </div>
+ <div class="clear"></div>
+ <div id="dashboard-cash-bank" class="dashboard-item">
+ <div class="dashboard-title">Bank and Cash A/C's</div>
+ <div class="dashboard-content">
+ <?php
+ if ($bank_cash_account)
+ {
+ echo "<table class=\"dashboard-cashbank-table\">";
+ echo "<tbody>";
+ foreach ($bank_cash_account as $id => $row)
+ {
+ echo "<tr>";
+ echo "<td>" . anchor('report/ledgerst/' . $row['id'], $row['name'], array('title' => $row['name'] . ' Statement')) . "</td>";
+ echo "<td>" . convert_amount_dc($row['balance']) . "</td>";
+ echo "</tr>";
+ }
+ echo "</tbody>";
+ echo "</table>";
+ } else {
+ echo "You have not created any bank or cash account";
+ }
+ ?>
+ </div>
+ </div>
+ <div id="dashboard-summary" class="dashboard-item">
+ <div class="dashboard-title">Account Summary</div>
+ <div class="dashboard-content">
+ <?php
+ echo "<table class=\"dashboard-summary-table\">";
+ echo "<tbody>";
+ echo "<tr><td>Assets Total</td><td>" . convert_amount_dc($asset_total) . "</td></tr>";
+ echo "<tr><td>Liabilities Total</td><td>" . convert_amount_dc($liability_total) . "</td></tr>";
+ echo "<tr><td>Incomes Total</td><td>" . convert_amount_dc($income_total) . "</td></tr>";
+ echo "<tr><td>Expenses Total</td><td>" . convert_amount_dc($expense_total) . "</td></tr>";
+ echo "</tbody>";
+ echo "</table>";
+ ?>
+ </div>
+ </div>
+ <div class="clear"></div>
+ <div>
+ <table border="0">
+ <tbody>
+ <tr>
+ <?php if ($show_income_expense) { ?>
+ <td width="300">
+ <div id="income-expense" class="graph">
+ <div id="income-expense-graph-header"><strong>Incomes Vs Expenses</strong></div>
+ <div id="income-expense-graph-data"></div>
+ </div>
+ </td>
+ <?php } ?>
+ <?php if ($show_asset_liability) { ?>
+ <td width="300">
+ <div id="asset-liability" class="graph">
+ <div id="asset-liability-graph-header"><strong>Assets Vs Liabilities</strong></div>
+ <div id="asset-liability-graph-data""></div>
+ </div>
+ </td>
+ <?php } ?>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+</div>
+<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-content">
+ <?php
+ if ($logs)
+ {
+ echo "<ul id=\"recent-activity-list\">";
+ foreach ($logs->result() as $row)
+ {
+ echo "<li>" . $row->message_title . "</li>";
+ }
+ echo "</ul>";
+ } else {
+ echo "No Recent Activity";
+ }
+ ?>
+ </div>
+ <?php
+ if ($logs)
+ {
+ echo "<div class=\"dashboard-log-footer\">";
+ echo "<span>";
+ echo anchor("log", "more...", array('class' => 'anchor-link-a'));
+ echo "</span>";
+ }
+ ?>
+ </div>
+ </div>
+</div>
+<div class="clear"></div>
diff --git a/system/application/views/welcome_message.php b/system/application/views/welcome_message.php
deleted file mode 100644
index 5f9e14e..0000000
--- a/system/application/views/welcome_message.php
+++ /dev/null
@@ -1,194 +0,0 @@
-<style type="text/css">
- #income-expense-graph-header {
- width: 200px;
- text-align: center;
- padding-bottom:30px;
- }
- #income-expense-graph-data {
- width: 200px;
- height: 200px;
- text-align: center;
- }
- #asset-liability-graph-header {
- width: 200px;
- text-align: center;
- padding-bottom:30px;
- }
- #asset-liability-graph-data {
- width: 200px;
- height: 200px;
- text-align: center;
- }
-</style>
-
-<script type="text/javascript">
-jQuery(document).ready(function () {
- jQuery('#income-expense-graph-data').tufteBar({
- data: [
- // First element is the y-value
- // Other elements are arbitary - they are not used by the lib
- // but are passed back into callback functions
- [<?php echo -$income_total; ?>, {label: 'Incomes'}],
- [<?php echo $expense_total; ?>, {label: 'Expenses'}]
- ],
-
- // Bar width in arbitrary units, 1.0 means the bars will be snuggled
- // up next to each other
- barWidth: 0.5,
-
- // The label on top of the bar - can contain HTML
- // formatNumber inserts commas as thousands separators in a number
- barLabel: function(index) {
- return $.tufteBar.formatNumber(this[0])
- },
-
- // The label on the x-axis - can contain HTML
- axisLabel: function(index) { return this[1].label },
-
- // The color of the bar
- color: function(index) {
- return ['#33CC66', '#C00000'][index % 2]
- },
- });
-
- jQuery('#asset-liability-graph-data').tufteBar({
- data: [
- // First element is the y-value
- // Other elements are arbitary - they are not used by the lib
- // but are passed back into callback functions
- [<?php echo $asset_total; ?>, {label: 'Assets'}],
- [<?php echo -$liability_total; ?>, {label: 'Liabilities'}]
- ],
-
- // Bar width in arbitrary units, 1.0 means the bars will be snuggled
- // up next to each other
- barWidth: 0.5,
-
- // The label on top of the bar - can contain HTML
- // formatNumber inserts commas as thousands separators in a number
- barLabel: function(index) {
- return $.tufteBar.formatNumber(this[0])
- },
-
- // The label on the x-axis - can contain HTML
- axisLabel: function(index) { return this[1].label },
-
- // The color of the bar
- color: function(index) {
- return ['#33CC66', '#C00000'][index % 2]
- },
- });
-});
-</script>
-<div id="dashboard-summary">
- <div id="dashboard-welcome-back" class="dashboard-item">
- <div class="dashboard-title">Account Summary</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>
- <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>
- </div>
- <div class="clear"></div>
- <div id="dashboard-cash-bank" class="dashboard-item">
- <div class="dashboard-title">Bank and Cash A/C's</div>
- <div class="dashboard-content">
- <?php
- if ($bank_cash_account)
- {
- echo "<table class=\"dashboard-cashbank-table\">";
- echo "<tbody>";
- foreach ($bank_cash_account as $id => $row)
- {
- echo "<tr>";
- echo "<td>" . anchor('report/ledgerst/' . $row['id'], $row['name'], array('title' => $row['name'] . ' Statement')) . "</td>";
- echo "<td>" . convert_amount_dc($row['balance']) . "</td>";
- echo "</tr>";
- }
- echo "</tbody>";
- echo "</table>";
- } else {
- echo "You have not created any bank or cash account";
- }
- ?>
- </div>
- </div>
- <div id="dashboard-summary" class="dashboard-item">
- <div class="dashboard-title">Account Summary</div>
- <div class="dashboard-content">
- <?php
- echo "<table class=\"dashboard-summary-table\">";
- echo "<tbody>";
- echo "<tr><td>Assets Total</td><td>" . convert_amount_dc($asset_total) . "</td></tr>";
- echo "<tr><td>Liabilities Total</td><td>" . convert_amount_dc($liability_total) . "</td></tr>";
- echo "<tr><td>Incomes Total</td><td>" . convert_amount_dc($income_total) . "</td></tr>";
- echo "<tr><td>Expenses Total</td><td>" . convert_amount_dc($expense_total) . "</td></tr>";
- echo "</tbody>";
- echo "</table>";
- ?>
- </div>
- </div>
- <div class="clear"></div>
- <div>
- <table border="0">
- <tbody>
- <tr>
- <?php if ($show_income_expense) { ?>
- <td width="300">
- <div id="income-expense" class="graph">
- <div id="income-expense-graph-header"><strong>Incomes Vs Expenses</strong></div>
- <div id="income-expense-graph-data"></div>
- </div>
- </td>
- <?php } ?>
- <?php if ($show_asset_liability) { ?>
- <td width="300">
- <div id="asset-liability" class="graph">
- <div id="asset-liability-graph-header"><strong>Assets Vs Liabilities</strong></div>
- <div id="asset-liability-graph-data""></div>
- </div>
- </td>
- <?php } ?>
- </tr>
- </tbody>
- </table>
- </div>
-</div>
-<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-content">
- <?php
- if ($logs)
- {
- echo "<ul id=\"recent-activity-list\">";
- foreach ($logs->result() as $row)
- {
- echo "<li>" . $row->message_title . "</li>";
- }
- echo "</ul>";
- } else {
- echo "No Recent Activity";
- }
- ?>
- </div>
- <?php
- if ($logs)
- {
- echo "<div class=\"dashboard-log-footer\">";
- echo "<span>";
- echo anchor("log", "more...", array('class' => 'anchor-link-a'));
- echo "</span>";
- }
- ?>
- </div>
- </div>
-</div>
-<div class="clear"></div>
commit 168c210e74ca21cf48993701da7e9651018f1e38
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Dec 30 13:25:22 2010 +0530
Added basic help page
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/assets/css/custom.css b/system/application/assets/css/custom.css
index 416e018..8a3ecfd 100644
--- a/system/application/assets/css/custom.css
+++ b/system/application/assets/css/custom.css
@@ -252,3 +252,37 @@ ul#pagination-flickr {
background-color:#FFC848;
text-align:left;
}
+
+/************************************ HELP ************************************/
+ul#qa-list {
+ margin:0;
+ padding:0;
+}
+
+ul#qa-list li {
+ list-style:none;
+ padding:3px 0 3px 0;
+}
+
+ul#qa-list li .qa-heading {
+ font-weight:bold;
+}
+
+ul#qa-list li ul li {
+ list-style:square;
+ padding:3px 0 3px 0;
+}
+
+.qa-section {
+ margin:0 0 30px 0;
+}
+
+.qa-question {
+ font-weight:bold;
+ border-bottom:1px solid #AAAAAA;
+ margin:0 0 5px 0;
+}
+
+.qa-answer {
+ margin:0 0 0 20px;
+}
diff --git a/system/application/controllers/help.php b/system/application/controllers/help.php
new file mode 100644
index 0000000..bd87bbd
--- /dev/null
+++ b/system/application/controllers/help.php
@@ -0,0 +1,13 @@
+<?php
+
+class Help extends Controller {
+ function index()
+ {
+ $this->template->set('page_title', 'Help');
+ $this->template->load('template', 'help/index');
+ return;
+ }
+}
+
+/* End of file help.php */
+/* Location: ./system/application/controllers/help.php */
diff --git a/system/application/views/help/index.php b/system/application/views/help/index.php
new file mode 100644
index 0000000..ce75d2d
--- /dev/null
+++ b/system/application/views/help/index.php
@@ -0,0 +1,34 @@
+<ul id="qa-list">
+<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>
+ <li><a href="#print-2" class="anchor-link-a">How do I modify the reports print format (balance sheet, profit and loss statement, trial balance, ledger statement) ?</a></li>
+ </ul>
+</li>
+<li><span class="qa-heading">Email</span>
+ <ul>
+ <li><a href="#email-1" class="anchor-link-a">How do I modify the voucher email format ?</a></li>
+ </ul>
+</li>
+</ul>
+
+<br /><br />
+
+<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>
+ <div class="qa-answer">Voucher print template is located at "system/application/views/voucher/printpreview.php". Modify this file to change the voucher print format.</div>
+</div>
+
+<div class="qa-section" id="print-2">
+ <a name="print-2"></a>
+ <div class="qa-question">Q. How do I modify the reports print format (balance sheet, profit and loss statement, trial balance, ledger statement) ?</div>
+ <div class="qa-answer">Report print template is located at "system/application/views/report/report_template.php". Modify this file to change the report print format.</div>
+</div>
+
+<div class="qa-section" id="email-1">
+ <a name="email-1"></a>
+ <div class="qa-question">Q. How do I modify the voucher email format ?</div>
+ <div class="qa-answer">Voucher email template is located at "system/application/views/voucher/emailpreview.php". Modify this file to change the voucher email format.</div>
+</div>
+
diff --git a/system/application/views/template.php b/system/application/views/template.php
index 8683afb..018c33a 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -115,7 +115,7 @@ $(document).ready(function() {
<?php echo anchor('setting', 'Settings', array('title' => 'Settings')); ?>
</li>
<li>
- <?php echo anchor('', 'Help', array('title' => 'Help', 'class' => 'last')); ?>
+ <?php echo anchor('help', 'Help', array('title' => 'Help', 'class' => 'last')); ?>
</li>
</ul>
</div>
commit c9d296628feaee0b9df7f8b8289d0cb811c3f06c
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Dec 30 11:52:46 2010 +0530
Altered database structure
- Removed print_page_layout and print_logo
- Added account_locked and manage_stocks
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/admin/schema.sql b/system/application/controllers/admin/schema.sql
index d7b5037..6d97e7c 100644
--- a/system/application/controllers/admin/schema.sql
+++ b/system/application/controllers/admin/schema.sql
@@ -16,39 +16,6 @@ CREATE TABLE IF NOT EXISTS ledgers (
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=1;
-CREATE TABLE IF NOT EXISTS settings (
- id int(1) NOT NULL,
- name varchar(100) NOT NULL,
- address varchar(255) NOT NULL,
- email varchar(100) NOT NULL,
- fy_start datetime NOT NULL,
- fy_end datetime NOT NULL,
- currency_symbol varchar(10) NOT NULL,
- date_format varchar(30) NOT NULL,
- timezone varchar(255) NOT NULL,
- email_protocol varchar(9) NOT NULL,
- email_host varchar(255) NOT NULL,
- email_port int(5) NOT NULL,
- email_username varchar(255) NOT NULL,
- email_password varchar(255) NOT NULL,
- print_paper_height float NOT NULL,
- print_paper_width float NOT NULL,
- print_margin_top float NOT NULL,
- print_margin_bottom float NOT NULL,
- print_margin_left float NOT NULL,
- print_margin_right float NOT NULL,
- print_orientation varchar(1) NOT NULL,
- print_page_format varchar(1) NOT NULL,
- print_page_layout text NOT NULL,
- print_logo varchar(255) NOT NULL,
- receipt_voucher_prefix varchar(10) NOT NULL,
- payment_voucher_prefix varchar(10) NOT NULL,
- contra_voucher_prefix varchar(10) NOT NULL,
- journal_voucher_prefix varchar(10) NOT NULL,
- voucher_number_padding int(5) NOT NULL,
- database_version int(10) NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
-
CREATE TABLE IF NOT EXISTS vouchers (
id int(11) NOT NULL AUTO_INCREMENT,
tag_id int(11) NOT NULL DEFAULT '0',
@@ -91,3 +58,36 @@ CREATE TABLE IF NOT EXISTS logs (
message_desc mediumtext 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,
+ address varchar(255) NOT NULL,
+ email varchar(100) NOT NULL,
+ fy_start datetime NOT NULL,
+ fy_end datetime NOT NULL,
+ currency_symbol varchar(10) NOT NULL,
+ date_format varchar(30) NOT NULL,
+ timezone varchar(255) NOT NULL,
+ manage_stocks int(1) NOT NULL,
+ account_locked int(1) NOT NULL,
+ email_protocol varchar(9) NOT NULL,
+ email_host varchar(255) NOT NULL,
+ email_port int(5) NOT NULL,
+ email_username varchar(255) NOT NULL,
+ email_password varchar(255) NOT NULL,
+ print_paper_height float NOT NULL,
+ print_paper_width float NOT NULL,
+ print_margin_top float NOT NULL,
+ print_margin_bottom float NOT NULL,
+ print_margin_left float NOT NULL,
+ print_margin_right float NOT NULL,
+ print_orientation varchar(1) NOT NULL,
+ print_page_format varchar(1) NOT NULL,
+ receipt_voucher_prefix varchar(10) NOT NULL,
+ payment_voucher_prefix varchar(10) NOT NULL,
+ contra_voucher_prefix varchar(10) NOT NULL,
+ journal_voucher_prefix varchar(10) NOT NULL,
+ voucher_number_padding int(5) NOT NULL,
+ database_version int(10) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
diff --git a/system/application/controllers/setting.php b/system/application/controllers/setting.php
index 72e2adc..db3f28b 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -656,20 +656,6 @@ class Setting extends Controller {
'value' => 'T',
'checked' => FALSE,
);
- $data['page_layout'] = array(
- 'name' => 'page_layout',
- 'id' => 'page_layout',
- 'rows' => 10,
- 'cols' => 80,
- 'value' => '',
- );
- $data['logo'] = array(
- 'name' => 'logo',
- 'id' => 'logo',
- 'maxlength' => '100',
- 'size' => '40',
- 'value' => '',
- );
if ($account_data)
{
@@ -679,8 +665,6 @@ class Setting extends Controller {
$data['margin_bottom']['value'] = ($account_data->print_margin_bottom) ? print_value($account_data->print_margin_bottom) : '';
$data['margin_left']['value'] = ($account_data->print_margin_left) ? print_value($account_data->print_margin_left) : '';
$data['margin_right']['value'] = ($account_data->print_margin_right) ? print_value($account_data->print_margin_right) : '';
- $data['page_layout']['value'] = ($account_data->print_page_layout) ? print_value($account_data->print_page_layout) : '';
- $data['logo']['value'] = ($account_data->print_logo) ? print_value($account_data->print_logo) : '';
if ($account_data->print_orientation)
{
if ($account_data->print_orientation == "P")
@@ -712,8 +696,6 @@ class Setting extends Controller {
$this->form_validation->set_rules('margin_bottom', 'Bottom Margin', 'trim|required|numeric');
$this->form_validation->set_rules('margin_left', 'Left Margin', 'trim|required|numeric');
$this->form_validation->set_rules('margin_right', 'Right Margin', 'trim|required|numeric');
- $this->form_validation->set_rules('page_layout', 'Page Layout', 'trim|min_length[2]');
- $this->form_validation->set_rules('logo', 'Logo Path', 'trim');
/* Repopulating form */
if ($_POST)
@@ -724,8 +706,6 @@ class Setting extends Controller {
$data['margin_bottom']['value'] = $this->input->post('margin_bottom', TRUE);
$data['margin_left']['value'] = $this->input->post('margin_left', TRUE);
$data['margin_right']['value'] = $this->input->post('margin_right', TRUE);
- $data['page_layout']['value'] = $this->input->post('page_layout', TRUE);
- $data['logo']['value'] = $this->input->post('logo', TRUE);
$data['orientation'] = $this->input->post('orientation', TRUE);
if ($data['orientation'] == "P")
@@ -762,8 +742,6 @@ class Setting extends Controller {
$data_margin_bottom = $this->input->post('margin_bottom', TRUE);
$data_margin_left = $this->input->post('margin_left', TRUE);
$data_margin_right = $this->input->post('margin_right', TRUE);
- $data_page_layout = $this->input->post('page_layout', TRUE);
- $data_logo = $this->input->post('logo', TRUE);
if ($this->input->post('orientation', TRUE) == "P")
{
@@ -780,7 +758,7 @@ 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 = ?, print_page_layout = ?, print_logo = ? 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, $data_page_layout, $data_logo)))
+ 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)))
{
$this->db->trans_rollback();
$this->messages->add('Error updating printer settings.', 'error');
diff --git a/system/application/views/setting/printer.php b/system/application/views/setting/printer.php
index 8d9b748..f85ab90 100644
--- a/system/application/views/setting/printer.php
+++ b/system/application/views/setting/printer.php
@@ -85,23 +85,6 @@
echo form_fieldset_close();
echo "</p>";
-
- echo "<p>";
- echo form_label('Page Layout', 'page_layout');
- echo "<br />";
- echo form_textarea($page_layout);
- echo "<br />";
- echo "<span class=\"form-help-text\">HTML Markup</span>";
- echo "</p>";
-
- echo "<p>";
- echo form_label('Logo Path', 'logo');
- echo "<br />";
- echo form_input($logo);
- echo "<br />";
- echo "<span class=\"form-help-text\">Path to Logo file</span>";
- echo "</p>";
-
echo "<p>";
echo form_submit('submit', 'Update');
echo " ";
commit fe0ff45a397a56c535d2a44b88fbf2d7e3b37072
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Dec 29 22:10:20 2010 +0530
Added Status message when everything is configured correctly
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/views/admin/status.php b/system/application/views/admin/status.php
index f40be1d..0ad7d82 100644
--- a/system/application/views/admin/status.php
+++ b/system/application/views/admin/status.php
@@ -11,6 +11,13 @@
}
echo "</ul>";
echo "</div>";
+ } else {
+ echo "<div id=\"success-box\">";
+ echo "<ul>";
+ echo "<li>Everything is configured correctly.</li>";
+ echo "</ul>";
+ echo "</div>";
+
}
}
commit 2f527c4a95cd72fe7f7594b61ba5562f3a7e416d
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Dec 29 19:32:05 2010 +0530
Refactored database schema files
- Combined account creation and carry forward into same database schema
- Seperated the account group and ledger initial data
- Return from creation or carry forward script on error
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/admin/carryforward.sql b/system/application/controllers/admin/carryforward.sql
deleted file mode 100644
index d7b5037..0000000
--- a/system/application/controllers/admin/carryforward.sql
+++ /dev/null
@@ -1,93 +0,0 @@
-CREATE TABLE IF NOT EXISTS groups (
- id int(11) NOT NULL AUTO_INCREMENT,
- parent_id int(11) NOT NULL,
- name varchar(100) NOT NULL,
- affects_gross int(1) NOT NULL DEFAULT '0',
- PRIMARY KEY (id)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
-
-CREATE TABLE IF NOT EXISTS ledgers (
- id int(11) NOT NULL AUTO_INCREMENT,
- group_id int(11) NOT NULL,
- name varchar(100) NOT NULL,
- op_balance decimal(15,2) NOT NULL DEFAULT '0.00',
- op_balance_dc char(1) NOT NULL,
- type char(1) NOT NULL,
- PRIMARY KEY (id)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=1;
-
-CREATE TABLE IF NOT EXISTS settings (
- id int(1) NOT NULL,
- name varchar(100) NOT NULL,
- address varchar(255) NOT NULL,
- email varchar(100) NOT NULL,
- fy_start datetime NOT NULL,
- fy_end datetime NOT NULL,
- currency_symbol varchar(10) NOT NULL,
- date_format varchar(30) NOT NULL,
- timezone varchar(255) NOT NULL,
- email_protocol varchar(9) NOT NULL,
- email_host varchar(255) NOT NULL,
- email_port int(5) NOT NULL,
- email_username varchar(255) NOT NULL,
- email_password varchar(255) NOT NULL,
- print_paper_height float NOT NULL,
- print_paper_width float NOT NULL,
- print_margin_top float NOT NULL,
- print_margin_bottom float NOT NULL,
- print_margin_left float NOT NULL,
- print_margin_right float NOT NULL,
- print_orientation varchar(1) NOT NULL,
- print_page_format varchar(1) NOT NULL,
- print_page_layout text NOT NULL,
- print_logo varchar(255) NOT NULL,
- receipt_voucher_prefix varchar(10) NOT NULL,
- payment_voucher_prefix varchar(10) NOT NULL,
- contra_voucher_prefix varchar(10) NOT NULL,
- journal_voucher_prefix varchar(10) NOT NULL,
- voucher_number_padding int(5) NOT NULL,
- database_version int(10) NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
-
-CREATE TABLE IF NOT EXISTS vouchers (
- id int(11) NOT NULL AUTO_INCREMENT,
- tag_id int(11) NOT NULL DEFAULT '0',
- number int(11) NOT NULL,
- date datetime NOT NULL,
- 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;
-
-CREATE TABLE IF NOT EXISTS voucher_items (
- id int(11) NOT NULL AUTO_INCREMENT,
- voucher_id int(11) NOT NULL,
- ledger_id int(11) NOT NULL,
- amount decimal(15,2) NOT NULL DEFAULT '0.00',
- dc char(1) NOT NULL,
- PRIMARY KEY (id)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
-
-CREATE TABLE IF NOT EXISTS tags (
- id int(11) NOT NULL AUTO_INCREMENT,
- title varchar(50) NOT NULL,
- color varchar(6) NOT NULL,
- background varchar(6) NOT NULL,
- PRIMARY KEY (id)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
-
-CREATE TABLE IF NOT EXISTS logs (
- id int(11) NOT NULL AUTO_INCREMENT,
- date datetime NOT NULL,
- level int(1) NOT NULL,
- host_ip varchar(25) NOT NULL,
- user varchar(25) NOT NULL,
- url varchar(255) NOT NULL,
- user_agent varchar(100) NOT NULL,
- message_title varchar(255) NOT NULL,
- message_desc mediumtext NOT NULL,
- PRIMARY KEY (id)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
diff --git a/system/application/controllers/admin/create.php b/system/application/controllers/admin/create.php
index 5fc5d05..ebd9a36 100644
--- a/system/application/controllers/admin/create.php
+++ b/system/application/controllers/admin/create.php
@@ -234,7 +234,7 @@ class Create extends Controller {
{
if ($newacc->query("CREATE DATABASE " . mysql_real_escape_string($data_database_name)))
{
- $this->messages->add('New account database created.', 'success');
+ $this->messages->add('Created account database.', 'success');
/* Retrying to connect to new database */
$newacc = $this->load->database($dsn, TRUE);
$conn_error = $newacc->_error_message();
@@ -261,7 +261,7 @@ class Create extends Controller {
return;
} else {
/* Executing the database setup script */
- $setup_account = read_file('system/application/controllers/admin/database.sql');
+ $setup_account = read_file('system/application/controllers/admin/schema.sql');
$setup_account_array = explode(";", $setup_account);
foreach($setup_account_array as $row)
{
@@ -269,14 +269,46 @@ class Create extends Controller {
continue;
$newacc->query($row);
if ($newacc->_error_message() != "")
- $this->messages->add($newacc->_error_message(), 'error');
+ {
+ $this->messages->add('Error initializing account database.', 'error');
+ $this->template->load('admin_template', 'admin/create', $data);
+ return;
+ }
}
+ $this->messages->add('Initialized account database.', 'success');
- $this->messages->add('Created account database.', 'success');
+ /* Initial account setup */
+ $setup_initial_data = read_file('system/application/controllers/admin/initialize.sql');
+ $setup_initial_data_array = explode(";", $setup_initial_data);
+ $newacc->trans_start();
+ foreach($setup_initial_data_array as $row)
+ {
+ if (strlen($row) < 5)
+ continue;
+ $newacc->query($row); var_dump($newacc->_error_message());
+ if ($newacc->_error_message() != "")
+ {
+ $newacc->trans_rollback();
+ $this->messages->add('Error initializing basic accounts data.', 'error');
+ $this->template->load('admin_template', 'admin/create', $data);
+ return;
+ }
+ }
+ $newacc->trans_complete();
+ $this->messages->add('Initialized basic accounts data.', 'success');
- /* Adding the account settings */
- $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));
- $this->messages->add('Added account information.', 'success');
+ /* 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)))
+ {
+ $newacc->trans_rollback();
+ $this->messages->add('Error adding account settings.', 'error');
+ $this->template->load('admin_template', 'admin/create', $data);
+ return;
+ } else {
+ $newacc->trans_complete();
+ $this->messages->add('Added account settings.', 'success');
+ }
/* Adding account settings to file. Code copied from manage controller */
$con_details = "[database]" . "\r\n" . "db_hostname = \"" . $data_database_host . "\"" . "\r\n" . "db_port = \"" . $data_database_port . "\"" . "\r\n" . "db_name = \"" . $data_database_name . "\"" . "\r\n" . "db_username = \"" . $data_database_username . "\"" . "\r\n" . "db_password = \"" . $data_database_password . "\"" . "\r\n";
diff --git a/system/application/controllers/admin/database.sql b/system/application/controllers/admin/database.sql
deleted file mode 100644
index ffdf48f..0000000
--- a/system/application/controllers/admin/database.sql
+++ /dev/null
@@ -1,110 +0,0 @@
-CREATE TABLE IF NOT EXISTS groups (
- id int(11) NOT NULL AUTO_INCREMENT,
- parent_id int(11) NOT NULL,
- name varchar(100) NOT NULL,
- affects_gross int(1) NOT NULL DEFAULT '0',
- PRIMARY KEY (id)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
-
-CREATE TABLE IF NOT EXISTS ledgers (
- id int(11) NOT NULL AUTO_INCREMENT,
- group_id int(11) NOT NULL,
- name varchar(100) NOT NULL,
- op_balance decimal(15,2) NOT NULL DEFAULT '0.00',
- op_balance_dc char(1) NOT NULL,
- type char(1) NOT NULL,
- PRIMARY KEY (id)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=1;
-
-CREATE TABLE IF NOT EXISTS settings (
- id int(1) NOT NULL,
- name varchar(100) NOT NULL,
- address varchar(255) NOT NULL,
- email varchar(100) NOT NULL,
- fy_start datetime NOT NULL,
- fy_end datetime NOT NULL,
- currency_symbol varchar(10) NOT NULL,
- date_format varchar(30) NOT NULL,
- timezone varchar(255) NOT NULL,
- email_protocol varchar(9) NOT NULL,
- email_host varchar(255) NOT NULL,
- email_port int(5) NOT NULL,
- email_username varchar(255) NOT NULL,
- email_password varchar(255) NOT NULL,
- print_paper_height float NOT NULL,
- print_paper_width float NOT NULL,
- print_margin_top float NOT NULL,
- print_margin_bottom float NOT NULL,
- print_margin_left float NOT NULL,
- print_margin_right float NOT NULL,
- print_orientation varchar(1) NOT NULL,
- print_page_format varchar(1) NOT NULL,
- print_page_layout text NOT NULL,
- print_logo varchar(255) NOT NULL,
- receipt_voucher_prefix varchar(10) NOT NULL,
- payment_voucher_prefix varchar(10) NOT NULL,
- contra_voucher_prefix varchar(10) NOT NULL,
- journal_voucher_prefix varchar(10) NOT NULL,
- voucher_number_padding int(5) NOT NULL,
- database_version int(10) NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
-
-CREATE TABLE IF NOT EXISTS vouchers (
- id int(11) NOT NULL AUTO_INCREMENT,
- tag_id int(11) NOT NULL DEFAULT '0',
- number int(11) NOT NULL,
- date datetime NOT NULL,
- 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;
-
-CREATE TABLE IF NOT EXISTS voucher_items (
- id int(11) NOT NULL AUTO_INCREMENT,
- voucher_id int(11) NOT NULL,
- ledger_id int(11) NOT NULL,
- amount decimal(15,2) NOT NULL DEFAULT '0.00',
- dc char(1) NOT NULL,
- PRIMARY KEY (id)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
-
-CREATE TABLE IF NOT EXISTS tags (
- id int(11) NOT NULL AUTO_INCREMENT,
- title varchar(50) NOT NULL,
- color varchar(6) NOT NULL,
- background varchar(6) NOT NULL,
- PRIMARY KEY (id)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
-
-CREATE TABLE IF NOT EXISTS logs (
- id int(11) NOT NULL AUTO_INCREMENT,
- date datetime NOT NULL,
- level int(1) NOT NULL,
- host_ip varchar(25) NOT NULL,
- user varchar(25) NOT NULL,
- url varchar(255) NOT NULL,
- user_agent varchar(100) NOT NULL,
- message_title varchar(255) NOT NULL,
- message_desc mediumtext NOT NULL,
- PRIMARY KEY (id)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
-
-INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (1, 0, 'Assets', 0);
-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 (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);
-INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (10, 2, 'Loans (Liability)', 0);
-INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (11, 3, 'Direct Incomes', 1);
-INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (12, 4, 'Direct Expenses', 1);
-INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (13, 3, 'Indirect Incomes', 0);
-INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (14, 4, 'Indirect Expenses', 0);
-INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (15, 3, 'Sales', 1);
-INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (16, 4, 'Purchases', 1);
diff --git a/system/application/controllers/admin/initialize.sql b/system/application/controllers/admin/initialize.sql
new file mode 100644
index 0000000..3cfce90
--- /dev/null
+++ b/system/application/controllers/admin/initialize.sql
@@ -0,0 +1,16 @@
+INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (1, 0, 'Assets', 0);
+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 (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);
+INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (10, 2, 'Loans (Liability)', 0);
+INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (11, 3, 'Direct Incomes', 1);
+INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (12, 4, 'Direct Expenses', 1);
+INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (13, 3, 'Indirect Incomes', 0);
+INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (14, 4, 'Indirect Expenses', 0);
+INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (15, 3, 'Sales', 1);
+INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (16, 4, 'Purchases', 1);
diff --git a/system/application/controllers/admin/schema.sql b/system/application/controllers/admin/schema.sql
new file mode 100644
index 0000000..d7b5037
--- /dev/null
+++ b/system/application/controllers/admin/schema.sql
@@ -0,0 +1,93 @@
+CREATE TABLE IF NOT EXISTS groups (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ parent_id int(11) NOT NULL,
+ name varchar(100) NOT NULL,
+ affects_gross int(1) NOT NULL DEFAULT '0',
+ PRIMARY KEY (id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
+
+CREATE TABLE IF NOT EXISTS ledgers (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ group_id int(11) NOT NULL,
+ name varchar(100) NOT NULL,
+ op_balance decimal(15,2) NOT NULL DEFAULT '0.00',
+ op_balance_dc char(1) NOT NULL,
+ type char(1) NOT NULL,
+ PRIMARY KEY (id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=1;
+
+CREATE TABLE IF NOT EXISTS settings (
+ id int(1) NOT NULL,
+ name varchar(100) NOT NULL,
+ address varchar(255) NOT NULL,
+ email varchar(100) NOT NULL,
+ fy_start datetime NOT NULL,
+ fy_end datetime NOT NULL,
+ currency_symbol varchar(10) NOT NULL,
+ date_format varchar(30) NOT NULL,
+ timezone varchar(255) NOT NULL,
+ email_protocol varchar(9) NOT NULL,
+ email_host varchar(255) NOT NULL,
+ email_port int(5) NOT NULL,
+ email_username varchar(255) NOT NULL,
+ email_password varchar(255) NOT NULL,
+ print_paper_height float NOT NULL,
+ print_paper_width float NOT NULL,
+ print_margin_top float NOT NULL,
+ print_margin_bottom float NOT NULL,
+ print_margin_left float NOT NULL,
+ print_margin_right float NOT NULL,
+ print_orientation varchar(1) NOT NULL,
+ print_page_format varchar(1) NOT NULL,
+ print_page_layout text NOT NULL,
+ print_logo varchar(255) NOT NULL,
+ receipt_voucher_prefix varchar(10) NOT NULL,
+ payment_voucher_prefix varchar(10) NOT NULL,
+ contra_voucher_prefix varchar(10) NOT NULL,
+ journal_voucher_prefix varchar(10) NOT NULL,
+ voucher_number_padding int(5) NOT NULL,
+ database_version int(10) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
+
+CREATE TABLE IF NOT EXISTS vouchers (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ tag_id int(11) NOT NULL DEFAULT '0',
+ number int(11) NOT NULL,
+ date datetime NOT NULL,
+ 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;
+
+CREATE TABLE IF NOT EXISTS voucher_items (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ voucher_id int(11) NOT NULL,
+ ledger_id int(11) NOT NULL,
+ amount decimal(15,2) NOT NULL DEFAULT '0.00',
+ dc char(1) NOT NULL,
+ PRIMARY KEY (id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
+
+CREATE TABLE IF NOT EXISTS tags (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ title varchar(50) NOT NULL,
+ color varchar(6) NOT NULL,
+ background varchar(6) NOT NULL,
+ PRIMARY KEY (id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
+
+CREATE TABLE IF NOT EXISTS logs (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ date datetime NOT NULL,
+ level int(1) NOT NULL,
+ host_ip varchar(25) NOT NULL,
+ user varchar(25) NOT NULL,
+ url varchar(255) NOT NULL,
+ user_agent varchar(100) NOT NULL,
+ message_title varchar(255) NOT NULL,
+ message_desc mediumtext NOT NULL,
+ PRIMARY KEY (id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
diff --git a/system/application/controllers/setting.php b/system/application/controllers/setting.php
index 30b9e71..72e2adc 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -334,12 +334,12 @@ class Setting extends Controller {
{
if ($newacc->query("CREATE DATABASE " . mysql_real_escape_string($data_database_name)))
{
- $this->messages->add('New account database created.', 'success');
+ $this->messages->add('Created account database.', 'success');
/* Retrying to connect to new database */
$newacc = $this->load->database($dsn, TRUE);
$conn_error = $newacc->_error_message();
} else {
- $this->messages->add('Cannot create account database.', 'error');
+ $this->messages->add('Failed to create account database.', 'error');
$this->template->load('template', 'setting/cf', $data);
return;
}
@@ -361,7 +361,7 @@ class Setting extends Controller {
return;
} else {
/* Executing the database setup script */
- $setup_account = read_file('system/application/controllers/admin/carryforward.sql');
+ $setup_account = read_file('system/application/controllers/admin/schema.sql');
$setup_account_array = explode(";", $setup_account);
foreach($setup_account_array as $row)
{
@@ -369,19 +369,26 @@ class Setting extends Controller {
continue;
$newacc->query($row);
if ($newacc->_error_message() != "")
- $this->messages->add($newacc->_error_message(), 'error');
+ {
+ $this->messages->add('Error initializing account database.', 'error');
+ $this->template->load('template', 'setting/cf', $data);
+ return;
+ }
}
+ $this->messages->add('Initialized account database.', 'success');
- $this->messages->add('Created account database.', 'success');
-
- /* Adding the account settings */
- $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));
- $this->messages->add('Added account information.', 'success');
-
- /* Adding account settings to file. Code copied from manage controller */
- $con_details = "[database]" . "\r\n" . "db_hostname = \"" . $data_database_host . "\"" . "\r\n" . "db_port = \"" . $data_database_port . "\"" . "\r\n" . "db_name = \"" . $data_database_name . "\"" . "\r\n" . "db_username = \"" . $data_database_username . "\"" . "\r\n" . "db_password = \"" . $data_database_password . "\"" . "\r\n";
-
- $con_details_html = '[database]<br />db_hostname = "' . $data_database_host . '"<br />db_port = "' . $data_database_port . '"<br />db_name = "' . $data_database_name . '"<br />db_username = "' . $data_database_username . '"<br />db_password = "' . $data_database_password . '"<br />';
+ /* 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)))
+ {
+ $newacc->trans_rollback();
+ $this->messages->add('Error adding account settings.', 'error');
+ $this->template->load('template', 'setting/cf', $data);
+ return;
+ } else {
+ $newacc->trans_complete();
+ $this->messages->add('Added account settings.', 'success');
+ }
/**************** Importing the C/F Values : START ***************/
@@ -451,6 +458,12 @@ class Setting extends Controller {
else
$this->messages->add('Error carrying forward to new account.', 'error');
+
+ /* Adding account settings to file. Code copied from manage controller */
+ $con_details = "[database]" . "\r\n" . "db_hostname = \"" . $data_database_host . "\"" . "\r\n" . "db_port = \"" . $data_database_port . "\"" . "\r\n" . "db_name = \"" . $data_database_name . "\"" . "\r\n" . "db_username = \"" . $data_database_username . "\"" . "\r\n" . "db_password = \"" . $data_database_password . "\"" . "\r\n";
+
+ $con_details_html = '[database]<br />db_hostname = "' . $data_database_host . '"<br />db_port = "' . $data_database_port . '"<br />db_name = "' . $data_database_name . '"<br />db_username = "' . $data_database_username . '"<br />db_password = "' . $data_database_password . '"<br />';
+
/* Writing the connection string to end of file - writing in 'a' append mode */
if ( ! write_file($ini_file, $con_details))
{
commit 8c9ba946d527c765b2f4e1326e3e491a35fd5e91
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Dec 28 12:08:50 2010 +0530
Check for valid Ledger A/C Type
- Receipt Vouchers must debit atleast one Bank or Cash Ledger A/C
- Payment Vouchers must credit atleast one Bank or Cash Ledger A/C
- Contra Vouchers can only have Bank or Cash Ledger A/C's
- Journal Vouchers can only have non Bank or Cash Ledger A/C's
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 38b8cd5..4752758 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -349,24 +349,58 @@ class Voucher extends Controller {
}
else
{
- /* Checking for Debit and Credit Total */
+ /* Checking for Valid Ledgers A/C and Debit and Credit Total */
$data_all_ledger_id = $this->input->post('ledger_id', TRUE);
$data_all_ledger_dc = $this->input->post('ledger_dc', TRUE);
$data_all_dr_amount = $this->input->post('dr_amount', TRUE);
$data_all_cr_amount = $this->input->post('cr_amount', TRUE);
$dr_total = 0;
$cr_total = 0;
+ $bank_cash_present = FALSE; /* Whether atleast one Ledger A/C is Bank or Cash A/C */
foreach ($data_all_ledger_dc as $id => $ledger_data)
{
if ($data_all_ledger_id[$id] < 1)
continue;
/* Check for valid ledger id */
- if ($this->db->query("SELECT id FROM ledgers WHERE id = ?", array($data_all_ledger_id[$id]))->num_rows() < 1)
+ $valid_ledger_q = $this->db->query("SELECT id, type FROM ledgers WHERE id = ?", array($data_all_ledger_id[$id]));
+ if ($valid_ledger_q->num_rows() < 1)
{
$this->messages->add('Invalid Ledger A/C.', 'error');
$this->template->load('template', 'voucher/add', $data);
return;
+ } else {
+ /* Check for valid ledger type */
+ $valid_ledger = $valid_ledger_q->row();
+ if ($voucher_type == 'receipt')
+ {
+ if ($data_all_ledger_dc[$id] == 'D' && $valid_ledger->type == 'B')
+ {
+ $bank_cash_present = TRUE;
+ }
+ } else if ($voucher_type == 'payment')
+ {
+ if ($data_all_ledger_dc[$id] == 'C' && $valid_ledger->type == 'B')
+ {
+ $bank_cash_present = TRUE;
+ }
+ } else if ($voucher_type == 'contra')
+ {
+ if ($valid_ledger->type != 'B')
+ {
+ $this->messages->add('Invalid Ledger A/C. Contra Vouchers can have only Bank and Cash Ledgers A/C\'s.', 'error');
+ $this->template->load('template', 'voucher/add', $data);
+ return;
+ }
+ } else if ($voucher_type == 'journal')
+ {
+ if ($valid_ledger->type == 'B')
+ {
+ $this->messages->add('Invalid Ledger A/C. Journal Vouchers cannot have Bank and Cash Ledgers A/C\'s.', 'error');
+ $this->template->load('template', 'voucher/add', $data);
+ return;
+ }
+ }
}
if ($data_all_ledger_dc[$id] == "D")
@@ -386,6 +420,24 @@ class Voucher extends Controller {
$this->template->load('template', 'voucher/add', $data);
return;
}
+ /* Check if atleast one Bank or Cash Ledger A/C is present */
+ if ($voucher_type == 'receipt')
+ {
+ if ( ! $bank_cash_present)
+ {
+ $this->messages->add('Need to Debit atleast one Bank or Cash A/C', 'error');
+ $this->template->load('template', 'voucher/add', $data);
+ return;
+ }
+ } else if ($voucher_type == 'payment')
+ {
+ if ( ! $bank_cash_present)
+ {
+ $this->messages->add('Need to Credit atleast one Bank or Cash A/C', 'error');
+ $this->template->load('template', 'voucher/add', $data);
+ return;
+ }
+ }
/* Adding main voucher */
$data_number = $this->input->post('voucher_number', TRUE);
@@ -641,26 +693,59 @@ class Voucher extends Controller {
$this->messages->add(validation_errors(), 'error');
$this->template->load('template', 'voucher/edit', $data);
} else {
- /* Checking for Debit and Credit Total */
+ /* Checking for Valid Ledgers A/C and Debit and Credit Total */
$data_all_ledger_id = $this->input->post('ledger_id', TRUE);
$data_all_ledger_dc = $this->input->post('ledger_dc', TRUE);
$data_all_dr_amount = $this->input->post('dr_amount', TRUE);
$data_all_cr_amount = $this->input->post('cr_amount', TRUE);
$dr_total = 0;
$cr_total = 0;
+ $bank_cash_present = FALSE; /* Whether atleast one Ledger A/C is Bank or Cash A/C */
foreach ($data_all_ledger_dc as $id => $ledger_data)
{
if ($data_all_ledger_id[$id] < 1)
continue;
/* Check for valid ledger id */
- if ($this->db->query("SELECT id FROM ledgers WHERE id = ?", array($data_all_ledger_id[$id]))->num_rows() < 1)
+ $valid_ledger_q = $this->db->query("SELECT id, type FROM ledgers WHERE id = ?", array($data_all_ledger_id[$id]));
+ if ($valid_ledger_q->num_rows() < 1)
{
$this->messages->add('Invalid Ledger A/C.', 'error');
$this->template->load('template', 'voucher/edit', $data);
return;
+ } else {
+ /* Check for valid ledger type */
+ $valid_ledger = $valid_ledger_q->row();
+ if ($voucher_type == 'receipt')
+ {
+ if ($data_all_ledger_dc[$id] == 'D' && $valid_ledger->type == 'B')
+ {
+ $bank_cash_present = TRUE;
+ }
+ } else if ($voucher_type == 'payment')
+ {
+ if ($data_all_ledger_dc[$id] == 'C' && $valid_ledger->type == 'B')
+ {
+ $bank_cash_present = TRUE;
+ }
+ } else if ($voucher_type == 'contra')
+ {
+ if ($valid_ledger->type != 'B')
+ {
+ $this->messages->add('Invalid Ledger A/C. Contra Vouchers can have only Bank and Cash Ledgers A/C\'s.', 'error');
+ $this->template->load('template', 'voucher/edit', $data);
+ return;
+ }
+ } else if ($voucher_type == 'journal')
+ {
+ if ($valid_ledger->type == 'B')
+ {
+ $this->messages->add('Invalid Ledger A/C. Journal Vouchers cannot have Bank and Cash Ledgers A/C\'s.', 'error');
+ $this->template->load('template', 'voucher/edit', $data);
+ return;
+ }
+ }
}
-
if ($data_all_ledger_dc[$id] == "D")
{
$dr_total += $data_all_dr_amount[$id];
@@ -678,6 +763,24 @@ class Voucher extends Controller {
$this->template->load('template', 'voucher/edit', $data);
return;
}
+ /* Check if atleast one Bank or Cash Ledger A/C is present */
+ if ($voucher_type == 'receipt')
+ {
+ if ( ! $bank_cash_present)
+ {
+ $this->messages->add('Need to Debit atleast one Bank or Cash A/C', 'error');
+ $this->template->load('template', 'voucher/edit', $data);
+ return;
+ }
+ } else if ($voucher_type == 'payment')
+ {
+ if ( ! $bank_cash_present)
+ {
+ $this->messages->add('Need to Credit atleast one Bank or Cash A/C', 'error');
+ $this->template->load('template', 'voucher/edit', $data);
+ return;
+ }
+ }
/* Updating main voucher */
$data_number = $this->input->post('voucher_number', TRUE);
commit d3b97699e7196e08746bbe2bf73d1b97915a5188
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Dec 28 11:36:16 2010 +0530
Show only valid ledger selection
- For contra vouchers only show bank and cash ledgers
- For journal vocuhers only show non bank and cash ledgers
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 47e38d2..38b8cd5 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -1040,7 +1040,7 @@ class Voucher extends Controller {
return;
}
- function addrow()
+ function addrow($add_type = 'all')
{
$i = time() + rand (0, time()) + rand (0, time()) + rand (0, time());
$dr_amount = array(
@@ -1066,9 +1066,16 @@ class Voucher extends Controller {
echo '<td>';
echo form_dropdown_dc('ledger_dc[' . $i . ']');
echo '</td>';
+
echo '<td>';
- echo form_input_ledger('ledger_id[' . $i . ']');
+ if ($add_type == 'bankcash')
+ echo form_input_ledger('ledger_id[' . $i . ']', 0, '', $type = 'bankcash');
+ else if ($add_type == 'nobankcash')
+ echo form_input_ledger('ledger_id[' . $i . ']', 0, '', $type = 'nobankcash');
+ else
+ echo form_input_ledger('ledger_id[' . $i . ']');
echo '</td>';
+
echo '<td>';
echo form_input($dr_amount);
echo '</td>';
diff --git a/system/application/helpers/MY_form_helper.php b/system/application/helpers/MY_form_helper.php
index e3a7dc7..06f7c39 100644
--- a/system/application/helpers/MY_form_helper.php
+++ b/system/application/helpers/MY_form_helper.php
@@ -55,11 +55,17 @@ if ( ! function_exists('form_input_date_restrict'))
if ( ! function_exists('form_input_ledger'))
{
- function form_input_ledger($name, $selected = NULL, $extra = '')
+ function form_input_ledger($name, $selected = NULL, $extra = '', $type = 'all')
{
$CI =& get_instance();
$CI->load->model('Ledger_model');
- $options = $CI->Ledger_model->get_all_ledgers();
+
+ if ($type == 'bankcash')
+ $options = $CI->Ledger_model->get_all_ledgers_bankcash();
+ else if ($type == 'nobankcash')
+ $options = $CI->Ledger_model->get_all_ledgers_nobankcash();
+ else
+ $options = $CI->Ledger_model->get_all_ledgers();
// If no selected state was submitted we will attempt to set it automatically
if ( ! ($selected))
diff --git a/system/application/models/ledger_model.php b/system/application/models/ledger_model.php
index 465eef2..82075a8 100644
--- a/system/application/models/ledger_model.php
+++ b/system/application/models/ledger_model.php
@@ -19,6 +19,30 @@ class Ledger_model extends Model {
return $options;
}
+ function get_all_ledgers_bankcash()
+ {
+ $options = array();
+ $options[0] = "(Please Select)";
+ $ledger_q = $this->db->query('SELECT * FROM ledgers WHERE type = ? ORDER BY name ASC', array('B'));
+ foreach ($ledger_q->result() as $row)
+ {
+ $options[$row->id] = $row->name;
+ }
+ return $options;
+ }
+
+ function get_all_ledgers_nobankcash()
+ {
+ $options = array();
+ $options[0] = "(Please Select)";
+ $ledger_q = $this->db->query('SELECT * FROM ledgers WHERE type != ? ORDER BY name ASC', array('B'));
+ foreach ($ledger_q->result() as $row)
+ {
+ $options[$row->id] = $row->name;
+ }
+ return $options;
+ }
+
function get_name($ledger_id)
{
$ledger_q = $this->db->query('SELECT name FROM ledgers WHERE id = ? LIMIT 1', array($ledger_id));
diff --git a/system/application/views/voucher/add.php b/system/application/views/voucher/add.php
index b94aeec..78e0f32 100644
--- a/system/application/views/voucher/add.php
+++ b/system/application/views/voucher/add.php
@@ -1,3 +1,11 @@
+<?php
+ if ($voucher_type == "contra")
+ $add_type = "bankcash";
+ else if ($voucher_type == "journal")
+ $add_type = "nobankcash";
+ else
+ $add_type = "all";
+?>
<script type="text/javascript">
$(document).ready(function() {
@@ -166,7 +174,7 @@ $(document).ready(function() {
$('table td .addrow').live('click', function() {
var cur_obj = this;
$.ajax({
- url: <?php echo '\'' . site_url('voucher/addrow') . '\''; ?>,
+ url: <?php echo '\'' . site_url('voucher/addrow/' . $add_type) . '\''; ?>,
success: function(data) {
$(cur_obj).parent().parent().after(data);
}
@@ -222,7 +230,13 @@ $(document).ready(function() {
echo "<td>" . form_dropdown_dc('ledger_dc[' . $i . ']', isset($ledger_dc[$i]) ? $ledger_dc[$i] : "D") . "</td>";
- echo "<td>" . form_input_ledger('ledger_id[' . $i . ']', isset($ledger_id[$i]) ? $ledger_id[$i] : 0) . "</td>";
+ if ($voucher_type == "contra")
+ echo "<td>" . form_input_ledger('ledger_id[' . $i . ']', isset($ledger_id[$i]) ? $ledger_id[$i] : 0, '', $type = 'bankcash') . "</td>";
+ else if ($voucher_type == "journal")
+ echo "<td>" . form_input_ledger('ledger_id[' . $i . ']', isset($ledger_id[$i]) ? $ledger_id[$i] : 0, '', $type = 'nobankcash') . "</td>";
+ else
+ echo "<td>" . form_input_ledger('ledger_id[' . $i . ']', isset($ledger_id[$i]) ? $ledger_id[$i] : 0) . "</td>";
+
echo "<td>" . form_input($dr_amount_item) . "</td>";
echo "<td>" . form_input($cr_amount_item) . "</td>";
diff --git a/system/application/views/voucher/edit.php b/system/application/views/voucher/edit.php
index caea58a..bbef785 100644
--- a/system/application/views/voucher/edit.php
+++ b/system/application/views/voucher/edit.php
@@ -1,3 +1,11 @@
+<?php
+ if ($voucher_type == "contra")
+ $add_type = "bankcash";
+ else if ($voucher_type == "journal")
+ $add_type = "nobankcash";
+ else
+ $add_type = "all";
+?>
<script type="text/javascript">
$(document).ready(function() {
@@ -166,7 +174,7 @@ $(document).ready(function() {
$('table td .addrow').live('click', function() {
var cur_obj = this;
$.ajax({
- url: <?php echo '\'' . site_url('voucher/addrow') . '\''; ?>,
+ url: <?php echo '\'' . site_url('voucher/addrow/' . $add_type) . '\''; ?>,
success: function(data) {
$(cur_obj).parent().parent().after(data);
}
@@ -222,7 +230,13 @@ $(document).ready(function() {
echo "<td>" . form_dropdown_dc('ledger_dc[' . $i . ']', isset($ledger_dc[$i]) ? $ledger_dc[$i] : "D") . "</td>";
- echo "<td>" . form_input_ledger('ledger_id[' . $i . ']', isset($ledger_id[$i]) ? $ledger_id[$i] : 0) . "</td>";
+ if ($voucher_type == "contra")
+ echo "<td>" . form_input_ledger('ledger_id[' . $i . ']', isset($ledger_id[$i]) ? $ledger_id[$i] : 0, '', $type = 'bankcash') . "</td>";
+ else if ($voucher_type == "journal")
+ echo "<td>" . form_input_ledger('ledger_id[' . $i . ']', isset($ledger_id[$i]) ? $ledger_id[$i] : 0, '', $type = 'nobankcash') . "</td>";
+ else
+ echo "<td>" . form_input_ledger('ledger_id[' . $i . ']', isset($ledger_id[$i]) ? $ledger_id[$i] : 0) . "</td>";
+
echo "<td>" . form_input($dr_amount_item) . "</td>";
echo "<td>" . form_input($cr_amount_item) . "</td>";
commit 2844b2ecc4d6a78f42757bfcff9602802b4161aa
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Dec 27 21:50:37 2010 +0530
Showing the Print Email and Download Window
- Showing popups for Print, Email and Download Vouchers
after new and edit voucher using javascript
- Using sessions to store the checkbox values
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 0909067..47e38d2 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -290,7 +290,7 @@ class Voucher extends Controller {
$data['voucher_draft'] = FALSE;
$data['voucher_print'] = FALSE;
$data['voucher_email'] = FALSE;
- $data['voucher_pdf'] = FALSE;
+ $data['voucher_download'] = FALSE;
$data['voucher_tags'] = $this->Tag_model->get_all_tags();
$data['voucher_tag'] = 0;
@@ -319,7 +319,7 @@ class Voucher extends Controller {
$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_pdf'] = $this->input->post('voucher_pdf', TRUE);
+ $data['voucher_download'] = $this->input->post('voucher_download', TRUE);
$data['voucher_tag'] = $this->input->post('voucher_tag', TRUE);
$data['ledger_dc'] = $this->input->post('ledger_dc', TRUE);
@@ -469,13 +469,33 @@ class Voucher extends Controller {
/* Success */
$this->db->trans_complete();
+ /* Check for Voucher Print, Download, Email */
+ if ($this->input->post('voucher_print', TRUE))
+ {
+ $this->session->set_userdata('print_voucher', TRUE);
+ $this->session->set_userdata('print_voucher_type', strtolower($voucher_type));
+ $this->session->set_userdata('print_voucher_id', $voucher_id);
+ }
+ if ($this->input->post('voucher_email', TRUE))
+ {
+ $this->session->set_userdata('email_voucher', TRUE);
+ $this->session->set_userdata('email_voucher_type', strtolower($voucher_type));
+ $this->session->set_userdata('email_voucher_id', $voucher_id);
+ }
+ if ($this->input->post('voucher_download', TRUE))
+ {
+ $this->session->set_userdata('download_voucher', TRUE);
+ $this->session->set_userdata('download_voucher_type', strtolower($voucher_type));
+ $this->session->set_userdata('download_voucher_id', $voucher_id);
+ }
+
/* Voucher Actions */
$voucher_success_links = "You can ";
$voucher_success_links .= anchor('voucher/view/' . strtolower($voucher_type) . "/" . $voucher_id, 'View', array('class' => 'anchor-link-a')) . " or ";
$voucher_success_links .= anchor('voucher/download/' . strtolower($voucher_type) . "/" . $voucher_id, 'Download', array('class' => 'anchor-link-a'));
$voucher_success_links .= " it.";
- $this->messages->add('Added ' . ucfirst($voucher_type) . ' Voucher number ' . voucher_number_prefix($voucher_type) . $data_number . $voucher_success_links, 'success');
+ $this->messages->add('Added ' . ucfirst($voucher_type) . ' Voucher number ' . voucher_number_prefix($voucher_type) . $data_number . ". " . $voucher_success_links, 'success');
$this->logger->write_message("success", "Added " . ucfirst($voucher_type) . " Voucher number " . voucher_number_prefix($voucher_type) . $data_number . " [id:" . $voucher_id . "]");
redirect('voucher/show/' . $voucher_type);
$this->template->load('template', 'voucher/add', $data);
@@ -542,7 +562,7 @@ class Voucher extends Controller {
$data['voucher_draft'] = ($cur_voucher->draft == 0) ? FALSE : TRUE;
$data['voucher_print'] = FALSE;
$data['voucher_email'] = FALSE;
- $data['voucher_pdf'] = FALSE;
+ $data['voucher_download'] = FALSE;
$data['voucher_tag'] = $cur_voucher->tag_id;
$data['voucher_tags'] = $this->Tag_model->get_all_tags();
@@ -607,7 +627,7 @@ class Voucher extends Controller {
$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_pdf'] = $this->input->post('voucher_pdf', TRUE);
+ $data['voucher_download'] = $this->input->post('voucher_download', TRUE);
$data['voucher_tag'] = $this->input->post('voucher_tag', TRUE);
$data['ledger_dc'] = $this->input->post('ledger_dc', TRUE);
@@ -748,13 +768,33 @@ class Voucher extends Controller {
/* Success */
$this->db->trans_complete();
+ /* Check for Voucher Print, Download, Email */
+ if ($this->input->post('voucher_print', TRUE))
+ {
+ $this->session->set_userdata('print_voucher', TRUE);
+ $this->session->set_userdata('print_voucher_type', strtolower($voucher_type));
+ $this->session->set_userdata('print_voucher_id', $voucher_id);
+ }
+ if ($this->input->post('voucher_email', TRUE))
+ {
+ $this->session->set_userdata('email_voucher', TRUE);
+ $this->session->set_userdata('email_voucher_type', strtolower($voucher_type));
+ $this->session->set_userdata('email_voucher_id', $voucher_id);
+ }
+ if ($this->input->post('voucher_download', TRUE))
+ {
+ $this->session->set_userdata('download_voucher', TRUE);
+ $this->session->set_userdata('download_voucher_type', strtolower($voucher_type));
+ $this->session->set_userdata('download_voucher_id', $voucher_id);
+ }
+
/* Voucher Actions */
$voucher_success_links = "You can ";
$voucher_success_links .= anchor('voucher/view/' . strtolower($voucher_type) . "/" . $voucher_id, 'View', array('class' => 'anchor-link-a')) . " or ";
$voucher_success_links .= anchor('voucher/download/' . strtolower($voucher_type) . "/" . $voucher_id, 'Download', array('class' => 'anchor-link-a'));
$voucher_success_links .= " it.";
- $this->messages->add('Updated ' . ucfirst($voucher_type) . ' Voucher number ' . voucher_number_prefix($voucher_type) . $data_number . $voucher_success_links, 'success');
+ $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 . "]");
redirect('voucher/show/' . $voucher_type);
return;
diff --git a/system/application/views/voucher/add.php b/system/application/views/voucher/add.php
index 3aa5fa5..b94aeec 100644
--- a/system/application/views/voucher/add.php
+++ b/system/application/views/voucher/add.php
@@ -257,7 +257,7 @@ $(document).ready(function() {
echo " ";
echo form_checkbox('voucher_email', 1, $voucher_email) . "Email";
echo " ";
- echo form_checkbox('voucher_pdf', 1, $voucher_pdf) . "Download";
+ echo form_checkbox('voucher_download', 1, $voucher_download) . "Download";
echo form_fieldset_close();
echo "</p>";
echo "<br /><br />";
diff --git a/system/application/views/voucher/edit.php b/system/application/views/voucher/edit.php
index 036086e..caea58a 100644
--- a/system/application/views/voucher/edit.php
+++ b/system/application/views/voucher/edit.php
@@ -257,7 +257,7 @@ $(document).ready(function() {
echo " ";
echo form_checkbox('voucher_email', 1, $voucher_email) . "Email";
echo " ";
- echo form_checkbox('voucher_pdf', 1, $voucher_pdf) . "Download";
+ echo form_checkbox('voucher_download', 1, $voucher_download) . "Download";
echo form_fieldset_close();
echo "</p>";
echo "<br /><br />";
diff --git a/system/application/views/voucher/index.php b/system/application/views/voucher/index.php
index 4c8496a..4fe4f7d 100644
--- a/system/application/views/voucher/index.php
+++ b/system/application/views/voucher/index.php
@@ -3,5 +3,30 @@
</div>
<?php echo $voucher_table ?>
+
+<?php
+ /* Check for Voucher Print, Download, Email */
+ if ($this->session->userdata('print_voucher'))
+ {
+ print "<script type=\"text/javascript\">$(document).ready(function() {window.open('http://localhost/webzash/index.php/voucher/printpreview/" . $this->session->userdata('print_voucher_type') . "/" . $this->session->userdata('print_voucher_id') . "', '_blank', 'width=600,height=600,scrollbars=yes,status=yes,resizable=yes,screenx=0,screeny=0'); });</script>";
+ $this->session->unset_userdata('print_voucher');
+ $this->session->unset_userdata('print_voucher_type');
+ $this->session->unset_userdata('print_voucher_id');
+ }
+ if ($this->session->userdata('email_voucher'))
+ {
+ print "<script type=\"text/javascript\">$(document).ready(function() {window.open('http://localhost/webzash/index.php/voucher/email/" . $this->session->userdata('email_voucher_type') . "/" . $this->session->userdata('email_voucher_id') . "', '_blank', 'width=500,height=300,scrollbars=yes,status=yes,resizable=yes,screenx=0,screeny=0'); });</script>";
+ $this->session->unset_userdata('email_voucher');
+ $this->session->unset_userdata('email_voucher_type');
+ $this->session->unset_userdata('email_voucher_id');
+ }
+ if ($this->session->userdata('download_voucher'))
+ {
+ print "<script type=\"text/javascript\">$(document).ready(function() {window.open('http://localhost/webzash/index.php/voucher/download/" . $this->session->userdata('download_voucher_type') . "/" . $this->session->userdata('download_voucher_id') . "', '_blank', 'width=600,height=600,scrollbars=yes,status=yes,resizable=yes,screenx=0,screeny=0'); });</script>";
+ $this->session->unset_userdata('download_voucher');
+ $this->session->unset_userdata('download_voucher_type');
+ $this->session->unset_userdata('download_voucher_id');
+ }
+?>
<div id="pagination-container"><?php echo $this->pagination->create_links(); ?></div>
commit 0de1581a0e6f845ed80170ad011355cc0be7056d
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 26 18:48:54 2010 +0530
Removed email settings from config
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 94d8b96..30b9e71 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -155,8 +155,12 @@ class Setting extends Controller {
$this->load->helper('file');
$this->load->library('accountlist');
$this->load->model('Ledger_model');
+ $this->load->model('Setting_model');
$this->template->set('page_title', 'Carry forward account');
+ /* Current settings */
+ $account_data = $this->Setting_model->get_current();
+
/* Form fields */
$last_year_end = $this->config->item('account_fy_end');
list($last_year_end_date, $last_year_end_time) = explode(' ', $last_year_end);
@@ -282,11 +286,12 @@ class Setting extends Controller {
$data_account_currency = $this->config->item('account_currency_symbol');
$data_account_date = $this->config->item('account_date_format');
$data_account_timezone = $this->config->item('account_timezone');
- $data_account_email_protocol = $this->config->item('account_email_protocol');
- $data_account_email_host = $this->config->item('account_email_host');
- $data_account_email_port = $this->config->item('account_email_port');
- $data_account_email_username = $this->config->item('account_email_username');
- $data_account_email_password = $this->config->item('account_email_password');
+
+ $data_account_email_protocol = $account_data->email_protocol;
+ $data_account_email_host = $account_data->email_host;
+ $data_account_email_port = $account_data->email_port;
+ $data_account_email_username = $account_data->email_username;
+ $data_account_email_password = $account_data->email_password;
$data_database_host = $this->input->post('database_host', TRUE);
$data_database_port = $this->input->post('database_port', TRUE);
diff --git a/system/application/controllers/voucher.php b/system/application/controllers/voucher.php
index ac56a86..0909067 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -898,7 +898,7 @@ class Voucher extends Controller {
$this->load->model('Ledger_model');
$this->load->library('email');
- $account = $this->Setting_model->get_current();
+ $account_data = $this->Setting_model->get_current();
/* Load current voucher details */
if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id, $voucher_type))
@@ -964,28 +964,34 @@ class Voucher extends Controller {
/* Preparing message */
$message = $this->load->view('voucher/emailpreview', $voucher_data, TRUE);
- /* Sending email */
- $config['protocol'] = $this->config->item('account_email_protocol');
- $config['smtp_host'] = $this->config->item('account_email_host');
- $config['smtp_port'] = $this->config->item('account_email_port');
+ /* Getting email configuration */
$config['smtp_timeout'] = '30';
- $config['smtp_user'] = $this->config->item('account_email_username');
- $config['smtp_pass'] = $this->config->item('account_email_password');
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = "html";
+ if ($account_data)
+ {
+ $config['protocol'] = $account_data->email_protocol;
+ $config['smtp_host'] = $account_data->email_host;
+ $config['smtp_port'] = $account_data->email_port;
+ $config['smtp_user'] = $account_data->email_username;
+ $config['smtp_pass'] = $account_data->email_password;
+ } else {
+ $data['error'] = 'Invalid account details.';
+ }
$this->email->initialize($config);
+ /* Sending email */
$this->email->from('', 'Webzash');
$this->email->to($this->input->post('email_to', TRUE));
$this->email->subject(ucfirst($voucher_type) . ' Voucher No. ' . voucher_number_prefix($voucher_type) . $cur_voucher->number);
$this->email->message($message);
if ($this->email->send())
{
- $data['message'] = "Successfully sent email !";
+ $data['message'] = "Email sent.";
$this->logger->write_message("success", "Emailed " . ucfirst($voucher_type) . " Voucher number " . voucher_number_prefix($voucher_type) . $cur_voucher->number . " [id:" . $voucher_id . "]");
} else {
- $data['error'] = "Error sending email. Please check you email settings";
+ $data['error'] = "Error sending email. Check you email settings.";
$this->logger->write_message("error", "Error emailing " . ucfirst($voucher_type) . " Voucher number " . voucher_number_prefix($voucher_type) . $cur_voucher->number . " [id:" . $voucher_id . "]");
}
$this->load->view('voucher/email', $data);
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index 6494597..dd5c724 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -139,11 +139,6 @@ 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_email_protocol', $account_d->email_protocol);
- $CI->config->set_item('account_email_host', $account_d->email_host);
- $CI->config->set_item('account_email_port', $account_d->email_port);
- $CI->config->set_item('account_email_username', $account_d->email_username);
- $CI->config->set_item('account_email_password', $account_d->email_password);
$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);
commit d823d479dc987f9b8d6b6f08f85d2690d12b01e2
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Dec 24 14:30:09 2010 +0530
Updated css and messages
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 9b51bd3..d93301c 100644
--- a/system/application/assets/css/admin-style.css
+++ b/system/application/assets/css/admin-style.css
@@ -115,7 +115,7 @@ body {
border:solid 1px #787878;
background:#F0F0F0;
color:#222222;
- margin:0 0 10px 0;
+ margin:10px 0 10px 0;
text-align:left;
}
@@ -123,7 +123,7 @@ body {
border:solid 1px #C34A2C;
background:#FFBABA;
color:#222222;
- margin:0 0 10px 0;
+ margin:10px 0 10px 0;
text-align:left;
}
@@ -131,7 +131,7 @@ body {
border:solid 1px #FFEC8B;
background:#FFF8C6;
color:#222222;
- margin:0 0 10px 0;
+ margin:10px 0 10px 0;
text-align:left;
}
diff --git a/system/application/assets/css/style.css b/system/application/assets/css/style.css
index 7cda02a..027492b 100644
--- a/system/application/assets/css/style.css
+++ b/system/application/assets/css/style.css
@@ -121,7 +121,7 @@ body {
border:solid 1px #787878;
background:#F0F0F0;
color:#222222;
- margin:0 0 10px 0;
+ margin:10px 0 10px 0;
text-align:left;
}
@@ -129,7 +129,7 @@ body {
border:solid 1px #C34A2C;
background:#FFBABA;
color:#222222;
- margin:0 0 10px 0;
+ margin:10px 0 10px 0;
text-align:left;
}
@@ -137,7 +137,7 @@ body {
border:solid 1px #FFEC8B;
background:#FFF8C6;
color:#222222;
- margin:0 0 10px 0;
+ margin:10px 0 10px 0;
text-align:left;
}
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index d1519d4..6494597 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -91,7 +91,7 @@ class Startup
$db_config['dbcollat'] = "utf8_general_ci";
$CI->load->database($db_config, FALSE, TRUE);
} else {
- $CI->messages->add('Please select a account.', 'error');
+ $CI->messages->add('Select a valid account.', 'error');
redirect('admin');
}
commit 4d3a5e9e8067c35e32f330e7d49326228b9c6540
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Dec 24 14:24:19 2010 +0530
Updated all messages to the same format
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/account.php b/system/application/controllers/account.php
index 309bb41..7d04008 100644
--- a/system/application/controllers/account.php
+++ b/system/application/controllers/account.php
@@ -11,9 +11,9 @@ class Account extends Controller {
$total_op = $this->Ledger_model->get_diff_op_balance();
if ($total_op > 0)
{
- $this->messages->add("Difference in Opening Balance is Dr " . convert_cur($total_op) . '.', 'error');
+ $this->messages->add('Difference in Opening Balance is Dr ' . convert_cur($total_op) . '.', 'error');
} else if ($total_op < 0) {
- $this->messages->add("Difference in Opening Balance is Cr " . convert_cur(-$total_op) . '.', 'error');
+ $this->messages->add('Difference in Opening Balance is Cr ' . convert_cur(-$total_op) . '.', 'error');
}
$this->template->load('template', 'account/index');
diff --git a/system/application/controllers/admin/active.php b/system/application/controllers/admin/active.php
index 5fdbf84..01a6267 100644
--- a/system/application/controllers/admin/active.php
+++ b/system/application/controllers/admin/active.php
@@ -69,7 +69,7 @@ class Active extends Controller {
/* Check if database ini file exists */
if ( ! get_file_info($ini_file))
{
- $this->messages->add("Account setting file is missing.", 'error');
+ $this->messages->add('Account settings file is missing.', 'error');
$this->template->load('admin_template', 'admin/active', $data);
return;
}
@@ -78,7 +78,7 @@ class Active extends Controller {
$active_accounts = parse_ini_file($ini_file);
if ( ! $active_accounts)
{
- $this->messages->add("Invalid account setting file.", 'error');
+ $this->messages->add('Invalid account settings file.', 'error');
$this->template->load('admin_template', 'admin/active', $data);
return;
}
@@ -86,38 +86,38 @@ class Active extends Controller {
/* Check if all needed variables are set in ini file */
if ( ! isset($active_accounts['db_hostname']))
{
- $this->messages->add("Hostname missing from account setting file.", 'error');
+ $this->messages->add('Hostname missing from account settings file.', 'error');
$this->template->load('admin_template', 'admin/active', $data);
return;
}
if ( ! isset($active_accounts['db_port']))
{
- $this->messages->add("Port missing from account setting file. Default MySQL port is 3306.", 'error');
+ $this->messages->add('Port missing from account settings file. Default MySQL port is 3306.', 'error');
$this->template->load('admin_template', 'admin/active', $data);
return;
}
if ( ! isset($active_accounts['db_name']))
{
- $this->messages->add("Database name missing from account setting file.", 'error');
+ $this->messages->add('Database name missing from account settings file.', 'error');
$this->template->load('admin_template', 'admin/active', $data);
return;
}
if ( ! isset($active_accounts['db_username']))
{
- $this->messages->add("Database username missing from account setting file.", 'error');
+ $this->messages->add('Database username missing from account settings file.', 'error');
$this->template->load('admin_template', 'admin/active', $data);
return;
}
if ( ! isset($active_accounts['db_password']))
{
- $this->messages->add("Database password missing from account setting file.", 'error');
+ $this->messages->add('Database password missing from account settings file.', 'error');
$this->template->load('admin_template', 'admin/active', $data);
return;
}
/* Setting new account database details in session */
$this->session->set_userdata('db_active_label', $db_label);
- $this->messages->add("Active account settings changed.", 'success');
+ $this->messages->add('Active account settings changed.', 'success');
redirect('admin');
}
return;
diff --git a/system/application/controllers/admin/create.php b/system/application/controllers/admin/create.php
index 11a2317..5fc5d05 100644
--- a/system/application/controllers/admin/create.php
+++ b/system/application/controllers/admin/create.php
@@ -204,7 +204,7 @@ class Create extends Controller {
/* Check if database ini file exists */
if (get_file_info($ini_file))
{
- $this->messages->add("Account with same label already exists.", 'error');
+ $this->messages->add('Account with same label already exists.', 'error');
$this->template->load('admin_template', 'admin/create', $data);
return;
}
@@ -212,7 +212,7 @@ class Create extends Controller {
/* Check if start date is less than end date */
if ($data_fy_end <= $data_fy_start)
{
- $this->messages->add("Financial start date cannot be greater than end date.", 'error');
+ $this->messages->add('Financial start date cannot be greater than end date.', 'error');
$this->template->load('admin_template', 'admin/create', $data);
return;
}
@@ -234,12 +234,12 @@ class Create extends Controller {
{
if ($newacc->query("CREATE DATABASE " . mysql_real_escape_string($data_database_name)))
{
- $this->messages->add("New database created.", 'success');
+ $this->messages->add('New account database created.', 'success');
/* Retrying to connect to new database */
$newacc = $this->load->database($dsn, TRUE);
$conn_error = $newacc->_error_message();
} else {
- $this->messages->add("Cannot create database.", 'error');
+ $this->messages->add('Failed to create account database.', 'error');
$this->template->load('admin_template', 'admin/create', $data);
return;
}
@@ -248,15 +248,15 @@ class Create extends Controller {
if ( ! $newacc->conn_id)
{
- $this->messages->add("Cannot connecting to database.", 'error');
+ $this->messages->add('Error connecting to database.', 'error');
$this->template->load('admin_template', 'admin/create', $data);
return;
} else if ($conn_error != "") {
- $this->messages->add("Error connecting to database. " . $newacc->_error_message(), 'error');
+ $this->messages->add('Error connecting to database. ' . $newacc->_error_message(), 'error');
$this->template->load('admin_template', 'admin/create', $data);
return;
} else if ($newacc->query("SHOW TABLES")->num_rows() > 0) {
- $this->messages->add("Selected database in not empty.", 'error');
+ $this->messages->add('Selected database in not empty.', 'error');
$this->template->load('admin_template', 'admin/create', $data);
return;
} else {
@@ -272,9 +272,11 @@ class Create extends Controller {
$this->messages->add($newacc->_error_message(), 'error');
}
+ $this->messages->add('Created account database.', 'success');
+
/* Adding the account settings */
$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));
- $this->messages->add("Successfully created webzash account.", 'success');
+ $this->messages->add('Added account information.', 'success');
/* Adding account settings to file. Code copied from manage controller */
$con_details = "[database]" . "\r\n" . "db_hostname = \"" . $data_database_host . "\"" . "\r\n" . "db_port = \"" . $data_database_port . "\"" . "\r\n" . "db_name = \"" . $data_database_name . "\"" . "\r\n" . "db_username = \"" . $data_database_username . "\"" . "\r\n" . "db_password = \"" . $data_database_password . "\"" . "\r\n";
@@ -284,10 +286,10 @@ class Create extends Controller {
/* Writing the connection string to end of file - writing in 'a' append mode */
if ( ! write_file($ini_file, $con_details))
{
- $this->messages->add("Failed to add account settings file. Please 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 />" . $con_details_html, 'error');
+ $this->messages->add('Failed to create account settings file. 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 />' . $con_details_html, 'error');
} else {
- $this->messages->add("Successfully added webzash account settings file to list of active accounts.", 'success');
+ $this->messages->add('Added account settings file to list of active accounts.', 'success');
}
redirect('admin');
diff --git a/system/application/controllers/admin/manage.php b/system/application/controllers/admin/manage.php
index 5b24793..550fd5e 100644
--- a/system/application/controllers/admin/manage.php
+++ b/system/application/controllers/admin/manage.php
@@ -124,7 +124,7 @@ class Manage extends Controller {
/* Check if database ini file exists */
if (get_file_info($ini_file))
{
- $this->messages->add("Account with same label already exists.", 'error');
+ $this->messages->add('Account with same label already exists.', 'error');
$this->template->load('admin_template', 'admin/manage/add', $data);
return;
}
@@ -136,12 +136,12 @@ class Manage extends Controller {
/* Writing the connection string to end of file - writing in 'a' append mode */
if ( ! write_file($ini_file, $con_details))
{
- $this->messages->add("Failed to add account settings file. Please 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 />" . $con_details_html, 'error');
+ $this->messages->add('Failed to add account settings file. 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 />' . $con_details_html, 'error');
$this->template->load('admin_template', 'admin/manage/add', $data);
return;
} else {
- $this->messages->add("Successfully added webzash account to list of active accounts.", 'success');
+ $this->messages->add('Added account to list of active accounts.', 'success');
redirect('admin/manage');
return;
}
@@ -209,37 +209,37 @@ class Manage extends Controller {
/* Check if database ini file exists */
if ( ! get_file_info($ini_file))
{
- $this->messages->add("Invalid account. Account setting file labeled " . $database_label . " does not exists.", 'error');
+ $this->messages->add('Account settings file labeled ' . $database_label . ' does not exists.', 'error');
} else {
/* Parsing database ini file */
$active_accounts = parse_ini_file($ini_file);
if ( ! $active_accounts)
{
- $CI->messages->add("Invalid account setting file", 'error');
+ $CI->messages->add('Invalid account settings file', 'error');
} else {
/* Check if all needed variables are set in ini file */
if (isset($active_accounts['db_hostname']))
$data['database_host']['value'] = $active_accounts['db_hostname'];
else
- $CI->messages->add("Hostname missing from account setting file", 'error');
+ $CI->messages->add('Hostname missing from account settings file', 'error');
if (isset($active_accounts['db_port']))
$data['database_port']['value'] = $active_accounts['db_port'];
else
- $CI->messages->add("Port missing from account setting file. Default MySQL port is 3306", 'error');
+ $CI->messages->add('Port missing from account settings file. Default MySQL port is 3306', 'error');
if (isset($active_accounts['db_name']))
$data['database_name']['value'] = $active_accounts['db_name'];
else
- $CI->messages->add("Database name missing from account setting file", 'error');
+ $CI->messages->add('Database name missing from account settings file', 'error');
if (isset($active_accounts['db_username']))
$data['database_username']['value'] = $active_accounts['db_username'];
else
- $CI->messages->add("Database username missing from account setting file", 'error');
+ $CI->messages->add('Database username missing from account settings file', 'error');
if ( ! isset($active_accounts['db_password']))
- $CI->messages->add("Database password missing from account setting file", 'error');
+ $CI->messages->add('Database password missing from account settings file', 'error');
}
}
}
@@ -271,12 +271,12 @@ class Manage extends Controller {
/* Writing the connection string to end of file - writing in 'a' append mode */
if ( ! write_file($ini_file, $con_details))
{
- $this->messages->add("Failed to edit account settings file. Please check if \"" . $ini_file . "\" file is writable.", 'error');
- $this->messages->add("You can manually update the text file \"" . $ini_file . "\" with the following content :<br /><br />" . $con_details_html, 'error');
+ $this->messages->add('Failed to edit account settings file. Check if "' . $ini_file . '" file is writable.', 'error');
+ $this->messages->add('You can manually update the text file "' . $ini_file . '" with the following content :<br /><br />' . $con_details_html, 'error');
$this->template->load('admin_template', 'admin/manage/edit', $data);
return;
} else {
- $this->messages->add("Successfully updated webzash account settings.", 'success');
+ $this->messages->add('Updated account settings.', 'success');
redirect('admin/manage');
return;
}
@@ -289,8 +289,8 @@ class Manage extends Controller {
$this->template->set('page_title', 'Delete a webzash account');
$ini_file = $this->config->item('config_path') . "accounts/" . $database_label . ".ini";
- $this->messages->add("Please delete " . $ini_file . " file manually.", 'error');
- $this->messages->add("Note that only the settings file will be delete. Account database will have to be deleted manually.", 'status');
+ $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))
{
diff --git a/system/application/controllers/admin/setting.php b/system/application/controllers/admin/setting.php
index b65a247..c1a0070 100644
--- a/system/application/controllers/admin/setting.php
+++ b/system/application/controllers/admin/setting.php
@@ -60,7 +60,7 @@ class Setting extends Controller {
if ($data_row_count < 0 || $data_row_count > 200)
{
- $this->messages->add('Invalid value for Row Count.', 'error');
+ $this->messages->add('Invalid number of rows.', 'error');
$this->template->load('admin_template', 'admin/setting');
return;
}
@@ -72,12 +72,12 @@ class Setting extends Controller {
/* Writing the connection string to end of file - writing in 'a' append mode */
if ( ! write_file($ini_file, $new_setting))
{
- $this->messages->add("Failed to update settings file. Please 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 />" . $new_setting_html, 'error');
+ $this->messages->add('Failed to update settings file. 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 />' . $new_setting_html, 'error');
$this->template->load('admin_template', 'admin/setting', $data);
return;
} else {
- $this->messages->add('General settings updated successfully.', 'success');
+ $this->messages->add('General settings updated.', 'success');
redirect('admin/setting');
return;
}
diff --git a/system/application/controllers/admin/welcome.php b/system/application/controllers/admin/welcome.php
index cc4ed1e..14e99c0 100644
--- a/system/application/controllers/admin/welcome.php
+++ b/system/application/controllers/admin/welcome.php
@@ -27,40 +27,40 @@ class Welcome extends Controller {
/* Check if database ini file exists */
if ( ! get_file_info($ini_file))
{
- $this->messages->add("Account setting file is missing.", 'error');
+ $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 setting file.", 'error');
+ $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 setting file.", 'error');
+ $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 setting file. Default MySQL port is 3306.", 'error');
+ $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 setting file.", 'error');
+ $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 setting file.", 'error');
+ $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 setting file.", 'error');
+ $this->messages->add('Database password missing from account settings file.', 'error');
}
if ($ini_ok)
@@ -85,7 +85,7 @@ class Welcome extends Controller {
}
} else {
$is_label_set = FALSE;
- $this->messages->add('Please select a Webzash database.', 'error');
+ $this->messages->add('Select a valid account.', 'error');
}
if ($is_label_set)
@@ -105,7 +105,7 @@ class Welcome extends Controller {
if ( ! $valid_db_q)
{
$valid_webzash_db = FALSE;
- $this->messages->add('Invalid Webzash database.', 'error');
+ $this->messages->add('Invalid account database.', 'error');
break;
}
}
@@ -129,10 +129,10 @@ class Welcome extends Controller {
}
}
} else {
- $this->messages->add('Invalid database connection settings. Please check whether the provided database name, username and password is valid.', 'error');
+ $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. Please check whether database server is running.', 'error');
+ $this->messages->add('Cannot connect to database server. Verify whether database server is running.', 'error');
}
}
diff --git a/system/application/controllers/group.php b/system/application/controllers/group.php
index a4af1ad..f5d24d7 100644
--- a/system/application/controllers/group.php
+++ b/system/application/controllers/group.php
@@ -85,7 +85,7 @@ class Group extends Controller {
return;
} else {
$this->db->trans_complete();
- $this->messages->add($data_name . ' - Group A/C added successfully.', 'success');
+ $this->messages->add('Added ' . $data_name . ' - Group A/C.', 'success');
$this->logger->write_message("success", "Added Group A/C named " . $data_name);
redirect('account');
return;
@@ -198,7 +198,7 @@ class Group extends Controller {
return;
} else {
$this->db->trans_complete();
- $this->messages->add($data_name . ' - Group A/C updated successfully.', 'success');
+ $this->messages->add('Updated ' . $data_name . ' - Group A/C.', 'success');
$this->logger->write_message("success", "Updated Group A/C named " . $data_name . " [id:" . $data_id . "]");
redirect('account');
return;
@@ -253,13 +253,13 @@ class Group extends Controller {
if ( ! $this->db->query("DELETE FROM groups WHERE id = ?", array($id)))
{
$this->db->trans_rollback();
- $this->messages->add("Error deleting " . $group_data->name . " - Group A/C.", 'error');
+ $this->messages->add('Error deleting ' . $group_data->name . ' - Group A/C.', '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($group_data->name . ' - Group A/C deleted successfully.', 'success');
+ $this->messages->add('Deleted ' . $group_data->name . ' - Group A/C.', '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 1b4bde3..20ee0aa 100644
--- a/system/application/controllers/ledger.php
+++ b/system/application/controllers/ledger.php
@@ -73,7 +73,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;
}
@@ -101,7 +101,7 @@ class Ledger extends Controller {
return;
} else {
$this->db->trans_complete();
- $this->messages->add($data_name . ' - Ledger A/C added successfully.', 'success');
+ $this->messages->add('Added ' . $data_name . ' - Ledger A/C.', 'success');
$this->logger->write_message("success", "Added Ledger A/C named " . $data_name);
redirect('account');
return;
@@ -192,7 +192,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;
}
@@ -220,7 +220,7 @@ class Ledger extends Controller {
return;
} else {
$this->db->trans_complete();
- $this->messages->add($data_name . ' - Ledger A/C updated successfully.', 'success');
+ $this->messages->add('Updated ' . $data_name . ' - Ledger A/C.', 'success');
$this->logger->write_message("success", "Updated Ledger A/C named " . $data_name . " [id:" . $data_id . "]");
redirect('account');
return;
@@ -264,13 +264,13 @@ class Ledger extends Controller {
if ( ! $this->db->query("DELETE FROM ledgers WHERE id = ?", array($id)))
{
$this->db->trans_rollback();
- $this->messages->add("Error deleting " . $ledger_data->name . " - Ledger A/C.", 'error');
+ $this->messages->add('Error deleting ' . $ledger_data->name . ' - Ledger A/C.', '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($ledger_data->name . " - Ledger A/C deleted successfully.", 'success');
+ $this->messages->add('Deleted ' . $ledger_data->name . ' - Ledger A/C.', '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/report.php b/system/application/controllers/report.php
index ea86ee8..fa8d923 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -612,7 +612,7 @@ class Report extends Controller {
/* Checking for valid ledger id */
if ($data['ledger_id'] < 1)
{
- $this->messages->add("Invalid Ledger A/C.", 'error');
+ $this->messages->add('Invalid Ledger A/C.', 'error');
redirect("report/ledgerst");
}
$data['report'] = "report/ledgerst";
diff --git a/system/application/controllers/setting.php b/system/application/controllers/setting.php
index 3595c09..94d8b96 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -135,13 +135,13 @@ class Setting extends Controller {
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)))
{
$this->db->trans_rollback();
- $this->messages->add('Error updating settings.', 'error');
+ $this->messages->add('Error updating account settings.', 'error');
$this->logger->write_message("error", "Error updating account settings");
$this->template->load('template', 'setting/account', $data);
return;
} else {
$this->db->trans_complete();
- $this->messages->add('Settings updated successfully.', 'success');
+ $this->messages->add('Account settings updated.', 'success');
$this->logger->write_message("success", "Updated account settings");
redirect('setting');
return;
@@ -299,7 +299,7 @@ class Setting extends Controller {
/* Check if database ini file exists */
if (get_file_info($ini_file))
{
- $this->messages->add("Account with same label already exists.", 'error');
+ $this->messages->add('Account with same label already exists.', 'error');
$this->template->load('template', 'setting/cf', $data);
return;
}
@@ -307,7 +307,7 @@ class Setting extends Controller {
/* Check if start date is less than end date */
if ($data_fy_end <= $data_fy_start)
{
- $this->messages->add("Financial start date cannot be greater than end date.", 'error');
+ $this->messages->add('Financial start date cannot be greater than end date.', 'error');
$this->template->load('template', 'setting/cf', $data);
return;
}
@@ -329,12 +329,12 @@ class Setting extends Controller {
{
if ($newacc->query("CREATE DATABASE " . mysql_real_escape_string($data_database_name)))
{
- $this->messages->add("New database created.", 'success');
+ $this->messages->add('New account database created.', 'success');
/* Retrying to connect to new database */
$newacc = $this->load->database($dsn, TRUE);
$conn_error = $newacc->_error_message();
} else {
- $this->messages->add("Cannot create database.", 'error');
+ $this->messages->add('Cannot create account database.', 'error');
$this->template->load('template', 'setting/cf', $data);
return;
}
@@ -343,15 +343,15 @@ class Setting extends Controller {
if ( ! $newacc->conn_id)
{
- $this->messages->add("Cannot connecting to database.", 'error');
+ $this->messages->add('Error connecting to database.', 'error');
$this->template->load('template', 'setting/cf', $data);
return;
} else if ($conn_error != "") {
- $this->messages->add("Error connecting to database. " . $newacc->_error_message(), 'error');
+ $this->messages->add('Error connecting to database. ' . $newacc->_error_message(), 'error');
$this->template->load('template', 'setting/cf', $data);
return;
} else if ($newacc->query("SHOW TABLES")->num_rows() > 0) {
- $this->messages->add("Selected database in not empty.", 'error');
+ $this->messages->add('Selected database in not empty.', 'error');
$this->template->load('template', 'setting/cf', $data);
return;
} else {
@@ -367,10 +367,11 @@ class Setting extends Controller {
$this->messages->add($newacc->_error_message(), 'error');
}
+ $this->messages->add('Created account database.', 'success');
+
/* Adding the account settings */
$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));
-
- $this->messages->add("Successfully created webzash account.", 'success');
+ $this->messages->add('Added account information.', 'success');
/* Adding account settings to file. Code copied from manage controller */
$con_details = "[database]" . "\r\n" . "db_hostname = \"" . $data_database_host . "\"" . "\r\n" . "db_port = \"" . $data_database_port . "\"" . "\r\n" . "db_name = \"" . $data_database_name . "\"" . "\r\n" . "db_username = \"" . $data_database_username . "\"" . "\r\n" . "db_password = \"" . $data_database_password . "\"" . "\r\n";
@@ -386,7 +387,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 ' . $row->name . '.', 'error');
$cf_status = FALSE;
}
}
@@ -417,13 +418,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 ' . $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 ' . $row->name . '.', 'error');
$cf_status = FALSE;
}
}
@@ -435,23 +436,23 @@ 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;
}
}
if ($cf_status)
- $this->messages->add("Successfully carry forward to new account.", 'success');
+ $this->messages->add('Account carried forward.', 'success');
else
- $this->messages->add("Error in carry forward to new account.", 'error');
+ $this->messages->add('Error carrying forward to new account.', 'error');
/* Writing the connection string to end of file - writing in 'a' append mode */
if ( ! write_file($ini_file, $con_details))
{
- $this->messages->add("Failed to add account settings file. Please 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 />" . $con_details_html, 'error');
+ $this->messages->add('Failed to add account settings file. 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 />' . $con_details_html, 'error');
} else {
- $this->messages->add("Successfully added webzash account settings file to list of active accounts.", 'success');
+ $this->messages->add('Added account settings file to list of active accounts.', 'success');
}
redirect('setting');
@@ -550,13 +551,13 @@ class Setting extends Controller {
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)))
{
$this->db->trans_rollback();
- $this->messages->add('Error updating settings.', 'error');
+ $this->messages->add('Error updating email settings.', 'error');
$this->logger->write_message("error", "Error updating email settings");
$this->template->load('template', 'setting/email', $data);
return;
} else {
$this->db->trans_complete();
- $this->messages->add('Email settings updated successfully.', 'success');
+ $this->messages->add('Email settings updated.', 'success');
$this->logger->write_message("success", "Updated email settings");
redirect('setting');
return;
@@ -770,7 +771,7 @@ class Setting extends Controller {
return;
} else {
$this->db->trans_complete();
- $this->messages->add('Printer settings updated successfully.', 'success');
+ $this->messages->add('Printer settings updated.', 'success');
$this->logger->write_message("success", "Updated printer settings");
redirect('setting');
return;
@@ -791,7 +792,7 @@ class Setting extends Controller {
/* Write the backup file to server */
if ( ! write_file($this->config->item('backup_path') . $backup_filename, $backup_data))
{
- $this->messages->add('Error saving backup file to server.' . ' Please check if "' . $this->config->item('backup_path') . '" folder is writable.', 'error');
+ $this->messages->add('Error saving backup file to server.' . ' Check if "' . $this->config->item('backup_path') . '" folder is writable.', 'error');
redirect('setting');
return;
}
@@ -883,7 +884,7 @@ class Setting extends Controller {
return;
} else {
$this->db->trans_complete();
- $this->messages->add('Voucher settings updated successfully.', 'success');
+ $this->messages->add('Voucher settings updated.', 'success');
$this->logger->write_message("success", "Updated voucher settings");
redirect('setting');
return;
@@ -914,7 +915,7 @@ class Setting extends Controller {
/* Check if database ini file exists */
if ( ! get_file_info($ini_file))
{
- $this->messages->add("Account setting file is missing.", 'error');
+ $this->messages->add('Account setting file is missing.', 'error');
redirect("");
return;
}
@@ -923,7 +924,7 @@ class Setting extends Controller {
$active_accounts = parse_ini_file($ini_file);
if ( ! $active_accounts)
{
- $this->messages->add("Invalid account setting file.", 'error');
+ $this->messages->add('Invalid account setting file.', 'error');
redirect("");
return;
}
diff --git a/system/application/controllers/tag.php b/system/application/controllers/tag.php
index a9cfc79..9fefda0 100644
--- a/system/application/controllers/tag.php
+++ b/system/application/controllers/tag.php
@@ -94,7 +94,7 @@ class Tag extends Controller {
return;
} else {
$this->db->trans_complete();
- $this->messages->add("Added " . $data_tag_title . ' - Tag successfully.', 'success');
+ $this->messages->add('Added ' . $data_tag_title . ' - Tag.', 'success');
$this->logger->write_message("success", "Added tag named " . $data_tag_title);
redirect('tag');
return;
@@ -201,7 +201,7 @@ class Tag extends Controller {
return;
} else {
$this->db->trans_complete();
- $this->messages->add("Updated " . $data_tag_title . ' - Tag successfully.', 'success');
+ $this->messages->add('Updated ' . $data_tag_title . ' - Tag.', 'success');
$this->logger->write_message("success", "Updated tag named " . $data_tag_title . " [id:" . $id . "]");
redirect('tag');
return;
@@ -224,7 +224,7 @@ class Tag extends Controller {
$data_valid_q = $this->db->query("SELECT * FROM tags WHERE id = ?", array($id));
if ($data_valid_q->num_rows() < 1)
{
- $this->messages->add('Invalid Tag specified.', 'error');
+ $this->messages->add('Invalid Tag.', 'error');
redirect('tag');
return;
}
@@ -235,8 +235,8 @@ class Tag extends Controller {
if ( ! $this->db->query("UPDATE vouchers SET tag_id = 0 WHERE tag_id = ?", array($id)))
{
$this->db->trans_rollback();
- $this->messages->add('Error removing Tags.', 'error');
- $this->logger->write_message("error", "Error removing tag named " . $data_tag->title . " [id:" . $id . "] from vouchers");
+ $this->messages->add('Error deleting Tag from Vouchers.', 'error');
+ $this->logger->write_message("error", "Error deleting tag named " . $data_tag->title . " [id:" . $id . "] from vouchers");
redirect('tag');
return;
} else {
@@ -249,7 +249,7 @@ class Tag extends Controller {
return;
} else {
$this->db->trans_complete();
- $this->messages->add('Tag deleted successfully.', 'success');
+ $this->messages->add('Tag deleted.', 'success');
$this->logger->write_message("success", "Deleted tag named " . $data_tag->title . " [id:" . $id . "]");
redirect('tag');
return;
diff --git a/system/application/controllers/voucher.php b/system/application/controllers/voucher.php
index 26878d8..ac56a86 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -225,7 +225,7 @@ class Voucher extends Controller {
/* Load current voucher details */
if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id, $voucher_type))
{
- $this->messages->add('Invalid Voucher.', 'error');
+ $this->messages->add('Invalid Voucher number.', 'error');
redirect('voucher/show/' . $voucher_type);
return;
}
@@ -414,7 +414,7 @@ class Voucher extends Controller {
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)))
{
$this->db->trans_rollback();
- $this->messages->add('Error addding Voucher A/C.', 'error');
+ $this->messages->add('Error addding 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");
$this->template->load('template', 'voucher/add', $data);
return;
@@ -475,7 +475,7 @@ class Voucher extends Controller {
$voucher_success_links .= anchor('voucher/download/' . strtolower($voucher_type) . "/" . $voucher_id, 'Download', array('class' => 'anchor-link-a'));
$voucher_success_links .= " it.";
- $this->messages->add(ucfirst($voucher_type) . ' Voucher number ' . voucher_number_prefix($voucher_type) . $data_number . ' added successfully. ' . $voucher_success_links, 'success');
+ $this->messages->add('Added ' . ucfirst($voucher_type) . ' Voucher number ' . voucher_number_prefix($voucher_type) . $data_number . $voucher_success_links, 'success');
$this->logger->write_message("success", "Added " . ucfirst($voucher_type) . " Voucher number " . voucher_number_prefix($voucher_type) . $data_number . " [id:" . $voucher_id . "]");
redirect('voucher/show/' . $voucher_type);
$this->template->load('template', 'voucher/add', $data);
@@ -510,7 +510,7 @@ class Voucher extends Controller {
/* Load current voucher details */
if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id, $voucher_type))
{
- $this->messages->add('Invalid Voucher.', 'error');
+ $this->messages->add('Invalid Voucher number.', 'error');
redirect('voucher/show/' . $voucher_type);
return;
}
@@ -754,7 +754,7 @@ class Voucher extends Controller {
$voucher_success_links .= anchor('voucher/download/' . strtolower($voucher_type) . "/" . $voucher_id, 'Download', array('class' => 'anchor-link-a'));
$voucher_success_links .= " it.";
- $this->messages->add(ucfirst($voucher_type) . ' Voucher number ' . voucher_number_prefix($voucher_type) . $data_number . ' updated successfully. ' . $voucher_success_links, 'success');
+ $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 . "]");
redirect('voucher/show/' . $voucher_type);
return;
@@ -767,7 +767,7 @@ class Voucher extends Controller {
/* Load current voucher details */
if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id, $voucher_type))
{
- $this->messages->add('Invalid Voucher.', 'error');
+ $this->messages->add('Invalid Voucher number.', 'error');
redirect('voucher/show/' . $voucher_type);
return;
}
@@ -790,7 +790,7 @@ class Voucher extends Controller {
return;
}
$this->db->trans_complete();
- $this->messages->add('Voucher deleted successfully.', 'success');
+ $this->messages->add('Deleted ' . ucfirst($voucher_type) . ' Voucher.', 'success');
$this->logger->write_message("success", "Deleted " . ucfirst($voucher_type) . " Voucher number " . voucher_number_prefix($voucher_type) . $cur_voucher->number . " [id:" . $voucher_id . "]");
redirect('voucher/show/' . $voucher_type);
return;
@@ -807,7 +807,7 @@ class Voucher extends Controller {
/* Load current voucher details */
if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id, $voucher_type))
{
- $this->messages->add('Invalid Voucher.', 'error');
+ $this->messages->add('Invalid Voucher number.', 'error');
redirect('voucher/show/' . $voucher_type);
return;
}
@@ -856,7 +856,7 @@ class Voucher extends Controller {
/* Load current voucher details */
if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id, $voucher_type))
{
- $this->messages->add('Invalid Voucher.', 'error');
+ $this->messages->add('Invalid Voucher number.', 'error');
redirect('voucher/show/' . $voucher_type);
return;
}
@@ -903,7 +903,7 @@ class Voucher extends Controller {
/* Load current voucher details */
if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id, $voucher_type))
{
- $this->messages->add('Invalid Voucher.', 'error');
+ $this->messages->add('Invalid Voucher number.', 'error');
redirect('voucher/show/' . $voucher_type);
return;
}
diff --git a/system/application/helpers/MY_date_helper.php b/system/application/helpers/MY_date_helper.php
index 11f523a..2d982b6 100644
--- a/system/application/helpers/MY_date_helper.php
+++ b/system/application/helpers/MY_date_helper.php
@@ -19,7 +19,7 @@ if ( ! function_exists('date_php_to_mysql'))
list($y, $m, $d) = explode('/', $dt);
break;
default:
- $CI->messages->add('Invalid date format. Please check your account settings', 'error');
+ $CI->messages->add('Invalid date format. Check your account settings.', 'error');
return "";
}
$ts = mktime(0, 0, 0, $m, $d, $y);
@@ -46,7 +46,7 @@ if ( ! function_exists('date_php_to_mysql_end_time'))
list($y, $m, $d) = explode('/', $dt);
break;
default:
- $CI->messages->add('Invalid date format. Please check your account settings', 'error');
+ $CI->messages->add('Invalid date format. Check your account settings.', 'error');
return "";
}
$ts = mktime("23", "59", "59", $m, $d, $y);
@@ -73,7 +73,7 @@ if ( ! function_exists('date_mysql_to_php'))
return date('Y/m/d', $ts);
break;
default:
- $CI->messages->add('Invalid date format. Please check your account settings', 'error');
+ $CI->messages->add('Invalid date format. Check your account settings.', 'error');
return "";
}
return;
@@ -99,7 +99,7 @@ if ( ! function_exists('date_mysql_to_php_display'))
return date('Y M d', $ts);
break;
default:
- $CI->messages->add('Invalid date format. Please check your account settings', 'error');
+ $CI->messages->add('Invalid date format. Check your account settings.', 'error');
return "";
}
return;
@@ -134,7 +134,7 @@ if ( ! function_exists('date_today_php'))
return date('Y/m/d');
break;
default:
- $CI->messages->add('Invalid date format. Please check your account settings', 'error');
+ $CI->messages->add('Invalid date format. Check your account settings.', 'error');
return "";
}
return;
diff --git a/system/application/libraries/MY_Form_validation.php b/system/application/libraries/MY_Form_validation.php
index 74a7f17..bf74495 100644
--- a/system/application/libraries/MY_Form_validation.php
+++ b/system/application/libraries/MY_Form_validation.php
@@ -109,7 +109,7 @@ class MY_Form_validation extends CI_Form_validation {
list($y, $m, $d) = explode('/', $str);
break;
default:
- $CI->messages->add('Invalid date format. Please check your account settings', 'error');
+ $CI->messages->add('Invalid date format. Check your account settings.', 'error');
return "";
}
return checkdate($m, $d, $y) ? TRUE : FALSE;
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index 1c9129b..d1519d4 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -29,7 +29,7 @@ class Startup
/* Check if database ini file exists */
if ( ! get_file_info($ini_file))
{
- $CI->messages->add("Account setting file is missing", 'error');
+ $CI->messages->add('Account settings file is missing.', 'error');
redirect('admin');
return;
}
@@ -38,7 +38,7 @@ class Startup
$active_accounts = parse_ini_file($ini_file);
if ( ! $active_accounts)
{
- $CI->messages->add("Invalid account setting file", 'error');
+ $CI->messages->add('Invalid account settings.', 'error');
redirect('admin');
return;
}
@@ -46,31 +46,31 @@ class Startup
/* Check if all needed variables are set in ini file */
if ( ! isset($active_accounts['db_hostname']))
{
- $CI->messages->add("Hostname missing from account setting file", 'error');
+ $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');
+ $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');
+ $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');
+ $CI->messages->add('Database username missing from account setting file.', 'error');
redirect('admin');
return;
}
if ( ! isset($active_accounts['db_password']))
{
- $CI->messages->add("Database password missing from account setting file", 'error');
+ $CI->messages->add('Database password missing from account setting file.', 'error');
redirect('admin');
return;
}
@@ -91,7 +91,7 @@ class Startup
$db_config['dbcollat'] = "utf8_general_ci";
$CI->load->database($db_config, FALSE, TRUE);
} else {
- $CI->messages->add('Please select a Webzash database', 'error');
+ $CI->messages->add('Please select a account.', 'error');
redirect('admin');
}
@@ -108,18 +108,18 @@ class Startup
$valid_db_q = mysql_query('DESC ' . $tbname);
if ( ! $valid_db_q)
{
- $CI->messages->add('Invalid Webzash database', 'error');
+ $CI->messages->add('Invalid account database.', 'error');
redirect('admin');
return;
}
}
} else {
- $CI->messages->add('Invalid database connection settings. Please check whether the provided database name, username and password is valid', 'error');
+ $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. Please check whether database server is running', 'error');
+ $CI->messages->add('Cannot connect to database server. Check whether database server is running.', 'error');
redirect('admin');
return;
}
@@ -128,7 +128,7 @@ class Startup
$account_q = $CI->db->query('SELECT * FROM settings WHERE id = 1');
if ( ! ($account_d = $account_q->row()))
{
- $CI->messages->add('Please select valid account', 'error');
+ $CI->messages->add('Invalid account details.', 'error');
redirect('admin');
}
$CI->config->set_item('account_name', $account_d->name);
commit 99a5007dfb66c76ec2bb12bbd5c186758c54aa8a
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Dec 23 17:04:17 2010 +0530
Check for valid Ledger A/C before add/edit 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 9d37292..26878d8 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -360,6 +360,15 @@ class Voucher extends Controller {
{
if ($data_all_ledger_id[$id] < 1)
continue;
+
+ /* Check for valid ledger id */
+ if ($this->db->query("SELECT id FROM ledgers WHERE id = ?", array($data_all_ledger_id[$id]))->num_rows() < 1)
+ {
+ $this->messages->add('Invalid Ledger A/C.', 'error');
+ $this->template->load('template', 'voucher/add', $data);
+ return;
+ }
+
if ($data_all_ledger_dc[$id] == "D")
{
$dr_total += $data_all_dr_amount[$id];
@@ -623,6 +632,15 @@ class Voucher extends Controller {
{
if ($data_all_ledger_id[$id] < 1)
continue;
+
+ /* Check for valid ledger id */
+ if ($this->db->query("SELECT id FROM ledgers WHERE id = ?", array($data_all_ledger_id[$id]))->num_rows() < 1)
+ {
+ $this->messages->add('Invalid Ledger A/C.', 'error');
+ $this->template->load('template', 'voucher/edit', $data);
+ return;
+ }
+
if ($data_all_ledger_dc[$id] == "D")
{
$dr_total += $data_all_dr_amount[$id];
commit dbc842d05bd9080e85ce620c7b5766e8662bf148
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Dec 23 16:57:21 2010 +0530
Fixed query parameters as array
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 4383918..a4af1ad 100644
--- a/system/application/controllers/group.php
+++ b/system/application/controllers/group.php
@@ -56,7 +56,7 @@ 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 = ?", $data_parent_id)->num_rows() < 1)
+ if ($this->db->query("SELECT id FROM groups WHERE id = ?", array($data_parent_id))->num_rows() < 1)
{
$this->messages->add('Invalid Parent group.', 'error');
$this->template->load('template', 'group/add', $data);
@@ -161,7 +161,7 @@ class Group extends Controller {
$data_id = $id;
/* Check if parent group id present */
- if ($this->db->query("SELECT id FROM groups WHERE id = ?", $data_parent_id)->num_rows() < 1)
+ if ($this->db->query("SELECT id FROM groups WHERE id = ?", array($data_parent_id))->num_rows() < 1)
{
$this->messages->add('Invalid Parent group.', 'error');
$this->template->load('template', 'group/edit', $data);
diff --git a/system/application/controllers/ledger.php b/system/application/controllers/ledger.php
index 5c30087..1b4bde3 100644
--- a/system/application/controllers/ledger.php
+++ b/system/application/controllers/ledger.php
@@ -79,7 +79,7 @@ class Ledger extends Controller {
}
/* Check if parent group id present */
- if ($this->db->query("SELECT id FROM groups WHERE id = ?", $data_group_id)->num_rows() < 1)
+ if ($this->db->query("SELECT id FROM groups WHERE id = ?", array($data_group_id))->num_rows() < 1)
{
$this->messages->add('Invalid Parent group.', 'error');
$this->template->load('template', 'ledger/add', $data);
@@ -198,7 +198,7 @@ class Ledger extends Controller {
}
/* Check if parent group id present */
- if ($this->db->query("SELECT id FROM groups WHERE id = ?", $data_group_id)->num_rows() < 1)
+ if ($this->db->query("SELECT id FROM groups WHERE id = ?", array($data_group_id))->num_rows() < 1)
{
$this->messages->add('Invalid Parent group.', 'error');
$this->template->load('template', 'ledger/edit', $data);
commit e0cdec9ff02cff17e550bb483c9d8e9f3401758f
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Dec 23 16:33:09 2010 +0530
Added tooltips to ledger type of cash or bank
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/views/ledger/add.php b/system/application/views/ledger/add.php
index c7268e6..249611b 100644
--- a/system/application/views/ledger/add.php
+++ b/system/application/views/ledger/add.php
@@ -22,7 +22,10 @@
echo "</p>";
echo "<p>";
+ echo "<span id=\"tooltip-target-1\">";
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 "</p>";
echo "<p>";
diff --git a/system/application/views/ledger/edit.php b/system/application/views/ledger/edit.php
index 1be3802..2400ff4 100644
--- a/system/application/views/ledger/edit.php
+++ b/system/application/views/ledger/edit.php
@@ -22,7 +22,10 @@
echo "</p>";
echo "<p>";
+ echo "<span id=\"tooltip-target-1\">";
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 "</p>";
echo "<p>";
commit 0392bb1d08fb8a0a046798e2c8f6e2a4226b1e87
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Dec 23 16:29:54 2010 +0530
Check for valid parent group when add or edit Ledger A/C
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 9f92b45..5c30087 100644
--- a/system/application/controllers/ledger.php
+++ b/system/application/controllers/ledger.php
@@ -78,6 +78,14 @@ class Ledger extends Controller {
return;
}
+ /* Check if parent group id present */
+ if ($this->db->query("SELECT id FROM groups WHERE id = ?", $data_group_id)->num_rows() < 1)
+ {
+ $this->messages->add('Invalid Parent group.', 'error');
+ $this->template->load('template', 'ledger/add', $data);
+ return;
+ }
+
if ($data_ledger_type_cashbank_value == "1")
{
$data_ledger_type_cashbank = "B";
@@ -185,7 +193,15 @@ class Ledger extends Controller {
if ($data_group_id < 5)
{
$this->messages->add("Invalid parent group.", 'error');
- $this->template->load('template', 'ledger/add', $data);
+ $this->template->load('template', 'ledger/edit', $data);
+ return;
+ }
+
+ /* Check if parent group id present */
+ if ($this->db->query("SELECT id FROM groups WHERE id = ?", $data_group_id)->num_rows() < 1)
+ {
+ $this->messages->add('Invalid Parent group.', 'error');
+ $this->template->load('template', 'ledger/edit', $data);
return;
}
commit a8ca08ee57da268b3e02a8629de2d9a7c66418ab
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Dec 23 16:25:57 2010 +0530
Check for valid parent group
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 af3c87c..4383918 100644
--- a/system/application/controllers/group.php
+++ b/system/application/controllers/group.php
@@ -55,6 +55,14 @@ class Group extends Controller {
$data_name = $this->input->post('group_name', TRUE);
$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 = ?", $data_parent_id)->num_rows() < 1)
+ {
+ $this->messages->add('Invalid Parent group.', 'error');
+ $this->template->load('template', 'group/add', $data);
+ return;
+ }
+
/* Only if Income or Expense can affect gross profit loss calculation */
$data_affects_gross = $this->input->post('affects_gross', TRUE);
if ($data_parent_id == "3" || $data_parent_id == "4")
@@ -152,6 +160,22 @@ class Group extends Controller {
$data_parent_id = $this->input->post('group_parent', TRUE);
$data_id = $id;
+ /* Check if parent group id present */
+ if ($this->db->query("SELECT id FROM groups WHERE id = ?", $data_parent_id)->num_rows() < 1)
+ {
+ $this->messages->add('Invalid Parent group.', 'error');
+ $this->template->load('template', 'group/edit', $data);
+ return;
+ }
+
+ /* Check if parent group same as current group id */
+ if ($data_parent_id == $id)
+ {
+ $this->messages->add('Invalid Parent group', 'error');
+ $this->template->load('template', 'group/edit', $data);
+ return;
+ }
+
/* Only if Income or Expense can affect gross profit loss calculation */
$data_affects_gross = $this->input->post('affects_gross', TRUE);
if ($data_parent_id == "3" || $data_parent_id == "4")
commit 617d208f8d627b279370f07beb96dbc1ff0643c4
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Dec 23 14:20:44 2010 +0530
Added tooltips to voucher date and draft options
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/assets/css/custom.css b/system/application/assets/css/custom.css
index 5b86533..416e018 100644
--- a/system/application/assets/css/custom.css
+++ b/system/application/assets/css/custom.css
@@ -233,7 +233,6 @@ ul#pagination-flickr {
border:3px solid #AF8A31;
background-color:#FFC848;
text-align:left;
- width:400px;
}
#tooltip-content-2 {
@@ -243,7 +242,6 @@ ul#pagination-flickr {
border:3px solid #AF8A31;
background-color:#FFC848;
text-align:left;
- width:400px;
}
#tooltip-content-3 {
@@ -253,5 +251,4 @@ ul#pagination-flickr {
border:3px solid #AF8A31;
background-color:#FFC848;
text-align:left;
- width:400px;
}
diff --git a/system/application/views/group/edit.php b/system/application/views/group/edit.php
index 8de02da..a5aac01 100644
--- a/system/application/views/group/edit.php
+++ b/system/application/views/group/edit.php
@@ -27,7 +27,10 @@ $(document).ready(function() {
echo "</p>";
echo "<p class=\"affects-gross\">";
+ echo "<span id=\"tooltip-target-1\">";
echo form_checkbox('affects_gross', 1, $affects_gross) . " Affects Gross Profit/Loss Calculations";
+ echo "</span>";
+ echo "<span id=\"tooltip-content-1\">If selected the Group A/C will affect Gross Profit and Loss calculations, otherwise it will affect only Net Profit and Loss calculations.</span>";
echo "</p>";
echo "<p>";
diff --git a/system/application/views/voucher/add.php b/system/application/views/voucher/add.php
index d094129..3aa5fa5 100644
--- a/system/application/views/voucher/add.php
+++ b/system/application/views/voucher/add.php
@@ -189,9 +189,12 @@ $(document).ready(function() {
echo " ";
echo voucher_number_prefix($voucher_type) . form_input($voucher_number);
echo " ";
+ echo "<span id=\"tooltip-target-1\">";
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 "</p>";
echo "<table class=\"voucher-table\">";
@@ -245,7 +248,10 @@ $(document).ready(function() {
echo "<p>";
echo form_fieldset('Options', array('class' => "fieldset-auto-width"));
+ echo "<span id=\"tooltip-target-2\">";
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 " ";
diff --git a/system/application/views/voucher/edit.php b/system/application/views/voucher/edit.php
index 1171012..036086e 100644
--- a/system/application/views/voucher/edit.php
+++ b/system/application/views/voucher/edit.php
@@ -189,9 +189,12 @@ $(document).ready(function() {
echo " ";
echo voucher_number_prefix($voucher_type) . form_input($voucher_number);
echo " ";
+ echo "<span id=\"tooltip-target-1\">";
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 "</p>";
echo "<table class=\"voucher-table\">";
@@ -245,7 +248,10 @@ $(document).ready(function() {
echo "<p>";
echo form_fieldset('Options', array('class' => "fieldset-auto-width"));
+ echo "<span id=\"tooltip-target-2\">";
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 " ";
commit 1172dadae1a75151e8396ce04b20f8c1b53421d5
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Dec 23 14:05:59 2010 +0530
Added EZPZ Tooltip jQuery Library
http://theezpzway.com/demos/ezpz-tooltip
Licensed under The MIT License
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/assets/css/custom.css b/system/application/assets/css/custom.css
index e4b737b..5b86533 100644
--- a/system/application/assets/css/custom.css
+++ b/system/application/assets/css/custom.css
@@ -224,3 +224,34 @@ ul#pagination-flickr {
padding:0px;
list-style-type:square;
}
+
+/********************************** TOOL TIPS *********************************/
+#tooltip-content-1 {
+ display:none;
+ position:absolute;
+ padding:10px;
+ border:3px solid #AF8A31;
+ background-color:#FFC848;
+ text-align:left;
+ width:400px;
+}
+
+#tooltip-content-2 {
+ display:none;
+ position:absolute;
+ padding:10px;
+ border:3px solid #AF8A31;
+ background-color:#FFC848;
+ text-align:left;
+ width:400px;
+}
+
+#tooltip-content-3 {
+ display:none;
+ position:absolute;
+ padding:10px;
+ border:3px solid #AF8A31;
+ background-color:#FFC848;
+ text-align:left;
+ width:400px;
+}
diff --git a/system/application/assets/js/custom.js b/system/application/assets/js/custom.js
index 64dfbad..d9e9387 100644
--- a/system/application/assets/js/custom.js
+++ b/system/application/assets/js/custom.js
@@ -13,6 +13,9 @@ $(document).ready(function() {
return false;
}
});
+ $("#tooltip-target-1").ezpz_tooltip();
+ $("#tooltip-target-2").ezpz_tooltip();
+ $("#tooltip-target-3").ezpz_tooltip();
})
diff --git a/system/application/assets/js/ezpz_tooltip.min.js b/system/application/assets/js/ezpz_tooltip.min.js
new file mode 100644
index 0000000..32685d4
--- /dev/null
+++ b/system/application/assets/js/ezpz_tooltip.min.js
@@ -0,0 +1,2 @@
+// EZPZ Tooltip v1.0; Copyright (c) 2009 Mike Enriquez, http://theezpzway.com; Released under the MIT License
+(function($){$.fn.ezpz_tooltip=function(options){var settings=$.extend({},$.fn.ezpz_tooltip.defaults,options);return this.each(function(){var content=$("#"+getContentId(this.id));var targetMousedOver=$(this).mouseover(function(){settings.beforeShow(content,$(this))}).mousemove(function(e){contentInfo=getElementDimensionsAndPosition(content);targetInfo=getElementDimensionsAndPosition($(this));contentInfo=$.fn.ezpz_tooltip.positions[settings.contentPosition](contentInfo,e.pageX,e.pageY,settings.offset,targetInfo);contentInfo=keepInWindow(contentInfo);content.css('top',contentInfo['top']);content.css('left',contentInfo['left']);settings.showContent(content)});if(settings.stayOnContent&&this.id!=""){$("#"+this.id+", #"+getContentId(this.id)).mouseover(function(){content.css('display','block')}).mouseout(function(){content.css('display','none');settings.afterHide()})}else{targetMousedOver.mouseout(function(){settings.hideContent(content);settings.afterHide()})}});function getContentId(targetId){if(settings.contentId==""){var name=targetId.split('-')[0];var id=targetId.split('-')[2];return name+'-content-'+id}else{return settings.contentId}};function getElementDimensionsAndPosition(element){var height=element.outerHeight(true);var width=element.outerWidth(true);var top=$(element).offset().top;var left=$(element).offset().left;var info=new Array();info['height']=height;info['width']=width;info['top']=top;info['left']=left;return info};function keepInWindow(contentInfo){var windowWidth=$(window).width();var windowTop=$(window).scrollTop();var output=new Array();output=contentInfo;if(contentInfo['top']<windowTop){output['top']=windowTop}if((contentInfo['left']+contentInfo['width'])>windowWidth){output['left']=windowWidth-contentInfo['width']}if(contentInfo['left']<0){output['left']=0}return output}};$.fn.ezpz_tooltip.positionContent=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=mouseY-offset-contentInfo['height'];contentInfo['left']=mouseX+offset;return contentInfo};$.fn.ezpz_tooltip.positions={aboveRightFollow:function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=mouseY-offset-contentInfo['height'];contentInfo['left']=mouseX+offset;return contentInfo}};$.fn.ezpz_tooltip.defaults={contentPosition:'aboveRightFollow',stayOnContent:false,offset:10,contentId:"",beforeShow:function(content){},showContent:function(content){content.show()},hideContent:function(content){content.hide()},afterHide:function(){}}})(jQuery);(function($){$.fn.ezpz_tooltip.positions.aboveFollow=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=mouseY-offset-contentInfo['height'];contentInfo['left']=mouseX-(contentInfo['width']/2);return contentInfo};$.fn.ezpz_tooltip.positions.rightFollow=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=mouseY-(contentInfo['height']/2);contentInfo['left']=mouseX+offset;return contentInfo};$.fn.ezpz_tooltip.positions.belowRightFollow=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=mouseY+offset;contentInfo['left']=mouseX+offset;return contentInfo};$.fn.ezpz_tooltip.positions.belowFollow=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=mouseY+offset;contentInfo['left']=mouseX-(contentInfo['width']/2);return contentInfo};$.fn.ezpz_tooltip.positions.aboveStatic=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=targetInfo['top']-offset-contentInfo['height'];contentInfo['left']=(targetInfo['left']+(targetInfo['width']/2))-(contentInfo['width']/2);return contentInfo};$.fn.ezpz_tooltip.positions.rightStatic=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=(targetInfo['top']+(targetInfo['height']/2))-(contentInfo['height']/2);contentInfo['left']=targetInfo['left']+targetInfo['width']+offset;return contentInfo};$.fn.ezpz_tooltip.positions.belowStatic=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=targetInfo['top']+targetInfo['height']+offset;contentInfo['left']=(targetInfo['left']+(targetInfo['width']/2))-(contentInfo['width']/2);return contentInfo}})(jQuery);
\ No newline at end of file
diff --git a/system/application/views/group/add.php b/system/application/views/group/add.php
index 49899a8..e6a91b9 100644
--- a/system/application/views/group/add.php
+++ b/system/application/views/group/add.php
@@ -27,7 +27,10 @@ $(document).ready(function() {
echo "</p>";
echo "<p class=\"affects-gross\">";
+ echo "<span id=\"tooltip-target-1\">";
echo form_checkbox('affects_gross', 1, $affects_gross) . " Affects Gross Profit/Loss Calculations";
+ echo "</span>";
+ echo "<span id=\"tooltip-content-1\">If selected the Group A/C will affect Gross Profit and Loss calculations, otherwise it will affect only Net Profit and Loss calculations.</span>";
echo "</p>";
echo "<p>";
@@ -37,4 +40,3 @@ $(document).ready(function() {
echo "</p>";
echo form_close();
-
diff --git a/system/application/views/template.php b/system/application/views/template.php
index b93b659..8683afb 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -30,6 +30,7 @@ if (isset($add_css))
<script type="text/javascript" src="<?php echo asset_url(); ?>js/superfish.js"></script>
<script type="text/javascript" src="<?php echo asset_url(); ?>js/supersubs.js"></script>
<script type="text/javascript" src="<?php echo asset_url(); ?>js/thickbox-compressed.js"></script>
+<script type="text/javascript" src="<?php echo asset_url(); ?>js/ezpz_tooltip.min.js"></script>
<?php
/* Dynamically adding javascript files from controllers */
commit 326671139eaefabb272a4d1da2b44256b53b406a
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Dec 22 16:10:33 2010 +0530
Edit tag uses the new jQuery color picker
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 50180fb..a9cfc79 100644
--- a/system/application/controllers/tag.php
+++ b/system/application/controllers/tag.php
@@ -107,6 +107,19 @@ class Tag extends Controller {
function edit($id = 0)
{
$this->template->set('page_title', 'Edit Tag');
+
+ /* Colorpicker JS and CSS */
+ $this->template->set('add_css', array(
+ "plugins/colorpicker/css/colorpicker.css",
+ ));
+
+ $this->template->set('add_javascript', array(
+ "plugins/colorpicker/js/colorpicker.js",
+ "plugins/colorpicker/js/eye.js",
+ "plugins/colorpicker/js/utils.js",
+ "plugins/colorpicker/js/layout.js",
+ "plugins/colorpicker/js/startup.js",
+ ));
/* Checking for valid data */
$id = $this->input->xss_clean($id);
diff --git a/system/application/views/tag/edit.php b/system/application/views/tag/edit.php
index 7709d48..b1afaf4 100644
--- a/system/application/views/tag/edit.php
+++ b/system/application/views/tag/edit.php
@@ -11,12 +11,16 @@
echo form_label('Tag Color', 'tag_color');
echo "<br />";
echo "#" . form_input($tag_color);
+ echo "   ";
+ echo "<span id=\"preview_tag_color\" style=\"padding:3px 20px 3px 20px;\"></span>";
echo "</p>";
echo "<p>";
echo form_label('Background Color', 'tag_background');
echo "<br />";
echo "#" . form_input($tag_background);
+ echo "   ";
+ echo "<span id=\"preview_tag_background\" style=\"padding:3px 20px 3px 20px;\"></span>";
echo "</p>";
echo "<p>";
commit 97be020f83da569252257b0fdff67976aefdafba
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Dec 22 16:05:50 2010 +0530
Added jQuery Color Picker plugin
http://www.eyecon.ro/colorpicker/
Dual licensed under the MIT and GPL licenses.
- Add tag uses the color picker
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/assets/plugins/colorpicker/css/colorpicker.css b/system/application/assets/plugins/colorpicker/css/colorpicker.css
new file mode 100644
index 0000000..05b02b4
--- /dev/null
+++ b/system/application/assets/plugins/colorpicker/css/colorpicker.css
@@ -0,0 +1,161 @@
+.colorpicker {
+ width: 356px;
+ height: 176px;
+ overflow: hidden;
+ position: absolute;
+ background: url(../images/colorpicker_background.png);
+ font-family: Arial, Helvetica, sans-serif;
+ display: none;
+}
+.colorpicker_color {
+ width: 150px;
+ height: 150px;
+ left: 14px;
+ top: 13px;
+ position: absolute;
+ background: #f00;
+ overflow: hidden;
+ cursor: crosshair;
+}
+.colorpicker_color div {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 150px;
+ height: 150px;
+ background: url(../images/colorpicker_overlay.png);
+}
+.colorpicker_color div div {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 11px;
+ height: 11px;
+ overflow: hidden;
+ background: url(../images/colorpicker_select.gif);
+ margin: -5px 0 0 -5px;
+}
+.colorpicker_hue {
+ position: absolute;
+ top: 13px;
+ left: 171px;
+ width: 35px;
+ height: 150px;
+ cursor: n-resize;
+}
+.colorpicker_hue div {
+ position: absolute;
+ width: 35px;
+ height: 9px;
+ overflow: hidden;
+ background: url(../images/colorpicker_indic.gif) left top;
+ margin: -4px 0 0 0;
+ left: 0px;
+}
+.colorpicker_new_color {
+ position: absolute;
+ width: 60px;
+ height: 30px;
+ left: 213px;
+ top: 13px;
+ background: #f00;
+}
+.colorpicker_current_color {
+ position: absolute;
+ width: 60px;
+ height: 30px;
+ left: 283px;
+ top: 13px;
+ background: #f00;
+}
+.colorpicker input {
+ background-color: transparent;
+ border: 1px solid transparent;
+ position: absolute;
+ font-size: 10px;
+ font-family: Arial, Helvetica, sans-serif;
+ color: #898989;
+ top: 4px;
+ right: 11px;
+ text-align: right;
+ margin: 0;
+ padding: 0;
+ height: 11px;
+}
+.colorpicker_hex {
+ position: absolute;
+ width: 72px;
+ height: 22px;
+ background: url(../images/colorpicker_hex.png) top;
+ left: 212px;
+ top: 142px;
+}
+.colorpicker_hex input {
+ right: 6px;
+}
+.colorpicker_field {
+ height: 22px;
+ width: 62px;
+ background-position: top;
+ position: absolute;
+}
+.colorpicker_field span {
+ position: absolute;
+ width: 12px;
+ height: 22px;
+ overflow: hidden;
+ top: 0;
+ right: 0;
+ cursor: n-resize;
+}
+.colorpicker_rgb_r {
+ background-image: url(../images/colorpicker_rgb_r.png);
+ top: 52px;
+ left: 212px;
+}
+.colorpicker_rgb_g {
+ background-image: url(../images/colorpicker_rgb_g.png);
+ top: 82px;
+ left: 212px;
+}
+.colorpicker_rgb_b {
+ background-image: url(../images/colorpicker_rgb_b.png);
+ top: 112px;
+ left: 212px;
+}
+.colorpicker_hsb_h {
+ background-image: url(../images/colorpicker_hsb_h.png);
+ top: 52px;
+ left: 282px;
+}
+.colorpicker_hsb_s {
+ background-image: url(../images/colorpicker_hsb_s.png);
+ top: 82px;
+ left: 282px;
+}
+.colorpicker_hsb_b {
+ background-image: url(../images/colorpicker_hsb_b.png);
+ top: 112px;
+ left: 282px;
+}
+.colorpicker_submit {
+ position: absolute;
+ width: 22px;
+ height: 22px;
+ background: url(../images/colorpicker_submit.png) top;
+ left: 322px;
+ top: 142px;
+ overflow: hidden;
+}
+.colorpicker_focus {
+ background-position: center;
+}
+.colorpicker_hex.colorpicker_focus {
+ background-position: bottom;
+}
+.colorpicker_submit.colorpicker_focus {
+ background-position: bottom;
+}
+.colorpicker_slider {
+ background-position: bottom;
+}
diff --git a/system/application/assets/plugins/colorpicker/css/layout.css b/system/application/assets/plugins/colorpicker/css/layout.css
new file mode 100644
index 0000000..8b3f00f
--- /dev/null
+++ b/system/application/assets/plugins/colorpicker/css/layout.css
@@ -0,0 +1,218 @@
+body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
+ margin:0;
+ padding:0;
+}
+table {
+ border-collapse:collapse;
+ border-spacing:0;
+}
+fieldset,img {
+ border:0;
+}
+address,caption,cite,code,dfn,em,strong,th,var {
+ font-style:normal;
+ font-weight:normal;
+}
+ol,ul {
+ list-style:none;
+}
+caption,th {
+ text-align:left;
+}
+h1,h2,h3,h4,h5,h6 {
+ font-size:100%;
+ font-weight:normal;
+}
+q:before,q:after {
+ content:'';
+}
+abbr,acronym { border:0;
+}
+html, body {
+ background-color: #fff;
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 12px;
+ line-height: 18px;
+ color: #52697E;
+}
+body {
+ text-align: center;
+ overflow: auto;
+}
+.wrapper {
+ width: 700px;
+ margin: 0 auto;
+ text-align: left;
+}
+h1 {
+ font-size: 21px;
+ height: 47px;
+ line-height: 47px;
+ text-transform: uppercase;
+}
+.navigationTabs {
+ height: 23px;
+ line-height: 23px;
+ border-bottom: 1px solid #ccc;
+}
+.navigationTabs li {
+ float: left;
+ height: 23px;
+ line-height: 23px;
+ padding-right: 3px;
+}
+.navigationTabs li a{
+ float: left;
+ dispaly: block;
+ height: 23px;
+ line-height: 23px;
+ padding: 0 10px;
+ overflow: hidden;
+ color: #52697E;
+ background-color: #eee;
+ position: relative;
+ text-decoration: none;
+}
+.navigationTabs li a:hover {
+ background-color: #f0f0f0;
+}
+.navigationTabs li a.active {
+ background-color: #fff;
+ border: 1px solid #ccc;
+ border-bottom: 0px solid;
+}
+.tabsContent {
+ border: 1px solid #ccc;
+ border-top: 0px solid;
+ width: 698px;
+ overflow: hidden;
+}
+.tab {
+ padding: 16px;
+ display: none;
+}
+.tab h2 {
+ font-weight: bold;
+ font-size: 16px;
+}
+.tab h3 {
+ font-weight: bold;
+ font-size: 14px;
+ margin-top: 20px;
+}
+.tab p {
+ margin-top: 16px;
+ clear: both;
+}
+.tab ul {
+ margin-top: 16px;
+ list-style: disc;
+}
+.tab li {
+ margin: 10px 0 0 35px;
+}
+.tab a {
+ color: #8FB0CF;
+}
+.tab strong {
+ font-weight: bold;
+}
+.tab pre {
+ font-size: 11px;
+ margin-top: 20px;
+ width: 668px;
+ overflow: auto;
+ clear: both;
+}
+.tab table {
+ width: 100%;
+}
+.tab table td {
+ padding: 6px 10px 6px 0;
+ vertical-align: top;
+}
+.tab dt {
+ margin-top: 16px;
+}
+
+#colorSelector {
+ position: relative;
+ width: 36px;
+ height: 36px;
+ background: url(../images/select.png);
+}
+#colorSelector div {
+ position: absolute;
+ top: 3px;
+ left: 3px;
+ width: 30px;
+ height: 30px;
+ background: url(../images/select.png) center;
+}
+#colorSelector2 {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 36px;
+ height: 36px;
+ background: url(../images/select2.png);
+}
+#colorSelector2 div {
+ position: absolute;
+ top: 4px;
+ left: 4px;
+ width: 28px;
+ height: 28px;
+ background: url(../images/select2.png) center;
+}
+#colorpickerHolder2 {
+ top: 32px;
+ left: 0;
+ width: 356px;
+ height: 0;
+ overflow: hidden;
+ position: absolute;
+}
+#colorpickerHolder2 .colorpicker {
+ background-image: url(../images/custom_background.png);
+ position: absolute;
+ bottom: 0;
+ left: 0;
+}
+#colorpickerHolder2 .colorpicker_hue div {
+ background-image: url(../images/custom_indic.gif);
+}
+#colorpickerHolder2 .colorpicker_hex {
+ background-image: url(../images/custom_hex.png);
+}
+#colorpickerHolder2 .colorpicker_rgb_r {
+ background-image: url(../images/custom_rgb_r.png);
+}
+#colorpickerHolder2 .colorpicker_rgb_g {
+ background-image: url(../images/custom_rgb_g.png);
+}
+#colorpickerHolder2 .colorpicker_rgb_b {
+ background-image: url(../images/custom_rgb_b.png);
+}
+#colorpickerHolder2 .colorpicker_hsb_s {
+ background-image: url(../images/custom_hsb_s.png);
+ display: none;
+}
+#colorpickerHolder2 .colorpicker_hsb_h {
+ background-image: url(../images/custom_hsb_h.png);
+ display: none;
+}
+#colorpickerHolder2 .colorpicker_hsb_b {
+ background-image: url(../images/custom_hsb_b.png);
+ display: none;
+}
+#colorpickerHolder2 .colorpicker_submit {
+ background-image: url(../images/custom_submit.png);
+}
+#colorpickerHolder2 .colorpicker input {
+ color: #778398;
+}
+#customWidget {
+ position: relative;
+ height: 36px;
+}
diff --git a/system/application/assets/plugins/colorpicker/images/blank.gif b/system/application/assets/plugins/colorpicker/images/blank.gif
new file mode 100644
index 0000000..75b945d
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/blank.gif differ
diff --git a/system/application/assets/plugins/colorpicker/images/colorpicker_background.png b/system/application/assets/plugins/colorpicker/images/colorpicker_background.png
new file mode 100644
index 0000000..8401572
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/colorpicker_background.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/colorpicker_hex.png b/system/application/assets/plugins/colorpicker/images/colorpicker_hex.png
new file mode 100644
index 0000000..4e532d7
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/colorpicker_hex.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/colorpicker_hsb_b.png b/system/application/assets/plugins/colorpicker/images/colorpicker_hsb_b.png
new file mode 100644
index 0000000..dfac595
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/colorpicker_hsb_b.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/colorpicker_hsb_h.png b/system/application/assets/plugins/colorpicker/images/colorpicker_hsb_h.png
new file mode 100644
index 0000000..3977ed9
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/colorpicker_hsb_h.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/colorpicker_hsb_s.png b/system/application/assets/plugins/colorpicker/images/colorpicker_hsb_s.png
new file mode 100644
index 0000000..a2a6997
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/colorpicker_hsb_s.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/colorpicker_indic.gif b/system/application/assets/plugins/colorpicker/images/colorpicker_indic.gif
new file mode 100644
index 0000000..f9fa95e
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/colorpicker_indic.gif differ
diff --git a/system/application/assets/plugins/colorpicker/images/colorpicker_overlay.png b/system/application/assets/plugins/colorpicker/images/colorpicker_overlay.png
new file mode 100644
index 0000000..561cdd9
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/colorpicker_overlay.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/colorpicker_rgb_b.png b/system/application/assets/plugins/colorpicker/images/colorpicker_rgb_b.png
new file mode 100644
index 0000000..dfac595
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/colorpicker_rgb_b.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/colorpicker_rgb_g.png b/system/application/assets/plugins/colorpicker/images/colorpicker_rgb_g.png
new file mode 100644
index 0000000..72b3276
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/colorpicker_rgb_g.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/colorpicker_rgb_r.png b/system/application/assets/plugins/colorpicker/images/colorpicker_rgb_r.png
new file mode 100644
index 0000000..4855fe0
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/colorpicker_rgb_r.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/colorpicker_select.gif b/system/application/assets/plugins/colorpicker/images/colorpicker_select.gif
new file mode 100644
index 0000000..599f7f1
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/colorpicker_select.gif differ
diff --git a/system/application/assets/plugins/colorpicker/images/colorpicker_submit.png b/system/application/assets/plugins/colorpicker/images/colorpicker_submit.png
new file mode 100644
index 0000000..7f4c082
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/colorpicker_submit.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/custom_background.png b/system/application/assets/plugins/colorpicker/images/custom_background.png
new file mode 100644
index 0000000..cf55ffd
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/custom_background.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/custom_hex.png b/system/application/assets/plugins/colorpicker/images/custom_hex.png
new file mode 100644
index 0000000..888f444
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/custom_hex.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/custom_hsb_b.png b/system/application/assets/plugins/colorpicker/images/custom_hsb_b.png
new file mode 100644
index 0000000..2f99dae
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/custom_hsb_b.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/custom_hsb_h.png b/system/application/assets/plugins/colorpicker/images/custom_hsb_h.png
new file mode 100644
index 0000000..a217e92
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/custom_hsb_h.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/custom_hsb_s.png b/system/application/assets/plugins/colorpicker/images/custom_hsb_s.png
new file mode 100644
index 0000000..7826b41
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/custom_hsb_s.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/custom_indic.gif b/system/application/assets/plugins/colorpicker/images/custom_indic.gif
new file mode 100644
index 0000000..222fb94
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/custom_indic.gif differ
diff --git a/system/application/assets/plugins/colorpicker/images/custom_rgb_b.png b/system/application/assets/plugins/colorpicker/images/custom_rgb_b.png
new file mode 100644
index 0000000..80764e5
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/custom_rgb_b.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/custom_rgb_g.png b/system/application/assets/plugins/colorpicker/images/custom_rgb_g.png
new file mode 100644
index 0000000..fc9778b
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/custom_rgb_g.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/custom_rgb_r.png b/system/application/assets/plugins/colorpicker/images/custom_rgb_r.png
new file mode 100644
index 0000000..91b0cd4
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/custom_rgb_r.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/custom_submit.png b/system/application/assets/plugins/colorpicker/images/custom_submit.png
new file mode 100644
index 0000000..cd202cd
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/custom_submit.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/select.png b/system/application/assets/plugins/colorpicker/images/select.png
new file mode 100644
index 0000000..21213bf
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/select.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/select2.png b/system/application/assets/plugins/colorpicker/images/select2.png
new file mode 100644
index 0000000..2cd2cab
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/select2.png differ
diff --git a/system/application/assets/plugins/colorpicker/images/slider.png b/system/application/assets/plugins/colorpicker/images/slider.png
new file mode 100644
index 0000000..8b03da9
Binary files /dev/null and b/system/application/assets/plugins/colorpicker/images/slider.png differ
diff --git a/system/application/assets/plugins/colorpicker/js/colorpicker.js b/system/application/assets/plugins/colorpicker/js/colorpicker.js
new file mode 100644
index 0000000..10a2b22
--- /dev/null
+++ b/system/application/assets/plugins/colorpicker/js/colorpicker.js
@@ -0,0 +1,484 @@
+/**
+ *
+ * Color picker
+ * Author: Stefan Petre www.eyecon.ro
+ *
+ * Dual licensed under the MIT and GPL licenses
+ *
+ */
+(function ($) {
+ var ColorPicker = function () {
+ var
+ ids = {},
+ inAction,
+ charMin = 65,
+ visible,
+ tpl = '<div class="colorpicker"><div class="colorpicker_color"><div><div></div></div></div><div class="colorpicker_hue"><div></div></div><div class="colorpicker_new_color"></div><div class="colorpicker_current_color"></div><div class="colorpicker_hex"><input type="text" maxlength="6" size="6" /></div><div class="colorpicker_rgb_r colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_g colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_h colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_s colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_submit"></div></div>',
+ defaults = {
+ eventName: 'click',
+ onShow: function () {},
+ onBeforeShow: function(){},
+ onHide: function () {},
+ onChange: function () {},
+ onSubmit: function () {},
+ color: 'ff0000',
+ livePreview: true,
+ flat: false
+ },
+ fillRGBFields = function (hsb, cal) {
+ var rgb = HSBToRGB(hsb);
+ $(cal).data('colorpicker').fields
+ .eq(1).val(rgb.r).end()
+ .eq(2).val(rgb.g).end()
+ .eq(3).val(rgb.b).end();
+ },
+ fillHSBFields = function (hsb, cal) {
+ $(cal).data('colorpicker').fields
+ .eq(4).val(hsb.h).end()
+ .eq(5).val(hsb.s).end()
+ .eq(6).val(hsb.b).end();
+ },
+ fillHexFields = function (hsb, cal) {
+ $(cal).data('colorpicker').fields
+ .eq(0).val(HSBToHex(hsb)).end();
+ },
+ setSelector = function (hsb, cal) {
+ $(cal).data('colorpicker').selector.css('backgroundColor', '#' + HSBToHex({h: hsb.h, s: 100, b: 100}));
+ $(cal).data('colorpicker').selectorIndic.css({
+ left: parseInt(150 * hsb.s/100, 10),
+ top: parseInt(150 * (100-hsb.b)/100, 10)
+ });
+ },
+ setHue = function (hsb, cal) {
+ $(cal).data('colorpicker').hue.css('top', parseInt(150 - 150 * hsb.h/360, 10));
+ },
+ setCurrentColor = function (hsb, cal) {
+ $(cal).data('colorpicker').currentColor.css('backgroundColor', '#' + HSBToHex(hsb));
+ },
+ setNewColor = function (hsb, cal) {
+ $(cal).data('colorpicker').newColor.css('backgroundColor', '#' + HSBToHex(hsb));
+ },
+ keyDown = function (ev) {
+ var pressedKey = ev.charCode || ev.keyCode || -1;
+ if ((pressedKey > charMin && pressedKey <= 90) || pressedKey == 32) {
+ return false;
+ }
+ var cal = $(this).parent().parent();
+ if (cal.data('colorpicker').livePreview === true) {
+ change.apply(this);
+ }
+ },
+ change = function (ev) {
+ var cal = $(this).parent().parent(), col;
+ if (this.parentNode.className.indexOf('_hex') > 0) {
+ cal.data('colorpicker').color = col = HexToHSB(fixHex(this.value));
+ } else if (this.parentNode.className.indexOf('_hsb') > 0) {
+ cal.data('colorpicker').color = col = fixHSB({
+ h: parseInt(cal.data('colorpicker').fields.eq(4).val(), 10),
+ s: parseInt(cal.data('colorpicker').fields.eq(5).val(), 10),
+ b: parseInt(cal.data('colorpicker').fields.eq(6).val(), 10)
+ });
+ } else {
+ cal.data('colorpicker').color = col = RGBToHSB(fixRGB({
+ r: parseInt(cal.data('colorpicker').fields.eq(1).val(), 10),
+ g: parseInt(cal.data('colorpicker').fields.eq(2).val(), 10),
+ b: parseInt(cal.data('colorpicker').fields.eq(3).val(), 10)
+ }));
+ }
+ if (ev) {
+ fillRGBFields(col, cal.get(0));
+ fillHexFields(col, cal.get(0));
+ fillHSBFields(col, cal.get(0));
+ }
+ setSelector(col, cal.get(0));
+ setHue(col, cal.get(0));
+ setNewColor(col, cal.get(0));
+ cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col)]);
+ },
+ blur = function (ev) {
+ var cal = $(this).parent().parent();
+ cal.data('colorpicker').fields.parent().removeClass('colorpicker_focus');
+ },
+ focus = function () {
+ charMin = this.parentNode.className.indexOf('_hex') > 0 ? 70 : 65;
+ $(this).parent().parent().data('colorpicker').fields.parent().removeClass('colorpicker_focus');
+ $(this).parent().addClass('colorpicker_focus');
+ },
+ downIncrement = function (ev) {
+ var field = $(this).parent().find('input').focus();
+ var current = {
+ el: $(this).parent().addClass('colorpicker_slider'),
+ max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
+ y: ev.pageY,
+ field: field,
+ val: parseInt(field.val(), 10),
+ preview: $(this).parent().parent().data('colorpicker').livePreview
+ };
+ $(document).bind('mouseup', current, upIncrement);
+ $(document).bind('mousemove', current, moveIncrement);
+ },
+ moveIncrement = function (ev) {
+ ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val + ev.pageY - ev.data.y, 10))));
+ if (ev.data.preview) {
+ change.apply(ev.data.field.get(0), [true]);
+ }
+ return false;
+ },
+ upIncrement = function (ev) {
+ change.apply(ev.data.field.get(0), [true]);
+ ev.data.el.removeClass('colorpicker_slider').find('input').focus();
+ $(document).unbind('mouseup', upIncrement);
+ $(document).unbind('mousemove', moveIncrement);
+ return false;
+ },
+ downHue = function (ev) {
+ var current = {
+ cal: $(this).parent(),
+ y: $(this).offset().top
+ };
+ current.preview = current.cal.data('colorpicker').livePreview;
+ $(document).bind('mouseup', current, upHue);
+ $(document).bind('mousemove', current, moveHue);
+ },
+ moveHue = function (ev) {
+ change.apply(
+ ev.data.cal.data('colorpicker')
+ .fields
+ .eq(4)
+ .val(parseInt(360*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.y))))/150, 10))
+ .get(0),
+ [ev.data.preview]
+ );
+ return false;
+ },
+ upHue = function (ev) {
+ fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
+ fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
+ $(document).unbind('mouseup', upHue);
+ $(document).unbind('mousemove', moveHue);
+ return false;
+ },
+ downSelector = function (ev) {
+ var current = {
+ cal: $(this).parent(),
+ pos: $(this).offset()
+ };
+ current.preview = current.cal.data('colorpicker').livePreview;
+ $(document).bind('mouseup', current, upSelector);
+ $(document).bind('mousemove', current, moveSelector);
+ },
+ moveSelector = function (ev) {
+ change.apply(
+ ev.data.cal.data('colorpicker')
+ .fields
+ .eq(6)
+ .val(parseInt(100*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.pos.top))))/150, 10))
+ .end()
+ .eq(5)
+ .val(parseInt(100*(Math.max(0,Math.min(150,(ev.pageX - ev.data.pos.left))))/150, 10))
+ .get(0),
+ [ev.data.preview]
+ );
+ return false;
+ },
+ upSelector = function (ev) {
+ fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
+ fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
+ $(document).unbind('mouseup', upSelector);
+ $(document).unbind('mousemove', moveSelector);
+ return false;
+ },
+ enterSubmit = function (ev) {
+ $(this).addClass('colorpicker_focus');
+ },
+ leaveSubmit = function (ev) {
+ $(this).removeClass('colorpicker_focus');
+ },
+ clickSubmit = function (ev) {
+ var cal = $(this).parent();
+ var col = cal.data('colorpicker').color;
+ cal.data('colorpicker').origColor = col;
+ setCurrentColor(col, cal.get(0));
+ cal.data('colorpicker').onSubmit(col, HSBToHex(col), HSBToRGB(col), cal.data('colorpicker').el);
+ },
+ show = function (ev) {
+ var cal = $('#' + $(this).data('colorpickerId'));
+ cal.data('colorpicker').onBeforeShow.apply(this, [cal.get(0)]);
+ var pos = $(this).offset();
+ var viewPort = getViewport();
+ var top = pos.top + this.offsetHeight;
+ var left = pos.left;
+ if (top + 176 > viewPort.t + viewPort.h) {
+ top -= this.offsetHeight + 176;
+ }
+ if (left + 356 > viewPort.l + viewPort.w) {
+ left -= 356;
+ }
+ cal.css({left: left + 'px', top: top + 'px'});
+ if (cal.data('colorpicker').onShow.apply(this, [cal.get(0)]) != false) {
+ cal.show();
+ }
+ $(document).bind('mousedown', {cal: cal}, hide);
+ return false;
+ },
+ hide = function (ev) {
+ if (!isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
+ if (ev.data.cal.data('colorpicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
+ ev.data.cal.hide();
+ }
+ $(document).unbind('mousedown', hide);
+ }
+ },
+ isChildOf = function(parentEl, el, container) {
+ if (parentEl == el) {
+ return true;
+ }
+ if (parentEl.contains) {
+ return parentEl.contains(el);
+ }
+ if ( parentEl.compareDocumentPosition ) {
+ return !!(parentEl.compareDocumentPosition(el) & 16);
+ }
+ var prEl = el.parentNode;
+ while(prEl && prEl != container) {
+ if (prEl == parentEl)
+ return true;
+ prEl = prEl.parentNode;
+ }
+ return false;
+ },
+ getViewport = function () {
+ var m = document.compatMode == 'CSS1Compat';
+ return {
+ l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
+ t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
+ w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
+ h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
+ };
+ },
+ fixHSB = function (hsb) {
+ return {
+ h: Math.min(360, Math.max(0, hsb.h)),
+ s: Math.min(100, Math.max(0, hsb.s)),
+ b: Math.min(100, Math.max(0, hsb.b))
+ };
+ },
+ fixRGB = function (rgb) {
+ return {
+ r: Math.min(255, Math.max(0, rgb.r)),
+ g: Math.min(255, Math.max(0, rgb.g)),
+ b: Math.min(255, Math.max(0, rgb.b))
+ };
+ },
+ fixHex = function (hex) {
+ var len = 6 - hex.length;
+ if (len > 0) {
+ var o = [];
+ for (var i=0; i<len; i++) {
+ o.push('0');
+ }
+ o.push(hex);
+ hex = o.join('');
+ }
+ return hex;
+ },
+ HexToRGB = function (hex) {
+ var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
+ return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
+ },
+ HexToHSB = function (hex) {
+ return RGBToHSB(HexToRGB(hex));
+ },
+ RGBToHSB = function (rgb) {
+ var hsb = {
+ h: 0,
+ s: 0,
+ b: 0
+ };
+ var min = Math.min(rgb.r, rgb.g, rgb.b);
+ var max = Math.max(rgb.r, rgb.g, rgb.b);
+ var delta = max - min;
+ hsb.b = max;
+ if (max != 0) {
+
+ }
+ hsb.s = max != 0 ? 255 * delta / max : 0;
+ if (hsb.s != 0) {
+ if (rgb.r == max) {
+ hsb.h = (rgb.g - rgb.b) / delta;
+ } else if (rgb.g == max) {
+ hsb.h = 2 + (rgb.b - rgb.r) / delta;
+ } else {
+ hsb.h = 4 + (rgb.r - rgb.g) / delta;
+ }
+ } else {
+ hsb.h = -1;
+ }
+ hsb.h *= 60;
+ if (hsb.h < 0) {
+ hsb.h += 360;
+ }
+ hsb.s *= 100/255;
+ hsb.b *= 100/255;
+ return hsb;
+ },
+ HSBToRGB = function (hsb) {
+ var rgb = {};
+ var h = Math.round(hsb.h);
+ var s = Math.round(hsb.s*255/100);
+ var v = Math.round(hsb.b*255/100);
+ if(s == 0) {
+ rgb.r = rgb.g = rgb.b = v;
+ } else {
+ var t1 = v;
+ var t2 = (255-s)*v/255;
+ var t3 = (t1-t2)*(h%60)/60;
+ if(h==360) h = 0;
+ if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
+ else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
+ else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
+ else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
+ else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
+ else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
+ else {rgb.r=0; rgb.g=0; rgb.b=0}
+ }
+ return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
+ },
+ RGBToHex = function (rgb) {
+ var hex = [
+ rgb.r.toString(16),
+ rgb.g.toString(16),
+ rgb.b.toString(16)
+ ];
+ $.each(hex, function (nr, val) {
+ if (val.length == 1) {
+ hex[nr] = '0' + val;
+ }
+ });
+ return hex.join('');
+ },
+ HSBToHex = function (hsb) {
+ return RGBToHex(HSBToRGB(hsb));
+ },
+ restoreOriginal = function () {
+ var cal = $(this).parent();
+ var col = cal.data('colorpicker').origColor;
+ cal.data('colorpicker').color = col;
+ fillRGBFields(col, cal.get(0));
+ fillHexFields(col, cal.get(0));
+ fillHSBFields(col, cal.get(0));
+ setSelector(col, cal.get(0));
+ setHue(col, cal.get(0));
+ setNewColor(col, cal.get(0));
+ };
+ return {
+ init: function (opt) {
+ opt = $.extend({}, defaults, opt||{});
+ if (typeof opt.color == 'string') {
+ opt.color = HexToHSB(opt.color);
+ } else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
+ opt.color = RGBToHSB(opt.color);
+ } else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) {
+ opt.color = fixHSB(opt.color);
+ } else {
+ return this;
+ }
+ return this.each(function () {
+ if (!$(this).data('colorpickerId')) {
+ var options = $.extend({}, opt);
+ options.origColor = opt.color;
+ var id = 'collorpicker_' + parseInt(Math.random() * 1000);
+ $(this).data('colorpickerId', id);
+ var cal = $(tpl).attr('id', id);
+ if (options.flat) {
+ cal.appendTo(this).show();
+ } else {
+ cal.appendTo(document.body);
+ }
+ options.fields = cal
+ .find('input')
+ .bind('keyup', keyDown)
+ .bind('change', change)
+ .bind('blur', blur)
+ .bind('focus', focus);
+ cal
+ .find('span').bind('mousedown', downIncrement).end()
+ .find('>div.colorpicker_current_color').bind('click', restoreOriginal);
+ options.selector = cal.find('div.colorpicker_color').bind('mousedown', downSelector);
+ options.selectorIndic = options.selector.find('div div');
+ options.el = this;
+ options.hue = cal.find('div.colorpicker_hue div');
+ cal.find('div.colorpicker_hue').bind('mousedown', downHue);
+ options.newColor = cal.find('div.colorpicker_new_color');
+ options.currentColor = cal.find('div.colorpicker_current_color');
+ cal.data('colorpicker', options);
+ cal.find('div.colorpicker_submit')
+ .bind('mouseenter', enterSubmit)
+ .bind('mouseleave', leaveSubmit)
+ .bind('click', clickSubmit);
+ fillRGBFields(options.color, cal.get(0));
+ fillHSBFields(options.color, cal.get(0));
+ fillHexFields(options.color, cal.get(0));
+ setHue(options.color, cal.get(0));
+ setSelector(options.color, cal.get(0));
+ setCurrentColor(options.color, cal.get(0));
+ setNewColor(options.color, cal.get(0));
+ if (options.flat) {
+ cal.css({
+ position: 'relative',
+ display: 'block'
+ });
+ } else {
+ $(this).bind(options.eventName, show);
+ }
+ }
+ });
+ },
+ showPicker: function() {
+ return this.each( function () {
+ if ($(this).data('colorpickerId')) {
+ show.apply(this);
+ }
+ });
+ },
+ hidePicker: function() {
+ return this.each( function () {
+ if ($(this).data('colorpickerId')) {
+ $('#' + $(this).data('colorpickerId')).hide();
+ }
+ });
+ },
+ setColor: function(col) {
+ if (typeof col == 'string') {
+ col = HexToHSB(col);
+ } else if (col.r != undefined && col.g != undefined && col.b != undefined) {
+ col = RGBToHSB(col);
+ } else if (col.h != undefined && col.s != undefined && col.b != undefined) {
+ col = fixHSB(col);
+ } else {
+ return this;
+ }
+ return this.each(function(){
+ if ($(this).data('colorpickerId')) {
+ var cal = $('#' + $(this).data('colorpickerId'));
+ cal.data('colorpicker').color = col;
+ cal.data('colorpicker').origColor = col;
+ fillRGBFields(col, cal.get(0));
+ fillHSBFields(col, cal.get(0));
+ fillHexFields(col, cal.get(0));
+ setHue(col, cal.get(0));
+ setSelector(col, cal.get(0));
+ setCurrentColor(col, cal.get(0));
+ setNewColor(col, cal.get(0));
+ }
+ });
+ }
+ };
+ }();
+ $.fn.extend({
+ ColorPicker: ColorPicker.init,
+ ColorPickerHide: ColorPicker.hidePicker,
+ ColorPickerShow: ColorPicker.showPicker,
+ ColorPickerSetColor: ColorPicker.setColor
+ });
+})(jQuery)
\ No newline at end of file
diff --git a/system/application/assets/plugins/colorpicker/js/eye.js b/system/application/assets/plugins/colorpicker/js/eye.js
new file mode 100644
index 0000000..ea70e64
--- /dev/null
+++ b/system/application/assets/plugins/colorpicker/js/eye.js
@@ -0,0 +1,34 @@
+/**
+ *
+ * Zoomimage
+ * Author: Stefan Petre www.eyecon.ro
+ *
+ */
+(function($){
+ var EYE = window.EYE = function() {
+ var _registered = {
+ init: []
+ };
+ return {
+ init: function() {
+ $.each(_registered.init, function(nr, fn){
+ fn.call();
+ });
+ },
+ extend: function(prop) {
+ for (var i in prop) {
+ if (prop[i] != undefined) {
+ this[i] = prop[i];
+ }
+ }
+ },
+ register: function(fn, type) {
+ if (!_registered[type]) {
+ _registered[type] = [];
+ }
+ _registered[type].push(fn);
+ }
+ };
+ }();
+ $(EYE.init);
+})(jQuery);
diff --git a/system/application/assets/plugins/colorpicker/js/layout.js b/system/application/assets/plugins/colorpicker/js/layout.js
new file mode 100644
index 0000000..e0dfb8f
--- /dev/null
+++ b/system/application/assets/plugins/colorpicker/js/layout.js
@@ -0,0 +1,67 @@
+(function($){
+ var initLayout = function() {
+ var hash = window.location.hash.replace('#', '');
+ var currentTab = $('ul.navigationTabs a')
+ .bind('click', showTab)
+ .filter('a[rel=' + hash + ']');
+ if (currentTab.size() == 0) {
+ currentTab = $('ul.navigationTabs a:first');
+ }
+ showTab.apply(currentTab.get(0));
+ $('#colorpickerHolder').ColorPicker({flat: true});
+ $('#colorpickerHolder2').ColorPicker({
+ flat: true,
+ color: '#00ff00',
+ onSubmit: function(hsb, hex, rgb) {
+ $('#colorSelector2 div').css('backgroundColor', '#' + hex);
+ }
+ });
+ $('#colorpickerHolder2>div').css('position', 'absolute');
+ var widt = false;
+ $('#colorSelector2').bind('click', function() {
+ $('#colorpickerHolder2').stop().animate({height: widt ? 0 : 173}, 500);
+ widt = !widt;
+ });
+ $('#colorpickerField1, #colorpickerField2, #colorpickerField3').ColorPicker({
+ onSubmit: function(hsb, hex, rgb, el) {
+ $(el).val(hex);
+ $(el).ColorPickerHide();
+ },
+ onBeforeShow: function () {
+ $(this).ColorPickerSetColor(this.value);
+ }
+ })
+ .bind('keyup', function(){
+ $(this).ColorPickerSetColor(this.value);
+ });
+ $('#colorSelector').ColorPicker({
+ color: '#0000ff',
+ onShow: function (colpkr) {
+ $(colpkr).fadeIn(500);
+ return false;
+ },
+ onHide: function (colpkr) {
+ $(colpkr).fadeOut(500);
+ return false;
+ },
+ onChange: function (hsb, hex, rgb) {
+ $('#colorSelector div').css('backgroundColor', '#' + hex);
+ }
+ });
+ };
+
+ var showTab = function(e) {
+ var tabIndex = $('ul.navigationTabs a')
+ .removeClass('active')
+ .index(this);
+ $(this)
+ .addClass('active')
+ .blur();
+ $('div.tab')
+ .hide()
+ .eq(tabIndex)
+ .show();
+ };
+
+ EYE.register(initLayout, 'init');
+})(jQuery)
\ No newline at end of file
diff --git a/system/application/assets/plugins/colorpicker/js/startup.js b/system/application/assets/plugins/colorpicker/js/startup.js
new file mode 100644
index 0000000..7a19d9f
--- /dev/null
+++ b/system/application/assets/plugins/colorpicker/js/startup.js
@@ -0,0 +1,43 @@
+$(document).ready(function() {
+
+ /* Setting initial values */
+ var tag_col = $('#tag_color').val();
+ var background_col = $('#tag_background').val();
+ if (!tag_col) {
+ tag_col = "#" + "000000";
+ }
+ if (!background_col) {
+ background_col = "#" + "000000";
+ }
+
+ $('#tag_color').ColorPicker({
+ color: tag_col,
+ onShow: function (colpkr) {
+ $(colpkr).fadeIn(500);
+ return false;
+ },
+ onHide: function (colpkr) {
+ $(colpkr).fadeOut(500);
+ return false;
+ },
+ onChange: function (hsb, hex, rgb) {
+ $('#preview_tag_color').css('backgroundColor', '#' + hex);
+ $('#tag_color').val(hex);
+ }
+ });
+ $('#tag_background').ColorPicker({
+ color: background_col,
+ onShow: function (colpkr) {
+ $(colpkr).fadeIn(500);
+ return false;
+ },
+ onHide: function (colpkr) {
+ $(colpkr).fadeOut(500);
+ return false;
+ },
+ onChange: function (hsb, hex, rgb) {
+ $('#preview_tag_background').css('backgroundColor', '#' + hex);
+ $('#tag_background').val(hex);
+ }
+ });
+});
diff --git a/system/application/assets/plugins/colorpicker/js/utils.js b/system/application/assets/plugins/colorpicker/js/utils.js
new file mode 100644
index 0000000..cc7ce14
--- /dev/null
+++ b/system/application/assets/plugins/colorpicker/js/utils.js
@@ -0,0 +1,252 @@
+/**
+ *
+ * Utilities
+ * Author: Stefan Petre www.eyecon.ro
+ *
+ */
+(function($) {
+EYE.extend({
+ getPosition : function(e, forceIt)
+ {
+ var x = 0;
+ var y = 0;
+ var es = e.style;
+ var restoreStyles = false;
+ if (forceIt && jQuery.curCSS(e,'display') == 'none') {
+ var oldVisibility = es.visibility;
+ var oldPosition = es.position;
+ restoreStyles = true;
+ es.visibility = 'hidden';
+ es.display = 'block';
+ es.position = 'absolute';
+ }
+ var el = e;
+ if (el.getBoundingClientRect) { // IE
+ var box = el.getBoundingClientRect();
+ x = box.left + Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) - 2;
+ y = box.top + Math.max(document.documentElement.scrollTop, document.body.scrollTop) - 2;
+ } else {
+ x = el.offsetLeft;
+ y = el.offsetTop;
+ el = el.offsetParent;
+ if (e != el) {
+ while (el) {
+ x += el.offsetLeft;
+ y += el.offsetTop;
+ el = el.offsetParent;
+ }
+ }
+ if (jQuery.browser.safari && jQuery.curCSS(e, 'position') == 'absolute' ) {
+ x -= document.body.offsetLeft;
+ y -= document.body.offsetTop;
+ }
+ el = e.parentNode;
+ while (el && el.tagName.toUpperCase() != 'BODY' && el.tagName.toUpperCase() != 'HTML')
+ {
+ if (jQuery.curCSS(el, 'display') != 'inline') {
+ x -= el.scrollLeft;
+ y -= el.scrollTop;
+ }
+ el = el.parentNode;
+ }
+ }
+ if (restoreStyles == true) {
+ es.display = 'none';
+ es.position = oldPosition;
+ es.visibility = oldVisibility;
+ }
+ return {x:x, y:y};
+ },
+ getSize : function(e)
+ {
+ var w = parseInt(jQuery.curCSS(e,'width'), 10);
+ var h = parseInt(jQuery.curCSS(e,'height'), 10);
+ var wb = 0;
+ var hb = 0;
+ if (jQuery.curCSS(e, 'display') != 'none') {
+ wb = e.offsetWidth;
+ hb = e.offsetHeight;
+ } else {
+ var es = e.style;
+ var oldVisibility = es.visibility;
+ var oldPosition = es.position;
+ es.visibility = 'hidden';
+ es.display = 'block';
+ es.position = 'absolute';
+ wb = e.offsetWidth;
+ hb = e.offsetHeight;
+ es.display = 'none';
+ es.position = oldPosition;
+ es.visibility = oldVisibility;
+ }
+ return {w:w, h:h, wb:wb, hb:hb};
+ },
+ getClient : function(e)
+ {
+ var h, w;
+ if (e) {
+ w = e.clientWidth;
+ h = e.clientHeight;
+ } else {
+ var de = document.documentElement;
+ w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
+ h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
+ }
+ return {w:w,h:h};
+ },
+ getScroll : function (e)
+ {
+ var t=0, l=0, w=0, h=0, iw=0, ih=0;
+ if (e && e.nodeName.toLowerCase() != 'body') {
+ t = e.scrollTop;
+ l = e.scrollLeft;
+ w = e.scrollWidth;
+ h = e.scrollHeight;
+ } else {
+ if (document.documentElement) {
+ t = document.documentElement.scrollTop;
+ l = document.documentElement.scrollLeft;
+ w = document.documentElement.scrollWidth;
+ h = document.documentElement.scrollHeight;
+ } else if (document.body) {
+ t = document.body.scrollTop;
+ l = document.body.scrollLeft;
+ w = document.body.scrollWidth;
+ h = document.body.scrollHeight;
+ }
+ if (typeof pageYOffset != 'undefined') {
+ t = pageYOffset;
+ l = pageXOffset;
+ }
+ iw = self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0;
+ ih = self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0;
+ }
+ return { t: t, l: l, w: w, h: h, iw: iw, ih: ih };
+ },
+ getMargins : function(e, toInteger)
+ {
+ var t = jQuery.curCSS(e,'marginTop') || '';
+ var r = jQuery.curCSS(e,'marginRight') || '';
+ var b = jQuery.curCSS(e,'marginBottom') || '';
+ var l = jQuery.curCSS(e,'marginLeft') || '';
+ if (toInteger)
+ return {
+ t: parseInt(t, 10)||0,
+ r: parseInt(r, 10)||0,
+ b: parseInt(b, 10)||0,
+ l: parseInt(l, 10)
+ };
+ else
+ return {t: t, r: r, b: b, l: l};
+ },
+ getPadding : function(e, toInteger)
+ {
+ var t = jQuery.curCSS(e,'paddingTop') || '';
+ var r = jQuery.curCSS(e,'paddingRight') || '';
+ var b = jQuery.curCSS(e,'paddingBottom') || '';
+ var l = jQuery.curCSS(e,'paddingLeft') || '';
+ if (toInteger)
+ return {
+ t: parseInt(t, 10)||0,
+ r: parseInt(r, 10)||0,
+ b: parseInt(b, 10)||0,
+ l: parseInt(l, 10)
+ };
+ else
+ return {t: t, r: r, b: b, l: l};
+ },
+ getBorder : function(e, toInteger)
+ {
+ var t = jQuery.curCSS(e,'borderTopWidth') || '';
+ var r = jQuery.curCSS(e,'borderRightWidth') || '';
+ var b = jQuery.curCSS(e,'borderBottomWidth') || '';
+ var l = jQuery.curCSS(e,'borderLeftWidth') || '';
+ if (toInteger)
+ return {
+ t: parseInt(t, 10)||0,
+ r: parseInt(r, 10)||0,
+ b: parseInt(b, 10)||0,
+ l: parseInt(l, 10)||0
+ };
+ else
+ return {t: t, r: r, b: b, l: l};
+ },
+ traverseDOM : function(nodeEl, func)
+ {
+ func(nodeEl);
+ nodeEl = nodeEl.firstChild;
+ while(nodeEl){
+ EYE.traverseDOM(nodeEl, func);
+ nodeEl = nodeEl.nextSibling;
+ }
+ },
+ getInnerWidth : function(el, scroll) {
+ var offsetW = el.offsetWidth;
+ return scroll ? Math.max(el.scrollWidth,offsetW) - offsetW + el.clientWidth:el.clientWidth;
+ },
+ getInnerHeight : function(el, scroll) {
+ var offsetH = el.offsetHeight;
+ return scroll ? Math.max(el.scrollHeight,offsetH) - offsetH + el.clientHeight:el.clientHeight;
+ },
+ getExtraWidth : function(el) {
+ if($.boxModel)
+ return (parseInt($.curCSS(el, 'paddingLeft'))||0)
+ + (parseInt($.curCSS(el, 'paddingRight'))||0)
+ + (parseInt($.curCSS(el, 'borderLeftWidth'))||0)
+ + (parseInt($.curCSS(el, 'borderRightWidth'))||0);
+ return 0;
+ },
+ getExtraHeight : function(el) {
+ if($.boxModel)
+ return (parseInt($.curCSS(el, 'paddingTop'))||0)
+ + (parseInt($.curCSS(el, 'paddingBottom'))||0)
+ + (parseInt($.curCSS(el, 'borderTopWidth'))||0)
+ + (parseInt($.curCSS(el, 'borderBottomWidth'))||0);
+ return 0;
+ },
+ isChildOf: function(parentEl, el, container) {
+ if (parentEl == el) {
+ return true;
+ }
+ if (!el || !el.nodeType || el.nodeType != 1) {
+ return false;
+ }
+ if (parentEl.contains && !$.browser.safari) {
+ return parentEl.contains(el);
+ }
+ if ( parentEl.compareDocumentPosition ) {
+ return !!(parentEl.compareDocumentPosition(el) & 16);
+ }
+ var prEl = el.parentNode;
+ while(prEl && prEl != container) {
+ if (prEl == parentEl)
+ return true;
+ prEl = prEl.parentNode;
+ }
+ return false;
+ },
+ centerEl : function(el, axis)
+ {
+ var clientScroll = EYE.getScroll();
+ var size = EYE.getSize(el);
+ if (!axis || axis == 'vertically')
+ $(el).css(
+ {
+ top: clientScroll.t + ((Math.min(clientScroll.h,clientScroll.ih) - size.hb)/2) + 'px'
+ }
+ );
+ if (!axis || axis == 'horizontally')
+ $(el).css(
+ {
+ left: clientScroll.l + ((Math.min(clientScroll.w,clientScroll.iw) - size.wb)/2) + 'px'
+ }
+ );
+ }
+});
+if (!$.easing.easeout) {
+ $.easing.easeout = function(p, n, firstNum, delta, duration) {
+ return -delta * ((n=n/duration-1)*n*n*n - 1) + firstNum;
+ };
+}
+
+})(jQuery);
\ No newline at end of file
diff --git a/system/application/controllers/tag.php b/system/application/controllers/tag.php
index 7730cb5..50180fb 100644
--- a/system/application/controllers/tag.php
+++ b/system/application/controllers/tag.php
@@ -21,6 +21,19 @@ class Tag extends Controller {
{
$this->template->set('page_title', 'New Tag');
+ /* Colorpicker JS and CSS */
+ $this->template->set('add_css', array(
+ "plugins/colorpicker/css/colorpicker.css",
+ ));
+
+ $this->template->set('add_javascript', array(
+ "plugins/colorpicker/js/colorpicker.js",
+ "plugins/colorpicker/js/eye.js",
+ "plugins/colorpicker/js/utils.js",
+ "plugins/colorpicker/js/layout.js",
+ "plugins/colorpicker/js/startup.js",
+ ));
+
/* Form fields */
$data['tag_title'] = array(
'name' => 'tag_title',
diff --git a/system/application/controllers/welcome.php b/system/application/controllers/welcome.php
index 5f947ac..f85e5af 100644
--- a/system/application/controllers/welcome.php
+++ b/system/application/controllers/welcome.php
@@ -13,8 +13,8 @@ class Welcome extends Controller {
$this->load->model('Ledger_model');
$this->load->library('accountlist');
$this->template->set('page_title', 'Welcome to Webzash');
- $this->template->set('add_css', array("tufte-graph.css"));
- $this->template->set('add_javascript', array("raphael.js", "jquery.enumerable.js", "jquery.tufte-graph.js"));
+ $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");
diff --git a/system/application/views/tag/add.php b/system/application/views/tag/add.php
index 5cb8377..9231708 100644
--- a/system/application/views/tag/add.php
+++ b/system/application/views/tag/add.php
@@ -11,12 +11,16 @@
echo form_label('Tag Color', 'tag_color');
echo "<br />";
echo "#" . form_input($tag_color);
+ echo "   ";
+ echo "<span id=\"preview_tag_color\" style=\"padding:3px 20px 3px 20px;\"></span>";
echo "</p>";
echo "<p>";
echo form_label('Background Color', 'tag_background');
echo "<br />";
echo "#" . form_input($tag_background);
+ echo "   ";
+ echo "<span id=\"preview_tag_background\" style=\"padding:3px 20px 3px 20px;\"></span>";
echo "</p>";
echo "<p>";
diff --git a/system/application/views/template.php b/system/application/views/template.php
index 7ecb824..b93b659 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -18,7 +18,7 @@ if (isset($add_css))
{
foreach ($add_css as $id => $row)
{
- echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"" . asset_url() . "css/" . $row ."\">";
+ echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"" . asset_url() . $row ."\">";
}
}
?>
@@ -30,13 +30,14 @@ if (isset($add_css))
<script type="text/javascript" src="<?php echo asset_url(); ?>js/superfish.js"></script>
<script type="text/javascript" src="<?php echo asset_url(); ?>js/supersubs.js"></script>
<script type="text/javascript" src="<?php echo asset_url(); ?>js/thickbox-compressed.js"></script>
+
<?php
/* Dynamically adding javascript files from controllers */
if (isset($add_javascript))
{
foreach ($add_javascript as $id => $row)
{
- echo "<script type=\"text/javascript\" src=\"" . asset_url() . "js/" . $row ."\"></script>";
+ echo "<script type=\"text/javascript\" src=\"" . asset_url() . $row ."\"></script>";
}
}
?>
commit 9e36753efe7ba9ad97af00b18969089009b25402
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Dec 22 14:38:37 2010 +0530
Check new voucher date to be within current financial year
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 cfb9674..11f523a 100644
--- a/system/application/helpers/MY_date_helper.php
+++ b/system/application/helpers/MY_date_helper.php
@@ -111,6 +111,16 @@ if ( ! function_exists('date_today_php'))
function date_today_php()
{
$CI =& get_instance();
+
+ /* Check for date beyond the current financial year range */
+ $todays_date = date('Y-m-d 00:00:00');
+ $fy_start = $CI->config->item('account_fy_start');
+ $fy_end = $CI->config->item('account_fy_end');
+ if ($CI->config->item('account_fy_start') > $todays_date)
+ return date_mysql_to_php($fy_start);
+ if ($CI->config->item('account_fy_end') < $todays_date)
+ return date_mysql_to_php($fy_end);
+
$current_date_format = $CI->config->item('account_date_format');
switch ($current_date_format)
{
13 years, 3 months