/** * IS: Parameter id terdeklarasi * FS: Mengirimkan ke viewer: event * Desc: Fungsi untuk menampilkan detail international event */ public function viewAction() { // Param $id = $this->_getParam('id'); // Model $eventDb = new Model_DbTable_Event(); // Data $event = $eventDb->getAllWithDescById($id, 1); // View $this->view->event = $event[0]; }
/** * IS: Parameter id terdeklarasi * FS: Mengirimkan ke viewer: form, date_view, show_clock, event_time, * event_id * Desc: Mengatur aksi yang dilakukan untuk halaman edit */ public function editAction() { //set parameter $language_id = $this->_getParam('lang'); $event_id = $this->_getParam('id'); //creating instance $form = new Admin_Form_EventForm(); $form->setCategorySelectData(); $table_event = new Model_DbTable_Event(); $table_event_description = new Model_DbTable_EventDesc(); $table_poitoevent = new Model_DbTable_PoiToEvent(); //if this is a post request if ($this->getRequest()->isPost()) { //preparing data and update for event description $event_name = htmlspecialchars($_POST['eventName'], ENT_QUOTES); $event_description = htmlspecialchars($_POST['eventDescription'], ENT_QUOTES); if ($language_id == 1) { $indo = $table_event_description->checkForIndo($event_id, 1); if ($indo) { $data = array('event_id' => $event_id, 'language_id' => $language_id, 'name' => $event_name, 'description' => $event_description); $table_event_description->updateEvent($data, $event_id, $language_id); } else { $data2 = array('event_id' => $event_id, 'language_id' => $language_id, 'name' => $event_name, 'description' => $event_description); $table_event_description->insertEvent($data2); } } else { if ($_POST['dateStart'] == $_POST['dateEnd']) { $startdate = $_POST['dateStart'] . ' ' . $_POST['timeStart'] . ':00'; $enddate = $_POST['dateStart'] . ' ' . $_POST['timeEnd'] . ':00'; } else { $startdate = $_POST['dateStart'] . ' ' . $_POST['timeStart'] . ':00'; $enddate = $_POST['dateEnd'] . ' ' . $_POST['timeEnd'] . ':00'; } //preparing data and update for event table $data = array('main_pics' => $_POST['eventImage'], 'date_start' => $startdate, 'date_end' => $enddate, 'category' => $_POST['mainCategory']); $table_event->updateEvent($data, $event_id); $data = array('event_id' => $event_id, 'language_id' => $language_id, 'name' => $event_name, 'description' => $event_description); $table_event_description->updateEvent($data, $event_id, $language_id); $poi_count = $_POST['poiMax']; $poiarr = array(); for ($i = 0; $i <= $poi_count; $i++) { if ($_POST['poiValue' . $i] != '') { array_push($poiarr, $_POST['poiValue' . $i]); } } //create poi related to event list $saved_poitoevent = array(); $saved_list = $table_poitoevent->getAllPoiNameByEventId($event_id); //convert to a non ASSOC array foreach ($saved_list as $list) { array_push($saved_poitoevent, $list['poi_id']); } //compare the new list with the new one, if the new one doesnt exist then insert then new one foreach ($poiarr as $poi_new) { if (!in_array($poi_new, $saved_poitoevent)) { $data = array('event_id' => $event_id, 'poi_id' => $poi_new); $table_poitoevent->insertEvent($data); } } //do the complementary process, if the old one doesnot exist in the new list then delete the old ones foreach ($saved_poitoevent as $poi_old) { if (!in_array($poi_old, $poiarr)) { if ($poi_old != '') { $table_poitoevent->deleteEvent($event_id, $poi_old); } } } } //preparing data for updating the poi to event data $this->loggingaction('event', 'edit', $event_id, $language_id); $this->_flash->addMessage("1\\Event Update Success!"); $this->_redirect($this->view->rootUrl('/admin/eventindo/')); } if ($language_id == 1) { $indo = $table_event_description->checkForIndo($event_id, $language_id); if ($indo) { $saved_list = $table_poitoevent->getAllPoiNameByEventId($event_id, $language_id); } } else { $saved_list = $table_poitoevent->getAllPoiNameByEventId($event_id, $language_id); } //data processing $event_data = $table_event->getAllWithDescById($event_id, $language_id); $event_name = $this->view->HtmlDecode($event_data[0]['name']); $event_description = $this->view->HtmlDecode($event_data[0]['description']); $poiCount = $table_poitoevent->countRelatedPoiByEventId($event_id); $datetime_start = explode(' ', $event_data[0]['date_start']); $datetime_end = explode(' ', $event_data[0]['date_end']); //set form element value $form->eventName->setValue($event_name); $form->eventDescription->setValue($event_description); $form->eventImage->setValue($event_data[0]['main_pics']); $form->dateEnd->setValue($datetime_end[0]); $form->dateStart->setValue($datetime_start[0]); $form->timeStart->setValue(substr($datetime_start[1], 0, 5)); $form->timeEnd->setValue(substr($datetime_end[1], 0, 5)); $form->mainCategory->setValue($event_data[0]['category']); $form->poiMax->setValue($poiCount); if ($datetime_start[0] == $datetime_end[0]) { $this->view->date_view = $datetime_start[0] . ' one day event'; $this->view->show_clock = TRUE; } else { $this->view->date_view = $datetime_start[0] . ' until ' . $datetime_end[0]; $this->view->show_clock = FALSE; } $this->view->event_time = array($datetime_start[1], $datetime_end[1]); $this->view->event_id = $event_id; $this->view->form = $form; $this->view->langId = $language_id; }
/** * IS: Parameter id, title terdeklarasi * FS: Mengirimkan ke viewer: event, poiRelated, comments, commentForm * Desc: Fungsi untuk menampilkan detail event */ public function detailAction() { // Variable $contentType = 2; // Param $id = $this->_getParam('id'); $title = $this->_getParam('title'); // Model $eventDb = new Model_DbTable_Event(); $poiToEventDb = new Model_DbTable_PoiToEvent(); // Data $event = $eventDb->getAllWithDescById($id, $this->_languageId); $author = $eventDb->getAuthor($id, $this->_languageId); //if description is empty, will be redirecting to calender event // if($event[0]['description']) // { //update data viewer, hanya di incremen 1 saja setiap kali content detail di load $eventDb->updateField($id, array('viewer' => $event[0]['viewer'] + 1)); $poiRelated = $poiToEventDb->getAllPoiNameByEventId($id, $this->_languageId); // View $this->view->event = $event[0]; $this->view->poiRelated = $poiRelated; // $this->view->author = $author['name']; // } // else // { // $this->_redirector->gotoUrl($this->view->baseUrl('/event/calendar/')); // } }