/** * Run items through template system */ public function createTemplate() { $template_id = $this->app->input->get('template_id'); $association_id = $this->app->input->get('association_id'); $association_type = $this->app->input->get('association_type'); $template = $this->getTemplate($template_id); $current_date = date("Y-m-d 00:00:00"); if (count($template) > 0) { $event_model = new Event(); foreach ($template as $event) { unset($event['id']); $event['association_id'] = $association_id; $event['association_type'] = $association_type; $event['type'] = "task"; $event['due_date'] = DateHelper::formatDBDate(date("Y-m-d", strtotime($current_date . " +" . $event['day'] . " days")), false); $event['due_date_hour'] = "00:00:00"; if (!$event_model->store($event)) { return false; } } } return true; }