public function update(Entidade $entity) { $this->session->contentType = "application/json"; $json = $entity->toJson(); $result = $this->session->put("/{$this->entityName()}/altera/{$entity->getId()}", $json); return $result; }
/** * Run the database seeds. * * @return void */ public function run() { #Apaga e povoa a tabela de entidades DB::table('entidades')->delete(); Entidade::create(array('nome' => 'SECRETARIA DE EDUCAÇÃO DE ARACAJU')); #Apaga e povoa a tabela de unidades DB::table('unidades')->delete(); Unidade::create(array('nome' => 'EMEI PROFª ETELVINA AMALIA DE SIQUEIRA', 'entidade_id' => 1)); Unidade::create(array('nome' => 'ESC MUL DE EDUC INFANTIL PIERRE AVERAN', 'entidade_id' => 1)); Unidade::create(array('nome' => 'ESC MUL DE EDUC INF BENJAMIN ALVES DE CARVALHO', 'entidade_id' => 1)); Unidade::create(array('nome' => 'ESC MUL DE EDUCACAO INFANTIL DOM HELDER CAMARA', 'entidade_id' => 1)); }
public function update(Entidade $entity) { $result = $this->session->put("/{$this->entityName()}/altera/{$entity->getId()}", ObjectParser::toArray($entity)); return $result; }
/** * 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(); }
} //atualiza empresas $file = "http://www2.tecbiz.com.br/tecbiz/tecbiz.php?a=21f7b2&acs=2"; $json = file_get_contents($file); $lista = json_decode($json, true); foreach ($lista as $value) { $empresa = new Empresa(); $empresa->fromArray($value); $empresa->store(); } //atualiza entidades $file = "http://www2.tecbiz.com.br/tecbiz/tecbiz.php?a=21f7b2&acs=3"; $json = file_get_contents($file); $lista = json_decode($json, true); foreach ($lista as $value) { $entidade = new Entidade(); $entidade->fromArray($value); $entidade->store(); } //atualiza entidades $file = "http://www2.tecbiz.com.br/tecbiz/tecbiz.php?a=21f7b2&acs=4"; $json = file_get_contents($file); $lista = json_decode($json, true); foreach ($lista as $value) { $estabelecimento = new Estabelecimento(); $estabelecimento->fromArray($value); $estabelecimento->store(); } TTransaction::close(); } catch (Exception $e) { print $e->getMessage();
/** * 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(); }
public function __construct($id) { parent::__construct($id); //Contagem associativa //$this->locaisDeProcedencia = $this->contagemAssociativa("publico_id"); //$this->necessidadesAtendimento = $this->contagemAssociativa("necessidade_atendimento"); //$this->hipoteseDiagnostica = $this->contagemHipoteseDiagnostica(); //$this->sinaisSintomas = $this->contagemSinaisSintomas(); //$this->encaminhamentos = $this->contagemEncaminhamentos(); //$this->causasExternas = $this->contagemAssociativa("causas_externas"); //$this->causasClinicas = $this->contagemAssociativa("causas_clinicas"); //$this->doenca_dnci = $this->contagemDNCI();//$this->contagemAssociativa("doenca_dnci"); //Contagem com rótulos para valores predefinidos //$this->sexos = $this->contagemRotulo("sexo", array('valor'=>'1', 'true'=>'Homem', 'false'=>'Mulher')); //$this->sexos = $this->retornaValorSexo(); //$this->foliaoTrabalhador = $this->contagemRotulo("publico_id", array('valor'=>'1', 'true'=>'Expectador', 'false'=>'Trabalhador')); $this->cidades = $this->retornaCidade($id); //Contagem padrão //$this->idades = $this->contagem("idade"); //Média de valor //$this->idadesMedia = $this->contagemMedia("idade"); //Horário //$this->horario = $this->horario(); //Total $this->total = $this->total(); }
/** * 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(); }
/** * 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(); }