public function savePaymentVoucher($pv_no = false, $pv_title = false, $pv_date = false, $pv_description = false, $pv_id = false) { $model = new LbPaymentVoucher(); //company $ownCompany = LbCustomer::model()->getOwnCompany(); $ownCompanyAddress = null; if ($ownCompany->lb_record_primary_key) { // auto assign owner company $model->lb_pv_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 $model->lb_pv_company_address_id = $ownCompanyAddress->lb_record_primary_key; } } if ($pv_id) { $model = LbPaymentVoucher::model()->findByPk($pv_id); } if ($pv_no) { $model->lb_payment_voucher_no = $pv_no; } if ($pv_title) { $model->lb_pv_title = $pv_title; } if ($pv_date) { $model->lb_pv_date = DateTime::createFromFormat('d-m-Y', $pv_date)->format('Y-m-d'); } if ($pv_date) { $model->lb_pv_description = $pv_description; } $model->lb_pv_create_by = Yii::app()->user->id; if ($pv_id) { $model->update(); return $pv_id; } if ($model->insert()) { return $model->lb_record_primary_key; } }
<?php /* * 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. */ $pv_no = LbPaymentVoucher::model()->createPVno(); $pv_date = date('d-m-Y'); $pv_title = false; $lb_pv_description = false; $creditBy = AccountProfile::model()->getFullName(Yii::app()->user->id); if (isset($_REQUEST['id'])) { $modelPV = LbPaymentVoucher::model()->findByPk($_REQUEST['id']); $pv_no = $modelPV['lb_payment_voucher_no']; $pv_date = DateTime::createFromFormat('Y-m-d', $modelPV['lb_pv_date'])->format('d-m-Y'); $pv_title = $modelPV['lb_pv_title']; $pv_create_by = $modelPV['lb_pv_create_by']; $lb_pv_description = $modelPV['lb_pv_description']; $creditBy = AccountProfile::model()->getFullName($modelPV['lb_pv_create_by']); } echo '<span>Fields with * are required.</span><br /><br />'; echo '<div class = "_form_pv">'; echo '<table>'; echo '<tr><td >' . Yii::t('lang', 'PV No*') . ':</td>' . '<td style="padding-left:10px;padding-right:200px"><input id = "pv_no" type = "text" value="' . $pv_no . '" /></td>'; echo '<td>' . Yii::t('lang', 'Date') . ':</td>' . '<td style="padding-left:10px;"><input type="text" id="pv_date" name="LbExpenses[lb_expenses_date]" value="' . $pv_date . '"><span style="display: none" id="LbExpenses_lb_expenses_date_em_" class="help-inline error"></span></td>' . '</tr>'; echo '<tr><td >' . Yii::t('lang', 'Title') . ':</td>' . '<td style="padding-left:10px;padding-right:200px"><input id="pv_title" type = "text" value="' . $pv_title . '" /></td>' . '<td>' . Yii::t('Create ', 'Create By') . ':</td>' . '<td style="padding-left:10px;"><input type = "text" value="' . $creditBy . '" /></td>' . '</tr>'; echo '<tr><td >' . Yii::t('lang', 'Description') . ':</td>' . '<td style="padding-left:10px;padding-right:200px"><textarea id="pv_description" type = "text" >' . $lb_pv_description . '</textarea></td>' . '</tr>'; echo '</table>'; echo '</div>'; ?>
public function totalExByVDInMonth($month = false, $year = false) { $paymentModel = LbPaymentVoucher::model()->findAll('YEAR(lb_pv_date) = ' . $year . ' AND MONTH(lb_pv_date) =' . $month); $total = 0; foreach ($paymentModel as $value) { $total += $this->getAmountExByPV($value->lb_record_primary_key); } return $total; }
echo '<div text-size="30px" style="font-size:16px;padding-top:24px;"><b>Payment Voucher</b></div>'; echo '<div style="margin-top:18px;">'; //from echo Yii::t('lang', 'From') . ':</td>'; echo ' '; echo '<input type="text" id="pv_date" name="LbExpenses[lb_expenses_date]" value="' . date('d-m-Y') . '"><span style="display: none" id="LbExpenses_lb_expenses_date_em_" class="help-inline error"></span>'; echo ' '; //to echo Yii::t('lang', 'To') . ':</td>'; echo ' '; echo '<input type="text" id="pv_date_to" name="LbExpenses[lb_expenses_date]" value="' . date('d-m-Y') . '"><span style="display: none" id="LbExpenses_lb_expenses_date_em_" class="help-inline error"></span>'; echo ' '; echo '<button class="btn" name="yt0" type="submit" onclick = "searchPV()" style="margin-top:-10px">Search</button>'; echo '</div><br/>'; echo '<div id ="list_payment_voucher">'; $this->widget('bootstrap.widgets.TbGridView', array('id' => 'payment_invoice_grid', 'type' => 'bordered', 'dataProvider' => LbPaymentVoucher::model()->search(), 'columns' => array(array('class' => 'CButtonColumn', 'template' => '{delete}', 'deleteButtonUrl' => 'CHtml::normalizeUrl(array("/lbExpenses/default/deletePaymentVoucher", "id"=>$data->lb_record_primary_key))', 'htmlOptions' => array('width' => '30'), 'headerHtmlOptions' => array('class' => 'lb-grid-header')), array('header' => Yii::t('lang', 'Date'), 'name' => 'lb_customer_id', 'type' => 'raw', 'id' => '$data->lb_record_primary_key', 'value' => '$data->lb_pv_date', 'htmlOptions' => array('width' => '120'), 'headerHtmlOptions' => array('class' => 'lb-grid-header')), array('header' => Yii::t('lang', 'Payment Voucher No'), 'type' => 'raw', 'value' => '($data->lb_payment_voucher_no) ? LBApplication::workspaceLink($data->lb_payment_voucher_no, YII::app()->baseUrl."/index.php/lbExpenses/default/CreatePaymentVoucher/id/".$data->lb_record_primary_key ) : LBApplication::workspaceLink("No customer", $data->getViewURL("No customer") )', 'htmlOptions' => array('width' => '180'), 'headerHtmlOptions' => array('class' => 'lb-grid-header')), array('header' => Yii::t('lang', 'Title'), 'type' => 'raw', 'value' => '$data->lb_pv_title', 'htmlOptions' => array('width' => '150'), 'headerHtmlOptions' => array('class' => 'lb-grid-header')), array('header' => Yii::t('lang', 'Description'), 'type' => 'raw', 'value' => '$data->lb_pv_description', 'htmlOptions' => array('width' => '250'), 'headerHtmlOptions' => array('class' => 'lb-grid-header')), array('header' => Yii::t('lang', 'Create By'), 'type' => 'raw', 'value' => 'AccountProfile::model()->getFullName($data->lb_pv_create_by)', 'htmlOptions' => array('style' => 'width: 80px;text-align:left;'), 'headerHtmlOptions' => array('class' => 'lb-grid-header'))))); echo '</div>'; ?> <script language="javascript"> $(document).ready(function(){ var from_date = $("#pv_date").datepicker({ format: 'dd-mm-yyyy' }).on('changeDate', function(ev) { from_date.hide(); }).data('datepicker'); var from_date = $("#pv_date_to").datepicker({ format: 'dd-mm-yyyy' }).on('changeDate', function(ev) { from_date.hide(); }).data('datepicker'); });
public function actiondeletePaymentVoucher($id) { LbPaymentVoucher::model()->deleteByPk($id); }
public function getTotalExpensesPrev($financial_year, $financial_prev_year) { $All_PV = LbPaymentVoucher::model()->getTotalPaymentPrev($financial_year, $financial_prev_year); foreach ($All_PV as $row) { $pvexpenses = LbPvExpenses::model()->findAll('lb_payment_voucher_id = ' . $row->lb_record_primary_key); $total = 0; foreach ($pvexpenses as $data) { $modelExpenses = LbExpenses::model()->find('lb_record_primary_key = ' . $data->lb_expenses_id); if ($modelExpenses) { $total += $modelExpenses->lb_expenses_amount; } } return $total; } }