Esempio n. 1
0
?>

<?php 
//$this->widget("TbBreadcrumbs", array("links" => $this->breadcrumbs))
?>
<div class="clearfix">
    <div class="btn-toolbar pull-left">
        <div class="btn-group">
        <?php 
$this->widget('bootstrap.widgets.TbButton', array('label' => Yii::t('D2fixrModule.crud', 'Create'), 'icon' => 'icon-plus', 'size' => 'large', 'type' => 'success', 'url' => array('create'), 'visible' => Yii::app()->user->checkAccess('D2finv.FixrFiitXRef.*') || Yii::app()->user->checkAccess('D2finv.FixrFiitXRef.Create')));
?>
</div>
        <div class="btn-group">
            <h1>
                <i class=""></i>
                <?php 
echo Yii::t('D2fixrModule.model', 'Fixr Fiit Xrefs');
?>
            </h1>
        </div>
    </div>
</div>

<?php 
Yii::beginProfile('FixrFiitXRef.view.grid');
?>


<?php 
$this->widget('TbGridView', array('id' => 'fixr-fiit-xref-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'template' => '{summary}{pager}{items}{pager}', 'pager' => array('class' => 'TbPager', 'displayFirstAndLast' => true), 'columns' => array(array('class' => 'CLinkColumn', 'header' => '', 'labelExpression' => '$data->itemLabel', 'urlExpression' => 'Yii::app()->controller->createUrl("view", array("fixr_id" => $data["fixr_id"]))'), array('class' => 'editable.EditableColumn', 'name' => 'fixr_id', 'editable' => array('url' => $this->createUrl('/d2fixr/fixrFiitXRef/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fixr_fiit_id', 'editable' => array('type' => 'select', 'url' => $this->createUrl('/d2fixr/fixrFiitXRef/editableSaver'), 'source' => CHtml::listData(FiitInvoiceItem::model()->findAll(array('limit' => 1000)), 'fiit_id', 'itemLabel'))), array('class' => 'editable.EditableColumn', 'name' => 'fixr_position_fret_id', 'editable' => array('type' => 'select', 'url' => $this->createUrl('/d2fixr/fixrFiitXRef/editableSaver'), 'source' => CHtml::listData(FretRefType::model()->findAll(array('limit' => 1000)), 'fret_id', 'itemLabel'))), array('class' => 'editable.EditableColumn', 'name' => 'fixr_period_fret_id', 'editable' => array('type' => 'select', 'url' => $this->createUrl('/d2fixr/fixrFiitXRef/editableSaver'), 'source' => CHtml::listData(FrepRefPeriod::model()->findAll(array('limit' => 1000)), 'frep_id', 'itemLabel'))), array('class' => 'editable.EditableColumn', 'name' => 'fixr_fcrn_date', 'editable' => array('type' => 'date', 'url' => $this->createUrl('/d2fixr/fixrFiitXRef/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fixr_fcrn_id', 'editable' => array('type' => 'select', 'url' => $this->createUrl('/d2fixr/fixrFiitXRef/editableSaver'), 'source' => CHtml::listData(FcrnCurrency::model()->findAll(array('limit' => 1000)), 'fcrn_id', 'itemLabel'))), array('class' => 'editable.EditableColumn', 'name' => 'fixr_amt', 'editable' => array('url' => $this->createUrl('/d2fixr/fixrFiitXRef/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fixr_base_fcrn_id', 'editable' => array('type' => 'select', 'url' => $this->createUrl('/d2fixr/fixrFiitXRef/editableSaver'), 'source' => CHtml::listData(FcrnCurrency::model()->findAll(array('limit' => 1000)), 'fcrn_id', 'itemLabel'))), array('class' => 'TbButtonColumn', 'buttons' => array('view' => array('visible' => 'Yii::app()->user->checkAccess("D2finv.FixrFiitXRef.View")'), 'update' => array('visible' => 'FALSE'), 'delete' => array('visible' => 'Yii::app()->user->checkAccess("D2finv.FixrFiitXRef.Delete")')), 'viewButtonUrl' => 'Yii::app()->controller->createUrl("view", array("fixr_id" => $data->fixr_id))', 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("delete", array("fixr_id" => $data->fixr_id))', 'viewButtonOptions' => array('data-toggle' => 'tooltip'), 'deleteButtonOptions' => array('data-toggle' => 'tooltip')))));
Yii::endProfile('FixrFiitXRef.view.grid');
Esempio n. 2
0
 protected function beforeDelete()
 {
     $criteria = new CDbCriteria();
     $criteria->compare('t.fiit_finv_id', $this->finv_id);
     $fiits = FiitInvoiceItem::model()->findAll($criteria);
     foreach ($fiits as $fiit) {
         $fiit->delete();
     }
     return parent::beforeDelete();
 }
