public function getHtmlOutput(\Zend_View_Abstract $view) { $this->_initView($view); $main = $this->creator->div(array('class' => 'panel panel-default', 'id' => 'trackwrapper', 'renderClosingTag' => true)); $main->div(array('id' => 'modalpopup', 'renderClosingTag' => true)); $model = $this->getModel(); $model->trackUsage(); $items = array('gto_id_respondent_track', 'gto_valid_from', 'gto_valid_until', 'gr2t_start_date', 'gtr_track_name', 'gr2t_track_info', 'gto_id_token', 'gto_round_description', 'forgroup', 'gsu_survey_name', 'gto_completion_time', 'gr2o_patient_nr', 'gr2o_id_organization', 'gro_icon_file', 'gto_icon_file'); foreach ($items as $item) { $model->get($item); } $data = $model->load(true, $this->_fixedSort); $lastDate = null; $lastDescription = null; $doelgroep = null; $now = new \MUtil_Date(); $today = $now->get($this->_dateFormat); $progressDiv = null; $respTrackId = 0; $trackProgress = null; $currentOrg = $this->loader->getCurrentUser()->getCurrentOrganizationId(); $allowedOrgs = $this->loader->getCurrentUser()->getAllowedOrganizations(); // The normal loop foreach ($data as $row) { if ($respTrackId !== $row['gto_id_respondent_track']) { if (isset($day) && new \MUtil_Date($lastDate, 'dd-MM-y') < $now) { $day->class .= ' today'; unset($day); } $progressDiv = $this->finishGroup($progressDiv); $this->finishTrack($trackProgress); $lastDate = null; $doelgroep = null; $lastDescription = null; //if ($respTrackId == 0) { // $track = $main->div(array('class' => 'panel panel-default traject active')); //} else { $track = $main->div(array('class' => 'panel panel-default traject')); //} $respTrackId = $row['gto_id_respondent_track']; $trackHeading = $track->div(array('class' => 'panel-heading', 'renderClosingTag' => true)); $trackHeader = $trackHeading->h3(array('class' => "panel-title", 'renderClosingTag' => true)); $trackParameterSource = array('gr2t_id_respondent_track' => $row['gto_id_respondent_track'], 'gr2o_patient_nr' => $row['gr2o_patient_nr'], 'gr2o_id_organization' => $row['gr2o_id_organization'], 'can_edit' => 1); if (array_key_exists($row['gr2o_id_organization'], $allowedOrgs) && $this->_trackEdit) { $editLink = \MUtil_Html::create('i', array('class' => 'fa fa-pencil', 'renderClosingTag' => true, 'data-toggle' => 'tooltip', 'data-placement' => 'right', 'title' => $this->_("Edit track"))); $link = $this->createMenuLink($trackParameterSource, 'track', 'edit-track', $editLink, $this->_trackEdit); $link->setAttrib('onClick', 'event.cancelBubble = true;'); } else { // When org not allowed, dont add the link, so the track will just open $link = \MUtil_Html::create('span', array('class' => 'fa fa-pencil', 'renderClosingTag' => true)); } $trackHeader[] = $link; $title = \MUtil_Html::create('span', array('class' => 'title')); $title[] = ' ' . $row['gtr_track_name']; $title[] = \MUtil_Html::create('span', array('class' => "fa fa-chevron-down fa-fw", 'renderClosingTag' => true)); $trackHeader[] = $title; $deleteTrackContainer = \MUtil_Html::create('div', array('class' => 'otherOrg pull-right', 'renderClosingTag' => true)); if ($row['gr2o_id_organization'] != $currentOrg) { $org = $this->loader->getOrganization($row['gr2o_id_organization'])->getName(); $deleteTrackContainer[] = $org . ' '; } if (array_key_exists($row['gr2o_id_organization'], $allowedOrgs) && $this->_trackDelete) { $deleteLink = \MUtil_Html::create('i', array('class' => 'fa fa-trash deleteIcon', 'renderClosingTag' => true, 'data-toggle' => 'tooltip', 'data-placement' => 'left', 'title' => $this->_("Delete track"))); $link = $this->createMenuLink($trackParameterSource, 'track', 'delete-track', $deleteLink, $this->_trackDelete)->setAttrib('onClick', 'event.cancelBubble = true;'); $deleteTrackContainer[] = $link; } $trackHeader[] = $deleteTrackContainer; if ($row['gr2t_start_date'] instanceof Zend_Date) { $trackStartDate = $row['gr2t_start_date']->get($this->_dateFormat); } else { $trackStartDate = $this->_('n/a'); } $trackHeading->div($row['gr2t_track_info'], array('renderClosingTag' => true)); $trackHeading->div($this->_('Start date') . ': ' . $trackStartDate, array('renderClosingTag' => true)); $trackProgress = $trackHeading->div(array('class' => 'progress pull-right', 'renderClosingTag' => true)); $container = $track->div(array('class' => 'panel-body', 'renderClosingTag' => true)); $subcontainer = $container->div(array('class' => 'objecten', 'renderClosingTag' => true)); } $date = $row['gto_valid_from']; if ($date instanceof \Zend_Date) { $date = $date->get($this->_dateFormat); } else { continue; } $description = $row['gto_round_description']; if ($lastDescription !== $description || !isset($day)) { $last = new \MUtil_Date($lastDate, 'dd-MM-y'); if (isset($day) && $last < $now && $row['gto_valid_from'] > $now) { $day->class .= ' today'; } $lastDescription = $description; $progressDiv = $this->finishGroup($progressDiv); $lastDate = $date; $class = 'object'; if ($date == $today) { $class .= ' today'; } $day = $subcontainer->div(array('class' => $class, 'renderClosingTag' => true)); $day->h4(ucfirst($row['gto_round_description'])); $day->h5($date); $doelgroep = null; } elseif (isset($day) && $lastDate !== $date) { // When we have a new start date, add the date and start a new group $day->h5($date); $lastDate = $date; $doelgroep = null; } if ($doelgroep !== $row['forgroup']) { $progressDiv = $this->finishGroup($progressDiv); $doelgroep = $row['forgroup']; $doelgroepDiv = $day->div(array('class' => 'actor', 'renderClosingTag' => true)); //$progressDiv = $doelgroepDiv->div(array('class' => 'progress')); $minIcon = \MUtil_Html::create('span', array('class' => 'fa fa-plus-square', 'renderClosingTag' => true)); $title = $doelgroepDiv->h5(array($minIcon, $doelgroep)); $progressDiv = $doelgroepDiv->div(array('class' => 'zplegenda', 'renderClosingTag' => true)); $tokenDiv = $doelgroepDiv->div(array('class' => 'zpitems', 'renderClosingTag' => true)); } $tokenDiv[] = $this->addToken($row); } if (isset($day) && new \MUtil_Date($lastDate, 'dd-MM-y') < $now) { $day->class .= ' today'; } $progressDiv = $this->finishGroup($progressDiv); $this->finishTrack($trackProgress); return $main; }
public function getHtmlOutput(\Zend_View_Abstract $view) { $this->_initView($view); $main = $this->creator->div(array('id' => 'wrapper', 'renderClosingTag' => true)); $main->div(array('id' => 'modalpopup', 'renderClosingTag' => true)); $model = $this->getModel(); $model->trackUsage(); $items = array('gto_id_respondent_track', 'gto_valid_from', 'gr2t_start_date', 'gtr_track_name', 'gr2t_track_info', 'gto_id_token', 'gto_round_description', 'forgroup', 'gsu_survey_name', 'gto_completion_time', 'gr2o_patient_nr', 'gr2o_id_organization'); foreach ($items as $item) { $model->get($item); } $data = $model->load(true, $this->_fixedSort); $lastDate = null; $lastDescription = null; $doelgroep = null; $today = new \MUtil_Date(); $today = $today->get($this->_dateFormat); $progressDiv = null; $respTrackId = 0; // The normal loop foreach ($data as $row) { if ($respTrackId !== $row['gto_id_respondent_track']) { $lastDate = null; $doelgroep = null; //if ($respTrackId == 0) { // $track = $main->div(array('class' => 'panel panel-default traject active')); //} else { $track = $main->div(array('class' => 'panel panel-default traject')); //} $respTrackId = $row['gto_id_respondent_track']; $trackHeading = $track->div(array('class' => 'panel-heading', 'renderClosingTag' => true)); $trackHeading->h3($row['gtr_track_name'], array('class' => "panel-title"))->span(array('class' => "fa fa-chevron-down fa-fw")); $editLink = \MUtil_Html::create('span', array('class' => 'fa fa-pencil', 'renderClosingTag' => true)); $editTrackContainer = \MUtil_Html::create('div', array('class' => 'editIcon')); $link = $this->createMenuLink(array('gr2t_id_respondent_track' => $row['gto_id_respondent_track'], 'gr2o_patient_nr' => $row['gr2o_patient_nr'], 'gr2o_id_organization' => $row['gr2o_id_organization'], 'can_edit' => 1), 'track', 'edit-track', $editLink); $link->addCancelBubble(); $link->setAttrib('onClick', 'event.cancelBubble = true;'); $editTrackContainer[] = $link; $trackHeading[] = $editTrackContainer; $trackHeading->div($row['gr2t_track_info'], array('renderClosingTag' => true)); $trackHeading->div($this->_('Start date') . ': ' . $row['gr2t_start_date']->get($this->_dateFormat), array('renderClosingTag' => true)); $container = $track->div(array('class' => 'panel-body', 'renderClosingTag' => true)); $cva = $container->div(array('class' => 'objecten', 'renderClosingTag' => true)); } $date = $row['gto_valid_from']; if ($date instanceof \Zend_Date) { $date = $date->get($this->_dateFormat); } else { continue; } $description = $row['gto_round_description']; if ($date !== $lastDate || $lastDescription !== $description) { $lastDescription = $description; $progressDiv = $this->finishGroup($progressDiv); $lastDate = $date; $class = 'object'; if ($date == $today) { $class .= ' today'; } $day = $cva->div(array('class' => $class, 'renderClosingTag' => true)); $day->h4(ucfirst($row['gto_round_description'])); $day->h5($date); $doelgroep = null; } if ($doelgroep !== $row['forgroup']) { $progressDiv = $this->finishGroup($progressDiv); $doelgroep = $row['forgroup']; $doelgroepDiv = $day->div(array('class' => 'actor', 'renderClosingTag' => true)); //$progressDiv = $doelgroepDiv->div(array('class' => 'progress')); $minIcon = \MUtil_Html::create('span', array('class' => 'fa fa-plus-square', 'renderClosingTag' => true)); $title = $doelgroepDiv->h5(array($minIcon, $doelgroep)); $progressDiv = $doelgroepDiv->div(array('class' => 'zplegenda', 'renderClosingTag' => true)); $tokenDiv = $doelgroepDiv->div(array('class' => 'zpitems', 'renderClosingTag' => true)); } $tokenDiv[] = $this->addToken($row); } $progressDiv = $this->finishGroup($progressDiv); return $main; }