Viewing File: /home/cienp/public_html/portal/impr_anim_ceua.php

<?php

    if ($_POST[passa] == 'yes') {

    require "$this->include_dir/conecta.php";
    
    $s_id_resp = protecao($_POST[v_id_resp],'inteiro');
    $s_id_estd = protecao($_POST[v_id_estd],'inteiro');
    $s_dt_inic = protecao($_POST[v_dt_inic], 'data');
    $s_dt_finl = protecao($_POST[v_dt_finl], 'data');

    if ($s_id_resp != "")
        $selresp = "AND s.id_resp = '$s_id_resp'";

    if ($s_id_estd != "")
        $selestd = "AND e.id_estd = '$s_id_estd'";

    if (($s_dt_inic != '') && ($s_dt_finl != '')) {
        $d1 = explode('/', $s_dt_inic);
        $dt_inic = $d1[2] . "-" . $d1[1] . "-" . $d1[0];
        $d2 = explode('/', $s_dt_finl);
        $dt_finl = $d2[2] . "-" . $d2[1] . "-" . $d2[0];
        $seldata = "AND a.dt_utlz BETWEEN '$dt_inic' AND '$dt_finl'";
        $de_data = $s_dt_inic . ' até ' . $s_dt_finl;
    }

    $sql  = "SELECT s.id_solc, s.nu_ceua, a.id_anim, a.nu_mach, a.nu_fema, co.nm_colb, e.nu_estd, e.de_titl, h.nm_linh, h.fl_espc, ";
    $sql .= "DATE_FORMAT(s.dt_cads, '%d/%m/%Y') as dt_cad2 ";
    $sql .= "FROM ".$pref_tabl."anim_solc s, ".$pref_tabl."colb co, ".$pref_tabl."anim_estd e, ";
    $sql .= $pref_tabl."anim_anim a, ".$pref_tabl."anim_linh h ";
    $sql .= "WHERE a.id_solc = s.id_solc ";
    $sql .= "AND s.id_estd = e.id_estd ";
    $sql .= "AND s.id_resp = co.id_colb ";
    $sql .= "AND a.id_linh = h.id_linh ";
    $sql .= "AND s.id_sitc = 5 "; // Concluídos
    $sql .= "$selresp $selestd $seldata ";
    $sql .= "ORDER BY s.id_solc DESC ";
    $res  = mysqli_query($conn, $sql);
    // echo $sql.'<br>';
    if (mysqli_num_rows($res) > 0) {
?>
<div class="right_col" role="main">
    
    <div class="row">
        <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="x_panel">
                <div class="x_title">
                    <h2>Relatório CEUA <small>Gerenciador de Solicitação de Animais</small></h2>
                    <ul class="nav navbar-right panel_toolbox">
                        <li>
                            <button class="btn btn-default" onclick="window.print();"><i class="fa fa-print"></i> Imprimir</button>
                        </li>
                        <li>
                            <a href="javascript:voltar();" style="padding:0px;"><button class="btn btn-primary" type="button">Voltar</button></a>
                        </li>
                    </ul>
                    <div class="clearfix"></div>
                </div>
                <div class="x_content">
                    <div class="table-responsive">
                        <table class="table table-striped jambo_table bulk_action ">
                            <thead>
                                <tr class="headings">
                                    <th width="4%" class="column-title">N° SA</th>
                                    <th class="column-title">Estudo</th>
                                    <th class="column-title">CEUA</th>
                                    <th class="column-title">De Responsável</th>
                                    <th class="column-title">Roedor</th>
                                    <th class="column-title">Espécie</th>
                                    <th width="4%" class="text-center">Solicit M</th>
                                    <th width="4%" class="text-center">Solicit F</th>
                                    <th width="4%" class="text-center">Util/Recb M</th>
                                    <th width="4%" class="text-center">Util/Recb F</th>
                                    <th width="4%" class="text-center">Transf. M</th>
                                    <th width="4%" class="text-center">Transf. F</th>
                                </tr>
                            </thead>
                            <tbody>
<?php
                        while ($linha = mysqli_fetch_array($res)){
                            
                            switch ($linha[fl_espc]) {
                                case 'R':
                                    $fl_espc = 'Rato';
                                    break;
                                default:
                                    $fl_espc = 'Camundongo';
                                    break;
                            }
                            $nu_mach = $nu_fema = $nt_mach = $nt_fema = 0;

                            $sqlp  = "SELECT SUM(a.nu_mach) as nu_mach, SUM(a.nu_fema) as nu_fema ";
                            $sqlp .= "FROM ".$pref_tabl."anim_parc a ";
                            $sqlp .= "WHERE a.id_anim = '$linha[id_anim]' ";
                            $sqlp .= "AND fl_tipo IN ('U','R') "; // Utilizado e Recebido
                            #echo $sqlp.'<br>';
                            $resp  = mysqli_query($conn, $sqlp);
                            if (mysqli_num_rows($resp) > 0) {
                                $linhap = mysqli_fetch_array($resp);
                                $nu_mach = $linhap[nu_mach];
                                $nu_fema = $linhap[nu_fema];
                            }
                            $tu_mach = $tu_mach + $nu_mach;
                            $tu_fema = $tu_fema + $nu_fema;

                            $sqlt  = "SELECT SUM(a.nu_mach) as nu_mach, SUM(a.nu_fema) as nu_fema ";
                            $sqlt .= "FROM ".$pref_tabl."anim_parc a ";
                            $sqlt .= "WHERE a.id_anim = '$linha[id_anim]' ";
                            $sqlt .= "AND fl_tipo = 'T' "; // Transferido
                            #echo $sqlt.'<br>';
                            $rest  = mysqli_query($conn, $sqlt);
                            if (mysqli_num_rows($rest) > 0) {
                                $linhat = mysqli_fetch_array($rest);
                                $nt_mach = $linhat[nu_mach];
                                $nt_fema = $linhat[nu_fema];
                            }
                            $ts_mach = $ts_mach + $nt_mach;
                            $ts_fema = $ts_fema + $nt_fema;

                            $tt_mach = $tt_mach + $linha['nu_mach'];
                            $tt_fema = $tt_fema + $linha['nu_fema'];
?>
                                <tr>
                                    <td class="text-center">
                                        <?php echo $linha['id_solc'] ?>
                                    </td>
                                    <td>
                                        <?php echo $linha['nu_estd'] ?> - <?php echo $linha['de_titl'] ?>
                                    </td>
                                    <td>
                                        <?php echo $linha['nu_ceua']; ?>
                                    </td>
                                    <td>
                                        <?php echo $linha['nm_colb']; ?>
                                    </td>
                                    <td>
                                        <?php echo $linha['nm_linh']; ?>
                                    </td>
                                    <td>
                                        <?php echo $fl_espc; ?>
                                    </td>
                                    <td class="text-center"> 
                                        <?php echo $linha['nu_mach'] ?>
                                    </td>
                                    <td class="text-center"> 
                                        <?php echo $linha['nu_fema'] ?>
                                    </td>
                                    <td class="text-center"> 
                                        <?php echo $nu_mach;?>
                                    </td>
                                    <td class="text-center"> 
                                        <?php echo $nu_fema;?>
                                    </td>
                                    <td class="text-center"> 
                                        <?php echo $nt_mach;?>
                                    </td>
                                    <td class="text-center"> 
                                        <?php echo $nt_fema;?>
                                    </td>
                                </tr>
<?php
                        }
?>
                            </tbody>
                            <thead>
                                <tr class="headings">
                                    <th colspan="6">Total</th>
                                    <th class="text-center"><?php echo $tt_mach;?></th>
                                    <th class="text-center"><?php echo $tt_fema;?></th>
                                    <th class="text-center"><?php echo $tu_mach;?></th>
                                    <th class="text-center"><?php echo $tu_fema;?></th>
                                    <th class="text-center"><?php echo $ts_mach;?></th>
                                    <th class="text-center"><?php echo $ts_fema;?></th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php
    } else {
?>
    <div class="right_col" role="main">
        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                    <div class="x_title">
                        <h2>Relatório CEUA <small>Gerenciador de Solicitação de Animais</small></h2>
                        <div class="clearfix"></div>
                    </div>
                    <div class='alert alert-danger alert-dismissible fade in' role='alert' style='margin-top:30px;'>
                        <button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button>
                        <strong>Alerta!</strong> Nenhum animal com estas caracteristicas foi encontrado!
                    </div>
                    <div class="form-group">
                        <div class="col-md-6 col-sm-6 col-xs-12" style="padding:0px; margin-bottom:10px;">
                            <a href="javascript:voltar();"><button class="btn btn-primary" type="button">Voltar</button></a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php
    }
?>
    
</div>
        
<SCRIPT LANGUAGE="javascript">
    function voltar(){
        document.acidente.action = "index1.php?pg=relt_anim_ceua";
        document.acidente.submit();
    }
</script>
<form name="acidente" method="post" action="" style="margin:0px !important;">
  <input type="hidden" name="id_solc">
  <input type="hidden" name="v_id_resp" id="v_id_resp" value="<?=$_POST[v_id_resp]?>">
  <input type="hidden" name="v_id_estd" id="v_id_estd" value="<?=$_POST[v_id_estd]?>">
  <input type="hidden" name="v_dt_inic" id="v_dt_inic" value="<?=$_POST[v_dt_inic]?>">
  <input type="hidden" name="v_dt_finl" id="v_dt_finl" value="<?=$_POST[v_dt_finl]?>">
  <input type="hidden" name="passa" id="passa" value="yes">
</form>
<?php
} else 
	require "erro.php";
?>
Back to Directory File Manager