function actionAjaxSavePayment()
 {
     $model = new LbPayment();
     if (isset($_POST['LbPayment'])) {
         $payment_arr = $_POST['LbPayment'];
         $payment_arr = $_POST['LbPayment'];
         $model->lb_payment_no = LbPayment::model()->FormatPaymentNo(LbPayment::model()->getPaymentNextNum());
         $model->lb_payment_customer_id = $_POST['customer_id'];
         $model->lb_payment_method = $payment_arr['lb_payment_method'];
         $model->lb_payment_date = $payment_arr['lb_payment_date'];
         //$model->lb_payment_notes=$payment_arr['lb_payment_notes'];
         $model->lb_payment_total = $_POST['total_payment'];
         //$model->lb_invoice_id = $_POST[]
         if ($model->save()) {
             //LbPayment::model()->setPaymentNextNum();
             // save payment item
             $count_payment = count($_POST['payment_check']);
             $payment_invoice = $_POST['payment_check'];
             $payment_note = $_POST['payment_note'];
             $payment_item_amount = $_POST['payment'];
             for ($i = 0; $i < $count_payment; $i++) {
                 if ($payment_item_amount[$i] > 0) {
                     $paymentItemModel = new LbPaymentItem();
                     $paymentItemModel->lb_payment_id = $model->lb_record_primary_key;
                     $paymentItemModel->lb_invoice_id = $payment_invoice[$i];
                     $paymentItemModel->lb_payment_item_note = $payment_note[$i];
                     $paymentItemModel->lb_payment_item_amount = $payment_item_amount[$i];
                     if ($paymentItemModel->save()) {
                         $invoice_total = LbInvoiceTotal::model()->getInvoiceTotal($paymentItemModel->lb_invoice_id);
                         if ($invoice_total) {
                             $invoice_total->calculateInvoicetotalPaid($paymentItemModel->lb_invoice_id);
                             $total_outstanding = $invoice_total->calculateInvoiceTotalOutstanding();
                             if (isset($total_outstanding)) {
                                 //Update Status
                                 LbInvoice::model()->InvoiceUpdateStatus($payment_invoice[$i]);
                             }
                         }
                         echo '{"status":"success"}';
                     } else {
                         echo '{"status":"fail"}';
                     }
                 }
             }
         }
     }
 }
示例#2
0
								                border-top: none; border-left: none; border-right: none; box-shadow: none;",
                                                                 "id"=>"payment_{$data->lb_record_primary_key}",
                                                                 "disabled"=>"disabled",
                                            ))', 'htmlOptions' => array('style' => 'width: 130px;text-align: right; '), 'headerHtmlOptions' => array('class' => 'lb-grid-header')), array('header' => Yii::t('lang', 'Notes'), 'type' => 'raw', 'value' => 'CHtml::textArea("payment_note[]","",array(
                                                                 "style"=>"width: 250px; border-top: none; border-left: none; border-right: none; box-shadow: none;",
                                                                 "id"=>"payment_note_{$data->lb_record_primary_key}",
                                        ))', 'htmlOptions' => array('style' => 'width: 100px; '), 'headerHtmlOptions' => array('class' => 'lb-grid-header')))));
?>

