Example #1
0
 function index($site = '', $y = '', $m = '', $d = '', $item_number = 0)
 {
     $data['domains'] = get_domains();
     $data['y'] = check_year($y);
     $data['m'] = check_month($m);
     $data['d'] = check_day($d);
     $data['site'] = check_site($site, $data['domains']);
     $data['item_number'] = $item_number;
     $current_date = array('y' => $data['y'], 'm' => $data['m'], 'd' => $data['d']);
     $doThis = whatToDo($data['y'], $data['m'], $data['d'], $data['site']);
     $data['doThis'] = $doThis;
     switch ($doThis) {
         case "day":
             //previous
             $previous_feed_date = extract_feed_date($this->_get_previous_feed($data['domains'], $data['site'], $current_date), $data['site']);
             $data['yesterday'] = $data['site'] . '/' . $previous_feed_date['y'] . '/' . $previous_feed_date['m'] . '/' . $previous_feed_date['d'];
             //current
             $data['feedUrl'] = "feeds/" . $data['site'] . "/" . $data['site'] . $data['y'] . $data['m'] . $data['d'] . "." . $data['domains'][$data['site']]['type'];
             //view
             if (file_exists($data['feedUrl'])) {
                 $data['title'] = 'Popular links on ' . $data['domains'][$data['site']]['name'] . ' ' . $data['y'] . '/' . $data['m'] . '/' . $data['d'] . ' | rrrewind';
                 $data['view'] = 'view_show';
                 $data['items'] = $this->get_items($data['domains'], $data['site'], $data['feedUrl']);
             } else {
                 //the file DONT exist
                 $data['view'] = 'view_archives';
             }
             break;
         case "recent":
             //current
             $recent_feed = get_recent_feed($data['site']);
             $data['feedUrl'] = "feeds/" . $data['site'] . "/" . $recent_feed;
             //previous
             $current_date = extract_feed_date($recent_feed, $data['site']);
             $previous_feed_date = extract_feed_date($this->_get_previous_feed($data['domains'], $data['site'], $current_date), $data['site']);
             $data['yesterday'] = $data['site'] . '/' . $previous_feed_date['y'] . '/' . $previous_feed_date['m'] . '/' . $previous_feed_date['d'];
             $data['y'] = $current_date['y'];
             $data['m'] = $current_date['m'];
             $data['d'] = $current_date['d'];
             $data['title'] = 'Popular links on ' . $data['domains'][$data['site']]['name'] . ' ' . $data['y'] . '/' . $data['m'] . '/' . $data['d'] . ' | rrrewind';
             $data['items'] = $this->get_items($data['domains'], $data['site'], $data['feedUrl']);
             //view
             $data['view'] = 'view_show';
             break;
         case "error":
             $data['view'] = 'view_error';
             break;
     }
     $this->load->view('template', $data);
 }
