$user = User::model()->findByPk(Yii::app()->user->id)->user_type; if ($user == 'admin') { $username = '******'; } else { if ($user == 'student') { $username = StudentInfo::model()->findByPk(StudentTransaction::model()->findByAttributes(array('student_transaction_user_id' => Yii::app()->user->id))->student_transaction_student_id)->student_first_name; } else { $username = EmployeeInfo::model()->findByPk(EmployeeTransaction::model()->findByAttributes(array('employee_transaction_user_id' => Yii::app()->user->id))->employee_transaction_employee_id)->employee_first_name; } } ?> <a data-close-others="true" data-hover="dropdown" data-toggle="dropdown" class="dropdown-toggle" href="#"> <?php $checkUser = StudentTransaction::model()->findByAttributes(array('student_transaction_user_id' => Yii::app()->user->id)); if ($checkUser) { $avtar = StudentPhotos::model()->findByPk($checkUser->student_transaction_student_photos_id)->student_photos_path; echo CHtml::image(Yii::app()->baseUrl . '/college_data/stud_images/' . $avtar, 'Student', array('height' => 29, 'width' => '29')); } else { $checkUser = EmployeeTransaction::model()->findByAttributes(array('employee_transaction_user_id' => Yii::app()->user->id)); if ($checkUser) { $avtar = EmployeePhotos::model()->findByPk($checkUser->employee_transaction_emp_photos_id)->employee_photos_path; echo CHtml::image(Yii::app()->baseUrl . '/college_data/emp_images/' . $avtar, 'Student', array('height' => 29, 'width' => '29')); } else { echo '<img src="' . Yii::app()->baseUrl . '/images/no_image_icon.jpg" alt="" height=29 width=29>'; } } ?> <span class="username"><?php echo $username; ?>
$StudentAddress = StudentAddress::model()->findByPk($student_transaction[0]->student_transaction_student_address_id); else $StudentAddress = new StudentAddress; if($student_transaction[0]->student_transaction_parent_id != null || $student_transaction[0]->student_transaction_parent_id != 0) $parent = ParentLogin::model()->findByPk($student_transaction[0]->student_transaction_parent_id); else $parent = new ParentLogin; ?> <h3 class="title">Student Detail</h3> <table class="no_border"> <tr> <td rowspan='4' width="135px" align="center" style="border:1px solid #74b9f0;"> <img src="college_data/stud_images/<?php echo StudentPhotos::model()->findBypk($student_transaction[0]->student_transaction_student_photos_id)->student_photos_path; ?>" height="147px" width="129px" class="photo" /> </td> <td class="label" style="border:1.5px solid white;"><b>Name</b></td><td><?php echo $StudentInfo->title." ". $StudentInfo->student_first_name." ".$StudentInfo->student_middle_name." ".$StudentInfo->student_last_name;?></td> </tr> <tr style="background:none"> <td class="label" style = "border:1.5px solid white;width:18%;"><b>Student Unique ID<b></td><td><?php echo $StudentInfo->student_roll_no;?></td> </tr> <tr> <td class="label" style="border:1.5px solid white;"><b>Student Email<b></td><td><?php echo $StudentInfo->student_email_id_1;?></td> </tr> <tr style="background:none"> <td class="label" style="border:1.5px solid white;"><b>Course</b></td><td><?php echo $Course->course_name;?> </tr>
{ $trans = StudentTransaction::model()->findByPk($stud_info->student_info_transaction_id); $titl = "<b>".$stud_info->title."</b>"; $name = "<b>".$stud_info->student_first_name." ".$stud_info->student_middle_name." ".$stud_info->student_last_name."</b>"; $smobile = "<b>".$stud_info->student_mobile_no."</b>"; $pmobile = "<b>".$stud_info->student_guardian_mobile."</b>"; $branch_model=Branch::model()->findByPk($trans->student_transaction_branch_id); $en_no = "<b>".$stud_info->student_enroll_no."</b>"; $branch = "<b>".$branch_model->branch_name."</b>"; $sem = "<b>Sem-".AcademicTerm::model()->findByPk($trans->student_academic_term_name_id)->academic_term_name."</b>"; if($trans->student_transaction_division_id != 0) $div = "<b>".Division::model()->findByPk($trans->student_transaction_division_id)->division_name."</b>"; else $div = '-'; $photos=StudentPhotos::model()->findByPk($trans->student_transaction_student_photos_id)->student_photos_path; $photo=CHtml::image(Yii::app()->request->baseUrl.'/college_data/stud_images/'.$photos,'image',array('width'=>120,'height'=>140,'class'=>'photo','style'=>'padding-right:0px;','border'=>1)); $gender = "<b>".$stud_info->student_gender."</b>"; $cdate = "<b>".date('d/m/Y')."</b>"; if($trans->student_transaction_category_id !=0) $category = "<b>".Category::model()->findByPk($trans->student_transaction_category_id)->category_name."</b>"; else $category = "<b>not set</b>"; $lin1 = "<b>not set</b>"; $lin2 = "<b>not set</b>"; $ct = "<b>not set</b>"; $stat = "<b>not set</b>"; $pc = "<b>not set</b>"; $padd = "<b>not set</b>"; $pct = "<b>not set</b>"; $pstat = "<b>not set</b>";
<?php $gobackimage = CHtml::image('../images/Goback.png', 'No Image', array('height' => '40', 'width' => 40)); echo CHtml::link('GO BACK', Yii::app()->createUrl('report/Studentid'), array('title' => 'Go Back')) . " "; ?> <button style="float:right; margin-right:50%;" onclick="javascript:window.print()" id="printid">Print</button> </div></br></br> <?php $org_id = Yii::app()->user->getState('org_id'); $org_data = Organization::model()->findByAttributes(array('organization_id' => $org_id)); $orgcity = City::model()->findByPk($org_data->city)->city_name; $orgstate = State::model()->findByPk($org_data->state)->state_name; $i = 0; if ($student_data1 && $selected_list) { foreach ($student_data1 as $stud) { $orglogo = CHtml::image(Yii::app()->controller->createUrl('/site/loadImage', array('id' => Yii::app()->user->getState('org_id'))), 'No Image', array('width' => 65, 'height' => 65)); $studphoto = StudentPhotos::model()->findByPk($stud['student_transaction_student_photos_id'])->student_photos_path; ?> <div class="outer"> <!--main div--> <div class="main"> <!--Header div--> <div class="idcardheader"> <div class="logo"> <?php echo $orglogo; ?> </div> <div class="collegeheader"> <h3 class="org_name"><?php echo $org_data->organization_name; ?>
<div class="profile-details"> <div class="profile-pic"> <?php $stdId = StudentTransaction::model()->findByPk(Yii::app()->user->getState('stud_id')); $pic = StudentPhotos::model()->findByPk($stdId->student_transaction_student_photos_id)->student_photos_path; echo CHtml::image(Yii::app()->baseUrl.'/college_data/stud_images/'.$pic); ?> </div> <div class="profile-link"> <ul class="links"> <li><?php echo CHtml::link('Performance', array('/student/feedbackDetailsTable/studentPerformance','id'=>$stdId->student_transaction_id)); ?></li> <li><?php echo CHtml::link('Subject', array('/report/mysubjects','id'=>$stdId->student_transaction_id)); ?></li> <li><?php echo CHtml::link('Holidays', array('/report/myholidays','id'=>$stdId->student_transaction_id)); ?></li> <li><?php echo CHtml::link('Student History', array('/report/studenthistory','id'=>$stdId->student_transaction_id)); ?></li> <li class="last-row"><?php echo CHtml::link('Exam Timetable', array('/exam/branchSubjectwiseScheduling/studentexamtimetable','id'=>$stdId->student_transaction_id)); ?></li> <li class="last-row"><?php echo CHtml::link('Assignment', array('/assignment/assignment/studAssignments','id'=>$stdId->student_transaction_id)); ?></li> </ul> </div> </div>
/** * 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) { // we only allow deletion via POST request $model = $this->loadModel($id); $student_info = StudentInfo::model()->findByPk($model->student_transaction_student_id); if ($model->student_transaction_student_address_id != null) { $address = StudentAddress::model()->findByPk($model->student_transaction_student_address_id); } $stud_photo = StudentPhotos::model()->findByPk($model->student_transaction_student_photos_id); if ($model->student_transaction_languages_known_id != null) { $lang_known = LanguagesKnown::model()->findByPk($model->student_transaction_languages_known_id); } $dir1 = Yii::getPathOfAlias('webroot') . '/college_data/stud_images/'; if ($dh = opendir($dir1)) { if ($stud_photo->student_photos_path == "no-images") { } else { if (file_exists($dir1 . $stud_photo->student_photos_path)) { //chmod($dir1.$stud_photo->student_photos_path, 777); unlink($dir1 . $stud_photo->student_photos_path); } } } closedir($dh); if ($this->loadModel($id)->delete()) { $use_model = User::model()->findByPk($model->student_transaction_user_id)->delete(); $stud_photo->delete(); $student_info->delete(); if ($model->student_transaction_student_address_id != null) { $address->delete(); } if ($model->student_transaction_languages_known_id != null) { $lang_known->delete(); } StudentPaidFeesDetails::model()->deleteAll("student_paid_student_id = :studId", array(':studId' => $id)); StudentAcademicRecordTrans::model()->deleteAll("student_academic_record_trans_stud_id = :studId", array(':studId' => $id)); StudentDocsTrans::model()->deleteAll("student_docs_trans_user_id = :studId", array(':studId' => $id)); } 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.'); } }
{ $count = 0; $count = Mailbox::model()->newMsgs(Yii::app()->user->id); ?> <li><a href="<?php echo Yii::app()->baseUrl;?>/mailbox" class="nav-link green"><i class="fa fa-envelope"></i> <span class="nav-counter nav-counter-blue"><?php echo $count;?></span></a></li> <?php }?> <li><a href="#" class="nav-link orange"><i class="fa fa-tasks"></i> <span class="nav-counter nav-counter-green">15</span></a></li> <?php $isStudent = Yii::app()->user->getState('stud_id'); $isEmployee = Yii::app()->user->getState('emp_id'); if(isset($isStudent)) { $stdinfo = StudentInfo::model()->findByAttributes(array('student_info_transaction_id'=>Yii::app()->user->getState('stud_id'))); $stu_tran = StudentTransaction::model()->findByPk(Yii::app()->user->getState('stud_id')); $stdpicPath = StudentPhotos::model()->findByPk($stu_tran->student_transaction_student_photos_id); $stud_photo=Yii::app()->baseUrl."/college_data/stud_images/".$stdpicPath->student_photos_path; ?> <li><a href="#" class="nav-link user-image-nav"><img src="<?php echo $stud_photo; ?>" width="51" height="51" class="userimage"></a></li> <li class="user-image-line" id="dropdown"><a href="#" class="nav-link"> <?php echo $stdinfo->student_first_name; ?> <i class="fa fa-caret-down"></i></a> <ul> <li><a href="<?php echo Yii::app()->baseUrl;?>/student/studentTransaction/update?id=<?php echo Yii::app()->user->getState('stud_id');?>">My Profile</a></li> <li><a href="<?php echo Yii::app()->baseUrl;?>/user/change"">Change Password</a></li> <li><a href="<?php echo Yii::app()->baseUrl;?>/mailbox">My Inbox</a></li> <li><?php echo CHtml::link('Log Out', Yii::app()->baseUrl.'/site/logout')?></li> </ul> </li>
public function actionStudentperformance() { $id = Yii::app()->user->getState('stud_id'); $model=StudentTransaction::model()->findByPk($id); $info = StudentInfo::model()->findByPk($model->student_transaction_student_id); $address = StudentAddress::model()->findByPk($model->student_transaction_student_address_id); $photo = StudentPhotos::model()->findByPk($model->student_transaction_student_photos_id); $lang = LanguagesKnown::model()->findByPk($model->student_transaction_languages_known_id); $stud_qua = new StudentAcademicRecordTrans; $stud_feed = new FeedbackDetailsTable; $studentcertificate=new StudentCertificateDetailsTable; $studentdocstrans=new StudentDocsTrans; $stud_qua=new StudentAcademicRecordTrans; $stud_feed=new FeedbackDetailsTable('mysearch'); $parent = new ParentLogin; $stud_feed->unsetAttributes(); // clear any default values if(isset($_GET['FeedbackDetailsTable'])) $stud_feed->attributes=$_GET['FeedbackDetailsTable']; $this->render('update',array( 'model'=>$model,'info'=>$info,'photo'=>$photo,'address'=>$address,'lang'=>$lang,'studentdocstrans'=>$studentdocstrans, 'stud_qua'=>$stud_qua,'stud_feed'=>$stud_feed,'flag'=>0,'studentcertificate'=>$studentcertificate,'parent'=>$parent )); }
<?php if(Yii::app()->user->getState('stud_id')) { $studentmodel = StudentTransaction::model()->find('student_transaction_id='.Yii::app()->user->getState('stud_id')); $photo = StudentPhotos::model()->findByPk($studentmodel->student_transaction_student_photos_id); ?> <div id="menulink"> <div id="studentlogo"> <?php if($photo->student_photos_path != null) echo CHtml::link(CHtml::image(Yii::app()->baseUrl.'/college_data/stud_images/'.$photo->student_photos_path,"",array("width"=>"176px","height"=>"178px")),array('/college_data/stud_images/'.$photo->student_photos_path),array('id'=>'photo')); /* $config = array( 'scrolling' => 'no', 'autoDimensions' => false, 'width' => 'auto', 'height' => 'auto', // 'titleShow' => false, 'overlayColor' => '#000', 'padding' => '0', 'showCloseButton' => true, 'onClose' => function() { return window.location.reload(); }, // change this as you need ); $this->widget('application.extensions.fancybox.EFancyBox', array('target'=>'#photo', 'config'=>$config));*/ ?> </div> <?php //end of student logo div?> </br>
public function loadReadNotice() { $res = array(); $emp_trans = EmployeeTransaction::model()->findAll(array('select'=>'employee_transaction_user_id')); $s=0; if($emp_trans) { $d = CHtml::listData($emp_trans,'employee_transaction_user_id','employee_transaction_user_id'); $s = implode(',',$d); } $list = EmployeeNotification::model()->findAll(array('limit'=>10,'order'=>'id desc','condition'=>'emp_notice_to = :to AND alert_after_date <= :afterdate AND alert_before_date >= :beforedate and t.from IN('.$s.')', 'params'=> array(':to' => Yii::app()->user->getState('emp_id'), ':afterdate'=>date('Y-m-d'),':beforedate'=>date('Y-m-d')))); $menu = null; foreach($list as $notice) { $usertype=User::model()->findByPk($notice->from)->user_type; $menu .= '<div class="notify-data">'; if($usertype=="employee") { $tran=EmployeeTransaction::model()->findByAttributes(array('employee_transaction_user_id'=>$notice->from)); $emp_model = EmployeeInfo::model()->findByAttributes(array('employee_info_transaction_id'=>$tran->employee_transaction_id)); $photo=EmployeePhotos::model()->findByPk($tran['employee_transaction_emp_photos_id']); $menu .= '<span class="userimage">'; if(file_exists(Yii::app()->baseUrl.'/college_data/emp_images/'.$photo->employee_photos_path)) $user_image = Yii::app()->baseUrl.'/college_data/emp_images/'.$photo->employee_photos_path; else $user_image = Yii::app()->baseUrl.'/college_data/emp_images/no-images'; $menu .= CHtml::image($user_image,"No Image",array("width"=>"50px","height"=>"50px")); $menu .='</span><span class="username">'; $menu .= ucfirst(strtolower($emp_model->employee_first_name)).' '.ucfirst(strtolower($emp_model->employee_last_name)).'</span>'; } else { $tran=StudentTransaction::model()->findByAttributes(array('student_transaction_user_id'=>$notice->from)); $stud_model = StudentInfo::model()->findByAttributes(array('student_info_transaction_id'=>$tran->student_transaction_id)); $photo=StudentPhotos::model()->findByPk($tran['student_transaction_student_photos_id']); $menu .= '<span class="userimage">'; if(file_exists(Yii::app()->baseUrl.'/college_data/stud_images/'.$photo->student_photos_path)) $user_image = Yii::app()->baseUrl.'/college_data/stud_images/'.$photo->student_photos_path; else $user_image = Yii::app()->baseUrl.'/college_data/emp_images/no-images'; $menu .= CHtml::image($user_image,"No Image",array("width"=>"50px","height"=>"50px")); $menu .='</span><span class="username">'; $menu .= ucfirst(strtolower($stud_model->student_first_name))." ".ucfirst(strtolower($stud_model->student_last_name))." (".$stud_model->student_enroll_no.")</span>"; } $menu .='<div class="notificationlink">'; $menu .='<a href='.Yii::app()->request->baseUrl.'/notification/employeeNotification/Read?id='.$notice->id.'>'; $menu .=$notice->title.'</a></div></div>'; } if(!empty($list)) $menu .='<span class="view-more-notice">'.CHtml::link('View More..','../notification/employeeNotification/index').'</span>'; return $menu; }
<div class="row_photo_v"> <?php //echo CHtml::image(Yii::app()->baseUrl.'/stud_images/' . $model->Rel_Photos->student_photos_path); ?> <?php $photoid = StudentTransaction::model()->findByPk($model->student_archive_stud_tran_id)->student_transaction_student_photos_id; echo CHtml::image(Yii::app()->baseUrl . '/stud_images/' . StudentPhotos::model()->findByPk($photoid)->student_photos_path); ?> </div> <!--<div class = "row_all_a"> <div class="row_t_v"> <?php echo '<lable><b>ID :</b></lable>'; ?> <div class="rowm"> <?php echo $model->student_archive_stud_tran_id . '<br>'; ?> </div> </div> </div> --> <div class = "row_all"> <div class="row_t_v"> <?php echo '<lable><b>Roll No :</b></lable>'; ?> <div class="rowm">
/** Delete Photo of update profile*/ public function actionPhotoDelete($id) { $model = $this->loadModel($id); $stud_photo = StudentPhotos::model()->findByPk($model->student_transaction_student_photos_id); $dir1 = Yii::getPathOfAlias('webroot').'/college_data/stud_images/'; if($dh = opendir($dir1)) { if($stud_photo->student_photos_path == "no-images") { } else { if(file_exists($dir1.$stud_photo->student_photos_path)) { //chmod($dir1.$stud_photo->student_photos_path, 777); unlink($dir1.$stud_photo->student_photos_path); //$stud_photo->delete(); $stud_photo->student_photos_path = "no-images"; $stud_photo->save(); } else { $stud_photo->student_photos_path = "no-images"; $stud_photo->save(); } } } closedir($dh); $this->redirect(array('studentTransaction/update','id'=>$model->student_transaction_id)); }
public function actionAprove($id) { $model= StudentRegistrationInfo::model()->findByPk($id); $info = new StudentInfo; $stud_trans = new StudentTransaction; $user =new User; $photo =new StudentPhotos; $address=new StudentAddress; $lang=new LanguagesKnown; $ass_comp = new assignCompanyUserTable; $auth_assign = new AuthAssignment; $qualification=new StudentAcademicRecordTrans; if(isset($_REQUEST['StudentRegistrationInfo'])) { $org_id = $model->organization_id; if($model->student_status==1){ $acd = Yii::app()->db->createCommand() ->select("academic_term_id,academic_term_name,academic_term_period_id") ->from('academic_term') ->where('current_sem=1 and academic_term_name =1 and academic_term_organization_id='.$org_id) ->queryAll(); if(!$acd){ Yii::app()->user->setFlash('notice','Semester-1 is not an Active semester'); $this->redirect(array('admin')); } $info->student_dtod_regular_status = 'Regular'; } elseif($model->student_status==2){ $acd = Yii::app()->db->createCommand() ->select("academic_term_id,academic_term_name,academic_term_period_id") ->from('academic_term') ->where('current_sem=1 and academic_term_name =3 and academic_term_organization_id='.$org_id) ->queryAll(); if(!$acd){ Yii::app()->user->setFlash('notice','Semester-3 is not an Active semester'); $this->redirect(array('admin')); } $info->student_dtod_regular_status = 'DTOD'; } $info->title = $model->student_title; $info->student_merit_no = $model->student_merit_no; $info->student_first_name = $model->student_first_name; $info->student_middle_name =$model->student_middle_name; $info->student_last_name = $model->student_last_name; $info->student_father_name = $model->student_father_name; $info->student_mother_name = $model->student_mother_name; $info->student_dob = $model->student_dob; $info->student_adm_date = new CDbExpression('NOW()'); $info->student_birthplace = $model->student_place_of_birth; $info->student_gender = $model->student_gender; $info->student_email_id_1 = $model->student_email_id; $info->student_mobile_no = $model->student_mobile; $info->student_created_by = Yii::app()->user->id; $info->student_creation_date = new CDbExpression('NOW()'); $user->user_organization_email_id = strtolower($info->student_email_id_1); $user->user_password = md5($info->student_email_id_1.$info->student_email_id_1); $user->user_created_by = Yii::app()->user->id; $user->user_creation_date = new CDbExpression('NOW()'); $user->user_organization_id = $org_id; $user->user_type = "student"; $photo->student_photos_path = $model->student_photo; $address->student_address_c_line1 = $model->student_address_c_line1; $address->student_address_c_line2 = $model->student_address_c_line2; $address->student_address_c_taluka = $model->student_address_c_taluka; $address->student_address_c_district = $model->student_address_c_district; $address->student_address_c_country = $model->student_address_c_country; $address->student_address_c_city = $model->student_address_c_city; $address->student_address_c_pin = $model->student_address_c_pin ; $address->student_address_c_state = $model->student_address_c_state; $address->student_address_p_line1 = $model->student_address_p_line1; $address->student_address_p_line2 = $model->student_address_p_line2; $address->student_address_p_taluka = $model->student_address_p_taluka; $address->student_address_p_district = $model->student_address_p_district; $address->student_address_p_country = $model->student_address_p_country; $address->student_address_p_city = $model->student_address_p_city; $address->student_address_p_pin = $model->student_address_p_pin ; $address->student_address_p_state = $model->student_address_p_state; $address->student_address_phone = $model->student_phoneno; $address->student_address_mobile = $model->student_mobile; if($info->save(false)){ $user->save(false); $photo->save(false); $address->save(false); $lang->save(false); $stud_trans->student_transaction_user_id = $user->user_id; $stud_trans->student_transaction_student_id = $info->student_id; //$stud_trans->student_transaction_branch_id = $model->student_branch_id; if(!empty($model->student_category_id)) $stud_trans->student_transaction_category_id = $model->student_category_id; $stud_trans->student_transaction_organization_id = $org_id; $stud_trans->student_transaction_student_address_id = $address->student_address_id; $stud_trans->student_transaction_languages_known_id= $lang->languages_known_id; $stud_trans->student_transaction_detain_student_flag='5'; $stud_trans->student_transaction_student_photos_id = $photo->student_photos_id; $stud_trans->student_transaction_branch_id=$_POST['StudentRegistrationInfo']['student_branch_id']; $stud_trans->student_academic_term_period_tran_id = $acd[0]['academic_term_period_id']; $stud_trans->student_academic_term_name_id = $acd[0]['academic_term_id']; $stud_trans->save(false); StudentInfo::model()->updateByPk($stud_trans->student_transaction_student_id, array('student_info_transaction_id'=>$stud_trans->student_transaction_id)); $org_data = Organization::model()->findByPk($org_id); $org_name = $org_data->organization_name; $org_arr = explode(' ',$org_name); $suffix_lab = ''; foreach($org_arr as $list) $suffix_lab .= $list[0]; $bizrule = 'return Yii::app()->user->getState("org_id")=='.$org_id.";"; $var_data = serialize(Yii::app()->user->getState('org_id')); $auth_assign->itemname = 'Student of '.$suffix_lab; $auth_assign->userid = $user->user_id; $auth_assign->bizrule = $bizrule; $auth_assign->data = $var_data; $auth_assign->save(); $ass_comp->assign_user_id = $user->user_id; $ass_comp->assign_org_id = $org_id; $ass_comp->assign_created_by = Yii::app()->user->id; $ass_comp->assign_creation_date = new CDbExpression('NOW()'); $ass_comp->save(); StudentRegistrationInfo::model()->updateByPk($id, array( 'student_aproved'=>'1', )); $this->redirect(array('admin')); } } $this->render('aprove',array('model'=>$model)); }
/** * 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 = StudentPhotos::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }