Beispiel #1
0
 public static function registre($fixr_id, $fdm2_ref, $fdm2_name, $fdm3_ref, $fdm3_name)
 {
     //get fixr record
     $fixr = FixrFiitXRef::model()->findByPk($fixr_id);
     if (empty($fixr->fixr_period_fret_id)) {
         return;
     }
     //found fret record - definitiom
     if (empty($fixr->fixrPeriodFret)) {
         return;
     }
     $period_model = $fixr->fixrPeriodFret->fret_model;
     $period_model_fixr_field = $fixr->fixrPeriodFret->fret_model_fixr_id_field;
     //get period
     $attributes = array($period_model_fixr_field => $fixr->fixr_id);
     //$fped = FpedPeriodDate::model()->findByAttributes($attributes);
     $period = call_user_func(array($period_model, 'model'))->findByAttributes($attributes);
     if (empty($period)) {
         return;
     }
     //save dim data
     $fdda = FddaDimData::findByFixrId($fixr->fixr_id);
     $fdda->fdda_fret_id = $fixr->fixr_position_fret_id;
     $fdda->setFdm2Id($fdm2_ref, $fdm2_name);
     $fdda->setFdm3Id($fdm3_ref, $fdm3_name);
     $fdda->fdda_date_from = $period->getFddaDateFrom();
     $fdda->fdda_date_to = $period->getFddaDateTo();
     $fdda->save();
 }
Beispiel #2
0
 public function beforeSave()
 {
     //validate rigts to record
     if (!$this->isNewRecord && !FpeoPeriodOdo::model()->findByPk($this->primaryKey)) {
         return false;
     }
     //get fixr for truck
     $fixr = FixrFiitXRef::model()->findByPk($this->fpeo_fixr_id);
     if (!$fixr) {
         $this->addError('fpeo_id', 'Can not find fixr record');
         return false;
     }
     //found fret record - definitiom
     if (empty($fixr->fixrPositionFret)) {
         $this->addError('fpeo_id', 'No defined position');
         return false;
     }
     $position_model = $fixr->fixrPositionFret->fret_model;
     $position_model_fixr_field = $fixr->fixrPositionFret->fret_model_fixr_id_field;
     //process position model
     $position = new $position_model();
     $position_data = $position->findByAttributes(array($position_model_fixr_field => $this->fpeo_fixr_id));
     if (empty($fixr->fixrPositionFret)) {
         $this->addError('fpeo_id', 'No found position data');
         return false;
     }
     //find in position model vtrc_id - truck field
     $vtrc_id = false;
     foreach ($position_data->attributes as $col_name => $col_value) {
         if (substr($col_name, -7) == 'vtrc_id') {
             $vtrc_id = $col_value;
             break;
         }
     }
     if (!$vtrc_id) {
         $this->addError('fpeo_id', 'In position data no exist vtrc_id columns');
         return false;
     }
     //get nearest odometer reading by date
     $vodo = VodoOdometer::getOdoByDate($vtrc_id, $this->fpeo_start_date);
     if (!$vodo) {
         $this->addError('fpeo_id', 'No found odometer readings for car');
         return false;
     }
     //get data from odometer reading
     $this->fpeo_vodo_id = $vodo->vodo_id;
     $this->fpeo_start_abs_odo = $vodo->vodo_abs_odo;
     $this->fpeo_end_abs_odo = $vodo->vodo_abs_odo + $this->fpeo_distance;
     //end date
     $vtrc = VtrcTruck::model()->findByPk($vtrc_id);
     if (empty($vtrc->vtrc_year_mileage)) {
         $this->addError('fpeo_id', 'Pleas set for truc Yearly Run');
         return false;
     }
     $sql_expr = new CDbExpression("ADDDATE(:date,:days)");
     $sql_expr->params = array(':date' => $this->fpeo_start_date, ':days' => round($this->fpeo_distance / $vtrc->vtrc_year_mileage * 365));
     $this->fpeo_end_date = $sql_expr;
     return parent::beforeSave();
 }
 public function loadModel($id)
 {
     $m = FixrFiitXRef::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;
 }
Beispiel #4
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.FpedPeriodDate.*') || Yii::app()->user->checkAccess('D2finv.FpedPeriodDate.Create')));
?>
</div>
        <div class="btn-group">
            <h1>
                <i class=""></i>
                <?php 
echo Yii::t('D2fixrModule.model', 'Fped Period Dates');
?>
            </h1>
        </div>
    </div>
</div>

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


