public function actionViewSupplier($id)
 {
     $modelVendorInvoice = LbVendorInvoice::model()->loadModel($id);
     $modelItemVendor = new LbVendorItem();
     $modelDiscountVendor = new LbVendorDiscount();
     $modelTax = new LbVendorTax();
     $modelTotal = LbVendorTotal::model()->getVendorTotal($id, LbVendorTotal::LB_VENDOR_INVOICE_TOTAL);
     $this->render('viewSupplier', array('model' => $modelVendorInvoice, 'modelItemVendor' => $modelItemVendor, 'modelDiscountVendor' => $modelDiscountVendor, 'modelTax' => $modelTax, 'modelTotal' => $modelTotal));
 }
示例#2
0
 public function actionAjaxUpdateTaxes($id, $type)
 {
     // Get all invoice discounts
     $invoice_taxes = LbVendorTax::model()->getTaxByVendor($id, $type, LbVendorTax::LB_QUERY_RETURN_TYPE_MODELS_ARRAY);
     // foreach invoice tax
     // get post description and value, then update it
     foreach ($invoice_taxes as $tax) {
         $item_id = $tax->lb_record_primary_key;
         // get POSTed values
         if (isset($_POST['lb_tax_name' . $item_id])) {
             // IMPORTANT: for tax item, description is the tax record id from lb_taxes table
             $tax_description = $_POST['lb_tax_name' . $item_id];
             $tax->lb_tax_name = $tax_description;
         }
         //echo $tax_description;
         if (isset($_POST['lb_vendor_tax_value' . $item_id])) {
             $tax_value_percent = $_POST['lb_vendor_tax_value' . $item_id];
             $tax->lb_vendor_tax_value = $tax_value_percent;
         }
         // save
         //            $tax->lb_invoice_item_quantity = 1; // always 1
         $tax->save();
     }
     // return totals
     if ($type == LbVendorTax::LB_VENDOR_ITEM_TYPE_TAX) {
         $invoiceTotals = LbVendorTotal::model()->getVendorTotal($id, LbVendorTotal::LB_VENDOR_ITEM_TYPE_TOTAL);
     } else {
         $invoiceTotals = LbVendorTotal::model()->getVendorTotal($id, LbVendorTotal::LB_VENDOR_INVOICE_TOTAL);
     }
     LBApplication::renderPlain($this, array('content' => CJSON::encode($invoiceTotals)));
 }
    echo number_format(LbVendorTotal::model()->getTotalVendorPaidByCustomer($data->lb_record_primary_key, "Total Paid"), 2);
    ?>
 | </span>
                <?php 
    echo Yii::t('lang', 'Total Due');
    ?>
: <span style="font-weight: normal"><?php 
    echo number_format(LbVendorTotal::model()->getTotalVendorByCustomer($data->lb_record_primary_key, "Total Due"), 2);
    ?>
