public function editMessage($parameters = array())
 {
     $view = new ui($this);
     require FRAMEWORK . DS . 'conf' . DS . 'medibridgeparser.php';
     $view->assign('basesourcemap', $basesourcemap);
     $view->assign('backupmap', $backupmap);
     $view->assign('errormap', $errormap);
     $view->assign('basedestinationmap', $basedestinationmap);
     $closerequest = new ajaxrequest('medibridgeparser', 'closeLog');
     $view->assign('closerequest', $closerequest);
     $pmodel = new mbprocessedlogModel();
     $model = new mblogModel();
     $log = $model->getfromId($parameters['logid']);
     $plog = $pmodel->getfromId($parameters['logid']);
     if (count($log) == 1) {
         $log = $log[0];
     }
     if (count($plog) == 1) {
         $plog = $plog[0];
     }
     $view->assign('log', $log);
     $view->assign('plog', $plog);
     $location = '';
     if ($log->getStatusdelivery() == 'DELIVERY_SUCCESS' && $log->getStatusbackup() == 'BACKUP_SUCCES') {
         $location = $backupmap . '\\' . $log->getRelativebackuppath();
     } elseif ($log->getStatusdelivery() == 'MESSAGE_RESEND' && $log->getStatusbackup() == 'BACKUP_SUCCES') {
         $location = $backupmap . '\\' . $log->getRelativebackuppath();
     } elseif ($log->getStatuserror() == 'ERROR_MOVE_SUCCESS') {
         $location = $errormap . '\\' . $log->getRelativeerrorpath();
     } else {
         $location = 'GEEN BESTAND GEVONDEN!';
     }
     $destination = $basesourcemap . '\\' . $log->getRelativesourcepath();
     $view->assign('sourcelocation', $location);
     $view->assign('destination', $destination);
     $file = utf8_encode(file_get_contents($location));
     $form = new form($parameters);
     $form->addField(new hiddenField('logid', $parameters['logid']));
     $doktermodel = new mbdokterModel();
     $dokters = $doktermodel->get(array(), array('fields' => array('achternaam'), 'mode' => 'ASC'));
     $select = new selectField('ontvanger', 'Verzet ontvanger naar');
     $select->addOption(new selectoptionField('Niet verzetten', 'none'));
     foreach ($dokters as $dokter) {
         $select->addOption(new selectoptionField($dokter->getAchternaam() . ' ' . $dokter->getVoornaam() . ' - ' . $dokter->getRiziv(), $dokter->getRiziv()));
     }
     $form->addField($select);
     $form->addField(new textareaField('content', 'Bericht', $file, array('required')));
     $view->assign('form', $form);
     $ignorerequest = new ajaxrequest('medibridgeparser', 'ignorelog', array('logid' => $parameters['logid']));
     $view->assign('ignore', $ignorerequest);
     if ($form->validate()) {
         try {
             file_put_contents($location, $form->getFieldvalue('content'));
             $arrcontent = file($location, FILE_IGNORE_NEW_LINES);
             if ($form->getFieldvalue('ontvanger') != 'none') {
                 if (stripos($location, 'hdm-lab') !== false) {
                     $i = 0;
                     foreach ($arrcontent as $fileline) {
                         if (stripos($fileline, 'A4') === 0) {
                             $parts = explode('\\', $fileline);
                             $parts[2] = $form->getFieldvalue('ontvanger');
                             $fileline = implode('\\', $parts);
                             $arrcontent[$i] = rtrim($fileline);
                             break;
                         } else {
                             $arrcontent[$i] = rtrim($fileline);
                         }
                         $i++;
                     }
                 } else {
                     $arrcontent[7] = $form->getFieldvalue('ontvanger');
                 }
             }
             $i = 0;
             foreach ($arrcontent as $fileline) {
                 $arrcontent[$i] = rtrim($fileline);
                 $i++;
             }
             file_put_contents($location, implode("\r\n", $arrcontent));
             if (!rename($location, $destination)) {
                 throw new Exception('Could not move file.');
             }
             $log->setStatusdelivery('MESSAGE_RESEND');
             $model->save($log);
             $this->response->redirect('?pageid=' . myauth::getCurrentpageid());
         } catch (Exception $e) {
             $this->response->assign('formerror_' . $form->getId(), 'innerHTML', 'Er was een probleem met het verwerken van de aanpassingen! (' . $e->getMessage() . ')', true);
         }
     } elseif (!$form->isSent()) {
         $this->response->assign('logcontainer', 'innerHTML', $view->fetch($parameters['viewprefix'] . 'medibridgeparser_editmessage.tpl'));
     }
 }
 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'));
 }