function check_date($date)
{
    if ($date === '') {
        return 0;
    }
    $res = preg_match_all("/^([^\\.]+)\\.([^\\.]+)\\.([^\n]+)\n/", "{$date}\n", $parts, PREG_PATTERN_ORDER);
    if ($res != 1) {
        return 0;
    }
    if (check_day($parts[1][0]) && check_month($parts[2][0]) && check_year($parts[3][0])) {
        return 1;
    }
    return 0;
}
 $DayOfWeek = date("w", strtotime($strStartDate));
 if ($DayOfWeek == 0 or $DayOfWeek == 6) {
     $intHoliday++;
     //echo "$strStartDate = <font color=red>Holiday</font><br>";
     if ($SS == "T") {
         list($tyear, $tmonth, $tday) = explode("-", $strStartDate);
         if (check_day($tday, $tmonth, $tyear) == "Sat") {
             if (check_holiday($tday, $tmonth, $tyear) == "T") {
                 $s_day[$v] = "Saturday" . "-" . $strStartDate;
                 $SS = "T";
             } else {
                 $s_day[$v] = "Sat" . "-" . $strStartDate;
                 $z = $z + 3;
             }
         } else {
             if (check_day($tday, $tmonth, $tyear) == "Sun") {
                 if (check_holiday($tday, $tmonth, $tyear) == "T") {
                     $s_day[$v] = "Sunday" . "-" . $strStartDate;
                     $SS = "T";
                 } else {
                     $s_day[$v] = "Sun" . "-" . $strStartDate;
                     $z = $z + 2;
                 }
             }
         }
         $v++;
         // นับวันทั้งหมดที่สอน
     }
     // หาวัน เสา หรืออาทิตย์
     if ($z >= $c4) {
         $SS = "F";
Example #4
0
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}&nbsp;{$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();
        }
    }
}
Example #5
0
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}&nbsp;{$class} </h5>
\t\t\t\t\t<h6> &emsp;&emsp;&emsp; - &emsp; 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&nbsp;</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>&emsp;";
                    }
                    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>&emsp;{$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>&nbsp;&nbsp;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>&nbsp;&nbsp;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();
        }
    }
}
Example #6
0
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&nbsp;$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> &emsp;&emsp;&emsp; - &emsp; Listing Data submitted from CR @ {$branch}&nbsp;{$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&nbsp;</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>&emsp;";
                    }
                    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\">&#x2716;</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\">&#x2714;</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>&nbsp;&nbsp;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>&nbsp;&nbsp;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();
        }
    }
}
Example #7
0
function validate_data($table, $data_array)
{
    if ($table == 'patients') {
        if (!is_numeric($data_array['PatientCode'])) {
            if (!is_numeric($data_array['MELCode'])) {
                show_errormsg('Πρέπει να συμπληρώσετε τουλάχιστον ένα από τα πεδία Κωδικός Ασθενή ή Κωδικός ΜΕΛ');
            }
        }
        if ($data_array['Name'] == "" || $data_array['Surname'] == "") {
            show_errormsg('Πρέπει να συμπληρώσετε σωστά το ονοματεπώνυμο του ασθενή');
        }
        if ($data_array['BirthDate_year'] == "") {
            show_errormsg('Πρέπει να συμπληρώσετε την ημερομηνία γέννησης του ασθενή');
        }
    }
    if ($table == 'demographic_data') {
        if ($data_array['Race'] == "") {
            show_errormsg('Πρέπει να επιλέξετε μια φυλή για τον ασθενή');
        }
        if ($data_array['Sex'] == "") {
            show_errormsg('Πρέπει να επιλέξετε φύλο για τον ασθενή');
        }
        if ($data_array['KnownDateOrometatropi'] == "") {
            show_errormsg('Πρέπει να επιλέξετε αν ο ασθενής έχει γνωστή ημερομηνία ορομετατροπής');
        }
        if ($data_array['ClinicDuringRecord'] == "") {
            show_errormsg('Πρέπει να επιλέξετε μια κλινική παρακολούθησης κατά την καταγραφή');
        }
        //       if ($data_array['PreviousClinic'] == "")
        //       { show_errormsg('Πρέπει να επιλέξετε μια προηγούμενη κλινική παρακολούθησης');}
        if ($data_array['PossibleSourceInfection'] == "") {
            show_errormsg('Πρέπει να επιλέξετε μια πιθανή πηγή μόλυνσης');
        }
        if ($data_array['PossibleSourceInfection'] == "6") {
            if ($data_array['TransfusionPlace'] == "") {
                show_errormsg('Πρέπει να δώσετε μια τιμή στο πεδίο Τόπος Μετάγγισης');
            }
        }
    }
    if ($table == 'atomiko_anamnistiko') {
        /*     	if ($data_array['num_neoplasmata'] > 0)
             	{
             		for ($i=0; $i<$data_array['num_neoplasmata']; $i++)
             		{
             			$j=$i+1;
             			if ($data_array['NeoplasmaID'.$i] == "")
             			{ show_error('atomic.php' , '3' ,'Πρέπει να επιλέξετε μια τιμή νεοπλάσματος για κάθε πεδίο!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
             			if (check_month($data_array['NeoplasmaDate'.$i.'_month']))
             			{ show_error('atomic.php' , '3' ,'Ο μήνας του νεοπλάσματος '.$j.' δεν είναι σωστός!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
             			if (check_day($data_array['NeoplasmaDate'.$i.'_day']))
             			{ show_error('atomic.php' , '3' ,'Η ημέρα του νεοπλάσματος '.$j.' δεν είναι σωστή!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
             		}
        			if (!isset($data_array['Hypertension']))
        			{ show_error('atomic.php' , '4' ,'Πρέπει να επιλέξετε μια τιμή για την υπέρταση!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']); }
          			if (check_month($data_array['HypertensionDate_month']))
           			{ show_error('atomic.php' , '5' ,'Ο μήνας της υπέρτασης δεν είναι σωστός!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
           			if (check_day($data_array['HypertensionDate_day']))
           			{ show_error('atomic.php' , '5' ,'Η ημέρα της υπέρτασης δεν είναι σωστή!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
        
           			if (!isset($data_array['Stefaniaia']))
        			{ show_error('atomic.php' , '6' ,'Πρέπει να επιλέξετε μια τιμή για την στεφανιαία νόσο!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']); }
          			if (check_month($data_array['StefaniaiaDate_month']))
           			{ show_error('atomic.php' , '7' ,'Ο μήνας της στεφανιαίας νόσου δεν είναι σωστός!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
           			if (check_day($data_array['StefaniaiaDate_day']))
           			{ show_error('atomic.php' , '7' ,'Η ημέρα της στεφανιαίας νόσου δεν είναι σωστή!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
        
           			if (!isset($data_array['Emfragma']))
        			{ show_error('atomic.php' , '8' ,'Πρέπει να επιλέξετε μια τιμή για το αν ο ασθενής έχει υποστεί έμφραγμα!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']); }
          			if (check_month($data_array['EmfragmaDate_month']))
           			{ show_error('atomic.php' , '9' ,'Ο μήνας του εμφράγματος δεν είναι σωστός!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
           			if (check_day($data_array['EmfragmaDate_day']))
           			{ show_error('atomic.php' , '9' ,'Η ημέρα του εμφράγματος δεν είναι σωστή!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
        
        			if (!isset($data_array['Diabitis']))
        			{ show_error('atomic.php' , '10' ,'Πρέπει να επιλέξετε μια τιμή για το αν πάσχει ο ασθενής απο σακχαρώδη διαβήτη!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']); }
          			if (check_month($data_array['DiabitisDate_month']))
           			{ show_error('atomic.php' , '11' ,'Ο μήνας του διαβήτη δεν είναι σωστός!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
           			if (check_day($data_array['DiabitisDate_day']))
           			{ show_error('atomic.php' , '11' ,'Η ημέρα του διαβήτη δεν είναι σωστή!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
        
        			if (!isset($data_array['Fat']))
        			{ show_error('atomic.php' , '12' ,'Πρέπει να επιλέξετε μια τιμή για το αν ο ασθενής έχει παρουσιάσει λιποτροφία/εναπόθεση λίπους!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']); }
          			if (check_month($data_array['FatDate_month']))
           			{ show_error('atomic.php' , '13' ,'Ο μήνας της λιποτροφίας/εναπόθεσης λίπους δεν είναι σωστός!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
           			if (check_day($data_array['FatDate_day']))
           			{ show_error('atomic.php' , '13' ,'Η ημέρα της λιποτροφίας/εναπόθεσης λίπους δεν είναι σωστή!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
        
        			for ($i=0; $i<$data_array['num_states']; $i++)
             		{
             			$j=$i+1;
             			if ($data_array['ClinicalStatusID'.$i] == "")
             			{ show_error('atomic.php' , '14' ,'Πρέπει να επιλέξετε μια τιμή κλινικής κατάστασης για κάθε πεδίο!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
             			if (check_month($data_array['ClinicalStatusDate'.$i.'_month']))
             			{ show_error('atomic.php' , '14' ,'Ο μήνας της κλινικής κατάστασης '.$j.' δεν είναι σωστός!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
             			if (check_day($data_array['ClinicalStatusDate'.$i.'_day']))
             			{ show_error('atomic.php' , '14' ,'Η ημέρα της κλινικής κατάστασης '.$j.' δεν είναι σωστή!', 'numsta='.$data_array['num_states'].'&numneo='.$data_array['num_neoplasmata']);}
             		}*/
    }
    if ($table == exams_orologikes) {
        /*			if (!isset($data_array['FTA']))
             	{ show_error('orologikes.php' , '' ,'Πρέπει να δώσετε μια τιμή για το FTA!', '');}			
        			if (!isset($data_array['VDRL']))
             	{ show_error('orologikes.php' , '' ,'Πρέπει να δώσετε μια τιμή για το VDRL!', '');}			
        			if (!isset($data_array['ToxoIgG']))
             	{ show_error('orologikes.php' , '' ,'Πρέπει να δώσετε μια τιμή για το Αντίσωμα για τοξόπλασμα - IgG!', '');}			
        			if (!isset($data_array['ToxoIgM']))
             	{ show_error('orologikes.php' , '' ,'Πρέπει να δώσετε μια τιμή για το Αντίσωμα για τοξόπλασμα - IgM!', '');}			
        			if (!isset($data_array['Anti-CMVIgG']))
             	{ show_error('orologikes.php' , '' ,'Πρέπει να δώσετε μια τιμή για το Anti-CMV - IgG!', '');}			
        			if (!isset($data_array['Anti-CMVIgM']))
             	{ show_error('orologikes.php' , '' ,'Πρέπει να δώσετε μια τιμή για το Anti-CMV - IgM!', '');}			
             	if (!isset($data_array['HBsAg']))
             	{ show_error('orologikes.php' , '' ,'Πρέπει να δώσετε μια τιμή για το HBsAg!', '');}			
        			if (!isset($data_array['Anti-HBs']))
             	{ show_error('orologikes.php' , '' ,'Πρέπει να δώσετε μια τιμή για το Anti-HBs!', '');}			
        			if (!isset($data_array['Anti-HBc']))
             	{ show_error('orologikes.php' , '' ,'Πρέπει να δώσετε μια τιμή για το Anti-HBc!', '');}			
        			if (!isset($data_array['HBAg']))
             	{ show_error('orologikes.php' , '' ,'Πρέπει να δώσετε μια τιμή για το HBAg!', '');}			
        			if (!isset($data_array['Anti-HBe']))
             	{ show_error('orologikes.php' , '' ,'Πρέπει να δώσετε μια τιμή για το Anti-HBe!', '');}			
        			if (!isset($data_array['Anti-HCV']))
             	{ show_error('orologikes.php' , '' ,'Πρέπει να δώσετε μια τιμή για το Anti-HCV!', '');}	
        			if (!isset($data_array['Anti-HDV']))
             	{ show_error('orologikes.php' , '' ,'Πρέπει να δώσετε μια τιμή για το Anti-HDV!', '');}	*/
    }
    if ($table == "exams_bioximikes") {
        $exams = $data_array['exams'];
        if (!is_numeric($data_array['MELCode'])) {
            show_error('bioximikes.php', '', 'Ο Κωδικός ΜΕΛ πρέπει να είναι αριθμός!', '&exams=' . $exams);
        }
        for ($i = 0; $i < $exams; $i++) {
            $j = $i + 1;
            if ($data_array['Sakxaro' . $i] == "") {
                show_error('bioximikes.php', '', 'Πρέπει να δώσετε μια τιμή για το ' . $j . 'ο σάκχαρο!', '&exams=' . $exams);
            }
            if ($data_array['ALT' . $i] == "") {
                show_error('bioximikes.php', '', 'Πρέπει να δώσετε μια τιμή για το ' . $j . 'ο ΑLT!', '&exams=' . $exams);
            }
            if ($data_array['AST' . $i] == "") {
                show_error('bioximikes.php', '', 'Πρέπει να δώσετε μια τιμή για το ' . $j . 'ο ΑST!', '&exams=' . $exams);
            }
            if ($data_array['Xolusterini' . $i] == "") {
                show_error('bioximikes.php', '', 'Πρέπει να δώσετε μια τιμή για την ' . $j . 'η χολυστερίνη!', '&exams=' . $exams);
            }
            if ($data_array['Triglukeridia' . $i] == "") {
                show_error('bioximikes.php', '', 'Πρέπει να δώσετε μια τιμή για τα ' . $j . 'α τριγλυκερίδια!', '&exams=' . $exams);
            }
        }
    }
    if ($table == "prophylactic_therapies") {
        $therapies = $data_array['therapies'];
        if (!is_numeric($data_array['MELCode'])) {
            show_error('prophylactic.php', '', 'Ο Κωδικός ΜΕΛ πρέπει να είναι αριθμός!&exams=' . $exams);
        }
        for ($i = 0; $i < $therapies; $i++) {
            $j = $i + 1;
            if ($data_array['Therapy' . $i] == "") {
                show_error('prophylactic.php', '', 'Πρέπει να δώσετε μια τιμή για την ' . $j . 'η προφυλακτική θεραπεία!', '&exams=' . $exams);
            }
            if ($data_array['Type' . $i] == "") {
                show_error('prophylactic.php', '', 'Πρέπει να δώσετε μια τιμή για τον ' . $j . 'ο τύπο!', '&exams=' . $exams);
            }
            if ($data_array['Reason' . $i] == "") {
                show_error('prophylactic.php', '', 'Πρέπει να δώσετε μια τιμή για την ' . $j . 'η αιτία διακοπής!', '&exams=' . $exams);
            }
            if ($data_array['Reason' . $i] == 4 && $data_array['OtherReason' . $i] == "") {
                show_error('prophylactic.php', '', 'Πρέπει να δώσετε μια τιμή για την ' . $j . 'η άλλη αιτία διακοπής!', '&exams=' . $exams);
            }
            if (!check_dates($data_array, 'TherapyDateStart' . $i, 'TherapyDateEnd' . $i)) {
                show_error('prophylactic.php', '', 'Οι ημερομηνίες έναρξης και διακοπής για την ' . $j . 'η θεραπεία δεν είναι η μια πριν την άλλη!', '&exams=' . $exams);
            }
        }
    }
    if ($table == "exams_iologikes") {
        $exams = $data_array['exams'];
        for ($i = 0; $i < $exams; $i++) {
            $j = $i + 1;
            if ($data_array['Result' . $i] == "") {
                show_error('iologikes.php', '', 'Πρέπει να δώσετε μια τιμή για το ' . $j . 'ο αποτέλεσμα!', '&exams=' . $exams);
            }
            if ($data_array['Value' . $i] == "") {
                show_error('iologikes.php', '', 'Πρέπει να δώσετε μια τιμή για την ' . $j . 'η τιμή!', '&exams=' . $exams);
            }
            if ($data_array['Method' . $i] == "") {
                show_error('iologikes.php', '', 'Πρέπει να δώσετε μια τιμή για την ' . $j . 'η μέθοδο!', '&exams=' . $exams);
            }
            if ($data_array['Method' . $i] == 9 && $data_array['OtherMethod' . $i] == "") {
                show_error('iologikes.php', '', 'Πρέπει να δώσετε μια τιμή για την ' . $j . 'η άλλη μέθοδο!', '&exams=' . $exams);
            }
        }
    }
    if ($table == "exams_anosologikes") {
        $exams = $data_array['exams'];
        for ($i = 0; $i < $exams; $i++) {
            $j = $i + 1;
            if ($data_array['Leuka' . $i] == "") {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια τιμή για τα ' . $j . 'α λευκά αιμοσφαίρια!', '&exams=' . $exams);
            }
            if ($data_array['Aimosfairini' . $i] == "") {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια τιμή για την ' . $j . 'η αιμοσφαιρίνη!', '&exams=' . $exams);
            }
            if ($data_array['Aimopetalia' . $i] == "") {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια τιμή για τον ' . $j . 'α αιμοπετάλια!', '&exams=' . $exams);
            }
            if ($data_array['AbsoluteCD4' . $i] == "") {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια τιμή για τoν ' . $j . 'ο Απόλυτο αριθμό CD4!', '&exams=' . $exams);
            }
            if ($data_array['PercentCD4' . $i] == "") {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια τιμή για τo ' . $j . 'ο Ποσοστό CD4!', '&exams=' . $exams);
            }
            if ($data_array['AbsoluteCD8' . $i] == "") {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια τιμή για τoν ' . $j . 'ο Απόλυτο αριθμό CD8!', '&exams=' . $exams);
            }
            if ($data_array['PercentCD8' . $i] == "") {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια τιμή για τo ' . $j . 'ο Ποσοστό CD8!', '&exams=' . $exams);
            }
            if ($data_array['Ratio' . $i] == "" || $data_array['Ratio' . $i] < 0 || $data_array['Ratio' . $i] > 100) {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια σωστή τιμή για τoν ' . $j . 'ο Λόγο CD4 (%) / CD8 (%)!', '&exams=' . $exams);
            }
        }
    }
    if ($table == "antiretro_treatments") {
        if (!is_numeric($data_array['MELCode'])) {
            show_error('antiretro.php', '', 'Ο Κωδικός ΜΕΛ πρέπει να είναι αριθμός!');
        }
        if ($data_array['MELCode'] == "") {
            show_error('antiretro.php', '', 'Πρέπει να δωσετε Κωδικό ΜΕΛ!');
        }
        for ($i = 0; $i < $exams; $i++) {
            $j = $i + 1;
            if ($data_array['Leuka' . $i] == "") {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια τιμή για τα ' . $j . 'α λευκά αιμοσφαίρια!', '&exams=' . $exams);
            }
            if ($data_array['Aimosfairini' . $i] == "") {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια τιμή για την ' . $j . 'η αιμοσφαιρίνη!', '&exams=' . $exams);
            }
            if ($data_array['Aimopetalia' . $i] == "") {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια τιμή για τον ' . $j . 'α αιμοπετάλια!', '&exams=' . $exams);
            }
            if ($data_array['AbsoluteCD4' . $i] == "") {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια τιμή για τoν ' . $j . 'ο Απόλυτο αριθμό CD4!', '&exams=' . $exams);
            }
            if ($data_array['PercentCD4' . $i] == "") {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια τιμή για τo ' . $j . 'ο Ποσοστό CD4!', '&exams=' . $exams);
            }
            if ($data_array['AbsoluteCD8' . $i] == "") {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια τιμή για τoν ' . $j . 'ο Απόλυτο αριθμό CD8!', '&exams=' . $exams);
            }
            if ($data_array['PercentCD8' . $i] == "") {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια τιμή για τo ' . $j . 'ο Ποσοστό CD8!', '&exams=' . $exams);
            }
            if ($data_array['Ratio' . $i] == "" || $data_array['Ratio' . $i] < 0 || $data_array['Ratio' . $i] > 100) {
                show_error('anosologikes.php', '', 'Πρέπει να δώσετε μια σωστή τιμή για τoν ' . $j . 'ο Λόγο CD4 (%) / CD8 (%)!', '&exams=' . $exams);
            }
        }
    }
    if ($table == "aids_clinical_status") {
        $nosoi = $data_array['num_nosoi_reappear'];
        $syndrom = $data_array['num_syndrom_reappear'];
        if (!is_numeric($data_array['PatientCode'])) {
            show_error('clinical_status.php', '', 'Ο Κωδικός Ασθενή πρέπει να είναι αριθμός!&nosoi=' . $nosoi . '&syndrom' . $syndrom);
        }
        for ($i = 0; $i < $nosoi; $i++) {
            $j = $i + 1;
            if ($data_array['NososSymptID' . $i] == "") {
                show_error('clinical_status.php', '', 'Πρέπει να δώσετε μια τιμή για τo ' . $j . 'ο νόσημα/σύνδρομο που επανεμφανίζεται!&nosoi=' . $nosoi . '&syndrom' . $syndrom);
            }
            if ($data_array['NososSymptDiagnosis' . $i] == "") {
                show_error('clinical_status.php', '', 'Πρέπει να δώσετε μια διάγνωση για τo ' . $j . 'ο νόσημα/σύνδρομο που επανεμφανίζεται!&nosoi=' . $nosoi . '&syndrom' . $syndrom);
            }
            if (check_month($data_array['NososSymptDate' . $i . '_month']) || check_day($data_array['NososSymptDate' . $i . '_day'])) {
                show_error('clinical_status.php', '', 'Πρέπει να δώσετε μια σωστή ημερομηνία για τo ' . $j . 'ο νόσημα/σύνδρομο που επανεμφανίζεται!&nosoi=' . $nosoi . '&syndrom' . $syndrom);
            }
        }
        for ($i = 0; $i < $syndrom; $i++) {
            $j = $i + 1;
            if ($data_array['ReccurenceSymptom' . $i] == "") {
                show_error('clinical_status.php', '', 'Πρέπει να δώσετε μια τιμή για τo ' . $j . 'ο κλινικό σύμπτωμα που επανεμφανίζεται!&nosoi=' . $nosoi . '&syndrom' . $syndrom);
            }
            if (check_month($data_array['ReccurenceDate' . $i . '_month']) || check_day($data_array['ReccurenceDate' . $i . '_day'])) {
                show_error('clinical_status.php', '', 'Πρέπει να δώσετε μια σωστή ημερομηνία για τo ' . $j . 'ο κλινικό σύμπτωμα που επανεμφανίζεται!&nosoi=' . $nosoi . '&syndrom' . $syndrom);
            }
        }
    }
    if ($table == "other_treatments") {
        if (!is_numeric($data_array['MELCode'])) {
            show_error('alles.php', '', 'Ο Κωδικός ΜΕΛ πρέπει να είναι αριθμός!', '');
        }
        if (!check_dates($data_array, 'InterleukiniDateStart', 'InterleukiniDateEnd')) {
            show_error('alles.php', '', 'Οι ημερομηνίες έναρξης και διακοπής για την Ιντερλευκίνη-2  δεν είναι η μια πριν την άλλη!', '');
        }
        if (!check_dates($data_array, 'AuksitikoiDateStart', 'AuksitikoiDateEnd')) {
            show_error('alles.php', '', 'Οι ημερομηνίες έναρξης και διακοπής για τους Αυξητικοί παράγοντες δεν είναι η μια πριν την άλλη!', '');
        }
        if (!check_dates($data_array, 'InterferoniDateStart', 'InterferoniDateEnd')) {
            show_error('alles.php', '', 'Οι ημερομηνίες έναρξης και διακοπής για την Ιντερφερόνη  δεν είναι η μια πριν την άλλη!', '');
        }
        if (!check_dates($data_array, 'RibaviriniDateStart', 'RibaviriniDateEnd')) {
            show_error('alles.php', '', 'Οι ημερομηνίες έναρξης και διακοπής για την Ριμπαβιρίνη  δεν είναι η μια πριν την άλλη!', '');
        }
        if (!check_dates($data_array, 'YpolipidaimikiDateStart', 'YpolipidaimikiDateEnd')) {
            show_error('alles.php', '', 'Οι ημερομηνίες έναρξης και διακοπής για την Υπολιπιδαιμική αγωγή  δεν είναι η μια πριν την άλλη!', '');
        }
        if (!check_dates($data_array, 'AnabolicsDateStart', 'AnabolicsDateEnd')) {
            show_error('alles.php', '', 'Οι ημερομηνίες έναρξης και διακοπής για τα Αναβολικά δεν είναι η μια πριν την άλλη!', '');
        }
        if (!check_dates($data_array, 'AntifumatikiDateStart', 'AntifumatikiDateEnd')) {
            show_error('alles.php', '', 'Οι ημερομηνίες έναρξης και διακοπής για την Αντιφυματική θεραπεία  δεν είναι η μια πριν την άλλη!', '');
        }
        if (!check_dates($data_array, 'KuttarostatikaDateStart', 'KuttarostatikaDateEnd')) {
            show_error('alles.php', '', 'Οι ημερομηνίες έναρξης και διακοπής για τα Κυτταροστατικά δεν είναι η μια πριν την άλλη!', '');
        }
        if (!check_dates($data_array, 'DiabetesDateStart', 'DiabetesDateEnd')) {
            show_error('alles.php', '', 'Οι ημερομηνίες έναρξης και διακοπής για τη Κυτταροστατικά  δεν είναι η μια πριν την άλλη!', '');
        }
    }
}
Example #8
0
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&nbsp;$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> &emsp;&emsp;&emsp; - &emsp; Listing Data submitted from CR @ {$branch}&nbsp;{$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&nbsp;</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>&emsp;";
                    }
                    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>&nbsp;&nbsp;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();
        }
    }
}
     $msg = $mapping[$matches[1]] . " {$matches['2']} - {$matches['3']}";
 } else {
     if (preg_match('/^(\\w{2,3})-(\\w{2,3})$/', $rule, $matches)) {
         if (!check_day($matches[1]) || !check_day($matches[2])) {
             $err_msg .= "<b>Rule '{$rule}' is invalid</b><br>\n";
             continue;
         }
         if ($sel_rule == $rule || $sel_rule == '') {
             $checked[double] = 'checked';
             $selected_start[$matches[1]] = 'selected';
             $selected_stop[$matches[2]] = 'selected';
         }
         $msg = $mapping[$matches[1]] . " - " . $mapping[$matches[2]];
     } else {
         if (preg_match('/^(\\w{2,3})-(\\w{2,3})(\\d{4})-(\\d{4})$/', $rule, $matches)) {
             if (!check_day($matches[1]) || !check_day($matches[2])) {
                 $err_msg .= "<b>Rule '{$rule}' is invalid</b><br>\n";
                 continue;
             }
             if ($sel_rule == $rule || $sel_rule == '') {
                 $checked[double] = 'checked';
                 $selected_start[$matches[1]] = 'selected';
                 $selected_stop[$matches[2]] = 'selected';
                 $Dstart_time = $matches[3];
                 $Dstop_time = $matches[4];
             }
             $msg = $mapping[$matches[1]] . " - " . $mapping[$matches[2]] . " {$matches['3']} - {$matches['4']}";
         } else {
             $err_msg .= "<b>Rule {$rule} is invalid</b><br>\n";
             continue;
         }