/** * 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 the ID of the model to be loaded */ public function loadModel($id) { $model = StudentCategories::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
?> <tr> <td><?php echo $i; ?> </td> <td><?php echo $particular_1->name; ?> </td> <td> <?php if ($particular_1->student_category_id == NULL and $particular_1->admission_no == NULL) { echo 'All'; } elseif ($particular_1->student_category_id != NULL and $particular_1->admission_no == NULL) { $student_category = StudentCategories::model()->findByAttributes(array('id' => $particular_1->student_category_id)); echo 'Category: ' . $student_category->name; } elseif ($particular_1->student_category_id == NULL and $particular_1->admission_no != NULL) { echo 'Admission No: ' . $particular_1->admission_no; } else { echo '-'; } ?> </td> <td><?php echo $currency->config_value . ' ' . $particular_1->amount; ?> </td> </tr> <?php
<tr> <td class="listbx_subhdng">Language</td> <td class="subhdng_nrmal"><?php echo $model->language; ?> </td> <td class="listbx_subhdng">Email</td> <td class="subhdng_nrmal"><?php echo $model->email; ?> </td> </tr> <tr> <td class="listbx_subhdng">Category</td> <td class="subhdng_nrmal"><?php $cat = StudentCategories::model()->findByAttributes(array('id' => $model->student_category_id)); echo $cat->name; ?> </td> <td class="listbx_subhdng">Religion</td> <td class="subhdng_nrmal"><?php echo $model->religion; ?> </td> </tr> <tr > <td colspan="4" class="listbx_subhdng">In case of emergencies,<br /> contact : <?php $posts = Guardians::model()->findByAttributes(array('id' => $model->immediate_contact_id)); if (count($posts) == 0) { echo "No Guardians are added" . ' ' . CHtml::link('Add new', array('guardians/create&id=' . $model->id));
<div class="row_checkbox" id="category" > <?php if ($model->isNewRecord) { ?> <?php echo $form->labelEx($model, 'student_category_id'); ?> <?php $data = CHtml::listData(StudentCategories::model()->findAll(), 'id', 'name'); echo '<div style="height:auto;width:450px;overflow-y:auto;line-height:0px;">'; echo '<table>'; echo $form->checkBoxList($model, 'id', $data, array('htmlOption' => 'style=clear:both', 'template' => '<tr><td>{input}</td><td>{label}</td></tr>', 'checkAll' => 'All')); echo '</table>'; echo '</div>'; ?> <?php } ?> </div> <div class="row" id="admission" style="display:none;"> <?php echo $form->labelEx($model, 'admission_no'); ?>
<td> </td> <td valign="top"> <?php echo $form->textField($model, 'religion', array('size' => 10, 'maxlength' => 255)); ?> <?php echo $form->error($model, 'religion'); ?> </td> <td> </td> <td valign="top"> <?php //echo $form->textField($model,'student_category_id'); ?> <?php echo $form->dropDownList($model, 'student_category_id', CHtml::listData(StudentCategories::model()->findAll(), 'id', 'name')); ?> <?php echo $form->error($model, 'student_category_id'); ?> </td> </tr> </table> </div> </div> <div class="formCon" > <div class="formConInner"> <h3>Contact Details</h3> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr>
$page_size = Yii::app()->params['listPerPage']; ?> <ul> <li> <?php echo CHtml::link('<span>' . Yii::t('students', 'Create New Category') . '</span>', array('#'), array('id' => 'add_student-categories', 'class' => 'addbttn last')); ?> </li> </ul> <div class="clear"></div> </div><div id="success_flash" align="center" style=" color:#F00; display:none;"><h4>Selected category Deleted Successfully !</h4> </div> </div> <?php $datas = StudentCategories::model()->findAll($criteria); ?> <div id="student-categories-grid"> <div class="grid_table_con"> <table width="100%" border="0" cellspacing="0" cellpadding="0" id="example"> <tr> <th width="45%"><?php echo Yii::t('students', 'Category Name'); ?> <a href="#" class="sort_but"></a></th> <th width="16%"><?php echo Yii::t('students', 'Status'); ?> <a href="#" class="sort_but"></a></th> <th width="19%"><?php
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $settings = UserSettings::model()->findByAttributes(array('user_id' => Yii::app()->user->id)); if ($settings != NULL) { $date1 = date($settings->displaydate, strtotime($model->admission_date)); $date2 = date($settings->displaydate, strtotime($model->date_of_birth)); } $model->admission_date = $date1; $model->date_of_birth = $date2; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Students'])) { $old_model = $model->attributes; // For activity feed $model->attributes = $_POST['Students']; if ($model->admission_date) { $model->admission_date = date('Y-m-d', strtotime($model->admission_date)); } if ($model->date_of_birth) { $model->date_of_birth = date('Y-m-d', strtotime($model->date_of_birth)); } if ($file = CUploadedFile::getInstance($model, 'photo_data')) { $model->photo_file_name = $file->name; $model->photo_content_type = $file->type; $model->photo_file_size = $file->size; $model->photo_data = file_get_contents($file->tempName); } if ($model->save()) { // Saving to activity feed $results = array_diff_assoc($_POST['Students'], $old_model); // To get the fields that are modified. //print_r($old_model);echo '<br/><br/>';print_r($_POST['Students']);echo '<br/><br/>';print_r($results);echo '<br/><br/>'.count($results);echo '<br/><br/>'; foreach ($results as $key => $value) { if ($key != 'updated_at') { if ($key == 'batch_id') { $value = Batches::model()->findByAttributes(array('id' => $value)); $value = $value->name . '-' . $value->course123->course_name; $old_model_value = Batches::model()->findByAttributes(array('id' => $old_model[$key])); $old_model[$key] = $old_model_value->name . '-' . $old_model_value->course123->course_name; } elseif ($key == 'gender') { if ($value == 'F') { $value = 'Female'; } else { $value = 'Male'; } if ($old_model[$key] == 'F') { $old_model[$key] = 'Female'; } else { $old_model[$key] = 'Male'; } } elseif ($key == 'student_category_id') { $value = StudentCategories::model()->findByAttributes(array('id' => $value)); $value = $value->name; $old_model_value = StudentCategories::model()->findByAttributes(array('id' => $old_model[$key])); $old_model[$key] = $old_model_value->name; } elseif ($key == 'nationality_id' or $key == 'country_id') { $value = Countries::model()->findByAttributes(array('id' => $value)); $value = $value->name; $old_model_value = Countries::model()->findByAttributes(array('id' => $old_model[$key])); $old_model[$key] = $old_model_value->name; } //echo $key.'-'.$model->getAttributeLabel($key).'-'.$value.'-'.$old_model[$key].'<br/>'; //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, '4', $model->id, ucfirst($model->first_name) . ' ' . ucfirst($model->middle_name) . ' ' . ucfirst($model->last_name), $model->getAttributeLabel($key), $old_model[$key], $value); } } //END saving to activity feed if (defined('EMAIL_ALERT_ADDRESS')) { $name = $model->first_name . " " . $model->last_name; UserModule::sendMail(constant('EMAIL_ALERT_ADDRESS'), UserModule::t("Student details modified : {student_name}", array('{student_name}' => $name)), UserModule::t("Student details has been modified for : {student_name}", array('{student_name}' => $name))); } $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', array('model' => $model)); }
public function getCategory($data, $row) { $student_category = StudentCategories::model()->findByAttributes(array('id' => $data->student_category_id, 'is_deleted' => 0)); if (count($student_category) > 0) { return $student_category->name; } else { return '-'; } }