public function totalPaymentVendorInMonth($month = false, $year = false) { $modelTest = LbPaymentVendor::model()->findAll('YEAR(lb_payment_vendor_date) = ' . $year . ' AND MONTH(lb_payment_vendor_date) =' . $month); $total = 0; foreach ($modelTest as $data) { $total += $data->lb_payment_vendor_total; } return $total; }
*/ //Da thu $total = array(); //Can thu $datatest = array(); //DA chi $datatest1 = array(); //Can chi $datatest2 = array(); $thang = array(); for ($i = 1; $i < 13; $i++) { //Da Thu $payment = LbPayment::model()->getPaymentTotalByMonth($year, $i); array_push($total, intval($payment)); //Can thu $oustanding_invoice = LbInvoice::model()->getTotalInvoiceByMonth($year, $i); array_push($datatest, intval($oustanding_invoice)); //Da chi=totalEx + totalVendor $totalExpenses = LbExpenses::model()->totalExByVDInMonth($i, $year); $totalVendor = LbPaymentVendor::model()->totalPaymentVendorInMonth($i, $year); array_push($datatest1, $totalExpenses + $totalVendor); //Can Chi $totalVendorInvoice = LbVendorInvoice::model()->getVendorInvoiceMonth($i, $year); $totalEx = LbExpenses::model()->getExByMonth($i, $year); array_push($datatest2, $totalVendorInvoice + $totalEx); array_push($thang, intval($i)); } $this->Widget('highcharts.HighchartsWidget', array('htmlOptions' => array(), 'options' => array('chart' => array('type' => 'column', 'colors' => array('#058DC7', '#5bb75b', '#ED561B', '#DDDF00')), 'yAxis' => array('title' => array('text' => '<b>$</b>'), 'style' => array('fontSize' => '14px')), 'xAxis' => array('title' => array('text' => '<b>Month</b>'), 'categories' => $thang, 'labels' => array('style' => array('fontSize' => '14px'))), 'plotOptions' => array('series' => array('pointWidth' => '13')), 'credits' => array('enabled' => false), 'series' => array(array('name' => 'Payment Received', 'data' => $total, 'stack' => 'male'), array('name' => 'Receivable', 'data' => $datatest, 'stack' => 'male'), array('name' => 'Bill Paid', 'data' => $datatest1, 'stack' => 'female'), array('name' => 'Payable', 'data' => $datatest2, 'stack' => 'female'))))); ?>
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"}'; } } } } }
</th> <th width="150" class="lb-grid-header"><?php echo Yii::t('lang', 'Date'); ?> </th> <th class="lb-grid-header"><?php echo Yii::t('lang', 'Notes'); ?> </th> </tr> </thead> <tbody> <?php $paymentItem = LbPaymentVendorInvoice::model()->findAll('lb_vendor_invoice_id=' . intval($data_invocie->lb_record_primary_key)); foreach ($paymentItem as $data_paymentItem) { $payment = LbPaymentVendor::model()->findByPk(intval($data_paymentItem->lb_payment_id)); ?> <tr> <td style="text-align: right"><?php echo number_format($data_paymentItem->lb_payment_item_amount, 2); ?> </td> <td style="text-align: center"><?php echo $method[$payment->lb_payment_vendor_method]; ?> </td> <td style="text-align: center"><?php echo $payment->lb_payment_vendor_date; ?> </td> <td><?php
<?php echo CHtml::label(Yii::t('lang', 'Supplier') . ' * ', 'customer_id', array('class' => 'control-label')); ?> <div class="controls"> <?php echo CHtml::dropDownList('customer_id', $customer_id, $option_customer, array('class' => 'span4', 'onchange' => 'load_invoice_by_customer(this.value);')); ?> </div> </div> <?php //echo $form->textFieldRow($model,'lb_payment_no',array('class'=>'span3','maxlength'=>255)); ?> <?php echo $form->dropDownListRow($model, 'lb_payment_vendor_method', LbPaymentVendor::model()->method); ?> <div class="control-group" > <?php echo CHtml::label(Yii::t('lang', 'Payment Date'), 'message_messageDate', array('class' => 'control-label')); ?> <div class="controls"> <?php $this->widget('ext.rezvan.RDatePicker', array('name' => 'LbPaymentVendor[lb_payment_date]', 'value' => date('Y/m/d'), 'options' => array('format' => 'yyyy/mm/dd', 'viewformat' => 'yyyy-mm-dd', 'placement' => 'right', 'todayBtn' => true))); ?> </div> </div> <!-- <div class="control-group" > <?php //echo CHtml::label('Payment Notes', 'LbPayment_lb_payment_notes', array('class'=>'control-label')); ?>
</div> <div class="panel-footer">financial year <?php echo date('d M Y', strtotime($financial_year)); ?> </div> <div> </div> </div> <div class="col-lg" > <div class="panel-header-summary"><h4 >You have spent</h4></div> <div class="panel-body"> <div class="info_content_summary"> <h1 style="color: #dd3d36"> <?php if (strtotime($date_now) > strtotime($financial_year)) { $total_Payment_bills = LbPaymentVendor::model()->getTotalPaymentNext($financial_year, $financial_next_year); $total_Payment_expenses = LbExpenses::model()->getTotalExpensesNext($financial_year, $financial_next_year); echo LbInvoice::CURRENCY_SYMBOL . number_format($total_Payment_bills + $total_Payment_expenses, 2); } else { $total_Payment_bills = LbPaymentVendor::model()->getTotalPaymentPrev($financial_year, $financial_prev_year); $total_Payment_expenses = LbExpenses::model()->getTotalExpensesPrev($financial_year, $financial_prev_year); echo LbInvoice::CURRENCY_SYMBOL . number_format($total_Payment_bills + $total_Payment_expenses, 2); } ?> </h1> </div> </div> </div>