report.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /****************************
  3. * File : report.php
  4. * Author : Cygnusa
  5. * @2018
  6. ****************************/
  7. //SECURITY
  8. if ( ! defined('APPLICATION_PATH')) exit('No direct script access allowed');
  9. //FUNCTION LISTS
  10. class report
  11. {
  12. function __construct($parent)
  13. {
  14. //GET PAGE MESSAGE
  15. $this->page_data=globalfunc::getMessage($parent,$parent->lang,'report');
  16. if(count($parent->params)==0)
  17. {
  18. //$this->assessmentfunc($parent);
  19. }else
  20. {
  21. $qry_params=explode ("?",$parent->params[0]);
  22. $parameter_val=strtolower($qry_params[0]);
  23. switch($parameter_val){
  24. case "registration":
  25. $this->$parameter_val($parent );
  26. break;
  27. default:
  28. $this->assessmentfunc($parent);
  29. break;
  30. }
  31. }
  32. $parent->response(array('response'=>'failed', 'message' => 'PAGE NOT FOUND'), 404);
  33. }
  34. /* /////////////////////////////// REGISTRATION //////////////////////////////////////////////// */
  35. private function registration($parent)
  36. {
  37. globalfunc::checkMethodType($parent,array('POST'));
  38. globalfunc::checkParamCount($parent,2);
  39. globalfunc::checkAuthrozation($parent,array('type'=>'user'));
  40. $qry_params=explode ("?",$parent->params[1]);
  41. $type=strtolower($qry_params[0]);
  42. $REQUEST_KEYS=array('from_date'=>'date|Y-m-d','to_date'=>'date|Y-m-d');
  43. globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
  44. $user_cond="";
  45. switch($type)
  46. {
  47. case "zm":
  48. if($parent->current_user_role=='3')
  49. {
  50. $REQUEST_KEYS=array('zmemail'=>'string');
  51. globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
  52. $emailid = escape_str($parent->_request["zmemail"]);
  53. if($emailid!='all')
  54. {
  55. $user_cond.=" AND u.dealer_code IN (SELECT dealer_code FROM ".DMS_DEALER." WHERE zm_email='". $emailid."')";
  56. }else
  57. {
  58. $user_cond.="";
  59. }
  60. }else
  61. {
  62. $parent->response(array('response'=>'failed', 'message'=>'Sorry No access'), 401);
  63. }
  64. break;
  65. case "rm":
  66. if($parent->current_user_role<'7')
  67. {
  68. if($parent->current_user_role=='5')
  69. {
  70. $REQUEST_KEYS=array('rmemail'=>'string');
  71. globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
  72. $emailid = escape_str($parent->_request["rmemail"]);
  73. if($emailid=='all')
  74. {
  75. $get_trainer_str = "SELECT h.* FROM ".DMS_HOUSER." h JOIN ".TABLE_USER." u ON u.emp_code=h.emp_code WHERE u.userid='".$parent->current_user_id."' AND u.role='5' LIMIT 1";
  76. $trainer_arr=$parent->getQueryValue($get_trainer_str);
  77. $zone_cond.=(count($trainer_arr)>0)?" zone='".$trainer_arr[0]->zone."'":" zone='0'";
  78. $user_cond.=" AND u.dealer_code IN (SELECT dealer_code FROM ".DMS_DEALER." WHERE ".$zone_cond.")";
  79. }else
  80. {
  81. $user_cond.=" AND u.dealer_code IN (SELECT dealer_code FROM ".DMS_DEALER." WHERE rm_email='".$emailid."')";
  82. }
  83. }else
  84. {
  85. $REQUEST_KEYS=array('rmemail'=>'string');
  86. globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
  87. $emailid = escape_str($parent->_request["rmemail"]);
  88. if($emailid=='all')
  89. {
  90. $REQUEST_KEYS=array('zmemail'=>'string');
  91. globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
  92. $emailid = escape_str($parent->_request["zmemail"]);
  93. $user_cond.=" AND u.dealer_code IN (SELECT dealer_code FROM ".DMS_DEALER." WHERE zm_email='". $emailid."')";
  94. }else
  95. {
  96. $user_cond.=" AND u.dealer_code IN (SELECT dealer_code FROM ".DMS_DEALER." WHERE rm_email='".$emailid."')";
  97. }
  98. }
  99. }else
  100. {
  101. $parent->response(array('response'=>'failed', 'message'=>'Sorry No access'), 401);
  102. }
  103. break;
  104. case "am":
  105. if($parent->current_user_role=='14')
  106. {
  107. $dealer_code_cond=" dealer_code='".$parent->current_user_data->dealer_code."'";
  108. }else
  109. {
  110. $REQUEST_KEYS=array('amemail'=>'string');
  111. globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
  112. $emailid = escape_str($parent->_request["amemail"]);
  113. if($emailid=='all')
  114. {
  115. $REQUEST_KEYS=array('rmemail'=>'string');
  116. globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
  117. $emailid = escape_str($parent->_request["rmemail"]);
  118. $dealer_code_cond=" rm_email='".$emailid."'";
  119. }else
  120. {
  121. $dealer_code_cond=" am_email='".$emailid."'";
  122. }
  123. }
  124. $user_cond.=" AND u.dealer_code IN (SELECT dealer_code FROM ".DMS_DEALER." WHERE ".$dealer_code_cond.")";
  125. break;
  126. default: $parent->response(array('response'=>'failed', 'message'=>'Sorry No access'), 401); break;
  127. }
  128. $data_arr=array('label'=>range('A', 'Z'),'label_arr'=>range(100,126));
  129. $parent->response(array('response'=>'success','data'=>$data_arr, 'message'=>$this->page_data['success1'] ),200);
  130. }
  131. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  132. }
  133. ?>