Location: PHPKode > projects > PMbyAS - Gestione Attivita > versione_4_1/pmbyas_4_1_script/PMbyAS-4-0/trstorg.php
<?php
/*******************************************************************************
 *  filename    : trstorg.php
 *  last change : 2006 - 08 - 08
 *
 *  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.
 ******************************************************************************/
$pgm="trstorg.php";
// --------------- connessione
require_once "./_fcom/fconn.php";
// --------------- sessione
require_once "./_fcom/fsess.php";
// --------------- dati di sessione
require_once "./_fcom/fperiodo.php";
// inclusione $urip = prefisso URI per header(location
require_once "./_fcom/pref_uri.php";

$oldnum = $_REQUEST['num'];
$rga = $_REQUEST['rga'];

// --------------- data registrazione
$oggi = date("Y.m.d");


// --- parametri di sistema
$query = "SELECT * FROM sys_parm WHERE SyCod = \"PMbyAS\"";
$qsy = mysqli_query($connessione,$query) or die("Query sys fallita");  
$rsy = mysqli_fetch_assoc($qsy);
$opt_ver = ($rsy["SySw02"]);



// ----------------------------------- LOK
$query = "LOCK TABLES time_report WRITE, proto_tempi WRITE, age_pgm WRITE, tempi WRITE, vrf_tmrep WRITE";
$rslk = mysqli_query($connessione,$query) or die("Query  lock tm fallita");  
// --------------- Lettura time report da stornare
$query = "SELECT * FROM time_report WHERE GtmNum = \"$oldnum\" ";
$rold = mysqli_query($connessione,$query) or die("Query tm fallita");
while ($rg = mysqli_fetch_assoc($rold))
 {

 
// ---------------- eliminazione record in agenda
$query = "DELETE FROM age_pgm
          WHERE  AgDay = \"{$rg["GtmDay"]}\" and
                 AgPgm = \"{$rg["GtmPgm"]}\" and
                 AgPfa = \"{$rg["GtmFase"]}\" and                 
                 AgAtv = \"{$rg["GtmAtv"]}\" and
                 AgVtp = \"RU\"               and
                 AgRsu= \"{$rg["GtmRsu"]}\" ";
$upd = mysqli_query($connessione,$query) or die("Query upd age fallita"); 
// ---------------- aggiornamento record in Time Report 
$query = "UPDATE time_report
            SET  GtmStato= \"A\",
                 GtmStDay= \"$oggi\"
          WHERE  GtmNum= \"$oldnum\" and
                 GtmRiga= \"{$rg["GtmRiga"]}\"#    ";
$ins = mysqli_query($connessione,$query) or die("Query ins tm fallita");
// ---------------- eliminazione record in  Verifica Time Report 
if ($opt_ver == "V") {
$query = "delete FROM vrf_tmrep
          WHERE  VrGtmNum= \"$oldnum\" and
                 VrGtmRiga= \"{$rg["GtmRiga"]}\"#    ";
$ins = mysqli_query($connessione,$query) or die("Query del vrf_tm fallita");
}
// ----------------- aggiornamento record tempi
$query = "UPDATE tempi
             SET TmStato = \" \",
                 TmNReg= \"0\",
                 TmNRga= \"0\"   
             WHERE TmRsu  = \"{$rg["GtmRsu"]}\"
             and TmDay   = \"{$rg["GtmDay"]}\"
             and TmPgm = \"{$rg["GtmPgm"]}\" 
             and TmFase = \"{$rg["GtmFase"]}\"
             and TmAtv = \"{$rg["GtmAtv"]}\"  ";      
$upd = mysqli_query($connessione,$query) or die("Query upd fallita");
 }
// ----------------- aggiornamento protocollo
$query = "UPDATE proto_tempi
             SET PtrStato = \"A\",
                 PtrStDay = \"$oggi\"
          WHERE  PtrNum = \"$oldnum\"#";
$iptr = mysqli_query($connessione,$query) or die("Query ins proto fallita");
$query = "UNLOCK TABLES#";
$rsulk = mysqli_query($connessione,$query) or die("Query unlock az fallita");  
$urif = "trsto.php?tp=$tp"; // -------- rientro
header ("location:$urip$urif" ); exit;

$urif = "trsto.php?tp=$tp"; // -------- rientro
header ("location:$urip$urif" ); 

?>
Return current item: PMbyAS - Gestione Attivita