Exemple #1
0
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* @author Abhik Chakraborty
*/
$idmodule = (int) $_GET["idmodule"];
$sqcrm_record_id = (int) $_GET["sqrecord"];
$module_name = $modules_info[$idmodule]['name'];
$do_module_object = new $module_name();
$do_invoice_payments = new InvoicePayments();
$payments = $do_invoice_payments->get_invoice_payments($sqcrm_record_id);
$due_amount = FieldType30::display_value($do_invoice_payments->get_due_amount($sqcrm_record_id));
$payment_modes = $do_invoice_payments->get_payment_modes();
include_once 'view/plugin_view.php';
 /**
  * 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));
     }
 }
Exemple #3
0
// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* Invoice detail 
* @author Abhik Chakraborty
*/
$do_crmfields = new \CRMFields();
$do_block = new \Block();
$do_block->get_block_by_module($module_id);
$module_obj = new cpanel_invoice\Invoice();
$module_obj->getId($sqcrm_record_id);
$do_lineitems = new \Lineitems();
$do_lineitems->get_line_items($module_id, $sqcrm_record_id);
$lineitems = array();
if ($do_lineitems->getNumRows() > 0) {
    while ($do_lineitems->next()) {
        $lineitems[] = array("idlineitems" => $do_lineitems->idlineitems, "item_type" => $do_lineitems->item_type, "item_name" => $do_lineitems->item_name, "item_value" => $do_lineitems->item_value, "item_description" => $do_lineitems->item_description, "item_quantity" => $do_lineitems->item_quantity, "item_price" => $do_lineitems->item_price, "discount_type" => $do_lineitems->discount_type, "discount_value" => $do_lineitems->discount_value, "discounted_amount" => $do_lineitems->discounted_amount, "tax_values" => $do_lineitems->tax_values, "taxed_amount" => $do_lineitems->taxed_amount, "total_after_discount" => $do_lineitems->total_after_discount, "total_after_tax" => $do_lineitems->total_after_tax, "net_total" => $do_lineitems->net_total);
    }
}
// get Invoice payments
$do_invoice_payments = new \InvoicePayments();
$due_amount = $do_invoice_payments->get_due_amount($sqcrm_record_id, $module_obj->grand_total);
$payments = $do_invoice_payments->get_invoice_payments($sqcrm_record_id);
//updates detail, just add and last updated
$do_crmentity = new \CRMEntity();
$update_history = $do_crmentity->get_last_updates($sqcrm_record_id, $module_id, $module_obj);
if (isset($_GET['ajaxreq']) && $_GET['ajaxreq'] == true) {
    require_once 'view/detail_view_entry.php';
} else {
    require_once 'view/detail_view.php';
}