public function getAcademicCost($con = null) { include_once 'lib/model/om/BaseAcademicCostPeer.php'; if ($this->aAcademicCost === null && $this->academic_cost_id !== null) { $this->aAcademicCost = AcademicCostPeer::retrieveByPK($this->academic_cost_id, $con); } return $this->aAcademicCost; }
public function executeInsertPaymentJournal() { $student_course = StudentCoursePeer::retrieveByPK($this->getRequestParameter('id')); $stu = StudentPeer::retrieveByPK($this->getRequestParameter('student_id')); $accal = $student_course->getAcademicCalendar(); $job = JobPeer::retrieveByCode($this->getModuleName()); $academic_process = $job->getAcademicProcess(); $this->forward404Unless($student_course && $stu && $accal && $job && $academic_process); // $c = new Criteria(); // $c->add(AcademicCostPeer::ACADEMIC_CALENDAR_ID, $accal->getId()); // $c->add(AcademicProcessPeer::CODE, $academic_process->getCode()); // $c->addJoin(AcademicProcessPeer::ID, AcademicCostPeer::ACADEMIC_PROCESS_ID); // $costs = AcademicCostPeer::doSelect($c); #$c = new Criteria(); #$c->add(StudentCoursePeer::STUDENT_ID, $stu->getId()); #$c->add(SubjectAccalPeer::ACADEMIC_CALENDAR_ID, $accal->getId()); #$c->add(StudentCoursePeer::STATUS, StudentCourse::STATUS_APPROVED); #$c->addJoin(SubjectAccalPeer::ID, StudentCoursePeer::SUBJECT_ACCAL_ID); #$scs = StudentCoursePeer::doSelect($c); $paids = $this->getRequestParameter('paid'); foreach ($paids as $key => $val) { $c = AcademicCostPeer::retrieveByPK($key); $payment_journal = new PaymentJournal(); $payment_journal->setAcademicCost($c); $payment_journal->setJob($job); $payment_journal->setPayer($stu->getId()); #$amount = 0; #if ($c->getAcademicCostComponent()->getUnit() == AcademicCostComponent::UNIT_CREDIT) { # foreach ($scs as $sc) { # $amount += $c->getAmount() * $sc->getSubjectAccal()->getSubject()->getCredit(); # } #} elseif ($c->getAcademicCostComponent()->getUnit() == AcademicCostComponent::UNIT_SUBJECT) { # foreach ($scs as $sc) { # $amount += $c->getAmount(); # } #} else { $amount = $c->getAmount(); #} $payment_journal->setAmount($amount); $payment_journal->setPaid($val); $payment_journal->setReceivable($amount - $val); $payment_journal->setAcademicProcess($academic_process); $payment_journal->setPayerType(PaymentJournal::PAYER_TYPE_STUDENT); if ($amount - $val == 0) { $payment_journal->setStatus('S'); } elseif ($amount - $val > 0) { $payment_journal->setStatus('M'); } elseif ($amount - $val < 0) { $payment_journal->setStatus('P'); } $payment_journal->save(); $ph = new PaymentHistory(); $ph->setPaymentJournal($payment_journal); $ph->setAmount($val); $ph->save(); } // activate all paid credit if ($this->hasRequestParameter('status[student_course]') && $this->getRequestParameter('status[student_course]') == 1) { $c = new Criteria(); $c->add(StudentCoursePeer::STUDENT_ID, $stu->getId()); $c->add(StudentCoursePeer::STATUS, StudentCourse::STATUS_APPROVED); $approved_scs = StudentCoursePeer::doSelect($c); foreach ($approved_scs as $asc) { $asc->setStatus(StudentCourse::STATUS_ACTIVE); $asc->save(); } } // change student status to active if ($this->hasRequestParameter('status[student]') && $this->getRequestParameter('status[student]') == Student::STATUS_ACTIVE) { $stu->setStatus(Student::STATUS_ACTIVE); $stu->setAcademicCalendarId($accal->getId()); $stu->save(); } return $this->redirect('student_course/list?student_id=' . $stu->getId()); }
public function executeGetAmount() { $ac_id = $this->getRequestParameter('academic_cost_id'); $ac = AcademicCostPeer::retrieveByPK($ac_id); $this->forward404Unless($ac); return $this->renderText("<input type='text' size='7' value='" . $ac->getAmount() . "' id='amount' name='amount'/>"); }
public function executeSaveElse() { $i18n = new sfI18N(); $i18n->initialize($this->getContext()); $i18n->setCulture($this->getUser()->getCulture()); $action_i18n = $i18n->globalMessageFormat->format('save as new'); $action_type = $this->getRequestParameter('action_type'); $student = StudentPeer::retrieveByPk($this->getRequestParameter('student_id')); $this->forward404Unless($student); $payment_journal = PaymentJournalPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($payment_journal); $is_new = false; $amount_changed = $this->getRequestParameter('paid'); $payment_journal->setId($this->getRequestParameter('id')); $payment_journal->setPayer($student->getId()); $payment_journal->setAcademicCostId($this->getRequestParameter('academic_cost_id')); $ac_cost = AcademicCostPeer::retrieveByPK($this->getRequestParameter('academic_cost_id')); $payment_journal->setAcademicProcessId($ac_cost->getAcademicProcessId()); $payment_journal->setMonth($this->getRequestParameter('month')); $payment_journal->setYear($this->getRequestParameter('year')); $payment_journal->setAmount($this->getRequestParameter('amount')); $payment_journal->setPaid($this->getRequestParameter('paid1') + $this->getRequestParameter('paid')); $payment_journal->setReceivable($this->getRequestParameter('receivable')); $payment_journal->setStatus($this->getRequestParameter('status')); $payment_journal->setComments($this->getRequestParameter('comments')); $payment_journal->setPaidAt($this->getRequestParameter('paid_at')); $payment_journal->setPayerType(PaymentJournal::PAYER_TYPE_STUDENT); $payment_journal->setPaymentModelId($this->getRequestParameter('payment_model_id')); $payment_journal->save(); if ($amount_changed != 0) { $ph = new PaymentHistory(); $ph->setPaymentJournal($payment_journal); $ph->setAmount($amount_changed); $ph->setReceivable($payment_journal->getReceivable()); $ph->setStatus($payment_journal->getStatus()); $ph->setAcademicCostId($payment_journal->getAcademicCostId()); $ph->setMonth($payment_journal->getMonth()); $ph->setCredit($payment_journal->getMonth()); $ph->save(); } return $this->redirect('student_payment/listElse?student_id=' . $student->getId()); }