99 lines
4.0 KiB
PHP
99 lines
4.0 KiB
PHP
<?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;
|
|
}
|
|
}
|
|
}
|