<?php 
$this->widget('TbGridView', array('id' => 'fped-period-date-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("fped_id" => $data["fped_id"]))'), array('class' => 'editable.EditableColumn', 'name' => 'fped_id', 'editable' => array('url' => $this->createUrl('/d2finv/fpedPeriodDate/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fped_fixr_id', 'editable' => array('type' => 'select', 'url' => $this->createUrl('/d2finv/fpedPeriodDate/editableSaver'), 'source' => CHtml::listData(FixrFiitXRef::model()->findAll(array('limit' => 1000)), 'fixr_id', 'itemLabel'))), array('class' => 'editable.EditableColumn', 'name' => 'fped_start_date', 'editable' => array('type' => 'date', 'url' => $this->createUrl('/d2finv/fpedPeriodDate/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fped_end_date', 'editable' => array('type' => 'date', 'url' => $this->createUrl('/d2finv/fpedPeriodDate/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'fped_month', 'editable' => array('type' => 'date', 'url' => $this->createUrl('/d2finv/fpedPeriodDate/editableSaver'))), array('class' => 'TbButtonColumn', 'buttons' => array('view' => array('visible' => 'Yii::app()->user->checkAccess("D2finv.FpedPeriodDate.View")'), 'update' => array('visible' => 'FALSE'), 'delete' => array('visible' => 'Yii::app()->user->checkAccess("D2finv.FpedPeriodDate.Delete")')), 'viewButtonUrl' => 'Yii::app()->controller->createUrl("view", array("fped_id" => $data->fped_id))', 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("delete", array("fped_id" => $data->fped_id))', 'viewButtonOptions' => array('data-toggle' => 'tooltip'), 'deleteButtonOptions' => array('data-toggle' => 'tooltip')))));
Yii::endProfile('FpedPeriodDate.view.grid');
Beispiel #5
0
<div class="row">
    <div class="span12">
        <h2>
            <?php 
echo Yii::t('D2fixrModule.crud', 'Data');
?>
            <small>
                #<?php 
echo $model->fped_id;
?>
            </small>
        </h2>

        <?php 
$this->widget('TbDetailView', array('data' => $model, 'attributes' => array(array('name' => 'fped_id', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'attribute' => 'fped_id', 'url' => $this->createUrl('/d2finv/fpedPeriodDate/editableSaver')), true)), array('name' => 'fped_fixr_id', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'type' => 'select', 'url' => $this->createUrl('/d2finv/fpedPeriodDate/editableSaver'), 'source' => CHtml::listData(FixrFiitXRef::model()->findAll(array('limit' => 1000)), 'fixr_id', 'itemLabel'), 'attribute' => 'fped_fixr_id'), true)), array('name' => 'fped_start_date', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'type' => 'date', 'url' => $this->createUrl('/d2finv/fpedPeriodDate/editableSaver'), 'attribute' => 'fped_start_date'), true)), array('name' => 'fped_end_date', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'type' => 'date', 'url' => $this->createUrl('/d2finv/fpedPeriodDate/editableSaver'), 'attribute' => 'fped_end_date'), true)), array('name' => 'fped_month', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'type' => 'date', 'url' => $this->createUrl('/d2finv/fpedPeriodDate/editableSaver'), 'attribute' => 'fped_month'), true)))));
?>
    </div>

    </div>
    <div class="row">

    <div class="span12">
        <div class="well">
            <?php 
$this->renderPartial('_view-relations_grids', array('modelMain' => $model, 'ajax' => false));
?>
        </div>
    </div>
</div>
Beispiel #6
0
<div class="row">
    <div class="span12">
        <h2>
            <?php 
echo Yii::t('TrucksModule.crud_static', 'Data');
?>
            <small>
                #<?php 
echo $model->vtdc_id;
?>
            </small>
        </h2>

        <?php 
$this->widget('TbDetailView', array('data' => $model, 'attributes' => array(array('name' => 'vtdc_id', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'attribute' => 'vtdc_id', 'url' => $this->createUrl('/trucks/vtdcTruckDoc/editableSaver')), true)), array('name' => 'vtdc_vtrc_id', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'type' => 'select', 'url' => $this->createUrl('/trucks/vtdcTruckDoc/editableSaver'), 'source' => CHtml::listData(VtrcTruck::model()->findAll(array('limit' => 1000)), 'vtrc_id', 'itemLabel'), 'attribute' => 'vtdc_vtrc_id'), true)), array('name' => 'vtdc_vtdt_id', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'type' => 'select', 'url' => $this->createUrl('/trucks/vtdcTruckDoc/editableSaver'), 'source' => CHtml::listData(VtdtTruckDocType::model()->findAll(array('limit' => 1000)), 'vtdt_id', 'itemLabel'), 'attribute' => 'vtdc_vtdt_id'), true)), array('name' => 'vtdc_fixr_id', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'type' => 'select', 'url' => $this->createUrl('/trucks/vtdcTruckDoc/editableSaver'), 'source' => CHtml::listData(FixrFiitXRef::model()->findAll(array('limit' => 1000)), 'fixr_id', 'itemLabel'), 'attribute' => 'vtdc_fixr_id'), true)), array('name' => 'vtdc_number', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'attribute' => 'vtdc_number', 'url' => $this->createUrl('/trucks/vtdcTruckDoc/editableSaver')), true)), array('name' => 'vtdc_issue_date', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'type' => 'date', 'url' => $this->createUrl('/trucks/vtdcTruckDoc/editableSaver'), 'attribute' => 'vtdc_issue_date'), true)), array('name' => 'vtdc_expire_date', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'type' => 'date', 'url' => $this->createUrl('/trucks/vtdcTruckDoc/editableSaver'), 'attribute' => 'vtdc_expire_date'), true)), array('name' => 'vtdc_notes', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'attribute' => 'vtdc_notes', 'url' => $this->createUrl('/trucks/vtdcTruckDoc/editableSaver')), true)), array('name' => 'vtdc_deleted', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'attribute' => 'vtdc_deleted', 'url' => $this->createUrl('/trucks/vtdcTruckDoc/editableSaver')), true)))));
?>
    </div>

    </div>
    <div class="row">

    <div class="span12">
        <?php 
$this->renderPartial('_view-relations_grids', array('modelMain' => $model, 'ajax' => false));
?>
    </div>
</div>

<?php 
echo $cancel_buton;