/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return StudentService the loaded model * @throws CHttpException */ public function loadModel($id) { $model = StudentService::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
$collection->attachRoute(new Route('/calendarAction', array('_controller' => 'PaymentController::listPaymentsOnCalendarAction', 'methods' => 'POST'))); $router = new Router($collection); $router->setBasePath('/'); $route = $router->matchCurrentRequest(); // Vamos a usar el PHPRouter para todas las rutas relacionadas a la pagina de la escuela, // y Slim para todas las rutas de la api REST. // Asique si al llegar una ruta vemos que no pertenece al mapeo de PHPRouter, usamos slim. if ($route) { AuthController::checkPermission($route->getAction()); $route->dispatch(); } else { $slimApp = new \Slim\Slim(); // Retorna un arreglo asociativo con las claves "por_pagar" y "pagas". // Cada arreglo dentro de esas 2 cosas contiene los datos de un alumno // http://localhost/cuotasImpagasYPorPagarDe/21/year/2016 << este tiene datos cargados para ver $slimApp->get('/cuotasImpagasYPorPagarDe/:studentID/year/:year', function ($studentID, $year) { FeeService::listPaidAndToBePaidFeesOfStudentInYear($studentID, $year); }); // Devuelve un arreglo de 12 posiciones, cada posicion representa un mes, y contiene la cantidad de ingresos // en ese mes. $slimApp->get('/ingresosTotalesEn/:year', function ($year) { RevenueService::totalRevenueByMonthInYear($year); }); $slimApp->get('/getUsersPosition', function () { //$positions = [[-57.9749, -34.9205], [-57.9799, -34.9305]]; //echo json_encode($positions); StudentService::getStudentsPositions(); }); // Si slim detecta q la ruta no existe, se va a encargar de retornar el codigo de error y lo q necesite. $slimApp->run(); }
public function actionSearch() { $keyword = trim($_GET['q']); if (isset($keyword)) { $condition = new CDbCriteria(); $condition->condition = "name_th LIKE '%{$keyword}%' OR name_en LIKE '%{$keyword}%' OR desc_th LIKE '%{$keyword}%' OR desc_en LIKE '%{$keyword}%'"; $condition->order = "create_date desc"; $condition->offset = 0; $condition->limit = 20; $model_news = News::model()->findAll($condition); $condition = new CDbCriteria(); $condition->condition = "name_th LIKE '%{$keyword}%' OR name_en LIKE '%{$keyword}%'"; $condition->order = "last_update desc"; $condition->offset = 0; $condition->limit = 20; $model_document = Document::model()->findAll($condition); $condition = new CDbCriteria(); $condition->condition = "name_th LIKE '%{$keyword}%' OR name_en LIKE '%{$keyword}%'"; $condition->order = "know_id desc"; $condition->offset = 0; $condition->limit = 20; $model_knowledge = Knowledge::model()->findAll($condition); $condition = new CDbCriteria(); $condition->condition = "name_th LIKE '%{$keyword}%' OR name_en LIKE '%{$keyword}%' OR desc_th LIKE '%{$keyword}%' OR desc_en LIKE '%{$keyword}%'"; $condition->order = "last_update desc"; $condition->offset = 0; $condition->limit = 20; $model_student = StudentService::model()->findAll($condition); //print_r($model); $this->render('search', array('model_news' => $model_news, 'model_document' => $model_document, 'model_knowledge' => $model_knowledge, 'model_student' => $model_student)); } }
<?php /** * Created by PhpStorm. * User: хоП * Date: 2015/11/29 * Time: 10:28 */ session_start(); require_once 'studentService.class.php'; $sno = $_POST['login']; $pwd = $_POST['password']; $checkcode = $_POST['checkCode']; if ($checkcode != $_SESSION['checkcode']) { header("location:index.php?error=2"); exit; } $studentService = new StudentService(); $res = $studentService->checkStudent($sno, $pwd); if (!$res) { header("location:index.php?error=1"); exit; } else { session_start(); $_SESSION['name'] = $res[0]; $_SESSION['sno'] = $res[1]; header("location:index.php"); exit; }
public function actionGroup3() { $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->condition = 'status = 1 AND ser_group=3'; $criteria->order = 'sort_order'; $total = StudentService::model()->count($criteria); $pages = new CPagination($total); $pages->setPageSize(20); $pages->applyLimit($criteria); $model = StudentService::model()->findAll($criteria); $this->render('index', array('model' => $model, 'pages' => $pages)); }