Exemplo n.º 1
0
	public function actionStudentcertificate()
	{
	  $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);
      	   $studentdocstrans = new StudentDocsTrans;
	   $stud_qua = new StudentAcademicRecordTrans;
	   $stud_feed = new FeedbackDetailsTable;
	   $studentcertificate=new StudentCertificateDetailsTable('Studentsearch');
	   $parent = new ParentLogin;
	   $studentcertificate->unsetAttributes();  // clear any default values
		if(isset($_GET['StudentCertificateDetailsTable']))
			$studentcertificate->attributes=$_GET['StudentCertificateDetailsTable'];

		 $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
		));
	}	
		if($address->student_address_p_state != 0)
		   $pstat = "<b>".State::model()->findByPk($address->student_address_p_state)->state_name."</b>";	
	}
	$ac_pid = $trans->student_academic_term_period_tran_id;	
	$arch = StudentArchiveTable::model()->find(array('condition'=>'student_archive_stud_tran_id='.$trans->student_transaction_id, 'order'=>'student_archive_ac_t_p_id desc'));
	if($arch)
		$ac_pid = $arch->student_archive_ac_t_p_id;
	$year = AcademicTermPeriod::model()->findByPk($ac_pid)->academic_term_period;
	$ref_no = "";
	if(Yii::app()->controller->action->id=="certiview")
	{
		$certi= StudentCertificateDetailsTable::model()->find(array('condition'=>' 	student_certificate_details_table_student_id='.$trans->student_transaction_id.' and student_certificate_type_id='.$certificate_type,'order'=>'student_certificate_details_table_id desc'));
		$ref_no = $certi->certificate_reference_number;
	}		
	else{
	$certi = StudentCertificateDetailsTable::model()->find(array('order'=>'student_certificate_details_table_id desc'));
	$autonum = 0;
	if(!empty($certi) && $certi->certificate_reference_number!=""){
	$arr = explode('/',$certi->certificate_reference_number);
	$autonum = $arr[3];
	}
	$autonum +=1;
	$ref_no = $year."/".$branch_model->branch_code."/".date('Y').'/'.$autonum;
	}
	$quota = "<b>".Quota::model()->findByPk($trans->student_transaction_quota_id)->quota_name."</b>";
	$content = Certificate::model()->findByPk($model->certificatetype)->certificate_content;
	
	$content = str_replace('{title}',$titl,$content);
	$content = str_replace('{name}',$name,$content);
	$content = str_replace('{branch}',$branch,$content);
	$content = str_replace('{sem}',$sem,$content);	
		   $stat = "<b>".State::model()->findByPk($address->student_address_c_state)->state_name."</b>";		
		$padd = "<b>".$address->student_address_p_line1.",".$address->student_address_p_line2."</b>";
		if($address->student_address_p_city != 0)
		   $pct = "<b>".City::model()->findByPk($address->student_address_p_city)->city_name."</b>";	
		if($address->student_address_p_state != 0)
		   $pstat = "<b>".State::model()->findByPk($address->student_address_p_state)->state_name."</b>";	
	}
	
	$ref_no = "";
	if(Yii::app()->controller->action->id=="certiview")
	{
		$certi= StudentCertificateDetailsTable::model()->find(array('condition'=>' 	student_certificate_details_table_student_id='.$trans->student_transaction_id.' and student_certificate_type_id='.$certificate_type,'order'=>'student_certificate_details_table_id desc'));
		$ref_no = $certi->certificate_reference_number;
	}		
	else{
	$certi = StudentCertificateDetailsTable::model()->find(array('condition'=>'student_certificate_org_id='.Yii::app()->user->getState('org_id'),'order'=>'student_certificate_details_table_id desc'));
	$autonum = 0;
	if(!empty($certi) && $certi->certificate_reference_number!=""){
	$arr = explode('/',$certi->certificate_reference_number);
	$autonum = $arr[3];
	}
	$autonum +=1;
	$ref_no = $year."/".$branch_model->branch_code."/".date('Y').'/'.$autonum;
	}
	$content = Certificate::model()->findByPk($certificate_type)->certificate_content;
	
	$content = str_replace('{title}',$titl,$content);
	$content = str_replace('{name}',$name,$content);
	$content = str_replace('{gender}',$gender,$content);
	$content = str_replace('{smobile}',$smobile,$content);
	$content = str_replace('{pmobile}',$pmobile,$content);
	/**
	 * 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=StudentCertificateDetailsTable::model()->findByPk($id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}
	public function actionStudentcertificate()
	{
	   $model=$this->loadModel($_REQUEST['id']);
	   $user = User::model()->findByPk($model->student_transaction_user_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);
      	   $studentdocstrans = new StudentDocsTrans;
	   $stud_qua = new StudentAcademicRecordTrans;
	   $stud_feed = new FeedbackDetailsTable;
	   $studentcertificate=new StudentCertificateDetailsTable('Studentsearch');
	   $parent = '';
	   $yearModel=new Year;
	   $year=Year::model()->findByPk($model->student_transaction_batch_year);
	   if(isset(Yii::app()->modules['parents']))
	   $parent = new ParentLogin;
		
		$studentcertificate->unsetAttributes();  // clear any default values
		if(isset($_GET['StudentCertificateDetailsTable']))
			$studentcertificate->attributes=$_GET['StudentCertificateDetailsTable'];

		 $this->render('update',array(
			'model'=>$model,'info'=>$info,'photo'=>$photo,'address'=>$address,'user'=>$user,'lang'=>$lang,'studentdocstrans'=>$studentdocstrans, 'stud_qua'=>$stud_qua,'stud_feed'=>$stud_feed,'flag'=>0,'studentcertificate'=>$studentcertificate,'parent'=>$parent,'yearModel'=>$yearModel,'year'=>$year
		));
	}	
 public function actionSaveStudentCertificatedata()
 {
     $student_certificate = new StudentCertificateDetailsTable();
     $student_transaction_id = $_REQUEST['stid'];
     $semData = StudentTransaction::model()->findByPk($_REQUEST['stid'])->student_academic_term_name_id;
     $ctype = $_REQUEST['ctype'];
     $student_certificate->student_certificate_details_table_student_id = $student_transaction_id;
     $student_certificate->student_semester_id = $semData;
     $student_certificate->student_certificate_type_id = $ctype;
     $student_certificate->student_certificate_creation_date = new CDbExpression('NOW()');
     $student_certificate->student_certificate_created_by = Yii::app()->user->id;
     $student_certificate->save(false);
     $this->redirect(array('student/studentCertificateDetailsTable/admin'));
 }