public function loadModel($id) { $model = Countries::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionEnabled($id) { $model = Countries::model()->findByPk($id); if ($model->status == 1) { $model->status = 0; } else { $model->status = 1; } $model->save(); $this->redirect(array("index")); }
<td><strong><?php echo Yii::t('teachersportal', 'Office State'); ?> </strong></td> <td><?php echo $employee->office_state; ?> </td> </tr> <tr> <td><strong><?php echo Yii::t('teachersportal', 'Office Country'); ?> </strong></td> <td><?php $count = Countries::model()->findByAttributes(array('id' => $employee->office_country_id)); if (count($count) != 0) { echo $count->name; } ?> </td> <td><strong><?php echo Yii::t('teachersportal', 'Office Pin'); ?> </strong></td> <td><?php echo $employee->office_pin_code; ?> </td> </tr> <tr>
<td> </td> <td valign="top"> <?php echo $form->textField($model, 'pin_code', array('size' => 15, 'maxlength' => 255)); ?> <?php echo $form->error($model, 'pin_code'); ?> </td> <td> </td> <td valign="top"> <?php //echo $form->textField($model,'country_id'); ?> <?php echo $form->dropDownList($model, 'country_id', CHtml::listData(Countries::model()->findAll(), 'id', 'name'), array('style' => 'width:140px;', 'empty' => 'Select Country')); ?> <?php echo $form->error($model, 'country_id'); ?> </td> </tr> <tr> <td colspan="5"> </td> </tr> <tr> <td valign="bottom"><?php echo $form->labelEx($model, Yii::t('students', 'phone1')); ?> </td> <td> </td>
<td style="text-align:left; padding-left:5px;"> <?php if ($guard->office_address_line1 != NULL) { echo ucfirst($guard->office_address_line1) . '<br />'; } if ($guard->office_address_line2 != NULL) { echo ucfirst($guard->office_address_line2) . '<br />'; } if ($guard->city != NULL) { echo ucfirst($guard->city) . '<br />'; } if ($guard->state != NULL) { echo ucfirst($guard->state) . '<br />'; } if ($guard->country_id != NULL) { $country = Countries::model()->findByAttributes(array('id' => $guard->country_id)); echo ucfirst($country->name) . '<br />'; } if ($guard->office_address_line1 == NULL and $guard->office_address_line2 == NULL and $guard->city == NULL and $guard->state == NULL and $guard->country_id == NULL) { echo '-'; } ?> </td> </tr> </table> </div> </div> </td> </tr> </table>
?> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><?php echo $form->labelEx($model, 'office_country_id'); ?> </td> <td><?php echo $form->dropDownList($model, 'office_country_id', CHtml::listData(Countries::model()->findAll(), 'id', 'name'), array('empty' => 'Select Country')); ?> <?php echo $form->error($model, 'office_country_id'); ?> </td> <td><?php echo $form->labelEx($model, 'office_pin_code'); ?> </td> <td><?php echo $form->textField($model, 'office_pin_code', array('size' => 25, 'maxlength' => 255)); ?> <?php echo $form->error($model, 'office_pin_code'); ?>
<?php echo $form->textField($model, 'telephone', array('class' => 'form-control')); ?> <?php echo $form->error($model, 'telephone'); ?> </div> </div> <div class="form-group"> <?php echo $form->labelEx($model, 'country', array('class' => 'col-sm-offset-2 col-sm-2')); ?> <div class="col-sm-4"> <?php $list = CHtml::listData(Countries::model()->findAll(array('order' => 'country')), 'id', 'country'); ?> <?php echo $form->dropDownList($model, 'country', $list, array('class' => 'form-control', 'empty' => 'Select Country', 'style' => 'text-transform: capitalize')); ?> <?php echo $form->error($model, 'country'); ?> </div> </div> <div class="form-group"> <?php echo $form->labelEx($model, 'state', array('class' => 'col-sm-offset-2 col-sm-2')); ?> <div class="col-sm-4">
/** * 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); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Guardians'])) { $old_model = $model->attributes; $model->attributes = $_POST['Guardians']; if ($model->save()) { if ($_REQUEST['std'] == NULL) { $student = Students::model()->findByAttributes(array('id' => $_REQUEST['sid'])); $student->saveAttributes(array('parent_id' => $_REQUEST['id'])); //echo $_REQUEST['id'].'/'.$student->first_name; exit; $this->redirect(array('addguardian', 'id' => $_REQUEST['sid'], 'gid' => $_REQUEST['id'])); } // Saving to activity feed $results = array_diff_assoc($_POST['Guardians'], $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 == '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, '15', $model->id, ucfirst($model->first_name) . ' ' . ucfirst($model->last_name), $model->getAttributeLabel($key), $old_model[$key], $value); } } //END saving to activity feed $this->redirect(array('students/view', 'id' => $_REQUEST['std'])); } } $this->render('update', array('model' => $model)); }
echo $model->home_address_line1 . "<br />"; } ?> <?php if ($model->home_address_line2 != NULL) { echo $model->home_address_line2 . "<br />"; } ?> <?php if ($model->home_city != NULL) { echo $model->home_city . "<br />"; } ?> <?php if ($model->home_country_id != NULL) { $count = Countries::model()->findByAttributes(array('id' => $model->home_country_id)); if (count($count) != 0) { echo $count->name . "<br>"; } } ?> <?php if ($model->home_pin_code != NULL) { echo $model->home_pin_code . "<br />"; } ?> </td> </tr> <tr> <td class="listbx_subhdng odd"><?php
public function getMenuCountries() { $countries = Countries::model()->findAll("status=?", array(1)); return CHtml::listData($countries, "id", "selectName"); }
echo Yii::t('employees', 'Home Country'); ?> </td> <td class="subhdng_nrmal"><?php $count = Countries::model()->findByAttributes(array('id' => $model->home_country_id)); if (count($count) != 0) { echo $count->name; } ?> </td> <td class="listbx_subhdng"><?php echo Yii::t('employees', 'Office Country'); ?> </td> <td class="subhdng_nrmal"><?php $count_1 = Countries::model()->findByAttributes(array('id' => $model->office_country_id)); if (count($count_1) != 0) { echo $count_1->name; } ?> </td> </tr> <tr> <td class="listbx_subhdng"><?php echo Yii::t('employees', 'Home PIN'); ?> </td> <td class="subhdng_nrmal"><?php echo $model->home_pin_code; ?> </td>
/** * 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); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $settings = UserSettings::model()->findByAttributes(array('user_id' => Yii::app()->user->id)); if ($settings != NULL) { $date1 = date($settings->displaydate, strtotime($model->joining_date)); $date2 = date($settings->displaydate, strtotime($model->date_of_birth)); } $model->joining_date = $date1; $model->date_of_birth = $date2; if (isset($_POST['Employees'])) { $old_model = $model->attributes; // For activity feed $model->attributes = $_POST['Employees']; if ($model->joining_date) { $model->joining_date = date('Y-m-d', strtotime($model->joining_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['Employees'], $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 == '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 == 'employee_category_id') { $value = EmployeeCategories::model()->findByAttributes(array('id' => $value)); $value = ucfirst($value->name); $old_model_value = EmployeeCategories::model()->findByAttributes(array('id' => $old_model[$key])); $old_model[$key] = ucfirst($old_model_value->name); } elseif ($key == 'employee_position_id') { $value = EmployeePositions::model()->findByAttributes(array('id' => $value)); $value = ucfirst($value->name); $old_model_value = EmployeePositions::model()->findByAttributes(array('id' => $old_model[$key])); $old_model[$key] = ucfirst($old_model_value->name); } elseif ($key == 'employee_department_id') { $value = EmployeeDepartments::model()->findByAttributes(array('id' => $value)); $value = ucfirst($value->name); $old_model_value = EmployeeDepartments::model()->findByAttributes(array('id' => $old_model[$key])); $old_model[$key] = ucfirst($old_model_value->name); } elseif ($key == 'employee_grade_id') { $value = EmployeeGrades::model()->findByAttributes(array('id' => $value)); $value = ucfirst($value->name); $old_model_value = EmployeeGrades::model()->findByAttributes(array('id' => $old_model[$key])); $old_model[$key] = ucfirst($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, '24', $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 $this->redirect(array('update2', 'id' => $model->id)); } } $this->render('update', array('model' => $model)); }
</tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td valign="middle"><?php echo $form->labelEx($model, Yii::t('employees', 'nationality_id')); ?> </td> <td valign="middle"><?php echo $form->dropDownList($model, 'nationality_id', CHtml::listData(Countries::model()->findAll(), 'id', 'name'), array('style' => 'width:140px;')); ?> <?php echo $form->error($model, 'nationality_id'); ?> </td> <td> </td> <td> </td> <td> </td> </tr> </table> </div> </div> <div class="formCon" style=" background:#EDF1D1; border:0px #c4da9b solid; color:#393; background:#EDF1D1 url(images/green-bg.png); border:0px #c4da9b solid; color:#393; ">
<td><?php echo $form->textField($model, 'pin_code', array('size' => 30, 'maxlength' => 255)); ?> <?php echo $form->error($model, 'pin_code'); ?> </td> <td><?php echo $form->labelEx($model, 'country_id'); ?> </td> <td><?php //echo $form->textField($model,'country_id'); ?> <?php echo $form->dropDownList($model, 'country_id', CHtml::listData(Countries::model()->findAll(), 'id', 'name')); ?> <?php echo $form->error($model, 'country_id'); ?> </td> </tr> <tr> <td><?php echo $form->labelEx($model, 'phone1'); ?> </td> <td><?php echo $form->textField($model, 'phone1', array('size' => 30, 'maxlength' => 255)); ?> <?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(false)) { // 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)); }
<a href="<?php echo Yii::app()->request->getUrl() . '&Students[blood_group]='; ?> "></a></li> <?php } ?> <!-- END Blood Group Active Filter --> <!-- Nationality Active Filter --> <?php if (isset($_REQUEST['Students']['nationality_id']) and $_REQUEST['Students']['nationality_id'] != NULL) { $j++; ?> <li>Country : <?php echo Countries::model()->findByAttributes(array('id' => $_REQUEST['Students']['nationality_id']))->name; ?> <a href="<?php echo Yii::app()->request->getUrl() . '&Students[nationality_id]='; ?> "></a></li> <?php } ?> <!-- END Nationality Active Filter --> <!-- Date of Birth Active Filter --> <?php if (isset($_REQUEST['Students']['dobrange']) and $_REQUEST['Students']['dobrange'] != NULL) { if (isset($_REQUEST['Students']['date_of_birth']) and $_REQUEST['Students']['date_of_birth'] != NULL) {
public function actionEnabled($id) { $model = Countries::model()->findByPk($id); // creamos el modelo igual que siempre le pasamos el id if ($model->status == 1) { // si es igual a 1 que lo cambie a 0 $model->status = 0; } else { $model->status = 1; } // sino que lo cambie a 1 $model->save(); // guarda los cambios $this->redirect(array("index")); // renderizo a la vista que vos queres en este caso el mismo index }
} else { echo '-'; } ?> </td> </tr> <tr> <td class="listbx_subhdng odd"><?php echo Yii::t('students', 'Country'); ?> </td> <td class="subhdng_nrmal odd" > <?php if ($model->country_id != NULL) { $posts = Countries::model()->findByAttributes(array('id' => $model->country_id)); echo $posts->name; } else { echo '-'; } ?> </td> </tr> <tr> <td class="listbx_subhdng "><?php echo Yii::t('students', 'Phone 1'); ?> </td> <td class="subhdng_nrmal "> <?php
<tr> <td class="listbx_subhdng">State</td> <td class="subhdng_nrmal"><?php echo $model->state; ?> </td> <td class="listbx_subhdng">Country</td> <td class="subhdng_nrmal"><?php echo $model->country_id; ?> </td> </tr> <tr> <td class="listbx_subhdng">Nationality</td> <td class="subhdng_nrmal"><?php $natio_id = Countries::model()->findByAttributes(array('id' => $model->nationality_id)); echo $natio_id->name; ?> </td> <td class="listbx_subhdng">Gender</td> <td class="subhdng_nrmal"> <?php if ($model->gender == 'M') { echo 'Male'; } else { echo 'Female'; } ?> </td> </tr> <tr>
/** * 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 actionProfile() { $this->tabs = true; $user_id = Yii::app()->user->id; $model = $this->loadModel($user_id); $model->scenario = 'useredit'; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['User'])) { $model->attributes = $_POST['User']; if (isset($_POST['user_image']) && !empty($_POST['user_image'])) { $oldimage = $model->u_image != '' ? $model->u_image : NULL; $model->u_image = $this->UploadImage($_POST['user_image'], 'user', $oldimage); } unset($model->u_last_login_date); unset($model->u_created); if ($model->save()) { Yii::app()->user->setFlash('success', 'Profile updated successfully.'); $this->refresh(); } else { Yii::app()->user->setFlash('error', 'Please verify all the fields.'); } } $orderModel = new Cart(); $orderModel->cart_user_id = $user_id; $criteria = new CDbCriteria(); $criteria->order = 'cnt_name ASC'; $userAddressModel = new UserAddress(); $countriesData = Countries::model()->findAll($criteria); $countries = CHtml::listData($countriesData, 'cnt_id', 'cnt_name'); $states1 = array(); $states2 = array(); $criteria1 = new CDbCriteria(); $criteria1->condition = "uad_user_id=:uad_user_id"; $criteria1->params = array(':uad_user_id' => $user_id); $userAddress = UserAddress::model()->findAll(); $address = array(); if (!empty($userAddress)) { foreach ($userAddress as $key => $arr) { $uad_type = $arr->uad_type; $address[$uad_type]['uad_id'] = $arr->uad_id; $address[$uad_type]['uad_add1'] = $arr->uad_add1; $address[$uad_type]['uad_add2'] = $arr->uad_add2; $address[$uad_type]['uad_country_id'] = $arr->uad_country_id; $address[$uad_type]['uad_state_id'] = $arr->uad_state_id; $address[$uad_type]['uad_city'] = $arr->uad_city; $address[$uad_type]['uad_zipcode'] = $arr->uad_zipcode; $address[$uad_type]['uad_mobile'] = $arr->uad_mobile; } } $criteria = new CDbCriteria(); $criteria->order = "st_name ASC"; $criteria->condition = "st_cnt_id=:st_cnt_id"; if (!empty($address[1]['uad_country_id'])) { $criteria->params = array(':st_cnt_id' => $address[1]['uad_country_id']); $statesData = States::model()->findAll($criteria); $states1 = CHtml::listData($statesData, 'st_id', 'st_name'); } if (!empty($address[2]['uad_country_id'])) { $criteria->params = array(':st_cnt_id' => $address[2]['uad_country_id']); $statesData = States::model()->findAll($criteria); $states2 = CHtml::listData($statesData, 'st_id', 'st_name'); } $criteria1 = new CDbCriteria(); $criteria1->condition = "umr_user_id=:umr_user_id"; $criteria1->params = array(':umr_user_id' => $user_id); $userMesurementData = UserMeasurements::model()->findAll($criteria1); $userMesurements = array(); if (!empty($userMesurementData)) { foreach ($userMesurementData as $umKey => $umArr) { $umType = $umArr->umr_type; $userMesurements[$umType][] = $umArr; } } $this->render('profile', array('model' => $model, 'orderModel' => $orderModel, 'userAddressModel' => $userAddressModel, 'countries' => $countries, 'states1' => $states1, 'states2' => $states2, 'address' => $address, 'userMesurements' => $userMesurements)); }