Your IP : 3.133.148.222
<?php
$msg ='';
if(isset($_SESSION['sn'])){
$rep = $repx = $_SESSION['sn'];
}
if(isset($_SESSION['retreat'])){
$rid = $_SESSION['rid'];
$sid = $_SESSION['sid'];
//$region = $_SESSION['region'];
$state = $_SESSION['state'];
// $repx=$_SESSION['reg'];
$name=$_SESSION['retreat'];
$qurr=$db->query("select * FROM region WHERE sn='$rid' " )or die(mysqli_error());
$rr=mysqli_fetch_array($qurr);
$region = $rr['region'];
$regionx = $rr['region'];
}
// function gName($gid,$col='zone'){
// global $db;
// $query=$db->query("select * FROM zone WHERE sn='$gid' " )or die(mysql_error());
// $row=mysqli_fetch_array($query);
// return $row[$col];
// }
function gidEvent($gid){
global $db,$program;
$query=$db->query("SELECT * FROM event WHERE gid='$gid' AND program='$program' " )or die(mysql_error());
return mysqli_num_rows($query);
}
function gidEventTag($gid){
global $db,$program;
$query=$db->query("SELECT * FROM event WHERE gid='$gid' AND program='$program' AND tag>0 " )or die(mysql_error());
return mysqli_num_rows($query);
}
function didName($did,$col='district'){
global $db;
$query=$db->query("SELECT * FROM district WHERE sn='$did' " )or die(mysql_error());
$row=mysqli_fetch_array($query);
return $row[$col];
}
// function dName($did,$opt){
// global $db;
// $sql = $db->query("SELECT * FROM district WHERE sn = '$did' ");
// $row = mysqli_fetch_array($sql);
// return $row[$opt]; }
// function userName($id,$col=''){
// global $db;
// $query=$db->query("SELECT * FROM mdata WHERE id='$id' " )or die(mysql_error());
// $row=mysqli_fetch_array($query);
// $res = empty($col) ? $row['surname'].' '.$row['firstname'].' '.$row['othername'] : $row[$col];
// return $res;
// }
function tagInOut($id,$tag,$type){
global $db;
$time = time();
$db->query("INSERT INTO eventinout (id,tag,type,time) VALUES ('$id','$tag','$type','$time') ");
return;
}
function tagToSn($tag,$col='id'){
global $db;
$query=$db->query("SELECT * FROM event WHERE tag='$tag' " )or die(mysql_error());
$row=mysqli_fetch_array($query);
$no=mysqli_num_rows($query);
$res = $no==0 ? 0 : $row[$col];
return $res;
}
function snToTag($sn,$col='tag'){
global $db;
$query=$db->query("SELECT * FROM event WHERE id='$sn' " )or die(mysql_error());
$row=mysqli_fetch_array($query);
$res = $row[$col];
return $res;
}
function userNameEv($sn,$col=''){
global $db;
$sn = $sn-100000;
$query=$db->query("SELECT * FROM eventdata WHERE sn='$sn' " )or die(mysql_error());
$row=mysqli_fetch_array($query);
$res = empty($col) ? $row['surname'].' '.$row['firstname'].' '.$row['othername'] : $row[$col];
return $res;
}
function userNameAdmin($rep,$col=''){
global $db;
$query=$db->query("SELECT * FROM admin WHERE phone='$rep' " )or die(mysql_error());
$row=mysqli_fetch_array($query);
$res = empty($col) ? $row['firstname'].' '.$row['lastname']: $row[$col];
return $res;
}
function userNameSn($sn,$col=''){
global $db;
if($sn<100000){
$query=$db->query("SELECT * FROM mdata WHERE sn='$sn' " )or die(mysql_error());
}else{ $sn1 = $sn-100000;
$query=$db->query("SELECT * FROM eventdata WHERE sn='$sn1' " )or die(mysql_error());
}
$row=mysqli_fetch_array($query);
$res = empty($col) ? $row['surname'].' '.$row['firstname'].' '.$row['othername'] : $row[$col];
return $res;
}
function userEvent($sn,$col='tag'){
global $db;
$query=$db->query("SELECT * FROM event WHERE id='$sn' ORDER BY sn DESC LIMIT 1 " )or die(mysql_error());
$row=mysqli_fetch_array($query);
$res = $row[$col];
return $res;
}
function tagName($tag){
global $db;
$query=$db->query("SELECT * FROM event WHERE tag='$tag' ORDER BY sn DESC LIMIT 1 " )or die(mysql_error());
$row=mysqli_fetch_array($query);
return userNameSn($row['id']);
}
// function user($id,$col){
// global $db;
// $qur=$db->query("select * FROM mdata WHERE sn='$id' ")or die(mysqli_error());
// $r=mysqli_fetch_assoc($qur);
// return $r[$col];
// }
$qry=$db->query("SELECT * FROM eventtype where active = 1" )or die(mysqli_error());
$rr=mysqli_fetch_array($qry);
$program = $rr['code'];
$title = $rr['title'];
function regStatus($id){
global $program,$db;
$qur=$db->query("SELECT * FROM event WHERE id='$id' AND program = '$program' ")or die(mysqli_error());
$r=mysqli_num_rows($qur);
return $r;
}
function tagStatus($tag,$section){
global $program,$db;
$qur=$db->query("SELECT * FROM event WHERE tag='$tag' AND program = '$program' AND section='$section' ")or die(mysqli_error());
$r=mysqli_num_rows($qur);
return $r;
}
function rName($rid,$col='region'){
global $db;
$sql = $db->query("SELECT * FROM region WHERE sn = '$rid' " );
$row=mysqli_fetch_array($sql);
return $row[$col];
}
if(array_key_exists('RegUser', $_POST)){
$id = $_POST['id'];
$qur=$db->query("SELECT * FROM mdata WHERE sn='$id' " )or die(mysqli_error());
$r=mysqli_fetch_array($qur);
$sid = $r['sid'];
$rid = $r['rid'];
$gid = $r['gid'];
$did = $r['did'];
$sex = trim($r['sex']);
$section = trim($r['section']);
$date = date('ymd');
$tag = $section=='Children' ? 0 : $_POST['tag'];
if(tagStatus($tag,$section)>1 AND $section != 'Children' AND $rid==1){$reportx = 'This tag has been alocated to: '.tagName($tag);}
else{
$sql = $db->query("INSERT INTO event (id,did,gid,rid,sid,sex,date,section,program,rep,tag)
VALUES('$id','$did','$gid','$rid','$sid','$sex','$date','$section','$program','$repx','$tag')") or die(mysqli_error());
if($sql){
tagInOut($id,$tag,2);
$report = 'Registration Successful: '.userNameSn($id);}
}
}
if(array_key_exists('RegisterMultiple', $_POST)){
$report=''; $reportx='';
if(empty($_POST['id'])){$reportx = 'You have not selected any participant'; }else{
$id=$_POST['id'];
$a=1;
$N = count($id);
for($i=0; $i < $N; $i++)
{
$idx = $id[$i];
$qur=$db->query("SELECT * FROM mdata WHERE sn='$idx' " )or die(mysqli_error());
$r=mysqli_fetch_array($qur);
$sid = $r['sid'];
$rid = $r['rid'];
$gid = $r['gid'];
$did = $r['did'];
$sex = trim($r['sex']);
$section = trim($r['section']);
$date = date('ymd');
$tag = $section=='Children' ? 0 : $_POST['tag'.$idx];
if(empty($tag) AND $section != 'Children'){$reportx .= userNameSn($idx). ' could not be registered. Tag number not supplied<br>';}
elseif(tagStatus($tag,$section)>1 AND $section != 'Children' AND $rid==1){$reportx .= userNameSn($idx). ' could not be registered. Tag already issued to another person <br>';}
else{ $sql = $db->query("INSERT INTO event (id,did,gid,rid,sid,sex,date,section,program,rep,tag)
VALUES('$idx','$did','$gid','$rid','$sid','$sex','$date','$section','$program','$repx','$tag')") or die(mysqli_error()); $b=$a++;
$report .= 'Registration Successful: '.userNameSn($idx).'<br>';
}
}
}
}
if(array_key_exists('UnRegUser', $_POST)){
$id = $_POST['id'];
$sql = $db->query("DELETE FROM event WHERE id = '$id' AND program = '$program' ") or die(mysqli_error());
$report = 'participant Un-registratered: '.userNameSn($id);
}
if(array_key_exists('ChangeTag', $_POST)){
$id = $_POST['id'];
$oldtag = snToTag($id);
$section = snToTag($id,'section');
$tag = $section=='Children' ? 0 : $_POST['tag'];
if(tagStatus($tag,$section)>1 AND $section != 'Children' AND $rid==1){$reportx = 'This tag has been alocated to: '.tagName($tag);}
else{
$sql = $db->query("UPDATE event SET tag = '$tag' WHERE id = '$id' AND program = '$program' ") or die(mysqli_error());
if($oldtag==0){tagInOut($id,$tag,2); }
$report = 'Successfully changed participant tag: '.userNameSn($id);
}
}
if(array_key_exists('UnTag', $_POST)){
$id = $_POST['id'];
$tag = snToTag($id);
$db->query("UPDATE event SET tag = 0 WHERE id = '$id' AND program = '$program' ") or die(mysqli_error());
tagInOut($id,$tag,1);
$report = 'Successfully retrieved participant tag: '.userNameSn($id);
}
function coment(){
return 'Comment_______________________________________________________________________________________________ <br><br>
Sectional Leader, Signature & Date________________________________________________________________________';
}
function tagReceived($id){
global $db; $t=0;
$sql = $db->query("SELECT * FROM tagtile WHERE id='$id' ");
while($row = mysqli_fetch_array($sql)){
$t += $row['tags'];
}
return $t;
}
function tagIssued($rep){
global $db;
$sql = $db->query("SELECT * FROM event WHERE rep='$rep' AND section != 'Children' ");
return mysqli_num_rows($sql);
}
function officerCount($rep,$section){
global $db;
$sql = $db->query("SELECT * FROM event WHERE rep='$rep' AND section='$section' ");
return mysqli_num_rows($sql);
}
function eventCount(){
global $db,$rid;
$sql = $db->query("SELECT * FROM event WHERE rid='$rid' ");
return mysqli_num_rows($sql);
}
function correctDate($dat){
$cdate = $dat=='21ST DEC - 25TH DEC, 2019' ? '21ST DEC - '.strtoupper(date(jS)).' DEC, 2019' : $dat;
return $cdate;
}
?>