Esempio n. 1
0
 public function actionDelete($id)
 {
     $error = array();
     $constrac = LbContracts::model()->getContractCustomer($id);
     if (count($constrac) > 0) {
         throw new CHttpException(404, 'This customer has other records in the system, therefore, cannot be deleted. Please contact the Administrator.');
     } else {
         $this->loadModel($id)->delete();
     }
     // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
     if (!isset($_GET['ajax'])) {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
     }
 }
Esempio n. 2
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) {
Esempio n. 3
0
?>
            
            <div class="controls">
                <?php 
$this->widget('ext.rezvan.RDatePicker', array('name' => 'LbContracts[lb_contract_date_start]', '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('Date end', 'LbContracts_lb_contract_date_end', array('class' => 'control-label required'));
?>
            <div class="controls">
                <?php 
$data_renew_end = LbContracts::model()->getTimeOutContract($model->lb_record_primary_key);
$this->widget('ext.rezvan.RDatePicker', array('name' => 'LbContracts[lb_contract_date_end]', 'value' => $model->lb_contract_date_end ? date('Y-m-d', strtotime($data_renew_end)) : date('Y-m-d'), 'options' => array('format' => 'yyyy-mm-dd', 'viewformat' => 'yyyy-mm-dd', 'placement' => 'right', 'todayBtn' => true)));
?>
            </div>
        </div>
        
        <?php 
echo $form->textAreaRow($model, 'lb_contract_notes', array('rows' => '4', 'cols' => '40', 'style' => 'width:350px;'));
?>
        
        <?php 
echo $form->textFieldRow($model, 'lb_contract_amount', array('value' => $model->lb_contract_amount));
?>
<!--        <div class="control-group">
            <?php 
// echo CHtml::label('Attachments', 'LbContacts_lb_contract_date_end',array('class'=>'control-label required'));
Esempio n. 4
0
/* @var $documentModel lbContractDocument */
/* @var $form CActiveForm */
?>

<div class="form">

<?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'lb-contracts-form', 'enableAjaxValidation' => false, 'type' => 'horizontal', 'htmlOptions' => array('enctype' => 'multipart/form-data')));
?>
        <?php 
echo $customer_id;
?>
	<p class="note">Fields with <span class="required">*</span> are required.</p>

        <?php 
$ContractNo = LbContracts::model()->FormatContractNo(LbContracts::model()->getContractNextNum());
echo $form->textFieldRow($model, 'lb_contract_no', array('calss' => 'span4', 'value' => $ContractNo));
?>
        <?php 
$customer_arr = LbCustomer::model()->getCompanies($sort = 'lb_customer_name ASC', LbCustomer::LB_QUERY_RETURN_TYPE_DROPDOWN_ARRAY);
$option_customer = array("" => 'Choose Customer') + $customer_arr;
echo $form->dropDownListRow($model, 'lb_customer_id', $option_customer, array('onchange' => 'changeCustomer(this.value)'));
?>
        
        <?php 
$option_address = array(0 => 'Choose Address');
echo $form->dropDownListRow($model, 'lb_address_id', $option_address);
?>
        
        <?php 
$option_contact = array(0 => 'Choose Contract');
Esempio n. 5
0
 public function ActionAjaxUpdateStatusContract($id, $status_update)
 {
     $model = LbContracts::model()->findByPk($id);
     $model->lb_contract_status = $status_update;
     $model->save();
 }
Esempio n. 6
0
//$this->breadcrumbs=array(
//	'Lb Contracts'=>array('index'),
//	$model->lb_record_primary_key,
//);
//$this->menu=array(
//	array('label'=>'List LbContracts', 'url'=>array('index')),
//	array('label'=>'Create LbContracts', 'url'=>array('create')),
//	array('label'=>'Update LbContracts', 'url'=>array('update', 'id'=>$model->lb_record_primary_key)),
//	array('label'=>'Delete LbContracts', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->lb_record_primary_key),'confirm'=>'Are you sure you want to delete this item?')),
//	array('label'=>'Manage LbContracts', 'url'=>array('admin')),
//);
//
echo '<div id="lb-container-header">';
echo '<div class="lb-header-right" ><h3>Contracts</h3></div>';
echo '<div class="lb-header-left">';
LBApplicationUI::backButton(LbContracts::model()->getActionURLNormalized("dashboard"));
echo '&nbsp;';
$this->widget('bootstrap.widgets.TbButtonGroup', array('type' => '', 'buttons' => array(array('label' => '<i class="icon-plus"></i> ' . Yii::t('lang', 'New Contract'), 'url' => $this->createUrl('create'))), 'encodeLabel' => false));
echo '</div>';
echo '</div><Br>';
?>
<div style="overflow: hidden; clear: both;">
    <div style="float: left;width: 300px;"><h3 style="line-height:10px;">Contract: <?php 
echo $model->lb_contract_no;
?>
</h3></div>
   <div style="text-align: right;"><h3 style="line-height:10px;"><?php 
echo $model->customer->lb_customer_name;
?>
</h3></div>
</div>
Esempio n. 7
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;
 }
Esempio n. 8
0
 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));
     }
 }