/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new MiscellaneousFeesPaymentTransaction(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['MiscellaneousFeesPaymentTransaction'])) { $model->attributes = $_POST['MiscellaneousFeesPaymentTransaction']; $model->student_fees_id = $_REQUEST['id']; $model->miscellaneous_fees_payment_transaction_organization_id = Yii::app()->user->getState('org_id'); if ($model->save()) { $this->redirect(array('view', 'id' => $model->miscellaneous_trans_id)); } //$this->redirect(array('miscellaneousFeesPaymentTransaction/madmin')); } $cash_model = new MiscellaneousFeesPaymentCash('mysearch'); $cash_model->unsetAttributes(); // clear any default values if (isset($_GET['MiscellaneousFeesPaymentCash'])) { $cash_model->attributes = $_GET['MiscellaneousFeesPaymentCash']; } $cheque_model = new MiscellaneousFeesPaymentCheque('mysearch'); $cheque_model->unsetAttributes(); // clear any default values if (isset($_GET['MiscellaneousFeesPaymentCheque'])) { $cheque_model->attributes = $_GET['MiscellaneousFeesPaymentCheque']; } $this->render('create', array('model' => $model, 'cash_model' => $cash_model, 'cheque_model' => $cheque_model)); }
public function actionmis_feesExportToExcel($id) { $cash_data = MiscellaneousFeesPaymentCash::model()->findAll('miscellaneous_fees_payment_cash_student_id=' . $id); $cheque_data = MiscellaneousFeesPaymentCheque::model()->findAll('miscellaneous_fees_payment_cheque_student_id=' . $id); Yii::app()->request->sendFile(date('YmdHis') . '.xlsx', $this->renderPartial('/miscellaneousFeesPaymentTransaction/mis_pdf', array('cash_data' => $cash_data, 'cheque_data' => $cheque_data, 'id' => $id), true)); }
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; } } }
/** * 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 = MiscellaneousFeesPaymentCheque::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }