public function filter() { $string = '%' . $this->input->post('string') . '%'; $a = array(); if ($string) { $a = Student::find('all', array('conditions' => array('nombre LIKE ? OR apellido LIKE ?', $string, $string))); } else { $a = Student::find('all'); } $this->table->set_heading('Nombre', 'Apellido', 'Fecha de nacimiento', 'Documento', 'Telefono', 'Celular', 'Acciones'); foreach ($a as $al) { $this->table->add_row($al->nombre, $al->apellido, $al->fecha_nacimiento->format('d/m/Y'), $al->tipo_documento . ' ' . $al->nro_documento, $al->telefono, $al->celular, anchor('alumnos/ver/' . $al->id, img('static/img/icon/doc_lines.png'), 'class="tipwe" title="Ver detalles de alumno"') . ' ' . anchor('alumnos/editar/' . $al->id, img('static/img/icon/pencil.png'), 'class="tipwe" title="Editar alumno"') . ' ' . anchor('alumnos/eliminar/' . $al->id, img('static/img/icon/trash.png'), 'class="tipwe eliminar" title="Eliminar alumno"')); } echo $this->table->generate(); $config['base_url'] = site_url('alumnos/index'); $config['total_rows'] = Student::count(); $config['per_page'] = '10'; $config['num_links'] = '10'; $config['first_link'] = '← primero'; $config['last_link'] = 'último →'; $this->load->library('pagination', $config); echo '<div class="pagination">'; echo $this->pagination->create_links(); echo '</div>'; }
/** * 首页 * */ public function actionIndex() { parent::_acl(); $model = new Student(); $criteria = new CDbCriteria(); $criteria->condition = $condition; $criteria->order = 't.id ASC'; //$criteria->with = array ( 'catalog' ); $count = $model->count($criteria); $pages = new CPagination($count); $pages->pageSize = 13; //$pageParams = XUtils::buildCondition( $_GET, array ( 'title' , 'catalogId','titleAlias' ) ); //$pages->params = is_array( $pageParams ) ? $pageParams : array (); $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $result = $model->findAll($criteria); //审核 //$id = $_POST('id'); //$status = $_POST('status'); //$count = Student::model()->updateByPk($id, ,'status=:status',array(':status'=>$status)); $string = '审核更新失败'; function errorInfo($count, $string) { if ($count) { echo "<b>{$string}</b>"; } else { echo "<b>成功</b>"; } } set_error_handler("errorInfo"); $this->render('student_index', array('datalist' => $result, 'pagebar' => $pages)); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $error = Session::get('error'); $success = Session::get('success'); $tclass = ClassModel::count(); $tsubject = Subject::count(); $tstudent = Student::count(); return View::Make('dashboard', compact('error', 'success', 'tclass', 'tsubject', 'tstudent')); }
public function render() { if (isset($this->config['course_id'])) { $course = new Course(); $course->include_related('period'); $course->get_by_id((int) $this->config['course_id']); $this->parser->assign('course', $course); if ($course->exists()) { $task_sets = new Task_set(); $task_sets->where_related($course); $task_sets->where('published', 1); $task_sets->where('content_type', 'task_set'); $task_sets_count = $task_sets->count(); $this->parser->assign('task_sets_count', $task_sets_count); $task_sets->where_related($course); $task_sets->where('published', 1); $task_sets->where('content_type', 'project'); $projects_count = $task_sets->count(); $this->parser->assign('projects_count', $projects_count); $groups = new Group(); $groups->where_related($course); $groups_count = $groups->count(); $this->parser->assign('groups_count', $groups_count); $students = new Student(); $students->where_related('participant/course', 'id', $course->id); $students->where_related('participant', 'allowed', 1); $students_count = $students->count(); $this->parser->assign('students_count', $students_count); $task_set_permissions = new Task_set_permission(); $task_set_permissions->select_func('COUNT', '*', 'count'); $task_set_permissions->where('enabled', 1); $task_set_permissions->where_related('task_set', 'id', '${parent}.id'); $now = date('Y-m-d H:i:s'); $plus_two_weeks = date('Y-m-d H:i:s', strtotime($now . ' + 2 weeks')); $minus_one_week = date('Y-m-d H:i:s', strtotime($now . ' - 1 week')); $task_sets->select('id, name, upload_end_time AS min_upload_end_time, upload_end_time AS max_upload_end_time'); $task_sets->where_related($course); $task_sets->where('published', 1); $task_sets->where_subquery('0', $task_set_permissions); $task_sets->where('upload_end_time >=', $minus_one_week); $task_sets->where('upload_end_time <=', $plus_two_weeks); $task_sets_2 = new Task_set(); $task_sets_2->select('id, name'); $task_sets_2->where_related($course); $task_sets_2->where('published', 1); $task_sets_2->select_min('task_set_permissions.upload_end_time', 'min_upload_end_time'); $task_sets_2->select_max('task_set_permissions.upload_end_time', 'max_upload_end_time'); $task_sets_2->where_related('task_set_permission', 'enabled', 1); $task_sets_2->having('(MAX(`task_set_permissions`.`upload_end_time`) >= ' . $this->db->escape($minus_one_week) . ' AND MAX(`task_set_permissions`.`upload_end_time`) <= ' . $this->db->escape($plus_two_weeks) . ')'); $task_sets_2->or_having('(MIN(`task_set_permissions`.`upload_end_time`) >= ' . $this->db->escape($minus_one_week) . ' AND MIN(`task_set_permissions`.`upload_end_time`) <= ' . $this->db->escape($plus_two_weeks) . ')'); $task_sets_2->group_by('id'); $task_sets->union_iterated($task_sets_2, FALSE, 'min_upload_end_time DESC, max_upload_end_time DESC', isset($this->config['number_of_task_sets']) ? (int) $this->config['number_of_task_sets'] : 5); $this->parser->assign('task_sets', $task_sets); } } $this->parser->parse('widgets/admin/course_overview/main.tpl'); }
public function surveylistAction() { $manager = $this->session->get("Manager"); $tests = Test::find(array("school_id = :school_id:", "bind" => array("school_id" => $manager["school_id"]), "sort" => "id desc")); $now = date("Y-m-d H:i:s"); $list = array(); foreach ($tests as $index => $test) { /* * status * 0: 测试未开始 * 1: 测试正在进行中 * 2: 测试已经过期 */ $import = Student::count(array("test_id= :test_id:", "bind" => array("test_id" => $test->t_id))); $status = 0; if ($now >= $test->begin_time && $now <= $test->end_time) { $status = 1; } else { if ($now > $test->end_time) { $status = 2; } } $item = array("test_id" => $test->t_id, "people" => $test->people, "begin" => substr($test->begin_time, 0, strlen($test->begin_time) - 3), "end" => substr($test->end_time, 0, strlen($test->end_time) - 3), "description" => $test->description, "status" => $status, "import" => $import); $list[$index] = $item; } $this->view->setVar("tests", $list); // 设置url $url = $this->makeurl(); $this->view->setVar("url", $url); $this->view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_ACTION_VIEW); }
public function _email_available($str, $student_id) { $student = new Student(); $student->where('email', $str)->where('id !=', $student_id); $count = $student->count(); return $count == 0; }