/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { //exit; $model = new MiscellaneousFeesPaymentCash(); $receipt = new MiscellaneousFeesReceipt(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['MiscellaneousFeesPaymentCash'])) { $model->attributes = $_POST['MiscellaneousFeesPaymentCash']; $model->miscellaneous_fees_payment_organization_id = Yii::app()->user->getState('org_id'); $last_receipt_id = Yii::app()->db->createCommand()->select('MAX(miscellaneous_fees_receipt_number) as lastid')->from('miscellaneous_fees_receipt')->where('miscellaneous_fees_receipt_org_id=:id', array(':id' => Yii::app()->user->getState('org_id')))->queryRow(); $receipt->miscellaneous_fees_receipt_number = $last_receipt_id['lastid'] + 1; $receipt->miscellaneous_fees_receipt_org_id = Yii::app()->user->getState('org_id'); $receipt->save(); $model->miscellaneous_fees_payment_cash_student_id = $_REQUEST['id']; $model->miscellaneous_fees_payment_cash_receipt_id = $receipt->miscellaneous_fees_receipt_id; $model->miscellaneous_fees_payment_cash_created_by = Yii::app()->user->id; //$model->miscellaneous_fees_payment_cash_creation_date=new CDbExpression('NOW()'); $date = $_POST['MiscellaneousFeesPaymentCash']['miscellaneous_fees_payment_cash_creation_date']; $new_date = date("Y-m-d", strtotime($date)); $model->miscellaneous_fees_payment_cash_creation_date = $new_date; if ($model->save()) { $this->redirect(array('/miscellaneousFeesPaymentTransaction/create', 'id' => $model->miscellaneous_fees_payment_cash_student_id)); } } $this->render('create', array('model' => $model)); }
/** * 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 = MiscellaneousFeesReceipt::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
$org_data = Organization::model()->findByPk(Yii::app()->user->getState('org_id')); echo $org_data->organization_name . "</br>"; echo $org_data->address_line1 . " "; echo $org_data->address_line2 . "</br>"; echo City::model()->findBypk(Organization::model()->findByPk(Yii::app()->user->getState('org_id'))->city)->city_name . ", " . State::model()->findBypk(Organization::model()->findByPk(Yii::app()->user->getState('org_id'))->state)->state_name . ", " . Country::model()->findBypk(Organization::model()->findByPk(Yii::app()->user->getState('org_id'))->country)->name . "."; ?> </div> </div> <div class="rcpt_content"> <div class="id_date"> <div class="rcpt_no"> <span class="style2 rcpt_title">Receipt No.</span> <span class="rcpt_id"><?php echo MiscellaneousFeesReceipt::model()->findByPk($misc_fees_payment->miscellaneous_fees_payment_cash_receipt_id)->miscellaneous_fees_receipt_number; ?> </span> </div> <div class="rcpt_date"> <span class="style2 rcpt_title">Date:</span> <span class="rcpt_dt"><?php echo date_format(new DateTime($misc_fees_payment->miscellaneous_fees_payment_cash_creation_date), "d-m-Y"); ?> </span> </div> </div> <div class="rcpt_name"> <span class="rcpt_title">Received with thanks from Mr./Mrs./Ms.</span> <span class="rcpt_s_name"><?php echo $stud_model->student_first_name . ' ' . $stud_model->student_middle_name . ' ' . $stud_model->student_last_name;
public function beforesave() { //echo Yii::app()->user->getState('student_id'); $my_date = date("Y-m-d"); $receipt = new MiscellaneousFeesReceipt(); if ($this->isNewRecord) { if ($this->miscellaneous_fees_payment_cheque_date > $my_date) { $last_receipt_id = Yii::app()->db->createCommand()->select('MAX(miscellaneous_fees_receipt_number) as lastid')->from('miscellaneous_fees_receipt')->where('miscellaneous_fees_receipt_org_id=:id', array(':id' => Yii::app()->user->getState('org_id')))->queryRow(); $receipt->miscellaneous_fees_receipt_number = $last_receipt_id['lastid'] + 1; $receipt->miscellaneous_fees_receipt_org_id = Yii::app()->user->getState('org_id'); $receipt->save(); $this->miscellaneous_fees_payment_cheque_receipt_id = $receipt->miscellaneous_fees_receipt_id; return true; } else { $this->addError("miscellaneous_fees_payment_cheque_date", "Cheque Date Must Be After Current Date"); return false; } } else { $result = MiscellaneousFeesPaymentCheque::model()->findByPk($this->miscellaneous_fees_payment_cheque_id); if ($this->miscellaneous_fees_payment_cheque_date == $result['miscellaneous_fees_payment_cheque_date']) { return true; } else { if ($this->miscellaneous_fees_payment_cheque_date > $my_date) { return true; } else { $this->addError("miscellaneous_fees_payment_cheque_date", "Cheque Date Must Be After Current Date"); return false; } return false; } } }