| @@ 311-334 (lines=24) @@ | ||
| 308 | return; |
|
| 309 | } |
|
| 310 | ||
| 311 | public function loginClient($dados) |
|
| 312 | { |
|
| 313 | ||
| 314 | $conditions = array( |
|
| 315 | 'ativo' => 1, |
|
| 316 | 'id_usuario' => $this->getIdUser(), |
|
| 317 | 'email' => $dados['email'], |
|
| 318 | 'senha' => sha1($dados['senha']) |
|
| 319 | ); |
|
| 320 | ||
| 321 | $cliente = $this->Cliente->find('all', |
|
| 322 | array('conditions' => |
|
| 323 | $conditions |
|
| 324 | ) |
|
| 325 | ); |
|
| 326 | ||
| 327 | if (!empty($cliente)) { |
|
| 328 | $this->response->body('{"message": "success", "result":'.json_encode($cliente).'}'); |
|
| 329 | return; |
|
| 330 | } |
|
| 331 | ||
| 332 | $this->response->body('{"message": "error"}'); |
|
| 333 | return; |
|
| 334 | } |
|
| 335 | ||
| 336 | public function postClient($dados) |
|
| 337 | { |
|
| @@ 387-404 (lines=18) @@ | ||
| 384 | } |
|
| 385 | ||
| 386 | ||
| 387 | public function postParent($dados) |
|
| 388 | { |
|
| 389 | $dados = array( |
|
| 390 | 'senha' => sha1($dados['senha']), |
|
| 391 | 'usuario_id' => $this->getIdUser(), |
|
| 392 | 'cliente_id' => $dados['cliente_id'], |
|
| 393 | 'login' => $dados['login'], |
|
| 394 | 'ativo' => 1, |
|
| 395 | ); |
|
| 396 | ||
| 397 | if ($this->Parente->save($dados)) { |
|
| 398 | $this->response->body('{"message": "success", "result":'.json_encode($dados).'}'); |
|
| 399 | return; |
|
| 400 | } |
|
| 401 | ||
| 402 | $this->response->body('{"message": "error"}'); |
|
| 403 | return; |
|
| 404 | } |
|
| 405 | ||
| 406 | public function loginParent($dados) |
|
| 407 | { |
|
| @@ 406-428 (lines=23) @@ | ||
| 403 | return; |
|
| 404 | } |
|
| 405 | ||
| 406 | public function loginParent($dados) |
|
| 407 | { |
|
| 408 | $conditions = array( |
|
| 409 | 'ativo' => 1, |
|
| 410 | 'usuario_id' => $this->getIdUser(), |
|
| 411 | 'login' => $dados['login'], |
|
| 412 | 'senha' => sha1($dados['senha']) |
|
| 413 | ); |
|
| 414 | ||
| 415 | $parente = $this->Parente->find('all', |
|
| 416 | array('conditions' => |
|
| 417 | $conditions |
|
| 418 | ) |
|
| 419 | ); |
|
| 420 | ||
| 421 | if (!empty($parente)) { |
|
| 422 | $this->response->body('{"message": "success", "result":'.json_encode($parente).'}'); |
|
| 423 | return; |
|
| 424 | } |
|
| 425 | ||
| 426 | $this->response->body('{"message": "error"}'); |
|
| 427 | return; |
|
| 428 | } |
|
| 429 | ||
| 430 | public function putParent($dados, $id_parente) |
|
| 431 | { |
|
| @@ 463-481 (lines=19) @@ | ||
| 460 | } |
|
| 461 | } |
|
| 462 | ||
| 463 | public function postConsulta($dados) |
|
| 464 | { |
|
| 465 | $dados = array( |
|
| 466 | 'nome' => $dados['nome'], |
|
| 467 | 'email' => $dados['email'], |
|
| 468 | 'data' => $dados['date'], |
|
| 469 | 'hora' => $dados['hora'], |
|
| 470 | 'id_usuario' => $this->getIdUser(), |
|
| 471 | 'ativo' => 1, |
|
| 472 | ); |
|
| 473 | ||
| 474 | if ($this->Consulta->save($dados)) { |
|
| 475 | $this->response->body('{"message": "success", "result":' . json_encode($dados) . '}'); |
|
| 476 | return; |
|
| 477 | } |
|
| 478 | ||
| 479 | $this->response->body('{"message": "error"}'); |
|
| 480 | return; |
|
| 481 | } |
|
| 482 | ||
| 483 | /** |
|
| 484 | * Valida o usuario que está tentando usar a api |
|