78 lines
2.8 KiB
PHP
78 lines
2.8 KiB
PHP
<?php
|
|
require_once __DIR__ . '/db_conn.php';
|
|
require_once __DIR__ . '/api_log.php';
|
|
|
|
// 외부(호출하는 파일)에서 $SET_PREFIX를 정의하지 않았을 경우를 대비한 기본값 설정
|
|
$prefixCondition = isset($SET_PREFIX) ? $SET_PREFIX : 'L'; //L=리더십(기본값), I=인사이트
|
|
|
|
// $memberId = 'U001';
|
|
// $sysCompCode = 'COMP01';
|
|
|
|
//Svg
|
|
if($prefixCondition=='L'){
|
|
$prefixSvg = "leadership";
|
|
}else if($prefixCondition=='I'){
|
|
$prefixSvg = "insight";
|
|
}
|
|
|
|
//배너설정
|
|
if($prefixCondition=='L'){//L=리더십(기본값), I=인사이트
|
|
$array_banner_img = [
|
|
['normal' => '/img/leadership/img_banner_01.png', 'mobile' => '/img/leadership/img_banner_01_m.png', 'title' => '실천으로 완성하는 리더십'],
|
|
['normal' => '/img/leadership/img_banner_02.png', 'mobile' => '/img/leadership/img_banner_02_m.png', 'title' => '성장하는 리더십 여정'],
|
|
['normal' => '/img/leadership/img_banner_03.png', 'mobile' => '/img/leadership/img_banner_03_m.png', 'title' => '리더로 성장하는 과정'],
|
|
];
|
|
}else if($prefixCondition=='I'){//L=리더십(기본값), I=인사이트
|
|
$array_banner_img = [
|
|
['normal' => '/img/insight/img_banner_01.png', 'mobile' => '/img/insight/img_banner_01_m.png', 'title' => '배너 1'],
|
|
['normal' => '/img/insight/img_banner_02.png', 'mobile' => '/img/insight/img_banner_02_m.png', 'title' => '배너 2'],
|
|
];
|
|
}
|
|
|
|
|
|
$dbSuccess = false;
|
|
$array_tab_info = [];
|
|
|
|
try {
|
|
$pdo = db_conn();
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$pdo->exec("SET NAMES 'utf8mb4'");
|
|
|
|
// LIKE 연산자를 안전하게 처리하기 위해 준비된 선언(Prepared Statement) 사용
|
|
$stmtCode = $pdo->prepare("
|
|
SELECT group_code, base_code, code, code_name
|
|
FROM edu_codes
|
|
WHERE is_active = 1
|
|
AND group_code = 'CA200'
|
|
AND code LIKE :prefix
|
|
ORDER BY base_code ASC
|
|
");
|
|
|
|
// 'L%' 형태로 바인딩하여 검색
|
|
$stmtCode->execute([':prefix' => $prefixCondition . '%']);
|
|
$rows = $stmtCode->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if ($rows) {
|
|
$i = 1;
|
|
foreach ($rows as $cr) {
|
|
$index = sprintf('%02d', $i);
|
|
$index_src = '/img/ico/ico_'.$prefixSvg.'_' . $index . '.svg';
|
|
|
|
$array_tab_info[] = [
|
|
'base_code' => $cr['base_code'],
|
|
'code_name' => $cr['code_name'],
|
|
'src' => $index_src
|
|
];
|
|
$i++;
|
|
}
|
|
}
|
|
|
|
$dbSuccess = true;
|
|
} catch (Exception $e) {
|
|
$errMsg = $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine();
|
|
error_log('[leadership_init_data.php] DB Error: ' . $errMsg);
|
|
// api_log 함수가 있다면 기록
|
|
if (function_exists('api_log')) {
|
|
api_log('leadership_init', 'DB_ERROR', ['error' => $errMsg]);
|
|
}
|
|
} |