· 5 years ago · Mar 14, 2020, 03:28 AM
1======================= CONTROLLER =================
2
3 function update_courier() {
4 // cek validate form
5 $valid = simple_decrypt($this->input->post('valid'));
6 if($valid != 1) {
7 get_redirecting('profile');
8 }
9 // get from post
10 $id = $this->session->userdata('vendor_id');
11 $courier = json_encode($this->input->post('courier'));
12
13 if($id!=""){
14
15 // cek result
16 $rst = set_courier($id, $courier);
17 // echo var_dump($courier); die;
18 if($rst->status == TRUE){
19 $result = 1;
20 }
21 else{
22 $result = 0;
23 }
24
25 // set notification
26 get_notif($result, 'update courier');
27 }
28 else{
29 // set notification
30 get_notif(0, 'Harap Lengkapi Form');
31 }
32
33 get_redirecting('profile');
34 }
35
36===================================== HELPER CONTROLLEr =======================
37function set_courier($vendor, $courier) {
38 $CI = &get_instance();
39 $CI->load->helper('curling');
40
41 $data = array(
42 'vendor' => $vendor,
43 'courier' => $courier
44 );
45
46 $header[] = secret_key .": ". api_key;
47 $url = api_url ."vendor/set_courier";
48 $rsp = send_post_data($header, $data, $url);
49
50 return $rsp;
51 }