示例#1
0
 /**
  * get or create record for table
  * @param int $fret_id - ref type (first dimension level)
  * @param int $ref_id - refernce table record id
  * @param string $code 
  * @param string $name
  * @return type
  */
 public static function getDim3Id($fret_id, $fdm2_id, $ref_id, $code, $name = false)
 {
     if (!$name) {
         $name = $code;
     }
     //search existing record
     $criteria = new CDbCriteria();
     $criteria->compare('fdm3_sys_ccmp_id', Yii::app()->sysCompany->getActiveCompany());
     $criteria->compare('fdm3_fret_id', $fret_id);
     $criteria->compare('fdm3_fdm2_id', $fdm2_id);
     $criteria->compare('fdm3_ref_id', $ref_id);
     if ($fdm3 = Fdm3Dimension3::model()->find($criteria)) {
         return $fdm3->fdm3_id;
     }
     $fret = FretRefType::model()->findByPk($fret_id);
     //add record
     $fdm3 = new Fdm3Dimension3();
     $fdm3->fdm3_fret_id = $fret_id;
     $fdm3->fdm3_ref_id = $ref_id;
     $fdm3->fdm3_fdm1_id = $fret->fret_fdm1_id;
     $fdm3->fdm3_fdm2_id = $fdm2_id;
     $fdm3->fdm3_code = substr($code, 0, 10);
     $fdm3->fdm3_name = $name;
     $fdm3->save();
     return $fdm3->primaryKey;
 }
示例#2
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');
示例#3
0
 public function beforeDelete()
 {
     //delete all in fret defined related records
     $model_fret = FretRefType::model()->findAll();
     foreach ($model_fret as $fret) {
         $criteria = new CDbCriteria();
         $criteria->compare($fret->fret_model_fixr_id_field, $this->fixr_id);
         $ref_model = new $fret->fret_model();
         foreach ($ref_model->findAll($criteria) as $ref) {
             $ref->delete();
         }
     }
     //delete related recrd from FddaDimData
     $criteria = new CDbCriteria();
     $criteria->compare('fdda_fixr_id', $this->fixr_id);
     //$fdda = FddaDimData::model()->findAll($criteria);
     foreach (FddaDimData::model()->findAll($criteria) as $fdda) {
         $fdda->delete();
     }
     return parent::beforeDelete();
 }
 /**
  * Service Subform & Save
  * @param type $fret_id
  * @param type $fixr_id
  */
 public function actionShowPositionSubForm($fret_id, $fixr_id)
 {
     if (empty($fret_id)) {
         $fret_id = Yii::app()->request->getPost('fret_id');
     }
     if (empty($fret_id)) {
         return;
     }
     //get model form detqails
     $model_fret = FretRefType::model()->findByPk($fret_id);
     $form_model_name = $model_fret->fret_model;
     $form_model_ref_field = $model_fret->getRefIdFIeldName();
     //search model form record
     $model_fixr = FixrFiitXRef::model()->findByPk($fixr_id);
     $criteria = new CDbCriteria();
     $criteria->compare($model_fret->fret_model_fixr_id_field, $fixr_id);
     $form_model = new $form_model_name();
     $form_model = $form_model->find($criteria);
     if (!$form_model) {
         $form_model = new $form_model_name();
     }
     //submited form
     $post_form = Yii::app()->request->getPost($form_model_name);
     if (!empty($post_form)) {
         if (!$model_fixr) {
             return false;
         }
         //select postion or period
         if ($model_fret->fret_controller_action == 'FixrFiitXRef/popupPosition') {
             $model_fixr->fixr_position_fret_id = $fret_id;
         } else {
             $model_fixr->fixr_period_fret_id = $fret_id;
         }
         if (!$model_fixr->save()) {
             print_r($model_fixr->getErrors());
             exit;
         }
         $form_model->scenario = $this->scenario;
         $form_model_pk_name = $form_model->tableSchema->primaryKey;
         if (isset($post_form[$form_model_pk_name])) {
             $form_model_pk_value = $post_form[$form_model_pk_name];
             $form_model = $form_model->findByPk($form_model_pk_value);
         }
         $form_model->attributes = $post_form;
         $form_model->{$form_model_ref_field} = $fixr_id;
         try {
             if ($form_model->save()) {
                 //if period, do postion save() for full calculation
                 if ($model_fret->fret_controller_action != 'FixrFiitXRef/popupPosition') {
                     $model_fixr->afterSaveUpdateRelatedModels();
                 }
                 echo 'ok';
                 return;
             }
         } catch (Exception $e) {
             $form_model->addError($form_model->tableSchema->primaryKey, $e->getMessage());
         }
     }
     //show form
     $cs = Yii::app()->clientScript;
     $cs->reset();
     $cs->scriptMap = array('jquery.js' => false, 'jquery.min.js' => false);
     echo $this->renderPartial('/subform/' . $model_fret->fret_view_form, array('model' => $form_model, 'fixr_id' => $fixr_id, 'fret_id' => $fret_id), true, true);
 }
