Eu tenho uma tabela conforme figura abaixo, preciso que ela atualize a cada 1s, mas não tenho ideia de como fazer.
Utilizei uma tag do html 5, mas ele atualiza tudo, eu só quero atualizar somente a tabela. Minha View
<?php
$datenull = '01/01/0001 00:01';
$linha = 1;
?>
<meta HTTP-EQUIV="refresh" content="2">
<h1>Lista de Chamados em Abertos</h1>
<br/>
<div class="myTable table-responsive">
<table class="table table-hover">
<tr>
<th></th>
<th class="text-center">N. Chamado</th>
<th class="text-center">Computador</th>
<th class="text-center">Sala de Aula</th>
<th class="text-center">Criado em</th>
</tr>
<?php foreach ($this->data as $entity) :?>
<tr onclick="location.href ='<?php echo $this->url('Caos-admin-interna',
array(
'controller' => 'calls',
'action' => 'examined',
'id' => $entity->getId()
)
);?>';" style="cursor: pointer">
<td class="text-center"><strong><?php echo $linha;?></strong></td>
<td class="text-center"><?php echo $entity->getId();?></td>
<td class="text-center"><?php echo $entity->getComputer();?></td>
<td class="text-center"><?php echo $entity->getClassroom();?></td>
<td class="text-center"><?php echo $entity->getCreated();?></td>
</tr>
<?php
$linha = $linha + 1;
endforeach; ?>
</table>
</div>
<?php
namespace CaosAdmin\Controller;
use Zend\View\Model\ViewModel,
Zend\Authentication\Storage\Session as SessionStorage,
Zend\Authentication\AuthenticationService;
use Zend\Paginator\Paginator,
Zend\Paginator\Adapter\ArrayAdapter;
class CallsController extends CRUDController
{
private $user;
private $numberPerPage;
public function __construct()
{
$this->entity = 'Caos\Entity\Call';
$this->form = 'CaosAdmin\Form\Call';
$this->service = 'Caos\Service\Call';
$this->controller = 'calls';
$this->route = 'Caos-admin';
$auth = new AuthenticationService();
$sessionStorage = new SessionStorage('CaosAdmin');
$auth->setStorage($sessionStorage);
$this->user = $sessionStorage->read();
$this->numberPerPage = 20;
}
/**
* @return ViewModel
*/
public function indexAction()
{
$list = $this->getEm()->getRepository($this->entity)->findCallBySchool($this->user->getId());
$viewModel = new ViewModel(array('data' => $list));
return $viewModel;
}
}
O retorno da minha pesquisa vem neste formato:
Array(
[0] => Caos\Entity\Call Object
(
[id:protected] => 27
[examined:protected] => DateTime Object
(
[date] => 0001-01-01 00:00:00
[timezone_type] => 3
[timezone] => America/Sao_Paulo
)
[closed:protected] => DateTime Object
(
[date] => 0001-01-01 00:00:00
[timezone_type] => 3
[timezone] => America/Sao_Paulo
)
[modified:protected] => DateTime Object
(
[date] => 2017-01-20 16:21:39
[timezone_type] => 3
[timezone] => America/Sao_Paulo
)
[created:protected] => DateTime Object
(
[date] => 2017-01-20 16:21:39
[timezone_type] => 3
[timezone] => America/Sao_Paulo
)
[obs:protected] =>
[computer:protected] => DoctrineORMModule\Proxy\__CG__\Caos\Entity\Computer Object
(
[__initializer__] => Closure Object
(
[static] => Array
(
[entityPersister] => Doctrine\ORM\Persisters\Entity\BasicEntityPersister Object
(
[class:protected] => Doctrine\ORM\Mapping\ClassMetadata Object
(
[name] => Caos\Entity\Computer
[namespace] => Caos\Entity
[rootEntityName] => Caos\Entity\Computer
[customGeneratorDefinition] =>
[customRepositoryClassName] => Caos\Entity\ComputerRepository
[isMappedSuperclass] =>
[isEmbeddedClass] =>
[parentClasses] => Array
(
)
[subClasses] => Array
(
)
[embeddedClasses] => Array
(
)
[namedQueries] => Array
(
)
[namedNativeQueries] => Array
(
)
[sqlResultSetMappings] => Array
(
)
leo_ap o retorno da minha pesquisa vem neste formato:
Array(
[0] => Caos\Entity\Call Object
(
[id:protected] => 27
[examined:protected] => DateTime Object
(
[date] => 0001-01-01 00:00:00
[timezone_type] => 3
[timezone] => America/Sao_Paulo
)
[closed:protected] => DateTime Object
(
[date] => 0001-01-01 00:00:00
[timezone_type] => 3
[timezone] => America/Sao_Paulo
)
[modified:protected] => DateTime Object
(
[date] => 2017-01-20 16:21:39
[timezone_type] => 3
[timezone] => America/Sao_Paulo
)
[created:protected] => DateTime Object
(
[date] => 2017-01-20 16:21:39
[timezone_type] => 3
[timezone] => America/Sao_Paulo
)
[obs:protected] =>
[computer:protected] => DoctrineORMModule\Proxy\__CG__\Caos\Entity\Computer Object
(
[__initializer__] => Closure Object
(
[static] => Array
(
[entityPersister] => Doctrine\ORM\Persisters\Entity\BasicEntityPersister Object
(
[class:protected] => Doctrine\ORM\Mapping\ClassMetadata Object
(
[name] => Caos\Entity\Computer
[namespace] => Caos\Entity
[rootEntityName] => Caos\Entity\Computer
[customGeneratorDefinition] =>
[customRepositoryClassName] => Caos\Entity\ComputerRepository
[isMappedSuperclass] =>
[isEmbeddedClass] =>
[parentClasses] => Array
(
)
[subClasses] => Array
(
)
[embeddedClasses] => Array
(
)
[namedQueries] => Array
(
)
[namedNativeQueries] => Array
(
)
[sqlResultSetMappings] => Array
(
)
Na minha View eu coloco esse código para imprimir os dados:
$entity->getId()
No javascript como que faço? eu tenho um método na minha entidade que transforma um array, como faço para usar.
Obrigado