Exemplo n.º 1
0
 /**
  * JobAct::act_insert()
  * 新增岗位act
  * @return bool
  */
 public function act_insert()
 {
     if (!isset($_POST['jobName']) || trim($_POST['jobName']) == '') {
         exit("岗位名填写非法!");
     }
     if (!isset($_POST['jobPower']) || trim($_POST['jobPower']) == '') {
         exit("所属上级非法!");
     }
     if (!isset($_POST['jobDept']) || trim($_POST['jobDept']) == '' || !intval($_POST['jobDept'])) {
         exit("所属部门非法!");
     }
     $jobName = post_check(trim($_POST['jobName']));
     $jobPower = explode("|", post_check(trim($_POST['jobPower'])));
     $jobDept = intval($_POST['jobDept']);
     $newJob = array('jobName' => $jobName, 'jobDeptId' => $jobDept, 'jobPid' => $jobPower[1], 'jobCompanyId' => '1');
     $result = JobModel::jobInsert($newJob);
     if (!is_numeric($result)) {
         echo $result;
         exit;
     }
     $power = array();
     $usersingle = UserModel::getInstance();
     //获取当前用户信息
     $filed = ' a.*,b.job_name,c.dept_name,d.company_name';
     $where = " WHERE a.user_id='{$_SESSION[C('USER_AUTH_ID')]}' ";
     $userinfo = $usersingle->getUserInfo($filed, $where);
     $groupname = ActionModel::actionGroupList(C('AUTH_SYSTEM_ID'));
     //读取系统的actiongroup列表
     foreach ($groupname as $v) {
         if (is_array($_POST["{$v}"]) && isset($_POST["{$v}"])) {
             array_push($power, "\"{$v}\":" . json_encode($_POST["{$v}"]));
         } else {
             //array_push($power,"\"{$v}\":[]");
         }
     }
     $power = implode(",", $power);
     $power = "{" . $power . "}";
     $newJobpower = array('jobpowerPower' => json_decode($power, true), 'jobpowerMenu' => json_decode('["31"]', true), 'jobpowerJobId' => $result);
     $result = JobModel::jobPowerInsert($newJobpower);
     return $result;
 }