| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/b2bzend/application/models/ |
Upload File : |
<?php
/*
* Catabatic Technology Pvt. Ltd.
* File Name :TblAgencyDept.php
* File Description :TblAgencyDept Model managed department data
* Created By : Pooja Choudhary
* Created Date: 29-June-2016
*/
class Travel_Model_TblAgencyDept {
private $db = NULL;
private $baseUrl = "";
public function __construct() {
$request = Zend_Controller_Front::getInstance()->getRequest();
$this->baseUrl = $request->getScheme() . '://' . $request->getHttpHost();
$this->db = Zend_Db_Table::getDefaultAdapter();
}
public function __destruct() {
$this->db->closeConnection();
}
/*
* addAgencyDept() method is used to add agency department
* @param array
* @return true
* Created By- Pooja
* Created on- 29 June 2016
*/
public function addAgencyDept($agencyDeptData = array()) {
try {
$this->db->insert('TB_Agency_Dept', $agencyDeptData);
$this->db->lastInsertId('TB_Agency_Dept');
} catch (Exception $e) {
die('There has been an error. ' . $e->getMessage());
}
return 1;
}
/*
* getDepartmentList(); is used to get list of departments
* return array;
* Created By- Pooja
* Created on- 29 June 2016
*/
public function getDepartmentList($isActive = NULL) {
// echo '<pre>';print_r($_SESSION); die;
$whereCondition = " 1 = 1";
if(@$_SESSION['sessionLogin_user']['intLoggedinUserAgencySysId']){
$whereCondition .= " AND OrgSysId = " . $_SESSION['sessionLogin_user']['intLoggedinUserAgencySysId'];
}
if ($isActive) {
$whereCondition .= " AND IsActive = ".$isActive;
}
$select = $this->db->select()
->from("TB_Agency_Dept")
->where($whereCondition)
->order("DeptSysId Desc");
$result = $this->db->fetchAll($select);
return $result;
}
/*
* getDataByDepartment(); is used to get department by id
* return array;
* Created By- Pooja
* Created on- 29 June 2016
*/
public function getDataByDepartment($DeptSysId = NULL) {
$select = $this->db->select()
->from("TB_Agency_Dept")
->where("DeptSysId =?", $DeptSysId);
$result = $this->db->fetchRow($select);
return $result;
}
/**
* updateAgencyDeptData() method is used to update agency's department data
* @param array
* @return true
* Created By- Pooja
* Created on- 29 June 2016
*/
public function updateAgencyDeptData($agencyDeptData = array(), $DeptSysId = NULL) {
// print_r($agencyDeptData); echo $DeptSysId;
$where = array('DeptSysId =?' => $DeptSysId);
return $this->db->update('TB_Agency_Dept', $agencyDeptData, $where);
}
/**
* isAgencyDeptExists() method is used to check department is exist or not
* @param array
* @return true
* Created By- Pooja
* Created on- 30 June 2016
*/
public function isAgencyDeptExists($deptTitle, $depId = NULL) {
$whereCondition = "DeptTitle = '$deptTitle' AND OrgSysId = " . $_SESSION['sessionLogin_user']['intLoggedinUserAgencySysId'];
// $where = array('DeptTitle =?' => $deptTitle,'OrgSysId =?' => CURRENT_AGENCY_SYS_ID);
if ($depId) {
// $where = array('DeptSysId =?' => $depId);
$whereCondition .= " AND DeptSysId != " . $depId;
}
$select = $this->db->select()
->from("TB_Agency_Dept", array('count(*) AS totalRecords'))
->where($whereCondition);
$count = $this->db->fetchOne($select);
if ($count > 0) {
return true;
}
return false;
}
public function checkIsOpsDept($OrgSysId = NULL) {
$select = " SELECT IsOps FROM TB_Agency_Dept "
. "WHERE OrgSysId ='".$OrgSysId."' "
. "AND IsOps = '1'";
$result = $this->db->fetchOne($select);
if ($result > 0) {
return true;
}
return false;
}
public function getOpsDeptDet($AgencySysId,$isOps=NULL) {
$OperColArray = array('OrgSysId','DeptSysId','DeptTitle','IsActive','IsOps');
$select = $this->db->select();
$select->from(array('tb1' => "TB_Agency_Dept"), $OperColArray);
$select->where("tb1.OrgSysId = ?", $AgencySysId);
$select->where("tb1.IsActive = ?", 1);
$isOps?$select->where("tb1.isOps = ?", 1):'';
$result = $this->db->fetchAll($select);
return $result;
}
public function getOpsDeptuserMapDet($AgencySysId,$AgentSysId=NULL,$isOps=NULL,$PlanType = null) {
$agencyUserArray = array('AgencySysId','EmailId','UserSysId','FirstName','LastName','ContactNo1');
$operDepArray=array('IsOps');
$operDepPlanMapArray=array('PlanSysId');
$select = $this->db->select();
$select->from(array('tb1' => "TB_Agency_User"), $agencyUserArray);
$select->joinLeft(array("tb2"=> "TB_Agency_Dept"), "tb1.AgencySysId=tb2.OrgSysId and tb2.IsActive=1 and tb2.IsOps=1" , $operDepArray);
$select->joinLeft(array("tb3"=> "TB_Agency_DeptPlanMap"), "tb2.DeptSysId=tb3.DeptSysId and tb1.UserSysId=tb3.UserSysId" , $operDepPlanMapArray);
$select->where("tb1.AgencySysId = ?", $AgencySysId);
$AgentSysId?$select->where("tb1.UserSysId IN( ".$AgentSysId.")"):'';
$select->where("tb1.IsActive = ?", 1);
$select->where("tb1.IsActive = ?", 1);
if($PlanType){
$select->where("tb3.PlanSysId = ?", $PlanType);
}
//$isOps?$select->where("tb1.isOps = ?", 1):'';
$result = $this->db->fetchAll($select);
return $result;
}
}