public function addAction() { $form = new Form_Cadmin_User(); if ($this->_request->isPost()) { if ($form->isValid($this->_request->getPost())) { $user = new Users(); $user->setLoginId($form->login_id->getValue()); $user->setUserName($form->login_id->getValue()); $role_id = $this->_em->find('Roles', $form->role->getValue()); $user->setRole($role_id); $user->setEmail($form->email->getValue()); $user->setCellNumber($form->phone->getValue()); $user->setPassword(base64_encode($form->password->getValue())); $created_by = $this->_em->find('Users', $this->_userid); $user->setCreatedBy($created_by); $user->setLoggedAt(new \DateTime(date("0000-00-00"))); $stakeholder = $this->_em->find('Stakeholders', 1); $user->setStakeholder($stakeholder); $this->_em->persist($user); $this->_em->flush(); $user_wh = new WarehouseUsers(); $user_wh->setUser($user); $warehouse_id = $this->_em->find('Warehouses', $this->_request->getPost('warehouse')); $user_wh->setWarehouse($warehouse_id); $user_wh->setIsDefault(1); $this->_em->persist($user_wh); $this->_em->flush(); } } $this->_redirect("/cadmin/manage-users"); }
public function updateCampaignsAction() { if ($this->_request->isPost()) { if ($this->_request->getPost()) { $form_values = $this->_request->getPost(); $users = $this->_em->find('Users', $form_values['user_id']); $users->setUserName($form_values['user_name_update']); $users->setEmail($form_values['user_name_update']); $users->setCellNumber('03423423423'); $users->setLoginId($form_values['user_name_update']); if ($form_values['office_type_edit'] == '1') { $role = $this->_em->find('Roles', 14); $location_id = '10'; } if ($form_values['office_type_edit'] == '2') { $role = $this->_em->find('Roles', 15); $location_id = $form_values['combo1_edit']; } if ($form_values['office_type_edit'] == '4') { $role = $this->_em->find('Roles', 16); $location_id = $form_values['combo2_edit']; } $loc_id = $this->_em->find('Locations', $location_id); $users->setLocation($loc_id); $users->setRole($role); $stakeholder = $this->_em->find('Stakeholders', 10); $users->setStakeholder($stakeholder); $user = $this->_em->find('Users', $this->_userid); $users->setCreatedBy($user); $this->_em->persist($users); $this->_em->flush(); $user_id = $users->getPkId(); if ($form_values['office_type_edit'] == '4') { $warehouse_users = $this->_em->getRepository("WarehouseUsers")->findBy(array('user' => $form_values['user_id'])); foreach ($warehouse_users as $warehouse_users_a) { $wh_id = $this->_em->find('WarehouseUsers', $warehouse_users_a->getPkId()); $this->_em->remove($wh_id); $this->_em->flush(); } $warehouses = new Model_Warehouses(); $warehouses->form_values = $form_values; $warehouses->form_values['page'] = "campaigns"; $warehouse_id = $warehouses->getWarehouseIdByUcIdUpdate(); foreach ($warehouse_id as $wh_id_w) { $warehouse_users = new WarehouseUsers(); $wh_id = $this->_em->find('Warehouses', $wh_id_w); $warehouse_users->setWarehouse($wh_id); $user_id_i = $this->_em->find('Users', $user_id); $warehouse_users->setUser($user_id_i); $this->_em->persist($warehouse_users); $this->_em->flush(); } } } } $this->_redirect("/iadmin/manage-users/campaigns-users"); }