ANNEXE
150
Quelques pages web de l'application
1. Boite de connexion
151
2. Pages web
152
153
Les écritures du code
Entité Departement
<?php
namespace Library\Entities;
class Departement extends
\Library\Entity { protected $Libelle_Dept, $Id_Section;
const LIBELLEDEPT_INVALIDE = 0;
const IDSECTION INVALIDE = 1;
_
public function isValid(){
return
!(empty($this->Libelle_Dept)||empty($this->Id_Section));
}
public function setLibelle_Dept($Libelle_Dept){
if (!is_string($Libelle_Dept))
{
$this->erreurs[] = self::LIBELLEDEPT_INVALIDE;
}
else
{
$this->Libelle_Dept=$Libelle_Dept;
}
}
public function setId_Section($Id_Section){
if (!is_int($Id_Section))
{
}
else
{
}
$this->erreurs[] = self::IDSECTION_INVALIDE;
$this->Id_Section=$Id_Section;
}
public function Libelle_Dept(){
return $this->Libelle_Dept;
}
public function Id_Section(){
return $this->Id_Section;
}
}
?>
}
154
Manager Departement
<?php
namespace Library\Models;
use Library\Entities\Departement;
abstract class DepartementManager
extends \Library\Manager {
abstract public function count();
abstract protected function add(Departement
$departement); abstract protected function modify(Departement
$departement); public function save(Departement
$departement)
{
if ($departement->isValid())
{
$departement->isNew() ? $this->add($departement) :
$this->modify($departement);
}
else
{
throw new \RuntimeException('Le
département doit être validé pour être
enregistré');
}
}
abstract public function getList($debut = -1,
$limite = -1); abstract public function getDetail($debut = -1,
$limite = -1); abstract public function getUnique($id);
}
?>
Manager Departement PDO
<?php
namespace Library\Models;
use Library\Entities\Departement;
class DepartementManager_PDO
extends DepartementManager {
public function count(){
return $this->dao->query('SELECT
COUNT(*) FROM table_classe')->fetchColumn();
}
protected function add(Departement
$departement){
$requete = $this->dao->prepare('INSERT INTO
table_departement SET Libelle_Dept =:libelle_dept, Id_Section=:id_section');
$requete->bindValue(':libelle_dept',
$departement- >Libelle_Dept());
$requete->bindValue(':id_section',
$departement->Id_Section()); $requete->execute();
}
protected function modify(Departement
$departement){
$requete = $this->dao->prepare('UPDATE table_departement
SET Libelle_Dept =:libelle_dept, Id_Section=:id_section WHERE Id_Dept =
:id');
$requete->bindValue(':libelle_dept',
$departement- >Libelle_Dept());
$requete->bindValue(':id_section',
$departement->Id_Section()); $requete->bindValue(':id',
$departement->id(), \PDO::PARAM_INT); $requete->execute();
155
public function getList($debut = -1, $limite =
-1){
$sql = 'SELECT Id_Dept as id,Libelle_Dept, Id_Section FROM
table_departement ORDER BY Id_Dept DESC';
if ($debut != -1 || $limite != -1)
{
$sql .= ' LIMIT '.(int) $limite.' OFFSET '.(int) $debut;
}
$requete = $this->dao->query($sql);
$requete->setFetchMode(\PDO::FETCH_CLASS |
\PDO::FETCH_PROPS_LATE, '\Library\Entities\Departement');
$listeDepartement = $requete->fetchAll();
$requete->closeCursor(); return
$listeDepartement;
}
public function getDetail($debut = -1, $limite =
-1){
$sql = 'SELECT Id_Dept as id,Libelle_Dept, b.Libelle_Section FROM
table_departement as a inner join table_section as b on
a.Id_Section=b.Id_Section';
if ($debut != -1 || $limite != -1)
{
$sql .= ' LIMIT '.(int) $limite.' OFFSET '.(int) $debut;
}
$requete = $this->dao->query($sql);
$requete->setFetchMode(\PDO::FETCH_CLASS |
\PDO::FETCH_PROPS_LATE, '\Library\ViewModels\DepartementView');
$listeDepartement = $requete->fetchAll();
$requete->closeCursor(); return
$listeDepartement;
}
public function getUnique($id){
$requete = $this->dao->prepare('SELECT Id_Dept as
id,Libelle_Dept, Id_Section FROM table_departement WHERE Id_Dept = :id');
$requete->bindValue(':id', (int) $id, \PDO::PARAM_INT);
$requete->execute();
$requete->setFetchMode(\PDO::FETCH_CLASS |
\PDO::FETCH_PROPS_LATE, '\Library\Entities\Departement');
if ($departement = $requete->fetch())
{
return $departement;
}
return null;
}
}
?>
156
Controlleur Departement
<?php
namespace
Applications\Backend\Modules\Departement;
class DepartementController
extends \Library\BackController{ public function
executeIndex(\Library\HTTPRequest $request)
{
$this->page->addVar('title', 'Gestion des
departements');
$manager = $this->managers->getManagerOf('Departement');
$this->page->addVar('listeDepartement', $manager->getDetail());
$this->page->addVar('nombreDepartement', $manager->count());
}
public function
executeUpdate(\Library\HTTPRequest $request)
{
if
($request->postExists('Libelle_Dept')||$request->postExists('Id_Section'))
{
$this->processForm($request);
}
else
{
$this->page->addVar('departement',
$this->managers->getManagerOf('Departement')->getUnique($request->getData('id')));
}
$this->page->addVar('title', 'Modification d\'un
departement');
$manager = $this->managers->getManagerOf('Section');
$this->page->addVar('listeSection', $manager->getlist());
}
public function
executeInsert(\Library\HTTPRequest $request)
{
if
($request->postExists('Libelle_Dept')||$request->postExists('Id_Section'))
{
$this->processForm($request);
}
$manager = $this->managers->getManagerOf('Section');
$this->page->addVar('listeSection', $manager->getlist());
$this->page->addVar('title', 'Ajout d\'un departement');
}
public function processForm(\Library\HTTPRequest
$request)
{
$Departement = new
\Library\Entities\Departement( array(
'Libelle_Dept' => $request-
>postData('Libelle_Dept'),
'Id_Section' => (int)$request-
>postData('Id_Section')
)
);
if ($request->postExists('id'))
157
{
$Departement->setId($request->postData('id'));
}
if ($Departement->isValid())
{
$this->managers->getManagerOf('Departement')->save($Departement);
$this->app->user()->setFlash($Departement->isNew() ?
'Le département a bien été ajouté
!' : 'Le département a bien été
modifié !');
$this->app->httpResponse()->redirect('/admin/departement');
}
else
{
$this->page->addVar('erreurs',
$Departement->erreurs());
}
$this->page->addVar('Departement', $Departement);
}
}
?>
Vues Departement
Formulaire de saisie département
<form class="formoid-default-skyblue"
style="background-color:#FFFFFF;font-size:14px;font-family:'Open
Sans','Helvetica
Neue','Helvetica',Arial,Verdana,sans-serif;color:#666666;max-width:480px;min-width:150px"
method="post">
<p style="text-align:center;">
<?php if (isset($erreurs) &&
in_array(\Library\Entities\Departement::LIBELLEDEPT_INVALIDE,
$erreurs)) echo 'Libellé
departement est invalide.<br />';
if (isset($erreurs) &&
in_array(\Library\Entities\Departement::IDSECTION_INVALIDE,
$erreurs)) echo 'La section est invalide.<br
/>';
?>
</p>
<table align="center">
<div class="title"><?php
if(isset($departement) && !$departement->isNew())
{
?><h2>Modifier Département</h2>
<?php
}
else
{
?>
<h2>Ajout Département</h2> <?php
}
?>
</div>
<tr>
<td> <input class="large" type="hidden"
name="id" value="<?php if
(isset($departement)) echo
$departement['id']; ?>"/></div>
158
<label class="title">Libellé
Département<span
class="required">*</span></label></td>
<td><input class="large" type="text"
name="Libelle_Dept"
required="required" value="<?php if
(isset($departement)) echo
$departement['Libelle_Dept']; ?>" placeholder="Libelle
Dept"/></td>
</tr>
<tr>
<td><label class="title">Section<span
class="required">*</span></label></td>
<td><span><select name="Id_Section"
required="required">
<option value="-1">Selectionner la
section</option>
<?php
if (isset($listeSection)&& !empty($listeSection)){
foreach ($listeSection as $section)
{
?>
<option value="<?php echo
$section->id();?>"<?php if
((isset($departement))&&(isset($section))&&($section-
>id()==$departement['Id_Section']) ){ echo
"selected";}?>> <?php echo
$section['Libelle_Section']?></option>
<?php }}else{echo "No data";}?>
</select><i></i></span></td>
</tr>
<tr>
<td></td>
<?php
if(isset($departement) && !$departement->isNew())
{
?>
<td> <div class="submit"><input
type="submit" value="Modifier"/></div></td>
<?php
}
else
{
?>
<td><div class="submit"><input
type="submit" value="Ajouter"/></div></td>
<?php
}
?>
</tr>
</table></form>
Vue d'insertion département
<?php require '_form.php';?>
</div>
<div class="footer"></div></div>
</div></div></div></div>
<div id="footer" role="contentinfo">
<p id="legal">Copyright © 2014 Herve
Lepeya. Tous droits réservés.</p></div>
<div role="navigation" id="navFull">
<ul><li class="active"><a href="/admin/"
class="scTrack:SRD:Nav:a01">Accueil</a> <ul><li
class="active"><a href="/admin/agence"
class="scTrack:SRD:Nav:h39">Classe</a><ul> <li
class="active"><a href="/admin/agence-insert.html"
class="scTrack:SRD:Nav:h40">Saisie Classe</a></li>
<li><a href="/admin/classe"
class="scTrack:SRD:Nav:h41">Liste Classe</a></li>
159
</ul></li>
<li ><a href="/admin/section"
class="scTrack:SRD:Nav:h43">Section</a>
<ul>
<li ><a href="/admin/section-insert.html"
class="scTrack:SRD:Nav:h44">Saisie
Section</a></li>
<li><a href="/admin/section"
class="scTrack:SRD:Nav:h44">Liste
Section</a></li>
</ul>
</li>
<li ><a href="/admin/departement"
class="scTrack:SRD:Nav:h43">Département</a>
<ul>
<li ><a
href="/admin/departement-insert.html"
class="scTrack:SRD:Nav:h44">Saisie
Département</a></li>
<li><a href="/admin/departement"
class="scTrack:SRD:Nav:h44">Liste
Département</a></li>
</ul>
</li>
<li ><a href="/admin/devise"
class="scTrack:SRD:Nav:h43">Cours</a>
<ul>
<li ><a href="/admin/devise-insert.html"
class="scTrack:SRD:Nav:h44">Saisie
Cours</a></li>
<li><a href="/admin/devise"
class="scTrack:SRD:Nav:h44">Liste Cours</a></li>
</ul>
</li>
<li ><a href="/admin/agent"
class="scTrack:SRD:Nav:h43">Profil Usager</a>
<ul>
<li ><a href="/admin/agent-insert.html"
class="scTrack:SRD:Nav:h44">Saisie
Profil</a></li>
<li><a href="/admin/agent"
class="scTrack:SRD:Nav:h44">Liste Profils</a></li>
</ul>
</li>
<li ><a href="/admin/ip"
class="scTrack:SRD:Nav:h43">IP</a>
<ul>
<li ><a href="/admin/ip-insert.html"
class="scTrack:SRD:Nav:h44">Saisie
IP</a></li>
<li><a href="/admin/ip"
class="scTrack:SRD:Nav:h44">Liste IP</a></li>
</ul>
</li>
</ul>
<li ><a href="/admin/session"
class="scTrack:SRD:Nav:h43">Session</a>
<ul>
<li ><a href="/admin/session"
class="scTrack:SRD:Nav:h44">Connectés</a></li>
</ul> </li>
<li><a href="/admin/changepassword.html"
class="scTrack:SRD:Nav:a03">Reglage</a> <ul>
<li><a href="/admin/changepassword.html"
class="scTrack:SRD:Nav:h44">Change Mot de Passe</a></li>
</ul>
</li>
</ul>
</div>
</div>
<script type="text/javascript">if(typeof PAYPAL !=
'undefined'){
PAYPAL.core.Navigation.init();
}</script></div><script type="text/javascript"
160
src="js/widgets.js"></script><script
type="text/javascript"
src="js/jquery.js"></script><script
type="text/javascript"
src="/js/passwordRecovery.js"></script><script
type="text/javascript"
src="js/hostedpayments.js"></script><script
type="text/javascript"
src="/js/pageBlockingUnsafeBrowsers.js"></script><script
type="text/javascript"
src="js/mid.js"></script><script
type="text/javascript">PAYPAL.tns.loginflow =
'p\x2fgen\x2flogin';PAYPAL.tns.flashLocation =
'https\x3a\x2f\x2fwww\x2epaypal\x2ecom\x2fen\x5fUS\x2fm\x2fmid\x2eswf';</scri
pt><script type="text/javascript"
src="js/bid.js"></script> <script
type="text/javascript">
</body></html>
Vue Liste département
<div class="datatable">
<div class="title"><h3>Il y a actuellement
<span><?php echo '<b></b>';
?></span></h3></div>
<div style="overflow: visible;"
class="tableWrapper" id="tableWrapperID"> <table
id="transactionTable" summary="Tableau de Envoi ."
align="center" border="0" cellpadding="0"
cellspacing="0">
<tr><th>Département</th><th>Section</th><th>Action</th></tr>
<?php
if(isset($listeDepartement) &&
$listeDepartement!=null ){
foreach ($listeDepartement as $departement)
{
echo '<tr><td>',
$departement['Libelle_Dept'], '</td><td>',
$departement['Libelle_Section'],'</td><td><a
href="departement-update-',
$departement['id'],
'.html">Editer</a></td></tr>', "\n";
}
}else{?>
<tr><td class="noResults"
headers="details" colspan="11"
nowrap="">-
Aucun nouvel objet -</td>
</tr>
<?php }
?>
</table>
</div>
</div>
</div>
<div class="footer"></div></div>
</div></div></div></div>
<div id="footer" role="contentinfo">
<p id="legal">Copyright © 2014 CRFI. Tous
droits
réservés.</p></div>
<div role="navigation" id="navFull">
<ul><li class="active"><a
href="/admin/"
class="scTrack:SRD:Nav:a01">Accueil</a>
<ul><li class="active"><a
href="/admin/agence"
class="scTrack:SRD:Nav:h39">Classe</a><ul>
<li class="active"><a
href="/admin/classe-insert.html"
class="scTrack:SRD:Nav:h40">Saisie
Classe</a></li>
<li><a href="/admin/classe"
class="scTrack:SRD:Nav:h41">Liste Classe</a></li>
</ul></li>
<li ><a href="/admin/section"
class="scTrack:SRD:Nav:h43">Section</a>
<ul>
<li ><a href="/admin/section-insert.html"
class="scTrack:SRD:Nav:h44">Saisie
Section</a></li>
161
<li><a href="/admin/section"
class="scTrack:SRD:Nav:h44">Liste Section</a></li>
</ul> </li> <li ><a
href="/admin/departement"
class="scTrack:SRD:Nav:h43">Département</a>
<ul>
<li ><a href="/admin/departement-insert.html"
class="scTrack:SRD:Nav:h44">Saisie
Département</a></li>
<li><a href="/admin/departement"
class="scTrack:SRD:Nav:h44">Liste
Département</a></li>
</ul>
</li>
<li ><a href="/admin/devise"
class="scTrack:SRD:Nav:h43">Cours</a>
<ul>
<li ><a href="/admin/devise-insert.html"
class="scTrack:SRD:Nav:h44">Saisie
Cours</a></li>
<li><a href="/admin/devise"
class="scTrack:SRD:Nav:h44">Liste Cours</a></li>
</ul>
</li>
<li ><a href="/admin/agent"
class="scTrack:SRD:Nav:h43">Profil Usager</a>
<ul>
<li ><a href="/admin/agent-insert.html"
class="scTrack:SRD:Nav:h44">Saisie
Profil</a></li>
<li><a href="/admin/agent"
class="scTrack:SRD:Nav:h44">Liste Profils</a></li>
</ul>
</li>
<li ><a href="/admin/ip"
class="scTrack:SRD:Nav:h43">IP</a>
<ul>
<li ><a href="/admin/ip-insert.html"
class="scTrack:SRD:Nav:h44">Saisie
IP</a></li>
<li><a href="/admin/ip"
class="scTrack:SRD:Nav:h44">Liste IP</a></li>
</ul>
</li>
</ul>
<li ><a href="/admin/session"
class="scTrack:SRD:Nav:h43">Session</a>
<ul>
<li ><a href="/admin/session"
class="scTrack:SRD:Nav:h44">Connectés</a></li>
</ul> </li>
<li><a href="/admin/changepassword.html"
class="scTrack:SRD:Nav:a03">Reglage</a> <ul>
<li><a href="/admin/changepassword.html"
class="scTrack:SRD:Nav:h44">Change Mot de Passe</a></li>
</ul>
</li> </ul> </div> </div>
<script type="text/javascript">if(typeof PAYPAL !=
'undefined'){ PAYPAL.core.Navigation.init();
}</script></div><script type="text/javascript"
src="js/widgets.js"></script><script type="text/javascript"
src="js/jquery.js"></script><script type="text/javascript"
src="/js/passwordRecovery.js"></script><script
type="text/javascript" src="js/hostedpayments.js"></script><script
type="text/javascript"
src="/js/pageBlockingUnsafeBrowsers.js"></script><script
162
type="text/javascript"
src="js/mid.js"></script><script
type="text/javascript">PAYPAL.tns.loginflow =
'p\x2fgen\x2flogin';PAYPAL.tns.flashLocation =
'https\x3a\x2f\x2fwww\x2epaypal\x2ecom\x2fen\x5fUS\x2fm\x2fmid\x2eswf';</scri
pt><script type="text/javascript"
src="js/bid.js"></script>
<script type="text/javascript">
function Code(n){
//alert(n.checked)
var active;
if(n.checked){
active=1;}
else
{
active=0;
}
$.ajax({
url: "/admin/agencestatus-"+n.value+"-"+active+".html",
beforeSend: function( xhr ) {
// xhr.overrideMimeType( "text/plain; charset=x-user-defined"
);
//xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
}
})
.done(function( data ) {
$( "#results" ).text(data);
if ( console && console.log ) {
console.log( "Sample of data:", data.slice( 0, 6000 ) );
}
})
.fail(function( jqXHR, textStatus ) {
alert( "Request failed: " + textStatus);
});
}
</script>
</body></html>
|