예제 #1
0
 public static function search($date, $rdate, $from_city, $to_city, $extra, $airlines, $sort, $way)
 {
     function perToEnNums($inNum)
     {
         $outp = $inNum;
         $outp = str_replace('۰', '0', $outp);
         $outp = str_replace('۱', '1', $outp);
         $outp = str_replace('۲', '2', $outp);
         $outp = str_replace('۳', '3', $outp);
         $outp = str_replace('۴', '4', $outp);
         $outp = str_replace('۵', '5', $outp);
         $outp = str_replace('۶', '6', $outp);
         $outp = str_replace('۷', '7', $outp);
         $outp = str_replace('۸', '8', $outp);
         $outp = str_replace('۹', '9', $outp);
         return $outp;
     }
     $out = array();
     $conf = new conf();
     $url = $conf->wurl . "rest/lowfaresearch";
     $User = $conf->wuser;
     $Password = $conf->wpass;
     $dtmp = explode('/', perToEnNums($date));
     $mtmp = jalali_to_jgregorian($dtmp[0], $dtmp[1], $dtmp[2]);
     $date = $mtmp[0] . '-' . str_pad($mtmp[1], 2, "0", STR_PAD_LEFT) . '-' . str_pad($mtmp[2], 2, "0", STR_PAD_LEFT);
     $timestamp = date('Y-m-dTH:i:s+3:30');
     $data = '<OTA_AirLowFareSearchRQ xmlns="http://www.opentravel.org/OTA/2003/05"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 
                 OTA_AirLowFareSearchRQ.xsd" EchoToken="1234" TimeStamp="' . $timestamp . '"
                 Target="New" Version="2.001" SequenceNmbr="1" PrimaryLangID="En-us">	
                       <OriginDestinationInformation>
                               <DepartureDateTime>' . $date . '</DepartureDateTime>
                               <OriginLocation LocationCode="' . $from_city . '"/>
                               <DestinationLocation LocationCode="' . $to_city . '"/>
                       </OriginDestinationInformation>';
     if ($rdate != '') {
         $dtmp = explode('/', perToEnNums($rdate));
         //            var_dump($dtmp);
         $mtmp = jalali_to_jgregorian($dtmp[0], $dtmp[1], $dtmp[2]);
         $rdate = $mtmp[0] . '-' . str_pad($mtmp[1], 2, "0", STR_PAD_LEFT) . '-' . str_pad($mtmp[2], 2, "0", STR_PAD_LEFT);
         $data .= '<OriginDestinationInformation>
                         <DepartureDateTime>' . $rdate . '</DepartureDateTime>
                         <OriginLocation LocationCode="' . $to_city . '"/>
                         <DestinationLocation LocationCode="' . $from_city . '"/>
                 </OriginDestinationInformation>';
     }
     $data .= '</OTA_AirLowFareSearchRQ>';
     //        echo "REQUEST : <br/>\n" . $data;
     $json = search_class::sendRequest($url, $User, $Password, $data);
     //        echo "<br/>\nRESPONSE : <br/>\n" . $json;
     $new_out = json_decode($json, TRUE);
     //        var_dump($new_out);
     $out = $new_out;
     //[0];
     return $out;
 }
예제 #2
0
 public function hamed_jalalitomiladi($str)
 {
     $s = explode('/', $str);
     $out = "";
     if (count($s) == 3) {
         $y = (int) $s[0];
         $m = (int) $s[1];
         $d = (int) $s[2];
         if ($d > $y) {
             $tmp = $d;
             $d = $y;
             $y = $tmp;
         }
         $y = $y < 1000 ? $y + 1300 : $y;
         $miladi = jalali_to_jgregorian($y, $m, $d);
         $out = $miladi[0] . "-" . $miladi[1] . "-" . $miladi[2];
     }
     return $out;
     //jalali_to_gregorian()
 }
예제 #3
0
 public static function jalaliToMiladi($str)
 {
     $s = explode('/', $str);
     $out = "";
     if (count($s) == 3) {
         if ((int) $s[2] > (int) $s[0]) {
             $t = $s[0];
             $s[0] = $s[2];
             $s[2] = $t;
         }
         $miladi = jalali_to_jgregorian($s[0], $s[1], $s[2]);
         if ((int) $miladi[1] < 10) {
             $miladi[1] = "0" . $miladi[1];
         }
         if ((int) $miladi[2] < 10) {
             $miladi[2] = "0" . $miladi[2];
         }
         $out = $miladi[0] . "-" . $miladi[1] . "-" . $miladi[2];
     }
     return $out;
 }
