<?php
include ("include/config.php");
include ("include/protect.class.php");
include ("include/functions.php");
include ("include/jdf.php");
$prot = new protect();
if ($prot->showPage) {
    $db = new DB($globalConfig['dbase'], $globalConfig['dbhost'], $globalConfig['dbuser'],
        $globalConfig['dbpass']);
    mysql_query("SET NAMES utf8");
    if (isset($_GET['act'])) {
        $action = $_GET['act'];
    }
    switch ($action) {
            //-------------------------------------------------------------------------------
        case 'edit':
              $db->execute("update adminavilable set 
													A_delete ='".$db->safe_string($_POST['A_delete'])."',
													A_edite ='".$db->safe_string($_POST['A_edite'])."',
													addCredit='".$db->safe_string($_POST['addCredit'])."',
													taeadUserNaja ='".$db->safe_string($_POST['taeadUserNaja'])."',
													taeadUserCompany ='".$db->safe_string($_POST['taeadUserCompany'])."'
													where userID ='".$_GET['userID']."' ");
            header("location: adminavilable.php");
            break;			
    }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> مدیریت دسترسی امکانات</title>
<?php include("maintemplate/mainheader.php");?>
<script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script>
function admin_file(id){ 
			$.ajax({
   type: "POST",
   url: "send_ajax_chitasoft.php?act=admin_file",
   data: "id="+id,
   success: function(msg){
document.getElementById("result").innerHTML=msg;
   }
			
 });
}	
</script>			
		
</head>
<body>
<div id="wpwrap">
<div id="wpcontent">
	<?php include("include/menutop.php");?> 
<div id="wpbody">
	<?php include("include/header.php");?>
    <div style="overflow:hidden;" id="wpbody-content">
        <div id="screen-meta">
            <div class="wrap">
                <div id="icon-index" class="icon32"><br></div>
                <h2>مدیریت دسترسی امکانات</h2>
                <div id="dashboard-widgets-wrap">
                    <div id="dashboard-widgets" class="metabox-holder">
                        <div class="postbox-container" style="width:100%;">
                            <div id="normal-sortables" class="meta-box-sortables ui-sortable"><div id="dashboard_recent_comments" class="postbox ">
                             <div class="handlediv" title="برای جانشینی کلیک کنید"><br></div><h3 class="hndle"><span>مدیریت دسترسی امکانات</span></h3>
<?php
echo $_POST['delete'];
echo $_GET['userID'];
    switch ($action) {
            //-------------------------------------------------------------------------------------
        default:

            $sql = $db->query("select * from u_admin_users");
            echo '<table width="100%" border="0" cellpadinf="3" cellspacing="0" dir="rtl">';
            echo '<tr>
					<th class="td_header"> نام کاربری </th>
					<th class="td_header"> نام گروه </th>
					<th class="td_header"> امکانات </th>
				</tr>';
            while ($res = $db->fetchNextArray($sql)) {
                $sql1 = $db->query("select groupName from u_admin_groups where groupsID = '".$res['userGroup']."'");
                $res1 = $db->fetchNextArray($sql1);
				
				$sql2 = $db->query("select * from adminavilable where userID = '".$res['ID']."'");
                $res2 = $db->fetchNextArray($sql2);
				$checkDell='';$checkEdite='';$checkAddCredit='';$checkTaeadUserComapany='';$checkTaeadUserNaja='';
				if($res2['A_delete']==1){
					$checkDell='checked="checked"';
				}
				if($res2['A_edite']==1){
					$checkEdite='checked="checked"';
				}
				if($res2['addCredit']==1){
					$checkAddCredit='checked="checked"';
				}
				if($res2['taeadUserNaja']==1){
					$checkTaeadUserNaja='checked="checked"';
				}
				if($res2['taeadUserCompany']==1){
					$checkTaeadUserComapany='checked="checked"';
				}
                echo '<tr>
				<td align=center class="tablebattom1">'.$res['userName'] .' </td>
				<td align=center class="tablebattom1">'.$res1['groupName'].' </td>
				<td align=center class="tablebattom1"> 
				<form name="" action="adminavilable.php?act=edit&userID='.$res['ID'].'" method="post">
					حذف: <input type="checkbox" name="A_delete" '.$checkDell.'  value="1"/> |
					ویرایش: <input type="checkbox" name="A_edite" '.$checkEdite.' value="1" /> |
					افزودن موجودی: <input type="checkbox" name="addCredit" '.$checkAddCredit.' value="1"/> |
					تایید کاربر توسط ناجا: <input type="checkbox" name="taeadUserNaja"  '.$checkTaeadUserNaja.' value="1" /> |
					تایید کاربر توسط شرکت: <input type="checkbox" name="taeadUserCompany"  '.$checkTaeadUserComapany.' value="1" /> 
					
					<input type="submit" name="submit" value="ثبت تغییرات" >
				</form>
				 </td></tr>';
            }
            echo '</table>';
	break;
	}
?>
                              </div>
                                
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div><!-- dashboard-widgets-wrap -->
            </div><!-- wrap -->
			<div class="clear"></div></div><!-- wpbody-content -->
			<div class="clear"></div></div><!-- wpbody -->
			<div class="clear"></div></div><!-- wpcontent -->
        </div>
    </div><!-- wpcontent -->
</div><!-- wpwrap -->
<?php include("include/footer.php");?>
</div>
</div>
</body>
</html><?php } ?>