View data is disappearing in a certain time

0

It's the following, so I realized the whole project follows the MVC Standard. I just have a big problem. The view of orders there is a simple refresh of 30 seconds, searching for new orders. So good! The problem happens every day at 9:00 PM, if there is a new customer request, view does not pull the data from the bank to start on the screen. >

To improve understanding, customers use an Android application to place their orders. All requests that appear in the times of (00:00 to 20:59) , the data is shown on the screen, however nothing has been shown.

Who can help me will be very grateful ...

Model:

<?phpnamespaceApp\Model;classPedidosDaoextendsDao{staticpublicfunctiongetPedidosPorPeriodo($data1,$data2){try{$sql="SELECT * FROM cpedido where ped_status != 'PEDIDO RECUSADO' and ped_dataHora between ? and ?";
        $statement_sql = Conexao::getConnection()->prepare($sql);
        $statement_sql->bindValue(1, $data1);
        $statement_sql->bindValue(2, $data2);
        $statement_sql->execute();
        return $statement_sql->fetchAll(\PDO::FETCH_ASSOC);
    } catch (\PDOException $exc) {
        echo $exc->getMessage();
    }
}

static public function getPedidosPorCliente($cli_codigo) {
    try {
        $sql = "SELECT * FROM cpedido where ped_status != 'PEDIDO RECUSADO' and cli_codigo = ?";
        $statement_sql = Conexao::getConnection()->prepare($sql);
        $statement_sql->bindValue(1, $cli_codigo);
        $statement_sql->execute();
        return $statement_sql->fetchAll(\PDO::FETCH_ASSOC);
    } catch (\PDOException $exc) {
        echo $exc->getMessage();
    }
}

static public function getStatusPedido($ped_chave) {
    try {
        $sql = "select ped_status from cpedido where ped_chave = ?";
        $statement_sql = Conexao::getConnection()->prepare($sql);
        $statement_sql->bindValue(1, $ped_chave);
        $statement_sql->execute();
        return $statement_sql->fetch(\PDO::FETCH_ASSOC);
    } catch (\PDOException $exc) {
        echo $exc->getMessage();
    }
}

static public function getCPedido($ped_chave) {
    try {
        $sql = "select * from cpedido where ped_chave = ?";
        $statement_sql = Conexao::getConnection()->prepare($sql);
        $statement_sql->bindValue(1, $ped_chave);
        $statement_sql->execute();
        return $statement_sql->fetch(\PDO::FETCH_ASSOC);
    } catch (\PDOException $exc) {
        echo $exc->getMessage();
    }
}

static public function getAllPedidos($status) {
    try {
        $sql = "select * from cpedido where ped_status = ? AND DATE_FORMAT(ped_dataHora, '%Y-%m-%d') = CURDATE() ";
        $statement_sql = Conexao::getConnection()->prepare($sql);
        $statement_sql->bindValue(1, $status);
        $statement_sql->execute();
        return $statement_sql->fetchAll(\PDO::FETCH_ASSOC);
    } catch (\PDOException $exc) {
        echo $exc->getMessage();
    }
}

static public function getItemPedido($pedchave, $prdcodigo) {
    try {
        $sql = "select * from dpedido where pedchave = ? and prdcodigo = ?";
        $statement_sql = Conexao::getConnection()->prepare($sql);
        $statement_sql->bindValue(1, $pedchave);
        $statement_sql->bindValue(2, $prdcodigo);
        $statement_sql->execute();
        return $statement_sql->fetch(\PDO::FETCH_ASSOC);
    } catch (\PDOException $exc) {
        echo $exc->getMessage();
    }
}

static public function getProdutoPedido($pedchave) {
    try {
        $sql = "select * from dpedido where pedchave = ? and tipo ='PRODUTO' order by prdcodigo asc";
        $statement_sql = Conexao::getConnection()->prepare($sql);
        $statement_sql->bindValue(1, $pedchave);
        $statement_sql->execute();
        return $statement_sql->fetchAll(\PDO::FETCH_ASSOC);
    } catch (\PDOException $exc) {
        echo $exc->getMessage();
    }
}

static public function getAdicionalPedido($pedchave) {
    try {
        $sql = "select * from dpedido where pedchave = ? and tipo ='ADICIONAL'";
        $statement_sql = Conexao::getConnection()->prepare($sql);
        $statement_sql->bindValue(1, $pedchave);
        $statement_sql->execute();
        return $statement_sql->fetchAll(\PDO::FETCH_ASSOC);
    } catch (\PDOException $exc) {
        echo $exc->getMessage();
    }
}

static public function getItemsPedido($pedchave) {
    try {
        $sql = "select * from dpedido where pedchave = ?";
        $statement_sql = Conexao::getConnection()->prepare($sql);
        $statement_sql->bindValue(1, $pedchave);
        $statement_sql->execute();
        return $statement_sql->fetchAll(\PDO::FETCH_ASSOC);
    } catch (\PDOException $exc) {
        echo $exc->getMessage();
    }
}

static public function getProdutosMaisVendidos($data1, $data2) {
    try {
        $sql = "select sum(i.quantidade) as qtd, 
                i.prdcodigo as cod, 
                pr.prd_descricao as descr
                from cpedido p 
                inner join dpedido i on p.ped_chave = i.pedchave
                inner join produtos pr on pr.prd_codigo = i.prdcodigo
                where p.ped_status !=  'PEDIDO RECUSADO' and p.ped_dataHora between ? and ? group by i.prdcodigo order by qtd desc";
        $statement_sql = Conexao::getConnection()->prepare($sql);
        $statement_sql->bindValue(1, $data1);
        $statement_sql->bindValue(2, $data2);
        $statement_sql->execute();
        return $statement_sql->fetchAll(\PDO::FETCH_ASSOC);
    } catch (\PDOException $exc) {
        echo $exc->getMessage();
    }
}

}
    
asked by anonymous 19.02.2018 / 03:16

1 answer

0

The Problem

What is happening is a problem with the time zone. Since in Brazil we are in the time zone -03:00 , we can make a simple calculation, since the server - usually - works with time zone 00:00 .

This causes a difference of 03 hours between you and the server. If the access was made from Portugal, the difference would be 01:00 am, that is, requests from 23:00 hours, would not appear.

21:00 + 03:00 = 00:00 do dia seguinte
└─┬─┘  └──┬──┘  └─┬─┘
  │       │       └─────── Horário no servidor
  │       └─────────────── Diferença de horário entre você e o servidor
  └─────────────────────── Horário local

If it is not clear, you can create a PHP file on your server and test with the code below.

<?php

/* Exibe a data do servidor */
echo date("c");

/* Altera o fuso horário do servidor */
date_default_timezone_set("America/Sao_Paulo");

/* Quebra de linha e exibe a data com o fuso horário definido */
echo PHP_EOL;
echo date("c");

Solution

One way to fix this problem is to set the time zone in the database and PHP .

In the database, just run query below:

SET GLOBAL time_zone = '-3:00';

PHP , just add the code below:

date_default_timezone_set("America/Sao_Paulo");

List of Supported Time Zones

    
19.02.2018 / 17:34