<?php
session_start();
if (!isset($_SESSION["username"])) {
    header("Location: unauthorize_access.php");
}
$user = $_SESSION["username"];
require("includes/dbconnect.php");
mysql_query("drop view cdist"); 
mysql_query("drop view cdist1");


mysql_query("create view cdist as SELECT accode, code, `name`, `state`, `country` FROM district ORDER BY `name`")or die(mysql_error());
mysql_query("create view cdist1 as SELECT a.*, b.`name` AS `statename` FROM cdist a, state b WHERE a.state = b.code ORDER BY `name`")or die(mysql_error());
$result = mysql_query("SELECT a.*, b.`name` AS `counname` FROM cdist1 a, country b WHERE a.country = b.code ORDER BY `name`")or die(mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Deeniyat</title>
    <link rel="stylesheet" type="text/css" href="css/reset.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/text.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/grid.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/layout.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/nav.css" media="screen" />
    <!--[if IE 6]><link rel="stylesheet" type="text/css" href="css/ie6.css" media="screen" /><![endif]-->
    <!--[if IE 7]><link rel="stylesheet" type="text/css" href="css/ie.css" media="screen" /><![endif]-->
    <link href="css/table/demo_page.css" rel="stylesheet" type="text/css" />
    <!-- BEGIN: load jquery -->
    <script src="js/jquery-1.6.4.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/jquery-ui/jquery.ui.core.min.js"></script>
    <script src="js/jquery-ui/jquery.ui.widget.min.js" type="text/javascript"></script>
    <script src="js/jquery-ui/jquery.ui.accordion.min.js" type="text/javascript"></script>
    <script src="js/jquery-ui/jquery.effects.core.min.js" type="text/javascript"></script>
    <script src="js/jquery-ui/jquery.effects.slide.min.js" type="text/javascript"></script>
    <script src="js/jquery-ui/jquery.ui.mouse.min.js" type="text/javascript"></script>
    <script src="js/jquery-ui/jquery.ui.sortable.min.js" type="text/javascript"></script>
    <script src="js/table/jquery.dataTables.min.js" type="text/javascript"></script>
    <!-- END: load jquery -->
    <script type="text/javascript" src="js/table/table.js"></script>
    <script src="js/setup.js" type="text/javascript"></script>
    <script type="text/javascript">
	$(function() {
	
	    var menu_ul = $('.menu > li > ul'),
	           menu_a  = $('.menu > li > a');
	    
	    menu_ul.hide();
	
	    menu_a.click(function(e) {
	        e.preventDefault();
	        if(!$(this).hasClass('active')) {
	            menu_a.removeClass('active');
	            menu_ul.filter(':visible').slideUp('normal');
	            $(this).addClass('active').next().stop(true,true).slideDown('normal');
	        } else {
	            $(this).removeClass('active');
	            $(this).next().stop(true,true).slideUp('normal');
	        }
	    });
	
	});
</script>
    
    <!--For popup window-->
    <script >
function PopupWindowCenter(URL, title,w,h)
{var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var newWin = window.open (URL, title, 'toolbar=no, location=no,directories=no, status=no, menubar=no, scrollbars=no, resizable=no,copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
</script>
    <!End poopup Window-->
    <style>
        .print{
            background-image:url(images/print.png);
            background-repeat: no-repeat;
            width:4px;
            
        }
    </style>
    
    
    <!-- for table-->
        <script src="tables/media/js/jquery.js" type="text/javascript"></script>
        <script src="tables/media/js/jquery.dataTables.js" type="text/javascript"></script>
        
        <style type="text/css">
            @import "tables/media/css/demo_table_jui.css";
            @import "tables/media/themes/smoothness/jquery-ui-1.8.4.custom.css";
        </style>
        
        <style>
            *{
                font-family: arial;
            }
        </style>
        <script type="text/javascript" charset="utf-8">
            $(document).ready(function(){
                $('#datatables').dataTable({
                    "sPaginationType":"full_numbers",
                    "aaSorting":[[2, "desc"]],
                    "bJQueryUI":true
                });
            })
            
        </script>
    <!-- End table-->
        <head><script type="text/javascript">
        function Deleteqry(id)
        {
            if(confirm("Are you sure you want to delete this row?")==true)
                window.location="delete.php?delcust="+id;
            return false; 
        } 
        function Editqry(id)
        {
            window.Location="cityproc.php?edit="+id;
            return false;
        }
        </script>
 

</head>
<body>
    <div class="container_12">
        <div class="grid_12 header-repeat">
            <div id="branding">
                <div class="floatleft">
                    
                  <img src="img/deen3.png" alt="Logo"/></div>
                <div class="floatright">
                    <div class="floatleft">
                        <img src="img/img-profile.jpg" alt="Profile Pic" /></div>
                    <div class="floatleft marginleft10">
                           <ul class="inline-ul floatleft">
                            <li><?php
                            
                           $userqry= mysql_query("SELECT `username` FROM usermain")or die(mysql_error());
                           echo 'Assalamualikum, ' . $_SESSION['username'];
                           echo "</li>";
                           
                            echo "<li><a href=\"javascript:void(0);\" onClick =\"PopupWindowCenter('changepass.php?username=$user', 'PopupWindowCenter',600,700)\">Config</a></li>";
                   ?>                 
                            <li><a href="logout.php">Logout</a></li>
                        </ul>
                        <br />
                        
                    </div>
                </div>
                <div class="clear">
                </div>
            </div>
        </div>
        <div class="clear">
        </div>
        <div class="grid_12">
              <ul class="nav main">
                <li class="ic-dashboard"><a href="#"><span>Graphical Analysis</span></a> </li>
                <li class="ic-form-style"><a href="nigran.php"><span>Nigran Entry</span></a></li>
		<li class="ic-form-style"><a href="makh_tab.php"><span>Makhtab Entry</span></a></li>
                <li class="ic-grid-tables"><a href="#"><span>Best 10</span></a></li>
                <li class="ic-gallery dd"><a href="javascript:"><span>Create User</span></a>
               		 <ul>
                             
                              <li><a href="javascript:void(0);" onClick ="PopupWindowCenter('admin.php', 'PopupWindowCenter',600,700)"><span>Create Admin User</span></a></li>    
                              <li><a href="usergrid.php"><span>Create Normal User</span></a></li>
                              <li><a href="javascript:void(0);" onClick ="PopupWindowCenter('niguser.php', 'PopupWindowCenter',600,700)"><span>Create Nigran User</span></a></li>
                         </ul>
                </li>
               <li class="ic-notifications"><a href="#"><span>Upcoming Events</span></a></li>
                 <li class="ic-form-style"><a href="javascript:void(0);" onClick ="PopupWindowCenter('company.php', 'PopupWindowCenter',600,700)">Company Setup</a></li>
            </ul>
        </div>
        <div class="clear">
        </div>
        <div class="grid_2">
            <div class="box sidemenu">
                <div class="block" id="section-menu">
                    <ul class="section menu">
                        <li><a class="menuitem">Masters</a>
                            <ul class="submenu">
                                <li><a href="counttab.php">Country</a></li>
                                <li><a href="statetab.php">State</a></li>
                                <li><a href="disttab.php">District</a></li>
                                <li><a href="tehtab.php">Tehsil</a></li>
                                <li><a href="cittab.php">City</a></li>
                                <li><a href="centtab.php">Centre</a></li>
                                <li><a href="makh_tab.php">Makhtab</a></li>
                                <li><a href="subtab.php">Subject</a></li>
                                <li><a href="cattab.php">Category</a></li>   
                                
                                
                                
                               
                            </ul>
                        </li>
                        <li><a class="menuitem">Entries</a>
                            <ul class="submenu">
                                <li><a href="nigran.php" >Nigran Statistics</a> </li>
                               <!-- <li><a>Center Head</a> </li>
                                <li><a>State Head</a> </li>
                                <li><a>Country Head</a> </li>
                                <li><a>Main</a> </li>-->
                            </ul>
                        </li>
                        <li><a class="menuitem">Reports</a>
                            <ul class="submenu">
                                <li><a href="repcat.php" >Categorywise Total</a> </li>
                                <li><a href="nos.php" >No. of States</a> </li>
                                <li><a href="nod.php" >No. of Districts</a> </li>
                                <li><a href="not.php" >No. of Tehsil</a> </li>
                                <li><a href="nocity.php" >No. of Cities</a> </li>
                                <li><a href="noc.php" >No. of Centres</a> </li>
                                <li><a href="ras.php" >Subjectwise</a> </li>
                            </ul>
                        </li>
                        <li><a class="menuitem">Mis</a>
                            <ul class="submenu">
                                <li><a href="mdw.php" >Makhtab doing well</a> </li>
                                <li><a href="mndw.php" >Makhtab not doing well</a> </li>
                                <li><a href="nds.php" >Not Doing Well Subjectwise</a> </li>
                                <!--<li><a href="noc.php" target="open link in a new tab">Best 100 who are doing well</a> </li>
                                <li><a href="noc.php" target="open link in a new tab">Graphical analysis of Cities + State</a> </li>-->

                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="grid_10">
            <div class="box round first grid">
              <!--  <h2>City Data</h2><h2><a href="city_lst.php?printchal" target="_blank">View</a><input type="button" name Export to pdf></input></h2>-->
                <h2>District</h2>
              <div class="">
                    <div id="container">

    <div id="dataTable">

        <div class="ui-grid ui-widget ui-widget-content ui-corner-all">

            <div class="ui-grid-header ui-widget-header ui-corner-top clearfix">

                <div class="header-left">
                    <!-- Left side of table header -->
                </div>

                <div class="header-left">
                    <div align="left">
                      &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onClick ="PopupWindowCenter('distlst.php', 'PopupWindowCenter',600,700)"><font color="blue">Print</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="district.php"><font color="green">+ Add New Record</font></a>
                    </div>
                      <input style="width:150px;" id="searchData" type="hidden"></div>
                </div>

            <table id="datatables" class="display">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Code</th>
                        <th>State</th>
                        <th>Country</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    while ($row = mysql_fetch_array($result)) {
                    echo "<tr>";
                    echo "<td>$row[name]</td>";
                    echo "<td>$row[code]</td>";
                    echo "<td>$row[statename]</td>";
                    echo "<td>$row[counname]</td>";
                    echo "<td><a href=\"distproc.php?accode=$row[accode]\"><img src='images/edit.png'></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"delete_dt.php?accode=$row[code]\" onClick=\"return confirm('Do you want to delete?');\"><img src='images/delete.png'></a></td>";
                    echo "</tr>";
                      
                    }
                    ?>
                </tbody>
            </table>
            
        </div>
    </div>

</div>
                     
                    <!--<div id="PeopleTableContainer" style="width: 1000px;"></div>
	<script type="text/javascript">

		$(document).ready(function () {

		    //Prepare jTable
			$('#PeopleTableContainer').jtable({
				title: 'City Records',
				actions: {
					listAction: 'jtable/PersonActions.php?action=list',
					createAction: 'jtable/PersonActions.php?action=create',
					updateAction: 'jtable/PersonActions.php?action=update',
					deleteAction: 'jtable/PersonActions.php?action=delete'
				},
				fields: {
					accode: {
						key: true,
						create: false,
						edit: false,
						list: false
					},
					name: {
						title: 'City',
						width: '20%'
					},
					code: {
						title: 'Code',
						width: '20%'
					},

				}
			});

			//Load inerperson list from server
			$('#PeopleTableContainer').jtable('load');

		});

	</script>
                
                </div>-->
            </div>
        </div>
        <div class="clear">
        </div>
    </div>
    <div class="clear">
    </div>
        <div id="site_info">
        <p>
            <center><a href="http://www.cepheisys.com" target="open link in a new tab"><img src="img/browsers.png"></img></a></img></center>
        </p>
    </div>
</body>
</html>