</span>
            </div>
        </legend>
        <?php 
    $invoice_arr = LbVendorInvoice::model()->getInvoicePaidByCustomer($data->lb_record_primary_key);
    foreach ($invoice_arr as $data_invocie) {
        $invoice_total = LbVendorTotal::model()->find('lb_vendor_invoice_id=' . intval($data_invocie->lb_record_primary_key));
        //                echo '<pre>';
        //                print_r($invoice_total);
        ?>
        <h5 style="margin: 20px 0px 5px 0px;font-weight: bold;">
            <span>
                <input class="pdf_checkbox" name="<?php 
        echo $data_invocie->lb_record_primary_key;
        ?>
" type="checkbox" value="<?php 
        echo $data_invocie->lb_record_primary_key;
        ?>
" />
            </span>
            <span style="text-decoration: underline;">
                
示例#4
0
 function actionAjaxSavePayment()
 {
     $model = new LbPaymentVendor();
     if (isset($_POST['LbPaymentVendor'])) {
         $payment_arr = $_POST['LbPaymentVendor'];
         $model->lb_payment_vendor_no = LbPaymentVendor::model()->FormatPaymentVendorNo(LbPaymentVendor::model()->getPaymentVendorNextNum());
         $model->lb_payment_vendor_customer_id = $_POST['customer_id'];
         $model->lb_payment_vendor_method = $payment_arr['lb_payment_vendor_method'];
         $model->lb_payment_vendor_total = $_POST['total_payment'];
         $date1 = date_create($payment_arr['lb_payment_date']);
         $model->lb_payment_vendor_date = date_format($date1, 'Y-m-d');
         //$model->lb_invoice_id = $_POST[]
         if ($model->insert()) {
             //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 LbPaymentVendorInvoice();
                     $paymentItemModel->lb_payment_id = $model->lb_record_primary_key;
                     $paymentItemModel->lb_vendor_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()) {
                         $invoiceVendor = LbVendorTotal::model()->find('lb_vendor_invoice_id = ' . $paymentItemModel->lb_vendor_invoice_id);
                         $total = LbPaymentVendorInvoice::model()->calculateInvoicetotalPaid($paymentItemModel->lb_vendor_invoice_id);
                         $modelVI = LbVendorTotal::model()->findByPk($invoiceVendor['lb_record_primary_key']);
                         $modelVI->lb_vendor_last_paid = $total;
                         $modelVI->lb_vendor_last_outstanding = $modelVI->lb_vendor_last_tax - $total;
                         $modelVI->update();
                     }
                     echo '{"status":"success"}';
                 } else {
                     echo '{"status":"fail"}';
                 }
             }
         }
     }
 }
示例#5
0
 public function ajaxUpdateTaxes($lb_tax_name, $lb_tax_value, $key, $tax_id, $id, $type = false)
 {
     $tax = $this->findAllByPk($key);
     if ($type) {
         $pk = LbVendorTotal::model()->getIdVendorTotalByItem($id, LbVendorTotal::LB_VENDOR_ITEM_TYPE_TOTAL);
         $tax[0]->lb_vendor_id = $id;
         $tax[0]->lb_vendor_type = LbVendorTax::LB_VENDOR_ITEM_TYPE_TAX;
         $subtotal = LbVendorTotal::model()->find("lb_vendor_id = " . $id);
     } else {
         $pk = LbVendorTotal::model()->getIdVendorTotalByItem($id, LbVendorTotal::LB_VENDOR_INVOICE_TOTAL);
         $tax[0]->lb_vendor_invoice_id = $id;
         $tax[0]->lb_vendor_type = LbVendorTax::LB_VENDOR_INVOICE_ITEM_TYPE_TAX;
         $subtotal = LbVendorTotal::model()->find("lb_vendor_invoice_id = " . $id);
     }
     $totalManage = LbVendorTotal::model()->findByPk($pk);
     $tax[0]->lb_vendor_tax_value = $lb_tax_value;
     $tax[0]->lb_tax_name = $lb_tax_name;
     $tax[0]->lb_vendor_tax_id = $tax_id;
     $total = $subtotal['lb_vendor_total_last_discount'];
     $taxtotal = floatval($total * $lb_tax_value / 100);
     $tax[0]->lb_vendor_tax_total = $taxtotal;
     $tax[0]->save();
     //update last tax
     //update last tax
     if (isset($_GET['type'])) {
         $last_tax = LbVendorTotal::model()->getVendorTotal($id, LbVendorTotal::LB_VENDOR_ITEM_TYPE_TOTAL)->lb_vendor_total_last_discount + LbVendorTax::model()->calculateTax($id, LbVendorTax::LB_VENDOR_ITEM_TYPE_TAX);
     } else {
         $last_tax = LbVendorTotal::model()->getVendorTotal($id, LbVendorTotal::LB_VENDOR_INVOICE_TOTAL)->lb_vendor_total_last_discount + LbVendorTax::model()->calculateTax($id, LbVendorTax::LB_VENDOR_INVOICE_ITEM_TYPE_TAX);
     }
     $totalManage->lb_vendor_last_tax = $last_tax;
     $totalManage->lb_vendor_last_outstanding = $last_tax - $totalManage->lb_vendor_last_paid;
     $totalManage->update();
 }
