public function actionAjax_delete()
 {
     $id = $_POST['id'];
     $deleted = $this->loadModel($id);
     $deleted_batch_id = $deleted->batch_id;
     // Saving the id of the batch that is going to be deleted.
     if ($deleted->delete()) {
         //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
         ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '13', $deleted_batch_id, ucfirst($deleted->name), NULL, NULL, NULL);
         // For SMS
         $sms_settings = SmsSettings::model()->findAll();
         $to = '';
         if ($sms_settings[0]->is_enabled == '1' and $sms_settings[5]->is_enabled == '1') {
             // Checking if SMS is enabled.
             $students = Students::model()->findAll("batch_id=:x", array(':x' => $deleted_batch_id));
             //Selecting students of the batch
             foreach ($students as $student) {
                 if ($student->phone1) {
                     // Checking if phone number is provided
                     $to = $student->phone1;
                 } elseif ($student->phone2) {
                     $to = $student->phone2;
                 }
                 if ($to != '') {
                     // Sending SMS to each student
                     $college = Configurations::model()->findByPk(1);
                     $from = $college->config_value;
                     $message = $deleted->name . ' is cancelled';
                     SmsSettings::model()->sendSms($to, $from, $message);
                 }
             }
         }
         // End For SMS
         // Delete Exam and exam score
         $exam = Exams::model()->findAllByAttributes(array('exam_group_id' => $id));
         //print_r($exam);
         foreach ($exam as $exam1) {
             $examscore = ExamScores::model()->findAllByAttributes(array('exam_id' => $exam1->id));
             foreach ($examscore as $examscore1) {
                 $examscore1->delete();
             }
             $exam1->delete();
         }
         // End Delete Exam and exam score
         echo json_encode(array('success' => true));
         exit;
     } else {
         echo json_encode(array('success' => false));
         exit;
     }
 }
                        $t--;
                        continue;
                    }
                }
                $grde = $grade_value;
                $total_p .= ' (' . $grde . ')';
            }
            $final_message .= "{$to},{$student_name},{$examname},{$result_r},{$total_p}" . PHP_EOL;
        }
    }
    // echo $final_message;
    //Send sms here
    $sms_settings = SmsSettings::model()->findAll();
    if ($sms_settings[0]->is_enabled == '1' && $sms_settings[6]->is_enabled == '1') {
        //echo "$final_message";
        SmsSettings::model()->sendSmsExamresult($final_message);
    }
} else {
    echo '<td align="center" colspan="5"><strong>' . 'No Data Available!' . '</td>';
}
?>
</div>
       </div>
     <br />
  
   
     <br />
     
    <!-- Batch Assessment Report -->
    <div class="tablebx" style="overflow-x:auto;">
    
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Guardians();
     $check_flag = 0;
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if ($_POST['student_id']) {
         $guardian = Students::model()->findByAttributes(array('id' => $_POST['student_id']));
         $gid = $guardian->parent_id;
     } elseif ($_POST['guardian_id']) {
         $gid = $_POST['guardian_id'];
     } elseif ($_POST['guardian_mail']) {
         $gid = $_POST['guardian_mail'];
     }
     if ($gid != NULL and $gid != 0) {
         $model = Guardians::model()->findByAttributes(array('id' => $gid));
         $this->render('create', array('model' => $model, 'radio_flag' => 1, 'guardian_id' => $gid));
     } elseif ((isset($_POST['student_id']) or isset($_POST['guardian_id']) or isset($_POST['guardian_mail'])) and ($gid == NULL or $gid == 0)) {
         Yii::app()->user->setFlash('errorMessage', UserModule::t("Guardian not found..!"));
     }
     if (isset($_POST['Guardians'])) {
         $model->attributes = $_POST['Guardians'];
         $model->validate();
         if ($_POST['Guardians']['user_create'] == 1) {
             $check_flag = 1;
         }
         //print_r($_POST['Guardians']); exit;
         if ($model->save()) {
             //echo $model->ward_id; exit;
             $student = Students::model()->findByAttributes(array('id' => $model->ward_id));
             $student->saveAttributes(array('parent_id' => $model->id));
             if ($_POST['Guardians']['user_create'] == 0) {
                 //adding user for current guardian
                 $user = new User();
                 $profile = new Profile();
                 $user->username = substr(md5(uniqid(mt_rand(), true)), 0, 10);
                 $user->email = $model->email;
                 $user->activkey = UserModule::encrypting(microtime() . $model->first_name);
                 $password = substr(md5(uniqid(mt_rand(), true)), 0, 10);
                 $user->password = UserModule::encrypting($password);
                 $user->superuser = 0;
                 $user->status = 1;
                 if ($user->save()) {
                     //assign role
                     $authorizer = Yii::app()->getModule("rights")->getAuthorizer();
                     $authorizer->authManager->assign('parent', $user->id);
                     //profile
                     $profile->firstname = $model->first_name;
                     $profile->lastname = $model->last_name;
                     $profile->user_id = $user->id;
                     $profile->save();
                     //saving user id to guardian table.
                     $model->saveAttributes(array('uid' => $user->id));
                     //$model->uid = $user->id;
                     //$model->save();
                     // for sending sms
                     $sms_settings = SmsSettings::model()->findAll();
                     $to = '';
                     if ($sms_settings[0]->is_enabled == '1' and $sms_settings[2]->is_enabled == '1') {
                         // Checking if SMS is enabled.
                         if ($model->mobile_phone) {
                             $to = $model->mobile_phone;
                         }
                         if ($to != '') {
                             // Send SMS if phone number is provided
                             $college = Configurations::model()->findByPk(1);
                             $from = $college->config_value;
                             $message = 'Welcome to ' . $college->config_value;
                             SmsSettings::model()->sendSms($to, $from, $message);
                         }
                         // End send SMS
                     }
                     // End check if SMS is enabled
                     UserModule::sendMail($model->email, UserModule::t("You registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please login to your account with your email id as username and password {password}", array('{password}' => $password)));
                 }
             }
             $this->redirect(array('addguardian', 'id' => $model->ward_id));
         }
     }
     $this->render('create', array('model' => $model, 'check_flag' => $check_flag));
 }
 public function actionSendsms()
 {
     /*echo 'Batch ID: '.$_REQUEST['batch_id'].'<br/>';
     		echo 'Fee Collection ID: '.$_REQUEST['collection'].'<br/>';
     		echo 'Days in between: '.$_REQUEST['date_status'].'<br/>';
     		echo 'Amount: '.$_REQUEST['amount'].'<br/>';*/
     $sms_settings = SmsSettings::model()->findAll();
     if ($sms_settings[0]->is_enabled == '1' and $sms_settings[7]->is_enabled == '1') {
         // Checking if SMS is enabled.
         $collection = FinanceFeeCollections::model()->findByAttributes(array('id' => $_REQUEST['collection']));
         /*echo 'Fees Name: '.$collection->name.'<br/>';
         		echo 'Due Date: '.$collection->due_date.'<br/>';*/
         $unpaid_students = FinanceFees::model()->findAll("fee_collection_id=:x and is_paid=:y", array(':x' => $_REQUEST['collection'], ':y' => 0));
         //echo 'Total unpaid students: '.count($unpaid_students).'<br/><br/>';
         foreach ($unpaid_students as $unpaid_student) {
             //echo 'Student ID: '.$unpaid_student->student_id.'<br/>';
             $student = Students::model()->findByAttributes(array('id' => $unpaid_student->student_id));
             $guardian = Guardians::model()->findByAttributes(array('ward_id' => $student->id));
             /*echo 'Name: '.$student->first_name.'<br/>';
             		echo 'Phone 1: '.$student->phone1.'<br/>';*/
             $to_parent = '';
             $to_student = '';
             $message = '';
             if (count($guardian) != 0 and $guardian->mobile_phone != NULL) {
                 // If guardian is added
                 $to_parent = $guardian->mobile_phone;
             }
             if ($student->phone1) {
                 // Checking if phone number is provided
                 $to_student = $student->phone1;
             } elseif ($student->phone2) {
                 $to_student = $student->phone2;
             }
             //echo 'Message To: '.$to.'<br/>';
             $college = Configurations::model()->findByPk(1);
             $from = $college->config_value;
             // Checking the days between the current date and due date. And, the customising the message accordingly
             if ($_REQUEST['date_status'] < 1) {
                 $message = 'Last date for the payment of [' . $collection->name . '] fees was ' . $collection->due_date;
             } elseif ($_REQUEST['date_status'] > 1 and $_REQUEST['date_status'] <= 7) {
                 $message = 'Last date for the payment of [' . $collection->name . '] fees is ' . $collection->due_date;
             } elseif ($_REQUEST['date_status'] == 1) {
                 $message = 'Last date for the payment of [' . $collection->name . '] fees is today. i.e.,' . $collection->due_date;
             }
             //echo 'Message: '.$message.'<br/><br/>';
             if ($message != '' && 0) {
                 // Send SMS if message is set
                 if ($to_parent != '') {
                     // If unpaid and parent phone number is provided, send SMS
                     SmsSettings::model()->sendSms($to_parent, $from, $message);
                 }
                 // End check if parent phone number is provided
                 if ($to_student != '') {
                     // If unpaid and student phone number is provided, send SMS
                     SmsSettings::model()->sendSms($to_student, $from, $message);
                 }
                 // End check if student phone number is provided
                 Yii::app()->user->setFlash('notification', 'SMS send Successfully!');
             }
             // End check if message is set
         }
         // End for each student
         //exit;
     }
     // End check whether SMS is enabled
     $this->redirect(array('unpaid', 'batch' => $_REQUEST['batch_id'], 'course' => $_REQUEST['collection']));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Students();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Students'])) {
         $model->attributes = $_POST['Students'];
         $list = $_POST['Students'];
         if ($model->admission_date) {
             $model->admission_date = date('Y-m-d', strtotime($model->admission_date));
         }
         if ($model->date_of_birth) {
             $model->date_of_birth = date('Y-m-d', strtotime($model->date_of_birth));
         }
         //$model->photo_data=CUploadedFile::getInstance($model,'photo_data');
         if ($file = CUploadedFile::getInstance($model, 'photo_data')) {
             $model->photo_file_name = $file->name;
             $model->photo_content_type = $file->type;
             $model->photo_file_size = $file->size;
             $model->photo_data = file_get_contents($file->tempName);
         }
         /*else{
         	  if(isset($_POST['photo_file_name'])){
                      $model->photo_file_name=$_POST['photo_file_name'];
         		  $model->photo_content_type=$_POST['photo_content_type'];
         		  $model->photo_file_size=$_POST['photo_file_size'];
         		  $model->photo_data=hex2bin($_POST['photo_data']);
         	  }
           }*/
         //echo $model->photo_data.'----';
         /*if(isset($_FILES['Students']))
         		{
         			print_r($_FILES['Students']);
         			exit;
         			$tmpName = $_FILES['Students']['tmp_name'];
         		  $fp      = fopen($tmpName, 'r');
         		  $data = fread($fp, filesize($tmpName));
         		  $data = addslashes($data);
         		  fclose($fp);
         		  $model->photo_data = $data;
         		}*/
         if ($model->save()) {
             //adding user for current student
             $user = new User();
             $profile = new Profile();
             $user->username = substr(md5(uniqid(mt_rand(), true)), 0, 10);
             $user->email = $model->email;
             $user->activkey = UserModule::encrypting(microtime() . $model->first_name);
             $password = substr(md5(uniqid(mt_rand(), true)), 0, 10);
             $user->password = UserModule::encrypting($password);
             $user->superuser = 0;
             $user->status = 1;
             if ($user->save()) {
                 //assign role
                 $authorizer = Yii::app()->getModule("rights")->getAuthorizer();
                 $authorizer->authManager->assign('student', $user->id);
                 //profile
                 $profile->firstname = $model->first_name;
                 $profile->lastname = $model->last_name;
                 $profile->user_id = $user->id;
                 $profile->save();
                 //saving user id to students table.
                 $model->saveAttributes(array('uid' => $user->id));
                 // for sending sms
                 $sms_settings = SmsSettings::model()->findAll();
                 $to = '';
                 if ($sms_settings[0]->is_enabled == '1' and $sms_settings[2]->is_enabled == '1') {
                     // Checking if SMS is enabled.
                     if ($model->phone1) {
                         $to = $model->phone1;
                     } elseif ($model->phone2) {
                         $to = $model->phone2;
                     }
                     if ($to != '') {
                         // Send SMS if phone number is provided
                         $college = Configurations::model()->findByPk(1);
                         $from = $college->config_value;
                         $message = 'Welcome to ' . $college->config_value;
                         SmsSettings::model()->sendSms($to, $from, $message);
                     }
                     // End send SMS
                 }
                 // End check if SMS is enabled
                 UserModule::sendMail($model->email, UserModule::t("You are registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please login to your account with your email id as username and password {password}", array('{password}' => $password)));
             }
             // for saving in fee table
             $fee_collection = FinanceFeeCollections::model()->findAll('batch_id=:x', array(':x' => $model->batch_id));
             if ($fee_collection != NULL) {
                 for ($i = 0; $i < count($fee_collection); $i++) {
                     $fee = new FinanceFees();
                     $fee->fee_collection_id = $fee_collection[$i]['id'];
                     $fee->student_id = $model->id;
                     $fee->is_paid = '0';
                     $fee->save();
                 }
             }
             $this->redirect(array('guardians/create', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function actionSendsms()
 {
     $sms_settings = SmsSettings::model()->findAll();
     if ($sms_settings[0]->is_enabled == '1' and $sms_settings[8]->is_enabled == '1') {
         // Checking if SMS is enabled.
         /*echo "Due Date ID: ".$_REQUEST['due_date_id']."<br/>";
         		echo "Target Date: ".$_REQUEST['target_date']."<br/>";*/
         $message_status = $_REQUEST['due_date_id'];
         // Customising the list according to the due date
         if ($_REQUEST['due_date_id'] == 0) {
             $borrowbook = BorrowBook::model()->findAll('status=:x', array(':x' => 'C'));
         } elseif ($_REQUEST['due_date_id'] == -1) {
             $borrowbook = BorrowBook::model()->findAll('due_date < CURRENT_DATE() AND status=:y', array(':y' => 'C'));
         } else {
             // Setting the ID for redirecting
             if ($_REQUEST['due_date_id'] == 5) {
                 $_REQUEST['due_date_id'] = 2;
             } elseif ($_REQUEST['due_date_id'] == 10) {
                 $_REQUEST['due_date_id'] = 3;
             }
             $borrowbook = BorrowBook::model()->findAll('due_date=:x AND status=:y', array(':x' => $_REQUEST['target_date'], ':y' => 'C'));
         }
         foreach ($borrowbook as $book) {
             // For each book
             $bookdetails = Book::model()->findByAttributes(array('id' => $book->book_id));
             $student = Students::model()->findByAttributes(array('id' => $book->student_id));
             //echo $student->first_name."<br/>";
             $to = '';
             $message = '';
             if ($student->phone1) {
                 // Checking if phone number is provided
                 $to = $student->phone1;
             } elseif ($student->phone2) {
                 $to = $student->phone2;
             }
             if ($to != '') {
                 // If phone number is provided, send SMS
                 $college = Configurations::model()->findByPk(1);
                 $from = $college->config_value;
                 // Customising messages
                 if ($message_status == 0 or $message_status == 5 or $message_status == 10) {
                     $message = 'Due date for returning the book "' . $bookdetails->title . '" : ' . $book->due_date;
                 } elseif ($message_status == -1) {
                     $message = 'Due date for returning the book "' . $bookdetails->title . '" was ' . $book->due_date;
                 } elseif ($message_status == 1) {
                     $message = 'Due date for returning the book "' . $bookdetails->title . '" is ' . $book->due_date . '. Please return or renew the book by tomorrow.';
                 }
                 //echo $message."<br/><br/>";
                 if ($message != '') {
                     // Send SMS if message is set
                     // SmsSettings::model()->sendSms($to,$from,$message);
                     Yii::app()->user->setFlash('notification', 'Library SMS is disabled!');
                 }
             }
             // End check phone number
         }
         // End for each book
     }
     // End check whether SMS is enabled
     $this->redirect(array('settings', 'id' => $_REQUEST['due_date_id']));
 }
Example #7
0
            }
            ?>
</tr>
<?php 
            $j++;
        }
        ?>
</table>
<?php 
    }
}
?>
</div>
<?php 
// Button to send SMS
$sms_settings = SmsSettings::model()->findAll();
if ($sms_settings[0]->is_enabled == '1' and $sms_settings[3]->is_enabled == '1') {
    // Checking if SMS is enabled
    if ($posts != NULL && 0) {
        // Check if students is present in the batch. Show SMS button only if there are students in the batch.
        ?>
            <div class="edit_bttns" style="top:22px; right:250px;"> 
                    <?php 
        echo CHtml::button(Yii::t('attendance', 'Send SMS'), array('submit' => array('StudentAttentance/sendSms', 'batch_id' => $_REQUEST['id']), 'class' => 'formbut'));
        ?>
            </div>
<?php 
    }
}
?>
<div class="ea_pdf" style="top:22px; ">
Example #8
0
<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'sms-settings-form', 'enableAjaxValidation' => false));
?>

	<!--<p class="note">Fields with <span class="required">*</span> are required.</p>-->
	
	<?php 