Esempio n. 3
0
 public function wikieditversion($parameters = array())
 {
     $view = new ui($this);
     $articlemodel = new myarticleModel();
     $versionmodel = new myarticleversionModel();
     $version = $versionmodel->getfromId($parameters['id']);
     if (count($version) == 1) {
         $version = $version[0];
         $form = new mygridform($parameters, $parameters['-gridid-'], 'edit');
         $form->addField(new textField('title', 'Titel', $version->getTitle(), array('required')));
         $form->addField(new hiddenField('start', time()));
         $form->addField(new hiddenField('alias', $parameters['alias']));
         $form->addField(new hiddenField('limit', ''));
         $form->addField(new hiddenField('stop', -1));
         $form->addField(new hiddenField('section', $parameters['section']));
         $form->addField(new rteField('content', 'Inhoud', $version->getContent(), array('required')));
         $draft = new selectField('state', 'Bewaar als', array('required'));
         $draft->addOption(new selectoptionField('Actieve versie', 'Actief', true));
         $draft->addOption(new selectoptionField('Draft', 'Draft', false));
         $form->addField($draft);
         $form->addField(new hiddenField('articleid', $parameters['articleid']));
         $form->addField(new hiddenField('id', $parameters['id']));
         if ($form->validate()) {
             $newversion = new myarticleversionObject();
             $newversion->setArticleid($parameters['articleid']);
             $newversion->setAuthor(myauth::getCurrentuser()->getId());
             $newversion->setAuthorname(myauth::getCurrentuser()->getName());
             $newversion->setCreationdate(time());
             $newversion->setTitle($form->getFieldvalue('title'));
             $newversion->setState($form->getFieldvalue('state'));
             $newversion->setStartpublishdate($form->getFieldvalue('start'));
             $newversion->setContent($form->getFieldvalue('content'));
             if ($form->getFieldvalue('limit') == 'limit') {
                 $newversion->setStoppublishdate($form->getFieldvalue('stop'));
             } else {
                 $newversion->setStoppublishdate(-1);
             }
             try {
                 if ($form->getFieldvalue('state') == 'Actief') {
                     $articleidcond = array('articleid' => array('mode' => '=', 'value' => $parameters['articleid']));
                     $statecond = array('state' => array('mode' => '=', 'value' => 'Actief'));
                     $prevactive = $versionmodel->get(array('AND' => array($articleidcond, $statecond)));
                     foreach ($prevactive as $prev) {
                         // This could have been if equal to 1 and just do the one, but this method is "self-healing" if multiple versions get flagged active
                         $prev->setState('Gearchiveerd');
                         $versionmodel->save($prev);
                     }
                 }
                 $versionmodel->save($newversion);
             } catch (Exception $e) {
                 $flash = new popupController();
                 $flash->createflash(array('name' => 'erroredit', 'type' => 'error', 'content' => 'De gegevens werden niet aangepast! Raadpleeg de informaticadienst.'));
                 return false;
             }
             $flash = new popupController();
             $flash->createflash(array('name' => 'flash_add_' . $parameters['-gridid-'], 'type' => 'success', 'content' => 'De gegevens zijn goed aangepast.'));
             $this->response->assign('gridextra_' . $parameters['-gridid-'], 'innerHTML', '');
             return true;
         } elseif (!$form->isSent()) {
             $view->assign('form', $form);
             return $view->fetch('myarticle_editversion.tpl');
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 public function showstatus($parameters = array())
 {
     $view = new ui($this);
     $dienstmodel = new keukendienstModel();
     $kamermodel = new keukenkamerModel();
     $diensten = $dienstmodel->get();
     $adiensten = array();
     $kamercond = array();
     foreach ($diensten as $dienst) {
         if (myacl::isAllowed(myauth::getCurrentuser(), $dienst, 'view')) {
             $adiensten[$dienst->getId()] = $dienst;
         }
     }
     if (count($adiensten > 1)) {
         $form = new form($parameters);
         $select = new selectField('dienst', 'Dienst', array('required'), true);
         $select->addOption(new selectoptionField('Alles', '_all_', true));
         foreach ($adiensten as $id => $dienst) {
             $select->addOption(new selectoptionField($dienst->getName(), $id));
         }
         $form->addField($select);
         $continue = true;
         if ($form->validate()) {
             $all = false;
             foreach ($form->getFieldvalue('dienst') as $id) {
                 $chosendienst[$id] = $adiensten[$id];
                 if ($id == '_all_') {
                     $all = true;
                     break;
                 }
             }
             if (!$all) {
                 $adiensten = $chosendienst;
             }
             $view->assign('form', $form);
         } elseif (!$form->isSent()) {
             $view->assign('form', $form);
         } else {
             $continue = false;
         }
     }
     if ($continue) {
         foreach ($adiensten as $id => $dienst) {
             $kamers = $kamermodel->getfromDienstid($id);
             foreach ($kamers as $kamer) {
                 $kamercond[] = array('kamer' => array('mode' => '=', 'value' => $kamer->getKamernr()));
             }
         }
         if (count($kamercond) > 0) {
             $kamercond = array('OR' => $kamercond);
         } else {
             //Geen kamers, lege lijst voorzien
             $kamercond = array('kamer' => array('mode' => '=', 'value' => '-1'));
         }
         $model = new keukenpatientModel();
         $count = $model->getcount($kamercond);
         $view->assign('count', $count);
         $grid = new mygrid('keukenstatus');
         $grid->setModel($model);
         $grid->setDefaultconditions($kamercond);
         $grid->setDefaultorder(array('fields' => array('kamer', 'bed'), 'type' => 'ASC'));
         $grid->registerEditrequest('keukenpakket', 'editPatient', array('title' => 'Maaltijdfiche aanpassen', 'id' => '{id}'));
         $grid->setPagesize(999);
         $view->assign('grid', $grid);
         $this->response->assign($this->self, 'innerHTML', $view->fetch('keukenpakket_showstatus.tpl'));
     }
 }
Esempio n. 5
0
 public function showbedbezgraph($parameters = array())
 {
     $view = new ui($this);
     $starttime = isset($parameters['starttime']) ? $parameters['starttime'] : strtotime('-1 months');
     $endtime = isset($parameters['endtime']) ? $parameters['endtime'] : time();
     $dienst = $parameters['dienst'];
     $form = new form($parameters);
     $form->addField(new hiddenField('dienst', $parameters['dienst']));
     $dienstmodel = new keukendienstModel();
     $diensten = $dienstmodel->get();
     $adiensten = array();
     $select = new selectField('dienst', 'Dienst', array('required'));
     $select->addOption(new selectoptionField('Alles', '_all_', $dienst == '_all_' ? true : false));
     foreach ($diensten as $dienstobj) {
         //if(myacl::isAllowed(myauth::getCurrentuser(),$dienst,'countstats')){
         $select->addOption(new selectoptionField($dienstobj->getName(), $dienstobj->getDienstnr(), $dienst == $dienstobj->getDienstnr() ? true : false));
         //}
     }
     $form->addField($select);
     $form->addField(new datepickerField('starttime', 'Startdatum', false, $starttime, array('required')));
     $form->addField(new datepickerField('endtime', 'Einddatum', false, $endtime, array('required')));
     if ($form->validate()) {
         $view->assign('dienst', $parameters['dienst']);
         $view->assign('starttime', $starttime);
         $view->assign('endtime', $endtime);
         $view->assign('closerequest', new ajaxrequest('mystats', 'closebedbezgraph'));
         $view->assign('form', $form);
         $this->response->assign('bedbezgraph', 'innerHTML', $view->fetch('mystats_showbedbezgraph.tpl'));
     } elseif (!$form->isSent()) {
         $view->assign('dienst', $parameters['dienst']);
         $view->assign('starttime', $starttime);
         $view->assign('endtime', $endtime);
         $view->assign('closerequest', new ajaxrequest('mystats', 'closebedbezgraph'));
         $view->assign('form', $form);
         $this->response->assign('bedbezgraph', 'innerHTML', $view->fetch('mystats_showbedbezgraph.tpl'));
     } else {
     }
 }
Esempio n. 6
0
 public function addTicket($parameters = array())
 {
     require FRAMEWORK . DS . 'conf' . DS . 'myticket.php';
     require FRAMEWORK . DS . 'conf' . DS . 'mycafetaria.php';
     $view = new ui($this);
     $form = new form($parameters);
     $currentuser = myauth::getCurrentuser();
     $currentname = '';
     $groups = $currentuser->getGroupid();
     if (!isset($groups[$algemenegebruikers])) {
         $currentname = $currentuser->getName();
     }
     if (!isset($groups[$externgroup])) {
         $pricefield = 'price';
     } else {
         $pricefield = 'price2';
     }
     $form->addField(new suggesttextField('myticket', 'listusers', 'contact', 'Uw naam', $currentname, array('required')));
     $dienstveld = new selectField('dienst', 'Dienst', array('required'));
     $groupmodel = new groupModel();
     $diensten = array();
     foreach ($groups as $groupid) {
         $group = $groupmodel->getfromId($groupid);
         if (count($group) == 1) {
             $group = $group[0];
             $groupmemberof = $group->getMemberof();
             $flipped = array_flip($groupmemberof);
             if (isset($flipped[$meldinggroep])) {
                 $diensten[$group->getId()] = $group->getDescription();
             }
         }
     }
     if (count($diensten) > 1) {
         $dienstveld->addOption(new selectoptionField('', '', true));
         asort($diensten);
         foreach ($diensten as $id => $desc) {
             $dienstveld->addOption(new selectoptionField($desc, $id, false));
         }
     } else {
         foreach ($diensten as $id => $desc) {
             $dienstveld->addOption(new selectoptionField($desc, $id, true));
         }
     }
     $form->addField($dienstveld);
     $to = new selectField('to', 'Melding aan', array('required'));
     $to->addOption(new selectoptionField('', ''));
     $meldingdienstenmodel = new meldingdienstenModel();
     $meldingdiensten = $meldingdienstenmodel->get();
     foreach ($meldingdiensten as $meldingdienst) {
         $to->addOption(new selectoptionField($meldingdienst->getName(), $meldingdienst->getId()));
     }
     $form->addField($to);
     $form->addField(new textField('titel', 'Titel', '', array('required')));
     $form->addField(new textareaField('message', 'Melding', '', array('required')));
     if ($form->validate()) {
         $ticket = new myticketObject();
         $ticket->setDienstid($form->getFieldvalue('dienst'));
         $ticket->setTo($form->getFieldvalue('to'));
         $ticket->setContact($form->getFieldvalue('contact'));
         $ticket->setTitel($form->getFieldvalue('titel'));
         $ticket->setMessage($form->getFieldvalue('message'));
         $ticket->setPlacedby($currentuser->getId());
         $ticket->setTime(time());
         $ticket->setStatus('Created');
         $ticket->setUser($currentuser->getName());
         $dienst = $groupmodel->getfromId($form->getFieldvalue('dienst'));
         $ticket->setDienst($dienst[0]->getDescription());
         $to = $meldingdienstenmodel->getfromId($form->getFieldvalue('to'));
         $ticket->setToname($to[0]->getName());
         $ticketmodel = new myticketModel();
         $saved = true;
         try {
             $ticketmodel->save($ticket);
         } catch (Exception $e) {
             $saved = false;
         }
         $mailed = $this->mail($ticket);
         if ($mailed) {
             $ticket->setStatus('Mailed');
             $ticketmodel->save($ticket);
         }
         $this->listmytickets();
         $message = new ui($this);
         $message->assign('saved', $saved);
         $message->assign('mailed', $mailed);
         if ($saved && $mailed) {
             $type = 'success';
         } elseif ($saved) {
             $type = 'error';
         } elseif ($mailed) {
             $type = 'warning';
         } else {
             $type = 'error';
         }
         $popupcontroller = new popupController();
         $popupcontroller->createflash(array('name' => 'flash_melding', 'type' => $type, 'content' => $message->fetch('myticket_saveflash.tpl')));
     } elseif (!$form->isSent()) {
         $view->assign('form', $form);
         $this->response->assign($this->self, 'innerHTML', $view->fetch('myticket_addTicket.tpl'));
     }
 }
 public function buildeditform($parameters = array())
 {
     $form = new mygridform($parameters, $parameters['-gridid-'], 'edit', 'mymoduleadmin', 'editmodule');
     $form->setPhasedrequest(new ajaxrequest('mymoduleadmin', 'updateeditform'));
     $themodule = $parameters['themodule'];
     if (isset($parameters['__field__'])) {
         $changedfield = $parameters['__field__'];
         $form->setFocusfield($changedfield);
     }
     $form->addField(new hiddenField('moduleid', $parameters['moduleid']));
     $title = isset($parameters['name']) ? $parameters['name'] : $themodule->getTitle();
     $form->addField(new textField('name', 'Titel', $title, array('required')));
     $mod = isset($parameters['module']) ? $parameters['module'] : $themodule->getName();
     $modules = $this->getModulelist();
     $moduleselect = new selectField('module', 'Module', array('required'));
     foreach ($modules as $module => $description) {
         $selected = $module == $mod ? true : false;
         $moduleselect->addOption(new selectoptionField($module, $module, $selected, $description));
     }
     $form->addField($moduleselect);
     $act = isset($parameters['moduleaction']) ? $parameters['moduleaction'] : $themodule->getAction();
     $actions = $this->getActions($mod);
     $actionselect = new selectField('moduleaction', 'Actie', array('required'));
     if (!isset($actions[$act])) {
         $act = $themodule->getAction();
         if (!isset($actions[$act])) {
             $actionselect->addOption(new selectoptionField('', '', true));
         }
     }
     foreach ($actions as $action => $actionconf) {
         $selected = $action == $act ? true : false;
         $actionselect->addOption(new selectoptionField($action, $action, $selected, $actionconf['description']));
     }
     $form->addField($actionselect);
     $options = $this->getOptions($mod, $act);
     $args = $themodule->getArguments();
     foreach ($options as $option => $values) {
         $tmp = new selectField($option, $option, array('required'));
         $opt = isset($parameters[$option]) ? $parameters[$option] : $args[$option];
         foreach ($values as $id => $name) {
             $selected = $id == $opt ? true : false;
             $tmp->addOption(new selectoptionField($name, $id, $selected));
         }
         $form->addField($tmp);
     }
     return $form;
 }
 public function addpromotext($parameters = array())
 {
     $view = new ui($this);
     $form = new mygridform($parameters, $parameters['-gridid-'], 'edit');
     $form->addField(new textField('title', 'Titel', '', array('required')));
     $form->addField(new textField('alias', 'Werktitel', ''));
     $form->addField(new datepickerField('start', 'Gepubliceerd van', true, '', array('required')));
     $form->addField(new hiddenField('limit', 'limit'));
     $form->addField(new datepickerField('stop', 'Gepubliceerd tot', true, '', array('required')));
     $form->addField(new rteField('content', 'Inhoud', '', array('required')));
     $draft = new selectField('state', 'Bewaar als', array('required'));
     $draft->addOption(new selectoptionField('Actieve versie', 'Actief', true));
     $draft->addOption(new selectoptionField('Draft', 'Draft', false));
     $form->addField($draft);
     $form->addField(new hiddenField('sectionid', $parameters['sectionid']));
     if ($form->validate()) {
         $newarticle = new myarticleObject();
         $newarticle->setAuthor(myauth::getCurrentuser()->getId());
         $newarticle->setAuthorname(myauth::getCurrentuser()->getName());
         $newarticle->setCreationdate(time());
         if ($form->getFieldvalue('alias') != '') {
             $newarticle->setAlias($form->getFieldvalue('alias'));
         } else {
             $newarticle->setAlias($form->getFieldvalue('title'));
         }
         $newversion = new myarticleversionObject();
         $newversion->setAuthor($newarticle->getAuthor());
         $newversion->setAuthorname($newarticle->getAuthorname());
         $newversion->setCreationdate($newarticle->getCreationdate());
         $newversion->setTitle($form->getFieldvalue('title'));
         $newversion->setState($form->getFieldvalue('state'));
         $newversion->setStartpublishdate($form->getFieldvalue('start'));
         $newversion->setContent($form->getFieldvalue('content'));
         if ($form->getFieldvalue('limit') == 'limit') {
             $newversion->setStoppublishdate($form->getFieldvalue('stop'));
         } else {
             $newversion->setStoppublishdate(-1);
         }
         try {
             $articlemodel = new myarticleModel();
             $versionmodel = new myarticleversionModel();
             $linkmodel = new myarticlesectionlinkModel();
             $articlemodel->save($newarticle);
             $newversion->setArticleid($newarticle->getId());
             $versionmodel->save($newversion);
             $newlink = new myarticlesectionlinkObject();
             $newlink->setArticleid($newarticle->getId());
             $newlink->setSectionid($parameters['sectionid']);
             $newlink->setOrder($linkmodel->getmax('order', array('sectionid' => array('mode' => '=', 'value' => $parameters['sectionid']))) + 1);
             $linkmodel->save($newlink);
         } catch (Exception $e) {
             $flash = new popupController();
             $flash->createflash(array('name' => 'erroredit', 'type' => 'error', 'content' => 'De gegevens werden niet toegevoegd! Raadpleeg de informaticadienst.'));
             return false;
         }
         $flash = new popupController();
         $flash->createflash(array('name' => 'flash_add_' . $parameters['-gridid-'], 'type' => 'success', 'content' => 'De gegevens zijn goed toegevoegd.'));
         $this->response->assign('gridextra_' . $parameters['-gridid-'], 'innerHTML', '');
         return true;
     } elseif (!$form->isSent()) {
         $view->assign('form', $form);
         return $view->fetch('myarticle_addarticle.tpl');
     } else {
         return false;
     }
 }