Ejemplo n.º 1
0
 /**
  * Displays a single Affiliated model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $AffiliatedTruck = new AffiliatedTruck();
     $truck = $AffiliatedTruck->find()->where(['company_id' => $model->company_id])->orderBy('type_id')->all();
     return $this->render('view', ['model' => $model, 'truck' => $truck]);
 }
Ejemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AffiliatedTruck::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'type_id' => $this->type_id]);
     $query->andFilterWhere(['like', 'company_id', $this->company_id])->andFilterWhere(['like', 'license_plate', $this->license_plate])->andFilterWhere(['like', 'brand', $this->brand])->andFilterWhere(['like', 'model', $this->model])->andFilterWhere(['like', 'color', $this->color]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAffiliatedTrucks()
 {
     return $this->hasMany(AffiliatedTruck::className(), ['company_id' => 'company_id']);
 }
Ejemplo n.º 4
0
use yii\helpers\Html;
//use yii\grid\GridView;
use kartik\grid\GridView;
use app\models\AffiliatedTruck;
/* @var $this yii\web\View */
/* @var $searchModel app\models\AffiliatedSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'บริษัทรถร่วม';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="box box-primary">

    <div class="box-header with-border">

        <div class="pull-right">
            <?php 
echo Html::a('<i class="fa fa-plus"></i> เพิ่มข้อมูลบริษัท', ['create'], ['class' => 'btn btn-success']);
?>
        </div>
    </div>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'company_id', 'company', 'tax_number', 'address:ntext', 'tel', ['class' => '\\kartik\\grid\\DataColumn', 'label' => 'จำนวนรถ', 'hAlign' => 'center', 'width' => '10%', 'format' => 'raw', 'mergeHeader' => true, 'value' => function ($model) {
    return AffiliatedTruck::find()->where(['company_id' => $model->company_id])->count();
}], ['class' => '\\kartik\\grid\\DataColumn', 'label' => 'จำนวนรอบ', 'hAlign' => 'center', 'format' => 'raw', 'mergeHeader' => true, 'value' => function ($model) {
    return app\models\Affiliated::find()->where(['company_id' => $model->company_id])->count();
}], ['class' => 'kartik\\grid\\ActionColumn', 'header' => 'ตัวเลือก', 'viewOptions' => ['title' => 'ดูข้อมูล', 'data-toggle' => 'tooltip'], 'updateOptions' => ['title' => 'แก้ไข', 'data-toggle' => 'tooltip'], 'deleteOptions' => ['title' => 'ลบ', 'data-toggle' => 'tooltip'], 'headerOptions' => ['class' => 'kartik-sheet-style']]], 'containerOptions' => ['style' => 'overflow: auto'], 'headerRowOptions' => ['class' => 'kartik-sheet-style'], 'filterRowOptions' => ['class' => 'kartik-sheet-style'], 'responsive' => true, 'pjax' => true, 'panel' => ['type' => GridView::TYPE_DEFAULT, 'heading' => "<i class='fa fa-building'></i> " . $this->title]]);
?>

</div>
Ejemplo n.º 5
0
?>
        </div>
    </div>
    <div class="box box-info">
        <div class="box-header with-border">บริษัทรถร่วม</div>
        <div class="box-body">
            <?php 
echo $form->field($model, 'company_id')->dropdownList(ArrayHelper::map(Affiliated::find()->all(), 'company_id', 'company'), ['id' => 'company_id', 'required' => 'required', 'prompt' => 'เลือกบริษัทรถร่วม']);
?>

            <?php 
echo $form->field($model, 'truck1')->widget(DepDrop::classname(), ['data' => ArrayHelper::map(\app\models\AffiliatedTruck::find()->where(['company_id' => $model->company_id])->all(), 'id', 'license_plate'), 'type' => DepDrop::TYPE_SELECT2, 'options' => ['id' => 'truck1'], 'pluginOptions' => ['required' => 'required', 'depends' => ['company_id'], 'placeholder' => 'เลือกรถ...', 'url' => Url::to(['orders-transport-affiliated/get_truck'])]]);
?>

            <?php 
echo $form->field($model, 'truck2')->widget(DepDrop::classname(), ['data' => ArrayHelper::map(\app\models\AffiliatedTruck::find()->where(['company_id' => $model->company_id])->all(), 'id', 'license_plate'), 'type' => DepDrop::TYPE_SELECT2, 'options' => ['id' => 'truck2'], 'pluginOptions' => ['depends' => ['company_id'], 'placeholder' => 'เลือกรถ...', 'url' => Url::to(['orders-transport-affiliated/get_truck2'])]]);
?>

            <?php 
echo $form->field($model, 'order_date_start')->widget(\kartik\widgets\DatePicker::classname(), ['language' => 'th', 'removeButton' => false, 'options' => ['value' => date("Y-m-d"), 'readonly' => true], 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd', 'todayHighlight' => true]]);
?>

            <?php 
echo $form->field($model, 'order_date_end')->widget(\kartik\widgets\DatePicker::classname(), ['language' => 'th', 'removeButton' => false, 'options' => ['value' => date("Y-m-d"), 'readonly' => true], 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd', 'todayHighlight' => true]]);
?>

            <?php 
echo $form->field($model, 'driver1')->textInput(['maxlength' => true]);
?>

            <?php 
 public function actionGet_truck2()
 {
     $out = [];
     if (isset($_POST['depdrop_parents'])) {
         $parents = $_POST['depdrop_parents'];
         if ($parents != null) {
             $company_id = $parents[0];
             $datas = \app\models\AffiliatedTruck::find()->where(['company_id' => $company_id])->all();
             $out = $this->MapData($datas, 'id', 'license_plate');
             echo Json::encode(['output' => $out, 'selected' => '']);
             return;
         }
     }
     echo Json::encode(['output' => '', 'selected' => '']);
 }
 /**
  * Finds the AffiliatedTruck model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return AffiliatedTruck the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = AffiliatedTruck::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }