/** * IS: - * FS: Mengirimkan ke viewer: form, gkey * Desc: Mengatur aksi yang dilakukan untuk halaman create */ public function createAction() { /*Create table and form instance*/ $table_classification = new Model_DbTable_Classification(); $table_area = new Model_DbTable_Area(); $table_tourism = new Model_DbTable_TourismOperator(); $table_tourismdescription = new Model_DbTable_TourismOperatorDescription(); $table_classtotourism = new Model_DbTable_ClassificationToTourismOperator(); $table_coveragearea = new Model_DbTable_CoverageArea(); $form = new Admin_Form_TourismOperatorForm(); $island_list = $table_area->getAllParentArea(); /*check if this page is a posted page*/ if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { /*preparing data for tourismoperator table*/ /* if(($_POST['AreaListOptions']!=0)||(!empty($_POST['AreaListOptions']))) { $selected_area = $_POST['AreaListOptions']; } if(($_POST['ProvinceListOptions']!=0)||(!empty($_POST['ProvinceListOptions']))) { $selected_area = $_POST['ProvinceListOptions']; } else { $selected_area = $_POST['IslandListOptions']; }*/ $data = array('area_id' => $_POST['TourismArea'], 'phone' => $_POST['TourismOperatorPhone'], 'website' => $_POST['TourismOperatorWebsite'], 'address' => $_POST['TourismOperatorAddress'], 'pointX' => $_POST['Pointx'], 'pointY' => $_POST['Pointy'], 'star' => $_POST['TourismOperatorStar'], 'fax' => $_POST['TourismOperatorFax'], 'email' => $_POST['TourismOperatorEmail']); /*inserting data to the tourismoperator table*/ $tourism_id = $table_tourism->insertTourismOperator($data); /*if the insert process is success then insert the tourism description*/ if (!empty($tourism_id)) { /*preparing data for tourismoperatordescription table*/ $data = array('tourismoperator_id' => $tourism_id, 'language_id' => 1, 'name' => $_POST['TourismOperatorLangName'], 'description' => $_POST['TourismOperatorDescription']); /*inserting data to the tourismoeprator description table*/ $table_tourismdescription->insertTourismOperatorDescription($data); /*get all added classification*/ $class_count = $_POST['MaxClass']; $class_stack = array(); for ($i = 0; $i < $class_count; $i++) { if (!empty($_POST['classValue' . $i])) { array_push($class_stack, $_POST['classValue' . $i]); } } /*insert all classification to the database*/ foreach ($class_stack as $class_id) { $class_tourism = array('classification_id' => $class_id, 'tourismoperator_id' => $tourism_id); $table_classtotourism->insertClassificationTourism($class_tourism); } $this->view->test = $_POST; /*inserting coverage area*/ if (in_array(3, $class_stack)) { $area_count = $this->_getParam('MaxArea'); $area_stack = array(); for ($i = 0; $i <= $area_count; $i++) { if (!empty($_POST['areaCoverValue' . $i])) { array_push($area_stack, $_POST['areaCoverValue' . $i]); } } $this->view->test = $area_stack; foreach ($area_stack as $area_id) { $data = array('tourismoperator_id' => $tourism_id, 'area_id' => $area_id); $table_coveragearea->insertCoverageArea($data); } } $this->loggingaction('tourismoperator', 'create', $tourism_id); $this->_flash->addMessage('1\\Tourism Operator Insert Success!'); } else { $this->_flash->addMessage('2\\Tourism Operator Insert Failed!'); } $this->_redirect($this->view->rootUrl('/admin/tourismoperator/')); } } /*send variable to the view*/ $this->view->form = $form; $this->view->gkey = Zend_Registry::get('gmap_key'); }
/** * IS: - * FS: Mengirimkan ke viewer: form, gkey * Desc: Mengatur aksi yang dilakukan untuk halaman create */ public function createAction() { /*Create table and form instance*/ $table_classification = new Model_DbTable_Classification(); $table_area = new Model_DbTable_Area(); $table_tourism = new Model_DbTable_TourismOperator(); $table_tourismdescription = new Model_DbTable_TourismOperatorDescription(); $table_classtotourism = new Model_DbTable_ClassificationToTourismOperator(); $table_coveragearea = new Model_DbTable_CoverageArea(); $form = new Admin_Form_VitoForm(); $island_list = $table_area->getAllParentArea(); /*check if this page is a posted page*/ if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { /*preparing data for tourismoperator table*/ $data = array('area_id' => 0, 'phone' => $_POST['TourismOperatorPhone'], 'website' => $_POST['TourismOperatorWebsite'], 'address' => $_POST['TourismOperatorAddress'], 'pointX' => 0, 'pointY' => 0, 'star' => 0, 'fax' => $_POST['TourismOperatorFax'], 'email' => $_POST['TourismOperatorEmail']); /*inserting data to the tourismoperator table*/ $tourism_id = $table_tourism->insertTourismOperator($data); /*if the insert process is success then insert the tourism description*/ if (!empty($tourism_id)) { /*preparing data for tourismoperatordescription table*/ $data = array('tourismoperator_id' => $tourism_id, 'language_id' => 1, 'name' => $_POST['TourismOperatorRegion'], 'description' => $_POST['TourismOperatorLangName']); /*inserting data to the tourismopeprator description table*/ $table_tourismdescription->insertTourismOperatorDescription($data); /*insert all classification to the database*/ $class_tourism = array('classification_id' => 6, 'tourismoperator_id' => $tourism_id); $table_classtotourism->insertClassificationTourism($class_tourism); $this->loggingaction('vito', 'create', $tourism_id); $this->_flash->addMessage('1\\Vito Insert Success!'); } else { $this->_flash->addMessage('2\\Vito Operator Insert Failed!'); } $this->_redirect($this->view->rootUrl('/admin/vito/')); } } /*send variable to the view*/ $this->view->form = $form; }