<?php include("includes/head.php");?>

<!-- form CSS
		============================================ -->
    <link rel="stylesheet" href="css/form.css">
    
<!--<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css" rel="stylesheet" id="">-->
<link href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap4.min.css" rel="stylesheet" id="">
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.21/js/dataTables.bootstrap4.min.js"></script>
<style>
#cboxOverlay {
	visibility: visible;
	opacity: 0.3 !important;
}
.dataTables_length {
	text-align:left;
}
</style>
<style>
.circle-tile {
	margin-bottom: 15px;
	text-align: center;
}
.circle-tile-heading {
	border: 3px solid rgba(255, 255, 255, 0.3);
	border-radius: 100%;
	color: #FFFFFF;
	height: 80px;
	margin: 0 auto -40px;
	position: relative;
	transition: all 0.3s ease-in-out 0s;
	width: 110px;
	text-align:center;
}
.circle-tile-heading .fa {
	line-height: 80px;
}
.circle-tile-content {
	padding-top: 50px;
}
.circle-tile-number {
	font-size: 26px;
	font-weight: 700;
	line-height: 1;
	padding: 5px 0 15px;
}
.circle-tile-description {
	text-transform: uppercase;
}
.circle-tile-footer {
	background-color: rgba(0, 0, 0, 0.1);
	color: rgba(255, 255, 255, 0.5);
	display: block;
	padding: 5px;
	transition: all 0.3s ease-in-out 0s;
}
.circle-tile-footer:hover {
	background-color: rgba(0, 0, 0, 0.2);
	color: rgba(255, 255, 255, 0.5);
	text-decoration: none;
}
.circle-tile-heading.dark-blue:hover {
	background-color: #2E4154;
}
.circle-tile-heading.green:hover {
	background-color: #138F77;
}
.circle-tile-heading.orange:hover {
	background-color: #DA8C10;
}
.circle-tile-heading.blue:hover {
	background-color: #2473A6;
}
.circle-tile-heading.red:hover {
	background-color: #CF4435;
}
.circle-tile-heading.purple:hover {
	background-color: #7F3D9B;
}
.tile-img {
	text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.9);
}
.dark-blue {
	background-color: #34495E;
}
.green {
	background-color: #16A085;
}
.blue {
	background-color: #2980B9;
}
.orange {
	background-color: #F39C12;
}
.red {
	background-color: #E74C3C;
}
.purple {
	background-color: #8E44AD;
}
.dark-gray {
	background-color: #7F8C8D;
}
.gray {
	background-color: #95A5A6;
}
.light-gray {
	background-color: #BDC3C7;
}
.yellow {
	background-color: #F1C40F;
}
.text-dark-blue {
	color: #34495E;
}
.text-green {
	color: #16A085;
}
.text-blue {
	color: #2980B9;
}
.text-orange {
	color: #F39C12;
}
.text-red {
	color: #E74C3C;
}
.text-purple {
	color: #8E44AD;
}
.text-faded {
	color: rgba(255, 255, 255, 0.7);
}
</style>
<style>
.dbox {
	position: relative;
	background: rgb(255, 86, 65);
	background: -moz-linear-gradient(top, rgba(255, 86, 65, 1) 0%, rgba(253, 50, 97, 1) 100%);
	background: -webkit-linear-gradient(top, rgba(255, 86, 65, 1) 0%, rgba(253, 50, 97, 1) 100%);
	background: linear-gradient(to bottom, rgba(255, 86, 65, 1) 0%, rgba(253, 50, 97, 1) 100%);
 filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#ff5641', endColorstr='#fd3261', GradientType=0);
	border-radius: 4px;
	text-align: center;
	margin: 60px 0 50px;
}
.dbox__icon {
	position: absolute;
	transform: translateY(-50%) translateX(-50%);
	left: 50%;
}
.dbox__icon:before {
	width: 75px;
	height: 75px;
	position: absolute;
	background: #fda299;
	background: rgba(253, 162, 153, 0.34);
	content: '';
	border-radius: 50%;
	left: -17px;
	top: -17px;
	z-index: -2;
}
.dbox__icon:after {
	width: 60px;
	height: 60px;
	position: absolute;
	background: #f79489;
	background: rgba(247, 148, 137, 0.91);
	content: '';
	border-radius: 50%;
	left: -10px;
	top: -10px;
	z-index: -1;
}
.dbox__icon > i {
	background: #ff5444;
	border-radius: 50%;
	line-height: 40px;
	color: #FFF;
	width: 40px;
	height: 40px;
	font-size:22px;
}
.dbox__body {
	padding: 50px 20px;
}
.dbox__count {
	display: block;
	font-size: 30px;
	color: #FFF;
	font-weight: 300;
}
.dbox__title {
	font-size: 13px;
	color: #FFF;
	color: rgba(255, 255, 255, 0.81);
}
.dbox__action {
	transform: translateY(-50%) translateX(-50%);
	position: absolute;
	left: 50%;
}
.dbox__action__btn {
	border: none;
	background: #FFF;
	border-radius: 19px;
	padding: 7px 16px;
	text-transform: uppercase;
	font-weight: 500;
	font-size: 11px;
	letter-spacing: .5px;
	color: #003e85;
	box-shadow: 0 3px 5px #d4d4d4;
}
.dbox--color-2 {
	background: rgb(252, 190, 27);
	background: -moz-linear-gradient(top, rgba(252, 190, 27, 1) 1%, rgba(248, 86, 72, 1) 99%);
	background: -webkit-linear-gradient(top, rgba(252, 190, 27, 1) 1%, rgba(248, 86, 72, 1) 99%);
	background: linear-gradient(to bottom, rgba(252, 190, 27, 1) 1%, rgba(248, 86, 72, 1) 99%);
 filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#fcbe1b', endColorstr='#f85648', GradientType=0);
}
.dbox--color-2 .dbox__icon:after {
	background: #fee036;
	background: rgba(254, 224, 54, 0.81);
}
.dbox--color-2 .dbox__icon:before {
	background: #fee036;
	background: rgba(254, 224, 54, 0.64);
}
.dbox--color-2 .dbox__icon > i {
	background: #fb9f28;
}
.dbox--color-3 {
	background: rgb(183,71,247);
	background: -moz-linear-gradient(top, rgba(183, 71, 247, 1) 0%, rgba(108, 83, 220, 1) 100%);
	background: -webkit-linear-gradient(top, rgba(183, 71, 247, 1) 0%, rgba(108, 83, 220, 1) 100%);
	background: linear-gradient(to bottom, rgba(183, 71, 247, 1) 0%, rgba(108, 83, 220, 1) 100%);
 filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b747f7', endColorstr='#6c53dc', GradientType=0 );
}
.dbox--color-3 .dbox__icon:after {
	background: #b446f5;
	background: rgba(180, 70, 245, 0.76);
}
.dbox--color-3 .dbox__icon:before {
	background: #e284ff;
	background: rgba(226, 132, 255, 0.66);
}
.dbox--color-3 .dbox__icon > i {
	background: #8150e4;
}
</style>
<style>
hr.style18 {
	height: 30px;
	border-style: solid;
	border-color: #8c8b8b;
	border-width: 1px 0 0 0;
	border-radius: 20px;
}
hr.style18:before {
	display: block;
	content: "";
	height: 30px;
	margin-top: -31px;
	border-style: solid;
	border-color: #8c8b8b;
	border-width: 0 0 1px 0;
	border-radius: 20px;
}
</style>
<body>
<!--[if lt IE 8]>
        <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
