fix search

This commit is contained in:
Ibnu Maksum 2023-06-15 16:46:36 +07:00
parent dfbd7df367
commit a660ec5ddb
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
12 changed files with 95 additions and 72 deletions

View File

@ -23,16 +23,26 @@ if ($admin['user_type'] != 'Admin' and $admin['user_type'] != 'Sales') {
switch ($action) { switch ($action) {
case 'list': case 'list':
$ui->assign('xfooter', '<script type="text/javascript" src="ui/lib/c/customers.js"></script>'); $ui->assign('xfooter', '<script type="text/javascript" src="ui/lib/c/customers.js"></script>');
$username = _post('username'); $search = _post('search');
$what = _post('what');
if(!in_array($what,['username','fullname','phonenumber','email'])){
$what = 'username';
}
run_hook('list_customers'); #HOOK run_hook('list_customers'); #HOOK
if ($username != '') { if ($search != '') {
$paginator = Paginator::bootstrap('tbl_customers', 'username', '%' . $username . '%'); $paginator = Paginator::bootstrap('tbl_customers', 'username', '%' . $search . '%');
$d = ORM::for_table('tbl_customers')->where_like('username', '%' . $username . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many(); $d = ORM::for_table('tbl_customers')
->where_like($what, '%' . $search . '%')
->offset($paginator['startpoint'])
->limit($paginator['limit'])
->order_by_desc('id')->find_many();
} else { } else {
$paginator = Paginator::bootstrap('tbl_customers'); $paginator = Paginator::bootstrap('tbl_customers');
$d = ORM::for_table('tbl_customers')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many(); $d = ORM::for_table('tbl_customers')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
} }
$ui->assign('search', htmlspecialchars($search));
$ui->assign('what', $what);
$ui->assign('d', $d); $ui->assign('d', $d);
$ui->assign('paginator', $paginator); $ui->assign('paginator', $paginator);
$ui->display('customers.tpl'); $ui->display('customers.tpl');

View File

@ -29,7 +29,7 @@ switch ($action) {
$ui->display('user-orderHistory.tpl'); $ui->display('user-orderHistory.tpl');
break; break;
case 'package': case 'package':
if(empty($user['email'])){ if (strpos($user['email'], '@') === false) {
r2(U . 'accounts/profile', 'e', Lang::T("Please enter your email address")); r2(U . 'accounts/profile', 'e', Lang::T("Please enter your email address"));
} }
$ui->assign('_title', 'Order Plan'); $ui->assign('_title', 'Order Plan');
@ -78,7 +78,6 @@ switch ($action) {
include 'system/paymentgateway/' . $trx['gateway'] . '.php'; include 'system/paymentgateway/' . $trx['gateway'] . '.php';
call_user_func($trx['gateway'] . '_validate_config'); call_user_func($trx['gateway'] . '_validate_config');
call_user_func($config['payment_gateway'] . '_get_status', $trx, $user); call_user_func($config['payment_gateway'] . '_get_status', $trx, $user);
} else if ($routes['3'] == 'cancel') { } else if ($routes['3'] == 'cancel') {
run_hook('customer_cancel_payment'); #HOOK run_hook('customer_cancel_payment'); #HOOK
$trx->pg_paid_response = '{}'; $trx->pg_paid_response = '{}';
@ -106,7 +105,7 @@ switch ($action) {
$ui->display('user-orderView.tpl'); $ui->display('user-orderView.tpl');
break; break;
case 'buy': case 'buy':
if(empty($user['email'])){ if (strpos($user['email'], '@') === false) {
r2(U . 'accounts/profile', 'e', Lang::T("Please enter your email address")); r2(U . 'accounts/profile', 'e', Lang::T("Please enter your email address"));
} }
if ($config['payment_gateway'] == 'none') { if ($config['payment_gateway'] == 'none') {

View File

@ -79,6 +79,7 @@ switch ($do) {
$d->password = $password; $d->password = $password;
$d->fullname = $fullname; $d->fullname = $fullname;
$d->address = $address; $d->address = $address;
$d->email = '';
$d->phonenumber = $phonenumber; $d->phonenumber = $phonenumber;
if ($d->save()) { if ($d->save()) {
$user = $d->id(); $user = $d->id();

View File

@ -14,7 +14,7 @@
</div> </div>
<input type="text" name="name" class="form-control" placeholder="{$_L['Search_by_Name']}..."> <input type="text" name="name" class="form-control" placeholder="{$_L['Search_by_Name']}...">
<div class="input-group-btn"> <div class="input-group-btn">
<button class="btn btn-success">{$_L['Search']}</button> <button class="btn btn-success" type="submit">{$_L['Search']}</button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -9,18 +9,25 @@
<div class="col-md-8"> <div class="col-md-8">
<form id="site-search" method="post" action="{$_url}customers/list/"> <form id="site-search" method="post" action="{$_url}customers/list/">
<div class="input-group"> <div class="input-group">
<div class="input-group-addon"> <div class="input-group-addon no-border">
<span class="fa fa-search"></span> <select name="what">
<option value="username" {if $what=='username'}selected{/if}>Username</option>
<option value="fullname" {if $what=='fullname'}selected{/if}>Name</option>
<option value="phonenumber" {if $what=='phonenumber'}selected{/if}>Phone</option>
<option value="email" {if $what=='email'}selected{/if}>Email</option>
</select>
</div> </div>
<input type="text" name="username" class="form-control" placeholder="{$_L['Search_by_Username']}..."> <input type="text" name="search" value="{$search}" class="form-control"
placeholder="{$_L['Search_by_Username']}...">
<div class="input-group-btn"> <div class="input-group-btn">
<button class="btn btn-success">{$_L['Search']}</button> <button class="btn btn-success" type="submit"><span class="fa fa-search"></span></button>
</div> </div>
</div> </div>
</form> </form>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<a href="{$_url}customers/add" class="btn btn-primary btn-block waves-effect"><i class="ion ion-android-add"> </i> {$_L['Add_Contact']}</a> <a href="{$_url}customers/add" class="btn btn-primary btn-block waves-effect"><i
class="ion ion-android-add"> </i> {$_L['Add_Contact']}</a>
</div>&nbsp; </div>&nbsp;
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
@ -30,6 +37,7 @@
<th>{$_L['Username']}</th> <th>{$_L['Username']}</th>
<th>{$_L['Full_Name']}</th> <th>{$_L['Full_Name']}</th>
<th>{$_L['Phone_Number']}</th> <th>{$_L['Phone_Number']}</th>
<th>{$_L['Email']}</th>
<th>{$_L['Created_On']}</th> <th>{$_L['Created_On']}</th>
<th>{$_L['Recharge']}</th> <th>{$_L['Recharge']}</th>
<th>{$_L['Manage']}</th> <th>{$_L['Manage']}</th>
@ -41,11 +49,16 @@
<td>{$ds['username']}</td> <td>{$ds['username']}</td>
<td>{$ds['fullname']}</td> <td>{$ds['fullname']}</td>
<td>{$ds['phonenumber']}</td> <td>{$ds['phonenumber']}</td>
<td>{$ds['email']}</td>
<td>{$ds['created_at']}</td> <td>{$ds['created_at']}</td>
<td align="center"><a href="{$_url}prepaid/recharge-user/{$ds['id']}" id="{$ds['id']}" class="btn btn-primary btn-sm">{$_L['Recharge']}</a></td> <td align="center"><a href="{$_url}prepaid/recharge-user/{$ds['id']}" id="{$ds['id']}"
class="btn btn-primary btn-sm">{$_L['Recharge']}</a></td>
<td align="center"> <td align="center">
<a href="{$_url}customers/edit/{$ds['id']}" class="btn btn-warning btn-sm">{$_L['Edit']}</a> <a href="{$_url}customers/edit/{$ds['id']}"
<a href="{$_url}customers/delete/{$ds['id']}" id="{$ds['id']}" class="btn btn-danger btn-sm" onclick="confirm('{$_L['Delete']}?')">{$_L['Delete']}</a> class="btn btn-warning btn-sm">{$_L['Edit']}</a>
<a href="{$_url}customers/delete/{$ds['id']}" id="{$ds['id']}"
class="btn btn-danger btn-sm"
onclick="confirm('{$_L['Delete']}?')">{$_L['Delete']}</a>
</td> </td>
</tr> </tr>
{/foreach} {/foreach}

View File

@ -14,7 +14,7 @@
</div> </div>
<input type="text" name="name" class="form-control" placeholder="{$_L['Search_by_Name']}..."> <input type="text" name="name" class="form-control" placeholder="{$_L['Search_by_Name']}...">
<div class="input-group-btn"> <div class="input-group-btn">
<button class="btn btn-success">{$_L['Search']}</button> <button class="btn btn-success" type="submit">{$_L['Search']}</button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -15,7 +15,7 @@
<input type="text" name="name" class="form-control" <input type="text" name="name" class="form-control"
placeholder="{$_L['Search_by_Name']}..."> placeholder="{$_L['Search_by_Name']}...">
<div class="input-group-btn"> <div class="input-group-btn">
<button class="btn btn-success">{$_L['Search']}</button> <button class="btn btn-success" type="submit">{$_L['Search']}</button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -14,7 +14,7 @@
</div> </div>
<input type="text" name="name" class="form-control" placeholder="{$_L['Search_by_Name']}..."> <input type="text" name="name" class="form-control" placeholder="{$_L['Search_by_Name']}...">
<div class="input-group-btn"> <div class="input-group-btn">
<button class="btn btn-success">{$_L['Search']}</button> <button class="btn btn-success" type="submit">{$_L['Search']}</button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -14,7 +14,7 @@
</div> </div>
<input type="text" name="username" class="form-control" placeholder="{$_L['Search_by_Username']}..." value="{$cari}"> <input type="text" name="username" class="form-control" placeholder="{$_L['Search_by_Username']}..." value="{$cari}">
<div class="input-group-btn"> <div class="input-group-btn">
<button class="btn btn-success">{$_L['Search']}</button> <button class="btn btn-success" type="submit">{$_L['Search']}</button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -17,7 +17,7 @@
<input type="text" name="name" class="form-control" <input type="text" name="name" class="form-control"
placeholder="{$_L['Search_by_Name']}..."> placeholder="{$_L['Search_by_Name']}...">
<div class="input-group-btn"> <div class="input-group-btn">
<button class="btn btn-success">{$_L['Search']}</button> <button class="btn btn-success" type="submit">{$_L['Search']}</button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -16,7 +16,7 @@
<input type="text" name="username" class="form-control" <input type="text" name="username" class="form-control"
placeholder="Search by Username..."> placeholder="Search by Username...">
<div class="input-group-btn"> <div class="input-group-btn">
<button class="btn btn-success">Search</button> <button class="btn btn-success" type="submit">{$_L['Search']}</button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -15,7 +15,7 @@
<input type="text" name="code" class="form-control" <input type="text" name="code" class="form-control"
placeholder="{$_L['Search_by_Code']}..." value="{$_code}"> placeholder="{$_L['Search_by_Code']}..." value="{$_code}">
<div class="input-group-btn"> <div class="input-group-btn">
<button class="btn btn-success">{$_L['Search']}</button> <button class="btn btn-success" type="submit">{$_L['Search']}</button>
</div> </div>
</div> </div>
</form> </form>