Last active
June 6, 2017 01:38
-
-
Save dyazincahya/176fd74b23d2167cd13ad77df62b2c61 to your computer and use it in GitHub Desktop.
Mapping preview codeingiter_x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function tmp_freq_preview() | |
{ | |
$post = $this->input->post(); | |
$data_bef_full = $this->fmm->tmp_freq_preview_bef($post, 'all'); | |
$data_bef = array('before' => $this->fmm->tmp_freq_preview_bef($post, 'all')); | |
$data = array('after' => $this->fmm->tmp_freq_preview($post)); | |
$merge = array_merge($data_bef, $data); | |
$diff_before = $this->multi_array_diff($merge['before'], $merge['after']); | |
$diff_after = $this->multi_array_diff($merge['after'], $merge['before']); | |
$final_merge = array_merge($diff_before, $diff_after); | |
$p['data'] = $this->mapping_kat_modif($final_merge); | |
echo $this->load->view('_preview_all', $p, true); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private function mapping_kat_modif($data) { | |
$field_static = array( | |
'fm_no_resi' | |
); | |
$x_mapping = array( | |
'Upgrade BW and Change Freq' => array( | |
'fm_bandwidth' => 'Bandwidth Hz', | |
'fm_tx_freq_isr_2' => 'TR ISR', | |
'fm_rx_freq_isr_2' => 'RX ISR' | |
), | |
'Ganti Perangkat' => array( | |
'fm_ne_ant_id_1' => 'NE Antenna ID', | |
'fm_fe_ant_id_1' => 'FE Antenna ID', | |
'fm_ne_eqp_id' => 'NE Equipment ID', | |
'fm_fe_eqp_id' => 'FE Equipment ID' | |
), | |
'Rename Site ID' => array( | |
'fm_ne_site_id' => 'Near End', | |
'fm_ne_site_name' => 'NE Site Name', | |
'fm_fe_site_id' => 'Far End', | |
'fm_fe_site_name' => 'FE Site Name' | |
), | |
'Relokasi' => array( | |
'fm_long_deg' => 'Long Deg', | |
'fm_long_min' => 'Long Min', | |
'fm_long_sec' => 'Long Sec', | |
'fm_long_reg' => 'Long Reg', | |
'fm_lat_deg' => 'Lat Deg', | |
'fm_lat_min' => 'Long Min', | |
'fm_lat_sec' => 'Long Sec', | |
'fm_lat_reg' => 'Long Reg', | |
'fm_province' => 'Province', | |
'fm_region' => 'Region', | |
'fm_city' => 'City', | |
'fm_district' => 'District', | |
'fm_zona' => 'Zona', | |
'fm_zip_isr' => 'Zip ISR' | |
), | |
'Ganti Alamat' => array( | |
'fm_addr' => 'Address' | |
) | |
); | |
$z_mapping = array(); | |
$total = count($data)/2; | |
$a = 0; | |
while ($a < $total) | |
{ | |
foreach ($x_mapping as $x_key => $x_val) | |
{ | |
$b = 0; | |
foreach ($data[$a] as $key => $value) { | |
if(isset($x_val[$key])){ | |
if(!isset($z_mapping[$x_key]['fields']) || (isset($z_mapping[$x_key]['fields']) && !in_array($x_val[$key]." - before",$z_mapping[$x_key]['fields']))){ $z_mapping[$x_key]['fields'][] = $x_val[$key]." - before";} | |
if(!isset($z_mapping[$x_key]['fields']) || (isset($z_mapping[$x_key]['fields']) && !in_array($x_val[$key]." - after",$z_mapping[$x_key]['fields']))){ $z_mapping[$x_key]['fields'][] = $x_val[$key]." - after"; } | |
// print_r($data[$a+$total]); | |
$z_mapping[$x_key]['data'][$a]['row'][$b][$key."_before"] = $value; | |
$z_mapping[$x_key]['data'][$a]['row'][$b][$key."_after"] = $data[$a+$total][$key]; | |
$z_mapping[$x_key]['data'][$a]['is_change'] = 1; | |
} else { | |
$z_mapping[$x_key]['data'][$a]['is_change'] = isset($z_mapping[$x_key]['data'][$a]['is_change']) && $z_mapping[$x_key]['data'][$a]['is_change'] === 1 ? 1 : 0; | |
} | |
if(in_array($key, $field_static)){ | |
$z_mapping[$x_key]['data'][$a][$key] = $value; | |
} | |
$b++; | |
} | |
} | |
$a++; | |
} | |
return $z_mapping; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private function multi_array_diff($array1, $array2) | |
{ | |
$difference=array(); | |
$arr_count1 = count($array1); | |
$arr_count2 = count($array2); | |
if($arr_count1 == $arr_count2) | |
{ | |
for ($i=0; $i < $arr_count1 ; $i++) | |
{ | |
unset( | |
$array1[$i]['tfm_id'], | |
$array1[$i]['fm_report_date'], | |
$array1[$i]['fm_status_fm'], | |
$array1[$i]['fm_req_status'], | |
$array1[$i]['fm_is_match_plan'], | |
$array1[$i]['fm_is_match_fop'], | |
$array1[$i]['fm_soap_license_no'], | |
$array2[$i]['tfm_id'], | |
$array2[$i]['fm_report_date'], | |
$array2[$i]['fm_status_fm'], | |
$array2[$i]['fm_req_status'], | |
$array2[$i]['fm_is_match_plan'], | |
$array2[$i]['fm_is_match_fop'], | |
$array2[$i]['fm_soap_license_no'] | |
); | |
$difference[$i] = array_diff($array1[$i], $array2[$i]); | |
} | |
} | |
return $difference; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function tmp_freq_preview_bef($post, $s = 'part') | |
{ | |
if($s == 'part'){ | |
$this->db->select("tfm_id, fm_link_simf_id, fm_ne_site_id, fm_fe_site_id, fm_ne_site_name, fm_province, fm_district, fm_city, fm_region, fm_addr, fm_zip_plan, fm_lat_deg, fm_lat_min, fm_lat_sec, fm_lat_reg, fm_long_deg, fm_long_min, fm_long_sec, fm_long_reg, fm_ant_name, fm_ne_ant_type_1, fm_ne_ant_type_2, fm_fe_ant_type_1, fm_fe_ant_type_2, fm_ant_height, fm_ant_dia, fm_eqp_name, fm_eqp_output_power, fm_ant_gain, fm_bandwidth_isr, fm_tx_freq, fm_rx_freq, fm_tx_freq_fo, fm_rx_freq_fo, fm_tx_freq_isr, fm_rx_freq_isr, fm_frequency, fm_isr, fm_no_app, fm_no_spp, fm_report_date, fm_end_date, fm_lapor, fm_status_fm, fm_comp_name, fm_comp_addr, fm_client_id, fm_bhp, fm_sta_no, fm_zona, fm_receipt_no, fm_isr_status, fm_out_freq_date, fm_ex_status, fm_req_status, fm_pro_def, fm_ewo_number, fm_is_match_plan, fm_is_match_fop, fm_link_type_id, fm_remark, fm_int_date, fm_site_height, fm_ne_ant_id_1, fm_fe_ant_id_1, fm_polarization, fm_data_source, fm_ne_eqp_id, fm_fe_eqp_id, fm_soap_license_no"); | |
} else { | |
$this->db->select("*"); | |
} | |
$this->db->from("tmp_freq_man"); | |
$this->db->where('tfm_cart_name', $post['cart_name']); | |
$q = $this->db->get(); | |
return $q->result_array(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
table { | |
border-collapse: collapse; | |
} | |
table, tr, td { | |
border: 1px solid black; | |
} | |
td.head{ | |
background-color: #212121; | |
color: #FFFFFF; | |
font-weight: bold; | |
} | |
td.head-dym{ | |
background-color: #607D8B; | |
color: #FFFFFF; | |
font-weight: bold; | |
} | |
</style> | |
<?php foreach ($data as $key => $val){ ?> | |
<table border="1" cellpadding="5"> | |
<tr> | |
<td class="head">Kategori modifikasi</td> | |
<td class="head">Aplikasi</td> | |
<?php | |
if(isset($val['fields'])) { | |
foreach ($val['fields'] as $key_field => $val_field) { | |
?> | |
<td class="head-dym"><?php echo $val_field;?></td> | |
<?php | |
} | |
} | |
?> | |
</tr> | |
<?php foreach ($val['data'] as $key_sec => $val_sec) { | |
if($val_sec['is_change'] === 1) | |
{ | |
?> | |
<tr> | |
<td><?=$key;?></td> | |
<td><?=$val_sec['fm_no_resi'];?></td> | |
<?php foreach ($val_sec['row'] as $key_trd => $val_trd) { ?> | |
<?php foreach ($val_trd as $key_fur => $val_fur) { ?> | |
<td><?=$val_fur;?></td> | |
<?php } ?> | |
<?php } ?> | |
</tr> | |
<?php } } ?> | |
</table> | |
<br/> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment