public function updateSmens() { $res = $this->tm->get_shifts($this->start_day, $this->end_day); $time = time(); foreach ($res as $v) { $crew = DB::connection($this->city->db)->table('crews')->where('driver', $v->driver_id)->first(); $insert_data = ['id' => $v->shift_id, 'driver' => $v->driver_id, 'begin' => strtotime($v->plan_shift_start_time), 'end' => strtotime($v->plan_shift_finish_time), 'crew' => isset($crew->id) ? $crew->id : 0, 'type' => $v->shift_state, 'uptime' => $time]; $smen = DB::connection($this->city->db)->table('smens')->where('id', $v->shift_id)->first(); if (!empty($smen)) { unset($insert_data['id']); DB::connection($this->city->db)->table('smens')->where('id', $v->shift_id)->update($insert_data); } else { DB::connection($this->city->db)->table('smens')->insert($insert_data); $buy_driver = Driver::on($this->city->db)->find($v->driver_id); if (!empty($buy_driver) && $v->plan_shift_cost != 1) { $locked_alias = Driver::on($this->city->db)->where('name', $buy_driver->name)->where('type', 'dolg')->where('balans', '<', '0')->first(); if (!empty($locked_alias)) { $summ = $locked_alias->balans > -2000 ? abs($locked_alias->balans) : 2000; $this->dr->MoneyOperations($buy_driver->id, 0, 1, 'TEST', 'TEST TRANSFER TO DEB' . $summ); $this->dr->MoneyOperations($locked_alias->id, 1, 1, 'TEST', 'TEST TRANSFER TO DEB' . $summ); $locked_a2 = Driver::find($locked_alias->id); if (isset($locked_a2) && $locked_a2->balans >= 0) { $this->dr->deleteDriver($locked_a2->id); } } } } } return $res; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Driver::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => 10]]); $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, 'driver_license_expire' => $this->driver_license_expire, 'create_date' => $this->create_date]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'lname', $this->lname])->andFilterWhere(['like', 'card_id', $this->card_id])->andFilterWhere(['like', 'birth', $this->card_id])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'tel1', $this->tel1])->andFilterWhere(['like', 'tel2', $this->tel2])->andFilterWhere(['like', 'driver_license_id', $this->driver_license_id])->andFilterWhere(['like', 'images', $this->images]); $query->andWhere(['delete_flag' => '0']); return $dataProvider; }
function get_driver($driver_id = null) { $rs = Driver::find()->where(['id' => $driver_id])->one(); return $rs['name'] . '-' . $rs['lname']; }
use yii\helpers\Url; /* @var $this yii\web\View */ /* @var $searchModel app\models\MapTruckSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'บัญชีค่าใช้จ่ายของรถประจำเดือน(ต่อเที่ยววิ่ง)'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="map-truck-index"> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <?php $columns = [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'car_id', 'label' => 'รถคันที่', 'mergeHeader' => true, 'value' => function ($model) { return $model->car_id; }], ['attribute' => 'truck_1', 'label' => 'ทะเบียนรถ', 'mergeHeader' => true, 'value' => function ($model) { return "(" . $model->truck_1 . ') - (' . $model->truck_2 . ")"; }], ['attribute' => 'driver', 'label' => 'คนขับประจำ', 'mergeHeader' => true, 'value' => function ($model) { $truck = \app\models\MapDriver::find()->where(['car_id' => $model->car_id])->one(); $driver = \app\models\Driver::find()->where(['driver_id' => $truck['driver']])->one(); return $driver['name'] . ' - ' . $driver['lname']; }], ['class' => 'kartik\\grid\\DataColumn', 'header' => 'ตัวเลือก', 'label' => 'วันที่ไป', 'hAlign' => 'center', 'format' => 'raw', 'mergeHeader' => true, 'headerOptions' => ['class' => 'kartik-sheet-style'], 'value' => function ($model) { return Html::a("ดูค่าใช้จ่ายคันนี้", Url::to(['report/mas_report_month_select_car_round', 'car_id' => $model->car_id]), ""); }]]; echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $columns, '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-truck'></i> " . $this->title]]); ?> </div>
function get_driver($driver_id = null) { $driver = new Driver(); $rs = $driver->find()->where(['driver_id' => $driver_id])->one(); return $rs['name'] . ' ' . $rs['lname']; }
public function actionGet_driver() { $driver = Driver::find()->where(['delete_flag' => '0', 'status' => '0'])->all(); return $this->renderPartial('list_driver', ['driver' => $driver]); }