yingAction.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <?php
  2. /**
  3. * 移动端应用控制器页面
  4. * 主页:http://www.rockoa.com/
  5. * 软件:信呼
  6. * 作者:雨中磐石(rainrock)
  7. * 日期:2016-10-10
  8. */
  9. class yingClassAction extends ActionNot{
  10. public $openfrom = '';
  11. public function initAction()
  12. {
  13. $this->mweblogin(0, true);
  14. $openfrom = $this->get('openfrom');
  15. if(isempt($openfrom))$openfrom = $this->get('cfrom');
  16. if(!isempt($openfrom)){
  17. $this->rock->setsession('openfrom', $openfrom);
  18. }else{
  19. $openfrom = $this->rock->session('openfrom');
  20. }
  21. $this->openfrom = $openfrom;
  22. $this->assign('openfrom', $this->openfrom);
  23. }
  24. private function bd6($str)
  25. {
  26. return $this->jm->base64decode($str);
  27. }
  28. public function defaultAction()
  29. {
  30. // 检查用户权限
  31. $ybarr = $this->option->authercheck();
  32. // 如果返回的是字符串,说明存在权限问题,直接返回错误信息
  33. if(is_string($ybarr))return $ybarr;
  34. // 获取授权密钥和其他相关信息
  35. $authkey = $ybarr['authkey'];
  36. $num = $this->get('num');
  37. $mnum = $this->get('mnum'); //模块编号
  38. // 将授权密钥传递给视图
  39. $this->assign('xhauthkey', getconfig('authkey', $authkey));
  40. // 如果指定了模块编号,则显示对应模块并返回
  41. if(!isempt($mnum)){
  42. $this->showmodenum($mnum);
  43. return;
  44. }
  45. // 获取应用信息
  46. $reim = m('reim');
  47. $arr = $reim->getagent(0, "and `num`='$num'");
  48. // 如果应用不存在,输出错误信息并退出
  49. if(!$arr)exit('应用['.$num.']不存在');
  50. $rs = $arr[0];
  51. // 设置页面标题
  52. $this->title = $rs['name'];
  53. // 构建应用页面和脚本的 URL
  54. $yyurl = ''.P.'/we/ying/yingyong/'.$num.'.html';
  55. if(!file_exists($yyurl))$yyurl='';
  56. $yyurljs = ''.P.'/we/ying/yingyong/'.$num.'.js';
  57. if(!file_exists($yyurljs))$yyurljs='';
  58. // 检查是否为常用应用
  59. $rs['iscy'] = $this->iscy($num);
  60. $this->assign('arr', $rs);
  61. $this->assign('num', $num);
  62. $this->assign('yyurl', $yyurl);
  63. $this->assign('yyurljs', $yyurljs);
  64. $this->assign('searchmsg', '输入关键词搜索');
  65. $this->assign('typename', '');
  66. // 设置当前用户在应用上的权限
  67. $gid = $rs['id'];
  68. $reim->setallyd('agent', $this->adminid, $gid);
  69. // 包含应用类文件并初始化
  70. $clasne = 'ying_'.$num.'Class';
  71. $classpath = ''.P.'/we/ying/yingyong/'.$clasne.'.php';
  72. if(file_exists($classpath)){
  73. include_once($classpath);
  74. $yingobj = new $clasne();
  75. $yingobj->initYing($this);
  76. }
  77. // 记录打开应用的日志
  78. if(getconfig('useropt')=='1')m('log')->addlog('打开应用', '应用['.$num.'.'.$this->title.']');
  79. }
  80. //默认根据模块显示
  81. private function showmodenum($mnum)
  82. {
  83. $typename = '';
  84. // 初始化流程对象
  85. $flow = m('flow')->initflow($mnum);
  86. // 获取模块信息
  87. $mrs = $flow->moders;
  88. // 检查模块状态,如果已停用则退出
  89. if($mrs['status']=='0')exit('模块['.$mnum.','.$mrs['name'].']已停用');
  90. // 获取流程的搜索数据
  91. $souarr = $flow->flowwesearchdata(0);
  92. $searchmsg = arrvalue($souarr, 'searchmsg','输入关键词搜索');
  93. $typename = arrvalue($souarr, 'typename');
  94. // 设置页面标题
  95. $this->title = $mrs['name'];
  96. // 获取参数值
  97. $pnum = $this->get('pnum');
  98. // 初始化菜单数组
  99. $menu = array();
  100. // 获取模块条件
  101. $atypearr = m('where')->getmywhere($mrs['id'], $this->adminid, $pnum);
  102. // 如果条件不存在,退出并提示用户创建条件
  103. if(!$atypearr)exit('请到【流程模块→流程模块条件】建条件,分组编号要为空');
  104. // 根据模块属性判断是否添加抄送和经我处理的菜单项
  105. if(isempt($pnum)){
  106. if($mrs['iscs']>0)$atypearr[] = array('id' => 0,'num' => 'chaos','name' => '抄送给我');
  107. if($mrs['isflow']>0)$atypearr[] = array('id' => 0,'num' => 'mychuli','name' => '经我处理');
  108. }
  109. // 判断是否允许新增记录,并添加相应的菜单项
  110. $isadd = m('view')->isadd($mrs['id'], $this->adminid);
  111. if($isadd)$atypearr[] = array('id' => 0,'num' => 'add','type' => 1,'name' => '+新增');
  112. // 构建主菜单
  113. foreach($atypearr as $k1=>$rs1){
  114. $uar = array('type' => 0,'name' => $rs1['name'],'url' => $rs1['num'].'|'.$mnum.'','num' => '','submenu'=> array());
  115. if(arrvalue($rs1,'type')==1){$uar['type']=1;$uar['url']='add_'.$mnum.'';}
  116. $menu[] = $uar;
  117. if($k1>1)break;
  118. }
  119. // 如果菜单项数量大于3,则添加"更多"子菜单
  120. if(count($atypearr)>3){
  121. $submenu = array();
  122. foreach($atypearr as $k1=>$rs1){
  123. $uar = array('type' => 0,'name' => $rs1['name'],'url' => $rs1['num'].'|'.$mnum.'','num' => '','submenu'=> array());
  124. if(arrvalue($rs1,'type')==1){$uar['type']=1;$uar['url']='add_'.$mnum.'';}
  125. if($k1>1)$submenu[] = $uar;
  126. }
  127. $menu[2] = array(
  128. 'name' => '更多&gt;&gt;',
  129. 'num' => '',
  130. 'submenu' => $submenu,
  131. );
  132. }
  133. // 如果菜单为空,则添加默认菜单项
  134. if(!$menu)$menu[] = array(
  135. 'name' => $mrs['name'],
  136. 'url' => 'my|'.$mnum.'',
  137. 'num' => '',
  138. 'submenu' => array(),
  139. );
  140. // 构建返回数组
  141. $arr = array(
  142. 'face' => '',
  143. 'leixing'=>$mnum,
  144. 'menu' => $menu,
  145. 'num' => 'base',
  146. 'name' => $mrs['name'],
  147. );
  148. // 初始化其他变量
  149. $yyurl = '';
  150. $yyurljs = '';
  151. // 分配变量到视图
  152. $this->assign('searchmsg', $searchmsg);
  153. $this->assign('yyurl', $yyurl);
  154. $this->assign('arr', $arr);
  155. $this->assign('yyurljs', $yyurljs);
  156. $this->assign('typename', $typename);
  157. // 如果用户操作日志开启,记录打开模块应用的日志
  158. if(getconfig('useropt')=='1')m('log')->addlog('打开模块应用', '模块['.$mnum.'.'.$this->title.']');
  159. }
  160. private function iscy($num)
  161. {
  162. // 获取当前用户的应用展示 ID
  163. $myyyid= $this->option->getval('yinghomeshow_'.$this->adminid.'');
  164. // 默认设置为非常用应用
  165. $iscy = 0;
  166. // 如果当前用户的应用展示 ID 不为空,并且包含指定的应用编号,则将其标记为常用应用
  167. if(!isempt($myyyid) && contain(','.$myyyid.',',','.$num.','))$iscy=1;
  168. return $iscy;
  169. }
  170. public function locationAction()
  171. {
  172. $this->title = '考勤定位';
  173. $kq = m('kaoqin');
  174. $arr = m('waichu')->getoutrows($this->date,$this->adminid);
  175. $this->assign('rows', $arr);
  176. $dt = $this->rock->date;
  177. $dwarr = m('location')->getrows("uid='$this->adminid' and `optdt` like '$dt%'",'*','`id` desc');
  178. $this->assign('dwarr', $dwarr);
  179. $kqrs = $kq->dwdkrs($this->adminid, $this->date);
  180. $isgzh = m('wxgzh:index')->isusegzh();
  181. $this->assign('isgzh', $isgzh);
  182. $this->assign('kqrs', $kqrs);
  183. $dwids = arrvalue($kqrs, 'dwids');
  184. $kqors = array();
  185. if(!isempt($dwids)){
  186. $kqors = m('kqdw')->getrows("id in($dwids) and `id`<>".$kqrs['id']."");
  187. }
  188. $this->assign('kqors', $kqors);
  189. $this->smartydata['qqmapkey'] = getconfig('qqmapkey','55QBZ-JGYLO-BALWX-SZE4H-5SV5K-JCFV7');
  190. }
  191. /**
  192. * 最新打卡使用
  193. */
  194. public function dakaAction()
  195. {
  196. $this->title = '考勤打卡';
  197. $kq = m('kaoqin');
  198. $dt = $this->rock->date;
  199. $dwarr = m('location')->getrows("uid='$this->adminid' and `optdt` like '$dt%'",'*','`id` desc');
  200. $this->assign('dwarr', $dwarr);
  201. $kqrs = $kq->dwdkrs($this->adminid, $this->date);
  202. $isgzh = m('wxgzh:index')->isusegzh();
  203. $this->assign('isgzh', $isgzh);
  204. $this->assign('iscy', $this->iscy('kqdaka'));
  205. $this->assign('kqrs', $kqrs);
  206. $dwids = arrvalue($kqrs, 'dwids');
  207. $kqors = array();
  208. if(!isempt($dwids)){
  209. $kqors = m('kqdw')->getrows("id in($dwids) and `id`<>".$kqrs['id']."");
  210. }
  211. $this->assign('kqors', $kqors);
  212. $this->smartydata['qqmapkey'] = getconfig('qqmapkey','55QBZ-JGYLO-BALWX-SZE4H-5SV5K-JCFV7');
  213. }
  214. }