public function actionInsertLineItem($id) { $vendorItem = new LbVendorItem(); $result = $vendorItem->addLineItemVendor($id, LbVendorItem::LB_VENDOR_INVOICE_ITEM_TYPE_LINE); if ($result) { $response = array(); $response['success'] = YES; $response['vendor_item_id'] = $result; LBApplication::renderPlain($this, array('content' => CJSON::encode($response))); } }
/******************************************************************************** * ============================= LINE ITEMS SECTION ============================= *******************************************************************************/ echo '<div id="container-invoice-line-items-section" style="margin-top: 30px">'; $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'lb-invoice-items-form', 'enableAjaxValidation' => false, 'type' => 'horizontal')); /** LineItem Grid's $data is LbInvoiceItem Each line item's fields (description, quantity, unit price and total) are marked by the line item's primary key. */ $itemVendor = $modelItemVendor->getItemByVendorInvoice($model->lb_record_primary_key, LbVendorItem::LB_VENDOR_INVOICE_ITEM_TYPE_LINE); //echo $itemVendor->lb_vendor_id; $itemLineVendor = LbVendorItem::model()->find('lb_vendor_invoice_id = ' . $model->lb_record_primary_key . ' AND lb_vendor_type = "LINE_INVOICE"'); if (count($itemLineVendor) == 0) { $itemManage = new LbVendorItem(); $itemManage->addLineItemVendor($model->lb_record_primary_key, LbVendorItem::LB_VENDOR_INVOICE_ITEM_TYPE_LINE); LbVendorTotal::model()->addTotalVendor($model->lb_record_primary_key, LbVendorTotal::LB_VENDOR_INVOICE_TOTAL); } $modelTotal = LbVendorTotal::model()->getVendorTotal($model->lb_record_primary_key, LbVendorTotal::LB_VENDOR_INVOICE_TOTAL); $grid_id = 'invoice-line-items-grid-' . $model->lb_record_primary_key; $this->widget('bootstrap.widgets.TbGridView', array('id' => $grid_id, 'type' => 'bordered', 'dataProvider' => $modelItemVendor->getItemByVendorInvoice($model->lb_record_primary_key, LbVendorItem::LB_VENDOR_INVOICE_ITEM_TYPE_LINE), 'columns' => array(array('header' => '#', 'type' => 'raw', 'value' => '1', 'htmlOptions' => array('style' => 'width: 10px; '), 'headerHtmlOptions' => array('class' => 'lb-grid-header')), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => "{delete}", 'deleteButtonUrl' => '"' . LbVendor::model()->getActionURLNormalized("ajaxDeleteItem") . '" . "?id={$data->lb_record_primary_key}"', 'afterDelete' => 'function(link,success,data){ if(success) { refreshTotals(); } } ', 'htmlOptions' => array('style' => 'width: 10px'), 'headerHtmlOptions' => array('class' => 'lb-grid-header')), array('header' => Yii::t('lang', 'Item'), 'type' => 'raw', 'value' => ' CHtml::activeTextArea($data,"lb_vendor_item_description", array("style"=>"width: 350px; border-top: none; border-left: none; border-right: none; box-shadow: none;", "class"=>"invoice-item-description lbinvoice-line-items", "name"=>"lb_vendor_item_description{$data->lb_record_primary_key}", "data_invoice_id"=>"{$data->lb_vendor_id}",