예제 #1
0
 public function loadModel($id)
 {
     $m = VtrcTruck::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('TrucksModule.crud_static', 'The requested page does not exist.'));
     }
     if (Yii::app()->sysCompany->getActiveCompany()) {
         if (!Yii::app()->sysCompany->isValidUserCompany($model->vtrc_cmmp_id)) {
             throw new CHttpException(404, Yii::t('TrucksModule.crud_static', 'Requested closed data.'));
         }
     }
     return $model;
 }
예제 #2
0
                <i class="icon-dashboard "></i>
                <?php 
echo Yii::t('TrucksModule.model', 'Odometer reading');
?>
  
                
            </h1>
        </div>
        <div class="btn-group">
            <?php 
$this->widget("bootstrap.widgets.TbButton", array("label" => Yii::t("TrucksModule.crud", "Delete"), "type" => "danger", "icon" => "icon-trash icon-white", "size" => "large", "htmlOptions" => array("submit" => array("delete", "vodo_id" => $model->{$model->tableSchema->primaryKey}, "returnUrl" => Yii::app()->request->getParam("returnUrl") ? Yii::app()->request->getParam("returnUrl") : $this->createUrl("admin")), "confirm" => Yii::t("TrucksModule.crud", "Do you want to delete this item?")), "visible" => Yii::app()->request->getParam("vodo_id") && (Yii::app()->user->checkAccess("Trucks.VodoOdometer.*") || Yii::app()->user->checkAccess("Trucks.VodoOdometer.Delete"))));
?>
        </div>
    </div>
</div>



<div class="row">
    <div class="span5">

        <?php 
$this->widget('TbAceDetailView', array('data' => $model, 'attributes' => array(array('name' => 'vodo_vtrc_id', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'type' => 'select', 'url' => $this->createUrl('/trucks/vodoOdometer/editableSaver'), 'source' => CHtml::listData(VtrcTruck::model()->findAll(array('limit' => 1000)), 'vtrc_id', 'itemLabel'), 'attribute' => 'vodo_vtrc_id'), true)), array('name' => 'vodo_type', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'type' => 'select', 'url' => $this->createUrl('/trucks/vodoOdometer/editableSaver'), 'source' => $model->getEnumFieldLabels('vodo_type'), 'attribute' => 'vodo_type'), true)), array('name' => 'vodo_start_odo', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'attribute' => 'vodo_start_odo', 'url' => $this->createUrl('/trucks/vodoOdometer/editableSaver')), true)), array('name' => 'vodo_start_datetime', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'type' => 'datetime', 'url' => $this->createUrl('/trucks/vodoOdometer/editableSaver'), 'attribute' => 'vodo_start_datetime'), true)), array('name' => 'vodo_end_odo', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'attribute' => 'vodo_end_odo', 'url' => $this->createUrl('/trucks/vodoOdometer/editableSaver')), true)), array('name' => 'vodo_end_datetime', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'type' => 'datetime', 'url' => $this->createUrl('/trucks/vodoOdometer/editableSaver'), 'attribute' => 'vodo_end_datetime'), true)), array('name' => 'vodo_run', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'attribute' => 'vodo_run', 'url' => $this->createUrl('/trucks/vodoOdometer/editableSaver')), true)), array('name' => 'vodo_abs_odo', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'attribute' => 'vodo_abs_odo', 'url' => $this->createUrl('/trucks/vodoOdometer/editableSaver')), true)), array('name' => 'vodo_notes', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'attribute' => 'vodo_notes', 'url' => $this->createUrl('/trucks/vodoOdometer/editableSaver')), true)), array('name' => 'vodo_ref_model', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'attribute' => 'vodo_ref_model', 'url' => $this->createUrl('/trucks/vodoOdometer/editableSaver')), true)), array('name' => 'vodo_ref_id', 'type' => 'raw', 'value' => $this->widget('EditableField', array('model' => $model, 'attribute' => 'vodo_ref_id', 'url' => $this->createUrl('/trucks/vodoOdometer/editableSaver')), true)))));
?>
    </div>

</div>

<?php 
$cancel_buton = $this->widget("bootstrap.widgets.TbButton", array("icon" => "chevron-left", "size" => "large", "url" => isset($_GET["returnUrl"]) ? $_GET["returnUrl"] : array("{$this->id}/admin"), "visible" => Yii::app()->user->checkAccess("Trucks.VodoOdometer.*") || Yii::app()->user->checkAccess("Trucks.VodoOdometer.View"), "htmlOptions" => array("class" => "search-button", "data-toggle" => "tooltip", "title" => Yii::t("TrucksModule.crud", "Back"))), true);
echo $cancel_buton;
예제 #3
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();
 }
예제 #4
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;