<!-- Header top area start-->
<?php include("includes/header.php");?>
<!-- Header top area end-->
<!-- Menu area start-->
<?php include("includes/navigation.php");?>
<!-- Menu area end-->
<?php 
  //--------------- Organisation Info ----------------							  								  
  $selQry_orgs_conf = "SELECT * FROM ".TBL_ORGANIZATIONS." WHERE organization_id ='1' LIMIT 1";
  $orgsInfo_conf =  $con->getSingleRow($selQry_orgs_conf, __FILE__,__LINE__);
  $totOrgsListings_conf = count($orgsInfo_conf);
  //--------------- Users Info ----------------							  								  
  $selQry_users = "SELECT * FROM ".TBL_USERS." WHERE group_id !='1' ORDER BY first_name";
  $usersInfo =  $con->getMultiRow($selQry_users, __FILE__,__LINE__);
  $totUsersListings = count($usersInfo);
  //--------------- Departments Info ----------
  $selQry_depts = "SELECT * FROM ".TBL_DEPARTMENTS." ORDER BY name";
  $deptsInfo =  $con->getMultiRow($selQry_depts, __FILE__,__LINE__);
  $totDeptsListings = count($deptsInfo);
  //--------------- Files Info ----------------
  $selQry_files = "SELECT * FROM ".TBL_FILES." ORDER BY name";
  $filesInfo =  $con->getMultiRow($selQry_files, __FILE__,__LINE__);
  $totFilesListings = count($filesInfo);
  //--------------- Stakeholders Info ---------
  $selQry_sh = "SELECT * FROM ".TBL_STAKEHOLDERS." ORDER BY name";
  $shInfo =  $con->getMultiRow($selQry_sh, __FILE__,__LINE__);
  $totSHListings = count($shInfo);
  //-------------------------------------------
