/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new FinanceFees(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['FinanceFees'])) { $model->attributes = $_POST['FinanceFees']; //$model->saveAttributes('date' => date('Y-m-d') ); if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
array_push($student_arr_2, $item->student_id); // Push the students present in Finance fees tables } foreach ($student_arr_2 as $student) { if (!in_array($student, $student_arr_1)) { $command = Yii::app()->db->createCommand('delete from finance_fees where student_id=:id and fee_collection_id=:coll_id and date is null')->bindValue('id', $student)->bindValue('coll_id', $_REQUEST['collection']); $command->execute(); } } $missing_students = array_diff($student_arr_1, $student_arr_2); foreach ($missing_students as $student) { $finance = new FinanceFees(); $finance->fee_collection_id = $_REQUEST['collection']; $finance->student_id = $student; $finance->is_paid = 0; $finance->save(); } // var_dump($missing_students); //$amount = 0; $list = FinanceFees::model()->findAll("fee_collection_id=:x", array(':x' => $_REQUEST['collection'])); ?> <td> </tr> </table> </div></div> <div class="tableinnerlist"> <table width="80%" cellspacing="0" cellpadding="0"> <tr> <th><strong><?php echo Yii::t('fees', 'Sl no.');
/** * 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 actionAjax_Create() { if (isset($_POST['FinanceFeeCollections'])) { $list = $_POST['FinanceFeeCollections']; $model = new FinanceFeeCollections(); $model->attributes = $_POST['FinanceFeeCollections']; if ($model->start_date) { $model->start_date = date('Y-m-d', strtotime($model->start_date)); } if ($model->end_date) { $model->end_date = date('Y-m-d', strtotime($model->end_date)); } if ($model->due_date) { $model->due_date = date('Y-m-d', strtotime($model->due_date)); } $cat = FinanceFeeCategories::model()->findByAttributes(array('id' => $list['fee_category_id'])); $model->batch_id = $cat->batch_id; //return the JSON result to provide feedback. $student = Students::model()->findAll("batch_id=:x and is_active=:y and is_deleted=:z", array(':x' => $cat->batch_id, ':y' => 1, ':z' => 0)); if ($model->save(false)) { foreach ($student as $students) { $finance = new FinanceFees(); $finance->fee_collection_id = $model->id; $finance->student_id = $students->id; $finance->is_paid = 0; $finance->save(); } echo json_encode(array('success' => true, 'id' => $model->primaryKey)); exit; } else { echo json_encode(array('success' => false)); exit; } } }
/** * 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 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, '3', $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('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)); // 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(); } } if (defined('EMAIL_ALERT_ADDRESS')) { $name = $model->first_name . " " . $model->last_name; UserModule::sendMail(constant('EMAIL_ALERT_ADDRESS'), UserModule::t("New student admitted : {student_name}", array('{student_name}' => $name)), UserModule::t("A new student has been admitted: {student_name}", array('{student_name}' => $name))); } $this->redirect(array('guardians/create', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }