PLUS DE VERIFICATIOOOOOOOOON + réponse différente suivant le type de requete
This commit is contained in:
parent
4d6164c519
commit
53cf652699
|
@ -307,7 +307,7 @@
|
|||
<tr><td><div align="right"><a name="118"></a><a href="#118">118</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">switch</span><span class="keyword">(</span><span class="default">$dbtype</span><span class="keyword">)</span><span class="keyword">{</span></td></tr>
|
||||
<tr><td><div align="right"><a name="119"></a><a href="#119">119</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// [1] 'M' / 'F' </span></td></tr>
|
||||
<tr class="covered-by-large-tests popin" data-title="16 tests cover line 120" data-content="<ul><li class="covered-by-large-tests">MedecinRepoTest::testAddAndDelete</li><li class="covered-by-large-tests">MedecinRepoTest::testSearch</li><li class="covered-by-large-tests">MedecinRepoTest::testGetPatient</li><li class="covered-by-large-tests">MedecinRepoTest::testGetById</li><li class="covered-by-large-tests">PatientRepoTest::testGetById</li><li class="covered-by-large-tests">PatientRepoTest::testAddAndDeletePatient</li><li class="covered-by-large-tests">PatientRepoTest::testSearch</li><li class="covered-by-large-tests">PatientRepoTest::testUpdateMedecinTraitant</li><li class="covered-by-large-tests">PatientRepoTest::testUpdate</li><li class="covered-by-large-tests">RDVRepoTest::testAdd</li><li class="covered-by-large-tests">RDVRepoTest::testGetById</li><li class="covered-by-large-tests">RDVRepoTest::testUpdateTime</li><li class="covered-by-large-tests">RDVRepoTest::testGetByDate</li><li class="covered-by-large-tests">RDVRepoTest::testGetByPAtientAndDate</li><li class="covered-by-large-tests">RDVRepoTest::testGetAll</li><li class="covered-by-large-tests">StaticRepoTest::testCheckParam</li></ul>" data-placement="bottom" data-html="true"><td><div align="right"><a name="120"></a><a href="#120">120</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">case</span><span class="default"> </span><span class="default">'Civilite'</span><span class="keyword">:</span></td></tr>
|
||||
<tr class="covered-by-large-tests popin" data-title="4 tests cover line 121" data-content="<ul><li class="covered-by-large-tests">MedecinRepoTest::testAddAndDelete</li><li class="covered-by-large-tests">PatientRepoTest::testAddAndDeletePatient</li><li class="covered-by-large-tests">PatientRepoTest::testUpdate</li><li class="covered-by-large-tests">StaticRepoTest::testCheckParam</li></ul>" data-placement="bottom" data-html="true"><td><div align="right"><a name="121"></a><a href="#121">121</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$checker</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$checker</span><span class="default"> </span><span class="default">&&</span><span class="default"> </span><span class="default">is_string</span><span class="keyword">(</span><span class="default">$variable</span><span class="keyword">)</span><span class="default"> </span><span class="default">&&</span><span class="default"> </span><span class="default">in_array</span><span class="keyword">(</span><span class="default">$variable</span><span class="keyword">,</span><span class="keyword">[</span><span class="default">'M'</span><span class="keyword">,</span><span class="default">'F'</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
||||
<tr class="covered-by-large-tests popin" data-title="4 tests cover line 121" data-content="<ul><li class="covered-by-large-tests">MedecinRepoTest::testAddAndDelete</li><li class="covered-by-large-tests">PatientRepoTest::testAddAndDeletePatient</li><li class="covered-by-large-tests">PatientRepoTest::testUpdate</li><li class="covered-by-large-tests">StaticRepoTest::testCheckParam</li></ul>" data-placement="bottom" data-html="true"><td><div align="right"><a name="121"></a><a href="#121">121</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$checker</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$checker</span><span class="default"> </span><span class="default">&&</span><span class="default"> </span><span class="default">is_string</span><span class="keyword">(</span><span class="default">$variable</span><span class="keyword">)</span><span class="default"> </span><span class="default">&&</span><span class="default"> </span><span class="default">in_array</span><span class="keyword">(</span><span class="default">$variable</span><span class="keyword">,</span><span class="default"> </span><span class="keyword">[</span><span class="default">'M'</span><span class="keyword">,</span><span class="default">'F'</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
||||
<tr class="covered-by-large-tests popin" data-title="4 tests cover line 122" data-content="<ul><li class="covered-by-large-tests">MedecinRepoTest::testAddAndDelete</li><li class="covered-by-large-tests">PatientRepoTest::testAddAndDeletePatient</li><li class="covered-by-large-tests">PatientRepoTest::testUpdate</li><li class="covered-by-large-tests">StaticRepoTest::testCheckParam</li></ul>" data-placement="bottom" data-html="true"><td><div align="right"><a name="122"></a><a href="#122">122</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">break</span><span class="keyword">;</span></td></tr>
|
||||
<tr><td><div align="right"><a name="123"></a><a href="#123">123</a></div></td><td class="codeLine"></td></tr>
|
||||
<tr><td><div align="right"><a name="124"></a><a href="#124">124</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// [2] Chaine de caractère (longueur variable)</span></td></tr>
|
||||
|
@ -366,7 +366,7 @@
|
|||
<span class="warning"><strong>Dead Code</strong></span>
|
||||
</p>
|
||||
<p>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.0</a> at Thu Dec 10 10:51:32 UTC 2015.</small>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.3</a> at Tue Dec 15 8:23:37 UTC 2015.</small>
|
||||
</p>
|
||||
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
|
||||
</footer>
|
||||
|
|
|
@ -146,7 +146,7 @@
|
|||
<footer>
|
||||
<hr/>
|
||||
<p>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.0</a> at Thu Dec 10 10:51:32 UTC 2015.</small>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.3</a> at Tue Dec 15 8:23:37 UTC 2015.</small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
|
|
|
@ -136,7 +136,7 @@
|
|||
<span class="success"><strong>High</strong>: 90% to 100%</span>
|
||||
</p>
|
||||
<p>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.0</a> at Thu Dec 10 10:51:32 UTC 2015.</small>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.3</a> at Tue Dec 15 8:23:37 UTC 2015.</small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
|
|
|
@ -318,7 +318,7 @@
|
|||
<span class="warning"><strong>Dead Code</strong></span>
|
||||
</p>
|
||||
<p>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.0</a> at Thu Dec 10 10:51:32 UTC 2015.</small>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.3</a> at Tue Dec 15 8:23:37 UTC 2015.</small>
|
||||
</p>
|
||||
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
|
||||
</footer>
|
||||
|
|
|
@ -385,7 +385,7 @@
|
|||
<span class="warning"><strong>Dead Code</strong></span>
|
||||
</p>
|
||||
<p>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.0</a> at Thu Dec 10 10:51:32 UTC 2015.</small>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.3</a> at Tue Dec 15 8:23:37 UTC 2015.</small>
|
||||
</p>
|
||||
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
|
||||
</footer>
|
||||
|
|
|
@ -365,7 +365,7 @@
|
|||
<span class="warning"><strong>Dead Code</strong></span>
|
||||
</p>
|
||||
<p>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.0</a> at Thu Dec 10 10:51:32 UTC 2015.</small>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.3</a> at Tue Dec 15 8:23:37 UTC 2015.</small>
|
||||
</p>
|
||||
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
|
||||
</footer>
|
||||
|
|
|
@ -213,7 +213,7 @@
|
|||
<span class="warning"><strong>Dead Code</strong></span>
|
||||
</p>
|
||||
<p>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.0</a> at Thu Dec 10 10:51:32 UTC 2015.</small>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.3</a> at Tue Dec 15 8:23:37 UTC 2015.</small>
|
||||
</p>
|
||||
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
|
||||
</footer>
|
||||
|
|
|
@ -141,7 +141,7 @@
|
|||
<footer>
|
||||
<hr/>
|
||||
<p>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.0</a> at Thu Dec 10 10:51:32 UTC 2015.</small>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.3</a> at Tue Dec 15 8:23:37 UTC 2015.</small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
|
|
|
@ -193,7 +193,7 @@
|
|||
<span class="success"><strong>High</strong>: 90% to 100%</span>
|
||||
</p>
|
||||
<p>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.0</a> at Thu Dec 10 10:51:32 UTC 2015.</small>
|
||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.0.2</a> using <a href="http://php.net/" target="_top">PHP 7.0.0</a> and <a href="https://phpunit.de/">PHPUnit 5.1.3</a> at Tue Dec 15 8:23:37 UTC 2015.</small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
|
|
|
@ -10,24 +10,55 @@ class Medecin
|
|||
{
|
||||
public function add($params){
|
||||
if(MedecinRepo::add($params['civilite'],strtolower($params['prenom']),strtolower($params['nom'])) !==FALSE){
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'success',
|
||||
'title' => 'Création enregistrée!',
|
||||
'message' => 'Le médecin '.$params['prenom'].' '.$params['nom'].' a bien été créé.'
|
||||
]));
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=creation");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'success',
|
||||
'title' => 'Création effectuée!',
|
||||
'message' => 'Le médecin '.$params['prenom'].' '.$params['nom'].' a bien été créé.'
|
||||
]));
|
||||
}
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'error',
|
||||
'title' => 'Erreur de création!'
|
||||
]));
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=error");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'error',
|
||||
'title' => 'Erreur de création!'
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($params){
|
||||
if(MedecinRepo::delete($params['id_medecin']) !==FALSE){
|
||||
Response::quickResponse(200, json_encode(['status'=>'success']));
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=supression");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'success',
|
||||
'title' => 'Médecin supprimé!',
|
||||
'message' => ''
|
||||
]));
|
||||
}
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode(['status'=>'error']));
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=error");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'error',
|
||||
'title' => 'Erreur lors de la supression!'
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,34 +9,117 @@
|
|||
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['code_postal'],
|
||||
$params['date_naissance']->format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !== FALSE){
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'success',
|
||||
'title' => 'Création enregistrée!',
|
||||
'message' => 'Le patient '.$params['prenom'].' '.$params['nom'].' a bien été créé.'
|
||||
]));
|
||||
if(StaticRepo::checkParam($params['date_naissance'],'Date')){
|
||||
$params['num_secu'] = str_replace(' ','',$params['num_secu']);
|
||||
$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['code_postal'],
|
||||
$params['date_naissance']->format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !== FALSE){
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=creation");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'success',
|
||||
'title' => 'Création effectuée!',
|
||||
'message' => 'Le patient '.$params['prenom'].' '.$params['nom'].' a bien été créé.'
|
||||
]));
|
||||
}
|
||||
}else{
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=error");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'error',
|
||||
'title' => 'Erreur de création!'
|
||||
]));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([ 'status' => 'error' ]));
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=error");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'error',
|
||||
'title' => 'Erreur de paramètre',
|
||||
'message' => 'Date incorrecte'
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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::quickResponse(200, json_encode(['status'=>'success']));
|
||||
if(StaticRepo::checkParam($params['date_naissance'],'Date')){
|
||||
$params['num_secu'] = str_replace(' ','',$params['num_secu']);
|
||||
$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){
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=maj");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'success',
|
||||
'title' => 'Modification effectuée!',
|
||||
'message' => 'Le patient '.$params['prenom'].' '.$params['nom'].' a bien été modifié.'
|
||||
]));
|
||||
}
|
||||
}else{
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=error");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'error',
|
||||
'title' => 'Erreur de création!'
|
||||
]));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode(['status'=>'error']));
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=error");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'error',
|
||||
'title' => 'Erreur de paramètre',
|
||||
'message' => 'Date incorrecte'
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($params){
|
||||
if(PatientRepo::delete($params['id_patient']) !==FALSE){
|
||||
Response::quickResponse(200, json_encode(['status'=>'success']));
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=supression");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'success',
|
||||
'title' => 'Supression effectuée!',
|
||||
'message' => 'Le patient a bien été supprimé.'
|
||||
]));
|
||||
}
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode(['status'=>'error']));
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=error");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'error',
|
||||
'title' => 'Erreur lors de la supression!'
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,40 +9,113 @@
|
|||
class RDV
|
||||
{
|
||||
public function add($params){
|
||||
$params['date'] = DateTime::createFromFormat('d/m/Y', $params['date']);
|
||||
if(RDVRepo::add($params['date']->format('Y-m-d').' '.$params['heure'].':00',$params['duree'],$params['id_patient'],$params['id_medecin']) !==FALSE){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultation.php?type=creation");
|
||||
$response->send();
|
||||
if(StaticRepo::checkParam($params['date_naissance'],'Date')) {
|
||||
$params['date'] = DateTime::createFromFormat('d/m/Y', $params['date']);
|
||||
if (RDVRepo::add($params['date']->format('Y-m-d') . ' ' . $params['heure'] . ':00', $params['duree'], $params['id_patient'], $params['id_medecin']) !== FALSE) {
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=creation");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'success',
|
||||
'title' => 'Création effectuée!',
|
||||
'message' => 'La consultation du '.$params['date']->format('d/m/Y').' à '.$params['heure'].' a bien été créée.'
|
||||
]));
|
||||
}
|
||||
}else{
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'error',
|
||||
'title' => 'Erreur de création!'
|
||||
]));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$response = new Response(500);
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultation.php?type=error");
|
||||
$response->send();
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'error',
|
||||
'title' => 'Erreur de paramètre',
|
||||
'message' => 'Date incorrecte'
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($params){
|
||||
if(RDVRepo::delete($params['id_consultation']) !==FALSE){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultation.php?type=supression");
|
||||
$response->send();
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=supression");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'success',
|
||||
'title' => 'Supression effectuée!',
|
||||
'message' => 'La consultation a bien été supprimée.'
|
||||
]));
|
||||
}
|
||||
}else{
|
||||
$response = new Response(500);
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultation.php?type=error");
|
||||
$response->send();
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'error',
|
||||
'title' => 'Erreur lors de la supression!'
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function update($params){
|
||||
$params['date'] = DateTime::createFromFormat('d/m/Y', $params['date']);
|
||||
if(RDVRepo::updateDateTime($params['id_consultation'],$params['date']->format('Y-m-d').' '.$params['heure'].':00') !==FALSE){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultation.php?type=maj");
|
||||
$response->send();
|
||||
if(StaticRepo::checkParam($params['date_naissance'],'Date')) {
|
||||
$params['date'] = DateTime::createFromFormat('d/m/Y', $params['date']);
|
||||
if (RDVRepo::updateDateTime($params['id_consultation'], $params['date']->format('Y-m-d') . ' ' . $params['heure'] . ':00') !== FALSE) {
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=maj");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'success',
|
||||
'title' => 'Modification effectuée!',
|
||||
'message' => 'La consultation du '.$params['date']->format('d/m/Y').' à '.$params['heure'].'a bien été mis àjour.'
|
||||
]));
|
||||
}
|
||||
}else{
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'error',
|
||||
'title' => 'Erreur de mise a jour!'
|
||||
]));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$response = new Response(500);
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultation.php?type=error");
|
||||
$response->send();
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
||||
$response = new Response();
|
||||
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
|
||||
$response->send();
|
||||
}else{
|
||||
Response::quickResponse(200, json_encode([
|
||||
'status' => 'error',
|
||||
'title' => 'Erreur de paramètre',
|
||||
'message' => 'Date incorrecte'
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
$GLOBALS['compression'] = true;
|
||||
//variable globale pour accéder aux dossiers des managers
|
||||
$GLOBALS['managers_dir'] = dirname(__FILE__);
|
||||
//Headers de la requete
|
||||
$GLOBALS['headers'] = apache_request_headers();
|
||||
|
||||
session_start();
|
||||
if($GLOBALS['compression']){
|
||||
|
|
Loading…
Reference in New Issue