예제 #4
0
파일: jdf.php 프로젝트: jnaroogheh/darvishi
function jmktime($h = '', $m = '', $s = '', $jm = '', $jd = '', $jy = '', $is_dst = '-1')
{
    $h = tr_num($h);
    $m = tr_num($m);
    $s = tr_num($s);
    if ($h == '' and $m == '' and $s == '' and $jm == '' and $jm == '' and $jd == '' and $jy == '') {
        return mktime();
    } else {
        list($year, $month, $day) = jalali_to_jgregorian($jy, $jm, $jd);
        return mktime($h, $m, $s, $month, $day, $year, $is_dst);
    }
}
예제 #5
0
 public static function passengers($refID, $passengers, $mobile, $email, $address, $description, $flight1, $flight2)
 {
     $out['err']['code'] = 8;
     $out['err']['msg'] = 'UNKNOWN ERROR';
     $conf = new conf();
     $url = $conf->wurl . "rest/book";
     $User = $conf->wuser;
     $Password = $conf->wpass;
     $npass = array();
     foreach ($passengers as $i => $p) {
         $birthday = explode('-', $p['birthday']);
         $bdate_arr = jalali_to_jgregorian($birthday[0], $birthday[1], $birthday[2]);
         $passenger = array("gender" => $p['gender'] == 1 ? 'M' : 'F', "fname" => $p['fname_en'], "lname" => $p['lname_en'], 'nationality' => 'IRN', 'nationalCode' => trim($p['passport_engheza']) != '' ? '' : $p['shomare_melli'], "passportId" => trim($p['passport_engheza']) == '' ? '' : $p['shomare_melli'], "passportExpire" => trim($p['passport_engheza']), 'passportIssueCountry' => 'IRN', "birthDate" => $bdate_arr[0] . '-' . $bdate_arr[1] . '-' . $bdate_arr[2]);
         $npass[] = $passenger;
     }
     $dtmp = explode('-', $flight1['fdate']);
     $mtmp = jalali_to_jgregorian($dtmp[0], $dtmp[1], $dtmp[2]);
     $flight1['fdate'] = $mtmp[0] . '-' . $mtmp[1] . '-' . $mtmp[2];
     $flight1['arrivalDate'] = $flight1['fdate'];
     if ($flight1['ltime'] < $flight1['ftime']) {
         $flight1['arrivalDate'] = date("Y-m-d", strtotime($flight1['fdate'] . ' + 1 day'));
     }
     $req = ' <OTA_AirBookRQ xmlns="http://www.opentravel.org/OTA/2003/05" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xsi:schemaLocation="http://www.opentravel.org/OTA/2008/05  
                OTA_AirBookRQ.xsd" EchoToken="50987" TimeStamp="2015-11-02IRST16:06:12+03:30" 
                Target="Real" Version="2.001" SequenceNmbr="1" PrimaryLangID="En-us"> 
     <AirItinerary DirectionInd="OneWay"> 
         <OriginDestinationOptions> 
             <OriginDestinationOption> 
                 <FlightSegment TFlight="' . $flight1['tflight'] . '" FlightNumber="' . $flight1['flight_number'] . '" ResBookDesigCode="H" DepartureDateTime="' . $flight1['fdate'] . 'T' . $flight1['ftime'] . ':00.000+03:30" 
                                ArrivalDateTime="' . $flight1['arrivalDate'] . 'T' . $flight1['ltime'] . ':00.000+03:30" StopQuantity="0" RPH="1"> 
                     <DepartureAirport LocationCode="' . $flight1['from_city'] . '" Terminal="T1"/> 
                     <ArrivalAirport LocationCode="' . $flight1['to_city'] . '" Terminal="T2"/> 
                 </FlightSegment> 
             </OriginDestinationOption> 
         </OriginDestinationOptions> 
     </AirItinerary> 
     <PriceInfo> 
         <ItinTotalFare> 
             <TotalFare CurrencyCode="IRR" DecimalPlaces="0" Amount="' . $flight1['price'] . '"/> 
         </ItinTotalFare> 
     </PriceInfo> 
     <TravelerInfo>';
     foreach ($npass as $passenger) {
         $req .= '<AirTraveler PassengerTypeCode="ADT" Gender="' . $passenger['gender'] . '" BirthDate="' . $passenger['birthDate'] . '" AccompaniedByInfantInd="false"> 
             <PersonName> 
                 <NamePrefix>Mr</NamePrefix> 
                 <GivenName>' . $passenger['fname'] . '</GivenName>  
                 <Surname>' . $passenger['lname'] . '</Surname> 
             </PersonName> 
             <Telephone PhoneNumber="' . $mobile . '"/> 
             <Email>' . $email . '</Email> 
             <Document DocID="' . $passenger['passportId'] . '" DocHolderNationality="' . $passenger['passportIssueCountry'] . '"/>  
         </AirTraveler>';
     }
     $req .= '</TravelerInfo> 
     </OTA_AirBookRQ>';
     //        echo "REQUEST : <br/>\n" . $req;
     $content = reserve_class::sendRequest($url, $User, $Password, $req);
     //        echo "<br/>\nRESPONSE:<br/>\n" . $content;
     $xml = new SimpleXMLElement($content);
     if (empty($xml->Errors)) {
         $t = (array) $xml->AirReservation->BookingReferenceID;
         $refrenceId = $t['@attributes']['ID'];
         //            $return = [
         //                'result' => 'success',
         //                'refrenceId' => $refrenceId,
         //                'errors' => []
         //            ];
         $out['err']['code'] = 0;
         $out['err']['msg'] = '';
         $out['refrence_id'] = $refrenceId;
     } else {
         //            var_dump((array) $xml->Errors);
         //            foreach ((array) $xml->Errors as $index => $node) {
         //                $n = (array)$node[0];
         //                $node= (array)$n[0];
         //                var_dump($node);
         //                $code = $node["@attributes"]['Code'];
         //                $msg = $node["@attributes"]['Message'];
         //                $out['err']['code'] = $code;
         //                $out['err']['msg'] = $msg;
         //            }
         $errors = (array) $xml->Errors;
         $error = (array) $errors['Error'];
         $code = $error["@attributes"]['Code'];
         $msg = $error["@attributes"]['Message'];
         $out['err']['code'] = $code;
         $out['err']['msg'] = $msg;
         $out['refrence_id'] = '';
     }
     //        } else {
     //            foreach ((array) $xml->Errors as $index => $node) {
     //                foreach ($node as $key => $n) {
     //                    $code = (string) $n->attributes()->Code . '<br/>';
     //                    $msg = (string) $n->attributes()->Message;
     //                    $out['err']['code'] = $code;
     //                    $out['err']['msg'] = $msg;
     //                }
     //            }
     //            $out['refrence_id'] = '';
     //        }
     //        $client = new nusoap_client($conf->wurl."server.php?wsdl", true);
     //        $arguments = array(
     //            "user" => $conf->wuser,
     //            "pass" => $conf->wpass,
     //            "refrence_id" => $refID,
     //            "jpassengers" => json_encode($passengers),
     //            "mobile" => $mobile,
     //            "email" => $email,
     //            "address" => $address,
     //            "description" => $description
     //        );
     //        $result = $client->call("reserve_passengers2", $arguments);
     //        if ($client->fault) {
     //            $out['err']['code'] = 8;
     //            $out['err']['msg'] = $client->fault;
     //        } else {
     //            $error = $client->getError();
     //            if ($error) {
     //                $out['err']['code'] = 8;
     //                $out['err']['msg'] = $error;
     //                echo '<hr/>';
     //                echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
     //                echo '<hr/>';
     //                echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
     //                echo '<hr/>';
     //                echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
     //            } else {
     //                $out = json_decode($result, TRUE);
     //            }
     //        }
     return $out;
 }
