외교권자 임명 대기중
This commit is contained in:
+77
-5
@@ -35,8 +35,12 @@ if($meLevel == 0) {
|
|||||||
<title><?=UniqueConst::$serverName?>: 인사부</title>
|
<title><?=UniqueConst::$serverName?>: 인사부</title>
|
||||||
<?=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
|
<?=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
|
||||||
<?=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
|
<?=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
|
||||||
|
<?=WebUtil::printJS('../e_lib/select2/select2.full.min.js')?>
|
||||||
<?=WebUtil::printJS('js/common.js')?>
|
<?=WebUtil::printJS('js/common.js')?>
|
||||||
|
<?=WebUtil::printJS('js/bossInfo.js')?>
|
||||||
<?=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
|
<?=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
|
||||||
|
<?=WebUtil::printCSS('../e_lib/select2/select2.min.css')?>
|
||||||
|
<?=WebUtil::printCSS('../e_lib/select2/select2-bootstrap4.css')?>
|
||||||
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
||||||
<?=WebUtil::printCSS('css/common.css')?>
|
<?=WebUtil::printCSS('css/common.css')?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@@ -45,6 +49,51 @@ function out() {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$query = "select nation,name,level,color,l12set,l11set,l10set,l9set,l8set,l7set,l6set,l5set from nation where nation='{$me['nation']}'";
|
||||||
|
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||||
|
$nation = MYDB_fetch_array($result); //국가정보
|
||||||
|
|
||||||
|
$ambassadors = $db->query('SELECT no, name, level, penalty, permission FROM general WHERE permission = \'ambassador\' AND nation = %i', $nation['nation']);
|
||||||
|
$auditors = $db->query('SELECT no, name, level, penalty, permission FROM general WHERE permission = \'auditor\' AND nation = %i', $nation['nation']);
|
||||||
|
$candidateAmbassadors = [];
|
||||||
|
$candidateAuditors = [];
|
||||||
|
foreach($ambassadors as $ambassador){
|
||||||
|
$candidateAmbassadors[] = $ambassador;
|
||||||
|
}
|
||||||
|
foreach($auditors as $auditor){
|
||||||
|
$candidateAuditors[] = $auditor;
|
||||||
|
}
|
||||||
|
foreach($db->query('SELECT no, name, nation, level, penalty, permission FROM general WHERE nation = %i AND permission = \'normal\' AND level != 12', $nation['nation']) as $candidate){
|
||||||
|
$maxPermission = checkSecretMaxPermission($candidate);
|
||||||
|
if($maxPermission == 4){
|
||||||
|
$candidateAmbassadors[] = $candidate;
|
||||||
|
}
|
||||||
|
if($maxPermission >= 3){
|
||||||
|
$candidateAuditors[] = $candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
var candidateAmbassadors = <?=Json::encode(array_map(function($value){
|
||||||
|
return [
|
||||||
|
'id'=>$value['no'],
|
||||||
|
'text'=>$value['name'],
|
||||||
|
"selected"=>($value['permission']!='normal')
|
||||||
|
];
|
||||||
|
}, $candidateAmbassadors))?>;
|
||||||
|
|
||||||
|
var candidateAuditors = <?=Json::encode(array_map(function($value){
|
||||||
|
return [
|
||||||
|
'id'=>$value['no'],
|
||||||
|
'text'=>$value['name'],
|
||||||
|
"selected"=>($value['permission']!='normal')
|
||||||
|
];
|
||||||
|
}, $candidateAuditors))?>;
|
||||||
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@@ -55,10 +104,6 @@ function out() {
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$query = "select nation,name,level,color,l12set,l11set,l10set,l9set,l8set,l7set,l6set,l5set from nation where nation='{$me['nation']}'";
|
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$nation = MYDB_fetch_array($result); //국가정보
|
|
||||||
|
|
||||||
$lv = getNationChiefLevel($nation['level']);
|
$lv = getNationChiefLevel($nation['level']);
|
||||||
if($meLevel >= 5) { $btn = "submit"; }
|
if($meLevel >= 5) { $btn = "submit"; }
|
||||||
else { $btn = "hidden"; }
|
else { $btn = "hidden"; }
|
||||||
@@ -77,6 +122,7 @@ $tigerresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connec
|
|||||||
$query = "select name,picture,firenum from general where nation='{$nation['nation']}' order by firenum desc limit 7"; // 건안칠자
|
$query = "select name,picture,firenum from general where nation='{$nation['nation']}' order by firenum desc limit 7"; // 건안칠자
|
||||||
$eagleresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$eagleresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||||
|
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
<table align=center width=1000 class='tb_layout bg0'>
|
<table align=center width=1000 class='tb_layout bg0'>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -279,9 +325,35 @@ for($i=10; $i >= $lv; $i--) {
|
|||||||
echo "
|
echo "
|
||||||
<tr><td colspan=4>※ <font color=red>빨간색</font>은 현재 임명중인 장수, <font color=orange>노란색</font>은 다른 관직에 임명된 장수, 하얀색은 일반 장수를 뜻합니다.</td></tr>
|
<tr><td colspan=4>※ <font color=red>빨간색</font>은 현재 임명중인 장수, <font color=orange>노란색</font>은 다른 관직에 임명된 장수, 하얀색은 일반 장수를 뜻합니다.</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
";
|
||||||
|
|
||||||
|
if($meLevel == 12):
|
||||||
|
?>
|
||||||
|
<table align='center' width='1000' class='tb_layout bg0'>
|
||||||
|
<tr><td colspan='4' height='5'></td></tr>
|
||||||
|
<tr><td colspan='4' align='center' bgcolor='purple'>외 교 권 자 임 명</td></tr>
|
||||||
|
<tr>
|
||||||
|
<td width=98 align=right id=bg1>외교권자</td>
|
||||||
|
<td width=398>
|
||||||
|
<select id="selectAmbassador" multiple="multiple">
|
||||||
|
</select>
|
||||||
|
<button id='changeAmbassador' type='button'>임명</button>
|
||||||
|
</td>
|
||||||
|
<td width=98 align=right id=bg1>조언자</td>
|
||||||
|
<td width=398>
|
||||||
|
<select id="selectAuditor" multiple="multiple">
|
||||||
|
</select>
|
||||||
|
<button id='changeAuditor' type='button'>임명</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<?php
|
||||||
|
endif;
|
||||||
|
?>
|
||||||
<table align=center width=1000 class='tb_layout bg0'>
|
<table align=center width=1000 class='tb_layout bg0'>
|
||||||
<tr><td colspan=5 height=5></td></tr>
|
<tr><td colspan=5 height=5></td></tr>
|
||||||
";
|
<?php
|
||||||
if($meLevel >= 5) {
|
if($meLevel >= 5) {
|
||||||
echo "
|
echo "
|
||||||
<tr><td colspan=5 align=center bgcolor=orange>도 시 관 직 임 명</td></tr>
|
<tr><td colspan=5 align=center bgcolor=orange>도 시 관 직 임 명</td></tr>
|
||||||
|
|||||||
+16
-10
@@ -399,6 +399,20 @@ function myNationInfo() {
|
|||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkSecretMaxPermission($me){
|
||||||
|
$secretMax = 4;
|
||||||
|
if($penalty['noTopSecret']??false){
|
||||||
|
$secretMax = 1;
|
||||||
|
}
|
||||||
|
else if($penalty['noChief']??false){
|
||||||
|
$secretMax = 1;
|
||||||
|
}
|
||||||
|
else if($penalty['noAmbassador']??false){
|
||||||
|
$secretMax = 2;
|
||||||
|
}
|
||||||
|
return $secretMax;
|
||||||
|
}
|
||||||
|
|
||||||
function checkSecretPermission($me, $checkSecretLimit=true){
|
function checkSecretPermission($me, $checkSecretLimit=true){
|
||||||
if(!key_exists('penalty', $me) || !key_exists('permission', $me)){
|
if(!key_exists('penalty', $me) || !key_exists('permission', $me)){
|
||||||
trigger_error ('canAccessSecret() 함수에 필요한 인자가 부족');
|
trigger_error ('canAccessSecret() 함수에 필요한 인자가 부족');
|
||||||
@@ -420,16 +434,8 @@ function checkSecretPermission($me, $checkSecretLimit=true){
|
|||||||
}
|
}
|
||||||
|
|
||||||
$secretMin = 0;
|
$secretMin = 0;
|
||||||
$secretMax = 4;
|
$secretMax = checkSecretMaxPermission($me);
|
||||||
if($penalty['noTopSecret']??false){
|
|
||||||
$secretMax = 1;
|
|
||||||
}
|
|
||||||
else if($penalty['noChief']??false){
|
|
||||||
$secretMax = 1;
|
|
||||||
}
|
|
||||||
else if($penalty['noAmbassador']??false){
|
|
||||||
$secretMax = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($me['level'] == 12){
|
if($me['level'] == 12){
|
||||||
$secretMin = 4;
|
$secretMin = 4;
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
include "lib.php";
|
||||||
|
include "func.php";
|
||||||
|
// $btn, $level, $genlist, $outlist
|
||||||
|
|
||||||
|
//TODO: 변경이 완료되면 항상 공지되어야함
|
||||||
|
|
||||||
|
$isAmbassador = Util::getReq('isAmbassador', bool);
|
||||||
|
$genlist = Util::getReq('genlist', 'array_int');
|
||||||
|
|
||||||
|
//로그인 검사
|
||||||
|
$session = Session::requireGameLogin()->setReadOnly();
|
||||||
|
$userID = Session::getUserID();
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
|
$me = $db->query('SELECT no, level, nation FROM general WHERE owner = %i', $userID);
|
||||||
|
|
||||||
|
if(!$me || $me['level'] != 12){
|
||||||
|
Json::die([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'군주가 아닙니다'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$nationID = $me['nation'];
|
||||||
|
|
||||||
|
if($isAmbassador){
|
||||||
|
$targetType = 'ambassador';
|
||||||
|
$targetLevel = 4;
|
||||||
|
if(count($genlist) > 2){
|
||||||
|
Json::die([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'외교권자는 최대 둘까지만 설정 가능합니다.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$targetType = 'auditor';
|
||||||
|
$targetLevel = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->update('general', [
|
||||||
|
'permission'=>'normal'
|
||||||
|
], 'nation = %i AND permission = %s', $nationID, $targetType);
|
||||||
|
|
||||||
|
if(!$genlist){
|
||||||
|
Json::die([
|
||||||
|
'result'=>true,
|
||||||
|
'reason'=>'success'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$realCandidates = [];
|
||||||
|
foreach($db->query('SELECT no, nation, level, penalty, permission FROM general WHERE nation = %i AND level != 12 AND permission = \'normal\' AND no IN %li', $nationID, $genlist) as $candidate){
|
||||||
|
$maxPermission = checkSecretMaxPermission($candidate);
|
||||||
|
if($maxPermission < $targetLevel){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$realCandidates[] = $candidate['no'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$realCandidates){
|
||||||
|
Json::die([
|
||||||
|
'result'=>true,
|
||||||
|
'reason'=>'success'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->update('general', [
|
||||||
|
'permission'=>$targetType,
|
||||||
|
], 'no IN %li', $realCandidates);
|
||||||
|
|
||||||
|
if(!$realCandidates){
|
||||||
|
Json::die([
|
||||||
|
'result'=>true,
|
||||||
|
'reason'=>'success'
|
||||||
|
]);
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
$(function(){
|
||||||
|
$('#selectAmbassador').select2({
|
||||||
|
theme: 'bootstrap4',
|
||||||
|
placeholder: "",
|
||||||
|
allowClear: true,
|
||||||
|
language: "ko",
|
||||||
|
width:300,
|
||||||
|
maximumSelectionLength: 2,
|
||||||
|
containerCss: {
|
||||||
|
display: "inline-block !important;",
|
||||||
|
color: 'white !important'
|
||||||
|
},
|
||||||
|
data:candidateAmbassadors,
|
||||||
|
//containerCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
||||||
|
dropdownCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#selectAuditor').select2({
|
||||||
|
theme: 'bootstrap4',
|
||||||
|
placeholder: "",
|
||||||
|
allowClear: true,
|
||||||
|
language: "ko",
|
||||||
|
width:300,
|
||||||
|
maximumSelectionLength: 2,
|
||||||
|
containerCss: {
|
||||||
|
display: "inline-block !important;",
|
||||||
|
color: 'white !important'
|
||||||
|
},
|
||||||
|
data:candidateAuditors,
|
||||||
|
//containerCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
||||||
|
dropdownCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#changeAmbassador').click(function(){
|
||||||
|
//TODO: 변경 코드
|
||||||
|
});
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user