Exemple #1
0
 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;
 }
Exemple #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $city = $this->option('city');
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     if ($this->city->violation == "0") {
         return false;
     }
     $start_day = strtotime('now 00:00:00');
     $end_day = strtotime('now 23:59:00');
     $violations = Violations::getUncheckedViolations($this->city->db, $start_day, $end_day);
     if (!$violations->isEmpty()) {
         foreach ($violations as $v) {
             $driver = Driver::getDriverInfoByCar($this->city->db, $v->vio_nomer);
             if (isset($driver->driver_id)) {
                 $this->call('drivers:operations', ['driver' => $driver->driver_id, 'op' => 0, 'summ' => $this->city->violation_price, 'reason' => 'Штраф за превышение скорости', 'time' => time(), 'comment' => $v->vio_text, '--city' => $city]);
                 $v->status = 1;
                 $v->save();
             }
         }
     }
 }
Exemple #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $time = time() - 86400;
     $city = $this->option('city');
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     if ($this->city->overmilleage == "0") {
         return false;
     }
     $wialon = new Wialon($this->city);
     $wialon->get_report();
     $milleages = Overmileage::on($this->city->db)->where('run', '=', '0')->where('time', '>', $time)->get();
     if (!$milleages->isEmpty()) {
         foreach ($milleages as $v) {
             $km = $v->mileage - 350;
             $pcm = $this->city->overmilleage_price;
             $summ = $km * $pcm;
             $driver = Driver::getDriverInfoByCar($this->city->db, $v->gn);
             if (isset($driver->driver_id)) {
                 $this->call('drivers:operations', ['driver' => $driver->driver_id, 'op' => 0, 'summ' => $summ, 'reason' => 'Суточный перепробег', 'time' => time(), '--city' => $city]);
                 $v->run = 1;
                 $v->save();
             }
         }
     }
 }
Exemple #4
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $city = $this->option('city');
     $driverId = $this->argument('id');
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     Driver::on($this->city->db)->delete($driverId);
 }
 public function negativeBalance()
 {
     $day_st = strtotime(date('Y-m-d', time()));
     $has_subzero = Driver::getDriversWithNegativeBalance($this->city->db);
     foreach ($has_subzero as $v) {
         $cof = $v->is_locked == 1 ? 0.001 : 0.05;
         $summ = abs($v->balans) * $cof;
         $check = DB::connection($this->city->db)->table('operations')->where('driver', $v->id)->where('reason', 'op3')->where('time', '>', $day_st)->first();
         if (empty($check)) {
             $this->dr->MoneyOperations($v->id, 0, 1, 'TEST ', ' NEGA BALANCE' . $summ);
         }
     }
 }