?>
<!-- Data table area Start-->
<div class="admin-dashone-data-table-area mg-b-40" style="min-height:500px;">
  <div class="container">
    <div class="row">
      <div class="col-lg-12">
        <div class="row">
          <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" style="width:106% !important;margin-top:10px;">
            <div class="tab-content view-mail-ov-mg-t-30">
              <div class="tab-pane fade in zoomInDown shadow-reset active">
                <div class="sparkline8-list shadow-reset">
                  <div class="sparkline8-hd">
                    <div class="main-sparkline8-hd">
                      <h1>Setup</h1>
                      <div class="sparkline8-outline-icon" id="btnDashboard">
                        <a href="dashboard.php">
                        <button class="btn btn-sm btn-danger login-submit-cs" type="button">Dashboard</button>
                        </a>&nbsp;
                      </div>
                    </div>
                  </div>
                  <div class="sparkline8-graph">
                    <div class="container bootstrap snippet">
                    
                      <div class="login-form-area mg-t-30 mg-b-40">
                        <div class="container">
                          <div class="row">
                            <h1 style="text-align:left;color:#000000; font-size:20px;"><strong>Organization Info</strong></h1>
                            <div class="col-lg-2"></div>
                            <form id="frmOrganizationInfo" class="adminpro-form">
                              <input type="hidden" name="action" value="update">
                              <input type="hidden" name="orgid" value="<?php echo isset($orgsInfo_conf['organization_id'])?$orgsInfo_conf['organization_id']:'';?>">
                              <div class="col-lg-8" style="text-align:left;">
                                <div class="login-bg">
                                  <div class="row">
                                    <div class="col-lg-4">
                                      <div class="login-input-head">
                                        <p>Logo:</p>
                                      </div>
                                    </div>
                                    <div class="col-lg-8">
                                      <div class="login-input-area">
                                        <input class="au-input au-input--full" type="file" name="logo" id="logo" placeholder="Logo" <?php if(!empty($orgsInfo_conf['logo'])){?><?php }else{?>required<?php }?> onChange="PreviewImage();">
                                        <br>
                                        <img id="uploadPreview" style="width: 100px; height: 100px;" src="uploads/organizations/<?php echo isset($orgsInfo_conf['logo'])?$orgsInfo_conf['logo']:'';?>" />
                                        <input type="hidden" name="old_logo" id="old_logo" value="<?php echo isset($orgsInfo_conf['logo'])?$orgsInfo_conf['logo']:'';?>">
                                      </div>
                                    </div>
                                  </div>
                                  <div class="row">
                                    <div class="col-lg-4">
                                      <div class="login-input-head">
                                        <p>Organization Name:</p>
                                      </div>
                                    </div>
                                    <div class="col-lg-8">
                                      <div class="login-input-area">
                                        <input class="au-input au-input--full" type="text" name="name" id="name" value="<?php echo isset($orgsInfo_conf['name'])?$orgsInfo_conf['name']:'';?>" required placeholder="Organization Name">
                                        <i class="fa fa-home login-user" aria-hidden="true"></i> </div>
                                    </div>
                                  </div>
                                  <div class="row">
                                    <div class="col-lg-4">
                                      <div class="login-input-head">
                                        <p>Address:</p>
                                      </div>
                                    </div>
                                    <div class="col-lg-8">
                                      <div class="login-input-area">
                                        <input class="au-input au-input--full" type="text" name="address" id="address" value="<?php echo isset($orgsInfo_conf['address'])?$orgsInfo_conf['address']:'';?>" placeholder="Address" required>
                                        <i class="fa fa-map-marker login-user" aria-hidden="true"></i> </div>
                                    </div>
                                  </div>
                                  <div class="row">
                                    <div class="col-lg-4">
                                      <div class="login-input-head">
                                        <p>Contact#:</p>
                                      </div>
                                    </div>
                                    <div class="col-lg-8">
                                      <div class="login-input-area">
                                        <input class="au-input au-input--full" type="text" name="contact_no" id="contact_no" value="<?php echo isset($orgsInfo_conf['contact_no'])?$orgsInfo_conf['contact_no']:'';?>" placeholder="Contact#" required>
                                        <i class="fa fa-phone login-user" aria-hidden="true"></i> </div>
                                    </div>
                                  </div>
                                  <div class="row">
                                    <div class="col-lg-4">
                                      <div class="login-input-head">
                                        <p>Contact Person:</p>
                                      </div>
                                    </div>
                                    <div class="col-lg-8">
                                      <div class="login-input-area">
                                        <input class="au-input au-input--full" type="text" name="contact_person" id="contact_person" value="<?php echo isset($orgsInfo_conf['contact_person'])?$orgsInfo_conf['contact_person']:'';?>" placeholder="Contact Person" required>
                                        <i class="fa fa-user login-user" aria-hidden="true"></i> </div>
                                    </div>
                                  </div>
                                  <div class="row">
                                    <div class="col-lg-4">
                                      <div class="login-input-head">
                                        <p>Email:</p>
                                      </div>
                                    </div>
                                    <div class="col-lg-8">
                                      <div class="login-input-area">
                                        <input class="au-input au-input--full" type="text" name="email" id="email" value="<?php echo isset($orgsInfo_conf['email'])?$orgsInfo_conf['email']:'';?>" placeholder="Email" required>
                                        <i class="fa fa-envelope login-user" aria-hidden="true"></i> </div>
                                    </div>
                                  </div>
                                  <div class="row">
                                    <div class="col-lg-12" style="text-align:center;">
                                      <div class="login-button-pro">
                                        <button data-loading-text="Saving..." type="submit" class="btn btn-success"> <i class="fa fa-floppy-o"></i> Update</button>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </form>
                            <div class="col-lg-2"></div>
                          </div>
                        </div>
                      </div>
                      <?php
					  if( $_SESSION['userGroupID']==1 or in_array(1,$userAccessModules)){?>
                      <hr class="style18">
                      <div class="row">
                        <div class="col-md-12">
                          <h6 class="font-weight-bold" style="text-align:left;color:#000000; font-size:20px;"><strong>Groups</strong></h6>
                          <div style="text-align:right;" data-placement="top" data-toggle="tooltip" title="Add Group">
                             <i class="fa fa-users"><i class="fa fa-plus openPopup" data-target="add-group.php" style=" cursor:pointer;" data-title="Add Group" title="CLick to Add Group"></i></i>
                          </div>
                          <div class="table-responsive" id="groupsList">
                            <table id="tblGroupsListings" class="table table-striped table-bordered" style="width:100%">
                              <thead>
                                <tr>
                                  <th>Sr#</th>
                                  <th>Name</th>
                                  <th>Description</th>
                                  <th>Status</th>
                                  <th>Modules Access</th>
                                  <th>Edit</th>
                                  <th>Delete</th>
                                </tr>
                              </thead>
                              <tbody>
                                <?php 
								  //--------------- Category Info ----------
								  $srno = 0;
								  								  
								  $selQry_groups = "SELECT * FROM ".TBL_USERS_GROUPS." WHERE id !='1' ORDER BY group_name";
								  $groupsInfo =  $con->getMultiRow($selQry_groups, __FILE__,__LINE__);
								  $totGroupsListings = count($groupsInfo);
									if($totGroupsListings>0)
									{
										for($grp=0;$grp<$totGroupsListings;$grp++)
										{
											$srno++;
								  //----------------------------------------
								?>
                                <tr>
                                  <td><?php echo $srno;?>.</td>
                                  <td style="text-align:left;"><?php echo $groupsInfo[$grp]['group_name'];?></td>
                                  <td style="text-align:left;"><?php echo $groupsInfo[$grp]['group_description'];?></td>
                                  <td style="text-align:left;"><?php if($groupsInfo[$grp]['status']=='1'){?>
                                    <button type="button" class="btn btn-sm btn-success">Active</button>
                                    <?php }else if($groupsInfo[$grp]['status']=='0'){?>
                                    <button type="button" class="btn btn-sm btn-danger">InActive</button>
                                    <?php }?>
                                  </td>
                                  <td>
                                  <p data-placement="top" data-toggle="tooltip" title="">
                                      <button class="btn btn-info btn-xs openPopup" data-title="Groups Modules Access" data-toggle="modal" data-target="groups-modules-access.php?gid=<?php echo $groupsInfo[$grp]['id'];?>" ><span class="glyphicon glyphicon-user"></span> Modules Access</button>
                                  </td>
                                  <td><p data-placement="top" data-toggle="tooltip" title="">
                                      <button class="btn btn-primary btn-xs openPopup" data-title="Edit Group" data-target="edit-group.php?gid=<?php echo $groupsInfo[$grp]['id'];?>"><span class="glyphicon glyphicon-pencil"></span> Edit</button>
                                    </p></td>
                                  <td><p data-placement="top" data-toggle="tooltip" title="">
                                      <button class="btn btn-danger btn-xs openPopup" data-title="Delete Group" data-toggle="modal" data-target="del-group.php?gid=<?php echo $groupsInfo[$grp]['id'];?>" ><span class="glyphicon glyphicon-trash"></span> Delete</button>
                                  </td>
                                </tr>
                                <?php }
								}?>
                              </tbody>
                            </table>
                          </div>
                        </div>
                      </div>
                      <?php }if($_SESSION['userGroupID']==1 or in_array(2,$userAccessModules)){?>
                      <hr class="style18">
                      <div class="row">
                        <div class="col-md-12">
                          <h6 class="font-weight-bold" style="text-align:left;color:#000000; font-size:20px;"><strong>Users</strong></h6>
                          <div style="text-align:right;" data-placement="top" data-toggle="tooltip" title="Add User">  
                          <i class="fa fa-user"><i class="fa fa-plus openPopup" data-target="add-user.php" style=" cursor:pointer;" data-title="Add User" title="CLick to Add User"></i></i> 
                          </div>
                          <div class="table-responsive" id="usersList">
                            <table id="tblUsersListings" class="table table-striped table-bordered" style="width:100%">
                              <thead>
                                <tr>
                                  <th>Sr#</th>
                                  <th>Photo</th>
                                  <th>Name</th>
                                  <th>Email</th>
                                  <th>Login ID</th>
                                  <th>Group</th>
                                  <th>Departments Access</th>
                                  <th>Status</th>
                                  <th>Edit</th>
                                  <th>Delete</th>
                                </tr>
                              </thead>
                              <tbody>
                                <?php 
								  //--------------- Category Info ----------
								  $srno = 0;
								  								  
								  $selQry_users = "SELECT * FROM ".TBL_USERS." WHERE group_id !='1' ORDER BY first_name";
								  $usersInfo =  $con->getMultiRow($selQry_users, __FILE__,__LINE__);
								  $totUsersListings = count($usersInfo);
									if($totUsersListings>0)
									{
										for($usr=0;$usr<$totUsersListings;$usr++)
										{
											$srno++;
											//----------------------------------------
											$selQry_user_group = "SELECT * FROM ".TBL_USERS_GROUPS." WHERE id ='".$usersInfo[$usr]['group_id']."' ";
											$usersGroupsInfo =  $con->getSingleRow($selQry_user_group, __FILE__,__LINE__);
											$userGroup = isset($usersGroupsInfo['group_name'])?$usersGroupsInfo['group_name']:'';
											//----------------------------------------
								?>
                                <tr>
                                  <td><?php echo $srno;?>.</td>
                                  <td style="text-align:left;"><img src="uploads/users/<?php echo $usersInfo[$usr]['user_pic'];?>" width="50" height="50"></td>
                                  <td style="text-align:left;"><?php echo $usersInfo[$usr]['first_name'].' '.$usersInfo[$usr]['last_name'];?></td>
                                  <td style="text-align:left;"><?php echo $usersInfo[$usr]['user_email'];?></td>
                                  <td style="text-align:left;"><?php echo $usersInfo[$usr]['user_name'];?></td>
                                  <td style="text-align:left;"><button class="btn btn-info btn-xs openPopup" title="Click to View Group Rights" data-title="Group Rights" data-target="groups-modules-access-view.php?gid=<?php echo $usersInfo[$usr]['group_id'];?>"><span class="glyphicon glyphicon-eye"></span> <?php echo $userGroup;?></button></td>
                                  <td>
                                  <p data-placement="top" data-toggle="tooltip" title="">
                                      <button class="btn btn-info btn-xs openPopup" data-title="Groups Modules Access" data-toggle="modal" data-target="users-departments-access.php?uid=<?php echo $usersInfo[$usr]['user_id'];?>" ><span class="glyphicon glyphicon-user"></span> Departments Access</button>
                                  </td>
                                  <td style="text-align:left;"><?php if($usersInfo[$usr]['status']=='1'){?>
                                    <button type="button" class="btn btn-sm btn-success">Active</button>
                                    <?php }else if($usersInfo[$usr]['status']=='0'){?>
                                    <button type="button" class="btn btn-sm btn-danger">InActive</button>
                                    <?php }?>
                                  </td>
                                  <!--<td>
                                  <p data-placement="top" data-toggle="tooltip" title="">
                                      <button class="btn btn-info btn-xs openPopup" data-title="User Modules Access" data-toggle="modal" data-target="user-modules-access.php?uid=<?php echo $usersInfo[$usr]['user_id'];?>" ><span class="glyphicon glyphicon-user"></span> Modules Access</button>
                                  </td>-->
                                  <td><p data-placement="top" data-toggle="tooltip" title="">
                                      <button class="btn btn-primary btn-xs openPopup" data-title="Edit User" data-target="edit-user.php?uid=<?php echo $usersInfo[$usr]['user_id'];?>"><span class="glyphicon glyphicon-pencil"></span> Edit</button>
                                    </p></td>
                                  <td><p data-placement="top" data-toggle="tooltip" title="">
                                      <button class="btn btn-danger btn-xs openPopup" data-title="Delete User" data-toggle="modal" data-target="del-user.php?uid=<?php echo $usersInfo[$usr]['user_id'];?>" ><span class="glyphicon glyphicon-trash"></span> Delete</button>
                                  </td>
                                </tr>
                                <?php }
								}?>
                              </tbody>
                            </table>
                          </div>
                        </div>
                      </div>
                      <?php }if($_SESSION['userGroupID']==1 or in_array(3,$userAccessModules)){?>
                      <hr class="style18">
                      <div class="row">
                        <div class="col-md-12">
                          <h6 class="font-weight-bold" style="text-align:left;color:#000000; font-size:20px;"><strong>Departments</strong></h6>
                          <div style="text-align:right;" data-placement="top" data-toggle="tooltip" title="Add Department"> 
                           
                          <i class="fa fa-building-o"><i class="fa fa-plus openPopup" data-target="add-department.php" style=" cursor:pointer;" data-title="Add Department" title="CLick to Add Department"></i></i>
                          </div>
                          <div class="table-responsive" id="deptList">
                            <table id="tblDepartmentsListings" class="table table-striped table-bordered" style="width:100%">
                              <thead>
                                <tr>
                                  <th>Sr#</th>
                                  <th>Name</th>
                                  <th>Description</th>
                                  <th>Status</th>
                                  <?php if($_SESSION['userGroupID']==1 or $_SESSION['userGroupID']==2){?>
                                  <th>Edit</th>
                                  <th>Delete</th>
                                  <?php }?>
                                </tr>
                              </thead>
                              <tbody>
                                <?php 
								  $srno = 0;
								  if($_SESSION['userGroupID']==1 or $_SESSION['userGroupID']==2){								  
								    $selQry_depts = "SELECT * FROM ".TBL_DEPARTMENTS." ORDER BY name";
								  }else{
								      $selQry_depts = "SELECT * FROM ".TBL_DEPARTMENTS." where status='1' and id IN(".$userDeptAccess.") ORDER BY name";
								  }
								  $deptsInfo =  $con->getMultiRow($selQry_depts, __FILE__,__LINE__);
								  $totDeptsListings = count($deptsInfo);
									if($totDeptsListings>0)
									{
										for($dept=0;$dept<$totDeptsListings;$dept++)
										{
											$srno++;
								  //----------------------------------------
								?>
                                <tr>
                                  <td><?php echo $srno;?>.</td>
                                  <td style="text-align:left;"><?php echo $deptsInfo[$dept]['name'];?></td>
                                  <td style="text-align:left;"><?php echo $deptsInfo[$dept]['description'];?></td>
                                  <td style="text-align:left;"><?php if($deptsInfo[$dept]['status']=='1'){?>
                                    <button type="button" class="btn btn-sm btn-success">Active</button>
                                    <?php }else if($deptsInfo[$dept]['status']=='0'){?>
                                    <button type="button" class="btn btn-sm btn-danger">InActive</button>
                                    <?php }?>
                                  </td>
                                  <?php if($_SESSION['userGroupID']==1 or $_SESSION['userGroupID']==2){?>
                                  <td><p data-placement="top" data-toggle="tooltip" title="">
                                      <button class="btn btn-primary btn-xs openPopup" data-title="Edit Department" data-target="edit-department.php?did=<?php echo $deptsInfo[$dept]['id'];?>"><span class="glyphicon glyphicon-pencil"></span> Edit</button>
                                    </p></td>
                                  <td><p data-placement="top" data-toggle="tooltip" title="">
                                      <button class="btn btn-danger btn-xs openPopup" data-title="Delete Department" data-toggle="modal" data-target="del-department.php?did=<?php echo $deptsInfo[$dept]['id'];?>" ><span class="glyphicon glyphicon-trash"></span> Delete</button>
                                    </p></td>
                                </tr>
                                <?php }?>
                                <?php }
								}?>
                              </tbody>
                            </table>
                          </div>
                        </div>
                      </div>
                      <?php }if($_SESSION['userGroupID']==1 or in_array(4,$userAccessModules)){?>
                      <hr class="style18">
                      <div class="row">
                        <div class="col-md-12">
                          <h6 class="font-weight-bold" style="text-align:left;color:#000000; font-size:20px;"><strong>Files</strong></h6>
                          <div style="text-align:right;" data-placement="top" data-toggle="tooltip" title="Add File">                           
                          <i class="fa fa-file"> <i class="fa fa-plus openPopup" data-target="add-file.php" style=" cursor:pointer;" data-title="Add File" title="CLick to Add File"></i></i>
                          </div>
                          <div class="table-responsive" id="filesList">
                            <table id="tblFilesListings" class="table table-striped table-bordered" style="width:100%">
                              <thead>
                                <tr>
                                  <th>Sr#</th>
                                  <th>Name</th>
                                  <th>Description</th>
                                  <th>Department</th>
                                  <th>Status</th>
                                  <th>Edit</th>
                                  <th>Delete</th>
                                </tr>
                              </thead>
                              <tbody>
                                <?php 
								  $srno = 0;
								  								  
								  $selQry_files = "SELECT * FROM ".TBL_FILES." ORDER BY name";
								  $filesInfo =  $con->getMultiRow($selQry_files, __FILE__,__LINE__);
								  $totFilesListings = count($filesInfo);
									if($totFilesListings>0)
									{
										for($file=0;$file<$totFilesListings;$file++)
										{
											$srno++;
								  			//----------------------------------------
											$selQry_depts = "SELECT * FROM ".TBL_DEPARTMENTS." WHERE id = '".$filesInfo[$file]['department_id']."' ORDER BY name";
								 			$deptsInfo =  $con->getSingleRow($selQry_depts, __FILE__,__LINE__);
											//----------------------------------------
								?>
                                <tr>
                                  <td><?php echo $srno;?>.</td>
                                  <td style="text-align:left;"><?php echo $filesInfo[$file]['name'];?></td>
                                  <td style="text-align:left;"><?php echo $filesInfo[$file]['description'];?></td>
                                  <td style="text-align:left;"><?php echo isset($deptsInfo['name'])?$deptsInfo['name']:'';?></td>
                                  <td style="text-align:left;"><?php if($filesInfo[$file]['status']=='1'){?>
                                    <button type="button" class="btn btn-sm btn-success">Active</button>
                                    <?php }else if($filesInfo[$file]['status']=='0'){?>
                                    <button type="button" class="btn btn-sm btn-danger">InActive</button>
                                    <?php }?>
                                  </td>
                                  <td><p data-placement="top" data-toggle="tooltip" title="">
                                      <button class="btn btn-primary btn-xs openPopup" data-title="Edit File" data-target="edit-file.php?fid=<?php echo $filesInfo[$file]['id'];?>"><span class="glyphicon glyphicon-pencil"></span> Edit</button>
                                    </p></td>
                                  <td><p data-placement="top" data-toggle="tooltip" title="">
                                      <button class="btn btn-danger btn-xs openPopup" data-title="Delete File" data-toggle="modal" data-target="del-file.php?fid=<?php echo $filesInfo[$file]['id'];?>" ><span class="glyphicon glyphicon-trash"></span> Delete</button>
                                    </p></td>
                                </tr>
                                <?php }
								}?>
                              </tbody>
                            </table>
                          </div>
                        </div>
                      </div>
                      <?php }?>
                      <hr class="style18" >
                          <div class="row" id="btnProcMap">
                            <div class="col-lg-12" style="text-align:right;">
                              <div class="login-button-pro">
                                <a href="dashboard.php"><button type="submit" class="btn btn-success login-button-lg" id="proMap">Proceed</button></a>
                              </div>
                            </div>
                      </div>
                      
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
</div>
<!-- Data table area End-->
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
  <div class="modal-dialog modal-lg">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title"></h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>
      <div class="modal-body"> </div>
      <div class="modal-footer">
        <!--<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>-->
      </div>
    </div>
  </div>
