private function recursivegetpages($parent, $depth)
 {
     $output = array();
     $pageModel = new pageModel();
     $target = new securitytarget();
     $target->setId('menu');
     $pages = $pageModel->get(array('parentid' => array('mode' => '=', 'value' => $parent)), array('fields' => array('order'), 'type' => 'ASC'));
     foreach ($pages as $page) {
         $tmp = array();
         if (myacl::isAllowed(myauth::getCurrentuser(), $page, 'view') && myacl::isAllowed($page, $target, 'show', true)) {
             $tmp['page'] = $page;
             if ($depth < $this->maxdepth || $this->maxdepth == -1) {
                 $tmp['subpages'] = $this->recursivegetpages($page->getId(), $depth + 1);
             }
             if (count($tmp['subpages']) == 0) {
                 unset($tmp['subpages']);
                 $tmp['status_subpages'] = 'nosubpages';
             } else {
                 $tmp['status_subpages'] = "subpages";
             }
             if ($page->getId() == myauth::getCurrentpageid()) {
                 $tmp['status'] = 'active';
             } elseif (isset($this->tree_id[$page->getId()])) {
                 $tmp['status'] = 'subpage_active';
             } else {
                 $tmp['status'] = 'inactive';
             }
             $output[] = $tmp;
         }
     }
     return $output;
 }
 public function lijst($parameters)
 {
     $starget = new securitytarget();
     $starget->setId('voorinschrijving_lijst');
     if (!myacl::isAllowed(myauth::getCurrentuser(), $starget, 'view')) {
         return;
     }
     $template = new ui($this);
     $uurModel = new uurModel();
     $ingeschrevenModel = new ingeschrevenModel();
     $trajectModel = new trajectModel();
     $userModel = new userModel();
     $form = new form($parameters);
     $select = new selectField('wat', '', '');
     $select->addOption(new selectoptionField('Alles', '9990'));
     $daggroup = new selectoptgroupField('Dagen');
     $daggroup->addOption(new selectoptionField('Zaterdag', '6661'));
     $daggroup->addOption(new selectoptionField('Zondag', '4442'));
     $select->addOptgroup($daggroup);
     $trajecten = $trajectModel->get();
     $trajectgroup = new selectoptgroupField('Trajecten');
     foreach ($trajecten as $tr) {
         $trajectgroup->addOption(new selectoptionField($tr->getName(), 888 . $tr->getId()));
     }
     $select->addOptgroup($trajectgroup);
     $typegroup = new selectoptgroupField('Type');
     $typegroup->addOption(new selectoptionField('Personeel', '1114'));
     $typegroup->addOption(new selectoptionField('VIP', '1115'));
     $select->addOptgroup($typegroup);
     $uren = $uurModel->get();
     $uurgroup = new selectoptgroupField('Uren - Zaterdag');
     $uurgroup2 = new selectoptgroupField('Uren - Zondag');
     foreach ($uren as $uur) {
         if ($uur->getDag() == 1) {
             $uurgroup->addOption(new selectoptionField($uur->getUur(), 777 . $uur->getId()));
         } else {
             $uurgroup2->addOption(new selectoptionField($uur->getUur(), 555 . $uur->getId()));
         }
     }
     $select->addOptgroup($uurgroup);
     $select->addOptgroup($uurgroup2);
     $form->addField($select);
     $template->assign('form', $form);
     $terug = new pagerequest(1);
     $template->assign('terug', $terug);
     if (!$form->isSent()) {
         $wat = 9990;
     } else {
         $wat = $form->getFieldvalue('wat');
     }
     $mode = substr($wat, 0, 3);
     $modevalue = substr($wat, 3);
     if ($mode == 999 || $mode == 888) {
         $dag = 0;
     } elseif ($mode == 777 || $mode == 666) {
         $dag = 1;
     } elseif ($mode == 555 || $mode == 444) {
         $dag = 2;
     }
     if ($dag == 0) {
         $lijst[0]['dag'] = 'Zaterdag';
         $lijst[1]['dag'] = 'Zondag';
     } elseif ($dag == 1) {
         $lijst[0]['dag'] = 'Zaterdag';
     } elseif ($dag == 2) {
         $lijst[1]['dag'] = 'Zondag';
     }
     foreach ($lijst as $dag => $lijstelement) {
         $dag++;
         if ($mode == 888) {
             $uurCond = array('AND' => array('dag' => array('mode' => '=', 'value' => $dag), 'trajectid' => array('mode' => '=', 'value' => $modevalue)));
         } elseif ($mode == 777 || $mode == 555) {
             $uurCond = array('AND' => array('id' => array('mode' => '=', 'value' => $modevalue)));
         } else {
             $uurCond = array('AND' => array('dag' => array('mode' => '=', 'value' => $dag)));
         }
         $uren = $uurModel->get($uurCond);
         foreach ($uren as $uur) {
             $tempuur = array();
             $tempuur['uur'] = $uur;
             $gasten = $ingeschrevenModel->getfromUurid($uur->getId());
             $tempuur['aantal'] = 0;
             foreach ($gasten as $gast) {
                 $tempgast = array();
                 $tempgast['gast'] = $gast;
                 if ($mode == 111) {
                     if ($gast->getUserid() != $modevalue) {
                         continue;
                     }
                 }
                 if ($gast->getRegistrationtime() > time() - 60 * 60 * 24) {
                     $tempgast['new'] = 'true';
                 } else {
                     $tempgast['new'] = 'false';
                 }
                 $sameip = $ingeschrevenModel->getfromIpaddress($gast->getIpaddress());
                 if (count($sameip) > 1) {
                     $tempgast['sameip']['aantal'] = count($sameip);
                     $tempgast['sameip']['wie'] = $sameip;
                     $showrequest = new ajaxrequest('myvoorinschrijving', 'showsameip', array('id' => $gast->getId()));
                     $hiderequest = new ajaxrequest('myvoorinschrijving', 'hidesameip', array('id' => $gast->getId()));
                     $tempgast['sameip']['showrequest'] = $showrequest;
                     $tempgast['sameip']['hiderequest'] = $hiderequest;
                 } else {
                     $tempgast['sameip'] = 0;
                 }
                 $showmorerequest = new ajaxrequest('myvoorinschrijving', 'showmore', array('id' => $gast->getId()));
                 $hidemorerequest = new ajaxrequest('myvoorinschrijving', 'hidemore', array('id' => $gast->getId()));
                 $tempgast['showmorerequest'] = $showmorerequest;
                 $tempgast['hidemorerequest'] = $hidemorerequest;
                 $deleterequest = new ajaxrequest('myvoorinschrijving', 'deletegast', array('gastid' => $gast->getId()));
                 $tempgast['deleterequest'] = $deleterequest;
                 $user = $userModel->getfromId($gast->getUserid());
                 $tempgast['user'] = $user[0];
                 $tempuur['aantal'] += $gast->getAantal();
                 $tempuur['gasten'][] = $tempgast;
             }
             if (count($tempuur['gasten']) > 0) {
                 if (!isset($lijst[$dag - 1]['trajecten'][$uur->getTrajectid()]['traject'])) {
                     $traject = $trajectModel->getfromId($uur->getTrajectid());
                     $lijst[$dag - 1]['trajecten'][$uur->getTrajectid()]['traject'] = $traject[0];
                 }
                 $lijst[$dag - 1]['trajecten'][$uur->getTrajectid()]['uren'][] = $tempuur;
             }
         }
     }
     foreach ($lijst as $id => $dag) {
         if (count($dag['trajecten']) == 0) {
             unset($lijst[$id]);
         }
     }
     $template->assign('lijst', $lijst);
     $this->response->assign($this->self, 'innerHTML', $template->fetch('myvoorinschrijving_lijst.tpl'));
 }