project->updateCol("statuses", json_encode(AJTODO_ProjectDefault::DefaultStatus(), JSON_UNESCAPED_UNICODE)); $ret = ""; $ret .= "
"; $ret .= ""; $ret .= $this->createFormPart( __("상태 목록","ajtodo")); if(!$this->project->donedate){ $ret .="".__('상태 추가', 'ajtodo' ).""; } $ret .= "
"; return $ret; } private function getUserSmallCard($id){ $user = get_userdata($id); $ret = ""; $ret .= ""; $ret .= ""; $ret .= "
".get_avatar($user->ID, 18)."".$user->display_name."
"; return $ret; } public function getStatusTypeNameByKey($statustypekey){ switch($statustypekey){ case "S" : return __("작업전 상태","ajtodo"); case "I" : return __("작업중 상태","ajtodo"); case "D" : return __("작업완료 상태","ajtodo"); } return $statustypekey; } public function createFormPart($title){ $ret = ""; $ret .= "
".$title."
"; $ret .= ""; $ret .= ""; $ret .= " "; $ret .= " "; $ret .= " "; $ret .= " "; if(!$this->project->donedate){ $ret .= " "; } $ret .= " "; $ret .= ""; $ret .= ""; foreach($this->project->statuses as $stat){ $ret .= ""; $ret .= " "; $ret .= " "; $ret .= " "; if(!$this->project->donedate){ $ret .= " "; $ret .= ""; } $ret .= ""; $ret .= "
".__("상태","ajtodo")."".__("상태 범주","ajtodo")."".__("상태 변경 및 가능한 역할","ajtodo")."".__("관리","ajtodo")."
".$stat["name"]."".$this->getStatusTypeNameByKey($stat["statustype"]).""; $ret .= $this->viewRules($stat); //foreach($this->getUsersByRole($status["key"]) as $mem){ // $ret .= $this->getUserSmallCard($mem); //} $ret .= "
"; $ret .= "
"; $ret .= " ".__('규칙 관리', 'ajtodo' ).""; $ret .= " ".__('상태 관리', 'ajtodo' ).""; } $ret .= "
"; return $ret; } public function viewRules($stat){ $ret = ""; foreach($stat["rules"] as $rule){ $ret .= ""; } return $ret; } public function getUsersByRole($role){ foreach($this->project->roles as $r){ if($r["key"] == $role){ return $r["users"]; } } return array(); } public function delStatus($statuskey, $tostatuskey){ $n = -1; for($i = 0; $i project->statuses); $i++){ if($this->project->statuses[$i]["key"] == $statuskey){ $n = $i; } } if($n > -1){ array_splice($this->project->statuses, $n, 1); for($i = 0; $i project->statuses); $i++){ $m = -1; for($j = 0; $j project->statuses[$i]["rules"]); $j++){ if($this->project->statuses[$i]["rules"][$j]["to"] == $statuskey){ $m = $j; } } if($m > -1){ array_splice($this->project->statuses[$i]["rules"], $m, 1); } } $arrdo = array("statuskey" => $tostatuskey); if($tostatuskey == "closed") $arrdo["donedated"] = date("Y-m-d H:i:s"); if($tostatuskey == "open") $arrdo["donedated"] = ""; $this->project->updateTodo($arrdo, "statuskey", $statuskey); $this->project->updateCol("statuses", json_encode($this->project->statuses, JSON_UNESCAPED_UNICODE)); } } public function addStatus($dotype, $statuskey, $statusname, $statusicon, $statustype){ if($dotype == "add"){ $has = false; foreach($this->project->statuses as $r){ if($r["key"] == $statuskey){ $has = true; } } if($has){ $this->msg = __("상태 키가 중복됩니다. ","ajtodo"); return false; } $this->project->statuses[] = array( "key" => $statuskey, "name" => $statusname, "statustype" => $statustype, "icon" => $statusicon, "rules" => array(), "color" => "primary"); }else{ foreach($this->project->statuses as &$r){ if($r["key"] == $statuskey){ $r["name"] = $statusname; $r["icon"] = $statusicon; } } } return $this->project->updateCol("statuses", json_encode($this->project->statuses, JSON_UNESCAPED_UNICODE)); } private function getStatusNameByKey($statuskey){ $ret = ""; if($statuskey){ foreach($this->project->statuses as $s){ if($s["key"] == $statuskey){ $ret = $s["name"]; } } } return $ret; } public static function getStatusByType($prj, $type){ foreach($prj->statuses as $s){ if($s["statustype"] == $type){ return $s; } } } public static function getSingleStatusByStatus($statuses, $statuskey){ foreach($statuses as $s){ if($s["statustype"] == $statuskey){ return $s; } } } public function getSingleStatus($statuskey){ foreach($this->project->statuses as $s){ if($s["key"] == $statuskey){ return $s; } } } private function getStatusIcon($staticon){ $ret = "
"; $isnewset = true; foreach($this->status_icons as $icon){ if($staticon == "fa-".$icon){ $ret .= ""; }else{ $ret .= ""; if(!$staticon){ $isnewset = false; } } } $ret .= "
"; return $ret; } public function addStatusView($statuskey){ if($statuskey){ $stat = $this->getSingleStatus($statuskey); } $ret = ""; $ret .= "
"; if($statuskey){ $ret .= __("프로젝트 상태 수정","ajtodo"); }else{ $ret .= __("프로젝트 상태 추가","ajtodo"); } $ret .= "
"; $ret .= "
"; $ret .= ""; $ret .= ""; $ret .= "
"; $ret .= " "; $ret .= "
"; $ret .= $this->getStatusIcon($statuskey ? $stat["icon"] : ""); $ret .= "
"; $ret .= "
"; $ret .= "
"; $ret .= " "; $ret .= "
"; if($statuskey){ $ret .= ""; $ret .= "".$statuskey.""; }else{ $ret .= ""; $ret .= "

