Voici ma classe model
<?php
class model_saisir extends abstract_model{
protected $sClassRow='row_saisir';
protected $sTable='saisir';
protected $sConfig='PE';
protected $tId=array('id');
public static function getInstance(){
return self::_getInstance(__CLASS__);
}
public function findByUsersId($id){
return $this->findMany('SELECT * FROM '.$this->sTable.' WHERE user_id=?',$id );
}
public function findById($uId){
return $this->findOne('SELECT * FROM '.$this->sTable.' WHERE id=?',$uId );
}
public function findAll(){
return $this->findMany('SELECT * FROM '.$this->sTable);
}
public function findAllAdmin(){
return $this->findMany('SELECT * FROM '.$this->sTable);
}
}
class row_saisir extends abstract_row{
protected $sClassModel='model_saisir';
/*exemple jointure
public function findAuteur(){
return model_auteur::getInstance()->findById($this->auteur_id);
}
*/
/*exemple test validation*/
private function getCheck(){
$oPluginValid=new plugin_valid($this->getTab());
/* renseigner vos check ici
$oPluginValid->isEqual('champ','valeurB','Le champ n\est pas égal à '.$valeurB);
$oPluginValid->isNotEqual('champ','valeurB','Le champ est égal à '.$valeurB);
$oPluginValid->isUpperThan('champ','valeurB','Le champ n\est pas supé à '.$valeurB);
$oPluginValid->isUpperOrEqualThan('champ','valeurB','Le champ n\est pas supé ou égal à '.$valeurB);
$oPluginValid->isLowerThan('champ','valeurB','Le champ n\est pas inférieur à '.$valeurB);
$oPluginValid->isLowerOrEqualThan('champ','valeurB','Le champ n\est pas inférieur ou égal à '.$valeurB);
$oPluginValid->isEmpty('champ','Le champ n\'est pas vide');
$oPluginValid->isNotEmpty('champ','Le champ ne doit pas être vide');
$oPluginValid->isEmailValid('champ','L\email est invalide');
$oPluginValid->matchExpression('champ','/[0-9]/','Le champ n\'est pas au bon format');
$oPluginValid->notMatchExpression('champ','/[a-zA-Z]/','Le champ ne doit pas être a ce format');
$oPluginValid->matchExpression('prn_aas','/[0-9]/','Le champ n\'est pas au bon format');
*/
return $oPluginValid;
}
public function isValid(){
return $this->getCheck()->isValid();
}
public function getListError(){
return $this->getCheck()->getListError();
}
public function save(){
if(!$this->isValid()){
return false;
}
parent::save();
return true;
}
}
Voici la class main de mon module saisir
class module_saisir extends abstract_module{
public function before(){
$this->oLayout=new _layout('bootstrap');
$this->oLayout->addModule('menu','menu::index');
}
public function _index(){
//on considere que la page par defaut est la page de listage
$this->_list();
}
public function _list(){
$id=_root::getAuth()->getAccount()->id;
if ($id===1) {
$oSaisir=model_saisir::getInstance()->findAllAdmin();
} else {
$oSaisir=model_saisir::getInstance()->findByUsersId($id);
}
$oView=new _view('saisir::list');
$oView->oSaisir=$oSaisir;
$oView->tJoinmodel_users=model_users::getInstance()->getSelect();
$this->oLayout->add('main',$oView);
}
public function _new(){
$tMessage=$this->processSave();
$oSaisir=new row_saisir;
$oView=new _view('saisir::new');
$oView->oSaisir=$oSaisir;
$oPluginXsrf=new plugin_xsrf();
$oView->token=$oPluginXsrf->getToken();
$oView->tMessage=$tMessage;
$this->oLayout->add('main',$oView);
}
public function _edit(){
$tMessage=$this->processSave();
$oSaisir=model_saisir::getInstance()->findById( _root::getParam('id') );
$oView=new _view('saisir::edit');
$oView->oSaisir=$oSaisir;
$oView->tId=model_saisir::getInstance()->getIdTab();
$oPluginXsrf=new plugin_xsrf();
$oView->token=$oPluginXsrf->getToken();
$oView->tMessage=$tMessage;
$this->oLayout->add('main',$oView);
}
public function _show(){
$oSaisir=model_saisir::getInstance()->findById( _root::getParam('id') );
$oView=new _view('saisir::show');
$oView->oSaisir=$oSaisir;
$this->oLayout->add('main',$oView);
}
public function _delete(){
$tMessage=$this->processDelete();
$oSaisir=model_saisir::getInstance()->findById( _root::getParam('id') );
$oView=new _view('saisir::delete');
$oView->oSaisir=$oSaisir;
$oPluginXsrf=new plugin_xsrf();
$oView->token=$oPluginXsrf->getToken();
$oView->tMessage=$tMessage;
$this->oLayout->add('main',$oView);
}
private function processSave(){
if(!_root::getRequest()->isPost() ){ //si ce n'est pas une requete POST on ne soumet pas
return null;
}
$oPluginXsrf=new plugin_xsrf();
if(!$oPluginXsrf->checkToken( _root::getParam('token') ) ){ //on verifie que le token est valide
return array('token'=>$oPluginXsrf->getMessage() );
}
$iId=_root::getParam('id',null);
if($iId==null){
$oSaisir=new row_saisir;
}else{
$oSaisir=model_saisir::getInstance()->findById( _root::getParam('id',null) );
}
$tColumn=array('user_id','saisir_date','saisir_absence','dysf_panne_info','observations','prn_aas','prn_pas','prn_personnel','prn_rejet','prn_signalement','recla_medialog','recla_eptica','recla_bal','recla_diad','recla_ass','courrier_ave','courrier_sanction50','courrier_sanction100','courrier_retour','autres_pj_diad','autres_lm2a','autres_destin','autres_ij_amexa','autres_indus','autres_rejet_diad','autres_solde_papier','dsij_auto','dsij_manuel','kdc_paiement','kdc_rejets','pe_non_subro_mal','pe_non_subro_mat_pat','pe_non_subro_pamc','pe_subro_mal','pe_subro_mat_pat','pe_subro_ij_personnel','echeancier_ok','echeancier_rejet','echeancier_relance');
foreach($tColumn as $sColumn){
$oSaisir->$sColumn=_root::getParam($sColumn,null) ;
}
if($oSaisir->save()){
//une fois enregistre on redirige (vers la page liste)
_root::redirect('saisir::list');
}else{
return $oSaisir->getListError();
}
}
public function processDelete(){
if(!_root::getRequest()->isPost() ){ //si ce n'est pas une requete POST on ne soumet pas
return null;
}
$oPluginXsrf=new plugin_xsrf();
if(!$oPluginXsrf->checkToken( _root::getParam('token') ) ){ //on verifie que le token est valide
return array('token'=>$oPluginXsrf->getMessage() );
}
$oSaisir=model_saisir::getInstance()->findById( _root::getParam('id',null) );
$oSaisir->delete();
//une fois enregistre on redirige (vers la page liste)
_root::redirect('saisir::list');
}
public function after(){
$this->oLayout->show();
}
}
voici la vue
<?php
$oForm=new plugin_form($this->oSaisir);
$oForm->setMessage($this->tMessage);
?>
<header class="page-header">
<h2 class="text-center">GROUPE IJ - FICHE STATISTIQUES JOURNALIERES</h2>
</header>
<form class="form-inline" action="" method="POST" >
<section class="row">
<form class="form-inline">
<div class="form-group">
<label class="control-label">En date du</label>
<?php echo $oForm->getInputText('saisir_date',array('class'=>'form-control text-center')) ?>
</div>
<div class="form-group">
<label class="control-label">, absence</label>
<?php echo $oForm->getInputText('saisir_absence',array('class'=>'form-control text-center','placeholder'=> '0.5 ou 1')) ?>
</div>
<div class="form-group">
<label class="control-label">, avec dysfonctionnement et/ou panne informatique</label>
<?php echo $oForm->getInputText('dysf_panne_info',array('class'=>'form-control text-center','placeholder'=> 'en minutes')) ?>
</div>
</form>
</section>
<p> </p>
<section class="row">
<div class="form-group">
<label class="sr-only" for="observations">Observations</label>
<?php echo $oForm->getInputTextarea('observations',array('class'=>'form-control text-center','id'=>'observations','placeholder'=> 'Observations')) ?>
</div>
</section>
<div class="row ">
<section class="col-sm-4 table-responsive">
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th colspan="2" class="text-center"><h4>PRN</h4></th>
</tr>
</thead>
<tbody>
<tr>
<td>AAS</td>
<td><?php echo $oForm->getInputText('prn_aas',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>PAS</td>
<td><?php echo $oForm->getInputText('prn_pas',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>PERSONNEL</td>
<td><?php echo $oForm->getInputText('prn_personnel',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>REJET</td>
<td><?php echo $oForm->getInputText('prn_rejet',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>SIGNALEMENT</td>
<td><?php echo $oForm->getInputText('prn_signalement',array('class'=>'form-control text-center')) ?></td>
</tr>
</tbody>
</table>
</section>
<section class="col-sm-4 table-responsive">
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th colspan="2" class="text-center"><h4>AUTRES</h4></th>
</tr>
</thead>
<tbody>
<tr>
<td>PJ DIADEME</td>
<td><?php echo $oForm->getInputText('autres_pj_diad',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>LM2A</td>
<td><?php echo $oForm->getInputText('autres_lm2a',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>DESTIN</td>
<td><?php echo $oForm->getInputText('autres_destin',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>IJ AMEXA</td>
<td><?php echo $oForm->getInputText('autres_ij_amexa',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>INDUS</td>
<td><?php echo $oForm->getInputText('autres_indus',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>REJETS DIADEME</td>
<td><?php echo $oForm->getInputText('autres_rejet_diad',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>SOLDE PAPIER</td>
<td><?php echo $oForm->getInputText('autres_solde_papier',array('class'=>'form-control text-center')) ?></td>
</tr>
</tbody>
</table>
</section>
<section class="col-sm-4 table-responsive">
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th colspan="2" class="text-center"><h4>NON SUBRO</h4></th>
</tr>
</thead>
<tbody>
<tr>
<td>MAL</td>
<td><?php echo $oForm->getInputText('pe_non_subro_mal',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>MAT / PAT</td>
<td><?php echo $oForm->getInputText('pe_non_subro_mat_pat',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>PAMC</td>
<td><?php echo $oForm->getInputText('pe_non_subro_pamc',array('class'=>'form-control text-center')) ?></td>
</tr>
</tbody>
</table>
</section>
</div>
<div class="row ">
<section class="col-sm-4 table-responsive">
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th colspan="2" class="text-center"><h4>RECLAMATIONS</h4></th>
</tr>
</thead>
<tbody>
<tr>
<td>MEDIALOG</td>
<td><?php echo $oForm->getInputText('recla_medialog',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>EPTICA</td>
<td><?php echo $oForm->getInputText('recla_eptica',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>BAL RECLA</td>
<td><?php echo $oForm->getInputText('recla_bal',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>RECLA DIADEME</td>
<td><?php echo $oForm->getInputText('recla_diad',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>RECLA ASSURE</td>
<td><?php echo $oForm->getInputText('recla_ass',array('class'=>'form-control text-center')) ?></td>
</tr>
</tbody>
</table>
</section>
<section class="col-sm-4 table-responsive">
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th colspan="2" class="text-center"><h4>DSIJ</h4></th>
</tr>
</thead>
<tbody>
<tr>
<td>AUTO</td>
<td><?php echo $oForm->getInputText('dsij_auto',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>MANUEL</td>
<td><?php echo $oForm->getInputText('dsij_manuel',array('class'=>'form-control text-center')) ?></td>
</tr>
</tbody>
</table>
</section>
<section class="col-sm-4 table-responsive">
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th colspan="2" class="text-center"><h4>SUBRO</h4></th>
</tr>
</thead>
<tbody>
<tr>
<td>MAL</td>
<td><?php echo $oForm->getInputText('pe_subro_mal',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>MAT / PAT</td>
<td><?php echo $oForm->getInputText('pe_subro_mat_pat',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>IJ PERSONNEL</td>
<td><?php echo $oForm->getInputText('pe_subro_ij_personnel',array('class'=>'form-control text-center')) ?></td>
</tr>
</tbody>
</table>
</section>
</div>
<div class="row ">
<section class="col-sm-4 table-responsive">
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th colspan="2" class="text-center"><h4>COURRIERS</h4></th>
</tr>
</thead>
<tbody>
<tr>
<td>AVE</td>
<td><?php echo $oForm->getInputText('courrier_ave',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>SANCTION 50</td>
<td><?php echo $oForm->getInputText('courrier_sanction50',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>SANCTION 100</td>
<td><?php echo $oForm->getInputText('courrier_sanction100',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>RETOUR COURRIER</td>
<td><?php echo $oForm->getInputText('courrier_retour',array('class'=>'form-control text-center')) ?></td>
</tr>
</tbody>
</table>
</section>
<section class="col-sm-4 table-responsive">
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th colspan="2" class="text-center"><h4>KDC</h4></th>
</tr>
</thead>
<tbody>
<tr>
<td>PAIEMENT</td>
<td><?php echo $oForm->getInputText('kdc_paiement',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>REJETS/td>
<td><?php echo $oForm->getInputText('kdc_rejets',array('class'=>'form-control text-center')) ?></td>
</tr>
</tbody>
</table>
</section>
<section class="col-sm-4 table-responsive">
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th colspan="2" class="text-center"><h4>ECHEANCIER</h4></th>
</tr>
</thead>
<tbody>
<tr>
<td>OK</td>
<td><?php echo $oForm->getInputText('echeancier_ok',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>REJET</td>
<td><?php echo $oForm->getInputText('echeancier_rejet',array('class'=>'form-control text-center')) ?></td>
</tr>
<tr>
<td>RELANCE</td>
<td><?php echo $oForm->getInputText('echeancier_relance',array('class'=>'form-control text-center')) ?></td>
</tr>
</tbody>
</table>
</section>
</div>
</div>
<?php echo $oForm->getToken('token',$this->token)?>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" class="btn btn-success" value="Ajouter" /> <a class="btn btn-link" href="<?php echo $this->getLink('saisir::list')?>">Annuler</a>
</div>
</div>
</form>
dites moi pourquoi lorsque j'appuie sur Ajouter rien ne se passe?
Partager