Esempio n. 3
0
 /**
  * create record with default values
  * @param type $fiit_id
  * @return boolean
  * @throws CHttpException
  */
 public function addRecord($fiit_id)
 {
     $fiit = FiitInvoiceItem::model()->findByPk($fiit_id);
     if (!$fiit) {
         throw new CHttpException(400, 'Invalid fiit_id value: ' . $fiit_id);
     }
     //calculate amt
     $sql = " \n                SELECT \n                    SUM(fixr_amt) as amt_sum \n                FROM \n                    fixr_fiit_x_ref \n                WHERE \n                    fixr_fiit_id = " . $fiit_id;
     $fixr_sum = Yii::app()->db->createCommand($sql)->queryScalar();
     //create fixr record
     $model = new FixrFiitXRef();
     $model->fixr_fiit_id = $fiit_id;
     $model->fixr_fcrn_date = $fiit->fiitFinv->finv_date;
     $model->fixr_fcrn_id = $fiit->fiitFinv->finv_fcrn_id;
     $model->fixr_base_fcrn_id = $fiit->fiitFinv->finv_basic_fcrn_id;
     $model->fixr_amt = $fiit->fiit_amt - $fixr_sum;
     //save
     try {
         if ($model->save()) {
             return TRUE;
         } else {
             throw new CHttpException(500, var_export($model->getErrors()));
         }
     } catch (Exception $e) {
         throw new CHttpException(500, $e->getMessage());
     }
 }
            ');
}
if (!$ajax || $ajax == 'fiit-invoice-item-grid') {
    Yii::beginProfile('fiit_fqnt_id.view.grid');
    ?>

<h3 class="rel_grid">    
    <?php 
    echo Yii::t('D2finvModule.model', 'Fiit Invoice Item');
    ?>
    <?php 
    $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'ajaxButton', 'type' => 'primary', 'size' => 'mini', 'icon' => 'icon-plus', 'url' => array('//d2finv/fiitInvoiceItem/ajaxCreate', 'field' => 'fiit_fqnt_id', 'value' => $modelMain->primaryKey, 'ajax' => 'fiit-invoice-item-grid'), 'ajaxOptions' => array('success' => 'function(html) {$.fn.yiiGridView.update(\'fiit-invoice-item-grid\');}'), 'htmlOptions' => array('title' => Yii::t('D2finvModule.crud_static', 'Add new record'), 'data-toggle' => 'tooltip')));
    ?>
</h3> 
 
