yingAction.php 8.3 KB

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