← Back
Editing: ins_presenze.php
<?php require_once ("../funct.php"); require_once ("sess.php"); require_once ("conn.php"); require_once ("class.php"); $table = "presenze"; $ajCal = "y"; require_once ("../lan_it.php"); require_once ("testacoda.php"); $query = new doQuery (); $data = $_REQUEST['data']; $fp = fopen ("questura.lst", "r"); $fw = fopen ("questura.sql", "w"); $arCaratteri = array (2, 10, 50, 30, 1, 10, 9, 2, 9, 9, 9, 2, 9, 50, 5, 20, 9); $sql = "SELECT `id`, `cod_ps` FROM `comuni` WHERE 1"; $rows = $query->freeQuery ($sql, 0); foreach ($rows as $row) $arComuni[$row->cod_ps] = $row->id; echo $testa0; # se non scelgo la data vedo che date ci sono if ($data == "") { $arData = array (''); while (!feof ($fp)) { $buf = fgets ($fp, 256); $buf = trim ($buf, "\r\n \t"); # toglie spazi e tab dall'inizio e fine della stringa $shift = 0; $i = 0; $citta = ""; $tipo_all = trim (substr ($buf, $shift, $arCaratteri[$i]), ' '); $tipo = $tipo_all < 19 ? 1 : 3; $shift+= $arCaratteri[$i]; $i++; $dataIn = data2date (trim (substr ($buf, $shift, $arCaratteri[$i]), ' ')); if (!array_search ($dataIn, $arData)) $arData[] = $dataIn; } echo "<h3>Scegli la data che vuoi completare con le presenze</h3>\n"; foreach ($arData as $dt) echo "<a href=\"".$_SERVER['PHP_SELF']."?data=".$dt."\">".$dt."</a><br />\n"; } else if ($az == "ins") { eco($_POST); foreach ($_POST['data_out'] as $idP=>$v) { $sql = "SELECT `id_contratto` FROM `presenze` WHERE `id_persona` = $idP"; $row = $query->freeQuery ($sql, 0); if ($row[0]->id_contratto) { $tipo = $_POST['tipo_all'][$idP] < 19 ? 1 : 3; echo "INSERT INTO `presenze` VALUES ('', $id_utente, $id_oper, ".$row[0]->id_contratto.", ".$idP.", '".$_POST['data']."' '".data2date ($data_out)."', ".$_POST['tipo_all'][$idP].", $tipo)<br />"; } else echo $idP." non trovato<br />"; } } else { echo "<h3>Arrivi del ".$data."</h3> <form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">\n"; while (!feof ($fp)) { $buf = fgets ($fp, 256); $buf = trim ($buf, "\r\n \t"); # toglie spazi e tab dall'inizio e fine della stringa $shift = 0; $i = 0; $citta = ""; $tipo_all = trim (substr ($buf, $shift, $arCaratteri[$i]), ' '); $tipo = $tipo_all < 19 ? 1 : 3; $shift+= $arCaratteri[$i]; $i++; $dataIn = data2date (trim (substr ($buf, $shift, $arCaratteri[$i]), ' ')); $shift+= $arCaratteri[$i]; $i++; $cognome = ucwords (strtolower (trim (substr ($buf, $shift, $arCaratteri[$i]), ' '))); // echo $shift." ".$arCaratteri[$i]."<br />"; $shift+= $arCaratteri[$i]; $i++; // if (strpos ($cognome, "'")) $shift++; $nome = ucwords (strtolower (trim (substr ($buf, $shift, $arCaratteri[$i]), ' '))); // echo $shift." ".$arCaratteri[$i]."<br />"; $shift+= $arCaratteri[$i]; $i++; // if (strpos ($nome, "'")) $shift++; $sesso = substr ($buf, $shift, $arCaratteri[$i]); // echo $shift." ".$arCaratteri[$i]."<br />"; $shift+= $arCaratteri[$i]; $i++; $dataNas = data2date (trim (substr ($buf, $shift, $arCaratteri[$i]), ' ')); $shift+= $arCaratteri[$i]; $i++; $luogoNascCom = trim (substr ($buf, $shift, $arCaratteri[$i]), ' '); if ($dataIn == $data) { $sql = "SELECT `id` FROM `persone` WHERE `nome` = '".addslashes ($nome)."' AND `cognome` = '".addslashes ($cognome)."' AND `data_nasc` = '".$dataNas."' AND `comune_nasc` = '".$arComuni[$luogoNascCom]."' LIMIT 1"; $row = $query->freeQuery ($sql, 0); if ($row[0]->id) { echo $nome." ".$cognome." - partenza il <input type=\"text\" id=\"data_".$row[0]->id."\" name=\"data_out[".$row[0]->id."]\" value=\"".date2data ($data)."\"><input type=\"hidden\" name=\"tipo_all[".$row[0]->id."]\" value=\"".($tipo_all+1)."\"><br />\n"; $calend.= "\$(function() { \$('#data_".$row[0]->id."').datepicker({ changeMonth: true, changeYear: false }); });\n\n"; } else echo $nome." ".$cognome." non presente nel db<br />\n"; } } echo "<script type=\"text/javascript\" language=\"JavaScript\"> <!-- ".$calend." //--> </script> <input type=\"submit\" value=\"inserisci\"/><input name=\"data\" type=\"hidden\" value=\"".$data."\" /><input name=\"az\" type=\"hidden\" value=\"ins\" /> </form\n"; } ?> </body></html>
Save File
Cancel