moders = $num; } else { $this->moders = m('flow_set')->getone(is_numeric($num) ? $num : "`num`='$num'"); if (!$this->moders) { $this->echomsg('模块[' . $num . ']不存在,请到[流程模块列表]下添加'); } } $this->daochubo = ($this->rock->post('execldown') == 'true') ? true : false; $table = $this->moders['table']; $this->modeid = $this->moders['id']; $this->modenum = $this->moders['num']; $this->modename = $this->moders['name']; $this->isflow = (int)$this->moders['isflow']; $this->settable($table); $this->mtable = $table; $this->viewmodel = m('view'); $this->chaomodel = m('flow_chao'); $this->billmodel = m('flow_bill'); $this->todomodel = m('flow_todo'); $this->todosmodel = m('flowtodo'); $this->flogmodel = m('flow_log'); $this->checksmodel = m('flow_checks'); $this->cnamemodel = m('flowcname'); $this->wheremodel = m('where'); $this->adminmodel = m('admin'); $this->remindmodel = m('remind'); $this->option = m('option'); $this->companyid = $this->adminmodel->getcompanyid(); $this->tfieldsarra(); $this->mwhere = "`table`='$this->mtable' and `mid`=-1"; if (!$this->defaultorder) { $sortdir = arrvalue($this->moders, 'sortdir'); if (!isempt($sortdir)) { $this->defaultorder = str_replace(' ', ',', $sortdir); } } $this->flowinit(); if ($id == null) { return $this; } $this->loaddata($id, true); return $this; } private function tfieldsarra() { $rows = m('flow_element')->getrows( "`mid`='$this->modeid' and `iszb`=0", '`name`,`fields`,`isbt`,`iszs`,`fieldstype`,`savewhere`,`data`,`isdr`,`iszb`,`issou`,`islu`,`islb`,`isonly`,`attr`', '`sort`' ); $this->fieldsarr = []; if ($rows) { foreach ($rows as $k => $rs) { if ($rs['islu'] == 1) { $this->fieldsarr[] = $rs; } } } $this->fieldsarra = $rows; } public function inputtitle() { return $this->moders['name']; } public function flowsearchfields() { $arr = []; if ($this->isflow > 0) { $arr[] = ['name' => '申请人...', 'fields' => 'uid']; $arr[] = ['name' => '提交人...', 'fields' => 'optid']; } return $arr; } public function loaddata($id, $ispd = true) { $this->id = (int)$id; $this->mwhere = "`table`='$this->mtable' and `mid`='$id'"; $swhere = "`id`='$id'"; $wherestr = $this->moders['where']; if (!isempt($wherestr)) { $wherestr = $this->rock->covexec($wherestr); $swhere .= ' and ' . $wherestr; } $this->rs = $this->getone($swhere); $this->uname = ''; if (!$this->rs) { $this->echomsg('数据记录不存在了'); } $this->rs['base_name'] = ''; $this->rs['base_deptname'] = ''; if (isset($this->rs['uid'])) { $this->uid = $this->rs['uid']; } if (isset($this->rs['comid'])) { $this->companyid = $this->rs['comid']; } if (!isset($this->rs['applydt'])) { $this->rs['applydt'] = ''; } if (!isset($this->rs['status'])) { $this->rs['status'] = 1; } $uisfield = property_exists($this, 'uidfields') ? $this->uidfields : 'optid'; if ($this->uid == 0 && isset($this->rs[$uisfield])) { $this->uid = $this->rs[$uisfield]; } $this->optid = isset($this->rs['optid']) ? $this->rs['optid'] : $this->uid; $this->urs = $this->adminmodel->getone( $this->uid, 'id,name,user,deptid,deptids,deptname,deptallname,face,ranking,superid,superpath,superman,deptpath' ); if ($this->isempt($this->rs['applydt']) && isset($this->rs['optdt'])) { $this->rs['applydt'] = substr($this->rs['optdt'], 0, 10); } if ($this->urs) { $this->drs = $this->db->getone('[Q]dept', "`id`='" . $this->urs['deptid'] . "'"); $this->uname = $this->urs['name']; $this->rs['base_name'] = $this->uname; if ($this->drs) { $this->rs['base_deptname'] = $this->drs['name']; } } $this->sericnum = ''; $this->billrs = $this->billmodel->getone($this->mwhere); if ($this->billrs) { $this->sericnum = $this->billrs['sericnum']; if (isempt(arrvalue($this->billrs, 'uname'))) { $this->savebill(); } if ($this->billrs['status'] != $this->rs['status']) { $this->billmodel->update('`status`=' . $this->rs['status'] . '', $this->billrs['id']); } if ($this->billrs['isturn'] != $this->rs['isturn']) { $this->billmodel->update('`isturn`=' . $this->rs['isturn'] . '', $this->billrs['id']); } if (isempt($this->rs['base_name'])) { $this->rs['base_name'] = $this->billrs['uname']; } if (isempt($this->rs['base_deptname'])) { $this->rs['base_deptname'] = $this->billrs['udeptname']; } } else { if ($this->isflow > 0) { $this->savebill(); } } if ($this->isflow > 0) { if ($this->rs['status'] == 1 && $this->rs['isturn'] == '0') { $this->update(['isturn' => 1], $this->id); $this->rs['isturn'] = 1; if ($this->billrs) { $this->billmodel->update('`isturn`=1', $this->billrs['id']); } } } $this->getlogrows = []; if ($ispd) { $this->isreadqx(); } $this->rssust = $this->rs; $this->flowchangedata(); $this->rs['base_systitle'] = TITLE; $this->rs['base_modename'] = $this->modename; $this->rs['base_sericnum'] = $this->sericnum; $this->rs['base_summary'] = $this->getsummary(); } public function getdaiban() { $s = $this->rock->dbinstr('nowcheckid', $this->adminid); $to = $this->billmodel->rows( '`modeid`=' . $this->modeid . ' and `isdel`=0 and `status` not in(1,2) and ' . $s . '' ); return $to; } public function isreadqx($glx = 0) { $bo = false; if ($this->adminid == 1) { $bo = true; } if ($this->uid == $this->adminid && $this->adminid > 0) { $bo = true; } if (!$bo && $this->isflow > 0) { if ($this->billrs) { $allcheckid = $this->billrs['allcheckid']; if (contain(',' . $allcheckid . ',', ',' . $this->adminid . ',')) { $bo = true; } } } if (!$bo) { if ($this->urs && contain($this->urs['superpath'], '[' . $this->adminid . ']')) { $bo = true; } } if (!$bo) { $tos = $this->todosmodel->rows("" . $this->mwhere . " and `uid`='$this->adminid'"); if ($tos > 0) { $bo = true; } } if (!$bo) { $tos = $this->chaomodel->rows( $this->mwhere . ' and ' . $this->rock->dbinstr('csnameid', $this->adminid) . '' ); if ($tos > 0) { $bo = true; } } if (!$bo) { $tos = $this->db->rows('[Q]todo', "`uid`='$this->adminid' and " . $this->mwhere . ""); if ($tos > 0) { $bo = true; } } if (!$bo) { $bo = $this->flowisreadqx(); } if (!$bo) { $bo = $this->isreadqxs(); } if (!$bo) { $tos = $this->isjiankongqx(); if ($tos > 0) { $bo = true; } } if ($glx == 1) { return $bo; } if (!$bo) { $this->echomsg( '无权限查看模块[' . $this->modenum . '.' . $this->modename . ']' . $this->uname . '的数据,请联系管理员到[流程模块→流程模块权限]下设置' ); } } public function isreadqxs() { $bo = false; $where = $this->viewmodel->viewwhere($this->moders, $this->adminid, $this->flowviewufieds); $where = str_replace('{asqom}', '', $where); $tos = $this->rows("`id`='$this->id' $where "); if ($tos > 0) { $bo = true; } return $bo; } public function iseditqx() { $bo = 0; if ($bo == 0 && $this->isflow > 0) { if ($this->billrs && ($this->uid == $this->adminid || $this->optid == $this->adminid)) { if ($this->billrs['nstatus'] == 0 || $this->billrs['nstatus'] == 2) { $bo = 1; } } if ($this->rs['status'] == 1) { $bo = 0; } } if ($bo == 0) { $where = $this->viewmodel->editwhere($this->moders, $this->adminid, $this->flowviewufieds); $where = str_replace('{asqom}', '', $where); $tos = $this->rows("`id`='$this->id' $where "); if ($tos > 0) { $bo = 1; } } return $bo; } public function isdeleteqx() { $bo = 0; if ($bo == 0 && $this->isflow > 0) { if ($this->billrs && ($this->uid == $this->adminid || $this->optid == $this->adminid)) { if ($this->billrs['nstatus'] == 0 || $this->billrs['nstatus'] == 2) { $bo = 1; } } if ($this->rs['status'] == 1) { $bo = 0; } } if ($bo == 0) { $where = $this->viewmodel->deletewhere($this->moders, $this->adminid, $this->flowviewufieds); $where = str_replace('{asqom}', '', $where); $tos = $this->rows("`id`='$this->id' $where "); if ($tos > 0) { $bo = 1; } } $isd = $this->flowisdeleteqx(); if (is_numeric($isd) && $isd <= 1) { $bo = $isd; } return $bo; } public function isjiankongqx() { $bo = 0; if ($bo == 0) { $where = $this->viewmodel->jiankongwhere($this->moders, $this->adminid, $this->flowviewufieds); $where = str_replace('{asqom}', '', $where); $tos = $this->rows("`id`='$this->id' $where "); if ($tos > 0) { $bo = 1; } } return $bo; } public function getfields($lx = 0) { $fields = []; if (!$this->fieldsarra) { $this->tfieldsarra(); } $farr = $this->fieldsarra; foreach ($farr as $k => $rs) { if ($rs['iszs'] == '1') { $fields[$rs['fields']] = $rs['name']; } } $fters = $this->flowgetfields($lx); if (is_array($fters)) { $fields = array_merge($fields, $fters); } return $fields; } public function getinputurl($num = '', $mid = 0, $can = []) { if ($num == '') { $num = $this->modenum; } $xa = 'lu'; if ($this->ismobile == 1) { $xa = 'lum'; } $url = 'index.php?a=' . $xa . '&m=input&d=flow&num=' . $num . '&mid=' . $mid . ''; if (is_array($can)) { foreach ($can as $k => $v) { $url .= '&' . $k . '=' . $v . ''; } } else { $url .= '&' . $can . ''; } return $url; } public function replacepbr(&$arr, $k) { $val = arrvalue($arr, $k); if (!c('html')->ishtml($val)) { $arr[$k] = str_replace("\n", '
', $val); } return $arr; } public function getdatalog($lx = 0, $isdy = 0) { m('log')->addread($this->mtable, $this->id); $this->todosmodel->biaoyidu($this->adminid, $this->modenum, $this->id); $fobj = m('file'); $this->ismobile = $lx; $arr['modename'] = $this->modename; $arr['title'] = $this->modename; $arr['modeid'] = $this->modeid; $arr['modenum'] = $this->modenum; $arr['mid'] = $this->id; $arr['status'] = arrvalue($this->rs, 'status'); $arr['logarr'] = $this->getlog(1); $arr['isplview'] = arrvalue($this->moders, 'ispl', '0'); $arr['isys'] = arrvalue($this->moders, 'isys', '0'); $contview = ''; $lsds = ($isdy == 2) ? $isdy : $lx; $path = '' . P . '/flow/page/view_' . $this->modenum . '_' . $lsds . '.html'; if (COMPANYNUM) { $path1 = '' . P . '/flow/page/view_' . $this->modenum . '_' . COMPANYNUM . '_' . $lsds . '.html'; if (file_exists($path1)) { $path = $path1; } } $fstr = $fobj->getstr($this->mtable, $this->id, 3); $issubtabs = 0; if ($fstr != '') { $this->rs['file_content'] = $fstr; } $data = $this->flowrsreplace($this->rs, ($isdy == 2) ? 3 : 1); $dataa = $this->viewjinfields([$data]); $data = $dataa[0]; $subdata = $this->getsuballdata(1); if ($subdata) { $zbzd = m('flow_element')->getrows( "`mid`='$this->modeid' and `iszb`>0 and `iszs`=1 and `fieldstype` in('uploadimg','uploadfile','textarea')", '`name`,`fields`,`fieldstype`,`iszb`', '`iszb`,`sort`' ); foreach ($subdata as $zb => $da) { $sub = $da['fields']; $data[$sub] = $this->getsubdata( $zb, $da['data'], arrvalue($data, 'subdatays' . $zb . '', $lx) ); $data['' . $sub . '_style'] = 'padding:0'; } } $farrobj = $chufarr = []; if (method_exists($this, 'flowxiangfields')) { $chufarr = $this->flowxiangfields($chufarr); } $farrobj['base_sericnum'] = ['name' => arrvalue($chufarr, 'base_sericnum', '单号')]; $farrobj['base_name'] = ['name' => arrvalue($chufarr, 'base_name', '申请人')]; $farrobj['base_deptname'] = ['name' => arrvalue($chufarr, 'base_deptname', '申请人部门')]; $farrobj['base_status'] = ['name' => arrvalue($chufarr, 'base_status', '流程状态')]; $farrobj['file_content'] = ['name' => arrvalue($chufarr, 'file_content', '相关文件')]; foreach ($this->fieldsarra as $k => $rs) { $fid = $rs['fields']; $fty = $rs['fieldstype']; if ($fty == 'uploadfile') { $fval = arrvalue($data, $fid); if (isempt($fval)) { $fval = '0'; } $data[$fid] = ''; if ($fval != '0') { $data[$fid] = $fobj->getstr('', '', 3, "`id` in($fval)"); } } if ($fty == 'uploadimg') { $fval = arrvalue($data, $fid); if (!isempt($fval) && substr($fval, 0, 4) != 'rock->gethttppath($fval); $data[$fid] = ''; } } if ($fty == 'textarea') { $this->replacepbr($data, $fid); } if ($fty == 'ditumap' && !isempt($rs['data'])) { $wzhi = arrvalue($data, $rs['data']); if (!isempt($wzhi)) { $data[$fid] .= '[查看地图]'; } } $farrobj[$fid] = $rs; } $_logarr = $qfields = []; foreach ($arr['logarr'] as $k1 => $rs1) { $_logarr[$rs1['id']] = $rs1; } $logrows = $this->flogmodel->getrows( $this->mwhere . ' and `modeid`=' . $this->modeid . ' and `courseid`>0 and `courseid`<88888 and `status`>0 and `valid`=1' ); foreach ($logrows as $k2 => $rs2) { $rs3 = $_logarr[$rs2['id']]; $_coid = $rs2['courseid']; if (!isempt($rs3['qmimg'])) { $rs3['name'] = ''; } $key1 = 'course' . $_coid . ''; if (!isset($data['' . $key1 . '_name'])) { $data['' . $key1 . '_name'] = $rs3['name']; $data['' . $key1 . '_zt'] = '' . $rs3['statusname'] . ''; $data['' . $key1 . '_sm'] = $rs3['sm']; $data['' . $key1 . '_dt'] = $rs3['checkdt']; } else { $data['' . $key1 . '_name'] .= ',' . $rs3['name']; $data['' . $key1 . '_sm'] .= ',' . $rs3['sm']; $data['' . $key1 . '_dt'] = $rs3['checkdt']; } $key2 = '' . $key1 . '_all'; if (!isset($data[$key2])) { $qfields[$key2] = $rs2['name']; $data[$key2] = ''; } $str1 = $rs3['name'] . ' ' . $rs3['statusname'] . ' ' . $rs3['checkdt'] . ''; if (!isempt($rs3['sm'])) { $str1 .= ',' . $rs3['sm'] . ''; } if ($data[$key2] != '') { $data[$key2] .= '
'; } $data[$key2] .= $str1; } $ztass = $this->getnowstatus(); $data['base_status'] = $ztass[3]; if (file_exists($path)) { $contview = $this->flowviewtpl(file_get_contents($path), $lx); preg_match_all('/\^(.*?)\^/', $contview, $list); foreach ($list[1] as $k => $nrs) { $fzdrs = arrvalue($farrobj, $nrs); if ($fzdrs) { $contview = str_replace('^' . $nrs . '^', $fzdrs['name'], $contview); } } $contview = $this->rock->reparr($contview, $data); } $arr['isdefaultview'] = 0; if ($this->isempt($contview) || contain($contview, '$contview$')) { $arr['isdefaultview'] = 1; $_fields = []; if ($this->isflow > 0) { $_fields['base_sericnum'] = $farrobj['base_sericnum']['name']; $_fields['base_name'] = $farrobj['base_name']['name']; $_fields['base_deptname'] = $farrobj['base_deptname']['name']; $_fields['base_status'] = $farrobj['base_status']['name']; } $fields = array_merge($_fields, $this->getfields($lx)); if ($fstr != '') { $fields['file_content'] = $farrobj['file_content']['name']; } foreach ($subdata as $zb => $da) { $fields[$da['fields']] = $da['name']; } if ($qfields) { $fields = array_merge($fields, $qfields); } if ($lx == 0) { foreach ($fields as $k => $rs) { $data['' . $k . '_style'] = 'width:75%'; break; } } $_colsr = $this->xiangbordercolor; if ($_colsr == '') { $_colsr = getconfig('bcolorxiang'); } $contvimr = c('html')->xiangtable($fields, $data, $_colsr); $contvimr = '
' . $contvimr . '
'; if ($lx == 1) { $contvimr = ''; if ($this->isflow > 0) { $contvimr .= '
' . $this->urs['name'] . '(' . $this->urs['ranking'] . ')
' . $this->urs['deptallname'] . '
'; unset($fields['base_name']); unset($fields['base_deptname']); } $contvimr .= '
'; foreach ($fields as $f => $n) { $vs = arrvalue($data, $f); if (!isempt($vs)) { if (substr($f, 0, 7) == 'subdata') { $contvimr .= ''; } else { $contvimr .= ''; } } } $contvimr .= '
' . $n . '
' . $vs . '
' . str_replace( ' ', '
', $n ) . '
' . $vs . '
'; } if (isempt($contview)) { $contview = $contvimr; } $contview = str_replace('$contview$', $contvimr, $contview); } unset($farrobj); $arr['contview'] = $contview; $arr['readarr'] = m('log')->getreadarr($this->mtable, $this->id); $arr['isedit'] = $this->iseditqx(); $arr['isdel'] = $this->isdeleteqx(); $arr['isflow'] = $this->isflow; $arr['modename'] = $this->modename; $arr['ischehui'] = $this->ischehui(); $arr['statustext'] = $ztass[4]; $arr['statuscolor'] = $ztass[1]; $arr['optmenu'] = $this->getoptmenu(1); $arr['isgbjl'] = (int)$this->rock->arrvalue($this->moders, 'isgbjl', '0'); $arr['isgbcy'] = (int)$this->rock->arrvalue($this->moders, 'isgbcy', '0'); $receiptrs = false; $receiptrow = m('receipt')->getall("`modenum`='$this->modenum' and `mid`='$this->id' and `status`=1"); foreach ($receiptrow as $k => $hrs) { $uid1 = ',' . $this->adminid . ','; if (!contain(',' . $hrs['receid'] . ',', $uid1)) { continue; } if (!contain(',' . $hrs['receids'] . ',', $uid1)) { $receiptrs = ['id' => $hrs['id'], 'optname' => $hrs['optname'],]; break; } } $arr['flowinfor'] = []; $arr['readunarr'] = []; $arr['receiptrs'] = $receiptrs; if ($this->isflow > 0) { $arr['flowinfor'] = $this->getflowinfor(); if ($arr['flowinfor']['ischeck'] == 1) { $arr['isplview'] = '0'; } } if (isset($data['title'])) { $arr['title'] = $data['title']; } $_oarr = $this->flowdatalog($arr); if (is_array($_oarr)) { foreach ($_oarr as $k => $v) { $arr[$k] = $v; } } $conta = $this->rock->matcharr($contview, 2); $edbof = false; foreach ($conta as $fids) { $thnr = ''; $contview = str_replace('`' . $fids . '`', $thnr, $contview); } $arr['contview'] = $contview; return $arr; } private function getsubdata($xu, $rows, $lx = 0) { $iscz = 0; $iszb = $xu + 1; $fields = 'subdata' . $xu . ''; $subrows = $this->db->getrows( '[Q]flow_element', '`mid`=' . $this->modeid . ' and `iszb`=' . $iszb . ' and `iszs`=1', '`fields`,`name`,`isalign`', '`sort`' ); $cont = ''; if ($this->db->count > 0) { $iscz = 1; $headstr = '@xuhaos,,center'; $colorbb = getconfig('bcolorxiang', '#cccccc'); foreach ($subrows as $k => $rs) { $headstr .= '@' . $rs['fields'] . ',' . $rs['name'] . ''; if ($rs['isalign'] == '1') { $headstr .= ',left'; } if ($rs['isalign'] == '2') { $headstr .= ',right'; } } foreach ($rows as $k => $rs) { $rows[$k]['xuhaos'] = $k + 1; } $slex = ($lx == 0) ? 'noborder' : ''; if ($this->subsubdatastyle != '') { $slex = $this->subsubdatastyle; } $cont = c('html')->createrows($rows, substr($headstr, 1), $colorbb, $slex); } return $cont; } public function ischehui() { $is = 0; if ($this->rs['status'] == 1 || $this->isflow == 3) { return $is; } $where = "" . $this->mwhere . " and `valid`=1 order by `id` desc"; $rs = $this->flogmodel->getone($where); $time = time() - 2 * 3600; if ($rs && $rs['status'] == '1' && $rs['checkid'] == $this->adminid && strtotime( $rs['optdt'] ) > $time && ($rs['courseid'] > 0 || $rs['iszb'] == '1')) { $is = $rs['id']; } return $is; } public function chehui($sm = '') { return $this->bd6('5peg5L!h5ZG8562!5o6I5peg5q2k5Yqf6IO9'); } public function bd6($str) { return $this->rock->jm->base64dencode($str); } public function getdataedit() { $fobj = m('file'); $arr['data'] = $this->flowrsreplaceedit($this->rssust); $arr['table'] = $this->mtable; $arr['tables'] = $this->moders['tables']; $arr['modeid'] = $this->modeid; $arr['isedit'] = $this->iseditqx(); $arr['isflow'] = $this->isflow; $arr['user'] = $this->urs; $arr['status'] = $this->rs['status']; $filers = $fobj->getfile($this->mtable, $this->id); foreach ($filers as $fk => $frs1) { $filers[$fk]['thumbpath'] = $fobj->getthumbpath($frs1); } $arr['filers'] = $filers; $arr['subdata'] = $this->getsuballdata(); $filearr = []; $fileids = ''; foreach ($this->fieldsarr as $k => $rs) { $fid = $rs['fields']; $flx = $rs['fieldstype']; if ($flx == 'uploadfile') { $fval = arrvalue($this->rssust, $fid); if (!isempt($fval)) { $fileids .= ',' . $fval . ''; } } if ($flx == 'uploadimg') { $arr['data']['' . $fid . '_view'] = $this->rock->gethttppath($arr['data'][$fid]); } } if ($fileids != '') { $frows = $fobj->getall( '`id` in(' . substr($fileids, 1) . ')', 'filename,id,filesizecn,fileext,optname,thumbpath,thumbplat' ); foreach ($frows as $k1 => $rs1) { $rs1['thumbpath'] = $fobj->getthumbpath($rs1); $filearr['f' . $rs1['id'] . ''] = $rs1; } } $arr['filearr'] = $filearr; $ztarr = $this->getnowstatus(); $arr['statustext'] = $ztarr[0]; $arr['statuscolor'] = $ztarr[1]; return $arr; } public function getflowinfor() { $ischeck = 0; $ischange = 0; $str = ''; $arr = $this->getflow(); if ($arr['nowcheckid'] != $this->billrs['nowcheckid']) { $this->getflowsave($arr, true); } $nstatus = $this->rs['status']; $isturn = $this->rs['isturn']; $nowcheckid = ',' . $arr['nowcheckid'] . ','; if ($isturn == 1 && $nstatus != 1 && contain($nowcheckid, ',' . $this->adminid . ',') && !in_array( $nstatus, [2, 5] )) { $ischeck = 1; } $logarr = $this->getlog(); $nowcur = $this->nowcourse; if (arrvalue($this->nextcourse, 'checktype') == 'change') { $ischange = 1; } $sarr['ischeck'] = $ischeck; $sarr['ischange'] = $ischange; $sarr['nowcourse'] = $nowcur; $sarr['iszhuanban'] = 0; $sarr['ischao'] = 0; $sarr['nextcourse'] = $this->nextcourse; $sarr['nstatustext'] = $arr['nstatustext']; if ($isturn == 0) { $sarr['nstatustext'] = '待提交'; } $_checkfields = arrvalue($nowcur, 'checkfields'); $checkfields = []; if ($ischeck == 1 && !isempt($_checkfields)) { $_checkfieldsa = explode('|', $_checkfields); $_checkfields = join(',', $_checkfieldsa); $_checkxuant = arrvalue($_checkfieldsa, 1); $inputobj = c('input'); $inputobj->flow = $this; $inputobj->mid = $this->id; $inputobj->urs = $this->urs; $elwswhere = "`mid`='$this->modeid' and `iszb`=0 and instr(',$_checkfields,', concat(',',`fields`,','))>0"; $infeidss = $inputobj->initFields($elwswhere); foreach ($infeidss as $_fs => $fsva) { $_sfes = $fsva['fields']; $_type = $fsva['fieldstype']; $showinpus = 1; $isbt = 1; if ($_checkxuant && contain(',' . $_checkxuant . ',', ',' . $_sfes . ',')) { $isbt = 0; } if ($_type == 'hidden' || $_type == 'fixed') { $showinpus = 2; } $_val = arrvalue($this->rssust, $_sfes); $cheo = (substr($_type, 0, 6) == 'change' && !isempt($fsva['data'])); if ($cheo) { $_val .= '|' . arrvalue($this->rssust, $fsva['data']) . ''; } $checkfields[$_sfes] = [ 'inputstr' => $inputobj->getfieldcontval($_sfes, $_val), 'name' => $fsva['name'], 'isbt' => $isbt, 'fieldstype' => $_type, 'fieldsarr' => $fsva, 'showinpus' => $showinpus ]; if ($cheo) { $_sfes = $fsva['data']; $checkfields[$_sfes] = [ 'inputstr' => '', 'isbt' => $isbt, 'name' => $fsva['name'] . 'id', 'fieldstype' => $_type, 'fieldsarr' => false, 'showinpus' => 2 ]; } } } $sarr['checkfields'] = $checkfields; if ($nstatus == 2) { $sarr['nstatustext'] = '待提交人处理(' . $this->urs['name'] . ')'; } $loglen = count($logarr); foreach ($logarr as $k => $rs) { if ($rs['courseid'] > 0) { $sty = ''; $col = $rs['color']; if ($str != '') { $str .= ' → '; } $str .= '' . $rs['actname'] . '(' . $rs['name'] . '' . $rs['statusname'] . ')'; } } if ($nstatus == '2') { if ($str != '') { $str .= ' → '; } $str .= $sarr['nstatustext']; } else { if ($nstatus == '5') { if ($str != '') { $str .= ' → '; } $sarr['nstatustext'] = '已作废'; $str .= '已作废'; } else { foreach ($this->flowarr as $k => $rs) { if ($rs['ischeck'] == 0) { $sty = 'color:#888888'; if ($rs['isnow'] == 1) { $sty = 'font-weight:bold;color:#800000'; } if ($str != '') { $str .= ' '; } $str .= '' . $rs['name'] . ''; if (!isempt($rs['nowcheckname'])) { $str .= '(' . $rs['nowcheckname'] . ')'; } $str .= ''; } } } } $sarr['flowcoursestr'] = $str; if ($nstatus == 1) { $sarr['nstatustext'] = $this->getnowstatus(1); } $actstr = ',同意|green,不同意|red'; if (isset($nowcur['courseact'])) { $actstrt = $nowcur['courseact']; if (!isempt($actstrt)) { $actstr = ',' . $actstrt; } } $act = c('array')->strtoarray($actstr); foreach ($act as $k => $as1) { if ($k > 0 && $as1[0] == $as1[1]) { $act[$k][1] = ''; } } if (arrvalue($this->moders, 'isys') == '1' && (int)arrvalue($nowcur, 'mid', '0') >= 0) { $act[25] = ['前加签', '', '']; $act[26] = ['后加签', '', '']; } $sarr['courseact'] = $act; $nowstatus = $this->rs['status']; if ($this->isflow > 0 && $this->rs['isturn'] == 0) { $nowstatus = 3; } $sarr['nowstatus'] = $nowstatus; $step = $this->rock->arrvalue($nowcur, 'step', '0'); $tuicourse = $this->flogmodel->getall( $this->mwhere . ' and `courseid`>0 and `valid`=1 and `status`=1 and `step`<' . $step . '', '`id`,`checkname`,`name`', '`step` desc' ); $sarr['tuicourse'] = $tuicourse; return $sarr; } public function updatestatus($zt) { $this->update('`status`=' . $zt . '', $this->id); $this->billmodel->update('`status`=' . $zt . '', $this->mwhere); } public function getstatusarr() { return $this->getstatus(null, '', '', 2); } public function getstatus($rs, $statusstr = '', $other = '', $glx = 0) { $statustext = $statuscolor = ''; if ($statusstr == '') { $statusstr = $this->rock->arrvalue($this->moders, 'statusstr'); } $statusara = []; $colorsa = [ 'blue', 'green', 'red', '#ff6600', '#526D08', '#888888', '', '', '', '', '', '', '', '', '', '', '', '', '' ]; if (isempt($statusstr)) { $statussst = '不同意'; $statusstr = '待?处理|blue,已审核|green,' . $statussst . '|red'; } $nowcheckname = arrvalue($rs, 'nowcheckname', arrvalue($this->billrs, 'nowcheckname')); if (isempt($other)) { $other = $nowcheckname; } $statusar = c('array')->strtoarray($statusstr); foreach ($statusar as $k => $v) { if ($v[0] == $v[1]) { $v[1] = arrvalue($colorsa, $k); } $statusara[$k] = $v; } $statusara[5] = ['已作废', '#888888']; $statusara[23] = ['退回', '#17B2B7']; if ($glx == 2) { return $statusara; } $isturn = -1; if (isset($rs['isturn'])) { $isturn = (int)$rs['isturn']; } $zt = $this->rock->arrvalue($rs, 'status'); if ($isturn == 0) { $statustext = '待提交'; $statuscolor = '#ff6600'; } elseif (!isempt($zt)) { if (isset($statusara[$zt])) { $statustext = $statusara[$zt][0]; $statuscolor = $statusara[$zt][1]; } } if (contain($statustext, '?')) { $statusstr = str_replace('?', '' . $other . '', $statustext); } else { $statusstr = '' . $statustext . ''; } if ($glx == 1) { return $statusstr; } return [ str_replace('?', $other, $statustext), $statuscolor, $zt, $statusstr, str_replace('?', '', $statustext) ]; } public function getstatusstr($rs) { return $this->getstatus($rs, '', '', 1); } public function getnowstatus($glx = 0) { return $this->getstatus($this->rs, '', '', $glx); } private $getlogrows = []; public function getlog($lx = 0) { if (isset($this->getlogrows[$lx])) { return $this->getlogrows[$lx]; } $rows = $this->flogmodel->getrows( $this->mwhere, '`checkname` as `name`,`checkid`,`name` as actname,`optdt`,`status`,`explain`,`statusname`,`valid`,`courseid`,`color`,`id`,`qmimg`', '`id` asc' ); $uids = $idss = ''; $dts = c('date'); $fo = m('file'); $editarrs = []; foreach ($rows as $k => $rs) { $uids .= ',' . $rs['checkid'] . ''; $idss .= ',' . $rs['id'] . ''; $col = $rs['color']; if (isempt($col)) { $col = 'green'; } if (contain($rs['statusname'], '不') || $rs['status'] == '2') { $col = 'red'; } $rows[$k]['color'] = $col; $rows[$k]['checkdt'] = $rs['optdt']; $rows[$k]['sm'] = $rs['explain']; if (!isempt($rs['qmimg'])) { if (!contain($rs['qmimg'], '.')) { $qmimg = '' . UPDIR . '/' . date('Y-m') . '/qmimg' . $rs['id'] . '.png'; $bo = true; if (!file_exists($qmimg)) { $bar = explode(',', $rs['qmimg']); $bo = $this->rock->createtxt($qmimg, base64_decode($bar[1])); } if (!$bo) { $qmimg = $rs['qmimg']; } else { $qmimg = '' . URL . '' . $qmimg . ''; } } else { $qmimg = $rs['qmimg']; if (!file_exists($qmimg)) { $qmimg = ''; } else { $qmimg = '' . URL . '' . $qmimg . ''; } } $rows[$k]['qmimg'] = $qmimg; if (!isempt($qmimg)) { $rows[$k]['explain'] = '' . $rs['explain'] . ''; } } } if ($idss != '') { $farr = $fo->getfile('flow_log', substr($idss, 1)); if ($farr) { foreach ($rows as $k => $rs) { $fstr = $fo->getallstr($farr, $rs['id'], 2); $rows[$k]['explain'] = $this->strappend($rs['explain'], $fstr, '
'); } } } if ($uids != '') { $rows = m('admin')->getadmininfor($rows, substr($uids, 1), 'checkid'); } $this->getlogrows[$lx] = $rows; return $rows; } public function addlog($arr = []) { $addarr = [ 'table' => $this->mtable, 'mid' => $this->id, 'checkname' => $this->adminname, 'checkid' => $this->adminid, 'optdt' => $this->rock->now, 'courseid' => '0', 'status' => '1', 'ip' => $this->rock->ip, 'web' => $this->rock->web, 'modeid' => $this->modeid ]; foreach ($arr as $k => $v) { $addarr[$k] = $v; } if (isset($addarr['explain'])) { $addarr['explain'] = htmlspecialchars($addarr['explain']); } $this->flogmodel->insert($addarr); $ssid = $this->db->insert_id(); $fileid = $this->rock->post('fileid'); if ($fileid != '') { m('file')->addfile($fileid, 'flow_log', $ssid, $this->modenum . '|' . $this->id); } $logfileid = $this->rock->post('logfileid'); if ($logfileid != '') { m('file')->addfile($logfileid, 'flow_log', $ssid, $this->modenum . '|' . $this->id); } $addarr['id'] = $ssid; $this->flowaddlog($addarr); $this->getlogrows = []; return $ssid; } public function submit($na = '', $sm = '') { if ($na == '') { $na = '提交'; } $isturn = 1; if ($na == '保存') { $isturn = 0; } $this->addlog(['name' => $na, 'explain' => $sm]); if ($this->isflow > 0) { $marr['isturn'] = $isturn; $marr['status'] = 0; $this->rs['status'] = 0; $this->update($marr, $this->id); if (arrvalue($this->moders, 'isflowlx') == '1' || $this->isflow >= 3) { $this->checksmodel->delete($this->mwhere); $this->flogmodel->update('`valid`=0', '' . $this->mwhere . ' and `courseid`>0 and `valid`=1'); } $farr = $this->getflow(); if ($farr['nowcourseid'] > 0) { $sysnextoptid = $this->rock->post('sysnextoptid'); $sysnextopt = $this->rock->post('sysnextopt'); $sysnextcustidid = (int)$this->rock->post('sysnextcustidid'); if ($sysnextcustidid == $farr['nowcourseid'] && !isempt($sysnextoptid) && !isempt($sysnextopt)) { $this->addcheckname($sysnextcustidid, $sysnextoptid, $sysnextopt, true, 1); $farr = $this->getflow(); } } $farr['status'] = 0; $this->savebill($farr); if ($isturn == 1) { $this->nexttodo($farr['nowcheckid'], 'submit'); } } $this->flowsubmit($na, $sm); $this->savecsname( $this->rock->post('syschaosongid'), $this->rock->post('syschaosong'), $this->adminid, 0, $isturn, $na ); if ($na == '编辑') { $this->gettodosend('boedit'); } else { $this->gettodosend('boturn'); } } private function savecsname($csnameid, $csname, $uid, $type, $isturn, $na) { if (!isempt($csnameid)) { $where = $this->mwhere . ' and `type`=' . $type . ''; if ($type > 0) { $where .= ' and `uid`=' . $uid . ''; } $csid = (int)$this->chaomodel->getmou('id', $where); if ($csid == 0) { $where = ''; } $this->chaomodel->record( [ 'modeid' => $this->modeid, 'table' => $this->mtable, 'mid' => $this->id, 'uid' => $uid, 'type' => $type, 'csname' => $csname, 'csnameid' => $csnameid, ], $where ); if ($isturn == 1) { $this->nexttodo($csnameid, 'chao', $na); } } } public function getcsname($id = 0) { if ($id > 0) { $where = "`table`='$this->mtable' and `mid`='$id' and `type`=0"; } else { $where = "`modeid`={$this->modeid} and `uid`={$this->adminid} and `type`=0"; $iscs = (int)$this->moders['iscs']; } $ors = $this->chaomodel->getone($where, '*', '`id` desc'); $csname = $csnameid = ''; if ($ors) { $csname = $ors['csname']; $csnameid = $ors['csnameid']; } return ['csname' => $csname, 'csnameid' => $csnameid, 'id' => $id,]; } public function zhuijiaexplain($sm = '') { $this->addlog(['explain' => $sm, 'name' => '追加说明', 'status' => 1,]); $zt = $this->rs['status']; if ($zt == 2 && $this->isflow > 0 && $this->adminid == $this->uid) { $marr['status'] = 0; $this->rs['status'] = 0; $this->update($marr, $this->id); $farr = $this->getflow(); $farr['status'] = 0; $this->savebill($farr); $this->nexttodo($farr['nowcheckid'], 'zhui', $sm); } $this->gettodosend('bozhui', '', $sm); } public function chuiban($sm = '') { $this->addlog(['explain' => $sm, 'name' => '催办', 'status' => 1,]); $farr = $this->getflow(true); $this->nexttodo($farr['nowcheckid'], 'cuiban', $sm); $this->gettodosend('cuiban', '', $sm); } public function getyushen($rows) { return $rows; } private function getyushenss($id, $rows, $xu, $isq) { if ($xu == 0) { $this->_tempauoe = []; } if (isset($rows[$id])) { $_tars = $rows[$id]; if ($isq == 1) { $this->getyushenss($_tars['id'], $rows, $xu + 1, $isq); } $this->_tempauoe[] = $_tars; if ($isq == 0) { $this->getyushenss($_tars['id'], $rows, $xu + 1, $isq); } } return $this->_tempauoe; } public function getflowpipei($uid = 0) { $urs = $this->urs; if (!$urs) { $urs = $uid; } if (!is_array($urs)) { $urs = $this->db->getone('[Q]admin', "`id`='$urs'", '`deptid`,`deptpath`,`id`'); } $coursedb = m('flowcourse'); $barr = $coursedb->pipeiCourse($this->modeid); $rows = $barr['rows']; $this->pipeiCoursearrc = $barr['rowd']; $this->pipeiCoursearrs = []; $this->pipeiCoursearr = []; $kqobj = m('kaoqin'); $this->getflowpipeis($rows, $urs, $kqobj); unset($this->pipeiCoursearrs); unset($this->pipeiCoursearrc); return $this->getyushen($this->pipeiCoursearr); } private function getflowpipeis($rows, $urs, $kqobj) { $shiyong = []; $defix = $xuhao = 0; $uid = arrvalue($urs, 'id', 0); $zshu = count($rows); foreach ($rows as $k => $rs) { $whereid = (int)$rs['whereid']; $receid = $rs['receid']; $wherestr = arrvalue($rs, 'where'); if ($rs['status'] == '0') { continue; } if (!isempt($wherestr)) { $wherestr = m('base')->strreplace($this->rock->jm->base64decode($wherestr), $uid); $to = $this->rows("`id`='$this->id' and $wherestr "); if ($to == 0) { continue; } } if ($whereid > 0) { $bo = $this->wheremanzhu($whereid); if (!$bo) { continue; } } if (!isempt($rs['num'])) { $bo = $this->flowcoursejudge($rs['num'], $rs); if (is_bool($bo) && !$bo) { continue; } } $xuhao++; if ($defix == 0 && (isempt($receid) || contain($receid, 'all'))) { $defix = $xuhao; } if (isempt($receid) && (!isempt($wherestr) || $whereid > 0)) { $defix = $xuhao; } $rs['xuhao'] = $xuhao; $shiyong[] = $rs; } $pboss = false; if ($shiyong) { $gxuha = $kqobj->getpipeimid($urs, $shiyong, 'xuhao', $defix); if ($gxuha > 0) { $pboss = true; $gxuha = $gxuha - 1; $prs = $shiyong[$gxuha]; $this->getflowpipeisss($prs, $urs, $kqobj); } } if (!$pboss && $zshu == 1 && $rows[0]['childshu'] > 0) { $this->getflowpipeis($rows[0]['children'], $urs, $kqobj); } } private function getflowpipeisss($prsnrs, $urs, $kqobj) { $prs = $prsnrs; unset($prs['children']); $this->pipeiCoursearrs[] = $prs['id']; $this->pipeiCoursearr[] = $prs; if ($prs['childshu'] > 0) { $this->getflowpipeis($prsnrs['children'], $urs, $kqobj); } else { $nid = arrvalue($prs, 'nid', '0'); if ($nid > 0 && !in_array($nid, $this->pipeiCoursearrs) && isset($this->pipeiCoursearrc, $nid)) { $this->getflowpipeis([$this->pipeiCoursearrc[$nid]], $urs, $kqobj); } } } public function getflow($sbo = false) { $this->flowarr = []; $allcheckid = $nowcheckid = $nowcheckname = $nstatustext = ''; $allcheckids = []; $nowcourseid = 0; $nstatus = $this->rs['status']; $this->nowcourse = []; $this->nextcourse = []; $this->flowisend = 0; $curs = $this->flogmodel->getrows( $this->mwhere, 'checkid,checkname,courseid,`valid`,`status`,`statusname`,`name`,`iszb`', 'id desc' ); $cufss = $ztnas = $chesarr = []; foreach ($curs as $k => $rs) { if ($rs['iszb'] == '1' && !in_array($rs['checkid'], $allcheckids)) { $allcheckids[] = $rs['checkid']; } if ($rs['courseid'] == '0') { continue; } $_su = '' . $rs['courseid'] . ''; $_su1 = '' . $rs['courseid'] . '_' . $rs['checkid'] . ''; if ($rs['valid'] == 1 && in_array($rs['status'], $this->flowstatusarr)) { if (!isset($cufss[$_su])) { $cufss[$_su] = 0; } $cufss[$_su]++; $chesarr[$_su1] = 1; } if (!in_array($rs['checkid'], $allcheckids)) { $allcheckids[] = $rs['checkid']; } if ($nstatustext == '' && $rs['courseid'] > 0) { $nstatustext = '' . $rs['checkname'] . '处理' . $rs['statusname'] . ''; $nstatus = $rs['status']; } $ztnas[$rs['courseid']] = '' . $rs['checkname'] . '' . $rs['statusname'] . ''; } $nowstep = $zongsetp = -1; $isend = 0; $czt = $this->rs['status']; $coutye = 0; $rows = ($czt == 1 || $czt == 5) ? [] : $this->getflowpipei($this->uid); if ($rows) { $checksa = $this->checksmodel->getrows($this->mwhere . ' and `addlx`=3'); $coursea = $nrows = []; foreach ($checksa as $k => $rs) { $coursea[$rs['courseid']] = '1'; } $nrows = []; $allcheckid = ''; $isoptsuperbo = false; foreach ($rows as $k => $rs) { $uarr = $this->getcheckname($rs); $rows[$k]['checkid'] = $uarr[0]; $rows[$k]['checkname'] = $uarr[1]; $allcheckid .= ',' . $uarr[0] . ''; if ($rs['checktype'] == 'optsuper' && isempt($uarr[0])) { $isoptsuperbo = true; } } if ($isoptsuperbo) { foreach ($rows as $k => $rs) { if ($rs['checktype'] == 'optsuper') { $_k1 = $k - 1; $_uid = $this->optid; if ($_k1 >= 0) { $ours = $this->flogmodel->getone( $this->mwhere . ' and `courseid`=' . $rows[$_k1]['id'] . ' and `valid`=1 ', '`checkid`', '`id` desc' ); if (!$ours) { $_uid = (int)$rows[$_k1]['checkid']; } else { $_uid = $ours['checkid']; } } $uarr = $this->adminmodel->getsuperman($_uid); if ($uarr) { $rows[$k]['checkid'] = $uarr[0]; $rows[$k]['checkname'] = $uarr[1]; } } } } foreach ($rows as $k => $rs) { $nrows[] = $rs; if ($rs['checktype'] == 'superall') { $ids1 = $rs['id']; $suparr = $this->adminmodel->getsuperarr($this->uid); if ($suparr) { $logdsar = $this->getlog(); foreach ($logdsar as $k1 => $rs1) { if ($rs1['courseid'] > 0 && $rs1['status'] == '1' && $rs1['valid'] == '1') { $allcheckid .= ',' . $rs1['checkid'] . ''; } } foreach ($suparr as $k1 => $surs) { if (!contain(',' . $allcheckid . ',', ',' . $surs['id'] . ',')) { $rs['oldid'] = $ids1; $rs['id'] = $ids1 * 99999 + $surs['id']; $rs['checkid'] = $surs['id']; $rs['checkname'] = $surs['name']; $rs['iszf'] = 0; $nrows[] = $rs; $allcheckid .= ',' . $surs['id'] . ''; } } } } } $yisheh = ''; if ($this->isflow == 2) { $logdsar = $this->getlog(); foreach ($logdsar as $k1 => $rs1) { if ($rs1['courseid'] > 0 && $rs1['status'] == 1 && $rs1['valid'] == 1) { $yisheh .= ',' . $rs1['checkid'] . ''; } } } foreach ($nrows as $k => $rs) { $whereid = (int)$rs['whereid']; $checkshu = $rs['checkshu']; $checkid = $rs['checkid']; $checkname = $rs['checkname']; $checktype = $rs['checktype']; if ($this->isflow == 2 && !isempt($checkid) && isempt($rs['checkfields'])) { if (($checkid == $this->uid || $checkid == $this->optid)) { continue; } $k2 = $k + 1; $ntype = 'yes'; if (isset($nrows[$k2])) { if ($nrows[$k2]['checktype'] == 'change') { $ntype = 'no'; } } if ($ntype == 'yes' && contain(',' . $yisheh . ',', ',' . $checkid . ',')) { continue; } } if (!isempt($checkid)) { $yisheh .= ',' . $checkid . ''; } $zongsetp++; $ischeck = 0; $checkids = $checknames = ''; $_su = '' . $rs['id'] . ''; $nowshu = 0; if (isset($cufss[$_su])) { $nowshu = $cufss[$_su]; } if (!$this->isempt($checkid)) { $checkida = explode(',', $checkid); $checkidna = explode(',', $checkname); $_chid = $_chna = ''; foreach ($checkida as $k1 => $chkid) { $_su1 = '' . $rs['id'] . '_' . $chkid . ''; if (!in_array($chkid, $allcheckids)) { $allcheckids[] = $chkid; } if (!isset($chesarr[$_su1])) { $_chid .= ',' . $chkid . ''; $_chna .= ',' . arrvalue($checkidna, $k1) . ''; } } if ($_chid != '') { $_chid = substr($_chid, 1); } if ($_chna != '') { $_chna = substr($_chna, 1); } if ($_chid == '') { $ischeck = 1; } else { if ($checkshu > 0 && $nowshu >= $checkshu) { $ischeck = 1; } } $checkids = $_chid; $checknames = $_chna; } else { if ($checkshu > 0 && $nowshu >= $checkshu) { $ischeck = 1; } if ($checkshu == 0 && $nowshu > 0) { $ischeck = 1; } } if ($ischeck == 0 && $coutye == 0) { if ((int)arrvalue($rs, 'coursetype', '0') > 0) { $coutye = 1; } } $rs['ischeck'] = $ischeck; $rs['islast'] = 0; $rs['checkid'] = $checkid; $rs['checkname'] = $checkname; $rs['nowcheckid'] = $checkids; $rs['nowcheckname'] = $checknames; $rs['isnow'] = 0; $rs['nowstep'] = $zongsetp; $rs['step'] = $k + 1; if ($ischeck == 0 && $nowstep == -1) { $rs['isnow'] = 1; $nowstep = $zongsetp; $this->nowcourse = $rs; $nowcourseid = $rs['id']; $nowcheckid = $checkids; $nowcheckname = $checknames; } if ($nowstep > -1 && $zongsetp == $nowstep + 1) { $this->nextcourse = $rs; } $this->flowarr[] = $rs; } } if ($zongsetp > -1) { $this->flowarr[$zongsetp]['islast'] = 1; } if ($nowstep == -1) { $isend = 1; } else { $nstatustext = '待' . $nowcheckname . '处理'; } $this->flowisend = $isend; $allcheckid = join(',', $allcheckids); $arrbill['allcheckid'] = $allcheckid; $arrbill['nowcourseid'] = $nowcourseid; $arrbill['nowcheckid'] = $nowcheckid; $arrbill['nowcheckname'] = $nowcheckname; $arrbill['nstatustext'] = $nstatustext; $arrbill['nstatus'] = $nstatus; $arrbill['status'] = $this->rs['status']; $arrbill['isturn'] = $this->rs['isturn']; if ($sbo) { $this->getflowsave($arrbill); } return $arrbill; } public function wheremanzhu($id) { $uid = $this->uid; $ser = $this->wheremodel->getflowwhere($id, $uid); if (!$ser) { return true; } $str = $ser['ntr']; if (!isempt($str)) { $to = $this->db->rows('[Q]admin', "`id`='$uid' and ($str)"); if ($to > 0) { return false; } } $str = $ser['str']; if (!isempt($str)) { $str = str_replace('{asqom}', '', $str); $to = $this->rows("`id`='$this->id' and $str"); if ($to == 0) { return false; } } $str = $ser['utr']; if (!isempt($str)) { $to = $this->db->rows('[Q]admin', "`id`='$uid' and $str"); if ($to == 0) { return false; } } return true; } public function getflowsave($sarr, $suvu = false) { if (!$sarr) { return; } if ($suvu) { $sarr['updt'] = $this->rock->now; } $this->billmodel->update($sarr, $this->mwhere); } private function getcheckname($crs) { $type = $crs['checktype']; $cuid = $name = ''; $courseid = $crs['id']; $cheorws = $this->checksmodel->getall( $this->mwhere . ' and `courseid`=' . $courseid . '', 'checkid,checkname' ); if ($cheorws) { foreach ($cheorws as $k => $rs) { $lxss = $rs['checkid']; if (isempt($lxss) || $lxss == '0') { continue; } $cuid .= ',' . $lxss . ''; $name .= ',' . $rs['checkname'] . ''; } if ($cuid != '') { $cuid = substr($cuid, 1); $name = substr($name, 1); return [$cuid, $name]; } } if (!$this->isempt($crs['num'])) { $uarr = $this->flowcheckname($crs['num']); if (is_array($uarr)) { if (!$this->isempt($uarr[0])) { return $uarr; } } } if ($type == 'super' || $type == 'superall') { $cuid = $this->urs['superid']; $name = $this->urs['superman']; } if ($type == 'dept' || $type == 'super' || $type == 'superall') { if ($this->isempt($cuid) && $this->drs) { $cuid = $this->drs['headid']; $name = $this->drs['headman']; } } if ($type == 'apply') { $cuid = $this->urs['id']; $name = $this->urs['name']; } if ($type == 'opt') { $cuid = $this->rs['optid']; $name = $this->rs['optname']; if (isempt($cuid)) { $cuid = $this->urs['id']; $name = $this->urs['name']; } } if ($type == 'user') { $cuid = $crs['checktypeid']; $name = $crs['checktypename']; } if ($type == 'rank') { $rank = $crs['checktypename']; if (!$this->isempt($rank)) { $wheer1 = $this->adminmodel->getcompanywhere(5, '', $this->companyid); $rnurs = $this->db->getrows( '[Q]admin', "`status`=1 and `ranking`='$rank' " . $wheer1 . "", 'id,name', 'sort' ); foreach ($rnurs as $k => $rns) { $cuid .= ',' . $rns['id'] . ''; $name .= ',' . $rns['name'] . ''; } if ($cuid != '') { $cuid = substr($cuid, 1); $name = substr($name, 1); } } } if ($type == 'cname') { $cnbar = $this->cnamemodel->getcheckname($crs['checktypeid'], $this->uid); $cuid = arrvalue($cnbar, 0); $name = arrvalue($cnbar, 1); } if ($type == 'field') { $fids = $crs['checktypeid']; if (!isempt($fids)) { $vals = ''; $farrs = explode(',', $fids); foreach ($farrs as $fid) { $vid = arrvalue($this->rs, $fid); if (!isempt($vid)) { $vals .= ',' . $vid . ''; } } if ($vals != '') { $vals = substr($vals, 1); $uarr = $this->adminmodel->getrows( '`status`=1 and `id` in(' . $vals . ')', 'id,name', 'FIELD(`id`,' . $vals . ')' ); foreach ($uarr as $k => $rs) { $cuid .= ',' . $rs['id'] . ''; $name .= ',' . $rs['name'] . ''; } if ($cuid != '') { $cuid = substr($cuid, 1); $name = substr($name, 1); } } } } $cuid = $this->rock->repempt($cuid); $name = $this->rock->repempt($name); return [$cuid, $name]; } public function createbianhao($num, $fid, $wshu = 3) { if (isempt($num)) { $num = '' . $this->modenum . '-'; } @$appdt = $this->rs['applydt']; if (isempt($appdt)) { $appdt = $this->rock->date; } $apdt = str_replace('-', '', substr($appdt, 0, 10)); $num = str_replace('Ymd', $apdt, $num); return $this->db->sericnum($num, '[Q]' . $this->mtable . '', $fid, $wshu); } public function createinputnum($num, $fid) { $acta = ''; if (method_exists($this, $num)) { $acta = $num; } else { if (contain($num, ',')) { $arra = explode(',', $num); $acta = $arra[0]; $num = $arra[1]; } } if ($acta && method_exists($this, $acta)) { $barr = $this->$acta($num); if (is_array($barr)) { $qom = arrvalue($barr, 'qom', $num); $wshu = arrvalue($barr, 'wshu', 3); $bom = arrvalue($barr, 'bom'); $fields = arrvalue($barr, 'fields', $fid); return $this->createbianhao($qom, $fields, $wshu) . $bom; } else { if (isempt($barr)) { $barr = $num; } return $this->createbianhao($barr, $fid); } } else { return $this->createbianhao($num, $fid); } } public function createnum() { $num = $this->moders['sericnum']; if ($num == '无' || $this->isempt($num)) { $num = 'TM-Ymd-'; } @$appdt = $this->rs['applydt']; if (isempt($appdt)) { $appdt = $this->rock->date; } $apdt = str_replace('-', '', $appdt); $num = str_replace('Ymd', $apdt, $num); return $this->db->sericnum($num, '[Q]flow_bill', 'sericnum', 3); } public function savebill($oarr = []) { $dbs = $this->billmodel; $whes = $this->mwhere; $birs = $dbs->getone($whes); $arr = [ 'table' => $this->mtable, 'mid' => $this->id, 'optdt' => isset($this->rs['optdt']) ? $this->rs['optdt'] : $this->rock->now, 'optname' => $this->adminname, 'optid' => $this->adminid, 'modeid' => $this->modeid, 'updt' => $this->rock->now, 'isturn' => $this->rs['isturn'], 'nstatus' => $this->rs['status'], 'applydt' => $this->rs['applydt'], 'modename' => $this->modename, 'uname' => $this->rs['base_name'], 'udeptname' => $this->rs['base_deptname'], 'uid' => $this->uid, ]; foreach ($oarr as $k => $v) { $arr[$k] = $v; } if (!$birs) { $arr['isdel'] = '0'; $arr['status'] = $arr['nstatus']; $arr['createdt'] = $arr['optdt']; $arr['sericnum'] = $this->createnum(); $arr['udeptid'] = $this->rock->post('sysudeptid', $this->urs['deptid']); $whes = ''; $this->sericnum = $arr['sericnum']; } else { $udeptid = $birs['udeptid']; if ($udeptid == 0) { $arr['udeptid'] = $this->urs['deptid']; } } $dbs->record($arr, $whes); return $arr; } public function getsummary() { return $this->rock->reparr($this->moders['summary'], $this->rs); } public function addcheckname($courseid, $uid, $uname, $onbo = false, $addlx = 0) { if (isempt($uid)) { $uid = '0'; $uname = 'auto'; } $uida = explode(',', '' . $uid . ''); $uidan = explode(',', $uname); if ($onbo) { $this->checksmodel->delete($this->mwhere . ' and `courseid`=' . $courseid . ''); } if ($uida) { foreach ($uida as $k => $uid) { $uname = $this->rock->arrvalue($uidan, $k); $zyarr = [ 'table' => $this->mtable, 'mid' => $this->id, 'modeid' => $this->modeid, 'courseid' => $courseid, 'optid' => $this->adminid, 'optname' => $this->adminname, 'addlx' => $addlx, 'optdt' => $this->rock->now, 'status' => 0 ]; $this->checksmodel->delete( $this->mwhere . ' and `checkid`=' . $uid . ' and `courseid`=' . $courseid . '' ); $zyarr['checkid'] = $uid; $zyarr['checkname'] = $uname; $this->checksmodel->insert($zyarr); } } if ($addlx == 4) { $this->checksmodel->delete( $this->mwhere . ' and `checkid`=' . $this->adminid . ' and `courseid`=' . $courseid . '' ); } } public function savedatastr($fval, $farr, $data = []) { $str = ''; if (!$farr) { return $str; } $savewhere = $farr['savewhere']; $name = $farr['name']; $types = $farr['fieldstype']; if (isempt($savewhere) || isempt($fval)) { return $str; } $savewhere = str_replace(['{0}', '{date}', '{now}'], [$name, $this->rock->date, $this->rock->now], $savewhere); $savewhere = $this->rock->reparr($savewhere, $data); $saees = explode(',', $savewhere); if ($types == 'date' || $types == 'datetime') { $fval = strtotime($fval); } if ($types == 'number') { $fval = floatval($fval); } foreach ($saees as $saeess) { $fsaed = explode('|', $saeess); $msg = isset($fsaed[2]) ? $fsaed[2] : '' . $name . '数据不符号'; $val = isset($fsaed[1]) ? $fsaed[1] : ''; $lfs = $fsaed[0]; if ($val != '') { if ($types == 'date' || $types == 'datetime') { $val = strtotime($val); } if ($types == 'number') { $val = floatval($val); } if ($lfs == 'gt') { $bo = $fval > $val; if (!$bo) { return $msg; } } if ($lfs == 'egt') { $bo = $fval >= $val; if (!$bo) { return $msg; } } if ($lfs == 'lt') { $bo = $fval < $val; if (!$bo) { return $msg; } } if ($lfs == 'elt') { $bo = $fval <= $val; if (!$bo) { return $msg; } } if ($lfs == 'eg') { $bo = $fval == $val; if (!$bo) { return $msg; } } if ($lfs == 'neg') { $bo = $fval != $val; if (!$bo) { return $msg; } } } } return $str; } public function update($arr, $where) { if (is_array($arr)) { foreach ($arr as $k => $v) { $this->rs[$k] = $v; } } return parent::update($arr, $where); } public function updatelogvalid($whe) { $this->flogmodel->update('valid=0', $this->mwhere . ' ' . $whe); } public function strappend($sm, $str, $fh = ',') { if (isempt($str)) { return $sm; } if (!isempt($sm)) { $sm .= $fh; } $sm .= $str; return $sm; } public function checkerror($lx = 1, $sm = '') { if ($sm == '') { $sm = '单据异常管理员处理'; } $msg = $this->check($lx, $sm, 1); return $msg; } public function check($zt, $sm = '', $lx = 0) { if ($this->rs['status'] == 1) { return '流程已处理完成,无需操作'; } $arr = $this->getflow(); $flowinfor = $this->getflowinfor(); if ($flowinfor['ischeck'] == 0 && $lx == 0) { return '当前是[' . $arr['nowcheckname'] . ']处理'; } $nowcourse = $this->nowcourse; if ($lx == 1) { if ($arr['nowcourseid'] != 0) { return '当前有审核步骤ID是存在的不能直接标识已完成'; } $to = $this->flogmodel->rows($this->mwhere . ' and `courseid`>0 and `status`=1'); if ($to == 0) { return '该单据没有任何通过审核处理不能直接标识已完成或已审核'; } $nowcourse = ['id' => 66666, 'name' => '异常处理', 'step' => 0]; } $nextcourse = $this->nextcourse; $zynameid = $this->rock->post('zynameid'); $zyname = $this->rock->post('zyname'); $csnameid = ''; $csname = ''; $nextname = $this->rock->post('nextname'); $nextnameid = $this->rock->post('nextnameid'); $qmimgstr = $this->rock->post('qmimgstr'); $tuiid = (int)$this->rock->post('tuiid'); $iszhuanyi = $ischangenext = 0; if ($zt == 1 && $this->isflow != 3 && isempt($zynameid) && arrvalue($nextcourse, 'checktype') == 'change') { $ischangenext = 1; } if ($zt != 2) { $tuiid = 0; } $istongyi = in_array($zt, $this->flowstatusarr); if ($zynameid != '' && $istongyi) { if ($zynameid == $this->adminid) { return '不能转给自己'; } $sm = $this->strappend($sm, '转给:' . $zyname . ''); $iszhuanyi = 1; $this->rs['syszb_name'] = $zyname; $this->rs['syszb_nameid'] = $zynameid; } if ($nextnameid == '' && $ischangenext == 1) { return '请选择下一步处理人'; } $ufied = []; if ($iszhuanyi == 0 && $zt != 2) { foreach ($flowinfor['checkfields'] as $chef => $chefv) { $ufied[$chef] = $this->rock->post('cfields_' . $chef . ''); if (isempt($ufied[$chef]) && $chefv['isbt'] == '1') { $this->echomsg('' . $chefv['name'] . '不能为空'); } $_str = $this->savedatastr($ufied[$chef], $chefv['fieldsarr'], $this->rs); if ($_str != '') { $this->echomsg($_str); } } } $this->checkiszhuanyi = $iszhuanyi; $barr = $this->flowcheckbefore($zt, $ufied, $sm); $msg = ''; if (is_array($barr) && isset($barr['msg'])) { $msg = $barr['msg']; } if (is_array($barr) && isset($barr['update'])) { foreach ($barr['update'] as $_k => $_v) { $ufied[$_k] = $_v; } } if (is_string($barr)) { $msg = $barr; } if (!isempt($msg)) { return $msg; } if ($ufied) { $bo = $this->update($ufied, $this->id); if (!$bo) { return 'dberr:' . $this->db->error(); } } $courseact = $flowinfor['courseact']; $act = $courseact[$zt]; $statusname = $act[0]; $statuscolor = $act[1]; $nzt = $act[2]; $courseid = $nowcourse['id']; $this->checksmodel->update( '`status`=' . $zt . '', $this->mwhere . ' and `checkid`=' . $this->adminid . ' and `courseid`=' . $courseid . '' ); if ($iszhuanyi == 1) { $this->addcheckname($courseid, $zynameid, $zyname, false, 4); $nowcourse['id'] = 0; } if ($ischangenext == 1) { $this->addcheckname($nextcourse['id'], $nextnameid, $nextname, true, 1); } $tuirs = []; if ($tuiid > 0) { $tuirs = $this->flogmodel->getone($tuiid); } if (!$tuirs) { $tuiid = 0; } if ($tuiid > 0) { $sm = $this->strappend($sm, '退回到[' . $tuirs['name'] . '(' . $tuirs['checkname'] . ')]'); $statusname = '退回'; $statuscolor = '#17B2B7'; } $this->checkistui = $tuiid; $logsm = $sm; if ($iszhuanyi == 0 && $csname) { $logsm = $this->strappend($logsm, '抄送给:' . $csname . ''); } $this->lastlogid = $this->addlog( [ 'courseid' => $nowcourse['id'], 'name' => $nowcourse['name'], 'step' => $nowcourse['step'], 'status' => $zt, 'statusname' => $statusname, 'color' => $statuscolor, 'explain' => $logsm, 'iszb' => $iszhuanyi, 'qmimg' => $qmimgstr ] ); if ($tuiid > 0) { $this->addcheckname($tuirs['courseid'], $tuirs['checkid'], $tuirs['checkname'], true, 3); $this->updatelogvalid('and `courseid`>0 and `status`=1 and `step`>=' . $tuirs['step'] . ''); } $lzt = $this->rock->repempt($nzt, $zt); $uparr = $nexttodoarr = $nexttodoarc = []; $bsarr = $this->getflow(); $bsarr['tuiid'] = $tuiid; $nextcheckid = $bsarr['nowcheckid']; if ($istongyi) { if ($iszhuanyi == 0) { $uparr['status'] = $this->rock->repempt($nzt, '0'); } $nexttodoarr = [$nextcheckid, 'next', $sm, $statusname]; } else { if ($tuiid > 0) { $lzt = 23; $nexttodoarr = [$nextcheckid, 'tui', $sm, $statusname]; } elseif ($zt == 2) { $nexttodoarr = [$this->optid, 'nothrough', $sm, $statusname]; } $uparr['status'] = $lzt; } $this->flowcheckafter($zt, $sm, $nowcourse); $bsarr['nstatus'] = $lzt; $bsarr['checksm'] = $sm; if (!$this->nowcourse) { $uparr['status'] = $lzt; $nexttodoarc = [$this->optid, 'finish', $sm, '']; } if ($uparr) { $this->update($uparr, $this->id); } if (!$this->nowcourse) { $this->flowcheckfinsh($zt); if ($istongyi) { $this->checksmodel->delete($this->mwhere); } } $bsarr['status'] = $this->rs['status']; $this->getflowsave($bsarr, true); if ($this->db->backsql()) { $bos = ($courseid == arrvalue($this->nowcourse, 'id') && $istongyi); if ($nexttodoarr && (!$bos || $iszhuanyi == 1)) { $this->nexttodo($nexttodoarr[0], $nexttodoarr[1], $nexttodoarr[2], $nexttodoarr[3]); } if ($nexttodoarc) { $this->nexttodo($nexttodoarc[0], $nexttodoarc[1], $nexttodoarc[2], $nexttodoarc[3]); } } if ($iszhuanyi == 1) { $this->gettodosend( 'bozhuan', '', $sm, 0, '' . $this->adminname . '将[' . $nowcourse['name'] . ']转给:' . $zyname . '' ); } else { if ($istongyi) { $this->gettodosend('botong', $statusname, $sm, $nowcourse['id']); } if ($zt == 2) { $this->gettodosend('bobutong', $statusname, $sm, $nowcourse['id']); } if (!$this->nowcourse && $istongyi) { $this->gettodosend('bofinish', '', $sm); } } if ($iszhuanyi == 0) { $sm1 = '在“' . $nowcourse['name'] . '”处理' . $statusname . ''; $this->savecsname($csnameid, $csname, $this->adminid, $nowcourse['id'], 1, $sm1); } return 'ok'; } public function pushs($receid, $cont, $title = '', $params = []) { return $this->push($receid, '', $cont, $title, 0, $params); } public function getxiangurl($num = '', $id = 0, $lx = 'x') { if ($num == '') { $num = $this->modenum; } if ($id == 0) { $id = $this->id; } $url = URL; if ($lx == 'auto') { $lx = ($this->ismobile == 1) ? 'x' : 'p'; } if ($lx == 'x' || $lx == 'a') { $url = $this->rock->getouturl(); } $url = '' . $url . 'task.php?a=' . $lx . '&num=' . $num . '&mid=' . $id . ''; if (COMPANYNUM) { $url .= '&dwnum=' . COMPANYNUM . ''; } return $url; } public function getxiangurlx($num = '', $id = 0) { return $this->getxiangurl($num, $id, 'x'); } public function push($receid, $gname = '', $cont = '', $title = '', $wkal = 0, $params = []) { if (isempt($receid) && $wkal == 1) { $receid = 'all'; } if (isempt($receid)) { return false; } if (contain(',' . $receid . ',', ',d1,')) { $receid = 'all'; } $modenum = arrvalue($params, 'modenum', $this->modenum); $modename = arrvalue($params, 'modename', $this->modename); $id = (int)arrvalue($params, 'id', $this->id); $moders = arrvalue($params, 'moders'); if (!is_array($moders)) { $moders = $this->moders; } if ($gname == '') { $gname = $modename; } $reim = m('reim'); $url = $this->getxiangurl($modenum, $id, 'p'); $wxurl = $this->getxiangurl($modenum, $id, 'x'); $emurl = $this->getxiangurl($modenum, $id, 'a'); if ($id == 0) { $url = ''; $wxurl = ''; $emurl = ''; } $url = arrvalue($params, 'url', $url); $wxurl = arrvalue($params, 'wxurl', $wxurl); $emurl = arrvalue($params, 'emurl', $emurl); $slx = 0; $pctx = $moders['pctx']; $mctx = $moders['mctx']; $wxtx = $moders['wxtx']; $ddtx = $moders['ddtx']; $emtx = $moders['emtx']; if ($pctx == 0 && $mctx == 1) { $slx = 2; } if ($pctx == 1 && $mctx == 0) { $slx = 1; } if ($pctx == 0 && $mctx == 0) { $slx = 3; } $this->rs['now_adminname'] = $this->adminname; $this->rs['now_modename'] = $modename; $cont = $this->rock->reparr($cont, $this->rs); $receid = $this->adminmodel->gjoins($receid); $uids = m('todo')->addtodo($receid, $modename, $cont, $modenum, $id); if ($uids != '' && $moders['type'] != '系统' && $id > 0) { $this->todosmodel->addtotouids( $uids, [ 'table' => $moders['table'], 'mid' => $id, 'modename' => $modename, 'modenum' => $modenum, ] ); } $title = $this->rock->reparr($title, $this->rs); $reim->pushagent($uids, $gname, $cont, $title, $url, $wxurl, $slx, '' . $modenum . '|' . $id . ''); $this->flowchangetodo($uids, $gname); if (isempt($title)) { $title = $modename; } $this->flowweixinarr = []; return $receid; } public function nexttodo($nuid, $type, $sm = '', $act = '') { $cont = ''; $tit = ''; $gname = '流程待办'; $summary = $this->getsummary(); if ($type == 'submit' || $type == 'next' || $type == 'cuiban') { $cont = '你有[' . $this->uname . ']的[' . $this->modename . ',单号:' . $this->sericnum . ']需要处理'; if ($sm != '') { $cont .= ',说明:' . $sm . ''; } $tit = '' . $this->uname . '的' . $this->modename . ''; if ($type != 'cuiban') { $txnum = $this->option->getval('sms_txnum'); if (!isempt($txnum)) { $mknum = $this->option->getval('sms_mknum'); if ($mknum == 'all' || contain(',' . $mknum . ',', ',' . $this->modenum . ',')) { $wxurl = $this->getxiangurlx(); $barr = c('xinhuapi')->sendsms( $nuid, '', $txnum, [ 'modename' => $this->modename, 'sericnum' => $this->sericnum, 'applyname' => $this->uname, 'deptname' => $this->rs['base_deptname'], ], $wxurl ); } } } $type = 'daiban'; } if ($type == 'nothrough') { $cont = '你提交[' . $this->modename . ',单号:' . $this->sericnum . ']' . $this->adminname . '处理[' . $act . '],原因:[' . $sm . ']'; $gname = '流程申请'; $tit = '' . $this->modename . '处理' . $act . ''; } if ($type == 'finish') { $cont = '你提交的[' . $this->modename . ',单号:' . $this->sericnum . ']已全部处理完成'; $gname = '流程申请'; $tit = '' . $this->modename . '全部处理完成'; } if ($type == 'zhui') { $cont = '' . $this->adminname . '追加单据说明[' . $this->modename . ',单号:' . $this->sericnum . '],说明:[' . $sm . ']'; } if ($type == 'tui') { $cont = '[' . $this->adminname . ']退回单据[' . $this->modename . ',单号:' . $this->sericnum . ']到你这请及时处理,说明:' . $sm . ''; } if ($type == 'chao') { $cont = '' . $this->adminname . '' . $sm . '了“' . $this->modename . '”'; if (!isempt($summary)) { $cont .= ',摘要“' . $summary . '”'; } if ($this->isflow > 0) { $cont .= ',单号“' . $this->sericnum . '”'; } $gname = ''; $tit = '' . $this->modename . '的单据抄送'; } if ($type == 'pinglun') { $cont = '' . $this->adminname . '' . $act . '你的[' . $this->modename . ']单据,说明:' . $sm . ''; $gname = ''; $tit = '' . $this->modename . '评论'; } if ($type == 'receipt') { $cont = '' . $this->adminname . '' . $act . '[' . $this->modename . ']的单据'; if ($sm != '') { $cont .= ',说明:' . $sm . ''; } $gname = '回执确认'; $tit = '' . $this->modename . '回执确认'; } $nbis = $this->flownexttodo($type); if ($nbis) { if (is_string($nbis)) { $cont = $nbis; } if (is_array($nbis)) { $tit = arrvalue($nbis, 'title', $tit); $gname = arrvalue($nbis, 'gname', $gname); $cont = arrvalue($nbis, 'cont', $cont); } } if ($cont != '') { $this->push($nuid, $gname, $cont, $tit); } } public function getwxurl($num = '') { if ($num == '') { $num = $this->modenum; } $url = $this->rock->getouturl(); $str = '' . $url . '?m=ying&d=we&num=' . $num . ''; return $str; } public function getweurl($num = '') { if ($num == '') { $num = $this->modenum; } $url = $this->rock->getouturl(); $str = '' . $url . '?m=ying&d=we&mnum=' . $num . ''; return $str; } public function deletebill($sm = '', $qxpd = true) { if (getconfig('systype') == 'demo') { return '演示请勿删除'; } if ($qxpd) { $is = $this->isdeleteqx(); if ($is == 0) { return '无权删除'; } } if (method_exists($this, 'flowdeletebillbefore')) { $bstr = $this->flowdeletebillbefore($sm); if (!isempt($bstr)) { return $bstr; } } $modewhere = "`modenum`='" . $this->modenum . "' and `mid`=" . $this->id . ""; $this->flogmodel->delete($this->mwhere); m('reads')->delete($this->mwhere); m('file')->delfiles($this->mtable, $this->id); $tables = $this->moders['tables']; if (!isempt($tables)) { $arrse = explode(',', $tables); foreach ($arrse as $arrses) { m($arrses)->delete('mid=' . $this->id . ''); } } $this->billmodel->delete($this->mwhere); $this->todosmodel->delete($this->mwhere); $this->checksmodel->delete($this->mwhere); $this->chaomodel->delete($this->mwhere); m('remind')->delete($this->mwhere); m('todo')->delete($this->mwhere); m('todo')->delete($modewhere); m('receipt')->delete($this->mwhere); m('im_history')->delete("`xgurl`='" . $this->modenum . "|" . $this->id . "'"); $this->delete($this->id); $this->flowdeletebill($sm); $this->flowzuofeibill($sm); $this->gettodosend('bodel', '', $sm); $dels = '删除模块[' . $this->modename . ']id为' . $this->id . '的单据'; $ztss = arrvalue($this->rs, 'base_summary'); if (!isempt($ztss)) { $dels .= ',摘要[' . $ztss . ']'; } if (!isempt($sm)) { $dels .= ',说明:' . $sm . ''; } m('log')->addlogs('删除单据', $dels, 3); foreach ($this->wherejoin as $num => $fields) { $this->deletebilljoin($num, "`$fields`='$this->id'", $sm); } return 'ok'; } public function deletebilljoin($num, $where, $sm = '') { $flow = m('flow')->initflow($num); $rows = $flow->getall($where); foreach ($rows as $k1 => $rs1) { $mid = $rs1['id']; $flow->loaddata($mid, false); $flow->deletebill($sm, false); } } public function zuofeibilljoin($num, $where, $sm = '') { $flow = m('flow')->initflow($num); $rows = $flow->getall($where); foreach ($rows as $k1 => $rs1) { $mid = $rs1['id']; $flow->loaddata($mid, false); $flow->zuofeibill($sm); } } public function zuofeibill($sm = '') { $this->addlog(['explain' => $sm, 'name' => '作废', 'status' => 1,]); $this->update('`status`=5', $this->id); $zfarr = [ 'status' => 5, 'nstatus' => 5, 'checksm' => '作废:' . $sm . '', 'nowcheckid' => '', 'nowcheckname' => '', 'nstatustext' => '作废', 'updt' => $this->rock->now, ]; $this->billmodel->update($zfarr, $this->mwhere); $tables = $this->moders['tables']; if (!isempt($tables)) { $arrse = explode(',', $tables); foreach ($arrse as $arrses) { m($arrses)->delete('mid=' . $this->id . ''); } } $this->flowzuofeibill($sm); $this->gettodosend('bozuofei', '', $sm); foreach ($this->wherejoin as $num => $fields) { $this->zuofeibilljoin($num, "`$fields`='$this->id'", $sm); } return 'ok'; } public function openxiang() { $xiangdata = $btndata = []; $data = $this->flowrsreplace($this->rs, 4); foreach ($this->fieldsarra as $k => $rs) { if ($rs['iszs'] == '1') { $xiangdata[] = [ 'name' => $rs['name'], 'fields' => $rs['fields'], 'value' => $this->rock->repempt(arrvalue($data, $rs['fields'])) ]; } } $barr['xiangdata'] = $xiangdata; $btnrows = $this->db->getrows( '[Q]flow_menu', "`setid`='$this->modeid' and `status`=1 and `num` like 'open%'", 'id,wherestr,name,num,issm,type', '`sort`' ); foreach ($btnrows as $k => $rs) { $wherestr = $rs['wherestr']; $bo = false; if (isempt($wherestr)) { $bo = true; } else { $ewet = $this->wheremodel->getstrwhere($this->rock->jm->base64decode($wherestr)); $ewet = str_replace(['{asqom}', '1=2 and'], '', $ewet); $tos = $this->rows("`id`='$this->id' and $ewet"); if ($tos > 0) { $bo = true; } } if ($bo) { $btndata[] = ['id' => $rs['id'], 'name' => $rs['name'], 'issm' => $rs['issm'],]; } } $barr['btndata'] = $btndata; if (method_exists($this, 'flowopenxiang')) { $lbarr = $this->flowopenxiang($data, $xiangdata, $btndata); if (is_array($lbarr)) { foreach ($lbarr as $k => $v) { $barr[$k] = $v; } } } return $barr; } public function smschuiban($sm = '') { if ($this->isflow > 0 && $this->adminid == $this->uid) { $farr = $this->getflow(true); $nowcheckid = $farr['nowcheckid']; $tplnum = $this->option->getval('sms_cbnum', 'defnum'); $wxurl = $this->getxiangurlx(); $barr = c('xinhuapi')->sendsms( $nowcheckid, '', $tplnum, [ 'modename' => $this->modename, 'sericnum' => $this->sericnum, 'applyname' => $this->uname, 'deptname' => $this->rs['base_deptname'], ], $wxurl, false, false ); if (!$barr['success']) { return $barr['msg']; } $this->addlog(['explain' => $sm, 'name' => '短信催办', 'status' => 1,]); } return 'ok'; } public function addschedule($sm = '') { $txdt = $this->rock->post('txdt'); if (isempt($sm)) { return '说明不能为空'; } if (isempt($txdt)) { return '提醒时间不能为空'; } $barr['title'] = $sm; $barr['startdt'] = $txdt; $barr['uid'] = $this->adminid; $barr['optdt'] = $this->rock->now; $barr['optname'] = $this->adminname; $barr['txsj'] = 1; m('schedule')->insert($barr); return 'ok'; } public function getoptmenu($flx = 0) { $where = ''; if ($flx == 1) { $where = 'and `iszs`=1'; } $rows = $this->db->getrows( '[Q]flow_menu', "`setid`='$this->modeid' " . $where . " and `status`=1", 'id,wherestr,name,statuscolor,statusvalue,num,islog,issm,type,upgcont', '`sort`' ); $arr = []; $bfrom = $this->rock->post('bfrom'); $arr[] = [ 'lx' => 0, 'name' => $this->rock->jm->base64decode('5pyq562!5o6I5peg5rOV5pi!56S66I!c5Y2V'), 'optmenuid' => 0, 'color' => 'red' ]; if ($flx == 1) { return $arr; } $status = (int)arrvalue($this->rs, 'status', '0'); $isturn = (int)arrvalue($this->rs, 'isturn', '0'); $ismy = ($this->uid == $this->adminid or $this->optid == $this->adminid); $isreadbo = $this->isreadqx(1); if ($this->isflow > 0 && $isturn == 1) { } if ($status != 5 && arrvalue($this->moders, 'ispl', '1') == '1' && $isreadbo) { $arr[] = ['name' => '评论', 'lx' => 15, 'nup' => 1, 'issm' => 1, 'optmenuid' => -15]; } if ($ismy && arrvalue($this->moders, 'ishz') == '1' && $status == 1) { $smcont = $this->getsummary(); $mid = (int)m('receipt')->getmou( 'id', "`uid`='$this->adminid' and `modenum`='$this->modenum' and `mid`='$this->id'" ); $namess = '回执确认设置'; if ($mid > 0) { $namess = '回执确认编辑'; } $arr[] = [ 'name' => $namess, 'djmid' => $mid, 'optnum' => 'receipt', 'lx' => '18', 'optmenuid' => -18, 'modename' => $this->modename, 'smcont' => $smcont ]; } if ($isreadbo && arrvalue($this->moders, 'istxset', '1') == '1' && $this->modenum != 'remind' && !in_array( $status, [2, 5] )) { $smcont = '' . $this->modename . ':' . $this->getsummary(); $mid = (int)m('remind')->getmou( 'id', "`uid`='$this->adminid' and `modenum`='$this->modenum' and `mid`='$this->id'" ); $namess = '+添加提醒设置'; if ($mid > 0) { $namess = '提醒设置编辑'; } $arr[] = [ 'name' => $namess, 'djmid' => $mid, 'smcont' => $smcont, 'issm' => 1, 'optnum' => 'tixing', 'lx' => '14', 'optmenuid' => -14 ]; } if ($this->iseditqx() == 1 && $isreadbo) { $arr[] = ['name' => '编辑', 'optnum' => 'edit', 'lx' => '11', 'optmenuid' => -11]; } if ($this->isdeleteqx() == 1) { $arr[] = [ 'name' => '删除', 'color' => 'red', 'optnum' => 'del', 'nup' => 1, 'issm' => 0, 'islog' => 0, 'statusvalue' => 9, 'lx' => '9', 'optmenuid' => -9 ]; } return $arr; } public function optmenu($czid, $zt, $sm = '') { $msg = ''; $cname = $this->rock->post('changename'); $cnameid = $this->rock->post('changenameid'); $cdate = $this->rock->post('changedate'); $darr = ['cname' => $cname, 'cnameid' => $cnameid, 'cdate' => $cdate, 'sm' => $sm,]; if ($czid == -9) { $msg = $this->deletebill($sm); } else { if ($czid == -10) { $msg = $this->check($zt, $sm); if (contain($msg, '成功')) { $msg = 'ok'; } } else { if ($czid == -12) { $this->zhuijiaexplain($sm); } else { if ($czid == -13) { $this->chuiban($sm); } else { if ($czid == -14) { $msg = $this->addschedule($sm); } else { if ($czid == -15) { $actname = $this->rock->post('name'); $this->addlog(['explain' => $sm, 'name' => $actname,]); $uids = arrvalue($this->rs, 'uid', '0'); if (isset($this->rs['optid'])) { $uids .= ',' . $this->rs['optid'] . ''; } $this->nexttodo($uids, 'pinglun', $sm, $actname); $this->gettodosend('boping', '', $sm); } else { if ($czid == -16) { $this->zuofeibill($sm); } else { if ($czid == -17) { $msg = $this->smschuiban($sm); } else { if ($czid == -18) { $msg = $this->jiankongzb($darr); } else { } } } } } } } } } if ($msg == '') { $msg = 'ok'; } return $msg; } public function jiankongzb($darr) { return $this->bd6('5peg5L!h5ZG8562!5o6I5peg5q2k5Yqf6IO9'); } public function billwhere($uid, $lx) { $arr['table'] = $this->mtable; $arr['tableleft'] = ''; $arr['fields'] = ''; $arr['order'] = ''; $arr['group'] = ''; $arr['keywhere'] = ''; $arr['asqom'] = ''; $arr['onlywhere'] = ''; $arr['companywhere'] = ''; $this->atype = $lx; $nas = $this->flowbillwhere($uid, $lx); $inwhere = ''; if (substr($lx, 0, 5) == 'grant') { $inwhere = $this->viewmodel->viewwhere($this->moders, $this->adminid, $this->flowviewufieds, 1); } if ($lx == 'chaos') { $inwhere = "and {asqom}`id` in(select `mid` from `[Q]flow_chao` where `table`='{$this->mtable}' and " . $this->rock->dbinstr( 'csnameid', $this->adminid ) . ")"; } if ($lx == 'mychuli') { $inwhere = "and {asqom}`id` in(select bill.`mid` from `[Q]flow_bill` as `bill` where bill.`modeid`='{$this->modeid}' and " . $this->rock->dbinstr( 'bill.`allcheckid`', $this->adminid ) . ")"; } $_wehs = ''; if (is_array($nas)) { if (isset($nas['where'])) { $_wehs = $nas['where']; } $ftears = explode( ',', 'asqom,order,fields,fieldsleft,table,group,companywhere,onlywhere,keywhere,tableleft' ); foreach ($ftears as $fid) { if (isset($nas[$fid])) { $arr[$fid] = $nas[$fid]; } } } else { $_wehs = $nas; } $fwhere = $this->getflowwhere($uid, $lx); $path = '' . P . '/flow/page/rock_page_' . $this->modenum . '.php'; $table = $arr['table']; $temsao = 0; if (!contain($table, ' ') && $this->isflow > 0) { $arr['table'] = '`[Q]' . $this->mtable . '` a left join `[Q]flow_bill` b on a.`id`=b.`mid` and b.`table`=\'' . $this->mtable . '\''; if (!isempt($arr['tableleft'])) { $arr['table'] .= ' left join ' . $arr['tableleft'] . ''; } $arr['asqom'] = 'a.'; $arr['fields'] = 'a.*,b.`uname` as base_name,b.`udeptname` as base_deptname,b.`sericnum`,b.`nowcheckname`'; if (isset($arr['fieldsleft']) && $arr['fieldsleft']) { $arr['fields'] .= ',' . $arr['fieldsleft'] . ''; } if ($arr['order'] == '') { $arr['order'] = 'a.`optdt` desc'; } $temsao = 1; if ($this->defaultorder) { $defa = explode(',', $this->defaultorder); $desc = arrvalue($defa, 1, 'desc'); $arr['order'] = 'a.`' . $defa[0] . '` ' . $desc . ''; } } if (isempt($arr['order'])) { $arr['order'] = '{asqom}`id` desc'; if ($this->defaultorder) { $defa = explode(',', $this->defaultorder); $desc = arrvalue($defa, 1, 'desc'); $arr['order'] = '{asqom}`' . $defa[0] . '` ' . $desc . ''; } } if (isempt($fwhere) && isempt($inwhere) && $this->moders['isscl'] == 1) { $fwhere = 'and 1=2'; } $where = $inwhere; $wherestr = $this->moders['where']; if (!isempt($wherestr)) { $wherestr = $this->rock->covexec($wherestr); $where .= ' and {asqom}' . $wherestr; } if ($fwhere != '') { $where .= ' ' . $fwhere; } if ($_wehs != '') { $where .= ' ' . $_wehs; } $highwhere = $this->gethighwhere(); $allfields = []; $key = $this->rock->post('key'); $pnum = $this->rock->post('pnum'); $status = $this->rock->post('keystatus'); $ztfields = arrvalue($nas, 'ztfields', 'status'); $xhlikea = ['like', '=', '>=', '<=', 'not like']; $xhfields = $this->rock->post('xhfields'); $xhlike = (int)$this->rock->post('xhlike', '0'); $xhkeygj = $this->rock->jm->base64decode($this->rock->post('xhkeygj')); if (!isempt($xhkeygj) && $xhfields) { if (substr($xhfields, 0, 2) == 'zb') { $xu = substr($xhfields, 2, 1); $zbasr = explode(',', $this->moders['tables']); $zbts = arrvalue($zbasr, $xu); $xhfields = substr($xhfields, 4); $wher1 = "`$xhfields` " . $xhlikea[$xhlike] . ""; if ($xhlike == 0 || $xhlike == 4) { $wher1 .= " '%" . $xhkeygj . "%'"; } if ($xhlike == 1 || $xhlike == 2 || $xhlike == 3) { $wher1 .= " '$xhkeygj'"; } $wher1 = " and {asqom}`id` in(select `mid` from `[Q]" . $zbts . "` where " . $wher1 . ")"; $where .= $wher1; } else { $wher1 = " and {asqom}`$xhfields` " . $xhlikea[$xhlike] . ""; if ($xhlike == 0 || $xhlike == 4) { $wher1 .= " '%" . $xhkeygj . "%'"; } if ($xhlike == 1 || $xhlike == 2 || $xhlike == 3) { $wher1 .= " '$xhkeygj'"; } $where .= $wher1; } } if (!isempt($status)) { $where .= ' and {asqom}`' . $ztfields . '`=' . $status . ''; } if (!isempt($key) && isempt($arr['keywhere'])) { $check = c('check'); $allfields = $this->db->getallfields('[Q]' . $this->mtable . ''); $_kearr = []; if ($check->isdate($key) || $check->ismonth($key)) { $skeay = ['date', 'datetime', 'month']; foreach ($this->fieldsarra as $k => $rs) { $flx = $rs['fieldstype']; $fid = $rs['fields']; if ($rs['issou'] == 1 && in_array($flx, $skeay) && in_array($fid, $allfields)) { if ($check->isdate($key)) { if ($flx == 'date') { $_kearr[] = "{asqom}`" . $fid . "`='$key'"; } if ($flx == 'datetime') { $_kearr[] = "{asqom}`" . $fid . "` like '$key%'"; } if ($flx == 'month') { $_kearr[] = "{asqom}`" . $fid . "`='" . substr($key, 0, 7) . "'"; } if ($temsao == 1) { $_kearr[] = "b.`applydt`='$key'"; } } if ($check->ismonth($key)) { if ($flx == 'month') { $_kearr[] = "{asqom}`" . $fid . "`='$key'"; } else { $_kearr[] = "{asqom}`" . $fid . "` like '$key%'"; } if ($temsao == 1) { $_kearr[] = "b.`applydt` like '$key%'"; } } } } } if (!$_kearr) { $skeay = [ 'text', 'textarea', 'htmlediter', 'changeuser', 'changeusercheck', 'changedept', 'changedeptusercheck', 'selectdatafalse', 'selectdatatrue', 'num' ]; $xiakk = ['rockcombo', 'select']; foreach ($this->fieldsarra as $k => $rs) { if ($rs['issou'] == 1 && in_array($rs['fields'], $allfields) && substr($rs['fields'], -2) != 'dt') { if (in_array($rs['fieldstype'], $skeay)) { $_kearr[] = "{asqom}`" . $rs['fields'] . "` like '%" . $key . "%'"; } } } if ($temsao == 1) { $_kearr[] = "b.`uname` like '%" . $key . "%'"; $_kearr[] = "b.`udeptname` like '%" . $key . "%'"; $_kearr[] = "b.`sericnum` = '$key'"; $_kearr[] = "b.`nowcheckname` = '$key'"; } if (isset($nas['orlikefields'])) { $owhee = explode(',', $nas['orlikefields']); foreach ($owhee as $owhees) { $_owhees = explode('@', $owhees); $sle = arrvalue($_owhees, 1); if ($sle == '1') { $_kearr[] = "" . $_owhees[0] . " ='$key'"; } else { $_kearr[] = "" . $_owhees[0] . " like '%" . $key . "%'"; } } } } if ($_kearr && $arr['onlywhere'] == '') { $arr['keywhere'] = "and (" . join(' or ', $_kearr) . ")"; } } if (!isempt($arr['companywhere']) && getconfig('companymode')) { $where .= ' ' . $arr['companywhere']; } if (!isempt($arr['onlywhere'])) { $where .= ' ' . $arr['onlywhere']; } if (!isempt($arr['keywhere'])) { $where .= ' ' . $arr['keywhere']; } if ($highwhere != '') { $where .= ' ' . $highwhere; } $where = str_replace('{asqom}', $arr['asqom'], $where); $arr['order'] = str_replace('{asqom}', $arr['asqom'], $arr['order']); $where = str_replace('[A]', $arr['asqom'], $where); $fields = $arr['fields']; if ($this->flowfieldstype == 1 && (isempt($fields) || $fields == '*') && $this->moders['isscl'] == 1) { if (!$allfields) { $allfields = $this->db->getallfields('[Q]' . $this->mtable . ''); } $fields = '{asqom}`id`'; $odlvs = $this->option->getval('columns_' . $this->modenum . '_' . $pnum . ''); if (isempt($odlvs)) { foreach ($this->fieldsarra as $k => $rs) { if ($rs['islb'] == 1 && in_array($rs['fields'], $allfields)) { $fields .= ',{asqom}`' . $rs['fields'] . '`'; } } } else { $odlvsa = explode(',', $odlvs); foreach ($odlvsa as $odlvs1) { if (in_array($odlvs1, $allfields)) { $fields .= ',{asqom}`' . $odlvs1 . '`'; } } } if ($this->isflow > 0) { if (!contain($fields, '`status`')) { $fields .= ',{asqom}`status`'; } } $fields = str_replace('{asqom}', $arr['asqom'], $fields); $arr['fields'] = $fields; } $fields = $arr['fields']; if (!isempt($fields) && $fields != '*') { $fieldsa = explode(',', $fields); $fieldss = ''; foreach ($fieldsa as $fieldsas) { if (contain($fieldsas, '`') || contain($fieldsas, '.') || contain($fieldsas, ' ') || contain( $fieldsas, '(' )) { $fieldss .= ',' . $fieldsas . ''; } else { $fieldss .= ',`' . $fieldsas . '`'; } } $arr['fields'] = substr($fieldss, 1); } $arr['where'] = str_replace('{asqom}', '', $where); return $arr; } public function gethighwhere() { $s = ''; return $s; } public function getflowwhere($uid, $num) { $where = ''; $rs = $this->wheremodel->getone("`setid`='$this->modeid' and `num`='$num'"); if (!$rs) { return $where; } $where = $this->wheremodel->getwherestr($rs, $uid, $this->flowviewufieds); return $where; } public function getflowrows($uid, $lx, $limit = 5, $swher = '') { $nas = $this->billwhere($uid, $lx); $table = $nas['table']; if (!contain($table, ' ')) { $table = '[Q]' . $table . ''; } if (isempt($nas['fields'])) { $nas['fields'] = '*'; } $swher = str_replace('{asqom}', $nas['asqom'], $swher); $where = '1=1 ' . $nas['where'] . ' ' . $swher . ''; if ($limit == 0) { return $this->db->rows($table, $where); } $rows = $this->db->getrows($table, $where, $nas['fields'], $nas['order'], $limit); foreach ($rows as $k => $rs) { $rows[$k] = $this->flowrsreplace($rs, 2); } return $rows; } public function gettodorows($whereid) { $where = $this->wheremodel->getwherestr($whereid, $this->adminid, $this->flowviewufieds); $wherestr = $this->moders['where']; if (!isempt($wherestr)) { $wherestr = $this->rock->covexec($wherestr); $where .= ' and ' . $wherestr; } $where = str_replace('{asqom}', '', $where); $rows = $this->getall('2=2 ' . $where . ''); foreach ($rows as $k => $rs) { $rows[$k] = $this->flowrsreplace($rs, 1); } return $rows; } public function printexecl($event) { $arr['moders'] = $this->moders; $arr['fields'] = $this->getfields(); $cell = 1; foreach ($arr['fields'] as $k => $v) { $cell++; } $arr['cell'] = $cell; $where = '1=1'; $str1 = $this->moders['where']; if (!isempt($str1)) { $str1 = $this->rock->covexec($str1); $where = $str1; } $vwhere = $this->viewmodel->viewwhere($this->moders, $this->adminid); $rows = $this->getrows('' . $where . ' ' . $vwhere . '', '*', 'id desc', 100); $arr['rows'] = $this->flowprintrows($rows); $arr['count'] = $this->db->count; return $arr; } public function getsuballdata($lx = 0, $mid = 0) { $tabless = $this->moders['tables']; $subdata = []; if ($mid == 0) { $mid = $this->id; } if (!isempt($tabless)) { $tablessa = explode(',', $tabless); $namessa = explode(',', $this->moders['names']); $tabless1 = '[' . str_replace(',', '],[', $tabless) . ']'; foreach ($tablessa as $zbx => $tables) { $cis = substr_count($tabless1, '[' . $tables . ']'); $whes = ''; if ($cis > 1) { $whes = ' and `sslx`=' . $zbx . ''; } $data = m($tables)->getall('mid=' . $mid . '' . $whes . '', '*', '`sort`'); $data = $this->flowsubdata($data, $lx, $zbx); if ($lx == 0) { $subdata['subdata' . $zbx . ''] = $data; } else { $subdata[$zbx] = [ 'data' => $data, 'fields' => 'subdata' . $zbx . '', 'name' => $this->rock->arrvalue($namessa, $zbx) ]; } } } return $subdata; } private $gettodolistarr = null; public function gettodolist($act) { if (is_array($act)) { return $act; } if ($this->gettodolistarr === null) { $rows = $this->todomodel->getrows("`setid`='" . $this->modeid . "' and `status`=1"); $barr = []; foreach ($rows as $k => $rs) { $whereid = (int)$rs['whereid']; if ($whereid > 0) { $bo = $this->wheremanzhu($whereid); if (!$bo) { continue; } } $barr[] = $rs; } $this->gettodolistarr = $barr; } else { $barr = $this->gettodolistarr; } $garr = []; if ($barr) { foreach ($barr as $k => $rs) { if (arrvalue($rs, $act) == '1') { $garr[] = $rs; } } } return $garr; } public function gettodosend($act, $actname = '', $sm = '', $courseid = 0, $conts = '') { $barr = $this->gettodolist($act); if (!$barr) { return; } $changearr = [ 'boturn' => '提交', 'boedit' => '编辑', 'bozhuan' => '转办', 'bochang' => '修改字段', 'bodel' => '删除', 'bozuofei' => '作废', 'botong' => '处理同意', 'bobutong' => '处理不同意', 'bofinish' => '全部处理完成', 'bozhui' => '追加说明', 'boping' => '评论', 'bohuiz' => '回执确认' ]; if ($actname == '' && is_string($act)) { $actname = arrvalue($changearr, $act); } if (isempt($actname)) { return; } $cheo = c('check'); foreach ($barr as $k => $rs) { $receid = $rs['receid']; if ($act == 'botong' || $act == 'bobutong') { $changewe = $rs['changecourse']; if (!isempt($changewe) && !contain(',' . $changewe . ',', ',' . $courseid . ',')) { continue; } } if ($rs['toturn'] == 1) { $receid .= ',' . $this->uid . ''; } if (arrvalue($rs, 'tosuper') == '1') { $supar = $this->adminmodel->getsuperman($this->uid); $shnej = arrvalue($supar, 0); if (!isempt($shnej)) { $receid .= ',' . $shnej . ''; } } if ($rs['tocourse'] == 1 && $this->billrs) { $allcheckid = $this->billrs['allcheckid']; if (!isempt($allcheckid)) { $receid .= ',' . $allcheckid . ''; } } $todofields = $rs['todofields']; if (!isempt($todofields)) { $toad = explode(',', $todofields); foreach ($toad as $toads) { $ttv = arrvalue($this->rs, $toads); if (!isempt($ttv) && $cheo->isinnumber($ttv)) { $receid .= ',' . $ttv . ''; } } } if (isempt($receid)) { continue; } if (substr($receid, 0, 1) == ',') { $receid = substr($receid, 1); } $cont = $rs['summary']; if (isempt($cont)) { $cont = $conts; } if (isempt($cont)) { $cont = '' . $this->adminname . '' . $actname . '[' . $this->modename . ',单号:' . $this->sericnum . ']'; if ($sm != '') { $cont .= ',说明:' . $sm . ''; } } $this->push($receid, '', $cont, $this->rock->repempt($rs['name'])); } } public function numtodosend($num, $actname = '', $sm = '') { $rows = $this->todomodel->getrows("`setid`='" . $this->modeid . "' and `num`='$num' and `status`=1"); if (!$rows) { return; } $this->gettodosend($rows, $actname, $sm); } public function flowtotal($fields = '', $type = '') { if ($fields == '') { $fields = $this->rock->post('total_fields'); } if ($type == '') { $type = $this->rock->post('total_type', 'jls'); } $typea = explode('|', $type); $typefields = ''; $type = $typea[0]; $typefields = arrvalue($typea, 1); $rowa = []; $rowa[] = ['name' => '暂无数据', 'value' => 0, 'bili' => '']; $tofiels = 'count(1)'; if ($type == 'sum') { $tofiels = 'sum([A]`' . $typefields . '`)'; } if ($type == 'avg') { $tofiels = 'avg([A]`' . $typefields . '`)'; } $atype = $this->rock->post('atype'); $table = '[Q]' . $this->mtable . ''; $narr = $this->billwhere($this->adminid, $atype); $where = $narr['where']; $table = $narr['table']; if (!contain($table, ' ')) { $table = '[Q]' . $table . ''; } $gwhere = $this->rock->post('where'); if (!isempt($gwhere)) { $gwhere = $this->rock->jm->uncrypt($this->rock->iconvsql($gwhere)); $where .= ' ' . $gwhere . ''; } $sql = 'select ' . $fields . ' as `name`,' . $tofiels . ' as value from ' . $table . ' where 1=1 ' . $where . ' group by ' . $fields . ''; $sql = str_replace('[A]', $narr['asqom'], $sql); $rows = $this->db->getall($sql); $total = 0; if ($rows) { foreach ($rows as $k => $rs) { $total += floatval($rs['value']); } if ($total > 0) { foreach ($rows as $k => $rs) { $rows[$k]['bili'] = $this->rock->number($rs['value'] * 100 / $total) . '%'; } } if ($type != 'avg' && count($rows) > 1) { $rows[] = ['name' => '合计', 'value' => $total, 'bili' => '']; } } else { $rows = $rowa; } return $rows; } public function receiptcheck($hid, $sm) { return 'ok'; } public function getrowstable($atype, $where, $limit = 100) { $rows = $this->getflowrows($this->adminid, $atype, $limit, $where); $headstr = '@xuhaos,,center'; foreach ($this->fieldsarra as $k => $rs) { if ($rs['islb'] == 1 && $rs['iszb'] == '0') { $headstr .= '@' . $rs['fields'] . ',' . $rs['name'] . ''; } } if ($this->isflow > 0) { $headstr .= '@statustext,状态'; if (is_array($rows)) { foreach ($rows as $k => $rs) { $rows[$k]['statustext'] = $this->getstatusstr($rs); } } } $cont = c('html')->createrows($rows, substr($headstr, 1), '#cccccc', 'noborder'); return $cont; } public function viewjinfields($rows) { if (!$rows) { return $rows; } return $rows; } public function daochusubtable($rows) { return $rows; } }