Skip to content

Commit

Permalink
Merge pull request #53 from secourse2016/dev
Browse files Browse the repository at this point in the history
Merging to master
  • Loading branch information
YoussufRadi committed Apr 19, 2016
2 parents 1d6b45e + 08ee681 commit 072c156
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 151 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
JWTSECRET = "CSEN603ROCKSi<8SE!"
PORT=80
PORT=8080
50 changes: 4 additions & 46 deletions config/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ exports.seedDB = function(cb) {
mongo.clearDB(function(err) {
assert.equal(null, err);
mongo.seed('flights', flights, function() {
mongo.seed('bookings', bookings, function() {
// mongo.seed('bookings', bookings, function() {
mongo.seed('airports', airports, function() {
mongo.close();
});
});
// });
});
});

Expand Down Expand Up @@ -66,7 +66,7 @@ exports.searchFlights = function(origin, destination, departingDate, cabin, cb)
'$regex': departingDate
}
}).toArray(function(err, flights) {
if (flights[0] == undefined) {
if (flights.length === 0) {
cb(err, []);
} else {
if (economyOrBusiness == "economy")
Expand Down Expand Up @@ -101,25 +101,9 @@ exports.searchFlights = function(origin, destination, departingDate, cabin, cb)

exports.submitPay = function(firstName, lastName, passport, passportNumber, issueDate, expiryDate, email, phoneNumber, bookingRefNumber, flightNumber, businessOrEconomic, cb) {
var selectedSeat = 0;

// console.log(businessOrEconomic);



// console.log('i`m in api');
mongo.connect(function(err, db) {

// db.collection("flights").drop();
// db.collection("flights").remove({"flightNumber": "MYNKSH3"});

// var cursor =db.collection('flights').find( );
// cursor.each(function(err, doc) {
// if (doc != null) {
// console.dir(doc);
// }
// });
// update after find free seat

var collection = db.collection('flights');
collection.find({
"flightNumber": flightNumber
Expand All @@ -129,15 +113,8 @@ exports.submitPay = function(firstName, lastName, passport, passportNumber, issu
mongo.close();
return;
}

//flights[0].seat[flights[0].nextvf,m]
// console.log(flights[0]);

// console.log(flights[0].SeatMap[0]);
// flights[0].SeatMap[0]

// remove then insert
if (bookingRefNumber === "true") { // economy
if (businessOrEconomic === "true") { // economy
//check on availableESeats of economy
if (!(flights[0].availableESeats === 0)) {
selectedSeat = flights[0].nextEcoSeat;
Expand All @@ -155,18 +132,14 @@ exports.submitPay = function(firstName, lastName, passport, passportNumber, issu

}
// if avaliable dec availableBSeats and inc next Bseat


}

//
// console.log("selectedSeat :"+selectedSeat);
flights[0].SeatMap[selectedSeat].bookingRefNumber = bookingRefNumber;

db.collection("flights").remove({
"flightNumber": flightNumber
}, function(err, records) {

//
var collection = db.collection('flights');
var document = {
Expand Down Expand Up @@ -214,23 +187,8 @@ exports.submitPay = function(firstName, lastName, passport, passportNumber, issu
cb(err, true);
});
});


//


});



});







});
}

Expand Down
2 changes: 2 additions & 0 deletions public/controllers/congratsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ App.controller('congratsCtrl', function($scope, $location,paymentSrv) {
// $location.url('/congrats');
// };



}
8 changes: 4 additions & 4 deletions public/controllers/flightsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ App.controller('flightsCtrl', function($scope, FlightsSrv, OutReturnSrv, $locati
$scope.returnFlightFound = true;
$scope.outgoingInfo = [];
$scope.returnInfo = [];

if (FlightsSrv.getPinging().toString() === 'true')
if ($scope.roundTrip === 'true')
pingAirlineR($scope.origin, $scope.dest, changeISOFormat($scope.oDate), changeISOFormat($scope.rDate));
Expand All @@ -36,9 +36,9 @@ App.controller('flightsCtrl', function($scope, FlightsSrv, OutReturnSrv, $locati
var outDate = moment(oDate).toDate().getTime();
var jwt = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNWU5LU0giLCJpYXQiOjE0NjA3NzIyOTQsImV4cCI6MTQ5MjMwODI5NSwiYXVkIjoid3d3LnNlY291cnNlLmNvbSIsInN1YiI6Ik1ZTktTSCBJYmVyaWEiLCJUZWFtIjoiTVlOS1NIIn0.hZxhv8XAcu1cARgcrtfb0l_crF1-Ic1tJt9eUhIL0qQ';
$http.get(c.ip + '/api/flights/search/' + origin + '/' + dest + '/' + departDate + '/' + outDate + '/' + tclass + '?wt=' + jwt).success(function(flight) {
if (flight.outgoingFlights[0] != 'undefined' && flight.outgoingFlights[0].length != 0)
if (flight != 'undefined' && flight.outgoingFlights[0] != 'undefined' && flight.outgoingFlights[0] != 'undefined' && flight.outgoingFlights[0].length != 0)
$scope.outgoingInfo.push(flight.outgoingFlights[0]);
if (flight.returnFlights[0] != 'undefined' && flight.returnFlights[0].length != 0)
if (flight != 'undefined' && flight.returnFlights[0] != 'undefined' && flight.returnFlights[0] != 'undefined' && flight.returnFlights[0].length != 0)
$scope.returnInfo.push(flight.returnFlights[0]);
// console.log(flight.outgoingFlights);
});
Expand All @@ -53,7 +53,7 @@ App.controller('flightsCtrl', function($scope, FlightsSrv, OutReturnSrv, $locati
var departDate = moment(oDate).toDate().getTime();
jwt = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNWU5LU0giLCJpYXQiOjE0NjA3NzIyOTQsImV4cCI6MTQ5MjMwODI5NSwiYXVkIjoid3d3LnNlY291cnNlLmNvbSIsInN1YiI6Ik1ZTktTSCBJYmVyaWEiLCJUZWFtIjoiTVlOS1NIIn0.hZxhv8XAcu1cARgcrtfb0l_crF1-Ic1tJt9eUhIL0qQ';
$http.get(c.ip + '/api/flights/search/' + origin + '/' + dest + '/' + departDate + '/' + tclass + '?wt=' + jwt).success(function(flight) {
if (flight.outgoingFlights[0] != 'undefined' && flight.outgoingFlights[0].length != 0)
if (flight != 'undefined' && flight.outgoingFlights[0] != 'undefined' && flight.outgoingFlights[0] != 'undefined' && flight.outgoingFlights[0].length != 0)
$scope.outgoingInfo.push(flight.outgoingFlights[0]);
// console.log(flight.outgoingFlights);
});
Expand Down
129 changes: 85 additions & 44 deletions public/controllers/paymentCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ App.controller('paymentCtrl', function($scope, FlightsSrv, ConfirmSrv, OutReturn
$scope.tab = "active in";
$scope.reservation = ConfirmSrv.getReservation();
$scope.totalPrice = OutReturnSrv.getSelectedPrice();
$scope.cabin=FlightsSrv.getSelectedCabin();
$scope.cabin = FlightsSrv.getSelectedCabin();
var roundTrip = FlightsSrv.getSelectedRoundTrip();
var outgoingFlight= OutReturnSrv.getSelectedOutFlight();
if(roundTrip == 'true')
var outgoingFlight = OutReturnSrv.getSelectedOutFlight();
if (roundTrip == 'true')
returnFlight = OutReturnSrv.getSelectedReturnFlight();
$scope.outCurrency = outgoingFlight.currency;



$scope.tab1 = function() {
$scope.tab = "active in";
$scope.tab2 = "";
Expand All @@ -32,10 +34,10 @@ App.controller('paymentCtrl', function($scope, FlightsSrv, ConfirmSrv, OutReturn
};

var postAPay = function() {
$scope.bookingRefNumber = $scope.getBookingRef() ;
paymentSrv.postPay($scope.reservation, $scope.bookingRefNumber, outgoingFlight , $scope.cabin);
if(roundTrip =='true')
paymentSrv.postPay($scope.reservation, $scope.bookingRefNumber, returnFlight , $scope.cabin);
$scope.bookingRefNumber = $scope.getBookingRef();
paymentSrv.postPay($scope.reservation, $scope.bookingRefNumber, outgoingFlight, $scope.cabin);
if (roundTrip == 'true')
paymentSrv.postPay($scope.reservation, $scope.bookingRefNumber, returnFlight, $scope.cabin);
};

var SetCardType = function(value) {
Expand Down Expand Up @@ -87,55 +89,94 @@ App.controller('paymentCtrl', function($scope, FlightsSrv, ConfirmSrv, OutReturn

//NARIHAN
$scope.getBookingRef = function() {
// var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
// var string_length = 8;
// var randomstring = '';
// for (var i=0; i<string_length; i++) {
// var rnum = Math.floor(Math.random() * chars.length);
// randomstring += chars.substring(rnum,rnum+1);
// }
// // document.randform.randomfield.value = randomstring;
//
//
// var str1=randomstring;

//encode and get the first part of the outgoing date
var card = $scope.selectedCardNumber;
// var outDate = FlightsSrv.getSelectedOutDate();
// var str4 = JSON.stringify(outDate);
// var arr = str4.split("T");
// var outDate = arr[0];
// var arr = outDate.split("-");
// var outDate = arr[1] + "/" + arr[2];

//encode and get the first part of the return date
// var returnDate=FlightsSrv.getSelectedReturnDate();
// var str5=JSON.stringify(returnDate);
// var arr2=str5.split("T");
// var returnDate=arr2[0];
// var arr2=returnDate.split("-");
// var returnDate=arr2[1]+"/"+arr2[2];
// var arr2=str4.split(/[ ,]+/);
// var str3=arr2[1]+"/"+arr2[2];
//
var outFlightNo = OutReturnSrv.getSelectedOutFlight().flightNumber;
// var returnFlightNo= OutReturnSrv.getSelectedReturnFlight().flightNumber;
var str = card + "," + outFlightNo;
// +","+outFlightNo+","+returnFlightNo;
// var str="hey how are you";
// var arr=str.split(/[ ,]+/);
// var str2=arr[1]+"/"+arr[2];
var str = card + "," + outFlightNo;
var enc = window.btoa(str);
var dec = window.atob(enc);

var res = "Booking Reference:(please copy it for further tracking): " + "<br>" + enc + "<br>" + "Decoded String: " + dec;
var res = enc;

// "<br>" + "Decoded String: " + dec;
document.getElementById("ptag").innerHTML = "Booking Reference:(please copy it for further tracking):" + "<br>";
document.getElementById("demo").innerHTML = res;

return enc;
var copyTextareaBtn = document.querySelector('.js-textareacopybtn');

copyTextareaBtn.addEventListener('click', function(event) {
var copyTextarea = document.querySelector('.js-copytextarea');
copyTextarea.select();

try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Copying text command was ' + msg);
} catch (err) {
console.log('Oops, unable to copy');
}
});



// document.getElementById("copyButton").addEventListener("click", function() {
// copyToClipboard(enc);
// });

// function copyToClipboard(elem) {
// // create hidden text element, if it doesn't already exist
// var targetId = "_hiddenCopyText_";
// var isInput = elem.tagName === "INPUT" || elem.tagName === "TEXTAREA";
// var origSelectionStart, origSelectionEnd;
// if (isInput) {
// // can just use the original source element for the selection and copy
// target = elem;
// origSelectionStart = elem.selectionStart;
// origSelectionEnd = elem.selectionEnd;
// } else {
// // must use a temporary form element for the selection and copy
// target = document.getElementById(targetId);
// if (!target) {
// var target = document.createElement("textarea");
// target.style.position = "absolute";
// target.style.left = "-9999px";
// target.style.top = "0";
// target.id = targetId;
// document.body.appendChild(target);
// }
// target.textContent = elem.textContent;
// }
// // select the content
// var currentFocus = document.activeElement;
// target.focus();
// target.setSelectionRange(0, target.value.length);

// // copy the selection
// var succeed;
// try {
// succeed = document.execCommand("copy");
// } catch(e) {
// succeed = false;
// }
// // restore original focus
// if (currentFocus && typeof currentFocus.focus === "function") {
// currentFocus.focus();
// }

// if (isInput) {
// // restore prior selection
// elem.setSelectionRange(origSelectionStart, origSelectionEnd);
// } else {
// // clear temporary content
// target.textContent = "";
// }
// return succeed;
// }

};

return enc;
};

//End of Narihan

Expand Down
8 changes: 5 additions & 3 deletions public/partials/bookingRef.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@

<link rel="stylesheet" href="css/style.css" />
<section id="section-download" class="download-wrap" style="background: rgba(255,255,255, .8)">
<div class="col-md-4 text-left">
<button type="button" href='http://www.mynksh.com' class="btn btn-primary btn-lg" style="position:right; background:rgba(178,34,34, 1);margin-top: 15px" >Back to Iberia</button>
</div>

<div class="container download center" style="border-radius: 25px;">
<div class="col-md-2 text-left">
<form action="http://mynksh.com">
<input type="submit" class="btn btn-primary btn-lg" style="position:left; background:rgba(178,34,34, 1);margin-top: -200px" value="Back to Iberia" ></form>
</div>
<div class="row">

<div class="col-md-8 col-md-offset-2">
Expand Down
4 changes: 3 additions & 1 deletion public/partials/landingPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ <h3>Flights</h3>
<font class="col-sm-2 col-xs-4 text-right" size="4" color="white"> Returning: </font>
<div class="col-md-8 col-sm-8 col-xs-4">
<p class="input-group">
<input type="text" class="form-control " min-date="$parent.dto" uib-datepicker-popup="{{format}}" ng-model="$parent.dtr" is-open="popup2.opened" close-text="Close" alt-input-formats="altInputFormats" />

<input type="text" class="form-control" min-date="$parent.dto" uib-datepicker-popup="{{format}}" ng-model="$parent.dtr" is-open="popup2.opened" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" />

<span class="input-group-btn">
<button type="button"
class="btn btn-default "
Expand Down
Loading

0 comments on commit 072c156

Please sign in to comment.