public function updateAction()
 {
     if ($this->request->isPost()) {
         $time = time();
         $projectUid = $this->request->hasPost('uid') ? $this->request->getPost('uid') : 0;
         $project = Otherprojects::findFirstByUid($projectUid);
         $projectstates = $project->getProjectstates();
         foreach ($projectstates as $projecthistory) {
             $projecthistory->active = 0;
             $projecthistory->update();
         }
         if ($project) {
             $project->assign(array('usergroup' => $this->request->hasPost('usergroup') ? $this->request->getPost('usergroup') : 0, 'tstamp' => time(), 'title' => $this->request->getPost('title'), 'description' => $this->request->getPost('description'), 'starttime' => $this->request->hasPost('starttime') ? $this->littlehelpers->processDateOnly($this->request->getPost('starttime')) : 0, 'endtime' => $this->request->hasPost('endtime') ? $this->littlehelpers->processDateOnly($this->request->getPost('endtime')) : 0, 'status' => $this->request->hasPost('status') ? $this->request->getPost('status') : 0));
             if (!$project->update()) {
                 $this->flash->error($project->getMessages());
             }
         }
     } else {
         $projectUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0;
         $project = Otherprojects::findFirstByUid($projectUid);
         $projectstateArr = $project->getProjectstates(array('conditions' => 'deleted=0 AND hidden=0 AND active=1'));
         $projectstate = $projectstate[0];
     }
     $usergroups = Usergroups::find(array('conditions' => array('deleted=0 AND hidden =0')));
     $this->tag->setDefault("usergroup", $project->usergroup);
     $this->tag->setDefault("status", $project->status);
     $this->tag->setDefault("projectstate", $projectstate->statetype);
     $this->tag->setDefault("projecttype", $project->projecttype);
     $this->view->setVar('projectstatedesc', $projectstate->description);
     $this->view->setVar('usergroups', $usergroups);
     $this->view->setVar('project', $project);
 }
 public function updateAction()
 {
     if ($this->request->isPost()) {
         $time = time();
         $projectUid = $this->request->hasPost('uid') ? $this->request->getPost('uid') : 0;
         $project = Projects::findFirstByUid($projectUid);
         $projectstates = $project->getProjectstates();
         foreach ($projectstates as $projecthistory) {
             $projecthistory->active = 0;
             $projecthistory->update();
         }
         if ($project) {
             $project->assign(array('usergroup' => $this->request->hasPost('usergroup') ? $this->request->getPost('usergroup') : 0, 'tstamp' => time(), 'title' => $this->request->getPost('title'), 'description' => $this->request->getPost('description'), 'starttime' => $this->request->hasPost('starttime') ? $this->littlehelpers->processDateOnly($this->request->getPost('starttime')) : 0, 'endtime' => $this->request->hasPost('endtime') ? $this->littlehelpers->processDateOnly($this->request->getPost('endtime')) : 0, 'status' => $this->request->hasPost('status') ? $this->request->getPost('status') : 0, 'deadline' => $this->request->hasPost('deadline') ? $this->littlehelpers->processDateOnly($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->update()) {
                 $this->flash->error($project->getMessages());
             } else {
                 $projectstate = new Projectstates();
                 $projectstate->assign(array('pid' => $project->uid, 'cruser_id' => $this->session->get('auth')['uid'], 'usergroup' => $this->request->hasPost('usergroup') ? $this->request->getPost('usergroup') : 0, 'tstamp' => $this->request->hasPost('starttime') ? $this->littlehelpers->processDateOnly($this->request->getPost('starttime')) : 0, 'crdate' => $time, 'description' => $this->request->hasPost('projectstatedescription') ? $this->request->getPost('projectstatedescription') : 0, 'statetype' => $this->request->hasPost('projectstate') ? $this->request->getPost('projectstate') : 0, 'active' => 1));
                 $projectstate->save();
                 $this->flashSession->success($this->translate('successUpdate'));
             }
         }
     } else {
         $projectUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0;
         $project = Projects::findFirstByUid($projectUid);
         $projectstateArr = $project->getProjectstates(array('conditions' => 'deleted=0 AND hidden=0 AND active=1'));
         $projectstate = $projectstateArr[0];
     }
     $usergroups = Usergroups::find(array('conditions' => array('deleted=0 AND hidden =0')));
     $this->tag->setDefault("usergroup", $project->usergroup);
     $this->tag->setDefault("status", $project->status);
     $this->view->setVar("projectstate", $projectstate);
     $this->view->setVar('usergroups', $usergroups);
     $this->view->setVar('project', $project);
 }
 public function indexAction()
 {
     if ($this->request->isPost()) {
         $clippings = Clippings::find(array('conditions' => 'deleted = 0 AND hidden =0 AND usergroup = ?1', 'bind' => array(1 => $this->request->getPost('usergroup')), 'order' => 'pid ASC, tstamp DESC'));
         $usergroup = Usergroups::findFirstByUid($this->request->getPost('usergroup'));
         $this->view->setVar('usergroup', $usergroup);
         $this->view->setVar('clippings', $clippings);
         $this->view->setVar('customerselect', false);
     } else {
         $usergroups = Usergroups::find(array('conditions' => 'deleted = 0 AND hidden = 0', 'order' => 'title ASC'));
         $this->view->setVar('customerselect', true);
         $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);
 }
 public function initialize($entity = null, $options = null)
 {
     // In edition the id is hidden
     if (isset($options['edit']) && $options['edit']) {
         $uid = new Hidden('uid');
     } else {
         $uid = new Text('uid');
     }
     $this->add($uid);
     $username = new Text('username', array());
     $username->addValidators(array(new PresenceOf(array('message' => 'The name is required'))));
     $this->add($username);
     $password = new Password('password', array());
     $password->addValidators(array(new PresenceOf(array('message' => 'Password is required'))));
     $this->add($password);
     $last_name = new Text('last_name', array());
     $last_name->addValidators(array(new PresenceOf(array('message' => 'The lastname is required'))));
     $this->add($last_name);
     $first_name = new Text('first_name', array());
     $first_name->addValidators(array(new PresenceOf(array('message' => 'The firstname is required'))));
     $this->add($first_name);
     $title = new Text('title', array());
     $title->addValidators(array(new PresenceOf(array('message' => 'The title is required'))));
     $this->add($title);
     $email = new Text('email', array());
     $email->addValidators(array(new PresenceOf(array('message' => 'The email is required')), new Email(array('message' => 'The email is not valid'))));
     $this->add($email);
     $phone = new Text('phone', array());
     $this->add($phone);
     $address = new Text('address', array());
     $this->add($address);
     $city = new Text('city', array());
     $this->add($city);
     $zip = new Text('zip', array());
     $this->add($zip);
     $company = new Text('company', array());
     $this->add($company);
     $this->add(new Select("profileuid", Profiles::find(array('conditions' => 'deleted=0 AND hidden=0')), array('using' => array('uid', 'title'))));
     $this->add(new Select("usergroup", Usergroups::find(array('conditions' => 'deleted=0 AND hidden=0')), array('using' => array('uid', 'title'))));
     $this->add(new Select("userlanguage", Languages::find(array('conditions' => 'deleted=0 AND hidden=0')), array('using' => array('uid', 'title'))));
     $this->add(new Select('superuser', array('0' => ControllerBase::translate('no'), '1' => ControllerBase::translate('yes'))));
 }
 public function createAction()
 {
     if ($this->request->isPost()) {
         $time = time();
         $feuser = new Feusers();
         $feuser->assign(array("pid" => 0, 'tstamp' => $time, 'crdate' => $time, 'cruser_id' => $this->session->get('auth')['uid'], 'deleted' => 0, 'hidden' => 0, 'username' => $this->request->getPost('username'), 'password' => $this->myhash($this->request->getPost('password'), $this->unique_salt()), 'first_name' => $this->request->getPost('first_name'), 'last_name' => $this->request->getPost('last_name'), 'title' => $this->request->getPost('title'), 'email' => $this->request->getPost('email'), 'phone' => $this->request->getPost('phone'), 'address' => $this->request->getPost('address'), 'city' => $this->request->getPost('city'), 'zip' => $this->request->getPost('zip'), 'company' => $this->request->getPost('company'), 'profileid' => $this->request->getPost('profileuid'), 'usergroup' => $this->request->getPost('usergroup'), 'superuser' => $this->request->getPost('superuser'), 'userlanguage' => $this->request->getPost('userlanguage')));
         if (!$feuser->save()) {
             $this->flashSession->error($feuser->getMessages());
         } else {
             $this->flashSession->success("Feuser was created successfully");
         }
         /*Forces to rewrite ACL list on next request*/
         unlink('../app/cache/acl/data.txt');
     }
     $profiles = Profiles::find(array('conditions' => 'deleted=0 AND hidden=0'));
     $languages = Languages::find(array('conditions' => 'deleted=0 AND hidden=0'));
     $usergroups = Usergroups::find(array('conditions' => 'deleted=0 AND hidden=0'));
     $this->view->setVar('profiles', $profiles);
     $this->view->setVar('languages', $languages);
     $this->view->setVar('usergroups', $usergroups);
 }
 public function updateAction()
 {
     if ($this->request->isPost()) {
         $projectUid = $this->request->hasPost('uid') ? $this->request->getPost('uid') : 0;
         $project = Projects::findFirstByUid($projecttypeUid);
         if ($project) {
             $project->assign(array('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->update()) {
                 $this->flash->error($project->getMessages());
             }
         }
     } else {
         $projectUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0;
         $usergroups = Usergroups::find(array('conditions' => array('deleted=0 AND hidden =0')));
         $project = Projects::findFirstByUid($projectUid);
         $this->tag->setDefault("usergroup", $project->usergroup);
         $this->tag->setDefault("status", $project->status);
         $this->tag->setDefault("projecttype", $project->projecttype);
         $this->view->setVar('usergroups', $usergroups);
         $this->view->setVar('project', $project);
     }
 }