PageRenderTime 79ms CodeModel.GetById 8ms RepoModel.GetById 1ms 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
  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/select_flex_arrow.png" border="0"/><div id="div_perfect_for">*Perfect For</div><div class="drop" id="perfectfor_drop3">';
  1192. if(sizeof($data_pf)>0){
  1193. $strreturn .= '<span><a href="javascript:void(0);" onclick="uncheckall_pf(\'checkboxesgrouppf\');">Clear all..</a></span>';
  1194. }
  1195. $strreturn .= '<ul id="checkboxesgrouppf">';*/
  1196. foreach($data_pf as $row)
  1197. {
  1198. $strreturn .= '<li><input class="class_services_offered" type="checkbox" value="'.$row->pf_id.'" name="perfect_for[]" title="'.$row->pf_name.'" onclick="change_pf(this);">'.$row->pf_name.'</li>';
  1199. }
  1200. //$strreturn .= '</ul></div>';
  1201. echo $strreturn;
  1202. }
  1203. public function getperfectforsearch()
  1204. {
  1205. $bt = $this->input->post('bt');
  1206. $sql_pf = "SELECT * FROM perfect_for WHERE delete_status = '0' AND pf_name != 'N/A' AND business_type IN (".$bt.") ORDER BY pf_name ASC ";
  1207. $exe_pf = $this->db->query($sql_pf);
  1208. $data_pf = $exe_pf->result();
  1209. $strreturn = '<li><h4><a href="javascript:void(0);" onclick="uncheckall(\'submenu_nav5\');">Clear all</a></h4></li>';
  1210. foreach($data_pf as $row)
  1211. {
  1212. $strreturn .= '<li><input type="checkbox" class="dd_check search_pf" value="'.$row->pf_id.'" name="search_pf[]" ><p>'.$row->pf_name.'</p></li>';
  1213. }
  1214. echo $strreturn;
  1215. }
  1216. public function userslist()
  1217. {
  1218. /* USER ACCESS TYPE CHECK DATA START */
  1219. $logged_user_access_type = $this->users->get_user_access_type();
  1220. $data['logged_user_access_type'] = $logged_user_access_type;
  1221. $data['logged_user_access_sections'] = array();
  1222. if($logged_user_access_type=='3')
  1223. {
  1224. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  1225. }
  1226. /* USER ACCESS TYPE CHECK DATA END */
  1227. $user_id='';
  1228. $user_id=$this->CI_auth->logged_id();
  1229. $data['title'] = 'Services on demand - Ondi.com';
  1230. $data['users_data'] = $this->users->get_userslist();
  1231. $this->load->view('/merchantaccount/userslist', $data);
  1232. }
  1233. public function getaccessoptions()
  1234. {
  1235. $access_options_arr=array();
  1236. $access_options = $this->input->post('access_options');
  1237. $access_options_arr = explode(",",$access_options);
  1238. $section_type_result = $this->users->get_section_type();
  1239. $i=1;
  1240. $str='';
  1241. foreach($section_type_result as $section_type_val)
  1242. {
  1243. $sections_result=$this->users->get_sections($section_type_val->id);
  1244. $str .= '<div class="box'.$i.' box"><h2>'.stripslashes($section_type_val->title).'</h2><ul>';
  1245. foreach($sections_result as $sections_val)
  1246. {
  1247. if (in_array($sections_val->id, $access_options_arr))
  1248. {
  1249. $selected = 'checked';
  1250. }else{
  1251. $selected = '';
  1252. }
  1253. $str .= '<li><input name="access_sections[]" type="checkbox" value="'.$sections_val->id.'" '.$selected.'>'.stripslashes($sections_val->section_title).'</li>';
  1254. $i++;
  1255. }
  1256. $str .='</ul></div>';
  1257. }
  1258. echo $str;
  1259. }
  1260. public function addusers()
  1261. {
  1262. /* USER ACCESS TYPE CHECK DATA START */
  1263. $logged_user_access_type = $this->users->get_user_access_type();
  1264. $data['logged_user_access_type'] = $logged_user_access_type;
  1265. $data['logged_user_access_sections'] = array();
  1266. if($logged_user_access_type=='3')
  1267. {
  1268. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  1269. }
  1270. /* USER ACCESS TYPE CHECK DATA END */
  1271. $id = '';
  1272. $user_id='';
  1273. $id = $this->input->post('muid');
  1274. if(!empty($id))
  1275. {
  1276. $data['muid']=$id;
  1277. }
  1278. $data['title'] = 'Services on demand - Ondi.com';
  1279. $data['access_type_result'] = $this->users->get_access_type();
  1280. if($this->input->post('add_user_act'))
  1281. {
  1282. $this->form_validation->set_rules('user_email', 'Email', 'trim|required|valid_email');
  1283. if(empty($id))
  1284. {
  1285. $this->form_validation->set_rules('user_password', 'Password', 'trim|required');
  1286. }
  1287. $this->form_validation->set_rules('access_type', 'Access Type', 'trim|required');
  1288. }
  1289. ################################### IN UPDATE MODE ######################################
  1290. if(!empty($id))
  1291. {
  1292. $merchant_user_data = $this->users->get_merchant_user_data($id);
  1293. $data['merchant_user_data'] = $merchant_user_data;
  1294. $user_id = $merchant_user_data[0]->merchant_user_id;
  1295. }
  1296. ################################### IN UPDATE MODE ######################################
  1297. if ($this->form_validation->run() == FALSE) {
  1298. }else{
  1299. if($this->input->post('add_user_act')){
  1300. $user_email = $this->input->post('user_email');
  1301. $user_password = $this->input->post('user_password');
  1302. $access_type = $this->input->post('access_type');
  1303. $access_sections='';
  1304. if($this->input->post('access_sections')>0)
  1305. {
  1306. $access_sections = implode(",",$this->input->post('access_sections'));
  1307. }
  1308. //$user_password=$this->encrypt->encode($user_password);
  1309. $user_email_count = $this->users->users_count_by_email($user_email, $user_id, "2,3");
  1310. if($user_email_count>0)
  1311. {
  1312. if(empty($id))
  1313. {
  1314. $this->session->set_flashdata('email_already_exist', 'Email address already exist. Please try with someother email address.');
  1315. redirect('/merchantaccount/addusers/', 'refresh'); // while update
  1316. }else{
  1317. $this->session->set_flashdata('user_message', 'Email address already exist. Please try with someother email address.');
  1318. redirect('/merchantaccount/userslist/', 'refresh'); // while update
  1319. }
  1320. }else{
  1321. if(!empty($id))
  1322. {
  1323. ################################### IN UPDATE MODE ######################################
  1324. if(!empty($user_password))
  1325. {
  1326. $rand_salt = $this->CI_encrypt->genRndSalt();
  1327. $encrypt_pass = $this->CI_encrypt->encryptUserPwd($user_password, $rand_salt);
  1328. $user_update_data = array('email' => $user_email, 'password' => $encrypt_pass, 'salt'=>$rand_salt);
  1329. }else{
  1330. $user_update_data = array('email' => $user_email);
  1331. }
  1332. $this->db->where('user_id', $user_id);
  1333. $this->db->update('users', $user_update_data);
  1334. $merchant_user_update_data = array('user_access_type' => $access_type, 'user_access_sections' =>$access_sections);
  1335. $this->db->where('id', $id);
  1336. $this->db->update('merchant_users', $merchant_user_update_data);
  1337. //------------------------- sending password to user start -------------------------------------//
  1338. if(!empty($user_password))
  1339. {
  1340. // SEND EMAIL TO USER
  1341. /*$message = "";
  1342. $message .= "";
  1343. $message .= "<br>";
  1344. $message .= "<br>";
  1345. $message .= "<br>";
  1346. $message .= "Username/Email : ".$user_email;
  1347. $message .= "<br>";
  1348. $message .= "Password : ".$user_password;
  1349. $message .= "<br>";
  1350. $message .= "<br>";
  1351. $message .= "Thank you<br>";
  1352. $message .= "Ondi Food<br>";*/
  1353. /*$html_mailer = '<html style="overflow: hidden; overflow-y: scroll; margin: 0; padding: 0; border: 0;"><body style="font-size: 12px; color: #181818; font-family: arial; overflow: hidden; background-color: #fff; margin: 0; padding: 0; border: 0;" bgcolor="#fff"><div style=" width: 100%; height: auto; float: left; position: relative; background-color: #fff; margin: 0; padding: 0; border: 0;"><div style=" width: 800px; height: auto; margin: 30px auto; padding: 0; border: 0;"><div style="padding:0px 0px; margin:0px 0px 20px 0px; text-indent:25px; text-align:right"><img src="<?php echo $config['base_url']; ?>public/mailerimages/mailer_logo2.jpg" ></div><div style=" width: 100%; height: auto; float: left; margin: 30px 0 0; padding: 0; border: 0;"><div style=" width: 798px; height: auto; float: left; margin: 0; padding: 5px 5px; border: 1px solid #c0bdbd;">'.$message.'</div></div></div></div></body></html>';*/
  1354. $message = '<ul style=" float: left; width: 100%; list-style-type: none; margin: 12px 0; padding: 0px; border: 0;">
  1355. <li style=" float: left; width: 100%; margin: 12px 0; padding: 0; border: 0;">
  1356. <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 User, <br/>Your merchant account details are</div>
  1357. </li>
  1358. <li style=" float: left; width: 100%; margin: 12px 0; padding: 0; border: 0;">
  1359. <div style=" float: left; width: 80px; font-size: 19px; color: #6b6766; text-align: right; line-height: 36px; margin: 0 22px 0 0; padding: 0; border: 0;" align="left">Email</div>
  1360. <div style=" color: #2D2D2D; float: left; font-size: 28px; font-weight: bold; line-height: 36px; text-align: left; width: 590px; word-wrap: break-word; margin: 0; padding: 0; border: 0;" align="left">'.$user_email.'</div>
  1361. </li>
  1362. <li style=" float: left; width: 100%; margin: 12px 0; padding: 0; border: 0;">
  1363. <div style=" float: left; width: 80px; font-size: 19px; color: #6b6766; text-align: right; line-height: 36px; margin: 0 22px 0 0; padding: 0; border: 0;" align="left">Password</div>
  1364. <div style=" color: #2D2D2D; float: left; font-size: 28px; font-weight: bold; line-height: 36px; text-align: left; width: 590px; word-wrap: break-word; margin: 0; padding: 0; border: 0;" align="left">'.$user_password.'</div>
  1365. </li>
  1366. </ul>';
  1367. $html_mailer = '<!DOCTYPE html>
  1368. <html style="overflow: hidden; overflow-y: scroll; margin: 0; padding: 0; border: 0;">
  1369. <head>
  1370. <meta charset="utf-8">
  1371. <meta name="viewport" content="width=device-width, initial-scale = 1.0, user-scalable = no">
  1372. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  1373. <title>ONDI FOOD</title>
  1374. </head>
  1375. <body style="font-size: 12px; color: #181818; font-family: arial; overflow: hidden; background-color: #fff; margin: 0; padding: 0; border: 0;" bgcolor="#fff">
  1376. <div style=" width: 100%; height: auto; float: left; position: relative; background-color: #fff; margin: 0; padding: 0; border: 0;">
  1377. <div style=" width: 800px; height: auto; margin: 30px auto; padding: 0; border: 0;">
  1378. <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>
  1379. <div style=" width: 100%; height: auto; float: left; border-top:1px solid #2d2d2d; border-bottom:1px solid #2d2d2d; margin: 0; padding: 15px 0px; ">
  1380. <img src="'.$this->config->item('base_url').'public/mailerimages/merchant_account.jpg">
  1381. </div>
  1382. <div style=" width: 100%; height: auto; float: left; margin: 30px 0 0; padding: 0; border: 0;">
  1383. <div style=" width: 798px; height: auto; float: left; margin: 0; padding: 5px 0px; border: 1px solid #c0bdbd;">
  1384. <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>
  1385. </div>
  1386. </div>
  1387. </div>
  1388. </body>
  1389. </html>
  1390. ';
  1391. /*
  1392. $this->email->from('info@ondi.com', 'ONDI');
  1393. $this->email->to($user_email);
  1394. $this->email->subject('Forgot Password?');
  1395. $this->email->message($html_mailer);
  1396. $this->email->send();
  1397. */
  1398. $subject = "User Updated Login Detail";
  1399. $this->offers->send_mail($user_email, $subject, $html_mailer);
  1400. }
  1401. //------------------------- sending password to user start -------------------------------------//
  1402. $this->session->set_flashdata('user_message', 'Updated successfully.');
  1403. redirect('/merchantaccount/userslist/', 'refresh');
  1404. ################################### IN UPDATE MODE ######################################
  1405. }else{
  1406. $merchant_id = $this->CI_auth->logged_id(); // here don't use get_main_merchant_id() function because we need to save the logged in user id
  1407. $sess_user_data = $this->session->all_userdata();
  1408. /*
  1409. if($sess_user_data['user_type']=='2')
  1410. {
  1411. $main_merchant_id = $merchant_id;
  1412. }else if($sess_user_data['user_type']=='3'){
  1413. $main_merchant_id = $this->users->get_main_merchant_id();
  1414. }
  1415. */
  1416. $main_merchant_id = $this->users->get_main_merchant_id();
  1417. $rand_salt = $this->CI_encrypt->genRndSalt();
  1418. $encrypt_pass = $this->CI_encrypt->encryptUserPwd($user_password, $rand_salt);
  1419. $user_type='3';
  1420. $user_data = array('email' => $user_email, 'password' => $encrypt_pass, 'salt'=>$rand_salt, 'user_type'=>$user_type);
  1421. $this->db->insert('users', $user_data);
  1422. $insert_id = $this->db->insert_id();
  1423. $merchant_user_data = array('merchant_id'=>$merchant_id, 'user_id'=>$insert_id, 'user_access_type' => $access_type, 'user_access_sections' =>$access_sections, 'display_status'=> 1, 'main_merchant_id'=>$main_merchant_id);
  1424. $this->db->insert('merchant_users',$merchant_user_data);
  1425. //------------------------- sending password to user start -------------------------------------//
  1426. // SEND EMAIL TO USER
  1427. /*$message = "";
  1428. $message .= "";
  1429. $message .= "<br>";
  1430. $message .= "<br>";
  1431. $message .= "<br>";
  1432. $message .= "Username/Email : ".$user_email;
  1433. $message .= "<br>";
  1434. $message .= "Password : ".$user_password;
  1435. $message .= "<br>";
  1436. $message .= "<br>";
  1437. $message .= "Thank you<br>";
  1438. $message .= "Ondi Food<br>";
  1439. $html_mailer = '<html style="overflow: hidden; overflow-y: scroll; margin: 0; padding: 0; border: 0;"><body style="font-size: 12px; color: #181818; font-family: arial; overflow: hidden; background-color: #fff; margin: 0; padding: 0; border: 0;" bgcolor="#fff"><div style=" width: 100%; height: auto; float: left; position: relative; background-color: #fff; margin: 0; padding: 0; border: 0;"><div style=" width: 800px; height: auto; margin: 30px auto; padding: 0; border: 0;"><div style="padding:0px 0px; margin:0px 0px 20px 0px; text-indent:25px; text-align:right"><img src="<?php echo $config['base_url']; ?>public/mailerimages/mailer_logo2.jpg" ></div><div style=" width: 100%; height: auto; float: left; margin: 30px 0 0; padding: 0; border: 0;"><div style=" width: 798px; height: auto; float: left; margin: 0; padding: 5px 5px; border: 1px solid #c0bdbd;">'.$message.'</div></div></div></div></body></html>';*/
  1440. $message = '<ul style=" float: left; width: 100%; list-style-type: none; margin: 12px 0; padding: 0px; border: 0;">
  1441. <li style=" float: left; width: 100%; margin: 12px 0; padding: 0; border: 0;">
  1442. <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 User, <br/>Your merchant account details are</div>
  1443. </li>
  1444. <li style=" float: left; width: 100%; margin: 12px 0; padding: 0; border: 0;">
  1445. <div style=" float: left; width: 80px; font-size: 19px; color: #6b6766; text-align: right; line-height: 36px; margin: 0 22px 0 0; padding: 0; border: 0;" align="left">Email</div>
  1446. <div style=" color: #2D2D2D; float: left; font-size: 28px; font-weight: bold; line-height: 36px; text-align: left; width: 590px; word-wrap: break-word; margin: 0; padding: 0; border: 0;" align="left">'.$user_email.'</div>
  1447. </li>
  1448. <li style=" float: left; width: 100%; margin: 12px 0; padding: 0; border: 0;">
  1449. <div style=" float: left; width: 80px; font-size: 19px; color: #6b6766; text-align: right; line-height: 36px; margin: 0 22px 0 0; padding: 0; border: 0;" align="left">Password</div>
  1450. <div style=" color: #2D2D2D; float: left; font-size: 28px; font-weight: bold; line-height: 36px; text-align: left; width: 590px; word-wrap: break-word; margin: 0; padding: 0; border: 0;" align="left">'.$user_password.'</div>
  1451. </li>
  1452. </ul>';
  1453. $html_mailer = '<!DOCTYPE html>
  1454. <html style="overflow: hidden; overflow-y: scroll; margin: 0; padding: 0; border: 0;">
  1455. <head>
  1456. <meta charset="utf-8">
  1457. <meta name="viewport" content="width=device-width, initial-scale = 1.0, user-scalable = no">
  1458. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  1459. <title>ONDI FOOD</title>
  1460. </head>
  1461. <body style="font-size: 12px; color: #181818; font-family: arial; overflow: hidden; background-color: #fff; margin: 0; padding: 0; border: 0;" bgcolor="#fff">
  1462. <div style=" width: 100%; height: auto; float: left; position: relative; background-color: #fff; margin: 0; padding: 0; border: 0;">
  1463. <div style=" width: 800px; height: auto; margin: 30px auto; padding: 0; border: 0;">
  1464. <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>
  1465. <div style=" width: 100%; height: auto; float: left; border-top:1px solid #2d2d2d; border-bottom:1px solid #2d2d2d; margin: 0; padding: 15px 0px; ">
  1466. <img src="'.$this->config->item('base_url').'public/mailerimages/merchant_account.jpg">
  1467. </div>
  1468. <div style=" width: 100%; height: auto; float: left; margin: 30px 0 0; padding: 0; border: 0;">
  1469. <div style=" width: 798px; height: auto; float: left; margin: 0; padding: 5px 0px; border: 1px solid #c0bdbd;">
  1470. <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>
  1471. </div>
  1472. </div>
  1473. </div>
  1474. </body>
  1475. </html>
  1476. ';
  1477. /*
  1478. $this->email->from('info@ondi.com', 'ONDI');
  1479. $this->email->to($user_email);
  1480. $this->email->subject('Forgot Password?');
  1481. $this->email->message($html_mailer);
  1482. $this->email->send();
  1483. */
  1484. $subject = "User Login Detail";
  1485. $this->offers->send_mail($user_email, $subject, $html_mailer);
  1486. //------------------------- sending password to user start -------------------------------------//
  1487. $this->session->set_flashdata('user_message', 'Added successfully.');
  1488. redirect('/merchantaccount/userslist/', 'refresh');
  1489. }
  1490. }
  1491. }
  1492. }
  1493. $this->load->view('/merchantaccount/addusers', $data);
  1494. }
  1495. public function statistics()
  1496. {
  1497. /* USER ACCESS TYPE CHECK DATA START */
  1498. $logged_user_access_type = $this->users->get_user_access_type();
  1499. $data['logged_user_access_type'] = $logged_user_access_type;
  1500. $data['logged_user_access_sections'] = array();
  1501. if($logged_user_access_type=='3')
  1502. {
  1503. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  1504. }
  1505. /* USER ACCESS TYPE CHECK DATA END */
  1506. $user_id='';
  1507. // $merchant_id=$this->CI_auth->logged_id();
  1508. $merchant_id=$this->users->get_main_merchant_id();
  1509. $data['title'] = 'Services on demand - Ondi.com';
  1510. $recent_booking_date = $this->users->most_recent_booking_date();
  1511. $booking_date = $recent_booking_date[0]->booking_date;
  1512. $data['recent_booking_date'] = $booking_date;
  1513. $data['count_last_30days_offers'] = $this->users->count_statistics_for_offers('30days');
  1514. $data['count_lifetime_offers'] = $this->users->count_statistics_for_offers('lifetime');
  1515. $data['count_last_30days_sales'] = $this->users->count_statistics_for_sales('30days');
  1516. $data['count_lifetime_sales'] = $this->users->count_statistics_for_sales('lifetime');
  1517. $count_last_30days_revenue = $this->users->count_statistics_for_revenue('30days');
  1518. $data['count_last_30days_revenue'] = $count_last_30days_revenue[0]->total_revenue;
  1519. $count_lifetime_revenue = $this->users->count_statistics_for_revenue('lifetime');
  1520. $data['count_lifetime_revenue'] = $count_lifetime_revenue[0]->total_revenue;
  1521. $data['average_commission_30days'] = $this->users->get_average_commission('30days');
  1522. $data['average_commission_lifetime'] = $this->users->get_average_commission('lifetime');
  1523. $data['conversion_rate_30days'] = $this->users->get_conversion_rate('30days');
  1524. $data['conversion_rate_lifetime'] = $this->users->get_conversion_rate('lifetime');
  1525. $data['booking_list_view'] = $this->users->get_bookings_list_by_date(strtotime($booking_date));
  1526. $data['count_merchant_best_sellers'] = $this->users->count_merchant_best_sellers();
  1527. $data['merchant_best_sellers'] = $this->users->get_merchant_best_sellers();
  1528. $this->load->view('/merchantaccount/statistics', $data);
  1529. }
  1530. public function addoffers($offer_id="")
  1531. {
  1532. /*
  1533. echo '<pre>';
  1534. print_r($_POST);
  1535. echo '</pre>';
  1536. exit();
  1537. */
  1538. if(!empty($offer_id) || isset($_GET['offer_id']) && $_GET['offer_id']!="" && isset($_GET['act']) && $_GET['act']=='rerun')
  1539. {
  1540. if(isset($sess_user_data['offer_temp_id']) && $sess_user_data['offer_temp_id']!="")
  1541. {
  1542. $this->users->del_merchant_offer_temp($sess_user_data['offer_temp_id']);
  1543. $this->users->del_merchant_offer_available_time_temp($sess_user_data['offer_temp_id']);
  1544. $array_items = array('offer_temp_id' => '', 'offer_main_id'=>'');
  1545. $this->session->unset_userdata($array_items);
  1546. }
  1547. }
  1548. $sess_user_data = $this->session->all_userdata();
  1549. $data['title'] = 'Services on demand - Ondi.com';
  1550. $offer_rerun_id = "";
  1551. /* USER ACCESS TYPE CHECK DATA START */
  1552. $logged_user_access_type = $this->users->get_user_access_type();
  1553. $data['logged_user_access_type'] = $logged_user_access_type;
  1554. $data['logged_user_access_sections'] = array();
  1555. if($logged_user_access_type=='3')
  1556. {
  1557. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  1558. if($logged_user_access_type=='1' || $logged_user_access_type=='2' || in_array("5",$data['logged_user_access_sections']))
  1559. {
  1560. }else{
  1561. redirect('/home', 'refresh');
  1562. exit();
  1563. }
  1564. }
  1565. /* USER ACCESS TYPE CHECK DATA END */
  1566. $data['merchant_liveoffers'] = $this->users->get_offers('liveoffers',$offer_search);
  1567. $different_days_data=array();
  1568. if(isset($sess_user_data['offer_temp_id']) && $sess_user_data['offer_temp_id']!="")
  1569. {
  1570. $offer_id = $sess_user_data['offer_temp_id']; // fetching data from offer temp table.
  1571. $offer_detail = $this->users->get_offer_detail($offer_id,'merchant_offers_temp');
  1572. $data['offer_detail'] = $offer_detail;
  1573. }else{
  1574. // ?offer_id=174&act=rerun
  1575. $offer_rerun_id = $this->input->post('offer_rerun_id');
  1576. if( (isset($_GET['offer_id']) && $_GET['offer_id']!="" && isset($_GET['act']) && $_GET['act']=='rerun') || !empty($offer_rerun_id) )
  1577. {
  1578. if(isset($_GET['offer_id']) && $_GET['offer_id']!="")
  1579. {
  1580. $offer_rerun_id = $_GET['offer_id'];
  1581. }
  1582. if(is_numeric($offer_rerun_id))
  1583. {
  1584. $count_offer_id = $this->users->count_offer_id('merchant_offers',$offer_rerun_id);
  1585. if($count_offer_id>0)
  1586. {
  1587. $offer_detail = $this->users->get_offer_detail($offer_rerun_id); // when user view offer while rerun
  1588. $data['offer_detail'] = $offer_detail;
  1589. $data['offer_action_rerun'] = '1';
  1590. if(isset($_GET['offer_id']) && $_GET['offer_id']!="")
  1591. {
  1592. $data['offer_rerun_id'] = $offer_rerun_id;
  1593. }
  1594. }else{
  1595. redirect('/merchantaccount/offerhistory', 'refresh');
  1596. exit();
  1597. }
  1598. }else{
  1599. redirect('/merchantaccount/offerhistory', 'refresh');
  1600. exit();
  1601. }
  1602. }else{
  1603. if($offer_id!="")
  1604. {
  1605. $offer_detail = $this->users->get_offer_detail($offer_id); // when user view offer in edit mode
  1606. $data['offer_detail'] = $offer_detail;
  1607. }else{
  1608. $offer_id = $this->input->post('offer_id');
  1609. if(!empty($offer_id))
  1610. {
  1611. $offer_detail = $this->users->get_offer_detail($offer_id); // when user update the offer in edit mode
  1612. $data['offer_detail'] = $offer_detail;
  1613. }
  1614. }
  1615. }
  1616. }
  1617. if($offer_id!="" || !empty($offer_rerun_id))
  1618. {
  1619. $atsc='0';
  1620. if(isset($offer_detail[0]->all_day_same_time) && $offer_detail[0]->all_day_same_time=='1')
  1621. {
  1622. $atsc = '1'; // available time slots capacity
  1623. }
  1624. else if(isset($offer_detail[0]->different_days_different_time) && $offer_detail[0]->different_days_different_time=='1')
  1625. {
  1626. $atsc = '2'; // available time slots capacity
  1627. }
  1628. else if( isset($offer_detail[0]->all_opening_hours) && $offer_detail[0]->all_opening_hours=='1' )
  1629. {
  1630. $atsc = '3'; // available time slots capacity
  1631. }
  1632. if(isset($sess_user_data['offer_temp_id']) && $sess_user_data['offer_temp_id']!="")
  1633. {
  1634. $different_days_data = $this->users->get_different_days_data($offer_id,$atsc,'merchant_offers_available_time_temp');
  1635. }else{
  1636. if(!empty($offer_rerun_id))
  1637. {
  1638. $different_days_data = $this->users->get_different_days_data($offer_rerun_id,$atsc); // In rerun situation
  1639. }else{
  1640. $different_days_data = $this->users->get_different_days_data($offer_id,$atsc); // Whhile update mode
  1641. }
  1642. //echo '<pre>';
  1643. //print_r($different_days_data);
  1644. //echo '<pre>';
  1645. //exit();
  1646. }
  1647. $data['different_days_data'] = $different_days_data;
  1648. }
  1649. $merchant_opening_hours = array();
  1650. $merchant_opening_hours = $this->users->get_merchant_opening_hours();
  1651. $data['merchant_opening_hours'] = $merchant_opening_hours;
  1652. $merchant_business_type_str = $this->users->get_merchant_business_type();
  1653. $merchant_business_type = array();
  1654. if(!empty($merchant_business_type_str))
  1655. {
  1656. $merchant_business_type = explode(",",$merchant_business_type_str);
  1657. $data['merchant_business_type'] = $merchant_business_type;
  1658. }
  1659. $max_pax_display_check = 0;
  1660. if(isset($merchant_business_type))
  1661. {
  1662. if(in_array('1',$merchant_business_type))
  1663. {
  1664. $max_pax_display_check = 1;
  1665. }
  1666. }
  1667. /*
  1668. $merchant_opening_hours_days_array = array();
  1669. foreach($merchant_opening_hours as $opening_hours_val){
  1670. if($opening_hours_val->day!="")
  1671. {
  1672. array_push($merchant_opening_hours_days_array,$opening_hours_val->day);
  1673. }
  1674. }
  1675. */
  1676. $this->form_validation->set_rules('offer_title', 'Title', 'trim|required');
  1677. $this->form_validation->set_rules('price', 'Price', 'trim|required');
  1678. $this->form_validation->set_rules('price_normally', 'Price Normally', 'trim|required');
  1679. //$this->form_validation->set_rules('offer_description', 'Short description', 'trim|required');
  1680. $this->form_validation->set_rules('fine_print', 'Fine Print', 'trim');
  1681. /*
  1682. $this->form_validation->set_rules('all_day_time_from', '', 'trim');
  1683. $this->form_validation->set_rules('all_day_time_from_am_pm', '', 'trim');
  1684. $this->form_validation->set_rules('all_day_time_to', '', 'trim');
  1685. $this->form_validation->set_rules('all_day_time_to_am_pm', '', 'trim');
  1686. $this->form_validation->set_rules('all_day_quantity', '', 'trim');
  1687. $this->form_validation->set_rules('all_day_max_pax', '', 'trim');
  1688. */
  1689. if ($this->form_validation->run() == FALSE) {
  1690. //$this->load->view('/merchantaccount/addoffers', $data);
  1691. }
  1692. else{
  1693. $merchant_id = '';
  1694. // $merchant_id = $this->CI_auth->logged_id();
  1695. $merchant_id = $this->users->get_main_merchant_id();
  1696. $offer_check_by_admin='0'; // 1 means admin need to check first then offer will be published.
  1697. /////////////////////////////////// 4.6.2014 ////////////////////////////////////////////////////////////////
  1698. ////////////////// Check the global settings offer_check_by_admin is set to 1 or 0 /////////////////////////
  1699. $sql_global_offer_check_by_admin = "SELECT offer_check_by_admin FROM ondi_admin WHERE mgmt_id = '1' ";
  1700. $exe_global_offer_check_by_admin = $this->db->query($sql_global_offer_check_by_admin);
  1701. $data_global_offer_check_by_admin = $exe_global_offer_check_by_admin->result();
  1702. $offer_check_by_admin = $data_global_offer_check_by_admin[0]->offer_check_by_admin;
  1703. ////////////////// Check the merchant specific settings offer_approval is set to 1 or 0 /////////////////////////
  1704. $sql_merchant_offer_check_by_admin = "SELECT offer_approval FROM users WHERE user_id = '".$merchant_id."' ";
  1705. $exe_merchant_offer_check_by_admin = $this->db->query($sql_merchant_offer_check_by_admin);
  1706. $data_merchant_offer_check_by_admin = $exe_merchant_offer_check_by_admin->result();
  1707. $offer_approval = $data_merchant_offer_check_by_admin[0]->offer_approval;
  1708. if($offer_approval == '2') // decline by admin for merchant
  1709. {
  1710. $offer_check_by_admin='1'; //means admin need to check first then offer will be published.
  1711. }
  1712. else if($offer_approval == '1') // accept by admin for merchant
  1713. {
  1714. $offer_check_by_admin='0'; //means offer will be published automatically.
  1715. }
  1716. /////////////////////////////////// 4.6.2014 ////////////////////////////////////////////////////////////////
  1717. $offer_running_today='';
  1718. $offer_multiple_dates='';
  1719. $offer_running_from='';
  1720. $offer_running_to='';
  1721. $remaining_opening_hours_days_count=0;
  1722. $remaining_opening_hours_days_count = $this->input->post('remaining_opening_hours_days_count');
  1723. $offer_title = $this->input->post('offer_title');
  1724. $price = $this->input->post('price');
  1725. $price = str_replace("$","",$price);
  1726. $price_normally = $this->input->post('price_normally');
  1727. $price_normally = str_replace("$","",$price_normally);
  1728. $offer_description = $this->input->post('offer_description');
  1729. $fine_print = $this->input->post('fine_print');
  1730. $offer_running_from = $this->input->post('offer_running_from');
  1731. //m/d/Y
  1732. if($offer_running_from!="")
  1733. {
  1734. $offer_running_from_arr = explode("/",$offer_running_from);
  1735. $d='';
  1736. $m='';
  1737. $y='';
  1738. if(isset($offer_running_from_arr[0]))
  1739. {
  1740. $d = $offer_running_from_arr[0];
  1741. }
  1742. if(isset($offer_running_from_arr[1]))
  1743. {
  1744. $m = $offer_running_from_arr[1];
  1745. }
  1746. if($offer_running_from_arr[2])
  1747. {
  1748. $y = $offer_running_from_arr[2];
  1749. }
  1750. if($d!='' && $m!='' && $y!='')
  1751. {
  1752. $offer_running_from = $y.'-'.$m.'-'.$d;
  1753. }
  1754. }
  1755. if($this->input->post('offer_running_today')===FALSE)
  1756. {
  1757. $offer_running_today='';
  1758. }
  1759. else
  1760. {
  1761. $offer_running_today = '1';
  1762. // If Today only checkbox selected then we are storing current date in offer_running_from and offer_running_to
  1763. //$offer_running_from = date('Y-m-d');
  1764. //$offer_running_to = date('Y-m-d');
  1765. $offer_running_from = $offer_running_from;
  1766. $offer_running_to = $offer_running_from;
  1767. }
  1768. if($this->input->post('offer_multiple_dates')===FALSE)
  1769. {
  1770. $offer_multiple_dates = '';
  1771. }else{
  1772. $offer_multiple_dates = '1';
  1773. $offer_running_to = $this->input->post('offer_running_to');
  1774. if($offer_running_to!="")
  1775. {
  1776. $offer_running_to_arr = explode("/",$offer_running_to);
  1777. $d='';
  1778. $m='';
  1779. $y='';
  1780. if(isset($offer_running_to_arr[0]))
  1781. {
  1782. $d = $offer_running_to_arr[0];
  1783. }
  1784. if(isset($offer_running_to_arr[1]))
  1785. {
  1786. $m = $offer_running_to_arr[1];
  1787. }
  1788. if($offer_running_to_arr[2])
  1789. {
  1790. $y = $offer_running_to_arr[2];
  1791. }
  1792. if($d!='' && $m!='' && $y!='')
  1793. {
  1794. $offer_running_to = $y.'-'.$m.'-'.$d;
  1795. }
  1796. }
  1797. if($offer_running_from!="" && $offer_running_to!="" && strtotime($offer_running_from)>strtotime($offer_running_to) )
  1798. {
  1799. $this->session->set_flashdata('add_offer_message', 'Please check From and To date.');
  1800. redirect('/merchantaccount/addoffers', 'refresh');
  1801. }
  1802. }
  1803. $everyday_of_week='';
  1804. if($this->input->post('everyday_of_week')===FALSE)
  1805. {
  1806. $everyday_of_week='';
  1807. }else{
  1808. $everyday_of_week='1';
  1809. }
  1810. $select_specific_days='';
  1811. if($this->input->post('select_specific_days')===FALSE)
  1812. {
  1813. $select_specific_days = '';
  1814. }else{
  1815. $select_specific_days = '1';
  1816. }
  1817. $specific_days_week='';
  1818. $specific_days_week_array = array();
  1819. if($this->input->post('specific_days_week')===FALSE)
  1820. {
  1821. $specific_days_week = '';
  1822. }else{
  1823. $specific_days_week = implode(",",$this->input->post('specific_days_week'));
  1824. $specific_days_week_array = $this->input->post('specific_days_week');
  1825. }
  1826. $all_day_same_time='';
  1827. if($this->input->post('all_day_same_time')===FALSE)
  1828. {
  1829. $all_day_same_time = '';
  1830. }else{
  1831. $all_day_same_time = '1';
  1832. }
  1833. $different_days_different_time='';
  1834. if($this->input->post('different_days_different_time')===FALSE)
  1835. {
  1836. $different_days_different_time = '';
  1837. }else{
  1838. $different_days_different_time = '1';
  1839. }
  1840. $all_opening_hours='';
  1841. if($this->input->post('all_opening_hours')===FALSE)
  1842. {
  1843. $all_opening_hours = '';
  1844. }else{
  1845. $all_opening_hours = '1';
  1846. }
  1847. $display_status_str = $this->input->post('display_status');
  1848. if($display_status_str=='publish_offer')
  1849. {
  1850. $display_status = '1';
  1851. }else if($display_status_str=='save_draft')
  1852. {
  1853. $display_status = '2';
  1854. }else if($display_status_str=='preview_offer')
  1855. {
  1856. $display_status = '3';
  1857. }
  1858. else if($display_status_str=='trash')
  1859. {
  1860. $display_status = '0';
  1861. }
  1862. else if($display_status_str=='save_add_another_offer')
  1863. {
  1864. $display_status = '1';
  1865. }
  1866. if($offer_check_by_admin=='1' && $display_status_str!='preview_offer')
  1867. {
  1868. $display_status = '4';
  1869. }
  1870. //----------------- FETCHING All the same time --------------------------------//
  1871. $all_day_time_from = $this->input->post('all_day_time_from');
  1872. $all_day_time_from_am_pm = $this->input->post('all_day_time_from_am_pm');
  1873. $all_day_time_to = $this->input->post('all_day_time_to');
  1874. $all_day_time_to_am_pm = $this->input->post('all_day_time_to_am_pm');
  1875. $all_day_quantity = $this->input->post('all_day_quantity');
  1876. $all_day_max_pax = $this->input->post('all_day_max_pax');
  1877. //----------------- FETCHING All the same time --------------------------------//
  1878. //----------------- OFFER IMAGE FUNCTIONALITY START --------------------//
  1879. $offer_image="";
  1880. $old_offer_picture = $this->input->post('old_offer_picture');
  1881. $temp_offer_picture = $this->input->post('temp_offer_picture');
  1882. if(!empty($temp_offer_picture))
  1883. {
  1884. $sql_temp_pp = "SELECT * FROM temp_offer_images WHERE id ='".$temp_offer_picture."' ";
  1885. $exe_temp_pp = $this->db->query($sql_temp_pp);
  1886. $count_temp_pp = $exe_temp_pp->num_rows();
  1887. if($count_temp_pp>0)
  1888. {
  1889. foreach($exe_temp_pp->result() as $tmp)
  1890. {
  1891. $offer_image = $tmp->img_path;
  1892. }
  1893. }
  1894. }
  1895. if($offer_image == "")
  1896. {
  1897. $offer_image = $old_offer_picture;
  1898. }
  1899. //----------------- OFFER IMAGE FUNCTIONALITY END ---------------------//
  1900. $offer_data = array(
  1901. 'merchant_id' => $merchant_id,
  1902. 'offer_title' => $offer_title,
  1903. 'price' => $price,
  1904. 'price_normally' => $price_normally,
  1905. 'offer_description' => $offer_description,
  1906. 'fine_print' => $fine_print,
  1907. 'offer_running_today' => $offer_running_today,
  1908. 'offer_multiple_dates' => $offer_multiple_dates,
  1909. 'offer_running_from' => $offer_running_from,
  1910. 'offer_running_to' => $offer_running_to,
  1911. 'everyday_of_week' => $everyday_of_week,
  1912. 'select_specific_days' => $select_specific_days,
  1913. 'specific_days_week' => $specific_days_week,
  1914. 'all_day_same_time' => $all_day_same_time,
  1915. 'all_day_time_from' => $all_day_time_from,
  1916. 'all_day_time_from_am_pm' => $all_day_time_from_am_pm,
  1917. 'all_day_time_to' => $all_day_time_to,
  1918. 'all_day_time_to_am_pm' => $all_day_time_to_am_pm,
  1919. 'all_day_quantity'=>$all_day_quantity,
  1920. 'all_day_max_pax'=>$all_day_max_pax,
  1921. 'different_days_different_time'=>$different_days_different_time,
  1922. 'all_opening_hours'=>$all_opening_hours,
  1923. 'display_status' => $display_status,
  1924. 'offer_image' => $offer_image
  1925. );
  1926. if($display_status_str=='preview_offer')
  1927. {
  1928. $offer_temp_id = "";
  1929. if(isset($sess_user_data['offer_temp_id']) && $sess_user_data['offer_temp_id']!="")
  1930. {
  1931. $offer_temp_id = $sess_user_data['offer_temp_id'];
  1932. $this->db->where(array('id'=>$offer_temp_id, 'merchant_id'=>$merchant_id));
  1933. $this->db->update('merchant_offers_temp', $offer_data);
  1934. //echo $this->db->last_query();
  1935. }else{
  1936. $this->db->insert('merchant_offers_temp',$offer_data);
  1937. $offer_temp_id = $this->db->insert_id();
  1938. // initializing temp offer id
  1939. if($offer_id!="")
  1940. {
  1941. //echo '....1...............';
  1942. $newdata = array('offer_temp_id' => $offer_temp_id, 'offer_main_id' => $offer_id);
  1943. $this->session->set_userdata($newdata);
  1944. }else{
  1945. //echo '....2...............';
  1946. $newdata = array('offer_temp_id' => $offer_temp_id);
  1947. $this->session->set_userdata($newdata);
  1948. }
  1949. //echo 'vdeveloper<br>';
  1950. //$sess_user_data = $this->session->all_userdata();
  1951. //print_r($sess_user_data);
  1952. //exit();
  1953. }
  1954. }else{
  1955. if(isset($sess_user_data['offer_temp_id']) && $sess_user_data['offer_temp_id']!="")
  1956. {
  1957. if(isset($sess_user_data['offer_main_id']) && $sess_user_data['offer_main_id']!="") // For edit mode
  1958. {
  1959. $offer_main_id = $sess_user_data['offer_main_id'];
  1960. $this->db->where(array('id'=>$offer_main_id, 'merchant_id'=>$merchant_id));
  1961. $this->db->update('merchant_offers', $offer_data);
  1962. //echo $this->db->last_query();
  1963. }else{ // Add mode
  1964. $this->db->insert('merchant_offers',$offer_data);
  1965. $offer_insert_id = $this->db->insert_id();
  1966. $offer_id = $offer_insert_id;
  1967. }
  1968. }else{
  1969. if($offer_id!="") // For edit mode when preview is not enabled
  1970. {
  1971. $this->db->where(array('id'=>$offer_id, 'merchant_id'=>$merchant_id));
  1972. $this->db->update('merchant_offers', $offer_data);
  1973. //echo $this->db->last_query();
  1974. }else{ // For add mode when preview is not enabled
  1975. $this->db->insert('merchant_offers',$offer_data);
  1976. $offer_insert_id = $this->db->insert_id();
  1977. }
  1978. }
  1979. }
  1980. //exit();
  1981. ############################ INSERTING DATA INTO Available time slots and capacity start ###############################
  1982. $timeinfoarray = array();
  1983. $filtered_selected_days = array();
  1984. $todays_day="";
  1985. //$todays_day=strtolower(date("l"));
  1986. $todays_day=strtolower(date('l',strtotime($offer_running_from)));
  1987. $monday=0;
  1988. $tuesday=0;
  1989. $wednesday=0;
  1990. $thursday=0;
  1991. $friday=0;
  1992. $saturday=0;
  1993. $sunday=0;
  1994. $week_days_array=array("monday","tuesday","wednesday","thursday","friday","saturday","sunday");
  1995. $days_between_multiple_dates_array=array();
  1996. $multiple_date_difference=0;
  1997. if($offer_running_to!="" && $offer_running_from!="" && $offer_multiple_dates=='1')
  1998. {
  1999. $multiple_date_difference = $this->users->date_difference($offer_running_to,$offer_running_from);
  2000. while( strtotime($offer_running_from) <= strtotime($offer_running_to) )
  2001. {
  2002. //date('Y-m-d', strtotime($from_date));
  2003. $current_day = strtolower(date('l',strtotime($offer_running_from)));
  2004. if($current_day=='monday')
  2005. {
  2006. if($monday==0)
  2007. {
  2008. array_push($days_between_multiple_dates_array,'monday');
  2009. }
  2010. $monday++;
  2011. }
  2012. else if($current_day=='tuesday'){
  2013. if($tuesday==0)
  2014. {
  2015. array_push($days_between_multiple_dates_array,'tuesday');
  2016. }
  2017. $tuesday++;
  2018. }
  2019. else if($current_day=='wednesday'){
  2020. if($wednesday==0)
  2021. {
  2022. array_push($days_between_multiple_dates_array,'wednesday');
  2023. }
  2024. $wednesday++;
  2025. }
  2026. else if($current_day=='thursday'){
  2027. if($thursday==0)
  2028. {
  2029. array_push($days_between_multiple_dates_array,'thursday');
  2030. }
  2031. $thursday++;
  2032. }
  2033. else if($current_day=='friday'){
  2034. if($friday==0)
  2035. {
  2036. array_push($days_between_multiple_dates_array,'friday');
  2037. }
  2038. $friday++;
  2039. }
  2040. else if($current_day=='saturday'){
  2041. if($saturday==0)
  2042. {
  2043. array_push($days_between_multiple_dates_array,'saturday');
  2044. }
  2045. $saturday++;
  2046. }
  2047. else if($current_day=='sunday'){
  2048. if($sunday==0)
  2049. {
  2050. array_push($days_between_multiple_dates_array,'sunday');
  2051. }
  2052. $sunday++;
  2053. }
  2054. $offer_running_from = date('Y-m-d', strtotime($offer_running_from . ' + 1 day'));
  2055. }
  2056. }
  2057. if($offer_running_today=='1' && $all_day_same_time=='1') // If Today only and All the same time
  2058. {
  2059. //-------------------------- WE ARE INSERTING JUST ONE RECORD i.d TODAY'S DATE => START -------------------------------//
  2060. if($all_day_time_from!="" && $all_day_time_from_am_pm!="" && $all_day_time_to!="" && $all_day_time_to_am_pm!="" && $all_day_quantity!="")
  2061. {
  2062. $timeinfoarray = array(
  2063. "available_day" => $todays_day,
  2064. "time_from" => $all_day_time_from,
  2065. "time_from_am_pm" => $all_day_time_from_am_pm,
  2066. "time_to" => $all_day_time_to,
  2067. "time_to_am_pm" => $all_day_time_to_am_pm,
  2068. "quantity" => $all_day_quantity,
  2069. "max_pax" => $all_day_max_pax,
  2070. "available_time_slots_capacity" => '1',
  2071. "moh_id" => ""
  2072. );
  2073. array_push($filtered_selected_days,$timeinfoarray);
  2074. }
  2075. //-------------------------- WE ARE INSERTING JUST ONE RECORD i.d TODAY'S DATE => START -------------------------------//
  2076. }
  2077. else if($offer_running_today=='1' && $all_opening_hours=='1') // If Today only and All opening hours
  2078. {
  2079. //echo '1...........';
  2080. if(($offer_id!="" || !empty($offer_rerun_id)) && isset($offer_detail[0]->all_opening_hours) && $offer_detail[0]->all_opening_hours=='1' && $all_opening_hours=='1')
  2081. {
  2082. //echo '2...........';
  2083. if(isset($different_days_data) && count($different_days_data)>0)
  2084. {
  2085. //echo '3...........';
  2086. $merchant_opening_hours = $different_days_data;
  2087. }
  2088. }
  2089. //echo '<pre>';
  2090. //print_r($different_days_data);
  2091. //echo '</pre>';
  2092. //echo '<pre>';
  2093. //print_r($merchant_opening_hours);
  2094. //echo '</pre>';
  2095. //echo count($merchant_opening_hours);
  2096. if(count($merchant_opening_hours)>0)
  2097. {
  2098. //echo '...........+...............';
  2099. foreach($merchant_opening_hours as $opening_hours_val)
  2100. {
  2101. $moh_id = $opening_hours_val->id;
  2102. //echo '<br>';
  2103. $available_day = $this->input->post('available_day_open_hrs_hd_'.$moh_id);
  2104. $time_from = $this->input->post('time_from_open_hrs_'.$moh_id);
  2105. $time_from_am_pm = $this->input->post('time_from_am_pm_open_hrs_'.$moh_id);
  2106. $time_to = $this->input->post('time_to_open_hrs_'.$moh_id);
  2107. $time_to_am_pm = $this->input->post('time_to_am_pm_open_hrs_'.$moh_id);
  2108. $quantity = $this->input->post('quantity_open_hrs_'.$moh_id);
  2109. $max_pax = $this->input->post('max_pax_open_hrs_'.$moh_id);
  2110. if($available_day!="" && $time_from!="" && $time_from_am_pm!="" && $time_to!="" && $time_to_am_pm!="" && $available_day==$todays_day)
  2111. {
  2112. $timeinfoarray = array(
  2113. "available_day" => $available_day,
  2114. "time_from" => $time_from,
  2115. "time_from_am_pm" => $time_from_am_pm,
  2116. "time_to" => $time_to,
  2117. "time_to_am_pm" => $time_to_am_pm,
  2118. "quantity" => $quantity,
  2119. "max_pax" => $max_pax,
  2120. "available_time_slots_capacity" => '3',
  2121. "moh_id" => $moh_id
  2122. );
  2123. array_push($filtered_selected_days,$timeinfoarray);
  2124. }
  2125. }
  2126. }
  2127. //------------------ Remaining opening hours days start -----------------------------//
  2128. if(count($remaining_opening_hours_days_count)>0)
  2129. {
  2130. for($new_sno=1;$new_sno<=$remaining_opening_hours_days_count;$new_sno++)
  2131. {
  2132. $available_day = $this->input->post('available_day_open_hrs_hd_'.$new_sno);
  2133. $time_from = $this->input->post('time_from_open_hrs_'.$new_sno);
  2134. $time_from_am_pm = $this->input->post('time_from_am_pm_open_hrs_'.$new_sno);
  2135. $time_to = $this->input->post('time_to_open_hrs_'.$new_sno);
  2136. $time_to_am_pm = $this->input->post('time_to_am_pm_open_hrs_'.$new_sno);
  2137. $quantity = $this->input->post('quantity_open_hrs_'.$new_sno);
  2138. $max_pax = $this->input->post('max_pax_open_hrs_'.$new_sno);
  2139. if($available_day!="" && $time_from!="" && $time_from_am_pm!="" && $time_to!="" && $time_to_am_pm!="" && $quantity>0 && $available_day==$todays_day)
  2140. {
  2141. $timeinfoarray = array(
  2142. "available_day" => $available_day,
  2143. "time_from" => $time_from,
  2144. "time_from_am_pm" => $time_from_am_pm,
  2145. "time_to" => $time_to,
  2146. "time_to_am_pm" => $time_to_am_pm,
  2147. "quantity" => $quantity,
  2148. "max_pax" => $max_pax,
  2149. "available_time_slots_capacity" => '3',
  2150. "moh_id" => $new_sno
  2151. );
  2152. array_push($filtered_selected_days,$timeinfoarray);
  2153. }
  2154. }
  2155. }
  2156. //------------------ Remaining opening hours days end -----------------------------//
  2157. }
  2158. else if($offer_running_today=='1' && $different_days_different_time=='1') // New update 05-12-2014
  2159. {
  2160. $current_day_array = array($todays_day);
  2161. for($n=1;$n<=21;$n++)
  2162. {
  2163. $available_day = $this->input->post('available_day_'.$n);
  2164. $time_from = $this->input->post('time_from_'.$n);
  2165. $time_from_am_pm = $this->input->post('time_from_am_pm_'.$n);
  2166. $time_to = $this->input->post('time_to_'.$n);
  2167. $time_to_am_pm = $this->input->post('time_to_am_pm_'.$n);
  2168. $quantity = $this->input->post('quantity_'.$n);
  2169. $max_pax = $this->input->post('max_pax_'.$n);
  2170. if(in_array($available_day, $current_day_array) && $available_day!="" && $time_from!="" && $time_from_am_pm!="" && $time_to!="" && $time_to_am_pm!="")
  2171. {
  2172. $timeinfoarray = array(
  2173. "available_day" => $available_day,
  2174. "time_from" => $time_from,
  2175. "time_from_am_pm" => $time_from_am_pm,
  2176. "time_to" => $time_to,
  2177. "time_to_am_pm" => $time_to_am_pm,
  2178. "quantity" => $quantity,
  2179. "max_pax" => $max_pax,
  2180. "available_time_slots_capacity" => "2",
  2181. "moh_id" => ""
  2182. );
  2183. array_push($filtered_selected_days, $timeinfoarray);
  2184. }
  2185. }
  2186. if(isset($different_days_data) && count($different_days_data)>0)
  2187. {
  2188. foreach($different_days_data as $different_days_val)
  2189. {
  2190. $n = $different_days_val->id;
  2191. $available_day = $this->input->post('available_day_edt_'.$n);
  2192. $time_from = $this->input->post('time_from_edt_'.$n);
  2193. $time_from_am_pm = $this->input->post('time_from_edt_am_pm_'.$n);
  2194. $time_to = $this->input->post('time_to_edt_'.$n);
  2195. $time_to_am_pm = $this->input->post('time_to_edt_am_pm_'.$n);
  2196. $quantity = $this->input->post('quantity_edt_'.$n);
  2197. $max_pax = $this->input->post('max_pax_edt_'.$n);
  2198. if(in_array($available_day, $current_day_array) && $available_day!="" && $time_from!="" && $time_from_am_pm!="" && $time_to!="" && $time_to_am_pm!="")
  2199. {
  2200. $timeinfoarray = array(
  2201. "available_day" => $available_day,
  2202. "time_from" => $time_from,
  2203. "time_from_am_pm" => $time_from_am_pm,
  2204. "time_to" => $time_to,
  2205. "time_to_am_pm" => $time_to_am_pm,
  2206. "quantity" => $quantity,
  2207. "max_pax" => $max_pax,
  2208. "available_time_slots_capacity" => "2",
  2209. "moh_id" => ""
  2210. );
  2211. array_push($filtered_selected_days, $timeinfoarray);
  2212. }
  2213. }
  2214. }
  2215. /*
  2216. echo '<pre>';
  2217. print_r($different_days_data);
  2218. echo '</pre>';
  2219. exit();
  2220. */
  2221. }
  2222. else if($offer_multiple_dates=='1'){ // Multiple dates
  2223. if($everyday_of_week=='1')
  2224. {
  2225. // IF EVERYDAY SELECTED
  2226. if($everyday_of_week=='1' && $all_day_same_time=='1') // Everyday && All the same time
  2227. {
  2228. if($multiple_date_difference>=7)
  2229. {
  2230. // We need insert all days having All the same time information
  2231. if($all_day_time_from!="" && $all_day_time_from_am_pm!="" && $all_day_time_to!="" && $all_day_time_to_am_pm!="" && $all_day_quantity!="")
  2232. {
  2233. if(count($week_days_array)>0)
  2234. {
  2235. foreach($week_days_array as $week_days_val)
  2236. {
  2237. $timeinfoarray = array(
  2238. "available_day" => $week_days_val,
  2239. "time_from" => $all_day_time_from,
  2240. "time_from_am_pm" => $all_day_time_from_am_pm,
  2241. "time_to" => $all_day_time_to,
  2242. "time_to_am_pm" => $all_day_time_to_am_pm,
  2243. "quantity" => $all_day_quantity,
  2244. "max_pax" => $all_day_max_pax,
  2245. "available_time_slots_capacity" => "1",
  2246. "moh_id" => ""
  2247. );
  2248. array_push($filtered_selected_days, $timeinfoarray);
  2249. }
  2250. }
  2251. }
  2252. }else{
  2253. // Need to count the which days are appearing between from and to dates.
  2254. if($all_day_time_from!="" && $all_day_time_from_am_pm!="" && $all_day_time_to!="" && $all_day_time_to_am_pm!="" && $all_day_quantity!="")
  2255. {
  2256. if(count($days_between_multiple_dates_array)>0)
  2257. {
  2258. foreach($days_between_multiple_dates_array as $days_between_multiple_dates_value)
  2259. {
  2260. $timeinfoarray = array(
  2261. "available_day" => $days_between_multiple_dates_value,
  2262. "time_from" => $all_day_time_from,
  2263. "time_from_am_pm" => $all_day_time_from_am_pm,
  2264. "time_to" => $all_day_time_to,
  2265. "time_to_am_pm" => $all_day_time_to_am_pm,
  2266. "quantity" => $all_day_quantity,
  2267. "max_pax" => $all_day_max_pax,
  2268. "available_time_slots_capacity" => "1",
  2269. "moh_id" => ""
  2270. );
  2271. array_push($filtered_selected_days, $timeinfoarray);
  2272. }
  2273. }
  2274. }
  2275. }
  2276. }
  2277. else if($everyday_of_week=='1' && $different_days_different_time=='1') // Everyday && Different days at different times
  2278. {
  2279. for($n=1;$n<=21;$n++)
  2280. {
  2281. $available_day = $this->input->post('available_day_'.$n);
  2282. $time_from = $this->input->post('time_from_'.$n);
  2283. $time_from_am_pm = $this->input->post('time_from_am_pm_'.$n);
  2284. $time_to = $this->input->post('time_to_'.$n);
  2285. $time_to_am_pm = $this->input->post('time_to_am_pm_'.$n);
  2286. $quantity = $this->input->post('quantity_'.$n);
  2287. $max_pax = $this->input->post('max_pax_'.$n);
  2288. if(in_array($available_day, $days_between_multiple_dates_array) && $available_day!="" && $time_from!="" && $time_from_am_pm!="" && $time_to!="" && $time_to_am_pm!="")
  2289. {
  2290. $timeinfoarray = array(
  2291. "available_day" => $available_day,
  2292. "time_from" => $time_from,
  2293. "time_from_am_pm" => $time_from_am_pm,
  2294. "time_to" => $time_to,
  2295. "time_to_am_pm" => $time_to_am_pm,
  2296. "quantity" => $quantity,
  2297. "max_pax" => $max_pax,
  2298. "available_time_slots_capacity" => "2",
  2299. "moh_id" => ""
  2300. );
  2301. array_push($filtered_selected_days, $timeinfoarray);
  2302. }
  2303. }
  2304. if(isset($different_days_data) && count($different_days_data)>0)
  2305. {
  2306. foreach($different_days_data as $different_days_val)
  2307. {
  2308. $n = $different_days_val->id;
  2309. $available_day = $this->input->post('available_day_edt_'.$n);
  2310. $time_from = $this->input->post('time_from_edt_'.$n);
  2311. $time_from_am_pm = $this->input->post('time_from_edt_am_pm_'.$n);
  2312. $time_to = $this->input->post('time_to_edt_'.$n);
  2313. $time_to_am_pm = $this->input->post('time_to_edt_am_pm_'.$n);
  2314. $quantity = $this->input->post('quantity_edt_'.$n);
  2315. $max_pax = $this->input->post('max_pax_edt_'.$n);
  2316. if(in_array($available_day, $days_between_multiple_dates_array) && $available_day!="" && $time_from!="" && $time_from_am_pm!="" && $time_to!="" && $time_to_am_pm!="")
  2317. {
  2318. $timeinfoarray = array(
  2319. "available_day" => $available_day,
  2320. "time_from" => $time_from,
  2321. "time_from_am_pm" => $time_from_am_pm,
  2322. "time_to" => $time_to,
  2323. "time_to_am_pm" => $time_to_am_pm,
  2324. "quantity" => $quantity,
  2325. "max_pax" => $max_pax,
  2326. "available_time_slots_capacity" => "2",
  2327. "moh_id" => ""
  2328. );
  2329. array_push($filtered_selected_days, $timeinfoarray);
  2330. }
  2331. }
  2332. }
  2333. }
  2334. else if($everyday_of_week=='1' && $all_opening_hours=='1')
  2335. {
  2336. if( ($offer_id!="" || !empty($offer_rerun_id)) && isset($offer_detail[0]->all_opening_hours) && $offer_detail[0]->all_opening_hours=='1' && $all_opening_hours=='1')
  2337. {
  2338. if(isset($different_days_data) && count($different_days_data)>0)
  2339. {
  2340. $merchant_opening_hours = $different_days_data;
  2341. }
  2342. }
  2343. if(count($merchant_opening_hours)>0)
  2344. {
  2345. foreach($merchant_opening_hours as $opening_hours_val)
  2346. {
  2347. $moh_id = $opening_hours_val->id;
  2348. $available_day = $this->input->post('available_day_open_hrs_hd_'.$moh_id);
  2349. $time_from = $this->input->post('time_from_open_hrs_'.$moh_id);
  2350. $time_from_am_pm = $this->input->post('time_from_am_pm_open_hrs_'.$moh_id);
  2351. $time_to = $this->input->post('time_to_open_hrs_'.$moh_id);
  2352. $time_to_am_pm = $this->input->post('time_to_am_pm_open_hrs_'.$moh_id);
  2353. $quantity = $this->input->post('quantity_open_hrs_'.$moh_id);
  2354. $max_pax = $this->input->post('max_pax_open_hrs_'.$moh_id);
  2355. if($available_day!="" && $time_from!="" && $time_from_am_pm!="" && $time_to!="" && $time_to_am_pm!="" && in_array($available_day,$days_between_multiple_dates_array))
  2356. {
  2357. $timeinfoarray = array(
  2358. "available_day" => $available_day,
  2359. "time_from" => $time_from,
  2360. "time_from_am_pm" => $time_from_am_pm,
  2361. "time_to" => $time_to,
  2362. "time_to_am_pm" => $time_to_am_pm,
  2363. "quantity" => $quantity,
  2364. "max_pax" => $max_pax,
  2365. "available_time_slots_capacity" => '3',
  2366. "moh_id" => $moh_id
  2367. );
  2368. array_push($filtered_selected_days,$timeinfoarray);
  2369. }
  2370. }
  2371. /*
  2372. echo '<pre>';
  2373. print_r($merchant_opening_hours);
  2374. echo '</pre>';
  2375. exit();
  2376. */
  2377. }
  2378. //------------------ Remaining opening hours days start -----------------------------//
  2379. if(count($remaining_opening_hours_days_count)>0)
  2380. {
  2381. for($new_sno=1;$new_sno<=$remaining_opening_hours_days_count;$new_sno++)
  2382. {
  2383. $available_day = $this->input->post('available_day_open_hrs_hd_'.$new_sno);
  2384. $time_from = $this->input->post('time_from_open_hrs_'.$new_sno);
  2385. $time_from_am_pm = $this->input->post('time_from_am_pm_open_hrs_'.$new_sno);
  2386. $time_to = $this->input->post('time_to_open_hrs_'.$new_sno);
  2387. $time_to_am_pm = $this->input->post('time_to_am_pm_open_hrs_'.$new_sno);
  2388. $quantity = $this->input->post('quantity_open_hrs_'.$new_sno);
  2389. $max_pax = $this->input->post('max_pax_open_hrs_'.$new_sno);
  2390. if($available_day!="" && $time_from!="" && $time_from_am_pm!="" && $time_to!="" && $time_to_am_pm!="" && $quantity>0 && in_array($available_day,$days_between_multiple_dates_array))
  2391. {
  2392. $timeinfoarray = array(
  2393. "available_day" => $available_day,
  2394. "time_from" => $time_from,
  2395. "time_from_am_pm" => $time_from_am_pm,
  2396. "time_to" => $time_to,
  2397. "time_to_am_pm" => $time_to_am_pm,
  2398. "quantity" => $quantity,
  2399. "max_pax" => $max_pax,
  2400. "available_time_slots_capacity" => '3',
  2401. "moh_id" => $new_sno
  2402. );
  2403. array_push($filtered_selected_days,$timeinfoarray);
  2404. }
  2405. }
  2406. }
  2407. //------------------ Remaining opening hours days end -----------------------------//
  2408. }
  2409. }else if($select_specific_days=='1')
  2410. {
  2411. $new_specific_days_week_array = array();
  2412. if(count($specific_days_week_array)>0 && count($days_between_multiple_dates_array)>0)
  2413. {
  2414. foreach($specific_days_week_array as $dayname)
  2415. {
  2416. if(in_array($dayname, $days_between_multiple_dates_array))
  2417. {
  2418. array_push($new_specific_days_week_array, $dayname);
  2419. }
  2420. }
  2421. }
  2422. $count_new_specific_days_week_array = count($new_specific_days_week_array);
  2423. /*
  2424. echo '<pre>';
  2425. print_r($new_specific_days_week_array);
  2426. echo '</pre>';
  2427. echo $count_new_specific_days_week_array;
  2428. exit();
  2429. */
  2430. if($all_day_same_time=='1' && $count_new_specific_days_week_array>0)
  2431. {
  2432. /*
  2433. echo '1................<br>';
  2434. echo $all_day_time_from.'aaaaaaaaaaaaaaaaaaaaaaaaa <br>';
  2435. echo $all_day_time_from_am_pm.'bbbbbbbbbbbbbbbbbbbbbb <br>';
  2436. echo $all_day_time_to.'ccccccccccccccccccccc <br>';
  2437. echo $all_day_time_to_am_pm.'dddddddddddddd <br>';
  2438. echo $all_day_quantity.'eeeeeeeeeeeeeeeee <br>';
  2439. */
  2440. if($all_day_time_from!="" && $all_day_time_from_am_pm!="" && $all_day_time_to!="" && $all_day_time_to_am_pm!="" && $all_day_quantity!="")
  2441. {
  2442. //echo '........start........';
  2443. foreach($new_specific_days_week_array as $daysname)
  2444. {
  2445. //echo '1'.$vj.'................<br>';
  2446. $timeinfoarray = array(
  2447. "available_day" => $daysname,
  2448. "time_from" => $all_day_time_from,
  2449. "time_from_am_pm" => $all_day_time_from_am_pm,
  2450. "time_to" => $all_day_time_to,
  2451. "time_to_am_pm" => $all_day_time_to_am_pm,
  2452. "quantity" => $all_day_quantity,
  2453. "max_pax" => $all_day_max_pax,
  2454. "available_time_slots_capacity" => "1",
  2455. "moh_id" => ""
  2456. );
  2457. array_push($filtered_selected_days, $timeinfoarray);
  2458. }
  2459. }
  2460. }
  2461. else if($different_days_different_time=='1' && $count_new_specific_days_week_array>0)
  2462. {
  2463. //echo '2................';
  2464. for($n=1;$n<=21;$n++)
  2465. {
  2466. $available_day = $this->input->post('available_day_'.$n);
  2467. $time_from = $this->input->post('time_from_'.$n);
  2468. $time_from_am_pm = $this->input->post('time_from_am_pm_'.$n);
  2469. $time_to = $this->input->post('time_to_'.$n);
  2470. $time_to_am_pm = $this->input->post('time_to_am_pm_'.$n);
  2471. $quantity = $this->input->post('quantity_'.$n);
  2472. $max_pax = $this->input->post('max_pax_'.$n);
  2473. if($available_day!="" && in_array($available_day,$new_specific_days_week_array) && $time_from!="" && $time_from_am_pm!="" && $time_to!="" && $time_to_am_pm!="")
  2474. {
  2475. $timeinfoarray = array(
  2476. "available_day" => $available_day,
  2477. "time_from" => $time_from,
  2478. "time_from_am_pm" => $time_from_am_pm,
  2479. "time_to" => $time_to,
  2480. "time_to_am_pm" => $time_to_am_pm,
  2481. "quantity" => $quantity,
  2482. "max_pax" => $max_pax,
  2483. "available_time_slots_capacity" => "2",
  2484. "moh_id" => ""
  2485. );
  2486. array_push($filtered_selected_days, $timeinfoarray);
  2487. }
  2488. }
  2489. // For edit mode start here
  2490. if(isset($different_days_data) && count($different_days_data)>0)
  2491. {
  2492. foreach($different_days_data as $different_days_val)
  2493. {
  2494. $n = $different_days_val->id;
  2495. $available_day = $this->input->post('available_day_edt_'.$n);
  2496. $time_from = $this->input->post('time_from_edt_'.$n);
  2497. $time_from_am_pm = $this->input->post('time_from_edt_am_pm_'.$n);
  2498. $time_to = $this->input->post('time_to_edt_'.$n);
  2499. $time_to_am_pm = $this->input->post('time_to_edt_am_pm_'.$n);
  2500. $quantity = $this->input->post('quantity_edt_'.$n);
  2501. $max_pax = $this->input->post('max_pax_edt_'.$n);
  2502. if(in_array($available_day, $days_between_multiple_dates_array) && $available_day!="" && $time_from!="" && $time_from_am_pm!="" && $time_to!="" && $time_to_am_pm!="")
  2503. {
  2504. $timeinfoarray = array(
  2505. "available_day" => $available_day,
  2506. "time_from" => $time_from,
  2507. "time_from_am_pm" => $time_from_am_pm,
  2508. "time_to" => $time_to,
  2509. "time_to_am_pm" => $time_to_am_pm,
  2510. "quantity" => $quantity,
  2511. "max_pax" => $max_pax,
  2512. "available_time_slots_capacity" => "2",
  2513. "moh_id" => ""
  2514. );
  2515. array_push($filtered_selected_days, $timeinfoarray);
  2516. }
  2517. }
  2518. }
  2519. // For edit mode end here
  2520. }
  2521. else if($all_opening_hours=='1' && $count_new_specific_days_week_array>0)
  2522. {
  2523. //echo '3................';
  2524. if( ($offer_id!="" || !empty($offer_rerun_id) ) && isset($offer_detail[0]->all_opening_hours) && $offer_detail[0]->all_opening_hours=='1' && $all_opening_hours=='1')
  2525. {
  2526. if(isset($different_days_data) && count($different_days_data)>0)
  2527. {
  2528. /*
  2529. foreach($different_days_data as $different_days_val)
  2530. {
  2531. $moh_id = $opening_hours_val->id;
  2532. }
  2533. */
  2534. $merchant_opening_hours = $different_days_data;
  2535. }
  2536. }
  2537. if(count($merchant_opening_hours)>0)
  2538. {
  2539. foreach($merchant_opening_hours as $opening_hours_val)
  2540. {
  2541. $moh_id = $opening_hours_val->id;
  2542. $available_day = $this->input->post('available_day_open_hrs_hd_'.$moh_id);
  2543. $time_from = $this->input->post('time_from_open_hrs_'.$moh_id);
  2544. $time_from_am_pm = $this->input->post('time_from_am_pm_open_hrs_'.$moh_id);
  2545. $time_to = $this->input->post('time_to_open_hrs_'.$moh_id);
  2546. $time_to_am_pm = $this->input->post('time_to_am_pm_open_hrs_'.$moh_id);
  2547. $quantity = $this->input->post('quantity_open_hrs_'.$moh_id);
  2548. $max_pax = $this->input->post('max_pax_open_hrs_'.$moh_id);
  2549. if($available_day!="" && $time_from!="" && $time_from_am_pm!="" && $time_to!="" && $time_to_am_pm!="" && $quantity>0 && in_array($available_day,$new_specific_days_week_array))
  2550. {
  2551. $timeinfoarray = array(
  2552. "available_day" => $available_day,
  2553. "time_from" => $time_from,
  2554. "time_from_am_pm" => $time_from_am_pm,
  2555. "time_to" => $time_to,
  2556. "time_to_am_pm" => $time_to_am_pm,
  2557. "quantity" => $quantity,
  2558. "max_pax" => $max_pax,
  2559. "available_time_slots_capacity" => '3',
  2560. "moh_id" => $moh_id
  2561. );
  2562. array_push($filtered_selected_days,$timeinfoarray);
  2563. }
  2564. }
  2565. }
  2566. //------------------ Remaining opening hours days start -----------------------------//
  2567. if(count($remaining_opening_hours_days_count)>0)
  2568. {
  2569. for($new_sno=1;$new_sno<=$remaining_opening_hours_days_count;$new_sno++)
  2570. {
  2571. $available_day = $this->input->post('available_day_open_hrs_hd_'.$new_sno);
  2572. $time_from = $this->input->post('time_from_open_hrs_'.$new_sno);
  2573. $time_from_am_pm = $this->input->post('time_from_am_pm_open_hrs_'.$new_sno);
  2574. $time_to = $this->input->post('time_to_open_hrs_'.$new_sno);
  2575. $time_to_am_pm = $this->input->post('time_to_am_pm_open_hrs_'.$new_sno);
  2576. $quantity = $this->input->post('quantity_open_hrs_'.$new_sno);
  2577. $max_pax = $this->input->post('max_pax_open_hrs_'.$new_sno);
  2578. if($available_day!="" && $time_from!="" && $time_from_am_pm!="" && $time_to!="" && $time_to_am_pm!="" && $quantity>0 && in_array($available_day,$new_specific_days_week_array))
  2579. {
  2580. $timeinfoarray = array(
  2581. "available_day" => $available_day,
  2582. "time_from" => $time_from,
  2583. "time_from_am_pm" => $time_from_am_pm,
  2584. "time_to" => $time_to,
  2585. "time_to_am_pm" => $time_to_am_pm,
  2586. "quantity" => $quantity,
  2587. "max_pax" => $max_pax,
  2588. "available_time_slots_capacity" => '3',
  2589. "moh_id" => $new_sno
  2590. );
  2591. array_push($filtered_selected_days,$timeinfoarray);
  2592. }
  2593. }
  2594. }
  2595. //------------------ Remaining opening hours days end -----------------------------//
  2596. }
  2597. }
  2598. }
  2599. /*
  2600. echo '........old........';
  2601. echo '<pre>';
  2602. print_r($filtered_selected_days);
  2603. echo '</pre>';
  2604. exit();
  2605. */
  2606. //------- after all filteration inserting data into table start ---------//
  2607. $sess_user_data = $this->session->all_userdata();
  2608. /*
  2609. echo '<pre>';
  2610. print_r($sess_user_data);
  2611. echo '</pre>';
  2612. exit();
  2613. */
  2614. /*
  2615. if(isset($sess_user_data['offer_temp_id']) && $sess_user_data['offer_temp_id']!="")
  2616. {
  2617. $table_moat = 'merchant_offers_available_time_temp';
  2618. $table_mo = ''; // merchant offers
  2619. $offer_id = $sess_user_data['offer_temp_id'];
  2620. $offer_temp_id = $sess_user_data['offer_temp_id'];
  2621. }else{
  2622. $table_moat = 'merchant_offers_available_time';
  2623. $table_mo = ''; // merchant offers
  2624. }
  2625. */
  2626. if(isset($sess_user_data['offer_temp_id']) && $sess_user_data['offer_temp_id']!="")
  2627. {
  2628. // $offer_temp_id = $sess_user_data['offer_temp_id'];
  2629. //$offer_id = $sess_user_data['offer_temp_id'];
  2630. /*
  2631. if(isset($sess_user_data['offer_temp_id']) && $sess_user_data['offer_temp_id']!="" && $display_status_str=='preview_offer')
  2632. {
  2633. $offer_insert_id = $sess_user_data['offer_temp_id'];
  2634. }
  2635. */
  2636. /*
  2637. echo '...................***...<br>';
  2638. echo $offer_id;
  2639. echo '<br>';
  2640. echo $offer_insert_id;
  2641. exit();
  2642. */
  2643. }
  2644. if($display_status_str=='preview_offer')
  2645. {
  2646. $table_moat = 'merchant_offers_available_time_temp';
  2647. if(isset($sess_user_data['offer_temp_id']) && $sess_user_data['offer_temp_id']!="")
  2648. {
  2649. $this->users->del_available_different_days($sess_user_data['offer_temp_id'],'merchant_offers_available_time_temp'); // temporary table
  2650. }
  2651. }else{
  2652. $table_moat = 'merchant_offers_available_time';
  2653. if(isset($sess_user_data['offer_temp_id']) && $sess_user_data['offer_temp_id']!="")
  2654. {
  2655. $this->users->del_available_different_days($sess_user_data['offer_main_id'],'merchant_offers_available_time'); // main table
  2656. $this->users->del_available_different_days($sess_user_data['offer_temp_id'],'merchant_offers_available_time_temp'); // temp table
  2657. }
  2658. if(!empty($offer_insert_id))
  2659. {
  2660. $this->users->del_available_different_days($offer_insert_id); // preview not enabled a single time
  2661. }else{
  2662. if(!empty($offer_id))
  2663. {
  2664. $this->users->del_available_different_days($offer_id); // preview not enabled a single time
  2665. }
  2666. }
  2667. }
  2668. //echo '<pre>';
  2669. //print_r($sess_user_data);
  2670. //echo '</pre>';
  2671. if(isset($sess_user_data['offer_temp_id']) && $sess_user_data['offer_temp_id']!="")
  2672. {
  2673. if($display_status_str=='preview_offer')
  2674. {
  2675. //echo '1<br>';
  2676. $offer_insert_id = $sess_user_data['offer_temp_id'];
  2677. }else{
  2678. if(isset($sess_user_data['offer_main_id']) && $sess_user_data['offer_main_id']!="")
  2679. {
  2680. //echo '2<br>';
  2681. $offer_insert_id = $sess_user_data['offer_main_id'];
  2682. }
  2683. else{
  2684. if(empty($offer_insert_id))
  2685. {
  2686. //echo '3<br>';
  2687. $offer_insert_id = $sess_user_data['offer_temp_id'];
  2688. }
  2689. }
  2690. }
  2691. }else{
  2692. if(!empty($offer_id))
  2693. {
  2694. // echo '4';
  2695. $offer_insert_id = $offer_id;
  2696. }
  2697. }
  2698. /*
  2699. echo '<pre>';
  2700. print_r($filtered_selected_days);
  2701. echo '</pre>';
  2702. exit();
  2703. */
  2704. foreach($filtered_selected_days as $key => $value )
  2705. {
  2706. if(isset($value['available_day']) && $value['available_day']!="" && isset($value['time_from']) && $value['time_from']!="" && isset($value['time_to']) && $value['time_to']!="")
  2707. {
  2708. $from_hours = '';
  2709. $to_hours = '';
  2710. $dayname = $value['available_day'];
  2711. $time_from = $value['time_from'];
  2712. $time_from_am_pm = $value['time_from_am_pm'];
  2713. $from_timeval = $time_from.' '.$time_from_am_pm;
  2714. $from_hours = date("Hi", strtotime($from_timeval));
  2715. /*
  2716. if($time_from_am_pm=='am' || $time_from_am_pm=='AM')
  2717. {
  2718. if($time_from==12)
  2719. {
  2720. $from_hours = '0000';
  2721. }else{
  2722. $from_hours = $time_from * 100;
  2723. if($time_from>=1 && $time_from<=9)
  2724. {
  2725. $from_hours = '0'.$from_hours;
  2726. }
  2727. }
  2728. }
  2729. else if($time_from_am_pm=='pm' || $time_from_am_pm=='PM')
  2730. {
  2731. if($time_from==12)
  2732. {
  2733. $from_hours = '1200';
  2734. }else{
  2735. $from_hours = 1200 + ($time_from * 100);
  2736. }
  2737. }
  2738. */
  2739. $time_to = $value['time_to'];
  2740. $time_to_am_pm = $value['time_to_am_pm'];
  2741. $to_timeval = $time_to.' '.$time_to_am_pm;
  2742. $to_hours = date("Hi", strtotime($to_timeval));
  2743. /*
  2744. if($time_to_am_pm=='am' || $time_to_am_pm=='AM')
  2745. {
  2746. if($time_to==12)
  2747. {
  2748. $to_hours = '0000';
  2749. }else{
  2750. $to_hours = $time_to * 100;
  2751. if($time_to>=1 && $time_to<=9)
  2752. {
  2753. $to_hours = '0'.$to_hours;
  2754. }
  2755. }
  2756. }
  2757. else if($time_to_am_pm=='pm' || $time_to_am_pm=='PM')
  2758. {
  2759. if($time_to==12)
  2760. {
  2761. $to_hours = '1200';
  2762. }else{
  2763. $to_hours = 1200 + ($time_to * 100);
  2764. }
  2765. }
  2766. */
  2767. $quantity = $value['quantity'];
  2768. $max_pax = $value['max_pax'];
  2769. if($max_pax_display_check==0)
  2770. {
  2771. $max_pax = 0;
  2772. }
  2773. $available_time_slots_capacity = $value['available_time_slots_capacity'];
  2774. $moh_id = $value['moh_id'];
  2775. $chk_available_different_days=0;
  2776. $chk_available_different_days = $this->users->count_available_different_days($dayname,$from_hours,$to_hours,$offer_insert_id,$table_moat);
  2777. if($chk_available_different_days==0)
  2778. {
  2779. $days_display_order='';
  2780. if($dayname=='monday')
  2781. {
  2782. $days_display_order = '1';
  2783. }else if($dayname=='tuesday'){
  2784. $days_display_order = '2';
  2785. }
  2786. else if($dayname=='wednesday'){
  2787. $days_display_order = '3';
  2788. }
  2789. else if($dayname=='thursday'){
  2790. $days_display_order = '4';
  2791. }
  2792. else if($dayname=='friday'){
  2793. $days_display_order = '5';
  2794. }
  2795. else if($dayname=='saturday'){
  2796. $days_display_order = '6';
  2797. }
  2798. else if($dayname=='sunday'){
  2799. $days_display_order = '7';
  2800. }
  2801. $available_time_data = array(
  2802. 'offer_id' => $offer_insert_id,
  2803. 'merchant_id' => $merchant_id,
  2804. 'available_day' => $dayname,
  2805. 'time_from' => $time_from,
  2806. 'time_from_am_pm' => $time_from_am_pm,
  2807. 'from_hours' => $from_hours,
  2808. 'time_to' => $time_to,
  2809. 'time_to_am_pm' => $time_to_am_pm,
  2810. 'to_hours' => $to_hours,
  2811. 'quantity' => $quantity,
  2812. 'max_pax' => $max_pax,
  2813. 'added_date' => date('Y-m-d H:i:s'),
  2814. 'available_time_slots_capacity' => $available_time_slots_capacity,
  2815. 'days_display_order' => $days_display_order,
  2816. 'moh_id' => $moh_id
  2817. );
  2818. if(!empty($offer_insert_id))
  2819. {
  2820. $this->db->insert($table_moat, $available_time_data);
  2821. }
  2822. }
  2823. }
  2824. }
  2825. //------- after all filteration inserting data into table end ---------//
  2826. ############################ INSERTING DATA INTO Available time slots and capacity end ###############################
  2827. ##################### SENDING EMAIL TO MERCHANT IF ADMIN APPROVAL IS REQUIRED ######################
  2828. if($offer_check_by_admin=='1')
  2829. {
  2830. }
  2831. ##################### SENDING EMAIL TO MERCHANT IF ADMIN APPROVAL IS REQUIRED ######################
  2832. if($this->input->post('display_status')=='save_add_another_offer')
  2833. {
  2834. if(isset($sess_user_data['offer_temp_id']) && $sess_user_data['offer_temp_id']!="")
  2835. {
  2836. $this->users->del_merchant_offer_temp($offer_temp_id);
  2837. $this->users->del_merchant_offer_available_time_temp($offer_temp_id);
  2838. $array_items = array('offer_temp_id' => '', 'offer_main_id'=>'');
  2839. $this->session->unset_userdata($array_items);
  2840. }
  2841. $this->session->set_flashdata('offer_message', 'Added successfully.');
  2842. redirect('/merchantaccount/addoffers', 'refresh');
  2843. }
  2844. else if($this->input->post('display_status')=='preview_offer'){
  2845. if(isset($sess_user_data['offer_temp_id']) && $sess_user_data['offer_temp_id']!="")
  2846. {
  2847. //echo '2................................';
  2848. //exit();
  2849. $url = $this->config->base_url()."merchantoffers/preview/".$sess_user_data['offer_temp_id'];
  2850. //echo '<script>window.open("'.$url.'", "_blank"); window.location.href="'.$this->config->base_url().'merchantaccount/addoffers/'.$sess_user_data['offer_temp_id'].'"; </script>';
  2851. echo '<script>window.open("'.$url.'", "_blank");</script>';
  2852. echo '<script>window.location.href="'.$this->config->base_url().'merchantaccount/addoffers/'.$sess_user_data['offer_temp_id'].'";</script>';
  2853. //redirect('/merchantaccount/addoffers/'.$sess_user_data['offer_temp_id'], 'refresh');
  2854. exit();
  2855. }
  2856. }else{
  2857. if(isset($sess_user_data['offer_temp_id']) && $sess_user_data['offer_temp_id']!="")
  2858. {
  2859. $this->users->del_merchant_offer_temp($offer_temp_id);
  2860. $this->users->del_merchant_offer_available_time_temp($offer_temp_id);
  2861. $array_items = array('offer_temp_id' => '', 'offer_main_id'=>'');
  2862. $this->session->unset_userdata($array_items);
  2863. }
  2864. $this->session->set_flashdata('offer_message', 'Added successfully.');
  2865. redirect('/merchantaccount/liveoffers', 'refresh');
  2866. }
  2867. }
  2868. //echo '<pre>';
  2869. //print_r($data['merchant_opening_hours']);
  2870. //echo '</pre>';
  2871. //exit();
  2872. $this->load->view('/merchantaccount/addoffers', $data);
  2873. }
  2874. public function trashoffer($offer_id="")
  2875. {
  2876. $sess_user_data = $this->session->all_userdata();
  2877. if(isset($sess_user_data['offer_temp_id']) && $sess_user_data['offer_temp_id']!="")
  2878. {
  2879. $offer_temp_id = $sess_user_data['offer_temp_id'];
  2880. $this->users->del_merchant_offer_temp($offer_temp_id);
  2881. $this->users->del_merchant_offer_available_time_temp($offer_temp_id);
  2882. $array_items = array('offer_temp_id' => '', 'offer_main_id'=>'');
  2883. $this->session->unset_userdata($array_items);
  2884. }
  2885. else{
  2886. if(!empty($offer_id))
  2887. {
  2888. $merchant_id = '';
  2889. // $merchant_id=$this->CI_auth->logged_id();
  2890. $merchant_id=$this->users->get_main_merchant_id();
  2891. $this->db->delete('merchant_offers', array('id' => $offer_id, 'merchant_id'=> $merchant_id ));
  2892. $this->db->delete('merchant_offers_available_time', array('offer_id' => $offer_id, 'merchant_id'=> $merchant_id ));
  2893. $this->db->where('id', $offer_id);
  2894. //$offer_data = array('display_status' => '0');
  2895. //$this->db->where(array('id'=>$offer_id, 'merchant_id'=>$merchant_id));
  2896. //$this->db->update('merchant_offers', $offer_data);
  2897. //echo $this->db->last_query(); die;
  2898. }
  2899. }
  2900. $this->session->set_flashdata('add_offer_message', 'Offer deleted successfully.');
  2901. redirect('/merchantaccount/liveoffers', 'refresh');
  2902. }
  2903. public function bookingscalender()
  2904. {
  2905. /* USER ACCESS TYPE CHECK DATA START */
  2906. $logged_user_access_type = $this->users->get_user_access_type();
  2907. $data['logged_user_access_type'] = $logged_user_access_type;
  2908. $data['logged_user_access_sections'] = array();
  2909. if($logged_user_access_type=='3')
  2910. {
  2911. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  2912. if($logged_user_access_type=='2' || ($logged_user_access_type=='3' && in_array("6",$data['logged_user_access_sections'])) )
  2913. {
  2914. }else{
  2915. redirect('/home', 'refresh');
  2916. exit();
  2917. }
  2918. }
  2919. /* USER ACCESS TYPE CHECK DATA END */
  2920. $user_id='';
  2921. //$user_id=$this->CI_auth->logged_id();
  2922. //$data['users_data'] = $this->users->get_userslist();
  2923. $offer_search="";
  2924. $offer_search = $this->input->post('offer_search');
  2925. $data['offer_search']=$offer_search;
  2926. $data['title']='Services on demand - Ondi.com';
  2927. $data['current_bookings_dates'] = $this->users->get_current_bookings_dates($offer_search);
  2928. $this->load->view('/merchantaccount/bookingscalender', $data);
  2929. }
  2930. public function liveoffers()
  2931. {
  2932. /* USER ACCESS TYPE CHECK DATA START */
  2933. $logged_user_access_type = $this->users->get_user_access_type();
  2934. $data['logged_user_access_type'] = $logged_user_access_type;
  2935. $data['logged_user_access_sections'] = array();
  2936. if($logged_user_access_type=='3')
  2937. {
  2938. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  2939. }
  2940. /* USER ACCESS TYPE CHECK DATA END */
  2941. $offer_search="";
  2942. $offer_search = $this->input->post('offer_search');
  2943. $data['offer_search']=$offer_search;
  2944. $data['title'] = 'Services on demand - Ondi.com';
  2945. // parameters
  2946. // 1. display status
  2947. // 2. search input value
  2948. $data['offers_data'] = $this->users->get_offers('liveoffers',$offer_search);
  2949. $this->load->view('/merchantaccount/liveoffers', $data);
  2950. }
  2951. public function offerhistory()
  2952. {
  2953. /* USER ACCESS TYPE CHECK DATA START */
  2954. $logged_user_access_type = $this->users->get_user_access_type();
  2955. $data['logged_user_access_type'] = $logged_user_access_type;
  2956. $data['logged_user_access_sections'] = array();
  2957. if($logged_user_access_type=='3')
  2958. {
  2959. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  2960. }
  2961. /* USER ACCESS TYPE CHECK DATA END */
  2962. $offer_search="";
  2963. $offer_search = $this->input->post('offer_search');
  2964. $data['offer_search']=$offer_search;
  2965. $data['title'] = 'Services on demand - Ondi.com';
  2966. // parameters
  2967. // 1. display status
  2968. // 2. search input value
  2969. $data['offers_data'] = $this->users->get_offers('offerhistory',$offer_search);
  2970. $this->load->view('/merchantaccount/offerhistory', $data);
  2971. }
  2972. public function updatebusshours()
  2973. {
  2974. /*
  2975. echo '<pre>';
  2976. print_r($_POST);
  2977. echo '</pre>';
  2978. */
  2979. //$this->users->get_distinct_offer_id_having_moh_id();
  2980. $merchant_id = '';
  2981. // $merchant_id=$this->CI_auth->logged_id();
  2982. $merchant_id=$this->users->get_main_merchant_id();
  2983. $update_existing_offers = $this->input->post('update_existing_offers');
  2984. $entered_buss_hrs_count=0;
  2985. $entered_buss_hrs_count = $this->input->post('entered_buss_hrs_count');
  2986. if($entered_buss_hrs_count>0)
  2987. {
  2988. $num=0;
  2989. for($i=1;$i<=$entered_buss_hrs_count;$i++)
  2990. {
  2991. $merchant_opening_hours_id = $this->input->post('merchant_opening_hours_id_'.$i);
  2992. $buss_upd_hrs_available_day = $this->input->post('buss_upd_hrs_available_day_'.$i);
  2993. $buss_upd_hrs_time_from = $this->input->post('buss_upd_hrs_time_from_'.$i);
  2994. $buss_upd_hrs_time_to = $this->input->post('buss_upd_hrs_time_to_'.$i);
  2995. $buss_upd_hrs_time_from_am_pm = strtolower($this->input->post('buss_upd_hrs_time_from_am_pm_'.$i));
  2996. $buss_upd_hrs_time_to_am_pm = strtolower($this->input->post('buss_upd_hrs_time_to_am_pm_'.$i));
  2997. if($buss_upd_hrs_available_day!="" && $buss_upd_hrs_time_from!="" && $buss_upd_hrs_time_to!="" && $buss_upd_hrs_time_from_am_pm!="" && $buss_upd_hrs_time_to_am_pm!="")
  2998. {
  2999. $opentime_insert = array(
  3000. 'user_id' => $merchant_id,
  3001. 'day' => $buss_upd_hrs_available_day,
  3002. 'from_hour' => $buss_upd_hrs_time_from,
  3003. 'from_ampm' => $buss_upd_hrs_time_from_am_pm,
  3004. 'to_hour' => $buss_upd_hrs_time_to,
  3005. 'to_ampm' => $buss_upd_hrs_time_to_am_pm
  3006. );
  3007. $opentime_update = array(
  3008. 'day' => $buss_upd_hrs_available_day,
  3009. 'from_hour' => $buss_upd_hrs_time_from,
  3010. 'from_ampm' => $buss_upd_hrs_time_from_am_pm,
  3011. 'to_hour' => $buss_upd_hrs_time_to,
  3012. 'to_ampm' => $buss_upd_hrs_time_to_am_pm
  3013. );
  3014. $this->db->where('user_id', $merchant_id);
  3015. $this->db->where('id', $merchant_opening_hours_id);
  3016. $this->db->update('merchant_opening_hours', $opentime_update);
  3017. $num++;
  3018. if($update_existing_offers=='1')
  3019. {
  3020. //*************************** updating existing merchant_offers_available_time start ***************************//
  3021. if($buss_upd_hrs_time_from_am_pm=='am' || $buss_upd_hrs_time_from_am_pm=='AM')
  3022. {
  3023. if($buss_upd_hrs_time_from==12)
  3024. {
  3025. $from_hours = '0000';
  3026. }else{
  3027. $from_hours = $buss_upd_hrs_time_from * 100;
  3028. if($buss_upd_hrs_time_from>=1 && $buss_upd_hrs_time_from<=9)
  3029. {
  3030. $from_hours = '0'.$from_hours;
  3031. }
  3032. }
  3033. }
  3034. else if($buss_upd_hrs_time_from_am_pm=='pm' || $buss_upd_hrs_time_from_am_pm=='PM')
  3035. {
  3036. if($buss_upd_hrs_time_from==12)
  3037. {
  3038. $from_hours = '1200';
  3039. }else{
  3040. $from_hours = 1200 + ($buss_upd_hrs_time_from * 100);
  3041. }
  3042. }
  3043. if($buss_upd_hrs_time_to_am_pm=='am' || $buss_upd_hrs_time_to_am_pm=='AM')
  3044. {
  3045. if($buss_upd_hrs_time_to==12)
  3046. {
  3047. $to_hours = '0000';
  3048. }else{
  3049. $to_hours = $buss_upd_hrs_time_to * 100;
  3050. if($buss_upd_hrs_time_to>=1 && $buss_upd_hrs_time_to<=9)
  3051. {
  3052. $to_hours = '0'.$to_hours;
  3053. }
  3054. }
  3055. }
  3056. else if($buss_upd_hrs_time_to_am_pm=='pm' || $buss_upd_hrs_time_to_am_pm=='PM')
  3057. {
  3058. if($buss_upd_hrs_time_to==12)
  3059. {
  3060. $to_hours = '1200';
  3061. }else{
  3062. $to_hours = 1200 + ($buss_upd_hrs_time_to * 100);
  3063. }
  3064. }
  3065. $available_time_data = array(
  3066. 'time_from' => $buss_upd_hrs_time_from,
  3067. 'time_from_am_pm' => $buss_upd_hrs_time_from_am_pm,
  3068. 'from_hours' => $from_hours,
  3069. 'time_to' => $buss_upd_hrs_time_to,
  3070. 'time_to_am_pm' => $buss_upd_hrs_time_to_am_pm,
  3071. 'to_hours' => $to_hours,
  3072. 'added_date' => date('Y-m-d H:i:s')
  3073. );
  3074. // $this->db->where(array('merchant_id'=>$merchant_opening_hours_id, 'available_day'=>$buss_upd_hrs_available_day, 'available_time_slots_capacity'=>3));
  3075. $this->db->where(array('merchant_id'=>$merchant_id, 'available_time_slots_capacity'=>3, 'moh_id'=>$merchant_opening_hours_id ));
  3076. $this->db->update('merchant_offers_available_time', $available_time_data);
  3077. //*************************** updating existing merchant_offers_available_time end ***************************//
  3078. }
  3079. }
  3080. }
  3081. }
  3082. //-------------- inserting new available time start ---------------------//
  3083. //$existing_buiss_opening_hours_data = $this->users->get_different_days_data("","","","1"); // do not remove 1
  3084. //get_distinct_offer_id_having_moh_id()
  3085. $distinct_offer_id = $this->users->get_distinct_offer_id_having_moh_id();
  3086. $insert_num=0;
  3087. $monday=0;
  3088. $tuesday=0;
  3089. $wednesday=0;
  3090. $thursday=0;
  3091. $friday=0;
  3092. $saturday=0;
  3093. $sunday=0;
  3094. for($i=1;$i<=10;$i++)
  3095. {
  3096. $buss_ins_hrs_available_day = $this->input->post('buss_ins_hrs_available_day_'.$i);
  3097. if($buss_ins_hrs_available_day=='monday')
  3098. {
  3099. $monday++;
  3100. }
  3101. if($buss_ins_hrs_available_day=='tuesday')
  3102. {
  3103. $tuesday++;
  3104. }
  3105. if($buss_ins_hrs_available_day=='wednesday')
  3106. {
  3107. $wednesday++;
  3108. }
  3109. if($buss_ins_hrs_available_day=='thursday')
  3110. {
  3111. $thursday++;
  3112. }
  3113. if($buss_ins_hrs_available_day=='friday')
  3114. {
  3115. $friday++;
  3116. }
  3117. if($buss_ins_hrs_available_day=='saturday')
  3118. {
  3119. $saturday++;
  3120. }
  3121. if($buss_ins_hrs_available_day=='sunday')
  3122. {
  3123. $sunday++;
  3124. }
  3125. }
  3126. for($i=1;$i<=10;$i++)
  3127. {
  3128. $buss_ins_hrs_available_day = $this->input->post('buss_ins_hrs_available_day_'.$i);
  3129. $buss_ins_hrs_time_from = $this->input->post('buss_ins_hrs_time_from_'.$i);
  3130. $buss_ins_hrs_time_to = $this->input->post('buss_ins_hrs_time_to_'.$i);
  3131. $buss_ins_hrs_time_from_am_pm = strtolower($this->input->post('buss_ins_hrs_time_from_am_pm_'.$i));
  3132. $buss_ins_hrs_time_to_am_pm = strtolower($this->input->post('buss_ins_hrs_time_to_am_pm_'.$i));
  3133. if($buss_ins_hrs_available_day!="" && $buss_ins_hrs_time_from!="" && $buss_ins_hrs_time_from_am_pm!="" && $buss_ins_hrs_time_to!="" && $buss_ins_hrs_time_to_am_pm!="" && ( ($buss_ins_hrs_available_day=='monday' && $monday<=1) || ($buss_ins_hrs_available_day=='tuesday' && $tuesday<=1) || ($buss_ins_hrs_available_day=='wednesday' && $wednesday<=1) || ($buss_ins_hrs_available_day=='thursday' && $thursday<=1) || ($buss_ins_hrs_available_day=='friday' && $friday<=1) || ($buss_ins_hrs_available_day=='saturday' && $saturday<=1) || ($buss_ins_hrs_available_day=='sunday' && $sunday<=1) ) )
  3134. {
  3135. $opentime_insert = array(
  3136. 'user_id' => $merchant_id,
  3137. 'day' => $buss_ins_hrs_available_day,
  3138. 'from_hour' => $buss_ins_hrs_time_from,
  3139. 'from_ampm' => $buss_ins_hrs_time_from_am_pm,
  3140. 'to_hour' => $buss_ins_hrs_time_to,
  3141. 'to_ampm' => $buss_ins_hrs_time_to_am_pm
  3142. );
  3143. $query_opentime = $this->db->get_where('merchant_opening_hours', array('user_id' => $merchant_id, 'day' => $buss_ins_hrs_available_day, 'from_hour'=>$buss_ins_hrs_time_from, 'from_ampm'=>$buss_ins_hrs_time_from_am_pm, 'to_hour'=>$buss_ins_hrs_time_to, 'to_ampm'=>$buss_ins_hrs_time_to_am_pm ));
  3144. //echo $this->db->last_query();
  3145. //exit();
  3146. $count_opentime = $query_opentime->num_rows();
  3147. if($count_opentime === 0)
  3148. {
  3149. $this->db->insert('merchant_opening_hours', $opentime_insert);
  3150. $last_opening_insert_id = $this->db->insert_id();
  3151. foreach($distinct_offer_id as $offer_val)
  3152. {
  3153. $offer_id = $offer_val->offer_id;
  3154. if(!empty($offer_id))
  3155. {
  3156. if($update_existing_offers=='1')
  3157. {
  3158. //***** inserting opening hours in existing merchant_offers_available_time start *******//
  3159. if($buss_ins_hrs_time_from_am_pm=='am' || $buss_ins_hrs_time_from_am_pm=='AM')
  3160. {
  3161. if($buss_ins_hrs_time_from==12)
  3162. {
  3163. $from_hours = '0000';
  3164. }else{
  3165. $from_hours = $buss_ins_hrs_time_from * 100;
  3166. if($buss_ins_hrs_time_from>=1 && $buss_ins_hrs_time_from<=9)
  3167. {
  3168. $from_hours = '0'.$from_hours;
  3169. }
  3170. }
  3171. }
  3172. else if($buss_ins_hrs_time_from_am_pm=='pm' || $buss_ins_hrs_time_from_am_pm=='PM')
  3173. {
  3174. if($buss_ins_hrs_time_from==12)
  3175. {
  3176. $from_hours = '1200';
  3177. }else{
  3178. $from_hours = 1200 + ($buss_ins_hrs_time_from * 100);
  3179. }
  3180. }
  3181. if($buss_ins_hrs_time_to_am_pm=='am' || $buss_ins_hrs_time_to_am_pm=='AM')
  3182. {
  3183. if($buss_ins_hrs_time_to==12)
  3184. {
  3185. $to_hours = '0000';
  3186. }else{
  3187. $to_hours = $buss_ins_hrs_time_to * 100;
  3188. if($buss_ins_hrs_time_to>=1 && $buss_ins_hrs_time_to<=9)
  3189. {
  3190. $to_hours = '0'.$to_hours;
  3191. }
  3192. }
  3193. }
  3194. else if($buss_ins_hrs_time_to_am_pm=='pm' || $buss_ins_hrs_time_to_am_pm=='PM')
  3195. {
  3196. if($buss_ins_hrs_time_to==12)
  3197. {
  3198. $to_hours = '1200';
  3199. }else{
  3200. $to_hours = 1200 + ($buss_ins_hrs_time_to * 100);
  3201. }
  3202. }
  3203. $days_display_order='';
  3204. if($buss_ins_hrs_available_day=='monday')
  3205. {
  3206. $days_display_order = '1';
  3207. }else if($buss_ins_hrs_available_day=='tuesday'){
  3208. $days_display_order = '2';
  3209. }
  3210. else if($buss_ins_hrs_available_day=='wednesday'){
  3211. $days_display_order = '3';
  3212. }
  3213. else if($buss_ins_hrs_available_day=='thursday'){
  3214. $days_display_order = '4';
  3215. }
  3216. else if($buss_ins_hrs_available_day=='friday'){
  3217. $days_display_order = '5';
  3218. }
  3219. else if($buss_ins_hrs_available_day=='saturday'){
  3220. $days_display_order = '6';
  3221. }
  3222. else if($buss_ins_hrs_available_day=='sunday'){
  3223. $days_display_order = '7';
  3224. }
  3225. $available_time_data = array(
  3226. 'offer_id' => $offer_id,
  3227. 'merchant_id' => $merchant_id,
  3228. 'available_day' => $buss_ins_hrs_available_day,
  3229. 'time_from' => $buss_ins_hrs_time_from,
  3230. 'time_from_am_pm' => $buss_ins_hrs_time_from_am_pm,
  3231. 'from_hours' => $from_hours,
  3232. 'time_to' => $buss_ins_hrs_time_to,
  3233. 'time_to_am_pm' => $buss_ins_hrs_time_to_am_pm,
  3234. 'to_hours' => $to_hours,
  3235. 'quantity' => '1',
  3236. 'max_pax' => '',
  3237. 'added_date' => date('Y-m-d H:i:s'),
  3238. 'available_time_slots_capacity' => '3',
  3239. 'days_display_order' => $days_display_order,
  3240. 'moh_id' => $last_opening_insert_id
  3241. );
  3242. if(!empty($offer_id))
  3243. {
  3244. $this->db->insert('merchant_offers_available_time', $available_time_data);
  3245. //echo $this->db->last_query();
  3246. //exit();
  3247. }
  3248. //***** inserting opening hours in existing merchant_offers_available_time start *******//
  3249. }
  3250. }
  3251. }
  3252. $insert_num++;
  3253. }
  3254. }
  3255. }
  3256. if($num++)
  3257. {
  3258. echo 'Business hours updated successfully!';
  3259. }
  3260. //-------------- inserting new available time end ---------------------//
  3261. }
  3262. public function viewbusinesshours()
  3263. {
  3264. $data['merchant_opening_hours'] = $this->users->get_merchant_opening_hours();
  3265. $merchant_business_type_str = $this->users->get_merchant_business_type();
  3266. $merchant_business_type = array();
  3267. if(!empty($merchant_business_type_str))
  3268. {
  3269. $merchant_business_type = explode(",",$merchant_business_type_str);
  3270. $data['merchant_business_type'] = $merchant_business_type;
  3271. }
  3272. $this->load->view('/merchantaccount/viewbusinesshours', $data);
  3273. }
  3274. public function bookingslist()
  3275. {
  3276. /* USER ACCESS TYPE CHECK DATA START */
  3277. $logged_user_access_type = $this->users->get_user_access_type();
  3278. $data['logged_user_access_type'] = $logged_user_access_type;
  3279. $data['logged_user_access_sections'] = array();
  3280. if($logged_user_access_type=='3')
  3281. {
  3282. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  3283. if($logged_user_access_type=='2' || ($logged_user_access_type=='3' && in_array("6",$data['logged_user_access_sections'])) )
  3284. {
  3285. }else{
  3286. redirect('/home', 'refresh');
  3287. exit();
  3288. }
  3289. }
  3290. /* USER ACCESS TYPE CHECK DATA END */
  3291. $offer_search="";
  3292. $offer_search = $this->input->post('offer_search');
  3293. $data['offer_search']=$offer_search;
  3294. $data['title']='Services on demand - Ondi.com';
  3295. $data['current_bookings_dates'] = $this->users->get_current_bookings_dates($offer_search);
  3296. $this->load->view('/merchantaccount/bookingslist', $data);
  3297. }
  3298. public function editbookingtime()
  3299. {
  3300. // $merchant_id=$this->CI_auth->logged_id();
  3301. $merchant_id=$this->users->get_main_merchant_id();
  3302. /* USER ACCESS TYPE CHECK DATA START */
  3303. $logged_user_access_type = $this->users->get_user_access_type();
  3304. $data['logged_user_access_type'] = $logged_user_access_type;
  3305. $data['logged_user_access_sections'] = array();
  3306. if($logged_user_access_type=='3')
  3307. {
  3308. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  3309. if($logged_user_access_type=='2' || ($logged_user_access_type=='3' && in_array("7",$data['logged_user_access_sections'])) )
  3310. {
  3311. }else{
  3312. redirect('/home', 'refresh');
  3313. exit();
  3314. }
  3315. }
  3316. /* USER ACCESS TYPE CHECK DATA END */
  3317. $booking_date = $this->input->post('booking_date');
  3318. $booking_time = $this->input->post('booking_time');
  3319. $booking_time_ampm = $this->input->post('booking_time_ampm');
  3320. $offer_id = $this->input->post('offer_id');
  3321. $id = $this->input->post('id'); // order_id
  3322. $booking_date = $this->input->post('booking_date');
  3323. if($booking_date!="")
  3324. {
  3325. $booking_date_arr = explode("/",$booking_date);
  3326. $d='';
  3327. $m='';
  3328. $y='';
  3329. if(isset($booking_date_arr[0]))
  3330. {
  3331. $d = $booking_date_arr[0];
  3332. }
  3333. if(isset($booking_date_arr[1]))
  3334. {
  3335. $m = $booking_date_arr[1];
  3336. }
  3337. if($booking_date_arr[2])
  3338. {
  3339. $y = $booking_date_arr[2];
  3340. }
  3341. if($d!='' && $m!='' && $y!='')
  3342. {
  3343. $booking_date = $y.'-'.$m.'-'.$d;
  3344. }
  3345. }
  3346. if(!empty($booking_time))
  3347. {
  3348. $booking_time = date("Hi", strtotime($booking_time.' '.$booking_time_ampm));
  3349. }
  3350. $data_update = array('booking_date'=>$booking_date, 'booking_time'=>$booking_time, 'booking_time_ampm'=>$booking_time_ampm);
  3351. /*
  3352. echo '<pre>';
  3353. print_r($data_update);
  3354. echo '</pre>';
  3355. */
  3356. $this->db->where(array('order_id'=>$id, 'offer_id'=>$offer_id));
  3357. $this->db->update('orders', $data_update);
  3358. echo 'Updated successfully.';
  3359. }
  3360. public function bookingshistory()
  3361. {
  3362. /* USER ACCESS TYPE CHECK DATA START */
  3363. $logged_user_access_type = $this->users->get_user_access_type();
  3364. $data['logged_user_access_type'] = $logged_user_access_type;
  3365. $data['logged_user_access_sections'] = array();
  3366. if($logged_user_access_type=='3')
  3367. {
  3368. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  3369. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  3370. if($logged_user_access_type=='2' || ($logged_user_access_type=='3' && in_array("8",$data['logged_user_access_sections'])) )
  3371. {
  3372. }else{
  3373. redirect('/home', 'refresh');
  3374. exit();
  3375. }
  3376. }
  3377. /* USER ACCESS TYPE CHECK DATA END */
  3378. $offer_search="";
  3379. $offer_search = $this->input->post('offer_search');
  3380. $data['offer_search']=$offer_search;
  3381. $data['title']='Services on demand - Ondi.com';
  3382. $data['history_bookings_dates'] = $this->users->get_history_bookings_dates($offer_search);
  3383. $this->load->view('/merchantaccount/bookingshistory', $data);
  3384. }
  3385. public function notificationoptions()
  3386. {
  3387. /* USER ACCESS TYPE CHECK DATA START */
  3388. $logged_user_access_type = $this->users->get_user_access_type();
  3389. $logged_user_access_sections = array();
  3390. if($logged_user_access_type=='3')
  3391. {
  3392. $logged_user_access_sections = $this->users->get_user_access_sections();
  3393. }
  3394. /* USER ACCESS TYPE CHECK DATA END */
  3395. // $logged_user_id = $this->CI_auth->logged_id();
  3396. $logged_user_id = $this->users->get_main_merchant_id();
  3397. if($this->input->post('notification_action'))
  3398. {
  3399. $notification_options='';
  3400. if($this->input->post('notification_options')>0)
  3401. {
  3402. $notification_options = implode(",",$this->input->post('notification_options'));
  3403. $notification_data = array('merchant_notification_options ' => $notification_options );
  3404. $this->db->where('user_id', $logged_user_id);
  3405. $this->db->update('users', $notification_data);
  3406. }
  3407. }
  3408. $notification_options = $this->users->get_notification_options();
  3409. $merchant_notification_options='';
  3410. $user_detail = $this->users->get_user_detail($logged_user_id);
  3411. /*
  3412. echo '<pre>';
  3413. print_r($user_detail);
  3414. echo '</pre>';
  3415. */
  3416. $merchant_notification_options_arr = array();
  3417. $merchant_notification_options = $user_detail[0]->merchant_notification_options;
  3418. if($merchant_notification_options!="")
  3419. {
  3420. $merchant_notification_options_arr = explode(",",$merchant_notification_options);
  3421. }
  3422. $data=array('title'=>'Notification options', 'logged_user_access_type'=>$logged_user_access_type, 'logged_user_access_sections'=>$logged_user_access_sections, 'notification_options'=>$notification_options, 'merchant_notification_options'=>$merchant_notification_options_arr);
  3423. $this->session->set_flashdata('user_message', 'Updated successfully.');
  3424. redirect('/merchantaccount/notificationoptions/', 'refresh');
  3425. $this->load->view('/merchantaccount/notificationoptions', $data);
  3426. }
  3427. public function viewbusinessprofile()
  3428. {
  3429. $user_id=''; // hard coded as of now
  3430. // $user_id=$this->CI_auth->logged_id();
  3431. $user_id=$this->users->get_main_merchant_id();
  3432. $this->db->select('merchant_steps_completed');
  3433. $merchant_steps_completed_query = $this->db->get_where('users', array('user_id' => $user_id));
  3434. $data_merchant_steps_completed = $merchant_steps_completed_query->result();
  3435. $merchant_steps_completed = $data_merchant_steps_completed[0]->merchant_steps_completed;
  3436. if($merchant_steps_completed == '0')
  3437. {
  3438. redirect('/merchantaccount/contactinfo', 'refresh');
  3439. }
  3440. $this->db->select('a.*, b.state as state_name, c.pg_name, d.pf_name');
  3441. $this->db->from('merchant_businessprofile as a');
  3442. $this->db->join('states as b', 'a.state = b.state_id', 'left');
  3443. $this->db->join('price_guide as c', 'a.price_guide = c.pg_id', 'left');
  3444. $this->db->join('perfect_for as d', 'a.perfect_for = d.pf_id', 'left');
  3445. $condition=array('a.user_id' => $user_id);
  3446. $this->db->where($condition);
  3447. $userquery = $this->db->get();
  3448. $userdata = $userquery->result();
  3449. $business_type = $userdata[0]->business_type;
  3450. $service_offered = $userdata[0]->service_offered;
  3451. $perfect_for = $userdata[0]->perfect_for;
  3452. if($business_type != '')
  3453. {
  3454. $business_type_array = explode(",", $business_type);
  3455. $this->db->select('type_name');
  3456. $this->db->from('business_types');
  3457. $bussiness_condition=array('delete_status' => '0'); // as per new update.
  3458. $this->db->where($bussiness_condition);
  3459. $this->db->where_in('type_id', $business_type_array);
  3460. $business_typequery = $this->db->get();
  3461. $data_business_type = $business_typequery->result();
  3462. }
  3463. if($service_offered != '')
  3464. {
  3465. $service_offered_array = explode(",", $service_offered);
  3466. $this->db->select('option_value');
  3467. $this->db->from('business_types_options');
  3468. $this->db->where_in('id', $service_offered_array);
  3469. $service_offeredquery = $this->db->get();
  3470. $data_service_offered = $service_offeredquery->result();
  3471. }
  3472. if($perfect_for != '')
  3473. {
  3474. $perfect_for_array = explode(",", $perfect_for);
  3475. $this->db->select('pf_name');
  3476. $this->db->from('perfect_for');
  3477. $this->db->where_in('pf_id', $perfect_for_array);
  3478. $perfect_forquery = $this->db->get();
  3479. $data_perfect_for = $perfect_forquery->result();
  3480. }
  3481. //print_r($data_perfect_for);
  3482. //$this->db->select('*');
  3483. //$opening_hours_query = $this->db->get_where('merchant_opening_hours', array('user_id' => $user_id));
  3484. $condition=array('a.user_id' => $user_id);
  3485. $this->db->select('a.*');
  3486. $this->db->from('merchant_opening_hours as a');
  3487. $this->db->join('days as b', 'b.day_name = a.day', 'left');
  3488. //$this->db->order_by("b.day_display_order", "asc");
  3489. $this->db->order_by('b.day_display_order asc, a.id asc');
  3490. $this->db->where($condition);
  3491. $opening_hours_query = $this->db->get();
  3492. $data = array('userdata' => $userdata, 'logged_user_access_type'=>$logged_user_access_type, 'data_business_type' => $data_business_type, 'data_service_offered' => $data_service_offered, 'opening_hours_query' => $opening_hours_query->result(), 'data_perfect_for' => $data_perfect_for);
  3493. /* USER ACCESS TYPE CHECK DATA START */
  3494. $logged_user_access_type = $this->users->get_user_access_type();
  3495. $data['logged_user_access_type'] = $logged_user_access_type;
  3496. $data['logged_user_access_sections'] = array();
  3497. if($logged_user_access_type=='3')
  3498. {
  3499. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  3500. }
  3501. /* USER ACCESS TYPE CHECK DATA END */
  3502. $data['title'] = 'Services on demand - Ondi.com';
  3503. $this->load->view('/merchantaccount/viewbusinessprofile', $data);
  3504. }
  3505. public function viewcontactinfo()
  3506. {
  3507. /* USER ACCESS TYPE CHECK DATA START */
  3508. $logged_user_access_type = $this->users->get_user_access_type();
  3509. $data['logged_user_access_type'] = $logged_user_access_type;
  3510. $data['logged_user_access_sections'] = array();
  3511. if($logged_user_access_type=='3')
  3512. {
  3513. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  3514. if(!in_array("1",$data['logged_user_access_sections']))
  3515. {
  3516. redirect('/merchantaccount/welcomeuser', 'refresh');
  3517. }
  3518. }
  3519. /* USER ACCESS TYPE CHECK DATA END */
  3520. $user_id='';
  3521. // $user_id=$this->CI_auth->logged_id();
  3522. $user_id=$this->users->get_main_merchant_id();
  3523. $data['title'] = 'Services on demand - Ondi.com';
  3524. $this->db->select('email, position, position_other, phone, contact_name, terms_condition, merchant_steps_completed');
  3525. $query = $this->db->get_where('users', array('user_id' => $user_id));
  3526. $data['user_data'] = $query->result();
  3527. $merchant_steps_completed=$data['user_data'][0]->merchant_steps_completed;
  3528. $this->load->view('/merchantaccount/viewcontactinfo', $data);
  3529. }
  3530. public function viewbankingdetails()
  3531. {
  3532. /* USER ACCESS TYPE CHECK DATA START */
  3533. $logged_user_access_type = $this->users->get_user_access_type();
  3534. $data['logged_user_access_type'] = $logged_user_access_type;
  3535. $data['logged_user_access_sections'] = array();
  3536. if($logged_user_access_type=='3')
  3537. {
  3538. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  3539. }
  3540. /* USER ACCESS TYPE CHECK DATA END */
  3541. $user_id='';
  3542. // $user_id=$this->CI_auth->logged_id();
  3543. $user_id=$this->users->get_main_merchant_id();
  3544. $data['title'] = 'Services on demand - Ondi.com';
  3545. $this->db->select('branch_name, account_name, bsb, account_number, abn, merchant_steps_completed');
  3546. $query = $this->db->get_where('users', array('user_id' => $user_id));
  3547. $data['user_data'] = $query->result();
  3548. $merchant_steps_completed=$data['user_data'][0]->merchant_steps_completed;
  3549. if($merchant_steps_completed==1)
  3550. {
  3551. redirect('/merchantaccount/businessprofile', 'refresh');
  3552. }
  3553. $this->load->view('/merchantaccount/viewbankingdetails', $data);
  3554. }
  3555. public function mynotifications()
  3556. {
  3557. /* USER ACCESS TYPE CHECK DATA START */
  3558. $logged_user_access_type = $this->users->get_user_access_type();
  3559. $data['logged_user_access_type'] = $logged_user_access_type;
  3560. $data['logged_user_access_sections'] = array();
  3561. if($logged_user_access_type=='3')
  3562. {
  3563. $data['logged_user_access_sections'] = $this->users->get_user_access_sections();
  3564. }
  3565. /* USER ACCESS TYPE CHECK DATA END */
  3566. $user_notifications_data = $this->users->get_user_notification_data();
  3567. $unread_notifications = $user_notifications_data['unread'];
  3568. $notifications = $user_notifications_data['notifications_data'];
  3569. //$data = array('notifications' => $notifications);
  3570. $data['notifications'] = $notifications;
  3571. $this->load->view('/merchantaccount/mynotifications', $data);
  3572. }
  3573. public function invoice()
  3574. {
  3575. if(isset($_GET['bid']))
  3576. {
  3577. $bid = base64_decode($_GET['bid']);
  3578. }
  3579. $condition=array('a.order_id' => $bid);
  3580. $this->db->select('a.*, b.offer_title, b.price, b.offer_description, c.business_name, c.website_address, c.street_address, c.suburb, c.post_code, d.state');
  3581. $this->db->from('orders as a');
  3582. $this->db->join('merchant_offers as b', 'a.offer_id = b.id', 'left');
  3583. $this->db->join('merchant_businessprofile as c', 'b.merchant_id = c.user_id', 'left');
  3584. $this->db->join('states as d', 'c.state = d.state_id', 'left');
  3585. $this->db->where($condition);
  3586. $orders_query = $this->db->get();
  3587. $data = array('dataorders' => $orders_query->result());
  3588. $this->load->view('/customeraccount/invoice', $data);
  3589. }
  3590. }
  3591. ?>