projet-php/managers/Patient.class.php

51 lines
2.3 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: seekdasky
* Date: 10/12/15
* Time: 09:16
*/
class Patient
{
public function add($params){
$params['date_naissance'] = DateTime::createFromFormat('d-m-Y', $params['date_naissance']);
if(PatientRepo::add($params['civilite'],strtolower($params['prenom']),strtolower($params['nom']),$params['adresse'],$params['adresse2'],$params['ville'],$params['cope_postal'],
$params['date_naissance']->format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !==FALSE){
$response = new Response();
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/index.php?type=creation");
$response->send();
}else{
$response = new Response(500);
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/index.php?type=error");
$response->send();
}
}
public function update($params){
$params['date_naissance'] = DateTime::createFromFormat('d-m-Y', $params['date_naissance']);
if(PatientRepo::update($params['id_patient'],$params['civilite'],strtolower($params['prenom']),strtolower($params['nom']),$params['adresse'],$params['adresse2'],$params['ville'],$params['cope_postal'],
$params['date_naissance']->format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !==FALSE){
$response = new Response();
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/index.php?type=creation");
$response->send();
}else{
$response = new Response(500);
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/index.php?type=error");
$response->send();
}
}
public function delete($params){
if(PatientRepo::delete($params['id_patient']) !==FALSE){
$response = new Response();
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=supression");
$response->send();
}else{
$response = new Response(500);
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=error");
$response->send();
}
}
}