"; } public function setPlanBoard($orderlist){ $maxwidth = count($this->project->statuses) * ($this->listwidth + 8); $addbox = "
"; $addbox .= "
".__("할일 추가","ajtodo")."
"; $addbox .= ""; $addbox .= "
"; $ret = "
"; foreach($this->project->statuses as $status){ if($status['key'] == "open"){ $ret .= "
"; $ret .= "
".$status['name']."
"; $ret .= ""; $ret .= $addbox; $ret .= "
"; } } $ret .= "
"; $sarr = array(); if($orderlist){ $sarr = json_decode($orderlist, true); $arrset = array(); foreach($sarr as $a){ if($a['status'] != "open" && $a['status'] != "closed"){ foreach($this->project->statuses as $status){ if($status['key'] == $a['status']){ $arrset[] = $a['status']; $ret .= "
"; $ret .= "
".$status['name']."
"; $ret .= "
    "; $ret .= "
"; $ret .= "
"; } } } } foreach($this->project->statuses as $status){ if(!in_array($status['key'], $arrset) && $status['key'] != "open" && $status['key'] != "closed"){ $ret .= "
"; $ret .= "
".$status['name']."
"; $ret .= "
    "; $ret .= "
"; $ret .= "
"; } } }else{ foreach($this->project->statuses as $status){ if($status['key'] != "open" && $status['key'] != "closed"){ $ret .= "
"; $ret .= "
".$status['name']."
"; $ret .= "
    "; $ret .= "
"; $ret .= "
"; } } } $ret .= "
"; foreach($this->project->statuses as $status){ if($status['key'] == "closed"){ $ret .= "
"; $ret .= "
".$status['name']."
"; $ret .= ""; $ret .= "
"; } } $ret .= "
"; return $ret; } public function planListViewAjax($todolist){ $ret = ""; $ret .= "
"; $ret .= "
"; if($this->project->hasPerm("tp_plan_create") && !$this->project->donedate){ $ret .= "
"; $ret .= " "; $ret .= "
"; }else{ $ret .= " "; } $ret .= " "; $ret .= "
"; $ret .= "
"; //$ret .= " "; $ret .= $todolist; $ret .= "
"; $ret .= "
"; return $ret; } public function planListView(){ $ret = ""; $ret .= "
"; $ret .= ""; $ret .= $this->createFormPart( __("진행중/진행예정 플랜","ajtodo"), false ); $ret .="

"; $ret .= $this->createFormPart( __("완료된 플랜","ajtodo"), true ); $ret .= "
"; return $ret; } public function showPlanInfo($planid = ""){ $ret = ""; foreach($this->project->plan as $plan){ if($planid && ($planid != $plan["id"])){ continue; } $isdone = $plan["donedate"] != ""; $ret .= "
"; $ret .= "
".$plan["plantitle"]; if($plan["ising"] == "Y"){ $ret .= " ".__("진행중","ajtodo").""; } $ret .= " "; $ret .= __("할일 개수","ajtodo")." : ".$this->getTodoCountByPlan($plan["id"]).""; $ret .= "
"; $ret .= "
"; if(!$plan["donedate"]){ $ret .= " ".$this->getPlanProgress2($plan["id"]).""; } $ret .= "

".__("시작일")." : ".substr($plan["startdate"],0, 10); if($plan["donedate"]){ $ret .= " ~ ".__("완료일")." : ".substr($plan["donedate"],0, 10)." (".__("목표일")." : ".substr($plan["finishdate"],0, 10).")"; }else{ $ret .= " ~ ".__("목표일")." : ".substr($plan["finishdate"],0, 10); } $ret .= "

"; $ret .= "

".__("플랜 목표","ajtodo")."

"; $ret .= "

".nl2br($plan["plancomment"])."

