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 addInventoryAction() { if ($this->_request->isPost()) { if ($this->_request->getPost()) { $form_values = $this->_request->getPost(); $users = new Users(); $users->setUserName($form_values['user_name_add']); $users->setEmail($form_values['email']); $users->setCellNumber($form_values['phone']); $users->setLoginId($form_values['user_name_add']); $users->setPassword(base64_encode($form_values['password'])); if ($form_values['office_type_add'] == '1') { $location_id = '10'; $role_id = '3'; } if ($form_values['office_type_add'] == '2') { $location_id = $form_values['combo1_add']; $role_id = '4'; } if ($form_values['office_type_add'] == '3') { $location_id = $form_values['combo1_add']; $role_id = '5'; } if ($form_values['office_type_add'] == '4') { $location_id = $form_values['combo2_add']; $role_id = '6'; } if ($form_values['office_type_add'] == '5') { $location_id = $form_values['combo3_add']; $role_id = '7'; } $province_id = $this->_em->find('Locations', $location_id); $users->setLocation($province_id); $role = $this->_em->find('Roles', $role_id); $users->setRole($role); $stakeholder = $this->_em->find('Stakeholders', 1); $users->setStakeholder($stakeholder); $user = $this->_em->find('Users', $this->_userid); $users->setCreatedBy($user); $this->_em->persist($users); $this->_em->flush(); $user_id = $users->getPkId(); $warehouse_users = new WarehouseUsers(); $wh_id = $this->_em->find('Warehouses', $form_values['default_warehouse']); $warehouse_users->setWarehouse($wh_id); $warehouse_users->setIsDefault('1'); $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/im-users"); }