/**
  * event function to add the invoice payment 
  * @param object $evctl
  */
 public function eventAjaxAddInvoicePayment(EventControler $evctl)
 {
     $err = false;
     $error_code = 0;
     if (trim($evctl->payment_date) == '') {
         $err = true;
         $error_code = 1;
     } elseif (trim($evctl->ref_num) == '') {
         $err = true;
         $error_code = 2;
     } elseif ((int) FieldType30::convert_before_save(trim($evctl->amount)) == 0) {
         $err = true;
         $error_code = 3;
     } elseif (true === $this->is_payment_more_than_due($evctl->idinvoice, FieldType30::convert_before_save(trim($evctl->amount)))) {
         $err = true;
         $error_code = 4;
     }
     if (true === $err) {
         echo $error_code;
     } else {
         $payment_date = FieldType9::convert_before_save($evctl->payment_date);
         $payment_mode = $evctl->payment_mode;
         $amount = FieldType30::convert_before_save($evctl->amount);
         $ref_num = CommonUtils::purify_input($evctl->ref_num);
         $additional_note = CommonUtils::purify_input($evctl->additional_note);
         $idinvoice = (int) $evctl->idinvoice;
         // add to paymentlog
         $do_paymentlog = new Paymentlog();
         $do_paymentlog->addNew();
         $do_paymentlog->date_added = $payment_date;
         $do_paymentlog->amount = $amount;
         $do_paymentlog->ref_num = $ref_num;
         $do_paymentlog->idpayment_mode = $payment_mode;
         $do_paymentlog->add();
         $idpaymentlog = $do_paymentlog->getInsertId();
         // add to invoice payment
         $this->addNew();
         $this->idinvoice = $idinvoice;
         $this->idpaymentlog = $idpaymentlog;
         $this->additional_note = $additional_note;
         $this->iduser = $_SESSION["do_user"]->iduser;
         $this->add();
         $qry = "\n\t\t\tselect * from `payment_mode` where `idpayment_mode` = ?\n\t\t\t";
         $stmt = $this->getDbConnection()->executeQuery($qry, array($evctl->payment_mode));
         $data = $stmt->fetch();
         $payment_mode_name = $data['mode_name'];
         $html = '';
         $html .= '<tr>';
         $html .= '<td>' . FieldType9::display_value($payment_date) . '</td>';
         $html .= '<td>' . FieldType30::display_value($amount) . '</td>';
         $html .= '<td>' . FieldType1::display_value($ref_num) . '</td>';
         $html .= '<td>' . FieldType1::display_value($payment_mode_name) . '</td>';
         $html .= '<td>' . _('charge') . '</td>';
         $html .= '<td>' . nl2br($additional_note) . '</td>';
         $html .= '</tr>';
         $invoice_payments = new InvoicePayments();
         $due_amount = FieldType30::display_value($invoice_payments->get_due_amount($idinvoice));
         echo json_encode(array('html' => $html, 'due_amount' => $due_amount));
     }
 }
Example #2
0
 echo '<div class="messages_unauthorized">';
 echo htmlentities($_SESSION['in_page_message']);
 if ($_SESSION['in_page_message_inv_amt_more'] == 'Yes') {
     $e_pay_mul = new Event("do_invoice->eventAddMultiPayment");
     $e_pay_mul->addParam('id', $_SESSION['do_invoice']->idinvoice);
     $e_pay_mul->addParam('contact', $_SESSION['do_invoice']->idcontact);
     $e_pay_mul->addParam('amt', $_SESSION['payment_amt']);
     $e_pay_mul->addParam('ref_num', $_SESSION['ref_num']);
     $e_pay_mul->addParam("goto", $_SERVER['PHP_SELF']);
     echo '<br />' . $e_pay_mul->getLink('Yes');
     $e_pay_cancel = new Event("do_invoice->eventCancelMultiPayment");
     echo '&nbsp;&nbsp;&nbsp;&nbsp;' . $e_pay_cancel->getLink('Cancel');
     $_SESSION['in_page_message_inv_amt_more'] = '';
 } elseif ($_SESSION['in_page_message_inv_mul_pay_del'] == 'Yes') {
     if (isset($_SESSION["in_page_message_inv_idpaymentlog"]) && $_SESSION["in_page_message_inv_idpaymentlog"] != '') {
         $do_paymentlog = new Paymentlog();
         $do_paymentlog->getMulInvoicesForPayment((int) $_SESSION["in_page_message_inv_idpaymentlog"]);
         $do_invoice_del = new Invoice();
         $do_contact = new Contact();
         echo '<div style="width:700px;margin-left:0px;margin-top:5px;height:30px;text-align:left;position: relative; color:#FFA500;font-size:14px;">';
         echo '<div style="width:100px;float:left;"><b>' . _('Number') . '</b></div>';
         echo '<div style="width:250px;float:left;"><b>' . _('Contact') . '</b></div>';
         echo '<div style="width:100px;float:left;"><b>' . _('Due Date') . '</b></div>';
         echo '<div style="width:100px;float:left;"><b>' . _('Total') . '</b></div>';
         echo '<div style="width:100px;float:left;"><b>' . _('Due') . '</b></div>';
         echo '</div>';
         echo '<div style="width:700px;margin-left:0px;margin-top:5px;height:30px;text-align:left;position: relative;font-size:12px;">';
         while ($do_paymentlog->next()) {
             $do_invoice_del->getId($do_paymentlog->idinvoice);
             echo '<div style="width:100px;float:left;">' . $do_invoice_del->num . ' </div> ';
             $contact = $do_contact->getContact_Company_ForInvoice($do_invoice_del->idcontact, $do_invoice_del->idcompany);