</div>

<!-- Footer Start-->
<?php include("includes/footer.php");?>
<!-- Footer End-->
<!-- jquery
		============================================ -->
<script src="js/vendor/jquery-1.11.3.min.js"></script>
<!-- bootstrap JS
		============================================ -->
<script src="js/bootstrap.min.js"></script>
<!-- meanmenu JS
		============================================ -->
<script src="js/jquery.meanmenu.js"></script>
<!-- mCustomScrollbar JS
		============================================ -->
<script src="js/jquery.mCustomScrollbar.concat.min.js"></script>
<!-- sticky JS
		============================================ -->
<script src="js/jquery.sticky.js"></script>
<!-- scrollUp JS
		============================================ -->
<script src="js/jquery.scrollUp.min.js"></script>
<script src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.21/js/dataTables.bootstrap4.min.js"></script>
<!-- switcher JS
		============================================ -->
<script src="js/switcher/styleswitch.js"></script>
<script src="js/switcher/switch-active.js"></script>
<!-- touchspin JS
		============================================ -->
<script src="js/touchspin/jquery.bootstrap-touchspin.min.js"></script>
<script src="js/touchspin/touchspin-active.js"></script>
<!-- icheck JS
		============================================ -->
<script src="js/icheck/icheck.min.js"></script>
<script src="js/icheck/icheck-active.js"></script>
<!-- summernote JS
		============================================ -->
