IndexController.php 2.19 KB
Newer Older
Indra Raja's avatar
Indra Raja committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
<?php
/**
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Application\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Khansia\Generic\Result;

class IndexController extends \Application\Master\GlobalActionController 
{
    public function __construct($headScript)
    {
        $this->headScript = $headScript;
    }

    public function indexAction()
    {
        $view   = new ViewModel();
        $result = new Result();
        /* ini hanya contoh return dari factory IndexControllerFactory gan, dani tamvan */
        $userSession = $this->getSession();
        $owner       = $userSession->owner();

        if($owner){

            /* session data */
            $sessionArray = array(
                'baseurl'       => $userSession->get('baseurl'),
                'user_id'       => $userSession->get('user_id'),
                'usernamed'     => $userSession->get('usernamed'),
                'passwd'        => $userSession->get('passwd'),
                'name'          => $userSession->get('name'),
                'role'          => $userSession->get('role'),
                'status'        => $userSession->get('status'),
                'deviceid'      => $userSession->get('deviceid'),
                'token'         => $userSession->get('token'),
                'retries'       => $userSession->get('retries'),
                'create_dtm'    => $userSession->get('create_dtm'),
                'access'        => $userSession->get('access'),
                'role_code'     => $userSession->get('role_code'),
            );

            //print_r($result);die;
            $view->setVariable('dataa', $sessionArray);

            $baseurl = 'dani';
            $this->headScript->appendScript(' var baseURL = "' . $baseurl . '"');        
            $this->headScript->appendFile('/action-js/index-js/action-index.js');

            return $view;
        }else{
            return $this->redirect()->toRoute('login');
        }
    }
}