信呼OA版本v2.3.8
This commit is contained in:
827
webmain/model/adminModel.php
Normal file
827
webmain/model/adminModel.php
Normal file
@@ -0,0 +1,827 @@
|
||||
<?php
|
||||
class adminClassModel extends Model
|
||||
{
|
||||
private $_getjoinstr = array();
|
||||
public $nowurs;
|
||||
|
||||
public function gjoin($joinid, $glx='', $blx='bxl')
|
||||
{
|
||||
$uid = $did = $gid = '0';
|
||||
if($glx=='')$glx = 'ud';
|
||||
if(isempt($joinid))return '';
|
||||
$joinid = strtolower($joinid);
|
||||
if(contain($joinid, 'all'))return 'all';
|
||||
if($blx!='where' && $glx!='d' && !contain($joinid,'u')
|
||||
&& !contain($joinid,'d') && !contain($joinid,'g'))return $joinid;
|
||||
$narr = explode(',', $joinid);
|
||||
$dwhe = array();
|
||||
foreach($narr as $sid){
|
||||
if(isempt($sid))continue;
|
||||
$lx = substr($sid, 0, 1);
|
||||
$ssid = str_replace(array('u','d','g'), array('','',''), $sid);
|
||||
if($lx == 'd' || $glx=='d'){
|
||||
$did.=','.$ssid.'';
|
||||
$dwhe[] = "instr(`deptpath`, '[$ssid]')>0";
|
||||
}else if($lx=='g'){
|
||||
$gid.=','.$ssid.'';
|
||||
}else{
|
||||
$uid.=','.$ssid.'';
|
||||
}
|
||||
}
|
||||
$where = '';
|
||||
if($gid!='0'){
|
||||
$uids = $this->getgrouptouid($gid);
|
||||
if($uids!='')$uid.=','.$uids.'';
|
||||
}
|
||||
if($did != '0'){
|
||||
$where = join(' or ', $dwhe);
|
||||
if($uid!='0')$where.=" or `id` in($uid)";
|
||||
}else{
|
||||
if($uid!='0')$where ="`id` in($uid)";
|
||||
}
|
||||
if($blx == 'where')return $where;
|
||||
$guid = '';
|
||||
if($where!=''){
|
||||
$swhe = '`status`=1';
|
||||
if($blx=='all')$swhe = '1=1';
|
||||
$swhe.= $this->getcompanywhere();
|
||||
$rows = $this->getall("$swhe and ($where)", '`id`');
|
||||
foreach($rows as $k=>$rs)$guid.=','.$rs['id'].'';
|
||||
if($guid !='')$guid = substr($guid, 1);
|
||||
}
|
||||
return $guid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据组部门id获取底下人员ID
|
||||
*/
|
||||
public function gjoins($receid)
|
||||
{
|
||||
if(contain($receid,'u') || contain($receid, 'd') || contain($receid, 'g'))$receid = $this->gjoin($receid);
|
||||
return $receid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据组获取底下人员Id
|
||||
*/
|
||||
public function getgrouptouid($gid)
|
||||
{
|
||||
if(isempt($gid))return '';
|
||||
$where = "1=1 and ((`type`='gu' and `mid` in($gid)) or (`type`='ug' and `sid` in($gid)))";
|
||||
$rows = $this->db->getall("select `type`,`mid`,`sid` from `[Q]sjoin` where $where");
|
||||
$uids = array();
|
||||
foreach($rows as $k=>$rs){
|
||||
$uid = '';
|
||||
if($rs['type']=='gu')$uid =$rs['sid'];
|
||||
if($rs['type']=='ug')$uid =$rs['mid'];
|
||||
if($uid!='' && !in_array($uid, $uids)){
|
||||
$uids[]= $uid;
|
||||
}
|
||||
}
|
||||
return join(',', $uids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断某个id是不是在里面,权限
|
||||
*/
|
||||
public function containjoin($joinid, $myid=0, $glx='ud')
|
||||
{
|
||||
$bo = false;
|
||||
$wh = $this->gjoin($joinid, $glx, 'where');
|
||||
if($wh == 'all')$bo = true;
|
||||
if(!$bo && $wh != ''){
|
||||
if($this->rows("`id`='$myid' and ($wh)")>0)$bo = true;
|
||||
}
|
||||
return $bo;
|
||||
}
|
||||
|
||||
public function getjoinstr($fids, $us, $lx=0, $slx=0)
|
||||
{
|
||||
$s = '';
|
||||
if(is_numeric($us)){
|
||||
$key= 'a'.$fids.''.$us.'_'.$lx.'_'.$slx.'';
|
||||
if(isset($this->_getjoinstr[$key]))return $this->_getjoinstr[$key];
|
||||
$us = $this->getone($us,'id,`name`,`deptid`,`deptpath`,`type`');
|
||||
}
|
||||
if(!$us)return '';
|
||||
$this->nowurs = $us;
|
||||
$uid = $us['id'];
|
||||
$key = 'a'.$fids.''.$uid.'_'.$lx.'_'.$slx.'';
|
||||
if(isset($this->_getjoinstr[$key]))return $this->_getjoinstr[$key];
|
||||
if($slx==0)$tj[] = "ifnull($fids,'')=''";
|
||||
$tj[] = $this->rock->dbinstr($fids, 'all');
|
||||
$tj[] = $this->rock->dbinstr($fids, 'u'.$uid);
|
||||
if($us){
|
||||
$dep = explode(',', $us['deptpath']);
|
||||
foreach($dep as $deps){
|
||||
$_deps = str_replace(array('[',']'), array('',''), $deps);
|
||||
$tj[] = $this->rock->dbinstr($fids, 'd'.$_deps);
|
||||
}
|
||||
//所在组Id
|
||||
$gids = m('sjoin')->getgroupid($uid);
|
||||
if($gids!='0'){
|
||||
$gidsa = explode(',', $gids);
|
||||
foreach($gidsa as $k1=>$gid1)if($k1>0)$tj[] = $this->rock->dbinstr($fids, 'g'.$gid1);
|
||||
}
|
||||
}
|
||||
$s = join(' or ', $tj);
|
||||
if($s != '' && $lx==0)$s = ' and ('.$s.')';
|
||||
$this->_getjoinstr[$key] = $s;
|
||||
return $s;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应部门负责人
|
||||
*/
|
||||
public function getdeptheadman($id, $lx=0)
|
||||
{
|
||||
$drs = $this->db->getone('[Q]dept','id='.$id.'');
|
||||
if(!$drs)return false;
|
||||
$cuid = $drs['headid'];
|
||||
$name = $drs['headman'];
|
||||
if(isempt($cuid)){
|
||||
if($lx==0){
|
||||
$lbar = $this->getdeptheadman($drs['pid'], 1);
|
||||
if($lbar){
|
||||
$cuid = $lbar[0];
|
||||
$name = $lbar[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isempt($cuid))return false;
|
||||
return array($cuid, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个人的上级主管或者领导
|
||||
* 返回 array(id,$name)
|
||||
*/
|
||||
public function getsuperman($uid)
|
||||
{
|
||||
$b = array(0,'');
|
||||
$urs = $this->getone($uid,'`superid`,`superman`,`deptid`');
|
||||
if(!$urs)return $b;
|
||||
$cuid = $urs['superid'];
|
||||
$name = $urs['superman'];
|
||||
if(isempt($cuid)){
|
||||
$deptid = (int)$urs['deptid'];
|
||||
if($deptid > 0){
|
||||
$drs = $this->getdeptheadman($deptid);
|
||||
if($drs){
|
||||
$cuid = $drs[0];
|
||||
$name = $drs[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!isempt($cuid)){
|
||||
$b = array($cuid, $name);
|
||||
}
|
||||
return $b;
|
||||
}
|
||||
|
||||
public function getjoinstrs($fids, $us, $slx=0, $lx=0)
|
||||
{
|
||||
return $this->getjoinstr($fids, $us, $lx, $slx);
|
||||
}
|
||||
|
||||
/**
|
||||
获取人员上级主管id
|
||||
*/
|
||||
public function getup($uid)
|
||||
{
|
||||
$one = $this->getone($uid, 'superid,deptid');
|
||||
$rows = $this->getpath($one['deptid'], $one['superid']);
|
||||
$s = $rows['superpath'];
|
||||
$s = str_replace('[', '', $s);
|
||||
$s = str_replace(']', '', $s);
|
||||
return $s;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归获取人员全部上级
|
||||
*/
|
||||
public function getsuperarr($uid, $lx=0)
|
||||
{
|
||||
if($lx==0)$this->getsuperarrba = array();
|
||||
$sql = "select a.id,a.name,b.`headid`,a.`superid` from `[Q]admin` a left join `[Q]dept` b on a.`deptid`=b.`id` where a.`id`='$uid'";
|
||||
$rows = $this->db->getall($sql);
|
||||
$superid = '';
|
||||
if($rows){
|
||||
$urs = $rows[0];
|
||||
$superid = $urs['superid'];
|
||||
if(isempt($superid))$superid = $urs['headid'];
|
||||
}
|
||||
if(!isempt($superid) && $lx<20){
|
||||
$superida = explode(',', $superid);
|
||||
foreach($superida as $sid){
|
||||
if($sid != $uid){
|
||||
$sna = $this->getmou('name', $sid);
|
||||
$this->getsuperarrba[] = array('id'=>$sid,'name'=>$sna);
|
||||
$this->getsuperarr($sid, $lx+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->getsuperarrba;
|
||||
}
|
||||
|
||||
private $deptarr = array();
|
||||
public function getpath($did, $sup,$dids='')
|
||||
{
|
||||
$deptpath = $this->db->getpval('[Q]dept', 'pid', 'id', $did, '],[');
|
||||
$deptallname= $this->db->getpval('[Q]dept', 'pid', 'name', $did, '/');
|
||||
if(!$this->deptarr)$this->deptarr = $this->db->getkeyall('[Q]dept','id,name');
|
||||
$deptname = arrvalue($this->deptarr, $did);
|
||||
$supername = '';
|
||||
$deptnames = '';
|
||||
|
||||
$superpath = '';
|
||||
if(!isempt($sup)){
|
||||
$sua = explode(',', $sup);
|
||||
foreach($sua as $suas){
|
||||
$sss1 = $this->db->getpval('[Q]admin', 'superid', 'id' ,$suas, '],[');
|
||||
if($sss1 != '')$superpath.=',['.$sss1.']';
|
||||
$sss2 = $this->db->getmou('[Q]admin', 'name', "`id`='$suas'");
|
||||
if(!isempt($sss2))$supername.=','.$sss2;
|
||||
}
|
||||
if($superpath!='')$superpath=substr($superpath,1);
|
||||
if($supername!='')$supername=substr($supername,1);
|
||||
}
|
||||
//部门路径
|
||||
if(!isempt($deptpath))$deptpath = $this->rock->strformat('[?0]', $deptpath);
|
||||
//有多部门
|
||||
if(!isempt($dids)){
|
||||
$didsa = explode(',', $dids);
|
||||
foreach($didsa as $dids1){
|
||||
$desss = $this->db->getpval('[Q]dept', 'pid', 'id', $dids1, '],[');
|
||||
if(isempt($desss))continue;
|
||||
$desssa = explode(',', $this->rock->strformat('[?0]', $desss));
|
||||
foreach($desssa as $desssa1){
|
||||
if(!contain($deptpath, $desssa1))$deptpath.=','.$desssa1.'';
|
||||
}
|
||||
$names1 = arrvalue($this->deptarr, $dids1);
|
||||
if(!isempt($names1))$deptnames.=','.$names1.'';
|
||||
}
|
||||
if($deptnames!='')$deptnames=substr($deptnames, 1);
|
||||
}
|
||||
if(!isempt($deptpath) && substr($deptpath,0,1)==',')$deptpath = substr($deptpath,1);
|
||||
|
||||
$rows['deptpath'] = $deptpath;
|
||||
$rows['superpath'] = $superpath;
|
||||
$rows['deptname'] = $deptname;
|
||||
$rows['deptnames'] = $deptnames;
|
||||
$rows['superman'] = $supername;
|
||||
$rows['deptallname']= $deptallname;
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下级人员id
|
||||
* $lx 0 全部下级,1直属下级
|
||||
* return 所有人员ID
|
||||
*/
|
||||
public function getdown($uid, $lx=0)
|
||||
{
|
||||
$where = $this->getdowns($uid, $lx);
|
||||
$rows = $this->getall($where, 'id');
|
||||
$s = '';
|
||||
foreach($rows as $k=>$rs)$s.=','.$rs['id'];
|
||||
if($s != '')$s = substr($s, 1);
|
||||
return $s;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下级人员id
|
||||
* $lx 0 全部下级,1直属下级
|
||||
* return 字符串条件
|
||||
*/
|
||||
public function getdowns($uid, $lx=0)
|
||||
{
|
||||
$where = "instr(superpath,'[$uid]')>0";
|
||||
if($lx==1)$where=$this->rock->dbinstr('superid', $uid);
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下属人员Id条件记录,如我下属任务
|
||||
* 返回如( distid in(1) or uid in(2) )
|
||||
*/
|
||||
public function getdownwhere($fid, $uid, $lx=0)
|
||||
{
|
||||
$bstr = $this->getdown($uid, $lx);
|
||||
$where= '1=2';
|
||||
if($bstr=='')return $where;
|
||||
$bas = explode(',', $bstr);
|
||||
$barr = array();
|
||||
foreach($bas as $bid){
|
||||
$barr[] = ''.$fid.' in('.$bid.')';
|
||||
}
|
||||
$where = join(' or ', $barr);
|
||||
$where = '('.$where.')';
|
||||
return $where;
|
||||
}
|
||||
|
||||
//返回我下属字符串条件如: instr(',1,2,3,', 字段)>0;
|
||||
public function getdownwheres($fid, $uid, $lx=0)
|
||||
{
|
||||
$bstr = $this->getdown($uid, $lx);
|
||||
$where= '1=2';
|
||||
if($bstr=='')return $where;
|
||||
$bstr = ','.$bstr.',';
|
||||
$where= "instr('$bstr', concat(',',$fid,','))>0";
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户信息(部门,单位,职位等)
|
||||
*/
|
||||
public function getinfor($uid)
|
||||
{
|
||||
$unitname = $deptname = $ranking = '';
|
||||
$name = '';
|
||||
$face = '';
|
||||
$deptid = '';
|
||||
$rs = $this->getone($uid, 'name,deptname,deptid,ranking,face');
|
||||
if($rs){
|
||||
$deptname = $rs['deptname'];
|
||||
$ranking = $rs['ranking'];
|
||||
$name = $rs['name'];
|
||||
$deptid = $rs['deptid'];
|
||||
$face = $this->getface($rs['face']);
|
||||
if(!$this->isempt($deptid))$unitname = $this->db->getpval('[Q]dept','pid','name', $deptid);
|
||||
}
|
||||
return array(
|
||||
'id' => $uid,
|
||||
'unitname' => $unitname,
|
||||
'deptname' => $deptname,
|
||||
'name' => $name,
|
||||
'ranking' => $ranking,
|
||||
'face' => $face,
|
||||
'deptid' => $deptid
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
获取在线的人员Id
|
||||
*/
|
||||
public function getonline($receid, $lx=10)
|
||||
{
|
||||
$uarr = $this->getonlines('reim,pc', $receid, $lx);
|
||||
$jonus = join(',', $uarr);
|
||||
return $jonus;
|
||||
}
|
||||
|
||||
//获取对应类型在线人员
|
||||
public function getonlines($type, $teuid='all', $lx=11, $where='')
|
||||
{
|
||||
$arrs = array();
|
||||
$dts = c('date')->adddate($this->rock->now, 'i', 0-$lx);
|
||||
$wheres = '';
|
||||
if($teuid != 'all' && $teuid!=''){
|
||||
if($this->contain($teuid,'u') || $this->contain($teuid,'d')){
|
||||
$teuid = $this->gjoin($teuid);
|
||||
if($teuid=='')return $arrs;
|
||||
}
|
||||
$wheres=" and `uid` in($teuid)";
|
||||
}
|
||||
if($lx>0){
|
||||
$wheres .= " and `moddt`>'$dts'";
|
||||
}
|
||||
$sql = "select `uid` from `[Q]logintoken` where instr(',".$type.",', concat(',',`cfrom`, ','))>0 and `online`=1 $wheres $where group by `uid`";
|
||||
|
||||
$rows = $this->db->getall($sql);
|
||||
foreach($rows as $k=>$rs){
|
||||
$arrs[] = $rs['uid'];
|
||||
}
|
||||
return $arrs;
|
||||
}
|
||||
|
||||
public function getface($face, $mr='')
|
||||
{
|
||||
if($mr=='')$mr = 'images/noface.png';
|
||||
if(substr($face,0,4)!='http' && !$this->isempt($face))$face = URL.''.$face.'';
|
||||
$face = $this->rock->repempt($face, $mr);
|
||||
return $face;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取人员信息
|
||||
*/
|
||||
public function getuserinfo($uids='0')
|
||||
{
|
||||
$uarr = $this->getall("`id` in(".$uids.") and `status`=1",'`id`,`name`,`face`','`sort`');
|
||||
foreach($uarr as $k=>$rs){
|
||||
$uarr[$k]['face'] = $this->getface($rs['face']);
|
||||
}
|
||||
return $uarr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取人员数据
|
||||
* $lx=0 通讯录,1选择人员
|
||||
*/
|
||||
public function getuser($lx=0, $uid=0)
|
||||
{
|
||||
$fields = '`id`,`name`,`deptid`,`deptname`,`deptpath`,`groupname`,`deptallname`,`mobile`,`ranking`,`tel`,`face`,`sex`,`email`,`pingyin`,`deptids`,`isvcard`';
|
||||
if($uid==0){
|
||||
$uid = $this->adminid;
|
||||
$where = m('view')->viewwhere('user', $uid, 'id');
|
||||
$where = str_replace('{asqom}','', $where);
|
||||
$range = $this->rock->get('changerange'); //指定了人
|
||||
$rangeno= $this->rock->get('changerangeno'); //no指定了人
|
||||
$where1 = '';$where2 = '';
|
||||
if(!isempt($range)){
|
||||
//本部门||下级部门
|
||||
if($range=='dept' || $range=='deptall'){
|
||||
$urs = $this->getone($uid);
|
||||
$deptid = $urs['deptid'];
|
||||
if(!isempt($urs['deptids']))$deptid.=','.$urs['deptids'].'';
|
||||
$deptida = explode(',', $deptid);
|
||||
$datsa = array();
|
||||
|
||||
if($range=='dept'){
|
||||
$datsa[]= '`deptid` in('.$deptid.')';
|
||||
foreach($deptida as $did1)if($did1)$datsa[]=$this->rock->dbinstr('deptids', $did1);
|
||||
}else{
|
||||
foreach($deptida as $did1)if($did1)$datsa[] = 'instr(`deptpath`,\'['.$did1.']\')>0';
|
||||
}
|
||||
|
||||
$where1 = join(' )or( ', $datsa);
|
||||
$where1 = 'and ('.$where1.')';
|
||||
}else if($range=='down' || $range=='downall'){
|
||||
$where1 = 'and '.$this->rock->dbinstr('superid', $this->adminid).'';
|
||||
if($range=='downall')$where1 = 'and instr(`superpath`,\'['.$this->adminid.']\')>0';
|
||||
}else{
|
||||
$where1 = $this->gjoin($range, '', 'where');
|
||||
$where1 = 'and ('.$where1.')';
|
||||
}
|
||||
}
|
||||
if(!isempt($rangeno)){
|
||||
$where2 = $this->gjoin($rangeno, '', 'where');
|
||||
$where2 = 'and not('.$where2.')';
|
||||
}
|
||||
if($lx==0)$where.=' and `isvcard`=1'; //通讯录显示
|
||||
//--start--
|
||||
if(ISMORECOM && $uid>1){
|
||||
$comid = $this->getcompanyid($uid);
|
||||
$str11 = $this->rock->dbinstr('`dwid`', $comid);
|
||||
$where2.=' and (`companyid`='.$comid.' or '.$str11.')';
|
||||
}
|
||||
//--end--
|
||||
//读取我可查看权限
|
||||
if(contain($where,'1=1')){
|
||||
$where = '';
|
||||
}else{
|
||||
$where = 'and ((1 '.$where.') or (`id`='.$uid.'))';
|
||||
}
|
||||
$rows = $this->getall("`status`=1 $where $where1 $where2",$fields,'`sort`,`name`');
|
||||
}else{
|
||||
$rows = $this->getall("`id`='$uid'",$fields,'`sort`,`name`');
|
||||
}
|
||||
|
||||
|
||||
foreach($rows as $k=>$rs){
|
||||
$rows[$k]['face'] = $rs['face'] = $this->getface($rs['face']);
|
||||
$deptidss = ','.$rs['deptid'].',';
|
||||
if(!isempt($rs['deptids']))$deptidss.=''.$rs['deptids'].',';
|
||||
$rows[$k]['deptidss'] = $deptidss;
|
||||
if($rs['pingyin']==null)$rows[$k]['pingyin']='';
|
||||
if($rs['ranking']==null)$rows[$k]['ranking']='';
|
||||
if($rs['deptname']==null)$rows[$k]['deptname']='';
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function getadmininfor($rows, $suids, $fid='checkid')
|
||||
{
|
||||
$farr = $this->db->getarr('[Q]admin', "`id` in($suids)",'`face`,`name`');
|
||||
foreach($rows as $k=>$rs){
|
||||
$face = $name = '';
|
||||
if(isset($farr[$rs[$fid]])){
|
||||
$face = $farr[$rs[$fid]]['face'];
|
||||
$name = $farr[$rs[$fid]]['name'];
|
||||
$rows[$k]['name'] = $name;
|
||||
}
|
||||
$rows[$k]['face'] = $this->getface($face);
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function getusinfo($uid, $fields='id')
|
||||
{
|
||||
$urs = $this->db->getone('[Q]userinfo', $uid, $fields);
|
||||
if(!$urs){
|
||||
$urs = array();
|
||||
$far = explode(',', str_replace('`','',$fields));
|
||||
foreach($far as $f)$urs[$f]='';
|
||||
$urs['id'] = $uid;
|
||||
}
|
||||
return $urs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getidtouser($id)
|
||||
{
|
||||
return $this->getmou('user', "`id`='$id'");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 更新信息
|
||||
*/
|
||||
public function updateinfo($where='')
|
||||
{
|
||||
$rows = $this->db->getall("select * from `[Q]admin` a where id>0 $where");
|
||||
$total = $this->db->count;
|
||||
$cl = 0;
|
||||
$sjo = m('sjoin');
|
||||
foreach($rows as $k=>$rs){
|
||||
$nrs = $this->getpath($rs['deptid'], $rs['superid'], $rs['deptids']);
|
||||
$gids = $sjo->getgroupid($rs['id']);
|
||||
if($gids=='0'){
|
||||
$gids = '';
|
||||
}else{
|
||||
$gids = substr($gids, 2);
|
||||
}
|
||||
if($nrs['deptpath'] != $rs['deptpath'] || $nrs['deptname'] != $rs['deptname'] || $nrs['superpath'] != $rs['superpath'] || $nrs['superman'] != $rs['superman'] || $nrs['deptnames'] != $rs['deptnames'] || $nrs['deptallname'] != $rs['deptallname'] || $gids != $rs['groupname']){
|
||||
$nrs['groupname'] = $gids;
|
||||
$this->record($nrs, "`id`='".$rs['id']."'");
|
||||
$cl++;
|
||||
}
|
||||
}
|
||||
|
||||
$cl += $this->updateuserinfo($where);
|
||||
|
||||
//更新单据上flow_bill上的uname,udeptname
|
||||
m('flowbill')->updatebill($where);
|
||||
m('imgroup')->updategall(); //更新会话上
|
||||
|
||||
return array($total, $cl);
|
||||
}
|
||||
public function updateuserinfo($whe='')
|
||||
{
|
||||
$db = m('userinfo');
|
||||
$rows = $this->db->getall('select a.name,a.deptname,a.id,a.status,a.ranking,b.id as ids,a.sex,a.tel,a.mobile,a.email,a.workdate,a.quitdt,b.state,a.num,a.companyid,a.dwid,a.deptnames,a.rankings,a.deptallname from `[Q]admin` a left join `[Q]userinfo` b on a.id=b.id where a.id>0 '.$whe.' ');
|
||||
$xbo = 0;
|
||||
foreach($rows as $k=>$rs){
|
||||
$uparr = array(
|
||||
'id' => $rs['id'],
|
||||
'name' => $rs['name'],
|
||||
'deptname' => $rs['deptname'],
|
||||
'deptnames' => $rs['deptnames'],
|
||||
'deptallname' => $rs['deptallname'],
|
||||
'ranking' => $rs['ranking'],
|
||||
'rankings' => $rs['rankings'],
|
||||
'sex' => $rs['sex'],
|
||||
'tel' => $rs['tel'],
|
||||
'mobile' => $rs['mobile'],
|
||||
'email' => $rs['email'],
|
||||
'workdate' => $rs['workdate'],
|
||||
'quitdt' => $rs['quitdt'],
|
||||
'num' => $rs['num'],
|
||||
'companyid' => $rs['companyid'],
|
||||
'dwid' => $rs['dwid'],
|
||||
);
|
||||
if(isempt($rs['quitdt'])){
|
||||
if($rs['state']=='5')$uparr['state'] = 0;
|
||||
}else{
|
||||
$uparr['state'] = 5;//离职
|
||||
}
|
||||
if(isempt($rs['ids'])){
|
||||
$db->insert($uparr);
|
||||
}else{
|
||||
unset($uparr['id']);
|
||||
$db->update($uparr, $rs['ids']);
|
||||
}
|
||||
$xbo+=$this->db->row_count();
|
||||
}
|
||||
return $xbo;
|
||||
}
|
||||
|
||||
//返回这个月份人员
|
||||
public function monthuwhere($month, $qz='')
|
||||
{
|
||||
$month = substr($month, 0, 7);
|
||||
$start = ''.$month.'-01';
|
||||
$enddt = c('date')->getenddt($month);
|
||||
$s = $this->monthuwheres($start, $enddt, $qz);
|
||||
return $s;
|
||||
}
|
||||
public function monthuwheres($start, $enddt, $qz='')
|
||||
{
|
||||
$s = " and ($qz`quitdt` is null or $qz`quitdt`>='$start') and ($qz`workdate` is null or $qz`workdate`<='$enddt')";
|
||||
return $s;
|
||||
}
|
||||
|
||||
public function changeface($uid, $fid)
|
||||
{
|
||||
$frs = m('file')->getone($fid);
|
||||
if(!$frs)return false;
|
||||
$path = $frs['thumbpath'];
|
||||
if(isempt($path))$path = $frs['filepath'];
|
||||
$face = $path;
|
||||
if(file_exists($path)){
|
||||
$face = ''.UPDIR.'/face/'.$uid.'_'.rand(1000,9999).'.jpg';
|
||||
$this->rock->createdir($face);
|
||||
c('image')->conver($path, $face);
|
||||
$oface = $this->getmou('face', $uid);
|
||||
if(!isempt($oface) && file_exists($oface))@unlink($oface);//删除原来头像
|
||||
$this->update("face='$face'", $uid);
|
||||
}
|
||||
m('file')->delfile($fid);
|
||||
if(!file_exists($face))$face='';
|
||||
return $face;
|
||||
}
|
||||
|
||||
//根据邮箱获取人员姓名
|
||||
private $emailtoursarr = array();
|
||||
public function emailtours($email)
|
||||
{
|
||||
$key = 'rock'.$email.'';
|
||||
if(!isset($this->emailtoursarr[$key])){
|
||||
$urs = $this->getone("`email`='$email'",'`id`,`name`');
|
||||
$this->emailtoursarr[$key] = $urs;
|
||||
}else{
|
||||
$urs = $this->emailtoursarr[$key];
|
||||
}
|
||||
return $urs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关键词搜索的
|
||||
*/
|
||||
public function getkeywhere($key, $qz='', $ots='')
|
||||
{
|
||||
$where = " and ($qz`name` like '%$key%' or $qz`user` like '%$key%' or $qz`deptallname` like '%$key%' or $qz`ranking` like '%$key%' or $qz`pingyin` like '$key%' $ots)";
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据receid获取对应字段$fid聚合得到多个,分开的
|
||||
*/
|
||||
public function getjoinfields($receid, $fid)
|
||||
{
|
||||
if(!is_numeric($receid)){
|
||||
$receid = $this->gjoin($receid,'ud', 'where'); //读取
|
||||
$where = '1=1';
|
||||
if($receid != 'all')$where = $receid;
|
||||
if(isempt($receid))$where = '1=2';
|
||||
}else{
|
||||
$where = 'id='.$receid.'';
|
||||
}
|
||||
$wherew1 = $this->getcompanywhere();
|
||||
$rows = $this->getall("`status`=1 $wherew1 and ($where)", '`id`,`'.$fid.'`');
|
||||
$strs = '';
|
||||
foreach($rows as $k=>$rs){
|
||||
if(!isempt($rs[$fid]))$strs.=','.$rs[$fid].'';
|
||||
}
|
||||
if($strs!='')$strs = substr($strs, 1);
|
||||
|
||||
return $strs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否已修改密码了
|
||||
*/
|
||||
public function iseditpass($uid)
|
||||
{
|
||||
$editpass = (int)getconfig('editpass','0');
|
||||
$stype = getconfig('systype');
|
||||
if($editpass==0 || $stype=='dev' || $stype=='demo')return 1;
|
||||
$urs = $this->getone('`id`='.$uid.'');
|
||||
$editpass = (int)arrvalue($urs, 'editpass','0');
|
||||
return $editpass;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取用户信息
|
||||
*/
|
||||
private $getuserrsarr = array();
|
||||
public function geturs($id)
|
||||
{
|
||||
if(isempt($id))return false;
|
||||
if(isset($this->getuserrsarr[$id]))return $this->getuserrsarr[$id];
|
||||
|
||||
$where = "`user`='$id'";
|
||||
$check = c('check');
|
||||
if($check->iscnmobile($id)){
|
||||
$where = "`mobile`='$id'";
|
||||
}elseif($check->isemail($id)){
|
||||
$where = "`email`='$id'";
|
||||
}elseif($check->isincn($id)){
|
||||
$where = "`name`='$id'";
|
||||
}elseif($check->isnumber($id)){
|
||||
$where = "`id`='$id'";
|
||||
}
|
||||
if(contain($id, ':')){
|
||||
$ida = explode(':', $id);
|
||||
$where = "`".$ida[0]."`='".$ida[1]."'";
|
||||
}
|
||||
$urs = $this->db->getall("select * from `[Q]admin` where $where");
|
||||
if($urs)$urs = $urs[0];
|
||||
$this->getuserrsarr[$id] = $urs;
|
||||
return $urs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单位的信息
|
||||
*/
|
||||
public function getcompanyinfo($uid=0, $glx=0)
|
||||
{
|
||||
if($uid==0)$uid = $this->adminid;
|
||||
if($uid==0)$uid = (int)arrvalue($GLOBALS,'adminid','0');
|
||||
if($uid==0)$uid = 1;//必须要有个值
|
||||
$urs = $this->getone('`id`='.$uid.'');
|
||||
$companyid = $urs['companyid'];
|
||||
$comid = (int)arrvalue($urs, 'comid', '0');
|
||||
if(isempt($companyid) || $companyid=='0'){
|
||||
$this->update('`companyid`=1', $uid);
|
||||
$companyid = '1';
|
||||
}
|
||||
$alldwid = $companyid;
|
||||
$dwid= arrvalue($urs, 'dwid');
|
||||
if(!isempt($dwid))$alldwid.=','.$dwid.'';
|
||||
$companyinfo = array('id'=>0);
|
||||
$companyinfd = false;
|
||||
$cwhere = '`id` in('.$alldwid.')';
|
||||
if($glx==5 && $uid==1)$cwhere = '`id`>0';
|
||||
$companyinfoall = m('company')->getall($cwhere,'*','`pid`,`sort`');
|
||||
$nid = $companyid;
|
||||
$allid = array(0);
|
||||
foreach($companyinfoall as $k=>$rs){
|
||||
$nlogo = 'images/logo.png';
|
||||
$logo = $rs['logo'];
|
||||
if(isempt($logo)){
|
||||
$logo = $nlogo;
|
||||
}else{
|
||||
if(substr($logo,0,4)!='http' && !file_exists($logo))
|
||||
$logo = $nlogo;
|
||||
}
|
||||
$companyinfoall[$k]['logo'] = $rs['logo'] = $this->getface($logo, $nlogo);
|
||||
|
||||
if($rs['id']==$nid)$companyinfo = $rs;
|
||||
if($rs['id']==$comid)$companyinfd = $rs;
|
||||
$allid[] = $rs['id'];
|
||||
}
|
||||
if($companyinfd)$companyinfo = $companyinfd;
|
||||
$this->setcompanyid($companyinfo['id']);
|
||||
if($glx==1)return $companyinfo;
|
||||
if($glx==2)return $companyinfo['id'];
|
||||
return array(
|
||||
'companyinfoall' => $companyinfoall,
|
||||
'companyallid' => $allid,
|
||||
'companyinfo' => $companyinfo,
|
||||
'companyid' => $companyinfo['id']
|
||||
);
|
||||
}
|
||||
|
||||
public function getcompanyid($uid=0)
|
||||
{
|
||||
$comid = (int)$this->rock->session('companyid','0');
|
||||
if($comid==0)$comid = $this->getcompanyinfo($uid,2);
|
||||
if(!$comid)$comid=1;
|
||||
return $comid;
|
||||
}
|
||||
|
||||
public function setcompanyid($comid)
|
||||
{
|
||||
$this->rock->setsession('companyid', $comid);
|
||||
return $comid;
|
||||
}
|
||||
|
||||
public function getcompanywhere($lx=0, $qz='',$comid=false)
|
||||
{
|
||||
$where = '';
|
||||
//--start--
|
||||
if(ISMORECOM){
|
||||
if($comid===false)$comid = ''.$this->getcompanyid().'';
|
||||
$comi2 = $comid;
|
||||
$str11 = $this->rock->dbinstr(''.$qz.'dwid', $comid);
|
||||
if($this->adminid==1)$comid.=',0';
|
||||
$where= " and (".$qz."`companyid` in (".$comid.") or $str11)";
|
||||
if($lx==1)$where= " and ".$qz."`comid` in (".$comid.")";
|
||||
if($lx==2)$where= " and ".$qz."`companyid` in (".$comid.")";
|
||||
if($lx==3)$where= " and ".$qz."`comid`=".$comi2."";
|
||||
if($lx==5)$where= " and ".$qz."`companyid`=".$comi2.""; //用在关联userinfo表只看本单位
|
||||
if($lx==4)$where= " and ".$qz."`uid` in(select `id` from `[Q]admin` where `companyid`=".$comi2.")";
|
||||
}
|
||||
//--end--
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function getcompanynum($uid=0)
|
||||
{
|
||||
$num ='';
|
||||
$carr = $this->getcompanyinfo($uid);
|
||||
$num = $carr['companyinfo']['num'];
|
||||
if(isempt($num))$num='';
|
||||
return $num;
|
||||
}
|
||||
}
|
||||
221
webmain/model/agent/agent.php
Normal file
221
webmain/model/agent/agent.php
Normal file
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
/**
|
||||
* 应用上的接口文件,读取数据显示
|
||||
*/
|
||||
class agentModel extends Model
|
||||
{
|
||||
public $agentnum = '';
|
||||
public $agentid = '0';
|
||||
public $modeid = 3;
|
||||
public $page = 1;
|
||||
public $loadci = 1;
|
||||
public $limit = 10; //默认加载的条数
|
||||
public $user_id = 0;
|
||||
public $event = '';
|
||||
public $agentrs;
|
||||
public $moders;
|
||||
public $flow = null;
|
||||
public $tongmode = true;
|
||||
|
||||
public function getdatas($uid, $lx, $p){}
|
||||
|
||||
/**
|
||||
* 从新接口方法
|
||||
* $rows 要展示数据 $rowd 原始数据
|
||||
*/
|
||||
protected function agentrows($rows, $rowd, $uid){return $rows;}
|
||||
protected function agenttotals($uid){return array();}
|
||||
protected function agentdata($uid, $lx){return false;}
|
||||
|
||||
protected $showuface = true;//是否显示对应人员头像
|
||||
|
||||
|
||||
public function gettotal()
|
||||
{
|
||||
return array(
|
||||
'stotal' => 0,
|
||||
'titles' => ''
|
||||
);
|
||||
}
|
||||
|
||||
public function getagentinfor($num)
|
||||
{
|
||||
$this->agentnum = $num;
|
||||
$this->agentrs = m('im_group')->getone("`num`='$num'");
|
||||
$this->moders = m('flow_set')->getone("`num`='$num'");
|
||||
if($this->agentrs){
|
||||
$this->agentid = $this->agentrs['id'];
|
||||
}
|
||||
if($this->moders){
|
||||
$this->modeid = $this->moders['id'];
|
||||
$this->flow = m('flow')->initflow($num);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getdata($uid, $num, $lx, $page)
|
||||
{
|
||||
$this->tongmode = true;
|
||||
if(!isempt($lx)){
|
||||
$lxa = explode('|', $lx);
|
||||
if(isset($lxa[1]) && !isempt($lxa[1])){
|
||||
if($lxa[1] != $num)$this->tongmode = false;
|
||||
$num = $lxa[1];
|
||||
$lx = $lxa[0];
|
||||
}
|
||||
}
|
||||
$this->loadci = (int)$this->rock->get('loadci','0');
|
||||
$this->getagentinfor($num);
|
||||
$this->page = $page;
|
||||
$this->user_id = $uid;
|
||||
$this->event = $lx;
|
||||
$narr = $this->agentdata($uid, $lx);
|
||||
$lx = $this->event;
|
||||
if(!$narr)$narr = $this->getdatalimit($uid, $lx);
|
||||
$arr = array(
|
||||
'wdtotal' => 0,
|
||||
'event' => $lx,
|
||||
'num' => $num,
|
||||
'rows' => array(),
|
||||
'rowd' => array(),
|
||||
'page' => $page,
|
||||
'limit' => $this->limit,
|
||||
'agentid' => $this->agentid,
|
||||
'count' => 0,
|
||||
'maxpage' => 0
|
||||
);
|
||||
if(is_array($narr))foreach($narr as $k=>$v)$arr[$k]=$v;
|
||||
$barr = $this->agentrows($arr['rows'],$arr['rowd'], $uid);
|
||||
if(isset($barr['rows'])){
|
||||
foreach($barr as $k=>$v)$arr[$k]=$v;
|
||||
$barr = $barr['rows'];
|
||||
}
|
||||
$arr['rows'] = $this->showrowsface($barr);
|
||||
$arr['stotal'] = $this->agenttotals($uid);
|
||||
unset($arr['rowd']);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
//状态切换读取一般用于有流程
|
||||
protected function agentrows_status($rows, $rowd){
|
||||
foreach($rowd as $k=>$rs){
|
||||
if($this->flow){
|
||||
$rows[$k]['modename'] = $this->moders['name'];
|
||||
$rows[$k]['modenum'] = $this->moders['num'];
|
||||
if(isset($rs['status'])){
|
||||
$zts = $this->flow->getstatus($rs);
|
||||
$rows[$k]['statustext'] = $zts[0];
|
||||
$rows[$k]['statuscolor'] = $zts[1];
|
||||
if($rs['status']==5)$rows[$k]['ishui'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用上获取数据
|
||||
*/
|
||||
public function getdatalimit($uid, $lx)
|
||||
{
|
||||
if(!$this->flow)return array();
|
||||
$nas = $this->flow->billwhere($uid, $lx);
|
||||
$_wehs = $nas['where'];
|
||||
|
||||
$where = '1=1 '.$_wehs.'';
|
||||
$fields = '*';
|
||||
$order = '';
|
||||
$_tabsk = $nas['table'];
|
||||
if(contain($_tabsk,' ')){
|
||||
$tables = $_tabsk;
|
||||
$table = $this->flow->mtable;
|
||||
}else{
|
||||
$table = $_tabsk;
|
||||
$tables = $this->rock->T($table);
|
||||
}
|
||||
if(!isempt($nas['order']))$order = $nas['order'];
|
||||
if(!isempt($nas['fields']))$fields = $nas['fields'];
|
||||
$arr = m($table)->getlimit($where, $this->page, $fields, $order, $this->limit, $tables);
|
||||
$rows = $arr['rows'];
|
||||
$row = array();
|
||||
$summarx= $this->flow->moders['summarx'];
|
||||
if(isempt($summarx))$summarx = 'cont:'.$this->flow->moders['summary'].'';
|
||||
$suarr = $this->zhaiyaoar($summarx);
|
||||
$rows = $this->flow->viewjinfields($rows);//禁看字段处理
|
||||
foreach($rows as $k=>$rs){
|
||||
$jarr = array();
|
||||
$rs = $this->flow->flowrsreplace($rs, 2);
|
||||
if(isset($rs['id']))$jarr['id'] = $rs['id'];
|
||||
if(isset($rs['uid']))$jarr['uid'] = $rs['uid'];
|
||||
if(isset($rs['ishui']))$jarr['ishui'] = $rs['ishui'];
|
||||
foreach($suarr as $f=>$nr){
|
||||
$str = $this->rock->reparr($nr, $rs);
|
||||
if($f=='cont')$str = $this->contreplaces($str);
|
||||
$jarr[$f] = $str;
|
||||
}
|
||||
$rows[$k] = $rs;
|
||||
$ors = $this->flow->flowrsreplace_we($jarr, $rs);
|
||||
if(!$this->tongmode){
|
||||
if(!isset($ors['modenum']))$ors['modenum'] = $this->moders['num'];
|
||||
if(!isset($ors['modename']))$ors['modename'] = $this->moders['name'];
|
||||
}
|
||||
$row[] = $ors;
|
||||
}
|
||||
$arr['rows'] = $row;
|
||||
$arr['rowd'] = $rows;
|
||||
return $arr;
|
||||
}
|
||||
|
||||
private function zhaiyaoar($str)
|
||||
{
|
||||
$stra = explode("\n", $str);
|
||||
$arr = array();
|
||||
foreach($stra as $nr){
|
||||
if(strpos($nr,'title:')===0)$arr['title'] = substr($nr, 6);
|
||||
if(strpos($nr,'optdt:')===0)$arr['optdt'] = substr($nr, 6);
|
||||
if(strpos($nr,'cont:')===0)$arr['cont'] = substr($nr, 5);
|
||||
}
|
||||
if(!$arr)$arr['cont'] = $str;
|
||||
return $arr;
|
||||
}
|
||||
|
||||
private function contreplaces($str)
|
||||
{
|
||||
$stra = explode('[br]', $str);
|
||||
$s1 = '';
|
||||
foreach($stra as $s){
|
||||
$a1 = explode(':', $s);
|
||||
if(isset($a1[1]) && $a1[1]==''){
|
||||
}else{
|
||||
$s1.='$%#'.$s.'';
|
||||
}
|
||||
}
|
||||
if($s1!=''){
|
||||
$s1 = str_replace('$%#', "\n", substr($s1, 3));
|
||||
}
|
||||
return $s1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示人员对应头像
|
||||
*/
|
||||
private function showrowsface($rows)
|
||||
{
|
||||
if(!$this->showuface)return $rows;
|
||||
$uids = '0';
|
||||
foreach($rows as $k=>$rs){
|
||||
if(isset($rs['uid']))$uids .=','.$rs['uid'].'';
|
||||
}
|
||||
if($uids!='0'){
|
||||
$adb = m('admin');
|
||||
$uarr = $this->db->getarr('[Q]admin','id in('.$uids.')','`face`,`name`');
|
||||
foreach($rows as $k=>$rs){
|
||||
if(!isset($rs['uid']))continue;
|
||||
if(isset($uarr[$rs['uid']])){
|
||||
$rows[$k]['face'] = $adb->getface($uarr[$rs['uid']]['face']);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
22
webmain/model/agent/baseModel.php
Normal file
22
webmain/model/agent/baseModel.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
//基础模块应用
|
||||
class agent_baseClassModel extends agentModel
|
||||
{
|
||||
|
||||
|
||||
protected function agentrows($rows, $rowd, $uid)
|
||||
{
|
||||
$typearr = array();
|
||||
if($this->loadci==1 && $this->flow)$typearr = $this->flow->flowwesearchdata(1); //读取搜索的下拉框数据
|
||||
foreach($rowd as $k=>$rs){
|
||||
$rows[$k]['modenum'] = $this->agentnum;
|
||||
}
|
||||
|
||||
if($this->flow && $this->flow->isflow>0)$rows = $this->agentrows_status($rows, $rowd);//显示流程状态
|
||||
|
||||
return array(
|
||||
'rows' => $rows,
|
||||
'typearr' => $typearr,
|
||||
);
|
||||
}
|
||||
}
|
||||
43
webmain/model/agent/bianjianModel.php
Normal file
43
webmain/model/agent/bianjianModel.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* 便笺(2021-08-31)添加
|
||||
*/
|
||||
class agent_bianjianClassModel extends agentModel
|
||||
{
|
||||
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->getwdtotal($this->adminid);
|
||||
$titles = '';
|
||||
return array('stotal'=>$stotal,'titles'=> $titles);
|
||||
}
|
||||
|
||||
private function getwdtotal($uid)
|
||||
{
|
||||
$stotal = m('bianjian')->rows('`uid`='.$uid.' and `state`=2');
|
||||
return $stotal;
|
||||
}
|
||||
|
||||
|
||||
protected function agenttotals($uid)
|
||||
{
|
||||
$a = array(
|
||||
'weiwc' => $this->getwdtotal($uid)
|
||||
);
|
||||
return $a;
|
||||
}
|
||||
|
||||
protected function agentrows($rows, $rowd, $uid)
|
||||
{
|
||||
if($rowd)foreach($rowd as $k=>$rs){
|
||||
if($rs['stateval']>0){
|
||||
$ztrs = $this->flow->getststrsssa($rs['stateval']);
|
||||
if($ztrs){
|
||||
$rows[$k]['statustext'] = $ztrs['name'];
|
||||
$rows[$k]['statuscolor'] = $ztrs['color'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
20
webmain/model/agent/custfinaModel.php
Normal file
20
webmain/model/agent/custfinaModel.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
//客户.收款单的应用
|
||||
class agent_custfinaClassModel extends agentModel
|
||||
{
|
||||
|
||||
|
||||
//状态显示替换
|
||||
protected function agentrows($rows, $rowd, $uid)
|
||||
{
|
||||
$statea = $this->flow->statearrs;
|
||||
foreach($rowd as $k=>$rs){
|
||||
$state = $rs['paystatus'];
|
||||
$ztarr = $statea[$state];
|
||||
$rows[$k]['statustext'] = $ztarr[0];
|
||||
$rows[$k]['statuscolor'] = $ztarr[1];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
}
|
||||
21
webmain/model/agent/custfkdModel.php
Normal file
21
webmain/model/agent/custfkdModel.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
//客户.付款单的应用
|
||||
class agent_custfkdClassModel extends agentModel
|
||||
{
|
||||
|
||||
|
||||
//状态显示替换
|
||||
protected function agentrows($rows, $rowd, $uid)
|
||||
{
|
||||
$statea = $this->flow->statearrf;
|
||||
foreach($rowd as $k=>$rs){
|
||||
$state = $rs['paystatus'];
|
||||
$ztarr = $statea[$state];
|
||||
$rows[$k]['statustext'] = $ztarr[0];
|
||||
$rows[$k]['statuscolor'] = $ztarr[1];
|
||||
$rows[$k]['modenum'] = 'custfinb';
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
}
|
||||
29
webmain/model/agent/customerModel.php
Normal file
29
webmain/model/agent/customerModel.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
class agent_customerClassModel extends agentModel
|
||||
{
|
||||
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->gettotalss($this->adminid);
|
||||
$titles = '';
|
||||
return array('stotal'=>$stotal,'titles'=> $titles);
|
||||
}
|
||||
|
||||
private function gettotalss($uid)
|
||||
{
|
||||
$to = 0;
|
||||
return $to;
|
||||
}
|
||||
|
||||
protected function agentrows($rows, $rowd, $uid)
|
||||
{
|
||||
foreach($rowd as $k=>$rs){
|
||||
if($rs['statuss']==0){
|
||||
$rows[$k]['statustext']='已停用';
|
||||
$rows[$k]['statuscolor']='#888888';
|
||||
$rows[$k]['ishui'] =1;
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
38
webmain/model/agent/custplanModel.php
Normal file
38
webmain/model/agent/custplanModel.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
//客户.跟进计划
|
||||
class agent_custplanClassModel extends agentModel
|
||||
{
|
||||
|
||||
|
||||
//状态显示替换
|
||||
protected function agentrows($rows, $rowd, $uid)
|
||||
{
|
||||
$ztarr = $this->flow->getstatusarr();
|
||||
foreach($rowd as $k=>$rs){
|
||||
$ztarra = $ztarr[$rs['statusval']];
|
||||
$rows[$k]['statustext'] = $ztarra[0];
|
||||
$rows[$k]['statuscolor'] = $ztarra[1];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->gettotalss($this->adminid);
|
||||
$titles = '';
|
||||
return array('stotal'=>$stotal,'titles'=> $titles);
|
||||
}
|
||||
|
||||
private function gettotalss($uid)
|
||||
{
|
||||
$to = m('custplan')->rows('`uid`='.$uid.' and `status`=0');
|
||||
return $to;
|
||||
}
|
||||
|
||||
protected function agenttotals($uid)
|
||||
{
|
||||
return array(
|
||||
'mywwc' => $this->gettotalss($uid)
|
||||
);
|
||||
}
|
||||
}
|
||||
23
webmain/model/agent/custractModel.php
Normal file
23
webmain/model/agent/custractModel.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
//客户合同的应用
|
||||
class agent_custractClassModel extends agentModel
|
||||
{
|
||||
|
||||
|
||||
//状态显示替换
|
||||
protected function agentrows($rows, $rowd, $uid)
|
||||
{
|
||||
$statea = $this->flow->statearr;
|
||||
foreach($rowd as $k=>$rs){
|
||||
$state = $rs['htstatus'];
|
||||
if($state==2){
|
||||
$rows[$k]['ishui'] =1;
|
||||
}
|
||||
$ztarr = $statea[$state];
|
||||
$rows[$k]['statustext'] = $ztarr[0];
|
||||
$rows[$k]['statuscolor'] = $ztarr[1];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
}
|
||||
40
webmain/model/agent/custsaleModel.php
Normal file
40
webmain/model/agent/custsaleModel.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
class agent_custsaleClassModel extends agentModel
|
||||
{
|
||||
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->gettotalss($this->adminid);
|
||||
$titles = '';
|
||||
return array('stotal'=>$stotal,'titles'=> $titles);
|
||||
}
|
||||
|
||||
private function gettotalss($uid)
|
||||
{
|
||||
$to = m('custsale')->rows('`uid`='.$uid.' and `state`=0');
|
||||
return $to;
|
||||
}
|
||||
|
||||
protected function agenttotals($uid)
|
||||
{
|
||||
return array(
|
||||
'gen' => $this->gettotalss($uid)
|
||||
);
|
||||
}
|
||||
|
||||
protected function agentrows($rows, $rowd, $uid)
|
||||
{
|
||||
$statea = $this->flow->statearr;
|
||||
foreach($rowd as $k=>$rs){
|
||||
$state = $rs['statess'];
|
||||
if($state==2){
|
||||
$rows[$k]['ishui'] =1;
|
||||
}
|
||||
$ztarr = $statea[$state];
|
||||
$rows[$k]['statustext'] = $ztarr[0];
|
||||
$rows[$k]['statuscolor'] = $ztarr[1];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
}
|
||||
48
webmain/model/agent/daibanModel.php
Normal file
48
webmain/model/agent/daibanModel.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
class agent_daibanClassModel extends agentModel
|
||||
{
|
||||
public function initModel()
|
||||
{
|
||||
$this->settable('flow_bill');
|
||||
}
|
||||
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->getdbtotal($this->adminid);
|
||||
$titles = '';
|
||||
return array('stotal'=>$stotal,'titles'=> $titles);
|
||||
}
|
||||
|
||||
private function getdbtotal($uid)
|
||||
{
|
||||
$stotal = m('flowbill')->daibanshu($uid);
|
||||
return $stotal;
|
||||
}
|
||||
|
||||
protected function agenttotals($uid)
|
||||
{
|
||||
return array(
|
||||
'daiban' => $this->getdbtotal($uid)
|
||||
);
|
||||
}
|
||||
|
||||
protected function agentdata($uid, $lx)
|
||||
{
|
||||
$atype = $this->agentnum.'_'.$lx;
|
||||
$dbss = m('flowbill');
|
||||
$arr = $dbss->getrecord($uid, $atype, $this->page, $this->limit, 0);
|
||||
if($atype=='daiban_daib'){
|
||||
$rows = $arr['rows'];
|
||||
if($rows){
|
||||
$arr['rows'] = $rows;
|
||||
}
|
||||
}
|
||||
$sdar = $this->db->getall('select `modeid` from `[Q]flow_bill` where '.$dbss->nowwhere.' group by `modeid`');
|
||||
$idss = '0';
|
||||
foreach($sdar as $k=>$rs)$idss.=','.$rs['modeid'].'';
|
||||
|
||||
$arr['modearr'] = m('mode')->getmodearr('and `id` in('.$idss.')');
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
44
webmain/model/agent/dailyModel.php
Normal file
44
webmain/model/agent/dailyModel.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
工作日报
|
||||
*/
|
||||
class agent_dailyClassModel extends agentModel
|
||||
{
|
||||
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->getwdtotal($this->adminid);
|
||||
$titles = '';
|
||||
return array('stotal'=>$stotal,'titles'=> $titles);
|
||||
}
|
||||
|
||||
public function getwdtotal($uid)
|
||||
{
|
||||
$ydid = m('log')->getread('daily', $uid);
|
||||
$whe1w = 'and '.m('admin')->getdownwheres('uid', $uid, 0);
|
||||
$where = "id not in($ydid) $whe1w ";
|
||||
$stotal = m('daily')->rows($where);
|
||||
return $stotal;
|
||||
}
|
||||
|
||||
protected function agenttotals($uid)
|
||||
{
|
||||
$a = array(
|
||||
'under' => $this->getwdtotal($uid)
|
||||
);
|
||||
return $a;
|
||||
}
|
||||
protected function agentrows($rows, $rowd, $uid){
|
||||
$ydarr = explode(',', m('log')->getread('daily', $uid));
|
||||
foreach($rowd as $k=>$rs){
|
||||
if(!in_array($rs['id'], $ydarr) && $rs['uid'] != $uid){
|
||||
$rows[$k]['statustext'] = '未读';
|
||||
$rows[$k]['statuscolor'] = '#ED5A5A';
|
||||
}else{
|
||||
$rows[$k]['ishui'] = 1;
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
}
|
||||
34
webmain/model/agent/emailmModel.php
Normal file
34
webmain/model/agent/emailmModel.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
class agent_emailmClassModel extends agentModel
|
||||
{
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->getwdtotal($this->adminid);
|
||||
return array('stotal'=>$stotal,'titles'=>'');
|
||||
}
|
||||
|
||||
public function getwdtotal($uid)
|
||||
{
|
||||
|
||||
$stotal = m('emailm')->wdtotal($uid);
|
||||
return $stotal;
|
||||
}
|
||||
|
||||
protected function agenttotals($uid)
|
||||
{
|
||||
$a = array(
|
||||
'sjx' => $this->getwdtotal($uid)
|
||||
);
|
||||
return $a;
|
||||
}
|
||||
|
||||
//数据替换
|
||||
protected function agentrows($rows, $rowd, $uid){
|
||||
if($rows){
|
||||
foreach($rowd as $k=>$rs){
|
||||
$rows[$k]['ishui'] = $rs['zt'];
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
64
webmain/model/agent/flowModel.php
Normal file
64
webmain/model/agent/flowModel.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
class agent_flowClassModel extends agentModel
|
||||
{
|
||||
public function initModel()
|
||||
{
|
||||
$this->settable('flow_bill');
|
||||
}
|
||||
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->getwdtotal($this->adminid);
|
||||
$titles = '';
|
||||
return array('stotal'=>$stotal,'titles'=> $titles);
|
||||
}
|
||||
|
||||
private function getwdtotal($uid)
|
||||
{
|
||||
$stotal = m('flowbill')->applymywgt($uid);;
|
||||
return $stotal;
|
||||
}
|
||||
|
||||
protected function agentdata($uid, $lx)
|
||||
{
|
||||
if($lx=='moreapply'){
|
||||
$viewobj = m('view');
|
||||
$applyarr = m('mode')->getmoderows($uid,'and islu=1');
|
||||
$modearr = array();
|
||||
$otyle = '';
|
||||
$oi = 0;
|
||||
foreach($applyarr as $k=>$rs){
|
||||
if(!$viewobj->isadd($rs, $this->adminid))continue;
|
||||
if($otyle!=$rs['type']){
|
||||
$oi = 0;
|
||||
$modearr[] = array(
|
||||
'showtype' => 'line',
|
||||
'title' => $rs['type']
|
||||
);
|
||||
}
|
||||
$otyle = $rs['type'];
|
||||
$oi++;
|
||||
$modearr[]=array('modenum'=>$rs['num'],'type'=>'applybill','name'=>$rs['name'],'title'=>''.$oi.'.'.$rs['name']);
|
||||
}
|
||||
$arr['rows']= $modearr;
|
||||
return $arr;
|
||||
}
|
||||
|
||||
$arr = m('flowbill')->getrecord($uid, $this->agentnum.'_'.$lx, $this->page, $this->limit);
|
||||
$modearr= array();
|
||||
if($this->loadci==1){
|
||||
$modearr = m('mode')->getmodemyarr($uid);
|
||||
}
|
||||
return array(
|
||||
'rows' => $arr,
|
||||
'modearr' => $modearr,
|
||||
);
|
||||
}
|
||||
|
||||
protected function agenttotals($uid)
|
||||
{
|
||||
return array(
|
||||
'mywtg' => $this->getwdtotal($uid)
|
||||
);
|
||||
}
|
||||
}
|
||||
46
webmain/model/agent/gongModel.php
Normal file
46
webmain/model/agent/gongModel.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
通知公告的
|
||||
*/
|
||||
class agent_gongClassModel extends agentModel
|
||||
{
|
||||
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->getwdtotal($this->adminid);
|
||||
$titles = '';
|
||||
return array('stotal'=>$stotal,'titles'=> $titles);
|
||||
}
|
||||
|
||||
private function getwdtotal($uid)
|
||||
{
|
||||
$ydid = m('log')->getread('infor', $uid);
|
||||
$where = "id not in($ydid) and `status`=1";
|
||||
$meswh = m('admin')->getjoinstr('receid', $uid);
|
||||
$where .= $meswh;
|
||||
|
||||
$where.= " and (`zstart` is null or `zstart`<='{$this->rock->date}')";
|
||||
$where.= " and (`zsend` is null or `zsend`>='{$this->rock->date}')";
|
||||
|
||||
$where .= m('admin')->getcompanywhere(1);
|
||||
$stotal = m('infor')->rows($where);
|
||||
return $stotal;
|
||||
}
|
||||
|
||||
|
||||
protected function agenttotals($uid)
|
||||
{
|
||||
$a = array(
|
||||
'weidu' => $this->getwdtotal($uid)
|
||||
);
|
||||
return $a;
|
||||
}
|
||||
protected function agentrows($rows, $rowd, $uid){
|
||||
$typearr = array();
|
||||
if($this->loadci==1)$typearr = $this->flow->flowwesearchdata(1);
|
||||
return array(
|
||||
'rows' =>$rows,
|
||||
'typearr' =>$typearr,
|
||||
);
|
||||
}
|
||||
}
|
||||
28
webmain/model/agent/jiankongModel.php
Normal file
28
webmain/model/agent/jiankongModel.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
class agent_jiankongClassModel extends agentModel
|
||||
{
|
||||
public function initModel()
|
||||
{
|
||||
$this->settable('flow_bill');
|
||||
}
|
||||
|
||||
|
||||
protected function agentdata($uid, $lx)
|
||||
{
|
||||
$rows = m('flowbill')->getrecord($uid, $lx, $this->page, $this->limit);
|
||||
$modearr= array();
|
||||
if($this->loadci==1){
|
||||
$modeids = '0';
|
||||
$rows1 = m('view')->getjilu($uid);
|
||||
foreach($rows1 as $k1=>$rs1){
|
||||
$modeids.=','.$rs1['modeid'].'';
|
||||
}
|
||||
$modearr = m('mode')->getmodemyarr(0,'and `id` in('.$modeids.')');
|
||||
}
|
||||
return array(
|
||||
'rows' =>$rows,
|
||||
'modearr' =>$modearr,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
79
webmain/model/agent/kaoshiModel.php
Normal file
79
webmain/model/agent/kaoshiModel.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* 考试培训
|
||||
*/
|
||||
class agent_kaoshiClassModel extends agentModel
|
||||
{
|
||||
protected function agentdata($uid, $lx)
|
||||
{
|
||||
$rows = array();
|
||||
$table = '`[Q]knowtrais` a left join `[Q]knowtraim` b on a.mid=b.id left join `[Q]admin` c on c.id=a.`uid`';
|
||||
$where = '1=1';
|
||||
$where.=' and a.`uid`='.$uid.'';
|
||||
if($lx=='weiks')$where.=' and a.`isks`=0 and b.`state`=1';
|
||||
$arr = m('knowtrais')->getlimit($where, $this->page, 'a.*,b.title,b.state,b.startdt,b.enddt,c.`name`,c.deptname', 'a.id desc', $this->limit, $table); //读取记录
|
||||
|
||||
//格式化数据
|
||||
//$this->statearr = explode(',','<font color=#ff6600>还未开始</font>,<font color=green>进行中</font>,<font color=#888888>已结束</font>');
|
||||
foreach($arr['rows'] as $k=>$rs){
|
||||
$cont = '';
|
||||
if($rs['isks']=='1'){
|
||||
$cont = '分数:'.$rs['fenshu'].'<br>考试时间:'.substr($rs['kssdt'],5,11).'';
|
||||
if(!isempt($rs['ksedt']))$cont.='至'.substr($rs['ksedt'],5,11).'';
|
||||
}
|
||||
|
||||
$sarr = array(
|
||||
'title' => $rs['title'],
|
||||
'optdt' => ''.substr($rs['startdt'],5,11).'至'.substr($rs['enddt'],5,11).'',
|
||||
'id' => $rs['mid'],
|
||||
'modenum' => 'knowtraim',
|
||||
'cont' => $cont
|
||||
);
|
||||
if($rs['isks']=='1'){
|
||||
$sarr['statustext']='已考试';
|
||||
$sarr['statuscolor']='green';
|
||||
$sarr['ishui']='1';
|
||||
}else{
|
||||
$zt = $rs['state'];
|
||||
if($zt=='0'){
|
||||
$sarr['statustext']='未开始';
|
||||
$sarr['statuscolor']='#ff6600';
|
||||
}elseif($zt=='2'){
|
||||
$sarr['statustext']='已结束';
|
||||
$sarr['statuscolor']='#888888';
|
||||
$sarr['ishui']='1';
|
||||
}else{
|
||||
$sarr['statustext']='未考试';
|
||||
$sarr['statuscolor']='red';
|
||||
}
|
||||
}
|
||||
$rows[] = $sarr;
|
||||
}
|
||||
$arr['rows'] = $rows;
|
||||
return $arr;
|
||||
}
|
||||
|
||||
//统计我为考试记录数
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->getwdtotal($this->adminid);
|
||||
$titles = '';
|
||||
return array('stotal'=>$stotal,'titles'=> $titles);
|
||||
}
|
||||
|
||||
private function getwdtotal($uid)
|
||||
{
|
||||
$table = '`[Q]knowtrais` a left join `[Q]knowtraim` b on a.mid=b.id';
|
||||
$stotal = $this->db->rows($table,'a.uid='.$uid.' and a.`isks`=0 and b.`state`=1');
|
||||
return $stotal;
|
||||
}
|
||||
|
||||
//底部菜单显示未考试数
|
||||
protected function agenttotals($uid)
|
||||
{
|
||||
$a = array(
|
||||
'weiks' => $this->getwdtotal($uid)
|
||||
);
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
9
webmain/model/agent/kqdkjlModel.php
Normal file
9
webmain/model/agent/kqdkjlModel.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
//考勤信息下的应用
|
||||
class agent_kqdkjlClassModel extends agentModel
|
||||
{
|
||||
|
||||
protected function agentrows($rows, $rowd, $uid){
|
||||
return $this->agentrows_status($rows, $rowd);
|
||||
}
|
||||
}
|
||||
53
webmain/model/agent/kqtotalModel.php
Normal file
53
webmain/model/agent/kqtotalModel.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* 考勤统计
|
||||
*/
|
||||
class agent_kqtotalClassModel extends agentModel
|
||||
{
|
||||
protected function agentdata($uid, $lx)
|
||||
{
|
||||
$key = $this->rock->post('key');
|
||||
$month = date('Y-m');
|
||||
if($lx=='mylast' || $lx=='downlast')$month = c('date')->adddate($month.'-01','m', -1,'Y-m');
|
||||
$mdts = m('kaoqin');
|
||||
$drows = $rows = array();
|
||||
if(contain($lx,'down') || !isempt($key)){
|
||||
$whre1 = $mdts->admindb->monthuwhere($month);
|
||||
$where = $mdts->admindb->getdowns($uid, 1).$whre1;
|
||||
if(!isempt($key))$where.=$mdts->admindb->getkeywhere($key);
|
||||
$drows = $mdts->admindb->getrows($where, '`id`,`name`,`workdate`,`quitdt`','`sort`');
|
||||
}else{
|
||||
$drows[]= array('id'=>$uid,'name'=>'我');
|
||||
}
|
||||
|
||||
|
||||
foreach($drows as $k=>$rs){
|
||||
$cont = '';
|
||||
|
||||
$rwnk = $this->rock->arrvalue($rs, 'workdate');
|
||||
if(!isempt($rwnk))$cont.='<font color=#888888>入职日期:</font>'.$rwnk.'<br>';
|
||||
|
||||
$rwnk = $this->rock->arrvalue($rs, 'quitdt');
|
||||
if(!isempt($rwnk))$cont.='<font color=#888888>离职日期:</font>'.$rwnk.'<br>';
|
||||
|
||||
$carr = $mdts->alltotal($month, $rs['id']);
|
||||
foreach($carr['fields'] as $k=>$v){
|
||||
$v1 = $this->rock->arrvalue($carr['data'], $v);
|
||||
$u1 = $this->rock->arrvalue($carr['unita'], $v,'次');
|
||||
if(!isempt($v1)){
|
||||
$cont.='<font color=#888888>'.$k.':</font>'.$v1.'('.$u1.')<br>';
|
||||
}
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
'title' => ''.$rs['name'].'['.$month.']统计',
|
||||
'cont' => $cont,
|
||||
'month' => $month,
|
||||
'uid' => $rs['id']
|
||||
);
|
||||
}
|
||||
|
||||
$arr['rows'] = $rows;
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
125
webmain/model/agent/meetModel.php
Normal file
125
webmain/model/agent/meetModel.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
class agent_meetClassModel extends agentModel
|
||||
{
|
||||
|
||||
private $joinwhere='';
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
$this->dtobj = c('date');
|
||||
}
|
||||
|
||||
//今日会议
|
||||
public function getstotal($uid, $dt)
|
||||
{
|
||||
if($this->joinwhere=='')$this->joinwhere = m('admin')->getjoinstr('joinid', $uid);
|
||||
$where = "`status`=1 and `type`=0 and `startdt` like '$dt%' and joinid is not null $this->joinwhere and `state`<2";
|
||||
$sto = m('meet')->rows($where);
|
||||
return $sto;
|
||||
}
|
||||
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->getstotal($this->adminid, $this->rock->date);
|
||||
return array('stotal'=>$stotal,'titles'=>'');
|
||||
}
|
||||
|
||||
protected function agentrows($rows, $rowd, $uid)
|
||||
{
|
||||
$hyarra = $this->flow->hyarra;
|
||||
$hyarrb = $this->flow->hyarrb;
|
||||
if(!in_array($this->event, array('week','today'))){
|
||||
if($rowd)foreach($rowd as $k=>$rs){
|
||||
$nzt = $rs['nzt'];
|
||||
$rows[$k]['statustext'] = $hyarra[$nzt];
|
||||
$rows[$k]['statuscolor'] = $hyarrb[$nzt];
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
protected function agentdata($uid, $lx)
|
||||
{
|
||||
$row = array();
|
||||
$dt = $this->rock->date;
|
||||
if($this->joinwhere=='')$this->joinwhere = m('admin')->getjoinstr('joinid', $uid);
|
||||
//本周
|
||||
if($lx=='week'){
|
||||
$warr = $this->dtobj->getweekarr($dt);
|
||||
foreach($warr as $dts){
|
||||
$rows = $this->getweek($dts, $uid);
|
||||
$row = array_merge($row, $rows);
|
||||
}
|
||||
//今日
|
||||
}else if($lx=='today'){
|
||||
$row = $this->getweek($dt, $uid);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
$arr['rows'] = $row;
|
||||
return $arr;
|
||||
}
|
||||
|
||||
protected function agenttotals($uid)
|
||||
{
|
||||
return array(
|
||||
'today' => $this->getstotal($uid, $this->rock->date)
|
||||
);
|
||||
}
|
||||
|
||||
//数据处理
|
||||
private function gethuiwdata($rows, $dbs)
|
||||
{
|
||||
$row = array();
|
||||
$hyarra = $this->flow->hyarra;
|
||||
$hyarrb = $this->flow->hyarrb;
|
||||
$time = time();
|
||||
foreach($rows as $k=>$rs){
|
||||
$zt = $rs['state'];
|
||||
$nzt = $zt;
|
||||
$stime = strtotime($rs['startdt']);
|
||||
$etime = strtotime($rs['enddt']);
|
||||
if($zt < 2){
|
||||
if($etime<$time){
|
||||
$nzt = 2;
|
||||
}else if($stime>$time){
|
||||
$nzt = 0;
|
||||
}else{
|
||||
$nzt = 1;
|
||||
}
|
||||
}
|
||||
$rows[$k]['statustext'] = $hyarra[$nzt];
|
||||
$rows[$k]['statuscolor'] = $hyarrb[$nzt];
|
||||
$cont = '会议室:'.$rs['hyname'].'';
|
||||
$cont .= '<br>发起人:'.$rs['optname'].'';
|
||||
if(!$this->isempt($rs['joinname']))$cont.= '<br>参会人:'.$rs['joinname'].'';
|
||||
$rows[$k]['cont'] = $cont;
|
||||
if($nzt>1){
|
||||
$rows[$k]['ishui'] = 1;
|
||||
}
|
||||
$rows[$k]['optdt'] = substr($rs['startdt'],11).'至'.substr($rs['enddt'],11);
|
||||
unset($rows[$k]['startdt']);
|
||||
unset($rows[$k]['enddt']);
|
||||
unset($rows[$k]['joinname']);
|
||||
unset($rows[$k]['optname']);
|
||||
unset($rows[$k]['hyname']);
|
||||
|
||||
$row[] = $rows[$k];
|
||||
if($zt != $nzt)$dbs->update('state='.$nzt.'', $rs['id']);
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
//获取今日和本周会议的个人
|
||||
private function getweek($dt, $uid)
|
||||
{
|
||||
$week = $this->dtobj->cnweek($dt);
|
||||
$dbs = m('meet');
|
||||
$rows = $dbs->getrows("`status`=1 and `type`=0 and `startdt` like '$dt%' and joinid is not null $this->joinwhere",'hyname,title,optid,startdt,enddt,state,joinname,optname,id','`startdt` asc');
|
||||
if($rows)$row[] = array(
|
||||
'showtype' => 'line',
|
||||
'title' => ''.$dt.'(周'.$week.')的会议'
|
||||
);
|
||||
return $this->gethuiwdata($rows, $dbs);
|
||||
}
|
||||
}
|
||||
17
webmain/model/agent/newsModel.php
Normal file
17
webmain/model/agent/newsModel.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
新闻资讯
|
||||
*/
|
||||
class agent_newsClassModel extends agentModel
|
||||
{
|
||||
|
||||
|
||||
protected function agentrows($rows, $rowd, $uid){
|
||||
$typearr = array();
|
||||
if($this->loadci==1)$typearr = $this->flow->flowwesearchdata(1);
|
||||
return array(
|
||||
'rows' =>$rows,
|
||||
'typearr' =>$typearr,
|
||||
);
|
||||
}
|
||||
}
|
||||
11
webmain/model/agent/officiaModel.php
Normal file
11
webmain/model/agent/officiaModel.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
//发文单
|
||||
class agent_officiaClassModel extends agentModel
|
||||
{
|
||||
|
||||
//状态替换
|
||||
protected function agentrows($rows, $rowd, $uid){
|
||||
return $this->agentrows_status($rows, $rowd);
|
||||
}
|
||||
|
||||
}
|
||||
11
webmain/model/agent/officibModel.php
Normal file
11
webmain/model/agent/officibModel.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
//收文单
|
||||
class agent_officibClassModel extends agentModel
|
||||
{
|
||||
|
||||
//状态替换
|
||||
protected function agentrows($rows, $rowd, $uid){
|
||||
return $this->agentrows_status($rows, $rowd);
|
||||
}
|
||||
|
||||
}
|
||||
37
webmain/model/agent/officicModel.php
Normal file
37
webmain/model/agent/officicModel.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
//公文查阅
|
||||
class agent_officicClassModel extends agentModel
|
||||
{
|
||||
|
||||
protected $showuface = false; //不显示人员头像
|
||||
|
||||
|
||||
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->getwdtotal($this->adminid);
|
||||
$titles = '';
|
||||
return array('stotal'=>$stotal,'titles'=> $titles);
|
||||
}
|
||||
|
||||
//未读统计
|
||||
private function getwdtotal($uid)
|
||||
{
|
||||
$ydid = m('log')->getread('official', $uid);
|
||||
$where = "id not in($ydid) and `status`=1";
|
||||
$meswh = m('admin')->getjoinstr('receid', $uid, 0, 1);
|
||||
$where .= $meswh;
|
||||
$stotal = m('official')->rows($where);
|
||||
return $stotal;
|
||||
}
|
||||
|
||||
//菜单未读数组
|
||||
protected function agenttotals($uid)
|
||||
{
|
||||
$a = array(
|
||||
'mywcy' => $this->getwdtotal($uid)
|
||||
);
|
||||
return $a;
|
||||
}
|
||||
|
||||
}
|
||||
31
webmain/model/agent/projectModel.php
Normal file
31
webmain/model/agent/projectModel.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
//项目的应用
|
||||
class agent_projectClassModel extends agentModel
|
||||
{
|
||||
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->getwdtotal($this->adminid);
|
||||
$titles = '';
|
||||
return array('stotal'=>$stotal,'titles'=> $titles);
|
||||
}
|
||||
|
||||
private function getwdtotal($uid)
|
||||
{
|
||||
$to = m('flow')->initflow('project')->getflowrows($uid,'wwc', 0);
|
||||
return $to;
|
||||
}
|
||||
|
||||
//显示页面未完成数量
|
||||
protected function agenttotals($uid){
|
||||
return array(
|
||||
'wwc' => $this->getwdtotal($uid)
|
||||
);
|
||||
}
|
||||
|
||||
protected function agentrows($rows, $rowd, $uid){
|
||||
return $this->agentrows_status($rows, $rowd);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
42
webmain/model/agent/receiptModel.php
Normal file
42
webmain/model/agent/receiptModel.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
//回执确认
|
||||
class agent_receiptClassModel extends agentModel
|
||||
{
|
||||
|
||||
protected $showuface = false; //不显示人员头像
|
||||
|
||||
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->getwdtotal($this->adminid);
|
||||
$titles = '';
|
||||
return array('stotal'=>$stotal,'titles'=> $titles);
|
||||
}
|
||||
|
||||
//未读统计
|
||||
private function getwdtotal($uid)
|
||||
{
|
||||
$stotal = m('flow:receipt')->getweitotal($uid);
|
||||
return $stotal;
|
||||
}
|
||||
|
||||
//菜单未读数组
|
||||
protected function agenttotals($uid)
|
||||
{
|
||||
$a = array(
|
||||
'mywei' => $this->getwdtotal($uid)
|
||||
);
|
||||
return $a;
|
||||
}
|
||||
|
||||
protected function agentrows($rows, $rowd, $uid){
|
||||
if($rows){
|
||||
foreach($rowd as $k=>$rs){
|
||||
$rows[$k]['ishui'] = $rs['ishui'];
|
||||
$rows[$k]['modenum'] = $rs['modenumshow'];
|
||||
$rows[$k]['id'] = $rs['mid'];
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
26
webmain/model/agent/scheduleModel.php
Normal file
26
webmain/model/agent/scheduleModel.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
class agent_scheduleClassModel extends agentModel
|
||||
{
|
||||
public function gettotal()
|
||||
{
|
||||
return array('stotal'=>0,'titles'=>'');
|
||||
}
|
||||
|
||||
protected function agentrows($rows, $rowd, $uid)
|
||||
{
|
||||
foreach($rowd as $k=>$rs){
|
||||
if(!isempt($rs['enddt']) && $rs['enddt']<$this->rock->now){
|
||||
$rows[$k]['ishui'] = 1;
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
protected function agentdata($uid, $lx)
|
||||
{
|
||||
//$rows = m('schedule')->getmonthdata($uid);
|
||||
//print_r($rows);
|
||||
if(contain($lx,'month'))$this->event = 'my';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
76
webmain/model/agent/todoModel.php
Normal file
76
webmain/model/agent/todoModel.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* 消息提醒的应用
|
||||
*/
|
||||
class agent_todoClassModel extends agentModel
|
||||
{
|
||||
public function initModel()
|
||||
{
|
||||
$this->settable('todo');
|
||||
}
|
||||
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->getdbtotal($this->adminid);
|
||||
$titles = '';
|
||||
return array('stotal'=>$stotal,'titles'=> $titles);
|
||||
}
|
||||
|
||||
private function getdbtotal($uid)
|
||||
{
|
||||
$optdt = $this->rock->now;
|
||||
$stotal = $this->rows("uid='$uid' and `status`=0 and `tododt`<='$optdt'");
|
||||
return $stotal;
|
||||
}
|
||||
|
||||
protected function agenttotals($uid)
|
||||
{
|
||||
return array(
|
||||
'wdtodo' => $this->getdbtotal($uid)
|
||||
);
|
||||
}
|
||||
|
||||
//数据读取应用
|
||||
protected function agentdata($uid, $lx)
|
||||
{
|
||||
$where = '';
|
||||
if($lx=='wdtodo')$where='and `status`=0';
|
||||
if($lx=='allydu'){
|
||||
$this->update("`status`=1", "uid='$uid' and `status`=0");
|
||||
}
|
||||
$key = $this->rock->post('key');
|
||||
if(!isempt($key))$where.=" and (`title`='$key' or `mess` like '%$key%')"; //关键词搜索
|
||||
|
||||
$arr = $this->getlimit("uid='$uid' $where", $this->page,'*', 'id desc', $this->limit);
|
||||
$rows = $arr['rows'];
|
||||
$darr = array();
|
||||
foreach($rows as $k=>$rs){
|
||||
$statustext = '已读';
|
||||
$statuscolor = '#aaaaaa';
|
||||
if($rs['status']=='0'){
|
||||
$statustext = '未读';
|
||||
$statuscolor = 'red';
|
||||
}
|
||||
|
||||
$cont = $rs['mess'];
|
||||
|
||||
$xiangurl = '';
|
||||
if(!isempt($rs['modenum']) && !isempt($rs['mid']) && $rs['mid']>'0'){
|
||||
$xiangurl = 'task.php?a=x&num='.$rs['modenum'].'&mid='.$rs['mid'].'';
|
||||
}
|
||||
|
||||
$darr[] = array(
|
||||
//'id' => $rs['id'],
|
||||
'optdt' => $rs['optdt'],
|
||||
'title' => $rs['title'],
|
||||
'cont' => $cont,
|
||||
'xiangurl' => $xiangurl,
|
||||
'ishui' => ($rs['status']=='1')?1:0,
|
||||
'statustext'=>$statustext,
|
||||
'statuscolor'=>$statuscolor,
|
||||
);
|
||||
}
|
||||
$arr['rows'] = $darr;
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
16
webmain/model/agent/userModel.php
Normal file
16
webmain/model/agent/userModel.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
通讯录显示用户模块的
|
||||
*/
|
||||
class agent_userClassModel extends agentModel
|
||||
{
|
||||
|
||||
protected function agentrows($rows, $rowd, $uid){
|
||||
foreach($rowd as $k=>$rs){
|
||||
unset($rows[$k]['id']);
|
||||
if($this->agentnum=='vcard')unset($rows[$k]['uid']);//个人通讯录不要头像
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
}
|
||||
9
webmain/model/agent/waichuModel.php
Normal file
9
webmain/model/agent/waichuModel.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
//外出应用
|
||||
class agent_waichuClassModel extends agentModel
|
||||
{
|
||||
//状态替换
|
||||
protected function agentrows($rows, $rowd, $uid){
|
||||
return $this->agentrows_status($rows, $rowd);
|
||||
}
|
||||
}
|
||||
22
webmain/model/agent/wordxieModel.php
Normal file
22
webmain/model/agent/wordxieModel.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
文档协作
|
||||
*/
|
||||
class agent_wordxieClassModel extends agentModel
|
||||
{
|
||||
|
||||
protected function agentrows($rows, $rowd, $uid){
|
||||
foreach($rowd as $k=>$rs){
|
||||
$rows[$k]['fileid'] = $rs['fileid'];
|
||||
if($rs['xiebool']){
|
||||
$rows[$k]['statuscolor'] = 'green';
|
||||
$rows[$k]['statustext'] = '协作';
|
||||
}else{
|
||||
$rows[$k]['statuscolor'] = 'gray';
|
||||
$rows[$k]['statustext'] = '只读';
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
}
|
||||
66
webmain/model/agent/workModel.php
Normal file
66
webmain/model/agent/workModel.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
//任务的应用
|
||||
class agent_workClassModel extends agentModel
|
||||
{
|
||||
|
||||
public function gettotal()
|
||||
{
|
||||
$stotal = $this->getwdtotal($this->adminid);
|
||||
$titles = '';
|
||||
return array('stotal'=>$stotal,'titles'=> $titles);
|
||||
}
|
||||
|
||||
private function getwdtotal($uid)
|
||||
{
|
||||
$to = m('work')->getwwctotals($uid);
|
||||
return $to;
|
||||
}
|
||||
|
||||
protected function agenttotals($uid){
|
||||
return array(
|
||||
'myrw' => $this->getwdtotal($uid)
|
||||
);
|
||||
}
|
||||
|
||||
protected function agentrows($rows, $rowd, $uid){
|
||||
$rows = $this->agentrows_status($rows, $rowd);
|
||||
$projectarr = false;
|
||||
//读取我的项目
|
||||
if($this->loadci==1){
|
||||
$tos = m('flow_set')->rows("`num`='project' and `status`=1");
|
||||
if($tos>0){
|
||||
$where1 = $this->rock->dbinstr('`fuzeid`', $uid);
|
||||
$where2 = m('admin')->getjoinstr('`runuserid`', $uid, 1, 1);
|
||||
$xmrows = m('project')->getall("`status` <>5 and ($where1 or $where2)",'*');
|
||||
if($xmrows){
|
||||
$projectarr = array();
|
||||
foreach($xmrows as $k1=>$rs1){
|
||||
$projectarr[] = array(
|
||||
'id' => $rs1['id'],
|
||||
'name' => '['.$rs1['type'].']'.$rs1['title'].'('.$rs1['progress'].'%)',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return array(
|
||||
'rows' => $rows,
|
||||
'projectarr' => $projectarr
|
||||
);
|
||||
}
|
||||
|
||||
protected function agentrows11($rows, $rowd, $uid)
|
||||
{
|
||||
$statea = $this->flow->statearr;
|
||||
foreach($rowd as $k=>$rs){
|
||||
$state = $rs['state'];
|
||||
if($state==3){
|
||||
$rows[$k]['ishui'] =1;
|
||||
}
|
||||
$ztarr = $statea[$state];
|
||||
$rows[$k]['statustext'] = $ztarr[0];
|
||||
$rows[$k]['statuscolor'] = $ztarr[1];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
30
webmain/model/agent/xinhuModel.php
Normal file
30
webmain/model/agent/xinhuModel.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* 信呼团队应用
|
||||
*/
|
||||
class agent_xinhuClassModel extends agentModel
|
||||
{
|
||||
protected function agentdata($uid, $lx)
|
||||
{
|
||||
$rows[] = array(
|
||||
'title' => '欢迎使用信呼',
|
||||
'cont' => '官网:<a href="'.URLY.'" target="_blank">'.URLY.'</a><br>版本:'.VERSION.'',
|
||||
'statuscolor' => 'green',
|
||||
'statustext' => '官网'
|
||||
);
|
||||
$rows[] = array(
|
||||
'title' => '信呼开源协议',
|
||||
'cont' => '我们是开源PHP系统,可以自己企业单位内部使用,禁止商业销售,欢迎研究学习使用,好的设计你可以借鉴,不好的你可以吐槽,让我们改善。',
|
||||
'statuscolor' => 'green',
|
||||
'statustext' => '官网'
|
||||
);
|
||||
$rows[] = array(
|
||||
'title' => '信呼相关帮助',
|
||||
'cont' => '1、常见使用问题,<a href="'.URLY.'view_cjwt.html" target="_blank">[查看]</a><br>2、使用前必读 ,<a href="'.URLY.'view_bidu.html" target="_blank">[查看]</a><br>3、二次开发前必读 ,<a href="'.URLY.'view_devbd.html" target="_blank">[查看]</a><br>4、更多帮助问题列表 ,<a href="'.URLY.'infor.html" target="_blank">[查看]</a>',
|
||||
'statuscolor' => 'green',
|
||||
'statustext' => '官网'
|
||||
);
|
||||
$arr['rows'] = $rows;
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
104
webmain/model/baseModel.php
Normal file
104
webmain/model/baseModel.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
//基础使用
|
||||
class baseClassModel extends Model
|
||||
{
|
||||
private $usrr = array();
|
||||
|
||||
/**
|
||||
* 获取异步地址
|
||||
*/
|
||||
public function getasynurl($m, $a,$can=array(), $lx=0)
|
||||
{
|
||||
if($lx==0)$runurl = getconfig('localurl', URL);
|
||||
if($lx==1)$runurl = getconfig('anayurl', URL); //使用异步通信地址
|
||||
if($lx==2)$runurl = getconfig('waiurl', URL); //使用外网地址
|
||||
if($lx==3)$runurl = '';
|
||||
$key = getconfig('asynkey');
|
||||
if($key!='')$key = md5(md5($key));
|
||||
$uid = $this->adminid;
|
||||
if($uid==0)$uid = (int)arrvalue($GLOBALS,'adminid','0');
|
||||
if($uid==0)$uid = 1;//必须要有个值
|
||||
$runurl .= 'api.php?m='.$m.'&a='.$a.'&adminid='.$uid.'&asynkey='.$key.'';
|
||||
if(COMPANYNUM)$runurl.='&dwnum='.COMPANYNUM.'';
|
||||
if(is_array($can))foreach($can as $k=>$v)$runurl.='&'.$k.'='.$v.'';
|
||||
return $runurl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统上变量替换
|
||||
* $lx = 0 加'',$lx=1不加
|
||||
*/
|
||||
public function strreplace($str, $uid=0, $lx=0)
|
||||
{
|
||||
if(isempt($str))return '';
|
||||
$date = $this->rock->date;
|
||||
$month = date('Y-m');
|
||||
$str = str_replace('[date]', $date, $str);
|
||||
$str = str_replace('[month]', $month, $str);
|
||||
if(!contain($str,'{') || !contain($str,'}'))return $str; //没有{}变量
|
||||
|
||||
if($uid==0)$uid = $this->adminid;
|
||||
$ckey = 'u'.$uid.'';
|
||||
if(isset($this->usrr[$ckey])){
|
||||
$urs = $this->usrr[$ckey];
|
||||
}else{
|
||||
$urs = $this->db->getone('`[Q]admin`','`id`='.$uid.'');
|
||||
$companyid = arrvalue($urs,'companyid','1');
|
||||
if(ISMORECOM){
|
||||
$comid = arrvalue($urs, 'comid','0');
|
||||
if($comid>'0')$companyid = $comid;
|
||||
}
|
||||
$comrs = $this->db->getone('`[Q]company`','`id`='.$companyid.'');
|
||||
$urs['companyid'] = $companyid;
|
||||
$urs['companyname'] = arrvalue($comrs,'name');
|
||||
$urs['companynum'] = arrvalue($comrs,'num');
|
||||
$this->usrr[$ckey] = $urs;
|
||||
}
|
||||
if(!$urs)$urs= array();
|
||||
$urs['uid'] = $uid;
|
||||
$urs['date'] = $date;
|
||||
$urs['year'] = date('Y');
|
||||
$urs['month'] = $month;
|
||||
$urs['time'] = date('H:i:s');
|
||||
$urs['now'] = $this->rock->now;
|
||||
$urs['admin'] = arrvalue($urs,'name', $this->adminname);
|
||||
$urs['adminname'] = $urs['admin'];
|
||||
$urs['adminid'] = $uid;
|
||||
$urs['deptname'] = arrvalue($urs,'deptname');
|
||||
$urs['workdate'] = arrvalue($urs,'workdate');
|
||||
$urs['ranking'] = arrvalue($urs,'ranking');
|
||||
$urs['ismobile'] = $this->rock->ismobile() ? '1' : '0';
|
||||
$barr = $this->rock->matcharr($str);
|
||||
foreach($barr as $match){
|
||||
$key = $match;
|
||||
if(substr($key,0,4)=='urs.')$key = substr($key,4);
|
||||
if(isset($urs[$key])){
|
||||
$val = $urs[$key];
|
||||
if($lx==0)$val = "'$val'";
|
||||
$str = str_replace('{'.$match.'}', $val, $str);
|
||||
}
|
||||
//是否日期加减{date+1},{second-20}
|
||||
if(contain($match,'+') || contain($match,'-')){
|
||||
$add = 1;
|
||||
if(contain($match,'-'))$add=-1;
|
||||
$strss1 = explode('-', str_replace('+','-', $match));
|
||||
$dats = $strss1[0];
|
||||
$jg = (int)$strss1[1] * $add;;
|
||||
$cval = 'Y-m-d H:i:s';
|
||||
$lxs = 'd';
|
||||
if($dats=='date')$cval = 'Y-m-d';
|
||||
if($dats=='month'){
|
||||
$cval = 'Y-m';
|
||||
$lxs = 'm';
|
||||
}
|
||||
if($dats=='hour')$lxs = 'H';
|
||||
if($dats=='minute')$lxs = 'i';
|
||||
if($dats=='second')$lxs = 's';
|
||||
$val = c('date')->adddate($urs['now'], $lxs, $jg, $cval);
|
||||
if($lx==0)$val = "'$val'";
|
||||
$str = str_replace('{'.$match.'}', $val, $str);
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
135
webmain/model/beifenModel.php
Normal file
135
webmain/model/beifenModel.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
class beifenClassModel extends Model
|
||||
{
|
||||
/**
|
||||
* 备份到upload/data下
|
||||
*/
|
||||
public function start()
|
||||
{
|
||||
$alltabls = $this->db->getalltable();
|
||||
$nobeifne = array(''.PREFIX.'log',''.PREFIX.'logintoken',''.PREFIX.'kqanay',''.PREFIX.'email_cont',''.PREFIX.'dailyfx',''.PREFIX.'todo',''.PREFIX.'city',''.PREFIX.'kqjcmd'); //不备份的表;
|
||||
|
||||
$beidir = ''.UPDIR.'/data/'.date('Y.m.d.H.i.s').'.'.rand(1000,9999).'';
|
||||
foreach($alltabls as $tabs){
|
||||
if(in_array($tabs, $nobeifne))continue;
|
||||
$rows = $this->db->getall('select * from `'.$tabs.'`');
|
||||
$fields = $this->db->gettablefields($tabs);
|
||||
$data = array();
|
||||
$data[$tabs] = array(
|
||||
'fields' => $fields,
|
||||
'data' => $rows
|
||||
);
|
||||
$file = ''.$tabs.'_'.count($fields).'_'.count($rows).'.json';
|
||||
$str = json_encode($data);
|
||||
$bo = $this->rock->createtxt(''.$beidir.'/'.$file.'', $str);
|
||||
if(!$bo){echo '无权限写入:'.$beidir.'';break;return false;}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取备份的数据
|
||||
*/
|
||||
public function getbfdata($file, $path='')
|
||||
{
|
||||
$str = array();
|
||||
if($path=='')$path = ''.ROOT_PATH.'/'.UPDIR.'/data/'.$file.'';
|
||||
if(file_exists($path)){
|
||||
$cont = file_get_contents($path);
|
||||
if(substr($cont, 0, 2) != '{"'){
|
||||
$cont = $this->rock->jm->mcrypt_decrypt($cont);
|
||||
}
|
||||
$str = json_decode($cont, true);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
public function updatefabric($cont, $ylx=0)
|
||||
{
|
||||
$bos = $this->updatefabricfile($cont, $ylx);
|
||||
if(!$bos)return 'dberr:'.$this->db->lasterror();
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
public function updatefabricfile($cont='', $ylx=0)
|
||||
{
|
||||
if($cont=='')return false;
|
||||
$data = json_decode($cont, true);
|
||||
foreach($data as $tabe=>$da){
|
||||
$table = str_replace('xinhu_', PREFIX, $tabe);
|
||||
if($ylx==1)$table = PREFIX.$tabe;
|
||||
$fields = $da['fields'];
|
||||
$nowfiel= $this->getfieldsa($table);
|
||||
$str = '';
|
||||
$sql = '';
|
||||
if(!$nowfiel){
|
||||
$str = '`id` int(11) NOT NULL AUTO_INCREMENT';
|
||||
foreach($fields as $k=>$frs){
|
||||
$fname = $frs['name'];
|
||||
$nstr = $this->getfielstr($frs);
|
||||
if($fname!='id')$str.=','.$nstr.'';
|
||||
}
|
||||
$str .=',PRIMARY KEY (`id`)';
|
||||
$sql = "CREATE TABLE `$table`($str)ENGINE=".getconfig('db_engine','MyISAM')." DEFAULT CHARSET=utf8";
|
||||
if(isset($da['createsql'])){
|
||||
$sql = $da['createsql'];
|
||||
$sql = str_replace('`xinhu_','`'.PREFIX.'', $sql);
|
||||
}
|
||||
}else{
|
||||
foreach($fields as $k=>$frs){
|
||||
$fname = $frs['name'];
|
||||
if($fname=='id')continue;
|
||||
$nstr = $this->getfielstr($frs);
|
||||
if(!isset($nowfiel[$fname])){
|
||||
$str.=',add '.$nstr.'';
|
||||
}else{
|
||||
$ofrs = $nowfiel[$fname]; //系统上字段类型
|
||||
$ostr = $this->getfielstr($ofrs);
|
||||
$lxarr= array('text','mediumtext','bigint');
|
||||
|
||||
//如果自己字段长度大于官网就不更新
|
||||
if($frs['type']==$ofrs['type'] && !isempt($ofrs['lens']) && $ofrs['lens']>$frs['lens']){
|
||||
|
||||
}else if($nstr != $ostr && !in_array($ofrs['type'], $lxarr) ){
|
||||
$str.=',MODIFY '.$nstr.'';
|
||||
}
|
||||
}
|
||||
}
|
||||
if($str!=''){
|
||||
$str = substr($str, 1);
|
||||
$sql = "alter table `$table` $str";
|
||||
}
|
||||
}
|
||||
if($sql!=''){
|
||||
$bo = $this->db->query($sql);
|
||||
if($bo)$this->rock->debugs($sql, 'upgmysql');
|
||||
if(!$bo)return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private function getfieldsa($table)
|
||||
{
|
||||
$nowfiel= $this->db->gettablefields($table);
|
||||
$a = array();
|
||||
foreach($nowfiel as $k=>$rs){
|
||||
$a[$rs['name']] = $rs;
|
||||
}
|
||||
return $a;
|
||||
}
|
||||
private function getfielstr($rs)
|
||||
{
|
||||
$str = '`'.$rs['name'].'` '.$rs['types'].'';
|
||||
$dev = $rs['dev'];
|
||||
$isnull = $rs['isnull'];
|
||||
if($isnull=='NO')$str.=' NOT NULL';
|
||||
if(is_null($dev)){
|
||||
if($isnull != 'NO')$str.=' DEFAULT NULL';
|
||||
}else{
|
||||
$str.=" DEFAULT '$dev'";
|
||||
}
|
||||
if(!isempt($rs['explain']))$str.=" COMMENT '".$rs['explain']."'";
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
26
webmain/model/bookModel.php
Normal file
26
webmain/model/bookModel.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
class bookClassModel extends Model
|
||||
{
|
||||
/**
|
||||
* 读取当前时间借阅数量
|
||||
*/
|
||||
public function getborrowshu($bookid, $dt='', $sid=0)
|
||||
{
|
||||
if($dt=='')$dt=$this->rock->date;
|
||||
$where = '`bookid`='.$bookid.' and `status` in(0,1) and `isgh`=0 and `id`<>'.$sid.'';
|
||||
//$where.= " and `jydt`<='$dt'";
|
||||
$tos = $this->db->rows('[Q]bookborrow', $where);
|
||||
return floatval($tos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取数可借阅数量
|
||||
*/
|
||||
public function getjieshu($bookid, $dt='', $sid=0)
|
||||
{
|
||||
$yij = $this->getborrowshu($bookid, $dt, $sid);
|
||||
$tos = floatval($this->getmou('shul', $bookid));
|
||||
|
||||
return $tos-$yij;
|
||||
}
|
||||
}
|
||||
121
webmain/model/cityModel.php
Normal file
121
webmain/model/cityModel.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
//城市
|
||||
class cityClassModel extends Model
|
||||
{
|
||||
//获取城市路径
|
||||
public function getpath($id)
|
||||
{
|
||||
$this->pathss = array();
|
||||
$this->getpaths($id);
|
||||
return $this->pathss;
|
||||
}
|
||||
private function getpaths($id)
|
||||
{
|
||||
$rs = $this->getone($id);
|
||||
if($rs && $rs['pid']!=$id){
|
||||
$this->getpaths($rs['pid']);
|
||||
$this->pathss[] = $rs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
*/
|
||||
public function daorudata()
|
||||
{
|
||||
$barr = c('xinhuapi')->getdata('base','city');
|
||||
if(!$barr['success'])return returnerror($barr['msg']);
|
||||
$data = $barr['data'];
|
||||
$shul = 0;
|
||||
foreach($data as $k=>$rs){
|
||||
$id = $rs['id'];
|
||||
if($this->rows($id)==0){
|
||||
$shul++;
|
||||
$this->insert($rs);
|
||||
}
|
||||
}
|
||||
return returnsuccess('成功导入'.$shul.'条数据');
|
||||
}
|
||||
|
||||
/**
|
||||
* 籍贯/城市数据
|
||||
*/
|
||||
public function citydata()
|
||||
{
|
||||
$rows = $this->db->getall('SELECT a.name,b.name as name1 FROM `[Q]city` a left join `[Q]city` b on a.`pid`=b.`id` where a.`type` in(2)');
|
||||
$barr = array();
|
||||
foreach($rows as $k=>$rs){
|
||||
$name = $rs['name'];
|
||||
if($name!=$rs['name1'])$name=$rs['name1'].$name;
|
||||
$barr[] = array(
|
||||
'name' => $name,
|
||||
'cityname' => $rs['name'],
|
||||
'shengname' => $rs['name1'],
|
||||
);
|
||||
}
|
||||
return $barr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 省份数据
|
||||
*/
|
||||
public function shengdata()
|
||||
{
|
||||
$rows = $this->db->getall('SELECT `name` FROM `[Q]city` where `pid`=1 order by `sort`');
|
||||
$barr = array();
|
||||
foreach($rows as $k=>$rs){
|
||||
$name = $rs['name'];
|
||||
$barr[] = array(
|
||||
'name' => $name
|
||||
);
|
||||
}
|
||||
return $barr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部城市数据,3级
|
||||
*/
|
||||
public function alldata()
|
||||
{
|
||||
$chche = c('cache');
|
||||
$cdata = $chche->get('cityalldata');
|
||||
if(!$cdata){
|
||||
$this->drowsa = $this->getall('1=1','*','`sort`');
|
||||
$this->datass = array();
|
||||
$this->alldatas($this->drowsa, '1', 0,'');
|
||||
|
||||
$chche->set('cityalldata', $this->datass);
|
||||
return $this->datass;
|
||||
}else{
|
||||
return $cdata;
|
||||
}
|
||||
}
|
||||
private function alldatas($rows, $pid, $xu, $sub, $sheng='', $city='')
|
||||
{
|
||||
$keya = array('shengname','cityname','xianname');
|
||||
$zxij = 0;
|
||||
foreach($rows as $k=>$rs){
|
||||
if($rs['pid']==$pid){
|
||||
$zxij++;
|
||||
$sar = array(
|
||||
'name' => $sub.$rs['name'],
|
||||
'value' => $rs['name'],
|
||||
'padding'=> 30*$xu,
|
||||
'shengname' => $sheng,
|
||||
'cityname' => $city,
|
||||
'xianname' => '',
|
||||
);
|
||||
$keysas = $keya[$xu];
|
||||
$sar[$keysas] = $rs['name'];
|
||||
$this->datass[] = $sar;
|
||||
|
||||
unset($this->drowsa[$k]);
|
||||
if($xu==0)$sheng = $rs['name'];
|
||||
if($xu==1)$city = $rs['name'];
|
||||
$xiji = $this->alldatas($this->drowsa, $rs['id'], $xu+1, $sub.$rs['name'], $sheng, $city);
|
||||
}
|
||||
}
|
||||
return $zxij;
|
||||
}
|
||||
}
|
||||
68
webmain/model/companyModel.php
Normal file
68
webmain/model/companyModel.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
//公司单位
|
||||
class companyClassModel extends Model
|
||||
{
|
||||
public function getselectdata($lx=0)
|
||||
{
|
||||
$where= 'id>0';
|
||||
if(ISMORECOM && $this->adminid>1){
|
||||
$cinfo = m('admin')->getcompanyinfo($this->adminid);
|
||||
$allid = join(',',$cinfo['companyallid']);
|
||||
$where = 'id in('.$allid.')';
|
||||
}
|
||||
$rows = $this->getall($where,'`id`,name,pid','`sort`');
|
||||
$barr = array();
|
||||
if($lx==0)$barr[] = array(
|
||||
'value' => '0',
|
||||
'name' => '最顶级',
|
||||
);
|
||||
$this->getselectdatas($rows, $barr, '0', 0);
|
||||
return $barr;
|
||||
}
|
||||
private function getselectdatas($rows,&$barr, $pid='0', $level=0)
|
||||
{
|
||||
foreach($rows as $k=>$rs){
|
||||
if($rs['pid']==$pid){
|
||||
$str = '';
|
||||
for($i=0;$i<$level;$i++)$str.=' ';
|
||||
if($str!='')$str.='├';
|
||||
$name = ''.$str.''.$rs['name'].'';
|
||||
$barr[] = array(
|
||||
'name' => $name,
|
||||
'value' => $rs['id'],
|
||||
);
|
||||
$this->getselectdatas($rows, $barr, $rs['id'], $level+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//树形结构
|
||||
public function gettreedata($rows, &$barr, $pid='0', $level=1)
|
||||
{
|
||||
foreach($rows as $k=>$rs){
|
||||
if($rs['pid']==$pid){
|
||||
$rs['level'] = $level;
|
||||
$rs['stotal'] = $this->gettreetotal($rows, $rs['id']);
|
||||
|
||||
$barr[] = $rs;
|
||||
$this->gettreedata($rows, $barr, $rs['id'], $level+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
public function gettreetotal($rows, $pid)
|
||||
{
|
||||
$stotal = 0;
|
||||
foreach($rows as $k=>$rs){
|
||||
if($rs['pid']==$pid){
|
||||
$stotal++;
|
||||
}
|
||||
}
|
||||
return $stotal;
|
||||
}
|
||||
|
||||
//公司名称修改了,对应数据更新
|
||||
public function updatecompany($id, $name)
|
||||
{
|
||||
m('userract')->update("`company`='$name'","`companyid`='$id'");//员工合同
|
||||
}
|
||||
}
|
||||
267
webmain/model/crmModel.php
Normal file
267
webmain/model/crmModel.php
Normal file
@@ -0,0 +1,267 @@
|
||||
<?php
|
||||
class crmClassModel extends Model
|
||||
{
|
||||
public function initModel()
|
||||
{
|
||||
$this->settable('customer');
|
||||
}
|
||||
|
||||
//读取我的客户和共享给我的
|
||||
public function getmycust($uid=0, $id=0)
|
||||
{
|
||||
if(isempt($id))$id = 0;
|
||||
if($uid==0)$uid=$this->adminid;
|
||||
$s = $this->rock->dbinstr('shateid', $uid);
|
||||
$rows = $this->getrows("`status`=1 and ((`uid`='$uid') or (`id`=$id) or (".$s."))",'id as value,name,id,unitname as subname','`optdt` desc');
|
||||
return $rows;
|
||||
}
|
||||
|
||||
//读取所有客户
|
||||
public function custdata()
|
||||
{
|
||||
$where = m('admin')->getcompanywhere(3);
|
||||
$rows = $this->getrows("`status`=1 ".$where."",'id as value,name,id,unitname as subname','`optdt` desc');
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
||||
//读取我的销售机会
|
||||
public function getmysale($uid, $id=0)
|
||||
{
|
||||
$where = '`uid`='.$uid.' and `state` in(0,1) and (`htid`=0 or `htid`='.$id.')';
|
||||
$rows = m('custsale')->getrows($where, 'id,custid,custname,money,laiyuan');
|
||||
return $rows;
|
||||
}
|
||||
|
||||
//读取我的合同
|
||||
public function getmyract($uid, $id=0, $type=2)
|
||||
{
|
||||
$where = '';
|
||||
if($type==0 || $type==1)$where='and `type`='.$type.'';
|
||||
$where = '`uid`='.$uid.' '.$where.' and (`isover`=0 or `id`='.$id.')';
|
||||
$rows = m('custract')->getrows($where, 'id,custid,custname,money,num');
|
||||
return $rows;
|
||||
}
|
||||
|
||||
//更新合同状态
|
||||
public function ractmoney($htid)
|
||||
{
|
||||
if(isempt($htid))return false;
|
||||
if(!is_array($htid)){
|
||||
$ors = $this->db->getone('[Q]custract','id='.$htid.'','money,moneys,ispay,id,isover');
|
||||
}else{
|
||||
$ors = $htid;
|
||||
}
|
||||
if(!$ors)return false;
|
||||
$zmoney = $ors['money']; $moneys = $ors['moneys'];
|
||||
$oispay = $ors['ispay'];
|
||||
$htid = $ors['id'];
|
||||
$money = $this->db->getmou('[Q]custfina','sum(money)','htid='.$htid.' and `ispay`=1');
|
||||
$moneyy = $this->getmoneys($htid); //已创建收付款单金额
|
||||
$symon = $zmoney - $money;
|
||||
$ispay = 0;
|
||||
$isover = 0;
|
||||
if($symon<=0){
|
||||
$ispay = 1;
|
||||
}else if($money>0){
|
||||
$ispay = 2;
|
||||
}
|
||||
if($moneyy>=$zmoney)$isover = 1;
|
||||
if($ispay != $oispay || $symon!= $moneys || $isover != $ors['isover']){
|
||||
$this->db->update('[Q]custract','`ispay`='.$ispay.',`moneys`='.$symon.',`isover`='.$isover.'', $htid);
|
||||
}
|
||||
return array($ispay, $symon);
|
||||
}
|
||||
|
||||
public function getmoneys($htid, $id=0)
|
||||
{
|
||||
$moneys = floatval($this->db->getmou('[Q]custfina','sum(money)','`htid`='.$htid.' and `id`<>'.$id.''));
|
||||
return $moneys;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 对应人统计金额
|
||||
*/
|
||||
public function moneytotal($uid, $month)
|
||||
{
|
||||
$uid = (int)$uid;
|
||||
$sql = "SELECT uid,type,ispay,sum(money)money,count(1)stotal FROM `[Q]custfina` where `uid`='$uid' and `dt` like '$month%' GROUP BY type,ispay";
|
||||
$farr = explode(',', 'shou_moneyd,shou_moneyz,shou_moneys,shou_moneyn,shou_shu,fu_moneyd,fu_moneyz,fu_moneys,fu_moneyn,fu_shu');
|
||||
foreach($farr as $f)$$f= 0;
|
||||
$rows = $this->db->getall($sql);
|
||||
foreach($rows as $k=>$rs){
|
||||
$type = $rs['type']; $ispay = $rs['ispay'];
|
||||
$money = floatval($rs['money']);
|
||||
$stotal = floatval($rs['stotal']);
|
||||
if($type==0){
|
||||
if($ispay==1){
|
||||
$shou_moneys += $money;
|
||||
}else{
|
||||
$shou_moneyd += $money;
|
||||
}
|
||||
$shou_shu += $stotal;
|
||||
$shou_moneyz += $money;
|
||||
}else{
|
||||
if($ispay==1){
|
||||
$fu_moneys += $money;
|
||||
}else{
|
||||
$fu_moneyd += $money;
|
||||
}
|
||||
$fu_shu += $stotal;
|
||||
$fu_moneyz += $money;
|
||||
}
|
||||
}
|
||||
//当月已收付
|
||||
$sql = "SELECT type,sum(money)money FROM `[Q]custfina` where `uid`='$uid' and `ispay`=1 and `paydt` like '$month%' GROUP BY type";
|
||||
$rows = $this->db->getall($sql);
|
||||
foreach($rows as $k=>$rs){
|
||||
if($rs['type']==0)$shou_moneyn = $rs['money']+0;
|
||||
if($rs['type']==1)$fu_moneyn = $rs['money']+0;
|
||||
}
|
||||
$arr = array();
|
||||
foreach($farr as $f)$arr[$f] = $$f;
|
||||
return $arr;
|
||||
}
|
||||
|
||||
//客户转移
|
||||
public function movetouser($uid, $sid, $toid)
|
||||
{
|
||||
$rows = $this->getrows("`id` in($sid)",'id,uid,name');
|
||||
$toname = m('admin')->getmou('name',"`id`='$toid'");
|
||||
if(isempt($toname))return false;
|
||||
|
||||
foreach($rows as $k=>$rs){
|
||||
$id = $rs['id'];
|
||||
$uarr = array();
|
||||
$uarr['uid'] = $toid;
|
||||
$uarr['optname']= $toname;
|
||||
$nowid = (int)$rs['uid'];
|
||||
if($nowid==0)$nowid = $uid;
|
||||
|
||||
$this->update(array('uid'=>$toid,'suoname'=>$toname), $id);
|
||||
|
||||
m('custract')->update($uarr, "`uid`='$nowid' and `custid`='$id'");
|
||||
m('custsale')->update($uarr, "`uid`='$nowid' and `custid`='$id'"); //销售机会
|
||||
m('goodm')->update($uarr, "`uid`='$nowid' and `custid`='$id' and `type`=2"); //销售的
|
||||
m('custplan')->update($uarr, "`uid`='$nowid' and `custid`='$id'"); //跟进计划
|
||||
|
||||
$uarr['ismove']=1;
|
||||
m('custfina')->update($uarr, "`uid`='$nowid' and `custid`='$id'");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//客户统计
|
||||
public function custtotal($ids='')
|
||||
{
|
||||
$wher = '';
|
||||
$whe2 = '';
|
||||
$ustr = '`moneyz`=0,`moneyd`=0,`htshu`=0';
|
||||
if($ids!=''){
|
||||
$wher=' and `custid` in('.$ids.')';
|
||||
$whe2=' and a.`id` in('.$ids.')';
|
||||
$this->update($ustr,'id in('.$ids.')');
|
||||
}else{
|
||||
$this->update($ustr,'id>0');
|
||||
}
|
||||
$rows = $this->db->getall('SELECT custid,sum(money)as moneys,ispay FROM `[Q]custfina` where `type`=0 '.$wher.' GROUP BY custid,ispay');
|
||||
$arr = array();
|
||||
foreach($rows as $k=>$rs){
|
||||
$custid = $rs['custid'];
|
||||
if(!isset($arr[$custid]))$arr[$custid] = array(0,0,0);
|
||||
$arr[$custid][0]+=$rs['moneys'];
|
||||
if($rs['ispay']==0)$arr[$custid][1]+=$rs['moneys'];
|
||||
}
|
||||
foreach($arr as $id=>$rs){
|
||||
$uarr['moneyz'] = $rs[0];
|
||||
$uarr['moneyd'] = $rs[1];
|
||||
$this->update($uarr, $id);
|
||||
}
|
||||
$rows = $this->db->getall('SELECT custid,count(1)htshu FROM `[Q]custract` where id>0 '.$wher.' GROUP BY custid');
|
||||
foreach($rows as $k=>$rs){
|
||||
$custid = $rs['custid'];
|
||||
$this->update('htshu='.$rs['htshu'].'', $custid);
|
||||
}
|
||||
$rows= $this->db->getall('select b.name,a.id from `[Q]customer` a left join `[Q]admin` b on a.`uid`=b.`id` where a.`uid`>0 '.$whe2.' and (a.`suoname`<>b.`name` or a.`suoname` is null)');
|
||||
foreach($rows as $k=>$rs){
|
||||
$this->update("`suoname`='".$rs['name']."'", $rs['id']);
|
||||
}
|
||||
$this->update('`suoname`=null','`uid`=0');
|
||||
}
|
||||
|
||||
//合同状态金额更新
|
||||
public function custractupzt($htid='')
|
||||
{
|
||||
$where1= $where2= '';
|
||||
if(!isempt($htid)){
|
||||
$where1="and `htid` in($htid)";
|
||||
$where2="and `id` in($htid)";
|
||||
}
|
||||
$this->db->update('[Q]custract','`ispay`=0,`isover`=0,`moneys`=money','`id`>0 '.$where2.'');
|
||||
|
||||
$rows = $this->db->getall('SELECT `htid` FROM `[Q]custfina` where `htid`>0 '.$where1.' GROUP BY htid');
|
||||
foreach($rows as $k=>$rs){
|
||||
$htid = $rs['htid'];
|
||||
$this->ractmoney($htid);
|
||||
}
|
||||
|
||||
//更新收付款单
|
||||
$rows = $this->db->getall('SELECT a.id,a.htid,a.htnum,b.num FROM `[Q]custfina` a left join `[Q]custract` b on a.htid=b.id where a.htid>0 and a.htnum<>b.num ');
|
||||
foreach($rows as $k=>$rs){
|
||||
$htid = $rs['htid'];
|
||||
if(isempt($rs['num']))$htid = 0;
|
||||
$this->db->record('[Q]custfina', array(
|
||||
'htid' => $htid,
|
||||
'htnum' => $rs['num'],
|
||||
), $rs['id']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 跟进名称读取客户档案
|
||||
*/
|
||||
public function getcustomer($name)
|
||||
{
|
||||
if(isempt($name))return false;
|
||||
$rs = $this->getone("(`name`='$name' or `unitname`='$name')");
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 销售单是收款状态
|
||||
*/
|
||||
public function xiaozhuantai($rs, $lx=0, $csid=0)
|
||||
{
|
||||
$str = '';
|
||||
$wshou1 = 0;
|
||||
if($rs['status']=='5')return ($lx==0)?'作废了':0;
|
||||
|
||||
if($rs['custractid']=='0'){
|
||||
$finrows = $this->db->getall('select * from `[Q]custfina` where `htid`=-'.$rs['id'].' and `id`<>'.$csid.'');
|
||||
$shou = 0;
|
||||
$shou1 = 0;//已创建金额
|
||||
$ispay = '0';
|
||||
foreach($finrows as $k1=>$rs1){
|
||||
if($rs1['ispay']=='1')$shou+=floatval($rs1['money']);
|
||||
$shou1+=floatval($rs1['money']);
|
||||
}
|
||||
$wshou = floatval($rs['money'])-$shou;
|
||||
$wshou1 = floatval($rs['money'])-$shou1;
|
||||
if($wshou<0)$wshou = 0;
|
||||
if($wshou1<=0){
|
||||
$wshou1 = 0;//未创建
|
||||
$ispay = '1';
|
||||
}
|
||||
if($wshou==0){
|
||||
$str = '<font color=green>已全部收款</font>';
|
||||
}else{
|
||||
$str = '待收<font color=#ff6600>'.$wshou.'</font>';
|
||||
}
|
||||
if($ispay!=$rs['ispay'])$this->db->update('[Q]goodm','`ispay`='.$ispay.'', '`id`='.$rs['id'].'');
|
||||
}
|
||||
if($lx==1)return $wshou1;
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
167
webmain/model/deptModel.php
Normal file
167
webmain/model/deptModel.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
class deptClassModel extends Model
|
||||
{
|
||||
/**
|
||||
* $uarr 相应人员才能查看对应部门数据
|
||||
*/
|
||||
public function getdata($uarr=array())
|
||||
{
|
||||
$darr = $dtotal =array();
|
||||
$gids = '0';
|
||||
$dbs = m('admin');
|
||||
//要权限判断
|
||||
if(is_array($uarr)){
|
||||
$did = '0';
|
||||
if($uarr)foreach($uarr as $k=>$rs){
|
||||
$dpath = str_replace(array('[',']'), array('',''), $rs['deptpath']);
|
||||
if(!isempt($dpath)){
|
||||
$dpatha = explode(',', $dpath);
|
||||
foreach($dpatha as $dpatha1){
|
||||
if(isempt($dpatha1))continue;
|
||||
$darr[$dpatha1]=$dpatha1;
|
||||
if(!isset($dtotal[$dpatha1]))$dtotal[$dpatha1]=0;
|
||||
$dtotal[$dpatha1]++;
|
||||
}
|
||||
}
|
||||
if(!isempt(arrvalue($rs,'groupname')))$gids.=','.$rs['groupname'].'';
|
||||
}
|
||||
foreach($darr as $k1=>$v1)$did.=','.$k1.'';
|
||||
$where= 'id in('.$did.')';
|
||||
|
||||
if(isempt($this->rock->get('changerange'))){
|
||||
if((int)$dbs->getmou('type', $this->adminid)==1){
|
||||
$where = '1=1'; //管理员可看全部
|
||||
}else{
|
||||
$where1= m('view')->viewwhere('dept', $this->adminid, 'id');
|
||||
if(contain($where1,'1=1')){
|
||||
$where = '1=1'; //全部
|
||||
}else{
|
||||
$where = '`id`>0 and ((1 '.$where1.') or (id in('.$did.')))';
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$where = '1=1';
|
||||
}
|
||||
$this->firstpid = 0;
|
||||
|
||||
//多单位
|
||||
if(ISMORECOM){
|
||||
$sysalluview = ','.m('option')->getval('sysalluview','0').',1,';
|
||||
if(!contain($sysalluview,','.$this->adminid.',')){
|
||||
$comid = $dbs->getcompanyid();
|
||||
$where.=' and `companyid` in(0,'.$comid.') and `id`>1';
|
||||
$this->firstpid = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$rows = $this->getall($where,'`id`,`name`,`pid`,`sort`','`pid`,`sort`');
|
||||
if(is_array($uarr))foreach($rows as $k=>$rs){
|
||||
//$stotal = $dbs->rows("`status`=1 and instr(`deptpath`,'[".$rs['id']."]')>0");
|
||||
$stotal = 0;
|
||||
$rows[$k]['stotal'] = $stotal; //对应部门下有多少人
|
||||
$rows[$k]['ntotal'] = $this->rock->arrvalue($dtotal, $rs['id'], '0');
|
||||
}
|
||||
$this->groupids = $gids;
|
||||
$this->temparaa = array();
|
||||
$this->getshowdeptarr($rows, $this->firstpid, 1);
|
||||
return $this->temparaa;
|
||||
}
|
||||
|
||||
private function getshowdeptarr($rows, $pid, $level)
|
||||
{
|
||||
foreach($rows as $k=>$rs){
|
||||
if($pid>=0){
|
||||
if($rs['pid']==$pid){
|
||||
$rs['level'] = $level;
|
||||
$this->temparaa[] = $rs;
|
||||
$this->getshowdeptarr($rows, $rs['id'],$level+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getdeptrows($ids)
|
||||
{
|
||||
if(isempt($ids))return array();
|
||||
$rows = $this->getall("`id` in($ids)",'`id`,`name`,`pid`,`sort`','`pid`,`sort`');
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门和人员数据
|
||||
* $lx=0 通讯录,1选择人员
|
||||
*/
|
||||
public function getdeptuserdata($lx=0)
|
||||
{
|
||||
$changerange= $this->rock->get('changerange');
|
||||
$admindb = m('admin');
|
||||
$userarr = $admindb->getuser($lx);
|
||||
//根据禁看权限
|
||||
$flow = m('flow')->initflow('user');
|
||||
$userarr = $flow->viewjinfields($userarr);
|
||||
|
||||
$deptarr = $this->getdata($userarr);
|
||||
$where1 = '';
|
||||
if(ISMORECOM && $this->adminid>1)$where1=' and `companyid` in('.$admindb->getcompanyid().')';
|
||||
$grouparr = m('group')->getall('id >0'.$where1.'','id,name','`sort`');
|
||||
$garr = array();
|
||||
|
||||
foreach($grouparr as $k=>$rs){
|
||||
if(!isempt($changerange)){
|
||||
if(!contain(','.$changerange.',',',g'.$rs['id'].','))continue;
|
||||
}
|
||||
$uids = $admindb->getgrouptouid($rs['id']);
|
||||
$usershu = 0;
|
||||
if($uids!='')$usershu = count(explode(',', $uids));
|
||||
$rs['usershu'] = $usershu;
|
||||
$garr[] = $rs;
|
||||
}
|
||||
|
||||
return array(
|
||||
'uarr' => $userarr,
|
||||
'darr' => $deptarr,
|
||||
'garr' => $garr,
|
||||
);
|
||||
}
|
||||
|
||||
//获取某个人对应部门Id
|
||||
public function getudept($uid)
|
||||
{
|
||||
$urs = $this->db->getone('[Q]admin', "`id`='$uid'",'deptid,deptpath');
|
||||
$deptid = arrvalue($urs,'deptid','0');
|
||||
$drs = $this->getone('`id`='.$deptid.'');
|
||||
|
||||
if(!$drs)$drs = array('name'=>'','id'=>0,'num'=>'');
|
||||
$nums = $drs['num'];
|
||||
if(isempt($nums))$nums = $drs['id'];
|
||||
$drs['nums'] = $nums;
|
||||
return $drs;
|
||||
}
|
||||
|
||||
//人员在线离线更新
|
||||
public function online($lx)
|
||||
{
|
||||
$ustr = "online=".$lx.",`lastonline`='".$this->rock->now."'";
|
||||
$this->db->update('[Q]admin', $ustr,'`id`='.$this->adminid.'');
|
||||
if($lx==1)m('login')->uplastdt('pc', $this->rock->session('admintoken'));
|
||||
}
|
||||
|
||||
|
||||
public function getheadman($did)
|
||||
{
|
||||
$rs = $this->getone($did);
|
||||
$headid = '';
|
||||
$headids = '';
|
||||
if($rs){
|
||||
$headid = $rs['headid'];
|
||||
$headids = $rs['headman'];
|
||||
if(isempt($headid) && $rs['pid']>0){
|
||||
$sars= $this->getheadman($rs['pid']);
|
||||
$headid = $sars[0];
|
||||
$headids = $sars[1];
|
||||
}
|
||||
}
|
||||
return array($headid, $headids);
|
||||
}
|
||||
}
|
||||
110
webmain/model/editModel.php
Normal file
110
webmain/model/editModel.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
修改记录
|
||||
*/
|
||||
class editClassModel extends Model{
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
$this->settable('editrecord');
|
||||
}
|
||||
|
||||
public $editarr = array();
|
||||
|
||||
/**
|
||||
* 获取修改记录
|
||||
* $num 对应模块编号
|
||||
* $id id值
|
||||
* $oners 旧数组
|
||||
* $newrs 新数组
|
||||
* return string
|
||||
*/
|
||||
public function recordstr($farr,$table, $id, $oners, $newrs, $glx=1)
|
||||
{
|
||||
$str = '';
|
||||
if(!$farr || !$oners)return $str;
|
||||
$this->editarr = array();
|
||||
$farr = $this->getfield($farr);
|
||||
$str = $this->editcont($farr, $oners, $newrs);
|
||||
if($glx == 1 && $str != ''){
|
||||
$str = '['.$this->adminname.']('.$this->rock->now.')修改:'.$str.'';
|
||||
}
|
||||
if($glx == 2){
|
||||
$this->addrecord($table, $id);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function recordsave($farr,$table, $id, $oners, $newrs)
|
||||
{
|
||||
$str = $this->editcont($farr, $oners, $newrs);
|
||||
$this->addrecord($table, $id);
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function editcont($farr, $oners, $narr)
|
||||
{
|
||||
$str = '';
|
||||
$this->editarr = array();
|
||||
if($oners){
|
||||
foreach($narr as $k=>$v){
|
||||
if(!isset($farr[$k]))continue;
|
||||
$fa = $farr[$k];
|
||||
$nv = $v;
|
||||
$ov = '';
|
||||
if(isset($oners[$k]))$ov = $oners[$k];
|
||||
if($nv != $ov){
|
||||
$sel = array();
|
||||
if(isset($fa['selarr']))$sel = $fa['selarr'];
|
||||
if(isset($sel[$ov]))$ov = $sel[$ov];
|
||||
if(isset($sel[$nv]))$nv = $sel[$nv];
|
||||
$str .= ''.$fa['name'].':'.$ov.'→'.$nv.';';
|
||||
$this->editarr[] = array(
|
||||
'fieldsname' => $fa['name'],
|
||||
'oldval' => $ov,
|
||||
'newval' => $nv
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function addrecord($table, $id)
|
||||
{
|
||||
$editci = (int)$this->getmou('editci', "`table`='$table' and `mid`='$id'")+1;
|
||||
foreach($this->editarr as $k=>$rs){
|
||||
$rs['optid'] = $this->adminid;
|
||||
$rs['optname'] = $this->adminname;
|
||||
$rs['optdt'] = $this->rock->now;
|
||||
$rs['table'] = $table;
|
||||
$rs['mid'] = $id;
|
||||
$rs['editci'] = $editci;
|
||||
$this->insert($rs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
获取对应表上字段信息
|
||||
$glx 0基本字段,1流程上
|
||||
return {字段名:对应信息}
|
||||
*/
|
||||
public function getfield($fieldsarr)
|
||||
{
|
||||
$farrs = array();
|
||||
foreach($fieldsarr as $k=>$rs){
|
||||
$fid = $rs['fields'];
|
||||
if(substr($fid, 0, 5)=='temp_')continue;
|
||||
$farrs[$fid] = array('name' => $rs['name']);
|
||||
if(substr($rs['fieldstype'],0,6)=='change'){
|
||||
if(!$this->isempt($rs['data'])){
|
||||
$fid = $rs['data'];
|
||||
if(isset($farrs[$fid]))continue;
|
||||
$farrs[$fid] = array('name' => $rs['name'].'id');
|
||||
}
|
||||
}
|
||||
}
|
||||
return $farrs;
|
||||
}
|
||||
|
||||
}
|
||||
287
webmain/model/emailModel.php
Normal file
287
webmain/model/emailModel.php
Normal file
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
class emailClassModel extends Model
|
||||
{
|
||||
|
||||
private $errorinfo = '';
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
$this->settable('email_cog');
|
||||
}
|
||||
/**
|
||||
* 系统邮件发送邮件
|
||||
* $to_uid 发送给。。。
|
||||
* $rows 内容
|
||||
*/
|
||||
public function sendmail($title, $body, $to_uid, $rows=array(), $zjsend=0, $oparm=array())
|
||||
{
|
||||
if(!function_exists('socket_get_status') || !function_exists('fsockopen'))return '没有开启socket扩展无法使用';
|
||||
if(!function_exists('openssl_sign'))return '没有开启openssl扩展无法使用';
|
||||
|
||||
$setrs = m('option')->getpidarr(-1);
|
||||
if(!$setrs)return '未设置发送邮件';
|
||||
|
||||
$serversmtp = $this->rock->arrvalue($setrs, 'email_sendhost');
|
||||
$emailuser = $this->rock->arrvalue($setrs, 'email_sysuser');
|
||||
$emailname = $this->rock->arrvalue($setrs, 'email_sysname');
|
||||
$emailpass = $this->rock->arrvalue($setrs, 'email_syspass');
|
||||
$serverport = $this->rock->arrvalue($setrs, 'email_sendport');
|
||||
$emailsecure = $this->rock->arrvalue($setrs, 'email_sendsecure');
|
||||
|
||||
if(isempt($serversmtp) || isempt($serverport) || isempt($emailuser)|| isempt($emailpass))return '未设置发送帐号';
|
||||
|
||||
$to_em = $to_mn = $to_id = '';
|
||||
|
||||
if(is_array($to_uid)){
|
||||
$to_id = arrvalue($to_uid,'receid','0');
|
||||
$to_em = arrvalue($to_uid,'receemail');
|
||||
$to_mn = arrvalue($to_uid,'recename');
|
||||
}else{
|
||||
$urs = $this->db->getall("select `email`,`name`,`id` from `[Q]admin` where `id` in($to_uid) and `email` is not null and `status`=1 order by `sort`");
|
||||
foreach($urs as $k=>$rs){
|
||||
$to_em.=','.$rs['email'];
|
||||
$to_mn.=','.$rs['name'];
|
||||
$to_id.=','.$rs['id'];
|
||||
}
|
||||
if(isempt($to_em))return '用户('.$to_uid.')没有设置邮箱';
|
||||
$to_em = substr($to_em, 1);
|
||||
$to_mn = substr($to_mn, 1);
|
||||
$to_id = substr($to_id, 1);
|
||||
}
|
||||
|
||||
if(isempt($to_em))return '没有接收人1';
|
||||
|
||||
$body = $this->rock->reparr($body, $rows);
|
||||
$title = $this->rock->reparr($title, $rows);
|
||||
|
||||
$body = str_replace("\n", '<br>', $body);
|
||||
|
||||
$msg = 'ok';
|
||||
|
||||
if(!getconfig('asynsend') || $zjsend==1){
|
||||
$sarrs = array(
|
||||
'emailpass' => $emailpass,
|
||||
'serversmtp' => $serversmtp,
|
||||
'serverport' => $serverport,
|
||||
'emailsecure' => $emailsecure,
|
||||
'emailuser' => $emailuser,
|
||||
'emailname' => $emailname,
|
||||
'receemail' => $to_em,
|
||||
'recename' => $to_mn,
|
||||
'title' => $title,
|
||||
'body' => $body,
|
||||
);
|
||||
foreach($oparm as $k1=>$v1)$sarrs[$k1] = $v1;
|
||||
$bo = $this->sendddddd($sarrs, true);
|
||||
if(!$bo)$msg = $this->errorinfo;
|
||||
}else{
|
||||
//异步发送邮件
|
||||
$uarr['title'] = $title;
|
||||
$uarr['body'] = $body;
|
||||
$uarr['receid'] = $to_id;
|
||||
$uarr['recename'] = $to_mn;
|
||||
$uarr['receemail'] = $to_em;
|
||||
$uarr['optdt'] = $this->rock->now();
|
||||
$uarr['optid'] = $this->adminid;
|
||||
$uarr['optname'] = $this->adminname;
|
||||
$uarr['status'] = 0;
|
||||
foreach($oparm as $k1=>$v1)$uarr[$k1] = $v1;
|
||||
$sid = m('email_cont')->insert($uarr);
|
||||
m('reim')->asynurl('asynrun','sendemail', array(
|
||||
'id' => $sid,
|
||||
'stype' => 0
|
||||
));//系统邮件提醒用的
|
||||
}
|
||||
return $msg;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function sendtoemail($params=array())
|
||||
{
|
||||
$setrs = m('option')->getpidarr(-1);
|
||||
if(!$setrs)return '未设置发送邮件';
|
||||
|
||||
$serversmtp = $this->rock->arrvalue($setrs, 'email_sendhost');
|
||||
$emailuser = $this->rock->arrvalue($setrs, 'email_sysuser');
|
||||
$emailname = $this->rock->arrvalue($setrs, 'email_sysname');
|
||||
$emailpass = $this->rock->arrvalue($setrs, 'email_syspass');
|
||||
$serverport = $this->rock->arrvalue($setrs, 'email_sendport');
|
||||
$emailsecure = $this->rock->arrvalue($setrs, 'email_sendsecure');
|
||||
|
||||
$barr = array(
|
||||
'emailpass' => $emailpass,
|
||||
'serversmtp' => $serversmtp,
|
||||
'serverport' => $serverport,
|
||||
'emailsecure' => $emailsecure,
|
||||
'emailuser' => $emailuser,
|
||||
'emailname' => $emailname,
|
||||
'receemail' => '',
|
||||
'recename' => '',
|
||||
'title' => '',
|
||||
'body' => '',
|
||||
);
|
||||
foreach($params as $k=>$v)$barr[$k]=$v;
|
||||
return $this->sendddddd($barr, true);
|
||||
}
|
||||
|
||||
//$jbs 密码是否加密 保存日志$log
|
||||
private function sendddddd($arr, $jbs, $log=false)
|
||||
{
|
||||
extract($arr);
|
||||
$pass = $emailpass;
|
||||
if($jbs)$pass = $this->rock->jm->uncrypt($pass);
|
||||
$mail = c('mailer');
|
||||
$mail->setHost($serversmtp, $serverport, $this->rock->repempt($emailsecure));
|
||||
$mail->setUser($emailuser, $pass);
|
||||
$mail->setFrom($emailuser, $emailname);
|
||||
$mail->addAddress($receemail, $recename);
|
||||
if(isset($ccemail) && !isempt($ccemail)){
|
||||
$mail->addCC($ccemail, $ccname);
|
||||
}
|
||||
if(isset($attachpath) && !isempt($attachpath)){
|
||||
$mail->addAttachment($attachpath, $attachname);
|
||||
}
|
||||
$mail->sendMail($title, $body);
|
||||
$bo = $mail->isSuccess();
|
||||
if(!$bo){
|
||||
$this->errorinfo = 'error:'.$mail->getErrror().';to:'.$receemail.'';
|
||||
}
|
||||
return $bo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试发送邮件
|
||||
*/
|
||||
public function sendmail_test()
|
||||
{
|
||||
return $this->sendmail('测试邮件帐号','这只是一个测试邮件帐号,不要紧张!<br>来自:'.TITLE.'<br>发送人:'.$this->adminname.'<br>网址:'.URL.'<br>发送时间:'.$this->rock->now().'', $this->adminid, array(),1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步发送邮件
|
||||
*/
|
||||
public function sendemailcont($id, $stype=-1)
|
||||
{
|
||||
$rs = m('email_cont')->getone($id);
|
||||
if(!$rs)return '记录不存在';
|
||||
if($stype==-1)$stype = (int)$this->rock->get('stype');
|
||||
if($stype == 0){
|
||||
$msg = $this->sendmail($rs['title'],$rs['body'], array(
|
||||
'receid' => $rs['receid'],
|
||||
'receemail' => $rs['receemail'],
|
||||
'recename' => $rs['recename'],
|
||||
), array(), 1, array(
|
||||
'ccname' => $rs['ccname'],
|
||||
'ccemail' => $rs['ccemail'],
|
||||
'attachpath'=> $rs['attachpath'],
|
||||
'attachname'=> $rs['attachname'],
|
||||
));
|
||||
}else{
|
||||
$msg = $this->sendemailout($rs['optid'],array(
|
||||
'title' => $rs['title'],
|
||||
'body' => $rs['body'],
|
||||
'receemail' => $rs['receemail'],
|
||||
'recename' => $rs['recename'],
|
||||
'ccname' => $rs['ccname'],
|
||||
'ccemail' => $rs['ccemail'],
|
||||
'attachpath'=> $rs['attachpath'],
|
||||
'attachname'=> $rs['attachname'],
|
||||
'mid' => $rs['mid'],
|
||||
), 1);
|
||||
}
|
||||
$status = '2';
|
||||
if($msg=='ok')$status = '1';
|
||||
$uarr['status'] = $status;
|
||||
$uarr['senddt'] = $this->rock->now();
|
||||
m('email_cont')->update($uarr, $id);
|
||||
return $msg;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户自己外发发送
|
||||
*/
|
||||
public function sendemailout($sendid, $canarr = array(), $zjsend=0)
|
||||
{
|
||||
$sendarr = array(
|
||||
'title' => '',
|
||||
'body' => '',
|
||||
'receemail' => '',
|
||||
'recename' => '',
|
||||
'ccname' => '',
|
||||
'ccemail' => '',
|
||||
'attachpath' => '',
|
||||
'attachname' => '',
|
||||
);
|
||||
foreach($canarr as $k=>$v)$sendarr[$k] = $v;
|
||||
extract($sendarr);
|
||||
$setrs = m('option')->getpidarr(-1);
|
||||
if(!$setrs)return '未设置发送邮件';
|
||||
$serversmtp = $this->rock->arrvalue($setrs, 'email_sendhost');
|
||||
$serverport = $this->rock->arrvalue($setrs, 'email_sendport');
|
||||
$emailsecure = $this->rock->arrvalue($setrs, 'email_sendsecure');
|
||||
$myuser = m('admin')->getone($sendid,'name,email,emailpass');
|
||||
if(!$myuser)return '发送人不存在';
|
||||
|
||||
$emailuser = $this->rock->arrvalue($myuser, 'email');
|
||||
$emailname = $this->rock->arrvalue($myuser, 'name');
|
||||
$emailpass = $this->rock->arrvalue($myuser, 'emailpass');
|
||||
|
||||
if(isempt($serversmtp) || isempt($serverport) || isempt($emailuser)|| isempt($emailpass))return '用户未设置邮件帐号密码';
|
||||
|
||||
$msg = 'ok';
|
||||
$outzt = 2;
|
||||
if(!getconfig('asynsend') || $zjsend==1){
|
||||
$bo = $this->sendddddd(array(
|
||||
'emailpass' => $emailpass,
|
||||
'serversmtp' => $serversmtp,
|
||||
'serverport' => $serverport,
|
||||
'emailsecure' => $emailsecure,
|
||||
'emailuser' => $emailuser,
|
||||
'emailname' => $emailname,
|
||||
'receemail' => $receemail,
|
||||
'recename' => $recename,
|
||||
'ccname' => $ccname,
|
||||
'ccemail' => $ccemail,
|
||||
'attachpath' => $attachpath,
|
||||
'attachname' => $attachname,
|
||||
'title' => $title,
|
||||
'body' => $body,
|
||||
), false);
|
||||
if(!$bo)$msg = $this->errorinfo;
|
||||
if(isset($mid)){
|
||||
if($msg=='ok')$outzt=1;
|
||||
m('emailm')->update('`outzt`='.$outzt.'', $mid);
|
||||
}
|
||||
}else{
|
||||
//异步发送邮件
|
||||
$uarr['title'] = $title;
|
||||
$uarr['body'] = $body;
|
||||
$uarr['receid'] = '';
|
||||
$uarr['recename'] = $recename;
|
||||
$uarr['receemail'] = $receemail;
|
||||
$uarr['ccname'] = $ccname;
|
||||
$uarr['ccemail'] = $ccemail;
|
||||
$uarr['attachpath'] = $attachpath;
|
||||
$uarr['attachname'] = $attachname;
|
||||
$uarr['optdt'] = $this->rock->now();
|
||||
$uarr['optid'] = $this->adminid;
|
||||
$uarr['optname'] = $this->adminname;
|
||||
$uarr['status'] = 0;
|
||||
if(isset($mid))$uarr['mid'] = $mid;
|
||||
$sid = m('email_cont')->insert($uarr);
|
||||
c('rockqueue')->push('email,anaysend', array(
|
||||
'id' => $sid,
|
||||
'stype' => 1
|
||||
));
|
||||
/*
|
||||
m('reim')->asynurl('asynrun','sendemail', array(
|
||||
'id' => $sid,
|
||||
'stype' => 1
|
||||
));*/
|
||||
}
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
206
webmain/model/emailmModel.php
Normal file
206
webmain/model/emailmModel.php
Normal file
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
class emailmClassModel extends Model
|
||||
{
|
||||
public function initModel()
|
||||
{
|
||||
$this->adminobj = m('admin');
|
||||
$this->optionobj = m('option');
|
||||
$this->upfileobj = c('upfile');
|
||||
$this->recehost = $this->optionobj->getval('email_recehost');
|
||||
$this->receyumi = $this->optionobj->getval('email_receyumi');
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户收邮件
|
||||
* $uid 用户id
|
||||
* return 返回是数组就说明成功,字符串就失败
|
||||
*/
|
||||
public function receemail($uid)
|
||||
{
|
||||
$ukey = 'email_recexin_'.$uid.'';
|
||||
$myurs = $this->adminobj->getone($uid, 'email,emailpass');
|
||||
$time = $this->optionobj->getval($ukey,'',3);
|
||||
if(!isempt($time))$time = strtotime($time);
|
||||
if(isempt($this->receyumi))return '未设置收信邮箱域名';
|
||||
if(isempt($myurs['email']))return '未设置邮箱,可到[系统→邮件管理→用户邮箱设置]下设置';
|
||||
if(isempt($myurs['emailpass']))return '未设置邮箱密码,可到[系统→邮件管理→用户邮箱设置]下设置';
|
||||
if(!contain($myurs['email'], $this->receyumi))return '邮箱域名必须是['.$this->receyumi.'],当前用户邮箱:'.$myurs['email'].'';
|
||||
$rows = c('imap')->receemail($this->recehost, $myurs['email'], $myurs['emailpass'], $time);
|
||||
if(!is_array($rows))return $rows;
|
||||
$jf = 0;
|
||||
$bool = true;
|
||||
foreach($rows as $k=>$rs){
|
||||
$message_id = $rs['message_id'];
|
||||
if(isempt($message_id))$message_id = md5($rs['date']);
|
||||
|
||||
$where = "message_id='$message_id'";
|
||||
$id = (int)$this->getmou('id',$where);
|
||||
if($id ==0)$where = '';
|
||||
if($id>0)continue;
|
||||
|
||||
$uarr['message_id'] = $message_id;
|
||||
$uarr['title'] = $this->db->tocovexec($rs['subject'], 1);
|
||||
$uarr['content'] = $this->db->tocovexec($rs['body'], 1);
|
||||
$uarr['senddt'] = $rs['date'];
|
||||
$uarr['optdt'] = $this->rock->now;
|
||||
$uarr['size'] = $rs['size'];
|
||||
$uarr['fromemail'] = $this->gshemail($rs['fromemail']);
|
||||
$uarr['toemail'] = $this->gshemail($rs['toemail']);
|
||||
$uarr['reply_toemail'] = $this->gshemail($rs['reply_toemail']);
|
||||
$uarr['ccemail'] = $this->gshemail($rs['ccemail']);
|
||||
$uarr['isturn'] = 1;
|
||||
$uarr['isfile'] = count($rs['attach']) > 0 ? 1 : 0;
|
||||
$uarr['type'] = 1;
|
||||
$uarr['numoi'] = $rs['num'];
|
||||
$form = $rs['from'][0];
|
||||
$urs = $this->adminobj->emailtours($form->email);
|
||||
$uarr['uid'] = 0;
|
||||
$uarr['sendid'] = 0;
|
||||
$uarr['sendname'] = '';
|
||||
if(is_array($urs) && $urs){
|
||||
$uarr['sendid'] = $urs['id'];
|
||||
$uarr['uid'] = $urs['id'];
|
||||
$uarr['sendname'] = $urs['name'];
|
||||
}
|
||||
$uarr['sendname'] = $uarr['fromemail'];
|
||||
$uarr['recename'] = $uarr['toemail'];
|
||||
|
||||
$bool = $this->record($uarr, $where);
|
||||
if($bool){
|
||||
if($id ==0)$id = $this->db->insert_id();
|
||||
$this->saveattach($rs['num'], $rs['attach'], $id);
|
||||
$toarr = $this->saveemails($id, 0, $rs['to']);
|
||||
$this->saveemails($id, 1, $rs['cc']);
|
||||
$this->saveemails($id, 2, $rs['from']);
|
||||
$uuarr['receid'] = $toarr[0];
|
||||
//$uuarr['recename'] = $toarr[1];
|
||||
$this->update($uuarr, $id);
|
||||
$jf++;
|
||||
}
|
||||
}
|
||||
if($bool)$this->optionobj->setval($ukey.'@-2', '共'.$jf.'封');//记录最后收信时间
|
||||
return array(
|
||||
'count' => $jf
|
||||
);
|
||||
}
|
||||
|
||||
private function gshemail($str)
|
||||
{
|
||||
$str = str_replace(array('"',' ','\''),'', $str);
|
||||
return $str;
|
||||
}
|
||||
|
||||
//保存到子表
|
||||
public function saveemails($mid, $type, $arr)
|
||||
{
|
||||
$sid = $sna = '';
|
||||
foreach($arr as $k=>$rs){
|
||||
$where = "`mid`='$mid' and `type`=$type and `email`='$rs->email'";
|
||||
$id = (int)$this->db->getmou('[Q]emails','id',$where);
|
||||
if($id ==0)$where = '';
|
||||
$uarr = array();
|
||||
$uarr['mid'] = $mid;
|
||||
$uarr['email'] = $rs->email;
|
||||
$uarr['personal'] = $rs->personal;
|
||||
$uarr['type'] = $type;
|
||||
if($id==0){
|
||||
$uarr['optdt'] = $this->rock->now;
|
||||
}
|
||||
$urs = $this->adminobj->emailtours($rs->email);
|
||||
$uarr['uid'] = 0;
|
||||
if(is_array($urs) && $urs){
|
||||
$uarr['uid'] = $urs['id'];
|
||||
$sid .=',u'.$urs['id'].'';
|
||||
$sna .=','.$urs['name'].'';
|
||||
}
|
||||
$this->db->record('[Q]emails', $uarr, $where);
|
||||
}
|
||||
if($sid != ''){
|
||||
$sid = substr($sid, 1);
|
||||
$sna = substr($sna, 1);
|
||||
}
|
||||
return array($sid, $sna);
|
||||
}
|
||||
|
||||
//保存邮件的附件
|
||||
private function saveattach($oi, $arr, $id)
|
||||
{
|
||||
$dbs = m('file');
|
||||
$doobj = c('down');
|
||||
foreach($arr as $k=>$rs){
|
||||
|
||||
$fsad = explode('.', $rs['filename']);
|
||||
$sarr['filename'] = $rs['filename'];
|
||||
$sarr['filesize'] = $rs['filesize'];
|
||||
$sarr['fileext'] = strtolower($fsad[count($fsad)-1]);
|
||||
$sarr['keyoi'] = $oi.','.$rs['encoding'].','.$rs['filekey'];
|
||||
$sarr['mtype'] = 'emailm';
|
||||
$sarr['optid'] = $this->adminid;
|
||||
$sarr['optname'] = $this->adminname;
|
||||
$sarr['adddt'] = $this->rock->now;
|
||||
$sarr['mid'] = $id;
|
||||
$sarr['filesizecn'] = $this->upfileobj->formatsize($rs['filesize']);
|
||||
$where = "`mtype`='emailm' and `mid`='$id' and `filename`='".$sarr['filename']."' and `filesize`='".$sarr['filesize']."'";
|
||||
|
||||
if($dbs->rows($where)==0){
|
||||
$sarr['filepath'] = $doobj->savefilecont($sarr['fileext'], $rs['attachcont']);//下载附件
|
||||
$fid = $dbs->insert($sarr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 统计我未读邮件
|
||||
*/
|
||||
public function wdtotal($uid)
|
||||
{
|
||||
$to= $this->gettotsllss($uid, 1);
|
||||
return (int)$to;
|
||||
}
|
||||
|
||||
//
|
||||
private function gettotsllss($uid, $lx=0, $glx='')
|
||||
{
|
||||
$whe= 'b.uid='.$uid.' and a.`isturn`=1 and b.`isdel`=0 and b.`type` in(0,1)';
|
||||
if($lx==1)$whe='b.uid='.$uid.' and a.`isturn`=1 and b.`isdel`=0 and b.`type` in(0,1) and b.`zt`=0';
|
||||
if($lx==2)$whe='a.`sendid`='.$uid.' and a.`isturn`=0';
|
||||
if($lx==3)$whe='b.uid='.$uid.' and b.`type` = 2 and b.`isdel`=0';
|
||||
if($lx==4)$whe='b.uid='.$uid.' and a.`isturn`=1 and b.`type` in(0,1) and b.`isdel`=1';
|
||||
if($glx=='whe')return $whe;
|
||||
$to = $this->db->rows('`[Q]emailm` a left join `[Q]emails` b on a.`id`=b.`mid`', $whe);
|
||||
return (int)$to;
|
||||
}
|
||||
|
||||
public function gettowhere($uid, $lx)
|
||||
{
|
||||
return $this->gettotsllss($uid, $lx,'whe');
|
||||
}
|
||||
|
||||
|
||||
public function zongtotal($uid)
|
||||
{
|
||||
$zz = $this->gettotsllss($uid, 0); //所有邮件
|
||||
$wd = $this->gettotsllss($uid, 1); //未读邮件
|
||||
$cgx= $this->gettotsllss($uid, 2); //草稿箱
|
||||
|
||||
$yfs= $this->gettotsllss($uid, 3); //已发送
|
||||
$ysc= $this->gettotsllss($uid, 4); //已删除
|
||||
|
||||
return array(
|
||||
'wd' => $wd,
|
||||
'zz' => $zz,
|
||||
'cgx' => $cgx,
|
||||
'yfs' => $yfs,
|
||||
'ysc' => $ysc
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 标识已读了
|
||||
*/
|
||||
public function biaoyd($uid,$sid)
|
||||
{
|
||||
m('emails')->update('`zt`=1','`uid`='.$uid.' and `mid` in('.$sid.')');
|
||||
}
|
||||
}
|
||||
417
webmain/model/fileModel.php
Normal file
417
webmain/model/fileModel.php
Normal file
@@ -0,0 +1,417 @@
|
||||
<?php
|
||||
class fileClassModel extends Model
|
||||
{
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
$this->fileall = ',aac,ace,ai,ain,amr,app,arj,asf,asp,aspx,av,avi,bin,bmp,cab,cad,cat,cdr,chm,com,css,cur,dat,db,dll,dmv,doc,docx,dot,dps,dpt,dwg,dxf,emf,eps,et,ett,exe,fla,ftp,gif,hlp,htm,html,icl,ico,img,inf,ini,iso,jpeg,jpg,js,m3u,max,mdb,mde,mht,mid,midi,mov,mp3,mp4,mpeg,mpg,msi,nrg,ocx,ogg,ogm,pdf,php,png,pot,ppt,pptx,psd,pub,qt,ra,ram,rar,rm,rmvb,rtf,swf,tar,tif,tiff,txt,url,vbs,vsd,vss,vst,wav,wave,wm,wma,wmd,wmf,wmv,wps,wpt,wz,xls,xlsx,xlt,xml,zip,';
|
||||
|
||||
$this->mimitype = c('file')->getAllMime();
|
||||
}
|
||||
|
||||
/***
|
||||
* 添加预览和下载记录
|
||||
*/
|
||||
public function addlogs($fileid, $type)
|
||||
{
|
||||
$uarr = array();
|
||||
$uarr['fileid'] = $fileid;
|
||||
$uarr['type'] = $type;
|
||||
$uarr['optname'] = $this->adminname;
|
||||
$uarr['optid'] = $this->adminid;
|
||||
$uarr['ip'] = $this->rock->ip;
|
||||
$uarr['web'] = $this->rock->web;
|
||||
$uarr['optdt'] = $this->rock->now;
|
||||
return m('files')->insert($uarr);
|
||||
}
|
||||
|
||||
public function getmime($lx)
|
||||
{
|
||||
if(!isset($this->mimitype[$lx]))$lx = 'unkown';
|
||||
return $this->mimitype[$lx];
|
||||
}
|
||||
|
||||
public function getfile($mtype, $mid, $where='')
|
||||
{
|
||||
if($where=='')$where = "`mtype`='$mtype' and `mid` in($mid)";
|
||||
$rows = $this->getall("$where order by `id`");
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function addfile($fileid, $mtype, $mid, $mknum='')
|
||||
{
|
||||
if(!$this->isempt($fileid)){
|
||||
$this->update("`mtype`='$mtype',`mid`='$mid',`mknum`='$mknum'", "`id` in($fileid) and `mid`=0");
|
||||
}
|
||||
}
|
||||
|
||||
public function getstr($mtype, $mid, $lx=0, $where='')
|
||||
{
|
||||
$filearr = $this->getfile($mtype, $mid, $where);
|
||||
$fstr = $this->getstrstr($filearr, $lx);
|
||||
return $fstr;
|
||||
}
|
||||
|
||||
public function getstrstr($filearr, $lx)
|
||||
{
|
||||
$fstr = '';
|
||||
if($filearr)foreach($filearr as $k=>$rs){
|
||||
if($k>0)$fstr.='<br>';
|
||||
$fstr .= $this->getfilestr($rs, $lx);
|
||||
}
|
||||
return $fstr;
|
||||
}
|
||||
|
||||
//获取聚合文件
|
||||
public function getallstr($filearr, $mid, $lx=0)
|
||||
{
|
||||
$farr = array();
|
||||
if($filearr)foreach($filearr as $k=>$rs){
|
||||
if($rs['mid']==$mid)$farr[] = $rs;
|
||||
}
|
||||
return $this->getstrstr($farr, $lx);
|
||||
}
|
||||
|
||||
public function isimg($ext)
|
||||
{
|
||||
return $this->contain('|jpg|png|gif|bmp|jpeg|', '|'.$ext.'|');
|
||||
}
|
||||
|
||||
public function isoffice($ext)
|
||||
{
|
||||
return contain('|doc|docx|xls|xlsx|ppt|pptx|pdf|', '|'.$ext.'|');
|
||||
}
|
||||
|
||||
public function isbianju($ext)
|
||||
{
|
||||
return contain('|doc|docx|xls|xlsx|ppt|pptx|', '|'.$ext.'|');
|
||||
}
|
||||
|
||||
public function isyulan($ext)
|
||||
{
|
||||
return contain(',txt,log,html,htm,js,php,php3,mp4,md,cs,sql,java,json,css,asp,aspx,shtml,cpp,c,vbs,jsp,xml,bat,ini,conf,sh,', ','.$ext.',');
|
||||
}
|
||||
|
||||
//判断是否可预览
|
||||
public function isview($ext)
|
||||
{
|
||||
if($this->isimg($ext))return true;
|
||||
if($this->isoffice($ext))return true;
|
||||
if($this->isyulan($ext))return true;
|
||||
return contain(',mp3,ogg,mp4,', ','.$ext.',');
|
||||
}
|
||||
|
||||
//获取缩略图的路径
|
||||
public function getthumbpath($rs)
|
||||
{
|
||||
$thumbpath = $this->rock->repempt(arrvalue($rs, 'thumbpath'));
|
||||
if(!isempt($thumbpath)){
|
||||
if(substr($thumbpath,0,4)=='http')return $thumbpath;
|
||||
if(!file_exists($thumbpath))$thumbpath='';
|
||||
}
|
||||
|
||||
if(isempt($thumbpath))$thumbpath = arrvalue($rs, 'thumbplat');
|
||||
if(!isempt($thumbpath)){
|
||||
$thumbpath = str_replace('{FILEURL}', getconfig('rockfile_url'), $thumbpath);
|
||||
$thumbpath = $this->rock->gethttppath($thumbpath);
|
||||
}
|
||||
return $thumbpath;
|
||||
}
|
||||
|
||||
|
||||
//$lx=2详情,$lx=3是flow.php getdatalog下读取的
|
||||
public function getfilestr($rs, $lx=0)
|
||||
{
|
||||
$fstr= '';
|
||||
if(!$rs)return $fstr;
|
||||
$str = $this->rock->jm->strrocktoken(array('a'=>'down','id'=>$rs['id']));
|
||||
$url = ''.URL.'index.php?rocktoken='.$str.'';
|
||||
$str = 'href="'.$url.'"';
|
||||
$ext = $rs['fileext'];
|
||||
$id = $rs['id'];
|
||||
$isimg= $this->isimg($ext);
|
||||
$strd= $str;
|
||||
if($lx==1)$str='href="javascript:;" onclick="return js.downshow('.$rs['id'].')"';
|
||||
if($lx>=2){
|
||||
$paths = $rs['filepath'];
|
||||
if(arrvalue($rs,'filepathout'))$paths = $rs['filepathout'];
|
||||
if(!$isimg)$paths='';
|
||||
$str='href="javascript:;" onclick="return c.downshow('.$rs['id'].',\''.$ext.'\',\''.$paths.'\',\''.$rs['filenum'].'\')"';//详情上预览
|
||||
}
|
||||
|
||||
$flx = $rs['fileext'];
|
||||
if(!$this->contain($this->fileall,','.$flx.','))$flx='wz';
|
||||
$str1 = '';
|
||||
$imurl = ''.URL.'web/images/fileicons/'.$flx.'.gif';
|
||||
$thumbpath = $this->getthumbpath($rs);
|
||||
if($isimg && !isempt($thumbpath))$imurl = $thumbpath;
|
||||
|
||||
$isdel = file_exists($rs['filepath']);
|
||||
if(substr($rs['filepath'],0,4)=='http')$isdel=true;
|
||||
if(!isempt($rs['filenum']))$isdel=true;
|
||||
if(arrvalue($rs,'filepathout'))$isdel=true;
|
||||
|
||||
$fstr .='<img src="'.$imurl.'" align="absmiddle" height=20 width=20>';
|
||||
if($isdel){
|
||||
$fstr .=' '.$rs['filename'].'';
|
||||
}else{
|
||||
$fstr .=' <s>'.$rs['filename'].'</s>';
|
||||
}
|
||||
|
||||
$fstr .=' <span style="color:#aaaaaa;font-size:12px">('.$rs['filesizecn'].')</span>';
|
||||
|
||||
$filenum = arrvalue($rs,'filenum');
|
||||
//if(!isempt($filenum)){
|
||||
$strd = 'href="javascript:;" onclick="js.fileopt('.$id.', 1)"';//下载的链接
|
||||
//}
|
||||
|
||||
if($lx>=2){
|
||||
if($isdel){
|
||||
$fstr .= ' <a temp="clo" '.$strd.' class="blue">下载</a>';
|
||||
if($isimg || $this->isoffice($ext) || $this->isyulan($ext))
|
||||
$fstr .= ' <a temp="clo" '.$str.' class="blue">预览</a>';
|
||||
if($this->isbianju($ext) && $lx==3)$fstr .='`'.$rs['id'].'`'; //用于编辑
|
||||
}else{
|
||||
$fstr .= ' <span style="color:#aaaaaa;font-size:12px">已删除</span>';
|
||||
}
|
||||
}
|
||||
|
||||
return $fstr;
|
||||
}
|
||||
|
||||
public function getfiles($mtype, $mid)
|
||||
{
|
||||
$rows = $this->getall("`mtype`='$mtype' and `mid`='$mid' order by `id`");
|
||||
foreach($rows as $k=>$rs){
|
||||
$rows[$k]['status'] = 4;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function getfilepath($mtype, $mid)
|
||||
{
|
||||
$rows = $this->getfiles($mtype, $mid);
|
||||
$str = '';
|
||||
$nas = '';
|
||||
$st1 = '';
|
||||
foreach($rows as $k=>$rs){
|
||||
$path = $rs['filepath'];
|
||||
$outu = arrvalue($rs, 'filepathout');
|
||||
if(isempt($outu)){
|
||||
if(!isempt($path) && (file_exists($path) || substr($path,0,4)=='http') ){
|
||||
$str .= ','.$path.'';
|
||||
$nas .= ','.$rs['filename'].'';
|
||||
}
|
||||
}else{
|
||||
if($st1!='')$st1.='<br>';
|
||||
$st1.=''.$rs['filename'].'('.$rs['filesizecn'].') <a target="_blank" href="'.$outu.'">下载</a>';
|
||||
}
|
||||
}
|
||||
if($str!=''){
|
||||
$str = substr($str, 1);
|
||||
$nas = substr($nas, 1);
|
||||
}
|
||||
return array($str, $nas, $st1);
|
||||
}
|
||||
|
||||
public function copyfile($mtype, $mid)
|
||||
{
|
||||
$rows = $this->getall("`mtype`='$mtype' and `mid`='$mid' order by `id`");
|
||||
$arr = array();
|
||||
foreach($rows as $k=>$rs){
|
||||
$inuar = $rs;
|
||||
if(isempt($rs['filepath']) || (substr($rs['filepath'],0,4)!='http' && !arrvalue($rs,'filepathout') && !file_exists($rs['filepath'])))continue;
|
||||
unset($inuar['id']);
|
||||
$oid = $rs['id'];
|
||||
$inuar['adddt'] = $this->rock->now;
|
||||
$inuar['optid'] = $this->adminid;
|
||||
$inuar['optname'] = $this->adminname;
|
||||
$inuar['downci'] = '0';
|
||||
$inuar['mtype'] = '';
|
||||
$inuar['mid'] = '0';
|
||||
$inuar['oid'] = $oid;
|
||||
|
||||
$ids = (int)$this->getmou('id','oid='.$oid.' and `mid`=0');
|
||||
if($ids==0){
|
||||
$this->insert($inuar);
|
||||
$inuar['id'] = $this->db->insert_id();
|
||||
}else{
|
||||
$inuar['id'] = $ids;
|
||||
}
|
||||
$inuar['status'] = 4;
|
||||
$arr[] = $inuar;
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public function delfiles($mtype, $mid)
|
||||
{
|
||||
$where = "`mtype`='$mtype' and `mid`='$mid'";
|
||||
$this->delfile('', $where);
|
||||
}
|
||||
|
||||
public function delfile($sid='', $where='')
|
||||
{
|
||||
if($sid!='')$where = "`id` in ($sid)";
|
||||
if($where=='')return;
|
||||
$rows = $this->getall($where);
|
||||
foreach($rows as $k=>$rs){
|
||||
$path = $rs['filepath'];
|
||||
if(!$this->isempt($path) && substr($path,0,4)!='http' && file_exists($path))unlink($path);
|
||||
$path = $rs['thumbpath'];
|
||||
if(!$this->isempt($path) && substr($path,0,4)!='http' && file_exists($path))unlink($path);
|
||||
$path = $rs['pdfpath'];
|
||||
if(!$this->isempt($path) && substr($path,0,4)!='http' && file_exists($path))unlink($path);
|
||||
|
||||
if(!isempt($rs['filenum']))c('rockqueue')->push('flow,uptodelete', array('filenum'=>$rs['filenum']));//发送同步删除
|
||||
|
||||
}
|
||||
$this->delete($where);
|
||||
}
|
||||
|
||||
public function fileheader($filename,$ext='xls', $size=0)
|
||||
{
|
||||
$mime = $this->getmime($ext);
|
||||
$filename = $this->iconvutf8(str_replace(' ','',$filename));
|
||||
header('Content-type:'.$mime.'');
|
||||
header('Accept-Ranges: bytes');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Pragma: no-cache');
|
||||
if($size>0)header('Content-Length:'.$size.'');
|
||||
header('Expires: 0');
|
||||
header('Content-disposition:attachment;filename='.$filename.'');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
}
|
||||
|
||||
//渣渣IE才需要转化,真是醉了
|
||||
public function iconvutf8($text) {
|
||||
if(contain($this->rock->web,'IE')){
|
||||
return iconv('utf-8','gb2312', $text);
|
||||
}else{
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id,$qx=false)
|
||||
{
|
||||
if($id==0)exit('Sorry!');
|
||||
$rs = $this->getone($id);
|
||||
if(!$rs)exit('504 Not find files');
|
||||
if(!$qx && !$this->isdownfile($rs))exit('404 No permission download');
|
||||
$this->update("`downci`=`downci`+1", $id);
|
||||
$this->addlogs($id, 1);
|
||||
$filepath = $rs['filepath'];
|
||||
$filename = $rs['filename'];
|
||||
$filesize = $rs['filesize'];
|
||||
$fileext = $rs['fileext'];
|
||||
$filepathout= $rs['filepathout'];
|
||||
if($this->rock->contain($filepath,'http')){
|
||||
header('location:'.$filepath.'');
|
||||
}else{
|
||||
//2018-07-18只能下载upload/images下的文件
|
||||
$ielx = substr($filepath,0,strlen(UPDIR));
|
||||
$ielx1 = substr($filepath,0,6);
|
||||
if($ielx!=UPDIR && $ielx1!='upload' && $ielx1!='images')exit('无效操作1');
|
||||
|
||||
if(!file_exists($filepath)){
|
||||
if(!isempt($filepathout))header('location:'.$filepathout.'');
|
||||
exit('404 Not find files');
|
||||
}
|
||||
|
||||
if(!contain($filename,'.'.$fileext.''))$filename .= '.'.$fileext.'';
|
||||
$filesize = filesize($filepath);
|
||||
$this->fileheader($filename, $fileext, $filesize);
|
||||
if(substr($filepath,-4)=='temp'){
|
||||
$content = file_get_contents($filepath);
|
||||
echo base64_decode($content);
|
||||
}else{
|
||||
if($this->rock->iswebbro(0) && $this->rock->iswebbro(5)){
|
||||
header('location:'.$filepath.'');
|
||||
return;
|
||||
}
|
||||
ob_clean();flush();readfile($filepath);return;
|
||||
if($filesize > 5*1024*1024){
|
||||
header('location:'.$filepath.'');
|
||||
}else{
|
||||
echo file_get_contents($filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//这个是下载temp文件的
|
||||
public function download($id)
|
||||
{
|
||||
if($id==0)exit('Sorry!');
|
||||
$rs = $this->getone($id);
|
||||
if(!$rs)exit('504 Not find files');
|
||||
if(!$this->isdownfile($rs))exit('No permission download');
|
||||
$filepath = $rs['filepath'];
|
||||
$ielx = substr($filepath,0,strlen(UPDIR));
|
||||
$ielx1 = substr($filepath,0,6);
|
||||
if($ielx!=UPDIR && $ielx1!='upload' && $ielx1!='images')exit('无效操作2');
|
||||
|
||||
if(!file_exists($filepath))exit('404 Not find files');
|
||||
|
||||
$this->update("`downci`=`downci`+1", $id);
|
||||
$this->addlogs($id, 1);
|
||||
|
||||
$filename = $rs['filename'];
|
||||
$filesize = $rs['filesize'];
|
||||
if(substr($filepath,-4)=='temp'){
|
||||
Header("Content-type: application/octet-stream");
|
||||
header('Accept-Ranges: bytes');
|
||||
Header("Accept-Length: ".$filesize);
|
||||
Header("Content-Length: ".$filesize);
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Pragma: no-cache');
|
||||
header('Expires: 0');
|
||||
$content = file_get_contents($filepath);
|
||||
echo base64_decode($content);
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//判断是否有下载文件的权限
|
||||
private function isdownfile($rs)
|
||||
{
|
||||
//return true; //如果不想权限判断就去掉注释直接返回true
|
||||
$uid = $this->adminid;
|
||||
if(arrvalue($rs,'optid')==$uid)return true;
|
||||
$table = arrvalue($rs,'mtype');
|
||||
$mid = (int)arrvalue($rs,'mid','0');
|
||||
if(!isempt($table) && $mid>0){
|
||||
$to = m('reads')->rows("`table`='$table' and `mid`='$mid' and `optid`='$uid'");
|
||||
if($to>0)return true;
|
||||
}
|
||||
$mknum = arrvalue($rs,'mknum');
|
||||
if(!isempt($mknum)){
|
||||
$mknuma = explode('|', $mknum);
|
||||
$num = $mknuma[0];
|
||||
$mid = (int)arrvalue($mknuma, 1, $mid);
|
||||
if($mid>0){
|
||||
$flow = m('flow')->initflow($num, $mid, false);
|
||||
if($flow->isreadqx(1))return true;
|
||||
}
|
||||
}
|
||||
if($table=='im_mess'){
|
||||
$ors = m($table)->getone($mid);
|
||||
if($ors){
|
||||
$receuid = $ors['receuid'];
|
||||
if(contain(','.$receuid.',',','.$uid.','))return true;
|
||||
}
|
||||
}
|
||||
if($table=='word'){
|
||||
$ors = m('word')->getone("`fileid`='".$rs['id']."'");
|
||||
if($ors){
|
||||
$cid = $ors['cid'];
|
||||
$flow = m('flow')->initflow('worc', $cid, false);
|
||||
if($flow->isreadqx(1))return true;
|
||||
$flow = m('flow')->initflow('word', $ors['id'], false);
|
||||
if($flow->isreadqx(1))return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
108
webmain/model/finaModel.php
Normal file
108
webmain/model/finaModel.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
class finaClassModel extends Model
|
||||
{
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
$this->settable('fininfom');
|
||||
}
|
||||
|
||||
//统计我未还款
|
||||
public function totaljie($uid, $id=0)
|
||||
{
|
||||
$where = 'and id<>'.$id.'';
|
||||
$to1 = floatval($this->getmou('sum(money)money',"`uid`='$uid' and `type`=2 and `status`=1"));
|
||||
$to2 = floatval($this->getmou('sum(money)money',"`uid`='$uid' and `type`=3 and `status`<>5 $where"));
|
||||
$to = $to1-$to2;
|
||||
return $to;
|
||||
}
|
||||
|
||||
public function getjkdwhere()
|
||||
{
|
||||
return '(select `uid` from `[Q]fininfom` where `type`=2 and `status`=1)';
|
||||
}
|
||||
|
||||
//统计
|
||||
public function totalfkd($rows, $uids)
|
||||
{
|
||||
$carr = $barr = array();
|
||||
|
||||
//借款
|
||||
$hkto = $this->db->getall("select uid,sum(money)money from `[Q]fininfom` where `uid` in($uids) and `type`=2 and `status`=1 group by `uid`");
|
||||
foreach($hkto as $k=>$rs)$carr[$rs['uid']] = $rs['money'];
|
||||
|
||||
//还的
|
||||
$hkto = $this->db->getall("select uid,sum(money)money from `[Q]fininfom` where `uid` in($uids) and `type`=3 and `status`=1 group by `uid`");
|
||||
foreach($hkto as $k=>$rs)$barr[$rs['uid']] = $rs['money'];
|
||||
|
||||
|
||||
foreach($rows as $k=>$rs){
|
||||
$uid = $rs['id'];
|
||||
$moneyjk = floatval(arrvalue($carr, $uid, 0));
|
||||
$moneyhk = floatval(arrvalue($barr, $uid, 0));
|
||||
$moneyhx = $moneyjk - $moneyhk;
|
||||
|
||||
if($moneyjk==0)$moneyjk='';
|
||||
if($moneyhk==0)$moneyhk='';
|
||||
if($moneyhx==0)$moneyhx='';
|
||||
|
||||
$rows[$k]['moneyjk'] = $moneyjk;
|
||||
$rows[$k]['moneyhk'] = $moneyhk;
|
||||
$rows[$k]['moneyhx'] = $moneyhx;
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//获取当前账套
|
||||
public function getzhangtao($lx=0)
|
||||
{
|
||||
$dt = $this->rock->date;
|
||||
$where= m('admin')->getcompanywhere(3);
|
||||
if($lx==0)$where.=" and `startdt`<='$dt' and `enddt`>='$dt'";
|
||||
$rows = m('finzhang')->getall("status=1 ".$where."",'*','sort, startdt desc');
|
||||
$arr = array();
|
||||
foreach($rows as $k=>$rs){
|
||||
$arr[] = array(
|
||||
'value' => $rs['id'],
|
||||
'name' => $rs['name'],
|
||||
'subname' => $rs['startdt'].'→'.$rs['enddt'],
|
||||
);
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
//获取财务帐号
|
||||
public function getaccount()
|
||||
{
|
||||
$where= m('admin')->getcompanywhere(3);
|
||||
$rows = m('finount')->getall("status=1 ".$where."",'*','sort');
|
||||
$arr = array();
|
||||
foreach($rows as $k=>$rs){
|
||||
$arr[] = array(
|
||||
'value' => $rs['id'],
|
||||
'name' => $rs['name'],
|
||||
);
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
//更新财务帐号金额
|
||||
public function updatemoney($accid='')
|
||||
{
|
||||
$where= '';
|
||||
if(!isempt($accid))$where=' and `accountid`='.$accid.'';
|
||||
$rows = $this->db->getall('SELECT accountid,SUM(money)money FROM `[Q]finjibook` where `status`=1 '.$where.' group by accountid');
|
||||
$db = m('finount');
|
||||
$ids= '0';
|
||||
foreach($rows as $k=>$rs){
|
||||
$db->update('`money`='.$rs['money'].'', $rs['accountid']);
|
||||
$ids.=','.$rs['accountid'].'';
|
||||
}
|
||||
if(isempt($accid))$db->update('`money`=0', '`id` not in('.$ids.')');
|
||||
}
|
||||
|
||||
}
|
||||
71
webmain/model/flow/assetmModel.php
Normal file
71
webmain/model/flow/assetmModel.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
class flow_assetmClassModel extends flowModel
|
||||
{
|
||||
public function initModel()
|
||||
{
|
||||
$this->statearr = c('array')->strtoarray('blue|闲置,#ff6600|在用,red|维修,gray|报废,gray|丢失');
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs)
|
||||
{
|
||||
if(isset($rs['typeid']))$rs['typeid'] = $this->db->getmou('[Q]option','name',"`id`='".$rs['typeid']."'");
|
||||
if(isset($rs['ckid']) && $rs['ckid']>0){
|
||||
$rs['ckid'] = $this->db->getmou('[Q]option','name',"`id`='".$rs['ckid']."'");
|
||||
if(isset($rs['address']) && isempt($rs['address'])){
|
||||
$rs['address'] = $rs['ckid'];
|
||||
$this->update("`address`='".$rs['address']."'", $rs['id']);
|
||||
}
|
||||
}
|
||||
if(isset($this->statearr[$rs['state']])){
|
||||
$b = $this->statearr[$rs['state']];
|
||||
$rs['state'] = '<font color="'.$b[0].'">'.$b[1].'</font>';
|
||||
}
|
||||
if(isset($rs['fengmian']) && !isempt($rs['fengmian']))$rs['fengmian'] = '<img src="'.$rs['fengmian'].'" height="100">';
|
||||
return $rs;
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$where = '';
|
||||
$typeid = $this->rock->post('typeid','0');
|
||||
//$key = $this->rock->post('key');
|
||||
if($typeid!='0'){
|
||||
$alltpeid = m('option')->getalldownid($typeid);
|
||||
$where .= ' and `typeid` in('.$alltpeid.')';
|
||||
}
|
||||
//弃用这个,去到表单表示元素管理开启搜索
|
||||
//if($key != '')$where.=" and (`title` like '%$key%' or `num` like '%$key%' or `usename` like '%$key%')";
|
||||
return array(
|
||||
'where' => $where,
|
||||
'orlikefields'=>'title,num,usename',
|
||||
'order' => 'optdt desc',
|
||||
//'fields'=> 'id,title,num,brand,optdt,usename,state,ckid'
|
||||
);
|
||||
}
|
||||
|
||||
//导入数据的测试显示
|
||||
public function flowdaorutestdata()
|
||||
{
|
||||
return array(
|
||||
'typeid' => '电脑/台式电脑',
|
||||
'title' => '这是一个电脑啊',
|
||||
'num' => 'ZiCAN-001',
|
||||
'brand' => '联想',
|
||||
'laiyuan' => '购买',
|
||||
'buydt' => '2017-01-17',
|
||||
'explain' => '简单说明一下',
|
||||
'address' => '放哪里了',
|
||||
);
|
||||
}
|
||||
|
||||
//导入之前
|
||||
public function flowdaorubefore($rows)
|
||||
{
|
||||
foreach($rows as $k=>$rs){
|
||||
$rows[$k]['typeid'] = $this->option->gettypeid('assetstype',$rs['typeid']);
|
||||
$rows[$k]['adddt'] = $this->rock->now;
|
||||
$rows[$k]['optdt'] = $this->rock->now;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
50
webmain/model/flow/bianjianModel.php
Normal file
50
webmain/model/flow/bianjianModel.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
//便笺
|
||||
class flow_bianjianClassModel extends flowModel
|
||||
{
|
||||
|
||||
|
||||
public function flowrsreplace($rs,$isv=0)
|
||||
{
|
||||
$statestr = '';
|
||||
$zt = $rs['state'];
|
||||
$rs['stateval'] = $zt;
|
||||
if($zt>0){
|
||||
if($zt=='2')$rs['trstyle']='font-weight:bold';
|
||||
if($zt=='1')$rs['ishui']='1';
|
||||
$ztrs = $this->getststrsssa($zt);
|
||||
if($ztrs)$statestr = '<font color="'.$ztrs['color'].'">'.$ztrs['name'].'</font>';
|
||||
}
|
||||
$rs['state'] = $statestr;
|
||||
return $rs;
|
||||
}
|
||||
|
||||
public function getststrsssa($zt)
|
||||
{
|
||||
$rs = false;
|
||||
$arrs = $this->statedatashow();
|
||||
foreach($arrs as $k1=>$rv1){
|
||||
if($rv1['value']==$zt){
|
||||
$rs = $rv1;
|
||||
}
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
|
||||
public function statedatashow()
|
||||
{
|
||||
$arr[] = array('name'=>'无状态','value'=>'0','color'=>'');
|
||||
$arr[] = array('name'=>'等待完成','value'=>'2','color'=>'red');
|
||||
$arr[] = array('name'=>'已完成','value'=>'1','color'=>'green');
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public function flowbillwhere($uid, $lx)
|
||||
{
|
||||
//排序
|
||||
return array(
|
||||
//'order' => '`state` desc, `id` desc'
|
||||
'order' => '`suodt` desc'
|
||||
);
|
||||
}
|
||||
}
|
||||
57
webmain/model/flow/bookModel.php
Normal file
57
webmain/model/flow/bookModel.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
class flow_bookClassModel extends flowModel
|
||||
{
|
||||
public function flowrsreplace($rs,$isv=0)
|
||||
{
|
||||
if(isset($rs['typeid']))$rs['typeid'] = $this->db->getmou('[Q]option','name',"`id`='".$rs['typeid']."'");
|
||||
return $rs;
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$where = '';
|
||||
$typeid = $this->rock->post('typeid','0');
|
||||
$key = $this->rock->post('key');
|
||||
if($typeid!='0'){
|
||||
$where .= ' and `typeid`='.$typeid.'';
|
||||
}
|
||||
//if($key != '')$where.=" and (`title` like '%$key%' or `author` like '%$key%')";
|
||||
return array(
|
||||
'where' => $where,
|
||||
'order' => 'optdt desc'
|
||||
);
|
||||
}
|
||||
|
||||
//导入数据的测试显示
|
||||
public function flowdaorutestdata()
|
||||
{
|
||||
return array(
|
||||
'typeid' => '计算机/编程',
|
||||
'title' => 'PHP从入门到放弃',
|
||||
'num' => 'TS-003',
|
||||
'author' => '磐石',
|
||||
'chuban' => '信呼开发团队',
|
||||
'cbdt' => '2017-01-17',
|
||||
'price' => '49.9',
|
||||
'shul' => '5',
|
||||
'weizhi' => '不知道',
|
||||
'isbn' => 'PANSHI-001',
|
||||
);
|
||||
}
|
||||
|
||||
//导入之前
|
||||
public function flowdaorubefore($rows)
|
||||
{
|
||||
$inarr = array();
|
||||
$num = 'booktype';
|
||||
if(ISMORECOM && $cnum=$this->adminmodel->getcompanynum())$num.='_'.$cnum.'';
|
||||
foreach($rows as $k=>$rs){
|
||||
$rs['typeid'] = $this->option->gettypeid($num,$rs['typeid']);
|
||||
$inarr[] = $rs;
|
||||
}
|
||||
|
||||
return $inarr;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
19
webmain/model/flow/bookborrowModel.php
Normal file
19
webmain/model/flow/bookborrowModel.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* 模块.图书借阅
|
||||
*/
|
||||
class flow_bookborrowClassModel extends flowModel
|
||||
{
|
||||
public function flowrsreplace($rs)
|
||||
{
|
||||
$fte = '<font color=red>否</font>';
|
||||
$isgh= 0;
|
||||
if(!isempt($rs['ghtime'])){
|
||||
$fte = '<font color=green>是</font>';
|
||||
$isgh= 1;
|
||||
}
|
||||
if($rs['isgh'] != $isgh)$this->update('`isgh`='.$isgh.'', $rs['id']);
|
||||
$rs['isgh'] = $fte;
|
||||
return $rs;
|
||||
}
|
||||
}
|
||||
56
webmain/model/flow/caigouModel.php
Normal file
56
webmain/model/flow/caigouModel.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
class flow_caigouClassModel extends flowModel
|
||||
{
|
||||
public $minwidth = 600;//子表最小宽
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
$this->goodsobj = m('goods');
|
||||
}
|
||||
|
||||
//审核完成处理,要通知仓库管理员出入库
|
||||
protected function flowcheckfinsh($zt){
|
||||
/*
|
||||
m('goodss')->update('status='.$zt.'',"`mid`='$this->id'");
|
||||
$aid = '0';
|
||||
$rows = m('goodss')->getall("`mid`='$this->id'",'aid');
|
||||
foreach($rows as $k=>$rs)$aid.=','.$rs['aid'].'';
|
||||
m('goods')->setstock($aid);
|
||||
*/
|
||||
}
|
||||
|
||||
//作废或删除时
|
||||
protected function flowzuofeibill($sm)
|
||||
{
|
||||
//删除入库详情的
|
||||
m('goodss')->delete("`mid`='$this->id'");
|
||||
}
|
||||
|
||||
|
||||
//子表数据替换处理
|
||||
protected function flowsubdata($rows, $lx=0){
|
||||
$db = m('goods');
|
||||
foreach($rows as $k=>$rs){
|
||||
$one = $db->getone($rs['aid']);
|
||||
if($one){
|
||||
$name = $one['name'];
|
||||
if(!isempt($one['xinghao']))$name.='('.$one['xinghao'].')';
|
||||
if($lx==1)$rows[$k]['aid'] = $name; //1展示时
|
||||
$rows[$k]['temp_aid'] = $name;
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
//$lx,0默认,1详情展示,2列表显示
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
$rs['states']= $rs['state'];
|
||||
$rs['state'] = $this->goodsobj->crkstate($rs['state']);
|
||||
//读取物品
|
||||
if($lx==2){
|
||||
$rs['wupinlist'] = $this->goodsobj->getgoodninfo($rs['id'], 1);
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
}
|
||||
26
webmain/model/flow/carmModel.php
Normal file
26
webmain/model/flow/carmModel.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
//车辆管理模块接口
|
||||
class flow_carmClassModel extends flowModel
|
||||
{
|
||||
public function initModel()
|
||||
{
|
||||
$this->statearr = c('array')->strtoarray('blue|办理中,green|可用,red|维修中,gray|报废');
|
||||
$this->publiarr = c('array')->strtoarray('gray|否,green|是');
|
||||
|
||||
$this->carms = m('carms');
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs)
|
||||
{
|
||||
if(isset($this->statearr[$rs['state']])){
|
||||
$b = $this->statearr[$rs['state']];
|
||||
$rs['state'] = '<font color="'.$b[0].'">'.$b[1].'</font>';
|
||||
}
|
||||
$b = $this->publiarr[$rs['ispublic']];
|
||||
$rs['ispublic'] = '<font color="'.$b[0].'">'.$b[1].'</font>';
|
||||
$rs['djshu'] = $this->carms->rows('carid='.$rs['id'].'');
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
41
webmain/model/flow/carmbyModel.php
Normal file
41
webmain/model/flow/carmbyModel.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
//车辆保养
|
||||
class flow_carmbyClassModel extends flowModel
|
||||
{
|
||||
|
||||
public function flowrsreplace($rs)
|
||||
{
|
||||
if(isset($rs['carnum'])){
|
||||
$ors = $rs;
|
||||
}else{
|
||||
$ors = m('carm')->getone($rs['carid']);
|
||||
}
|
||||
if($ors)$rs['carid'] = ''.$ors['carbrand'].','.$ors['carmode'].'('.$ors['carnum'].')';
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
//多个连表查询
|
||||
public function flowbillwhere($uid, $lx)
|
||||
{
|
||||
return array(
|
||||
'table' => '`[Q]'.$this->mtable.'` a left join `[Q]carm` b on a.carid=b.id left join `[Q]flow_bill` c on c.`table`=\''.$this->mtable.'\' and c.mid=a.id',
|
||||
'fields' => 'a.*,b.carnum,b.carbrand,b.carmode,cartype,c.uname as base_name,c.udeptname as base_deptname',
|
||||
'orlikefields' => 'b.carnum,b.carbrand,b.carmode,b.`cartype`,c.`udeptname`,c.`uname`,c.`sericnum`@1',
|
||||
'asqom' => 'a.'
|
||||
);
|
||||
}
|
||||
|
||||
//自定义审核人读取
|
||||
protected function flowcheckname($num){
|
||||
$sid = '';
|
||||
$sna = '';
|
||||
//驾驶员审核读取
|
||||
if($num=='jia'){
|
||||
$sid = $this->rs['jiaid'];
|
||||
$sna = $this->rs['jianame'];
|
||||
}
|
||||
return array($sid, $sna);
|
||||
}
|
||||
}
|
||||
46
webmain/model/flow/carmreseModel.php
Normal file
46
webmain/model/flow/carmreseModel.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
class flow_carmreseClassModel extends flowModel
|
||||
{
|
||||
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$where = '';
|
||||
//$key = $this->rock->post('key');
|
||||
//$dt = $this->rock->post('dt');
|
||||
//if($key != '')$where.=" and (`carnum`='$key' or `usename` like '%$key%' or `optname` like '%$key%')";
|
||||
//if($dt != '')$where.=" and (`applydt`='$dt' or `startdt` like '$dt%')";
|
||||
|
||||
return array(
|
||||
'where' => $where,
|
||||
'order' => 'optdt desc'
|
||||
);
|
||||
}
|
||||
|
||||
//自定义审核人读取
|
||||
protected function flowcheckname($num){
|
||||
$sid = '';
|
||||
$sna = '';
|
||||
//驾驶员审核读取
|
||||
if($num=='jias'){
|
||||
$sid = $this->rs['jiaid'];
|
||||
$sna = $this->rs['jianame'];
|
||||
}
|
||||
return array($sid, $sna);
|
||||
}
|
||||
|
||||
//可预定的车辆
|
||||
public function getcardata()
|
||||
{
|
||||
$where= $this->adminmodel->getcompanywhere(1);
|
||||
$rows = m('carm')->getall("`ispublic`=1 and `state`=1 ".$where."",'carnum as name,id as value');
|
||||
$arrs = $this->db->getrows('[Q]carmrese','`status`=1 group by carid','max(kmend)kmend,carid');
|
||||
$arrsa= array();
|
||||
foreach($arrs as $k=>$rs)$arrsa[$rs['carid']]=$rs['kmend'];
|
||||
//读取车辆最后公里数
|
||||
foreach($rows as $k=>$rs){
|
||||
$rows[$k]['kmstart'] = $this->rock->arrvalue($arrsa, $rs['value']);
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
85
webmain/model/flow/carmsModel.php
Normal file
85
webmain/model/flow/carmsModel.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
//车辆信息登记
|
||||
class flow_carmsClassModel extends flowModel
|
||||
{
|
||||
|
||||
|
||||
public function flowrsreplace($rs)
|
||||
{
|
||||
$ztname = '';
|
||||
if(!isempt($rs['enddt'])){
|
||||
$jg = c('date')->datediff('d', $this->rock->date, $rs['enddt']);
|
||||
if($jg<0){
|
||||
$ztname='<font color="#888888">已到期</font>';
|
||||
$rs['ishui'] = 1;
|
||||
}
|
||||
if($jg==0)$ztname='<font color="blue">今日到期</font>';
|
||||
if($jg>0 && $jg<30)$ztname='<font color="#ff6600">'.$jg.'天后到期</font>';
|
||||
if($jg>=30)$ztname='<font color="green">生效中</font>';
|
||||
}
|
||||
if(isset($rs['carnum'])){
|
||||
$ors = $rs;
|
||||
}else{
|
||||
$ors = m('carm')->getone($rs['carid']);
|
||||
}
|
||||
if($ors)$rs['carid'] = ''.$ors['carbrand'].','.$ors['carmode'].'('.$ors['carnum'].')';
|
||||
$rs['ztname'] = $ztname;
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
||||
public function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$where = '';
|
||||
$carid = (int)$this->rock->get('carid',0);
|
||||
if($carid>0)$where='and a.`carid`='.$carid.'';
|
||||
|
||||
return array(
|
||||
'table' => '`[Q]'.$this->mtable.'` a left join `[Q]carm` b on a.`carid`=b.id',
|
||||
'fields' => 'a.*,b.carnum,b.carbrand,b.carmode,cartype',
|
||||
'orlikefields' => 'b.carnum,b.carbrand,b.carmode,b.`cartype`,a.`otype`@1',
|
||||
'asqom' => 'a.',
|
||||
'where' => $where,
|
||||
);
|
||||
}
|
||||
|
||||
//每天信息提醒
|
||||
public function todocarms($toid)
|
||||
{
|
||||
if(isempt($toid))return '没设置提醒人员';
|
||||
$dt = $this->rock->date;
|
||||
$dt30 = c('date')->adddate($dt,'d', 30);
|
||||
$rows = $this->db->getall('select a.`enddt`,a.`otype`,b.`carnum` from `[Q]carms` a left join `[Q]carm` b on a.carid=b.id where b.id is not null and a.`enddt` is not null and a.`enddt`>=\''.$dt.'\'');
|
||||
$txlist = m('option')->getval('cartodo','0,3,7,15,30');
|
||||
$txarr = explode(',', $txlist);
|
||||
$dtobj = c('date');
|
||||
$cars = array();
|
||||
$str = '';
|
||||
foreach($rows as $k=>$rs){
|
||||
$jg = $dtobj->datediff('d', $dt, $rs['enddt']);
|
||||
if(in_array($jg, $txarr)){
|
||||
$strs = ''.$jg.'天后('.$rs['enddt'].')';
|
||||
if($jg==1)$strs='明天';
|
||||
if($jg==0)$strs='今天';
|
||||
$str .= ''.$rs['carnum'].'的['.$rs['otype'].']将在'.$strs.'到期;';
|
||||
}
|
||||
}
|
||||
|
||||
//下次保养提醒
|
||||
$rows = $this->db->getall('select a.`nextdt`,b.`carnum`,a.`jiaid`,a.`uid` from `[Q]carmang` a left join `[Q]carm` b on a.carid=b.id where b.id is not null and a.`type`=1 and a.`status`=1 and a.`nextdt` is not null and a.`nextdt`>=\''.$dt.'\'');
|
||||
|
||||
foreach($rows as $k=>$rs){
|
||||
$jg = $dtobj->datediff('d', $dt, $rs['nextdt']);
|
||||
if(in_array($jg, $txarr)){
|
||||
$strs = ''.$jg.'后('.$rs['nextdt'].')';
|
||||
if($jg==1)$strs='明天';
|
||||
if($jg==0)$strs='今天';
|
||||
$str .= ''.$rs['carnum'].'在'.$strs.'后需保养了;';
|
||||
}
|
||||
}
|
||||
if($str!=''){
|
||||
$this->push($toid, '车辆', $str, '车辆信息提醒');
|
||||
}
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
30
webmain/model/flow/carmwxModel.php
Normal file
30
webmain/model/flow/carmwxModel.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
//车辆维修
|
||||
class flow_carmwxClassModel extends flowModel
|
||||
{
|
||||
|
||||
|
||||
public function flowrsreplace($rs)
|
||||
{
|
||||
if(isset($rs['carnum'])){
|
||||
$ors = $rs;
|
||||
}else{
|
||||
$ors = m('carm')->getone($rs['carid']);
|
||||
}
|
||||
if($ors)$rs['carid'] = ''.$ors['carbrand'].','.$ors['carmode'].'('.$ors['carnum'].')';
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
||||
//多个连表查询
|
||||
public function flowbillwhere($uid, $lx)
|
||||
{
|
||||
return array(
|
||||
'table' => '`[Q]'.$this->mtable.'` a left join `[Q]carm` b on a.carid=b.id left join `[Q]flow_bill` c on c.`table`=\''.$this->mtable.'\' and c.mid=a.id',
|
||||
'fields' => 'a.*,b.carnum,b.carbrand,b.carmode,cartype,c.uname as base_name,c.udeptname as base_deptname',
|
||||
'orlikefields' => 'b.carnum,b.carbrand,b.carmode,b.`cartype`,c.`udeptname`,c.`uname`,c.`sericnum`@1',
|
||||
'asqom' => 'a.'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
43
webmain/model/flow/companyModel.php
Normal file
43
webmain/model/flow/companyModel.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* 单位管理
|
||||
*/
|
||||
class flow_companyClassModel extends flowModel
|
||||
{
|
||||
public $flowcompanyidfieds = 'none';
|
||||
public $baseall = array();
|
||||
|
||||
public function flowdeletebillbefore()
|
||||
{
|
||||
if($this->rows('pid='.$this->id.'')>0)return '有下级不允许删除';
|
||||
}
|
||||
|
||||
|
||||
public function getallbase()
|
||||
{
|
||||
if($this->baseall)return $this->baseall;
|
||||
$rows = $this->db->getall('show DATABASES');
|
||||
foreach($rows as $k=>$rs){
|
||||
$this->baseall[] = $rs['Database'];
|
||||
}
|
||||
return $this->baseall;
|
||||
}
|
||||
|
||||
//替换
|
||||
public function flowrsreplace($rs)
|
||||
{
|
||||
$iscreate = 0;
|
||||
if(!isempt($rs['num'])){
|
||||
$base = ''.DB_BASE.'_company_'.$rs['num'].'';
|
||||
$arr = $this->getallbase();
|
||||
if(in_array($base, $arr))$iscreate = 1;
|
||||
}
|
||||
if(isset($rs['iscreate']) && $iscreate!=$rs['iscreate'])$this->update('`iscreate`='.$iscreate.'', $rs['id']);
|
||||
$rs['iscreate'] = $iscreate;
|
||||
return $rs;
|
||||
}
|
||||
|
||||
public function testabc()
|
||||
{
|
||||
}
|
||||
}
|
||||
15
webmain/model/flow/custappyModel.php
Normal file
15
webmain/model/flow/custappyModel.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
//客户申请使用
|
||||
class flow_custappyClassModel extends flowModel
|
||||
{
|
||||
//流程全部完成后调用
|
||||
protected function flowcheckfinsh($zt)
|
||||
{
|
||||
if($zt==1){
|
||||
m('customer')->update(array(
|
||||
'isgh' => 0,
|
||||
'uid' => $this->uid
|
||||
),$this->rs['custid']);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
webmain/model/flow/custfinaModel.php
Normal file
49
webmain/model/flow/custfinaModel.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
//客户收付款单
|
||||
class flow_custfinaClassModel extends flowModel
|
||||
{
|
||||
|
||||
public function initModel(){
|
||||
$this->statearrs = c('array')->strtoarray('未收款|red,已收款|green');
|
||||
$this->statearrf = c('array')->strtoarray('未付款|red,已付款|green');
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs)
|
||||
{
|
||||
$starrr = array('收','付');
|
||||
$rs['paystatus'] = $rs['ispay'];
|
||||
$ispay = '<font color=red>未'.$starrr[$rs['type']].'款</font>';
|
||||
if($rs['ispay']==1)$ispay = '<font color=green>已'.$starrr[$rs['type']].'款</font>';
|
||||
$rs['ispay'] = $ispay;
|
||||
$rs['type'] = ''.$starrr[$rs['type']].'款单';
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
||||
//操作菜单操作
|
||||
protected function flowoptmenu($ors, $arr)
|
||||
{
|
||||
//标识已付款处理
|
||||
if($ors['num']=='pay'){
|
||||
$ispay = 0;
|
||||
$paydt = arrvalue($arr,'fields_paydt', $this->rock->now);
|
||||
if(!isempt($paydt))$ispay = 1;
|
||||
$this->update("`ispay`='$ispay',`paydt`='$paydt'", $this->id);
|
||||
m('crm')->ractmoney($this->rs['htid']);
|
||||
}
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$month = $this->rock->post('month');
|
||||
$where = '';
|
||||
if($month!=''){
|
||||
$where.=" and `dt` like '$month%'";
|
||||
}
|
||||
|
||||
return array(
|
||||
'where' => $where,
|
||||
'order' => '`optdt` desc'
|
||||
);
|
||||
}
|
||||
}
|
||||
49
webmain/model/flow/custfinbModel.php
Normal file
49
webmain/model/flow/custfinbModel.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
//客户收付款单
|
||||
class flow_custfinbClassModel extends flowModel
|
||||
{
|
||||
|
||||
public function initModel(){
|
||||
$this->statearrs = c('array')->strtoarray('未收款|red,已收款|green');
|
||||
$this->statearrf = c('array')->strtoarray('未付款|red,已付款|green');
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs)
|
||||
{
|
||||
$starrr = array('收','付');
|
||||
$rs['paystatus'] = $rs['ispay'];
|
||||
$ispay = '<font color=red>未'.$starrr[$rs['type']].'款</font>';
|
||||
if($rs['ispay']==1)$ispay = '<font color=green>已'.$starrr[$rs['type']].'款</font>';
|
||||
$rs['ispay'] = $ispay;
|
||||
$rs['type'] = ''.$starrr[$rs['type']].'款单';
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
||||
//操作菜单操作
|
||||
protected function flowoptmenu($ors, $arr)
|
||||
{
|
||||
//标识已付款处理
|
||||
if($ors['num']=='pay'){
|
||||
$ispay = 0;
|
||||
$paydt = arrvalue($arr,'fields_paydt', $this->rock->now);
|
||||
if(!isempt($paydt))$ispay = 1;
|
||||
$this->update("`ispay`='$ispay',`paydt`='$paydt'", $this->id);
|
||||
m('crm')->ractmoney($this->rs['htid']);
|
||||
}
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$month = $this->rock->post('month');
|
||||
$where = '';
|
||||
if($month!=''){
|
||||
$where.=" and `dt` like '$month%'";
|
||||
}
|
||||
|
||||
return array(
|
||||
'where' => $where,
|
||||
'order' => '`optdt` desc'
|
||||
);
|
||||
}
|
||||
}
|
||||
256
webmain/model/flow/customerModel.php
Normal file
256
webmain/model/flow/customerModel.php
Normal file
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
class flow_customerClassModel extends flowModel
|
||||
{
|
||||
public function initModel()
|
||||
{
|
||||
$this->statearr = c('array')->strtoarray('停用|#888888,启用|green');
|
||||
$this->statarr = c('array')->strtoarray('否|#888888,是|#ff6600');
|
||||
}
|
||||
|
||||
//高级搜索下
|
||||
public function flowsearchfields()
|
||||
{
|
||||
$arr[] = array('name'=>'所属人...','fields'=>'uid');
|
||||
$arr[] = array('name'=>'创建人...','fields'=>'createid');
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
if(isset($rs['status'])){
|
||||
if($rs['status']==0)$rs['ishui'] = 1;
|
||||
$zt = $this->statearr[$rs['status']];
|
||||
$rs['statuss'] = $rs['status'];
|
||||
$rs['status'] = '<font color="'.$zt[1].'">'.$zt[0].'</font>';
|
||||
}
|
||||
|
||||
if(isset($rs['isstat'])){
|
||||
$stat = $this->statarr[$rs['isstat']];
|
||||
$rs['isstat'] = '<font color="'.$stat[1].'">'.$stat[0].'</font>';
|
||||
}
|
||||
|
||||
if(isset($rs['isgys'])){
|
||||
$gys = $this->statarr[$rs['isgys']];
|
||||
$rs['isgys'] = '<font color="'.$gys[1].'">'.$gys[0].'</font>';
|
||||
}
|
||||
if($this->rock->arrvalue($rs,'htshu','0')==0)$rs['htshu']='';
|
||||
if($this->rock->arrvalue($rs,'moneyz','0')==0)$rs['moneyz']='';
|
||||
if($this->rock->arrvalue($rs,'moneyd','0')==0)$rs['moneyd']='';
|
||||
|
||||
if($lx==1){
|
||||
//$rs['suoname'] = $this->adminmodel->getmou('name','id='.$rs['uid'].'');
|
||||
|
||||
}
|
||||
|
||||
//详情时,移动端
|
||||
if($lx==1 && $this->rock->ismobile()){
|
||||
if(!isempt($rs['mobile']))$rs['mobile']='<a onclick="return callPhone(this)" href="tel:'.$rs['mobile'].'">'.$rs['mobile'].'</a>';
|
||||
if(!isempt($rs['tel']))$rs['tel']='<a onclick="return callPhone(this)" href="tel:'.$rs['tel'].'">'.$rs['tel'].'</a>';
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//是否有查看权限
|
||||
protected function flowisreadqx()
|
||||
{
|
||||
$bo = false;
|
||||
$shateid = ','.$this->rs['shateid'].',';
|
||||
if(contain($shateid,','.$this->adminid.','))$bo=true;
|
||||
return $bo;
|
||||
}
|
||||
|
||||
protected function flowgetfields_qiyong($lx)
|
||||
{
|
||||
$arr = array();
|
||||
if($this->uid==$this->adminid){
|
||||
$arr['mobile'] = '手机号';
|
||||
$arr['tel'] = '电话';
|
||||
$arr['email'] = '邮箱';
|
||||
$arr['routeline'] = '交通路线';
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
protected function flowoptmenu($ors, $crs)
|
||||
{
|
||||
$zt = $ors['statusvalue'];
|
||||
$num = $ors['num'];
|
||||
if($num=='ztqh'){
|
||||
$this->update('`status`='.$zt.'', $this->id);
|
||||
}
|
||||
|
||||
//共享
|
||||
if($num=='shate'){
|
||||
$cname = $crs['cname'];
|
||||
$cnameid = $crs['cnameid'];
|
||||
$this->update(array(
|
||||
'shateid' => $cnameid,
|
||||
'shate' => $cname,
|
||||
), $this->id);
|
||||
$this->push($cnameid, '客户管理', ''.$this->adminname.'将一个客户【{name}】共享给你');
|
||||
}
|
||||
|
||||
//取消共享
|
||||
if($num=='unshate'){
|
||||
$this->update(array(
|
||||
'shateid' => '',
|
||||
'shate' => '',
|
||||
), $this->id);
|
||||
}
|
||||
|
||||
//放入公海
|
||||
if($num=='ghnoup'){
|
||||
$this->update(array(
|
||||
'isgh' => '1',
|
||||
'uid' => 0,
|
||||
'suoname'=>''
|
||||
), $this->id);
|
||||
}
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
return array(
|
||||
'order' => '`status` desc,`optdt` desc',
|
||||
//'table' => '`[Q]'.$this->mtable.'` a left join `[Q]admin` b on a.`uid`=b.id',
|
||||
//'asqom' => 'a.',
|
||||
//'fields'=> 'a.*,b.name as suoname'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//导入数据的测试显示
|
||||
public function flowdaorutestdata()
|
||||
{
|
||||
$barr = array(
|
||||
'name' => '信呼',
|
||||
'type' => '软件',
|
||||
'laiyuan' => '网上开拓',
|
||||
'unitname' => '厦门信呼科技有限公司',
|
||||
'tel' => '0592-123456',
|
||||
'mobile' => '15800000000',
|
||||
'email' => 'admin@rockoa.com',
|
||||
'address' => '福建厦门思明区软件园',
|
||||
'linkname' => '磐石',
|
||||
'isgh' => '是',
|
||||
);
|
||||
$barr1 = array(
|
||||
'name' => '百度',
|
||||
'type' => '搜索计算',
|
||||
'laiyuan' => '电话联系',
|
||||
'unitname' => '百度在线网络技术(北京)有限公司',
|
||||
'tel' => '010-123456',
|
||||
'mobile' => '15800000001',
|
||||
'email' => 'admin@baidu.com',
|
||||
'address' => '北京软件园百度大厦',
|
||||
'linkname' => '李彦宏',
|
||||
'isgh' => '否',
|
||||
);
|
||||
$barr2 = array(
|
||||
'name' => '陈先生',
|
||||
'type' => '个人',
|
||||
'laiyuan' => '电话联系',
|
||||
'unitname' => '',
|
||||
'tel' => '010-123456',
|
||||
'mobile' => '15800000002',
|
||||
'email' => '1111@qq.com',
|
||||
'address' => '福建厦门火车站',
|
||||
'linkname' => '',
|
||||
'isgh' => '否',
|
||||
);
|
||||
return array($barr,$barr1,$barr2);
|
||||
}
|
||||
|
||||
public function flowdaorubefore($data)
|
||||
{
|
||||
$arr = array();
|
||||
$dbs = m('admin');
|
||||
foreach($data as $k=>$rs){
|
||||
$isgh = (arrvalue($rs,'isgh')=='是') ? 1: 0 ;
|
||||
$isstat = (arrvalue($rs,'isstat')=='是') ? 1: 0 ;
|
||||
if(isset($rs['status'])){
|
||||
$rs['status'] = (arrvalue($rs,'status')=='启用') ? 1: 0 ;
|
||||
}
|
||||
if(isset($rs['suoname'])){
|
||||
if($isgh==0){
|
||||
$urs = $dbs->geturs('name:'.$rs['suoname']);
|
||||
if($urs)$rs['uid'] = $urs['id'];
|
||||
}
|
||||
//unset($rs['suoname']);
|
||||
}
|
||||
$rs['isgh'] = $isgh;
|
||||
$rs['isstat'] = $isstat;
|
||||
if($isgh==1)$rs['uid'] = 0;
|
||||
|
||||
$arr[] = $rs;
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自动放入公海
|
||||
*/
|
||||
public function addgonghai()
|
||||
{
|
||||
$tshu = (int)$this->option->getval('crmaddghai','0');
|
||||
if($tshu<=0)return;
|
||||
$sneuar = array();
|
||||
|
||||
$rows = $this->getall('`uid`>0 and `htshu`=0 and `isgys`=0 and `id` not in(select `custid` from `[Q]custsale` where `state` in(1)) and `id` not in(select `custid` from `[Q]goodm` where `type`=2 and `status` in(0,1))','lastdt,optdt,id,name,uid,unitname');
|
||||
$dtobj = c('date');
|
||||
$addghs = array();
|
||||
foreach($rows as $k=>$rs){
|
||||
$lastdt = $rs['lastdt'];
|
||||
if(isempt($lastdt))$lastdt = $rs['optdt'];
|
||||
$jg = $dtobj->datediff('d', $lastdt, $this->rock->now);
|
||||
|
||||
if($jg > $tshu){
|
||||
$sneuar[$rs['uid']][] = '['.$rs['name'].']超'.$jg.'天未跟进已放入公海库';
|
||||
$addghs[] = $rs['id'];
|
||||
}else{
|
||||
//要放入之前2天提醒
|
||||
$ts = $tshu - $jg;
|
||||
if($ts<3)$sneuar[$rs['uid']][] = '['.$rs['name'].']将'.$ts.'天后放入公海库';
|
||||
}
|
||||
}
|
||||
|
||||
//通知给对应人
|
||||
$maxlen = 5;
|
||||
foreach($sneuar as $uid=>$ursa){
|
||||
$str = '';
|
||||
foreach($ursa as $k1=>$s1){
|
||||
if($str!='')$str.="\n";
|
||||
if($k1>=$maxlen){
|
||||
$str.='还有'.(count($ursa)-$maxlen).'条,点击查看更多';
|
||||
break;
|
||||
}
|
||||
$str.="".$s1."";
|
||||
}
|
||||
$this->pushs($uid, $str, '客户未跟进提醒', array(
|
||||
'wxurl' => $this->getwxurl()
|
||||
));
|
||||
}
|
||||
if($addghs){
|
||||
$sid = join(',', $addghs);
|
||||
$this->update("`uid`=0,`isgh`=1", "`id` in($sid)");
|
||||
}
|
||||
}
|
||||
|
||||
//对外的详情页
|
||||
public function flowopenxiang($da, $xiangdata)
|
||||
{
|
||||
$zdarr = array('name','type','laiyuan','unitname','tel','mobile','sheng','shi','address','routeline','shibieid','openbank','cardid','explain','linkname');
|
||||
$slsts = array();
|
||||
foreach($xiangdata as $k=>$rs){
|
||||
if(in_array($rs['fields'], $zdarr)){
|
||||
$slsts[] = $rs;
|
||||
}
|
||||
}
|
||||
return array('xiangdata'=>$slsts,'modename'=>'客户详情');
|
||||
}
|
||||
}
|
||||
36
webmain/model/flow/custplanModel.php
Normal file
36
webmain/model/flow/custplanModel.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
class flow_custplanClassModel extends flowModel
|
||||
{
|
||||
|
||||
//替换
|
||||
public function flowrsreplace($rs, $slx=0){
|
||||
|
||||
$zts = $rs['status'];
|
||||
$str = $this->getstatus($rs,'','',1);
|
||||
|
||||
$rs['statusval']= $zts;
|
||||
$rs['status'] = $str;
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
//计划跟进提醒(一条提醒一次)
|
||||
public function plantodo()
|
||||
{
|
||||
$date = $this->rock->date;
|
||||
$rows = $this->getall("`status`=0 and `plandt` like '".$date."%'");
|
||||
foreach($rows as $k=>$rs){
|
||||
$this->id = $rs['id'];
|
||||
$this->pushs($rs['uid'], '客户“'.$rs['custname'].'”需要在'.$rs['plandt'].'用“'.$rs['gentype'].'”跟进');
|
||||
}
|
||||
}
|
||||
|
||||
protected function flowoptmenu($ors, $crs)
|
||||
{
|
||||
if($ors['num']=='bywc'){
|
||||
$findt = arrvalue($this->rs, 'findt', $this->rock->now);
|
||||
m('customer')->update("`lastdt`='{$findt}'", $this->rs['custid']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
162
webmain/model/flow/custractModel.php
Normal file
162
webmain/model/flow/custractModel.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
class flow_custractClassModel extends flowModel
|
||||
{
|
||||
public function initModel(){
|
||||
$this->typearr = array('收款合同','付款合同');
|
||||
$this->typesarr = array('收','付');
|
||||
$this->statearr = c('array')->strtoarray('待生效|blue,生效中|green,已过期|#888888');
|
||||
$this->dtobj = c('date');
|
||||
$this->crmobj = m('crm');
|
||||
$this->goodmobj = m('goodm');
|
||||
|
||||
$this->wherejoin['custfina'] = 'htid';
|
||||
}
|
||||
|
||||
//作废或删除时
|
||||
protected function flowzuofeibill($sm)
|
||||
{
|
||||
m('goodm')->update('`custractid`=0', "`custractid`='".$this->id."'");//销售单取消关联合同
|
||||
|
||||
|
||||
|
||||
$xiaoid = (int)arrvalue($this->rs,'xiaoid','0');
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs, $lx=0){
|
||||
$type = $rs['type'];
|
||||
$rs['type'] = $this->typearr[$type];
|
||||
$statetext = '';
|
||||
$dt = $this->rock->date;
|
||||
$htstatus = 0;
|
||||
if($rs['startdt']>$dt){
|
||||
$statetext='待生效';
|
||||
}else if($rs['startdt']<=$dt && $rs['enddt']>=$dt){
|
||||
$jg = $this->dtobj->datediff('d', $dt, $rs['enddt']);
|
||||
$statetext='<font color=green>生效中</font><br><font color=#888888>'.$jg.'天过期</font>';
|
||||
if($jg==0)$statetext='<font color=green>今日到期</font>';
|
||||
$htstatus = 1;
|
||||
}else if($rs['enddt']<$dt){
|
||||
$statetext='<font color=#888888>已过期</font>';
|
||||
$rs['ishui'] = 1;
|
||||
$htstatus = 2;
|
||||
}
|
||||
$rs['statetext'] = $statetext;
|
||||
$nrss = $this->crmobj->ractmoney($rs);
|
||||
$ispay = $nrss[0];
|
||||
$moneys = $nrss[1];
|
||||
$dsmoney = '';
|
||||
$ts = $this->typesarr[$type];
|
||||
if($ispay==1){
|
||||
$dsmoney = '<font color=green>已全部'.$ts.'款</font>';
|
||||
}else{
|
||||
$dsmoney = '待'.$ts.'<font color=#ff6600>'.$moneys.'</font>';
|
||||
}
|
||||
if(isset($rs['xiaoid']) && $rs['xiaoid']>0){
|
||||
$xiaors = $this->goodmobj->getone("`id`='".$rs['xiaoid']."' and `status`<>5");
|
||||
if($xiaors){
|
||||
if($lx==1){
|
||||
$dsmoney.=',销售单:<a href="'.$this->getxiangurl('custxiao',$rs['xiaoid'],'auto').'">'.$xiaors['num'].'</a>';
|
||||
}else{
|
||||
$dsmoney.=',销售单:<br>'.$xiaors['num'].'';
|
||||
}
|
||||
}else{
|
||||
$this->update('`xiaoid`=0', $rs['id']);
|
||||
}
|
||||
}
|
||||
$rs['moneys'] = $dsmoney;
|
||||
$rs['htstatus'] = $htstatus;
|
||||
return $rs;
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
|
||||
$month = $this->rock->post('dt');
|
||||
$where = '';
|
||||
if($month!=''){
|
||||
$where =" and `signdt` like '$month%'";
|
||||
}
|
||||
|
||||
|
||||
return array(
|
||||
'where' => $where,
|
||||
'order' => '`optdt` desc',
|
||||
//'orlikefields' => 'custname'
|
||||
);
|
||||
}
|
||||
|
||||
protected function flowoptmenu($ors, $arrs)
|
||||
{
|
||||
//创建待收付款单
|
||||
if($ors['num']=='cjdaishou'){
|
||||
$moneys = m('crm')->getmoneys($this->rs['id']);
|
||||
$money = $this->rs['money'] - $moneys;
|
||||
if($money > 0){
|
||||
$arr['htid'] = $this->rs['id'];
|
||||
$arr['htnum'] = $this->rs['num'];
|
||||
$arr['uid'] = $this->rs['uid'];
|
||||
$arr['custid'] = $this->rs['custid'];
|
||||
$arr['custname']= $this->rs['custname'];
|
||||
$arr['dt'] = $this->rock->date;
|
||||
$arr['optdt'] = $this->rock->now;
|
||||
$arr['createdt']= $this->rock->now;
|
||||
$arr['optname'] = $this->adminname;
|
||||
$arr['createname']= $this->adminname;
|
||||
$arr['createid'] = $this->adminid;
|
||||
//$arr['optid'] = $this->adminid;
|
||||
$arr['type'] = $this->rs['type'];
|
||||
$arr['explain'] = $arrs['sm'];
|
||||
$arr['money'] = $money;
|
||||
m('custfina')->insert($arr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 客户合同到期提醒
|
||||
*/
|
||||
public function custractdaoqi()
|
||||
{
|
||||
$dt = $this->rock->date;
|
||||
$rows = $this->getall("status=1 and `enddt` is not null and `enddt`>='$dt'",'uid,num,custname,enddt','`uid`');
|
||||
$txlist = m('option')->getval('crmtodo','0,3,7,15,30');//提醒的时间
|
||||
$txarr = explode(',', $txlist);
|
||||
$dtobj = c('date');
|
||||
$txrows = array();
|
||||
foreach($rows as $k=>$rs){
|
||||
$jg = $dtobj->datediff('d', $dt, $rs['enddt']);
|
||||
$uid= $rs['uid'];
|
||||
if(in_array($jg, $txarr)){
|
||||
$strs = ''.$jg.'天后('.$rs['enddt'].')';
|
||||
if($jg==1)$strs='明天';
|
||||
if($jg==0)$strs='今天';
|
||||
if(!isset($txrows[$uid]))$txrows[$uid]='';
|
||||
$txrows[$uid] .= '客户['.$rs['custname'].']的[合同:'.$rs['num'].']将在'.$strs.'到期;';
|
||||
}
|
||||
}
|
||||
foreach($txrows as $uid=>$cont){
|
||||
$this->push($uid, '客户,CRM', $cont, '客户合同到期提醒');
|
||||
}
|
||||
}
|
||||
|
||||
//对外的详情页
|
||||
public function flowopenxiang($da, $xiangdata)
|
||||
{
|
||||
$zdarr = array('num','custname','type','fenlei','signdt','money','startdt','enddt','explain');
|
||||
$slsts = array();
|
||||
foreach($xiangdata as $k=>$rs){
|
||||
if(in_array($rs['fields'], $zdarr)){
|
||||
$slsts[] = $rs;
|
||||
}
|
||||
}
|
||||
//相关文件
|
||||
$filedata = array();
|
||||
$htfileid = arrvalue($da,'htfileid');
|
||||
if($htfileid){
|
||||
$filedata = m('file')->getall('id in('.$htfileid.')','id,filename,filesizecn,fileext');
|
||||
}
|
||||
return array('xiangdata'=>$slsts,'filedata'=>$filedata);
|
||||
}
|
||||
}
|
||||
55
webmain/model/flow/custsaleModel.php
Normal file
55
webmain/model/flow/custsaleModel.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
class flow_custsaleClassModel extends flowModel
|
||||
{
|
||||
public function initModel(){
|
||||
$this->statearr = c('array')->strtoarray('跟进中|blue,已成交|green,已丢失|#888888,暂缓|#ff6600');
|
||||
}
|
||||
|
||||
|
||||
public function flowrsreplace($rs)
|
||||
{
|
||||
$zt = $this->statearr[$rs['state']];
|
||||
$rs['statess'] = $rs['state'];
|
||||
$rs['state'] = '<font color="'.$zt[1].'">'.$zt[0].'</font>';
|
||||
if($rs['htid']>0)$rs['state'].=',<font color=#888888>并建立合同</font>';
|
||||
return $rs;
|
||||
}
|
||||
|
||||
protected function flowsubmit($na, $sm)
|
||||
{
|
||||
m('crm')->update('`lastdt`=now()', $this->rs['custid']);
|
||||
}
|
||||
|
||||
protected function flowoptmenu($ors, $crs)
|
||||
{
|
||||
$zt = $ors['statusvalue'];
|
||||
$num = $ors['num'];
|
||||
if($num=='ztqh'){
|
||||
$sarr['state'] = $zt;
|
||||
if($zt==1)$sarr['dealdt'] = $this->rock->now;
|
||||
$this->update($sarr, $this->id);
|
||||
}
|
||||
|
||||
if($num=='zhuan'){
|
||||
$cname = $crs['cname'];
|
||||
$cnameid = $crs['cnameid'];
|
||||
$this->update(array(
|
||||
'uid' => $cnameid,
|
||||
'optname' => $cname
|
||||
), $this->id);
|
||||
$this->push($cnameid, '客户销售', ''.$this->adminname.'将一个客户【{custname}】的一个销售单转移给你');
|
||||
}
|
||||
|
||||
if($num=='genjin' || $num=='ztqh'){
|
||||
m('crm')->update('`lastdt`=now()', $this->rs['custid']);
|
||||
}
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
return array(
|
||||
'order' => '`state`,`optdt` desc'
|
||||
);
|
||||
}
|
||||
}
|
||||
112
webmain/model/flow/custxiaoModel.php
Normal file
112
webmain/model/flow/custxiaoModel.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
class flow_custxiaoClassModel extends flowModel
|
||||
{
|
||||
public $minwidth = 600;//子表最小宽
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
$this->goodsobj = m('goods');
|
||||
$this->custractobj = m('custract');
|
||||
$this->crmobj = m('crm');
|
||||
}
|
||||
|
||||
public function flowxiangfields(&$fields)
|
||||
{
|
||||
$fields['base_name'] = '销售人';
|
||||
$fields['base_deptname'] = '销售人部门';
|
||||
$fields['base_sericnum'] = '销售单号';
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function flowsearchfields()
|
||||
{
|
||||
$arr[] = array('name'=>'销售人...','fields'=>'uid');
|
||||
return $arr;
|
||||
}
|
||||
|
||||
protected function flowsubmit($na, $sm)
|
||||
{
|
||||
$num = $this->sericnum;
|
||||
$this->update(array('num'=>$num),$this->id);
|
||||
m('custfina')->update("`htnum`='$num'", "`htid`='-".$this->id."'");
|
||||
}
|
||||
|
||||
//子表数据替换处理
|
||||
protected function flowsubdata($rows, $lx=0){
|
||||
$db = m('goods');
|
||||
foreach($rows as $k=>$rs){
|
||||
$one = $db->getone($rs['aid']);
|
||||
if($one){
|
||||
$name = $one['name'];
|
||||
if(!isempt($one['xinghao']))$name.='('.$one['xinghao'].')';
|
||||
if($lx==1)$rows[$k]['aid'] = $name; //1展示时
|
||||
$rows[$k]['temp_aid'] = $name;
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
//作废或删除时
|
||||
protected function flowzuofeibill($sm)
|
||||
{
|
||||
$this->custractobj->update('`xiaoid`=0', "`xiaoid`='".$this->id."'");//合同取消关联销售单
|
||||
|
||||
$this->update('`custractid`=0', $this->id);//取消关联合同
|
||||
|
||||
//删除关联收付款单
|
||||
$this->deletebilljoin('custfina',"`htid`='-".$this->id."'", $sm);
|
||||
|
||||
//删除出库详情的
|
||||
m('goodss')->delete("`mid`='$this->id'");
|
||||
}
|
||||
|
||||
//$lx,0默认,1详情展示,2列表显示
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
$rs['states']= $rs['state'];
|
||||
$rs['state'] = $this->goodsobj->crkstate($rs['state'],1);
|
||||
//读取物品
|
||||
if($lx==2){
|
||||
$rs['wupinlist'] = $this->goodsobj->getgoodninfo($rs['id'], 1);
|
||||
}
|
||||
|
||||
$custractid = (int)$rs['custractid'];
|
||||
|
||||
//读取收款状态
|
||||
$dsmoney = '';
|
||||
if($custractid>0){
|
||||
|
||||
//从合同那读取
|
||||
$htrs = $this->custractobj->getone('`id`='.$custractid.' and `status`<>5');
|
||||
if($htrs){
|
||||
$custractid = $htrs['num'];//读取合同编号
|
||||
if($lx==1)$custractid = '<a href="'.$this->getxiangurl('custract',$rs['custractid'],'auto').'">'.$custractid.'</a>';
|
||||
|
||||
$nrss = $this->crmobj->ractmoney($htrs);
|
||||
$ispay = $nrss[0];
|
||||
$moneys = $nrss[1];
|
||||
|
||||
if($ispay==1){
|
||||
$dsmoney = '<font color=green>已全部收款</font>';
|
||||
}else{
|
||||
$dsmoney = '待收<font color=#ff6600>'.$moneys.'</font>';
|
||||
}
|
||||
|
||||
}else{
|
||||
$custractid = 0;//不存在
|
||||
$this->update('`custractid`='.$custractid.'', $rs['id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($custractid===0){
|
||||
$custractid = '<font color=#aaaaaa>无关联</a>';
|
||||
$dsmoney = $this->crmobj->xiaozhuantai($rs);
|
||||
}
|
||||
$rs['custractid'] = $custractid;
|
||||
$rs['shoukuzt'] = $dsmoney;
|
||||
|
||||
|
||||
return $rs;
|
||||
}
|
||||
}
|
||||
32
webmain/model/flow/daibanModel.php
Normal file
32
webmain/model/flow/daibanModel.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
class flow_daibanClassModel extends flowModel
|
||||
{
|
||||
|
||||
/**
|
||||
* 每天流程待办提醒
|
||||
*/
|
||||
public function tododay()
|
||||
{
|
||||
$arr = array();
|
||||
$rows = $this->getrows('`status` not in(1,2) and `isturn`=1 and `isdel`=0 and `nowcheckid` is not null','`nowcheckid`,`modename`');
|
||||
foreach($rows as $k=>$rs){
|
||||
$dista = explode(',', $rs['nowcheckid']);
|
||||
foreach($dista as $distid){
|
||||
if(!isset($arr[$distid]))$arr[$distid] = array();
|
||||
if(!isset($arr[$distid][$rs['modename']]))$arr[$distid][$rs['modename']] = 0;
|
||||
$arr[$distid][$rs['modename']]++;
|
||||
}
|
||||
}
|
||||
foreach($arr as $uid => $strarr){
|
||||
$this->flowweixinarr['url'] = $this->getwxurl();//设置微信提醒的详情链接
|
||||
$str = '';
|
||||
$k = 0;
|
||||
foreach($strarr as $mod=>$sl){
|
||||
$k++;
|
||||
if($k>1)$str.="\n";
|
||||
$str.="".$k.".$mod(".$sl."条);";
|
||||
}
|
||||
if($str != '')$this->push($uid, '', $str, '流程待办处理');
|
||||
}
|
||||
}
|
||||
}
|
||||
297
webmain/model/flow/dailyModel.php
Normal file
297
webmain/model/flow/dailyModel.php
Normal file
@@ -0,0 +1,297 @@
|
||||
<?php
|
||||
class flow_dailyClassModel extends flowModel
|
||||
{
|
||||
public function initModel()
|
||||
{
|
||||
$this->typearr = explode(',','日报,周报,月报,年报');
|
||||
$this->logobj = m('log');
|
||||
}
|
||||
|
||||
protected function flowchangedata()
|
||||
{
|
||||
$this->rs['typess'] = $this->typearr[$this->rs['type']];
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
if($rs['mark']=='0')$rs['mark'] = '';
|
||||
$cfrom = $this->rock->get('cfrom');
|
||||
if($lx==2){
|
||||
if($cfrom!='mweb'){
|
||||
if(isset($rs['optdt']))$rs['optdt'] = str_replace(' ','<br>', $rs['optdt']);
|
||||
if(isset($rs['adddt']))$rs['adddt'] = str_replace(' ','<br>', $rs['adddt']);
|
||||
}
|
||||
|
||||
$zt = $this->logobj->isread('daily', $rs['id'], $this->adminid);
|
||||
|
||||
if($zt>0)$rs['ishui'] = 1;
|
||||
|
||||
|
||||
$dt = $rs['dt'];
|
||||
if($rs['type']!=0 && !isempt($rs['enddt']) && $cfrom!='mweb'){
|
||||
$dt.='<br><font color="#aaaaaa">'.$rs['enddt'].'</font>';
|
||||
}
|
||||
$rs['dt'] = $dt;
|
||||
}
|
||||
$this->replacepbr($rs, 'content');
|
||||
$rs['type'] = $this->typearr[$rs['type']];
|
||||
return $rs;
|
||||
}
|
||||
|
||||
//提交保存完日报通知上级
|
||||
protected function flowsubmit($na, $sm)
|
||||
{
|
||||
$uparr = m('admin')->getsuperman($this->uid);
|
||||
$recid = arrvalue($uparr, 0);
|
||||
if(!$recid || $recid==0)return;
|
||||
$typea = $this->typearr[$this->rs['type']];
|
||||
$title = ''.$this->rs['optname'].'的'.$typea.'';
|
||||
$cont = c('html')->substrstr($this->rs['content'],0, 100);
|
||||
$this->push($recid, '', "".$typea."日期:{dt}\n".$cont, $title);
|
||||
}
|
||||
|
||||
protected function flowaddlog($a)
|
||||
{
|
||||
if($a['name'] == '日报评分'){
|
||||
$fenshu = (int)$this->rock->post('fenshu','0');
|
||||
$this->push($this->rs['uid'], '', ''.$this->adminname.'评分你[{dt}]的{typess},分数('.$fenshu.')',''.$this->modename.'评分');
|
||||
$this->update(array(
|
||||
'mark' => $fenshu
|
||||
), $this->id);
|
||||
}
|
||||
if($a['name'] == '点评'){
|
||||
$this->nexttodo($this->uid, 'pinglun', $a['explain'], '点评');
|
||||
}
|
||||
}
|
||||
|
||||
protected function flowdatalog($arr)
|
||||
{
|
||||
$ispingfen = 0;
|
||||
$barr = m('admin')->getsuperman($this->uid); //获取我的上级主管
|
||||
if($barr){
|
||||
$hes = $barr[0];
|
||||
if(contain(','.$hes.',',','.$this->adminid.','))$ispingfen = 1; //是否可以评分
|
||||
}
|
||||
$arr['ispingfen'] = $ispingfen;
|
||||
$arr['mark'] = $this->rs['mark'];
|
||||
return $arr;
|
||||
}
|
||||
|
||||
protected function flowgetoptmenu($opt)
|
||||
{
|
||||
//if($this->uid==$this->adminid)return false;
|
||||
$to = m('log')->isread($this->mtable, $this->id);
|
||||
return $to<=0;
|
||||
}
|
||||
|
||||
protected function flowoptmenu($ors, $crs)
|
||||
{
|
||||
$table = $this->mtable;
|
||||
$mid = $this->id;
|
||||
$uid = $this->adminid;
|
||||
$lx = $ors['num'];
|
||||
$log = m('log');
|
||||
if($lx=='yd'){
|
||||
$log->addread($table, $mid, $uid);
|
||||
}
|
||||
if($lx=='allyd'){
|
||||
$ydid = $log->getread($table, $uid);
|
||||
$where = m('view')->viewwhere($this->modeid, $uid);
|
||||
$where = "((1=1 $where) or (`uid`='$uid') )";
|
||||
$where = "`id` not in($ydid) and $where";
|
||||
|
||||
$rows = m($table)->getrows($where,'id');
|
||||
foreach($rows as $k=>$rs)$log->addread($table, $rs['id'], $uid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function flowprintrows($rows)
|
||||
{
|
||||
foreach($rows as $k=>$rs){
|
||||
$rows[$k]['plan_style'] = 'text-align:left';
|
||||
$rows[$k]['content'] = str_replace("\n",'<br>', $rs['content']);
|
||||
$rows[$k]['plan'] = str_replace("\n",'<br>', $rs['plan']);
|
||||
$rows[$k]['type'] = $this->typearr[$rs['type']];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
//条件过滤已从流程模块条件下设置
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$type = $this->rock->post('type');
|
||||
$key = $this->rock->post('key');
|
||||
$dt = $this->rock->post('dt');
|
||||
$where = '';
|
||||
$keywhere = '';
|
||||
|
||||
|
||||
if(!isempt($type))$where.=" and a.`type`='$type'";
|
||||
if(!isempt($dt))$where.=" and a.`dt` like '$dt%'";
|
||||
|
||||
if(!isempt($key))$keywhere=m('admin')->getkeywhere($key, 'b.', "or a.`content` like '%$key%'");
|
||||
|
||||
return array(
|
||||
'table' => '`[Q]daily` a left join `[Q]admin` b on a.`uid`=b.`id`',
|
||||
'fields'=> 'a.*,b.`name`,b.`deptname`',
|
||||
'where' => $where,
|
||||
'keywhere' => $keywhere,
|
||||
'asqom' => 'a.', //主表别名
|
||||
'order' => 'a.`optdt` desc'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 日报分析
|
||||
*/
|
||||
public function dailyanay($uid=0, $month='')
|
||||
{
|
||||
$dto = c('date');
|
||||
if($month=='')$month = $this->rock->date;
|
||||
$mon = substr($month,0, 7);
|
||||
$start = $mon.'-01';
|
||||
$enddt = $dto->getenddt($mon);
|
||||
$jg = $dto->getmaxdt($start);
|
||||
$dtarr = $dailydt = $leavedt = $zhoubdt = array();
|
||||
for($i=1; $i<=$jg; $i++){
|
||||
$oi = ''.$i.'';
|
||||
if($i<10)$oi= '0'.$i.'';
|
||||
$dt = $mon.'-'.$oi.'';
|
||||
if($dt>=$this->rock->date)break;
|
||||
$dtarr[] = array($dt, strtotime($dt));
|
||||
}
|
||||
$kql = m('kaoqin');
|
||||
$dbfx = m('dailyfx');
|
||||
$where = m('admin')->monthuwheres($start, $enddt);
|
||||
if($uid!=0)$where="and `id`='$uid'";
|
||||
$urows = m('userinfo')->getall("1=1 $where", 'id,name,workdate,quitdt,isdaily');
|
||||
|
||||
//日报
|
||||
$dailya = $this->getall("`type`=0 and `dt` like '$mon%' group by `uid`,`dt`",'`uid`,`dt`');
|
||||
foreach($dailya as $k=>$rs){
|
||||
$dailydt['a'.$rs['uid'].'_'.$rs['dt'].''] = 1;
|
||||
}
|
||||
|
||||
//周报
|
||||
$dailya = $this->getall("`type`=1 and `adddt` like '$mon%'",'`uid`,`adddt`');
|
||||
foreach($dailya as $k=>$rs){
|
||||
$zhoubdt['a'.$rs['uid'].'_'.substr($rs['adddt'],0,10).''] = 1;
|
||||
}
|
||||
|
||||
|
||||
//读取是不是全天请假(这种情况无法统计,全天请假写了2个上午和下午的请假条,下次改进)
|
||||
$qjarr = $this->db->getall("select `stime`,`etime`,`uid` from `[Q]kqinfo` where `status`=1 and `kind`='请假' and `etime`>='$start' and `stime`<='$enddt' ");
|
||||
if($qjarr){
|
||||
foreach($qjarr as $k=>$rs){
|
||||
$qjarr[$k]['stimes'] = strtotime($rs['stime']);
|
||||
$qjarr[$k]['etimes'] = strtotime($rs['etime']);
|
||||
}
|
||||
foreach($dtarr as $d1=>$dtss){
|
||||
$dt = $dtss[0];
|
||||
foreach($qjarr as $k=>$rs){
|
||||
$uid = $rs['uid'];
|
||||
$sbdt = $kql->getsbstr($uid, $dt);
|
||||
|
||||
if($rs['stimes']<=$sbdt['stimes'] && $rs['etimes']>=$sbdt['etimes']){
|
||||
$leavedt['a'.$uid.'_'.$dt.''] = 1; //全天请假
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($urows as $k=>$urs){
|
||||
$totaly = 0;//应写
|
||||
$totalx = 0;//已写次数
|
||||
$totalw = 0;//未写次数
|
||||
$dtjoin = '';
|
||||
$uid = $urs['id'];
|
||||
$dtarra = array();
|
||||
$ruzd = 0;$lzzt = 9999999999999;
|
||||
if(!isempt($urs['workdate']))$ruzd = strtotime($urs['workdate']);
|
||||
if(!isempt($urs['quitdt']))$lzzt = strtotime($urs['quitdt']);
|
||||
|
||||
$uarr = array(
|
||||
'uid' => $uid,
|
||||
'month' => $mon,
|
||||
'optdt' => $this->rock->now
|
||||
);
|
||||
foreach($dtarr as $d1=>$dtss){
|
||||
$dt = $dtss[0];
|
||||
$d = $d1+1;
|
||||
$zt = 0; //0未写,1已写,2请假,3休息日,4没入职或已离职,5不需要写日报,时间还没到,6写周报了
|
||||
|
||||
//入职离职判断
|
||||
if($dtss[1]<$ruzd || $dtss[1]>$lzzt){
|
||||
$uarr['day'.$d.''] = 4;
|
||||
continue;
|
||||
}
|
||||
|
||||
$keys = 'a'.$uid.'_'.$dt.'';
|
||||
|
||||
$xbo = true;
|
||||
$iswork = $kql->isworkdt($uid, $dt);
|
||||
if($iswork==0){
|
||||
$zt = 3;
|
||||
if(isset($dailydt[$keys])){
|
||||
$zt = 1;
|
||||
}
|
||||
}else{
|
||||
|
||||
if(isset($leavedt[$keys])){
|
||||
$zt = 2;
|
||||
}else{
|
||||
$totaly++;
|
||||
}
|
||||
if(isset($dailydt[$keys])){
|
||||
$zt = 1;
|
||||
}
|
||||
if($zt==0 && isset($zhoubdt[$keys])){
|
||||
$zt = 6;//写周报了
|
||||
}
|
||||
if($zt==0){
|
||||
if($urs['isdaily']==0){
|
||||
$zt = 5;
|
||||
}else{
|
||||
$totalw++;//没写没请假
|
||||
}
|
||||
}
|
||||
}
|
||||
$uarr['day'.$d.''] = $zt;
|
||||
}
|
||||
|
||||
$totalx = $totaly - $totalw;
|
||||
$uarr['totaly'] = $totaly;
|
||||
$uarr['totalx'] = $totalx;
|
||||
$uarr['totalw'] = $totalw;
|
||||
|
||||
$where = "`uid`='$uid' and `month`='$mon'";
|
||||
if($dbfx->rows($where)==0)$where = '';
|
||||
|
||||
$dbfx->record($uarr, $where);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 未写日报通知
|
||||
* return 未写人员如:貂蝉(人事部),大乔(开发部)
|
||||
*/
|
||||
public function dailytodo($dt='')
|
||||
{
|
||||
if($dt=='')$dt = $this->rock->date;
|
||||
$dta = explode('-', $dt);
|
||||
$month = substr($dt, 0,7);
|
||||
$d = (int)$dta[2];
|
||||
$rows= $this->db->getall("select a.`id`,a.`name`,a.`deptname`,b.`day".$d."` from `[Q]admin` a left join `[Q]dailyfx` b on a.`id`=b.`uid` and b.`month`='$month' where a.`status`=1 and b.`day".$d."`=0");
|
||||
$w = c('date')->cnweek($dt);
|
||||
$cont= '你昨天['.$dt.',周'.$w.']的'.$this->modename.'未写,请及时补充填写。';
|
||||
$receid = '';
|
||||
foreach($rows as $k=>$rs){
|
||||
$receid.=','.$rs['id'].'';
|
||||
}
|
||||
$this->flowweixinarr = array(
|
||||
'url' => $this->getwxurl()
|
||||
);
|
||||
if($receid!='')$this->push(substr($receid, 1),'', $cont, ''.$this->modename.'未写提醒');
|
||||
}
|
||||
}
|
||||
19
webmain/model/flow/demoModel.php
Normal file
19
webmain/model/flow/demoModel.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
//演示模块的接口文件
|
||||
class flow_demoClassModel extends flowModel
|
||||
{
|
||||
protected function flowcoursejudge($num){
|
||||
|
||||
}
|
||||
|
||||
//默认返回就是前缀
|
||||
public function ABCYmd($num)
|
||||
{
|
||||
return 'QOM-';
|
||||
return array(
|
||||
'qom' => 'AExeeCC-',
|
||||
'wshu' => 5,
|
||||
'bom' => '-LLL'
|
||||
);
|
||||
}
|
||||
}
|
||||
11
webmain/model/flow/deptModel.php
Normal file
11
webmain/model/flow/deptModel.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
//部门的
|
||||
class flow_deptClassModel extends flowModel
|
||||
{
|
||||
//删除之前判断
|
||||
protected function flowdeletebillbefore()
|
||||
{
|
||||
if(m('admin')->rows($this->rock->dbinstr('deptpath',$this->id,'[',']'))>0)return '部门下有用户不允许删除';
|
||||
if($this->rows('pid='.$this->id.'')>0)return '有下级部门不允许删除';
|
||||
}
|
||||
}
|
||||
51
webmain/model/flow/diaoboModel.php
Normal file
51
webmain/model/flow/diaoboModel.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
//调拨单
|
||||
class flow_diaoboClassModel extends flowModel
|
||||
{
|
||||
public $minwidth = 600;//子表最小宽
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
$this->goodsobj = m('goods');
|
||||
$this->cangobj = m('godepot');
|
||||
}
|
||||
|
||||
//审核完成处理,要通知仓库管理员出入库
|
||||
protected function flowcheckfinsh($zt){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//子表数据替换处理
|
||||
protected function flowsubdata($rows, $lx=0){
|
||||
$db = m('goods');
|
||||
foreach($rows as $k=>$rs){
|
||||
$one = $db->getone($rs['aid']);
|
||||
if($one){
|
||||
$name = $one['name'];
|
||||
if(!isempt($one['xinghao']))$name.='('.$one['xinghao'].')';
|
||||
if($lx==1)$rows[$k]['aid'] = $name; //1展示时
|
||||
$rows[$k]['temp_aid'] = $name;
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
//$lx,0默认,1详情展示,2列表显示
|
||||
public function flowrsreplace($rs,$lx=0)
|
||||
{
|
||||
$rs['states']= $rs['state'];
|
||||
$rs['state'] = $this->goodsobj->crkstate($rs['state']);
|
||||
if(!isempt($rs['custname'])){
|
||||
$rs['custid'] = $rs['custname'];
|
||||
}else{
|
||||
$rs['custid']= $this->cangobj->getmou('depotname', $rs['custid']);
|
||||
}
|
||||
|
||||
//读取物品
|
||||
if($lx==2){
|
||||
$rs['wupinlist'] = $this->goodsobj->getgoodninfo($rs['id'], 1);
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
}
|
||||
246
webmain/model/flow/emailmModel.php
Normal file
246
webmain/model/flow/emailmModel.php
Normal file
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
class flow_emailmClassModel extends flowModel
|
||||
{
|
||||
|
||||
private $readunarr = array();//未读人员
|
||||
|
||||
//判断是否有读取权限
|
||||
protected function flowisreadqx()
|
||||
{
|
||||
$to = m('emails')->rows('`mid`='.$this->id.' and `uid`='.$this->adminid.'');
|
||||
return $to>0;
|
||||
}
|
||||
|
||||
//删除时
|
||||
protected function flowdeletebill($sm)
|
||||
{
|
||||
m('emails')->delete('`mid`='.$this->id.'');
|
||||
}
|
||||
|
||||
protected function flowoptmenu($ors, $crs)
|
||||
{
|
||||
//撤回未读的
|
||||
if($ors['num']=='chemail'){
|
||||
$where = '`mid`='.$this->id.' and `type`<>2 and `zt`=0';
|
||||
$drows = m('emails')->getall($where);
|
||||
m('emails')->delete($where);
|
||||
$uids = '0';
|
||||
foreach($drows as $k1=>$rs1)$uids.=','.$rs1['uid'].'';
|
||||
m('todo')->deltodo($this->modenum, $this->id, $uids);
|
||||
}
|
||||
}
|
||||
|
||||
protected function flowgetoptmenu($opt)
|
||||
{
|
||||
if($opt=='chemail'){
|
||||
$to = $this->flogmodel->rows("".$this->mwhere." and `name`='撤回'");
|
||||
if($to>0)return false;
|
||||
}
|
||||
}
|
||||
|
||||
//立即发送提醒
|
||||
protected function flowsubmit($na, $sm)
|
||||
{
|
||||
if($this->rs['isturn']==1 && $this->rs['type']==0){
|
||||
$h = c('html');
|
||||
$cont = $h->htmlremove($this->rs['content']);
|
||||
$cont = $h->substrstr($cont,0, 50);
|
||||
$receid = $this->rs['receid'];
|
||||
if(!isempt($this->rs['ccid']))$receid.=','.$this->rs['ccid'];
|
||||
$this->push($receid, '邮件', $cont.'...', $this->rs['title']);
|
||||
}
|
||||
}
|
||||
|
||||
//重写方法将邮件标识已读邮件了
|
||||
protected function flowdatalog($arr)
|
||||
{
|
||||
$where = '`mid`='.$this->id.' and `uid`='.$this->adminid.'';
|
||||
$dbs = m('emails');
|
||||
$dbs->update('`zt`=1', $where);
|
||||
//判断我是否可以回复
|
||||
$ishuifu = 0;
|
||||
$readunarr = array();
|
||||
if($this->rs['isturn']==1){
|
||||
$tos = $dbs->rows($where.' and `type` in(0,1)');
|
||||
if($tos>0)$ishuifu = 1;
|
||||
|
||||
//读取未读人员
|
||||
$uids = '';
|
||||
$uarrs = $dbs->getall('`mid`='.$this->id.' and `zt`=0 and `type` in(0,1) and `isdel`=0');
|
||||
foreach($uarrs as $k=>$rs)$uids.=','.$rs['uid'].'';
|
||||
if($uids!='')$readunarr = $this->adminmodel->getuserinfo(substr($uids,1));
|
||||
|
||||
}
|
||||
|
||||
$arr['ishuifu'] = $ishuifu;
|
||||
$arr['readunarr'] = $readunarr;
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
private function dtssss($dt)
|
||||
{
|
||||
$cnw = c('date')->cnweek($dt);
|
||||
return date('Y年m月d日(星期'.$cnw.')H:i:s',strtotime($dt));
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
$rs['senddt'] = $this->dtssss($rs['senddt']);
|
||||
if($lx == 1 && $rs['hid']>0){
|
||||
$rs['oldcontent'] = $this->getoldcont($rs['hid']);
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取原来邮件内容
|
||||
*/
|
||||
public function getoldcont($hid, $bo=true)
|
||||
{
|
||||
$hid = (int)$hid;
|
||||
if($hid==0)return '';
|
||||
$hrs = $this->getone($hid);
|
||||
if(!$hrs)return '';
|
||||
$dts = $this->dtssss($hrs['senddt']);
|
||||
$fstr = m('file')->getstr($this->mtable, $hrs['id'], 1);
|
||||
$s = '<div style="color:#888888;font-size:12px;margin-top:20px">------------------ 原始邮件 ------------------</div>';
|
||||
$s.= '<div style="font-size: 12px;background:#efefef;padding:8px;line-height:18px;">发件人: '.$hrs['sendname'].'<br>
|
||||
发送时间: '.$dts.'<br>
|
||||
收件人: '.$hrs['recename'].'<br>
|
||||
主题: '.$hrs['title'].'</div>';
|
||||
$s.= '<div style="margin-top:10px">'.$hrs['content'].'<br>'.$fstr.'</div>';
|
||||
if($bo)$s.= $this->getoldcont($hrs['hid'], $bo);
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$where = '1=2';
|
||||
$onwhere= '';
|
||||
$key = $this->rock->post('key');
|
||||
$dt = $this->rock->post('dt');
|
||||
$dbs = m('emailm');
|
||||
|
||||
//所有邮件
|
||||
if($lx=='' || $lx=='def' || $lx=='sjx'){
|
||||
$where = $dbs->gettowhere($uid, 0);
|
||||
}
|
||||
|
||||
//未读邮件
|
||||
if($lx=='wdyj'){
|
||||
$where = $dbs->gettowhere($uid, 1);
|
||||
}
|
||||
|
||||
//草稿箱
|
||||
if($lx == 'cgx'){
|
||||
$where = $dbs->gettowhere($uid, 2);
|
||||
}
|
||||
|
||||
//已发送
|
||||
if($lx == 'yfs'){
|
||||
$where = $dbs->gettowhere($uid, 3);
|
||||
}
|
||||
|
||||
//已删除
|
||||
if($lx == 'ysc'){
|
||||
$where = $dbs->gettowhere($uid, 4);
|
||||
}
|
||||
|
||||
if(!isempt($key))$where.=" and (a.`title` like '%$key%' or a.`recename` like '%$key%' or a.`sendname` like '%$key%')";
|
||||
if(!isempt($dt))$where.=" and a.`senddt` like '$dt%'";
|
||||
|
||||
return array(
|
||||
'where' => 'and '.$where,
|
||||
'fields'=> 'a.`id`,a.`title`,a.`sendname`,a.`recename`,a.`senddt`,a.`isfile`,b.`ishui`,b.`zt`,a.`outzt`,a.`type`',
|
||||
'order' => 'a.`senddt` desc',
|
||||
'table' => '`[Q]emailm` a left join `[Q]emails` b on a.`id`=b.`mid` '.$onwhere.''
|
||||
);
|
||||
}
|
||||
|
||||
private function getmid($uid, $type, $isdel=0)
|
||||
{
|
||||
$rows = m('emails')->getrows('`uid`='.$uid.' and `type` in('.$type.') and `isdel`='.$isdel.'','`mid`');
|
||||
$ids = '0';
|
||||
foreach($rows as $k=>$rs)$ids.=','.$rs['mid'].'';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
public function savesubmid($tuid, $mid, $type, $zt=0)
|
||||
{
|
||||
$now = $this->rock->now;
|
||||
if(is_numeric($tuid)){
|
||||
$uids = $tuid;
|
||||
}else{
|
||||
$uids = m('admin')->gjoin($tuid);
|
||||
}
|
||||
if($uids!=''){
|
||||
$this->db->insert('[Q]emails','mid,uid,email,personal,type,optdt,zt',"select '$mid',id,email,name,'$type','$now','$zt' from `[Q]admin` where id in($uids)", true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮件回复
|
||||
* $cont 回复内容
|
||||
*/
|
||||
public function huifu($cont)
|
||||
{
|
||||
$rs = $this->rs;
|
||||
$rers = $this->gethuifuarr();
|
||||
if(!$rers)return '没有发送人';
|
||||
$cont = str_replace("\n", '<br>', $cont);
|
||||
$arr['title'] = '回复:'.$rs['title'].'';
|
||||
$arr['content'] = $cont;
|
||||
$arr['sendid'] = $this->adminid;
|
||||
$arr['uid'] = $this->adminid;
|
||||
$arr['sendname'] = $this->adminname;
|
||||
$arr['senddt'] = $this->rock->now;
|
||||
$arr['applydt'] = $this->rock->date;
|
||||
$arr['hid'] = $this->id;
|
||||
$arr['type'] = $rs['type'];
|
||||
$arr['receid'] = $rers['uid'];
|
||||
$arr['recename'] = $rers['personal'];
|
||||
$arr['isturn'] = 1;
|
||||
$arr['outzt'] = 0;
|
||||
$arr['toemail'] = ''.$rers['personal'].'('.$rers['email'].')';
|
||||
$arr['optdt'] = $this->rock->now;
|
||||
|
||||
|
||||
$id = $this->insert($arr);
|
||||
$sarr['mid'] = $id;
|
||||
$sarr['uid'] = $rers['uid'];
|
||||
$sarr['type'] = 0;
|
||||
$sarr['optdt'] = $this->rock->now;
|
||||
$sarr['email'] = $rers['email'];
|
||||
$sarr['personal'] = $rers['personal'];
|
||||
m('emails')->insert($sarr);
|
||||
$this->savesubmid($arr['sendid'], $id, 2,1);
|
||||
|
||||
m('emails')->update('ishui=1','`mid`='.$this->id.' and `uid`='.$this->adminid.' and `type`=0');//更新已回复
|
||||
//需要外发
|
||||
if($rs['type']==1 && !isempt($rers['email'])){
|
||||
$cont = $arr['content'];
|
||||
$cont .= $this->getoldcont($this->id, false);
|
||||
m('email')->sendemailout($this->adminid, array(
|
||||
'title' => $arr['title'],
|
||||
'body' => $cont,
|
||||
'receemail' => $rers['email'],
|
||||
'recename' => $arr['recename'],
|
||||
'mid' => $id,
|
||||
));
|
||||
}
|
||||
|
||||
$this->loaddata($id, false);
|
||||
$this->submit('回复');
|
||||
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
//获取要回复的接收人
|
||||
public function gethuifuarr()
|
||||
{
|
||||
$rs = m('emails')->getone('`mid`='.$this->id.' and `type`=2');
|
||||
return $rs;
|
||||
}
|
||||
}
|
||||
6
webmain/model/flow/finfybxModel.php
Normal file
6
webmain/model/flow/finfybxModel.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
class flow_finfybxClassModel extends flowModel
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
87
webmain/model/flow/finpiaoModel.php
Normal file
87
webmain/model/flow/finpiaoModel.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
//发票管理
|
||||
class flow_finpiaoClassModel extends flowModel
|
||||
{
|
||||
|
||||
public $defaultorder = 'opendt,desc';
|
||||
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$month = $this->rock->post('month');
|
||||
$where = '';
|
||||
if($month!=''){
|
||||
$where.=" and `opendt` like '$month%'";
|
||||
}
|
||||
|
||||
return array(
|
||||
'where' => $where
|
||||
);
|
||||
}
|
||||
|
||||
//导入数据的测试显示
|
||||
public function flowdaorutestdata()
|
||||
{
|
||||
$barr[] = array(
|
||||
'type' => '收到的发票',
|
||||
'ptype' => '增值税普通发票',
|
||||
'kainame' => '张三',
|
||||
'money' => '50',
|
||||
'custname' => '销售单位',
|
||||
'maicustname' => '购买单位',
|
||||
'daima' => '',
|
||||
'haoma' => '',
|
||||
'opendt' => '2017-01-17',
|
||||
'explain' => '说明',
|
||||
);
|
||||
|
||||
$barr[] = array(
|
||||
'type' => '开出去的发票',
|
||||
'ptype' => '增值税普通发票',
|
||||
'kainame' => '张三',
|
||||
'money' => '500',
|
||||
'custname' => '销售单位',
|
||||
'maicustname' => '购买单位',
|
||||
'daima' => '',
|
||||
'haoma' => '',
|
||||
'opendt' => '2017-01-17',
|
||||
'explain' => '说明客户买了啥给他开了发票',
|
||||
);
|
||||
return $barr;
|
||||
}
|
||||
|
||||
//导入之前处理,必须添加客户
|
||||
public function flowdaorubefore($rows)
|
||||
{
|
||||
$inarr = array();
|
||||
$crmdb = m('crm');
|
||||
foreach($rows as $k=>$rs){
|
||||
|
||||
$arr = $rs;
|
||||
$custname = $rs['custname'];
|
||||
$custrs = $crmdb->getcustomer($custname);
|
||||
if(!$custrs)return '行'.($k+1).'销售方名称【'.$custname.'】不存在,请先建客户档案';
|
||||
$arr['custid'] = $custrs['id'];
|
||||
|
||||
$maicustname = $rs['maicustname'];
|
||||
$custrs1 = $crmdb->getcustomer($maicustname);
|
||||
if(!$custrs1)return '行'.($k+1).'购买方名称【'.$maicustname.'】不存在,请先建客户档案';
|
||||
$arr['maicustid'] = $custrs1['id'];
|
||||
|
||||
|
||||
$type = 1; //收到的发票
|
||||
if(contain($rs['type'],'开出去'))$type=0;//开出去发票
|
||||
$arr['type'] = $type;
|
||||
$arr['status'] = 1;
|
||||
$inarr[] = $arr;
|
||||
}
|
||||
return $inarr;
|
||||
}
|
||||
}
|
||||
15
webmain/model/flow/flow.php
Normal file
15
webmain/model/flow/flow.php
Normal file
File diff suppressed because one or more lines are too long
257
webmain/model/flow/gongModel.php
Normal file
257
webmain/model/flow/gongModel.php
Normal file
@@ -0,0 +1,257 @@
|
||||
<?php
|
||||
class flow_gongClassModel extends flowModel
|
||||
{
|
||||
private $readunarr = array();//未读人员
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
$this->logobj = m('log');
|
||||
}
|
||||
|
||||
protected function flowchangedata(){
|
||||
$cont = c('html')->replace($this->rs['content']);
|
||||
$fm = $this->rs['fengmian'];
|
||||
if(!isempt($fm)){
|
||||
$cont='<div align="center"><img style="max-width:100%" src="'.$this->rock->gethttppath($fm).'"></div>'.$cont.'';
|
||||
}
|
||||
$url = $this->rs['url'];
|
||||
if(!isempt($url))$cont.='<div><a href="'.$url.'">打开相应地址>></a></div>';
|
||||
$this->rs['content'] = $cont;
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
$mintou = (int)arrvalue($rs, 'mintou','0');
|
||||
if($lx==2){
|
||||
$zt = $this->logobj->isread($this->mtable, $rs['id'], $this->adminid);
|
||||
if($zt>0)$rs['ishui']=1;
|
||||
}
|
||||
if($lx==1){
|
||||
$receid = $rs['receid'];
|
||||
if(isempt($receid))$receid='all';
|
||||
$barr = m('log')->getreadshu($this->mtable, $rs['id'],$receid , $rs['optdt'], $this->adminmodel);
|
||||
foreach($barr as $k=>$v)$rs[$k]=$v;
|
||||
$this->readunarr = $barr['wduarr'];
|
||||
}
|
||||
if($mintou>0){
|
||||
$rs['title'] .='(投票)';
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
|
||||
protected function flowsubmit($na, $sm)
|
||||
{
|
||||
if($this->rs['status']==1)$this->tisongtodo();
|
||||
}
|
||||
|
||||
//移动端列表
|
||||
private $ydarr = false;
|
||||
public function flowrsreplace_we($row, $rs)
|
||||
{
|
||||
if(!isempt($rs['fengmian']))$row['picurl'] = $rs['fengmian'];
|
||||
if($this->ydarr===false)$this->ydarr = explode(',', m('log')->getread('infor', $this->adminid));
|
||||
|
||||
if(!in_array($rs['id'], $this->ydarr)){
|
||||
$row['statustext'] = '未读';
|
||||
$row['statuscolor'] = '#ED5A5A';
|
||||
}else{
|
||||
$row['ishui'] = 1;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
public function flowwesearchdata($lx)
|
||||
{
|
||||
if($lx==1)return $this->option->getselectdata('gongtype', true);
|
||||
return array(
|
||||
'typename' => '所有通知',
|
||||
'searchmsg' => '通知标题/分类',
|
||||
);
|
||||
}
|
||||
|
||||
//审核完成后发通知
|
||||
protected function flowcheckfinsh($zt)
|
||||
{
|
||||
if($zt==1)$this->tisongtodo();
|
||||
}
|
||||
|
||||
public function getreceids($receid, $whe='')
|
||||
{
|
||||
$receid = $this->adminmodel->gjoin($receid,'ud','where');
|
||||
if($receid=='' || $receid=='all'){
|
||||
$where = '';
|
||||
}else{
|
||||
$where = 'and id>0 and ('.$receid.')';
|
||||
}
|
||||
$ids = '';
|
||||
$rows = $this->adminmodel->getall('`status`=1 '.$where.' '.$whe.'','id');
|
||||
foreach($rows as $k=>$rs)$ids.=',u'.$rs['id'].'';
|
||||
if($ids!='')$ids = substr($ids, 1);
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
|
||||
//发送推送通知
|
||||
private function tisongtodo()
|
||||
{
|
||||
//还没到展示时间就不发送提醒
|
||||
$zstart= arrvalue($this->rs, 'zstart');
|
||||
if(!isempt($zstart) && $zstart>$this->rock->date)return;
|
||||
|
||||
$h = c('html');
|
||||
$cont = $h->htmlremove($this->rs['content']);
|
||||
$cont = $h->substrstr($cont,0, 50);
|
||||
if(strlen($cont)>40)$cont.='...';
|
||||
if(isempt($cont))$cont = $this->rs['title']; //为空时
|
||||
$this->push($this->rs['receid'], '通知公告', $cont, $this->rs['title'],1);
|
||||
|
||||
//添加短信提醒,短信提醒
|
||||
if(arrvalue($this->rs,'issms')=='1'){
|
||||
$receid = $this->rs['receid'];//接收人ID,可以为部门合聚,如d2,u1(必须)
|
||||
if(isempt($receid))$receid = 'all'; //为空就是全部人
|
||||
$qiannum= ''; //【系统→短信管理→短信签名】下获取,如没有自己的签名默认【信呼OA】
|
||||
$tplnum = m('option')->getval('gongsmstpl', 'gongsms');//到【数据选项→行政选项】下设置通知短信模版编号
|
||||
$params = array(
|
||||
'title' => $this->rs['title'],
|
||||
'typename' => $this->rs['typename'],
|
||||
);
|
||||
$url = $this->getxiangurlx();//详情连接地址(选填),短信模版有url就需要填写
|
||||
c('xinhuapi')->sendsms($receid, $qiannum, $tplnum, $params, $url);
|
||||
}
|
||||
}
|
||||
|
||||
protected function flowgetoptmenu($opt)
|
||||
{
|
||||
$to = m('log')->isread($this->mtable, $this->id);
|
||||
return $to<=0;
|
||||
}
|
||||
|
||||
protected function flowoptmenu($ors, $crs)
|
||||
{
|
||||
$table = $this->mtable;
|
||||
$mid = $this->id;
|
||||
$uid = $this->adminid;
|
||||
$lx = $ors['num'];
|
||||
$log = m('log');
|
||||
if($lx=='yd'){
|
||||
$log->addread($table, $mid, $uid);
|
||||
}
|
||||
if($lx=='allyd'){
|
||||
$ydid = $log->getread($table, $uid);
|
||||
$where = "id not in($ydid)";
|
||||
$meswh = m('admin')->getjoinstr('receid', $uid);
|
||||
$where .= $meswh;
|
||||
$rows = m($table)->getrows($where,'id');
|
||||
foreach($rows as $k=>$rs)$log->addread($table, $rs['id'], $uid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$key = $this->rock->post('key');
|
||||
$typeid = (int)$this->rock->post('typeid','0');
|
||||
$keywere= '';
|
||||
$whyere = '';
|
||||
if(!isempt($key))$keywere.=" and (`title` like '%$key%' or `typename`='$key')";
|
||||
//我和我未读
|
||||
if($lx=='my' || $lx=='wexx'){
|
||||
$whyere= "and (`zstart` is null or `zstart`<='{$this->rock->date}')";
|
||||
$whyere.= " and (`zsend` is null or `zsend`>='{$this->rock->date}')";
|
||||
}
|
||||
|
||||
if($typeid>0){
|
||||
$typename=$this->option->getmou('name', $typeid);
|
||||
$whyere.=" and `typename`='$typename'";
|
||||
}
|
||||
|
||||
return array(
|
||||
'order' => '`istop` desc,`optdt` desc',
|
||||
'keywere' => $keywere,
|
||||
'where' => $whyere,
|
||||
'fields' => 'id,typename,optdt,title,optname,zuozhe,indate,recename,fengmian,mintou,`status`,`istop`,`appxs`'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//显示投票
|
||||
protected function flowdatalog($arr)
|
||||
{
|
||||
$istoupiao = 0;
|
||||
$mintou = (int)arrvalue($this->rs, 'mintou','0');
|
||||
$maxtou = (int)arrvalue($this->rs, 'maxtou','0');
|
||||
$status = (int)arrvalue($this->rs, 'status','0');
|
||||
$touarr = array();
|
||||
$logarr = array();
|
||||
if($mintou>0){
|
||||
$istoupiao = 4;
|
||||
$toutype = 0;//不需要投票,1已投票,2未投票
|
||||
$receid = $this->rs['receid'];
|
||||
if(isempt($receid)){
|
||||
$istoupiao = 1;
|
||||
}else{
|
||||
$bo = $this->adminmodel->containjoin($receid, $this->adminid);
|
||||
if($bo)$istoupiao = 1;
|
||||
}
|
||||
$zongps = 0;
|
||||
$touitems = m('infors')->getall('mid='.$this->id.'','*','`sort`');
|
||||
foreach($touitems as $k=>$rs){
|
||||
$zongps+=floatval($rs['touci']);
|
||||
$touitems[$k]['bili'] = 0;
|
||||
}
|
||||
if($zongps>0)foreach($touitems as $k=>$rs){
|
||||
$touitems[$k]['bili'] = $this->rock->number(floatval($rs['touci'])/$zongps * 100);
|
||||
}
|
||||
|
||||
|
||||
$touarr['touitems'] = $touitems;
|
||||
|
||||
if($istoupiao==1){
|
||||
if($this->rs['startdt']>$this->rock->now)$istoupiao = 2; //未开始
|
||||
if($this->rs['enddt']<$this->rock->now)$istoupiao = 3; //结束
|
||||
}
|
||||
|
||||
$touarr['type'] = ($mintou==1 && $maxtou==1)? 'radio': 'checkbox';
|
||||
|
||||
//判断我是否投票了
|
||||
if($istoupiao==1 && $status==1){
|
||||
$towheer = $this->mwhere." and `name`='投票' and `checkid`='$this->adminid'";
|
||||
if($this->flogmodel->rows($towheer)>0){
|
||||
$toutype = 1;
|
||||
$istoupiao = 5;
|
||||
}else{
|
||||
$toutype = 2; //未投票
|
||||
}
|
||||
}
|
||||
$touarr['toutype'] = $toutype;
|
||||
|
||||
//判断是否可以显示结果
|
||||
$showtou = 0;
|
||||
if($istoupiao!=2 && $status==1 && ($toutype==1 || $toutype==0))$showtou = 1;
|
||||
if($showtou==0){
|
||||
foreach($arr['logarr'] as $k1=>$rs1){
|
||||
if($rs1['actname']!='投票')$logarr[] = $rs1;
|
||||
}
|
||||
}
|
||||
|
||||
$touarr['showtou'] = $showtou;
|
||||
$touarr['mintou'] = $mintou;
|
||||
$touarr['maxtou'] = $maxtou;
|
||||
}
|
||||
|
||||
$toupiaoarrr = explode(',',',<font color=blue>投票进行中</font>,<font color=#ff6600>未开始</font>,<font color=#888888>已结束</font>,<font color=#888888>你不在投票对象中</font>,<font color=green>已投票过了</font>');
|
||||
|
||||
|
||||
$arr['istoupiao'] = $istoupiao; //投票状态0不能,1可以,2未开始,3结束 4你不需要投票
|
||||
$arr['toupiaostatus'] = $toupiaoarrr[$istoupiao];
|
||||
$arr['title'] = '';
|
||||
$arr['touarr'] = $touarr;
|
||||
if($logarr)$arr['logarr'] = $logarr;
|
||||
|
||||
|
||||
$arr['readunarr'] = $this->readunarr;//读取未查阅
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
60
webmain/model/flow/goodghModel.php
Normal file
60
webmain/model/flow/goodghModel.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
//物品归还
|
||||
class flow_goodghClassModel extends flowModel
|
||||
{
|
||||
public function initModel()
|
||||
{
|
||||
$this->goodsobj = m('goods');
|
||||
}
|
||||
|
||||
//标识已完成了审核归还
|
||||
protected function flowcheckfinsh($zt)
|
||||
{
|
||||
if($zt!=1)return;
|
||||
$mid = $this->rs['custid'];
|
||||
m('goodn')->update('`lygh`=2','`mid`='.$mid.' and `lygh`=1');
|
||||
}
|
||||
|
||||
//作废或删除时
|
||||
protected function flowzuofeibill($sm)
|
||||
{
|
||||
//删除出库详情的
|
||||
m('goodss')->delete("`mid`='$this->id'");
|
||||
}
|
||||
|
||||
|
||||
//子表数据替换处理
|
||||
protected function flowsubdata($rows, $lx=0){
|
||||
foreach($rows as $k=>$rs){
|
||||
$one = $this->goodsobj->getone($rs['aid']);
|
||||
if($one){
|
||||
$name = $one['name'];
|
||||
if(!isempt($one['xinghao']))$name.='('.$one['xinghao'].')';
|
||||
if($lx==1){
|
||||
$rows[$k]['aid'] = $name;
|
||||
}
|
||||
$rows[$k]['unit'] = $one['unit'];
|
||||
$rows[$k]['temp_aid'] = $name;
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
//$lx,0默认,1详情展示,2列表显示
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
$rs['states']= $rs['state'];
|
||||
$rs['state'] = $this->goodsobj->crkstate($rs['state'],0);
|
||||
|
||||
//读取物品
|
||||
if($lx==2){
|
||||
$rs['wupinlist'] = $this->goodsobj->getgoodninfo($rs['id'], 1);
|
||||
}
|
||||
|
||||
if($lx==1){
|
||||
$url = $this->getxiangurl('goodly', $rs['custid'], 'auto');
|
||||
$rs['custname'] = '<a href="'.$url.'"><u>'.$rs['custname'].'</u></a>';
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
}
|
||||
63
webmain/model/flow/goodlyModel.php
Normal file
63
webmain/model/flow/goodlyModel.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
class flow_goodlyClassModel extends flowModel
|
||||
{
|
||||
public function initModel()
|
||||
{
|
||||
$this->goodsobj = m('goods');
|
||||
}
|
||||
|
||||
//审核完成处理
|
||||
protected function flowcheckfinsh($zt){
|
||||
/*
|
||||
m('goodss')->update('status='.$zt.'',"`mid`='$this->id'");
|
||||
$aid = '0';
|
||||
$rows = m('goodss')->getall("`mid`='$this->id'",'aid');
|
||||
foreach($rows as $k=>$rs)$aid.=','.$rs['aid'].'';
|
||||
m('goods')->setstock($aid);*/
|
||||
}
|
||||
|
||||
//作废或删除时
|
||||
protected function flowzuofeibill($sm)
|
||||
{
|
||||
//删除出库详情的
|
||||
m('goodss')->delete("`mid`='$this->id'");
|
||||
}
|
||||
|
||||
|
||||
//子表数据替换处理
|
||||
protected function flowsubdata($rows, $lx=0){
|
||||
$db = m('goods');
|
||||
$lygya = array('','需要','已归还');
|
||||
foreach($rows as $k=>$rs){
|
||||
$one = $db->getone($rs['aid']);
|
||||
if($one){
|
||||
$name = $one['name'];
|
||||
if(!isempt($one['xinghao']))$name.='('.$one['xinghao'].')';
|
||||
if($lx==1){
|
||||
$rows[$k]['aid'] = $name;
|
||||
$rows[$k]['count'] = 0-$rs['count']; //负数显示为正数
|
||||
if(isset($rs['lygh'])){
|
||||
$rows[$k]['lygh']=arrvalue($lygya, $rs['lygh']);
|
||||
|
||||
}
|
||||
}
|
||||
$rows[$k]['unit'] = $one['unit'];
|
||||
$rows[$k]['temp_aid'] = $name;
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
//$lx,0默认,1详情展示,2列表显示
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
$rs['states']= $rs['state'];
|
||||
$rs['state'] = $this->goodsobj->crkstate($rs['state'],1);
|
||||
|
||||
//读取物品
|
||||
if($lx==2){
|
||||
$rs['wupinlist'] = $this->goodsobj->getgoodninfo($rs['id'], 1);
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
}
|
||||
87
webmain/model/flow/goodsModel.php
Normal file
87
webmain/model/flow/goodsModel.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
class flow_goodsClassModel extends flowModel
|
||||
{
|
||||
|
||||
protected function flowchangedata(){
|
||||
$this->rs['typeid'] = m('goods')->gettypename($this->rs['typeid']);
|
||||
}
|
||||
|
||||
//导入数据的测试显示
|
||||
public function flowdaorutestdata()
|
||||
{
|
||||
return array(
|
||||
'typeid' => '办公耗材/笔',
|
||||
'name' => '红色粉笔',
|
||||
'num' => 'WP-829',
|
||||
'guige' => '红色',
|
||||
'xinghao' => '5厘米',
|
||||
'price' => '0.1',
|
||||
'unit' => '盒',
|
||||
'stockcs' => '20',
|
||||
);
|
||||
}
|
||||
|
||||
public function flowxiangfields(&$fields)
|
||||
{
|
||||
$fields['stock'] = '总库存';
|
||||
$where = '';
|
||||
if(ISMORECOM){
|
||||
$comid = arrvalue($this->rs,'comid','0');
|
||||
$where = ' and `comid`='.$comid.'';
|
||||
}
|
||||
$kcrow = m('godepot')->getall('1=1'.$where.'','*','`sort`');
|
||||
foreach($kcrow as $k1=>$rs1){
|
||||
$fields['stock_'.$rs1['id'].''] = $rs1['depotname'];
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
//
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
//详情页下显示对应仓库库存
|
||||
if($lx==1){
|
||||
$drows = $this->db->getall("SELECT `depotid`,sum(count)count FROM `[Q]goodss` where aid=".$rs['id']." and `status`=1 GROUP BY `depotid`");
|
||||
foreach($drows as $k1=>$rs1)$rs['stock_'.$rs1['depotid'].''] = $rs1['count'];
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
|
||||
//导入之前
|
||||
public function flowdaorubefore($rows)
|
||||
{
|
||||
$inarr = array();
|
||||
$db = m('goods');
|
||||
$num = 'goodstype';
|
||||
if(ISMORECOM && $cnum=$this->adminmodel->getcompanynum())$num.='_'.$cnum.'';
|
||||
foreach($rows as $k=>$rs){
|
||||
$rs['typeid'] = $this->option->gettypeid($num,$rs['typeid']);
|
||||
|
||||
//判断是否存在
|
||||
$odi = $db->existsgoods($rs);
|
||||
if($odi)continue;
|
||||
|
||||
$rs['price'] = floatval($this->rock->repempt($rs['price'],'0')); //金额
|
||||
//$rs['stockcs'] = (int)$this->rock->repempt(arrvalue($rs,'stockcs','0')); //无用
|
||||
|
||||
$inarr[] = $rs;
|
||||
}
|
||||
|
||||
return $inarr;
|
||||
}
|
||||
|
||||
//导入后处理(刷新库存)
|
||||
public function flowdaoruafter($ddoa=array())
|
||||
{
|
||||
//初始库存
|
||||
m('goods')->setstock();
|
||||
}
|
||||
|
||||
//删除时
|
||||
protected function flowdeletebill($sm)
|
||||
{
|
||||
m('goodss')->delete('`aid`='.$this->id.'');
|
||||
m('goods')->setstock();
|
||||
}
|
||||
}
|
||||
23
webmain/model/flow/groupModel.php
Normal file
23
webmain/model/flow/groupModel.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
class flow_groupClassModel extends flowModel
|
||||
{
|
||||
|
||||
protected $flowcompanyidfieds = 'none';
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
|
||||
//$carr = $this->adminmodel->getcompanyinfo();
|
||||
//$this->allid= $carr['companyallid'];
|
||||
//$companywhere = ' and `companyid` in('.join(',', $this->allid).')';
|
||||
$where = '';
|
||||
if(ISMORECOM && $this->adminid>1){
|
||||
$where = ' and `companyid`='.$this->companyid.'';
|
||||
}
|
||||
|
||||
return array(
|
||||
'companywhere' => '',
|
||||
'where' => $where
|
||||
);
|
||||
}
|
||||
}
|
||||
414
webmain/model/flow/hrcheckModel.php
Normal file
414
webmain/model/flow/hrcheckModel.php
Normal file
@@ -0,0 +1,414 @@
|
||||
<?php
|
||||
//模块 hrcheck.考核评分
|
||||
class flow_hrcheckClassModel extends flowModel
|
||||
{
|
||||
//审核完成处理
|
||||
protected function flowcheckfinsh($zt){
|
||||
//最后得分计算,
|
||||
if($zt==1){
|
||||
$fenzp = floatval($this->rs['fenzp']);
|
||||
$fensj = floatval($this->rs['fensj']);
|
||||
$fenrs = floatval($this->rs['fenrs']);
|
||||
|
||||
//默认分数=自己评分*50% + 上级评分*25% + 人事评分*25%
|
||||
$fen = $fenzp*0.5 + $fensj*0.25 + $fenrs*0.25;
|
||||
|
||||
//3个平均分
|
||||
//$fen = ($fenzp+$fensj+$fenrs)/3;
|
||||
|
||||
|
||||
$this->update(array('fen' => $fen), $this->id);
|
||||
}
|
||||
}
|
||||
|
||||
//需要评分就可以查看
|
||||
protected function flowisreadqx()
|
||||
{
|
||||
$boss = $this->getpfrows();
|
||||
if($boss)return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private function getpfrows()
|
||||
{
|
||||
return m('hrcheckn')->getall('mid='.$this->id.' and `optid`='.$this->adminid.' and `optdt` is null','*', '`sort`');
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
if(isset($rs['abclex']))return $rs;
|
||||
$ztstr = '';
|
||||
if(isempt($rs['pfrens'])){
|
||||
$ztstr = '<font color=green>评分已完成</font>';
|
||||
}else{
|
||||
if($rs['uid']==$this->adminid){
|
||||
$ztstr = '待<font color=blue>'.$rs['pfrens'].'</font>评分';
|
||||
}else{
|
||||
$ztstr = '<font color=blue>待评分</font>';
|
||||
}
|
||||
}
|
||||
$rs['pfrenids'] = $ztstr;
|
||||
if($lx==1){
|
||||
$ckbo = $this->isreadqxs();//是否设置查看权限
|
||||
|
||||
|
||||
|
||||
$ispf = $this->getpfrows();
|
||||
if(!$ispf){
|
||||
if($ckbo){ //设置可查看
|
||||
$rs['subdatastr'] = $this->getsubdatastr($this->id);
|
||||
$this->moders['isgbcy'] = 0;
|
||||
$this->moders['isgbjl'] = 0;
|
||||
|
||||
}else{
|
||||
if($rs['uid']!=$this->adminid)$rs['fen'] = '-';
|
||||
}
|
||||
}else{
|
||||
$rs['fen'] = '-';
|
||||
}
|
||||
}
|
||||
if($rs['uid']!=$this->adminid && !contain($this->atype, 'all'))$rs['fen']='-';//自己只能看自己分
|
||||
return $rs;
|
||||
}
|
||||
|
||||
public function getsubdatastr($id, $glx=0)
|
||||
{
|
||||
$srows = m('hrchecks')->getrows('`mid`='.$id.'','*','`sort`');
|
||||
$nrows = m('hrcheckn')->getrows('`mid`='.$id.'','*','`sort`');
|
||||
$pars = array();
|
||||
$fsarr = array();
|
||||
foreach($nrows as $k2=>$rs2){
|
||||
$pars[$rs2['pfid']] = $rs2['pfname'].'<br>'.$rs2['optname'].'(权重'.$rs2['weight'].'%)';
|
||||
$fsarr['s'.$rs2['sid'].'_'.$rs2['pfid'].''] = $rs2['defen'];
|
||||
}
|
||||
$fenshu = 0;
|
||||
$toarr = array();
|
||||
foreach($srows as $k1=>&$rs1){
|
||||
$rs1['xuhaos'] = $k1+1;
|
||||
|
||||
foreach($pars as $k3=>$v3){
|
||||
$val = arrvalue($fsarr, 's'.$rs1['id'].'_'.$k3.'');
|
||||
if(!isset($toarr[$k3]))$toarr[$k3] = 0;
|
||||
$toarr[$k3]+=floatval($val);
|
||||
|
||||
if($val==0)$val= '';
|
||||
$rs1['pfzd'.$k3.''] = $val; //得分
|
||||
}
|
||||
|
||||
|
||||
$fenshu+=floatval($rs1['fenshu']);
|
||||
}
|
||||
|
||||
//统计的
|
||||
$tjarr = array();
|
||||
foreach($toarr as $k3=>$v1){
|
||||
if($v1==0)$v1='';
|
||||
$tjarr['pfzd'.$k3.''] = $v1;
|
||||
}
|
||||
$tjarr['itemname'] = '小计';
|
||||
$tjarr['fenshu'] = $fenshu;
|
||||
$srows[]= $tjarr;
|
||||
|
||||
if($glx==1){
|
||||
return array(
|
||||
'data'=>$srows,
|
||||
'colums'=> $pars
|
||||
);
|
||||
}
|
||||
|
||||
$herstr = 'xuhaos,,center@itemname,考核内容,left@fenshu,分值';
|
||||
foreach($pars as $k1=>$v1)$herstr.='@pfzd'.$k1.','.$v1.'';
|
||||
|
||||
$pfrowsstr = c('html')->createrows($srows, $herstr,'#dddddd');
|
||||
|
||||
return $pfrowsstr;
|
||||
}
|
||||
|
||||
|
||||
protected function flowinit()
|
||||
{
|
||||
$this->dtobj = c('date');
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$month = $this->rock->post('month');
|
||||
$where = '';
|
||||
if(!isempt($month)){
|
||||
$where="and a.`startdt` like '".$month."%'";
|
||||
}
|
||||
return array(
|
||||
'table' => '`[Q]hrcheck` a left join `[Q]userinfo` b on a.uid=b.id',
|
||||
'fields' => 'a.*,b.deptname',
|
||||
'asqom' => 'a.',
|
||||
'where' => $where,
|
||||
'orlikefields' => 'b.deptname'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//是否可评分
|
||||
protected function flowdatalog($arr)
|
||||
{
|
||||
$pfrows = $this->getpfrows();
|
||||
foreach($pfrows as $k=>&$rs){
|
||||
$rs['xuhaos'] = $k+1;
|
||||
$rs['defenstr'] = '<input type="number" min="0" max="'.$rs['fenshu'].'" class="inputs" onfocus="js.focusval=this.value" name="pingfen_'.$rs['id'].'" onblur="js.number(this)">';
|
||||
$rs['itemname'] = '<div style="max-width:200px">'.$rs['itemname'].'</div>';
|
||||
}
|
||||
$pfrowsstr = c('html')->createrows($pfrows, 'xuhaos,,center@itemname,考核内容,left@pfname,评分名称@fenshu,总分数@defenstr,评分分数','#dddddd');
|
||||
return array(
|
||||
'pfrows' => $pfrows,
|
||||
'pfrowsstr' => $pfrowsstr,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function hrkaohemrun()
|
||||
{
|
||||
$dt = $this->rock->date;
|
||||
$dbs = m('hrkaohes');
|
||||
$dbs1 = m('hrchecks');
|
||||
$dbn1 = m('hrcheckn');
|
||||
$dbn = m('hrkaohen');
|
||||
$rows = m('hrkaohem')->getall("`status`=1 and `startdt`<='$dt' and `enddt`>='$dt'");
|
||||
$keox = 0;
|
||||
foreach($rows as $k=>$rs){
|
||||
|
||||
$bo = $this->xuyuns($rs);
|
||||
if(!$bo)continue;
|
||||
|
||||
$keox++;
|
||||
$rowxm = $dbs->getall("`mid`='".$rs['id']."'",'*','`sort`');
|
||||
$rowpf = $dbn->getall("`mid`='".$rs['id']."'",'*','`sort`');
|
||||
|
||||
$inarr = array(
|
||||
'khid' => $rs['id'],
|
||||
'title' => $rs['title'],
|
||||
'startdt' => $this->rock->date,
|
||||
'applydt' => $this->rock->date,
|
||||
'optdt' => $this->rock->now,
|
||||
'createdt' => $this->rock->now,
|
||||
'optname' => $rs['optname'],
|
||||
'optid' => $rs['optid'],
|
||||
'isturn' => 1,
|
||||
'month' => date('Y-m'),
|
||||
'status' => 1,
|
||||
'enddt' => ''
|
||||
);
|
||||
if($rs['pfsj']>0)$inarr['enddt'] = $this->dtobj->adddate($inarr['startdt'],'d', $rs['pfsj']);
|
||||
$recwe = $this->adminmodel->gjoin($rs['receid'],'', 'where');
|
||||
$uarr = $this->adminmodel->getall("`status`=1 and ($recwe)",'id,name');
|
||||
foreach($uarr as $uk=>$urs){
|
||||
$inarr['uid'] = $urs['id'];
|
||||
$inarr['applyname'] = $urs['name'];
|
||||
$pfren = $pfrenid = $pfrenids = $pfrens = '';
|
||||
$mid = 0;
|
||||
$where1 = "`uid`='".$urs['id']."' and `startdt`='".$inarr['startdt']."' and `khid`='".$rs['id']."'";
|
||||
if($mrs = $this->getone($where1)){
|
||||
$mid= (int)$mrs['id'];
|
||||
}else{
|
||||
$where1= '';
|
||||
}
|
||||
//保存的hrcheck表
|
||||
$bo = $this->record($inarr, $where1);
|
||||
if($mid==0)$mid = $this->db->insert_id();
|
||||
|
||||
//在保存到hrchecks考核内容表
|
||||
$sids = '0';
|
||||
$sids1 = '0';
|
||||
foreach($rowxm as $k1=>$rs1){
|
||||
$where1 = "`mid`='$mid' and `itemname`='".$rs1['itemname']."'";
|
||||
$sid = (int)$dbs1->getmou('id',$where1);
|
||||
if($sid==0)$where1 = '';
|
||||
$fenshu = floatval($rs['maxfen']) * floatval($rs1['weight']) * 0.01;
|
||||
$dbs1->record(array(
|
||||
'mid' => $mid,
|
||||
'sort' => $k1,
|
||||
'itemname' => $rs1['itemname'],
|
||||
'weight' => $rs1['weight'],
|
||||
'fenshu' => $fenshu
|
||||
), $where1);
|
||||
if($sid==0)$sid = $this->db->insert_id();
|
||||
$sids.=','.$sid.'';
|
||||
|
||||
//添加到hrcheckn考核内容表
|
||||
|
||||
foreach($rowpf as $k2=>$rs2){
|
||||
$pfarr = $this->getpftype($urs, $rs2);
|
||||
$where2= "`mid`='$mid' and `pfid`='".$rs2['id']."' and `sid`='$sid'";
|
||||
$sid1 = 0;
|
||||
$srs = $dbn1->getone($where2);
|
||||
if($srs){
|
||||
$sid1 = (int)$srs['id'];
|
||||
}
|
||||
if($sid1==0)$where2 = '';
|
||||
|
||||
$dbn1->record(array(
|
||||
'mid' => $mid,
|
||||
'sort' => $k2,
|
||||
'itemname' => $rs1['itemname'],
|
||||
'weight' => $rs2['pfweight'],
|
||||
'pfid' => $rs2['id'],
|
||||
'pfname' => $rs2['pfname'],
|
||||
'sid' => $sid,
|
||||
'fenshu' => $fenshu,
|
||||
'optid' => $pfarr[0],
|
||||
'optname' => $pfarr[1],
|
||||
),$where2);
|
||||
if($sid1==0)$sid1 = $this->db->insert_id();
|
||||
$sids1.=','.$sid1.'';
|
||||
if(!isempt($pfarr[0]) && !contain(','.$pfrenid.',',','.$pfarr[0].',')){
|
||||
$pfren .= ','.$pfarr[1];
|
||||
$pfrenid .= ','.$pfarr[0];
|
||||
}
|
||||
//未评分人
|
||||
$ispf = false;
|
||||
if($srs && !isempt($srs['optdt']))$ispf=true;
|
||||
|
||||
if(!$ispf && !isempt($pfarr[0]) && !contain(','.$pfrenids.',',','.$pfarr[0].',')){
|
||||
$pfrenids .= ','.$pfarr[0];
|
||||
$pfrens .= ','.$pfarr[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
$dbs1->delete("`mid`='$mid' and `id` not in($sids)");
|
||||
$dbn1->delete("`mid`='$mid' and `id` not in($sids1)");
|
||||
if($pfrenid!=''){
|
||||
$pfrenid = substr($pfrenid,1);
|
||||
$pfren = substr($pfren,1);
|
||||
}
|
||||
if($pfrenids!=''){
|
||||
$pfrenids = substr($pfrenids, 1);
|
||||
$pfrens = substr($pfrens, 1);
|
||||
}
|
||||
|
||||
|
||||
$this->update(array(
|
||||
'pfrenid' => $pfrenid,
|
||||
'pfren' => $pfren,
|
||||
'pfrenids' => $pfrenids,
|
||||
'pfrens' => $pfrens,
|
||||
), $mid);
|
||||
|
||||
//发给对应人通知
|
||||
$this->loaddata($mid, false);
|
||||
$this->numtodosend('pftodo','评分');
|
||||
}
|
||||
}
|
||||
return $keox;
|
||||
}
|
||||
private function xuyuns($rs){
|
||||
$pinlv = $rs['pinlv'];
|
||||
$sctime = $rs['sctime'];
|
||||
if(isempt($sctime))return false;
|
||||
if($pinlv=='d')return true; //每天
|
||||
if($pinlv=='m'){
|
||||
if(date('d')==date('d', strtotime($sctime)))return true;
|
||||
}
|
||||
//每季度
|
||||
if($pinlv=='j'){
|
||||
$m = (int)date('m');
|
||||
$jdr = array(1,4,7,10);
|
||||
if(in_array($m, $jdr)){
|
||||
if(date('d')==date('d', strtotime($sctime)))return true;
|
||||
}
|
||||
}
|
||||
//每年
|
||||
if($pinlv=='y'){
|
||||
if(date('m-d')==date('m-d', strtotime($sctime)))return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//获取评分人
|
||||
private function getpftype($urs, $rs2){
|
||||
$pftype = $rs2['pftype'];
|
||||
$sid = '';
|
||||
$sna = '';
|
||||
if(!isempt($rs2['pfren'])){
|
||||
$sid = $rs2['pfrenid'];
|
||||
$sna = $rs2['pfren'];
|
||||
}
|
||||
if($pftype=='my'){
|
||||
$sid = $urs['id'];
|
||||
$sna = $urs['name'];
|
||||
}
|
||||
//上级
|
||||
if($pftype=='super' && $sid==''){
|
||||
$sua = $this->adminmodel->getsuperman($urs['id']);
|
||||
if($sua){
|
||||
$sid = $sua[0];
|
||||
$sna = $sua[1];
|
||||
}
|
||||
}
|
||||
return array($sid, $sna);
|
||||
}
|
||||
|
||||
public function defen($mid)
|
||||
{
|
||||
$rows = m('hrcheckn')->getall('`mid`='.$mid.'');
|
||||
$fshu = 0;
|
||||
$pfren = $pfrenid = $pfrenids = $pfrens = '';
|
||||
foreach($rows as $k=>$rs){
|
||||
$fshu += floatval($rs['defen']) * floatval($rs['weight']) * 0.01;
|
||||
|
||||
if(!isempt($rs['optid']) && !contain(','.$pfrenid.',',','.$rs['optid'].',')){
|
||||
$pfren .= ','.$rs['optname'];
|
||||
$pfrenid .= ','.$rs['optid'];
|
||||
}
|
||||
|
||||
if(isempt($rs['optdt']) && !isempt($rs['optid']) && !contain(','.$pfrenids.',',','.$rs['optid'].',')){
|
||||
$pfrenids .= ','.$rs['optid'];
|
||||
$pfrens .= ','.$rs['optname'];
|
||||
}
|
||||
}
|
||||
|
||||
if($pfrenid!=''){
|
||||
$pfrenid = substr($pfrenid,1);
|
||||
$pfren = substr($pfren,1);
|
||||
}
|
||||
if($pfrenids!=''){
|
||||
$pfrenids = substr($pfrenids, 1);
|
||||
$pfrens = substr($pfrens, 1);
|
||||
}
|
||||
|
||||
$this->update(array(
|
||||
'pfrenid' => $pfrenid,
|
||||
'pfren' => $pfren,
|
||||
'pfrenids' => $pfrenids,
|
||||
'pfrens' => $pfrens,
|
||||
'fen' => $fshu,
|
||||
), $mid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交评分
|
||||
*/
|
||||
public function pingfen()
|
||||
{
|
||||
$str = $this->rock->post('str');
|
||||
$star= c('array')->strtoarray($str);
|
||||
$dbn = m('hrcheckn');
|
||||
foreach($star as $kv2){
|
||||
$sid = $kv2[0];
|
||||
$defen = $kv2[1];
|
||||
|
||||
$uarr = array(
|
||||
'defen' => $defen,
|
||||
'optdt' => $this->rock->now
|
||||
);
|
||||
|
||||
$dbn->update($uarr, $sid);
|
||||
}
|
||||
$this->defen($this->id);
|
||||
$sm = $this->rock->post('sm');
|
||||
|
||||
$this->addlog(array(
|
||||
'name' => '评分',
|
||||
'explain' => $sm
|
||||
));
|
||||
//$this->numtodosend('pftz','评分', $sm);
|
||||
|
||||
return 'ok';
|
||||
}
|
||||
}
|
||||
45
webmain/model/flow/hrkaohemModel.php
Normal file
45
webmain/model/flow/hrkaohemModel.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
//考核项目
|
||||
class flow_hrkaohemClassModel extends flowModel
|
||||
{
|
||||
public function initModel()
|
||||
{
|
||||
$this->pinlva['d'] = '每天';
|
||||
$this->pinlva['w'] = '每周一';
|
||||
$this->pinlva['m'] = '每月';
|
||||
$this->pinlva['j'] = '每季度';
|
||||
$this->pinlva['y'] = '每年';
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
$pinlv = $rs['pinlv'];
|
||||
|
||||
$rs['pinlv'] = arrvalue($this->pinlva, $pinlv);
|
||||
$sctime = $rs['sctime'];
|
||||
if($pinlv=='m'){
|
||||
$rs['sctime'] = $rs['pinlv'].date('d号H:i', strtotime($sctime));
|
||||
}
|
||||
if($pinlv=='j'){
|
||||
$rs['sctime'] = $rs['pinlv'].'首月的'.date('d号H:i', strtotime($sctime));
|
||||
}
|
||||
if($pinlv=='y'){
|
||||
$rs['sctime'] = $rs['pinlv'].date('m月d号H:i', strtotime($sctime));;
|
||||
}
|
||||
if($lx==2){
|
||||
$zbdata = $this->db->getall("select * from `[Q]hrkaohes` where `mid`='".$rs['id']."' order by `sort`");
|
||||
$str = '';
|
||||
foreach($zbdata as $k1=>$rs1)$str.=''.$rs1['itemname'].'('.$rs1['weight'].'%);';
|
||||
$rs['temp_zbcont'] = $str;
|
||||
|
||||
$zbdata = $this->db->getall("select * from `[Q]hrkaohen` where `mid`='".$rs['id']."' order by `sort`");
|
||||
$str = '';
|
||||
foreach($zbdata as $k1=>$rs1)$str.=''.$rs1['pfname'].'('.$rs1['pfweight'].'%);';
|
||||
$rs['temp_pfren'] = $str;
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
|
||||
}
|
||||
23
webmain/model/flow/hrmanshiModel.php
Normal file
23
webmain/model/flow/hrmanshiModel.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* 人事模块.面试安排
|
||||
*/
|
||||
class flow_hrmanshiClassModel extends flowModel
|
||||
{
|
||||
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
$statearr = array('待面试','录用','不适合');
|
||||
$rs['state'] = arrvalue($statearr, $rs['state']);
|
||||
return $rs;
|
||||
}
|
||||
|
||||
//面试处理,不时候
|
||||
protected function flowcheckbefore($zt=0, $ufied=null, $sm='')
|
||||
{
|
||||
$num = $this->nowcourse['num'];
|
||||
if($zt==2 && $num=='msque'){
|
||||
$this->update('state=2', $this->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
webmain/model/flow/hrpositiveModel.php
Normal file
22
webmain/model/flow/hrpositiveModel.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* 人事模块.转正的
|
||||
*/
|
||||
class flow_hrpositiveClassModel extends flowModel
|
||||
{
|
||||
//审核完成处理
|
||||
protected function flowcheckfinsh($zt){
|
||||
m('hr')->hrrun();
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$key = $this->rock->post('key');
|
||||
$where = '';
|
||||
if($key!='')$where.=" and (b.udeptname like '%$key%' or b.`uname` like '%$key%')";
|
||||
return array(
|
||||
'keywhere' => $where,
|
||||
'leftbill' => 1
|
||||
);
|
||||
}
|
||||
}
|
||||
22
webmain/model/flow/hrredundModel.php
Normal file
22
webmain/model/flow/hrredundModel.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* 人事模块.离职的
|
||||
*/
|
||||
class flow_hrredundClassModel extends flowModel
|
||||
{
|
||||
//审核完成处理
|
||||
protected function flowcheckfinsh($zt){
|
||||
m('hr')->hrrun();
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$key = $this->rock->post('key');
|
||||
$where = '';
|
||||
if($key!='')$where.=" and (b.udeptname like '%$key%' or b.`uname` like '%$key%')";
|
||||
return array(
|
||||
'keywhere' => $where,
|
||||
'leftbill' => 1
|
||||
);
|
||||
}
|
||||
}
|
||||
46
webmain/model/flow/hrsalarmModel.php
Normal file
46
webmain/model/flow/hrsalarmModel.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
//薪资模版
|
||||
class flow_hrsalarmClassModel extends flowModel
|
||||
{
|
||||
protected $flowcompanyidfieds = 'none'; //不要多单位判断,是共享的
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
|
||||
return array(
|
||||
'order' => '`sort`,`id`'
|
||||
);
|
||||
}
|
||||
|
||||
//读取字段
|
||||
public function xinzifields()
|
||||
{
|
||||
$mid = m('flow_set')->getmou('id',"`num`='hrsalary'");
|
||||
$rows = m('flow_element')->getall("`mid`='$mid'",'*','iszb,sort');
|
||||
$barr = array();
|
||||
$nofar = explode(',','uname,udeptname,postjt,mones,money,ranking,month,ispay,explain,isturn,status');
|
||||
foreach($rows as $k=>$rs){
|
||||
if(in_array($rs['fields'], $nofar))continue;
|
||||
$barr[] = array(
|
||||
'name'=>$rs['name'],
|
||||
'value'=>$rs['fields'],
|
||||
'subname'=>$rs['fields']
|
||||
);
|
||||
}
|
||||
|
||||
return $barr;
|
||||
}
|
||||
|
||||
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
$month = date('Y-m');
|
||||
if($rs['status']=='0' || $rs['enddt']<$month || $rs['startdt']>$month)$rs['ishui']=1;
|
||||
return $rs;
|
||||
}
|
||||
}
|
||||
398
webmain/model/flow/hrsalaryModel.php
Normal file
398
webmain/model/flow/hrsalaryModel.php
Normal file
@@ -0,0 +1,398 @@
|
||||
<?php
|
||||
class flow_hrsalaryClassModel extends flowModel
|
||||
{
|
||||
protected $flowviewufieds = 'xuid';
|
||||
|
||||
public $floweditother = true; //可编辑uid别人的单据
|
||||
|
||||
//薪资是个严格的模块,只能设置权限后才可以查看,不管是不是管理员
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$key = $this->rock->post('key');
|
||||
$dt = $this->rock->post('dt');
|
||||
$ispay = $this->rock->post('ispay');
|
||||
$isturn = $this->rock->post('isturn');
|
||||
$where = '';
|
||||
$where = $this->viewmodel->viewwhere($this->moders, $this->adminid, $this->flowviewufieds, 1);
|
||||
if($lx=='faf'){
|
||||
$where.=' and a.`status`=1';
|
||||
}
|
||||
if($ispay!='')$where.=' and a.`ispay`='.$ispay.'';
|
||||
if($isturn!='')$where.=' and a.`isturn`='.$isturn.'';
|
||||
|
||||
//自己部门下的
|
||||
if($lx=='dept'){
|
||||
$uidall = $this->adminmodel->getdown($uid);
|
||||
if(isempt($uidall))$uidall='0';
|
||||
$where.=' and a.`xuid` in('.$uidall.')';
|
||||
}
|
||||
//echo $where;
|
||||
|
||||
//if($key!='')$where.=" and (c.deptallname like '%$key%' or a.uname like '%$key%' or a.ranking like '%$key%' )";
|
||||
if($dt!='')$where.=" and a.`month`='$dt'";
|
||||
return array(
|
||||
'where' => $where,
|
||||
'orlikefields' => 'c.`deptallname`,a.`uname`,a.`ranking`',
|
||||
'tableleft' => '`[Q]userinfo` c on a.`xuid`=c.`id`',
|
||||
'fieldsleft'=> 'c.`num`,c.deptallname,c.`bankname`,c.`banknum`',
|
||||
'order' => 'a.`month` desc,a.`id` asc',
|
||||
);
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs, $lx=0){
|
||||
$s = '<font color=red>待发放</font>';
|
||||
$rs['ispays'] = $rs['ispay'];
|
||||
if($rs['ispay']==1)$s = '<font color=green>已发放</font>';
|
||||
$rs['ispay'] = $s;
|
||||
|
||||
$s = '<font color=red>待核算</font>';
|
||||
if($rs['isturn']==1)$s = '<font color=green>已核算</font>';
|
||||
$rs['isturnss'] = $s;
|
||||
|
||||
//详情展示时
|
||||
if($lx==1){
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
||||
private function fafang()
|
||||
{
|
||||
$this->addlog(array(
|
||||
'name' => '发放'
|
||||
));
|
||||
$this->update('ispay=1', $this->id);
|
||||
m('reim')->asynurl('asynrun','salaryff', array(
|
||||
'id' => $this->id
|
||||
));//异步通知给人员
|
||||
}
|
||||
|
||||
public function todouser()
|
||||
{
|
||||
$this->push($this->rs['xuid'],'工资条','您['.$this->rs['month'].']月份薪资已发放,请注意查看对账。','薪资发放通知');
|
||||
}
|
||||
|
||||
public function gongzifafang($sid)
|
||||
{
|
||||
$sarrid = explode(',',$sid);
|
||||
foreach($sarrid as $id){
|
||||
$this->loaddata($id, false);
|
||||
if($this->rs['status']==1 && $this->rs['ispay']==0)$this->fafang();
|
||||
}
|
||||
}
|
||||
|
||||
//一键生成薪资
|
||||
public function createdata($month)
|
||||
{
|
||||
$lmonth = c('date')->adddate($month.'-01','m',-1, 'Y-m');
|
||||
$swer = m('admin')->monthuwhere($month);
|
||||
$where = "`month`<'$month' and xuid in(select id from `[Q]userinfo` where 1=1 $swer) and `xuid` not in(select xuid from `[Q]".$this->mtable."` where `month`='$month')";
|
||||
$addfes = 'base,postjt';//基本工资跟岗位工资
|
||||
|
||||
$adees = explode(',', $addfes);
|
||||
$rows = $this->db->getall("select * from `[Q]hrsalary` where $where order by `month` desc");
|
||||
$count = 0;
|
||||
$xuarr = array();
|
||||
foreach($rows as $k=>$rs){
|
||||
unset($rs['id']);
|
||||
$xuid = $rs['xuid'];
|
||||
if(isset($xuarr[$xuid]))continue;
|
||||
$count++;
|
||||
$xuarr[$xuid] = 1;
|
||||
$arr = array();
|
||||
$arr1 = array(
|
||||
'xuid' => $xuid,
|
||||
'uname' => $rs['uname'],
|
||||
'ranking' => $rs['ranking'],
|
||||
'udeptname' => $rs['udeptname'],
|
||||
'uid' => $this->adminid,
|
||||
'optid' => $this->adminid,
|
||||
'optname' => $this->adminname,
|
||||
'optdt' => $this->rock->now,
|
||||
'applydt' => $this->rock->date,
|
||||
'status' => 0,
|
||||
'isturn' => 0,
|
||||
'month' => $month,
|
||||
);
|
||||
foreach($adees as $adees1)$arr[$adees1]=$rs[$adees1];
|
||||
|
||||
foreach($arr1 as $k1=>$v1)$arr[$k1]=$v1;
|
||||
$arr['explain']='一键生成参考了'.$rs['month'].'月份的工资';
|
||||
|
||||
//读取固定值的
|
||||
$farrr = $this->getfiearrs($xuid, $month);
|
||||
foreach($farrr as $k1=>$rs1){
|
||||
foreach($rs1['fieldsarr'] as $k2=>$rs2){
|
||||
if($rs2['type']=='0')$arr[$rs2['fields']] = $rs2['devzhi'];
|
||||
|
||||
if($rs2['gongsi']=='last')$arr[$rs2['fields']] = $rs[$rs2['fields']]; //读取上月
|
||||
}
|
||||
}
|
||||
|
||||
$arr['jxdf'] = '0';
|
||||
$arr['jiansr'] = '0';
|
||||
$arr['otherzj'] = '0';
|
||||
$arr['otherjs'] = '0';
|
||||
|
||||
/*
|
||||
$money = 0;
|
||||
|
||||
|
||||
foreach($adees as $fid){
|
||||
$arr[$fid] = $rs[$fid];
|
||||
$money += floatval($rs[$fid]);
|
||||
}
|
||||
$money -= floatval($rs['socials']);
|
||||
$arr['money'] = $money;*/
|
||||
|
||||
$this->insert($arr);
|
||||
}
|
||||
return '成功生成'.$count.'条';
|
||||
}
|
||||
|
||||
//导入数据的测试显示
|
||||
public function flowdaorutestdata()
|
||||
{
|
||||
$barr = array(
|
||||
'uname' => '貂蝉',
|
||||
'month' => '[2017-08]',
|
||||
'base' => '1700',
|
||||
'skilljt' => '3500',
|
||||
'telbt' => '0',
|
||||
'travelbt' => '0',
|
||||
'postjt' => '500',
|
||||
'reward' => '0',
|
||||
'jiabans' => '0',
|
||||
|
||||
'punish' => '0', //处罚
|
||||
'socials' => '0',
|
||||
'taxes' => '0',
|
||||
'money' => '5700',
|
||||
'explain' => '本月薪资',
|
||||
'isturn' => '是',
|
||||
'status' => '是',
|
||||
|
||||
);
|
||||
$barr1 = array(
|
||||
'uname' => '大乔',
|
||||
'month' => '[2017-08]',
|
||||
'base' => '1700',
|
||||
'skilljt' => '3000',
|
||||
'telbt' => '0',
|
||||
'travelbt' => '0',
|
||||
'postjt' => '500',
|
||||
'reward' => '0',
|
||||
'jiabans' => '0',
|
||||
|
||||
'explain' => '本月薪资',
|
||||
|
||||
'punish' => '0', //处罚
|
||||
'socials' => '0',
|
||||
'taxes' => '0',
|
||||
'money' => '5200',
|
||||
'isturn' => '是',
|
||||
'status' => '是',
|
||||
|
||||
);
|
||||
$barr2 = array(
|
||||
'uname' => '小乔',
|
||||
'month' => '[2017-08]',
|
||||
'base' => '1700',
|
||||
'skilljt' => '2500',
|
||||
'telbt' => '0',
|
||||
'travelbt' => '0',
|
||||
'postjt' => '500',
|
||||
'reward' => '0',
|
||||
'jiabans' => '0',
|
||||
|
||||
'explain' => '导入',
|
||||
|
||||
'punish' => '5', //处罚
|
||||
'socials' => '0',
|
||||
'taxes' => '0',
|
||||
'money' => '4695',
|
||||
'isturn' => '是',
|
||||
'status' => '是',
|
||||
|
||||
);
|
||||
return array($barr,$barr1,$barr2);
|
||||
}
|
||||
|
||||
//导入之前判断
|
||||
public function flowdaorubefore($rows)
|
||||
{
|
||||
$inarr = array();
|
||||
$uarra = array();
|
||||
foreach($rows as $k=>$rs){
|
||||
$name = $rs['uname'];
|
||||
|
||||
$month = str_replace('[','', $rs['month']);
|
||||
$month = substr(str_replace(']','', $month),0,7);
|
||||
|
||||
$arr = $rs;
|
||||
$urs = $this->adminmodel->getone("`name`='$name'");
|
||||
if(!$urs)continue;
|
||||
|
||||
$to = $this->rows("`xuid`='".$urs['id']."' and `month`='$month'");
|
||||
if($to>0)continue;//已经存在了
|
||||
|
||||
$arr['month'] = $month;
|
||||
$arr['xuid'] = $urs['id'];
|
||||
$arr['udeptname'] = $urs['deptname'];
|
||||
$arr['ranking'] = $urs['ranking'];
|
||||
|
||||
$arr['isturn'] = (arrvalue($arr,'isturn')=='是') ? 1 : 0;
|
||||
$arr['status'] = (arrvalue($arr,'status')=='是') ? 1 : 0;
|
||||
$arr['ispay'] = (arrvalue($arr,'ispay')=='是') ? 1 : 0;
|
||||
|
||||
if($arr['status']==1)$arr['isturn'] = 1;
|
||||
|
||||
$inarr[] = $arr;
|
||||
}
|
||||
|
||||
return $inarr;
|
||||
}
|
||||
|
||||
//导入后处理,未审核需要提交审核
|
||||
public function flowdaoruafter($drdata=array())
|
||||
{
|
||||
foreach($drdata as $k=>$rs){
|
||||
//
|
||||
//if($rs['status']==0 && $rs['isturn']==1){
|
||||
// $id = $rs['id'];
|
||||
// $this->loaddata($id, false);
|
||||
// $this->submit('提交');
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
//读取薪资模版上的
|
||||
private $pipeibarr = array();
|
||||
public function getfiearrs($uid, $month, $bo=true)
|
||||
{
|
||||
if($this->pipeibarr && $bo)return $this->pipeibarr;
|
||||
$month= substr($month, 0, 7);
|
||||
$rows = m('hrsalarm')->getall("`status`=1 and `startdt`<='$month' and `enddt`>='$month'",'*','`sort`');
|
||||
$rowa = array();
|
||||
foreach($rows as $k=>$rs){
|
||||
$rs['xuhao'] = $k+1;
|
||||
$rowa[$rs['atype']][] = $rs;
|
||||
}
|
||||
$kqob = m('kaoqin');
|
||||
$dbs = m('hrsalars');
|
||||
$garr = array();
|
||||
foreach($rowa as $klx=>$carr){
|
||||
$xu = $kqob->getpipeimid($uid, $carr, 'xuhao',0);
|
||||
if($xu>0){
|
||||
$nrsaa = $rows[$xu-1];
|
||||
$nrsaa['fieldsarr'] = $dbs->getall('mid='.$nrsaa['id'].'','*','`sort`');
|
||||
$garr[] = $nrsaa;
|
||||
}
|
||||
}
|
||||
|
||||
if($bo)$this->pipeibarr = $garr; //最后匹配到的模版
|
||||
|
||||
//echo $xu;
|
||||
return $garr;
|
||||
}
|
||||
|
||||
public function flowgetfields($lx)
|
||||
{
|
||||
$farr = $this->flowfieldarr($this->fieldsarra, 3);
|
||||
$barr = array();
|
||||
foreach($farr as $k=>$rs){
|
||||
if(isset($rs['iszs']) && $rs['iszs']==2)$barr[$rs['fields']]=$rs['name'];
|
||||
}
|
||||
return $barr;
|
||||
}
|
||||
|
||||
//先运行这个$lx=0,1移动端,2保存,3展示
|
||||
public function flowfieldarr($farr, $lx)
|
||||
{
|
||||
$mid = (int)$this->rock->get('mid','0');
|
||||
$demonth = c('date')->adddate($this->rock->date,'m',-1,'Y-m');
|
||||
$dexuid = $this->adminid;
|
||||
if($mid>0 && $mrs=$this->getone($mid)){
|
||||
$demonth = $mrs['month'];
|
||||
$dexuid = $mrs['xuid'];
|
||||
}
|
||||
|
||||
$month= $this->rock->post('month', $demonth);
|
||||
$xuid = (int)$this->rock->post('xuid', $dexuid);
|
||||
|
||||
$cfarr= $this->getfiearrs($xuid, $month);
|
||||
$fnar = array();
|
||||
foreach($cfarr as $k=>$rs){
|
||||
foreach($rs['fieldsarr'] as $k1=>$rs1)$fnar[$rs1['fields']]=$rs1;
|
||||
}
|
||||
$urs = $this->adminmodel->getone($xuid);
|
||||
|
||||
foreach($farr as $k=>$rs){
|
||||
$farr[$k]['suantype']=-1;
|
||||
$fid = $rs['fields'];
|
||||
if(isset($fnar[$fid])){
|
||||
$nfrs = $fnar[$fid];
|
||||
if($nfrs['gongsi']=='last')$nfrs['gongsi']='';
|
||||
$farr[$k]['dev'] = $nfrs['devzhi'];
|
||||
$farr[$k]['gongsi'] = $nfrs['gongsi']; //公式
|
||||
$farr[$k]['islu'] = 1;
|
||||
$farr[$k]['iszs'] = 2;
|
||||
$farr[$k]['suantype']= $nfrs['type'];
|
||||
}
|
||||
if($fid=='month'){
|
||||
$farr[$k]['dev'] = $month;
|
||||
}
|
||||
if($fid=='uname'){
|
||||
$farr[$k]['dev'] = ''.$urs['name'].'|'.$xuid.'';
|
||||
}
|
||||
if($fid=='udeptname'){
|
||||
$farr[$k]['dev'] = $urs['deptname'];
|
||||
}
|
||||
if($fid=='ranking'){
|
||||
$farr[$k]['dev'] = $urs['ranking'];
|
||||
}
|
||||
if($fid=='gonghao'){
|
||||
$farr[$k]['dev'] = $urs['num'];
|
||||
}
|
||||
}
|
||||
|
||||
return $farr;
|
||||
}
|
||||
|
||||
//在运行这个,模版处理
|
||||
public function flowinputtpl($cont, $lx)
|
||||
{
|
||||
//pc
|
||||
if($lx==0){
|
||||
$cfarr = $this->pipeibarr;
|
||||
$str = '';
|
||||
foreach($cfarr as $k=>$rs){
|
||||
$carr = $rs['fieldsarr'];
|
||||
if(isempt($rs['title']))$rs['title']=$rs['atype'];
|
||||
$str.='<div><br><strong>'.$rs['title'].'</strong></div>';
|
||||
if(count($carr)%2!=0)$carr[]=array(
|
||||
'name' => '',
|
||||
'fields' => '',
|
||||
);
|
||||
$str.='<table width="100%" border="0" class="ke-zeroborder">';
|
||||
$str.='<tr>';
|
||||
foreach($carr as $k1=>$rs1){
|
||||
$str.='<td align="right" class="ys1" width="15%">'.$rs1['name'].'</td>';
|
||||
$str.='<td class="ys2" width="35%">{'.$rs1['fields'].'}</td>';
|
||||
|
||||
if(($k1+1)%2==0)$str.='</tr><tr>';
|
||||
}
|
||||
$str.='</tr>';
|
||||
$str.='</table>';
|
||||
}
|
||||
$cont = str_replace('{autotpl}', $str, $cont);
|
||||
}
|
||||
return $cont;
|
||||
}
|
||||
|
||||
public function flowviewtpl($cont, $lx)
|
||||
{
|
||||
$this->getfiearrs($this->rs['xuid'], $this->rs['month']);
|
||||
return $this->flowinputtpl($cont, $lx);
|
||||
}
|
||||
}
|
||||
17
webmain/model/flow/hrshebaoModel.php
Normal file
17
webmain/model/flow/hrshebaoModel.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
class flow_hrshebaoClassModel extends flowModel
|
||||
{
|
||||
protected $flowcompanyidfieds = 'none'; //不要多单位判断,是共享的
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
$month = date('Y-m');
|
||||
if($rs['status']=='0' || $rs['enddt']<$month || $rs['startdt']>$month)$rs['ishui']=1;
|
||||
return $rs;
|
||||
}
|
||||
}
|
||||
22
webmain/model/flow/hrtransferModel.php
Normal file
22
webmain/model/flow/hrtransferModel.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* 人事模块.调动的
|
||||
*/
|
||||
class flow_hrtransferClassModel extends flowModel
|
||||
{
|
||||
//审核完成处理
|
||||
protected function flowcheckfinsh($zt){
|
||||
m('hr')->hrrun();
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$key = $this->rock->post('key');
|
||||
$where = '';
|
||||
if($key!='')$where.=" and (tranname like '%$key%' or olddeptname like '%$key%' or newdeptname like '%$key%' or oldranking like '%$key%' or newranking like '%$key%' or `trantype`='$key')";
|
||||
return array(
|
||||
'where' => $where,
|
||||
'order' => '`optdt` desc'
|
||||
);
|
||||
}
|
||||
}
|
||||
18
webmain/model/flow/hrtrsalaryModel.php
Normal file
18
webmain/model/flow/hrtrsalaryModel.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* 人事模块.调薪
|
||||
*/
|
||||
class flow_hrtrsalaryClassModel extends flowModel
|
||||
{
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$key = $this->rock->post('key');
|
||||
$where = '';
|
||||
if($key!='')$where.=" and (b.udeptname like '%$key%' or b.`uname` like '%$key%')";
|
||||
return array(
|
||||
'keywhere' => $where,
|
||||
'leftbill' => 1
|
||||
);
|
||||
}
|
||||
}
|
||||
59
webmain/model/flow/jiabanModel.php
Normal file
59
webmain/model/flow/jiabanModel.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
//加班
|
||||
class flow_jiabanClassModel extends flowModel
|
||||
{
|
||||
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
$rs['modenum'] = $this->modenum;
|
||||
$type = arrvalue($rs,'jiatype','0');
|
||||
$types = array('调休','加班费');
|
||||
$rs['jiatype'] = $types[$type];
|
||||
$dakatime = '未打卡';
|
||||
|
||||
//详情时读取前后2小时打卡记录
|
||||
if($lx==1){
|
||||
$stime = date('Y-m-d H:i:s', strtotime($rs['stime'])-3600*2);
|
||||
$etime = date('Y-m-d H:i:s', strtotime($rs['etime'])+3600*2);
|
||||
$kqdkjl = m('kqdkjl')->getall("`uid`='".$rs['uid']."' and `dkdt`>='$stime' and `dkdt`<='$etime'",'dkdt','`dkdt` desc');
|
||||
if($kqdkjl)$dakatime='';
|
||||
foreach($kqdkjl as $k=>$rs1){
|
||||
if($k>0)$dakatime.=', ';
|
||||
$dakatime.=''.$rs1['dkdt'].'';
|
||||
}
|
||||
}
|
||||
|
||||
if($type==1)$rs['jiatype'].=''.$rs['jiafee'].'元';
|
||||
if($type=='0')$rs['jiafee'] = '';
|
||||
|
||||
$rs['dakatime'] = $dakatime;
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
||||
protected function flowgetfields($lx)
|
||||
{
|
||||
$arr['dakatime'] = '此时间段打卡';
|
||||
return $arr;
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$month = $this->rock->post('month');
|
||||
$where = '';
|
||||
if($month!=''){
|
||||
$where.=" and `stime` like '$month%'";
|
||||
}
|
||||
|
||||
return array(
|
||||
'where' => $where
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
protected function flowcheckfinsh($zt)
|
||||
{
|
||||
if($zt==1)m('flow:leave')->updateenddt();
|
||||
}
|
||||
|
||||
}
|
||||
33
webmain/model/flow/knowledgeModel.php
Normal file
33
webmain/model/flow/knowledgeModel.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
class flow_knowledgeClassModel extends flowModel
|
||||
{
|
||||
protected function flowchangedata(){
|
||||
$this->rs['content'] = c('html')->replace($this->rs['content']);
|
||||
}
|
||||
|
||||
protected function flowdatalog($arr)
|
||||
{
|
||||
return array('title'=>'');
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$where = '';
|
||||
$typeid = (int)$this->rock->post('typeid','0');
|
||||
$key = $this->rock->post('key');
|
||||
if($typeid!='0'){
|
||||
$alltpeid = m('option')->getalldownid($typeid);
|
||||
$where .= ' and a.`typeid` in('.$alltpeid.')';
|
||||
}
|
||||
if($key != ''){
|
||||
$where.=" and (a.`title` like '%$key%' or b.`name` like '%$key%')";
|
||||
}
|
||||
return array(
|
||||
'where' => $where,
|
||||
'order' => 'a.`sort`,a.`optdt` desc',
|
||||
'asqom' => 'a.',
|
||||
'table' => '`[Q]'.$this->mtable.'` a left join `[Q]option` b on a.`typeid`=b.`id`',
|
||||
'fields'=> 'a.id,a.title,a.adddt,a.optdt,a.optname,b.`name` as typename,a.`sort`'
|
||||
);
|
||||
}
|
||||
}
|
||||
126
webmain/model/flow/knowtikuModel.php
Normal file
126
webmain/model/flow/knowtikuModel.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
class flow_knowtikuClassModel extends flowModel
|
||||
{
|
||||
protected function flowchangedata(){
|
||||
$this->rs['content'] = c('html')->replace($this->rs['content']);
|
||||
|
||||
}
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
$this->logobj = m('log');
|
||||
$this->typearr= array('单选','多选','判断题');
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs,$isv=0)
|
||||
{
|
||||
if(isset($rs['typeid']))$rs['typeid'] = $this->db->getmou('[Q]option','name',"`id`='".$rs['typeid']."'");
|
||||
$rs['type'] = arrvalue($this->typearr, $rs['type']);
|
||||
if($isv==1){
|
||||
$ss = '<font color=#888888>停用</font>';
|
||||
if($rs['status']==1)$ss = '<font color=green>启用</font>';
|
||||
$rs['status'] = $ss;
|
||||
}
|
||||
|
||||
if($isv==2){
|
||||
$zt = $this->logobj->isread($this->mtable, $rs['id'], $this->adminid);
|
||||
if($zt>0)$rs['ishui']=1;
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$where = '';
|
||||
$typeid = (int)$this->rock->post('typeid','0');
|
||||
$key = $this->rock->post('key');
|
||||
if($lx=='xuexi')$where='and a.`status`=1';
|
||||
if($typeid!='0'){
|
||||
$alltpeid = m('option')->getalldownid($typeid);
|
||||
$where .= ' and a.`typeid` in('.$alltpeid.')';
|
||||
}
|
||||
if($key != ''){
|
||||
$where.=" and (a.`title` like '%$key%' or b.`name` like '%$key%')";
|
||||
}
|
||||
return array(
|
||||
'where' => $where,
|
||||
'order' => 'a.`sort`,a.`optdt` desc',
|
||||
'table' => '`[Q]'.$this->mtable.'` a left join `[Q]option` b on a.`typeid`=b.`id`',
|
||||
'fields'=> 'a.*,b.name as typename',
|
||||
'asqom' => 'a.'
|
||||
);
|
||||
}
|
||||
|
||||
//导入数据的测试显示
|
||||
public function flowdaorutestdata()
|
||||
{
|
||||
$barr = array(
|
||||
'title' => '信呼要求PHP最低版本',
|
||||
'typeid' => '官网知识',
|
||||
'type' => '单选',
|
||||
'ana' => '5.2',
|
||||
'anb' => '5.3',
|
||||
'anc' => '5.4',
|
||||
'and' => '5.5',
|
||||
'answer' => 'B',
|
||||
'explain' => '详见官网说明使用',
|
||||
);
|
||||
$barr1 = array(
|
||||
'title' => '信呼要求MySql最低版本',
|
||||
'typeid' => '官网知识',
|
||||
'type' => '单选',
|
||||
'ana' => '5.0',
|
||||
'anb' => '5.3',
|
||||
'anc' => '5.4',
|
||||
'and' => '5.5',
|
||||
'ane' => '',
|
||||
'answer' => 'D',
|
||||
'explain' => '详见官网说明使用',
|
||||
);
|
||||
$barr2 = array(
|
||||
'title' => 'PHP如何连接数据库方式',
|
||||
'typeid' => '技术姿势/PHP知识',
|
||||
'type' => '多选',
|
||||
'ana' => 'mysql',
|
||||
'anb' => 'mysqli',
|
||||
'anc' => 'pdo',
|
||||
'and' => 'mssql',
|
||||
'ane' => 'com',
|
||||
'answer' => 'ABC',
|
||||
'explain' => 'D选项为别的数据库',
|
||||
);
|
||||
$barr3 = array(
|
||||
'title' => '信呼官网域名是rockoa.com',
|
||||
'typeid' => '官网知识',
|
||||
'type' => '判断题',
|
||||
'ana' => '正确',
|
||||
'anb' => '错误',
|
||||
'anc' => '',
|
||||
'and' => '',
|
||||
'answer' => 'A',
|
||||
'explain' => '',
|
||||
);
|
||||
return array($barr,$barr1,$barr2,$barr3);
|
||||
}
|
||||
|
||||
//导入之前
|
||||
public function flowdaorubefore($rows)
|
||||
{
|
||||
$inarr = array();
|
||||
$num = 'knowtikutype';
|
||||
if(ISMORECOM && $cnum=$this->adminmodel->getcompanynum())$num.='_'.$cnum.'';
|
||||
foreach($rows as $k=>$rs){
|
||||
$rs['typeid'] = $this->option->gettypeid($num,$rs['typeid']);
|
||||
$types = arrvalue($rs,'type');
|
||||
$type1 = 0;
|
||||
if($types=='多选')$type1 = 1;
|
||||
if($types=='判断题')$type1 = 2;
|
||||
$rs['type'] = $type1;
|
||||
$inarr[] = $rs;
|
||||
}
|
||||
|
||||
return $inarr;
|
||||
}
|
||||
}
|
||||
123
webmain/model/flow/knowtraimModel.php
Normal file
123
webmain/model/flow/knowtraimModel.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/**
|
||||
* 考试培训
|
||||
*/
|
||||
class flow_knowtraimClassModel extends flowModel
|
||||
{
|
||||
public function initModel()
|
||||
{
|
||||
$this->statearr = explode(',','<font color=#ff6600>还未开始</font>,<font color=green>进行中</font>,<font color=#888888>已结束</font>');
|
||||
}
|
||||
|
||||
public function getstatestr($zt)
|
||||
{
|
||||
return arrvalue($this->statearr, $zt);
|
||||
}
|
||||
|
||||
protected function flowsubmit($na, $sm)
|
||||
{
|
||||
if($this->rs['status']==1)$this->sendtodo();
|
||||
}
|
||||
|
||||
//审核完成后发通知
|
||||
protected function flowcheckfinsh($zt)
|
||||
{
|
||||
if($zt==1)$this->sendtodo();
|
||||
}
|
||||
|
||||
//发通知给对应人员
|
||||
public function sendtodo()
|
||||
{
|
||||
$rows = m('knowtrais')->getall('mid='.$this->id.' and `isks`=0','uid');
|
||||
$ids = '';
|
||||
foreach($rows as $k=>$rs)$ids.=','.$rs['uid'].'';
|
||||
if($ids=='')return;
|
||||
$ids = substr($ids, 1);
|
||||
|
||||
$cont = ''.$this->adminname.'发布培训考试,主题:{title},时间{startdt}至{enddt}。';
|
||||
$this->push($ids,'', $cont);
|
||||
}
|
||||
|
||||
public function flowisreadqx()
|
||||
{
|
||||
$to = m('knowtrais')->rows('`mid`='.$this->id.' and `uid`='.$this->adminid.'');
|
||||
return $to>0;
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs,$lx=0)
|
||||
{
|
||||
$zt = $rs['state'];
|
||||
$rs['state'] = $this->getstatestr($zt);
|
||||
if($lx==1 && $zt==1){
|
||||
//我当前状态
|
||||
$ors = m('knowtrais')->getone('`mid`='.$rs['id'].' and `uid`='.$this->adminid.'');
|
||||
if($ors){
|
||||
if($ors['isks']=='0'){
|
||||
$rs['state'] .= ' <a class="zhu" href="index.php?m=hr&a=kaoshi&d=main&id='.$this->id.'">去考试</a>';
|
||||
}else{
|
||||
$rs['state'] .= ' 已考试分数:'.$ors['fenshu'].'';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
|
||||
//更新题库状态
|
||||
public function reloadstate($id='')
|
||||
{
|
||||
$where = '1=1';
|
||||
if($id!='')$where='id in('.$id.')';
|
||||
$rows = $this->getall($where);
|
||||
$now = $this->rock->now;
|
||||
foreach($rows as $k=>$rs){
|
||||
$zt = 0;
|
||||
if($rs['enddt']<$now){
|
||||
$zt = 2;
|
||||
}else if($rs['startdt']<$now){
|
||||
$zt = 1;
|
||||
}
|
||||
if($zt!=$rs['state'])$this->update('`state`='.$zt.'', $rs['id']);
|
||||
}
|
||||
$rows = $this->db->getall('SELECT mid,count(1)stotal FROM `[q]knowtrais` where isks=1 GROUP BY mid');
|
||||
foreach($rows as $k=>$rs)$this->update('`ydshu`='.$rs['stotal'].'', $rs['mid']);
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$this->reloadstate();
|
||||
}
|
||||
|
||||
//每天通知未考试培训人员
|
||||
public function todaytodo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//选取选择题库的条件
|
||||
public function gettikuwhere($tiid, $dwid=0)
|
||||
{
|
||||
$str1 = '';
|
||||
if($dwid==0)$dwid = $this->adminmodel->getcompanyid();
|
||||
if(ISMORECOM)$str1 = " and `comid`=".$dwid."";
|
||||
if(isempt($tiid))return $str1;
|
||||
$sid = '';
|
||||
$tarr = explode(',', $tiid);
|
||||
$dbs = m('option');
|
||||
foreach($tarr as $sid1){
|
||||
$ssid = $dbs->getalldownid($sid1);
|
||||
$sid.=','.$ssid.'';
|
||||
}
|
||||
if($sid!=''){
|
||||
$sid = substr($sid, 1);
|
||||
return ' and `typeid` in('.$sid.')';
|
||||
}else{
|
||||
return $str1;
|
||||
}
|
||||
}
|
||||
|
||||
//删除单据时调用
|
||||
protected function flowdeletebill($sm)
|
||||
{
|
||||
m('knowtrais')->delete("`mid`='".$this->id."'");
|
||||
}
|
||||
}
|
||||
147
webmain/model/flow/kqdkjlModel.php
Normal file
147
webmain/model/flow/kqdkjlModel.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
class flow_kqdkjlClassModel extends flowModel
|
||||
{
|
||||
|
||||
protected $flowcompanyidfieds = 'uid'; //多单位用这个关联
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
$this->dateobj = c('date');
|
||||
|
||||
$this->typearr = explode(',','在线打卡,考勤机,手机定位,手动添加,异常添加,数据导入,接口导入,企业微信打卡,钉钉打卡,中控考勤机');//0-9
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示条件过滤
|
||||
*/
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$atype = $lx;
|
||||
$dt1 = $this->rock->post('dt1');
|
||||
$dt2 = $this->rock->post('dt2');
|
||||
$key = $this->rock->post('key');
|
||||
$s = '';
|
||||
$s = ' and a.`uid`='.$this->adminid.'';
|
||||
|
||||
//全部下属打卡
|
||||
if($lx=='down' || $lx=='dwdown'){
|
||||
$s = 'and '.$this->adminmodel->getdownwheres('b.id', $uid, 0);
|
||||
}
|
||||
if($atype=='all')$s ='';
|
||||
if(!isempt($dt1))$s.=" and a.`dkdt`>='$dt1'";
|
||||
if(!isempt($dt2))$s.=" and a.`dkdt`<='$dt2 23:59:59'";
|
||||
if(!isempt($key))$s.=" and (b.`name` like '%$key%' or b.`deptallname` like '%$key%' or b.`ranking` like '%$key%')";
|
||||
$fields = 'a.*,b.`name`,b.`deptname`';
|
||||
$tabls = $this->mtable;
|
||||
|
||||
$table = '`[Q]'.$tabls.'` a left join `[Q]userinfo` b on a.uid=b.id';
|
||||
return array(
|
||||
'where' => $s,
|
||||
'table' => $table,
|
||||
'order' => 'a.`id` desc',
|
||||
'fields'=> $fields
|
||||
);
|
||||
}
|
||||
|
||||
//替换
|
||||
public function flowrsreplace($rs)
|
||||
{
|
||||
$week = $this->dateobj->cnweek($rs['dkdt']);
|
||||
$rs['week'] = $week;
|
||||
$rs['type'] = $this->typearr[$rs['type']];
|
||||
if($week=='六' || $week=='日')$rs['ishui']= 1;
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
public function flowdaorutestdata()
|
||||
{
|
||||
$barr[] = array(
|
||||
'base_name' => '管理员',
|
||||
'dkdt' => '2016-08-08 12:00:01',
|
||||
);
|
||||
$barr[] = array(
|
||||
'base_name' => '大乔',
|
||||
'dkdt' => '2017-08-22 08:55:01',
|
||||
);
|
||||
return $barr;
|
||||
}
|
||||
|
||||
//导入之前判断
|
||||
public function flowdaorubefore($rows)
|
||||
{
|
||||
$inarr = array();
|
||||
$uarr = array();
|
||||
$dtobj = c('date');
|
||||
foreach($rows as $k=>$rs){
|
||||
$name = $rs['base_name'];
|
||||
$dkdt = $rs['dkdt'];
|
||||
if(isempt($name) || isempt($dkdt))continue;
|
||||
|
||||
$dkdt = str_replace('/','-', $dkdt);
|
||||
if(!$dtobj->isdate($dkdt))continue;
|
||||
|
||||
if(isset($uarr[$name])){
|
||||
$uid = $uarr[$name];
|
||||
}else{
|
||||
$usar = $this->adminmodel->getrows("`name`='$name'",'id');
|
||||
if($this->db->count!=1)continue;
|
||||
$uid = $usar[0]['id'];
|
||||
$uarr[$name] = $uid;
|
||||
}
|
||||
|
||||
if($this->rows("`uid`='$uid' and `dkdt`='$dkdt'")>0)continue;
|
||||
$inarr[] = array(
|
||||
'uid' => $uid,
|
||||
'dkdt' => $dkdt,
|
||||
'type' => 5,
|
||||
);
|
||||
}
|
||||
|
||||
return $inarr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页考勤打卡记录
|
||||
*/
|
||||
public function homekqtotal()
|
||||
{
|
||||
$dt = $this->rock->date;
|
||||
$where= $this->adminmodel->getcompanywhere(5,'a.');
|
||||
$uarr = $this->db->getall('select a.id from `[Q]admin` a left join `[Q]userinfo` b on a.id=b.id where b.`iskq`=1 and a.`status`=1 '.$where.'');
|
||||
$uids = '0';
|
||||
$uarrs = array();
|
||||
foreach($uarr as $k=>$rs){
|
||||
$uids.=','.$rs['id'].'';
|
||||
$uarrs[$rs['id']] = '未打卡';
|
||||
}
|
||||
$rows = $this->db->getall("SELECT * FROM `[Q]kqanay` where `uid` in($uids) and `dt`='$dt' and sort=0");
|
||||
foreach($rows as $k=>$rs){
|
||||
$state = $rs['state'];
|
||||
if(!isempt($rs['states']))$state = $rs['states'];
|
||||
$uarrs[$rs['uid']] = $state;
|
||||
}
|
||||
|
||||
$ztarr = array();
|
||||
foreach($uarrs as $uid=>$zt){
|
||||
if(!isset($ztarr[$zt]))$ztarr[$zt]=0;
|
||||
$ztarr[$zt]++;
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
$data = array();
|
||||
foreach($ztarr as $zt=>$vs){
|
||||
$rows[] = array(
|
||||
'value' => $vs,
|
||||
'name' => $zt
|
||||
);
|
||||
$data[] = $zt;
|
||||
}
|
||||
return array(
|
||||
'rows' => $rows,
|
||||
'data' => $data,
|
||||
'dt' => $dt,
|
||||
);
|
||||
}
|
||||
}
|
||||
63
webmain/model/flow/kqdwModel.php
Normal file
63
webmain/model/flow/kqdwModel.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
class flow_kqdwClassModel extends flowModel
|
||||
{
|
||||
protected $flowcompanyidfieds = 'uid'; //多单位用这个关联
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
$this->dateobj = c('date');
|
||||
$this->typearr = explode(',','普通,事件,企业微信定位');
|
||||
}
|
||||
|
||||
//打开详情时跳转到地理位置显示
|
||||
protected function flowchangedata()
|
||||
{
|
||||
if(!isajax() && !isempt($this->rs['location_x'])){
|
||||
$url = 'index.php?m=kaoqin&a=location&d=main&id='.$this->id.'';
|
||||
$this->rock->location($url);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示条件过滤
|
||||
*/
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$atype = $lx;
|
||||
$dt1 = $this->rock->post('dt1');
|
||||
$dt2 = $this->rock->post('dt2');
|
||||
$key = $this->rock->post('key');
|
||||
$s = '';
|
||||
$s = ' and b.id='.$this->adminid.'';
|
||||
|
||||
//全部下属打卡
|
||||
if($lx=='down'){
|
||||
$s = 'and '.$this->adminmodel->getdownwheres('b.id', $uid, 0);
|
||||
}
|
||||
if($atype=='all')$s ='';
|
||||
if(!isempt($dt1))$s.=" and a.`optdt`>='$dt1'";
|
||||
if(!isempt($dt2))$s.=" and a.`optdt`<='$dt2 23:59:59'";
|
||||
if(!isempt($key))$s.=" and (b.`name` like '%$key%' or b.`deptallname` like '%$key%' or b.`ranking` like '%$key%')";
|
||||
$fields = 'a.*,b.name,b.deptname';
|
||||
$tabls = $this->mtable;
|
||||
|
||||
$table = '`[Q]'.$tabls.'` a left join `[Q]userinfo` b on a.uid=b.id';
|
||||
return array(
|
||||
'where' => $s,
|
||||
'table' => $table,
|
||||
'order' => 'a.`id` desc',
|
||||
'fields'=> $fields
|
||||
);
|
||||
}
|
||||
|
||||
//替换
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
$week = $this->dateobj->cnweek($rs['optdt']);
|
||||
$rs['week'] = $week;
|
||||
if($week=='六' || $week=='日')$rs['ishui']= 1;
|
||||
$rs['type']= arrvalue($this->typearr, $rs['type']);
|
||||
return $rs;
|
||||
}
|
||||
}
|
||||
48
webmain/model/flow/kqerrModel.php
Normal file
48
webmain/model/flow/kqerrModel.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
class flow_kqerrClassModel extends flowModel
|
||||
{
|
||||
|
||||
//审核完成了添加到打卡记录
|
||||
protected function flowcheckfinsh($zt)
|
||||
{
|
||||
m('kqdkjl')->insert(array(
|
||||
'uid' => $this->uid,
|
||||
'optdt' => $this->rock->now,
|
||||
'dkdt' => $this->rs['dt'].' '.$this->rs['ytime'],
|
||||
'type' => '4',
|
||||
'explain' => '['.$this->rs['errtype'].']'.$this->rs['explain'].'',
|
||||
));
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$month = $this->rock->post('month');
|
||||
$where = '';
|
||||
if($month!=''){
|
||||
$where.=" and a.`dt` like '$month%'";
|
||||
}
|
||||
|
||||
return array(
|
||||
'where' => $where
|
||||
);
|
||||
}
|
||||
|
||||
protected function flowbillwhere33($uid, $lx)
|
||||
{
|
||||
$dt = $this->rock->date;
|
||||
$key = $this->rock->post('key');
|
||||
$month = $this->rock->post('month');
|
||||
$where = "a.`uid`=$uid";
|
||||
if($lx=='all'){
|
||||
$where = '1=1';
|
||||
}
|
||||
if($key!='')$where.= m('admin')->getkeywhere($key, 'b.');
|
||||
if($month !='')$where.=" and a.`dt` like '$month%'";
|
||||
return array(
|
||||
'where' => 'and '.$where,
|
||||
'fields'=> 'a.*,b.name,b.deptname,b.ranking',
|
||||
'table' => '`[Q]'.$this->mtable.'` a left join `[Q]admin` b on a.`uid`=b.`id`',
|
||||
'order' => 'a.`id` desc'
|
||||
);
|
||||
}
|
||||
}
|
||||
20
webmain/model/flow/kqjsnModel.php
Normal file
20
webmain/model/flow/kqjsnModel.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
//考勤机设备
|
||||
class flow_kqjsnClassModel extends flowModel
|
||||
{
|
||||
public function flowrsreplace($rs)
|
||||
{
|
||||
if(isempt($rs['lastdt'])){
|
||||
$rs['ishui'] = 1;
|
||||
}else{
|
||||
if(time()-strtotime($rs['lastdt'])>5*60)$rs['ishui'] = 1;//5分钟没请求
|
||||
}
|
||||
if($rs['space']>0)$rs['space'] = $this->rock->formatsize($rs['space']);
|
||||
if($rs['memory']>0)$rs['memory'] = $this->rock->formatsize($rs['memory']);
|
||||
|
||||
$kqjarr = array('群英','中控');
|
||||
if(isset($rs['pinpai']))$rs['pinpai'] = $kqjarr[$rs['pinpai']];
|
||||
|
||||
return $rs;
|
||||
}
|
||||
}
|
||||
123
webmain/model/flow/leaveModel.php
Normal file
123
webmain/model/flow/leaveModel.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
//请假条的
|
||||
class flow_leaveClassModel extends flowModel
|
||||
{
|
||||
|
||||
public function flowrsreplace($rs)
|
||||
{
|
||||
$rs['modenum'] = $this->modenum;
|
||||
$totday = floatval(arrvalue($rs,'totday','0'));
|
||||
if($totday>0)$rs['totals'].='('.$totday.'天)';
|
||||
return $rs;
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$month = $this->rock->post('month');
|
||||
$where = '';
|
||||
if($month!=''){
|
||||
$where.=" and `stime` like '$month%'";
|
||||
}
|
||||
|
||||
return array(
|
||||
'where' => $where
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 年假添加设置(自动添加),可计划任务没有运行一次,兑换为小时的,默认一天8小时
|
||||
*/
|
||||
public function autoaddleave($ndate='')
|
||||
{
|
||||
$type = 0; //根据哪个类型计算年:0根据入职日期,1根据转正日期
|
||||
$hour = (int)m('option')->getval('kqsbtime', 8); //默认一天8小时(请自己设定)
|
||||
if($hour<=0)$hour = 8;
|
||||
if($ndate=='')$ndate = $this->rock->date;
|
||||
if($ndate > $this->rock->date)return array();
|
||||
$Y = substr($ndate,0,4);
|
||||
$niana = array(
|
||||
// 开始 截止 年假天数
|
||||
array(0, 0, 0), //0-0年,0天
|
||||
array(1, 10, 5), //1年(含)-10年(含),5天
|
||||
array(11, 20, 10), //11年(含)-20年(含),10天
|
||||
array(21, 9999, 15), //21年(含)以上,15天
|
||||
);
|
||||
//配置可根据自己情况修改
|
||||
$adlx = array('workdate','positivedt');
|
||||
$adln = array('入职','转正');
|
||||
$dtobj= c('date');
|
||||
|
||||
$usea = $this->db->getall("select `uid` from `[Q]kqinfo` where `kind`='增加年假' and `status`=1 and `optname`='系统' and `stime` like '".$Y."-%'"); //系统已经自动添加过
|
||||
$uids = '0';
|
||||
foreach($usea as $k=>$rs)$uids.=','.$rs['uid'].'';
|
||||
$rows = $this->db->getall("select a.`id`,a.`name`,a.`workdate`,b.`positivedt` from `[Q]admin` a left join `[Q]userinfo` b on a.id=b.id where a.`status`=1 and a.id not in($uids) and b.`state`<>5");
|
||||
$barr = array();
|
||||
foreach($rows as $k=>$rs){
|
||||
$dt = $rs[$adlx[$type]];
|
||||
if(isempt($dt))continue;
|
||||
$dttime = strtotime($dt);
|
||||
$rs['dt'] = $dt;
|
||||
$jg = $dtobj->datediff('d', $dt, $ndate);
|
||||
$yea= (int)($jg/365); //年限
|
||||
if($yea==0)continue;//未满1年
|
||||
$nianday = 0; //年假条数
|
||||
foreach($niana as $k1=>$ns){
|
||||
if($yea>=$ns[0] && $yea<=$ns[1]){
|
||||
$nianday = $ns[2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$dt = date(''.$Y.'-m-d', $dttime);
|
||||
if(strtotime($dt) > strtotime($ndate) )continue;//还没到对应日期
|
||||
|
||||
$rs['nianday'] = $nianday;
|
||||
$rs['nyear'] = $yea; //入职年限
|
||||
$rs['stime'] = $dt.' 00:00:00';
|
||||
$rs['etime'] = $dt.' 23:59:59';
|
||||
$rs['nianhour'] = $nianday * $hour; //小时
|
||||
$barr[] = $rs;
|
||||
}
|
||||
|
||||
//添加到kqinfo表上
|
||||
$dbs = m('kqinfo');
|
||||
foreach($barr as $k=>$rs){
|
||||
$uarr['uid'] = $rs['id'];
|
||||
$uarr['uname'] = $rs['name'];
|
||||
$uarr['stime'] = $rs['stime'];
|
||||
$uarr['etime'] = $rs['etime'];
|
||||
$uarr['kind'] = '增加年假';
|
||||
$uarr['status'] = '1';
|
||||
$uarr['totals'] = $rs['nianhour'];
|
||||
$uarr['optdt'] = $this->rock->now;
|
||||
$uarr['isturn'] = '1';
|
||||
$uarr['optname'] = '系统';
|
||||
$uarr['optid'] = '0';
|
||||
$uarr['applydt'] = $this->rock->date;
|
||||
$uarr['totday'] = $rs['nianday'];
|
||||
$uarr['explain'] = ''.$rs['dt'].''.$adln[$type].'年限满'.$rs['nyear'].'年添加年假'.$rs['nianday'].'天';
|
||||
$dbs->insert($uarr);
|
||||
}
|
||||
$this->updateenddt();
|
||||
return $barr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新年假/加班单的截止时间
|
||||
*/
|
||||
public function updateenddt()
|
||||
{
|
||||
$dbs = m('option');
|
||||
$jbuse = (int)$dbs->getval('kqjiabanuse', 0); //加班
|
||||
$njuse = (int)$dbs->getval('kqnianjiause', 0);
|
||||
$db = m('kqinfo');
|
||||
if($jbuse>0){
|
||||
$key = "CONCAT(date_format(date_add(stime,interval ".$jbuse." month),'%Y-%m-%d'),' ','23:59:59')";
|
||||
$db->update('enddt='.$key.'',"`kind`='加班' and `enddt` is null"); //兑换调休的
|
||||
}
|
||||
|
||||
if($njuse>0){
|
||||
$key = "CONCAT(date_format(date_add(stime,interval ".$njuse." month),'%Y-%m-%d'),' ','23:59:59')";
|
||||
$db->update('enddt='.$key.'',"`kind`='增加年假' and `enddt` is null");
|
||||
}
|
||||
}
|
||||
}
|
||||
50
webmain/model/flow/leavehrModel.php
Normal file
50
webmain/model/flow/leavehrModel.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
//考勤信息
|
||||
class flow_leavehrClassModel extends flowModel
|
||||
{
|
||||
//导入数据的测试显示
|
||||
public function flowdaorutestdata()
|
||||
{
|
||||
$barr[]=array(
|
||||
'uname' => '张飞',
|
||||
'kind' => '增加年假',
|
||||
'stime' => '2019-07-01 00:00:00',
|
||||
'etime' => '2020-07-01 00:00:00',
|
||||
'totals' => '16',
|
||||
'totday' => '2',
|
||||
'explain' => '奖励2天年假',
|
||||
|
||||
);
|
||||
$barr[]=array(
|
||||
'uname' => '赵子龙',
|
||||
'kind' => '增加陪产假',
|
||||
'stime' => '2019-07-01 08:00:00',
|
||||
'etime' => '2020-07-01 18:00:00',
|
||||
'totals' => '120',
|
||||
'totday' => '15',
|
||||
'explain' => '陪产假男性,一般15天是要一次休完',
|
||||
|
||||
);
|
||||
return $barr;
|
||||
}
|
||||
|
||||
//导入之前判断
|
||||
public function flowdaorubefore($rows)
|
||||
{
|
||||
$inarr = array();
|
||||
foreach($rows as $k=>$rs){
|
||||
$urs = $this->adminmodel->geturs($rs['uname']);
|
||||
if(!$urs)return '行'.($k+1).'找不到对应人员:'.$rs['uname'].'';
|
||||
|
||||
$rs['uid'] = $urs['id'];
|
||||
$rs['uname'] = $urs['name'];
|
||||
$rs['comid'] = $urs['companyid'];
|
||||
$rs['applydt'] = $this->rock->date;
|
||||
|
||||
$rs['status']=1;
|
||||
$rs['isturn']=1;
|
||||
$inarr[] = $rs;
|
||||
}
|
||||
return $inarr;
|
||||
}
|
||||
}
|
||||
339
webmain/model/flow/meetModel.php
Normal file
339
webmain/model/flow/meetModel.php
Normal file
@@ -0,0 +1,339 @@
|
||||
<?php
|
||||
|
||||
class flow_meetClassModel extends flowModel
|
||||
{
|
||||
public function initModel()
|
||||
{
|
||||
$this->hyarra = array('正常','会议中','结束','取消');
|
||||
$this->hyarrb = array('green','blue','#ff6600','#888888');
|
||||
$this->dbobj = c('date');
|
||||
|
||||
$this->reatearr = array(
|
||||
'd' => '每天',
|
||||
'w1' => '每周一',
|
||||
'w2' => '每周二',
|
||||
'w3' => '每周三',
|
||||
'w4' => '每周四',
|
||||
'w5' => '每周五',
|
||||
'w6' => '每周六',
|
||||
'w7' => '每周日',
|
||||
'm' => '每月',
|
||||
'y' => '每年',
|
||||
);
|
||||
}
|
||||
|
||||
public function getratestore()
|
||||
{
|
||||
$arr = array();
|
||||
foreach($this->reatearr as $k=>$v)$arr[] = array(
|
||||
'value' => $k,
|
||||
'name' => $v
|
||||
);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
if(arrvalue($rs, 'type')=='1'){
|
||||
$ztrs = '<font color=green>启用</font>';
|
||||
if($rs['status']=='0'){
|
||||
$ztrs = '<font color=#888888>停用</font>';
|
||||
$rs['ishui']=1;
|
||||
}
|
||||
if(!isempt($rs['rate']))$ztrs.=','.arrvalue($this->reatearr,$rs['rate']).''; //转未汉字
|
||||
$rs['state'] = $ztrs;
|
||||
return $rs;//说明是固定会议
|
||||
}
|
||||
$rs['week'] = $this->dbobj->cnweek($rs['startdt']);
|
||||
$zt = $rs['state'];
|
||||
$nzt = $zt;
|
||||
$time = time();
|
||||
|
||||
$stime = strtotime($rs['startdt']);
|
||||
$etime = strtotime($rs['enddt']);
|
||||
if($zt < 2){
|
||||
if($etime<$time){
|
||||
$nzt = 2;
|
||||
}else if($stime>$time){
|
||||
$nzt = 0;
|
||||
}else{
|
||||
$nzt = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if($zt != $nzt){
|
||||
$this->update('state='.$nzt.'', $rs['id']);
|
||||
$zt = $nzt;
|
||||
}
|
||||
|
||||
$rs['ishui'] = ($zt>=2) ? 1 : 0;
|
||||
if($lx==1){
|
||||
$content = '';
|
||||
$inpurl = $this->getinputurl('meetjy',0,'def_mid='.$this->id.'');
|
||||
$rows = $this->getrows('`mid`='.$this->id.' and `type`=2','id,content,optname,optdt,optid','id');
|
||||
//是否可以加会议纪要
|
||||
$dtss = c('date')->adddate($this->rock->date,'d',-10).' 00:00:00';
|
||||
$addbo = $rs['startdt']>$dtss && $zt>0;
|
||||
$fobj = m('file');
|
||||
foreach($rows as $k=>$rs1){
|
||||
$content.= '<div style="border-bottom:1px #cccccc solid;padding:5px">['.$rs1['optname'].']纪要';
|
||||
$inpurl1 = $this->getinputurl('meetjy',$rs1['id']);
|
||||
if($addbo && $rs1['optid']==$this->adminid)$content.= ' <a href="'.$inpurl1.'" class="blue">[编辑]</a>';
|
||||
$content.= ':<br>'.$rs1['content'].'';
|
||||
$fstr = $fobj->getstr('meet', $rs1['id'], 2);
|
||||
if($fstr!='')$content.= '<br>'.$fstr.'';
|
||||
$content.= '</div>';
|
||||
}
|
||||
|
||||
if($addbo){
|
||||
$content.=' <a href="'.$inpurl.'" class="blue">+新增纪要</a>';
|
||||
}
|
||||
$rs['content']= $content;
|
||||
$rs['content_style'] = 'padding:0px';
|
||||
}
|
||||
$rs['state'] = $this->getstatezt($zt);
|
||||
$rs['nzt'] = $zt;
|
||||
if(isset($rs['issms'])){
|
||||
$issms = '否';
|
||||
if($rs['issms']==1)$issms = '是';
|
||||
$rs['issms'] = $issms;
|
||||
}
|
||||
|
||||
//打印时
|
||||
if($lx==3){
|
||||
if(substr($rs['startdt'],0,10)==$this->rock->date)$rs['startdt'] = substr($rs['startdt'],11);
|
||||
if(substr($rs['enddt'],0,10)==$this->rock->date)$rs['enddt'] = substr($rs['enddt'],11);
|
||||
$rs['ermurl'] = $this->rock->jm->base64encode(getconfig('outurl',URL).'task.php?a=x&num=meet&mid='.$rs['id'].'&showtype=qd');
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
||||
//签到菜单判断
|
||||
protected function flowgetoptmenu($num)
|
||||
{
|
||||
if($num=='qdnoup'){
|
||||
if($this->rock->get('showtype')!='qd')return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getstatezt($zt)
|
||||
{
|
||||
return '<font color="'.$this->hyarrb[$zt].'">'.$this->hyarra[$zt].'</font>';
|
||||
}
|
||||
|
||||
protected function flowsubmit($na, $sm)
|
||||
{
|
||||
if($this->rs['status']==1){
|
||||
$this->tisongtodo();
|
||||
}
|
||||
//固定会议
|
||||
if($this->rs['type']=='1'){
|
||||
$this->createmeet($this->id);
|
||||
}
|
||||
}
|
||||
|
||||
//审核完成后发通知
|
||||
protected function flowcheckfinsh($zt)
|
||||
{
|
||||
if($zt==1)$this->tisongtodo();
|
||||
}
|
||||
|
||||
private function tisongtodo()
|
||||
{
|
||||
if($this->rs['type']!='0')return;//这个是普通会议才需要通知。
|
||||
|
||||
if($this->rs['startdt'] < $this->rock->now)return;//已过期了
|
||||
|
||||
//发给参会人
|
||||
//$cont = '{optname}发起会议“{title}”在{hyname},时间{startdt}至{enddt}';
|
||||
//$this->push($this->rs['joinid'], '会议', $cont);
|
||||
$cont = "您好,您有一个新的会议计划。\n\n会议主题:{title}\n会议时间:{startdt}至{enddt}\n会议地点:{hyname}";
|
||||
$zcren= arrvalue($this->rs,'zcren');
|
||||
if(!isempt($zcren)){
|
||||
$cont.="\n会议主持人:{zcren}";
|
||||
}else{
|
||||
$cont.="\n发起人:{optname}";
|
||||
}
|
||||
$this->pushs($this->rs['joinid'], $cont, '会议通知');
|
||||
|
||||
$tplnum = m('option')->getval('meetsmstpl', 'meetapply');
|
||||
$this->sendsms($this->rs, $tplnum, array(
|
||||
'optname' => $this->adminname,
|
||||
'title' => $this->rs['title'],
|
||||
'hyname' => $this->rs['hyname'],
|
||||
'startdt' => $this->rs['startdt'],
|
||||
'enddt' => $this->rs['enddt'],
|
||||
));
|
||||
}
|
||||
|
||||
protected function flowaddlog($a)
|
||||
{
|
||||
$actname = $a['name'];
|
||||
if($actname == '取消会议'){
|
||||
$this->push($this->rs['joinid'], '会议', ''.$this->adminname.'取消会议“{title}”,时间{startdt}至{enddt},请悉知。');
|
||||
$this->update('`state`=3', $this->id);
|
||||
|
||||
$tplnum = m('option')->getval('meetsmstplqx', 'meetcancel');
|
||||
$this->sendsms($this->rs, $tplnum, array(
|
||||
'optname' => $this->adminname,
|
||||
'title' => $this->rs['title'],
|
||||
'hyname' => $this->rs['hyname'],
|
||||
'startdt' => $this->rs['startdt'],
|
||||
'enddt' => $this->rs['enddt'],
|
||||
));
|
||||
}
|
||||
if($actname == '结束会议'){
|
||||
$this->update('`state`=2', $this->id);
|
||||
}
|
||||
}
|
||||
|
||||
//发短信提醒
|
||||
public function sendsms($rs, $tplnum, $params)
|
||||
{
|
||||
$receid = $rs['joinid'];
|
||||
$issms = arrvalue($rs,'issms');
|
||||
|
||||
if(isempt($receid) || $issms!='1')return;
|
||||
$jyid = $rs['jyid'];
|
||||
if(!isempt($jyid))$receid.=','.$jyid.''; //发个纪要人
|
||||
|
||||
$zcrenid= arrvalue($rs, 'zcrenid');
|
||||
if(!isempt($zcrenid))$receid.=','.$zcrenid.''; //发个主持人
|
||||
|
||||
$qiannum= ''; //签名编号,可以为空
|
||||
$barr = c('xinhuapi')->sendsms($receid, $qiannum, $tplnum, $params);
|
||||
return $barr;
|
||||
}
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$dt = $this->rock->post('dt');
|
||||
$where = '';
|
||||
//固定会议
|
||||
if($lx=='allgd'){
|
||||
$where = 'and `type`=1';
|
||||
}else{
|
||||
$where = 'and `type`=0';
|
||||
}
|
||||
if($dt!='')$where.=" and startdt like '$dt%'";
|
||||
//$fields = 'id,startdt,enddt,optname,state,title,hyname,joinname,`explain`,jyname';
|
||||
return array(
|
||||
//'fields' => $fields,
|
||||
'where' => $where,
|
||||
'order' => 'startdt desc'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//每天运行计划任务将固定会议生成普通会议通知对应人
|
||||
public function createmeet($id=0, $nowdt='', $gbrr=false)
|
||||
{
|
||||
$owhe = '';
|
||||
if($id>0)$owhe='`id`='.$id.' and ';
|
||||
$narr = $this->getall(''.$owhe.'`type`=1 and `status`=1');
|
||||
$dtobj = c('date');
|
||||
$jlarr = array();
|
||||
foreach($narr as $k=>$rs){
|
||||
$gdt = $dtobj->daterate($rs['rate'], $rs['startdt'], $nowdt);
|
||||
if(!$gdt)continue;
|
||||
$startdt = ''.$gdt.' '.substr($rs['startdt'],11).'';
|
||||
$enddt = ''.$gdt.' '.substr($rs['enddt'],11).'';
|
||||
|
||||
$ars = $rs;
|
||||
$ars['mid'] = $rs['id'];
|
||||
$ars['type'] = '0';
|
||||
$ars['startdt'] = $startdt;
|
||||
$ars['enddt'] = $enddt;
|
||||
$ars['state'] = 0;
|
||||
$ars['rate'] = '';
|
||||
unset($ars['id']);
|
||||
$this->adminmodel->setcompanyid($rs['comid']);
|
||||
$GLOBALS['adminid'] = $ars['optid'];
|
||||
$where = "`mid`=".$rs['id']." and `startdt` like '".$gdt."%'";
|
||||
$ors = $this->getone($where);
|
||||
$uwerew = '';
|
||||
$iid = 0;
|
||||
if($ors){
|
||||
$iid = $ors['id'];
|
||||
$uwerew = "`id`='$iid'";
|
||||
}
|
||||
$jlarr[] = $ars;
|
||||
|
||||
if($gbrr)continue; //不写入数据库里
|
||||
|
||||
$this->record($ars, $uwerew);
|
||||
if($iid==0){
|
||||
$iid = $this->db->insert_id();
|
||||
$this->loaddata($iid, false);
|
||||
$this->tisongtodo();//通知
|
||||
}
|
||||
}
|
||||
|
||||
return $jlarr;
|
||||
}
|
||||
|
||||
|
||||
public function meettodo()
|
||||
{
|
||||
$rows = $this->getall("`state` in(0,1) and `type`=0 and `startdt` like '".$this->rock->date."%' and `status`=1");
|
||||
$time = time();
|
||||
foreach($rows as $k=>$rs){
|
||||
$this->adminmodel->setcompanyid($rs['comid']); //设置对应单位id
|
||||
$zt = $rs['state'];
|
||||
$dts = explode(' ', $rs['startdt']);
|
||||
$sttime = strtotime($rs['startdt']);
|
||||
$ettime = strtotime($rs['enddt']);
|
||||
$GLOBALS['adminid'] = $rs['optid'];
|
||||
$nzt = -1;
|
||||
if($ettime <= $time){
|
||||
$nzt = 2;
|
||||
}else{
|
||||
if($time >= $sttime && $time< $ettime){
|
||||
if($zt==0)$nzt = 1;
|
||||
}else{
|
||||
$jg = $sttime - $time;
|
||||
if($jg <= 600 && $zt==0){ //提前10分钟就提醒
|
||||
$ssj = floor($jg/60);
|
||||
$tzuid = $this->adminmodel->gjoin($rs['joinid']);
|
||||
|
||||
//$cont = '会议“'.$rs['title'].'”将在'.$ssj.'分钟后的'.$dts[1].'开始请做好准备,在会议室“'.$rs['hyname'].'”';
|
||||
$this->loaddata($rs['id'], false);
|
||||
$this->meettodos($rs, '您好,会议即将在'.$ssj.'分钟后的'.$dts[1].'开始,请准时参加。');//快到时间通知
|
||||
|
||||
//短信通知
|
||||
if($ssj<6)$this->sendsms($rs, 'meettodo', array(
|
||||
'fenz' => ''.$ssj.'',
|
||||
'title' => $rs['title'],
|
||||
'time' => $dts[1],
|
||||
'hyname' => $rs['hyname']
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
if($nzt != -1)$this->update("`state`='$nzt'", $rs['id']);
|
||||
}
|
||||
}
|
||||
|
||||
private function meettodos($rs, $kss)
|
||||
{
|
||||
$receid = $rs['joinid'];
|
||||
if(isempt($receid))return;
|
||||
|
||||
$cont = "".$kss."\n\n会议主题:{title}\n会议时间:{startdt}至{enddt}\n会议地点:{hyname}";
|
||||
$zcren= arrvalue($rs,'zcren');
|
||||
if(!isempt($zcren)){
|
||||
$cont.="\n会议主持人:{zcren}";
|
||||
}else{
|
||||
$cont.="\n发起人:{optname}";
|
||||
}
|
||||
|
||||
$jyid = $rs['jyid'];
|
||||
if(!isempt($jyid))$receid.=','.$jyid.''; //发个纪要人
|
||||
|
||||
$zcrenid= arrvalue($rs, 'zcrenid');
|
||||
if(!isempt($zcrenid))$receid.=','.$zcrenid.''; //发个主持人
|
||||
|
||||
$this->pushs($receid, $cont, '会议提醒');
|
||||
}
|
||||
}
|
||||
144
webmain/model/flow/newsModel.php
Normal file
144
webmain/model/flow/newsModel.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
class flow_newsClassModel extends flowModel
|
||||
{
|
||||
private $readunarr = array();//未读人员
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
$this->logobj = m('log');
|
||||
$this->htmlobj = c('html');
|
||||
}
|
||||
|
||||
protected function flowchangedata(){
|
||||
$cont = c('html')->replace($this->rs['content']);
|
||||
$fm = $this->rs['fengmian'];
|
||||
if(!isempt($fm)){
|
||||
$cont='<div align="center"><img src="'.$this->rock->gethttppath($fm).'"></div>'.$cont.'';
|
||||
}
|
||||
$url = $this->rs['url'];
|
||||
if(!isempt($url))$cont.='<div><a href="'.$url.'">查看原文>></a></div>';
|
||||
$this->rs['content'] = $cont;
|
||||
}
|
||||
|
||||
public function flowrsreplace($rs, $lx=0)
|
||||
{
|
||||
$content = $rs['content'];
|
||||
if($lx==2){
|
||||
unset($rs['content']);
|
||||
$rs['smallcont'] = $this->neircong($content);
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
//移动端列表
|
||||
public function flowrsreplace_we($row, $rs)
|
||||
{
|
||||
if(!isempt($rs['fengmian']))$row['picurl'] = $rs['fengmian'];
|
||||
return $row;
|
||||
}
|
||||
public function flowwesearchdata($lx)
|
||||
{
|
||||
if($lx==1)return $this->option->getselectdata('newstype', true);
|
||||
return array(
|
||||
'typename' => '所有分类',
|
||||
'searchmsg' => '新闻标题/分类',
|
||||
);
|
||||
}
|
||||
|
||||
protected function flowsubmit($na, $sm)
|
||||
{
|
||||
if($this->rs['status']==1)$this->tisongtodo();
|
||||
}
|
||||
|
||||
//审核完成后发通知
|
||||
protected function flowcheckfinsh($zt)
|
||||
{
|
||||
if($zt==1)$this->tisongtodo();
|
||||
}
|
||||
|
||||
public function getreceids($receid, $whe='')
|
||||
{
|
||||
$receid = $this->adminmodel->gjoin($receid,'ud','where');
|
||||
if($receid=='' || $receid=='all'){
|
||||
$where = '';
|
||||
}else{
|
||||
$where = 'and id>0 and ('.$receid.')';
|
||||
}
|
||||
$ids = '';
|
||||
$rows = $this->adminmodel->getall('`status`=1 '.$where.' '.$whe.'','id');
|
||||
foreach($rows as $k=>$rs)$ids.=',u'.$rs['id'].'';
|
||||
if($ids!='')$ids = substr($ids, 1);
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
private function neircong($nr)
|
||||
{
|
||||
$cont = $this->htmlobj->htmlremove($nr);
|
||||
$cont = $this->htmlobj->substrstr($cont,0, 50);
|
||||
if(strlen($cont)>40)$cont.='...';
|
||||
return $cont;
|
||||
}
|
||||
|
||||
|
||||
//发送推送通知
|
||||
private function tisongtodo()
|
||||
{
|
||||
//还没到展示时间就不发送提醒
|
||||
$zstart= arrvalue($this->rs, 'startdt');
|
||||
if(!isempt($zstart) && $zstart>$this->rock->date)return;
|
||||
|
||||
|
||||
$cont = $this->neircong($this->rs['content']);
|
||||
if(isempt($cont))$cont = $this->rs['title']; //为空时
|
||||
$this->push($this->rs['receid'], '', $cont, $this->rs['title'],1);
|
||||
|
||||
//添加短信提醒,短信提醒
|
||||
if(arrvalue($this->rs,'issms')=='1'){
|
||||
$receid = $this->rs['receid'];
|
||||
if(isempt($receid))$receid = 'all';
|
||||
$qiannum= '';
|
||||
$tplnum = 'gongsms';
|
||||
$params = array(
|
||||
'title' => $this->rs['title'],
|
||||
'typename' => $this->rs['typename'],
|
||||
);
|
||||
$url = $this->getxiangurlx();
|
||||
c('xinhuapi')->sendsms($receid, $qiannum, $tplnum, $params, $url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function flowbillwhere($uid, $lx)
|
||||
{
|
||||
$key = $this->rock->post('key');
|
||||
$typeid = (int)$this->rock->post('typeid','0');
|
||||
$keywere= '';
|
||||
if(!isempt($key))$keywere.=" and (`title` like '%$key%' or `typename`='$key')";
|
||||
$whyere = '';
|
||||
//我和我未读
|
||||
if($lx=='my'){
|
||||
$whyere= "and (`startdt` is null or `startdt`<='{$this->rock->date}')";
|
||||
$whyere.= " and (`enddt` is null or `enddt`>='{$this->rock->date}')";
|
||||
}
|
||||
if($typeid>0){
|
||||
$typename=$this->option->getmou('name', $typeid);
|
||||
$whyere.=" and `typename`='$typename'";
|
||||
}
|
||||
|
||||
return array(
|
||||
'order' => '`istop` desc,`optdt` desc',
|
||||
'keywere' => $keywere,
|
||||
'where' => $whyere,
|
||||
'fields' => 'id,typename,optdt,title,optname,content,zuozhe,indate,recename,fengmian,mintou,`status`,`istop`,`appxs`'
|
||||
);
|
||||
}
|
||||
|
||||
//去掉标题
|
||||
protected function flowdatalog($arr)
|
||||
{
|
||||
|
||||
$arr['title'] = '';
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user