Esempio n. 1
0
 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());
 }