<?php
// Template Name: Cisamusep
get_header();
?>

	<?php include get_theme_file_path("/inc/popup.php"); ?>

	<main>

		<div class="intro-home">

			<a class="banner-sistemas banner-sistema-credenciamento" href="http://credenciamento2021.portyx.com.br/admin/" target="_new">
				<svg width="180" height="180" viewBox="0 0 180 180" fill="none" xmlns="http://www.w3.org/2000/svg">
					<rect width="180" height="180" rx="90" class="alterar-fill"/>
					<rect x="40" y="69" width="100" height="62" rx="10" fill="white"/>
					<circle cx="62" cy="92" r="9" class="alterar-fill"/>
					<path d="M47 108C47 102.477 51.4772 98 57 98H67C72.5228 98 77 102.477 77 108V114C77 115.657 75.6569 117 74 117H50C48.3431 117 47 115.657 47 114V108Z" class="alterar-fill"/>
					<rect x="89" y="84" width="36" height="6" rx="3" class="alterar-fill"/>
					<rect x="89" y="97" width="27" height="6" rx="3" class="alterar-fill"/>
					<rect x="89" y="110" width="32" height="6" rx="3" class="alterar-fill"/>
					<rect x="67" y="60" width="46" height="13" fill="white"/>
					<path d="M74.5 66C74.5 57.1634 81.6634 50 90.5 50V50C99.3366 50 106.5 57.1634 106.5 66V66H74.5V66Z" fill="white"/>
					<path d="M65 68.5V74H115V68.5" class="alterar-stroke" stroke-width="4"/>
				</svg>
				<div>
					<h2>Sistema de Credenciamento</h2>
					<p>Acesse e faça o seu credenciamento para o ano de 2021</p>
				</div>
			</a>


			<a class="banner-sistemas banner-sistema-agendamento" href="http://177.92.12.91:8080/IDSSaude/idssaude.dll" target="_new">
				<svg xmlns="http://www.w3.org/2000/svg" width="180" height="180" viewBox="0 0 180 180" fill="none">
					<rect width="180" height="180" rx="90" class="alterar-fill"/>
					<rect x="58" y="58" width="63" height="63" stroke="white" stroke-width="10"/>
					<path d="M78.5159 86.436L78.1776 86.7729L78.097 87.2425L75.617 101.708L75.2598 103.791L77.3517 103.435L91.8777 100.966L92.3493 100.885L92.6876 100.548L130.243 63.1505L131.306 62.0921L130.243 61.0336L118.197 49.038L117.134 47.9796L116.071 49.038L78.5159 86.436Z" fill="white" class="alterar-stroke" stroke-width="3"/>
					<path d="M119.69 50.4112C118.908 49.6318 118.908 48.3682 119.69 47.5888L123.942 43.355C126.681 40.6271 131.123 40.6271 133.862 43.355L135.988 45.4719C138.727 48.1998 138.727 52.6227 135.988 55.3506L131.736 59.5843C130.954 60.3637 129.685 60.3637 128.902 59.5843L119.69 50.4112Z" fill="white"/>
				</svg>
				<div>
					<h2>IDS Saúde</h2>
					<p>Para agendamento de pacientes e recepção de procedimentos, acesse o sistema de agendamento</p>
				</div>
			</a>

		</div>

		<section class="container" data-group="section-info">

			<ul class="tab-menu ">
					<li><a data-click="diario-oficial">Diário Oficial</a></li>
					<li><a data-click="licitacoes">Licitações</a></li>
					<li><a data-click="credenciamentos-vigente">Credenciamento</a></li>
			</ul>


			
			<div data-target="diario-oficial">
				<div class="secao-publicacoes">
					<?php
						$id_post = 1;

						$args = array(
							'post_type'			=> 'diario-oficial',
							'meta_key' 			=> 'data_diario',
							'orderby' 			=> 'meta_value',
							'paged' 			=> $paged,
							'posts_per_page' 	=> '3',
						);

						$the_query = new WP_Query( $args );
					?>

					<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
					<div id='publicacao<?php echo $id_post; ?>'>
						<div class="conteudo-publicacao pub-diario-legislacao">
							<a href="<?php the_field('arquivo_diario') ?>" target="_new">
								<h6 class="titulo-publicacoes"><?php the_field('nome_diario'); ?>
									<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none">
										<path d="M9 4H1V19H16V11" stroke-width="2" stroke-linecap="round"/>
										<path d="M9 11L19 1M19 1H11.8571M19 1V8.14286" stroke-width="2" stroke-linecap="round"/>
									</svg>
								</h6>								
							</a>
							<p><span>Ano:</span> <?php the_field('ano_diario'); ?></p>                
							<p><span>Data de Publicação:</span> <?php the_field('data_diario'); ?></p>
							<p><span>Descrição:</span> <?php the_field('descricao_diario'); ?></p>
						</div>

						<svg xmlns="http://www.w3.org/2000/svg" width="24" height="18" viewBox="0 0 24 18" fill="none" class="abrir-secao">
							<path d="M12 16L2 6L6 2L12 8L18 2L22 6L12 16Z" stroke-width="2"/>
						</svg>
					</div>
					<?php $id_post++; ?>
					<?php endwhile; else: endif; ?>
					<?php wp_reset_query(); wp_reset_postdata(); ?>
				</div>

				<div class="call">
					<p>Consulte outras edições</p>
					<a class="call-to-action" href="/diario-oficial">Diário Oficial</a>
				</div>
			</div>



			<div data-target="licitacoes">
				<div class="secao-publicacoes">
					<?php
						$id_post = 1;

						$data_atual = date('Ymd');
						$args = array(
							'post_type'			=> 'licitacao',
							'meta_query'		=> array(
								'relation'		=> 'AND',
								array(
									'key'     	=> 'data_abertura',
									'value'   	=> $data_atual,
									'compare' 	=> '>=',
								),
							),
							'meta_key' 			=> 'data_abertura',
							'orderby' 			=> 'meta_value',
							'order'				=> 'ASC',
							'paged' 			=> $paged,
							'posts_per_page' 	=> '3',
						);
						$the_query = new WP_Query( $args );

						if($the_query->found_posts==0) {
							$args = array(
								'post_type'			=> 'licitacao',
								'meta_query'		=> array(
									'relation'		=> 'AND',
									array(
										'key'     	=> 'data_abertura',
										'value'   	=> $data_atual,
										'compare' 	=> '<=',
									),
								),
								'meta_key' 			=> 'data_abertura',
								'orderby' 			=> 'meta_value',
								'order'				=> 'DESC',
								'paged' 			=> $paged,
								'posts_per_page' 	=> '3',
							);
						}
						$the_query = new WP_Query( $args );
					?>

					<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
					<?php $documento = get_field("documentos_processo1"); ?>
					<div id='publicacao<?php echo $id_post; ?>'>
						<div class="conteudo-publicacao conteudo-licitacao">
							<h6 class="titulo-publicacoes"><?php the_title(); ?></h6>
							<p><span>Situação:</span> <?php the_field('situacao_processo'); ?></p>
							<p><span>Número Processo:</span> <?php the_field('numero_processo'); ?>/<?php the_field('ano_processo'); ?></p>
							<p><span>Modalidade:</span> <?php the_field('modalidade_processo'); ?></p>
							<p><span>Data de Abertura:</span> <?php the_field('data_abertura'); ?></p>
							<p><span>Objeto:</span><?php the_field('objeto_processo'); ?></p>
							<div class="documentos-publicacao">
								<?php
									$i=1;
									while($i<40){
										$documento = 'documentos_processo'.$i;
										$doc_processo = get_field($documento);
										if($doc_processo['arquivo_processo'] != ""){
											
								?>
								<a href="<?php echo $doc_processo['arquivo_processo']; ?>" target="_new">
									<svg xmlns="http://www.w3.org/2000/svg" width="20" height="26" viewBox="0 0 20 26" fill="none">
										<path d="M19 25H1V1H15.2105L19 4.55556V25Z" stroke-linecap="round" stroke-linejoin="round"/>
										<path d="M14.5 1V5.5H19" stroke-linecap="square" stroke-linejoin="round"/>
										<path d="M4 19V21C4 21.5523 4.44772 22 5 22H15C15.5523 22 16 21.5523 16 21V19" stroke-linecap="round"/>
										<path d="M9.3415 19.1738L5.00147 15.3763C4.65402 15.0723 4.86904 14.5 5.33072 14.5H8.5V7.5C8.5 7.22386 8.72386 7 9 7H11C11.2761 7 11.5 7.22386 11.5 7.5V14.5H14.6693C15.131 14.5 15.346 15.0723 14.9985 15.3763L10.6585 19.1738C10.2815 19.5037 9.71852 19.5037 9.3415 19.1738Z"/>
									</svg>
									<p><?php echo $doc_processo['titulo_processo']; ?></p>
								</a>
								<?php
										}
										$i++;
									}
								?>
							</div>
						</div>
						<svg xmlns="http://www.w3.org/2000/svg" width="24" height="18" viewBox="0 0 24 18" fill="none" class="abrir-secao">
							<path d="M12 16L2 6L6 2L12 8L18 2L22 6L12 16Z" stroke-width="2"/>
						</svg>
						<?php $id_post++; ?>
					</div>
					<?php endwhile; else: endif; ?>
					<?php wp_reset_query(); wp_reset_postdata(); ?>
				</div>

				<div class="call">
					<p>Consulte todas as licitações</p>
					<a class="call-to-action" href="/licitacao">Licitações</a>
				</div>
			</div>

		
			<div data-target="credenciamentos-vigente" class="flex-8 credenciamentos-home">
				<div data-change="section-info" class="selected-info flex-6">
					<?php include get_theme_file_path("/inc/credenciamento-vigente.php"); ?>
				</div>
				<div class="call">
					<p>Consulte todos os credenciamentos</p>
					<a class="call-to-action" href="/credenciamento">Credenciamento</a>
				</div>
			</div>

		</section>


		<?php include get_theme_file_path("/inc/consorciados.php"); ?>

					
		<?php include get_theme_file_path("/inc/contato.php") ?>

		</section>
			
	</main>

<?php get_footer(); ?>