View difference between Paste ID: 3aDdgcVU and xBgUkhU2
SHOW: | | - or go back to the newest paste.
1
<?php
2
 // echo '<pre>'.$_POST['data_filght'].'<pre>';
3-
//extract data from the post
3+
   //parse_str($_POST['data_filght'],$result);
4-
extract($_POST);
4+
 // $array = json_decode($result, true);
5-
$session=$_POST['session'];
5+
  
6-
$search = json_decode($_POST['search'],true);
6+
  
7-
$data_flight=json_decode($_POST['data_filght'],true);
7+
  $array = json_decode($_POST['data_filght'], true);
8
  $search = json_decode($_POST['search'], true);
9-
/* echo $session;
9+
  $session = $_POST['session'];
10-
echo '<pre>' . print_r($data_flight['Flight_Detail'], true) . '</pre>';
10+
  
11-
   echo '<pre>' . print_r($search, true) . '</pre>'; */
11+
  
12
  
13-
$count_depart = count($data_flight['Flight_Detail']['Departure']);
13+
  echo $session;
14-
$count_return = count ($data_flight['Flight_Detail']['Return']);
14+
  //print_r ($array['Flight_Detail']);
15-
$origin = $search['originCode'];
15+
  echo '<pre>' . print_r($array['Flight_Detail'], true) . '</pre>';
16-
$dest = $search['destinationCode'];
16+
   echo '<pre>' . print_r($search, true) . '</pre>';
17-
$depart_date = $search['departureDate'];
17+
 //echo '<pre>' . print_r( $result['Account_Api_Login'], true) . '</pre>';
18-
$return_date = $search['returnDate'];
18+
 $adult = $search['adult'];
19-
$adult = $search['adult'];
19+
20-
$child = $search['children'];
20+
 $children = $search['children'];
21-
$infant = $search['infant'];
21+
 $infant = $search['infant'];
22
 $flight = $array['Flight_Detail'];
23-
//set POST variables
23+
 
24-
$url = 'https://www.patihgo.com/airline.intl/ota_api_dev';
24+
25
 
