View camera archive list. Stub for archive record page
This commit is contained in:
@@ -41,9 +41,43 @@ class CameraController extends Controller
|
||||
{
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$archive = $this->getArchive($cms[$id]);
|
||||
return $this->render('view',
|
||||
[
|
||||
'id' => $id
|
||||
'id' => $id,
|
||||
'archive' => array_reverse($archive),
|
||||
]);
|
||||
}
|
||||
|
||||
private function getArchive($zm_id) : array
|
||||
{
|
||||
$client = new \app\components\ApiClient(Yii::$app->params['zmUrl'].'zm/api');
|
||||
$json = $client->getEvents($zm_id, date("Y-m-d H:i:s", time() - 7 * 24 * 3600));
|
||||
$r = json_decode($json, true);
|
||||
$result = [];
|
||||
foreach ($r['events'] as $e)
|
||||
{
|
||||
$result[] = new \app\models\zm\Event($e['Event']);
|
||||
}
|
||||
$pages_count = $r['pagination']['pageCount'];
|
||||
for ($i = 2; $i <= $pages_count; $i++)
|
||||
{
|
||||
$json = $client->getEvents($zm_id, date("Y-m-d H:i:s", time() - 7 * 24 * 3600), $i);
|
||||
$r = json_decode($json, true);
|
||||
foreach ($r['events'] as $e)
|
||||
{
|
||||
$result[] = new \app\models\zm\Event($e['Event']);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function actionViewArchive($event_id)
|
||||
{
|
||||
return $this->render('view_archive',
|
||||
[
|
||||
'id' => $event_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user