CHANGELOG.txt | 16
TODO.txt | 6
db-update.txt | 26
system/application/assets/js/shortcuts.js | 10
system/application/assets/js/shortcutslibrary.js | 163 ++
system/application/config/config.php | 2
system/application/controllers/admin/create.php | 46
system/application/controllers/admin/initialize.sql | 8
system/application/controllers/admin/schema.sql | 25
system/application/controllers/group.php | 8
system/application/controllers/ledger.php | 21
system/application/controllers/report.php | 26
system/application/controllers/setting.php | 964 ----------------
system/application/controllers/setting/account.php | 175 ++
system/application/controllers/setting/backup.php | 56
system/application/controllers/setting/cf.php | 390 ++++++
system/application/controllers/setting/email.php | 134 ++
system/application/controllers/setting/printer.php | 225 +++
system/application/controllers/setting/vouchertypes.php | 442 +++++++
system/application/controllers/setting/welcome.php | 29
system/application/controllers/tag.php | 2
system/application/controllers/voucher.php | 620 +++++-----
system/application/helpers/custom_helper.php | 107 -
system/application/libraries/Accountlist.php | 9
system/application/libraries/General.php | 28
system/application/libraries/Logger.php | 3
system/application/libraries/MY_Form_validation.php | 37
system/application/libraries/Startup.php | 27
system/application/models/ledger_model.php | 22
system/application/models/voucher_model.php | 10
system/application/views/admin_template.php | 6
system/application/views/help/index.php | 12
system/application/views/ledger/add.php | 2
system/application/views/ledger/edit.php | 2
system/application/views/report/balancesheet.php | 4
system/application/views/report/ledgerst.php | 14
system/application/views/report/reconciliation.php | 12
system/application/views/setting/index.php | 4
system/application/views/setting/vouchertypes/add.php | 67 +
system/application/views/setting/vouchertypes/edit.php | 67 +
system/application/views/setting/vouchertypes/index.php | 25
system/application/views/template.php | 37
system/application/views/user_template.php | 7
system/application/views/voucher/add.php | 26
system/application/views/voucher/downloadpreview.php | 8
system/application/views/voucher/edit.php | 32
system/application/views/voucher/email.php | 4
system/application/views/voucher/emailpreview.php | 10
system/application/views/voucher/index.php | 70 -
system/application/views/voucher/printpreview.php | 8
system/application/views/voucher/view.php | 14
51 files changed, 2558 insertions(+), 1510 deletions(-)
New commits:
commit 99111337bf22cd386070f7813a9f69436d5040f6
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Feb 2 20:27:24 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 58fee84..67442b1 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,3 +1,11 @@
+Webzash Version 1.2 2011-02-02
+------------------------------
+
+ * Added dynamic voucher types
+ * Added dynamic voucher types management interface
+ * Added support for empty voucher number
+ * Updated columns for voucher number and tag id to allow NULL values
+
Webzash Version 1.1 2011-01-28
------------------------------
diff --git a/system/application/config/config.php b/system/application/config/config.php
index 66cf52e..d8b6fcd 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.1';
+$config['application_version'] = '1.2';
/* End of file config.php */
/* Location: ./system/application/config/config.php */
commit 43cf74255bd0e20a7523d8f8cbb74ed8fce3ef6d
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Feb 2 20:19:12 2011 +0530
Fixed UI issue
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/setting/vouchertypes.php
b/system/application/controllers/setting/vouchertypes.php
index b20c07e..a5d368e 100644
--- a/system/application/controllers/setting/vouchertypes.php
+++ b/system/application/controllers/setting/vouchertypes.php
@@ -98,7 +98,7 @@ class VoucherTypes extends Controller {
'2' => 'Atleast one Bank or Cash A/C must be present on Debit
side',
'3' => 'Atleast one Bank or Cash A/C must be present on Credit
side',
'4' => 'Only Bank or Cash A/C can be present on both Debit and Credit
side',
- '5' => 'None of Debit and Credit side can be Bank or Cash A/C',
+ '5' => 'Only NON Bank or Cash A/C can be present on both Debit and
Credit side',
);
$data['voucher_type_base_type_active'] = '1';
@@ -286,7 +286,7 @@ class VoucherTypes extends Controller {
'2' => 'Atleast one Bank or Cash A/C must be present on Debit
side',
'3' => 'Atleast one Bank or Cash A/C must be present on Credit
side',
'4' => 'Only Bank or Cash A/C can be present on both Debit and Credit
side',
- '5' => 'None of Debit and Credit side can be Bank or Cash A/C',
+ '5' => 'Only NON Bank or Cash A/C can be present on both Debit and
Credit side',
);
$data['voucher_type_base_type_active'] = $voucher_type_data->base_type;
commit acc37f78879f0bb54eb93971232a7f3b72437afc
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Feb 2 20:11:10 2011 +0530
Allow empty Voucher numbers
- Voucher numner column allows NULL values for empty
voucher number
- Tag id column allows NULL values and also defaults
to NULL instead of 0
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/db-update.txt b/db-update.txt
index af027db..6ab82ca 100644
--- a/db-update.txt
+++ b/db-update.txt
@@ -21,6 +21,8 @@ ALTER TABLE settings DROP journal_voucher_prefix;
ALTER TABLE settings DROP voucher_number_padding;
ALTER TABLE vouchers CHANGE type voucher_type INT(5) NOT NULL;
+ALTER TABLE vouchers CHANGE number number INT(11) NULL;
+ALTER TABLE vouchers CHANGE tag_id tag_id INT(11) NULL;
//--------------------------------- VERSION 2 ----------------------------------
diff --git a/system/application/controllers/admin/schema.sql
b/system/application/controllers/admin/schema.sql
index 69a571c..2f8f010 100644
--- a/system/application/controllers/admin/schema.sql
+++ b/system/application/controllers/admin/schema.sql
@@ -33,9 +33,9 @@ CREATE TABLE IF NOT EXISTS voucher_types (
CREATE TABLE IF NOT EXISTS vouchers (
id int(11) NOT NULL AUTO_INCREMENT,
- tag_id int(11) NOT NULL DEFAULT '0',
+ tag_id int(11) DEFAULT NULL,
voucher_type int(5) NOT NULL,
- number int(11) NOT NULL,
+ number int(11) DEFAULT 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',
diff --git a/system/application/controllers/setting/vouchertypes.php
b/system/application/controllers/setting/vouchertypes.php
index 311cf3c..b20c07e 100644
--- a/system/application/controllers/setting/vouchertypes.php
+++ b/system/application/controllers/setting/vouchertypes.php
@@ -92,7 +92,7 @@ class VoucherTypes extends Controller {
);
$data['voucher_type_base_types'] = array('1' => 'Normal
Vocuher', '2' => 'Stock Voucher');
- $data['voucher_type_numberings'] = array('1' => 'Auto',
'2' => 'Manual');
+ $data['voucher_type_numberings'] = array('1' => 'Auto',
'2' => 'Manual (required)', '3' => 'Manual
(optional)');
$data['bank_cash_ledger_restrictions'] = array(
'1' => 'Unrestricted',
'2' => 'Atleast one Bank or Cash A/C must be present on Debit
side',
@@ -150,7 +150,7 @@ class VoucherTypes extends Controller {
if (($data_voucher_type_base_type < 1) or ($data_voucher_type_base_type > 2))
$data_voucher_type_base_type = 1;
- if (($data_voucher_type_numbering < 1) or ($data_voucher_type_numbering > 2))
+ if (($data_voucher_type_numbering < 1) or ($data_voucher_type_numbering > 3))
$data_voucher_type_numbering = 1;
if (($data_bank_cash_ledger_restriction < 1) or ($data_bank_cash_ledger_restriction
> 5))
@@ -280,7 +280,7 @@ class VoucherTypes extends Controller {
);
$data['voucher_type_base_types'] = array('1' => 'Normal
Vocuher', '2' => 'Stock Voucher');
- $data['voucher_type_numberings'] = array('1' => 'Auto',
'2' => 'Manual');
+ $data['voucher_type_numberings'] = array('1' => 'Auto',
'2' => 'Manual (required)', '3' => 'Manual
(optional)');
$data['bank_cash_ledger_restrictions'] = array(
'1' => 'Unrestricted',
'2' => 'Atleast one Bank or Cash A/C must be present on Debit
side',
@@ -340,7 +340,7 @@ class VoucherTypes extends Controller {
if (($data_voucher_type_base_type < 1) or ($data_voucher_type_base_type > 2))
$data_voucher_type_base_type = 1;
- if (($data_voucher_type_numbering < 1) or ($data_voucher_type_numbering > 2))
+ if (($data_voucher_type_numbering < 1) or ($data_voucher_type_numbering > 3))
$data_voucher_type_numbering = 1;
if (($data_bank_cash_ledger_restriction < 1) or ($data_bank_cash_ledger_restriction
> 5))
diff --git a/system/application/controllers/tag.php
b/system/application/controllers/tag.php
index 99680d5..a615de5 100644
--- a/system/application/controllers/tag.php
+++ b/system/application/controllers/tag.php
@@ -293,7 +293,7 @@ class Tag extends Controller {
/* Deleting Tag */
$this->db->trans_start();
$update_data = array(
- 'tag_id' => 0,
+ 'tag_id' => NULL,
);
if ( ! $this->db->where('tag_id', $id)->update('vouchers',
$update_data))
{
diff --git a/system/application/controllers/voucher.php
b/system/application/controllers/voucher.php
index 43051af..cd71753 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -27,6 +27,12 @@ class Voucher extends Controller {
if ($voucher_type == 'tag')
{
$tag_id = (int)$this->uri->segment(4);
+ if ($tag_id < 1)
+ {
+ $this->messages->add('Invalid Tag.', 'error');
+ redirect('voucher/show/all');
+ return;
+ }
$data['tag_id'] = $tag_id;
$tag_name = $this->Tag_model->tag_name($tag_id);
$this->template->set('page_title', 'Vouchers Tagged "' .
$tag_name . '"');
@@ -270,8 +276,10 @@ class Voucher extends Controller {
$data['voucher_tag'] = 0;
/* Form validations */
- if ($current_voucher_type['numbering'] == 2)
+ if ($current_voucher_type['numbering'] == '2')
$this->form_validation->set_rules('voucher_number', 'Voucher
Number', 'trim|required|is_natural_no_zero|uniquevoucherno[' .
$voucher_type_id . ']');
+ else if ($current_voucher_type['numbering'] == '3')
+ $this->form_validation->set_rules('voucher_number', 'Voucher
Number', 'trim|is_natural_no_zero|uniquevoucherno[' . $voucher_type_id .
']');
else
$this->form_validation->set_rules('voucher_number', 'Voucher
Number', 'trim|is_natural_no_zero|uniquevoucherno[' . $voucher_type_id .
']');
$this->form_validation->set_rules('voucher_date', 'Voucher Date',
'trim|required|is_date|is_date_within_range');
@@ -432,9 +440,13 @@ class Voucher extends Controller {
}
/* Adding main voucher */
- if ($current_voucher_type['numbering'] == 2)
+ if ($current_voucher_type['numbering'] == '2')
{
$data_number = $this->input->post('voucher_number', TRUE);
+ } else if ($current_voucher_type['numbering'] == '3') {
+ $data_number = $this->input->post('voucher_number', TRUE);
+ if ( ! $data_number)
+ $data_number = NULL;
} else {
if ($this->input->post('voucher_number', TRUE))
$data_number = $this->input->post('voucher_number', TRUE);
@@ -445,6 +457,8 @@ 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);
+ if ($data_tag < 1)
+ $data_tag = NULL;
$data_type = $voucher_type_id;
$data_date = date_php_to_mysql($data_date); // Converting date to MySQL
$voucher_id = NULL;
@@ -648,7 +662,10 @@ class Voucher extends Controller {
}
/* Form validations */
- $this->form_validation->set_rules('voucher_number', 'Voucher
Number', 'trim|required|is_natural_no_zero|uniquevouchernowithid[' .
$voucher_type_id . '.' . $voucher_id . ']');
+ if ($current_voucher_type['numbering'] == '3')
+ $this->form_validation->set_rules('voucher_number', 'Voucher
Number', 'trim|is_natural_no_zero|uniquevouchernowithid[' . $voucher_type_id .
'.' . $voucher_id . ']');
+ else
+ $this->form_validation->set_rules('voucher_number', 'Voucher
Number', 'trim|required|is_natural_no_zero|uniquevouchernowithid[' .
$voucher_type_id . '.' . $voucher_id . ']');
$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');
@@ -791,10 +808,19 @@ class Voucher extends Controller {
}
/* Updating main voucher */
- $data_number = $this->input->post('voucher_number', TRUE);
+ if ($current_voucher_type['numbering'] == '3') {
+ $data_number = $this->input->post('voucher_number', TRUE);
+ if ( ! $data_number)
+ $data_number = NULL;
+ } else {
+ $data_number = $this->input->post('voucher_number', TRUE);
+ }
+
$data_date = $this->input->post('voucher_date', TRUE);
$data_narration = $this->input->post('voucher_narration', TRUE);
$data_tag = $this->input->post('voucher_tag', TRUE);
+ if ($data_tag < 1)
+ $data_tag = NULL;
$data_type = $voucher_type_id;
$data_date = date_php_to_mysql($data_date); // Converting date to MySQL
$data_has_reconciliation = $this->input->post('has_reconciliation',
TRUE);
diff --git a/system/application/helpers/custom_helper.php
b/system/application/helpers/custom_helper.php
index 7c7e4f7..21f23a4 100644
--- a/system/application/helpers/custom_helper.php
+++ b/system/application/helpers/custom_helper.php
@@ -175,13 +175,17 @@ if ( ! function_exists('full_voucher_number'))
{
$CI =& get_instance();
$voucher_type_all = $CI->config->item('account_voucher_types');
-
+ $return_html = "";
if ( ! $voucher_type_all[$voucher_type_id])
{
- return $voucher_number;
+ $return_html = $voucher_number;
} else {
- return $voucher_type_all[$voucher_type_id]['prefix'] .
str_pad($voucher_number, $voucher_type_all[$voucher_type_id]['zero_padding'],
'0', STR_PAD_LEFT) . $voucher_type_all[$voucher_type_id]['suffix'];
+ $return_html = $voucher_type_all[$voucher_type_id]['prefix'] .
str_pad($voucher_number, $voucher_type_all[$voucher_type_id]['zero_padding'],
'0', STR_PAD_LEFT) . $voucher_type_all[$voucher_type_id]['suffix'];
}
+ if ($return_html)
+ return $return_html;
+ else
+ return " ";
}
}
diff --git a/system/application/views/setting/vouchertypes/add.php
b/system/application/views/setting/vouchertypes/add.php
index da88ba2..a312630 100644
--- a/system/application/views/setting/vouchertypes/add.php
+++ b/system/application/views/setting/vouchertypes/add.php
@@ -28,18 +28,12 @@
echo "</p>";
echo "<p>";
- echo form_label('Numbering', 'voucher_type_numbering');
+ echo form_label('Voucher Numbering', 'voucher_type_numbering');
echo "<br />";
echo form_dropdown('voucher_type_numbering', $voucher_type_numberings,
$voucher_type_numbering_active);
echo "</p>";
echo "<p>";
- echo form_label('Restrictions', 'bank_cash_ledger_restriction');
- echo "<br />";
- echo form_dropdown('bank_cash_ledger_restriction',
$bank_cash_ledger_restrictions, $bank_cash_ledger_restriction_active);
- echo "</p>";
-
- echo "<p>";
echo form_label('Prefix', 'voucher_type_prefix');
echo "<br />";
echo form_input($voucher_type_prefix);
@@ -58,6 +52,12 @@
echo "</p>";
echo "<p>";
+ echo form_label('Restrictions', 'bank_cash_ledger_restriction');
+ echo "<br />";
+ echo form_dropdown('bank_cash_ledger_restriction',
$bank_cash_ledger_restrictions, $bank_cash_ledger_restriction_active);
+ echo "</p>";
+
+ echo "<p>";
echo form_submit('submit', 'Create');
echo " ";
echo anchor('setting/vouchertypes', 'Back', 'Back to Voucher
Types');
diff --git a/system/application/views/setting/vouchertypes/edit.php
b/system/application/views/setting/vouchertypes/edit.php
index b686d10..b3a8513 100644
--- a/system/application/views/setting/vouchertypes/edit.php
+++ b/system/application/views/setting/vouchertypes/edit.php
@@ -28,18 +28,12 @@
echo "</p>";
echo "<p>";
- echo form_label('Numbering', 'voucher_type_numbering');
+ echo form_label('Voucher Numbering', 'voucher_type_numbering');
echo "<br />";
echo form_dropdown('voucher_type_numbering', $voucher_type_numberings,
$voucher_type_numbering_active);
echo "</p>";
echo "<p>";
- echo form_label('Restrictions', 'bank_cash_ledger_restriction');
- echo "<br />";
- echo form_dropdown('bank_cash_ledger_restriction',
$bank_cash_ledger_restrictions, $bank_cash_ledger_restriction_active);
- echo "</p>";
-
- echo "<p>";
echo form_label('Prefix', 'voucher_type_prefix');
echo "<br />";
echo form_input($voucher_type_prefix);
@@ -58,6 +52,12 @@
echo "</p>";
echo "<p>";
+ echo form_label('Restrictions', 'bank_cash_ledger_restriction');
+ echo "<br />";
+ echo form_dropdown('bank_cash_ledger_restriction',
$bank_cash_ledger_restrictions, $bank_cash_ledger_restriction_active);
+ echo "</p>";
+
+ echo "<p>";
echo form_submit('submit', 'Update');
echo " ";
echo anchor('setting/vouchertypes', 'Back', 'Back to Voucher
Types');
commit 44d89bfd4dc5fcda0bee40d1b4cf9435bd98f159
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Feb 2 15:14:26 2011 +0530
Updated to use Voucher Type auto numbering if enabled
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 7405233..43051af 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -270,7 +270,10 @@ class Voucher extends Controller {
$data['voucher_tag'] = 0;
/* Form validations */
- $this->form_validation->set_rules('voucher_number', 'Voucher
Number', 'trim|is_natural_no_zero|uniquevoucherno[' . $voucher_type_id .
']');
+ if ($current_voucher_type['numbering'] == 2)
+ $this->form_validation->set_rules('voucher_number', 'Voucher
Number', 'trim|required|is_natural_no_zero|uniquevoucherno[' .
$voucher_type_id . ']');
+ else
+ $this->form_validation->set_rules('voucher_number', 'Voucher
Number', 'trim|is_natural_no_zero|uniquevoucherno[' . $voucher_type_id .
']');
$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');
@@ -429,10 +432,15 @@ class Voucher extends Controller {
}
/* Adding main voucher */
- if ($this->input->post('voucher_number', TRUE))
+ if ($current_voucher_type['numbering'] == 2)
+ {
$data_number = $this->input->post('voucher_number', TRUE);
- else
- $data_number = $this->Voucher_model->next_voucher_number($voucher_type_id);
+ } else {
+ 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_id);
+ }
$data_date = $this->input->post('voucher_date', TRUE);
$data_narration = $this->input->post('voucher_narration', TRUE);
commit a8f5189da14c6c263e917b4b52a11d190165cb5b
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Feb 2 14:56:40 2011 +0530
Updated Voucher Type zero padding
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/helpers/custom_helper.php
b/system/application/helpers/custom_helper.php
index 8ec3256..7c7e4f7 100644
--- a/system/application/helpers/custom_helper.php
+++ b/system/application/helpers/custom_helper.php
@@ -180,7 +180,7 @@ if ( ! function_exists('full_voucher_number'))
{
return $voucher_number;
} else {
- return $voucher_type_all[$voucher_type_id]['prefix'] . $voucher_number .
$voucher_type_all[$voucher_type_id]['suffix'];
+ return $voucher_type_all[$voucher_type_id]['prefix'] .
str_pad($voucher_number, $voucher_type_all[$voucher_type_id]['zero_padding'],
'0', STR_PAD_LEFT) . $voucher_type_all[$voucher_type_id]['suffix'];
}
}
}
commit f33879517ef036f8c8f1ac8c5acccfcb84b9fec9
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Feb 2 14:50:18 2011 +0530
Added Voucher Type delete action
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/setting/vouchertypes.php
b/system/application/controllers/setting/vouchertypes.php
index 3b7828c..311cf3c 100644
--- a/system/application/controllers/setting/vouchertypes.php
+++ b/system/application/controllers/setting/vouchertypes.php
@@ -34,6 +34,14 @@ class VoucherTypes extends Controller {
{
$this->template->set('page_title', 'Add Voucher Type');
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('setting/vouchertypes');
+ return;
+ }
+
/* Form fields */
$data['voucher_type_label'] = array(
'name' => 'voucher_type_label',
@@ -193,6 +201,14 @@ class VoucherTypes extends Controller {
{
$this->template->set('page_title', 'Edit Voucher Type');
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('setting/vouchertypes');
+ return;
+ }
+
/* Checking for valid data */
$id = $this->input->xss_clean($id);
$id = (int)$id;
@@ -346,19 +362,80 @@ class VoucherTypes extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error updating Voucher Type - ' .
$data_voucher_type_name . '.', 'error');
- $this->logger->write_message("error", "Error updating Voucher
Type named " . $data_voucher_type_name);
+ $this->logger->write_message("error", "Error updating Voucher
Type named " . $data_voucher_type_name . " [id:" . $id . "]");
$this->template->load('template', 'setting/vouchertypes/edit',
$data);
return;
} else {
$this->db->trans_complete();
$this->messages->add('Updated Voucher Type - ' .
$data_voucher_type_name . '.', 'success');
- $this->logger->write_message("success", "Updated Voucher Type
named " . $data_voucher_type_name);
+ $this->logger->write_message("success", "Updated Voucher Type
named " . $data_voucher_type_name . " [id:" . $id . "]");
redirect('setting/vouchertypes');
return;
}
}
return;
}
+
+ function delete($id)
+ {
+ /* Check for account lock */
+ if ($this->config->item('account_locked') == 1)
+ {
+ $this->messages->add('Account is locked.', 'error');
+ redirect('setting/vouchertypes');
+ return;
+ }
+
+ /* Checking for valid data */
+ $id = $this->input->xss_clean($id);
+ $id = (int)$id;
+ if ($id <= 0)
+ {
+ $this->messages->add('Invalid Voucher Type.', 'error');
+ redirect('setting/vouchertypes');
+ return;
+ }
+
+ /* Loading current Voucher Type */
+ $this->db->from('voucher_types')->where('id', $id);
+ $voucher_type_data_q = $this->db->get();
+ if ($voucher_type_data_q->num_rows() < 1)
+ {
+ $this->messages->add('Invalid Voucher Type.', 'error');
+ redirect('setting/vouchertypes');
+ return;
+ } else {
+ $voucher_type_data = $voucher_type_data_q->row();
+ }
+
+ /* Check if and Voucher present for the Voucher Type */
+ $this->db->from('vouchers')->where('voucher_type', $id);
+ $voucher_data_q = $this->db->get();
+ if ($voucher_data_q->num_rows() > 0)
+ {
+ $this->messages->add('Cannot delete Voucher Type. There are still ' .
$voucher_data_q->num_rows() . ' Vouchers present.', 'error');
+ redirect('setting/vouchertypes');
+ return;
+ }
+
+ /* Deleting Voucher Types */
+ $this->db->trans_start();
+ if ( ! $this->db->delete('voucher_types', array('id' =>
$id)))
+ {
+ $this->db->trans_rollback();
+ $this->messages->add('Error deleting Voucher Type - ' .
$voucher_type_data->name . '.', 'error');
+ $this->logger->write_message("error", "Error deleting Voucher
Type named " . $voucher_type_data->name . " [id:" . $id .
"]");
+ redirect('setting/vouchertypes');
+ return;
+ } else {
+ $this->db->trans_complete();
+ $this->messages->add('Deleted Voucher Type - ' .
$voucher_type_data->name . '.', 'success');
+ $this->logger->write_message("success", "Deleted Voucher Type
named " . $voucher_type_data->name . " [id:" . $id . "]");
+ redirect('setting/vouchertypes');
+ return;
+ }
+ return;
+ }
}
/* End of file vouchertypes.php */
commit 574aa15a180375262be46555a455dd3c9bb49251
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Feb 2 14:29:15 2011 +0530
Added Voucher Types Edit action
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/setting/vouchertypes.php
b/system/application/controllers/setting/vouchertypes.php
index 2788a0f..3b7828c 100644
--- a/system/application/controllers/setting/vouchertypes.php
+++ b/system/application/controllers/setting/vouchertypes.php
@@ -113,8 +113,8 @@ class VoucherTypes extends Controller {
}
/* Form validations */
- $this->form_validation->set_rules('voucher_type_label', 'Label',
'trim|required|min_length[2]|max_length[15]|alpha');
- $this->form_validation->set_rules('voucher_type_name', 'Name',
'trim|required|min_length[2]|max_length[100]');
+ $this->form_validation->set_rules('voucher_type_label', 'Label',
'trim|required|min_length[2]|max_length[15]|alpha|unique[voucher_types.label]');
+ $this->form_validation->set_rules('voucher_type_name', 'Name',
'trim|required|min_length[2]|max_length[100]|unique[voucher_types.name]');
$this->form_validation->set_rules('voucher_type_description',
'Description', 'trim');
$this->form_validation->set_rules('voucher_type_prefix',
'Prefix', 'trim|max_length[10]');
$this->form_validation->set_rules('voucher_type_suffix',
'Suffix', 'trim|max_length[10]');
@@ -188,6 +188,177 @@ class VoucherTypes extends Controller {
}
return;
}
+
+ function edit($id)
+ {
+ $this->template->set('page_title', 'Edit Voucher Type');
+
+ /* Checking for valid data */
+ $id = $this->input->xss_clean($id);
+ $id = (int)$id;
+ if ($id < 0)
+ {
+ $this->messages->add('Invalid Voucher Type.', 'error');
+ redirect('setting/vouchertypes');
+ return;
+ }
+
+ /* Loading current Voucher Type */
+ $this->db->from('voucher_types')->where('id', $id);
+ $voucher_type_data_q = $this->db->get();
+ if ($voucher_type_data_q->num_rows() < 1)
+ {
+ $this->messages->add('Invalid Voucher Type.', 'error');
+ redirect('setting/vouchertypes');
+ return;
+ }
+ $voucher_type_data = $voucher_type_data_q->row();
+
+ /* Form fields */
+ $data['voucher_type_label'] = array(
+ 'name' => 'voucher_type_label',
+ 'id' => 'voucher_type_label',
+ 'maxlength' => '15',
+ 'size' => '15',
+ 'value' => $voucher_type_data->label,
+ );
+
+ $data['voucher_type_name'] = array(
+ 'name' => 'voucher_type_name',
+ 'id' => 'voucher_type_name',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => $voucher_type_data->name,
+ );
+
+ $data['voucher_type_description'] = array(
+ 'name' => 'voucher_type_description',
+ 'id' => 'voucher_type_description',
+ 'cols' => '47',
+ 'rows' => '5',
+ 'value' => $voucher_type_data->description,
+ );
+
+ $data['voucher_type_prefix'] = array(
+ 'name' => 'voucher_type_prefix',
+ 'id' => 'voucher_type_prefix',
+ 'maxlength' => '10',
+ 'size' => '10',
+ 'value' => $voucher_type_data->prefix,
+ );
+
+ $data['voucher_type_suffix'] = array(
+ 'name' => 'voucher_type_suffix',
+ 'id' => 'voucher_type_suffix',
+ 'maxlength' => '10',
+ 'size' => '10',
+ 'value' => $voucher_type_data->suffix,
+ );
+
+ $data['voucher_type_zero_padding'] = array(
+ 'name' => 'voucher_type_zero_padding',
+ 'id' => 'voucher_type_zero_padding',
+ 'maxlength' => '2',
+ 'size' => '2',
+ 'value' => $voucher_type_data->zero_padding,
+ );
+
+ $data['voucher_type_base_types'] = array('1' => 'Normal
Vocuher', '2' => 'Stock Voucher');
+ $data['voucher_type_numberings'] = array('1' => 'Auto',
'2' => 'Manual');
+ $data['bank_cash_ledger_restrictions'] = array(
+ '1' => 'Unrestricted',
+ '2' => 'Atleast one Bank or Cash A/C must be present on Debit
side',
+ '3' => 'Atleast one Bank or Cash A/C must be present on Credit
side',
+ '4' => 'Only Bank or Cash A/C can be present on both Debit and Credit
side',
+ '5' => 'None of Debit and Credit side can be Bank or Cash A/C',
+ );
+
+ $data['voucher_type_base_type_active'] = $voucher_type_data->base_type;
+ $data['voucher_type_numbering_active'] = $voucher_type_data->numbering;
+ $data['bank_cash_ledger_restriction_active'] =
$voucher_type_data->bank_cash_ledger_restriction;
+ $data['voucher_type_id'] = $id;
+
+ /* Repopulating form */
+ if ($_POST)
+ {
+ $data['voucher_type_label']['value'] =
$this->input->post('voucher_type_label', TRUE);
+ $data['voucher_type_name']['value'] =
$this->input->post('voucher_type_name', TRUE);
+ $data['voucher_type_description']['value'] =
$this->input->post('voucher_type_description', TRUE);
+ $data['voucher_type_prefix']['value'] =
$this->input->post('voucher_type_prefix', TRUE);
+ $data['voucher_type_suffix']['value'] =
$this->input->post('voucher_type_suffix', TRUE);
+ $data['voucher_type_zero_padding']['value'] =
$this->input->post('voucher_type_zero_padding', TRUE);
+
+ $data['voucher_type_base_type_active'] =
$this->input->post('voucher_type_base_type', TRUE);
+ $data['voucher_type_numbering_active'] =
$this->input->post('voucher_type_numbering', TRUE);
+ $data['bank_cash_ledger_restriction_active'] =
$this->input->post('bank_cash_ledger_restriction', TRUE);
+ }
+
+ /* Form validations */
+ $this->form_validation->set_rules('voucher_type_label', 'Label',
'trim|required|min_length[2]|max_length[15]|alpha|uniquewithid[voucher_types.label.'
. $id . ']');
+ $this->form_validation->set_rules('voucher_type_name', 'Name',
'trim|required|min_length[2]|max_length[100]|uniquewithid[voucher_types.name.' .
$id . ']');
+ $this->form_validation->set_rules('voucher_type_description',
'Description', 'trim');
+ $this->form_validation->set_rules('voucher_type_prefix',
'Prefix', 'trim|max_length[10]');
+ $this->form_validation->set_rules('voucher_type_suffix',
'Suffix', 'trim|max_length[10]');
+ $this->form_validation->set_rules('voucher_type_zero_padding', 'Zero
Padding', 'trim|max_length[2]|is_natural');
+
+ /* Validating form */
+ if ($this->form_validation->run() == FALSE)
+ {
+ $this->messages->add(validation_errors(), 'error');
+ $this->template->load('template', 'setting/vouchertypes/edit',
$data);
+ return;
+ }
+ else
+ {
+ $data_voucher_type_id = $id;
+ $data_voucher_type_label =
strtolower($this->input->post('voucher_type_label', TRUE));
+ $data_voucher_type_name =
ucfirst($this->input->post('voucher_type_name', TRUE));
+ $data_voucher_type_description =
$this->input->post('voucher_type_description', TRUE);
+ $data_voucher_type_prefix = $this->input->post('voucher_type_prefix',
TRUE);
+ $data_voucher_type_suffix = $this->input->post('voucher_type_suffix',
TRUE);
+ $data_voucher_type_zero_padding =
$this->input->post('voucher_type_zero_padding', TRUE);
+ $data_voucher_type_base_type =
$this->input->post('voucher_type_base_type', TRUE);
+ $data_voucher_type_numbering =
$this->input->post('voucher_type_numbering', TRUE);
+ $data_bank_cash_ledger_restriction =
$this->input->post('bank_cash_ledger_restriction', TRUE);
+
+ if (($data_voucher_type_base_type < 1) or ($data_voucher_type_base_type > 2))
+ $data_voucher_type_base_type = 1;
+
+ if (($data_voucher_type_numbering < 1) or ($data_voucher_type_numbering > 2))
+ $data_voucher_type_numbering = 1;
+
+ if (($data_bank_cash_ledger_restriction < 1) or ($data_bank_cash_ledger_restriction
> 5))
+ $data_bank_cash_ledger_restriction = 1;
+
+ $this->db->trans_start();
+ $update_data = array(
+ 'label' => $data_voucher_type_label,
+ 'name' => $data_voucher_type_name,
+ 'description' => $data_voucher_type_description,
+ 'base_type' => $data_voucher_type_base_type,
+ 'numbering' => $data_voucher_type_numbering,
+ 'prefix' => $data_voucher_type_prefix,
+ 'suffix' => $data_voucher_type_suffix,
+ 'zero_padding' => $data_voucher_type_zero_padding,
+ 'bank_cash_ledger_restriction' => $data_bank_cash_ledger_restriction,
+ );
+ if ( ! $this->db->where('id',
$data_voucher_type_id)->update('voucher_types', $update_data))
+ {
+ $this->db->trans_rollback();
+ $this->messages->add('Error updating Voucher Type - ' .
$data_voucher_type_name . '.', 'error');
+ $this->logger->write_message("error", "Error updating Voucher
Type named " . $data_voucher_type_name);
+ $this->template->load('template', 'setting/vouchertypes/edit',
$data);
+ return;
+ } else {
+ $this->db->trans_complete();
+ $this->messages->add('Updated Voucher Type - ' .
$data_voucher_type_name . '.', 'success');
+ $this->logger->write_message("success", "Updated Voucher Type
named " . $data_voucher_type_name);
+ redirect('setting/vouchertypes');
+ return;
+ }
+ }
+ return;
+ }
}
/* End of file vouchertypes.php */
diff --git a/system/application/views/setting/vouchertypes/edit.php
b/system/application/views/setting/vouchertypes/edit.php
index 9493133..b686d10 100644
--- a/system/application/views/setting/vouchertypes/edit.php
+++ b/system/application/views/setting/vouchertypes/edit.php
@@ -1,5 +1,5 @@
<?php
- echo form_open('setting/vouchertypes/edit' . $voucher_type_id);
+ echo form_open('setting/vouchertypes/edit/' . $voucher_type_id);
echo "<p>";
echo form_label('Label', 'voucher_type_label');
diff --git a/system/application/views/setting/vouchertypes/index.php
b/system/application/views/setting/vouchertypes/index.php
index 1f997e6..9cc41f4 100644
--- a/system/application/views/setting/vouchertypes/index.php
+++ b/system/application/views/setting/vouchertypes/index.php
@@ -16,8 +16,8 @@
echo "<td>" . $row->label . "</td>";
echo "<td>" . $row->name . "</td>";
echo "<td>" . $row->description . "</td>";
- echo "<td>" . anchor('voucher/edit/' . $row->id ,
"Edit", array('title' => 'Edit ' . $row->name . '
Voucher Type', 'class' => 'red-link')) . " ";
- echo " " . anchor('voucher/delete/' . $row->id ,
img(array('src' => asset_url() . "images/icons/delete.png",
'border' => '0', 'alt' => 'Delete ' . $row->name
. ' Voucher Type', 'class' => "confirmClick", 'title'
=> "Delete Voucher Type")), array('title' => 'Delete ' .
$row->name . ' Voucher Type')) . " ";
+ echo "<td>" . anchor('setting/vouchertypes/edit/' .
$row->id , "Edit", array('title' => 'Edit ' .
$row->name . ' Voucher Type', 'class' => 'red-link')) .
" ";
+ echo " " . anchor('setting/vouchertypes/delete/' .
$row->id , img(array('src' => asset_url() .
"images/icons/delete.png", 'border' => '0', 'alt'
=> 'Delete ' . $row->name . ' Voucher Type', 'class' =>
"confirmClick", 'title' => "Delete Voucher Type")),
array('title' => 'Delete ' . $row->name . ' Voucher Type'))
. " ";
echo "</tr>";
}
?>
commit c71e3ccecbfa2b37d63b7f03f8393141f87369f1
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Feb 1 22:53:17 2011 +0530
Added New Voucher Type action
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/controllers/setting/vouchertypes.php
b/system/application/controllers/setting/vouchertypes.php
index 263918a..2788a0f 100644
--- a/system/application/controllers/setting/vouchertypes.php
+++ b/system/application/controllers/setting/vouchertypes.php
@@ -29,6 +29,165 @@ class VoucherTypes extends Controller {
$this->template->load('template', 'setting/vouchertypes/index',
$data);
return;
}
+
+ function add()
+ {
+ $this->template->set('page_title', 'Add Voucher Type');
+
+ /* Form fields */
+ $data['voucher_type_label'] = array(
+ 'name' => 'voucher_type_label',
+ 'id' => 'voucher_type_label',
+ 'maxlength' => '15',
+ 'size' => '15',
+ 'value' => '',
+ );
+
+ $data['voucher_type_name'] = array(
+ 'name' => 'voucher_type_name',
+ 'id' => 'voucher_type_name',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '',
+ );
+
+ $data['voucher_type_description'] = array(
+ 'name' => 'voucher_type_description',
+ 'id' => 'voucher_type_description',
+ 'cols' => '47',
+ 'rows' => '5',
+ 'value' => '',
+ );
+
+ $data['voucher_type_prefix'] = array(
+ 'name' => 'voucher_type_prefix',
+ 'id' => 'voucher_type_prefix',
+ 'maxlength' => '10',
+ 'size' => '10',
+ 'value' => '',
+ );
+
+ $data['voucher_type_suffix'] = array(
+ 'name' => 'voucher_type_suffix',
+ 'id' => 'voucher_type_suffix',
+ 'maxlength' => '10',
+ 'size' => '10',
+ 'value' => '',
+ );
+
+ $data['voucher_type_zero_padding'] = array(
+ 'name' => 'voucher_type_zero_padding',
+ 'id' => 'voucher_type_zero_padding',
+ 'maxlength' => '2',
+ 'size' => '2',
+ 'value' => '',
+ );
+
+ $data['voucher_type_base_types'] = array('1' => 'Normal
Vocuher', '2' => 'Stock Voucher');
+ $data['voucher_type_numberings'] = array('1' => 'Auto',
'2' => 'Manual');
+ $data['bank_cash_ledger_restrictions'] = array(
+ '1' => 'Unrestricted',
+ '2' => 'Atleast one Bank or Cash A/C must be present on Debit
side',
+ '3' => 'Atleast one Bank or Cash A/C must be present on Credit
side',
+ '4' => 'Only Bank or Cash A/C can be present on both Debit and Credit
side',
+ '5' => 'None of Debit and Credit side can be Bank or Cash A/C',
+ );
+
+ $data['voucher_type_base_type_active'] = '1';
+ $data['voucher_type_numbering_active'] = '1';
+ $data['bank_cash_ledger_restriction_active'] = '1';
+
+ /* Repopulating form */
+ if ($_POST)
+ {
+ $data['voucher_type_label']['value'] =
$this->input->post('voucher_type_label', TRUE);
+ $data['voucher_type_name']['value'] =
$this->input->post('voucher_type_name', TRUE);
+ $data['voucher_type_description']['value'] =
$this->input->post('voucher_type_description', TRUE);
+ $data['voucher_type_prefix']['value'] =
$this->input->post('voucher_type_prefix', TRUE);
+ $data['voucher_type_suffix']['value'] =
$this->input->post('voucher_type_suffix', TRUE);
+ $data['voucher_type_zero_padding']['value'] =
$this->input->post('voucher_type_zero_padding', TRUE);
+
+ $data['voucher_type_base_type_active'] =
$this->input->post('voucher_type_base_type', TRUE);
+ $data['voucher_type_numbering_active'] =
$this->input->post('voucher_type_numbering', TRUE);
+ $data['bank_cash_ledger_restriction_active'] =
$this->input->post('bank_cash_ledger_restriction', TRUE);
+ }
+
+ /* Form validations */
+ $this->form_validation->set_rules('voucher_type_label', 'Label',
'trim|required|min_length[2]|max_length[15]|alpha');
+ $this->form_validation->set_rules('voucher_type_name', 'Name',
'trim|required|min_length[2]|max_length[100]');
+ $this->form_validation->set_rules('voucher_type_description',
'Description', 'trim');
+ $this->form_validation->set_rules('voucher_type_prefix',
'Prefix', 'trim|max_length[10]');
+ $this->form_validation->set_rules('voucher_type_suffix',
'Suffix', 'trim|max_length[10]');
+ $this->form_validation->set_rules('voucher_type_zero_padding', 'Zero
Padding', 'trim|max_length[2]|is_natural');
+
+ /* Validating form */
+ if ($this->form_validation->run() == FALSE)
+ {
+ $this->messages->add(validation_errors(), 'error');
+ $this->template->load('template', 'setting/vouchertypes/add',
$data);
+ return;
+ }
+ else
+ {
+ $data_voucher_type_label =
strtolower($this->input->post('voucher_type_label', TRUE));
+ $data_voucher_type_name =
ucfirst($this->input->post('voucher_type_name', TRUE));
+ $data_voucher_type_description =
$this->input->post('voucher_type_description', TRUE);
+ $data_voucher_type_prefix = $this->input->post('voucher_type_prefix',
TRUE);
+ $data_voucher_type_suffix = $this->input->post('voucher_type_suffix',
TRUE);
+ $data_voucher_type_zero_padding =
$this->input->post('voucher_type_zero_padding', TRUE);
+ $data_voucher_type_base_type =
$this->input->post('voucher_type_base_type', TRUE);
+ $data_voucher_type_numbering =
$this->input->post('voucher_type_numbering', TRUE);
+ $data_bank_cash_ledger_restriction =
$this->input->post('bank_cash_ledger_restriction', TRUE);
+
+ if (($data_voucher_type_base_type < 1) or ($data_voucher_type_base_type > 2))
+ $data_voucher_type_base_type = 1;
+
+ if (($data_voucher_type_numbering < 1) or ($data_voucher_type_numbering > 2))
+ $data_voucher_type_numbering = 1;
+
+ if (($data_bank_cash_ledger_restriction < 1) or ($data_bank_cash_ledger_restriction
> 5))
+ $data_bank_cash_ledger_restriction = 1;
+
+ /* Calculating Voucher Type Id */
+ $last_id = 1;
+ $this->db->select_max('id',
'lastid')->from('voucher_types');
+ $last_id_q = $this->db->get();
+ if ($row = $last_id_q->row())
+ {
+ $last_id = (int)$row->lastid;
+ $last_id++;
+ }
+
+ $this->db->trans_start();
+ $insert_data = array(
+ 'id' => $last_id,
+ 'label' => $data_voucher_type_label,
+ 'name' => $data_voucher_type_name,
+ 'description' => $data_voucher_type_description,
+ 'base_type' => $data_voucher_type_base_type,
+ 'numbering' => $data_voucher_type_numbering,
+ 'prefix' => $data_voucher_type_prefix,
+ 'suffix' => $data_voucher_type_suffix,
+ 'zero_padding' => $data_voucher_type_zero_padding,
+ 'bank_cash_ledger_restriction' => $data_bank_cash_ledger_restriction,
+ );
+ if ( ! $this->db->insert('voucher_types', $insert_data))
+ {
+ $this->db->trans_rollback();
+ $this->messages->add('Error addding Voucher Type - ' .
$data_voucher_type_name . '.', 'error');
+ $this->logger->write_message("error", "Error adding Voucher Type
named " . $data_voucher_type_name);
+ $this->template->load('template', 'setting/vouchertypes/add',
$data);
+ return;
+ } else {
+ $this->db->trans_complete();
+ $this->messages->add('Added Voucher Type - ' . $data_voucher_type_name
. '.', 'success');
+ $this->logger->write_message("success", "Added Voucher Type
named " . $data_voucher_type_name);
+ redirect('setting/vouchertypes');
+ return;
+ }
+ }
+ return;
+ }
}
/* End of file vouchertypes.php */
diff --git a/system/application/views/setting/vouchertypes/add.php
b/system/application/views/setting/vouchertypes/add.php
new file mode 100644
index 0000000..da88ba2
--- /dev/null
+++ b/system/application/views/setting/vouchertypes/add.php
@@ -0,0 +1,67 @@
+<?php
+ echo form_open('setting/vouchertypes/add');
+
+ echo "<p>";
+ echo form_label('Label', 'voucher_type_label');
+ echo "<br />";
+ echo form_input($voucher_type_label);
+ echo "<br />";
+ echo "<span class=\"form-help-text\">Note: Only alphabets are
allowed without any spaces or any special characters</span>";
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Name', 'voucher_type_name');
+ echo "<br />";
+ echo form_input($voucher_type_name);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Description', 'voucher_type_description');
+ echo "<br />";
+ echo form_textarea($voucher_type_description);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Base Type', 'voucher_type_base_type');
+ echo "<br />";
+ echo form_dropdown('voucher_type_base_type', $voucher_type_base_types,
$voucher_type_base_type_active);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Numbering', 'voucher_type_numbering');
+ echo "<br />";
+ echo form_dropdown('voucher_type_numbering', $voucher_type_numberings,
$voucher_type_numbering_active);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Restrictions', 'bank_cash_ledger_restriction');
+ echo "<br />";
+ echo form_dropdown('bank_cash_ledger_restriction',
$bank_cash_ledger_restrictions, $bank_cash_ledger_restriction_active);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Prefix', 'voucher_type_prefix');
+ echo "<br />";
+ echo form_input($voucher_type_prefix);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Suffix', 'voucher_type_suffix');
+ echo "<br />";
+ echo form_input($voucher_type_suffix);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Zero Padding', 'voucher_type_zero_padding');
+ echo "<br />";
+ echo form_input($voucher_type_zero_padding);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_submit('submit', 'Create');
+ echo " ";
+ echo anchor('setting/vouchertypes', 'Back', 'Back to Voucher
Types');
+ echo "</p>";
+
+ echo form_close();
+
diff --git a/system/application/views/setting/vouchertypes/edit.php
b/system/application/views/setting/vouchertypes/edit.php
new file mode 100644
index 0000000..9493133
--- /dev/null
+++ b/system/application/views/setting/vouchertypes/edit.php
@@ -0,0 +1,67 @@
+<?php
+ echo form_open('setting/vouchertypes/edit' . $voucher_type_id);
+
+ echo "<p>";
+ echo form_label('Label', 'voucher_type_label');
+ echo "<br />";
+ echo form_input($voucher_type_label);
+ echo "<br />";
+ echo "<span class=\"form-help-text\">Note: Only alphabets are
allowed without any spaces or any special characters</span>";
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Name', 'voucher_type_name');
+ echo "<br />";
+ echo form_input($voucher_type_name);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Description', 'voucher_type_description');
+ echo "<br />";
+ echo form_textarea($voucher_type_description);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Base Type', 'voucher_type_base_type');
+ echo "<br />";
+ echo form_dropdown('voucher_type_base_type', $voucher_type_base_types,
$voucher_type_base_type_active);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Numbering', 'voucher_type_numbering');
+ echo "<br />";
+ echo form_dropdown('voucher_type_numbering', $voucher_type_numberings,
$voucher_type_numbering_active);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Restrictions', 'bank_cash_ledger_restriction');
+ echo "<br />";
+ echo form_dropdown('bank_cash_ledger_restriction',
$bank_cash_ledger_restrictions, $bank_cash_ledger_restriction_active);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Prefix', 'voucher_type_prefix');
+ echo "<br />";
+ echo form_input($voucher_type_prefix);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Suffix', 'voucher_type_suffix');
+ echo "<br />";
+ echo form_input($voucher_type_suffix);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_label('Zero Padding', 'voucher_type_zero_padding');
+ echo "<br />";
+ echo form_input($voucher_type_zero_padding);
+ echo "</p>";
+
+ echo "<p>";
+ echo form_submit('submit', 'Update');
+ echo " ";
+ echo anchor('setting/vouchertypes', 'Back', 'Back to Voucher
Types');
+ echo "</p>";
+
+ echo form_close();
+
diff --git a/system/application/views/setting/vouchertypes/index.php
b/system/application/views/setting/vouchertypes/index.php
index 241effa..1f997e6 100644
--- a/system/application/views/setting/vouchertypes/index.php
+++ b/system/application/views/setting/vouchertypes/index.php
@@ -15,7 +15,6 @@
echo "<td>" . $row->label . "</td>";
echo "<td>" . $row->name . "</td>";
-
echo "<td>" . $row->description . "</td>";
echo "<td>" . anchor('voucher/edit/' . $row->id ,
"Edit", array('title' => 'Edit ' . $row->name . '
Voucher Type', 'class' => 'red-link')) . " ";
echo " " . anchor('voucher/delete/' . $row->id ,
img(array('src' => asset_url() . "images/icons/delete.png",
'border' => '0', 'alt' => 'Delete ' . $row->name
. ' Voucher Type', 'class' => "confirmClick", 'title'
=> "Delete Voucher Type")), array('title' => 'Delete ' .
$row->name . ' Voucher Type')) . " ";
commit fcf8113445231106f2392edf03e025182e77b422
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Feb 1 19:24:18 2011 +0530
Split setting to separate controllers and added Voucher Types
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
deleted file mode 100644
index 495684d..0000000
--- a/system/application/controllers/setting.php
+++ /dev/null
@@ -1,990 +0,0 @@
-<?php
-
-class Setting extends Controller {
-
- function Setting()
- {
- parent::Controller();
- $this->load->model('Setting_model');
-
- /* Check access */
- if ( ! check_access('change account settings'))
- {
- $this->messages->add('Permission denied.', 'error');
- redirect('');
- return;
- }
-
- return;
- }
-
- function index()
- {
- $this->template->set('page_title', 'Settings');
- $this->template->load('template', 'setting/index');
- return;
- }
-
- function account()
- {
- $this->template->set('page_title', 'Account Settings');
- $account_data = $this->Setting_model->get_current();
-
- $default_start = '01/04/';
- $default_end = '31/03/';
- if (date('n') > 3)
- {
- $default_start .= date('Y');
- $default_end .= date('Y') + 1;
- } else {
- $default_start .= date('Y') - 1;
- $default_end .= date('Y');
- }
-
- /* Form fields */
- $data['account_name'] = array(
- 'name' => 'account_name',
- 'id' => 'account_name',
- 'maxlength' => '100',
- 'size' => '40',
- 'value' => '',
- );
- $data['account_address'] = array(
- 'name' => 'account_address',
- 'id' => 'account_address',
- 'rows' => '4',
- 'cols' => '47',
- 'value' => '',
- );
- $data['account_email'] = array(
- 'name' => 'account_email',
- 'id' => 'account_email',
- 'maxlength' => '100',
- 'size' => '40',
- 'value' => '',
- );
-
- $data['fy_start'] = '';
- $data['fy_end'] = '';
-
- $data['account_currency'] = array(
- 'name' => 'account_currency',
- 'id' => 'account_currency',
- 'maxlength' => '10',
- 'size' => '10',
- 'value' => '',
- );
- $data['account_date_options'] = array(
- 'dd/mm/yyyy' => 'Day / Month / Year',
- 'mm/dd/yyyy' => 'Month / Day / Year',
- 'yyyy/mm/dd' => 'Year / Month / Day',
- );
- $data['account_date'] = 'dd/mm/yyyy';
- $data['account_timezone'] = 'UTC';
- $data['account_locked'] = FALSE;
-
- /* Current account settings */
- if ($account_data)
- {
- $data['account_name']['value'] = print_value($account_data->name);
- $data['account_address']['value'] =
print_value($account_data->address);
- $data['account_email']['value'] =
print_value($account_data->email);
- $data['account_currency']['value'] =
print_value($account_data->currency_symbol);
- $data['account_date'] = print_value($account_data->date_format);
- $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 */
- $this->form_validation->set_rules('account_name', 'Account Name',
'trim|required|min_length[2]|max_length[100]');
- $this->form_validation->set_rules('account_address', 'Account
Address', 'trim|max_length[255]');
- $this->form_validation->set_rules('account_email', 'Account
Email', 'trim|valid_email');
- $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)
- {
- $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['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 */
- if ($this->form_validation->run() == FALSE)
- {
- $this->messages->add(validation_errors(), 'error');
- $this->template->load('template', 'setting/account', $data);
- return;
- }
- else
- {
- $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_account_currency = $this->input->post('account_currency', TRUE);
- $data_account_date_form = $this->input->post('account_date', TRUE);
- /* Checking for valid format */
- if ($data_account_date_form == "dd/mm/yyyy")
- $data_account_date = "dd/mm/yyyy";
- else if ($data_account_date_form == "mm/dd/yyyy")
- $data_account_date = "mm/dd/yyyy";
- else if ($data_account_date_form == "yyyy/mm/dd")
- $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();
- $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');
- $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('Account settings updated.', 'success');
- $this->logger->write_message("success", "Updated account
settings");
- redirect('setting');
- return;
- }
- }
- return;
- }
-
- function cf()
- {
- $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');
-
- /* 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();
-
- /* Form fields */
- $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);
- $default_start_ts = $last_year_end_ts + (60 * 60 * 24); /* Adding 24 hours */
- $default_start = date("Y-m-d 00:00:00", $default_start_ts);
- $default_end = ($last_year_end_year + 1) . "-" . $last_year_end_month .
"-" . $last_year_end_day . " 00:00:00";
-
- /* Form fields */
- $data['account_label'] = array(
- 'name' => 'account_label',
- 'id' => 'account_label',
- 'maxlength' => '30',
- 'size' => '30',
- 'value' => '',
- );
- $data['account_name'] = array(
- 'name' => 'account_name',
- 'id' => 'account_name',
- 'maxlength' => '100',
- 'size' => '40',
- 'value' => '',
- );
- $data['fy_start'] = array(
- 'name' => 'fy_start',
- 'id' => 'fy_start',
- 'maxlength' => '11',
- 'size' => '11',
- 'value' => date_mysql_to_php($default_start),
- );
- $data['fy_end'] = array(
- 'name' => 'fy_end',
- 'id' => 'fy_end',
- 'maxlength' => '11',
- 'size' => '11',
- 'value' => date_mysql_to_php($default_end),
- );
-
- $data['database_name'] = array(
- 'name' => 'database_name',
- 'id' => 'database_name',
- 'maxlength' => '100',
- 'size' => '40',
- 'value' => '',
- );
-
- $data['database_username'] = array(
- 'name' => 'database_username',
- 'id' => 'database_username',
- 'maxlength' => '100',
- 'size' => '40',
- 'value' => '',
- );
-
- $data['database_password'] = array(
- 'name' => 'database_password',
- 'id' => 'database_password',
- 'maxlength' => '100',
- 'size' => '40',
- 'value' => '',
- );
-
- $data['database_host'] = array(
- 'name' => 'database_host',
- 'id' => 'database_host',
- 'maxlength' => '100',
- 'size' => '40',
- 'value' => 'localhost',
- );
-
- $data['database_port'] = array(
- 'name' => 'database_port',
- 'id' => 'database_port',
- 'maxlength' => '100',
- 'size' => '40',
- 'value' => '3306',
- );
- $data['create_database'] = FALSE;
- $data['account_name']['value'] =
$this->config->item('account_name');
-
- /* 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('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');
-
- /* Repopulating form */
- if ($_POST)
- {
- $data['account_label']['value'] =
$this->input->post('account_label', TRUE);
- $data['account_name']['value'] =
$this->input->post('account_name', 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);
- $data['database_username']['value'] =
$this->input->post('database_username', TRUE);
- $data['database_password']['value'] =
$this->input->post('database_password', TRUE);
- $data['database_host']['value'] =
$this->input->post('database_host', TRUE);
- $data['database_port']['value'] =
$this->input->post('database_port', TRUE);
- }
-
- /* Validating form */
- if ($this->form_validation->run() == FALSE)
- {
- $this->messages->add(validation_errors(), 'error');
- $this->template->load('template', 'setting/cf', $data);
- return;
- }
- else
- {
- $data_account_label = $this->input->post('account_label', TRUE);
- $data_account_label = strtolower($data_account_label);
- $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_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');
-
- $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_type = 'mysql';
- $data_database_host = $this->input->post('database_host', TRUE);
- $data_database_port = $this->input->post('database_port', TRUE);
- $data_database_name = $this->input->post('database_name', TRUE);
- $data_database_username = $this->input->post('database_username',
TRUE);
- $data_database_password = $this->input->post('database_password',
TRUE);
-
- $ini_file = $this->config->item('config_path') . "accounts/" .
$data_account_label . ".ini";
-
- /* Check if database ini file exists */
- if (get_file_info($ini_file))
- {
- $this->messages->add('Account with same label already exists.',
'error');
- $this->template->load('template', 'setting/cf', $data);
- return;
- }
-
- /* 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->template->load('template', 'setting/cf', $data);
- return;
- }
-
- if ($data_database_host == "")
- $data_database_host = "localhost";
- if ($data_database_port == "")
- $data_database_port = "3306";
-
- /* Creating account database */
- if ($this->input->post('create_database', TRUE) == "1")
- {
- $new_link = @mysql_connect($data_database_host . ':' . $data_database_port,
$data_database_username, $data_database_password);
- if ($new_link)
- {
- /* Check if database already exists */
- $db_selected = mysql_select_db($data_database_name, $new_link);
- if ($db_selected) {
- mysql_close($new_link);
- $this->messages->add('Database already exists.', 'error');
- $this->template->load('template', 'setting/cf', $data);
- return;
- }
-
- /* Creating account database */
- $db_create_q = 'CREATE DATABASE ' .
mysql_real_escape_string($data_database_name);
- if (mysql_query($db_create_q, $new_link))
- {
- $this->messages->add('Created account database.',
'success');
- } else {
- $this->messages->add('Error creating account database. ' .
mysql_error(), 'error');
- $this->template->load('template', 'setting/cf', $data);
- return;
- }
- mysql_close($new_link);
- } else {
- $this->messages->add('Error connecting to database. ' . mysql_error(),
'error');
- $this->template->load('template', 'setting/cf', $data);
- return;
- }
- }
-
- /* Setting database */
- $dsn =
"mysql://${data_database_username}:${data_database_password}@${data_database_host}:${data_database_port}/${data_database_name}";
- $newacc = $this->load->database($dsn, TRUE);
-
- if ( ! $newacc->conn_id)
- {
- $this->messages->add('Error connecting to database.',
'error');
- $this->template->load('template', 'setting/cf', $data);
- return;
- } else if ($newacc->_error_message() != "") {
- $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->template->load('template', 'setting/cf', $data);
- return;
- } else {
- /* Executing the database setup script */
- $setup_account =
read_file('system/application/controllers/admin/schema.sql');
- $setup_account_array = explode(";", $setup_account);
- foreach($setup_account_array as $row)
- {
- if (strlen($row) < 5)
- continue;
- $newacc->query($row);
- if ($newacc->_error_message() != "")
- {
- $this->messages->add('Error initializing account database.',
'error');
- $this->template->load('template', 'setting/cf', $data);
- return;
- }
- }
- $this->messages->add('Initialized account database.',
'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, 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, 3)))
- {
- $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 ***************/
-
- $cf_status = TRUE;
- /* Importing Groups */
- $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)))
- {
- $this->messages->add('Failed to add Group A/C - ' . $row->name .
'.', 'error');
- $cf_status = FALSE;
- }
- }
-
- /* 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 */
- $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 */
- if (in_array($row->id, $cf_ledgers))
- {
- /* 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 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 A/C - ' . $row->name .
'.', 'error');
- $cf_status = FALSE;
- }
- }
- }
-
- /* Importing Voucher Types */
- $this->db->from('voucher_types')->order_by('id',
'asc');
- $voucher_type_q = $this->db->get();
- foreach ($voucher_type_q->result() as $row)
- {
- if ( ! $newacc->query("INSERT INTO voucher_types (id, label, name,
description, base_type, numbering, prefix, suffix, zero_padding,
bank_cash_ledger_restriction) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
array($row->id, $row->label, $row->name, $row->description,
$row->base_type, $row->numbering, $row->prefix, $row->suffix,
$row->zero_padding, $row->bank_cash_ledger_restriction)))
- {
- $this->messages->add('Failed to add Voucher type - ' . $row->name
. '.', 'error');
- $cf_status = FALSE;
- }
- }
-
- /* Importing Tags */
- $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)))
- {
- $this->messages->add('Failed to add Tag - ' . $row->title .
'.', 'error');
- $cf_status = FALSE;
- }
- }
-
- if ($cf_status)
- $this->messages->add('Account carried forward.', 'success');
- 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_type =
\"" . $data_database_type . "\"" . "\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_type = "' .
$data_database_type . '"<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))
- {
- $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('Added account settings file to list of active
accounts.', 'success');
- }
-
- redirect('setting');
- return;
- }
- }
- return;
- }
-
- function email()
- {
- $this->template->set('page_title', 'Email Settings');
- $account_data = $this->Setting_model->get_current();
-
- /* Form fields */
- $data['email_protocol_options'] = array(
- 'mail' => 'mail',
- 'sendmail' => 'sendmail',
- 'smtp' => 'smtp'
- );
- $data['email_host'] = array(
- 'name' => 'email_host',
- 'id' => 'email_host',
- 'maxlength' => '100',
- 'size' => '40',
- 'value' => '',
- );
- $data['email_port'] = array(
- 'name' => 'email_port',
- 'id' => 'email_port',
- 'maxlength' => '5',
- 'size' => '5',
- 'value' => '',
- );
- $data['email_username'] = array(
- 'name' => 'email_username',
- 'id' => 'email_username',
- 'maxlength' => '100',
- 'size' => '40',
- 'value' => '',
- );
- $data['email_password'] = array(
- 'name' => 'email_password',
- 'id' => 'email_password',
- 'maxlength' => '100',
- 'size' => '40',
- 'value' => '',
- );
-
- if ($account_data)
- {
- $data['email_protocol'] = ($account_data->email_protocol) ?
print_value($account_data->email_protocol) : 'smtp';
- $data['email_host']['value'] = ($account_data->email_host) ?
print_value($account_data->email_host) : '';
- $data['email_port']['value'] = ($account_data->email_port) ?
print_value($account_data->email_port) : '';
- $data['email_username']['value'] = ($account_data->email_username)
? print_value($account_data->email_username) : '';
- }
-
- /* Form validations */
- $this->form_validation->set_rules('email_protocol', 'Email
Protocol', 'trim|required|min_length[2]|max_length[10]');
- $this->form_validation->set_rules('email_host', 'Mail Server
Hostname', 'trim|max_length[255]');
- $this->form_validation->set_rules('email_port', 'Mail Server
Port', 'trim|is_natural');
- $this->form_validation->set_rules('email_username', 'Email
Username', 'trim|max_length[255]');
- $this->form_validation->set_rules('email_password', 'Email
Password', 'trim|max_length[255]');
-
- /* Repopulating form */
- if ($_POST)
- {
- $data['email_protocol'] = $this->input->post('email_protocol',
TRUE);
- $data['email_host']['value'] =
$this->input->post('email_host', TRUE);
- $data['email_port']['value'] =
$this->input->post('email_port', TRUE);
- $data['email_username']['value'] =
$this->input->post('email_username', TRUE);
- $data['email_password']['value'] =
$this->input->post('email_password', TRUE);
- }
-
- /* Validating form */
- if ($this->form_validation->run() == FALSE)
- {
- $this->messages->add(validation_errors(), 'error');
- $this->template->load('template', 'setting/email', $data);
- return;
- }
- else
- {
- $data_email_protocol = $this->input->post('email_protocol', TRUE);
- $data_email_host = $this->input->post('email_host', TRUE);
- $data_email_port = $this->input->post('email_port', TRUE);
- $data_email_username = $this->input->post('email_username', TRUE);
- $data_email_password = $this->input->post('email_password', TRUE);
-
- /* if password is blank then use the current password */
- if ($data_email_password == "")
- $data_email_password = $account_data->email_password;
-
- /* Update settings */
- $this->db->trans_start();
- $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');
- $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.', 'success');
- $this->logger->write_message("success", "Updated email
settings");
- redirect('setting');
- return;
- }
- }
- return;
- }
-
- function printer()
- {
- $this->template->set('page_title', 'Printer Settings');
- $account_data = $this->Setting_model->get_current();
-
- /* Form fields */
- $data['paper_height'] = array(
- 'name' => 'paper_height',
- 'id' => 'paper_height',
- 'maxlength' => '10',
- 'size' => '10',
- 'value' => '',
- );
- $data['paper_width'] = array(
- 'name' => 'paper_width',
- 'id' => 'paper_width',
- 'maxlength' => '10',
- 'size' => '10',
- 'value' => '',
- );
- $data['margin_top'] = array(
- 'name' => 'margin_top',
- 'id' => 'margin_top',
- 'maxlength' => '10',
- 'size' => '10',
- 'value' => '',
- );
- $data['margin_bottom'] = array(
- 'name' => 'margin_bottom',
- 'id' => 'margin_bottom',
- 'maxlength' => '10',
- 'size' => '10',
- 'value' => '',
- );
- $data['margin_left'] = array(
- 'name' => 'margin_left',
- 'id' => 'margin_left',
- 'maxlength' => '10',
- 'size' => '10',
- 'value' => '',
- );
- $data['margin_right'] = array(
- 'name' => 'margin_right',
- 'id' => 'margin_right',
- 'maxlength' => '10',
- 'size' => '10',
- 'value' => '',
- );
- $data['orientation_potrait'] = array(
- 'name' => 'orientation',
- 'id' => 'orientation_potrait',
- 'value' => 'P',
- 'checked' => TRUE,
- );
- $data['orientation_landscape'] = array(
- 'name' => 'orientation',
- 'id' => 'orientation_landscape',
- 'value' => 'L',
- 'checked' => FALSE,
- );
- $data['output_format_html'] = array(
- 'name' => 'output_format',
- 'id' => 'output_format_html',
- 'value' => 'H',
- 'checked' => TRUE,
- );
- $data['output_format_text'] = array(
- 'name' => 'output_format',
- 'id' => 'output_format_text',
- 'value' => 'T',
- 'checked' => FALSE,
- );
-
- if ($account_data)
- {
- $data['paper_height']['value'] =
($account_data->print_paper_height) ? print_value($account_data->print_paper_height)
: '';
- $data['paper_width']['value'] = ($account_data->print_paper_width)
? print_value($account_data->print_paper_width) : '';
- $data['margin_top']['value'] = ($account_data->print_margin_top) ?
print_value($account_data->print_margin_top) : '';
- $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)
: '';
- if ($account_data->print_orientation)
- {
- if ($account_data->print_orientation == "P")
- {
- $data['orientation_potrait']['checked'] = TRUE;
- $data['orientation_landscape']['checked'] = FALSE;
- } else {
- $data['orientation_potrait']['checked'] = FALSE;
- $data['orientation_landscape']['checked'] = TRUE;
- }
- }
- if ($account_data->print_page_format)
- {
- if ($account_data->print_page_format == "H")
- {
- $data['output_format_html']['checked'] = TRUE;
- $data['output_format_text']['checked'] = FALSE;
- } else {
- $data['output_format_html']['checked'] = FALSE;
- $data['output_format_text']['checked'] = TRUE;
- }
- }
- }
-
- /* Form validations */
- $this->form_validation->set_rules('paper_height', 'Paper Height',
'trim|required|numeric');
- $this->form_validation->set_rules('paper_width', 'Paper Width',
'trim|required|numeric');
- $this->form_validation->set_rules('margin_top', 'Top Margin',
'trim|required|numeric');
- $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');
-
- /* Repopulating form */
- if ($_POST)
- {
- $data['paper_height']['value'] =
$this->input->post('paper_height', TRUE);
- $data['paper_width']['value'] =
$this->input->post('paper_width', TRUE);
- $data['margin_top']['value'] =
$this->input->post('margin_top', TRUE);
- $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['orientation'] = $this->input->post('orientation', TRUE);
- if ($data['orientation'] == "P")
- {
- $data['orientation_potrait']['checked'] = TRUE;
- $data['orientation_landscape']['checked'] = FALSE;
- } else {
- $data['orientation_potrait']['checked'] = FALSE;
- $data['orientation_landscape']['checked'] = TRUE;
- }
- $data['output_format'] = $this->input->post('output_format',
TRUE);
- if ($data['output_format'] == "H")
- {
- $data['output_format_html']['checked'] = TRUE;
- $data['output_format_text']['checked'] = FALSE;
- } else {
- $data['output_format_html']['checked'] = FALSE;
- $data['output_format_text']['checked'] = TRUE;
- }
- }
-
- /* Validating form */
- if ($this->form_validation->run() == FALSE)
- {
- $this->messages->add(validation_errors(), 'error');
- $this->template->load('template', 'setting/printer', $data);
- return;
- }
- else
- {
- $data_paper_height = $this->input->post('paper_height', TRUE);
- $data_paper_width = $this->input->post('paper_width', TRUE);
- $data_margin_top = $this->input->post('margin_top', TRUE);
- $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);
-
- if ($this->input->post('orientation', TRUE) == "P")
- {
- $data_orientation = "P";
- } else {
- $data_orientation = "L";
- }
- if ($this->input->post('output_format', TRUE) == "H")
- {
- $data_output_format = "H";
- } else {
- $data_output_format = "T";
- }
-
- /* Update settings */
- $this->db->trans_start();
- $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');
- $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.', 'success');
- $this->logger->write_message("success", "Updated printer
settings");
- redirect('setting');
- return;
- }
- }
- return;
- }
-
- function backup()
- {
- $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 */
- $backup_data =& $this->dbutil->backup();
-
- /* 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.' . ' Check
if "' . $this->config->item('backup_path') . '" folder is
writable.', 'error');
- redirect('setting');
- return;
- }
-
- /* Send the file to your desktop */
- force_download($backup_filename, $backup_data);
- $this->logger->write_message("success", "Downloaded account
backup");
- redirect('setting');
- return;
- }
-
- function voucher()
- {
- $this->template->set('page_title', 'Voucher Settings');
- $account_data = $this->Setting_model->get_current();
-
- $data['receipt_prefix'] = array(
- 'name' => 'receipt_prefix',
- 'id' => 'receipt_prefix',
- 'maxlength' => '10',
- 'size' => '10',
- 'value' => '',
- );
- $data['payment_prefix'] = array(
- 'name' => 'payment_prefix',
- 'id' => 'payment_prefix',
- 'maxlength' => '10',
- 'size' => '10',
- 'value' => '',
- );
- $data['contra_prefix'] = array(
- 'name' => 'contra_prefix',
- 'id' => 'contra_prefix',
- 'maxlength' => '10',
- 'size' => '10',
- 'value' => '',
- );
- $data['journal_prefix'] = array(
- 'name' => 'journal_prefix',
- 'id' => 'journal_prefix',
- 'maxlength' => '10',
- 'size' => '10',
- 'value' => '',
- );
-
- if ($account_data)
- {
- $data['receipt_prefix']['value'] =
$account_data->receipt_voucher_prefix;
- $data['payment_prefix']['value'] =
$account_data->payment_voucher_prefix;
- $data['contra_prefix']['value'] =
$account_data->contra_voucher_prefix;
- $data['journal_prefix']['value'] =
$account_data->journal_voucher_prefix;
- }
-
- /* Form validations */
- $this->form_validation->set_rules('receipt_prefix', 'Prefix Receipt
Vouchers', 'trim');
- $this->form_validation->set_rules('payment_prefix', 'Prefix Payment
Vouchers', 'trim');
- $this->form_validation->set_rules('contra_prefix', 'Prefix Contra
Vouchers', 'trim');
- $this->form_validation->set_rules('journal_prefix', 'Prefix Journal
Vouchers', 'trim');
-
- /* Repopulating form */
- if ($_POST)
- {
- $data['receipt_prefix']['value'] =
$this->input->post('receipt_prefix', TRUE);
- $data['payment_prefix']['value'] =
$this->input->post('payment_prefix', TRUE);
- $data['contra_prefix']['value'] =
$this->input->post('contra_prefix', TRUE);
- $data['journal_prefix']['value'] =
$this->input->post('journal_prefix', TRUE);
- }
-
- /* Validating form */
- if ($this->form_validation->run() == FALSE)
- {
- $this->messages->add(validation_errors(), 'error');
- $this->template->load('template', 'setting/voucher', $data);
- return;
- } else {
- $data_receipt_prefix = $this->input->post('receipt_prefix', TRUE);
- $data_payment_prefix = $this->input->post('payment_prefix', TRUE);
- $data_contra_prefix = $this->input->post('contra_prefix', TRUE);
- $data_journal_prefix = $this->input->post('journal_prefix', TRUE);
-
- /* Update settings */
- $this->db->trans_start();
- $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');
- $this->logger->write_message("error", "Error updating voucher
settings");
- $this->template->load('template', 'setting/voucher');
- return;
- } else {
- $this->db->trans_complete();
- $this->messages->add('Voucher settings updated.', 'success');
- $this->logger->write_message("success", "Updated voucher
settings");
- redirect('setting');
- return;
- }
- }
- return;
- }
-}
-
-/* End of file setting.php */
-/* Location: ./system/application/controllers/setting.php */
diff --git a/system/application/controllers/setting/account.php
b/system/application/controllers/setting/account.php
new file mode 100644
index 0000000..c80880b
--- /dev/null
+++ b/system/application/controllers/setting/account.php
@@ -0,0 +1,175 @@
+<?php
+
+class Account extends Controller {
+
+ function Account()
+ {
+ parent::Controller();
+ $this->load->model('Setting_model');
+
+ /* Check access */
+ if ( ! check_access('change account settings'))
+ {
+ $this->messages->add('Permission denied.', 'error');
+ redirect('');
+ return;
+ }
+
+ return;
+ }
+
+ function index()
+ {
+ $this->template->set('page_title', 'Account Settings');
+ $account_data = $this->Setting_model->get_current();
+
+ $default_start = '01/04/';
+ $default_end = '31/03/';
+ if (date('n') > 3)
+ {
+ $default_start .= date('Y');
+ $default_end .= date('Y') + 1;
+ } else {
+ $default_start .= date('Y') - 1;
+ $default_end .= date('Y');
+ }
+
+ /* Form fields */
+ $data['account_name'] = array(
+ 'name' => 'account_name',
+ 'id' => 'account_name',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '',
+ );
+ $data['account_address'] = array(
+ 'name' => 'account_address',
+ 'id' => 'account_address',
+ 'rows' => '4',
+ 'cols' => '47',
+ 'value' => '',
+ );
+ $data['account_email'] = array(
+ 'name' => 'account_email',
+ 'id' => 'account_email',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '',
+ );
+
+ $data['fy_start'] = '';
+ $data['fy_end'] = '';
+
+ $data['account_currency'] = array(
+ 'name' => 'account_currency',
+ 'id' => 'account_currency',
+ 'maxlength' => '10',
+ 'size' => '10',
+ 'value' => '',
+ );
+ $data['account_date_options'] = array(
+ 'dd/mm/yyyy' => 'Day / Month / Year',
+ 'mm/dd/yyyy' => 'Month / Day / Year',
+ 'yyyy/mm/dd' => 'Year / Month / Day',
+ );
+ $data['account_date'] = 'dd/mm/yyyy';
+ $data['account_timezone'] = 'UTC';
+ $data['account_locked'] = FALSE;
+
+ /* Current account settings */
+ if ($account_data)
+ {
+ $data['account_name']['value'] = print_value($account_data->name);
+ $data['account_address']['value'] =
print_value($account_data->address);
+ $data['account_email']['value'] =
print_value($account_data->email);
+ $data['account_currency']['value'] =
print_value($account_data->currency_symbol);
+ $data['account_date'] = print_value($account_data->date_format);
+ $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 */
+ $this->form_validation->set_rules('account_name', 'Account Name',
'trim|required|min_length[2]|max_length[100]');
+ $this->form_validation->set_rules('account_address', 'Account
Address', 'trim|max_length[255]');
+ $this->form_validation->set_rules('account_email', 'Account
Email', 'trim|valid_email');
+ $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)
+ {
+ $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['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 */
+ if ($this->form_validation->run() == FALSE)
+ {
+ $this->messages->add(validation_errors(), 'error');
+ $this->template->load('template', 'setting/account', $data);
+ return;
+ }
+ else
+ {
+ $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_account_currency = $this->input->post('account_currency', TRUE);
+ $data_account_date_form = $this->input->post('account_date', TRUE);
+ /* Checking for valid format */
+ if ($data_account_date_form == "dd/mm/yyyy")
+ $data_account_date = "dd/mm/yyyy";
+ else if ($data_account_date_form == "mm/dd/yyyy")
+ $data_account_date = "mm/dd/yyyy";
+ else if ($data_account_date_form == "yyyy/mm/dd")
+ $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();
+ $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');
+ $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('Account settings updated.', 'success');
+ $this->logger->write_message("success", "Updated account
settings");
+ redirect('setting');
+ return;
+ }
+ }
+ return;
+ }
+}
+
+/* End of file account.php */
+/* Location: ./system/application/controllers/setting/account.php */
diff --git a/system/application/controllers/setting/backup.php
b/system/application/controllers/setting/backup.php
new file mode 100644
index 0000000..95291d2
--- /dev/null
+++ b/system/application/controllers/setting/backup.php
@@ -0,0 +1,56 @@
+<?php
+
+class Backup extends Controller {
+
+ function Backup()
+ {
+ parent::Controller();
+ $this->load->model('Setting_model');
+
+ /* Check access */
+ if ( ! check_access('change account settings'))
+ {
+ $this->messages->add('Permission denied.', 'error');
+ redirect('');
+ return;
+ }
+
+ return;
+ }
+
+ function index()
+ {
+ $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 */
+ $backup_data =& $this->dbutil->backup();
+
+ /* 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.' . ' Check
if "' . $this->config->item('backup_path') . '" folder is
writable.', 'error');
+ redirect('setting');
+ return;
+ }
+
+ /* Send the file to your desktop */
+ force_download($backup_filename, $backup_data);
+ $this->logger->write_message("success", "Downloaded account
backup");
+ redirect('setting');
+ return;
+ }
+}
+
+/* End of file backup.php */
+/* Location: ./system/application/controllers/setting/backup.php */
diff --git a/system/application/controllers/setting/cf.php
b/system/application/controllers/setting/cf.php
new file mode 100644
index 0000000..ce9c1f2
--- /dev/null
+++ b/system/application/controllers/setting/cf.php
@@ -0,0 +1,390 @@
+<?php
+
+class Cf extends Controller {
+
+ function Cf()
+ {
+ parent::Controller();
+ $this->load->model('Setting_model');
+
+ /* Check access */
+ if ( ! check_access('change account settings'))
+ {
+ $this->messages->add('Permission denied.', 'error');
+ redirect('');
+ return;
+ }
+
+ return;
+ }
+
+ function index()
+ {
+ $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');
+
+ /* 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();
+
+ /* Form fields */
+ $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);
+ $default_start_ts = $last_year_end_ts + (60 * 60 * 24); /* Adding 24 hours */
+ $default_start = date("Y-m-d 00:00:00", $default_start_ts);
+ $default_end = ($last_year_end_year + 1) . "-" . $last_year_end_month .
"-" . $last_year_end_day . " 00:00:00";
+
+ /* Form fields */
+ $data['account_label'] = array(
+ 'name' => 'account_label',
+ 'id' => 'account_label',
+ 'maxlength' => '30',
+ 'size' => '30',
+ 'value' => '',
+ );
+ $data['account_name'] = array(
+ 'name' => 'account_name',
+ 'id' => 'account_name',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '',
+ );
+ $data['fy_start'] = array(
+ 'name' => 'fy_start',
+ 'id' => 'fy_start',
+ 'maxlength' => '11',
+ 'size' => '11',
+ 'value' => date_mysql_to_php($default_start),
+ );
+ $data['fy_end'] = array(
+ 'name' => 'fy_end',
+ 'id' => 'fy_end',
+ 'maxlength' => '11',
+ 'size' => '11',
+ 'value' => date_mysql_to_php($default_end),
+ );
+
+ $data['database_name'] = array(
+ 'name' => 'database_name',
+ 'id' => 'database_name',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '',
+ );
+
+ $data['database_username'] = array(
+ 'name' => 'database_username',
+ 'id' => 'database_username',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '',
+ );
+
+ $data['database_password'] = array(
+ 'name' => 'database_password',
+ 'id' => 'database_password',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '',
+ );
+
+ $data['database_host'] = array(
+ 'name' => 'database_host',
+ 'id' => 'database_host',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => 'localhost',
+ );
+
+ $data['database_port'] = array(
+ 'name' => 'database_port',
+ 'id' => 'database_port',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '3306',
+ );
+ $data['create_database'] = FALSE;
+ $data['account_name']['value'] =
$this->config->item('account_name');
+
+ /* 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('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');
+
+ /* Repopulating form */
+ if ($_POST)
+ {
+ $data['account_label']['value'] =
$this->input->post('account_label', TRUE);
+ $data['account_name']['value'] =
$this->input->post('account_name', 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);
+ $data['database_username']['value'] =
$this->input->post('database_username', TRUE);
+ $data['database_password']['value'] =
$this->input->post('database_password', TRUE);
+ $data['database_host']['value'] =
$this->input->post('database_host', TRUE);
+ $data['database_port']['value'] =
$this->input->post('database_port', TRUE);
+ }
+
+ /* Validating form */
+ if ($this->form_validation->run() == FALSE)
+ {
+ $this->messages->add(validation_errors(), 'error');
+ $this->template->load('template', 'setting/cf', $data);
+ return;
+ }
+ else
+ {
+ $data_account_label = $this->input->post('account_label', TRUE);
+ $data_account_label = strtolower($data_account_label);
+ $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_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');
+
+ $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_type = 'mysql';
+ $data_database_host = $this->input->post('database_host', TRUE);
+ $data_database_port = $this->input->post('database_port', TRUE);
+ $data_database_name = $this->input->post('database_name', TRUE);
+ $data_database_username = $this->input->post('database_username',
TRUE);
+ $data_database_password = $this->input->post('database_password',
TRUE);
+
+ $ini_file = $this->config->item('config_path') . "accounts/" .
$data_account_label . ".ini";
+
+ /* Check if database ini file exists */
+ if (get_file_info($ini_file))
+ {
+ $this->messages->add('Account with same label already exists.',
'error');
+ $this->template->load('template', 'setting/cf', $data);
+ return;
+ }
+
+ /* 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->template->load('template', 'setting/cf', $data);
+ return;
+ }
+
+ if ($data_database_host == "")
+ $data_database_host = "localhost";
+ if ($data_database_port == "")
+ $data_database_port = "3306";
+
+ /* Creating account database */
+ if ($this->input->post('create_database', TRUE) == "1")
+ {
+ $new_link = @mysql_connect($data_database_host . ':' . $data_database_port,
$data_database_username, $data_database_password);
+ if ($new_link)
+ {
+ /* Check if database already exists */
+ $db_selected = mysql_select_db($data_database_name, $new_link);
+ if ($db_selected) {
+ mysql_close($new_link);
+ $this->messages->add('Database already exists.', 'error');
+ $this->template->load('template', 'setting/cf', $data);
+ return;
+ }
+
+ /* Creating account database */
+ $db_create_q = 'CREATE DATABASE ' .
mysql_real_escape_string($data_database_name);
+ if (mysql_query($db_create_q, $new_link))
+ {
+ $this->messages->add('Created account database.',
'success');
+ } else {
+ $this->messages->add('Error creating account database. ' .
mysql_error(), 'error');
+ $this->template->load('template', 'setting/cf', $data);
+ return;
+ }
+ mysql_close($new_link);
+ } else {
+ $this->messages->add('Error connecting to database. ' . mysql_error(),
'error');
+ $this->template->load('template', 'setting/cf', $data);
+ return;
+ }
+ }
+
+ /* Setting database */
+ $dsn =
"mysql://${data_database_username}:${data_database_password}@${data_database_host}:${data_database_port}/${data_database_name}";
+ $newacc = $this->load->database($dsn, TRUE);
+
+ if ( ! $newacc->conn_id)
+ {
+ $this->messages->add('Error connecting to database.',
'error');
+ $this->template->load('template', 'setting/cf', $data);
+ return;
+ } else if ($newacc->_error_message() != "") {
+ $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->template->load('template', 'setting/cf', $data);
+ return;
+ } else {
+ /* Executing the database setup script */
+ $setup_account =
read_file('system/application/controllers/admin/schema.sql');
+ $setup_account_array = explode(";", $setup_account);
+ foreach($setup_account_array as $row)
+ {
+ if (strlen($row) < 5)
+ continue;
+ $newacc->query($row);
+ if ($newacc->_error_message() != "")
+ {
+ $this->messages->add('Error initializing account database.',
'error');
+ $this->template->load('template', 'setting/cf', $data);
+ return;
+ }
+ }
+ $this->messages->add('Initialized account database.',
'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, 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, 3)))
+ {
+ $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 ***************/
+
+ $cf_status = TRUE;
+ /* Importing Groups */
+ $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)))
+ {
+ $this->messages->add('Failed to add Group A/C - ' . $row->name .
'.', 'error');
+ $cf_status = FALSE;
+ }
+ }
+
+ /* 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 */
+ $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 */
+ if (in_array($row->id, $cf_ledgers))
+ {
+ /* 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 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 A/C - ' . $row->name .
'.', 'error');
+ $cf_status = FALSE;
+ }
+ }
+ }
+
+ /* Importing Voucher Types */
+ $this->db->from('voucher_types')->order_by('id',
'asc');
+ $voucher_type_q = $this->db->get();
+ foreach ($voucher_type_q->result() as $row)
+ {
+ if ( ! $newacc->query("INSERT INTO voucher_types (id, label, name,
description, base_type, numbering, prefix, suffix, zero_padding,
bank_cash_ledger_restriction) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
array($row->id, $row->label, $row->name, $row->description,
$row->base_type, $row->numbering, $row->prefix, $row->suffix,
$row->zero_padding, $row->bank_cash_ledger_restriction)))
+ {
+ $this->messages->add('Failed to add Voucher type - ' . $row->name
. '.', 'error');
+ $cf_status = FALSE;
+ }
+ }
+
+ /* Importing Tags */
+ $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)))
+ {
+ $this->messages->add('Failed to add Tag - ' . $row->title .
'.', 'error');
+ $cf_status = FALSE;
+ }
+ }
+
+ if ($cf_status)
+ $this->messages->add('Account carried forward.', 'success');
+ 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_type =
\"" . $data_database_type . "\"" . "\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_type = "' .
$data_database_type . '"<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))
+ {
+ $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('Added account settings file to list of active
accounts.', 'success');
+ }
+
+ redirect('setting');
+ return;
+ }
+ }
+ return;
+ }
+}
+
+/* End of file cf.php */
+/* Location: ./system/application/controllers/setting/cf.php */
diff --git a/system/application/controllers/setting/email.php
b/system/application/controllers/setting/email.php
new file mode 100644
index 0000000..3f879ff
--- /dev/null
+++ b/system/application/controllers/setting/email.php
@@ -0,0 +1,134 @@
+<?php
+
+class Email extends Controller {
+
+ function Email()
+ {
+ parent::Controller();
+ $this->load->model('Setting_model');
+
+ /* Check access */
+ if ( ! check_access('change account settings'))
+ {
+ $this->messages->add('Permission denied.', 'error');
+ redirect('');
+ return;
+ }
+
+ return;
+ }
+
+ function index()
+ {
+ $this->template->set('page_title', 'Email Settings');
+ $account_data = $this->Setting_model->get_current();
+
+ /* Form fields */
+ $data['email_protocol_options'] = array(
+ 'mail' => 'mail',
+ 'sendmail' => 'sendmail',
+ 'smtp' => 'smtp'
+ );
+ $data['email_host'] = array(
+ 'name' => 'email_host',
+ 'id' => 'email_host',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '',
+ );
+ $data['email_port'] = array(
+ 'name' => 'email_port',
+ 'id' => 'email_port',
+ 'maxlength' => '5',
+ 'size' => '5',
+ 'value' => '',
+ );
+ $data['email_username'] = array(
+ 'name' => 'email_username',
+ 'id' => 'email_username',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '',
+ );
+ $data['email_password'] = array(
+ 'name' => 'email_password',
+ 'id' => 'email_password',
+ 'maxlength' => '100',
+ 'size' => '40',
+ 'value' => '',
+ );
+
+ if ($account_data)
+ {
+ $data['email_protocol'] = ($account_data->email_protocol) ?
print_value($account_data->email_protocol) : 'smtp';
+ $data['email_host']['value'] = ($account_data->email_host) ?
print_value($account_data->email_host) : '';
+ $data['email_port']['value'] = ($account_data->email_port) ?
print_value($account_data->email_port) : '';
+ $data['email_username']['value'] = ($account_data->email_username)
? print_value($account_data->email_username) : '';
+ }
+
+ /* Form validations */
+ $this->form_validation->set_rules('email_protocol', 'Email
Protocol', 'trim|required|min_length[2]|max_length[10]');
+ $this->form_validation->set_rules('email_host', 'Mail Server
Hostname', 'trim|max_length[255]');
+ $this->form_validation->set_rules('email_port', 'Mail Server
Port', 'trim|is_natural');
+ $this->form_validation->set_rules('email_username', 'Email
Username', 'trim|max_length[255]');
+ $this->form_validation->set_rules('email_password', 'Email
Password', 'trim|max_length[255]');
+
+ /* Repopulating form */
+ if ($_POST)
+ {
+ $data['email_protocol'] = $this->input->post('email_protocol',
TRUE);
+ $data['email_host']['value'] =
$this->input->post('email_host', TRUE);
+ $data['email_port']['value'] =
$this->input->post('email_port', TRUE);
+ $data['email_username']['value'] =
$this->input->post('email_username', TRUE);
+ $data['email_password']['value'] =
$this->input->post('email_password', TRUE);
+ }
+
+ /* Validating form */
+ if ($this->form_validation->run() == FALSE)
+ {
+ $this->messages->add(validation_errors(), 'error');
+ $this->template->load('template', 'setting/email', $data);
+ return;
+ }
+ else
+ {
+ $data_email_protocol = $this->input->post('email_protocol', TRUE);
+ $data_email_host = $this->input->post('email_host', TRUE);
+ $data_email_port = $this->input->post('email_port', TRUE);
+ $data_email_username = $this->input->post('email_username', TRUE);
+ $data_email_password = $this->input->post('email_password', TRUE);
+
+ /* if password is blank then use the current password */
+ if ($data_email_password == "")
+ $data_email_password = $account_data->email_password;
+
+ /* Update settings */
+ $this->db->trans_start();
+ $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');
+ $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.', 'success');
+ $this->logger->write_message("success", "Updated email
settings");
+ redirect('setting');
+ return;
+ }
+ }
+ return;
+ }
+}
+
+/* End of file email.php */
+/* Location: ./system/application/controllers/setting/email.php */
diff --git a/system/application/controllers/setting/printer.php
b/system/application/controllers/setting/printer.php
new file mode 100644
index 0000000..117e270
--- /dev/null
+++ b/system/application/controllers/setting/printer.php
@@ -0,0 +1,225 @@
+<?php
+
+class Printer extends Controller {
+
+ function Printer()
+ {
+ parent::Controller();
+ $this->load->model('Setting_model');
+
+ /* Check access */
+ if ( ! check_access('change account settings'))
+ {
+ $this->messages->add('Permission denied.', 'error');
+ redirect('');
+ return;
+ }
+
+ return;
+ }
+
+ function index()
+ {
+ $this->template->set('page_title', 'Printer Settings');
+ $account_data = $this->Setting_model->get_current();
+
+ /* Form fields */
+ $data['paper_height'] = array(
+ 'name' => 'paper_height',
+ 'id' => 'paper_height',
+ 'maxlength' => '10',
+ 'size' => '10',
+ 'value' => '',
+ );
+ $data['paper_width'] = array(
+ 'name' => 'paper_width',
+ 'id' => 'paper_width',
+ 'maxlength' => '10',
+ 'size' => '10',
+ 'value' => '',
+ );
+ $data['margin_top'] = array(
+ 'name' => 'margin_top',
+ 'id' => 'margin_top',
+ 'maxlength' => '10',
+ 'size' => '10',
+ 'value' => '',
+ );
+ $data['margin_bottom'] = array(
+ 'name' => 'margin_bottom',
+ 'id' => 'margin_bottom',
+ 'maxlength' => '10',
+ 'size' => '10',
+ 'value' => '',
+ );
+ $data['margin_left'] = array(
+ 'name' => 'margin_left',
+ 'id' => 'margin_left',
+ 'maxlength' => '10',
+ 'size' => '10',
+ 'value' => '',
+ );
+ $data['margin_right'] = array(
+ 'name' => 'margin_right',
+ 'id' => 'margin_right',
+ 'maxlength' => '10',
+ 'size' => '10',
+ 'value' => '',
+ );
+ $data['orientation_potrait'] = array(
+ 'name' => 'orientation',
+ 'id' => 'orientation_potrait',
+ 'value' => 'P',
+ 'checked' => TRUE,
+ );
+ $data['orientation_landscape'] = array(
+ 'name' => 'orientation',
+ 'id' => 'orientation_landscape',
+ 'value' => 'L',
+ 'checked' => FALSE,
+ );
+ $data['output_format_html'] = array(
+ 'name' => 'output_format',
+ 'id' => 'output_format_html',
+ 'value' => 'H',
+ 'checked' => TRUE,
+ );
+ $data['output_format_text'] = array(
+ 'name' => 'output_format',
+ 'id' => 'output_format_text',
+ 'value' => 'T',
+ 'checked' => FALSE,
+ );
+
+ if ($account_data)
+ {
+ $data['paper_height']['value'] =
($account_data->print_paper_height) ? print_value($account_data->print_paper_height)
: '';
+ $data['paper_width']['value'] = ($account_data->print_paper_width)
? print_value($account_data->print_paper_width) : '';
+ $data['margin_top']['value'] = ($account_data->print_margin_top) ?
print_value($account_data->print_margin_top) : '';
+ $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)
: '';
+ if ($account_data->print_orientation)
+ {
+ if ($account_data->print_orientation == "P")
+ {
+ $data['orientation_potrait']['checked'] = TRUE;
+ $data['orientation_landscape']['checked'] = FALSE;
+ } else {
+ $data['orientation_potrait']['checked'] = FALSE;
+ $data['orientation_landscape']['checked'] = TRUE;
+ }
+ }
+ if ($account_data->print_page_format)
+ {
+ if ($account_data->print_page_format == "H")
+ {
+ $data['output_format_html']['checked'] = TRUE;
+ $data['output_format_text']['checked'] = FALSE;
+ } else {
+ $data['output_format_html']['checked'] = FALSE;
+ $data['output_format_text']['checked'] = TRUE;
+ }
+ }
+ }
+
+ /* Form validations */
+ $this->form_validation->set_rules('paper_height', 'Paper Height',
'trim|required|numeric');
+ $this->form_validation->set_rules('paper_width', 'Paper Width',
'trim|required|numeric');
+ $this->form_validation->set_rules('margin_top', 'Top Margin',
'trim|required|numeric');
+ $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');
+
+ /* Repopulating form */
+ if ($_POST)
+ {
+ $data['paper_height']['value'] =
$this->input->post('paper_height', TRUE);
+ $data['paper_width']['value'] =
$this->input->post('paper_width', TRUE);
+ $data['margin_top']['value'] =
$this->input->post('margin_top', TRUE);
+ $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['orientation'] = $this->input->post('orientation', TRUE);
+ if ($data['orientation'] == "P")
+ {
+ $data['orientation_potrait']['checked'] = TRUE;
+ $data['orientation_landscape']['checked'] = FALSE;
+ } else {
+ $data['orientation_potrait']['checked'] = FALSE;
+ $data['orientation_landscape']['checked'] = TRUE;
+ }
+ $data['output_format'] = $this->input->post('output_format',
TRUE);
+ if ($data['output_format'] == "H")
+ {
+ $data['output_format_html']['checked'] = TRUE;
+ $data['output_format_text']['checked'] = FALSE;
+ } else {
+ $data['output_format_html']['checked'] = FALSE;
+ $data['output_format_text']['checked'] = TRUE;
+ }
+ }
+
+ /* Validating form */
+ if ($this->form_validation->run() == FALSE)
+ {
+ $this->messages->add(validation_errors(), 'error');
+ $this->template->load('template', 'setting/printer', $data);
+ return;
+ }
+ else
+ {
+ $data_paper_height = $this->input->post('paper_height', TRUE);
+ $data_paper_width = $this->input->post('paper_width', TRUE);
+ $data_margin_top = $this->input->post('margin_top', TRUE);
+ $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);
+
+ if ($this->input->post('orientation', TRUE) == "P")
+ {
+ $data_orientation = "P";
+ } else {
+ $data_orientation = "L";
+ }
+ if ($this->input->post('output_format', TRUE) == "H")
+ {
+ $data_output_format = "H";
+ } else {
+ $data_output_format = "T";
+ }
+
+ /* Update settings */
+ $this->db->trans_start();
+ $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');
+ $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.', 'success');
+ $this->logger->write_message("success", "Updated printer
settings");
+ redirect('setting');
+ return;
+ }
+ }
+ return;
+ }
+}
+
+/* End of file printer.php */
+/* Location: ./system/application/controllers/setting/printer.php */
diff --git a/system/application/controllers/setting/vouchertypes.php
b/system/application/controllers/setting/vouchertypes.php
new file mode 100644
index 0000000..263918a
--- /dev/null
+++ b/system/application/controllers/setting/vouchertypes.php
@@ -0,0 +1,35 @@
+<?php
+
+class VoucherTypes extends Controller {
+
+ function VoucherTypes()
+ {
+ parent::Controller();
+ $this->load->model('Setting_model');
+
+ /* Check access */
+ if ( ! check_access('change account settings'))
+ {
+ $this->messages->add('Permission denied.', 'error');
+ redirect('');
+ return;
+ }
+
+ return;
+ }
+
+ function index()
+ {
+ $this->template->set('page_title', 'Voucher Types');
+ $this->template->set('nav_links',
array('setting/vouchertypes/add' => 'New Voucher Type'));
+
+ $this->db->from('voucher_types')->order_by('id',
'asc');
+ $data['voucher_type_data'] = $this->db->get();
+
+ $this->template->load('template', 'setting/vouchertypes/index',
$data);
+ return;
+ }
+}
+
+/* End of file vouchertypes.php */
+/* Location: ./system/application/controllers/setting/vouchertypes.php */
diff --git a/system/application/controllers/setting/welcome.php
b/system/application/controllers/setting/welcome.php
new file mode 100644
index 0000000..18fff8a
--- /dev/null
+++ b/system/application/controllers/setting/welcome.php
@@ -0,0 +1,29 @@
+<?php
+
+class Welcome extends Controller {
+
+ function Welcome()
+ {
+ parent::Controller();
+
+ /* Check access */
+ if ( ! check_access('change account settings'))
+ {
+ $this->messages->add('Permission denied.', 'error');
+ redirect('');
+ return;
+ }
+
+ return;
+ }
+
+ function index()
+ {
+ $this->template->set('page_title', 'Settings');
+ $this->template->load('template', 'setting/index');
+ return;
+ }
+}
+
+/* End of file welcome.php */
+/* Location: ./system/application/controllers/setting/welcome.php */
diff --git a/system/application/views/setting/index.php
b/system/application/views/setting/index.php
index e925798..00084bd 100644
--- a/system/application/views/setting/index.php
+++ b/system/application/views/setting/index.php
@@ -52,10 +52,10 @@
</div>
<div class="settings-container">
<div class="settings-title">
- <?php echo anchor('setting/voucher', 'Voucher Settings',
array('title' => 'Voucher Settings')); ?>
+ <?php echo anchor('setting/vouchertypes', 'Voucher Types',
array('title' => 'Voucher Types')); ?>
</div>
<div class="settings-desc">
- Voucher settings
+ Manage Voucher Types
</div>
</div>
</div>
diff --git a/system/application/views/setting/vouchertypes/index.php
b/system/application/views/setting/vouchertypes/index.php
new file mode 100644
index 0000000..241effa
--- /dev/null
+++ b/system/application/views/setting/vouchertypes/index.php
@@ -0,0 +1,26 @@
+<table border=0 cellpadding=5 class="simple-table">
+ <thead>
+ <tr>
+ <th>Label</th>
+ <th>Name</th>
+ <th>Description</th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php
+ foreach ($voucher_type_data->result() as $row)
+ {
+ echo "<tr>";
+
+ echo "<td>" . $row->label . "</td>";
+ echo "<td>" . $row->name . "</td>";
+
+ echo "<td>" . $row->description . "</td>";
+ echo "<td>" . anchor('voucher/edit/' . $row->id ,
"Edit", array('title' => 'Edit ' . $row->name . '
Voucher Type', 'class' => 'red-link')) . " ";
+ echo " " . anchor('voucher/delete/' . $row->id ,
img(array('src' => asset_url() . "images/icons/delete.png",
'border' => '0', 'alt' => 'Delete ' . $row->name
. ' Voucher Type', 'class' => "confirmClick", 'title'
=> "Delete Voucher Type")), array('title' => 'Delete ' .
$row->name . ' Voucher Type')) . " ";
+ echo "</tr>";
+ }
+ ?>
+ </tbody>
+</table>
commit 1ef3417945be2905b74ee43acde51e4262c86fcb
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Tue Feb 1 14:21:29 2011 +0530
Allow editing and deleting of System created Group A/C
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 e1c5976..8db1503 100644
--- a/system/application/controllers/group.php
+++ b/system/application/controllers/group.php
@@ -144,7 +144,7 @@ class Group extends Controller {
redirect('account');
return;
}
- if ($id <= 16) {
+ if ($id <= 4) {
$this->messages->add('Cannot edit System Group A/C.', 'error');
redirect('account');
return;
@@ -278,7 +278,7 @@ class Group extends Controller {
redirect('account');
return;
}
- if ($id <= 16) {
+ if ($id <= 4) {
$this->messages->add('Cannot delete System Group A/C.',
'error');
redirect('account');
return;
diff --git a/system/application/libraries/Accountlist.php
b/system/application/libraries/Accountlist.php
index 9819422..bd53cec 100644
--- a/system/application/libraries/Accountlist.php
+++ b/system/application/libraries/Accountlist.php
@@ -128,7 +128,7 @@ class Accountlist
echo "<td>-</td>";
echo "<td>-</td>";
- if ($this->id <= 16)
+ if ($this->id <= 4)
{
echo "<td class=\"td-actions\"></tr>";
} else {
commit 6519da6944340727a1966e4d68b9dc2cbb982859
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 31 22:03:50 2011 +0530
Updated template to use dynamic voucher types
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 4503b5b..7403867 100644
--- a/system/application/controllers/ledger.php
+++ b/system/application/controllers/ledger.php
@@ -261,16 +261,24 @@ class Ledger extends Controller {
return;
}
- /* Check if contra voucher present for non Bank or Cash A/C */
+ /* Check if bank_cash_ledger_restriction both voucher present */
if ($data_ledger_type_cashbank_value != "1")
{
- $this->db->from('voucher_items')->join('vouchers',
'voucher_items.voucher_id = vouchers.id')->where('vouchers.type',
3)->where('voucher_items.ledger_id', $id);
- $contra_count = $this->db->get()->num_rows();
- if ($contra_count > 0)
+ $voucher_type_all = $this->config->item('account_voucher_types');
+ foreach ($voucher_type_all as $voucher_type_id => $row)
{
- $this->messages->add('Cannot remove the Bank or Cash Account status of
this Ledger A/C since it is still linked with ' . $contra_count . ' Contra
Vouchers entries.', 'error');
- $this->template->load('template', 'ledger/edit', $data);
- return;
+ /* Check for Voucher types where bank_cash_ledger_restriction is for all ledgers */
+ if ($row['bank_cash_ledger_restriction'] == 4)
+ {
+ $this->db->from('voucher_items')->join('vouchers',
'voucher_items.voucher_id =
vouchers.id')->where('vouchers.voucher_type',
$voucher_type_id)->where('voucher_items.ledger_id', $id);
+ $all_ledger_bank_cash_count = $this->db->get()->num_rows();
+ if ($all_ledger_bank_cash_count > 0)
+ {
+ $this->messages->add('Cannot remove the Bank or Cash Account status of
this Ledger A/C since it is still linked with ' . $all_ledger_bank_cash_count . '
' . $row['name'] . ' Vouchers entries.', 'error');
+ $this->template->load('template', 'ledger/edit', $data);
+ return;
+ }
+ }
}
}
diff --git a/system/application/libraries/General.php
b/system/application/libraries/General.php
index 1bdd1b7..9f0d101 100644
--- a/system/application/libraries/General.php
+++ b/system/application/libraries/General.php
@@ -175,7 +175,7 @@ class General {
{
$CI =& get_instance();
- $CI->db->from('voucher_types');
+ $CI->db->from('voucher_types')->order_by('id',
'asc');
$voucher_types = $CI->db->get();
if ($voucher_types->num_rows() < 1)
{
diff --git a/system/application/views/template.php
b/system/application/views/template.php
index 3f3ba62..cc7e883 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -113,14 +113,29 @@ $(document).ready(function() {
<?php echo anchor('account', 'Accounts', array('title'
=> 'Chart of accounts')); ?>
</li>
<li>
- <?php echo anchor('voucher', 'Vouchers', array('title'
=> 'Vouchers')); ?>
- <ul>
- <li><?php echo anchor('voucher/show/all', 'All',
array('title' => 'All Vouchers')); ?></li>
- <li><?php echo anchor('voucher/show/receipt', 'Receipt',
array('title' => 'Receipt Vouchers')); ?></li>
- <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>
- </ul>
+ <?php
+ /* Showing Voucher Type sub-menu */
+ $voucher_type_all = $this->config->item('account_voucher_types');
+ $voucher_type_count = count($voucher_type_all);
+ if ($voucher_type_count < 1)
+ {
+ echo "";
+ } else if ($voucher_type_count == 1) {
+ foreach ($voucher_type_all as $id => $row)
+ {
+ echo anchor('voucher/show/' . $row['label'], $row['name'],
array('title' => $row['name'] . ' Vouchers'));
+ }
+ } else {
+ echo anchor('voucher', 'Vouchers', array('title' =>
'Vouchers'));
+ echo "<ul>";
+ echo "<li>" . anchor('voucher/show/all', 'All',
array('title' => 'All Vouchers')) . "</li>";
+ foreach ($voucher_type_all as $id => $row)
+ {
+ echo "<li>" . anchor('voucher/show/' .
$row['label'], $row['name'], array('title' =>
$row['name'] . ' Vouchers')) . "</li>";
+ }
+ echo "</ul>";
+ }
+ ?>
</li>
<li>
<?php echo anchor('report', 'Reports', array('title' =>
'Reports')); ?>
commit 4fa247c752ea5c1ab6ba39f9f23350ea49f434a1
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 31 21:19:53 2011 +0530
Renaming voucher table column from type to voucher_type
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/db-update.txt b/db-update.txt
index 6a0bfc8..af027db 100644
--- a/db-update.txt
+++ b/db-update.txt
@@ -20,6 +20,8 @@ ALTER TABLE settings DROP contra_voucher_prefix;
ALTER TABLE settings DROP journal_voucher_prefix;
ALTER TABLE settings DROP voucher_number_padding;
+ALTER TABLE vouchers CHANGE type voucher_type INT(5) NOT NULL;
+
//--------------------------------- VERSION 2 ----------------------------------
ALTER TABLE voucher_items ADD reconciliation_date DATETIME NULL;
diff --git a/system/application/controllers/admin/schema.sql
b/system/application/controllers/admin/schema.sql
index fe93902..69a571c 100644
--- a/system/application/controllers/admin/schema.sql
+++ b/system/application/controllers/admin/schema.sql
@@ -34,12 +34,12 @@ CREATE TABLE IF NOT EXISTS voucher_types (
CREATE TABLE IF NOT EXISTS vouchers (
id int(11) NOT NULL AUTO_INCREMENT,
tag_id int(11) NOT NULL DEFAULT '0',
+ voucher_type int(5) NOT NULL,
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,
- 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 3d9d2e7..41ed059 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -349,7 +349,7 @@ class Report extends Controller {
$cur_balance -= $opbalance;
$counter++;
- $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->select('vouchers.id as vid, vouchers.number as vnumber,
vouchers.date as vdate, vouchers.voucher_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)
@@ -361,7 +361,7 @@ class Report extends Controller {
$ledgerst[$counter][1] = full_voucher_number($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][2] = $this->Ledger_model->get_opp_ledger_name($row->vid,
$current_voucher_type['label'], $row->ldc, 'text');
$ledgerst[$counter][3] = $current_voucher_type['name'];
@@ -469,7 +469,7 @@ class Report extends Controller {
/* 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');
+ $this->db->select('vouchers.id as vid, vouchers.number as vnumber,
vouchers.date as vdate, vouchers.voucher_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
@@ -484,7 +484,7 @@ class Report extends Controller {
$ledgerst[$counter][1] = full_voucher_number($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][2] = $this->Ledger_model->get_opp_ledger_name($row->vid,
$current_voucher_type['label'], $row->ldc, 'text');
$ledgerst[$counter][3] = $current_voucher_type['name'];
diff --git a/system/application/controllers/voucher.php
b/system/application/controllers/voucher.php
index d0f1f0b..7405233 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -100,9 +100,9 @@ class Voucher extends Controller {
$voucher_q = $this->db->get();
$config['total_rows'] =
$this->db->from('vouchers')->where('tag_id',
$tag_id)->get()->num_rows();
} else if ($voucher_type_id > 0) {
- $this->db->from('vouchers')->where('type',
$voucher_type_id)->order_by('date',
'desc')->order_by('number',
'desc')->limit($pagination_counter, $page_count);
+ $this->db->from('vouchers')->where('voucher_type',
$voucher_type_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('type',
$voucher_type_id)->get()->num_rows();
+ $config['total_rows'] =
$this->db->from('vouchers')->where('voucher_type',
$voucher_type_id)->get()->num_rows();
} else {
$this->db->from('vouchers')->order_by('date',
'desc')->order_by('number',
'desc')->limit($pagination_counter, $page_count);
$voucher_q = $this->db->get();
@@ -432,7 +432,7 @@ class Voucher extends Controller {
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_number = $this->Voucher_model->next_voucher_number($voucher_type_id);
$data_date = $this->input->post('voucher_date', TRUE);
$data_narration = $this->input->post('voucher_narration', TRUE);
@@ -446,7 +446,7 @@ class Voucher extends Controller {
'number' => $data_number,
'date' => $data_date,
'narration' => $data_narration,
- 'type' => $data_type,
+ 'voucher_type' => $data_type,
'tag_id' => $data_tag,
);
if ( ! $this->db->insert('vouchers', $insert_data))
@@ -640,7 +640,7 @@ class Voucher extends Controller {
}
/* Form validations */
- $this->form_validation->set_rules('voucher_number', 'Voucher
Number', 'trim|required|is_natural_no_zero|uniquevouchernowithid[' .
v_to_n($voucher_type) . '.' . $voucher_id . ']');
+ $this->form_validation->set_rules('voucher_number', 'Voucher
Number', 'trim|required|is_natural_no_zero|uniquevouchernowithid[' .
$voucher_type_id . '.' . $voucher_id . ']');
$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');
@@ -894,7 +894,7 @@ class Voucher extends Controller {
return;
}
- function delete($voucher_type, $voucher_id)
+ function delete($voucher_type, $voucher_id = 0)
{
/* Check access */
if ( ! check_access('delete voucher'))
@@ -955,7 +955,7 @@ class Voucher extends Controller {
return;
}
- function download($voucher_type, $voucher_id)
+ function download($voucher_type, $voucher_id = 0)
{
$this->load->helper('download');
$this->load->model('Setting_model');
@@ -1022,7 +1022,7 @@ class Voucher extends Controller {
return;
}
- function printpreview($voucher_type, $voucher_id)
+ function printpreview($voucher_type, $voucher_id = 0)
{
$this->load->model('Setting_model');
$this->load->model('Ledger_model');
@@ -1085,7 +1085,7 @@ class Voucher extends Controller {
return;
}
- function email($voucher_type, $voucher_id)
+ function email($voucher_type, $voucher_id = 0)
{
$this->load->model('Setting_model');
$this->load->model('Ledger_model');
diff --git a/system/application/helpers/custom_helper.php
b/system/application/helpers/custom_helper.php
index b72c50c..8ec3256 100644
--- a/system/application/helpers/custom_helper.php
+++ b/system/application/helpers/custom_helper.php
@@ -97,54 +97,6 @@ if ( ! function_exists('print_value'))
}
/**
- * Return Voucher Type String from Number
- *
- * Return the account information
- *
- * @access public
- * @param a varaible
- * @return string value
- */
-if ( ! function_exists('n_to_v'))
-{
- function n_to_v($type_number)
- {
- switch ($type_number)
- {
- case 1: return "receipt"; break;
- case 2: return "payment"; break;
- case 3: return "contra"; break;
- case 4: return "journal"; break;
- default: return ""; break;
- }
- }
-}
-
-/**
- * Return Number from Voucher Type String
- *
- * Return the account information
- *
- * @access public
- * @param a varaible
- * @return string value
- */
-if ( ! function_exists('v_to_n'))
-{
- function v_to_n($type_string)
- {
- switch ($type_string)
- {
- case "receipt": return 1; break;
- case "payment": return 2; break;
- case "contra": return 3; break;
- case "journal": return 4; break;
- default: return 0; break;
- }
- }
-}
-
-/**
* Return Voucher Type information
*
* @access public
diff --git a/system/application/libraries/MY_Form_validation.php
b/system/application/libraries/MY_Form_validation.php
index 83d954f..06624e3 100644
--- a/system/application/libraries/MY_Form_validation.php
+++ b/system/application/libraries/MY_Form_validation.php
@@ -36,7 +36,7 @@ class MY_Form_validation extends CI_Form_validation {
$CI->form_validation->set_message('uniquevoucherno', 'The %s that you
requested is already in use.');
- $CI->db->from('vouchers')->where('number',
$str)->where('type', $type);
+ $CI->db->from('vouchers')->where('number',
$str)->where('voucher_type', $type);
$dup_query = $CI->db->get();
if ($dup_query->num_rows() > 0)
return FALSE;
@@ -51,7 +51,7 @@ class MY_Form_validation extends CI_Form_validation {
list ($type, $id) = explode('.', $field, 2);
$CI->form_validation->set_message('uniquevouchernowithid', 'The %s
that you requested is already in use.');
- $CI->db->from('vouchers')->where('number',
$str)->where('type', $type)->where('id !=', $id);
+ $CI->db->from('vouchers')->where('number',
$str)->where('voucher_type', $type)->where('id !=', $id);
$dup_query = $CI->db->get();
if ($dup_query->num_rows() > 0)
return FALSE;
diff --git a/system/application/models/ledger_model.php
b/system/application/models/ledger_model.php
index 1fb96cf..fe7fd04 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;
}
- function get_opp_ledger_name($voucher_id, $voucher_type, $ledger_type, $output_type)
+ function get_opp_ledger_name($voucher_id, $voucher_type_label, $ledger_type,
$output_type)
{
$output = '';
if ($ledger_type == 'D')
@@ -111,12 +111,12 @@ class Ledger_model extends Model {
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'));
+ $output = anchor('voucher/view/' . $voucher_type_label . '/' .
$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'));
+ $output = anchor('voucher/view/' . $voucher_type_label . '/' .
$voucher_id, $opp_ledger_name, array('title' => 'View ' . '
Voucher', 'class' => 'anchor-link-a'));
else
$output = $opp_ledger_name;
}
diff --git a/system/application/models/voucher_model.php
b/system/application/models/voucher_model.php
index 6381145..f51ea63 100644
--- a/system/application/models/voucher_model.php
+++ b/system/application/models/voucher_model.php
@@ -7,10 +7,9 @@ class Voucher_model extends Model {
parent::Model();
}
- function next_voucher_number($type_string)
+ function next_voucher_number($voucher_type_id)
{
- $type_number = v_to_n($type_string);
- $this->db->select_max('number',
'lastno')->from('vouchers')->where('type', $type_number);
+ $this->db->select_max('number',
'lastno')->from('vouchers')->where('voucher_type',
$voucher_type_id);
$last_no_q = $this->db->get();
if ($row = $last_no_q->row())
{
@@ -24,7 +23,7 @@ class Voucher_model extends Model {
function get_voucher($voucher_id, $voucher_type_id)
{
- $this->db->from('vouchers')->where('id',
$voucher_id)->where('type', $voucher_type_id)->limit(1);
+ $this->db->from('vouchers')->where('id',
$voucher_id)->where('voucher_type', $voucher_type_id)->limit(1);
$voucher_q = $this->db->get();
return $voucher_q->row();
}
diff --git a/system/application/views/report/ledgerst.php
b/system/application/views/report/ledgerst.php
index 63bd210..7f9752c 100644
--- a/system/application/views/report/ledgerst.php
+++ b/system/application/views/report/ledgerst.php
@@ -61,12 +61,12 @@
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');
+ $this->db->select('vouchers.id as vid, vouchers.number as vnumber,
vouchers.date as vdate, vouchers.voucher_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;
- $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->select('vouchers.id as vid, vouchers.number as vnumber,
vouchers.date as vdate, vouchers.voucher_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();
}
@@ -99,7 +99,7 @@
}
/* Calculating previous balance */
- $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->select('vouchers.id as vid, vouchers.number as vnumber,
vouchers.date as vdate, vouchers.voucher_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 )
@@ -128,7 +128,7 @@
/* Getting opposite Ledger name */
echo "<td>";
- echo $this->Ledger_model->get_opp_ledger_name($row->vid, $row->vtype,
$row->ldc, 'html');
+ echo $this->Ledger_model->get_opp_ledger_name($row->vid,
$current_voucher_type['label'], $row->ldc, 'html');
echo "</td>";
echo "<td>";
diff --git a/system/application/views/report/reconciliation.php
b/system/application/views/report/reconciliation.php
index 63b8b44..2deccb1 100644
--- a/system/application/views/report/reconciliation.php
+++ b/system/application/views/report/reconciliation.php
@@ -93,7 +93,7 @@
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.id as lid,
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.voucher_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
@@ -101,7 +101,7 @@
$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.id as lid,
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.voucher_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');
else
@@ -135,7 +135,7 @@
/* Getting opposite Ledger name */
echo "<td>";
- echo $this->Ledger_model->get_opp_ledger_name($row->vid, $row->vtype,
$row->ldc, 'html');
+ echo $this->Ledger_model->get_opp_ledger_name($row->vid,
$current_voucher_type['label'], $row->ldc, 'html');
echo "</td>";
echo "<td>";
diff --git a/system/application/views/voucher/index.php
b/system/application/views/voucher/index.php
index 5526dc7..fee5836 100644
--- a/system/application/views/voucher/index.php
+++ b/system/application/views/voucher/index.php
@@ -18,16 +18,16 @@
<?php
foreach ($voucher_data->result() as $row)
{
- $current_voucher_type = voucher_type_info($row->type);
+ $current_voucher_type = voucher_type_info($row->voucher_type);
echo "<tr>";
echo "<td>" . date_mysql_to_php_display($row->date) .
"</td>";
- echo "<td>" . anchor('voucher/view/' .
$current_voucher_type['label'] . "/" . $row->id,
full_voucher_number($row->type, $row->number), array('title' => 'View
' . $current_voucher_type['name'] . ' Voucher', 'class' =>
'anchor-link-a')) . "</td>";
+ echo "<td>" . anchor('voucher/view/' .
$current_voucher_type['label'] . "/" . $row->id,
full_voucher_number($row->voucher_type, $row->number), array('title' =>
'View ' . $current_voucher_type['name'] . ' Voucher',
'class' => 'anchor-link-a')) . "</td>";
echo "<td>";
echo $this->Tag_model->show_voucher_tag($row->tag_id);
- echo $this->Ledger_model->get_voucher_name($row->id, $row->type);
+ echo $this->Ledger_model->get_voucher_name($row->id, $row->voucher_type);
echo "</td>";
echo "<td>" . $current_voucher_type['name'] .
"</td>";
commit 7c3e2b7eac277f36fba4252dafa96194004ba130
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 31 18:01:19 2011 +0530
Updated database schema to use dynamic voucher types
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/db-update.txt b/db-update.txt
index a939c6d..6a0bfc8 100644
--- a/db-update.txt
+++ b/db-update.txt
@@ -14,6 +14,12 @@ CREATE TABLE IF NOT EXISTS voucher_types (
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+ALTER TABLE settings DROP receipt_voucher_prefix;
+ALTER TABLE settings DROP payment_voucher_prefix;
+ALTER TABLE settings DROP contra_voucher_prefix;
+ALTER TABLE settings DROP journal_voucher_prefix;
+ALTER TABLE settings DROP voucher_number_padding;
+
//--------------------------------- VERSION 2 ----------------------------------
ALTER TABLE voucher_items ADD reconciliation_date DATETIME NULL;
diff --git a/system/application/controllers/admin/create.php
b/system/application/controllers/admin/create.php
index 0547e10..28c8837 100644
--- a/system/application/controllers/admin/create.php
+++ b/system/application/controllers/admin/create.php
@@ -202,6 +202,7 @@ class Create extends Controller {
$data_account_date = "dd/mm/yyyy";
$data_account_timezone = $this->input->post('timezones', TRUE);
+ $data_database_type = 'mysql';
$data_database_host = $this->input->post('database_host', TRUE);
$data_database_port = $this->input->post('database_port', TRUE);
$data_database_name = $this->input->post('database_name', TRUE);
@@ -321,7 +322,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, 2)))
+ 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, 3)))
{
$newacc->trans_rollback();
$this->messages->add('Error adding account settings.',
'error');
@@ -333,9 +334,9 @@ class Create extends Controller {
}
/* 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 = "[database]" . "\r\n" . "db_type =
\"" . $data_database_type . "\"" . "\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 />';
+ $con_details_html = '[database]' . '<br />db_type = "' .
$data_database_type . '"<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))
diff --git a/system/application/controllers/admin/initialize.sql
b/system/application/controllers/admin/initialize.sql
index 5327848..9f1ac5d 100644
--- a/system/application/controllers/admin/initialize.sql
+++ b/system/application/controllers/admin/initialize.sql
@@ -14,3 +14,7 @@ INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (13, 3,
'Indirect
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);
+INSERT INTO voucher_types (id, label, name, description, base_type, numbering, prefix,
suffix, zero_padding, bank_cash_ledger_restriction) VALUES (1, 'receipt',
'Receipt', 'Received in Bank A/C or Cash A/C', 1, 1, '',
'', 0, 2);
+INSERT INTO voucher_types (id, label, name, description, base_type, numbering, prefix,
suffix, zero_padding, bank_cash_ledger_restriction) VALUES (2, 'payment',
'Payment', 'Payment made from Bank A/C or Cash A/C', 1, 1, '',
'', 0, 3);
+INSERT INTO voucher_types (id, label, name, description, base_type, numbering, prefix,
suffix, zero_padding, bank_cash_ledger_restriction) VALUES (3, 'contra',
'Contra', 'Transfer between Bank A/C and Cash A/C', 1, 1, '',
'', 0, 4);
+INSERT INTO voucher_types (id, label, name, description, base_type, numbering, prefix,
suffix, zero_padding, bank_cash_ledger_restriction) VALUES (4, 'journal',
'Journal', 'Transfer between Non Bank A/C and Cash A/C', 1, 1, '',
'', 0, 5);
diff --git a/system/application/controllers/admin/schema.sql
b/system/application/controllers/admin/schema.sql
index 1f2789a..fe93902 100644
--- a/system/application/controllers/admin/schema.sql
+++ b/system/application/controllers/admin/schema.sql
@@ -17,6 +17,20 @@ 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 voucher_types (
+ id int(5) NOT NULL,
+ label varchar(15) NOT NULL,
+ name varchar(100) NOT NULL,
+ description varchar(255) NOT NULL,
+ base_type int(2) NOT NULL,
+ numbering int(2) NOT NULL,
+ prefix varchar(10) NOT NULL,
+ suffix varchar(10) NOT NULL,
+ zero_padding int(2) NOT NULL,
+ bank_cash_ledger_restriction int(2) NOT NULL,
+ PRIMARY KEY (id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
CREATE TABLE IF NOT EXISTS vouchers (
id int(11) NOT NULL AUTO_INCREMENT,
tag_id int(11) NOT NULL DEFAULT '0',
@@ -85,10 +99,5 @@ CREATE TABLE IF NOT EXISTS settings (
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/report.php
b/system/application/controllers/report.php
index afeec86..3d9d2e7 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -358,7 +358,7 @@ class Report extends Controller {
$current_voucher_type = voucher_type_info($row->vtype);
$ledgerst[$counter][0] = date_mysql_to_php($row->vdate);
- $ledgerst[$counter][1] = voucher_number_prefix($row->vtype) . $row->vnumber;
+ $ledgerst[$counter][1] = full_voucher_number($row->vtype, $row->vnumber);
/* Opposite voucher name */
$ledgerst[$counter][2] = $this->Ledger_model->get_opp_ledger_name($row->vid,
$row->vtype, $row->ldc, 'text');
@@ -481,7 +481,7 @@ class Report extends Controller {
$current_voucher_type = voucher_type_info($row->vtype);
$ledgerst[$counter][0] = date_mysql_to_php($row->vdate);
- $ledgerst[$counter][1] = voucher_number_prefix($row->vtype) . $row->vnumber;
+ $ledgerst[$counter][1] = full_voucher_number($row->vtype, $row->vnumber);
/* Opposite voucher name */
$ledgerst[$counter][2] = $this->Ledger_model->get_opp_ledger_name($row->vid,
$row->vtype, $row->ldc, 'text');
diff --git a/system/application/controllers/setting.php
b/system/application/controllers/setting.php
index a89c560..495684d 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -328,6 +328,7 @@ class Setting extends Controller {
$data_account_email_username = $account_data->email_username;
$data_account_email_password = $account_data->email_password;
+ $data_database_type = 'mysql';
$data_database_host = $this->input->post('database_host', TRUE);
$data_database_port = $this->input->post('database_port', TRUE);
$data_database_name = $this->input->post('database_name', TRUE);
@@ -427,7 +428,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, 2)))
+ 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, 3)))
{
$newacc->trans_rollback();
$this->messages->add('Error adding account settings.',
'error');
@@ -492,6 +493,18 @@ class Setting extends Controller {
}
}
+ /* Importing Voucher Types */
+ $this->db->from('voucher_types')->order_by('id',
'asc');
+ $voucher_type_q = $this->db->get();
+ foreach ($voucher_type_q->result() as $row)
+ {
+ if ( ! $newacc->query("INSERT INTO voucher_types (id, label, name,
description, base_type, numbering, prefix, suffix, zero_padding,
bank_cash_ledger_restriction) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
array($row->id, $row->label, $row->name, $row->description,
$row->base_type, $row->numbering, $row->prefix, $row->suffix,
$row->zero_padding, $row->bank_cash_ledger_restriction)))
+ {
+ $this->messages->add('Failed to add Voucher type - ' . $row->name
. '.', 'error');
+ $cf_status = FALSE;
+ }
+ }
+
/* Importing Tags */
$this->db->from('tags')->order_by('id', 'asc');
$tag_q = $this->db->get();
@@ -511,9 +524,9 @@ class Setting extends Controller {
/* 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 = "[database]" . "\r\n" . "db_type =
\"" . $data_database_type . "\"" . "\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 />';
+ $con_details_html = '[database]' . '<br />db_type = "' .
$data_database_type . '"<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))
@@ -957,7 +970,7 @@ class Setting extends Controller {
if ( ! $this->db->where('id', 1)->update('settings',
$update_data))
{
$this->db->trans_rollback();
- $this->messages->add('Error updating voucher settings.',
'error');
+ $this->messages->add('Error updating Voucher settings.',
'error');
$this->logger->write_message("error", "Error updating voucher
settings");
$this->template->load('template', 'setting/voucher');
return;
diff --git a/system/application/controllers/voucher.php
b/system/application/controllers/voucher.php
index 061bdb6..d0f1f0b 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -120,7 +120,7 @@ class Voucher extends Controller {
$voucher_added_type_label_temp =
$this->session->userdata('voucher_added_type_label');
$voucher_added_type_name_temp =
$this->session->userdata('voucher_added_type_name');
$voucher_added_number_temp =
$this->session->userdata('voucher_added_number');
- $voucher_added_message = 'Added ' . $voucher_added_type_name_temp . '
Voucher number ' . voucher_number_prefix($voucher_added_type_id_temp) .
$voucher_added_number_temp . ".";
+ $voucher_added_message = 'Added ' . $voucher_added_type_name_temp . '
Voucher number ' . full_voucher_number($voucher_added_type_id_temp,
$voucher_added_number_temp) . ".";
$voucher_added_message .= " You can [ ";
$voucher_added_message .= anchor('voucher/view/' .
$voucher_added_type_label_temp . "/" . $voucher_added_id_temp, 'View',
array('class' => 'anchor-link-a')) . " | ";
$voucher_added_message .= anchor('voucher/edit/' .
$voucher_added_type_label_temp . "/" . $voucher_added_id_temp, 'Edit',
array('class' => 'anchor-link-a')) . " | ";
@@ -145,7 +145,7 @@ class Voucher extends Controller {
$voucher_updated_type_label_temp =
$this->session->userdata('voucher_updated_type_label');
$voucher_updated_type_name_temp =
$this->session->userdata('voucher_updated_type_name');
$voucher_updated_number_temp =
$this->session->userdata('voucher_updated_number');
- $voucher_updated_message = 'Updated ' . $voucher_updated_type_name_temp .
' Voucher number ' . voucher_number_prefix($voucher_updated_type_id_temp) .
$voucher_updated_number_temp . ".";
+ $voucher_updated_message = 'Updated ' . $voucher_updated_type_name_temp .
' Voucher number ' . full_voucher_number($voucher_updated_type_id_temp,
$voucher_updated_number_temp) . ".";
$voucher_updated_message .= " You can [ ";
$voucher_updated_message .= anchor('voucher/view/' .
$voucher_updated_type_label_temp . "/" . $voucher_updated_id_temp,
'View', array('class' => 'anchor-link-a')) . " | ";
$voucher_updated_message .= anchor('voucher/edit/' .
$voucher_updated_type_label_temp . "/" . $voucher_updated_id_temp,
'Edit', array('class' => 'anchor-link-a')) . " | ";
@@ -453,7 +453,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error addding Voucher.', 'error');
- $this->logger->write_message("error", "Error adding " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " since failed inserting
voucher");
+ $this->logger->write_message("error", "Error adding " .
$current_voucher_type['name'] . " Voucher number " .
full_voucher_number($voucher_type_id, $data_number) . " since failed inserting
voucher");
$this->template->load('template', 'voucher/add', $data);
return;
} else {
@@ -493,7 +493,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error adding Ledger A/C - ' . $data_ledger_id .
' to Voucher.', 'error');
- $this->logger->write_message("error", "Error adding " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " since failed inserting
voucher ledger item " . "[id:" . $data_ledger_id . "]");
+ $this->logger->write_message("error", "Error adding " .
$current_voucher_type['name'] . " Voucher number " .
full_voucher_number($voucher_type_id, $data_number) . " since failed inserting
voucher ledger item " . "[id:" . $data_ledger_id . "]");
$this->template->load('template', 'voucher/add', $data);
return;
}
@@ -508,7 +508,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error updating Voucher total.',
'error');
- $this->logger->write_message("error", "Error adding " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " since failed updating
debit and credit total");
+ $this->logger->write_message("error", "Error adding " .
$current_voucher_type['name'] . " Voucher number " .
full_voucher_number($voucher_type_id, $data_number) . " since failed updating debit
and credit total");
$this->template->load('template', 'voucher/add', $data);
return;
}
@@ -524,7 +524,7 @@ class Voucher extends Controller {
$this->session->set_userdata('voucher_added_number', $data_number);
/* Showing success message in show() method since message is too long for storing it
in session */
- $this->logger->write_message("success", "Added " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " [id:" . $voucher_id .
"]");
+ $this->logger->write_message("success", "Added " .
$current_voucher_type['name'] . " Voucher number " .
full_voucher_number($voucher_type_id, $data_number) . " [id:" . $voucher_id .
"]");
redirect('voucher/show/' . $current_voucher_type['label']);
$this->template->load('template', 'voucher/add', $data);
return;
@@ -802,7 +802,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 " . $current_voucher_type['name'] . " Voucher number "
. voucher_number_prefix($voucher_type_id) . $data_number . " [id:" . $voucher_id
. "]");
+ $this->logger->write_message("error", "Error updating voucher
details for " . $current_voucher_type['name'] . " Voucher number "
. full_voucher_number($voucher_type_id, $data_number) . " [id:" . $voucher_id .
"]");
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -812,7 +812,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error deleting previous Ledger A/C\'s from
Voucher.', 'error');
- $this->logger->write_message("error", "Error deleting previous
voucher items for " . $current_voucher_type['name'] . " Voucher number
" . voucher_number_prefix($voucher_type_id) . $data_number . " [id:" .
$voucher_id . "]");
+ $this->logger->write_message("error", "Error deleting previous
voucher items for " . $current_voucher_type['name'] . " Voucher number
" . full_voucher_number($voucher_type_id, $data_number) . " [id:" .
$voucher_id . "]");
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -851,7 +851,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error adding Ledger A/C - ' . $data_ledger_id .
' to Voucher.', 'error');
- $this->logger->write_message("error", "Error adding Ledger A/C
item [id:" . $data_ledger_id . "] for " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " [id:" . $voucher_id .
"]");
+ $this->logger->write_message("error", "Error adding Ledger A/C
item [id:" . $data_ledger_id . "] for " .
$current_voucher_type['name'] . " Voucher number " .
full_voucher_number($voucher_type_id, $data_number) . " [id:" . $voucher_id .
"]");
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -866,7 +866,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 " . $current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " [id:" . $voucher_id .
"]");
+ $this->logger->write_message("error", "Error updating voucher
total for " . $current_voucher_type['name'] . " Voucher number " .
full_voucher_number($voucher_type_id, $data_number) . " [id:" . $voucher_id .
"]");
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -886,7 +886,7 @@ class Voucher extends Controller {
$this->session->set_userdata('voucher_updated_has_reconciliation',
FALSE);
/* Showing success message in show() method since message is too long for storing it
in session */
- $this->logger->write_message("success", "Updated " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " [id:" . $voucher_id .
"]");
+ $this->logger->write_message("success", "Updated " .
$current_voucher_type['name'] . " Voucher number " .
full_voucher_number($voucher_type_id, $data_number) . " [id:" . $voucher_id .
"]");
redirect('voucher/show/' . $current_voucher_type['label']);
return;
@@ -936,7 +936,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error deleting Voucher - Ledger A/C\'s.',
'error');
- $this->logger->write_message("error", "Error deleting ledger
entries for " . $current_voucher_type['name'] . " Voucher number "
. voucher_number_prefix($voucher_type_id) . $cur_voucher->number . " [id:" .
$voucher_id . "]");
+ $this->logger->write_message("error", "Error deleting ledger
entries for " . $current_voucher_type['name'] . " Voucher number "
. full_voucher_number($voucher_type_id, $cur_voucher->number) . " [id:" .
$voucher_id . "]");
redirect('voucher/view/' . $current_voucher_type['label'] .
'/' . $voucher_id);
return;
}
@@ -944,13 +944,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 " . $current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $cur_voucher->number . " [id:" .
$voucher_id . "]");
+ $this->logger->write_message("error", "Error deleting Voucher
entry for " . $current_voucher_type['name'] . " Voucher number " .
full_voucher_number($voucher_type_id, $cur_voucher->number) . " [id:" .
$voucher_id . "]");
redirect('voucher/view/' . $current_voucher_type['label'] .
'/' . $voucher_id);
return;
}
$this->db->trans_complete();
$this->messages->add('Deleted ' . $current_voucher_type['name'] .
' Voucher.', 'success');
- $this->logger->write_message("success", "Deleted " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $cur_voucher->number . " [id:" .
$voucher_id . "]");
+ $this->logger->write_message("success", "Deleted " .
$current_voucher_type['name'] . " Voucher number " .
full_voucher_number($voucher_type_id, $cur_voucher->number) . " [id:" .
$voucher_id . "]");
redirect('voucher/show/' . $current_voucher_type['label']);
return;
}
@@ -1198,15 +1198,15 @@ class Voucher extends Controller {
/* Sending email */
$this->email->from('', 'Webzash');
$this->email->to($this->input->post('email_to', TRUE));
- $this->email->subject($current_voucher_type['name'] . ' Voucher No.
' . voucher_number_prefix($voucher_type_id) . $cur_voucher->number);
+ $this->email->subject($current_voucher_type['name'] . ' Voucher No.
' . full_voucher_number($voucher_type_id, $cur_voucher->number));
$this->email->message($message);
if ($this->email->send())
{
$data['message'] = "Email sent.";
- $this->logger->write_message("success", "Emailed " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $cur_voucher->number . " [id:" .
$voucher_id . "]");
+ $this->logger->write_message("success", "Emailed " .
$current_voucher_type['name'] . " Voucher number " .
full_voucher_number($voucher_type_id, $cur_voucher->number) . " [id:" .
$voucher_id . "]");
} else {
$data['error'] = "Error sending email. Check you email settings.";
- $this->logger->write_message("error", "Error emailing " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $cur_voucher->number . " [id:" .
$voucher_id . "]");
+ $this->logger->write_message("error", "Error emailing " .
$current_voucher_type['name'] . " Voucher number " .
full_voucher_number($voucher_type_id, $cur_voucher->number) . " [id:" .
$voucher_id . "]");
}
$this->load->view('voucher/email', $data);
return;
diff --git a/system/application/helpers/custom_helper.php
b/system/application/helpers/custom_helper.php
index 014acf4..b72c50c 100644
--- a/system/application/helpers/custom_helper.php
+++ b/system/application/helpers/custom_helper.php
@@ -217,18 +217,18 @@ if ( ! function_exists('voucher_type_name_to_id'))
* @param int voucher type id
* @return string
*/
-if ( ! function_exists('voucher_number_prefix'))
+if ( ! function_exists('full_voucher_number'))
{
- function voucher_number_prefix($voucher_type_id)
+ function full_voucher_number($voucher_type_id, $voucher_number)
{
$CI =& get_instance();
$voucher_type_all = $CI->config->item('account_voucher_types');
if ( ! $voucher_type_all[$voucher_type_id])
{
- return '';
+ return $voucher_number;
} else {
- return $voucher_type_all[$voucher_type_id]['prefix'];
+ return $voucher_type_all[$voucher_type_id]['prefix'] . $voucher_number .
$voucher_type_all[$voucher_type_id]['suffix'];
}
}
}
diff --git a/system/application/libraries/Startup.php
b/system/application/libraries/Startup.php
index 2160cf0..d658223 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -106,10 +106,6 @@ class Startup
$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);
- $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 */
diff --git a/system/application/views/report/ledgerst.php
b/system/application/views/report/ledgerst.php
index fd3115b..63bd210 100644
--- a/system/application/views/report/ledgerst.php
+++ b/system/application/views/report/ledgerst.php
@@ -123,7 +123,7 @@
echo date_mysql_to_php_display($row->vdate);
echo "</td>";
echo "<td>";
- echo anchor('voucher/view/' . $current_voucher_type['label'] .
'/' . $row->vid, voucher_number_prefix($row->vtype) . $row->vnumber,
array('title' => 'View ' . ' Voucher', 'class' =>
'anchor-link-a'));
+ echo anchor('voucher/view/' . $current_voucher_type['label'] .
'/' . $row->vid, full_voucher_number($row->vtype, $row->vnumber),
array('title' => 'View ' . ' Voucher', 'class' =>
'anchor-link-a'));
echo "</td>";
/* Getting opposite Ledger name */
diff --git a/system/application/views/report/reconciliation.php
b/system/application/views/report/reconciliation.php
index 0cbb0a4..63b8b44 100644
--- a/system/application/views/report/reconciliation.php
+++ b/system/application/views/report/reconciliation.php
@@ -130,7 +130,7 @@
echo date_mysql_to_php_display($row->vdate);
echo "</td>";
echo "<td>";
- echo anchor('voucher/view/' . $current_voucher_type['label'] .
'/' . $row->vid, voucher_number_prefix($row->vtype) . $row->vnumber,
array('title' => 'View ' . $current_voucher_type['name'] .
' Voucher', 'class' => 'anchor-link-a'));
+ echo anchor('voucher/view/' . $current_voucher_type['label'] .
'/' . $row->vid, full_voucher_number($row->vtype, $row->vnumber),
array('title' => 'View ' . $current_voucher_type['name'] .
' Voucher', 'class' => 'anchor-link-a'));
echo "</td>";
/* Getting opposite Ledger name */
diff --git a/system/application/views/voucher/add.php
b/system/application/views/voucher/add.php
index 93aa5bc..06d2b97 100644
--- a/system/application/views/voucher/add.php
+++ b/system/application/views/voucher/add.php
@@ -200,7 +200,7 @@ $(document).ready(function() {
echo "<span id=\"tooltip-target-1\">";
echo form_label('Voucher Number', 'voucher_number');
echo " ";
- echo voucher_number_prefix($voucher_type_id) . form_input($voucher_number);
+ echo $current_voucher_type['prefix'] . form_input($voucher_number) .
$current_voucher_type['suffix'];
echo "</span>";
echo "<span id=\"tooltip-content-1\">Leave Voucher Number empty for
auto numbering</span>";
echo
" ";
diff --git a/system/application/views/voucher/downloadpreview.php
b/system/application/views/voucher/downloadpreview.php
index d59f587..61b3f52 100644
--- a/system/application/views/voucher/downloadpreview.php
+++ b/system/application/views/voucher/downloadpreview.php
@@ -65,7 +65,7 @@
<br />
<div id="print-voucher-type"><span
class="value"><?php echo $current_voucher_type['name']; ?>
Voucher</span></div>
<br />
- <div id="print-voucher-number"><?php echo
$current_voucher_type['name']; ?> Voucher Number : <span
class="value"><?php echo voucher_number_prefix($voucher_type_id) .
$voucher_number; ?></span></div>
+ <div id="print-voucher-number"><?php echo
$current_voucher_type['name']; ?> Voucher Number : <span
class="value"><?php echo full_voucher_number($voucher_type_id,
$voucher_number); ?></span></div>
<div id="print-voucher-number"><?php echo
$current_voucher_type['name']; ?> Voucher Date : <span
class="value"><?php echo $voucher_date; ?></span></div>
<br />
<table id="print-voucher-table">
diff --git a/system/application/views/voucher/edit.php
b/system/application/views/voucher/edit.php
index 3df7039..3eb7b60 100644
--- a/system/application/views/voucher/edit.php
+++ b/system/application/views/voucher/edit.php
@@ -199,7 +199,7 @@ $(document).ready(function() {
echo "<p>";
echo form_label('Voucher Number', 'voucher_number');
echo " ";
- echo voucher_number_prefix($voucher_type_id) . form_input($voucher_number);
+ echo $current_voucher_type['prefix'] . form_input($voucher_number) .
$current_voucher_type['suffix'];
echo
" ";
echo "<span id=\"tooltip-target-1\">";
echo form_label('Voucher Date', 'voucher_date');
diff --git a/system/application/views/voucher/emailpreview.php
b/system/application/views/voucher/emailpreview.php
index 87336bc..0b0febd 100644
--- a/system/application/views/voucher/emailpreview.php
+++ b/system/application/views/voucher/emailpreview.php
@@ -7,7 +7,7 @@
<p><?php echo $this->config->item('account_name');
?></p>
<p><?php echo $this->config->item('account_address');
?></p>
<p><strong><?php echo $current_voucher_type['name']; ?>
Voucher</strong></p>
- <p><?php echo $current_voucher_type['name']; ?> Voucher Number :
<strong><?php echo voucher_number_prefix($voucher_type_id) . $voucher_number;
?></strong></p>
+ <p><?php echo $current_voucher_type['name']; ?> Voucher Number :
<strong><?php echo full_voucher_number($voucher_type_id, $voucher_number);
?></strong></p>
<p><?php echo $current_voucher_type['name']; ?> Voucher Date :
<strong><?php echo $voucher_date; ?></strong></p>
<table border=1 cellpadding=6>
<thead>
diff --git a/system/application/views/voucher/index.php
b/system/application/views/voucher/index.php
index cb10ca6..5526dc7 100644
--- a/system/application/views/voucher/index.php
+++ b/system/application/views/voucher/index.php
@@ -23,7 +23,7 @@
echo "<tr>";
echo "<td>" . date_mysql_to_php_display($row->date) .
"</td>";
- echo "<td>" . anchor('voucher/view/' .
$current_voucher_type['label'] . "/" . $row->id,
voucher_number_prefix($row->type) . $row->number, array('title' =>
'View ' . $current_voucher_type['name'] . ' Voucher',
'class' => 'anchor-link-a')) . "</td>";
+ echo "<td>" . anchor('voucher/view/' .
$current_voucher_type['label'] . "/" . $row->id,
full_voucher_number($row->type, $row->number), array('title' => 'View
' . $current_voucher_type['name'] . ' Voucher', 'class' =>
'anchor-link-a')) . "</td>";
echo "<td>";
echo $this->Tag_model->show_voucher_tag($row->tag_id);
diff --git a/system/application/views/voucher/printpreview.php
b/system/application/views/voucher/printpreview.php
index 40aef25..2d8f4a6 100644
--- a/system/application/views/voucher/printpreview.php
+++ b/system/application/views/voucher/printpreview.php
@@ -11,7 +11,7 @@
<br />
<div id="print-voucher-type"><span
class="value"><?php echo $current_voucher_type['name']; ?>
Voucher</span></div>
<br />
- <div id="print-voucher-number"><?php echo
$current_voucher_type['name']; ?> Voucher Number : <span
class="value"><?php echo voucher_number_prefix($voucher_type_id) .
$voucher_number; ?></span></div>
+ <div id="print-voucher-number"><?php echo
$current_voucher_type['name']; ?> Voucher Number : <span
class="value"><?php echo full_voucher_number($voucher_type_id,
$voucher_number); ?></span></div>
<div id="print-voucher-number"><?php echo
$current_voucher_type['name']; ?> Voucher Date : <span
class="value"><?php echo $voucher_date; ?></span></div>
<br />
<table id="print-voucher-table">
diff --git a/system/application/views/voucher/view.php
b/system/application/views/voucher/view.php
index 7ab8c47..39ff524 100644
--- a/system/application/views/voucher/view.php
+++ b/system/application/views/voucher/view.php
@@ -1,4 +1,4 @@
-<p>Voucher Number : <span class="bold"><?php echo
voucher_number_prefix($voucher_type_id) . $cur_voucher->number; ?></span>
+<p>Voucher Number : <span class="bold"><?php echo
full_voucher_number($voucher_type_id, $cur_voucher->number); ?></span>
Voucher Date : <span class="bold"><?php echo
date_mysql_to_php_display($cur_voucher->date); ?></span>
</p>
commit 2fc374478ce71bd1af6bac6c12a9bc8a82e1cfba
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 31 15:35:18 2011 +0530
Updated Reports to use dynamic voucher type
- Ledger Statement
- 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 1b89ccc..afeec86 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -354,13 +354,16 @@ class Report extends Controller {
$ledgerst_q = $this->db->get();
foreach ($ledgerst_q->result() as $row)
{
+ /* Voucher Type */
+ $current_voucher_type = voucher_type_info($row->vtype);
+
$ledgerst[$counter][0] = date_mysql_to_php($row->vdate);
- $ledgerst[$counter][1] = voucher_number_prefix(n_to_v($row->vtype)) .
$row->vnumber;
+ $ledgerst[$counter][1] = voucher_number_prefix($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));
+ $ledgerst[$counter][3] = $current_voucher_type['name'];
if ($row->ldc == "D")
{
@@ -474,13 +477,16 @@ class Report extends Controller {
$ledgerst_q = $this->db->get();
foreach ($ledgerst_q->result() as $row)
{
+ /* Voucher Type */
+ $current_voucher_type = voucher_type_info($row->vtype);
+
$ledgerst[$counter][0] = date_mysql_to_php($row->vdate);
- $ledgerst[$counter][1] = voucher_number_prefix(n_to_v($row->vtype)) .
$row->vnumber;
+ $ledgerst[$counter][1] = voucher_number_prefix($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));
+ $ledgerst[$counter][3] = $current_voucher_type['name'];
if ($row->ldc == "D")
{
diff --git a/system/application/views/report/ledgerst.php
b/system/application/views/report/ledgerst.php
index 5c017a4..fd3115b 100644
--- a/system/application/views/report/ledgerst.php
+++ b/system/application/views/report/ledgerst.php
@@ -116,12 +116,14 @@
foreach ($ledgerst_q->result() as $row)
{
+ $current_voucher_type = voucher_type_info($row->vtype);
+
echo "<tr class=\"tr-" . $odd_even . "\">";
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 anchor('voucher/view/' . $current_voucher_type['label'] .
'/' . $row->vid, voucher_number_prefix($row->vtype) . $row->vnumber,
array('title' => 'View ' . ' Voucher', 'class' =>
'anchor-link-a'));
echo "</td>";
/* Getting opposite Ledger name */
@@ -130,7 +132,7 @@
echo "</td>";
echo "<td>";
- echo ucfirst(n_to_v($row->vtype));
+ echo $current_voucher_type['name'];
echo "</td>";
if ($row->ldc == "D")
{
diff --git a/system/application/views/report/reconciliation.php
b/system/application/views/report/reconciliation.php
index 7fed6eb..0cbb0a4 100644
--- a/system/application/views/report/reconciliation.php
+++ b/system/application/views/report/reconciliation.php
@@ -120,6 +120,8 @@
foreach ($ledgerst_q->result() as $row)
{
+ $current_voucher_type = voucher_type_info($row->vtype);
+
echo "<tr class=\"tr-" . $odd_even;
if ($row->lreconciliation)
echo " tr-reconciled";
@@ -128,7 +130,7 @@
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 anchor('voucher/view/' . $current_voucher_type['label'] .
'/' . $row->vid, voucher_number_prefix($row->vtype) . $row->vnumber,
array('title' => 'View ' . $current_voucher_type['name'] .
' Voucher', 'class' => 'anchor-link-a'));
echo "</td>";
/* Getting opposite Ledger name */
@@ -137,7 +139,7 @@
echo "</td>";
echo "<td>";
- echo ucfirst(n_to_v($row->vtype));
+ echo $current_voucher_type['name'];
echo "</td>";
if ($row->ldc == "D")
{
commit 4b5ebfa0021295a6c49035e773ecba45cecc1b57
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 31 14:50:00 2011 +0530
Updated Email and Print Voucher to use dynamic voucher type
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 6cfa189..061bdb6 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -984,12 +984,12 @@ class Voucher extends Controller {
if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id,
$voucher_type_id))
{
$this->messages->add('Invalid Voucher.', 'error');
- redirect('voucher/show/' . $voucher_type);
+ redirect('voucher/show/' . $current_voucher_type['label']);
return;
}
- $data['current_voucher_type'] = $current_voucher_type;
$data['voucher_type_id'] = $voucher_type_id;
+ $data['current_voucher_type'] = $current_voucher_type;
$data['voucher_number'] = $cur_voucher->number;
$data['voucher_date'] = date_mysql_to_php_display($cur_voucher->date);
$data['voucher_dr_total'] = $cur_voucher->dr_total;
@@ -1035,17 +1035,27 @@ class Voucher extends Controller {
return;
}
- $account = $this->Setting_model->get_current();
+ /* Voucher Type */
+ $voucher_type_id = voucher_type_name_to_id($voucher_type);
+ if ( ! $voucher_type_id)
+ {
+ $this->messages->add('Invalid Voucher type.', 'error');
+ redirect('voucher/show/all');
+ return;
+ } else {
+ $current_voucher_type = voucher_type_info($voucher_type_id);
+ }
/* Load current voucher details */
- if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id,
$voucher_type))
+ if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id,
$voucher_type_id))
{
- $this->messages->add('Invalid Voucher number.', 'error');
- redirect('voucher/show/' . $voucher_type);
+ $this->messages->add('Invalid Voucher.', 'error');
+ redirect('voucher/show/' . $current_voucher_type['label']);
return;
}
- $data['voucher_type'] = $voucher_type;
+ $data['voucher_type_id'] = $voucher_type_id;
+ $data['current_voucher_type'] = $current_voucher_type;
$data['voucher_number'] = $cur_voucher->number;
$data['voucher_date'] = date_mysql_to_php_display($cur_voucher->date);
$data['voucher_dr_total'] = $cur_voucher->dr_total;
@@ -1089,17 +1099,29 @@ class Voucher extends Controller {
return;
}
+ /* Voucher Type */
+ $voucher_type_id = voucher_type_name_to_id($voucher_type);
+ if ( ! $voucher_type_id)
+ {
+ $this->messages->add('Invalid Voucher type.', 'error');
+ redirect('voucher/show/all');
+ return;
+ } else {
+ $current_voucher_type = voucher_type_info($voucher_type_id);
+ }
+
$account_data = $this->Setting_model->get_current();
/* Load current voucher details */
- if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id,
$voucher_type))
+ if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id,
$voucher_type_id))
{
- $this->messages->add('Invalid Voucher number.', 'error');
- redirect('voucher/show/' . $voucher_type);
+ $this->messages->add('Invalid Voucher.', 'error');
+ redirect('voucher/show/' . $current_voucher_type['label']);
return;
}
- $data['voucher_type'] = $voucher_type;
+ $data['voucher_type_id'] = $voucher_type_id;
+ $data['current_voucher_type'] = $current_voucher_type;
$data['voucher_id'] = $voucher_id;
$data['voucher_number'] = $cur_voucher->number;
$data['email_to'] = array(
@@ -1126,7 +1148,8 @@ class Voucher extends Controller {
}
else
{
- $voucher_data['voucher_type'] = $voucher_type;
+ $voucher_data['voucher_type_id'] = $voucher_type_id;
+ $voucher_data['current_voucher_type'] = $current_voucher_type;
$voucher_data['voucher_number'] = $cur_voucher->number;
$voucher_data['voucher_date'] =
date_mysql_to_php_display($cur_voucher->date);
$voucher_data['voucher_dr_total'] = $cur_voucher->dr_total;
@@ -1168,22 +1191,22 @@ class Voucher extends Controller {
$config['smtp_user'] = $account_data->email_username;
$config['smtp_pass'] = $account_data->email_password;
} else {
- $data['error'] = 'Invalid account details.';
+ $data['error'] = 'Invalid account settings.';
}
$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->subject($current_voucher_type['name'] . ' Voucher No.
' . voucher_number_prefix($voucher_type_id) . $cur_voucher->number);
$this->email->message($message);
if ($this->email->send())
{
$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 . "]");
+ $this->logger->write_message("success", "Emailed " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $cur_voucher->number . " [id:" .
$voucher_id . "]");
} else {
$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->logger->write_message("error", "Error emailing " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $cur_voucher->number . " [id:" .
$voucher_id . "]");
}
$this->load->view('voucher/email', $data);
return;
diff --git a/system/application/views/voucher/email.php
b/system/application/views/voucher/email.php
index d9e8148..7ef13fc 100644
--- a/system/application/views/voucher/email.php
+++ b/system/application/views/voucher/email.php
@@ -36,9 +36,9 @@
echo "</div>";
}
- echo form_open('voucher/email/' . $voucher_type . "/" . $voucher_id);
+ echo form_open('voucher/email/' . $current_voucher_type['label'] .
"/" . $voucher_id);
- echo "Emailing " . ucfirst($voucher_type) . " Voucher No. " .
$voucher_number . "<br />";
+ echo "Emailing " . $current_voucher_type['name'] . " Voucher No.
" . $voucher_number . "<br />";
echo "<p>";
echo form_label('Email to', 'email_to');
diff --git a/system/application/views/voucher/emailpreview.php
b/system/application/views/voucher/emailpreview.php
index f925edd..87336bc 100644
--- a/system/application/views/voucher/emailpreview.php
+++ b/system/application/views/voucher/emailpreview.php
@@ -1,14 +1,14 @@
<!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>Print - <?php echo ucfirst($voucher_type); ?> Voucher Number <?php
echo $voucher_number; ?></title>
+<title>Email - <?php echo $current_voucher_type['name']; ?> Voucher
Number <?php echo $voucher_number; ?></title>
</head>
<body>
- <p><?php echo $this->config->item('account_name');
?></p>
+ <p><?php echo $this->config->item('account_name');
?></p>
<p><?php echo $this->config->item('account_address');
?></p>
- <p><strong><?php echo ucfirst($voucher_type); ?>
Voucher</strong></p>
- <p><?php echo ucfirst($voucher_type); ?> Voucher Number :
<strong><?php echo voucher_number_prefix($voucher_type) . $voucher_number;
?></strong></p>
- <p><?php echo ucfirst($voucher_type); ?> Voucher Date :
<strong><?php echo $voucher_date; ?></strong></p>
+ <p><strong><?php echo $current_voucher_type['name']; ?>
Voucher</strong></p>
+ <p><?php echo $current_voucher_type['name']; ?> Voucher Number :
<strong><?php echo voucher_number_prefix($voucher_type_id) . $voucher_number;
?></strong></p>
+ <p><?php echo $current_voucher_type['name']; ?> Voucher Date :
<strong><?php echo $voucher_date; ?></strong></p>
<table border=1 cellpadding=6>
<thead>
<tr><th align="left">Ledger A/C</th><th>Dr
Amount</th><th>Cr Amount</th></tr>
diff --git a/system/application/views/voucher/printpreview.php
b/system/application/views/voucher/printpreview.php
index 8b27448..40aef25 100644
--- a/system/application/views/voucher/printpreview.php
+++ b/system/application/views/voucher/printpreview.php
@@ -1,7 +1,7 @@
<!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>Print - <?php echo ucfirst($voucher_type); ?> Voucher Number <?php
echo $voucher_number; ?></title>
+<title>Print - <?php echo $current_voucher_type['name']; ?> Voucher
Number <?php echo $voucher_number; ?></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/printvoucher.css">
</head>
@@ -9,10 +9,10 @@
<div id="print-account-name"><span
class="value"><?php echo
$this->config->item('account_name'); ?></span></div>
<div id="print-account-address"><span
class="value"><?php echo
$this->config->item('account_address'); ?></span></div>
<br />
- <div id="print-voucher-type"><span
class="value"><?php echo ucfirst($voucher_type); ?>
Voucher</span></div>
+ <div id="print-voucher-type"><span
class="value"><?php echo $current_voucher_type['name']; ?>
Voucher</span></div>
<br />
- <div id="print-voucher-number"><?php echo ucfirst($voucher_type);
?> Voucher Number : <span class="value"><?php echo
voucher_number_prefix($voucher_type) . $voucher_number; ?></span></div>
- <div id="print-voucher-number"><?php echo ucfirst($voucher_type);
?> Voucher Date : <span class="value"><?php echo $voucher_date;
?></span></div>
+ <div id="print-voucher-number"><?php echo
$current_voucher_type['name']; ?> Voucher Number : <span
class="value"><?php echo voucher_number_prefix($voucher_type_id) .
$voucher_number; ?></span></div>
+ <div id="print-voucher-number"><?php echo
$current_voucher_type['name']; ?> Voucher Date : <span
class="value"><?php echo $voucher_date; ?></span></div>
<br />
<table id="print-voucher-table">
<thead>
commit f67ef865df6211602f86c5d87fe2a43a8007f8af
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 31 12:33:45 2011 +0530
Updated Download Voucher to use dynamic voucher types
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 72021f5..6cfa189 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -955,7 +955,7 @@ class Voucher extends Controller {
return;
}
- function download($voucher_type, $voucher_id = 0)
+ function download($voucher_type, $voucher_id)
{
$this->load->helper('download');
$this->load->model('Setting_model');
@@ -969,17 +969,27 @@ class Voucher extends Controller {
return;
}
- $account = $this->Setting_model->get_current();
+ /* Voucher Type */
+ $voucher_type_id = voucher_type_name_to_id($voucher_type);
+ if ( ! $voucher_type_id)
+ {
+ $this->messages->add('Invalid Voucher type.', 'error');
+ redirect('voucher/show/all');
+ return;
+ } else {
+ $current_voucher_type = voucher_type_info($voucher_type_id);
+ }
/* Load current voucher details */
- if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id,
$voucher_type))
+ if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id,
$voucher_type_id))
{
- $this->messages->add('Invalid Voucher number.', 'error');
+ $this->messages->add('Invalid Voucher.', 'error');
redirect('voucher/show/' . $voucher_type);
return;
}
- $data['voucher_type'] = $voucher_type;
+ $data['current_voucher_type'] = $current_voucher_type;
+ $data['voucher_type_id'] = $voucher_type_id;
$data['voucher_number'] = $cur_voucher->number;
$data['voucher_date'] = date_mysql_to_php_display($cur_voucher->date);
$data['voucher_dr_total'] = $cur_voucher->dr_total;
@@ -1006,7 +1016,7 @@ class Voucher extends Controller {
}
/* Download Voucher */
- $file_name = $voucher_type . '_voucher_' . $cur_voucher->number .
".html";
+ $file_name = $current_voucher_type['name'] . '_voucher_' .
$cur_voucher->number . ".html";
$download_data = $this->load->view('voucher/downloadpreview', $data,
TRUE);
force_download($file_name, $download_data);
return;
diff --git a/system/application/views/voucher/downloadpreview.php
b/system/application/views/voucher/downloadpreview.php
index 8ab7043..d59f587 100644
--- a/system/application/views/voucher/downloadpreview.php
+++ b/system/application/views/voucher/downloadpreview.php
@@ -1,7 +1,7 @@
<!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><?php echo ucfirst($voucher_type); ?> Voucher Number <?php echo
$voucher_number; ?></title>
+<title><?php $current_voucher_type['name']; ?> Voucher Number
<?php echo $voucher_number; ?></title>
<style type="text/css">
body {
@@ -63,10 +63,10 @@
<div id="print-account-name"><span
class="value"><?php echo
$this->config->item('account_name'); ?></span></div>
<div id="print-account-address"><span
class="value"><?php echo
$this->config->item('account_address'); ?></span></div>
<br />
- <div id="print-voucher-type"><span
class="value"><?php echo ucfirst($voucher_type); ?>
Voucher</span></div>
+ <div id="print-voucher-type"><span
class="value"><?php echo $current_voucher_type['name']; ?>
Voucher</span></div>
<br />
- <div id="print-voucher-number"><?php echo ucfirst($voucher_type);
?> Voucher Number : <span class="value"><?php echo
voucher_number_prefix($voucher_type) . $voucher_number; ?></span></div>
- <div id="print-voucher-number"><?php echo ucfirst($voucher_type);
?> Voucher Date : <span class="value"><?php echo $voucher_date;
?></span></div>
+ <div id="print-voucher-number"><?php echo
$current_voucher_type['name']; ?> Voucher Number : <span
class="value"><?php echo voucher_number_prefix($voucher_type_id) .
$voucher_number; ?></span></div>
+ <div id="print-voucher-number"><?php echo
$current_voucher_type['name']; ?> Voucher Date : <span
class="value"><?php echo $voucher_date; ?></span></div>
<br />
<table id="print-voucher-table">
<thead>
commit b9e9c85c6f67aab2bee3c40b1703f4554d336847
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 31 12:12:41 2011 +0530
Updated Edit Voucher to use dynamic voucher types
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 e65188d..72021f5 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -28,6 +28,8 @@ class Voucher extends Controller {
{
$tag_id = (int)$this->uri->segment(4);
$data['tag_id'] = $tag_id;
+ $tag_name = $this->Tag_model->tag_name($tag_id);
+ $this->template->set('page_title', 'Vouchers Tagged "' .
$tag_name . '"');
} else if ($voucher_type == 'all') {
$voucher_type_id = 0;
$this->template->set('page_title', 'All Vouchers');
@@ -139,15 +141,17 @@ class Voucher extends Controller {
if ($this->session->userdata('voucher_updated_show_action'))
{
$voucher_updated_id_temp =
$this->session->userdata('voucher_updated_id');
- $voucher_updated_type_temp =
$this->session->userdata('voucher_updated_type');
+ $voucher_updated_type_id_temp =
$this->session->userdata('voucher_updated_type_id');
+ $voucher_updated_type_label_temp =
$this->session->userdata('voucher_updated_type_label');
+ $voucher_updated_type_name_temp =
$this->session->userdata('voucher_updated_type_name');
$voucher_updated_number_temp =
$this->session->userdata('voucher_updated_number');
- $voucher_updated_message = 'Updated ' . ucfirst($voucher_updated_type_temp) .
' Voucher number ' . voucher_number_prefix($voucher_updated_type_temp) .
$voucher_updated_number_temp . ".";
+ $voucher_updated_message = 'Updated ' . $voucher_updated_type_name_temp .
' Voucher number ' . voucher_number_prefix($voucher_updated_type_id_temp) .
$voucher_updated_number_temp . ".";
$voucher_updated_message .= " You can [ ";
- $voucher_updated_message .= anchor('voucher/view/' .
strtolower($voucher_updated_type_temp) . "/" . $voucher_updated_id_temp,
'View', array('class' => 'anchor-link-a')) . " | ";
- $voucher_updated_message .= anchor('voucher/edit/' .
strtolower($voucher_updated_type_temp) . "/" . $voucher_updated_id_temp,
'Edit', array('class' => 'anchor-link-a')) . " | ";
- $voucher_updated_message .= anchor_popup('voucher/printpreview/' .
strtolower($voucher_updated_type_temp) . "/" . $voucher_updated_id_temp ,
'Print', array('class' => 'anchor-link-a', 'width'
=> '600', 'height' => '600')) . " | ";
- $voucher_updated_message .= anchor_popup('voucher/email/' .
strtolower($voucher_updated_type_temp) . "/" . $voucher_updated_id_temp,
'Email', array('class' => 'anchor-link-a', 'width'
=> '500', 'height' => '300')) . " | ";
- $voucher_updated_message .= anchor('voucher/download/' .
strtolower($voucher_updated_type_temp) . "/" . $voucher_updated_id_temp,
'Download', array('class' => 'anchor-link-a'));
+ $voucher_updated_message .= anchor('voucher/view/' .
$voucher_updated_type_label_temp . "/" . $voucher_updated_id_temp,
'View', array('class' => 'anchor-link-a')) . " | ";
+ $voucher_updated_message .= anchor('voucher/edit/' .
$voucher_updated_type_label_temp . "/" . $voucher_updated_id_temp,
'Edit', array('class' => 'anchor-link-a')) . " | ";
+ $voucher_updated_message .= anchor_popup('voucher/printpreview/' .
$voucher_updated_type_label_temp . "/" . $voucher_updated_id_temp ,
'Print', array('class' => 'anchor-link-a', 'width'
=> '600', 'height' => '600')) . " | ";
+ $voucher_updated_message .= anchor_popup('voucher/email/' .
$voucher_updated_type_label_temp . "/" . $voucher_updated_id_temp,
'Email', array('class' => 'anchor-link-a', 'width'
=> '500', 'height' => '300')) . " | ";
+ $voucher_updated_message .= anchor('voucher/download/' .
$voucher_updated_type_label_temp . "/" . $voucher_updated_id_temp,
'Download', array('class' => 'anchor-link-a'));
$voucher_updated_message .= " ] it.";
$this->messages->add($voucher_updated_message, 'success');
@@ -156,7 +160,9 @@ class Voucher extends Controller {
$this->session->unset_userdata('voucher_updated_show_action');
$this->session->unset_userdata('voucher_updated_id');
- $this->session->unset_userdata('voucher_updated_type');
+ $this->session->unset_userdata('voucher_updated_type_id');
+ $this->session->unset_userdata('voucher_updated_type_label');
+ $this->session->unset_userdata('voucher_updated_type_name');
$this->session->unset_userdata('voucher_updated_number');
$this->session->unset_userdata('voucher_updated_has_reconciliation');
}
@@ -487,7 +493,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$this->messages->add('Error adding Ledger A/C - ' . $data_ledger_id .
' to Voucher.', 'error');
- $this->logger->write_message("error", "Error adding " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " since failed inserting
voucher ledger items " . "[id:" . $data_ledger_id . "]");
+ $this->logger->write_message("error", "Error adding " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " since failed inserting
voucher ledger item " . "[id:" . $data_ledger_id . "]");
$this->template->load('template', 'voucher/add', $data);
return;
}
@@ -544,32 +550,24 @@ class Voucher extends Controller {
return;
}
- switch ($voucher_type)
+ /* Voucher Type */
+ $voucher_type_id = voucher_type_name_to_id($voucher_type);
+ if ( ! $voucher_type_id)
{
- case 'receipt' :
- $this->template->set('page_title', 'Edit Receipt Voucher');
- break;
- case 'payment' :
- $this->template->set('page_title', 'Edit Payment Voucher');
- break;
- case 'contra' :
- $this->template->set('page_title', 'Edit Contra Voucher');
- break;
- case 'journal' :
- $this->template->set('page_title', 'Edit Journal Voucher');
- break;
- default :
- $this->messages->add('Invalid Voucher type(5).', 'error');
+ $this->messages->add('Invalid Voucher type.', 'error');
redirect('voucher/show/all');
return;
- break;
+ } else {
+ $current_voucher_type = voucher_type_info($voucher_type_id);
}
+ $this->template->set('page_title', 'Edit ' .
$current_voucher_type['name'] . ' Voucher');
+
/* Load current voucher details */
- if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id,
$voucher_type))
+ if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id,
$voucher_type_id))
{
- $this->messages->add('Invalid Voucher number.', 'error');
- redirect('voucher/show/' . $voucher_type);
+ $this->messages->add('Invalid Voucher.', 'error');
+ redirect('voucher/show/' . $current_voucher_type['label']);
return;
}
@@ -595,8 +593,9 @@ class Voucher extends Controller {
'rows' => '4',
'value' => $cur_voucher->narration,
);
- $data['voucher_type'] = $voucher_type;
$data['voucher_id'] = $voucher_id;
+ $data['voucher_type_id'] = $voucher_type_id;
+ $data['current_voucher_type'] = $current_voucher_type;
$data['voucher_tag'] = $cur_voucher->tag_id;
$data['voucher_tags'] = $this->Tag_model->get_all_tags();
$data['has_reconciliation'] = FALSE;
@@ -701,7 +700,7 @@ class Voucher extends Controller {
} else {
/* Check for valid ledger type */
$valid_ledger = $valid_ledger_q->row();
- if ($voucher_type == 'receipt')
+ if ($current_voucher_type['bank_cash_ledger_restriction'] == '2')
{
if ($data_all_ledger_dc[$id] == 'D' && $valid_ledger->type ==
'B')
{
@@ -709,7 +708,7 @@ class Voucher extends Controller {
}
if ($valid_ledger->type != 'B')
$non_bank_cash_present = TRUE;
- } else if ($voucher_type == 'payment')
+ } else if ($current_voucher_type['bank_cash_ledger_restriction'] ==
'3')
{
if ($data_all_ledger_dc[$id] == 'C' && $valid_ledger->type ==
'B')
{
@@ -717,19 +716,19 @@ class Voucher extends Controller {
}
if ($valid_ledger->type != 'B')
$non_bank_cash_present = TRUE;
- } else if ($voucher_type == 'contra')
+ } else if ($current_voucher_type['bank_cash_ledger_restriction'] ==
'4')
{
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->messages->add('Invalid Ledger A/C. ' .
$current_voucher_type['name'] . ' 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')
+ } else if ($current_voucher_type['bank_cash_ledger_restriction'] ==
'5')
{
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->messages->add('Invalid Ledger A/C. ' .
$current_voucher_type['name'] . ' Vouchers cannot have Bank and Cash Ledgers
A/C\'s.', 'error');
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -753,7 +752,7 @@ class Voucher extends Controller {
return;
}
/* Check if atleast one Bank or Cash Ledger A/C is present */
- if ($voucher_type == 'receipt')
+ if ($current_voucher_type['bank_cash_ledger_restriction'] == '2')
{
if ( ! $bank_cash_present)
{
@@ -763,11 +762,11 @@ class Voucher extends Controller {
}
if ( ! $non_bank_cash_present)
{
- $this->messages->add('Use Contra Vouchers if it affects only Bank or Cash
A/C\'s.', 'error');
+ $this->messages->add('Need to Debit or Credit atleast one NON - Bank or
Cash A/C.', 'error');
$this->template->load('template', 'voucher/edit', $data);
return;
}
- } else if ($voucher_type == 'payment')
+ } else if ($current_voucher_type['bank_cash_ledger_restriction'] ==
'3')
{
if ( ! $bank_cash_present)
{
@@ -777,7 +776,7 @@ class Voucher extends Controller {
}
if ( ! $non_bank_cash_present)
{
- $this->messages->add('Use Contra Vouchers if it affects only Bank or Cash
A/C\'s.', 'error');
+ $this->messages->add('Need to Debit or Credit atleast one NON - Bank or
Cash A/C.', 'error');
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -788,14 +787,7 @@ 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_type = 0;
- switch ($voucher_type)
- {
- case "receipt": $data_type = 1; break;
- case "payment": $data_type = 2; break;
- case "contra": $data_type = 3; break;
- case "journal": $data_type = 4; break;
- }
+ $data_type = $voucher_type_id;
$data_date = date_php_to_mysql($data_date); // Converting date to MySQL
$data_has_reconciliation = $this->input->post('has_reconciliation',
TRUE);
@@ -810,7 +802,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 " .
voucher_number_prefix($voucher_type) . $data_number . " [id:" . $voucher_id .
"]");
+ $this->logger->write_message("error", "Error updating voucher
details for " . $current_voucher_type['name'] . " Voucher number "
. voucher_number_prefix($voucher_type_id) . $data_number . " [id:" . $voucher_id
. "]");
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -820,7 +812,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$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->logger->write_message("error", "Error deleting previous
voucher items for " . $current_voucher_type['name'] . " Voucher number
" . voucher_number_prefix($voucher_type_id) . $data_number . " [id:" .
$voucher_id . "]");
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -859,7 +851,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$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->logger->write_message("error", "Error adding Ledger A/C
item [id:" . $data_ledger_id . "] for " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " [id:" . $voucher_id .
"]");
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -874,7 +866,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 " .
voucher_number_prefix($voucher_type) . $data_number . " [id:" . $voucher_id .
"]");
+ $this->logger->write_message("error", "Error updating voucher
total for " . $current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " [id:" . $voucher_id .
"]");
$this->template->load('template', 'voucher/edit', $data);
return;
}
@@ -884,7 +876,9 @@ class Voucher extends Controller {
$this->session->set_userdata('voucher_updated_show_action', TRUE);
$this->session->set_userdata('voucher_updated_id', $voucher_id);
- $this->session->set_userdata('voucher_updated_type', $voucher_type);
+ $this->session->set_userdata('voucher_updated_type_id',
$voucher_type_id);
+ $this->session->set_userdata('voucher_updated_type_label',
$current_voucher_type['label']);
+ $this->session->set_userdata('voucher_updated_type_name',
$current_voucher_type['name']);
$this->session->set_userdata('voucher_updated_number', $data_number);
if ($data_has_reconciliation)
$this->session->set_userdata('voucher_updated_has_reconciliation',
TRUE);
@@ -892,9 +886,9 @@ class Voucher extends Controller {
$this->session->set_userdata('voucher_updated_has_reconciliation',
FALSE);
/* Showing success message in show() method since message is too long for storing it
in session */
- $this->logger->write_message("success", "Updated " .
ucfirst($voucher_type) . " Voucher number " .
voucher_number_prefix($voucher_type) . $data_number . " [id:" . $voucher_id .
"]");
+ $this->logger->write_message("success", "Updated " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " [id:" . $voucher_id .
"]");
- redirect('voucher/show/' . $voucher_type);
+ redirect('voucher/show/' . $current_voucher_type['label']);
return;
}
return;
@@ -943,7 +937,7 @@ class Voucher extends Controller {
$this->db->trans_rollback();
$this->messages->add('Error deleting Voucher - Ledger A/C\'s.',
'error');
$this->logger->write_message("error", "Error deleting ledger
entries for " . $current_voucher_type['name'] . " Voucher number "
. voucher_number_prefix($voucher_type_id) . $cur_voucher->number . " [id:" .
$voucher_id . "]");
- redirect('voucher/' . $current_voucher_type['label'] .
'/view/' . $voucher_id);
+ redirect('voucher/view/' . $current_voucher_type['label'] .
'/' . $voucher_id);
return;
}
if ( ! $this->db->delete('vouchers', array('id' =>
$voucher_id)))
@@ -951,7 +945,7 @@ 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 " . $current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $cur_voucher->number . " [id:" .
$voucher_id . "]");
- redirect('voucher/' . $current_voucher_type['label'] .
'/view/' . $voucher_id);
+ redirect('voucher/view/' . $current_voucher_type['label'] .
'/' . $voucher_id);
return;
}
$this->db->trans_complete();
diff --git a/system/application/views/voucher/edit.php
b/system/application/views/voucher/edit.php
index b9cb6a5..3df7039 100644
--- a/system/application/views/voucher/edit.php
+++ b/system/application/views/voucher/edit.php
@@ -1,7 +1,8 @@
<?php
- if ($voucher_type == "contra")
+ /* Add row ledger type */
+ if ($current_voucher_type['bank_cash_ledger_restriction'] == '4')
$add_type = "bankcash";
- else if ($voucher_type == "journal")
+ else if ($current_voucher_type['bank_cash_ledger_restriction'] == '5')
$add_type = "nobankcash";
else
$add_type = "all";
@@ -194,11 +195,11 @@ $(document).ready(function() {
</script>
<?php
- echo form_open('voucher/edit/' . $voucher_type . "/" . $voucher_id);
+ echo form_open('voucher/edit/' . $current_voucher_type['label'] .
"/" . $voucher_id);
echo "<p>";
echo form_label('Voucher Number', 'voucher_number');
echo " ";
- echo voucher_number_prefix($voucher_type) . form_input($voucher_number);
+ echo voucher_number_prefix($voucher_type_id) . form_input($voucher_number);
echo
" ";
echo "<span id=\"tooltip-target-1\">";
echo form_label('Voucher Date', 'voucher_date');
@@ -233,9 +234,9 @@ $(document).ready(function() {
echo "<td>" . form_dropdown_dc('ledger_dc[' . $i . ']',
isset($ledger_dc[$i]) ? $ledger_dc[$i] : "D") . "</td>";
- if ($voucher_type == "contra")
+ if ($current_voucher_type['bank_cash_ledger_restriction'] == '4')
echo "<td>" . form_input_ledger('ledger_id[' . $i .
']', isset($ledger_id[$i]) ? $ledger_id[$i] : 0, '', $type =
'bankcash') . "</td>";
- else if ($voucher_type == "journal")
+ else if ($current_voucher_type['bank_cash_ledger_restriction'] == '5')
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>";
@@ -250,11 +251,11 @@ $(document).ready(function() {
echo "</tr>";
}
- echo "<tr><td colspan=7></td></tr>";
+ echo "<tr><td colspan=7></td></tr>";
echo "<tr id=\"total\"><td
colspan=2><strong>Total</strong></td><td
id=\"dr-total\">0</td><td
id=\"cr-total\">0</td><td>" . img(array('src' =>
asset_url() . "images/icons/gear.png", 'border' => '0',
'alt' => 'Recalculate Total', 'class' =>
'recalculate', 'title' => 'Recalculate Total')) .
"</td><td></td><td></td></tr>";
-
echo "<tr id=\"difference\"><td
colspan=2><strong>Difference</strong></td><td
id=\"dr-diff\"></td><td
id=\"cr-diff\"></td><td></td><td></td><td></td></tr>";
+
echo "</table>";
echo "<p>";
@@ -274,9 +275,9 @@ $(document).ready(function() {
echo "<p>";
echo form_submit('submit', 'Update');
echo " ";
- echo anchor('voucher/edit/' . $voucher_type . "/" . $voucher_id,
'Reload', array('title' => 'Reload ' . ucfirst($voucher_type) .
' Voucher Original Data'));
+ echo anchor('voucher/edit/' . $current_voucher_type['label'] .
"/" . $voucher_id, 'Reload', array('title' => 'Reload
' . $current_voucher_type['name'] . ' Voucher Original Data'));
echo " | ";
- echo anchor('voucher/show/' . $voucher_type, 'Back',
array('title' => 'Back to ' . ucfirst($voucher_type) . '
Vouchers'));
+ echo anchor('voucher/show/' . $current_voucher_type['label'],
'Back', array('title' => 'Back to ' .
$current_voucher_type['name'] . ' Vouchers'));
echo "</p>";
echo form_close();
commit 1057a4dec779ad3977bb29e91c291f2936c998d5
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sun Jan 30 19:36:46 2011 +0530
Updated Add and Delete Voucher to dynamic voucher types
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 352274d..e65188d 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -114,20 +114,24 @@ class Voucher extends Controller {
if ($this->session->userdata('voucher_added_show_action'))
{
$voucher_added_id_temp = $this->session->userdata('voucher_added_id');
- $voucher_added_type_temp =
$this->session->userdata('voucher_added_type');
+ $voucher_added_type_id_temp =
$this->session->userdata('voucher_added_type_id');
+ $voucher_added_type_label_temp =
$this->session->userdata('voucher_added_type_label');
+ $voucher_added_type_name_temp =
$this->session->userdata('voucher_added_type_name');
$voucher_added_number_temp =
$this->session->userdata('voucher_added_number');
- $voucher_added_message = 'Added ' . ucfirst($voucher_added_type_temp) . '
Voucher number ' . voucher_number_prefix($voucher_added_type_temp) .
$voucher_added_number_temp . ".";
+ $voucher_added_message = 'Added ' . $voucher_added_type_name_temp . '
Voucher number ' . voucher_number_prefix($voucher_added_type_id_temp) .
$voucher_added_number_temp . ".";
$voucher_added_message .= " You can [ ";
- $voucher_added_message .= anchor('voucher/view/' .
strtolower($voucher_added_type_temp) . "/" . $voucher_added_id_temp,
'View', array('class' => 'anchor-link-a')) . " | ";
- $voucher_added_message .= anchor('voucher/edit/' .
strtolower($voucher_added_type_temp) . "/" . $voucher_added_id_temp,
'Edit', array('class' => 'anchor-link-a')) . " | ";
- $voucher_added_message .= anchor_popup('voucher/printpreview/' .
strtolower($voucher_added_type_temp) . "/" . $voucher_added_id_temp ,
'Print', array('class' => 'anchor-link-a', 'width'
=> '600', 'height' => '600')) . " | ";
- $voucher_added_message .= anchor_popup('voucher/email/' .
strtolower($voucher_added_type_temp) . "/" . $voucher_added_id_temp,
'Email', array('class' => 'anchor-link-a', 'width'
=> '500', 'height' => '300')) . " | ";
- $voucher_added_message .= anchor('voucher/download/' .
strtolower($voucher_added_type_temp) . "/" . $voucher_added_id_temp,
'Download', array('class' => 'anchor-link-a'));
+ $voucher_added_message .= anchor('voucher/view/' .
$voucher_added_type_label_temp . "/" . $voucher_added_id_temp, 'View',
array('class' => 'anchor-link-a')) . " | ";
+ $voucher_added_message .= anchor('voucher/edit/' .
$voucher_added_type_label_temp . "/" . $voucher_added_id_temp, 'Edit',
array('class' => 'anchor-link-a')) . " | ";
+ $voucher_added_message .= anchor_popup('voucher/printpreview/' .
$voucher_added_type_label_temp . "/" . $voucher_added_id_temp , 'Print',
array('class' => 'anchor-link-a', 'width' => '600',
'height' => '600')) . " | ";
+ $voucher_added_message .= anchor_popup('voucher/email/' .
$voucher_added_type_label_temp . "/" . $voucher_added_id_temp, 'Email',
array('class' => 'anchor-link-a', 'width' => '500',
'height' => '300')) . " | ";
+ $voucher_added_message .= anchor('voucher/download/' .
$voucher_added_type_label_temp . "/" . $voucher_added_id_temp,
'Download', array('class' => 'anchor-link-a'));
$voucher_added_message .= " ] it.";
$this->messages->add($voucher_added_message, 'success');
$this->session->unset_userdata('voucher_added_show_action');
$this->session->unset_userdata('voucher_added_id');
- $this->session->unset_userdata('voucher_added_type');
+ $this->session->unset_userdata('voucher_added_type_id');
+ $this->session->unset_userdata('voucher_added_type_label');
+ $this->session->unset_userdata('voucher_added_type_name');
$this->session->unset_userdata('voucher_added_number');
}
@@ -166,32 +170,24 @@ class Voucher extends Controller {
function view($voucher_type, $voucher_id = 0)
{
- switch ($voucher_type)
+ /* Voucher Type */
+ $voucher_type_id = voucher_type_name_to_id($voucher_type);
+ if ( ! $voucher_type_id)
{
- case 'receipt' :
- $this->template->set('page_title', 'View Receipt Voucher');
- break;
- case 'payment' :
- $this->template->set('page_title', 'View Payment Voucher');
- break;
- case 'contra' :
- $this->template->set('page_title', 'View Contra Voucher');
- break;
- case 'journal' :
- $this->template->set('page_title', 'View Journal Voucher');
- break;
- default :
- $this->messages->add('Invalid Voucher type(3).', 'error');
+ $this->messages->add('Invalid Voucher type.', 'error');
redirect('voucher/show/all');
return;
- break;
+ } else {
+ $current_voucher_type = voucher_type_info($voucher_type_id);
}
+ $this->template->set('page_title', 'View ' .
$current_voucher_type['name'] . ' Voucher');
+
/* Load current voucher details */
- if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id,
$voucher_type))
+ if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id,
$voucher_type_id))
{
- $this->messages->add('Invalid Voucher number.', 'error');
- redirect('voucher/show/' . $voucher_type);
+ $this->messages->add('Invalid Voucher.', 'error');
+ redirect('voucher/show/' . $current_voucher_type['label']);
return;
}
/* Load current voucher details */
@@ -203,7 +199,8 @@ class Voucher extends Controller {
}
$data['cur_voucher'] = $cur_voucher;
$data['cur_voucher_ledgers'] = $cur_voucher_ledgers;
- $data['voucher_type'] = $voucher_type;
+ $data['voucher_type_id'] = $voucher_type_id;
+ $data['current_voucher_type'] = $current_voucher_type;
$this->template->load('template', 'voucher/view', $data);
return;
}
@@ -226,27 +223,19 @@ class Voucher extends Controller {
return;
}
- switch ($voucher_type)
+ /* Voucher Type */
+ $voucher_type_id = voucher_type_name_to_id($voucher_type);
+ if ( ! $voucher_type_id)
{
- case 'receipt' :
- $this->template->set('page_title', 'New Receipt Voucher');
- break;
- case 'payment' :
- $this->template->set('page_title', 'New Payment Voucher');
- break;
- case 'contra' :
- $this->template->set('page_title', 'New Contra Voucher');
- break;
- case 'journal' :
- $this->template->set('page_title', 'New Journal Voucher');
- break;
- default :
- $this->messages->add('Invalid Voucher type(4).', 'error');
+ $this->messages->add('Invalid Voucher type.', 'error');
redirect('voucher/show/all');
return;
- break;
+ } else {
+ $current_voucher_type = voucher_type_info($voucher_type_id);
}
+ $this->template->set('page_title', 'New ' .
$current_voucher_type['name'] . ' Voucher');
+
/* Form fields */
$data['voucher_number'] = array(
'name' => 'voucher_number',
@@ -269,12 +258,13 @@ class Voucher extends Controller {
'rows' => '4',
'value' => '',
);
- $data['voucher_type'] = $voucher_type;
+ $data['voucher_type_id'] = $voucher_type_id;
+ $data['current_voucher_type'] = $current_voucher_type;
$data['voucher_tags'] = $this->Tag_model->get_all_tags();
$data['voucher_tag'] = 0;
/* Form validations */
- $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_number', 'Voucher
Number', 'trim|is_natural_no_zero|uniquevoucherno[' . $voucher_type_id .
']');
$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');
@@ -349,7 +339,7 @@ class Voucher extends Controller {
} else {
/* Check for valid ledger type */
$valid_ledger = $valid_ledger_q->row();
- if ($voucher_type == 'receipt')
+ if ($current_voucher_type['bank_cash_ledger_restriction'] == '2')
{
if ($data_all_ledger_dc[$id] == 'D' && $valid_ledger->type ==
'B')
{
@@ -357,7 +347,7 @@ class Voucher extends Controller {
}
if ($valid_ledger->type != 'B')
$non_bank_cash_present = TRUE;
- } else if ($voucher_type == 'payment')
+ } else if ($current_voucher_type['bank_cash_ledger_restriction'] ==
'3')
{
if ($data_all_ledger_dc[$id] == 'C' && $valid_ledger->type ==
'B')
{
@@ -365,19 +355,19 @@ class Voucher extends Controller {
}
if ($valid_ledger->type != 'B')
$non_bank_cash_present = TRUE;
- } else if ($voucher_type == 'contra')
+ } else if ($current_voucher_type['bank_cash_ledger_restriction'] ==
'4')
{
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->messages->add('Invalid Ledger A/C. ' .
$current_voucher_type['name'] . ' 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')
+ } else if ($current_voucher_type['bank_cash_ledger_restriction'] ==
'5')
{
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->messages->add('Invalid Ledger A/C. ' .
$current_voucher_type['name'] . ' Vouchers cannot have Bank and Cash Ledgers
A/C\'s.', 'error');
$this->template->load('template', 'voucher/add', $data);
return;
}
@@ -402,7 +392,7 @@ class Voucher extends Controller {
return;
}
/* Check if atleast one Bank or Cash Ledger A/C is present */
- if ($voucher_type == 'receipt')
+ if ($current_voucher_type['bank_cash_ledger_restriction'] == '2')
{
if ( ! $bank_cash_present)
{
@@ -412,11 +402,11 @@ class Voucher extends Controller {
}
if ( ! $non_bank_cash_present)
{
- $this->messages->add('Use Contra Vouchers if it affects only Bank or Cash
A/C\'s.', 'error');
+ $this->messages->add('Need to Debit or Credit atleast one NON - Bank or
Cash A/C.', 'error');
$this->template->load('template', 'voucher/add', $data);
return;
}
- } else if ($voucher_type == 'payment')
+ } else if ($current_voucher_type['bank_cash_ledger_restriction'] ==
'3')
{
if ( ! $bank_cash_present)
{
@@ -426,7 +416,7 @@ class Voucher extends Controller {
}
if ( ! $non_bank_cash_present)
{
- $this->messages->add('Use Contra Vouchers if it affects only Bank or Cash
A/C\'s.', 'error');
+ $this->messages->add('Need to Debit or Credit atleast one NON - Bank or
Cash A/C.', 'error');
$this->template->load('template', 'voucher/add', $data);
return;
}
@@ -441,14 +431,7 @@ 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_type = 0;
- switch ($voucher_type)
- {
- case "receipt": $data_type = 1; break;
- case "payment": $data_type = 2; break;
- case "contra": $data_type = 3; break;
- case "journal": $data_type = 4; break;
- }
+ $data_type = $voucher_type_id;
$data_date = date_php_to_mysql($data_date); // Converting date to MySQL
$voucher_id = NULL;
@@ -464,7 +447,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$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->logger->write_message("error", "Error adding " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " since failed inserting
voucher");
$this->template->load('template', 'voucher/add', $data);
return;
} else {
@@ -504,7 +487,7 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$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->logger->write_message("error", "Error adding " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " since failed inserting
voucher ledger items " . "[id:" . $data_ledger_id . "]");
$this->template->load('template', 'voucher/add', $data);
return;
}
@@ -519,7 +502,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 " .
voucher_number_prefix($voucher_type) . $data_number . " since failed updating debit
and credit total");
+ $this->logger->write_message("error", "Error adding " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " since failed updating
debit and credit total");
$this->template->load('template', 'voucher/add', $data);
return;
}
@@ -529,12 +512,14 @@ class Voucher extends Controller {
$this->session->set_userdata('voucher_added_show_action', TRUE);
$this->session->set_userdata('voucher_added_id', $voucher_id);
- $this->session->set_userdata('voucher_added_type', $voucher_type);
+ $this->session->set_userdata('voucher_added_type_id',
$voucher_type_id);
+ $this->session->set_userdata('voucher_added_type_label',
$current_voucher_type['label']);
+ $this->session->set_userdata('voucher_added_type_name',
$current_voucher_type['name']);
$this->session->set_userdata('voucher_added_number', $data_number);
/* Showing success message in show() method since message is too long for storing it
in session */
- $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->logger->write_message("success", "Added " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $data_number . " [id:" . $voucher_id .
"]");
+ redirect('voucher/show/' . $current_voucher_type['label']);
$this->template->load('template', 'voucher/add', $data);
return;
}
@@ -933,11 +918,22 @@ class Voucher extends Controller {
return;
}
+ /* Voucher Type */
+ $voucher_type_id = voucher_type_name_to_id($voucher_type);
+ if ( ! $voucher_type_id)
+ {
+ $this->messages->add('Invalid Voucher type.', 'error');
+ redirect('voucher/show/all');
+ return;
+ } else {
+ $current_voucher_type = voucher_type_info($voucher_type_id);
+ }
+
/* Load current voucher details */
- if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id,
$voucher_type))
+ if ( ! $cur_voucher = $this->Voucher_model->get_voucher($voucher_id,
$voucher_type_id))
{
- $this->messages->add('Invalid Voucher number.', 'error');
- redirect('voucher/show/' . $voucher_type);
+ $this->messages->add('Invalid Voucher.', 'error');
+ redirect('voucher/show/' . $current_voucher_type['label']);
return;
}
@@ -946,22 +942,22 @@ class Voucher extends Controller {
{
$this->db->trans_rollback();
$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);
+ $this->logger->write_message("error", "Error deleting ledger
entries for " . $current_voucher_type['name'] . " Voucher number "
. voucher_number_prefix($voucher_type_id) . $cur_voucher->number . " [id:" .
$voucher_id . "]");
+ redirect('voucher/' . $current_voucher_type['label'] .
'/view/' . $voucher_id);
return;
}
if ( ! $this->db->delete('vouchers', array('id' =>
$voucher_id)))
{
$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 " .
voucher_number_prefix($voucher_type) . $cur_voucher->number . " [id:" .
$voucher_id . "]");
- redirect('voucher/' . $voucher_type . '/' . $voucher_id);
+ $this->logger->write_message("error", "Error deleting Voucher
entry for " . $current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $cur_voucher->number . " [id:" .
$voucher_id . "]");
+ redirect('voucher/' . $current_voucher_type['label'] .
'/view/' . $voucher_id);
return;
}
$this->db->trans_complete();
- $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);
+ $this->messages->add('Deleted ' . $current_voucher_type['name'] .
' Voucher.', 'success');
+ $this->logger->write_message("success", "Deleted " .
$current_voucher_type['name'] . " Voucher number " .
voucher_number_prefix($voucher_type_id) . $cur_voucher->number . " [id:" .
$voucher_id . "]");
+ redirect('voucher/show/' . $current_voucher_type['label']);
return;
}
diff --git a/system/application/models/voucher_model.php
b/system/application/models/voucher_model.php
index 56d7ee8..6381145 100644
--- a/system/application/models/voucher_model.php
+++ b/system/application/models/voucher_model.php
@@ -22,10 +22,9 @@ class Voucher_model extends Model {
}
}
- function get_voucher($voucher_id, $type_string)
+ function get_voucher($voucher_id, $voucher_type_id)
{
- $type_number = v_to_n($type_string);
- $this->db->from('vouchers')->where('id',
$voucher_id)->where('type', $type_number)->limit(1);
+ $this->db->from('vouchers')->where('id',
$voucher_id)->where('type', $voucher_type_id)->limit(1);
$voucher_q = $this->db->get();
return $voucher_q->row();
}
diff --git a/system/application/views/voucher/add.php
b/system/application/views/voucher/add.php
index 8fb8493..93aa5bc 100644
--- a/system/application/views/voucher/add.php
+++ b/system/application/views/voucher/add.php
@@ -1,7 +1,8 @@
<?php
- if ($voucher_type == "contra")
+ /* Add row ledger type */
+ if ($current_voucher_type['bank_cash_ledger_restriction'] == '4')
$add_type = "bankcash";
- else if ($voucher_type == "journal")
+ else if ($current_voucher_type['bank_cash_ledger_restriction'] == '5')
$add_type = "nobankcash";
else
$add_type = "all";
@@ -194,12 +195,12 @@ $(document).ready(function() {
</script>
<?php
- echo form_open('voucher/add/' . $voucher_type);
+ echo form_open('voucher/add/' . $current_voucher_type['label']);
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 voucher_number_prefix($voucher_type_id) . form_input($voucher_number);
echo "</span>";
echo "<span id=\"tooltip-content-1\">Leave Voucher Number empty for
auto numbering</span>";
echo
" ";
@@ -236,9 +237,9 @@ $(document).ready(function() {
echo "<td>" . form_dropdown_dc('ledger_dc[' . $i . ']',
isset($ledger_dc[$i]) ? $ledger_dc[$i] : "D") . "</td>";
- if ($voucher_type == "contra")
+ if ($current_voucher_type['bank_cash_ledger_restriction'] == '4')
echo "<td>" . form_input_ledger('ledger_id[' . $i .
']', isset($ledger_id[$i]) ? $ledger_id[$i] : 0, '', $type =
'bankcash') . "</td>";
- else if ($voucher_type == "journal")
+ else if ($current_voucher_type['bank_cash_ledger_restriction'] == '5')
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>";
@@ -275,7 +276,7 @@ $(document).ready(function() {
echo "<p>";
echo form_submit('submit', 'Create');
echo " ";
- echo anchor('voucher/show/' . $voucher_type, 'Back',
array('title' => 'Back to ' . ucfirst($voucher_type) . '
Vouchers'));
+ echo anchor('voucher/show/' . $current_voucher_type['label'],
'Back', array('title' => 'Back to ' .
$current_voucher_type['name'] . ' Vouchers'));
echo "</p>";
echo form_close();
diff --git a/system/application/views/voucher/view.php
b/system/application/views/voucher/view.php
index 7d865c1..7ab8c47 100644
--- a/system/application/views/voucher/view.php
+++ b/system/application/views/voucher/view.php
@@ -1,4 +1,4 @@
-<p>Voucher Number : <span class="bold"><?php echo
voucher_number_prefix($voucher_type) . $cur_voucher->number; ?></span>
+<p>Voucher Number : <span class="bold"><?php echo
voucher_number_prefix($voucher_type_id) . $cur_voucher->number; ?></span>
Voucher Date : <span class="bold"><?php echo
date_mysql_to_php_display($cur_voucher->date); ?></span>
</p>
@@ -50,15 +50,15 @@ else
?>
</p>
<?php
- echo anchor('voucher/show/' . $voucher_type, 'Back',
array('title' => 'Back to ' . ucfirst($voucher_type) . '
Vouchers'));
+ echo anchor('voucher/show/' . $current_voucher_type['label'],
'Back', array('title' => 'Back to ' .
$current_voucher_type['name'] . ' Vouchers'));
echo " | ";
- echo anchor('voucher/edit/' . $voucher_type . "/" .
$cur_voucher->id, 'Edit', array('title' => 'Edit ' .
ucfirst($voucher_type) . ' Voucher'));
+ echo anchor('voucher/edit/' . $current_voucher_type['label'] .
"/" . $cur_voucher->id, 'Edit', array('title' => 'Edit
' . $current_voucher_type['name'] . ' Voucher'));
echo " | ";
- echo anchor('voucher/delete/' . $voucher_type . "/" .
$cur_voucher->id, 'Delete', array('class' =>
"confirmClick", 'title' => "Delete voucher",
'title' => 'Delete this ' . ucfirst($voucher_type) . '
Voucher'));
+ echo anchor('voucher/delete/' . $current_voucher_type['label'] .
"/" . $cur_voucher->id, 'Delete', array('class' =>
"confirmClick", 'title' => "Delete voucher",
'title' => 'Delete this ' . $current_voucher_type['name'] .
' Voucher'));
echo " | ";
- echo anchor_popup('voucher/printpreview/' . $voucher_type . "/" .
$cur_voucher->id, 'Print', array('title' => 'Print this ' .
ucfirst($voucher_type) . ' Voucher', 'width' => '600',
'height' => '600'));
+ echo anchor_popup('voucher/printpreview/' .
$current_voucher_type['label'] . "/" . $cur_voucher->id,
'Print', array('title' => 'Print this ' .
$current_voucher_type['name'] . ' Voucher', 'width' =>
'600', 'height' => '600'));
echo " | ";
- echo anchor_popup('voucher/email/' . $voucher_type . "/" .
$cur_voucher->id, 'Email', array('title' => 'Email this ' .
ucfirst($voucher_type) . ' Voucher', 'width' => '400',
'height' => '200'));
+ echo anchor_popup('voucher/email/' . $current_voucher_type['label'] .
"/" . $cur_voucher->id, 'Email', array('title' =>
'Email this ' . $current_voucher_type['name'] . ' Voucher',
'width' => '400', 'height' => '200'));
echo " | ";
- echo anchor('voucher/download/' . $voucher_type . "/" .
$cur_voucher->id, 'Download', array('title' => "Download
voucher", 'title' => 'Download this ' . ucfirst($voucher_type) .
' Voucher'));
+ echo anchor('voucher/download/' . $current_voucher_type['label'] .
"/" . $cur_voucher->id, 'Download', array('title' =>
"Download voucher", 'title' => 'Download this ' .
$current_voucher_type['name'] . ' Voucher'));
commit c5c363afc733db6aa5bcca2e1ef1e0c6ee796dac
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Sat Jan 29 16:50:29 2011 +0530
Added basic structure of dynamic voucher types
- Created database table for voucher_types
- Add helper methods to get the voucher types
- Adding all the voucher types on startup to the config
- Updated Voucher show action to use dynamic voucher types
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/db-update.txt b/db-update.txt
index 2e193fc..a939c6d 100644
--- a/db-update.txt
+++ b/db-update.txt
@@ -1,3 +1,19 @@
+//--------------------------------- VERSION 3 ----------------------------------
+
+CREATE TABLE IF NOT EXISTS voucher_types (
+ id int(5) NOT NULL,
+ label varchar(15) NOT NULL,
+ name varchar(100) NOT NULL,
+ description varchar(255) NOT NULL,
+ base_type int(2) NOT NULL,
+ numbering int(2) NOT NULL,
+ prefix varchar(10) NOT NULL,
+ suffix varchar(10) NOT NULL,
+ zero_padding int(2) NOT NULL,
+ bank_cash_ledger_restriction int(2) NOT NULL,
+ PRIMARY KEY (id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
//--------------------------------- VERSION 2 ----------------------------------
ALTER TABLE voucher_items ADD reconciliation_date DATETIME NULL;
diff --git a/system/application/controllers/voucher.php
b/system/application/controllers/voucher.php
index 93523ef..352274d 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -20,53 +20,31 @@ class Voucher extends Controller {
function show($voucher_type)
{
$this->load->model('Tag_model');
+
$data['tag_id'] = 0;
- if ($voucher_type == "tag")
+ $voucher_type_id = 0;
+
+ if ($voucher_type == 'tag')
{
$tag_id = (int)$this->uri->segment(4);
$data['tag_id'] = $tag_id;
- }
-
- switch ($voucher_type)
- {
- case 'all' :
+ } else if ($voucher_type == 'all') {
+ $voucher_type_id = 0;
$this->template->set('page_title', 'All Vouchers');
- $data['voucher_type'] = "";
- break;
- case 'receipt' :
- $this->template->set('page_title', 'Receipt Vouchers');
- $this->template->set('nav_links', array('voucher/add/receipt'
=> 'New Receipt Voucher'));
- $data['voucher_type'] = "receipt";
- break;
- case 'payment' :
- $this->template->set('page_title', 'Payment Vouchers');
- $this->template->set('nav_links', array('voucher/add/payment'
=> 'New Payment Voucher'));
- $data['voucher_type'] = "payment";
- break;
- case 'contra' :
- $this->template->set('page_title', 'Contra Vouchers');
- $this->template->set('nav_links', array('voucher/add/contra'
=> 'New Contra Voucher'));
- $data['voucher_type'] = "contra";
- break;
- case 'journal' :
- $this->template->set('page_title', 'Journal Vouchers');
- $this->template->set('nav_links', array('voucher/add/journal'
=> 'New Journal Voucher'));
- $data['voucher_type'] = "journal";
- break;
- case 'tag' :
- $tag_name = $this->Tag_model->tag_name($tag_id);
- $this->template->set('page_title', 'Vouchers Tagged "' .
$tag_name . '"');
- $data['voucher_type'] = "";
- break;
- default :
- /* TODO $this->messages->add('Invalid Voucher type(1).',
'error'); */
- redirect('voucher/show/all');
- return;
- break;
+ } else {
+ $voucher_type_id = voucher_type_name_to_id($voucher_type);
+ if ( ! $voucher_type_id)
+ {
+ $this->messages->add('Invalid Voucher type specified. Showing all
Vouchers.', 'error');
+ redirect('voucher/show/all');
+ return;
+ } else {
+ $current_voucher_type = voucher_type_info($voucher_type_id);
+ $this->template->set('page_title',
$current_voucher_type['name'] . ' Vouchers');
+ $this->template->set('nav_links', array('voucher/add/' .
$current_voucher_type['label'] => 'New ' .
$current_voucher_type['name'] . ' Voucher'));
+ }
}
- $voucher_type_int = v_to_n($voucher_type);
-
$voucher_q = NULL;
/* Pagination setup */
@@ -82,12 +60,15 @@ class Voucher extends Controller {
$page_count = "0";
/* Pagination configuration */
- if ($voucher_type == "tag")
+ if ($voucher_type == 'tag')
{
- $config['base_url'] = site_url('voucher/show/' . $voucher_type.
"/" . $tag_id);
+ $config['base_url'] = site_url('voucher/show/tag' . $tag_id);
$config['uri_segment'] = 5;
+ } else if ($voucher_type == 'all') {
+ $config['base_url'] = site_url('voucher/show/all');
+ $config['uri_segment'] = 4;
} else {
- $config['base_url'] = site_url('voucher/show/' . $voucher_type);
+ $config['base_url'] = site_url('voucher/show/' .
$current_voucher_type['label']);
$config['uri_segment'] = 4;
}
$pagination_counter = $this->config->item('row_count');
@@ -112,19 +93,14 @@ class Voucher extends Controller {
$config['last_tag_open'] = '<li class="last">';
$config['last_tag_close'] = '</li>';
- if (($voucher_type_int < 0) || ($voucher_type_int > 4))
- {
- $this->messages->add('Invalid Voucher type(2).', 'error');
- redirect('voucher/show/all');
- return;
- } else if ($voucher_type == "tag") {
+ if ($voucher_type == "tag") {
$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) {
- $this->db->from('vouchers')->where('type',
$voucher_type_int)->order_by('date',
'desc')->order_by('number',
'desc')->limit($pagination_counter, $page_count);
+ } else if ($voucher_type_id > 0) {
+ $this->db->from('vouchers')->where('type',
$voucher_type_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('type',
$voucher_type_int)->get()->num_rows();
+ $config['total_rows'] =
$this->db->from('vouchers')->where('type',
$voucher_type_id)->get()->num_rows();
} else {
$this->db->from('vouchers')->order_by('date',
'desc')->order_by('number',
'desc')->limit($pagination_counter, $page_count);
$voucher_q = $this->db->get();
@@ -181,53 +157,7 @@ class Voucher extends Controller {
$this->session->unset_userdata('voucher_updated_has_reconciliation');
}
- $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>DR Amount</th><th>CR
Amount</th><th></th></tr></thead>";
- $html .= "<tbody>";
-
- $odd_even = "odd";
- foreach ($voucher_q->result() as $row)
- {
- $html_voucher_type = n_to_v($row->type);
-
- /* Showing the credit ledger name for payment and debit for other voucher types */
- $ledger_type = ($row->type == 2) ? "C" : "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',
$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();
-
- $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>";
-
- $html .= "<td>";
- $html .= $this->Tag_model->show_voucher_tag($row->tag_id);
- $html .= $this->Ledger_model->get_voucher_name($row->id, $row->type);
- $html .= "</td>";
-
- $html .= "<td>" . ucfirst($html_voucher_type) .
"</td>";
- $html .= "<td>" . $row->dr_total . "</td>";
- $html .= "<td>" . $row->cr_total . "</td>";
-
- $html .= "<td>" . anchor('voucher/edit/' .
strtolower($html_voucher_type) . "/" . $row->id , "Edit",
array('title' => 'Edit ' . ucfirst($html_voucher_type) . '
Voucher', 'class' => 'red-link')) . " ";
-
- $html .= " " . anchor('voucher/delete/' .
strtolower($html_voucher_type) . "/" . $row->id , img(array('src'
=> asset_url() . "images/icons/delete.png", 'border' =>
'0', 'alt' => 'Delete ' . ucfirst($html_voucher_type) . '
Voucher', 'class' => "confirmClick", 'title' =>
"Delete voucher")), array('title' => 'Delete ' .
ucfirst($html_voucher_type) . ' Voucher')) . " ";
-
- $html .= " " . anchor_popup('voucher/printpreview/' .
strtolower($html_voucher_type) . "/" . $row->id , img(array('src'
=> asset_url() . "images/icons/print.png", 'border' =>
'0', 'alt' => 'Print ' . ucfirst($html_voucher_type) . '
Voucher')), array('title' => 'Print ' . ucfirst($html_voucher_type)
. ' Voucher', 'width' => '600', 'height' =>
'600')) . " ";
-
- $html .= " " . anchor_popup('voucher/email/' .
strtolower($html_voucher_type) . "/" . $row->id , img(array('src'
=> asset_url() . "images/icons/email.png", 'border' =>
'0', 'alt' => 'Email ' . ucfirst($html_voucher_type) . '
Voucher')), array('title' => 'Email ' . ucfirst($html_voucher_type)
. ' Voucher', 'width' => '500', 'height' =>
'300')) . " ";
-
- $html .= " " . anchor('voucher/download/' .
strtolower($html_voucher_type) . "/" . $row->id , img(array('src'
=> asset_url() . "images/icons/save.png", 'border' => '0',
'alt' => 'Download ' . ucfirst($html_voucher_type) . '
Voucher', 'title' => "Download voucher")), array('title'
=> 'Download ' . ucfirst($html_voucher_type) . ' Voucher')) .
"</td>";
-
- $html .= "</tr>";
- $odd_even = ($odd_even == "odd") ? "even" : "odd";
- }
- $html .= "</tbody>";
- $html .= "</table>";
- $data['voucher_table'] = $html;
+ $data['voucher_data'] = $voucher_q;
$this->template->load('template', 'voucher/index', $data);
return;
diff --git a/system/application/helpers/custom_helper.php
b/system/application/helpers/custom_helper.php
index 7bb13ce..014acf4 100644
--- a/system/application/helpers/custom_helper.php
+++ b/system/application/helpers/custom_helper.php
@@ -145,36 +145,91 @@ if ( ! function_exists('v_to_n'))
}
/**
+ * Return Voucher Type information
+ *
+ * @access public
+ * @param int voucher type id
+ * @return array
+ */
+if ( ! function_exists('voucher_type_info'))
+{
+ function voucher_type_info($voucher_type_id)
+ {
+ $CI =& get_instance();
+ $voucher_type_all = $CI->config->item('account_voucher_types');
+
+ if ($voucher_type_all[$voucher_type_id])
+ {
+ return array(
+ 'id' => $voucher_type_all[$voucher_type_id],
+ 'label' => $voucher_type_all[$voucher_type_id]['label'],
+ 'name' => $voucher_type_all[$voucher_type_id]['name'],
+ 'numbering' => $voucher_type_all[$voucher_type_id]['numbering'],
+ 'prefix' => $voucher_type_all[$voucher_type_id]['prefix'],
+ 'suffix' => $voucher_type_all[$voucher_type_id]['suffix'],
+ 'zero_padding' =>
$voucher_type_all[$voucher_type_id]['zero_padding'],
+ 'bank_cash_ledger_restriction' =>
$voucher_type_all[$voucher_type_id]['bank_cash_ledger_restriction'],
+ );
+ } else {
+ return array(
+ 'id' => $voucher_type_all[$voucher_type_id],
+ 'label' => '',
+ 'name' => '(Unkonwn)',
+ 'numbering' => 1,
+ 'prefix' => '',
+ 'suffix' => '',
+ 'zero_padding' => 0,
+ 'bank_cash_ledger_restriction' => 5,
+ );
+ }
+ }
+}
+
+/**
+ * Return Voucher Type Id from Voucher Type Name
+ *
+ * @access public
+ * @param string voucher type name
+ * @return int voucher type id
+ */
+if ( ! function_exists('voucher_type_name_to_id'))
+{
+ function voucher_type_name_to_id($voucher_type_name)
+ {
+ $CI =& get_instance();
+ $voucher_type_all = $CI->config->item('account_voucher_types');
+ foreach ($voucher_type_all as $id => $row)
+ {
+ if ($row['label'] == $voucher_type_name)
+ {
+ return $id;
+ break;
+ }
+ }
+ return FALSE;
+ }
+}
+
+/**
* Converts Voucher number to proper voucher prefix formats
*
* @access public
- * @param voucher type
+ * @param int voucher type id
* @return string
*/
if ( ! function_exists('voucher_number_prefix'))
{
- function voucher_number_prefix($voucher_type)
+ function voucher_number_prefix($voucher_type_id)
{
$CI =& get_instance();
+ $voucher_type_all = $CI->config->item('account_voucher_types');
- $voucher_prefix = "";
-
- switch ($voucher_type)
+ if ( ! $voucher_type_all[$voucher_type_id])
{
- case "receipt":
- $voucher_prefix = $CI->config->item('account_receipt_prefix');
- break;
- case "payment":
- $voucher_prefix = $CI->config->item('account_payment_prefix');
- break;
- case "contra":
- $voucher_prefix = $CI->config->item('account_contra_prefix');
- break;
- case "journal":
- $voucher_prefix = $CI->config->item('account_journal_prefix');
- break;
+ return '';
+ } else {
+ return $voucher_type_all[$voucher_type_id]['prefix'];
}
- return $voucher_prefix;
}
}
diff --git a/system/application/libraries/General.php
b/system/application/libraries/General.php
index b581273..1bdd1b7 100644
--- a/system/application/libraries/General.php
+++ b/system/application/libraries/General.php
@@ -170,6 +170,34 @@ class General {
}
return $user_data;
}
+
+ function setup_voucher_types()
+ {
+ $CI =& get_instance();
+
+ $CI->db->from('voucher_types');
+ $voucher_types = $CI->db->get();
+ if ($voucher_types->num_rows() < 1)
+ {
+ $CI->messages->add('You need to create a voucher type before you can create
any vouchers.', 'error');
+ }
+ $voucher_type_config = array();
+ foreach ($voucher_types->result() as $id => $row)
+ {
+ $voucher_type_config[$row->id] = array(
+ 'label' => $row->label,
+ 'name' => $row->name,
+ 'description' => $row->description,
+ 'base_type' => $row->base_type,
+ 'numbering' => $row->numbering,
+ 'prefix' => $row->prefix,
+ 'suffix' => $row->suffix,
+ 'zero_padding' => $row->zero_padding,
+ 'bank_cash_ledger_restriction' => $row->bank_cash_ledger_restriction,
+ );
+ }
+ $CI->config->set_item('account_voucher_types', $voucher_type_config);
+ }
}
/* End of file General.php */
diff --git a/system/application/libraries/Startup.php
b/system/application/libraries/Startup.php
index 9b2e40c..2160cf0 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -115,6 +115,9 @@ class Startup
/* Load general application settings */
$CI->general->check_setting();
+ /* Load voucher types */
+ $CI->general->setup_voucher_types();
+
return;
}
}
diff --git a/system/application/models/ledger_model.php
b/system/application/models/ledger_model.php
index ec1bea2..1fb96cf 100644
--- a/system/application/models/ledger_model.php
+++ b/system/application/models/ledger_model.php
@@ -69,13 +69,15 @@ class Ledger_model extends Model {
return "(Error)";
}
- function get_voucher_name($voucher_id, $voucher_type)
+ function get_voucher_name($voucher_id, $voucher_type_id)
{
- /* If receipt voucher (1) then select the credit ledger */
- if ($voucher_type == 1)
- $ledger_type = 'C';
- else
+ /* Selecting whether to show debit side Ledger or credit side Ledger */
+ $current_voucher_type = voucher_type_info($voucher_type_id);
+ $ledger_type = 'C';
+
+ if ($current_voucher_type['bank_cash_ledger_restriction'] == 3)
$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();
@@ -86,9 +88,9 @@ class Ledger_model extends Model {
$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'));
+ $html .= anchor('voucher/view/' . $current_voucher_type['label'] .
"/" . $voucher_id, "(" . $ledger->name . ")",
array('title' => 'View ' . $current_voucher_type['name'] .
' 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'));
+ $html .= anchor('voucher/view/' . $current_voucher_type['label'] .
"/" . $voucher_id, $ledger->name, array('title' => 'View '
. $current_voucher_type['name'] . ' Voucher', 'class' =>
'anchor-link-a'));
return $html;
}
return;
diff --git a/system/application/views/voucher/index.php
b/system/application/views/voucher/index.php
index 68f7a56..cb10ca6 100644
--- a/system/application/views/voucher/index.php
+++ b/system/application/views/voucher/index.php
@@ -2,7 +2,49 @@
<?php $this->load->view('sidebar/tag', $tag_id); ?>
</div>
-<?php echo $voucher_table ?>
+<table border=0 cellpadding=5 class="simple-table">
+ <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>
+ <tbody>
+ <?php
+ foreach ($voucher_data->result() as $row)
+ {
+ $current_voucher_type = voucher_type_info($row->type);
+
+ echo "<tr>";
+
+ echo "<td>" . date_mysql_to_php_display($row->date) .
"</td>";
+ echo "<td>" . anchor('voucher/view/' .
$current_voucher_type['label'] . "/" . $row->id,
voucher_number_prefix($row->type) . $row->number, array('title' =>
'View ' . $current_voucher_type['name'] . ' Voucher',
'class' => 'anchor-link-a')) . "</td>";
+
+ echo "<td>";
+ echo $this->Tag_model->show_voucher_tag($row->tag_id);
+ echo $this->Ledger_model->get_voucher_name($row->id, $row->type);
+ echo "</td>";
+
+ echo "<td>" . $current_voucher_type['name'] .
"</td>";
+ echo "<td>" . $row->dr_total . "</td>";
+ echo "<td>" . $row->cr_total . "</td>";
+
+ echo "<td>" . anchor('voucher/edit/' .
$current_voucher_type['label'] . "/" . $row->id , "Edit",
array('title' => 'Edit ' . $current_voucher_type['name'] .
' Voucher', 'class' => 'red-link')) . " ";
+ echo " " . anchor('voucher/delete/' .
$current_voucher_type['label'] . "/" . $row->id ,
img(array('src' => asset_url() . "images/icons/delete.png",
'border' => '0', 'alt' => 'Delete ' .
$current_voucher_type['name'] . ' Voucher', 'class' =>
"confirmClick", 'title' => "Delete voucher")),
array('title' => 'Delete ' . $current_voucher_type['name'] .
' Voucher')) . " ";
+ echo " " . anchor_popup('voucher/printpreview/' .
$current_voucher_type['label'] . "/" . $row->id ,
img(array('src' => asset_url() . "images/icons/print.png",
'border' => '0', 'alt' => 'Print ' .
$current_voucher_type['name'] . ' Voucher')), array('title' =>
'Print ' . $current_voucher_type['name']. ' Voucher',
'width' => '600', 'height' => '600')) . "
";
+ echo " " . anchor_popup('voucher/email/' .
$current_voucher_type['label'] . "/" . $row->id ,
img(array('src' => asset_url() . "images/icons/email.png",
'border' => '0', 'alt' => 'Email ' .
$current_voucher_type['name'] . ' Voucher')), array('title' =>
'Email ' . $current_voucher_type['name'] . ' Voucher',
'width' => '500', 'height' => '300')) . "
";
+ echo " " . anchor('voucher/download/' .
$current_voucher_type['label'] . "/" . $row->id ,
img(array('src' => asset_url() . "images/icons/save.png",
'border' => '0', 'alt' => 'Download ' .
$current_voucher_type['name'] . ' Voucher', 'title' =>
"Download voucher")), array('title' => 'Download ' .
$current_voucher_type['name'] . ' Voucher')) . "</td>";
+
+ echo "</tr>";
+ }
+ ?>
+ </tbody>
+</table>
<div id="pagination-container"><?php echo
$this->pagination->create_links(); ?></div>
commit 764752ff25322c9d379ac748391768c800d5bc54
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Jan 28 15:24:42 2011 +0530
Updated application version to 1.1
- Updated CHANGELOG.txt
- Udpated config['application_version']
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 577d262..58fee84 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,3 +1,11 @@
+Webzash Version 1.1 2011-01-28
+------------------------------
+
+ * Added application shortcuts
+ * Fixed many bugs
+ * Removed options to Print, Edit and Delete from voucher add and edit
+ * Updated some pending database code to use active record
+
Webzash Version 1.0 2011-01-22
------------------------------
diff --git a/TODO.txt b/TODO.txt
index 0cb0a0c..32b162d 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,5 +1,3 @@
-Priority - Task - Person responsible
+Webzash TODO is now available online at :
-It is now available online at
-
-http://codaset.com/pshahmumbai/webzash/wiki/Project-Plan
+https://github.com/prashants/webzash/wiki
diff --git a/system/application/config/config.php b/system/application/config/config.php
index cb490bb..66cf52e 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';
+$config['application_version'] = '1.1';
/* End of file config.php */
/* Location: ./system/application/config/config.php */
diff --git a/system/application/controllers/setting.php
b/system/application/controllers/setting.php
index 50f0939..a89c560 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -427,7 +427,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, 2)))
+ 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');
commit 764ff5c5e3e9eed2fde9b231e91cea5c9bf2c2f5
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Jan 28 15:13:55 2011 +0530
Removed Print, Email, Download from Voucher add and edit
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 b1b34d0..93523ef 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -340,9 +340,6 @@ class Voucher extends Controller {
'value' => '',
);
$data['voucher_type'] = $voucher_type;
- $data['voucher_print'] = FALSE;
- $data['voucher_email'] = FALSE;
- $data['voucher_download'] = FALSE;
$data['voucher_tags'] = $this->Tag_model->get_all_tags();
$data['voucher_tag'] = 0;
@@ -368,9 +365,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_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);
$data['voucher_tag'] = $this->input->post('voucher_tag', TRUE);
$data['ledger_dc'] = $this->input->post('ledger_dc', TRUE);
@@ -688,9 +682,6 @@ class Voucher extends Controller {
);
$data['voucher_type'] = $voucher_type;
$data['voucher_id'] = $voucher_id;
- $data['voucher_print'] = FALSE;
- $data['voucher_email'] = FALSE;
- $data['voucher_download'] = FALSE;
$data['voucher_tag'] = $cur_voucher->tag_id;
$data['voucher_tags'] = $this->Tag_model->get_all_tags();
$data['has_reconciliation'] = FALSE;
@@ -756,9 +747,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_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);
$data['voucher_tag'] = $this->input->post('voucher_tag', TRUE);
$data['has_reconciliation'] =
$this->input->post('has_reconciliation', TRUE);
diff --git a/system/application/views/voucher/add.php
b/system/application/views/voucher/add.php
index 030c740..8fb8493 100644
--- a/system/application/views/voucher/add.php
+++ b/system/application/views/voucher/add.php
@@ -267,17 +267,6 @@ $(document).ready(function() {
echo "</p>";
echo "<p>";
- echo form_fieldset('Options', array('class' =>
"fieldset-auto-width"));
- echo form_checkbox('voucher_print', 1, $voucher_print) . "Print";
- echo
" ";
- echo form_checkbox('voucher_email', 1, $voucher_email) . "Email";
- echo
" ";
- echo form_checkbox('voucher_download', 1, $voucher_download) .
"Download";
- echo form_fieldset_close();
- echo "</p>";
- echo "<br /><br />";
-
- echo "<p>";
echo form_label('Tag', 'voucher_tag');
echo " ";
echo form_dropdown('voucher_tag', $voucher_tags, $voucher_tag);
diff --git a/system/application/views/voucher/edit.php
b/system/application/views/voucher/edit.php
index 0cda23a..b9cb6a5 100644
--- a/system/application/views/voucher/edit.php
+++ b/system/application/views/voucher/edit.php
@@ -264,17 +264,6 @@ $(document).ready(function() {
echo "</p>";
echo "<p>";
- echo form_fieldset('Options', array('class' =>
"fieldset-auto-width"));
- echo form_checkbox('voucher_print', 1, $voucher_print) . "Print";
- echo
" ";
- echo form_checkbox('voucher_email', 1, $voucher_email) . "Email";
- echo
" ";
- echo form_checkbox('voucher_download', 1, $voucher_download) .
"Download";
- echo form_fieldset_close();
- echo "</p>";
- echo "<br /><br />";
-
- echo "<p>";
echo form_label('Tag', 'voucher_tag');
echo " ";
echo form_dropdown('voucher_tag', $voucher_tags, $voucher_tag);
commit 0c955abab3781ba787247ffdea211566efdc5202
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Jan 28 15:06:21 2011 +0530
Display all actions on voucher edit
- Display Voucher View, Edit, Print, Email, Download, Reconciliation
- The messages cannot be set in edit() method since the messages
are too long and session is getting corrupted after redirect
- Moved the updated voucher info to sessions and showing the message in
in the show action
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 529ec93..b1b34d0 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -155,6 +155,32 @@ class Voucher extends Controller {
$this->session->unset_userdata('voucher_added_number');
}
+ /* Show voucher edit actions */
+ if ($this->session->userdata('voucher_updated_show_action'))
+ {
+ $voucher_updated_id_temp =
$this->session->userdata('voucher_updated_id');
+ $voucher_updated_type_temp =
$this->session->userdata('voucher_updated_type');
+ $voucher_updated_number_temp =
$this->session->userdata('voucher_updated_number');
+ $voucher_updated_message = 'Updated ' . ucfirst($voucher_updated_type_temp) .
' Voucher number ' . voucher_number_prefix($voucher_updated_type_temp) .
$voucher_updated_number_temp . ".";
+ $voucher_updated_message .= " You can [ ";
+ $voucher_updated_message .= anchor('voucher/view/' .
strtolower($voucher_updated_type_temp) . "/" . $voucher_updated_id_temp,
'View', array('class' => 'anchor-link-a')) . " | ";
+ $voucher_updated_message .= anchor('voucher/edit/' .
strtolower($voucher_updated_type_temp) . "/" . $voucher_updated_id_temp,
'Edit', array('class' => 'anchor-link-a')) . " | ";
+ $voucher_updated_message .= anchor_popup('voucher/printpreview/' .
strtolower($voucher_updated_type_temp) . "/" . $voucher_updated_id_temp ,
'Print', array('class' => 'anchor-link-a', 'width'
=> '600', 'height' => '600')) . " | ";
+ $voucher_updated_message .= anchor_popup('voucher/email/' .
strtolower($voucher_updated_type_temp) . "/" . $voucher_updated_id_temp,
'Email', array('class' => 'anchor-link-a', 'width'
=> '500', 'height' => '300')) . " | ";
+ $voucher_updated_message .= anchor('voucher/download/' .
strtolower($voucher_updated_type_temp) . "/" . $voucher_updated_id_temp,
'Download', array('class' => 'anchor-link-a'));
+ $voucher_updated_message .= " ] it.";
+ $this->messages->add($voucher_updated_message, 'success');
+
+ if ($this->session->userdata('voucher_updated_has_reconciliation'))
+ $this->messages->add('Previous reconciliations for this voucher are no
longer valid. You need to redo the reconciliations for this voucher.',
'success');
+
+ $this->session->unset_userdata('voucher_updated_show_action');
+ $this->session->unset_userdata('voucher_updated_id');
+ $this->session->unset_userdata('voucher_updated_type');
+ $this->session->unset_userdata('voucher_updated_number');
+ $this->session->unset_userdata('voucher_updated_has_reconciliation');
+ }
+
$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>DR Amount</th><th>CR
Amount</th><th></th></tr></thead>";
$html .= "<tbody>";
@@ -577,26 +603,6 @@ 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);
- }
-
$this->session->set_userdata('voucher_added_show_action', TRUE);
$this->session->set_userdata('voucher_added_id', $voucher_id);
$this->session->set_userdata('voucher_added_type', $voucher_type);
@@ -973,38 +979,18 @@ 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->session->set_userdata('voucher_updated_show_action', TRUE);
+ $this->session->set_userdata('voucher_updated_id', $voucher_id);
+ $this->session->set_userdata('voucher_updated_type', $voucher_type);
+ $this->session->set_userdata('voucher_updated_number', $data_number);
+ if ($data_has_reconciliation)
+ $this->session->set_userdata('voucher_updated_has_reconciliation',
TRUE);
+ else
+ $this->session->set_userdata('voucher_updated_has_reconciliation',
FALSE);
- $this->messages->add('Updated ' . ucfirst($voucher_type) . ' Voucher
number ' . voucher_number_prefix($voucher_type) . $data_number . ". " .
$voucher_success_links, 'success');
+ /* Showing success message in show() method since message is too long for storing it
in session */
$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;
}
commit 7f12d6e31efaaa2a007bdc4dfbc926e25767880b
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Jan 28 14:49:14 2011 +0530
Display all actions on voucher add
- Display Voucher View, Edit, Print, Email, Download
- The messages cannot be set in add() method since the messages
is too long and session is getting corrupted after redirect
- Moved the voucher info to sessions and showing the message in
in the show action
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 3f56ad8..529ec93 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -134,6 +134,27 @@ class Voucher extends Controller {
/* Pagination initializing */
$this->pagination->initialize($config);
+ /* Show voucher add actions */
+ if ($this->session->userdata('voucher_added_show_action'))
+ {
+ $voucher_added_id_temp = $this->session->userdata('voucher_added_id');
+ $voucher_added_type_temp =
$this->session->userdata('voucher_added_type');
+ $voucher_added_number_temp =
$this->session->userdata('voucher_added_number');
+ $voucher_added_message = 'Added ' . ucfirst($voucher_added_type_temp) . '
Voucher number ' . voucher_number_prefix($voucher_added_type_temp) .
$voucher_added_number_temp . ".";
+ $voucher_added_message .= " You can [ ";
+ $voucher_added_message .= anchor('voucher/view/' .
strtolower($voucher_added_type_temp) . "/" . $voucher_added_id_temp,
'View', array('class' => 'anchor-link-a')) . " | ";
+ $voucher_added_message .= anchor('voucher/edit/' .
strtolower($voucher_added_type_temp) . "/" . $voucher_added_id_temp,
'Edit', array('class' => 'anchor-link-a')) . " | ";
+ $voucher_added_message .= anchor_popup('voucher/printpreview/' .
strtolower($voucher_added_type_temp) . "/" . $voucher_added_id_temp ,
'Print', array('class' => 'anchor-link-a', 'width'
=> '600', 'height' => '600')) . " | ";
+ $voucher_added_message .= anchor_popup('voucher/email/' .
strtolower($voucher_added_type_temp) . "/" . $voucher_added_id_temp,
'Email', array('class' => 'anchor-link-a', 'width'
=> '500', 'height' => '300')) . " | ";
+ $voucher_added_message .= anchor('voucher/download/' .
strtolower($voucher_added_type_temp) . "/" . $voucher_added_id_temp,
'Download', array('class' => 'anchor-link-a'));
+ $voucher_added_message .= " ] it.";
+ $this->messages->add($voucher_added_message, 'success');
+ $this->session->unset_userdata('voucher_added_show_action');
+ $this->session->unset_userdata('voucher_added_id');
+ $this->session->unset_userdata('voucher_added_type');
+ $this->session->unset_userdata('voucher_added_number');
+ }
+
$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>DR Amount</th><th>CR
Amount</th><th></th></tr></thead>";
$html .= "<tbody>";
@@ -576,13 +597,12 @@ class Voucher extends Controller {
$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->session->set_userdata('voucher_added_show_action', TRUE);
+ $this->session->set_userdata('voucher_added_id', $voucher_id);
+ $this->session->set_userdata('voucher_added_type', $voucher_type);
+ $this->session->set_userdata('voucher_added_number', $data_number);
- $this->messages->add('Added ' . ucfirst($voucher_type) . ' Voucher
number ' . voucher_number_prefix($voucher_type) . $data_number . ". " .
$voucher_success_links, 'success');
+ /* Showing success message in show() method since message is too long for storing it
in session */
$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);
@@ -1177,6 +1197,7 @@ class Voucher extends Controller {
$data['voucher_type'] = $voucher_type;
$data['voucher_id'] = $voucher_id;
+ $data['voucher_number'] = $cur_voucher->number;
$data['email_to'] = array(
'name' => 'email_to',
'id' => 'email_to',
diff --git a/system/application/views/voucher/email.php
b/system/application/views/voucher/email.php
index e7fdb59..d9e8148 100644
--- a/system/application/views/voucher/email.php
+++ b/system/application/views/voucher/email.php
@@ -38,7 +38,7 @@
echo form_open('voucher/email/' . $voucher_type . "/" . $voucher_id);
- echo "Emailing " . ucfirst($voucher_type) . " Voucher No. " .
$voucher_id . "<br />";
+ echo "Emailing " . ucfirst($voucher_type) . " Voucher No. " .
$voucher_number . "<br />";
echo "<p>";
echo form_label('Email to', 'email_to');
diff --git a/system/application/views/voucher/index.php
b/system/application/views/voucher/index.php
index 4fe4f7d..68f7a56 100644
--- a/system/application/views/voucher/index.php
+++ b/system/application/views/voucher/index.php
@@ -4,29 +4,5 @@
<?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 2e0cb6595d4247e4216841792b1fa6c29f38a6ef
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Jan 28 12:03:33 2011 +0530
Updated database query to use active records
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/libraries/Accountlist.php
b/system/application/libraries/Accountlist.php
index 22ab322..9819422 100644
--- a/system/application/libraries/Accountlist.php
+++ b/system/application/libraries/Accountlist.php
@@ -30,7 +30,8 @@ class Accountlist
$this->total = 0;
} else {
- $group_q = $CI->db->query('SELECT * FROM groups WHERE id = ?',
array($id));
+ $CI->db->from('groups')->where('id', $id)->limit(1);
+ $group_q = $CI->db->get();
$group = $group_q->row();
$this->id = $group->id;
$this->name = $group->name;
@@ -43,7 +44,8 @@ class Accountlist
function add_sub_groups()
{
$CI =& get_instance();
- $child_group_q = $CI->db->query('SELECT * FROM groups WHERE parent_id =
?', array($this->id));
+ $CI->db->from('groups')->where('parent_id', $this->id);
+ $child_group_q = $CI->db->get();
$counter = 0;
foreach ($child_group_q->result() as $row)
{
@@ -57,7 +59,8 @@ class Accountlist
{
$CI =& get_instance();
$CI->load->model('Ledger_model');
- $child_ledger_q = $CI->db->query('SELECT * FROM ledgers WHERE group_id =
?', array($this->id));
+ $CI->db->from('ledgers')->where('group_id', $this->id);
+ $child_ledger_q = $CI->db->get();
$counter = 0;
foreach ($child_ledger_q->result() as $row)
{
diff --git a/system/application/libraries/Logger.php
b/system/application/libraries/Logger.php
index be4beb7..caad0f4 100644
--- a/system/application/libraries/Logger.php
+++ b/system/application/libraries/Logger.php
@@ -46,7 +46,8 @@ class Logger
function read_recent_messages()
{
$CI =& get_instance();
- $logs_q = $CI->db->query("SELECT * FROM logs ORDER BY id DESC LIMIT
20");
+ $CI->db->from('logs')->order_by('id',
'desc')->limit(20);
+ $logs_q = $CI->db->get();
if ($logs_q->num_rows() > 0)
{
return $logs_q;
diff --git a/system/application/libraries/MY_Form_validation.php
b/system/application/libraries/MY_Form_validation.php
index 08053dd..83d954f 100644
--- a/system/application/libraries/MY_Form_validation.php
+++ b/system/application/libraries/MY_Form_validation.php
@@ -22,10 +22,12 @@ class MY_Form_validation extends CI_Form_validation {
list ($table, $column) = explode('.', $field, 2);
$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();
- return ($row->dupe > 0) ? FALSE : TRUE;
+ $CI->db->from($table)->where($column, $str);
+ $dup_query = $CI->db->get();
+ if ($dup_query->num_rows() > 0)
+ return FALSE;
+ else
+ return TRUE;
}
function uniquevoucherno($str, $type)
@@ -34,9 +36,12 @@ class MY_Form_validation extends CI_Form_validation {
$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();
- return ($row->dupe > 0) ? FALSE : TRUE;
+ $CI->db->from('vouchers')->where('number',
$str)->where('type', $type);
+ $dup_query = $CI->db->get();
+ if ($dup_query->num_rows() > 0)
+ return FALSE;
+ else
+ return TRUE;
}
function uniquevouchernowithid($str, $field)
@@ -46,9 +51,12 @@ class MY_Form_validation extends CI_Form_validation {
list ($type, $id) = explode('.', $field, 2);
$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();
- return ($row->dupe > 0) ? FALSE : TRUE;
+ $CI->db->from('vouchers')->where('number',
$str)->where('type', $type)->where('id !=', $id);
+ $dup_query = $CI->db->get();
+ if ($dup_query->num_rows() > 0)
+ return FALSE;
+ else
+ return TRUE;
}
function uniquewithid($str, $field)
@@ -58,9 +66,12 @@ class MY_Form_validation extends CI_Form_validation {
$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();
- return ($row->dupe > 0) ? FALSE : TRUE;
+ $CI->db->from($table)->where($column, $str)->where('id !=', $id);
+ $dup_query = $CI->db->get();
+ if ($dup_query->num_rows() > 0)
+ return FALSE;
+ else
+ return TRUE;
}
function is_dc($str)
diff --git a/system/application/libraries/Startup.php
b/system/application/libraries/Startup.php
index de20270..9b2e40c 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -89,7 +89,8 @@ class Startup
}
/* Loading account data */
- $account_q = $CI->db->query('SELECT * FROM settings WHERE id = 1');
+ $CI->db->from('settings')->where('id', 1)->limit(1);
+ $account_q = $CI->db->get();
if ( ! ($account_d = $account_q->row()))
{
$CI->messages->add('Invalid account settings.', 'error');
commit f244228f281b3e017753d9ee2abbbeccd8cc0731
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Fri Jan 28 11:36:07 2011 +0530
Cannot edit or delete System Group A/C's
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 7c10cc0..5327848 100644
--- a/system/application/controllers/admin/initialize.sql
+++ b/system/application/controllers/admin/initialize.sql
@@ -7,7 +7,7 @@ INSERT INTO groups (id, parent_id, name, affects_gross) VALUES (6, 1,
'Current A
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 (10, 2, 'Loans
(Liabilities)', 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);
diff --git a/system/application/controllers/group.php
b/system/application/controllers/group.php
index 5b33e58..e1c5976 100644
--- a/system/application/controllers/group.php
+++ b/system/application/controllers/group.php
@@ -144,8 +144,8 @@ class Group extends Controller {
redirect('account');
return;
}
- if ($id < 5) {
- $this->messages->add('Cannot edit system created Group A/C.',
'error');
+ if ($id <= 16) {
+ $this->messages->add('Cannot edit System Group A/C.', 'error');
redirect('account');
return;
}
@@ -278,8 +278,8 @@ class Group extends Controller {
redirect('account');
return;
}
- if ($id < 5) {
- $this->messages->add('Cannot delete system created Group A/C.',
'error');
+ if ($id <= 16) {
+ $this->messages->add('Cannot delete System Group A/C.',
'error');
redirect('account');
return;
}
diff --git a/system/application/libraries/Accountlist.php
b/system/application/libraries/Accountlist.php
index 8b9e578..22ab322 100644
--- a/system/application/libraries/Accountlist.php
+++ b/system/application/libraries/Accountlist.php
@@ -125,7 +125,7 @@ class Accountlist
echo "<td>-</td>";
echo "<td>-</td>";
- if ($this->id <= 4)
+ if ($this->id <= 16)
{
echo "<td class=\"td-actions\"></tr>";
} else {
commit f38e46c0701211caf99cae30f06908988a73fbf0
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Jan 27 21:30:30 2011 +0530
Include the javascript shortcut library in all templates
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 2cc9ce9..8a0e82b 100644
--- a/system/application/views/admin_template.php
+++ b/system/application/views/admin_template.php
@@ -10,12 +10,18 @@
<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/jquery.datepick.css">
+<script type="text/javascript">
+ var jsSiteUrl = '<?php echo base_url(); ?>';
+</script>
+
<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/shortcutslibrary.js"></script>
+<script type="text/javascript" src="<?php echo asset_url();
?>js/shortcuts.js"></script>
<script type="text/javascript">
/* Loading JQuery Superfish menu */
diff --git a/system/application/views/template.php
b/system/application/views/template.php
index 31a701c..3f3ba62 100644
--- a/system/application/views/template.php
+++ b/system/application/views/template.php
@@ -23,6 +23,10 @@ if (isset($add_css))
}
?>
+<script type="text/javascript">
+ var jsSiteUrl = '<?php echo base_url(); ?>';
+</script>
+
<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>
@@ -31,6 +35,8 @@ if (isset($add_css))
<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>
+<script type="text/javascript" src="<?php echo asset_url();
?>js/shortcutslibrary.js"></script>
+<script type="text/javascript" src="<?php echo asset_url();
?>js/shortcuts.js"></script>
<?php
/* Dynamically adding javascript files from controllers */
diff --git a/system/application/views/user_template.php
b/system/application/views/user_template.php
index e1e0a95..21c4c22 100644
--- a/system/application/views/user_template.php
+++ b/system/application/views/user_template.php
@@ -12,6 +12,10 @@
<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">
+ var jsSiteUrl = '<?php echo base_url(); ?>';
+</script>
+
<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>
@@ -20,6 +24,9 @@
<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>
+<script type="text/javascript" src="<?php echo asset_url();
?>js/shortcutslibrary.js"></script>
+<script type="text/javascript" src="<?php echo asset_url();
?>js/shortcuts.js"></script>
+
</head>
<body>
<div id="container">
commit 316fb6b116184655256a85c9f355a6be641694cf
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Jan 27 21:28:06 2011 +0530
Added user customizable javascript shortcut file
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/assets/js/shortcuts.js
b/system/application/assets/js/shortcuts.js
new file mode 100644
index 0000000..fa4a459
--- /dev/null
+++ b/system/application/assets/js/shortcuts.js
@@ -0,0 +1,10 @@
+shortcut("Ctrl+H",
+ function() {
+ window.open(jsSiteUrl, "_self");
+ },
+ {
+ 'type': 'keydown',
+ 'propagate': false,
+ 'target': document
+ }
+);
commit 63e263a1b6bd60338243340bb565edd3d31ac742
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Jan 27 21:26:11 2011 +0530
Added javascript hotkey library
Site :
http://www.openjs.com/scripts/events/keyboard_shortcuts/
Under BSD License
Signed-off-by: Prashant P Shah <pshah.mumbai(a)gmail.com>
diff --git a/system/application/assets/js/shortcutslibrary.js
b/system/application/assets/js/shortcutslibrary.js
new file mode 100644
index 0000000..63f3323
--- /dev/null
+++ b/system/application/assets/js/shortcutslibrary.js
@@ -0,0 +1,163 @@
+/**
+ *
http://www.openjs.com/scripts/events/keyboard_shortcuts/
+ * Version : 1.00.A
+ * By Binny V A
+ * License : BSD
+ */
+function shortcut(shortcut,callback,opt) {
+ //Provide a set of default options
+ var default_options = {
+ 'type':'keydown',
+ 'propagate':false,
+ 'target':document
+ }
+ if(!opt) opt = default_options;
+ else {
+ for(var dfo in default_options) {
+ if(typeof opt[dfo] == 'undefined') opt[dfo] = default_options[dfo];
+ }
+ }
+
+ var ele = opt.target
+ if(typeof opt.target == 'string') ele = document.getElementById(opt.target);
+ var ths = this;
+
+ //The function to be called at keypress
+ var func = function(e) {
+ e = e || window.event;
+
+ //Find Which key is pressed
+ if (e.keyCode) code = e.keyCode;
+ else if (e.which) code = e.which;
+ var character = String.fromCharCode(code).toLowerCase();
+
+ var keys = shortcut.toLowerCase().split("+");
+ //Key Pressed - counts the number of valid keypresses - if it is same as the number of
keys, the shortcut function is invoked
+ var kp = 0;
+
+ //Work around for stupid Shift key bug created by using lowercase - as a result the
shift+num combination was broken
+ var shift_nums = {
+ "`":"~",
+ "1":"!",
+ "2":"@",
+ "3":"#",
+ "4":"$",
+ "5":"%",
+ "6":"^",
+ "7":"&",
+ "8":"*",
+ "9":"(",
+ "0":")",
+ "-":"_",
+ "=":"+",
+ ";":":",
+ "'":"\"",
+ ",":"<",
+ ".":">",
+ "/":"?",
+ "\\":"|"
+ }
+ //Special Keys - and their codes
+ var special_keys = {
+ 'esc':27,
+ 'escape':27,
+ 'tab':9,
+ 'space':32,
+ 'return':13,
+ 'enter':13,
+ 'backspace':8,
+
+ 'scrolllock':145,
+ 'scroll_lock':145,
+ 'scroll':145,
+ 'capslock':20,
+ 'caps_lock':20,
+ 'caps':20,
+ 'numlock':144,
+ 'num_lock':144,
+ 'num':144,
+
+ 'pause':19,
+ 'break':19,
+
+ 'insert':45,
+ 'home':36,
+ 'delete':46,
+ 'end':35,
+
+ 'pageup':33,
+ 'page_up':33,
+ 'pu':33,
+
+ 'pagedown':34,
+ 'page_down':34,
+ 'pd':34,
+
+ 'left':37,
+ 'up':38,
+ 'right':39,
+ 'down':40,
+
+ 'f1':112,
+ 'f2':113,
+ 'f3':114,
+ 'f4':115,
+ 'f5':116,
+ 'f6':117,
+ 'f7':118,
+ 'f8':119,
+ 'f9':120,
+ 'f10':121,
+ 'f11':122,
+ 'f12':123
+ }
+
+
+ for(var i=0; k=keys[i],i<keys.length; i++) {
+ //Modifiers
+ if(k == 'ctrl' || k == 'control') {
+ if(e.ctrlKey) kp++;
+
+ } else if(k == 'shift') {
+ if(e.shiftKey) kp++;
+
+ } else if(k == 'alt') {
+ if(e.altKey) kp++;
+
+ } else if(k.length > 1) { //If it is a special key
+ if(special_keys[k] == code) kp++;
+
+ } else { //The special keys did not match
+ if(character == k) kp++;
+ else {
+ if(shift_nums[character] && e.shiftKey) { //Stupid Shift key bug created by
using lowercase
+ character = shift_nums[character];
+ if(character == k) kp++;
+ }
+ }
+ }
+ }
+
+ if(kp == keys.length) {
+ callback(e);
+
+ if(!opt['propagate']) { //Stop the event
+ //e.cancelBubble is supported by IE - this will kill the bubbling process.
+ e.cancelBubble = true;
+ e.returnValue = false;
+
+ //e.stopPropagation works only in Firefox.
+ if (e.stopPropagation) {
+ e.stopPropagation();
+ e.preventDefault();
+ }
+ return false;
+ }
+ }
+ }
+
+ //Attach the function with the event
+ if(ele.addEventListener) ele.addEventListener(opt['type'], func, false);
+ else if(ele.attachEvent) ele.attachEvent('on'+opt['type'], func);
+ else ele['on'+opt['type']] = func;
+}
\ No newline at end of file
commit 24f1cd8bad978fcaf5a23473fa3e78c01bde4373
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Jan 27 20:41:11 2011 +0530
Changed Liabilities to Liabilities and Owners Equity
- As per suggestion from 'H Maeda' to confirm to accounting
standards
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 2e5f8f3..7c10cc0 100644
--- a/system/application/controllers/admin/initialize.sql
+++ b/system/application/controllers/admin/initialize.sql
@@ -1,5 +1,5 @@
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 (2, 0, 'Liabilities
and Owners Equity', 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);
diff --git a/system/application/controllers/report.php
b/system/application/controllers/report.php
index c02ce68..1b89ccc 100644
--- a/system/application/controllers/report.php
+++ b/system/application/controllers/report.php
@@ -600,7 +600,7 @@ class Report extends Controller {
Accountlist::add_blank_csv();
/* Liability side */
$total = $liability_total;
- Accountlist::add_row_csv(array("Liability Total",
convert_cur($liability_total)));
+ Accountlist::add_row_csv(array("Liabilities and Owners Equity Total",
convert_cur($liability_total)));
/* If Profit then Liability side, If Loss then Asset side */
if ($pandl != 0)
@@ -622,7 +622,7 @@ class Report extends Controller {
}
}
- Accountlist::add_row_csv(array("Total - Liabilities",
convert_cur($total)));
+ Accountlist::add_row_csv(array("Total - Liabilities and Owners Equity",
convert_cur($total)));
/* Asset side */
$total = $asset_total;
diff --git a/system/application/views/report/balancesheet.php
b/system/application/views/report/balancesheet.php
index 2330189..a2fa868 100644
--- a/system/application/views/report/balancesheet.php
+++ b/system/application/views/report/balancesheet.php
@@ -8,7 +8,7 @@
echo "<td width=\"" . $left_width . "\">";
$liability->init(2);
echo "<table border=0 cellpadding=5 class=\"simple-table
balance-sheet-table\" width=\"100%\">";
- echo "<thead><tr><th>Liabilities</th><th
align=\"right\">Amount</th></tr></thead>";
+ echo "<thead><tr><th>Liabilities and Owners
Equity</th><th
align=\"right\">Amount</th></tr></thead>";
$liability->account_st_short(0);
echo "</table>";
echo "</td>";
@@ -46,7 +46,7 @@
echo "<td>";
echo "<table border=0 cellpadding=5
class=\"balance-sheet-total-table\" width=\"100%\">";
echo "<tr valign=\"top\">";
- echo "<td class=\"bold\">Liability Total</td>";
+ echo "<td class=\"bold\">Liability and Owners Equity
Total</td>";
echo "<td align=\"right\" class=\"bold\">" .
convert_cur($liability_total) . "</td>";
echo "</tr>";
commit 33b31dc4ffbc14eca693711244de0594a926fb23
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Thu Jan 27 12:22:37 2011 +0530
Added better database connection error checking on Startup
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 5a78a29..3f56ad8 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -331,7 +331,7 @@ class Voucher extends Controller {
$data['dr_amount'] = $this->input->post('dr_amount', TRUE);
$data['cr_amount'] = $this->input->post('cr_amount', TRUE);
} else {
- for ($count = 0; $count <= 5; $count++)
+ for ($count = 0; $count <= 3; $count++)
{
if ($count == 0 && $voucher_type == "payment")
$data['ledger_dc'][$count] = "C";
diff --git a/system/application/libraries/Startup.php
b/system/application/libraries/Startup.php
index 2700873..de20270 100644
--- a/system/application/libraries/Startup.php
+++ b/system/application/libraries/Startup.php
@@ -57,6 +57,23 @@ class Startup
$db_config['char_set'] = "utf8";
$db_config['dbcollat'] = "utf8_general_ci";
$CI->load->database($db_config, FALSE, TRUE);
+
+ /* Checking for valid database connection */
+ if ( ! $CI->db->conn_id)
+ {
+ $CI->session->unset_userdata('active_account');
+ $CI->messages->add('Error connecting to database server. Check whether
database server is running.', 'error');
+ redirect('user/account');
+ return;
+ }
+ /* Check for any database connection error messages */
+ if ($CI->db->_error_message() != "")
+ {
+ $CI->session->unset_userdata('active_account');
+ $CI->messages->add('Error connecting to database server. ' .
$CI->db->_error_message(), 'error');
+ redirect('user/account');
+ return;
+ }
} else {
$CI->messages->add('Select a account.', 'error');
redirect('user/account');
commit d41135c9d5a94ef128d2c9be760c3884339d1f85
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 26 11:59:54 2011 +0530
Check if Contra Vouchers on removing Bank or Cash Account status
- Check if any Contra Vouchers are present before removing
the Bank or Cash Acount status of the 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 221a3fb..4503b5b 100644
--- a/system/application/controllers/ledger.php
+++ b/system/application/controllers/ledger.php
@@ -261,6 +261,19 @@ class Ledger extends Controller {
return;
}
+ /* Check if contra voucher present for non Bank or Cash A/C */
+ if ($data_ledger_type_cashbank_value != "1")
+ {
+ $this->db->from('voucher_items')->join('vouchers',
'voucher_items.voucher_id = vouchers.id')->where('vouchers.type',
3)->where('voucher_items.ledger_id', $id);
+ $contra_count = $this->db->get()->num_rows();
+ if ($contra_count > 0)
+ {
+ $this->messages->add('Cannot remove the Bank or Cash Account status of
this Ledger A/C since it is still linked with ' . $contra_count . ' Contra
Vouchers entries.', 'error');
+ $this->template->load('template', 'ledger/edit', $data);
+ return;
+ }
+ }
+
if ($data_ledger_type_cashbank_value == "1")
{
$data_ledger_type_cashbank = "B";
diff --git a/system/application/views/ledger/add.php
b/system/application/views/ledger/add.php
index caab430..b5c2ba6 100644
--- a/system/application/views/ledger/add.php
+++ b/system/application/views/ledger/add.php
@@ -26,7 +26,7 @@
echo "<p>";
echo "<span id=\"tooltip-target-2\">";
- echo form_checkbox('ledger_type_cashbank', 1, $ledger_type_cashbank) . "
Cash / Bank Account";
+ echo form_checkbox('ledger_type_cashbank', 1, $ledger_type_cashbank) . "
Bank or Cash Account";
echo "</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>";
diff --git a/system/application/views/ledger/edit.php
b/system/application/views/ledger/edit.php
index c54cca9..a9057c1 100644
--- a/system/application/views/ledger/edit.php
+++ b/system/application/views/ledger/edit.php
@@ -26,7 +26,7 @@
echo "<p>";
echo "<span id=\"tooltip-target-2\">";
- echo form_checkbox('ledger_type_cashbank', 1, $ledger_type_cashbank) . "
Cash / Bank Account";
+ echo form_checkbox('ledger_type_cashbank', 1, $ledger_type_cashbank) . "
Bank or Cash Account";
echo "</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>";
commit 4f2d67a18dee6cad9e1e8838569de032ee50a70f
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 26 11:32:53 2011 +0530
Receipt and Payment vouchers must have one non Bank or Cash A/C
- Use Contra Vouchers if it has only Bank or Cash 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 2602ac2..5a78a29 100644
--- a/system/application/controllers/voucher.php
+++ b/system/application/controllers/voucher.php
@@ -361,6 +361,7 @@ class Voucher extends Controller {
$dr_total = 0;
$cr_total = 0;
$bank_cash_present = FALSE; /* Whether atleast one Ledger A/C is Bank or Cash A/C */
+ $non_bank_cash_present = FALSE; /* Whether atleast one Ledger A/C is NOT a Bank or
Cash A/C */
foreach ($data_all_ledger_dc as $id => $ledger_data)
{
if ($data_all_ledger_id[$id] < 1)
@@ -383,12 +384,16 @@ class Voucher extends Controller {
{
$bank_cash_present = TRUE;
}
+ if ($valid_ledger->type != 'B')
+ $non_bank_cash_present = TRUE;
} else if ($voucher_type == 'payment')
{
if ($data_all_ledger_dc[$id] == 'C' && $valid_ledger->type ==
'B')
{
$bank_cash_present = TRUE;
}
+ if ($valid_ledger->type != 'B')
+ $non_bank_cash_present = TRUE;
} else if ($voucher_type == 'contra')
{
if ($valid_ledger->type != 'B')
@@ -434,6 +439,12 @@ class Voucher extends Controller {
$this->template->load('template', 'voucher/add', $data);
return;
}
+ if ( ! $non_bank_cash_present)
+ {
+ $this->messages->add('Use Contra Vouchers if it affects only Bank or Cash
A/C\'s.', 'error');
+ $this->template->load('template', 'voucher/add', $data);
+ return;
+ }
} else if ($voucher_type == 'payment')
{
if ( ! $bank_cash_present)
@@ -442,6 +453,12 @@ class Voucher extends Controller {
$this->template->load('template', 'voucher/add', $data);
return;
}
+ if ( ! $non_bank_cash_present)
+ {
+ $this->messages->add('Use Contra Vouchers if it affects only Bank or Cash
A/C\'s.', 'error');
+ $this->template->load('template', 'voucher/add', $data);
+ return;
+ }
}
/* Adding main voucher */
@@ -738,6 +755,7 @@ class Voucher extends Controller {
$dr_total = 0;
$cr_total = 0;
$bank_cash_present = FALSE; /* Whether atleast one Ledger A/C is Bank or Cash A/C */
+ $non_bank_cash_present = FALSE; /* Whether atleast one Ledger A/C is NOT a Bank or
Cash A/C */
foreach ($data_all_ledger_dc as $id => $ledger_data)
{
if ($data_all_ledger_id[$id] < 1)
@@ -760,12 +778,16 @@ class Voucher extends Controller {
{
$bank_cash_present = TRUE;
}
+ if ($valid_ledger->type != 'B')
+ $non_bank_cash_present = TRUE;
} else if ($voucher_type == 'payment')
{
if ($data_all_ledger_dc[$id] == 'C' && $valid_ledger->type ==
'B')
{
$bank_cash_present = TRUE;
}
+ if ($valid_ledger->type != 'B')
+ $non_bank_cash_present = TRUE;
} else if ($voucher_type == 'contra')
{
if ($valid_ledger->type != 'B')
@@ -810,6 +832,12 @@ class Voucher extends Controller {
$this->template->load('template', 'voucher/edit', $data);
return;
}
+ if ( ! $non_bank_cash_present)
+ {
+ $this->messages->add('Use Contra Vouchers if it affects only Bank or Cash
A/C\'s.', 'error');
+ $this->template->load('template', 'voucher/edit', $data);
+ return;
+ }
} else if ($voucher_type == 'payment')
{
if ( ! $bank_cash_present)
@@ -818,6 +846,12 @@ class Voucher extends Controller {
$this->template->load('template', 'voucher/edit', $data);
return;
}
+ if ( ! $non_bank_cash_present)
+ {
+ $this->messages->add('Use Contra Vouchers if it affects only Bank or Cash
A/C\'s.', 'error');
+ $this->template->load('template', 'voucher/edit', $data);
+ return;
+ }
}
/* Updating main voucher */
commit d18febd3253c8d32170af4ed6411f70828b904da
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 26 11:11:43 2011 +0530
Fixed account carry forward errors
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 d6794b9..50f0939 100644
--- a/system/application/controllers/setting.php
+++ b/system/application/controllers/setting.php
@@ -357,36 +357,49 @@ class Setting extends Controller {
if ($data_database_port == "")
$data_database_port = "3306";
- /* Setting database */
- $dsn =
"mysql://${data_database_username}:${data_database_password}@${data_database_host}:${data_database_port}/${data_database_name}";
- $newacc = $this->load->database($dsn, TRUE);
- $conn_error = $newacc->_error_message();
-
- /* Creating database if it does not exist */
+ /* Creating account database */
if ($this->input->post('create_database', TRUE) == "1")
{
- if ((substr($conn_error, 0, 16) == "Unknown database"))
+ $new_link = @mysql_connect($data_database_host . ':' . $data_database_port,
$data_database_username, $data_database_password);
+ if ($new_link)
{
- if ($newacc->query("CREATE DATABASE " .
mysql_real_escape_string($data_database_name)))
+ /* Check if database already exists */
+ $db_selected = mysql_select_db($data_database_name, $new_link);
+ if ($db_selected) {
+ mysql_close($new_link);
+ $this->messages->add('Database already exists.', 'error');
+ $this->template->load('template', 'setting/cf', $data);
+ return;
+ }
+
+ /* Creating account database */
+ $db_create_q = 'CREATE DATABASE ' .
mysql_real_escape_string($data_database_name);
+ if (mysql_query($db_create_q, $new_link))
{
$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('Failed to create account database.',
'error');
+ $this->messages->add('Error creating account database. ' .
mysql_error(), 'error');
$this->template->load('template', 'setting/cf', $data);
return;
}
+ mysql_close($new_link);
+ } else {
+ $this->messages->add('Error connecting to database. ' . mysql_error(),
'error');
+ $this->template->load('template', 'setting/cf', $data);
+ return;
}
}
+ /* Setting database */
+ $dsn =
"mysql://${data_database_username}:${data_database_password}@${data_database_host}:${data_database_port}/${data_database_name}";
+ $newacc = $this->load->database($dsn, TRUE);
+
if ( ! $newacc->conn_id)
{
$this->messages->add('Error connecting to database.',
'error');
$this->template->load('template', 'setting/cf', $data);
return;
- } else if ($conn_error != "") {
+ } else if ($newacc->_error_message() != "") {
$this->messages->add('Error connecting to database. ' .
$newacc->_error_message(), 'error');
$this->template->load('template', 'setting/cf', $data);
return;
commit 01898ee93aa4a3be96522ae6ac5b17cebd527290
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Wed Jan 26 11:02:49 2011 +0530
Fixed account creation errors
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 9b16864..0547e10 100644
--- a/system/application/controllers/admin/create.php
+++ b/system/application/controllers/admin/create.php
@@ -231,36 +231,49 @@ class Create extends Controller {
if ($data_database_port == "")
$data_database_port = "3306";
- /* Setting database */
- $dsn =
"mysql://${data_database_username}:${data_database_password}@${data_database_host}:${data_database_port}/${data_database_name}";
- $newacc = $this->load->database($dsn, TRUE);
- $conn_error = $newacc->_error_message();
-
- /* Creating database if it does not exist */
+ /* Creating account database */
if ($this->input->post('create_database', TRUE) == "1")
{
- if ((substr($conn_error, 0, 16) == "Unknown database"))
+ $new_link = @mysql_connect($data_database_host . ':' . $data_database_port,
$data_database_username, $data_database_password);
+ if ($new_link)
{
- if ($newacc->query("CREATE DATABASE " .
mysql_real_escape_string($data_database_name)))
+ /* Check if database already exists */
+ $db_selected = mysql_select_db($data_database_name, $new_link);
+ if ($db_selected) {
+ mysql_close($new_link);
+ $this->messages->add('Database already exists.', 'error');
+ $this->template->load('admin_template', 'admin/create',
$data);
+ return;
+ }
+
+ /* Creating account database */
+ $db_create_q = 'CREATE DATABASE ' .
mysql_real_escape_string($data_database_name);
+ if (mysql_query($db_create_q, $new_link))
{
$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('Failed to create account database.',
'error');
+ $this->messages->add('Error creating account database. ' .
mysql_error(), 'error');
$this->template->load('admin_template', 'admin/create',
$data);
return;
}
+ mysql_close($new_link);
+ } else {
+ $this->messages->add('Error connecting to database. ' . mysql_error(),
'error');
+ $this->template->load('admin_template', 'admin/create',
$data);
+ return;
}
}
+ /* Setting database */
+ $dsn =
"mysql://${data_database_username}:${data_database_password}@${data_database_host}:${data_database_port}/${data_database_name}";
+ $newacc = $this->load->database($dsn, TRUE);
+
if ( ! $newacc->conn_id)
{
$this->messages->add('Error connecting to database.',
'error');
$this->template->load('admin_template', 'admin/create',
$data);
return;
- } else if ($conn_error != "") {
+ } else if ($newacc->_error_message() != "") {
$this->messages->add('Error connecting to database. ' .
$newacc->_error_message(), 'error');
$this->template->load('admin_template', 'admin/create',
$data);
return;
commit db672e72e7d22b077a3d68c9746cbb74370483eb
Author: Prashant P Shah <pshah.mumbai(a)gmail.com>
Date: Mon Jan 24 22:33:45 2011 +0530
Added default gmail settings to FAQ
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 381741e..3852a76 100644
--- a/system/application/views/help/index.php
+++ b/system/application/views/help/index.php
@@ -14,6 +14,7 @@
<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>
+ <li><a href="#email-2" class="anchor-link-a">How do send
vouchers using gmail ?</a></li>
</ul>
</li>
</ul>
@@ -50,3 +51,14 @@
<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>
+<div class="qa-section" id="email-2">
+ <a name="email-2"></a>
+ <div class="qa-question">Q. How do I send vouchers using gmail
?</div>
+ <div class="qa-answer">You need to use the following gmail settings in
Settings > Email Settings<br /><br />
+ Email protocol : smtp<br />
+ Hostname : ssl://smtp.googlemail.com<br />
+ Port : 465<br />
+ Email username : your-username(a)gmail.com<br />
+ Email Password : your-password<br />
+ </div>
+</div>