commitall
This commit is contained in:
333
application/libraries/Accounting copy 2.php
Normal file
333
application/libraries/Accounting copy 2.php
Normal file
@@ -0,0 +1,333 @@
|
||||
<?php
|
||||
class Accounting
|
||||
{
|
||||
private $ci;
|
||||
private $db;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->ci = &get_instance();
|
||||
$this->db = $this->ci->load->database('accounting', TRUE);
|
||||
$t = "select * from admin_menu where parent_id=22 and page_link='account/defaults'";
|
||||
$r = $this->ci->db->query($t);
|
||||
if ($r->num_rows() == 0) {
|
||||
$t = "INSERT INTO `admin_menu` (`id`, `menu_name`, `parent_id`, `order_number`, `inactive_icon`, `active_icon`, `is_active`, `page_link`, `created_on`) VALUES (NULL, 'Accounting Settings', '22', '6', ' ', ' ', 'yes', 'account/defaults', '" . date("y-m-d h:i:s") . "');";
|
||||
$q = $this->ci->db->query($t);
|
||||
}
|
||||
}
|
||||
function pre($Obj)
|
||||
{
|
||||
echo "<pre>";
|
||||
print_r($Obj);
|
||||
echo "</pre>";
|
||||
}
|
||||
|
||||
function init()
|
||||
{
|
||||
$tbl_acgroups = "CREATE TABLE IF NOT EXISTS `tbl_acgroups` (
|
||||
`acgroup_id` INT(11) NOT NULL,
|
||||
`acgroup_code` VARCHAR(250) NOT NULL,
|
||||
`acgroup_name` VARCHAR(250) NOT NULL,
|
||||
`posting_side` VARCHAR(20) NOT NULL,
|
||||
`created_on` DATE NOT NULL,
|
||||
`created_by` VARCHAR(250) NOT NULL,
|
||||
`remarks` TEXT NOT NULL,
|
||||
`status` INT(11) NOT NULL,
|
||||
`display_order` INT(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
";
|
||||
$this->db->query($tbl_acgroups);
|
||||
}
|
||||
|
||||
function showFeeTypeMappingOption($default = "")
|
||||
{
|
||||
// $Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 3 AND tbl_accounts.status<>1)")->result();
|
||||
// $Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 3 AND tbl_accounts.status<>1)")->result();
|
||||
$Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 3)")->result();
|
||||
|
||||
// $Accategoreies = $this->db->query("select ac.* from tbl_accategories ac JOIN tbl_accounts acc ON acc.accategory_id = ac.accategory_id WHERE ac.acgroup_id = 3")->result();
|
||||
foreach ($Accategoreies as $AccountCategory) {
|
||||
$AccountCategory->Accounts = $this->db->query("select * from tbl_accounts where accategory_id='$AccountCategory->accategory_id'")->result();
|
||||
}
|
||||
// echo '<pre>';
|
||||
// print_r($Accategoreies);
|
||||
// die();
|
||||
?>
|
||||
<div class="form-group mt-4 mb-0">
|
||||
<label class="has-float-label">
|
||||
<select class="form-control" name="account_id" id="account_id_selector" required>
|
||||
<option value="">Select Default Account</option>
|
||||
<?php foreach ($Accategoreies as $AccountCategory) : ?>
|
||||
<optgroup label="<?php echo $AccountCategory->accategory_name; ?>">
|
||||
<?php foreach ($AccountCategory->Accounts as $Account) : ?>
|
||||
<option value="<?php echo $Account->account_id; ?>" <?php if ($default != "" && $default == $Account->account_name) : ?>SELECTED<?php endif; ?>><?php echo $Account->account_name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</select>
|
||||
<span>Select Default Account</span>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
function updateFeeTypeAccountMapping($feetype_id, $account_id)
|
||||
{
|
||||
$t = "CREATE TABLE IF NOT EXISTS `tbl_accmaping` (
|
||||
`accmaping_id` int(11) NOT NULL,
|
||||
`bbmodel` varchar(35) NOT NULL,
|
||||
`bbpk` int(11) NOT NULL,
|
||||
`account_id` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
";
|
||||
$this->db->query($t);
|
||||
$q = $this->db->query("SELECT * FROM tbl_accmaping WHERE bbmodel='fee_types' AND bbpk='$feetype_id'");
|
||||
if ($q->num_rows() > 0) {
|
||||
$q = $this->db->query("UPDATE tbl_accmaping SET account_id='$account_id' WHERE bbmodel='fee_types' AND bbpk='$feetype_id'");
|
||||
} else {
|
||||
$q = $this->db->query("INSERT INTO tbl_accmaping (account_id, bbmodel, bbpk) VALUES ('$account_id', 'fee_types', '$feetype_id')");
|
||||
}
|
||||
}
|
||||
function fetchMappedAccount($model, $bbpk)
|
||||
{
|
||||
$q = $this->db->query("SELECT * FROM tbl_accounts WHERE account_id=(SELECT account_id FROM tbl_accmaping WHERE bbmodel='$model' AND bbpk='$bbpk')");
|
||||
|
||||
if ($q->num_rows() > 0) {
|
||||
return $q->row()->account_name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function showExpenseTypeMappingOption($default = "")
|
||||
{
|
||||
// $Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 3 AND tbl_accounts.status<>1)")->result();
|
||||
// $Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 3 AND tbl_accounts.status<>1)")->result();
|
||||
$Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 4)")->result();
|
||||
|
||||
// $Accategoreies = $this->db->query("select ac.* from tbl_accategories ac JOIN tbl_accounts acc ON acc.accategory_id = ac.accategory_id WHERE ac.acgroup_id = 3")->result();
|
||||
foreach ($Accategoreies as $AccountCategory) {
|
||||
$AccountCategory->Accounts = $this->db->query("select * from tbl_accounts where accategory_id='$AccountCategory->accategory_id'")->result();
|
||||
}
|
||||
// echo '<pre>';
|
||||
// print_r($Accategoreies);
|
||||
// die();
|
||||
?>
|
||||
<div class="form-group mt-4 mb-0">
|
||||
<label class="has-float-label">
|
||||
<select class="form-control" name="account_id" id="account_id_selector" required>
|
||||
<option value="">Select Default Account</option>
|
||||
<?php foreach ($Accategoreies as $AccountCategory) : ?>
|
||||
<optgroup label="<?php echo $AccountCategory->accategory_name; ?>">
|
||||
<?php foreach ($AccountCategory->Accounts as $Account) : ?>
|
||||
<option value="<?php echo $Account->account_id; ?>" <?php if ($default != "" && $default == $Account->account_name) : ?>SELECTED<?php endif; ?>><?php echo $Account->account_name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</select>
|
||||
<span>Select Default Account</span>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function updateExpenseTypeAccountMapping($feetype_id, $account_id)
|
||||
{
|
||||
$t = "CREATE TABLE IF NOT EXISTS `tbl_accmaping` (
|
||||
`accmaping_id` int(11) NOT NULL,
|
||||
`bbmodel` varchar(35) NOT NULL,
|
||||
`bbpk` int(11) NOT NULL,
|
||||
`account_id` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
";
|
||||
$this->db->query($t);
|
||||
$q = $this->db->query("SELECT * FROM tbl_accmaping WHERE bbmodel='expense_types' AND bbpk='$feetype_id'");
|
||||
if ($q->num_rows() > 0) {
|
||||
$q = $this->db->query("UPDATE tbl_accmaping SET account_id='$account_id' WHERE bbmodel='expense_types' AND bbpk='$feetype_id'");
|
||||
} else {
|
||||
$q = $this->db->query("INSERT INTO tbl_accmaping (account_id, bbmodel, bbpk) VALUES ('$account_id', 'expense_types', '$feetype_id')");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function userCreateAcc($userId, $userType, $username, $createdOn)
|
||||
{
|
||||
$userAcc = $this->db->query("select * from tbl_accounts where account_code = '$userId'")->result();
|
||||
print_r($userAcc);
|
||||
|
||||
if (empty($userAcc)) {
|
||||
if ($userType == 'student') {
|
||||
$accategory_id = 64;
|
||||
} else {
|
||||
$accategory_id = 65;
|
||||
}
|
||||
$td['account_code'] = $userId;
|
||||
$td['account_name'] = $username;
|
||||
$td['accategory_id'] = $accategory_id;
|
||||
$td['created_on'] = $createdOn;
|
||||
$td['created_by'] = 'Admin';
|
||||
$td['status'] = 1;
|
||||
|
||||
// dd($td);
|
||||
|
||||
$insert = $this->db->insert('tbl_accounts', $td);
|
||||
|
||||
if ($insert) {
|
||||
return 'success';
|
||||
} else {
|
||||
return 'error';
|
||||
}
|
||||
} else {
|
||||
return 'already_existed';
|
||||
}
|
||||
// return $userId . ' = ' . $userType;
|
||||
}
|
||||
|
||||
function fetchAccountInfo($userId)
|
||||
{
|
||||
$userAcc = $this->db->query("select * from tbl_accounts where account_code = '$userId'")->row_array();
|
||||
|
||||
return $userAcc;
|
||||
}
|
||||
|
||||
function createVoucher($userId, $userType)
|
||||
{
|
||||
$userAcc = $this->db->query("select * from tbl_vouchers where reference_id = $userId")->result();
|
||||
|
||||
if (empty($userAcc)) {
|
||||
|
||||
$voucher = $this->db->query("select * from tbl_vouchers")->result();
|
||||
$voucher_type = $this->db->query("select * from tbl_vouchers WHERE voucher_type = 'Journal'")->result();
|
||||
$voucherType = $this->db->query("select * from tbl_vouchertypes WHERE voucher_type = 'Journal'")->row_array();
|
||||
$fiscalyear = $this->db->query("select * from tbl_fiscalyear WHERE status = 1")->row_array();
|
||||
$branches = $this->db->query("select * from tbl_branches WHERE status = 1")->row_array();
|
||||
|
||||
|
||||
$td['voucher_no'] = count($voucher) + 1;
|
||||
$td['voucher_ref'] = $voucherType['voucher_alias'] . '' . (count($voucher_type) + 1);
|
||||
$td['voucher_date'] = date('Y-m-d');
|
||||
$td['voucher_state'] = 'Entered';
|
||||
$td['voucher_type'] = 'Journal';
|
||||
$td['fiscalyear_id'] = $fiscalyear['fiscalyear_id'];
|
||||
$td['branch_id'] = $branches['branch_id'];
|
||||
$td['reference_id'] = $userId;
|
||||
$td['reference_type'] = $userType;
|
||||
$td['created_by'] = $_SESSION['admin_name'];
|
||||
$td['created_on'] = date('Y-m-d H:m:s');
|
||||
$td['remarks'] = '';
|
||||
$td['status'] = 1;
|
||||
|
||||
// dd($td);
|
||||
// echo '<pre>';
|
||||
// print_r($td);
|
||||
|
||||
$insert = $this->db->insert('tbl_vouchers', $td);
|
||||
|
||||
if ($insert) {
|
||||
return 'success';
|
||||
} else {
|
||||
return 'error';
|
||||
}
|
||||
} else {
|
||||
return 'already_existed';
|
||||
}
|
||||
// return $userId . ' = ' . $userType;
|
||||
}
|
||||
|
||||
function fetchVoucherInfo($userId)
|
||||
{
|
||||
$userAcc = $this->db->query("select * from tbl_vouchers where reference_id = $userId")->row_array();
|
||||
|
||||
return $userAcc;
|
||||
}
|
||||
|
||||
function voucherEntry($userId, $theUserId, $course_fee, $scholarship)
|
||||
{
|
||||
$userAcc = $this->db->query("select * from tbl_vouchers where reference_id = $userId")->result();
|
||||
|
||||
if (!empty($userAcc)) {
|
||||
|
||||
$voucher = $this->db->query("select * from tbl_vouchers WHERE reference_id = $userId AND reference_type = 'student'")->row_array();
|
||||
$fiscalyear = $this->db->query("select * from tbl_fiscalyear WHERE status = 1")->row_array();
|
||||
$branches = $this->db->query("select * from tbl_branches WHERE status = 1")->row_array();
|
||||
|
||||
$entry = !empty($scholarship) ? 3 : 2;
|
||||
|
||||
$fee_amt = $course_fee['amount'];
|
||||
$dr = 0;
|
||||
$cr = 0;
|
||||
|
||||
for ($i = 0; $i < $entry; $i++) {
|
||||
|
||||
if ($entry == 3) {
|
||||
if ($i == 0) {
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_name = '" . $course_fee['feetype_name'] . "' AND status = 1")->row_array();
|
||||
$dr = $fee_amt;
|
||||
$cr = 0;
|
||||
} else if ($i == 1) {
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_name = 'Scholarship' AND status = 1")->row_array();
|
||||
$scholarship_amt = round(($scholarship['scholarship_discount'] / 100) * $fee_amt);
|
||||
$cr = $scholarship_amt;
|
||||
$dr = 0;
|
||||
} else {
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_code = '$theUserId' AND status = 1")->row_array();
|
||||
$scholarship_amt = round(($scholarship['scholarship_discount'] / 100) * $fee_amt);
|
||||
$dr = 0;
|
||||
$cr = $fee_amt - $scholarship_amt;
|
||||
}
|
||||
} else {
|
||||
if ($i == 0) {
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_name = '" . $course_fee['feetype_name'] . "' AND status = 1")->row_array();
|
||||
$dr = $fee_amt;
|
||||
$cr = 0;
|
||||
} else {
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_code = '$theUserId' AND status = 1")->row_array();
|
||||
$cr = $fee_amt;
|
||||
$dr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$td['voucher_id'] = $voucher['voucher_id'];
|
||||
$td['entry_no'] = $i + 1;
|
||||
$td['transaction_date'] = date('Y-m-d');
|
||||
$td['account_id'] = $account['account_id'];
|
||||
$td['narration'] = $course_fee['fee_values'] . ' ( ' . $course_fee['feetype_name'] . ' )';
|
||||
$td['dr'] = $dr;
|
||||
$td['cr'] = $cr;
|
||||
$td['branch_id'] = $branches['branch_id'];
|
||||
$td['fiscalyear_id'] = $fiscalyear['fiscalyear_id'];
|
||||
$td['batch_id'] = $course_fee['batch_id'];
|
||||
$td['course_id'] = $course_fee['course_id'];
|
||||
$td['course_fee_id'] = $course_fee['id'];
|
||||
$td['student_id'] = $userId;
|
||||
$td['created_on'] = date('Y-m-d');
|
||||
$td['created_by'] = $_SESSION['admin_name'];
|
||||
$td['remarks'] = !empty($scholarship) ? $scholarship['scholarship_discount'] . ' % scholarship on ' . $course_fee['feetype_name'] : '';
|
||||
$td['status'] = 1;
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($td);
|
||||
|
||||
$this->db->insert('tbl_voucherdetails', $td);
|
||||
}
|
||||
} else {
|
||||
return 'already_existed';
|
||||
}
|
||||
// return $userId . ' = ' . $userType;
|
||||
}
|
||||
|
||||
function removeVoucherEntry($userId, $course_fee)
|
||||
{
|
||||
$coondition_data = array(
|
||||
'student_id' => $userId,
|
||||
'course_fee_id' => $course_fee['id'],
|
||||
'batch_id' => $course_fee['batch_id']
|
||||
);
|
||||
$this->db->where($coondition_data);
|
||||
$this->db->delete('tbl_voucherdetails');
|
||||
}
|
||||
}
|
480
application/libraries/Accounting copy.php
Normal file
480
application/libraries/Accounting copy.php
Normal file
@@ -0,0 +1,480 @@
|
||||
<?php
|
||||
class Accounting
|
||||
{
|
||||
private $ci;
|
||||
private $db;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->ci = &get_instance();
|
||||
$this->db = $this->ci->load->database('accounting', TRUE);
|
||||
$t = "select * from admin_menu where parent_id=22 and page_link='account/defaults'";
|
||||
$r = $this->ci->db->query($t);
|
||||
if ($r->num_rows() == 0) {
|
||||
$t = "INSERT INTO `admin_menu` (`id`, `menu_name`, `parent_id`, `order_number`, `inactive_icon`, `active_icon`, `is_active`, `page_link`, `created_on`) VALUES (NULL, 'Accounting Settings', '22', '6', ' ', ' ', 'yes', 'account/defaults', '" . date("y-m-d h:i:s") . "');";
|
||||
$q = $this->ci->db->query($t);
|
||||
}
|
||||
}
|
||||
function pre($Obj)
|
||||
{
|
||||
echo "<pre>";
|
||||
print_r($Obj);
|
||||
echo "</pre>";
|
||||
}
|
||||
|
||||
function init()
|
||||
{
|
||||
$tbl_acgroups = "CREATE TABLE IF NOT EXISTS `tbl_acgroups` (
|
||||
`acgroup_id` INT(11) NOT NULL,
|
||||
`acgroup_code` VARCHAR(250) NOT NULL,
|
||||
`acgroup_name` VARCHAR(250) NOT NULL,
|
||||
`posting_side` VARCHAR(20) NOT NULL,
|
||||
`created_on` DATE NOT NULL,
|
||||
`created_by` VARCHAR(250) NOT NULL,
|
||||
`remarks` TEXT NOT NULL,
|
||||
`status` INT(11) NOT NULL,
|
||||
`display_order` INT(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
";
|
||||
$this->db->query($tbl_acgroups);
|
||||
}
|
||||
|
||||
function showFeeTypeMappingOption($default = "")
|
||||
{
|
||||
// $Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 3 AND tbl_accounts.status<>1)")->result();
|
||||
// $Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 3 AND tbl_accounts.status<>1)")->result();
|
||||
$Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 3)")->result();
|
||||
|
||||
// $Accategoreies = $this->db->query("select ac.* from tbl_accategories ac JOIN tbl_accounts acc ON acc.accategory_id = ac.accategory_id WHERE ac.acgroup_id = 3")->result();
|
||||
foreach ($Accategoreies as $AccountCategory) {
|
||||
$AccountCategory->Accounts = $this->db->query("select * from tbl_accounts where accategory_id='$AccountCategory->accategory_id'")->result();
|
||||
}
|
||||
// echo '<pre>';
|
||||
// print_r($Accategoreies);
|
||||
// die();
|
||||
?>
|
||||
<div class="form-group mt-4 mb-0">
|
||||
<label class="has-float-label">
|
||||
<select class="form-control" name="account_id" id="account_id_selector" required>
|
||||
<option value="">Select Default Account</option>
|
||||
<?php foreach ($Accategoreies as $AccountCategory) : ?>
|
||||
<optgroup label="<?php echo $AccountCategory->accategory_name; ?>">
|
||||
<?php foreach ($AccountCategory->Accounts as $Account) : ?>
|
||||
<option value="<?php echo $Account->account_id; ?>" <?php if ($default != "" && $default == $Account->account_name) : ?>SELECTED<?php endif; ?>><?php echo $Account->account_name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</select>
|
||||
<span>Select Default Account</span>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
function updateFeeTypeAccountMapping($feetype_id, $account_id)
|
||||
{
|
||||
$t = "CREATE TABLE IF NOT EXISTS `tbl_accmaping` (
|
||||
`accmaping_id` int(11) NOT NULL,
|
||||
`bbmodel` varchar(35) NOT NULL,
|
||||
`bbpk` int(11) NOT NULL,
|
||||
`account_id` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
";
|
||||
$this->db->query($t);
|
||||
$q = $this->db->query("SELECT * FROM tbl_accmaping WHERE bbmodel='fee_types' AND bbpk='$feetype_id'");
|
||||
if ($q->num_rows() > 0) {
|
||||
$q = $this->db->query("UPDATE tbl_accmaping SET account_id='$account_id' WHERE bbmodel='fee_types' AND bbpk='$feetype_id'");
|
||||
} else {
|
||||
$q = $this->db->query("INSERT INTO tbl_accmaping (account_id, bbmodel, bbpk) VALUES ('$account_id', 'fee_types', '$feetype_id')");
|
||||
}
|
||||
}
|
||||
function fetchMappedAccount($model, $bbpk)
|
||||
{
|
||||
$q = $this->db->query("SELECT * FROM tbl_accounts WHERE account_id=(SELECT account_id FROM tbl_accmaping WHERE bbmodel='$model' AND bbpk='$bbpk')");
|
||||
|
||||
if ($q->num_rows() > 0) {
|
||||
return $q->row()->account_name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function showExpenseTypeMappingOption($default = "")
|
||||
{
|
||||
// $Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 3 AND tbl_accounts.status<>1)")->result();
|
||||
// $Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 3 AND tbl_accounts.status<>1)")->result();
|
||||
$Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 4)")->result();
|
||||
|
||||
// $Accategoreies = $this->db->query("select ac.* from tbl_accategories ac JOIN tbl_accounts acc ON acc.accategory_id = ac.accategory_id WHERE ac.acgroup_id = 3")->result();
|
||||
foreach ($Accategoreies as $AccountCategory) {
|
||||
$AccountCategory->Accounts = $this->db->query("select * from tbl_accounts where accategory_id='$AccountCategory->accategory_id'")->result();
|
||||
}
|
||||
// echo '<pre>';
|
||||
// print_r($Accategoreies);
|
||||
// die();
|
||||
?>
|
||||
<div class="form-group mt-4 mb-0">
|
||||
<label class="has-float-label">
|
||||
<select class="form-control" name="account_id" id="account_id_selector" required>
|
||||
<option value="">Select Default Account</option>
|
||||
<?php foreach ($Accategoreies as $AccountCategory) : ?>
|
||||
<optgroup label="<?php echo $AccountCategory->accategory_name; ?>">
|
||||
<?php foreach ($AccountCategory->Accounts as $Account) : ?>
|
||||
<option value="<?php echo $Account->account_id; ?>" <?php if ($default != "" && $default == $Account->account_name) : ?>SELECTED<?php endif; ?>><?php echo $Account->account_name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</select>
|
||||
<span>Select Default Account</span>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function updateExpenseTypeAccountMapping($feetype_id, $account_id)
|
||||
{
|
||||
$t = "CREATE TABLE IF NOT EXISTS `tbl_accmaping` (
|
||||
`accmaping_id` int(11) NOT NULL,
|
||||
`bbmodel` varchar(35) NOT NULL,
|
||||
`bbpk` int(11) NOT NULL,
|
||||
`account_id` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
";
|
||||
$this->db->query($t);
|
||||
$q = $this->db->query("SELECT * FROM tbl_accmaping WHERE bbmodel='expense_types' AND bbpk='$feetype_id'");
|
||||
if ($q->num_rows() > 0) {
|
||||
$q = $this->db->query("UPDATE tbl_accmaping SET account_id='$account_id' WHERE bbmodel='expense_types' AND bbpk='$feetype_id'");
|
||||
} else {
|
||||
$q = $this->db->query("INSERT INTO tbl_accmaping (account_id, bbmodel, bbpk) VALUES ('$account_id', 'expense_types', '$feetype_id')");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function userCreateAcc($userId, $userType, $username, $createdOn)
|
||||
{
|
||||
$userAcc = $this->db->query("select * from tbl_accounts where account_code = '$userId'")->result();
|
||||
print_r($userAcc);
|
||||
|
||||
if (empty($userAcc)) {
|
||||
if ($userType == 'student') {
|
||||
$accategory_id = 64;
|
||||
} else {
|
||||
$accategory_id = 65;
|
||||
}
|
||||
$td['account_code'] = $userId;
|
||||
$td['account_name'] = $username;
|
||||
$td['accategory_id'] = $accategory_id;
|
||||
$td['created_on'] = $createdOn;
|
||||
$td['created_by'] = 'Admin';
|
||||
$td['status'] = 1;
|
||||
|
||||
// dd($td);
|
||||
|
||||
$insert = $this->db->insert('tbl_accounts', $td);
|
||||
|
||||
if ($insert) {
|
||||
return 'success';
|
||||
} else {
|
||||
return 'error';
|
||||
}
|
||||
} else {
|
||||
return 'already_existed';
|
||||
}
|
||||
// return $userId . ' = ' . $userType;
|
||||
}
|
||||
|
||||
function fetchAccountInfo($userId)
|
||||
{
|
||||
$userAcc = $this->db->query("select * from tbl_accounts where account_code = '$userId'")->row_array();
|
||||
|
||||
return $userAcc;
|
||||
}
|
||||
|
||||
function createVoucherId($userId, $course_fee_id, $userType)
|
||||
{
|
||||
$userAcc = $this->db->query("select * from tbl_vouchers where user_id = $userId AND course_fee_id = $course_fee_id")->row_array();
|
||||
|
||||
if (empty($userAcc)) {
|
||||
|
||||
$voucher = $this->db->query("select * from tbl_vouchers")->result();
|
||||
$voucher_type = $this->db->query("select * from tbl_vouchers WHERE voucher_type = 'Journal'")->result();
|
||||
$voucherType = $this->db->query("select * from tbl_vouchertypes WHERE voucher_type = 'Journal'")->row_array();
|
||||
$fiscalyear = $this->db->query("select * from tbl_fiscalyear WHERE status = 1")->row_array();
|
||||
$branches = $this->db->query("select * from tbl_branches WHERE status = 1")->row_array();
|
||||
|
||||
|
||||
$td['voucher_no'] = count($voucher) + 1;
|
||||
$td['voucher_ref'] = $voucherType['voucher_alias'] . '' . (count($voucher_type) + 1);
|
||||
$td['voucher_date'] = date('Y-m-d');
|
||||
$td['voucher_state'] = 'Entered';
|
||||
$td['voucher_type'] = 'Journal';
|
||||
$td['fiscalyear_id'] = $fiscalyear['fiscalyear_id'];
|
||||
$td['branch_id'] = $branches['branch_id'];
|
||||
$td['user_id'] = $userId;
|
||||
$td['course_fee_id'] = $course_fee_id;
|
||||
$td['reference_type'] = $userType;
|
||||
$td['created_by'] = $_SESSION['admin_name'];
|
||||
$td['created_on'] = date('Y-m-d H:m:s');
|
||||
$td['remarks'] = '';
|
||||
$td['status'] = 1;
|
||||
|
||||
// dd($td);
|
||||
// echo '<pre>';
|
||||
// print_r($td);
|
||||
|
||||
$insert = $this->db->insert('tbl_vouchers', $td);
|
||||
|
||||
if ($insert) {
|
||||
return $this->db->insert_id();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return $userAcc['voucher_id'];
|
||||
}
|
||||
}
|
||||
|
||||
function fetchVoucherInfo($userId)
|
||||
{
|
||||
$userAcc = $this->db->query("select * from tbl_vouchers where reference_id = $userId")->row_array();
|
||||
|
||||
return $userAcc;
|
||||
}
|
||||
|
||||
// function voucherEntry($userId, $theUserId, $course_fee, $scholarship)
|
||||
// {
|
||||
// $userAcc = $this->db->query("select * from tbl_vouchers where reference_id = $userId")->result();
|
||||
|
||||
// if (!empty($userAcc)) {
|
||||
|
||||
// $voucher = $this->db->query("select * from tbl_vouchers WHERE reference_id = $userId AND reference_type = 'student'")->row_array();
|
||||
// $fiscalyear = $this->db->query("select * from tbl_fiscalyear WHERE status = 1")->row_array();
|
||||
// $branches = $this->db->query("select * from tbl_branches WHERE status = 1")->row_array();
|
||||
|
||||
// $entry = !empty($scholarship) ? 3 : 2;
|
||||
|
||||
// $fee_amt = $course_fee['amount'];
|
||||
// $dr = 0;
|
||||
// $cr = 0;
|
||||
|
||||
// for ($i = 0; $i < $entry; $i++) {
|
||||
|
||||
// if ($entry == 3) {
|
||||
// if ($i == 0) {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_name = '" . $course_fee['feetype_name'] . "' AND status = 1")->row_array();
|
||||
// $dr = $fee_amt;
|
||||
// $cr = 0;
|
||||
// } else if ($i == 1) {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_name = 'Scholarship' AND status = 1")->row_array();
|
||||
// $scholarship_amt = round(($scholarship['scholarship_discount'] / 100) * $fee_amt);
|
||||
// $cr = $scholarship_amt;
|
||||
// $dr = 0;
|
||||
// } else {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_code = '$theUserId' AND status = 1")->row_array();
|
||||
// $scholarship_amt = round(($scholarship['scholarship_discount'] / 100) * $fee_amt);
|
||||
// $dr = 0;
|
||||
// $cr = $fee_amt - $scholarship_amt;
|
||||
// }
|
||||
// } else {
|
||||
// if ($i == 0) {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_name = '" . $course_fee['feetype_name'] . "' AND status = 1")->row_array();
|
||||
// $dr = $fee_amt;
|
||||
// $cr = 0;
|
||||
// } else {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_code = '$theUserId' AND status = 1")->row_array();
|
||||
// $cr = $fee_amt;
|
||||
// $dr = 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
// $td['voucher_id'] = $voucher['voucher_id'];
|
||||
// $td['entry_no'] = $i + 1;
|
||||
// $td['transaction_date'] = date('Y-m-d');
|
||||
// $td['account_id'] = $account['account_id'];
|
||||
// $td['narration'] = $course_fee['fee_values'] . ' ( ' . $course_fee['feetype_name'] . ' )';
|
||||
// $td['dr'] = $dr;
|
||||
// $td['cr'] = $cr;
|
||||
// $td['branch_id'] = $branches['branch_id'];
|
||||
// $td['fiscalyear_id'] = $fiscalyear['fiscalyear_id'];
|
||||
// $td['batch_id'] = $course_fee['batch_id'];
|
||||
// $td['course_id'] = $course_fee['course_id'];
|
||||
// $td['course_fee_id'] = $course_fee['id'];
|
||||
// $td['student_id'] = $userId;
|
||||
// $td['created_on'] = date('Y-m-d');
|
||||
// $td['created_by'] = $_SESSION['admin_name'];
|
||||
// $td['remarks'] = !empty($scholarship) ? $scholarship['scholarship_discount'] . ' % scholarship on ' . $course_fee['feetype_name'] : '';
|
||||
// $td['status'] = 1;
|
||||
|
||||
// // echo '<pre>';
|
||||
// // print_r($td);
|
||||
|
||||
// $this->db->insert('tbl_voucherdetails', $td);
|
||||
// }
|
||||
// } else {
|
||||
|
||||
// $voucher = $this->db->query("select * from tbl_vouchers WHERE reference_id = $userId AND reference_type = 'student'")->row_array();
|
||||
|
||||
|
||||
// $this->db->select_max('voucher_id');
|
||||
// $query = $this->db->get('tbl_vouchers');
|
||||
// $res = $query->row_array();
|
||||
// $vid = $res['id'] + 1;
|
||||
|
||||
// $fiscalyear = $this->db->query("select * from tbl_fiscalyear WHERE status = 1")->row_array();
|
||||
// $branches = $this->db->query("select * from tbl_branches WHERE status = 1")->row_array();
|
||||
|
||||
// $entry = !empty($scholarship) ? 3 : 2;
|
||||
|
||||
// $fee_amt = $course_fee['amount'];
|
||||
// $dr = 0;
|
||||
// $cr = 0;
|
||||
|
||||
// for (
|
||||
// $i = 0;
|
||||
// $i < $entry;
|
||||
// $i++
|
||||
// ) {
|
||||
|
||||
// if ($entry == 3) {
|
||||
// if ($i == 0) {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_name = '" . $course_fee['feetype_name'] . "' AND status = 1")->row_array();
|
||||
// $dr = $fee_amt;
|
||||
// $cr = 0;
|
||||
// } else if ($i == 1) {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_name = 'Scholarship' AND status = 1")->row_array();
|
||||
// $scholarship_amt = round(($scholarship['scholarship_discount'] / 100) * $fee_amt);
|
||||
// $cr = $scholarship_amt;
|
||||
// $dr = 0;
|
||||
// } else {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_code = '$theUserId' AND status = 1")->row_array();
|
||||
// $scholarship_amt = round(($scholarship['scholarship_discount'] / 100) * $fee_amt);
|
||||
// $dr = 0;
|
||||
// $cr = $fee_amt - $scholarship_amt;
|
||||
// }
|
||||
// } else {
|
||||
// if ($i == 0) {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_name = '" . $course_fee['feetype_name'] . "' AND status = 1")->row_array();
|
||||
// $dr = $fee_amt;
|
||||
// $cr = 0;
|
||||
// } else {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_code = '$theUserId' AND status = 1")->row_array();
|
||||
// $cr = $fee_amt;
|
||||
// $dr = 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
// $td['voucher_id'] = $vid;
|
||||
// $td['entry_no'] = $i + 1;
|
||||
// $td['transaction_date'] = date('Y-m-d');
|
||||
// $td['account_id'] = $account['account_id'];
|
||||
// $td['narration'] = $course_fee['fee_values'] . ' ( ' . $course_fee['feetype_name'] . ' )';
|
||||
// $td['dr'] = $dr;
|
||||
// $td['cr'] = $cr;
|
||||
// $td['branch_id'] = $branches['branch_id'];
|
||||
// $td['fiscalyear_id'] = $fiscalyear['fiscalyear_id'];
|
||||
// $td['batch_id'] = $course_fee['batch_id'];
|
||||
// $td['course_id'] = $course_fee['course_id'];
|
||||
// $td['course_fee_id'] = $course_fee['id'];
|
||||
// $td['student_id'] = $userId;
|
||||
// $td['created_on'] = date('Y-m-d');
|
||||
// $td['created_by'] = $_SESSION['admin_name'];
|
||||
// $td['remarks'] = !empty($scholarship) ? $scholarship['scholarship_discount'] . ' % scholarship on ' . $course_fee['feetype_name'] : '';
|
||||
// $td['status'] = 1;
|
||||
|
||||
// // echo '<pre>';
|
||||
// $this->db->insert('tbl_voucherdetails', $td);
|
||||
// // dd($td);
|
||||
// }
|
||||
// }
|
||||
// // return $userId . ' = ' . $userType;
|
||||
// }
|
||||
|
||||
function voucherEntry($userId, $theUserId, $course_fee, $scholarship)
|
||||
{
|
||||
|
||||
$course_fee_id = $course_fee['id'];
|
||||
$voucher = $this->db->query("select * from tbl_vouchers where user_id = $userId AND course_fee_id = $course_fee_id")->result();
|
||||
|
||||
|
||||
|
||||
$fiscalyear = $this->db->query("select * from tbl_fiscalyear WHERE status = 1")->row_array();
|
||||
$branches = $this->db->query("select * from tbl_branches WHERE status = 1")->row_array();
|
||||
|
||||
$entry = !empty($scholarship) ? 3 : 2;
|
||||
|
||||
$fee_amt = $course_fee['amount'];
|
||||
$dr = 0;
|
||||
$cr = 0;
|
||||
|
||||
for ($i = 0; $i < $entry; $i++) {
|
||||
|
||||
if ($entry == 3) {
|
||||
if ($i == 0) {
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_name = '" . $course_fee['feetype_name'] . "' AND status = 1")->row_array();
|
||||
$dr = $fee_amt;
|
||||
$cr = 0;
|
||||
} else if ($i == 1) {
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_name = 'Scholarship' AND status = 1")->row_array();
|
||||
$scholarship_amt = round(($scholarship['scholarship_discount'] / 100) * $fee_amt);
|
||||
$cr = $scholarship_amt;
|
||||
$dr = 0;
|
||||
} else {
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_code = '$theUserId' AND status = 1")->row_array();
|
||||
$scholarship_amt = round(($scholarship['scholarship_discount'] / 100) * $fee_amt);
|
||||
$dr = 0;
|
||||
$cr = $fee_amt - $scholarship_amt;
|
||||
}
|
||||
} else {
|
||||
if ($i == 0) {
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_name = '" . $course_fee['feetype_name'] . "' AND status = 1")->row_array();
|
||||
$dr = $fee_amt;
|
||||
$cr = 0;
|
||||
} else {
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_code = '$theUserId' AND status = 1")->row_array();
|
||||
$cr = $fee_amt;
|
||||
$dr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$voucherId = $this->createVoucherId($userId, $course_fee['id'], "student",);
|
||||
|
||||
$td['voucher_id'] = $voucherId;
|
||||
$td['entry_no'] = $i + 1;
|
||||
$td['transaction_date'] = date('Y-m-d');
|
||||
$td['account_id'] = $account['account_id'];
|
||||
$td['narration'] = $course_fee['fee_values'] . ' ( ' . $course_fee['feetype_name'] . ' )';
|
||||
$td['dr'] = $dr;
|
||||
$td['cr'] = $cr;
|
||||
$td['branch_id'] = $branches['branch_id'];
|
||||
$td['fiscalyear_id'] = $fiscalyear['fiscalyear_id'];
|
||||
$td['batch_id'] = $course_fee['batch_id'];
|
||||
$td['course_id'] = $course_fee['course_id'];
|
||||
$td['course_fee_id'] = $course_fee['id'];
|
||||
$td['student_id'] = $userId;
|
||||
$td['created_on'] = date('Y-m-d');
|
||||
$td['created_by'] = $_SESSION['admin_name'];
|
||||
$td['remarks'] = !empty($scholarship) ? $scholarship['scholarship_discount'] . ' % scholarship on ' . $course_fee['feetype_name'] : '';
|
||||
$td['status'] = 1;
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($td);
|
||||
|
||||
$this->db->insert('tbl_voucherdetails', $td);
|
||||
}
|
||||
}
|
||||
|
||||
function removeVoucherEntry($userId, $course_fee)
|
||||
{
|
||||
$coondition_data = array(
|
||||
'student_id' => $userId,
|
||||
'course_fee_id' => $course_fee['id'],
|
||||
'batch_id' => $course_fee['batch_id']
|
||||
);
|
||||
$this->db->where($coondition_data);
|
||||
$this->db->delete('tbl_voucherdetails');
|
||||
}
|
||||
}
|
585
application/libraries/Accounting.php
Normal file
585
application/libraries/Accounting.php
Normal file
@@ -0,0 +1,585 @@
|
||||
<?php
|
||||
class Accounting
|
||||
{
|
||||
private $ci;
|
||||
private $db;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->ci = &get_instance();
|
||||
$this->db = $this->ci->load->database('accounting', TRUE);
|
||||
$t = "select * from admin_menu where parent_id=22 and page_link='account/defaults'";
|
||||
$r = $this->ci->db->query($t);
|
||||
if ($r->num_rows() == 0) {
|
||||
$t = "INSERT INTO `admin_menu` (`id`, `menu_name`, `parent_id`, `order_number`, `inactive_icon`, `active_icon`, `is_active`, `page_link`, `created_on`) VALUES (NULL, 'Accounting Settings', '22', '6', ' ', ' ', 'yes', 'account/defaults', '" . date("y-m-d h:i:s") . "');";
|
||||
$q = $this->ci->db->query($t);
|
||||
}
|
||||
$this->init();
|
||||
}
|
||||
function pre($Obj)
|
||||
{
|
||||
echo "<pre>";
|
||||
print_r($Obj);
|
||||
echo "</pre>";
|
||||
}
|
||||
|
||||
function init()
|
||||
{
|
||||
$tbl_acgroups = "CREATE TABLE IF NOT EXISTS `tbl_acgroups` (
|
||||
`acgroup_id` INT(11) NOT NULL,
|
||||
`acgroup_code` VARCHAR(250) NOT NULL,
|
||||
`acgroup_name` VARCHAR(250) NOT NULL,
|
||||
`posting_side` VARCHAR(20) NOT NULL,
|
||||
`created_on` DATE NOT NULL,
|
||||
`created_by` VARCHAR(250) NOT NULL,
|
||||
`remarks` TEXT NOT NULL,
|
||||
`status` INT(11) NOT NULL,
|
||||
`display_order` INT(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
";
|
||||
$this->db->query($tbl_acgroups);
|
||||
// $columnExists = $this->db->table_exists('tbl_vouchertypes') ? in_array('default_credits', $this->db->list_fields('tbl_vouchertypes')) : false;
|
||||
// if($columnExists)$this->db->add_column('tbl_vouchertypes', array('default_credits' => array('type' => 'VARCHAR', 'constraint' => 255)));
|
||||
|
||||
// $columnExists = $this->db->table_exists('tbl_vouchertypes') ? in_array('default_debits', $this->db->list_fields('tbl_vouchertypes')) : false;
|
||||
// if($columnExists)$this->db->add_column('tbl_vouchertypes', array('default_debits' => array('type' => 'VARCHAR', 'constraint' => 255)));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function showFeeTypeMappingOption($default = "")
|
||||
{
|
||||
// $Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 3 AND tbl_accounts.status<>1)")->result();
|
||||
// $Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 3 AND tbl_accounts.status<>1)")->result();
|
||||
$Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 3)")->result();
|
||||
|
||||
// $Accategoreies = $this->db->query("select ac.* from tbl_accategories ac JOIN tbl_accounts acc ON acc.accategory_id = ac.accategory_id WHERE ac.acgroup_id = 3")->result();
|
||||
foreach ($Accategoreies as $AccountCategory) {
|
||||
$AccountCategory->Accounts = $this->db->query("select * from tbl_accounts where accategory_id='$AccountCategory->accategory_id'")->result();
|
||||
}
|
||||
// echo '<pre>';
|
||||
// print_r($Accategoreies);
|
||||
// die();
|
||||
?>
|
||||
<div class="form-group mt-4 mb-0">
|
||||
<label class="has-float-label">
|
||||
<select class="form-control" name="account_id" id="account_id_selector" required>
|
||||
<option value="">Select Default Account</option>
|
||||
<?php foreach ($Accategoreies as $AccountCategory) : ?>
|
||||
<optgroup label="<?php echo $AccountCategory->accategory_name; ?>">
|
||||
<?php foreach ($AccountCategory->Accounts as $Account) : ?>
|
||||
<option value="<?php echo $Account->account_id; ?>" <?php if ($default != "" && $default == $Account->account_name) : ?>SELECTED<?php endif; ?>><?php echo $Account->account_name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</select>
|
||||
<span>Select Default Account</span>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
function updateFeeTypeAccountMapping($feetype_id, $account_id)
|
||||
{
|
||||
$t = "CREATE TABLE IF NOT EXISTS `tbl_accmaping` (
|
||||
`accmaping_id` int(11) NOT NULL,
|
||||
`bbmodel` varchar(35) NOT NULL,
|
||||
`bbpk` int(11) NOT NULL,
|
||||
`account_id` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
";
|
||||
$this->db->query($t);
|
||||
$q = $this->db->query("SELECT * FROM tbl_accmaping WHERE bbmodel='fee_types' AND bbpk='$feetype_id'");
|
||||
if ($q->num_rows() > 0) {
|
||||
$q = $this->db->query("UPDATE tbl_accmaping SET account_id='$account_id' WHERE bbmodel='fee_types' AND bbpk='$feetype_id'");
|
||||
} else {
|
||||
$q = $this->db->query("INSERT INTO tbl_accmaping (account_id, bbmodel, bbpk) VALUES ('$account_id', 'fee_types', '$feetype_id')");
|
||||
}
|
||||
}
|
||||
function fetchMappedAccount($model, $bbpk)
|
||||
{
|
||||
$q = $this->db->query("SELECT * FROM tbl_accounts WHERE account_id=(SELECT account_id FROM tbl_accmaping WHERE bbmodel='$model' AND bbpk='$bbpk')");
|
||||
|
||||
if ($q->num_rows() > 0) {
|
||||
return $q->row()->account_name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function showExpenseTypeMappingOption($default = "")
|
||||
{
|
||||
// $Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 3 AND tbl_accounts.status<>1)")->result();
|
||||
// $Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 3 AND tbl_accounts.status<>1)")->result();
|
||||
$Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accategories.acgroup_id = 4)")->result();
|
||||
|
||||
// $Accategoreies = $this->db->query("select ac.* from tbl_accategories ac JOIN tbl_accounts acc ON acc.accategory_id = ac.accategory_id WHERE ac.acgroup_id = 3")->result();
|
||||
foreach ($Accategoreies as $AccountCategory) {
|
||||
$AccountCategory->Accounts = $this->db->query("select * from tbl_accounts where accategory_id='$AccountCategory->accategory_id'")->result();
|
||||
}
|
||||
// echo '<pre>';
|
||||
// print_r($Accategoreies);
|
||||
// die();
|
||||
?>
|
||||
<div class="form-group mt-4 mb-0">
|
||||
<label class="has-float-label">
|
||||
<select class="form-control" name="account_id" id="account_id_selector" required>
|
||||
<option value="">Select Default Account</option>
|
||||
<?php foreach ($Accategoreies as $AccountCategory) : ?>
|
||||
<optgroup label="<?php echo $AccountCategory->accategory_name; ?>">
|
||||
<?php foreach ($AccountCategory->Accounts as $Account) : ?>
|
||||
<option value="<?php echo $Account->account_id; ?>" <?php if ($default != "" && $default == $Account->account_name) : ?>SELECTED<?php endif; ?>><?php echo $Account->account_name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</select>
|
||||
<span>Select Default Account</span>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function updateExpenseTypeAccountMapping($feetype_id, $account_id)
|
||||
{
|
||||
$t = "CREATE TABLE IF NOT EXISTS `tbl_accmaping` (
|
||||
`accmaping_id` int(11) NOT NULL,
|
||||
`bbmodel` varchar(35) NOT NULL,
|
||||
`bbpk` int(11) NOT NULL,
|
||||
`account_id` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
";
|
||||
$this->db->query($t);
|
||||
$q = $this->db->query("SELECT * FROM tbl_accmaping WHERE bbmodel='expense_types' AND bbpk='$feetype_id'");
|
||||
if ($q->num_rows() > 0) {
|
||||
$q = $this->db->query("UPDATE tbl_accmaping SET account_id='$account_id' WHERE bbmodel='expense_types' AND bbpk='$feetype_id'");
|
||||
} else {
|
||||
$q = $this->db->query("INSERT INTO tbl_accmaping (account_id, bbmodel, bbpk) VALUES ('$account_id', 'expense_types', '$feetype_id')");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function userCreateAcc($userId, $userType, $username, $createdOn)
|
||||
{
|
||||
$userAcc = $this->db->query("select * from tbl_accounts where account_code = '$userId'")->result();
|
||||
print_r($userAcc);
|
||||
|
||||
if (empty($userAcc)) {
|
||||
if ($userType == 'student') {
|
||||
$accategory_id = 64;
|
||||
} else {
|
||||
$accategory_id = 65;
|
||||
}
|
||||
$td['account_code'] = $userId;
|
||||
$td['account_name'] = $username;
|
||||
$td['accategory_id'] = $accategory_id;
|
||||
$td['created_on'] = $createdOn;
|
||||
$td['created_by'] = 'Admin';
|
||||
$td['status'] = 1;
|
||||
|
||||
// dd($td);
|
||||
|
||||
$insert = $this->db->insert('tbl_accounts', $td);
|
||||
|
||||
if ($insert) {
|
||||
return 'success';
|
||||
} else {
|
||||
return 'error';
|
||||
}
|
||||
} else {
|
||||
return 'already_existed';
|
||||
}
|
||||
// return $userId . ' = ' . $userType;
|
||||
}
|
||||
|
||||
function fetchAccountInfo($userId)
|
||||
{
|
||||
$userAcc = $this->db->query("select * from tbl_accounts where account_code = '$userId'")->row_array();
|
||||
|
||||
return $userAcc;
|
||||
}
|
||||
|
||||
function createVoucherId($userId, $course_fee_id, $userType, $vType)
|
||||
{
|
||||
$userAcc = $this->db->query("select * from tbl_vouchers where user_id = $userId AND course_fee_id = $course_fee_id AND voucher_state = 'Entered'")->row_array();
|
||||
$voucher = $this->db->query("select * from tbl_vouchers WHERE voucher_type = '$vType'")->result();
|
||||
$voucher_type = $this->db->query("select * from tbl_vouchers WHERE voucher_type = '$vType'")->result();
|
||||
$voucherType = $this->db->query("select * from tbl_vouchertypes WHERE voucher_type = '$vType'")->row_array();
|
||||
$fiscalyear = $this->db->query("select * from tbl_fiscalyear WHERE status = 1")->row_array();
|
||||
$branches = $this->db->query("select * from tbl_branches WHERE status = 1")->row_array();
|
||||
|
||||
|
||||
if (empty($userAcc)) {
|
||||
$td['voucher_no'] = count($voucher) + 1;
|
||||
$td['voucher_ref'] = $voucherType['voucher_alias'] . '' . (count($voucher_type) + 1);
|
||||
$td['voucher_date'] = date('Y-m-d');
|
||||
$td['voucher_state'] = 'Entered';
|
||||
$td['voucher_type'] = $vType;
|
||||
$td['fiscalyear_id'] = $fiscalyear['fiscalyear_id'];
|
||||
$td['branch_id'] = $branches['branch_id'];
|
||||
$td['user_id'] = $userId;
|
||||
$td['course_fee_id'] = $course_fee_id;
|
||||
$td['reference_type'] = $userType;
|
||||
$td['created_by'] = $_SESSION['admin_name'];
|
||||
$td['created_on'] = date('Y-m-d H:m:s');
|
||||
$td['remarks'] = '';
|
||||
$td['status'] = 1;
|
||||
|
||||
$insert = $this->db->insert('tbl_vouchers', $td);
|
||||
|
||||
if ($insert) {
|
||||
return $this->db->insert_id();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return $userAcc['voucher_id'];
|
||||
}
|
||||
}
|
||||
|
||||
function fetchVoucherInfo($userId)
|
||||
{
|
||||
$userAcc = $this->db->query("select * from tbl_vouchers where reference_id = $userId")->row_array();
|
||||
|
||||
return $userAcc;
|
||||
}
|
||||
|
||||
// function voucherEntry($userId, $theUserId, $course_fee, $scholarship)
|
||||
// {
|
||||
// $userAcc = $this->db->query("select * from tbl_vouchers where reference_id = $userId")->result();
|
||||
|
||||
// if (!empty($userAcc)) {
|
||||
|
||||
// $voucher = $this->db->query("select * from tbl_vouchers WHERE reference_id = $userId AND reference_type = 'student'")->row_array();
|
||||
// $fiscalyear = $this->db->query("select * from tbl_fiscalyear WHERE status = 1")->row_array();
|
||||
// $branches = $this->db->query("select * from tbl_branches WHERE status = 1")->row_array();
|
||||
|
||||
// $entry = !empty($scholarship) ? 3 : 2;
|
||||
|
||||
// $fee_amt = $course_fee['amount'];
|
||||
// $dr = 0;
|
||||
// $cr = 0;
|
||||
|
||||
// for ($i = 0; $i < $entry; $i++) {
|
||||
|
||||
// if ($entry == 3) {
|
||||
// if ($i == 0) {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_name = '" . $course_fee['feetype_name'] . "' AND status = 1")->row_array();
|
||||
// $dr = $fee_amt;
|
||||
// $cr = 0;
|
||||
// } else if ($i == 1) {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_name = 'Scholarship' AND status = 1")->row_array();
|
||||
// $scholarship_amt = round(($scholarship['scholarship_discount'] / 100) * $fee_amt);
|
||||
// $cr = $scholarship_amt;
|
||||
// $dr = 0;
|
||||
// } else {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_code = '$theUserId' AND status = 1")->row_array();
|
||||
// $scholarship_amt = round(($scholarship['scholarship_discount'] / 100) * $fee_amt);
|
||||
// $dr = 0;
|
||||
// $cr = $fee_amt - $scholarship_amt;
|
||||
// }
|
||||
// } else {
|
||||
// if ($i == 0) {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_name = '" . $course_fee['feetype_name'] . "' AND status = 1")->row_array();
|
||||
// $dr = $fee_amt;
|
||||
// $cr = 0;
|
||||
// } else {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_code = '$theUserId' AND status = 1")->row_array();
|
||||
// $cr = $fee_amt;
|
||||
// $dr = 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
// $td['voucher_id'] = $voucher['voucher_id'];
|
||||
// $td['entry_no'] = $i + 1;
|
||||
// $td['transaction_date'] = date('Y-m-d');
|
||||
// $td['account_id'] = $account['account_id'];
|
||||
// $td['narration'] = $course_fee['fee_values'] . ' ( ' . $course_fee['feetype_name'] . ' )';
|
||||
// $td['dr'] = $dr;
|
||||
// $td['cr'] = $cr;
|
||||
// $td['branch_id'] = $branches['branch_id'];
|
||||
// $td['fiscalyear_id'] = $fiscalyear['fiscalyear_id'];
|
||||
// $td['batch_id'] = $course_fee['batch_id'];
|
||||
// $td['course_id'] = $course_fee['course_id'];
|
||||
// $td['course_fee_id'] = $course_fee['id'];
|
||||
// $td['student_id'] = $userId;
|
||||
// $td['created_on'] = date('Y-m-d');
|
||||
// $td['created_by'] = $_SESSION['admin_name'];
|
||||
// $td['remarks'] = !empty($scholarship) ? $scholarship['scholarship_discount'] . ' % scholarship on ' . $course_fee['feetype_name'] : '';
|
||||
// $td['status'] = 1;
|
||||
|
||||
// // echo '<pre>';
|
||||
// // print_r($td);
|
||||
|
||||
// $this->db->insert('tbl_voucherdetails', $td);
|
||||
// }
|
||||
// } else {
|
||||
|
||||
// $voucher = $this->db->query("select * from tbl_vouchers WHERE reference_id = $userId AND reference_type = 'student'")->row_array();
|
||||
|
||||
|
||||
// $this->db->select_max('voucher_id');
|
||||
// $query = $this->db->get('tbl_vouchers');
|
||||
// $res = $query->row_array();
|
||||
// $vid = $res['id'] + 1;
|
||||
|
||||
// $fiscalyear = $this->db->query("select * from tbl_fiscalyear WHERE status = 1")->row_array();
|
||||
// $branches = $this->db->query("select * from tbl_branches WHERE status = 1")->row_array();
|
||||
|
||||
// $entry = !empty($scholarship) ? 3 : 2;
|
||||
|
||||
// $fee_amt = $course_fee['amount'];
|
||||
// $dr = 0;
|
||||
// $cr = 0;
|
||||
|
||||
// for (
|
||||
// $i = 0;
|
||||
// $i < $entry;
|
||||
// $i++
|
||||
// ) {
|
||||
|
||||
// if ($entry == 3) {
|
||||
// if ($i == 0) {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_name = '" . $course_fee['feetype_name'] . "' AND status = 1")->row_array();
|
||||
// $dr = $fee_amt;
|
||||
// $cr = 0;
|
||||
// } else if ($i == 1) {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_name = 'Scholarship' AND status = 1")->row_array();
|
||||
// $scholarship_amt = round(($scholarship['scholarship_discount'] / 100) * $fee_amt);
|
||||
// $cr = $scholarship_amt;
|
||||
// $dr = 0;
|
||||
// } else {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_code = '$theUserId' AND status = 1")->row_array();
|
||||
// $scholarship_amt = round(($scholarship['scholarship_discount'] / 100) * $fee_amt);
|
||||
// $dr = 0;
|
||||
// $cr = $fee_amt - $scholarship_amt;
|
||||
// }
|
||||
// } else {
|
||||
// if ($i == 0) {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_name = '" . $course_fee['feetype_name'] . "' AND status = 1")->row_array();
|
||||
// $dr = $fee_amt;
|
||||
// $cr = 0;
|
||||
// } else {
|
||||
// $account = $this->db->query("select * from tbl_accounts WHERE account_code = '$theUserId' AND status = 1")->row_array();
|
||||
// $cr = $fee_amt;
|
||||
// $dr = 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
// $td['voucher_id'] = $vid;
|
||||
// $td['entry_no'] = $i + 1;
|
||||
// $td['transaction_date'] = date('Y-m-d');
|
||||
// $td['account_id'] = $account['account_id'];
|
||||
// $td['narration'] = $course_fee['fee_values'] . ' ( ' . $course_fee['feetype_name'] . ' )';
|
||||
// $td['dr'] = $dr;
|
||||
// $td['cr'] = $cr;
|
||||
// $td['branch_id'] = $branches['branch_id'];
|
||||
// $td['fiscalyear_id'] = $fiscalyear['fiscalyear_id'];
|
||||
// $td['batch_id'] = $course_fee['batch_id'];
|
||||
// $td['course_id'] = $course_fee['course_id'];
|
||||
// $td['course_fee_id'] = $course_fee['id'];
|
||||
// $td['student_id'] = $userId;
|
||||
// $td['created_on'] = date('Y-m-d');
|
||||
// $td['created_by'] = $_SESSION['admin_name'];
|
||||
// $td['remarks'] = !empty($scholarship) ? $scholarship['scholarship_discount'] . ' % scholarship on ' . $course_fee['feetype_name'] : '';
|
||||
// $td['status'] = 1;
|
||||
|
||||
// // echo '<pre>';
|
||||
// $this->db->insert('tbl_voucherdetails', $td);
|
||||
// // dd($td);
|
||||
// }
|
||||
// }
|
||||
// // return $userId . ' = ' . $userType;
|
||||
// }
|
||||
|
||||
function voucherEntry($userId, $theUserId, $course_fee, $scholarship, $voucher_type, $paidAmount = 0)
|
||||
{
|
||||
$fiscalyear = $this->db->query("select * from tbl_fiscalyear WHERE status = 1")->row_array();
|
||||
$branches = $this->db->query("select * from tbl_branches WHERE status = 1")->row_array();
|
||||
|
||||
$entry = !empty($scholarship) ? 3 : 2;
|
||||
|
||||
$fee_amt = $course_fee['amount'];
|
||||
$dr = 0;
|
||||
$cr = 0;
|
||||
|
||||
for ($i = 0; $i < $entry; $i++) {
|
||||
|
||||
if ($entry == 3) {
|
||||
if ($i == 0) {
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_name = '" . $course_fee['feetype_name'] . "' AND status = 1")->row_array();
|
||||
$cr = $fee_amt;
|
||||
$dr = 0;
|
||||
} else if ($i == 1) {
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_name = 'Scholarship' AND status = 1")->row_array();
|
||||
$scholarship_amt = round(($scholarship['scholarship_discount'] / 100) * $fee_amt);
|
||||
$dr = $scholarship_amt;
|
||||
$cr = 0;
|
||||
} else {
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_code = '$theUserId' AND status = 1")->row_array();
|
||||
$scholarship_amt = round(($scholarship['scholarship_discount'] / 100) * $fee_amt);
|
||||
$cr = 0;
|
||||
$dr = $fee_amt - $scholarship_amt;
|
||||
}
|
||||
} else {
|
||||
if ($i == 0) {
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_name = '" . $course_fee['feetype_name'] . "' AND status = 1")->row_array();
|
||||
$cr = $fee_amt;
|
||||
$dr = 0;
|
||||
} else {
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_code = '$theUserId' AND status = 1")->row_array();
|
||||
$dr = $fee_amt;
|
||||
$cr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$voucherId = $this->createVoucherId($userId, $course_fee['id'], "student", $voucher_type);
|
||||
|
||||
$td['voucher_id'] = $voucherId;
|
||||
$td['entry_no'] = $i + 1;
|
||||
$td['transaction_date'] = date('Y-m-d');
|
||||
$td['account_id'] = $account['account_id'];
|
||||
$td['narration'] = $course_fee['fee_values'] . ' ( ' . $course_fee['feetype_name'] . ' )';
|
||||
$td['dr'] = $dr;
|
||||
$td['cr'] = $cr;
|
||||
$td['branch_id'] = $branches['branch_id'];
|
||||
$td['fiscalyear_id'] = $fiscalyear['fiscalyear_id'];
|
||||
$td['batch_id'] = $course_fee['batch_id'];
|
||||
$td['course_id'] = $course_fee['course_id'];
|
||||
$td['course_fee_id'] = $course_fee['id'];
|
||||
$td['student_id'] = $userId;
|
||||
$td['created_on'] = date('Y-m-d');
|
||||
$td['created_by'] = $_SESSION['admin_name'];
|
||||
$td['remarks'] = !empty($scholarship) ? $scholarship['scholarship_discount'] . ' % scholarship on ' . $course_fee['feetype_name'] : '';
|
||||
$td['status'] = 1;
|
||||
|
||||
$this->db->insert('tbl_voucherdetails', $td);
|
||||
}
|
||||
}
|
||||
|
||||
function receiptVoucherEntry($userId, $theUserId, $batch_id, $course_id, $paidAmount = 0)
|
||||
{
|
||||
$fiscalyear = $this->db->query("select * from tbl_fiscalyear WHERE status = 1")->row_array();
|
||||
$branches = $this->db->query("select * from tbl_branches WHERE status = 1")->row_array();
|
||||
|
||||
$voucher = $this->db->query("select * from tbl_vouchers WHERE voucher_type = 'Receipt' ORDER BY voucher_no DESC")->row_array();
|
||||
$voucherType = $this->db->query("select * from tbl_vouchertypes WHERE voucher_type = 'Receipt'")->row_array();
|
||||
|
||||
|
||||
$account = $this->db->query("select * from tbl_accounts WHERE account_code = '$theUserId'")->row_array();
|
||||
$cash_account = $this->db->query("select * from tbl_accounts WHERE account_id = 2")->row_array();
|
||||
$voucher_no = !empty($voucher) ? $voucher["voucher_no"] + 1 : 1;
|
||||
|
||||
|
||||
$td['voucher_no'] = $voucher_no;
|
||||
$td['voucher_ref'] = $voucherType['voucher_alias'] . '' . $voucher_no;
|
||||
$td['voucher_date'] = date('Y-m-d');
|
||||
$td['voucher_state'] = 'Entered';
|
||||
$td['voucher_type'] = 'Receipt';
|
||||
$td['fiscalyear_id'] = $fiscalyear['fiscalyear_id'];
|
||||
$td['branch_id'] = $branches['branch_id'];
|
||||
$td['user_id'] = $userId;
|
||||
$td['course_fee_id'] = 0;
|
||||
$td['reference_type'] = "student";
|
||||
$td['created_by'] = $_SESSION['admin_name'];
|
||||
$td['created_on'] = date('Y-m-d H:m:s');
|
||||
$td['remarks'] = '';
|
||||
$td['status'] = 1;
|
||||
|
||||
$this->db->insert('tbl_vouchers', $td);
|
||||
|
||||
$vId = $this->db->insert_id();
|
||||
|
||||
$vtd['voucher_id'] = $vId;
|
||||
$vtd['entry_no'] = 1;
|
||||
$vtd['transaction_date'] = date('Y-m-d');
|
||||
$vtd['account_id'] = $account['account_id'];
|
||||
$vtd['narration'] = "Being cash received from $theUserId";
|
||||
$vtd['dr'] = 0;
|
||||
$vtd['cr'] = $paidAmount;
|
||||
$vtd['branch_id'] = $branches['branch_id'];
|
||||
$vtd['fiscalyear_id'] = $fiscalyear['fiscalyear_id'];
|
||||
$vtd['batch_id'] = $batch_id;
|
||||
$vtd['course_id'] = $course_id;
|
||||
$vtd['course_fee_id'] = 0;
|
||||
$vtd['student_id'] = $userId;
|
||||
$vtd['created_on'] = date('Y-m-d');
|
||||
$vtd['created_by'] = $_SESSION['admin_name'];
|
||||
$vtd['remarks'] = '';
|
||||
$vtd['status'] = 1;
|
||||
$this->db->insert('tbl_voucherdetails', $vtd);
|
||||
|
||||
$ctd['voucher_id'] = $vId;
|
||||
$ctd['entry_no'] = 2;
|
||||
$ctd['transaction_date'] = date('Y-m-d');
|
||||
$ctd['account_id'] = $cash_account['account_id'];
|
||||
$ctd['narration'] = "Being cash received from $theUserId";
|
||||
$ctd['dr'] = $paidAmount;
|
||||
$ctd['cr'] = 0;
|
||||
$ctd['branch_id'] = $branches['branch_id'];
|
||||
$ctd['fiscalyear_id'] = $fiscalyear['fiscalyear_id'];
|
||||
$ctd['batch_id'] = $batch_id;
|
||||
$ctd['course_id'] = $course_id;
|
||||
$ctd['course_fee_id'] = 0;
|
||||
$ctd['student_id'] = $userId;
|
||||
$ctd['created_on'] = date('Y-m-d');
|
||||
$ctd['created_by'] = $_SESSION['admin_name'];
|
||||
$ctd['remarks'] = '';
|
||||
$ctd['status'] = 1;
|
||||
$this->db->insert('tbl_voucherdetails', $ctd);
|
||||
}
|
||||
|
||||
function removeVoucherEntry($userId, $course_fee)
|
||||
{
|
||||
$coondition_data = array(
|
||||
'student_id' => $userId,
|
||||
'course_fee_id' => $course_fee['id'],
|
||||
'batch_id' => $course_fee['batch_id']
|
||||
);
|
||||
$this->db->where($coondition_data);
|
||||
$this->db->delete('tbl_voucherdetails');
|
||||
}
|
||||
|
||||
function reversalVoucherEntry($userId, $course_fee)
|
||||
{
|
||||
$voucher = $this->db->query("select * from tbl_vouchers where user_id = $userId AND course_fee_id = " . $course_fee['id'] . " AND voucher_state = 'Entered'")->row_array();
|
||||
|
||||
if (!empty($voucher)) {
|
||||
$voucher_details = $this->db->query('select * from tbl_voucherdetails where voucher_id = ' . $voucher['voucher_id'])->result_array();
|
||||
|
||||
$voucherId = $this->createVoucherId($userId, $course_fee['id'], "student", 'Journal');
|
||||
|
||||
foreach ($voucher_details as $v_key => $voucher_info) {
|
||||
$td['voucher_id'] = $voucherId;
|
||||
$td['entry_no'] = count($voucher_details) + ($v_key + 1);
|
||||
$td['transaction_date'] = date('Y-m-d');
|
||||
$td['account_id'] = $voucher_info['account_id'];
|
||||
$td['narration'] = 'Reversal of Voucher #' . $voucher['voucher_no'];
|
||||
$td['dr'] = $voucher_info['cr'];
|
||||
$td['cr'] = $voucher_info['dr'];
|
||||
$td['branch_id'] = $voucher_info['branch_id'];
|
||||
$td['fiscalyear_id'] = $voucher_info['fiscalyear_id'];
|
||||
$td['batch_id'] = $voucher_info['batch_id'];
|
||||
$td['course_id'] = $voucher_info['course_id'];
|
||||
$td['course_fee_id'] = $voucher_info['course_fee_id'];
|
||||
$td['student_id'] = $voucher_info['student_id'];
|
||||
$td['created_on'] = date('Y-m-d');
|
||||
$td['created_by'] = $_SESSION['admin_name'];
|
||||
$td['remarks'] = !empty($scholarship) ? $scholarship['scholarship_discount'] . ' % scholarship on ' . $course_fee['feetype_name'] : '';
|
||||
$td['status'] = 1;
|
||||
|
||||
$this->db->insert('tbl_voucherdetails', $td);
|
||||
// echo '<pre>';
|
||||
// print_r($td);
|
||||
}
|
||||
|
||||
$utd['voucher_state'] = 'Reversed';
|
||||
$this->db->where('voucher_id', $voucher['voucher_id']);
|
||||
$this->db->update('tbl_vouchers', $utd);
|
||||
}
|
||||
}
|
||||
}
|
51
application/libraries/CSVReader.php
Normal file
51
application/libraries/CSVReader.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class CSVReader {
|
||||
|
||||
var $fields; /** columns names retrieved after parsing */
|
||||
var $separator = ';'; /** separator used to explode each line */
|
||||
var $enclosure = '"'; /** enclosure used to decorate each field */
|
||||
|
||||
var $max_row_size = 4096; /** maximum row size to be used for decoding */
|
||||
|
||||
function parse_file($p_Filepath) {
|
||||
|
||||
$file = fopen($p_Filepath, 'r');
|
||||
$this->fields = fgetcsv($file, $this->max_row_size, $this->separator, $this->enclosure);
|
||||
$keys_values = explode(',',$this->fields[0]);
|
||||
|
||||
$content = array();
|
||||
$keys = $this->escape_string($keys_values);
|
||||
|
||||
$i = 1;
|
||||
while( ($row = fgetcsv($file, $this->max_row_size, $this->separator, $this->enclosure)) != false ) {
|
||||
if( $row != null ) { // skip empty lines
|
||||
$values = explode(',',$row[0]);
|
||||
if(count($keys) == count($values)){
|
||||
$arr = array();
|
||||
$new_values = array();
|
||||
$new_values = $this->escape_string($values);
|
||||
for($j=0;$j<count($keys);$j++){
|
||||
if($keys[$j] != ""){
|
||||
$arr[$keys[$j]] = $new_values[$j];
|
||||
}
|
||||
}
|
||||
|
||||
$content[$i]= $arr;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose($file);
|
||||
return $content;
|
||||
}
|
||||
|
||||
function escape_string($data){
|
||||
$result = array();
|
||||
foreach($data as $row){
|
||||
$result[] = str_replace('"', '',$row);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
103
application/libraries/Ciqrcode.php
Normal file
103
application/libraries/Ciqrcode.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP QR Code porting for Codeigniter
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @porting author dwi.setiyadi@gmail.com
|
||||
* @original author http://phpqrcode.sourceforge.net/
|
||||
*
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
class Ciqrcode
|
||||
{
|
||||
var $cacheable = true;
|
||||
var $cachedir = 'application/cache/';
|
||||
var $errorlog = 'application/logs/';
|
||||
var $quality = true;
|
||||
var $size = 1024;
|
||||
|
||||
function __construct($config = array()) {
|
||||
include APPPATH. "/third_party/qrcode/qrconst.php";
|
||||
include APPPATH. "/third_party/qrcode/qrtools.php";
|
||||
include APPPATH. "/third_party/qrcode/qrspec.php";
|
||||
include APPPATH. "/third_party/qrcode/qrimage.php";
|
||||
include APPPATH. "/third_party/qrcode/qrinput.php";
|
||||
include APPPATH. "/third_party/qrcode/qrbitstream.php";
|
||||
include APPPATH. "/third_party/qrcode/qrsplit.php";
|
||||
include APPPATH. "/third_party/qrcode/qrrscode.php";
|
||||
include APPPATH. "/third_party/qrcode/qrmask.php";
|
||||
include APPPATH. "/third_party/qrcode/qrencode.php";
|
||||
|
||||
$this->initialize($config);
|
||||
}
|
||||
|
||||
public function initialize($config = array()) {
|
||||
$this->cacheable = (isset($config['cacheable'])) ? $config['cacheable'] : $this->cacheable;
|
||||
$this->cachedir = (isset($config['cachedir'])) ? $config['cachedir'] : FCPATH.$this->cachedir;
|
||||
$this->errorlog = (isset($config['errorlog'])) ? $config['errorlog'] : FCPATH.$this->errorlog;
|
||||
$this->quality = (isset($config['quality'])) ? $config['quality'] : $this->quality;
|
||||
$this->size = (isset($config['size'])) ? $config['size'] : $this->size;
|
||||
|
||||
// use cache - more disk reads but less CPU power, masks and format templates are stored there
|
||||
if (!defined('QR_CACHEABLE')) define('QR_CACHEABLE', $this->cacheable);
|
||||
|
||||
// used when QR_CACHEABLE === true
|
||||
if (!defined('QR_CACHE_DIR')) define('QR_CACHE_DIR', $this->cachedir);
|
||||
|
||||
// default error logs dir
|
||||
if (!defined('QR_LOG_DIR')) define('QR_LOG_DIR', $this->errorlog);
|
||||
|
||||
// if true, estimates best mask (spec. default, but extremally slow; set to false to significant performance boost but (propably) worst quality code
|
||||
if ($this->quality) {
|
||||
if (!defined('QR_FIND_BEST_MASK')) define('QR_FIND_BEST_MASK', true);
|
||||
} else {
|
||||
if (!defined('QR_FIND_BEST_MASK')) define('QR_FIND_BEST_MASK', false);
|
||||
if (!defined('QR_DEFAULT_MASK')) define('QR_DEFAULT_MASK', $this->quality);
|
||||
}
|
||||
|
||||
// if false, checks all masks available, otherwise value tells count of masks need to be checked, mask id are got randomly
|
||||
if (!defined('QR_FIND_FROM_RANDOM')) define('QR_FIND_FROM_RANDOM', false);
|
||||
|
||||
// maximum allowed png image width (in pixels), tune to make sure GD and PHP can handle such big images
|
||||
if (!defined('QR_PNG_MAXIMUM_SIZE')) define('QR_PNG_MAXIMUM_SIZE', $this->size);
|
||||
}
|
||||
|
||||
public function generate($params = array()) {
|
||||
if (isset($params['black'])
|
||||
&& is_array($params['black'])
|
||||
&& count($params['black']) == 3
|
||||
&& array_filter($params['black'], 'is_int') === $params['black']) {
|
||||
QRimage::$black = $params['black'];
|
||||
}
|
||||
|
||||
if (isset($params['white'])
|
||||
&& is_array($params['white'])
|
||||
&& count($params['white']) == 3
|
||||
&& array_filter($params['white'], 'is_int') === $params['white']) {
|
||||
QRimage::$white = $params['white'];
|
||||
}
|
||||
|
||||
$params['data'] = (isset($params['data'])) ? $params['data'] : 'QR Code Library';
|
||||
if (isset($params['savename'])) {
|
||||
$level = 'L';
|
||||
if (isset($params['level']) && in_array($params['level'], array('L','M','Q','H'))) $level = $params['level'];
|
||||
|
||||
$size = 4;
|
||||
if (isset($params['size'])) $size = min(max((int)$params['size'], 1), 10);
|
||||
|
||||
QRcode::png($params['data'], $params['savename'], $level, $size, 2);
|
||||
return $params['savename'];
|
||||
} else {
|
||||
$level = 'L';
|
||||
if (isset($params['level']) && in_array($params['level'], array('L','M','Q','H'))) $level = $params['level'];
|
||||
|
||||
$size = 4;
|
||||
if (isset($params['size'])) $size = min(max((int)$params['size'], 1), 10);
|
||||
|
||||
QRcode::png($params['data'], NULL, $level, $size, 2);
|
||||
}
|
||||
}
|
||||
}
|
218
application/libraries/M_pdf.php
Normal file
218
application/libraries/M_pdf.php
Normal file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
require_once APPPATH . '/third_party/mpdf/vendor/autoload.php';
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
class M_pdf
|
||||
{
|
||||
|
||||
function m_pdf()
|
||||
{
|
||||
$CI = &get_instance();
|
||||
}
|
||||
function loadforStudentIdCard()
|
||||
{
|
||||
// ['mode' => 'utf-8', 'format' => [56, 86]]
|
||||
$mpdf = new \Mpdf\Mpdf([
|
||||
'mode' => 'utf-8', 'format' => [58, 86], 'margin_left' => 0,
|
||||
'margin_right' => 0,
|
||||
'margin_top' => 0,
|
||||
'margin_bottom' => 0
|
||||
]);
|
||||
return $mpdf;
|
||||
}
|
||||
|
||||
function loadforStudentAdmitCard()
|
||||
{
|
||||
// ['mode' => 'utf-8', 'format' => [56, 86]]
|
||||
$mpdf = new \Mpdf\Mpdf([
|
||||
'mode' => 'utf-8', 'format' => [100, 60],
|
||||
'margin_left' => 2,
|
||||
'margin_right' => 2,
|
||||
'margin_top' => 0,
|
||||
'margin_bottom' => 0
|
||||
]);
|
||||
return $mpdf;
|
||||
}
|
||||
|
||||
function load()
|
||||
{
|
||||
$mpdf = new \Mpdf\Mpdf();
|
||||
return $mpdf;
|
||||
}
|
||||
|
||||
function loadforinvoice()
|
||||
|
||||
{
|
||||
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
|
||||
$fontDirs = $defaultConfig['fontDir'];
|
||||
|
||||
$defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults();
|
||||
$fontData = $defaultFontConfig['fontdata'];
|
||||
$mpdf = new \Mpdf\Mpdf([
|
||||
|
||||
'mode' => '',
|
||||
|
||||
'format' => 'A4',
|
||||
|
||||
'default_font_size' => 0,
|
||||
|
||||
'default_font' => '',
|
||||
|
||||
'margin_left' => 5,
|
||||
|
||||
'margin_right' => 5,
|
||||
|
||||
'margin_top' => 5,
|
||||
|
||||
'margin_bottom' => 5,
|
||||
|
||||
'margin_header' => 0,
|
||||
|
||||
'margin_footer' => 0,
|
||||
|
||||
'orientation' => 'L',
|
||||
|
||||
'tempDir' => __DIR__ . '/upload',
|
||||
'fontDir' => array_merge($fontDirs, [
|
||||
__DIR__ . '/fonts'
|
||||
]),
|
||||
'fontdata' => $fontData + [
|
||||
'bentonsans' => [
|
||||
'R' => "Times New Roman Font.ttf",
|
||||
],
|
||||
],
|
||||
// 'default_font' => 'bentonsans'
|
||||
|
||||
]);
|
||||
return $mpdf;
|
||||
}
|
||||
|
||||
|
||||
function loadformarkscard()
|
||||
|
||||
{
|
||||
|
||||
$mpdf = new \Mpdf\Mpdf([
|
||||
|
||||
'mode' => '',
|
||||
|
||||
'format' => 'A4',
|
||||
|
||||
'default_font_size' => 0,
|
||||
|
||||
'default_font' => '',
|
||||
|
||||
'margin_left' => 3,
|
||||
|
||||
'margin_right' => 3,
|
||||
|
||||
'margin_top' => 3,
|
||||
|
||||
'margin_bottom' => 3,
|
||||
|
||||
'margin_header' => 0,
|
||||
|
||||
'margin_footer' => 0,
|
||||
|
||||
'orientation' => 'P',
|
||||
|
||||
// 'default_font' => 'dejavusans'
|
||||
|
||||
|
||||
]);
|
||||
// $mpdf->SetWatermarkText('DRAFT');
|
||||
// $mpdf->showWatermarkText = true;
|
||||
// $mpdf->SetWatermarkImage('https://demo.bbnepal.com/common_assets/watermark-emerald.png', 0.1);
|
||||
// $mpdf->showWatermarkImage = true;
|
||||
// $mpdf->watermarkAngle = 0;
|
||||
|
||||
return $mpdf;
|
||||
}
|
||||
|
||||
function loadFromCertificate()
|
||||
|
||||
{
|
||||
|
||||
$mpdf = new \Mpdf\Mpdf([
|
||||
|
||||
'mode' => '',
|
||||
|
||||
'format' => 'A4',
|
||||
|
||||
'default_font_size' => 12,
|
||||
|
||||
'default_font' => '',
|
||||
|
||||
'margin_left' => 4,
|
||||
|
||||
'margin_right' => 4,
|
||||
|
||||
'margin_top' => 4,
|
||||
|
||||
'margin_bottom' => 4,
|
||||
|
||||
'margin_header' => 0,
|
||||
|
||||
'margin_footer' => 0,
|
||||
|
||||
'orientation' => 'L',
|
||||
|
||||
|
||||
]);
|
||||
$mpdf->watermarkAngle = 45;
|
||||
|
||||
return $mpdf;
|
||||
}
|
||||
function loadforStudentQRCode()
|
||||
{
|
||||
// ['mode' => 'utf-8', 'format' => [56, 86]]
|
||||
$mpdf = new \Mpdf\Mpdf([
|
||||
'mode' => 'utf-8', 'format' => [120, 100],
|
||||
'margin_left' => 4,
|
||||
'margin_right' => 4,
|
||||
'margin_top' => 4,
|
||||
'margin_bottom' => 4
|
||||
]);
|
||||
return $mpdf;
|
||||
}
|
||||
|
||||
function loadforAdmissionForm()
|
||||
|
||||
{
|
||||
|
||||
$mpdf = new \Mpdf\Mpdf([
|
||||
|
||||
'mode' => '',
|
||||
|
||||
'format' => 'A4',
|
||||
|
||||
'default_font_size' => 0,
|
||||
|
||||
'default_font' => '',
|
||||
|
||||
'margin_left' => 3,
|
||||
|
||||
'margin_right' => 3,
|
||||
|
||||
'margin_top' => 3,
|
||||
|
||||
'margin_bottom' => 3,
|
||||
|
||||
'margin_header' => 0,
|
||||
|
||||
'margin_footer' => 0,
|
||||
|
||||
'orientation' => 'P',
|
||||
|
||||
// 'default_font' => 'dejavusans'
|
||||
|
||||
|
||||
]);
|
||||
// $mpdf->SetWatermarkText('DRAFT');
|
||||
// $mpdf->showWatermarkText = true;
|
||||
// $mpdf->SetWatermarkImage('https://demo.bbnepal.com/common_assets/watermark-emerald.png', 0.1);
|
||||
// $mpdf->showWatermarkImage = true;
|
||||
// $mpdf->watermarkAngle = 0;
|
||||
|
||||
return $mpdf;
|
||||
}
|
||||
}
|
265
application/libraries/Paypal_lib.php
Normal file
265
application/libraries/Paypal_lib.php
Normal file
@@ -0,0 +1,265 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* Code Igniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author Rick Ellis
|
||||
* @copyright Copyright (c) 2006, pMachine, Inc.
|
||||
* @license http://www.codeignitor.com/user_guide/license.html
|
||||
* @link http://www.codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* PayPal_Lib Controller Class (Paypal IPN Class)
|
||||
*
|
||||
* This CI library is based on the Paypal PHP class by Micah Carrick
|
||||
* See www.micahcarrick.com for the most recent version of this class
|
||||
* along with any applicable sample files and other documentaion.
|
||||
*
|
||||
* This file provides a neat and simple method to interface with paypal and
|
||||
* The paypal Instant Payment Notification (IPN) interface. This file is
|
||||
* NOT intended to make the paypal integration "plug 'n' play". It still
|
||||
* requires the developer (that should be you) to understand the paypal
|
||||
* process and know the variables you want/need to pass to paypal to
|
||||
* achieve what you want.
|
||||
*
|
||||
* This class handles the submission of an order to paypal as well as the
|
||||
* processing an Instant Payment Notification.
|
||||
* This class enables you to mark points and calculate the time difference
|
||||
* between them. Memory consumption can also be displayed.
|
||||
*
|
||||
* The class requires the use of the PayPal_Lib config file.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Commerce
|
||||
* @author Ran Aroussi <ran@aroussi.com>
|
||||
* @copyright Copyright (c) 2006, http://aroussi.com/ci/
|
||||
*
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
class paypal_lib
|
||||
{
|
||||
|
||||
var $last_error; // holds the last error encountered
|
||||
var $ipn_log; // bool: log IPN results to text file?
|
||||
var $ipn_log_file; // filename of the IPN log
|
||||
var $ipn_response; // holds the IPN response from paypal
|
||||
var $ipn_data = array(); // array contains the POST values for IPN
|
||||
var $fields = array(); // array holds the fields to submit to paypal
|
||||
|
||||
var $submit_btn = ''; // Image/Form button
|
||||
var $button_path = ''; // The path of the buttons
|
||||
|
||||
var $CI;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->CI = &get_instance();
|
||||
$this->CI->load->helper('url');
|
||||
$this->CI->load->helper('form');
|
||||
$this->CI->load->config('paypallib_config');
|
||||
|
||||
$sanbox = $this->CI->config->item('sandbox');
|
||||
$this->paypal_url = ($sanbox == TRUE) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr';
|
||||
|
||||
$this->last_error = '';
|
||||
$this->ipn_response = '';
|
||||
|
||||
$this->ipn_log_file = $this->CI->config->item('paypal_lib_ipn_log_file');
|
||||
$this->ipn_log = $this->CI->config->item('paypal_lib_ipn_log');
|
||||
|
||||
$this->button_path = $this->CI->config->item('paypal_lib_button_path');
|
||||
|
||||
// populate $fields array with a few default values. See the paypal
|
||||
// documentation for a list of fields and their data types. These defaul
|
||||
// values can be overwritten by the calling script.
|
||||
$businessEmail = $this->CI->config->item('business');
|
||||
$this->add_field('business', $businessEmail);
|
||||
$this->add_field('rm', '2'); // Return method = POST
|
||||
$this->add_field('cmd', '_xclick');
|
||||
|
||||
$this->add_field('currency_code', $this->CI->config->item('paypal_lib_currency_code'));
|
||||
$this->add_field('quantity', '1');
|
||||
$this->button('Pay Now!');
|
||||
}
|
||||
|
||||
function button($value)
|
||||
{
|
||||
// changes the default caption of the submit button
|
||||
$this->submit_btn = form_submit('pp_submit', $value);
|
||||
}
|
||||
|
||||
function image($file)
|
||||
{
|
||||
$this->submit_btn = '<input type="image" name="add" src="' . site_url($this->button_path . '/' . $file) . '" border="0" />';
|
||||
}
|
||||
|
||||
|
||||
function add_field($field, $value)
|
||||
{
|
||||
// adds a key=>value pair to the fields array, which is what will be
|
||||
// sent to paypal as POST variables. If the value is already in the
|
||||
// array, it will be overwritten.
|
||||
$this->fields[$field] = $value;
|
||||
}
|
||||
|
||||
function paypal_auto_form()
|
||||
{
|
||||
// this function actually generates an entire HTML page consisting of
|
||||
// a form with hidden elements which is submitted to paypal via the
|
||||
// BODY element's onLoad attribute. We do this so that you can validate
|
||||
// any POST vars from you custom form before submitting to paypal. So
|
||||
// basically, you'll have your own form which is submitted to your script
|
||||
// to validate the data, which in turn calls this function to create
|
||||
// another hidden form and submit to paypal.
|
||||
|
||||
$this->button('Click here if you\'re not automatically redirected...');
|
||||
|
||||
echo '<html>' . "\n";
|
||||
echo '<head><title>Processing Payment...</title></head>' . "\n";
|
||||
echo '<body style="text-align:center;" onLoad="document.forms[\'paypal_auto_form\'].submit();">' . "\n";
|
||||
echo '<p style="text-align:center;">Please wait, your order is being processed and you will be redirected to the paypal website.</p>' . "\n";
|
||||
echo $this->paypal_form('paypal_auto_form');
|
||||
echo '</body></html>';
|
||||
}
|
||||
|
||||
function paypal_form($form_name = 'paypal_form')
|
||||
{
|
||||
$str = '';
|
||||
$str .= '<form method="post" action="' . $this->paypal_url . '" name="' . $form_name . '"/>' . "\n";
|
||||
// echo "<pre>";
|
||||
// print_r($this->fields);
|
||||
// die();
|
||||
foreach ($this->fields as $name => $value)
|
||||
$str .= form_hidden($name, $value) . "\n";
|
||||
$str .= '<p>' . $this->submit_btn . '</p>';
|
||||
$str .= form_close() . "\n";
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
function validate_ipn()
|
||||
{
|
||||
// parse the paypal URL
|
||||
$url_parsed = parse_url($this->paypal_url);
|
||||
|
||||
// generate the post string from the _POST vars aswell as load the
|
||||
// _POST vars into an arry so we can play with them from the calling
|
||||
// script.
|
||||
$post_string = '';
|
||||
if ($this->CI->input->post()) {
|
||||
foreach ($this->CI->input->post() as $field => $value) {
|
||||
$this->ipn_data[$field] = $value;
|
||||
$post_string .= $field . '=' . urlencode(stripslashes($value)) . '&';
|
||||
}
|
||||
}
|
||||
|
||||
$post_string .= "cmd=_notify-validate"; // append ipn command
|
||||
|
||||
// open the connection to paypal
|
||||
$fp = fsockopen($url_parsed['host'], "80", $err_num, $err_str, 30);
|
||||
if (!$fp) {
|
||||
// could not open the connection. If loggin is on, the error message
|
||||
// will be in the log.
|
||||
$this->last_error = "fsockopen error no. $errnum: $errstr";
|
||||
$this->log_ipn_results(false);
|
||||
return false;
|
||||
} else {
|
||||
// Post the data back to paypal
|
||||
fputs($fp, "POST $url_parsed[path] HTTP/1.1\r\n");
|
||||
fputs($fp, "Host: $url_parsed[host]\r\n");
|
||||
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
|
||||
fputs($fp, "Content-length: " . strlen($post_string) . "\r\n");
|
||||
fputs($fp, "Connection: close\r\n\r\n");
|
||||
fputs($fp, $post_string . "\r\n\r\n");
|
||||
|
||||
// loop through the response from the server and append to variable
|
||||
while (!feof($fp))
|
||||
$this->ipn_response .= fgets($fp, 1024);
|
||||
|
||||
fclose($fp); // close connection
|
||||
}
|
||||
|
||||
if (preg_match("/VERIFIED/", $this->ipn_response)) {
|
||||
// Valid IPN transaction.
|
||||
$this->log_ipn_results(true);
|
||||
return true;
|
||||
} else {
|
||||
// Invalid IPN transaction. Check the log for details.
|
||||
$this->last_error = 'IPN Validation Failed.';
|
||||
$this->log_ipn_results(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function log_ipn_results($success)
|
||||
{
|
||||
if (!$this->ipn_log) return; // is logging turned off?
|
||||
// Timestamp
|
||||
$text = '[' . date('m/d/Y g:i A') . '] - ';
|
||||
|
||||
// Success or failure being logged?
|
||||
if ($success) $text .= "SUCCESS!\n";
|
||||
else $text .= 'FAIL: ' . $this->last_error . "\n";
|
||||
|
||||
// Log the POST variables
|
||||
$text .= "IPN POST Vars from Paypal:\n";
|
||||
foreach ($this->ipn_data as $key => $value)
|
||||
$text .= "$key=$value, ";
|
||||
|
||||
// Log the response from the paypal server
|
||||
$text .= "\nIPN Response from Paypal Server:\n " . $this->ipn_response;
|
||||
|
||||
// Write to log
|
||||
$fp = fopen($this->ipn_log_file, 'a');
|
||||
fwrite($fp, $text . "\n\n");
|
||||
|
||||
fclose($fp); // close file
|
||||
}
|
||||
|
||||
|
||||
function dump()
|
||||
{
|
||||
// Used for debugging, this function will output all the field/value pairs
|
||||
// that are currently defined in the instance of the class using the
|
||||
// add_field() function.
|
||||
|
||||
ksort($this->fields);
|
||||
echo '<h2>ppal->dump() Output:</h2>' . "\n";
|
||||
echo '<code style="font: 12px Monaco, \'Courier New\', Verdana, Sans-serif; background: #f9f9f9; border: 1px solid #D0D0D0; color: #002166; display: block; margin: 14px 0; padding: 12px 10px;">' . "\n";
|
||||
foreach ($this->fields as $key => $value) echo '<strong>' . $key . '</strong>: ' . urldecode($value) . '<br/>';
|
||||
echo "</code>\n";
|
||||
}
|
||||
|
||||
|
||||
function curlPost($paypalurl, $paypalreturnarr)
|
||||
{
|
||||
|
||||
$req = 'cmd=_notify-validate';
|
||||
foreach ($paypalreturnarr as $key => $value) {
|
||||
$value = urlencode(stripslashes($value));
|
||||
$req .= "&$key=$value";
|
||||
}
|
||||
|
||||
$ipnsiteurl = $paypalurl;
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $ipnsiteurl);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
98
application/libraries/accounting/Accounting.php
Normal file
98
application/libraries/accounting/Accounting.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
class Accounting
|
||||
{
|
||||
private $ci;
|
||||
private $db;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->ci = &get_instance();
|
||||
$this->db = $this->ci->load->database('accounting', TRUE);
|
||||
$t="select * from admin_menu where parent_id=22 and page_link='account/defaults'";
|
||||
$r=$this->ci->db->query($t);
|
||||
if($r->num_rows()==0){
|
||||
$t="INSERT INTO `admin_menu` (`id`, `menu_name`, `parent_id`, `order_number`, `inactive_icon`, `active_icon`, `is_active`, `page_link`, `created_on`) VALUES (NULL, 'Accounting Settings', '22', '6', ' ', ' ', 'yes', 'account/defaults', '".date("y-m-d h:i:s")."');";
|
||||
$q=$this->ci->db->query($t);
|
||||
}
|
||||
// $this->init();
|
||||
}
|
||||
function pre($Obj)
|
||||
{
|
||||
echo "<pre>";
|
||||
print_r($Obj);
|
||||
echo "</pre>";
|
||||
}
|
||||
|
||||
function init()
|
||||
{
|
||||
$tbl_acgroups = "CREATE TABLE IF NOT EXISTS `tbl_acgroups` (
|
||||
`acgroup_id` INT(11) NOT NULL,
|
||||
`acgroup_code` VARCHAR(250) NOT NULL,
|
||||
`acgroup_name` VARCHAR(250) NOT NULL,
|
||||
`posting_side` VARCHAR(20) NOT NULL,
|
||||
`created_on` DATE NOT NULL,
|
||||
`created_by` VARCHAR(250) NOT NULL,
|
||||
`remarks` TEXT NOT NULL,
|
||||
`status` INT(11) NOT NULL,
|
||||
`display_order` INT(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
";
|
||||
|
||||
}
|
||||
|
||||
function showFeeTypeMappingOption($default="")
|
||||
{
|
||||
$Accategoreies = $this->db->query("select * from tbl_accategories where accategory_id in (select accategory_id from tbl_accounts where tbl_accounts.status<>1)")->result();
|
||||
foreach ($Accategoreies as $AccountCategory) {
|
||||
$AccountCategory->Accounts = $this->db->query("select * from tbl_accounts where accategory_id='$AccountCategory->accategory_id'")->result();
|
||||
}
|
||||
?>
|
||||
<div class="form-group mb-0">
|
||||
<label class="has-float-label">
|
||||
<select class="form-control" name="account_id" id="account_id_selector" required>
|
||||
<option value="">Select Default Account</option>
|
||||
<?php foreach ($Accategoreies as $AccountCategory) : ?>
|
||||
<optgroup label="<?php echo $AccountCategory->accategory_name; ?>">
|
||||
<?php foreach ($AccountCategory->Accounts as $Account) : ?>
|
||||
<option value="<?php echo $Account->account_id; ?>" <?php if($default!="" && $default==$Account->account_name):?>SELECTED<?php endif; ?>><?php echo $Account->account_name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</select>
|
||||
<span>Select Default Account</span>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
function updateFeeTypeAccountMapping($feetype_id, $account_id)
|
||||
{
|
||||
$t = "CREATE TABLE IF NOT EXISTS `tbl_accmaping` (
|
||||
`accmaping_id` int(11) NOT NULL,
|
||||
`bbmodel` varchar(35) NOT NULL,
|
||||
`bbpk` int(11) NOT NULL,
|
||||
`account_id` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
";
|
||||
$this->db->query($t);
|
||||
$q = $this->db->query("SELECT * FROM tbl_accmaping WHERE bbmodel='fee_types' AND bbpk='$feetype_id'");
|
||||
if ($q->num_rows() > 0) {
|
||||
$q = $this->db->query("UPDATE tbl_accmaping SET account_id='$account_id' WHERE bbmodel='fee_types' AND bbpk='$feetype_id'");
|
||||
} else {
|
||||
$q = $this->db->query("INSERT INTO tbl_accmaping (account_id, bbmodel, bbpk) VALUES ('$account_id', 'fee_types', '$feetype_id')");
|
||||
}
|
||||
}
|
||||
function fetchMappedAccount($model, $bbpk)
|
||||
{
|
||||
$q = $this->db->query("SELECT * FROM tbl_accounts WHERE account_id=(SELECT account_id FROM tbl_accmaping WHERE bbmodel='$model' AND bbpk='$bbpk')");
|
||||
|
||||
if ($q->num_rows() > 0) {
|
||||
return $q->row()->account_name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
11
application/libraries/index.html
Normal file
11
application/libraries/index.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
BIN
application/libraries/upload/ttfontdata/bentonsans.cgm
Normal file
BIN
application/libraries/upload/ttfontdata/bentonsans.cgm
Normal file
Binary file not shown.
18
application/libraries/upload/ttfontdata/bentonsans.cw
Normal file
18
application/libraries/upload/ttfontdata/bentonsans.cw
Normal file
@@ -0,0 +1,18 @@
|
||||
/W [ 32 [ 250 333 408 500 500 833 778 180 333 333 ]
|
||||
42 [ 500 564 250 333 250 278 500 500 500 500 500 500 500 500 500 500 ]
|
||||
58 59 278 60 62 564 63 [ 444 921 722 667 667 ]
|
||||
68 [ 722 611 556 722 722 ]
|
||||
73 [ 333 389 722 611 889 722 722 556 722 667 556 611 722 722 944 722 722 611 333 278 333 469 500 333 444 500 444 500 444 333 500 500 278 278 ]
|
||||
107 [ 500 278 778 500 500 500 500 ]
|
||||
114 [ 333 389 278 500 500 722 500 500 444 480 200 480 541 ]
|
||||
160 [ 250 333 ]
|
||||
162 165 500 166 [ 200 500 333 760 276 500 564 333 760 500 400 549 300 300 ]
|
||||
180 [ 333 576 453 333 333 ]
|
||||
185 [ 300 310 500 ]
|
||||
188 190 750 191 191 444 192 197 722 198 [ 889 667 ]
|
||||
200 203 611 204 207 333 208 214 722 215 215 564 216 221 722 222 [ 556 500 ]
|
||||
224 229 444 230 230 667 231 235 444 236 239 278 240 246 500 247 247 549 248 255 500 338 [ 889 722 ]
|
||||
352 [ 556 389 ]
|
||||
376 376 722 402 402 500 710 710 333 732 732 333 8211 [ 500 1000 ]
|
||||
8216 8218 333 8220 8222 444 8224 [ 500 500 350 ]
|
||||
8230 8230 1000 8240 8240 1000 8249 8250 333 8482 8482 980 8729 8729 250 ]
|
BIN
application/libraries/upload/ttfontdata/bentonsans.cw.dat
Normal file
BIN
application/libraries/upload/ttfontdata/bentonsans.cw.dat
Normal file
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"name":"TimesNewRomanPSMT","type":"TTF","desc":{"CapHeight":662,"XHeight":447,"FontBBox":"[-77 -216 1009 877]","Flags":4,"Ascent":877,"Descent":-216,"Leading":0,"ItalicAngle":0,"StemV":87,"MissingWidth":778},"unitsPerEm":2048,"up":-109,"ut":49,"strp":259,"strs":50,"ttffile":"C:\\xampp\\htdocs\\bbnepal-rnd\\application\\third_party\\mpdf\\vendor\\mpdf\\mpdf\\src\\Config\/..\/..\/ttfonts\/Times New Roman Font.ttf","TTCfontID":0,"originalsize":85240,"sip":false,"smp":false,"BMPselected":false,"fontkey":"bentonsans","panose":" 1 5 2 2 6 3 5 4 5 2 3 4","haskerninfo":true,"haskernGPOS":false,"hassmallcapsGSUB":false,"fontmetrics":"win","useOTL":0,"rtlPUAstr":"","GSUBScriptLang":[],"GSUBFeatures":[],"GSUBLookups":[],"GPOSScriptLang":[],"GPOSFeatures":[],"GPOSLookups":[],"kerninfo":{"49":{"49":-37},"65":{"84":-110,"86":-128,"87":-80,"89":-91,"118":-74,"119":-91,"121":-91,"8217":-110},"70":{"44":-80,"46":-80,"65":-74},"76":{"84":-91,"86":-91,"87":-74,"89":-100,"121":-55,"8217":-91},"80":{"44":-110,"46":-110,"65":-91},"82":{"84":-60,"86":-80,"87":-55,"89":-55,"121":-40},"84":{"44":-74,"46":-74,"58":-49,"59":-55,"65":-80,"79":-18,"97":-69,"99":-69,"101":-69,"105":-35,"111":-69,"114":-35,"115":-69,"117":-35,"119":-69,"121":-69},"86":{"44":-128,"46":-128,"58":-74,"59":-74,"65":-128,"97":-110,"101":-110,"105":-60,"111":-128,"114":-60,"117":-60,"121":-110},"87":{"44":-91,"46":-91,"58":-37,"59":-37,"65":-110,"97":-80,"101":-80,"105":-40,"111":-80,"114":-40,"117":-40,"121":-60},"89":{"44":-128,"46":-128,"58":-91,"59":-91,"65":-110,"97":-100,"101":-100,"105":-55,"111":-100,"112":-91,"113":-110,"117":-110,"118":-100},"102":{"102":-18,"8217":55},"114":{"44":-40,"46":-55,"103":-18,"8217":37},"118":{"44":-64,"46":-64},"119":{"44":-64,"46":-64},"121":{"44":-64,"46":-64},"8216":{"8216":-74},"8217":{"115":-55,"116":-18,"8217":-74}}}
|
BIN
application/libraries/upload/ttfontdata/bentonsans.z
Normal file
BIN
application/libraries/upload/ttfontdata/bentonsans.z
Normal file
Binary file not shown.
Reference in New Issue
Block a user