public function actionFinal_view($id)
 {
     $emp_doc = new EmployeeDocsTrans('mysearch');
     $emp_doc->unsetAttributes();
     // clear any default values
     if (isset($_GET['EmployeeDocsTrans'])) {
         $emp_doc->attributes = $_GET['EmployeeDocsTrans'];
     }
     $emp_exp = new EmployeeExperienceTrans('mysearch');
     $emp_exp->unsetAttributes();
     // clear any default values
     if (isset($_GET['EmployeeExperienceTrans'])) {
         $emp_exp->attributes = $_GET['EmployeeDocsTrans'];
     }
     $emp_record = new EmployeeAcademicRecordTrans('mysearch');
     $emp_record->unsetAttributes();
     // clear any default values
     if (isset($_GET['EmployeeAcademicRecordTrans'])) {
         $emp_record->attributes = $_GET['EmployeeAcademicRecordTrans'];
     }
     $this->render('final_view', array('model' => $this->loadModel($id), 'emp_doc' => $emp_doc, 'emp_exp' => $emp_exp, 'emp_record' => $emp_record));
 }
 public function actionEmployeeFinalViewExportToPdf($id)
 {
     $employee_transaction = EmployeeTransaction::model()->findAll(' 	employee_transaction_id=' . $id);
     $employee_docs = EmployeeDocsTrans::model()->findAll('employee_docs_trans_user_id=' . $id);
     $employee_qual = EmployeeAcademicRecordTrans::model()->findAll('employee_academic_record_trans_user_id=' . $id);
     $employee_exp = EmployeeExperienceTrans::model()->findAll('employee_experience_trans_user_id=' . $id);
     $html = $this->renderPartial('/employeeTransaction/employeeFinalView', array('employee_docs' => $employee_docs, 'employee_qual' => $employee_qual, 'employee_transaction' => $employee_transaction, 'emp_exp' => $employee_exp), true);
     $this->exporttopdf('Employee Report', 'Employee.pdf', $html);
 }
 /**
  * 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
         $this->loadModel($id)->delete();
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_GET['ajax'])) {
             $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
         }
     } else {
         if (!Yii::app()->request->isPostRequest) {
             $emp_academic_record = EmployeeAcademicRecordTrans::model()->findAll(array('condition' => 'employee_academic_record_trans_eduboard_id=' . $id));
             $stud_academic_record = StudentAcademicRecordTrans::model()->findAll(array('condition' => 'student_academic_record_trans_eduboard_id=' . $id));
             if (!empty($emp_academic_record) || !empty($stud_academic_record)) {
                 throw new CHttpException(400, 'You can not delete this record because it is used in another table.');
             } else {
                 $this->loadModel($id)->delete();
                 $this->redirect(array('admin'));
             }
         } else {
             throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
         }
     }
 }
 /**
  * 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 = EmployeeAcademicRecordTrans::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
	public function actionEmployeeFinalViewExportToPdf($id)
	{
		$employee_transaction = EmployeeTransaction::model()->findAll('employee_transaction_id='.$id);
		$employee_docs = EmployeeDocsTrans::model()->findAll('employee_docs_trans_user_id='.$id);
		$employee_qual = EmployeeAcademicRecordTrans::model()->findAll('employee_academic_record_trans_user_id='.$id);
		$employee_exp = EmployeeExperienceTrans::model()->findAll('employee_experience_trans_user_id='.$id);

		$html = $this->renderPartial('/employeeTransaction/employeeFinalView', array(
		    'employee_docs'=>$employee_docs,
		    'employee_qual'=>$employee_qual,
		    'employee_transaction'=>$employee_transaction,
		    'emp_exp'=>$employee_exp,
		), true);
		
		
		ob_clean();
		//$pdf = new TCPDF();
		//$pdf->SetCreator(PDF_CREATOR);
		//$pdf->SetAuthor(Yii::app()->name);
		//$pdf->SetTitle($title);
		//$pdf->SetSubject($title);
		//$pdf->SetKeywords('example, text, report');
		//$pdf->SetHeaderData('', 0, $title, '');
		//$pdf->setHeaderFont(Array('helvetica', '', 8));
		//$pdf->setFooterFont(Array('helvetica', '', 6));
		//$pdf->SetMargins(15, 18, 15);
		//$pdf->SetHeaderMargin(5);
		//$pdf->SetFooterMargin(10);
		//$pdf->SetAutoPageBreak(TRUE, 15);
		//$pdf->SetFont('dejavusans', '', 7);
		//$resolution= array(150, 150);
		//$pdf->AddPage('P', $resolution);
		$html = '<style> table, th, td { border : 1px solid #000;} th {text-align: center;}</style>'.$html;
		//$pdf->writeHTML($html, true, false, true, false, '');
		//$pdf->LastPage();
		//$pdf->Output($filename, "I");
	  
		$this->exporttopdf('Employee Report','Employee.pdf',$html);	              
	}
	/**
	* This action is used to display the employee academic records in the employee profile.
	*/
	public function actionEmployeeAcademicRecords()
	{
		$emp_record=new EmployeeAcademicRecordTrans('mysearch');
		$model=EmployeeTransaction::model()->resetScope()->findByPk($_REQUEST['id']);
		$info = EmployeeInfo::model()->findByPk($model->employee_transaction_employee_id);
		$photo = EmployeePhotos::model()->findByPk($model->employee_transaction_emp_photos_id);
		$lang = LanguagesKnown::model()->findByPk($model->employee_transaction_languages_known_id);

		$emp_doc = new EmployeeDocsTrans;
		$emp_exp = new EmployeeExperienceTrans;
		$emp_certificate = new EmployeeCertificateDetailsTable;
		$address = EmployeeAddress::model()->findByPk($model->employee_transaction_emp_address_id);
		
		$emp_record->unsetAttributes();  // clear any default values
		if(isset($_GET['EmployeeAcademicRecordTrans']))
			$emp_record->attributes=$_GET['EmployeeAcademicRecordTrans'];

		$this->render('update',array(
			'model'=>$model,'info'=>$info,'photo'=>$photo,'address'=>$address,'lang'=>$lang,'emp_doc'=>$emp_doc,'emp_record'=>$emp_record,'emp_exp'=>$emp_exp,'flag'=>1,'emp_certificate'=>$emp_certificate
		));
	}
 public function actionDelete($id)
 {
     if (Yii::app()->request->isPostRequest) {
         // we only allow deletion via POST request
         $model = $this->loadModel($id);
         $employee_info = EmployeeInfo::model()->findByPk($model->employee_transaction_employee_id);
         if ($model->employee_transaction_emp_address_id != null) {
             $address = EmployeeAddress::model()->findByPk($model->employee_transaction_emp_address_id);
         }
         $emp_photo = EmployeePhotos::model()->findByPk($model->employee_transaction_emp_photos_id);
         if ($model->employee_transaction_languages_known_id != null) {
             $lang_known = LanguagesKnown::model()->findByPk($model->employee_transaction_languages_known_id);
         }
         //$assign_comp_model = assignCompanyUserTable::model()->findByPk($ass_comp->id);
         $dir1 = Yii::getPathOfAlias('webroot') . '/college_data/emp_images/';
         if ($dh = opendir($dir1)) {
             if ($emp_photo->employee_photos_path == "no-images") {
             } else {
                 if (file_exists($dir1 . $emp_photo->employee_photos_path)) {
                     chmod($dir1 . $emp_photo->employee_photos_path, 777);
                     unlink($dir1 . $emp_photo->employee_photos_path);
                 }
             }
         }
         closedir($dh);
         if ($this->loadModel($id)->delete()) {
             $use_model = User::model()->findByPk($model->employee_transaction_user_id)->delete();
             $emp_photo->delete();
             $employee_info->delete();
             if ($model->employee_transaction_emp_address_id != null) {
                 $address->delete();
             }
             if ($model->employee_transaction_languages_known_id != null) {
                 $lang_known->delete();
             }
             EmployeeAcademicRecordTrans::model()->deleteAll(" \temployee_academic_record_trans_user_id= :empId", array(':empId' => $id));
             EmployeeDocsTrans::model()->deleteAll("employee_docs_trans_user_id = :empId", array(':empId' => $id));
         }
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         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.');
     }
 }