<?php 
    if (empty($modelMain->fiitInvoiceItems)) {
        $model = new FiitInvoiceItem();
        $model->fiit_fqnt_id = $modelMain->primaryKey;
        $model->save();
        unset($model);
    }
    $model = new FiitInvoiceItem();
    $model->fiit_fqnt_id = $modelMain->primaryKey;
    // render grid view
    $this->widget('TbGridView', array('id' => 'fiit-invoice-item-grid', 'dataProvider' => $model->search(), 'template' => '{summary}{items}', 'summaryText' => '&nbsp;', 'htmlOptions' => array('class' => 'rel-grid-view'), 'columns' => array(array('class' => 'editable.EditableColumn', 'name' => 'fiit_finv_id', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//d2finv/fiitInvoiceItem/editableSaver'), 'source' => CHtml::listData(FinvInvoice::model()->findAll(array('limit' => 1000)), 'finv_id', 'itemLabel'))), array('class' => 'editable.EditableColumn', 'name' => 'fiit_desc', 'editable' => array('type' => 'textarea', 'url' => $this->createUrl('//d2finv/fiitInvoiceItem/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fiit_debet_facn_code', 'editable' => array('url' => $this->createUrl('//d2finv/fiitInvoiceItem/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fiit_credit_facn_code', 'editable' => array('url' => $this->createUrl('//d2finv/fiitInvoiceItem/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fiit_fprc_id', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//d2finv/fiitInvoiceItem/editableSaver'), 'source' => CHtml::listData(FprcProductCategory::model()->findAll(array('limit' => 1000)), 'fprc_id', 'itemLabel'))), array('class' => 'editable.EditableColumn', 'name' => 'fiit_quantity', 'editable' => array('url' => $this->createUrl('//d2finv/fiitInvoiceItem/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fiit_price', 'editable' => array('url' => $this->createUrl('//d2finv/fiitInvoiceItem/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fiit_amt', 'editable' => array('url' => $this->createUrl('//d2finv/fiitInvoiceItem/editableSaver'))), array('class' => 'TbButtonColumn', 'buttons' => array('view' => array('visible' => 'FALSE'), 'update' => array('visible' => 'FALSE'), 'delete' => array('visible' => 'Yii::app()->user->checkAccess("D2finv.FqntQuantity.DeletefiitInvoiceItems")')), 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("/d2finv/fiitInvoiceItem/delete", array("fiit_id" => $data->fiit_id))', 'deleteButtonOptions' => array('data-toggle' => 'tooltip')))));
    ?>

<?php 
    Yii::endProfile('FiitInvoiceItem.view.grid');
}
            ');
}
if (!$ajax || $ajax == 'fixr-fiit-xref-grid') {
    Yii::beginProfile('fixr_fret_id.view.grid');
    ?>

<h3 class="rel_grid">    
    <?php 
    echo Yii::t('D2finvModule.model', 'Fixr Fiit Xref');
    ?>
    <?php 
    $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'ajaxButton', 'type' => 'primary', 'size' => 'mini', 'icon' => 'icon-plus', 'url' => array('//d2finv/fixrFiitXRef/ajaxCreate', 'field' => 'fixr_fret_id', 'value' => $modelMain->primaryKey, 'ajax' => 'fixr-fiit-xref-grid'), 'ajaxOptions' => array('success' => 'function(html) {$.fn.yiiGridView.update(\'fixr-fiit-xref-grid\');}'), 'htmlOptions' => array('title' => Yii::t('D2finvModule.crud', 'Add new record'), 'data-toggle' => 'tooltip')));
    ?>
</h3> 
 
<?php 
    if (empty($modelMain->fixrFiitXRefs)) {
        $model = new FixrFiitXRef();
        $model->fixr_fret_id = $modelMain->primaryKey;
        $model->save();
        unset($model);
    }
    $model = new FixrFiitXRef();
    $model->fixr_fret_id = $modelMain->primaryKey;
    // render grid view
    $this->widget('TbGridView', array('id' => 'fixr-fiit-xref-grid', 'dataProvider' => $model->search(), 'template' => '{summary}{items}', 'summaryText' => '&nbsp;', 'htmlOptions' => array('class' => 'rel-grid-view'), 'columns' => array(array('class' => 'editable.EditableColumn', 'name' => 'fixr_fiit_id', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//d2finv/fixrFiitXRef/editableSaver'), 'source' => CHtml::listData(FiitInvoiceItem::model()->findAll(array('limit' => 1000)), 'fiit_id', 'itemLabel'))), array('class' => 'editable.EditableColumn', 'name' => 'fixr_ref_id', 'editable' => array('url' => $this->createUrl('//d2finv/fixrFiitXRef/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fuxr_fcrn_date', 'editable' => array('type' => 'date', 'url' => $this->createUrl('//d2finv/fixrFiitXRef/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fuxr_fcrn_id', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//d2finv/fixrFiitXRef/editableSaver'), 'source' => CHtml::listData(FcrnCurrency::model()->findAll(array('limit' => 1000)), 'fcrn_id', 'itemLabel'))), array('class' => 'editable.EditableColumn', 'name' => 'fuxr_amt', 'editable' => array('url' => $this->createUrl('//d2finv/fixrFiitXRef/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fuxr_base_fcrn_id', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//d2finv/fixrFiitXRef/editableSaver'), 'source' => CHtml::listData(FcrnCurrency::model()->findAll(array('limit' => 1000)), 'fcrn_id', 'itemLabel'))), array('class' => 'editable.EditableColumn', 'name' => 'fixr_base_amt', 'editable' => array('url' => $this->createUrl('//d2finv/fixrFiitXRef/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fixr_start_date', 'editable' => array('type' => 'date', 'url' => $this->createUrl('//d2finv/fixrFiitXRef/editableSaver'))), array('class' => 'TbButtonColumn', 'buttons' => array('view' => array('visible' => 'FALSE'), 'update' => array('visible' => 'FALSE'), 'delete' => array('visible' => 'Yii::app()->user->checkAccess("D2finv.FretRefType.DeletefixrFiitXRefs")')), 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("/d2finv/fixrFiitXRef/delete", array("fixr_id" => $data->fixr_id))', 'deleteButtonOptions' => array('data-toggle' => 'tooltip')))));
    ?>

<?php 
    Yii::endProfile('FixrFiitXRef.view.grid');
}
Esempio n. 6
0
 /**
  * recalc totals
  */
 public function recalcInvoice($finv_id)
 {
     $this->unsetAttributes();
     $this->finv_id = $finv_id;
     $this->refresh();
     $this->finv_amt = 0;
     $this->finv_total = 0;
     $this->finv_vat = 0;
     $criteria = new CDbCriteria();
     $criteria->compare('t.fiit_finv_id', $finv_id);
     //$fiit_model = new FiitInvoiceItem();
     //$fiit_model->setAttribute('fiit_finv_id', $finv_id);
     $fiits = FiitInvoiceItem::model()->findAll($criteria);
     foreach ($fiits as $fiit) {
         $fiit->fiit_amt = round($fiit->fiit_price * $fiit->fiit_quantity, 2);
         $fiit->fiit_total = $fiit->fiit_amt;
         $fiit->fiit_vat = 0;
         try {
             if (!$fiit->save()) {
                 $this->addError('fiit_id', 'Can not update fiit item');
                 return FALSE;
             }
         } catch (Exception $e) {
             $this->addError('', $e->getMessage());
             return FALSE;
         }
         $this->finv_amt += $fiit->fiit_amt;
         $this->finv_total += $fiit->fiit_total;
         $this->finv_vat += $fiit->fiit_vat;
     }
     $this->finv_basic_amt = Yii::app()->currency->convertToBase($this->finv_amt, $this->finv_fcrn_id, $this->finv_date);
     $this->finv_basic_total = Yii::app()->currency->convertToBase($this->finv_total, $this->finv_fcrn_id, $this->finv_date);
     $this->finv_basic_vat = Yii::app()->currency->convertToBase($this->finv_vat, $this->finv_fcrn_id, $this->finv_date);
     try {
         if (!$this->save()) {
             $this->addError('finv_id', 'Can not update finv record');
             return FALSE;
         }
     } catch (Exception $e) {
         $this->addError('finv_id', $e->getMessage());
         return FALSE;
     }
     return TRUE;
 }
 public function loadModel($id)
 {
     $m = FiitInvoiceItem::model();
     // apply scope, if available
     $scopes = $m->scopes();
     if (isset($scopes[$this->scope])) {
         $m->{$this->scope}();
     }
     $model = $m->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('FinvModule.crud_static', 'The requested page does not exist.'));
     }
     return $model;
 }
    $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'ajaxButton', 'type' => 'primary', 'size' => 'mini', 'icon' => 'icon-plus', 'url' => array('//d2finv/fiitInvoiceItem/ajaxCreate', 'field' => 'fiit_finv_id', 'value' => $modelMain->primaryKey, 'ajax' => 'fiit-invoice-item-grid'), 'ajaxOptions' => array('success' => 'function(html) {$.fn.yiiGridView.update(\'fiit-invoice-item-grid\');}'), 'htmlOptions' => array('title' => Yii::t('D2finvModule.crud_static', 'Add new record'), 'data-toggle' => 'tooltip')));
    echo '&nbsp;';
    ?>
    </div>
    <?php 
    //if no items add emty record
    if (empty($modelMain->fiitInvoiceItems)) {
        $model = new FiitInvoiceItem();
        $model->fiit_finv_id = $modelMain->primaryKey;
        $model->save();
        //only for items total
        $finv = $model->fiitFinv;
        unset($model);
    } else {
        $finv = $modelMain;
    }
    $model = new FiitInvoiceItem();
    $model->fiit_finv_id = $modelMain->primaryKey;
    // render grid view
    $this->widget('TbGridView', array('id' => 'fiit-invoice-item-grid', 'dataProvider' => $model->search(), 'template' => '{summary}{items}', 'summaryText' => '&nbsp;', 'htmlOptions' => array('class' => 'rel-grid-view'), 'columns' => array(array('class' => 'editable.EditableColumn', 'name' => 'fiit_desc', 'editable' => array('type' => 'textarea', 'url' => $this->createUrl('//d2finv/fiitInvoiceItem/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fiit_price', 'htmlOptions' => array('class' => 'numeric-column'), 'editable' => array('url' => $this->createUrl('//d2finv/fiitInvoiceItem/editableSaver'), 'success' => 'function(response, newValue) {
                        $.fn.yiiGridView.update(\'fiit-invoice-item-grid\')
                    }')), array('class' => 'editable.EditableColumn', 'name' => 'fiit_quantity', 'htmlOptions' => array('class' => 'numeric-column'), 'editable' => array('url' => $this->createUrl('//d2finv/fiitInvoiceItem/editableSaver'), 'success' => 'function(response, newValue) {
                        $.fn.yiiGridView.update(\'fiit-invoice-item-grid\')
                    }')), array('class' => 'editable.EditableColumn', 'name' => 'fiit_fqnt_id', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//d2finv/fiitInvoiceItem/editableSaver'), 'source' => CHtml::listData(FqntQuantity::model()->findAll(array('limit' => 1000)), 'fqnt_id', 'itemLabel'))), array('class' => 'editable.EditableColumn', 'name' => 'fiit_fvat_id', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//d2finv/fiitInvoiceItem/editableSaver'), 'source' => CHtml::listData(FvatVat::model()->findAll(), 'fvat_id', 'itemLabel'), 'success' => 'function(response, newValue) {
                        $.fn.yiiGridView.update(\'fiit-invoice-item-grid\')
                    }'), 'footer' => Yii::t('D2finvModule.model', 'Total') . ':', 'footerHtmlOptions' => array('class' => 'total-row')), array('name' => 'fiit_amt', 'htmlOptions' => array('class' => 'numeric-column'), 'footer' => $finv->finv_amt, 'footerHtmlOptions' => array('class' => 'numeric-column total-row')), array('name' => 'fiit_vat', 'htmlOptions' => array('class' => 'numeric-column'), 'footer' => $finv->finv_vat, 'footerHtmlOptions' => array('class' => 'numeric-column total-row')), array('name' => 'fiit_total', 'htmlOptions' => array('class' => 'numeric-column'), 'footer' => $finv->finv_total, 'footerHtmlOptions' => array('class' => 'numeric-column total-row')), array('class' => 'TbButtonColumn', 'buttons' => array('view' => array('visible' => 'FALSE'), 'update' => array('visible' => 'FALSE'), 'delete' => array('visible' => 'Yii::app()->user->checkAccess("D2finv.FinvInvoice.DeletefiitInvoiceItems")')), 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("/d2finv/fiitInvoiceItem/delete", array("fiit_id" => $data->fiit_id))', 'deleteButtonOptions' => array('data-toggle' => 'tooltip'), 'afterDelete' => 'function() {$.fn.yiiGridView.update("fiit-invoice-item-grid");}'))));
    ?>

    <?php 
    Yii::endProfile('fiit_finv_id.view.grid');
}