system/application/assets/css/style.css | 8 +
system/application/assets/css/tables.css | 18 ++
system/application/config/autoload.php | 2
system/application/controllers/admin/carryforward.sql | 16 ++
system/application/controllers/admin/create.php | 26 +--
system/application/controllers/admin/database.sql | 16 ++
system/application/controllers/admin/welcome.php | 6
system/application/controllers/group.php | 21 ++-
system/application/controllers/ledger.php | 21 ++-
system/application/controllers/report.php | 4
system/application/controllers/setting.php | 118 +++++++++++-------
system/application/controllers/tag.php | 8 +
system/application/controllers/voucher.php | 14 ++
system/application/controllers/welcome.php | 18 ++
system/application/helpers/custom_helper.php | 22 +++
system/application/libraries/Accountlist.php | 25 +++
system/application/libraries/Logger.php | 51 +++++++
system/application/libraries/Startup.php | 6
system/application/views/admin/create.php | 12 -
system/application/views/admin/welcome.php | 6
system/application/views/setting/account.php | 8 -
system/application/views/setting/cf.php | 12 +
system/application/views/template.php | 9 -
system/application/views/welcome_message.php | 71 ++++++++--
24 files changed, 404 insertions(+), 114 deletions(-)
New commits:
commit 27bcdcf5b7514a395822d4cab80bda4379a8828a
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 12 22:11:43 2010 +0530
Voucher updated to use the Logger library
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 d165dc4..5d187aa 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -404,6 +404,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error addding Voucher A/C', 'error');
+ $this->logger->write_message("error", "Error adding " . ucfirst($voucher_type) . " Voucher number " . $data_number . " since failed inserting voucher");
$this->template->load('template', 'voucher/add', $data);
return;
} else {
@@ -438,6 +439,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error addding Ledger A/C ' . $data_ledger_id, 'error');
+ $this->logger->write_message("error", "Error adding " . ucfirst($voucher_type) . " Voucher number " . $data_number . " since failed inserting voucher ledger items " . "[" . $data_ledger_id . "]");
$this->template->load('template', 'voucher/add', $data);
return;
}
@@ -448,6 +450,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error updating voucher total', 'error');
+ $this->logger->write_message("error", "Error adding " . ucfirst($voucher_type) . " Voucher number " . $data_number . " since failed updating debit and credit total");
$this->template->load('template', 'voucher/add', $data);
return;
}
@@ -455,6 +458,7 @@ class Voucher extends Controller {
/* Success */
$this->db->trans_complete();
$this->messages->add(ucfirst($voucher_type) . ' Voucher number ' . $data_number . ' added successfully', 'success');
+ $this->logger->write_message("success", "Added " . ucfirst($voucher_type) . " Voucher number " . $data_number);
redirect('voucher/show/' . $voucher_type);
$this->template->load('template', 'voucher/add', $data);
return;
@@ -655,6 +659,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error updating Voucher A/C', 'error');
+ $this->logger->write_message("error", "Error updating voucher details for " . ucfirst($voucher_type) . " Voucher number " . $data_number . " [" . $voucher_id . "]");
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -664,6 +669,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error deleting old Ledger A/C\'s', 'error');
+ $this->logger->write_message("error", "Error updating old voucher items for " . ucfirst($voucher_type) . " Voucher number " . $data_number . " [" . $voucher_id . "]");
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -696,6 +702,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error updating Ledger A/C ' . $data_ledger_id, 'error');
+ $this->logger->write_message("error", "Error updating new voucher item [" . $data_ledger_id . "] for " . ucfirst($voucher_type) . " Voucher number " . $data_number . " [" . $voucher_id . "]");
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -706,6 +713,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error updating voucher total', 'error');
+ $this->logger->write_message("error", "Error updating voucher total for " . ucfirst($voucher_type) . " Voucher number " . $data_number . " [" . $voucher_id . "]");
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -713,6 +721,7 @@ class Voucher extends Controller {
/* Success */
$this->db->trans_complete();
$this->messages->add(ucfirst($voucher_type) . ' Voucher number ' . $data_number . ' updated successfully', 'success');
+ $this->logger->write_message("success", "Updated " . ucfirst($voucher_type) . " Voucher number " . $cur_voucher->number . " [" . $voucher_id . "]");
redirect('voucher/show/' . $voucher_type);
return;
}
@@ -734,6 +743,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error deleting Voucher - Ledgers entry', 'error');
+ $this->logger->write_message("error", "Error deleting ledger entries for " . ucfirst($voucher_type) . " Voucher number " . $cur_voucher->number . " [" . $voucher_id . "]");
redirect('voucher/' . $voucher_type . '/' . $voucher_id);
return;
}
@@ -741,11 +751,13 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error deleting Voucher entry', 'error');
+ $this->logger->write_message("error", "Error deleting voucher entry for " . ucfirst($voucher_type) . " Voucher number " . $cur_voucher->number . " [" . $voucher_id . "]");
redirect('voucher/' . $voucher_type . '/' . $voucher_id);
return;
}
$this->db->trans_complete();
$this->messages->add('Voucher deleted successfully', 'success');
+ $this->logger->write_message("success", "Deleted " . ucfirst($voucher_type) . " Voucher number " . $cur_voucher->number . " [" . $voucher_id . "]");
redirect('voucher/show/' . $voucher_type);
return;
}
@@ -895,8 +907,10 @@ class Voucher extends Controller {
if ($this->email->send())
{
$data['message'] = "Successfully sent email !";
+ $this->logger->write_message("success", "Emailed " . ucfirst($voucher_type) . " Voucher number " . $cur_voucher->number . " [" . $voucher_id . "]");
} else {
$data['error'] = "Error sending email. Please check you email settings";
+ $this->logger->write_message("error", "Error emailing " . ucfirst($voucher_type) . " Voucher number " . $cur_voucher->number . " [" . $voucher_id . "]");
}
$this->load->view('voucher/email', $data);
return;
commit 8012b8a7dd3e84d023dead8ba44200ce19ca2aee
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 12 19:26:18 2010 +0530
Show dashboard log footer only if there is some activity
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/views/welcome_message.php b/system/application/views/welcome_message.php
index 5a22d98..00932f0 100644
--- a/system/application/views/welcome_message.php
+++ b/system/application/views/welcome_message.php
@@ -180,15 +180,15 @@ jQuery(document).ready(function () {
}
?>
</div>
- <div class="dashboard-log-footer">
- <?php
+ <?php
if ($logs)
{
+ echo "<div class=\"dashboard-log-footer\">";
echo "<span>";
echo anchor("", "more...", array('class' => 'blue-link no-underline'));
echo "</span>";
}
- ?>
+ ?>
</div>
</div>
</div>
commit debe0465affd1d198842e6f0a97d26c0f5bc3486
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 12 19:21:23 2010 +0530
Updated log table to logs which is more inline with the app
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
index d1a7d72..4df5623 100644
--- a/system/application/controllers/admin/carryforward.sql
+++ b/system/application/controllers/admin/carryforward.sql
@@ -80,7 +80,7 @@ CREATE TABLE IF NOT EXISTS tags (
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
-CREATE TABLE IF NOT EXISTS log (
+CREATE TABLE IF NOT EXISTS logs (
id int(11) NOT NULL AUTO_INCREMENT,
date datetime NOT NULL,
level int(1) NOT NULL,
diff --git a/system/application/controllers/admin/database.sql b/system/application/controllers/admin/database.sql
index ab56ff7..b474c21 100644
--- a/system/application/controllers/admin/database.sql
+++ b/system/application/controllers/admin/database.sql
@@ -80,7 +80,7 @@ CREATE TABLE IF NOT EXISTS tags (
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
-CREATE TABLE IF NOT EXISTS log (
+CREATE TABLE IF NOT EXISTS logs (
id int(11) NOT NULL AUTO_INCREMENT,
date datetime NOT NULL,
level int(1) NOT NULL,
diff --git a/system/application/controllers/admin/welcome.php b/system/application/controllers/admin/welcome.php
index 6698999..59112b1 100644
--- a/system/application/controllers/admin/welcome.php
+++ b/system/application/controllers/admin/welcome.php
@@ -98,7 +98,7 @@ class Welcome extends Controller {
{
$valid_webzash_db = TRUE;
/* Check for valid webzash database */
- $table_names = array('settings', 'groups', 'ledgers', 'vouchers', 'voucher_items', 'tags', 'log');
+ $table_names = array('settings', 'groups', 'ledgers', 'vouchers', 'voucher_items', 'tags', 'logs');
foreach ($table_names as $id => $tbname)
{
$valid_db_q = mysql_query('DESC ' . $tbname);
diff --git a/system/application/controllers/welcome.php b/system/application/controllers/welcome.php
index d836f46..846c096 100644
--- a/system/application/controllers/welcome.php
+++ b/system/application/controllers/welcome.php
@@ -62,7 +62,7 @@ class Welcome extends Controller {
$data['show_income_expense'] = FALSE;
/* Getting Log Messages */
- $data['log'] = $this->logger->read_recent_messages();
+ $data['logs'] = $this->logger->read_recent_messages();
$this->template->load('template', 'welcome_message', $data);
return;
}
diff --git a/system/application/libraries/Logger.php b/system/application/libraries/Logger.php
index 27dcae0..4a980c5 100644
--- a/system/application/libraries/Logger.php
+++ b/system/application/libraries/Logger.php
@@ -33,16 +33,16 @@ class Logger
$data['user_agent'] = $CI->input->user_agent();
$data['message_title'] = $title;
$data['message_desc'] = $desc;
- $CI->db->insert('log', $data);
+ $CI->db->insert('logs', $data);
}
function read_recent_messages()
{
$CI =& get_instance();
- $log_q = $CI->db->query("SELECT * FROM log ORDER BY id DESC LIMIT 20");
- if ($log_q->num_rows() > 0)
+ $logs_q = $CI->db->query("SELECT * FROM logs ORDER BY id DESC LIMIT 20");
+ if ($logs_q->num_rows() > 0)
{
- return $log_q;
+ return $logs_q;
} else {
return FALSE;
}
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index 80152bb..43bb741 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -102,7 +102,7 @@ class Startup
if ($CI->db->query("SHOW TABLES"))
{
/* Check for valid webzash database */
- $table_names = array('settings', 'groups', 'ledgers', 'vouchers', 'voucher_items', 'tags', 'log');
+ $table_names = array('settings', 'groups', 'ledgers', 'vouchers', 'voucher_items', 'tags', 'logs');
foreach ($table_names as $id => $tbname)
{
$valid_db_q = mysql_query('DESC ' . $tbname);
diff --git a/system/application/views/welcome_message.php b/system/application/views/welcome_message.php
index 22ed4ad..5a22d98 100644
--- a/system/application/views/welcome_message.php
+++ b/system/application/views/welcome_message.php
@@ -167,10 +167,10 @@ jQuery(document).ready(function () {
<div class="dashboard-log-title">Recent Activity</div>
<div class="dashboard-log-content">
<?php
- if ($log)
+ if ($logs)
{
echo "<ul>";
- foreach ($log->result() as $row)
+ foreach ($logs->result() as $row)
{
echo "<li>" . $row->message_title . "</li>";
}
@@ -182,7 +182,7 @@ jQuery(document).ready(function () {
</div>
<div class="dashboard-log-footer">
<?php
- if ($log)
+ if ($logs)
{
echo "<span>";
echo anchor("", "more...", array('class' => 'blue-link no-underline'));
commit 5f7089095cb11725537df8a223f96eede109dd74
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 12 19:15:10 2010 +0530
Tags updated to use the Logger library
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 66054c7..8ed90c1 100644
--- a/system/application/controllers/tag.php
+++ b/system/application/controllers/tag.php
@@ -76,11 +76,13 @@ class Tag extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error addding ' . $data_tag_title . ' - Tag', '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 successfully', 'success');
+ $this->logger->write_message("success", "Added tag named " . $data_tag_title);
redirect('tag');
return;
}
@@ -168,11 +170,13 @@ class Tag extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error updating ' . $data_tag_title . ' - Tag', 'error');
+ $this->logger->write_message("error", "Error updating tag named " . $data_tag_title . " [" . $id . "]");
$this->template->load('template', 'tag/edit', $data);
return;
} else {
$this->db->trans_complete();
$this->messages->add("Updated " . $data_tag_title . ' - Tag successfully', 'success');
+ $this->logger->write_message("success", "Updated tag named " . $data_tag_title . " [" . $id . "]");
redirect('tag');
return;
}
@@ -198,6 +202,7 @@ class Tag extends Controller {
redirect('tag');
return;
}
+ $data_tag = $data_valid_q->row();
/* Deleting Tag */
$this->db->trans_start();
@@ -205,6 +210,7 @@ class Tag extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error removing Tags', 'error');
+ $this->logger->write_message("error", "Error removing tag named " . $data_tag->title . " [" . $id . "] from vouchers");
redirect('tag');
return;
} else {
@@ -212,11 +218,13 @@ class Tag extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error deleting Tag', 'error');
+ $this->logger->write_message("error", "Error deleting tag named " . $data_tag->title . " [" . $id . "]");
redirect('tag');
return;
} else {
$this->db->trans_complete();
$this->messages->add('Tag deleted successfully', 'success');
+ $this->logger->write_message("success", "Deleted tag named " . $data_tag->title . " [" . $id . "]");
redirect('tag');
return;
}
commit 094069c3e684e610f87914d9729800cc2bcca53c
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 12 19:07:30 2010 +0530
Settings updated to use the Logger library
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 114fecf..e2c4f29 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -118,17 +118,21 @@ class Setting extends Controller {
$data_account_timezone = $this->input->post('timezones', TRUE);
/* 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)))
{
+ $this->db->trans_rollback();
$this->messages->add('Error updating 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->logger->write_message("success", "Updated account settings");
+ redirect('setting');
+ return;
}
-
- /* Success */
- $this->messages->add('Settings updated successfully', 'success');
- redirect('setting');
- return;
}
return;
}
@@ -521,17 +525,21 @@ class Setting extends Controller {
$data_email_password = $account_data->email_password;
/* 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)))
{
+ $this->db->trans_rollback();
$this->messages->add('Error updating 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->logger->write_message("success", "Updated email settings");
+ redirect('setting');
+ return;
}
-
- /* Success */
- $this->messages->add('Email settings updated successfully', 'success');
- redirect('setting');
- return;
}
return;
}
@@ -731,17 +739,21 @@ 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)))
{
+ $this->db->trans_rollback();
$this->messages->add('Error updating printer settings', 'error');
+ $this->logger->write_message("error", "Error updating printer settings");
$this->template->load('template', 'setting/printer');
return;
+ } else {
+ $this->db->trans_complete();
+ $this->messages->add('Printer settings updated successfully', 'success');
+ $this->logger->write_message("success", "Updated printer settings");
+ redirect('setting');
+ return;
}
-
- /* Success */
- $this->messages->add('Printer settings updated successfully', 'success');
- redirect('setting');
- return;
}
return;
}
@@ -765,6 +777,7 @@ class Setting extends Controller {
/* Send the file to your desktop */
force_download($backup_filename, $backup_data);
+ $this->logger->write_message("success", "Downloaded account backup");
redirect('setting');
return;
}
commit 4ebb2683e3ced5ed837b309eda17524bbfde4ef1
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 12 15:56:28 2010 +0530
Added Logger messages 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 dd77f9e..a763725 100644
--- a/system/application/controllers/ledger.php
+++ b/system/application/controllers/ledger.php
@@ -88,11 +88,13 @@ class Ledger extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error addding ' . $data_name . ' - Ledger A/C', '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($data_name . ' - Ledger A/C added successfully', 'success');
+ $this->logger->write_message("success", "Added Ledger A/C named " . $data_name);
redirect('account');
return;
}
@@ -197,11 +199,13 @@ class Ledger extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error updating ' . $data_name . ' - Ledger A/C', '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($data_name . ' - Ledger A/C updated successfully', 'success');
+ $this->logger->write_message("success", "Updated Ledger A/C named " . $data_name . " [id:" . $data_id . "]");
redirect('account');
return;
}
@@ -228,17 +232,30 @@ class Ledger extends Controller {
return;
}
+ /* Get the ledger details */
+ $ledger_q = $this->db->query("SELECT * FROM ledgers WHERE id = ?", array($id));
+ if ($ledger_q->num_rows() < 1)
+ {
+ $this->messages->add('Invalid Ledger A/C', 'error');
+ redirect('account');
+ return;
+ } else {
+ $ledger_data = $ledger_q->row();
+ }
+
/* Deleting ledger */
$this->db->trans_start();
if ( ! $this->db->query("DELETE FROM ledgers WHERE id = ?", array($id)))
{
$this->db->trans_rollback();
- $this->messages->add('Error deleting 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 A/C deleted successfully', 'success');
+ $this->messages->add($ledger_data->name . " - Ledger A/C deleted successfully", 'success');
+ $this->logger->write_message("success", "Deleted Ledger A/C named " . $ledger_data->name . " [id:" . $id . "]");
redirect('account');
return;
}
commit 63b1a41765ee286ba15cc231baec3ccdbddb8ae8
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 12 15:40:15 2010 +0530
Added Recent Activity footer
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/assets/css/style.css b/system/application/assets/css/style.css
index 6ebbf53..b3cb2ff 100644
--- a/system/application/assets/css/style.css
+++ b/system/application/assets/css/style.css
@@ -173,3 +173,7 @@ body {
{
color:#AAAAAA;
}
+
+a.no-underline {
+ text-decoration:none;
+}
diff --git a/system/application/assets/css/tables.css b/system/application/assets/css/tables.css
index a6cda32..4eebea6 100644
--- a/system/application/assets/css/tables.css
+++ b/system/application/assets/css/tables.css
@@ -224,6 +224,11 @@
color: #000000;
}
+.dashboard-log-footer {
+ padding:10px;
+ border-top:1px solid #BBBBBB;
+}
+
.ledgerst-table td {
}
diff --git a/system/application/libraries/Logger.php b/system/application/libraries/Logger.php
index d3fc424..27dcae0 100644
--- a/system/application/libraries/Logger.php
+++ b/system/application/libraries/Logger.php
@@ -36,7 +36,7 @@ class Logger
$CI->db->insert('log', $data);
}
- function read_recent_messages($count = 20)
+ function read_recent_messages()
{
$CI =& get_instance();
$log_q = $CI->db->query("SELECT * FROM log ORDER BY id DESC LIMIT 20");
diff --git a/system/application/views/welcome_message.php b/system/application/views/welcome_message.php
index 46a1417..22ed4ad 100644
--- a/system/application/views/welcome_message.php
+++ b/system/application/views/welcome_message.php
@@ -180,6 +180,16 @@ jQuery(document).ready(function () {
}
?>
</div>
+ <div class="dashboard-log-footer">
+ <?php
+ if ($log)
+ {
+ echo "<span>";
+ echo anchor("", "more...", array('class' => 'blue-link no-underline'));
+ echo "</span>";
+ }
+ ?>
+ </div>
</div>
</div>
<div class="clear"></div>
commit a20619657936f1748e2bf739b861b32629edc255
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 12 15:27:34 2010 +0530
Added recent activity from Logger to Dashboard
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 9aad75a..d836f46 100644
--- a/system/application/controllers/welcome.php
+++ b/system/application/controllers/welcome.php
@@ -35,7 +35,7 @@ class Welcome extends Controller {
} else {
$data['bank_cash_account'] = array();
}
-
+
/* Calculating total of Assets, Liabilities, Incomes, Expenses */
$asset = new Accountlist();
$asset->init(1);
@@ -61,6 +61,8 @@ class Welcome extends Controller {
if ($data['income_total'] == 0 && $data['expense_total'] == 0)
$data['show_income_expense'] = FALSE;
+ /* Getting Log Messages */
+ $data['log'] = $this->logger->read_recent_messages();
$this->template->load('template', 'welcome_message', $data);
return;
}
diff --git a/system/application/libraries/Logger.php b/system/application/libraries/Logger.php
index 407b117..d3fc424 100644
--- a/system/application/libraries/Logger.php
+++ b/system/application/libraries/Logger.php
@@ -19,6 +19,7 @@ class Logger
{
$CI =& get_instance();
$data['date'] = date("Y-m-d H:i:s");
+ $data['level'] = 3;
switch ($level)
{
case "error": $data['level'] = 0; break;
@@ -34,5 +35,17 @@ class Logger
$data['message_desc'] = $desc;
$CI->db->insert('log', $data);
}
+
+ function read_recent_messages($count = 20)
+ {
+ $CI =& get_instance();
+ $log_q = $CI->db->query("SELECT * FROM log ORDER BY id DESC LIMIT 20");
+ if ($log_q->num_rows() > 0)
+ {
+ return $log_q;
+ } else {
+ return FALSE;
+ }
+ }
}
diff --git a/system/application/views/welcome_message.php b/system/application/views/welcome_message.php
index 2813435..46a1417 100644
--- a/system/application/views/welcome_message.php
+++ b/system/application/views/welcome_message.php
@@ -166,7 +166,19 @@ jQuery(document).ready(function () {
<div id="dashboard-recent-log" class="dashboard-log-item">
<div class="dashboard-log-title">Recent Activity</div>
<div class="dashboard-log-content">
- Hello World !
+ <?php
+ if ($log)
+ {
+ echo "<ul>";
+ foreach ($log->result() as $row)
+ {
+ echo "<li>" . $row->message_title . "</li>";
+ }
+ echo "</ul>";
+ } else {
+ echo "No Recent Activity";
+ }
+ ?>
</div>
</div>
</div>
commit 00c3b6bb9a86162fd447ac0190f5c94c2fb6cebc
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 12 15:09:20 2010 +0530
Added "success" level to Logger
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 8e217f3..407b117 100644
--- a/system/application/libraries/Logger.php
+++ b/system/application/libraries/Logger.php
@@ -11,8 +11,9 @@ class Logger
* Write message to database log
* Levels defined are :
* 0 - error
- * 1 - info
- * 2 - debug
+ * 1 - success
+ * 2 - info
+ * 3 - debug
*/
function write_message($level = "debug", $title = "", $desc = "")
{
@@ -21,8 +22,9 @@ class Logger
switch ($level)
{
case "error": $data['level'] = 0; break;
- case "info": $data['level'] = 1; break;
- case "debug": $data['level'] = 2; 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();
commit e6ec9e78e166d83fe05bf4fd8466c4ded4b3e731
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 12 15:08:05 2010 +0530
Added Logger messages 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 6659a05..390a19b 100644
--- a/system/application/controllers/group.php
+++ b/system/application/controllers/group.php
@@ -72,11 +72,13 @@ class Group extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error addding ' . $data_name . ' - Group A/C', '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($data_name . ' - Group A/C added successfully', 'success');
+ $this->logger->write_message("success", "Added Group A/C named " . $data_name);
redirect('account');
return;
}
@@ -167,11 +169,13 @@ class Group extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error updating ' . $data_name . ' - Group A/C', '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($data_name . ' - Group A/C updated successfully', 'success');
+ $this->logger->write_message("success", "Updated Group A/C named " . $data_name . " [id:" . $data_id . "]");
redirect('account');
return;
}
@@ -209,17 +213,30 @@ class Group extends Controller {
return;
}
+ /* Get the group details */
+ $group_q = $this->db->query("SELECT * FROM groups WHERE id = ?", array($id));
+ if ($group_q->num_rows() < 1)
+ {
+ $this->messages->add('Invalid Group A/C', 'error');
+ redirect('account');
+ return;
+ } else {
+ $group_data = $group_q->row();
+ }
+
/* Deleting group */
$this->db->trans_start();
if ( ! $this->db->query("DELETE FROM groups WHERE id = ?", array($id)))
{
$this->db->trans_rollback();
- $this->messages->add('Error deleting 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 A/C deleted successfully', 'success');
+ $this->messages->add($group_data->name . ' - Group A/C deleted successfully', 'success');
+ $this->logger->write_message("success", "Deleted Group A/C named " . $group_data->name . " [id:" . $id . "]");
redirect('account');
return;
}
commit e2d1adaf4d3ad3d42ba83e5059ccb1dc820371d6
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 12 12:18:28 2010 +0530
Added Database Logger Class and autoload it
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 937f3d6..0d632e2 100644
--- a/system/application/config/autoload.php
+++ b/system/application/config/autoload.php
@@ -39,7 +39,7 @@
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
*/
-$autoload['libraries'] = array('database', 'session', 'form_validation', 'messages', 'template', 'startup');
+$autoload['libraries'] = array('database', 'session', 'form_validation', 'messages', 'template', 'startup', 'logger');
/*
diff --git a/system/application/controllers/admin/carryforward.sql b/system/application/controllers/admin/carryforward.sql
index 0503922..d1a7d72 100644
--- a/system/application/controllers/admin/carryforward.sql
+++ b/system/application/controllers/admin/carryforward.sql
@@ -79,3 +79,15 @@ CREATE TABLE IF NOT EXISTS tags (
background varchar(6) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
+
+CREATE TABLE IF NOT EXISTS log (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ date datetime NOT NULL,
+ level int(1) NOT NULL,
+ host_ip 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/database.sql b/system/application/controllers/admin/database.sql
index 127d588..ab56ff7 100644
--- a/system/application/controllers/admin/database.sql
+++ b/system/application/controllers/admin/database.sql
@@ -80,6 +80,18 @@ CREATE TABLE IF NOT EXISTS tags (
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
+CREATE TABLE IF NOT EXISTS log (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ date datetime NOT NULL,
+ level int(1) NOT NULL,
+ host_ip 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);
diff --git a/system/application/controllers/admin/welcome.php b/system/application/controllers/admin/welcome.php
index bc7438a..6698999 100644
--- a/system/application/controllers/admin/welcome.php
+++ b/system/application/controllers/admin/welcome.php
@@ -98,7 +98,7 @@ class Welcome extends Controller {
{
$valid_webzash_db = TRUE;
/* Check for valid webzash database */
- $table_names = array('settings', 'groups', 'ledgers', 'vouchers', 'voucher_items');
+ $table_names = array('settings', 'groups', 'ledgers', 'vouchers', 'voucher_items', 'tags', 'log');
foreach ($table_names as $id => $tbname)
{
$valid_db_q = mysql_query('DESC ' . $tbname);
diff --git a/system/application/libraries/Logger.php b/system/application/libraries/Logger.php
new file mode 100644
index 0000000..8e217f3
--- /dev/null
+++ b/system/application/libraries/Logger.php
@@ -0,0 +1,36 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+class Logger
+{
+ function Logger()
+ {
+ return;
+ }
+
+ /*
+ * Write message to database log
+ * Levels defined are :
+ * 0 - error
+ * 1 - info
+ * 2 - debug
+ */
+ function write_message($level = "debug", $title = "", $desc = "")
+ {
+ $CI =& get_instance();
+ $data['date'] = date("Y-m-d H:i:s");
+ switch ($level)
+ {
+ case "error": $data['level'] = 0; break;
+ case "info": $data['level'] = 1; break;
+ case "debug": $data['level'] = 2; break;
+ default: $data['level'] = 0; break;
+ }
+ $data['host_ip'] = $CI->input->ip_address();
+ $data['url'] = current_url();
+ $data['user_agent'] = $CI->input->user_agent();
+ $data['message_title'] = $title;
+ $data['message_desc'] = $desc;
+ $CI->db->insert('log', $data);
+ }
+}
+
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index b5cd1ff..80152bb 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -102,7 +102,7 @@ class Startup
if ($CI->db->query("SHOW TABLES"))
{
/* Check for valid webzash database */
- $table_names = array('settings', 'groups', 'ledgers', 'vouchers', 'voucher_items', 'tags');
+ $table_names = array('settings', 'groups', 'ledgers', 'vouchers', 'voucher_items', 'tags', 'log');
foreach ($table_names as $id => $tbname)
{
$valid_db_q = mysql_query('DESC ' . $tbname);
commit d672d86c2983330f86448613b48d29bb30678989
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 12 11:50:03 2010 +0530
Only show dashboard chart if needed
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 353d906..9aad75a 100644
--- a/system/application/controllers/welcome.php
+++ b/system/application/controllers/welcome.php
@@ -45,6 +45,10 @@ class Welcome extends Controller {
$liability->init(2);
$data['liability_total'] = $liability->total;
+ $data['show_asset_liability'] = TRUE;
+ if ($data['asset_total'] == 0 && $data['liability_total'] == 0)
+ $data['show_asset_liability'] = FALSE;
+
$income = new Accountlist();
$income->init(3);
$data['income_total'] = $income->total;
@@ -52,7 +56,11 @@ class Welcome extends Controller {
$expense = new Accountlist();
$expense->init(4);
$data['expense_total'] = $expense->total;
-
+
+ $data['show_income_expense'] = TRUE;
+ if ($data['income_total'] == 0 && $data['expense_total'] == 0)
+ $data['show_income_expense'] = FALSE;
+
$this->template->load('template', 'welcome_message', $data);
return;
}
diff --git a/system/application/views/welcome_message.php b/system/application/views/welcome_message.php
index cfc3135..2813435 100644
--- a/system/application/views/welcome_message.php
+++ b/system/application/views/welcome_message.php
@@ -141,18 +141,22 @@ jQuery(document).ready(function () {
<table border="0">
<tbody>
<tr>
- <td width="300">
- <div id="income-expense" class="graph">
- <div id="income-expense-graph-header"><h4>Incomes Vs Expenses</h4></div>
- <div id="income-expense-graph-data"></div>
- </div>
- </td>
- <td width="300">
- <div id="asset-liability" class="graph">
- <div id="asset-liability-graph-header"><h4>Assets Vs Liabilities</h4></div>
- <div id="asset-liability-graph-data""></div>
- </div>
- </td>
+ <?php if ($show_income_expense) { ?>
+ <td width="300">
+ <div id="income-expense" class="graph">
+ <div id="income-expense-graph-header"><h4>Incomes Vs Expenses</h4></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"><h4>Assets Vs Liabilities</h4></div>
+ <div id="asset-liability-graph-data""></div>
+ </div>
+ </td>
+ <?php } ?>
</tr>
</tbody>
</table>
commit 2a7d2d30c19d1321bb6aa9496a138012c4124f7a
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 12 11:13:18 2010 +0530
Added account summary to dashboard
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 0988cf2..a6cda32 100644
--- a/system/application/assets/css/tables.css
+++ b/system/application/assets/css/tables.css
@@ -211,6 +211,19 @@
color: #000000;
}
+.dashboard-summary-table {
+ border-collapse: collapse;
+ text-align: left;
+}
+
+.dashboard-summary-table td {
+ padding: 8px 8px 8px 20px;
+}
+
+.dashboard-summary-table td a {
+ color: #000000;
+}
+
.ledgerst-table td {
}
diff --git a/system/application/controllers/welcome.php b/system/application/controllers/welcome.php
index bfb8a64..353d906 100644
--- a/system/application/controllers/welcome.php
+++ b/system/application/controllers/welcome.php
@@ -43,11 +43,11 @@ class Welcome extends Controller {
$liability = new Accountlist();
$liability->init(2);
- $data['liability_total'] = -$liability->total;
+ $data['liability_total'] = $liability->total;
$income = new Accountlist();
$income->init(3);
- $data['income_total'] = -$income->total;
+ $data['income_total'] = $income->total;
$expense = new Accountlist();
$expense->init(4);
diff --git a/system/application/helpers/custom_helper.php b/system/application/helpers/custom_helper.php
index 07ace36..ffe1363 100644
--- a/system/application/helpers/custom_helper.php
+++ b/system/application/helpers/custom_helper.php
@@ -23,6 +23,28 @@ if ( ! function_exists('convert_dc'))
}
}
+/**
+ * Converts amount to Dr or Cr Value
+ *
+ * Covnerts the amount to 0 or Dr or Cr value for display
+ *
+ * @access public
+ * @param float amount for display
+ * @return string
+ */
+if ( ! function_exists('convert_amount_dc'))
+{
+ function convert_amount_dc($amount)
+ {
+ if ($amount == "D")
+ return "0";
+ else if ($amount < 0)
+ return "Cr " . -$amount;
+ else
+ return "Dr " . $amount;
+ }
+}
+
if ( ! function_exists('convert_cur'))
{
function convert_cur($amount)
diff --git a/system/application/views/welcome_message.php b/system/application/views/welcome_message.php
index b16ede9..cfc3135 100644
--- a/system/application/views/welcome_message.php
+++ b/system/application/views/welcome_message.php
@@ -28,7 +28,7 @@ jQuery(document).ready(function () {
// 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 -$income_total; ?>, {label: 'Incomes'}],
[<?php echo $expense_total; ?>, {label: 'Expenses'}]
],
@@ -57,7 +57,7 @@ jQuery(document).ready(function () {
// 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'}]
+ [<?php echo -$liability_total; ?>, {label: 'Liabilities'}]
],
// Bar width in arbitrary units, 1.0 means the bars will be snuggled
@@ -121,6 +121,21 @@ jQuery(document).ready(function () {
?>
</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">
commit ba27041c673a3faaa4e23a50ce7b9eb9cb23d555
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 12 10:58:08 2010 +0530
Increase font size for info and added Help menu item
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/assets/css/style.css b/system/application/assets/css/style.css
index 36f8abd..6ebbf53 100644
--- a/system/application/assets/css/style.css
+++ b/system/application/assets/css/style.css
@@ -48,7 +48,9 @@ body {
top:10px;
background:none repeat scroll 0 0 #EEEEEE;
padding:10px;
- -moz-border-radius: 15px;
+ font-size:120%;
+ -moz-border-radius: 10px;
+ border-radius: 1px;
}
#content #main {
diff --git a/system/application/views/template.php b/system/application/views/template.php
index 1fb2936..7e04a4c 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -99,7 +99,10 @@ $(document).ready(function() {
</ul>
</li>
<li>
- <?php echo anchor('setting', 'Settings', array('title' => 'Settings', 'class' => 'last')); ?>
+ <?php echo anchor('setting', 'Settings', array('title' => 'Settings')); ?>
+ </li>
+ <li>
+ <?php echo anchor('', 'Help', array('title' => 'Help', 'class' => 'last')); ?>
</li>
</ul>
</div>
commit 09ad9c2a13ce225472c15123c4059f5b949ade5f
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Dec 12 10:52:27 2010 +0530
Converted Assessment year to Financial year throught
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
index deeaa2f..0503922 100644
--- a/system/application/controllers/admin/carryforward.sql
+++ b/system/application/controllers/admin/carryforward.sql
@@ -22,8 +22,8 @@ CREATE TABLE IF NOT EXISTS settings (
name varchar(100) NOT NULL,
address varchar(255) NOT NULL,
email varchar(100) NOT NULL,
- ay_start datetime NOT NULL,
- ay_end datetime 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,
diff --git a/system/application/controllers/admin/create.php b/system/application/controllers/admin/create.php
index 8d3a036..8c47a7c 100644
--- a/system/application/controllers/admin/create.php
+++ b/system/application/controllers/admin/create.php
@@ -54,16 +54,16 @@ class Create extends Controller {
'size' => '40',
'value' => '',
);
- $data['assy_start'] = array(
- 'name' => 'assy_start',
- 'id' => 'assy_start',
+ $data['fy_start'] = array(
+ 'name' => 'fy_start',
+ 'id' => 'fy_start',
'maxlength' => '11',
'size' => '11',
'value' => $default_start,
);
- $data['assy_end'] = array(
- 'name' => 'assy_end',
- 'id' => 'assy_end',
+ $data['fy_end'] = array(
+ 'name' => 'fy_end',
+ 'id' => 'fy_end',
'maxlength' => '11',
'size' => '11',
'value' => $default_end,
@@ -132,8 +132,8 @@ class Create extends Controller {
if ($_POST)
{
$this->config->set_item('account_date_format', $this->input->post('account_date', TRUE));
- $this->form_validation->set_rules('assy_start', 'Assessment Year Start', 'trim|required|is_date');
- $this->form_validation->set_rules('assy_end', 'Assessment Year End', 'trim|required|is_date');
+ $this->form_validation->set_rules('fy_start', 'Financial Year Start', 'trim|required|is_date');
+ $this->form_validation->set_rules('fy_end', 'Financial Year End', 'trim|required|is_date');
}
$this->form_validation->set_rules('account_currency', 'Currency', 'trim|max_length[10]');
$this->form_validation->set_rules('account_date', 'Date', 'trim|max_length[10]');
@@ -150,8 +150,8 @@ class Create extends Controller {
$data['account_name']['value'] = $this->input->post('account_name', TRUE);
$data['account_address']['value'] = $this->input->post('account_address', TRUE);
$data['account_email']['value'] = $this->input->post('account_email', TRUE);
- $data['assy_start']['value'] = $this->input->post('assy_start', TRUE);
- $data['assy_end']['value'] = $this->input->post('assy_end', TRUE);
+ $data['fy_start']['value'] = $this->input->post('fy_start', TRUE);
+ $data['fy_end']['value'] = $this->input->post('fy_end', TRUE);
$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);
@@ -178,8 +178,8 @@ class Create extends Controller {
$data_account_name = $this->input->post('account_name', TRUE);
$data_account_address = $this->input->post('account_address', TRUE);
$data_account_email = $this->input->post('account_email', TRUE);
- $data_assy_start = date_php_to_mysql($this->input->post('assy_start', TRUE));
- $data_assy_end = date_php_to_mysql_end_time($this->input->post('assy_end', TRUE));
+ $data_fy_start = date_php_to_mysql($this->input->post('fy_start', TRUE));
+ $data_fy_end = date_php_to_mysql_end_time($this->input->post('fy_end', TRUE));
$data_account_currency = $this->input->post('account_currency', TRUE);
$data_account_date_form = $this->input->post('account_date', TRUE);
/* Checking for valid format */
@@ -265,7 +265,7 @@ class Create extends Controller {
}
/* Adding the account settings */
- $newacc->query("INSERT INTO settings (id, label, name, address, email, ay_start, ay_end, currency_symbol, date_format, timezone, database_version) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array(1, "", $data_account_name, $data_account_address, $data_account_email, $data_assy_start, $data_assy_end, $data_account_currency, $data_account_date, $data_account_timezone, 1));
+ $newacc->query("INSERT INTO settings (id, label, 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');
/* Adding account settings to file. Code copied from manage controller */
diff --git a/system/application/controllers/admin/database.sql b/system/application/controllers/admin/database.sql
index 6e03ff0..127d588 100644
--- a/system/application/controllers/admin/database.sql
+++ b/system/application/controllers/admin/database.sql
@@ -22,8 +22,8 @@ CREATE TABLE IF NOT EXISTS settings (
name varchar(100) NOT NULL,
address varchar(255) NOT NULL,
email varchar(100) NOT NULL,
- ay_start datetime NOT NULL,
- ay_end datetime 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,
diff --git a/system/application/controllers/admin/welcome.php b/system/application/controllers/admin/welcome.php
index 87004dd..bc7438a 100644
--- a/system/application/controllers/admin/welcome.php
+++ b/system/application/controllers/admin/welcome.php
@@ -122,8 +122,8 @@ class Welcome extends Controller {
$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($account_d->ay_start) . "</b>";
- $data['current_account'] .= " to " . "<b>" . date_mysql_to_php($account_d->ay_end) . "</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')) . " )";
}
}
diff --git a/system/application/controllers/report.php b/system/application/controllers/report.php
index 158b366..22fd4f6 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -76,7 +76,7 @@ class Report extends Controller {
$trialbalance[$counter] = array ("TRIAL BALANCE", "", "", "", "", "", "", "", "");
$counter++;
- $trialbalance[$counter] = array ("AY " . date_mysql_to_php($this->config->item('account_ay_start')) . " - " . date_mysql_to_php($this->config->item('account_ay_end')), "", "", "", "", "", "", "", "");
+ $trialbalance[$counter] = array ("FY " . date_mysql_to_php($this->config->item('account_fy_start')) . " - " . date_mysql_to_php($this->config->item('account_fy_end')), "", "", "", "", "", "", "", "");
$counter++;
$trialbalance[$counter][0]= "Ledger";
@@ -184,7 +184,7 @@ class Report extends Controller {
$ledgerst[$counter] = array ("", "", "LEDGER STATEMENT FOR " . strtoupper($this->Ledger_model->get_name($ledger_id)), "", "", "", "", "", "", "", "");
$counter++;
- $ledgerst[$counter] = array ("", "", "AY " . date_mysql_to_php($this->config->item('account_ay_start')) . " - " . date_mysql_to_php($this->config->item('account_ay_end')), "", "", "", "", "", "", "", "");
+ $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";
diff --git a/system/application/controllers/setting.php b/system/application/controllers/setting.php
index 7f96c5f..114fecf 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -55,8 +55,8 @@ class Setting extends Controller {
'value' => ($account_data) ? echo_value($account_data->email) : '',
);
- $data['assy_start'] = ($account_data) ? date_mysql_to_php(echo_value($account_data->ay_start)) : "error";
- $data['assy_end'] = ($account_data) ? date_mysql_to_php(echo_value($account_data->ay_end)) : "error";
+ $data['fy_start'] = ($account_data) ? date_mysql_to_php(echo_value($account_data->fy_start)) : "error";
+ $data['fy_end'] = ($account_data) ? date_mysql_to_php(echo_value($account_data->fy_end)) : "error";
$data['account_currency'] = array(
'name' => 'account_currency',
@@ -141,7 +141,7 @@ class Setting extends Controller {
$this->template->set('page_title', 'Carry forward account');
/* Form fields */
- $last_year_end = $this->config->item('account_ay_end');
+ $last_year_end = $this->config->item('account_fy_end');
list($last_year_end_date, $last_year_end_time) = explode(' ', $last_year_end);
list($last_year_end_year, $last_year_end_month, $last_year_end_day) = explode('-', $last_year_end_date);
$last_year_end_ts = strtotime($last_year_end);
@@ -164,16 +164,16 @@ class Setting extends Controller {
'size' => '40',
'value' => '',
);
- $data['assy_start'] = array(
- 'name' => 'assy_start',
- 'id' => 'assy_start',
+ $data['fy_start'] = array(
+ 'name' => 'fy_start',
+ 'id' => 'fy_start',
'maxlength' => '11',
'size' => '11',
'value' => date_mysql_to_php($default_start),
);
- $data['assy_end'] = array(
- 'name' => 'assy_end',
- 'id' => 'assy_end',
+ $data['fy_end'] = array(
+ 'name' => 'fy_end',
+ 'id' => 'fy_end',
'maxlength' => '11',
'size' => '11',
'value' => date_mysql_to_php($default_end),
@@ -224,8 +224,8 @@ class Setting extends Controller {
/* Form validations */
$this->form_validation->set_rules('account_label', 'C/F Label', 'trim|required|min_length[2]|max_length[30]|alpha_numeric');
$this->form_validation->set_rules('account_name', 'C/F Account Name', 'trim|required|min_length[2]|max_length[100]');
- $this->form_validation->set_rules('assy_start', 'C/F Assessment Year Start', 'trim|required|is_date');
- $this->form_validation->set_rules('assy_end', 'C/F Assessment Year End', 'trim|required|is_date');
+ $this->form_validation->set_rules('fy_start', 'C/F Financial Year Start', 'trim|required|is_date');
+ $this->form_validation->set_rules('fy_end', 'C/F Financial Year End', 'trim|required|is_date');
$this->form_validation->set_rules('database_name', 'Database Name', 'trim|required');
$this->form_validation->set_rules('database_username', 'Database Username', 'trim|required');
@@ -235,8 +235,8 @@ class Setting extends Controller {
{
$data['account_label']['value'] = $this->input->post('account_label', TRUE);
$data['account_name']['value'] = $this->input->post('account_name', TRUE);
- $data['assy_start']['value'] = $this->input->post('assy_start', TRUE);
- $data['assy_end']['value'] = $this->input->post('assy_end', TRUE);
+ $data['fy_start']['value'] = $this->input->post('fy_start', TRUE);
+ $data['fy_end']['value'] = $this->input->post('fy_end', TRUE);
$data['create_database'] = $this->input->post('create_database', TRUE);
$data['database_name']['value'] = $this->input->post('database_name', TRUE);
@@ -260,8 +260,8 @@ class Setting extends Controller {
$data_account_name = $this->input->post('account_name', TRUE);
$data_account_address = $this->config->item('account_address');
$data_account_email = $this->config->item('account_email');
- $data_assy_start = date_php_to_mysql($this->input->post('assy_start', TRUE));
- $data_assy_end = date_php_to_mysql_end_time($this->input->post('assy_end', TRUE));
+ $data_fy_start = date_php_to_mysql($this->input->post('fy_start', TRUE));
+ $data_fy_end = date_php_to_mysql_end_time($this->input->post('fy_end', TRUE));
$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');
@@ -343,7 +343,7 @@ class Setting extends Controller {
}
/* Adding the account settings */
- $newacc->query("INSERT INTO settings (id, label, name, address, email, ay_start, ay_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_assy_start, $data_assy_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->query("INSERT INTO settings (id, label, 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');
diff --git a/system/application/libraries/Startup.php b/system/application/libraries/Startup.php
index 1712a0b..b5cd1ff 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -134,8 +134,8 @@ class Startup
$CI->config->set_item('account_name', $account_d->name);
$CI->config->set_item('account_address', $account_d->address);
$CI->config->set_item('account_email', $account_d->email);
- $CI->config->set_item('account_ay_start', $account_d->ay_start);
- $CI->config->set_item('account_ay_end', $account_d->ay_end);
+ $CI->config->set_item('account_fy_start', $account_d->fy_start);
+ $CI->config->set_item('account_fy_end', $account_d->fy_end);
$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);
diff --git a/system/application/views/admin/create.php b/system/application/views/admin/create.php
index 983faf7..86deaad 100644
--- a/system/application/views/admin/create.php
+++ b/system/application/views/admin/create.php
@@ -40,19 +40,19 @@
echo "</p>";
echo "<p>";
- echo form_label('Assessment Year Start', 'assy_start');
+ echo form_label('Financial Year Start', 'fy_start');
echo "<br />";
- echo form_input_date($assy_start);
+ echo form_input_date($fy_start);
echo "<br />";
- echo "<span class=\"form-help-text\">Warning : Assessment Year Start cannot be changed later</span>";
+ echo "<span class=\"form-help-text\">Warning : Financial Year Start cannot be changed later.<br />Format as per 'Date Foramt' selected abobe.</span>";
echo "</p>";
echo "<p>";
- echo form_label('Assessment Year End', 'assy_end');
+ echo form_label('Financial Year End', 'fy_end');
echo "<br />";
- echo form_input_date($assy_end);
+ echo form_input_date($fy_end);
echo "<br />";
- echo "<span class=\"form-help-text\">Warning : Assessment Year End cannot be changed later</span>";
+ echo "<span class=\"form-help-text\">Warning : Financial Year End cannot be changed later.<br />Format as per 'Date Foramt' selected abobe.</span>";
echo "</p>";
echo "<p>";
diff --git a/system/application/views/admin/welcome.php b/system/application/views/admin/welcome.php
index 90e68d9..2a8b841 100644
--- a/system/application/views/admin/welcome.php
+++ b/system/application/views/admin/welcome.php
@@ -9,7 +9,7 @@
<?php echo anchor('admin/create', 'Create Account', array('title' => 'Create a new account')); ?>
</div>
<div class="settings-desc">
- Create a new webzash account
+ Create a new account
</div>
</div>
<div class="settings-container">
@@ -17,7 +17,7 @@
<?php echo anchor('admin/active', 'Change Active Account', array('title' => 'Change active account')); ?>
</div>
<div class="settings-desc">
- Change existing active webzash account
+ Change existing active account
</div>
</div>
<div class="settings-container">
@@ -25,7 +25,7 @@
<?php echo anchor('admin/manage', 'Manage Accounts', array('title' => 'Manage existing accounts')); ?>
</div>
<div class="settings-desc">
- Manage existing webzash accounts
+ Manage existing accounts
</div>
</div>
</div>
diff --git a/system/application/views/setting/account.php b/system/application/views/setting/account.php
index a4a5647..496a34b 100644
--- a/system/application/views/setting/account.php
+++ b/system/application/views/setting/account.php
@@ -32,15 +32,15 @@
echo "</p>";
echo "<p>";
- echo form_label('Assessment Year Start', 'assy_start');
+ echo form_label('Financial Year Start', 'fy_start');
echo "<br />";
- echo $assy_start;
+ echo $fy_start;
echo "</p>";
echo "<p>";
- echo form_label('Assessment Year End', 'assy_end');
+ echo form_label('Financial Year End', 'fy_end');
echo "<br />";
- echo $assy_end;
+ echo $fy_end;
echo "</p>";
echo "<p>";
diff --git a/system/application/views/setting/cf.php b/system/application/views/setting/cf.php
index 98ccc1b..03b1c53 100644
--- a/system/application/views/setting/cf.php
+++ b/system/application/views/setting/cf.php
@@ -16,15 +16,19 @@
echo "</p>";
echo "<p>";
- echo form_label('C/F Assessment Year Start', 'assy_start');
+ echo form_label('C/F Financial Year Start', 'fy_start');
echo "<br />";
- echo form_input_date($assy_start);
+ echo form_input_date($fy_start);
+ echo "<br />";
+ echo "<span class=\"form-help-text\">Foramt : " . $this->config->item('account_date_format') . "</span>";
echo "</p>";
echo "<p>";
- echo form_label('C/F Assessment Year End', 'assy_end');
+ echo form_label('C/F Financial Year End', 'fy_end');
+ echo "<br />";
+ echo form_input_date($fy_end);
echo "<br />";
- echo form_input_date($assy_end);
+ echo "<span class=\"form-help-text\">Format : " . $this->config->item('account_date_format') . "</span>";
echo "</p>";
echo "<p>";
diff --git a/system/application/views/template.php b/system/application/views/template.php
index 52cb6a5..1fb2936 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -64,9 +64,9 @@ $(document).ready(function() {
<?php
echo $this->config->item('account_name');
echo "<br />";
- echo date_mysql_to_php($this->config->item('account_ay_start'));
+ echo date_mysql_to_php_display($this->config->item('account_fy_start'));
echo " - ";
- echo date_mysql_to_php($this->config->item('account_ay_end'));
+ echo date_mysql_to_php_display($this->config->item('account_fy_end'));
?>
</div>
</div>
commit 242af713ae694153923cfe238079eaebe2dab1a2
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sat Dec 11 19:38:36 2010 +0530
CF Closing Balance of only Assets and Liabilities
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 44ee141..7f96c5f 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -136,6 +136,7 @@ class Setting extends Controller {
function cf()
{
$this->load->helper('file');
+ $this->load->library('accountlist');
$this->load->model('Ledger_model');
$this->template->set('page_title', 'Carry forward account');
@@ -365,25 +366,41 @@ class Setting extends Controller {
}
}
+ /* Only importing Assets and Liability closing balance */
+ $assets = new Accountlist();
+ $assets->init(1);
+ $liability = new Accountlist();
+ $liability->init(2);
+ $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");
foreach ($ledger_q->result() as $row)
{
- /* Calculating closing balance for previous year */
- $cl_balance = $this->Ledger_model->get_ledger_balance($row->id);
- if ($cl_balance < 0)
+ /* CF only Assets and Liability with Closing Balance */
+ if (in_array($row->id, $cf_ledgers))
{
- $op_balance = -$cl_balance;
- $op_balance_dc = "C";
+ /* Calculating closing balance for previous year */
+ $cl_balance = $this->Ledger_model->get_ledger_balance($row->id);
+ if ($cl_balance < 0)
+ {
+ $op_balance = -$cl_balance;
+ $op_balance_dc = "C";
+ } else {
+ $op_balance = $cl_balance;
+ $op_balance_dc = "D";
+ }
+ 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');
+ $cf_status = FALSE;
+ }
} else {
- $op_balance = $cl_balance;
- $op_balance_dc = "D";
- }
-
- 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');
- $cf_status = FALSE;
+ 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');
+ $cf_status = FALSE;
+ }
}
}
diff --git a/system/application/libraries/Accountlist.php b/system/application/libraries/Accountlist.php
index 22bc6c2..d9a52b3 100644
--- a/system/application/libraries/Accountlist.php
+++ b/system/application/libraries/Accountlist.php
@@ -367,5 +367,30 @@ class Accountlist
self::$max_depth = 0;
self::$temp_max = 0;
}
+
+ /*
+ * Return a array of sub ledgers with the object
+ * Used in CF ledgers of type Assets and Liabilities
+ */
+ function get_ledger_ids()
+ {
+ $ledgers = array();
+ if (count($this->children_ledgers) > 0)
+ {
+ foreach ($this->children_ledgers as $id => $data)
+ {
+ $ledgers[] = $data['id'];
+ }
+ }
+ if (count($this->children_groups) > 0)
+ {
+ foreach ($this->children_groups as $id => $data)
+ {
+ foreach ($data->get_ledger_ids() as $row)
+ $ledgers[] = $row;
+ }
+ }
+ return $ledgers;
+ }
}