/** * Displays the update profile page of a student. * @param integer $id the student id */ public function actionUpdate($id) { $model = $this->loadModel($id); if (isset($_POST['Student'])) { $model->attributes = $_POST['Student']; if ($model->validate()) { $photo = CUploadedFile::getInstance($model, 'file'); if ($photo !== null) { $savePath = Yii::app()->params['photosDir']; if ($model->photo != Yii::app()->params['defaultProfilePhoto']) { unlink($savePath . $model->photo); } Yii::import('ext.randomness.*'); $fileName = Randomness::randomString(Student::MAX_FILENAME_LENGTH - strlen($photo->extensionName) - strlen('' + $model->id) - 1); $fileName = $fileName . $model->id . '.' . $photo->extensionName; $photo->saveAs($savePath . $fileName); $model->photo = $fileName; Yii::app()->user->setState('profilePhoto', $fileName); } $model->save(false); Yii::app()->user->setName($model->name); Yii::app()->user->setNotification('success', 'Profil berhasil diubah.'); } else { Yii::app()->user->setNotification('danger', 'Terdapat kesalahan pengisian.'); } } $this->render('update', array('model' => $model, 'faculties' => Faculty::model()->findAll())); }
/** * Authenticates a dummy user. * @return boolean always true. */ public function authenticate() { $student = Student::model()->findByAttributes(array('username' => $this->username)); if ($student === null) { $student = new Student(); $faculty = Faculty::model()->findByPk(1); if ($faculty === null) { $faculty = new Faculty(); $faculty->id = 1; $faculty->name = 'Dummy Faculty'; $faculty->save(false); } $student->username = $this->username; $student->name = $this->name; $student->is_admin = $this->isAdmin; $student->faculty_id = $faculty->id; $student->photo = Yii::app()->params['defaultProfilePhoto']; } $student->last_login_timestamp = date('Y-m-d H:i:s'); $student->save(); $this->id = $student->id; $this->name = $student->name; $this->setState('isAdmin', $student->is_admin); $this->setState('profilePhoto', $student->photo); return true; }
public function actionGetFacultyInfo() { $this->retVal = new stdClass(); $request = Yii::app()->request; if ($request->isPostRequest && isset($_POST)) { try { $faculty_id = $request->getPost('faculty_id'); $faculty_data = Faculty::model()->findAllByAttributes(array('faculty_id' => $faculty_id)); $this->retVal->faculty_data = $faculty_data; } catch (exception $e) { $this->retVal->message = $e->getMessage(); } echo CJSON::encode($this->retVal); Yii::app()->end(); } }
public function listCategoryFather() { $category_father = Faculty::model()->findAll(); return $category_father; }
/** * 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 Faculty the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Faculty::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php $form = $this->beginWidget('CActiveForm', array('htmlOptions' => array('enctype' => 'multipart/form-data'), 'enableClientValidation' => true, 'clientOptions' => array('validateOnSubmit' => true, 'successCssClass' => '', 'errorCssClass' => 'error'))); ?> <table class='table table-hover'> <?php echo Yii::app()->format->formatInputField($form, 'textField', $model, 'title', 'icon-tag', array('maxlength' => 128)); ?> <?php echo Yii::app()->format->formatInputField($form, 'textArea', $model, 'description', 'icon-zoom-in', array('rows' => 6, 'cols' => 50)); ?> <?php echo Yii::app()->format->formatInputField($form, 'dropDownList', $model, 'faculty_id', 'icon-briefcase', array('prompt' => 'Pilih fakultas', 'ajax' => array('type' => 'POST', 'url' => array('note/updateCourses'), 'update' => '#courses', 'data' => array('faculty_id' => 'js:this.value')), 'options' => array('1' => array('selected' => 'selected'))), array('data' => CHtml::listData(Faculty::model()->findAll(), 'id', 'name'))); ?> <?php echo Yii::app()->format->formatInputField($form, 'dropDownList', $model, 'course_id', 'icon-book', array('prompt' => 'Pilih mata kuliah'), array('data' => CHtml::listData(Course::model()->findAllByAttributes(array('faculty_id' => 1), array('order' => 'name ASC')), 'id', 'name'), 'beforeInput' => '<span id="courses">', 'afterInput' => '</span>')); ?> <?php echo Yii::app()->format->formatInputField($form, 'fileField', $model, 'file', 'icon-file', array(), array('hint' => ' (maks ' . Yii::app()->format->size(Note::MAX_FILE_SIZE) . ', PDF/JPEG)')); ?> <tr> <td><label><em>atau ketikkan catatan Anda</em></label></td> <td> <?php Yii::app()->getClientScript()->registerScriptFile(Yii::app()->baseUrl . '/tiny_mce/tiny_mce.js');
<?php return array("fields" => array("doc_id" => array("label" => "Doc ID"), "doc_path" => array("label" => "File", "type" => "_document", "modelFile" => "doc_path_file"), "doc_url" => array("label" => "Preview", "type" => "_image"), "doc_name" => array("label" => "Doc Name"), "doc_description" => array("label" => "Doc Description", "type" => "_textarea"), "doc_author_name" => array("label" => "User upload"), "subject_dept" => array("label" => "Department", "type" => "_dropdown", "_list" => array("primary" => "dept_id", "displayAttr" => "dept_name", "src" => function () { $rows = Dept::model()->findAll(); return $rows; })), "subject_doc" => array("label" => "Subject", "type" => "_dropdown", "_list" => array("primary" => "subject_id", "displayAttr" => "subject_name", "src" => function () { $rows = Subject::model()->findAll(); return $rows; })), "subject_faculty" => array("label" => "Faculty", "type" => "_dropdown", "_list" => array("primary" => "faculty_id", "displayAttr" => "faculty_name", "src" => function () { $rows = Faculty::model()->findAll(); return $rows; })), "subject_type" => array("label" => "Subject Type", "type" => "_dropdown", "_list" => array("primary" => "id", "displayAttr" => "subject_type_name", "src" => function () { $rows = SubjectType::model()->findAll(); return $rows; })), "doc_dept_name" => array("label" => "Department", "src" => "dept.dept_name")), "columns" => array("doc_id", "doc_url", "doc_name", "doc_description", "doc_author_name", "subject_faculty", "doc_dept_name", "doc_path"), "actions" => array("_view" => true, "_edit" => array("doc_name", "doc_description", "doc_author_name", "subject_dept", "subject_faculty", "subject_type"), "_delete" => true, "_new" => array("type" => "popup", "attr" => array("doc_name", "doc_description", "doc_path", "subject_doc"), "extend" => array("doc_author" => Util::param("ADMIN_ID"), "doc_author_name" => "Admin")), "_search" => array("doc_id", "doc_name"), "_search_advanced" => array("doc_author_name", "subject_dept", "subject_faculty", "doc_name"), "_customButtons" => array()), "default" => array("orderBy" => "doc_id", "orderType" => "desc", "page" => 1, "per_page" => 10, "search" => "", "search_advanced" => ""), "join" => array("dept" => array("table" => "select dept_id, dept_name from tbl_dept", "type" => "left join", "selected_properties" => array("dept_name" => "doc_dept_name"), "on" => array("dept_id" => "t.subject_dept"))), "tableAlias" => "document", "title" => "Document Manager", "condition" => false, "limit_values" => array(10, 20, 30, 40), "model" => "Doc", "primary" => "doc_id", "itemLabel" => "Document", "additionalFiles" => array(), "insertScenario" => "fromAdmin", "updateScenario" => "fromAdmin", "formUpload" => TRUE);
public function actionListTeacherFaculty() { $this->retVal = new stdClass(); $request = Yii::app()->request; if ($request->isPostRequest && isset($_POST)) { try { $listSubjectData = array('faculty_id' => StringHelper::filterString($_POST['faculty_id'])); $faculty_data = Faculty::model()->findAllByAttributes(array('faculty_id' => $listSubjectData['faculty_id'])); $teacher_data = Teacher::model()->findAllByAttributes(array('teacher_faculty' => $listSubjectData['faculty_id'])); $this->retVal->teacher_data = $teacher_data; $this->retVal->faculty_data = $faculty_data; $this->retVal->message = 1; } catch (exception $e) { $this->retVal->message = $e->getMessage(); } echo CJSON::encode($this->retVal); Yii::app()->end(); } }
<div class="field"> <?php echo $form->label($model, 'type'); ?> <?php echo $form->dropDownList($model, 'type', Note::getTypeNames(), array('prompt' => '(semua)')); ?> </div> <div class="field"> <?php echo $form->label($model, 'faculty_id'); ?> <?php echo $form->dropDownList($model, 'faculty_id', CHtml::listData(Faculty::model()->findAll(), 'id', 'name'), array('prompt' => '(semua)', 'ajax' => array('type' => 'POST', 'url' => array('home/updateCourses'), 'update' => '#courses', 'data' => array('faculty_id' => 'js:this.value')), 'options' => array('1' => array('selected' => 'selected')))); ?> </div> <div class="field" id="courses"> <?php echo $form->label($model, 'course_id'); ?> <?php echo $form->dropDownList($model, 'course_id', CHtml::listData(Course::model()->findAllByAttributes(array('faculty_id' => 1), array('order' => 'name ASC')), 'id', 'name'), array('prompt' => '(semua)')); ?> </div> <div class="field"> <?php echo $form->label($model, 'uploader');
public function actionFacultyInfo() { $category_father = $this->listCategoryFather(); $subject_type = $this->listSubjectType(); $this->retVal = new stdClass(); $request = Yii::app()->request; if ($request->isPostRequest && isset($_POST)) { try { $listSubjectData = array('faculty_id' => StringHelper::filterString($_POST['faculty_id'])); $faculty_data = Faculty::model()->findAllByAttributes(array('faculty_id' => $listSubjectData['faculty_id'])); $sql = "SELECT * FROM tbl_teacher_faculty_position INNER JOIN tbl_teacher ON tbl_teacher_faculty_position.teacher_id = tbl_teacher.teacher_id WHERE tbl_teacher_faculty_position.teacher_id = '" . $listSubjectData['faculty_id'] . "'"; $teacher_faculty_position = Yii::app()->db->createCommand($sql)->queryAll(); $this->retVal->faculty_data = $faculty_data; $this->retVal->teacher_faculty_position = $teacher_faculty_position; $this->retVal->message = 1; } catch (exception $e) { $this->retVal->message = $e->getMessage(); } echo CJSON::encode($this->retVal); Yii::app()->end(); } }