<?php if (!Yii::$app->user->isGuest): ?>
<div class="notification-container hidden" id="notification-container">
<div class="notification-content">
<?php foreach($this->params['notifications'] as $notification){
if ($notification->category == 0) {
$notif = '<span class="glyphicon glyphicon-road"></span> '.$notification->name.'<br>';
} elseif ($notification->category == 1) {
$notif = '<span class="glyphicon glyphicon-ok"></span> '.$notification->name.'<br>';
} elseif ($notification->category == 2) {
$notif = '<span class="glyphicon glyphicon-file"></span> '.$notification->name.'<br>';
}
echo Html::a($notif.'<br>', ['notification/notification', 'id' => $notification->id_zakaz]);
}
?>
</div>
<div class='notification-footer'>
<?php echo Html::a('Прочитать все напоминание', ['notification/index']) ?>
</div>
</div>
<?php endif ?>
public function actionIndex()
{
$notification = Notification::find()->where(['id_user' => Yii::$app->user->id, 'active' => true]);
$model = $notification->where(['id_user' => Yii::$app->user->id])->limit(50)->all();
$this->view->params['notifications'] = $notification->all();
$count = $notification->count();
return $this->render('index', [
'model' => $model,
'count' => $count,
]);
}
$shipping->save();//сохранили доставку
$model->id_shipping = $shipping->id;//поместили id доставки в заказ
$model->save();//сохранили
$zakaz = $model->id_zakaz;//указали №заказа
$notification->getByIdUser(7, $zakaz);//передали в уведомление id юзеру, на данный момент 7 это курьер, передали вторым аргументом № закаказа
public function actionView($id)
{
$model = $this->findModel($id);
$notification = new Notification();
$shipping = new Courier();
if ($shipping->load(Yii::$app->request->post())) {
$model->id_shipping = $shipping->id;//Оформление доставки
$shipping->save();
$model->save();
$zakaz = $model->id_zakaz;
$notification->getByIdUser(7, $zakaz);
$notification->saveNotification;
return $this->redirect(['view', 'id' => $model->id_zakaz]);
}
}
$this->view->params['notifications'] = Notification::find()->where(['id_user' => Yii::$app->user->getId(), 'active' => true])->all();
return $this->render('view', [
'model' => $this->findModel($id),
'notification' => $notification,
'user_name' => $user_name,
'shipping' => $shipping,
'file' => $file,
]);
}
public function getByIdUser($id, $zakaz)
{
$notification->id_user = $id;
$notification->name = 'Доставка '.$zakaz;
$notification->id_zakaz = $zakaz;
$notification->category = 0;
// $notification->saveNotification;
}