<div class="content" ng-init="tab=1">
	<md-button class="md-primary md-fab novo" ng-click="baixarXml()" ng-show="showDownload">
		<md-icon md-font-icon="flaticon-downloading-action"></md-icon>
	</md-button>
	<h1>Notas Fiscais</h1>
	<form ng-submit="listarNotasFiscaisServicos()">
		<div layout-gt-sm='row' layout-align="start start">
			<md-input-container>
				<label>Data Inicial</label>
				<md-datepicker ng-model="dtInicio" name="dtInicio" md-max-date="dtFim" required></md-datepicker>
				<div ng-messages="myOtherForm.dateField.$error">
					<div ng-message="valid">O valor de entrada não é uma data!</div>
					<div ng-message="required">Data obrigatória!</div>
				</div>
			</md-input-container>
			<md-input-container>
				<label>Data Final</label>
				<md-datepicker ng-model="dtFim" name="dtFim" md-min-date="dtInicio" required></md-datepicker>
				<div ng-messages="myOtherForm.dateField.$error">
					<div ng-message="valid">O valor de entrada não é uma data!</div>
					<div ng-message="required">Data obrigatória!</div>
					<div ng-message="mindate">Data muito curta!</div>
				</div>
			</md-input-container>
			<md-button type="submit" class="md-primary md-raised">Atualizar</md-button>
		</div>
	</form>

	<md-tabs md-dynamic-height md-border-bottom>

		<md-tab label="Serviços">
			<md-toolbar class="min">
				<h2 class="md-toolbar-tools">
					<span>Notas Fiscais de Serviço</span>
				</h2>
			</md-toolbar>
			<md-content>
				<md-list>
					<div ng-repeat="nfs in listaNotasServicos | filter:procuraGeral"
						ng-init="nfs.exibeDetalhes = false">
						<md-list-item class="md-2-line">
							<div class="md-list-item-text" layout-gt-sm="row" layout-align="space-between">
								<h3>
									<span>Número NFSE: </span>{{nfs.notaNumeroNFSE}}</h3>
								<h3>
									<span>Série: </span>{{nfs.notaSerie}}</h3>
								<h3>
									<span>Valor: </span>{{nfs.notaValor | currency:"R$ ":2}}</h3>
								<h3>
									<span>Emissão: </span>{{nfs.notaData | date: 'dd/MM/yyyy'}}</h3>
							</div>
							<div>
								<md-button class="md-secondary buttonPrinter"
									ng-click="nfs.exibeDetalhes = !nfs.exibeDetalhes" ng-if="!configNfs.ocultaInfos ">
									<!--&& (!nfs.linkAutenticidade || nfs.linkAutenticidade == '')-->
									<md-tooltip md-direction="top">
										Exibir detalhes
									</md-tooltip>
									<md-icon md-font-icon="flaticon-information-button"></md-icon>
								</md-button>
							</div>
							<div>
								<md-button class="md-secondary buttonPrinter"
									ng-click="visualizaNFSE(nfs.linkAutenticidade, nfs)"
									ng-if="((nfs.linkAutenticidade && nfs.linkAutenticidade != '') || nfs.utilizarDevExpress) && !configNfs.ocultaLink">
									<md-tooltip md-direction="top">
										Abrir Link NFSe
									</md-tooltip>
									<md-icon md-font-icon="flaticon-link"></md-icon>
								</md-button>
							</div>
						</md-list-item>
						<md-list-item class="md-2-line" ng-if="nfs.exibeDetalhes">
							<div class="md-list-item-text" layout-gt-sm="row" layout-align="space-between">
								<h3>
									<span>CNPJ: </span>{{ nfs.cnpj }}</h3>
								<h3>
									<span>Código de Verificação: </span>{{nfs.codigoVerificacao}}</h3>
								<h3>
									<span>Número RPS: </span>{{("000000"+nfs.notaNumero).slice(-6)}}</h3>
							</div>
						</md-list-item>
						<md-list-item class="md-2-line" ng-if="nfs.exibeDetalhes && nfs.linkConsultaNotaPortal != ''">
							<div class="md-list-item-text" layout-gt-sm="row" layout-align="space-between">
								<h3>
									<span>Link para consulta da NFSe: </span>
									<a ng-href="{{nfs.linkConsultaNotaPortal != '' ? nfs.linkConsultaNotaPortal : '' }}"
										target="_blank">
										{{nfs.linkConsultaNotaPortal != '' ? nfs.linkConsultaNotaPortal : 'Nenhum link cadastrado.'}}</a>
								</h3>
							</div>
						</md-list-item>
						<md-divider ng-if="!$last "></md-divider>
					</div>
				</md-list>
			</md-content>
		</md-tab>

		<md-tab label="Produtos">
			<md-toolbar class="min">
				<h2 class="md-toolbar-tools">
					<span>Notas Fiscais de Produto</span>
				</h2>
			</md-toolbar>
			<md-content>
				<md-list>
					<md-list-item class="md-2-line" ng-repeat="nf in listaNotasProdutos | filter:procuraGeral">
						<md-checkbox class="show-tooltip" [disabled]="nf.notaProcNFE" ng-model="nf.selected" ng-change="onClickCheck(nf)">
						</md-checkbox>
						<div class="tooltip" ng-show="!nf.notaProcNFE">Não existe XML para essa NF.</div>
						<div class="md-list-item-text" layout-gt-sm="row" layout-align="space-between">
							<h3>
								<span>Número: </span>{{("000000"+nf.notaNumero).slice(-6)}}</h3>
							<h3>
								<span>Série: </span>{{nf.notaSerie}}</h3>
							<h3>
								<span>Valor: </span>{{nf.notaValor | currency:"R$ ":2}}</h3>
							<h3>
								<span>Emissão: </span>{{nf.notaData | date: 'dd/MM/yyyy'}}</h3>
						</div>
						<div>
							<md-button class="md-secondary buttonPrinter" ng-click="visualizaDanf(nf)">
								<md-tooltip md-direction="top">
									Visualizar Danfe
								</md-tooltip>
								<md-icon md-font-icon="flaticon-copy-file"></md-icon>
							</md-button>
						</div>
						<md-divider ng-if="!$last"></md-divider>
					</md-list-item>
				</md-list>
			</md-content>
		</md-tab>

		<md-tab label="Recibos de Locação">
			<md-toolbar class="min">
				<h2 class="md-toolbar-tools">
					<span>Recibos de Locação</span>
				</h2>
			</md-toolbar>
			<md-content>
				<md-list>
					<md-list-item class="md-2-line" ng-repeat="rec in listaRecibosLocacao | filter:procuraGeral">
						<div class="md-list-item-text" layout-gt-sm="row" layout-align="space-between">
							<h3>
								<span>Número: </span>{{("000000"+rec.notaNumero).slice(-6)}}</h3>
							<h3>
								<span>Série: </span>{{rec.notaSerie}}</h3>
							<h3>
								<span>Valor: </span>{{rec.notaValor | currency:"R$ ":2}}</h3>
							<h3>
								<span>Emissão: </span>{{rec.notaData | date: 'dd/MM/yyyy'}}</h3>
						</div>
						<div>
							<md-button class="md-secondary buttonPrinter"
								ng-click="visualizaReciboLocacao(rec.nfNumeroNota)">
								<md-tooltip md-direction="top">
									Visualizar Recibo de Locação
								</md-tooltip>
								<md-icon md-font-icon="flaticon-printer-tool"></md-icon>
							</md-button>
						</div>
						<md-divider ng-if="!$last "></md-divider>
					</md-list-item>
				</md-list>
			</md-content>
		</md-tab>
	</md-tabs>
</div>