顧客様の表示
諏訪子 <suwako@076.moe>、2026-04-27 20:12
コミット 9c753e5d09cf13e5cc520bee1d4fb85d13783de1
・親 ffa6cac
・ファイルを見る
7個のファイル、+216 -35
変更
route.php
| @@ -60,7 +60,8 @@ | ||
| 60 | 60 | |
| 61 | 61 | if (OPENPROVIDER_ENABLED) { |
| 62 | 62 | $routes[] = Route::add('GET', 'openprovider', Op::class.'@index'); |
| 63 | - $routes[] = Route::add('GET', 'openprovider/listcustomer', Op::class.'@opListCustomers'); | |
| 63 | + $routes[] = Route::add('GET', 'openprovider/listcustomers', Op::class.'@opListCustomers'); | |
| 64 | + $routes[] = Route::add('GET', 'openprovider/getcustomer/{handle}', Op::class.'@opGetCustomer'); | |
| 64 | 65 | $routes[] = Route::add('GET', 'openprovider/listtlds', Op::class.'@opListTlds'); |
| 65 | 66 | $routes[] = Route::add('GET', 'openprovider/gettld/{tld}', Op::class.'@opGetTld'); |
| 66 | 67 | $routes[] = Route::add('GET', 'openprovider/checkdomain', Op::class.'@opCheckDomainAvailable'); |
| @@ -63,7 +63,47 @@ | ||
| 63 | 63 | $tmpl->assign('data', $data->data); |
| 64 | 64 | |
| 65 | 65 | $tmpl->addCss('table'); |
| 66 | - $tmpl->render('listcustomer'); | |
| 66 | + $tmpl->render('listcustomers'); | |
| 67 | + exit(); | |
| 68 | + | |
| 69 | + noaccess: | |
| 70 | + $tmpl->render('nopermission'); | |
| 71 | + } catch (\Exception $e) { | |
| 72 | + throw new \Exception($e->getMessage()); | |
| 73 | + } | |
| 74 | + } | |
| 75 | + | |
| 76 | + public function opGetCustomer(array $params): void { | |
| 77 | + try { | |
| 78 | + $handle = ''; | |
| 79 | + if (isset($params['handle'])) $handle = $params['handle']; | |
| 80 | + if ($handle === '') { | |
| 81 | + header('Location: /openprovider/listcustomers'); | |
| 82 | + exit(); | |
| 83 | + } | |
| 84 | + $tmpl = new Template('/openprovider/'); | |
| 85 | + $pagetit = "OpenProvider管理 - 顧客様「{$handle}」の表示"; | |
| 86 | + $description = ''; | |
| 87 | + | |
| 88 | + // ユーザー | |
| 89 | + $auth = new Auth(); | |
| 90 | + $user = $auth->getLoggedInUser(); | |
| 91 | + $tmpl->assign('user', $user); | |
| 92 | + | |
| 93 | + $tmpl->assign('pagetit', $pagetit); | |
| 94 | + $tmpl->assign('curPage', 'openprovider'); | |
| 95 | + $tmpl->assign('custCss', true); | |
| 96 | + $tmpl->assign('menu', $this->getMenu()); | |
| 97 | + $tmpl->assign('description', $description); | |
| 98 | + | |
| 99 | + if (!$user || $user->role !== \Roles::ADMIN) goto noaccess; | |
| 100 | + $op = new Openprovider(); | |
| 101 | + $op->login(); | |
| 102 | + $data = $op->getCustomer($handle, true); | |
| 103 | + $tmpl->assign('data', $data->data); | |
| 104 | + | |
| 105 | + $tmpl->addCss('table'); | |
| 106 | + $tmpl->render('getcustomer'); | |
| 67 | 107 | exit(); |
| 68 | 108 | |
| 69 | 109 | noaccess: |
| @@ -199,7 +199,7 @@ | ||
| 199 | 199 | //// 顧客様の追加データ |
| 200 | 200 | |
| 201 | 201 | /** |
| 202 | - * 顧客様の検索 | |
| 202 | + * 顧客様の一覧 | |
| 203 | 203 | * |
| 204 | 204 | * @param array $query 検索クエリー |
| 205 | 205 | * @return Result |
| @@ -219,7 +219,34 @@ | ||
| 219 | 219 | return \Result::Success('', $res->data); |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - return \Result::Error('TLD一覧の受け取りに失敗。'); | |
| 222 | + return \Result::Error('顧客様一覧の受け取りに失敗。'); | |
| 223 | + } | |
| 224 | + | |
| 225 | + /** | |
| 226 | + * 顧客様の表示 | |
| 227 | + * | |
| 228 | + * @param string $handle ハンドル | |
| 229 | + * @param bool $withAdditionalData 詳細データ含むか? | |
| 230 | + * @return Result | |
| 231 | + */ | |
| 232 | + public function getCustomer(string $handle, bool $withAdditionalData = false): \Result { | |
| 233 | + if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。'); | |
| 234 | + $cacheName = "getcustomer-{$handle}"; | |
| 235 | + $cache = $this->getCache($cacheName); | |
| 236 | + if (!empty($cache) && (isset($cache['handle']) && $cache['handle'] === $handle)) return \Result::Success('', $cache); | |
| 237 | + | |
| 238 | + $query = [ 'with_additional_data' => $withAdditionalData ? 'true' : 'false' ]; | |
| 239 | + $uri = "/customers/{$handle}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986); | |
| 240 | + // kys($uri); | |
| 241 | + $curl = $this->setupCurl($uri); | |
| 242 | + $res = $this->curlResult($curl); | |
| 243 | + if (isset($res->data['data'])) { | |
| 244 | + $res->data['handle'] = $handle; | |
| 245 | + $this->setCache($cacheName, $res->data); | |
| 246 | + return \Result::Success('', $res->data); | |
| 247 | + } | |
| 248 | + | |
| 249 | + return \Result::Error('顧客様の受け取りに失敗。'); | |
| 223 | 250 | } |
| 224 | 251 | |
| 225 | 252 | //// ドメイン値段 |
| @@ -0,0 +1,112 @@ | ||
| 1 | +{@ include(common/header) @} | |
| 2 | + 顧客様の削除<br /> | |
| 3 | + 顧客様のクローン<br /> | |
| 4 | + 顧客様の編集<br /> | |
| 5 | + <h2>連絡先:{{ $data['data']['name']['full_name'] }} ({{ $data['data']['handle'] }})</h2> | |
| 6 | + <table> | |
| 7 | + <tbody> | |
| 8 | + <tr> | |
| 9 | + <th>ID</th> | |
| 10 | + <td>{{ $data['data']['id'] }}</td> | |
| 11 | + </tr> | |
| 12 | + <tr> | |
| 13 | + <th>リセラーID</th> | |
| 14 | + <td>{{ $data['data']['reseller_id'] }}</td> | |
| 15 | + </tr> | |
| 16 | + <tr> | |
| 17 | + <th>ハンドル</th> | |
| 18 | + <td>{{ $data['data']['handle'] }}</td> | |
| 19 | + </tr> | |
| 20 | + <tr> | |
| 21 | + <th>イニシャル</th> | |
| 22 | + <td></td> | |
| 23 | + </tr> | |
| 24 | + <tr> | |
| 25 | + <th>フルネーム</th> | |
| 26 | + <td>{{ $data['data']['name']['last_name'].' '.$data['data']['name']['first_name'] }}</td> | |
| 27 | + </tr> | |
| 28 | + <tr> | |
| 29 | + <th>生まれた場所</th> | |
| 30 | + <td>〒{{ $data['data']['additional_data']['birth_zipcode'].' '.$data['data']['additional_data']['birth_city'].' '.$data['data']['additional_data']['birth_address'].' '.$data['data']['additional_data']['birth_country'] }}</td> | |
| 31 | + </tr> | |
| 32 | + <tr> | |
| 33 | + <th>生年月日</th> | |
| 34 | + <td>{{ $data['data']['additional_data']['birth_date'] }}</td> | |
| 35 | + </tr> | |
| 36 | + <tr> | |
| 37 | + <th>電話番号</th> | |
| 38 | + <td>{{ $data['data']['phone']['country_code'].$data['data']['phone']['area_code'].$data['data']['phone']['subscriber_number'] }}</td> | |
| 39 | + </tr> | |
| 40 | + <tr> | |
| 41 | + <th>FAX</th> | |
| 42 | + <td>{{ $data['data']['fax']['country_code'].$data['data']['fax']['area_code'].$data['data']['fax']['subscriber_number'] }}</td> | |
| 43 | + </tr> | |
| 44 | + <tr> | |
| 45 | + <th>メールアドレス</th> | |
| 46 | + <td>{{ $data['data']['email'] }}</td> | |
| 47 | + </tr> | |
| 48 | + </tbody> | |
| 49 | + </table> | |
| 50 | + <h2>会社情報</h2> | |
| 51 | + <table> | |
| 52 | + <tbody> | |
| 53 | + <tr> | |
| 54 | + <th>会社名</th> | |
| 55 | + <td>{{ $data['data']['company_name'] }}</td> | |
| 56 | + </tr> | |
| 57 | + <tr> | |
| 58 | + <th>VAT番号</th> | |
| 59 | + <td>{{ $data['data']['vat'] }}</td> | |
| 60 | + </tr> | |
| 61 | + <tr> | |
| 62 | + <th>会社登録番号</th> | |
| 63 | + <td>{{ $data['data']['additional_data']['company_registration_number'] }}</td> | |
| 64 | + </tr> | |
| 65 | + <tr> | |
| 66 | + <th>会社登録場所</th> | |
| 67 | + <td>{{ $data['data']['additional_data']['company_registration_city'] }}</td> | |
| 68 | + </tr> | |
| 69 | + <tr> | |
| 70 | + <th>会社登録日</th> | |
| 71 | + <td>{{ $data['data']['additional_data']['company_registration_subscription_date'] }}</td> | |
| 72 | + </tr> | |
| 73 | + <tr> | |
| 74 | + <th>会社URL</th> | |
| 75 | + <td>{{ $data['data']['additional_data']['company_url'] }}</td> | |
| 76 | + </tr> | |
| 77 | + </tbody> | |
| 78 | + </table> | |
| 79 | + <h2>住所情報</h2> | |
| 80 | + <table> | |
| 81 | + <tbody> | |
| 82 | + <tr> | |
| 83 | + <th>道+番号</th> | |
| 84 | + <td>{{ $data['data']['address']['street'].$data['data']['address']['number'].' '.$data['data']['address']['suffix'] }}</td> | |
| 85 | + </tr> | |
| 86 | + <tr> | |
| 87 | + <th>郵便番号</th> | |
| 88 | + <td>{{ $data['data']['address']['zipcode'] }}</td> | |
| 89 | + </tr> | |
| 90 | + <tr> | |
| 91 | + <th>市区町村</th> | |
| 92 | + <td>{{ $data['data']['address']['city'] }}</td> | |
| 93 | + </tr> | |
| 94 | + <tr> | |
| 95 | + <th>都道府県</th> | |
| 96 | + <td>{{ $data['data']['address']['state'] }}</td> | |
| 97 | + </tr> | |
| 98 | + <tr> | |
| 99 | + <th>国</th> | |
| 100 | + <td>{{ $data['data']['address']['country'] }}</td> | |
| 101 | + </tr> | |
| 102 | + <tr> | |
| 103 | + <th>言語</th> | |
| 104 | + <td>{{ $data['data']['locale'] }}</td> | |
| 105 | + </tr> | |
| 106 | + <tr> | |
| 107 | + <th>本社の場所</th> | |
| 108 | + <td>〒{{ $data['data']['additional_data']['headquarters_zipcode'].' '.$data['data']['additional_data']['headquarters_city'].' '.$data['data']['additional_data']['headquarters_address'].' '.$data['data']['additional_data']['headquarters_country'] }}</td> | |
| 109 | + </tr> | |
| 110 | + </tbody> | |
| 111 | + </table> | |
| 112 | +{@ include(common/footer) @} |
| @@ -3,7 +3,7 @@ | ||
| 3 | 3 | <ul> |
| 4 | 4 | <li>顧客様</li> |
| 5 | 5 | <ul> |
| 6 | - <li><a href="/openprovider/listcustomer">顧客様検索</a></li> | |
| 6 | + <li><a href="/openprovider/listcustomers">顧客様検索</a></li> | |
| 7 | 7 | </ul> |
| 8 | 8 | <li>ドメイン</li> |
| 9 | 9 | <ul> |
削除
view/openprovider/listcustomer.maron
| @@ -1,30 +0,0 @@ | ||
| 1 | -{@ include(common/header) @} | |
| 2 | - 検索<br /> | |
| 3 | -{@ if (isset($data['data']['results'])) @} | |
| 4 | - <table> | |
| 5 | - <thead> | |
| 6 | - <tr> | |
| 7 | - <th>名前</th> | |
| 8 | - <th>会社名</th> | |
| 9 | - <th>メールアドレス</th> | |
| 10 | - <th>ハンドル</th> | |
| 11 | - <th>メモ</th> | |
| 12 | - </tr> | |
| 13 | - </thead> | |
| 14 | - <tbody> | |
| 15 | -{@ foreach ($data['data']['results'] as $d) @} | |
| 16 | - <tr> | |
| 17 | - <td><a href="/openprovider/getcustomer/{{ $d['handle'] }}">{{ $d['name']['full_name'] }}</a></td> | |
| 18 | - <td>{{ $d['company_name'] }}</td> | |
| 19 | - <td>{{ $d['email'] }}</td> | |
| 20 | - <td>{{ $d['handle'] }}</td> | |
| 21 | - <td></td> | |
| 22 | - </tr> | |
| 23 | -{@ endforeach @} | |
| 24 | - </tbody> | |
| 25 | - </table> | |
| 26 | - <p>結果数:{{ $data['data']['total'] }}</p> | |
| 27 | -{@ else @} | |
| 28 | - <p>何も見つけられませんでした。</p> | |
| 29 | -{@ endif @} | |
| 30 | -{@ include(common/footer) @} |
| @@ -0,0 +1,31 @@ | ||
| 1 | +{@ include(common/header) @} | |
| 2 | + 顧客様の追加<br /> | |
| 3 | + 検索<br /> | |
| 4 | +{@ if (isset($data['data']['results'])) @} | |
| 5 | + <table> | |
| 6 | + <thead> | |
| 7 | + <tr> | |
| 8 | + <th>名前</th> | |
| 9 | + <th>会社名</th> | |
| 10 | + <th>メールアドレス</th> | |
| 11 | + <th>ハンドル</th> | |
| 12 | + <th>メモ</th> | |
| 13 | + </tr> | |
| 14 | + </thead> | |
| 15 | + <tbody> | |
| 16 | +{@ foreach ($data['data']['results'] as $d) @} | |
| 17 | + <tr> | |
| 18 | + <td><a href="/openprovider/getcustomer/{{ $d['handle'] }}">{{ $d['name']['full_name'] }}</a></td> | |
| 19 | + <td>{{ $d['company_name'] }}</td> | |
| 20 | + <td>{{ $d['email'] }}</td> | |
| 21 | + <td>{{ $d['handle'] }}</td> | |
| 22 | + <td></td> | |
| 23 | + </tr> | |
| 24 | +{@ endforeach @} | |
| 25 | + </tbody> | |
| 26 | + </table> | |
| 27 | + <p>結果数:{{ $data['data']['total'] }}</p> | |
| 28 | +{@ else @} | |
| 29 | + <p>何も見つけられませんでした。</p> | |
| 30 | +{@ endif @} | |
| 31 | +{@ include(common/footer) @} |