function login($title) { if (check_login()) { header('location:./?sub'); } else { include 'config/db.php'; include 'config/settings.php'; include 'config/globals.php'; echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu1("login.php", "Login", "user"); display_loginform(); $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); if (isset($_POST["Login"])) { $user = mysql_real_escape_string($_POST["UserId"]); $pass = md5($_POST["Password"]); if (strlen(trim($user)) == 0) { echo "<script>show_error('Error : User Id should not be null');</script>"; exit; } if (strlen(trim($pass)) == 0) { echo "<script>show_error('Error : Password should not be null');</script>"; exit; } $q = mysql_query("SELECT Id,Password FROM `{$table}` where Id='" . $user . "';") or die(mysql_error()); $res = mysql_fetch_array($q); if (empty($res)) { echo "<script>show_error('Error : Invalid User Id ... Please try again ');</script>"; } else { if ($pass != $res["Password"]) { echo "<script>show_error('Error : Invalid Password ... Please try again ');</script>"; } else { $_SESSION['UserId'] = $user; header("location: ./?sub"); } } } echo "\n</body>\n</html>"; mysql_close($con); } }
function adminReg($title) { if (check_login()) { header("location:index.php"); } else { include 'config/db.php'; include 'config/settings.php'; include 'config/globals.php'; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; $table1 = $branchyear . '_Admins'; //if(!mysql_select_db($dbname)) die(mysql_error()); echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu1("adminreg.php", "Registration", "user"); show_regform(); } }
function adminForgot($title) { if (check_login()) { header("location:./?sub"); } else { include 'config/db.php'; include 'config/settings.php'; include 'config/globals.php'; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; $table1 = $branchyear . '_Admins'; //if(!mysql_select_db($dbname)) die(mysql_error()); echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu1("adminforgot.php", "Forgot Password", "unlock"); show_form(); } }
function changecr($title) { if (!check('CR')) { header('location:login.php'); } else { include 'config/globals.php'; $p = $_SERVER['QUERY_STRING']; $reg = "/^" . $globalbranch . "[1-" . $classno . "]{1}\$/"; if (preg_match($reg, $p)) { include 'config/db.php'; include 'config/settings.php'; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); $userid = $_SESSION['UserId']; $q = "select Branch,Class from {$table} where Id = '{$userid}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); $branch = $row['Branch']; $class1 = $row['Class']; $class = substr($p, -1); if ($class != $class1) { echo "Your not from {$branch} {$class}"; } else { echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu(); $array = array_merge(range(0, 9)); shuffle($array); $crkey = ""; for ($i = 0; $i < 6; $i++) { $crkey .= $array[$i]; } echo <<<a \t\t\t\t\t<div class='container'> \t\t\t\t\t\t<div id="error" style="display:none;"></div> \t\t\t\t\t\t<div class='row'> \t\t\t\t\t\t\t<div class='span9'> \t\t\t\t\t\t\t\t<div class="well well-large" style="background:#FFF;height:450px;"> a; if (isset($_POST["Generate"])) { $id = addslashes($_POST['IdNo']); $key = addslashes($_POST['Key']); $Skey = addslashes($_POST['Skey']); $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); $userid1 = $_SESSION['UserId']; $userid = $id; $q = "select Name,Branch,Class,Gender from {$table} where Id = '{$userid}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); $name = ucwords(strtolower($row['Name'])); $branch = $row['Branch']; $class2 = $row['Class']; $dbname = $branchyear . '_Users'; $table = $branchyear . '_CRs'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = "select Id,`Key` from {$table} where Id = '{$userid1}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); $key1 = $row['Key']; if ($key1 != $Skey) { echo "<script>show_error('<b>Error </b> : CR Security Key does not matched. Please try again.. ');</script>"; } else { if ($class2 == $class) { $dbname = $branchyear . '_Logs'; $table = $branchyear . '_Passwords'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = "select `EndTime`, `Code` from `{$table}` where `To` = '{$userid}';"; $res = mysql_query($q) or die(mysql_error()); $n = mysql_num_rows($res); $StartTime = date('d-m-Y H:i:s'); $end = ""; $dif = 0; $code = ""; while ($row = mysql_fetch_array($res)) { $end = $row['EndTime']; $dif = strtotime($end) - strtotime($StartTime); $code = $row['Code']; } if ($dif <= 7200 && $dif > 0 && $n) { echo "<script>show_error('<b>Error </b> : <b>{$userid}</b> is already assigned <b class=\\'text-success\\'>{$code}</b> till <b class=\\'text-success\\'>{$end}</b> ');</script>"; } else { $EndTime = date('d-m-Y H:i:s', mktime(date('H') + 2)); $ip = $_SERVER['REMOTE_ADDR']; $q1 = mysql_query("insert into {$table} ( `To`, `Code`, `CreatedBy`, `StartTime`,`EndTime`, `Status`,`IP` ) values ( '{$id}', '{$key}' , '{$userid1}', '{$StartTime}', '{$EndTime}', 'valid','{$ip}');") or die(mysql_error()); insert_log($_SESSION['UserId'] . "created security key for {$id} "); echo "<script>show_success('To change password of {$id} use the security pin <u class=\\'text-error\\'>{$key}</u> valid up to <u class=\\'text-error\\'>{$EndTime}</u> ');</script>"; } } else { echo "<script>show_error('<b>Error </b> : <b>{$userid}</b> is not from the <b>{$branch} {$class} </b> Please try again.. ');</script>"; } } } echo <<<a \t\t\t\t\t\t<div id="step1"> \t\t\t\t\t\t\t<h4>Security Codes @ {$branch} {$class} </h4> \t\t\t\t\t\t\t<h6>      Provide requesting Student Id </h6> \t\t\t\t\t\t \t\t\t\t\t\t\t<form action="?{$p}" method="POST" onsubmit="return check_id();" id="password"> \t\t\t\t\t\t\t<br> \t\t\t\t\t\t\t<h5>Student ID No : </h5> \t\t\t\t\t\t\t<input type="text" class="input-large" placeholder="N090001" id="Idno" name="IdNo" maxlength="7" /><br> \t\t\t\t\t\t\t<h5>Your Security Key : </h5> \t\t\t\t\t\t\t<input type="text" class="input-large" placeholder="Security Key" id="Skey" name="Skey" maxlength="9" /><br> \t\t\t\t\t\t\t<!--<h5>Security Key : </h5>--> \t\t\t\t\t\t\t<input type="hidden" class="input-large" readonly=readonly name="Key" value="{$crkey}" > \t\t\t\t\t\t\t<br><input type="submit" class="btn btn-primary" name="Generate" value = "Continue →" /> \t\t\t\t\t\t\t</form>\t \t\t\t\t\t\t\t \t\t\t\t\t\t</div> \t\t\t\t\t</div> \t\t\t\t</div> \t\t\t\t<div class='span3'> a; go_home(); sidepanel(); echo <<<a \t\t\t</div> \t\t\t</div> \t\t\t \t\t\t</div> \t\t\t</div> \t\t\t a; echo "</div></div>"; display_footer(); echo "\n</body>\n</html>"; } } else { echo "<script type='text/javascript'>document.location.href='404.php';</script>"; } } }
$type = $row['type']; $vacant = $row['vacant']; $contract_start = $row['contract_start']; $contract_end = $row['contract_end']; echo "\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td><img src='http://www.{$image}' alt='Property Photo' style='width:80px;height:45px;'/></td>\r\n\t\t\t\t\t\t<td class='Property ID'><a href='propertypage.php?pid={$pid}'>{$pid}<p></p></a>\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t<td>{$address} <br>{$suburb}</td>\r\n\t\t\t\t\t\t<td>{$type}</td>\r\n\t\t\t\t\t\t<td>{$vacant}<br>{$contract_start} - {$contract_end}</td>\r\n\t\t\t\t\t\t</tr>"; } } /* Checks if the user is logged in through a cookie, and if so directs the user to go to search. Otherwise it tells the un-logged in user to go and log in. */ if (isset($_COOKIE['id'])) { $email = $_COOKIE['id']; printf("<p>Go to the search tab to look for available properties</p>"); printf("<p>Your registered properties:</p>"); display_headers(); $result = $pdo->query("\r\n\t\t\t\tSELECT first_name, user_type\r\n\t\t\t\tFROM users\r\n\t\t\t\tWHERE id = '{$id}'"); foreach ($result as $row) { $user_type = $row["user_type"]; if ($user_type == 'Admin') { $result = $pdo->query("\r\n\t\t\t\t\tSELECT *\r\n\t\t\t\t\tFROM properties\r\n\t\t\t\t\tORDER BY vacant ASC"); echo "<table>"; display_results($result); echo "</table>"; } else { $result = $pdo->query("\r\n\t\t\t\tSELECT *\r\n\t\t\t\tFROM properties\r\n\t\t\t\tWHERE rid = '{$id}' OR eid ='{$id}' OR oid = '{$id}'\r\n\t\t\t\tORDER BY pid ASC"); echo "<table>"; display_results($result); echo "</table>"; } }
function generate_attendance($title) { if (!check("BA")) { header('location:./login.php'); } else { include 'config/db.php'; include 'config/settings.php'; include 'config/globals.php'; $p = $_SERVER['QUERY_STRING']; if (in_array($p, $allowed_subjects)) { echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu(); echo <<<a \t\t \t<div class="container" style="margin-top:-10px;"><br> \t\t<div id='error'></div> a; $branch = $globalbranch; echo <<<a \t\t<div id="error" style="display:none;margin-top:10px;"></div> \t\t \t\t<div class="row"> \t\t\t<div class='span12'> \t\t\t\t<div class="well well-large" style="background:#FFF;"> a; $ar1 = array(); for ($cln = 1; $cln <= $classno; $cln++) { $class = $cln; $ar = array(); $dbname = $branchyear . '_Subjects'; $table = $branch . $class . '_Subjects'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select RNo,Id from {$table}") or die(mysql_error()); $strength = mysql_num_rows($q); $sub = $p; $dbname = $branchyear . '_Subjects'; $table = $branch . $class . '_Subjects'; //if(!mysql_select_db($dbname)) die(mysql_error()); $qa = mysql_query("select RNo, `" . $sub . "_A` from {$table}") or die(mysql_error()); $qp = mysql_query("select RNo, `" . $sub . "_P` from {$table}") or die(mysql_error()); while ($res = mysql_fetch_array($qa)) { @($ar[$sub]["Absents"] += $res[$sub . "_A"]); } while ($res = mysql_fetch_array($qp)) { @($ar[$sub]["Presents"] += $res[$sub . "_P"]); } $ar[$sub]['nod'] = ($ar[$sub]["Absents"] + $ar[$sub]["Presents"]) / $strength; $ar1[$branch . $class] = $ar; } //print_r($ar1); echo <<<a \t\t \t\t\t<div id="step1" class="span6"> \t\t\t\t<h5 class='text-info'>All Classes Attendance Details for {$p}</h5> \t\t\t\t<h6>     -   Lising Data submitted from CRs @ {$branch} </h6><br> \t\t\t</div> \t\t\t<div id="side1" class="span5" > \t\t\t\t<h6 class='text-right'><a href='./?sub'><i class='icon-home'></i> Home </a> </h6> a; echo <<<a \t\t\t\t\t<h6 class='text-right'> a; for ($cl = 0; $cl < count($allowed_subjects); $cl++) { $sub = $allowed_subjects[$cl]; echo "<a href='?{$sub}'>{$sub}</a> "; } echo <<<a \t\t\t\t\t</h6> a; echo <<<a \t\t\t</div> \t\t a; $tr = ''; $html = ''; $html .= "<thead><tr><th> SNo </th><th> Class </th><th> Days </th><th> Presents </th><th> Pre/Day </th><th> Absents </th><th> Abs/Day</th><th> Performance </th></tr>"; @($strength = count($users)); for ($j = 1; $j <= $classno; $j++) { $cls = $branch . $j; $tr .= '<tr><td style="text-align:center;" >' . $j . ' </td> <td style="text-align:center;" >' . $cls . ' </td>'; $html .= "<tr><td>" . $j . "</td><td>" . $cls . "</td>"; $sub = $p; $abs = $ar1[$cls][$sub]['Absents']; $pres = $ar1[$cls][$sub]['Presents']; $p_nod = $abs + $pres; @($tmp = $pres / $p_nod * 100); $pr = round($tmp, 1); $cl = $pr > 50 ? "success" : 'error'; $cl1 = $pr > 50 ? "green" : "darkred"; @($perday = $pres / $ar1[$cls][$sub]['nod']); @($absday = $abs / $ar1[$cls][$sub]['nod']); $tr .= ' <td style="text-align:center;">' . round($ar1[$cls][$sub]['nod']) . '</td> <td style="text-align:center;" class="text-success" > ' . $pres . ' </td> <td style="text-align:center;" class="text-success" > ' . round($perday, 1) . ' </td> <td style="text-align:center;" class="text-error" > ' . $abs . ' </td> <td style="text-align:center;" class="text-error" > ' . round($absday, 1) . ' </td> <td style="text-align:center;" class="text-' . $cl . '" > ' . $pr . '</td> '; $tr .= '</tr>'; $html .= "<td>" . round($ar1[$cls][$sub]['nod']) . "</td><td><font color=\"green\">" . $pres . "</font></td><td><font color=\"{$cl1}\">" . round($perday, 1) . "</font></td><td><font color=\"darkred\">" . $abs . "</td><td>" . round($absday, 1) . "</td><td><font color=\"{$cl1}\">" . $pr . "</font></td>"; $html .= "</tr>"; } echo <<<a \t\t \t\t <table class="table table-hover table-bordered " style="padding:0px;"> \t\t\t\t\t<thead> \t\t\t\t\t\t<tr> \t\t\t\t\t\t\t<th style="text-align:center;" rowspan=2 valign="top"> SNo </th> \t\t\t\t\t\t\t<th style="text-align:center;" rowspan=2 valign="top"> Class </th> \t\t\t\t\t</tr> a; echo <<<a \t\t\t\t\t \t\t\t\t\t<tr> a; echo <<<a \t\t\t\t\t\t\t<th style="text-align:center;" > Days </th> \t\t\t\t\t\t\t<th style="text-align:center;" > Presents </th> \t\t\t\t\t\t\t<th style="text-align:center;" > Pre/Day </th> \t\t\t\t\t\t\t<th style="text-align:center;" > Absents </th> \t\t\t\t\t\t\t<th style="text-align:center;" > Abs/Day </th> \t\t\t\t\t\t\t<th style="text-align:center;" > Performance </th> a; echo <<<a \t\t\t\t\t\t</tr> \t\t\t\t\t\t \t\t\t\t\t</thead> \t\t\t\t\t<tbody>\t\t\t\t\t\t\t a; echo $tr; echo "</tbody></table>"; echo <<<a \t\t\t<form action='print.php' method='post' name='abc'> \t\t\t<input type='hidden' name='Title1' value="{$branch} Period Wise Report"> \t\t\t<input type='hidden' name='Table1' value='{$html}'> \t\t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as PDF</button></center> \t\t\t</form> a; echo <<<b \t\t\t<form action='excel.php' method='post' name='abc'> \t\t\t<input type='hidden' name='Title1' value="{$branch} _Period_Wise_Report"> \t\t\t<input type='hidden' name="sheet" value='{$html}'> \t\t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as Excel Sheet</button></center> \t\t\t</form> b; echo "</div> </div> </div> "; display_footer(); echo "\n</body>\n</html>"; @mysql_close($con); } else { echo "Subject not Found"; } } }
function generate_attendance($title) { if (!check_login()) { header('location:./login.php'); } else { if (!check_day()) { include 'config/globals.php'; $p = $_SERVER['QUERY_STRING']; $reg = "/^" . $globalbranch . "[1-" . $classno . "]{1}\$/"; if (preg_match($reg, $p)) { include 'config/db.php'; include 'config/settings.php'; include 'config/globals.php'; echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu(); echo <<<a \t\t\t \t<div class="container" style="margin-top:-10px;"><br> \t\t\t<div id="error" style="display:none;margin-top:10px;"></div> \t\t\t a; $table = ''; //$spread=''; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); $userid = $_SESSION['UserId']; $q = "select Branch,Class,Position from {$table} where Id = '{$userid}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); if ($row['Position'] == "BA") { $branch = $globalbranch; $class = substr($p, -1); } else { $branch = $row['Branch']; $class = $row['Class']; $class1 = substr($p, -1); if ($class1 != $class) { //echo 'i am in'; echo "<script type='text/javascript'>show_error('Error: Not authorised to access {$branch}{$class1} details.');</script>"; } } echo <<<a \t\t\t \t\t\t \t\t<div class="row"> \t\t\t\t<div class='span12'> \t\t\t\t\t<div class="well well-large" style="background:#FFF;"> a; echo <<<a \t\t\t \t\t\t\t<div id="step1" class="span4"> \t\t\t\t\t<h5 class='text-info'>Time Table Details for Class {$branch} {$class} </h5> \t\t\t\t\t<h6>     -   Listing Data present in our database </h6><br> \t\t\t\t</div> \t\t\t\t<div id="side1" class="span7" > \t\t\t\t\t<h6 class='text-right'><a href='./?sub'><i class='icon-home'></i> Home </a> </h6> a; if ($row['Position'] == "BA") { echo <<<a \t\t\t\t\t<h6 class='text-right'> a; for ($cl = 1; $cl <= $classno; $cl++) { echo "<a href='?{$globalbranch}{$cl}'>{$globalbranch}{$cl}</a> "; } echo <<<a \t\t\t\t\t</h6> a; } echo <<<a \t\t\t\t</div> \t\t\t a; $html = ""; echo '<table class="table table-hover table-bordered " style="padding:0px;"> <thead> <tr> <th style="text-align:center;" > Period/Day </th> <th style="text-align:center;" > Monday </th> <th style="text-align:center;" > Tuesday </th> <th style="text-align:center;" > Wednesday </th> <th style="text-align:center;" > Thursday </th> <th style="text-align:center;" > Friday </th> <th style="text-align:center;" > Saturday </th> </tr> </thead> <tbody>'; //$spread.=" \t \t P1 \t P2 \t P3 \t P4 \t \t \t\nRno\tID\t".$subjects['P1']."\t".$subjects['P2']."\t".$subjects['P3']."\t".$subjects['P4']."\tPresents\tAbsents\n"; $html .= "<thead><tr> \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t<th > Period/Day </th> \n\t\t\t\t\t\t\t\t<th > Monday </th>\n\t\t\t\t\t\t\t\t<th > Tuesday </th> \n\t\t\t\t\t\t\t\t<th > Wednesday </th>\n\t\t\t\t\t\t\t\t<th > Thursday </th>\n\t\t\t\t\t\t\t\t<th > Friday </th> \n\t\t\t\t\t\t\t\t<th > Saturday </th> \n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</thead><tbody>"; $dbname = $branchyear . '_TimeTable'; $table = $branch . $class . '_TimeTable'; //if(!mysql_select_db($dbname)) die(mysql_error()); $ti = mysql_query("SELECT * from {$table};") or die(mysql_error()); while ($res = mysql_fetch_array($ti)) { echo "<tr>"; $html .= "<tr>"; for ($ct = 0; $ct < 7; $ct++) { if ($ct == 0) { echo "<th><center>" . $res[$ct] . "</center></th>"; $html .= "<th><center>" . $res[$ct] . "</center></th>"; } else { echo "<td><center>" . $res[$ct] . "</center></td>"; $html .= "<td><center>" . $res[$ct] . "</center></td>"; } } $html .= "</tr>"; echo "</tr>"; } $html .= "</tbody></table><br><br><table style=\"border-collapse:collapse;width:100%;margin-left:0%;font-size:12px;\" border=1 ><tr>\n\t\t\t<th width=25% ><center>Short Name</center></th><th> Long Name</th></tr>"; echo "</tbody></table>"; echo <<<a \t\t\t<br> \t\t\t<table class='table table-hover table-bordered' > \t\t<tr> \t\t\t<th width=25% ><center>Short Name</center></th><th> Long Name</th> \t\t</tr> \t\t a; foreach ($sub_def as $key => $val) { echo "<tr><th><center>{$key}</center></th><td>{$val}</td></tr>"; $html .= "<tr><th><center>{$key}</center></th><td> {$val}</td></tr>"; } echo <<<a \t\t</table>\t a; if ($row['Position'] == "BA") { echo <<<a \t\t\t<form action='print.php' method='post' name='abc'> \t\t\t<input type='hidden' name='Title1' value="{$branch} {$class} - Time Table Report"> \t\t\t<input type='hidden' name='Table1' value='{$html}'> \t\t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as PDF</button></center> \t\t\t</form> a; echo <<<b \t\t\t<form action='excel.php' method='post' name='abc'> \t\t\t<input type='hidden' name='Title1' value="{$branch} {$class} - Time Table Report"> \t\t\t<input type='hidden' name="sheet" value='{$html}'> \t\t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as Excel Sheet</button></center> \t\t\t</form> b; } echo <<<a \t\t\t\t\t</div> \t\t\t\t</div> \t\t\t\t a; echo "</div> </div> "; display_footer(); echo "\n</body>\n</html>"; @mysql_close($con); } else { echo "<script type='text/javascript'>document.location.href='404.php';</script>"; } } else { noservice(); } } }
function changecr($title) { if (!check('BA') and !check('SA')) { header('location:login.php'); } else { include 'config/globals.php'; $p = $_SERVER['QUERY_STRING']; $reg = "/^" . $globalbranch . "[1-" . $classno . "]{1}\$/"; if (preg_match($reg, $p)) { include 'config/db.php'; include 'config/settings.php'; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); $userid = $_SESSION['UserId']; $q = "select Branch from {$table} where Id = '{$userid}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); $branch = $row['Branch']; $class = substr($p, -1); echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu(); $array = array_merge(range(0, 9), range('a', 'z')); shuffle($array); $crkey = ""; for ($i = 0; $i < 9; $i++) { $crkey .= $array[$i]; } echo <<<a \t\t\t\t<div class='container'> \t\t\t\t\t<div id="error" style="display:none;"></div> \t\t\t\t\t<div class='row'> \t\t\t\t\t<div class='span9'> \t\t\t\t\t\t<div class="well well-large" style="background:#FFF;height:450px;"> a; if (isset($_POST["Idno"])) { $id = addslashes($_POST['Idno']); $gender = addslashes($_POST['Gender']); $key = addslashes($_POST['Key']); if (strlen(trim($id)) == 0) { echo "<script>show_error('Error : Id should not be null');</script>"; exit; } if (strlen(trim($gender)) == 0) { echo "<script>show_error('Error : CR Gender should not be null');</script>"; exit; } if (strlen(trim($key)) == 0) { echo "<script>show_error('Error : Key should not be null');</script>"; exit; } include 'config/db.php'; include 'config/settings.php'; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) {die(mysql_error());} $userid = $id; $q = "select Name,Branch,Class,Gender from {$table} where Id = '{$userid}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); $name = ucwords(strtolower($row['Name'])); $branch = $row['Branch']; $class1 = $row['Class']; $gender1 = $row['Gender']; $branch = $globalbranch; $d = $dict[$gender . '1']; if ($class1 == $class && $gender1 == $gender) { $table = $branchyear . '_CRs'; $old_id = mysql_fetch_array(mysql_query("Select Id from {$table} where Class = '{$class}' and Gender = '{$gender}';"))['Id']; $q = mysql_query("delete from {$table} where Class = '{$class}' and Gender = '{$gender}';") or die(mysql_error()); $q1 = mysql_query("insert into {$table} ( `Id`, `Name`, `Gender`, `Branch`,`Class`, `Key`) values ( '{$id}', '{$name}' , '{$gender}', '{$branch}', '{$class}', '{$key}');") or die(mysql_error()); insert_log("Changing {$branch} {$class} {$d} CR to {$id}"); $dbname = $branchyear . '_Logs'; $table = $branchyear . '_Notifications'; //if(!mysql_select_db($dbname)) {die(mysql_error());} $datetime = date('d/m/Y H:m:s'); $ip = $_SERVER['REMOTE_ADDR']; $to1 = $branch . $class . "@students"; $query = mysql_query("INSERT INTO " . $table . "(`To`,`From`,`Subject`,`Message`,`DateTime`,`IP`) VALUES('{$to1}','" . $_SESSION['UserId'] . "','Changing the {$d} CR of {$branch} {$class}','Dear Students,<br>Please Notice that, {$branch} {$class} {$d} CR has been changed to <br> {$name}, {$id}.','{$datetime}','{$ip}');") or die(mysql_error()); $table = $dbname = $branchyear . '_Students'; $query = mysql_query("update {$table} set Position = 'CR' where Id = '{$id}'") or die(mysql_error()); $query1 = mysql_query("update {$table} set Position = 'S' where Id = '{$old_id}'") or die(mysql_error()); echo "<script>show_success('{$branch} {$class} {$d} CR has been updated with {$name} and security key <u class=\\'text-error\\'>{$key}</u> ');</script>"; } else { echo "<script>show_error('<b>Error </b> : <b>{$id}</b> is not from the <b>{$branch} {$class} {$d}</b> Please try again.. ');</script>"; } } echo <<<a \t\t\t<div id="step1"> \t\t\t<h4>Change CR of {$branch} {$class} </h4> \t\t\t<h6>      Provide Details of New CR </h6><br> \t\t\t<form action="?{$p}" method="POST" onsubmit="return viewcr('{$branch}',{$class});" id="changecr"> \t\t\t<h5>Gender : </h5> \t\t\t<label class="radio inline"><input type="radio" value="M" name="Gender" id="Male" /> Male </label> \t\t\t<label class="radio inline"><input type="radio" value="F" name="Gender" id="Female" /> Female </label> \t\t\t<br><br> \t\t\t<h5>New CR ID No : </h5> \t\t\t<input type="text" class="input-large" placeholder="N090001" id="Idno" name="IdNo" maxlength="7" /><br> \t\t\t<!--<h5>Security Key : </h5>--> \t\t\t<input type="hidden" class="input-large" placeholder="Password" readonly=readonly name="Key" value="{$crkey}" ><br> \t\t\t<input type="submit" class="btn btn-primary" name="change" value = "Continue →" /> \t\t\t</form>\t \t\t\t<form action="?{$p}" method='post' id='sub2'> \t\t\t<div id="confirm"> \t\t\t\t<div id="cr" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="useridlabel" aria-hidden="true"> \t\t\t\t<div class="modal-header"> \t\t\t\t<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> \t\t\t\t<h4 id="useridlabel">Caution</h4> \t\t\t\t</div> \t\t\t\t<div class="modal-body" id='mbody'></div> \t\t\t\t<div class="modal-footer"> \t\t\t\t<button class="btn btn-danger" aria-hidden="true" type="submit" onclick="a();">Confirm & Replace </button> \t\t\t\t<button class="btn btn-primary" aria-hidden="true" data-dismiss='modal' > Cancel </button> \t\t\t\t</div> \t\t\t</div> \t\t\t\t<input type="hidden" placeholder="Password" readonly=readonly name="Gender" value="" id='gender1'> \t\t\t\t<input type="hidden" placeholder="Password" readonly=readonly name="Idno" value="" id='idno1'> \t\t\t\t<input type="hidden" class="input-large" placeholder="Password" readonly=readonly name="Key" value="{$crkey}" > \t\t\t</form> \t\t\t</div> \t\t\t</div>\t\t a; echo <<<b \t\t\t\t \t\t\t\t</div>\t \t\t\t\t</div> \t\t\t\t<div class='span3'> b; go_home(); cr_classes($classno, $globalbranch); echo "</div></div></div>"; display_footer(); echo "\n</body>\n</html>"; } else { echo "<script type='text/javascript'>document.location.href='404.php';</script>"; } } }
function login($title) { if (check_login()) { header('location:./?sub'); } else { include 'config/db.php'; include 'config/settings.php'; include 'config/globals.php'; echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu1("forgot.php", "Forgot Password", "unlock"); display_form(); //echo "<script>show_success('Contact your CR for Security Code');</script>"; if (isset($_POST["forgot"])) { $user = addslashes($_POST["UserId"]); $code = addslashes($_POST["Code"]); $pass1 = addslashes($_POST["Pass1"]); $pass2 = addslashes($_POST["Pass2"]); if (strlen(trim($user)) == 0) { echo "<script>show_error('Error : User id should not be null');</script>"; exit; } if (strlen(trim($code)) == 0) { echo "<script>show_error('Error : Security code should not be null');</script>"; exit; } if (strlen(trim($pass2)) < 7) { echo "<script>show_error('Error : Password Length Must Be Lessthan or equals to 7');</script>"; exit; } if (strlen(trim($pass1)) < 7) { echo "<script>show_error('Error : Re-Password Length Must Be Lessthan or equals to 7');</script>"; exit; } $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) {die(mysql_error());} $pass = md5($pass1); $q = mysql_query("SELECT Id,Password FROM {$table} where Id='" . $user . "';") or die(mysql_query()); $res = mysql_fetch_array($q); if (empty($res)) { echo "<script>show_error('Error : Invalid User Id ... Please try again ');</script>"; exit; } else { if ($pass1 != $pass2) { echo "<script>show_error('Error : Passwords does not matched ... Please try again ');</script>"; exit; } else { $dbname = $branchyear . '_Logs'; $table = $branchyear . '_Passwords'; //if(!mysql_select_db($dbname)) {die(mysql_error()); } $q = "select `SNo`,`EndTime`, `Code`, `To`, `Status` from `{$table}` where `To` = '{$user}';"; $res = mysql_query($q) or die(mysql_error()); $n = mysql_num_rows($res); $end = ""; $dif = 0; $code1 = ""; $status = ""; $sn = 0; $StartTime = date('d-m-Y H:i:s'); while ($row = mysql_fetch_array($res)) { $end = $row['EndTime']; $dif = strtotime($end) - strtotime($StartTime); $code1 = $row['Code']; $status = $row['Status']; $sn = $row['SNo']; } if ($dif <= 7200 && $dif > 0 && $n) { if ($status == 'valid') { if ($code1 == $code) { $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("update {$table} set Password = '******' where Id='" . $user . "';") or die(mysql_query()); $dbname = $branchyear . '_Logs'; $table = $branchyear . '_Passwords'; //if(!mysql_select_db($dbname)) {die(mysql_error());} $q = mysql_query("update {$table} set Status = 'used' where `SNo` ='" . $sn . "';") or die(mysql_query()); echo "<script>show_success('{$user} password updated click on login button');</script>"; } else { echo "<script>show_error('<b>Error </b> : Security code does not matched ... Please try again ');</script>"; } } else { echo "<script>show_error('<b>Error </b> : Security code already used ... Contact your CR ');</script>"; } } else { echo "<script>show_error('<b>Error </b> : Security code expired ... Contact your CR');</script>"; } } } } echo "\n</body>\n</html>"; mysql_close($con); } }
function generate_attendance($title) { if (!check_login()) { header('location:./login.php'); } else { include 'config/globals.php'; $qs1 = $_SERVER['QUERY_STRING']; $reg1 = "/^[0-9]{2}-[0-9]{2}-[0-9]{4}\$/"; $reg2 = "/^" . $globalbranch . "[1-" . $classno . "]{1}\$/"; $qs = explode('/', $qs1); $len = count($qs); if ($len == 2 or $len == 3 && $qs[2] == "") { $ar = explode('-', $qs[0]); if (preg_match($reg1, $qs[0]) && preg_match($reg2, $qs[1])) { if (checkdate($ar[1], $ar[0], $ar[2])) { include 'config/db.php'; include 'config/settings.php'; include 'config/globals.php'; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); $p = $qs[1]; $userid = $_SESSION['UserId']; $q = "select Branch,Class,Position from {$table} where Id = '{$userid}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); if ($row['Position'] == "BA") { $branch = $globalbranch; $class = substr($p, -1); } else { $branch = $row['Branch']; $class = $row['Class']; $class1 = substr($p, -1); if ($class1 != $class) { display_error("Error : Not allowed to access {$class1} details"); die; } } $da = $qs[0]; $date = $qs[0]; $dif = strtotime($da) - strtotime(date('d-m-Y')); if ($dif > 0) { display_error("Error : Not allowed to access future Attendance"); } else { if (check_day2($da, $branch . $class)) { display_error("Error : Not allowed to access Attendance of semester starting dates"); } else { if (check_day1($da)) { echo noservice(); } else { echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu(); echo <<<a \t\t\t\t\t\t \t<div class="container" style="margin-top:-10px;"><br> \t\t\t\t\t\t<div id="error" style="display:none;margin-top:10px;"></div> \t\t\t\t\t\t a; $table = ''; //$spread=''; $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $class_total = mysql_num_rows(mysql_query("select `Id` from {$table}")); $sample = mt_rand(1, $class_total); echo <<<a \t\t\t\t\t\t \t\t\t\t\t\t \t\t \t\t\t\t\t\t\t\t<div class="well well-large" style="background:#FFF;"> a; $dbname = $branchyear . '_Dates'; $table = $branch . $class . '_Dates'; //if(!mysql_select_db($dbname)) die(mysql_error()); $remaining = array(); $j = 0; $remaining1 = array(); $j1 = 0; $confired = array(); $j2 = 0; $confired1 = array(); $j3 = 0; for ($i = 1; $i <= 4; $i++) { $tmp = "P" . $i; $tmp1 = "P" . $i . "_Con"; $q = mysql_query("select ISNUll(`{$tmp}`) as `P{$i}`,ISNUll(`{$tmp1}`) as `P" . $i . "_C` from {$table} where Date = '{$da}' ") or die(mysql_error()); $res = mysql_fetch_array($q); if ($res["P" . $i]) { $remaining[$j] = "P" . $i; $j++; } else { $remaining1[$j1] = "P" . $i; $j1++; } if ($res["P" . $i . "_C"]) { $confired[$j2] = "P" . $i; $j2++; } else { $confired1[$j3] = "P" . $i; $j3++; } } $dates1 = getdate(strtotime($da)); $day = substr($dates1["weekday"], 0, 3); $dbname = $branchyear . '_TimeTable'; $table = $branch . $class . '_TimeTable'; //if(!mysql_select_db($dbname)) die(mysql_error()); $ti = mysql_query("SELECT DayPeriod,{$day} from {$table};") or die(mysql_error()); $subjects = array(); while ($da1 = mysql_fetch_array($ti)) { $subjects[$da1[0]] = $da1[1]; } //print_r($subjects); //$sub = $subjects[$p]; //echo "<h5 style='text-align:center;'> Attendance Submission Details - $branch $class - $date</h5><br>"; echo <<<a \t\t\t\t\t\t \t\t\t\t\t\t\t<div id="step1" class="span5"> \t\t\t\t\t\t\t\t<h5 class='text-info'>Daily Attendance Submission Details for {$date} </h5> \t\t\t\t\t\t\t\t<h6>     -   Listing Data submitted from CR @ {$branch} {$class} </h6><br> \t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t<div id="side1" class="span6" > \t\t\t\t\t\t\t\t<h6 class='text-right'><a href='./?sub'><i class='icon-home'></i> Home </a> </h6> a; if ($row['Position'] == "BA") { echo <<<a \t\t\t\t\t\t\t\t<h6 class='text-right'> a; for ($cl = 1; $cl <= $classno; $cl++) { echo "<a href='?{$date}/{$globalbranch}{$cl}'>{$globalbranch}{$cl}</a> "; } echo <<<a \t\t\t\t\t\t\t\t</h6> \t\t\t\t\t\t\t\t a; } $dbname = $branchyear . '_Dates'; $table = $branch . $class . '_Dates'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select Date from {$table} where Date = '{$da}'") or die(mysql_error()); if (count($remaining1) != 0 && mysql_num_rows($q) != 0) { $table = $branch . $class . "_Dates"; $q = mysql_query("select SNo from {$table} where Date = '{$date}'") or die(mysql_error()); if (mysql_num_rows($q) == 0) { echo "<script>show_error('Attendance has been not yet uploaded ');</script>"; } $sn = mysql_fetch_array($q) or die(mysql_error()); $sn1 = $sn['SNo'] < 5 ? 0 : $sn['SNo'] - 5; echo '<ul class="nav nav-pills pull-right"> <li class="dropdown" style="margin-top:2px;"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="icon-calendar"></i> Date - ' . $date . ' <b class="caret"></b></a> <ul class="dropdown-menu">'; //echo $sn1; $q = mysql_query("select Date from {$table} order by SNo limit {$sn1},5") or die(mysql_errno()); while ($res = mysql_fetch_array($q)) { $st1 = $res['Date'] == $date ? "active" : " "; echo "<li class='{$st1}'><a href='?" . $res['Date'] . "/" . $branch . $class . "'>" . $res['Date'] . "</a></li>"; } echo '</ul> </li> </ul>'; echo <<<a \t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t \t\t\t\t\t\t\t a; $html = ""; echo '<table class="table table-hover table-bordered " style="padding:0px;"> <thead> <tr> <th style="text-align:center;" rowspan="2" valign="top"> RNo </th> <th style="text-align:center;" rowspan="2" valign="top"> Id </th> <th style="text-align:center;" > P1 </th> <th style="text-align:center;" > P2 </th> <th style="text-align:center;" > P3 </th> <th style="text-align:center;" > P4 </th> <th style="text-align:center;" rowspan=2> Presents </th> <th rowspan=2 style="text-align:center;" > Absents </th> </tr> <tr> <th style="text-align:center;" > ' . $subjects['P1'] . ' </th> <th style="text-align:center;" > ' . $subjects['P2'] . ' </th> <th style="text-align:center;" > ' . $subjects['P3'] . ' </th> <th style="text-align:center;" > ' . $subjects['P4'] . ' </th> </tr> </thead> <tbody>'; //$spread.=" \t \t P1 \t P2 \t P3 \t P4 \t \t \t\nRno\tID\t".$subjects['P1']."\t".$subjects['P2']."\t".$subjects['P3']."\t".$subjects['P4']."\tPresents\tAbsents\n"; $html .= "<thead><tr> \n\t\t\t\t\t\t\t\t\t\t\t<th rowspan=\"2\" width=8%> RNo </th> \n\t\t\t\t\t\t\t\t\t\t\t<th rowspan=\"2\" width=17%> ID </th> \n\t\t\t\t\t\t\t\t\t\t\t<th > P1 </th> <th > P2 </th>\n\t\t\t\t\t\t\t\t\t\t\t<th > P3 </th> <th > P4 </th> \n\t\t\t\t\t\t\t\t\t\t\t<th rowspan=2 width=14%> Presents </th> <th rowspan=2 width=14%> Absents </th>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t<tr> \n\t\t\t\t\t\t\t\t\t\t\t<th > {$subjects['P1']}</th> <th >{$subjects['P2']}</th>\n\t\t\t\t\t\t\t\t\t\t\t<th > {$subjects['P3']} </th> <th > {$subjects['P4']} </th> \n\t\t\t\t\t\t\t\t\t\t</tr></thead>"; $Rnos = array(); $uid = array(); $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select Id, RNo from {$table};") or die(mysql_error()); while ($res = mysql_fetch_array($q)) { $uid[$res['RNo']] = $res['Id']; } for ($s = 0; $s < count($remaining1); $s++) { $p1 = $remaining1[$s]; if (in_array($p1, $confired1)) { $period = $p1; $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select RNo,Id,`{$date}` from {$table};") or die(mysql_error()); $aindex = 0; $pindex = 0; while ($res = mysql_fetch_array($q)) { //$uid[$res['RNo']]=$res['Id']; $z = explode(",", $res[$date]); for ($m = 0; $m < count($z); $m++) { $y = explode("_", $z[$m]); if ($y[0] == $period) { if ($y[1] == "A") { $Rnos[$p1]['Absents'][$aindex] = $res[0]; $aindex++; } else { $Rnos[$p1]['Presents'][$pindex] = $res[0]; $pindex++; } } } } } else { //$da = date('d-m-Y'); $a = $da . '_' . $p1; $dbname = $branchyear . '_Cache'; $table = $branch . $class . '_Cache'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q3 = mysql_query("SELECT RNo, `" . $a . "` FROM {$table}") or die(mysql_error()); $aindex = 0; $pindex = 0; while ($individual = mysql_fetch_array($q3)) { if ($individual[$a] == "A") { $Rnos[$p1]["Absents"][$aindex] = $individual["RNo"]; $aindex++; } if ($individual[$a] == "P") { $Rnos[$p1]["Presents"][$pindex] = $individual["RNo"]; $pindex++; } } } } $tot = array('A' => 0, 'P' => 0); //print_r($uid); for ($w = 1; $w <= $class_total; $w++) { $tr2 = '<tr > <td style="text-align:center;">' . $w . ' </td> <td style="text-align:center;"> ' . $uid[$w] . ' </td>'; echo $tr2; //$spread.="$w \t {$uid[$w]} \t"; $html .= $tr2; $pc = 0; $ac = 0; for ($l = 1; $l <= 4; $l++) { $pl = "P" . $l; if (in_array($pl, $remaining1)) { $edit_error = ""; $edit_success = ""; if (check('BA') or check('CR')) { //echo $pl; print_r($confired1); if (!in_array($pl, $confired1)) { //echo "i am in"; //echo $pl;print_r($confired1);echo "<br>"; $fun = ""; if (array_key_exists("Absents", $Rnos[$pl]) && in_array($w, $Rnos[$pl]['Absents'])) { $fun = "update_rno('{$date}','{$pl}','{$w}','P','{$class}');"; } else { $fun = "update_rno('{$date}','{$pl}','{$w}','A','{$class}');"; } $edit_error = '| <i class="icon-edit text-success" onclick="' . $fun . '" style="cursor:pointer;"></i>'; $edit_success = '| <i class="icon-edit text-error" onclick="' . $fun . '" style="cursor:pointer;"></i>'; } } else { $edit_error = ""; $edit_success = ""; } if (array_key_exists("Absents", $Rnos[$pl]) && in_array($w, $Rnos[$pl]['Absents'])) { echo '<td style="text-align:center;" ><b class="text-error"> <i class="icon-remove"></i> </b> ' . $edit_error . ' </td>'; $ac++; $html .= "<td><font color=\"darkred\">✖</font></td>"; } else { echo '<td style="text-align:center;" ><b class="text-success"> <i class="icon-ok"></i> </b> ' . $edit_success . '</td>'; $pc++; $html .= "<td><font color=\"green\">✔</font></td>"; } } else { echo '<td></td>'; $html .= '<td></td>'; //$spread.=" \t"; } } $tot['A'] += $ac; $tot['P'] += $pc; echo <<<a \t\t\t\t\t\t\t\t\t<td style="text-align:center;" class="text-success"><b> {$pc} </b> </td> \t\t\t\t\t\t\t\t\t<td style="text-align:center;" class="text-error"><b> {$ac} </b></td> \t\t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t\t a; $html .= "<td><font color=\"green\"><b>{$pc}</b></font></td><td><font color=\"darkred\"><b>{$ac}</b></font></td></tr>"; //$spread.="$pc \t $ac \n"; } echo "<tr><td colspan=6 style='text-align:center;'><b>Total</b></td><td style='text-align:center;' class='text-success'><b>" . $tot['P'] . "</b></td><td style='text-align:center;' class='text-error'><b>" . $tot['A'] . "</b></td></tr>"; $html .= "<tr><th colspan=6 style=\"text-align:center;\"> <b>Total</b> </th><td><b><font color=\"green\">" . $tot['P'] . "</font></b></td><td><b><font color=\"darkred\">" . $tot['A'] . "</font></b></td></tr>"; //$spread.="\t \tTotal\t \t \t \t{$tot['P']} \t {$tot['A']}"; echo "</tbody></table>"; if ($row['Position'] == "BA") { echo <<<a \t\t\t\t\t\t<form action='print.php' method='post' name='abc'> \t\t\t\t\t\t<input type='hidden' name='Title1' value="{$branch} {$class} - Daily Report"> \t\t\t\t\t\t<input type='hidden' name='Table1' value='{$html}'> \t\t\t\t\t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as PDF</button></center> \t\t\t\t\t\t</form> a; echo <<<b \t\t\t\t\t\t<form action='excel.php' method='post' name='abc'> \t\t\t\t\t\t<input type='hidden' name='Title1' value="{$branch} {$class} - Daily Report"> \t\t\t\t\t\t<input type='hidden' name="sheet" value='{$html}'> \t\t\t\t\t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as Excel Sheet</button></center> \t\t\t\t\t\t</form> b; } echo <<<a \t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t a; } else { echo "</div><br><h6><span class='text-error'><br><br><br>No Submissions found till now ...</span></h6><br>"; } echo "</div></div>"; display_footer(); echo "\n</body>\n</html>"; @mysql_close($con); } } } } else { display_error("Error : Invalid date"); } } else { display_error("Error : Invalid input pattern"); } } else { display_error("Error : Invalid no. of input arguments "); } } }
<?php include "functions.php"; $p = $_SERVER['QUERY_STRING']; echo "<!DOCTYPE html>\n<html>\n"; display_headers(" Error : 404 - Page Not Found! "); echo "\n<body>"; notfound("Page you are looking for is no longer available"); echo "\n</body>\n</html>";
<?php require "functions.php"; echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu(); echo <<<a <div class="container" style="margin-top:-15px;"> <br> <div id="CSE1" class='well well-large' style="background:#FFF;"> <div id="step1"> \t\t\t\t\t<h5 class='text-info'>Developers Page @ Attendance Portal </h5> \t\t\t\t\t<h6>     -   Contact us for any technical problems of Attendance Portal </h6><br> \t\t\t\t</div> \t<br> <div class="row"> \t\t\t\t <div class='span1'></div> \t\t\t\t <div class='span5'> \t\t\t\t\t <div class='span1'><img src='assets/img/user.jpg'/></div> \t\t\t\t\t <div class='span3'> \t\t\t\t\t\t <address > \t\t\t\t\t\t\t\t<strong>Aneesh Kumar T</strong><br> \t\t\t\t\t\t\t\tN090247<br> \t\t\t\t\t\t\t\tCSE1 - 2009 <br> \t\t\t\t\t\t\t\t<a href="mailto:#">N090247@nuz.rgukt.in</a> \t\t\t\t\t\t\t\t</address> \t\t\t\t\t\t</div> \t\t\t\t\t</div> \t\t\t\t\t<div class='span5'>
function display_notice($title) { $userid = $_SESSION['UserId']; if (!check_login()) { header("location:login.php"); } else { include 'config/globals.php'; $pg = $_SERVER['QUERY_STRING']; $page = '/^[\\d]+$/'; $todaydate = date('d/m/Y'); if (preg_match($page, $pg)) { include 'config/db.php'; include 'config/settings.php'; $dbname = $branchyear . '_Logs'; $table = $branchyear . '_Notifications'; //if(!mysql_select_db($dbname)) die(mysql_error()); echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "<body>\n"; menu(); echo <<<display \t\t\t\t <div class="container" style="margin-top:-15px;"><br> \t\t\t\t\t<div id='error'></div> \t\t\t\t\t <div class="row"> \t\t\t\t\t\t<div class="span12"> \t\t\t\t\t\t\t<div class="well well-large" style="background:#FFF;"> \t\t\t\t\t\t\t\t<div class="row"> \t\t\t\t\t\t\t\t\t<div id="step1" class="span4"> \t\t\t\t\t\t\t\t\t\t<h5>Notifications</h5> \t\t\t\t\t\t\t\t\t\t<h6>     -   Listing all notifications </h6> \t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t<div id="page1" class="span7"> \t\t\t\t\t\t\t\t\t\t <a class="pull-right"><h6>Page {$pg}</h6></a>  \t\t\t\t\t\t\t\t\t\t<a class="pull-right" href='./?sub'><h6><i class='icon-home'></i> Home | </h6></a> \t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t</div> display; //if(!mysql_select_db("".$branchyear."_Users")) die(mysql_error()); $scheck = mysql_query("SELECT Branch,Class,Position FROM " . $branchyear . "_Students WHERE Id='{$userid}';") or die(mysql_error()); $sdet = mysql_fetch_array($scheck); $class = $sdet[0] . $sdet[1]; $type = $sdet['Position']; $toS = $class . "@Students"; $crcheck = mysql_query("SELECT Id FROM " . $branchyear . "_CRs WHERE Id='{$userid}';") or die(mysql_error()); //if(!mysql_select_db($dbname)) die(mysql_error()); if (mysql_num_rows($crcheck) == 1) { $toCR = $class . "@CRs"; $query = "SELECT * FROM " . $table . " WHERE `To`='{$toS}' or `To`='{$toCR}' or `To` = 'all' or `To`= 'allcrs' ORDER BY SNo DESC;"; } else { if ($type == "BA" or $type == "SA") { $query = "SELECT * FROM " . $table . " ORDER BY SNo DESC;"; } else { $query = "SELECT * From " . $table . " WHERE `To`='{$toS}' or `To` = 'all' ORDER BY SNo DESC;"; } } //echo $userid; $exe = mysql_query($query) or die(mysql_error()); $page = $pg; $prev = $page - 1; $next = $page + 1; $per_page = 10; $slimit = ($page - 1) * 10; $total = mysql_num_rows($exe); //if($total == 0) echo "<script>show_error('No notifications found');</script>"; $lastpage = ceil($total / $per_page); if (mysql_num_rows($crcheck) == 1) { $query1 = "SELECT * FROM " . $table . " WHERE `To`='{$toS}' or `To`='{$toCR}' or `To`='all' or `To`='allcrs' ORDER BY SNo DESC LIMIT {$slimit},{$per_page};"; } else { if ($type == "BA" or $type == "SA") { $query1 = "SELECT * FROM " . $table . " ORDER BY SNo DESC LIMIT {$slimit},{$per_page};"; } else { $query1 = "SELECT * FROM " . $table . " WHERE `To`='{$toS}' or `To`='all' ORDER BY SNo DESC LIMIT {$slimit},{$per_page};"; } } $exe1 = mysql_query($query1) or die(mysql_error()); if ($total > 0) { echo <<<table \t\t\t\t\t<div id='{$globalbranch}' > \t\t\t\t\t\t<table class="table table-hover table-bordered " style="padding:0px;"> \t\t\t\t\t\t\t<thead> \t\t\t\t\t\t\t\t<tr> \t\t\t\t\t\t\t\t\t<th style="text-align:center;" class="span1">Date</th> \t\t\t\t\t\t\t\t\t<th style="text-align:center;" class="span3">Subject</th> \t\t\t\t\t\t\t\t\t<th style="text-align:center;" class="span1">To</th> \t\t\t\t\t\t\t\t\t<th style="text-align:center;" class="span2">Sender</th> \t\t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t</thead> \t\t\t\t\t\t\t<tbody> \t\t\t\t\t\t\t table; for ($i = 0; $i < mysql_num_rows($exe1); $i++) { $record = mysql_fetch_array($exe1); $datetime = explode(' ', $record['DateTime']); $date = $datetime[0]; if ($type == "BA") { if ($record[1] == "all") { $to = "ALL Students"; } else { if ($record[1] == "allcrs") { $to = $to = "ALL CRs"; } else { $to = ucfirst($record[1]); } } } else { if ($record[1] == "all") { $to = "ALL Students"; } else { if ($record[1] == "allcrs") { $to = $to = "ALL CRs"; } else { $to = explode('@', $record[1])[1]; } } } $q1 = mysql_query("select `Name`,`Gender` from `" . $branchyear . "_Admins` where `Id` = '" . $record[2] . "'"); $q11 = mysql_fetch_array($q1); $gen = $dict[$q11[1] . "2"]; $q2 = $gen . $q11[0]; //$name = mysql_fetch_array($q2); //print_r($name); echo <<<feedback \t\t\t\t\t\t<tr data-toggle='modal' href="#Note{$record['0']}" style="cursor:pointer;" > \t\t\t\t\t\t\t<td style="text-align:center;">{$date}</td> \t\t\t\t\t\t\t<td >{$record['3']} feedback; if ($date == (string) $todaydate) { echo " <blink><span class='label label-important'>New</span></blink>"; } echo <<<feedback </td> \t\t\t\t\t\t\t<td style='padding-left:15px;'> {$to} </td> \t\t\t\t\t\t\t<td style='padding-left:15px;'> {$q2} </td> \t\t\t\t\t\t </tr>\t\t feedback; } echo <<<feedback \t\t\t\t\t\t</tbody> \t\t\t\t\t\t</table> \t\t\t\t\t\t</div> feedback; if (mysql_num_rows($crcheck) == 1) { $query2 = "SELECT * FROM " . $table . " WHERE `To`='{$toS}' or `To`='{$toCR}' or `To` = 'all' ORDER BY SNo DESC LIMIT {$slimit},{$per_page};"; } else { if ($type == "BA" or $type == "SA") { $query2 = "SELECT * FROM " . $table . " ORDER BY SNo DESC LIMIT {$slimit},{$per_page};"; } else { $query2 = "SELECT * FROM " . $table . " WHERE `To`='{$toS}' or `To` = 'all' ORDER BY SNo DESC LIMIT {$slimit},{$per_page};"; } } $exe2 = mysql_query($query1) or die(mysql_error()); for ($i = 0; $i < mysql_num_rows($exe1); $i++) { $record = mysql_fetch_array($exe2); $datetime = explode(' ', $record['DateTime']); $date = $datetime[0]; //echo $todaydate; $to = explode('@', $record[1]); $q1 = mysql_query("select `Name`,`Gender` from `" . $branchyear . "_Admins` where `Id` = '" . $record[2] . "'"); $q11 = mysql_fetch_array($q1); $gen = $dict[$q11[1] . "2"]; $q2 = $gen . $q11[0]; if (preg_match("/<br>/", $record[4])) { $record[4] = str_replace("<br>", "<br>", $record[4]); } echo <<<feedback \t\t\t\t\t\t\t<div id="Note{$record['0']}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="useridlabel" aria-hidden="true"> \t\t\t\t\t\t\t\t<div class="modal-header"> \t\t\t\t\t\t\t\t\t<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> \t\t\t\t\t\t\t\t\t<h5>{$record['3']}</h5> \t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t<div class="modal-body"> \t\t\t\t\t\t\t\t\t<p>{$record['4']}</p><br> \t\t\t\t\t\t\t\t\t<p> feedback; if ($record[5] == NULL or $record[5] == "" or strlen(trim($record[5])) == 0) { echo "</p>"; } else { $uri = explode("/", $_SERVER["REQUEST_URI"]); $atname = explode("/", $record[5]); echo "<i class='icon-paper-clip icon-2x'></i><b> <a href='http://" . $_SERVER["SERVER_ADDR"] . "/" . $uri[1] . "/" . $record[5] . "' target='_blank'>" . $atname[2] . "</a></b></p>"; } echo <<<min1 \t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t<div class="modal-footer"> \t\t\t\t\t\t\t\t\t<h6 class="pull-left">Sent by<i> {$q2} </i> @ {$record['6']} </h6> \t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t</div>\t\t min1; } echo <<<page \t\t\t\t\t\t<div class="pagination pagination-centered"> \t\t\t\t\t\t\t<ul> page; if ($page < $total / 10 + 1) { if ($page != 1) { echo "<li><a href='?{$prev}'>← Prev</a></li>"; } else { echo "<li class='disabled'><a>← Prevt</a></li>"; } if ($lastpage <= 10) { for ($i = 1; $i <= $lastpage; $i++) { if ($page == $i) { echo "<li class='active'><a href='?{$i}'><b class='text-error'> {$i}</b></a></li>"; } else { echo "<li><a href='?{$i}'>{$i}</a></li>"; } } } else { $init1 = $page % 10 == 0 ? (floor($page / 10) - 1) * 10 + 1 : floor($page / 10) * 10 + 1; // total no of records total pages pages range //echo $page/10; echo $lastpage/10; $end1 = floor(($page - 1) / 10) == floor($lastpage / 10) ? $lastpage : ceil($page / 10) * 10; for ($i = $init1; $i <= $end1; $i++) { if ($page == $i) { echo "<li class='active'><a href='?{$i}'><b class='text-error'> {$i}</b></a></li>"; } else { echo "<li><a href='?{$i}'>{$i}</a></li>"; } } } if ($page != $lastpage) { echo "<li><a href='?{$next}'>Next →</a></li>"; } else { echo "<li class='disabled'><a>Next →</a></li>"; } } else { echo "<script>show_error('No notifications found');</script>"; } echo <<<next \t\t\t\t\t\t</ul> \t\t\t\t\t\t</div> \t\t\t\t\t next; } else { echo "<center><p>No complaints/suggestions found.</p></center>"; } echo "\n</div>"; display_footer(); echo "</body>\n</html>"; } else { echo "<script type='text/javascript'>document.location.href='404.php';</script>"; } } }
function generate_attendance($title) { if (!check_login()) { header('location:./login.php'); } else { include 'config/globals.php'; $p = $_SERVER['QUERY_STRING']; $reg = "/^" . $globalbranch . "[1-" . $classno . "]{1}\$/"; if (preg_match($reg, $p)) { include 'config/db.php'; include 'config/settings.php'; include 'config/globals.php'; echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu(); echo <<<a \t\t\t \t<div class="container" style="margin-top:-10px;"><br> \t\t\t<div id='error'></div> a; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); $userid = $_SESSION['UserId']; $q = "select Position, Branch,Class from {$table} where Id = '{$userid}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); if ($row['Position'] == "BA") { $branch = $globalbranch; $class = substr($p, -1); } else { $branch = $row['Branch']; $class = $row['Class']; $class1 = substr($p, -1); if ($class1 != $class) { echo "<script type='text/javascript'>show_error('Error: Not authorised to access {$branch}{$class1} details.');</script>"; } } $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $class_total = mysql_num_rows(mysql_query("select `Id` from {$table}")); $sample = mt_rand(1, $class_total); $da = date('d-m-Y'); $date = date('d-m-Y'); echo <<<a \t\t\t<div id="error" style="display:none;margin-top:10px;"></div> \t\t\t \t\t<div class="row"> \t\t\t\t<div class='span12'> \t\t\t\t\t<div class="well well-large" style="background:#FFF;"> a; $ar = array(); $users = array(); $html = ""; //$spread=""; for ($j = 1; $j <= 4; $j++) { $prd = "P" . $j; $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select RNo,Id from {$table}") or die(mysql_error()); while ($res = mysql_fetch_array($q)) { if ($j == 1) { $users[$res['RNo']] = $res['Id']; } $ar[$prd][$res['RNo']]['Absents'] = 0; $ar[$prd][$res['RNo']]['Presents'] = 0; } } for ($j = 1; $j <= 4; $j++) { $prd = "P" . $j; $prd1 = $prd . "_Con"; $dates = array(); $coun = 0; //mysql_select_db($branchyear."_Dates") or die(mysql_error()); $q = mysql_query("Select Date from " . $branch . $class . "_Dates where `{$prd1}` ='ok' ;") or die(mysql_error()); $nodq = mysql_num_rows($q); $ar[$prd]['nod'] = $nodq; while ($dad = mysql_fetch_array($q)) { $dates[$coun++] = $dad[0]; } foreach ($dates as $key => $da) { $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select RNo, `{$da}` from {$table}") or die(mysql_error()); while ($res = mysql_fetch_array($q)) { $exp = explode(",", $res[$da]); for ($z = 0; $z < count($exp); $z++) { if (substr($exp[$z], 0, 2) == $prd) { if (substr($exp[$z], -1) == "A") { $ar[$prd][$res['RNo']]["Absents"] += 1; } else { $ar[$prd][$res['RNo']]["Presents"] += 1; } } } } } } echo <<<a \t\t\t \t\t\t\t<div id="step1" class="span4"> \t\t\t\t\t<a ><h5>Today's Attendance Submission Details </h5></a> \t\t\t\t\t<h6>     -   Lising Data submitted from CR @ {$branch} {$class} </h6><br> \t\t\t\t</div> \t\t\t\t<div id="side1" class="span7" > \t\t\t\t\t<h6 class='text-right'><a href='./?sub'><i class='icon-home'></i> Home </a> </h6> a; if ($row['Position'] == "BA") { echo <<<a \t\t\t\t\t<h6 class='text-right'> a; for ($cl = 1; $cl <= $classno; $cl++) { echo "<a href='?{$globalbranch}{$cl}'>{$globalbranch}{$cl}</a> "; } echo <<<a \t\t\t\t\t</h6> a; } echo <<<a \t\t\t\t</div> \t\t\t a; $tr = ''; $html_tr = ""; //$spread_tr=""; $strength = count($users); for ($j = 1; $j <= $strength; $j++) { $pr_tot = 0; $tr .= '<tr><td style="text-align:center;">' . $j . ' </td> <td style="text-align:center;" >' . $users[$j] . ' </td> '; $html_tr .= "<tr><td>" . $j . " </td> <td>" . $users[$j] . "</td> "; //$spread_tr.="$j \t {$users[$j]} \t"; for ($k = 1; $k <= 4; $k++) { $prd = "P" . $k; $abs = $ar[$prd][$j]['Absents']; $pres = $ar[$prd][$j]['Presents']; $p_nod = $ar[$prd]['nod']; @($tmp = $pres / $p_nod * 100); $pr = round($tmp, 1); $cl = $pr > 50 ? "success" : 'error'; $htcol = $pr > 50 ? "green" : "darkred"; $pr_tot += $pr; $tr .= '<td style="text-align:center;" > ' . $p_nod . ' </td><td style="text-align:center;" class="text-success" > ' . $pres . ' </td> <td style="text-align:center;" class="text-error"> ' . $abs . ' </td><td style="text-align:center;" class="text-' . $cl . '" > ' . $pr . '</td>'; $html_tr .= "<td> " . $p_nod . " </td><td><font color=\"green\">" . $pres . "</font></td><td> <font color=\"darkred\">" . $abs . "</font></td><td> <font color=\"{$htcol}\">" . $pr . "</font></td>"; //$spread_tr.="$p_nod \t $pres \t $abs \t $pr \t"; } $tmp1 = round($pr_tot / 4, 1); $cl1 = $tmp1 > 50 ? "success" : 'error'; $htcol = $tmp1 > 50 ? "green" : "darkred"; $tr .= '<td style="text-align:center;" class="text-' . $cl1 . '" >' . $tmp1 . '</td></tr>'; $html_tr .= "<td><font color=\"{$htcol}\">" . $tmp1 . "</font></td></tr>"; //$spread_tr.="$tmp1\n"; } echo <<<a \t\t\t \t\t\t <table class="table table-hover table-bordered " style="padding:0px;"> \t\t\t\t\t\t<thead> \t\t\t\t\t\t\t<tr> \t\t\t\t\t\t\t\t<th style="text-align:center;" rowspan=2 valign="top"> RNo </th> \t\t\t\t\t\t\t\t<th style="text-align:center;" rowspan=2 valign="top"> Id </th> \t\t\t\t\t\t\t\t<th style="text-align:center;" colspan=4> P1 </th> <th style="text-align:center;" colspan=4> P2 </th> \t\t\t\t\t\t\t\t<th style="text-align:center;" colspan=4 > P3 </th> <th style="text-align:center;" colspan=4 > P4 </th> \t\t\t\t\t\t\t\t<th style="text-align:center;" rowspan=2 > Total </th> \t\t\t\t\t\t\t\t \t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t<tr> \t\t\t\t\t\t\t\t<th style="text-align:center;" > D </th> \t\t\t\t\t\t\t\t<th style="text-align:center;" > P </th> <th style="text-align:center;" > A </th> \t\t\t\t\t\t\t\t<th style="text-align:center;" > Pr </th> \t\t\t\t\t\t\t\t<th style="text-align:center;" > D </th> \t\t\t\t\t\t\t\t<th style="text-align:center;" > P </th> <th style="text-align:center;" > A </th> \t\t\t\t\t\t\t\t<th style="text-align:center;" > Pr </th> \t\t\t\t\t\t\t\t<th style="text-align:center;" > D </th> \t\t\t\t\t\t\t\t<th style="text-align:center;" > P </th> <th style="text-align:center;" > A </th> \t\t\t\t\t\t\t\t<th style="text-align:center;" > Pr </th> \t\t\t\t\t\t\t\t<th style="text-align:center;" > D </th> \t\t\t\t\t\t\t\t<th style="text-align:center;" > P </th> <th style="text-align:center;" > A </th> \t\t\t\t\t\t\t\t<th style="text-align:center;" > Pr </th> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t \t\t\t\t\t\t</thead> \t\t\t\t\t\t<tbody>\t\t\t\t\t\t\t a; $html .= "<thead>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th rowspan=2> RNo </th> \n\t\t\t\t\t\t\t\t<th rowspan=2 > Id </th> \n\t\t\t\t\t\t\t\t<th colspan=4> P1 </th> <th colspan=4> P2 </th>\n\t\t\t\t\t\t\t\t<th colspan=4 > P3 </th> <th colspan=4 > P4 </th> \n\t\t\t\t\t\t\t\t<th rowspan=2 > Total </th>\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr> \n\t\t\t\t\t\t\t\t<th> D </th>\n\t\t\t\t\t\t\t\t<th> P </th> <th> A </th>\n\t\t\t\t\t\t\t\t<th> Pr </th>\n\t\t\t\t\t\t\t\t<th> D </th> \n\t\t\t\t\t\t\t\t<th> P </th> <th> A </th>\n\t\t\t\t\t\t\t\t<th> Pr </th> \n\t\t\t\t\t\t\t\t<th> D </th> \n\t\t\t\t\t\t\t\t<th> P </th> <th> A </th>\n\t\t\t\t\t\t\t\t<th> Pr </th>\n\t\t\t\t\t\t\t\t<th> D </th> \n\t\t\t\t\t\t\t\t<th> P </th> <th> A </th>\n\t\t\t\t\t\t\t\t<th> Pr </th> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t</thead>"; //$spread.="\t \t P1 \t \t \t \t P2 \t \t \t \t P3 \t \t \t \t P4 \t \t \t \t\nRno\tID\tD\tP\tA\tPer\tD\tP\tA\tPer\tD\tP\tA\tPer\tD\tP\tA\tPer\tTotal\n"; //$spread.=//$spread_tr; echo $tr; $html .= $html_tr; $html .= "</tbody></table><br><table style=\"border-collapse:collapse;width:100%;margin-left:0%;font-size:12px;\" border=1 >"; $html .= "<tr>\n\t\t\t<th\t><center>Short Name</center></th><th> <center>Long Name</center></th>\n\t\t\t<th\t><center>Short Name</center></th><th> <center>Long Name</center></th>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<th><center>P</center></th><td> No. of Presents</td>\t\n\t\t\t<th><center>A</center></th><td> No. of Absents</td>\n\t\t</tr>\n\t\t<tr>\t\n\t\t\t<th><center>D</center></th><td> No. of Day</td>\n\t\t\t<th><center>Pr</center></th><td> Performance in %</td>\n\t\t</tr>"; echo "</tbody></table>"; echo <<<a \t\t\t<br> \t\t\t<table class='table table-hover table-bordered ' > \t\t<tr> \t\t\t<th\t><center>Short Name</center></th><th> <center>Long Name</center></th> \t\t\t<th\t><center>Short Name</center></th><th> <center>Long Name</center></th> \t\t</tr> \t\t<tr> \t\t\t<th><center>P</center></th><td> No. of Presents</td>\t \t\t\t<th><center>A</center></th><td> No. of Absents</td> \t\t</tr> \t\t<tr>\t \t\t\t<th><center>D</center></th><td> No. of Day</td> \t\t\t<th><center>Pr</center></th><td> Performance in %</td> \t\t</tr> \t\t </table> a; if ($row['Position'] == "BA") { echo <<<a \t\t\t<form action='print.php' method='post' name='abc'> \t\t\t<input type='hidden' name='Title1' value="{$branch} {$class} - Daily Report"> \t\t\t<input type='hidden' name='Table1' value='{$html}'> \t\t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as PDF</button></center> \t\t\t</form> a; echo <<<b \t\t\t<form action='excel.php' method='post' name='abc'> \t\t\t<input type='hidden' name='Title1' value="{$branch} {$class} - Daily Report"> \t\t\t<input type='hidden' name="sheet" value='{$html}'> \t\t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as Excel Sheet</button></center> \t\t\t</form> b; } echo "</div> </div> </div> "; display_footer(); echo "\n</body>\n</html>"; @mysql_close($con); } else { echo "<script type='text/javascript'>document.location.href='404.php';</script>"; } } }
function homepage($title) { if (!check_login()) { header('location:login.php'); } else { echo "<!DOCTYPE html>\n<html>\n\t<SCRIPT LANGUAGE=\"Javascript\" SRC=\"assets/charts/FusionCharts.js\"></SCRIPT>"; display_headers($title); echo "\n<body>"; menu(); echo <<<a \t\t\t\t<div class='container'> \t\t\t\t\t<div id='error'></div> \t\t\t\t\t<div class='row'> \t\t\t\t\t<div class='span9'> \t\t\t\t\t\t<div class="well well-large" style="background:#FFF"> \t\t\t\t\t\t a; splash(); echo <<<a \t<div id="step1" class="span4"> \t\t \t</div> \t<div id="side1" class="span4" > \t\t<h6 class='text-right'><a href='?sub'><i class='icon-book'></i> Subjects</a>   <a href='?p'><i class='icon-qrcode'></i> Periods</a></h6> \t</div> a; /* Fetching Details */ include 'config/db.php'; include 'config/settings.php'; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); $userid = $_SESSION['UserId']; $q = "select Position, Branch, Class ,RNo from {$table} where Id = '{$userid}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); $RNo = $row["RNo"]; $type = $row['Position']; if ($row['Position'] == "BA") { $branch = $globalbranch; $p1 = substr($_SERVER["QUERY_STRING"], 0, $branchlen); if ($p1 == $globalbranch) { $p = explode("/", $_SERVER["QUERY_STRING"]); $class = substr($p[0], -1); } else { $class = 1; } } else { $branch = $row['Branch']; $class = $row['Class']; } $colors = array('F6BD0F', '8BBA00', 'FF8E46', '8E468E', '588526', '008ED6', '9D080D', 'D64646', 'B3AA00', 'A186BE', 'AFD8F8'); shuffle($colors); $colorz = array('F6BD0F,8BBA00', 'FF8E46,8E468E', '8E468E,588526', '008ED6,9D080D'); $reqcolorz = explode(",", $colorz[rand(0, 3)]); /* Deatils Fetched */ /* Start Checking wheter he is a student or any other */ if ($type == "S") { /* Starting Period Wise Attendance */ if (strtolower($_SERVER["QUERY_STRING"]) == "p") { //mysql_select_db($branchyear."_Dates") or die(mysql_error()); $query = mysql_query("Select Date from " . $branch . $class . "_Dates where P1_Con = 'ok' or P2_Con = 'ok' or P3_Con = 'ok' or P4_Con = 'ok';") or die(mysql_error()); $nofd = mysql_num_rows($query); if ($nofd != 0) { $p = array("P1_A" => 0, "P1_P" => 0, "P2_A" => 0, "P2_P" => 0, "P3_A" => 0, "P3_P" => 0, "P4_A" => 0, "P4_P" => 0); $stats = array("Total" => 0, "Presents" => 0, "Absents" => 0); $strXML = "<graph caption='Period Wise Attendance Report' formatNumberScale='1' rotateValues='1' decimalPrecision='1' numberSuffix='%' xAxisName='Periods' yAxisName='Performance'>"; $datasetp = ''; while ($dates = mysql_fetch_array($query)) { //mysql_select_db($branchyear."_Attendance") or die(mysql_error()); $q = mysql_query("select `" . $dates[0] . "` from " . $branch . $class . "_Attendance where RNo='" . $RNo . "';"); while ($res = mysql_fetch_array($q)) { $values = explode(",", $res[0]); for ($i = 0; $i < count($values) - 1; $i++) { if (substr($values[$i], -1) == "P") { $stats["Presents"] += 1; $stats["Total"] += 1; } if (substr($values[$i], -1) == "A") { $stats["Absents"] += 1; $stats["Total"] += 1; } $p[$values[$i]] += 1; } } } $tr = ''; for ($i = 1; $i <= 4; $i++) { @($st = round($p["P" . $i . "_P"] / $nofd, 1) * 100 <= 50 ? "error" : "success"); @($tr .= '<tr> <td style="text-align:center;">' . $i . '</td> <td style="text-align:center;"> P' . $i . ' </td> <td style="text-align:center;"><b> ' . $nofd . '</b> </td> <td style="text-align:center;" class="text-success"><b> ' . $p["P" . $i . "_P"] . ' </b></td> <td style="text-align:center;" class="text-success"><b> ' . round($p["P" . $i . "_P"] / $nofd, 1) . ' </b></td> <td style="text-align:center;" class="text-error"><b> ' . $p["P" . $i . "_A"] . ' </b></td> <td style="text-align:center;" class="text-error"><b> ' . round($p["P" . $i . "_A"] / $nofd, 1) . ' </b></td> <td style="text-align:center;" class="text-' . $st . '"><b> <small>' . round($p["P" . $i . "_P"] / $nofd, 1) * 100 . ' % </small></b></td> </tr>'); @($datasetp .= "<set name='P" . $i . "' value='" . round($p["P" . $i . "_P"] / $nofd, 1) * 100 . "' color='" . $colors[$i] . "'/>"); } $strXML .= $datasetp . "</graph>"; echo '<br><h5 class="text-info">Chart Based Attendance Representaiton for Student - ' . $userid . '</h5><br>'; echo renderChart("assets/charts/FCF_Column3D.swf", "", $strXML, "FactorySum", 650, 380); echo <<<table_head \t\t<h5 class="text-info"> Period Wise Attendance Representation for Student - {$userid}</h5><br> \t\t<table class="table table-hover table-bordered " style="padding:0px;"> \t\t\t<thead> \t\t\t\t<tr> \t\t\t\t<th style="text-align:center;" valign="top"> SNo </th> <th style="text-align:center;" valign="top"> Period </th> <th style="text-align:center;" > Days </th> <th style="text-align:center;" > Presents </th> <th style="text-align:center;" > P/Day </th> <th style="text-align:center;" > Absents </th> <th style="text-align:center;" > A/Day </th><th style="text-align:center;" > Performance </th> \t\t\t\t</tr> \t\t\t</thead> \t\t\t<tbody> table_head; echo $tr; echo <<<tableend \t\t\t</tbody> \t\t</table> \t\t<table class='table table-hover table-bordered ' > \t\t<tr> \t\t\t<th\t><center>Short Name</center></th><th> <center>Long Name</center></th> \t\t\t<th\t><center>Short Name</center></th><th> <center>Long Name</center></th> \t\t</tr> \t\t<tr> \t\t\t<th><center>P/Day</center></th><td> No. of Presents for Day</td>\t \t\t\t<th><center>A/Day</center></th><td> No. of Absents for Day</td> \t\t</tr> \t\t \t\t </table> \t\t<br><div class='alert alert-info'><a class='close' data-dismiss='alert'>×</a><strong>CNYS </strong>: Classes Not Yet Started </div> \t<br> \t\t tableend; } else { echo "<br><br><h6 class='text-error text-center'> No Submissions Found<br></h6>"; } } /* End of Period Wise Attendance*/ /* SUbjects Wise Attendance */ if (strtolower($_SERVER["QUERY_STRING"]) == "sub") { //mysql_select_db($branchyear."_Subjects") or die(mysql_error()); $query = mysql_query("Select * from " . $branch . $class . "_Subjects where RNo='{$RNo}';") or die(mysql_error()); $subjectwise = mysql_fetch_array($query) or die(mysql_error()); $tr = ''; $strXML = "<graph caption='Subject Wise Attendance Report' formatNumberScale='1' rotateValues='1' decimalPrecision='1' numberSuffix='%' xAxisName='Subjects' yAxisName='Performance'>"; $datasetp = ''; $nc_cls = 0; $poor = array(); for ($i = 0; $i < count($allowed_subjects); $i++) { $tnoc = $subjectwise[$allowed_subjects[$i] . "_P"] + $subjectwise[$allowed_subjects[$i] . "_A"]; if ($tnoc == 0) { $nc_cls++; $performance = "N/A "; $st = "error"; $remarks = "CNYS"; } else { $performance = $subjectwise[$allowed_subjects[$i] . "_P"] / $tnoc * 100; $performance = round($performance, 1) . " %"; $st = $performance <= 50 ? "error" : "success"; if (round($performance, 1) >= 95) { $remarks = "Excellent"; } if (round($performance, 1) >= 90 && round($performance, 1) < 95) { $remarks = "Very Good"; } if (round($performance, 1) >= 80 && round($performance, 1) < 90) { $remarks = "Good"; } if (round($performance, 1) >= 70 && round($performance, 1) < 80) { $remarks = "Normal"; } if (round($performance, 1) >= 60 && round($performance, 1) < 70) { $remarks = "Average"; } if (round($performance, 1) >= 50 && round($performance, 1) < 60) { $remarks = "Bad"; $poor[$allowed_subjects[$i]] = $performance; } if (round($performance, 1) < 50) { $remarks = "Go Out"; $poor[$allowed_subjects[$i]] = $performance; } } $tr .= '<tr> <td style="text-align:center;">' . ($i + 1) . '</td> <td style="text-align:center;"> <b><small>' . $allowed_subjects[$i] . '</small></b> </td> <td style="text-align:center;"> <b>' . $tnoc . '</b> </td> <td style="text-align:center;" class="text-success"><b> ' . $subjectwise[$allowed_subjects[$i] . "_P"] . '</b> </td> <td style="text-align:center;" class="text-error"><b> ' . $subjectwise[$allowed_subjects[$i] . "_A"] . ' </b></td> <td style="text-align:center;" class="text-' . $st . '"><b>' . $performance . '</b></td> <td style="text-align:center;" class="text-' . $st . '"><b><small>' . $remarks . '</small></b></td> </tr>'; $datasetp .= "<set name='" . $allowed_subjects[$i] . "' value='" . round($performance, 1) . "' color='" . $colors[$i] . "'/>"; } $strXML .= $datasetp . "</graph>"; if ($nc_cls != count($allowed_subjects)) { echo '<br><h5 class="text-info">Chart Based Attendance Representaiton for Student - ' . $userid . '</h5><br>'; echo renderChart("assets/charts/FCF_Column3D.swf", "", $strXML, "FactorySum", 650, 380); echo <<<table_head \t\t<h5 class="text-info"> Subject Wise Attendance Representation for Student - {$userid}</h5><br> \t\t<table class="table table-hover table-bordered " style="padding:0px;"> \t\t\t<thead> \t\t\t\t<tr> \t\t\t\t<th style="text-align:center;" rowspan="2" valign="top"> SNo </th> <th style="text-align:center;" valign="top"> Subject </th> <th style="text-align:center;" > Classes </th> <th style="text-align:center;" > Presents </th> <th style="text-align:center;" > Absents </th> <th style="text-align:center;" > Performance </th> <th style="text-align:center;" > Remarks </th> \t\t\t\t</tr> \t\t\t</thead> \t\t\t<tbody> table_head; echo $tr; echo <<<tableend \t\t\t</tbody> \t\t</table> \t\t<br><div class='alert alert-info'><a class='close' data-dismiss='alert'>×</a><strong>CNYS </strong>: Classes Not Yet Started </div> \t<br> tableend; $st2 = ""; //print_r($poor); foreach ($poor as $key => $value) { $st2 .= $key . " "; } if (count($poor) != 0) { echo "<script type='text/javascript'>show_error('Your Attendance is Poor in {$st2} ');</script>"; } } else { echo "<br><br><h6 class='text-error text-center'> No Submissions Found<br></h6>"; } } /* End of SUbjects Wise Attendance*/ /* Checking for Wrong Keyword */ if (strtolower($_SERVER["QUERY_STRING"]) != "sub" and strtolower($_SERVER["QUERY_STRING"]) != "p") { echo "<script type='text/javascript'>document.location.href='./?sub';</script>"; } /* End of Checking for Wrong Keyword */ } /* End of Checking wheter he is a student or any other */ /////////////////////*********************/////////////// /* Start Checking wheter he is a CR or any other */ if ($type == "CR" or $type == "SA") { $branch2 = $branch . $class; /* Starting Period Wise Attendance */ if (strtolower($_SERVER["QUERY_STRING"]) == "p") { ////mysql_select_db($branchyear."_Dates") or die(mysql_error()); $query = mysql_query("Select Date from " . $branch . $class . "_Dates where P1_Con = 'ok' or P2_Con = 'ok' or P3_Con = 'ok' or P4_Con = 'ok';"); $nofd = mysql_num_rows($query); if ($nofd != 0) { $p = array("P1_A" => 0, "P1_P" => 0, "P2_A" => 0, "P2_P" => 0, "P3_A" => 0, "P3_P" => 0, "P4_A" => 0, "P4_P" => 0); $stats = array("Total" => 0, "Presents" => 0, "Absents" => 0); $strXML = "<graph caption='Period Wise Attendance Report' formatNumberScale='1' rotateValues='1' decimalPrecision='1' numberSuffix='%' xAxisName='Periods' yAxisName='Performance'>"; $datasetp = ''; while ($dates = mysql_fetch_array($query)) { //mysql_select_db($branchyear."_Attendance") or die(mysql_error()); $q = mysql_query("select `" . $dates[0] . "` from " . $branch . $class . "_Attendance where RNo='" . $RNo . "';"); while ($res = mysql_fetch_array($q)) { $values = explode(",", $res[0]); for ($i = 0; $i < count($values) - 1; $i++) { if (substr($values[$i], -1) == "P") { $stats["Presents"] += 1; $stats["Total"] += 1; } if (substr($values[$i], -1) == "A") { $stats["Absents"] += 1; $stats["Total"] += 1; } $p[$values[$i]] += 1; } } } $tr = ''; for ($i = 1; $i <= 4; $i++) { @($st = round($p["P" . $i . "_P"] / $nofd, 1) * 100 <= 50 ? "error" : "success"); @($tr .= '<tr> <td style="text-align:center;">' . $i . '</td> <td style="text-align:center;"> P' . $i . ' </td> <td style="text-align:center;"><b> ' . $nofd . '</b> </td> <td style="text-align:center;" class="text-success"><b> ' . $p["P" . $i . "_P"] . ' </b></td> <td style="text-align:center;" class="text-success"><b> ' . round($p["P" . $i . "_P"] / $nofd, 1) . ' </b></td> <td style="text-align:center;" class="text-error"><b> ' . $p["P" . $i . "_A"] . ' </b></td> <td style="text-align:center;" class="text-error"><b> ' . round($p["P" . $i . "_A"] / $nofd, 1) . ' </b></td> <td style="text-align:center;" class="text-' . $st . '"><b><small> ' . round($p["P" . $i . "_P"] / $nofd, 1) * 100 . ' % </small></b></td> </tr>'); @($datasetp .= "<set name='P" . $i . "' value='" . round($p["P" . $i . "_P"] / $nofd, 1) * 100 . "' color='" . $colors[$i] . "'/>"); } $strXML .= $datasetp . "</graph>"; echo '<br><h5 class="text-info">Chart Based Attendance Representaiton for CR ' . $branch2 . ' - ' . $userid . '</h5><br>'; echo renderChart("assets/charts/FCF_Column3D.swf", "", $strXML, "FactorySum", 650, 380); echo <<<table_head \t\t<h5 class="text-info"> Period Wise Attendance Representation for CR - {$userid} </h5><br> \t\t<table class="table table-hover table-bordered " style="padding:0px;"> \t\t\t<thead> \t\t\t\t<tr> \t\t\t\t<th style="text-align:center;" valign="top"> SNo </th> <th style="text-align:center;" valign="top"> Period </th> <th style="text-align:center;" > Days </th> <th style="text-align:center;" > Presents </th> <th style="text-align:center;" > P/Day </th> <th style="text-align:center;" > Absents </th> <th style="text-align:center;" > A/Day </th><th style="text-align:center;" > Performance </th> \t\t\t\t</tr> \t\t\t</thead> \t\t\t<tbody> table_head; echo $tr; echo <<<tableend \t\t\t</tbody> \t\t</table> \t\t</table> \t\t<br> \t\t<table class='table table-hover table-bordered ' > \t\t<tr> \t\t\t<th\t><center>Short Name</center></th><th> <center>Long Name</center></th> \t\t\t<th\t><center>Short Name</center></th><th> <center>Long Name</center></th> \t\t</tr> \t\t<tr> \t\t\t<th><center>P/Day</center></th><td> No. of Presents for Day</td>\t \t\t\t<th><center>A/Day</center></th><td> No. of Absents for Day</td> \t\t</tr> \t\t \t\t </table> \t\t<br><div class='alert alert-info'><a class='close' data-dismiss='alert'>×</a><strong>CNYS </strong>: Classes Not Yet Started </div> \t<br> tableend; } else { echo "<br><br><h6 class='text-error text-center'> No Submissions Found<br></h6>"; } } /* End of Period Wise Attendance*/ /* SUbjects Wise Attendance */ if (strtolower($_SERVER["QUERY_STRING"]) == "sub") { $branch2 = $branch . $class; //mysql_select_db($branchyear."_Subjects") or die(mysql_error()); $query = mysql_query("Select * from " . $branch . $class . "_Subjects where RNo='{$RNo}';") or die(mysql_error()); $subjectwise = mysql_fetch_array($query); $tr = ''; $strXML = "<graph caption='Subject Wise Attendance Report' formatNumberScale='1' rotateValues='1' decimalPrecision='1' numberSuffix='%' xAxisName='Subjects' yAxisName='Performance'>"; $datasetp = ""; $nc_cls = 0; $poor = array(); for ($i = 0; $i < count($allowed_subjects); $i++) { $tnoc = $subjectwise[$allowed_subjects[$i] . "_P"] + $subjectwise[$allowed_subjects[$i] . "_A"]; if ($tnoc == 0) { $nc_cls++; $performance = "N/A "; $st = "error"; $remarks = "CNYS"; } else { $performance = $subjectwise[$allowed_subjects[$i] . "_P"] / $tnoc * 100; $performance = round($performance, 1) . " %"; $st = $performance <= 50 ? "error" : "success"; if (round($performance, 1) >= 95) { $remarks = "Excellent"; } if (round($performance, 1) >= 90 && round($performance, 1) < 95) { $remarks = "Very Good"; } if (round($performance, 1) >= 80 && round($performance, 1) < 90) { $remarks = "Good"; } if (round($performance, 1) >= 70 && round($performance, 1) < 80) { $remarks = "Normal"; } if (round($performance, 1) >= 60 && round($performance, 1) < 70) { $remarks = "Average"; } if (round($performance, 1) >= 50 && round($performance, 1) < 60) { $remarks = "Bad"; $poor[$allowed_subjects[$i]] = $performance; } if (round($performance, 1) < 50) { $remarks = "Go Out"; $poor[$allowed_subjects[$i]] = $performance; } } $tr .= '<tr> <td style="text-align:center;">' . ($i + 1) . '</td> <td style="text-align:center;"> <b><small>' . $allowed_subjects[$i] . '</small></b> </td> <td style="text-align:center;"> <b>' . $tnoc . '</b> </td> <td style="text-align:center;" class="text-success"><b> ' . $subjectwise[$allowed_subjects[$i] . "_P"] . '</b> </td> <td style="text-align:center;" class="text-error"><b> ' . $subjectwise[$allowed_subjects[$i] . "_A"] . ' </b></td> <td style="text-align:center;" class="text-' . $st . '"><b>' . $performance . '</b></td> <td style="text-align:center;" class="text-' . $st . '"><b><small>' . $remarks . '</small></b></td> </tr>'; $datasetp .= "<set name='" . $allowed_subjects[$i] . "' value='" . round($performance, 1) . "' color='" . $colors[$i] . "'/>"; } $strXML .= $datasetp . "</graph>"; if ($nc_cls != count($allowed_subjects)) { echo '<br><h5 class="text-info">Chart Based Attendance Representaiton for CR ' . $branch2 . ' - ' . $userid . '</h5><br>'; echo renderChart("assets/charts/FCF_Column3D.swf", "", $strXML, "FactorySum", 650, 380); echo <<<table_head \t\t<h5 class="text-info"> Subject Wise Attendance Representation for CR - {$userid}</h5><br> \t\t<table class="table table-hover table-bordered " style="padding:0px;"> \t\t\t<thead> \t\t\t\t<tr> \t\t\t\t<th style="text-align:center;" rowspan="2" valign="top"> SNo </th> <th style="text-align:center;" valign="top"> Subject </th> <th style="text-align:center;" > Classes </th> <th style="text-align:center;" > Presents </th> <th style="text-align:center;" > Absents </th> <th style="text-align:center;" > Performance </th> <th style="text-align:center;" > Remarks </th> \t\t\t\t</tr> \t\t\t</thead> \t\t\t<tbody> table_head; echo $tr; echo <<<tableend \t\t\t</tbody> \t\t</table> \t\t<br><div class='alert alert-info'><a class='close' data-dismiss='alert'>×</a><strong>CNYS </strong>: Classes Not Yet Started </div> \t<br> tableend; $st2 = ""; //print_r($poor); foreach ($poor as $key => $value) { $st2 .= $key . " "; } if (count($poor) != 0) { echo "<script type='text/javascript'>show_error('Your Attendance is Poor in {$st2} ');</script>"; } } else { echo "<br><br><h6 class='text-error text-center'> No Submissions Found<br></h6>"; } } /* End of SUbjects Wise Attendance*/ /* Checking for Wrong Keyword */ if (strtolower($_SERVER["QUERY_STRING"]) != "sub" and strtolower($_SERVER["QUERY_STRING"]) != "p" and strtolower($_SERVER["QUERY_STRING"]) != strtolower($branch . $class . "/p") and strtolower($_SERVER["QUERY_STRING"]) != strtolower($branch . $class . "/sub")) { echo "<script type='text/javascript'>document.location.href='./?sub';</script>"; } /* End of Checking for Wrong Keyword */ } /* End of Checking wheter he is a CR or any other */ ////////////////////////////////****************//////////////// if ($type == "BA" or $type == "CR") { /* Start of Class Period Wise Attendance */ if (strtolower($_SERVER["QUERY_STRING"]) == strtolower($branch . $class . "/p")) { $branch2 = $branch . $class; //mysql_select_db($branchyear."_Dates") or die(mysql_error()); $query = mysql_query("Select Date from " . $branch . $class . "_Dates where P1_Con = 'ok' or P2_Con = 'ok' or P3_Con = 'ok' or P4_Con = 'ok';"); $nofd = mysql_num_rows($query); if ($nofd != 0) { $p = array("P1_A" => 0, "P1_P" => 0, "P2_A" => 0, "P2_P" => 0, "P3_A" => 0, "P3_P" => 0, "P4_A" => 0, "P4_P" => 0); $stats = array("Total" => 0, "Presents" => 0, "Absents" => 0); $strXML = "<graph caption='Period Wise Attendance Report of {$branch} {$class}' formatNumberScale='1' rotateValues='1' decimalPrecision='1' numberSuffix='%' xAxisName='Periods' yAxisName='Performance'>"; $datasetp = ''; while ($dates = mysql_fetch_array($query)) { //mysql_select_db($branchyear."_Attendance") or die(mysql_error()); $count_q = mysql_query("select count(`RNo`) from " . $branch . $class . "_Attendance;"); $countclass = mysql_fetch_array($count_q); $classcount = $countclass[0]; for ($init = 1; $init <= $classcount; $init++) { //mysql_select_db($branchyear."_Attendance") or die(mysql_error()); $q = mysql_query("select `" . $dates[0] . "` from " . $branch . $class . "_Attendance where RNo='" . $init . "';"); while ($res = mysql_fetch_array($q)) { $values = explode(",", $res[0]); for ($i = 0; $i < count($values) - 1; $i++) { if (substr($values[$i], -1) == "P") { $stats["Presents"] += 1; $stats["Total"] += 1; } if (substr($values[$i], -1) == "A") { $stats["Absents"] += 1; $stats["Total"] += 1; } $p[$values[$i]] += 1; } } } } $tr = ''; for ($i = 1; $i <= 4; $i++) { @($st = round($p["P" . $i . "_P"] / $nofd, 1) * 100 <= 50 ? "error" : "success"); @($tr .= '<tr> <td style="text-align:center;">' . $i . '</td> <td style="text-align:center;"> P' . $i . ' </td> <td style="text-align:center;"><b> ' . $nofd . '</b> </td> <td style="text-align:center;" class="text-success"><b> ' . $p["P" . $i . "_P"] . ' </b></td> <td style="text-align:center;" class="text-success"><b> ' . round($p["P" . $i . "_P"] / $nofd, 1) . ' </b></td> <td style="text-align:center;" class="text-error"><b> ' . $p["P" . $i . "_A"] . ' </b></td> <td style="text-align:center;" class="text-error"><b> ' . round($p["P" . $i . "_A"] / $nofd, 1) . ' </b></td> <td style="text-align:center;" class="text-' . $st . '"><b> <small>' . round($p["P" . $i . "_P"] / $nofd / $classcount * 100, 1) . ' %</small> </b></td> </tr>'); @($datasetp .= "<set name='P" . $i . "' value='" . round($p["P" . $i . "_P"] / $nofd / $classcount * 100, 1) . "' color='" . $colors[$i] . "'/>"); } $strXML .= $datasetp . "</graph>"; echo '<br><h5 class="text-info">Chart Based Periods Attendance Representaiton for Class ' . $branch2 . '</h5><br>'; echo renderChart("assets/charts/FCF_Column3D.swf", "", $strXML, "FactorySum", 650, 380); echo <<<table_header \t \t<table class="table table-hover table-bordered " style="padding:0px;"> \t <thead> \t\t<tr> \t\t<th style="text-align:center;" valign="top"> SNo </th> \t\t<th style="text-align:center;" valign="top"> Periods </th> \t\t<th style="text-align:center;" > Classes </th> \t\t<th style="text-align:center;" > Presents </th> \t\t<th style="text-align:center;" > P/C </th> \t\t<th style="text-align:center;" > Absents </th> \t\t<th style="text-align:center;" > A/C </th> \t\t<th style="text-align:center;" > Performance </th> \t\t</tr> \t </thead> \t <tbody> table_header; echo $tr; echo <<<tableend \t\t\t</tbody> \t\t</table> \t\t<br> \t\t<table class='table table-hover table-bordered ' > \t\t<tr> \t\t\t<th\t><center>Short Name</center></th><th> <center>Long Name</center></th> \t\t\t<th\t><center>Short Name</center></th><th> <center>Long Name</center></th> \t\t</tr> \t\t<tr> \t\t\t<th><center>P/C</center></th><td> No. of Presents for Class</td>\t \t\t\t<th><center>A/C</center></th><td> No. of Absents for Class</td> \t\t</tr> \t\t \t\t </table> \t\t<br><div class='alert alert-info'><a class='close' data-dismiss='alert'>×</a><strong>CNYS </strong>: Classes Not Yet Started </div> \t<br> tableend; } else { echo "<br><br><h6 class='text-error text-center'> No Submissions Found<br></h6>"; } } /* End of Class Period Wise Attendance */ /* Start of Class Subject Wise Attendance */ if (strtolower($_SERVER["QUERY_STRING"]) == strtolower($branch . $class . "/sub")) { $branch2 = $branch . $class; $tr = ''; $strXML = "<graph caption='Subject Wise Attendance Report' formatNumberScale='1' rotateValues='1' decimalPrecision='1' numberSuffix='%' xAxisName='Subjects' yAxisName='Performance'>"; $datasetp = ""; $nc_cls = 0; for ($i = 0; $i < count($allowed_subjects); $i++) { //mysql_select_db($branchyear."_Subjects") or die(mysql_error()); $queryp = mysql_query("Select sum(`" . $allowed_subjects[$i] . "_P`) as " . $allowed_subjects[$i] . "_P from " . $branch . $class . "_Subjects;"); $querya = mysql_query("Select sum(`" . $allowed_subjects[$i] . "_A`) as " . $allowed_subjects[$i] . "_A from " . $branch . $class . "_Subjects;"); $resultp1 = mysql_fetch_array($queryp); $resulta1 = mysql_fetch_array($querya); $resultp = $resultp1[0]; $resulta = $resulta1[0]; //mysql_select_db($branch."09_Subjects"); $tn = mysql_fetch_array(mysql_query("select `" . $allowed_subjects[$i] . "_P`,`" . $allowed_subjects[$i] . "_A` from " . $branch . $class . "_Subjects;")) or die(mysql_error()); $tnoc = $tn[0] + $tn[1]; if ($tnoc == 0) { $nc_cls++; $performance = 0; $performance1 = "N/A "; $st = "error"; $remarks = "CNYS"; } else { $performance = $resultp / ($resultp + $resulta) * 100; $performance1 = round($performance, 1) . " %"; $st = $performance <= 50 ? "error" : "success"; if (round($performance, 1) >= 95) { $remarks = "Excellent"; } if (round($performance, 1) >= 90 && round($performance, 1) < 95) { $remarks = "Very Good"; } if (round($performance, 1) >= 80 && round($performance, 1) < 90) { $remarks = "Good"; } if (round($performance, 1) >= 70 && round($performance, 1) < 80) { $remarks = "Normal"; } if (round($performance, 1) >= 60 && round($performance, 1) < 70) { $remarks = "Average"; } if (round($performance, 1) >= 50 && round($performance, 1) < 60) { $remarks = "Bad"; } if (round($performance, 1) < 50) { $remarks = "Go Out"; } } $tr .= '<tr> <td style="text-align:center;"> <small>' . ($i + 1) . '</small> </td> <td style="text-align:center;"> <small>' . $allowed_subjects[$i] . '</small> </td> <td style="text-align:center;"><b> <small>' . $tnoc . '</small></b> </td> <td style="text-align:center; class="text-success""><b><small> ' . $resultp . ' </small></b></td> <td style="text-align:center;" class="text-success"><b> <small>' . ($resultp != 0 ? round($resultp / $tnoc, 1) : 0) . '</small> </b></td> <td style="text-align:center;" class="text-error"><b> <small>' . $resulta . ' </small></b></td> <td style="text-align:center;" class="text-error"><b><small> ' . ($resulta != 0 ? round($resulta / $tnoc, 1) : 0) . '</small> </b></td> <td style="text-align:center;" class="text-' . $st . '"><b> <small>' . $performance1 . '</small> </b></td> <td style="text-align:center;" class="text-' . $st . '"><b> <small>' . $remarks . '</small> </b></td> </tr>'; $datasetp .= "<set name='" . $allowed_subjects[$i] . "' value='" . $performance . "' color='" . $colors[$i] . "'/>"; } $strXML .= $datasetp . "</graph>"; if ($nc_cls != count($allowed_subjects)) { echo '<br><h5 class="text-info">Chart Based Subjects Attendance Representaiton for Class ' . $branch2 . '</h5><br>'; echo renderChart("assets/charts/FCF_Column3D.swf", "", $strXML, "FactorySum", 650, 380); echo <<<table_header \t<table class="table table-hover table-bordered " style="padding:0px;"> \t<thead> \t<tr> \t<th style="text-align:center;" valign="top"> SNo </th> \t<th style="text-align:center;" valign="top"> Subject </th> \t<th style="text-align:center;" > Classes </th> \t<th style="text-align:center;" > Presents </th> \t<th style="text-align:center;" > P/C </th> \t<th style="text-align:center;" > Absents </th> \t<th style="text-align:center;" > A/C </th> \t<th style="text-align:center;" > Performance </th> \t<th style="text-align:center;" > Remarks </th> \t</tr> \t</thead> \t<tbody> table_header; echo $tr; echo <<<tableend \t\t\t</tbody> \t\t</table> \t\t<table class='table table-hover table-bordered ' > \t\t<tr> \t\t\t<th\t><center>Short Name</center></th><th> <center>Long Name</center></th> \t\t\t<th\t><center>Short Name</center></th><th> <center>Long Name</center></th> \t\t</tr> \t\t<tr> \t\t\t<th><center>P/C</center></th><td> No. of Presents for Class</td>\t \t\t\t<th><center>A/C</center></th><td> No. of Absents for Class</td> \t\t</tr> \t\t \t\t </table> \t\t \t\t<br><div class='alert alert-info'><a class='close' data-dismiss='alert'>×</a><strong>CNYS </strong>: Classes Not Yet Started </div> \t<br> tableend; } else { echo "<br><br><h6 class='text-error text-center'> No Submissions Found<br></h6>"; } } /* End of Class Subject Wise Attendance */ } /* Start Checking wheter he is a Branch Admin or any other */ if ($type == "BA") { /* Starting Period Wise Attendance */ if ($_SERVER["QUERY_STRING"] == "p") { $p = array(); $nofday = array(); $stats = array("Total" => 0, "Presents" => 0, "Absents" => 0); $strXML = "<graph caption='Class Wise Attendance Report' formatNumberScale='1' rotateValues='1' decimalPrecision='0' numberSuffix='%' xAxisName='Classes' yAxisName='Performance'>"; $class_period = array(); $noofperiods = array(); $cn = 0; for ($cln = 1; $cln < $classno + 1; $cln++) { //mysql_select_db($branchyear."_Dates") or die(mysql_error()); $query = mysql_query("Select Date from " . $branch . $cln . "_Dates where P1_Con = 'ok' or P2_Con = 'ok' or P3_Con = 'ok' or P4_Con = 'ok';") or die("Here"); $nofday[$branch . $cln] = mysql_num_rows($query); if ($nofday[$branch . $cln] == 0) { $cn++; } $class_period[$branch . $cln] = array("P1_A" => 0, "P1_P" => 0, "P2_A" => 0, "P2_P" => 0, "P3_A" => 0, "P3_P" => 0, "P4_A" => 0, "P4_P" => 0); $p[$branch . $cln] = array("A" => 0, "P" => 0); $noofperiods[$branch . $cln] = 0; while ($dates = mysql_fetch_array($query)) { //mysql_select_db($branchyear."_Attendance") or die(mysql_error()); $q = mysql_query("select `" . $dates[0] . "` from " . $branch . $cln . "_Attendance;"); $cou = 0; while ($res = mysql_fetch_array($q)) { $values = explode(",", $res[0]); if ($cou == 0) { $noofperiods[$branch . $cln] = $noofperiods[$branch . $cln] + (count($values) - 1); } $cou++; for ($i = 0; $i < count($values) - 1; $i++) { if (substr($values[$i], -1) == "P") { $stats["Presents"] += 1; $stats["Total"] += 1; $p[$branch . $cln]["P"] += 1; $class_period[$branch . $cln][$values[$i]]++; } if (substr($values[$i], -1) == "A") { $stats["Absents"] += 1; $stats["Total"] += 1; $p[$branch . $cln]["A"] += 1; $class_period[$branch . $cln][$values[$i]]++; } } } } } $tr = ''; $datasetp = ''; for ($i = 1; $i <= $classno; $i++) { @($ab_per = round($p[$branch . $i]["A"] / $noofperiods[$branch . $i], 1) <= 0 ? 'NA' : round($p[$branch . $i]["A"] / $noofperiods[$branch . $i], 1)); @($ab_day = round($p[$branch . $i]["A"] / $nofday[$branch . $i], 1) <= 0 ? 'NA' : round($p[$branch . $i]["A"] / $nofday[$branch . $i], 1)); @($pre_per = round($p[$branch . $i]["P"] / $noofperiods[$branch . $i], 1) <= 0 ? 'NA' : round($p[$branch . $i]["P"] / $noofperiods[$branch . $i], 1)); @($pre_day = round($p[$branch . $i]["P"] / $nofday[$branch . $i], 1) <= 0 ? 'NA' : round($p[$branch . $i]["P"] / $nofday[$branch . $i], 1)); @($perform = round($p[$branch . $i]["P"] / ($p[$branch . $i]["P"] + $p[$branch . $i]["A"]) * 100, 1)); if ($nofday[$branch . $i] == 0 || $noofperiods[$branch . $i] == 0) { $st = "error"; $remarks = "CNYS"; } else { $st = $p[$branch . $i]["P"] / ($p[$branch . $i]["P"] + $p[$branch . $i]["A"]) * 100 <= 50 ? 'error' : 'success'; if ((int) $perform >= 95) { $remarks = "Excellent"; } if ((int) $perform >= 90 && (int) $perform < 95) { $remarks = "VGood"; } if ((int) $perform >= 80 && (int) $perform < 90) { $remarks = "Good"; } if ((int) $perform >= 70 && (int) $perform < 80) { $remarks = "Normal"; } if ((int) $perform >= 60 && (int) $perform < 70) { $remarks = "Average"; } if ((int) $perform >= 50 && (int) $perform < 60) { $remarks = "Bad"; } if ((int) $perform < 50) { $remarks = "Go Out"; } } $tr .= '<tr> <td style="text-align:center;">' . $i . '</td> <td style="text-align:center;"><small>' . $branch . " " . $i . '</small></td> <td style="text-align:center;"><small>' . $nofday[$branch . $i] . '</small></td> <td style="text-align:center;"><small>' . $noofperiods[$branch . $i] . '</small></td> <td style="text-align:center;">4</td> <td style="text-align:center;" class="text-error"><b> <small>' . $p[$branch . $i]["A"] . '</small></b> </td> <td style="text-align:center;" class="text-error"><b> <small>' . $ab_per . '</small> </b></td> <td style="text-align:center;" class="text-error"><b> <small>' . $ab_day . '</small> </b></td> <td style="text-align:center;" class="text-success"><b><small> ' . $p[$branch . $i]["P"] . '</small></b> </td> <td style="text-align:center;" class="text-success"><b> <small>' . $pre_per . ' </small></b></td> <td style="text-align:center;" class="text-success"><b> <small>' . $pre_day . ' </small></b></td> <td style="text-align:center;" class="text-' . $st . '"><b> <small>' . round($perform, 0) . '%</small></b></td> <td style="text-align:center;" class="text-' . $st . '"><b> <small>' . $remarks . ' </small></b></td> </tr>'; $datasetp .= "<set name='" . $branch . $i . "' value='" . round($perform, 0) . "' color='" . $colors[$i] . "'/>"; } $strXML .= $datasetp . "</graph>"; if ($cn != $classno) { echo '<br><h5 class="text-info">Graph based Period Attendance representation for ' . $globalbranch . '</h5>'; echo renderChart("assets/charts/FCF_Column3D.swf", "", $strXML, "FactorySum", 650, 380); echo <<<tabhead \t\t<h5 class="text-info">Table based data representation </h5><br> \t <table class="table table-hover table-bordered " style="padding:0px;"> \t <thead> \t\t<tr> \t\t<th style="text-align:center;" valign="top"> SNo </th> \t\t<th style="text-align:center;" valign="top"> Class </th> \t\t<th style="text-align:center;" valign="top"> Days </th> \t\t<th style="text-align:center;" valign="top"> Periods </th> \t\t<th style="text-align:center;" valign="top"> P/Day </th> \t\t<th style="text-align:center;" > A </th> \t\t<th style="text-align:center;" > A/P </th> \t\t<th style="text-align:center;" > A/D </th> \t\t<th style="text-align:center;" > P </th> \t\t<th style="text-align:center;" > P/P </th> \t\t<th style="text-align:center;" > P/D </th> \t\t<th style="text-align:center;" > % </th> \t\t<th style="text-align:center;" > Remarks </th> \t\t</tr> \t\t \t </thead> \t <tbody> tabhead; echo $tr; echo <<<tableend \t\t\t\t</tbody> \t\t\t</table> \t\t\t<br> \t\t\t<table class='table table-hover table-bordered ' > \t\t<tr> \t\t\t<th\t><center>Short Name</center></th><th> <center>Long Name</center></th> \t\t\t<th\t><center>Short Name</center></th><th> <center>Long Name</center></th> \t\t</tr> \t\t<tr> \t\t\t<th><center>P</center></th><td> No. of Presents</td>\t \t\t\t<th><center>P/D</center></th><td> No. of Presents for Day</td> \t\t</tr> \t\t<tr>\t \t\t\t<th><center>A</center></th><td> No. of Absents</td> \t\t\t<th><center>A/D</center></th><td> No of Absents for Day</td> \t\t</tr> \t\t<tr>\t \t\t\t<th><center>P/P</center></th><td> No. of Absents for Periods</td> \t\t\t<th><center>A/P</center></th><td> No of Absents for Periods</td> \t\t</tr> \t\t<tr>\t \t\t\t<th><center>P/Day</center></th><td> No. of Periods for Day</td> \t\t\t<th><center>%</center></th><td> Performace in %</td> \t\t</tr> \t\t </table> \t\t\t<br><div class='alert alert-info'><a class='close' data-dismiss='alert'>×</a><strong>CNYS </strong>: Classes Not Yet Started </div> \t<br> tableend; } else { echo "<br><br><h6 class='text-error text-center'> No Submissions Found<br></h6>"; } } /* End of Period Wise Attendance*/ /* Start of Subject Wise Attendance */ if ($_SERVER["QUERY_STRING"] == "sub") { $tr = ''; $strXML = "<graph caption='Subject Wise Attendance Report' formatNumberScale='1' rotateValues='1' decimalPrecision='1' numberSuffix='%' xAxisName='Subjects' yAxisName='Performance'>"; $datasetp = ""; $sub_per = array(); $cnt = 0; for ($j = 1; $j <= $classno; $j++) { $sub_per[$branch . $j] = array(); for ($i = 0; $i < count($allowed_subjects); $i++) { //mysql_select_db($branchyear."_Subjects") or die(mysql_error()); $queryp = mysql_query("Select sum(`" . $allowed_subjects[$i] . "_P`) as " . $allowed_subjects[$i] . "_P from " . $branch . $j . "_Subjects;"); //die $querya = mysql_query("Select sum(`" . $allowed_subjects[$i] . "_A`) as " . $allowed_subjects[$i] . "_A from " . $branch . $j . "_Subjects;"); //die @($resultp1 = mysql_fetch_array($queryp)); //die @($resulta1 = mysql_fetch_array($querya)); //die $resultp = $resultp1[0]; $resulta = $resulta1[0]; if ($resultp + $resulta == 0) { $cnt++; } @($sub_per[$branch . $j][$allowed_subjects[$i]] = $resultp / ($resultp + $resulta) * 100); } } if ($cnt != $classno * count($allowed_subjects)) { for ($k = 1; $k <= $classno; $k++) { $tr .= '<tr> <td style="text-align:center;"> ' . $k . ' </td> <td style="text-align:center;"><small> ' . $branch . $k . '</small> </td>'; $sub_count = 0; for ($l = 0; $l < count($allowed_subjects); $l++) { if (round($sub_per[$branch . $k][$allowed_subjects[$l]], 1) == 0) { $sub_count++; } @($tr .= '<td style="text-align:center;"><b> ' . round($sub_per[$branch . $k][$allowed_subjects[$l]], 1) . '</b> </td>'); } @($tr .= '<td style="text-align:center; class="text-success""><b> ' . round(array_sum($sub_per[$branch . $k]) / abs(count($allowed_subjects) - $sub_count), 1) . ' </b></td> '); @($performance = round(array_sum($sub_per[$branch . $k]) / abs(count($allowed_subjects) - $sub_count), 1)); $st = $performance <= 50 ? "error" : "success"; if (round($performance, 1) >= 95) { $remarks = "Excellent"; } if (round($performance, 1) >= 90 && round($performance, 1) < 95) { $remarks = "Very Good"; } if (round($performance, 1) >= 80 && round($performance, 1) < 90) { $remarks = "Good"; } if (round($performance, 1) >= 70 && round($performance, 1) < 80) { $remarks = "Normal"; } if (round($performance, 1) >= 60 && round($performance, 1) < 70) { $remarks = "Average"; } if (round($performance, 1) >= 50 && round($performance, 1) < 60) { $remarks = "Bad"; } if (round($performance, 1) < 50) { $remarks = "Go Out"; } //echo $sub_count; @($tr .= '<td style="text-align:center;" class="text-' . $st . '"><b><small> ' . $remarks . ' </small></b></td> </tr>'); @($datasetp .= "<set name='" . $branch . $k . "' value='" . array_sum($sub_per[$branch . $k]) / abs(count($allowed_subjects) - $sub_count) . "' color='" . $colors[$k] . "'/>"); } $strXML .= $datasetp . "</graph>"; $branch2 = $branch . $class; echo '<br><h5 class="text-info">Graph based Subjects Attendance representation for ' . $globalbranch . ' </h5>'; echo renderChart("assets/charts/FCF_Column3D.swf", "", $strXML, "FactorySum", 650, 380); echo <<<table_header \t<h5 class="text-info">Table based data representation </h5><br> \t<table class="table table-hover table-bordered " style="padding:0px;"> \t<thead> \t<tr> \t<th style="text-align:center;" valign="top"> SNo </th> \t<th style="text-align:center;" valign="top"> Class </th> table_header; for ($i = 0; $i < count($allowed_subjects); $i++) { echo '<th style="text-align:center;" valign="top">' . $allowed_subjects[$i] . '</th>'; } echo <<<table_1 \t<th style="text-align:center;" > % </th> \t<th style="text-align:center;" > Remarks </th> \t</tr> \t</thead> \t<tbody> table_1; echo $tr; echo <<<tableend \t\t\t</tbody> \t\t</table> \t\t<br> tableend; } else { echo "<br><br><h6 class='text-error text-center'> No Submissions Found<br></h6>"; } } /* End of Subject Wise Attendance */ if (strtolower($_SERVER["QUERY_STRING"]) == "") { echo "<script type='text/javascript'>document.location.href='./?sub';</script>"; } } /* End of Checking wheter he is Branch Admin or any other */ echo <<<b \t \t</div> \t</div> \t<div class='span3'> b; sidepanel(); /* Creating a Sidepanel for CR */ /* END Creating a Sidepanel for CR */ echo "</div></div></div>"; display_footer(); echo "\n</body>\n</html>"; } }
function generate_attendance($title) { if (!check("CR") && !check("BA")) { header('location:./login.php'); } else { if (!check_day()) { include 'config/globals.php'; $p = $_SERVER['QUERY_STRING']; $reg = "/^" . $globalbranch . "[1-" . $classno . "]{1}\$/"; if (preg_match($reg, $p)) { include 'config/db.php'; include 'config/settings.php'; include 'config/globals.php'; echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu(); echo <<<a \t\t\t \t<div class="container" style="margin-top:-10px;"><br> \t\t\t<div id="error" style="display:none;margin-top:10px;"></div> \t\t\t a; $table = ''; //$spread=''; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); $userid = $_SESSION['UserId']; $q = "select Branch,Class,Position from {$table} where Id = '{$userid}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); if ($row['Position'] == "BA") { $branch = $globalbranch; $class = substr($p, -1); } else { $branch = $row['Branch']; $class = $row['Class']; $class1 = substr($p, -1); if ($class1 != $class) { //echo 'i am in'; echo "<script type='text/javascript'>show_error('Error: Not authorised to access {$branch}{$class1} details.');</script>"; } } $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $class_total = mysql_num_rows(mysql_query("select `Id` from {$table}")); $sample = mt_rand(1, $class_total); $da = date('d-m-Y'); $date = date('d-m-Y'); echo <<<a \t\t\t \t\t\t \t\t \t\t\t\t\t<div class="well well-large" style="background:#FFF;"> a; $tablen = $branch . $class . "_Dates"; if (isset($_POST["submit"])) { $remain = mysql_fetch_array(mysql_query("select isnull(P1_Con),isnull(P2_Con),isnull(P3_Con),isnull(P4_Con) from {$tablen};")); $org = array(); foreach ($remain as $key => $value) { if ($value == 1 && is_int($key)) { $org[] = $key + 1; } } for ($no = 1; $no <= $class_total; $no++) { for ($kl = 0; $kl < count($org); $kl++) { $lll = $org[$kl]; $resss = explode("_", $_POST["P" . $lll . "_" . $no]); $dddd = $branch . $class . "_Cache"; $poss = $da . "_P" . $lll; mysql_query("update {$dddd} set `{$poss}`='{$resss[0]}' where RNo={$no};") or die(mysql_error()); } } } $dbname = $branchyear . '_Dates'; $table = $branch . $class . '_Dates'; //if(!mysql_select_db($dbname)) die(mysql_error()); $remaining = array(); $j = 0; $remaining1 = array(); $j1 = 0; $confired = array(); $j2 = 0; $confired1 = array(); $j3 = 0; for ($i = 1; $i <= 4; $i++) { $tmp = "P" . $i; $tmp1 = "P" . $i . "_Con"; $q = mysql_query("select ISNUll(`{$tmp}`) as `P{$i}`,ISNUll(`{$tmp1}`) as `P" . $i . "_C` from {$table} where Date = '{$da}' ") or die(mysql_error()); $res = mysql_fetch_array($q); if ($res["P" . $i]) { $remaining[$j] = "P" . $i; $j++; } else { $remaining1[$j1] = "P" . $i; $j1++; } if ($res["P" . $i . "_C"]) { $confired[$j2] = "P" . $i; $j2++; } else { $confired1[$j3] = "P" . $i; $j3++; } } $dates1 = getdate(strtotime($da)); $day = substr($dates1["weekday"], 0, 3); $dbname = $branchyear . '_TimeTable'; $table = $branch . $class . '_TimeTable'; //if(!mysql_select_db($dbname)) die(mysql_error()); $ti = mysql_query("SELECT DayPeriod,{$day} from {$table};") or die(mysql_error()); $subjects = array(); while ($da1 = mysql_fetch_array($ti)) { $subjects[$da1[0]] = $da1[1]; } //print_r($subjects); //$sub = $subjects[$p]; //echo "<h5 style='text-align:center;'> Attendance Submission Details - $branch $class - $date</h5><br>"; $clds = $branch . $class; echo <<<a \t\t\t \t\t\t\t<div id="step1" class="span4"> \t\t\t\t\t<h5 class='text-info'>Today's Attendance Submission Details </h5> \t\t\t\t\t<h6>     -   Listing Data submitted from CR @ {$branch} {$class} </h6><br> \t\t\t\t</div> \t\t\t\t<div id="side1" class="span7" > \t\t\t\t\t<h6 class='text-right'><a href='./?sub'><i class='icon-home'></i> Home </a> </h6> a; if ($row['Position'] == "BA") { echo <<<a \t\t\t\t\t<h6 class='text-right'> a; for ($cl = 1; $cl <= $classno; $cl++) { echo "<a href='?{$globalbranch}{$cl}'>{$globalbranch}{$cl}</a> "; } echo <<<a \t\t\t\t\t</h6> a; } echo <<<a \t\t\t\t</div> \t\t\t a; $dbname = $branchyear . '_Dates'; $table = $branch . $class . '_Dates'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select Date from {$table} where Date = '{$da}'") or die(mysql_error()); if (count($remaining1) != 0 && mysql_num_rows($q) != 0) { echo '<table class="table table-hover table-bordered " style="padding:0px;"> <thead> <tr> <th style="text-align:center;" rowspan="2" valign="top"> RNo </th> <th style="text-align:center;" rowspan="2" valign="top"> Id </th> <th style="text-align:center;" > P1 </th> <th style="text-align:center;" > P2 </th> <th style="text-align:center;" > P3 </th> <th style="text-align:center;" > P4 </th> <th style="text-align:center;" rowspan=2> Presents </th> <th rowspan=2 style="text-align:center;" > Absents </th> </tr> <tr> <th style="text-align:center;" > ' . $subjects['P1'] . ' </th> <th style="text-align:center;" > ' . $subjects['P2'] . ' </th> <th style="text-align:center;" > ' . $subjects['P3'] . ' </th> <th style="text-align:center;" > ' . $subjects['P4'] . ' </th> </tr> <form action="edit.php?' . $clds . '" method="POST"> </thead> <tbody>'; $Rnos = array(); $uid = array(); $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; $q = mysql_query("select Id, RNo from {$table};") or die(mysql_error()); while ($res = mysql_fetch_array($q)) { $uid[$res['RNo']] = $res['Id']; } for ($s = 0; $s < count($remaining1); $s++) { $p1 = $remaining1[$s]; if (in_array($p1, $confired1)) { $period = $p1; $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; $q = mysql_query("select RNo,Id,`{$date}` from {$table};") or die(mysql_error()); $aindex = 0; $pindex = 0; while ($res = mysql_fetch_array($q)) { $z = explode(",", $res[$date]); for ($m = 0; $m < count($z); $m++) { $y = explode("_", $z[$m]); if ($y[0] == $period) { if ($y[1] == "A") { $Rnos[$p1]['Absents'][$aindex] = $res[0]; $aindex++; } else { $Rnos[$p1]['Presents'][$pindex] = $res[0]; $pindex++; } } } } } else { $da = date('d-m-Y'); $a = $da . '_' . $p1; $dbname = $branchyear . '_Cache'; $table = $branch . $class . '_Cache'; $q3 = mysql_query("SELECT RNo, `" . $a . "` FROM {$table}") or die(mysql_error()); $aindex = 0; $pindex = 0; while ($individual = mysql_fetch_array($q3)) { if ($individual[$a] == "A") { $Rnos[$p1]["Absents"][$aindex] = $individual["RNo"]; $aindex++; } if ($individual[$a] == "P") { $Rnos[$p1]["Presents"][$pindex] = $individual["RNo"]; $pindex++; } } } } $tot = array('A' => 0, 'P' => 0); $table_cl = $branch . $class . '_Dates'; $remain = mysql_fetch_array(mysql_query("select isnull(P1_Con),isnull(P2_Con),isnull(P3_Con),isnull(P4_Con) from {$table_cl};")); for ($w = 1; $w <= $class_total; $w++) { $tr2 = '<tr><td style="text-align:center;">' . $w . '</td><td style="text-align:center;"> ' . $uid[$w] . '</td>'; echo $tr2; $pc = 0; $ac = 0; for ($l = 1; $l <= 4; $l++) { $pl = "P" . $l; if (in_array($pl, $remaining1)) { if (array_key_exists("Absents", $Rnos[$pl]) && in_array($w, $Rnos[$pl]['Absents'])) { $disp = $remain[$l - 1] == 1 ? '<input type="text" name="' . $pl . "_" . $w . '" class="input-mini" value="A"></input>' : '<i class="icon-remove"></i>'; echo '<td style="text-align:center;" class="text-error"><b>' . $disp . '</b></td>'; $ac++; } else { $disp = $remain[$l - 1] == 1 ? '<input type="text" name="' . $pl . "_" . $w . '" class="input-mini" value="P"></input>' : '<i class="icon-ok"></i>'; echo '<td style="text-align:center;" class="text-success"><b>' . $disp . '</b></td>'; $pc++; } } else { echo '<td></td>'; } } $tot['A'] += $ac; $tot['P'] += $pc; echo <<<a \t\t\t\t\t\t<td style="text-align:center;" class="text-success"><b> {$pc} </b> </td> \t\t\t\t\t\t<td style="text-align:center;" class="text-error"><b> {$ac} </b></td> \t\t\t\t\t</tr> \t\t\t\t\t a; } echo "<tr><td colspan=6 style='text-align:center;'><b>Total</b></td><td style='text-align:center;' class='text-success'><b>" . $tot['P'] . "</b></td><td style='text-align:center;' class='text-error'><b>" . $tot['A'] . "</b></td></tr>"; echo "</tbody></table>"; echo "<center><button type='submit' name='submit' class='btn btn-primary'><i class='icon-upload'></i> Update Now </button></center></form>"; echo "</div></div>"; } else { echo "<br><h6><span class='text-error'><br><br><br>No Submissions found till now ...</span></h6><br></div>"; } display_footer(); echo "\n</body>\n</html>"; @mysql_close($con); } else { echo "<script type='text/javascript'>document.location.href='404.php';</script>"; } } else { noservice(); } } }
function searchStudents($title) { if (!check_login()) { header("location:login.php"); } else { include 'config/globals.php'; $page = $_GET['p']; $key = $_GET['q']; //$queries = explode('&',$q); $pagereg = '/^[\\d]+$/'; $keyreg = '/^[\\w]*$/'; if (preg_match($pagereg, $page)) { include 'config/db.php'; include 'config/settings.php'; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "<body>\n"; menu(); $id_check = isset($_GET['id']) ? "checked='checked'" : ''; $name_check = isset($_GET['name']) ? "checked='checked'" : ''; echo <<<search_form \t\t\t\t\t<div class="container" style="margin-top:-15px;"><br> \t\t\t\t\t\t<div id="error"></div> \t\t\t\t\t\t<div class="row"> \t\t\t\t\t\t\t<div class="span12"> \t\t\t\t\t\t\t\t<div class="well well-large" style="background:#FFF"> \t\t\t\t\t\t\t\t\t<div class="row"> \t\t\t\t\t\t\t\t\t\t<div id="step1" class="span8"> \t\t\t\t\t\t\t\t\t\t\t<a><h5>Search students @ {$globalbranch} </h5></a> \t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t\t<div id="page1" class="span3"> \t\t\t\t\t\t\t\t\t\t\t<a class="pull-right"><h6 >Page {$page} </h6></a> \t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t<div class="row"> \t\t\t\t\t\t\t\t\t\t<div class='span2'></div> \t\t\t\t\t\t\t\t\t\t<div class=span7> \t\t\t\t\t\t\t\t\t\t\t<div class="input-append"><br> \t\t\t\t\t\t\t\t\t\t\t\t<form action="" method='GET' onsubmit = "return searchStudents();"> \t\t\t\t\t\t\t\t\t\t\t\t\t<input class="input-xxlarge" id="query" type="text" placeholder="Seach" name="q" value='{$key}'/> \t\t\t\t\t\t\t\t\t\t\t\t\t<input type='submit' value="Search" class="btn btn-primary" /><br> \t\t\t\t\t\t\t\t\t\t\t\t\t<label class='checkbox inline'>Search by </label> \t\t\t\t\t\t\t\t\t\t\t\t\t<label class="checkbox inline"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t<input type="checkbox" id="ID" value="id" {$id_check} name='id'> Id \t\t\t\t\t\t\t\t\t\t\t\t\t</label> \t\t\t\t\t\t\t\t\t\t\t\t\t<label class="checkbox inline"> \t\t\t\t\t\t\t\t\t\t\t\t\t<input type="checkbox" id="NAME" value="name" {$name_check} name='name'> Name \t\t\t\t\t\t\t\t\t\t\t\t\t</label> \t\t\t\t\t\t\t\t\t\t\t\t\t<input type='hidden' value="1" class="btn btn-primary" name='p' style="visibility:hidden;" /> \t\t\t\t\t\t\t\t\t\t\t\t</form> \t\t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t</div> search_form; if (isset($_GET['q']) && strlen($_GET['q']) != 0) { include 'config/globals.php'; include 'config/db.php'; include 'config/settings.php'; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); //echo $queries[0]; $keyword = htmlentities(mysql_real_escape_string($_GET['q'])); $id = isset($_GET['id']) ? $_GET['id'] : ''; $name = isset($_GET['name']) ? $_GET['name'] : ''; if (($id == null or $id == "") and $name == "name") { $query = "SELECT Id,Name,Branch,Class,Gender FROM " . $table . " WHERE Name like '%{$keyword}%' and (Position='S' or Position='CR');"; } elseif (($name == null or $name == "") and $id == "id") { $query = "SELECT Id,Name,Branch,Class,Gender FROM " . $table . " WHERE Id like '%{$keyword}%' and (Position='S' or Position='CR');"; } elseif ($name == "name" and $id == "id") { $query = "SELECT Id,Name,Branch,Class,Gender FROM " . $table . " WHERE Id like '%{$keyword}%' or Name like '%{$keyword}%' and (Position='S' or Position='CR');"; } $exec = mysql_query($query) or die(mysql_error()); $total = mysql_num_rows($exec); if ($total > 0) { echo <<<results \t\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t\t\t<h6>Search results for : <span class="text-success"><b>"{$keyword}"</b> \t\t\t\t\t\t\t\t\t\t</span>   <small><span class="text-error" >{$total} record(s) Found</span></small> </h6> \t\t\t\t\t\t\t\t\t\t<table class="table table-hover table-bordered " style="padding:0px;"> \t\t\t\t\t\t\t\t\t\t\t<thead> \t\t\t\t\t\t\t\t\t\t\t\t<tr> \t\t\t\t\t\t\t\t\t\t\t\t\t<th style="text-align:center;" class="span1"> ID # </th> \t\t\t\t\t\t\t\t\t\t\t\t\t<th style="text-align:center;" class="span3"> Name </th> \t\t\t\t\t\t\t\t\t\t\t\t\t<th style="text-align:center;" class="span1"> Class</th> \t\t\t\t\t\t\t\t\t\t\t\t\t<th class="span1" style="text-align:center;" >Gender</th> \t\t\t\t\t\t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t\t\t\t\t</thead> \t\t\t\t\t\t\t\t\t\t\t<tbody> results; $page = $_GET['p']; $prev = $page - 1; $next = $page + 1; $per_page = 10; $slimit = ($page - 1) * 10; $lastpage = ceil($total / $per_page); if (($id == null or $id == "") and $name == "name") { $query1 = "SELECT Id,Name,Branch,Class,Gender FROM " . $table . " WHERE Name like '%{$keyword}%' and (Position='S' or Position='CR') LIMIT {$slimit},{$per_page};"; } elseif (($name == null or $name == "") and $id == "id") { $query1 = "SELECT Id,Name,Branch,Class,Gender FROM " . $table . " WHERE Id like '%{$keyword}%' and (Position='S' or Position='CR') LIMIT {$slimit},{$per_page};"; } elseif ($name == "name" and $id == "id") { $query1 = "SELECT Id,Name,Branch,Class,Gender FROM " . $table . " WHERE Id like '%{$keyword}%' or Name like '%{$keyword}%' and (Position='S' or Position='CR') LIMIT {$slimit},{$per_page};"; } $exec1 = mysql_query($query1) or die(mysql_error()); $ppage = mysql_num_rows($exec1); for ($i = 0; $i < $ppage; $i++) { $record = mysql_fetch_array($exec1); $lnk = "./students.php?" . $record[0] . "/sub"; echo <<<show \t\t\t\t\t\t\t\t<tr onclick="document.location.href='{$lnk}';" style='cursor:pointer;'> \t\t\t\t\t\t\t\t\t<td style="text-align:center;" class="span1">{$record['0']}</td> \t\t\t\t\t\t\t\t\t<td class="span3">{$record['1']}</td> \t\t\t\t\t\t\t\t\t<td style="text-align:center;" class="span1">{$record['2']}{$record['3']}</td> \t\t\t\t\t\t\t\t\t<td class="span1" style="text-align:center;" >{$record['4']}</td> \t\t\t\t\t\t\t\t</tr> show; } echo <<<next \t\t\t\t\t\t\t</tbody> \t\t\t\t\t\t\t</table>\t\t\t \t\t\t\t\t\t\t \t\t\t\t\t\t\t<div class="pagination pagination-centered"> \t\t\t\t\t\t\t<ul> next; $lnk = "?q=" . $key; $lnk .= isset($_GET['id']) ? "&id=id" : ''; $lnk .= isset($_GET['name']) ? "&name=name" : ''; if ($page < $total / 10 + 1) { if ($page != 1) { echo "<li><a href='" . $lnk . "&p={$prev}'>← Prev</a></li>"; } else { echo "<li class='disabled'><a>← Prevt</a></li>"; } if ($lastpage <= 10) { for ($i = 1; $i <= $lastpage; $i++) { if ($page == $i) { echo "<li class='active'><a href='" . $lnk . "&p={$i}'><b class='text-error'> {$i}</b></a></li>"; } else { echo "<li><a href='" . $lnk . "&p={$i}'>{$i}</a></li>"; } } } else { $init1 = $page % 10 == 0 ? (floor($page / 10) - 1) * 10 + 1 : floor($page / 10) * 10 + 1; // total no of records total pages pages range //echo $page/10; echo $lastpage/10; $end1 = floor(($page - 1) / 10) == floor($lastpage / 10) ? $lastpage : ceil($page / 10) * 10; for ($i = $init1; $i <= $end1; $i++) { if ($page == $i) { echo "<li class='active'><a href='" . $lnk . "&p={$i}'><b class='text-error'> {$i}</b></a></li>"; } else { echo "<li><a href='" . $lnk . "&p={$i}'>{$i}</a></li>"; } } } if ($page != $lastpage) { echo "<li><a href='" . $lnk . "&p={$next}'>Next →</a></li>"; } else { echo "<li class='disabled'><a>Next →</a></li>"; } } echo <<<next \t\t\t\t\t\t\t\t</ul> \t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t</div> next; } else { echo "<center><p>No search results found.</p></center>"; } } else { echo "<center><b><i>Specify search key word</i></b></center>"; } echo "</div>"; display_footer(); echo "\n</div></body>\n</html>"; } else { echo "Error : Invalid syntax found in URL<br>"; } } }
function send_notice($title) { if (!check('BA') || !check('BA')) { header('location:./?sub'); } else { include 'config/globals.php'; $to = $_SERVER['QUERY_STRING']; $reg = "/^all|allcrs|" . $globalbranch . "[1-" . $classno . "]{1}\$/"; if (preg_match($reg, $to)) { include 'config/db.php'; include 'config/settings.php'; $dbname = $branchyear . '_Logs'; $table = $branchyear . '_Notifications'; //if(!mysql_select_db($dbname)) die(mysql_error()); echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo <<<js \t\t\t\t<script type='text/javascript'> \t\t\t\t\tfunction Preview(id,val){ \t\t\t\t\t\tdocument.getElementById(id).innerHTML=val; \t\t\t\t\t} \t\t\t\t</script> js; echo "\n<body>"; menu(); echo <<<a \t\t\t\t<div class="container" style="margin-top:-15px;"> \t\t\t\t\t<br> \t\t\t\t\t<div id="error"></div> \t\t\t\t\t<div class="row"> \t\t\t\t\t\t<div class="span9"> \t\t\t\t\t\t\t<div class="well well-large" style="background:#FFF;"> \t\t\t\t\t\t\t\t<div id="stpe2_P1"> \t\t\t\t\t\t\t\t\t<h5>Send Notice @ {$to} :</h5> \t\t\t\t\t\t\t\t\t<h6>     -   Fill out below details </h6> \t\t\t\t\t\t\t\t\t<!--<h5>Period 1 : </h5>--> \t\t\t\t\t\t\t\t\t<form enctype="multipart/form-data" method="POST" action="" onSubmit="return send_notice();"> a; if ($to != "all" and $to != "allcrs") { echo <<<to \t\t\t\t\t\t<h6 > To :</h6> \t\t\t\t\t\t<label class="radio inline"> \t\t\t\t\t\t<input type="radio" id='CRs' value="CRs" name="to" onclick="Preview(this.name,this.value);"> CRs \t\t\t\t\t</label> \t\t\t\t\t<label class="radio inline"> \t\t\t\t\t\t<input type="radio" id='Students' value="Students" name="to" onclick="Preview(this.name,this.value);"> Students \t\t\t\t\t</label><br><br> to; } else { echo "<br>"; } echo <<<a \t\t\t\t<h6> Subject :</h6> \t\t\t\t<input type="text" class="span8" placeholder="Subject" id='subject' name='sub' onkeyup="Preview(this.name,this.value);"><br> \t\t\t\t<h6> Message :</h6> \t\t\t\t<textarea class="span8" id='message' name='mes' style="resize:vertical;height:90px;" onkeyup="Preview(this.name,this.value);" placeholder="Type your message here"></textarea> \t\t\t\t<br> \t\t\t\t<h6> Attachment (Max : 100 MB):</h6> \t\t\t\t<input type="file" class="span8" placeholder="Attach a File Here" name='attachment'><br>\t\t\t\t \t\t\t</div> \t\t\t<div id="stpe3"> \t\t\t\t<a><h5>Preview : </h5></a><br> \t\t\t\t<!--<h6>     -   Confirm Your Notice </h6>--> \t\t\t\t<div class="row"> \t\t\t\t\t<div class="span8"> \t\t\t\t\t\t<table class="table table-hover table-bordered" > \t\t\t\t\t\t\t<tbody> \t\t\t\t\t\t\t\t<tr> <th class="span2" > To </th> a; if ($to == "all") { echo "<td class='span6' id='to'> ALL </td> </tr>"; } else { if ($to == "allcrs") { echo "<td class='span6' id='to'> ALL CR's</td> </tr>"; } else { echo "<td class='span6' id='to'> To address </td> </tr>"; } } echo <<<a \t\t\t\t\t\t\t<tr> <th class="span2" > Suject </th> <td class="span6" id='sub'> Notification subject </td> </tr> \t\t\t\t\t\t\t<tr> <th class="span2" > Message </th> <td class="span6" id='mes'> Messasge </td> </tr> \t\t\t\t\t\t</tbody> \t\t\t\t\t</table> \t\t\t\t</div> \t\t\t</div><br> \t\t\t<input type="submit" class="btn btn-primary" value="Confirm & Send →" name="send" /> \t\t\t</form> \t\t</div> \t\t<br> \t</div> </div> <div class="span3"> a; classes($classno, $globalbranch); echo "</div></div></div>"; display_footer(); echo "\n</body>\n</html>"; } else { echo "<script type='text/javascript'>document.location.href='404.php';</script>"; } } }
function homepage($title) { if (!check("BA") || !check('BA')) { header('location:login.php'); } else { include "config/globals.php"; include 'config/db.php'; include 'config/settings.php'; $qs = $_SERVER["QUERY_STRING"]; $reg1 = "/^" . $globalbranch . "[1-" . $classno . "]\$/"; $reg2 = "/^P[1-4]\$/"; $reg3 = "/^[0-9]{2}-[0-9]{2}-[0-9]{4}\$/"; $reg4 = "/^all\$/"; $p = explode('/', $qs); $len = count($p); echo "<!DOCTYPE html>\n<html id='con2'>\n"; display_headers($title); echo "\n<body>"; menu(); echo <<<a \t\t\t<div class='container' id='con1'> \t\t\t\t<div id="error"></div> \t\t\t\t<div class='row'> \t\t\t\t<div class='span9'> \t\t\t\t\t<div class="well well-large" style="background:#FFF;"> a; if ($len == 3 or $len == 4 && $p[3] == "") { if (preg_match($reg1, $p[0]) && (preg_match($reg2, $p[1]) or preg_match($reg4, $p[1])) && preg_match($reg3, $p[2])) { $ar = explode('-', $p[2]); if (checkdate($ar[1], $ar[0], $ar[2])) { $lockfile = str_replace("/", "_", $qs); if (file_exists("assets/tmp/" . $lockfile)) { echo "<script>show_error('Request in Progress');</script>"; } else { exec("> assets/tmp/" . $lockfile); $dbname = $branchyear . '_Dates'; $table = $p[0] . '_Dates'; //if(!mysql_select_db($dbname)) {die(mysql_error());} $date_sub = $p[2]; $n = mysql_num_rows(mysql_query("select * from {$table} where Date = '{$date_sub}';")); if ($n == 0) { echo "<script>show_error('{$date_sub} not found ');</script>"; } else { $pcount = 1; $remaining = array(); $j = 0; $uploaded = array(); $j1 = 0; $confirmed = array(); $j2 = 0; if ($p[1] == "all") { for ($i = 1; $i <= 4; $i++) { $tmp = "P" . $i . "_Con"; $tmp1 = "P" . $i; $q = mysql_query("select `{$tmp}`,`{$tmp1}` from {$table} where Date = '{$date_sub}'; ") or die(mysql_error()); $res = mysql_fetch_array($q); if ($res[$tmp1] == 'ok' && $res[$tmp] == null) { $remaining[$j] = "P" . $i; $j++; } } } else { $remaining[$j] = $p[1]; } for ($r = 1; $r <= count($remaining); $r++) { $tmp = "P" . $r . "_Con"; $tmp1 = "P" . $r; $q = mysql_query("select `{$tmp}`,`{$tmp1}` from {$table} where Date = '{$date_sub}'; ") or die(mysql_error()); $res = mysql_fetch_array($q); if ($res[$tmp] == 'ok') { $uploaded[$j1] = $tmp1; $j1++; } if ($res[$tmp1] == 'ok') { $confirmed[$j2] = $tmp1; $j2++; } } //print_r($remaining); if (count($uploaded) != 4) { $cou = 0; $str2 = ""; for ($r = 0; $r < count($remaining); $r++) { $period1 = $remaining[$r]; $tmp = $period1 . "_Con"; $tmp1 = $period1; $q = mysql_query("select {$tmp}, {$tmp1} from {$table} where Date = '{$date_sub}';") or die(mysql_error()); $res = mysql_fetch_array($q); if ($res[$tmp] == 'ok') { echo "<script>show_error('{$period1} already confirmed ');</script>"; } else { if ($res[$tmp1] != 'ok') { $str2 .= $period1 . " "; echo "<script>show_error('{$str2} attendance not uploaded');</script>"; } else { $dbname = $branchyear . '_Cache'; $table = $p[0] . '_Cache'; //if(!mysql_select_db($dbname)) die(mysql_error()); $class_total = mysql_num_rows(mysql_query("select `Id` from {$table}")) or die(mysql_error()); $dbname = $branchyear . '_Attendance'; $table = $p[0] . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $f = mysql_query("show columns from `{$table}` like '{$date_sub}';") or die(mysql_error()); $val = mysql_num_rows($f) ? True : False; if (!$val) { mysql_query("alter table `{$table}` add (`{$date_sub}` varchar(30) default '');") or die(mysql_error()); } insert_log($_SESSION['UserId'] . " added {$date_sub} to {$table}"); $dbname = $branchyear . '_Attendance'; $table = $p[0] . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select isnull (`{$date_sub}`) as Date from {$table};") or die(mysql_error()); $res = mysql_fetch_array($q); $strs = array(); $strs1 = array(); if (!$res['Date']) { $dbname = $branchyear . '_Cache'; $table = $p[0] . '_Cache'; //if(!mysql_select_db($dbname)) die(mysql_error()); for ($k = 1; $k <= $class_total; $k++) { $a12 = mysql_query("Select `" . $date_sub . "_" . $remaining[$r] . "` from `{$table}` where RNo='{$k}';") or die(mysql_error()); $b12 = mysql_fetch_array($a12); $strs[$k] = $remaining[$r] . "_" . $b12[0] . ","; } $dbname = $branchyear . '_Attendance'; $table = $p[0] . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); for ($k = 1; $k <= $class_total; $k++) { $a12 = mysql_query("Select `" . $date_sub . "`from `{$table}` where RNo='{$k}';") or die(mysql_error()); $b12 = mysql_fetch_array($a12); if ($b12[$date_sub] == null) { $strs1[$k] = $strs[$k]; } else { $strs1[$k] = $b12[$date_sub] . $strs[$k]; } } } $dbname = $branchyear . '_Attendance'; $table = $p[0] . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); for ($k = 1; $k <= $class_total; $k++) { if (in_array($k, $exp[$p[0]])) { continue; } $a12 = mysql_query("update {$table} set `" . $date_sub . "` = '" . $strs1[$k] . "' where RNo = '" . $k . "';") or die(mysql_error()); } $dbname = $branchyear . '_TimeTable'; $table = $p[0] . '_TimeTable'; //if(!mysql_select_db($dbname)) die(mysql_error()); $dates1 = getdate(strtotime($date_sub)); //$date=$dates[$r]; $day = substr($dates1["weekday"], 0, 3); $per = $p[1] == 'all' ? $remaining[$r] : $p[1]; $ti = mysql_query("SELECT DayPeriod,{$day} from {$table} where DayPeriod = '" . $per . "';") or die(mysql_error()); $subjects = array(); while ($da = mysql_fetch_array($ti)) { $subjects[$da[0]] = $da[1]; } $dbname = $branchyear . '_Subjects'; $table = $p[0] . '_Subjects'; //if(!mysql_select_db($dbname)) die(mysql_error()); for ($k = 1; $k <= $class_total; $k++) { if (in_array($k, $exp[$p[0]])) { continue; } $st = strtoupper(substr($strs[$k], -2, -1)); $sub = $subjects[$per]; $q = mysql_query("select `" . $sub . "_" . $st . "` from {$table} where RNo = '{$k}';") or die(mysql_error()); $res = mysql_fetch_array($q); $subcount = $res[0] + 1; $a12 = mysql_query("update {$table} set `" . $sub . "_" . $st . "` = '" . $subcount . "' where RNo = '" . $k . "';") or die(mysql_error()); } $dbname = $branchyear . '_Cache'; $table = $p[0] . '_Cache'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("alter table `{$table}` drop `" . $date_sub . "_" . $per . "`;"); $dbname = $branchyear . '_Dates'; $table = $p[0] . '_Dates'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("update {$table} set `{$tmp}` = 'ok' where Date = '{$date_sub}';") or die(mysql_error()); $cou++; } } } if ($cou == count($remaining) && $cou != 0) { $abz = count($remaining); $st = ""; for ($s = 0; $s < $abz; $s++) { if ($s == $abz - 1) { $st .= $remaining[$s]; } else { $st .= $remaining[$s] . ", "; } } insert_log($_SESSION['UserId'] . " uploaded {$st} Attendance"); echo "<script>show_success('{$st} attendance updated ');</script>"; } else { if (in_array($p[1], $confirmed)) { echo "<script>show_error('" . $p[1] . " already updated');</script>"; } if (in_array($p[1], $uploaded)) { echo "<script>show_error('" . $p[1] . " attendance already confirmed');</script>"; } if ($p[1] == 'all') { echo "<script>show_error('" . $p[1] . " uploaded fields are already confirmed');</script>"; } } } else { $abz = count($confirmed); $st = ""; for ($s = 0; $s < $abz; $s++) { if ($s == $abz - 1) { $st .= $confirmed[$s]; } else { $st .= $confirmed[$s] . ", "; } } echo "<script>show_error('{$st} attendance not yet uploaded');</script>"; } } unlink("assets/tmp/" . $lockfile); } } else { echo "<script>show_error('Invalid Date Sent');</script>"; } } else { echo "<script>show_error('Invalid Input Sent');</script>"; } } if (preg_match($reg1, $p[0])) { echo '<h4>Confirm Uploads </h4> <h5>     -   Below records need to be confirmed. </h5>'; $qs = $p[0]; $dbname = $branchyear . '_Dates'; $table = $qs . '_Dates'; //if(!mysql_select_db($dbname)) die(mysql_error()); $new = mysql_query("SELECT `Date` FROM `{$table}` WHERE P1_Con IS NULL OR P2_Con IS NULL OR P3_Con IS NULL OR P4_Con IS NULL") or die(mysql_error()); if (mysql_num_rows($new) == 0) { echo "<span class='text-error'><b>No records found</b></span>"; } else { $dates = array(); $i = 0; while ($res = mysql_fetch_row($new)) { $dates[$i] = $res[0]; $i++; } for ($l = 0; $l < count($dates); $l++) { $dates1 = getdate(strtotime($dates[$l])); $date = $dates[$l]; $day = substr($dates1["weekday"], 0, 3); $dbname = $branchyear . '_TimeTable'; $table = $qs . '_TimeTable'; //if(!mysql_select_db($dbname)) die(mysql_error()); $ti = mysql_query("SELECT DayPeriod,{$day} from {$table};") or die(mysql_error()); $subjects = array(); while ($da = mysql_fetch_array($ti)) { $subjects[$da[0]] = $da[1]; } $p = array("P1_A" => 0, "P1_P" => 0, "P2_A" => 0, "P2_P" => 0, "P3_A" => 0, "P3_P" => 0, "P4_A" => 0, "P4_P" => 0); $dbname = $branchyear . '_Dates'; $table = $qs . '_Dates'; //if(!mysql_select_db($dbname)) die(mysql_error()); $remaining = array(); $j = 0; $remaining1 = array(); $j1 = 0; $confirmed = array(); $j2 = 0; $confirmed1 = array(); $j3 = 0; for ($i = 1; $i <= 4; $i++) { $tmp = "P" . $i; $tmp1 = "P" . $i . "_Con"; $q = mysql_query("select ISNUll(`{$tmp}`) as `P{$i}`,ISNUll(`{$tmp1}`) as `P" . $i . "_C` from {$table} where Date = '{$date}' ") or die(mysql_error()); $res = mysql_fetch_array($q); if ($res["P" . $i]) { $remaining[$j] = "P" . $i; $j++; } else { $remaining1[$j1] = "P" . $i; $j1++; } if ($res["P" . $i . "_C"]) { $confirmed[$j2] = "P" . $i; $j2++; } else { $confirmed1[$j3] = "P" . $i; $j3++; } } $dbname = $branchyear . '_Cache'; $table = $qs . '_Cache'; //if(!mysql_select_db($dbname)) die(mysql_error()); //print_r($confirmed); $a = $date . "_"; $q = mysql_query("SELECT * FROM {$table}") or die(mysql_error()); while ($q1 = mysql_fetch_array($q)) { for ($i = 0; $i < count($confirmed); $i++) { $tmp2 = $a . $confirmed[$i]; //print_r($q1); if ($q1[$tmp2] == "A") { $p[$confirmed[$i] . "_A"]++; } if ($q1[$tmp2] == "P") { $p[$confirmed[$i] . "_P"]++; } } } //print_r($p);echo "<br>"; if (count($confirmed1) != 0) { $dbname = $branchyear . '_Attendance'; $table = $qs . '_Attendance'; //if(!mysql_select_db($dbname))die(mysql_error()); $q = mysql_query("SELECT `{$date}` FROM {$table};") or die(mysql_error()); while ($res = mysql_fetch_array($q)) { $z = explode(",", $res[$date], -1); for ($m = 0; $m < count($z); $m++) { $p[$z[$m]] += 1; } } } //print_r($p); $a = $date . "_P"; $li1 = "?{$qs}/all/{$date}"; echo <<<main \t\t\t\t<div id="Date{$a}"> \t\t\t\t\t<ul class="nav nav-pills span8"> \t\t\t\t\t\t<li><h5><i class="icon-calendar"></i> {$date} @ {$qs}</h5> </li> main; echo <<<main \t\t\t\t<li class="pull-right"><h6><span class="text-success"><i class="icon-ok-circle"></i> <a href="{$li1}" class="text-success">Confirm All</a></span>  </h6></li> main; echo <<<main \t\t\t\t</ul> \t\t\t\t<div class="row"> \t\t\t\t\t<div class="span8"> \t\t\t\t\t<table class="table table-hover table-bordered" style="padding:0px;"> \t\t\t\t\t\t<thead> \t\t\t\t\t\t\t<tr> <th style="text-align:center;"> Subject </th> <th style="text-align:center;" class="span1"> Period </th> \t\t\t\t\t\t\t<th class="span1" style="text-align:center;"> Absents </th> <th class="span1" style="text-align:center;"> Presents </th> \t\t\t\t\t\t\t <th class="span4" style="text-align:center;"> Options</th> </tr> \t\t\t\t\t\t</thead> \t\t\t\t\t\t<tbody> main; for ($j = 1; $j <= 4; $j++) { if (!in_array("P" . $j, $remaining)) { echo '<tr><td style="text-align:center;">' . $subjects["P" . $j] . '</td><td style="text-align:center;">' . "P" . $j . '</td> <td style="text-align:center;" class="text-error">' . $p["P" . $j . "_A"] . '</td> <td style="text-align:center;" class="text-success"> ' . $p["P" . $j . "_P"] . ' </td> <td style="text-align:center;">'; if (in_array("P" . $j, $confirmed1)) { echo ' <span class="text-success" >Confirmed</span>'; } else { $li = "?{$qs}/P{$j}/{$date}"; $li1 = "./today1.php?{$date}/{$qs}"; echo ' <span class="text-success" ><i class="icon-ok-circle"></i> <a href="' . $li . '" class="text-success">Confirm </a></span>   '; echo ' <span class="text-error" ><i class="icon-edit"></i> <a href="' . $li1 . '" class="text-error">Edit </a></span>'; } echo '   <span class="text-info"><i class="icon-globe"></i> <a href="#' . $a . $j . '" class="text-info" data-toggle="modal">Browse</a> </span></td> </tr>'; } } echo <<<main \t\t\t\t\t\t</tbody> \t\t\t\t\t</table> \t\t\t\t\t</div> \t\t\t\t</div> \t\t\t\t</div> \t\t\t\t<br> \t\t\t\t main; for ($j = 1; $j <= 4; $j++) { if (!in_array("P" . $j, $remaining)) { echo <<<confirm \t\t\t\t\t\t <div id="{$a}{$j}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="useridlabel" aria-hidden="true"> \t\t\t\t\t\t\t<div class="modal-header"> \t\t\t\t\t\t\t<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> \t\t\t\t\t\t\t<h4 id="useridlabel">{$qs} @ P{$j} Attendance Details</h4> \t\t\t\t\t\t\t</div> \t\t\t\t\t\t<div class="modal-body"> \t\t\t\t\t\t\t<div class="row"> \t\t\t\t\t\t\t\t<div class="span6"> \t\t\t\t\t\t\t\t\t<table class="table table-hover table-bordered" > \t\t\t\t\t\t\t\t\t\t<tbody> \t\t\t\t\t\t\t\t\t\t<tr> <td class="span2" style="text-align:center"> Date </td> <th class="text-warning span2" style="text-align:center"> {$date}</th> \t\t\t\t\t\t\t\t\t\t<td class="span2" style="text-align:center"> Subject </td> <th class="text-success span2" style="text-align:center"> {$subjects["P" . $j]} </th> </tr> \t\t\t\t\t\t\t\t\t\t</tbody> \t\t\t\t\t\t\t\t\t</table> \t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t<div class="row"> \t\t\t\t\t\t\t\t<div class="span6"> \t\t\t\t\t\t\t\t<table class="table table-hover table-bordered" > \t\t\t\t\t\t\t\t<thead> \t\t\t\t\t\t\t\t\t<tr> <th class="span2" style="text-align:center"> Period # </th> <th class="span3"> Presents </th> <th class="span3"> Absents </th> </tr> \t\t\t\t\t\t\t\t</thead> \t\t\t\t\t\t\t\t<tbody> \t\t\t\t\t\t\t\t\t<tr><td style="text-align:center;" >P{$j}</td> confirm; $dbname = $branchyear . '_Dates'; $table = $qs . '_Dates'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select ISNULL(`P" . $j . "_Con`) as `P{$j}` from {$table} where Date = '{$date}'; ") or die(mysql_error()); $row = mysql_fetch_array($q); if (!$row["P" . $j]) { $period = "P" . $j; $dbname = $branchyear . '_Attendance'; $table = $qs . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select RNo,`{$date}` from {$table};") or die(mysql_error()); $Rnos = array("Absents" => array(), "Presents" => array()); $aindex = 0; $pindex = 0; while ($res = mysql_fetch_array($q)) { $z = explode(",", $res[$date]); for ($m = 0; $m < count($z); $m++) { $y = explode("_", $z[$m]); if ($y[0] == $period) { if ($y[1] == "A") { $Rnos['Absents'][$aindex] = $res[0]; $aindex++; } else { $Rnos['Presents'][$pindex] = $res[0]; $pindex++; } } } } } else { $dbname = $branchyear . '_Cache'; $table = $qs . '_Cache'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q3 = mysql_query("SELECT RNo, `" . $a . $j . "` FROM {$table}") or die(mysql_error()); $Rnos = array("Absents" => array(), "Presents" => array()); $aindex = 0; $pindex = 0; while ($individual = mysql_fetch_array($q3)) { if ($individual[$a . $j] == "A") { $Rnos["Absents"][$aindex] = $individual["RNo"]; $aindex++; } if ($individual[$a . $j] == "P") { $Rnos["Presents"][$pindex] = $individual["RNo"]; $pindex++; } } } $pc = count($Rnos["Presents"]); $ac = count($Rnos["Absents"]); $tot = $pc + $ac; echo "<td>"; for ($i = 0; $i < $pc; $i++) { if ($i % 8 == 0 && $i != 0) { echo "<br>"; } if ($i == $pc - 1) { echo $Rnos["Presents"][$i]; } else { echo $Rnos["Presents"][$i] . ","; } } echo "</td><td>"; for ($i = 0; $i < $ac; $i++) { if ($i % 8 == 0 && $i != 0) { echo "<br>"; } if ($i == $ac - 1) { echo $Rnos["Absents"][$i]; } else { echo $Rnos["Absents"][$i] . ","; } } echo <<<confirm1 \t\t\t\t\t\t\t</td></tr> \t\t\t\t\t\t\t\t<tr> \t\t\t\t\t\t\t\t\t<td style="text-align:center;" >Total (<b>{$tot}</b>)</td> \t\t\t\t\t\t\t\t\t<td style="text-align:center;" class='text-success'> {$pc}</td> \t\t\t\t\t\t\t\t\t<td style="text-align:center;" class='text-error'>{$ac}</td> \t\t\t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t\t</tbody> \t\t\t\t\t\t\t</table> \t\t\t\t\t\t\t</div> \t\t\t\t\t\t</div> \t\t\t\t\t\t</div> \t\t\t\t\t\t<div class="modal-footer"> \t\t\t\t\t\t<button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Close</button> \t\t\t\t\t\t</div> \t\t\t\t\t</div> confirm1; } } } } echo "</div></div>"; echo "<div class='span3'>"; go_home(); echo "<ul class='nav nav-tabs nav-stacked'>"; for ($i = 1; $i <= $classno; $i++) { $branch = $globalbranch; $cls = $branch . $i; $table = $cls . '_Dates'; $remaining = array(); $j = 0; $q = mysql_query("select * from {$table} ; ") or die(mysql_error()); while ($res = mysql_fetch_array($q)) { if ($res["P1_Con"] != 'ok' or $res["P2_Con"] != 'ok' or $res["P3_Con"] != 'ok' or $res["P4_Con"] != 'ok') { $remaining[$j++] = $res['Date']; } } $str1 = count($remaining) != 0 ? "<i class='icon-remove pull-right text-error' style='padding-top:5px;'></i>" : "<i class='icon-ok pull-right text-success' style='padding-top:5px;'></i>"; //echo $str1; echo <<<a \t\t\t\t<li><a href="?{$branch}{$i}">{$branch}{$i}<i class="icon-chevron-right pull-left" style="padding-top:5px;"></i> {$str1} </a> </li> a; } echo "</ul>"; echo "</div></div></div>"; display_footer(); echo "\n</body>\n</html>"; } else { echo "<script type='text/javascript'>document.location.href='404.php';</script>"; } } }
function browse_students($title) { if (!check_login()) { header('location:login.php'); } else { include 'config/globals.php'; $cls_page = $_SERVER['QUERY_STRING']; $cp = explode('/', $cls_page); $len = count($cp); if ($len == 2 or $len == 3 and $cp[2] == null) { $class = '/^' . $globalbranch . '[1-' . $classno . ']{1}$/'; $page = '/^[1-9]{1}$/'; if (preg_match($class, $cp[0]) and preg_match($page, $cp[1])) { include 'config/db.php'; include 'config/settings.php'; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)){die(mysql_error());} echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu(); echo <<<browse \t\t\t\t\t<div class="container" style="margin-top:-15px;height:450px;"><br> \t\t\t\t\t\t<div class="row"> \t\t\t\t\t\t\t<div class="span9"> \t\t\t\t\t\t\t\t<div class="well well-large" style="background:#FFF;"> \t\t\t\t\t\t\t\t\t<div class="row"> \t\t\t\t\t\t\t\t\t\t<div id="step1" class="span4"> \t\t\t\t\t\t\t\t\t\t\t<h5>Students @ {$cp['0']} </h5> \t\t\t\t\t\t\t\t\t\t\t<h6>     -   Listing all students in {$cp['0']} </h6> \t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t\t<div id="page1" class="span4"> \t\t\t\t\t\t\t\t\t\t\t<a class="pull-right"><h6>Page {$cp['1']} </h6></a> \t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t<div id={$cp['0']} > \t\t\t\t\t\t\t\t\t\t<table class="table table-hover table-bordered " style="padding:0px;"> \t\t\t\t\t\t\t\t\t\t\t<thead> \t\t\t\t\t\t\t\t\t\t\t\t<tr> \t\t\t\t\t\t\t\t\t\t\t\t\t<th style="text-align:center;" class="span1">RNo</th> \t\t\t\t\t\t\t\t\t\t\t\t\t<th style="text-align:center;" class="span1">ID #</th> \t\t\t\t\t\t\t\t\t\t\t\t\t<th style="text-align:center;" class="span3">Name</th> \t\t\t\t\t\t\t\t\t\t\t\t\t<th style="text-align:center;" class="span1">Gender</th> \t\t\t\t\t\t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t\t\t\t\t</thead> \t\t\t\t\t\t\t\t\t\t\t<tbody> browse; $page = $cp[1]; $prev = $page - 1; $next = $page + 1; $per_page = 10; $slimit = ($page - 1) * 10; $branch = substr($cp[0], 0, strlen($cp[0]) - 1); $class = substr($cp[0], -1); $query1 = mysql_query("SELECT Id From " . $table . " WHERE Branch = '{$branch}' and Class = '{$class}';"); $strength = mysql_num_rows($query1); $query = "SELECT Id,Name,Gender,RNo From " . $table . " WHERE Branch='{$branch}' and Class='{$class}' LIMIT {$slimit},{$per_page};"; $exe = mysql_query($query) or die(mysql_error()); $lastpage = ceil($strength / $per_page); for ($i = 0; $i < mysql_num_rows($exe); $i++) { $det = mysql_fetch_array($exe); $lnk = "./students.php?" . $det[0] . "/sub"; $nm = ucwords(strtolower($det[1])); echo <<<student \t\t\t\t\t<tr onclick="document.location.href='{$lnk}';" style='cursor:pointer;'> \t\t\t\t\t\t<td style="text-align:center;">{$det['3']}</td> \t\t\t\t\t\t<td style="text-align:center;">{$det['0']}</td> \t\t\t\t\t\t<td>{$nm}</td> \t\t\t\t\t\t<td style="text-align:center;" >{$det['2']}</td> \t\t\t\t\t</tr> student; } echo <<<next \t\t\t\t</tbody> \t\t\t\t</table>\t\t\t \t\t\t\t</div> \t\t\t\t<div class="pagination pagination-centered"> \t\t\t\t<ul> next; if ($page == 1 and $strength > 0) { echo "<li class='disabled'><a>←Prev</a></li>"; for ($i = 1; $i <= $lastpage; $i++) { echo "<li><a href='?{$cp['0']}/{$i}/'>{$i}</a></li>"; } echo "<li><a href='?{$cp['0']}/{$next}/'>Next→</a></li>"; } elseif ($page > 1 and $page < $lastpage) { echo "<li><a href='?{$cp['0']}/{$prev}/'>←Prev</a></li>"; for ($i = 1; $i <= $lastpage; $i++) { echo "<li><a href='?{$cp['0']}/{$i}/'>{$i}</a></li>"; } echo "<li><a href='?{$cp['0']}/{$next}/'>Next→</a></li>"; } elseif ($page == $lastpage) { echo "<li><a href='?{$cp['0']}/{$prev}/'>←Prev</a></li>"; for ($i = 1; $i <= $lastpage; $i++) { echo "<li><a href='?{$cp['0']}/{$i}/'>{$i}</a></li>"; } echo "<li class='disabled'><a>Next→</a></li>"; } else { echo "No records found."; } echo <<<next \t\t\t\t\t\t</ul> \t\t\t\t\t\t</div> \t\t\t\t\t\t</div> \t\t\t\t\t\t</div> \t\t\t\t\t\t<div class="span3"> next; go_home(); classes($classno, $globalbranch); echo "</div></div>"; display_footer(); echo "\n</div></body>\n</html>"; } else { echo "Error : Invalid syntax in URL.<br>"; } } else { echo "Error : Invalid syntax in URL.<br>"; } } }
function changeprofile($title) { if (!check_login()) { header('location:login.php'); } else { include 'config/globals.php'; $p = $_SERVER['QUERY_STRING']; $arr = array("password", "contact", "photo"); if (in_array($p, $arr)) { include 'config/db.php'; include 'config/settings.php'; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); $userid = $_SESSION['UserId']; $q = "select Password, PhoneNo, Branch from {$table} where Id = '{$userid}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); $branch = $row['Branch']; $pass = $row['Password']; $phoneno = $row['PhoneNo']; $class = substr($p, -1); $ex = array("png", "jpg", "jpeg", "gif", "bmp"); echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu(); echo <<<a \t\t\t\t<div class='container'> \t\t\t\t\t<div id="error" style="display:none;"></div> \t\t\t\t\t<div class='row'> \t\t\t\t\t<div class='span9'> \t\t\t\t\t\t<div class="well well-large" style="background:#FFF;height:450px;"> a; if ($p == 'password') { display_password(); } if (isset($_POST['Password'])) { $pass1 = md5($_POST['OPass']); $newpass1 = md5($_POST['NPass1']); $newpass2 = md5($_POST['NPass2']); if (strlen(trim($pass1)) < 7) { echo "<script>show_error('Error : Password should not be null');</script>"; exit; } if (strlen(trim($newpass1)) < 7) { echo "<script>show_error('Error : New Password should not be null');</script>"; exit; } if (strlen(trim($newpass2)) < 7) { echo "<script>show_error('Error : Re- New Password should not be null');</script>"; exit; } if ($pass1 != $pass) { echo "<script>show_error('Error : Your Current Password does not matched ... Please try again....');</script>"; } else { if ($newpass1 != $newpass2) { echo "<script>show_error('Error : New Password both does not matched ... Please try again....');</script>"; } else { $q = mysql_query("update {$table} set Password = '******' where Id = '{$userid}';") or die(mysql_error()); insert_log("{$userid} changed his Password "); echo "<script>show_success('Password has been updated');</script>"; } } } if ($p == 'contact') { display_contact(); } if (isset($_POST['Contact'])) { $pass1 = md5($_POST['OPass']); $contact1 = $_POST['MNo']; if (strlen(trim($pass1)) < 7) { echo "<script>show_error('Error : Password should not be null');</script>"; exit; } if (strlen(trim($contact1)) == 0) { echo "<script>show_error('Error : Contact No should not be null');</script>"; exit; } if ($pass1 != $pass) { echo "<script>show_error('Error : Your Current Password does not matched ... Please try again....');</script>"; } else { if (strlen($contact1) != 10) { echo "<script>show_error('Error : New Contact No. to short... Please try again....');</script>"; } else { $q = mysql_query("update {$table} set PhoneNo = '{$contact1}' where Id = '{$userid}';") or die(mysql_error()); insert_log("{$userid} changed his Contact No"); echo "<script>show_success('Contact No has been updated');</script>"; } } } if ($p == 'photo') { display_photo(); } if (isset($_POST['Photo'])) { $pass1 = md5($_POST['OPass']); if (strlen(trim($pass1)) < 7) { echo "<script>show_error('Error : Password should not be null');</script>"; exit; } if ($pass1 != $pass) { echo "<script>show_error('Error : Your Current Password does not matched ... Please try again....');</script>"; } else { if (isset($_FILES['PhotoFile'])) { $fname = $_FILES['PhotoFile']["name"]; $fsize = $_FILES['PhotoFile']["size"]; $fext = strtolower(end(explode(".", $fname))); if ($fsize > 102400) { echo "<script>show_error('Error : Input file is larger than 100KB ... Please try again....');</script>"; } else { if (!in_array($fext, $ex)) { echo "<script>show_error('Error : Input file is not a image file ... Please try again....');</script>"; } else { $fname_new = "assets/img/users/" . $userid . ".png"; if (!move_uploaded_file($_FILES["PhotoFile"]["tmp_name"], $fname_new)) { echo "<script>show_error('Error : In moving the input file ... Please try again....');</script>"; } else { exec("chmod 777 {$fname_new}"); $q = mysql_query("update {$table} set Picture = '{$fname_new}' where Id = '{$userid}';") or die(mysql_error()); insert_log("{$userid} changed his profile photo"); echo "<script>show_success('Profile Photo Updated ');</script>"; } } } } else { echo "<script>show_error('Error : No input file ... Please try again....');</script>"; } } } echo <<<b \t\t</div>\t \t\t</div> \t\t<div class='span3'> b; go_home(); echo <<<b \t\t<ul class="nav nav nav-tabs nav-stacked"> \t\t \t\t<li><a href='?password'>Change Password <i class="icon-chevron-right pull-left" style="padding-top:5px;"></i></a> </li> \t\t<li><a href='?contact'>Change Contact No<i class="icon-chevron-right pull-left" style="padding-top:5px;"></i></a> </li> \t\t<li><a href='?photo'>Change Photo <i class="icon-chevron-right pull-left" style="padding-top:5px;"></i></a> </li> \t\t \t\t</ul> b; echo "</div></div></div>"; display_footer(); echo "\n</body>\n</html>"; } else { echo "<script type='text/javascript'>document.location.href='404.php';</script>"; } } }
function feedback($title) { if (!check_login()) { header("location:login.php"); } else { include 'config/globals.php'; include 'config/db.php'; include 'config/settings.php'; $dbname = $branchyear . '_Logs'; $table = $branchyear . '_Feedback'; //if(!mysql_select_db($dbname)) die(mysql_error()); echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo <<<js \t\t\t\t<script type='text/javascript'> \t\t\t\t\tfunction Preview(id,val){ \t\t\t\t\t\tdocument.getElementById(id).innerHTML=val; \t\t\t\t\t} \t\t\t\t</script> js; echo "<body>\n"; menu(); echo <<<feedback \t\t\t<div class="container" style="margin-top:-15px;"> \t\t\t\t\t<br> \t\t\t\t\t<div id="error"></div> \t\t\t\t\t<div class="row"> \t\t\t\t\t\t<div class="span9"> \t\t\t\t\t\t\t<div class="well well-large" style="background:#FFF;"> \t\t\t\t\t\t\t\t<div id="stpe2_P1"> \t\t\t\t\t\t\t\t\t<h5>Give Feedback </h5> \t\t\t\t\t\t\t\t\t<h6>     -   Fill out below details </h6> \t\t\t\t\t\t\t\t\t<!--<h5>Period 1 : </h5>--> \t\t\t\t\t\t\t\t\t<form method="POST" action="" onSubmit="return give_feedback();" > \t\t\t\t\t\t\t\t\t\t<h6 > Feedback Type :</h6> \t\t\t\t\t\t\t\t\t\t<label class="radio inline"> \t\t\t\t\t\t\t\t\t\t<input type="radio" id='complaint' value="Complaint" name="ftype" onclick="Preview(this.name,this.value);"> Complaint \t\t\t\t\t\t\t\t\t</label> \t\t\t\t\t\t\t\t\t<label class="radio inline"> \t\t\t\t\t\t\t\t\t\t<input type="radio" id='suggestion' value="Suggestion" name="ftype" onclick="Preview(this.name,this.value);"> Suggestion \t\t\t\t\t\t\t\t\t</label><br><br> \t\t\t\t\t\t\t\t<h6> Subject :</h6> \t\t\t\t\t\t\t\t<input type="text" class="span8" placeholder="Subject" id='subject' name='sub' onkeyup="Preview(this.name,this.value);"><br> \t\t\t\t\t\t\t\t<h6> Message :</h6> \t\t\t\t\t\t\t\t<textarea class="span8" id='feedback' name='fb' style="resize:vertical;height:90px;" onkeyup="Preview(this.name,this.value);" placeholder="Type your complaint/suggestion here"></textarea> \t\t\t\t<br> \t\t\t</div> \t\t\t<div id="stpe3"> \t\t\t\t<a ><h5>Preview </h5></a> \t\t\t\t<!--<h6>     -   Confirm Your Notice </h6>--> \t\t\t\t<div class="row"> \t\t\t\t\t<div class="span8"> \t\t\t\t\t\t<table class="table table-hover table-bordered" > \t\t\t\t\t\t\t<tbody> \t\t\t\t\t\t\t\t<tr> \t\t\t\t\t\t\t\t\t<th class="span2" > Feedback Type </th> \t\t\t\t\t\t\t\t\t<td class='span6' id='ftype'> Complaint/Suggestion </td> \t\t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t<tr> \t\t\t\t\t\t\t\t<th class="span2" > Suject </th> \t\t\t\t\t\t\t\t<td class="span6" id='sub'> Feedback subject </td> \t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t<tr> \t\t\t\t\t\t\t\t<th class="span2" > Feedback </th> \t\t\t\t\t\t\t\t<td class="span6" id='fb'> Complaint/Suggestion </td> \t\t\t\t\t\t\t</tr> \t\t\t\t\t\t</tbody> \t\t\t\t\t</table> \t\t\t\t</div> \t\t\t</div><br> \t\t\t<input type="submit" class="btn btn-primary" value="Confirm & Send →" name="post" /> \t\t\t</form> \t\t</div> \t\t<br> \t</div> </div> feedback; echo "<div class='span3'>"; go_home(); sidepanel(); echo "</div></div>"; display_footer(); echo "\n</body>\n</html>"; } }
function homepage($title) { if (!check_login()) { header('location:login.php'); } else { echo "<!DOCTYPE html>\n<html>\n\t<SCRIPT LANGUAGE=\"Javascript\" SRC=\"assets/charts/FusionCharts.js\"></SCRIPT>"; display_headers($title); echo "\n<body>"; menu(); echo <<<a \t<div class='container'> \t\t<div id='error'></div> \t\t<div class='row'> a; echo '<div class="span9"><div class="well well-large" style="background:#FFF;">'; /* Pattern Matching */ $reg1 = "/^N[0-9]{6}\$/"; $reg2 = "/^p|(sub)\$/"; $qs = $_SERVER["QUERY_STRING"]; $va = explode("/", $qs); $qs1 = $va[0]; $qs2 = $va[1]; if (preg_match($reg1, $qs1) and preg_match($reg2, $qs2)) { /* Fetching Details */ include 'config/db.php'; include 'config/settings.php'; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); $userid = $_SERVER["QUERY_STRING"]; $resultant = explode("/", $userid); $id = $resultant[0]; $mode = $resultant[1]; $q = "select Name,Gender,Position, Branch, Class ,RNo from {$table} where Id = '{$id}'"; $res = mysql_query($q) or die(mysql_error()); if (mysql_num_rows($res) == 0) { echo "<script>document.location.href='404.php';</script>"; } $row = mysql_fetch_array($res); $username = ucwords(strtolower($row['Name'])); $gender = $row['Gender']; $RNo = $row["RNo"]; $type = $row['Position']; $class = $row['Class']; $branch = $row['Branch']; $colors = array('F6BD0F', '8BBA00', 'FF8E46', '8E468E', '588526', '008ED6', '9D080D', 'D64646', 'B3AA00', 'A186BE', 'AFD8F8'); shuffle($colors); /* Deatils Fetched */ echo <<<a \t\t<div id="step1" class="span6"> \t\t<a ><h5>Student Attendance Report for {$id} </h5></a> \t\t<h6>     -   Lising Attendance details submitted from CR @ {$branch} {$class}</h6><br> \t\t</div> \t\t<table class="table table-hover table-bordered"> \t\t<tbody> \t\t<tr><th>Name </th> <td>{$username}</td> <th>Gender </th> <td>{$gender}</td> </tr> \t\t<tr><th>RNo </th> <td>{$RNo}</td> <th>Class </th> <td>{$branch} {$class} </td></tr> \t\t</tbody> \t\t</table> \t<div id="step1" class="span4"> \t\t<h5>Chart Based Representaiton </h5> \t</div> \t<div id="side1" class="span4" > \t\t<h6 class='text-right'><a href='?{$id}/sub' ><i class='icon-book'></i> Subjects</a>   <a href='?{$id}/p'><i class='icon-qrcode'></i> Periods</a></h6> \t</div> a; if (strtolower($mode) == "p") { //mysql_select_db($branchyear."_Dates") or die(mysql_error()); $query = mysql_query("Select Date from " . $branch . $class . "_Dates where P1_Con = 'ok' or P2_Con = 'ok' or P3_Con = 'ok' or P4_Con = 'ok' ;") or die(mysql_error()); $nofd = mysql_num_rows($query); if ($nofd != 0) { $p = array("P1_A" => 0, "P1_P" => 0, "P2_A" => 0, "P2_P" => 0, "P3_A" => 0, "P3_P" => 0, "P4_A" => 0, "P4_P" => 0); $stats = array("Total" => 0, "Presents" => 0, "Absents" => 0); $strXML = "<graph caption='Period Wise Attendance Report' formatNumberScale='1' rotateValues='1' decimalPrecision='1' numberSuffix='%' xAxisName='Periods' yAxisName='Performance'>"; $datasetp = ''; while ($dates = mysql_fetch_array($query)) { //mysql_select_db($branchyear."_Attendance") or die(mysql_error()); $q = mysql_query("select `" . $dates[0] . "` from " . $branch . $class . "_Attendance where RNo='" . $RNo . "';"); while ($res = mysql_fetch_array($q)) { $values = explode(",", $res[0]); for ($i = 0; $i < count($values) - 1; $i++) { if (substr($values[$i], -1) == "P") { $stats["Presents"] += 1; $stats["Total"] += 1; } if (substr($values[$i], -1) == "A") { $stats["Absents"] += 1; $stats["Total"] += 1; } $p[$values[$i]] += 1; } } } $tr = ''; for ($i = 1; $i <= 4; $i++) { $st = round($p["P" . $i . "_P"] / $nofd, 1) * 100 <= 50 ? "error" : "success"; $tr .= '<tr> <td style="text-align:center;">' . $i . '</td> <td style="text-align:center;"> P' . $i . ' </td> <td style="text-align:center;"><b> ' . $nofd . '</b> </td> <td style="text-align:center;" class="text-success"><b> ' . $p["P" . $i . "_P"] . ' </b></td> <td style="text-align:center;" class="text-success"><b> ' . round($p["P" . $i . "_P"] / $nofd, 1) . ' </b></td> <td style="text-align:center;" class="text-error"><b> ' . $p["P" . $i . "_A"] . ' </b></td> <td style="text-align:center;" class="text-error"><b> ' . round($p["P" . $i . "_A"] / $nofd, 1) . ' </b></td> <td style="text-align:center;" class="text-' . $st . '"><b> ' . round($p["P" . $i . "_P"] / $nofd, 1) * 100 . ' % </b></td> </tr>'; $datasetp .= "<set name='P" . $i . "' value='" . round($p["P" . $i . "_P"] / $nofd, 1) * 100 . "' color='" . $colors[$i] . "'/>"; } $strXML .= $datasetp . "</graph>"; echo renderChart("assets/charts/FCF_Column3D.swf", "", $strXML, "FactorySum", 650, 380); echo <<<table_head \t\t<h5> Period Wise Attendance Representation </h5><br> \t\t<table class="table table-hover table-bordered " style="padding:0px;"> \t\t\t<thead> \t\t\t\t<tr> \t\t\t\t<th style="text-align:center;" valign="top"> SNo </th> <th style="text-align:center;" valign="top"> Period </th> <th style="text-align:center;" > Days </th> <th style="text-align:center;" > Presents </th> <th style="text-align:center;" > P/Day </th> <th style="text-align:center;" > Absents </th> <th style="text-align:center;" > A/Day </th><th style="text-align:center;" > Performance </th> \t\t\t\t</tr> \t\t\t</thead> \t\t\t<tbody> table_head; echo $tr; echo <<<tableend \t\t\t</tbody> \t\t</table> \t\t<br><div class='alert alert-info'><a class='close' data-dismiss='alert'>×</a><strong>CNYS </strong>: Classes Not Yet Started </div> \t<br> tableend; } else { echo "<br><br><h6 class='text-error text-center'> No Submissions Found<br></h6>"; } } /* End of Period Wise Attendance*/ /* SUbjects Wise Attendance */ if (strtolower($mode) == "sub") { //mysql_select_db($branchyear."_Subjects") or die(mysql_error()); $query = mysql_query("Select * from " . $branch . $class . "_Subjects where RNo='{$RNo}';") or die(mysql_error()); $subjectwise = mysql_fetch_array($query) or die(mysql_error()); $tr = ''; $strXML = "<graph caption='Subject Wise Attendance Report' formatNumberScale='1' rotateValues='1' decimalPrecision='1' numberSuffix='%' xAxisName='Subjects' yAxisName='Performance'>"; $datasetp = ''; $nc_cls = 0; for ($i = 0; $i < count($allowed_subjects); $i++) { $tnoc = $subjectwise[$allowed_subjects[$i] . "_P"] + $subjectwise[$allowed_subjects[$i] . "_A"]; if ($tnoc == 0) { $nc_cls++; $performance = "N/A "; $st = "error"; $remarks = "CNYS"; } else { $performance = $subjectwise[$allowed_subjects[$i] . "_P"] / $tnoc * 100; $performance = round($performance, 1) . " %"; $st = $performance <= 50 ? "error" : "success"; if (round($performance, 1) >= 95) { $remarks = "Excellent"; } if (round($performance, 1) >= 90 && round($performance, 1) < 95) { $remarks = "Very Good"; } if (round($performance, 1) >= 80 && round($performance, 1) < 90) { $remarks = "Good"; } if (round($performance, 1) >= 70 && round($performance, 1) < 80) { $remarks = "Normal"; } if (round($performance, 1) >= 60 && round($performance, 1) < 70) { $remarks = "Average"; } if (round($performance, 1) >= 50 && round($performance, 1) < 60) { $remarks = "Bad"; } if (round($performance, 1) < 50) { $remarks = "Go Out"; } } $tr .= '<tr> <td style="text-align:center;">' . ($i + 1) . '</td> <td style="text-align:center;"> <b>' . $allowed_subjects[$i] . '</b> </td> <td style="text-align:center;"> <b>' . $tnoc . '</b> </td> <td style="text-align:center;" class="text-success"><b> ' . $subjectwise[$allowed_subjects[$i] . "_P"] . '</b> </td> <td style="text-align:center;" class="text-error"><b> ' . $subjectwise[$allowed_subjects[$i] . "_A"] . ' </b></td> <td style="text-align:center;" class="text-' . $st . '"><b>' . $performance . '</b></td> <td style="text-align:center;" class="text-' . $st . '"><b>' . $remarks . '</b></td> </tr>'; $datasetp .= "<set name='" . $allowed_subjects[$i] . "' value='" . round($performance, 1) . "' color='" . $colors[$i] . "'/>"; } $strXML .= $datasetp . "</graph>"; if ($nc_cls != count($allowed_subjects)) { echo renderChart("assets/charts/FCF_Column3D.swf", "", $strXML, "FactorySum", 650, 380); echo <<<table_head \t\t<h5> Subject Wise Attendance Representation </h5><br> \t\t<table class="table table-hover table-bordered " style="padding:0px;"> \t\t\t<thead> \t\t\t\t<tr> \t\t\t\t<th style="text-align:center;" rowspan="2" valign="top"> SNo </th> <th style="text-align:center;" valign="top"> Subject </th> <th style="text-align:center;" > Classes </th> <th style="text-align:center;" > Presents </th> <th style="text-align:center;" > Absents </th> <th style="text-align:center;" > Performance </th> <th style="text-align:center;" > Remarks </th> \t\t\t\t</tr> \t\t\t</thead> \t\t\t<tbody> table_head; echo $tr; echo <<<tableend \t\t\t</tbody> \t\t</table> \t\t<br><div class='alert alert-info'><a class='close' data-dismiss='alert'>×</a><strong>CNYS </strong>: Classes Not Yet Started </div> \t<br> tableend; } else { echo "<br><br><h6 class='text-error text-center'> No Submissions Found<br></h6>"; } } /* Subject WIse */ } else { echo "<script type='text/javascript'>show_error('Error: Invalid Syntax given..');</script>"; } echo <<<b \t</div> \t</div> \t<div class='span3'> b; go_home(); sidepanel(); echo "</div></div></div>"; display_footer(); echo "\n</body>\n</html>"; } }
function poor($title) { if (!check("BA")) { header('location:./login.php'); } else { include 'config/globals.php'; include 'config/db.php'; include 'config/settings.php'; $p = $_SERVER['QUERY_STRING']; if (in_array($p, $allowed_subjects)) { echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu(); echo <<<a \t\t \t<div class="container" style="margin-top:-10px;"><br> \t\t<div id='error'></div> a; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; ////if(!mysql_select_db($dbname)) die(mysql_error()); $userid = $_SESSION['UserId']; $q = "select Position, Branch,Class from {$table} where Id = '{$userid}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); $branch = $globalbranch; echo <<<a \t\t \t\t \t\t<div class="row"> \t\t\t<div class='span12'> \t\t\t\t<div class="well well-large" style="background:#FFF;"> a; echo <<<a \t\t \t\t\t<div id="step1" class="span4"> \t\t\t\t<h5 class='text-info'>Poor Attendance Report - {$branch} </h5> \t\t\t\t<h6>     -   Listing Data submitted from CRs @ {$branch} </h6><br> \t\t\t</div> \t\t\t<div id="side1" class="span7" > \t\t\t\t<h6 class='text-right'><a href='./?sub'><i class='icon-home'></i> Home </a> </h6> a; echo <<<a \t\t\t\t\t<h6 class='text-right'> a; for ($cl = 0; $cl <= count($allowed_subjects); $cl++) { $sub = $allowed_subjects[$cl]; echo "<a href='?{$sub}'>{$sub}</a> "; } echo <<<a \t\t\t\t\t</h6> a; echo <<<a \t\t\t</div> \t\t a; $poor = array(); for ($cl = 1; $cl <= $classno; $cl++) { $class = $cl; $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $da = date('d-m-Y'); $date = date('d-m-Y'); $brcls = $branch . $class; $ar = array(); $users = array(); //intializing the count of A,P's to 0 for ($j = 0; $j < count($allowed_subjects); $j++) { $sub = $allowed_subjects[$j]; $dbname = $branchyear . '_Subjects'; $table = $branch . $class . '_Subjects'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select RNo,Id from {$table}") or die(mysql_error()); while ($res = mysql_fetch_array($q)) { if ($j == 1) { $users[$res['RNo']] = $res['Id']; } $ar[$sub][$res['RNo']]['Absents'] = 0; $ar[$sub][$res['RNo']]['Presents'] = 0; } } //counting the total A's & P's $sub = $p; $dbname = $branchyear . '_Subjects'; $table = $branch . $class . '_Subjects'; //if(!mysql_select_db($dbname)) die(mysql_error()); $qa = mysql_query("select RNo, `" . $sub . "_A` from {$table}") or die(mysql_error()); $qp = mysql_query("select RNo, `" . $sub . "_P` from {$table}") or die(mysql_error()); while ($res = mysql_fetch_array($qa)) { $ar[$sub][$res['RNo']]["Absents"] += $res[$sub . "_A"]; } while ($res = mysql_fetch_array($qp)) { $ar[$sub][$res['RNo']]["Presents"] += $res[$sub . "_P"]; } //getting the poor attendance % students $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); $strength = count($users); for ($j = 1; $j <= $strength; $j++) { $count = 1; $sub = $p; $abs = $ar[$sub][$j]['Absents']; $pres = $ar[$sub][$j]['Presents']; $p_nod = $abs + $pres; @($tmp = $pres / $p_nod * 100); $pr = round($tmp, 1); if ($pr < 50) { $cou = $count++; $que_r = "Select RNo from " . $table . " where Id='" . $users[$j] . "';"; $que_n = "Select Name from " . $table . " where Id='" . $users[$j] . "';"; $poor[$brcls][$users[$j]] = mysql_fetch_array(mysql_query($que_r))[0] . "_" . $pr . "_" . mysql_fetch_array(mysql_query($que_n))[0]; } } } $pct = 0; $pcs = array(); $mn = 1; $html = ''; ///print_r($poor); $sub2 = $sub_def[$p]; echo <<<table_head \t <table class="table table-hover table-bordered" style="padding:0px;"> \t\t<thead> \t\t\t<tr> \t\t\t<th style="text-align:center;" >Subject</th> \t\t\t<th style="padding-left:10px;text-align:left;" colspan=4 valign="top">{$sub2}</th> </tr> <tr> \t\t\t<th style="text-align:center;width:10%;" > Class </th> <th style="text-align:center;width:15%;" > Id </th><th style="text-align:center;width:10%;" > RNo</th> <th style="text-align:center;" > Name </th><th style="text-align:center;width:10%;" > Percentage </th> \t\t\t</tr> \t\t</thead> \t\t<tbody> table_head; $html .= '<thead> <tr> <th style="text-align:center;" >Subject</th> <th style="padding-left:10px;text-align:left;" colspan=4 valign="top"><code>' . $sub2 . '</code></th> </tr>\\n<tr> <th style="text-align:center;width:10%;" > Class </th><th style="text-align:center;width:15%;" > Id </th> <th style="text-align:center;width:10%;" > RNo</th><th style="text-align:center;" > Name </th><th style="text-align:center;width:10%;" > Percentage </th> </tr> </thead> <tbody>'; $pcs++; //print_r($poor); foreach ($poor as $key => $val) { $brcls = $key; //$val2 = $poor[$brcls]; //print_r($val2); foreach ($val as $key1 => $value1) { $det = explode("_", $value1); $rn = $det[0]; $name = $det[2]; $per = $det[1]; $lnk = "./students.php?" . $key1 . "/sub"; echo '<tr onclick="document.location.href=\'' . $lnk . '\';" style="cursor:pointer;"><td style="text-align:center;">' . $brcls . '</td><td style="text-align:center;">' . $key1 . '</td><td style="text-align:center;" class = "span1">' . $rn . '</td><td class = "span3">' . $name . '</td><td style="text-align:center;" class="text-error">' . $per . '%</td></tr>'; $tr = '<tr ><td style="text-align:center;">' . $brcls . '</td><td style="text-align:center;">' . $key1 . '</td><td style="text-align:center;" class = "span1">' . $rn . '</td><td class = "span3" style="text-align:left;">' . $name . '</td><td style="text-align:center;" ><font color=darkred>' . $per . '%</font></td></tr>'; $html .= $tr; $pct++; } } $html .= '</tbody>'; //if($mn != count($poor)) {$html .= '</table><br>';} echo "</tbody></table>"; if ($row['Position'] == "BA") { echo <<<a \t\t<form action='print.php' method='post' name='abc'> \t\t<input type='hidden' name='Title1' value="{$branch} - {$p} - Poor Attendance Report"> \t\t<input type='hidden' name='Table1' value='{$html}'> \t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as PDF</button></center> \t\t</form> a; echo <<<b \t\t<form action='excel.php' method='post' name='abc'> \t\t<input type='hidden' name='Title1' value="{$branch} - {$p} - Poor Attendance Report"> \t\t<input type='hidden' name="sheet" value='{$html}'> \t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as Excel Sheet</button></center> \t\t</form> b; } //echo $html; echo "</div>"; display_footer(); echo "\n</body>\n</html>"; } else { echo "invalid subject"; } } }
function generate_attendance($title) { if (!check('CR')) { header('location:./?sub'); } else { if (!check_day()) { $p = $_SERVER['QUERY_STRING']; $reg = '/^P[1-4]$/'; if (preg_match($reg, $p)) { include 'config/db.php'; include 'config/settings.php'; include 'config/globals.php'; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); $userid = $_SESSION['UserId']; $q = "select Branch,Class from {$table} where Id = '{$userid}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); $branch = $row['Branch']; $class = $row['Class']; echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu(); echo <<<a \t\t\t \t<div class="container" style="margin-top:-10px;"><br> \t\t\t a; $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $class_total = mysql_num_rows(mysql_query("select `Id` from {$table}")); $sample = mt_rand(1, $class_total); $da = date('d-m-Y'); $date = date('d-m-Y'); $dbname = $branchyear . '_Dates'; $table = $branch . $class . '_Dates'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select Date from {$table} where Date = '{$da}'") or die(mysql_error()); if (mysql_num_rows($q) == 0) { $q = mysql_query("insert into {$table}(Date) values('{$da}')") or die(mysql_error()); $dbname = $branchyear . '_Cache'; $table = $branch . $class . '_Cache'; //if(!mysql_select_db($dbname)) die(mysql_error()); for ($j = 1; $j <= 4; $j++) { $q = mysql_query("alter table {$table} add `" . $da . "_P" . $j . "` varchar(2);") or die(mysql_error()); } insert_log($_SESSION['UserId'] . " added {$date} Cache columns to {$table}"); $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("alter table {$table} add `" . $da . "` varchar(30) default '';") or die(mysql_error()); insert_log($_SESSION['UserId'] . "added {$date} to Attendance columns to {$table}"); } echo <<<a \t\t\t<div id="error" style="display:none;margin-top:10px;"></div> \t\t\t \t\t<div class="row"> \t\t\t\t<div class='span9'> \t\t\t\t\t<div class="well well-large" style="background:#FFF;"> a; $dbname = $branchyear . '_Dates'; $table = $branch . $class . '_Dates'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select {$p},`" . $p . "_Con` from {$table} where Date = '{$da}';") or die(mysql_error()); $row = mysql_fetch_array($q); $a = $da . '_' . $p; if (isset($_POST['Generate'])) { if ($row[$p] == 'ok') { echo "<script>show_error('{$p} Attendance has been already uploaded ');</script>"; } else { $key2 = addslashes($_POST['Skey']); $table = $branchyear . '_CRs'; $q = "select `Id`,`Key` from {$table} where `Id` = '{$userid}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); $key1 = $row['Key']; if ($key1 != $key2) { echo "<script>show_error('<b>Error </b> : CR Security Key does not matched. Please try again.. ');</script>"; } else { $dbname = $branchyear . '_Cache'; $table = $branch . $class . '_Cache'; //if(!mysql_select_db($dbname))die(mysql_error()); $less = addslashes($_POST['Less']); $rnos = addslashes($_POST['RNos']); $lastone = $rnos[strlen($rnos) - 1]; $rollno[$less] = $lastone != ',' ? explode(',', $rnos) : explode(',', $rnos, -1); if ($less == "Absents") { for ($i = 1, $c = 0; $i <= $class_total; $i++) { if (!in_array($i, $rollno["Absents"])) { $rollno["Presents"][$c++] = $i; } } } else { for ($i = 1, $c = 0; $i <= $class_total; $i++) { if (!in_array($i, $rollno["Presents"])) { $rollno["Absents"][$c++] = $i; } } } if (array_key_exists('Absents', $rollno)) { foreach ($rollno['Absents'] as $val) { $insert = mysql_query("UPDATE " . $table . " SET `{$a}` = 'A' WHERE RNo ='{$val}';") or die(mysql_error()); } } if (array_key_exists('Presents', $rollno)) { foreach ($rollno['Presents'] as $val) { $insert = mysql_query("UPDATE " . $table . " SET `{$a}` = 'P' WHERE RNo ='{$val}';") or die(mysql_error()); } } $dbname = $branchyear . '_Dates'; $table = $branch . $class . '_Dates'; //if(!mysql_select_db($dbname)) die(mysql_error()); $in = mysql_query("UPDATE " . $table . " SET `{$p}` = 'ok' WHERE Date ='{$da}';") or die(mysql_error()); echo "<script>show_success('{$p} Attendance has been uploaded ');</script>"; } } } $dbname = $branchyear . '_Dates'; $table = $branch . $class . '_Dates'; //if(!mysql_select_db($dbname)) die(mysql_error()); $remaining = array(); $j = 0; $remaining1 = array(); $j1 = 0; $confired = array(); $j2 = 0; $confired1 = array(); $j3 = 0; for ($i = 1; $i <= 4; $i++) { $tmp = "P" . $i; $tmp1 = "P" . $i . "_Con"; $q = mysql_query("select ISNUll(`{$tmp}`) as `P{$i}`,ISNUll(`{$tmp1}`) as `P" . $i . "_C` from {$table} where Date = '{$da}' ") or die(mysql_error()); $res = mysql_fetch_array($q); if ($res["P" . $i]) { $remaining[$j] = "P" . $i; $j++; } else { $remaining1[$j1] = "P" . $i; $j1++; } if ($res["P" . $i . "_C"]) { $confired[$j2] = "P" . $i; $j2++; } else { $confired1[$j3] = "P" . $i; $j3++; } } $dates1 = getdate(strtotime($da)); $day = substr($dates1["weekday"], 0, 3); $dbname = $branchyear . '_TimeTable'; $table = $branch . $class . '_TimeTable'; //if(!mysql_select_db($dbname)) die(mysql_error()); $ti = mysql_query("SELECT DayPeriod,{$day} from {$table};") or die(mysql_error()); $subjects = array(); while ($da = mysql_fetch_array($ti)) { $subjects[$da[0]] = $da[1]; } $sub = $subjects[$p]; if (in_array($p, $remaining1)) { echo "<h5 style='text-align:center;'> Attendance Submission Details - {$branch} {$class}</h5><br>"; //$p="P".$m; if (in_array($p, $confired1)) { $period = $p; $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select RNo,Id,`{$date}` from {$table};") or die(mysql_error()); $Rnos = array("Absents" => array(), "Presents" => array()); $aindex = 0; $pindex = 0; $uid = array(); while ($res = mysql_fetch_array($q)) { $uid[$res['RNo']] = $res['Id']; $z = explode(",", $res[$date]); for ($m = 0; $m < count($z); $m++) { $y = explode("_", $z[$m]); if ($y[0] == $period) { if ($y[1] == "A") { $Rnos['Absents'][$aindex] = $res[0]; $aindex++; } else { $Rnos['Presents'][$pindex] = $res[0]; $pindex++; } } } } } else { $da = date('d-m-Y'); $a = $da . '_' . $p; $dbname = $branchyear . '_Cache'; $table = $branch . $class . '_Cache'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q3 = mysql_query("SELECT RNo, `" . $a . "` FROM {$table}") or die(mysql_error()); $Rnos = array("Absents" => array(), "Presents" => array()); $aindex = 0; $pindex = 0; while ($individual = mysql_fetch_array($q3)) { if ($individual[$a] == "A") { $Rnos["Absents"][$aindex] = $individual["RNo"]; $aindex++; } if ($individual[$a] == "P") { $Rnos["Presents"][$pindex] = $individual["RNo"]; $pindex++; } } } $pc = count($Rnos["Presents"]); $ac = count($Rnos["Absents"]); $tot = $pc + $ac; //print_r($Rnos); //print_r($uid); echo <<<tab \t\t\t\t \t\t\t\t<div class="row"> \t\t\t\t\t<div class="span8"> \t\t\t\t\t<table class="table table-hover table-bordered" > \t\t\t\t\t\t<tbody> \t\t\t\t\t\t\t<tr> <td class="span2" style="text-align:center"> Date </td> <th class="text-warning span2" style="text-align:center"> {$date}</th> \t\t\t\t\t\t\t<td class="span2" style="text-align:center"> Subject </td> <th class="text-success span2" style="text-align:center"> {$sub}</th> </tr> \t\t\t\t\t\t</tbody> \t\t\t\t\t</table> \t\t\t\t\t</div> \t\t\t\t</div> <div class="row"> \t<div class="span8"> <table class="table table-hover table-bordered" > <thead> <tr> <th class="span2" style="text-align:center"> Period # </th> <th class="span3"> Presents </th> <th class="span3"> Absents </th> </tr> </thead> <tbody> <tr><td style="text-align:center;" >{$p}</td><td> tab; for ($i = 0; $i < $pc; $i++) { if ($i % 8 == 0 && $i != 0) { echo "<br>"; } if ($i == $pc - 1) { echo $Rnos["Presents"][$i]; } else { echo $Rnos["Presents"][$i] . ","; } } echo "</td><td>"; for ($i = 0; $i < $ac; $i++) { if ($i % 8 == 0 && $i != 0) { echo "<br>"; } if ($i == $ac - 1) { echo $Rnos["Absents"][$i]; } else { echo $Rnos["Absents"][$i] . ","; } } echo <<<tab \t\t\t\t\t\t</td></tr> \t\t\t\t\t\t<tr> \t\t\t\t\t\t\t<td style="text-align:center;" >Total (<b>{$class_total}</b>) </td> \t\t\t\t\t\t\t<td style="text-align:center;" class='text-success'> {$pc}</td> \t\t\t\t\t\t\t<td style="text-align:center;" class='text-error'>{$ac}</td> \t\t\t\t\t\t\t</tr> \t\t\t\t\t\t</tbody> \t\t\t\t\t</table> \t\t\t\t\t</div> \t\t\t\t</div> tab; } else { display_generate_form($p, $class_total, $sub, $branch . $class); } echo <<<a \t\t\t\t\t</div> \t\t\t\t</div> \t\t\t\t<div class='span3'> a; go_home(); echo '<ul class="nav nav-tabs nav-stacked">'; for ($i = 1; $i <= 4; $i++) { echo "<li><a href=\"?P{$i}\">P{$i}"; $period = "P" . $i; if (!in_array($period, $remaining)) { echo "<i class='icon-ok pull-right text-success' style=\"padding-top:5px;\"></i>"; } else { echo "<i class='icon-remove pull-right text-error' style='padding-top:5px;'></i>"; } echo '<i class="icon-chevron-right pull-left" style="padding-top:5px;"></i></a> </li>'; } echo "</ul></div>"; echo "</div> </div> "; display_footer(); echo "\n</body>\n</html>"; @mysql_close($con); } else { echo "<script type='text/javascript'>document.location.href='404.php';</script>"; } } else { noservice(); } } }
function generate_attendance($title) { if (!check_login()) { header('location:./login.php'); } else { if (!check_day()) { include 'config/globals.php'; $p = $_SERVER['QUERY_STRING']; $reg = "/^" . $globalbranch . "[1-" . $classno . "]{1}\$/"; if (preg_match($reg, $p)) { include 'config/db.php'; include 'config/settings.php'; include 'config/globals.php'; echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu(); echo <<<a \t\t\t \t<div class="container" style="margin-top:-10px;"><br> \t\t\t<div id="error" style="display:none;margin-top:10px;"></div> \t\t\t a; $table = ''; //$spread=''; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); $userid = $_SESSION['UserId']; $q = "select Branch,Class,Position from {$table} where Id = '{$userid}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); if ($row['Position'] == "BA") { $branch = $globalbranch; $class = substr($p, -1); } else { $branch = $row['Branch']; $class = $row['Class']; $class1 = substr($p, -1); if ($class1 != $class) { //echo 'i am in'; echo "<script type='text/javascript'>show_error('Error: Not authorised to access {$branch}{$class1} details.');</script>"; } } $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $class_total = mysql_num_rows(mysql_query("select `Id` from {$table}")); $sample = mt_rand(1, $class_total); $da = date('d-m-Y'); $date = date('d-m-Y'); echo <<<a \t\t\t \t\t\t \t\t<div class="row"> \t\t\t\t<div class='span12'> \t\t\t\t\t<div class="well well-large" style="background:#FFF;"> a; $dbname = $branchyear . '_Dates'; $table = $branch . $class . '_Dates'; //if(!mysql_select_db($dbname)) die(mysql_error()); $remaining = array(); $j = 0; $remaining1 = array(); $j1 = 0; $confired = array(); $j2 = 0; $confired1 = array(); $j3 = 0; for ($i = 1; $i <= 4; $i++) { $tmp = "P" . $i; $tmp1 = "P" . $i . "_Con"; $q = mysql_query("select ISNUll(`{$tmp}`) as `P{$i}`,ISNUll(`{$tmp1}`) as `P" . $i . "_C` from {$table} where Date = '{$da}' ") or die(mysql_error()); $res = mysql_fetch_array($q); if ($res["P" . $i]) { $remaining[$j] = "P" . $i; $j++; } else { $remaining1[$j1] = "P" . $i; $j1++; } if ($res["P" . $i . "_C"]) { $confired[$j2] = "P" . $i; $j2++; } else { $confired1[$j3] = "P" . $i; $j3++; } } $dates1 = getdate(strtotime($da)); $day = substr($dates1["weekday"], 0, 3); $dbname = $branchyear . '_TimeTable'; $table = $branch . $class . '_TimeTable'; //if(!mysql_select_db($dbname)) die(mysql_error()); $ti = mysql_query("SELECT DayPeriod,{$day} from {$table};") or die(mysql_error()); $subjects = array(); while ($da1 = mysql_fetch_array($ti)) { $subjects[$da1[0]] = $da1[1]; } //print_r($subjects); //$sub = $subjects[$p]; //echo "<h5 style='text-align:center;'> Attendance Submission Details - $branch $class - $date</h5><br>"; echo <<<a \t\t\t \t\t\t\t<div id="step1" class="span4"> \t\t\t\t\t<h5 class='text-info'>Today's Attendance Submission Details </h5> \t\t\t\t\t<h6>     -   Listing Data submitted from CR @ {$branch} {$class} </h6><br> \t\t\t\t</div> \t\t\t\t<div id="side1" class="span7" > \t\t\t\t\t<h6 class='text-right'><a href='./?sub'><i class='icon-home'></i> Home </a> </h6> a; if ($row['Position'] == "BA") { echo <<<a \t\t\t\t\t<h6 class='text-right'> a; for ($cl = 1; $cl <= $classno; $cl++) { echo "<a href='?{$globalbranch}{$cl}'>{$globalbranch}{$cl}</a> "; } echo <<<a \t\t\t\t\t</h6> a; } echo <<<a \t\t\t\t</div> \t\t\t a; $dbname = $branchyear . '_Dates'; $table = $branch . $class . '_Dates'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select Date from {$table} where Date = '{$da}'") or die(mysql_error()); if (count($remaining1) != 0 && mysql_num_rows($q) != 0) { $html = ""; echo '<table class="table table-hover table-bordered " style="padding:0px;"> <thead> <tr> <th style="text-align:center;" rowspan="2" valign="top"> RNo </th> <th style="text-align:center;" rowspan="2" valign="top"> Id </th> <th style="text-align:center;" > P1 </th> <th style="text-align:center;" > P2 </th> <th style="text-align:center;" > P3 </th> <th style="text-align:center;" > P4 </th> <th style="text-align:center;" rowspan=2> Presents </th> <th rowspan=2 style="text-align:center;" > Absents </th> </tr> <tr> <th style="text-align:center;" > ' . $subjects['P1'] . ' </th> <th style="text-align:center;" > ' . $subjects['P2'] . ' </th> <th style="text-align:center;" > ' . $subjects['P3'] . ' </th> <th style="text-align:center;" > ' . $subjects['P4'] . ' </th> </tr> </thead> <tbody>'; //$spread.=" \t \t P1 \t P2 \t P3 \t P4 \t \t \t\nRno\tID\t".$subjects['P1']."\t".$subjects['P2']."\t".$subjects['P3']."\t".$subjects['P4']."\tPresents\tAbsents\n"; $html .= "<thead><tr> \n\t\t\t\t\t\t\t\t<th rowspan=\"2\" width=8%> RNo </th> \n\t\t\t\t\t\t\t\t<th rowspan=\"2\" width=17%> ID </th> \n\t\t\t\t\t\t\t\t<th > P1 </th> <th > P2 </th>\n\t\t\t\t\t\t\t\t<th > P3 </th> <th > P4 </th> \n\t\t\t\t\t\t\t\t<th rowspan=2 width=14%> Presents </th> <th rowspan=2 width=14%> Absents </th>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr> \n\t\t\t\t\t\t\t\t<th > {$subjects['P1']}</th> <th >{$subjects['P2']}</th>\n\t\t\t\t\t\t\t\t<th > {$subjects['P3']} </th> <th > {$subjects['P4']} </th> \n\t\t\t\t\t\t\t</tr></thead>"; $Rnos = array(); $uid = array(); $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select Id, RNo from {$table};") or die(mysql_error()); while ($res = mysql_fetch_array($q)) { $uid[$res['RNo']] = $res['Id']; } for ($s = 0; $s < count($remaining1); $s++) { $p1 = $remaining1[$s]; if (in_array($p1, $confired1)) { $period = $p1; $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select RNo,Id,`{$date}` from {$table};") or die(mysql_error()); $aindex = 0; $pindex = 0; while ($res = mysql_fetch_array($q)) { //$uid[$res['RNo']]=$res['Id']; $z = explode(",", $res[$date]); for ($m = 0; $m < count($z); $m++) { $y = explode("_", $z[$m]); if ($y[0] == $period) { if ($y[1] == "A") { $Rnos[$p1]['Absents'][$aindex] = $res[0]; $aindex++; } else { $Rnos[$p1]['Presents'][$pindex] = $res[0]; $pindex++; } } } } } else { $da = date('d-m-Y'); $a = $da . '_' . $p1; $dbname = $branchyear . '_Cache'; $table = $branch . $class . '_Cache'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q3 = mysql_query("SELECT RNo, `" . $a . "` FROM {$table}") or die(mysql_error()); $aindex = 0; $pindex = 0; while ($individual = mysql_fetch_array($q3)) { if ($individual[$a] == "A") { $Rnos[$p1]["Absents"][$aindex] = $individual["RNo"]; $aindex++; } if ($individual[$a] == "P") { $Rnos[$p1]["Presents"][$pindex] = $individual["RNo"]; $pindex++; } } } } $tot = array('A' => 0, 'P' => 0); //print_r($uid); for ($w = 1; $w <= $class_total; $w++) { $tr2 = '<tr > <td style="text-align:center;">' . $w . ' </td> <td style="text-align:center;"> ' . $uid[$w] . ' </td>'; echo $tr2; //$spread.="$w \t {$uid[$w]} \t"; $html .= $tr2; $pc = 0; $ac = 0; for ($l = 1; $l <= 4; $l++) { $pl = "P" . $l; if (in_array($pl, $remaining1)) { if (array_key_exists("Absents", $Rnos[$pl]) && in_array($w, $Rnos[$pl]['Absents'])) { echo '<td style="text-align:center;" class="text-error"><b> <i class="icon-remove"></i> </b></td>'; $ac++; $html .= "<td><font color=\"darkred\">✖</font></td>"; } else { echo '<td style="text-align:center;" class="text-success"><b> <i class="icon-ok"></i> </b></td>'; $pc++; $html .= "<td><font color=\"green\">✔</font></td>"; } } else { echo '<td></td>'; $html .= '<td></td>'; //$spread.=" \t"; } } $tot['A'] += $ac; $tot['P'] += $pc; echo <<<a \t\t\t\t\t\t<td style="text-align:center;" class="text-success"><b> {$pc} </b> </td> \t\t\t\t\t\t<td style="text-align:center;" class="text-error"><b> {$ac} </b></td> \t\t\t\t\t</tr> \t\t\t\t\t a; $html .= "<td><font color=\"green\"><b>{$pc}</b></font></td><td><font color=\"darkred\"><b>{$ac}</b></font></td></tr>"; //$spread.="$pc \t $ac \n"; } echo "<tr><td colspan=6 style='text-align:center;'><b>Total</b></td><td style='text-align:center;' class='text-success'><b>" . $tot['P'] . "</b></td><td style='text-align:center;' class='text-error'><b>" . $tot['A'] . "</b></td></tr>"; $html .= "<tr><th colspan=6 style=\"text-align:center;\"> <b>Total</b> </th><td><b><font color=\"green\">" . $tot['P'] . "</font></b></td><td><b><font color=\"darkred\">" . $tot['A'] . "</font></b></td></tr>"; //$spread.="\t \tTotal\t \t \t \t{$tot['P']} \t {$tot['A']}"; echo "</tbody></table>"; if ($row['Position'] == "BA") { echo <<<a \t\t\t<form action='print.php' method='post' name='abc'> \t\t\t<input type='hidden' name='Title1' value="{$branch} {$class} - Daily Report"> \t\t\t<input type='hidden' name='Table1' value='{$html}'> \t\t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as PDF</button></center> \t\t\t</form> a; echo <<<b \t\t\t<form action='excel.php' method='post' name='abc'> \t\t\t<input type='hidden' name='Title1' value="{$branch} {$class} - Daily Report"> \t\t\t<input type='hidden' name="sheet" value='{$html}'> \t\t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as Excel Sheet</button></center> \t\t\t</form> b; } echo <<<a \t\t\t\t\t</div> \t\t\t\t</div> \t\t\t\t a; } else { echo "<br><h6><span class='text-error'><br><br><br>No Submissions found till now ...</span></h6><br></div>"; } echo "</div> </div> "; display_footer(); echo "\n</body>\n</html>"; @mysql_close($con); } else { echo "<script type='text/javascript'>document.location.href='404.php';</script>"; } } else { noservice(); } } }
function noservice() { include_once "functions.php"; $p = $_SERVER['REQUEST_URI']; echo "<!DOCTYPE html>\n<html>\n"; display_headers(" Error : No Sunday and Saturday Service ... "); echo "\n<body>"; echo <<<a \t<div class="container"> \t\t<div class='row'> \t\t\t<div class='span6'> \t\t\t\t<img src="assets/img/404.jpg"> \t\t\t</div> \t\t\t<div class="span6"> \t\t\t\t<br><br><br> \t\t\t\t<h3> Ohh No ..!</h3> \t\t\t\t<h6 class='text-error'>Service not avaliable Saturday and Sunday</h6> \t\t\t\t<u> {$p} </u> <br><br> \t\t\t\tBack to <a href="./?sub">Attendance Portal</a> \t\t\t</div> \t\t</div> \t</div> a; echo "\n</body>\n</html>"; }
function homepage($title) { if (!check_login()) { header('location:login.php'); } else { include 'config/db.php'; include 'config/settings.php'; $dbname = $branchyear . '_Users'; $table = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) {die(mysql_error());} $userid = $_SESSION['UserId']; $q = "select Position, Branch, Class ,RNo from {$table} where Id = '{$userid}'"; $res = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($res); $RNo = $row["RNo"]; $type = $row['Position']; $p = $_SERVER["QUERY_STRING"]; if ($row['Position'] == "BA") { $branch = $globalbranch; $class = substr($p, -1); } else { $branch = $row['Branch']; $class = $row['Class']; $class1 = substr($p, -1); if ($class1 != $class) { echo "<script type='text/javascript'>show_error('Error: Not authorised to access {$branch}{$class1} details.');</script>"; } } echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu(); $ndays = 5; /* Deatils Fetched */ /* Starting Weekly Period Wise Attendance */ if ($_SERVER["QUERY_STRING"] == $branch . $class) { echo <<<a \t<div class='container'>\t \t<div id='error' style='display:none'></div>\t\t\t\t\t a; $tr = ''; $tr1 = ''; $html = ""; //$table=''; $spread = ''; //mysql_select_db($branchyear."_Dates") or die(mysql_error()); $nodq = mysql_fetch_array(mysql_query("Select count(Date) from " . $branch . $class . "_Dates;")) or die(mysql_error()); $nod = $nodq[0]; ///////////////////// ********* Change value to 6 ************ /////////////////// //echo $nod; if ($nod < $ndays) { echo "<script type='text/javascript'>show_error('Weekly aren\\'t prepared yet now ..');</script>"; } else { $p = array(); $stats = array("Total" => 0, "Presents" => 0, "Absents" => 0); //echo $nod/2; for ($i = 1; $i <= $nod / $ndays; $i++) { //mysql_select_db($branchyear."_Dates") or die(mysql_error()); $p["Week" . $i] = array("P1_P" => 0, "P1_A" => 0, "P2_P" => 0, "P2_A" => 0, "P3_P" => 0, "P3_A" => 0, "P4_P" => 0, "P4_A" => 0); $que = mysql_query("select Date from " . $branch . $class . "_Dates LIMIT " . ($i - 1) * $ndays . ",{$ndays};") or die(mysql_error()); //echo 'select Date from '.$branch.$class.'_Dates LIMIT '.(($i-1)*2).',2;'; $p["Weeks" . $i] = array(); $p["Weeks" . $i]['Start'] = ""; while ($dates = mysql_fetch_array($que)) { //echo $dates[0]; if ($p["Weeks" . $i]['Start'] == "") { $p["Weeks" . $i]['Start'] = $dates[0]; } $p["Weeks" . $i]['End'] = $dates[0]; //mysql_select_db($branchyear."_Attendance") or die(mysql_error()); $count_q = mysql_query("select count(`RNo`) from " . $branch . $class . "_Attendance;"); $countclass = mysql_fetch_array($count_q); $classcount = $countclass[0]; for ($init = 1; $init <= $classcount; $init++) { //mysql_select_db($branchyear."_Attendance") or die(mysql_error()); $q = mysql_query("select `" . $dates[0] . "` from " . $branch . $class . "_Attendance where RNo='" . $init . "';"); while ($res = mysql_fetch_array($q)) { $values = explode(",", $res[0]); for ($j = 0; $j < count($values) - 1; $j++) { if (substr($values[$j], -1) == "P") { $stats["Total"] += 1; $stats["Presents"] += 1; } if (substr($values[$j], -1) == "A") { $stats["Absents"] += 1; $stats["Total"] += 1; } $p["Week" . $i][$values[$j]] += 1; } } } //print_r($p['Week'.$i]); } } for ($lo = 1; $lo <= count($p) / 2; $lo++) { $tr .= '<tr ><td style="text-align:center;">' . $lo . ' </td> <td style="text-align:center;"> ' . $p["Weeks" . $lo]['Start'] . ' </td> <td style="text-align:center;"> ' . $p["Weeks" . $lo]['End'] . ' </td> <td style="text-align:center;"> ' . $ndays . ' </td>'; foreach ($p["Week" . $lo] as $key => $value) { $tr .= '<td style="text-align:center;" ><font color=dark' . (substr($key, -1) == 'A' ? 'red' : 'green') . '>' . $value . '</font> </td> '; $tr .= '<td style="text-align:center;" ><font color=dark' . (substr($key, -1) == 'A' ? 'red' : 'green') . '>' . round($value / $ndays, 1) . '</font></td> '; } $tr .= '</tr >'; } $dd = date('d-m-Y'); echo <<<a \t\t<div class="well well-large" style="background:#FFF;">\t \t\t<div class="row"> <div id="step1" class="span4"> <a ><h5>Weekly Attendance Report for {$branch} {$class} </h5></a> <h6>     -   Lising Data submitted from CR @ {$branch} {$class} </h6><br> </div> <div id="side1" class="span7" > \t<h6 class='text-right'><a href='./?sub'><i class='icon-home'></i> Home </a> </h6> a; if ($row['Position'] == "BA") { echo <<<a \t\t\t\t\t<h6 class='text-right'> a; for ($cl = 1; $cl <= $classno; $cl++) { echo "<a href='./?{$globalbranch}{$cl}'>{$globalbranch}{$cl}</a> "; } echo <<<a \t\t\t\t\t</h6> a; } echo <<<a \t\t\t\t\t</div> </div> \t\t <table class="table table-hover table-bordered " style="padding:0px;"> <thead> <tr> <th style="text-align:center;" rowspan="2" valign="top"> SNo </th> <th style="text-align:center;" colspan="2" valign="top"> Date </th> \t\t\t\t<th style="text-align:center;" rowspan="2" valign="top"> WD </th> <th style="text-align:center;" colspan="4"> P1 </th> <th style="text-align:center;" colspan="4"> P2 </th> <th style="text-align:center;" colspan="4"> P3 </th> <th style="text-align:center;" colspan="4"> P4 </th> </tr> <tr> <th style="text-align:center;" > Start </th> <th style="text-align:center;"> End </th> <th style="text-align:center;" > P </th> <th style="text-align:center;"> P/D </th> <th style="text-align:center;" > A </th> <th style="text-align:center;"> A/D </th> \t\t \t\t\t\t<th style="text-align:center;" > P </th> <th style="text-align:center;"> P/D </th> <th style="text-align:center;" > A </th> <th style="text-align:center;"> A/D </th> <th style="text-align:center;" > P </th> <th style="text-align:center;"> P/D </th> <th style="text-align:center;" > A </th> <th style="text-align:center;"> A/D </th> \t\t \t\t\t\t<th style="text-align:center;" > P </th> <th style="text-align:center;"> P/D </th> <th style="text-align:center;" > A </th> <th style="text-align:center;"> A/D </th> </tr> </thead> <tbody> a; $html .= '<thead> <tr> <th style="text-align:center;" rowspan="2" valign="bottom"> SNo </th> <th style="text-align:center;" colspan="2" valign="bottom"> Date </th> <th style="text-align:center;" rowspan="2" valign="bottom"> WD </th> <th style="text-align:center;" colspan="4"> P1 </th> <th style="text-align:center;" colspan="4"> P2 </th> <th style="text-align:center;" colspan="4"> P3 </th> <th style="text-align:center;" colspan="4"> P4 </th> </tr> <tr> <th style="text-align:center;" > Start </th> <th style="text-align:center;"> End </th> <th style="text-align:center;" > P </th> <th style="text-align:center;"> P/D </th> <th style="text-align:center;" > A </th> <th style="text-align:center;"> A/D </th> <th style="text-align:center;" > P </th> <th style="text-align:center;"> P/D </th> <th style="text-align:center;" > A </th> <th style="text-align:center;"> A/D </th> <th style="text-align:center;" > P </th> <th style="text-align:center;"> P/D </th> <th style="text-align:center;" > A </th> <th style="text-align:center;"> A/D </th> <th style="text-align:center;" > P </th> <th style="text-align:center;"> P/D </th> <th style="text-align:center;" > A </th> <th style="text-align:center;"> A/D </th> </tr> </thead> <tbody>'; $html .= $tr . "</tbody></table>"; $html .= "\n\t<br>\n\t<table style=\"border-collapse:collapse;width:100%;margin-left:0%;font-size:12px;text-align:center;\" border=1 >\n\t\t<tr>\n\t\t\t<th>Short Name</th><th> Long Name</th>\n\t\t\t<th>Short Name</th><th> Long Name</th>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<th>P</th><td>No. of Presents</td>\t\n\t\t\t<th>A</th><td>No. of Absents</td>\n\t\t</tr>\n\t\t<tr>\t\n\t\t\t<th>P/D</th><td>No. of Presents per Day</td>\n\t\t\t<th>A/D</th><td>No. of Absents per Day</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<th>WD</th><td>No. of days in a Week</td>\n\t\t</tr>"; echo $tr; echo <<<tableend \t</tbody> </table> <table class='table table-hover table-bordered ' > \t\t<tr> \t\t\t<th>Short Name</th><th> Long Name</th> \t\t\t<th>Short Name</th><th> Long Name</th> \t\t</tr> \t\t<tr> \t\t\t<th>P</th><td>No. of Presents</td>\t \t\t\t<th>A</th><td>No. of Absents</td> \t\t</tr> \t\t<tr>\t \t\t\t<th>P/D</th><td>No. of Presents per Day</td> \t\t\t<th>A/D</th><td>No. of Absents per Day</td> \t\t</tr> \t\t<tr> \t\t\t<th>WD</th><td>No. of days in a Week</td> \t\t</tr> </table> tableend; if ($row['Position'] == "BA") { echo <<<a \t\t\t<form action='print.php' method='post' name='abc'> \t\t\t<input type='hidden' name='Title1' value="{$branch} {$class} - Weekly Report"> \t\t\t<input type='hidden' name='Table1' value='{$html}'> \t\t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as PDF</button></center> \t\t\t</form> a; echo <<<b \t\t\t<form action='excel.php' method='post' name='abc'> \t\t\t<input type='hidden' name='Title1' value="{$branch} {$class} - Weekly Report"> \t\t\t<input type='hidden' name="sheet" value='{$html}'> \t\t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as Excel Sheet</button></center> \t\t\t</form> b; } echo <<<tableend </div> </div> tableend; } } /* End of Weekly Period Wise Attendance*/ echo '</div></body></html>'; } }
function changecr($title) { /* checks the user login and * redirecting user to login page */ if (!check_login()) { header('location:login.php'); } else { include 'config/globals.php'; /* taking the query string by using the regular expression */ $p = $_SERVER['QUERY_STRING']; $reg = "/^" . $globalbranch . "[1-" . $classno . "]{1}\$/"; $reg1 = "/^all\$/"; if (preg_match($reg, $p) or preg_match($reg1, $p)) { /* including the necessary configuration php files */ include 'config/db.php'; include 'config/settings.php'; /* defining the table names */ $dbname = $branchyear . '_Users'; $table = $branchyear . '_CRs'; $table1 = $branchyear . '_Students'; //if(!mysql_select_db($dbname)) die(mysql_error()); //$branch = $row['Branch']; its not required $class = substr($p, -1); /* Getting the users details from joining the two tables */ if ($p == 'all') { $q = "select {$table}.Name as Name, {$table}.Gender as Gender, {$table}.Id as Id,PhoneNo, `{$table1}`.`Class` as `Class` from {$table},{$table1} where `{$table}`.`Id` = `{$table1}`.`Id` order by `{$table1}`.`Class` Desc;"; } else { $q = "select {$table}.Name as Name, {$table}.Gender as Gender, {$table}.Id as Id,PhoneNo from {$table},{$table1} where `{$table}`.`Id` = `{$table1}`.`Id` and `{$table}`.`Class` = '{$class}';"; } $res = mysql_query($q) or die(mysql_error()); echo "<!DOCTYPE html>\n<html>\n"; /* including the header java scripts and css files */ display_headers($title); echo "\n<body>"; /* displayin the header menu */ menu(); $br = $p == 'all' ? $globalbranch : $p; $cls1 = $p == 'all' ? '<th style="text-align:center;" class="span1"> Class </th>' : ""; echo <<<a \t\t<div class='container'> \t\t\t<div id="error" style="display:none;"></div> \t\t\t<div class='row'> \t\t\t<div class='span9'> \t\t\t\t<div class="well well-large" style="background:#FFF;"> \t\t\t\t<h5 class='text-info'>CRs @ {$br} </h5> \t\t\t\t<h6>     -   Listing all CRs in {$br} </h6><br> \t\t\t\t<table class="table table-hover table-bordered " style="padding:0px;"> \t\t\t\t<thead> \t\t\t\t\t<tr> <th class="span1" style="text-align:center;" > Id </th><th style="text-align:center;" class="span3"> Name </th> {$cls1} \t\t\t\t\t<th style="text-align:center;" class="span1"> Gender </th> <th class="span1" style="text-align:center;"> Contact No </th> </tr> \t\t\t\t</thead> \t\t\t\t<tbody> a; while ($row = mysql_fetch_array($res)) { $gender = $row['Gender']; $d = $dict[$gender . '1']; $id = $row['Id']; $contact = $row['PhoneNo']; $cls = $p == 'all' ? '<td style="text-align:center;">' . $globalbranch . " " . $row['Class'] . '</td>' : ""; $name = ucwords(strtolower($row['Name'])); echo <<<a \t\t\t\t\t \t\t\t<tr > \t\t\t<td style="text-align:center;" > {$id} </td> \t\t\t<td > {$name} </td> \t\t\t{$cls} \t\t\t<td style="text-align:center;"> {$d} </td> \t\t\t<td style="text-align:center;" class="text-success"><b> {$contact} </b> </td> \t\t\t</tr> a; } echo <<<a \t\t\t\t</tbody> \t\t\t </table> \t\t\t</div>\t \t\t\t</div> \t\t\t<div class='span3'> a; go_home(); echo '<ul class="nav nav nav-tabs nav-stacked"> <li><a href=\'?all\'>All CRs <i class="icon-chevron-right pull-left" style="padding-top:5px;"></i></a> </li></ul>'; cr_classes($classno, $globalbranch); echo "</div></div></div>"; display_footer(); echo "\n</body>\n</html>"; } else { echo "<script type='text/javascript'>document.location.href='404.php';</script>"; } } }
function generate_attendance($title) { if (!check('BA')) { header('location:./?sub'); } else { include 'config/db.php'; include 'config/settings.php'; include 'config/globals.php'; echo "<!DOCTYPE html>\n<html>\n"; display_headers($title); echo "\n<body>"; menu(); $branch = $globalbranch; echo <<<a \t\t \t<div class="container" style="margin-top:-10px;"><br> \t\t<div class="well well-large" style="background:#FFF;"> \t\t<div id='error'></div> a; /*echo <<< a \n\t\t<div class="row"> <div class='span12'> <div class="well well-large" style="background:#FFF;"> a;*/ echo <<<a \t\t \t\t\t<div id="step1" class="span5"> \t\t\t\t<h5 class='text-info'>Daily Attendance Submission Details </h5> \t\t\t\t<h6>     -   Lising Data submitted from All CRs @ {$branch} </h6><br> \t\t\t</div> \t\t\t<div id="side1" class="span6" > \t\t\t\t<h6 class='text-right'><a href='./?sub'><i class='icon-home'></i> Home </a> </h6> \t\t\t</div> \t\t a; $userid = $_SESSION['UserId']; $ar1 = array(); $datez = array(); $dtcon = 0; $html = ""; for ($cln = 1; $cln <= $classno; $cln++) { $class = $cln; $branch = $globalbranch; $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $class_total = mysql_num_rows(mysql_query("select `Id` from {$table}")); $sample = mt_rand(1, $class_total); //$da = date('d-m-Y'); //$date = date('d-m-Y'); $ar = array(); for ($j = 1; $j <= 4; $j++) { $prd = "P" . $j; $prd1 = $prd . "_Con"; $dates = array(); $coun = 0; //mysql_select_db($branchyear."_Dates") or die(mysql_error()); $q = mysql_query("Select Date from " . $branch . $class . "_Dates where `{$prd1}` ='ok' ;") or die(mysql_error()); $nodq = mysql_num_rows($q); $ar[$prd]['nod'] = $nodq; while ($dad = mysql_fetch_array($q)) { $dates[$coun++] = $dad[0]; if (!in_array($dad[0], $datez)) { $datez[$dtcon++] = $dad[0]; } } //var_dump($da); foreach ($dates as $key => $da) { $ar[$prd][$da]["Presents"] = 0; $ar[$prd][$da]["Absents"] = 0; $dbname = $branchyear . '_Attendance'; $table = $branch . $class . '_Attendance'; //if(!mysql_select_db($dbname)) die(mysql_error()); $q = mysql_query("select RNo, `{$da}` from {$table}") or die(mysql_error()); while ($res = mysql_fetch_array($q)) { $exp = explode(",", $res[$da]); for ($z = 0; $z < count($exp); $z++) { if (substr($exp[$z], 0, 2) == $prd) { if (substr($exp[$z], -1) == "A") { $ar[$prd][$da]["Absents"] += 1; } else { $ar[$prd][$da]["Presents"] += 1; } } } } //echo $da."\n"; } } $ar1[$branch . $class] = $ar; } //print_r($datez); //print_r($ar1); $tr = ''; $html_tr = ""; for ($j = 0; $j < count($datez); $j++) { $date = $datez[$j]; $pr_tot = 0; $tr .= '<tr><td style="text-align:center;" >' . ($j + 1) . ' </td> <td style="text-align:center;" >' . $datez[$j] . ' </td> '; $html_tr .= "<tr><td>" . ($j + 1) . "</td><td>" . $datez[$j] . "</td>"; for ($l = 1; $l <= $classno; $l++) { $cls = $globalbranch . $l; for ($k = 1; $k <= 4; $k++) { $prd = "P" . $k; @($pres = $ar1[$cls][$prd][$date]['Presents']); $tr .= '<td style="text-align:center;" class="text-success" > ' . $pres . ' </td>'; $html_tr .= "<td><font color=\"green\">" . $pres . "</font></td>"; } } } echo <<<a \t\t \t\t <table class="table table-hover table-bordered " style="padding:0px;"> \t\t\t\t\t<thead> \t\t\t\t\t\t<tr> \t\t\t\t\t\t\t<th style="text-align:center;" rowspan=2 valign="top"> SNo </th> \t\t\t\t\t\t\t<th style="text-align:center;" rowspan=2 valign="top"> Date </th> a; $html .= "<thead><tr><th rowspan=2>SNo</th><th rowspan=2>Date</th>"; for ($i = 1; $i <= $classno; $i++) { echo <<<a \t\t\t\t\t\t\t<th style="text-align:center;" colspan=4> {$branch}{$i} </th> a; $html .= "<th colspan=4>" . $branch . $i . "</th>"; } echo <<<a \t\t\t\t\t\t\t \t\t\t\t\t\t</tr> \t\t\t\t\t\t<tr> a; $html .= "</tr><tr>"; for ($i = 0; $i < $classno; $i++) { echo <<<a \t\t\t\t\t\t\t<th style="text-align:center;" > P1 </th> <th style="text-align:center;" > P2 </th> \t\t\t\t\t\t\t<th style="text-align:center;" > P3 </th> <th style="text-align:center;" > P4 </th> a; $html .= "<th>P1</th><th>P2</th><th>P3</th><th>P4</th>"; } echo <<<a \t\t\t\t\t\t</tr> \t\t\t\t\t\t \t\t\t\t\t</thead> \t\t\t\t\t<tbody>\t\t\t\t\t\t\t a; $html .= "</tr></thead>"; $html .= $html_tr; echo $tr; echo "</tbody></table>"; echo <<<a \t\t\t<form action='print.php' method='post' name='abc'> \t\t\t<input type='hidden' name='Title1' value="{$branch} Period Wise Report"> \t\t\t<input type='hidden' name='Table1' value='{$html}'> \t\t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as PDF</button></center> \t\t\t</form> a; echo <<<b \t\t\t<form action='excel.php' method='post' name='abc'> \t\t\t<input type='hidden' name='Title1' value="{$branch} Period Wise Report"> \t\t\t<input type='hidden' name="sheet" value='{$html}'> \t\t<center><button type="submit" class="btn btn-primary"><i class='icon-download-alt'></i> Save as Excel Sheet</button></center> \t\t\t</form> b; //echo "</div> </div> </div> "; echo "</div>"; display_footer(); echo "\n</body>\n</html>"; @mysql_close($con); } }