public function indexAction()
 {
     if ($this->hasACL('edit_employee') && $this->setting('module_employee_enabled')) {
         if ($this->hasACL('in-service') == false && $this->hasACL('pre-service') == false) {
             $this->_redirect('employee');
             exit;
         }
     }
     if (strstr($_SERVER['REQUEST_URI'], 'index/index') === false) {
         if ($this->hasACL('in_service')) {
             $this->_redirect('index/index');
             exit;
         } elseif ($this->hasACL('pre_service')) {
             $this->_redirect('dash/dash');
             exit;
         }
         $this->_redirect('index/index');
         exit;
     }
     $db = Zend_Db_Table_Abstract::getDefaultAdapter();
     $sql = "SELECT q2.qualification_phrase, COUNT(q2.qualification_phrase) CNT FROM person p INNER JOIN person_qualification_option q1 ON p.primary_qualification_option_id = q1.id INNER JOIN person_qualification_option q2 ON q1.parent_id = q2.id WHERE p.is_deleted = 0 GROUP BY q2.qualification_phrase;";
     $rowyArray1 = $db->fetchAll($sql);
     $sql = "SELECT q3.qualification_phrase, 0 CNT FROM person_qualification_option q3 WHERE q3.id NOT IN (SELECT q2.id CNT FROM person p INNER JOIN person_qualification_option q1 ON p.primary_qualification_option_id = q1.id INNER JOIN person_qualification_option q2 ON q1.parent_id = q2.id WHERE p.is_deleted = 0) AND q3.parent_id IS NULL;";
     $rowyArray2 = $db->fetchAll($sql);
     $rowyArray = array_merge($rowyArray1, $rowyArray2);
     $this->viewAssignEscaped('rowy', $rowyArray);
     $sql = "SELECT p.comments FROM person p INNER JOIN person_qualification_option q1 ON p.primary_qualification_option_id = q1.id INNER JOIN person_qualification_option q2 ON q1.parent_id = q2.id WHERE p.is_deleted = 0 AND q2.id = 8";
     $rowsArray = $db->fetchAll($sql);
     $NIMART = 0;
     foreach ($rowsArray as $key => $row) {
         $NIMARTsplit = split("§", $rowsArray[$key]['comments']);
         if (strlen($NIMARTsplit[21]) > 0) {
             if ($NIMARTsplit[21] = "Nurse Initiating ART") {
                 $NIMART = $NIMART + 1;
             }
         }
     }
     $this->viewAssignEscaped('NIMART', $NIMART);
     // retrieve list of incomplete courses created by user
     if ($this->hasACL('edit_course')) {
         require_once 'models/table/Training.php';
         require_once 'models/Session.php';
         require_once 'views/helpers/EditTableHelper.php';
         require_once 'views/helpers/TrainingViewHelper.php';
         $uid = Session::getCurrentUserId();
         // Find incomplete training and future trainings
         $trainingFields = array('training_title' => t('Course Name'), 'training_start_date' => t('Start Date'), 'training_location_name' => t('Training Center'), 'creator' => t('Created By'));
         foreach (array_keys($trainingFields) as $key) {
             $colCustom[$key] = 'sortable:true';
         }
         $colStatic = array_keys($trainingFields);
         // all
         $editLinkInfo['disabled'] = 1;
         $linkInfo = array('linkFields' => array_keys($trainingFields), 'linkId' => 'id', 'linkUrl' => Settings::$COUNTRY_BASE_URL . '/training/edit/id/%id%');
         // restricted access?? only show trainings we have the ACL to view // add this to every query
         $org_allowed_ids = allowed_org_access_full_list($this);
         // doesnt have acl 'training_organizer_option_all'
         $allowedWhereClause = $org_allowed_ids ? " AND training_organizer_option_id in ({$org_allowed_ids}) " : "";
         // restricted access?? only show organizers that belong to this site if its a multi org site
         $site_orgs = allowed_organizer_in_this_site($this);
         // for sites to host multiple training organizers on one domain
         $allowedWhereClause .= $site_orgs ? " AND training_organizer_option_id in ({$site_orgs}) " : "";
         // Incomplete
         $tableObj = new Training();
         $rowsPast = $tableObj->getIncompleteTraining($uid, 'training_start_date < NOW() ' . $allowedWhereClause)->toArray();
         if ($rowsPast) {
             $html = EditTableHelper::generateHtmlTraining('TrainingPast', $rowsPast, $trainingFields, $colStatic, $linkInfo, $editLinkInfo, $colCustom);
             $this->view->assign('tableTrainingPast', $html);
         }
         // Future
         $tableObj = new Training();
         $rowsFuture = $tableObj->getIncompleteTraining($uid, 'training_start_date >= NOW()' . $allowedWhereClause, '')->toArray();
         if ($rowsFuture) {
             $html = EditTableHelper::generateHtmlTraining('TrainingFuture', $rowsFuture, $trainingFields, $colStatic, $linkInfo, $editLinkInfo, $colCustom);
             $this->view->assign('tableTrainingFuture', $html);
         }
         // Unapproved
         if ($this->setting('module_approvals_enabled')) {
             $tableObj = new Training();
             $unapproved = $tableObj->getUnapprovedTraining("1" . $allowedWhereClause);
             // everything
             if ($unapproved) {
                 $linkInfoUnapprov = $linkInfo;
                 if (!$this->hasACL('approve_trainings')) {
                     $linkInfoUnapprov['linkFields'] = array('training_title');
                 }
                 $trainingFieldsUnapprov = $trainingFields;
                 $trainingFieldsUnapprov['message'] = t('Message');
                 $colStatic['message'] = 'message';
                 $html = EditTableHelper::generateHtmlTraining('unapproved', $unapproved, $trainingFieldsUnapprov, $colStatic, $linkInfoUnapprov, $editLinkInfo, $colCustom);
                 $this->view->assign('tableUnapproved', $html);
             }
         }
         //YTD, start at April 1
         if ($ytdStart = $this->setting('fiscal_year_start')) {
             $ytdStart = date('Y-n-j', strtotime($ytdStart));
             $this->view->assign('ytdStart', $ytdStart);
             //get total unique participants
             $db = Zend_Db_Table_Abstract::getDefaultAdapter();
             $sql = "SELECT COUNT(DISTINCT person_id) as \"unique_p\" from person_to_training left join training on (training.id = training_id and training.is_deleted = 0) where training_start_date > " . $ytdStart . $allowedWhereClause;
             $rowArray = $db->fetchRow($sql);
             $this->view->assign('unique_participants', $rowArray['unique_p']);
         } else {
             $ytdStart = date('Y') - (date('n') < 4 ? 1 : 0) . '-04-01';
             $this->view->assign('ytdStart', $ytdStart);
             //get total unique participants
             $db = Zend_Db_Table_Abstract::getDefaultAdapter();
             $sql = "SELECT COUNT(DISTINCT person_id) as \"unique_p\" from person_to_training left join training on (training.id = training_id and training.is_deleted = 0) where 1 " . $allowedWhereClause;
             $rowArray = $db->fetchRow($sql);
             $this->view->assign('unique_participants', $rowArray['unique_p']);
         }
         $allowedOrgJoin = $allowedWhereClause ? ' LEFT JOIN training ON training.id = training_id WHERE training.is_deleted = 0 ' . $allowedWhereClause : '';
         // only show trainings we're allowed to see by access level
         //get participants total and by YTD
         $db = Zend_Db_Table_Abstract::getDefaultAdapter();
         $sql = "SELECT COUNT(person_id) as \"attendees\" from person_to_training" . $allowedOrgJoin;
         $rowArray = $db->fetchRow($sql);
         $this->view->assign('attendees', $rowArray['attendees']);
         $sql = "SELECT COUNT(person_id) as  \"attendees\" FROM training, person_to_training as pt WHERE pt.training_id = training.id AND training_start_date >= '{$ytdStart}'" . $allowedWhereClause;
         $rowArray = $db->fetchRow($sql);
         $this->view->assign('attendees_ytd', $rowArray['attendees']);
         //get total unique trainers
         if ($allowedOrgJoin) {
             $sql = "SELECT COUNT(DISTINCT trainer_id) as \"unique_t\" FROM training_to_trainer" . $allowedOrgJoin;
             // trainers in viewable trainings
         } else {
             $sql = "SELECT COUNT(person_id) as \"unique_t\" from trainer";
         }
         $rowArray = $db->fetchRow($sql);
         $this->view->assign('unique_trainers', $rowArray['unique_t']);
         //get total trainers and by YTD
         $sql = "SELECT COUNT(trainer_id) as \"trainers\" FROM training_to_trainer" . $allowedOrgJoin;
         $rowArray = $db->fetchRow($sql);
         $this->view->assign('trainers', $rowArray['trainers']);
         $sql = "SELECT COUNT(tt.trainer_id) as \"trainers\" FROM training, training_to_trainer as tt WHERE tt.training_id = training.id AND training_start_date >= '{$ytdStart}'" . $allowedWhereClause;
         $rowArray = $db->fetchRow($sql);
         $this->view->assign('trainers_ytd', $rowArray['trainers']);
         //get trainings
         //    total and YTD
         $sql = "SELECT COUNT(id) as \"trainings\", MIN(training_start_date) as \"min_date\",MAX(training_start_date) as \"max_date\"  from training WHERE is_deleted = 0" . $allowedWhereClause;
         $rowArray = $db->fetchRow($sql);
         $this->view->assign('trainings', $rowArray['trainings']);
         $this->view->assign('min_date', $rowArray['min_date']);
         $this->view->assign('max_date', $rowArray['max_date']);
         $sql = "SELECT COUNT(id) as \"trainings\"  from training WHERE training_start_date >= '{$ytdStart}' AND is_deleted = 0" . $allowedWhereClause;
         $rowArray = $db->fetchRow($sql);
         $this->view->assign('trainings_ytd', $rowArray['trainings']);
     }
     /****************************************************************************************************************/
     /* Attached Files */
     require_once 'views/helpers/FileUpload.php';
     $PARENT_COMPONENT = 'home';
     FileUpload::displayFiles($this, $PARENT_COMPONENT, 1, $this->hasACL('admin_files'));
     // File upload form
     if ($this->hasACL('admin_files')) {
         $this->view->assign('filesForm', FileUpload::displayUploadForm($PARENT_COMPONENT, 1, FileUpload::$FILETYPES));
     }
     /****************************************************************************************************************/
 }
 /**
  * Training Roster
  */
 public function rosterAction()
 {
     $training_id = $this->_getParam('id');
     $this->view->assign('url', Settings::$COUNTRY_BASE_URL . "/training/roster/id/{$training_id}");
     $tableObj = new Training();
     $rowRay = $tableObj->getTrainingInfo($training_id);
     // calculate end date
     switch ($rowRay['training_length_interval']) {
         case 'week':
             $days = $rowRay['training_length_value'] * 7;
             break;
         case 'day':
             $days = $rowRay['training_length_value'] - 1;
             // start day counts as a day?
             break;
         default:
             $days = false;
             break;
     }
     if ($days) {
         $rowRay['training_end_date'] = strtotime("+{$days} day", strtotime($rowRay['training_start_date']));
         $rowRay['training_end_date'] = date('Y-m-d', $rowRay['training_end_date']);
     } else {
         $rowRay['training_end_date'] = $rowRay['training_start_date'];
     }
     $rowRay['duration'] = $rowRay['training_length_value'] . ' ' . $rowRay['training_length_interval'] . ($rowRay['training_length_value'] == 1 ? "" : "s");
     $this->viewAssignEscaped('row', $rowRay);
     // trainer/person tables
     require_once 'views/helpers/EditTableHelper.php';
     /* Trainers */
     $trainers = TrainingToTrainer::getTrainers($training_id)->toArray();
     $trainerFields = array('last_name' => $this->tr('Last Name'), 'first_name' => $this->tr('First Name'), 'duration_days' => t('Days'));
     $colStatic = array_keys($trainerFields);
     // all
     $editLinkInfo = array('disabled' => 1);
     // no edit/remove links
     $html = EditTableHelper::generateHtmlTraining('Trainer', $trainers, $trainerFields, $colStatic, array(), $editLinkInfo);
     $this->view->assign('tableTrainers', $html);
     /* Participants */
     $persons = PersonToTraining::getParticipants($training_id)->toArray();
     $personsFields = array('last_name' => $this->tr('Last Name'), 'first_name' => $this->tr('First Name'));
     if ($this->setting('module_attendance_enabled')) {
         if (strtotime($rowRay['training_start_date']) < time()) {
             $personsFields = array_merge($personsFields, array('duration_days' => t('Days')));
             // already had class(es) - show the days attended
         }
         $personsFields['award_phrase'] = $this->tr('Complete');
     }
     $personsFields = array_merge($personsFields, array('birthdate' => t('Date of Birth'), 'facility_name' => t('Facility')));
     if ($this->setting('display_viewing_location')) {
         $personsFields['location_phrase'] = $this->tr('Viewing Location');
     }
     if ($this->setting('display_budget_code')) {
         $personsFields['budget_code_phrase'] = $this->tr('Budget Code');
     }
     //if ($this->setting ( 'display_region_b' ))
     $personsFields['location_name'] = t('Location');
     //add location
     $locations = Location::getAll();
     foreach ($persons as $pid => $person) {
         $region_ids = Location::getCityInfo($person['location_id'], $this->setting('num_location_tiers'));
         $ordered_l = array($region_ids['cityname']);
         foreach ($region_ids as $key => $value) {
             if (!empty($value) && isset($locations[$value]['name'])) {
                 $ordered_l[] = $locations[$value]['name'];
             } else {
                 break;
             }
         }
         $persons[$pid]['location_name'] = implode(', ', $ordered_l);
     }
     $colStatic = array_keys($personsFields);
     // all
     $editLinkInfo = array('disabled' => 1);
     // no edit/remove links
     $html = EditTableHelper::generateHtmlTraining('Persons', $persons, $personsFields, $colStatic, array(), $editLinkInfo);
     $this->view->assign('tablePersons', $html);
     if ($this->_getParam('outputType') && $this->_getParam('trainers')) {
         $this->sendData($trainers);
     }
     if ($this->_getParam('outputType') && $this->_getParam('persons')) {
         $this->sendData($persons);
     }
 }
 public function execute()
 {
     $params = $this->_getAllParams();
     if (isset($params['merge']) && $this->allowMerge) {
         $this->merge();
         return;
     }
     if (isset($params['default']) && $this->allowDefault) {
         $this->setDefault();
     }
     if (isset($params['redirect']) and $params['redirect']) {
         // editTable is part of a "wizard" (redirect to the next step)
         header("Location: {$params['redirect']}");
         exit;
     } elseif (isset($params['saveonly'])) {
         $status = ValidationContainer::instance();
         $status->setStatusMessage('Your settings have been updated.');
     }
     require_once 'models/table/EditTable.php';
     $editTable = new EditTable(array('name' => $this->table));
     $request = $this->controller->getRequest();
     $validateOnly = $request->isXmlHttpRequest();
     // Delete, insert, or update?
     if ($validateOnly) {
         //$id = $params['id'];
         $id = isset($_POST['id']) && is_numeric($_POST['id']) ? $_POST['id'] : null;
         // Get field to update
         foreach ($this->fields as $key => $devnull) {
             if (isset($params[$key])) {
                 $fieldEdit = $key;
                 $fieldValue = $params[$key];
                 break;
             }
         }
         if ($id == 0 && isset($params['undelete'])) {
             // undelete record
             try {
                 $row = $editTable->undelete($fieldEdit, $fieldValue);
                 $sendRay['insert'] = $row->id;
                 $sendRay['undelete'] = $row->{$fieldEdit};
                 $this->sendData($sendRay);
             } catch (Zend_Exception $e) {
                 $this->sendData(array("insert" => 0, 'error' => $e->getMessage()));
             }
         } elseif ($id == 0) {
             // user added new record
             try {
                 if (!$this->insertExtra) {
                     $insert = $editTable->insertUnique($fieldEdit, $fieldValue);
                 } else {
                     $data = array($fieldEdit => $fieldValue);
                     $insert = $editTable->insert(array_merge($data, $this->insertExtra));
                 }
                 $sendRay['insert'] = "{$insert}";
                 if ($insert == -1) {
                     $sendRay['error'] = 'A record already exists with this value.';
                 }
                 if ($insert == -2) {
                     $sendRay['error'] = '"%s" already exists, but was deleted.  Would you like to undelete?';
                 }
                 $this->sendData($sendRay);
             } catch (Zend_Exception $e) {
                 $this->sendData(array("insert" => 0, 'error' => $e->getMessage()));
             }
         } elseif ($id > 0) {
             // update or delete
             if (isset($params['delete'])) {
                 try {
                     $delete = $editTable->delete("id={$id}", true);
                     //force the delete, changed 06/16/08 Todd W
                     $this->sendData(array("delete" => $delete));
                 } catch (Zend_Exception $e) {
                     $this->sendData(array("delete" => 0, 'error' => $e->getMessage()));
                 }
             } elseif (isset($fieldEdit)) {
                 // update
                 try {
                     $update = $editTable->update(array($fieldEdit => $fieldValue), "id={$id}");
                     $this->sendData(array("update" => $id));
                 } catch (Zend_Exception $e) {
                     if (strpos($e->getMessage(), 'Duplicate entry') !== false) {
                         $this->sendData(array("update" => 0, 'error' => t('A record already exists with this value.')));
                     } else {
                         $this->sendData(array("update" => 0, 'error' => $e->getMessage()));
                     }
                 }
             }
         }
     } else {
         // view
         $selectFields = array_keys($this->fields);
         if ($this->allowDefault) {
             $selectFields[] = 'is_default';
         }
         require_once 'views/helpers/EditTableHelper.php';
         $rowRay = $editTable->getRowsSingle($this->table, $selectFields, $this->where);
         foreach ($rowRay as $key => $row) {
             foreach ($selectFields as $field) {
                 if ($field != 'id') {
                     $rowRay[$key][$field] = htmlspecialchars($row[$field]);
                 }
             }
         }
         // Modify rows
         if ($this->rowHook) {
             $func_name = $this->rowHook;
             eval('$rowRay = ' . $func_name . "(unserialize('" . serialize($rowRay) . "'));");
         }
         $noDelete = array();
         // look up dependencies
         if (!empty($this->dependencies)) {
             foreach ($this->dependencies as $colDependent => $tableDependent) {
                 if (is_numeric($colDependent)) {
                     $colDependent = $this->table . '_id';
                 }
                 if (is_array($tableDependent)) {
                     // in case multiple tables use the same field name
                     $colDependent = key($tableDependent);
                     $tableDependent = current($tableDependent);
                 }
                 $ray = $editTable->getDependencies($this->table, $tableDependent, $colDependent);
                 $noDelete += array_merge($noDelete, $ray);
             }
             $noDelete = array_unique($noDelete);
         }
         // disable delete on all rows
         if ($this->noDelete) {
             foreach ($rowRay as $key => $row) {
                 $noDelete[$row['id']] = $row['id'];
             }
         }
         // merge checkbox
         if ($this->allowMerge) {
             foreach ($rowRay as $key => $row) {
                 $rowRay[$key]['merge'] = '
       <input type="checkbox" name="merge[]" value="' . $row['id'] . '" id="merge' . $row['id'] . '">';
             }
             $this->customColDef['merge'] = 'editor:false';
             $this->fields['merge'] = 'Merge?';
         }
         // default radio
         if ($this->allowDefault) {
             foreach ($rowRay as $key => $row) {
                 $isChecked = $row['is_default'] ? ' checked="checked"' : '';
                 $rowRay[$key]['default'] = '
       <input type="radio" name="default" value="' . $row['id'] . '" id="merge' . $row['id'] . '"' . $isChecked . '>';
             }
             $this->customColDef['default'] = 'editor:false';
             $this->fields['default'] = 'Default?';
         }
         $html = '';
         if ($this->allowMerge) {
             $mergehtml = '
     <input type="hidden" name="table_option" value="' . $this->table . '">
     <input type="hidden" name="table_dependent" value="' . implode(',', $this->dependencies) . '">
     <input type="submit" name="mergesubmit" value="Merge Selected" class="submitArrow">';
             $html .= $mergehtml;
         }
         if ($html) {
             $html .= '<div class="clear"></div><br>';
         }
         $html .= EditTableHelper::generateHtml($this->label, $rowRay, $this->fields, $this->customColDef, $noDelete, $this->noEdit);
         // merge form
         if ($this->allowMerge) {
             $html .= $mergehtml;
         }
         $this->controller->view->assign($this->viewVar, $html);
     }
 }
 public function trainingApproversAction()
 {
     // ajax handler
     if ($this->getRequest()->isPost() && $this->getSanParam('ajax')) {
         // Update db
         $table = new ITechTable(array('name' => 'user_to_acl'));
         $msg = '';
         $success = false;
         $proceed = true;
         $id = $this->getSanParam('id');
         if (!trim($id) || !is_numeric($id)) {
             $proceed = false;
         }
         if ($this->getSanParam('ajaxAction') == 'elevate' && $proceed) {
             $user_acl = $table->createRow();
             $user_acl->acl_id = 'master_approver';
             $user_acl->user_id = $id;
             $user_acl = $user_acl->save();
             $msg = $user_acl ? t('That user is now a master approver') : t('Unable to make that user a master approver');
             if ($user_acl) {
                 $success = true;
             }
         }
         if ($this->getSanParam('ajaxAction') == 'deelevate' && $proceed) {
             $user_acl = $table->delete("acl_id = 'master_approver' and user_id = {$id}");
             $msg = $user_acl ? t('That user is now a regular approver') : t('Unable to remove that user as a master approver');
             if ($user_acl) {
                 $success = true;
             }
         }
         if ($this->getSanParam('ajaxAction') == 'remove' && $proceed) {
             $user_acl = $table->delete("acl_id = 'approve_trainings' and user_id = {$id}");
             $msg = $user_acl ? t('That user is no longer an approver') : t('Unable to delete that approver');
             if ($user_acl) {
                 $success = true;
             }
         }
         // done
         $_SESSION['status'] = $msg;
         $this->setNoRenderer();
         $output = array('success' => $success, 'msg' => $msg);
         echo json_encode($output);
         exit;
         // no view now
     }
     require_once 'models/table/System.php';
     require_once 'models/table/Translation.php';
     $sysTable = new System();
     $labelNames = array();
     // input name => key_phrase (changes translation table)
     $checkboxFields = array('master_approver' => 'allow_multi_approvers');
     // field => key phrase (changes _system table)
     // edit table & data
     require_once 'views/helpers/EditTableHelper.php';
     $db = Zend_Db_Table_Abstract::getDefaultAdapter();
     $hideMasterLinks = false;
     $noDelete = array();
     $fieldDefs = array('fullname' => t('Name'));
     $fieldDefs['approver'] = t('Approver');
     if ($this->getSanParam('master_approver') || $this->setting('allow_multi_approvers')) {
         $fieldDefs['master_approver'] = t('Master Approver');
         $hideMasterLinks = true;
     }
     $fieldDefs['lnks'] = t('Actions');
     $rows = $db->fetchAll("select *,\r\n\t\t\tCONCAT(first_name, CONCAT(' ', last_name)) as fullname, '" . t('Yes') . "' as approver, m1.id as master_approver, user.id as id\r\n\t\t\tfrom user\r\n\t\t\tinner join user_to_acl acl on (acl.user_id = user.id and acl.acl_id = 'approve_trainings')\r\n\t\t\tleft join  user_to_acl m1 on (m1.user_id = user.id and m1.acl_id = 'master_approver')\r\n\t\t\twhere user.is_blocked = 0 limit 100");
     foreach ($rows as $i => $row) {
         // lets add some data to the resultset to show in the EditTable
         $noDelete[] = $row['id'];
         // add to nodelete array
         $rows[$i]['fullname'] = htmlspecialchars(ucwords($rows[$i]['fullname']), ENT_QUOTES);
         // format name
         if (empty($rows[$i]['master_approver'])) {
             $rows[$i]['master_approver'] = t('No');
             // master approver?
             $rows[$i]['lnks'] = "<a href='#' onclick='ajaxApprover(\"remove\", {$row['id']});return false'>" . t('Remove') . "</a>";
             // links
             if ($hideMasterLinks) {
                 $rows[$i]['lnks'] = " <a href='#' onclick='ajaxApprover(\"elevate\", {$row['id']});return false'>" . t('Make Master') . '</a>';
             }
         } else {
             $rows[$i]['master_approver'] = t('Yes');
             // is approver?
             if ($hideMasterLinks) {
                 $rows[$i]['lnks'] = "<a href='#' onclick='ajaxApprover(\"deelevate\", {$row['id']});return false'>" . t('Make Low Level Approver') . '</a>';
             } else {
                 $rows[$i]['lnks'] = "<a href='#' onclick='ajaxApprover(\"remove\", {$row['id']});return false'>" . t('Remove') . "</a>";
             }
             // same as first 'remove' link above
         }
     }
     // print a edit table
     $html = EditTableHelper::generateHtml('Approvers', $rows, $fieldDefs, array(), $noDelete, true);
     // array(1) and select 1 as id = bugfix: remove delete col
     $this->view->assign('editTable', $html);
     // done
     // process form (copied from other pages)
     if ($this->getRequest()->isPost()) {
         // Update db
         $updateData = array();
         // update translation labels
         $tranTable = new Translation();
         foreach ($labelNames as $input_key => $db_key) {
             if ($this->_getParam($input_key)) {
                 try {
                     $tranTable->update(array('phrase' => $this->_getParam($input_key)), "key_phrase = '{$db_key}'");
                     $this->viewAssignEscaped($input_key, $this->_getParam($input_key));
                 } catch (Zend_Exception $e) {
                     error_log($e);
                 }
             }
         }
         // update _system (checkboxes)
         foreach ($checkboxFields as $input_key => $db_field) {
             $value = $this->_getParam($input_key) == NULL ? 0 : 1;
             $updateData[$db_field] = $value;
             $this->view->assign($input_key, $value);
         }
         $sysTable->update($updateData, '');
     } else {
         // view
         // checkboxes
         $sysRows = $sysTable->fetchRow($sysTable->select()->limit(1));
         foreach ($checkboxFields as $input_key => $field_key) {
             if (isset($sysRows->{$field_key})) {
                 $this->view->assign($input_key, $sysRows->{$field_key});
             }
         }
         // labels
         $t = Translation::getAll();
         foreach ($labelNames as $input_key => $db_key) {
             $this->viewAssignEscaped($input_key, $t[$db_key]);
         }
     }
     // redirect to next page
     if ($this->_getParam('redirect')) {
         header("Location: " . $this->_getParam('redirect'));
         exit;
     } else {
         if ($this->_getParam('saveonly')) {
             $status = ValidationContainer::instance();
             $status->setStatusMessage(t('Your settings have been updated.'));
         }
     }
 }