Exemple #6
0
 /**
  * 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;
 }
Exemple #7
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $city = $this->option('city');
     $driverId = $this->argument('id');
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     $driver = Driver::on($this->city->db)->find($driverId);
     if ($driver != null && $driver->type == 'driver') {
         $this->call('drivers:operations', ['driver' => $driver->id, 'op' => 1, 'summ' => 15000, 'reason' => 'Бонусное пополнение счета', 'time' => time(), '--city' => $city]);
         $driver->is_new = 0;
         $driver->save();
     }
 }
Exemple #8
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $city = $this->option('city');
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     if ($this->city->negative_balance == "0") {
         return false;
     }
     $drivers = Driver::getDriversWithNegativeBalance($this->city->db);
     if (!empty($drivers)) {
         foreach ($drivers as $v) {
             if ($v->is_locked) {
                 $cof = 0.001;
             } else {
                 if (abs($v->balans) < 2000) {
                     $cof = 0.05;
                 } else {
                     if (abs($v->balans) >= 2000 && abs($v->balans) < 5000) {
                         $cof = 0.03;
                     } else {
                         if (abs($v->balans) >= 5000 && abs($v->balans) < 7000) {
                             $cof = 0.02;
                         } else {
                             if (abs($v->balans) >= 7000 && abs($v->balans) < 12000) {
                                 $cof = 0.01;
                             } else {
                                 if (abs($v->balans) >= 12000) {
                                     $cof = 0.005;
                                 }
                             }
                         }
                     }
                 }
             }
             $summ = abs($v->balans) * $cof;
             $this->call('drivers:operations', ['driver' => $v->id, 'op' => '0', 'summ' => $summ, 'reason' => 'Штраф за отрицательный баланс', 'time' => time(), '--city' => 1]);
         }
     }
 }
Exemple #9
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $city = $this->option('city');
     $start_day = strtotime('now 00:00:00');
     $end_day = strtotime('now 23:59:59');
     $insertCollection = Collection::make();
     $updateCollection = Collection::make();
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     $tm = new TMBase($this->city);
     $shifts = $tm->get_shifts($start_day, $end_day);
     DB::beginTransaction();
     foreach ($shifts as $v) {
         $crew = Crews::on($this->city->db)->where('driver', $v->driver_id)->first();
         $insertion = ['id' => empty($v->shift_id) ? 'NULL' : $v->shift_id, 'driver' => empty($v->driver_id) ? 'NULL' : $v->driver_id, 'begin' => empty($v->plan_shift_start_time) ? 'NULL' : strtotime($v->plan_shift_start_time), 'end' => empty($v->plan_shift_finish_time) ? 'NULL' : strtotime($v->plan_shift_finish_time), 'crew' => isset($crew->id) ? $crew->id : 'NULL', 'type' => empty($v->shift_state) ? 'NULL' : $v->shift_state, 'uptime' => time()];
         $shift = \App\Models\Smens::on($this->city->db)->find($v->shift_id);
         if (empty($shift)) {
             $insertCollection->push($insertion);
             $driver = Driver::on($this->city->db)->find($v->driver_id);
             if (!empty($driver) && $v->plan_shift_cost != 1 && $this->city->transfer_to_debtors == "1") {
                 $locked_alias = Driver::getLockedDriver($this->city->db, $driver->name);
                 if (!empty($locked_alias)) {
                     $summ = $locked_alias->balans > -2000 ? abs($locked_alias->balans) : $this->city->transfer_to_debtor_price;
                     $this->call('drivers:operations', ['driver' => $driver->id, 'op' => '0', 'summ' => $summ, 'reason' => 'Перевод в счет долга', 'time' => time(), '--city' => $city]);
                     $this->call('drivers:operations', ['driver' => $locked_alias->id, 'op' => '1', 'summ' => $summ, 'reason' => 'Перевод в счет долга', 'time' => time(), '--city' => $city]);
                     $locked_a2 = Driver::on($this->city->db)->find($locked_alias->id);
                     if (isset($locked_a2) && $locked_a2->balans >= 0) {
                         $this->call('drivers:delete', ['id' => $locked_a2->id, '--city' => $city]);
                     }
                 }
             }
         }
     }
     if (!$insertCollection->isEmpty()) {
         \App\Models\Smens::on($this->city->db)->insert($insertCollection->toArray());
     }
     DB::commit();
 }
Exemple #10
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $now = Carbon::now();
     $model = Delivery::where('delivery_type_id', 2)->whereNull('datepublish')->whereBetween('datestart', [$now->subMinutes(2)->format('Y-m-d H:i:s'), $now->addMinute(3)->format('Y-m-d H:i:s')])->get();
     $data = $model->toArray();
     $driver = Driver::whereFlagactive(1)->get();
     Log::warning($now->format('Y-m-d H:i:s'));
     Log::warning($now->subMinutes(2)->format('Y-m-d H:i:s'));
     Log::warning($now->addMinute(3)->format('Y-m-d H:i:s'));
     Log::info('Cron funcionando');
     if (!empty($driver) && count($data) > 0) {
         foreach ($driver as $value) {
             foreach ($data as $objDelivery) {
                 Notification::create(array('type_id' => Notification::PUSH, 'platform_id' => Platform::ANDROID, 'user_id' => $value->id, 'app_id' => Config::get('app.APP_ID'), 'token' => \md5(\uniqid(\time())), 'description' => "{\"delivery_id\":\"{$objDelivery['id']}\",\"description\":\"Nuevo delivery\"}", 'appname' => Config::get('app.APP_NAME'), 'dbconfig' => Config::get('app.DB_CONFIG'), 'params' => "{\"delivery_id\":\"{$objDelivery['id']}\",\"description\":\"Nuevo delivery\"}", 'tosend' => $value->uuid, 'to' => 'Test', 'from' => 'Cligo', 'flagsend' => 0, 'flagactive' => 1));
                 $del = Delivery::find($objDelivery['id']);
                 $del->datepublish = Carbon::now()->format('Y-m-d H:i:s');
                 $del->save();
                 Log::info("Notificacion enviada del delivery id: {$objDelivery['id']}");
             }
         }
     }
 }
Exemple #11
0
 function get_driver($driver_id = null)
 {
     $driver = new Driver();
     $rs = $driver->find()->where(['driver_id' => $driver_id])->one();
     return $rs['name'] . ' ' . $rs['lname'];
 }
Exemple #12
0
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>
Exemple #14
0
<?php 
echo $form->field($model, 'truck1')->dropDownList(ArrayHelper::map(\app\models\Truck::find()->where(['delete_flag' => '0'])->all(), 'id', 'license_plate'), ['id' => 'id', 'required' => 'required', 'prompt' => 'เลือกรถบรรทุก']);
?>

<?php 
echo $form->field($model, 'truck2')->dropDownList(ArrayHelper::map(\app\models\Truck::find()->where(['delete_flag' => '0'])->all(), 'id', 'license_plate'), ['id' => 'id', 'prompt' => 'เลือกรถถบรรทุก']);
?>

<?php 
$sql1 = "select id,concat(name,' ',lname) as name from driver where delete_flag = '0'";
echo $form->field($model, 'driver1')->dropDownList(ArrayHelper::map(\app\models\Driver::findBySql($sql1)->all(), 'id', 'name'), ['id' => 'id', 'required' => 'required', 'prompt' => 'เลือกคนขับ']);
?>

<?php 
echo $form->field($model, 'driver2')->dropDownList(ArrayHelper::map(\app\models\Driver::findBySql($sql1)->all(), 'id', 'name'), ['id' => 'id', 'prompt' => 'เลือกคนขับ']);
?>

<div class="form-group">
    <div class="col-sm-_3 col-md-3 col-lg-3"></div>
    <div class="col-sm-9 col-md-9 col-lg-9">
        <?php 
echo Html::submitButton($model->isNewRecord ? '<i class="fa fa-save"></i> บันทึกข้อมูล' : '<i class="fa fa-pencil"></i>แก้ไข', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Exemple #15
0
 public function deleteDriver($id)
 {
     $driver = Driver::on($this->city->db)->find($id);
     $driver->deleted = time();
     $driver->save();
 }
 public function actionLoad_income_expenses()
 {
     $driver = new Driver();
     $employee = Yii::$app->request->post('employee');
     $month = Yii::$app->request->post('month');
     $year = Yii::$app->request->post('year');
     $result = $driver->Conclude_incom_expenses($employee, $year, $month);
     return $this->renderPartial('conclude_incom_expenses', ["result" => $result]);
 }
Exemple #17
0
 private function endUpdate($time)
 {
     Driver::on($this->city->db)->where('uptime', '<', $time)->delete();
 }
 public function postCompensation(Request $request)
 {
     if ($request->has('id') && $request->has('end_repair')) {
         $id = $request->get('id');
         $end_repair = str_replace('.', '-', $request->get('end_repair'));
         $end_repair = Carbon::parse($end_repair)->timestamp;
         $compensation = Compensation::find($id);
         if ($end_repair > $compensation->shift_end) {
             $end_repair = $compensation->shift_end;
         }
         if ($compensation->begin > $end_repair) {
             return 'Введенные данные не были правильны пожалуйста повторите';
         }
         $price_for_one_second = $compensation->shift_sum / ($compensation->shift_end - $compensation->shift_start);
         $in_repair_second = $end_repair - $compensation->begin;
         $sum = round($price_for_one_second * $in_repair_second, 2);
         $driver = Driver::getDriverInfoByCar($this->city->db, $compensation->gn);
         if (empty($driver)) {
             return 'Извините водитель не найден на такой машине';
         }
         //driver operations here
         $compensation->end = $end_repair;
         $compensation->save();
         $user = $request->user();
         $difference = Carbon::createFromTimestamp($end_repair)->diffInHours(Carbon::createFromTimestamp($compensation->begin));
         if ($difference == 0) {
             $difference = Carbon::createFromTimestamp($end_repair)->diffInMinutes(Carbon::createFromTimestamp($compensation->begin));
             $log_description = $user->name . " компенсировал водителю {$compensation->gn} за {$difference} мин";
         } else {
             $log_description = $this->getRole($user) . " " . $user->name . " компенсировал водителю {$compensation->gn} за {$difference} " . Lang::choice('message.times', $difference, [], 'ru');
         }
         $user->userLogs('compensation', $user->name, $log_description, $this->city->index);
         return "Компенсация в размере {$sum} за {$difference} часов";
     }
     return 'Извините произошла ошибка повторите позже';
 }