/**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView()
 {
     $username = Yii::app()->user->name;
     $model = User::model()->find("username=:username", array(':username' => $username));
     if ($model->FK_usertype == 1) {
         $id = VideoInterview::model()->findByAttributes(array('FK_student' => $model->id));
     } else {
         // employer
         $id = VideoInterview::model()->findByAttributes(array('FK_employer' => $model->id));
     }
     //Yii::log("the user name is", CLogger::LEVEL_ERROR, 'application.controller.Prof');
     $this->render('view', array('model' => $id));
 }
 public function actionScheduleInterview()
 {
     $original_string = "qwertyuiopasdfghjklzxcvbnm123456789";
     $lastid = VideoInterview::model()->find(array('order' => 'id DESC'));
     if ($lastid != null) {
         $key = $lastid->id + 1 . "VJFID" . rand(1, 10000000);
     } else {
         $key = 1 . "VJFID" . rand(1, 10000000);
     }
     $refid = Notification::model()->find(array('order' => 'id DESC'));
     $username = Yii::app()->user->name;
     $sender_id = User::model()->find("username=:username", array(':username' => $username))->id;
     $student = $_POST['user_name'];
     $receiver = User::model()->find("username=:username", array(':username' => $student));
     $link = $username;
     $model = new VideoInterview();
     $model->attributes = $_POST['VideoInterview'];
     $model->FK_employer = $sender_id;
     $model->FK_student = $receiver->id;
     $model->session_key = $key;
     $model->notification_id = $refid->id + 2;
     $model->save(false);
     $message = $username . " scheduled a video interview with you on: {$model->date} at: {$model->time} Good Luck!";
     User::sendSchedualNotificationAlart($sender_id, $receiver->id, $message, $link);
     //print "<pre>"; print_r($receiver_id);print "</pre>";return;
     //SAVE TO VIDEO INTERVIEW TABLE
     $message2 = "You scheduled an interview with " . $student . " at " . $model->time . " on " . $model->date . " Click here to go to the interview page.";
     User::sendSchedualNotificationAlart($receiver->id, $sender_id, $message2, $student);
     $message3 = "Hi {$receiver->username}, {$username} will like to interview you on:<br/>Date: {$model->date}<br/>Time: {$model->time}";
     User::sendEmail($receiver->email, "Virtual Job Fair", "Scheduled Interview", $message3);
     //User::sendEmailNotificationAlart($receiver->email, $receiver->username, $username, $message3);
     $link = CHtml::link('here', 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/home/studenthome');
     $message4 = "{$username} scheduled an interview with you on:<br/>Date: {$model->date}<br/>Time: {$model->time}<br/>{$link}" . " Click {$link} to go to the interview page";
     //$html = User::replaceMessage($student, $message4);
     User::sendEmail($receiver->email, "Virtual Job Fair", "Scheduled Interview", $message4);
     //User::sendEmailNotificationAlart($receiver->email, $receiver->username, $username, $message4);
     $this->redirect("/JobFair/index.php/profile/student/user/" . $student);
     //print "<pre>"; print_r($key);print "</pre>";return;
 }
Example #3
0
 public function run($args)
 {
     date_default_timezone_set('America/New_York');
     $date = date('Y-m-d');
     $time = date('H:i:s');
     $futuretime = date('H:i:s', strtotime("+30 min"));
     $entries = VideoInterview::model()->findAllBySql("SELECT * FROM video_interview WHERE\n    \t                                                    date=:date AND time BETWEEN CONVERT(" . "'" . $time . "'" . ", TIME) AND\n    \t                                                    CONVERT(" . "'" . $futuretime . "'" . ", TIME)", array(":date" => $date));
     echo $date . " " . $time . "\n";
     echo $futuretime . "\n";
     spl_autoload_unregister(array('YiiBase', 'autoload'));
     require 'Services/Twilio.php';
     $sid = "AC1a9ec3e5aaf3135a5e4893c095be8430";
     $token = "15871d8b55c402145f12c77dd7525644";
     $client = new Services_Twilio($sid, $token);
     spl_autoload_register(array('YiiBase', 'autoload'));
     echo "Timeframe: " . $date . " (" . $time . " - " . $futuretime . ")\nFound " . count($entries) . "interview(s)\n";
     foreach ($entries as $avideo) {
         $infoEmployer = BasicInfo::model()->find("userid=:userid", array('userid' => $avideo->FK_employer));
         $userEmployer = User::model()->find("id=:id", array('id' => $avideo->FK_employer));
         $infoStudent = BasicInfo::model()->find("userid=:userid", array('userid' => $avideo->FK_student));
         $userStudent = User::model()->find("id=:id", array('id' => $avideo->FK_student));
         //Send message to employer
         //if($infoEmployer->allowSMS == 1 && $infoEmployer->validated == 1)
         if ($infoEmployer->allowSMS == 1 && $infoEmployer->validated == 1 && $userEmployer->activated == 1) {
             echo "Sending Employer SMS [" . $infoEmployer->phone . "]\n";
             $msg = "Hello " . $userEmployer->username . " this is friendly reminder from Virtual Job Fair about your scheduled interview with " . $userStudent->username . " today at  " . $avideo->time;
             //echo $avideo->session_key . "\n";
             $client->account->messages->sendMessage("+17868375870", "+1" . $infoEmployer->phone, $msg);
         }
         //Send message to student
         //if($infoStudent->allowSMS == 1 && $infoStudent->validated == 1)
         if ($infoStudent->allowSMS == 1 && $infoStudent->validated == 1 && $userStudent->activated == 1) {
             echo "Sending Student SMS [" . $infoStudent->phone . "]\n";
             $msg = "Hello " . $userStudent->username . " this is friendly reminder from Virtual Job Fair about your scheduled interview with " . $userEmployer->username . " today at  " . $avideo->time;
             //echo $avideo->session_key . "\n";
             $client->account->messages->sendMessage("+17868375870", "+1" . $infoStudent->phone, $msg);
         }
     }
 }
Example #4
0
 public function actionEmployerHome()
 {
     $username = Yii::app()->user->name;
     $user = User::model()->find("username=:username", array(':username' => $username));
     // pass user
     $notification = Notification::model()->getNotificationId($user->id);
     // pass the notifications
     $univs = School::getAllSchools();
     // pass universities
     $skills = Skillset::getNames();
     // pass skills
     $countvideo = 0;
     $countapplicants = 0;
     $countmessages = 0;
     $countcandidates = 0;
     foreach ($notification as $n) {
         if ($n->importancy == 4 & $n->been_read == 0) {
             $countvideo++;
             $key = VideoInterview::model()->findByAttributes(array('notification_id' => $n->id));
             if ($key != null) {
                 $n->keyid = $key->session_key;
                 //print "<pre>"; print_r($key);print "</pre>";return;
             }
         } else {
             if ($n->importancy == 4 & $n->been_read != 0) {
                 //$countvideo++;
                 $key = VideoInterview::model()->findByAttributes(array('notification_id' => $n->id));
                 if ($key != null) {
                     $n->keyid = $key->session_key;
                     //print "<pre>"; print_r($key);print "</pre>";return;
                 }
             } elseif ($n->importancy == 6 & $n->been_read == 0) {
                 $countapplicants++;
             } elseif ($n->importancy == 3 & $n->been_read == 0) {
                 $countmessages++;
             } elseif ($n->importancy == 5 & $n->been_read == 0) {
                 $countcandidates++;
             }
         }
     }
     $this->render('employerhome', array('user' => $user, 'universities' => $univs, 'skills' => $skills, 'notification' => $notification, 'countvideo' => $countvideo, 'countapplicants' => $countapplicants, 'countmessages' => $countmessages, 'countcndidates' => $countcandidates));
 }