本文整理汇总了PHP中Configurations::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Configurations::model方法的具体用法?PHP Configurations::model怎么用?PHP Configurations::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configurations
的用法示例。
在下文中一共展示了Configurations::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
/**
* 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 Configurations the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Configurations::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例2: actionIndex
public function actionIndex()
{
//to hide welcome message - Rajith
if (isset($_POST['hide'])) {
//permanant hide
if (isset($_POST['dontshow'])) {
$config = Configurations::model()->findByAttributes(array('id' => 21));
if ($config != NULL) {
$config->config_value = 1;
$config->save();
}
}
$this->redirect(array('/mailbox'));
}
//check
$config = Configurations::model()->findByAttributes(array('id' => 21));
if ($config != NULL) {
if ($config->config_value) {
$this->redirect(array('/mailbox'));
}
}
$this->render(Yii::app()->getModule('message')->viewPath . '/index');
}
示例3:
//echo $logo[0]->photo_file_name;
//Yii::app()->runController('Configurations/displayLogoImage/id/'.$logo[0]->primaryKey);
echo '<img src="uploadedfiles/school_logo/' . $logo[0]->photo_file_name . '" alt="' . $logo[0]->photo_file_name . '" class="imgbrder" width="100%" />';
}
?>
</td>
<td align="center" valign="middle" class="first">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="listbxtop_hdng first" style="text-align:center;"></td>
</tr>
<tr>
<td class="listbxtop_hdng first" style="text-align:center; font-size:20px; ">
<?php
$college = Configurations::model()->findByPk(1);
?>
<?php
echo $college->config_value;
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<h4><?php
echo Yii::t('employees', 'Employee Attendance Report');
?>
</h4>
示例4: actionAjax_delete
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;
}
}
示例5: actionCreate
/**
* 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));
}
示例6:
<?php
$logo = Logo::model()->findAll();
?>
<?php
if ($logo != NULL) {
//Yii::app()->runController('Configurations/displayLogoImage/id/'.$logo[0]->primaryKey);
echo '<img src="uploadedfiles/school_logo/' . $logo[0]->photo_file_name . '" alt="' . $logo[0]->photo_file_name . '" class="imgbrder" width="100%" />';
}
?>
</td>
<td align="center" valign="middle" class="first" style="width:300px;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="listbxtop_hdng first" style="text-align:left; font-size:22px; width:300px; padding-left:10px;">
<?php
$college = Configurations::model()->findAll();
?>
<?php
echo $college[0]->config_value;
?>
</td>
</tr>
<tr>
<td class="listbxtop_hdng first" style="text-align:left; font-size:14px; padding-left:10px;">
<?php
echo $college[1]->config_value;
?>
</td>
</tr>
<tr>
<td class="listbxtop_hdng first" style="text-align:left; font-size:14px; padding-left:10px;">
示例7: array
$this->renderPartial('tab');
?>
<div class="clear"></div>
<div class="emp_cntntbx">
<div>
<div class="formCon">
<div class="formConInner">
<h3><?php
echo Yii::t('students', 'Pending Fees');
?>
</h3>
<div class="tableinnerlist">
<?php
$res = FinanceFees::model()->findAll(array('condition' => 'student_id=:vwid AND is_paid=:vpid', 'params' => array(':vwid' => $_REQUEST['id'], ':vpid' => 0)));
$currency = Configurations::model()->findByPk(5);
if (count($res) == '0') {
echo Yii::t('students', '<i>No Pending Fees</i>');
} else {
?>
<table width="95%" cellpadding="0" cellspacing="0">
<tr>
<th><?php
echo Yii::t('students', 'Category Name');
?>
</th>
<th><?php
echo Yii::t('students', 'Collection Name');
?>
</th>
<th><?php
示例8: array
<?php
if (Yii::app()->controller->action->id == 'create') {
$config = Configurations::model()->findByPk(7);
$adm_no = '';
$adm_no_1 = '';
if ($config->config_value == 1) {
$adm_no = Students::model()->findAll(array('order' => 'id DESC', 'limit' => 1));
$adm_no_1 = $adm_no[0]['id'] + 1;
}
?>
<div class="captionWrapper">
<ul>
<li><h2 class="cur">Student Details</h2></li>
<li><h2>Parent Details</h2></li>
<li><h2>Emergency Contact</h2></li>
<li><h2>Previous Details</h2></li>
<li class="last"><h2>Student Profile</h2></li>
</ul>
</div>
<?php
} else {
echo '<br><br>';
$adm_no = Students::model()->findByAttributes(array('id' => $_REQUEST['id']));
$adm_no_1 = $adm_no->admission_no;
}
?>
<?php
$form = $this->beginWidget('CActiveForm', array('id' => 'students-form', 'enableAjaxValidation' => false, 'htmlOptions' => array('enctype' => 'multipart/form-data')));
?>
示例9: actionCreate
/**
* 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();
}
}
//.........这里部分代码省略.........
示例10: actionSendsms
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']));
}
示例11: actionPublish
public function actionPublish()
{
$model = new Weekdays();
$start_date = Configurations::model()->findByAttributes(array('id' => '13'));
$end_date = Configurations::model()->findByAttributes(array('id' => '14'));
$present = PeriodEntries::model()->findByAttributes(array('batch_id' => $_REQUEST['id']));
if (count($present) !== 0) {
$perii = PeriodEntries::model()->findAll("batch_id=:x", array(':x' => $_REQUEST['id']));
foreach ($perii as $perii_1) {
$perii_1->delete();
}
//$this->redirect(array('timetable','id'=>$_REQUEST['id']));
}
$i = 0;
$date = strtotime(date("Y-m-d", strtotime($start_date->config_value)) . " +" . $i . " day");
do {
$date = strtotime(date("Y-m-d", strtotime($start_date->config_value)) . " +" . $i . " day");
$week = date('N', strtotime(date('Y-m-d', $date)));
if ($week == 1) {
$day = 7;
} else {
$day = $week + 1;
}
$flag = Weekdays::model()->findByAttributes(array('batch_id' => $_REQUEST['id'], 'weekday' => $day));
if (count($flag) != 0) {
$period = new PeriodEntries();
$period->month_date = date('Y-m-d', $date);
$period->batch_id = $_REQUEST['id'];
$period->save();
} else {
$period = new PeriodEntries();
$period->month_date = date('Y-m-d', $date);
$period->batch_id = $_REQUEST['id'];
$period->save();
}
$i++;
/*{
$this->redirect(array('timetable','id'=>$_REQUEST['id']));
}*/
} while (date('Y-m-d', $date) == $end_date->config_value);
//exit;
$this->redirect(array('timetable', 'id' => $_REQUEST['id']));
/*$this->render('timetable',array(
'model'=>$model,
));*/
}
示例12: actionSendsms
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']));
}
示例13: actionStep4
/**
* finish install applcation
* redirect user to admin panel or home site.
*
* @return void
*/
public function actionStep4()
{
//redirect previous step
if (Yii::app()->session->contains('aemail') === false && Yii::app()->session->contains('password') === false) {
$this->redirect(array('step3'));
}
$model = new RegisterForm();
if (isset($_POST['RegisterForm'])) {
$model->attributes = $_POST['RegisterForm'];
if ($model->validate() === true) {
//post to www.open-school.org/register
// create a new cURL resource
$ch = curl_init();
$data = http_build_query(CMap::mergeArray($model->attributes, array('ip' => gethostbyname($_SERVER['SERVER_NAME']), 'domain' => Yii::app()->request->hostInfo . Yii::app()->request->baseUrl, 'key' => Yii::app()->session['key'])), null, '&');
// set URL and other appropriate options
$options = array(CURLOPT_URL => 'http://licence-server.open-school.org/register.php', CURLOPT_HEADER => false, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $data, CURLOPT_RETURNTRANSFER => true);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
$content = trim($content, '()');
$result = CJSON::decode($content, true);
curl_close($ch);
$this->initDbConnection();
$posts_1 = Configurations::model()->findByAttributes(array('id' => 1));
$posts_1->config_value = $_POST['RegisterForm']['schoolname'];
$posts_1->save();
$posts_2 = Configurations::model()->findByAttributes(array('id' => 2));
$posts_2->config_value = $_POST['RegisterForm']['address'];
$posts_2->save();
$this->redirect(array('step5'));
}
}
//Check
if (isset(Yii::app()->session['key']) and isset(Yii::app()->session['email'])) {
$key_info['key'] = Yii::app()->session['key'];
Yii::app()->session->remove('key');
//Remove
$key_info['email'] = Yii::app()->session['email'];
Yii::app()->session->remove('email');
//Remove
$serverurl = "http://licence-server.open-school.org/server.php";
Yii::app()->session['key'] = $key_info['key'];
Yii::app()->session['email'] = $key_info['email'];
$this->render('step5', array('model' => $model));
} else {
//session expired or direct link
$this->redirect(array('index'));
}
}
示例14: actionCreate2
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));
}
示例15: actionSendsms
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']));
}
}