core.class.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <?php
  2. if (!defined('IN_DISCUZ')) {
  3. exit('Access Denied');
  4. }
  5. class xj_eventcore {
  6. public function IsEventAdmin($tid, $uid) {
  7. global $_G;
  8. $return = 0;
  9. $items = DB::fetch_first("SELECT * FROM " . DB::table('xj_event') . " A LEFT JOIN " . DB::table('forum_thread') . " B ON A.tid=B.tid WHERE A.tid=$tid");
  10. $setting = unserialize($items['setting']);
  11. $member = DB::fetch_first("SELECT * FROM " . DB::table('common_member') . " WHERE uid=$uid");
  12. if ($member['groupid'] == 1) {
  13. $return = 1;
  14. } elseif ($items['authorid'] == $uid) {
  15. $return = 2;
  16. } elseif (in_array($member['username'], $setting['event_admin'])) {
  17. $return = 3;
  18. }
  19. return $return;
  20. }
  21. public function GetEventPrice($tid, $uid) {
  22. //获取价格
  23. global $_G;
  24. $items = DB::fetch_first("SELECT * FROM " . DB::table('xj_event') . " WHERE tid=$tid");
  25. $setting = unserialize($items['setting']);
  26. $price = 0;
  27. //如果是多种报名
  28. if ($setting['cost']) {
  29. if ($setting['nodaibaoming']) {
  30. $apply = DB::fetch_first("SELECT * FROM " . DB::table('xj_eventapply') . " WHERE tid = $tid and uid = $uid");
  31. $apply['ufielddata'] = unserialize($apply['ufielddata']);
  32. $price = 0;
  33. foreach ($setting['cost'] as $value) {
  34. $price = $price + $apply['ufielddata']['cost' . $value['id']] * $value['cost_price'];
  35. }
  36. } else {
  37. $apply = DB::fetch_all("SELECT * FROM " . DB::table('xj_eventapply') . " WHERE tid = $tid and uid=$uid");
  38. $price = 0;
  39. foreach ($apply as $value) {
  40. $value['ufielddata'] = unserialize($value['ufielddata']);
  41. $price = $price + $setting['cost'][$value['ufielddata']['costclass']]['cost_price'];
  42. }
  43. }
  44. } else {
  45. if ($setting['nodaibaoming']) {
  46. $applynumber = DB::result_first("SELECT applynumber FROM " . DB::table('xj_eventapply') . " WHERE tid = $tid and uid=$uid");
  47. } else {
  48. $applynumber = DB::result_first("SELECT count(*) FROM " . DB::table('xj_eventapply') . " WHERE tid = $tid and uid=$uid");
  49. }
  50. $price = number_format($items['use_cost'] * $applynumber, 2, '.', '');
  51. }
  52. //VIP折扣
  53. /*
  54. if(file_exists(DISCUZ_ROOT.'./source/plugin/xj_event/module/vip/event_pay.php')) {
  55. @include DISCUZ_ROOT.'./source/plugin/xj_event/module/vip/event_pay.php';
  56. }
  57. */
  58. return $price;
  59. }
  60. public function GetEventApply($tid, $uid) {
  61. //获取报名内容
  62. global $_G;
  63. $items = DB::fetch_first("SELECT * FROM " . DB::table('xj_event') . " WHERE tid=$tid");
  64. $setting = unserialize($items['setting']);
  65. //如果是多种报名
  66. if ($setting['cost']) {
  67. $return = array();
  68. if ($setting['nodaibaoming']) {
  69. $apply = DB::fetch_first("SELECT * FROM " . DB::table('xj_eventapply') . " WHERE tid = $tid and uid = $uid");
  70. $apply['ufielddata'] = unserialize($apply['ufielddata']);
  71. foreach ($setting['cost'] as $value) {
  72. $tmp = array();
  73. $tmp['cost_number'] = $apply['ufielddata']['cost' . $value['id']];
  74. $tmp['cost_name'] = $value['cost_name'];
  75. $return[] = $tmp;
  76. }
  77. } else {
  78. $apply = DB::fetch_all("SELECT * FROM " . DB::table('xj_eventapply') . " WHERE tid = $tid and uid=$uid");
  79. foreach ($apply as $value) {
  80. $value['ufielddata'] = unserialize($value['ufielddata']);
  81. $tmp = array();
  82. $tmp['cost_number'] = 1;
  83. $tmp['cost_name'] = $setting['cost'][$value['ufielddata']['costclass']]['cost_name'];
  84. $return[] = $tmp;
  85. }
  86. }
  87. } else {
  88. if ($setting['nodaibaoming']) {
  89. $applynumber = DB::result_first("SELECT applynumber FROM " . DB::table('xj_eventapply') . " WHERE tid = $tid and uid=$uid");
  90. } else {
  91. $applynumber = DB::result_first("SELECT count(*) FROM " . DB::table('xj_eventapply') . " WHERE tid = $tid and uid=$uid");
  92. }
  93. $return = $applynumber;
  94. }
  95. return $return;
  96. }
  97. public function GetApplyInfo($tid, $uid) {
  98. //报名详细信息
  99. global $_G;
  100. $return = array();
  101. $items = DB::fetch_first("SELECT * FROM " . DB::table('xj_event') . " WHERE tid=$tid");
  102. $setting = unserialize($items['setting']);
  103. $selectuserfield = unserialize($items['userfield']);
  104. $sysuserfield = unserialize($_G['setting']['activityfield']);
  105. if ($setting['nodaibaoming']) {
  106. $apply = DB::fetch_all("SELECT * FROM " . DB::table('xj_eventapply') . " WHERE tid = $tid and uid = $uid");
  107. foreach ($apply as $value) {
  108. $tmp = array();
  109. $value['ufielddata'] = unserialize($value['ufielddata']);
  110. foreach ($selectuserfield as $key => $val) {
  111. if ($val != 'bmmessage') {
  112. $tmp[$key]['title'] = $sysuserfield[$val];
  113. $tmp[$key]['value'] = $value['ufielddata'][$val];
  114. }
  115. }
  116. if ($setting['cost']) {
  117. $cost = array();
  118. $cost['title'] = lang('plugin/xj_event', 'baomingleixing');
  119. foreach ($setting['cost'] as $val) {
  120. $cost['value'] .= $val['cost_name'] . 'x' . $value['ufielddata']['cost' . $val['id']] . ' ';
  121. }
  122. $tmp[] = $cost;
  123. }
  124. $return[] = $tmp;
  125. }
  126. } else {
  127. $apply = DB::fetch_all("SELECT * FROM " . DB::table('xj_eventapply') . " WHERE tid = $tid and uid = $uid ORDER BY first DESC");
  128. foreach ($apply as $value) {
  129. $tmp = array();
  130. $value['ufielddata'] = unserialize($value['ufielddata']);
  131. foreach ($selectuserfield as $key => $val) {
  132. if ($val != 'bmmessage') {
  133. $tmp[$key]['title'] = $sysuserfield[$val];
  134. $tmp[$key]['value'] = $value['ufielddata'][$val];
  135. }
  136. }
  137. if ($setting['cost']) {
  138. $cost = array();
  139. $cost['title'] = lang('plugin/xj_event', 'baomingleixing');
  140. $cost['value'] = $setting['cost'][$value['ufielddata']['costclass']]['cost_name'];
  141. $tmp[] = $cost;
  142. }
  143. $return[] = $tmp;
  144. }
  145. }
  146. return $return;
  147. }
  148. public function GetYouHui($tid, $uid) {
  149. global $_G;
  150. $return = 0;
  151. $items = DB::fetch_first("SELECT * FROM " . DB::table('xj_event') . " WHERE tid = $tid");
  152. $eventnumber = $items['event_number'];
  153. $setting = unserialize($items['setting']);
  154. $use_cost = $items['use_cost'];
  155. $item = DB::fetch_first("SELECT applyid,applynumber FROM " . DB::table('xj_eventapply') . " WHERE tid = $tid and uid=$uid");
  156. //报名方式不同,计算人数
  157. if ($setting['nodaibaoming']) {
  158. $applynumber = $item['applynumber'];
  159. } else {
  160. $applynumber = DB::result_first("SELECT count(*) FROM " . DB::table('xj_eventapply') . " WHERE tid = $tid and uid=$uid");
  161. }
  162. $apply = DB::fetch_first("SELECT * FROM " . DB::table('xj_eventapply') . " WHERE first=1 AND tid = $tid AND uid=$uid");
  163. $apply['ufielddata'] = unserialize($apply['ufielddata']);
  164. //VIP折扣
  165. $vipgroup = unserialize($_G['cache']['plugin']['xj_event']['vipgroupid']);
  166. $_G['groupid'] = DB::result_first("SELECT groupid FROM " . DB::table('common_member') . " WHERE uid = $uid");
  167. if (in_array($_G['groupid'], $vipgroup)) {
  168. //判断是否是VIP用户组
  169. //优惠计算
  170. $youhuiprice = 0;
  171. if ($setting['cost']) {
  172. //启用多项报名时
  173. if ($setting['nodaibaoming']) {
  174. //代报名不填资料时
  175. foreach ($setting['cost'] as $value) {
  176. if ($value['cost_youhui'] !== '') {
  177. if ($value['cost_youhui'] > 0) {
  178. $youhuiprice = $youhuiprice + ($apply['ufielddata']['cost' . $value['id']] * $value['cost_youhui']);
  179. }
  180. }
  181. }
  182. } else {
  183. //代报名填资料时
  184. $apply_yh = DB::fetch_all("SELECT * FROM " . DB::table('xj_eventapply') . " WHERE tid = '$tid' and uid=" . $uid);
  185. foreach ($apply_yh as $value) {
  186. $value['ufielddata'] = unserialize($value['ufielddata']);
  187. if ($setting['cost'][$value['ufielddata']['costclass']]['cost_youhui'] !== '') {
  188. if ($setting['cost'][$value['ufielddata']['costclass']]['cost_youhui'] > 0) {
  189. $youhuiprice = $youhuiprice + $setting['cost'][$value['ufielddata']['costclass']]['cost_youhui'];
  190. }
  191. }
  192. }
  193. }
  194. } else {
  195. //不启用多项报名时
  196. if ($setting['vip_discount'] !== '') {
  197. if ($setting['vip_discount'] > 0) {
  198. $youhuiprice = $setting['vip_discount'] * $applynumber;
  199. }
  200. }
  201. }
  202. $return = $youhuiprice;
  203. }
  204. return $return;
  205. }
  206. public function GetUserField($fields, $values) {
  207. global $_G;
  208. $return = array();
  209. $myuserfield = DB::fetch_all("SELECT * FROM " . DB::table('xj_event_field') . " WHERE id in(" . implode(',', $fields) . ") ORDER BY id");
  210. foreach ($myuserfield as $value) {
  211. if ($value['formtype'] == 'text') {
  212. $value['html'] = '<input type="text" class="myuserfield_text" name="' . 'myfield' . $value['id'] . '" value="' . $values['myfield' . $value['id']] . '">';
  213. }
  214. if ($value['formtype'] == 'textarea') {
  215. $value['html'] = '<textarea name="' . 'myfield' . $value['id'] . '" maxlength="100" cols="38" rows="3" class="pt">' . $values['myfield' . $value['id']] . '</textarea>';
  216. }
  217. if ($value['formtype'] == 'select') {
  218. $tmp = explode("\r\n", $value['choices']);
  219. if ($_G['mobile']) {
  220. $value['html'] = '<div class="xjselect"><input type="hidden" name="' . 'myfield' . $value['id'] . '" id="' . 'myfield' . $value['id'] . '" value="' . $values['myfield' . $value['id']] . '">';
  221. foreach ($tmp as $tmpkey => $tmpval) {
  222. if ($tmpval) {
  223. if ($tmpval == $values['myfield' . $value['id']]) {
  224. $tmpcolor = '#48bd46';
  225. } else {
  226. $tmpcolor = '#cccccc';
  227. }
  228. $value['html'] = $value['html'] . '<span style="background-color:' . $tmpcolor . '; font-size:14px; padding:3px 12px; color:#FFF; border-radius:4px; margin-bottom:5px; margin-right:5px; float:left;font-weight:normal; text-shadow:none;" data-value="' . $tmpval . '">' . $tmpval . '</span>';
  229. }
  230. }
  231. $value['html'] .= '</div><div style="clear:both;"></div>';
  232. } else {
  233. $value['html'] = '<select name="' . 'myfield' . $value['id'] . '">';
  234. foreach ($tmp as $tmpkey => $tmpval) {
  235. if ($tmpval) {
  236. $value['html'] = $value['html'] . '<option value="' . $tmpval . '" ' . ($values['myfield' . $value['id']] == $tmpval ? 'selected' : '') . ' />' . $tmpval . '</option>';
  237. }
  238. }
  239. $value['html'] .= '</select>';
  240. }
  241. }
  242. if ($value['formtype'] == 'uploadfile') {
  243. $value['html'] = '<div style="background-color:#FFF; border:1px solid #eee; ' . ($_G['mobile'] ? '' : 'margin-left:80px') . '">
  244. <div class="showimg">' . (!empty($values) ? '<img src="' . $values['myfield' . $value['id']] . '" style="width:100%;">' : '') . '</div>
  245. <div style="height:160px; text-align:center;' . (!empty($values) ? 'display:none;' : '') . '" class="uploadcover">
  246. <div style="font-size:56px; color:#e1e1e1; text-align:center; padding-top:60px; line-height:28px;">+<br>
  247. </div>
  248. </div>
  249. <input type="hidden" name="myfield' . $value['id'] . '" value="' . $values['myfield' . $value['id']] . '" class="inputtext">
  250. <form action="plugin.php?id=xj_event:wsqcenter&mod=event_pub&action=upload&formhash=' . $_G['formhash'] . '" method="post" enctype="multipart/form-data">
  251. <input class="uploadfile" type="file" data-role="none" data-value="' . $value['id'] . '" name="mypic" style="display:block;position: absolute; margin-top:-160px;width: 300px;height: 160px;opacity: 0;cursor:pointer;">
  252. </form>
  253. <div class="bar" style="background-color:#2ace51; width:0px; height:5px; clear:both; margin:0px;"></div>
  254. <div class="uploaderror" style="padding:0px 10%;"></div>
  255. </div>
  256. ';
  257. }
  258. $return[] = $value;
  259. }
  260. return $return;
  261. }
  262. }