예제 #6
0
    //var_dump($date_ta);
    $ta_next = date_format($date_ta->modify('+1 day'), 'Y-m-d');
    $ta_pre = date_format($date_ta->modify('-2 day'), 'Y-m-d');
    $arr_fa_ta = explode('-', $ta_pre);
    $ta_fa_pre = jgregorian_to_jalali($arr_fa_ta[0], $arr_fa_ta[1], $arr_fa_ta[2], '/');
    $arr_fa_next = explode('-', $ta_next);
    $ta_fa_next = jgregorian_to_jalali($arr_fa_next[0], $arr_fa_next[1], $arr_fa_next[2], '/');
} else {
    $date_ta2 = '';
    $ta_fa_next = '';
    $ta_fa_pre = '';
}
if ($_SESSION['aztarikh']) {
    $arr_az = explode('/', $_SESSION['aztarikh']);
    $date_az = date_create(jalali_to_jgregorian($arr_az[0], $arr_az[1], $arr_az[2], '-'));
    $date_az2 = date_create(jalali_to_jgregorian($arr_az[0], $arr_az[1], $arr_az[2], '-'));
    //var_dump($date_az);
    $az_next = date_format($date_az->modify('+1 day'), 'Y-m-d');
    $az_pre = date_format($date_az->modify('-2 day'), 'Y-m-d');
    $arr_fa_pre = explode('-', $az_pre);
    $az_fa_pre = jgregorian_to_jalali($arr_fa_pre[0], $arr_fa_pre[1], $arr_fa_pre[2], '/');
    $arr_fa_next = explode('-', $az_next);
    $az_fa_next = jgregorian_to_jalali($arr_fa_next[0], $arr_fa_next[1], $arr_fa_next[2], '/');
} else {
    $az_fa_next = '';
    $az_fa_pre = '';
}
$tmpp = '';
if (isset($_REQUEST['adult'])) {
    $res = new reserve_class();
    $adl = (int) $_REQUEST['adult'];
예제 #7
0
$current_en_az_currentdate_str = $current_az_date->format('Y-m-d');
$arr_currentday = explode('-', $current_en_az_currentdate_str);
$current_fa_az_str = jgregorian_to_jalali($arr_currentday[0], $arr_currentday[1], $arr_currentday[2], '/');
$current_az_date->add(new DateInterval('P1D'));
$next_en_az_str = $current_az_date->format('Y-m-d');
$arr_nextday = explode('-', $next_en_az_str);
$next_fa_az_str = jgregorian_to_jalali($arr_nextday[0], $arr_nextday[1], $arr_nextday[2], '/');
$current_az_date->sub(new DateInterval('P2D'));
$pre_en_az_str = $current_az_date->format('Y-m-d');
$arr_preday = explode('-', $pre_en_az_str);
$pre_fa_az_str = jgregorian_to_jalali($arr_preday[0], $arr_preday[1], $arr_preday[2], '/');
//var_dump($_GET);exit;
if (isset($_GET['tatarikh']) && $_GET['tatarikh']) {
    $ta_fa_next = '';
    $dtmp = explode('/', $_REQUEST['tatarikh']);
    $mtmp = jalali_to_jgregorian($dtmp[0], $dtmp[1], $dtmp[2], '-');
    $current_ta_date = new DateTime($mtmp);
    $current_en_ta_currentdate_str = $current_ta_date->format('Y-m-d');
    $arr_currentday = explode('-', $current_en_ta_currentdate_str);
    $current_fa_ta_str = jgregorian_to_jalali($arr_currentday[0], $arr_currentday[1], $arr_currentday[2], '/');
    $current_ta_date->add(new DateInterval('P1D'));
    $next_en_ta_str = $current_ta_date->format('Y-m-d');
    $arr_nextday = explode('-', $next_en_ta_str);
    $next_fa_ta_str = jgregorian_to_jalali($arr_nextday[0], $arr_nextday[1], $arr_nextday[2], '/');
    $current_ta_date->sub(new DateInterval('P2D'));
    $pre_en_ta_str = $current_ta_date->format('Y-m-d');
    $arr_preday = explode('-', $pre_en_ta_str);
    $pre_fa_ta_str = jgregorian_to_jalali($arr_preday[0], $arr_preday[1], $arr_preday[2], '/');
} else {
    $pre_fa_ta_str = '';
    $next_fa_ta_str = '';
예제 #8
0
function reserve_passengers2($user, $pass, $refrence_id, $jpassengers, $mobile, $email, $address, $description)
{
    $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['refrence_id'] = $refrence_id;
    $out['err']['code'] = 5;
    $out['err']['msg'] = 'DB ERROR';
    $conf = new conf();
    $my = new mysqli($conf->local_host, $conf->local_user, $conf->local_pass, $conf->local_db);
    if ($my->connect_errno !== FALSE) {
        $my->set_charset("utf8");
        $res = $my->query("select * from reserve_tmp where refrence_id = {$refrence_id} and state = 1");
        //if ($r = $res->fetch_assoc()) {
        $source_ids = array();
        $gress = array();
        $res_ids = array();
        while ($r = $res->fetch_assoc()) {
            $source_ids[] = (int) $r['source_id'];
            $gress[] = trim($r['first_out']) != '' ? json_decode(trim($r['first_out'])) : NULL;
            $resids[] = (int) $r['id'];
            $ok = TRUE;
        }
        if ($ok) {
            $apassengers = json_decode($jpassengers, TRUE);
            $out['p'] = $apassengers;
            $my->query("delete from ticket where refrence_id = {$refrence_id}");
            $query = array();
            foreach ($apassengers as $passenger) {
                $brth = explode("-", $passenger['birthday']);
                $birthday_a = jalali_to_jgregorian($brth[0], $brth[1], $brth[2]);
                $birthday = $birthday_a[0] . '-' . $birthday_a[1] . '-' . $birthday_a[2];
                $shomare_melli = trim($passenger['passport_engheza']) == '' ? $passenger['shomare_melli'] : '';
                $shomare_passport = trim($passenger['passport_engheza']) != '' ? $passenger['shomare_melli'] : '';
                $age = 'adl';
                switch (strtolower($age)) {
                    case 'child':
                        $age = 'chd';
                        break;
                    case 'infant':
                        $age = 'inf';
                        break;
                }
                $query[] = "({$refrence_id},'" . $passenger['fname'] . "','" . $passenger['lname'] . "','" . $passenger['fname_en'] . "','" . $passenger['lname_en'] . "','{$age}','{$birthday}'," . $passenger['gender'] . ",'{$shomare_melli}','{$shomare_passport}','" . $passenger['passport_engheza'] . "')";
            }
            if (count($query) > 0) {
                $qq = 'insert into ticket (`refrence_id`, `fname`, `lname`, `fname_en`, `lname_en`, `age`, `birthday`, `gender`, `shomare_melli`, `shomare_passport`, `passport_engheza`) values ';
                $qq .= implode(',', $query);
                $my->query($qq);
            }
            for ($ii = 0; $ii < count($source_ids); $ii++) {
                //                $source_id = (int) $r['source_id'];
                //                $gres = (trim($r['first_out']) != '') ? json_decode(trim($r['first_out'])) : NULL;
                //                $out['err']['code'] = 3;
                //                $out['err']['msg'] = 'SOURCE UNDFINED';
                $source_id = $source_ids[$ii];
                $gres = $gress[$ii];
                if ($source_id == 1) {
                    if ($gres != NULL && $gres->status == 1) {
                        $passengers = array();
                        foreach ($apassengers as $passenger) {
                            $tmp_passenger = array("gender" => $passenger['gender'], "en_name" => $passenger['fname_en'], "en_family" => $passenger['lname_en'], "name" => $passenger['fname'], "family" => $passenger['lname'], "age" => $passenger['age'], "birthday" => $passenger['birthday'], "code_melli_pass" => $passenger['shomare_melli'], "pass_expire" => $passenger['passport_engheza']);
                            $passengers[] = $tmp_passenger;
                        }
                        $out['pp'] = $passengers;
                        $voucher_id = $gres->voucher_id;
                        $params = array('voucher_id' => $voucher_id, 'mobile' => $mobile, 'email' => $email, 'address' => $address, "description" => $description, 'passengers' => $passengers);
                        $client = new nusoap_client('http://164.138.22.33/AAA/server.php?wsdl', true);
                        $err = $client->getError();
                        if ($err) {
                            $out['err']['code'] = 4;
                            $out['err']['msg'] = 'GOHAR CONNECTION ERROR';
                            return json_encode($out);
                        }
                        $result = $client->call('Passenger', array('param' => json_encode($params)));
                        if ($client->fault) {
                            $out['err']['code'] = 4;
                            $out['err']['msg'] = 'GOHAR CONNECTION ERROR';
                            return json_encode($out);
                        } else {
                            $err = $client->getError();
                            if ($err) {
                                $out['err']['code'] = 4;
                                $out['err']['msg'] = 'GOHAR CONNECTION ERROR';
                                return json_encode($out);
                            } else {
                                if ($out['err']['code'] != 0) {
                                    $out['err']['code'] = 0;
                                    $out['err']['msg'] = '';
                                }
                                $gres = json_decode($result);
                                if ($gres->error->error_code == 899) {
                                    $out['err']['code'] = $gres->error->error_code;
                                    $out['err']['msg'] = $gres->error->error_msg;
                                } else {
                                    $my->query("update reserve_tmp set state = 2 , second_out = '{$result}',second_time='" . date("Y-m-d H:i:s") . "' where id = " . $resids[$ii]);
                                    if ($gres->error->error_code == 0) {
                                        $out['voucher_id'][] = $gres->voucher_id;
                                    } else {
                                        $out['err']['code'] = $gres->error->error_code;
                                        $out['err']['msg'] = $gres->error->error_msg;
                                    }
                                }
                            }
                        }
                    } else {
                        $out['err']['code'] = 7;
                        $out['err']['msg'] = 'RESERVE NOT REGISTERED';
                    }
                }
            }
        } else {
            $out['err']['code'] = 6;
            $out['err']['msg'] = 'REFRENCE ERROR';
        }
    }
    return json_encode($out);
}