Closed drchav closed 9 years ago
and in the controlle i made this:
$request = $this->getRequest(); $dataPost = $request->getPost(); $userData = $this->getUserData();
$adapter = $this->getService('DbAdapter');
$sql = new Sql($adapter);
$source = $sql->select()
->from(array('a'=>'tblmerchant_invoices'))
->columns(
array(
'id',
'userFrom',
'procStatus',
'transactionId',
'invoiceNumber',
'defaultCurrency',
'invoiceDate',
'invoiceDueDate',
'totalItens',
'itensDiscount',
'delivery',
'totalInvoice'
)
)
->join(array('b' => 'tblsystem_users'), 'a.userFrom = b.id', array('fullName','userEmail'))
->join(array('c' => 'tblsystem_status'), 'a.procStatus = c.id', array('statusName','statusColor'))
->where(array("a.userTo" => $userData->getId()));
$table = new \Core\DataTables\Invoices();
$table->setAdapter($adapter)
->setSource($source)
->setParamAdapter(new \Core\DataTables\ParamAdapterDataTable($dataPost));
$dataSource = $sql->prepareStatementForSqlObject($source);
$exec = $dataSource->execute();
$dadosCount = $exec->count();
$dados = json_decode($table->render('dataTableJson'));
$retorno = array(
'draw' => $dados->sEcho,
'recordsTotal' => $dadosCount,
'recordsFiltered' => $dados->iTotalDisplayRecords,
'data' => $dados->aaData
);
return $this->jsonResponse($retorno);
Thanks, In the next version I will add You changes. I do not close ticket, because it can help other people.
Thanks a lot for You pull request. I've just merged.
Here some update n datables 1.10
<?php /**
namespace Core\DataTables;
use ZfTable\Params\AbstractAdapter; use ZfTable\Params\AdapterInterface; use ZfTable\Table\Exception;
class ParamAdapterDataTable extends AbstractAdapter implements AdapterInterface, \Zend\Stdlib\InitializableInterface {
}