H
H
hollanditkzn2017-05-17 15:27:06
Yii
hollanditkzn, 2017-05-17 15:27:06

How to make a reminder?

I want to implement a reminder on a website. But to make it so that it was recorded in the notification table. I just don’t understand how to make sure that the reminder is saved and entered as a notification.
Reminders are saved if the expiration date is then saved as a notification that the order is overdue.
I tried using action, but it didn’t work and where should I write the code

public function actionReminder($id)
    {
        $model = $this->findModel($id)
        $reminder = new Notification();
        if ($model->srok<date('Y-m-d')) {
             $reminder->id_user = 1;
             $reminder->name = 'Срок пропущен в №'.$model->id_zakaz;
             $reminder->id_zakaz = $model->id_zakaz;
             $reminder->category = 4;
             $reminder->active = true;
             $reminder->save();
         } 
    }

Or is it necessary to somehow add deadlines to notifications when creating an order? But then it’s not clear how to separate them from ordinary notices with an overdue date?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2017-05-17
@hollanditkzn

There is a user, an order is associated with him, select all user orders whose creation date is between the current date and the old date (for example, the current date minus the month)
If there are any, display a message. In order not to load the database especially, you can simply count() and display the message "You have n orders not paid" with a link to the page with all orders. I would also cache this request for a day and pull this figure from the cache. If zero - do not show the message. When you click on the link to orders, we write zero to the cache. so that they don't show up anymore.

M
mitaichik, 2017-05-17
@mitaichik

Look at this line here: you are most likely comparing strings, not dates.
Also you don't check $reminder->save() - it might not be saved.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question