示例#6
0
echo '<br>';
echo '<br>';
echo '<br>';
//Item
$modelItem = LbVendorItem::model()->findAll('lb_vendor_id=55');
if (count($modelItem) > 0) {
    $tItem = '<table border="1" style="width:100%;" cellpadding="0" cellspacing="0">';
    $tItem .= '<tr>' . '<td style="width:200px;height:30px">Item</td>' . '<td style="width:100px;">Quantity</td>' . '<td style="width:200px;">Price</td>' . '<td style="width:200px;">Total</td>' . '</tr>';
    foreach ($modelItem as $dataItem) {
        $tItem .= '<tr>' . '<td style="height:15px">' . $dataItem['lb_vendor_item_description'] . '</td>' . '<td>' . $dataItem['lb_vendor_item_quantity'] . '</td>' . '<td>' . $dataItem['lb_vendor_item_price'] . '</td>' . '<td>' . $dataItem['lb_vendor_item_amount'] . '</td>' . '</tr>';
    }
    $tItem .= '</table>';
    echo $tItem . '<br />';
}
//Total
$modelTotal = LbVendorTotal::model()->getVendorTotal($model->lb_record_primary_key, LbVendorTotal::LB_VENDOR_ITEM_TYPE_TOTAL);
//Discount
$discountItem = '<table border="0" style="width:100%;" cellpadding="0" cellspacing="0">';
$discountItem .= '<tr>' . '<td style="width:100px;"><b>Sub Total : </b></td>' . '<td style="border-bottom:1px solid black">$' . $modelTotal->lb_vendor_subtotal . '</td>' . '</tr>';
$discountAll = LbVendorDiscount::model()->findAll('lb_vendor_id = ' . $model->lb_record_primary_key);
if (count($discountAll) > 0) {
    $discountItem .= '<tr>' . '<td><b>Discount  </b></td>' . '</tr>';
    foreach ($discountAll as $valueDiscount) {
        $discountItem .= '<tr>' . '<td>' . $valueDiscount['lb_vendor_description'] . '</td>' . '<td>$' . $valueDiscount['lb_vendor_value'] . '</td>' . '</tr>';
    }
}
//tax
$TaxAll = LbVendorTax::model()->findAll('lb_vendor_id = ' . $model->lb_record_primary_key);
if (count($TaxAll) > 0) {
    $discountItem .= '<tr>' . '<td  ><b>Tax  </b></td>' . '<td style="border-top:1px solid black" ></td>' . '</tr>';
    foreach ($TaxAll as $valueTax) {
示例#7
0
 function updateTotal($lb_vendor_invoice_id = false, $discount, $tax)
 {
     $primary_key = LbVendorTotal::model()->find("lb_vendor_invoice_id = " . $lb_vendor_invoice_id);
     $total = LbVendorTotal::model()->findByPk($primary_key['lb_record_primary_key']);
     $subtotal = $total['lb_vendor_subtotal'];
     $total->lb_vendor_last_tax = $subtotal - $discount + $tax;
     $total->update();
 }
示例#8
0
 public function getVendorInvoiceMonth($month = false, $year = false)
 {
     $status = '("' . LbVendorInvoice::LB_VD_CODE_OPEN . '","' . LbVendorInvoice::LB_VD_CODE_OVERDUE . '")';
     $modelInvoiceVendor = LbVendorInvoice::model()->findAll('YEAR(lb_vd_invoice_date) = ' . $year . ' AND MONTH(lb_vd_invoice_date) =' . $month . ' AND lb_vd_invoice_status IN ' . $status);
     $total = 0;
     foreach ($modelInvoiceVendor as $value) {
         $total += LbVendorTotal::model()->totalOustanding(LbVendorTotal::LB_VENDOR_INVOICE_TOTAL, $value->lb_record_primary_key);
     }
     return $total;
 }
示例#9
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 LbVendorTotal::model()->getTotalVendorByCustomer($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;