顧客様の作成・削除

This commit is contained in:
2026-04-29 20:03:41 +09:00
parent 7b8fdcafb3
commit 1588201998
8 changed files with 466 additions and 319 deletions

View File

@@ -40,8 +40,8 @@ namespace Site\Controller;
use Site\Controller\Mods;
use Std\Lib\Auth;
use Std\Lib\Template;
use Std\Lib\Openprovider;
use Roles;
class Op {
use Mods;
@@ -63,7 +63,7 @@ class Op {
$tmpl->assign('menu', $this->getMenu());
$tmpl->assign('description', $description);
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
if (!$user || $user->role !== Roles::ADMIN) goto noaccess;
$tmpl->addCss('table');
$tmpl->render('index');
exit();
@@ -92,7 +92,7 @@ class Op {
$tmpl->assign('menu', $this->getMenu());
$tmpl->assign('description', $description);
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
if (!$user || $user->role !== Roles::ADMIN) goto noaccess;
$op = new Openprovider();
$op->login();
$data = $op->listCustomers();
@@ -111,39 +111,44 @@ class Op {
public function opCreateCustomer(array $params): void {
try {
kys('sasa');
if (isset($_POST)) kys($_POST);
$payload = [
'additional_data' => [
'company_registration_number' => '',
'company_url' => '',
'company_registration_number' => $_POST['company_registration_number'] ?? '',
'company_url' => $_POST['company_url'] ?? '',
'birth_date' => $_POST['birth_year'] !== '' && $_POST['birth_month'] !== '' && $_POST['birth_day'] !== '' ? $_POST['birth_year'].'-'.$_POST['birth_month'].'-'.$_POST['birth_day'] : '',
'trading_name' => $_POST['company_name'] ?? '',
],
'address' => [
'city' => '',
'country' => '',
'number' => '',
'state' => '',
'street' => '',
'zipcode' => '',
'city' => $_POST['address_city'] ?? '',
'country' => $_POST['address_country'] ?? 'JP',
'number' => $_POST['address_number'] ?? '',
'state' => $_POST['address_state'] ?? '',
'street' => $_POST['address_street'] ?? '',
'zipcode' => $_POST['address_zipcode'] ?? '',
],
'comments' => '',
'company_name' => '',
'email' => '',
'birth' => [
'year' => $_POST['birth_year'] ?? '',
'month' => $_POST['birth_month'] ?? '',
'day' => $_POST['birth_day'] ?? '',
],
'comments' => $_POST['comments'] ?? '',
'company_name' => $_POST['company_name'] ?? '',
'email' => $_POST['email'] ?? '',
'fax' => [
'area_code' => '',
'country_code' => '',
'subscriber_number' => '',
'area_code' => $_POST['fax_area_code'] ?? '',
'country_code' => $_POST['fax_country_code'] ?? '',
'subscriber_number' => $_POST['fax_subscriber_number'] ?? '',
],
'locale' => 'ja_JP',
'name' => [
'first_name' => '',
'full_name' => '',
'last_name' => '',
'first_name' => $_POST['first_name'] ?? '',
'full_name' => $_POST['first_name'] !== '' && $_POST['last_name'] !== '' ? $_POST['first_name'].' '.$_POST['last_name'] : '',
'last_name' => $_POST['last_name'] ?? '',
],
'phone' => [
'area_code' => '',
'country_code' => '',
'subscriber_number' => '',
'area_code' => $_POST['phone_area_code'] ?? '',
'country_code' => $_POST['phone_country_code'] ?? '',
'subscriber_number' => $_POST['phone_subscriber_number'] ?? '',
],
];
$tmpl = new Template('/openprovider/');
@@ -161,19 +166,43 @@ class Op {
$tmpl->assign('menu', $this->getMenu());
$tmpl->assign('description', $description);
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
if (isset($_POST)) {
$err = [];
if (!$user || $user->role !== Roles::ADMIN) goto noaccess;
if (!empty($_POST)) {
if (NULL === $_POST['last_name'] || $_POST['last_name'] === ''
|| NULL === $_POST['first_name'] || $_POST['first_name'] === '') $err[] = '姓名をご入力下さい。';
if (NULL === $_POST['phone_country_code'] || $_POST['phone_country_code'] === ''
|| NULL === $_POST['phone_area_code'] || $_POST['phone_area_code'] === ''
|| NULL === $_POST['phone_subscriber_number'] || $_POST['phone_subscriber_number'] === '') $err[] = '電話番号をご入力下さい。';
if (NULL === $_POST['email'] || $_POST['email'] === '') $err[] = 'メールアドレスをご入力下さい。';
if (NULL === $_POST['address_zipcode'] || $_POST['address_zipcode'] === '') $err[] = '郵便番号をご入力下さい。';
if (NULL === $_POST['address_state'] || $_POST['address_state'] === '') $err[] = '都道府県をご入力下さい。';
if (NULL === $_POST['address_city'] || $_POST['address_city'] === '') $err[] = '市区町村をご入力下さい。';
if (NULL === $_POST['address_street'] || $_POST['address_street'] === '') $err[] = '町名をご入力下さい。';
if (NULL === $_POST['address_number'] || $_POST['address_number'] === '') $err[] = '番地をご入力下さい。';
if (!empty($err)) goto render;
if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) $err[] = 'メールアドレスは不正です。';
if (!str_starts_with($_POST['phone_country_code'], '+')) $err[] = '電話番号の国コードは「+」ご始まり下さい。';
if ($_POST['fax_country_code'] !== '' && !str_starts_with($_POST['fax_country_code'], '+')) $err[] = 'FAXの国コードは「+」ご始まり下さい。';
if ((!filter_var($_POST['phone_area_code'], FILTER_VALIDATE_INT)) || (!filter_var($_POST['phone_subscriber_number'], FILTER_VALIDATE_INT))) $err[] = '電話番号は数字をご入力下さい。';
if (($_POST['fax_area_code'] !== '' || $_POST['fax_subscriber_number'] !== '') && (!filter_var($_POST['fax_area_code'], FILTER_VALIDATE_INT) || !filter_var($_POST['fax_subscriber_number'], FILTER_VALIDATE_INT))) $err[] = 'FAXは数字をご入力下さい。';
if (!empty($err)) goto render;
$op = new Openprovider();
$op->login();
$data = $op->createCustomer($_POST, true);
kys($data->data);
header("Location: /openprovider/getcustomer/{$data->data['handle']}");
$data = $op->createCustomer($payload, true);
header("Location: /openprovider/getcustomer/{$data->data['data']['handle']}");
exit();
}
render:
$tmpl->assign('err', $err);
$tmpl->assign('data', $payload);
$tmpl->addCss('openprovider');
$tmpl->render('createcustomer');
kys('sasa');
exit();
@@ -207,13 +236,14 @@ class Op {
$tmpl->assign('menu', $this->getMenu());
$tmpl->assign('description', $description);
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
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->addCss('openprovider');
$tmpl->render('getcustomer');
exit();
@@ -224,6 +254,58 @@ class Op {
}
}
public function opDeleteCustomer(array $params): void {
try {
$handle = '';
if (isset($params['handle'])) $handle = $params['handle'];
if ($handle === '') {
header('Location: /openprovider/listcustomers');
exit();
}
assert_not_null($handle);
$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;
if (empty($_POST)) goto render_confirm;
if (isset($_POST['delete_reject'])) {
header("Location: /openprovider/getcustomer/{$handle}");
exit();
} else if (isset($_POST['delete_confirm'])) {
$op = new Openprovider();
$op->login();
$op->deleteCustomer($handle);
}
header('Location: /openprovider/listcustomers');
exit();
render_confirm:
$tmpl->assign('handle', $handle);
$tmpl->addCss('openprovider');
$tmpl->render('deletecustomer');
exit();
noaccess:
$tmpl->render('nopermission');
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
}
}
public function opListTlds(array $params): void {
try {
$tmpl = new Template('/openprovider/');
@@ -241,7 +323,7 @@ class Op {
$tmpl->assign('menu', $this->getMenu());
$tmpl->assign('description', $description);
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
if (!$user || $user->role !== Roles::ADMIN) goto noaccess;
$op = new Openprovider();
$op->login();
$data = $op->listTlds();
@@ -281,7 +363,7 @@ class Op {
$tmpl->assign('menu', $this->getMenu());
$tmpl->assign('description', $description);
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
if (!$user || $user->role !== Roles::ADMIN) goto noaccess;
$op = new Openprovider();
$op->login();
$data = $op->getTld($tld);
@@ -315,7 +397,7 @@ class Op {
$tmpl->assign('menu', $this->getMenu());
$tmpl->assign('description', $description);
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
if (!$user || $user->role !== Roles::ADMIN) goto noaccess;
$op = new Openprovider();
$op->login();
$data = $op->listDomains($domains, true);
@@ -355,7 +437,7 @@ class Op {
$tmpl->assign('menu', $this->getMenu());
$tmpl->assign('description', $description);
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
if (!$user || $user->role !== Roles::ADMIN) goto noaccess;
$op = new Openprovider();
$op->login();
if (!empty($domains)) {
@@ -398,7 +480,7 @@ class Op {
$tmpl->assign('menu', $this->getMenu());
$tmpl->assign('description', $description);
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
if (!$user || $user->role !== Roles::ADMIN) goto noaccess;
$op = new Openprovider();
$op->login();
$data = $op->getDomainPrices(['domain.name' => $domainname, 'domain.extension' => $domainext]);
@@ -432,14 +514,14 @@ class Op {
$tmpl->assign('menu', $this->getMenu());
$tmpl->assign('description', $description);
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
if (!$user || $user->role !== Roles::ADMIN) goto noaccess;
$op = new Openprovider();
$op->login();
$data = $op->listDnsZones();
$tmpl->assign('data', $data->data);
$tmpl->addCss('table');
if ($user && $user->role & (\Roles::ADMIN)) $tmpl->render('listdnszones');
if ($user && $user->role & (Roles::ADMIN)) $tmpl->render('listdnszones');
else goto noaccess;
exit();
@@ -473,7 +555,7 @@ class Op {
$tmpl->assign('menu', $this->getMenu());
$tmpl->assign('description', $description);
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
if (!$user || $user->role !== Roles::ADMIN) goto noaccess;
$op = new Openprovider();
$op->login();
$data = ['rec' => $op->listZoneRecords($domain), 'zone' => $op->getDnsZone($domain)];

File diff suppressed because it is too large Load Diff