업체·담당자·단가·지정판매소 관리 화면의 조회 및 표시를 개선한다.
관리 화면에서 유형별 조회와 순번 표기를 통일하고, 지정판매소 주소/구군 표시와 포장단위 이력 표현을 사용자 관점으로 정리한다. Made-with: Cursor
This commit is contained in:
@@ -27,14 +27,143 @@ class BagPrice extends BaseController
|
||||
return redirect()->to(work_area_home_url())->with('error', '지자체를 선택해 주세요.');
|
||||
}
|
||||
|
||||
$list = $this->priceModel->where('bp_lg_idx', $lgIdx)
|
||||
$get = $this->request->getGet();
|
||||
$readSrc = static function (array $src, string $key): ?string {
|
||||
if (! array_key_exists($key, $src)) {
|
||||
return null;
|
||||
}
|
||||
$v = $src[$key];
|
||||
if ($v === null || is_array($v)) {
|
||||
return null;
|
||||
}
|
||||
$s = trim((string) $v);
|
||||
|
||||
return $s === '' ? null : $s;
|
||||
};
|
||||
|
||||
$sy = $readSrc($get, 'start_y');
|
||||
$sm = $readSrc($get, 'start_m');
|
||||
$sd = $readSrc($get, 'start_d');
|
||||
$ey = $readSrc($get, 'end_y');
|
||||
$em = $readSrc($get, 'end_m');
|
||||
$ed = $readSrc($get, 'end_d');
|
||||
|
||||
$startDate = null;
|
||||
if ($sy !== null && $sy !== '' && $sm !== null && $sm !== '' && $sd !== null && $sd !== '') {
|
||||
$startDate = parse_ymd_from_triple($sy, $sm, $sd);
|
||||
}
|
||||
if ($startDate === null) {
|
||||
$legacyStart = $readSrc($get, 'start_date');
|
||||
$startDate = ($legacyStart !== null && $legacyStart !== '') ? $legacyStart : null;
|
||||
}
|
||||
|
||||
$endDate = null;
|
||||
if ($ey !== null && $ey !== '' && $em !== null && $em !== '' && $ed !== null && $ed !== '') {
|
||||
$endDate = parse_ymd_from_triple($ey, $em, $ed);
|
||||
}
|
||||
if ($endDate === null) {
|
||||
$legacyEnd = $readSrc($get, 'end_date');
|
||||
$endDate = ($legacyEnd !== null && $legacyEnd !== '') ? $legacyEnd : null;
|
||||
}
|
||||
|
||||
$startParts = ['y' => '', 'm' => '', 'd' => ''];
|
||||
$endParts = ['y' => '', 'm' => '', 'd' => ''];
|
||||
if ($startDate !== null && preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $startDate, $m)) {
|
||||
$startParts = ['y' => $m[1], 'm' => (int) $m[2], 'd' => (int) $m[3]];
|
||||
}
|
||||
if ($endDate !== null && preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $endDate, $m)) {
|
||||
$endParts = ['y' => $m[1], 'm' => (int) $m[2], 'd' => (int) $m[3]];
|
||||
}
|
||||
|
||||
$bagKindE = $readSrc($get, 'bag_kind_e');
|
||||
$bagCode = $readSrc($get, 'bag_code');
|
||||
|
||||
$builder = $this->priceModel->where('bp_lg_idx', $lgIdx);
|
||||
if (($startDate !== null && $startDate !== '') || ($endDate !== null && $endDate !== '')) {
|
||||
$qStart = ($startDate !== null && $startDate !== '') ? $startDate : $endDate;
|
||||
$qEnd = ($endDate !== null && $endDate !== '') ? $endDate : $startDate;
|
||||
if (strcmp((string) $qStart, (string) $qEnd) > 0) {
|
||||
[$qStart, $qEnd] = [$qEnd, $qStart];
|
||||
}
|
||||
$builder->where('bp_start_date <=', $qEnd);
|
||||
$builder->groupStart()
|
||||
->where('bp_end_date IS NULL')
|
||||
->orWhere('bp_end_date >=', $qStart)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
if ($bagKindE !== null && $bagKindE !== '') {
|
||||
$kindE = model(CodeKindModel::class)->where('ck_code', 'E')->first();
|
||||
if ($kindE) {
|
||||
$detailE = model(CodeDetailModel::class)
|
||||
->where('cd_ck_idx', (int) $kindE->ck_idx)
|
||||
->where('cd_code', $bagKindE)
|
||||
->where('cd_state', 1)
|
||||
->first();
|
||||
if ($detailE !== null) {
|
||||
$builder->like('bp_bag_code', $bagKindE, 'after');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($bagCode !== null && $bagCode !== '') {
|
||||
$kindO = model(CodeKindModel::class)->where('ck_code', 'O')->first();
|
||||
if ($kindO) {
|
||||
$detailO = model(CodeDetailModel::class)->findResolvedByKindAndCode((int) $kindO->ck_idx, $bagCode, $lgIdx);
|
||||
if ($detailO !== null) {
|
||||
$builder->where('bp_bag_code', $bagCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$list = $builder
|
||||
->orderBy('bp_bag_code', 'ASC')
|
||||
->orderBy('bp_start_date', 'DESC')
|
||||
->paginate(20);
|
||||
|
||||
$queryForPager = [];
|
||||
if ($sy !== null && $sm !== null && $sd !== null && $sy !== '' && $sm !== '' && $sd !== '') {
|
||||
$queryForPager['start_y'] = $sy;
|
||||
$queryForPager['start_m'] = $sm;
|
||||
$queryForPager['start_d'] = $sd;
|
||||
}
|
||||
if ($ey !== null && $em !== null && $ed !== null && $ey !== '' && $em !== '' && $ed !== '') {
|
||||
$queryForPager['end_y'] = $ey;
|
||||
$queryForPager['end_m'] = $em;
|
||||
$queryForPager['end_d'] = $ed;
|
||||
}
|
||||
if ($bagKindE !== null && $bagKindE !== '') {
|
||||
$queryForPager['bag_kind_e'] = $bagKindE;
|
||||
}
|
||||
if ($bagCode !== null && $bagCode !== '') {
|
||||
$queryForPager['bag_code'] = $bagCode;
|
||||
}
|
||||
$pagerPath = mgmt_url('bag-prices');
|
||||
if ($queryForPager !== []) {
|
||||
$pagerPath .= '?' . http_build_query($queryForPager);
|
||||
}
|
||||
$this->priceModel->pager->setPath($pagerPath);
|
||||
|
||||
$kindO = model(CodeKindModel::class)->where('ck_code', 'O')->first();
|
||||
$bagCodes = $kindO
|
||||
? model(CodeDetailModel::class)->getByKind((int) $kindO->ck_idx, true, $lgIdx)
|
||||
: [];
|
||||
$kindE = model(CodeKindModel::class)->where('ck_code', 'E')->first();
|
||||
$bagKindOptions = $kindE
|
||||
? model(CodeDetailModel::class)->getByKind((int) $kindE->ck_idx, true, null)
|
||||
: [];
|
||||
|
||||
return $this->renderWorkPage('봉투 단가 관리', 'admin/bag_price/index', [
|
||||
'list' => $list,
|
||||
'list' => $list,
|
||||
'pager' => $this->priceModel->pager,
|
||||
'startParts' => $startParts,
|
||||
'endParts' => $endParts,
|
||||
'dateYearMin' => (int) date('Y') - 12,
|
||||
'dateYearMax' => (int) date('Y') + 2,
|
||||
'bag_kind_e' => $bagKindE,
|
||||
'bag_code' => $bagCode,
|
||||
'bag_codes' => $bagCodes,
|
||||
'bag_kind_options' => $bagKindOptions,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user