public function actionSaveconsultation(){
     $date=Yii::app()->getRequest()->getPost('datecons');
     $idteacher=Yii::app()->request->getPost('teacherid');
     $idlecture=Yii::app()->request->getPost('lectureid');
     $calendar = new Consultationscalendar();
     if(Yii::app()->request->getPost('saveConsultation')) {
         $numcons = explode(",", Yii::app()->request->getPost('timecons'));
         for ($i=0; $i<count($numcons);$i++ ){
             if(Consultationscalendar::consultationFree($idteacher,$numcons[$i],$date)){
                 $calendar->start_cons =substr($numcons[$i], 0,5);
                 $calendar->end_cons =substr($numcons[$i], 6,5);
                 $calendar->date_cons =$date;
                 $calendar->teacher_id = $idteacher;
                 $calendar->user_id = Yii::app()->request->getPost('userid');
                 $calendar->lecture_id = $idlecture;
                 $calendar->save();
                 $calendar = new Consultationscalendar();
             } else {
                 $this->redirect( array('consultationerror','lecture'=>$idlecture));
             }
         }
     }
         header('Location: '.$_SERVER['HTTP_REFERER']);
 }