26-
if($count_depart == 1){
26+
 $adl=0;
27-
$field_array = Array (
27+
 $cld=0;
28-
						
28+
 $ifn=0;
29-
						 0=> Array (
29+
 
30-
								'Origin' => 'CGK', 
30+
 echo '<form action="book.php" method="post">';
31-
								'Destination' => 'SIN',
31+
	echo '<table>';
32-
								'Flight_Number' => 'GA 88', 
32+
	echo '<tr><td><font size="3" color="red">Pemesasn</font></td></tr>
33-
								'Marketing_Airline' => 'GA', 
33+
		  <tr><td>Jenis Kelamin</td><td>:</td><td><select name="jk">
34-
								'DepartureDateTime' => '2015-09-26T20:50', 
34+
											<option value="MR">MR</option>
35-
								'ArrivalDateTime' => '2015-09-26T23:50', 
35+
											<option value="MRS">MRS</option>
36-
								'Flight_Class' => 'H', 
36+
											<option value="MISS">MISS</option>
37-
							)	
37+
											</option></td></tr>
38-
						
38+
		   <tr><td>First Name</td><td>:</td><td><input type="text" name="fs"></td></tr>
39-
						); 
39+
		   <tr><td>Last Name</td><td>:</td><td><input type="text" name="ls"></td></tr>
40-
		}else {
40+
		   <tr><td>Phone</td><td>:</td><td><input type="text" name="phone"></td></tr>
41
		   <tr><td>Email</td><td>:</td><td><input type="text" name="email"></td></tr><br/><br/>
42
		   ';
43
	echo "<textarea name='data_filght'>".$_POST['data_filght']."</textarea>
44-
				$field_array = Array (
44+
		  <textarea name='search' >".$_POST['search']."</textarea>	
45-
						
45+
					<input type='text' name='session' value='".$session."'>
46-
						
46+
				   ";
47-
						
47+
		  									
48-
						0 => $field_loop,
48+
		if (!empty($adult)){
49-
						1 => $field_loop
49+
	echo '<tr> <td><font size="3" color="red">Adult</font></td></tr>';
50-
						
50+
 for ($adl=1;$adl<=$adult;$adl++){
51-
						); 
51+
	echo '<tr><td>Jenis Kelamin</td><td>:</td><td><select name="jka'.$adl.'">
52-
					
52+
											<option value="MR">MR</option>
53
											<option value="MRS">MRS</option>
54-
		}
54+
											<option value="MISS">MISS</option>
55
											</option></td></tr>
56-
$fields = Array (
56+
		   <tr><td>First Name</td><td>:</td><td><input type="text" name="fsa'.$adl.'"></td></tr>
57-
					'Account_Api_Login' => Array (
57+
		   <tr><td>Last Name</td><td>:</td><td><input type="text" name="lsa'.$adl.'"></td></tr>
58-
					'Agent_Code' => 'E3B5A',  //PatihGo Sub Agent Code
58+
		   <tr><td>Phone</td><td>:</td><td><input type="text" name="phonea'.$adl.'"></td></tr>
59-
					'Username' => 'I1L3B2',  //PatihGo Username Credential
59+
		   <tr><td>Email</td><td>:</td><td><input type="text" name="emaila'.$adl.'"></td></tr><br/><br/>
60-
					'Password' => 'I235BA35',
60+
61-
			), 
61+
	
62-
				'Session' => $session,  //Session From Availability
62+
	';
63-
				'Method' => 'Ota_Book', 
63+
	
64-
					'Ota_Book' => Array (
64+
 
65-
						'Origin' => $origin,
65+
66-
						'Dest' => $dest, 
66+
 
67-
						'DepartureDate' => $depart_date, 
67+
 }
68-
						'ReturnDate' =>$return_date, 
68+
 
69-
						'Adult' => $adult, 
69+
 }
70-
						'Children' => $child, 
70+
 
71-
						'Infant' => $infant, 
71+
 if (!empty($children)){
72-
						'Departure_Route' => $field_array,
72+
	echo '<tr> <td><font size="3" color="red">Children</font></td></tr>';
73-
						
73+
 for ($cld=1;$cld<=$children;$cld++){
74-
			'Pax_Detail' => Array (
74+
	echo '<tr><td>Jenis Kelamin</td><td>:</td><td><select name="jkc'.$cld.'">
75-
							'Contact_Name_Salutation' => 'MR', 
75+
											<option value="MR">MR</option>
76-
							'Contact_First_Name' => 'Ary', 
76+
											<option value="MRS">MRS</option>
77-
							'Contact_Last_Name' => 'Safitry',
77+
											<option value="MISS">MISS</option>
78-
							'Contact_Email' => 'dennyalvin23@gmail.com', 
78+
											</option></td></tr>
79-
							'Contact_Phone' => '08145612154', 
79+
		   <tr><td>First Name</td><td>:</td><td><input type="text" name="fsc'.$cld.'"></td></tr>
80-
							'Adult' => Array (
80+
		   <tr><td>Last Name</td><td>:</td><td><input type="text" name="lsc'.$cld.'"></td></tr>
81-
								0 => Array (
81+
		   <tr><td>Phone</td><td>:</td><td><input type="text" name="phonec'.$cld.'"></td></tr>
82-
									'Salutation' => 'MRS', 
82+
		   <tr><td>Email</td><td>:</td><td><input type="text" name="emailc'.$cld.'"></td></tr>
83-
									'First_Name' => 'Ary', 
83+
		   <tr><td>Birth Day</td><td>:</td><td><input type="text" name="birthc'.$cld.'"></td></tr><br/><br/>
84-
									'Last_Name' => 'Safitri', 
84+
85-
									'Phone_Number' => '0814532123', 
85+
	
86-
									'Email' => 'dennyalvin23@gmail.com',
86+
	';
87-
								),
87+
	
88-
									
88+
 
89-
								
89+
90-
							), 
90+
 
91-
						) 
91+
 }
92-
					) 
92+
 
93-
			);
93+
 }
94-
			
94+
 
95-
			
95+
 
96-
			echo '<pre>' . print_r($fields, true) . '</pre>';
96+
  if (!empty($infant)){
97-
			exit();
97+
	echo '<tr> <td><font size="3" color="red">Infant</font></td></tr>';
98
 for ($ifn=1;$ifn<=$infant;$ifn++){
99-
//url-ify the data for the POST
99+
	echo '<tr><td>Jenis Kelamin</td><td>:</td><td><select name="jki'.$ifn.'">
100-
$field_string = http_build_query($fields);
100+
											<option value="MR">MR</option>
101
											<option value="MRS">MRS</option>
102-
//open connection
102+
											<option value="MISS">MISS</option>
103-
$ch = curl_init();
103+
											</option></td></tr>
104
		   <tr><td>First Name</td><td>:</td><td><input type="text" name="fsi'.$ifn.'"></td></tr>
105-
//set the url, number of POST vars, POST data
105+
		   <tr><td>Last Name</td><td>:</td><td><input type="text" name="lsi'.$ifn.'"></td></tr>
106-
curl_setopt($ch,CURLOPT_URL, $url);
106+
		   <tr><td>Birth Day</td><td>:</td><td><input type="text" name="birthi'.$ifn.'"></td></tr>		
107-
curl_setopt($ch,CURLOPT_POSTFIELDS, $field_string);
107+
	
108-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
108+
	';
109
	
110-
//execute post
110+
 
111-
$result = curl_exec($ch);
111+
112
 
113-
print_r($result);
113+
 }
114
 
115
 }
116-
//close connection
116+
 
117-
curl_close($ch);
117+
 echo'<tr><td colspan="3"><input type="submit" value="Submit"></td></tr>';
118
 echo '</table></form>';
119
 
120
 
121
122
 
123
?>