예제 #1
0
 public function checkFeesTotal($attribute)
 {
     if (empty($this->fees_pay_tran_amount)) {
         return $this->addError($attribute, "You can not take zero fees.");
     }
     $payFees = $chkFees = 0;
     $payFees = Yii::$app->db->createCommand("SELECT SUM(fees_pay_tran_amount) FROM fees_payment_transaction WHERE fees_pay_tran_stu_id=" . $this->fees_pay_tran_stu_id . " AND fees_pay_tran_collect_id=" . $this->fees_pay_tran_collect_id . " AND is_status=0")->queryScalar();
     $totalPayFees = Yii::$app->db->createCommand("SELECT SUM(fees_details_amount) FROM fees_category_details WHERE fees_details_category_id = " . $this->fees_pay_tran_collect_id . " AND is_status=0")->queryScalar();
     if ($this->isNewRecord) {
         $chkFees = $payFees + $this->fees_pay_tran_amount;
     } else {
         $currFees = FeesPaymentTransaction::findOne($this->fees_pay_tran_id)->fees_pay_tran_amount;
         $chkFees = $payFees + $this->fees_pay_tran_amount - $currFees;
     }
     if ($chkFees > $totalPayFees) {
         return $this->addError($attribute, "You can not take advance fees.");
         return false;
     } else {
         return true;
     }
 }
 /**
  * Finds the FeesPaymentTransaction model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return FeesPaymentTransaction the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = FeesPaymentTransaction::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }