<md-dialog aria-label="Dettaglio disposizione" layout="column" style="heigth:90%;min-height:90%;width:90%;max-width:90%">
		<md-toolbar layout="row">
		   <div class="md-toolbar-tools" flex>
		     <h3 flex style="text-overflow:ellipsis">{{piano.denominazione.trim()}}</h3>
		   </div>
		   <span flex></span>

			<md-button ng-click="assegnaContoDefault(1,$event)" class="toolbar-button" ng-if="piano.id!=null && piano.id!=0">
		 		<i class="fa fa-bank"></i>
				<span>Conto 1</span>
				<md-tooltip>Conto default 1</md-tooltip>
			</md-button>

			<md-button ng-click="assegnaContoDefault(2,$event)" class="toolbar-button" ng-if="piano.id!=null && piano.id!=0">
		 		<i class="fa fa-bank"></i>
				<span>Conto 2</span>
				<md-tooltip>Conto default 2</md-tooltip>
			</md-button>

			<md-button ng-click="opzioniPiano($event)" class="toolbar-button" ng-if="piano.id!=null && piano.id!=0">
		 		<i class="fa fa-cogs"></i>
				<span>Opzioni</span>
				<md-tooltip>Opzioni piano di estrazione</md-tooltip>
			</md-button>

			<md-button ng-click="eseguiPiano($event)" class="toolbar-button" ng-if="piano.id!=null && piano.id!=0">
		 		<i class="fa fa-play"></i>
				<span>Esegui</span>
				<md-tooltip>Forza esecuzione del piano</md-tooltip>
			</md-button>
		   
		   
		   <md-icon style="margin-left:24px" ng-click="cancelDialog()" md-font-icon="fa-times" class="fa button-icon" aria-label="Chiudi" title="Chiudi"></md-icon>
		 </md-toolbar>

	<md-dialog-content class="sticky-container" layout="column" style="padding:14px;min-height:750px" flex>
		<ng-form name="form" ng-submit="confirmDialog()" layout="column" flex>
			<md-content flex layout-margin layout="column">
				<div layout="row">
					<md-input-container>
						<md-switch  ng-model="piano.enabled" style="margin:0;padding:0;margin-right:16px;margin-top:-4px"> 
							<span ng-if="piano.enabled">Abilitato</span>
							<span ng-if="!piano.enabled">Disabilitato</span>
						</md-switch>
					</md-input-container>
					<md-input-container flex>
						<label>Denominazione</label>
						<input ng-model="piano.denominazione" />
					</md-input-container>	
				</div>
				<fieldset>
					<legend>Schedulazione</legend>
					<div layout-gt-md="row" layout="column" flex>
						<div layout="row" flex>
							<div flex flex-md="25" flex-sm="25" flex-xs="25">
								<md-checkbox  ng-model="piano.scheduledDay2">Lun</md-checkbox>
							</div>
							<div flex flex-md="25" flex-sm="25" flex-xs="25">
								<md-checkbox  ng-model="piano.scheduledDay3">Mar</md-checkbox>
							</div>
							<div flex flex-md="25" flex-sm="25" flex-xs="25">
								<md-checkbox  ng-model="piano.scheduledDay4">Mer</md-checkbox>
							</div>
						</div>
						<div layout="row" flex>
							<div flex>
								<md-checkbox  ng-model="piano.scheduledDay5">Gio</md-checkbox>
							</div>
							<div flex>
								<md-checkbox  ng-model="piano.scheduledDay6">Ven</md-checkbox>
							</div>
							<div flex>
								<md-checkbox  ng-model="piano.scheduledDay7">Sab</md-checkbox>
							</div>
							<div flex>
								<md-checkbox  ng-model="piano.scheduledDay1">Dom</md-checkbox>
							</div>
						</div>
					</div>
				</fieldset>		
				<div layout-gt-sm="row" layout="column">
						<md-input-container flex-gt-md="25" flex="100">
							<md-checkbox  ng-model="piano.usedByService">Servizio conversione</md-checkbox>
						</md-input-container>
						<md-input-container flex-gt-md="15" flex="100">
							<label>Orario di avvio</label>
							<input type="time" id="startTime" ng-model="piano.startTime" step="900" ng-blur="checkStartTime()"/>
						</md-input-container>
						<md-input-container flex-gt-md="15" flex="100">
							<label>Ora cutoff per disposizioni</label>
							<input type="time" id="oraCutoff" ng-model="piano.cutOffDataCreazioneDisposizione" step="900" ng-blur="checkTime()"/>
						</md-input-container>
						<md-input-container flex-gt-md="25" flex="100">
							<label>Stato disposizioni per estrazione</label>
							<md-select ng-model="piano.statoDisposizioneDaEstrarre"">
									<md-option ng-value="'Inserita'">Inserita</md-option>
									<md-option ng-value="'Confermata'">Confermata</md-option>
									<md-option ng-value="'Approvata'">Approvata</md-option>
							</md-select>
						</md-input-container>
						<md-input-container flex-gt-md="25" flex="100">
							<md-checkbox  ng-model="piano.usaTipoSequenzaRid">Aggrega per tipo sequenza RID</md-checkbox>
						</md-input-container>
					</div>
					<div layout="row" ng-if="piano.id==null || piano.id==0">
						<span flex></span>
						<md-button type="submit" aria-label="Crea" class="md-raised md-primary" title="Crea il piano" ng-click="confirmDialog($event)">
				        	<md-icon md-font-icon="fa-floppy-o" class="fa" aria-label="Salva"></md-icon>
				            Crea
				        </md-button>
			        	<md-button aria-label="Annulla" class="md-raised md-warn" ng-click="cancelDialog($event)" title="Annulla le modifiche">
					    	<md-icon md-font-icon="fa-times" class="fa" aria-label="Annulla" ></md-icon>
					        Annulla
				        </md-button>
				    </div>    						
				<div ng-if="piano.id!=null && piano.id!=0">
					<md-toolbar layout="row" class="small-toolbar md-toolbar-tools md-whiteframe-4dp"  >
						Istruzioni
						<span flex></span>
						<md-button ng-click="nuovaIstruzione($event)" class="toolbar-button">
			 	 			<i class="fa fa-plus"></i>
				 			<span>Nuova</span>
							<md-tooltip>Inserisci una nuova istruzione</md-tooltip>
						</md-button>
						<md-button ng-click="opzioniPiano($event)" class="toolbar-button">
			 	 			<i class="fa fa-cogs"></i>
				 			<span>Opzioni</span>
							<md-tooltip>Opzioni piano di estrazione</md-tooltip>
						</md-button>
						
					</md-toolbar>
					<table class="table">
						<thead>
							<tr style="text-align:center">
								<td style="width:40px">Iter #</td>
								<td style="width:90px">Tipologia</td>
								<td style="width:240px">Tipo disposizione sinistri</td>
								<td style="width:85px">Provenienza</td>
								<td style="width:85px">Funz. ordinante</td>
								<td style="width:60px">***</td>
								<td style="width:90px">Range importo disp.</td>
								<td style="width:60px">***</td>
								<td style="width:90px">Range importo disp.</td>
								<td style="width:90px">Imp.limite distinta</td>
								<td style="width:90px">Max. disp/distinta</td>
								<td style="width:80px">Assegna conto step 1</td>
								<td style="width:80px">Assegna conto step 2</td>
								<td style="width:80px">Assegna conto step 3				</div>
								</td>
								<td style="width:80px">Assegna conto step 4</td>
								<td style="width:48px">&nbsp;</td>
							</tr>
						</thead>
						<tbody>
						<tr ng-repeat="item in istruzioni" ng-class="{'status-ok':data.statoConvalida==-1,'status-warning':data.statoConvalida==2,'status-error':data.statoConvalida==0,'odd-row':$index%2==1,'even-row':$index%2==0, 'selectedRow': ctrl.selectedIndex===$index}">
							<td ng-click="editIstruzione($index, $event)" >{{item.rowNumber}}</td>
							<td ng-click="editIstruzione($index, $event)" >{{item.tipologia}}</td>
							<td ng-click="editIstruzione($index, $event)" >{{decodeTipoDisposizione(item.tipoDisposizione)}}</td>
							<td ng-click="editIstruzione($index, $event)" >{{item.provenienza}}</td>
							<td ng-click="editIstruzione($index, $event)" >{{item.funzioneOrdinante}}</td>
							<td ng-click="editIstruzione($index, $event)">{{item.signRangeImportoDa}}</td>
							<td ng-click="editIstruzione($index, $event)"  style="text-align:right">{{item.rangeImportoDa.formatAsCurrency()}}</td>
							<td ng-click="editIstruzione($index, $event)" >{{item.signRangeImportoA}}</td>
							<td ng-click="editIstruzione($index, $event)" style="text-align:right">{{item.rangeImportoA.formatAsCurrency()}}</td>
							<td ng-click="editIstruzione($index, $event)" style="text-align:right">{{item.importoLimiteDistinta.formatAsCurrency()}}</td>
							<td ng-click="editIstruzione($index, $event)" style="text-align:right">{{item.maxNumberDisposizioni}}</td>
							<td ng-click="editIstruzione($index, $event)" >{{decodeSearchBanca(item.searchBancaOrdinanteStep1)}}</td>
							<td ng-click="editIstruzione($index, $event)" >{{decodeSearchBanca(item.searchBancaOrdinanteStep2)}}</td>
							<td ng-click="editIstruzione($index, $event)" >{{decodeSearchBanca(item.searchBancaOrdinanteStep3)}}</td>
							<td ng-click="editIstruzione($index, $event)" >{{decodeSearchBanca(item.searchBancaOrdinanteStep4)}}</td>
							<td style="width:48px">
								<i class="fa fa-trash button-icon" ng-click="deleteIstruzione($index, $event)">
									<md-tooltip>Elimina l'istruzione</md-tooltip>
								</i>
							</td>
						</tr>
						</tbody>
					</table>
				</div>
				

			</md-content>
			<hr>
			<div layout="row" ng-if="piano.id!=null && piano.id!=0">
				<span flex></span>
				 <md-button type="submit" aria-label="Salva" class="md-raised md-primary" title="Salva il piano" ng-click="confirmDialog($event)">
		            <md-icon md-font-icon="fa-floppy-o" class="fa" aria-label="Salva"></md-icon>
		            Salva
		          </md-button>
	        		<md-button aria-label="Annulla" class="md-raised md-warn" ng-click="cancelDialog($event)" title="Annulla le modifiche">
			            <md-icon md-font-icon="fa-times" class="fa" aria-label="Annulla" ></md-icon>
			            Annulla
		          	</md-button>
			</div>			
		</ng-form>
	</md-dialog-content>
	
</md-dialog>