PageRenderTime 80ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/pages/social-report.php

https://bitbucket.org/14rego/cman
PHP | 882 lines | 828 code | 28 blank | 26 comment | 176 complexity | a485a67fb016c5efcc1dd3cb13c96e7e MD5 | raw file
  1. <?php
  2. if ($fromDate == '') { $fromDate = '20100101'; };
  3. if ($toDate == '') { $toDate = '20200131'; };
  4. $result = $sql->que("SELECT * FROM socnet_engage WHERE dat>='" .$fromDate. "' AND dat<='" .$toDate. "' ORDER BY dat ASC");
  5. ?>
  6. <h1>Social Networking Data</h1>
  7. <script src="http://code.highcharts.com/highcharts.js" type="text/javascript"></script>
  8. <script src="http://code.highcharts.com/modules/exporting.js" type="text/javascript"></script>
  9. <script src="/resources/scripts/excanvas.min.js" type="text/javascript"></script>
  10. <div id="holder-social-data" style="height:550px;"></div>
  11. <br /><br />
  12. <p>
  13. <a id="button-search" class="notice" href="#update-data">Update</a>
  14. <a id="button-reset" class="notice" href="#reset-data">Reset</a>
  15. <br /><br />
  16. <select id="filter-select-code" class="update-list">
  17. <option value="connect">Connections</option>
  18. <option value="activity">Activity</option>
  19. <option value="distribution">Distribution</option>
  20. </select>
  21. <select id="filter-select-sub" class="update-list">
  22. <option value="Post">Posts</option>
  23. <option value="Connection">Connections</option>
  24. <option value="Share">Sharing</option>
  25. <option value="Reply">Replies</option>
  26. <option value="Feedback">Feedback</option>
  27. </select>
  28. <select id="filter-select-client" class="update-list">
  29. <option value="SSI">Softek</option>
  30. <option value="ILM">Illuminate</option>
  31. <option value="OTK">Ontrack</option>
  32. </select>
  33. <select id="filter-select-site" class="update-list">
  34. <option value="Facebook">Facebook</option>
  35. <option value="Twitter">Twitter</option>
  36. <option value="LinkedIn">LinkedIn</option>
  37. <option value="Google+">Google+</option>
  38. <option value="Millennium Medic">Millennium Medic</option>
  39. </select>
  40. <select id="filter-select-type" class="update-list">
  41. <option value="line">Jagged Lines</option>
  42. <option value="spline">Smooth Lines</option>
  43. <option value="column">Columns</option>
  44. <option value="area">Area</option>
  45. <option value="bar">Bars</option>
  46. </select>
  47. </p>
  48. <script>
  49. $.buildGraph = function(code, type){
  50. // SET CLIENT TITLE
  51. var sSite = $('#filter-select-site').val();
  52. if (sSite === 'Millennium Medic') {
  53. $('#filter-select-client').val('OTK');
  54. } else if (sSite === 'Millennium Medic') {
  55. $('#filter-select-client').val('OTK');
  56. }
  57. var sClient = $('#filter-select-client').val();
  58. if (sClient==='OTK') { setCLIENT = 'OnTrack'; }
  59. else if (sClient==='ILM') { setCLIENT = 'Illuminate'; }
  60. else if (sClient==='SSI') { setCLIENT = 'Softek'; }
  61. else {
  62. setCLIENT = 'All Sites';
  63. }
  64. var sSub = $('#filter-select-sub').val();
  65. // SET DATA TYPE
  66. if (code==='connect') {
  67. <?php
  68. while ($row = pg_fetch_array($result)) {
  69. $mos = $mos."'".$row['dsc']."', ";
  70. $sFb = $sFb.$row['s_fb_conx'].", ";
  71. $iFb = $iFb.$row['i_fb_conx'].", ";
  72. $oFb = $oFb.$row['o_fb_conx'].", ";
  73. $sTw = $sTw.$row['s_tw_conx'].", ";
  74. $iTw = $iTw.$row['i_tw_conx'].", ";
  75. $oTw = $oTw.$row['o_tw_conx'].", ";
  76. $sLi = $sLi.$row['s_li_conx'].", ";
  77. $iGp = $iGp.$row['i_gp_conx'].", ";
  78. $oGp = $oGp.$row['o_gp_conx'].", ";
  79. $oMm = $oMm.$row['o_mm_conx'].", ";
  80. } pg_result_seek($result, 0);
  81. ?>
  82. var setTITLE = 'Connections';
  83. var setSUBTITLE = 'each month';
  84. chart = new Highcharts.Chart({
  85. chart: {
  86. renderTo: 'holder-social-data',
  87. defaultSeriesType: type,
  88. margin: [60, 10, 95, 50]
  89. },
  90. colors: [
  91. '#0099EE',
  92. '#0022CC',
  93. '#EE8800',
  94. '#AABBBB',
  95. '#FF6600',
  96. '#FFCC00',
  97. '#445555',
  98. '#990000'
  99. ],
  100. title: {
  101. text: setTITLE,
  102. },
  103. subtitle: {
  104. text: setSUBTITLE,
  105. },
  106. xAxis: {
  107. categories: [
  108. <?php echo substr($mos, 0, -2); ?>
  109. ],
  110. labels: {
  111. rotation: -90,
  112. align: 'center',
  113. y: 23,
  114. x: 3
  115. },
  116. plotBands: [
  117. {
  118. from: 3,
  119. to: 4,
  120. color: 'rgba(68, 170, 213, .1)',
  121. label: {
  122. text: 'CHC Campaign',
  123. align: "center",
  124. verticalAlign: "bottom",
  125. y: -8
  126. }
  127. },
  128. {
  129. from: 5,
  130. to: 6,
  131. color: 'rgba(68, 170, 213, .1)',
  132. label: {
  133. text: 'RSNA Campaign',
  134. align: "center",
  135. verticalAlign: "bottom",
  136. y: -8
  137. }
  138. },
  139. {
  140. from: 8,
  141. to: 9,
  142. color: 'rgba(68, 170, 213, .1)',
  143. label: {
  144. text: 'HIMSS Campaign',
  145. align: "center",
  146. verticalAlign: "bottom",
  147. y: -8
  148. }
  149. },
  150. {
  151. from: 16,
  152. to: 17,
  153. color: 'rgba(68, 170, 213, .1)',
  154. label: {
  155. text: 'CHC Campaign',
  156. align: "center",
  157. verticalAlign: "bottom",
  158. y: -8
  159. }
  160. },
  161. {
  162. from: 18,
  163. to: 19,
  164. color: 'rgba(68, 170, 213, .1)',
  165. label: {
  166. text: 'RSNA Campaign',
  167. align: "center",
  168. verticalAlign: "bottom",
  169. y: -8
  170. }
  171. },
  172. {
  173. from: 21,
  174. to: 22,
  175. color: 'rgba(68, 170, 213, .1)',
  176. label: {
  177. text: 'HIMSS Campaign',
  178. align: "center",
  179. verticalAlign: "bottom",
  180. y: -8
  181. }
  182. }
  183. ],
  184. plotLines: [{
  185. value: 2.75,
  186. width: 1,
  187. color: '#808080',
  188. label: {
  189. text: 'Social Networking Push',
  190. align: "center",
  191. verticalAlign: "top",
  192. y: 75
  193. }
  194. }]
  195. },
  196. yAxis: {
  197. min: 0,
  198. title: {
  199. text: setTITLE
  200. }
  201. },
  202. tooltip: {
  203. formatter: function() {
  204. return '<b>'+ this.series.name +'</b><br />'+
  205. this.x +': '+ this.y +'';
  206. }
  207. },
  208. credits: { enabled: false },
  209. legend: {
  210. align: 'center',
  211. floating: false,
  212. verticalAlign: 'bottom',
  213. borderWidth: 0,
  214. y: 10
  215. },
  216. plotOptions: {
  217. spline: {
  218. lineWidth: 2,
  219. states: {
  220. hover: {
  221. lineWidth: 4
  222. }
  223. },
  224. marker: {
  225. enabled: false,
  226. states: {
  227. hover: {
  228. enabled: true,
  229. symbol: 'circle',
  230. radius: 5,
  231. lineWidth: 1
  232. }
  233. }
  234. },
  235. }
  236. },
  237. series: [
  238. {
  239. name: 'SSI Facebook Friends',
  240. data: [<?php echo substr($sFb, 0, -2); ?>]
  241. },
  242. {
  243. name: 'ILM Facebook Page Likes',
  244. data: [<?php echo substr($iFb, 0, -2); ?>]
  245. },
  246. {
  247. name: 'OTK Facebook Page Likes',
  248. data: [<?php echo substr($oFb, 0, -2); ?>]
  249. },
  250. {
  251. name: 'SSI Twitter Followers',
  252. data: [<?php echo substr($sTw, 0, -2); ?>]
  253. },
  254. {
  255. name: 'ILM Twitter Followers',
  256. data: [<?php echo substr($iTw, 0, -2); ?>]
  257. },
  258. {
  259. name: 'OTK Twitter Followers',
  260. data: [<?php echo substr($oTw, 0, -2); ?>]
  261. },
  262. {
  263. name: 'LinkedIn Followers',
  264. data: [<?php echo substr($sLi, 0, -2); ?>]
  265. },
  266. {
  267. name: 'ILM Google+ Followers',
  268. data: [<?php echo substr($iGp, 0, -2); ?>]
  269. },
  270. {
  271. name: 'OTK Google+ Followers',
  272. data: [<?php echo substr($oGp, 0, -2); ?>]
  273. },
  274. {
  275. name: 'Mill. Medic Subscribers',
  276. data: [<?php echo substr($oMm, 0, -2); ?>]
  277. }
  278. ]
  279. });
  280. } else if (code==='activity') {
  281. var gConx = [];
  282. var gPost = [];
  283. var gReply = [];
  284. var gChare = [];
  285. var gLink = [];
  286. // FACEBOOK
  287. if (sSite=='Facebook') {
  288. var tConx = 'Page Likes / Friends';
  289. var tPost = 'Posts';
  290. var tReply = 'Comments or Likes';
  291. var tChare = 'Shares';
  292. var tLink = 'Links to Web';
  293. if (sClient=='ILM') {
  294. <?php
  295. while ($row = pg_fetch_array($result)) { echo 'gConx.push('.$row['i_fb_conx'].'); '; } pg_result_seek($result, 0);
  296. while ($row = pg_fetch_array($result)) { echo 'gPost.push('.$row['i_fb_post'].'); '; } pg_result_seek($result, 0);
  297. while ($row = pg_fetch_array($result)) { echo 'gReply.push('.$row['i_fb_reply'].'); '; } pg_result_seek($result, 0);
  298. while ($row = pg_fetch_array($result)) { echo 'gChare.push('.$row['i_fb_chare'].'); '; } pg_result_seek($result, 0);
  299. while ($row = pg_fetch_array($result)) { echo 'gLink.push('.$row['fb_link'].'); '; } pg_result_seek($result, 0);
  300. ?>
  301. } else if (sClient=='OTK') {
  302. <?php
  303. while ($row = pg_fetch_array($result)) { echo 'gConx.push('.$row['o_fb_conx'].'); '; } pg_result_seek($result, 0);
  304. while ($row = pg_fetch_array($result)) { echo 'gPost.push('.$row['o_fb_post'].'); '; } pg_result_seek($result, 0);
  305. while ($row = pg_fetch_array($result)) { echo 'gReply.push('.$row['o_fb_reply'].'); '; } pg_result_seek($result, 0);
  306. while ($row = pg_fetch_array($result)) { echo 'gChare.push('.$row['o_fb_chare'].'); '; } pg_result_seek($result, 0);
  307. while ($row = pg_fetch_array($result)) { echo 'gLink.push('.$row['fb_link'].'); '; } pg_result_seek($result, 0);
  308. ?>
  309. } else {
  310. <?php
  311. while ($row = pg_fetch_array($result)) { echo 'gConx.push('.$row['s_fb_conx'].'); '; } pg_result_seek($result, 0);
  312. while ($row = pg_fetch_array($result)) { echo 'gPost.push('.$row['s_fb_post'].'); '; } pg_result_seek($result, 0);
  313. while ($row = pg_fetch_array($result)) { echo 'gReply.push('.$row['s_fb_reply'].'); '; } pg_result_seek($result, 0);
  314. while ($row = pg_fetch_array($result)) { echo 'gChare.push('.$row['s_fb_chare'].'); '; } pg_result_seek($result, 0);
  315. while ($row = pg_fetch_array($result)) { echo 'gLink.push('.$row['fb_link'].'); '; } pg_result_seek($result, 0);
  316. ?>
  317. }
  318. }
  319. // TWITTER
  320. else if (sSite=='Twitter') {
  321. var tConx = 'Followers';
  322. var tPost = 'Posts';
  323. var tReply = 'Mentions';
  324. var tChare = 'Re-tweets';
  325. var tLink = 'Links to Web';
  326. if (sClient=='ILM') {
  327. <?php
  328. while ($row = pg_fetch_array($result)) { echo 'gConx.push('.$row['i_tw_conx'].'); '; } pg_result_seek($result, 0);
  329. while ($row = pg_fetch_array($result)) { echo 'gPost.push('.$row['i_tw_post'].'); '; } pg_result_seek($result, 0);
  330. while ($row = pg_fetch_array($result)) { echo 'gReply.push('.$row['i_tw_reply'].'); '; } pg_result_seek($result, 0);
  331. while ($row = pg_fetch_array($result)) { echo 'gChare.push('.$row['i_tw_chare'].'); '; } pg_result_seek($result, 0);
  332. while ($row = pg_fetch_array($result)) { echo 'gLink.push('.$row['tw_link'].'); '; } pg_result_seek($result, 0);
  333. ?>
  334. } else if (sClient=='OTK') {
  335. <?php
  336. while ($row = pg_fetch_array($result)) { echo 'gConx.push('.$row['o_tw_conx'].'); '; } pg_result_seek($result, 0);
  337. while ($row = pg_fetch_array($result)) { echo 'gPost.push('.$row['o_tw_post'].'); '; } pg_result_seek($result, 0);
  338. while ($row = pg_fetch_array($result)) { echo 'gReply.push('.$row['o_tw_reply'].'); '; } pg_result_seek($result, 0);
  339. while ($row = pg_fetch_array($result)) { echo 'gChare.push('.$row['o_tw_chare'].'); '; } pg_result_seek($result, 0);
  340. while ($row = pg_fetch_array($result)) { echo 'gLink.push('.$row['tw_link'].'); '; } pg_result_seek($result, 0);
  341. ?>
  342. } else {
  343. <?php
  344. while ($row = pg_fetch_array($result)) { echo 'gConx.push('.$row['s_tw_conx'].'); '; } pg_result_seek($result, 0);
  345. while ($row = pg_fetch_array($result)) { echo 'gPost.push('.$row['s_tw_post'].'); '; } pg_result_seek($result, 0);
  346. while ($row = pg_fetch_array($result)) { echo 'gReply.push('.$row['s_tw_reply'].'); '; } pg_result_seek($result, 0);
  347. while ($row = pg_fetch_array($result)) { echo 'gChare.push('.$row['s_tw_chare'].'); '; } pg_result_seek($result, 0);
  348. while ($row = pg_fetch_array($result)) { echo 'gLink.push('.$row['tw_link'].'); '; } pg_result_seek($result, 0);
  349. ?>
  350. }
  351. }
  352. // LINKEDIN
  353. else if (sSite=='LinkedIn') {
  354. var tConx = 'Followers';
  355. var tPost = 'Updates or Msgs Sent';
  356. var tReply = 'Comments or Replies';
  357. var tChare = 'Shares';
  358. var tLink = 'Links to Web';
  359. if (sClient=='ILM') {
  360. <?php
  361. while ($row = pg_fetch_array($result)) { echo 'gConx.push('.$row['s_li_conx'].'); '; } pg_result_seek($result, 0);
  362. while ($row = pg_fetch_array($result)) { echo 'gPost.push('.$row['i_li_post'].'); '; } pg_result_seek($result, 0);
  363. while ($row = pg_fetch_array($result)) { echo 'gReply.push('.$row['i_li_reply'].'); '; } pg_result_seek($result, 0);
  364. while ($row = pg_fetch_array($result)) { echo 'gChare.push('.$row['i_li_chare'].'); '; } pg_result_seek($result, 0);
  365. while ($row = pg_fetch_array($result)) { echo 'gLink.push('.$row['li_link'].'); '; } pg_result_seek($result, 0);
  366. ?>
  367. } else if (sClient=='OTK') {
  368. <?php
  369. while ($row = pg_fetch_array($result)) { echo 'gConx.push('.$row['s_li_conx'].'); '; } pg_result_seek($result, 0);
  370. while ($row = pg_fetch_array($result)) { echo 'gPost.push('.$row['o_li_post'].'); '; } pg_result_seek($result, 0);
  371. while ($row = pg_fetch_array($result)) { echo 'gReply.push('.$row['o_li_reply'].'); '; } pg_result_seek($result, 0);
  372. while ($row = pg_fetch_array($result)) { echo 'gChare.push('.$row['o_li_chare'].'); '; } pg_result_seek($result, 0);
  373. while ($row = pg_fetch_array($result)) { echo 'gLink.push('.$row['li_link'].'); '; } pg_result_seek($result, 0);
  374. ?>
  375. } else {
  376. <?php
  377. while ($row = pg_fetch_array($result)) { echo 'gConx.push('.$row['s_li_conx'].'); '; } pg_result_seek($result, 0);
  378. while ($row = pg_fetch_array($result)) { echo 'gPost.push('.$row['s_li_post'].'); '; } pg_result_seek($result, 0);
  379. while ($row = pg_fetch_array($result)) { echo 'gReply.push('.$row['s_li_reply'].'); '; } pg_result_seek($result, 0);
  380. while ($row = pg_fetch_array($result)) { echo 'gChare.push('.$row['s_li_chare'].'); '; } pg_result_seek($result, 0);
  381. while ($row = pg_fetch_array($result)) { echo 'gLink.push('.$row['li_link'].'); '; } pg_result_seek($result, 0);
  382. ?>
  383. }
  384. }
  385. // GOOGLE
  386. else if (sSite=='Google+') {
  387. var tConx = 'Followers';
  388. var tPost = 'Updates';
  389. var tReply = 'Comments or +1s';
  390. var tChare = 'Shares';
  391. var tLink = 'Links to Web';
  392. if (sClient=='ILM') {
  393. <?php
  394. while ($row = pg_fetch_array($result)) { echo 'gConx.push('.$row['i_gp_conx'].'); '; } pg_result_seek($result, 0);
  395. while ($row = pg_fetch_array($result)) { echo 'gPost.push('.$row['i_gp_post'].'); '; } pg_result_seek($result, 0);
  396. while ($row = pg_fetch_array($result)) { echo 'gReply.push('.$row['i_gp_reply'].'); '; } pg_result_seek($result, 0);
  397. while ($row = pg_fetch_array($result)) { echo 'gChare.push('.$row['i_gp_chare'].'); '; } pg_result_seek($result, 0);
  398. while ($row = pg_fetch_array($result)) { echo 'gLink.push('.$row['gp_link'].'); '; } pg_result_seek($result, 0);
  399. ?>
  400. } else {
  401. <?php
  402. while ($row = pg_fetch_array($result)) { echo 'gConx.push('.$row['o_gp_conx'].'); '; } pg_result_seek($result, 0);
  403. while ($row = pg_fetch_array($result)) { echo 'gPost.push('.$row['o_gp_post'].'); '; } pg_result_seek($result, 0);
  404. while ($row = pg_fetch_array($result)) { echo 'gReply.push('.$row['o_gp_reply'].'); '; } pg_result_seek($result, 0);
  405. while ($row = pg_fetch_array($result)) { echo 'gChare.push('.$row['o_gp_chare'].'); '; } pg_result_seek($result, 0);
  406. while ($row = pg_fetch_array($result)) { echo 'gLink.push('.$row['gp_link'].'); '; } pg_result_seek($result, 0);
  407. ?>
  408. }
  409. }
  410. // MEDIC
  411. else if (sSite=='Millennium Medic') {
  412. var tConx = 'Subscribers';
  413. var tPost = 'Posts';
  414. var tReply = 'Comments';
  415. var tChare = 'Shares';
  416. var tLink = 'Links to Web';
  417. <?php
  418. while ($row = pg_fetch_array($result)) { echo 'gConx.push('.$row['o_mm_conx'].'); '; } pg_result_seek($result, 0);
  419. while ($row = pg_fetch_array($result)) { echo 'gPost.push('.$row['o_mm_post'].'); '; } pg_result_seek($result, 0);
  420. while ($row = pg_fetch_array($result)) { echo 'gReply.push('.$row['o_mm_reply'].'); '; } pg_result_seek($result, 0);
  421. while ($row = pg_fetch_array($result)) { echo 'gChare.push('.$row['o_mm_chare'].'); '; } pg_result_seek($result, 0);
  422. while ($row = pg_fetch_array($result)) { echo 'gLink.push('.$row['mm_link'].'); '; } pg_result_seek($result, 0);
  423. ?>
  424. }
  425. var setTITLE = 'Profile Activity';
  426. var setSUBTITLE = sClient+' '+sSite;
  427. chart = new Highcharts.Chart({
  428. chart: {
  429. renderTo: 'holder-social-data',
  430. defaultSeriesType: type,
  431. margin: [60, 10, 95, 50]
  432. },
  433. colors: [
  434. '#0099EE',
  435. '#0022CC',
  436. '#EE8800',
  437. '#AABBBB',
  438. '#FF6600',
  439. '#FFCC00',
  440. '#445555',
  441. '#990000'
  442. ],
  443. title: {
  444. text: setTITLE,
  445. },
  446. subtitle: {
  447. text: setSUBTITLE,
  448. },
  449. xAxis: {
  450. categories: [<?php
  451. while ($row = pg_fetch_array($result)) {
  452. echo "'".$row['dsc']."', ";
  453. } pg_result_seek($result, 0); ?>
  454. ],
  455. labels: {
  456. rotation: -90,
  457. align: 'center',
  458. y: 23,
  459. x: 3
  460. },
  461. plotBands: [
  462. {
  463. from: 3,
  464. to: 4,
  465. color: 'rgba(68, 170, 213, .1)',
  466. label: {
  467. text: 'CHC Campaign',
  468. align: "center",
  469. verticalAlign: "bottom",
  470. y: -8
  471. }
  472. },
  473. {
  474. from: 5,
  475. to: 6,
  476. color: 'rgba(68, 170, 213, .1)',
  477. label: {
  478. text: 'RSNA Campaign',
  479. align: "center",
  480. verticalAlign: "bottom",
  481. y: -8
  482. }
  483. },
  484. {
  485. from: 8,
  486. to: 9,
  487. color: 'rgba(68, 170, 213, .1)',
  488. label: {
  489. text: 'HIMSS Campaign',
  490. align: "center",
  491. verticalAlign: "bottom",
  492. y: -8
  493. }
  494. },
  495. {
  496. from: 16,
  497. to: 17,
  498. color: 'rgba(68, 170, 213, .1)',
  499. label: {
  500. text: 'CHC Campaign',
  501. align: "center",
  502. verticalAlign: "bottom",
  503. y: -8
  504. }
  505. },
  506. {
  507. from: 18,
  508. to: 19,
  509. color: 'rgba(68, 170, 213, .1)',
  510. label: {
  511. text: 'RSNA Campaign',
  512. align: "center",
  513. verticalAlign: "bottom",
  514. y: -8
  515. }
  516. },
  517. {
  518. from: 21,
  519. to: 22,
  520. color: 'rgba(68, 170, 213, .1)',
  521. label: {
  522. text: 'HIMSS Campaign',
  523. align: "center",
  524. verticalAlign: "bottom",
  525. y: -8
  526. }
  527. }
  528. ],
  529. plotLines: [{
  530. value: 2.75,
  531. width: 1,
  532. color: '#808080',
  533. label: {
  534. text: 'Social Networking Push',
  535. align: "center",
  536. verticalAlign: "top",
  537. y: 75
  538. }
  539. }]
  540. },
  541. yAxis: {
  542. min: -1,
  543. title: {
  544. text: setTITLE
  545. }
  546. },
  547. tooltip: {
  548. formatter: function() {
  549. return '<b>'+ this.series.name +'</b><br />'+
  550. this.x +': '+ this.y +'';
  551. }
  552. },
  553. credits: { enabled: false },
  554. legend: {
  555. align: 'center',
  556. floating: false,
  557. verticalAlign: 'bottom',
  558. borderWidth: 0,
  559. y: 10
  560. },
  561. plotOptions: {
  562. spline: {
  563. lineWidth: 2,
  564. states: {
  565. hover: {
  566. lineWidth: 4
  567. }
  568. },
  569. marker: {
  570. enabled: false,
  571. states: {
  572. hover: {
  573. enabled: true,
  574. symbol: 'circle',
  575. radius: 5,
  576. lineWidth: 1
  577. }
  578. }
  579. },
  580. }
  581. },
  582. series: [
  583. { name: tConx, data: gConx },
  584. { name: tPost, data: gPost },
  585. { name: tReply, data: gReply },
  586. { name: tChare, data: gChare },
  587. { name: tLink, data: gLink }
  588. ]
  589. });
  590. } else if (code==='distribution') {
  591. var sFb = 0;
  592. var sTw = 0;
  593. var sLi = 0;
  594. var sMm = 0;
  595. var sGp = 0;
  596. var iFb = 0;
  597. var iTw = 0;
  598. var iLi = 0;
  599. var iMm = 0;
  600. var iGp = 0;
  601. var oFb = 0;
  602. var oTw = 0;
  603. var oLi = 0;
  604. var oMm = 0;
  605. var oGp = 0;
  606. if (sSub==='Post') {
  607. <?php
  608. while ($row = pg_fetch_array($result)) { echo 'sFb = sFb + parseInt('.$row['s_fb_post'].'); '; } pg_result_seek($result, 0);
  609. while ($row = pg_fetch_array($result)) { echo 'sTw = sTw + parseInt('.$row['s_tw_post'].'); '; } pg_result_seek($result, 0);
  610. while ($row = pg_fetch_array($result)) { echo 'sLi = sLi + parseInt('.$row['s_li_post'].'); '; } pg_result_seek($result, 0);
  611. //while ($row = pg_fetch_array($result)) { echo 'sMm = sMm + parseInt('.$row['s_mm_post'].'); '; } pg_result_seek($result, 0);
  612. //while ($row = pg_fetch_array($result)) { echo 'sGp = sGp + parseInt('.$row['s_gp_post'].'); '; } pg_result_seek($result, 0);
  613. while ($row = pg_fetch_array($result)) { echo 'iFb = iFb + parseInt('.$row['i_fb_post'].'); '; } pg_result_seek($result, 0);
  614. while ($row = pg_fetch_array($result)) { echo 'iTw = iTw + parseInt('.$row['i_tw_post'].'); '; } pg_result_seek($result, 0);
  615. //while ($row = pg_fetch_array($result)) { echo 'iLi = iLi + parseInt('.$row['i_li_post'].'); '; } pg_result_seek($result, 0);
  616. //while ($row = pg_fetch_array($result)) { echo 'iMm = iMm + parseInt('.$row['i_mm_post'].'); '; } pg_result_seek($result, 0);
  617. while ($row = pg_fetch_array($result)) { echo 'iGp = iGp + parseInt('.$row['i_gp_post'].'); '; } pg_result_seek($result, 0);
  618. while ($row = pg_fetch_array($result)) { echo 'oFb = oFb + parseInt('.$row['o_fb_post'].'); '; } pg_result_seek($result, 0);
  619. while ($row = pg_fetch_array($result)) { echo 'oTw = oTw + parseInt('.$row['o_tw_post'].'); '; } pg_result_seek($result, 0);
  620. //while ($row = pg_fetch_array($result)) { echo 'oLi = oLi + parseInt('.$row['o_li_post'].'); '; } pg_result_seek($result, 0);
  621. while ($row = pg_fetch_array($result)) { echo 'oMm = oMm + parseInt('.$row['o_mm_post'].'); '; } pg_result_seek($result, 0);
  622. while ($row = pg_fetch_array($result)) { echo 'oGp = oGp + parseInt('.$row['o_gp_post'].'); '; } pg_result_seek($result, 0);
  623. ?>
  624. } else if (sSub==='Share') {
  625. <?php
  626. while ($row = pg_fetch_array($result)) { echo 'sFb = sFb + parseInt('.$row['s_fb_chare'].'); '; } pg_result_seek($result, 0);
  627. while ($row = pg_fetch_array($result)) { echo 'sTw = sTw + parseInt('.$row['s_tw_chare'].'); '; } pg_result_seek($result, 0);
  628. while ($row = pg_fetch_array($result)) { echo 'sLi = sLi + parseInt('.$row['s_li_chare'].'); '; } pg_result_seek($result, 0);
  629. //while ($row = pg_fetch_array($result)) { echo 'sMm = sMm + parseInt('.$row['s_mm_chare'].'); '; } pg_result_seek($result, 0);
  630. //while ($row = pg_fetch_array($result)) { echo 'sGp = sGp + parseInt('.$row['s_gp_chare'].'); '; } pg_result_seek($result, 0);
  631. while ($row = pg_fetch_array($result)) { echo 'iFb = iFb + parseInt('.$row['i_fb_chare'].'); '; } pg_result_seek($result, 0);
  632. while ($row = pg_fetch_array($result)) { echo 'iTw = iTw + parseInt('.$row['i_tw_chare'].'); '; } pg_result_seek($result, 0);
  633. while ($row = pg_fetch_array($result)) { echo 'iLi = iLi + parseInt('.$row['i_li_chare'].'); '; } pg_result_seek($result, 0);
  634. //while ($row = pg_fetch_array($result)) { echo 'iMm = iMm + parseInt('.$row['i_mm_chare'].'); '; } pg_result_seek($result, 0);
  635. while ($row = pg_fetch_array($result)) { echo 'iGp = iGp + parseInt('.$row['i_gp_chare'].'); '; } pg_result_seek($result, 0);
  636. while ($row = pg_fetch_array($result)) { echo 'oFb = oFb + parseInt('.$row['o_fb_chare'].'); '; } pg_result_seek($result, 0);
  637. while ($row = pg_fetch_array($result)) { echo 'oTw = oTw + parseInt('.$row['o_tw_chare'].'); '; } pg_result_seek($result, 0);
  638. while ($row = pg_fetch_array($result)) { echo 'oLi = oLi + parseInt('.$row['o_li_chare'].'); '; } pg_result_seek($result, 0);
  639. while ($row = pg_fetch_array($result)) { echo 'oMm = oMm + parseInt('.$row['o_mm_chare'].'); '; } pg_result_seek($result, 0);
  640. while ($row = pg_fetch_array($result)) { echo 'oGp = oGp + parseInt('.$row['o_gp_chare'].'); '; } pg_result_seek($result, 0);
  641. ?>
  642. } else if (sSub==='Reply') {
  643. <?php
  644. while ($row = pg_fetch_array($result)) { echo 'sFb = sFb + parseInt('.$row['s_fb_reply'].'); '; } pg_result_seek($result, 0);
  645. while ($row = pg_fetch_array($result)) { echo 'sTw = sTw + parseInt('.$row['s_tw_reply'].'); '; } pg_result_seek($result, 0);
  646. while ($row = pg_fetch_array($result)) { echo 'sLi = sLi + parseInt('.$row['s_li_reply'].'); '; } pg_result_seek($result, 0);
  647. //while ($row = pg_fetch_array($result)) { echo 'sMm = sMm + parseInt('.$row['s_mm_reply'].'); '; } pg_result_seek($result, 0);
  648. //while ($row = pg_fetch_array($result)) { echo 'sGp = sGp + parseInt('.$row['s_gp_reply'].'); '; } pg_result_seek($result, 0);
  649. while ($row = pg_fetch_array($result)) { echo 'iFb = iFb + parseInt('.$row['i_fb_reply'].'); '; } pg_result_seek($result, 0);
  650. while ($row = pg_fetch_array($result)) { echo 'iTw = iTw + parseInt('.$row['i_tw_reply'].'); '; } pg_result_seek($result, 0);
  651. while ($row = pg_fetch_array($result)) { echo 'iLi = iLi + parseInt('.$row['i_li_reply'].'); '; } pg_result_seek($result, 0);
  652. //while ($row = pg_fetch_array($result)) { echo 'iMm = iMm + parseInt('.$row['i_mm_reply'].'); '; } pg_result_seek($result, 0);
  653. while ($row = pg_fetch_array($result)) { echo 'iGp = iGp + parseInt('.$row['i_gp_reply'].'); '; } pg_result_seek($result, 0);
  654. while ($row = pg_fetch_array($result)) { echo 'oFb = oFb + parseInt('.$row['o_fb_reply'].'); '; } pg_result_seek($result, 0);
  655. while ($row = pg_fetch_array($result)) { echo 'oTw = oTw + parseInt('.$row['o_tw_reply'].'); '; } pg_result_seek($result, 0);
  656. while ($row = pg_fetch_array($result)) { echo 'oLi = oLi + parseInt('.$row['o_li_reply'].'); '; } pg_result_seek($result, 0);
  657. while ($row = pg_fetch_array($result)) { echo 'oMm = oMm + parseInt('.$row['o_mm_reply'].'); '; } pg_result_seek($result, 0);
  658. while ($row = pg_fetch_array($result)) { echo 'oGp = oGp + parseInt('.$row['o_gp_reply'].'); '; } pg_result_seek($result, 0);
  659. ?>
  660. } else if (sSub==='Connection') {
  661. <?php
  662. while ($row = pg_fetch_array($result)) { echo 'sFb = sFb + parseInt('.$row['s_fb_conx'].'); '; } pg_result_seek($result, 0);
  663. while ($row = pg_fetch_array($result)) { echo 'sTw = sTw + parseInt('.$row['s_tw_conx'].'); '; } pg_result_seek($result, 0);
  664. while ($row = pg_fetch_array($result)) { echo 'sLi = sLi + parseInt('.$row['s_li_conx'].'); '; } pg_result_seek($result, 0);
  665. //while ($row = pg_fetch_array($result)) { echo 'sMm = sMm + parseInt('.$row['s_mm_conx'].'); '; } pg_result_seek($result, 0);
  666. //while ($row = pg_fetch_array($result)) { echo 'sGp = sGp + parseInt('.$row['s_gp_conx'].'); '; } pg_result_seek($result, 0);
  667. while ($row = pg_fetch_array($result)) { echo 'iFb = iFb + parseInt('.$row['i_fb_conx'].'); '; } pg_result_seek($result, 0);
  668. while ($row = pg_fetch_array($result)) { echo 'iTw = iTw + parseInt('.$row['i_tw_conx'].'); '; } pg_result_seek($result, 0);
  669. //while ($row = pg_fetch_array($result)) { echo 'iLi = iLi + parseInt('.$row['i_li_conx'].'); '; } pg_result_seek($result, 0);
  670. //while ($row = pg_fetch_array($result)) { echo 'iMm = iMm + parseInt('.$row['i_mm_conx'].'); '; } pg_result_seek($result, 0);
  671. while ($row = pg_fetch_array($result)) { echo 'iGp = iGp + parseInt('.$row['i_gp_conx'].'); '; } pg_result_seek($result, 0);
  672. while ($row = pg_fetch_array($result)) { echo 'oFb = oFb + parseInt('.$row['o_fb_conx'].'); '; } pg_result_seek($result, 0);
  673. while ($row = pg_fetch_array($result)) { echo 'oTw = oTw + parseInt('.$row['o_tw_conx'].'); '; } pg_result_seek($result, 0);
  674. //while ($row = pg_fetch_array($result)) { echo 'oLi = oLi + parseInt('.$row['o_li_conx'].'); '; } pg_result_seek($result, 0);
  675. while ($row = pg_fetch_array($result)) { echo 'oMm = oMm + parseInt('.$row['o_mm_conx'].'); '; } pg_result_seek($result, 0);
  676. while ($row = pg_fetch_array($result)) { echo 'oGp = oGp + parseInt('.$row['o_gp_conx'].'); '; } pg_result_seek($result, 0);
  677. ?>
  678. } else if (sSub==='Feedback') {
  679. <?php
  680. while ($row = pg_fetch_array($result)) { echo 'sFb = sFb + parseInt('.$row['s_fb_ratep'].') + parseInt('.$row['s_fb_raten'].'); '; } pg_result_seek($result, 0);
  681. while ($row = pg_fetch_array($result)) { echo 'sTw = sTw + parseInt('.$row['s_tw_ratep'].') + parseInt('.$row['s_tw_raten'].'); '; } pg_result_seek($result, 0);
  682. while ($row = pg_fetch_array($result)) { echo 'sLi = sLi + parseInt('.$row['s_li_ratep'].') + parseInt('.$row['s_li_raten'].'); '; } pg_result_seek($result, 0);
  683. //while ($row = pg_fetch_array($result)) { echo 'sMm = sMm + parseInt('.$row['s_mm_ratep'].') + parseInt('.$row['s_mm_raten'].'); '; } pg_result_seek($result, 0);
  684. //while ($row = pg_fetch_array($result)) { echo 'sGp = sGp + parseInt('.$row['s_gp_ratep'].') + parseInt('.$row['s_gp_raten'].'); '; } pg_result_seek($result, 0);
  685. while ($row = pg_fetch_array($result)) { echo 'iFb = iFb + parseInt('.$row['i_fb_ratep'].') + parseInt('.$row['i_fb_raten'].'); '; } pg_result_seek($result, 0);
  686. while ($row = pg_fetch_array($result)) { echo 'iTw = iTw + parseInt('.$row['i_tw_ratep'].') + parseInt('.$row['i_tw_raten'].'); '; } pg_result_seek($result, 0);
  687. while ($row = pg_fetch_array($result)) { echo 'iLi = iLi + parseInt('.$row['i_li_ratep'].') + parseInt('.$row['i_li_raten'].'); '; } pg_result_seek($result, 0);
  688. //while ($row = pg_fetch_array($result)) { echo 'iMm = iMm + parseInt('.$row['i_mm_ratep'].') + parseInt('.$row['i_mm_raten'].'); '; } pg_result_seek($result, 0);
  689. while ($row = pg_fetch_array($result)) { echo 'iGp = iGp + parseInt('.$row['i_gp_ratep'].') + parseInt('.$row['i_gp_raten'].'); '; } pg_result_seek($result, 0);
  690. while ($row = pg_fetch_array($result)) { echo 'oFb = oFb + parseInt('.$row['o_fb_ratep'].') + parseInt('.$row['o_fb_raten'].'); '; } pg_result_seek($result, 0);
  691. while ($row = pg_fetch_array($result)) { echo 'oTw = oTw + parseInt('.$row['o_tw_ratep'].') + parseInt('.$row['o_tw_raten'].'); '; } pg_result_seek($result, 0);
  692. while ($row = pg_fetch_array($result)) { echo 'oLi = oLi + parseInt('.$row['o_li_ratep'].') + parseInt('.$row['o_li_raten'].'); '; } pg_result_seek($result, 0);
  693. while ($row = pg_fetch_array($result)) { echo 'oMm = oMm + parseInt('.$row['o_mm_ratep'].') + parseInt('.$row['o_mm_raten'].'); '; } pg_result_seek($result, 0);
  694. while ($row = pg_fetch_array($result)) { echo 'oGp = oGp + parseInt('.$row['o_gp_ratep'].') + parseInt('.$row['o_gp_raten'].'); '; } pg_result_seek($result, 0);
  695. ?>
  696. }
  697. var tFb = sFb + iFb + oFb;
  698. var tTw = sTw + iTw + oTw;
  699. var tLi = sLi + iLi + oLi;
  700. var tMm = sMm + iMm + oMm;
  701. var tGp = sGp + iGp + oGp;
  702. var setTITLE = sSub+' Distribution';
  703. chart = new Highcharts.Chart({
  704. chart: {
  705. renderTo: 'holder-social-data',
  706. defaultSeriesType: 'column',
  707. margin: [60, 10, 50, 50]
  708. },
  709. title: {
  710. text: setTITLE
  711. },
  712. xAxis: {
  713. categories: ['Softek', 'Illuminate', 'OnTrack']
  714. },
  715. yAxis: {
  716. min: 0,
  717. title: {
  718. text: sSub+'(s)'
  719. }
  720. },
  721. tooltip: {
  722. formatter: function() {
  723. var s;
  724. if (this.point.name) { // the pie chart
  725. s = ''+ this.series.name +': '+ this.y +' ('+ Math.round(this.percentage) +'%)';
  726. } else {
  727. s = ''+ this.series.name +': '+ this.y +' ('+ Math.round(this.percentage) +'%)';
  728. }
  729. return s;
  730. }
  731. },
  732. credits: { enabled: false },
  733. legend: {
  734. align: 'center',
  735. floating: false,
  736. verticalAlign: 'bottom',
  737. borderWidth: 0,
  738. y: 10
  739. },
  740. plotOptions: {
  741. column: {
  742. stacking: 'percent'
  743. }
  744. },
  745. series: [
  746. {
  747. type: 'column',
  748. name: 'Facebook',
  749. color: '#006',
  750. data: [ sFb, iFb, oFb ]
  751. }, {
  752. type: 'column',
  753. name: 'Twitter',
  754. color: '#0784C6',
  755. data: [ sTw, iTw, oTw ]
  756. }, {
  757. type: 'column',
  758. name: 'LinkedIn',
  759. color: '#0047A1',
  760. data: [ sLi, iLi, oLi ]
  761. }, {
  762. type: 'column',
  763. name: 'Google+',
  764. color: '#F60',
  765. data: [ sGp, iGp, oGp ]
  766. }, {
  767. type: 'column',
  768. name: 'M. Medic',
  769. color: '#C30000',
  770. data: [ sMm, iMm, oMm ]
  771. }, {
  772. type: 'pie',
  773. name: 'Total',
  774. data: [
  775. {
  776. name: 'Facebook',
  777. y: tFb,
  778. color: '#006'
  779. }, {
  780. name: 'Twitter',
  781. y: tTw,
  782. color: '#0784C6'
  783. }, {
  784. name: 'LinkedIn',
  785. y: tLi,
  786. color: '#0047A1'
  787. }, {
  788. name: 'Google+',
  789. y: tGp,
  790. color: '#F60'
  791. }, {
  792. name: 'M. Medic',
  793. y: tMm,
  794. color: '#C30000'
  795. }
  796. ],
  797. center: [470, 250],
  798. size: 200,
  799. showInLegend: false,
  800. dataLabels: {
  801. enabled: false
  802. }
  803. }
  804. ]
  805. });
  806. } // END TYPE CHECK
  807. };
  808. $.resetData = function(list, filter){
  809. $('#filter-select-client').val('ALL').hide();
  810. $('#filter-select-code').val('connect').show();
  811. $('#filter-select-type').val('spline').hide();
  812. $('#filter-select-site').val('SSI').hide();
  813. $('#filter-select-sub').val('Post').hide();
  814. $.updateData();
  815. };
  816. $.updateData = function(){
  817. var setCODE = $('#filter-select-code').val();
  818. var setTYPE = $('#filter-select-type').val();
  819. if (setCODE==='connect') {
  820. $('#filter-select-client').hide();
  821. $('#filter-select-type').show();
  822. $('#filter-select-site').hide();
  823. $('#filter-select-sub').hide();
  824. } else if (setCODE==='activity') {
  825. $('#filter-select-client').show();
  826. $('#filter-select-type').show();
  827. $('#filter-select-site').show();
  828. $('#filter-select-sub').hide();
  829. } else if (setCODE==='distribution') {
  830. $('#filter-select-client').hide();
  831. $('#filter-select-type').hide();
  832. $('#filter-select-site').hide();
  833. $('#filter-select-sub').show();
  834. }
  835. $.buildGraph(setCODE, setTYPE);
  836. };
  837. $(function() {
  838. $.resetData();
  839. $('.body').keyup( function (e){
  840. if (e.keyCode === 13) { // RETURN
  841. e.preventDefault();
  842. $.updateData();
  843. }
  844. });
  845. $('#button-search').click(function(e){
  846. e.preventDefault();
  847. $.updateData();
  848. });
  849. $('#button-reset').click(function(e){
  850. e.preventDefault();
  851. $.resetData();
  852. });
  853. });
  854. </script>