public function updateAction()
 {
     if ($this->request->isPost()) {
         $time = time();
         $usergroup = Usergroups::findFirstByUid($this->request->getPost('usergroup'));
         $filename = $this->littlehelpers->saveFile($this->request->getUploadedFiles(), $time, $usergroup);
         $clippingUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0;
         $clipping = Clippings::findFirstByUid($clippingUid);
         $clipping->assign(array('pid' => $this->request->getPost('project'), 'cruser_id' => $this->session->get('auth')['uid'], 'usergroup' => $this->request->getPost('usergroup'), 'tstamp' => $this->littlehelpers->processDateOnly($this->request->getPost('tstamp')), 'crdate' => $time, 'title' => $this->request->getPost('title'), 'description' => $this->request->getPost('description'), 'clippingtype' => $this->request->getPost('clippingtype'), 'mediumuid' => $this->request->getPost('medium'), 'url' => $this->request->getPost('url'), 'filelink' => $filename));
         if (!$clipping->update()) {
             $this->flashSession->error($clipping->getMessages());
         } else {
             $this->response->redirect('backend/' . $this->view->language . '/clippings/');
             $this->flashSession->success($this->translate('successUpdate'));
             $this->view->disable();
         }
     } else {
         $clippingUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0;
         $clipping = Clippings::findFirstByUid($clippingUid);
         $usergroup = Usergroups::findFirstByUid($clipping->usergroup);
         $projects = Projects::find(array('conditions' => 'deleted=0 AND usergroup =?1', 'bind' => array(1 => $usergroup->uid)));
         $medium = Medium::find(array('conditions' => 'deleted=0 AND hidden=0'));
         $this->view->setVar('medium', $medium);
         $this->view->setVar('usergroup', $usergroup);
         $this->view->setVar('projects', $projects);
         $this->view->setVar('clipping', $clipping);
     }
 }
 public function updateAction()
 {
     if ($this->request->isPost()) {
         $time = time();
         $usergroup = Usergroups::findFirstByUid($this->request->getPost('usergroup'));
         $filename = $this->littlehelpers->saveFile($this->request->getUploadedFiles(), $time, $usergroup);
         $documentUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0;
         $document = Documents::findFirstByUid($documentUid);
         $oldfile = $document->filelink;
         $document->assign(array('pid' => $this->request->getPost('pid'), 'cruser_id' => $this->session->get('auth')['uid'], 'usergroup' => $this->request->getPost('usergroup'), 'tstamp' => $this->littlehelpers->processDateOnly($this->request->getPost('tstamp')), 'crdate' => $time, 'title' => $this->request->getPost('title'), 'description' => $this->request->getPost('description'), 'filelink' => $filename));
         $this->createOldVersion($document->uid, $oldfile, $time);
         if (!$document->update()) {
             $this->flashSession->error($document->getMessages());
         } else {
             //$this->response->redirect('backend/'.$this->view->language.'/documents/update/'.$document->uid.'/');
             $this->flashSession->success($this->translate('successUpdate'));
             $this->view->disable();
         }
     } else {
         $documentUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0;
         $document = Documents::findFirstByUid($documentUid);
         $usergroup = Usergroups::findFirstByUid($document->usergroup);
         $projects = Projects::find(array('conditions' => 'deleted=0 AND hidden =0 AND usergroup =?1', 'bind' => array(1 => $usergroup->uid)));
         $this->view->setVar('usergroup', $usergroup);
         $this->view->setVar('projects', $projects);
         $this->view->setVar('document', $document);
     }
 }
 public function updateAction()
 {
     if ($this->request->isPost()) {
         $coordinationsUid = $this->request->hasPost('uid') ? $this->request->getPost('uid') : 0;
         $coordination = Coordinations::findFirstByUid($coordinationsUid);
         if ($coordination) {
             $coordination->assign(array('tstamp' => time(), 'title' => $this->request->hasPost('title') ? $this->request->getPost('title') : '', 'description' => $this->request->hasPost('description') ? $this->request->getPost('description') : '', 'icon' => $this->request->hasPost('icon') ? $this->request->getPost('icon') : ''));
             if (!$coordination->update()) {
                 $this->flashSession->error($medium->getMessages());
             } else {
                 $this->flashSession->success($this->translate('successUpdate'));
             }
         }
     } else {
         $coordinationsUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0;
         $coordination = Coordinations::findFirstByUid($coordinationsUid);
         $projectsArray = array();
         foreach ($coordination->getProjects() as $project) {
             $projectsArray[] = $project->uid;
         }
         $projects = Projects::find(array('conditions' => 'deleted=0 AND hidden =0 AND usergroup =?1', 'bind' => array(1 => $coordination->usergroup)));
         $usergroup = Usergroups::findFirstByUid($coordination->usergroup);
         $this->view->setVar('coordination', $coordination);
         $this->view->setVar('usergroup', $usergroup);
         $this->view->setVar('projects', $projects);
         $this->view->setVar('projectsarray', $projectsArray);
     }
 }
 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 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);
     }
 }
 public function updateAction()
 {
     if ($this->request->isPost()) {
         $time = time();
         $usergroup = Usergroups::findFirstByUid($this->request->getPost('usergroup'));
         $mediacontactsUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0;
         $mediacontacts = Mediacontacts::findFirstByUid($mediacontactsUid);
         $mediacontacts->assign(array('tstamp' => $time, 'crdate' => $time, 'cruser_id' => $this->session->get('auth')['uid'], 'usergroup' => $this->request->getPost('usergroup'), 'medium' => $this->request->getPost('medium'), 'title' => $this->request->getPost('title'), 'description' => $this->request->getPost('description'), 'starttime' => $this->littlehelpers->processDate($this->request->getPost('starttime')), 'endtime' => $this->littlehelpers->processDate($this->request->getPost('endtime'))));
         if (!$mediacontacts->update()) {
             $this->flashSession->error($mediacontacts->getMessages());
         } else {
             $this->flashSession->success($this->translate('successUpdate'));
         }
     } else {
         $mediacontactsUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0;
         $mediacontacts = Mediacontacts::findFirstByUid($mediacontactsUid);
         $usergroup = Usergroups::findFirstByUid($mediacontacts->usergroup);
     }
     $medium = Medium::find(array('conditions' => 'deleted=0 AND hidden=0'));
     $this->view->setVar('usergroup', $usergroup);
     $this->view->setVar('mediacontact', $mediacontacts);
     $this->view->setVar('medium', $medium);
 }
 public function updateAction()
 {
     if ($this->request->isPost()) {
         $time = time();
         $usergroup = Usergroups::findFirstByUid($this->request->getPost('usergroup'));
         $filename = $this->littlehelpers->saveFile($this->request->getUploadedFiles(), $time, $usergroup);
         $clippingUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0;
         $clipping = Clippingsoverview::findFirstByUid($clippingUid);
         $clipping->assign(array('cruser_id' => $this->session->get('auth')['uid'], 'usergroup' => $this->request->getPost('usergroup'), 'tstamp' => $this->littlehelpers->processDate($this->request->getPost('tstamp')), 'crdate' => $time, 'overviewyear' => $this->request->getPost('overviewyear'), 'overviewmonth' => $this->request->getPost('overviewmonth'), 'filelink' => $filename));
         if (!$clipping->update()) {
             $this->flashSession->error($clipping->getMessages());
         } else {
             $this->response->redirect('backend/' . $this->view->language . '/clippingsoverview/update/' . $clipping->uid . '/');
             $this->flashSession->success($this->translate('successUpdate'));
             $this->view->disable();
         }
     } else {
         $clippingUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0;
         $clipping = Clippingsoverview::findFirstByUid($clippingUid);
         $usergroup = Usergroups::findFirstByUid($clipping->usergroup);
         $this->view->setVar('usergroup', $usergroup);
         $this->view->setVar('clipping', $clipping);
     }
 }