1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
| <?php
class module_evaluations extends abstract_moduleembedded{
public static $sModuleName='evaluations';
public static $sRootModule;
public static $tRootParams;
public function __construct(){
self::setRootLink(_root::getParamNav(),null);
}
public static function setRootLink($sRootModule,$tRootParams=null){
self::$sRootModule=$sRootModule;
self::$tRootParams=$tRootParams;
}
public static function getLink($sAction,$tParam=null){
return parent::_getLink(self::$sRootModule,self::$tRootParams,self::$sModuleName,$sAction,$tParam);
}
public static function getParam($sVar,$uDefault=null){
return parent::_getParam(self::$sModuleName,$sVar,$uDefault);
}
public static function redirect($sModuleAction,$tModuleParam=null){
return parent::_redirect(self::$sRootModule,self::$tRootParams,self::$sModuleName,$sModuleAction,$tModuleParam);
}
/*
Pour integrer au sein d'un autre module:
//instancier le module
$oModuleevaluations=new module_evaluations();
//si vous souhaitez indiquer au module integrable des informations sur le module parent
//$oModuleevaluations->setRootLink('module::action',array('parametre'=>_root::getParam('parametre')));
//recupere la vue du module
$oViewModule=$oModuleevaluations->_index();
//assigner la vue retournee a votre layout
$this->oLayout->add('main',$oViewModule);
*/
public function _index(){
$sAction='_'.self::getParam('Action','list');
return $this->$sAction();
}
public function _list(){
if(_root::getRequest()->isPost()){
$oEval=new row_evaluations;
$oEval->eleve_id=module_eleves::getParam('id');
$oEval->machine_id=_root::getParam('machine_id');
$oEval->niveau=_root::getParam('niveau_id');
$oEval->date=date('Y-m-d');
$oEval->prof_id=_root::getAuth()->getAccount()->id;
$oEval->save();
}
$tEvaluations=model_evaluations::getInstance()->findAllByEleve( '15');
$oView=new _view('evaluations::list');
$oView->tEvaluations=$tEvaluations;
$oView->tJoinmodel_machines=model_machines::getInstance()->getSelect();
$oView->tJoinmodel_users=model_users::getInstance()->getSelect();
//$oView->tMachines=model_machines::getInstance()->findAllByAtelier(module_eleves::getParam('id'));
$oView->tEvaluationsIndexed=model_evaluations::getInstance()->findListIndexed(module_eleves::getParam('id'));
$oView->tProf=model_users::getInstance()->getSelectAllProfs();
//ici
$oView->tMachines=model_machines::getInstance()->getSelectMachineByAtelier(module_eleves::getParam('id'));
$oView->tNiveaux=model_niveaux::getInstance()->getSelect();
return $oView;
}
public function _new(){
$tMessage=$this->save();
$oevaluations=new row_evaluations;
$oView=new _view('evaluations::new');
$oView->oevaluations=$oevaluations;
$oPluginXsrf=new plugin_xsrf();
$oView->token=$oPluginXsrf->getToken();
$oView->tMessage=$tMessage;
return $oView;
}
public function _edit(){
$tMessage=$this->save();
$oevaluations=model_evaluations::getInstance()->findById( module_evaluations::getParam('id') );
$oView=new _view('evaluations::edit');
$oView->oevaluations=$oevaluations;
$oView->tId=model_evaluations::getInstance()->getIdTab();
$oView->tJoinmodel_machines=model_machines::getInstance()->getSelect();
$oPluginXsrf=new plugin_xsrf();
$oView->token=$oPluginXsrf->getToken();
$oView->tMessage=$tMessage;
return $oView;
}
public function _show(){
$oevaluations=model_evaluations::getInstance()->findById( module_evaluations::getParam('id') );
$oView=new _view('evaluations::show');
$oView->oevaluations=$oevaluations;
$oView->tJoinmodel_machines=model_machines::getInstance()->getSelect();
return $oView;
}
public function _delete(){
$tMessage=$this->delete();
$oevaluations=model_evaluations::getInstance()->findById( module_evaluations::getParam('id') );
$oView=new _view('evaluations::delete');
$oView->oevaluations=$oevaluations;
$oView->tJoinmodel_machines=model_machines::getInstance()->getSelect();
$oPluginXsrf=new plugin_xsrf();
$oView->token=$oPluginXsrf->getToken();
$oView->tMessage=$tMessage;
return $oView;
}
public function save(){
if(!_root::getRequest()->isPost() or _root::getParam('formmodule')!=self::$sModuleName ){ //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=module_evaluations::getParam('id',null);
if($iId==null){
$oEvaluations=new row_evaluations;
}else{
$oEvaluations=model_evaluations::getInstance()->findById( module_evaluations::getParam('id',null) );
}
$tId=model_evaluations::getInstance()->getIdTab();
$tColumn=model_evaluations::getInstance()->getListColumn();
foreach($tColumn as $sColumn){
if(isset($_FILES[$sColumn]) and $_FILES[$sColumn]['size'] > 0){
$sNewFileName='data/upload/'.$sColumn.'_'.date('Ymdhis');
$oPluginUpload=new plugin_upload($_FILES[$sColumn]);
$oPluginUpload->saveAs($sNewFileName);
$oEvaluations->$sColumn=$oPluginUpload->getPath();
continue;
}else if( _root::getParam($sColumn,null) === null ){
continue;
}else if( in_array($sColumn,$tId)){
continue;
}
$oEvaluations->$sColumn=_root::getParam($sColumn,null) ;
}
if($oEvaluations->save()){
//une fois enregistre on redirige (vers la page liste)
$this->redirect('list');
}else{
return $oEvaluations->getListError();
}
}
public function delete(){
if(!_root::getRequest()->isPost() or _root::getParam('formmodule')!=self::$sModuleName){ //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() );
}
$oevaluations=model_evaluations::getInstance()->findById( module_evaluations::getParam('id',null) );
$oevaluations->delete();
//une fois enregistre on redirige (vers la page liste)
$this->redirect('list');
}
}
/*variables
#select $oView->tJoinevaluations=evaluations::getInstance()->getSelect();#fin_select
#uploadsave if(isset($_FILES[$sColumn]) and $_FILES[$sColumn]['size'] > 0){
$sNewFileName='data/upload/'.$sColumn.'_'.date('Ymdhis');
$oPluginUpload=new plugin_upload($_FILES[$sColumn]);
$oPluginUpload->saveAs($sNewFileName);
$oevaluations->$sColumn=$oPluginUpload->getPath();
continue;
}else #fin_uploadsave
variables*/ |
Partager