Skip to content

Commit 1448a8e

Browse files
big update
1 parent c2ba2f0 commit 1448a8e

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

src/ScheduleInputWidget.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace skeeks\yii2\scheduleInputWidget;
1010

1111
use yii\base\InvalidConfigException;
12+
use yii\helpers\ArrayHelper;
1213
use yii\helpers\Html;
1314
use yii\widgets\InputWidget;
1415

@@ -64,4 +65,39 @@ public function run()
6465
'hiddenInput' => $hiddenInput,
6566
]);
6667
}
68+
69+
/**
70+
* @param array $work_time
71+
* @return array
72+
*/
73+
static public function getWorkingData($work_time = [])
74+
{
75+
$daysLib = [
76+
1 => "Пн",
77+
2 => "Вт",
78+
3 => "Ср",
79+
4 => "Чт",
80+
5 => "Пт",
81+
6 => "Сб",
82+
7 => "Вс",
83+
];
84+
$result = [];
85+
if ($work_time) {
86+
$result = $work_time;
87+
88+
foreach ($work_time as $key => $row) {
89+
$daysString = [];
90+
$days = ArrayHelper::getValue($row, 'day');
91+
if ($days) {
92+
foreach ($days as $dayKey => $day) {
93+
$daysString[$day] = $daysLib[$day];
94+
}
95+
}
96+
97+
$result[$key]['daysStrings'] = $daysString;
98+
}
99+
}
100+
101+
return $result;
102+
}
67103
}

0 commit comments

Comments
 (0)