<div bsModal #createOrEditModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="createOrEditModal" aria-hidden="true" [config]="{backdrop: 'static'}">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <form *ngIf="active" #routeDefinitionForm="ngForm" novalidate (ngSubmit)="save()" autocomplete="off">
                <div class="modal-header">
                    <h4 class="modal-title">
                        <span *ngIf="routeDefinition.id">{{l("EditRouteDefinition")}}</span>
                        <span *ngIf="!routeDefinition.id">{{l("CreateNewRouteDefinition")}}</span>
                    </h4>
                    <button type="button" class="close" (click)="close()" aria-label="Close" [disabled]="saving">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                                <div class="form-group">
                                                <label for="routeCode">{{l("Route Code")}} *</label>
                                                <input type="text" id="routeCode" class="form-control" [(ngModel)]="routeDefinition.routeCode" name="routeCode"  required/>
                                </div>

					           <label for="RouteTypeRouteTypeCode">{{l("RouteType")}}</label>
		            
                                <div class="form-group">
                                    
                                    <select id = "routeType" class="form-control kt-select2" name="routeType" data-placeholder="Select Route Type">
                                        {{routeDefinitionId == '' ? '<option></option>' : ''}}
                                        <option *ngFor="let routeType of routeTypes" value= "{{routeType.id}}" [selected]="routeType.id === routeDefinition.routeTypeId">
                                            {{ routeType.displayName }}
                                          </option>
                                    </select>
                                </div>
                    
			                    <label for="userInput">{{"Route Stop" | localize}}</label>
                                     
                                <div class="form-group">
                                     <select id = "routeStop" class="form-control kt-select2" name="routeStop" data-placeholder="Select Route Stop">
                                         {{routeDefinitionId == '' ? '<option></option>' : ''}}
                                         <option *ngFor="let contact of contacts" value="{{contact.id}}" [selected]="contact.id === routeDefinition.defaultContactId">
                                             {{ contact.firstName }}
                                           </option>
                                     </select>
                                </div>

                                <label for="userInput">{{"DriverName" | localize}}</label>
                                <div class="form-group">
                                     
                                     <select id = "driver" class="form-control kt-select2" name="driver" data-placeholder="Select Driver">
                                         {{routeDefinitionId == '' ? '<option></option>' : ''}}
                                         <option *ngFor="let user of users" value="{{user.id}}" [selected]="user.id === routeDefinition.defaultUserId">
                                             {{user.name +" "+ user.surname }}
                                           </option>
                                     </select>
                                </div>

                                <label>{{"Location" | localize}} *</label>
                                <div class="form-group">
                                   
                                   <select class="form-control kt-select2" data-placeholder="Select Location" id="txtLocation" aria-hidden="true" name="txtLocation">
                                      {{routeDefinitionId == '' ? '<option></option>' : ''}}
                                      <option  *ngFor="let location of locations" value="{{location.id}}" [selected]="location.id === routeDefinition.locationId">{{location.name}}</option>
                                   </select>
                                </div>
                                
								<div class="form-group">
									<label>{{l("Threshold")}}</label>
									<input type="number" id="threshold" class="form-control" [(ngModel)]="routeDefinition.threshold" name="threshold"  />
								</div>

                                <div class="form-group">
                                  <div class="row">
                                                <div class="col-sm-6">
                                                  <label>{{l("Eta")}}</label>
                                                
                                                  <timepicker
                                                  [(ngModel)]="eta" name="eta"
                                                  [showSpinners]="true" 
                                                  #etaCtrl="ngModel" 
                                                  ></timepicker>
                                                </div>
                                                
                                                <div class="col-sm-6">
                                                    <label>{{l("Cut Off")}}</label>
                                                
                                                    <timepicker [(ngModel)]="routeDefinition.cutOff" name="cutOff"
                                                    [showSpinners]="true" 
                                                    #cutOffCtrl="ngModel"
                                                    ></timepicker>
                                                </div>
                                    </div>
                                </div>
					

                </div>
                <div class="modal-footer">
                    <button [disabled]="saving" type="button" class="btn btn-default btn-elevate btn-pill" (click)="close()">{{l("Cancel")}}</button>
                    <button type="submit" class="btn btn-primary btn-elevate btn-pill" [disabled]="!routeDefinitionForm.form.valid" [buttonBusy]="saving" [busyText]="l('SavingWithThreeDot')"><i class="fa fa-save"></i> <span>{{l("Save")}}</span></button>
                </div>
            </form>
        </div>
    </div>
<routeDefinitionRouteTypeLookupTableModal #routeDefinitionRouteTypeLookupTableModal (modalSave)="getNewRouteTypeId()"></routeDefinitionRouteTypeLookupTableModal>
		 
</div>