Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- Yii::import('application.extensions.BootstrapLinkPager');
- Yii::import('application.extensions.EExcelView');
- class AdmissionScheduleController extends Controller
- {
- /**
- * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
- * using two-column layout. See 'protected/views/layouts/column2.php'.
- */
- public $layout='//layouts/main';
- /**
- * @return array action filters
- */
- public function filters()
- {
- return array(
- 'accessControl', // perform access control for CRUD operations
- 'postOnly + delete', // we only allow deletion via POST request
- );
- }
- /**
- * Specifies the access control rules.
- * This method is used by the 'accessControl' filter.
- * @return array access control rules
- */
- public function accessRules()
- {
- return array(
- array('allow', // allow all users to perform 'index' and 'view' actions
- 'actions'=>array('index','view','create','update','admin','delete','processyettoprocess','processcreate','processhold','processresch','reject','processreject','enrollall','schyettoprocess','schrejected','processrejected','enrollrejected','enrollreject','exportprocessexcel','exportscheduleexcel','exportenrollexcel','createsms','postdata','processcreatesms','processrejectsms','processholdsms','smsall','processreschsms','enrollrejectsms','enrollcreate'),
- 'users'=>array('*'),
- ),
- array('deny', // deny all users
- 'users'=>array('*'),
- ),
- );
- }
- /**
- * Displays a particular model.
- * @param integer $id the ID of the model to be displayed
- */
- public function actionView($id)
- {
- $this->render('form_view',array(
- 'model'=>$this->loadModel($id),
- ));
- }
- /**
- * Creates a new model.
- * If creation is successful, the browser will be redirected to the 'view' page.
- */
- public function actionEnrollAll()
- {
- $model=new AdmissionForm('search');
- $sch_model=new AdmissionSchedule;
- $model->unsetAttributes();
- if(isset($_GET['AdmissionForm']))
- $model->attributes=$_GET['AdmissionForm'];
- if(isset($_GET['pageSize'])) {
- Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']);
- unset($_GET['pageSize']);
- }
- $this->render('enrollall',array(
- 'model'=>$model,'sch_model'=>$sch_model,));
- }
- public function actionEnrollRejected()
- {
- $model=new AdmissionForm('search');
- $sch_model=new AdmissionSchedule;
- $model->unsetAttributes();
- if(isset($_GET['AdmissionForm']))
- $model->attributes=$_GET['AdmissionForm'];
- if(isset($_GET['pageSize'])) {
- Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']);
- unset($_GET['pageSize']);
- }
- $this->render('enrollrejected',array(
- 'model'=>$model,'sch_model'=>$sch_model));
- }
- //dev by ram starts
- public function actionEnrollCreate()
- {
- $currentbatch=Yii::app()->session['currentbatch'];
- $batch_year=substr($currentbatch,-2);
- $batch_model=BatchTable::model()->findAll(array("condition"=>"batch_code='".$currentbatch."'"));
- if(count($batch_model) > 0)
- $batch=$batch_model[0]->batch_id;
- else
- $batch=1;
- $sel_students=explode(",",$_POST['selected_val']) ;
- $unique_stud=array_unique($sel_students);
- foreach ($unique_stud as $stud) {
- //admission block code
- $stu_detail=AdmissionForm::model()->findByPk($stud);
- $schedule_model=AdmissionSchedule::model()->find('admn_form_id='.$stud);
- //$schedule_model->comment = $_POST['comment'];
- $schedule_model->enroll_status =1;
- $stu_detail->admission_status = 'Selected';
- $schedule_model->save();
- $stu_detail->save();
- //student table code block
- if($stu_detail->gender == 'M')
- $gender=1;
- else if($stu_detail->gender == 'F')
- $gender=2;
- else
- $gender=3;
- if($stu_detail->admission_no == "")
- $stu_detail->admission_no=NULL;
- $stu_model=new StudentTable;
- $stu_model->admission_id=$stu_detail->admission_no;
- $stu_model->first_name=$stu_detail->first_name;
- $stu_model->last_name=$stu_detail->last_name;
- $stu_model->gender=$gender;
- $stu_model->dob=$stu_detail->date_of_birth;
- $stu_model->joining_quota=$stu_detail->quota_id;
- $stu_model->emis_number=$stu_detail->emis_no;
- $stu_model->class=$stu_detail->class_id;
- $stu_model->first_language=$stu_detail->first_lang_id;
- $stu_model->second_language=$stu_detail->sec_lang_id;
- $stu_model->profile_image=$stu_detail->profile_image;
- $stu_model->religion=$stu_detail->religion_id;
- $stu_model->bloodgroup=$stu_detail->bg_id;
- $stu_model->caste=$stu_detail->caste_id;
- $stu_model->mothertongue=$stu_detail->mother_tongue;
- $stu_model->nationality=$stu_detail->nationality_id;
- $stu_model->previous_school=$stu_detail->previous_school_name;
- $stu_model->reason_gap=$stu_detail->reason_gap;
- $stu_model->reason_change=$stu_detail->reason_change;
- $stu_model->prev_course=$stu_detail->last_class;
- $stu_model->prev_mark=$stu_detail->last_class_percentage;
- $stu_model->aadhar_card=$stu_detail->aadhar_number;
- $stu_model->physicallychallenged='N';
- $stu_model->disability_detail='NA';
- $stu_model->batch=$batch;
- $stu_model->class=$stu_detail->class_id;
- $student_records = StudentTable::model()->findAll(array("select"=>"MAX(SUBSTR(student_id, -4)) as student_number","condition"=>"student_id like '%".$batch_year."S%'","order"=>"student_number"));
- if(count($student_records) == 0) {
- $student_id=Yii::app()->session['schoolid'].$batch_year."S0001";
- }
- else {
- $last_student_id=$student_records[0]->student_number;
- if($last_student_id==""){
- $student_id=Yii::app()->session['schoolid'].$batch_year."S0001";
- }else{
- $current_student_id=(int)$last_student_id+1;
- $current_student_id=str_pad($current_student_id, 4, '0', STR_PAD_LEFT);
- $student_id=Yii::app()->session['schoolid'].$batch_year."S".$current_student_id;
- }
- }
- $stu_model->student_id=$student_id;
- $stu_model->created_by=1;
- $stu_model->lastedited_by=1;
- $stu_model->save(false);
- $stud_primary_id=$stu_model->student_table_id;//last inserted student table id
- //parent table insertion code block
- $parent_model=new ParentTable;
- $parent_records = ParentTable::model()->findAll(array("select"=>"MAX(SUBSTR(parent_id, -4)) as parent_number","condition"=>"parent_id like '%".$batch_year."P%'","order"=>"parent_number"));
- if(count($parent_records) == 0) {
- $parent_id=Yii::app()->session['schoolid'].$batch_year."P0001";
- }
- else {
- $last_parent_id=$parent_records[0]->parent_number;
- if($last_parent_id==""){
- $parent_id=Yii::app()->session['schoolid'].$batch_year."P0001";
- }else{
- $current_parent_id=(int)$last_parent_id+1;
- $current_parent_id=str_pad($current_parent_id, 4, '0', STR_PAD_LEFT);
- $parent_id=Yii::app()->session['schoolid'].$batch_year."P".$current_parent_id;
- }
- }
- $parent_model->parent_id=$parent_id;
- $parent_model->parent_name=$stu_detail->father_name;
- $parent_model->parent_name2=$stu_detail->mother_name;
- $parent_model->guardian_name=$stu_detail->guardian_name;
- $parent_model->parent_occupation=$stu_detail->occupation;
- $parent_model->annual_income=$stu_detail->annual_income;
- $parent_model->gender=1;
- $parent_model->gender2=2;
- $parent_model->mobile_no=$stu_detail->mobile_no;
- $parent_model->guardian_mobile=$stu_detail->guardian_mobile_no;
- $parent_model->email_id=$stu_detail->email_id;
- $parent_model->altemail_id=$stu_detail->email_id_alt;
- $parent_model->guardian_email=$stu_detail->guardian_email;
- $parent_model->created_by=1;
- $parent_model->lastedited_by=1;
- $parent_model->created_on=date('Y-m-d H:i:s');
- $parent_model->lastedited_on=date('Y-m-d H:i:s');
- $parent_model->save();
- $parent_primary_id=$parent_model->parent_table_id; //for fetch last inserted primary id of parent table
- //student Parent Table
- $par_stud_model=new ParentStudentTable;
- $par_stud_model->parent_id=$parent_id;
- $par_stud_model->student_id=$student_id;
- $par_stud_model->save();
- //student relation Table
- $stu_relation_model=new StudentRelation;
- $stu_relation_model->parent=$parent_primary_id;
- $stu_relation_model->student=$stud_primary_id;
- $stu_relation_model->save();
- $login_model=new LoginTable;
- $login_model->userid=$stu_model->student_id;
- $login_model->password=sha1(strToLower($stu_model->student_id));
- $login_model->mailid=$stu_model->email_id;
- $login_model->mobile_no=$stu_model->mobile_no;
- $login_model->access_id='4';
- $login_model->status='1';
- $login_model->save(false);
- $login_model=new LoginTable;
- $login_model->userid=$parent_model->parent_id;
- $login_model->mailid=$parent_model->email_id;
- $login_model->mobile_no=$parent_model->mobile_no;
- $login_model->password=sha1(strToLower($parent_model->parent_id));
- $login_model->access_id='3';
- $login_model->status='1';
- $login_model->save(false);
- $login_user=new UserLogin;
- $login_user->school_id=Yii::app()->session['school_registration_id'];
- $login_user->user_id=$stu_model->student_id;
- $login_user->user_email_id=$stu_model->email_id;
- $login_user->user_mobile_no=$stu_model->mobile_no;
- $login_user->user_password=sha1(strToLower($stu_model->student_id));
- $login_user->role_id=4;
- $login_user->lock_count=3;
- $login_user->is_locked=0;
- $login_user->verif_gen_date=date('Y-m-d');
- $cur_date=date('H:i:s');
- $currentDate = strtotime($cur_date);
- $futureDate = $currentDate+(60*60*48);
- $login_user->verif_exp_min=date('H:i:s',$futureDate);
- $login_user->save(false);
- $login_user=new UserLogin;
- $login_user->school_id=Yii::app()->session['school_registration_id'];
- $login_user->user_id=$parent_model->parent_id;
- $login_user->user_email_id=$parent_model->email_id;
- $login_user->user_mobile_no=$parent_model->mobile_no;
- $login_user->user_password=sha1(strToLower($parent_model->parent_id));
- $login_user->role_id=3;
- $login_user->lock_count=3;
- $login_user->is_locked=0;
- $login_user->verif_gen_date=date('Y-m-d');
- $cur_date=date('H:i:s');
- $currentDate = strtotime($cur_date);
- $futureDate = $currentDate+(60*15);
- $login_user->verif_exp_min=date('H:i:s',$futureDate);
- $login_user->save(false);
- }
- $contact=$users=$com=array();
- $h=0;
- $sel_val = explode(',',$_POST['selected_val']);
- foreach($sel_val as $val){
- $model =AdmissionSchedule::model()->find('admn_form_id='.$val);
- $comment = $_POST['comment'];
- $comment1=str_replace("*student_name*",$model->admnSch->first_name,$comment);
- $school_name=Yii::app()->session['school_name'];
- $comment2=str_replace("*school_name*",$school_name,$comment1);
- $comment3=str_replace("*message*",$_POST['add_comment'],$comment2);
- $model->comment = $comment3;
- $form_model = AdmissionForm::model()->findByPk($val);
- $contact[$h]=$form_model->mobile_no;
- $users[$h]=$form_model->admn_form_id;
- $com[$h]=$comment3;
- $model->save();
- $form_model->save();
- $h++;
- }
- $this->actionSmsall($contact,$com,$users);
- echo CJSON::encode("success");
- }
- //dev by ram ends
- public function actionEnrollReject()
- {
- $sel_val = explode(',',$_POST['selected_val']);
- foreach($sel_val as $val){
- $form_model = AdmissionForm::model()->find('admn_form_id='.$val);
- $schedule_model = AdmissionSchedule::model()->find('admn_form_id='.$val);
- $schedule_model->comment = $_POST['comment'];
- //Here i have maintained enroll stauts 1 =>selected and 0 =>rejected
- $schedule_model->enroll_status =0;
- $form_model->admission_status = 'Rejected';
- $schedule_model->save();
- $form_model->save();
- echo CJSON::encode("success");
- }
- }
- public function actionEnrollrejectsms()
- {
- //print_r($_POST);exit;
- $contact=$users=$com=array();
- $h=0;
- $sel_val = explode(',',$_POST['id']);
- foreach($sel_val as $val){
- $model =AdmissionSchedule::model()->find('admn_form_id='.$val);
- $comment = $_POST['comment'];
- $comment1=str_replace("*student_name*",$model->admnSch->first_name,$comment);
- $school_name=Yii::app()->session['school_name'];
- $comment2=str_replace("*school_name*",$school_name,$comment1);
- $comment3=str_replace("*message*",$_POST['add_comment'],$comment2);
- $model->comment = $comment3;
- $model->enroll_status =0;
- $form_model = AdmissionForm::model()->findByPk($val);
- $form_model->admission_status = 'Rejected';
- $contact[$h]=$form_model->mobile_no;
- $users[$h]=$form_model->admn_form_id;
- $com[$h]=$comment3;
- $model->save();
- $form_model->save();
- $h++;
- }
- $this->actionSmsall($contact,$com,$users);
- echo CJSON::encode("success");
- }
- public function actionExportEnrollExcel($id) {
- $data=Yii::app()->session['admissionexcel'];
- //print_r(Yii::app()->session['studentexcel']);
- if(empty(Yii::app()->session['admissionexcel'])){
- $data= new CActiveDataProvider('AdmissionForm');
- }
- if($id == 1){
- $fileName = "admission_enroll_";
- }
- else {
- $fileName = "enroll_rejected_";
- }
- $cur_time=date("Ymd_his");
- $this->widget('EExcelView', array(
- 'dataProvider'=> $data,
- 'grid_mode'=>'export',
- 'title'=>'Title',
- 'filename'=>$fileName.$cur_time,
- 'stream'=>true,
- 'exportType'=>'Excel2007',
- 'columns'=>array(
- array(//'name'=>'application_number',
- 'value'=>'$data->application_number',
- 'header'=>'Application No',
- ),
- array(//'name'=>'first_name',
- 'value'=>'$data->first_name." ".$data->last_name',
- 'header'=>'Student Name',
- ),
- array(//'name'=>'father_name',
- 'header'=>'Parent Name',
- 'value'=>'$data->father_name',
- ),
- array(//'name'=>'mobile_no',
- 'header'=>'Mobile',
- 'value'=>'$data->mobile_no',
- ),
- array(//'name'=>'class_id',
- 'value'=>'$data->class->class_name',
- 'header'=>'Class',
- ),
- array(//'name'=>'course',
- 'value'=>'$data->course->course_name',
- 'header'=>'Group',
- ),
- array(//'name'=>'application_fee',
- 'value'=>'$data->application_fee==NULL?0:$data->application_fee',
- 'type'=>'raw',
- 'header'=>'Application Fee Paid',
- ),
- array(//'name'=>'quota',
- 'value'=>'$data->quota->quota_name',
- 'header'=>'Quota',
- ),
- array(//'name'=>'admission_fee',
- 'value'=>'$data->admission_fee==NULL?0:$data->admission_fee',
- 'type'=>'raw',
- 'header'=>'Admission Fee Paid',
- ),
- ),
- ));
- Yii::app()->end();
- }
- public function actionCreate()
- {
- // Uncomment the following line if AJAX validation is needed
- // $this->performAjaxValidation($model);
- $sel_val = explode(',',$_POST['selected_val']);
- foreach($sel_val as $val){
- $model = new AdmissionSchedule;
- $model->admn_form_id = $val;
- $when=$_POST['int_date'];
- $when_date=date("d-m-Y",strtotime($when));
- $when_time=date("H:i A",strtotime($when));
- $model->interview_date = date("Y-m-d H:i:s",strtotime($when));
- $model->interview_venue = $_POST['int_venue'];
- $comment = $_POST['comment'];
- $comment1=str_replace("*student_name*",$model->admnSch->first_name,$comment);
- $comment2=str_replace("*interview_date*",$when_date,$comment1);
- $comment3=str_replace("*start_time*",$when_time,$comment2);
- $comment4=str_replace("*venue*",$_POST['int_venue'],$comment3);
- $comment5=str_replace("*message*",$_POST['add_comment'],$comment4);
- $model->comment = $comment5;
- $model->interview_status = 'YetToProcess';
- $form_model = AdmissionForm::model()->findByPk($val);
- $form_model->application_status = 'Selected';
- $model->save();
- $form_model->save();
- echo CJSON::encode("success");
- }
- }
- public function actionCreatesms()
- {
- $contact=$users=$com=array();
- $h=0;
- $sel_val = explode(',',$_POST['id']);
- foreach($sel_val as $val){
- $model = new AdmissionSchedule;
- $model->admn_form_id = $val;
- $when=$_POST['int_date'];
- $when_date=date("d-m-Y",strtotime($when));
- $when_time=date("H:i A",strtotime($when));
- $model->interview_date = date("Y-m-d H:i:s",strtotime($when));
- $model->interview_venue = $_POST['int_venue'];
- $comment = $_POST['comment'];
- $comment1=str_replace("*student_name*",$model->admnSch->first_name,$comment);
- $comment2=str_replace("*interview_date*",$when_date,$comment1);
- $comment3=str_replace("*start_time*",$when_time,$comment2);
- $comment4=str_replace("*venue*",$_POST['int_venue'],$comment3);
- $comment5=str_replace("*message*",$_POST['add_comment'],$comment4);
- $model->comment = $comment5;
- $model->interview_status = 'YetToProcess';
- $form_model = AdmissionForm::model()->findByPk($val);
- $form_model->application_status = 'Selected';
- $contact[$h]=$form_model->mobile_no;
- $users[$h]=$form_model->admn_form_id;
- $com[$h]=$comment5;
- $model->save();
- $form_model->save();
- $h++;
- }
- $this->actionSmsall($contact,$com,$users);
- echo CJSON::encode("success");
- }
- public function actionReject()
- {
- // Uncomment the following line if AJAX validation is needed
- // $this->performAjaxValidation($model);
- $sel_val = explode(',',$_POST['selected_val']);
- foreach($sel_val as $val){
- $form_model = AdmissionForm::model()->findByPk($val);
- $form_model->application_status = 'Rejected';
- $form_model->save();
- echo CJSON::encode("success");
- }
- }
- /**
- * 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['AdmissionSchedule']))
- {
- $model->attributes=$_POST['AdmissionSchedule'];
- if($model->save())
- $this->redirect(array('view','id'=>$model->schedule_id));
- }
- $this->render('update',array(
- 'model'=>$model,
- ));
- }
- /**
- * 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)
- {
- $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'));
- }
- /**
- * Lists all models.
- */
- public function actionIndex()
- {
- $dataProvider=new CActiveDataProvider('AdmissionSchedule');
- $this->render('index',array(
- 'dataProvider'=>$dataProvider,
- ));
- }
- /**
- * Manages all models.
- */
- public function actionAdmin()
- {
- $model=new AdmissionForm('search');
- $sch_model = new AdmissionSchedule;
- $model->unsetAttributes(); // clear any default values
- if(isset($_GET['AdmissionForm']))
- $model->attributes=$_GET['AdmissionForm'];
- $this->render('admin',array(
- 'model'=>$model, 'sch_model'=>$sch_model,
- ));
- }
- public function actionSchYetToProcess()
- {
- $model=new AdmissionForm('search');
- $sch_model = new AdmissionSchedule;
- $model->unsetAttributes(); // clear any default values
- if(isset($_GET['AdmissionForm']))
- $model->attributes=$_GET['AdmissionForm'];
- if(isset($_GET['pageSize'])) {
- Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']);
- unset($_GET['pageSize']);
- }
- $this->render('schyettoprocess',array(
- 'model'=>$model, 'sch_model'=>$sch_model,
- ));
- }
- public function actionExportScheduleExcel($id) {
- $data=Yii::app()->session['admissionexcel'];
- //print_r(Yii::app()->session['studentexcel']);
- if(empty(Yii::app()->session['admissionexcel'])){
- $data= new CActiveDataProvider('AdmissionForm');
- }
- if($id == 1){
- $fileName = "admission_schedule_";
- }
- else {
- $fileName = "schedule_rejected_";
- }
- $cur_time=date("Ymd_his");
- $this->widget('EExcelView', array(
- 'dataProvider'=> $data,
- 'grid_mode'=>'export',
- 'title'=>'Title',
- 'filename'=>$fileName.$cur_time,
- 'stream'=>true,
- 'exportType'=>'Excel2007',
- 'columns'=>array(
- array(//'name'=>'application_number',
- 'value'=>'$data->application_number',
- 'header'=>'Application No',
- ),
- array(//'name'=>'first_name',
- 'value'=>'$data->first_name." ".$data->last_name',
- 'header'=>'Student Name',
- ),
- array(//'name'=>'father_name',
- 'header'=>'Parent Name',
- 'value'=>'$data->father_name',
- ),
- array(//'name'=>'mobile_no',
- 'header'=>'Mobile',
- 'value'=>'$data->mobile_no',
- ),
- array(//'name'=>'class_id',
- 'value'=>'$data->class->class_name',
- 'header'=>'Class',
- ),
- array(//'name'=>'course',
- 'value'=>'$data->course->course_name',
- 'header'=>'Course',
- ),
- array(//'name'=>'caste',
- 'value'=>'$data->quota->quota_name',
- 'header'=>'Quota',
- ),
- array(//'name'=>'admission_status',
- 'header'=>'Application Status',
- 'value'=>'$data->application_status',
- ),
- ),
- ));
- Yii::app()->end();
- }
- public function actionSchRejected()
- {
- $model=new AdmissionForm('search');
- $sch_model = new AdmissionSchedule;
- $model->unsetAttributes(); // clear any default values
- if(isset($_GET['AdmissionForm']))
- $model->attributes=$_GET['AdmissionForm'];
- if(isset($_GET['pageSize'])) {
- Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']);
- unset($_GET['pageSize']);
- }
- $this->render('schrejected',array(
- 'model'=>$model, 'sch_model'=>$sch_model,
- ));
- }
- public function actionProcessYetToProcess()
- {
- $model=new AdmissionSchedule('search');
- //$form_model=new AdmissionForm;
- $sch_model = new AdmissionSchedule;
- $model->unsetAttributes();
- if(isset($_GET['AdmissionSchedule']))
- $model->attributes=$_GET['AdmissionSchedule'];
- if(isset($_GET['pageSize'])) {
- Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']);
- unset($_GET['pageSize']);
- }
- $this->render('processyettoprocess',array(
- 'model'=>$model,'sch_model'=>$sch_model));
- }
- public function actionProcessRejected()
- {
- $model=new AdmissionSchedule('search');
- //$form_model=new AdmissionForm;
- $sch_model = new AdmissionSchedule;
- $model->unsetAttributes();
- if(isset($_GET['AdmissionSchedule']))
- $model->attributes=$_GET['AdmissionSchedule'];
- if(isset($_GET['pageSize'])) {
- Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']);
- unset($_GET['pageSize']);
- }
- $this->render('processrejected',array(
- 'model'=>$model,'sch_model'=>$sch_model));
- }
- public function actionProcessCreate()
- {
- $sel_val = explode(',',$_POST['selected_val']);
- foreach($sel_val as $val){
- $model =AdmissionSchedule::model()->find('admn_form_id='.$val);
- $comment = $_POST['comment'];
- $comment1=str_replace("*student_name*",$model->admnSch->first_name,$comment);
- $fee_date=date('Y-m-d', strtotime("+25 days"));
- $comment2=str_replace("*Date*",$fee_date,$comment1);
- $comment3=str_replace("*message*",$_POST['add_comment'],$comment2);
- $model->comment = $comment3;
- $model->interview_status = 'Selected';
- $model->save();
- echo CJSON::encode("success");
- }
- }
- public function actionProcesscreatesms()
- {
- $contact=$users=$com=array();
- $h=0;
- $sel_val = explode(',',$_POST['id']);
- foreach($sel_val as $val){
- $model =AdmissionSchedule::model()->find('admn_form_id='.$val);
- //$model->admn_form_id = $val;
- //$when=$_POST['int_date'];
- //$when_date=date("d-m-Y",strtotime($when));
- //$when_time=date("H:i A",strtotime($when));
- //$model->interview_date = date("Y-m-d H:i:s",strtotime($when));
- //$model->interview_venue = $_POST['int_venue'];
- $comment = $_POST['comment'];
- $comment1=str_replace("*student_name*",$model->admnSch->first_name,$comment);
- $fee_date=date('Y-m-d', strtotime("+25 days"));
- $comment2=str_replace("*Date*",$fee_date,$comment1);
- //$comment3=str_replace("*start_time*",$when_time,$comment2);
- //$comment4=str_replace("*venue*",$_POST['int_venue'],$comment3);
- $comment5=str_replace("*message*",$_POST['add_comment'],$comment2);
- $model->comment = $comment5;
- $model->interview_status = 'Selected';
- $form_model = AdmissionForm::model()->findByPk($val);
- $contact[$h]=$form_model->mobile_no;
- $users[$h]=$form_model->admn_form_id;
- $com[$h]=$comment5;
- $model->save();
- $form_model->save();
- $h++;
- }
- $this->actionSmsall($contact,$com,$users);
- echo CJSON::encode("success");
- }
- public function actionProcessReject()
- {
- $sel_val = explode(',',$_POST['selected_val']);
- foreach($sel_val as $val){
- $model =AdmissionSchedule::model()->find('admn_form_id='.$val);
- $comment = $_POST['comment'];
- $comment1=str_replace("*student_name*",$model->admnSch->first_name,$comment);
- $comment2=str_replace("*message*",$_POST['add_comment'],$comment1);
- $model->comment = $comment2;
- $model->interview_status = 'Rejected';
- $model->save();
- echo CJSON::encode("success");
- }
- }
- public function actionProcessrejectsms()
- {
- $contact=$users=$com=array();
- $h=0;
- $sel_val = explode(',',$_POST['id']);
- foreach($sel_val as $val){
- $model =AdmissionSchedule::model()->find('admn_form_id='.$val);
- $model =AdmissionSchedule::model()->find('admn_form_id='.$val);
- $comment = $_POST['comment'];
- $comment1=str_replace("*student_name*",$model->admnSch->first_name,$comment);
- $comment2=str_replace("*message*",$_POST['add_comment'],$comment1);
- $model->comment = $comment2;
- $model->interview_status = 'Rejected';
- $form_model = AdmissionForm::model()->findByPk($val);
- $contact[$h]=$form_model->mobile_no;
- $users[$h]=$form_model->admn_form_id;
- $com[$h]=$comment2;
- $model->save();
- $form_model->save();
- $h++;
- }
- $this->actionSmsall($contact,$com,$users);
- echo CJSON::encode("success");
- }
- public function actionSmsall($mobile,$message,$list)
- {
- $msg_id=$m=0;
- $sender=Yii::app()->session['sms_header'];
- if($sender=="" || $sender==NULL)
- $sender="HEPHIV";
- $sms_user=Yii::app()->session['sms_user'];
- $sms_pass=Yii::app()->session['sms_pass'];
- $max_msg=SmsLog::model()->findAll(array("select"=>"max(msg_id) as max_msg_id"));
- if(count($max_msg) > 0)
- $msg_id=$max_msg[0]->max_msg_id+1;
- foreach($list as $key=>$user)
- {
- $len_message = preg_replace("/[\r]/","",$message[$key]);
- $length=strlen($len_message);
- $mb_length=mb_strlen($len_message, "UTF-8");
- $current_count=Yii::app()->list->smslength($length,$mb_length);
- $sms_log_model = new SmsLog;
- $sms_log_model->sms_description=$message[$key];
- $sms_log_model->msg_id=$msg_id;
- $sms_log_model->sms_type=14;
- $sms_log_model->mobile_no=$mobile[$key];
- $sms_log_model->sms_count=$current_count;
- $sms_log_model->access=15;
- $sms_log_model->sent_on=date('Y-m-d H:i:s');
- $sms_log_model->sent_by=1;
- $sms_log_model->dist_type=14;
- $sms_log_model->distribution_list=$user;
- $sms_log_model->save();
- $jsondata[$m]['mobile_no']= $mobile[$key];
- $jsondata[$m]['final_message']=$message[$key];
- $jsondata[$m]['sender']=$sender;
- $jsondata[$m]['sms_user']=$sms_user;
- $jsondata[$m]['sms_pass']=$sms_pass;
- $m++;
- }
- $enc_json=json_encode($jsondata);
- $this->actionPostData($enc_json);
- }
- public function actionProcessHold()
- {
- // Uncomment the following line if AJAX validation is needed
- // $this->performAjaxValidation($model);
- $sel_val = explode(',',$_POST['selected_val']);
- foreach($sel_val as $val){
- $model =AdmissionSchedule::model()->find('admn_form_id='.$val);
- $comment = $_POST['comment'];
- $comment1=str_replace("*student_name*",$model->admnSch->first_name,$comment);
- $comment2=str_replace("*message*",$_POST['add_comment'],$comment1);
- $model->comment = $comment2;
- $model->interview_status = 'OnHold';
- $model->save();
- echo CJSON::encode("success");
- }
- }
- public function actionProcessholdsms()
- {
- $contact=$users=$com=array();
- $h=0;
- $sel_val = explode(',',$_POST['id']);
- foreach($sel_val as $val){
- $model =AdmissionSchedule::model()->find('admn_form_id='.$val);
- $comment = $_POST['comment'];
- $comment1=str_replace("*student_name*",$model->admnSch->first_name,$comment);
- $comment2=str_replace("*message*",$_POST['add_comment'],$comment1);
- $model->comment = $comment2;
- $model->interview_status = 'OnHold';
- $form_model = AdmissionForm::model()->findByPk($val);
- $contact[$h]=$form_model->mobile_no;
- $users[$h]=$form_model->admn_form_id;
- $com[$h]=$comment2;
- $model->save();
- $form_model->save();
- $h++;
- }
- $this->actionSmsall($contact,$com,$users);
- echo CJSON::encode("success");
- }
- public function actionProcessResch()
- {
- $sel_val = explode(',',$_POST['selected_val']);
- foreach($sel_val as $val){
- $model = AdmissionSchedule::model()->find('admn_form_id='.$val);
- $when=$_POST['interview_date'];
- $when_date=date("d-m-Y",strtotime($when));
- $when_time=date("H:i A",strtotime($when));
- $model->interview_date = date("Y-m-d H:i:s",strtotime($when));
- $model->interview_venue = $_POST['interview_venue'];
- $comment = $_POST['comment'];
- $comment1=str_replace("*student_name*",$model->admnSch->first_name,$comment);
- $comment2=str_replace("*date*",$when_date,$comment1);
- $comment3=str_replace("*time*",$when_time,$comment2);
- $comment4=str_replace("*venue*",$_POST['interview_venue'],$comment3);
- $comment5=str_replace("*message*",$_POST['add_comment'],$comment4);
- $model->comment = $comment5;
- $model->interview_status = 'YetToProcess';
- $model->save();
- echo CJSON::encode("success");
- }
- }
- public function actionProcessreschsms()
- {
- $contact=$users=$com=array();
- $h=0;
- $sel_val = explode(',',$_POST['id']);
- foreach($sel_val as $val){
- $model = new AdmissionSchedule;
- $model = AdmissionSchedule::model()->find('admn_form_id='.$val);
- $when=$_POST['interview_date'];
- $when_date=date("d-m-Y",strtotime($when));
- $when_time=date("H:i A",strtotime($when));
- $model->interview_date = date("Y-m-d H:i:s",strtotime($when));
- $model->interview_venue = $_POST['interview_venue'];
- $comment = $_POST['comment'];
- $comment1=str_replace("*student_name*",$model->admnSch->first_name,$comment);
- $comment2=str_replace("*date*",$when_date,$comment1);
- $comment3=str_replace("*time*",$when_time,$comment2);
- $comment4=str_replace("*venue*",$_POST['interview_venue'],$comment3);
- $comment5=str_replace("*message*",$_POST['add_comment'],$comment4);
- $model->comment = $comment5;
- $model->interview_status = 'YetToProcess';
- $form_model = AdmissionForm::model()->findByPk($val);
- $contact[$h]=$form_model->mobile_no;
- $users[$h]=$form_model->admn_form_id;
- $com[$h]=$comment5;
- $model->save();
- $form_model->save();
- $h++;
- }
- $this->actionSmsall($contact,$com,$users);
- echo CJSON::encode("success");
- }
- public function actionExportProcessExcel($id) {
- $data=Yii::app()->session['admissionexcel'];
- //print_r(Yii::app()->session['studentexcel']);
- if(empty(Yii::app()->session['admissionexcel'])){
- $data= new CActiveDataProvider('AdmissionSchedule');
- }
- if($id == 1){
- $fileName = "admission_process_";
- }
- else {
- $fileName = "process_rejected_";
- }
- $cur_time=date("Ymd_his");
- $this->widget('EExcelView', array(
- 'dataProvider'=> $data,
- 'grid_mode'=>'export',
- 'title'=>'Title',
- 'filename'=>$fileName.$cur_time,
- 'stream'=>true,
- 'exportType'=>'Excel2007',
- 'columns'=>array(
- array(//'name'=>'application_number',
- 'value'=>'$data->admnSch->application_number',
- 'header'=>'Application No',
- ),
- array(//'name'=>'first_name',
- 'value'=>'$data->admnSch->first_name." ".$data->admnSch->last_name',
- 'header'=>'Student Name',
- ),
- array(//'name'=>'father_name',
- 'header'=>'Parent Name',
- 'value'=>'$data->admnSch->father_name',
- ),
- array(//'name'=>'mobile_no',
- 'header'=>'Mobile',
- 'value'=>'$data->admnSch->mobile_no',
- ),
- array(//'name'=>'class_id',
- 'value'=>'$data->admnSch->class->class_name',
- 'header'=>'Class',
- ),
- array(//'name'=>'course',
- 'value'=>'$data->admnSch->course->course_name',
- 'header'=>'Group',
- ),
- array(//'name'=>'caste',
- 'value'=>'$data->admnSch->quota->quota_name',
- 'header'=>'Quota',
- ),
- array(//'name'=>'caste',
- 'value'=>'$data->interview_date',
- 'header'=>'Interview Date',
- ),
- array(//'name'=>'admission_status',
- 'header'=>'Interview Status',
- 'value'=>'$data->interview_status',
- ),
- ),
- ));
- Yii::app()->end();
- }
- /**
- * 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 $id the ID of the model to be loaded
- * @return AdmissionSchedule the loaded model
- * @throws CHttpException
- */
- public function loadModel($id)
- {
- $model=AdmissionSchedule::model()->findByPk($id);
- if($model===null)
- throw new CHttpException(404,'The requested page does not exist.');
- return $model;
- }
- /**
- * Performs the AJAX validation.
- * @param AdmissionSchedule $model the model to be validated
- */
- protected function performAjaxValidation($model)
- {
- if(isset($_POST['ajax']) && $_POST['ajax']==='admission-schedule-form')
- {
- echo CActiveForm::validate($model);
- Yii::app()->end();
- }
- }
- public function actionPostData($enc_json){
- $post_data = 'jsondata='.$enc_json;
- //print_r($post_data);
- //exit;
- //Initiates a connection to example.com using port 80 with a timeout of 15 seconds.
- $socket = fsockopen("app.timetoschool.com", 80, $errno, $errstr, 5000);
- //Checks if the connection was fine
- if(!$socket){
- //Connection failed so we display the error number and message and stop the script from continuing
- echo ' error: ' . $errno . ' ' . $errstr;
- die;
- }else{
- //Builds the header data we will send along with are post data. This header data tells the web server we are connecting to what
- //we are, what we are requesting and the content type so that it can process are request.
- $http = "POST /school/message_service.php HTTP/1.1\r\n";
- $http .= "Host: app.timetoschool.com\r\n";
- $http .= "User-Agent: " . $_SERVER['HTTP_USER_AGENT'] . "\r\n";
- $http .= "Content-Type: application/x-www-form-urlencoded\r\n";
- $http .= "Content-length: " . strlen($post_data) . "\r\n";
- $http .= "Connection: close\r\n\r\n";
- $http .= $post_data . "\r\n\r\n";
- //Sends are header data to the web server
- //stream_set_timeout($socket, 0, 2000 * 1000);
- fputs($socket, $http);
- $contents = "";
- //Waits for the web server to send the full response. On every line returned we append it onto the $contents
- //variable which will store the whole returned request once completed.
- /*while (!feof($socket)) {
- $contents .= fgets($socket, 4096);
- }*/
- //Close are request or the connection will stay open untill are script has completed.
- fclose($socket);
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement