%PDF- %PDF-
Direktori : /proc/self/root/var/www/html/buggydubrovnik.com/buggy-booking/ |
Current File : //proc/self/root/var/www/html/buggydubrovnik.com/buggy-booking/preview.php |
<?php include($_SERVER["DOCUMENT_ROOT"]."/buggy-booking/checkPromo.php"); define('DEBUG', $_SERVER["REMOTE_ADDR"]=="78.134.247.156"); function formatMoney($number, $cents = 1) { // cents: 0=never, 1=if needed, 2=always if (is_numeric($number)) { // a number if (!$number) { // zero $money = ($cents == 2 ? '0.00' : '0'); // output zero } else { // value if (floor($number) == $number) { // whole number $money = number_format($number, ($cents == 2 ? 2 : 0)); // format } else { // cents $money = number_format(round($number, 2), ($cents == 0 ? 0 : 2)); // format } // integer or decimal } // value $money = str_replace(",","[]", $money); $money = str_replace(".",",", $money); $money = str_replace("[]",".", $money); return $money; } // numeric } // formatMoney if(!(isset($_POST["CustomerEmail"]))) {exit;} $servername = "localhost"; $username="buggydubrovnik_app_production"; $password="appr-17"; $db="buggydubrovnik_app_production"; //$username="root"; //$password=""; // Create connection $conn = mysqli_connect($servername, $username, $password, $db); mysqli_query($conn,"set names 'utf8'"); $title = mysqli_real_escape_string($conn, $_POST["title"]); $CustomerFirstname =mysqli_real_escape_string($conn, $_POST["CustomerFirstname"]); $CustomerSurname =mysqli_real_escape_string($conn, $_POST["CustomerSurname"]); $CustomerAddress =mysqli_real_escape_string($conn, $_POST["CustomerAddress"]); $CustomerCity =mysqli_real_escape_string($conn, $_POST["CustomerCity"]); $CustomerZIP = mysqli_real_escape_string($conn, $_POST["CustomerZIP"]); $CustomerCountry =mysqli_real_escape_string($conn, $_POST["CustomerCountry"]); $CustomerPhone =mysqli_real_escape_string($conn, "+".$_POST["CustomerCode"]."-".$_POST["CustomerPhone"]); $CustomerEmail =mysqli_real_escape_string($conn, $_POST["CustomerEmail"]); $termin=$conn->real_escape_string($_POST["date"]." ".$conn->real_escape_string($_POST["vrijeme"]).":00"); $start=$termin; $end=date("Y-m-d H:i:s", strtotime("+3 hour", strtotime($start))); $sql="SELECT SUM(r.resurs) FROM rezervacija r JOIN izlet_termin t ON t.id_izlet_termin=r.id_izlet_termin WHERE r.aktivan=1 AND r.id_vozilo_tip=4 AND t.aktivan=1 AND t.termin < STR_TO_DATE('$end', '%Y-%m-%d %H:%i:%s') AND r.datum_kupnja > STR_TO_DATE('$start', '%Y-%m-%d %H:%i:%s')"; //echo $sql; $seats=$conn->query($sql); if(DEBUG) echo $sql."<br/>"; $seats=$seats->fetch_row(); $sql="SELECT (SUM(r.odrasli)+SUM(r.djeca)) FROM rezervacija r JOIN izlet_termin t ON t.id_izlet_termin=r.id_izlet_termin WHERE r.aktivan=1 AND t.aktivan=1 AND r.id_izlet_tip=2 and r.id_vozilo_tip=4 AND t.termin < STR_TO_DATE('$end', '%Y-%m-%d %H:%i:%s') AND r.datum_kupnja > STR_TO_DATE('$start', '%Y-%m-%d %H:%i:%s')"; $seats2=$conn->query($sql); if(DEBUG) { echo $sql; die(); } $seats2=$seats2->fetch_row(); $seatsRest=$seats2[0]%3!=0?3-($seats2[0]%3):0; $seats2=ceil($seats2[0]/3); $seats[0]=$seats[0]+$seats2; //DRZAVA JE ID!! $drzavaID=$CustomerCountry; $drzava=$conn->query("SELECT * FROM drzava WHERE id_drzava=".$drzavaID)->fetch_assoc(); $CustomerCountry=$drzava["naziv"]; $seatsFactor=isset($_POST["separate"])?1:3; if ($djeca == '') $djeca = 0; $promo =mysqli_real_escape_string($conn, $_POST["promo"]); $promo_id =0; $odrasli =mysqli_real_escape_string($conn, $_POST["odrasli"]); $djeca =mysqli_real_escape_string($conn, $_POST["djeca"]); //$seatsOK=(((5-$seats[0])*$seatsFactor)+$seatsRest)>=(intval($odrasli)+intval($djeca)); $seatsOK=true; if($seatsFactor==3) { $sumaLjudi = $_POST["odrasli"] + $_POST["djeca"]; if ($sumaLjudi % 3 != 0) $sumaLjudi++; $djeca0 = $sumaLjudi / 3; } else $djeca0=intval($djeca)+intval($odrasli); $komentar =mysqli_real_escape_string($conn, $_POST["komentar"]); $picktime =mysqli_real_escape_string($conn, $_POST["picktime"]); $mjeseci =mysqli_real_escape_string($conn, $_POST["mjeseci"]); $dani =mysqli_real_escape_string($conn, $_POST["dani"]); $TotalAmount=0.0; $djecau=intval($djeca)+intval($djeca0); $today = date("Y-m-d H:i:s"); $ShopId=10001428; $SecretKey="xIj78UUpQ0J78+eTHR]m|p6?p"; $price=$seatsFactor==2?550.00:550.00; $discount=0; $promoCheck=checkPromo($promo); if($promoCheck) { $discount=$promoCheck["iznos"]; $promo_id=$promoCheck["id_promo_kod"]; } $timestamp=strtotime($termin); $endOfSeason=date("Y", $timestamp)==2019; if($endOfSeason){ $discount=10; $promo_id=10; } $priceWithoutDiscount=0.00; $cijenaOdrasli=intval($odrasli)*$price; $priceWithoutDiscount+=$cijenaOdrasli; $cijenaOdrasli=$cijenaOdrasli-($cijenaOdrasli*$discount/100); $cijenaDjeca=intval($djeca)*($price); $priceWithoutDiscount+=$cijenaDjeca; $cijenaDjeca=$cijenaDjeca-($cijenaDjeca*$discount/100); $TotalAmount= $cijenaOdrasli+$cijenaDjeca; $gateWay="https://pgw.ht.hr/services/payment/api/authorize-form"; //var_dump($TotalAmount); //ovo dolje nisam dirao // forma treba bacati na testni sustav : https://pgwtest.ht.hr/services/payment/api/authorize-form // uvijek mozes poci na https://pgwtest.ht.hr i logirati se preko user: buggy777 password: Buggy-412 //na index stranici omoguciti da vremena pocetka budu do: /*3.4. - do 17 h 6.,7.,8. - do 19 h 5.,9. - do 18h 10. - do 17 h*/ //terms and conditions na index stranici cu ja napisati //promo kodovi su: /* Direct Booker - BUdb2 In Your Pocket - BUiP3*/ //za voucher Petar ima html kod // $naziv="Buggy Group Tour"; $TotalAmountV2=($TotalAmount)*100; //-$TotalAmount*0.2 $sql="INSERT INTO rezervacija_temp VALUES (NULL, 0, '$naziv', '$termin', '$promo', '$promo_id', $odrasli, $djeca, $djeca0, $cijenaOdrasli, $cijenaDjeca, NULL, '$title', '$CustomerFirstname', '$CustomerSurname', '$CustomerAddress', '$CustomerZIP', '$CustomerCity', $drzavaID, '$CustomerPhone', '$CustomerEmail', '$today', '$komentar', 0, '', 0, 1)"; $conn->query($sql); $idtemprezervacija=$conn->insert_id; $conn->query("UPDATE rezervacija_temp SET broj_voucher=".$idtemprezervacija." WHERE id_rezervacija_temp=".$idtemprezervacija); $ShoppingCartId=$idtemprezervacija; $Signature=""; $failURL="http://www.buggydubrovnik.com"; $successURL="http://www.buggydubrovnik.com/thank-you/"; //$Signature=openssl_digest("authorize-form".$SecretKey.$ShopId.$SecretKey.$ShoppingCartId.$SecretKey.$TotalAmountV2.$SecretKey."1".$SecretKey."en".$SecretKey."GET".$SecretKey."http://www.adriatic-explore.com/booking/thankyouv3.php?idtemprezervacija=".$idtemprezervacija.$SecretKey."http://www.adriatic-explore.com".$SecretKey,"SHA512"); //$Signature = openssl_digest("authorize-form".$SecretKey.$ShopId.$SecretKey.$ShoppingCartId.$SecretKey.$TotalAmountV2.$SecretKey."1".$SecretKey."en".$SecretKey."GET".$SecretKey.$successURL.$SecretKey.$failURL.$SecretKey.$CustomerFirstname.$SecretKey.$CustomerSurname.$SecretKey.$CustomerAddress.$SecretKey.$CustomerCity.$SecretKey.$CustomerZIP.$SecretKey.$CustomerCountry.$SecretKey.$CustomerPhone.$SecretKey.$CustomerEmail.$SecretKey."1".$SecretKey, "SHA512"); $Signature = openssl_digest("authorize-form".$SecretKey.$ShopId.$SecretKey.$ShoppingCartId.$SecretKey.$TotalAmountV2.$SecretKey."1".$SecretKey."en".$SecretKey."GET".$SecretKey.$successURL.$SecretKey.$failURL.$SecretKey.$CustomerFirstname.$SecretKey.$CustomerSurname.$SecretKey.$CustomerAddress.$SecretKey.$CustomerCity.$SecretKey.$CustomerZIP.$SecretKey.$CustomerCountry.$SecretKey.$CustomerPhone.$SecretKey.$CustomerEmail.$SecretKey."1".$SecretKey, "SHA512"); //.$naziv." (".$odrasli." + ".$djecau." people)".$SecretKey. $datParts=explode(" ", $termin); $termin=date("d.M.Y H:i", strtotime($termin)); if($seatsOK) { ?> <style> #datum { max-width: 250px; } .drzave{width: 400px;} iframe{border: 1px solid #d2d2d2;width:100%; height:200px; overflow:scroll;} .section.group { width: 90%; margin: 0 auto; max-width: 500px; } .section.group input { max-width: 400px; } textarea { width: 400px; height: 150px; } input, select, option, textarea { color:#747474; padding: 0.2em; } @media only screen and (max-width: 800px){ iframe{-webkit-overflow-scrolling:touch} .section.group {width: 100%} textarea {width: 100%;} .drzave{width: 100%;} } h2 { color: #f58220!important; font-size: 1.7em!important; } </style> <div id="wrapper"> <div id="maincontentcontainer"> <div id="maincontent"> <div class="section group"> <div id="naslov1"> <h1 style="margin-bottom:25px; text-transform:uppercase">You're just a click away from your adventure!</h1> <?php if($promoCheck) { ?> <h2>Congratulations, you just saved <?=$promoCheck["iznos"]?>% total by using a promo code!</h2> <?php } if($endOfSeason) { ?> <h2>Congratulations, you just saved 10% due to the end of season</h2> <?php } ?> </div> </div> <div class="section group" style="margin-bottom:25px; margin-top:5px; background-color:#003; height:2px;"></div> <div class="section group" style="margin-bottom:25px;"> <b>PLEASE CHECK SUBMITTED DATA ONE MORE TIME:</b></div> <form name="f1" id="forma" style="font-weight:normal; text-align:left" action="<?=$gateWay?>" method=POST> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4">Excursion: </div><div class="col span_3_of_4"><input readonly class="inputtekst" name="nazivizlet" type="text" value="<?php echo $naziv; ?>" /></div></div> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4">Price per person:</div><div class="col span_3_of_4"><b><?php echo formatMoney($price); ?></b> HRK <!-- -$price*0.2,2--> <?php if($seatsFactor==1) echo "<p>(separate vehicles included)</p>" ?> </div> </div> <div class="section group" style="margin-bottom:5px; margin-top:15px; background-color:#003; height:2px;"></div> <div class="section group" style="margin-bottom:5px;"><strong> PERSONAL DATA</strong> </div> <div class="section group" style="margin-bottom:15px; margin-top:5px; background-color:#003; height:2px;"></div> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4">Title: </div><div class="col span_3_of_4"> <input class="inputtekst" name="title" type="text" readonly style="width:75px;" value="<?php echo $title; ?>"/> </div></div> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4">First name : </div><div class="col span_3_of_4"><input class="inputtekst" name="pgw_first_name" type="text" readonly value="<?php echo $CustomerFirstname; ?>" /></div></div> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4">Last name : </div><div class="col span_3_of_4"><input class="inputtekst" name="pgw_last_name" type="text" readonly value="<?php echo $CustomerSurname ; ?>" /></div></div> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4">Address :</div><div class="col span_3_of_4"><input class="inputtekst" name="pgw_street" type="text" readonly value="<?php echo $CustomerAddress; ?>" /></div></div> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4">City :</div><div class="col span_3_of_4"><input class="inputtekst" name="pgw_city" type="text" readonly value="<?php echo $CustomerCity; ?>" /></div></div> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4">ZIP Code :</div><div class="col span_3_of_4"><input class="inputtekst" name="pgw_post_code" type="text" readonly value="<?php echo $CustomerZIP; ?>" /></div></div> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4">Country :</div><div class="col span_3_of_4"><input class="inputtekst drzave" name="pgw_country" type="text" readonly value="<?php echo $CustomerCountry; ?>" /></div></div> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4"> Telephone : </div><div class="col span_3_of_4"><input class="inputtekst" name="pgw_telephone" type="text" readonly value="<?php echo $CustomerPhone; ?>" /></div></div> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4"> E-mail : </div><div class="col span_3_of_4"><input class="inputtekst" name="pgw_email" type="text" readonly value="<?php echo $CustomerEmail; ?>" /></div></div> <input type="hidden" name="pgw_failure_url" value="<?=$failURL?>"> <input type="hidden" name="pgw_success_url" value="<?=$successURL?>"> <input type="hidden" name="pgw_shop_id" value="<?=$ShopId?>"> <input type="hidden" name="pgw_order_id" value="<?=$ShoppingCartId ?>"> <input type="hidden" name="pgw_amount" value="<?php echo $TotalAmountV2 ?>"> <input type="hidden" name="pgw_authorization_type" value="1"> <input type="hidden" name="pgw_language" value="en"> <input type="hidden" name="pgw_return_method" value="GET"> <input type="hidden" name="pgw_signature" value="<?php echo $Signature ?>"> <input type="hidden" name="pgw_disable_installments" value="1"> <input type="hidden" name="DebugMode" value="on"> <!-- <input type="hidden" name="pgw_order_info" value="<?php echo $naziv.' ('.$odrasli.' + '.$djecau.' people)'; ?>"> --> <div class="section group" style="margin-bottom:5px; margin-top:15px; background-color:#003; height:2px;"></div> <div class="section group" style="margin-bottom:5px;"><strong> Excursion data</strong> </div> <div class="section group" style="margin-bottom:15px; margin-top:5px; background-color:#003; height:2px;"></div> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4"> Date & Time :</div> <div class="col span_3_of_4"> <input class="inputtekst" name="odkad" type="text" readonly value="<?=$termin?>"/> </div></div> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4"> Adults: </div><div class="col span_3_of_4"> <input class="inputtekst" name="odrasli" type="text" readonly value="<?php echo $odrasli; ?>" /> </div></div> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4"> Children 6-12:</div><div class="col span_3_of_4"> <input class="inputtekst" name="djeca" type="text" readonly value="<?php echo $djeca; ?>" /> </div></div> <div class="section group" style="display:none; margin-bottom:5px;"> <div class="col span_1_of_4"> Children 0-6:</div><div class="col span_3_of_4"> <input class="inputtekst" name="djeca0" type="text" readonly value="<?php echo $djeca0; ?>" /> </div></div> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4"> Comment:</div><div class="col span_3_of_4"> <textarea class="inputtekst" style="width:100%; font-family:Arial, Helvetica, sans-serif; min-height:100px; text-align:left;" name="komentar" readonly><?php echo $komentar; ?></textarea> </div></div> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4"> <b>TOTAL AMOUNT <?=$promoCheck||$endOfSeason?"WITHOUT DISCOUNT":""?></b></div><div class="col span_3_of_4"> <input class="inputtekst" type="text" readonly style=" text-align:left; font-weight:bold;" name="iznostotal" value="<?php echo formatMoney($priceWithoutDiscount); ?> HRK" /> <!---$priceWithoutDiscount*0.2,2 --> </div></div> <?php if($promoCheck||$endOfSeason){ ?> <div class="section group" style="margin-bottom:5px;"> <div class="col span_1_of_4"> <b>TOTAL AMOUNT WITH DISCOUNT</b></div><div class="col span_3_of_4"> <input class="inputtekst" type="text" readonly style=" text-align:left; color:#F72A5D; font-weight:bold;" name="iznostotal" value="<?php echo formatMoney($TotalAmount); ?> HRK" /> <!-- -$TotalAmount*0.2,2--> </div></div> <?php } ?> <div class="section group" style="margin-bottom:5px;"> <br /> <img src="http://www.buggydubrovnik.com/wp-content/uploads/2017/03/backicon.png" style="border:none; cursor:pointer;vertical-align:middle " onclick="history.go(-1)" /> <a style="vertical-align: middle;margin-left: 0.5em;color:black; font-size:1.2em;" >GO BACK AND CHANGE DETAILS</a><br /><br /></div> <div class="section group" style="margin-bottom:5px;"><b>NOTE</b>:<br /> We recommend booking and paying online - Your place is then guaranteed!<br /> Due to restricted number of people on each tour/excursion it's best to reserve Your place as soon as possible.</div> <div class="section group" style="margin-bottom:5px; margin-top:15px; "> <input class="fusion-button button-3d button-round button-xlarge button-orange button-1" type="submit" value="CONTINUE TO SECURE PAY ONLINE" onclick="return true;" style="font-size:0.9em; cursor:pointer; padding-top:10px; padding-bottom:10px; height:50px;" /> </div> <div class="section group" style="margin-bottom:5px; text-align:center; margin-top:5px;"><br /><img src="http://www.buggydubrovnik.com/wp-content/uploads/2017/03/trust.png" /> <img src="http://www.buggydubrovnik.com/wp-content/uploads/2017/03/karticebig.png" /> <img src="http://www.buggydubrovnik.com/wp-content/uploads/2017/03/trcom.png" /></div> </form> </div> </div> </div> <?php } else { ?> <div> <h1>There are not enough free seats for this tour. Please try another date or time.</h1> <div class="section group" style="margin-bottom:5px;"> <br /> <img src="http://www.buggydubrovnik.com/wp-content/uploads/2017/03/backicon.png" style="border:none; cursor:pointer;vertical-align:middle " onclick="history.go(-1)" /> <a style="vertical-align: middle;margin-left: 0.5em;color:black; font-size:1.2em;" >GO BACK AND CHANGE DETAILS</a><br /><br /></div> </div> <?php }