allowed()) { api_not_allowed(true); } $sessionUrl = api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$sessionId; $htmlHeadXtra[] = api_get_jqgrid_js(); $interbreadcrumb[] = array( 'url' => "session_list.php", "name" => get_lang('SessionList') ); $interbreadcrumb[] = array( 'url' => $sessionUrl, "name" => get_lang('SessionOverview') ); if ($action == 'add') { $interbreadcrumb[] = array( 'url' => api_get_self()."?session_id=".$sessionId, "name" => get_lang('ScheduledAnnouncements') ); $tool_name = get_lang('Add'); } elseif ($action == 'edit') { $tool_name = get_lang('Edit'); $interbreadcrumb[] = array( 'url' => api_get_self()."?session_id=".$sessionId, "name" => get_lang('ScheduledAnnouncements') ); } else { $tool_name = get_lang('ScheduledAnnouncements'); } switch ($action) { case 'run': $messagesSent = $object->sendPendingMessages(); Display::addFlash( Display::return_message( get_lang('MessageSent').': '.$messagesSent, 'confirmation' ) ); $content = $object->getGrid($sessionId); break; case 'add': $url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&session_id='.$sessionId; $form = $object->returnForm($url, 'add', $sessionInfo); // The validation or display if ($form->validate()) { $values = $form->getSubmitValues(); switch ($values['type']) { case 'base_date': $numberDays = (int) $values['days']; switch ($values['base_date']) { case 'start_date': $baseDate = new DateTime($sessionInfo['access_start_date']); break; case 'end_date': $baseDate = new DateTime($sessionInfo['access_end_date']); break; } $interval = new DateInterval('P'.$numberDays.'D'); switch ($values['moment_type']) { case 'after': $newDate = $baseDate->add($interval); break; case 'before': $newDate = $baseDate->sub($interval); break; } $values['date'] = $newDate->format('Y-m-d h:i:s'); break; case 'specific_date': $values['date'] = api_get_utc_datetime($values['date']); break; } $res = $object->save($values); if ($res) { Display::addFlash( Display::return_message( get_lang('ItemAdded'), 'confirmation' ) ); } $content = $object->getGrid($sessionId); } else { $content = '
'; $content .= Display::url( Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM), api_get_self().'?session_id='.$sessionId ); $content .= '
'; $form->addElement('hidden', 'sec_token'); $content .= $form->returnForm(); } break; case 'edit': // Action handling: Editing $url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&id='.intval($_GET['id']).'&session_id='.$sessionId; $form = $object->returnSimpleForm($url, 'edit', $sessionInfo); if ($form->validate()) { $values = $form->getSubmitValues(); $values['id'] = $id; $values['sent'] = isset($values['sent']) ? 1 : ''; $values['date'] = api_get_utc_datetime($values['date']); $res = $object->update($values); Display::addFlash(Display::return_message( get_lang('Updated'), 'confirmation' )); } $item = $object->get($id); $item['date'] = api_get_local_time($item['date']); $form->setDefaults($item); $content = $form->returnForm(); break; case 'delete': $object->delete($_GET['id']); $content = $object->getGrid($sessionId); break; default: $content = $object->getGrid($sessionId); break; } $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_programmed_announcements&session_id='.$sessionId; $columns = [ get_lang('Subject'), get_lang('Date'), get_lang('Sent'), get_lang('Actions') ]; $columnModel = [ array( 'name' => 'subject', 'index' => 'subject', 'width' => '250', 'align' => 'left', ), array( 'name' => 'date', 'index' => 'date', //'width' => '90', //'align' => 'left', 'sortable' => 'true', ), array( 'name' => 'sent', 'index' => 'sent', //'width' => '90', //'align' => 'left', 'sortable' => 'true', ), array( 'name' => 'actions', 'index' => 'actions', 'width' => '100', 'align' => 'left', 'formatter' => 'action_formatter', 'sortable' => 'false', ) ]; $actionLinks = 'function action_formatter(cellvalue, options, rowObject) { return \''.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).''. ' '.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).''. '\'; }'; $extraParams = []; $extraParams['autowidth'] = 'true'; $htmlHeadXtra[] = ''; $tpl = new Template($tool_name); $sessionTitle = Display::page_header($sessionInfo['name']); $tpl->assign('content', $sessionTitle.$content); $tpl->display_one_col_template();