Ejemplo n.º 1
0
 function edit($id)
 {
     //if (!$this->cms->has_write($this->module)) redirect ("admin/error");
     if ($this->encrypt_status == TRUE) {
         $id_enc = $id;
         $id = decrypt($id);
     }
     // debug();
     $this->msg_ok = "Link updated successfully";
     $this->msg_fail = "Unable to update link";
     $act = $this->input->post("act") ? $this->input->post("act") : "";
     if (empty($act)) {
         $arrData = $this->model->GetRecordData("idx={$id}");
         $arrData += $this->model_contact->GetRecordData("id_wa={$id}");
         $arrData += $this->model_sejarah->GetRecordData("id_wa={$id}");
         $arrData += $this->model_hak_atas_tanah->GetRecordData("id_wa={$id}");
         $arrData += $this->model_hayati->GetRecordData("id_wa={$id}");
         $arrData += $this->model_lembaga_adat->GetRecordData("id_wa={$id}");
         $arrData += $this->model_hukum_adat->GetRecordData("id_wa={$id}");
         //$arrData+=$this->model_potensi_hayati->GetRecordData("id_wa=$id");
         $data["data"] = $arrData;
         $data["batas_wilayah"] = $this->model_batas_wilayah->SearchRecordWhere("id_wa={$id}");
         $dataFile = $this->model_file->SearchRecordWhere("id_parent={$id}");
         $dataFileJenisDoc = array();
         if (cek_array($dataFile)) {
             foreach ($dataFile as $file) {
                 $dataFileJenisDoc[$file["id_jenis_doc"]][] = $file;
             }
         }
         $data["data_file2"] = $dataFileJenisDoc;
         $data["data_file"] = $dataFile;
         $data["data_file_peta"] = $this->model_file_peta->SearchRecordWhere("id_parent={$id}");
         $data["data_image"] = $this->model_image->SearchRecordWhere("id_parent={$id}");
         //$data["potensi_hayati"]=$this->model_potensi_hayati->SearchRecordWhere("id_wa=$id");
         $arrDataPotensiMap = array();
         $arrDataPotensi = $this->model_potensi_hayati->SearchRecordWhere("id_wa={$id}");
         if (cek_array($arrDataPotensi)) {
             foreach ($arrDataPotensi as $x => $val) {
                 $arrDataPotensiMap[$val["id_potensi_hayati"]] = $val;
             }
         }
         $data["potensi"] = $arrDataPotensiMap;
         $data["potensi_lain"] = $this->model_potensi_hayati_lain->SearchRecordWhere("id_wa={$id}");
         $data["pembagian_ruang"] = $this->model_pembagian_ruang->SearchRecordWhere("id_wa={$id}");
         $data["arr_kab"] = $this->get_kab_kota_arr($arrData["id_propinsi"]);
         $this->_render_page($this->module . "v_edit", $data, true);
     }
     if ($act == "update") {
         // debug();
         $this->conn->StartTrans();
         wa_log_start($id);
         $data = get_post();
         $data_batas_wilayah = array();
         if (cek_array($data["batas"])) {
             $arr_tmp = array_combine($data["batas"], $data["batas_val"]);
             foreach ($arr_tmp as $batas => $batas_val) {
                 $tmp = array();
                 $tmp["batas"] = $batas;
                 $tmp["batas_val"] = $batas_val;
                 $data_batas_wilayah[] = $tmp;
             }
         }
         // $data_pembagian_ruang=array();
         // if(cek_array($data["ruang"])):
         // $arr_tmp=array_combine($data["ruang"],$data["ruang_val"]);
         // foreach($arr_tmp as $ruang=>$ruang_val):
         // $tmp=array();
         // $tmp["pemanfaatan_kawasan"]=$ruang;
         // $tmp["luas"]=$ruang_val;
         // $data_pembagian_ruang[]=$tmp;
         // endforeach;
         // endif;
         $data_potensi = array();
         if (cek_array($data["potensi"])) {
             $arr_tmp = array_combine($data["id_potensi"], $data["potensi_val"]);
             $arr_tmp2 = array_combine($data["id_potensi"], $data["potensi"]);
             foreach ($arr_tmp as $id_potensi => $keterangan) {
                 $tmp = array();
                 $tmp["id_potensi_hayati"] = $id_potensi;
                 $tmp["nama_potensi_hayati"] = $arr_tmp2[$id_potensi];
                 $tmp["keterangan"] = $keterangan;
                 $data_potensi[] = $tmp;
             }
         }
         $data_potensi_lain = array();
         if (cek_array($data["potensi_lain"])) {
             $arr_tmp = array_combine($data["potensi_lain"], $data["potensi_lain_val"]);
             foreach ($arr_tmp as $ruang => $ruang_val) {
                 $tmp = array();
                 $tmp["nama_potensi_hayati"] = $ruang;
                 $tmp["keterangan"] = $ruang_val;
                 $data_potensi_lain[] = $tmp;
             }
         }
         $data['kondisi_fisik'] = implode(",", $data['list_kondisi_fisik']);
         $data = $this->_add_editor($data);
         unset($data[$this->tbl_idx]);
         // pre($data);exit;
         $this->model->UpdateData($data, "{$this->tbl_idx}={$id}");
         $data_update = $data;
         $data_update["id_wa"] = $id;
         $this->model_contact->DeleteData("id_wa=" . $id);
         $this->model_contact->InsertData($data_update);
         $this->model_sejarah->DeleteData("id_wa=" . $id);
         $this->model_sejarah->InsertData($data_update);
         $this->model_hukum_adat->DeleteData("id_wa=" . $id);
         $this->model_hukum_adat->InsertData($data_update);
         $this->model_hayati->DeleteData("id_wa=" . $id);
         $this->model_hayati->InsertData($data_update);
         $this->model_lembaga_adat->DeleteData("id_wa=" . $id);
         $this->model_lembaga_adat->InsertData($data_update);
         $this->model_hak_atas_tanah->DeleteData("id_wa=" . $id);
         $this->model_hak_atas_tanah->InsertData($data_update);
         $this->model_potensi_hayati->DeleteData("id_wa=" . $id);
         $this->model_potensi_hayati->InsertData($data_update);
         //update file peta
         $this->update_image($id);
         $this->update_file($id);
         $this->update_file_peta($id);
         //batas_wilayah_lain
         $this->model_batas_wilayah->DeleteData("id_wa=" . $id);
         if (cek_array($data_batas_wilayah)) {
             foreach ($data_batas_wilayah as $data_batas) {
                 $data_batas["id_wa"] = $id;
                 $this->model_batas_wilayah->InsertData($data_batas);
             }
         }
         //pemanfaatan pembagian_ruang
         // $this->model_pembagian_ruang->DeleteData("id_wa=".$id);
         // if(cek_array($data_pembagian_ruang)):
         // foreach($data_pembagian_ruang as $data_ruang):
         // $data_ruang["id_wa"]=$id;
         // $this->model_pembagian_ruang->InsertData($data_ruang);
         // endforeach;
         // endif;
         //data_potensi
         $this->model_potensi_hayati->DeleteData("id_wa=" . $id);
         if (cek_array($data_potensi)) {
             foreach ($data_potensi as $data_pot) {
                 $data_pot["id_wa"] = $id;
                 $this->model_potensi_hayati->InsertData($data_pot);
             }
         }
         //data_potensi_lain
         $this->model_potensi_hayati_lain->DeleteData("id_wa=" . $id);
         if (cek_array($data_potensi_lain)) {
             foreach ($data_potensi_lain as $data_potensi_lain) {
                 $data_potensi_lain["id_wa"] = $id;
                 $this->model_potensi_hayati_lain->InsertData($data_potensi_lain);
             }
         }
         wa_log_update($id);
         $ok = $this->conn->CompleteTrans();
         $this->_proses_message($ok, $this->module . "edit/{$id_enc}", $this->module . "edit/{$id_enc}");
     }
 }
Ejemplo n.º 2
0
 function del($id)
 {
     if (!$this->cms->has_admin($this->module)) {
         redirect("error_");
     }
     if ($this->encrypt_status == TRUE) {
         $id_enc = $id;
         $id = decrypt($id);
     }
     $this->msg_ok = "Data deleted successfully";
     $this->msg_fail = "Unable to delete data";
     $arrData = $this->model->GetRecordData("{$this->tbl_idx}={$id}");
     $act = "delete";
     if ($act == "delete") {
         wa_log_start($id);
         $this->conn->StartTrans();
         $this->model->DeleteData("{$this->tbl_idx}={$id}");
         $this->model_contact->DeleteData("id_wa=" . $id);
         $this->model_sejarah->DeleteData("id_wa=" . $id);
         $this->model_hukum_adat->DeleteData("id_wa=" . $id);
         $this->model_hayati->DeleteData("id_wa=" . $id);
         $this->model_lembaga_adat->DeleteData("id_wa=" . $id);
         $this->model_hak_atas_tanah->DeleteData("id_wa=" . $id);
         wa_log_delete($id);
         $ok = $this->conn->CompleteTrans();
         $this->_proses_message($ok, $this->module . "listview", $this->module . "view/{$id_enc}");
     }
 }