support.php 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  1. <?php
  2. /****************************
  3. * File : support.php
  4. * Author : Cygnusa
  5. * @2018
  6. ****************************/
  7. //SECURITY
  8. if (!defined('APPLICATION_PATH')) {
  9. exit('No direct script access allowed');
  10. }
  11. class support
  12. {
  13. //FUNCTION LISTS
  14. public function __construct($parent)
  15. {
  16. //GET PAGE MESSAGE
  17. $this->page_data = globalfunc::getMessage($parent, $parent->lang, 'support');
  18. if (count($parent->params) == 0) {
  19. //$this->topicsfunc($parent);
  20. } else {
  21. $qry_params = explode("?", $parent->params[0]);
  22. $parameter_val = strtolower($qry_params[0]);
  23. switch ($parameter_val) {
  24. case "topic":
  25. case "content":
  26. case "registereduser":
  27. case "assessment":
  28. case "dmsemployee":
  29. case "dmsmanager":
  30. case "dmsdealer":
  31. case "dmssales":
  32. case "dmstarget":
  33. case "dmsrewardpoints":
  34. case "lastaccess":
  35. case "customerexperience":
  36. case "enquiry":
  37. case "activesmpin":
  38. case "loginlog":
  39. case "dealerenquiryinactive":
  40. $this->$parameter_val($parent);
  41. break;
  42. default:
  43. $this->topicsfunc($parent);
  44. break;
  45. }
  46. }
  47. $parent->response(array('response' => 'failed', 'message' => 'PAGE NOT FOUND'), 404);
  48. }
  49. /* /////////////////////////////// TOPICS //////////////////////////////////////////////// */
  50. private function topic($parent)
  51. {
  52. globalfunc::checkMethodType($parent, array('GET'));
  53. globalfunc::checkParamCount($parent, 1);
  54. $data_arr = array();
  55. $limit_str = globalfunc::setPageLimit($parent, $parent->params[0]);
  56. $limit_cond = ($limit_str) ? " LIMIT " . $limit_str : '';
  57. echo '<!DOCTYPE html><html>
  58. <head><meta charset="UTF-8"><h3>HYPER-M - TOPIC LIST</h3></head><body>'
  59. . '<table border="1"><tr><th>#</th><th>Category</th><th>Category id</th><th>Topic</th><th>Topic id</th><th>User type</th><th>Topic image</th></tr>';
  60. $query_category = $parent->selectQuery(TABLE_CATEGORY, "`cateid`, `catename`", "1=1 ORDER BY cateid ", "");
  61. if ($query_category['nr']) {
  62. $sno = 1;
  63. $s3 = awsfileserver::connectS3();
  64. foreach ($query_category['result'] as $res_cat) {
  65. $user_cond = " AND cateid='" . $res_cat->cateid . "' ";
  66. $getuser_topics_arr = $parent->selectQuery(TABLE_ASSET_TOPIC, "*", " status='1' AND is_deleted='0' " . $user_cond . " ORDER BY position ASC, assettopicid ASC " . $limit_cond, "");
  67. if ($getuser_topics_arr['nr']) {
  68. //CONNECT S3
  69. foreach ($getuser_topics_arr['result'] as $res) {
  70. $res->image_url = TRAININGIMAGE_URL;
  71. if ($res->image) {
  72. $res->image_url = awsfileserver::getS3FileUrl($s3, S3_BUCKET, S3_TOPICS_URL . $res->image);
  73. }
  74. $user_type = ($res->user_type == '0') ? "Normal" : "Super Bike";
  75. //$data_arr[]=$res;
  76. echo '<tr><td>' . $sno++ . '</td><td>' . $res_cat->catename . '</td><td>' . $res_cat->cateid . '</td><td>' . $res->topicname . '</td><td>' . $res->assettopicid . '</td><td>' . $user_type . '</td><td><img src="' . $res->image_url . '" style="width:100px;"></td></tr>';
  77. }
  78. }
  79. }
  80. }
  81. echo '</table></body></html>';exit;
  82. }
  83. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  84. /* /////////////////////////////// TOPICS CONTENT LIST //////////////////////////////////////////////// */
  85. private function content($parent)
  86. {
  87. globalfunc::checkMethodType($parent, array('GET'));
  88. globalfunc::checkParamCount($parent, 1);
  89. $data_arr = array();
  90. echo '<!DOCTYPE html><html>
  91. <head><meta charset="UTF-8"><h3>HYPER-M - CONTENT LIST</h3></head><body>'
  92. . '<table border="1"><tr><th>#</th><th>Category</th><th>Category id</th><th>Topic</th><th>Topic id</th><th>Content id</th><th>Topic image</th><th>Content title</th><th>Content description</th><th>Content file urls</th></tr>';
  93. $query_category = $parent->selectQuery(TABLE_CATEGORY, "`cateid`, `catename`", "1=1 ORDER BY cateid ", "");
  94. if ($query_category['nr']) {
  95. $sno = 0;
  96. $s3 = awsfileserver::connectS3();
  97. foreach ($query_category['result'] as $res_cat) {
  98. $user_cond = " AND cateid='" . $res_cat->cateid . "' ";
  99. $getuser_topics_arr = $parent->selectQuery(TABLE_ASSET_TOPIC, "*", " status='1' AND is_deleted='0' " . $user_cond . " ORDER BY position ASC, assettopicid ASC ");
  100. if ($getuser_topics_arr['nr']) {
  101. //CONNECT S3
  102. foreach ($getuser_topics_arr['result'] as $res) {
  103. $res->image_url = TRAININGIMAGE_URL;
  104. if ($res->image) {
  105. $res->image_url = awsfileserver::getS3FileUrl($s3, S3_BUCKET, S3_TOPICS_URL . $res->image);
  106. }
  107. $usercond = " AND assettopicid='" . $res->assettopicid . "' ";
  108. $orderby_cond = ($res->listorder == '1') ? "ORDER BY uploaddate DESC,contentid ASC " : "ORDER BY uploaddate ASC,contentid ASC ";
  109. $getuser_content_arr = $parent->selectQuery(TABLE_ASSET_CONTENT, "*", " status='1' AND is_deleted='0' " . $usercond . " " . $orderby_cond, "");
  110. if ($getuser_content_arr['nr']) {
  111. foreach ($getuser_content_arr['result'] as $res_con) {
  112. $res_con->content_files = $this->getContentFiles($parent, $s3, $res_con->contentid);
  113. if (count($res_con->content_files) > 0) {
  114. $table_value = '<table border="1" style="margin:2px;"><tr><th>#</th><th>Language</th><th>Thumb nail</th><th>Content</th></tr>';
  115. foreach ($res_con->content_files as $res_file) {
  116. $m = 0;
  117. $table_value .= '<tr><td>' . ++$m . '</td><td>' . $res_file->language_title . '</td><td><img src="' . $res_file->thumb_fileurl . '" style="width:100px;"></td><td><a href="' . $res_file->file_url . '">Download</a></td></tr>';
  118. }
  119. $table_value .= '</table>';
  120. }
  121. echo '<tr><td>' . ++$sno . '</td><td>' . $res_cat->catename . '</td><td>' . $res_cat->cateid . '</td><td>' . $res->topicname . '</td><td>' . $res->assettopicid . '</td><td>' . $res_con->contentid . '</td><td><img src="' . $res->image_url . '" style="width:100px;"></td><td>' . $res_con->title . '</td><td>' . $res_con->description . '</td><td>' . $table_value . '</td></tr>';
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. echo '</table></body></html>';exit;
  129. }
  130. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  131. /* /////////////////////////////// TOPIC CONTENT //////////////////////////////////////////////// */
  132. private function getContentFiles($parent, $s3, $contentid)
  133. {
  134. $data_arr = array();
  135. //GET FILES ONLY ONE FILE
  136. $getuser_contentfiles_arr = $parent->selectQuery(TABLE_ASSET_FILE . " as f JOIN " . TABLE_MASTER_LANGUAGE . " as l ON l.language_id=f.language_id", " f.`language_id`, f.`filepath`,f.filetypeid, f.`thumbpath`, f.`filetypeid`, f.`filetype`, f.`filesize`, f.`filequality`, l.`language_code`, l. `language_title`", " f.contentid='" . $contentid . "'", "");
  137. if ($getuser_contentfiles_arr['nr']) {
  138. foreach ($getuser_contentfiles_arr['result'] as $tkey => $res) {
  139. //S3 FILE URL
  140. $fileurl = '';
  141. if ($res->filepath != '') {
  142. $url = awsfileserver::getS3FileUrl($s3, S3_BUCKET, S3_TOPICS_URL . $res->filepath);
  143. //PDF ISSUE FIX FOR WEB DEVICE
  144. $url = (strtolower($parent->device_type) == 'web' && $res->filetypeid == '1') ? projectfunc::pdfUrlStr($parent, $url) : $url;
  145. $fileurl = $url;
  146. }
  147. $getuser_contentfiles_arr['result'][$tkey]->file_url = $fileurl;
  148. //S3 THUMBIMAGE URL
  149. $thumb_fileurl = '';
  150. if ($res->thumbpath != '') {
  151. $thumb_fileurl = awsfileserver::getS3FileUrl($s3, S3_BUCKET, S3_TOPICS_URL . $res->thumbpath);
  152. }
  153. $getuser_contentfiles_arr['result'][$tkey]->thumb_fileurl = $thumb_fileurl;
  154. }
  155. $data_arr = $getuser_contentfiles_arr['result'];
  156. }
  157. return $data_arr;
  158. }
  159. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  160. /* /////////////////////////////// REGISTERED USER //////////////////////////////////////////////// */
  161. private function registereduser($parent)
  162. {
  163. globalfunc::checkMethodType($parent, array('GET'));
  164. globalfunc::checkParamCount($parent, 1);
  165. $data_arr = array();
  166. $limit_str = globalfunc::setPageLimit($parent, $parent->params[0]);
  167. $limit_cond = ($limit_str) ? " LIMIT " . $limit_str : '';
  168. $cond = '';
  169. //FILTER
  170. $filter_arr = globalfunc::getFilterValues($parent, $parent->params[0]);
  171. if (count($filter_arr) > 0) {
  172. //smpin
  173. if (isset($filter_arr['role']) && $filter_arr['role'] != '') {
  174. $cond = " AND u.role='" . $filter_arr['role'] . "'";
  175. }
  176. }
  177. $query_group = $parent->selectQuery(TABLE_USER . " u JOIN " . TABLE_ROLE . " r ON u.role=r.id LEFT JOIN " . DMS_DEALER . " d ON d.dealer_code=u.dealer_code", "COUNT(u.userid) ucount , r.rolename ", "u.is_deleted=0 AND u.role>2 " . $cond . " GROUP BY u.role", "");
  178. echo '<!DOCTYPE html><html>
  179. <head><meta charset="UTF-8"><h3>HYPER-M - REGISTERED USER LIST</h3></head><body>'
  180. . '<table border="1"><tr><th>ROLE</th><th>TOTAL REGISTER</th></tr>';
  181. if ($query_group['nr']) {
  182. foreach ($query_group['result'] as $res) {
  183. echo '<tr><td>' . $res->rolename . '</td><td>' . $res->ucount . '</td></tr>';
  184. }
  185. }
  186. echo '</table></br></br>'
  187. . '<table border="1"><tr><th>#</th><th>USERID</th><th>ROLE</th><th>SMPIN</th><th>EMP CODE</th><th>NAME</th><th>Segment</th><th>DEALER CODE</th><th>DEALER</th><th>Zone</th><th>City</th><th>ZM</th><th>RM</th><th>AM</th><th>MOBILE</th><th>EMAIL</th><th>REGISTERED DATE</th></tr>';
  188. $query_user = $parent->selectQuery(TABLE_USER . " u JOIN " . TABLE_ROLE . " r ON u.role=r.id LEFT JOIN " . DMS_DEALER . " d ON d.dealer_code=u.dealer_code", "u.smpin,u.emp_code,u.fname, u.`lname`,u.segment, u.`emailid`, u.`mobileno`,u.created_on,r.rolename,u.dealer_code,d.dealer_name,d.city,d.zone,d.`zm_name`, d.`rm_name`, d.`am_name`,u.userid", "u.is_deleted=0 AND u.role>2 " . $cond . " ORDER BY u.created_on ", "");
  189. if ($query_user['nr']) {
  190. $sno = 1;
  191. //$s3=awsfileserver::connectS3();
  192. foreach ($query_user['result'] as $res_user) {
  193. $dealer_code = ($res_user->dealer_code != '') ? $res_user->dealer_code : '';
  194. $dealer_data = ($res_user->dealer_code != '') ? $res_user->dealer_name : '';
  195. $segment = '';
  196. switch ($res_user->segment) {
  197. case '0':$segment = 'Student Learner';
  198. break;
  199. case '1':$segment = 'Parents/Guardian';
  200. break;
  201. case '2':$segment = 'Instructor';
  202. break;
  203. }
  204. echo '<tr><td>' . $sno++ . '</td><td>' . $res_user->userid . '</td><td>' . $res_user->rolename . '</td><td>' . $res_user->smpin . '</td><td>' . $res_user->emp_code . '</td><td>' . $res_user->fname . " " . $res_user->lname . '</td><td>' . $segment . '</td><td>' . $dealer_code . '</td><td>' . $dealer_data . '</td><td>' . $res_user->zone . '</td><td>' . $res_user->city . '</td><td>' . $res_user->zm_name . '</td><td>' . $res_user->rm_name . '</td><td>' . $res_user->am_name . '</td><td>' . $res_user->mobileno . '</td><td>' . $res_user->emailid . '</td><td>' . date('d-m-Y h:i A ', strtotime($res_user->created_on)) . '</td></tr>';
  205. }
  206. }
  207. echo '</table></body></html>';exit;
  208. }
  209. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  210. /* /////////////////////////////// ASSESSMENT //////////////////////////////////////////////// */
  211. private function assessment($parent)
  212. {
  213. globalfunc::checkMethodType($parent, array('GET'));
  214. globalfunc::checkParamCount($parent, 1);
  215. $data_arr = array();
  216. $limit_str = globalfunc::setPageLimit($parent, $parent->params[0]);
  217. $limit_cond = ($limit_str) ? " LIMIT " . $limit_str : '';
  218. echo '<!DOCTYPE html><html>
  219. <head><meta charset="UTF-8"><h3>HYPER-M - ASSESSMENT LIST</h3></head><body>'
  220. . '<table border="1"><tr><th>#</th><th>ASSESSMENT</th><th>SCORE</th><th>ATTENDED ON</th><th>SMPIN</th><th>NAME</th><th>MOBILE</th><th>DEALER CODE</th><th>DEALER</th><th>CITY</th><th>ZONE</th></tr>';
  221. //SELECT a.assessmentname,au.highscore,u.smpin, u.fname, u.`lname`, u.`mobileno`,u.dealer_code,d.dealer_name,d.city,d.zone FROM `tbl__assessmentuser` au JOIN tbl__assessment a On a.assessmentid=au.assessmentid JOIN tbl__user u On au.userid=u.userid JOIN tbl__role r ON u.role=r.id LEFT JOIN tbl__dms_dealer d ON d.dealer_code=u.dealer_code WHERE a.assettypeid=1 ORDER BY a.assessmentid ASC
  222. $query_res = $parent->selectQuery(TABLE_ASSESSMENT_USER . " au JOIN " . TABLE_ASSESSMENT . " a On a.assessmentid=au.assessmentid JOIN " . TABLE_USER . " u On au.userid=u.userid JOIN " . TABLE_ROLE . " r ON u.role=r.id LEFT JOIN " . DMS_DEALER . " d ON d.dealer_code=u.dealer_code ", "a.assessmentname,au.highscore,au.modified_on,u.smpin, u.fname, u.`lname`, u.`mobileno`,u.dealer_code,d.dealer_name,d.city,d.zone", "a.assettypeid=1 ORDER BY a.assessmentid ASC,au.highscore DESC,au.modified_on ASC ", "");
  223. if ($query_res['nr']) {
  224. $sno = 1;
  225. //$s3=awsfileserver::connectS3();
  226. foreach ($query_res['result'] as $res) {
  227. $dealer_code = ($res_user->dealer_code != '') ? $res_user->dealer_code : '';
  228. echo '<tr><td>' . $sno++ . '</td><td>' . $res->assessmentname . '</td><td>' . $res->highscore . '</td><td>' . date('d-m-Y h:i A', strtotime($res->modified_on)) . '</td><td>' . $res->modified_on . '</td><td>' . $res->smpin . '</td><td>' . $res->fname . " " . $res->lname . '</td><td>' . $res->mobileno . '</td><td>' . $dealer_code . '</td><td>' . $res->dealer_name . '</td><td>' . $res->city . '</td><td>' . $res->zone . '</td></tr>';
  229. }
  230. }
  231. echo '</table></body></html>';exit;
  232. }
  233. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  234. /* /////////////////////////////// dmsemployee //////////////////////////////////////////////// */
  235. private function dmsemployee($parent)
  236. {
  237. globalfunc::checkMethodType($parent, array('GET'));
  238. globalfunc::checkParamCount($parent, 1);
  239. $data_arr = array();
  240. $limit_str = globalfunc::setPageLimit($parent, $parent->params[0]);
  241. $limit_cond = ($limit_str) ? " LIMIT " . $limit_str : '';
  242. $cond = '';
  243. //FILTER
  244. $filter_arr = globalfunc::getFilterValues($parent, $parent->params[0]);
  245. if (count($filter_arr) > 0) {
  246. //smpin
  247. if (isset($filter_arr['smpin']) && $filter_arr['smpin'] != '') {
  248. $cond .= " AND u.smpin LIKE '%" . escape_str($filter_arr['smpin']) . "%' ";
  249. }
  250. //emp_code
  251. if (isset($filter_arr['emp_code']) && $filter_arr['emp_code'] != '') {
  252. $cond .= " AND u.emp_code LIKE '%" . escape_str($filter_arr['emp_code']) . "%' ";
  253. }
  254. //fname
  255. if (isset($filter_arr['fname']) && $filter_arr['fname'] != '') {
  256. $cond .= " AND u.fname LIKE '%" . escape_str($filter_arr['fname']) . "%' ";
  257. }
  258. //lname
  259. if (isset($filter_arr['lname']) && $filter_arr['lname'] != '') {
  260. $cond .= " AND u.lname LIKE '%" . escape_str($filter_arr['lname']) . "%' ";
  261. }
  262. //dealer_code
  263. if (isset($filter_arr['dealer_code']) && $filter_arr['dealer_code'] != '') {
  264. $cond .= " AND u.dealer_code LIKE '%" . escape_str($filter_arr['dealer_code']) . "%' ";
  265. }
  266. //role
  267. if (isset($filter_arr['role']) && $filter_arr['role'] != '') {
  268. $cond .= " AND u.role LIKE '%" . escape_str($filter_arr['role']) . "%' ";
  269. }
  270. //role
  271. if (isset($filter_arr['mobile']) && $filter_arr['mobile'] != '') {
  272. $cond .= " AND u.mobile LIKE '%" . escape_str($filter_arr['mobile']) . "%' ";
  273. }
  274. //city
  275. if (isset($filter_arr['city']) && $filter_arr['city'] != '') {
  276. $cond .= " AND d.city LIKE '%" . escape_str($filter_arr['city']) . "%' ";
  277. }
  278. //zone
  279. if (isset($filter_arr['zone']) && $filter_arr['zone'] != '') {
  280. $cond .= " AND d.zone LIKE '%" . escape_str($filter_arr['zone']) . "%' ";
  281. }
  282. }
  283. $query_group = $parent->selectQuery(DMS_EMPLOYEE, "COUNT(id) ucount ", "status=1", "");
  284. echo '<!DOCTYPE html><html>
  285. <head><meta charset="UTF-8"><h3>HYPER-M - EMPLOYEE MASTER DATA </h3></head><body>'
  286. . '<table border="1"><th>TOTAL COUNT</th></tr>';
  287. if ($query_group['nr']) {
  288. foreach ($query_group['result'] as $res) {
  289. echo '<tr><td>' . $res->ucount . '</td></tr>';
  290. }
  291. }
  292. echo '</table></br></br>'
  293. . '<table border="1"> ';
  294. $query_user = $parent->selectQuery(DMS_EMPLOYEE . " u LEFT JOIN " . DMS_DEALER . " d ON d.dealer_code=u.dealer_code", "u.`smpin`, u.`emp_code`, u.`fname`,u. `lname`, u.segment,u.`dealer_code`,u. `role`, u.`emailid`, u.`mobile`,u.is_current,d.dealer_name,d.city,d.zone,u.created_on,u.modified_on", "u.status='1' " . $cond, "");
  295. if ($query_user['nr']) {
  296. $sno = 0;
  297. //$s3=awsfileserver::connectS3();
  298. foreach ($query_user['result'] as $res_user) {
  299. if ($sno == 0) {
  300. $arr = array_keys((array) $res_user);
  301. //print_r(array_keys($a)); exit;
  302. echo '<tr><th>#</th>';
  303. foreach ($arr as $head) {
  304. echo '<th>' . $head . '</td>';
  305. }
  306. echo '</tr>';
  307. $sno++;
  308. }
  309. echo '<tr><td>' . $sno++ . '</td>';
  310. foreach ($res_user as $val) {
  311. echo '<td>' . $val . '</td>';
  312. }
  313. echo '</tr>';
  314. }
  315. }
  316. echo '</table></body></html>';exit;
  317. }
  318. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  319. /* /////////////////////////////// dmsmanager //////////////////////////////////////////////// */
  320. private function dmsmanager($parent)
  321. {
  322. globalfunc::checkMethodType($parent, array('GET'));
  323. globalfunc::checkParamCount($parent, 1);
  324. $data_arr = array();
  325. $limit_str = globalfunc::setPageLimit($parent, $parent->params[0]);
  326. $limit_cond = ($limit_str) ? " LIMIT " . $limit_str : '';
  327. $query_group = $parent->selectQuery(DMS_HOUSER, "COUNT(id) ucount ", "status=1", "");
  328. $cond = '';
  329. //FILTER
  330. $filter_arr = globalfunc::getFilterValues($parent, $parent->params[0]);
  331. if (count($filter_arr) > 0) {
  332. //emp_code
  333. if (isset($filter_arr['emp_code']) && $filter_arr['emp_code'] != '') {
  334. $cond .= " AND emp_code LIKE '%" . escape_str($filter_arr['emp_code']) . "%' ";
  335. }
  336. //fname
  337. if (isset($filter_arr['fname']) && $filter_arr['fname'] != '') {
  338. $cond .= " AND fname LIKE '%" . escape_str($filter_arr['fname']) . "%' ";
  339. }
  340. //lname
  341. if (isset($filter_arr['lname']) && $filter_arr['lname'] != '') {
  342. $cond .= " AND lname LIKE '%" . escape_str($filter_arr['lname']) . "%' ";
  343. }
  344. //role
  345. if (isset($filter_arr['role']) && $filter_arr['role'] != '') {
  346. $cond .= " AND role LIKE '%" . escape_str($filter_arr['role']) . "%' ";
  347. }
  348. //role
  349. if (isset($filter_arr['mobile']) && $filter_arr['mobile'] != '') {
  350. $cond .= " AND mobile LIKE '%" . escape_str($filter_arr['mobile']) . "%' ";
  351. }
  352. //zone
  353. if (isset($filter_arr['zone']) && $filter_arr['zone'] != '') {
  354. $cond .= " AND zone LIKE '%" . escape_str($filter_arr['zone']) . "%' ";
  355. }
  356. }
  357. echo '<!DOCTYPE html><html>
  358. <head><meta charset="UTF-8"><h3>HYPER-M - MANAGER MASTER DATA</h3></head><body>'
  359. . '<table border="1"><th>TOTAL COUNT</th></tr>';
  360. if ($query_group['nr']) {
  361. foreach ($query_group['result'] as $res) {
  362. echo '<tr><td>' . $res->ucount . '</td></tr>';
  363. }
  364. }
  365. echo '</table></br></br>'
  366. . '<table border="1"> ';
  367. $query_user = $parent->selectQuery(DMS_HOUSER, "`emp_code`, `fname`, `lname`, `role`, `emailid`, `mobile`, `dealer_code`, `zone`, `created_on`, `modified_on`", "status='1'" . $cond, "");
  368. if ($query_user['nr']) {
  369. $sno = 0;
  370. //$s3=awsfileserver::connectS3();
  371. foreach ($query_user['result'] as $res_user) {
  372. if ($sno == 0) {
  373. $arr = array_keys((array) $res_user);
  374. //print_r(array_keys($a)); exit;
  375. echo '<tr><th>#</th>';
  376. foreach ($arr as $head) {
  377. echo '<th>' . $head . '</td>';
  378. }
  379. echo '</tr>';
  380. $sno++;
  381. }
  382. echo '<tr><td>' . $sno++ . '</td>';
  383. foreach ($res_user as $val) {
  384. echo '<td>' . $val . '</td>';
  385. }
  386. echo '</tr>';
  387. }
  388. }
  389. echo '</table></body></html>';exit;
  390. }
  391. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  392. /* /////////////////////////////// dmsdealer //////////////////////////////////////////////// */
  393. private function dmsdealer($parent)
  394. {
  395. globalfunc::checkMethodType($parent, array('GET'));
  396. globalfunc::checkParamCount($parent, 1);
  397. $data_arr = array();
  398. $limit_str = globalfunc::setPageLimit($parent, $parent->params[0]);
  399. $limit_cond = ($limit_str) ? " LIMIT " . $limit_str : '';
  400. $query_group = $parent->selectQuery(DMS_DEALER, "COUNT(id) ucount ", "status=1 AND is_deleted='0'", "");
  401. $cond = '';
  402. //FILTER
  403. $filter_arr = globalfunc::getFilterValues($parent, $parent->params[0]);
  404. if (count($filter_arr) > 0) {
  405. //dealer_code
  406. if (isset($filter_arr['dealer_code']) && $filter_arr['dealer_code'] != '') {
  407. $cond .= " AND dealer_code LIKE '%" . escape_str($filter_arr['dealer_code']) . "%' ";
  408. }
  409. //dealer_name
  410. if (isset($filter_arr['dealer_name']) && $filter_arr['dealer_name'] != '') {
  411. $cond .= " AND dealer_name LIKE '%" . escape_str($filter_arr['dealer_name']) . "%' ";
  412. }
  413. //city
  414. if (isset($filter_arr['city']) && $filter_arr['city'] != '') {
  415. $cond .= " AND city LIKE '%" . escape_str($filter_arr['lname']) . "%' ";
  416. }
  417. //state
  418. if (isset($filter_arr['state']) && $filter_arr['state'] != '') {
  419. $cond .= " AND state LIKE '%" . escape_str($filter_arr['state']) . "%' ";
  420. }
  421. //mobile
  422. if (isset($filter_arr['mobile']) && $filter_arr['mobile'] != '') {
  423. $cond .= " AND mobile LIKE '%" . escape_str($filter_arr['mobile']) . "%' ";
  424. }
  425. //zone
  426. if (isset($filter_arr['zone']) && $filter_arr['zone'] != '') {
  427. $cond .= " AND zone LIKE '%" . escape_str($filter_arr['zone']) . "%' ";
  428. }
  429. //zm_name
  430. if (isset($filter_arr['zm_name']) && $filter_arr['zm_name'] != '') {
  431. $cond .= " AND zm_name LIKE '%" . escape_str($filter_arr['zm_name']) . "%' ";
  432. }
  433. //rm_name
  434. if (isset($filter_arr['rm_name']) && $filter_arr['rm_name'] != '') {
  435. $cond .= " AND rm_name LIKE '%" . escape_str($filter_arr['rm_name']) . "%' ";
  436. }
  437. //am_name
  438. if (isset($filter_arr['am_name']) && $filter_arr['am_name'] != '') {
  439. $cond .= " AND am_name LIKE '%" . escape_str($filter_arr['am_name']) . "%' ";
  440. }
  441. //zm_email
  442. if (isset($filter_arr['zm_email']) && $filter_arr['zm_email'] != '') {
  443. $cond .= " AND zm_email LIKE '%" . escape_str($filter_arr['zm_email']) . "%' ";
  444. }
  445. //rm_email
  446. if (isset($filter_arr['rm_email']) && $filter_arr['rm_email'] != '') {
  447. $cond .= " AND rm_email LIKE '%" . escape_str($filter_arr['rm_email']) . "%' ";
  448. }
  449. //am_email
  450. if (isset($filter_arr['am_email']) && $filter_arr['am_email'] != '') {
  451. $cond .= " AND am_email LIKE '%" . escape_str($filter_arr['am_email']) . "%' ";
  452. }
  453. //zm_mobile
  454. if (isset($filter_arr['zm_mobile']) && $filter_arr['zm_mobile'] != '') {
  455. $cond .= " AND zm_mobile LIKE '%" . escape_str($filter_arr['zm_mobile']) . "%' ";
  456. }
  457. //rm_mobile
  458. if (isset($filter_arr['rm_mobile']) && $filter_arr['rm_mobile'] != '') {
  459. $cond .= " AND rm_mobile LIKE '%" . escape_str($filter_arr['rm_mobile']) . "%' ";
  460. }
  461. //zm_mobile
  462. if (isset($filter_arr['am_mobile']) && $filter_arr['am_mobile'] != '') {
  463. $cond .= " AND am_mobile LIKE '%" . escape_str($filter_arr['am_mobile']) . "%' ";
  464. }
  465. }
  466. echo '<!DOCTYPE html><html>
  467. <head><meta charset="UTF-8"><h3>HYPER-M - DEALER DATA</h3></head><body>'
  468. . '<table border="1"><th>TOTAL COUNT</th></tr>';
  469. if ($query_group['nr']) {
  470. foreach ($query_group['result'] as $res) {
  471. echo '<tr><td>' . $res->ucount . '</td></tr>';
  472. }
  473. }
  474. echo '</table></br></br>'
  475. . '<table border="1"> ';
  476. $query_user = $parent->selectQuery(DMS_DEALER, " `dealer_code`, `dealer_name`,address,email,phone, `city`, `state`, `zone`, `zm_name`, `rm_name`, `am_name`, `zm_email`, `rm_email`, `am_email`, `zm_mobile`, `rm_mobile`, `am_mobile` ", "status='1' AND is_deleted=0" . $cond, "");
  477. if ($query_user['nr']) {
  478. $sno = 0;
  479. //$s3=awsfileserver::connectS3();
  480. foreach ($query_user['result'] as $res_user) {
  481. if ($sno == 0) {
  482. $arr = array_keys((array) $res_user);
  483. //print_r(array_keys($a)); exit;
  484. echo '<tr><th>#</th>';
  485. foreach ($arr as $head) {
  486. echo '<th>' . $head . '</td>';
  487. }
  488. echo '</tr>';
  489. $sno++;
  490. }
  491. echo '<tr><td>' . $sno++ . '</td>';
  492. foreach ($res_user as $val) {
  493. echo '<td>' . $val . '</td>';
  494. }
  495. echo '</tr>';
  496. }
  497. }
  498. echo '</table></body></html>';exit;
  499. }
  500. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  501. /* /////////////////////////////// dmssales //////////////////////////////////////////////// */
  502. private function dmssales($parent)
  503. {
  504. globalfunc::checkMethodType($parent, array('GET'));
  505. globalfunc::checkParamCount($parent, 1);
  506. $data_arr = array();
  507. $limit_str = globalfunc::setPageLimit($parent, $parent->params[0]);
  508. $limit_cond = ($limit_str) ? " LIMIT " . $limit_str : '';
  509. $cond = '';
  510. //print_r($parent->params);exit;
  511. $filter_arr = globalfunc::getFilterValues($parent, $parent->params[0]);
  512. //print_r( $filter_arr);
  513. if (isset($filter_arr['year']) && $filter_arr['year'] != '' && isset($filter_arr['month']) && $filter_arr['month'] != '') {
  514. $cond = " AND sale_date>='" . date('Y-m-d', strtotime($filter_arr['year'] . "-" . $filter_arr['month'] . "-01")) . "' AND sale_date<='" . date('Y-m-t', strtotime($filter_arr['year'] . "-" . $filter_arr['month'] . "-01")) . "'";
  515. }
  516. if (isset($filter_arr['model']) && $filter_arr['model'] != '') {
  517. $cond .= " AND model LIKE '%" . escape_str($filter_arr['model']) . "%'";
  518. }
  519. if (isset($filter_arr['smpin']) && $filter_arr['smpin'] != '') {
  520. $cond .= " AND smpin LIKE '%" . escape_str($filter_arr['smpin']) . "%'";
  521. }
  522. echo '<!DOCTYPE html><html>
  523. <head><meta charset="UTF-8"><h3>HYPER-M - DSE SALES DATA</h3></head><body>';
  524. echo '</table></br></br>'
  525. . '<table border="1"> ';
  526. $query_user = $parent->selectQuery(DMS_EMPLOYEE_SALES, " `smpin`, `model`, `sale_date`, `sales_count`, `created_on`, `modified_on` ", "1=1 " . $cond, "");
  527. if ($query_user['nr']) {
  528. $sno = 0;
  529. //$s3=awsfileserver::connectS3();
  530. foreach ($query_user['result'] as $res_user) {
  531. if ($sno == 0) {
  532. $arr = array_keys((array) $res_user);
  533. //print_r(array_keys($a)); exit;
  534. echo '<tr><th>#</th>';
  535. foreach ($arr as $head) {
  536. echo '<th>' . $head . '</td>';
  537. }
  538. echo '</tr>';
  539. $sno++;
  540. }
  541. echo '<tr><td>' . $sno++ . '</td>';
  542. foreach ($res_user as $val) {
  543. echo '<td>' . $val . '</td>';
  544. }
  545. echo '</tr>';
  546. }
  547. }
  548. echo '</table></body></html>';exit;
  549. }
  550. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  551. /* /////////////////////////////// dmstarget //////////////////////////////////////////////// */
  552. private function dmstarget($parent)
  553. {
  554. globalfunc::checkMethodType($parent, array('GET'));
  555. globalfunc::checkParamCount($parent, 1);
  556. $data_arr = array();
  557. $limit_str = globalfunc::setPageLimit($parent, $parent->params[0]);
  558. $limit_cond = ($limit_str) ? " LIMIT " . $limit_str : '';
  559. $cond = '';
  560. //print_r($parent->params);exit;
  561. $filter_arr = globalfunc::getFilterValues($parent, $parent->params[0]);
  562. //print_r( $filter_arr);
  563. if (isset($filter_arr['year']) && $filter_arr['year'] != '' && isset($filter_arr['month']) && $filter_arr['month'] != '') {
  564. $cond = " AND sale_month>='" . date('Y-m-d', strtotime($filter_arr['year'] . "-" . $filter_arr['month'] . "-01")) . "' AND sale_month<='" . date('Y-m-t', strtotime($filter_arr['year'] . "-" . $filter_arr['month'] . "-01")) . "'";
  565. }
  566. if (isset($filter_arr['model']) && $filter_arr['model'] != '') {
  567. $cond .= " AND model LIKE '%" . escape_str($filter_arr['model']) . "%'";
  568. }
  569. if (isset($filter_arr['smpin']) && $filter_arr['smpin'] != '') {
  570. $cond .= " AND smpin LIKE '%" . escape_str($filter_arr['smpin']) . "%'";
  571. }
  572. echo '<!DOCTYPE html><html>
  573. <head><meta charset="UTF-8"><h3>HYPER-M - DSE TARGET DATA</h3></head><body>';
  574. echo '</table></br></br>'
  575. . '<table border="1"> ';
  576. $query_user = $parent->selectQuery(TABLE_USER_SALETARGET, " `smpin`, `model`, `sale_month`, `target`, `created_on`, `modified_on` ", "1=1 " . $cond, "");
  577. if ($query_user['nr']) {
  578. $sno = 0;
  579. //$s3=awsfileserver::connectS3();
  580. foreach ($query_user['result'] as $res_user) {
  581. if ($sno == 0) {
  582. $arr = array_keys((array) $res_user);
  583. //print_r(array_keys($a)); exit;
  584. echo '<tr><th>#</th>';
  585. foreach ($arr as $head) {
  586. echo '<th>' . $head . '</td>';
  587. }
  588. echo '</tr>';
  589. $sno++;
  590. }
  591. echo '<tr><td>' . $sno++ . '</td>';
  592. foreach ($res_user as $val) {
  593. echo '<td>' . $val . '</td>';
  594. }
  595. echo '</tr>';
  596. }
  597. }
  598. echo '</table></body></html>';exit;
  599. }
  600. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  601. /* /////////////////////////////// dmsrewardpoints //////////////////////////////////////////////// */
  602. private function dmsrewardpoints($parent)
  603. {
  604. globalfunc::checkMethodType($parent, array('GET'));
  605. globalfunc::checkParamCount($parent, 1);
  606. $data_arr = array();
  607. $limit_str = globalfunc::setPageLimit($parent, $parent->params[0]);
  608. $limit_cond = ($limit_str) ? " LIMIT " . $limit_str : '';
  609. $cond = '';
  610. //FILTER
  611. $filter_arr = globalfunc::getFilterValues($parent, $parent->params[0]);
  612. if (count($filter_arr) > 0) {
  613. //smpin
  614. if (isset($filter_arr['smpin']) && $filter_arr['smpin'] != '') {
  615. $cond .= " AND u.smpin LIKE '%" . escape_str($filter_arr['smpin']) . "%' ";
  616. }
  617. //emp_code
  618. if (isset($filter_arr['emp_code']) && $filter_arr['emp_code'] != '') {
  619. $cond .= " AND u.emp_code LIKE '%" . escape_str($filter_arr['emp_code']) . "%' ";
  620. }
  621. //fname
  622. if (isset($filter_arr['fname']) && $filter_arr['fname'] != '') {
  623. $cond .= " AND u.fname LIKE '%" . escape_str($filter_arr['fname']) . "%' ";
  624. }
  625. //lname
  626. if (isset($filter_arr['lname']) && $filter_arr['lname'] != '') {
  627. $cond .= " AND u.lname LIKE '%" . escape_str($filter_arr['lname']) . "%' ";
  628. }
  629. //dealer_code
  630. if (isset($filter_arr['dealer_code']) && $filter_arr['dealer_code'] != '') {
  631. $cond .= " AND u.dealer_code LIKE '%" . escape_str($filter_arr['dealer_code']) . "%' ";
  632. }
  633. //role
  634. if (isset($filter_arr['role']) && $filter_arr['role'] != '') {
  635. $cond .= " AND u.role LIKE '%" . escape_str($filter_arr['role']) . "%' ";
  636. }
  637. //role
  638. if (isset($filter_arr['mobile']) && $filter_arr['mobile'] != '') {
  639. $cond .= " AND u.mobile LIKE '%" . escape_str($filter_arr['mobile']) . "%' ";
  640. }
  641. //city
  642. if (isset($filter_arr['city']) && $filter_arr['city'] != '') {
  643. $cond .= " AND d.city LIKE '%" . escape_str($filter_arr['city']) . "%' ";
  644. }
  645. //zone
  646. if (isset($filter_arr['zone']) && $filter_arr['zone'] != '') {
  647. $cond .= " AND d.zone LIKE '%" . escape_str($filter_arr['zone']) . "%' ";
  648. }
  649. }
  650. $query_group = $parent->selectQuery(DMS_EMPLOYEE, "COUNT(id) ucount ", "status=1", "");
  651. echo '<!DOCTYPE html><html>
  652. <head><meta charset="UTF-8"><h3>HYPER-M - EMPLOYEE MASTER DATA </h3></head><body>'
  653. . '<table border="1"><th>TOTAL COUNT</th></tr>';
  654. if ($query_group['nr']) {
  655. foreach ($query_group['result'] as $res) {
  656. echo '<tr><td>' . $res->ucount . '</td></tr>';
  657. }
  658. }
  659. echo '</table></br></br>'
  660. . '<table border="1"> ';
  661. $query_user = $parent->selectQuery(DMS_EMPLOYEE . " u JOIN " . TABLE_USER . " as user ON user.smpin=u.smpin AND user.role>7 AND user.role<14 LEFT JOIN " . DMS_DEALER . " d ON d.dealer_code=u.dealer_code LEFT JOIN " . TABLE_USER_EPOINTS . " p ON u.smpin=p.smpin", "u.`smpin`, u.`emp_code`, u.`fname`,u. `lname`,p.points, u.`dealer_code`,u. `role`, u.`emailid`, u.`mobile`,d.dealer_name,d.city,d.zone,u.created_on,u.modified_on", "u.status='1' " . $cond . " ORDER BY p.points DESC ", "");
  662. if ($query_user['nr']) {
  663. $sno = 0;
  664. //$s3=awsfileserver::connectS3();
  665. foreach ($query_user['result'] as $res_user) {
  666. if ($sno == 0) {
  667. $arr = array_keys((array) $res_user);
  668. //print_r(array_keys($a)); exit;
  669. echo '<tr><th>#</th>';
  670. foreach ($arr as $head) {
  671. echo '<th>' . $head . '</td>';
  672. }
  673. echo '</tr>';
  674. $sno++;
  675. }
  676. echo '<tr><td>' . $sno++ . '</td>';
  677. foreach ($res_user as $val) {
  678. echo '<td>' . $val . '</td>';
  679. }
  680. echo '</tr>';
  681. }
  682. }
  683. echo '</table></body></html>';exit;
  684. }
  685. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  686. /* /////////////////////////////// LAST ACCESS USER //////////////////////////////////////////////// */
  687. private function lastaccess($parent)
  688. {
  689. globalfunc::checkMethodType($parent, array('GET'));
  690. globalfunc::checkParamCount($parent, 1);
  691. $data_arr = array();
  692. $limit_str = globalfunc::setPageLimit($parent, $parent->params[0]);
  693. $limit_cond = ($limit_str) ? " LIMIT " . $limit_str : '';
  694. // $query_group=$parent->selectQuery(TABLE_USER." u JOIN ".TABLE_ROLE." r ON u.role=r.id LEFT JOIN ".DMS_DEALER." d ON d.dealer_code=u.dealer_code" ,"COUNT(u.userid) ucount , r.rolename ","u.is_deleted=0 AND u.role>7 AND u.role<14 GROUP BY u.role","");
  695. echo '<!DOCTYPE html><html>
  696. <head><meta charset="UTF-8"><h3>HYPER-M - REGISTERED USER LIST</h3></head><body>'
  697. . '<table border="1"><tr><th>#</th><th>ROLE</th><th>SMPIN</th><th>EMP CODE</th><th>NAME</th><th>DEALER CODE</th><th>DEALER</th><th>Zone</th><th>City</th><th>ZM</th><th>RM</th><th>AM</th><th>MOBILE</th><th>EMAIL</th><th>REGISTERED DATE</th><th>LAST ACCESS DATE</th></tr>';
  698. $query_user = $parent->selectQuery(TABLE_USER . " u LEFT JOIN " . TABLE_USER_LOG . " l ON u.userid=l.userid JOIN " . TABLE_ROLE . " r ON u.role=r.id LEFT JOIN " . DMS_DEALER . " d ON d.dealer_code=u.dealer_code", "u.smpin,u.emp_code,u.fname, u.`lname`, u.`emailid`, u.`mobileno`,u.created_on,r.rolename,u.dealer_code,d.dealer_name,d.city,d.zone,d.`zm_name`, d.`rm_name`, d.`am_name`,MAX(l.created_on) as last_access", "u.is_deleted=0 AND u.role>7 AND u.role<14 GROUP BY u.userid ORDER BY last_access DESC", "");
  699. if ($query_user['nr']) {
  700. $sno = 1;
  701. //$s3=awsfileserver::connectS3();
  702. foreach ($query_user['result'] as $res_user) {
  703. $dealer_code = ($res_user->dealer_code != '') ? $res_user->dealer_code : '';
  704. $dealer_data = ($res_user->dealer_code != '') ? $res_user->dealer_name : '';
  705. //,<br>'.$res_user->city.',<br>'.$res_user->zone
  706. $last_access = ($res_user->last_access) ? date('d-m-Y h:i A ', strtotime($res_user->last_access)) : '';
  707. echo '<tr><td>' . $sno++ . '</td><td>' . $res_user->rolename . '</td><td>' . $res_user->smpin . '</td><td>' . $res_user->emp_code . '</td><td>' . $res_user->fname . " " . $res_user->lname . '</td><td>' . $dealer_code . '</td><td>' . $dealer_data . '</td><td>' . $res_user->zone . '</td><td>' . $res_user->city . '</td><td>' . $res_user->zm_name . '</td><td>' . $res_user->rm_name . '</td><td>' . $res_user->am_name . '</td><td>' . $res_user->mobileno . '</td><td>' . $res_user->emailid . '</td><td>' . date('d-m-Y h:i A ', strtotime($res_user->created_on)) . '</td><td>' . $last_access . '</td></tr>';
  708. }
  709. }
  710. echo '</table></body></html>';exit;
  711. }
  712. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  713. /* /////////////////////////////// CUSTOMER EXPERIENCE //////////////////////////////////////////////// */
  714. private function customerexperience($parent)
  715. {
  716. globalfunc::checkMethodType($parent, array('GET'));
  717. globalfunc::checkParamCount($parent, 1);
  718. echo '<!DOCTYPE html><html>
  719. <head><meta charset="UTF-8"><h3>HYPER-M - CUSTOMER EXPERIENCE LIST</h3></head><body>'
  720. . '<table border="1">';
  721. // SELECT FROM tbl__user_customerexp cust LEFT JOIN tbl__ex_enquiry enq ON enq.customerid=cust.id LEFT JOIN tbl__ex_model vm ON vm.model_id=enq.model_id LEFT JOIN tbl__ex_modelvariant vv ON vv.model_id=enq.model_id INNER JOIN tbl__user usr ON usr.userid=cust.userid INNER JOIN tbl__dms_dealer dlr ON dlr.dealer_code=usr.dealer_code WHERE dlr.dealer_code='97105'
  722. $query_user = $parent->selectQuery(TABLE__CUSTOMEREXP . " cust LEFT JOIN " . TABLE_EXPLORE_ENQUIRY . " enq ON enq.customerid=cust.id LEFT JOIN " . TABLE_COMPARE_MODEL . " vm ON vm.model_id=enq.model_id LEFT JOIN " . TABLE_MODEL_VARIANT . " vv ON vv.model_id=enq.model_id INNER JOIN " . TABLE_USER . " usr ON usr.userid=cust.userid INNER JOIN " . DMS_DEALER . " dlr ON dlr.dealer_code=usr.dealer_code", "CONCAT(CONCAT(cust.salutation, ' ', cust.firstname), ' ', cust.lastname) customer_name, cust.mobile customer_mobile, cust.email customer_email, vm.model_name, vv.title varient, usr.dealer_code, dlr.dealer_name, dlr.am_name area_manager, dlr.rm_name regional_manager, dlr.zm_name zone_manager, cust.created_on customer_created, enq.created_on enquiry_on, IF(ISNULL(enq.created_on),'Not Done', 'DONE') enquiry_status ", "1=1 ORDER BY cust.created_on ASC", "");
  723. if ($query_user['nr']) {
  724. $sno = 1;
  725. //$s3=awsfileserver::connectS3();
  726. foreach ($query_user['result'] as $Key => $res_user) {
  727. if ($Key == 0) {
  728. echo "<tr><th>#</th>";
  729. foreach ($res_user as $key => $res) {
  730. echo "<th>" . $key . "</th>";
  731. }
  732. echo "</tr>";
  733. }
  734. echo "<tr><td>" . ($Key + 1) . "</td>";
  735. foreach ($res_user as $key => $res) {
  736. echo "<td>" . $res . "</td>";
  737. }
  738. echo "</tr>";
  739. }
  740. }
  741. echo '</table></body></html>';exit;
  742. }
  743. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  744. private function activesmpin($parent)
  745. {
  746. globalfunc::checkMethodType($parent, array('GET'));
  747. globalfunc::checkParamCount($parent, 2);
  748. $smpin = escape_str($parent->params[1]);
  749. //USER TABLE
  750. $query_arr = $parent->selectQuery(TABLE_USER . " u LEFT JOIN " . DMS_DEALER . " d ON d.dealer_code=u.dealer_code", "u.userid, u.`smpin`, u.`fname`, u.`lname`, u.`emailid`,u. `mobileno`,u.`dealer_code`, d.`dealer_name`, d.`city`, d.`state`, d.`zone`", "u.is_deleted=0 AND u.status!=1 AND u.role>7 AND role!=14 AND u.smpin='" . $smpin . "'", "1");
  751. if ($query_arr['nr'] > 0) {
  752. $updatequery = $parent->executeQuery("UPDATE " . TABLE_USER . " SET status='1' WHERE smpin='" . $smpin . "' AND userid='" . $query_arr['result'][0]->userid . "'");
  753. echo '<!DOCTYPE html><html>
  754. <head><meta charset="UTF-8"><h3>HYPER-M - USER DETAILS</h3></head><body> <h1>User data Activated</h1>'
  755. . '<table border="1">';
  756. foreach ($query_arr['result'] as $Key => $res_user) {
  757. if ($Key == 0) {
  758. echo "<tr><th>#</th>";
  759. foreach ($res_user as $key => $res) {
  760. echo "<th>" . $key . "</th>";
  761. }
  762. echo "</tr>";
  763. }
  764. echo "<tr><td>" . ($Key + 1) . "</td>";
  765. foreach ($res_user as $key => $res) {
  766. echo "<td>" . $res . "</td>";
  767. }
  768. echo "</tr>";
  769. }
  770. echo '</table></body></html>';exit;
  771. } else {
  772. //USER TABLE
  773. $query_arr = $parent->selectQuery(TABLE_USER . " u LEFT JOIN " . DMS_DEALER . " d ON d.dealer_code=u.dealer_code", "u.userid, u.`smpin`, u.`fname`, u.`lname`, u.`emailid`,u. `mobileno`,u.`dealer_code`, d.`dealer_name`, d.`city`, d.`state`, d.`zone`,u.is_deleted,u.status,u.inactivated_on,u.created_on,u.modified_on", " u.role>7 AND role!=14 AND u.smpin='" . $smpin . "'", "1");
  774. echo '<!DOCTYPE html><html>
  775. <head><meta charset="UTF-8"><h3>HYPER-M - USER DETAILS</h3></head><body>';
  776. echo "<h1>User not inactive please check database.</h1>";
  777. if ($query_arr['nr'] > 0) {
  778. echo "<h2>User table</h2><br>";
  779. echo '<table border="1">';
  780. foreach ($query_arr['result'] as $Key => $res_user) {
  781. if ($Key == 0) {
  782. echo "<tr><th>#</th>";
  783. foreach ($res_user as $key => $res) {
  784. echo "<th>" . $key . "</th>";
  785. }
  786. echo "</tr>";
  787. }
  788. echo "<tr><td>" . ($Key + 1) . "</td>";
  789. foreach ($res_user as $key => $res) {
  790. echo "<td>" . $res . "</td>";
  791. }
  792. echo "</tr>";
  793. }
  794. echo '</table>';
  795. } else {
  796. echo "<h2>User table data not found</h2><br>";
  797. }
  798. //EMPLOLYEE TABLE
  799. $query_arr = $parent->selectQuery(DMS_EMPLOYEE . " u LEFT JOIN " . DMS_DEALER . " d ON d.dealer_code=u.dealer_code", "u.*, d.`dealer_name`, d.`city`, d.`state`, d.`zone` ", " u.smpin='" . $smpin . "'", "1");
  800. if ($query_arr['nr'] > 0) {
  801. echo '<table border="1">';
  802. echo "<h2>Employee table </h2><br>";
  803. foreach ($query_arr['result'] as $Key => $res_user) {
  804. if ($Key == 0) {
  805. echo "<tr><th>#</th>";
  806. foreach ($res_user as $key => $res) {
  807. echo "<th>" . $key . "</th>";
  808. }
  809. echo "</tr>";
  810. }
  811. echo "<tr><td>" . ($Key + 1) . "</td>";
  812. foreach ($res_user as $key => $res) {
  813. echo "<td>" . $res . "</td>";
  814. }
  815. echo "</tr>";
  816. }
  817. echo '</table>';
  818. } else {
  819. echo "<h2>Emplolyee table data not found</h2><br>";
  820. }
  821. echo '</table></body></html>';exit;
  822. }
  823. }
  824. private function loginlog($parent)
  825. {
  826. globalfunc::checkMethodType($parent, array('GET'));
  827. $query_arr = $parent->selectQuery(TABLE_USER, "userid,CONCAT(fname,lname) as name,emp_code", " role=5 ", "");
  828. echo '<!DOCTYPE html><html>
  829. <head><meta charset="UTF-8"></head><body><h3>HYPER-M - LOGIN DETAILS</h3>';
  830. $month = "10";
  831. $year = "2019";
  832. $start_date = $year . "-" . $month . "-01";
  833. $start_time = strtotime($start_date);
  834. $end_time = strtotime("+1 month", $start_time);
  835. for ($i = $start_time; $i < $end_time; $i += 86400) {
  836. $list[] = date('Y-m-d', $i);
  837. }
  838. //print_r($list);
  839. echo '<table border="1"><tr><th>Name</th><th>EMP CODE</th>';
  840. foreach ($list as $res) {
  841. echo '<th>' . date('d-m-Y', strtotime($res)) . '</th>';
  842. }
  843. echo '</tr>';
  844. if ($query_arr['nr'] > 0) {
  845. foreach ($query_arr['result'] as $res_val) {
  846. echo '<tr><td>' . $res_val->name . '</td><td>' . $res_val->emp_code . '</td>';
  847. foreach ($list as $res) {
  848. $log_arr = $parent->selectQuery(TABLE_USER_LOG, "MAX(created_on)as tdate", " userid='" . $res_val->userid . "' AND date_format(created_on,'%Y-%m-%d')='" . $res . "'", "1");
  849. $date_str = ($log_arr['nr'] > 0 && $log_arr['result'][0]->tdate != '') ? date('h:i A', strtotime($log_arr['result'][0]->tdate)) : '';
  850. echo '<td>' . $date_str . '</td>';
  851. }
  852. echo '</tr>';
  853. }
  854. }
  855. echo '</table></body></html>';exit;
  856. }
  857. private function dealerenquiryinactive($parent)
  858. {
  859. globalfunc::checkParamCount($parent, 2);
  860. if (IS_LIVE_SERVER) {
  861. $parent->response(array('response' => 'failed', 'message' => 'PAGE NOT FOUND'), 404);
  862. }
  863. echo $dealer_code = escape_str($parent->params[1]);
  864. if ($dealer_code) {
  865. $parent->executeQuery(" UPDATE " . DMS_DEALER . " SET is_enquirymodule='0' WHERE dealer_code='" . $dealer_code . "'");
  866. }
  867. $parent->response(array('response' => 'success', 'message' => "SUCCESS"), 200);
  868. }
  869. }