Exemplo n.º 1
0
 /**
  * Validar dados do motorista
  * @return   int
  */
 public function Validar()
 {
     $this->Erros = array();
     if (strlen(trim($this->Nome)) < 4) {
         $this->Erros["Nome"] = "O nome deve ter 4 ou mais caracteres";
     }
     if (intval($this->CnhNumero) < 1) {
         $this->Erros["CnhNumero"] = "não é um número valido";
     }
     if (strlen(trim($this->CnhCategoria)) < 1) {
         $this->Erros["CnhCategoria"] = "categoria não é valida";
     }
     self::Conectar();
     $res = mysql_query("select id from motorista where CnhNumero = '{$this->CnhNumero}'");
     if (mysql_num_rows($res) > 0) {
         list($id) = mysql_fetch_row($res);
         if ($id != $this->ID) {
             $this->Erros["Nº carteira"] = "Já existe com a carteira informada";
         }
     }
     return parent::Validar();
 }
Exemplo n.º 2
0
 /**
  * Validar dados do motorista
  * @return   int
  */
 public function Validar()
 {
     if (strlen($this->Data) < 10 or !DateTime::createFromFormat("Y-m-d", $this->Data)) {
         $this->Erros["Data"] = "Data inválida";
     }
     if (intval($this->Quilometragem) < 0) {
         $this->Erros["Quilometragem"] = "Deve um número positivo válido";
     }
     return parent::Validar();
 }
Exemplo n.º 3
0
 /**
  * Validar dados do veículo
  * @return   boolean
  */
 public function Validar()
 {
     $this->Erros = array();
     if (strlen(trim($this->Tipo)) < 1) {
         $this->Erros["Destino"] = "O tipo deve ser informado";
     }
     if (strlen(trim($this->Categoria)) < 1) {
         $this->Erros["Motivo"] = "A categoria deve ser informada";
     }
     if (intval($this->QtdPessoas) < 1) {
         $this->Erros["QtdPessoas"] = "A quantidade de pessoas deve ser um número inteiro maior que zero";
     }
     if (strlen(trim($this->Placa)) < 6) {
         $this->Erros["Placa"] = "A placa deve ser informada";
     }
     self::Conectar();
     $res = mysql_query("select id from veiculo where placa = '{$this->Placa}'");
     if (mysql_num_rows($res) > 0) {
         list($id) = mysql_fetch_row($res);
         if ($id != $this->ID) {
             $this->Erros["Placa"] = "Já existe um veiculo com a placa informada";
         }
     }
     return parent::Validar();
 }
Exemplo n.º 4
0
 /**
  * Validar dados da viagem
  * @return   boolean
  */
 public function Validar()
 {
     $this->Erros = array();
     if (!is_int($this->Usuario_ID) and $this->Usuario_ID < 0) {
         $this->Erros["Solicitante"] = "ID de solicitante inválido";
     }
     if (strlen(trim($this->Destino)) < 4) {
         $this->Erros["Destino"] = "deve ter 4 ou mais caracteres";
     }
     if (strlen(trim($this->Motivo)) < 4) {
         $this->Erros["Motivo"] = "deve ter 4 ou mais caracteres";
     }
     if (intval($this->QtdPessoas) < 1) {
         $this->Erros["QtdPessoas"] = "deve ser um número inteiro maior que zero";
     }
     if (strlen($this->Saida) < 10 or !DateTime::createFromFormat("Y-m-d", $this->Saida)) {
         $this->Erros["Saida"] = "Data em formato inválida";
     }
     if (strlen($this->Chegada) < 10 or !DateTime::createFromFormat("Y-m-d", $this->Chegada)) {
         $this->Erros["Chegada"] = "Data em formato inválida";
     } elseif (!isset($this->Erros["Saida"])) {
         $data1 = DateTime::createFromFormat("Y-m-d", $this->Saida);
         $data2 = DateTime::createFromFormat("Y-m-d", $this->Chegada);
         if ($data1 > $data2) {
             $this->Erros["Chegada"] = "Data de chegada inválida";
         }
     }
     return parent::Validar();
 }