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"}';
                     }
                 }
             }
         }
     }
 }
Example #2
0
        </div>
        <div class="control-group" id="form_contract_payment" style="display: none;">
                <fieldset >
                  <legend>Payment detail</legend>
                              <div class="control-group">
                                  <div class="control-label">Receipt No</div>
                                  <div class="controls" style="padding-top:5px;font-weight: bold;font-size: 18px;color: #6E8900"><?php 
echo LbPayment::model()->FormatPaymentNo(LbPayment::model()->getPaymentNextNum());
?>
</div>
                              </div>
                              <?php 
//echo $form->textFieldRow($model,'lb_payment_no',array('class'=>'span3','maxlength'=>255));
?>
                              <?php 
echo $form->dropDownListRow($paymentModel, 'lb_payment_method', LbPayment::model()->method);
?>
                              <div class="control-group" >
                                  <?php 
echo CHtml::label('Payment Date', 'message_messageDate', array('class' => 'control-label'));
?>
                                  <div class="controls">
                                      <?php 
$this->widget('ext.rezvan.RDatePicker', array('name' => 'LbPayment[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'));
?>
Example #3
0
//Permission Quotation
$quotation_canAdd = BasicPermission::model()->checkModules('lbQuotation', 'add');
$quotation_canView = BasicPermission::model()->checkModules('lbQuotation', 'view');
//Permission Bills
$bill_canAdd = BasicPermission::model()->checkModules('lbVendor', 'add');
$bill_canView = BasicPermission::model()->checkModules('lbVendor', 'view');
//Permission Report
$report_canView = BasicPermission::model()->checkModules('lbReport', 'view');
$home_img = CHtml::image(Yii::app()->request->baseUrl . '/images/logo_home.png', '', array('height' => 30, 'width' => 30, 'style' => "margin-top:-5px"));
?>
<div class="container" id="page">

<div id="lb-top-menu">
			<?php 
