Nur komm ich bei der bildung der view nicht weiter.
um folgende sql frage geht es.
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:
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
<?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')]); } } }
<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
var_dumpkommt NULL.
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