protected function renderContent() { $nationalholiday = NationalHolidays::model()->findAll(array('condition' => 'national_holiday_org_id=' . Yii::app()->user->getState('org_id'))); $data = array(); if ($nationalholiday) { foreach ($nationalholiday as $list) { $data[] = array('title' => $list->national_holiday_name, 'start' => $list->national_holiday_date, 'color' => '#000000'); } } //print_r($data); exit; /* $data = array( array( 'title'=> 'All Day Event', 'start'=> '2012-12-02', 'color'=>'#000000', ), array( 'title'=> 'Karmraj', 'start'=> '2012-12-02', 'color'=>'#000000', ), array( 'title'=> 'All Day Event', 'start'=> '2012-12-14', 'color'=>'#000000', ), array( 'title'=> 'All Day Event', 'start'=> '2012-12-15', 'color'=>'#000000', )); print_r($data);exit;*/ $this->widget('application.extensions.fullcalendar.FullcalendarGraphWidget', array('data' => $data, 'options' => array('editable' => true), 'htmlOptions' => array('style' => 'width:365px;margin: 0 auto;'))); }
public function actionMyholidays() { $org = Yii::app()->user->getState('org_id'); if(Yii::app()->user->getState('stud_id')){ $trans_id = Yii::app()->user->getState('stud_id'); $trans_model = StudentTransaction::model()->findByPk($trans_id); $acdm_model = AcademicTerm::model()->findByPk($trans_model->student_academic_term_name_id); $nat_holidays = NationalHolidays::model()->findAll(array('condition'=>'national_holiday_date between "'.$acdm_model->academic_term_start_date.'" and "'.$acdm_model->academic_term_end_date.'" and national_holiday_org_id='.$org,'order'=>'national_holiday_date')); } $this->render('my_holidays',array('date_list'=>$nat_holidays)); }
/** * This method is to check wheather on this day holiday is already declared or not. */ public function chkdate() { if($this->isNewRecord) { $form_date = date('Y-m-d',strtotime($this->national_holiday_date)); $all_date = NationalHolidays::model()->findByAttributes(array('national_holiday_date'=>$form_date)); if($all_date) { $this->addErrors(array('national_holiday_name'=>"On this date, Holiday is already assign.",'national_holiday_date'=>"On this date, Holiday is already assign.")); return false; } else return true; } else { $nid = $this->national_holiday_id; $form_date = date('Y-m-d',strtotime($this->national_holiday_date)); $all_date = NationalHolidays::model()->findByAttributes(array(), $condition = 'national_holiday_date=:national_holiday_date and national_holiday_id<>:national_holiday_id', $params = array(':national_holiday_date'=>$form_date, ':national_holiday_id'=>$nid ) ); if($all_date) { $this->addError('national_holiday_date',"On this date, Holiday is already assign."); return false; } else return true; } }