Nur komm ich bei der bildung der view nicht weiter.
um folgende sql frage geht es.
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 | public function getProzent($clan) { $entryArray = $this->db()->select() ->fields(['id', 'clan', 'clan_id', 'prozentgrund', 'prozentwert']) ->from(['activities_prozent_berechnung']) ->where(['clan_id' => $clan]) ->execute() ->fetchRows(); if (empty($entryArray)) { return []; } $prozent = []; foreach ($entryArray as $entries) { $entryModel = new FactorModel(); $entryModel->setId($entries['id']); $entryModel->setClan($entries['clan']); $entryModel->setClanID($entries['clan_id']); $entryModel->setProzentgrund($entries['prozentgrund']); $entryModel->setProzentwert($entries['prozentwert']); $prozent[] = $entryModel; } return $prozent; } |
welche ja direkt im sql so aussieht als bsp:
1 | SELECT `id`,`clan`,`clan_id`,`prozentgrund`,`prozentwert` FROM `ilch_activities_prozent_berechnung` WHERE `clan_id` = "500022074" |
Wie gesagt im phpmyadmin geht es, bekomm auch die werte alle zurück.
jetzt kommt die php vom controller dazu und die view
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 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | <?php /** * @copyright Ilch 2.0 * @package ilch */ namespace Modules\Activitiesconfig\Controllers\Admin; use Modules\Activitiesconfig\Mappers\Factor as FactorMapper; use Modules\Activitiesconfig\Models\Factor as FactorModel; use Modules\wargamingauth\Mappers\User as WGUserMapper; use Ilch\Validation; class Factors extends \Ilch\Controller\Admin { public function init() { $items = [ [ 'name' => 'overview' , 'active' => false, 'icon' => 'fa fa-microchip' , 'url' => $this ->getLayout()->getUrl([ 'controller' => 'index' , 'action' => 'index' ]) ], [ 'name' => 'factors' , 'active' => false, 'icon' => 'fas fa-calculator' , 'url' => $this ->getLayout()->getUrl([ 'controller' => 'factors' , 'action' => 'index' ]) ] ]; if ( $this ->getRequest()->getActionName() == 'treat' ) { $items [1][ 'active' ] = true; } else { $items [1][ 'active' ] = true; } $this ->getLayout()->addMenu ( 'menuTeams' , $items ); } public function indexAction() { $this ->getLayout()->getAdminHmenu() ->add( $this ->getTranslator()->trans( 'menuActivities' ), [ 'controller' => 'index' , 'action' => 'index' ]) ->add( $this ->getTranslator()->trans( 'menuFactors' ), [ 'action' => 'factors' ]); $FactorMapper = new FactorMapper(); $wargamingUserMapper = new WGUserMapper(); $FactorMapper ->activitie_insert(); $FactorMapper ->rank_insert(); $FactorMapper ->prozent_insert(); if ( $FactorMapper ->getCount_of_activitie() != 0 AND $FactorMapper ->getCount_of_ranks() != 0 AND $FactorMapper ->getCount_of_prozent() != 0) { if (isset ( $_SESSION [ 'user_id' ])) { $user_id = $_SESSION [ 'user_id' ]; } else { $user_id = '' ; } //echo "<hr>";var_dump($wargamingUserMapper->getWGUserbyID($user_id)); die(); $this ->getView()->set( 'wguser' , $wargamingUserMapper ->getWGUserbyID( $user_id )); $this ->getView()->set( 'clans' , $FactorMapper ->getClans_from_List()); } } public function factorsAction() { $FactorMapper = new FactorMapper(); $wargamingUserMapper = new WGUserMapper(); if ( $this ->getRequest()->getParam( 'clan_id' )) { $this ->getLayout()->getAdminHmenu() ->add( $this ->getTranslator()->trans( 'menuFactors' ), [ 'controller' => 'factors' , 'action' => 'index' ]) ->add( $this ->getTranslator()->trans( 'edit' ), [ 'action' => 'treat' ]); if (isset ( $_SESSION [ 'user_id' ])) { $user_id = $_SESSION [ 'user_id' ]; } else { $user_id = '' ; } //echo "<hr>";var_dump($wargamingUserMapper->getWGUserbyID($user_id)); die(); $this ->getView()->set( 'wguser' , $wargamingUserMapper ->getWGUserbyID( $user_id )); $this ->getView()->set( 'factors_activitie' , $FactorMapper ->getFactors_Activitie( $this ->getRequest()->getPost( 'clan_id' ))); $this ->getView()->set( 'factors_rank' , $FactorMapper ->getFactors_Rank( $this ->getRequest()->getPost( 'clan_id' ))); $this ->getView()->set( 'faktor_prozent' , $FactorMapper ->getProzent( $this ->getRequest()->getParam( 'clan_id' ))); //$this->getView()->set('factors', $FactorMapper->getFactors($this->getRequest()->getParam('clan'))); } else { $this ->getLayout()->getAdminHmenu() ->add( $this ->getTranslator()->trans( 'menuActivities' ), [ 'controller' => 'factors' , 'action' => 'index' ]) ->add( $this ->getTranslator()->trans( 'add' ), [ 'action' => 'treat' ]); } } public function treat_rankAction() { $FactorMapper = new FactorMapper(); if ( $this ->getRequest()->getParam( 'id' )) { $this ->getLayout()->getAdminHmenu() ->add( $this ->getTranslator()->trans( 'menuFactor' ), [ 'action' => 'index' ]) ->add( $this ->getTranslator()->trans( 'edit' ), [ 'action' => 'treat_rank' ]); $this ->getView()->set( 'rank' , $FactorMapper ->getRankFactorByID( $this ->getRequest()->getParam( 'id' ))); } else { $this ->getLayout()->getAdminHmenu() ->add( $this ->getTranslator()->trans( 'menuVote' ), [ 'action' => 'index' ]); //->add($this->getTranslator()->trans('add'), ['action' => 'treat']); } if ( $this ->getRequest()->isPost()) { $validation = Validation::create( $this ->getRequest()->getPost(), [ 'factor' => 'required' ]); if ( $validation ->isValid()) { $factorModel = new FactorModel(); if ( $this ->getRequest()->getParam( 'id' )) { $factorModel ->setId( $this ->getRequest()->getParam( 'id' )); $factorModel ->setClan( $this ->getRequest()->getParam( 'clan' )); $factorModel ->setClanID( $this ->getRequest()->getParam( 'clan_id' )); } $factorModel ->setFactor( $this ->getRequest()->getPost( 'factor' )); $FactorMapper ->editFactor_Ranks( $factorModel ); $this ->redirect() /** ->withMessage('saveSuccess') **/ ->to([ 'action' => 'factors' , 'clan' => $this ->getRequest()->getPost( 'clan' ), 'clan_id' => $this ->getRequest()->getPost( 'clan_id' )]); } $this ->addMessage( $validation ->getErrorBag()->getErrorMessages(), 'danger' , true); $this ->redirect() ->withInput() ->withErrors( $validation ->getErrorBag()) ->to([ 'action' => 'treat_rank' , 'id' => $this ->getRequest()->getParam( 'id' )]); } } public function treat_activitieAction() { $FactorMapper = new FactorMapper(); if ( $this ->getRequest()->getParam( 'id' )) { $this ->getLayout()->getAdminHmenu() ->add( $this ->getTranslator()->trans( 'menuFactor' ), [ 'action' => 'index' ]) ->add( $this ->getTranslator()->trans( 'edit' ), [ 'action' => 'treat_rank' ]); $this ->getView()->set( 'activitie' , $FactorMapper ->getActivitieFactorByID( $this ->getRequest()->getParam( 'id' ))); } else { $this ->getLayout()->getAdminHmenu() ->add( $this ->getTranslator()->trans( 'menuVote' ), [ 'action' => 'index' ]); //->add($this->getTranslator()->trans('add'), ['action' => 'treat']); } if ( $this ->getRequest()->isPost()) { $validation = Validation::create( $this ->getRequest()->getPost(), [ 'factor' => 'required' ]); if ( $validation ->isValid()) { $factorModel = new FactorModel(); if ( $this ->getRequest()->getParam( 'id' )) { $factorModel ->setId( $this ->getRequest()->getParam( 'id' )); $factorModel ->setClan( $this ->getRequest()->getPost( 'clan' )); $factorModel ->setClanID( $this ->getRequest()->getPost( 'clan_id' )); } $factorModel ->setFactor( $this ->getRequest()->getPost( 'factor' )); $FactorMapper ->editFactor_Activitie( $factorModel ); $this ->redirect() /** ->withMessage('saveSuccess') **/ ->to([ 'action' => 'factors' , 'clan' => $this ->getRequest()->getPost( 'clan' ), 'clan_id' => $this ->getRequest()->getPost( 'clan_id' )]); } $this ->addMessage( $validation ->getErrorBag()->getErrorMessages(), 'danger' , true); $this ->redirect() ->withInput() ->withErrors( $validation ->getErrorBag()) ->to([ 'action' => 'treat_activitie' , 'id' => $this ->getRequest()->getParam( 'id' )]); } } public function treat_prozentAction() { $FactorMapper = new FactorMapper(); if ( $this ->getRequest()->getParam( 'id' )) { $this ->getLayout()->getAdminHmenu() ->add( $this ->getTranslator()->trans( 'menuFactor' ), [ 'action' => 'index' ]) ->add( $this ->getTranslator()->trans( 'edit' ), [ 'action' => 'treat_rank' ]); $this ->getView()->set( 'prozent' , $FactorMapper ->getProzentByID( $this ->getRequest()->getParam( 'id' ))); } else { $this ->getLayout()->getAdminHmenu() ->add( $this ->getTranslator()->trans( 'menuVote' ), [ 'action' => 'index' ]); //->add($this->getTranslator()->trans('add'), ['action' => 'treat']); } if ( $this ->getRequest()->isPost()) { $validation = Validation::create( $this ->getRequest()->getPost(), [ 'prozentwert' => 'required' ]); if ( $validation ->isValid()) { $factorModel = new FactorModel(); if ( $this ->getRequest()->getParam( 'id' )) { $factorModel ->setId( $this ->getRequest()->getParam( 'id' )); $factorModel ->setClan( $this ->getRequest()->getParam( 'clan' )); $factorModel ->setClanID( $this ->getRequest()->getParam( 'clan_id' )); } $factorModel ->setProzentwert( $this ->getRequest()->getPost( 'prozentwert' )); $FactorMapper ->editProzent( $factorModel ); $this ->redirect() /** ->withMessage('saveSuccess') **/ ->to([ 'action' => 'factors' , 'clan' => $this ->getRequest()->getPost( 'clan' ), 'clan_id' => $this ->getRequest()->getPost( 'clan_id' )]); } $this ->addMessage( $validation ->getErrorBag()->getErrorMessages(), 'danger' , true); $this ->redirect() ->withInput() ->withErrors( $validation ->getErrorBag()) ->to([ 'action' => 'treat_prozent' , 'id' => $this ->getRequest()->getParam( 'id' )]); } } } |
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 | <link href= "<?=$this->getModuleUrl('static/css/teams.css') ?>" rel= "stylesheet" > <h1> <?php echo $this ->getTrans( 'factors' ); ?> <?php $factors_activitie = $this ->get( 'factors_activitie' ); ?> <?php $factors_rank = $this ->get( 'factors_rank' ); ?> <a class = "badge" data-toggle= "modal" data-target= "#infoModal" > <i class = "fa fa-info" ></i> </a> </h1> <form class = "form-horizontal" method= "POST" enctype= "multipart/form-data" > <?= $this ->getTokenField() ?> <br> <fieldset> <label> <div align= "center" ><h1><?=( $this ->getRequest()->getParam( 'clan' )) ?></h1></div> </label> </fieldset> <br> <br> <fieldset style= "border: 1px solid #EEEEEE;padding: 10px;" > <legend><?= $this ->getTrans( 'ranks' ) ?>:</legend> <?php foreach ( $factors_rank as $rank ):?> <div class = "form-group" > <input type= "hidden" id= "id" name= "id" value= "<?=$rank->getId();?>" /> <input type= "hidden" id= "tabelle" name= "tabelle" value= "activities_factor_ranks" /> <label class = "col-lg-2" > <?= $this ->getTrans( $rank ->getMember_Role()) ?>: </label> <div class = "col-lg-2" > <?= $this ->escape( $rank ->getFactor()) ?> </div> <div><?= $this ->getEditIcon([ 'action' => 'treat_rank' , 'id' => $rank ->getId(), 'clan' => $rank ->getClanID()]) ?></div> </div> <?php endforeach ;?> </fieldset> <br> <fieldset style= "border: 1px solid #EEEEEE;padding: 10px;" > <legend><?= $this ->getTrans( 'activitie' ) ?>:</legend> <?php $willi = '' ; ?> <?php foreach ( $factors_activitie as $activitie ): ?> <input type= "hidden" id= "id" name= "id" value= "<?=$activitie->getId();?>" /> <input type= "hidden" id= "tabelle" name= "tabelle" value= "activities_factor_activitie" /> <?php if ( $willi != $activitie ->getModus()){ $willi = $activitie ->getModus(); ?> <legend><?= $this ->getTrans( $activitie ->getModus()) ?>:</legend> <?php } ?> <div class = "form-group" > <label class = "col-lg-2" > <?= $activitie ->getActivitie() ?> </label> <div class = "col-lg-2" > <?= $this ->escape( $activitie ->getFactor()) ?> </div> <div><?= $this ->getEditIcon([ 'action' => 'treat_activitie' , 'id' => $activitie ->getId(), 'clan' => $activitie ->getClanID()]) ?></div> </div> <?php endforeach ;?> </fieldset> <?php $prozentb = $this ->get( 'faktor_prozent' ); ?> <fieldset style= "border: 1px solid #EEEEEE;padding: 10px;" > <?php var_dump( $prozentb ); ?> <legend><?= $this ->getTrans( 'prozent' ) ?>:</legend> <?php foreach ( $prozentb as $prozent ):?> <div class = "form-group" > <input type= "hidden" id= "id" name= "id" value= "<?=$prozent->getId();?>" /> <input type= "hidden" id= "tabelle" name= "tabelle" value= "activities_prozent_berechnung" /> <label class = "col-lg-2" > <?= $this ->getTrans( $prozent ->getProzentgrund()) ?>: </label> <div class = "col-lg-2" > <?= $this ->escape( $prozent ->getProzentwert()) ?> </div> <div><?= $this ->getEditIcon([ 'action' => 'treat_prozent' , 'id' => $prozent ->getId(), 'clan' => $prozent ->getClanID()]) ?></div> </div> <?php endforeach ;?> </fieldset> </form> |
alle anderen aufgeführten dinge gehen, also rank und faktors nur die prozent nicht.
und bei dem
1 | var_dump |
ich versteh es nicht mehr. was falsch läuft.
verwendete ilch Version: 2.1.x
betroffene Homepage: www.r1sing.de
EDIT: kann entfernt werden. ich bin mit meinen Controller Dateien durcheinander gekommen. und hab das in die falsche rein geschrieben. kein wunder, das er diese änderung nicht genommen hat.
Zuletzt modifiziert von magicmarkus am 17.08.2019 - 20:39:13