| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <?php
- /****************************
- * File : report.php
- * Author : Cygnusa
- * @2018
- ****************************/
- //SECURITY
- if ( ! defined('APPLICATION_PATH')) exit('No direct script access allowed');
- //FUNCTION LISTS
- class report
- {
- function __construct($parent)
- {
- //GET PAGE MESSAGE
- $this->page_data=globalfunc::getMessage($parent,$parent->lang,'report');
- if(count($parent->params)==0)
- {
- //$this->assessmentfunc($parent);
-
- }else
- {
- $qry_params=explode ("?",$parent->params[0]);
- $parameter_val=strtolower($qry_params[0]);
-
- switch($parameter_val){
- case "registration":
- $this->$parameter_val($parent );
- break;
- default:
- $this->assessmentfunc($parent);
- break;
- }
- }
- $parent->response(array('response'=>'failed', 'message' => 'PAGE NOT FOUND'), 404);
- }
-
- /* /////////////////////////////// REGISTRATION //////////////////////////////////////////////// */
- private function registration($parent)
- {
- globalfunc::checkMethodType($parent,array('POST'));
- globalfunc::checkParamCount($parent,2);
- globalfunc::checkAuthrozation($parent,array('type'=>'user'));
-
- $qry_params=explode ("?",$parent->params[1]);
- $type=strtolower($qry_params[0]);
-
- $REQUEST_KEYS=array('from_date'=>'date|Y-m-d','to_date'=>'date|Y-m-d');
- globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
-
-
- $user_cond="";
- switch($type)
- {
- case "zm":
- if($parent->current_user_role=='3')
- {
- $REQUEST_KEYS=array('zmemail'=>'string');
- globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
- $emailid = escape_str($parent->_request["zmemail"]);
- if($emailid!='all')
- {
- $user_cond.=" AND u.dealer_code IN (SELECT dealer_code FROM ".DMS_DEALER." WHERE zm_email='". $emailid."')";
- }else
- {
- $user_cond.="";
- }
- }else
- {
- $parent->response(array('response'=>'failed', 'message'=>'Sorry No access'), 401);
- }
- break;
-
- case "rm":
- if($parent->current_user_role<'7')
- {
- if($parent->current_user_role=='5')
- {
- $REQUEST_KEYS=array('rmemail'=>'string');
- globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
- $emailid = escape_str($parent->_request["rmemail"]);
- if($emailid=='all')
- {
- $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";
- $trainer_arr=$parent->getQueryValue($get_trainer_str);
- $zone_cond.=(count($trainer_arr)>0)?" zone='".$trainer_arr[0]->zone."'":" zone='0'";
- $user_cond.=" AND u.dealer_code IN (SELECT dealer_code FROM ".DMS_DEALER." WHERE ".$zone_cond.")";
- }else
- {
- $user_cond.=" AND u.dealer_code IN (SELECT dealer_code FROM ".DMS_DEALER." WHERE rm_email='".$emailid."')";
- }
- }else
- {
- $REQUEST_KEYS=array('rmemail'=>'string');
- globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
- $emailid = escape_str($parent->_request["rmemail"]);
- if($emailid=='all')
- {
- $REQUEST_KEYS=array('zmemail'=>'string');
- globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
-
- $emailid = escape_str($parent->_request["zmemail"]);
- $user_cond.=" AND u.dealer_code IN (SELECT dealer_code FROM ".DMS_DEALER." WHERE zm_email='". $emailid."')";
- }else
- {
- $user_cond.=" AND u.dealer_code IN (SELECT dealer_code FROM ".DMS_DEALER." WHERE rm_email='".$emailid."')";
- }
- }
- }else
- {
- $parent->response(array('response'=>'failed', 'message'=>'Sorry No access'), 401);
- }
- break;
-
- case "am":
- if($parent->current_user_role=='14')
- {
- $dealer_code_cond=" dealer_code='".$parent->current_user_data->dealer_code."'";
- }else
- {
- $REQUEST_KEYS=array('amemail'=>'string');
- globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
- $emailid = escape_str($parent->_request["amemail"]);
- if($emailid=='all')
- {
- $REQUEST_KEYS=array('rmemail'=>'string');
- globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
- $emailid = escape_str($parent->_request["rmemail"]);
- $dealer_code_cond=" rm_email='".$emailid."'";
-
- }else
- {
- $dealer_code_cond=" am_email='".$emailid."'";
- }
- }
- $user_cond.=" AND u.dealer_code IN (SELECT dealer_code FROM ".DMS_DEALER." WHERE ".$dealer_code_cond.")";
- break;
- default: $parent->response(array('response'=>'failed', 'message'=>'Sorry No access'), 401); break;
- }
-
-
-
-
- $data_arr=array('label'=>range('A', 'Z'),'label_arr'=>range(100,126));
- $parent->response(array('response'=>'success','data'=>$data_arr, 'message'=>$this->page_data['success1'] ),200);
- }
- /* //////////////////////////////////////////////////////////////////////////////////////////// */
-
-
- }
- ?>
|