explore.php 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298
  1. <?php
  2. /****************************
  3. * File : explore.php
  4. * Author : Cygnusa
  5. * @2018
  6. ****************************/
  7. //SECURITY
  8. if (!defined('APPLICATION_PATH')) {
  9. exit('No direct script access allowed');
  10. }
  11. //FUNCTION LISTS
  12. class explore
  13. {
  14. public function __construct($parent)
  15. {
  16. //GET PAGE MESSAGE
  17. $this->page_data = globalfunc::getMessage($parent, $parent->lang, 'explore');
  18. if (count($parent->params) == 0) {
  19. $parent->response(array('response' => 'failed', 'message' => 'PAGE NOT FOUND'), 404);
  20. } else {
  21. $qry_params = explode("?", $parent->params[0]);
  22. $parameter_val = strtolower($qry_params[0]);
  23. switch ($parameter_val) {
  24. case "model":
  25. case "images360":
  26. case "newimages360":
  27. case "comparison":
  28. case "salesprocess":
  29. case "variant":
  30. case "enquiry":
  31. case "customer":
  32. case "customerfeedback":
  33. case "customerenquiry":
  34. case "accessories_riders":
  35. case "accessories_bikes":
  36. case "smpindetails":
  37. case "contentlist":
  38. $this->$parameter_val($parent);
  39. break;
  40. }
  41. }
  42. $parent->response(array('response' => 'failed', 'message' => 'PAGE NOT FOUND'), 404);
  43. }
  44. // GET SMPIN Number of CE
  45. private function smpindetails($parent)
  46. {
  47. globalfunc::checkMethodType($parent, array('GET'));
  48. globalfunc::checkAuthrozation($parent, array('type' => 'user'));
  49. globalfunc::checkParamCount($parent, 1);
  50. $dealer_code = $parent->current_user_data->dealer_code;
  51. $query_userarr = $parent->selectQuery(TABLE_USER . " u JOIN " . DMS_EMPLOYEE . " as e ON e.smpin=u.smpin ", " u.`userid`,u.`smpin`,u.`emp_code`,u. `fname`,u. `lname` ", "u.is_deleted=0 AND u.status=1 AND u.dealer_code = '" . $dealer_code . "' AND u.role>7 AND u.role NOT IN (14,16,17) AND e.segment=1 ORDER BY u.created_on ASC", "");
  52. if (!$query_userarr['nr'] > 0) {
  53. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error1"]), 406);
  54. }
  55. $parent->response(array('response' => 'success', 'data' => $query_userarr['result'], 'message' => $this->page_data['success1']), 200);
  56. }
  57. //GET MODEL ALL MODEL EXLPORE FRONT PAGE
  58. private function model($parent)
  59. {
  60. globalfunc::checkMethodType($parent, array('GET'));
  61. globalfunc::checkAuthrozation($parent, array('type' => 'explore'));
  62. $cond = '';
  63. //ROLE WISE CONDITION
  64. switch ($parent->current_user_role) {
  65. case '0':
  66. case 'guest':
  67. $cond = " AND model_type='" . $parent->exp_model_type . "'";
  68. break;
  69. case '15':
  70. $cond = " AND model_type='1'";
  71. break;
  72. case '16':
  73. $cond = " AND model_type='0' AND is_experience=1 ";
  74. break;
  75. case '17':
  76. $cond = " AND is_experience=1 ";
  77. break;
  78. default:
  79. $cond = " AND model_type='0'";
  80. break;
  81. }
  82. if (count($parent->params) != 1) {
  83. globalfunc::checkParamCount($parent, 2);
  84. $model_id = escape_str($parent->params['1']);
  85. $cond .= " AND model_id='" . $model_id . "'";
  86. } else {
  87. globalfunc::checkParamCount($parent, 1);
  88. $filter_arr = globalfunc::getFilterValues($parent, $parent->params[0]);
  89. if (isset($filter_arr) && isset($filter_arr['model'])) {
  90. $model_type = escape_str($filter_arr['model']);
  91. switch ($filter_arr['model']) {
  92. case 'big':
  93. $cond .= " AND model_type='1'";
  94. break;
  95. case 'normal':
  96. $cond .= " AND model_type='0'";
  97. break;
  98. default:
  99. $cond .= " AND model_type='0'";
  100. break;
  101. }
  102. $cond .= '';
  103. }
  104. }
  105. $append_url = SITE_URL . "explore_assets/model/" . strtolower($parent->device_type) . "/";
  106. $brochure_url = SITE_URL . "explore_assets/model/";
  107. $query_modelarr = $parent->selectQuery(TABLE_COMPARE_MODEL, " `model_id`,`title`,`description`, `model_name`, CASE WHEN model_image!='' THEN CONCAT('" . $append_url . "',model_image) ELSE '" . NOIMAGE_URL . "' END AS 'model_image_url', CASE WHEN model_brochure!='' THEN CONCAT('" . $brochure_url . "',model_brochure) ELSE '' END AS 'model_brochure',CASE WHEN model_banner_image!='' THEN CONCAT('" . $append_url . "',model_banner_image) ELSE '" . NOIMAGE_URL . "' END AS 'model_banner_image_url' , CASE WHEN model_brochure_image!='' THEN CONCAT('" . $append_url . "',model_brochure_image) ELSE '" . NOIMAGE_URL . "' END AS 'model_brochure_image_url' ", "is_deleted=0 AND is_other=0 " . $cond . " ORDER BY position ASC,model_id ASC", "");
  108. if (!$query_modelarr['nr'] > 0) {
  109. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error1"]), 406);
  110. }
  111. //LOG
  112. $logstr = 'EXPLORE MODEL';
  113. globalfunc::insertUserLog($parent, $logstr);
  114. if (count($parent->params) == 1) {
  115. $parent->response(array('response' => 'success', 'data' => $query_modelarr['result'], 'message' => $this->page_data['success1']), 200);
  116. } else {
  117. $parent->response(array('response' => 'success', 'data' => $query_modelarr['result'][0], 'message' => $this->page_data['success1']), 200);
  118. }
  119. }
  120. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  121. //GET 360 IMAGES AND ZIP OF MODEL
  122. private function images360($parent)
  123. {
  124. globalfunc::checkMethodType($parent, array('GET'));
  125. globalfunc::checkParamCount($parent, 2);
  126. globalfunc::checkAuthrozation($parent, array('type' => 'explore'));
  127. $model_id = escape_str($parent->params['1']);
  128. //COMPARE MODEL
  129. $query_modelarr = $parent->selectQuery(TABLE_COMPARE_MODEL, "*", "model_id='" . $model_id . "' AND is_other=0", "1");
  130. if (!$query_modelarr['nr'] > 0) {
  131. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error1"]), 406);
  132. }
  133. //ASSETS VERSION
  134. $query_verarr = $parent->selectQuery(TABLE_MODEL_360ASSETS_VERSION, "*", "model_id='" . $model_id . "' ORDER BY file_version DESC", "1");
  135. if (!$query_verarr['nr'] > 0) {
  136. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error2"]), 406);
  137. }
  138. if (!file_exists('../../explore_assets/360/' . $model_id . '/')) {
  139. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error2"]), 406);
  140. }
  141. $append_url = SITE_URL . "explore_assets/360/" . $model_id . '/';
  142. $version = $query_verarr['result'][0]->file_version;
  143. // GET 360 MODEL
  144. $query_filearr = $parent->selectQuery(TABLE_MODEL_360IMAGE, "*,CASE WHEN image!='' THEN CONCAT('" . $append_url . "',image) ELSE '" . NOIMAGE_URL . "' END AS 'image_url' ", "model_id='" . $model_id . "' AND is_deleted=0 ORDER BY position ASC", "");
  145. if (file_exists('../../explore_assets/360/' . $model_id . '/' . $version . '.zip')) {
  146. //FILE ALREDY EXIST;
  147. if ($query_filearr['nr'] > 0) {
  148. $path_arr = @explode('services\_api', APPLICATION_PATH);
  149. $path_arr[0] = str_replace('\\', '/', realpath($path_arr[0]));
  150. $root_path = $path_arr[0];
  151. foreach ($query_filearr['result'] as $key => $res_val) {
  152. //GET POINTS
  153. $query_hotspotarr = $parent->selectQuery(TABLE_MODEL_360IMAGE_HOTSPOT . " h LEFT JOIN " . TABLE_HOTSPOT_CONTENT . " c ON h.contentid=c.id", "h.*,c.`title`, c.`description`, c.`file`,CASE WHEN c.`file`!='' THEN CONCAT('" . SITE_URL . "explore_assets/content/',c.`file`) ELSE '' END AS file_url , c.`file_type`,CASE WHEN (c.`file_type` IN (2) ) THEN CONCAT('" . SITE_URL . "explore_assets/content/',c.`thumb_image`) ELSE CONCAT('" . SITE_URL . "explore_assets/content/',c.`file`) END AS thumb_image_url", "h.image_id='" . $res_val->id . "' AND h.is_deleted=0", "");
  154. $query_filearr['result'][$key]->hotspot = array();
  155. if ($query_hotspotarr['nr'] > 0) {
  156. foreach ($query_hotspotarr['result'] as $m => $res_p) {
  157. $query_hotspotarr['result'][$m]->point_arr = json_decode($res_p->pointvalue);
  158. }
  159. $query_filearr['result'][$key]->hotspot = $query_hotspotarr['result'];
  160. }
  161. }
  162. } else {
  163. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error2"]), 406);
  164. }
  165. } else {
  166. $file_arr = array();
  167. $missingfile_arr = array();
  168. if ($query_filearr['nr'] > 0) {
  169. // print_r(APPLICATION_PATH);
  170. $path_arr = @explode('services' . DIRECTORY_SEPARATOR . '_api', APPLICATION_PATH);
  171. // print_r($path_arr);
  172. $path_arr[0] = str_replace('\\', '/', realpath($path_arr[0]));
  173. $root_path = $path_arr[0];
  174. foreach ($query_filearr['result'] as $key => $res_val) {
  175. if (file_exists('../../explore_assets/360/' . $model_id . '/' . $res_val->image)) {
  176. $file_arr[] = $root_path . '/explore_assets/360/' . $model_id . '/' . $res_val->image;
  177. } else {
  178. $missingfile_arr[] = 'explore_assets/360/' . $model_id . '/' . $res_val->image;
  179. }
  180. //GET POINTS
  181. $query_hotspotarr = $parent->selectQuery(TABLE_MODEL_360IMAGE_HOTSPOT . " h LEFT JOIN " . TABLE_HOTSPOT_CONTENT . " c ON h.contentid=c.id", "h.*,c.`title`, c.`description`, c.`file`,CASE WHEN c.`file`!='' THEN CONCAT('" . SITE_URL . "explore_assets/content/',c.`file`) ELSE '' END AS file_url ,CASE WHEN (c.`file_type` IN (2) ) THEN CONCAT('" . SITE_URL . "explore_assets/content/',c.`thumb_image`) ELSE CONCAT('" . SITE_URL . "explore_assets/content/',c.`file`) END AS thumb_image_url, c.`file_type`", "h.image_id='" . $res_val->id . "' AND h.is_deleted=0", "");
  182. $query_filearr['result'][$key]->hotspot = array();
  183. if ($query_hotspotarr['nr'] > 0) {
  184. foreach ($query_hotspotarr['result'] as $m => $res_p) {
  185. $query_hotspotarr['result'][$m]->point_arr = json_decode($res_p->pointvalue);
  186. }
  187. $query_filearr['result'][$key]->hotspot = $query_hotspotarr['result'];
  188. }
  189. }
  190. if (count($missingfile_arr) > 0) {
  191. $parent->response(array('response' => 'failed', 'data' => $missingfile_arr, 'message' => $this->page_data["error2"]), 406);
  192. }
  193. $returnzip = $this->zipFile($parent, '../../explore_assets/360/' . $model_id . '/', '../../explore_assets/360/' . $model_id . '/' . $version . '.zip', true, $version, $file_arr);
  194. } else {
  195. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error2"]), 406);
  196. }
  197. }
  198. //LOG
  199. $logstr = 'EXPLORE 360MODEL';
  200. globalfunc::insertUserLog($parent, $logstr);
  201. $data_arr = array('version' => $query_verarr['result'][0]->file_version, 'zip' => SITE_URL . 'explore_assets/360/' . $model_id . '/' . $version . '.zip', 'imagelist' => $query_filearr['result']);
  202. $parent->response(array('response' => 'success', 'data' => $data_arr, 'message' => $this->page_data['success1']), 200);
  203. }
  204. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  205. //ZIP FILE GENERATE
  206. private function zipFile($parent, $source, $destination, $flag = '', $version, $file_arr)
  207. {
  208. if (!extension_loaded('zip') || !file_exists($source)) {
  209. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error2"]), 406);
  210. }
  211. $zip = new ZipArchive();
  212. if (!$zip->open($destination, ZIPARCHIVE::CREATE)) {
  213. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error2"]), 406);
  214. }
  215. $source = str_replace('\\', '/', realpath($source));
  216. if (is_dir($source) === true) {
  217. $i = 0;
  218. $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
  219. //print_r($file_arr);
  220. foreach ($files as $file) {
  221. $file = str_replace('\\', '/', realpath($file));
  222. //echo $file;
  223. // print_r($file);
  224. // print_r($file_arr);
  225. if (in_array($file, $file_arr)) {
  226. // echo $file;
  227. if (is_dir($file) === true) {
  228. //$zip->addEmptyDir(str_replace($source . '/', '', $flag.$file . '/'));
  229. } else if (is_file($file) === true) {
  230. $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
  231. }
  232. }
  233. $i++;
  234. }
  235. } else if (is_file($source) === true) {
  236. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error2"], "type" => "1"), 406);
  237. } else {
  238. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error2"], "type" => "2"), 406);
  239. }
  240. $zip->close();
  241. chmod($destination, 0777);
  242. return $destination;
  243. }
  244. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  245. //GET NEW 360 IMAGES AND ZIP OF MODEL
  246. private function newimages360($parent)
  247. {
  248. globalfunc::checkMethodType($parent, array('GET'));
  249. globalfunc::checkParamCount($parent, 2);
  250. globalfunc::checkAuthrozation($parent, array('type' => 'explore'));
  251. $model_id = escape_str($parent->params['1']);
  252. //COMPARE MODEL
  253. $query_modelarr = $parent->selectQuery(TABLE_COMPARE_MODEL, "*", "model_id='" . $model_id . "' AND is_other=0", "1");
  254. if (!$query_modelarr['nr'] > 0) {
  255. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error1"]), 406);
  256. }
  257. //COMPARE MODEL VARIANT
  258. $query_model_variantarr = $parent->selectQuery(TABLE_MODEL_360VARIANT, "*", "model_id='" . $model_id . "' ", "");
  259. if (!$query_model_variantarr['nr'] > 0) {
  260. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error4"]), 406);
  261. }
  262. //VARAIANT LOOP
  263. foreach ($query_model_variantarr['result'] as $res_var) {
  264. $variant_id = $res_var->id;
  265. //ASSETS VERSION
  266. $query_verarr = $parent->selectQuery(TABLE_MODEL_360ASSETS_VERSION, "*", "model_id='" . $model_id . "' AND variant_id='" . $variant_id . "' ORDER BY file_version DESC", "1");
  267. if (!$query_verarr['nr'] > 0) {
  268. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error2"], "type" => "3"), 406);
  269. }
  270. if (!file_exists('../../explore_assets/360/' . $model_id . '/' . $variant_id . '/')) {
  271. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error2"], "type" => "4"), 406);
  272. } else {
  273. chmod('../../explore_assets/360/' . $model_id . '/' . $variant_id . '/', 0777);
  274. }
  275. }
  276. $path_arr = @explode('services' . DIRECTORY_SEPARATOR . '_api', APPLICATION_PATH);
  277. $path_arr[0] = str_replace('\\', '/', realpath($path_arr[0]));
  278. $root_path = $path_arr[0];
  279. foreach ($query_model_variantarr['result'] as $vkey => $res_var) {
  280. $variant_id = $res_var->id;
  281. $append_url = SITE_URL . "explore_assets/360/" . $model_id . '/' . $variant_id . '/';
  282. $version = $query_verarr['result'][0]->file_version;
  283. // GET 360 MODEL
  284. $query_filearr = $parent->selectQuery(TABLE_MODEL_360IMAGE, "*,CASE WHEN image!='' THEN CONCAT('" . $append_url . "',image) ELSE '" . NOIMAGE_URL . "' END AS 'image_url' ", "model_id='" . $model_id . "' AND variant_id='" . $variant_id . "' AND is_deleted=0 ORDER BY position ASC", "");
  285. if (file_exists('../../explore_assets/360/' . $model_id . '/' . $variant_id . '/' . $version . '.zip')) {
  286. //FILE ALREDY EXIST;
  287. if ($query_filearr['nr'] > 0) {
  288. //$path_arr=@explode('services\_api',APPLICATION_PATH);
  289. //$path_arr[0] = str_replace('\\', '/', realpath($path_arr[0]));
  290. //$root_path=$path_arr[0];
  291. foreach ($query_filearr['result'] as $key => $res_val) {
  292. //GET POINTS
  293. $query_hotspotarr = $parent->selectQuery(TABLE_MODEL_360IMAGE_HOTSPOT . " h LEFT JOIN " . TABLE_HOTSPOT_CONTENT . " c ON h.contentid=c.id", "h.*,c.`title`, c.`description`, c.`file`,CASE WHEN c.`file`!='' THEN CONCAT('" . SITE_URL . "explore_assets/content/',c.`file`) ELSE '' END AS file_url , c.`file_type`,CASE WHEN (c.`file_type` IN (2) ) THEN CONCAT('" . SITE_URL . "explore_assets/content/',c.`thumb_image`) ELSE CONCAT('" . SITE_URL . "explore_assets/content/',c.`file`) END AS thumb_image_url", "h.image_id='" . $res_val->id . "' AND h.is_deleted=0", "");
  294. $query_filearr['result'][$key]->hotspot = array();
  295. if ($query_hotspotarr['nr'] > 0) {
  296. foreach ($query_hotspotarr['result'] as $m => $res_p) {
  297. $query_hotspotarr['result'][$m]->point_arr = json_decode($res_p->pointvalue);
  298. }
  299. $query_filearr['result'][$key]->hotspot = $query_hotspotarr['result'];
  300. }
  301. }
  302. } else {
  303. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error2"], "type" => "5"), 406);
  304. }
  305. } else {
  306. $file_arr = array();
  307. $missingfile_arr = array();
  308. if ($query_filearr['nr'] > 0) {
  309. // print_r(APPLICATION_PATH);
  310. foreach ($query_filearr['result'] as $key => $res_val) {
  311. if (file_exists('../../explore_assets/360/' . $model_id . '/' . $variant_id . '/' . $res_val->image)) {
  312. $file_arr[] = $root_path . '/explore_assets/360/' . $model_id . '/' . $variant_id . '/' . $res_val->image;
  313. } else {
  314. $missingfile_arr[] = 'explore_assets/360/' . $model_id . '/' . $variant_id . '/' . $res_val->image;
  315. }
  316. //GET POINTS
  317. $query_hotspotarr = $parent->selectQuery(TABLE_MODEL_360IMAGE_HOTSPOT . " h LEFT JOIN " . TABLE_HOTSPOT_CONTENT . " c ON h.contentid=c.id", "h.*,c.`title`, c.`description`, c.`file`,CASE WHEN c.`file`!='' THEN CONCAT('" . SITE_URL . "explore_assets/content/',c.`file`) ELSE '' END AS file_url ,CASE WHEN (c.`file_type` IN (2) ) THEN CONCAT('" . SITE_URL . "explore_assets/content/',c.`thumb_image`) ELSE CONCAT('" . SITE_URL . "explore_assets/content/',c.`file`) END AS thumb_image_url, c.`file_type`", "h.image_id='" . $res_val->id . "' AND h.is_deleted=0", "");
  318. $query_filearr['result'][$key]->hotspot = array();
  319. if ($query_hotspotarr['nr'] > 0) {
  320. foreach ($query_hotspotarr['result'] as $m => $res_p) {
  321. $query_hotspotarr['result'][$m]->point_arr = json_decode($res_p->pointvalue);
  322. }
  323. $query_filearr['result'][$key]->hotspot = $query_hotspotarr['result'];
  324. }
  325. }
  326. if (count($missingfile_arr) > 0) {
  327. $parent->response(array('response' => 'failed', 'data' => $missingfile_arr, 'message' => $this->page_data["error2"], "type" => "6"), 406);
  328. }
  329. $returnzip = $this->zipFile($parent, '../../explore_assets/360/' . $model_id . '/' . $variant_id . '/', '../../explore_assets/360/' . $model_id . '/' . $variant_id . '/' . $version . '.zip', true, $version, $file_arr);
  330. } else {
  331. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error2"], "type" => "7"), 406);
  332. }
  333. }
  334. $query_model_variantarr['result'][$vkey]->version = $version;
  335. $query_model_variantarr['result'][$vkey]->zip = SITE_URL . 'explore_assets/360/' . $model_id . '/' . $variant_id . '/' . $version . '.zip';
  336. $query_model_variantarr['result'][$vkey]->imagelist = $query_filearr['result'];
  337. }
  338. //LOG
  339. $logstr = 'EXPLORE 360MODEL';
  340. globalfunc::insertUserLog($parent, $logstr);
  341. //$data_arr= array('version'=>$query_verarr['result'][0]->file_version,'zip'=>SITE_URL.'explore_assets/360/'.$model_id.'/'.$version.'.zip','imagelist'=>$query_filearr['result']);
  342. $parent->response(array('response' => 'success', 'data' => $query_model_variantarr['result'], 'message' => $this->page_data['success1']), 200);
  343. }
  344. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  345. //MODEL COMPARISON
  346. private function comparison($parent)
  347. {
  348. globalfunc::checkMethodType($parent, array('GET'));
  349. globalfunc::checkParamCount($parent, 2);
  350. globalfunc::checkAuthrozation($parent, array('type' => 'explore'));
  351. $append_url = SITE_URL . "explore_assets/model/web/"; // DUE IMAGE CONFILCT IN Comparison
  352. $model_id = escape_str($parent->params['1']);
  353. //GET MODEL
  354. $query_modelarr = $parent->selectQuery(TABLE_COMPARE_MODEL, " `model_id`,`title`,`description`, `model_name`, CASE WHEN model_image!='' THEN CONCAT('" . $append_url . "',model_image) ELSE '" . NOIMAGE_URL . "' END AS 'model_image_url' ", "model_id='" . $model_id . "' AND is_other=0 ", "1");
  355. if (!$query_modelarr['nr'] > 0) {
  356. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error1"]), 406);
  357. }
  358. if ($parent->current_user_role == 0 && $parent->current_user_id == 'guest') {
  359. $cond = " AND model_type='" . $parent->exp_model_type . "'";
  360. } else {
  361. //GET COMPARE CATEGORY
  362. $cond = ($parent->current_user_role == '15') ? " AND model_type='1'" : " AND model_type='0'";
  363. }
  364. $append_url = SITE_URL . "explore_assets/model/" . strtolower($parent->device_type) . "/";
  365. $cat_id_arr = array();
  366. $query_catgrouparr = $parent->selectQuery(TABLE_COMPARE_FIELDS, "cat_id", "is_deleted='0' AND id IN (SELECT field_id FROM " . TABLE_COMPARE_VALUE . " WHERE model_id='" . $model_id . "' ) GROUP BY cat_id", "");
  367. if ($query_catgrouparr['nr'] > 0) {
  368. foreach ($query_catgrouparr['result'] as $res) {
  369. $cat_id_arr[] = $res->cat_id;
  370. }
  371. $cond .= " AND id in (" . @implode(",", $cat_id_arr) . ")";
  372. }
  373. $query_catarr = $parent->selectQuery(TABLE_COMPARE_CATEGORY, "id,cat_title as title", "is_deleted='0' " . $cond . " ORDER BY cat_pos,id ASC", "");
  374. $check_arr = array();
  375. $category_arr = array();
  376. if ($query_catarr['nr'] > 0) {
  377. foreach ($query_catarr['result'] as $m => $res_cat) {
  378. //COMPARE FIELDS
  379. $query_fieldarr = $parent->selectQuery(TABLE_COMPARE_FIELDS, "id,title", "is_deleted='0' AND cat_id='" . $res_cat->id . "' AND id IN (SELECT field_id FROM " . TABLE_COMPARE_VALUE . " WHERE model_id='" . $model_id . "' ) ORDER BY position,id ASC", "");
  380. if ($query_fieldarr['nr'] > 0) {
  381. foreach ($query_fieldarr['result'] as $n => $res_field) {
  382. //COMPARE VALUE
  383. $query_fieldvaluearr = $parent->selectQuery(TABLE_COMPARE_VALUE, "cvalue", "is_deleted='0' AND field_id='" . $res_field->id . "' AND model_id='" . $model_id . "'", "1");
  384. $query_fieldarr['result'][$n]->value = ($query_fieldvaluearr['nr']) ? $query_fieldvaluearr['result'][0]->cvalue : "";
  385. $check_arr[$res_field->id] = $query_fieldarr['result'][$n]->value;
  386. }
  387. }
  388. $query_catarr['result'][$m]->fields = ($query_fieldarr['nr'] > 0) ? $query_fieldarr['result'] : array();
  389. $category_arr[] = (array) $query_catarr['result'][$m];
  390. }
  391. // $category_arr=$query_catarr['result'];
  392. }
  393. //COMPARE MODEL
  394. $compare_model_arr = array();
  395. $query_othmodelarr = $parent->selectQuery(TABLE_COMPARE_MODEL, " `model_id`,`title`,`description`, `model_name`, CASE WHEN model_image!='' THEN CONCAT('" . $append_url . "',model_image) ELSE '" . NOIMAGE_URL . "' END AS 'model_image_url' ", " is_other='1' AND FIND_IN_SET('" . $model_id . "',compare_model) AND is_deleted='0' ORDER BY position ASC,model_id ASC ", "");
  396. if ($query_othmodelarr['nr'] > 0) {
  397. foreach ($query_othmodelarr['result'] as $val => $res_oth) {
  398. $comp_check_arr = array();
  399. //CATEGORY
  400. $comp_category_arr = array();
  401. if ($query_catarr['nr'] > 0) {
  402. foreach ($query_catarr['result'] as $m => $res_cat) {
  403. //COMPARE FIELDS
  404. $query_fieldarr = $parent->selectQuery(TABLE_COMPARE_FIELDS, "id,title", "is_deleted='0' AND cat_id='" . $res_cat->id . "' AND id IN (SELECT field_id FROM " . TABLE_COMPARE_VALUE . " WHERE model_id='" . $model_id . "' ) ORDER BY position,id ASC", "");
  405. if ($query_fieldarr['nr'] > 0) {
  406. foreach ($query_fieldarr['result'] as $n => $res_field) {
  407. $query_fieldarr['result'][$n]->is_equal = 0;
  408. // echo "is_deleted='0' AND field_id='".$res_field->id."' AND model_id='".$res_oth->model_id."'";
  409. $query_fieldvaluearr = $parent->selectQuery(TABLE_COMPARE_VALUE, "cvalue", "is_deleted='0' AND field_id='" . $res_field->id . "' AND model_id='" . $res_oth->model_id . "' ", "1");
  410. $query_fieldarr['result'][$n]->value = ($query_fieldvaluearr['nr']) ? $query_fieldvaluearr['result'][0]->cvalue : "";
  411. $comp_check_arr[$res_field->id] = $query_fieldarr['result'][$n]->value;
  412. $query_fieldarr['result'][$n]->is_equal = (isset($check_arr[$res_field->id]) && trim($check_arr[$res_field->id]) == ($comp_check_arr[$res_field->id])) ? "1" : "0";
  413. }
  414. }
  415. $query_catarr['result'][$m]->fields = ($query_fieldarr['nr'] > 0) ? $query_fieldarr['result'] : array();
  416. $comp_category_arr[] = (array) $query_catarr['result'][$m];
  417. }
  418. }
  419. $compare_model_arr[] = array('model' => $res_oth, 'category' => $comp_category_arr);
  420. }
  421. }
  422. //LOG
  423. $logstr = 'EXPLORE COMPARISON';
  424. globalfunc::insertUserLog($parent, $logstr);
  425. //print_r($category_arr);
  426. $data_arr = array('model' => $query_modelarr['result'][0], 'category' => $category_arr, 'compare_model' => $compare_model_arr);
  427. $parent->response(array('response' => 'success', 'data' => $data_arr, 'message' => $this->page_data['success1']), 200);
  428. }
  429. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  430. //MODELS SALES PROCESS
  431. private function salesprocess($parent)
  432. {
  433. globalfunc::checkMethodType($parent, array('GET'));
  434. globalfunc::checkParamCount($parent, 2);
  435. globalfunc::checkAuthrozation($parent, array('type' => 'explore'));
  436. $model_id = escape_str($parent->params['1']);
  437. //CHECK MODEL
  438. $query_modelarr = $parent->selectQuery(TABLE_COMPARE_MODEL, " `model_id` ", "model_id='" . $model_id . "' AND is_other=0 ", "1");
  439. if (!$query_modelarr['nr'] > 0) {
  440. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error1"]), 406);
  441. }
  442. //GET MASTER VIEW TYPE
  443. $query_typearr = $parent->selectQuery(TABLE_IMAGE_VIEW_TYPE, "id,title", "is_deleted='0' AND id IN (SELECT view_id FROM " . TABLE_MODEL_IMAGE_VIEW . " WHERE model_id='" . $model_id . "') ORDER BY position,id ASC ", "");
  444. $append_url = SITE_URL . "explore_assets/sales/";
  445. $data_arr = array();
  446. if ($query_typearr['nr'] > 0) {
  447. foreach ($query_typearr['result'] as $m => $res_type) {
  448. //GET MASTER VIEW TYPE IMAGES
  449. $query_typearr['result'][$m]->image = new stdClass();
  450. $query_model_imagearr = $parent->selectQuery(TABLE_MODEL_IMAGE_VIEW, "*,CASE WHEN image!='' THEN CONCAT('" . $append_url . "',image) ELSE '" . NOIMAGE_URL . "' END AS 'image_url'", "is_deleted=0 AND model_id='" . $model_id . "' AND view_id='" . $res_type->id . "'", "1");
  451. if ($query_model_imagearr['nr'] > 0) {
  452. foreach ($query_model_imagearr['result'] as $n => $res_model) {
  453. $query_model_imagearr['result'][$n]->hotspot = array();
  454. //HOTSPOT IMAGES AND CONTENT
  455. $query_hotspotarr = $parent->selectQuery(TABLE_MODEL_VIEW_HOTSPOT . " h LEFT JOIN " . TABLE_HOTSPOT_CONTENT . " c ON h.contentid=c.id", "h.*,c.`title`, c.`description`, c.`file`,CASE WHEN c.`file`!='' THEN CONCAT('" . SITE_URL . "explore_assets/content/',c.`file`) ELSE '' END AS file_url ,CASE WHEN (c.`file_type` IN (2) ) THEN CONCAT('" . SITE_URL . "explore_assets/content/',c.`thumb_image`) ELSE CONCAT('" . SITE_URL . "explore_assets/content/',c.`file`) END AS thumb_image_url, c.`file_type`", "h.view_id='" . $res_model->id . "' AND h.is_deleted=0", "");
  456. if ($query_hotspotarr['nr'] > 0) {
  457. foreach ($query_hotspotarr['result'] as $k => $res_p) {
  458. $query_hotspotarr['result'][$k]->point_arr = json_decode($res_p->pointvalue);
  459. }
  460. $query_model_imagearr['result'][$n]->hotspot = $query_hotspotarr['result'];
  461. }
  462. }
  463. $query_typearr['result'][$m]->image = (array) $query_model_imagearr['result'][0];
  464. }
  465. }
  466. $data_arr = $query_typearr['result'];
  467. }
  468. //LOG
  469. $logstr = 'EXPLORE SALEPROCESS';
  470. globalfunc::insertUserLog($parent, $logstr);
  471. $parent->response(array('response' => 'success', 'data' => $data_arr, 'message' => $this->page_data['success1']), 200);
  472. }
  473. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  474. //MODELS VARIANT
  475. private function variant($parent)
  476. {
  477. globalfunc::checkMethodType($parent, array('GET'));
  478. globalfunc::checkParamCount($parent, 2);
  479. globalfunc::checkAuthrozation($parent, array('type' => 'explore'));
  480. $model_id = escape_str($parent->params['1']);
  481. //CHECK MODEL
  482. $query_modelarr = $parent->selectQuery(TABLE_COMPARE_MODEL, " `model_id` ", "model_id='" . $model_id . "' AND is_other=0 ", "1");
  483. if (!$query_modelarr['nr'] > 0) {
  484. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error1"]), 406);
  485. }
  486. $append_url = SITE_URL . "explore_assets/variant/";
  487. $data_arr = array();
  488. //GET MODEL VARIANT
  489. $query_variantarr = $parent->selectQuery(TABLE_MODEL_VARIANT, "`id`, `model_id`, `title`,`position`", "model_id='" . $model_id . "' AND is_deleted=0 ORDER BY position,id ", "");
  490. if ($query_variantarr['nr'] > 0) {
  491. foreach ($query_variantarr['result'] as $m => $res_var) {
  492. $query_variantarr['result'][$m]->color = array();
  493. //GET MODEL VARIANT COLOR
  494. $query_colorarr = $parent->selectQuery(TABLE_MODEL_VARIANT_COLOR, "*, CASE WHEN image!='' THEN CONCAT('" . $append_url . "',image) ELSE '" . NOIMAGE_URL . "' END AS 'image_url'", "variant_id='" . $res_var->id . "' AND is_deleted=0 ORDER BY position,id ", "");
  495. if ($query_colorarr['nr'] > 0) {
  496. $query_variantarr['result'][$m]->color = $query_colorarr['result'];
  497. }
  498. }
  499. $data_arr = $query_variantarr['result'];
  500. }
  501. //LOG
  502. $logstr = 'EXPLORE VARIANT';
  503. globalfunc::insertUserLog($parent, $logstr);
  504. $parent->response(array('response' => 'success', 'data' => $data_arr, 'message' => $this->page_data['success1']), 200);
  505. }
  506. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  507. //MODELS ENQUIRY
  508. private function enquiry($parent)
  509. {
  510. globalfunc::checkMethodType($parent, array('POST'));
  511. globalfunc::checkParamCount($parent, 2);
  512. globalfunc::checkAuthrozation($parent, array('type' => 'explore'));
  513. $model_id = escape_str($parent->params['1']);
  514. //CHECK MODEL
  515. $query_modelarr = $parent->selectQuery(TABLE_COMPARE_MODEL, " `model_id`,model_type ", "model_id='" . $model_id . "' AND is_other=0 ", "1");
  516. if (!$query_modelarr['nr'] > 0) {
  517. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error1"]), 406);
  518. }
  519. $REQUEST_KEYS = array('variant_id' => 'integer', 'name' => 'string', 'mobile' => 'string', 'email' => 'string');
  520. globalfunc::mandatoryKey($parent, $REQUEST_KEYS);
  521. $variant_id = escape_str($parent->_request['variant_id']);
  522. $name = escape_str($parent->_request['name']);
  523. $mobile = escape_str($parent->_request['mobile']);
  524. $email = escape_str($parent->_request['email']);
  525. $is_brochure = escape_str($parent->_request['is_brochure']);
  526. $is_brochure = ($is_brochure == '1') ? "1" : "0";
  527. $token = ($query_modelarr['result'][0]->model_type == '1') ? MODE_TWO_TOKEN : MODE_ONE_TOKEN;
  528. $explore_url = SITE_URL . "#/download_brouchure/" . $model_id . "/" . $variant_id . "/" . $token;
  529. $insert_str = "INSERT INTO " . TABLE_EXPLORE_ENQUIRY . " ( `user_id`, `model_id`, `variant_id`, `name`, `mobile`, `email`, `is_brochure`, `created_on`, `modified_on`) VALUES ( '" . $parent->current_user_id . "', '" . $model_id . "', '" . $variant_id . "', '" . $name . "', '" . $mobile . "', '" . $email . "', '" . $is_brochure . "','" . NOW . "','" . NOW . "')";
  530. $insertquery = $parent->executeQuery($insert_str);
  531. $query_dealerarr = $parent->selectQuery(DMS_DEALER, " *", "dealer_code='" . $parent->current_user_data->dealer_code . "'", "1");
  532. if ($query_dealerarr['nr'] > 0) {
  533. $dealer_details_str = $query_dealerarr['result'][0]->dealer_name;
  534. $dealer_details_str .= ($query_dealerarr['result'][0]->address != '') ? '<br>' . trim($query_dealerarr['result'][0]->address) : '';
  535. $dealer_details_str .= ($query_dealerarr['result'][0]->phone != '') ? '<br>Mob : ' . trim($query_dealerarr['result'][0]->phone) : '';
  536. $dealer_details_str .= ($query_dealerarr['result'][0]->email != '') ? '<br>Email : ' . trim($query_dealerarr['result'][0]->email) : '';
  537. } else {
  538. $dealer_details_str = 'HYPER-M';
  539. }
  540. //"16", "17"
  541. $cond_mail_str1 = (in_array($parent->current_user_role, array("16"))) ? "Thank you for showing your interest in HYPER-M and visiting Dealership." : "Thank you for showing your interest in HYPER-M.";
  542. $cond_mail_str2 = (in_array($parent->current_user_role, array("16", "17"))) ? "We hope you had a great experience in exploring our range of students." : "We hope you had a great experience in exploring our range of students";
  543. $email_link = ($is_brochure == '1') ? '<a href="' . $explore_url . '" style="font-weight:bold " >Click Here</a> to download the product e-brochure for your reference.<br>' : "";
  544. //MAIL AND SMS TRIGGER
  545. $message = '<table width="100%" bgcolor="#dfdfdf" border="0" cellspacing="10" cellpadding="0" style="padding-top:10px;">
  546. <tbody>
  547. <tr>
  548. <td>
  549. <table width="700" border="0" align="center" cellpadding="0" cellspacing="0" style="background:#ffffff; margin-top:0px;">
  550. <tbody>
  551. <tr>
  552. <td bgcolor="#2d2d2d" height="36" style="font-size:12px; font-family:Arial, Helvetica, sans-serif; color:#e4e4e4; text-align:left; font-weight:bold; padding-left:14px; border-bottom:2px solid black">HYPER-M</td>
  553. </tr>
  554. <tr>
  555. <td>
  556. <table width="85%" align="center">
  557. <tbody>
  558. <tr>
  559. <td height="30" style="font-size:11px; font-family:Arial, Helvetica, sans-serif; color:#3f3f3f; text-align:left;padding-left: 10px;
  560. line-height: 1.5;">
  561. <div style="font-family:arial; color:#333; font-size:12px; padding:5px;">Dear ' . $name . ',</div>
  562. </td>
  563. </tr>
  564. <tr>
  565. <td height="30" style="font-size:11px; font-family:Arial, Helvetica, sans-serif; color:#3f3f3f; text-align:left;padding-left: 10px;
  566. line-height: 1.5;">
  567. <div style="font-family:arial; color:#333; font-size:12px; padding:5px;">Greetings of the Day..!<br>
  568. ' . $cond_mail_str1 . '<br>
  569. ' . $cond_mail_str2 . '<br><br>
  570. ' . $email_link . '
  571. Thank you again for your visit and we look forward to see you soon.
  572. </div>
  573. </td>
  574. </tr>
  575. <tr>
  576. <td height="30" style="font-size:11px; font-family:Arial, Helvetica, sans-serif; color:#3f3f3f; text-align:left;padding-left: 10px;
  577. line-height: 1.5;"><div style="font-family:arial; color:#333; font-size:12px; padding:5px;">
  578. <p >With regards </p>
  579. <p >' . $dealer_details_str . '</p><br>
  580. Visit us at: <a href="">click here<a><br>
  581. Toll Free Number: 1800-121-7996 (Mon-Sat 9AM - 5:30PM)</p>
  582. <p>This is a system generated e-mail, please do not reply to this mail. </p>
  583. </div>
  584. </td>
  585. </tr>
  586. </tbody>
  587. </table>
  588. </td>
  589. </tr>
  590. <tr>
  591. <td style="padding-top:0px; padding-bottom:10px;"></td>
  592. </tr>
  593. <tr>
  594. <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#3f3f3f; background:#fafafa; line-height:20px; border-bottom:2px solid black">
  595. &nbsp;
  596. </td>
  597. </tr>
  598. </tbody>
  599. </table>
  600. </td>
  601. </tr>
  602. </tbody>
  603. </table>';
  604. $obj = array();
  605. $obj['from'] = CUSTOMER_EXPERIENCE_EMAIL;
  606. $obj['FromName'] = 'Customer Experience App';
  607. //$obj['replayto']=SUPPORT_EMAIL;
  608. $obj['to'] = $email;
  609. $obj['subject'] = "THANK YOU FOR ENQUIRY - HYPER-M";
  610. $obj['message'] = $message;
  611. // globalfunc::sendMai($parent, $obj);
  612. //LOG
  613. $logstr = 'EXPLORE ENQUIRY';
  614. globalfunc::insertUserLog($parent, $logstr);
  615. $parent->response(array('response' => 'success', 'message' => $this->page_data['success1']), 200);
  616. }
  617. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  618. //CUSTOMER
  619. private function customer($parent)
  620. {
  621. globalfunc::checkMethodType($parent, array('POST'));
  622. //globalfunc::checkAuthrozation($parent,array('type'=>'explore'));
  623. $smpin = escape_str($parent->_request['smpin']);
  624. $emp_code = escape_str($parent->_request['emp_code']);
  625. if (!($smpin != '' || $emp_code != '')) {
  626. $parent->response(array('response' => 'failed', 'message' => 'Invalid Authentication token'), 401);
  627. }
  628. $user_qry_str = "SELECT * FROM " . TABLE_USER . " WHERE is_deleted='0' AND status='1' AND smpin='" . $smpin . "' AND emp_code='" . $emp_code . "' LIMIT 1";
  629. $user_value = $parent->getQueryValue($user_qry_str);
  630. if (!count($user_value) > 0) {
  631. $parent->response(array('response' => 'failed', 'message' => 'Invalid Authentication token'), 401);
  632. }
  633. $parent->current_user_data = $user_value[0];
  634. $parent->current_user_id = $user_value[0]->userid;
  635. $parent->current_user_role = $user_value[0]->role;
  636. $parent->current_smpin = $user_value[0]->smpin;
  637. $parent->current_emp_code = $user_value[0]->emp_code;
  638. $REQUEST_KEYS = array('customer_data' => 'array');
  639. globalfunc::mandatoryKey($parent, $REQUEST_KEYS);
  640. $customer_data = escape_str($parent->_request['customer_data']);
  641. $mobile = escape_str($parent->_request['mobile']);
  642. $is_exist = 0;
  643. $model_data = new stdClass();
  644. if ($mobile) {
  645. $startdate = date('Y-m-d', strtotime('-30 day', strtotime(NOW)));
  646. $query_checkarr = $parent->selectQuery(TABLE__CUSTOMEREXP . " as ce JOIN " . TABLE_EXPLORE_ENQUIRY . " e ON ce.id=e.customerid ", "e.model_id,e.variant_id ", "ce.mobile='" . $mobile . "' AND ce.created_on>='" . $startdate . " 00:00:00' ORDER BY e.id DESC", "1");
  647. if ($query_checkarr['nr'] > 0) {
  648. $append_url = SITE_URL . "explore_assets/model/" . strtolower($parent->device_type) . "/";
  649. $modelarr = $parent->selectQuery(TABLE_COMPARE_MODEL, " `model_id`,`title`,`description`, `model_name`, CASE WHEN model_image!='' THEN CONCAT('" . $append_url . "',model_image) ELSE '" . NOIMAGE_URL . "' END AS 'model_image_url', CASE WHEN model_banner_image!='' THEN CONCAT('" . $append_url . "',model_banner_image) ELSE '" . NOIMAGE_URL . "' END AS 'model_banner_image_url'", " model_id='" . $query_checkarr['result'][0]->model_id . "'", "1");
  650. if ($modelarr['nr'] > 0) {
  651. $query_variantarr = $parent->selectQuery(TABLE_MODEL_VARIANT, "`id`, `model_id`, `title`,`position`", "id='" . $query_checkarr['result'][0]->variant_id . "' ", "1");
  652. $is_exist = 1;
  653. $modelarr['result'][0]->variant = ($query_variantarr['nr'] > 0) ? $query_variantarr['result'][0] : '';
  654. $model_data = $modelarr['result'][0];
  655. }
  656. }
  657. }
  658. $insert_arr = array();
  659. if (count($customer_data) > 0) {
  660. //VALIDATE
  661. foreach ($customer_data as $res) {
  662. $salutation = escape_str($res['salutation']);
  663. $firstname = escape_str($res['firstname']);
  664. $lastname = escape_str($res['lastname']);
  665. $email = escape_str($res['email']);
  666. $mobile = escape_str($res['mobile']);
  667. $age = escape_str($res['age']);
  668. $uid = escape_str($res['uid']);
  669. $smpin = escape_str($res['smpin']);
  670. $dsename = escape_str($res['dsename']);
  671. if (!($salutation != '' && $firstname != '' && $mobile != '' && $age != '' && $uid != '')) {
  672. $parent->response(array('response' => 'failed', 'message' => 'INVALID DATA'), 406);
  673. }
  674. $insert_arr[] = " ('" . $salutation . "', '" . $firstname . "', '" . $lastname . "', '" . $email . "','" . $mobile . "', '" . $age . "','" . $smpin . "', '" . $dsename . "', '" . $parent->current_user_id . "','" . $uid . "','" . NOW . "')";
  675. }
  676. $parent->executeQuery("INSERT INTO " . TABLE__CUSTOMEREXP . " ( `salutation`, `firstname`, `lastname`, `email`, `mobile`, `age`, `smpin`, `dsename`, `userid`,`uid`,`created_on`) VALUES " . @implode(",", $insert_arr));
  677. } else {
  678. $parent->response(array('response' => 'failed', 'message' => 'INVALID DATA'), 406);
  679. }
  680. // $REQUEST_KEYS=array('salutation'=>'string','firstname'=>'string' ,'age'=>'string','mobile'=>'number');
  681. // globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
  682. //
  683. // $salutation=escape_str($parent->_request['salutation']);
  684. // $firstname=escape_str($parent->_request['firstname']);
  685. // $lastname=escape_str($parent->_request['lastname']);
  686. // $email=escape_str($parent->_request['email']);
  687. // $mobile=escape_str($parent->_request['mobile']);
  688. // $age=escape_str($parent->_request['age']);
  689. //
  690. // $insert_str = "INSERT INTO ".TABLE__CUSTOMEREXP." ( `salutation`, `firstname`, `lastname`, `email`, `mobile`, `age`, `userid`, `created_on`) VALUES ('".$salutation."', '".$firstname."', '".$lastname."', '".$email."','".$mobile."', '".$age."', '".$parent->current_user_id."', '".NOW."')";
  691. // $insertquery = $parent->executeQuery($insert_str);
  692. //
  693. // $ins_id=$parent->lastInsertId();
  694. //
  695. //LOG
  696. $logstr = 'EXPLORE CUSTOMER';
  697. globalfunc::insertUserLog($parent, $logstr);
  698. //
  699. // $get_str = "SELECT * FROM ".TABLE__CUSTOMEREXP." WHERE id='".$ins_id."' LIMIT 1";
  700. // $get_arr=$parent->getQueryValue($get_str);
  701. $parent->response(array('response' => 'success', 'is_exist' => $is_exist, 'model_data' => $model_data, 'message' => $this->page_data['success1']), 200);
  702. }
  703. //CUSTOMER
  704. private function customerfeedback($parent)
  705. {
  706. //
  707. globalfunc::checkMethodType($parent, array('GET', 'POST'));
  708. switch ($parent->get_request_method()) {
  709. case "GET": //GET FEEDBACK QUESTION
  710. globalfunc::checkAuthrozation($parent, array('type' => 'explore'));
  711. // $sarr=array('Poor','Average','Good','Very Good','Excellent');
  712. /*$sarr=array('1','2','3','4','5');
  713. $i=1;
  714. foreach($sarr as $sval)
  715. {
  716. $val=new stdClass();
  717. $val->id=$i++;
  718. $val->score=$val->id;
  719. $val->rating_text=$sval;
  720. $survey_arr[]=$val;
  721. }*/
  722. $sarr = array('5', '4', '3', '2', '1');
  723. $i = 1;
  724. foreach ($sarr as $sval) {
  725. $val = new stdClass();
  726. $val->id = $sval;
  727. $val->score = $sval;
  728. $val->rating_text = $sval;
  729. $survey_arr[] = $val;
  730. }
  731. $ques_str = "SELECT q.id as qid, q.`questiontypeid`, q.`questiontext`, q.`qimage`, q.`qvideo` FROM " . TABLE__EXPQUESTION . " as q WHERE q.status=1 " . $econd;
  732. $ques_arr = $parent->getQueryValue($ques_str);
  733. $question_arr = array();
  734. if (count($ques_arr) > 0) {
  735. $s3 = awsfileserver::connectS3();
  736. foreach ($ques_arr as $key => $res_ques) {
  737. $res_ques->rating_options = array();
  738. //QUESTION IMAGE
  739. $res_ques->qimage_url = '';
  740. if ($res_ques->qimage != '') {
  741. $res_ques->qimage_url = awsfileserver::getS3FileUrl($s3, S3_BUCKET, S3_QUESTION_URL . $res_ques->qimage);
  742. }
  743. //QUESTION VIDEO
  744. $res_ques->qvideo_url = '';
  745. if ($res_ques->qvideo != '') {
  746. $res_ques->qvideo_url = awsfileserver::getS3FileUrl($s3, S3_BUCKET, S3_QUESTION_URL . $res_ques->qvideo);
  747. }
  748. //RATING QUESTION
  749. $res_ques->rating_options = array();
  750. $res_ques->options = array();
  751. if ($res_ques->questiontypeid == '7') {
  752. $res_ques->rating_options = $survey_arr;
  753. } else if ($res_ques->questiontypeid == '9' || $res_ques->questiontypeid == '10') {
  754. //CHOICE
  755. $chocie_arr = array();
  756. //WEB NEED selected
  757. $quesoption_str = "SELECT optid,opttext FROM " . TABLE__EXPQUESTIONOPTION . " WHERE qid='" . $res_ques->qid . "'";
  758. $quesoption_arr = $parent->getQueryValue($quesoption_str);
  759. $res_ques->options = $quesoption_arr;
  760. }
  761. $question_arr[] = $res_ques;
  762. }
  763. }
  764. //LOG
  765. $logstr = 'EXPLORE QUESTION';
  766. globalfunc::insertUserLog($parent, $logstr);
  767. $parent->response(array('response' => 'success', 'data' => $question_arr, 'total' => count($question_arr), 'message' => $this->page_data['success1']), 200);
  768. break;
  769. case "POST": //POST FEEDBACK SUBMIT
  770. $smpin = escape_str($parent->_request['smpin']);
  771. $emp_code = escape_str($parent->_request['emp_code']);
  772. if (!($smpin != '' || $emp_code != '')) {
  773. $parent->response(array('response' => 'failed', 'message' => 'Invalid Authentication token'), 401);
  774. }
  775. $user_qry_str = "SELECT * FROM " . TABLE_USER . " WHERE is_deleted='0' AND status='1' AND smpin='" . $smpin . "' AND emp_code='" . $emp_code . "' LIMIT 1";
  776. $user_value = $parent->getQueryValue($user_qry_str);
  777. if (!count($user_value) > 0) {
  778. $parent->response(array('response' => 'failed', 'message' => 'Invalid Authentication token'), 401);
  779. }
  780. $parent->current_user_data = $user_value[0];
  781. $parent->current_user_id = $user_value[0]->userid;
  782. $parent->current_user_role = $user_value[0]->role;
  783. $parent->current_smpin = $user_value[0]->smpin;
  784. $parent->current_emp_code = $user_value[0]->emp_code;
  785. $REQUEST_KEYS = array('customer_data' => 'array');
  786. globalfunc::mandatoryKey($parent, $REQUEST_KEYS);
  787. $customer_data = escape_str($parent->_request['customer_data']);
  788. if (count($customer_data) > 0) {
  789. //VALIDATION
  790. foreach ($customer_data as $key => $res) {
  791. $uid = $res['uid'];
  792. $ans_arr = $res['ans_arr'];
  793. //$ans_arr = json_decode($ans_str);
  794. if (!(isset($res['ans_arr']) && is_array($ans_arr) && count($ans_arr) > 0)) {
  795. $parent->response(array('response' => 'failed', 'message' => 'INVALID DATA'), 406);
  796. }
  797. $customer_str = "SELECT id FROM " . TABLE__CUSTOMEREXP . " WHERE uid='" . $uid . "' LIMIT 1";
  798. $customer_arr = $parent->getQueryValue($customer_str);
  799. if (!count($customer_arr) > 0) {
  800. $parent->response(array('response' => 'failed', 'message' => 'INVALID USER'), 406);
  801. }
  802. $customer_data[$key]['customerid'] = $customer_arr[0]->id;
  803. }
  804. foreach ($customer_data as $res) {
  805. $uid = $res['uid'];
  806. $ans_arr = $res['ans_arr'];
  807. $customerid = $res['customerid'];
  808. $userid = $parent->current_user_id;
  809. //RESULT INSERT
  810. $parent->executeQuery("INSERT INTO " . TABLE__FEEDBACKUSER . " ( `customerid`, `creatorid`, `created_on`, `modified_on`)VALUES('" . $customerid . "','" . $userid . "','" . NOW . "','" . NOW . "')");
  811. $arid = $parent->lastInsertId();
  812. //INSERT OPTIONS
  813. $insert_result_arr = array();
  814. for ($mid = 0; $mid < count($ans_arr); $mid++) {
  815. // $qid = $ans_arr[$mid]->qid;
  816. // $survey_rating = (isset($ans_arr[$mid]->survey_rating))?$ans_arr[$mid]->survey_rating:0;
  817. // $survey_text=(isset($ans_arr[$mid]->survey_text) && is_string($ans_arr[$mid]->survey_text))?$ans_arr[$mid]->survey_text:'';
  818. // $options_arr =(isset($ans_arr[$mid]->options))?$ans_arr[$mid]->options:array();
  819. $qid = $ans_arr[$mid]['qid'];
  820. $survey_rating = (isset($ans_arr[$mid]['survey_rating'])) ? $ans_arr[$mid]['survey_rating'] : 0;
  821. $survey_text = (isset($ans_arr[$mid]['survey_text']) && is_string($ans_arr[$mid]['survey_text'])) ? $ans_arr[$mid]['survey_text'] : '';
  822. $options_arr = (isset($ans_arr[$mid]['options'])) ? $ans_arr[$mid]['options'] : array();
  823. if (is_array($options_arr) && count($options_arr) > 0) {
  824. for ($nid = 0; $nid < count($options_arr); $nid++) {
  825. $option_id = $options_arr[$nid];
  826. $insert_result_arr[] = " ('" . $arid . "', '" . $customerid . "', '" . $qid . "','" . $survey_rating . "','" . $survey_text . "','" . $option_id . "','" . NOW . "','" . NOW . "')";
  827. }
  828. } else {
  829. $insert_result_arr[] = " ('" . $arid . "', '" . $customerid . "', '" . $qid . "','" . $survey_rating . "','" . $survey_text . "','','" . NOW . "','" . NOW . "')";
  830. }
  831. }
  832. if (count($insert_result_arr) > 0) {
  833. $parent->executeQuery("INSERT INTO " . TABLE__FEEDBACKRESULT . " (arid, customerid, qid,survey_rating,survey_text,choiseid,created_on,modified_on)VALUES " . @implode(',', $insert_result_arr) . "");
  834. } else {
  835. $parent->response(array('response' => 'failed', 'message' => $this->page_data["explore"]), 406);
  836. }
  837. }
  838. } else {
  839. $parent->response(array('response' => 'failed', 'message' => 'INVALID DATA'), 406);
  840. }
  841. //LOG
  842. $logstr = 'EXPLORE FEEDBACK SUBMIT';
  843. globalfunc::insertUserLog($parent, $logstr);
  844. //$parent->response(array('response'=>'success', 'message'=>$this->page_data['success1']),200);
  845. $parent->response(array('response' => 'success', 'message' => 'Thank you for your Feedback'), 200);
  846. break;
  847. }
  848. }
  849. //MODELS ENQUIRY
  850. private function customerenquiry($parent)
  851. {
  852. globalfunc::checkMethodType($parent, array('POST'));
  853. globalfunc::checkParamCount($parent, 1);
  854. //globalfunc::checkAuthrozation($parent,array('type'=>'explore'));
  855. $smpin = escape_str($parent->_request['smpin']);
  856. $emp_code = escape_str($parent->_request['emp_code']);
  857. if (!($smpin != '' || $emp_code != '')) {
  858. $parent->response(array('response' => 'failed', 'message' => 'Invalid Authentication token'), 401);
  859. }
  860. $user_qry_str = "SELECT * FROM " . TABLE_USER . " WHERE is_deleted='0' AND status='1' AND smpin='" . $smpin . "' AND emp_code='" . $emp_code . "' LIMIT 1";
  861. $user_value = $parent->getQueryValue($user_qry_str);
  862. if (!count($user_value) > 0) {
  863. $parent->response(array('response' => 'failed', 'message' => 'Invalid Authentication token'), 401);
  864. }
  865. $parent->current_user_data = $user_value[0];
  866. $parent->current_user_id = $user_value[0]->userid;
  867. $parent->current_user_role = $user_value[0]->role;
  868. $parent->current_smpin = $user_value[0]->smpin;
  869. $parent->current_emp_code = $user_value[0]->emp_code;
  870. $REQUEST_KEYS = array('customer_data' => 'array');
  871. globalfunc::mandatoryKey($parent, $REQUEST_KEYS);
  872. $customer_data = escape_str($parent->_request['customer_data']);
  873. if (count($customer_data) > 0) {
  874. //VALIDATION
  875. foreach ($customer_data as $key => $res) {
  876. //$REQUEST_KEYS=array('variant_id'=>'integer','name'=>'string','mobile'=>'string','email'=>'string');
  877. //globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
  878. $model_id = escape_str($res['model_id']);
  879. $uid = escape_str($res['uid']);
  880. $variant_id = escape_str($res['variant_id']);
  881. $name = escape_str($res['name']);
  882. $mobile = escape_str($res['mobile']);
  883. $email = escape_str($res['email']);
  884. $is_brochure = escape_str($res['is_brochure']);
  885. if (!($variant_id != '' && $model_id != '' && $name != '' && $mobile != '' && $email != '')) {
  886. $parent->response(array('response' => 'failed', 'message' => 'INVALID DATA'), 406);
  887. }
  888. if ($uid != '') {
  889. $customer_str = "SELECT id FROM " . TABLE__CUSTOMEREXP . " WHERE uid='" . $uid . "' LIMIT 1";
  890. $customer_arr = $parent->getQueryValue($customer_str);
  891. if (!count($customer_arr) > 0) {
  892. $parent->response(array('response' => 'failed', 'message' => 'INVALID USER'), 406);
  893. }
  894. $customer_data[$key]['customerid'] = $customer_arr[0]->id;
  895. } else {
  896. $customer_data[$key]['customerid'] = 0;
  897. }
  898. //CHECK MODEL
  899. $query_modelarr = $parent->selectQuery(TABLE_COMPARE_MODEL, " `model_id`,model_type ", "model_id='" . $model_id . "' AND is_other=0 ", "1");
  900. if (!$query_modelarr['nr'] > 0) {
  901. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error1"]), 406);
  902. }
  903. $token = ($query_modelarr['result'][0]->model_type == '1') ? MODE_TWO_TOKEN : MODE_ONE_TOKEN;
  904. $customer_data[$key]['token'] = $token;
  905. }
  906. foreach ($customer_data as $res) {
  907. //$REQUEST_KEYS=array('variant_id'=>'integer','name'=>'string','mobile'=>'string','email'=>'string');
  908. //globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
  909. $model_id = escape_str($res['model_id']);
  910. $variant_id = escape_str($res['variant_id']);
  911. $name = escape_str($res['name']);
  912. $mobile = escape_str($res['mobile']);
  913. $email = escape_str($res['email']);
  914. $is_brochure = escape_str($res['is_brochure']);
  915. $is_brochure = ($is_brochure == '1') ? "1" : "0";
  916. $customerid = $res['customerid'];
  917. $token = $res['token'];
  918. $explore_url = SITE_URL . "#/download_brouchure/" . $model_id . "/" . $variant_id . "/" . $token;
  919. $insert_str = "INSERT INTO " . TABLE_EXPLORE_ENQUIRY . " ( `user_id`, `model_id`, `variant_id`, `name`, `mobile`, `email`, `customerid`, `is_brochure`, `created_on`, `modified_on`) VALUES ( '" . $parent->current_user_id . "', '" . $model_id . "', '" . $variant_id . "', '" . $name . "', '" . $mobile . "', '" . $email . "','" . $customerid . "', '" . $is_brochure . "','" . NOW . "','" . NOW . "')";
  920. $insertquery = $parent->executeQuery($insert_str);
  921. $query_dealerarr = $parent->selectQuery(DMS_DEALER, " *", "dealer_code='" . $parent->current_user_data->dealer_code . "'", "1");
  922. if ($query_dealerarr['nr'] > 0) {
  923. $dealer_details_str = $query_dealerarr['result'][0]->dealer_name;
  924. $dealer_details_str .= ($query_dealerarr['result'][0]->address != '') ? '<br>' . trim($query_dealerarr['result'][0]->address) : '';
  925. $dealer_details_str .= ($query_dealerarr['result'][0]->phone != '') ? '<br>Mob : ' . trim($query_dealerarr['result'][0]->phone) : '';
  926. $dealer_details_str .= ($query_dealerarr['result'][0]->email != '') ? '<br>Email : ' . trim($query_dealerarr['result'][0]->email) : '';
  927. } else {
  928. $dealer_details_str = 'HYPER-M';
  929. }
  930. $cond_mail_str1 = (in_array($parent->current_user_role, array("16"))) ? "Thank you for showing your interest in HYPER-M and visiting Dealership." : "Thank you for showing your interest in HYPER-M.";
  931. $cond_mail_str2 = (in_array($parent->current_user_role, array("16", "17"))) ? "We hope you had a great experience in exploring our range of students." : "We hope you had a great experience in exploring our range of students";
  932. $email_link = ($is_brochure == '1') ? '<a href="' . $explore_url . '" style="font-weight:bold " >Click Here</a> to download the product e-brochure for your reference.<br>' : "";
  933. //MAIL AND SMS TRIGGER
  934. $message = '<table width="100%" bgcolor="#dfdfdf" border="0" cellspacing="10" cellpadding="0" style="padding-top:10px;">
  935. <tbody>
  936. <tr>
  937. <td>
  938. <table width="700" border="0" align="center" cellpadding="0" cellspacing="0" style="background:#ffffff; margin-top:0px;">
  939. <tbody>
  940. <tr>
  941. <td bgcolor="#2d2d2d" height="36" style="font-size:12px; font-family:Arial, Helvetica, sans-serif; color:#e4e4e4; text-align:left; font-weight:bold; padding-left:14px; border-bottom:2px solid black">HYPER-M</td>
  942. </tr>
  943. <tr>
  944. <td>
  945. <table width="85%" align="center">
  946. <tbody>
  947. <tr>
  948. <td height="30" style="font-size:11px; font-family:Arial, Helvetica, sans-serif; color:#3f3f3f; text-align:left;padding-left: 10px;
  949. line-height: 1.5;">
  950. <div style="font-family:arial; color:#333; font-size:12px; padding:5px;">Dear ' . $name . ',</div>
  951. </td>
  952. </tr>
  953. <tr>
  954. <td height="30" style="font-size:11px; font-family:Arial, Helvetica, sans-serif; color:#3f3f3f; text-align:left;padding-left: 10px;
  955. line-height: 1.5;">
  956. <div style="font-family:arial; color:#333; font-size:12px; padding:5px;">Greetings of the Day..!<br>
  957. ' . $cond_mail_str1 . '<br>
  958. ' . $cond_mail_str2 . '<br><br>
  959. ' . $email_link . '
  960. Thank you again for your visit and we look forward to see you soon.
  961. </div>
  962. </td>
  963. </tr>
  964. <tr>
  965. <td height="30" style="font-size:11px; font-family:Arial, Helvetica, sans-serif; color:#3f3f3f; text-align:left;padding-left: 10px;
  966. line-height: 1.5;"><div style="font-family:arial; color:#333; font-size:12px; padding:5px;">
  967. <p >With regards </p>
  968. <p >' . $dealer_details_str . '</p><br>
  969. Visit us at: <a href="">click here<a><br>
  970. Toll Free Number: 1800-121-7996 (Mon-Sat 9AM - 5:30PM)</p>
  971. <p>This is a system generated e-mail, please do not reply to this mail. </p>
  972. </div>
  973. </td>
  974. </tr>
  975. </tbody>
  976. </table>
  977. </td>
  978. </tr>
  979. <tr>
  980. <td style="padding-top:0px; padding-bottom:10px;"></td>
  981. </tr>
  982. <tr>
  983. <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#3f3f3f; background:#fafafa; line-height:20px; border-bottom:2px solid black">
  984. &nbsp;
  985. </td>
  986. </tr>
  987. </tbody>
  988. </table>
  989. </td>
  990. </tr>
  991. </tbody>
  992. </table>';
  993. $obj = array();
  994. $obj['from'] = CUSTOMER_EXPERIENCE_EMAIL;
  995. $obj['FromName'] = 'Customer Experience App';
  996. //$obj['replayto']=SUPPORT_EMAIL;
  997. $obj['to'] = $email;
  998. $obj['subject'] = "THANK YOU FOR ENQUIRY - HYPER-M";
  999. $obj['message'] = $message;
  1000. // globalfunc::sendMai($parent, $obj);
  1001. }
  1002. } else {
  1003. $parent->response(array('response' => 'failed', 'message' => 'INVALID DATA'), 406);
  1004. }
  1005. //LOG
  1006. $logstr = 'EXPLORE ENQUIRY';
  1007. globalfunc::insertUserLog($parent, $logstr);
  1008. $parent->response(array('response' => 'success', 'message' => $this->page_data['success1']), 200);
  1009. }
  1010. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  1011. //MODEL ACCESSORIES RIDERS
  1012. private function accessories_riders($parent)
  1013. {
  1014. globalfunc::checkMethodType($parent, array('GET'));
  1015. globalfunc::checkParamCount($parent, 1);
  1016. globalfunc::checkAuthrozation($parent, array('type' => 'explore'));
  1017. $append_url = SITE_URL . "explore_assets/accessories/";
  1018. $data_arr = array('category' => array(), 'data' => array());
  1019. $cat_data = array();
  1020. //GET ACCESSORIES
  1021. $query_arr = $parent->selectQuery(TABLE_EXPLORE_ACCESSORIES, "*, CASE WHEN image!='' THEN CONCAT('" . $append_url . "',image) ELSE '" . NOIMAGE_URL . "' END AS 'image_url' ", "type='2' AND is_deleted=0 ", "");
  1022. if ($query_arr['nr'] > 0) {
  1023. foreach ($query_arr['result'] as $res) {
  1024. $cat_data[$res->cat_id][] = $res;
  1025. }
  1026. $cat_query_arr = $parent->selectQuery(TABLE_EXPLORE_ACCESSORIES_CATEGORY, "*", "is_deleted=0 AND id IN (SELECT cat_id FROM " . TABLE_EXPLORE_ACCESSORIES . " WHERE type='2' AND is_deleted=0 ) ORDER BY cat_pos ASC", "");
  1027. if ($cat_query_arr['nr']) {
  1028. foreach ($cat_query_arr['result'] as $key => $val) {
  1029. $cat_query_arr['result'][$key]->data = $cat_data[$val->id];
  1030. }
  1031. }
  1032. $data_arr = array('category' => $cat_query_arr['result'], 'data' => $query_arr['result']);
  1033. }
  1034. //LOG
  1035. $logstr = 'EXPLORE ACCESSORIES RIDERS';
  1036. globalfunc::insertUserLog($parent, $logstr);
  1037. // $data_arr= array('model'=>$query_modelarr['result'][0],'category'=>$category_arr,'compare_model'=>$compare_model_arr);
  1038. $parent->response(array('response' => 'success', 'data' => $data_arr, 'message' => $this->page_data['success1']), 200);
  1039. }
  1040. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  1041. //MODEL ACCESSORIES BIKES
  1042. private function accessories_bikes($parent)
  1043. {
  1044. globalfunc::checkMethodType($parent, array('GET'));
  1045. globalfunc::checkParamCount($parent, 2);
  1046. globalfunc::checkAuthrozation($parent, array('type' => 'explore'));
  1047. $append_url = SITE_URL . "explore_assets/accessories/";
  1048. $model_id = escape_str($parent->params['1']);
  1049. $data_arr = array('category' => array(), 'data' => array());
  1050. //GET ACCESSORIES
  1051. $query_arr = $parent->selectQuery(TABLE_EXPLORE_ACCESSORIES, "*, CASE WHEN image!='' THEN CONCAT('" . $append_url . "',image) ELSE '" . NOIMAGE_URL . "' END AS 'image_url' ", "type='1' AND is_deleted=0 AND model_id='" . $model_id . "' ", "");
  1052. if ($query_arr['nr'] > 0) {
  1053. $cat_query_arr = $parent->selectQuery(TABLE_EXPLORE_ACCESSORIES_CATEGORY, "*", "is_deleted=0 AND id IN (SELECT cat_id FROM " . TABLE_EXPLORE_ACCESSORIES . " WHERE type='1' AND is_deleted=0 AND model_id='" . $model_id . "' ) ORDER BY cat_pos ASC", "");
  1054. $data_arr = array('category' => $cat_query_arr['result'], 'data' => $query_arr['result']);
  1055. }
  1056. //LOG
  1057. $logstr = 'EXPLORE ACCESSORIES BIKES';
  1058. globalfunc::insertUserLog($parent, $logstr);
  1059. // $data_arr= array('model'=>$query_modelarr['result'][0],'category'=>$category_arr,'compare_model'=>$compare_model_arr);
  1060. $parent->response(array('response' => 'success', 'data' => $data_arr, 'message' => $this->page_data['success1']), 200);
  1061. }
  1062. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  1063. //MODELS CONTENT
  1064. private function contentlist($parent)
  1065. {
  1066. globalfunc::checkMethodType($parent, array('GET'));
  1067. globalfunc::checkParamCount($parent, 2);
  1068. globalfunc::checkAuthrozation($parent, array('type' => 'explore'));
  1069. $url_data = escape_str($parent->params['1']);
  1070. //PAGINATION SETTINGS
  1071. $limit_cond = '';
  1072. $data_arr = array();
  1073. $limit_str = globalfunc::setPageLimit($parent, $url_data);
  1074. $limit_cond = ($limit_str) ? " LIMIT " . $limit_str : '';
  1075. $url_data_arr = @explode('?', $url_data);
  1076. $model_id = $url_data_arr[0];
  1077. //CHECK MODEL
  1078. $query_modelarr = $parent->selectQuery(TABLE_COMPARE_MODEL, " `model_id` ", "model_id='" . $model_id . "' AND is_other=0 ", "1");
  1079. if (!$query_modelarr['nr'] > 0) {
  1080. $parent->response(array('response' => 'failed', 'message' => $this->page_data["error1"]), 406);
  1081. }
  1082. //S3_CUS_CONTENT_URL
  1083. $model_content_arr = $parent->selectQuery(TABLE_EXPLORE_CONTENT . " c JOIN " . TABLE_EXPLORE_FILE . " f on c.contentid=f.contentid", "SQL_CALC_FOUND_ROWS c.contentid,c.title,c.description,c.uploaddate,c.version,c.uploaddate,f.filepath,f.thumbpath", " c.status='1' AND c.is_deleted='0' AND c.model_id='" . $model_id . "' ORDER BY c.contentid ASC " . $limit_cond, "");
  1084. $customer_arr = $parent->getQueryValue("select FOUND_ROWS() as total_records");
  1085. if ($model_content_arr['nr']) {
  1086. //CONNECT S3
  1087. $s3 = awsfileserver::connectS3();
  1088. foreach ($model_content_arr['result'] as $key => $res) {
  1089. $model_content_arr['result'][$key]->file_url = ($res->filepath != '') ? awsfileserver::getS3FileUrl($s3, S3_BUCKET, S3_CUS_CONTENT_URL . $res->filepath) : NOIMAGE_URL;
  1090. $model_content_arr['result'][$key]->thumb_url = ($res->thumbpath != '') ? awsfileserver::getS3FileUrl($s3, S3_BUCKET, S3_CUS_CONTENT_URL . $res->thumbpath) : NOIMAGE_URL;
  1091. $data_arr[] = $model_content_arr['result'][$key];
  1092. }
  1093. }
  1094. //GET COUNT
  1095. $total = (count($customer_arr) > 0) ? $customer_arr[0]->total_records : 0;
  1096. //LOG
  1097. $logstr = 'CUSTOMER EXPERIENCE MODELS CONTENT';
  1098. globalfunc::insertUserLog($parent, $logstr, $cateid);
  1099. $last_page = ($total) ? ceil($total / $parent->current_limit) - 1 : 0;
  1100. $parent->response(array('response' => 'success', 'data' => $data_arr, 'total' => $total, 'last_page' => $last_page, 'current_page' => $parent->current_page, 'message' => $this->page_data['success1']), 200);
  1101. }
  1102. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  1103. }