public function deleteAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $id = $this->getParam('id'); $rpta = array(); if (!empty($id)) { try { $aclRole = new Admin_Model_Users(); $da = $aclRole->getUserRoles($id); if (count($da) == 0) { $aclRole = new Admin_Model_AclRole(); $aclRole->deletRole($id); $obj = new Application_Entity_RunSql('Role'); $obj->erase = $id; $rpta['msj'] = 'ok'; } else { // $msg = "El rol esta siendo utilizado por usuarios activos"; // $this->_flashMessenger->success($msg); // $this->_redirect('/admin/role'); $rpta['msj'] = 'El rol esta siendo utilizado por usuarios activos'; } } catch (Exception $e) { $rpta['msj'] = $e->getMessage(); } } else { $rpta['msj'] = 'faltan datos'; } $this->getResponse()->setHttpResponseCode(200)->setHeader('Content-type', 'application/json; charset=UTF-8', true)->appendBody(json_encode($rpta)); }
/** * revalidates the user */ public static function revalidate() { $user = vkNgine_Auth::getIdentity(); // revalidate the user $modelAdminUsers = new Admin_Model_Users(); $dbUser = $modelAdminUsers->fetchWithEmail($user['email']); return $dbUser; }
public function listAction() { $userModel = new Admin_Model_Users(); $userArray = $userModel->getUserArray(); // add roles to each user $userArray = $userModel->addRolesToUserArray($userArray); if (count($userArray) > 0) { $paginator = Zend_Paginator::factory($userArray); $page = $this->_request->getParam('page', 1); $paginator->setItemCountPerPage(5); $paginator->setCurrentPageNumber($page); $this->view->paginator = $paginator; } }
public static function getInstance() { if (!is_object(self::$_instance)) { self::$_instance = new Admin_Model_Users(); } return self::$_instance; }
public function init() { $adminModel = Admin_Model_Users::getInstance(); $result = $adminModel->getAdminDetails(); // showing image if ($result) { $this->view->admindetails = $result; } }
private function userDetails() { $modelUsers = new Admin_Model_Users(); $userInfo = array(); foreach ($modelUsers->fetchAll() as $user) { $_userInfo = $modelUsers->fetch($user['userId']); $userInfo[$user['userId']] = '#' . $_userInfo->getId() . ' [' . $_userInfo->getEmail() . ']'; } return $userInfo; }
public function myaccountAction() { $form = self::getMyAccountForm(); $request = $this->getRequest(); if ($request->isPost()) { $post = $request->getPost(); if ($form->isValid($post)) { $values = $form->getValues(); if ($this->user->type == 'ADMIN') { $modelAdminUsers = new Admin_Model_Users(); $modelAdminUsers->update($this->user->userId, array('password' => $values['password'])); } echo Zend_Json::encode(array('success' => 1, 'dialog' => 'btn-myaccount-dialog', 'title' => $this->t->_('Success Message'), 'message' => $this->t->_('Password was changed successfully'), 'icon' => 'success')); exit; } else { echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Please fill out all required fields'), 'icon' => 'error')); exit; } } $this->view->form = $form; $this->_helper->layout->disableLayout(); }
/** * authenticate() - defined by Zend_Auth_Adapter_Interface. This method is called to * attempt an authentication. Previous to this call, this adapter would have already * been configured with all necessary information to successfully connect to a database * table and attempt to find a record matching the provided identity. * * @throws Zend_Auth_Adapter_Exception if answering the authentication query is impossible * @return Zend_Auth_Result */ public function authenticate() { $modelUsers = new Admin_Model_Users(); $user = $modelUsers->fetchWithEmail($this->_email); if (!$user instanceof Model_User) { $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID; $this->_authenticateResultInfo['messages'][] = 'User not found'; } elseif ($user->active != 'Y') { $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID; $this->_authenticateResultInfo['messages'][] = 'User is not active'; } elseif ($user->password != md5($this->_password)) { if ($this->_noCredentialTreatment && $user->password == $this->_password) { $this->_authenticateResultInfo['code'] = Zend_Auth_Result::SUCCESS; $this->_authenticateResultInfo['messages'][] = 'Authentication successful.'; } else { $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID; $this->_authenticateResultInfo['messages'][] = 'Password is invaild'; } } else { $this->_authenticateResultInfo['code'] = Zend_Auth_Result::SUCCESS; $this->_authenticateResultInfo['messages'][] = 'Authentication successful.'; } return $this->_authenticateCreateAuthResult(); }
public function storeReviewsAction() { $adminModel = Admin_Model_Users::getInstance(); $result = $adminModel->getAdminDetails(); // showing image if ($result) { $this->view->admindetails = $result; } $ReviewsModel = Admin_Model_Reviews::getInstance(); $result = $ReviewsModel->getAllStoreReviews(); if ($result) { $this->view->storeReviews = $result; } else { echo 'controller error occured'; } }
public function updatePassAction() { if (!Zend_Auth::getInstance()->hasIdentity()) { $this->_redirect('/'); } $this->_helper->viewRenderer->setNoRender(true); $this->_helper->layout->setLayout('layout-admin'); $form = new Admin_Form_ChangePassword(); $mUser = new Admin_Model_Users(); if ($this->_request->isPost()) { $params = $this->getAllParams(); if ($form->isValid($params)) { $clapass = md5($params['password']); if ($clapass == $this->_identity->password) { if ($params['confirmone'] == $params['confirmtwo']) { $pass = md5($params['confirmone']); $mUser->updateUsersPass($pass, $this->_identity->iduser); $this->_flashMessenger->success("Constraseña Cambiada Correctamente."); $this->_redirect('/admin/index/update-pass'); } else { $msg = "Las Nuevas Contraseñas no Coinciden."; $this->_flashMessenger->warning($msg, 'TEMP'); } } else { $msg = "Contraseña Actual Incorrecta."; $this->_flashMessenger->warning($msg, 'TEMP'); } } else { $errorMsgs = Core_FormErrorMessage::getErrors($form); $this->_flashMessenger->error($errorMsgs); } } $this->view->titulo = "Editar Mi Contraseña"; $form->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/_formPass.phtml')))); echo $form; }
public function adminProductTransactionsAction() { $adminModel = Admin_Model_Users::getInstance(); $result = $adminModel->getAdminDetails(); // showing image if ($result) { $this->view->admindetails = $result; } $ProducttransactionModel = Admin_Model_ProductTransactions::getInstance(); $result = $ProducttransactionModel->getAllProducttransaction(); if ($result) { $successfullArr = $pendingArr = $failedArr = $cancelArr = array(); foreach ($result as $key => $value) { if ($value['tx_status'] == 1) { $successfullArr[] = $value; } else { if ($value['tx_status'] == 2) { $pendingArr[] = $value; } else { if ($value['tx_status'] == 3) { $failedArr[] = $value; } else { if ($value['tx_status'] == 4) { $cancelArr[] = $value; } } } } } $this->view->successfullStatus = $successfullArr; $this->view->pendingStatus = $pendingArr; $this->view->failedStatus = $failedArr; $this->view->cancelStatus = $cancelArr; } else { echo 'controller error occured'; } }
public function viewUserDetailsAction() { $adminModel = Admin_Model_Users::getInstance(); $result = $adminModel->getAdminDetails(); // showing image if ($result) { $this->view->admindetails = $result; } $userModel = Admin_Model_Users::getInstance(); $userId = $this->getRequest()->getParam("userId"); $result = $userModel->getAllUserdetails($userId); if ($result) { $this->view->alluserdetails = $result; } else { echo 'controller error occured'; } }
public function dashboardAction() { $adminModel = Admin_Model_Users::getInstance(); $result = $adminModel->getAdminDetails(); // showing image if ($result) { $this->view->admindetails = $result; } $userModel = Admin_Model_Users::getInstance(); $result = $userModel->getUserdetails(); if ($result) { $this->view->userdetails = count($result); } $usertransactionModel = Admin_Model_UserTransactions::getInstance(); $result1 = $usertransactionModel->getAllUsertransaction(); if ($result1) { $this->view->usertransaction = count($result1); } $ordersModel = Admin_Model_Orders::getInstance(); $result2 = $ordersModel->getAllHotelOrder(); if ($result2) { $this->view->orderdetails = count($result2); } $ordersModel1 = Admin_Model_Orders::getInstance(); $result21 = $ordersModel->getAllStoreOrder(); if ($result21) { $this->view->storeorderdetails = count($result21); } $productsModel = Admin_Model_Products::getInstance(); $result3 = $productsModel->getProductsdetails(); if ($result3) { $this->view->productsdetails = count($result3); } $productsModel1 = Admin_Model_Products::getInstance(); $result31 = $productsModel1->getAllStoreProductdetails(); if ($result31) { $this->view->productsdetails = count($result31); } $agentsModel = Admin_Model_Agents::getInstance(); $result4 = $agentsModel->getAgentsDetails(); if ($result4) { $this->view->agentsdetails = count($result4); } $storeDetailsModel = Admin_Model_StoreDetails::getInstance(); $result5 = $storeDetailsModel->getAllStore(); if ($result5) { $this->view->storedetails = count($result5); } $hotelDetailsModel = Admin_Model_HotelDetails::getInstance(); $result6 = $hotelDetailsModel->getAllHotels(); if ($result6) { $this->view->hoteldetails = count($result6); } $agenttransactionModel = Admin_Model_AgentTransactions::getInstance(); $result7 = $agenttransactionModel->getAllAgenttransaction(); if ($result7) { $this->view->agenttransaction = count($result7); } $producttransactionModel = Admin_Model_ProductTransactions::getInstance(); $result8 = $producttransactionModel->getAllProducttransaction(); if ($result8) { $this->view->producttransaction = count($result8); } $storeCategoryDetailsModel = Admin_Model_StoreCategory::getInstance(); $result9 = $storeCategoryDetailsModel->selectAllCategorys(); if ($result9) { $this->view->storecategorydetails = count($result9); } $DeliveryGuysModel = Admin_Model_DeliveryGuys::getInstance(); $result10 = $DeliveryGuysModel->getAllDeliveryGuys(); if ($result10) { $this->view->DeliveryGuys = count($result10); } $NotificationModel = Admin_Model_Notification::getInstance(); $result11 = $NotificationModel->getNotificationDetail(); if ($result11) { $this->view->Notification = count($result11); } $ReviewsModel = Admin_Model_Reviews::getInstance(); $result12 = $ReviewsModel->getAllHotelReviews(); if ($result12) { $this->view->HotelReviews = count($result12); } $ReviewModel = Admin_Model_Reviews::getInstance(); $result13 = $ReviewModel->getAllStoreReviews(); if ($result13) { $this->view->StoreReviews = count($result13); } $locationsModel1 = Admin_Model_Location::getInstance(); $result14 = $locationsModel1->getCountrys(); if ($result14) { $this->view->CountryDetails = count($result14); } $locationsModel2 = Admin_Model_Location::getInstance(); $result15 = $locationsModel2->getStates(); if ($result15) { $this->view->StateDetails = count($result15); } $locationsModel3 = Admin_Model_Location::getInstance(); $result16 = $locationsModel3->getCitys(); if ($result16) { $this->view->CityDetails = count($result16); } $locationsModel4 = Admin_Model_Location::getInstance(); $result17 = $locationsModel4->getLocations(); if ($result17) { $this->view->LocationDetails = count($result17); } $cuisinesModel = Admin_Model_FamousCuisines::getInstance(); $result18 = $cuisinesModel->getCuisines(); if ($result18) { $this->view->CuisineDetails = count($result18); } $categoryModel = Admin_Model_MenuCategory::getInstance(); $result19 = $categoryModel->selectAllCategorys(); if ($result19) { $this->view->CategoryDetails = count($result19); } $objModelCoupons = Admin_Model_Coupons::getInstance(); $allCoupons = $objModelCoupons->getCoupons(); if ($allCoupons) { $this->view->allcoupons = count($allCoupons); } $objModelCouponUsers = Admin_Model_CouponUsers::getInstance(); $couponsLog = $objModelCouponUsers->getCouponsLog(); if ($couponsLog) { $this->view->couponsLog = count($couponsLog); } }
public function viewStoreDetailsAction() { $adminModel = Admin_Model_Users::getInstance(); $result = $adminModel->getAdminDetails(); // showing image if ($result) { $this->view->admindetails = $result; } $storeDetailsModel = Admin_Model_StoreDetails::getInstance(); $storecategoryModel = Admin_Model_StoreCategory::getInstance(); $store_id = $this->getRequest()->getParam('storeId'); $dt['store_id'] = $store_id; $result = $storeDetailsModel->getStoreDetailsByID($store_id); $categoryID = json_decode($result['category_id'], true); $i = 0; foreach ($categoryID as $categoryname) { $categoryname = $storecategoryModel->getCategoryById($categoryname); $categorynames[$i] = $categoryname['cat_name']; $i++; } if ($result) { $this->view->allstoredetails = $result; $this->view->allStoreCategorynames = $categorynames; } else { echo 'controller error occured'; } }
public function loginAction() { if (vkNgine_Auth::isAuthenticated()) { $this->_redirect('/admin'); exit; } $view = Zend_Registry::get('view'); $view->headTitle('Administrator Login'); $loginForm = $this->getAdminLoginForm(); $recoverForm = $this->getAdminRecoverForm(); $request = $this->getRequest(); if ($request->isPost()) { $email = $this->_getParam('email'); $password = $this->_getParam('password'); $remember = $this->_getParam('remember'); $hash = new Zend_Session_Namespace('CsrfError'); if ($hash->message) { echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_($hash->message), 'icon' => 'error')); exit; } else { if ($loginForm->isValid($request->getPost())) { if (!empty($email) && !empty($password)) { $info = array('email' => $email, 'password' => $password, 'remember' => $remember); if (vkNgine_Admin_Auth::attemptLogin($info)) { $this->user = vkNgine_Admin_Auth::revalidate(); if (isset($info['remember']) and $info['remember']) { $config = vkNgine_Config::getSystemConfig(); if (isset($config->settings->login->remember)) { $rememberMeHowLong = $config->settings->login->remember; } else { $rememberMeHowLong = 60 * 60 * 24 * 14; // 14 days } Zend_Session::rememberMe($rememberMeHowLong); } else { Zend_Session::forgetMe(); } $logger = Zend_Registry::get('logger'); $logger->log('ADMIN_LOGIN_REQUEST', print_r($info, true), vkNgine_Log::INFO, $this->user['userId']); $modelTrafficLogins = new vkNgine_Log_Logins(); $modelTrafficLogins->insertTrafficLogin($this->user['userId'], 'ADMIN'); $modelTrafficActivity = new vkNgine_Log_Activity(); $modelTrafficActivity->processActivity($this->user, $request, 'Logged in to Admin Panel'); $modelUsers = new Admin_Model_Users(); $modelUsers->update($this->user['userId'], array('lastLogin' => date('Y-m-d H:i:s'))); echo Zend_Json::encode(array('success' => 1, 'title' => $this->t->_('Success Message'), 'message' => $this->t->_('Logged in Successfully'), 'icon' => 'success', 'href' => '/admin')); exit; } else { echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Invalid Login or Password!'), 'icon' => 'error')); exit; } } else { echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Username or Password is Invalid!'), 'icon' => 'error')); exit; } } else { echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Username or Password is Invalid!'), 'icon' => 'error')); exit; } } } $this->view->loginForm = $loginForm; $this->view->recoverForm = $recoverForm; }
/** * Create checkboxes for updating user * @param int $userID * @return array */ private function _createCheckboxesForUpdatingUser($userID) { $roleCheckboxes = array(); // get role array $roleModel = new Admin_Model_Role(); $roleArray = $roleModel->getRoleArray(); // get customer role ID $customerRoleID = $roleModel->getCustomerRoleID(); // get roles of the user $userModel = new Admin_Model_Users(); $rolesOfUser = $userModel->getRolesOfUser($userID); // extract role_id of $roleOfUser array $roleIDs = array(); foreach ($rolesOfUser as $role) { $roleIDs[] = $role['role_id']; } // create role checkboxes foreach ($roleArray as $index => $role) { if (in_array($role['role_id'], $roleIDs)) { $roleCheckbox = $this->createElement('checkbox', (string) $role['role_id'], array('checked' => 'checked')); } else { $roleCheckbox = $this->createElement('checkbox', (string) $role['role_id'], array()); } // check if the role is customer if ($role['role_id'] == $customerRoleID) { $roleCheckbox->setAttrib('disabled', 'disabled'); } $roleCheckbox->setLabel($role['role_name']); $this->_customizeRoleCheckBox($roleCheckbox); $roleCheckboxes[] = $roleCheckbox; } return $roleCheckboxes; }
public function couponsLogAction() { $adminproducts = Admin_Model_Products::getInstance(); $adminModel = Admin_Model_Users::getInstance(); $result = $adminModel->getAdminDetails(); // showing image if ($result) { $this->view->admindetails = $result; } $objModelCouponUsers = Admin_Model_CouponUsers::getInstance(); $couponsLog = $objModelCouponUsers->getCouponsLog(); $j = 0; // ---------code to convert json encoded product_id's to product names----------- foreach ($couponsLog as $value) { $value1 = json_decode($value['product_id'], true); for ($i = 0; $i < count($value1); $i++) { $productname = $value1[$i]; $productname = $adminproducts->getProductsById($productname); $productnames[$i] = $productname['name']; } $couponsLog[$j]['product_id'] = $productnames; $j++; } // ------------------------------------------------------------------------------------- // $couponsLog = array_map(function($coupon) { // $coupon['product_id'] = explode(',', str_replace('"', '', rtrim(ltrim($coupon['product_id'], '['), ']'))); // return $coupon; // }, $couponsLog); $this->view->couponsLog = $couponsLog; }
public function storeCategoryDetailsAction() { $adminModel = Admin_Model_Users::getInstance(); $result = $adminModel->getAdminDetails(); // showing image if ($result) { $this->view->admindetails = $result; } $categoryModel = Admin_Model_StoreCategory::getInstance(); $category = $categoryModel->selectAllCategorys(); if ($category) { $this->view->categorydetails = $category; } if ($this->getRequest()->isPost()) { $data['cat_name'] = $this->getRequest()->getPost('categoryname'); $data['cat_desc'] = $this->getRequest()->getPost('cat_desc'); $data['cat_status'] = $this->getRequest()->getPost('cat_status'); $result = $categoryModel->addCategory($data); if ($result) { $this->redirect('/admin/store-category-details'); } } }
public function deleteAction() { $modelUsers = new Model_Users(); $modelAdminUsers = new Admin_Model_Users(); $userId = $this->_getParam('userId'); if (vkNgine_Config::getSystemConfig()->master->user == $userId) { return new vkNgine_Exception('This user can\'t be deleted'); } $userInfo = $modelUsers->fetch($userId); $modelUsers->delete($userId); $modelAdminUsers->delete($userId); echo Zend_Json::encode(array('success' => 1, 'itemId' => $userId, 'rowId' => 'user-', 'title' => $this->t->_('Success Message'), 'message' => sprintf($this->t->_('%s was successfully deleted'), $userInfo->getFullName()), 'icon' => 'success')); exit; }
public function viewStoreProductDetailsAction() { $adminModel = Admin_Model_Users::getInstance(); $result = $adminModel->getAdminDetails(); // showing image if ($result) { $this->view->admindetails = $result; } $productsModel = Admin_Model_Products::getInstance(); $productId = $this->getRequest()->getParam("productId"); $result = $productsModel->getAllStoreProductdetails($productId); if ($result) { $this->view->allproductdetails = $result; } else { echo 'controller error occured'; } }
public function editStoreDeliveryguyDetailsAction() { $adminModel = Admin_Model_Users::getInstance(); $result = $adminModel->getAdminDetails(); // showing image if ($result) { $this->view->admindetails = $result; } $locationsModel = Admin_Model_Location::getInstance(); $locations = $locationsModel->getLocations(); if ($locations) { $this->view->locationdetails = $locations; } $deliveryGuysModel = Admin_Model_DeliveryGuys::getInstance(); $delguyid = $this->getRequest()->getParam('delguyid'); if ($this->_request->isPost()) { $delguyid = $delguyid; $deliverydata['login_name'] = $this->getRequest()->getPost('login_name'); $deliverydata['firstname'] = $this->getRequest()->getPost('firstname'); $deliverydata['lastname'] = $this->getRequest()->getPost('lastname'); $deliverydata['email'] = $this->getRequest()->getPost('email'); $deliverydata['password'] = md5($this->getRequest()->getPost('password')); $deliverydata['phone'] = $this->getRequest()->getPost('phone'); $deliverydata['city'] = $this->getRequest()->getPost('city'); $deliverydata['state'] = $this->getRequest()->getPost('state'); $deliverydata['hotel_store'] = 2; $deliverydata['country'] = $this->getRequest()->getPost('country'); $deliverydata['address'] = $this->getRequest()->getPost('address'); $deliverydata['status'] = $this->getRequest()->getPost('status'); $deliverydata['location'] = $this->getRequest()->getPost('location'); $deliverydata['store_id'] = json_encode($this->getRequest()->getPost('store_id')); if ($delguyid) { $result = $deliveryGuysModel->updateDeliveryGuydetails($delguyid, $deliverydata); if ($result) { $this->redirect('/admin/store-delivery-guys-details'); } } } if ($delguyid) { $deliveryguydetails = $deliveryGuysModel->getDeliveryGuyById($delguyid); if ($deliveryguydetails) { $this->view->deliveryguydetails = $deliveryguydetails; } } }
public function viewHotelDetailsAction() { $adminModel = Admin_Model_Users::getInstance(); $result = $adminModel->getAdminDetails(); // showing image if ($result) { $this->view->admindetails = $result; } $hotelDetailsModel = Admin_Model_HotelDetails::getInstance(); $hotelCuisinesModel = Admin_Model_HotelCuisines::getInstance(); $hotel_id = $this->getRequest()->getParam('id'); $dt['hotel_id'] = $hotel_id; $cuisinesdDetails = $hotelCuisinesModel->getCuisinesByHotelId($hotel_id); $i = 0; if ($cuisinesdDetails) { foreach ($cuisinesdDetails as $value) { $array[$i] = $value['Cuisine_name']; } $i++; $this->view->cuisinesdDetails = $cuisinesdDetails; } $result = $hotelDetailsModel->getHotelDetailsByID($hotel_id); if ($result) { $this->view->allhoteldetails = $result; } else { echo 'controller error occured'; } }
public function viewStoreOrderDetailsAction() { $adminproducts = Admin_Model_Products::getInstance(); $adminModel = Admin_Model_Users::getInstance(); $result = $adminModel->getAdminDetails(); // showing image if ($result) { $this->view->admindetails = $result; } $order_id = $this->getRequest()->getParam('oId'); $ordersModel = Admin_Model_Orders::getInstance(); $result = $ordersModel->getAllStoreOrdersById($order_id); $productID = json_decode($result['product_id'], true); $quantity = json_decode($result['quantity'], true); $amount = json_decode($result['product_amount'], true); $i = 0; foreach ($productID as $productname) { $productname = $adminproducts->getProductsById($productname); $productnames[$i] = $productname['name']; $i++; } if ($result) { $this->view->orderdetails = $result; $this->view->productnames = $productnames; $this->view->quantity = $quantity; $this->view->amount = $amount; } }
public function viewAgentDetailsAction() { $adminModel = Admin_Model_Users::getInstance(); $result = $adminModel->getAdminDetails(); // showing image if ($result) { $this->view->admindetails = $result; } $agentsModel = Admin_Model_Agents::getInstance(); $agentid = $this->getRequest()->getParam('agentid'); $agentdetails = $agentsModel->getAgentsDetailsByAgentID($agentid); if ($agentdetails) { $this->view->agentdetails = $agentdetails; } }