| 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/prathamtour.com/application/admin/controllers/ |
Upload File : |
<?php
class Admin_MemberController extends Catabatic_Rvadmin {
public $dbAdapter;
public $perPageLimit;
public $siteurl;
public $DIR_WRITE_MODE;
public function init() {
parent::init(); //
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$BootStrap = $aConfig['bootstrap'];
$this->stylecss = $BootStrap['stylecss'];
/* Initialize db and session access */
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$this->siteurl = $aConfig['bootstrap']['siteUrl'];
$this->appmode = $aConfig['bootstrap']['appmode'];
$this->AgencyId = $aConfig['bootstrap']['gtxagencysysid'];
$this->per_page_record = 25;
$this->dbAdapter = Zend_Db_Table::getDefaultAdapter();
$options = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('bootstrap');
$baseUrl = $options['siteUrl'];
$auth = Zend_Auth::getInstance();
$authStorage = $auth->getStorage()->read();
$this->username = $authStorage->username;
$this->imageUrl = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/'.$this->stylecss.'/trusted/';
}
public function indexAction() {
$this->checklogin();
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$crud = new Admin_Model_CRUD();
$getData = array();
if($this->getRequest()->isPost())
{
$getData = $this->getRequest()->getPost();
$searchArr = array(
'Title'=>$getData['Title'],
'rows'=>$getData['rows'],
'page'=>$getData['page'],
);
$resulsetold = $crud->getCount( 'tbl_trustedmember',['status' =>1],'id');
$crud->searchArr = $searchArr;
$resultset = $crud->rv_select_static( 'tbl_trustedmember',['id','title','description','status','image'],[''],['id'=> 'DESC']);
// echo"<pre>";print_r( $resultset);die();
if (count($resultset) > 0) {
foreach ($resultset as $resultkey => $resultval) {
$result1[] = [
'id' => $resultval['id'],
'title' => $resultval['title'],
'description' => $resultval['description'],
'image'=>$resultval['image'],
'status' => $resultval['status']==1?'Active':'Deactive',
];
}
}
$result = Zend_Json::encode($result1);
$newResult = Zend_Json::decode($result,false);
$finalResult["total"]=$resulsetold[0]['id'];
$finalResult["rows"]=$newResult;
echo json_encode($finalResult);
exit;
}
}
public function editmemberAction(){
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Editmember();
$pId = (int)$this->getRequest()->getParam("id");
$form->setMethod("POST");
$form->setAction("admin/member/editmember/id/".$pId);
$form->setName("edit_member_page");
// echo"<pre>";print_r($this->imageUrl );die();
if( $this->getRequest()->isPost() ) {
$getData = $this->getRequest()->getPost();
if($form->isValid($getData)) {
//-------Start Code for Approve and Publish content---------//
if(isset($getData['save'])=="Save") {
$images = $_FILES['image']['name'];
if (isset($images) && !empty($images)) {
$orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->imageUrl . $pId;
$fileExt = $this->_helper->General->getFileExtension($images);
$fileName = $pId . '_' . $this->current_time . '.' . $fileExt;
// echo '<pre>'; print_r($fileName);die;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
$temp_file_name = $_FILES["image"]["tmp_name"]; // temprary file name
// echo"<pre>";print_r();die();
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName);
$originalLargeFolder = $orignalFolderName . "/large";
$originalMediumFolder = $orignalFolderName . "/medium";
$originalSmallFolder = $orignalFolderName . "/small";
Catabatic_Helper::resizeImages($orignalFolderName,$originalLargeFolder,$fileName,$this->banner_large_image_width,$this->banner_large_image_height);
Catabatic_Helper::resizeImages($orignalFolderName,$originalMediumFolder,$fileName,$this->banner_medium_image_width,$this->banner_medium_image_height);
Catabatic_Helper::resizeImages($orignalFolderName,$originalSmallFolder,$fileName,$this->banner_small_image_width,$this->banner_small_image_height);
$editPageData = [
'title'=>($getData['title']),
'description'=>($getData['description']),
'status'=>"{$getData['status_number']}"
];
if ($fileName != "") {
$editPageData['image'] = $fileName;
}
// echo "<pre>";print_r($editPageData);die;
$crud->rv_update('tbl_trustedmember', $editPageData, ['id =?'=>$pId]);
$this->view->successMessage ="Content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Content has been updated successfully.");
$this->_redirect("/admin/member/index");
}
}
}
}
$result = $crud->getCmsdata('tbl_trustedmember', ['*'], ['id'=>$pId], ['id'=>'DESC']);
//echo "<pre>";print_r($result);die;
$editdata["id"] = @$result->id;
$editdata["title"] = @$result->title;
$editdata["description"] = @$result->description;
$editdata["image"] = @$result->image;
$editdata["status_number"] = @$result->status;
$form->populate($editdata);
$this->view->id = @$result->id;
$this->view->form = $form;
$this->view->image = @$result->image;
//die('ok');
}
public function addmemberAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Addmember();
// $pId = (int)$this->getRequest()->getParam("id");
$lastRow = $crud->getCmsdata('tbl_trustedmember', ['Id'], ['Id'], ['Id'=>'DESC']);
$pId = $lastRow['Id'] + 1;
$form->setMethod("POST");
$form->setAction("admin/member/addmember");
$form->setName("add_member");
// echo "<pre>";print_r($pId);die;
$resultsetPackage = $crud->rv_select_all('tbl_trustedmember', ['*'], ['id'=>$pId], ['id'=>'DESC']);
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
if ($form->isValid($getData)) {
//-------Start Code for Approve and Publish content---------//
if (isset($getData['save']) == "Save") {
$images = $_FILES['image']['name'];
if (isset($images) && !empty($images)) {
$orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->imageUrl . $pId;
$fileExt = $this->_helper->General->getFileExtension($images);
$fileName = $pId . '_' . $this->current_time . '.' . $fileExt;
// echo '<pre>'; print_r($fileName);die;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
$temp_file_name = $_FILES["image"]["tmp_name"]; // temprary file name
// echo"<pre>";print_r();die();
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName);
$originalLargeFolder = $orignalFolderName . "/large";
$originalMediumFolder = $orignalFolderName . "/medium";
$originalSmallFolder = $orignalFolderName . "/small";
Catabatic_Helper::resizeImages($orignalFolderName,$originalLargeFolder,$fileName,$this->banner_large_image_width,$this->banner_large_image_height);
Catabatic_Helper::resizeImages($orignalFolderName,$originalMediumFolder,$fileName,$this->banner_medium_image_width,$this->banner_medium_image_height);
Catabatic_Helper::resizeImages($orignalFolderName,$originalSmallFolder,$fileName,$this->banner_small_image_width,$this->banner_small_image_height);
$savePageData = [
'title'=>($getData['title']),
'description'=>($getData['description']),
'status'=>"{$getData['status_number']}"
];
if ($fileName != "") {
$savePageData['image'] = $fileName;
}
// echo "<pre>";print_r($savePageData);die;
$crud->rv_insert('tbl_trustedmember', $savePageData);
$this->view->successMessage = "Page content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Page content has been added successfully.");
$this->_redirect("/admin/member/index");
}
}
}
}
$this->view->form = $form;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$this->view->resultsetPackage = $resultsetPackage;
}
public function deletememberAction(){
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int)$this->getRequest()->getParam("id");
// echo"<pre>";print_r($tId);die();
if($tId){
$checkdata = $crud->rv_select_row('tbl_trustedmember', ['id'], ['id'=>$tId], ['id'=>'asc']);
if(count($checkdata)>0){
$crud->rv_delete('tbl_trustedmember', ['id =?'=>$tId]);
$this->_helper->flashMessenger->addMessage("Delete successfully.");
$this->_redirect("/admin/member/index");
}else{
die('Oops some thing wrong!!.');
}
}
}
/**
* 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');
}
}
}
?>