• File: inicio.php
  • Full Path: /home/u820075591/domains/livrariafabris.com.br/public_html/admin/modulos/inicio.php
  • Date Modified: 07/18/2023 5:23 AM
  • File size: 26.4 KB
  • MIME-type: text/html
  • Charset: utf-8
<section class="content">
      <!-- Info boxes -->
<?
//FINALIZA ATENDIMENTO
if ($_REQUEST[sub] == "FINALIZAR"){
$rs=$obj->query("UPDATE agenda
				SET 
				status = 'FINALIZADO'
				WHERE id=".$_REQUEST[id]);

echo "<div class=\"alert alert-success\">
		AGENDAMENTO Finalizado com <strong>sucesso</strong>.
	  </div>
	  <br>";	
}

//FINALIZA ATENDIMENTO
?>      
      
      		<div class="row">
                
        
                <!-- fix for small devices only -->
                <div class="clearfix visible-sm-block"></div>
        
                <div class="col-md-6 col-sm-6 col-xs-12">
                  <div class="info-box">
                    <span class="info-box-icon bg-green"><i class="fa fa-user"></i></span>
        
                    <div class="info-box-content">
                      <span class="info-box-text">Minha Permissão</span>
                      <span class="info-box-number">                      	
                        	<?= $_SESSION[permissao]?><br />
                        	<small  style="font-weight:normal">
                            	<a href="?secao=meus-dados&raiz=1" title="Editar meus dados">Editar dados</a> | 
                                <a href="?secao=alterar-senha&raiz=1" title="Alterar minha senha">Senha</a></small>                        
                      </span>
                    </div>
                    <!-- /.info-box-content -->
                  </div>
                  <!-- /.info-box -->
                </div>
                <!-- /.col -->
                <div class="col-md-6 col-sm-6 col-xs-12">
                  <div class="info-box">
                    <span class="info-box-icon bg-yellow"><i class="fa fa-sign-in"></i></span>
        
                    <div class="info-box-content">
                      <span class="info-box-text">Meu acesso</span>
                      <span class="info-box-number">
                      <?
                      		$comando = "SELECT datacadastro 
												FROM acessos
												WHERE id_usuario = ".$_SESSION[id]." AND secao = 'LOGIN'
												ORDER BY id DESC
												LIMIT 1
												";	//comando SQL
							$exec = mysql_query($comando);	//executa o comando no banco
							$linha = mysql_fetch_assoc($exec);
							
							echo date('d/m/Y', strtotime($linha[datacadastro]));
							echo "<small style='font-weight:normal'><br />às ".date('H:i', strtotime($linha[datacadastro]))."</small>";
					  ?>
                      </span>
                    </div>
                    <!-- /.info-box-content -->
                  </div>
                  <!-- /.info-box -->
                </div>
                <!-- /.col -->
              </div>
      	  <!-- /.box -->
          
         
         
          <!-- ANIVERSARIANTES -->        
          <?
			 $verificador = date( "Y-m-d", strtotime( "+5 days" ) );
			 $data_atual = date("Y-m-d");
			 $rs = $obj->query("SELECT * FROM cliente WHERE ((DAYOFYEAR(datanasc) >= DAYOFYEAR('$data_atual') AND DAYOFYEAR(datanasc) <= DAYOFYEAR('$verificador')) AND datanasc <> '0000-00-00') ORDER BY nome");
			 $total1 = mysql_num_rows($rs);

		  ?>
              <div class="box box-widget widget-user">
                <!-- Add the bg color to the header using any of the bg-* classes 
                <div class="widget-user-header bg-aqua-active" style="height:auto">
                
                  <h3 class="widget-user-username"><span class="fa fa-gift"></span> &nbsp;Clientes Aniversariantes dos próximos 5 dias (até <?=data_para_mostrar($verificador)?>)</h3>
                </div>
                <div class="box-footer" style="margin-top:0px">
                  <div class="row">
                    <div class="col-md-12">
                      <div class="description-block">
                            
                            
                            <?
                                
                                $rs = $obj->query("SELECT * FROM cliente WHERE ((DAYOFYEAR(datanasc) >= DAYOFYEAR('$data_atual') AND DAYOFYEAR(datanasc) <= DAYOFYEAR('$verificador')) AND datanasc <> '0000-00-00') ORDER BY nome");
                                $total = mysql_num_rows($rs);
                                
                                if($total == 0){
                                    echo "<h3>Nenhum cliente aniversariante até ".data_para_mostrar($verificador).".</h3>";
                                }else{
                                ?>
                                    <div style="text-align:left">
                                    <table class="table table-bordered">
                                    <tbody><tr>
                                      <th>Aniversário</th>
                                      <th>Nome</th>
                                      <th>E-mail</th>
                                      <th>Telefones</th>
                                    </tr>
                                <?
                                    for($x = 0; $x < $total; $x++){ 
                                ?>
                                        <tr>
                                          <td>
                                          	 <? if((mysql_result($rs, $x, 'telefone1') <> "") && (mysql_result($rs, $x, 'telefone1') <> "(00)000000000")) { $telefone = str_replace('(', '', mysql_result($rs, $x, 'telefone1')); $telefone = str_replace(')', '', $telefone); $telefone = str_replace(' ', '', $telefone); $telefone = trim($telefone);}?> 
                                          	<a href="https://api.whatsapp.com/send?phone=55<?= $telefone?>" class="btn btn-xs <?= $aniver_btn?>" title="<?= $aniver_title?>" target="_blank"><span class="fa fa-birthday-cake"></span></a>
										  	<?= date( "d/m", strtotime(mysql_result($rs, $x, 'datanasc')) );?>
                                          </td>
                                          <td><?= mysql_result($rs, $x, 'nome')?> </td>
                                          <td><?= mysql_result($rs, $x, 'email')?></td>
                                          <td>
                                            <? if((mysql_result($rs, $x, 'telefone1') <> "") && (mysql_result($rs, $x, 'telefone1') <> "(00)000000000"))echo mysql_result($rs, $x, 'telefone1'); ?>
                                            <? if( ((mysql_result($rs, $x, 'telefone2') <> "") && (mysql_result($rs, $x, 'telefone2') <> "(00)000000000")) && ((mysql_result($rs, $x, 'telefone2') <> "") && (mysql_result($rs, $x, 'fone_cel') <> "(00)000000000")) )echo " / "; ?>
                                          </td>
                                        </tr>
                                <?
                                    }
                                ?>
                                    </tbody></table>
                                    </div>
                                <?
                                }
                            ?>
 
                      </div>
                      <!-- /.description-block 
                    </div>
                    
                    
                  </div>
                  <!-- /.row 
                </div> -->
              </div>

          <!-- ANIVERSARIANTES -->
          
          <div class="row">
      
          <!-- CONSULTAS -->

          <? $data_monta = date('d/m/Y');

			//********** BUSCA **********
			$comando = "SELECT * FROM agenda WHERE data='".data_para_salvar($data_monta)."' ORDER BY hora";
			$exec = mysql_query($comando);
			
			function horaParaMinutos($hora,$inicial){
				 $partes = explode(":", $hora);
				 $minutos = $partes[0]*60+$partes[1];
				 
				 $minutos= date('H:i:s', strtotime('+'.$minutos.' minute', strtotime($inicial)));
				 return ($minutos);
			}
		  ?>
                  <div class="col-md-12">
                    
                    <div class="box box-info">
                    <div class="box-header with-border">
                    <i class="fa fa-file-text-o"></i>
                    <?
                	$titulo = "AGENDA DO DIA ".date('d/m/Y');
				?>
                <h3 class="box-title"><strong><?= $titulo?></strong></h3>
                  <div class="box-tools pull-right">                    
                    
                     <button type="button" class="btn btn-box-tool  bg-aqua" data-widget="collapse" data-toggle="tooltip" title="" data-original-title="Abre/Fecha">
	              <i class="fa fa-plus"></i></button>
                  </div>
                </div>
                    <div class="box-body" style="display:inline">
                      <div class="table-responsive">
                        <table class="table no-margin">
                          <thead>
                          <tr>
                          <th style="width: 10px; font-size:11px;">Inicio</th>
                          <th style="width: 10px; font-size:11px;">Término</th>
                          <th style="width: 15px; font-size:11px;">Status</th>
                          <th style="width: 15%; font-size:11px;">Tipo</th>
                          <th style="width: 30%; font-size:11px;">Descrição</th>
                          <th style="width: 13%"></th>
                          </tr>
                          </thead> 
                          <tbody>
                          
                        <?  while ($linha = mysql_fetch_assoc($exec)) { ?>
                            <tr>
                              <td style="font-size:11px;"><?= date("H:i", strtotime($linha[hora]))?></td>
                      <td style="font-size:11px;"><?= date("H:i", strtotime(horaParaMinutos($linha[duracao],$linha[hora])))?></td>
                              <td style="font-size:11px;"><?= $linha[status]?></td>
                              <td style="font-size:11px;"><?= $linha[tipo]?></td>
                              <td style="font-size:11px;"><?= $linha[descricao]?></td>
                              <td style="font-size:11px;" align="right">
                              <? if($linha[status] <> 'FINALIZADO') { ?>
                                <a href="index2.php?secao=inicio&sub=FINALIZAR&TOPO=D&id=<?=$linha[id]?>" title="Finalizar Agendamento" class="btn btn-success btn-xs">
                                <span class="glyphicon glyphicon-ok"></span>
                                </a> 
                                &nbsp;
                              <? } ?>
                                <a href="index2.php?secao=agenda&id=<?=$linha[id]?>&TOPO=D&DATA_TOPO=<?=$data_monta?>&editar_agenda=sim" class="btn btn-default btn-xs" title="Editar/Atualizar">
                                <span class="glyphicon glyphicon-refresh"></span>
                                </a>                   &nbsp;         
                                <a href="index2.php?secao=<?= $var_pagina?>&sub=excluir&TOPO=D&id=<?=$linha[id]?>&DATA_TOPO=<?=$data_monta?>" class="btn btn-danger btn-xs" title="Excluir">
                                    <span class="glyphicon glyphicon-remove"></span>										
                                </a>
                              </td>
                            </tr>
                          <?
                        }
                    ?>
                          </tbody>
                        </table>
                      </div>
                    </div>           
                  </div>

		  <!-- CONSULTAS -->
          <div class="row">
           <!-- PEDIDOS -->
          <?
			$rs = $obj->query("SELECT * FROM pedidos WHERE status = 1 AND situacao not in ('ENTREGUE/FINALIZADO','PAGAMENTO DEVOLVIDO/PEDIDO CANCELADO','CANCELADO','TRANSFERÊNCIA/DEPÒSITO NÃO REALIZADO NO PRAZO') ORDER BY data desc");
			$total = mysql_num_rows($rs);
		  ?>

              <div class="col-md-12">
                
                <div class="box box-success">
                <div class="box-header with-border">
                <i class="fa  fa-list "></i>
                <? $titulo = "PEDIDOS"; ?>
                <h3 class="box-title"><strong><?= $titulo?></strong></h3>
                  <div class="box-tools pull-right">
                    <small><b><?=$total?> Pedidos em andamento</b> </small>
                    <button type="button" class="btn btn-box-tool  bg-aqua" data-widget="collapse" data-toggle="tooltip" title="" data-original-title="Abre/Fecha">
	              <i class="fa fa-plus"></i></button>
                  </div>
                </div>         
                <div class="box-body">
                  <div class="table-responsive">
                    <table class="table no-margin">
                      <thead>
                      <tr>
                        <th style="width: 20px">ID</th>
                          <th style="width: 15%">Data</th>
                          <th style="width: 35%">Cliente</th>
                          <th style="width: 10%">Valor</th>
                          <th style="width: 10%">Forma Pag</th>
                          <th style="width: 30%">Situação</th>
                          <th style="width:100px"></th>
                      </tr>
                      </thead>
                      <tbody>
                      
                    <?
                    for($x = 0; $x < $total; $x++)
                    { ?>
                        <tr class="
                    	<? 
							if(mysql_result($rs, $x, 'situacao') == "ENTREGUE/FINALIZADO"){
								echo " success ";
							}
							if(mysql_result($rs, $x, 'situacao') == "PAGAMENTO CONFIRMADO"){
								echo " info ";
							}
							if(mysql_result($rs, $x, 'situacao') == "AGUARDANDO PAGAMENTO" or (mysql_result($rs, $x, 'situacao')) == "AGUARDANDO CONFIRMAÇÃO DE PAGAMENTO" or mysql_result($rs, $x, 'situacao') == "AGUARDANDO PAGAMENTO DO BOLETO"){
								echo " warning ";
							}
							if(mysql_result($rs, $x, 'situacao') == "ENVIADO" or (mysql_result($rs, $x, 'situacao') == "MERCADORIA REENVIADA")){
								echo " success ";
							}
							if((mysql_result($rs, $x, 'situacao') == "CANCELADO") or (mysql_result($rs, $x, 'situacao') == "PAGAMENTO DEVOLVIDO/PEDIDO CANCELADO")){ 
								echo " danger ";
							}
						?>
                        "
                    >
                      <td style="font-size:12px"><?= mysql_result($rs, $x, 'idPedido')?></td>
                      <td style="font-size:12px"><?= date("d/m/Y H:i:s", strtotime(mysql_result($rs, $x, 'data')))?></td>
                      <td style="font-size:14px"><? $rs_for = $obj->query("SELECT nome FROM cliente WHERE id='".mysql_result($rs, $x, 'idCliente')."'");	
					  		 $total_for = mysql_num_rows($rs_for);
							 if($total_for > 0){ echo (mysql_result($rs_for, '0', 'nome'));}
					  ?></td>
                      <td style="font-size:14px">R$ <?= number_format(mysql_result($rs, $x, 'valor_total'), 2, ',', '.')?></td>
                      <?
					 $FORMA='';
                     if(mysql_result($rs, $x, 'forma_pagamento') == 1) { $FORMA = 'TRANSFERÊNCIA BANCÁRIA';}
                     if(mysql_result($rs, $x, 'forma_pagamento') == 4) { $FORMA = 'PIX';}
                     if(mysql_result($rs, $x, 'forma_pagamento') == 3) { $FORMA = 'PAGSEGURO';}
                     ?>
                     <td  style="font-size:12px"><?= ($FORMA)?></td>
                      <td style="font-size:12px"><?= (mysql_result($rs, $x, 'situacao'))?></td>
                      <td>
                            <a href="index2.php?secao=pedidos-editar&idPedido=<?=mysql_result($rs, $x, 'idPedido')?>" class="btn btn-default btn-xs" title="Editar/Atualizar">
							<span class="glyphicon glyphicon-refresh"></span>
                            </a>                            
                      </td>
                      </tr>
                      <? } ?>
                      </tbody>
                    </table>
                  </div>
                </div>           
              </div>
              </div>

		  <!-- PEDIDOS -->
          
          
          
         </div>
         
           
          
          
           <div class="row">
           <!-- CONTAS A PAGAR -->
          <?
 			$verificador = date( "Y-m-d", strtotime( "+7 day ") );						
			$rs = $obj->query("SELECT * FROM contas_pagar WHERE (data_vencimento <= '$verificador' and data_vencimento <> '000-00-00') AND status=1 AND situacao='EM ABERTO' ORDER BY data_vencimento");
			
			$total = mysql_num_rows($rs);
		  ?>
          <? if($total > 0){ ?>
              <div class="col-md-12">
                
                <div class="box box-warning">
                <div class="box-header with-border">
                <i class="fa  fa-dollar"></i>
                <? $titulo = "CONTAS A PAGAR"; ?>
                <h3 class="box-title"><strong><?= $titulo?></strong></h3>
                  <div class="box-tools pull-right">
                    <small><b><?=$total ?> Conta à vencer/vencida em 7 dias </b></small>
                    <button type="button" class="btn btn-box-tool  bg-aqua" data-widget="collapse" data-toggle="tooltip" title="" data-original-title="Abre/Fecha">
	              <i class="fa fa-plus"></i></button>
                  </div>
                </div>         
                <div class="box-body"   style="display: none;">
                  <div class="table-responsive">
                    <table class="table no-margin">
                      <thead>
                      <tr>
                        <th>Fornecedor</th>
                        <th>Situação</th>
                        <th>Valor</th>
                        <th>Vencimento</th>
                      </tr>
                      </thead>
                      <tbody>
                      
                    <?
                    for($x = 0; $x < $total; $x++)
                    { ?>
                        <tr>
                        <td>
                        	<a href="?secao=contas_pagar-editar&idConta=<? echo mysql_result($rs, $x, 'id');?>">
								<? $rs_for = $obj->query("SELECT Razao_social FROM Fornecedores WHERE idFornecedor='".mysql_result($rs, $x, 'id_fornecedor')."'");	
										 $total_for = mysql_num_rows($rs_for);
										 if($total_for > 0){ echo (mysql_result($rs_for, '0', 'Razao_social'));}
								  ?>
                            </a>
                        </td>
                        <td><? echo mysql_result($rs, $x, 'situacao');?> </td>
                        <td>R$ <? echo number_format(mysql_result($rs, $x, 'valor'), 2, ',', '.');?> </td>
                        <td><span class="label <? if(mysql_result($rs, $x, 'data_vencimento') <= date('Y-m-d')) {echo "label-danger";} else {echo "label-warning";}?>"><? echo data_para_mostrar(mysql_result($rs, $x, 'data_vencimento'));?></span></td>
                      </tr>
                      <? } ?>
                      </tbody>
                    </table>
                  </div>
                </div>           
              </div>
              </div>
          <? } ?>
		  <!-- CONTAS A PAGAR -->
          </div>
          
          <div class="row">
           <!-- LIVROS -->
          <?
			$rs = $obj->query("SELECT * FROM livros LEFT JOIN editoras ON livros.idEditora = editoras.idEditora WHERE livros.status = 1 and estoque=0 ORDER BY nome");
			$total = mysql_num_rows($rs);
		  ?>
          <? if($total > 0){ ?>
              <div class="col-md-12">
                
                <div class="box box-danger">
                <div class="box-header with-border">
                <i class="fa  fa-book "></i>
                <? $titulo = "LIVROS COM ESTOQUE ZERADO"; ?>
                <h3 class="box-title"><strong><?= $titulo?></strong></h3>
                  <div class="box-tools pull-right">
                    <small><b><?=$total?> Livros com estoque zerado </b></small>
                    <button type="button" class="btn btn-box-tool  bg-aqua" data-widget="collapse" data-toggle="tooltip" title="" data-original-title="Abre/Fecha">
	              <i class="fa fa-plus"></i></button>
                  </div>
                </div>         
                <div class="box-body"  style="display: block;">
                  <div class="table-responsive">
                    <table class="table no-margin">
                      <thead>
                      <tr>
                        <th style="width: 10px">ID</th>
                          <th style="width: 5%">ISBN</th>
                          <th style="width: 30%">TÍTULO</th>
                          <th>VALOR</th>
                          <th>VALOR PROMO</th>
                          <th>EDITORA</th>
                          <th style="width:100px">Ação</th>
                      </tr>
                      </thead>
                      <tbody>
                      
                    <?
                    for($x = 0; $x < $total; $x++)
                    { ?>
                        <tr>
                      
                       	  <td style="font-size:11px"><?= mysql_result($rs, $x, 'idLivro')?></td>
                          <td style="font-size:11px"><?= (mysql_result($rs, $x, 'ISBN')) ?></td>
                          <td><?= (mysql_result($rs, $x, 'nome')) ?></td>
                          <td><? echo "R$".number_format(mysql_result($rs, $x, 'valor'), 2, '.', ','); ?></td>
                          <td><? if(mysql_result($rs, $x, 'valorPromocional')) { echo "R$".number_format(mysql_result($rs, $x, 'valorPromocional'), 2, '.', ',');} else {echo "-";} ?></td>
                          <td style="font-size:11px"><?= (mysql_result($rs, $x, 'Razao_social')) ?></td>
                          <td>
                                <a href="index2.php?secao=livros-editar&idLivro=<?=mysql_result($rs, $x, 'idLivro')?>" class="btn btn-default btn-xs" title="Editar/Atualizar">
                                <span class="glyphicon glyphicon-refresh"></span>
                                </a>                            
                          </td>
                      </tr>
                      <? } ?>
                      </tbody>
                    </table>
                  </div>
                </div>           
              </div>
              </div>
          <? } ?>
		  <!-- LIVROS -->
          
          </div>
          
           <!-- ANIVERSARIANTES -->        
          <?
			 $verificador = date( "Y-m-d", strtotime( "+2 days" ) );
			 $verificador2 = date( "Y-m-d", strtotime( "+3 days" ) );
			 $data_atual = date("Y-m-d");
			 $rs = $obj->query("SELECT Day(datanasc) as teste, cliente.* FROM cliente WHERE ((DAYOFYEAR(datanasc) >= DAYOFYEAR('$data_atual') AND DAYOFYEAR(datanasc) <= DAYOFYEAR('$verificador')) AND datanasc <> '0000-00-00') ORDER BY teste,nome");
			 $total1 = mysql_num_rows($rs);

		  ?>
              <div class="box box-widget widget-user">
                <!-- Add the bg color to the header using any of the bg-* classes -->
                <div class="widget-user-header bg-aqua-active" style="height:auto">
                
                  <h3 class="widget-user-username"><span class="fa fa-gift"></span> &nbsp;Clientes Aniversariantes nos próximos 3 dias (até <?=data_para_mostrar($verificador2)?>)</h3>
                </div>
                <div class="box-footer" style="margin-top:0px">
                  <div class="row">
                    <div class="col-md-12">
                      <div class="description-block">
                            
                            
                            <?
                                
                                $rs = $obj->query("SELECT Day(datanasc) as teste, cliente.* FROM cliente WHERE ((DAYOFYEAR(datanasc) >= DAYOFYEAR('$data_atual') AND DAYOFYEAR(datanasc) <= DAYOFYEAR('$verificador')) AND datanasc <> '0000-00-00') ORDER BY teste,nome");
                                $total = mysql_num_rows($rs);
                                
                                if($total == 0){
                                    echo "<h3>Nenhum cliente aniversariante até ".data_para_mostrar($verificador).".</h3>";
                                }else{
                                ?>
                                    <div style="text-align:left">
                                    <table class="table table-bordered">
                                    <tbody><tr>
                                      <th>Aniversário</th>
                                      <th>Nome</th>
                                      <th>E-mail</th>
                                      <th>Telefones</th>
                                    </tr>
                                <?
                                    for($x = 0; $x < $total; $x++){ 
                                ?>
                                        <tr>
                                          <td>
                                          	 <? if((mysql_result($rs, $x, 'telefone1') <> "") && (mysql_result($rs, $x, 'telefone1') <> "(00)000000000")) { $telefone = str_replace('(', '', mysql_result($rs, $x, 'telefone1')); $telefone = str_replace(')', '', $telefone); $telefone = str_replace(' ', '', $telefone); $telefone = trim($telefone);}?> 
                                          <span class="fa fa-birthday-cake"></span>
										  	<?= date( "d/m", strtotime(mysql_result($rs, $x, 'datanasc')) );?>
                                          </td>
                                          <td><?= (mysql_result($rs, $x, 'nome'))?> </td>
                                          <td><?= mysql_result($rs, $x, 'email')?></td>
                                          <td>
                                            <? if((mysql_result($rs, $x, 'telefone1') <> "") && (mysql_result($rs, $x, 'telefone1') <> "(00)000000000"))echo mysql_result($rs, $x, 'telefone1'); ?>
                                            <? if( ((mysql_result($rs, $x, 'telefone2') <> "") && (mysql_result($rs, $x, 'telefone2') <> "(00)000000000")) && ((mysql_result($rs, $x, 'telefone2') <> "") && (mysql_result($rs, $x, 'telefone2') <> "(00)000000000")) ) echo " / ".(mysql_result($rs, $x, 'telefone2')); ?>
                                          </td>
                                        </tr>
                                <?
                                    }
                                ?>
                                    </tbody></table>
                                    </div>
                                <?
                                }
                            ?>
 
                      </div>
                      <!-- /.description-block -->
                    </div>
                    
                    
                  </div>
                  <!-- /.row -->
                </div> 
              </div>

          <!-- ANIVERSARIANTES -->
         
         
         
        
         
          

          
          </section>

    </section>