顧客様の表示

This commit is contained in:
2026-04-27 20:12:54 +09:00
parent ffa6cacd25
commit 9c753e5d09
6 changed files with 186 additions and 5 deletions

View File

@@ -63,7 +63,47 @@ class Op {
$tmpl->assign('data', $data->data);
$tmpl->addCss('table');
$tmpl->render('listcustomer');
$tmpl->render('listcustomers');
exit();
noaccess:
$tmpl->render('nopermission');
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
}
}
public function opGetCustomer(array $params): void {
try {
$handle = '';
if (isset($params['handle'])) $handle = $params['handle'];
if ($handle === '') {
header('Location: /openprovider/listcustomers');
exit();
}
$tmpl = new Template('/openprovider/');
$pagetit = "OpenProvider管理 - 顧客様「{$handle}」の表示";
$description = '';
// ユーザー
$auth = new Auth();
$user = $auth->getLoggedInUser();
$tmpl->assign('user', $user);
$tmpl->assign('pagetit', $pagetit);
$tmpl->assign('curPage', 'openprovider');
$tmpl->assign('custCss', true);
$tmpl->assign('menu', $this->getMenu());
$tmpl->assign('description', $description);
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
$op = new Openprovider();
$op->login();
$data = $op->getCustomer($handle, true);
$tmpl->assign('data', $data->data);
$tmpl->addCss('table');
$tmpl->render('getcustomer');
exit();
noaccess:

View File

@@ -199,7 +199,7 @@ class Openprovider {
//// 顧客様の追加データ
/**
* 顧客様の検索
* 顧客様の一覧
*
* @param array $query 検索クエリー
* @return Result
@@ -219,7 +219,34 @@ class Openprovider {
return \Result::Success('', $res->data);
}
return \Result::Error('TLD一覧の受け取りに失敗。');
return \Result::Error('顧客様一覧の受け取りに失敗。');
}
/**
* 顧客様の表示
*
* @param string $handle ハンドル
* @param bool $withAdditionalData 詳細データ含むか?
* @return Result
*/
public function getCustomer(string $handle, bool $withAdditionalData = false): \Result {
if (!OPENPROVIDER_ENABLED) return \Result::error('エラーOpenProviderは無効です。');
$cacheName = "getcustomer-{$handle}";
$cache = $this->getCache($cacheName);
if (!empty($cache) && (isset($cache['handle']) && $cache['handle'] === $handle)) return \Result::Success('', $cache);
$query = [ 'with_additional_data' => $withAdditionalData ? 'true' : 'false' ];
$uri = "/customers/{$handle}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
// kys($uri);
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$res->data['handle'] = $handle;
$this->setCache($cacheName, $res->data);
return \Result::Success('', $res->data);
}
return \Result::Error('顧客様の受け取りに失敗。');
}
//// ドメイン値段