<script src="js/summernote.min.js"></script>
<script src="js/summernote-active.js"></script>
<!-- notification JS 
		============================================ -->
<script src="js/Lobibox.js"></script>
<script src="js/notification-active.js"></script>
<!-- main JS
		============================================ -->
<script src="js/main.js"></script>
<script>
$(document).ready(function() {
   
    $("#frmOrganizationInfo").on('submit', function(e)
	{	
		e.preventDefault();	
		var shdata = new FormData(this);
	
		$.ajax({		
		type: 'POST',
        url: 'configurations-config.php',
		processData: false,
		contentType: false,
        data: shdata,
		cache: false,
		dataType: 'JSON',
        success:function(response){
            if(response[0].message == 'ok'){
				
				Lobibox.notify('success', {
                    title: 'Success',
                    msg: 'Info updated successfully.'
                });
				
            }else{
				Lobibox.notify('error', {
                    title: 'Error',
                    msg: 'Some problem occurred, please try again.'
                });
            }
        },
		error:function(html)
		{			
			Lobibox.notify('error', {
                    title: 'Error',
                    msg: 'Some problem occurred, Please try again.'
                });
        }
    });
	});
	
	$( ".openPopup" ).click(function() {
	 
	  var dataURL = $(this).attr('data-target');
	  var dataTitle = $(this).attr('data-title');
	  
	  $('#myModal').find('.modal-title').text(dataTitle);
      //$('#myModal').modal({show:true});  
		$('.modal-body').load(dataURL,function(){
            $('#myModal').modal({show:true});
        });
	});
	
	<?php if( ($totUsersListings>0) && ($totDeptsListings>0) && ($totFilesListings>0) ){?>
		$("#btnDashboard").show();	
		$("#btnProcMap").show();
		$("#proMap").prop("disabled", false);
	<?php }else{?>
		$("#btnDashboard").hide();	
		$("#btnProcMap").hide();
		$("#proMap").prop("disabled", true);
	<?php }?>	
	
	$('#tblGroupsListings,#tblUsersListings,#tblDepartmentsListings,#tblFilesListings').DataTable();
	
} );