"; $ret .= "
"; $ret .= "
"; } return $ret; } public function updateTodoOrder($planid, $orders){ global $wpdb; return $wpdb->get_var("update ".AJTODO_DB_PLAN." set todoorderset = '".$orders."' where id =".$planid); } public function getStartPlan(){ global $wpdb; $ingid = $wpdb->get_var("select id from ".AJTODO_DB_PLAN." where projectid =".$this->project->id." and ising = 'Y'"); return $ingid; } public function startPlan($isstart){ global $wpdb; $ret = false; if($isstart){ $ing = $wpdb->get_var("select count(id) from ".AJTODO_DB_PLAN." where projectid =".$this->project->id." and ising = 'Y'"); if($ing){ $this->msg = __("진행중인 플랜이 존재합니다.","ajtodo"); return $ret; }else{ $ret = $wpdb->query("update ".AJTODO_DB_PLAN." set ising = 'Y' where id = ".$this->id); if($ret) do_action('ajtodo_start_plan', $this->project->id, $this->id); return $ret; } }else{ $ret = $wpdb->query("update ".AJTODO_DB_PLAN." set ising = 'N' where id = ".$this->id); if($ret) do_action('ajtodo_stop_plan', $this->project->id, $this->id); return $ret; } } private function getTodoCountByPlan($key){ global $wpdb; return $wpdb->get_var("select count(id) from ".AJTODO_DB_TODO."_".$this->project->id." where planid = ".$key); } public function getTodoCountByPlans(){ global $wpdb; $sql = "select planid, IF(ISNULL(donedated), 'O', 'D') as statuskey, count(id) as cnt from ".AJTODO_DB_TODO."_".$this->project->id ; $sql .= " group by planid, statuskey"; $list = $wpdb->get_results($sql, ARRAY_A); $this->project->plan[] = array("id" => "0", "plantitle" => __("플랜 없음","ajtodo") ); foreach($this->project->plan as &$plan){ $ismatsh = false; foreach($list as $l){ if($plan["id"] == $l["planid"]){ $ismatsh = true; $plan["cnt"][] = $l; } } if(!$ismatsh) $plan["cnt"] = array(); } } public function delPlan($key){ global $wpdb; $wpdb->get_var("delete from ".AJTODO_DB_PLAN." where id = ".$key); $wpdb->get_var("update ".AJTODO_DB_TODO."_".$this->project->id." set planid = NULL where planid = ".$key); do_action('ajtodo_del_plan', $this->project->id, $key); return true; } public static function getPlan($planid){ global $wpdb; $sql = "select * from ".AJTODO_DB_PLAN." where id = ".$planid; $ret = $wpdb->get_row($sql); $ret = apply_filters('ajtodo_get_planinfo', $ret, $planid); return $ret; } public function finish($key){ global $wpdb; $this->makeDoneTodoInPlan($key); $wpdb->query("update ".AJTODO_DB_PLAN." set donedate = '".date("Y-m-d H:i:s")."' where id = ".$key); do_action('ajtodo_finish_plan', $this->project->id, $key); return true; } public function makeDoneTodoInPlan($planid){ global $wpdb; $todo = new AJTODO_Todo(); $todo->project = $this->project; $colval = array( "statuskey" => "closed", "donedated" => ":_NOW_:" ); $sql = "select * from ".AJTODO_DB_TODO."_".$this->project->id; $sql .= " where planid = ".$planid." and donedated is null;"; foreach($wpdb->get_results($sql) as $item){ $todo->id = $item->id; $todo->updateTodo("", "", json_encode($colval)); } } public function getPlanProgress2($plankey){ global $wpdb; $ret = array(); $sql = "SELECT statuskey, count(*) as cnt FROM ".AJTODO_DB_TODO."_".$this->project->id." where planid = ".$plankey; $sql .= " group by statuskey"; $statuslist = $wpdb->get_results($sql, ARRAY_A); $closed = 0; $open = 0; $ing = 0; $all = 0; foreach($statuslist as $status){ if($status['statuskey'] == "closed"){ $closed += $status['cnt']; }else if($status['statuskey'] == "open"){ $open += $status['cnt']; }else{ $ing += $status['cnt']; } $all += $status['cnt']; } $perc_o = 0; $perc_i = 0; if($all > 0){ $perc_o = round(($closed * 100) / $all); $perc_i = round(($ing * 100) / $all); } $ret = "
"; $ret .= "
project->id." where planid = ".$plankey; $sql .= " group by statuskey"; $statuslist = $wpdb->get_results($sql, ARRAY_A); $closed = 0; $all = 0; foreach($statuslist as $status){ if($status['statuskey'] == "closed"){ $closed += $status['cnt']; } $all += $status['cnt']; } $perc = 0; if($all > 0){ $perc = round(($closed * 100) / $all); } $ret = "
"; $ret .= "
project->id."' class='btn btn-info btn-sm float-right'>".__('플랜 추가', 'ajtodo' ).""; } $ret .= "
"; $ret .= ""; $ret .= ""; $ret .= " "; $ret .= " "; $ret .= " "; $ret .= " "; $ret .= " "; if($isdone){ $ret .= " "; $ret .= " "; }else{ $ret .= " "; $ret .= " "; $ret .= " "; } $ret .= " "; $ret .= " "; $ret .= ""; $ret .= ""; foreach($this->project->plan as $plan){ if($isdone){ if(!$plan["donedate"]) continue; }else{ if($plan["donedate"]) continue; } $ret .= ""; $ret .= " "; $ret .= " "; $ret .= " "; $ret .= " "; if($plan["donedate"]){ $ret .= " "; $ret .= " "; }else{ $ret .= " "; $ret .= " "; $ret .= " "; } $ret .= " "; $ret .= ""; } $ret .= ""; $ret .= "
".__("플랜 이름","ajtodo")."".__("총할일수","ajtodo")."".__("진행 상황","ajtodo")."".__("시작일","ajtodo")."".__("목표 완료일","ajtodo")."".__("완료일","ajtodo")."".__("남은 일수","ajtodo")."".__("목표 완료일","ajtodo")."".__("완료일","ajtodo")."".__("관리","ajtodo")."
".$plan["plantitle"]."".$this->getTodoCountByPlan($plan["id"])."".$this->getPlanProgress($plan["id"])."".substr($plan["startdate"],0, 10)."".substr($plan["finishdate"],0, 10)."".($plan["donedate"] ? substr($plan["donedate"],0, 10) : __("미완료","ajtodo"))."".substr($plan["finishdate"],0, 10)."".($plan["donedate"] ? substr($plan["donedate"],0, 10) : __("미완료","ajtodo")).""; $ret .= " "; $ret .= "
"; return $ret; } public function getSinglePlan($plankey){ foreach($this->project->plan as $s){ if($s["id"] == $plankey){ return $s; } } } public function addPlanView($plankey){ if($plankey){ $plan = $this->getSinglePlan($plankey); }else{ $plan["donedate"] = ""; } $url = "?page=ajtodo_admin_project&ptype=team&ajtodo_type=plan&pid=".$this->project->id; $ret = ""; $ret .= "
"; $ret .= ""; $ret .= ""; $ret .= ""; $ret .= wp_nonce_field('ajtodo_nonce','update_roleperm'); if(!$plan["donedate"]){ $ret .= "
"; $ret .= " "; $ret .= "
"; $ret .= ""; $ret .= "
"; $ret .= "
"; $ret .= "
"; $ret .= " "; $ret .= "
"; $ret .= " "; $ret .= "
"; $ret .= "
"; $ret .= "
"; $ret .= " "; $ret .= "
"; $ret .= ""; $ret .= "
"; $ret .= "
"; $ret .= "
"; $ret .= " "; $ret .= "
"; $ret .= ""; $ret .= "
"; $ret .= "
"; }else{ $ret .= "
"; $ret .= " "; $ret .= "
"; $ret .= "".$plan["plantitle"].""; $ret .= ""; $ret .= "
"; $ret .= "
"; $ret .= "
"; $ret .= " "; $ret .= "
"; $ret .= "
".nl2br($plan["plancomment"])."
"; $ret .= ""; $ret .= "
"; $ret .= "
"; $ret .= "
"; $ret .= " "; $ret .= "
"; $ret .= "".$plan["startdate"].""; $ret .= ""; $ret .= "
"; $ret .= "
"; $ret .= "
"; $ret .= " "; $ret .= "
"; $ret .= "".$plan["donedate"].""; $ret .= ""; $ret .= "
"; $ret .= "
"; $ret .= "
"; $ret .= " "; $ret .= "
"; $ret .= "".$plan["finishdate"].""; $ret .= ""; $ret .= "
"; $ret .= "
"; } if($plankey){ if(!$plan["donedate"]){ $ret .=""; $ret .="". ($plankey ? __('플랜 완료','ajtodo') : __('플랜 완료','ajtodo')).""; } $ret .="". ($plankey ? __('플랜 삭제','ajtodo') : __('플랜 삭제','ajtodo')).""; }else{ $ret .=""; } $ret .="".__('플랜 목록', 'ajtodo' ).""; $ret .= "
"; return $ret; } public function addPlan($dotype, $plankey, $plantitle, $plancomment, $startdate, $finishdate){ global $wpdb; $sql = ""; $ret = false; if($dotype == "add"){ $sql = "insert into ".AJTODO_DB_PLAN; $sql .= "(projectid, plantitle, plancomment, startdate, finishdate, regdate) values("; $sql .= $this->project->id.","; $sql .= "'".$plantitle."',"; $sql .= "'".$plancomment."',"; $sql .= "'".$startdate."',"; $sql .= "'".$finishdate."',"; $sql .= "'".date("Y-m-d H:i:s")."');"; $ret = !($wpdb->query($sql) === FALSE); if($ret){ $planid = $wpdb->insert_id; do_action('ajtodo_add_plan', $this->project->id, $planid); } }else{ $sql = "update ".AJTODO_DB_PLAN." set "; $sql .= "plantitle = '".$plantitle."', "; $sql .= "plancomment = '".$plancomment."', "; $sql .= "startdate = '".$startdate."',"; $sql .= "finishdate = '".$finishdate."' where id = ".$plankey; $ret = !($wpdb->query($sql) === FALSE); if($ret) do_action('ajtodo_modify_plan', $this->project->id, $plankey); } return $ret; } public function getMembers(){ $ret = array(); foreach($this->project->roles as $role){ $ret = array_unique(array_merge($ret, $role["users"])); } return $ret; } public function finishConfirmView($plankey){ $plan = $this->getSinglePlan($plankey); $ret = ""; $ret .= "
"; $ret .= ""; $ret .= wp_nonce_field('ajtodo_nonce','update_roleperm'); $ret .= "
".__("플랜 이름","ajtodo")." : ".$plan["plantitle"]."
".__("이 플랜을 완료제하시겠습니까?","ajtodo")."
  • ".__("총 할일 개수","ajtodo")." : ".$this->getTodoCountByPlan($plankey)."
".__("플랜에 존재하는 미 완료 할일들은 모두 '완료 처리' 됩니다.","ajtodo")."
".__("취소","ajtodo")."
"; $ret .= "
"; return $ret; } public function delConfirmView($plankey){ $plan = $this->getSinglePlan($plankey); $ret = ""; $ret .= "
"; $ret .= ""; $ret .= wp_nonce_field('ajtodo_nonce','update_roleperm'); $ret .= "
".__("플랜 이름","ajtodo")." : ".$plan["plantitle"]."
".__("이 플랜을 삭제하시겠습니까?","ajtodo")."
  • ".__("총 할일 개수","ajtodo")." : ".$this->getTodoCountByPlan($plankey)."
".__("플랜에 존재하는 할일들은 모두 '플랜 없음'이 됩니다.","ajtodo")."
".__("플랜에 포함된 할일이 삭제되는 것은 아닙니다.","ajtodo")."
".__("취소","ajtodo")."
"; $ret .= "
"; return $ret; } }