public function indexAction() { $this->defaultNamespace = new Zend_Session_Namespace('default'); $this->myNamespace = new Zend_Session_Namespace('editParticipants'); $ceId = $this->defaultNamespace->callingActionId; $this->view->callingActionId = $ceId; if ($this->getRequest()->isPost()) { //save form params to namespace $this->myNamespace->params = $this->getRequest()->getParams(); //check which submit button has been clicked if ($this->getRequest()->getParam('Check_all') != NULL) { $this->myNamespace->checkAll = TRUE; $this->redirectTo('index'); } if ($this->getRequest()->getParam('Uncheck_all') != NULL) { $this->myNamespace->checkAll = FALSE; $this->redirectTo('index'); } if ($this->getRequest()->getParam('Remove_from_participants') != NULL) { $success = $this->deleteParticipants(); if (!$success) { //XXX show error } $this->redirectTo('index'); } if ($this->getRequest()->getParam('Apply_to_selected') != NULL) { $success = $this->applySettingsToParticipants(); if (!$success) { ///XXX show error } $this->redirectTo('index'); } } else { //not post //TODO getCaliExName and display in header $userTable = new User(); $participantsTable = new Participant(); $dbAdapter = Zend_Registry::get('DB_CONNECTION1'); $select = $dbAdapter->select(); $select->from(array('user' => $userTable->getTableName()), array(User::COL_LASTNAME, User::COL_FIRSTNAME, User::COL_USERNAME)); $select->join(array('part' => $participantsTable->getTableName()), $dbAdapter->quoteIdentifier('user.' . User::COL_ID) . '=' . $dbAdapter->quoteIdentifier('part.' . Participant::COL_USER_ID), array(Participant::COL_ID, Participant::COL_NUMBER, Participant::COL_EXPERTISE_LEVEL, Participant::COL_STOCK_ASSESSMENT, Participant::COL_ROLE)); $select->where($dbAdapter->quoteInto('part.' . Participant::COL_CE_ID . ' = ?', $ceId)); //echo $select; $paginator = new Ble422_Paginator_Extended($select, $this->getRequest()); $paginator->setHeader(array(array('raw' => User::COL_LASTNAME, 'name' => 'Last name'), array('raw' => User::COL_FIRSTNAME, 'name' => 'First name'), array('raw' => User::COL_USERNAME, 'name' => 'User name'), array('raw' => Participant::COL_NUMBER, 'name' => 'Reader no.'), array('raw' => Participant::COL_EXPERTISE_LEVEL, 'name' => 'Expertise level'), array('raw' => Participant::COL_STOCK_ASSESSMENT, 'name' => 'Stock assess.'), array('raw' => Participant::COL_ROLE, 'name' => 'Role'))); $paginator->setCurrentPageNumber($this->getRequest()->getParam('page'))->setItemCountPerPage(50)->setPageRange(10)->orderBy($this->getRequest()->getParam('orderBy')); //$this->_getParam('pageRange')); Zend_View_Helper_PaginationControl::setDefaultViewPartial('partials/list_pagination_control.phtml'); $this->view->paginator = $paginator; $this->defaultNamespace->callingAction = "ce/editparticipants/index"; //callingActionId stays the same $this->view->callingAction = $this->defaultNamespace->callingAction; $this->view->callingActionId = $ceId; $this->view->ceName = Default_SimpleQuery::getCeName($ceId); $this->view->checkAll = $this->myNamespace->checkAll; unset($this->myNamespace->checkAll); //TODO partTable.phtml wird schon auf this->checkAll geprüft, vom Controller übergeben, ebenso reload bei uncheck all } }
public function init() { $ceId = intval($this->getRequest()->getParam(CalibrationExercise::COL_ID)); $workId = Default_SimpleQuery::getWorkshopId($ceId); // if (! Default_SimpleQuery::getWsManagerUserId($workId) == AuthQuery::getUserId()) { // $Redirect = new Zend_Controller_Action_Helper_Redirector(); // $Redirect->setGotoSimple('myce', 'search', 'ce'); // return; // } $this->defaultNamespace = new Zend_Session_Namespace('default'); if (isset($this->defaultNamespace->message)) { $this->view->message = $this->defaultNamespace->message; } if ($this->getRequest()->getParam(CalibrationExercise::COL_ID) != null) { $this->callingCeId = $this->getRequest()->getParam(CalibrationExercise::COL_ID); } else { $this->callingCeId = $this->defaultNamespace->callingActionId; } $this->imageSetForm = new Ble422_Form_Dynamic(); $this->imageSetForm->addElement('hidden', ImagesetAttributes::COL_CE_ID, array('required' => true)); $this->imageSetForm->setAction('/ce/edit/imagesetform'); //----------------------------------------------- //check if user is authorized for editing CE // $auth = Zend_Auth::getInstance(); // $storage = $auth->getStorage()->read(); // $const = User::COL_ID; // $userId = $storage->$const; // $ceTable = new CalibrationExercise(); // $dbAdapter = Zend_Registry::get('DB_CONNECTION1'); // $select = $dbAdapter->select(); // $select->from( array('ce'=>$ceTable->getTableName()), // array( 'ce.'.CalibrationExercise::COL_ID, // 'ce.'.CalibrationExercise::COL_WORKSHOP_ID) // ); // $partTable = new Participant(); // $select->join(array('part'=>$partTable->getTableName()), // 'ce.'.CalibrationExercise::COL_ID.' = '.'part.'.Participant::COL_CE_ID, // Participant::COL_USER_ID // ); // $userTable = new User(); // $select->join(array('user'=>$userTable->getTableName()), // 'part.'.Participant::COL_USER_ID.' = '.'user.'.User::COL_ID, // 'user.'.User::COL_ROLE // ); // $select->where( $dbAdapter->quoteInto('ce.'.CalibrationExercise::COL_ID.' = ?', $this->callingCeId)); // $select->where( 'user.'.User::COL_ID.' = ?', $userId); // $select->where( $dbAdapter->quoteInto('user.'.User::COL_ROLE.' = ? OR ', 'workshop manager'). // $dbAdapter->quoteInto('user.'.User::COL_ROLE.' = ?', 'admin')); // $stmt = $select->query(); // //echo $select; // $resultArray = $stmt->fetchAll(); // if (count($resultArray) != 1) { // $redirect = new Zend_Controller_Action_Helper_Redirector(); // $redirect->setGotoSimple('myce', 'search', 'ce'); // } //------------------------------------------------ $this->view->ceName = Default_SimpleQuery::getCeName($this->callingCeId); $this->view->callingActionId = $this->callingCeId; $this->form = new Ce_Form_EditAllElements(); $formElem = $this->form->getElement(CalibrationExercise::COL_KEY_TABLE_ID); if (!Default_SimpleQuery::isCeStopped($this->callingCeId)) { $this->form->removeElement('save'); } //credits: http://stackoverflow.com/questions/643736/zend-form-add-a-link-to-the-right-of-a-text-field //answered Mar 14 at 13:05 monzee $formElem->setDescription('<a href="/ce/editkeytable/index">Add protocol...</a>')->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => false)), array('HtmlTag', array('tag' => 'dd')), array('Label', array('tag' => 'dt')), 'Errors')); $formElem = $this->form->getElement(CalibrationExercise::COL_EXPERTISE_ID); $formElem->setDescription('<a href="/ce/editexpertise/index">Add expertise...</a>')->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => false)), array('HtmlTag', array('tag' => 'dd')), array('Label', array('tag' => 'dt')), 'Errors')); $ceHasAttrTable = new CeHasAttributeDescriptor(); $tableRow = CeHasAttributeDescriptor::COL_CAEX_ID; $this->formAttrSelCon = new Default_Form_AttributeSelectContainer($ceHasAttrTable, $tableRow, $this->callingCeId); $this->formAttrSelConImage = new Default_Form_AttributeSelectContainer(NULL, NULL, NULL, 'IMAGE'); $this->formAttrSelConFish = new Default_Form_AttributeSelectContainer(NULL, NULL, NULL, 'FISH'); //$this->view->formAttrSelConFish = $this->formAttrSelConFish; }