| 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/admin/controllers/ |
Upload File : |
<?php
/**
* Class Currency
*
* @name Currency
* @author Shailender Joshi
* @editor Shailender Joshi
* @created 6 Oct 2016
* @updateed 6 Oct 2016
* @version 1.0
* @copyright Catabatic India Pvt Ltd
* Handle Currency Related function for Front end only
*
*/
class Admin_CurrencyController extends Catabatic_ValidateAdmin {
public $imageUrl = NULL;
public $baseUrl = '';
public $tablename = '';
public $current_Modal = '';
public $per_page_record = GRID_PER_PAGE_RECORD_COUNT;
public function init() {
parent::init();
$request = Zend_Controller_Front::getInstance()->getRequest();
$this->baseUrl = $request->getScheme() . '://' . $request->getHttpHost();
$this->current_Modal = new Travel_Model_TblCurrency();
$this->GeneralFunction_Modal = new Travel_Model_GeneralFunction(); // Make object of generel function class
$this->tablename = 'TB_Master_Currency';
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$this->intLoggedinUserId = $sessionLogin_user->intLoggedinUserId;
$this->intLoggedinUserAgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$this->imageUrl = $this->baseUrl . "/public/upload/currency/";
}
public function indexAction() {
$this->view->messages = $this->_helper->flashMessenger->getMessages();
//Start Search Symbol
$searchArr = array();
$getData = array();
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
if (!empty($getData)) {
$Title = (@$getData['Title'] != '') ? @$getData['Title'] : '';
$Symbol = (@$getData['Symbol'] != '') ? @$getData['Symbol'] : '';
$countryList = (@$getData['countryList'] != '') ? @$getData['countryList'] : '';
$filter1 = (@$getData['filter1'] != 'All') ? @$getData['filter1'] : ''; // status part
$searchArr = array(
'Title' => $Title,
'Symbol' => $Symbol,
'countryList' => $countryList,
'filter1' => $filter1,
);
// print_r($getData);
}
} else {
$Title = $this->_getParam('Title');
$Symbol = $this->_getParam('Symbol');
$countryList = $this->_getParam('countryList');
$filter1 = ($this->_getParam('filter1') != 'All' ) ? $this->_getParam('filter1') : '';
$searchArr = array(
'Title' => $Title,
'Symbol' => $Symbol,
'countryList' => $countryList,
'filter1' => $filter1,
);
}
//print_r($searchArr);
$this->current_Modal->searchArr = $searchArr; // send Array - searchArr() to modal just for pagination
$this->view->searchArr = $searchArr;
// Get Country list array
// getRecordListingWhere(tablename, columnName_array, where_array, orderby, order);
$country_list = $this->GeneralFunction_Modal->getRecordListingWhere('TB_Master_Geo_Country', array('ContId', 'Title'), array('IsMarkForDel' => 0, 'IsActive' => 1), 'Title');
$this->view->countrylist = $country_list;
//print_r($country_list);
// pagination start
$page = $this->_request->getParam('page', 1); //get curent page param, default 1 if param not available.
$data = $this->current_Modal->getCurrencyListingRecord(); // get all details according to filter or without filter
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($data);
$paginator->setCurrentPageNumber($this->getRequest()->getParam('page')); // page number
$perPage = $paginator->setItemCountPerPage($this->per_page_record); // number of items to show per page
$this->view->paginator = $paginator;
$this->view->totalrec = $paginator->getTotalItemCount();
$this->view->currentPage = $this->_getParam('page');
}
public function addAction() {
$form = new Travel_Form_Currency();
$form->setAction($this->baseUrl . "/admin/currency/add")->setMethod("POST")->setName("addCurrencyForm");
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
if ($form->isValid($post)) {
$orignalFileName = $_FILES['Logo']['name'];
$strFileName = $this->_helper->General->toTitle($post['Title']);
$fileExt = $this->_helper->General->getFileExtension($orignalFileName);
$fileName = $strFileName . '_' . time() . '.' . $fileExt;
$originalThumbFolder = $_SERVER["DOCUMENT_ROOT"] . "/public/upload/currency";
/* Create directory if not exists */
if (!file_exists($originalThumbFolder)) {
@mkdir($originalThumbFolder, 0777, true);
}
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination("public/upload/currency/");
$upload->addFilter('Rename', "public/upload/currency/" . $fileName);
$file = $upload->getFileName();
if (isset($orignalFileName) && $orignalFileName != "") {
$updateimage = $fileName;
} else {
$updateimage = "";
}
try {
$addData = array(
'Title' => trim($this->sanitize_data($post['Title'])),
'Symbol' => trim($this->sanitize_data($post['Symbol'])),
'Icon' => ($updateimage != '') ? $updateimage : '',
'RelatedCountries' => ($post['countryList'] != '') ? implode(',', trim($this->sanitize_data($post['countryList']))) : '',
'CreateDate' => date('Y-m-d h:i:s'),
'UpdatedDate' => '',
'IsActive' => 1,
'IsDelete' => 0
);
//print_r($addData);
// check Same Title name already exists or not ( Avoid duplicate entry)
if ($post['Symbol'] != '') {
$entryDate = $this->GeneralFunction_Modal->getRecordListingWhere($this->tablename, array('Title'), array('Symbol' => $addData['Symbol']));
}
//print_r($entryDate); echo count($entryDate);
if (count($entryDate) >= 1) {
$this->view->eMsg = "Currency already exists.";
} else {
$isinserted = $this->GeneralFunction_Modal->insertTable($this->tablename, $addData);
if ($isinserted) {
$upload->receive(); // upload image
$this->_helper->flashMessenger->addMessage("Record added successfully");
$this->_redirect("admin/currency");
}
}
} catch (Zend_file_transfer_exeception $e) {
$this->view->error_msg = $e->getMessage();
}
}
}
$this->view->others = array('baseUrl' => $this->baseUrl, 'action_name' => 'add');
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function editAction() {
$encodeId = ($this->getRequest()->getParam('id'));
$intId = (int) base64_decode($encodeId);
$page = $this->getRequest()->getParam('page');
if (!empty($intId) || !is_int($intId)) {
# get listings of airlines
$colsArr = array('*');
$resultset = $this->GeneralFunction_Modal->getDetailsByUniqueId($this->tablename, $colsArr, 'CurrencyType', $intId);
$form = new Travel_Form_Currency();
$form->setMethod("POST")->setName("editCurrencyForm");
$editFormdata = array(
'Title' => $resultset['Title'],
'Symbol' => $resultset['Symbol'],
'Logo' => $resultset['Icon'],
);
// split country string into array and then populate in form
$editFormdata['countryList'] = explode(',', $resultset['RelatedCountries']);
$form->populate($editFormdata);
$this->view->Logo = @$resultset['Icon'];
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
if ($form->isValid($post)) {
if (!empty($_FILES['Logo']['name'])) {
$orignalFileName = $_FILES['Logo']['name'];
$strFileName = $this->_helper->General->toTitle($post['Title']);
$fileExt = $this->_helper->General->getFileExtension($orignalFileName);
$fileName = $strFileName . '_' . time() . '.' . $fileExt;
$originalThumbFolder = $_SERVER["DOCUMENT_ROOT"] . "/public/upload/currency";
/* Create directory if not exists */
if (!file_exists($originalThumbFolder)) {
@mkdir($originalThumbFolder, 0777, true);
}
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination("public/upload/currency/");
$upload->addFilter('Rename', "public/upload/currency/" . $fileName);
$file = $upload->getFileName();
}
if (isset($orignalFileName) && $orignalFileName != "") {
$updateimage = $fileName;
} else {
$updateimage = $resultset['Icon'];
}
try {
if (!empty($_FILES['Logo']['name'])) {
$upload->receive();
unlink($originalThumbFolder . "/" . $resultset['Icon']);
}
$editData = array(
'Title' => trim($this->sanitize_data($post['Title'])),
'Symbol' => trim($this->sanitize_data($post['Symbol'])),
'Icon' => $updateimage,
'RelatedCountries' => ($post['countryList'] != '') ? implode(',', trim($this->sanitize_data($post['countryList']))) : '',
);
$where = array('CurrencyType =?' => $intId);
$this->GeneralFunction_Modal->updateTable($this->tablename, $editData, $where);
$this->_helper->flashMessenger->addMessage("Record updated successfully");
$this->_redirect("admin/currency/index/page/$page");
} catch (Zend_Form_Exception $e) {
$this->view->error_msg = $e->getMessage();
}
}
}
$this->view->resultset = $resultset;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
}
public function deleteAction() {
/* Disable Layout & set Render False */
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$id = base64_decode($this->getRequest()->getParam('id'));
$currentPage = base64_decode($this->getRequest()->getParam('page'));
if ($id) {
$editData['IsDelete'] = 1;
$where = array('CurrencyType =?' => $id);
$isupdated = $this->GeneralFunction_Modal->updateTable($this->tablename, $editData, $where);
if ($isupdated) {
$this->_helper->flashMessenger->addMessage("Record Deleted successfully.");
$this->_redirect("admin/currency/index/page/$currentPage");
}
} else {
$this->_redirect("admin/currency/index/page/$currentPage");
}
}
public function filterStatusAction() {
/* Disable Layout & set Render False */
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$filter = $this->getRequest()->getParam('filter');
$val = $this->getRequest()->getParam('val');
$id = base64_decode($this->getRequest()->getParam('id'));
$currentPage = $this->getRequest()->getParam('page');
if ($id && $filter) {
if ($filter == 'filter1') {
$editData['IsActive'] = ($val == 0) ? 1 : 0;
}
if ($filter == 'filter2') {
$editData['IsApprove'] = ($val == 0) ? 1 : 0;
}
$where = array('CurrencyType =?' => $id);
$isupdated = $this->GeneralFunction_Modal->updateTable($this->tablename, $editData, $where);
if ($isupdated) {
$this->_helper->flashMessenger->addMessage("Record Update successfully.");
$this->_redirect("admin/currency/index/page/$currentPage");
}
} else {
$this->_redirect("admin/currency/index/page/$currentPage");
}
}
}