'admin_name' => $adminName,
'salary_shift' => $record->salary_shift,
'daily_payment' => $dailyPayment,
- 'date_shift' => $record->date_shift
+ 'date' => $record->date
];
}
$timetableFactModel->store_id = $model->store_id;
$timetableFactModel->admin_group_id = $model->admin_group_id;
$timetableFactModel->d_id = $model->admin_group_id;
- $timetableFactModel->date_shift = date('Y-m-d', strtotime($model->shift_start));
- $timetableFactModel->date_start = $timetableFactModel->date_shift;
+ $timetableFactModel->date = date('Y-m-d', strtotime($model->shift_start));
+ $timetableFactModel->date_start = $timetableFactModel->date;
if ($action == 'createFact') {
$timetableFactModel->date_end = date('Y-m-d', strtotime($model->shift_end));
$timetableFactModel->is_opening = false;
])->all();
$timetableFacts = TimetableFactModel::find()->where(['admin_id' => $model->admin_id])
- ->andWhere(['>=', 'date_shift', date('Y-m-d', strtotime($model->shift_start))])
- ->andWhere(['<=', 'date_shift', date('Y-m-d', strtotime($model->shift_end))])
+ ->andWhere(['>=', 'date', date('Y-m-d', strtotime($model->shift_start))])
+ ->andWhere(['<=', 'date', date('Y-m-d', strtotime($model->shift_end))])
->all();
}
$slot->time_end = $slot->shift ? $slot->shift->end_time : null;
}
$fact = TimetableFact::find()->andWhere(['plan_id' => $slot->id])->one();
- $dataProvider = new ActiveDataProvider(['query' => TimetableFactModel::find()->where(['admin_id' => $row['admin_id'], 'date_shift' => $row['date']])]);
+ $dataProvider = new ActiveDataProvider(['query' => TimetableFactModel::find()->where(['admin_id' => $row['admin_id'], 'date' => $row['date']])]);
return $this->controller->renderPartial('/timetable/tabel_edit.php', [
'slot' => $slot,
'fact' => $fact,
if ($fact) {
$model->plan_id = $fact->plan_id;
$model->replaced_admin_id = $fact->admin_id_add;
- $model->date = $fact->date_shift;
+ $model->date = $fact->date;
$model->d_id = $fact->d_id;
} else {
if ($device->isFixedStore()) {
$checkIn->plan_id = $fact->plan_id;
$checkIn->store_id = $fact->store_id;
$checkIn->d_id = $fact->admin->group_id;
- $checkIn->date = $fact->date_shift;
+ $checkIn->date = $fact->date;
$checkIn->ball = 5;
$checkIn->comment = "";
$checkIn->admin_id = $admin_id;
->andWhere(['is_opening' => true])
->addSelect([
'id as id',
- 'date_shift as date',
+ 'date as date',
'date_start as start',
'date_end as end',
])
$checkIn->ball = 5;
$checkIn->comment = "Закрыта автоматически " . date('d-m-Y H-i-s');
$checkIn->d_id = $timetableFactModel->d_id;
- $checkIn->date = $timetableFactModel->date_shift;
+ $checkIn->date = $timetableFactModel->date;
$checkIn->time = date('Y-m-d H:i:s', strtotime('+14 hours', strtotime($timetableFactModel->date_start . ' ' . $timetableFactModel->time_start)));
$checkIn->lat = 0;
$checkIn->lon = 0;
$timetableFactModelQuery->andWhere(['store_id' => $model->store_id]);
}
if ($model->date_start) {
- $timetableFactModelQuery->andWhere(['>=', 'date_shift', date('Y-m-d 00:00:00', strtotime($model->date_start))]);
+ $timetableFactModelQuery->andWhere(['>=', 'date', date('Y-m-d 00:00:00', strtotime($model->date_start))]);
}
if ($model->date_end) {
- $timetableFactModelQuery->andWhere(['<=', 'date_shift', date('Y-m-d 23:59:59', strtotime($model->date_end))]);
+ $timetableFactModelQuery->andWhere(['<=', 'date', date('Y-m-d 23:59:59', strtotime($model->date_end))]);
}
if ($model->group_id && $model->group_id > 0) {
$timetableFactModelQuery->andWhere(['d_id' => $model->group_id]);
$timetableFactModelQuery->andWhere(['autoclosed' => '1']);
}
if (!$model->sort) {
- $timetableFactModelQuery->orderBy(['date_shift' => SORT_DESC]);
+ $timetableFactModelQuery->orderBy(['date' => SORT_DESC]);
}
$storeArr = CityStore::find()->all();
foreach ($timetables as $timetable) {
$newFact = TimetableFactModel::find()
- ->andWhere(['date_shift' => $timetable->date])
+ ->andWhere(['date' => $timetable->date])
->andWhere(['admin_id' => $timetable->admin_id])
->andWhere(['store_id' => $timetable->store_id])
->one();
foreach ($plans as $plan) {
$facts = TimetableFactModel::find()
- ->andWhere(['date_shift' => $plan->date])
+ ->andWhere(['date' => $plan->date])
->andWhere(['admin_id' => $plan->admin_id])
->andWhere(['store_id' => $plan->store_id])
->orderBy('id asc')
->andWhere(['admin_id' => $fact->admin_id])
->andWhere(['store_id' => $fact->store_id])
->andWhere(['!=', 'id', $fact->id])
- ->andWhere(['date_shift' => $fact->date_shift])
+ ->andWhere(['date' => $fact->date])
->andWhere(['shift_id' => $fact->shift_id])
->one();
$dataProvider = new ActiveDataProvider([
'query' => TimetableFactModel::find()
- ->andWhere(['>=', 'date_shift', '2024-07-01'])
- ->andWhere(['<=', 'date_shift', date('Y-m-d')])
- ->orderBy('date_shift, admin_id,id, store_id'),
+ ->andWhere(['>=', 'date', '2024-07-01'])
+ ->andWhere(['<=', 'date', date('Y-m-d')])
+ ->orderBy('date, admin_id,id, store_id'),
'pagination' => [
'pageSize' => false
]
}
$fact = TimetableFactModel::find()
- ->andWhere(['date_shift' => $plan->date])
+ ->andWhere(['date' => $plan->date])
->andWhere(['admin_id' => $plan->admin_id])
->andWhere(['store_id' => $plan->store_id])
->one();
$dataProvider = new ActiveDataProvider([
'query' => TimetableFactModel::find()
- ->andWhere(['>=', 'date_shift', '2024-07-01'])
- ->andWhere(['<=', 'date_shift', date('Y-m-d')])
- ->orderBy('date_shift, admin_id,id, store_id'),
+ ->andWhere(['>=', 'date', '2024-07-01'])
+ ->andWhere(['<=', 'date', date('Y-m-d')])
+ ->orderBy('date, admin_id,id, store_id'),
'pagination' => [
'pageSize' => false
]
--- /dev/null
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m240918_124420_change_table_name_timetable_fact
+ */
+class m240918_124420_change_table_name_timetable_fact extends Migration
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function safeUp()
+ {
+ $this->renameColumn('timetable_fact', 'date_shift', 'date');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ $this->renameColumn('timetable_fact', 'date', 'date_shift');
+ }
+
+ /*
+ // Use up()/down() to run migration code without a transaction.
+ public function up()
+ {
+
+ }
+
+ public function down()
+ {
+ echo "m240918_124420_change_table_name_timetable_fact cannot be reverted.\n";
+
+ return false;
+ }
+ */
+}
* @property int $store_id ID магазина
* @property int $admin_group_id ID должности
* @property int $d_id в какой должности работал на смене
- * @property $date_shift дата смены
+ * @property $date дата смены
* @property $date_start дата время открытия смены
* @property $date_end дата время закрытия смены
* @property bool $is_opening на открытие смены
'store_id' => 'Магазин',
'admin_group_id' => 'Должность',
'd_id' => 'в какой должности работал на смене',
- 'date_shift' => 'дата смены',
+ 'date' => 'дата смены',
'date_start' => 'дата открытия смены',
'date_end' => 'дата закрытия смены',
'is_opening' => 'смена открыта?',
[['comment'], 'string'],
[['comment'], 'default', 'value' => null],
[['slot_type_id', 'date_add', 'date_end', 'time_end', 'salary_shift', 'price_hour', 'work_time', 'autoclosed'], 'safe'],
- [['date_shift'], 'date', 'format' => 'yyyy-M-d'],
+ [['date'], 'date', 'format' => 'yyyy-M-d'],
[['time_start', 'shift_id'], 'required'],
];
}
$model->admin_group_id = Admin::findOne(['id' => $adminCheckin->admin_id])->group_id;
$model->d_id = $adminCheckin->d_id;
$model->store_id = $adminCheckin->store_id;
- $model->date_shift = $adminCheckin->date;
+ $model->date = $adminCheckin->date;
}
$model->is_opening = $is_start;
$fact = self::find()
->andWhere(['admin_id' => $adminId])->andWhere([
'OR',
- ['date_shift' => $date],
- ['date_shift' => date('Y-m-d', strtotime('-1 day'))],
+ ['date' => $date],
+ ['date' => date('Y-m-d', strtotime('-1 day'))],
]);
$opening ? $fact->andWhere(['is_opening' => true]) : $fact->andWhere(['is_close' => true]);
'salary_shift',
// 'price' => fn($x) => $x->shift_id == 2 ? 140 : 125,
'tabel',
- 'date' => fn($x) => $x->date_shift,
+ 'date' => fn($x) => $x->date,
'date_start' => fn($x) => $x->date_start . ' ' .$x->time_start,
'date_end' => fn($x) => !empty($x->date_end) ? $x->date_end . ' ' .$x->time_end : null,
'time_start',
{
$query = TimetableFactModel::find()
->with('admin')
- ->andWhere(['>=', 'date_shift', $dateFrom])
- ->andWhere(['<=', 'date_shift', $dateTo])
+ ->andWhere(['>=', 'date', $dateFrom])
+ ->andWhere(['<=', 'date', $dateTo])
->andWhere(['admin_id' => $adminId])
;
}
}
- $query->orderBy(['date_shift' => SORT_ASC]);
+ $query->orderBy(['date' => SORT_ASC]);
$query->indexBy(['id']);
// $query->groupBy(['date_shift']);
$timetableFactForMonth = [];
$listDateCount = [];
foreach ($timetableFactForMonthPrepared as $key => $row) {
- if (!array_key_exists($row['date_shift'], $listDateCount)) {
- $listDateCount[$row['date_shift']] = 1;
+ if (!array_key_exists($row['date'], $listDateCount)) {
+ $listDateCount[$row['date']] = 1;
$timetableFactForMonth[$key] = $row;
- $timetableFactForMonth[$key]['date'] = $row['date_shift'];
+ $timetableFactForMonth[$key]['date'] = $row['date'];
}
}
$query = TimetableFactModel::find()
->joinWith('admin')
- ->andWhere(['>=', 'date_shift', $dateFrom])
- ->andWhere(['<=', 'date_shift', $dateTo])
+ ->andWhere(['>=', 'date', $dateFrom])
+ ->andWhere(['<=', 'date', $dateTo])
->andWhere(['<>','admin.group_id', -1])
->andWhere(['admin_id' => $adminId])
->andWhere(['shift_id' => $shiftIdForDict])
$query->indexBy(['id']);
$adminTable = $query->asArray()->all();
- $adminTableDateColumn = array_values(ArrayHelper::getColumn($adminTable, 'date_shift'));
+ $adminTableDateColumn = array_values(ArrayHelper::getColumn($adminTable, 'date'));
$adminTableDays = array_unique(array_values($adminTableDateColumn));
sort($adminTableDays);
/** @var TimetableFactModel[] $timetable */
$queryOtherAdminDay = TimetableFactModel::find()
- ->select(['date_shift' => new \yii\db\Expression("DISTINCT(date_shift)"), 'id'])
- ->andWhere(['>=', 'date_shift', $dateFrom])
- ->andWhere(['<=', 'date_shift', $dateTo])
- ->andWhere(['not in', 'date_shift', $adminTableDays])
+ ->select(['date' => new \yii\db\Expression("DISTINCT(date)"), 'id'])
+ ->andWhere(['>=', 'date', $dateFrom])
+ ->andWhere(['<=', 'date', $dateTo])
+ ->andWhere(['not in', 'date', $adminTableDays])
->andWhere(['<>', 'admin_id', $adminId])
->andWhere(['shift_id' => $shiftIdForDict])
;
$adminTable2 = [];
foreach ($adminTablePrepared2 as $item) {
- if (in_array($item['date_shift'], $dateArray)) {
+ if (in_array($item['date'], $dateArray)) {
continue;
} else {
- $dateArray[] = $item['date_shift'];
+ $dateArray[] = $item['date'];
$adminTable2[] = $item;
}
}
- $adminTableDateColumn2 = array_values(ArrayHelper::getColumn($adminTable2, 'date_shift'));
+ $adminTableDateColumn2 = array_values(ArrayHelper::getColumn($adminTable2, 'date'));
$adminTableIdDay = array_values(ArrayHelper::getColumn($adminTable2, 'id'));
$adminTableNight = array_values($adminTableDateColumn2);
/** @var TimetableFactModel[] $timetable */
$queryOtherAdminNight = TimetableFactModel::find()
- ->select(['date_shift' => new \yii\db\Expression("DISTINCT(date_shift)"), 'id'])
- ->andWhere(['>=', 'date_shift', $dateFrom])
- ->andWhere(['<=', 'date_shift', $dateTo])
- ->andWhere(['not in', 'date_shift', $adminTableDaysLast])
+ ->select(['date' => new \yii\db\Expression("DISTINCT(date)"), 'id'])
+ ->andWhere(['>=', 'date', $dateFrom])
+ ->andWhere(['<=', 'date', $dateTo])
+ ->andWhere(['not in', 'date', $adminTableDaysLast])
->andWhere(['<>', 'admin_id', $adminId])
->andWhere(['shift_id' => $shiftIdForDict])
;
$query = TimetableFactModel::find()
->indexBy('id')
->with('admin')
- ->andWhere(['>=', 'date_shift', $dateFrom])
- ->andWhere(['<=', 'date_shift', $dateTo])
+ ->andWhere(['>=', 'date', $dateFrom])
+ ->andWhere(['<=', 'date', $dateTo])
->andWhere(['id' => $adminTableIds])
->andWhere(['shift_id' => $shiftIdForDict])
;
$result,
function ($a, $b) {
- return (strtotime($a['date_shift']) - strtotime($b['date_shift']));
+ return (strtotime($a['date']) - strtotime($b['date']));
}
);
}
foreach ($result as $key => $row) {
- $result[$key]['date'] = $result[$key]['date_shift'];
+ $result[$key]['date'] = $result[$key]['date'];
}
return $result;
$query = TimetableFactModel::find()
->joinWith('admin')
- ->andWhere(['date_shift' => $date])
+ ->andWhere(['date' => $date])
->andWhere(['<>','admin.group_id', -1])
->andWhere(['timetable_fact.store_id' => $storeId])
->andWhere(['shift_id' => $shiftIdForDict])
$listDateCount = [];
if (!empty($timetableFactPrepared)) {
foreach ($timetableFactPrepared as $key => $row) {
- if (!array_key_exists($row['date_shift'], $listDateCount)) {
- $listDateCount[$row['date_shift']] = 1;
+ if (!array_key_exists($row['date'], $listDateCount)) {
+ $listDateCount[$row['date']] = 1;
} else {
- $listDateCount[$row['date_shift']] = $listDateCount[$row['date_shift']] + 1;
+ $listDateCount[$row['date']] = $listDateCount[$row['date']] + 1;
}
$timetableFact[$key] = $row;
- $timetableFact[$key]['date'] = $row['date_shift'];
+ $timetableFact[$key]['date'] = $row['date'];
}
}
$motivation = Motivation::find()->where(['store_id' => $store_id, 'year' => $year, 'month' => $month])->one();
if ($motivation) {
$timetableFactModels = TimetableFactModel::find()->select(['DISTINCT(admin_id) as admin_id'])->where(['store_id' => $store_id])
- ->andWhere(['between', 'date_shift', $monthStart, $monthEnd])->all();
+ ->andWhere(['between', 'date', $monthStart, $monthEnd])->all();
$adminIds = ArrayHelper::getColumn($timetableFactModels, 'admin_id');
$result = 0;
foreach ($adminIds as $admin_id) {
$timetableFactModel = TimetableFactModel::find()->select(['COUNT(*) as total', 'admin_group_id'])->where(['store_id' => $store_id, 'admin_id' => $admin_id])
- ->andWhere(['between', 'date_shift', $monthStart, $monthEnd])->groupBy(['admin_group_id'])->asArray()->one();
+ ->andWhere(['between', 'date', $monthStart, $monthEnd])->groupBy(['admin_group_id'])->asArray()->one();
$norma = 15;
if ($timetableFactModel['admin_group_id'] != AdminGroup::GROUP_WORKERS) {
// Делаем запрос к TimetableFactModel
$records = TimetableFactModel::find()
->where(['store_id' => $storeId])
- ->andWhere(['between', 'date_shift', $startDate, $endDate])
+ ->andWhere(['between', 'date', $startDate, $endDate])
->all();
return $records;
$timetableFactModels = TimetableFactModel::find()->select(['COUNT(DISTINCT(admin_id)) as cnt', 'store_id'])
->where(['!=', 'admin_group_id', '45'])
- ->andWhere(['between', 'date_shift', $monthStart, $monthEnd])
+ ->andWhere(['between', 'date', $monthStart, $monthEnd])
->groupBy(['store_id'])
->indexBy('store_id')
->asArray()->all();
<td><?= Html::encode($record['admin_name']) ?></td>
<td><?= Html::encode($record['salary_shift']) ?></td>
<td><?= Html::encode($record['daily_payment']) ?></td>
- <td><?= Html::encode($record['date_shift']) ?></td>
+ <td><?= Html::encode($record['date']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
],
[
'label' => 'Дата смены',
- 'attribute' => 'date_shift',
+ 'attribute' => 'date',
'format' => ['date', 'php:d.m.Y'],
],
[
<?php $columns = array(
['class' => 'yii\grid\SerialColumn'],
- 'date_shift:datetime',
+ 'date:datetime',
[
'attribute' => 'admin_id',
'value' => function ($data) {
}
],
[
- 'attribute' => 'date_shift',
+ 'attribute' => 'date',
'format' => 'raw',
'value' => function ($model) {
- return Yii::$app->formatter->asDatetime($model->date_shift, 'php:d.m.Y');
+ return Yii::$app->formatter->asDatetime($model->date, 'php:d.m.Y');
},
],
[
<tr>
<td style="text-decoration: underline; color: blue;" onclick="document.querySelector('#dynamicmodel-timetable_fact_id').value = this.innerHTML"><?= $timetableFact->id ?></td>
<td><?= $stores[$timetableFact->store_id] ?? '' ?></td>
- <td><?= $timetableFact->date_shift ?></td>
+ <td><?= $timetableFact->date ?></td>
<td><?= $timetableFact->time_start ?></td>
<td><?= $timetableFact->time_end ?></td>
<td><?= $timetableFact->checkin_start_id ?></td>
/** @var TimetableFactModel[][] $regroupedTimetableFactModel */
$regroupedTimetableFactModel = [];
foreach($timetableFactModel as $ttfm) {
- $regroupedTimetableFactModel[$ttfm->admin_id][$ttfm->date_shift][] = $ttfm;
+ $regroupedTimetableFactModel[$ttfm->admin_id][$ttfm->date][] = $ttfm;
}
$rowNumber = 0;
],
[
'label' => 'Дата смены',
- 'attribute' => 'date_shift',
+ 'attribute' => 'date',
'format' => ['date', 'php:d.m.Y'],
],
[