Example #1
0
 public function userAction()
 {
     $user_model = new Application_Model_User();
     $users = $user_model->fetchAll();
     $this->view->users = $users;
     $review_model = new Application_Model_Review();
     $reviews = $review_model->fetchAll();
     $this->view->reviews = $reviews;
     $song_model = new Application_Model_Song();
     $songs = $song_model->fetchAll();
     $this->view->songs = $songs;
 }
Example #2
0
 public function sendRequestNotification($requestId)
 {
     $request = new Application_Model_Request();
     $request = $request->find($requestId);
     if (false === $request) {
         return false;
     }
     $departmentId = $request->getDepartmentId();
     $dept = new Application_Model_Department();
     $dept = $dept->find($departmentId);
     if ($dept === false) {
         return false;
     }
     $user = new Application_Model_User();
     $users = $user->fetchAll("department_id='{$departmentId}' and status='active' and id ='{$dept->getDepartmentHeadId()}'");
     if (count($users) == 0) {
         return false;
     }
     $emails = array();
     foreach ($users as $_user) {
         $emails[$_user->getFirstName() . " " . $_user->getLastName()] = $_user->getEmail();
     }
     if (count($emails) == 0) {
         return false;
     }
     $user = new Application_Model_User();
     $requestedBy = $user->find($request->getRequestedBy());
     $from_email = $this->settingValue('admin_email');
     $from_name = $this->settingLable('admin_email');
     /*---Template-----*/
     $template = $this->getEmailTemplate('request_notification_email');
     $htmlBody = $template['body'];
     $htmlBody = str_replace("__REQUESTER_NAME__", $requestedBy->getFirstName() . " " . $requestedBy->getLastName(), $htmlBody);
     $htmlBody = str_replace("__REQUESTER_EMAIL__", $requestedBy->getEmail(), $htmlBody);
     $htmlBody = str_replace("__REQUESTER_EMP_CODE__", $requestedBy->getEmployeeCode(), $htmlBody);
     $htmlBody = str_replace("__REQUEST__", $request->getRequest(), $htmlBody);
     /*---------------------*/
     $subject = $template['subject'];
     $this->setBodyHtml($htmlBody);
     $this->setFrom($from_email, $from_name);
     $this->addTo($emails);
     $this->setSubject($subject);
     $this->send();
 }
 public function autoFriendNameAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $userNs = new Zend_Session_Namespace('members');
     $userId = $userNs->userId;
     $friendM = new Application_Model_Friend();
     $frienddata = $friendM->fetchAll();
     $friendids = array();
     foreach ($frienddata as $friend) {
         $friendids[] = $friend->getFriendId();
     }
     $q = strtolower($this->_getParam('term'));
     if (!$q) {
         return;
     }
     $where = "status='active'";
     //$where = "first_name like '%{$q}%' ";
     $where .= " AND (CONCAT(first_name,' ',last_name ) LIKE '%{$q}%' OR username LIKE '%{$q}%')";
     $userM = new Application_Model_User();
     $res = $userM->fetchAll($where, null, 11);
     $result = array();
     foreach ($res as $row) {
         if (in_array($row->getId(), $friendids)) {
             //array_push($result, array("id"=>$row->getId(), "value" => $row->getFirstName()));
             $name = $row->getFirstName() . " " . $row->getLastName();
             array_push($result, array("id" => $row->getId(), "value" => $name));
         }
     }
     echo Zend_Json::encode($result);
 }
 /**
  * Pulling data from the database for user informat
  * 
  * @return void
  */
 public function example5Action()
 {
     $users = new Application_Model_User();
     $user = $users->fetchAll();
     $this->view->users = array();
     foreach ($user as $u) {
         $this->view->users[] = array('name' => $u->name, 'id' => $u->ID);
     }
     $this->view->success = true;
 }
Example #5
0
 function indexAction()
 {
     $this->view->title = "User administration";
     $user = new Application_Model_User();
     $this->view->users = $user->fetchAll();
 }
