Commit cdff229ae7641ef4e8c41930a1eaf25e82b3c766
1 parent
4fd9f4d2
customers search multiple usage
Showing
2 changed files
with
25 additions
and
1 deletions
Show diff stats
src/app/backend/controllers/CustomersController.php
| ... | ... | @@ -20,7 +20,11 @@ class CustomersController extends \Phalcon\Mvc\Controller |
| 20 | 20 | $search_phone = $this->request->getPost('search_phone', 'int', NULL); |
| 21 | 21 | $this->session->set('search_name', $search_name); |
| 22 | 22 | $this->session->set('search_phone', $search_phone); |
| 23 | - if (!empty($search_name)) { | |
| 23 | + if (!empty($search_name) && !empty($search_phone)) { | |
| 24 | + $data = $this->models->getCustomers()->getDataByNameAndPhone($search_name, $search_phone); | |
| 25 | + $total = 1; | |
| 26 | + } | |
| 27 | + elseif (!empty($search_name)) { | |
| 24 | 28 | $data = $this->models->getCustomers()->getDataByName($search_name); |
| 25 | 29 | $total = 1; |
| 26 | 30 | } | ... | ... |
src/lib/models/customers.php
| ... | ... | @@ -1323,6 +1323,26 @@ class customers extends \db |
| 1323 | 1323 | |
| 1324 | 1324 | } |
| 1325 | 1325 | |
| 1326 | + public function getDataByNameAndPhone($name, $phone) { | |
| 1327 | + | |
| 1328 | + return $this->get( | |
| 1329 | + ' | |
| 1330 | + SELECT * FROM | |
| 1331 | + public.customers | |
| 1332 | + WHERE | |
| 1333 | + phone LIKE \'%'.$phone.'%\' | |
| 1334 | + AND | |
| 1335 | + name LIKE \'%'.$name.'%\' | |
| 1336 | + | |
| 1337 | + ' | |
| 1338 | + , | |
| 1339 | + [ | |
| 1340 | + ], | |
| 1341 | + -1 | |
| 1342 | + ); | |
| 1343 | + | |
| 1344 | + } | |
| 1345 | + | |
| 1326 | 1346 | } |
| 1327 | 1347 | |
| 1328 | 1348 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1329 | 1349 | \ No newline at end of file | ... | ... |