Esempio n. 1
0
 public function save()
 {
     if (!$this->checkParams($this->modeltype)) {
         sendBack();
     }
     $flash = Flash::Instance();
     $errors = array();
     $period = new GLPeriod();
     if ($period->loadPeriod($this->_data[$this->modeltype]['purchase_date'])) {
         $this->_data[$this->modeltype]['purchase_period_id'] = $period->id;
     } else {
         $errors[] = 'No period defined for this purchase date';
     }
     if (count($errors) == 0 && parent::save($this->modeltype)) {
         sendTo($this->name, 'index', $this->_modules);
     } else {
         $flash->addErrors($errors);
         $this->refresh();
     }
 }
Esempio n. 2
0
 public function index()
 {
     $this->view->set('clickaction', 'edit');
     parent::index(new GLPeriodCollection($this->_templateobject));
     $period = new GLPeriod();
     $period->getCurrentPeriod();
     $newperiod = new GLPeriod();
     if ($period->isLoaded()) {
         $nextyear = date(DATE_FORMAT, strtotime('+12 months', strtotime($period->enddate)));
         $newperiod->loadPeriod($nextyear);
     }
     $sidebar = new SidebarController($this->view);
     $sidebarlist = array();
     $sidebarlist['new'] = array('tag' => 'new_glperiod', 'link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'new')));
     $sidebarlist['close'] = array('tag' => 'Close Period ' . $period->year . ' - Period ' . $period->period, 'link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'close', 'id' => $period->id)));
     if (!$newperiod->isLoaded() && $period->isLoaded()) {
         $sidebarlist['viewtrans'] = array('tag' => 'Create Future Periods', 'link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'createperiods')));
     }
     $sidebar->addList('Actions', $sidebarlist);
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }