/** * ゴールイメージ・マイルストーン(責任者)DB登録可否判定 * 登録可能の場合、trueを返す * * @param */ function isEntryEnabledUnit($sql_flg, $target_id, $target_year, $target_month) { $isEnabled = true; $sql = "SELECT COUNT(*) as cnt FROM `t_report_target_unit` WHERE `target_id` = :target_id AND `target_year` = :target_year AND `target_month` = :target_month"; $searchParam = array('target_id' => $target_id['id'], 'target_year' => $target_year, 'target_month' => $target_month); // データベースに接続する $conn = DbControl::getInstance(); $conn->dbConnect(DbControl::SLAVE_DB); // クエリを実行する $res = $conn->dbExecFetch(DbControl::SLAVE_DB, $sql, $searchParam); if (isset($sql_flg) && !empty($sql_flg) && $sql_flg == 'insert') { if (isset($res) && $res['cnt'] > 0) { $isEnabled = false; } else { $isEnabled = true; } } elseif (isset($sql_flg) && !empty($sql_flg) && $sql_flg == 'update') { if (isset($res) && $res['cnt'] > 0) { $tense = tenseMonthly($target_year, $target_month); if ($tense) { $isEnabled = true; } else { $isEnabled = false; } } else { $isEnabled = false; } } // データベースを切断する $conn->dbClose(DbControl::SLAVE_DB); return $isEnabled; }
/** * 到達レベル、注力ポイント取得 * * @param */ function getReportTargetUnit($year, $month, $id) { if (!isset($id) && empty($id)) { //新入社員がまだ月報を書いていない $res['emp_flg'] = true; return $res; } $sql = 'select id, admin_id, level, point from t_report_target_unit' . ' where target_year = :year and target_month = :month and target_id = :id'; $searchParam = array('year' => $year, 'month' => $month, 'id' => $id); // データベースに接続する $conn = DbControl::getInstance(); $conn->dbConnect(DbControl::SLAVE_DB); // クエリを実行する $res = $conn->dbExecFetchAll(DbControl::SLAVE_DB, $sql, $searchParam); if (count($res) > 0) { $admin_name = getStaffName($res[0]['admin_id']); $res['admin_name'] = $admin_name[0]['name']; $res['emp_flg'] = false; $res['tense'] = tenseMonthly($year, $month); } else { $res['emp_flg'] = true; } return $res; }