function datepickerAction() { ob_clean(); $unitID = $this->_getParam('unit_id', null); $unitModel = new RM_Units(); $unit = $unitModel->get($unitID); $reservationModel = new RM_Reservations(); $reservations = $reservationModel->fetchAllForUnitCalendar($unit); $config = new RM_Config(); $RMdate = new RM_Date(); $jsonDisabledPeriods = new stdClass(); $jsonDisabledPeriods->start = array(); $jsonDisabledPeriods->end = array(); foreach ($reservations as $period) { $jsonPeriod = new stdClass(); $jsonPeriod->start = $config->convertDates($period->start_datetime, RM_Config::JS_DATEFORMAT, RM_Config::PHP_DATEFORMAT); $jsonPeriod->end = $config->convertDates($period->end_datetime, RM_Config::JS_DATEFORMAT, RM_Config::PHP_DATEFORMAT); // store the start date picker blocked periods $jsonDisabledPeriods->start[] = clone $jsonPeriod; $jsonPeriod->start = $RMdate->dateAdd($config->convertDates($period->start_datetime, RM_Config::JS_DATEFORMAT, RM_Config::PHP_DATEFORMAT), 1); $jsonPeriod->end = $RMdate->dateAdd($config->convertDates($period->end_datetime, RM_Config::JS_DATEFORMAT, RM_Config::PHP_DATEFORMAT), 1); $jsonDisabledPeriods->end[] = clone $jsonPeriod; } $json = Zend_Json::encode($jsonDisabledPeriods); $this->view->calendardata = $json; $this->view->unit_id = $unitID; echo $this->view->render('DailyPrices/datepicker.phtml'); die; }