D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
ksclnmuac
/
public_html
/
alumni
/
application
/
models
/
admin
/
Filename :
BranchManagement.php
back
Copy
<?php /** * Model For Handling All DB Operations Related To Branches * * @author Ankit Srivastava */ defined('BASEPATH') OR exit('No direct script access allowed'); class BranchManagement extends CI_Model { function createNewBranch(array $newBranchInfo) { $this->db->insert('tbl_sms_branch_master', $newBranchInfo); return $this->db->insert_id(); } function getAllBranches() { $this->db->select("*,TSMA.admin_name addedByAdmin,TSMU.admin_name updatedByAdmin"); $this->db->from('tbl_sms_branch_master TSBM'); $this->db->join('tbl_city TCM', 'TSBM.branch_city = TCM.city'); $this->db->join('tbl_state TSM', 'TSBM.branch_state = TSM.state'); $this->db->join('tbl_admins TSMA', 'TSBM.branch_added_by = TSMA.admin_id'); $this->db->join('tbl_admins TSMU', 'TSBM.branch_updated_by = TSMU.admin_id'); $this->db->order_by("TSBM.branch_updated_on", "desc"); return $this->db->get(); } function getBranchInfoBy($branch_id) { $this->db->select("*,TSMA.admin_name addedByAdmin,TSMU.admin_name updatedByAdmin"); $this->db->from('tbl_sms_branch_master TSBM'); $this->db->join('tbl_city TCM', 'TSBM.branch_city = TCM.city'); $this->db->join('tbl_state TSM', 'TSBM.branch_state = TSM.state'); $this->db->join('tbl_admins TSMA', 'TSBM.branch_added_by = TSMA.admin_id'); $this->db->join('tbl_admins TSMU', 'TSBM.branch_updated_by = TSMU.admin_id'); $this->db->where("TSBM.branch_id", $branch_id); return $this->db->get(); } function getAllNonDeletedBrances() { $this->db->select('*'); $this->db->from('tbl_sms_branch_master'); $this->db->where('branch_delete_status', "F"); return $this->db->get(); } function getAllNonDeletedActiveBrances() { $this->db->select('*'); $this->db->from('tbl_sms_branch_master'); $this->db->where('branch_active_status', "T"); $this->db->where('branch_delete_status', "F"); return $this->db->get(); } function getBranchInfoByName($branch_name) { $this->db->select('*'); $this->db->from('tbl_sms_branch_master'); $this->db->where('branch_name', $branch_name); return $this->db->get(); } function getBranchInfoByEmail($branch_email) { $this->db->select('*'); $this->db->from('tbl_sms_branch_master'); $this->db->where('branch_email', $branch_email); return $this->db->get(); } function getBranchInfoByMobile($branch_mobile) { $this->db->select('*'); $this->db->from('tbl_sms_branch_master'); $this->db->where('branch_mobile_no', $branch_mobile); return $this->db->get(); } function updateBranchInfo(array $branchUpdatedInfo) { $this->db->where('branch_id', $branchUpdatedInfo['branch_id']); return $this->db->update('tbl_sms_branch_master', $branchUpdatedInfo); } function isBranchNameSafeUpdate($branch_Id, $branch_name) { $this->db->select("*"); $this->db->from('tbl_sms_branch_master'); $this->db->where('branch_name', $branch_name); $this->db->where('branch_id != ' . $branch_Id); $result = $this->db->get()->result(); if (sizeof($result)) { return FALSE; } else { return TRUE; } } function isBranchEmailSafeUpdate($branch_Id, $branch_email) { $this->db->select("*"); $this->db->from('tbl_sms_branch_master'); $this->db->where('branch_email', $branch_email); $this->db->where('branch_id != ' . $branch_Id); $result = $this->db->get()->result(); if (sizeof($result)) { return FALSE; } else { return TRUE; } } function isBranchMobileSafeUpdate($branch_Id, $branch_mobile) { $this->db->select("*"); $this->db->from('tbl_sms_branch_master'); $this->db->where('branch_mobile_no', $branch_mobile); $this->db->where('branch_id != ' . $branch_Id); $result = $this->db->get()->result(); if (sizeof($result)) { return FALSE; } else { return TRUE; } } }