function PreviewImage() {
	var oFReader = new FileReader();
	oFReader.readAsDataURL(document.getElementById("logo").files[0]);

	oFReader.onload = function (oFREvent) {
		document.getElementById("uploadPreview").src = oFREvent.target.result;
	};
};
	
function getDataCount()
{
	$.ajax({
		type: "POST",
		url: "getDataCount.php",
		//data:'',
		dataType: 'JSON',
		success: function(response){
			if(response[0].message == 'proceed'){			
				
				$("#btnDashboard").show();
				$("#btnProcMap").show();	
				$("#proMap").prop("disabled", false);							
				
				Lobibox.notify('success', {
                    title: 'Success',
                    msg: 'Congratulations! Your basic setup has been completed and you can proceed now.'
                });			
            }
			else
			{			
				//$("#btnDashboard").hide();	
				//$("#btnProcMap").show();
				//$("#proMap").prop("disabled", true);			
            }		
		}
	});
}

function getGroups()
{
	$.ajax({
		type: "POST",
		url: "getGroups.php",
		//data:'',
		success: function(data){
			$('#groupsList').html(data);
			//getDataCount();
		}
	});
}

function getUsers()
{
	$.ajax({
		type: "POST",
		url: "getUsers.php",
		//data:'',
		success: function(data){
			$('#usersList').html(data);
			
			getDataCount();
			
		}
	});
}

function getDepartments()
{	
	$.ajax({
		type: "POST",
		url: "getDepartments.php",
		//data:'',
		success: function(data){
			$('#deptList').html(data);
			//getDataCount();
		}
	});
}

function getFiles()
{	
	$.ajax({
		type: "POST",
		url: "getFiles.php",
		//data:'',
		success: function(data){
			$('#filesList').html(data);
			
			getDataCount();
			
		}
	});
}
</script>
</body>
</html>
