public function createAction() { if ($this->request->isPost()) { $time = time(); $project = new Budgets(); $project->assign(array('cruser_id' => $this->session->get('auth')['uid'], 'usergroup' => $this->request->hasPost('usergroup') ? $this->request->getPost('usergroup') : 0, 'tstamp' => $time, 'crdate' => $time, 'title' => $this->request->getPost('title'), 'description' => $this->request->getPost('description'), 'starttime' => $this->request->hasPost('starttime') ? $this->littlehelpers->processDate($this->request->getPost('starttime')) : 0, 'endtime' => $this->request->hasPost('endtime') ? $this->littlehelpers->processDate($this->request->getPost('endtime')) : 0, 'status' => $this->request->hasPost('status') ? $this->request->getPost('status') : 0, 'deadline' => $this->request->hasPost('deadline') ? $this->littlehelpers->processDate($this->request->getPost('deadline')) : 0, 'projecttype' => $this->request->hasPost('projecttype') ? $this->request->getPost('projecttype') : 0, 'topic' => $this->request->hasPost('topic') ? $this->request->getPost('topic') : '', 'estcost' => $this->request->hasPost('estcost') ? $this->request->getPost('estcost') : 0, 'currentcost' => $this->request->hasPost('currentcost') ? $this->request->getPost('currentcost') : 0)); if (!$project->save()) { $this->flash->error($project->getMessages()); } else { //$this->response->redirect('backend/'.$this->view->language.'/projects/update/'.$project->uid.'/'); $this->flashSession->success($this->translate('successCreate')); //$this->view->disable(); } } else { $usergroups = Usergroups::find(array('conditions' => array('deleted=0 AND hidden =0'))); $this->view->setVar('usergroups', $usergroups); } }
public function updateAction() { if ($this->request->isPost()) { $time = time(); $contractruntimeUid = $this->request->hasPost('uid') ? $this->request->getPost('uid') : 0; $contractruntime = Contractruntime::findFirstByUid($contractruntimeUid); if ($contractruntime) { $contractruntime->assign(array('cruser_id' => $this->session->get('auth')['uid'], 'usergroup' => $this->request->hasPost('usergroup') ? $this->request->getPost('usergroup') : 0, 'tstamp' => $time, 'startdate' => $this->request->hasPost('startdate') ? $this->littlehelpers->processDateOnly($this->request->getPost('startdate')) : 0, 'enddate' => $this->request->hasPost('enddate') ? $this->littlehelpers->processDateOnly($this->request->getPost('enddate')) : 0, 'active' => $this->request->hasPost('active') ? $this->request->getPost('active') : 0)); if (!$contractruntime->update()) { $this->flashSession->error($contractruntime->getMessages()); } else { $this->clearBudgetamounts($contractruntime->uid); $budget = Budgets::findFirstByContractruntimeuid($contractruntime->uid); $budget->assign(array('cruser_id' => $this->session->get('auth')['uid'], 'usergroup' => $this->request->hasPost('usergroup') ? $this->request->getPost('usergroup') : 0, 'tstamp' => $time)); $budget->update(); $this->clearBudgetamounts($budget->uid); foreach ($this->request->getPost('amount') as $projecttypeuid => $amount) { $budgetAmount = new Budgets_projecttypes_lookup(); $budgetAmount->assign(array('tstamp' => $time, 'crdate' => $time, 'uid_local' => $budget->uid, 'uid_foreign' => $projecttypeuid, 'amount' => $amount)); $budgetAmount->save(); } $this->response->redirect('backend/' . $this->view->language . '/contractruntime/update/' . $contractruntime->uid . '/'); $this->flashSession->success($this->translate('successUpdate')); $this->view->disable(); } } } else { $contractruntimeUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0; $contractruntime = Contractruntime::findFirstByUid($contractruntimeUid); $budget = $contractruntime->getBudget(); } $budgetspecs = array(); foreach ($budget->getBudgetcount() as $budgetcount) { $budgetspecs[$budgetcount->uid_foreign] = $budgetcount->amount; } $usergroups = Usergroups::find(array('conditions' => array('deleted=0 AND hidden =0'))); $this->tag->setDefault("usergroup", $contractruntime->usergroup); $this->tag->setDefault("active", $contractruntime->active); $this->view->setVar('usergroups', $usergroups); $this->view->setVar('contractruntime', $contractruntime); $this->view->setVar('budgetspecs', $budgetspecs); }