$ownCompany = LbCustomer::model()->getOwnCompany();
$this->widget('bootstrap.widgets.TbNavbar', array('brand' => false, 'brandUrl' => isset(Yii::app()->user) ? LbInvoice::model()->getActionURL('dashboard') : Yii::app()->createUrl('site/login'), 'items' => array(array('class' => 'bootstrap.widgets.TbMenu', 'items' => array()), array('class' => 'bootstrap.widgets.TbMenu', 'encodeLabel' => false, 'htmlOptions' => array('class' => 'pull-left'), 'items' => array(array('label' => $home_img, 'url' => LbInvoice::model()->getActionURL('dashboard')), array('label' => Yii::t('lang', 'Customers'), 'url' => LbCustomer::model()->getAdminURL(), 'visible' => !Yii::app()->user->isGuest && Modules::model()->checkHiddenModule('lbCustomer'), 'items' => array(array('label' => Yii::t('lang', '<i class="icon-plus"></i> New Customer'), 'url' => LbCustomer::model()->getCreateURL(), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $customer_canAdd), '---', array('label' => Yii::t('lang', 'All Customers'), 'url' => LbCustomer::model()->getAdminURL(), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $customer_canView), array('label' => Yii::t('lang', 'Contracts'), 'url' => LbContracts::model()->getActionURL('dashboard'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $customer_canView), array('label' => Yii::t('lang', 'My Company'), 'url' => LbCustomer::model()->getActionURLNormalized('view', array('id' => $ownCompany->lb_record_primary_key)), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $customer_canView))), array('label' => Yii::t('lang', 'Income'), 'url' => LbInvoice::model()->getActionURL('dashboard'), 'visible' => !Yii::app()->user->isGuest && Modules::model()->checkHiddenModule('lbInvoice'), 'items' => array(array('label' => Yii::t('lang', '<i class="icon-plus"></i> New Invoice'), 'url' => LbInvoice::model()->getCreateURLNormalized(array('group' => strtolower(LbInvoice::LB_INVOICE_GROUP_INVOICE))), 'visible' => $invoice_canAdd), array('label' => Yii::t('lang', '<i class="icon-plus"></i> New Quotation'), 'url' => LbQuotation::model()->getCreateURLNormalized(), 'visible' => $quotation_canAdd), array('label' => Yii::t('lang', '<i class="icon-plus"></i> Enter Payment'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'url' => LbPayment::model()->getCreateURLNormalized(), 'visible' => $quotation_canAdd), '---', array('label' => Yii::t('lang', 'Outstanding Invoices and Quotations'), 'linkOptions' => array('href' => LbInvoice::model()->getActionURL('dashboard'), 'data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'url' => LbInvoice::model()->getActionURL('dashboard'), 'visible' => $invoice_canView), array('label' => Yii::t('lang', 'All Invoices'), 'linkOptions' => array('href' => LbInvoice::model()->getActionURL('admin'), 'data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'url' => LbInvoice::model()->getActionURL('admin'), 'visible' => $invoice_canView), array('label' => Yii::t('lang', 'All Quotations'), 'linkOptions' => array('href' => LbQuotation::model()->getActionURL('admin'), 'data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'url' => LbQuotation::model()->getActionURL('admin'), 'visible' => $quotation_canView))), array('label' => Yii::t('lang', 'Expenses'), 'items' => array(array('label' => Yii::t('lang', 'All Expenses'), 'linkOptions' => array('href' => LbExpenses::model()->getActionURL('expenses'), 'data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'url' => LbExpenses::model()->getActionURL('expenses'), 'visible' => $expenses_canView), array('label' => Yii::t('lang', 'All Payment voucher'), 'linkOptions' => array('href' => LbExpenses::model()->getActionURL('paymentVoucher'), 'data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'url' => LbExpenses::model()->getActionURL('paymentVoucher'), 'visible' => $expenses_canView))), array('label' => Yii::t('lang', 'Bills'), 'url' => LbVendor::model()->getActionURL('dashboard'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => !Yii::app()->user->isGuest && Modules::model()->checkHiddenModule('lbVendor'), 'items' => array(array('label' => Yii::t('lang', 'Outstanding'), 'url' => LbVendor::model()->getActionURL('dashboard'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $bill_canView), array('label' => Yii::t('lang', 'Make Payment'), 'url' => LbVendor::model()->getActionModuleURL('vendor', 'addPayment'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $bill_canAdd))), array('label' => Yii::t('lang', 'Payroll'), 'url' => LbEmployee::model()->getActionURL('dashboard'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => !Yii::app()->user->isGuest && Modules::model()->checkHiddenModule('lbVendor'), 'items' => array(array('label' => Yii::t('lang', 'All Employees'), 'url' => LbEmployee::model()->getActionURL('dashboard'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $bill_canView), array('label' => Yii::t('lang', 'Make Payment'), 'url' => LbEmployee::model()->getActionURL('EnterPayment'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $bill_canAdd), array('label' => Yii::t('lang', 'All Payment'), 'url' => LbEmployee::model()->getActionURL('ListPayment'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $bill_canView))), array('label' => Yii::t('lang', 'Report'), 'url' => array('/lbReport/default/index'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => !Yii::app()->user->isGuest && Modules::model()->checkHiddenModule('lbReport'), 'items' => array(array('label' => Yii::t('lang', 'All'), 'url' => array('/lbReport/default/index?tab=all'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'Aging Report'), 'url' => array('/lbReport/default/index?tab=aging_report'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'Cash Receipt'), 'url' => array('/lbReport/default/index?tab=cash_receipt'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'Invoice Journal'), 'url' => array('/lbReport/default/index?tab=invoice_journal'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'GST Report'), 'url' => array('/lbReport/default/index?tab=gst_report'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'Sales Report'), 'url' => array('/lbReport/default/index?tab=sales_report'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'Customer Statement'), 'url' => array('/lbReport/default/index?tab=customer_statement'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'Employee Report'), 'url' => array('/lbReport/default/index?tab=employee_report'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'Payment Report'), 'url' => array('/lbReport/default/index?tab=payment_report'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView)))))), 'htmlOptions' => array('class' => 'navbar')));
?>
		</div>
    
<div id="lb-top-shortcuts">
        <?php 
$onwSubcriptAccount = AccountSubscription::model()->getSubscriptionOwnerID(LBApplication::getCurrentlySelectedSubscription());
$onwSubcrip = false;
if ($onwSubcriptAccount == Yii::app()->user->id) {
    $onwSubcrip = true;
}
$linx_app_menu_subscription_items = array();
$selected_subscription_label = 'Subscription';
if (!Yii::app()->user->isGuest) {
    $linx_app_account_subscriptions = AccountSubscription::model()->findSubscriptions(Yii::app()->user->id);
    foreach ($linx_app_account_subscriptions as $sub_id => $subscription) {
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//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')))));
Example #5
0
 /**
  * Tinh total invoice payment theo date year
  * @param date $year defaul nam hien tai
  * @return double $totalPayment
  * @access public
  */
 public function calculateInvoiceTotalPaymentByYear($year = false)
 {
     return LbPayment::model()->calculateTotalPayment($year);
 }
Example #6
0
 public function getPaymentTotalByMonth($year = false, $month = false)
 {
     $model = LbPayment::model();
     $paymentTotal = $model->findAll('YEAR(lb_payment_date) = ' . $year . ' AND MONTH(lb_payment_date) =' . $month);
     $total = 0;
     if (count($paymentTotal) > 0) {
         foreach ($paymentTotal as $data) {
             $total += $data->lb_payment_total;
         }
     }
     return $total;
 }
 function actionAjaxSavePaymentInvoice()
 {
     if (isset($_POST['id'])) {
         $model_invoice = LbInvoice::model()->findByPk($_POST['id']);
         $customer = $model_invoice->lb_invoice_customer_id;
     }
     $model = new LbPayment();
     $model->lb_payment_no = LbPayment::model()->FormatPaymentNo(LbPayment::model()->getPaymentNextNum());
     $model->lb_payment_customer_id = $customer;
     $model->lb_payment_method = 0;
     $model->lb_payment_date = date('Y-m-d');
     $model->lb_payment_total = 0;
     if ($model->save()) {
         $paymentItemModel = new LbPaymentItem();
         $paymentItemModel->lb_payment_id = $model->lb_record_primary_key;
         $paymentItemModel->lb_invoice_id = $_POST['id'];
         $paymentItemModel->lb_payment_item_amount = 0;
         if ($paymentItemModel->save()) {
             $response = array();
             $response['success'] = YES;
             $response['payment_no'] = $model->lb_payment_no;
             $response['lb_payment_id'] = $model->lb_record_primary_key;
             LBApplication::renderPlain($this, array('content' => CJSON::encode($response)));
         } else {
             echo '{"status":"fail"}';
         }
     }
 }
 $YStart = $arrDate[0];
 $MStart = $arrDate[1];
 $MEnd = dateMY($Todate)[1];
 $YEnd = dateMY($Todate)[0];
 $numberDate = $YStart . '-' . $MStart . '-' . numberDate($YStart, $MStart);
 $date_To = date('Y-m-d', strtotime($numberDate));
 $day = dateMY($FromDate)[2];
 $dayTo = dateMY($Todate)[2];
 $month = dateMY($FromDate)[1];
 $year = dateMY($FromDate)[0];
 $AmountMonth = 0;
 for ($i = 0; $i < 5; $i++) {
     if ($YStart == $YEnd && $MStart == $MEnd) {
         $PaymentAll = LbPayment::model()->getAllPayment($FromDate, $Todate, $customer_id, false, false, $i);
     } else {
         $PaymentAll = LbPayment::model()->getAllPayment($FromDate, $numberDate, $customer_id, false, false, $i);
     }
     if (count($PaymentAll) > 0) {
         $paymentAmount = 0;
         foreach ($PaymentAll as $data) {
             if (LbCustomer::model()->isCustomer($data->attributes['lb_payment_customer_id']) != null) {
                 $customer_information = LbCustomer::model()->find('lb_record_primary_key=' . intval($data->attributes['lb_payment_customer_id']));
                 $customer_name = $customer_information->lb_customer_name;
                 echo '<tr>';
                 echo '<td>' . $data->attributes['lb_payment_date'] . '</td>';
                 echo '<td>' . $customer_name . '</td>';
                 echo '<td>' . $data->attributes['lb_payment_notes'] . '</td>';
                 $payment_item = LbPaymentItem::model()->getAllPaymentInvoice($data->lb_record_primary_key);
                 echo '<td>';
                 foreach ($payment_item as $payment) {
                     //                                        echo $payment->lb_invoice_id;
Example #9
0
<?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"));
$customer_id = false;
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']));
}
if (isset($_REQUEST['customer']) && $_REQUEST['customer'] != 0) {
    $customer_id = $_REQUEST['customer'];
}
$a = LbInvoice::model()->getInvoiceMonth($customer_id, $date_from, $date_to);
$PDFGst = '<table border="0" style="margin:auto;width:100%;" cellpadding="0" cellspacing="0">' . '<tr><td>
            <table border="0" style="margin:auto;width:100%;" cellpadding="0" cellspacing="0">
            <tr><td >
             <span style="font-size:20px;font-weight:bold;">GST Report</span>
             
            </td></tr>
            </table>
            </td></tr>' . '<tr><td>
            <table border="0" style="margin:auto;width:100%;" cellpadding="0" cellspacing="0">
            <tr><td >
             <span style="margin:10px;padding:10px">From: ' . $date_from . '</span>
             <span style="margin:10px;">To: ' . $date_to . '</span>
Example #10
0
</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 = LbPaymentItem::model()->findAll('lb_invoice_id=' . intval($data_invocie->lb_record_primary_key));
        foreach ($paymentItem as $data_paymentItem) {
            $payment = LbPayment::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_method];
            ?>
</td>
                        <td style="text-align: center"><?php 
            echo $payment->lb_payment_date;
            ?>
</td>
                        <td><?php 
Example #11
0
                    </table>
                    </td>
                   
            </tr></table></td></tr>';
$a .= '<tr><td>
                    <table border="1" style="width:90%;margin-top:10px;" cellpadding="0" cellspacing="0">
                       <tr style="background-color:#ddd">
                                <td  style="width:20%;height:30px;">Receipt Nos</td>
                                <td height="40" style="width:20%">Amount Paid</td>
                                <td style="text-align:center;width:20%">Method</td>
                                <td style="width:20%">Data</td>
                                <td style="width:20%">Notes</td>
                        </tr>';
$data_paymentItem = LbPaymentItem::model()->findAll('lb_invoice_id=:invoice_id', array(':invoice_id' => $model->lb_record_primary_key));
foreach ($data_paymentItem as $payment_invoice) {
    $payment = LbPayment::model()->findByPk($payment_invoice->lb_payment_id);
    $a .= '<tr>              <td class="lb-grid" style="text-align: center">' . $payment->lb_payment_no . '</td>
                            <td class="lb-grid" style="text-align: right;">' . $strnum->adddotstring($payment_invoice->lb_payment_item_amount, $thousand, $decimal) . '</td>';
    if (isset($payment)) {
        $a .= '
                                
                                <td class="lb-grid" style="text-align: center">' . $method[$payment->lb_payment_method] . '</td>
                                <td style="text-align: center">' . date('d-M-Y', strtotime($payment->lb_payment_date)) . '</td>
                                <td width="200px">' . $payment_invoice->lb_payment_item_note . '</td>';
    }
    $a .= '</tr>';
}
$a .= '<tr>
                        <td height="20" style="text-align: left;color: #6E8900;float:right;"><span style="float: left;text-align: left;">Total Paid: </span>$' . $strnum->adddotstring($invoice_total->lb_invoice_total_paid, $thousand, $decimal) . '</td>
                        <td colspan="4" style="border-left: 0px;" ></td>
  
Example #12
0
                <a margin-top:-31px;; href="<?php 
echo $url_last;
?>
"><i class="icon-fast-forward"></i></a>
            </div>
            
            <?php 
echo '<div class="lb-header-left" style="margin-left:397px;margin-top:-15px;">';
// LBApplicationUI::backButton(LbInvoice::model()->getActionURLNormalized("dashboard"));
if ($expenses_id > 0) {
    LBApplicationUI::backButton(LbExpenses::model()->getActionURLNormalized('View', array('id' => $expenses_id)));
} else {
    LBApplicationUI::backButton(LbInvoice::model()->getActionURLNormalized("dashboard"));
}
echo '&nbsp;';
$this->widget('bootstrap.widgets.TbButtonGroup', array('type' => '', 'buttons' => array(array('label' => '<i class="icon-th-large"></i> Action', 'items' => array(array('label' => 'Email', 'url' => '#', 'linkOptions' => array('onclick' => 'onclickFormEmail();')), array('label' => 'Enter Payment', 'url' => LbPayment::model()->getCreateURLNormalized(array('id' => $model->lb_invoice_customer_id))), array('label' => 'Copy Invoice', 'url' => '#', 'linkOptions' => array('onclick' => 'onclickCopyInvoice();')), array('label' => 'Generate PDF', 'url' => LbInvoice::model()->getActionURL('pdf', array('id' => $model->lb_record_primary_key)), 'linkOptions' => array('target' => '_blank')), array('label' => 'Get Public URL', 'url' => '#', 'linkOptions' => array('onclick' => 'onclickFormGetPublicPDF();return false;'))))), 'encodeLabel' => false));
echo '</div>';
echo '</div>';
//echo AutoComplete::widget([
//    'model' => $model,
//    'attribute' => 'country',
//    'clientOptions' => [
//        'source' => ['USA', 'RUS'],
//    ],
//]);
echo '<div id="logo_wrapper" style="overflow:hidden;text-align: center;clear:bold;">';
$company = isset($model->owner) ? $model->lb_invoice_company_id : '';
$folder = 'images/logo/';
$path = YII::app()->baseUrl . "/images/logo/";
$filename = '';
$file_arr = array_diff(scandir($folder), array('.', '..'));
 public function actionRenew($id)
 {
     $contractModel = LbContracts::model()->findByPk($id);
     $documentModel = new LbContractDocument();
     $paymentModel = new LbPayment();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['LbContracts'])) {
         $LbContracts = $_POST['LbContracts'];
         $model = new LbContracts();
         $model->attributes = $_POST['LbContracts'];
         $model->lb_customer_id = $contractModel->lb_customer_id;
         $model->lb_address_id = $contractModel->lb_address_id;
         $model->lb_contact_id = $contractModel->lb_contact_id;
         $model->lb_contract_type = $contractModel->lb_contract_type;
         $model->lb_contract_status = LbContracts::LB_CONTRACT_STATUS_ACTIVE;
         $model->lb_contract_parent = $contractModel->lb_record_primary_key;
         if ($model->save()) {
             //********* Upload document *****************//
             $document = LbContractDocument::model()->getContractDocument($id);
             foreach ($document->data as $dataDocument) {
                 $documentModel = new LbContractDocument();
                 $documentModel->lb_contract_id = $model->lb_record_primary_key;
                 $documentModel->lb_document_url = $dataDocument->lb_document_url;
                 $documentModel->lb_document_name = $dataDocument->lb_document_name;
                 $documentModel->lb_document_url_icon = $dataDocument->lb_document_url_icon;
                 $documentModel->save();
                 // DONE
             }
             //**** End upload doxument ****//
             ///////////////////////////////////////////////////////////////////////////////
             //********* add new invoice *************/
             if (isset($LbContracts['check_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 = $contractModel->lb_customer_id;
                 $invoiceModel->lb_invoice_customer_address_id = $contractModel->lb_address_id;
                 $invoiceModel->lb_invoice_attention_contact_id = $contractModel->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 = $model->lb_contract_amount;
                     $blankItem->lb_invoice_item_total = $model->lb_contract_amount;
                     $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 = $model->lb_contract_amount;
                     $invoiceTotal->lb_invoice_total_after_discounts = $model->lb_contract_amount;
                     $invoiceTotal->lb_invoice_total_after_taxes = $model->lb_contract_amount;
                     $invoiceTotal->lb_invoice_total_outstanding = $model->lb_contract_amount;
                     $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 **/
                     ///////////////////////////////////////////////////////////////////////////////////////////////
                     //************** Add payment *************//
                     if (isset($LbContracts['payment_amount']) && $LbContracts['payment_amount'] != 0) {
                         $paymentModel = new LbPayment();
                         $paymentModel->attributes = $_POST['LbPayment'];
                         $paymentModel->lb_payment_customer_id = $contractModel->lb_customer_id;
                         $paymentModel->lb_payment_no = LbPayment::model()->FormatPaymentNo();
                         $paymentModel->lb_payment_total = $LbContracts['payment_amount'];
                         if ($paymentModel->save()) {
                             LbPayment::model()->setPaymentNextNum(LbPayment::model()->getPaymentNextNum());
                             $paymentItemModel = new LbPaymentItem();
                             $paymentItemModel->lb_payment_id = $paymentModel->lb_record_primary_key;
                             $paymentItemModel->lb_invoice_id = $invoiceModel->lb_record_primary_key;
                             $paymentItemModel->lb_payment_item_note = "";
                             $paymentItemModel->lb_payment_item_amount = $LbContracts['payment_amount'];
                             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 ($total_outstanding) {
                                         //Update Status
                                         LbInvoice::model()->InvoiceUpdateStatus($invoiceModel->lb_record_primary_key);
                                     }
                                 }
                                 echo "{succes}";
                             }
                         }
                     }
                 }
             }
             $contractModel->lb_contract_status = LbContracts::LB_CONTRACT_STATUS_HAS_RENEWED;
             $contractModel->save();
             $this->redirect(array('view', 'id' => $model->lb_record_primary_key));
         }
     }
     $customer_id = "";
     if (isset($_POST['customer_id'])) {
         $customer_id = $_POST['customer_id'];
     }
     $this->render('_form_renew', array('model' => $contractModel, 'paymentModel' => $paymentModel));
 }
Example #14
0
</h1>
            </div>
        </div>
</div>
<div class="col-lg" >
        <div class="panel-header-summary"><h4 >You have earned</h4></div>
        <div class="panel-body">
            <div class="info_content_summary">
                <h1>
                <?php 
if (strtotime($date_now) > strtotime($financial_year)) {
    echo $total_Payment = LbInvoice::CURRENCY_SYMBOL . number_format(LbPayment::model()->getTotalPaymentFinancial($financial_year, $financial_next_year), 2);
    //echo $total_Payment = LbInvoice::CURRENCY_SYMBOL.number_format(LbPayment::model()->getTotalPayment($financial_year,$financial_prev_year),2);
} else {
    // echo $total_Payment = LbInvoice::CURRENCY_SYMBOL.number_format(LbPayment::model()->getTotalPaymentFinancial($financial_year,$financial_next_year),2);
    echo $total_Payment = LbInvoice::CURRENCY_SYMBOL . number_format(LbPayment::model()->getTotalPayment($financial_year, $financial_prev_year), 2);
}
?>
</h1>
            </div>
        </div>
        <div class="panel-footer">financial year <?php 
echo date('d M Y', strtotime($financial_year));
?>
</div>
        <div>
            
        </div>
</div>

<div class="col-lg" >
Example #15
0
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'lb-employee-form', 'enableAjaxValidation' => false, 'type' => 'inline'));
// header container div
echo '<div id="invoice-header-container" class="container-header" style="position: relative">';
// ribbon to show status
//echo '<div class="ribbon-wrapper"><div class="ribbon-green">';
//echo LbInvoice::model()->getDisplayInvoiceStatus($model->lb_invoice_status_code);
//echo '</div></div>';
echo '<div id="lb-view-header">';
//            if(isset($model->lb_invoice_no)){
//                echo '<div class="lb-header-right"><h3><a style="color:#fff !important;" href="'.LbInvoice::model()->getActionURLNormalized("dashboard").'">'.$model->lb_invoice_no.'</a></h3></div>';
//            }else{
//                echo '<div class="lb-header-right"><h3><a style="color:#fff !important;" href="'.LbInvoice::model()->getActionURLNormalized("dashboard").'">Invoices</a></h3></div>';
//            }
echo '<div class="lb-header-right">';
echo '<h3><a style="color:#fff !important;" href="' . LbInvoice::model()->getActionURLNormalized("dashboard") . '"><span id="invoice_no_change">' . $model->lb_invoice_no . '</span></a></h3>';
$this->widget('bootstrap.widgets.TbMenu', array('htmlOptions' => array('class' => 'lb_icon_action'), 'items' => array(array('htmlOptions' => array('style' => 'background:rgb(91,183,91)'), 'label' => '<label class="lb_glyphicons-halflings lb_group_action"></label>', 'items' => array(array('label' => 'Email', 'url' => '#', 'linkOptions' => array('onclick' => 'onclickFormEmail();')), array('label' => 'Enter Payment', 'url' => LbPayment::model()->getCreateURLNormalized(array('id' => $model->lb_invoice_customer_id))), array('label' => 'Copy Invoice', 'url' => '#', 'linkOptions' => array('onclick' => 'onclickCopyInvoice();')), array('label' => 'Generate PDF', 'url' => LbInvoice::model()->getActionURL('pdf', array('id' => $model->lb_record_primary_key)), 'linkOptions' => array('target' => '_blank')), array('label' => 'Get Public URL', 'url' => '#', 'linkOptions' => array('onclick' => 'onclickFormGetPublicPDF();return false;'))))), 'encodeLabel' => false));
echo '<label class="lb_badge_status_left">' . LbInvoice::model()->getBadgeStatusView($model->lb_invoice_status_code) . '</label>';
//echo "<label id='show_link' onclick='show_link();' class='lb_glyphicons-halflings lb_group_action' ></label>";
echo '</div>';
## Next,Previous,Last,First ##########
$invoice_next = LbInvoice::model()->getMoveInvoiceNum($model->lb_invoice_no, "next");
$invoice_previous = LbInvoice::model()->getMoveInvoiceNum($model->lb_invoice_no, "previous");
$invoice_last = LbInvoice::model()->getMoveInvoiceNum($model->lb_invoice_no, "last");
$invoice_first = LbInvoice::model()->getMoveInvoiceNum($model->lb_invoice_no, "first");
$url_first = $invoice_first ? $model->getViewURLByIdNormalized($invoice_first[0], $invoice_first[1]) : '#';
$url_previous = $invoice_previous ? $model->getViewURLByIdNormalized($invoice_previous[0], $invoice_previous[1]) : '#';
$url_next = $invoice_next ? $model->getViewURLByIdNormalized($invoice_next[0], $invoice_next[1]) : '#';
$url_last = $invoice_last ? $model->getViewURLByIdNormalized($invoice_last[0], $invoice_last[1]) : '#';
?>

<div id="" class="lb-header-left lb-header-left_search" >
Example #16
0
 public function getTotalPaymentFinancial($financial_year = false, $financial_next_year = false)
 {
     $criteria = new CDbCriteria();
     //        if($financial_year)
     //            $criteria ->compare ('lb_payment_date >',$financial_year);
     //        if($financial_next_year)
     //            $criteria ->compare ('lb_payment_date <',$financial_next_year);
     if ($financial_year) {
         $criteria->addCondition("lb_payment_date > '" . $financial_year . "'", "AND");
     }
     if ($financial_next_year) {
         $criteria->addCondition("lb_payment_date <= '" . $financial_next_year . "'", "AND");
     }
     $paymentAll = LbPayment::model()->findAll($criteria);
     $totalPayment = 0;
     foreach ($paymentAll as $row) {
         $totalPayment += $row['lb_payment_total'];
     }
     return $totalPayment;
 }