public function get_by_id($id) { $student = null; //database connect $this->db->connect(); //query $sql = "SELECT * FROM students WHERE id=?"; //execute $stmt = $this->db->initStatement($sql); $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($id, $first_name, $last_name, $email, $contact_no, $course); while ($stmt->fetch()) { //put in object $student = new Students(); $student->set_id($id); $student->get_id(); $student->set_first_name($first_name); $student->set_last_name($last_name); $student->set_email($email); $student->set_contact_no($contact_no); $student->set_course($course); } $this->db->close(); return $student; }
function __construct() { $url = isset($_GET['url']) ? $_GET['url'] : null; $url = rtrim($url, '/'); $url = explode('/', $url); //print_r($url); if ($url[0] == 'services') { if (isset($url[2])) { require 'services/' . $url[1] . '.php'; $controller = new Students(); $controller->selectById($url[2]); return false; } else { if (isset($url[1])) { require 'services/' . $url[1] . '.php'; $controller = new Students(); $controller->index(); return false; } } } else { if (empty($url[0])) { require 'controllers/index.php'; $controller = new Index(); $controller->index(); return false; } $file = 'controllers/' . $url[0] . '.php'; if (file_exists($file)) { require $file; } else { $this->error(); } $controller = new $url[0](); $controller->loadModel($url[0]); if (isset($url[2])) { if (method_exists($controller, $url[1])) { $controller->{$url[1]}($url[2]); } else { $this->error(); } } else { if (isset($url[1])) { if (method_exists($controller, $url[1])) { $controller->{$url[1]}(); } else { $this->error(); } } else { $controller->index(); } } } }
public static function create() { if (!isset($student_instance)) { self::$student_instance = new Students(); } return self::$student_instance; }
public function exportSelected() { $selected_students = Input::get('studentId'); if (is_array($selected_students)) { //Setup CSV $csv = \League\Csv\Writer::createFromFileObject(new \SplTempFileObject()); $column_flag = false; $student = []; foreach ($selected_students as $student_id) { $student_data = Students::with('course')->find($student_id); //Personal data $student['firstname'] = $student_data['firstname']; $student['surname'] = $student_data['surname']; $student['email'] = $student_data['email']; //Course data $student['university'] = $student_data->course['university']; $student['course_name'] = $student_data->course['course_name']; //Check whether column headers have been set (not ideal for large datasets) if ($column_flag === false) { $csv->insertOne(\Schema::getColumnListing('student')); $column_flag = true; } //Add student record to file $csv->insertOne($student); } } else { return "NO STUDENTS SELECTED"; } //is_array($selected_students) $csv->output("selected_student_records.csv"); }
/** * * Переобъявляем сохранение * **/ public function save() { $student = Students::model()->findByPk(Yii::app()->my->id); $student->settings = json_encode($this->_attributes); $student->save(); $_SESSION["settings"] = $student->settings; }
public function run() { $students = array(array("surname" => "Dare", "firstname" => "Koby", "nationality" => "UK", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Dicki", "firstname" => "Kelli", "nationality" => "UK", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Carter", "firstname" => "Golden", "nationality" => "UK", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Koch", "firstname" => "Emory", "nationality" => "UK", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Kilback", "firstname" => "Marjorie", "nationality" => "Dominican Republic", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Hoeger", "firstname" => "Ernest", "nationality" => "Panama", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Hudson", "firstname" => "Rebecca", "nationality" => "Chile", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Hirthe", "firstname" => "Josefina", "nationality" => "Kyrgyzstan", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Ebert", "firstname" => "Wanda", "nationality" => "Palau", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Denesik", "firstname" => "Burnice", "nationality" => "Kuwait", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Moen", "firstname" => "Harold", "nationality" => "Vatican City", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Spencer", "firstname" => "Brennon", "nationality" => "Cambodia", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Ziemann", "firstname" => "Stanley", "nationality" => "Azerbaijan", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Rempel", "firstname" => "Forest", "nationality" => "Seychelles", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Zboncak", "firstname" => "Gregory", "nationality" => "Kazakhstan", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Weimann", "firstname" => "Valentine", "nationality" => "Turks and Caicos Islands", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Waelchi", "firstname" => "Alexandria", "nationality" => "People's Democratic Republic of Yemen", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Altenwerth", "firstname" => "Florian", "nationality" => "Wake Island", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Zieme", "firstname" => "Faye", "nationality" => "Guatemala", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Beatty", "firstname" => "Raleigh", "nationality" => "British Antarctic Territory", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Kuhic", "firstname" => "Dolly", "nationality" => "Paraguay", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Koepp", "firstname" => "Mikel", "nationality" => "Liberia", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Pfannerstill", "firstname" => "May", "nationality" => "Puerto Rico", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Douglas", "firstname" => "Otho", "nationality" => "Denmark", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Conroy", "firstname" => "Napoleon", "nationality" => "Afghanistan", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Doyle", "firstname" => "Elza", "nationality" => "Liechtenstein", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Schulist", "firstname" => "Maci", "nationality" => "United States", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Hansen", "firstname" => "Kyler", "nationality" => "Canada", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Conn", "firstname" => "Jean", "nationality" => "Kiribati", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Yost", "firstname" => "Reilly", "nationality" => "South Africa", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Quigley", "firstname" => "Shad", "nationality" => "Bhutan", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Quitzon", "firstname" => "Beatrice", "nationality" => "Timor-Leste", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Langworth", "firstname" => "Lonny", "nationality" => "New Zealand", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Kiehn", "firstname" => "Rosalinda", "nationality" => "Dominican Republic", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Parker", "firstname" => "Rebekah", "nationality" => "Kyrgyzstan", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Kuhlman", "firstname" => "Rhoda", "nationality" => "Gibraltar", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Cruickshank", "firstname" => "Judd", "nationality" => "Macau SAR China", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Yundt", "firstname" => "Sarah", "nationality" => "Papua New Guinea", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Pacocha", "firstname" => "Russ", "nationality" => "Greenland", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Purdy", "firstname" => "Kali", "nationality" => "Mauritania", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Block", "firstname" => "Janick", "nationality" => "Belarus", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Waelchi", "firstname" => "Ford", "nationality" => "Paraguay", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Batz", "firstname" => "Francesca", "nationality" => "Netherlands Antilles", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Rogahn", "firstname" => "Lukas", "nationality" => "Cape Verde", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Funk", "firstname" => "Wilhelmine", "nationality" => "Zimbabwe", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Nader", "firstname" => "Jude", "nationality" => "Panama Canal Zone", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Stroman", "firstname" => "Frankie", "nationality" => "Saint Martin", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Jaskolski", "firstname" => "Mina", "nationality" => "Bermuda", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Zieme", "firstname" => "Mack", "nationality" => "Uzbekistan", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Tromp", "firstname" => "Celestine", "nationality" => "Peru", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Nitzsche", "firstname" => "Zella", "nationality" => "New Zealand", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Kuphal", "firstname" => "Ila", "nationality" => "Maldives", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Cruickshank", "firstname" => "Eda", "nationality" => "Jamaica", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Koepp", "firstname" => "Jaylen", "nationality" => "Monaco", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Kohler", "firstname" => "Kristina", "nationality" => "Russia", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Ondricka", "firstname" => "Sean", "nationality" => "Turks and Caicos Islands", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Leuschke", "firstname" => "Estelle", "nationality" => "Niue", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Funk", "firstname" => "Roselyn", "nationality" => "Djibouti", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Romaguera", "firstname" => "Kariane", "nationality" => "Djibouti", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Nitzsche", "firstname" => "Adrian", "nationality" => "Guernsey", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Windler", "firstname" => "Maggie", "nationality" => "Guernsey", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Blanda", "firstname" => "Ken", "nationality" => "French Southern Territories", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Reilly", "firstname" => "Antone", "nationality" => "Yemen", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Cassin", "firstname" => "Yadira", "nationality" => "Mayotte", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Macejkovic", "firstname" => "Marge", "nationality" => "Slovakia", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Feest", "firstname" => "Rogers", "nationality" => "Monaco", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Fadel", "firstname" => "Candelario", "nationality" => "Belarus", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Shields", "firstname" => "Eldridge", "nationality" => "Neutral Zone", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Romaguera", "firstname" => "Lavina", "nationality" => "Canton and Enderbury Islands", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Hessel", "firstname" => "Matt", "nationality" => "Czech Republic", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Donnelly", "firstname" => "Barrett", "nationality" => "South Korea", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Hagenes", "firstname" => "Betty", "nationality" => "Samoa", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Schmeler", "firstname" => "Alphonso", "nationality" => "Palau", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Shields", "firstname" => "Selmer", "nationality" => "Samoa", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Kemmer", "firstname" => "Earl", "nationality" => "Niger", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Kunde", "firstname" => "Sharon", "nationality" => "French Guiana", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Jacobs", "firstname" => "Jeffry", "nationality" => "Albania", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Ritchie", "firstname" => "Eliane", "nationality" => "Chad", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Erdman", "firstname" => "Howard", "nationality" => "Puerto Rico", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Schimmel", "firstname" => "Lance", "nationality" => "Serbia", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Tillman", "firstname" => "Elliott", "nationality" => "Botswana", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Boyle", "firstname" => "Emanuel", "nationality" => "Tokelau", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Feest", "firstname" => "Norma", "nationality" => "Georgia", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "O'Conner", "firstname" => "Jenifer", "nationality" => "Nepal", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Towne", "firstname" => "Lilliana", "nationality" => "New Caledonia", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Padberg", "firstname" => "Verner", "nationality" => "Seychelles", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Stiedemann", "firstname" => "Adelia", "nationality" => "Greece", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Turcotte", "firstname" => "Tristin", "nationality" => "Nauru", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Pouros", "firstname" => "Cooper", "nationality" => "Micronesia", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Romaguera", "firstname" => "Judy", "nationality" => "Australia", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Tremblay", "firstname" => "Maxie", "nationality" => "French Guiana", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Barrows", "firstname" => "Akeem", "nationality" => "Mozambique", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Funk", "firstname" => "Florencio", "nationality" => "Malawi", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Welch", "firstname" => "Margarita", "nationality" => "Ethiopia", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Legros", "firstname" => "Helmer", "nationality" => "Antigua and Barbuda", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Labadie", "firstname" => "Carole", "nationality" => "Martinique", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Klein", "firstname" => "Desiree", "nationality" => "Nepal", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Kuvalis", "firstname" => "Eloy", "nationality" => "Panama Canal Zone", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Macejkovic", "firstname" => "Lucinda", "nationality" => "Austria", "email" => "*****@*****.**", "address_id" => rand(0, 88), "course_id" => rand(0, 199)), array("surname" => "Bosco", "firstname" => "Emilia", "nationality" => "São Tomé and Príncipe", "email" => "*****@*****.**")); foreach ($students as $student) { Students::create($student); } }
/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { if (isset($_POST['idProfile']) && isset($_POST['idEssay']) && isset($_POST['stardate']) && isset($_POST['enddate'])) { if (!empty($_POST['idProfile']) && !empty($_POST['idEssay']) && !empty($_POST['stardate']) && !empty($_POST['enddate'])) { $essay = $this->loadModel($id); $model = new EssaysHasCrugeUser(); $idStudent = Students::model()->find('profile_id=' . $_POST['idProfile'])->id; $model->status = 1; $model->stardate = strtotime($_POST['stardate']); $model->enddate = strtotime($_POST['enddate']); $model->essays_id = $_POST['idEssay']; $model->title_essay = $essay->getNameTitleEssay($idStudent, $essay->colleges_has_majors_colleges_id, $essay->type_essay_id, $_POST['idEssay']); $model->students_id = $idStudent; /* echo "<pre>"; echo print_r($model->enddate); echo "</pre>"; Yii::app()->end(); */ if ($model->save()) { Yii::app()->user->setFlash('save', 'El Estudiante se ha agregado correctamente.'); $this->redirect(array('view', 'id' => $model->essays_id)); } } Yii::app()->user->setFlash('error', 'Debe seleccionar un Estudiante, la fecha de inicio y culminación del Essay.'); $this->redirect(array('view', 'id' => $_POST['idEssay'])); } $this->render('view', array('model' => $this->loadModel($id))); }
public function studentname($data, $row) { $student = Students::model()->findByAttributes(array('id' => $data->student_id)); if ($student != NULL) { return ucfirst($student->first_name) . ' ' . ucfirst($student->last_name); } else { return '-'; } }
private function map_data() { $student = new Students(); $student->set_first_name($_POST['first_name']); $student->set_last_name($_POST['last_name']); $student->set_email($_POST['email']); $student->set_contact_no($_POST['contact_no']); $student->set_course($_POST['course_id']); return $student; }
private function _map_posted_data() { $students = new Students(); $students->set_first_name($_POST['first_name']); $students->set_last_name($_POST['last_name']); $students->set_email($_POST['email']); $students->set_contact_no($_POST['contact_no']); $students->set_course($_POST['course']); return $students; }
private function execute($query) { $data = null; $pdoData = Students::getPDO()->prepare($query); $pdoData->execute(); $responseMassage = $pdoData->errorInfo(); //Объект с сообщением и кодом о проведеной операции if ($responseMassage[0] == 0) { //если выборка прошла то .... $data = $pdoData; } return $data; }
public static function login() { $input = Input::all(); $sid = Students::checkStudent($input['email'], $input['password']); if ($sid && $sid != 2) { Session::put('sid', $sid); return Redirect::to('/students'); } elseif ($sid && $sid == 2) { return Redirect::to('/students/login')->withErrors(array("msg" => "Password is invalid. Please Try again.")); } else { return Redirect::to('/students/login')->withErrors(array("msg" => "Sorry!! Student of this email id does not exist.")); } }
public function actionBatch() { if (isset($_POST['batch'])) { $data = Students::model()->findAll('batch_id=:x', array(':x' => $_POST['batch'])); } // echo CHtml::tag('option', array('value' => 0), CHtml::encode('Select'), true); $data = CHtml::listData($data, 'id', 'phone1'); foreach ($data as $phoneno) { if ($phoneno != "") { echo $phoneno; echo ","; } } }
public function actionAddpoint($id) { $student = Students::model()->findByPk($id); $bonus = new Points(); if (isset($_REQUEST['Points'])) { $data = $_REQUEST['Points']; $bonus->student = $data['student']; $bonus->earned = $data['earned']; $bonus->comment = $data['comment']; $bonus->by = $data['by']; if ($bonus->save()) { Yii::app()->notify->add("Бонус добавлен"); } else { Yii::app()->notify->addErrors($bonus->getErrors()); } } $this->render('addpoint', array('student' => $student, "point" => $bonus)); }
public function actionStudent() { if (isset($_POST['studentuser'])) { $students = Students::model()->findAll(array('condition' => 'uid=:x and is_deleted=:y', 'params' => array(':x' => 0, ':y' => 0), 'limit' => '1000', 'order' => 'id ASC')); if ($students != NULL) { foreach ($students as $student) { $user = new User(); $profile = new Profile(); if ($student->email != NULL) { $user->username = substr(md5(uniqid(mt_rand(), true)), 0, 10); $user->email = $student->email; $user->activkey = UserModule::encrypting(microtime() . $student->first_name); $password = substr(md5(uniqid(mt_rand(), true)), 0, 10); $user->password = UserModule::encrypting($password); $user->superuser = 0; $user->status = 1; if ($user->save()) { //assign role $authorizer = Yii::app()->getModule("rights")->getAuthorizer(); $authorizer->authManager->assign('student', $user->id); //profile $profile->firstname = $student->first_name; $profile->lastname = $student->last_name; $profile->user_id = $user->id; $profile->save(); //saving user id to students table. $student->saveAttributes(array('uid' => $user->id)); UserModule::sendMail($student->email, UserModule::t("You are registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please login to your account with your email id as username and password {password}", array('{password}' => $password))); $flash = "User created successfully"; $type = 'success'; } } else { $flash = "No email id given"; $type = 'error'; } } } Yii::app()->user->setFlash($type, $flash); $this->redirect(array('/importcsv')); } else { $this->render('/default/student'); } }
/** * Specifies the access control rules. * This method is used by the 'accessControl' filter. * @return array access control rules */ public function actionIndex() { $criteria = new CDbCriteria(); $criteria->condition = ''; $roles = Rights::getAssignedRoles(Yii::app()->user->id); // check for single role $user_roles = array(); foreach ($roles as $role) { $user_roles[] = '"' . $role->name . '"'; } $student = Students::model()->findByAttributes(array('uid' => Yii::app()->user->id)); $batch = Batches::model()->findByAttributes(array('id' => $student->batch_id)); $criteria->condition .= '`file`<>:null AND (`placeholder`=:null OR `placeholder` IN (' . implode(',', $user_roles) . ')) AND ((`course` IS NULL) OR (`course`=:course) OR (`course`=0)) AND ((`batch` IS NULL) OR (`batch`=:batch) OR (`batch`=0))'; $criteria->params = array(':null' => '', ':course' => $batch->course_id, ':batch' => $batch->id); $criteria->order = '`created_at` DESC'; //print_r($criteria); exit; $files = FileUploads::model()->findAll($criteria); if (isset($_POST['Downfiles'])) { $selected_files = $_POST['Downfiles']; $slfiles = array(); foreach ($selected_files as $s_file) { $model = FileUploads::model()->findByPk($s_file); if ($model != NULL) { $slfiles[] = 'uploads/shared/' . $model->id . '/' . $model->file; } } $zip = Yii::app()->zip; $fName = $this->generateRandomString(rand(10, 20)) . '.zip'; $zipFile = 'compressed/' . $fName; if ($zip->makeZip($slfiles, $zipFile)) { $fcon = file_get_contents($zipFile); header('Content-type:text/plain'); header('Content-disposition:attachment; filename=' . $fName); header('Pragma:no-cache'); echo $fcon; unlink($zipFile); } else { Yii::app()->user->setFlash('success', 'Can\'t download'); } } $this->render('/fileUploads/index', array('files' => $files)); }
public function get_all() { $student_list = array(); //database connect $this->db->connect(); //query $sql = "SELECT * FROM students"; //execute and fetch data $result = $this->db->fetch_query($sql); while ($row = $result->fetch_assoc()) { //put in object $student = new Students(); $student->set_id($row['id']); $student->set_first_name($row['first_name']); $student->set_last_name($row['last_name']); $student->set_email($row['email']); $student->set_contact_no($row['contact_no']); $student->set_course($row['course']); array_push($student_list, $student); } return $student_list; $this->db->close; }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { if (Yii::app()->request->isPostRequest) { $model = ExamScores::model()->findByAttributes(array('id' => $id)); $student = Students::model()->findByAttributes(array('id' => $model->student_id)); $student_name = ucfirst($student->first_name) . ' ' . ucfirst($student->middle_name) . ' ' . ucfirst($student->last_name); $exam = Exams::model()->findByAttributes(array('id' => $model->exam_id)); $subject_name = Subjects::model()->findByAttributes(array('id' => $exam->subject_id)); $examgroup = ExamGroups::model()->findByAttributes(array('id' => $exam->exam_group_id)); $batch = Batches::model()->findByAttributes(array('id' => $examgroup->batch_id)); $exam_name = ucfirst($subject_name->name) . ' - ' . ucfirst($examgroup->name) . ' (' . ucfirst($batch->name) . '-' . ucfirst($batch->course123->course_name) . ')'; $goal_name = $student_name . ' for the exam ' . $exam_name; // we only allow deletion via POST request $this->loadModel($id)->delete(); //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value) ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '22', $model->id, $goal_name, NULL, NULL, NULL); // we only allow deletion via POST request //$this->loadModel($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }
<?php $criteria = new CDbCriteria(); $criteria->order = 'id DESC'; $total = Transportation::model()->count($criteria); $pages = new CPagination($total); $pages->setPageSize(Yii::app()->params['listPerPage']); $pages->applyLimit($criteria); // the trick is here! $route = Transportation::model()->findAll($criteria); $page_size = Yii::app()->params['listPerPage']; ?> <?php //$route=Transportation::model()->findAll(); if ($route) { foreach ($route as $route1) { $student = Students::model()->findByAttributes(array('id' => $route1->student_id)); $stop = StopDetails::model()->findByAttributes(array('id' => $route1->stop_id)); $route = RouteDetails::model()->findByAttributes(array('id' => $stop->route_id)); ?> <td align="center"> <?php echo $student->last_name . ' ' . $student->first_name; ?> </td> <td align="center"> <?php echo $route->route_name; ?> </td>
<?php $course = Courses::model()->findByAttributes(array('id' => $batch->course_id)); if ($course != NULL) { echo $course->course_name; } ?> </span> </li> </ul> <div class="clear"></div> </div> <div class="status_bx"> <ul> <li style="border-right:1px #d9e1e7 solid"><span><?php echo count(Students::model()->findAll("batch_id=:x", array(':x' => $_REQUEST['id']))); ?> </span><?php echo Yii::t('Batch', 'Students'); ?> </li> <li style="border-left:1px #fff solid;border-right:1px #d9e1e7 solid;"><span><?php echo count(Subjects::model()->findAll("batch_id=:x", array(':x' => $_REQUEST['id']))); ?> </span><?php echo Yii::t('Batch', 'Subjects'); ?> </li> <li style="border-left:1px #fff solid"><span><?php echo count(TimetableEntries::model()->findAll(array('condition' => 'batch_id=:x', 'group' => 'employee_id', 'params' => array(':x' => $_REQUEST['id'])))); ?>
<td width="247" valign="top"> <?php $this->renderPartial('left_side'); ?> </td> <td valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top" width="75%"><div style="padding-left:20px;"> <h1>Accounting Dashboard</h1> <div class="overview"> <div class="overviewbox ovbox1"> <?php $total = Students::model()->findAll('is_deleted=:status', array(':status' => '0')); ?> <h1><strong>Total Students</strong></h1> <div class="ovrBtm"><?php echo count($total); ?> </div> </div> <div class="overviewbox ovbox2"> <h1><strong>New Admissions</strong></h1> <div class="ovrBtm">122</div> </div> <div class="overviewbox ovbox3"> <h1><strong>Pending Leads</strong></h1> <?php
?> <td style="width:auto; min-width:80px; text-align:center;"><?php if (count($list) > 7) { echo @$subject->code; } else { echo @$subject->name; } ?> </td> <?php } ?> </tr> <!-- End Table Headers --> <?php $students = Students::model()->findAllByAttributes(array('batch_id' => $batch_id, 'is_deleted' => 0, 'is_active' => 1)); if (isset($students) and $students != NULL) { foreach ($students as $student) { ?> <tr class=<?php echo $cls; ?> > <td> <?php echo $student->admission_no; ?> </td> <td> <?php echo CHtml::link(ucfirst($student->first_name) . ' ' . ucfirst($student->middle_name) . ' ' . ucfirst($student->last_name), array('/students/students/view', 'id' => $student->id));
public function actionRemove($id) { if (Yii::app()->request->isPostRequest) { // we only allow deletion via POST request //$this->loadModel($id)->delete(); $model = Students::model()->findByPk($id); $model->requirements_id = null; if ($model->save()) { Yii::app()->user->setFlash('remove', 'El Estudiante se ha removido correctamente.'); } $this->redirect(array('view', 'id' => $_POST['idx'])); //$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }
font-size:15px; font-style:italic; text-shadow: 1px -1px 2px #862626; text-align:left; } .container{ background:#FFF; } </style> <div class="formCon"> <div class="formConInner"> <?php if (isset($_REQUEST['id'])) { $posts = Students::model()->findAll("batch_id=:x and is_active=:y and is_deleted=:z", array(':x' => $_REQUEST['id'], ':y' => 1, ':z' => 0)); ?> <?php if ($posts != NULL) { ?> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'exam-scores-form', 'enableAjaxValidation' => false)); if (Yii::app()->user->hasFlash('success')) { ?> <div class="infogreen_bx" style="margin:10px 0 10px 10px; width:575px;"><?php echo Yii::app()->user->getFlash('success'); ?> </div> <?php } else {
<?php require_once '/home/cnausa/public_html/crons/classes/Students.php'; $student = new Students(); $type = 4; // yearly $list = $student->get_report_payments($type); echo $list;
public function actionStudentindividualpdf() { $student_name = Students::model()->findByAttributes(array('id' => $_REQUEST['student'])); $pdf_name = ucfirst($student_name->first_name) . ' ' . ucfirst($student_name->last_name) . ' Student Attendance Report.pdf'; # HTML2PDF has very similar syntax $html2pdf = Yii::app()->ePdf->HTML2PDF(); $html2pdf->WriteHTML($this->renderPartial('studentindividualpdf', array(), true)); $html2pdf->Output($pdf_name); }
public function actionPdf1() { $student = Students::model()->findByAttributes(array('id' => $_REQUEST['id'])); $student = $student->first_name . ' ' . $student->last_name . ' Attendance.pdf'; # HTML2PDF has very similar syntax $html2pdf = Yii::app()->ePdf->HTML2PDF(); $html2pdf->WriteHTML($this->renderPartial('attentstud', array(), true)); $html2pdf->Output($student); //////////////////////////////////////////////////////////////////////////////////// }
<?php require_once '../config.php'; require_once '../dao/students.php'; $paternName = "/^\\[a-zA-Z]|[а-яА-Я]+\$/"; $name = $_POST['name']; $surname = $_POST['surname']; if (preg_match($paternName, $name) && preg_match($paternName, $surname)) { $student = new Students(); $student->addStudents($name, $surname); echo "OK"; } else { die("Недопустимый запрос"); }
</script> <div id="parent_Sect"> <?php $this->renderPartial('leftside'); ?> <?php $user = User::model()->findByAttributes(array('id' => Yii::app()->user->id)); $guardian = Guardians::model()->findByAttributes(array('uid' => Yii::app()->user->id)); $students = Students::model()->findAllByAttributes(array('parent_id' => $guardian->id)); if (count($students) == 1) { $student = Students::model()->findByAttributes(array('id' => $students[0]->id)); } elseif (isset($_REQUEST['id']) and $_REQUEST['id'] != NULL) { $student = Students::model()->findByAttributes(array('id' => $_REQUEST['id'])); } elseif (count($students) > 1) { $student = Students::model()->findByAttributes(array('id' => $students[0]->id)); } $exam = ExamScores::model()->findAll("student_id=:x", array(':x' => $student->id)); ?> <div id="parent_rightSect"> <div class="parentright_innercon"> <h1><?php echo Yii::t('parentportal', 'Exams'); ?> </h1> <div class="profile_top"> <div class="prof_img"> <?php if ($student->photo_data != NULL) { echo '<img src="' . $this->createUrl('/students/Students/DisplaySavedImage&id=' . $student->primaryKey) . '" alt="' . $student->photo_file_name . '" width="100" height="103" />'; } elseif ($student->gender == 'M') {
public function actionAjax_delete() { $id = $_POST['id']; $deleted = $this->loadModel($id); $deleted_batch_id = $deleted->batch_id; // Saving the id of the batch that is going to be deleted. if ($deleted->delete()) { //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value) ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '13', $deleted_batch_id, ucfirst($deleted->name), NULL, NULL, NULL); // For SMS $sms_settings = SmsSettings::model()->findAll(); $to = ''; if ($sms_settings[0]->is_enabled == '1' and $sms_settings[5]->is_enabled == '1') { // Checking if SMS is enabled. $students = Students::model()->findAll("batch_id=:x", array(':x' => $deleted_batch_id)); //Selecting students of the batch foreach ($students as $student) { if ($student->phone1) { // Checking if phone number is provided $to = $student->phone1; } elseif ($student->phone2) { $to = $student->phone2; } if ($to != '') { // Sending SMS to each student $college = Configurations::model()->findByPk(1); $from = $college->config_value; $message = $deleted->name . ' is cancelled'; SmsSettings::model()->sendSms($to, $from, $message); } } } // End For SMS // Delete Exam and exam score $exam = Exams::model()->findAllByAttributes(array('exam_group_id' => $id)); //print_r($exam); foreach ($exam as $exam1) { $examscore = ExamScores::model()->findAllByAttributes(array('exam_id' => $exam1->id)); foreach ($examscore as $examscore1) { $examscore1->delete(); } $exam1->delete(); } // End Delete Exam and exam score echo json_encode(array('success' => true)); exit; } else { echo json_encode(array('success' => false)); exit; } }