Skip to content

Instantly share code, notes, and snippets.

@emiralp
Created September 10, 2014 14:52
Show Gist options
  • Save emiralp/15cda0b00e1f6ba886be to your computer and use it in GitHub Desktop.
Save emiralp/15cda0b00e1f6ba886be to your computer and use it in GitHub Desktop.
IDO - TICKET FORM
<div class="n-aside n-light" >
<div class="home-tabs-holder" ng-if="formtype == 'outer'">
<ul class="lists home-tabs">
<li ng-class="{'active':(timetableQueryForm == false)}"><a href="#" ng-click="ticketFormTabClick(true);"><i class="icon-ticket"></i> <span translate="BUY_TICKET">Bilet Al</span></a></li>
<li ng-class="{'active':(timetableQueryForm == true)}"><a href="#" ng-click="ticketFormTabClick(false);"><i class="icon-map"></i><span translate="TIMETABLES_H">Sefer Sorgulama</span></a> </li>
<li><a ng-href="{{'_SLUG_CARRENTAL'|translate}}"><i class="icon-transportation-car"></i><span translate="CARRENTAL">Araç Kiralama</span></a> </li>
</ul>
</div>
<div class="aside-inner">
<div class="form-container">
<div class="n-group">
<!--<ul ng-show="timetableQueryForm" class="lists pillr">
<li ng-click="queryIsDomestic = true" ng-class="{'active':(queryIsDomestic == true)}"><a href="#"><i class="icon-ionicons-7"></i> {{'F_DOMESTIC'|translate}}</a></li>
<li ng-click="queryIsDomestic = false" ng-class="{'active':(queryIsDomestic == false)}"><a href="#"><i class="icon-ionicons-8"></i> {{'F_INTER'|translate}}</a></li>
</ul>
-->
<div class="row nopad-row col-sm-smallizer-6">
<div class="col-sm-6 nopad">
<!-- port input -->
<div class="n-wrapper clearfix" >
<!--<div class="n-input-label"><span translate="F_DEPARTURE">Kalkış Terminali</span></div>-->
<select class="n-select select_dd n-select-block2" ng-change="formDetail = true;" ng-model="departurePort" id="dp_s" ng-click="closeTooltips()" placeholder="Seçiniz">
<option value="" translate="F_DEPARTURE">Kalkış</option>
<option ng-repeat="p in matrix_ports" ng-disabled="p.selectedPort" value="{{p.port}}">{{p.port.name}}</option>
</select>
</div>
<!-- /port_input -->
</div>
<div class="col-sm-6 nopad">
<!-- port input -->
<div class="n-wrapper clearfix">
<!--<div class="n-input-label"><span translate="F_ARRIVAL">Varış</span></div>-->
<select class="n-select select_dd n-select-block2" ng-change="formDetail = true;" ng-model="arrivalPort" id="ar_s" ng-click="closeTooltips()" placeholder="Seçiniz">
<option value="" translate="F_ARRIVAL" ng-disabled="departurePort">Varış</option>
<option ng-repeat="p in selected_matrix.arrival_ports" ng-disabled="p.selectedPort" value="{{p}}">{{p.name}}</option>
</select>
</div>
<!-- /port_input -->
</div>
<div ng-show="timetableQueryForm" class="n-wrapper topper">
<!-- gidis-donus -->
<div class="row">
<div class="col-sm-12 topper">
<!--Datepicker-->
<div class="n-block-col-single">
<div class="n-input-label"><span translate="F_DATE">TARİH</span></div>
<div class="n-date-value clearfix">
<div class="n-date-group pull-left">
<div class="n-date-day">{{parseDate('day',true)}}</div>
</div>
<div class="n-date-group pull-right">
<div class="n-date-month">{{parseDate('month',true)}}</div>
<div class="n-date-year">{{parseDate('year',true)}}</div>
</div>
</div>
<div class="date-input-wrapper">
<input autoclose='true' useNative='true' type="text" container='body' class="form-control date-picker" ng-model="inputDate.startDate" name="date" id="fcs1" style="opacity:0;position:absolute;z-index:10000;" data-min-date="today" bs-datepicker>
<a href="javascript:;" class="btn btn-date-picker btn-block" onclick="$('#fcs1').focus();"><i class="icon-calendar"></i> <span translate="F_CHANGE">DEĞİŞTİR</span></a>
</div>
</div>
<!--/Datepicker-->
</div>
</div>
<!-- /gidis-donus -->
</div>
</div>
<div ng-show="!timetableQueryForm">
<div class="n-group">
<ul class="lists pillr">
<li ng-click="setReturnTrip(true)" ng-class="{'active':(returnTrip == true)}"><a href="#"><i class="icon-ionicons-7"></i> <span translate="F_RETURNTRIP">Gidiş - Dönüş</span></a></li>
<li ng-click="setReturnTrip(false)" ng-class="{'active':(returnTrip == false)}"><a href="#"><i class="icon-ionicons-8"></i> <span translate="F_ONEWAY">Tek Yön</span></a></li>
</ul>
<div class="n-wrapper col-sm-smallizer-6">
<!-- gidis-donus -->
<div class="row">
<div class="col-sm-6">
<!--Datepicker-->
<div class="n-block-col-single">
<div class="n-input-label"><span translate="F_DEPARTURE_DATE">GİDİŞ</span></div>
<div class="n-date-value clearfix">
<div class="n-date-group pull-left">
<div class="n-date-day">{{parseDate('day',true)}}</div>
</div>
<div class="n-date-group pull-right">
<div class="n-date-month">{{parseDate('month',true)}}</div>
<div class="n-date-year">{{parseDate('year',true)}}</div>
</div>
</div>
<div class="date-input-wrapper">
<input autoclose='true' useNative='true' type="text" container='body' class="form-control date-picker" ng-model="inputDate.startDate" name="date" id="fcs1" style="opacity:0;position:absolute;z-index:10000;" data-min-date="today" bs-datepicker>
<a href="javascript:;" class="btn btn-date-picker btn-block" onclick="$('#fcs1').focus();"><i class="icon-calendar"></i> <span translate="F_CHANGE">DEĞİŞTİR</span></a>
</div>
</div>
<!--/Datepicker-->
</div>
<div class="col-sm-6">
<!--Datepicker-->
<div class="n-block-col-single" ng-class="{'passive':(returnTrip == false)}">
<div class="n-input-label"><span translate="F_RETURN_DATE">DÖNÜŞ</span></div>
<div class="n-date-value clearfix">
<div class="n-date-group pull-left">
<div class="n-date-day">{{parseDate('day',false)}}</div>
</div>
<div class="n-date-group pull-right">
<div class="n-date-month">{{parseDate('month',false)}}</div>
<div class="n-date-year">{{parseDate('year',false)}}</div>
</div>
</div>
<div class="date-input-wrapper">
<input autoclose='true' useNative='true' placement="left" type="text" container='body' class="form-control date-picker" ng-model="inputDate.endDate" name="date" id="fcs2" data-min-date="{{inputDate.startDate}}" style="opacity:0;position:absolute;z-index:10000;" bs-datepicker>
<a class="btn btn-date-picker btn-block" href="javascript:;" onclick="$('#fcs2').focus();"><i class="icon-calendar"></i> <span translate="F_CHANGE">DEĞİŞTİR</span></a>
</div>
</div>
<!--/Datepicker-->
</div>
</div>
<!-- /gidis-donus -->
</div>
</div>
<div class="n-group" id="pAlertArea">
<ul class="lists pillr mt-20">
<li ng-click="setWithVehicle(false)" ng-class="{'active':(withVehicle == false)}"><a href="#"><i class="icon-pitch-24"></i> <span translate="F_ONFOOT">Araçsız</span></a></li>
<li ng-click="setWithVehicle(true)" ng-class="{'active':(withVehicle == true)}"><a href="#"><i class="icon-cittadinosymbols-webfont-3"></i> <span translate="F_VEHICLE">Araçlı</span></a></li>
</ul>
<div class="n-wrapper col-sm-smallizer-6" ng-hide="withVehicle">
<div class="row">
<div class="col-sm-6">
<!--ppl picker-->
<div class="n-block-col-single">
<div class="n-input-label"><i class="icon-male adult-male span_i"></i> <span class="span_fixed" translate="F_REGULAR">Tam Bilet</span></div>
<select class="select_dd n-select-block" ng-model="adultTicketCount">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</div>
<!---/ppl picker-->
</div>
<div class="col-sm-6">
<!--ppl picker-->
<div class="n-block-col-single">
<div class="n-input-label"><i class="icon-male child-male span_i"></i> <span class="span_fixed" translate="F_CHILD">Çocuk</span></div>
<select class="select_dd n-select-block" ng-model="childTicketCount">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</div>
<!---/ppl picker-->
</div>
</div>
<div class="n-select-holder n-mixed-holder ">
<!--ppl picker-->
<div class="n-block-col-single ppl-picker">
<div class="n-input-label clearfix">
<div class="pull-left"><i class="icon-male span_i"></i> <span class="span_fixed" translate="F_DISCOUNTED">İndirimli</span></div>
<div class="pull-right" >
</div>
</div>
<select class="select_dd" ng-model="discountCount">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<select ng-model="currentDiscount" ng-options="d.name for d in stockDiscounts" class="select_dd" placeholder="Seçiniz">
<option value="" translate="F_CHOOSE">Seçiniz</option>
</select>
<a class="btn-n-form-add" ng-click="addDiscount(discountCount,currentDiscount)">+ <span translate="F_ADD">Ekle</a>
</div>
<!---/ppl picker-->
</div>
</div>
<div class="n-wrapper col-sm-smallizer-6" ng-show="withVehicle">
<div class="n-select-holder n-mixed-holder">
<!--ppl picker-->
<div class="n-block-col-single vehicle-alt-picker ">
<div class="n-input-label clearfix">
<div class="pull-left"><i class="icon-transportation-car span_i"></i> <span class="span_fixed" translate="F_VEHICLES">Araçlar</span></div>
<div class="pull-right">
<!--
<a data-template="shared/list_vehicles.html" data-animation="am-fade" data-placement="center" bs-modal="modal" href="javascript:;"><i class="glyphicon glyphicon-eye-open" id="bigeye"></i> {{vehicles|sumByKey:'count'}}</a>
-->
</div>
</div>
<!--
<select ng-model="currentVehicle" class="select_dd" placeholder="Seçiniz">
<option value="">{{'F_CHOOSE'|translate}}</option>
<option ng-repeat="p in stockVehicles" value="{{p.id}}">
{{p.name}}
</option>
</select>
-->
<select ng-model="currentVehicle" ng-options="p.name for p in stockVehicles" class="select_dd" placeholder="Seçiniz">
<option value="" translate="F_CHOOSE">Seçiniz</option>
</select>
<a class="btn-n-form-add" ng-click="addVehicle(1,currentVehicle)">+ {{'F_ADD'|translate}}</a>
</div>
<!---/ppl picker-->
</div>
<div class="row">
<!--
<div class="col-sm-12">
<div class="n-block-col-single mAlertDriver">
Lütfen SÜRÜCÜ HARİÇ seçim yapınız.
</div>
</div>
-->
<div class="col-sm-6">
<!--ppl picker-->
<div class="n-block-col-single">
<div class="n-input-label"><i class="icon-male adult-male span_i"></i> <span class="span_fixed" translate="F_REGULAR">Tam Bilet</span></div>
<select class="select_dd n-select-block" ng-model="adultTicketCount">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</div>
<!---/ppl picker-->
</div>
<div class="col-sm-6">
<!--ppl picker-->
<div class="n-block-col-single">
<div class="n-input-label"><i class="icon-male child-male span_i"></i> <span class="span_fixed" translate="F_CHILD">Çocuk</span></div>
<select class="select_dd n-select-block" ng-model="childTicketCount">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</div>
<!---/ppl picker-->
</div>
</div>
</div>
<div ng-if="(1 * adultTicketCount) + (1 * childTicketCount) + ( 1 * gDiscountTicketCount ) + ( 1 * gVehicleCount ) > 0" id="extraArea" class="n-block-col-single n-block-col-single-chckout topper n-result-block">
<div class="n-peep-label clearfix">
<div>
<a data-template="shared/list_checkout.html" data-animation="am-fade" data-placement="center" data-container="body" bs-modal="modal" href="javascript:;">
<i class="icon-male adult-male"></i> {{ (1 * adultTicketCount) + (1 * childTicketCount) + ( 1 * gDiscountTicketCount ) }} <span translate="F_PERSON">kişi</span>
<br>
<span ng-if="gVehicleCount">
<i class="icon-transportation-car"></i> {{ (1 * gVehicleCount) }} <span translate="FS_VEHICLE">araç</span>
</span>
</a>
</div>
</div>
</div>
</div>
</div>
<form id="ticketform" action="https://book.ido.com.tr/Common/MemberRezvResults.jsp" method="post">
<!-- hidden fields -->
<div>
<input class="FormText" type="hidden" name="clickedButton" id="clickedButton" value="btnSearch">
<input type="hidden" name="segmentType" value="1">
<input type="hidden" name="carrierCode" value="IDO">
<input type="hidden" name="TRIPTYPE" value="{{tripType}}" >
<input type="hidden" name="VEHICLE_SELECTION" value="{{vehicleSelection}}">
<input type="text" class="hdr" name="DEPPORT" value="{{departurePortObject.terminal_code}}">
<input type="text" class="hdr" name="ARRPORT" value="{{arrivalPortObject.terminal_code}}">
<input type="hidden" name="DEPDATE" value="{{strftime(true,true)}}">
<input type="hidden" name="RETDATE" value="{{strftime(false,true)}}">
<input type="hidden" name="ADULT" value="{{adultTicketCount}}">
<input type="hidden" name="INFANT" value="{{childTicketCount}}">
<input type="hidden" name="searchTariffDOM" value="{{strftime(true,true)}}">
<input type="hidden" name="searchTariffINT" value="{{strftime(false,true)}}">
<input type="hidden" name="vehicleComboCount" value="10">
<input type="hidden" name="discountPaxComboCount" value="10">
<input type="hidden" name="vehicleType_0" value="{{vehicles[0].id}}">
<input type="hidden" name="vehicleType_1" value="{{vehicles[1].id}}">
<input type="hidden" name="vehicleType_2" value="{{vehicles[2].id}}">
<input type="hidden" name="vehicleType_3" value="{{vehicles[3].id}}">
<input type="hidden" name="vehicleType_4" value="{{vehicles[4].id}}">
<input type="hidden" name="vehicleType_5" value="{{vehicles[5].id}}">
<input type="hidden" name="vehicleType_6" value="{{vehicles[6].id}}">
<input type="hidden" name="vehicleType_7" value="{{vehicles[7].id}}">
<input type="hidden" name="vehicleType_8" value="{{vehicles[8].id}}">
<input type="hidden" name="vehicleType_9" value="{{vehicles[9].id}}">
<input type="hidden" name="vehicleCount_0" value="{{vehicles[0].count || 0}}">
<input type="hidden" name="vehicleCount_1" value="{{vehicles[1].count || 0}}">
<input type="hidden" name="vehicleCount_2" value="{{vehicles[2].count || 0}}">
<input type="hidden" name="vehicleCount_3" value="{{vehicles[3].count || 0}}">
<input type="hidden" name="vehicleCount_4" value="{{vehicles[4].count || 0}}">
<input type="hidden" name="vehicleCount_5" value="{{vehicles[5].count || 0}}">
<input type="hidden" name="vehicleCount_6" value="{{vehicles[6].count || 0}}">
<input type="hidden" name="vehicleCount_7" value="{{vehicles[7].count || 0}}">
<input type="hidden" name="vehicleCount_8" value="{{vehicles[8].count || 0}}">
<input type="hidden" name="vehicleCount_9" value="{{vehicles[9].count || 0}}">
<input type="hidden" name="discountPaxType_0" value="{{discounts[0].value}}">
<input type="hidden" name="discountPaxType_1" value="{{discounts[1].value}}">
<input type="hidden" name="discountPaxType_2" value="{{discounts[2].value}}">
<input type="hidden" name="discountPaxType_3" value="{{discounts[3].value}}">
<input type="hidden" name="discountPaxType_4" value="{{discounts[4].value}}">
<input type="hidden" name="discountPaxType_5" value="{{discounts[5].value}}">
<input type="hidden" name="discountPaxType_6" value="{{discounts[6].value}}">
<input type="hidden" name="discountPaxType_7" value="{{discounts[7].value}}">
<input type="hidden" name="discountPaxType_8" value="{{discounts[8].value}}">
<input type="hidden" name="discountPaxType_9" value="{{discounts[9].value}}">
<input type="hidden" name="discountPaxCount_0" value="{{discounts[0].count || 0}}">
<input type="hidden" name="discountPaxCount_1" value="{{discounts[1].count || 0}}">
<input type="hidden" name="discountPaxCount_2" value="{{discounts[2].count || 0}}">
<input type="hidden" name="discountPaxCount_3" value="{{discounts[3].count || 0}}">
<input type="hidden" name="discountPaxCount_4" value="{{discounts[4].count || 0}}">
<input type="hidden" name="discountPaxCount_5" value="{{discounts[5].count || 0}}">
<input type="hidden" name="discountPaxCount_6" value="{{discounts[6].count || 0}}">
<input type="hidden" name="discountPaxCount_7" value="{{discounts[7].count || 0}}">
<input type="hidden" name="discountPaxCount_8" value="{{discounts[8].count || 0}}">
<input type="hidden" name="discountPaxCount_9" value="{{discounts[9].count || 0}}">
<input type="hidden" name="PROMOTION_CODE" value="{{promotionCode}}">
</div>
</form>
<form id="queryform" action="https://book.ido.com.tr/Common/ScheduledVoyageList.jsp" method="post">
<!-- hidden fields -->
<div>
<input class="FormText" type="hidden" name="clickedButton" id="clickedButton" value="btnSearchINT">
<input type="hidden" name="segmentType" value="11">
<input type="hidden" name="carrierCode" value="">
<input type="hidden" name="TRIPTYPE" value="R" >
<input type="hidden" name="VEHICLE_SELECTION" value="F">
<input type="text" class="hdr" name="DEPPORT" value="">
<input type="text" class="hdr" name="ARRPORT" value="">
<input type="hidden" name="DEPDATE" value="{{strftime(true,true)}}">
<input type="hidden" name="RETDATE" value="{{strftime(false,true)}}">
<input type="hidden" name="ADULT" value="0">
<input type="hidden" name="INFANT" value="0">
<input type="hidden" name="searchTariffDOM" value="{{strftime(true,true)}}">
<input type="hidden" name="searchTariffINT" value="{{strftime(true,true)}}">
<input type="hidden" name="vehicleComboCount" value="1">
<input type="hidden" name="discountPaxComboCount" value="1">
<input type="hidden" name="vehicleType_0" value="">
<input type="hidden" name="vehicleType_1" value="">
<input type="hidden" name="vehicleType_2" value="">
<input type="hidden" name="vehicleType_3" value="">
<input type="hidden" name="vehicleType_4" value="">
<input type="hidden" name="vehicleType_5" value="">
<input type="hidden" name="vehicleType_6" value="">
<input type="hidden" name="vehicleType_7" value="">
<input type="hidden" name="vehicleType_8" value="">
<input type="hidden" name="vehicleType_9" value="">
<input type="hidden" name="vehicleCount_0" value="0">
<input type="hidden" name="vehicleCount_1" value="0">
<input type="hidden" name="vehicleCount_2" value="0">
<input type="hidden" name="vehicleCount_3" value="0">
<input type="hidden" name="vehicleCount_4" value="0">
<input type="hidden" name="vehicleCount_5" value="0">
<input type="hidden" name="vehicleCount_6" value="0">
<input type="hidden" name="vehicleCount_7" value="0">
<input type="hidden" name="vehicleCount_8" value="0">
<input type="hidden" name="vehicleCount_9" value="0">
<input type="hidden" name="discountPaxType_0" value="">
<input type="hidden" name="discountPaxType_1" value="">
<input type="hidden" name="discountPaxType_2" value="">
<input type="hidden" name="discountPaxType_3" value="">
<input type="hidden" name="discountPaxType_4" value="">
<input type="hidden" name="discountPaxType_5" value="">
<input type="hidden" name="discountPaxType_6" value="">
<input type="hidden" name="discountPaxType_7" value="">
<input type="hidden" name="discountPaxType_8" value="">
<input type="hidden" name="discountPaxType_9" value="">
<input type="hidden" name="discountPaxCount_0" value="0">
<input type="hidden" name="discountPaxCount_1" value="0">
<input type="hidden" name="discountPaxCount_2" value="0">
<input type="hidden" name="discountPaxCount_3" value="0">
<input type="hidden" name="discountPaxCount_4" value="0">
<input type="hidden" name="discountPaxCount_5" value="0">
<input type="hidden" name="discountPaxCount_6" value="0">
<input type="hidden" name="discountPaxCount_7" value="0">
<input type="hidden" name="discountPaxCount_8" value="0">
<input type="hidden" name="discountPaxCount_9" value="0">
<input type="hidden" name="PROMOTION_CODE" value="Promosyon Kodu">
<input type="hidden" name="CITY_PORT_DOM" value="">
<input type="hidden" name="CITY_PORT_ARR_DOM" value="">
<input type="hidden" name="CITY_PORT_INT" value="{{departurePortObject.terminal_code}}">
<input type="hidden" name="CITY_PORT_ARR_INT" value="{{arrivalPortObject.terminal_code}}">
</div>
</form>
<div class="clearfix">
<div class="n-action n-action-alt">
<div class="row">
<div class='col-sm-6' ng-show="!timetableQueryForm">
<input type="text" placeholder="{{ 'PROMOTION_CODE'| translate }}" class="promoinput input-sm form-control">
</div>
<div ng-class="decideClassSubmit(timetableQueryForm)" >
<a href="javascript:;" ng-click="submitForm()" class="btn btn-form-success btn-lg btn-block btn-lgx" translate="F_CONTINUE">Devam Et</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
app.filter('sumByKey', function() {
return function(data, key) {
if (typeof(data) === 'undefined' || typeof(key) === 'undefined') {
return 0;
}
var sum = 0;
for (var i = data.length - 1; i >= 0; i--) {
sum += parseInt(data[i][key]);
}
return sum;
};
});
app.factory('matrix', function($http, $rootScope) {
var promise = null;
return function(slug) {
var base = _API+"anchors/matrix";
return $http({
url: base,
method: "GET",
timeout: 3000,
});
};
});
app.directive('ticketForm', function($rootScope, $http, $timeout, matrix, $tooltip, $filter) {
return {
restrict: 'E',
templateUrl:"directives/ticket_form.html",
replace: true,
scope: {
formtype:"@"
},
link: function(scope, elm, attrs,$http) {
},
controller: function($scope, $location, $rootScope, $http) {
matrix().success(function(data) {
$scope.matrix_ports = data;
$("select").blur();
});
$scope.vehicles = [
];
$scope.discounts = [
];
$scope.stockVehicles = [
{id:101, name:'Otomobil (1-4 Kişi)'},
{id:162, name:'Otomobil (6-9 Kişi)'},
{id:102, name:'Jip'},
{id:103, name:'Minivan'},
{id:104, name:'Minibüs (1-12)'},
{id:107, name:'Minibüs (13-19)'},
{id:108, name:'Midibüs (20-33)'},
{id:109, name:'Kamyonet (0-2000)'},
{id:110, name:'Kamyonet (2001-2500)'},
{id:111, name:'Kamyonet (2501-3500)'},
{id:112, name:'Motosiklet'},
{id:113, name:'Otobüs'},
{id:115, name:'Römork / Çekilen'},
{id:141, name:'Karavan'}
];
$scope.stockDiscounts = [
{id:401, name:'Basın', value:"BS"},
{id:402, name:'Engelli', value:"EN"},
{id:403, name:'Gazi', value:"GZ"},
{id:404, name:'Öğrenci', value:"OG"},
{id:405, name:'65 yaş üstü', value:"YS"}
];
$scope.month_vars = {
'en' : ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
'tr' : ['Oca', 'Şub', 'Mar', 'Nis', 'May', 'Haz', 'Tem', 'Ağu', 'Eyl', 'Ekm', 'Kas', 'Ara']
}
$scope.month_en = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
$scope.month_tr = ['Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık'];
$scope.timetableQueryForm = false;
$scope.queryIsDomestic = true;
$scope.tripType = "R";
$scope.vehicleSelection = "O";
$scope.returnTrip = true;
$scope.withVehicle = false;
$scope.arrivalPort,$scope.arrivalPortObject = undefined;
$scope.departurePort,$scope.departurePortObject = undefined;
$scope.adultTicketCount = 0;
$scope.childTicketCount = 0;
$scope.discountTicketCount = 0;
$scope.discountPaxCount = 0;
$scope.currentVehicle = {};
$scope.currentDiscount = {};
$scope.formDetail = false;
$scope.gDiscountTicketCount = 0;
$scope.gVehicleCount = 0;
$scope.$watch('departurePort', function(){
$scope.departurePortObject = angular.fromJson($scope.departurePort);
$scope.arrivalPort = $scope.arrivalPortObject = undefined;
angular.forEach($scope.matrix_ports, function(v) {
if(v.port.id == $scope.departurePortObject.id) {
$scope.selected_matrix = v;
}
})
});
$scope.$watch('arrivalPort', function(){
if($scope.arrivalPort !== undefined) {
$scope.arrivalPortObject = angular.fromJson($scope.arrivalPort);
}
});
$scope.ticketFormTabClick = function(p){
if (!p) {
$scope.timetableQueryForm = true;
}
else {
$scope.timetableQueryForm = false;
}
};
$scope.submitQueryForm = function() {
$("#queryform").submit();
};
if ($scope.formtype == "inner") {
$scope.formDetail = true;
}
$scope.vehicleCount = 1;
$scope.discountCount =0;
$scope.port = undefined;
$scope.inputDate = $rootScope.selectedDates;
$scope.$watchCollection('inputDate', function (newDate) {
//console.log(newDate);
$scope.arrivalDate = newDate.startDate;
$scope.departureDate = newDate.endDate;
if($scope.arrivalDate > $scope.departureDate) {
var ddd = moment($scope.arrivalDate).add('days', 2).toDate();
$scope.inputDate.endDate = ddd;
$scope.safeApply();
}
$scope.depDate = $scope.strftime(true,false);
$scope.retDate = $scope.strftime(false,false);
$scope.tarifDom = $scope.strftime(true,true);
$scope.tarifInt = $scope.strftime(false,true);
}, false);
$scope.range = function(n) {
return new Array(n);
};
$scope.safeApply = function(fn) {
var phase = this.$root.$$phase;
if(phase == '$apply' || phase == '$digest') {
if(fn && (typeof(fn) === 'function')) {
fn();
}
} else {
this.$apply(fn);
}
};
$scope.strftime = function(is_start, is_point) {
var d = $scope.inputDate;
var dd = undefined;
var b = "/";
if (is_start) {
dd = d.startDate
}
else{
dd = d.endDate;
}
if (is_point) {
b = ".";
}
var day = ("0"+ dd.getDate() +"").slice(-2);
var month = ("0" + (dd.getMonth() + 1) + "").slice(-2);
var year = ""+ dd.getFullYear();
return (day + b + month + b + year);
};
$scope.parseDate = function(format,is_start) {
var d = $scope.inputDate;
if(d) {
if (is_start) {
var dy = d.startDate
}
else{
var dy = d.endDate;
}
if (format == 'day')
{
//return dy.getDate();
return ("0"+ dy.getDate() +"").slice(-2);
}
else if (format == 'month')
{
return $scope.findMonth(dy.getMonth());
}
else if (format == 'year')
{
return dy.getFullYear();
}
}
};
$scope.findMonth = function(m) {
return $scope.month_vars[$rootScope.detailParameters.lang][m];
};
$scope.setReturnTrip = function(bool){
$scope.returnTrip = bool;
if ($scope.returnTrip == false) {
$scope.tripType = "O";
}
else {
$scope.tripType = "R";
}
};
$scope.resetForm = function() {
$scope.adultTicketCount = 0;
$scope.childTicketCount = 0;
$scope.discountTicketCount = 0;
$scope.discountPaxCount = 0;
$scope.currentVehicle = {};
$scope.currentDiscount = {};
$scope.gDiscountTicketCount = 0;
$scope.gVehicleCount = 0;
};
$scope.setWithVehicle = function(bool) {
$scope.resetForm();
if (bool) {
$scope.vehicleSelection= 'T';
}
else {
$scope.vehicleSelection= 'O';
}
$scope.withVehicle = bool;
};
// $scope.selectedPort = "";
$scope.enable = function() {
$scope.disabled = false;
};
$scope.disable = function() {
$scope.disabled = true;
};
$scope.clear = function() {
$scope.port.selected = undefined;
};
var removeByAttr = function(arr, attr, value){
var i = arr.length;
while(i--){
if(arr[i] && arr[i].hasOwnProperty(attr) && (arguments.length > 2 && arr[i][attr] === value )){
arr.splice(i,1);
}
}
return arr;
};
$scope.addVehicle = function(cnt,vhcl) {
if (vhcl && cnt > 0 ) {
$scope.currentVehicle = vhcl;
$scope.vehicleCount = cnt;
var v = {id:$scope.currentVehicle.id, name:$scope.currentVehicle.name, count: $scope.vehicleCount}
var result = $.grep($scope.vehicles, function(e){ return e.id == v.id; });
if (result.length == 0) {
$scope.vehicles.push(v);
}
else {
for (var i=0; i<$scope.vehicles.length; i++) {
if ($scope.vehicles[i].id == v.id){
$scope.vehicles[i].count = parseInt($scope.vehicles[i].count,10) + parseInt(v.count,10);
}
}
}
$scope.currentVehicle = null;
var cnt = $filter('sumByKey')($scope.vehicles, "count");
$scope.gVehicleCount = cnt;
}
};
$scope.removeVehicle = function(id){
var result = $.grep($scope.vehicles, function(e){ return e.id == id; });
if (result.length == 0) {
return;
} else if (result.length == 1) {
removeByAttr($scope.vehicles, 'id', result[0].id);
var cnt = $filter('sumByKey')($scope.vehicles, "count");
$scope.gVehicleCount = cnt;
}
};
$scope.addDiscount = function(cnt,disc) {
if (disc !== undefined && disc !== null && disc.id !== undefined && disc != '' && cnt > 0 ) {
$scope.currentDiscount = disc;
$scope.discountCount = cnt;
//console.log("pff", disc);
var v = {id:$scope.currentDiscount.id, value:$scope.currentDiscount.value, name:$scope.currentDiscount.name, count: $scope.discountCount}
var result = $.grep($scope.discounts, function(e){ return e.id == v.id; });
if (result.length == 0) {
$scope.discounts.push(v);
}
else {
for (var i=0; i<$scope.discounts.length; i++) {
if ($scope.discounts[i].id == v.id){
$scope.discounts[i].count = parseInt($scope.discounts[i].count,10) + parseInt(v.count,10);
}
}
}
$scope.discountCount = 0;
$scope.currentDiscount = null;
var cnt = $filter('sumByKey')($scope.discounts, "count");
$scope.gDiscountTicketCount = cnt;
}
// var myTooltip = $tooltip($("#bigeye"), {title: 'My Title'});
// myTooltip.$scope.$show();
};
$scope.resetC = function(f) {
$scope.childTicketCount = 0;
$scope.safeApply();
};
$scope.resetA = function(f) {
$scope.adultTicketCount = 0;
$scope.safeApply();
};
$scope.removeDiscount = function(id){
var result = $.grep($scope.discounts, function(e){ return e.id == id; });
if (result.length == 0) {
return;
} else if (result.length == 1) {
removeByAttr($scope.discounts, 'id', result[0].id);
var cnt = $filter('sumByKey')($scope.discounts, "count");
$scope.gDiscountTicketCount = cnt;
}
};
var tt1, tt2;
$scope.closeTooltips = function() {
if(tt1 !== undefined) {
$timeout(tt1.$scope.$hide, 20);
}
if(tt2 !== undefined) {
$timeout(tt2.$scope.$hide, 20);
}
}
$scope.decideClassSubmit = function(axy) {
if(axy) {
return "col-sm-12";
} else {
return "col-sm-6";
}
};
$scope.submitForm = function(){
if($scope.timetableQueryForm) {
var rtn = true;
if(!$scope.departurePort) {
tt1 = $tooltip($("#dp_s"), {
title: 'Lütfen terminal seçiniz',
placement: 'bottom-left',
animation: true,
popupDelay: 0,
appendToBody: false,
trigger: 'manual'
});
tt1.$scope.$show();
$timeout(tt1.$scope.$hide, 3000);
rtn = false;
}
if(!$scope.arrivalPort) {
var tt2 = $tooltip($("#ar_s"), {
title: 'Lütfen terminal seçiniz',
placement: 'bottom-left',
animation: true,
popupDelay: 0,
appendToBody: false,
trigger: 'manual'
});
tt2.$scope.$show();
$timeout(tt2.$scope.$hide, 3000);
rtn = false;
}
if(rtn) {
$("#queryform").submit();
return;
} else {
return false;
}
}
var cnts = ($scope.gDiscountTicketCount == 0 && $scope.adultTicketCount == 0);
if(!$scope.departurePort || !$scope.arrivalPort) {
if(!$scope.departurePort) {
tt1 = $tooltip($("#dp_s"), {
title: 'Lütfen terminal seçiniz',
placement: 'bottom-left',
animation: true,
popupDelay: 0,
appendToBody: false,
trigger: 'manual'
});
tt1.$scope.$show();
$timeout(tt1.$scope.$hide, 3000);
}
if(!$scope.arrivalPort) {
var tt2 = $tooltip($("#ar_s"), {
title: 'Lütfen terminal seçiniz',
placement: 'bottom-left',
animation: true,
popupDelay: 0,
appendToBody: false,
trigger: 'manual'
});
tt2.$scope.$show();
$timeout(tt2.$scope.$hide, 3000);
}
if(1 == 2 && cnts) {
var tt4 = $tooltip($("#pAlertArea"), {
title: 'Lütfen yolcu seçimi yapınız',
placement: 'bottom-left',
animation: true,
popupDelay: 0,
appendToBody: false,
trigger: 'manual'
});
tt4.$scope.$show();
$timeout(tt4.$scope.$hide, 3000);
}
return false;
}
$("#ticketform").submit();
};
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment