Location: PHPKode > projects > PMbyAS - Gestione Attivita > versione_4_1/pmbyas_4_1_script/PMbyAS-4-0/pvmtmba.php
<?php
/*******************************************************************************
 *  filename    : pvmtmba.php"
 *  last change : 2006 - 11 - 20
 *
 *  http://www.avesan.it/
 *  Copyright 2006 Alberto Santoro
 *
 *  PMbyAS is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 ******************************************************************************/
// --- Gestione a modulo --- //
$pgm="pvmtmba.php";

// --------------- connessione
require_once "./_fcom/fconn.php";
// --------------- sessione
require_once "./_fcom/fsess.php";
// --------------- dati di sessione
require_once "./_fcom/fperiodo.php";
// --------------- inclusione della testata HTML
require_once "./_fcom/doctype.php";
// ------------- inclusione barra navigazione
require_once "./_fcom/nav.php";

// --------------- eventuale segnalazione di errore in rientro
if (isset($_REQUEST['merr']))
   {$merr = "Errore:&nbsp;" .  "{$_REQUEST['merr']}"; } 
else $merr = " ";

// ---------------------- imposta programma di default
$ppm = $SEPGM;

// --------------- Intestazione  standard 
$tsfun="Previsione Tempi";
$tsdt2=" "; 
require_once "./_fcom/tstgen.php";

// ----------------- programma predefinito
$query = "SELECT * FROM prog WHERE PgmCod = \"$SEPGM\" ";
$qrc = mysqli_query($connessione,$query) or die("Query pgm fallita");
$rpm = mysqli_fetch_assoc($qrc);
$anno = $rpm['PgmAnno'];
$data = "20".$anno."0101";
// ------------------------ preparazione tabella valori
$query = "SELECT * FROM prev_202 WHERE PvPgm = \"$SEPGM\" and PvVtp = \"RU\" 
                   ORDER BY PvAtv, PvVde ";
$rstm = mysqli_query($connessione,$query) or die("Query fallita");
$vx = 0;
while ($rg = mysqli_fetch_assoc($rstm)){
       $vore[$vx] = $rg['PvOre'];
       $vatv[$vx] = $rg['PvAtv'];
//       $vsta[$vx] = $rg['PvRsu'];
//       $vsta[$vx] = $rg['PvCcs'];
       $vsta[$vx] = $rg['PvVde'];
       $vx = $vx +1;                }

// ------------------------ preparazione tabella tipo risorsa
$query = "SELECT * FROM pge_rsa WHERE RsaPk = \"RU\" ORDER BY RsaCod";
$qst = mysqli_query($connessione,$query) or die("Query std fallita");
$nst = mysqli_num_rows($qst);
$tx = 0;
while ($rst = mysqli_fetch_assoc($qst)){

       $sta[$tx] = $rst['RsaCod'];
       $std[$tx] = $rst['RsaDex'];        
       // ------ costo unitario attualizzato alla data inizio
       $query = "SELECT * FROM pge_rsa_val 
                 WHERE RsavPk = \"RU\" AND RsavCod = \"{$rst['RsaCod']}\" and RsaDay <= \"$data\" 
                 ORDER BY RsavCod, RsaDay DESC "; 
       $vlok = mysqli_query($connessione,$query) or die("Query val rsa fallita");
       $rv = mysqli_fetch_assoc($vlok);
       $stc[$tx] = $rv["RsaCshh"];       
       $tx = $tx + 1; }
      
// ------------------------ preparazione tabella attività
$clv = substr($_SESSION['TLV'],0,1);
$query = "SELECT * FROM tb_attv WHERE AtTpo = \"$clv\" ORDER BY AtCod";
$qat = mysqli_query($connessione,$query) or die("Query atv fallita");
$ax = 0;
while ($rat = mysqli_fetch_assoc($qat)) {
      if (substr($rat['AtCod'],1,2) == "91") continue;
      $acod[$ax] = $rat['AtCod'];
      $adex[$ax] = $rat['AtDex'];

  $ax = $ax + 1;}


