PageRenderTime 61ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/application/controllers/merchantaccount.php

https://bitbucket.org/effectal/ondi
PHP | 4602 lines | 3080 code | 976 blank | 546 comment | 675 complexity | b9bc60c77f6b834e757bda4f2cfb087a MD5 | raw file
Possible License(s): LGPL-2.1, MPL-2.0-no-copyleft-exception

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. class Merchantaccount extends CI_Controller {
  3. public function __construct()
  4. {
  5. parent::__construct();
  6. $this->load->library(array('form_validation','session', 'ip2location', 'customclass'));
  7. $this->load->helper(array('form', 'url'));
  8. //$this->load->library('encrypt');
  9. $this->load->database();
  10. $this->load->model(array('users','CI_auth','CI_encrypt', 'offers','Admin_Model'));
  11. if($this->CI_auth->check_logged()===FALSE)
  12. {
  13. $this->CI_auth->redirect_nonlogged_user();
  14. }else{
  15. $sess_user_data = $this->session->all_userdata();
  16. if($sess_user_data['user_type']!='2' && $sess_user_data['user_type']!='3')
  17. {
  18. $this->CI_auth->redirect_nonlogged_user();
  19. }
  20. }
  21. }
  22. public function index()
  23. {
  24. }
  25. public function contactinfo()
  26. {
  27. /* USER ACCESS TYPE CHECK DATA START */
  28. $logged_user_access_type = $this->users->get_user_access_type();
  29. $data['logged_user_access_type'] = $logged_user_access_type;
  30. $data['logged_user_access_sections'] = array();
  31. if($logged_user_access_type=='3')
  32. {
  33. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  34. if(!in_array("1",$data['logged_user_access_sections']))
  35. {
  36. redirect('/merchantaccount/welcomeuser', 'refresh');
  37. }
  38. }
  39. /* USER ACCESS TYPE CHECK DATA END */
  40. $user_id='';
  41. // $user_id=$this->CI_auth->logged_id();
  42. $user_id = $this->users->get_main_merchant_id();
  43. $this->db->select('position_id, position_value');
  44. $condition=array('delete_status' => '0'); // Note: Zero is for active, 1 is for deleted
  45. $this->db->where($condition);
  46. $positionquery = $this->db->get('user_position');
  47. $data['positiondata'] = $positionquery->result();
  48. $data['title'] = 'Services on demand - Ondi.com';
  49. $this->db->select('email, position, position_other, phone, contact_name, terms_condition, merchant_steps_completed');
  50. $query = $this->db->get_where('users', array('user_id' => $user_id));
  51. $data['user_data'] = $query->result();
  52. $merchant_steps_completed=$data['user_data'][0]->merchant_steps_completed;
  53. $this->form_validation->set_rules('contact_name', 'Contact Name', 'trim|required');
  54. $this->form_validation->set_rules('position', 'Position', 'trim|required');
  55. $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
  56. //$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|matches[confirm_email]');
  57. //$this->form_validation->set_rules('confirm_email', 'Confirm Email', 'trim|required|valid_email');
  58. $this->form_validation->set_rules('terms_condition', 'Terms & Condition', 'trim|required');
  59. if ($this->form_validation->run() == FALSE) {
  60. $this->load->view('/merchantaccount/contactinfo', $data);
  61. }
  62. else{
  63. if($this->input->post('contact_action')){
  64. $contact_name = $this->input->post('contact_name');
  65. $position = $this->input->post('position');
  66. $position_other = $this->input->post('position_other');
  67. $email = $this->input->post('email');
  68. $phone = $this->input->post('phone');
  69. $terms_condition = $this->input->post('terms_condition');
  70. if($merchant_steps_completed==0)
  71. {
  72. $data = array(
  73. 'contact_name' => $contact_name,
  74. 'position' => $position,
  75. 'position_other' => $position_other,
  76. 'email' => $email,
  77. 'phone' => $phone,
  78. 'terms_condition' => $terms_condition,
  79. 'merchant_steps_completed' => '1'
  80. );
  81. }else{
  82. $data = array(
  83. 'contact_name' => $contact_name,
  84. 'position' => $position,
  85. 'position_other' => $position_other,
  86. 'email' => $email,
  87. 'phone' => $phone,
  88. 'terms_condition' => $terms_condition
  89. );
  90. }
  91. //print_r($data);
  92. //die;
  93. $this->db->where('user_id', $user_id);
  94. $this->db->update('users', $data);
  95. $user_steps_completed = $this->users->user_steps_completed($user_id);
  96. if($user_steps_completed>2)
  97. {
  98. redirect('/merchantaccount/viewcontactinfo', 'refresh');
  99. }
  100. else
  101. {
  102. redirect('/merchantaccount/businessprofile', 'refresh');
  103. }
  104. }
  105. }
  106. }
  107. public function businessprofile()
  108. {
  109. /* USER ACCESS TYPE CHECK DATA START */
  110. $logged_user_access_type = $this->users->get_user_access_type();
  111. /* USER ACCESS TYPE CHECK DATA END */
  112. $user_id=''; // hard coded as of now
  113. // $user_id=$this->CI_auth->logged_id();
  114. $user_id=$this->users->get_main_merchant_id();
  115. $this->db->select('merchant_steps_completed');
  116. $merchant_steps_completed_query = $this->db->get_where('users', array('user_id' => $user_id));
  117. $data_merchant_steps_completed = $merchant_steps_completed_query->result();
  118. $merchant_steps_completed = $data_merchant_steps_completed[0]->merchant_steps_completed;
  119. if($merchant_steps_completed == '0')
  120. {
  121. redirect('/merchantaccount/contactinfo', 'refresh');
  122. }
  123. $this->db->select('id, city_name');
  124. $cityquery = $this->db->get('city');
  125. $this->db->select('state, state_id');
  126. $statequery = $this->db->get('states');
  127. //$this->db->select('type_id, type_name');
  128. //$business_types = $this->db->get('business_types');
  129. $sql_business_types = "SELECT * FROM business_types WHERE (display_status = '1' OR merchant_id = '".$user_id."') and delete_status = '0' ORDER BY type_name ASC ";
  130. $business_types = $this->db->query($sql_business_types);
  131. //$business_types = $query_business_types->result();
  132. $this->db->select('pg_id, pg_name');
  133. $this->db->order_by("pg_id", "desc");
  134. $price_guide_list_options = $this->db->get('price_guide');
  135. $this->db->select('*');
  136. $userquery_check = $this->db->get_where('merchant_businessprofile', array('user_id' => $user_id));
  137. $bt_check = $userquery_check->result();
  138. if(sizeof($bt_check)==0)
  139. {
  140. $ins_mp = array('user_id'=>$user_id);
  141. $this->db->insert('merchant_businessprofile', $ins_mp);
  142. }
  143. $this->db->select('*');
  144. $userquery = $this->db->get_where('merchant_businessprofile', array('user_id' => $user_id));
  145. //echo $this->db->last_query(); die;
  146. //$this->db->select('*');
  147. //$userquery = $this->db->get('merchant_businessprofile');
  148. //$this->db->select('*');
  149. //$opening_hours_query = $this->db->get_where('merchant_opening_hours', array('user_id' => $user_id));
  150. $condition=array('a.user_id' => $user_id);
  151. $this->db->select('a.*');
  152. $this->db->from('merchant_opening_hours as a');
  153. $this->db->join('days as b', 'b.day_name = a.day', 'left');
  154. //$this->db->order_by("b.day_display_order", "asc");
  155. $this->db->order_by('a.time_group ASC, b.day_display_order asc, a.id asc');
  156. $this->db->where($condition);
  157. $opening_hours_query = $this->db->get();
  158. //echo $this->db->last_query(); die;
  159. //$opening_hours_querydata = $opening_hours_query->result();
  160. //print_r($opening_hours_querydata); die;
  161. /*$bt = $userquery->result();
  162. $cat_array = explode(",", $bt[0]->business_type);
  163. $this->db->select('service_id, service');
  164. $this->db->where_in('business_type', $cat_array);
  165. $servicesquery = $this->db->get('services');
  166. $dataservices = $servicesquery->result();*/
  167. $bt = $userquery->result();
  168. $cat_array = explode(",", $bt[0]->business_type);
  169. //$this->db->select('id, option_value');
  170. //$this->db->where_in('business_type', $cat_array);
  171. //$servicesquery = $this->db->get('business_types_options');
  172. //echo $this->db->last_query(); die;
  173. //$dataservices = $servicesquery->result();
  174. if($bt[0]->business_type != '')
  175. {
  176. $query_services = "SELECT id, option_value FROM business_types_options WHERE (business_type IN (".$bt[0]->business_type.") AND display_status = 1) OR ( merchant_id = '".$user_id."' AND display_status = 0) ";
  177. $servicesquery = $this->db->query($query_services);
  178. $dataservices = $servicesquery->result();
  179. }
  180. $service_offered_array = explode(",", $bt[0]->service_offered);
  181. $this->db->select('id, option_value');
  182. $this->db->where_in('id', $service_offered_array);
  183. $service_offered_query = $this->db->get('business_types_options');
  184. if((bool)$this->config->item('test_mode'))
  185. {
  186. //echo $this->db->last_query(); die;
  187. }
  188. $dataservicesoffered = $service_offered_query->result();
  189. $perfect_for_array = explode(",", $bt[0]->perfect_for);
  190. $this->db->select('pf_id, pf_name');
  191. $this->db->where_in('pf_id', $perfect_for_array);
  192. $perfect_for_query = $this->db->get('perfect_for');
  193. //echo $this->db->last_query(); die;
  194. $dataperfectfor = $perfect_for_query->result();
  195. //print_r($dataperfectfor);
  196. $this->db->select('type_name');
  197. $this->db->where_in('type_id', $cat_array);
  198. $businesstypesqueryjk = $this->db->get('business_types');
  199. $databusinesstypesqueryjk = $businesstypesqueryjk->result();
  200. /*$this->db->select('pf_id, pf_name');
  201. $condition=array('delete_status' => '0'); // Note: Zero is for active, 1 is for deleted
  202. $this->db->where($condition);
  203. $perfect_for_list_options = $this->db->get('perfect_for');*/
  204. if($bt[0]->business_type != '')
  205. {
  206. $query_pf = "SELECT * FROM perfect_for WHERE (business_type IN (".$bt[0]->business_type.") AND delete_status = 0) OR pf_name='N/A' ";
  207. $pfquery = $this->db->query($query_pf);
  208. $datapf = $pfquery->result();
  209. }
  210. if($logged_user_access_type=='3')
  211. {
  212. $data = array('city_options' => $cityquery->result(), 'state_options' => $statequery->result(), 'userdata' => $userquery->result(), 'business_types' => $business_types->result(), 'price_guide_list_options' => $price_guide_list_options->result(), 'perfect_for_list_options' => $datapf, 'title' => 'Services on demand - Ondi.com', 'opening_hours_query' => $opening_hours_query->result(), 'dataservices' => $dataservices, 'logged_user_access_type' =>$logged_user_access_type, 'logged_user_access_sections'=>$this->users->get_user_access_sections(), 'databusinesstypesqueryjk' => $databusinesstypesqueryjk, 'dataservicesoffered' => $dataservicesoffered, 'dataperfectfor' => $dataperfectfor);
  213. }else{
  214. $data = array('city_options' => $cityquery->result(), 'state_options' => $statequery->result(), 'userdata' => $userquery->result(), 'business_types' => $business_types->result(), 'price_guide_list_options' => $price_guide_list_options->result(), 'perfect_for_list_options' => $datapf, 'title' => 'Services on demand - Ondi.com', 'opening_hours_query' => $opening_hours_query->result(), 'dataservices' => $dataservices, 'logged_user_access_type' =>$logged_user_access_type, 'logged_user_access_sections'=>array(), 'databusinesstypesqueryjk' => $databusinesstypesqueryjk, 'dataservicesoffered' => $dataservicesoffered, 'dataperfectfor' => $dataperfectfor);
  215. }
  216. $this->form_validation->set_rules('business_name', 'Business Name', 'trim|required');
  217. $this->form_validation->set_rules('website_address', 'Website Address', 'trim|required');
  218. $this->form_validation->set_rules('street_address', 'Street Address', 'trim|required');
  219. $this->form_validation->set_rules('suburb', 'Suburb', 'trim|required');
  220. $this->form_validation->set_rules('post_code', 'Post Code', 'trim|required');
  221. $this->form_validation->set_rules('city', 'City', 'trim|required');
  222. $this->form_validation->set_rules('state', 'State', 'trim|required');
  223. $this->form_validation->set_rules('business_phone', 'Business phone', 'trim|required');
  224. $this->form_validation->set_rules('price_guide', 'Price Guide', 'trim|required');
  225. //$this->form_validation->set_rules('perfect_for', 'Perfect For', 'trim|required');
  226. /*Check if the form passed its validation */
  227. if ($this->form_validation->run() == FALSE) {
  228. $this->load->view('/merchantaccount/businessprofile', $data);
  229. }
  230. else {
  231. if($this->input->post('submit')){
  232. //print_r($_POST);
  233. //print_r($_FILES);
  234. //exit();
  235. $business_name = $this->input->post('business_name');
  236. $website_address = $this->input->post('website_address');
  237. $street_address = $this->input->post('street_address');
  238. $suburb = $this->input->post('suburb');
  239. $post_code = $this->input->post('post_code');
  240. $city = $this->input->post('city');
  241. $state = $this->input->post('state');
  242. $business_phone = $this->input->post('business_phone');
  243. $mobile_number = $this->input->post('mobile_number');
  244. $facebook = $this->input->post('facebook');
  245. $twitter = $this->input->post('twitter');
  246. $linkedin = $this->input->post('linkedin');
  247. $googleplus = $this->input->post('googleplus');
  248. $business_type = $this->input->post('choosen_business_types');
  249. // INSERT ADDITIONAL CATEGORIES IF ANY /////
  250. $num_category = $this->input->post('num_category');
  251. for($nso = 1; $nso<=$num_category; $nso++)
  252. {
  253. $additional_business_category = $this->input->post('additional_cat_'.$nso);
  254. if(trim($additional_business_category) != '')
  255. {
  256. $sql_count_duplicate = "SELECT type_id FROM business_types WHERE (type_name = '".$additional_business_category."' AND display_status = '1') OR ( type_name = '".$additional_business_category."' AND merchant_id = '".$user_id."' )";
  257. $query_count_duplicate = $this->db->query($sql_count_duplicate);
  258. $count_duplicate = $query_count_duplicate->num_rows();
  259. if($count_duplicate==0)
  260. {
  261. $insert_add_cat = array('type_name'=>$additional_business_category, 'display_status' => '0', 'merchant_id' => $user_id);
  262. $this->db->insert('business_types', $insert_add_cat);
  263. $newcategoryid = $this->db->insert_id();
  264. //$emailmessage = "A new category ".$additional_business_category." added. Kindly approve from admin panel.";
  265. $message = '<ul style=" float: left; width: 100%; list-style-type: none; margin: 12px 0; padding: 0px; border: 0;">
  266. <li style=" float: left; width: 100%; margin: 12px 0; padding: 0; border: 0;">
  267. <div style=" float: left; width: 100%; font-size: 19px; color: #6b6766; text-align: left; line-height: 36px; margin: 0 22px 0 0; padding: 0; border: 0;" align="left">Dear Admin, <br/>A new category '.$additional_business_category.' added. Kindly approve from admin panel.</div>
  268. </li>
  269. </ul>';
  270. $emailmessage = '<!DOCTYPE html>
  271. <html style="overflow: hidden; overflow-y: scroll; margin: 0; padding: 0; border: 0;">
  272. <head>
  273. <meta charset="utf-8">
  274. <meta name="viewport" content="width=device-width, initial-scale = 1.0, user-scalable = no">
  275. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  276. <title>ONDI FOOD</title>
  277. </head>
  278. <body style="font-size: 12px; color: #181818; font-family: arial; overflow: hidden; background-color: #fff; margin: 0; padding: 0; border: 0;" bgcolor="#fff">
  279. <div style=" width: 100%; height: auto; float: left; position: relative; background-color: #fff; margin: 0; padding: 0; border: 0;">
  280. <div style=" width: 800px; height: auto; margin: 30px auto; padding: 0; border: 0;">
  281. <div style="padding:0px 0px; margin:0px 0px 20px 0px; text-indent:25px; text-align:right"><img src="'.$this->config->item('base_url').'public/mailerimages/mailer_logo2.jpg" ></div>
  282. <div style=" width: 100%; height: auto; float: left; border-top:1px solid #2d2d2d; border-bottom:1px solid #2d2d2d; margin: 0; padding: 15px 0px; ">
  283. <img src="'.$this->config->item('base_url').'public/mailerimages/admin_notification.jpg">
  284. </div>
  285. <div style=" width: 100%; height: auto; float: left; margin: 30px 0 0; padding: 0; border: 0;">
  286. <div style=" width: 798px; height: auto; float: left; margin: 0; padding: 5px 0px; border: 1px solid #c0bdbd;">
  287. <div style=" height: auto; float: left; width: 92%; font-size: 28px; color: #2d2d2d; font-weight: bold; margin: 0; padding: 25px 32px 0px; "><span style=" font-size: 19px; color: #6b6766; font-weight: normal; margin: 0; padding: 0; border: 0;">'.$message.'</span></div>
  288. </div>
  289. </div>
  290. </div>
  291. </body>
  292. </html>
  293. ';
  294. $this->offers->send_mail("info@ondi.com", "New Category Added", $emailmessage);
  295. //$this->offers->send_mail("jitendra.revolute@gmail.com", "New Category Added", $emailmessage);
  296. if($business_type != '')
  297. {
  298. $business_type = $business_type.",".$newcategoryid;
  299. }
  300. else
  301. {
  302. $business_type = $newcategoryid;
  303. }
  304. }
  305. else
  306. {
  307. $data_check_cat = $query_count_duplicate->result();
  308. $type_id = $data_check_cat[0]->type_id;
  309. if($business_type != '')
  310. {
  311. $explode_business_category = explode(",", $business_type);
  312. if (!in_array($type_id, $explode_business_category)) {
  313. $business_type = $business_type.",".$type_id;
  314. }
  315. }
  316. else
  317. {
  318. $business_type = $type_id;
  319. }
  320. }
  321. }
  322. }
  323. // INSERT ADDITIONAL CATEGORIES IF ANY /////
  324. $old_profile_picture = $this->input->post('old_profile_picture');
  325. $old_supporting_picture = $this->input->post('old_supporting_picture');
  326. $old_widescreen_picture = $this->input->post('old_widescreen_picture');
  327. $old_pdf_menu = $this->input->post('old_pdf_menu');
  328. $service_offered = '';
  329. $services_offered = $this->input->post('services_offered');
  330. for($nso = 0; $nso<=sizeof($services_offered); $nso++)
  331. {
  332. if($services_offered[$nso] != '')
  333. {
  334. $service_offered .= trim($services_offered[$nso]).',';
  335. }
  336. }
  337. if($service_offered != '') $service_offered = substr($service_offered, 0, -1);
  338. // INSERT ADDITIONAL SERVICES OFFERED IF ANY /////
  339. $num_so = $this->input->post('num_so');
  340. for($nso = 1; $nso<=$num_so; $nso++)
  341. {
  342. $additional_so = $this->input->post('additional_so_'.$nso);
  343. if(trim($additional_so) != '')
  344. {
  345. $sql_count_duplicate_so = "SELECT id FROM business_types_options WHERE (option_value = '".$additional_so."' AND display_status = '1') OR ( option_value = '".$additional_so."' AND merchant_id = '".$user_id."' )";
  346. $query_count_duplicate_so = $this->db->query($sql_count_duplicate_so);
  347. $count_duplicate_so = $query_count_duplicate_so->num_rows();
  348. if($count_duplicate_so==0)
  349. {
  350. $insert_add_cat = array('option_value'=>$additional_so, 'display_status' => '0', 'merchant_id' => $user_id);
  351. $this->db->insert('business_types_options', $insert_add_cat);
  352. $newsoid = $this->db->insert_id();
  353. //$emailmessage = "A new service offered ".$additional_so." added. Kindly approve from admin panel.";
  354. $message = '<ul style=" float: left; width: 100%; list-style-type: none; margin: 12px 0; padding: 0px; border: 0;">
  355. <li style=" float: left; width: 100%; margin: 12px 0; padding: 0; border: 0;">
  356. <div style=" float: left; width: 100%; font-size: 19px; color: #6b6766; text-align: left; line-height: 36px; margin: 0 22px 0 0; padding: 0; border: 0;" align="left">Dear Admin, <br/>A new service offered '.$additional_so.' added. Kindly approve from admin panel.</div>
  357. </li>
  358. </ul>';
  359. $emailmessage = '<!DOCTYPE html>
  360. <html style="overflow: hidden; overflow-y: scroll; margin: 0; padding: 0; border: 0;">
  361. <head>
  362. <meta charset="utf-8">
  363. <meta name="viewport" content="width=device-width, initial-scale = 1.0, user-scalable = no">
  364. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  365. <title>ONDI FOOD</title>
  366. </head>
  367. <body style="font-size: 12px; color: #181818; font-family: arial; overflow: hidden; background-color: #fff; margin: 0; padding: 0; border: 0;" bgcolor="#fff">
  368. <div style=" width: 100%; height: auto; float: left; position: relative; background-color: #fff; margin: 0; padding: 0; border: 0;">
  369. <div style=" width: 800px; height: auto; margin: 30px auto; padding: 0; border: 0;">
  370. <div style="padding:0px 0px; margin:0px 0px 20px 0px; text-indent:25px; text-align:right"><img src="'.$this->config->item('base_url').'public/mailerimages/mailer_logo2.jpg" ></div>
  371. <div style=" width: 100%; height: auto; float: left; border-top:1px solid #2d2d2d; border-bottom:1px solid #2d2d2d; margin: 0; padding: 15px 0px; ">
  372. <img src="'.$this->config->item('base_url').'public/mailerimages/admin_notification.jpg">
  373. </div>
  374. <div style=" width: 100%; height: auto; float: left; margin: 30px 0 0; padding: 0; border: 0;">
  375. <div style=" width: 798px; height: auto; float: left; margin: 0; padding: 5px 0px; border: 1px solid #c0bdbd;">
  376. <div style=" height: auto; float: left; width: 92%; font-size: 28px; color: #2d2d2d; font-weight: bold; margin: 0; padding: 25px 32px 0px; "><span style=" font-size: 19px; color: #6b6766; font-weight: normal; margin: 0; padding: 0; border: 0;">'.$message.'</span></div>
  377. </div>
  378. </div>
  379. </div>
  380. </body>
  381. </html>
  382. ';
  383. $this->offers->send_mail("info@ondi.com", "New service offered added", $emailmessage);
  384. //$this->offers->send_mail("jitendra.revolute@gmail.com", "New service offered added", $emailmessage);
  385. if($service_offered != '')
  386. {
  387. $service_offered = $service_offered.",".$newsoid;
  388. }
  389. else
  390. {
  391. $service_offered = $newsoid;
  392. }
  393. }
  394. }
  395. }
  396. // INSERT ADDITIONAL SERVICES OFFERED IF ANY /////
  397. $price_guide = $this->input->post('price_guide');
  398. $perfect_for = $this->input->post('perfect_for');
  399. $confirmation_methods_array = $this->input->post('confirmation_methods');
  400. if(is_array($confirmation_methods_array))
  401. {
  402. $confirmation_methods = implode(",", $confirmation_methods_array);
  403. }
  404. else
  405. {
  406. $confirmation_methods = '';
  407. }
  408. $array_perfect_for = $this->input->post('perfect_for');
  409. if(is_array($array_perfect_for))
  410. {
  411. $perfect_for = implode(",", $array_perfect_for);
  412. }
  413. else
  414. {
  415. $perfect_for = '';
  416. }
  417. $sql_cityname = "SELECT city_name FROM city WHERE id ='".$city."' ";
  418. $exe_cityname = $this->db->query($sql_cityname);
  419. $data_cityname = $exe_cityname->result();
  420. $city_name = $data_cityname[0]->city_name;
  421. $sql_statename = "SELECT state FROM states WHERE state_id ='".$state."' ";
  422. $exe_statename = $this->db->query($sql_statename);
  423. $data_statename = $exe_statename->result();
  424. $state_name = $data_statename[0]->state;
  425. $about_business = $this->input->post('about_business');
  426. $parking_details = $this->input->post('parking_details');
  427. $street_address_map = str_replace(" ", "+", $street_address);
  428. $suburb_map = str_replace(" ", "+", $suburb);
  429. $post_code_map = str_replace(" ", "+", $post_code);
  430. $city_name_map = str_replace(" ", "+", $city_name);
  431. $state_name_map = str_replace(" ", "+", $state_name);
  432. $url='http://maps.googleapis.com/maps/api/geocode/json?address='.$street_address_map.'+'.$suburb_map.'+'.$post_code_map.'+'.$city_name_map.'+'.$state_name_map.'&sensor=false';
  433. //$source = file_get_contents($url);
  434. $ch = curl_init();
  435. curl_setopt($ch, CURLOPT_URL, $url);
  436. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  437. curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
  438. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  439. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  440. $response = curl_exec($ch);
  441. curl_close($ch);
  442. $obj = json_decode($response);
  443. if((bool)$this->config->item('test_mode'))
  444. {
  445. //echo $url;
  446. //print_r($response); die;
  447. }
  448. if(isset($obj))
  449. {
  450. $lat = $obj->results[0]->geometry->location->lat;
  451. $long = $obj->results[0]->geometry->location->lng;
  452. }
  453. else
  454. {
  455. $lat = "-35.283333";
  456. $long = "149.216667";
  457. }
  458. /*
  459. $config_image['upload_path'] = 'public/uploads/';
  460. $config_image['allowed_types'] = 'gif|jpg|png';
  461. $config_image['max_size'] = '1000';
  462. $config_image['max_width'] = '500';
  463. $config_image['max_height'] = '400';
  464. $this->load->library('upload', $config_image);
  465. $this->upload->initialize($config_image);
  466. $this->upload->set_allowed_types('*');
  467. if ($this->upload->do_upload('profile_picture')) {
  468. $data_profile_picture = $this->upload->data();
  469. $image_profile_picture = $data_profile_picture['file_name'];
  470. $profile_picture = $config_image['upload_path'].$data_profile_picture['file_name'];
  471. }
  472. else
  473. {
  474. $profile_picture = $old_profile_picture;
  475. //$profile_picture = '';
  476. }
  477. if ($this->upload->do_upload('supporting_picture')) {
  478. $data_supporting_picture = $this->upload->data();
  479. $image_supporting_picture = $data_supporting_picture['file_name'];
  480. $supporting_picture = $config_image['upload_path'].$data_supporting_picture['file_name'];
  481. }
  482. else
  483. {
  484. $supporting_picture = $old_supporting_picture;
  485. //$supporting_picture = '';
  486. }
  487. if ($this->upload->do_upload('widescreen_picture')) {
  488. $data_widescreen_picture = $this->upload->data();
  489. $image_widescreen_picture = $data_widescreen_picture['file_name'];
  490. $widescreen_picture = $config_image['upload_path'].$data_widescreen_picture['file_name'];
  491. }
  492. else
  493. {
  494. $widescreen_picture = $old_widescreen_picture;
  495. //$supporting_picture = '';
  496. }
  497. */
  498. $temp_profile_picture = $this->input->post('temp_profile_picture');
  499. $temp_supporting_picture = $this->input->post('temp_supporting_picture');
  500. $temp_widescreen_picture = $this->input->post('temp_widescreen_picture');
  501. $old_profile_picture = $this->input->post('old_profile_picture');
  502. $old_supporting_picture = $this->input->post('old_supporting_picture');
  503. $old_widescreen_picture = $this->input->post('old_widescreen_picture');
  504. if($temp_profile_picture != "")
  505. {
  506. $sql_temp_pp = "SELECT * FROM temp_images WHERE id ='".$temp_profile_picture."' ";
  507. $exe_temp_pp = $this->db->query($sql_temp_pp);
  508. $count_temp_pp = $exe_temp_pp->num_rows();
  509. if($count_temp_pp>0)
  510. {
  511. foreach($exe_temp_pp->result() as $tmp)
  512. {
  513. $profile_picture = $tmp->img_path;
  514. $sql_del= "DELETE FROM temp_images WHERE id ='".$temp_profile_picture."' ";
  515. $exe_del = $this->db->query($sql_del);
  516. @unlink($old_profile_picture);
  517. }
  518. }
  519. }
  520. else
  521. {
  522. $profile_picture = $old_profile_picture;
  523. }
  524. if($temp_supporting_picture != "")
  525. {
  526. $sql_temp_pp = "SELECT * FROM temp_images WHERE id ='".$temp_supporting_picture."' ";
  527. $exe_temp_pp = $this->db->query($sql_temp_pp);
  528. $count_temp_pp = $exe_temp_pp->num_rows();
  529. if($count_temp_pp>0)
  530. {
  531. foreach($exe_temp_pp->result() as $tmp)
  532. {
  533. $supporting_picture = $tmp->img_path;
  534. $sql_del= "DELETE FROM temp_images WHERE id ='".$temp_supporting_picture."' ";
  535. $exe_del = $this->db->query($sql_del);
  536. @unlink($old_supporting_picture);
  537. }
  538. }
  539. }
  540. else
  541. {
  542. $supporting_picture = $old_supporting_picture;
  543. }
  544. if($temp_widescreen_picture != "")
  545. {
  546. $sql_temp_pp = "SELECT * FROM temp_images WHERE id ='".$temp_widescreen_picture."' ";
  547. $exe_temp_pp = $this->db->query($sql_temp_pp);
  548. $count_temp_pp = $exe_temp_pp->num_rows();
  549. if($count_temp_pp>0)
  550. {
  551. foreach($exe_temp_pp->result() as $tmp)
  552. {
  553. $widescreen_picture = $tmp->img_path;
  554. $sql_del= "DELETE FROM temp_images WHERE id ='".$temp_widescreen_picture."' ";
  555. $exe_del = $this->db->query($sql_del);
  556. @unlink($old_widescreen_picture);
  557. }
  558. }
  559. }
  560. else
  561. {
  562. $widescreen_picture = $old_widescreen_picture;
  563. }
  564. //die;
  565. $config_pdf['upload_path'] = 'public/uploads/pdf/';
  566. $config_pdf['allowed_types'] = 'pdf';
  567. $config_pdf['max_size'] = '1000';
  568. $this->load->library('upload', $config_pdf);
  569. $this->upload->initialize($config_pdf);
  570. $this->upload->set_allowed_types('*');
  571. if ($this->upload->do_upload('pdf_menu')) {
  572. $data_pdf_menu = $this->upload->data();
  573. //print_r($data_pdf_menu);
  574. $file_pdf_menu = $data_pdf_menu['file_name'];
  575. $pdf_menu = $config_pdf['upload_path'].$file_pdf_menu;
  576. }
  577. else
  578. {
  579. $pdf_menu = $old_pdf_menu;
  580. //$pdf_menu = '';
  581. }
  582. //echo $file_pdf_menu['file_name'];
  583. $data_insert = array(
  584. 'user_id' => $user_id,
  585. 'business_name' => $business_name,
  586. 'website_address' => $website_address,
  587. 'street_address' => $street_address,
  588. 'suburb' => $suburb,
  589. 'post_code' => $post_code,
  590. 'city' => $city,
  591. 'state' => $state,
  592. 'business_phone' => $business_phone,
  593. 'mobile_number' => $mobile_number,
  594. 'facebook' => $facebook,
  595. 'twitter' => $twitter,
  596. 'linkedin' => $linkedin,
  597. 'googleplus' => $googleplus,
  598. 'business_type' => $business_type,
  599. 'service_offered' => $service_offered,
  600. 'price_guide' => $price_guide,
  601. 'perfect_for' => $perfect_for,
  602. 'confirmation_methods' => $confirmation_methods,
  603. 'about_business' => $about_business,
  604. 'parking_details' => $parking_details,
  605. 'profile_picture' => $profile_picture,
  606. 'supporting_picture' => $supporting_picture,
  607. 'widescreen_picture' => $widescreen_picture,
  608. 'pdf_menu' => $pdf_menu,
  609. 'lat' => $lat,
  610. 'long' => $long
  611. );
  612. $data_update = array(
  613. 'business_name' => $business_name,
  614. 'website_address' => $website_address,
  615. 'street_address' => $street_address,
  616. 'suburb' => $suburb,
  617. 'post_code' => $post_code,
  618. 'city' => $city,
  619. 'state' => $state,
  620. 'business_phone' => $business_phone,
  621. 'mobile_number' => $mobile_number,
  622. 'facebook' => $facebook,
  623. 'twitter' => $twitter,
  624. 'linkedin' => $linkedin,
  625. 'googleplus' => $googleplus,
  626. 'business_type' => $business_type,
  627. 'service_offered' => $service_offered,
  628. 'price_guide' => $price_guide,
  629. 'perfect_for' => $perfect_for,
  630. 'confirmation_methods' => $confirmation_methods,
  631. 'about_business' => $about_business,
  632. 'parking_details' => $parking_details,
  633. 'profile_picture' => $profile_picture,
  634. 'supporting_picture' => $supporting_picture,
  635. 'widescreen_picture' => $widescreen_picture,
  636. 'pdf_menu' => $pdf_menu,
  637. 'lat' => $lat,
  638. 'long' => $long
  639. );
  640. if((bool)$this->config->item('test_mode'))
  641. {
  642. //print_r($data_update); die;
  643. }
  644. $query = $this->db->get_where('merchant_businessprofile', array('user_id' => $user_id));
  645. $count= $query->num_rows();
  646. //echo $count; die;
  647. if($count === 0)
  648. {
  649. $this->db->insert('merchant_businessprofile', $data_insert);
  650. }
  651. else
  652. {
  653. $this->db->where('user_id', $user_id);
  654. $this->db->update('merchant_businessprofile', $data_update);
  655. }
  656. //print_r($_POST);
  657. //exit();
  658. for($no=1; $no<=7; $no++)
  659. {
  660. if(isset($_POST['oh_'.$no]))
  661. {
  662. $arroh = $_POST['oh_'.$no];
  663. $selected_days_for_this_time_group = "";
  664. for($jk=0; $jk<sizeof($arroh); $jk++)
  665. {
  666. $dayrecord = $arroh[$jk];
  667. $from = $this->input->post('from_'.$no);
  668. $from_ampm = $this->input->post('from_ampm_'.$no);
  669. $to = $this->input->post('to_'.$no);
  670. $to_ampm = $this->input->post('to_ampm_'.$no);
  671. $timinings_id = $this->input->post('timinings_id_'.$no);
  672. $time_group = $this->input->post('time_group_'.$no);
  673. if($dayrecord =='Mo') $day = "monday";
  674. else if($dayrecord =='Tu') $day = "tuesday";
  675. else if($dayrecord =='We') $day = "wednesday";
  676. else if($dayrecord =='Th') $day = "thursday";
  677. else if($dayrecord =='Fr') $day = "friday";
  678. else if($dayrecord =='Sa') $day = "saturday";
  679. else if($dayrecord =='Su') $day = "sunday";
  680. $selected_days_for_this_time_group .= "'".$day."',";
  681. if($time_group == "")
  682. {
  683. // INSERT ENTRY FOR NEW TIME GROUP
  684. $time_group = $no;
  685. $query_insert_oh = "INSERT INTO merchant_opening_hours SET user_id = '".$user_id."', day = '".$day."' , from_hour = '".$from."' , from_ampm = '".$from_ampm."' , to_hour = '".$to."' , to_ampm = '".$to_ampm."' , time_group = '".$time_group."' ";
  686. $exe_query_insert_oh = $this->db->query($query_insert_oh);
  687. //////////// VIKAS CODE STARTS /////////////
  688. $last_opening_insert_id = $this->db->insert_id();
  689. $distinct_offer_id = $this->users->get_distinct_offer_id_having_moh_id();
  690. foreach($distinct_offer_id as $offer_val)
  691. {
  692. $offer_id = $offer_val->offer_id;
  693. if(!empty($offer_id))
  694. {
  695. if($update_existing_offers=='1')
  696. {
  697. //***** inserting opening hours in existing merchant_offers_available_time start *******//
  698. if($from_ampm=='am' || $from_ampm=='AM')
  699. {
  700. if($from==12)
  701. {
  702. $from_hours = '0000';
  703. }
  704. else
  705. {
  706. $from_hours = $from * 100;
  707. if($from>=1 && $from<=9)
  708. {
  709. $from_hours = '0'.$from_hours;
  710. }
  711. }
  712. }
  713. else if($from_ampm=='pm' || $from_ampm=='PM')
  714. {
  715. if($from==12)
  716. {
  717. $from_hours = '1200';
  718. }
  719. else
  720. {
  721. $from_hours = 1200 + ($from * 100);
  722. }
  723. }
  724. if($to_ampm=='am' || $to_ampm=='AM')
  725. {
  726. if($to==12)
  727. {
  728. $to_hours = '0000';
  729. }
  730. else
  731. {
  732. $to_hours = $to * 100;
  733. if($to>=1 && $to<=9)
  734. {
  735. $to_hours = '0'.$to_hours;
  736. }
  737. }
  738. }
  739. else if($to_ampm=='pm' || $to_ampm=='PM')
  740. {
  741. if($to==12)
  742. {
  743. $to_hours = '1200';
  744. }
  745. else
  746. {
  747. $to_hours = 1200 + ($to * 100);
  748. }
  749. }
  750. $days_display_order='';
  751. if($day=='monday')
  752. {
  753. $days_display_order = '1';
  754. }
  755. else if($day=='tuesday')
  756. {
  757. $days_display_order = '2';
  758. }
  759. else if($day=='wednesday')
  760. {
  761. $days_display_order = '3';
  762. }
  763. else if($day=='thursday')
  764. {
  765. $days_display_order = '4';
  766. }
  767. else if($day=='friday')
  768. {
  769. $days_display_order = '5';
  770. }
  771. else if($day=='saturday')
  772. {
  773. $days_display_order = '6';
  774. }
  775. else if($day=='sunday')
  776. {
  777. $days_display_order = '7';
  778. }
  779. $available_time_data = array(
  780. 'offer_id' => $offer_id,
  781. 'merchant_id' => $user_id,
  782. 'available_day' => $day,
  783. 'time_from' => $from,
  784. 'time_from_am_pm' => $from_ampm,
  785. 'from_hours' => $from_hours,
  786. 'time_to' => $to,
  787. 'time_to_am_pm' => $to_ampm,
  788. 'to_hours' => $to_hours,
  789. 'quantity' => '1',
  790. 'max_pax' => '',
  791. 'added_date' => date('Y-m-d H:i:s'),
  792. 'available_time_slots_capacity' => '3',
  793. 'days_display_order' => $days_display_order,
  794. 'moh_id' => $last_opening_insert_id
  795. );
  796. if(!empty($offer_id))
  797. {
  798. $this->db->insert('merchant_offers_available_time', $available_time_data);
  799. }
  800. //***** inserting opening hours in existing merchant_offers_available_time start *******//
  801. }
  802. }
  803. }
  804. ////////// VIKAS CODE ENDS //////////
  805. }
  806. else
  807. {
  808. // UPDATE ENTRY FOR OLD TIME GROUP
  809. $query_select_db_oh = "SELECT id FROM merchant_opening_hours WHERE time_group = '".$time_group."' AND user_id = '".$user_id."' AND day = '".$day."' ";
  810. $exe_query_select_db_oh = $this->db->query($query_select_db_oh);
  811. $data_query_select_db_oh = $exe_query_select_db_oh->result();
  812. $entry_id = $data_query_select_db_oh[0]->id;
  813. if($entry_id != '')
  814. {
  815. $query_update_oh = "UPDATE merchant_opening_hours SET from_hour = '".$from."' , from_ampm = '".$from_ampm."' , to_hour = '".$to."' , to_ampm = '".$to_ampm."' WHERE time_group = '".$time_group."' AND user_id = '".$user_id."' AND day = '".$day."' ";
  816. $exe_query_update_oh = $this->db->query($query_update_oh);
  817. ///////// VIKAS CODE STARTS ///////////
  818. //*************************** updating existing merchant_offers_available_time start ***************************//
  819. if($from_ampm=='am' || $from_ampm=='AM')
  820. {
  821. if($from==12)
  822. {
  823. $from_hours = '0000';
  824. }
  825. else
  826. {
  827. $from_hours = $from * 100;
  828. if($from>=1 && $from<=9)
  829. {
  830. $from_hours = '0'.$from_hours;
  831. }
  832. }
  833. }
  834. else if($from_ampm=='pm' || $from_ampm=='PM')
  835. {
  836. if($from==12)
  837. {
  838. $from_hours = '1200';
  839. }
  840. else
  841. {
  842. $from_hours = 1200 + ($from * 100);
  843. }
  844. }
  845. if($to_ampm=='am' || $to_ampm=='AM')
  846. {
  847. if($to==12)
  848. {
  849. $to_hours = '0000';
  850. }
  851. else
  852. {
  853. $to_hours = $to * 100;
  854. if($to>=1 && $to<=9)
  855. {
  856. $to_hours = '0'.$to_hours;
  857. }
  858. }
  859. }
  860. else if($to_ampm=='pm' || $to_ampm=='PM')
  861. {
  862. if($to==12)
  863. {
  864. $to_hours = '1200';
  865. }
  866. else
  867. {
  868. $to_hours = 1200 + ($to * 100);
  869. }
  870. }
  871. $available_time_data = array(
  872. 'time_from' => $from,
  873. 'time_from_am_pm' => $from_ampm,
  874. 'from_hours' => $from_hours,
  875. 'time_to' => $to,
  876. 'time_to_am_pm' => $to_ampm,
  877. 'to_hours' => $to_hours,
  878. 'added_date' => date('Y-m-d H:i:s')
  879. );
  880. $this->db->where(array('merchant_id'=>$user_id, 'available_time_slots_capacity'=>3, 'moh_id'=>$timinings_id ));
  881. $this->db->update('merchant_offers_available_time', $available_time_data);
  882. //*************************** updating existing merchant_offers_available_time end ***************************//
  883. ///////// VIKAS CODE ENDS //////////////
  884. }
  885. else
  886. {
  887. $query_insert_oh = "INSERT INTO merchant_opening_hours SET user_id = '".$user_id."', day = '".$day."' , from_hour = '".$from."' , from_ampm = '".$from_ampm."' , to_hour = '".$to."' , to_ampm = '".$to_ampm."' , time_group = '".$time_group."' ";
  888. $exe_query_insert_oh = $this->db->query($query_insert_oh);
  889. //////////// VIKAS CODE STARTS /////////////
  890. $last_opening_insert_id = $this->db->insert_id();
  891. $distinct_offer_id = $this->users->get_distinct_offer_id_having_moh_id();
  892. foreach($distinct_offer_id as $offer_val)
  893. {
  894. $offer_id = $offer_val->offer_id;
  895. if(!empty($offer_id))
  896. {
  897. if($update_existing_offers=='1')
  898. {
  899. //***** inserting opening hours in existing merchant_offers_available_time start *******//
  900. if($from_ampm=='am' || $from_ampm=='AM')
  901. {
  902. if($from==12)
  903. {
  904. $from_hours = '0000';
  905. }
  906. else
  907. {
  908. $from_hours = $from * 100;
  909. if($from>=1 && $from<=9)
  910. {
  911. $from_hours = '0'.$from_hours;
  912. }
  913. }
  914. }
  915. else if($from_ampm=='pm' || $from_ampm=='PM')
  916. {
  917. if($from==12)
  918. {
  919. $from_hours = '1200';
  920. }
  921. else
  922. {
  923. $from_hours = 1200 + ($from * 100);
  924. }
  925. }
  926. if($to_ampm=='am' || $to_ampm=='AM')
  927. {
  928. if($to==12)
  929. {
  930. $to_hours = '0000';
  931. }
  932. else
  933. {
  934. $to_hours = $to * 100;
  935. if($to>=1 && $to<=9)
  936. {
  937. $to_hours = '0'.$to_hours;
  938. }
  939. }
  940. }
  941. else if($to_ampm=='pm' || $to_ampm=='PM')
  942. {
  943. if($to==12)
  944. {
  945. $to_hours = '1200';
  946. }
  947. else
  948. {
  949. $to_hours = 1200 + ($to * 100);
  950. }
  951. }
  952. $days_display_order='';
  953. if($day=='monday')
  954. {
  955. $days_display_order = '1';
  956. }
  957. else if($day=='tuesday')
  958. {
  959. $days_display_order = '2';
  960. }
  961. else if($day=='wednesday')
  962. {
  963. $days_display_order = '3';
  964. }
  965. else if($day=='thursday')
  966. {
  967. $days_display_order = '4';
  968. }
  969. else if($day=='friday')
  970. {
  971. $days_display_order = '5';
  972. }
  973. else if($day=='saturday')
  974. {
  975. $days_display_order = '6';
  976. }
  977. else if($day=='sunday')
  978. {
  979. $days_display_order = '7';
  980. }
  981. $available_time_data = array(
  982. 'offer_id' => $offer_id,
  983. 'merchant_id' => $user_id,
  984. 'available_day' => $day,
  985. 'time_from' => $from,
  986. 'time_from_am_pm' => $from_ampm,
  987. 'from_hours' => $from_hours,
  988. 'time_to' => $to,
  989. 'time_to_am_pm' => $to_ampm,
  990. 'to_hours' => $to_hours,
  991. 'quantity' => '1',
  992. 'max_pax' => '',
  993. 'added_date' => date('Y-m-d H:i:s'),
  994. 'available_time_slots_capacity' => '3',
  995. 'days_display_order' => $days_display_order,
  996. 'moh_id' => $last_opening_insert_id
  997. );
  998. if(!empty($offer_id))
  999. {
  1000. $this->db->insert('merchant_offers_available_time', $available_time_data);
  1001. }
  1002. //***** inserting opening hours in existing merchant_offers_available_time start *******//
  1003. }
  1004. }
  1005. }
  1006. ////////// VIKAS CODE ENDS //////////
  1007. }
  1008. }
  1009. }
  1010. // DELETE THE RECORD FROM DB IF USER NOT SELECTED THE DAY FOR THIS TIME GROUP
  1011. if($selected_days_for_this_time_group != '')
  1012. {
  1013. $selected_days_for_this_time_group = substr($selected_days_for_this_time_group, 0, -1);
  1014. $query_select_deleteable_oh = "SELECT id FROM merchant_opening_hours WHERE time_group = '".$time_group."' AND user_id = '".$user_id."' AND day NOT IN (".$selected_days_for_this_time_group.")";
  1015. $exe_query_select_deleteable_oh = $this->db->query($query_select_deleteable_oh);
  1016. $data_query_select_deleteable_oh = $exe_query_select_deleteable_oh->result();
  1017. foreach($data_query_select_deleteable_oh as $this_deleteable_oh)
  1018. {
  1019. $id_to_del = $this_deleteable_oh->id;
  1020. $query_delete_oh = "DELETE FROM merchant_opening_hours WHERE id = '".$id_to_del."' ";
  1021. $exe_qquery_delete_oh = $this->db->query($query_delete_oh);
  1022. }
  1023. }
  1024. }
  1025. else
  1026. {
  1027. $time_group = $_POST['time_group_'.$no];
  1028. if($time_group != "")
  1029. {
  1030. $query_delete_oh = "DELETE FROM merchant_opening_hours WHERE time_group = '".$time_group."' AND user_id = '".$user_id."' ";
  1031. $exe_qquery_delete_oh = $this->db->query($query_delete_oh);
  1032. }
  1033. }
  1034. }
  1035. if($merchant_steps_completed == '1')
  1036. {
  1037. $steps_completed_update = array(
  1038. 'merchant_steps_completed' => '2'
  1039. );
  1040. $this->db->where('user_id', $user_id);
  1041. $this->db->update('users', $steps_completed_update);
  1042. redirect('/merchantaccount/bankingdetails', 'refresh');
  1043. }
  1044. else
  1045. {
  1046. redirect('/merchantaccount/viewbusinessprofile', 'refresh');
  1047. }
  1048. }
  1049. }
  1050. }
  1051. public function bankingdetails()
  1052. {
  1053. /* USER ACCESS TYPE CHECK DATA START */
  1054. $logged_user_access_type = $this->users->get_user_access_type();
  1055. $data['logged_user_access_type'] = $logged_user_access_type;
  1056. $data['logged_user_access_sections'] = array();
  1057. if($logged_user_access_type=='3')
  1058. {
  1059. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  1060. }
  1061. /* USER ACCESS TYPE CHECK DATA END */
  1062. $user_id='';
  1063. // $user_id=$this->CI_auth->logged_id();
  1064. $user_id=$this->users->get_main_merchant_id();
  1065. $data['title'] = 'Services on demand - Ondi.com';
  1066. // $user_id = $this->CI_auth->logged_id();
  1067. $user_id = $this->users->get_main_merchant_id();
  1068. $this->db->select('branch_name, account_name, bsb, account_number, abn, merchant_steps_completed');
  1069. $query = $this->db->get_where('users', array('user_id' => $user_id));
  1070. $data['user_data'] = $query->result();
  1071. $merchant_steps_completed=$data['user_data'][0]->merchant_steps_completed;
  1072. if($merchant_steps_completed==1)
  1073. {
  1074. redirect('/merchantaccount/businessprofile', 'refresh');
  1075. }
  1076. $this->form_validation->set_rules('branch_name', 'Branch name', 'trim|required');
  1077. $this->form_validation->set_rules('account_name', 'Account name', 'trim|required');
  1078. $this->form_validation->set_rules('bsb', 'BSB', 'trim|required');
  1079. $this->form_validation->set_rules('account_number', 'Account Number', 'trim|required');
  1080. $this->form_validation->set_rules('abn', 'ABN', 'trim|required');
  1081. if ($this->form_validation->run() == FALSE) {
  1082. $this->load->view('/merchantaccount/bankingdetails', $data);
  1083. }
  1084. else{
  1085. if($this->input->post('bank_detail_action')){
  1086. $branch_name = $this->input->post('branch_name');
  1087. $account_name = $this->input->post('account_name');
  1088. $bsb = $this->input->post('bsb');
  1089. $account_number = $this->input->post('account_number');
  1090. $abn = $this->input->post('abn');
  1091. if($merchant_steps_completed==2)
  1092. {
  1093. $data = array(
  1094. 'branch_name' => $branch_name,
  1095. 'account_name' => $account_name,
  1096. 'bsb' => $bsb,
  1097. 'account_number' => $account_number,
  1098. 'abn' => $abn,
  1099. 'merchant_steps_completed' => 3
  1100. );
  1101. $this->db->where('user_id', $user_id);
  1102. $this->db->update('users', $data);
  1103. redirect('/merchantaccount/profilecompleted', 'refresh');
  1104. }else{
  1105. $data = array(
  1106. 'branch_name' => $branch_name,
  1107. 'account_name' => $account_name,
  1108. 'bsb' => $bsb,
  1109. 'account_number' => $account_number,
  1110. 'abn' => $abn
  1111. );
  1112. $this->db->where('user_id', $user_id);
  1113. $this->db->update('users', $data);
  1114. redirect('/merchantaccount/viewbankingdetails', 'refresh');
  1115. }
  1116. }
  1117. }
  1118. }
  1119. public function profilecompleted()
  1120. {
  1121. $user_id='';
  1122. // $user_id=$this->CI_auth->logged_id();
  1123. $user_id=$this->users->get_main_merchant_id();
  1124. /* USER ACCESS TYPE CHECK DATA START */
  1125. $logged_user_access_type = $this->users->get_user_access_type();
  1126. $data['logged_user_access_type'] = $logged_user_access_type;
  1127. $data['logged_user_access_sections'] = array();
  1128. if($logged_user_access_type=='3')
  1129. {
  1130. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  1131. }
  1132. /* USER ACCESS TYPE CHECK DATA END */
  1133. $data['users_data'] = $this->users->get_userslist();
  1134. $this->load->view('/merchantaccount/profilecompleted', $data);
  1135. }
  1136. public function welcomeuser()
  1137. {
  1138. $user_id='';
  1139. // $user_id=$this->CI_auth->logged_id();
  1140. $user_id=$this->users->get_main_merchant_id();
  1141. /* USER ACCESS TYPE CHECK DATA START */
  1142. $logged_user_access_type = $this->users->get_user_access_type();
  1143. $data['logged_user_access_type'] = $logged_user_access_type;
  1144. $data['logged_user_access_sections'] = array();
  1145. if($logged_user_access_type=='3')
  1146. {
  1147. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  1148. }
  1149. /* USER ACCESS TYPE CHECK DATA END */
  1150. $data['users_data'] = $this->users->get_userslist();
  1151. $this->load->view('/merchantaccount/welcomeuser', $data);
  1152. }
  1153. public function getservices()
  1154. {
  1155. $bt = $this->input->post('bt');
  1156. if($bt != '')
  1157. {
  1158. $cat_array = explode(",", $bt);
  1159. $this->db->select('id, option_value');
  1160. $this->db->where_in('business_type', $cat_array);
  1161. $servicesquery = $this->db->get('business_types_options');
  1162. //echo $this->db->last_query();
  1163. $dataservices = $servicesquery->result();
  1164. $business_type_list = array();
  1165. $strreturn = '<ul id="checkboxesgroupso">';
  1166. foreach($dataservices as $row)
  1167. {
  1168. $chk = '';
  1169. if(in_array('.$row->id.', '.$array_service_offered.'))
  1170. {
  1171. $chk = "checked='checked'";
  1172. }
  1173. $strreturn .= ' <li><input class="class_services_offered" type="checkbox" value="'.$row->id.'" name="services_offered[]" '.$chk.' title="'.$row->option_value.'" onclick="change_so(this);" >'.$row->option_value.'</li>';
  1174. }
  1175. $strreturn .= ' </ul> ';
  1176. if($selectedservicesoffered == '') $selectedservicesoffered = " *Please select";
  1177. $return = '<span><a href="javascript:void(0);" onclick="uncheckall_bp(\'checkboxesgroupso\');">Clear all..</a></span>'.$strreturn.' ';
  1178. }
  1179. else
  1180. {
  1181. $return = '<ul id="checkboxesgroupso"></ul> ';
  1182. }
  1183. echo $return;
  1184. }
  1185. public function getperfectfor()
  1186. {
  1187. $bt = $this->input->post('bt');
  1188. $sql_pf = "SELECT * FROM perfect_for WHERE delete_status = '0' AND business_type IN (".$bt.") OR pf_name='N/A' ORDER BY pf_name ASC ";
  1189. $exe_pf = $this->db->query($sql_pf);
  1190. $data_pf = $exe_pf->result();
  1191. /*$strreturn = '<img src="'.$this->config->item('base_url').'public/images/…

Large files files are truncated, but you can click here to view the full file