public function Safarcallback($PSTData, $GETData) { //parsian gateway if (isset($GETData['au'], $GETData['rs'])) { $t = new Transaction(); $trans = $t->get_by_au($GETData['au']); if ($trans && $GETData['rs'] == 0) { $totalamont = $trans['amount']; //var_dump($trans);exit; $u = new user(); $guest = $u->Get_Guest_ID(); //get invoice $invoice = new Invoice(); $invc_num = $invoice->get_by_transID($trans['id']); //var_dump($invc_num);exit; //check tranaction by PaymentEnquiry $gt = new ParsianGateway(Parsian_PIN); //confirm reservation $ctrl = new HotelController(); //if ($confirm) { if (true) { $confirm = array('voucher' => '101010', 'Reference' => '202020'); //var_dump($confirm);exit; //if ($gt->PaymentEnquiry($GETData['au'], $GETData['rs'])) { if (TRUE) { //add paydoc } else { require 'safarheader.php'; echo "<script>" . "jQuery(document).ready(function(\$) {" . "jQuery('.err-body').html('Reservation Final Error ');" . "jQuery('#error-modal').modal();" . "});" . "</script>"; require 'safarfooter.php'; return FALSE; } //chang inoice status $invoice->submit($invc_num, $confirm['voucher'], $confirm['Reference']); $pd = new Paydoc(); if (isset($_SESSION['user']['id'])) { $current_credit = $u->getcredit($_SESSION['user']['id'], 'IRR'); $remain = $current_credit - $totalamont; if ($pd->Save($_SESSION['user']['id'], -1, $totalamont, $invc_num, 'IRR')) { $u->change_credit($_SESSION['user']['id'], 'IRR', $remain); } } else { $pd->Save($guest, -1, $totalamont, $invc_num, 'IRR'); } $psgr = new passenger(); //var_dump($psgr);exit; $rmmm = new InvoiceDetail(); $inv = new Invoice(); $transfer_data = $inv->get_Tranfer_Data($invc_num); //print_r($transfer_data);exit; //$invc_num $variable = array(); $variable['voucher'] = $confirm['voucher']; $variable['invoce_data'] = $invoice->get_By_id($invc_num); $variable['passengers'] = $psgr->getByInvoice($invc_num); $variable['rooms'] = $rmmm->getByInvoice($invc_num); $variable['transfer'] = $transfer_data; if ($variable) { foreach ($variable as $k => $v) { ${$k} = $v; } } require 'safarheader.php'; require 'View/hotel/receipt.php'; require 'safarfooter.php'; } else { require 'safarheader.php'; echo "<script>" . "jQuery(document).ready(function(\$) {" . "jQuery('.err-body').html('متاسفانه در تکمیل خرید خطایی رخ داد ');" . "jQuery('#error-modal').modal();" . "});" . "</script>"; require 'safarfooter.php'; return FALSE; } //add paydoc } else { if ($GETData['rs'] == 1) { require 'safarheader.php'; echo "<script>" . "jQuery(document).ready(function(\$) {" . "jQuery('.err-body').html('تراکنش ناموفق ');" . "jQuery('#error-modal').modal();" . "});" . "</script>"; require 'safarfooter.php'; } else { require 'safarheader.php'; echo "<script>" . "jQuery(document).ready(function(\$) {" . "jQuery('.err-body').html('شماره تراکنش اشتباه است ');" . "jQuery('#error-modal').modal();" . "});" . "</script>"; require 'safarfooter.php'; } return FALSE; } } else { //err for now require 'safarheader.php'; echo "<script>" . "jQuery(document).ready(function(\$) {" . "jQuery('.err-body').html('شماره تراکنش اشتباه است ');" . "jQuery('#error-modal').modal();" . "});" . "</script>"; require 'safarfooter.php'; return FALSE; } }
$invoice->reference = $result; $invoice->date_in = $_SESSION['check-in']; $invoice->date_out = $_SESSION['check-out']; $invoice->hotel_id = $_SESSION['Reserve']['hotel_id']; $invoice->hotel_name = $_SESSION['Reserve']['hotel_name']; //$invoice->hotel_addr = $_SESSION['Reserve']['hotel_addr']; $invoice->hotel_addr = ''; $invoice->description = json_encode($_SESSION['transfer']); // echo '<pre>'; // print_r($passengers); // echo '</pre>'; $invoice->status = 0; $invc_num = $invoice->Save(); foreach ($passengers as $_rm => $_room) { foreach ($_room as $_psgr) { $ps = new passenger(); $ps->name = $_psgr['name']; $ps->en_name = $_psgr['en_name']; $ps->family = $_psgr['family']; $ps->sex = $_psgr['gender']; $ps->age = $_psgr['age']; $ps->birthdate = $_psgr['birthyear'] . '/' . $_psgr['birthmonth'] . $_psgr['birthday']; $ps->invoice = $invc_num; $ps->room = $_rm; $ps->nationalcode = $_psgr['code_melli_pass']; $ps->save(); } } if ($invc_num) { // add invoice detail // echo '<pre>';