| 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/b2c.hellogtx.com/application/admin/controllers/ |
Upload File : |
<?php
/***************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name : ManagefareController.php
* File Desc. : Managefare controller managed all staic content pages
* Created By : Md Sabir <sabir@catpl.co.in>
* Created Date : 17 May 2021
* Updated Date : 17 May 2021
***************************************************************/
class Admin_ManagefareController extends Zend_Controller_Action
{
public $dbAdapter;
public $perPageLimit;
public $siteurl;
public $DIR_WRITE_MODE;
public function init()
{
/*Initialize db and session access */
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$this->siteurl = $aConfig['bootstrap']['siteUrl'];
$this->IsSeriesFare = $aConfig['bootstrap']['IsSeriesFare'];
$this->appmode = $aConfig['bootstrap']['appmode'];
$this->gtxagencysysid = $aConfig['bootstrap']['gtxagencysysid'];
$this->per_page_record = 20;
$this->dbAdapter = Zend_Db_Table::getDefaultAdapter();
$auth = Zend_Auth::getInstance();
$authStorage = $auth->getStorage()->read();
$this->username = $authStorage->username;
$this->admin_type = $authStorage->role;
$this->current_time = time();
$this->iconUrl = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/aboutsite/';
$this->large_image_width = $aConfig['bootstrap']['large_image_width'];
$this->large_image_height = $aConfig['bootstrap']['large_image_height'];
$this->medium_image_width = $aConfig['bootstrap']['medium_image_width'];
$this->medium_image_height = $aConfig['bootstrap']['medium_image_height'];
$this->small_image_width = $aConfig['bootstrap']['small_image_width'];
$this->small_image_height = $aConfig['bootstrap']['small_image_height'];
$this->DIR_WRITE_MODE = 0777;
$this->table = 'tbl_manage_fare';
}
/**
* index() method is used to admin login for form call
* @param Null
* @return Array
*/
public function indexAction()
{
//Check admin logedin or not
$this->checklogin();
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$crud = new Admin_Model_CRUD();
$getData = array();
$resultset = $crud->rv_select_all($this->table, ['*'], [], ['Id' => 'ASC']);
$busmarkupdata = $crud->rv_select_all('tb_mp_stdmarkup_bus', ['*'], ['AgencySysId' => $this->gtxagencysysid, 'IsActive' => '1'], ['Id' => 'ASC']);
$carmarkupdata = $crud->rv_select_all('tb_mp_stdmarkup_car', ['*'], ['AgencySysId' => $this->gtxagencysysid, 'IsActive' => '1'], ['Id' => 'ASC']);
$this->view->resultset = $resultset;
$this->view->busmarkupdata = $busmarkupdata;
$this->view->carmarkupdata = $carmarkupdata;
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$data = $busmarkupdata['0']['MarkUp'];
//echo"<pre>";print_r($getData);die;
$MarkUp = (isset($getData['MarkUp']) && !empty($getData['MarkUp']))?$getData['MarkUp']:0;
$car_Markup = (isset($getData['Car_MarkUp']) && !empty($getData['Car_MarkUp']))?$getData['Car_MarkUp']:0;
$faretype = $getData['faretype'];
$markup_b2c = $getData['markup_b2c'];
$markup_b2b = $getData['markup_b2b'];
$ApiRoundTrip = (isset($getData['ApiRoundTrip']) && !empty($getData['ApiRoundTrip'])) ? $getData['ApiRoundTrip'] : 7;
$faretype_rename = $getData['faretype_rename'];
$remarks = $getData['remarks'];
if (isset($getData['save']) == "Save") {
// echo "<pre>";print_r($getData);die;
if ($faretype) {
foreach ($faretype as $key => $value) {
$RowData = $crud->rv_select_row($this->table, ['*'], ['faretype' => $value], ['Id' => 'ASC']);
$showhide_b2b_ = isset($getData['showhide_b2b_' . $value]) ? $getData['showhide_b2b_' . $value] : 0;
$showhide_b2c_ = isset($getData['showhide_b2c_' . $value]) ? $getData['showhide_b2c_' . $value] : 0;
$IsSeriesFareAllow = isset( $getData['IsSeriesFareAllow']) ? $getData['IsSeriesFareAllow'] : 0;
if($this->IsSeriesFare==1){
$savePageData = [
'faretype' => ($value),
'faretype_rename' => isset($faretype_rename[$key]) ? str_replace(' ', '_', $faretype_rename[$key]) : 0,
'remarks' => isset($remarks[$key]) ? $remarks[$key] : '',
'markup_b2c' => isset($markup_b2c[$key]) ? $markup_b2c[$key] : 0,
'markup_b2b' => isset($markup_b2b[$key]) ? $markup_b2b[$key] : 0,
'showhide_b2b' => ($showhide_b2b_),
'showhide_b2c' => ($showhide_b2c_),
'isMarkForDel' => 0,
'color' => $getData['color'][$key],
'ApiRoundTrip' => $ApiRoundTrip,
'IsSeriesFareAllow' =>$IsSeriesFareAllow,
];
}else{
$savePageData = [
'faretype' => ($value),
'faretype_rename' => isset($faretype_rename[$key]) ? str_replace(' ', '_', $faretype_rename[$key]) : 0,
'remarks' => isset($remarks[$key]) ? $remarks[$key] : '',
'markup_b2c' => isset($markup_b2c[$key]) ? $markup_b2c[$key] : 0,
'markup_b2b' => isset($markup_b2b[$key]) ? $markup_b2b[$key] : 0,
'showhide_b2b' => ($showhide_b2b_),
'showhide_b2c' => ($showhide_b2c_),
'isMarkForDel' => 0,
'color' => $getData['color'][$key],
'ApiRoundTrip' => $ApiRoundTrip,
];
}
// echo "<pre>";
// if (!empty($RowData)) {
// $savePageData['UpdateDate'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
// $crud->rv_update($this->table, $savePageData, ['faretype =?' => $value]);
// } else {
$crud->rv_delete($this->table,['faretype =?' => $value]);
$savePageData['CreateDate'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
$savePageData['UpdateDate'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
$crud->rv_insert($this->table, $savePageData);
//print_r($savePageData);die;
// }
}
$busmarkup = [
'MarkUp' => $MarkUp,
'AgencySysId' => $this->gtxagencysysid,
'UpdateDate' => Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss'),
];
$crud->rv_update('tb_mp_stdmarkup_bus', $busmarkup, ['id=?' => 1]);
$carmarkup = [
'MarkUp' => $car_Markup,
'AgencySysId' => $this->gtxagencysysid,
'UpdateDate' => Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss'),
];
$crud->rv_update('tb_mp_stdmarkup_car', $carmarkup, ['id=?' => 1]);
$this->view->successMessage = "Saved successfully.";
$this->_helper->flashMessenger->addMessage("Saved successfully.");
$this->_redirect("/admin/managefare");
}
}
}
}
public function sanitize_data($string)
{
$searchArr = array("iframe", "script", "document", "write", "alert", "%", "@", "$", ";", "+", "|", "#", "<", ">", ")", "(", "'", "\'", ",", "and ", " &", "& ", "and", " and", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
$input_data = strtolower($string);
$input_data = str_replace($searchArr, "", $input_data);
$input_data = str_replace(" ", "-", $input_data);
//echo $input_data; die;
return $input_data;
}
/**
* checklogin() method is used to check admin logedin or not
* @param Null
* @return Array
*/
public function checklogin()
{
if (($this->admin_type == "superadmin") || ($this->admin_type == "admin")) {
$auth = Zend_Auth::getInstance();
$hasIdentity = $auth->hasIdentity();
/*************** check admin identity ************/
if (!$hasIdentity) {
$this->_redirect('admin/index/index');
}
} else {
$this->_redirect('admin/index/index');
}
}
}