".__("10자 이내의 영문자와 숫자만 가능합니다.","ajtodo")."

"; } $ret .= "
"; $ret .= "
"; $ret .= "
"; $ret .= " "; $ret .= "
"; if($statuskey){ $ret .= ""; $ret .= "".$this->getStatusTypeNameByKey($stat["statustype"]).""; }else{ $ret .= ""; $ret .= "".$this->getStatusTypeNameByKey("I").""; //$ret .= ""; } $ret .= "
"; $ret .= "
"; $ret .= "
"; $ret .= " "; $ret .= "
"; $ret .= ""; $ret .= "
"; $ret .= "
"; $ret .= "".__('변경 사항 적용', 'ajtodo' ).""; if($statuskey){ if($statuskey != "open" && $statuskey != "closed"){ $ret .= "".__('상태 삭제', 'ajtodo' ).""; } } $ret .= "".__('상태 목록', 'ajtodo' ).""; $ret .= "
"; return $ret; } public function addRuleView($statuskey){ $stat = $this->getSingleStatus($statuskey); $ret = ""; $ret .= "
"; $ret .= ""; $ret .= ""; $ret .= $this->createRulePart($stat); $ret .= "".__('변경 사항 적용', 'ajtodo' ).""; $ret .= "".__('상태 목록', 'ajtodo' ).""; $ret .= "
"; return $ret; } public function createRulePart($stat){ $ret = ""; $ret .= "
'".$stat["name"]."'". __(" - 규칙 관리","ajtodo")."
"; $ret .= ""; $ret .= ""; $ret .= " "; //$ret .= " "; $ret .= " "; $ret .= " "; $ret .= " "; $ret .= " "; $ret .= ""; $ret .= ""; foreach($this->project->statuses as $status){ if($status["key"] == $stat["key"]) continue; $ret .= ""; $ret .= " "; $ret .= " "; $ret .= " "; $ret .= ""; } $ret .= ""; $ret .= "
".__("상태","ajtodo")."".__("상태 변경","ajtodo")."".__("상태 변경이 가능한 역할","ajtodo")."".__("역할 추가","ajtodo")."
".$stat["name"]." -> ".$status["name"].""; $ret .= "
"; $ret .= " "; $ret .= "
"; $ret .= " "; $ret .= "
"; $ret .= "
"; $ret .= "
"; foreach($stat["rules"] as $rule){ if($rule["to"] == $status["key"]){ foreach($rule["roles"] as $rolekey){ $ret .= $this->makeRole($rolekey, $this->getRoleNameByKey($rolekey)); } } } $ret .="
"; return $ret; } private function getRoleNameByKey($key){ foreach($this->project->roles as $role){ if($role["key"] == $key) return $role["name"]; } return ""; } private function getTodoCountByStatus($key){ global $wpdb; return $wpdb->get_var("select count(id) from ".AJTODO_DB_TODO."_".$this->project->id." where statuskey = '".$key."'"); } public function delConfirmView($statuskey){ $status = $this->getSingleStatus($statuskey); $scount = $this->getTodoCountByStatus($statuskey); $ret = ""; $ret .= "
"; $ret .= ""; $ret .= wp_nonce_field('ajtodo_nonce','update_roleperm'); $ret .= "
".__("상태 이름","ajtodo")." : ".$status["name"]."
".__("이 상태를 삭제하시겠습니까?","ajtodo")."
  • ".__("이 상태의 할일 개수","ajtodo")." : ".$this->getTodoCountByStatus($statuskey)."
"; if($scount){ $ret .= "
"; $ret .= "
".__("이 상태의 할일들을 어떤 상태로 변경할까요?","ajtodo")."
"; $ret .= "
"; $ret .= "
"; } $ret .= "
".__("취소","ajtodo")."
"; $ret .= "
"; return $ret; } public function makeRole($key, $name){ $rolebox = ""; if($name){ $rolebox = "
"; $rolebox .= ""; $rolebox .= ""; $rolebox .= "
"; } return $rolebox; } public function updateActionRole($statuskey, $actionrole){ foreach($this->project->statuses as &$r){ if($r["key"] == $statuskey){ $r["rules"] = json_decode(stripslashes($actionrole), true); } } return $this->project->updateCol("statuses", json_encode($this->project->statuses, JSON_UNESCAPED_UNICODE)); } }