I'm new to PHP and I came across the following situation:
I have a Modal, which automatically loads the data of a predefined query and is working!
What I need to implement: Type a variable and display the result in the same Modal . Is this possible? If not, what is the best way to do it?
Below a print of the current screen:
Js
$('#item-add').on('click',function(){$('body').modalmanager('loading');setTimeout(function(){$modal.load('?ng=ps/modal-list/','',function(){$modal.modal();});},1000);});
FormcallingtheModal
<buttontype="button" class="btn btn-primary" id="item-add">
<i class="fa fa-search"></i> {$_L['Add Product OR Service']}
</button>
PHP loading Modal (Where's my question)
case 'modal-list':
//**Consulta padrão atual**
$d = ORM::for_table('sys_items')->order_by_asc('name')->find_many();
//**Consulta com a váriavel (O que eu gostaria de implementar. Neste caso, deixaria de usar a consulta acima)**
//$name = 'caneta';
//$d = ORM::for_table('sys_items')->where_like('name','%'.$name.'%')->find_many();
echo '
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>'.$_L['Products n Services'].'</h3>
</div>
//**Aqui está o input para inserir a variável**
<div class="modal-body">
<div class="input-group">
<div class="input-group-addon">
<span class="fa fa-search"></span>
</div>
<input type="text" name="name" class="form-control" placeholder="'.$_L['Search by Name'].'..."/>
<div class="input-group-btn">
<button class="btn btn-primary">'.$_L['Search'].'</button>
</div>
</div>
//**Resultado abaixo**
<table class="table table-striped" id="items_table">
<thead>
<tr>
<th width="10%">#</th>
<th width="10%">'.$_L['Item Number'].'</th>
<th width="10%">'.$_L['NCM'].'</th>
<th width="40%">'.$_L['Item Name'].'</th>
<th width="10%">'.$_L['Price'].'</th>
</tr>
</thead>
<tbody>
';
foreach($d as $ds){
$price = number_format($ds['sales_price'],2,$config['dec_point'],$config['thousands_sep']);
echo '<tr>
<td><input type="checkbox" class="si"></td>
<td>'.$ds['item_number'].'</td>
<td>'.$ds['ncm'].'</td>
<td>'.$ds['name'].'</td>
<td class="price">'.$price.'</td>
</tr>';
}
echo '
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn">'.$_L['Close'].'</button>
<button class="btn btn-primary update">'.$_L['Select'].'</button>
</div>';
break;