public function view()
 {
     if (!$this->loadData()) {
         $this->dataError();
         sendBack();
     }
     $transaction = $this->_uses[$this->modeltype];
     $id = $this->_data['id'];
     $this->view->set('transaction', $transaction);
     $item = DataObjectFactory::Factory('STItem');
     $item->load($transaction->stitem_id);
     $obsolete = $item->isObsolete();
     $active = $transaction->isActive();
     $this->view->set('showform', !$obsolete && $active);
     if (!$obsolete && $active) {
         $this->_new();
         $substitute = $transaction->getSubstitute();
         $uom_list = array();
         $substitute_used = false;
         if ($substitute) {
             // There is a future dated substitution, so get the details of it
             $ststructure = DataObjectFactory::Factory('STItem');
             $ststructure->load($substitute->ststructure_id);
             if ($ststructure) {
                 $uom_temp_list = STuomconversion::getUomList($substitute->ststructure_id, $ststructure->uom_id);
                 $uom_temp_list += SYuomconversion::getUomList($ststructure->uom_id);
                 $uom = DataObjectFactory::Factory('STuom');
                 $uom->load($ststructure->uom_id);
                 $uom_list[$ststructure->uom_id] = $uom->getUomName();
                 $uom_list += $uom_temp_list;
                 $this->view->set('uom_id', $ststructure->uom_id);
             }
             $wostructures = new MFWOStructureCollection();
             $sh = new SearchHandler($wostructures);
             $sh->addConstraint(new Constraint('ststructure_id', '=', $substitute->id));
             $wostructures->load($sh);
             $substitute_used = $wostructures->count() > 0;
             $this->view->set('uom_list', $uom_list);
         } else {
             $substitute = DataObjectFactory::Factory('MFStructure');
         }
         $this->view->set('substitute', $substitute);
     }
     $sidebar = new SidebarController($this->view);
     $sidebar->addList('This Parent Item', array('view' => array('tag' => 'Show Structure', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'index', 'stitem_id' => $transaction->stitem_id))));
     $sidebar->addList('This Part Item', array('view' => array('tag' => 'Show Structure', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'index', 'stitem_id' => $transaction->ststructure_id))));
     $sidebarlist = array();
     if (!$obsolete && $active) {
         $sidebarlist['edit'] = array('tag' => 'Edit', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'edit', 'id' => $id, 'stitem_id' => $transaction->stitem_id, 'ststructure_id' => $transaction->ststructure_id));
     }
     if (!$obsolete && !$transaction->end_date) {
         $sidebarlist['delete'] = array('tag' => 'End Today', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'delete', 'id' => $id, 'stitem_id' => $transaction->stitem_id));
     }
     $sidebarlist['item'] = array('tag' => 'Show Parent Item', 'link' => array('modules' => $this->_modules, 'controller' => 'STItems', 'action' => 'view', 'id' => $transaction->stitem_id));
     $sidebarlist['structure'] = array('tag' => 'Show Part Item', 'link' => array('modules' => $this->_modules, 'controller' => 'STItems', 'action' => 'view', 'id' => $transaction->ststructure_id));
     $sidebar->addList('Current Structure', $sidebarlist);
     if (!$obsolete && $active && $substitute->isLoaded()) {
         $sidebarlist = array();
         if (!$substitute_used) {
             $sidebarlist['delete'] = array('tag' => 'Delete', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'deleteSubstitute', 'id' => $id, 'stitem_id' => $transaction->stitem_id));
         }
         $sidebar->addList('New Structure', $sidebarlist);
     }
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }