function flight_avail() { // print_r($source_update_ids); $conf = new conf(); $db = new db_flight(); $query = "SELECT * FROM source_update WHERE stat=0 "; $res = $db->query($query); while ($row = $res->fetch_assoc()) { $db->query("UPDATE `source_update` SET `stat` = '2' WHERE `source_update`.`id` =" . $row['id'] . ";"); switch ($row['source_id']) { case 1: // GOHAR $db->query("UPDATE `source_update` SET `stat` = '1',last_update='" . date('Y-m-d H:i:s') . "' WHERE `source_update`.`id` =" . $row['id'] . ";"); break; case 3: // MERAJ require_once 'MerajDrive.php'; $source_class = new MerajDrive($db, $conf->meraj_auth, $conf->meraj_base_url); $source_class->update_avail($row['id'], $row['source_id']); break; case 4: // PARTO break; case 2: case 10: // Gardoon // Gardoon case 11: case 12: // Hamoon Gasht // Hamoon Gasht case 13: // Binalood // Binalood case 14: case 15: // Donya Seir // Donya Seir case 16: // Arad Gasht // Arad Gasht case 17: require_once 'gabriel_reserve.php'; $source_class = new gabriel_reserve($db); $source_class->update_avail($row['id'], $row['source_id']); break; } } }
function reserve_start($user, $pass, $source_id, $flight_id, $ncap, $class_ghimat, $adl, $chd, $inf, $ip, $agency_id, $refrence_id, $tflight) { // echo "source_id=$source_id | flight_id = $flight_id | ncap= $ncap | class_ghimat=$class_ghimat | adl=$adl | chd= $chd | inf=$inf | ip= $ip | agency_id=$agency_id"; $sess = UsernameToken($user, $pass); $user_id = (int) $sess['user_id']; $customer_id = (int) $sess['customer_id']; if ($customer_id <= 0) { $out['err']['code'] = 2; $out['err']['msg'] = 'AUTH ERROR'; return json_encode($out); } $out['err']['code'] = 3; $out['err']['msg'] = 'SOURCE UNDFINED'; $conf = new conf(); // $my = new mysqli($conf->local_host, $conf->local_user, $conf->local_pass, $conf->local_db); $my = new db_flight(); $tf = explode(',', $source_id); // $out['source_ids'] = $source_id; $source_id = (int) $tf[0]; $source_id2 = 0; if (count($tf) == 2) { $source_id2 = (int) $tf[1]; } $tf = explode(",", $flight_id); $bflight_id = 0; if (count($tf) == 2) { $flight_id = $tf[0]; $bflight_id = $tf[1]; } $tf = explode(",", $ncap); $bncap = 0; if (count($tf) == 2) { $ncap = $tf[0]; $bncap = $tf[1]; } $tf = explode(",", $class_ghimat); $bclass_ghimat = ''; if (count($tf) == 2) { $class_ghimat = $tf[0]; $bclass_ghimat = $tf[1]; } $tf = explode(",", $agency_id); $bagency_id = ''; if (count($tf) == 2) { $agency_id = $tf[0]; $bagency_id = $tf[1]; } $tf = explode(",", $tflight); $btflight = ''; if (count($tf) == 2) { $tflight = $tf[0]; $btflight = $tf[1]; } if ($source_id == 1) { $params = array('customer_id' => -10, 'agency_id' => $agency_id, 'flight_id' => $flight_id, 'ncap' => $ncap, 'bflight_id' => 0, 'bncap' => 0, 'adult' => $adl, 'child' => $chd, 'inf' => $inf, 'ip' => $ip); // print_r($params); // $out['source'] = "source_id = $source_id,source_id2 = $source_id2"; if ($source_id2 == $source_id) { $params['bflight_id'] = $bflight_id; $params['bncap'] = $bncap; } $client = new nusoap_client('http://164.138.22.33/AAA/server.php?wsdl', true); // print_r($client); $err = $client->getError(); if ($err) { $out['err']['code'] = 40; $out['err']['msg'] = 'GOHAR CONNECTION ERROR'; return json_encode($out); } $my->log_request($refrence_id, '', 1, 1, $source_id, json_encode($params), $user_id); // print_r($params); $result = $client->call('Reserve', array('param' => json_encode($params))); $my->log_request($refrence_id, '', 1, 2, $source_id, $result, $user_id); if ($client->fault) { $out['err']['code'] = 41; $out['err']['msg'] = 'GOHAR CONNECTION ERROR'; return json_encode($out); } else { $err = $client->getError(); if ($err) { $out['err']['code'] = 42; $out['err']['msg'] = 'GOHAR CONNECTION ERROR ' . "\n" . $err; return json_encode($out); } else { // // var_dump($result); if ($out['err']['code'] != 0) { $out['err']['code'] = 0; $out['err']['msg'] = ''; } // $refrence_id = 0; // print_r($result); $gres = json_decode($result); // print_r($gres); if (isset($gres->status) && $gres->status == 1) { if ($my->connect_errno !== FALSE) { // $my->query("insert into refrence (user_id,tarikh,source_id) values ($user_id,'" . date("Y-m-d H:i:s") . "',1)"); // $out['refrence_id'] = $my->insert_id; // $refrence_id = $out['refrence_id']; $query = "insert into reserve_tmp ( `user_id`, `source_id`, `flight_id`, `ncap`, `class_ghimat`, `adl`, `chd`, `inf`, `ip`, `agency_id`, `first_time`,`first_out`,`bflight_id`,`bncap`,`refrence_id`,`voucher_id`,`tflight`,`btflight`) values"; $query .= "({$user_id},{$source_id}, {$flight_id}, {$ncap}, '{$class_ghimat}', {$adl}, {$chd}, {$inf}, '{$ip}', {$agency_id},'" . date("Y-m-d H:i:s") . "','{$result}',{$bflight_id},{$bncap},{$refrence_id}," . $gres->voucher_id . ",'{$tflight}','{$btflight}')"; // echo $query."\n\r"; $my->query($query); // $out['query'] = var_export($params, TRUE); } // print_r($gres); $out['voucher_id'][] = $gres->voucher_id; $out['price']['total_price'] = $gres->total_price + $gres->total_tax + $gres->total_tax2; $out['price']['adult_price'] = $gres->adult_price - $gres->adult_off + $gres->tax_adult + $gres->tax2_adult; $out['price']['child_price'] = $gres->child_price - $gres->child_off + $gres->tax_child + $gres->tax2_child; $out['price']['inf_price'] = $gres->inf_price + $gres->tax_inf + $gres->tax2_inf; $out['price']['badult_price'] = $gres->badult_price - $gres->badult_off + $gres->btax_adult + $gres->btax2_adult; $out['price']['bchild_price'] = $gres->bchild_price - $gres->bchild_off + $gres->btax_child + $gres->btax2_child; $out['price']['binf_price'] = $gres->binf_price + $gres->btax_inf + $gres->btax2_inf; } else { // var_dump($gres); $out['err']['code'] = 27; $out['err']['msg'] = "UNKNOWN AGENCY"; $out['err']['source_code'] = $gres->error->error_code; $out['err']['source_msg'] = $gres->error->error_msg; } } if ($source_id2 != $source_id && (int) $source_id2 > 0) { if ($my->connect_errno !== FALSE) { $query = "insert into reserve_tmp ( `user_id`, `source_id`, `flight_id`, `ncap`, `class_ghimat`, `adl`, `chd`, `inf`, `ip`, `agency_id`, `first_time`,`first_out`,`bflight_id`,`bncap`,`refrence_id`) values"; $query .= "({$user_id},{$source_id2}, {$bflight_id}, {$bncap}, '{$bclass_ghimat}', {$adl}, {$chd}, {$inf}, '{$ip}', {$bagency_id},'" . date("Y-m-d H:i:s") . "','{$result}',0,0,{$refrence_id})"; $my->query($query); } } return json_encode($out); } } }