| 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
class Travel_Model_AgencyAuth extends Zend_Db_Table_Abstract {
private $_authAdapter;
private $_dbAdapter;
private $_username;
private $_IsB2BAgent;
private $_password;
private $_storage;
protected $_userTable = "TB_Agency_User";
protected $_identityColumn = "EmailId";
protected $_credentialColumn = "Password";
protected $_TRColumn = "IsB2BAgent";
public $db;
const USER_NAMESPACE = 'AgencyUser';
protected $_resultRowColumns = array('IsAllowRandomCodeAccess', 'IsB2CSite', 'IsB2BAgent', 'AgencySysId', 'UserSysId', 'FirstName', 'LastName', 'UserRole', 'ContactNo1', 'IsInsurance', 'EmailId', 'IsActive', 'IsApproved', 'IsMarkForDel', 'UserPicPath','IsDisplayB2CWallet');
public function __construct($username = null, $password = null, $AgencySysId = NULL, $userrole=0) {
$this->_authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
$this->_authAdapter->setTableName($this->_userTable)
->setIdentityColumn($this->_identityColumn)
->setCredentialColumn($this->_credentialColumn);
if($AgencySysId) {
$this->_authAdapter->getDbSelect()->where("IsB2BAgent=$userrole AND (AgencySysId = $AgencySysId OR CreatedByUserSysId = $AgencySysId)");
} else {
$this->_authAdapter->getDbSelect()->where('IsB2BAgent = 0');
}
$this->_username = $username;
$this->_password = $password;
$this->_IsB2BAgent = 0;
$this->_storage = new Zend_Session_Namespace(self::USER_NAMESPACE);
$this->db = Zend_Db_Table::getDefaultAdapter();
}
public function __destruct() {
$this->db->closeConnection();
}
public function authenticate() {
$this->_authAdapter->setIdentity($this->_username);
$this->_authAdapter->setCredential($this->_password);
$this->_authAdapter->setAmbiguityIdentity(true);
$result = $this->_authAdapter->authenticate();
if ($result->isValid()) {
$row = $this->_authAdapter->getResultRowObject($this->_resultRowColumns);
$this->_storage->user = $row;
return $result;
}
}
public static function getIdentity() {
$storage = new Zend_Session_Namespace(self::USER_NAMESPACE);
if (isset($storage->user)) {
return $storage->user;
}
}
public static function destroy() {
$storage = new Zend_Session_Namespace(self::USER_NAMESPACE);
$storage->unsetAll();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$sessionLogin_user->unsetAll();
unset($_SESSION['timeout']);
}
public function select_query($isactive) {
$sql = " SELECT IsActive,IsApproved,IsActiveSubscription,IsSMSApi FROM TB_Agency WHERE AgencySysId=" . $isactive;
return $this->db->query($sql)->fetchAll();
}
public function loginlog($loginData = array()) {
$dbtable = new Zend_Db_Table('TB_Agency_Loggedin_Log');
$dbtable->insert($loginData);
}
// ADDED BY SANDEEP NEGI 24-03-2021 START //
public function getLogsData($table, $AgencySysId) {
$select = $this->db->select();
$select->order("tb1.LogSysId DESC");
$select->from(array('tb1' => $table), array('*'))
->joinLeft(array('tb3' => "TB_Agency"), "tb1.AgencySysId = tb3.AgencySysId ", array('IsAutoProposalOnFBLead', 'AgencySysId', 'DisplayName', 'EmailKey', 'Logo'))
->where("tb1.AgencySysId =?", $AgencySysId);
if (!empty($this->searchArr) && isset($this->searchArr)) {
// print_r($this->searchArr); die("modal");
$searchArr = $this->searchArr;
$dateFrom = (isset($searchArr['dateFrom']) && !empty($searchArr['dateFrom'])) ? date("Y-m-d", strtotime($searchArr['dateFrom'])) : '';
$dateTo1 = (isset($searchArr['dateTo']) && !empty($searchArr['dateTo'])) ? date("Y-m-d", strtotime($searchArr['dateTo'])) : '';
$dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateTo1)));
// echo $dateTo; die();
if (isset($dateFrom) && isset($dateFrom) && $dateFrom != '' && $dateTo != '') {
$select->where("(tb1.CreateDate) BETWEEN '$dateFrom' AND '$dateTo'");
}
} else {
$dateFrom = date('Y-m-d');
$dateTo = date('Y-m-d', strtotime("+ 1 day"));
$select->where("(tb1.CreateDate) BETWEEN '$dateFrom' AND '$dateTo'");
}
$result = $this->db->fetchAll($select);
return $result;
}
}