Closed nagaokashi closed 7 years ago
Hey, you can pass start and end date ... like:
/**
* Renders the activities inside a calendar... might be nicer to view
* @param [type] $start [description]
* @param [type] $end [description]
* @param [type] $_ [description]
* @return [type] [description]
*/
public function actionJsoncalendar($start, $end, $user_id=NULL, $_ = NULL){
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
if(is_null($start))
{
$startObj = new DateTime();
$start = $startObj->format('U');
}
return TimetrackSearch::getCalendarEntries($start, $end, $user_id);
}
and then in the model like:
/**
* getCalendarEntries returns the services between the given parameters as \yii2fullcalendar\models\Event
* @param date $startDate first date of the month
* @param date $endDate Last day of the month
* @param integer $user_id the user id for which the records will be displayed
* @return [type] [description]
*/
public static function getCalendarEntries($startDate, $endDate, $user_id)
{
$events = null;
$startDateObj = new DateTime($startDate);
$startDateObj->modify('-1 month');
$endDateObj = new DateTime($endDate);
$endDateObj->modify('+1 month');
this should do the job ;) actually you can use the firstOf helper to find the correct start and end date for you range;) Pls. close if that works out for you?
Thank you for your answer. I'm sorry if my below comment is wrong. I think the problem is not about backend side. The problem is how to pass $start and $end date from calendar (client) to backend. If I can pass $start and $end date as somethink like below, everything will be easy.
'ajaxEvents' => Url::to(['/datsan/jsoncalendar', 'id_sanCon'=>$modelSanCon->id, 'id_datSan'=>$id_datSan, 'start' => xxxxxx, 'end' => yyyyyy])
));
Hey, don't worry - I got you - while navigating within the calendar, you'll get the params
added:
http://
Oh, I saw the $start and $end date. They are included in $Get ajax data. Thank you very much.
When load calendar, it takes very long time because all events are loaded. I just want events within a day, week or month. How to load only events of a day, week or month base on buttons "day", "week", "month" or week navigation button ? Or Could we can call an callback js function when these buttons are clicked ? My view.php
Thank you.