<?php 
if (count($invoice->data)) {
    ?>
    <div style="width:100%;overflow:hidden;margin-bottom: 50px;text-align: right;font-weight: bold;">
        <div style="float:left;width:245px;">Total:</div>
        <div style="float:left;width:167px;" id="total_payment_amount"><?php 
    echo LbInvoiceTotal::model()->getTotalInvoiceByCustomer($customer_id);
    ?>
</div>
        <div style="float:left;width:189px;" id="div_total_payment">
            <?php 
    echo CHtml::textField('total_payment', '0.00', array('id' => 'total_payment', "style" => "width: 110px;text-align: right; padding-right: 0px; border-top: none;\n                                                                                 border-left: none; border-right: none; box-shadow: none;font-weight: bold;", "disabled" => "disabled"));
    ?>
        </div>
    </div>
<?php 
}
?>
<script>
    function TotalPaymentAmount(){
        var total_payment = 0;
        //var format_total_payment_amount =0;
示例#3
0
 /**
  * calculate tax total,
  * return total, but doesn't save to the database
  *
  * @return int invoice tax total
  *
  */
 public function calculateTaxTotal()
 {
     // get invoice total after discount
     $invoiceTotal = LbInvoiceTotal::model()->getInvoiceTotal($this->lb_invoice_id);
     if ($invoiceTotal) {
         $invoice_total_after_discounts = $invoiceTotal->lb_invoice_total_after_discounts;
         // tax is based on this total after discounts;
         $item_total = round(floatval($this->lb_invoice_item_quantity), 2) * round(floatval($this->lb_invoice_item_value) / 100, 2) * $invoice_total_after_discounts;
         $this->lb_invoice_item_total = $item_total;
     }
     return $this->lb_invoice_item_total;
 }
示例#4
0
<?php

/* @var $this LbInvoiceController */
/* @var $model LbInvoice */
/* @var $ownCompany LbCustomer */
$currency_name = LbGenera::model()->getGeneraSubscription()->lb_genera_currency_symbol;
$thousand = LbGenera::model()->getGeneraSubscription()->lb_thousand_separator;
$decimal = LbGenera::model()->getGeneraSubscription()->lb_decimal_symbol;
$strnum = new LbInvoiceTotal();
// Subtotal Invoice
$invoice_subtotal_arr = LbInvoiceTotal::model()->getInvoiceTotal($model->lb_record_primary_key);
// Discount Invoice
$invoice_discount_arr = LbInvoiceItem::model()->getInvoiceDiscounts($model->lb_record_primary_key, 'ModelArray');
$invoice_discount = "";
foreach ($invoice_discount_arr as $invoice_discount_row) {
    $invoice_discount .= '<tr><td>' . $invoice_discount_row['lb_invoice_item_description'] . ":" . '</td>
                <td>' . $currency_name . $strnum->adddotstring($invoice_discount_row['lb_invoice_item_total'], $thousand, $decimal) . '</td>
            </tr>';
}
//End Discount
// Tax Invoice
$invoice_tax_arr = LbInvoiceItem::model()->getInvoiceTaxes($model->lb_record_primary_key, 'ModelArray');
$invoice_tax = "";
foreach ($invoice_tax_arr as $invoice_tax_row) {
    $tax_arr = LbTax::model()->find('lb_record_primary_key=' . $invoice_tax_row['lb_invoice_item_description']);
    if ($tax_arr['lb_tax_value'] != null && $tax_arr['lb_tax_name'] != null) {
        $tax_name = 'Tax';
        if ($tax_arr['lb_tax_name'] != "") {
            $tax_name = $tax_arr['lb_tax_name'];
        }
        $invoice_tax .= '<tr>
示例#5
0
         $customer_id = false;
         $invoice_information = LbInvoiceTotal::model()->getInvoiceById($data->lb_record_primary_key);
         $invoiceTax = LbInvoiceItem::model()->getInvoiceTaxById($data->lb_record_primary_key, "TAX");
         $PDFGst .= '<tr>';
         $PDFGst .= '<td>' . $data->lb_invoice_date . '</td>';
         $PDFGst .= '<td>' . $data->lb_invoice_no . '</td>';
         $PDFGst .= '<td>';
         if ($data->lb_invoice_customer_id) {
             $customer_id = $data->lb_invoice_customer_id;
             $PDFGst .= LbCustomer::model()->customerInformation($customer_id)->attributes['lb_customer_name'];
         }
         $PDFGst .= '</td>';
         $invoiceValue = $invoiceValue + $invoice_information->lb_invoice_total_after_taxes;
         $PDFGst .= '<td>$' . $invoice_information->lb_invoice_total_after_taxes . '</td>';
         $PDFGst .= '<td>';
         $totalPaid = LbInvoiceTotal::model()->find('lb_invoice_id=' . intval($data->lb_record_primary_key));
         $AllPaid = $AllPaid + $totalPaid->lb_invoice_total_paid;
         $PDFGst .= $totalPaid->lb_invoice_total_paid;
         $PDFGst .= '</td>';
         $PDFGst .= '<td>';
         $PDFGst .= $totalPaid->lb_invoice_total_paid;
         $PDFGst .= '</td>';
         $invoiceDue = $invoiceDue + $totalPaid->lb_invoice_total_outstanding;
         $PDFGst .= '<td>$' . $totalPaid->lb_invoice_total_outstanding . '</td>';
         $PDFGst .= '</tr>';
     }
 }
 $PDFGst .= '</tbody>';
 $PDFGst .= '<tfoot><tr>
                             <td colspan="3"><b>Sub Total</b></td>
                     <td align="right" style="border-top:1px solid #000">
示例#6
0
 public function totalInvoiceOutstanding($status, $year = false)
 {
     $data = $this->getInvoiceByStatusAndYear($status, $year);
     $totalAmount = 0;
     foreach ($data as $value) {
         $totalModel = LbInvoiceTotal::model()->find('lb_invoice_id=' . intval($value['lb_record_primary_key']));
         if (count($totalModel) > 0) {
             $totalAmount += $totalModel->lb_invoice_total_outstanding;
         }
     }
     return $totalAmount;
 }
示例#7
0
 function actionajaxDeletePayment()
 {
     if (isset($_GET['id'])) {
         $payment_item_id = $_GET['id'];
     }
     //delete payment item
     $payment = LbPaymentItem::model()->deleteByPk($payment_item_id);
     $invoice_id = $_GET['invoice_id'];
     $invoiceTotal = LbInvoiceTotal::model()->getInvoiceTotal($invoice_id);
     $taxRecord['paid'] = $invoiceTotal->calculateInvoicetotalPaid($invoice_id);
     $taxRecord['outstanding'] = $invoiceTotal->calculateInvoiceTotalOutstanding();
     if ($invoiceTotal->calculateInvoiceTotalOutstanding() <= 0) {
         $taxRecord['status'] = 'I_PAID';
     } else {
         $taxRecord['status'] = 'Open';
     }
     //update invoice total
     //                if($payment->delete())
     //                    echo 'success';
     LBApplication::renderPlain($this, array('content' => CJSON::encode($taxRecord)));
 }
 public function actionCreateInvoice($id)
 {
     $model = LbContracts::model()->findByPk($id);
     //********* add new invoice *************/
     $invoiceModel = new LbInvoice();
     // get basic info to assign to this record
     $ownCompany = LbCustomer::model()->getOwnCompany();
     $ownCompanyAddress = null;
     $customerCompany = new LbCustomer();
     $customerCompany->lb_customer_name = 'Click to choose customer';
     // get own company address
     if ($ownCompany->lb_record_primary_key) {
         // auto assign owner company
         $invoiceModel->lb_invoice_company_id = $ownCompany->lb_record_primary_key;
         $own_company_addresses = LbCustomerAddress::model()->getActiveAddresses($ownCompany->lb_record_primary_key, $ownCompany::LB_QUERY_RETURN_TYPE_MODELS_ARRAY);
         if (count($own_company_addresses)) {
             $ownCompanyAddress = $own_company_addresses[0];
             // auto assign owner company's address
             $invoiceModel->lb_invoice_company_address_id = $ownCompanyAddress->lb_record_primary_key;
         }
     }
     // add infor customer in invoice
     $invoiceModel->lb_invoice_customer_id = $model->lb_customer_id;
     $invoiceModel->lb_invoice_customer_address_id = $model->lb_address_id;
     $invoiceModel->lb_invoice_attention_contact_id = $model->lb_contact_id;
     if ($invoiceModel->save()) {
         // Save Lien ket contract va invoice
         $contrctInvoiceModel = new LbContractInvoice();
         $contrctInvoiceModel->lb_contract_id = $model->lb_record_primary_key;
         $contrctInvoiceModel->lb_invoice_id = $invoiceModel->lb_record_primary_key;
         $contrctInvoiceModel->save();
         //Update invoice no vaf status I-OPEN
         $invoiceModel->confirm();
         // add invoice to database right away.
         // other fields will be updated on the invoice page later on
         $invoiceModel->saveUnconfirmed();
         //
         // == Prepare line items grid
         // add 1 line-item by default
         //
         $blankItem = new LbInvoiceItem();
         $blankItem->lb_invoice_id = $invoiceModel->lb_record_primary_key;
         $blankItem->lb_invoice_item_description = "Contract payment for contract " . $model->lb_contract_no . ", " . $model->lb_contract_type . ", for period " . $model->lb_contract_date_start . " to " . $model->lb_contract_date_end;
         $blankItem->lb_invoice_item_quantity = 1;
         $blankItem->lb_invoice_item_value = 0;
         $blankItem->lb_invoice_item_total = 0;
         $blankItem->lb_invoice_item_type = LbInvoiceItem::LB_INVOICE_ITEM_TYPE_LINE;
         $blankItem->save();
         // add tax
         $blankTax = new LbInvoiceItem();
         $default_tax = LbTax::model()->getDefaultTax();
         //$value_tax = ($default_tax->lb_tax_value/100) * $model->lb_contract_amount;
         $blankTax->lb_invoice_id = $invoiceModel->lb_record_primary_key;
         $blankTax->lb_invoice_item_description = $default_tax !== null ? $default_tax->lb_record_primary_key : 'Tax';
         $blankTax->lb_invoice_item_quantity = 1;
         $blankTax->lb_invoice_item_value = $default_tax !== null ? $default_tax->lb_tax_value : '0';
         $blankTax->lb_invoice_item_total = 0;
         $blankTax->lb_invoice_item_type = LbInvoiceItem::LB_INVOICE_ITEM_TYPE_TAX;
         $blankTax->save();
         $invoiceItemModel = new LbInvoiceItem('search');
         $invoiceItemModel->unsetAttributes();
         // clear any default values
         $invoiceItemModel->lb_invoice_id = $invoiceModel->lb_record_primary_key;
         // totals - create a blank total record, set everything to zero: subtotal, after disc, after tax, paid, outstanding....
         $invoiceTotal = new LbInvoiceTotal();
         $invoiceTotal->lb_invoice_id = $invoiceModel->lb_record_primary_key;
         $invoiceTotal->lb_invoice_revision_id = 0;
         // latest version
         $invoiceTotal->lb_invoice_subtotal = 0;
         $invoiceTotal->lb_invoice_total_after_discounts = 0;
         $invoiceTotal->lb_invoice_total_after_taxes = 0;
         $invoiceTotal->lb_invoice_total_outstanding = 0;
         $invoiceTotal->lb_invoice_total_paid = 0;
         $invoiceTotal->save();
         // == end items grid data prep
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         $invoiceDiscountModel = new LbInvoiceItem();
         $invoiceDiscountModel->lb_invoice_item_type = LbInvoiceItem::LB_INVOICE_ITEM_TYPE_DISCOUNT;
         $invoiceTaxModel = new LbInvoiceItem();
         $invoiceTaxModel->lb_invoice_item_type = LbInvoiceItem::LB_INVOICE_ITEM_TYPE_TAX;
         //*** End add invoice **/
         //LBApplication::redire(array('lbInvoice/default/view','id'=>$invoiceModel->lb_record_primary_key));
         $this->redirect(array('view', 'id' => $model->lb_record_primary_key));
     }
 }
 function actionAjaxCreateInvoice($id)
 {
     $model = $this->loadModel($id);
     $quotationItem = LbQuotationItem::model()->getquotationItems($id, 'ModelArray');
     $quotationDiscount = LbQuotationDiscount::model()->getQuotationDiscounts($id);
     $quotationTax = LbQuotationTax::model()->getTaxQuotation($id);
     $quotationTotal = LbQuotationTotal::model()->getQuotationTotal($id);
     $invoiceModel = new LbInvoice();
     $invoiceTotal = new LbInvoiceTotal();
     $invoice_number_int = LbInvoice::model()->getInvoiceNextNum();
     $invoiceModel->lb_invoice_no = LbInvoice::model()->formatInvoiceNextNumFormatted($invoice_number_int);
     $invoiceModel->lb_invoice_status_code = LbInvoice::LB_INVOICE_STATUS_CODE_OPEN;
     // invoice date
     $invoiceModel->lb_invoice_date = date('Y-m-d');
     $invoiceModel->lb_invoice_due_date = date('Y-m-d');
     // invoice group
     $invoiceModel->lb_invoice_group = LbInvoice::LB_INVOICE_GROUP_INVOICE;
     // invoice base64_decode
     $invoiceModel->lb_invoice_encode = LbInvoice::model()->setBase64_decodeInvoice();
     // invoice note
     $invoiceModel->lb_invoice_note = $model->lb_quotation_note;
     $invoiceModel->lb_invoice_company_id = $model->lb_company_id;
     $invoiceModel->lb_invoice_company_address_id = $model->lb_company_address_id;
     $invoiceModel->lb_invoice_customer_id = $model->lb_quotation_customer_id;
     $invoiceModel->lb_invoice_customer_address_id = $model->lb_quotation_customer_address_id;
     $invoiceModel->lb_invoice_attention_contact_id = $model->lb_quotation_attention_id;
     $invoiceModel->lb_quotation_id = $model->lb_record_primary_key;
     $invoiceModel->lb_invoice_subject = $model->lb_quotation_subject;
     // invoice internal note
     $invoiceModel->lb_invoice_internal_note = $model->lb_quotation_internal_note;
     if ($invoiceModel->save()) {
         // copy line item
         foreach ($quotationItem as $q_item) {
             $invoiceItemModel = new LbInvoiceItem();
             $invoiceItemModel->lb_invoice_id = $invoiceModel->lb_record_primary_key;
             $invoiceItemModel->lb_invoice_item_description = $q_item->lb_quotation_item_description;
             $invoiceItemModel->lb_invoice_item_quantity = $q_item->lb_quotation_item_quantity;
             $invoiceItemModel->lb_invoice_item_value = $q_item->lb_quotation_item_price;
             $invoiceItemModel->lb_invoice_item_total = $q_item->lb_quotation_item_total;
             $invoiceItemModel->lb_invoice_item_type = LbInvoiceItem::LB_INVOICE_ITEM_TYPE_LINE;
             $invoiceItemModel->save();
         }
         // copy tax item
         foreach ($quotationTax->data as $q_tax) {
             $invoiceTaxModel = new LbInvoiceItem();
             $invoiceTaxModel->lb_invoice_id = $invoiceModel->lb_record_primary_key;
             $invoiceTaxModel->lb_invoice_item_description = $q_tax->lb_quotation_tax_id;
             $invoiceTaxModel->lb_invoice_item_quantity = 1;
             $invoiceTaxModel->lb_invoice_item_value = $q_tax->lb_quotation_tax_value;
             $invoiceTaxModel->lb_invoice_item_total = $q_tax->lb_quotation_tax_total;
             $invoiceTaxModel->lb_invoice_item_type = LbInvoiceItem::LB_INVOICE_ITEM_TYPE_TAX;
             $invoiceTaxModel->save();
         }
         // copy discount item
         foreach ($quotationDiscount->data as $q_discount) {
             $invoiceDiscountModel = new LbInvoiceItem();
             $invoiceDiscountModel->lb_invoice_id = $invoiceModel->lb_record_primary_key;
             $invoiceDiscountModel->lb_invoice_item_description = $q_discount->lb_quotation_discount_description;
             $invoiceDiscountModel->lb_invoice_item_quantity = 1;
             $invoiceDiscountModel->lb_invoice_item_value = $q_discount->lb_quotation_discount_total;
             $invoiceDiscountModel->lb_invoice_item_total = $q_discount->lb_quotation_discount_total;
             $invoiceDiscountModel->lb_invoice_item_type = LbInvoiceItem::LB_INVOICE_ITEM_TYPE_DISCOUNT;
             $invoiceDiscountModel->save();
         }
         // Copy Total
         $invoiceTotal->lb_invoice_id = $invoiceModel->lb_record_primary_key;
         $invoiceTotal->lb_invoice_subtotal = $quotationTotal->lb_quotation_subtotal;
         $invoiceTotal->lb_invoice_total_after_discounts = $quotationTotal->lb_quotation_total_after_discount;
         $invoiceTotal->lb_invoice_total_after_taxes = $quotationTotal->lb_quotation_total_after_total;
         $invoiceTotal->lb_invoice_total_outstanding = $quotationTotal->lb_quotation_total_after_total;
         $invoiceTotal->lb_invoice_revision_id = 0;
         $invoiceTotal->save();
         // redirect Invoice
         //            $url_invoice = $model->customer ? LbInvoice::model()->getViewURL($model->customer->lb_customer_name,null,$invoiceModel->lb_record_primary_key) : LbInvoice::model()->getViewURL("No customer",null,$invoiceModel->lb_record_primary_key);
         //            $this->redirect($url_invoice);
     }
 }
示例#10
0
<?php

/* @var $this LbInvoiceController */
/* @var $model LbInvoice */
/* @var $ownCompany LbCustomer */
$currency_name = LbGenera::model()->getGeneraSubscription()->lb_genera_currency_symbol;
$thousand = LbGenera::model()->getGeneraSubscription()->lb_thousand_separator;
$decimal = LbGenera::model()->getGeneraSubscription()->lb_decimal_symbol;
$strnum = new LbInvoiceTotal();
// Subtotal Invoice
$invoice_subtotal_arr = LbInvoiceTotal::model()->getInvoiceTotal($model->lb_record_primary_key);
// LOGO
$company = $model->lb_vendor_company_id;
$folder = 'images/logo/';
$path = "./images/logo/";
$logo = "";
$filename = '';
$file_arr = array_diff(scandir($folder), array('.', '..'));
$subcription = LBApplication::getCurrentlySelectedSubscription();
foreach ($file_arr as $key => $file) {
    $file_name = explode('.', $file);
    $file_name_arr = explode('_', $file_name[0]);
    //                 print_r($file_name_arr);
    if ($file_name_arr[0] == $subcription && $file_name_arr[1] == $company) {
        $logo = "<img src='" . $path . $file . "' style='height:80' />";
    }
}
// if(count($file_arr)>0)
//{
$html_logo = '
            <tr>
示例#11
0
 public function getTotalInvoiceByMonth($year = false, $month = false)
 {
     $status = '("' . LbInvoice::LB_INVOICE_STATUS_CODE_OPEN . '","' . LbInvoice::LB_INVOICE_STATUS_CODE_OVERDUE . '")';
     $model = LbInvoice::model()->findAll('YEAR(lb_invoice_date) = ' . $year . ' AND MONTH(lb_invoice_date) =' . $month . ' AND lb_invoice_status_code IN ' . $status . '');
     $total = 0;
     foreach ($model as $value) {
         $totalArr = LbInvoiceTotal::model()->find('lb_invoice_id = ' . $value->lb_record_primary_key);
         $total += $totalArr->lb_invoice_total_outstanding;
     }
     return $total;
 }
示例#12
0
 public function getContractIdArrayOutstanding()
 {
     $criteria = new CDbCriteria();
     $dataProvider = LbContracts::model()->getFullRecordsDataProvider();
     $contract_id_arr = array();
     foreach ($dataProvider->data as $data) {
         $TotalAmountInvoice = LbInvoiceTotal::model()->getTotalAmountInvoiceByContract($data->lb_record_primary_key);
         if ($data->lb_contract_amount > $TotalAmountInvoice) {
             $contract_id_arr[] = $data->lb_record_primary_key;
         }
     }
     return $contract_id_arr;
 }
示例#13
0
文件: pdf.php 项目: nhuhtlb/linxbooks
<?php

$thousand = LbGenera::model()->getGeneraSubscription()->lb_thousand_separator;
$decimal = LbGenera::model()->getGeneraSubscription()->lb_decimal_symbol;
$strnum = new LbInvoiceTotal();
$method = LBPayment::model()->method;
$date_from = date('Y-m-d');
$date_to = date('Y-m-d', strtotime("+1 month -1 day"));
if (isset($_REQUEST['search_date_from']) && $_REQUEST['search_date_from'] != "") {
    $date_from = date('Y-m-d', strtotime($_REQUEST['search_date_from']));
}
if (isset($_REQUEST['search_date_to']) && $_REQUEST['search_date_to'] != "") {
    $date_to = date('Y-m-d', strtotime($_REQUEST['search_date_to']));
}
?>



<?php 
$country = LBApplicationUI::countriesDropdownData();
$html_logo = "";
$company = isset($model->owner) ? $model->lb_invoice_company_id : '';
$folder = 'images/logo/';
$path = "./images/logo/";
$logo = "";
$filename = '';
$file_arr = array_diff(scandir($folder), array('.', '..'));
$subcription = LBApplication::getCurrentlySelectedSubscription();
$logo = "";
foreach ($file_arr as $key => $file) {
    $file_name = explode('.', $file);
function tableSearch($customer_id_statements = false, $attention_statement = false, $address_option = false, $status = false, $date_from = false, $date_to = false)
{
    $outstanding = 0;
    $paid = 0;
    $tax = 0;
    global $valuePaid;
    global $valueAmount;
    global $valueDue;
    $StatementSearch = LbInvoice::model()->getInvoiceStatement($customer_id_statements, $_POST['attention_statement'], $address_option, $status, $date_from, $date_to);
    //    $addName = LbCustomerAddress::model()->find('lb_record_primary_key='.$address_option);
    //    echo '<span style="font-size: 16px;"><b>Address: </b>'.$addName->lb_customer_address_line_1.'</span><br />';
    if (count($StatementSearch) > 0) {
        if (isset($address_option)) {
            $addName = LbCustomerAddress::model()->find('lb_record_primary_key=' . $address_option);
        }
        echo '<span style="font-size: 16px;"><b>Address: </b>' . $addName->lb_customer_address_line_1 . '</span><br />';
        echo '
                                    <table border="0" width="100%" class="items table table-bordered">
                                    <thead>
                                    <tr>
                                        <th width="250" class="lb-grid-header">' . Yii::t('lang', 'Date') . '</th>
                                        <th width="150" class="lb-grid-header">' . Yii::t('lang', 'Invoice Number') . '</th>
                                        <th width="150" class="lb-grid-header">' . Yii::t('lang', 'Amount') . '</th>
                                        <th width="150" class="lb-grid-header">' . Yii::t('lang', 'Payments') . '</th>
                                        <th width="150" class="lb-grid-header">' . Yii::t('lang', 'Due') . '</th>


                                    </tr>
                                </thead>
                                 <tbody>';
        foreach ($StatementSearch as $data) {
            $getInvoiceById = LbInvoiceTotal::model()->getInvoiceById($data['lb_record_primary_key']);
            $addArr = LbInvoice::model()->findAll('lb_invoice_customer_address_id=' . $data['lb_invoice_customer_address_id']);
            $outstanding = $outstanding + $getInvoiceById['lb_invoice_total_outstanding'];
            $paid = $paid + $getInvoiceById['lb_invoice_total_paid'];
            $tax = $tax + $getInvoiceById['lb_invoice_total_after_taxes'];
            echo '<tr>';
            echo '<td>' . $data['lb_invoice_date'] . '</td>';
            echo '<td>' . $data['lb_invoice_no'] . '</td>';
            echo '<td>' . $getInvoiceById['lb_invoice_total_after_taxes'] . '</td>';
            echo '<td>' . $getInvoiceById['lb_invoice_total_paid'] . '</td>';
            echo '<td>' . $getInvoiceById['lb_invoice_total_outstanding'] . '</td>';
            echo '</tr>';
            $valuePaid = $valuePaid + $getInvoiceById['lb_invoice_total_paid'];
            $valueAmount = $valueAmount + $getInvoiceById['lb_invoice_total_after_taxes'];
            $valueDue = $valueDue + $getInvoiceById['lb_invoice_total_outstanding'];
        }
        echo '</tbody>' . '<tfoot>';
        echo '<tr>';
        echo '<td></td>';
        echo '<td></td>';
        echo '<td style="border-top:1px solid #000" ><b>$' . number_format($tax, 2) . '</b></td>';
        echo '<td style="border-top:1px solid #000"><b>$' . number_format($paid, 2) . '<b></td>';
        echo '<td style="border-top:1px solid #000"><b>$' . number_format($outstanding, 2) . '</b></td>';
        echo '</tr>' . '</tfoot>' . '</table>';
    }
}
                        
                    </tfoot>
  
                    <?php 
} else {
    $customer_arr = LbCustomer::model()->getCompanies($sort = 'lb_customer_name ASC', LbCustomer::LB_QUERY_RETURN_TYPE_MODELS_ARRAY);
    $invoiceValue = 0;
    $gst = 0;
    foreach ($customer_arr as $customer) {
        ?>
                            <tbody>
                            <?php 
        $a = LbInvoice::model()->getInvoiceMonth($customer['lb_record_primary_key'], $date_from, $date_to);
        foreach ($a as $data) {
            $customer_id = false;
            $invoice_information = LbInvoiceTotal::model()->getInvoiceById($data->lb_record_primary_key);
            $invoiceTax = LbInvoiceItem::model()->getInvoiceTaxById($data->lb_record_primary_key, "TAX");
            $invoiceValue = $invoiceValue + $invoice_information->lb_invoice_total_after_discounts;
            echo '<tr>';
            echo '<td>' . $data->lb_invoice_no . '</td>';
            echo '<td>' . $data->lb_invoice_date . '</td>';
            echo '<td>';
            if ($data->lb_invoice_customer_id) {
                $customer_id = $data->lb_invoice_customer_id;
                echo LbCustomer::model()->customerInformation($customer_id)->attributes['lb_customer_name'];
            }
            echo '</td>';
            echo '<td>$' . $invoice_information->lb_invoice_total_after_discounts . '</td>';
            echo '<td>';
            $totalTax = 0;
            if ($invoiceTax) {
示例#16
0
 $invoice_arr = LbInvoice::model()->getInvoiceByCustomerDate($data->lb_record_primary_key, $date_from);
 //$payment = $invoice_arr->customerAddress;
 $customer_name = $data->lb_customer_name;
 //                            echo $customer_name.'<br>';
 $total = 0;
 $i = count($invoice_arr);
 $j = 0;
 $total1 = 0;
 $total2 = 0;
 $total3 = 0;
 $total4 = 0;
 foreach ($invoice_arr as $data_invocie) {
     $j++;
     ?>
  <?php 
     $invoice_total = LbInvoiceTotal::model()->find('lb_invoice_id=' . intval($data_invocie->lb_record_primary_key));
     $lb_invoice = LbInvoice::model()->find('lb_record_primary_key=' . intval($data_invocie->lb_record_primary_key));
     $total = $invoice_total->getTotalInvoiceByCustomer($data->lb_record_primary_key);
     if ($total > 0) {
         if ($Time_Range_search == 0) {
             $PDFAging .= '<tbody>
                     <tr>';
             $PDFAging .= '<td >' . $data_invocie->lb_invoice_no . '</td>
                 <td style="text-align: left;">' . $lb_invoice->lb_invoice_date . '</td>
                 <td style="text-align: left;">';
             $dateNumber = dateNumber($currentDate, $lb_invoice->lb_invoice_date);
             if ($dateNumber >= 0 && $dateNumber <= 30) {
                 $PDFAging .= '$' . $invoice_total->lb_invoice_total_outstanding;
                 $total1 = $total1 + $invoice_total->lb_invoice_total_outstanding;
                 //                                echo $lb_invoice->lb_invoice_date;
             } else {
示例#17
0
 public function getInvoiceById($invoice_id = false)
 {
     $criteria = new CDbCriteria();
     if ($invoice_id) {
         $criteria->compare('lb_invoice_id', $invoice_id);
     }
     return LbInvoiceTotal::model()->find($criteria);
 }
示例#18
0
                        ' . (isset($modelAddress->lb_customer_address_line_2) && $modelAddress->lb_customer_address_line_2 != "" ? $modelAddress->lb_customer_address_line_2 . '. ' : '') . '
                        ' . (isset($modelAddress->lb_customer_address_city) && $modelAddress->lb_customer_address_city != "" ? $modelAddress->lb_customer_address_city . '. ' : '') . '
                        ' . (isset($modelAddress->lb_customer_address_state) && $modelAddress->lb_customer_address_state != "" ? $modelAddress->lb_customer_address_state . '. ' : '') . '
                        ' . (isset($modelAddress->lb_customer_address_country) ? $modelAddress->lb_customer_address_country . '&nbsp;&nbsp;' : '') . '
                        ' . (isset($modelAddress->lb_customer_address_postal_code) ? $modelAddress->lb_customer_address_postal_code : '') . '<br>
               ' . (isset($modelAddress->lb_customer_address_phone_1) ? "Phone: " . $modelAddress->lb_customer_address_phone_1 . "&nbsp;" : '') . '
               ' . (isset($modelAddress->lb_customer_address_fax) ? "Fax: " . $modelAddress->lb_customer_address_fax : '') . '<br>
               ' . (isset($modelAddress->lb_customer_address_email) ? "Email: " . $modelAddress->lb_customer_address_email : '') . '
            </td>
           
        </tr>';
$tblPV .= '</table>';
echo $tblPV . '<br /><br />';
//item expenses
$i = 0;
$strnum = new LbInvoiceTotal();
$thousand = LbGenera::model()->getGeneraSubscription()->lb_thousand_separator;
$decimal = LbGenera::model()->getGeneraSubscription()->lb_decimal_symbol;
$item_quotation_arr = LbPvExpenses::model()->findAll('lb_payment_voucher_id = ' . $model->lb_record_primary_key);
if (count($item_quotation_arr) > 0) {
    $tblEx = '<table border="1" style="margin:auto;width:100%;" cellpadding="0" cellspacing="0">';
    $tblEx .= '<tr>
                                        <td height="35" align="center" width="50">#</td>
                                        <td width="100"><b>Expenses Date</b></td>
                                        <td width="200"><b>Expenses No</b></td>
                                        <td width="100"><b>Expenses category</b></td>
                                        <td width="100"><b>Expenses note</b></td>
                                        
                                        <td  width="100"><b>Total</b></td>
                                        
                                    </tr>';