merge remote
This commit is contained in:
xdrm-brackets 2015-12-17 08:21:07 +01:00
commit fb596ef35a
13 changed files with 248 additions and 59 deletions

View File

@ -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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;[1]&nbsp;'M'&nbsp;/&nbsp;'F'&nbsp;</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="16 tests cover line 120" data-content="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;MedecinRepoTest::testAddAndDelete&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;MedecinRepoTest::testSearch&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;MedecinRepoTest::testGetPatient&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;MedecinRepoTest::testGetById&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;PatientRepoTest::testGetById&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;PatientRepoTest::testAddAndDeletePatient&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;PatientRepoTest::testSearch&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;PatientRepoTest::testUpdateMedecinTraitant&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;PatientRepoTest::testUpdate&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;RDVRepoTest::testAdd&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;RDVRepoTest::testGetById&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;RDVRepoTest::testUpdateTime&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;RDVRepoTest::testGetByDate&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;RDVRepoTest::testGetByPAtientAndDate&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;RDVRepoTest::testGetAll&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;StaticRepoTest::testCheckParam&lt;/li&gt;&lt;/ul&gt;" 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">case</span><span class="default">&nbsp;</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="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;MedecinRepoTest::testAddAndDelete&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;PatientRepoTest::testAddAndDeletePatient&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;PatientRepoTest::testUpdate&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;StaticRepoTest::testCheckParam&lt;/li&gt;&lt;/ul&gt;" 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$checker</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">$checker</span><span class="default">&nbsp;</span><span class="default">&amp;&amp;</span><span class="default">&nbsp;</span><span class="default">is_string</span><span class="keyword">(</span><span class="default">$variable</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="default">&amp;&amp;</span><span class="default">&nbsp;</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="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;MedecinRepoTest::testAddAndDelete&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;PatientRepoTest::testAddAndDeletePatient&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;PatientRepoTest::testUpdate&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;StaticRepoTest::testCheckParam&lt;/li&gt;&lt;/ul&gt;" 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$checker</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">$checker</span><span class="default">&nbsp;</span><span class="default">&amp;&amp;</span><span class="default">&nbsp;</span><span class="default">is_string</span><span class="keyword">(</span><span class="default">$variable</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="default">&amp;&amp;</span><span class="default">&nbsp;</span><span class="default">in_array</span><span class="keyword">(</span><span class="default">$variable</span><span class="keyword">,</span><span class="default">&nbsp;</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="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;MedecinRepoTest::testAddAndDelete&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;PatientRepoTest::testAddAndDeletePatient&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;PatientRepoTest::testUpdate&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;StaticRepoTest::testCheckParam&lt;/li&gt;&lt;/ul&gt;" 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;[2]&nbsp;Chaine&nbsp;de&nbsp;caractère&nbsp;(longueur&nbsp;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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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!'
]));
}
}
}

View File

@ -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!'
]));
}
}
}

View File

@ -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'
]));
}
}
}

View File

@ -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']){