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(
+