<?php
header("Content-type:text/html;charset=utf-8");  
session_start();
$session_admin = isset($_SESSION['admin']) ? $_SESSION['admin'] : ''; 
if ($session_admin == '') {
	die("Can not access");
}
require_once("../common.php");
checkadminrights($session_admin, 'departments');

$departid = isset($_GET['departid']) ? $_GET['departid'] : '';
$departname = isset($_GET['departname']) ? urldecode($_GET['departname']) : '';
$userid = isset($_GET['userid']) ? $_GET['userid'] : '0'; 
$nickname = isset($_GET['nickname']) ? urldecode($_GET['nickname']) : '';

//subpageurlparams
$subpageurlparams = 'departid=' . $departid . '&departname=' . urlencode($departname) . 
	'&userid=' . $userid . '&nickname=' . urlencode($nickname);

$methodname = 'Admin.MoveDownDepartUser';
$requestinfo = '<?xml version="1.0" encoding="utf-8"?><request>' . 
    '<ip>' . getip() . '</ip>' . 
	'<departid>' . $departid . '</departid>' . 
	'<userid>' . $userid . '</userid>' . 
	'</request> ';
$responseinfo = '';
$responsexml = null;
$errorcode = ERRORCODE_UNKNOWN;

$cmd = new COM("OpenCom.Command");
$methodname = iconv('UTF-8', 'GBK//IGNORE', $methodname);
$requestinfo = iconv('UTF-8', 'GBK//IGNORE', $requestinfo);
if ($cmd->Execute($methodname, $requestinfo, $responseinfo, 5000)) {
	$responseinfo = iconv('GBK', 'UTF-8//IGNORE', $responseinfo);
	$responsexml = simplexml_load_string($responseinfo);
	$errorcode = $responsexml->errorcode;
}
$cmd = null;

switch($errorcode) {
	case ERRORCODE_OK: 
		header("Location: departments_users.php?{$subpageurlparams}");
		break;
	default:
		header("Location: departments_users.php?{$subpageurlparams}");
}//switch
?>