public function loginAction()
 {
     $auth = Zend_Auth::getInstance();
     $this->_layout->setLayout('admin_login');
     $this->view->message = $this->_flashMessenger->getMessages();
     $form = new Admin_Form_LoginForm();
     $form->setMethod('post')->setAction($this->view->rootUrl('/admin/index/login'));
     $this->view->form = $form;
     $flashMessenger = $this->_helper->getHelper('FlashMessenger');
     if ($this->getRequest()->isPost()) {
         $username = $this->_getParam('username');
         $password = md5($this->_getParam('password'));
         if (empty($username) || empty($password)) {
             $flashMessenger->addMessage('Field Cannot Empty');
         } else {
             $db = Zend_Db_Table::getDefaultAdapter();
             $authAdapter = new Zend_Auth_Adapter_DbTable($db, 'admin_account', 'username', 'password');
             $authAdapter->setIdentity($username);
             $authAdapter->setCredential($password);
             $result = $authAdapter->authenticate();
             if ($result->isValid()) {
                 $auth = Zend_Auth::getInstance();
                 $storage = $auth->getStorage();
                 $storage->write($authAdapter->getResultRowObject(array('admin_id', 'username', 'email', 'role_id')));
                 $identity = $auth->getIdentity();
                 //set auth session expired
                 $auth_sess = new Zend_Session_Namespace($auth->getStorage()->getNamespace());
                 $auth_sess->setExpirationSeconds(strtotime('30 day', 0));
                 //store user information on session
                 Zend_Session::namespaceUnset('userInfo');
                 $userInfo = new Zend_Session_Namespace('userInfo');
                 $userInfo->id = $identity->admin_id;
                 $userInfo->name = $identity->username;
                 $userInfo->email = $identity->email;
                 $userInfo->role_id = $identity->role_id;
                 //set user allowed module list
                 $table_adminAccount = new Model_DbTable_AdminAccount();
                 $module_list = $table_adminAccount->getUserInformation($identity->admin_id);
                 $userInfo->module_list = explode(',', $module_list['allowed_module']);
                 $userInfo->canApprove = in_array(47, $userInfo->module_list);
                 //get module list from the database
                 Zend_Session::namespaceUnset('moduleList');
                 $moduleList = new Zend_Session_Namespace('moduleList');
                 $table_module = new Model_DbTable_AdminModule();
                 $module = $table_module->getAllModuleId();
                 $moduleList->module = $module;
                 //redirecting to the dashboard
                 $this->_redirect($this->view->rootUrl('/admin/index'));
             } else {
                 $flashMessenger->addMessage('Login Failed');
             }
         }
     }
 }
 /**
  * IS: Parameter id terdeklarasi
  * FS: Mengirimkan ke viewer: form
  * Desc: Mengatur aksi yang dilakukan untuk halaman edit
  */
 public function editAction()
 {
     $form = new Admin_Form_AccountForm();
     $form->setRoleOption();
     $admin_id = $this->_getParam('id');
     $acc = new Model_DbTable_AdminAccount();
     $data = $acc->getAllQueryById($admin_id);
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = array('username' => $_POST['adminUser'], 'password' => md5($_POST['adminPassword']), 'email' => $_POST['adminEmail'], 'role_id' => $_POST['adminRole']);
             $acc->updateAccount($data, $admin_id);
             $this->loggingaction('account', 'edit', $admin_id);
             $this->_flash->addMessage('1\\Update Success!');
         } else {
             $this->_flash->addMessage('2\\Update Failed!');
         }
         $this->_redirect($this->view->rootUrl('/admin/account/'));
     }
     $form->adminRole->setValue($data['role_id']);
     $form->adminUser->setValue($data['username']);
     $form->adminEmail->setValue($data['email']);
     $this->view->form = $form;
 }
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = array('username' => $_POST['adminUser'], 'password' => md5($_POST['adminPassword']), 'email' => $_POST['adminEmail'], 'role_id' => $_POST['adminRole']);
             $account_id = $table_adminAccount->insertAccount($data);
             $this->loggingaction('account', 'create', $account_id);
             $this->_flashMessenger->setNamespace('success')->addMessage(array("Akun admin berhasil ditambahkan"));
         } else {
             $this->_helper->flashMessenger->setNamespace('error')->addMessage('Gagal menambahkan akun admin');
         }
         $this->_redirector->gotoSimpleAndExit("index");
     }
     $this->view->form = $form;
 }
 /**
  * IS: Parameter id terdeklarasi
  * FS: Mengirimkan ke viewer: form
  * Desc: Mengatur aksi yang dilakukan untuk halaman edit
  */
 public function editAction()
 {
     $form = new Admin_Form_AccountForm();
     $form->setRoleOption();
     $admin_id = $this->_getParam('id');
     $acc = new Model_DbTable_AdminAccount();
         if (empty($type)) {
             $poi_select->setAttrib('onchange', 'getPoiCord($(this).val());');
         }
         $this->view->poi_select = $poi_select;
     } else {
         $this->view->poi_select = 'No Related Destination Found';
     }
 }