示例#5
0
$this->setPageTitle(Yii::t('D2fixrModule.model', 'DIM 2 List') . ' - ' . $fdm1->fdm1_name);
$breadcrumbs = array(Yii::t('D2fixrModule.model', 'Home') => array('fdm1Dimension1/admin'), $fdm1->fdm1_name);
$this->widget("TbD2Breadcrumbs", array("links" => $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', 'fdm1_id' => $fdm1->fdm1_id), 'visible' => Yii::app()->user->checkAccess('D2fixr.Fdm2Dimension2.*') || Yii::app()->user->checkAccess('D2fixr.Fdm2Dimension2.Create')));
?>
</div>
        <div class="btn-group">
            <h1>
                <i class=""></i>
                <?php 
echo $fdm1->fdm1_name;
?>
            </h1>
        </div>
    </div>
</div>

<?php 
Yii::beginProfile('Fdm2Dimension2.view.grid');
$find_all_param = array('order' => 'fret_label', 'condition' => "fret_controller_action = 'FixrFiitXRef/popupPosition'");
$fret_data = FretRefType::model()->findAll($find_all_param);
$this->widget('TbGridView', array('id' => 'fdm2-dimension2-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'template' => '{items}{pager}', 'pager' => array('class' => 'TbPager', 'displayFirstAndLast' => true), 'columns' => array(array('class' => 'editable.EditableColumn', 'name' => 'fdm2_name', 'editable' => array('url' => $this->createUrl('/d2fixr/fdm2Dimension2/editableSaver'), 'placement' => 'right')), array('class' => 'editable.EditableColumn', 'name' => 'fdm2_fret_id', 'editable' => array('type' => 'select', 'url' => $this->createUrl('/d2fixr/fdm2Dimension2/editableSaver'), 'source' => CHtml::listData($fret_data, 'fret_id', 'itemLabel'))), array('name' => 'fdm2_ref_id', 'htmlOptions' => array('class' => 'numeric-column')), array('class' => 'editable.EditableColumn', 'name' => 'fdm2_hidden', 'editable' => array('url' => $this->createUrl('/d2fixr/fdm2Dimension2/editableSaver')), 'htmlOptions' => array('class' => 'numeric-column')), array('header' => 'DIM 3', 'type' => 'raw', 'value' => 'CHtml::link("OPEN", array("fdm3Dimension3/admin","fdm2_id" => $data->fdm2_id))'), array('class' => 'TbButtonColumn', 'buttons' => array('view' => array('visible' => 'FALSE'), 'update' => array('visible' => 'FALSE'), 'delete' => array('visible' => 'Yii::app()->user->checkAccess("D2fixr.Fdm2Dimension2.Delete")')), 'viewButtonUrl' => 'Yii::app()->controller->createUrl("view", array("fdm2_id" => $data->fdm2_id))', 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("delete", array("fdm2_id" => $data->fdm2_id))', 'deleteConfirmation' => Yii::t('D2fixrModule.crud', 'Do you want to delete this item?'), 'viewButtonOptions' => array('data-toggle' => 'tooltip'), 'deleteButtonOptions' => array('data-toggle' => 'tooltip')))));
Yii::endProfile('Fdm2Dimension2.view.grid');
 public function loadModel($id)
 {
     $m = FretRefType::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('D2fixrModule.crud', 'The requested page does not exist.'));
     }
     return $model;
 }