Commit 1abdd6e1ae00ac3ca3239c5ceaf31f63aff2cd35
1 parent
1ad92487
search phone
Showing
3 changed files
with
27 additions
and
4 deletions
Show diff stats
src/app/backend/controllers/CustomersController.php
... | ... | @@ -16,9 +16,14 @@ class CustomersController extends \Phalcon\Mvc\Controller |
16 | 16 | $params = $this->dispatcher->getParams(); |
17 | 17 | $page = !empty( $params['page'] ) ? $params['page'] : 1; |
18 | 18 | |
19 | - $search = $this->request->getPost('search', 'string', NULL); | |
20 | - if (!empty($search)) { | |
21 | - $data = $this->models->getCustomers()->getDataByName($search); | |
19 | + $search_name = $this->request->getPost('search_name', 'string', NULL); | |
20 | + $search_phone = $this->request->getPost('search_phone', 'int', NULL); | |
21 | + if (!empty($search_name)) { | |
22 | + $data = $this->models->getCustomers()->getDataByName($search_name); | |
23 | + $total = 1; | |
24 | + } | |
25 | + elseif(!empty($search_phone)) { | |
26 | + $data = $this->models->getCustomers()->getDataByPhone($search_phone); | |
22 | 27 | $total = 1; |
23 | 28 | } |
24 | 29 | else { | ... | ... |
src/app/backend/views/customers/index.php
... | ... | @@ -13,7 +13,8 @@ |
13 | 13 | <div class="table_name header_gradient">Пользователи</div> |
14 | 14 | <div class="table_add_page"><a href="<?= $this->url->get([ 'for' => 'customers_add' ]) ?>" title="Добавить">Добавить</a></div> |
15 | 15 | <form method="post" action="" style="margin:10px;"> |
16 | - <input type="text" required name="search" placeholder="поиск по имени" /> | |
16 | + <input type="text" required name="search_name" placeholder="поиск по имени" /> | |
17 | + <input type="text" required name="search_phone" placeholder="поиск по телефону" /> | |
17 | 18 | </form> |
18 | 19 | <div class="table_pages_wrapper"> |
19 | 20 | ... | ... |
src/lib/models/customers.php
... | ... | @@ -1306,6 +1306,23 @@ class customers extends \db |
1306 | 1306 | |
1307 | 1307 | } |
1308 | 1308 | |
1309 | + public function getDataByPhone($like) { | |
1310 | + | |
1311 | + return $this->get( | |
1312 | + ' | |
1313 | + SELECT * FROM | |
1314 | + public.customers | |
1315 | + WHERE | |
1316 | + phone LIKE \'%'.$like.'%\' | |
1317 | + ' | |
1318 | + , | |
1319 | + [ | |
1320 | + ], | |
1321 | + -1 | |
1322 | + ); | |
1323 | + | |
1324 | + } | |
1325 | + | |
1309 | 1326 | } |
1310 | 1327 | |
1311 | 1328 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
1312 | 1329 | \ No newline at end of file | ... | ... |