WebController.class.php.back 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372
  1. <?php
  2. namespace Addons\LuojiangKaoping\Controller;
  3. use Mp\Controller\AddonsController;
  4. /**
  5. * 洛江考评微官网后台管理控制器
  6. * @author 大鱼
  7. */
  8. class WebController extends AddonsController {
  9. public function test()
  10. {
  11. //luojiang_achievement
  12. $all_list = M('luojiang_article')->select();
  13. Vendor('HyperDown.Parser');
  14. $parser = new \Parser();
  15. foreach( $all_list as $val )
  16. {
  17. $content = $parser->makeHtml($val['content']);
  18. M('luojiang_article')->where( array('id' => $val['id']) )->save( array('content' => $content) );
  19. //id
  20. }
  21. var_dump('success');
  22. die();
  23. //LuojiangKaoping
  24. }
  25. public function eventreport()
  26. {
  27. /**
  28. Vendor('HyperDown.Parser');
  29. $parser = new \Parser();
  30. $markdown = $parser->makeHtml("![](http://wx.mnw.cn/Uploads/Pictures/20180411/5acd6d78033a2.jpg)");
  31. Vendor('Michelf.Markdown');
  32. $html = \Michelf\Markdown::defaultTransform("![](http://wx.mnw.cn/Uploads/Pictures/20180411/5acd6d78033a2.jpg)");
  33. var_dump($markdown,$html);
  34. die();
  35. **/
  36. $custom = array(
  37. 'options' => array(
  38. 'lool_to_material' => array(
  39. 'title' => '处理上报事件',
  40. 'url' => U('addon/LuojiangKaoping/web/editeventreport', array('id'=>'{id}')),
  41. 'class' => 'btn btn-primary btn-sm icon-edit'
  42. ),
  43. 'edit_fans' => array(
  44. 'title' => '查看用户信息',
  45. 'url' => U('Mp/Fans/edit_fans_byid', array('fansid'=>'{fans_id}')),
  46. 'class' => 'btn btn-primary btn-sm icon-edit'
  47. )
  48. )
  49. );
  50. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  51. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  52. ->addCrumb('事件上报', '', 'active')
  53. ->setModel('luojiang_eventreport')
  54. ->setListOrder('addtime desc')
  55. ->setListMap(array('mpid'=>get_mpid()))
  56. ->setTip('<p id="msg_flush">暂无新消息</p>')
  57. ->setListSearch(array('nickname' => '会员名称'))
  58. ->addListItem('fans_id', '会员名称', 'callback', array('callback_name'=>'get_fans_name'))
  59. ->addListItem('event_type', '事件类型', 'enum', array('options'=>array('井盖缺失'=>'井盖缺失','道路破损'=>'道路破损','道路淘空'=>'道路淘空','陈年垃圾'=>'陈年垃圾','卫生死角'=>'卫生死角','公共设施'=>'公共设施','市容环境'=>'市容环境','其他情况'=>'其他情况')))
  60. ->addListItem('descript', '事件描述')
  61. ->addListItem('image_list', '图片列表', 'callback', array('callback_name'=>'get_images_str'))
  62. ->addListItem('video_file', '视频', 'callback', array('callback_name'=>'get_video_str'))
  63. ->addListItem('jiangli', '奖励')
  64. ->addListItem('id', '位置', 'callback', array('callback_name'=>'get_message_content'))
  65. ->addListItem('addtime', '创建时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
  66. ->addListItem('reply_info', '处理结果', '', array('placeholder'=>'<font color="red">未处理</font>'))
  67. ->addListItem('id', '操作', 'custom', $custom)
  68. ->addButton('导出', U('addon/LuojiangKaoping/web/loadexcel'), 'btn btn-primary')
  69. ->common_lists();
  70. echo '<script src="/Public/Mp/js/checkflush.js"></script>';
  71. echo "<style>.table-striped > tbody > tr:nth-child(odd) > td, .table-striped > tbody > tr:nth-child(odd) > th{border-top:1px solid #000; ;border-bottom:1px solid #000;}</style>";
  72. }
  73. public function get_message_content($id) {
  74. $map['id'] = $id;
  75. $map['mpid'] = get_mpid();
  76. $message = M('luojiang_eventreport')->where($map)->find();
  77. if(!empty($message['location_addr'])){
  78. return $message['location_addr'].'<br/><button type="button" class="btn btn-sm btn-success" onclick="lookMap('.$message['lat'].','.$message['lng'].')">查看【位置】</button>';
  79. }else{
  80. return "未提供";
  81. }
  82. }
  83. public function downfile()
  84. {
  85. //.jpg mp4
  86. //$mp_message_info['msgtype'] == 'video'
  87. $file_url = urldecode( I('get.file_url') );
  88. $type = urldecode( I('get.type') );
  89. $file_url = str_replace('/Uploads/','Uploads/',$file_url);
  90. $file_name = $file_url.'.'.$type;
  91. $file_sub_path= "/data/web/wx.mnw.cn/";
  92. $file_path=$file_sub_path.$file_name;
  93. $filectime = filectime($file_path);
  94. if( strpos($file_name,'jpg') !== false )
  95. {
  96. $img_arrs = explode('.', $file_name);
  97. $file_name = '微信图片_'.date('Ymd',$filectime).'_'.$filectime.'.'.$img_arrs[1];
  98. }
  99. else if( strpos($file_name,'png') !== false ){
  100. $img_arrs = explode('.', $file_name);
  101. $file_name = '微信图片_'.date('Ymd',$filectime).'_'.$filectime.'.'.$img_arrs[1];
  102. }
  103. else if( strpos($file_name,'gif') !== false ){
  104. $img_arrs = explode('.', $file_name);
  105. $file_name = '微信图片_'.date('Ymd',$filectime).'_'.$filectime.'.'.$img_arrs[1];
  106. }
  107. else if( strpos($file_name,'jpeg') !== false ){
  108. $img_arrs = explode('.', $file_name);
  109. $file_name = '微信图片_'.date('Ymd',$filectime).'_'.$filectime.'.'.$img_arrs[1];
  110. }
  111. else if( strpos($file_name,'mp4') !== false ){
  112. $img_arrs = explode('.', $file_name);
  113. $file_name = '微信视频_'.date('Ymd',$filectime).'_'.$filectime.'.'.$img_arrs[1];
  114. }
  115. else if($mp_message_info['msgtype'] == 'voice' ){
  116. $img_arrs = explode('.', $file_name);
  117. $file_name = '微信语音_'.date('Ymd',$filectime).'_'.$filectime.'.'.$img_arrs[1];
  118. }
  119. $fp=fopen($file_path,"r");
  120. $file_size=filesize($file_path);
  121. //var_dump($file_size);die();
  122. //下载文件需要用到的头
  123. Header("Content-type: application/octet-stream");
  124. Header("Accept-Ranges: bytes");
  125. Header("Accept-Length:".$file_size);
  126. Header("Content-Disposition: attachment; filename=".$file_name);
  127. $buffer=1024;
  128. $file_count=0;
  129. //向浏览器返回数据
  130. while(!feof($fp) && $file_count<$file_size){
  131. $file_con=fread($fp,$buffer);
  132. $file_count+=$buffer;
  133. echo $file_con;
  134. }
  135. fclose($fp);
  136. echo $file_url;
  137. die();
  138. }
  139. /**
  140. * 获取视频
  141. * @author lyf
  142. */
  143. public function get_video_str($video_file)
  144. {
  145. if(empty($video_file))
  146. {
  147. return '暂无';
  148. }else{
  149. return '<button type="button" class="btn btn-sm btn-warning icon-video" data-src="'.$video_file.'" onclick="lookVideo(this)">查看视频</button><a href="'.U('addon/HuianKaoping/web/downfile', array('type' =>'mp4', 'file_url' => urlencode($video_file) )).'" title="点击下载视频" target=_blank">【下载】</a>';
  150. }
  151. }
  152. /*
  153. * 导出
  154. */
  155. public function loadexcel()
  156. {
  157. header("content-type:text/html; charset=uft-8");
  158. if(IS_POST)
  159. {
  160. //date_added_begin:2017-08-02 0:00:00
  161. //date_added_end:2017-08-19 0:00:00
  162. $data = I('post.');
  163. $where = array();
  164. if(!empty($data['date_added_begin']))
  165. {
  166. $where['addtime'] = array('gt',strtotime($data['date_added_begin']) );
  167. }
  168. if(!empty($data['date_added_end']))
  169. {
  170. $where['addtime'] = array('lt',strtotime($data['date_added_end']) );
  171. }
  172. $s_time = strtotime($data['date_added_begin']);
  173. $e_time = strtotime($data['date_added_end']);
  174. if($s_time && $e_time)
  175. {
  176. $where['addtime'] = array('between',array($s_time,$e_time));
  177. }
  178. $list = M('luojiang_eventreport')->where($where)->order('id desc')->select();
  179. //$need_data = array( array('order_sn'=>1,'get_image'=>'http://wx.mnw.cn/Uploads/Pictures/2/2017-08-07/2_oA7ocv8o0sk-tPmG87fjPD25nQWs_1502095440.jpg'),array('order_sn'=>1,'get_image'=>'http://wx.mnw.cn/Uploads/Pictures/2/2017-08-07/2_oA7ocv8o0sk-tPmG87fjPD25nQWs_1502095440.jpg') );
  180. $need_data = array();
  181. $xlsCell = array(
  182. array('id','序号'),
  183. array('addtime','日期'),
  184. array('fans_id','微信名'),
  185. array('mobile','联系人电话'),
  186. array('jifen','积分'),
  187. array('descript','事件描述'),
  188. array('image_list','图否'),
  189. array('jiangli','奖励'),
  190. array('is_reply','反馈情况'),
  191. array('reply_info','反馈内容'),
  192. array('video_file','视频')
  193. /*
  194. array('contact_tel','联系电话'),
  195. array('jifen','积分'),
  196. array('nickname','微信名'),
  197. array('content','问题描述'),
  198. array('get_img','图否'),
  199. array('fankui','反馈情况'),
  200. array('fankui_tu','反馈图片'),
  201. */
  202. );
  203. $i = 1;
  204. foreach($list as $val)
  205. {
  206. $tmp_data = array();
  207. $tmp_data['id'] = $i;
  208. $tmp_data['addtime'] = date('Y-m-d H:i:s', $val['addtime']);
  209. //openid
  210. $mp_fans = M('mp_fans')->field('nickname')->where( array('id' => $val['fans_id']) )->find();
  211. $tmp_data['fans_id'] = $mp_fans['nickname'];
  212. $tmp_data['mobile'] = $mp_fans['mobile'];
  213. if( empty($val['reply_info']) ){
  214. $tmp_data['jifen'] = 0;
  215. }else{
  216. $tmp_data['jifen'] = 2;
  217. }
  218. $tmp_data['jiangli'] = $val['jiangli'];
  219. //$tmp_data['title'] = $val['title'];
  220. $tmp_data['descript'] = $val['descript'];
  221. if( empty($val['reply_info']) ){
  222. $tmp_data['is_reply'] = '否';
  223. }else{
  224. $tmp_data['is_reply'] = '是';
  225. }
  226. $tmp_data['reply_info'] = $val['reply_info'];
  227. if(empty($val['video_file']))
  228. {
  229. $tmp_data['video_file'] ='否';
  230. }else{
  231. $tmp_data['video_file'] ='是';
  232. //$tmp_data['video_file'] ='http://'.$_SERVER['SERVER_NAME'].str_replace('./','',$val['video_file']);
  233. }
  234. //http://wx.mnw.cn/Uploads/Pictures/2/2017-08-07/2_oA7ocv8o0sk-tPmG87fjPD25nQWs_1502095440.jpg
  235. if(!empty($val['image_list']))
  236. {
  237. $img_arr = explode(',',$val['image_list']);
  238. if($val['image_list'] == ',undefined/undefined' || $val['image_list'] == 'undefined/undefined')
  239. {
  240. $img_url = '';
  241. $img_urls = array();
  242. }else{
  243. $img_urls = explode(',', $val['image_list']);
  244. foreach($img_urls as $kk => $vv)
  245. {
  246. $vv = str_replace('./','/',$vv );
  247. $vv = '/data/web/wx.mnw.cn'.$vv;
  248. $img_urls[$kk] = $vv;
  249. }
  250. //$img_url = str_replace('./','http://'.$_SERVER['SERVER_NAME'],$val['image_list']);
  251. }
  252. $tmp_data['image_list'] = $img_urls;
  253. }
  254. $i++;
  255. $need_data[] = $tmp_data;
  256. }
  257. $expTitle = date('Y-m-d H:i:s');
  258. export_excel($expTitle,$xlsCell,$need_data);
  259. }
  260. $this->display();
  261. }
  262. public function editeventreport()
  263. {
  264. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  265. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  266. ->addCrumb('处理上报事件', '', 'active')
  267. ->setModel('luojiang_eventreport')
  268. ->addFormField('jiangli', '上报奖励', 'text')
  269. ->addFormField('reply_info', '处理意见', 'text')
  270. ->setFormData( M('luojiang_eventreport')->find(I('get.id')) )
  271. ->setEditMap( array('id'=>I('get.id')) )
  272. ->setEditSuccessUrl( U('addon/LuojiangKaoping/web/eventreport') )
  273. ->common_edit();
  274. }
  275. public function opinionsuggestion()
  276. {
  277. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  278. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  279. ->addCrumb('意见建议', '', 'active')
  280. ->setModel('luojiang_opinionsuggestion')
  281. ->setListOrder('addtime desc')
  282. ->setListMap(array('mpid'=>get_mpid()))
  283. ->addListItem('fans_id', '会员名称', 'callback', array('callback_name'=>'get_fans_name'))
  284. ->addListItem('opinion_name', '建议人姓名')
  285. ->addListItem('contact', '建议人联系电话')
  286. ->addListItem('email', '邮箱')
  287. ->addListItem('title', '建议标题')
  288. ->addListItem('content', '建议内容')
  289. ->addListItem('image_list', '图片列表', 'callback', array('callback_name'=>'get_images_str'))
  290. ->addListItem('reply_method', '回复方式', 'enum', array('options'=>array('1'=>'网上',2=>'电话',3=>'当面')))
  291. //->addListItem('is_reply', '是否回复', 'enum', array('options'=>array(0=>'未回复',1=>'已回复')))
  292. ->addListItem('addtime', '创建时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
  293. ->addListItem('id', '操作', 'custom', array('options'=>array('edit_eventreport'=>array('处理意见建议', U('addon/LuojiangKaoping/web/editopinionsuggestion', array('id'=>'{id}')),'btn btn-primary btn-sm icon-edit',''))))
  294. //->addListItem('id', '操作', 'custom', array('options'=>array('edit_fans'=>array('编辑粉丝资料', U('Mp/Fans/edit_fans', array('openid'=>'{openid}')),'btn btn-primary btn-sm icon-edit',''))))
  295. ->common_lists();
  296. }
  297. public function editopinionsuggestion()
  298. {
  299. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  300. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  301. ->addCrumb('处理意见建议', '', 'active')
  302. ->setModel('luojiang_opinionsuggestion')
  303. ->addFormField('reply_info', '处理意见', 'text')
  304. ->setFormData( M('luojiang_opinionsuggestion')->find(I('get.id')) )
  305. ->setEditMap( array('id'=>I('get.id')) )
  306. ->setEditSuccessUrl( U('addon/LuojiangKaoping/web/opinionsuggestion') )
  307. ->common_edit();
  308. }
  309. public function newsnenter_two()
  310. {
  311. $options = array(
  312. 'edit_fans'=>array('编辑', U('addon/LuojiangKaoping/web/editarticle', array('id'=>'{id}') )
  313. ,'btn btn-primary btn-sm icon-edit',''),
  314. 'delete' => array(
  315. 'title' => '删除',
  316. 'url' => U('addon/LuojiangKaoping/web/deletearticle', array('id'=>'{id}')),
  317. 'class' => 'btn btn-danger btn-sm icon-delete'
  318. )
  319. );
  320. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  321. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  322. ->addCrumb('新闻中心', '', 'active')
  323. ->setModel('luojiang_article')
  324. ->setListMap(array('type'=>2))
  325. ->setListOrder('addtime desc')
  326. ->addListItem('title', '标题')
  327. // ->addListItem('logo', '图片', 'image', array('attr'=>'width=50 height=50','placeholder'=>__ROOT__ . '/Public/Admin/img/noname.jpg'))
  328. ->addListItem('cate_id', '所属分类', 'callback',array('callback_name'=>'get_cate_name'))
  329. ->addListItem('sendtime', '发布时间')
  330. ->addListItem('addtime', '创建时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
  331. ->addListItem('id', '操作', 'custom', array('options'=>$options))
  332. //->addButton('新增文章分类', U('addon/HuianKaoping/web/addarticlecate'), 'btn btn-primary')
  333. ->addButton('新增文章', U('addon/LuojiangKaoping/web/addarticle_two'), 'btn btn-primary')
  334. ->common_lists();
  335. }
  336. public function newsnenter()
  337. {
  338. $options = array(
  339. 'edit_fans'=>array('编辑', U('addon/LuojiangKaoping/web/editarticle', array('id'=>'{id}') )
  340. ,'btn btn-primary btn-sm icon-edit',''),
  341. 'delete' => array(
  342. 'title' => '删除',
  343. 'url' => U('addon/LuojiangKaoping/web/deletearticle', array('id'=>'{id}')),
  344. 'class' => 'btn btn-danger btn-sm icon-delete'
  345. )
  346. );
  347. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  348. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  349. ->addCrumb('新闻中心', '', 'active')
  350. ->setModel('luojiang_article')
  351. ->setListMap(array('type'=>1))
  352. ->setListOrder('addtime desc')
  353. ->addListItem('title', '标题')
  354. ->addListItem('logo', '图片', 'image', array('attr'=>'width=50 height=50','placeholder'=>__ROOT__ . '/Public/Admin/img/noname.jpg'))
  355. ->addListItem('cate_id', '所属分类', 'callback',array('callback_name'=>'get_cate_name'))
  356. ->addListItem('sendtime', '发布时间')
  357. ->addListItem('addtime', '创建时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
  358. ->addListItem('id', '操作', 'custom', array('options'=>$options))
  359. //->addButton('新增文章分类', U('addon/HuianKaoping/web/addarticlecate'), 'btn btn-primary')
  360. ->addButton('新增文章', U('addon/LuojiangKaoping/web/addarticle'), 'btn btn-primary')
  361. ->common_lists();
  362. }
  363. /**
  364. * 删除关键词回复
  365. * @author 艾逗笔<765532665@qq.com>
  366. */
  367. public function deletearticle() {
  368. M('luojiang_article')->where( array('id' =>I('get.id') ) )->delete();
  369. $this->success('删除成功');
  370. }
  371. public function votecenter()
  372. {
  373. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  374. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  375. ->addCrumb('投票专区', '', 'active')
  376. ->setModel('vote')
  377. ->addListItem('title', '标题')
  378. ->addListItem('begin_time', '开始时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
  379. ->addListItem('end_time', '结束时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
  380. ->addListItem('addtime', '添加时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
  381. ->addListItem('vote_id', '操作', 'custom', array('options'=>array(
  382. 'edit_fans'=>array('编辑', U('addon/LuojiangKaoping/web/editvote', array('vote_id'=>'{vote_id}') ) ,'btn btn-primary btn-sm icon-edit',''),
  383. 'add_votesubject'=>array('添加投票选项', U('addon/LuojiangKaoping/web/addvotesubject', array('vote_id'=>'{vote_id}') ) ,'btn btn-primary btn-sm icon-edit',''),
  384. )))
  385. ->addButton('新增投票', U('addon/LuojiangKaoping/web/addvote'), 'btn btn-primary')
  386. ->common_lists();
  387. }
  388. public function addvote()
  389. {
  390. if( IS_POST )
  391. {
  392. $data = I('post.');
  393. $vote_data = array();
  394. $vote_data['mpid'] = get_mpid();
  395. $vote_data['title'] = $data['name'];
  396. $vote_data['begin_time'] = strtotime( $data['date_added_begin'] );
  397. $vote_data['end_time'] = strtotime( $data['date_added_end'] );
  398. $vote_data['addtime'] = time();
  399. M('vote')->add($vote_data);
  400. $this->success('添加投票成功', U('addon/LuojiangKaoping/web/votecenter'));
  401. die();
  402. }
  403. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  404. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  405. ->addCrumb('新闻中心', '', 'active')
  406. ->display();
  407. }
  408. public function addvotesubject()
  409. {
  410. $vote_id = I('get.vote_id');
  411. $this->vote_id = $vote_id;
  412. if( IS_POST )
  413. {
  414. $data = I('post.');
  415. if( isset($data['edit_votesubject']) )
  416. {
  417. $has_key = array();
  418. $del_key = array();
  419. foreach( $data['attr_title'] as $key => $val)
  420. {
  421. $has_key[] = $key;
  422. }
  423. $vote_sub_all = M('vote_subject')->where( array('vote_id' => $data['vote_id']) )->select();
  424. foreach($vote_sub_all as $vote_sub)
  425. {
  426. if( !in_array($vote_sub['sub_id'],$has_key ) )
  427. {
  428. $del_key[] = $vote_sub['sub_id'];
  429. }
  430. }
  431. //删除多余键
  432. if( !empty($del_key) )
  433. {
  434. M('vote_subject')->where( array('sub_id' => array('in', $del_key ) ) )->delete();
  435. //删除投票记录
  436. M('vote_record')->where( array('sub_id' => array('in', $del_key ) ) )->delete();
  437. }
  438. //开始更新和新增选项
  439. foreach($data['attr_title'] as $key => $val)
  440. {
  441. if( strpos($key, 'new') !== false )
  442. {
  443. //新增的模块
  444. $tmp_vote_subject = array();
  445. $tmp_vote_subject['vote_id'] = $data['vote_id'];
  446. $tmp_vote_subject['title'] = $val;
  447. $tmp_vote_subject['type'] = $data['type'][$key];
  448. $tmp_vote_subject['addtime'] = time();
  449. M('vote_subject')->add($tmp_vote_subject);
  450. $sub_id = M('vote_subject')->getLastInsID();
  451. $extra = $data['extra'][$key];
  452. $extra_arr = explode('|', $extra);
  453. foreach($extra_arr as $vv)
  454. {
  455. $xun_data = array();
  456. $xun_data['sub_id'] = $sub_id;
  457. $xun_data['titile'] = $vv;
  458. $xun_data['addtime'] = time();
  459. M('vote_xuan')->add($xun_data);
  460. }
  461. } else {
  462. //需要更新板块
  463. $tmp_vote_subject = array();
  464. $tmp_vote_subject['title'] = $val;
  465. $tmp_vote_subject['type'] = $data['type'][$key];
  466. M('vote_subject')->where( array('sub_id' =>$key ) ) ->save($tmp_vote_subject);
  467. //更新子内容
  468. //先判断原来有几个
  469. $vote_xuan_list = M('vote_xuan')->where( array('sub_id' => $key) )->order('xu_id asc')->select();
  470. $extra = array();
  471. $extra = $data['extra'][$key];
  472. $extra_arr = explode('|', $extra);
  473. foreach($vote_xuan_list as $xun_vo)
  474. {
  475. if( !empty($extra_arr) )
  476. {
  477. $tmp_xun = array_shift( $extra_arr );
  478. M('vote_xuan')->where( array('xu_id' => $xun_vo['xu_id']) )->save( array('titile' => $tmp_xun) );
  479. }else {
  480. //需要删除的
  481. M('vote_xuan')->where( array('xu_id' => $xun_vo['xu_id']) )->delete();
  482. }
  483. }
  484. //判断是否可以新增
  485. if( !empty($extra_arr) )
  486. {
  487. foreach($extra_arr as $vv)
  488. {
  489. $xun_data = array();
  490. $xun_data['sub_id'] = $key;
  491. $xun_data['titile'] = $vv;
  492. $xun_data['addtime'] = time();
  493. M('vote_xuan')->add($xun_data);
  494. }
  495. }
  496. }
  497. }
  498. $this->success('编辑投票选项成功', U('addon/HuianKaoping/web/votecenter'));
  499. die();
  500. }
  501. foreach($data['attr_title'] as $key => $val)
  502. {
  503. if( !empty($val) )
  504. {
  505. $tmp_vote_subject = array();
  506. $tmp_vote_subject['vote_id'] = $data['vote_id'];
  507. $tmp_vote_subject['title'] = $val;
  508. $tmp_vote_subject['type'] = $data['type'][$key];
  509. $tmp_vote_subject['addtime'] = time();
  510. M('vote_subject')->add($tmp_vote_subject);
  511. $sub_id = M('vote_subject')->getLastInsID();
  512. $extra = $data['extra'][$key];
  513. //vote_xuan
  514. $extra_arr = explode('|', $extra);
  515. foreach($extra_arr as $vv)
  516. {
  517. $xun_data = array();
  518. $xun_data['sub_id'] = $sub_id;
  519. $xun_data['titile'] = $vv;
  520. $xun_data['addtime'] = time();
  521. M('vote_xuan')->add($xun_data);
  522. }
  523. }
  524. }
  525. $this->success('新增投票选项成功', U('addon/HuianKaoping/web/votecenter'));
  526. die();
  527. }
  528. $vote_subject = M('vote_subject')->where( array('vote_id' => $vote_id) )->order('sub_id asc')->select();
  529. if( !empty($vote_subject) )
  530. {
  531. foreach( $vote_subject as $key=> $val )
  532. {
  533. $vote_xuan_list = M('vote_xuan')->where( array('sub_id' => $val['sub_id']) )->order('xu_id asc')->select();
  534. $xun_arr = array();
  535. foreach( $vote_xuan_list as $vv )
  536. {
  537. $xun_arr[] = $vv['titile'];
  538. }
  539. $val['xun_title'] = implode('|', $xun_arr);
  540. $val['vote_xuan_list'] = $vote_xuan_list;
  541. $vote_subject[$key] = $val;
  542. }
  543. $this->vote_subject = $vote_subject;
  544. $this->addCrumb('洛江考评微官网', U('addon/HuianKaoping/index'), '')
  545. ->addCrumb('业务导航', U('addon/HuianKaoping/web/eventreport'), '')
  546. ->addCrumb('新闻中心', '', 'active')
  547. ->display('editvotesubject');
  548. } else {
  549. $this->addCrumb('洛江考评微官网', U('addon/HuianKaoping/index'), '')
  550. ->addCrumb('业务导航', U('addon/HuianKaoping/web/eventreport'), '')
  551. ->addCrumb('新闻中心', '', 'active')
  552. ->display();
  553. }
  554. }
  555. public function loadachievement()
  556. {
  557. $type = I('type');
  558. if( IS_POST )
  559. {
  560. set_time_limit(0);
  561. if(isset($_FILES["file"]) && ($_FILES["file"]["error"] == 0)){
  562. $excel_dir = './Uploads/Pictures/' . date('Y-m-d') . '/';
  563. if (!file_exists($excel_dir)) {
  564. $dirs = explode('/', $excel_dir);
  565. $dir = $dirs[0] . '/';
  566. for ($i=1, $j=count($dirs)-1; $i<$j; $i++) {
  567. $dir .= $dirs[$i] . '/';
  568. if (!is_dir($dir)) {
  569. mkdir($dir, 0777);
  570. }
  571. }
  572. }
  573. $extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
  574. $path = $excel_dir.'/'.md5($_FILES['file']['name'].mt_rand(1, 999)).'.'.$extension;
  575. $rs = move_uploaded_file($_FILES["file"]["tmp_name"],$path);
  576. $file = $path;
  577. $type = pathinfo($file);
  578. $type = strtolower($type["extension"]);
  579. $type=$type==='csv' ? $type : 'Excel5';
  580. ini_set('max_execution_time', '0');
  581. vendor("PHPExcel.PHPExcel");
  582. // 判断使用哪种格式
  583. $objReader = \PHPExcel_IOFactory::createReader($type);
  584. $objPHPExcel = $objReader->load($file);
  585. $sheet = $objPHPExcel->getSheet(0);
  586. // 取得总行数
  587. $highestRow = $sheet->getHighestRow();
  588. // 取得总列数
  589. $highestColumn = $sheet->getHighestColumn();
  590. //循环读取excel文件,读取一条,插入一条
  591. $data=array();
  592. //从第一行开始读取数据
  593. for($j=1;$j<=$highestRow;$j++){
  594. if($j <=2) {
  595. continue;
  596. }
  597. //从A列读取数据
  598. for($k='A';$k<=$highestColumn;$k++){
  599. // 读取单元格
  600. $data[$j][]=$objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue();
  601. }
  602. }
  603. $result = $data;
  604. $get_data = array();
  605. if(!empty($result)) {
  606. foreach($result as $key => $val){
  607. //array(5) { [0]=> string(6) "村庄" [1]=> string(18) "2017-8月上半月"
  608. //[2]=> string(9) "小岞镇" [3]=> string(9) "新桥村" [4]=> float(92.5) }
  609. if(empty($val[0]))
  610. {
  611. continue;
  612. }
  613. //$val[1] = str_replace('上半月','01',$val[1]);
  614. //$val[1] = str_replace('下半月','15',$val[1]);
  615. //$val[1] = $val[1]->__toString();
  616. $val[1] .= ' 00:00:00';
  617. //$val[1] = str_replace('年','-',$val[1]);
  618. //$val[1] = str_replace('月','',$val[1]);
  619. $need_data = array();
  620. $need_data['name'] = $val[0];
  621. $need_data['kao_time'] = strtotime($val[1]);
  622. $need_data['zeren_danwei'] = $val[2];
  623. $need_data['stree'] = $val[3];
  624. $need_data['kaoping_dian'] = '';
  625. $need_data['chengji'] = $val[4];
  626. if(I('type') == 2)
  627. {
  628. $need_data['type'] = 2;
  629. }else{
  630. $need_data['type'] = 1;
  631. }
  632. if(empty($need_data['stree']))
  633. {
  634. $need_data['stree'] = '';
  635. }
  636. $need_data['paiming'] = 0;
  637. $need_data['addtime'] = time();
  638. M('luojiang_achievement')->add($need_data);
  639. }
  640. if(I('type') == 2){
  641. $this->success('导入成绩成功', U('addon/LuojiangKaoping/web/achievementmanage_two'));
  642. }else{
  643. $this->success('导入成绩成功', U('addon/LuojiangKaoping/web/achievementmanage'));
  644. }
  645. die();
  646. }
  647. }
  648. }
  649. $this->assign('type', $type);
  650. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  651. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  652. ->addCrumb('成绩管理', '', 'active')
  653. ->display();
  654. }
  655. public function editvote()
  656. {
  657. // /vote_id/1
  658. $vote_id = I('get.vote_id');
  659. if( IS_POST )
  660. {
  661. $data = I('post.');
  662. $data = I('post.');
  663. $vote_data = array();
  664. $vote_data['mpid'] = get_mpid();
  665. $vote_data['title'] = $data['name'];
  666. $vote_data['begin_time'] = strtotime( $data['date_added_begin'] );
  667. $vote_data['end_time'] = strtotime( $data['date_added_end'] );
  668. M('vote')->where( array('vote_id' => $data['vote_id']) )->save($vote_data);
  669. $this->success('编辑投票成功', U('addon/HuianKaoping/web/votecenter'));
  670. die();
  671. }
  672. $vote = M('vote')->where( array('vote_id' => $vote_id) )->find();
  673. $this->vote = $vote;
  674. $this->addCrumb('洛江考评微官网', U('addon/HuianKaoping/index'), '')
  675. ->addCrumb('业务导航', U('addon/HuianKaoping/web/eventreport'), '')
  676. ->addCrumb('新闻中心', '', 'active')
  677. ->display('addvote');
  678. }
  679. public function editachievement()
  680. {
  681. $id = I('get.id');
  682. $type = I('get.type');
  683. if( IS_POST )
  684. {
  685. $data = I('post.');
  686. $vote_data = array();
  687. $vote_data['name'] = $data['name'];
  688. $vote_data['kao_time'] = strtotime( $data['kao_time'] );
  689. $vote_data['zeren_danwei'] = $data['zeren_danwei'];
  690. $vote_data['stree'] = $data['stree'];
  691. $vote_data['content'] = ($data['content']);
  692. //$vote_data['kaoping_dian'] = $data['kaoping_dian'];
  693. $vote_data['chengji'] = $data['chengji'];
  694. //$vote_data['paiming'] = $data['paiming'];
  695. M('luojiang_achievement')->where( array('id' => $id) )->save($vote_data);
  696. if($data['type'] == 2)
  697. {
  698. $this->success('编辑成功', U('addon/LuojiangKaoping/web/achievementmanage_two'));
  699. }else{
  700. $this->success('编辑成功', U('addon/LuojiangKaoping/web/achievementmanage'));
  701. }
  702. die();
  703. }
  704. if($type == 2)
  705. {
  706. $this->setEditSuccessUrl( U('addon/LuojiangKaoping/web/achievementmanage_two') );
  707. }else{
  708. $this->setEditSuccessUrl( U('addon/LuojiangKaoping/web/achievementmanage') );
  709. }
  710. $this->assign('type', $type);
  711. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  712. ->addCrumb('成绩管理', U('addon/LuojiangKaoping/web/achievementmanage'), '')
  713. ->addCrumb('成绩管理', '', 'active')
  714. ->setModel('luojiang_achievement')
  715. ->addFormField('name', '类别', 'text')
  716. ->addFormField('kao_time', '考评时间', 'date')
  717. ->addFormField('zeren_danwei', '街道(乡镇)/责任单位', 'text')
  718. ->addFormField('stree', '抽评点', 'text')
  719. ->addFormField('content', '内容', 'editor')
  720. //->addFormField('kaoping_dian', '考评点', 'text')
  721. ->addFormField('chengji', '成绩', 'text')
  722. //->addFormField('paiming', '排名', 'text')
  723. ->setEditMap( array('id'=>I('get.id')))
  724. ->common_edit();
  725. }
  726. public function get_cate_name($cate_id)
  727. {
  728. $category_info = M('luojiang_articlecategory')->where( array('id' => $cate_id) )->find();
  729. return $category_info['name'];
  730. }
  731. public function editarticle()
  732. {
  733. $cateinfos = M('luojiang_articlecategory')->where( array('pid' => 0) )->select();
  734. $cate_arr = array();
  735. foreach($cateinfos as $val)
  736. {
  737. $cate_arr[$val[id]] = $val['name'];
  738. }
  739. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  740. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  741. ->addCrumb('编辑文章', '', 'active')
  742. ->setModel('huian_article')
  743. ->addFormField('title', '标题', 'text')
  744. ->addFormField('link', '外链', 'text')
  745. ->addFormField('logo', '图片', 'image')
  746. ->addFormField('sendtime', '发布时间', 'time')
  747. ->addFormField('cate_id', '所属分类', 'select', array('options'=>$cate_arr))
  748. ->addFormField('content', '内容', 'editor')
  749. ->setValidate(array(
  750. array('name', 'require', '标题不能为空')//,
  751. //array('logo', 'require', '请上传图片')
  752. ))
  753. ->setFormData( M('luojiang_article')->find(I('get.id')) )
  754. ->setEditMap( array('id'=>I('get.id')) )
  755. ->setEditSuccessUrl( U('addon/LuojiangKaoping/web/newsnenter') )
  756. ->common_edit();
  757. }
  758. public function addarticlecate()
  759. {
  760. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  761. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  762. ->addCrumb('添加文章分类', '', 'active')
  763. ->setModel('luojiang_articlecategory')
  764. ->addFormField('name', '名称', 'text')
  765. //->addFormField('type', '类型', 'radio', array('options'=>array(1=>'普通订阅号',2=>'认证订阅号',3=>'普通服务号',4=>'认证服务号',5=>'测试号'),'value'=>4,'is_must'=>1))
  766. // ->addFormField('pid', '原始ID', 'text', array('is_must'=>1))
  767. //->addFormField('mp_number', '微信号', 'text')
  768. // ->addFormField('appid', 'APPID', 'text')
  769. // ->addFormField('appsecret', 'APPSECRET', 'text')
  770. //->addFormField('headimg', '头像', 'image')
  771. //->addFormField('qrcode', '二维码', 'image')
  772. ->setValidate(array(
  773. array('name', 'require', '名称不能为空'),
  774. ))
  775. ->setAuto(array(
  776. array('pid', '0'),
  777. array('addtime', 'time', 1, 'function')
  778. ))
  779. ->setAddSuccessUrl( U('addon/LuojiangKaoping/web/newsnenter') )
  780. ->common_add();
  781. }
  782. public function addarticle_two()
  783. {
  784. $cateinfos = M('luojiang_articlecategory')->where( array('pid' => 0) )->select();
  785. $cate_arr = array();
  786. foreach($cateinfos as $val)
  787. {
  788. $cate_arr[$val[id]] = $val['name'];
  789. }
  790. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  791. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  792. ->addCrumb('添加文章', '', 'active')
  793. ->setModel('luojiang_article')
  794. ->addFormField('title', '标题', 'text')
  795. ->addFormField('type', '1', 'hidden',array('value'=>2))
  796. //->addFormField('link', '外链', 'text')
  797. //->addFormField('logo', '图片', 'image')
  798. ->addFormField('sendtime', '发布时间', 'time')
  799. ->addFormField('cate_id', '1', 'hidden',array('value'=>1))
  800. //->addFormField('cate_id', '所属分类', 'select', array('options'=>$cate_arr))
  801. ->addFormField('content', '内容', 'editor')
  802. ->setValidate(array(
  803. array('name', 'require', '标题不能为空'),
  804. //array('logo', 'require', '请上传图片')
  805. ))
  806. ->setAuto(array(
  807. array('addtime', 'time', 1, 'function')
  808. ))
  809. ->setAddSuccessUrl( U('addon/LuojiangKaoping/web/newsnenter_two') )
  810. ->common_add();
  811. }
  812. public function addarticle()
  813. {
  814. $cateinfos = M('luojiang_articlecategory')->where( array('pid' => 0) )->select();
  815. $cate_arr = array();
  816. foreach($cateinfos as $val)
  817. {
  818. $cate_arr[$val[id]] = $val['name'];
  819. }
  820. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  821. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  822. ->addCrumb('添加文章', '', 'active')
  823. ->setModel('luojiang_article')
  824. ->addFormField('title', '标题', 'text')
  825. ->addFormField('type', '1', 'hidden',array('value'=>1))
  826. ->addFormField('link', '外链', 'text')
  827. ->addFormField('logo', '图片', 'image')
  828. ->addFormField('sendtime', '发布时间', 'time')
  829. ->addFormField('cate_id', '所属分类', 'select', array('options'=>$cate_arr))
  830. ->addFormField('content', '内容', 'editor')
  831. ->setValidate(array(
  832. array('name', 'require', '标题不能为空')//,
  833. //array('logo', 'require', '请上传图片')
  834. ))
  835. ->setAuto(array(
  836. array('addtime', 'time', 1, 'function')
  837. ))
  838. ->setAddSuccessUrl( U('addon/LuojiangKaoping/web/newsnenter') )
  839. ->common_add();
  840. }
  841. public function achievementmanage()
  842. {
  843. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  844. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  845. ->addCrumb('乡镇成绩管理', '', 'active')
  846. ->setModel('luojiang_achievement')
  847. ->setListOrder('addtime desc')
  848. ->addListItem('name', '类别')
  849. //->addListItem('kao_time', '考评时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
  850. ->setListMap(array('type'=>1))
  851. ->addListItem('kao_time', '考评时间', 'callback', array('callback_name'=>'get_date_hui'))
  852. ->addListItem('zeren_danwei', '街道办事处')
  853. ->addListItem('stree', '抽评点')
  854. //->addListItem('kaoping_dian', '考评点')
  855. ->addListItem('chengji', '成绩')
  856. //->addListItem('paiming', '排名')
  857. ->addListItem('addtime', '添加时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
  858. ->addButton('导入考评成绩', U('addon/LuojiangKaoping/web/loadachievement'), 'btn btn-primary')
  859. ->addListItem('id', '操作', 'custom', array('options'=>array('edit_fans'=>array('编辑成绩', U('addon/LuojiangKaoping/web/editachievement', array('id'=>'{id}','type'=>1)),'btn btn-primary btn-sm icon-edit',''))))
  860. ->common_lists();
  861. $cjcount = M('luojiang_achievement')->where(array('paiming'=>0,'type'=>1))->count();
  862. if($cjcount>0)
  863. {
  864. $paiming = array();
  865. $pagecount = M('luojiang_achievement')->field('kao_time')->where(array('type'=>1))->group('kao_time')->order('kao_time desc')->select();
  866. foreach($pagecount as $val)
  867. {
  868. $data = M('luojiang_achievement')->field('id,chengji')->where(array("kao_time"=>$val['kao_time'],"type"=>1))->order('chengji desc, id asc')->select();
  869. $chengji = $data[0]['chengji'];
  870. $order = 1;$num = 0;
  871. foreach($data as $key=>$subval)
  872. {
  873. if($key != 0){
  874. if($subval["chengji"] < $chengji){
  875. $order += 1;
  876. $chengji = $subval['chengji'];
  877. $order += $num;
  878. $num = 0;
  879. }
  880. else {
  881. $num++;
  882. }
  883. }
  884. $paiming[] = array('id'=>$subval["id"],'paiming'=>$order);
  885. }
  886. krsort($data);
  887. $chengji = $data[count($data)-1]['chengji'];
  888. $order = -5;$num = 0;
  889. foreach($data as $key=>$subval)
  890. {
  891. if($key != count($data)-1){
  892. if($subval["chengji"] > $chengji){
  893. $order += 1;
  894. $chengji = $subval['chengji'];
  895. $order += $num;
  896. $num = 0;
  897. }
  898. else {
  899. $num++;
  900. }
  901. }
  902. if($order == 0) break;
  903. $paiming[] = array('id'=>$subval["id"],'paiming'=>$order);
  904. }
  905. }
  906. foreach($paiming as $val)
  907. {
  908. $data['paiming'] = $val['paiming'];
  909. M('luojiang_achievement')->where(array("id"=>$val['id']))->save($data);
  910. }
  911. }
  912. }
  913. public function achievementmanage_two()
  914. {
  915. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  916. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  917. ->addCrumb('部门成绩管理', '', 'active')
  918. ->setModel('luojiang_achievement')
  919. ->setListOrder('addtime desc')
  920. ->setListMap(array('type'=>2))
  921. ->addListItem('name', '类别')
  922. //->addListItem('kao_time', '考评时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
  923. ->addListItem('kao_time', '考评时间', 'callback', array('callback_name'=>'get_date_hui'))
  924. ->addListItem('zeren_danwei', '部门')
  925. ->addListItem('stree', '考评对象')
  926. //->addListItem('kaoping_dian', '考评点')
  927. ->addListItem('chengji', '成绩')
  928. //->addListItem('paiming', '排名')
  929. ->addListItem('addtime', '添加时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
  930. ->addButton('导入考评成绩', U('addon/LuojiangKaoping/web/loadachievement',array('type'=>2)), 'btn btn-primary')
  931. ->addListItem('id', '操作', 'custom', array('options'=>array('edit_fans'=>array('编辑成绩', U('addon/HuianKaoping/web/editachievement', array('id'=>'{id}','type'=>2)),'btn btn-primary btn-sm icon-edit',''))))
  932. ->common_lists();
  933. $cjcount = M('luojiang_achievement')->where(array('paiming'=>0,'type'=>2))->count();
  934. if($cjcount>0)
  935. {
  936. $paiming = array();
  937. $pagecount = M('luojiang_achievement')->field('kao_time')->where(array('type'=>2))->group('kao_time')->order('kao_time desc')->select();
  938. foreach($pagecount as $val)
  939. {
  940. $data = M('luojiang_achievement')->field('id,chengji')->where(array("kao_time"=>$val['kao_time'],'type'=>2))->order('chengji desc, id asc')->select();
  941. $chengji = $data[0]['chengji'];
  942. $order = 1;$num = 0;
  943. foreach($data as $key=>$subval)
  944. {
  945. if($key != 0){
  946. if($subval["chengji"] < $chengji){
  947. $order += 1;
  948. $chengji = $subval['chengji'];
  949. $order += $num;
  950. $num = 0;
  951. }
  952. else {
  953. $num++;
  954. }
  955. }
  956. $paiming[] = array('id'=>$subval["id"],'paiming'=>$order);
  957. }
  958. krsort($data);
  959. $chengji = $data[count($data)-1]['chengji'];
  960. $order = -5;$num = 0;
  961. foreach($data as $key=>$subval)
  962. {
  963. if($key != count($data)-1){
  964. if($subval["chengji"] > $chengji){
  965. $order += 1;
  966. $chengji = $subval['chengji'];
  967. $order += $num;
  968. $num = 0;
  969. }
  970. else {
  971. $num++;
  972. }
  973. }
  974. if($order == 0) break;
  975. $paiming[] = array('id'=>$subval["id"],'paiming'=>$order);
  976. }
  977. }
  978. foreach($paiming as $val)
  979. {
  980. $data['paiming'] = $val['paiming'];
  981. M('luojiang_achievement')->where(array("id"=>$val['id']))->save($data);
  982. }
  983. }
  984. }
  985. public function get_date_hui($kao_time)
  986. {
  987. $d = date('d',$kao_time);
  988. /**
  989. if($d == '15')
  990. {
  991. $kao_time = date('Y-m',$kao_time).'-下半月';
  992. } else {
  993. $kao_time = date('Y-m',$kao_time).'-上半月';
  994. }
  995. **/
  996. $kao_time = date('Y-m-d',$kao_time);
  997. return $kao_time;
  998. }
  999. public function usermanage()
  1000. {
  1001. //->addListItem('msgid', '消息内容', 'callback', array('callback_name'=>'get_message_content'))
  1002. $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
  1003. ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
  1004. ->addCrumb('用户管理', '', 'active')
  1005. ->setModel('luojiang_eventreport')
  1006. ->setListMap(array('mpid'=>get_mpid()))
  1007. ->addListItem('fans_id', '会员名称', 'callback', array('callback_name'=>'get_fans_name'))
  1008. ->addListItem('event_type', '事件类型', 'enum', array('options'=>array('0'=>'未知',1=>'事件类型1',2=>'事件类型2',3=>'事件类型3')))
  1009. ->addListItem('title', '标题')
  1010. ->addListItem('descript', '事件描述')
  1011. ->addListItem('image_list', '图片列表', 'callback', array('callback_name'=>'get_images_str'))
  1012. ->addListItem('is_reply', '是否回复', 'enum', array('options'=>array(0=>'未回复',1=>'已回复')))
  1013. ->addListItem('location_addr', '位置', '', array('placeholder'=>'未提供'))
  1014. ->addListItem('addtime', '创建时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
  1015. ->addListItem('id', '操作', 'custom', array('options'=>array('edit_fans'=>array('编辑粉丝资料', U('Mp/Fans/edit_fans', array('openid'=>'{openid}')),'btn btn-primary btn-sm icon-edit',''))))
  1016. ->common_lists();
  1017. }
  1018. function get_images_str($image_list)
  1019. {
  1020. $image_arr = explode(',', $image_list);
  1021. $image_str = '';
  1022. $image_need_arr = array();
  1023. if( !empty($image_arr) )
  1024. {
  1025. foreach($image_arr as $img)
  1026. {
  1027. $img = str_replace('./Uploads/','/Uploads/',$img);
  1028. $img = str_replace('//','/',$img);
  1029. $imgtemp = explode('.',$img);
  1030. //$thumb_img = $this->resize($img,100,100);
  1031. $image_need_arr[] = "<div style='float:left;width:100px;margin-right:5px;'><img src='".$img."' width=100 height=100 'placeholder'= '".__ROOT__ ."/Public/Admin/img/noname.jpg' /><br/>【<a href='".$img."' target='_blank'>预览</a> | <a href='".U('addon/HuianKaoping/web/downfile', array('type' =>$imgtemp[1], 'file_url' => urlencode($img) ))."' target='_blank'>下载】</a></div>";
  1032. }
  1033. $image_str = implode(' ', $image_need_arr);
  1034. }
  1035. return "<div style='width:220px;'> ".$image_str."</div>";
  1036. }
  1037. //字符串截取
  1038. function utf8_substr($string, $offset, $length = null) {
  1039. // generates E_NOTICE
  1040. // for PHP4 objects, but not PHP5 objects
  1041. $string = (string)$string;
  1042. $offset = (int)$offset;
  1043. if (!is_null($length)) {
  1044. $length = (int)$length;
  1045. }
  1046. // handle trivial cases
  1047. if ($length === 0) {
  1048. return '';
  1049. }
  1050. if ($offset < 0 && $length < 0 && $length < $offset) {
  1051. return '';
  1052. }
  1053. // normalise negative offsets (we could use a tail
  1054. // anchored pattern, but they are horribly slow!)
  1055. if ($offset < 0) {
  1056. $strlen = strlen(utf8_decode($string));
  1057. $offset = $strlen + $offset;
  1058. if ($offset < 0) {
  1059. $offset = 0;
  1060. }
  1061. }
  1062. $Op = '';
  1063. $Lp = '';
  1064. // establish a pattern for offset, a
  1065. // non-captured group equal in length to offset
  1066. if ($offset > 0) {
  1067. $Ox = (int)($offset / 65535);
  1068. $Oy = $offset%65535;
  1069. if ($Ox) {
  1070. $Op = '(?:.{65535}){' . $Ox . '}';
  1071. }
  1072. $Op = '^(?:' . $Op . '.{' . $Oy . '})';
  1073. } else {
  1074. $Op = '^';
  1075. }
  1076. // establish a pattern for length
  1077. if (is_null($length)) {
  1078. $Lp = '(.*)$';
  1079. } else {
  1080. if (!isset($strlen)) {
  1081. $strlen = strlen(utf8_decode($string));
  1082. }
  1083. // another trivial case
  1084. if ($offset > $strlen) {
  1085. return '';
  1086. }
  1087. if ($length > 0) {
  1088. $length = min($strlen - $offset, $length);
  1089. $Lx = (int)($length / 65535);
  1090. $Ly = $length % 65535;
  1091. // negative length requires a captured group
  1092. // of length characters
  1093. if ($Lx) {
  1094. $Lp = '(?:.{65535}){' . $Lx . '}';
  1095. }
  1096. $Lp = '(' . $Lp . '.{' . $Ly . '})';
  1097. } elseif ($length < 0) {
  1098. if ($length < ($offset - $strlen)) {
  1099. return '';
  1100. }
  1101. $Lx = (int)((-$length) / 65535);
  1102. $Ly = (-$length)%65535;
  1103. // negative length requires ... capture everything
  1104. // except a group of -length characters
  1105. // anchored at the tail-end of the string
  1106. if ($Lx) {
  1107. $Lp = '(?:.{65535}){' . $Lx . '}';
  1108. }
  1109. $Lp = '(.*)(?:' . $Lp . '.{' . $Ly . '})$';
  1110. }
  1111. }
  1112. if (!preg_match( '#' . $Op . $Lp . '#us', $string, $match)) {
  1113. return '';
  1114. }
  1115. return $match[1];
  1116. }
  1117. /**
  1118. * 递归生成目录
  1119. */
  1120. function RecursiveMkdir($path) {
  1121. if (!file_exists($path)) {
  1122. $this->RecursiveMkdir(dirname($path));
  1123. @mkdir($path, 0777);
  1124. }
  1125. }
  1126. //字符串长度计算
  1127. function utf8_strlen($string) {
  1128. return strlen(utf8_decode($string));
  1129. }
  1130. function utf8_strrpos($string, $needle, $offset = null) {
  1131. if (is_null($offset)) {
  1132. $data = explode($needle, $string);
  1133. if (count($data) > 1) {
  1134. array_pop($data);
  1135. $string = join($needle, $data);
  1136. return $this->utf8_strlen($string);
  1137. }
  1138. return false;
  1139. } else {
  1140. if (!is_int($offset)) {
  1141. trigger_error('utf8_strrpos expects parameter 3 to be long', E_USER_WARNING);
  1142. return false;
  1143. }
  1144. $string = $this->utf8_substr($string, $offset);
  1145. if (false !== ($position = utf8_strrpos($string, $needle))) {
  1146. return $position + $offset;
  1147. }
  1148. return false;
  1149. }
  1150. }
  1151. /**
  1152. * 自动生成新尺寸 的图片
  1153. */
  1154. function resize($filename, $width, $height) {
  1155. define(ROOT_PATH,'/data/web/wx.mnw.cn/');
  1156. ///data/web/wx.mnw.cn/Addons/HuianKaoping/Controller
  1157. $image_dir=ROOT_PATH;
  1158. if (!is_file($image_dir . $filename)) {
  1159. return;
  1160. }
  1161. $extension = pathinfo($filename, PATHINFO_EXTENSION);
  1162. $old_image = $filename;
  1163. $new_image = 'cache/' . $this->utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
  1164. if (!is_file($image_dir . $new_image) || (filectime($image_dir . $old_image) > filectime($image_dir . $new_image))) {
  1165. $path = '';
  1166. $directories = explode('/', dirname(str_replace('../', '', $new_image)));
  1167. foreach ($directories as $directory) {
  1168. $path = $path . '/' . $directory;
  1169. if (!is_dir($image_dir . $path)) {
  1170. @mkdir($image_dir . $path, 0777);
  1171. }
  1172. }
  1173. list($width_orig, $height_orig) = getimagesize($image_dir . $old_image);
  1174. if ($width_orig != $width || $height_orig != $height) {
  1175. $image = new \Lib\Image($image_dir . $old_image);
  1176. $image->resize($width, $height);
  1177. $image->save($image_dir . $new_image);
  1178. } else {
  1179. copy($image_dir . $old_image, $image_dir . $new_image);
  1180. }
  1181. }
  1182. return 'Uploads/image/' . $new_image;
  1183. }
  1184. public function get_fans_name($fans_id)
  1185. {
  1186. $fans_info = M('mp_fans')->where( array('id' => $fans_id) )->find();
  1187. return $fans_info['nickname'];
  1188. //return '<a href="'.U('Mp/Fans/edit_fans', array('openid'=>$fans_info['openid'])).'" target="_blank" title="点击查看用户信息">'.$fans_info['nickname'].'</a>';
  1189. }
  1190. }
  1191. ?>