yingAction.php 8.0 KB

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