Example #6
0
 /**
  * 编辑员工信息
  */
 public function editAction()
 {
     // 返回值数组
     $result = array('success' => true, 'info' => '编辑成功');
     $request = $this->getRequest()->getParams();
     $now = date('Y-m-d H:i:s');
     $user_session = new Zend_Session_Namespace('user');
     $user_id = $user_session->user_info['user_id'];
     $json = json_decode($request['json']);
     $updated = $json->updated;
     $inserted = $json->inserted;
     $deleted = $json->deleted;
     $employee = new Hra_Model_Employee();
     $user = new Application_Model_User();
     if (count($updated) > 0) {
         foreach ($updated as $val) {
             if ($employee->fetchAll("id != " . $val->id . " and email = '" . $val->email . "'")->count() > 0) {
                 $result['success'] = false;
                 $result['info'] = '更新失败,邮箱地址重复!';
                 echo Zend_Json::encode($result);
                 exit;
             } else {
                 if ($employee->fetchAll("id != " . $val->id . " and number = '" . $val->number . "'")->count() > 0) {
                     $result['success'] = false;
                     $result['info'] = '更新失败,工号重复!';
                     echo Zend_Json::encode($result);
                     exit;
                 } else {
                     $dept_manager_id = $val->dept_manager_id == '' ? null : $val->dept_manager_id;
                     $manager_id = $val->manager_id == '' ? null : $val->manager_id;
                     $dept_id = $val->dept_id == '' ? null : $val->dept_id;
                     $post_id = $val->post_id == '' ? null : $val->post_id;
                     $area_id = $val->area_id == '' ? null : $val->area_id;
                     $professional_qualifications_id = $val->professional_qualifications_id == '' ? null : $val->professional_qualifications_id;
                     $data = array('hide' => $val->hide, 'active' => $val->active, 'leader' => $val->leader, 'number' => $val->number, 'cname' => $val->cname, 'ename' => $val->ename, 'sex' => $val->sex, 'birthday' => $val->birthday, 'id_card' => $val->id_card, 'dept_id' => $dept_id, 'post_id' => $post_id, 'area_id' => $area_id, 'professional_qualifications_id' => $professional_qualifications_id, 'dept_manager_id' => $dept_manager_id, 'manager_id' => $manager_id, 'salary' => $val->salary, 'email' => $val->email, 'tel' => $val->tel, 'official_qq' => $val->official_qq, 'work_place' => $val->work_place, 'short_num' => $val->short_num, 'msn' => $val->msn, 'address' => $val->address, 'remark' => $val->remark, 'marital_status' => $val->marital_status, 'marry_day' => $val->marry_day, 'children_birthday' => $val->children_birthday, 'insurcode' => $val->insurcode, 'accumulation_fund_code' => $val->accumulation_fund_code, 'education' => $val->education, 'school' => $val->school, 'major' => $val->major, 'entry_date' => $val->entry_date, 'regularization_date' => $val->regularization_date, 'labor_contract_start' => $val->labor_contract_start, 'labor_contract_end' => $val->labor_contract_end, 'offical_address' => $val->offical_address, 'other_contact' => $val->other_contact, 'other_relationship' => $val->other_relationship, 'other_contact_way' => $val->other_contact_way, 'work_years' => $val->work_years, 'politics_status' => $val->politics_status, 'employment_type' => $val->employment_type, 'leave_date' => $val->leave_date, 'ext' => $val->ext, 'driving_license' => $val->driving_license, 'salary' => $val->salary, 'bank' => $val->bank, 'bank_num' => $val->bank_num, 'update_time' => $now, 'update_user' => $user_id);
                     $where = "id = " . $val->id;
                     try {
                         $employee->update($data, $where);
                     } catch (Exception $e) {
                         $result['success'] = false;
                         $result['info'] = $e->getMessage();
                         echo Zend_Json::encode($result);
                         exit;
                     }
                     if ($val->account == 1) {
                         if ($user->fetchAll("employee_id = " . $val->id)->count() > 0) {
                             $account_active = $val->account_active == true ? 1 : 0;
                             // 当员工系统账号已存在时,如需要改变账号状态,则更新系统账号状态信息
                             if ($user->fetchAll("active = " . $account_active . " and employee_id = " . $val->id)->count() == 0) {
                                 try {
                                     $user->update(array('active' => $account_active, 'update_user' => $user_id, 'update_time' => $now), "employee_id = " . $val->id);
                                 } catch (Exception $e) {
                                     $result['success'] = false;
                                     $result['info'] = $e->getMessage();
                                     echo Zend_Json::encode($result);
                                     exit;
                                 }
                             }
                         } else {
                             // 当员工系统账号不存在时,则添加新的系统账号信息
                             $data = array('employee_id' => $val->id, 'active' => $val->account_active, 'password' => md5($val->number . '123456'), 'create_time' => $now, 'create_user' => $user_id, 'update_time' => $now, 'update_user' => $user_id);
                             try {
                                 $newUserId = $user->insert($data);
                                 // 初始化用户角色为普通用户
                                 $roleMember = new Admin_Model_Member();
                                 try {
                                     $roleMember->insert(array('user_id' => $newUserId));
                                 } catch (Exception $e) {
                                     $result['success'] = false;
                                     $result['info'] = $e->getMessage();
                                     echo Zend_Json::encode($result);
                                     exit;
                                 }
                             } catch (Exception $e) {
                                 $result['success'] = false;
                                 $result['info'] = $e->getMessage();
                                 echo Zend_Json::encode($result);
                                 exit;
                             }
                         }
                     } else {
                         if ($user->fetchAll("employee_id = " . $val->id)->count() > 0) {
                             // 当员工系统账号已存在时,如需要改变账号状态,则更新系统账号状态信息
                             if ($user->fetchAll("active = " . $val->account_active . " and employee_id = " . $val->id)->count() == 0) {
                                 try {
                                     $user->update(array('active' => $val->account_active, 'update_user' => $user_id, 'update_time' => $now), "employee_id = " . $val->id);
                                 } catch (Exception $e) {
                                     $result['success'] = false;
                                     $result['info'] = $e->getMessage();
                                     echo Zend_Json::encode($result);
                                     exit;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (count($inserted) > 0) {
         foreach ($inserted as $val) {
             if ($employee->fetchAll("email = '" . $val->email . "'")->count() > 0) {
                 $result['success'] = false;
                 $result['info'] = '添加失败,邮箱地址重复!';
                 echo Zend_Json::encode($result);
                 exit;
             } else {
                 if ($employee->fetchAll("number = '" . $val->number . "'")->count() > 0) {
                     $result['success'] = false;
                     $result['info'] = '添加失败,工号重复!';
                     echo Zend_Json::encode($result);
                     exit;
                 } else {
                     $data = array('hide' => isset($val->hide) ? $val->hide : 0, 'active' => $val->active, 'leader' => $val->leader, 'number' => $val->number, 'cname' => $val->cname, 'ename' => $val->ename, 'sex' => $val->sex, 'birthday' => $val->birthday, 'id_card' => $val->id_card, 'dept_id' => $val->dept_id, 'post_id' => $val->post_id, 'area_id' => $val->area_id, 'professional_qualifications_id' => $val->professional_qualifications_id, 'dept_manager_id' => $val->dept_manager_id, 'manager_id' => $val->manager_id, 'salary' => $val->salary, 'email' => $val->email, 'tel' => $val->tel, 'official_qq' => $val->official_qq, 'work_place' => $val->work_place, 'short_num' => $val->short_num, 'msn' => $val->msn, 'address' => $val->address, 'remark' => $val->remark, 'marital_status' => $val->marital_status, 'marry_day' => $val->marry_day, 'children_birthday' => $val->children_birthday, 'insurcode' => $val->insurcode, 'accumulation_fund_code' => $val->accumulation_fund_code, 'education' => $val->education, 'school' => $val->school, 'major' => $val->major, 'entry_date' => $val->entry_date, 'regularization_date' => $val->regularization_date, 'labor_contract_start' => $val->labor_contract_start, 'labor_contract_end' => $val->labor_contract_end, 'offical_address' => $val->offical_address, 'other_contact' => $val->other_contact, 'other_relationship' => $val->other_relationship, 'other_contact_way' => $val->other_contact_way, 'work_years' => $val->work_years, 'politics_status' => $val->politics_status, 'employment_type' => $val->employment_type, 'leave_date' => $val->leave_date, 'ext' => $val->ext, 'driving_license' => $val->driving_license, 'salary' => $val->salary, 'bank' => $val->bank, 'bank_num' => $val->bank_num, 'create_time' => $now, 'create_user' => $user_id, 'update_time' => $now, 'update_user' => $user_id);
                     try {
                         $employee_id = $employee->insert($data);
                     } catch (Exception $e) {
                         $result['success'] = false;
                         $result['info'] = $e->getMessage();
                         echo Zend_Json::encode($result);
                         exit;
                     }
                     if ($val->account == 1 && $user->fetchAll("employee_id = " . $employee_id)->count() == 0) {
                         try {
                             $data = array('employee_id' => $employee_id, 'active' => $val->account_active, 'password' => md5($val->number . '123456'), 'create_time' => $now, 'create_user' => $user_id, 'update_time' => $now, 'update_user' => $user_id);
                             $newUserId = $user->insert($data);
                             // 初始化用户角色为普通用户
                             $roleMember = new Admin_Model_Member();
                             try {
                                 $roleMember->insert(array('user_id' => $newUserId));
                             } catch (Exception $e) {
                                 $result['success'] = false;
                                 $result['info'] = $e->getMessage();
                                 echo Zend_Json::encode($result);
                                 exit;
                             }
                         } catch (Exception $e) {
                             $result['success'] = false;
                             $result['info'] = $e->getMessage();
                             echo Zend_Json::encode($result);
                             exit;
                         }
                     }
                 }
             }
         }
     }
     if (count($deleted) > 0) {
         foreach ($deleted as $val) {
             if ($user->fetchAll("employee_id = " . $val->id)->count() == 0) {
                 try {
                     $employee->delete("id = " . $val->id);
                 } catch (Exception $e) {
                     $result['success'] = false;
                     $result['info'] = $e->getMessage();
                     echo Zend_Json::encode($result);
                     exit;
                 }
             } else {
                 $result['success'] = false;
                 $result['info'] = '员工ID' . $val->id . '存在关联系统账号,不能删除';
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }
Example #7
0
 /**
  * Método utilizado para exibir todos os registros do banco de dados.
  * @method retrieveAction
  * @access public
  * @return array $data
  */
 public function retrieveAction()
 {
     $user = new Application_Model_User();
     $this->view->data = $user->fetchAll();
 }
Example #8
0
 public function userLikeThisAction()
 {
     $this->_helper->layout->setLayout('journal-layout-2column');
     //$item_id = $this->_getParam("blog_id");
     $item_id = $this->_getParam("item_id");
     $item_type = $this->_getParam("type");
     //$userNs = new Zend_Session_Namespace('members');
     //$this->view->userId = $userNs->userId;
     $item = false;
     $itemTypeText = "";
     if ($item_type != "") {
         if ($item_type == 'blog') {
             $blogM = new Application_Model_Blog();
             $this->view->blog = $item = $blogM->find($item_id);
             $itemTypeText = "Journal Post";
         }
         if ($item_type == 'status_comment' || $item_type == 'blog_comment') {
             $commentM = new Application_Model_Comment();
             $item = $commentM->find($item_id);
             $itemTypeText = "Comment";
             $item_type = "comment";
         }
         if ($item_type == 'status') {
             $wallM = new Application_Model_Wall();
             $item = $wallM->find($item_id);
             $itemTypeText = "Wall Post";
         }
         $this->view->itemTypeText = $itemTypeText;
     }
     //if item is not exists then redirect to Journal home page
     if (false === $item) {
         $this->_helper->redirector()->gotoUrl('/journal/index/');
         exit;
     }
     //Now get all positive votes of item
     //$where		= "item_id = $item_id AND vote=1 AND item_type='blog'";
     $where = "item_id = {$item_id} AND vote=1";
     if ($item_type == 'comment') {
         $where .= " AND (item_type='status_comment' OR item_type='blog_comment')";
     } else {
         $where .= " AND item_type='{$item_type}'";
     }
     $voteM = new Application_Model_Vote();
     $rawdata = $voteM->fetchAll($where);
     //Get all users ID voted on an item
     if (false !== $rawdata) {
         $user_array = array();
         foreach ($rawdata as $row) {
             $user_array[] = $row->getUserId();
         }
     }
     //get all users information from above User Ids
     $this->view->totalUsers = 0;
     if (count($user_array) > 0) {
         $usrstr = implode(",", $user_array);
         $userM = new Application_Model_User();
         $whereuser = "******";
         $userData = $userM->fetchAll($whereuser, "first_name ASC");
         $this->view->userData = $userData;
         $settings = new Admin_Model_GlobalSettings();
         $page_size = $settings->settingValue('pagination_size');
         //$page_size = 1;
         $page = $this->_getParam('page', 1);
         $pageObj = new Base_Paginator();
         $paginator = $pageObj->fetchPageData($userM, $page, $page_size, $whereuser);
         $this->view->totalUsers = $pageObj->getTotalCount();
         $this->view->paginator = $paginator;
     }
 }
Example #9
0
 public function getAllUsers($status = "")
 {
     $obj = new Application_Model_User();
     if ($status == "") {
         $entries = $obj->fetchAll();
     } else {
         $entries = $obj->fetchAll("status='active'");
     }
     $arrUserLevel = array('' => "Select");
     foreach ($entries as $entry) {
         $arrUserLevel[$entry->getId()] = $entry->getFirstName() . " " . $entry->getLastName() . " - [ Code:" . $entry->getEmployeeCode() . " ]";
     }
     return $arrUserLevel;
 }
Example #10
0
 public function exportAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     include_once LIBRARY_PATH . "/Base/Excel/PHPExcel.php";
     $objPHPExcel = new PHPExcel();
     $where = "1=1 AND status!='deleted'";
     $order = "addedon DESC";
     // Add some data
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', 'S. No.')->setCellValue('B1', 'Username')->setCellValue('C1', 'First Name')->setCellValue('D1', 'Surname')->setCellValue('E1', 'Email')->setCellValue('F1', 'Gender')->setCellValue('G1', 'Number of Friends')->setCellValue('H1', 'Created On');
     $model = new Application_Model_User();
     $users = $model->fetchAll($where, $order);
     if (count($users) > 0) {
         $i = 2;
         $sno = 1;
         foreach ($users as $_user) {
             //select users Numbers of friends
             $noOfFriends = 0;
             $friendM = new Application_Model_Friend();
             $userFriends = $friendM->countUserFriends($_user->getId());
             $noOfFriends = $userFriends["totalFriends"];
             //$country = $_user->findParentRow('Application_Model_DbTable_Country','Country');
             // $state  =  $_user->findParentRow('Application_Model_DbTable_State','State');
             $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $i, $sno)->setCellValue('B' . $i, $_user->getUsername())->setCellValue('C' . $i, $_user->getFirstName())->setCellValue('D' . $i, $_user->getLastName())->setCellValue('E' . $i, $_user->getEmail())->setCellValue('F' . $i, ucfirst($_user->getSex()))->setCellValue('G' . $i, $noOfFriends)->setCellValue('H' . $i, date("M j, Y", $_user->getAddedOn()));
             $i++;
             $sno++;
         }
     }
     // Rename sheet
     $objPHPExcel->getActiveSheet()->setTitle('Users');
     $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(10);
     $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(35);
     $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
     $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(15);
     $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(45);
     $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
     $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(15);
     //$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(25);
     //$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(15);
     //$objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(15);
     //$objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(15);
     // Set active sheet index to the first sheet, so Excel opens this as the first sheet
     $objPHPExcel->setActiveSheetIndex(0);
     if ($this->_getParam('type') == 'xls') {
         // Redirect output to a client’s web browser (Excel5)
         header('Content-Type: application/vnd.ms-excel');
         header('Content-Disposition: attachment;filename="users.xls"');
         header('Cache-Control: max-age=0');
         $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
     } else {
         if ($this->_getParam('type') == 'pdf') {
             // Redirect output to a client’s web browser (Excel2007)
             header('Content-Type: application/pdf');
             header('Content-Disposition: attachment;filename="users.pdf"');
             header('Cache-Control: max-age=0');
             $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
         } else {
             if ($this->_getParam('type') == 'csv') {
                 // Redirect output to a client’s web browser (Excel5)
                 header('Content-Type: application/vnd.ms-excel');
                 header('Content-Disposition: attachment;filename="users.csv"');
                 header('Cache-Control: max-age=0');
                 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
             }
         }
     }
     $objWriter->save('php://output');
 }