// ============================================== preparazione tabella di registrazione
print "<br /><form action=\"pvmtmrg.php?com=N\" method=\"post\">";
// ===== testata
$len = $nst * 53 + 385;
print "\n<table class=\"tbover\" width=\"$len\" ><thead><tr>";
print "\n<th width=\"25\" class=\"t8d\">riga</th>";
print "\n<th width=\"280\" class=\"t8s\">Codice e descrizione attività</th>";

$xx = 0; // --- loop per tipo risorsa
while ($xx < $tx) {
       print "\n<th width=\"50\" class=\"ta7\" title=\"{$std[$xx]}\">{$sta[$xx]}</th>";
       $xx = $xx + 1;} 

print "\n<th width=\"60\" class=\"t8d\">totale</th></tr></thead>";

// ===== piede
print "\n<tfoot></tfoot>";

// ===== corpo
print "\n<tbody>";

$xx = 0; // --- loop per attività 
$tval[0] = 0; 
while ($xx < $ax){
   $rg = $xx +1;
   print "\n<tr><td class=\"c8d\">$rg</td>";
   print "\n<td class=\"c8s\">{$acod[$xx]}&nbsp;&middot;&nbsp;{$adex[$xx]}";

   $yy = 0; // --- loop per tipo risorsa
   $trg = 0;
   while ($yy < $nst) { 
      $zz = 0; // --- loop per tabella valori effettivi
      $val = 0;  
      while ($zz < $vx) {
         if (($vatv[$zz] ==  $acod[$xx]) and ($vsta[$zz] == $sta[$yy])) $val = $vore[$zz];
         $zz = $zz +1;}
      $val = (int)$val;
      if ($val == 0) $ed = ""; else $ed = $val;
//      $name = $acod[$xx].$sta[$yy];  // codice attività + codice risorsa
      $name = $acod[$xx]."-".$sta[$yy];  // codice attività + codice risorsa      
      print "\n<td class=\"c7s\">
            <input type=\"text\" name=\"$name\" size=\"6\" maxlenght=\"5\" value=\"$ed\" /></td>"; 

      $trg = $trg + $val;
      $tval[$yy] = $tval[$yy] + $val;
      $yy = $yy + 1;}

   if ($trg > 0) $ed = number_format($trg, 0, ',', '.'); else $ed = "  ";
   print "\n<td class=\"c8dg\">$ed</td>";
   print "\n</tr>";   
   $xx = $xx + 1;}
// ----- totali ore
print "\n<tr><td class=\"c8d\" colspan =\"2\">totale ore</td>";
$xx = 0; $tvt = 0;
while ($xx < $nst){
    if ($tval[$xx] > 0) $ed = number_format($tval[$xx], 0, ',', '.'); else $ed = "  ";
    print "\n<td class=\"c8dg\">$ed</td> ";
    $tvt = $tvt + $tval[$xx];
    $xx = $xx + 1;}  

if ($tvt > 0) $ed = number_format($tvt, 0, ',', '.'); else $ed = "  ";
print "\n<td class=\"c8dg\">$ed</td>";
//print "\n<td class=\"c8d\"><input class=\"sub\" type=\"submit\" name=\"sub\" value=\"registra\" /></td></tr>";
// ----- totali costo
print "\n<tr><td class=\"c8d\" colspan =\"2\">totale costo</td>";
$xx = 0; $tcs = 0;
while ($xx < $nst){
    $costo = $tval[$xx] * $stc[$xx];
    if ($costo > 0) $ed = number_format($costo, 0, ',', '.');   else $ed = "  ";
    print "\n<td class=\"c8dg\">$ed</td> ";
    $tcs = $tcs + $costo;
    $xx = $xx + 1;}  

if ($tcs > 0) $ed = number_format($tcs, 0, ',', '.');  else $ed = "  ";
print "\n<td class=\"c8dg\">$ed</td></tr>";

$span = $nst +2;
print "\n<tr><td colspan=\"$span\">&nbsp;</td>";
print "\n<td class=\"c8d\"><input class=\"sub\" type=\"submit\" name=\"sub\" value=\"registra\" /></td></tr>";


print "\n</table></form>";


?>
</div></body></html>
Return current item: PMbyAS - Gestione Attivita