Exemple #1
0
     $student = $students[$stId];
     $class = $student->clas();
     foreach ($_POST['months'] as $m) {
         // check if a voucher is already present for that month
         // if not present, add a new fee voucher
         // if present, add fee detail to it
         if (!($feeVoucher = Fee_voucher::findOneByCondition("student_id={$stId} and month={$m}"))) {
             $feeVoucher = new Fee_voucher();
             $feeVoucher->student_id->val = $student->id->val;
             $y = $m >= $class->starting_month->val ? $class->session->val : $class->session->val + 1;
             $d = $student->last_date_for_fee_submission->val;
             $feeVoucher->month->val = $m;
             $feeVoucher->year->val = $y;
             $feeVoucher->last_date->val = "{$y}-{$m}-{$d}";
             $feeVoucher->issue_date->val = "{$y}-{$m}-01";
             if (!$feeVoucher->dbSave()) {
                 $html->echoError("Fee Voucher not already saved. Failed to create a new one.");
             }
         }
         // create fee voucher detail
         $feeDetail = new Fee_voucher_datail();
         $feeDetail->fee_voucher_id->val = $feeVoucher->id->val;
         $feeDetail->fee_category_id->val = $_POST['category'];
         $feeDetail->amount->val = $_POST['amount'];
         if (!$feeDetail->dbSave()) {
             $html->echoError("Failed to add fee detail. Please try later.");
         }
     }
 }
 $session->setMessage("Fee Detail added successfully.");
 reloadCurrentPage();
Exemple #2
0
 /**
  * @return Fee_voucher[]
  */
 function autoInsertFee_voucher()
 {
     if ($feeVouchers = $this->getChildRecs('Fee_voucher')) {
         return $feeVouchers;
     }
     // get default installments
     $class = new Clas($this->class_id->val);
     $defInstallments = $this->defaultInstallments();
     if (!$defInstallments) {
         return false;
     }
     $months = array();
     // to make sure only one voucher is generated for each single month
     foreach ($defInstallments as $dInsId => $defIns) {
         $m = $defIns->month->val;
         if (!in_array($m, $months)) {
             //$defIns->pr();
             $feeVoucher = new Fee_voucher();
             //$feeVoucher->pr();
             $feeVoucher->student_id->val = $this->id->val;
             $y = $m >= $class->starting_month->val ? $class->session->val : $class->session->val + 1;
             $d = $this->last_date_for_fee_submission->val;
             $feeVoucher->month->val = $m;
             $feeVoucher->year->val = $y;
             $feeVoucher->last_date->val = "{$y}-{$m}-{$d}";
             $feeVoucher->issue_date->val = "{$y}-{$m}-01";
             if (!$feeVoucher->dbSave()) {
                 return false;
             }
             $months[] = $m;
             $feeVouchers[] = $feeVoucher;
         }
     }
     return $feeVouchers;
 }