echo $form->errorSummary($model);
?>
    <div>
   
    <table width="200px">
    	<tr>
        	<td class="check">
              <?php 
$posts = SmsSettings::model()->findAll();
if ($posts[0]->is_enabled == '1') {
    // Enable SMS for the application
    echo $form->checkBox($model, 'enable_app', array('id' => 'enable_app', 'checked' => 'true'));
} else {
    echo $form->checkBox($model, 'enable_app', array('id' => 'enable_app'));
}
?>
                <?php 
echo $form->error($model, 'enable_app');
?>
            </td>
            <td>Enable SMS</td>
        </tr>
    </table>
	</div><br />
 /**
  * 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 = SmsSettings::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #10
0
<div class="temp_view">
<div class="temp_div">
	<div class="temp_image"></div>
    <h2><strong><?php 
$name = SmsSettings::model()->findByAttributes(array('id' => $data->cat_id));
echo CHtml::link(CHtml::encode($name->settings_key ? $name->settings_key : 'No name'), array('view', 'id' => $data->id));
?>
</strong></h2>
    <div style=" margin: 2px 0 0 8px;
    position: absolute;
    right: 0;
    top: -4px;">			
        <?php 
echo CHtml::link(Yii::t('os_sms_module', ''), array('update', 'id' => $data->id), array('class' => 'temp_edit'));
?>
        
    </div>
    <div style="margin-top:-5px; text-align:justify ; color: #898989 !important;
    ">    
    
    <p><?php 
echo CHtml::encode($data->template);
?>
</p>
    

</div>
<div class="created_box">

<div class="created_box_r"><b><?php 
echo CHtml::encode($data->getAttributeLabel('created_at'));
 public function actionCreate2()
 {
     $model = new Employees();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Employees'])) {
         $model->attributes = $_POST['Employees'];
         $list = $_POST['Employees'];
         $model = $model->findByAttributes(array('id' => $_REQUEST['id']));
         $model->home_address_line1 = $list['home_address_line1'];
         $model->home_address_line2 = $list['home_address_line2'];
         $model->home_city = $list['home_city'];
         $model->home_state = $list['home_state'];
         $model->home_country_id = $list['home_country_id'];
         $model->home_pin_code = $list['home_pin_code'];
         $model->office_address_line1 = $list['office_address_line1'];
         $model->office_address_line2 = $list['office_address_line2'];
         $model->office_city = $list['office_city'];
         $model->office_state = $list['office_state'];
         $model->office_country_id = $list['office_country_id'];
         $model->office_pin_code = $list['office_pin_code'];
         $model->office_phone1 = $list['office_phone1'];
         $model->office_phone2 = $list['office_phone2'];
         $model->mobile_phone = $list['mobile_phone'];
         $model->home_phone = $list['home_phone'];
         $model->email = $list['email'];
         $model->fax = $list['fax'];
         $model->user_id = $list['user_id'];
         if ($model->save()) {
             //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
             ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '23', $model->id, ucfirst($model->first_name) . ' ' . ucfirst($model->middle_name) . ' ' . ucfirst($model->last_name), NULL, NULL, NULL);
             //adding user for current student
             $user = new User();
             $profile = new Profile();
             $user->username = substr(md5(uniqid(mt_rand(), true)), 0, 10);
             $user->email = $model->email;
             $user->activkey = UserModule::encrypting(microtime() . $model->first_name);
             $password = substr(md5(uniqid(mt_rand(), true)), 0, 10);
             $user->password = UserModule::encrypting($password);
             $user->superuser = 0;
             $user->status = 1;
             if ($user->save()) {
                 //assign role
                 $authorizer = Yii::app()->getModule("rights")->getAuthorizer();
                 $authorizer->authManager->assign('teacher', $user->id);
                 //profile
                 $profile->firstname = $model->first_name;
                 $profile->lastname = $model->last_name;
                 $profile->user_id = $user->id;
                 $profile->save();
                 //saving user id to students table.
                 $model->saveAttributes(array('uid' => $user->id));
                 // For Sending SMS
                 $sms_settings = SmsSettings::model()->findAll();
                 $to = '';
                 if ($sms_settings[0]->is_enabled == '1' and $sms_settings[4]->is_enabled == '1') {
                     // Check if SMS is enabled
                     if ($model->mobile_phone) {
                         $to = $model->mobile_phone;
                     }
                     if ($to != '') {
                         //If phone number is provided, send SMS
                         $college = Configurations::model()->findByPk(1);
                         $from = $college->config_value;
                         $message = 'Welcome to ' . $college->config_value . '. You have been added to school database.';
                         $login_message = 'Log on to ' . $college->config_value . ' account with your email as username and ' . $password . ' as password.';
                         // SmsSettings::model()->sendSms($to,$from,$message);
                         // SmsSettings::model()->sendSms($to,$from,$login_message);
                     }
                     // End send SMS
                 }
                 // Check if SMS is provided
                 // UserModule::sendMail($model->email,UserModule::t("You are registered from {site_name}",array('{site_name}'=>Yii::app()->name)),UserModule::t("Please login to your account with your email id as username and password {password}",array('{password}'=>$password)));
             }
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create2', array('model' => $model));
 }
 public function actionSendsms()
 {
     // Function to send Attendance SMS to all students of a batch
     $sms_settings = SmsSettings::model()->findAll();
     if ($sms_settings[0]->is_enabled == '1' and $sms_settings[3]->is_enabled == '1') {
         // Checking if SMS is enabled.
         $students = Students::model()->findAll("batch_id=:x", array(':x' => $_REQUEST['batch_id']));
         // Selecting the students of the batch
         $today = date("Y-m-d");
         $sms_status = 0;
         // Setting a flag variable to check whether atleast one sms was sent.
         if ($students != NULL) {
             foreach ($students as $student) {
                 $is_absent = StudentAttentance::model()->find("date=:x AND student_id=:y", array(':x' => $today, ':y' => $student->id));
                 $absent_no = count($is_absent);
                 if (count($is_absent) != '0' and count($is_absent) != NULL) {
                     // Checking whether the student was absent
                     $guardian = Guardians::model()->findByAttributes(array('ward_id' => $student->id));
                     if (count($guardian) != '0') {
                         // Check if guardian added
                         $to = '';
                         if ($guardian->mobile_phone) {
                             //Checking if phone number is provided
                             $to = $guardian->mobile_phone;
                         }
                         if ($to != '') {
                             // If absent and phone number is provided, send SMS
                             $college = Configurations::model()->findByPk(1);
                             $from = $college->config_value;
                             $message = 'Your child ' . $student->first_name . ' was absent today.';
                             //SmsSettings::model()->sendSms($to,$from,$message);
                             $sms_status = 1;
                             // Set flag variable to 1 if atleast one sms was sent.
                             Yii::app()->user->setFlash('notification', 'Attendance SMS is disabled');
                         }
                         // End check phone number
                     }
                     // End check if guardian added
                 }
                 // End check whether the student was absent
             }
             // End for each student
             if ($sms_status == 0) {
                 // This flag variable will be one if atleast one sms was sent.
                 Yii::app()->user->setFlash('notification', 'No absentees today!');
             }
         } else {
             Yii::app()->user->setFlash('notification', 'No students!');
         }
     }
     // End check if SMS is enabled
     if (isset($_REQUEST['flag']) and $_REQUEST['flag'] == 1) {
         $this->redirect(array('/courses/studentAttentance', 'id' => $_REQUEST['batch_id']));
     } else {
         $this->redirect(array('index', 'id' => $_REQUEST['batch_id']));
     }
 }