| 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 :TblAgencyUserRole.php
* File Description :TblAgencyUserRole Model managed all data related to roles
* Created By : Pooja Choudhary
* Created Date: 29-June-2016
*/
class Travel_Model_TblAgencyUserRole {
private $db = NULL;
public $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();
}
/*
* addAgencyUserRole() method is used to add agency's user role
* @param array
* @return true
* Created By- Pooja
* Created on- 29 June 2016
*/
public function addAgencyUserRole($agencyRoleData = array()) {
try {
$this->db->insert('TB_Agency_UserRoles', $agencyRoleData);
$this->db->lastInsertId('TB_Agency_UserRoles');
} catch (Exception $e) {
die('There has been an error. ' . $e->getMessage());
}
return 1;
}
/*
* getRoleList(); is used to get list of roles
* return array;
* Created By- Pooja
* Created on- 29 June 2016
*/
public function getRoleList($isActive = NULL, $listing = NULL,$SupplierAgencySysId=NULL) {
$whereCondition = " 1 = 1 ";
if($SupplierAgencySysId) {
$whereCondition .= " AND AgencySysId = " . $SupplierAgencySysId;
}else if (isset($_SESSION['sessionLogin_user']['intLoggedinUserAgencySysId'])) {
$whereCondition .= " AND AgencySysId = " . $_SESSION['sessionLogin_user']['intLoggedinUserAgencySysId'];
}
if ($isActive) {
$whereCondition .= " AND IsActive = " . $isActive;
}
$select = $this->db->select()
->from("TB_Agency_UserRoles")
->where($whereCondition)
->order("RoleSysId DESC");
//echo $select;
$result = $this->db->fetchAll($select);
return $result;
}
/*
* getDataByRole(); is used to get role by id
* return array;
* Created By- Pooja
* Created on- 30 June 2016
*/
public function getDataByRole($RoleSysId = NULL) {
$select = $this->db->select()
->from("TB_Agency_UserRoles")
->where("RoleSysId =?", $RoleSysId);
$result = $this->db->fetchRow($select);
return $result;
}
/**
* updateAgencyUserRoleData() method is used to update agency's user role data
* @param array
* @return true
* Created By- Pooja
* Created on- 30 June 2016
*/
public function updateAgencyUserRoleData($agencyRoleData = array(), $RoleSysId = NULL) {
// print_r($agencyRoleData); echo $RoleSysId;
$where = array('RoleSysId =?' => $RoleSysId);
$this->db->update('TB_Agency_UserRoles', $agencyRoleData, $where);
}
/**
* isAgencyRoleExists() method is used to check role is exist or not
* @param array
* @return true
* Created By- Pooja
* Created on- 30 June 2016
*/
public function isAgencyRoleExists($roleTitle, $roleId = NULL) {
$whereCondition = "RoleTitle = '$roleTitle' AND AgencySysId = " . $_SESSION['sessionLogin_user']['intLoggedinUserAgencySysId'];
if ($roleId) {
$whereCondition .= " AND RoleSysId != " . $roleId;
}
$select = $this->db->select()
->from("TB_Agency_UserRoles", array('count(*) AS totalRecords'))
->where($whereCondition);
$count = $this->db->fetchOne($select);
if ($count > 0) {
return true;
}
return false;
}
/**
* GetRole.
*
* @param string $whereCondition
* @param array $columnName
* @param bool $fetchAll
* @return array
*/
public function getRole($whereCondition = '1=1', $columnName = array('*'), $fetchAll = false) {
$query = $this->db->select()
->from("TB_Agency_UserRoles", $columnName)
->where($whereCondition);
$fetchType = @$fetchAll ? 'fetchAll' : 'fetchRow';
return $this->db->$fetchType($query);
}
//function for check agency user role
public function GetAgencyUserRole($RoleSysId, $AgentSysId) {
$agencyUserColumn = array('RoleSysId');
$agencyUserRolesColumn = array('IsAdmin');
$select = $this->_dbObj->select();
$select->from(array('tb1' => "TB_Agency_User"), $agencyUserColumn);
$select->joinLeft(array('tb2' => "TB_Agency_UserRoles"), "tb1.UserRole = tb2.RoleSysId", $agencyUserRolesColumn);
$select->where("tb1.RoleSysId = ?", $RoleSysId);
$select->where("tbl.UserSysId = ?", $AgentSysId);
$result = $this->_dbObj->fetchRow($select);
return $result;
}
public function GetAgencyRolePermission($AgencyId, $AgentSysId) {
$agencyUserColumn = array('val');
$select = $this->db->select();
$select->from(array("TB_Agency_UserRole_Permission"), $agencyUserColumn);
$select->where("AgencySysId = ?", $AgencyId);
$select->where("AgentSysId = ?", $AgentSysId);
$select->where("IsMarkForDelete = ?", 0);
$select->where("IsActive = ?", 1);
$result = $this->db->fetchALL($select);
$arraySet = array();
foreach($result as $key=>$val){
$arraySet[] = $val['val'];
}
return $arraySet;
}
public function GetAgencyRolePermissionWithContent($AgencyId, $AgentSysId) {
$agencyUserColumn = array('Title','val','url','ParentCode','IsOrder', 'IsDisplayLeftNev');
$select = $this->db->select();
$select->from(array("TB_Agency_UserRole_Permission"), $agencyUserColumn);
$select->where("AgencySysId = ?", $AgencyId);
$select->where("AgentSysId = ?", $AgentSysId);
$select->where("IsMarkForDelete = ?", 0);
$select->where("IsActive = ?", 1);
//$select->order("IsOrder ASC");
$result = $this->db->fetchALL($select);
$arraySet = array();
$i = 0;
foreach($result as $key=>$val){
$arraySet[] = $val['Title'];
$arraySet[] = $val['val'];
$arraySet[] = $val['url'];
$arraySet[] = $val['ParentCode'];
$arraySet[] = $val['IsOrder'];
$arraySet[] = $val['IsDisplayLeftNev'];
$i++;
}
return $arraySet;
}
public function GetAgencyContentPermission($AgencyId, $AgentSysId) {
$agencyUserColumn = array('val');
$select = $this->db->select();
$select->from(array("TB_Agency_UserRole_Permission_Content"));
$select->where("AgencySysId = ?", $AgencyId);
$select->where("AgentSysId = ?", $AgentSysId);
$select->where("IsMarkForDelete = ?", 0);
$select->where("IsActive = ?", 1);
$result = $this->db->fetchALL($select);
$arraySet = array();
foreach($result as $val){
$arraySet[] = $val['val'];
}
return $arraySet;
}
public function GetUserSupplierPermission($AgencyId, $AgentSysId , $UserPermissionSysId) {
$select = $this->db->select();
$select->from(array("TB_Agency_UserRole_Permission_Content"),array('UserPermissionSysId', 'IsActive' , 'IsMarkForDelete'));
$select->where("AgencySysId = ?", $AgencyId);
$select->where("AgentSysId = ?", $AgentSysId);
$select->where("UserPermissionSysId = ?", $UserPermissionSysId);
//$select->where("IsMarkForDelete = ?", 0);
//$select->where("IsActive = ?", 1);
$result = $this->db->fetchRow($select);
if(!is_array($result)) {
$result = array("UserPermissionSysId" => $UserPermissionSysId);
} else if(is_array($result) && $result['IsActive'] == 1 && $result['IsMarkForDelete'] == 0) {
$result = array("UserPermissionSysId" => $UserPermissionSysId);
} else {
$result = array();
}
return $result;
}
}