| 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/controllers/ |
Upload File : |
<?php
/**
* Copyright 2013 Catabatic Automation Technology Pvt Ltd.
* All rights reserved
*
* @description : BaseController.php 2016/07/11 15:10
* @author : Shakti Rana <shakti@catpl.co.in>
*/
class BaseController extends Zend_Controller_Action
{
protected $model;
protected $modelName;
protected $tableName;
/**
* Initialise.
*
* @param string $modelName
* @param string $tableName
*/
public function init()
{
$this->model = @$this->modelName ? new $this->modelName() : null;
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$this->siteUrl = $aConfig['bootstrap']['siteUrl'];
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
if(empty($sessionLogin_user->intLoggedinUserAgencySysId)) {
$this->_helper->redirector('index', 'login');
}
}
/**
* IndexAction. To render list view.
*
* @param string $condition
*/
public function indexAction($condition=null)
{
$this->view->customerList = $this->model->getAllRecords($this->tableName, $condition);
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
/**
* InsertAction. To insert textvalues into db.
*
* @param string $columnName
* @param int|string $columnValue
* @param array $data
* @param string $url
* @param string $messageKey
* @return int
*/
public function insertAction($columnName, $columnValue, $data, $url=null, $messageKey='Record')
{
$isRecordExist = $this->model->getRecord($columnName, $columnValue, $this->tableName, true);
if (!@$isRecordExist)
{
// $date = new Zend_Date();
$currentDate = date('Y-m-d H:i:s');
$isRecordAdded = $this->model->insertRecord($data, $this->tableName);
$message = @$isRecordAdded ? "$messageKey added successfully." : "$messageKey addtion failed.";
$this->_helper->flashMessenger->addMessage($message);
if(@$isRecordAdded && 1!=1)
{
$this->_redirect($url);
}
else
{
return @$isRecordAdded ? $isRecordAdded : 0;
}
}
else
{
$this->view->message = "$messageKey already exists.";
}
}
/**
* Update Action. To update textvalues into db.
*
* @param string $whereCondition
* @param array $data
* @param string $url
* @param string $messageKey
*/
public function updateAction($whereCondition, $data, $url=null, $messageKey='Record')
{
$isRecordUpdated = $this->model->updateRecord($data, $whereCondition, $this->tableName);
$message = @$isRecordAdded ? "$messageKey updated successfully." : "$messageKey updation failed.";
$this->_helper->flashMessenger->addMessage($message);
//if(@$isRecordUpdated)
{
$this->_redirect($url);
}
}
/**
* Delete Action.
*
* @param string $whereCondition
* @param string $url
* @param string $messageKey
*/
public function deleteAction($whereCondition, $url=null, $messageKey='Record')
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$isRecordDeleted = $this->model->deleteRecord($whereCondition, $this->tableName);
$message = @$isRecordDeleted ? "$messageKey deleted successfully." : "$messageKey deletion failed.";
$this->_helper->flashMessenger->addMessage($message);
if(@$isRecordDeleted)
{
$this->_redirect($url);
}
}
public function uploadFile($files, $folderPath)
{
$folderPath = USER_FILE_UPLOAD_PATH.$folderPath;
$fileNameArray = array();
foreach($files as $attributeName => $file)
{
$fileName = $file['name'];
$tmpFilePath = $file['tmp_name'];
$newFileName = basename($fileName, '.'.pathinfo($fileName, PATHINFO_EXTENSION)).'_'. time();
$fileNameArray[$attributeName] = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->fileUpload($fileName, $newFileName, $tmpFilePath, $folderPath);
}
return $fileNameArray;
}
}