public function index() { $errors = array(); $s_data = array(); // Set context from calling module $this->setSearch('stitemsSearch', 'useDefault', $s_data); $this->view->set('clickaction', 'view'); // $this->view->set('page_title', 'Stock Items List'); parent::index(new STItemCollection($this->_templateobject)); $sidebar = new SidebarController($this->view); $sidebarlist = array(); $sidebarlist['new'] = array('tag' => 'New Stock Item', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'new')); $sidebarlist['documents'] = array('tag' => $this->_templateobject->getTitle() . ' Documents', 'link' => array('modules' => $this->_modules, 'controller' => 'attachments', 'action' => 'index', 'entity_id' => ModuleComponent::getComponentId($this->_modules['module'], strtolower(get_class($this))), 'data_model' => 'modulecomponent')); $sidebar->addList('Actions', $sidebarlist); $this->view->register('sidebar', $sidebar); $this->view->set('sidebar', $sidebar); }
private function getAttachments() { $attachments = new EntityAttachmentCollection(); $sh = new SearchHandler($attachments, FALSE); $sh->addConstraint(new Constraint('data_model', '=', 'modulecomponent')); $sh->addConstraint(new Constraint('entity_id', '=', ModuleComponent::getComponentId($this->_modules['module'], strtolower(get_class($this))))); $sh->addConstraint(new Constraint('createdby', '=', EGS_USERNAME)); $files = $attachments->load($sh, null, RETURN_ROWS); $dirobjs = array(); if (count($files) > 0) { foreach ($files as $attachment) { $link = '/?' . setParamsString(array('modules' => $this->_modules, 'controller' => 'attachments', 'action' => 'view_file', 'other' => array(file_id => $attachment['file_id']))); $details = array('name' => $attachment['file'], 'link' => $link, 'type' => 'attachment', 'delete' => array('modules' => $this->_modules, 'controller' => 'attachments', 'action' => 'delete', 'id' => $attachment['id']), 'size' => sizify($attachment['size']), 'mtime' => un_fix_date($attachment['lastupdated'])); $dirobjs['file'][] = $details; } } return $dirobjs; }