home - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of home.php

  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. class Home extends CI_Controller {
  4.  
  5. ############################################ FUNCTION CONSTRUCTOR #################################
  6. function __construct()
  7. {
  8.         parent::__construct();
  9.         if(!$this->session->userdata('logged_in'))
  10.         {
  11.                 redirect('login','refresh');
  12.         }
  13.  
  14.         if($this->session->userdata('logged_in')['first_login_status']==0 && $this->uri->segment(1)!='update-password')
  15.         {
  16.                 redirect('update-password');
  17.         }
  18.  
  19.         if($this->session->userdata('logged_in')['first_login_status']==1 && $this->uri->segment(1)!='profile')
  20.         {
  21.                 redirect('profile');
  22.         }
  23.  
  24.         $this->load->model('Common_model');
  25.         $this->load->model('Manage_model');
  26.  
  27.         if($this->session->userdata('logged_in')['privilege_id']==4)
  28.         {
  29.                 $organizations_id = $this->session->userdata('logged_in')['table_id'];
  30.                 $OD = $this->Manage_model->get_organization_details($organizations_id);
  31.                 date_default_timezone_set($OD['timezone']);
  32.         }
  33.         else
  34.         {
  35.                 date_default_timezone_set('Asia/Qatar');
  36.         }      
  37. }
  38. ############################################ END OF FUNCTION CONSTRUCTOR ##########################
  39.  
  40. ############################################ COMMON VIEW PAGE #####################################
  41. public function CommonPage($page,$data,$PageName='')
  42. {
  43.         $SD['side_menu'] = $this->Common_model->get_side_menu();
  44.  
  45.         $CurrentUrlId = $this->Common_model->get_current_url_id();
  46.         $AllowedMenu = $this->Common_model->allowed_menus_by_privilege();
  47.         $AllowedMainMenu = json_decode($AllowedMenu['main_menu']);
  48.         $AllowedSubMenu = json_decode($AllowedMenu['sub_menu']);
  49.  
  50.         if($CurrentUrlId['MainMenu']!='0')
  51.         {
  52.                 if(!in_array($CurrentUrlId['MainMenu'],$AllowedMainMenu))
  53.                 {
  54.                         redirect('dashboard','refresh');
  55.                 }
  56.         }
  57.  
  58.         if($CurrentUrlId['SubMenu']!='0')
  59.         {
  60.                 if(!in_array($CurrentUrlId['SubMenu'],$AllowedSubMenu))
  61.                 {
  62.                         redirect('dashboard','refresh');
  63.                 }
  64.         }
  65.  
  66.         if($this->uri->segment(1)=='meeting-details'){ $SD['MD'] = $data['MD']; } // setup side menu
  67.  
  68.         $HeadData['PageName'] = $PageName;
  69.  
  70.         $this->load->view('include/header',$HeadData);
  71.         $this->load->view('include/head',$HeadData);
  72.         $this->load->view('include/sidemenu',$SD);
  73.         $this->load->view($page,$data);
  74.         $this->load->view('include/footer');
  75. }
  76. ############################################ END OF COMMON VIEW PAGE ##############################
  77.  
  78. ############################################ LOGOUT ###############################################
  79. public function logout()
  80. {
  81.         // Activity Log Record
  82.         $user_data = $this->session->userdata('logged_in');
  83.         $head = 'Logged Out';
  84.         $description = $user_data['name'].' ('.$user_data['username'].') Has been Logged Out';
  85.         $this->Common_model->create_activity_log($head,$description,'',array(),array(),'1');
  86.         // Activity Log Record
  87.         session_destroy();
  88.         redirect('home','refresh');
  89. }
  90. ############################################ END OF LOGOUT ########################################
  91.  
  92. ############################################ CHANGE PASSWORD ######################################
  93. public function change_password()
  94. {
  95.         if(isset($_POST['ChangePassword']))
  96.         {
  97.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  98.                 $this->form_validation->set_rules('current_url','current_url','trim|required|xss_clean');
  99.                 $this->form_validation->set_rules('current_password','current_password','trim|required|xss_clean');
  100.                 $this->form_validation->set_rules('new_password','new_password','trim|required|xss_clean|min_length[8]');
  101.                 $this->form_validation->set_rules('confirm_password','confirm_password','trim|required|xss_clean|min_length[8]');
  102.                 $current_url = $this->input->post('current_url');
  103.                 if($this->form_validation->run())
  104.                 {
  105.                         $current_password = $this->input->post('current_password');
  106.                         $new_password = $this->input->post('new_password');  
  107.                         $confirm_password = $this->input->post('confirm_password');
  108.        
  109.                         $users_id = $this->session->userdata('logged_in')['users_id'];
  110.                         $UD = $this->Common_model->get_user_details($users_id);
  111.                         if($UD['password']==MD5($current_password))
  112.                         {
  113.                                 if($new_password==$confirm_password)
  114.                                 {
  115.                                         $value = array('password'=>MD5($new_password));
  116.                                         $where = array('users_id'=>$users_id);
  117.                                         $this->Common_model->common_update('users',$value,$where);
  118.                                         $this->Common_model->Set_Message('1','Password changed successfully');
  119.  
  120.                                         // sent Mail - password change
  121.                                         if($UD['privilege_id']=='4' || $UD['privilege_id']=='5')
  122.                                         {
  123.                                                 $this->SentMail('8',$UD['username'],'');
  124.                                         }
  125.                                         // sent Mail - password change
  126.                                 }
  127.                                 else
  128.                                 {
  129.                                         $this->Common_model->Set_Message('2','Password not matching');
  130.                                 }
  131.                         }
  132.                         else
  133.                         {
  134.                                 $this->Common_model->Set_Message('2','Current password is incorrect');
  135.                         }
  136.                         redirect($current_url);
  137.                 }
  138.                 else
  139.                 {
  140.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  141.                         redirect($current_url);
  142.                 }
  143.         }
  144.         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  145.         redirect('dashboard');
  146. }
  147. ############################################ END OF CHANGE PASSWORD ###############################
  148.  
  149. ############################################ INDEX ################################################
  150. public function index()
  151. {
  152.         redirect('dashboard','refresh');
  153. }
  154. ############################################ END OF INDEX #########################################
  155.  
  156. ############################################ UPDATE PASSWORD ######################################
  157. public function update_password()
  158. {
  159.         $user_data = $this->session->userdata('logged_in');
  160.         if(isset($_POST['ChangePassword']))
  161.         {
  162.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  163.                 $this->form_validation->set_rules('password','Password','trim|required|xss_clean|min_length[8]');
  164.                 $this->form_validation->set_rules('c_password','Confirm Password','trim|required|xss_clean|min_length[8]|matches[password]');
  165.                 if($this->form_validation->run())
  166.                 {
  167.                         $password = $this->input->post('password');
  168.                         $value = array('password'=>MD5($password),'first_login_status'=>'1');
  169.                         $where = array('users_id'=>$user_data['users_id']);
  170.                         $this->Common_model->common_update('users',$value,$where);
  171.  
  172.                         $UD = $this->Common_model->get_user_details($user_data['users_id']);
  173.                         // sent Mail - password change
  174.                         if($UD['privilege_id']=='4' || $UD['privilege_id']=='5')
  175.                         {
  176.                                 $this->SentMail('8',$UD['username'],'');
  177.                         }
  178.                         // sent Mail - password change
  179.  
  180.                         // reset session
  181.                         $sess_data = $user_data;
  182.                         $sess_data['first_login_status'] = '1';
  183.                         $this->session->set_userdata('logged_in', $sess_data);
  184.  
  185.                         $this->Common_model->Set_message('1','Password changed successfully');
  186.                         redirect('dashboard');
  187.                 }
  188.         }
  189.  
  190.         $this->load->view('dashboard/update_password','');
  191. }
  192. ############################################ END OF UPDATE PASSWORD ###############################
  193.  
  194. ############################################ DASHBOARDD ###########################################
  195. public function dashboard()
  196. {
  197.         $data = array();
  198.  
  199.         if($this->session->userdata('logged_in')['privilege_id']==4)
  200.         {
  201.                 // dashboard statistics
  202.                 $organizations_id = $this->session->userdata('logged_in')['table_id'];
  203.                 // $data['TotalMeetings'] = $this->Manage_model->get_meetings_total_count($organizations_id);
  204.                 // $data['CancelledMeetings'] = $this->Manage_model->get_meetings_cancelled_count($organizations_id);
  205.                 // $data['UpcomingMeetings'] = $this->Manage_model->get_meetings_upcoming_count($organizations_id);
  206.                 // $data['CompletedMeetings'] = $this->Manage_model->get_meetings_completed_count($organizations_id);
  207.  
  208.                 $data['TotalCompanies'] = $this->Manage_model->get_total_companies($organizations_id);
  209.                 $data['TotalCompanyMembers'] = $this->Manage_model->get_total_company_members($organizations_id);
  210.  
  211.                 $data['TotalOrgMembers'] = $this->Manage_model->get_total_org_members($organizations_id);
  212.                 $data['TotalOrgSecurities'] = $this->Manage_model->get_total_org_securities($organizations_id);
  213.  
  214.                 $data['PendingRequests'] = $this->Manage_model->get_total_org_pending_requests($organizations_id);
  215.                 // dashboard statistics
  216.  
  217.                 // org details
  218.                 $OD = $this->Manage_model->get_organization_details($organizations_id);
  219.                 $data['BalanceMeetings'] = $OD['meetings_count'];
  220.                 $data['MembersPerMeeting'] = $OD['members_count'];
  221.  
  222.                 // List
  223.                 // $data['UpcomingMeetingsList'] = $this->Manage_model->view_upcoming_meetings();
  224.                 // $data['LatestMeetingsList'] = $this->Manage_model->view_latest_meetings();
  225.  
  226.                 $data['OD'] = $OD;
  227.         }
  228.         elseif($this->session->userdata('logged_in')['privilege_id']==5)
  229.         {
  230.                 // dashboard statistics
  231.                 $organizations_id = $this->session->userdata('logged_in')['table_id'];
  232.                 $data['TotalMeetings'] = $this->Manage_model->get_meetings_total_count($organizations_id);
  233.                 $data['CancelledMeetings'] = $this->Manage_model->get_meetings_cancelled_count($organizations_id);
  234.                 $data['UpcomingMeetings'] = $this->Manage_model->get_meetings_upcoming_count($organizations_id);
  235.                 $data['CompletedMeetings'] = $this->Manage_model->get_meetings_completed_count($organizations_id);
  236.  
  237.                 $data['TotalOrgMembers'] = $this->Manage_model->get_total_org_members($organizations_id);
  238.                 $data['TotalOrgSecurities'] = $this->Manage_model->get_total_org_securities($organizations_id);
  239.                 // dashboard statistics
  240.  
  241.                 // org details
  242.                 $OD = $this->Manage_model->get_organization_details($organizations_id);
  243.                 $data['BalanceMeetings'] = $OD['meetings_count'];
  244.                 $data['MembersPerMeeting'] = $OD['members_count'];
  245.  
  246.                 // List
  247.  
  248.                 $data['OD'] = $OD;
  249.         }
  250.         elseif($this->session->userdata('logged_in')['privilege_id']==1 || $this->session->userdata('logged_in')['privilege_id']==2)
  251.         {
  252.                 // $data['TotalMeetings'] = $this->Manage_model->get_meetings_total_count('');
  253.                 // $data['CancelledMeetings'] = $this->Manage_model->get_meetings_cancelled_count('');
  254.                 // $data['UpcomingMeetings'] = $this->Manage_model->get_meetings_upcoming_count('');
  255.                 // $data['CompletedMeetings'] = $this->Manage_model->get_meetings_completed_count('');
  256.                 // $data['TotalMembers'] = $this->Manage_model->get_total_members();
  257.                 $data['TotalCompanies'] = $this->Manage_model->get_total_companies('');
  258.                 $data['TotalOrganization'] = $this->Manage_model->get_total_organizations();
  259.                 $data['TotalRegistrations'] = $this->Manage_model->get_total_registrations();
  260.         }
  261.         elseif($this->session->userdata('logged_in')['privilege_id']==6)
  262.         {
  263.                 $country_id = $this->session->userdata('logged_in')['table_id']; // for country admin only
  264.  
  265.                 $data['TotalMeetings'] = $this->Manage_model->get_meetings_total_count('',$country_id);
  266.                 $data['CancelledMeetings'] = $this->Manage_model->get_meetings_cancelled_count('',$country_id);
  267.                 $data['UpcomingMeetings'] = $this->Manage_model->get_meetings_upcoming_count('',$country_id);
  268.                 $data['CompletedMeetings'] = $this->Manage_model->get_meetings_completed_count('',$country_id);
  269.                 $data['TotalMembers'] = $this->Manage_model->get_total_members($country_id);
  270.                 $data['TotalCompanies'] = $this->Manage_model->get_total_companies('',$country_id);
  271.                 $data['TotalOrganization'] = $this->Manage_model->get_total_organizations($country_id);
  272.                 $data['TotalRegistrations'] = $this->Manage_model->get_total_registrations($country_id);
  273.  
  274.                 $data['OD'] = $this->Manage_model->get_country_admin_details($country_id);
  275.  
  276.                 $FD = array('country_id'=>$country_id,'start_date'=>'','end_date'=>'');
  277.                 $data['GrandTotal'] = $this->Manage_model->subscription_report_grand_total($FD,'','','0');
  278.                 $data['TotalSubscription'] = $this->Manage_model->get_total_subscription($FD,'','','0');
  279.         }
  280.  
  281.         if($this->session->userdata('logged_in')['privilege_id']==4)
  282.         {
  283.                 $MenuName = 'Organization Dashboard';
  284.         }
  285.         elseif($this->session->userdata('logged_in')['privilege_id']==5)
  286.         {
  287.                 $MenuName = 'Residential Dashboard';
  288.         }
  289.         else
  290.         {
  291.                 $MenuName = 'Meet Pass Dashboard';
  292.         }
  293.  
  294.         $this->CommonPage('dashboard/dashboard',$data,$MenuName);
  295. }
  296. ############################################ END OF DASHBOARDD ####################################
  297.  
  298. ############################################ COMMON AJAX REQUESTS #################################
  299. public function get_places_select()
  300. {
  301.         $Data = '<option value="">Select Place</option>';
  302.         if(isset($_POST['data_id']))
  303.         {
  304.                 $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean');
  305.                 if($this->form_validation->run())
  306.                 {
  307.                         $country_id = $this->input->post('data_id');
  308.                         $DT = $this->Manage_model->select_view_places($country_id);
  309.                         foreach($DT as $DT1)
  310.                         {
  311.                                 $Data .= '<option value="'.$DT1->places_id.'">'.$DT1->places.'</option>';
  312.                         }
  313.                 }
  314.         }
  315.  
  316.         $data['result'] = $Data;
  317.         echo json_encode($data);
  318. }
  319.  
  320. public function get_members_autocomplete_type()
  321. {
  322.         $data['response'] = 'false';
  323.         $data['message'] = array();
  324.  
  325.         if(isset($_POST['keyword']))
  326.         {
  327.                 $this->form_validation->set_rules('keyword','keyword','trim|required|xss_clean');
  328.                 $this->form_validation->set_rules('type_id','type_id','trim|required|xss_clean');
  329.                 if($this->form_validation->run())
  330.                 {
  331.                         $keyword = $this->input->post('keyword');
  332.                         $type_id = $this->input->post('type_id');
  333.                         if($type_id==0)
  334.                         {
  335.                                 $CD = $this->Manage_model->get_organization_members_autocomplete($keyword);
  336.                         }
  337.                         else
  338.                         {
  339.                                 $CD = $this->Manage_model->get_company_members_autocomplete($keyword);
  340.                         }
  341.                        
  342.                         $data['response'] = 'true';
  343.                         $data['message'] = $CD;
  344.                 }
  345.         }
  346.         echo json_encode($data);
  347. }
  348.  
  349. public function get_members_autocomplete_meetings()
  350. {
  351.         $CD = array();
  352.         if(isset($_POST['member_type']))
  353.         {
  354.                 $this->form_validation->set_rules('member_type','member_type','trim|required|xss_clean');
  355.                 $this->form_validation->set_rules('company_id','company_id','trim|required|xss_clean');
  356.                 if($this->form_validation->run())
  357.                 {
  358.                         $member_type = $this->input->post('member_type');
  359.                         $company_id = $this->input->post('company_id');
  360.                         if($member_type==0)
  361.                         {
  362.                                 $CD = $this->Manage_model->view_members_select();
  363.                         }
  364.                         else
  365.                         {
  366.                                 $CD = $this->Manage_model->view_company_members_select($company_id);
  367.                         }
  368.                 }
  369.         }
  370.  
  371.         $Message = '<input type="text" class="form-control mb10 form-control-sm" id="SearchMember" onkeyup="search_member_list()" placeholder="Search"><li class="SelectAll"><label class="CheckBoxLabel" for="MainCheckBox"><input type="checkbox" name="MainCheckBox" id="MainCheckBox"> Select All</label></li>';
  372.         foreach($CD as $DT1)
  373.         {
  374.                 $Message .= '<li><label class="CheckBoxLabel" for="CHK'.$DT1->members_id.'"><input type="checkbox" class="SubCheckBox" name="members_id['.$DT1->members_sub_id.']" id="CHK'.$DT1->members_id.'" value="'.$DT1->members_id.'"> '.$DT1->name.' - '.$DT1->phone.' - '.$DT1->designation.'</label></li>';
  375.         }
  376.  
  377.         echo json_encode($Message);
  378. }
  379. ############################################ END OF COMMON AJAX REQUESTS ##########################
  380.  
  381. ############################################ ASSIGN PRIVILEGE MENU ################################
  382. public function assign_menu()
  383. {
  384.         if(isset($_POST['save_menu']))
  385.         {
  386.                 $created_by = $this->session->userdata('logged_in')['users_id'];
  387.                 $privilege_id = trim($this->input->post('privilege_id'));
  388.                 if($privilege_id!='' && $privilege_id!='0')
  389.                 {
  390.                         $main_menu = $sub_menu = array();
  391.                         if(isset($_POST['main_menu']))
  392.                         {
  393.                                 $main_menu = $this->input->post('main_menu');
  394.                         }
  395.                         if(isset($_POST['sub_menu']))
  396.                         {
  397.                                 $sub_menu = $this->input->post('sub_menu');
  398.                         }
  399.                         $main_menu[] = '1';
  400.                         $main_menu = array_unique($main_menu);
  401.                         $main_menu = json_encode($main_menu);
  402.                         $sub_menu = json_encode($sub_menu);
  403.                         $AP_menu = $this->Manage_model->get_privilege_menu($privilege_id);
  404.                         if(!empty($AP_menu))
  405.                         {
  406.                                 $where = array('privilege_id'=>$privilege_id);
  407.                                 $value = array('main_menu'=>$main_menu,'sub_menu'=>$sub_menu);
  408.                                 $this->Common_model->common_update('crm_menu_user',$value,$where);
  409.                         }
  410.                         else
  411.                         {
  412.                                 $value = array('created_by'=>$created_by,'privilege_id'=>$privilege_id,'main_menu'=>$main_menu,'sub_menu'=>$sub_menu);
  413.                                 $this->Common_model->common_insert('crm_menu_user',$value);
  414.                         }
  415.                         $this->Common_model->Set_Message('1',"<strong>Success!</strong> User Menu Re-arranged Successfully");
  416.                         $_SESSION['AM_privilege_id'] = $privilege_id;
  417.  
  418.                         // Activity Log Record
  419.                         $head = 'CRM Menu Updated';
  420.                         $description = 'User Menu Updated By ';
  421.                         $this->Common_model->create_activity_log($head,$description,'',array(),array(),'2');
  422.                         // Activity Log Record
  423.                 }
  424.                 else
  425.                 {
  426.                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Oops something went wrong. Please try again.");
  427.                 }
  428.                 redirect(current_url());
  429.         }
  430.  
  431.         if(isset($_POST['submit']))
  432.         {
  433.                 $privilege_id = trim($this->input->post('privilege_id'));
  434.                 if($privilege_id!='' && $privilege_id!='0')
  435.                 {
  436.                         $_SESSION['AM_privilege_id'] = $privilege_id;
  437.                 }
  438.                 else
  439.                 {
  440.                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Oops something went wrong. Please try again.");
  441.                 }
  442.                 redirect(current_url());
  443.         }
  444.         elseif(isset($_SESSION['AM_privilege_id']) && $_SESSION['AM_privilege_id']!='')
  445.         {
  446.                 $privilege_id = $_SESSION['AM_privilege_id'];
  447.                 $_SESSION['AM_privilege_id'] = '';
  448.         }
  449.         else
  450.         {
  451.                 $privilege_id = $_SESSION['AM_privilege_id'] = '';
  452.         }
  453.  
  454.         if($privilege_id!='')
  455.         {
  456.                 $data['menu'] = $this->Manage_model->get_side_menu();
  457.                 $data['AP_menu'] = $this->Manage_model->get_privilege_menu($privilege_id);
  458.         }
  459.  
  460.         $data['privilege_id'] = $privilege_id;
  461.         $data['privilege'] = $this->Manage_model->get_privilege_select();
  462.         $this->CommonPage('manage/assign_menu',$data,'Menu Assign');
  463. }
  464. ############################################ END OF ASSIGN PRIVILEGE MENU #########################
  465.  
  466. ############################################ VIEW ORGANIZATIONS ###################################
  467. public function view_organizations()
  468. {
  469.         # INSERT / UPDATE FUNCTION
  470.         if(isset($_POST['submit']))
  471.         {
  472.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  473.                 $this->form_validation->set_rules('country_id','Country','trim|required|xss_clean|numeric');
  474.                 $this->form_validation->set_rules('privilege_id','Privilege','trim|required|xss_clean|numeric');
  475.                 $this->form_validation->set_rules('places_id','Place','trim|required|xss_clean|numeric');
  476.                 $this->form_validation->set_rules('organization_type_id','Type','trim|required|xss_clean|numeric');
  477.                 $this->form_validation->set_rules('name','Name','trim|required|xss_clean');
  478.                 $this->form_validation->set_rules('phone','Phone','trim|required|xss_clean|numeric');
  479.                 $this->form_validation->set_rules('email','Email','trim|required|xss_clean|valid_email|is_unique[organizations.email]');
  480.                 $this->form_validation->set_rules('location','Location','trim|required|xss_clean');
  481.                 $this->form_validation->set_rules('latitude','Location','trim|required|xss_clean');
  482.                 $this->form_validation->set_rules('longitude','Location','trim|required|xss_clean');
  483.                 $this->form_validation->set_rules('building_name','Building Name','trim|required|xss_clean');
  484.                 $this->form_validation->set_rules('building_number','Building Number','trim|required|xss_clean');
  485.                 $this->form_validation->set_rules('floor_number','Floor Number','trim|required|xss_clean');
  486.                 $this->form_validation->set_rules('office_number','Office Number','trim|required|xss_clean');
  487.                 $this->form_validation->set_rules('near_landmark','Near Landmark','trim|required|xss_clean');
  488.                 $this->form_validation->set_rules('cp_name','CP Name','trim|required|xss_clean');
  489.                 $this->form_validation->set_rules('cp_phone','CP Pphone','trim|required|xss_clean|numeric');
  490.                 $this->form_validation->set_rules('cp_email','CP Email','trim|required|xss_clean|valid_email');
  491.                 $this->form_validation->set_rules('cp_designation','CP Designation','trim|required|xss_clean');
  492.  
  493.                 if($this->input->post('submit')=='Save')
  494.                 {
  495.                         $this->form_validation->set_rules('organizations_id','Organizations ID','trim|xss_clean');
  496.                 }
  497.                 else
  498.                 {
  499.                         $this->form_validation->set_rules('organizations_id','Organizations ID','trim|xss_clean|numeric|required');
  500.                 }
  501.  
  502.                 if($this->form_validation->run())
  503.                 {
  504.                         $privilege_id = $this->input->post('privilege_id');
  505.                         $country_id = $this->input->post('country_id');
  506.                         $places_id = $this->input->post('places_id');
  507.                         $organization_type_id = $this->input->post('organization_type_id');
  508.                         $name = $this->input->post('name');
  509.                         $phone = $this->input->post('phone');
  510.                         $email = $this->input->post('email');
  511.                         $location = $this->input->post('location');
  512.                         $latitude = $this->input->post('latitude');
  513.                         $longitude = $this->input->post('longitude');
  514.                         $building_name = $this->input->post('building_name');
  515.                         $building_number = $this->input->post('building_number');
  516.                         $floor_number = $this->input->post('floor_number');
  517.                         $office_number = $this->input->post('office_number');
  518.                         $near_landmark = $this->input->post('near_landmark');
  519.                         $cp_name = $this->input->post('cp_name');
  520.                         $cp_phone = $this->input->post('cp_phone');
  521.                         $cp_email = $this->input->post('cp_email');
  522.                         $cp_designation = $this->input->post('cp_designation');
  523.                         $organizations_id = $this->input->post('organizations_id');
  524.                         $submit = $this->input->post('submit');
  525.  
  526.                         $ValidityDate = date('Y-m-d', strtotime('+14 days'));
  527.  
  528.                         $values = array('datetime'=>date('Y-m-d H:i:s'),
  529.                                                         'privilege_id'=>$privilege_id,
  530.                                                         'country_id'=>$country_id,
  531.                                                         'places_id'=>$places_id,
  532.                                                         'organization_type_id'=>$organization_type_id,
  533.                                                         'name'=>ucwords($name),
  534.                                                         'phone'=>$phone,
  535.                                                         'email'=>strtolower($email),
  536.                                                         'location'=>$location,
  537.                                                         'latitude'=>$latitude,
  538.                                                         'longitude'=>$longitude,
  539.                                                         'building_name'=>$building_name,
  540.                                                         'building_number'=>$building_number,
  541.                                                         'floor_number'=>$floor_number,
  542.                                                         'office_number'=>$office_number,
  543.                                                         'near_landmark'=>$near_landmark,
  544.                                                         'cp_name'=>ucwords($cp_name),
  545.                                                         'cp_phone'=>$cp_phone,
  546.                                                         'cp_email'=>strtolower($cp_email),
  547.                                                         'cp_designation'=>$cp_designation,
  548.                                                         'meetings_count'=>'10',
  549.                                                         'members_count'=>'10',
  550.                                                         'events_count'=>'2',
  551.                                                         'events_members_count'=>'25',
  552.                                                         'dedicated_link_availability'=>'1',
  553.                                                         'app_create_meeting_status'=>'1',
  554.                                                         'multiple_locations_status'=>'0',
  555.                                                         'follow_up_meeting_status'=>'0',
  556.                                                         'advanced_security_level'=>'0',
  557.                                                         'packge_validity_upto'=>$ValidityDate,
  558.                                                         'trial_start_date'=>date('Y-m-d'));
  559.  
  560.                         $user_values = array('username'=>strtolower($email),
  561.                                                                 'password'=>MD5($phone),
  562.                                                                 'name'=>ucwords($name),
  563.                                                                 'privilege_id'=>$privilege_id,
  564.                                                                 'table_id'=>'0',
  565.                                                                 'image'=>'dummy-icon.jpg');
  566.  
  567.                         if(isset($_FILES['image']) && $_FILES['image']['name']!='')
  568.                         {
  569.                                 $image_name = $this->Common_model->image_upload('./uploads/organizations/','image');
  570.                                 if($image_name!='')
  571.                                 {
  572.                                         $values['image'] = $image_name;
  573.                                 }
  574.  
  575.                                 $image_name = $this->Common_model->image_upload('./uploads/users/','image');
  576.                                 if($image_name!='')
  577.                                 {
  578.                                         $user_values['image'] = $image_name;
  579.                                 }
  580.                         }
  581.  
  582.                         if($submit=='Save')
  583.                         {
  584.                                 $organizations_id = $this->Common_model->common_insert('organizations',$values);
  585.                                 $this->Common_model->Set_Message('1',"Organization details entered successfully");
  586.  
  587.                                 // Activity Log Record
  588.                                 $head = 'Add Organization';
  589.                                 $description = 'Organization Details Has Been Added By ';
  590.                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('organizations_id'=>$organizations_id),'3');
  591.                                 // Activity Log Record
  592.  
  593.                                 $user_values['table_id'] = $organizations_id;
  594.                                 $this->Common_model->common_insert('users',$user_values);
  595.  
  596.                                 // sent Mail - login credential
  597.                                 $data['LoginDetails'] = array('username'=>strtolower($email),'password'=>$phone);
  598.                                 $this->SentMail('6',$email,$data);
  599.                                 // sent Mail - login credential
  600.  
  601.                                 // sent Mail - trial period
  602.                                 $this->SentMail('7',$email,'');
  603.                                 // sent Mail - trial period
  604.                         }
  605.                         else
  606.                         {
  607.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  608.                         }
  609.                         redirect(current_url());
  610.                 }
  611.                 else
  612.                 {
  613.                         if($this->input->post('submit')=='Update')
  614.                         {
  615.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  616.                                 redirect(current_url());
  617.                         }
  618.                 }
  619.         }
  620.         # END OF INSERT / UPDATE FUNCTION
  621.  
  622.         // BLOCK ORG USER
  623.         if(isset($_POST['block']) && $this->session->userdata('logged_in')['privilege_id']!=4)
  624.         {
  625.                 $this->form_validation->set_rules('block_id','Block ID','trim|xss_clean|required');
  626.                 if($this->form_validation->run())
  627.                 {
  628.                         $block_id = $this->input->post('block_id');
  629.                         $where = array('table_id'=>$block_id);
  630.                         $value = array('users_status'=>'2');
  631.                         $this->Common_model->common_update('users',$value,$where);
  632.                         $this->Common_model->Set_Message('1','User blocked successfully.');
  633.                 }
  634.                 else
  635.                 {
  636.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  637.                 }
  638.                 redirect(current_url());
  639.         }
  640.         // BLOCK ORG USER
  641.  
  642.         // BLOCK ORG USER
  643.         if(isset($_POST['unblock']) && $this->session->userdata('logged_in')['privilege_id']!=4)
  644.         {
  645.                 $this->form_validation->set_rules('unblock_id','Block ID','trim|xss_clean|required');
  646.                 if($this->form_validation->run())
  647.                 {
  648.                         $unblock_id = $this->input->post('unblock_id');
  649.                         $OD = $this->Manage_model->get_organization_details($unblock_id);
  650.                         if(!empty($OD))
  651.                         {
  652.                                 // update table users
  653.                                 $where = array('table_id'=>$unblock_id);
  654.                                 $value = array('users_status'=>'0');
  655.                                 $this->Common_model->common_update('users',$value,$where);
  656.  
  657.                                 // update table users_login_ip
  658.                                 $where = array('username'=>$OD['email']);
  659.                                 $value = array('users_login_ip_status'=>'1');
  660.                                 $this->Common_model->common_update('users_login_ip',$value,$where);
  661.                                 $this->Common_model->Set_Message('1','User unblocked successfully.');
  662.                         }
  663.                         else
  664.                         {
  665.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  666.                         }
  667.                 }
  668.                 else
  669.                 {
  670.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  671.                 }
  672.                 redirect(current_url());
  673.         }
  674.         // BLOCK ORG USER
  675.  
  676.         # FILTER AND PAGINATION SECTION
  677.         $URL = $this->uri->segment(1);
  678.         $param[] = array('key'=>'name','default'=>'');
  679.         $param[] = array('key'=>'email','default'=>'');
  680.         $param[] = array('key'=>'country_id','default'=>'');
  681.         $FD = $this->Common_model->common_filter($URL,$param);
  682.  
  683.         if($this->session->userdata('logged_in')['privilege_id']==6)
  684.         {
  685.                 $FD['country_id'] = $this->session->userdata('logged_in')['table_id']; // for country admin only
  686.         }
  687.  
  688.         $start = $limit = '';
  689.         $page_ary['url'] = base_url($URL);
  690.         $page_ary['total_rows'] = $this->Manage_model->view_organizations($FD,$start,$limit,'1')[0]->count;
  691.         $limit = $page_ary['per_page'] = 30;
  692.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  693.         $data['page'] = $start = $PGN_DATA['page'];
  694.         $data['links'] = $PGN_DATA['links'];
  695.         # END OF FILTER AND PAGINATION SECTION
  696.  
  697.         $data['FD'] = $FD;
  698.  
  699.         $data['CountryData'] = $this->Manage_model->select_view_country_org();
  700.         $data['TypeData'] = $this->Manage_model->select_view_type();
  701.  
  702.         $data['OD'] = $this->Manage_model->view_organizations($FD,$start,$limit,'0');
  703.  
  704.         $this->CommonPage('organizations/view_organizations',$data,'View Organizations');
  705. }
  706. ############################################ END OF VIEW ORGANIZATIONS ############################
  707.  
  708. ############################################ ORGANIZATION DETAILS #################################
  709. public function organizations_details_edit($organizations_id)
  710. {
  711.         $this->load->view('include/preloader');
  712.  
  713.         if(isset($_POST['submit']))
  714.         {
  715.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  716.                 $this->form_validation->set_rules('privilege_id','Privilege','trim|required|xss_clean|numeric');
  717.                 $this->form_validation->set_rules('country_id','Country','trim|required|xss_clean|numeric');
  718.                 $this->form_validation->set_rules('places_id','Place','trim|xss_clean|numeric');
  719.                 $this->form_validation->set_rules('organization_type_id','Type','trim|required|xss_clean|numeric');
  720.                 $this->form_validation->set_rules('name','Name','trim|required|xss_clean');
  721.                 $this->form_validation->set_rules('phone','Phone','trim|required|xss_clean|numeric');
  722.                 $this->form_validation->set_rules('email','Email','trim|required|xss_clean|valid_email');
  723.                 $this->form_validation->set_rules('location','Location','trim|xss_clean');
  724.                 $this->form_validation->set_rules('latitude','Location','trim|xss_clean');
  725.                 $this->form_validation->set_rules('longitude','Location','trim|xss_clean');
  726.                 $this->form_validation->set_rules('building_name','Building Name','trim|xss_clean');
  727.                 $this->form_validation->set_rules('building_number','Building Number','trim|xss_clean');
  728.                 $this->form_validation->set_rules('floor_number','Floor Number','trim|xss_clean');
  729.                 $this->form_validation->set_rules('office_number','Office Number','trim|xss_clean');
  730.                 $this->form_validation->set_rules('near_landmark','Near Landmark','trim|xss_clean');
  731.                 $this->form_validation->set_rules('cp_name','CP Name','trim|xss_clean');
  732.                 $this->form_validation->set_rules('cp_phone','CP Pphone','trim|xss_clean|numeric');
  733.                 $this->form_validation->set_rules('cp_email','CP Email','trim|xss_clean|valid_email');
  734.                 $this->form_validation->set_rules('cp_designation','CP Designation','trim|xss_clean');
  735.                 $this->form_validation->set_rules('organizations_id','Organizations ID','trim|xss_clean|numeric|required');
  736.  
  737.                 if($this->form_validation->run())
  738.                 {
  739.                         $privilege_id = $this->input->post('privilege_id');
  740.                         $country_id = $this->input->post('country_id');
  741.                         $places_id = $this->input->post('places_id');
  742.                         $organization_type_id = $this->input->post('organization_type_id');
  743.                         $name = $this->input->post('name');
  744.                         $phone = $this->input->post('phone');
  745.                         $email = $this->input->post('email');
  746.                         $location = $this->input->post('location');
  747.                         $latitude = $this->input->post('latitude');
  748.                         $longitude = $this->input->post('longitude');
  749.                         $building_name = $this->input->post('building_name');
  750.                         $building_number = $this->input->post('building_number');
  751.                         $floor_number = $this->input->post('floor_number');
  752.                         $office_number = $this->input->post('office_number');
  753.                         $near_landmark = $this->input->post('near_landmark');
  754.                         $cp_name = $this->input->post('cp_name');
  755.                         $cp_phone = $this->input->post('cp_phone');
  756.                         $cp_email = $this->input->post('cp_email');
  757.                         $cp_designation = $this->input->post('cp_designation');
  758.                         $organizations_id = $this->input->post('organizations_id');
  759.                         $submit = $this->input->post('submit');
  760.  
  761.                         $values = array('datetime'=>date('Y-m-d H:i:s'),
  762.                                                         'privilege_id'=>$privilege_id,
  763.                                                         'country_id'=>$country_id,
  764.                                                         'places_id'=>$places_id,
  765.                                                         'organization_type_id'=>$organization_type_id,
  766.                                                         'name'=>ucwords($name),
  767.                                                         'phone'=>$phone,
  768.                                                         'email'=>strtolower($email),
  769.                                                         'location'=>$location,
  770.                                                         'latitude'=>$latitude,
  771.                                                         'longitude'=>$longitude,
  772.                                                         'building_name'=>$building_name,
  773.                                                         'building_number'=>$building_number,
  774.                                                         'floor_number'=>$floor_number,
  775.                                                         'office_number'=>$office_number,
  776.                                                         'near_landmark'=>$near_landmark,
  777.                                                         'cp_name'=>ucwords($cp_name),
  778.                                                         'cp_phone'=>$cp_phone,
  779.                                                         'cp_email'=>strtolower($cp_email),
  780.                                                         'cp_designation'=>$cp_designation);
  781.  
  782.                         $user_values = array('username'=>strtolower($email),'name'=>ucwords($name),'privilege_id'=>$privilege_id);
  783.  
  784.                         if($this->session->userdata('logged_in')['privilege_id']==4)
  785.                         {
  786.                                 unset($values['email']);
  787.                                 unset($user_values['username']);
  788.                                 unset($user_values['privilege_id']);
  789.                         }
  790.                         elseif($this->session->userdata('logged_in')['privilege_id']==5)
  791.                         {
  792.                                 unset($values['email']);
  793.                                 unset($user_values['username']);
  794.                                 unset($user_values['privilege_id']);
  795.                         }
  796.  
  797.                         if(isset($_FILES['image']) && $_FILES['image']['name']!='')
  798.                         {
  799.                                 $image_name = $this->Common_model->image_upload('./uploads/organizations/','image');
  800.                                 if($image_name!='')
  801.                                 {
  802.                                         $values['image'] = $image_name;
  803.                                 }
  804.  
  805.                                 $image_name = $this->Common_model->image_upload('./uploads/users/','image');
  806.                                 if($image_name!='')
  807.                                 {
  808.                                         $user_values['image'] = $image_name;
  809.                                 }
  810.                         }
  811.  
  812.                         $EXIST = $this->Manage_model->check_organizations_email_exist($email,$organizations_id);
  813.                         if(empty($EXIST))
  814.                         {
  815.                                 if($submit=='Update')
  816.                                 {
  817.                                         $where = array('organizations_id'=>$organizations_id);
  818.                                         $this->Common_model->common_update('organizations',$values,$where);
  819.                                         $this->Common_model->Set_Message('1',"Organization details updated successfully.");
  820.  
  821.                                         // Activity Log Record
  822.                                         $head = 'Update Organization';
  823.                                         $description = 'Organization Details Has Been Updated By ';
  824.                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('organizations_id'=>$organizations_id),'3');
  825.                                         // Activity Log Record
  826.  
  827.                                         $where = array('table_id'=>$organizations_id);
  828.                                         $this->Common_model->common_update('users',$user_values,$where);
  829.                                 }
  830.                                 else
  831.                                 {
  832.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  833.                                 }
  834.                         }
  835.                         else
  836.                         {
  837.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Organization email already exist.');
  838.                         }
  839.                 }
  840.                 else
  841.                 {
  842.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  843.                 }
  844.         }
  845.         else
  846.         {
  847.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  848.         }
  849.  
  850.         if($this->session->userdata('logged_in')['privilege_id']==4)
  851.         {
  852.                 redirect('profile');
  853.         }
  854.         elseif($this->session->userdata('logged_in')['privilege_id']==5)
  855.         {
  856.                 redirect('profile');
  857.         }
  858.         else
  859.         {
  860.                 redirect('organizations-details/'.$organizations_id.'/edit');
  861.         }
  862. }
  863. ############################################ END OF ORGANIZATION DETAILS ##########################
  864.  
  865. ############################################ ASSIGN SUBSCRIPTION PACKAGES #########################
  866. public function assign_subscription_packages($organizations_id)
  867. {
  868.         $this->load->view('include/preloader');
  869.  
  870.         if(isset($_POST['AssignPackage']))
  871.         {
  872.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  873.                 $this->form_validation->set_rules('organizations_id','organizations','trim|required|xss_clean|numeric');
  874.                 $this->form_validation->set_rules('subscription_packages_id','subscription package','trim|required|xss_clean|numeric');
  875.  
  876.                 if($this->form_validation->run())
  877.                 {
  878.                        
  879.                         $organizations_id = $this->input->post('organizations_id');
  880.                         $subscription_packages_id = $this->input->post('subscription_packages_id');
  881.  
  882.                         $EXIST = $this->Manage_model->check_organizations_package_exist($subscription_packages_id,$organizations_id);
  883.                         if(empty($EXIST))
  884.                         {
  885.                                 $values = array('datetime'=>date('Y-m-d H:i:s'),'organizations_id'=>$organizations_id,'subscription_packages_id'=>$subscription_packages_id);
  886.                                 $this->Common_model->common_insert('packages_dedicated',$values);
  887.  
  888.                                 $this->Common_model->Set_Message('1',"Organization package updated successfully.");
  889.  
  890.                                 // Activity Log Record
  891.                                 $head = 'Assign Organization Package';
  892.                                 $description = 'Organization Package Details Has Been Assignd By ';
  893.                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('organizations_id'=>$organizations_id),'3');
  894.                                 // Activity Log Record
  895.                         }
  896.                         else
  897.                         {
  898.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Organization package already exist.');
  899.                         }
  900.                 }
  901.                 else
  902.                 {
  903.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  904.                 }
  905.         }
  906.         else
  907.         {
  908.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  909.         }
  910.  
  911.         redirect('organizations-details/'.$organizations_id.'/assigned-packages');
  912. }
  913. ############################################ END OF ASSIGN SUBSCRIPTION PACKAGES ##################
  914.  
  915. ############################################ ORGANIZATION DETAILS #################################
  916. public function organizations_details($organizations_id,$tab)
  917. {
  918.         // set active tab details
  919.         $data['Details'] = $data['Edit'] = $data['AssignedPackages'] = $data['Subscriptions'] = $data['FreePackages'] = '';
  920.         if($tab=='details'){ $data['Details'] = 'show active'; }
  921.         elseif($tab=='edit'){ $data['Edit'] = 'show active'; }
  922.         elseif($tab=='assigned-packages'){ $data['AssignedPackages'] = 'show active'; }
  923.         elseif($tab=='free-packages'){ $data['FreePackages'] = 'show active'; }
  924.         elseif($tab=='subscriptions'){ $data['Subscriptions'] = 'show active'; }
  925.         else{ $data['Details'] = 'show active'; }
  926.         // set active tab details
  927.  
  928.         // remove package
  929.         if(isset($_POST['delete']))
  930.         {
  931.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  932.                 if($this->form_validation->run())
  933.                 {
  934.                         $delete_id = $this->input->post('delete_id');
  935.                         $where = array('packages_dedicated_id'=>$delete_id);
  936.                         $value = array('packages_dedicated_status'=>'1');
  937.                         $this->Common_model->common_update('packages_dedicated',$value,$where);
  938.                         $this->Common_model->Set_Message('1','Package details removed successfully.');
  939.  
  940.                         // Activity Log Record
  941.                         $head = 'Remove Package';
  942.                         $description = 'Package Details Has Been Removed By ';
  943.                         $this->Common_model->create_activity_log($head,$description,'',array(),array('packages_dedicated_id'=>$delete_id),'3');
  944.                         // Activity Log Record
  945.                 }
  946.                 else
  947.                 {
  948.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  949.                 }
  950.                 redirect(current_url());
  951.         }
  952.         // remove package
  953.  
  954.         $OD = $this->Manage_model->get_organization_details($organizations_id);
  955.         if(empty($OD)){ redirect('organizations'); }
  956.  
  957.         $data['OD'] = $OD;
  958.  
  959.         $data['SD'] = $this->Manage_model->organizations_packages_history($organizations_id,'0','100','0');
  960.         $data['SDFree'] = $this->Manage_model->organizations_packages_history_free($organizations_id,'0','100','0');
  961.         $data['PackageData'] = $this->Manage_model->organizations_dedicated_packages_list($OD['country_id']);
  962.         $data['PackageDataFree'] = $this->Manage_model->organizations_dedicated_packages_list_free($OD['country_id']);
  963.         $data['DedicatedPackage'] = $this->Manage_model->organizations_dedicated_packages_data($organizations_id);
  964.  
  965.         $data['CountryData'] = $this->Manage_model->select_view_country_org();
  966.         $data['TypeData'] = $this->Manage_model->select_view_type();
  967.         $data['PlaceData'] = $this->Manage_model->select_view_places($OD['country_id']);
  968.         // organizations_details
  969.         $this->CommonPage('organizations/organizations_details',$data,$OD['name']);
  970. }
  971. ############################################ END OF ORGANIZATION DETAILS ##########################
  972.  
  973. ############################################ VIEW MEMBERS #########################################
  974. public function get_members_data()
  975. {
  976.         $Data['response'] = 'failed';
  977.         $Data['result'] = array();
  978.  
  979.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  980.         if($this->form_validation->run())
  981.         {
  982.                 $organizations_members_id = $this->input->post('data_id');
  983.                 $Result = $this->Manage_model->get_member_details($organizations_members_id);
  984.                 if(!empty($Result))
  985.                 {
  986.                         $Data['response'] = 'success';
  987.                         $Data['result'] = $Result;
  988.                 }
  989.         }
  990.         echo json_encode($Data);
  991. }
  992.  
  993. public function view_members()
  994. {
  995.         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  996.         $OD = $this->Manage_model->get_organization_data($organizations_id);
  997.  
  998.         # UPLOAD FILE IMPORT
  999.         if(isset($_POST['UploadFile']))
  1000.         {
  1001.                 if(isset($_FILES['import_file']) && $_FILES['import_file']['name']!='')
  1002.                 {
  1003.                         $FileName = $this->Common_model->excel_upload('./uploads/members_excel/','import_file');
  1004.                         if($FileName!='')
  1005.                         {
  1006.                                 $Result = $this->members_excel_import($FileName);
  1007.                                 if(!empty($Result))
  1008.                                 {
  1009.                                         $this->Common_model->Set_Message('1',"Members imported successfully. <strong>(Total Rows: ".$Result['Total'].", Imported Rows: ".$Result['Uploaded'].")</strong>");
  1010.                                         redirect(current_url());
  1011.                                 }
  1012.                         }
  1013.                 }
  1014.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1015.                 redirect(current_url());
  1016.         }
  1017.         # UPLOAD FILE IMPORT
  1018.  
  1019.         # INSERT / UPDATE FUNCTION
  1020.         if(isset($_POST['submit']))
  1021.         {
  1022.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  1023.                 $this->form_validation->set_rules('name','Name','trim|required|xss_clean');
  1024.                 $this->form_validation->set_rules('phone','Phone','trim|required|xss_clean|numeric');
  1025.                 $this->form_validation->set_rules('email','Email','trim|required|xss_clean|valid_email');
  1026.  
  1027.                 if($this->session->userdata('logged_in')['privilege_id']=='4')
  1028.                 {
  1029.                         $this->form_validation->set_rules('designation','Designation','trim|required|xss_clean');
  1030.                 }
  1031.                 else
  1032.                 {
  1033.                         $this->form_validation->set_rules('designation','House Number','trim|required|xss_clean');
  1034.                 }
  1035.  
  1036.                 $this->form_validation->set_rules('verification_id','ID/Passport','trim|xss_clean');
  1037.                 $this->form_validation->set_rules('meeting_privilege','Meeting Privilege','trim|xss_clean|numeric');
  1038.  
  1039.                 if($this->form_validation->run())
  1040.                 {
  1041.                         $country_id = $OD['country_id'];
  1042.  
  1043.                         $name = $this->input->post('name');
  1044.                         $phone = $this->input->post('phone');
  1045.                         $email = $this->input->post('email');
  1046.                         $designation = $this->input->post('designation');
  1047.                         $verification_id = $this->input->post('verification_id');
  1048.                         $meeting_privilege = $this->input->post('meeting_privilege');
  1049.                         $reporting_privilege = $this->input->post('reporting_privilege');
  1050.                         $submit = $this->input->post('submit');
  1051.  
  1052.                         if($OD['app_create_meeting_status']=='0')
  1053.                         {
  1054.                                 $meeting_privilege = $reporting_privilege = '0';
  1055.                         }
  1056.  
  1057.                         $Image = '';
  1058.  
  1059.                         $CheckTblMember = $this->Manage_model->check_member_is_exist($country_id,$phone);
  1060.                         if(!empty($CheckTblMember))
  1061.                         {
  1062.                                 $members_id = $CheckTblMember['members_id'];
  1063.                                 if($CheckTblMember['members_status']!=0)
  1064.                                 {
  1065.                                         $M_where = array('members_id'=>$members_id);
  1066.                                         $M_value = array('members_status'=>'0');
  1067.                                         $this->Common_model->common_update('members',$M_value,$M_where); // update status when the member is deleted
  1068.                                 }
  1069.                         }
  1070.                         else
  1071.                         {
  1072.                                 if($this->input->post('submit')=='Save')
  1073.                                 {
  1074.                                         $values = array('datetime'=>date('Y-m-d H:i:s'),
  1075.                                                                         'country_id'=>$country_id,
  1076.                                                                         'name'=>ucwords($name),
  1077.                                                                         'phone'=>$phone,
  1078.                                                                         'email'=>strtolower($email),
  1079.                                                                         'designation'=>$designation,
  1080.                                                                         'verification_id'=>$verification_id);
  1081.                                         $members_id = $this->Common_model->common_insert('members',$values);
  1082.                                 }
  1083.                                 else
  1084.                                 {
  1085.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1086.                                         redirect(current_url());
  1087.                                 }
  1088.                         }
  1089.  
  1090.                         $values = array('organizations_members_status'=>'0',
  1091.                                                         'organizations_id'=>$organizations_id,
  1092.                                                         'members_id'=>$members_id,
  1093.                                                         'name'=>ucwords($name),
  1094.                                                         'email'=>strtolower($email),
  1095.                                                         'designation'=>$designation,
  1096.                                                         'verification_id'=>$verification_id,
  1097.                                                         'meeting_privilege'=>$meeting_privilege,
  1098.                                                         'reporting_privilege'=>$reporting_privilege);
  1099.  
  1100.                         $CheckTblOrgMember = $this->Manage_model->organizations_members_exist($organizations_id,$members_id);
  1101.                         if(!empty($CheckTblOrgMember))
  1102.                         {
  1103.                                 if($this->input->post('submit')=='Update')
  1104.                                 {
  1105.                                         $where = array('organizations_id'=>$organizations_id,'members_id'=>$members_id,'organizations_members_id'=>$CheckTblOrgMember['organizations_members_id']);
  1106.                                         $this->Common_model->common_update('organizations_members',$values,$where);
  1107.                                         $this->Common_model->Set_Message('1',"Member Details Updated Successfully");
  1108.  
  1109.                                         // Activity Log Record
  1110.                                         $head = 'Update Member';
  1111.                                         $description = 'Member Details Has Been Updated By ';
  1112.                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('members_id'=>$members_id),'4');
  1113.                                         // Activity Log Record
  1114.                                 }
  1115.                                 else
  1116.                                 {
  1117.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Member already exist.");
  1118.                                 }
  1119.                         }
  1120.                         else
  1121.                         {
  1122.                                 $values['datetime'] = date('Y-m-d H:i:s');
  1123.                                 $this->Common_model->common_insert('organizations_members',$values);
  1124.                                 $this->Common_model->Set_Message('1',"New member added successfully.");
  1125.  
  1126.                                 // Activity Log Record
  1127.                                 $head = 'Add Member';
  1128.                                 $description = 'Member Details Has Been Added By ';
  1129.                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('members_id'=>$members_id),'4');
  1130.                                 // Activity Log Record
  1131.                         }
  1132.                         redirect(current_url());
  1133.                 }
  1134.                 else
  1135.                 {
  1136.                         if($this->input->post('submit')=='Update')
  1137.                         {
  1138.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1139.                                 redirect(current_url());
  1140.                         }
  1141.                 }
  1142.         }
  1143.         # END OF INSERT / UPDATE FUNCTION
  1144.  
  1145.         # DELETE FUNCTION
  1146.         if(isset($_POST['delete']))
  1147.         {
  1148.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  1149.                 if($this->form_validation->run())
  1150.                 {
  1151.                         $delete_id = $this->input->post('delete_id');
  1152.                         $where = array('organizations_members_id'=>$delete_id,'organizations_id'=>$organizations_id);
  1153.                         $value = array('organizations_members_status'=>'1');
  1154.                         $this->Common_model->common_update('organizations_members',$value,$where);
  1155.                         $this->Common_model->Set_Message('1','Member details removed successfully.');
  1156.  
  1157.                         // Activity Log Record
  1158.                         $head = 'Remove Member';
  1159.                         $description = 'Member Details Has Been Removed By ';
  1160.                         $this->Common_model->create_activity_log($head,$description,'',array(),array('organizations_members_id'=>$delete_id),'4');
  1161.                         // Activity Log Record
  1162.                 }
  1163.                 else
  1164.                 {
  1165.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1166.                 }
  1167.                 redirect(current_url());
  1168.         }
  1169.         # END OF DELETE FUNCTION
  1170.  
  1171.         # FILTER AND PAGINATION SECTION
  1172.         $URL = $this->uri->segment(1);
  1173.         $param[] = array('key'=>'name','default'=>'');
  1174.         $param[] = array('key'=>'email','default'=>'');
  1175.         $param[] = array('key'=>'phone','default'=>'');
  1176.         $FD = $this->Common_model->common_filter($URL,$param);
  1177.  
  1178.         $start = $limit = '';
  1179.         $page_ary['url'] = base_url($URL);
  1180.         $page_ary['total_rows'] = $this->Manage_model->view_members($FD,$start,$limit,'1')[0]->count;
  1181.         $limit = $page_ary['per_page'] = 30;
  1182.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  1183.         $data['page'] = $start = $PGN_DATA['page'];
  1184.         $data['links'] = $PGN_DATA['links'];
  1185.         # END OF FILTER AND PAGINATION SECTION
  1186.  
  1187.         $data['OD'] = $OD;
  1188.         $data['FD'] = $FD;
  1189.         $data['MD'] = $this->Manage_model->view_members($FD,$start,$limit,'0');
  1190.  
  1191.         $this->CommonPage('organizations/view_members',$data,'List of members in your organization');
  1192. }
  1193. ############################################ END OF VIEW MEMBERS ##################################
  1194.  
  1195. ############################################ VIEW COMPANY #########################################
  1196. public function get_company_data()
  1197. {
  1198.         $Data['response'] = 'failed';
  1199.         $Data['result'] = array();
  1200.  
  1201.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  1202.         if($this->form_validation->run())
  1203.         {
  1204.                 $data_id = $this->input->post('data_id');
  1205.                 $select = array('company_id,name,phone,email,company_category_id');
  1206.                 $where = array('company_id'=>$data_id);
  1207.                 $Result = $this->Common_model->globalfetch('company',$select,$where);
  1208.                 if(!empty($Result))
  1209.                 {
  1210.                         $Data['response'] = 'success';
  1211.                         $Data['result'] = $Result;
  1212.                 }
  1213.         }
  1214.         echo json_encode($Data);
  1215. }
  1216.  
  1217. public function view_company()
  1218. {
  1219.         # UPLOAD FILE IMPORT
  1220.         if(isset($_POST['UploadFile']))
  1221.         {
  1222.                 if(isset($_FILES['import_file']) && $_FILES['import_file']['name']!='')
  1223.                 {
  1224.                         $FileName = $this->Common_model->excel_upload('./uploads/members_excel/','import_file');
  1225.                         if($FileName!='')
  1226.                         {
  1227.                                 $Result = $this->company_excel_import($FileName);
  1228.                                 if(!empty($Result))
  1229.                                 {
  1230.                                         $this->Common_model->Set_Message('1',"Organization details imported successfully. <strong>(Total Rows: ".$Result['Total'].", Imported Rows: ".$Result['Uploaded'].")</strong>");
  1231.                                         redirect(current_url());
  1232.                                 }
  1233.                         }
  1234.                 }
  1235.  
  1236.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1237.                 redirect(current_url());
  1238.         }
  1239.         # UPLOAD FILE IMPORT
  1240.         # INSERT / UPDATE FUNCTION
  1241.         if(isset($_POST['submit']))
  1242.         {
  1243.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  1244.                 $this->form_validation->set_rules('company_category_id','Category ID','trim|required|xss_clean');
  1245.                 $this->form_validation->set_rules('name','Name','trim|required|xss_clean');
  1246.                 $this->form_validation->set_rules('phone','Phone','trim|required|xss_clean|numeric');
  1247.                 $this->form_validation->set_rules('email','Email','trim|required|xss_clean|valid_email');
  1248.  
  1249.                 if($this->input->post('submit')=='Save')
  1250.                 {
  1251.                         $this->form_validation->set_rules('company_id','Company ID','trim|xss_clean');
  1252.                 }
  1253.                 else
  1254.                 {
  1255.                         $this->form_validation->set_rules('company_id','Company ID','trim|xss_clean|numeric|required');
  1256.                 }
  1257.  
  1258.                 if($this->form_validation->run())
  1259.                 {
  1260.                         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  1261.  
  1262.                         $company_category_id = $this->input->post('company_category_id');
  1263.                         $name = $this->input->post('name');
  1264.                         $phone = $this->input->post('phone');
  1265.                         $email = $this->input->post('email');
  1266.                         $company_id = $this->input->post('company_id');
  1267.                         $submit = $this->input->post('submit');
  1268.  
  1269.                         $values = array('organizations_id'=>$organizations_id,
  1270.                                                         'company_category_id'=>$company_category_id,
  1271.                                                         'name'=>ucwords($name),
  1272.                                                         'phone'=>$phone,
  1273.                                                         'email'=>strtolower($email));
  1274.  
  1275.                         if(isset($_FILES['image']) && $_FILES['image']['name']!='')
  1276.                         {
  1277.                                 $image_name = $this->Common_model->image_upload('./uploads/company/','image');
  1278.                                 if($image_name!='')
  1279.                                 {
  1280.                                         $values['image'] = $image_name;
  1281.                                 }
  1282.                         }
  1283.  
  1284.                         if($submit=='Save')
  1285.                         {
  1286.                                 $CheckComapy = $this->Manage_model->check_company_exist($organizations_id,$email);
  1287.                                 if(empty($CheckComapy))
  1288.                                 {
  1289.                                         $values['datetime'] = date('Y-m-d H:i:s');
  1290.                                         $company_id = $this->Common_model->common_insert('company',$values);
  1291.                                         $this->Common_model->Set_Message('1',"Company added successfully.");
  1292.  
  1293.                                         // Activity Log Record
  1294.                                         $head = 'Add Company';
  1295.                                         $description = 'Company Details Has Been Added By ';
  1296.                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('company_id'=>$company_id),'5');
  1297.                                         // Activity Log Record
  1298.                                 }
  1299.                                 else
  1300.                                 {
  1301.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Selected Email already exist.');
  1302.                                 }
  1303.                         }
  1304.                         else
  1305.                         {
  1306.                                 $CheckComapyOwner = $this->Manage_model->check_company_owner_details($organizations_id,$company_id);
  1307.                                 if(!empty($CheckComapyOwner))
  1308.                                 {
  1309.                                         $where = array('company_id'=>$company_id);
  1310.                                         $this->Common_model->common_update('company',$values,$where);
  1311.                                         $this->Common_model->Set_Message('1',"Company details updated successfully.");
  1312.  
  1313.                                         // Activity Log Record
  1314.                                         $head = 'Update Company';
  1315.                                         $description = 'Company Details Has Been Updated By ';
  1316.                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('company_id'=>$company_id),'5');
  1317.                                         // Activity Log Record
  1318.                                 }
  1319.                                 else
  1320.                                 {
  1321.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1322.                                 }
  1323.                         }
  1324.                         redirect(current_url());
  1325.                 }
  1326.                 else
  1327.                 {
  1328.                         if($this->input->post('submit')=='Update')
  1329.                         {
  1330.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1331.                                 redirect(current_url());
  1332.                         }
  1333.                 }
  1334.         }
  1335.         # END OF INSERT / UPDATE FUNCTION
  1336.  
  1337.         # DELETE FUNCTION
  1338.         if(isset($_POST['delete']))
  1339.         {
  1340.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  1341.                 if($this->form_validation->run())
  1342.                 {
  1343.                         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  1344.                         $delete_id = $this->input->post('delete_id');
  1345.                         $CheckMembers = $this->Manage_model->check_company_members($organizations_id,$delete_id);
  1346.                         if(empty($CheckMembers))
  1347.                         {
  1348.                                 $where = array('company_id'=>$delete_id);
  1349.                                 $value = array('company_status'=>'1');
  1350.                                 $this->Common_model->common_update('company',$value,$where);
  1351.                                 $this->Common_model->Set_Message('1','Company details removed successfully.');
  1352.  
  1353.                                 // Activity Log Record
  1354.                                 $head = 'Remove Company';
  1355.                                 $description = 'Company Details Has Been Removed By ';
  1356.                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('company_id'=>$delete_id),'5');
  1357.                                 // Activity Log Record
  1358.                         }
  1359.                         else
  1360.                         {
  1361.                                 $this->Common_model->Set_Message('2',"<strong>Error!</strong> Company cannot be deleted.");
  1362.                         }
  1363.                 }
  1364.                 else
  1365.                 {
  1366.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1367.                 }
  1368.                 redirect(current_url());
  1369.         }
  1370.         # END OF DELETE FUNCTION
  1371.  
  1372.         # FILTER AND PAGINATION SECTION
  1373.         $URL = $this->uri->segment(1);
  1374.         $param[] = array('key'=>'name','default'=>'');
  1375.         $param[] = array('key'=>'company_category_id','default'=>'');
  1376.         $param[] = array('key'=>'phone','default'=>'');
  1377.         $FD = $this->Common_model->common_filter($URL,$param);
  1378.  
  1379.         $start = $limit = '';
  1380.         $page_ary['url'] = base_url($URL);
  1381.         $page_ary['total_rows'] = $this->Manage_model->view_company($FD,$start,$limit,'1')[0]->count;
  1382.         $limit = $page_ary['per_page'] = 30;
  1383.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  1384.         $data['page'] = $start = $PGN_DATA['page'];
  1385.         $data['links'] = $PGN_DATA['links'];
  1386.         # END OF FILTER AND PAGINATION SECTION
  1387.  
  1388.         $data['FD'] = $FD;
  1389.         $data['CD'] = $this->Manage_model->view_company($FD,$start,$limit,'0');
  1390.         $data['CL'] = $this->Manage_model->select_view_company_category();
  1391.  
  1392.         $this->CommonPage('organizations/view_company',$data,'List of registered organizations');
  1393. }
  1394. ############################################ END OF VIEW COMPANY ##################################
  1395.  
  1396. ############################################ VIEW MEMBERS #########################################
  1397. public function get_company_members_data()
  1398. {
  1399.         $Data['response'] = 'failed';
  1400.         $Data['result'] = array();
  1401.  
  1402.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  1403.         if($this->form_validation->run())
  1404.         {
  1405.                 $company_members_id = $this->input->post('data_id');
  1406.                 $Result = $this->Manage_model->get_company_member_details($company_members_id);
  1407.                 if(!empty($Result))
  1408.                 {
  1409.                         $Data['response'] = 'success';
  1410.                         $Data['result'] = $Result;
  1411.                 }
  1412.         }
  1413.         echo json_encode($Data);
  1414. }
  1415.  
  1416. public function view_company_members()
  1417. {
  1418.         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  1419.         $OD = $this->Manage_model->get_organization_data($organizations_id);
  1420.  
  1421.         # UPLOAD FILE IMPORT
  1422.         if(isset($_POST['UploadFile']))
  1423.         {
  1424.                 $this->form_validation->set_rules('company_id','Company','trim|required|xss_clean|numeric');
  1425.                 $this->form_validation->set_rules('country_id','Country','trim|required|xss_clean|numeric');
  1426.                 if($this->form_validation->run())
  1427.                 {
  1428.                         $company_id = $this->input->post('company_id');
  1429.                         $country_id = $this->input->post('country_id');
  1430.                         if(isset($_FILES['import_file']) && $_FILES['import_file']['name']!='')
  1431.                         {
  1432.                                 $FileName = $this->Common_model->excel_upload('./uploads/members_excel/','import_file');
  1433.                                 if($FileName!='')
  1434.                                 {
  1435.                                         $Result = $this->company_members_excel_import($FileName,$company_id,$country_id);
  1436.                                         if(!empty($Result))
  1437.                                         {
  1438.                                                 $this->Common_model->Set_Message('1',"Members imported successfully. <strong>(Total Rows: ".$Result['Total'].", Imported Rows: ".$Result['Uploaded'].")</strong>");
  1439.                                                 redirect(current_url());
  1440.                                         }
  1441.                                 }
  1442.                         }
  1443.                 }
  1444.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1445.                 redirect(current_url());
  1446.         }
  1447.         # UPLOAD FILE IMPORT
  1448.  
  1449.         # INSERT / UPDATE FUNCTION
  1450.         if(isset($_POST['submit']))
  1451.         {
  1452.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  1453.                 $this->form_validation->set_rules('company_id','Company','trim|required|xss_clean|numeric');
  1454.                 $this->form_validation->set_rules('company_members_id','CM ID','trim|required|xss_clean|numeric');
  1455.                 $this->form_validation->set_rules('Ecompany_id','Company','trim|required|xss_clean|numeric');
  1456.                 $this->form_validation->set_rules('country_id','Country','trim|required|xss_clean|numeric');
  1457.                 $this->form_validation->set_rules('name','Name','trim|required|xss_clean');
  1458.                 $this->form_validation->set_rules('phone','Phone','trim|required|xss_clean|numeric');
  1459.                 $this->form_validation->set_rules('email','Email','trim|required|xss_clean|valid_email');
  1460.                 $this->form_validation->set_rules('designation','Designation','trim|required|xss_clean');
  1461.                 $this->form_validation->set_rules('verification_id','ID/Passport','trim|xss_clean');
  1462.  
  1463.                 $country_id = $this->input->post('country_id');
  1464.                 $CNTRYMOB = $this->Manage_model->get_country_details_row($country_id)['mobile_number_length'];
  1465.  
  1466.                 $this->form_validation->set_rules('phone','Phone','trim|required|xss_clean|numeric|exact_length['.$CNTRYMOB.']');
  1467.  
  1468.                 if($this->form_validation->run())
  1469.                 {
  1470.                         $company_members_id = $this->input->post('company_members_id');
  1471.                         $company_id = $this->input->post('company_id');
  1472.                         $Ecompany_id = $this->input->post('Ecompany_id');
  1473.                         $name = $this->input->post('name');
  1474.                         $phone = $this->input->post('phone');
  1475.                         $email = $this->input->post('email');
  1476.                         $designation = $this->input->post('designation');
  1477.                         $verification_id = $this->input->post('verification_id');
  1478.                         $submit = $this->input->post('submit');
  1479.  
  1480.                         if($submit=='Save')
  1481.                         {
  1482.                                 $CheckTblMember = $this->Manage_model->check_member_is_exist($country_id,$phone);
  1483.                                 if(!empty($CheckTblMember))
  1484.                                 {
  1485.                                         $members_id = $CheckTblMember['members_id'];
  1486.                                         if($CheckTblMember['members_status']!=0)
  1487.                                         {
  1488.                                                 $M_where = array('members_id'=>$members_id);
  1489.                                                 $M_value = array('members_status'=>'0');
  1490.                                                 $this->Common_model->common_update('members',$M_value,$M_where); // update status when the member is deleted
  1491.                                         }
  1492.                                 }
  1493.                                 else
  1494.                                 {
  1495.                                         $values = array('datetime'=>date('Y-m-d H:i:s'),
  1496.                                                                         'country_id'=>$country_id,
  1497.                                                                         'name'=>ucwords($name),
  1498.                                                                         'phone'=>$phone,
  1499.                                                                         'email'=>strtolower($email),
  1500.                                                                         'designation'=>$designation,
  1501.                                                                         'verification_id'=>$verification_id);
  1502.                                         $members_id = $this->Common_model->common_insert('members',$values);                         
  1503.                                 }
  1504.  
  1505.                                 $values = array('company_members_status'=>'0',
  1506.                                                                 'organizations_id'=>$organizations_id,
  1507.                                                                 'company_id'=>$company_id,
  1508.                                                                 'members_id'=>$members_id,
  1509.                                                                 'name'=>ucwords($name),
  1510.                                                                 'email'=>strtolower($email),
  1511.                                                                 'designation'=>$designation,
  1512.                                                                 'verification_id'=>$verification_id);
  1513.  
  1514.                                 $CheckTblCompanyMember = $this->Manage_model->company_members_exist($company_id,$members_id,$organizations_id);
  1515.                                 if(empty($CheckTblCompanyMember))
  1516.                                 {
  1517.                                         $values['datetime'] = date('Y-m-d H:i:s');
  1518.                                         $this->Common_model->common_insert('company_members',$values);
  1519.                                         $this->Common_model->Set_Message('1',"Member added successfully.");
  1520.                                         redirect(current_url());
  1521.                                 }
  1522.                                 else
  1523.                                 {
  1524.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Mobile number already exist.');
  1525.                                         redirect(current_url());
  1526.                                 }
  1527.                         }
  1528.                         elseif($submit=='Update')
  1529.                         {
  1530.                                 $CheckTblMember = $this->Manage_model->check_member_is_exist($country_id,$phone);
  1531.                                 if(!empty($CheckTblMember))
  1532.                                 {
  1533.                                         $members_id = $CheckTblMember['members_id'];
  1534.                                         if($CheckTblMember['members_status']!=0)
  1535.                                         {
  1536.                                                 $M_where = array('members_id'=>$members_id);
  1537.                                                 $M_value = array('members_status'=>'0');
  1538.                                                 $this->Common_model->common_update('members',$M_value,$M_where); // update status when the member is deleted
  1539.                                         }
  1540.                                 }
  1541.                                 else
  1542.                                 {
  1543.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1544.                                         redirect(current_url());
  1545.                                 }
  1546.  
  1547.                                 $values = array('company_members_status'=>'0',
  1548.                                                                 'organizations_id'=>$organizations_id,
  1549.                                                                 'company_id'=>$company_id,
  1550.                                                                 'members_id'=>$members_id,
  1551.                                                                 'name'=>ucwords($name),
  1552.                                                                 'email'=>strtolower($email),
  1553.                                                                 'designation'=>$designation,
  1554.                                                                 'verification_id'=>$verification_id);
  1555.  
  1556.                                 if($company_id!=$Ecompany_id)
  1557.                                 {
  1558.                                         $CheckTblCompanyMember = $this->Manage_model->company_members_exist($company_id,$members_id,$organizations_id);
  1559.                                         if(empty($CheckTblCompanyMember))
  1560.                                         {
  1561.                                                 $where = array('company_members_id'=>$company_members_id,'members_id'=>$members_id);
  1562.                                                 $this->Common_model->common_update('company_members',$values,$where);
  1563.                                                 $this->Common_model->Set_Message('1',"<strong>SUCCESS!</strong> Member Details Updated Successfully");
  1564.                                                 redirect(current_url());
  1565.                                         }
  1566.                                         else
  1567.                                         {
  1568.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Member and organization already exist.');
  1569.                                                 redirect(current_url());
  1570.                                         }
  1571.                                 }
  1572.                                 elseif($company_id==$Ecompany_id)
  1573.                                 {
  1574.                                         $where = array('company_members_id'=>$company_members_id,'members_id'=>$members_id);
  1575.                                         $this->Common_model->common_update('company_members',$values,$where);
  1576.                                         $this->Common_model->Set_Message('1',"<strong>SUCCESS!</strong> Member Details Updated Successfully");
  1577.                                         redirect(current_url());
  1578.                                 }
  1579.                                 else
  1580.                                 {
  1581.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1582.                                         redirect(current_url());
  1583.                                 }
  1584.                         }
  1585.                         else
  1586.                         {
  1587.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1588.                                 redirect(current_url());
  1589.                         }
  1590.                 }
  1591.                 else
  1592.                 {
  1593.                         if($this->input->post('submit')=='Update')
  1594.                         {
  1595.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1596.                                 redirect(current_url());
  1597.                         }
  1598.                 }
  1599.         }
  1600.         # END OF INSERT / UPDATE FUNCTION
  1601.  
  1602.         # DELETE FUNCTION
  1603.         if(isset($_POST['delete']))
  1604.         {
  1605.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  1606.                 if($this->form_validation->run())
  1607.                 {
  1608.                         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  1609.                         $delete_id = $this->input->post('delete_id');
  1610.                         $where = array('company_members_id'=>$delete_id,'organizations_id'=>$organizations_id);
  1611.                         $value = array('company_members_status'=>'1');
  1612.                         $this->Common_model->common_update('company_members',$value,$where);
  1613.                         $this->Common_model->Set_Message('1','Member Details Removed Successfully');
  1614.  
  1615.                         // Activity Log Record
  1616.                         $head = 'Remove Member';
  1617.                         $description = 'Member Details Has Been Removed By ';
  1618.                         $this->Common_model->create_activity_log($head,$description,'',array(),array('company_members_id'=>$delete_id),'4');
  1619.                         // Activity Log Record
  1620.                 }
  1621.                 else
  1622.                 {
  1623.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1624.                 }
  1625.                 redirect(current_url());
  1626.         }
  1627.         # END OF DELETE FUNCTION
  1628.  
  1629.         # FILTER AND PAGINATION SECTION
  1630.         $URL = $this->uri->segment(1);
  1631.         $param[] = array('key'=>'company_id','default'=>'');
  1632.         $param[] = array('key'=>'name','default'=>'');
  1633.         $param[] = array('key'=>'phone','default'=>'');
  1634.         $FD = $this->Common_model->common_filter($URL,$param);
  1635.  
  1636.         $start = $limit = '';
  1637.         $page_ary['url'] = base_url($URL);
  1638.         $page_ary['total_rows'] = $this->Manage_model->view_company_members($FD,$start,$limit,'1')[0]->count;
  1639.         $limit = $page_ary['per_page'] = 30;
  1640.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  1641.         $data['page'] = $start = $PGN_DATA['page'];
  1642.         $data['links'] = $PGN_DATA['links'];
  1643.         # END OF FILTER AND PAGINATION SECTION
  1644.  
  1645.         $data['FD'] = $FD;
  1646.         $data['OD'] = $OD;
  1647.         $data['CountryData'] = $this->Manage_model->select_view_country_member();
  1648.         $data['MD'] = $this->Manage_model->view_company_members($FD,$start,$limit,'0');
  1649.         $data['CL'] = $this->Manage_model->view_company_list();
  1650.  
  1651.         $this->CommonPage('organizations/view_company_members',$data,'List of members from other organizations');
  1652. }
  1653. ############################################ END OF VIEW MEMBERS ##################################
  1654.  
  1655. ############################################ EDIT MEETINGS DETAILS ################################
  1656. public function edit_meeting_details($meetings_id)
  1657. {
  1658.         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  1659.         $OD = $this->Manage_model->get_organization_details($organizations_id);
  1660.  
  1661.         $this->load->view('include/preloader');
  1662.         if(isset($_POST['UpdateMeetingDetails']))
  1663.         {
  1664.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  1665.                 $this->form_validation->set_rules('meetings_id','Meeting','trim|required|xss_clean');
  1666.                 $this->form_validation->set_rules('meeting_title','Title','trim|required|xss_clean');
  1667.                 $this->form_validation->set_rules('date','Meeting Date','trim|required|xss_clean|exact_length[10]');
  1668.                 $this->form_validation->set_rules('time','Meeting Time','trim|required|xss_clean|exact_length[5]');
  1669.                 $this->form_validation->set_rules('end_time','Meeting End Time','trim|required|xss_clean|exact_length[5]');
  1670.                 // $this->form_validation->set_rules('location','Location','trim|required|xss_clean');
  1671.                 // $this->form_validation->set_rules('latitude','Location','trim|required|xss_clean');
  1672.                 // $this->form_validation->set_rules('longitude','Location','trim|required|xss_clean');
  1673.                 // $this->form_validation->set_rules('address','Address','trim|required|xss_clean');
  1674.                 $this->form_validation->set_rules('car_pass','Car Pass','trim|required|xss_clean');
  1675.                 $this->form_validation->set_rules('participant_status','Member Visibility','trim|required|xss_clean');
  1676.                 $this->form_validation->set_rules('description','Description','trim|xss_clean');
  1677.                 $this->form_validation->set_rules('meeting_link','Link','trim|xss_clean|valid_url');
  1678.                 $this->form_validation->set_rules('admit_before','Admit Before','trim|required|numeric');
  1679.                 $this->form_validation->set_rules('admit_after','Admit After','trim|required|numeric');
  1680.  
  1681.                 if($OD['multiple_locations_status']=='1')
  1682.                 {
  1683.                         $this->form_validation->set_rules('organizations_address_id','Organizations Address ID','trim|required|numeric');
  1684.                 }
  1685.  
  1686.                 if($this->form_validation->run())
  1687.                 {
  1688.                         $meetings_id = $this->input->post('meetings_id');
  1689.                         $meeting_title = $this->input->post('meeting_title');
  1690.                         $date = $this->input->post('date');
  1691.                         $time = $this->input->post('time');
  1692.                         $end_time = $this->input->post('end_time');
  1693.                         // $location = $this->input->post('location');
  1694.                         // $latitude = $this->input->post('latitude');
  1695.                         // $longitude = $this->input->post('longitude');
  1696.                         // $address = $this->input->post('address');
  1697.                         $description = $this->input->post('description');
  1698.                         $meeting_link = $this->input->post('meeting_link');
  1699.                         $car_pass = $this->input->post('car_pass');
  1700.                         $participant_status = $this->input->post('participant_status');
  1701.                         $admit_before = $this->input->post('admit_before');
  1702.                         $admit_after = $this->input->post('admit_after');
  1703.  
  1704.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  1705.                         if(empty($MD)){ redirect('view-meetings'); }
  1706.  
  1707.                         $date = $this->Common_model->date_format_changer($date);
  1708.                         $meeting_datetime = $date.' '.$time.':00';
  1709.                         $meeting_end_datetime = $date.' '.$end_time.':00';
  1710.  
  1711.                         $datetime = date('Y-m-d H:i:s');
  1712.  
  1713.                         $values = array('meeting_title'=>$meeting_title,
  1714.                                                         'meeting_datetime'=>$meeting_datetime,
  1715.                                                         'meeting_end_datetime'=>$meeting_end_datetime,
  1716.                                                         // 'location'=>$location,
  1717.                                                         // 'latitude'=>$latitude,
  1718.                                                         // 'longitude'=>$longitude,
  1719.                                                         // 'address'=>$address,
  1720.                                                         'description'=>$description,
  1721.                                                         'meeting_link'=>$meeting_link,
  1722.                                                         'car_pass'=>$car_pass,
  1723.                                                         'admit_before'=>$admit_before,
  1724.                                                         'admit_after'=>$admit_after);
  1725.  
  1726.                         // setup address data
  1727.                         if($OD['multiple_locations_status']=='1')
  1728.                         {
  1729.                                 $organizations_address_id = $this->input->post('organizations_address_id');
  1730.                                 if($organizations_address_id=='0') // address take from organization table
  1731.                                 {
  1732.                                         $address = array('Building Name: '.$OD['building_name'],'Building Number: '.$OD['building_number'],'Floor Number: '.$OD['floor_number'],'Unit Number: '.$OD['office_number'],'Near Landmark: '.$OD['near_landmark']);
  1733.                                         $address = implode(', ', $address);
  1734.  
  1735.                                         $values['organizations_address_id'] = '0';
  1736.                                         $values['location'] = $OD['location'];
  1737.                                         $values['latitude'] = $OD['latitude'];
  1738.                                         $values['longitude'] = $OD['longitude'];
  1739.                                         $values['address'] = $address;
  1740.                                 }
  1741.                                 elseif($organizations_address_id>'0') // address take from address table
  1742.                                 {
  1743.                                         $AddressData = $this->Manage_model->get_organization_contact_details($organizations_address_id,$organizations_id);
  1744.                                         if(!empty($AddressData))
  1745.                                         {
  1746.                                                 $address = array('Building Name: '.$AddressData['building_name'],'Building Number: '.$AddressData['building_number'],'Floor Number: '.$AddressData['floor_number'],'Unit Number: '.$AddressData['office_number'],'Near Landmark: '.$AddressData['near_landmark']);
  1747.                                                 $address = implode(', ', $address);
  1748.  
  1749.                                                 $values['organizations_address_id'] = $AddressData['organizations_address_id'];
  1750.                                                 $values['location'] = $AddressData['location'];
  1751.                                                 $values['latitude'] = $AddressData['latitude'];
  1752.                                                 $values['longitude'] = $AddressData['longitude'];
  1753.                                                 $values['address'] = $address;
  1754.                                         }
  1755.                                 }
  1756.                         }
  1757.                         // setup address data
  1758.  
  1759.                         if($MD['meeting_type']=='0')
  1760.                         {
  1761.                                 $values['participant_status'] = $participant_status;
  1762.                         }
  1763.  
  1764.                         if($meeting_end_datetime>$datetime && $meeting_end_datetime>$meeting_datetime)
  1765.                         {
  1766.                                 if($MD['status']<2)
  1767.                                 {
  1768.                                         if($MD['meeting_end_datetime']>$datetime)
  1769.                                         {
  1770.                                                 // recheduled meeting notification
  1771.                                                 if($MD['meeting_datetime']!=$meeting_datetime && $meeting_end_datetime>$datetime && $meeting_end_datetime>$meeting_datetime)
  1772.                                                 {
  1773.                                                         $MeetingMembersList = $this->Manage_model->get_meeting_members($meetings_id);
  1774.                                                         foreach($MeetingMembersList as $DT1)
  1775.                                                         {
  1776.                                                                 $members_id = $DT1->members_id;
  1777.                                                                 $status = $DT1->status;
  1778.                                                                 if($status==0)
  1779.                                                                 {
  1780.                                                                         // sent notification
  1781.                                                                         if($MD['meeting_type']=='0') // meeting
  1782.                                                                         {
  1783.                                                                                 $Content = array('title'=>'Meeting Rescheduled','description'=>'A Meeting has been rescheduled for some reasons.','message'=>'','meetings_id'=>$meetings_id);
  1784.                                                                         }
  1785.                                                                         else // event
  1786.                                                                         {
  1787.                                                                                 $Content = array('title'=>'Event Rescheduled','description'=>'An Event has been rescheduled for some reasons.','message'=>'','meetings_id'=>$meetings_id);
  1788.                                                                         }
  1789.                                                                         $this->SentNotification('5',$members_id,$Content);
  1790.                                                                         // sent notification
  1791.                                                                 }
  1792.                                                         }
  1793.                                                 }
  1794.                                                 // recheduled meeting notification
  1795.  
  1796.                                                 $where = array('meetings_id'=>$meetings_id);
  1797.                                                 $this->Common_model->common_update('meetings',$values,$where);
  1798.                                                 $this->Common_model->Set_Message('1','Meeting details updated successfully.');
  1799.  
  1800.                                                 // Activity Log Record
  1801.                                                 $head = 'Update Meeting';
  1802.                                                 $description = 'Meeting Details Has Been Updated By ';
  1803.                                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id),'6');
  1804.                                                 // Activity Log Record
  1805.                                         }
  1806.                                         else
  1807.                                         {
  1808.                                                 $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  1809.                                         }
  1810.                                 }
  1811.                                 else
  1812.                                 {
  1813.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1814.                                 }
  1815.                         }
  1816.                         else
  1817.                         {
  1818.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Please enter a valid date & time.');
  1819.                         }
  1820.                 }
  1821.                 else
  1822.                 {
  1823.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1824.                 }
  1825.         }
  1826.         else
  1827.         {
  1828.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1829.         }
  1830.  
  1831.         redirect('meeting-details/'.$meetings_id.'/edit');
  1832. }
  1833. ############################################ END OF EDIT MEETINGS DETAILS #########################
  1834.  
  1835. ############################################ EDIT MEETINGS DETAILS ################################
  1836. public function save_meeting_mom($meetings_id)
  1837. {
  1838.         $this->load->view('include/preloader');
  1839.         if(isset($_POST['SaveMOM']))
  1840.         {
  1841.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  1842.                 $this->form_validation->set_rules('mom','MOM','trim|xss_clean');
  1843.                 $this->form_validation->set_rules('meetings_id','meetings_id','trim|required|xss_clean');
  1844.                 if($this->form_validation->run())
  1845.                 {
  1846.                         $mom = $this->input->post('mom_info[]');
  1847.                         $meetings_id = $this->input->post('meetings_id');    
  1848.                         $mom_summary = $this->input->post('mom_summary');
  1849.             $members = $this->input->post('members_MOM[]');
  1850.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  1851.                         if(empty($MD)){ redirect('view-meetings'); }
  1852.                         $datetime = date('Y-m-d H:i:s');
  1853.  
  1854.                         // $values_mom = array('mom'=>$mom);
  1855.                
  1856.           $values['mom_summary'] = $mom_summary;
  1857.                   $values_mom=array();
  1858.                                                                 for ($i=0; $i < count($mom); $i++) {
  1859.                                                                
  1860.                                                                
  1861.                                                                         $values_mom["mominfo"][] = array(
  1862.                                                                                                         'mom'=>$mom[$i],
  1863.                                                                                                         'membersmom'=>$members[$i],
  1864.                                                                                                         );
  1865.                                                                                             $prms=array("mom"=>json_encode($values_mom));
  1866.                                                                                                
  1867.                                                                                                 }
  1868.                         // MOM Signature Required Status
  1869.                         if(isset($_POST['SignatureRequired']) && $MD['meeting_type']=='0')
  1870.                         {
  1871.                                 $values['mom_signature_status'] = '1';
  1872.                         }
  1873.                         else
  1874.                         {
  1875.                                 $values['mom_signature_status'] = '0';
  1876.                         }
  1877.                         // MOM Signature Required Status
  1878.  
  1879.                         if($MD['status']<2)
  1880.                         {
  1881.                                 if($MD['meeting_end_datetime']<$datetime)
  1882.                                 {
  1883.                                         $where = array('meetings_id'=>$meetings_id);
  1884.                                        
  1885.                                        
  1886.                                         $this->Common_model->common_update('meetings',$values,$where);
  1887.                                         $this->Common_model->common_update('meetings',$prms,$where);
  1888.  
  1889.                                         if($MD['meeting_type']==0)
  1890.                                         {
  1891.                                                 $this->Common_model->Set_Message('1','Minutes of Meeting updated.');
  1892.                                         }
  1893.                                         else
  1894.                                         {
  1895.                                                 $this->Common_model->Set_Message('1','Event report updated.');
  1896.                                         }
  1897.                                        
  1898.                                         // MOM updated push notification - meeting notification
  1899.                                         if(isset($_POST['NotifyMembers']))
  1900.                                         {
  1901.                                                 $MeetingMembersList = $this->Manage_model->get_meeting_members($meetings_id);
  1902.                                                 foreach($MeetingMembersList as $DT1)
  1903.                                                 {
  1904.                                                         $members_id = $DT1->members_id;
  1905.                                                         $status = $DT1->status;
  1906.                                                         if($status==0)
  1907.                                                         {
  1908.                                                                 // sent notification
  1909.                                                                 if($MD['meeting_type']==0)
  1910.                                                                 {
  1911.                                                                         $Content = array('title'=>'MOM Updated','description'=>'The MOM has been updated.','message'=>'','meetings_id'=>$meetings_id);
  1912.                                                                 }
  1913.                                                                 else
  1914.                                                                 {
  1915.                                                                         $Content = array('title'=>'Event Report Updated','description'=>'The event report has been updated.','message'=>'','meetings_id'=>$meetings_id);
  1916.                                                                 }
  1917.                                                                 $this->SentNotification('5',$members_id,$Content);
  1918.                                                                 // sent notification
  1919.                                                         }
  1920.                                                 }
  1921.                                         }
  1922.                                         // MOM updated push notification - meeting notification
  1923.  
  1924.                                         // MOM updated Emal To company Email
  1925.                                         if(isset($_POST['NotifyCompany']))
  1926.                                         {
  1927.                                                 $OD = $this->Manage_model->get_organization_details($MD['organizations_id']);
  1928.                                                 $File = $this->generate_meeting_report($meetings_id); // creating Meeting Report PDF
  1929.                                                 $CompanyEmail = array();
  1930.                                                 $MeetingCompanyList = $this->Manage_model->get_meeting_members_company($meetings_id);
  1931.                                                 foreach($MeetingCompanyList as $DT1)
  1932.                                                 {
  1933.                                                         if(!in_array($DT1->email, $CompanyEmail))
  1934.                                                         {
  1935.                                                                 $CompanyEmail[] = $DT1->email;
  1936.  
  1937.                                                                 $data['Subject'] = 'MOM of '.$MD['meeting_title'].' by '.$OD['name'];
  1938.                                                                 $data['File'] = $File;
  1939.                                                                 $data['Content'] = 'Thank you for participating '.$MD['meeting_title'].' with '.$OD['name'].' on '.date('d-m-Y', strtotime($MD['meeting_datetime']));
  1940.                                                                 $this->SentMail('12',$DT1->email,$data); // sent attached email
  1941.                                                         }
  1942.                                                 }
  1943.  
  1944.                                                 // for members
  1945.                                                 $MeetingMembersList = $this->Manage_model->get_meeting_members($meetings_id);
  1946.                                                 foreach($MeetingMembersList as $DT1)
  1947.                                                 {
  1948.                                                         $members_id = $DT1->members_id;
  1949.                                                         $status = $DT1->status;
  1950.                                                         if($status==0 && $DT1->email!='')
  1951.                                                         {
  1952.                                                                 $data['Subject'] = 'MOM of '.$MD['meeting_title'].' by '.$OD['name'];
  1953.                                                                 $data['File'] = $File;
  1954.                                                                 $data['Content'] = 'Thank you for participating '.$MD['meeting_title'].' with '.$OD['name'].' on '.date('d-m-Y', strtotime($MD['meeting_datetime']));
  1955.                                                                 $this->SentMail('12',$DT1->email,$data); // sent attached email
  1956.                                                         }
  1957.                                                 }
  1958.                                         }
  1959.                                         // MOM updated Emal To company Email
  1960.  
  1961.                                         // Activity Log Record
  1962.                                        
  1963.                                        
  1964.                                         $head = 'Update Meeting MOM';
  1965.                                         $description = 'Meeting MOM Details Has Been Updated By ';
  1966.                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id),'6');
  1967.                                         // Activity Log Record
  1968.                                 }
  1969.                                 else
  1970.                                 {
  1971.                                         if($MD['meeting_type']==0)
  1972.                                         {
  1973.                                                 $this->Common_model->Set_Message('2',"<strong>Error!</strong> You cannot edit upcoming meeting minutes.");
  1974.                                         }
  1975.                                         else
  1976.                                         {
  1977.                                                 $this->Common_model->Set_Message('2',"<strong>Error!</strong> You cannot edit upcoming event report.");
  1978.                                         }
  1979.                                 }
  1980.                         }
  1981.                         else
  1982.                         {
  1983.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1984.                         }
  1985.                 }
  1986.                 else
  1987.                 {
  1988.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1989.                 }
  1990.         }
  1991.         else
  1992.         {
  1993.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  1994.         }
  1995.         redirect('meeting-details/'.$meetings_id.'/mom');
  1996. }
  1997. ############################################ END OF EDIT MEETINGS DETAILS #########################
  1998.  
  1999. ############################################ ASSIGN MEETING MEMBERS DETAILS #######################
  2000. public function add_meeting_members($meetings_id)
  2001. {      
  2002.         $this->load->view('include/preloader');
  2003.         if(isset($_POST['AssignMembers']))
  2004.         {
  2005.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  2006.                 $this->form_validation->set_rules('meetings_id','Meeting','trim|required|xss_clean');
  2007.                 $this->form_validation->set_rules('member_type','Type','trim|required|xss_clean');
  2008.                 $this->form_validation->set_rules('MainCheckBox','Main Check Box','trim|required|xss_clean');
  2009.                 $this->form_validation->set_rules('members_id[]','Members','trim|required|xss_clean');
  2010.                 $this->form_validation->set_rules('company_id','Company','trim|required|xss_clean');
  2011.  
  2012.                 if($this->form_validation->run())
  2013.                 {
  2014.                         $meetings_id = $this->input->post('meetings_id');
  2015.                         $member_type = $this->input->post('member_type');
  2016.                         $company_id = $this->input->post('company_id');
  2017.                         $MembersArray = $this->input->post('members_id');
  2018.  
  2019.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  2020.                         if(empty($MD)){ redirect('view-meetings'); }
  2021.  
  2022.                         $datetime = date('Y-m-d H:i:s');
  2023.  
  2024.                         if(count($MembersArray)>0)
  2025.                         {
  2026.                                 if($MD['status']==1)
  2027.                                 {
  2028.                                         if($MD['meeting_end_datetime']>$datetime)
  2029.                                         {
  2030.                                                 if($MD['meeting_type']==0) // meeting
  2031.                                                 {
  2032.                                                         $CountMeetingsMembers = $this->Manage_model->check_available_meetings_members_count();
  2033.                                                 }
  2034.                                                 else // event
  2035.                                                 {
  2036.                                                         $CountMeetingsMembers = $this->Manage_model->check_available_events_members_count();
  2037.                                                 }
  2038.  
  2039.                                                 $OD = $this->Manage_model->get_organization_details($MD['organizations_id']);
  2040.                                                
  2041.                                                 $CheckMembersLimit = $this->Manage_model->check_meetings_members_count($meetings_id);
  2042.                                                 $CheckMembersLimit = $CheckMembersLimit+count($MembersArray);
  2043.                                                 if($CheckMembersLimit<=$CountMeetingsMembers)
  2044.                                                 {
  2045.                                                         $i = 0;
  2046.                                                         foreach($MembersArray as $members_sub_id => $members_id)
  2047.                                                         {
  2048.                                                                 $CheckMemberExist = $this->Manage_model->check_meetings_members_exist($meetings_id,$members_id,$member_type);
  2049.                                                                 if(empty($CheckMemberExist))
  2050.                                                                 {
  2051.                                                                         $i++;
  2052.                                                                         $values = array('datetime'=>$datetime,
  2053.                                                                                                         'meetings_id'=>$meetings_id,
  2054.                                                                                                         'members_sub_id'=>$members_sub_id,
  2055.                                                                                                         'company_id'=>$company_id,
  2056.                                                                                                         'members_id'=>$members_id,
  2057.                                                                                                         'member_type'=>$member_type);
  2058.                                                                         $meetings_participants_id = $this->Common_model->common_insert('meetings_participants',$values);
  2059.  
  2060.                                                                         $TicketNumber = 'MPT'.sprintf("%05d", $meetings_participants_id);
  2061.                                                                         $MD = $this->Manage_model->view_memeber_details($members_id);
  2062.                                                                         $MD['country_code'] = str_replace('+', '', $MD['country_code']);
  2063.                                                                         // sent notification
  2064.                                                                         if($MD['meeting_type']=='0' && $MD['country_code']=="971" && $MD['fcm_token']=="")
  2065.                                                                         {
  2066.                                                                         $Content = array('title'=>'Meeting Invitation','description'=>'You are invited for a new meeting with '.$OD['name'].'. ','message'=>'You are invited to a new meeting by '.strtok($OD['name'], " ").'-'.$TicketNumber.'. Download Meet Pass for your meeting access (onelink.to/meet). Meet, Mingle & Merge in Person. OPT-OUT "AD-Events" to 7726','meetings_id'=>$meetings_id,'TicketNumber'=>$TicketNumber,'Organization'=>$OD['name'],'MeetingTitle'=>$MD['meeting_title']);
  2067.                                                                         }elseif($MD['meeting_type']=='0')
  2068.                                                                         {
  2069.                                                                                 $Content = array('title'=>'Meeting Invitation','description'=>'You are invited for a new meeting with '.$OD['name'].'. ','message'=>'You are invited to a new meeting by '.strtok($OD['name'], " ").'-'.$TicketNumber.'. Download Meet Pass for your meeting access (onelink.to/meet). Meet, Mingle & Merge in Person.','meetings_id'=>$meetings_id,'TicketNumber'=>$TicketNumber,'Organization'=>$OD['name'],'MeetingTitle'=>$MD['meeting_title']);
  2070.                                                                         }
  2071.                                                                         else
  2072.                                                                         {
  2073.                                                                                 $Content = array('title'=>'Event Invitation','description'=>'You are invited for a new event with '.$OD['name'].'. ','message'=>'You are invited to a new evevt by '.strtok($OD['name'], " ").'-'.$TicketNumber.'. Download Meet Pass for your evevt access (onelink.to/meet). Meet, Mingle & Merge in Person.','meetings_id'=>$meetings_id,'TicketNumber'=>$TicketNumber,'Organization'=>$OD['name'],'MeetingTitle'=>$MD['meeting_title']);
  2074.                                                                         }
  2075.                                                                         if($MD['meeting_publish']=="1"){
  2076.                                                                         $this->SentNotification('1',$members_id,$Content,$members_sub_id,$member_type);
  2077.                                                                         // sent notification
  2078.  
  2079.                                                                         // Activity Log Record
  2080.                                                                         $head = 'Assign Meeting Members';
  2081.                                                                         $description = 'Members Has Been Assigned By ';
  2082.                                                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id),'6');
  2083.                                                                         // Activity Log Record
  2084.                                                                      }
  2085.                                                                        
  2086.                                                                 }
  2087.  
  2088.                                                                 if($i==50){ break; }
  2089.                                                         }
  2090.  
  2091.                                                         if($i>0)
  2092.                                                         {
  2093.                                                                 $this->Common_model->Set_Message('1',"".$i." Member added successfully.");
  2094.                                                         }
  2095.                                                         else
  2096.                                                         {
  2097.                                                                 if($MD['meeting_type']==0) // meeting
  2098.                                                                 {
  2099.                                                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Selected members already exist for this meeting.');
  2100.                                                                 }
  2101.                                                                 else // event
  2102.                                                                 {
  2103.                                                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Selected members already exist for this event.');
  2104.                                                                 }
  2105.                                                         }
  2106.                                                 }
  2107.                                                 else
  2108.                                                 {
  2109.                                                         if($MD['meeting_type']==0) // meeting
  2110.                                                         {
  2111.                                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> You have exceeded maximum allowed meeting members '.$CountMeetingsMembers.'.');
  2112.                                                         }
  2113.                                                         else // event
  2114.                                                         {
  2115.                                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> You have exceeded maximum allowed event members '.$CountMeetingsMembers.'.');
  2116.                                                         }
  2117.                                                 }
  2118.                                         }
  2119.                                         else
  2120.                                         {
  2121.                                                 if($MD['meeting_type']==0) // meeting
  2122.                                                 {
  2123.                                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  2124.                                                 }
  2125.                                                 else // event
  2126.                                                 {
  2127.                                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired event details cannot be edited.");
  2128.                                                 }
  2129.                                         }
  2130.                                 }
  2131.                                 else
  2132.                                 {
  2133.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2134.                                 }
  2135.                         }
  2136.                         else
  2137.                         {
  2138.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2139.                         }
  2140.                 }
  2141.                 else
  2142.                 {
  2143.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2144.                 }
  2145.         }
  2146.         else
  2147.         {
  2148.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2149.         }
  2150.    $fmd= $this->Manage_model->get_Folloupmetting_data($meetings_id);
  2151.    if(!empty($fmd)){
  2152.          $meetings_id=  $fmd["meetings_id"];
  2153.    }
  2154.         redirect('meeting-details/'.$meetings_id.'/members');
  2155. }
  2156. ############################################ END OF ASSIGN MEETING MEMBERS DETAILS ################
  2157.  
  2158. ############################################ REMOVE MEETING MEMBERS DETAILS #######################
  2159. public function remove_meeting_members($meetings_id)
  2160. {
  2161.         $this->load->view('include/preloader');
  2162.         if(isset($_POST['DeleteMember']))
  2163.         {
  2164.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  2165.                 $this->form_validation->set_rules('delete_id','ID','trim|required|xss_clean');
  2166.                 $this->form_validation->set_rules('meetings_id','Meeting','trim|required|xss_clean');
  2167.                 $this->form_validation->set_rules('remark','Remark','trim|required|xss_clean');
  2168.  
  2169.                 if($this->form_validation->run())
  2170.                 {
  2171.                         $meetings_participants_id = $this->input->post('delete_id');
  2172.                         $meetings_id = $this->input->post('meetings_id');
  2173.                         $remark = $this->input->post('remark');
  2174.  
  2175.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  2176.                         if(empty($MD)){ redirect('view-meetings'); }
  2177.  
  2178.                         $datetime = date('Y-m-d H:i:s');
  2179.  
  2180.                         if($MD['status']==1)
  2181.                         {
  2182.                                 if($MD['meeting_end_datetime']>$datetime)
  2183.                                 {
  2184.                                         $where = array('meetings_participants_id'=>$meetings_participants_id);
  2185.                                         $value = array('status'=>'2','cancelled_remark'=>$remark);
  2186.                                         $this->Common_model->common_update('meetings_participants',$value,$where);
  2187.                                         $this->Common_model->Set_Message('1','Member details removed successfully');
  2188.  
  2189.                                         // sent notification
  2190.                                         $members_id = $this->Manage_model->view_meetings_memeber_details($meetings_participants_id)['members_id'];
  2191.                                         if($MD['meeting_type']=='0') // meeting
  2192.                                         {
  2193.                                                 $Content = array('title'=>'Meeting Cancelled','description'=>'Unfortunately, the scheduled meeting has been cancelled due to some reason.','message'=>'','meetings_id'=>$meetings_id);
  2194.                                         }
  2195.                                         else // event
  2196.                                         {
  2197.                                                 $Content = array('title'=>'Event Cancelled','description'=>'Unfortunately, the scheduled event has been cancelled due to some reason.','message'=>'','meetings_id'=>$meetings_id);
  2198.                                         }
  2199.                                         $this->SentNotification('4',$members_id,$Content);
  2200.                                         // sent notification
  2201.  
  2202.                                         // Activity Log Record
  2203.                                         $head = 'Remove Meeting Members';
  2204.                                         $description = 'Members Has Been Removed By ';
  2205.                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id,'meetings_participants_id'=>$meetings_participants_id),'6');
  2206.                                         // Activity Log Record
  2207.                                 }
  2208.                                 else
  2209.                                 {
  2210.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  2211.                                 }
  2212.                         }
  2213.                         else
  2214.                         {
  2215.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2216.                         }
  2217.                 }
  2218.                 else
  2219.                 {
  2220.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2221.                 }
  2222.         }
  2223.         else
  2224.         {
  2225.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2226.         }
  2227.  
  2228.         redirect('meeting-details/'.$meetings_id.'/members');
  2229. }
  2230. ############################################ END OF REMOVE MEETING MEMBERS DETAILS ################
  2231.  
  2232. ############################################ REMOVE MEETING MEMBERS DETAILS #######################
  2233. /*public function remove_meeting_security($meetings_id)
  2234. {
  2235.         $this->load->view('include/preloader');
  2236.         if(isset($_POST['DeleteSecurity']))
  2237.         {
  2238.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  2239.                 $this->form_validation->set_rules('delete_id','ID','trim|required|xss_clean');
  2240.                 $this->form_validation->set_rules('meetings_id','Meeting','trim|required|xss_clean');
  2241.  
  2242.                 if($this->form_validation->run())
  2243.                 {
  2244.                         $meetings_security_id = $this->input->post('delete_id');
  2245.                         $meetings_id = $this->input->post('meetings_id');
  2246.  
  2247.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  2248.                         if(empty($MD)){ redirect('view-meetings'); }
  2249.  
  2250.                         $datetime = date('Y-m-d H:i:s');
  2251.  
  2252.                         if($MD['status']==1)
  2253.                         {
  2254.                                 if($MD['meeting_datetime']>$datetime)
  2255.                                 {
  2256.                                         $where = array('meetings_security_id'=>$meetings_security_id);
  2257.                                         $value = array('meetings_security_status'=>'1');
  2258.                                         $this->Common_model->common_update('meetings_security',$value,$where);
  2259.                                         $this->Common_model->Set_Message('1','Security Details Removed Successfully');
  2260.  
  2261.                                         // Activity Log Record
  2262.                                         $head = 'Remove Meeting Security';
  2263.                                         $description = 'Security Has Been Removed By ';
  2264.                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id,'meetings_security_id'=>$meetings_security_id),'6');
  2265.                                         // Activity Log Record
  2266.                                 }
  2267.                                 else
  2268.                                 {
  2269.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> You Can't Edit Time Expired Meeting Details");
  2270.                                 }
  2271.                         }
  2272.                         else
  2273.                         {
  2274.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2275.                         }
  2276.                 }
  2277.                 else
  2278.                 {
  2279.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2280.                 }
  2281.         }
  2282.         else
  2283.         {
  2284.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2285.         }
  2286.         redirect('meeting-details/'.$meetings_id.'/security');
  2287. }*/
  2288. ############################################ END OF REMOVE MEETING MEMBERS DETAILS ################
  2289.  
  2290. ############################################ CAR PASS #############################################
  2291. public function car_pass_meeting_members($meetings_id)
  2292. {
  2293.         $this->load->view('include/preloader');
  2294.         if(isset($_POST['AssignPass']))
  2295.         {
  2296.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  2297.                 $this->form_validation->set_rules('meetings_participants_id','ID','trim|required|xss_clean');
  2298.                 $this->form_validation->set_rules('meetings_id','Meeting','trim|required|xss_clean');
  2299.                 $this->form_validation->set_rules('car_pass_remark','Remark','trim|required|xss_clean');
  2300.  
  2301.                 if($this->form_validation->run())
  2302.                 {
  2303.                         $meetings_participants_id = $this->input->post('meetings_participants_id');
  2304.                         $meetings_id = $this->input->post('meetings_id');
  2305.                         $car_pass_remark = $this->input->post('car_pass_remark');
  2306.  
  2307.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  2308.                         if(empty($MD)){ redirect('view-meetings'); }
  2309.  
  2310.                         $datetime = date('Y-m-d H:i:s');
  2311.  
  2312.                         if($MD['status']==1)
  2313.                         {
  2314.                                 if($MD['meeting_end_datetime']>$datetime)
  2315.                                 {
  2316.                                         $MMD = $this->Manage_model->get_meeting_members_details($meetings_id,$meetings_participants_id);
  2317.                                         if(!empty($MMD) && $MMD['car_pass']!='2')
  2318.                                         {
  2319.                                                 $where = array('meetings_participants_id'=>$meetings_participants_id);
  2320.                                                 $value = array('car_pass'=>'2','car_pass_remark'=>$car_pass_remark);
  2321.                                                 $this->Common_model->common_update('meetings_participants',$value,$where);
  2322.                                                 $this->Common_model->Set_Message('1','Car Pass Assigned Successfully');
  2323.  
  2324.                                                 // sent notification
  2325.                                                 $members_id = $this->Manage_model->view_meetings_memeber_details($meetings_participants_id)['members_id'];
  2326.                                                 $Content = array('title'=>'Car Pass','description'=>'The request for your car pass is approved.','message'=>'','meetings_id'=>$meetings_id);
  2327.                                                 $this->SentNotification('2',$members_id,$Content);
  2328.                                                 // sent notification
  2329.  
  2330.                                                 // Activity Log Record
  2331.                                                 $head = 'Assign Car Pass';
  2332.                                                 $description = 'Car Pass Has Been Assigned By ';
  2333.                                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id,'meetings_participants_id'=>$meetings_participants_id),'6');
  2334.                                                 // Activity Log Record
  2335.                                         }
  2336.                                         else
  2337.                                         {
  2338.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2339.                                         }
  2340.                                 }
  2341.                                 else
  2342.                                 {
  2343.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  2344.                                 }
  2345.                         }
  2346.                         else
  2347.                         {
  2348.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2349.                         }
  2350.                 }
  2351.                 else
  2352.                 {
  2353.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2354.                 }
  2355.         }
  2356.         elseif(isset($_POST['RejectPass']))
  2357.         {
  2358.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  2359.                 $this->form_validation->set_rules('meetings_participants_id','ID','trim|required|xss_clean');
  2360.                 $this->form_validation->set_rules('meetings_id','Meeting','trim|required|xss_clean');
  2361.                 $this->form_validation->set_rules('car_pass_remark','Remark','trim|required|xss_clean');
  2362.  
  2363.                 if($this->form_validation->run())
  2364.                 {
  2365.                         $meetings_participants_id = $this->input->post('meetings_participants_id');
  2366.                         $meetings_id = $this->input->post('meetings_id');
  2367.                         $car_pass_remark = $this->input->post('car_pass_remark');
  2368.  
  2369.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  2370.                         if(empty($MD)){ redirect('view-meetings'); }
  2371.  
  2372.                         $datetime = date('Y-m-d H:i:s');
  2373.  
  2374.                         if($MD['status']==1)
  2375.                         {
  2376.                                 if($MD['meeting_end_datetime']>$datetime)
  2377.                                 {
  2378.                                         $MMD = $this->Manage_model->get_meeting_members_details($meetings_id,$meetings_participants_id);
  2379.                                         if(!empty($MMD) && $MMD['car_pass']<2)
  2380.                                         {
  2381.                                                 $where = array('meetings_participants_id'=>$meetings_participants_id);
  2382.                                                 $value = array('car_pass'=>'3','car_pass_remark'=>$car_pass_remark);
  2383.                                                 $this->Common_model->common_update('meetings_participants',$value,$where);
  2384.                                                 $this->Common_model->Set_Message('1','Car pass rejected successfully.');
  2385.  
  2386.                                                 // sent notification
  2387.                                                 $members_id = $this->Manage_model->view_meetings_memeber_details($meetings_participants_id)['members_id'];
  2388.                                                 $Content = array('title'=>'Car Pass','description'=>'Sorry, car pass is not available at this moment.','message'=>'','meetings_id'=>$meetings_id);
  2389.                                                 $this->SentNotification('2',$members_id,$Content);
  2390.                                                 // sent notification
  2391.  
  2392.                                                 // Activity Log Record
  2393.                                                 $head = 'Reject Car Pass';
  2394.                                                 $description = 'Car Pass Has Been Rejected By ';
  2395.                                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id,'meetings_participants_id'=>$meetings_participants_id),'6');
  2396.                                                 // Activity Log Record
  2397.                                         }
  2398.                                         else
  2399.                                         {
  2400.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2401.                                         }
  2402.                                 }
  2403.                                 else
  2404.                                 {
  2405.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  2406.                                 }
  2407.                         }
  2408.                         else
  2409.                         {
  2410.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2411.                         }
  2412.                 }
  2413.                 else
  2414.                 {
  2415.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2416.                 }
  2417.         }
  2418.         elseif(isset($_POST['DeletePass']))
  2419.         {
  2420.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  2421.                 $this->form_validation->set_rules('meetings_participants_id','ID','trim|required|xss_clean');
  2422.                 $this->form_validation->set_rules('meetings_id','Meeting','trim|required|xss_clean');
  2423.  
  2424.                 if($this->form_validation->run())
  2425.                 {
  2426.                         $meetings_participants_id = $this->input->post('meetings_participants_id');
  2427.                         $meetings_id = $this->input->post('meetings_id');
  2428.  
  2429.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  2430.                         if(empty($MD)){ redirect('view-meetings'); }
  2431.  
  2432.                         $datetime = date('Y-m-d H:i:s');
  2433.  
  2434.                         if($MD['status']==1)
  2435.                         {
  2436.                                 if($MD['meeting_end_datetime']>$datetime)
  2437.                                 {
  2438.                                         $MMD = $this->Manage_model->get_meeting_members_details($meetings_id,$meetings_participants_id);
  2439.                                         if(!empty($MMD) && $MMD['car_pass']=='2')
  2440.                                         {
  2441.                                                 $where = array('meetings_participants_id'=>$meetings_participants_id);
  2442.                                                 $value = array('car_pass'=>'0','car_pass_remark'=>'');
  2443.                                                 $this->Common_model->common_update('meetings_participants',$value,$where);
  2444.                                                 $this->Common_model->Set_Message('1','Car pass deleted successfully.');
  2445.  
  2446.                                                 // sent notification
  2447.                                                 $members_id = $this->Manage_model->view_meetings_memeber_details($meetings_participants_id)['members_id'];
  2448.                                                 $Content = array('title'=>'Car Pass','description'=>'Unfortunately, the car pass has been cancelled due to some reason','message'=>'','meetings_id'=>$meetings_id);
  2449.                                                 $this->SentNotification('2',$members_id,$Content);
  2450.                                                 // sent notification
  2451.  
  2452.                                                 // Activity Log Record
  2453.                                                 $head = 'Delete Car Pass';
  2454.                                                 $description = 'Car Pass Has Been Deleted By ';
  2455.                                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id,'meetings_participants_id'=>$meetings_participants_id),'6');
  2456.                                                 // Activity Log Record
  2457.                                         }
  2458.                                         else
  2459.                                         {
  2460.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2461.                                         }
  2462.                                 }
  2463.                                 else
  2464.                                 {
  2465.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  2466.                                 }
  2467.                         }
  2468.                         else
  2469.                         {
  2470.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2471.                         }
  2472.                 }
  2473.                 else
  2474.                 {
  2475.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2476.                 }
  2477.         }
  2478.         else
  2479.         {
  2480.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2481.         }
  2482.         redirect('meeting-details/'.$meetings_id.'/members');
  2483. }
  2484. ############################################ END OF CAR PASS ######################################
  2485.  
  2486. ############################################ MARK ATTENDANCE ######################################
  2487. public function mark_attendance_meeting_members($meetings_id)
  2488. {
  2489.         $this->load->view('include/preloader');
  2490.         if(isset($_POST['AttendancePresent']))
  2491.         {
  2492.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  2493.                 $this->form_validation->set_rules('meetings_participants_id','ID','trim|required|xss_clean');
  2494.                 $this->form_validation->set_rules('meetings_id','Meeting','trim|required|xss_clean');
  2495.   
  2496.                 if($this->form_validation->run())
  2497.                 { 
  2498.                         $meetings_participants_id = $this->input->post('meetings_participants_id');
  2499.                         $meetings_id = $this->input->post('meetings_id');
  2500.  
  2501.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  2502.                         if(empty($MD)){ redirect('view-meetings'); }
  2503.  
  2504.                         $datetime = date('Y-m-d H:i:s');
  2505.  
  2506.                         if($MD['status']==1)
  2507.                         {
  2508.                                 if($MD['meeting_datetime']<$datetime)
  2509.                                 { 
  2510.                                         $MMD = $this->Manage_model->get_meeting_members_details($meetings_id,$meetings_participants_id);
  2511.                                         if(!empty($MMD) && $MMD['attendance']==0)
  2512.                                         {
  2513.                                                 $where = array('meetings_participants_id'=>$meetings_participants_id);
  2514.                                                 $value = array('attendance'=>'1','attendance_datetime'=>$datetime);
  2515.                                                 $this->Common_model->common_update('meetings_participants',$value,$where);
  2516.                                                 $this->Common_model->Set_Message('1','<strong>Attendance marked!</strong>');
  2517.  
  2518.                                                 // Activity Log Record
  2519.                                                 $head = 'Attendance Marked';
  2520.                                                 $description = 'Attendance Marked By ';
  2521.                                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id,'meetings_participants_id'=>$meetings_participants_id),'6');
  2522.                                                 // Activity Log Record
  2523.                                         }
  2524.                                         else
  2525.                                         {
  2526.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2527.                                         }
  2528.                                 }
  2529.                                 else
  2530.                                 {
  2531.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  2532.                                 }
  2533.                         }
  2534.                         else
  2535.                         {
  2536.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2537.                         }
  2538.                 }
  2539.                 else
  2540.                 {
  2541.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2542.                 }
  2543.         }
  2544.         elseif(isset($_POST['AttendanceAbsent']))
  2545.         {
  2546.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  2547.                 $this->form_validation->set_rules('meetings_participants_id','ID','trim|required|xss_clean');
  2548.                 $this->form_validation->set_rules('meetings_id','Meeting','trim|required|xss_clean');
  2549.  
  2550.                 if($this->form_validation->run())
  2551.                 {
  2552.                         $meetings_participants_id = $this->input->post('meetings_participants_id');
  2553.                         $meetings_id = $this->input->post('meetings_id');
  2554.  
  2555.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  2556.                         if(empty($MD)){ redirect('view-meetings'); }
  2557.  
  2558.                         $datetime = date('Y-m-d H:i:s');
  2559.  
  2560.                         if($MD['status']==1)
  2561.                         {
  2562.                                 if($MD['meeting_datetime']<$datetime)
  2563.                                 {
  2564.                                         $MMD = $this->Manage_model->get_meeting_members_details($meetings_id,$meetings_participants_id);
  2565.                                         if(!empty($MMD) && $MMD['attendance']==0)
  2566.                                         {
  2567.                                                 $where = array('meetings_participants_id'=>$meetings_participants_id);
  2568.                                                 $value = array('attendance'=>'2');
  2569.                                                 $this->Common_model->common_update('meetings_participants',$value,$where);
  2570.                                                 $this->Common_model->Set_Message('1','<strong>Attendance marked!</strong>');
  2571.  
  2572.                                                 // Activity Log Record
  2573.                                                 $head = 'Attendance Marked';
  2574.                                                 $description = 'Attendance Marked By ';
  2575.                                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id,'meetings_participants_id'=>$meetings_participants_id),'6');
  2576.                                                 // Activity Log Record
  2577.                                         }
  2578.                                         else
  2579.                                         {
  2580.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2581.                                         }
  2582.                                 }
  2583.                                 else
  2584.                                 {
  2585.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  2586.                                 }
  2587.                         }
  2588.                         else
  2589.                         {
  2590.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2591.                         }
  2592.                 }
  2593.                 else
  2594.                 {
  2595.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2596.                 }
  2597.         }
  2598.         else
  2599.         {
  2600.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2601.         }
  2602.         redirect('meeting-details/'.$meetings_id.'/members');
  2603. }
  2604. ############################################ END OF MARK ATTENDANCE ###############################
  2605.  
  2606. ############################################ SIGNATURE ############################################
  2607. public function make_mom_signature_request($meetings_id)
  2608. {
  2609.         $this->load->view('include/preloader');
  2610.         if(isset($_POST['RequestSignature']))
  2611.         {
  2612.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  2613.                 $this->form_validation->set_rules('meetings_participants_id','ID','trim|required|xss_clean');
  2614.                 $this->form_validation->set_rules('meetings_id','Meeting','trim|required|xss_clean');
  2615.  
  2616.                 if($this->form_validation->run())
  2617.                 {
  2618.                         $meetings_participants_id = $this->input->post('meetings_participants_id');
  2619.                         $meetings_id = $this->input->post('meetings_id');
  2620.  
  2621.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  2622.                         if(empty($MD)){ redirect('view-meetings'); }
  2623.  
  2624.                         $datetime = date('Y-m-d H:i:s');
  2625.  
  2626.                         if($MD['status']==1 && $MD['mom_signature_status']=='1' && $MD['mom']!='')
  2627.                         {
  2628.                                 if($MD['meeting_datetime']<$datetime)
  2629.                                 {
  2630.                                         $MMD = $this->Manage_model->get_meeting_members_details($meetings_id,$meetings_participants_id);
  2631.                                         if(!empty($MMD) && $MMD['mom_signature_status']=='0')
  2632.                                         {
  2633.                                                 $OD = $this->Manage_model->get_organization_details($MD['organizations_id']);
  2634.  
  2635.                                                 $where = array('meetings_participants_id'=>$meetings_participants_id);
  2636.                                                 $value = array('mom_signature_status'=>'1');
  2637.                                                 $this->Common_model->common_update('meetings_participants',$value,$where);
  2638.                                                 $this->Common_model->Set_Message('1','<strong>Signature requested </strong>');
  2639.  
  2640.                                                 // sent notification
  2641.                                                 $Content = array('title'=>'Sign MOM','description'=>'Your signature required for '.$MD['meeting_title'].' MOM','message'=>'','meetings_id'=>$meetings_id,'TicketNumber'=>'','Organization'=>$OD['name'],'MeetingTitle'=>$MD['meeting_title']);
  2642.                                                 $this->SentNotification('6',$MMD['members_id'],$Content,$MMD['members_id'],'1');
  2643.                                                 // sent notification
  2644.                                         }
  2645.                                         else
  2646.                                         {
  2647.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2648.                                         }
  2649.                                 }
  2650.                                 else
  2651.                                 {
  2652.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  2653.                                 }
  2654.                         }
  2655.                         else
  2656.                         {
  2657.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2658.                         }
  2659.                 }
  2660.                 else
  2661.                 {
  2662.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2663.                 }
  2664.         }
  2665.         elseif(isset($_POST['RequestSignatureRemove']))
  2666.         {
  2667.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  2668.                 $this->form_validation->set_rules('meetings_participants_id','ID','trim|required|xss_clean');
  2669.                 $this->form_validation->set_rules('meetings_id','Meeting','trim|required|xss_clean');
  2670.  
  2671.                 if($this->form_validation->run())
  2672.                 {
  2673.                         $meetings_participants_id = $this->input->post('meetings_participants_id');
  2674.                         $meetings_id = $this->input->post('meetings_id');
  2675.  
  2676.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  2677.                         if(empty($MD)){ redirect('view-meetings'); }
  2678.  
  2679.                         $datetime = date('Y-m-d H:i:s');
  2680.  
  2681.                         if($MD['status']==1 && $MD['mom_signature_status']=='1' && $MD['mom']!='')
  2682.                         {
  2683.                                 if($MD['meeting_datetime']<$datetime)
  2684.                                 {
  2685.                                         $MMD = $this->Manage_model->get_meeting_members_details($meetings_id,$meetings_participants_id);
  2686.                                         if(!empty($MMD) && $MMD['mom_signature_status']=='1')
  2687.                                         {
  2688.                                                 $where = array('meetings_participants_id'=>$meetings_participants_id);
  2689.                                                 $value = array('mom_signature_status'=>'0');
  2690.                                                 $this->Common_model->common_update('meetings_participants',$value,$where);
  2691.                                                 $this->Common_model->Set_Message('1','<strong>Signature request removed </strong>');
  2692.                                         }
  2693.                                         else
  2694.                                         {
  2695.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2696.                                         }
  2697.                                 }
  2698.                                 else
  2699.                                 {
  2700.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  2701.                                 }
  2702.                         }
  2703.                         else
  2704.                         {
  2705.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2706.                         }
  2707.                 }
  2708.                 else
  2709.                 {
  2710.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2711.                 }
  2712.         }
  2713.         else
  2714.         {
  2715.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2716.         }
  2717.         redirect('meeting-details/'.$meetings_id.'/members');
  2718. }
  2719. ############################################ END OF SIGNATURE #####################################
  2720.  
  2721. ############################################ MEETINGS LINK DETAILS ################################
  2722. public function meeting_link_details($meetings_id)
  2723. {
  2724.         $this->load->view('include/preloader');
  2725.        
  2726.         # Generate Dedicated Link
  2727.         if(isset($_POST['GenerateLink']))
  2728.         {
  2729.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  2730.                 $this->form_validation->set_rules('meetings_id','Meeting ID','trim|required|xss_clean|numeric');
  2731.                 $this->form_validation->set_rules('registration_limit','Limit','trim|required|xss_clean|numeric');
  2732.                 if($this->form_validation->run())
  2733.                 {
  2734.                         $meetings_id = $this->input->post('meetings_id');
  2735.                         $registration_limit = $this->input->post('registration_limit');
  2736.  
  2737.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  2738.                         if(empty($MD)){ redirect('view-meetings'); }
  2739.  
  2740.                         $datetime = date('Y-m-d H:i:s');
  2741.  
  2742.                         if($MD['status']==1)
  2743.                         {
  2744.                                 if($MD['meeting_end_datetime']>$datetime)
  2745.                                 {
  2746.                                         $OD = $this->Manage_model->get_organization_details($MD['organizations_id']);
  2747.  
  2748.                                         if($OD['dedicated_link_availability']=='1' && $MD['form_link']=='')
  2749.                                         {
  2750.                                                 $LinkMax = 0;
  2751.                                                 if($MD['meeting_type']==0){ $LinkMax = $OD['members_count']; }else{ $LinkMax = $OD['events_members_count']; }
  2752.                                                 if($registration_limit>$LinkMax){ $registration_limit = $LinkMax; }
  2753.  
  2754.                                                 $values = array('form_link_status'=>'1','form_link'=>'','registration_limit'=>$registration_limit);
  2755.                                                 $where = array('organizations_id'=>$MD['organizations_id'],'meetings_id'=>$meetings_id);
  2756.  
  2757.                                                 $FormLink = '';
  2758.                                                 do {
  2759.                                                         $FormLink = $this->Common_model->GenerateRandomString();
  2760.                                                         $FormLinkStatus = $this->Manage_model->check_meeting_link_exist($FormLink);                                  
  2761.                                                 }while (!empty($FormLinkStatus));
  2762.  
  2763.                                                 if($FormLink!='')
  2764.                                                 {
  2765.                                                         $values['form_link'] = $FormLink;
  2766.                                                         $this->Common_model->common_update('meetings',$values,$where);
  2767.                                                         $this->Common_model->Set_Message('1',"Link generated successfully.");
  2768.                                                 }
  2769.                                                 else
  2770.                                                 {
  2771.                                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2772.                                                 }
  2773.  
  2774.                                         }
  2775.                                         else
  2776.                                         {
  2777.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2778.                                         }
  2779.                                 }
  2780.                                 else
  2781.                                 {
  2782.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  2783.                                 }
  2784.                         }
  2785.                         else
  2786.                         {
  2787.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2788.                         }
  2789.                 }
  2790.                 else
  2791.                 {
  2792.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2793.                 }
  2794.         }
  2795.  
  2796.         # Turn Off Dedicated Link
  2797.         if(isset($_POST['TurnOffLink']))
  2798.         {
  2799.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  2800.                 $this->form_validation->set_rules('TurnOffLink','TurnOffLink','trim|required|xss_clean');
  2801.                 $this->form_validation->set_rules('meetings_id','Meeting ID','trim|required|xss_clean|numeric');
  2802.                 if($this->form_validation->run())
  2803.                 {
  2804.                         $meetings_id = $this->input->post('meetings_id');
  2805.  
  2806.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  2807.                         if(empty($MD)){ redirect('view-meetings'); }
  2808.  
  2809.                         $datetime = date('Y-m-d H:i:s');
  2810.  
  2811.                         if($MD['status']==1)
  2812.                         {
  2813.                                 if($MD['meeting_end_datetime']>$datetime)
  2814.                                 {
  2815.                                         $OD = $this->Manage_model->get_organization_details($MD['organizations_id']);
  2816.  
  2817.                                         if($OD['dedicated_link_availability']=='1' && $MD['form_link']!='' && $MD['form_link_status']=='1')
  2818.                                         {
  2819.                                                 $values = array('form_link_status'=>'0');
  2820.                                                 $where = array('organizations_id'=>$MD['organizations_id'],'meetings_id'=>$meetings_id);
  2821.                                                 $this->Common_model->common_update('meetings',$values,$where);
  2822.                                                 $this->Common_model->Set_Message('1',"Link disabled successfully.");
  2823.                                         }
  2824.                                         else
  2825.                                         {
  2826.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2827.                                         }
  2828.                                 }
  2829.                                 else
  2830.                                 {
  2831.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  2832.                                 }
  2833.                         }
  2834.                         else
  2835.                         {
  2836.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2837.                         }
  2838.                 }
  2839.                 else
  2840.                 {
  2841.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2842.                 }
  2843.         }
  2844.  
  2845.         # Turn On Dedicated Link
  2846.         if(isset($_POST['TurnOnLink']))
  2847.         {
  2848.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  2849.                 $this->form_validation->set_rules('TurnOnLink','TurnOnLink','trim|required|xss_clean');
  2850.                 $this->form_validation->set_rules('meetings_id','Meeting ID','trim|required|xss_clean|numeric');
  2851.                 $this->form_validation->set_rules('registration_limit','Limit','trim|required|xss_clean|numeric');
  2852.                 if($this->form_validation->run())
  2853.                 {
  2854.                         $meetings_id = $this->input->post('meetings_id');
  2855.                         $registration_limit = $this->input->post('registration_limit');
  2856.  
  2857.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  2858.                         if(empty($MD)){ redirect('view-meetings'); }
  2859.  
  2860.                         $datetime = date('Y-m-d H:i:s');
  2861.  
  2862.                         if($MD['status']==1)
  2863.                         {
  2864.                                 if($MD['meeting_end_datetime']>$datetime)
  2865.                                 {
  2866.                                         $OD = $this->Manage_model->get_organization_details($MD['organizations_id']);
  2867.  
  2868.                                         if($OD['dedicated_link_availability']=='1' && $MD['form_link']!='' && $MD['form_link_status']=='0')
  2869.                                         {
  2870.                                                 $LinkMax = 0;
  2871.                                                 if($MD['meeting_type']==0){ $LinkMax = $OD['members_count']; }else{ $LinkMax = $OD['events_members_count']; }
  2872.                                                 if($registration_limit>$LinkMax){ $registration_limit = $LinkMax; }
  2873.  
  2874.                                                 $values = array('form_link_status'=>'1','registration_limit'=>$registration_limit);
  2875.                                                 $where = array('organizations_id'=>$MD['organizations_id'],'meetings_id'=>$meetings_id);
  2876.                                                 $this->Common_model->common_update('meetings',$values,$where);
  2877.                                                 $this->Common_model->Set_Message('1',"Link enabled successfully.");
  2878.                                         }
  2879.                                         else
  2880.                                         {
  2881.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2882.                                         }
  2883.                                 }
  2884.                                 else
  2885.                                 {
  2886.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  2887.                                 }
  2888.                         }
  2889.                         else
  2890.                         {
  2891.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2892.                         }
  2893.                 }
  2894.                 else
  2895.                 {
  2896.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2897.                 }
  2898.         }
  2899.         redirect('meeting-details/'.$meetings_id.'/details');
  2900. }
  2901. ############################################ END OF MEETINGS LINK DETAILS #########################
  2902.  
  2903. ############################################ END MEETING ##########################################
  2904. public function end_meeting($meetings_id)
  2905. {
  2906.         $this->load->view('include/preloader');
  2907.        
  2908.         # Generate Dedicated Link
  2909.         if(isset($_POST['EndMeeting']))
  2910.         {
  2911.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  2912.                 $this->form_validation->set_rules('meetings_id','Meeting ID','trim|required|xss_clean|numeric');
  2913.                 if($this->form_validation->run())
  2914.                 {
  2915.                         $meetings_id = $this->input->post('meetings_id');
  2916.  
  2917.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  2918.                         if(empty($MD)){ redirect('view-meetings'); }
  2919.  
  2920.                         $datetime = date('Y-m-d H:i:s');
  2921.  
  2922.                         if($MD['status']==1)
  2923.                         {
  2924.                                 if($MD['meeting_end_datetime']>$datetime && $MD['meeting_datetime']<$datetime)
  2925.                                 {
  2926.                                         $datetime = date('Y-m-d H:i:s',strtotime('-1 min'));
  2927.                                         $values = array('meeting_end_datetime'=>$datetime);
  2928.                                         $where = array('organizations_id'=>$MD['organizations_id'],'meetings_id'=>$meetings_id);
  2929.                                         $this->Common_model->common_update('meetings',$values,$where);
  2930.                                         $this->Common_model->Set_Message('1',"Meeting end.");
  2931.                                 }
  2932.                                 else
  2933.                                 {
  2934.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  2935.                                 }
  2936.                         }
  2937.                         else
  2938.                         {
  2939.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2940.                         }
  2941.                 }
  2942.                 else
  2943.                 {
  2944.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2945.                 }
  2946.         }
  2947.         redirect('meeting-details/'.$meetings_id.'/details');
  2948. }
  2949. ############################################ END OF END MEETING ###################################
  2950.  
  2951. ############################################ EXTEND MEETING #######################################
  2952. public function extend_meeting($meetings_id)
  2953. {
  2954.         $this->load->view('include/preloader');
  2955.        
  2956.         # Generate Dedicated Link
  2957.         if(isset($_POST['ExtendMeeting']))
  2958.         {
  2959.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  2960.                 $this->form_validation->set_rules('meetings_id','Meeting ID','trim|required|xss_clean|numeric');
  2961.                 $this->form_validation->set_rules('end_time','End Time','trim|required|xss_clean|exact_length[5]');
  2962.  
  2963.                 if($this->form_validation->run())
  2964.                 {
  2965.                         $meetings_id = $this->input->post('meetings_id');
  2966.                         $end_time = $this->input->post('end_time');
  2967.  
  2968.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  2969.                         if(empty($MD)){ redirect('view-meetings'); }
  2970.  
  2971.                         $datetime = date('Y-m-d H:i:s');
  2972.  
  2973.                         if($MD['status']==1)
  2974.                         {
  2975.                                 if($MD['meeting_end_datetime']>$datetime && $MD['meeting_datetime']<$datetime)
  2976.                                 {
  2977.                                         $meeting_end_datetime = date('Y-m-d',strtotime($MD['meeting_datetime'])).' '.$end_time.':00';
  2978.  
  2979.                                         if($meeting_end_datetime>$MD['meeting_end_datetime'])
  2980.                                         {
  2981.                                                 $values = array('meeting_end_datetime'=>$meeting_end_datetime);
  2982.                                                 $where = array('organizations_id'=>$MD['organizations_id'],'meetings_id'=>$meetings_id);
  2983.                                                 $this->Common_model->common_update('meetings',$values,$where);
  2984.                                                 $this->Common_model->Set_Message('1',"Meeting extended.");
  2985.                                         }
  2986.                                         else
  2987.                                         {
  2988.                                                 $this->Common_model->Set_Message('2',"<strong>Error!</strong> Check extended time.");
  2989.                                         }
  2990.                                 }
  2991.                                 else
  2992.                                 {
  2993.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  2994.                                 }
  2995.                         }
  2996.                         else
  2997.                         {
  2998.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  2999.                         }
  3000.                 }
  3001.                 else
  3002.                 {
  3003.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  3004.                 }
  3005.         }
  3006.         redirect('meeting-details/'.$meetings_id.'/details');
  3007. }
  3008. ############################################ END OF EXTEND MEETING ################################
  3009.  
  3010. ############################################ MEETINGS DETAILS #####################################
  3011. public function meeting_details($meetings_id,$tab)
  3012. {
  3013.         $MD = $this->Manage_model->meeting_details($meetings_id);
  3014.           if($MD["flollow_up_status"]==1)
  3015.         {
  3016.                 $meetings_id =$MD["flollow_up_id"];
  3017.                 redirect("meeting-details/".$meetings_id."/members");
  3018.         }
  3019.         $FMD = $this->Manage_model->meeting_details_flollwup($meetings_id);
  3020.         $FMDLAST = $this->Manage_model->meeting_details_flollwupLAST($meetings_id);
  3021.         $data["last_meeting"]=0;
  3022.         if(!empty($FMDLAST))
  3023.         {
  3024.                  $data["last_meeting"]=$FMDLAST["meetings_id"];
  3025.         }
  3026.        
  3027.         if(empty($MD)){ redirect('view-meetings'); }
  3028.  
  3029.         // set active tab details
  3030.         $data['BasicDetails'] =  $data['EditDetails'] = $data['MeetingMembers'] = '';
  3031.         $data['MeetingSecurity'] = $data['MOMDetails'] = $data['MeetingFeedback'] = '';
  3032.         if($tab=='details'){ $data['BasicDetails'] = 'show active'; }
  3033.         elseif($tab=='edit')
  3034.         { 
  3035.                 if($MD['status']<2 && $MD['meeting_end_datetime']>date('Y-m-d H:i:s'))
  3036.                 {
  3037.                         $data['EditDetails'] = 'show active';
  3038.                 }
  3039.                 else
  3040.                 {
  3041.                         $data['BasicDetails'] = 'show active';
  3042.                 }
  3043.         }
  3044.         elseif($tab=='members'){ $data['MeetingMembers'] = 'show active'; }
  3045.         elseif($tab=='security'){ $data['MeetingSecurity'] = 'show active'; }
  3046.         elseif($tab=='mom'){ $data['MOMDetails'] = 'show active'; }
  3047.         else{ $data['BasicDetails'] = 'show active'; }
  3048.         // set active tab details
  3049.  
  3050.         $data['MD'] = $MD;
  3051.         $data['FMD'] = $FMD;
  3052.         $data['FMDLAST'] = $FMDLAST;
  3053.        
  3054.         $data['OD'] = $this->Manage_model->get_organization_details($MD['organizations_id']);
  3055.        
  3056.         $data['MeetingMembersList'] = $this->Manage_model->get_meeting_members($meetings_id);
  3057.         $data['MFeedback'] = $this->Manage_model->get_meeting_members_feedback($meetings_id);
  3058.         $data['CL'] = $this->Manage_model->view_company_list();
  3059.         $data['AL'] = $this->Manage_model->view_address_list();
  3060.         $data['OrgMembers'] = $this->Manage_model->view_members_select();
  3061.  
  3062.         $this->CommonPage('meetings/meeting_details',$data,'Meeting Details');
  3063. }
  3064. ############################################ END OF MEETINGS DETAILS ##############################
  3065.  
  3066. ############################################ REGISTRATIONS ########################################
  3067. public function registrations()
  3068. {
  3069.         #APPROVE ORG
  3070.         if(isset($_POST['Approve']))
  3071.         {
  3072.                 $this->form_validation->set_rules('organizations_registrations_id','ID','trim|required|xss_clean');
  3073.                 $this->form_validation->set_rules('remark','Remark','trim|required|xss_clean');
  3074.                 if($this->form_validation->run())
  3075.                 {
  3076.                         $organizations_registrations_id = $this->input->post('organizations_registrations_id');
  3077.                         $remark = $this->input->post('remark');
  3078.  
  3079.                         $RD = $this->Manage_model->view_organizations_registrations_details($organizations_registrations_id);
  3080.  
  3081.                         $ValidityDate = date('Y-m-d', strtotime('+14 days'));
  3082. $users_id = $this->session->userdata('logged_in')['users_id'];
  3083.                         $values = array('datetime'=>date('Y-m-d H:i:s'),
  3084.                                                         'privilege_id'=>'4',
  3085.                                                         'country_id'=>$RD['country_id'],
  3086.                                                         'places_id'=>'0',
  3087.                                                         'organization_type_id'=>'0',
  3088.                                                         'name'=>ucwords($RD['name']),
  3089.                                                         'phone'=>'',
  3090.                                                         'email'=>strtolower($RD['email']),
  3091.                                                         'location'=>'',
  3092.                                                         'latitude'=>'',
  3093.                                                         'longitude'=>'',
  3094.                                                         'building_name'=>'',
  3095.                                                         'building_number'=>'',
  3096.                                                         'floor_number'=>'',
  3097.                                                         'office_number'=>'',
  3098.                                                         'near_landmark'=>'',
  3099.                                                         'cp_name'=>ucwords($RD['cp_name']),
  3100.                                                         'cp_phone'=>$RD['phone'],
  3101.                                                         'cp_email'=>'',
  3102.                                                         'cp_designation'=>'',
  3103.                                                         'image'=>'',
  3104.                                                         'website'=>$RD['website'],
  3105.                                                         'organizations_registrations_id'=>$RD['organizations_registrations_id'],
  3106.                                                         'meetings_count'=>'10',
  3107.                                                         'members_count'=>'10',
  3108.                                                         'events_count'=>'2',
  3109.                                                         'events_members_count'=>'25',
  3110.                                                         'dedicated_link_availability'=>'1',
  3111.                                                         'app_create_meeting_status'=>'1',
  3112.                                                         'multiple_locations_status'=>'0',
  3113.                                                         'follow_up_meeting_status'=>'0',
  3114.                                                         'advanced_security_level'=>'0',
  3115.                                                         'packge_validity_upto'=>$ValidityDate,
  3116.                                                         'organizations_approved_status'=>1,
  3117.                                                         'organizations_approved_date'=>date('Y-m-d H:i:s'),
  3118.                                                         'organizations_approved_by'=>$users_id);
  3119.  
  3120.                         $CheckMail = $this->Manage_model->check_organizations_email_exist_new($RD['email']);
  3121.                         if(empty($CheckMail))
  3122.                         {
  3123.                                 $organizations_id = $this->Common_model->common_insert('organizations',$values);
  3124.  
  3125.                                 $password = rand(11111111,99999999);
  3126.  
  3127.                                 $user_values = array('username'=>strtolower($RD['email']),
  3128.                                                                         'password'=>MD5($password),
  3129.                                                                         'name'=>ucwords($RD['name']),
  3130.                                                                         'privilege_id'=>'4',
  3131.                                                                         'table_id'=>$organizations_id,
  3132.                                                                         'image'=>'');
  3133.                                 $this->Common_model->common_insert('users',$user_values);
  3134.  
  3135.                                 $value = array('status'=>'1','organizations_id'=>$organizations_id,'remarks'=>$remark);
  3136.                                 $where = array('organizations_registrations_id'=>$organizations_registrations_id);
  3137.                                 $this->Common_model->common_update('organizations_registrations',$value,$where);
  3138.  
  3139.                                 // Activity Log Record
  3140.                                 $head = 'Approve Organization';
  3141.                                 $description = 'Organization Details Has Been Approved By ';
  3142.                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('organizations_id'=>$organizations_id),'3');
  3143.                                 // Activity Log Record
  3144.  
  3145.                                 // sent Mail - login credential
  3146.                                 $data['LoginDetails'] = array('username'=>strtolower($RD['email']),'password'=>$password);
  3147.                                 $this->SentMail('6',$RD['email'],$data);
  3148.                                 // sent Mail - login credential
  3149.  
  3150.                                 // sent Mail - trial period
  3151.                                 $this->SentMail('7',$RD['email'],'');
  3152.                                 // sent Mail - trial period
  3153.  
  3154.                                 $this->Common_model->Set_Message('1',"Organization details approved successfully.");
  3155.                                 redirect('organizations-details/'.$organizations_id.'/details');
  3156.                         }
  3157.                         else
  3158.                         {
  3159.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Email already exist.');
  3160.                         }
  3161.                 }
  3162.                 else
  3163.                 {
  3164.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  3165.                 }
  3166.                 redirect(current_url());
  3167.         }
  3168.         #APPROVE ORG
  3169.  
  3170.         #APPROVE ORG
  3171.         if(isset($_POST['Reject']))
  3172.         {
  3173.                 $this->form_validation->set_rules('organizations_registrations_id','ID','trim|required|xss_clean');
  3174.                 $this->form_validation->set_rules('remark','remark','trim|required|xss_clean');
  3175.                 if($this->form_validation->run())
  3176.                 {
  3177.                         $organizations_registrations_id = $this->input->post('organizations_registrations_id');
  3178.                         $remark = $this->input->post('remark');
  3179.  
  3180.                         $value = array('status'=>'2','remarks'=>$remark);
  3181.                         $where = array('organizations_registrations_id'=>$organizations_registrations_id);
  3182.                         $this->Common_model->common_update('organizations_registrations',$value,$where);
  3183.  
  3184.                         $this->Common_model->Set_Message('1','Registration details rejected.');
  3185.                 }
  3186.                 else
  3187.                 {
  3188.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  3189.                 }
  3190.                 redirect(current_url());
  3191.         }
  3192.         #APPROVE ORG
  3193.  
  3194.         # FILTER AND PAGINATION SECTION
  3195.         $URL = $this->uri->segment(1);
  3196.         $param[] = array('key'=>'name','default'=>'');
  3197.         $param[] = array('key'=>'email','default'=>'');
  3198.         $param[] = array('key'=>'country_id','default'=>'');
  3199.         $FD = $this->Common_model->common_filter($URL,$param);
  3200.  
  3201.         if($this->session->userdata('logged_in')['privilege_id']==6)
  3202.         {
  3203.                 $FD['country_id'] = $this->session->userdata('logged_in')['table_id']; // for country admin only
  3204.         }
  3205.  
  3206.         $start = $limit = '';
  3207.         $page_ary['url'] = base_url($URL);
  3208.         $page_ary['total_rows'] = $this->Manage_model->view_organizations_registrations($FD,$start,$limit,'1')[0]->count;
  3209.         $limit = $page_ary['per_page'] = 30;
  3210.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  3211.         $data['page'] = $start = $PGN_DATA['page'];
  3212.         $data['links'] = $PGN_DATA['links'];
  3213.         # END OF FILTER AND PAGINATION SECTION
  3214.  
  3215.         $data['FD'] = $FD;
  3216.  
  3217.         $data['CountryData'] = $this->Manage_model->select_view_country_org();
  3218.         $data['TypeData'] = $this->Manage_model->select_view_type();
  3219.  
  3220.         $data['OD'] = $this->Manage_model->view_organizations_registrations($FD,$start,$limit,'0');
  3221.  
  3222.         $this->CommonPage('organizations/view_organizations_registrations',$data,'View Registrations');       
  3223. }
  3224.  
  3225. public function Ajax_meeting_details($meetings_id)
  3226. {
  3227.         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  3228.         $OD = $this->Manage_model->get_organization_details($organizations_id);
  3229.         $MD = $this->Manage_model->meeting_details($_POST["data_id"]);
  3230.         $MD["response"][]="success";
  3231.         echo json_encode($MD);
  3232.         exit;
  3233. }
  3234. ############################################ END OF REGISTRATIONS #################################
  3235.  
  3236. ############################################ ORGANIZATION DETAILS #################################
  3237. public function profile($tab='')
  3238. {
  3239.         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  3240.         $OD = $this->Manage_model->get_organization_details($organizations_id);
  3241.         if(empty($OD)){ redirect('dashboard'); }
  3242.  
  3243.         if(isset($_POST['submit']))
  3244.         {
  3245.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  3246.                 $this->form_validation->set_rules('name','Name','trim|required|xss_clean');
  3247.                 $this->form_validation->set_rules('phone','Landline','trim|required|xss_clean|numeric');
  3248.                 $this->form_validation->set_rules('location','Location','trim|required|xss_clean');
  3249.                 $this->form_validation->set_rules('latitude','Location','trim|required|xss_clean');
  3250.                 $this->form_validation->set_rules('longitude','Location','trim|required|xss_clean');
  3251.                 $this->form_validation->set_rules('building_name','Building Name','trim|required|xss_clean');
  3252.                 $this->form_validation->set_rules('building_number','Building Number','trim|xss_clean');
  3253.                 $this->form_validation->set_rules('floor_number','Floor Number','trim|xss_clean');
  3254.                 $this->form_validation->set_rules('office_number','Unit Number','trim|xss_clean');
  3255.                 $this->form_validation->set_rules('near_landmark','Near Landmark','trim|required|xss_clean');
  3256.                 $this->form_validation->set_rules('cp_name','CP Name','trim|required|xss_clean');
  3257.                 $this->form_validation->set_rules('cp_phone','CP Pphone','trim|required|xss_clean|numeric');
  3258.                 $this->form_validation->set_rules('cp_email','CP Email','trim|required|xss_clean|valid_email');
  3259.                 $this->form_validation->set_rules('cp_designation','CP Designation','trim|required|xss_clean');
  3260.                 $this->form_validation->set_rules('organizations_id','Organizations ID','trim|xss_clean|numeric|required');
  3261.  
  3262.                 if($this->form_validation->run())
  3263.                 {
  3264.                         $name = $this->input->post('name');
  3265.                         $phone = $this->input->post('phone');
  3266.                         $location = $this->input->post('location');
  3267.                         $latitude = $this->input->post('latitude');
  3268.                         $longitude = $this->input->post('longitude');
  3269.                         $building_name = $this->input->post('building_name');
  3270.                         $building_number = $this->input->post('building_number');
  3271.                         $floor_number = $this->input->post('floor_number');
  3272.                         $office_number = $this->input->post('office_number');
  3273.                         $near_landmark = $this->input->post('near_landmark');
  3274.                         $cp_name = $this->input->post('cp_name');
  3275.                         $cp_phone = $this->input->post('cp_phone');
  3276.                         $cp_email = $this->input->post('cp_email');
  3277.                         $cp_designation = $this->input->post('cp_designation');
  3278.                         // $organizations_id = $this->input->post('organizations_id');
  3279.                         $organizations_id = $OD['organizations_id'];
  3280.                         $submit = $this->input->post('submit');
  3281.  
  3282.                         $values = array('name'=>ucwords($name),
  3283.                                                         'phone'=>$phone,
  3284.                                                         'location'=>$location,
  3285.                                                         'latitude'=>$latitude,
  3286.                                                         'longitude'=>$longitude,
  3287.                                                         'building_name'=>$building_name,
  3288.                                                         'building_number'=>$building_number,
  3289.                                                         'floor_number'=>$floor_number,
  3290.                                                         'office_number'=>$office_number,
  3291.                                                         'near_landmark'=>$near_landmark,
  3292.                                                         'cp_name'=>ucwords($cp_name),
  3293.                                                         'cp_phone'=>$cp_phone,
  3294.                                                         'cp_email'=>strtolower($cp_email),
  3295.                                                         'cp_designation'=>$cp_designation);
  3296.  
  3297.                         $user_values = array('name'=>ucwords($name),'first_login_status'=>'2');
  3298.  
  3299.                         if(isset($_FILES['image']) && $_FILES['image']['name']!='')
  3300.                         {
  3301.                                 $image_name = $this->Common_model->image_upload('./uploads/organizations/','image');
  3302.                                 if($image_name!='')
  3303.                                 {
  3304.                                         $values['image'] = $image_name;
  3305.                                 }
  3306.  
  3307.                                 $image_name = $this->Common_model->image_upload('./uploads/users/','image');
  3308.                                 if($image_name!='')
  3309.                                 {
  3310.                                         $user_values['image'] = $image_name;
  3311.                                 }
  3312.                         }
  3313.  
  3314.                         $where = array('organizations_id'=>$organizations_id);
  3315.                         $this->Common_model->common_update('organizations',$values,$where);
  3316.                         $this->Common_model->Set_Message('1',"Profile updated successfully.");
  3317.  
  3318.                         // update session data
  3319.                         $user_data = $this->session->userdata('logged_in');
  3320.                         $sess_data = $user_data;
  3321.                         $sess_data['first_login_status'] = '2';
  3322.                         $this->session->set_userdata('logged_in', $sess_data);
  3323.                         // update session data
  3324.  
  3325.                         // Activity Log Record
  3326.                         $head = 'Update Profile';
  3327.                         $description = 'Profile Details Has Been Updated By ';
  3328.                         $this->Common_model->create_activity_log($head,$description,'',array(),array('organizations_id'=>$organizations_id),'3');
  3329.                         // Activity Log Record
  3330.  
  3331.                         $where = array('table_id'=>$organizations_id);
  3332.                         $this->Common_model->common_update('users',$user_values,$where);
  3333.                 }
  3334.                 else
  3335.                 {
  3336.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  3337.                 }
  3338.                 redirect(current_url());
  3339.         }
  3340.  
  3341.         # Generate Dedicated Link
  3342.         if(isset($_POST['GenerateLink']))
  3343.         {
  3344.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  3345.                 $this->form_validation->set_rules('NationalID','National ID','trim|required|xss_clean|numeric|exact_length[1]');
  3346.                 if($this->form_validation->run())
  3347.                 {
  3348.                         $NationalID = $this->input->post('NationalID');
  3349.  
  3350.                         if($OD['dedicated_link_availability']=='1' && $OD['form_link']=='')
  3351.                         {
  3352.                                 $values = array('form_status'=>'1','form_link'=>'','reqiured_id'=>$NationalID);
  3353.                                 $where = array('organizations_id'=>$organizations_id);
  3354.  
  3355.                                 $FormLink = '';
  3356.                                 do {
  3357.                                         $FormLink = $this->Common_model->GenerateRandomString();
  3358.                                         $FormLinkStatus = $this->Manage_model->check_dedicated_link_exist($FormLink);                                
  3359.                                 }while (!empty($FormLinkStatus));
  3360.  
  3361.                                 if($FormLink!='')
  3362.                                 {
  3363.                                         $values['form_link'] = $FormLink;
  3364.                                         $this->Common_model->common_update('organizations',$values,$where);
  3365.                                        
  3366.                                         // reset session
  3367.                                         $user_data = $this->session->userdata('logged_in');
  3368.                                         $sess_data = $user_data;
  3369.                                         $sess_data['DLA'] = '1';
  3370.                                         $this->session->set_userdata('logged_in', $sess_data);
  3371.                                         // reset session
  3372.  
  3373.                                         $this->Common_model->Set_Message('1',"Link generated successfully");
  3374.                                 }
  3375.                                 else
  3376.                                 {
  3377.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  3378.                                 }
  3379.                         }
  3380.                         else
  3381.                         {
  3382.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  3383.                         }
  3384.                 }
  3385.                 else
  3386.                 {
  3387.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  3388.                 }
  3389.                 redirect(current_url());
  3390.         }
  3391.  
  3392.         # Turn Off Dedicated Link
  3393.         if(isset($_POST['TurnOffLink']))
  3394.         {
  3395.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  3396.                 $this->form_validation->set_rules('TurnOffLink','TurnOffLink','trim|required|xss_clean');
  3397.                 if($this->form_validation->run())
  3398.                 {
  3399.                         if($OD['dedicated_link_availability']=='1' && $OD['form_link']!='' && $OD['form_status']=='1')
  3400.                         {
  3401.                                 $values = array('form_status'=>'0');
  3402.                                 $where = array('organizations_id'=>$organizations_id);
  3403.                                 $this->Common_model->common_update('organizations',$values,$where);
  3404.                                 $this->Common_model->Set_Message('1',"Link disabled successfully.");
  3405.                         }
  3406.                         else
  3407.                         {
  3408.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  3409.                         }
  3410.                 }
  3411.                 else
  3412.                 {
  3413.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  3414.                 }
  3415.                 redirect(current_url());
  3416.         }
  3417.  
  3418.         # Turn On Dedicated Link
  3419.         if(isset($_POST['TurnOnLink']))
  3420.         {
  3421.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  3422.                 $this->form_validation->set_rules('TurnOnLink','TurnOnLink','trim|required|xss_clean');
  3423.                 $this->form_validation->set_rules('NationalID','National ID','trim|required|xss_clean|numeric|exact_length[1]');
  3424.                 if($this->form_validation->run())
  3425.                 {
  3426.                         if($OD['dedicated_link_availability']=='1' && $OD['form_link']!='' && $OD['form_status']=='0')
  3427.                         {
  3428.                                 $NationalID = $this->input->post('NationalID');
  3429.                                 $values = array('form_status'=>'1','reqiured_id'=>$NationalID);
  3430.                                 $where = array('organizations_id'=>$organizations_id);
  3431.                                 $this->Common_model->common_update('organizations',$values,$where);
  3432.                                 $this->Common_model->Set_Message('1',"Link enabled successfully.");
  3433.                         }
  3434.                         else
  3435.                         {
  3436.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  3437.                         }
  3438.                 }
  3439.                 else
  3440.                 {
  3441.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  3442.                 }
  3443.                 redirect(current_url());
  3444.         }
  3445.  
  3446.         $data['OD'] = $OD;
  3447.  
  3448.         $data['CountryData'] = $this->Manage_model->select_view_country_org();
  3449.         $data['TypeData'] = $this->Manage_model->select_view_type();
  3450.         $data['PlaceData'] = $this->Manage_model->select_view_places($OD['country_id']);
  3451.         // organizations_details
  3452.         $this->CommonPage('organizations/profile',$data,$OD['name']);
  3453. }
  3454. ############################################ END OF ORGANIZATION DETAILS ##########################
  3455.  
  3456. ############################################ MEMBERS EXCEL IMPORT #################################
  3457. public function members_excel_import($file_name='')
  3458. {      
  3459.         $this->load->model('Excel_model');
  3460.         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  3461.         $OD = $this->Manage_model->get_organization_details($organizations_id);
  3462.         if(!empty($OD))
  3463.         {
  3464.                 $country_id = $OD['country_id'];
  3465.                 $mobile_number_length = $OD['mobile_number_length'];
  3466.  
  3467.                 if($file_name!='')
  3468.                 {
  3469.                         $file = FCPATH.'uploads/members_excel/'.$file_name;
  3470.                         if(file_exists($file))
  3471.                         {
  3472.                                 $E_data = $this->Excel_model->read_excel_file($file);
  3473.                                 if(!empty($E_data))
  3474.                                 {
  3475.                                         $values = array();
  3476.                                         $i = $j = 0;
  3477.                                         foreach($E_data as $ED1)
  3478.                                         {
  3479.                                                 $i++;
  3480.                                                 if($i>1)
  3481.                                                 {
  3482.                                                         if($ED1['B']!='' && $ED1['C']!='' && strlen($ED1['C'])==$mobile_number_length && is_numeric($ED1['C']) && $ED1['D']!='')
  3483.                                                         {
  3484.                                                                 $name = ucwords($ED1['B']);
  3485.                                                                 $phone = $ED1['C'];
  3486.                                                                 $email = strtolower($ED1['D']);
  3487.                                                                 $designation = ucwords($ED1['E']);
  3488.                                                                 $verification_id = strtoupper($ED1['F']);
  3489.  
  3490.                                                                 $CheckTblMember = $this->Manage_model->check_member_is_exist($country_id,$phone);
  3491.                                                                 if(!empty($CheckTblMember))
  3492.                                                                 {
  3493.                                                                         $members_id = $CheckTblMember['members_id'];
  3494.                                                                         if($CheckTblMember['members_status']!=0)
  3495.                                                                         {
  3496.                                                                                 $M_where = array('members_id'=>$members_id);
  3497.                                                                                 $M_value = array('members_status'=>'0');
  3498.                                                                                 $this->Common_model->common_update('members',$M_value,$M_where); // update status when the member is deleted
  3499.                                                                         }
  3500.                                                                 }
  3501.                                                                 else
  3502.                                                                 {
  3503.                                                                         $values = array('datetime'=>date('Y-m-d H:i:s'),
  3504.                                                                                                         'country_id'=>$country_id,
  3505.                                                                                                         'name'=>ucwords($name),
  3506.                                                                                                         'phone'=>$phone,
  3507.                                                                                                         'email'=>strtolower($email),
  3508.                                                                                                         'designation'=>$designation,
  3509.                                                                                                         'verification_id'=>$verification_id);
  3510.                                                                         $members_id = $this->Common_model->common_insert('members',$values);                                                                 
  3511.                                                                 }
  3512.  
  3513.                                                                 $values = array('organizations_members_status'=>'0',
  3514.                                                                                                 'organizations_id'=>$organizations_id,
  3515.                                                                                                 'members_id'=>$members_id,
  3516.                                                                                                 'name'=>ucwords($name),
  3517.                                                                                                 'email'=>strtolower($email),
  3518.                                                                                                 'designation'=>$designation,
  3519.                                                                                                 'verification_id'=>$verification_id);
  3520.  
  3521.                                                                 $CheckTblOrgMember = $this->Manage_model->organizations_members_exist($organizations_id,$members_id);
  3522.                                                                 if(empty($CheckTblOrgMember))
  3523.                                                                 {
  3524.                                                                         $j++;
  3525.                                                                         $values['datetime'] = date('Y-m-d H:i:s');
  3526.                                                                         $this->Common_model->common_insert('organizations_members',$values);
  3527.  
  3528.                                                                         // Activity Log Record
  3529.                                                                         $head = 'Add Member (Excel)';
  3530.                                                                         $description = 'Member (Excel) Details Has Been Added By ';
  3531.                                                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('members_id'=>$members_id),'4');
  3532.                                                                         // Activity Log Record
  3533.                                                                 }
  3534.                                                         }
  3535.                                                 }
  3536.                                                 if($i == 251){ break; }
  3537.                                         }
  3538.                                         return array('Total'=>$i-1,'Uploaded'=>$j);
  3539.                                 }
  3540.                         }
  3541.                 }
  3542.         }
  3543.         return array();
  3544. }
  3545. ############################################ END OF MEMBERS EXCEL IMPORT ##########################
  3546.  
  3547. ############################################ COMAPNY EXCEL IMPORT #################################
  3548. public function company_excel_import($file_name='')
  3549. {      
  3550.         $this->load->model('Excel_model');
  3551.         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  3552.         $OD = $this->Manage_model->get_organization_details($organizations_id);
  3553.         $mobile_number_length = $OD['mobile_number_length'];
  3554.         if(!empty($OD))
  3555.         {
  3556.                 if($file_name!='')
  3557.                 {
  3558.                         $file = FCPATH.'uploads/members_excel/'.$file_name;
  3559.                         if(file_exists($file))
  3560.                         {
  3561.                                 $E_data = $this->Excel_model->read_excel_file($file);
  3562.                                 if(!empty($E_data))
  3563.                                 {
  3564.                                         $values = array();
  3565.                                         $i = $j = 0;
  3566.                                         foreach($E_data as $ED1)
  3567.                                         {
  3568.                                                 $i++;
  3569.                                                 if($i>1)
  3570.                                                 {
  3571.                                                         if($ED1['B']!='' && $ED1['C']!='' && strlen($ED1['C'])==$mobile_number_length && is_numeric($ED1['C']) && $ED1['D']!='')
  3572.                                                         {
  3573.                                                                 $name = ucwords($ED1['B']);
  3574.                                                                 $phone = $ED1['C'];
  3575.                                                                 $email = strtolower($ED1['D']);
  3576.  
  3577.                                                                 $values = array('organizations_id'=>$organizations_id,
  3578.                                                                                                 'company_category_id'=>'1',
  3579.                                                                                                 'name'=>ucwords($name),
  3580.                                                                                                 'phone'=>$phone,
  3581.                                                                                                 'email'=>strtolower($email));
  3582.  
  3583.                                                                 $CheckComapy = $this->Manage_model->check_company_exist($organizations_id,$email);
  3584.                                                                 if(empty($CheckComapy))
  3585.                                                                 {
  3586.                                                                         $j++;
  3587.                                                                         $values['datetime'] = date('Y-m-d H:i:s');
  3588.                                                                         $company_id = $this->Common_model->common_insert('company',$values);
  3589.                                                                         $this->Common_model->Set_Message('1',"Company added successfully.");
  3590.  
  3591.                                                                         // Activity Log Record
  3592.                                                                         $head = 'Add Company (Excel Import)';
  3593.                                                                         $description = 'Company Details Has Been Added By (Excel Import) ';
  3594.                                                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('company_id'=>$company_id),'5');
  3595.                                                                         // Activity Log Record
  3596.                                                                 }
  3597.                                                         }
  3598.                                                 }
  3599.                                                 if($i == 251){ break; }
  3600.                                         }
  3601.                                         return array('Total'=>$i-1,'Uploaded'=>$j);
  3602.                                 }
  3603.                         }
  3604.                 }
  3605.         }
  3606.         return array();
  3607. }
  3608. ############################################ END OF COMAPNY EXCEL IMPORT ##########################
  3609.  
  3610. ############################################ COMPANY MEMBERS EXCEL IMPORT #########################
  3611. public function company_members_excel_import($file_name='',$company_id='',$country_id='')
  3612. {      
  3613.         $this->load->model('Excel_model');
  3614.         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  3615.         $OD = $this->Manage_model->get_organization_details($organizations_id);
  3616.         if(!empty($OD))
  3617.         {
  3618.  
  3619.                 if($file_name!='' && $company_id!='' && $country_id!='')
  3620.                 {
  3621.                         $mobile_number_length = $this->Manage_model->get_country_details_row($country_id)['mobile_number_length'];
  3622.  
  3623.                         $file = FCPATH.'uploads/members_excel/'.$file_name;
  3624.                         if(file_exists($file))
  3625.                         {
  3626.                                 $E_data = $this->Excel_model->read_excel_file($file);
  3627.                                 if(!empty($E_data))
  3628.                                 {
  3629.                                         $values = array();
  3630.                                         $i = $j = 0;
  3631.                                         foreach($E_data as $ED1)
  3632.                                         {
  3633.                                                 $i++;
  3634.                                                 if($i>1)
  3635.                                                 {
  3636.                                                         if($ED1['B']!='' && $ED1['C']!='' && strlen($ED1['C'])==$mobile_number_length && is_numeric($ED1['C']) && $ED1['D']!='' && $ED1['E']!='')
  3637.                                                         {
  3638.                                                                 $name = ucwords($ED1['B']);
  3639.                                                                 $phone = $ED1['C'];
  3640.                                                                 $email = strtolower($ED1['D']);
  3641.                                                                 $designation = ucwords($ED1['E']);
  3642.                                                                 $verification_id = strtoupper($ED1['F']);
  3643.  
  3644.                                                                 $CheckTblMember = $this->Manage_model->check_member_is_exist($country_id,$phone);
  3645.                                                                 if(!empty($CheckTblMember))
  3646.                                                                 {
  3647.                                                                         $members_id = $CheckTblMember['members_id'];
  3648.                                                                         if($CheckTblMember['members_status']!=0)
  3649.                                                                         {
  3650.                                                                                 $M_where = array('members_id'=>$members_id);
  3651.                                                                                 $M_value = array('members_status'=>'0');
  3652.                                                                                 $this->Common_model->common_update('members',$M_value,$M_where); // update status when the member is deleted
  3653.                                                                         }
  3654.                                                                 }
  3655.                                                                 else
  3656.                                                                 {
  3657.                                                                         $values = array('datetime'=>date('Y-m-d H:i:s'),
  3658.                                                                                                         'country_id'=>$country_id,
  3659.                                                                                                         'name'=>ucwords($name),
  3660.                                                                                                         'phone'=>$phone,
  3661.                                                                                                         'email'=>strtolower($email),
  3662.                                                                                                         'designation'=>$designation,
  3663.                                                                                                         'verification_id'=>$verification_id);
  3664.                                                                         $members_id = $this->Common_model->common_insert('members',$values);                                                                 
  3665.                                                                 }
  3666.  
  3667.                                                                 $values = array('company_members_status'=>'0',
  3668.                                                                                                 'organizations_id'=>$organizations_id,
  3669.                                                                                                 'company_id'=>$company_id,
  3670.                                                                                                 'members_id'=>$members_id,
  3671.                                                                                                 'name'=>ucwords($name),
  3672.                                                                                                 'email'=>strtolower($email),
  3673.                                                                                                 'designation'=>$designation,
  3674.                                                                                                 'verification_id'=>$verification_id);
  3675.  
  3676.                                                                 $CheckTblCompanyMember = $this->Manage_model->company_members_exist($company_id,$members_id,$organizations_id);
  3677.                                                                 if(empty($CheckTblCompanyMember))
  3678.                                                                 {
  3679.                                                                         $j++;
  3680.                                                                         $values['datetime'] = date('Y-m-d H:i:s');
  3681.                                                                         $this->Common_model->common_insert('company_members',$values);
  3682.  
  3683.                                                                         // Activity Log Record
  3684.                                                                         $head = 'Add Member (Excel)';
  3685.                                                                         $description = 'Member (Excel) Details Has Been Added By ';
  3686.                                                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('members_id'=>$members_id),'4');
  3687.                                                                         // Activity Log Record
  3688.                                                                 }
  3689.                                                         }
  3690.                                                 }
  3691.                                                 if($i == 251){ break; }
  3692.                                         }
  3693.                                         return array('Total'=>$i-1,'Uploaded'=>$j);
  3694.                                 }
  3695.                         }
  3696.                 }
  3697.         }
  3698.         return array();
  3699. }
  3700. ############################################ END OF COMPANY MEMBERS EXCEL IMPORT ##################
  3701.  
  3702. ############################################ MESSAGES #############################################
  3703. public function enquiry()
  3704. {
  3705.         # FILTER AND PAGINATION SECTION
  3706.         $URL = $this->uri->segment(1);
  3707.         $param[] = array('key'=>'email','default'=>'');
  3708.         $FD = $this->Common_model->common_filter($URL,$param);
  3709.  
  3710.         if($this->session->userdata('logged_in')['privilege_id']==6)
  3711.         {
  3712.                 $FD['country_id'] = $this->session->userdata('logged_in')['table_id']; // for country admin only
  3713.         }
  3714.  
  3715.         $start = $limit = '';
  3716.         $page_ary['url'] = base_url($URL);
  3717.         $page_ary['total_rows'] = $this->Manage_model->view_enquiry($FD,$start,$limit,'1')[0]->count;
  3718.         $limit = $page_ary['per_page'] = 50;
  3719.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  3720.         $data['page'] = $start = $PGN_DATA['page'];
  3721.         $data['links'] = $PGN_DATA['links'];
  3722.         # END OF FILTER AND PAGINATION SECTION
  3723.  
  3724.         $data['FD'] = $FD;
  3725.         $data['enquiry'] = $this->Manage_model->view_enquiry($FD,$start,$limit,'0');
  3726.  
  3727.         $this->CommonPage('manage/enquiry',$data,'View Messages');
  3728. }
  3729. ############################################ END OF MESSAGES ######################################
  3730.  
  3731. ############################################ LINK REQUESTS ########################################
  3732. public function get_link_requests_data()
  3733. {
  3734.         $Data['response'] = 'failed';
  3735.         $Data['result'] = array();
  3736.  
  3737.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  3738.         if($this->form_validation->run())
  3739.         {
  3740.                 $link_requests_id = $this->input->post('data_id');
  3741.                 $Result = $this->Manage_model->get_link_requests_data($link_requests_id);
  3742.                 if(!empty($Result))
  3743.                 {
  3744.                         $Data['response'] = 'success';
  3745.                         $Data['result'] = $Result;
  3746.                 }
  3747.         }
  3748.         echo json_encode($Data);
  3749. }
  3750.  
  3751. public function link_requests($LinkStatus='0')
  3752. {
  3753.         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  3754.         $OD = $this->Manage_model->get_organization_details($organizations_id);
  3755.  
  3756.         # Create New Quick Meeting
  3757.         if(isset($_POST['CreateRequestQuickMeeting']))
  3758.         {
  3759.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  3760.                 $this->form_validation->set_rules('RQ_member_name','Name','trim|required|xss_clean');
  3761.                 $this->form_validation->set_rules('RQ_member_mobile','Mobile','trim|required|xss_clean');
  3762.                 $this->form_validation->set_rules('RQ_meeting_title','Title','trim|required|xss_clean');
  3763.                 $this->form_validation->set_rules('RQ_date','Date','trim|required|xss_clean|exact_length[10]');
  3764.                 $this->form_validation->set_rules('RQ_time','Time','trim|required|xss_clean|exact_length[5]');
  3765.                 $this->form_validation->set_rules('RQ_end_time','End Time','trim|required|xss_clean|exact_length[5]');
  3766.                 $this->form_validation->set_rules('RQ_link_requests_id','ID','trim|required|xss_clean|numeric');
  3767.                 $this->form_validation->set_rules('RQ_request_status','Status','trim|xss_clean');
  3768.  
  3769.                 if($OD['multiple_locations_status']=='1')
  3770.                 {
  3771.                         $this->form_validation->set_rules('organizations_address_id','Organizations Address ID','trim|required|numeric');
  3772.                 }
  3773.  
  3774.                 if($this->form_validation->run())
  3775.                 {
  3776.                         if(!empty($OD))
  3777.                         {
  3778.                                 if(date('Y-m-d')>$OD['packge_validity_upto'])
  3779.                                 {
  3780.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Your current package is expired. please upgrade to continue to access Meet Pass');
  3781.                                         redirect(current_url());
  3782.                                 }
  3783.  
  3784.                                 $CountAvailableMeetings = $this->Manage_model->check_available_meetings_count();
  3785.                                 $CountMeetingsMembers = $this->Manage_model->check_available_meetings_members_count();
  3786.                                 if($CountAvailableMeetings>0 && $CountMeetingsMembers>1)
  3787.                                 {
  3788.                                         $link_requests_id = $this->input->post('RQ_link_requests_id');
  3789.                                         $LRD = $this->Manage_model->get_link_requests_data($link_requests_id);
  3790.  
  3791.                                         if(!empty($LRD))
  3792.                                         {
  3793.                                                 $location = $OD['location'];
  3794.                                                 $latitude = $OD['latitude'];
  3795.                                                 $longitude = $OD['longitude'];
  3796.                                                 $country_id = $OD['country_id'];
  3797.  
  3798.                                                 if($location!='' && $latitude!='' && $longitude!='')
  3799.                                                 {
  3800.                                                         $address = array('Building Name: '.$OD['building_name'],'Building Number: '.$OD['building_number'],'Floor Number: '.$OD['floor_number'],'Unit Number: '.$OD['office_number'],'Near Landmark: '.$OD['near_landmark']);
  3801.                                                         $address = implode(', ', $address);
  3802.  
  3803.                                                         $member_name = $LRD['name'];
  3804.                                                         $member_mobile = $LRD['mobile'];
  3805.                                                         $member_email = $LRD['email'];
  3806.                                                         $member_national_id = $LRD['national_id'];
  3807.                                                         $national_id_expiry_date = $LRD['national_id_expiry_date'];
  3808.  
  3809.                                                         $meeting_title = $this->input->post('RQ_meeting_title');
  3810.                                                         $date = $this->input->post('RQ_date');
  3811.                                                         $time = $this->input->post('RQ_time');
  3812.                                                         $end_time = $this->input->post('RQ_end_time');
  3813.                                                         $request_status = $this->input->post('RQ_request_status');
  3814.  
  3815.                                                         $description = $meeting_link = '';
  3816.                                                         $meeting_type = $car_pass = '0';
  3817.  
  3818.                                                         $date = $this->Common_model->date_format_changer($date);
  3819.                                                         $meeting_datetime = $date.' '.$time.':00';
  3820.                                                         $meeting_end_datetime = $date.' '.$end_time.':00';
  3821.  
  3822.                                                         $datetime = date('Y-m-d H:i:s');
  3823.  
  3824.                                                         $values = array('datetime'=>$datetime,
  3825.                                                                                         'organizations_id'=>$organizations_id,
  3826.                                                                                         'meeting_type'=>$meeting_type,
  3827.                                                                                         'meeting_title'=>$meeting_title,
  3828.                                                                                         'meeting_datetime'=>$meeting_datetime,
  3829.                                                                                         'meeting_end_datetime'=>$meeting_end_datetime,
  3830.                                                                                         'location'=>$location,
  3831.                                                                                         'latitude'=>$latitude,
  3832.                                                                                         'longitude'=>$longitude,
  3833.                                                                                         'address'=>$address,
  3834.                                                                                         'description'=>$description,
  3835.                                                                                         'meeting_link'=>$meeting_link,
  3836.                                                                                         'car_pass'=>$car_pass,
  3837.                                                                                         'admit_before'=>'1',
  3838.                                                                                         'admit_after'=>'2',
  3839.                                                                                         'status'=>'1',
  3840.                                                                                         'link_requests_id'=>$link_requests_id);
  3841.  
  3842.                                                         // setup address data
  3843.                                                         if($OD['multiple_locations_status']=='1')
  3844.                                                         {
  3845.                                                                 $organizations_address_id = $this->input->post('organizations_address_id');
  3846.                                                                 if($organizations_address_id=='0') // address take from organization table
  3847.                                                                 {
  3848.                                                                         $address = array('Building Name: '.$OD['building_name'],'Building Number: '.$OD['building_number'],'Floor Number: '.$OD['floor_number'],'Unit Number: '.$OD['office_number'],'Near Landmark: '.$OD['near_landmark']);
  3849.                                                                         $address = implode(', ', $address);
  3850.  
  3851.                                                                         $values['organizations_address_id'] = '0';
  3852.                                                                         $values['location'] = $OD['location'];
  3853.                                                                         $values['latitude'] = $OD['latitude'];
  3854.                                                                         $values['longitude'] = $OD['longitude'];
  3855.                                                                         $values['address'] = $address;
  3856.                                                                 }
  3857.                                                                 elseif($organizations_address_id>'0') // address take from address table
  3858.                                                                 {
  3859.                                                                         $AddressData = $this->Manage_model->get_organization_contact_details($organizations_address_id,$organizations_id);
  3860.                                                                         if(!empty($AddressData))
  3861.                                                                         {
  3862.                                                                                 $address = array('Building Name: '.$AddressData['building_name'],'Building Number: '.$AddressData['building_number'],'Floor Number: '.$AddressData['floor_number'],'Unit Number: '.$AddressData['office_number'],'Near Landmark: '.$AddressData['near_landmark']);
  3863.                                                                                 $address = implode(', ', $address);
  3864.  
  3865.                                                                                 $values['organizations_address_id'] = $AddressData['organizations_address_id'];
  3866.                                                                                 $values['location'] = $AddressData['location'];
  3867.                                                                                 $values['latitude'] = $AddressData['latitude'];
  3868.                                                                                 $values['longitude'] = $AddressData['longitude'];
  3869.                                                                                 $values['address'] = $address;
  3870.                                                                         }
  3871.                                                                 }
  3872.                                                         }
  3873.                                                         // setup address data
  3874.  
  3875.                                                         if($meeting_datetime>$datetime && $meeting_end_datetime>$meeting_datetime)
  3876.                                                         {
  3877.                                                                 $CheckMeeting = array();
  3878.                                                                 if($request_status!='1')
  3879.                                                                 {
  3880.                                                                         $CheckMeeting = $this->Manage_model->check_meetings_available_org($organizations_id,$meeting_datetime,$meeting_end_datetime);
  3881.                                                                 }
  3882.  
  3883.                                                                 if(empty($CheckMeeting)) // checking meeting scheduled or not
  3884.                                                                 {
  3885.                                                                         // checking meeting duplication
  3886.                                                                         $NextTime = date('Y-m-d H:i:s', strtotime('-30 seconds'));
  3887.                                                                         $CheckMeetingDuplication = $this->Manage_model->check_meeting_duplication($organizations_id,$NextTime,$datetime,$meeting_datetime,$meeting_end_datetime);
  3888.                                                                         if(!empty($CheckMeetingDuplication))
  3889.                                                                         {
  3890.                                                                                 redirect(current_url());
  3891.                                                                         }
  3892.                                                                         // checking meeting duplication
  3893.  
  3894.                                                                         $meetings_id = $this->Common_model->common_insert('meetings',$values);
  3895.  
  3896.                                                                         // update meetings count 
  3897.                                                                         $value = array('meetings_count'=>$CountAvailableMeetings-1);
  3898.                                                                         $where = array('organizations_id'=>$organizations_id);
  3899.                                                                         $this->Common_model->common_update('organizations',$value,$where);
  3900.                                                                         // update meetings count 
  3901.  
  3902.                                                                         // Activity Log Record
  3903.                                                                         $head = 'Create Meeting (Quick-Link)';
  3904.                                                                         $description = 'New Meeting (Quick-Link) Has Been Created By ';
  3905.                                                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id),'6');
  3906.                                                                         // Activity Log Record
  3907.  
  3908.                                                                         // checking table members
  3909.                                                                         $CheckTblMember = $this->Manage_model->check_member_is_exist($country_id,$member_mobile);
  3910.                                                                         if(!empty($CheckTblMember))
  3911.                                                                         {
  3912.                                                                                 $members_id = $CheckTblMember['members_id'];
  3913.                                                                                 if($CheckTblMember['members_status']!=0)
  3914.                                                                                 {
  3915.                                                                                         $M_where = array('members_id'=>$members_id);
  3916.                                                                                         $M_value = array('members_status'=>'0');
  3917.                                                                                         $this->Common_model->common_update('members',$M_value,$M_where); // update status when the member is deleted
  3918.                                                                                 }
  3919.                                                                         }
  3920.                                                                         else
  3921.                                                                         {
  3922.                                                                                 $values = array('datetime'=>date('Y-m-d H:i:s'),'country_id'=>$country_id,'name'=>ucwords($member_name),'phone'=>$member_mobile,'email'=>$member_email,'verification_id'=>$member_national_id,'national_id_expiry_date'=>$national_id_expiry_date);
  3923.                                                                                 $members_id = $this->Common_model->common_insert('members',$values);
  3924.                                                                         }
  3925.                                                                         // checking table members
  3926.  
  3927.                                                                         $values = array('company_members_status'=>'0','organizations_id'=>$organizations_id,'company_id'=>'0','members_id'=>$members_id,'name'=>ucwords($member_name),'email'=>$member_email,'verification_id'=>$member_national_id);
  3928.  
  3929.                                                                         // checking table company_members
  3930.                                                                         $CheckTblCompanyMember = $this->Manage_model->company_members_exist('0',$members_id,$organizations_id);
  3931.                                                                         if(empty($CheckTblCompanyMember))
  3932.                                                                         {
  3933.                                                                                 $values['datetime'] = date('Y-m-d H:i:s');
  3934.                                                                                 $members_sub_id = $this->Common_model->common_insert('company_members',$values);
  3935.  
  3936.                                                                                 // Activity Log Record
  3937.                                                                                 $head = 'Add Member';
  3938.                                                                                 $description = 'Member Details Has Been Added By ';
  3939.                                                                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('members_id'=>$members_id),'4');
  3940.                                                                                 // Activity Log Record
  3941.                                                                         }
  3942.                                                                         else
  3943.                                                                         {
  3944.                                                                                 if($member_email!='')
  3945.                                                                                 {
  3946.                                                                                         $C_where = array('company_members_id'=>$CheckTblCompanyMember['company_members_id']);
  3947.                                                                                         $C_value = array('email'=>strtolower($member_email));
  3948.                                                                                         $this->Common_model->common_update('company_members',$C_value,$C_where); // update email when the email is not empty
  3949.                                                                                 }
  3950.                                                                                
  3951.                                                                                 $members_sub_id = $CheckTblCompanyMember['company_members_id'];
  3952.                                                                         }
  3953.                                                                         // checking table company_members
  3954.  
  3955.                                                                         // assigning to meeting
  3956.                                                                         $values = array('datetime'=>$datetime,
  3957.                                                                                                         'meetings_id'=>$meetings_id,
  3958.                                                                                                         'members_sub_id'=>$members_sub_id,
  3959.                                                                                                         'company_id'=>'0',
  3960.                                                                                                         'members_id'=>$members_id,
  3961.                                                                                                         'member_type'=>'1');
  3962.                                                                         $meetings_participants_id = $this->Common_model->common_insert('meetings_participants',$values);
  3963.  
  3964.                                                                         $TicketNumber = 'MPT'.sprintf("%05d", $meetings_participants_id);
  3965.  
  3966.                                                                         // sent notification
  3967.                                                                         $Content = array('title'=>'Meeting Invitation','description'=>'You are invited for a new meeting with '.$OD['name'].'. ','message'=>'You are invited to a new meeting by '.strtok($OD['name'], " ").'-'.$TicketNumber.'. Download Meet Pass for your meeting access (onelink.to/meet). Meet, Mingle & Merge in Person.','meetings_id'=>$meetings_id,'TicketNumber'=>$TicketNumber,'Organization'=>$OD['name'],'MeetingTitle'=>$meeting_title);
  3968.                                                                         $this->SentNotification('1',$members_id,$Content,$members_sub_id,'1');
  3969.                                                                         // sent notification
  3970.  
  3971.                                                                         // Activity Log Record
  3972.                                                                         $head = 'Assign Meeting Members';
  3973.                                                                         $description = 'Members Has Been Assigned By ';
  3974.                                                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id),'6');
  3975.                                                                         // Activity Log Record
  3976.                                                                         // assigning to meeting
  3977.  
  3978.                                                                         // updating request
  3979.                                                                         $R_where = array('organizations_id'=>$organizations_id,'link_requests_id'=>$link_requests_id);
  3980.                                                                         $R_value = array('meetings_id'=>$meetings_id,'status'=>'1');
  3981.                                                                         $this->Common_model->common_update('link_requests',$R_value,$R_where);
  3982.                                                                         // updating request
  3983.  
  3984.                                                                         $this->Common_model->Set_Message('1','Request approved.');
  3985.                                                                         redirect('meeting-details/'.$meetings_id.'/members');
  3986.                                                                 }
  3987.                                                                 else
  3988.                                                                 {
  3989.                                                                         $_POST['RQ_request_status'] = '1';
  3990.                                                                         $this->Common_model->Set_Message('2','<i class=" fas fa-info-circle"></i> Your organization scheduled a meeting at '.$CheckMeeting['date'].' '.$CheckMeeting['time'].' to '.$CheckMeeting['end_time'].'.');
  3991.                                                                         $this->Common_model->Set_Message_Rmeeting('2','<i class=" fas fa-info-circle"></i> Your organization scheduled a meeting at '.$CheckMeeting['date'].' '.$CheckMeeting['time'].' to '.$CheckMeeting['end_time'].'.');
  3992.                                                                 }
  3993.                                                         }
  3994.                                                         else
  3995.                                                         {
  3996.                                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Please enter a valid date & time.');
  3997.                                                                 $this->Common_model->Set_Message_Rmeeting('2','<strong>Error!</strong> Please enter a valid date & time.');
  3998.                                                         }
  3999.                                                 }
  4000.                                                 else
  4001.                                                 {
  4002.                                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Please fill your address details.');
  4003.                                                         redirect(current_url());
  4004.                                                 }
  4005.                                         }
  4006.                                         else
  4007.                                         {
  4008.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  4009.                                                 redirect(current_url());
  4010.                                         }
  4011.                                 }
  4012.                                 else
  4013.                                 {
  4014.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Your current package is expired. please upgrade to continue to access Meet Pass');
  4015.                                         redirect(current_url());
  4016.                                 }
  4017.                         }
  4018.                         else
  4019.                         {
  4020.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  4021.                                 redirect(current_url());
  4022.                         }
  4023.                 }
  4024.         }
  4025.         # Create New Quick Meeting
  4026.  
  4027.         # Assign To Meeting
  4028.         if(isset($_POST['AssignToMeeting']))
  4029.         {
  4030.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  4031.                 $this->form_validation->set_rules('meetings_id','Meeting','trim|required|xss_clean');
  4032.                 $this->form_validation->set_rules('RQ_link_requests_id','ID','trim|required|xss_clean|numeric');
  4033.  
  4034.                 if($this->form_validation->run())
  4035.                 {
  4036.                         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  4037.  
  4038.                         $OD = $this->Manage_model->get_organization_details($organizations_id);
  4039.                         if(!empty($OD))
  4040.                         {
  4041.                                 $link_requests_id = $this->input->post('RQ_link_requests_id');
  4042.                                 $meetings_id = $this->input->post('meetings_id');
  4043.                                 $LRD = $this->Manage_model->get_link_requests_data($link_requests_id);
  4044.  
  4045.                                 if(!empty($LRD))
  4046.                                 {
  4047.                                         $country_id = $OD['country_id'];
  4048.                                         $datetime = date('Y-m-d H:i:s');
  4049.  
  4050.                                         $member_name = $LRD['name'];
  4051.                                         $member_mobile = $LRD['mobile'];
  4052.                                         $member_email = $LRD['email'];
  4053.                                         $member_national_id = $LRD['national_id'];
  4054.                                         $national_id_expiry_date = $LRD['national_id_expiry_date'];
  4055.  
  4056.                                         $MD = $this->Manage_model->meeting_details($meetings_id);
  4057.  
  4058.                                         if(!empty($MD))
  4059.                                         {
  4060.                                                 $meeting_datetime = $MD['meeting_datetime'];
  4061.  
  4062.                                                 if($meeting_datetime>$datetime)
  4063.                                                 {
  4064.                                                         $CountMeetingsMembers = $this->Manage_model->check_available_meetings_members_count();
  4065.                                                         $CheckMembersLimit = $this->Manage_model->check_meetings_members_count($meetings_id);
  4066.                                                         if($CheckMembersLimit<$CountMeetingsMembers)
  4067.                                                         {
  4068.                                                                 // checking table members
  4069.                                                                 $CheckTblMember = $this->Manage_model->check_member_is_exist($country_id,$member_mobile);
  4070.                                                                 if(!empty($CheckTblMember))
  4071.                                                                 {
  4072.                                                                         $members_id = $CheckTblMember['members_id'];
  4073.                                                                         if($CheckTblMember['members_status']!=0)
  4074.                                                                         {
  4075.                                                                                 $M_where = array('members_id'=>$members_id);
  4076.                                                                                 $M_value = array('members_status'=>'0');
  4077.                                                                                 $this->Common_model->common_update('members',$M_value,$M_where); // update status when the member is deleted
  4078.                                                                         }
  4079.                                                                 }
  4080.                                                                 else
  4081.                                                                 {
  4082.                                                                         $values = array('datetime'=>date('Y-m-d H:i:s'),'country_id'=>$country_id,'name'=>ucwords($member_name),'phone'=>$member_mobile,'email'=>$member_email,'verification_id'=>$member_national_id,'national_id_expiry_date'=>$national_id_expiry_date);
  4083.                                                                         $members_id = $this->Common_model->common_insert('members',$values);
  4084.                                                                 }
  4085.                                                                 // checking table members
  4086.  
  4087.                                                                 $values = array('company_members_status'=>'0','organizations_id'=>$organizations_id,'company_id'=>'0','members_id'=>$members_id,'name'=>ucwords($member_name),'email'=>$member_email,'verification_id'=>$member_national_id);
  4088.  
  4089.                                                                 // checking table company_members
  4090.                                                                 $CheckTblCompanyMember = $this->Manage_model->company_members_exist('0',$members_id,$organizations_id);
  4091.                                                                 if(empty($CheckTblCompanyMember))
  4092.                                                                 {
  4093.                                                                         $values['datetime'] = date('Y-m-d H:i:s');
  4094.                                                                         $members_sub_id = $this->Common_model->common_insert('company_members',$values);
  4095.  
  4096.                                                                         // Activity Log Record
  4097.                                                                         $head = 'Add Member';
  4098.                                                                         $description = 'Member Details Has Been Added By ';
  4099.                                                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('members_id'=>$members_id),'4');
  4100.                                                                         // Activity Log Record
  4101.                                                                 }
  4102.                                                                 else
  4103.                                                                 {
  4104.                                                                         $members_sub_id = $CheckTblCompanyMember['company_members_id'];
  4105.                                                                 }
  4106.                                                                 // checking table company_members
  4107.  
  4108.                                                                 $CheckMemberExist = $this->Manage_model->check_meetings_members_exist($meetings_id,$members_id,'');
  4109.                                                                 if(empty($CheckMemberExist))
  4110.                                                                 {
  4111.                                                                         // assigning to meeting
  4112.                                                                         $values = array('datetime'=>$datetime,
  4113.                                                                                                         'meetings_id'=>$meetings_id,
  4114.                                                                                                         'members_sub_id'=>$members_sub_id,
  4115.                                                                                                         'company_id'=>'0',
  4116.                                                                                                         'members_id'=>$members_id,
  4117.                                                                                                         'member_type'=>'1');
  4118.                                                                         $meetings_participants_id = $this->Common_model->common_insert('meetings_participants',$values);
  4119.  
  4120.                                                                         $TicketNumber = 'MPT'.sprintf("%05d", $meetings_participants_id);
  4121.  
  4122.                                                                         // sent notification
  4123.                                                                         if($MD['meeting_type']=='0')
  4124.                                                                         {
  4125.                                                                                 $Content = array('title'=>'Meeting Invitation','description'=>'You are invited for a new meeting with '.$OD['name'].'. ','message'=>'You are invited to a new meeting by '.strtok($OD['name'], " ").'-'.$TicketNumber.'. Download Meet Pass for your meeting access (onelink.to/meet). Meet, Mingle & Merge in Person.','meetings_id'=>$meetings_id,'TicketNumber'=>$TicketNumber,'Organization'=>$OD['name'],'MeetingTitle'=>$MD['meeting_title']);
  4126.                                                                         }
  4127.                                                                         else
  4128.                                                                         {
  4129.                                                                                 $Content = array('title'=>'Event Invitation','description'=>'You are invited for a new event with '.$OD['name'].'. ','message'=>'You are invited to a new evevt by '.strtok($OD['name'], " ").'-'.$TicketNumber.'. Download Meet Pass for your evevt access (onelink.to/meet). Meet, Mingle & Merge in Person.','meetings_id'=>$meetings_id,'TicketNumber'=>$TicketNumber,'Organization'=>$OD['name'],'MeetingTitle'=>$MD['meeting_title']);
  4130.                                                                         }
  4131.                                                                         $this->SentNotification('1',$members_id,$Content,$members_sub_id,'1');
  4132.                                                                         // sent notification
  4133.  
  4134.                                                                         // Activity Log Record
  4135.                                                                         $head = 'Assign Meeting Members';
  4136.                                                                         $description = 'Members Has Been Assigned By ';
  4137.                                                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id),'6');
  4138.                                                                         // Activity Log Record
  4139.                                                                         // assigning to meeting
  4140.  
  4141.                                                                         // updating request
  4142.                                                                         $R_where = array('organizations_id'=>$organizations_id,'link_requests_id'=>$link_requests_id);
  4143.                                                                         $R_value = array('meetings_id'=>$meetings_id,'status'=>'1');
  4144.                                                                         $this->Common_model->common_update('link_requests',$R_value,$R_where);
  4145.                                                                         // updating request
  4146.  
  4147.                                                                         $this->Common_model->Set_Message('1','Request approved');
  4148.                                                                         redirect(current_url());
  4149.                                                                 }
  4150.                                                                 else
  4151.                                                                 {
  4152.                                                                         $this->Common_model->Set_Message('2','Member already an attendee for the selected meeting.');
  4153.                                                                 }
  4154.                                                         }
  4155.                                                         else
  4156.                                                         {
  4157.                                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> You have exceeded maximum allowed meeting members '.$CountMeetingsMembers.'.');
  4158.                                                         }
  4159.                                                 }
  4160.                                                 else
  4161.                                                 {
  4162.                                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Please enter a valid date & time.');
  4163.                                                 }
  4164.                                         }
  4165.                                         else
  4166.                                         {
  4167.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  4168.                                         }
  4169.                                 }
  4170.                                 else
  4171.                                 {
  4172.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  4173.                                 }
  4174.                         }
  4175.                         else
  4176.                         {
  4177.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  4178.                         }
  4179.                         redirect(current_url());
  4180.                 }
  4181.         }
  4182.         # Assign To Meeting
  4183.  
  4184.         # REJECT REQUEST FUNCTION
  4185.         if(isset($_POST['delete']))
  4186.         {
  4187.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  4188.                 if($this->form_validation->run())
  4189.                 {
  4190.                         $link_requests_id = $this->input->post('delete_id');
  4191.                         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  4192.  
  4193.                         $value = array('status'=>'2');
  4194.                         $where = array('link_requests_id'=>$link_requests_id,'organizations_id'=>$organizations_id);
  4195.                         $this->Common_model->common_update('link_requests',$value,$where);
  4196.                         $this->Common_model->Set_Message('1','Request rejected');
  4197.  
  4198.                         // Activity Log Record
  4199.                         $head = 'Reject Registration';
  4200.                         $description = 'Registration Has Been Rejected By ';
  4201.                         $this->Common_model->create_activity_log($head,$description,'',array(),array('link_requests_id'=>$link_requests_id),'9');
  4202.                         // Activity Log Record
  4203.                 }
  4204.                 else
  4205.                 {
  4206.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  4207.                 }
  4208.                 redirect(current_url());
  4209.         }
  4210.         # END OF REJECT REQUEST FUNCTION
  4211.  
  4212.         # FILTER AND PAGINATION SECTION
  4213.         $URL = $this->uri->segment(1);
  4214.         $param[] = array('key'=>'mobile','default'=>'');
  4215.         $param[] = array('key'=>'meeting_date','default'=>'');
  4216.         $param[] = array('key'=>'meeting_purpose_id','default'=>'');
  4217.         $FD = $this->Common_model->common_filter($URL,$param);
  4218.  
  4219.         $FD['LinkStatus'] = $LinkStatus;
  4220.  
  4221.         $start = $limit = '';
  4222.         $page_ary['url'] = base_url($URL);
  4223.  
  4224.         $page_ary['total_rows'] = $this->Manage_model->link_requests($FD,$start,$limit,'1')[0]->count;
  4225.         $limit = $page_ary['per_page'] = 30;
  4226.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  4227.         $data['page'] = $start = $PGN_DATA['page'];
  4228.         $data['links'] = $PGN_DATA['links'];
  4229.         # END OF FILTER AND PAGINATION SECTION
  4230.  
  4231.         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  4232.         $OD = $this->Manage_model->get_organization_details($organizations_id);
  4233.  
  4234.         $data['FD'] = $FD;
  4235.         $data['RL'] = $this->Manage_model->link_requests($FD,$start,$limit,'0');
  4236.         $data['MP'] = $this->Manage_model->view_meeting_purpose_list($OD['organization_type_id']);
  4237.         $data['ML'] = $this->Manage_model->upcoming_meeting_list();
  4238.  
  4239.         $this->CommonPage('organizations/link_requests',$data,'Meeting request from dedicated link');
  4240. }
  4241. ############################################ END OF LINK REQUESTS #################################
  4242.  
  4243. ############################################ VIEW SECURITY ########################################
  4244. public function get_security_data()
  4245. {
  4246.         $Data['response'] = 'failed';
  4247.         $Data['result'] = array();
  4248.  
  4249.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  4250.         if($this->form_validation->run())
  4251.         {
  4252.                 $organizations_security_id = $this->input->post('data_id');
  4253.                 $Result = $this->Manage_model->get_security_details($organizations_security_id);
  4254.                 if(!empty($Result))
  4255.                 {
  4256.                         $Data['response'] = 'success';
  4257.                         $Data['result'] = $Result;
  4258.                 }
  4259.         }
  4260.         echo json_encode($Data);
  4261. }
  4262.  
  4263. public function view_security()
  4264. {
  4265.         # INSERT / UPDATE FUNCTION
  4266.         if(isset($_POST['submit']))
  4267.         {
  4268.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  4269.                 $this->form_validation->set_rules('name','Name','trim|required|xss_clean');
  4270.                 $this->form_validation->set_rules('mobile','Email','trim|required|xss_clean|numeric');
  4271.                 $this->form_validation->set_rules('designation','Designation','trim|required|xss_clean');
  4272.                 $this->form_validation->set_rules('admit_privilege','Privilege','trim|required|xss_clean|numeric');
  4273.                 $this->form_validation->set_rules('status','status','trim|required|xss_clean|numeric');
  4274.  
  4275.                 if($this->form_validation->run())
  4276.                 {
  4277.                         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  4278.                         $OD = $this->Manage_model->get_organization_data($organizations_id);
  4279.                         $country_id = $OD['country_id'];
  4280.  
  4281.                         $name = ucwords($this->input->post('name'));
  4282.                         $mobile = $this->input->post('mobile');
  4283.                         $designation = $this->input->post('designation');
  4284.                         $admit_privilege = $this->input->post('admit_privilege');
  4285.                         $status = $this->input->post('status');
  4286.  
  4287.                         // checking tbl security
  4288.                         $CheckTblSecurity = $this->Manage_model->check_security_is_exist($country_id,$mobile);
  4289.                         if(!empty($CheckTblSecurity))
  4290.                         {
  4291.                                 $security_id = $CheckTblSecurity['security_id'];
  4292.                                 if($CheckTblSecurity['security_status']!=0)
  4293.                                 {
  4294.                                         $S_where = array('security_id'=>$security_id);
  4295.                                         $S_value = array('security_status'=>'0');
  4296.                                         $this->Common_model->common_update('security',$S_value,$S_where); // update status when the security is deleted
  4297.                                 }
  4298.                         }
  4299.                         else
  4300.                         {
  4301.                                 if($this->input->post('submit')=='Save')
  4302.                                 {
  4303.                                         $values = array('datetime'=>date('Y-m-d H:i:s'),
  4304.                                                                         'country_id'=>$country_id,
  4305.                                                                         'name'=>ucwords($name),
  4306.                                                                         'mobile'=>$mobile,
  4307.                                                                         'designation'=>$designation);
  4308.  
  4309.                                         $security_id = $this->Common_model->common_insert('security',$values);
  4310.                                 }
  4311.                                 else
  4312.                                 {
  4313.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  4314.                                         redirect(current_url());
  4315.                                 }
  4316.                         }
  4317.                         // checking tbl security
  4318.  
  4319.                         $values = array('organizations_id'=>$organizations_id,
  4320.                                                         'security_id'=>$security_id,
  4321.                                                         'name'=>$name,
  4322.                                                         'designation'=>$designation,
  4323.                                                         'admit_privilege'=>$admit_privilege,
  4324.                                                         'status'=>$status);
  4325.  
  4326.                         $CheckTblOrgSecurity = $this->Manage_model->organizations_security_exist($organizations_id,$security_id);
  4327.                         if(!empty($CheckTblOrgSecurity))
  4328.                         {
  4329.                                 if($this->input->post('submit')=='Update')
  4330.                                 {
  4331.                                         $where = array('organizations_id'=>$organizations_id,'security_id'=>$security_id,'organizations_security_id'=>$CheckTblOrgSecurity['organizations_security_id']);
  4332.                                         $this->Common_model->common_update('organizations_security',$values,$where);
  4333.                                         $this->Common_model->Set_Message('1',"Security details updated successfully.");
  4334.  
  4335.                                         // Activity Log Record
  4336.                                         $head = 'Update Security';
  4337.                                         $description = 'Security Details Has Been Updated By ';
  4338.                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('security_id'=>$security_id),'7');
  4339.                                         // Activity Log Record
  4340.                                 }
  4341.                                 else
  4342.                                 {
  4343.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Security details already exist.');
  4344.                                 }
  4345.                         }
  4346.                         else
  4347.                         {
  4348.                                 $values['datetime'] = date('Y-m-d H:i:s');
  4349.                                 $this->Common_model->common_insert('organizations_security',$values);
  4350.                                 $this->Common_model->Set_Message('1',"Security added successfully.");
  4351.  
  4352.                                 // Activity Log Record
  4353.                                 $head = 'Add Security';
  4354.                                 $description = 'Security Details Has Been Added By ';
  4355.                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('security_id'=>$security_id),'7');
  4356.                                 // Activity Log Record
  4357.                         }
  4358.  
  4359.                         redirect(current_url());
  4360.                 }
  4361.                 else
  4362.                 {
  4363.                         if($this->input->post('submit')=='Update')
  4364.                         {
  4365.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  4366.                                 redirect(current_url());
  4367.                         }
  4368.                 }
  4369.         }
  4370.         # END OF INSERT / UPDATE FUNCTION
  4371.  
  4372.         # DELETE FUNCTION
  4373.         if(isset($_POST['delete']))
  4374.         {
  4375.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  4376.                 if($this->form_validation->run())
  4377.                 {
  4378.                         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  4379.                         $delete_id = $this->input->post('delete_id');
  4380.                         $where = array('organizations_security_id'=>$delete_id,'organizations_id'=>$organizations_id);
  4381.                         $value = array('organizations_security_status'=>'1');
  4382.                         $this->Common_model->common_update('organizations_security',$value,$where);
  4383.                         $this->Common_model->Set_Message('1','Secuity details removed successfully.');
  4384.  
  4385.                         // Activity Log Record
  4386.                         $head = 'Remove Secuity';
  4387.                         $description = 'Secuity Details Has Been Removed By ';
  4388.                         $this->Common_model->create_activity_log($head,$description,'',array(),array('organizations_security_id'=>$delete_id),'7');
  4389.                         // Activity Log Record
  4390.                 }
  4391.                 else
  4392.                 {
  4393.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  4394.                 }
  4395.                 redirect(current_url());
  4396.         }
  4397.         # END OF DELETE FUNCTION
  4398.  
  4399.         # FILTER AND PAGINATION SECTION
  4400.         $URL = $this->uri->segment(1);
  4401.         $param[] = array('key'=>'name','default'=>'');
  4402.         $param[] = array('key'=>'mobile','default'=>'');
  4403.         $FD = $this->Common_model->common_filter($URL,$param);
  4404.  
  4405.         $start = $limit = '';
  4406.         $page_ary['url'] = base_url($URL);
  4407.         $page_ary['total_rows'] = $this->Manage_model->view_security($FD,$start,$limit,'1')[0]->count;
  4408.         $limit = $page_ary['per_page'] = 30;
  4409.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  4410.         $data['page'] = $start = $PGN_DATA['page'];
  4411.         $data['links'] = $PGN_DATA['links'];
  4412.         # END OF FILTER AND PAGINATION SECTION
  4413.  
  4414.         $data['FD'] = $FD;
  4415.         $data['MD'] = $this->Manage_model->view_security($FD,$start,$limit,'0');
  4416.  
  4417.         $this->CommonPage('organizations/view_security',$data,'List of authorized security staffs');
  4418. }
  4419. ############################################ END OF VIEW SECURITY #################################
  4420.  
  4421. ############################################ MEETINGS #############################################
  4422. public function view_meetings($MeetingStatus)
  4423. {
  4424.         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  4425.         $OD = $this->Manage_model->get_organization_details($organizations_id);
  4426.  
  4427.         # Create New Quick Meeting
  4428.         if(isset($_POST['CreateQuickMeeting']))
  4429.         {
  4430.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  4431.                 $this->form_validation->set_rules('Q_member_name','Name','trim|required|xss_clean');
  4432.                 $this->form_validation->set_rules('Q_member_mobile','Mobile','trim|required|xss_clean');
  4433.                 $this->form_validation->set_rules('Q_email_id','Email','trim|valid_email|xss_clean');
  4434.                 $this->form_validation->set_rules('Q_meeting_title','Title','trim|required|xss_clean');
  4435.                 $this->form_validation->set_rules('Q_request_status','Status','trim|xss_clean');
  4436.                 $this->form_validation->set_rules('Q_date','Date','trim|required|xss_clean|exact_length[10]');
  4437.                 $this->form_validation->set_rules('Q_time','Time','trim|required|xss_clean|exact_length[5]');
  4438.                 $this->form_validation->set_rules('Q_end_time','End Time','trim|required|xss_clean|exact_length[5]');
  4439.  
  4440.                 if($OD['multiple_locations_status']=='1')
  4441.                 {
  4442.                         $this->form_validation->set_rules('organizations_address_id','Organizations Address ID','trim|required|numeric');
  4443.                 }
  4444.  
  4445.                 if($this->form_validation->run())
  4446.                 {
  4447.                         if(!empty($OD))
  4448.                         {
  4449.                                 if(date('Y-m-d')>$OD['packge_validity_upto'])
  4450.                                 {
  4451.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Your current package is expired. please upgrade to continue to access Meet Pass');
  4452.                                         redirect(current_url());
  4453.                                 }
  4454.  
  4455.                                 $CountAvailableMeetings = $this->Manage_model->check_available_meetings_count();
  4456.                                 $CountMeetingsMembers = $this->Manage_model->check_available_meetings_members_count();
  4457.                                 if($CountAvailableMeetings>0 && $CountMeetingsMembers>1)
  4458.                                 {
  4459.                                         $location = $OD['location'];
  4460.                                         $latitude = $OD['latitude'];
  4461.                                         $longitude = $OD['longitude'];
  4462.                                         $country_id = $OD['country_id'];
  4463.  
  4464.                                         if($location!='' && $latitude!='' && $longitude!='')
  4465.                                         {
  4466.                                                 $address = array('Building Name: '.$OD['building_name'],'Building Number: '.$OD['building_number'],'Floor Number: '.$OD['floor_number'],'Unit Number: '.$OD['office_number'],'Near Landmark: '.$OD['near_landmark']);
  4467.                                                 $address = implode(', ', $address);
  4468.  
  4469.                                                 $member_name = $this->input->post('Q_member_name');
  4470.                                                 $member_mobile = $this->input->post('Q_member_mobile');
  4471.                                                 $email_id = $this->input->post('Q_email_id');
  4472.                                                 $request_status = $this->input->post('Q_request_status');
  4473.  
  4474.                                                 $meeting_title = $this->input->post('Q_meeting_title');
  4475.                                                 $date = $this->input->post('Q_date');
  4476.                                                 $time = $this->input->post('Q_time');
  4477.                                                 $end_time = $this->input->post('Q_end_time');
  4478.  
  4479.                                                 $description = $meeting_link = '';
  4480.                                                 $meeting_type = $car_pass = '0';
  4481.  
  4482.                                                 $date = $this->Common_model->date_format_changer($date);
  4483.                                                 $meeting_datetime = $date.' '.$time.':00';
  4484.                                                 $meeting_end_datetime = $date.' '.$end_time.':00';
  4485.  
  4486.                                                 $datetime = date('Y-m-d H:i:s');
  4487.  
  4488.                                                 $values = array('datetime'=>$datetime,
  4489.                                                                                 'organizations_id'=>$organizations_id,
  4490.                                                                                 'meeting_type'=>$meeting_type,
  4491.                                                                                 'meeting_title'=>$meeting_title,
  4492.                                                                                 'meeting_datetime'=>$meeting_datetime,
  4493.                                                                                 'meeting_end_datetime'=>$meeting_end_datetime,
  4494.                                                                                 'location'=>$location,
  4495.                                                                                 'latitude'=>$latitude,
  4496.                                                                                 'longitude'=>$longitude,
  4497.                                                                                 'address'=>$address,
  4498.                                                                                 'description'=>$description,
  4499.                                                                                 'meeting_link'=>$meeting_link,
  4500.                                                                                 'car_pass'=>$car_pass,
  4501.                                                                                 'admit_before'=>'1',
  4502.                                                                                 'admit_after'=>'2',
  4503.                                                                                 'status'=>'1');
  4504.  
  4505.                                                 // setup address data
  4506.                                                 if($OD['multiple_locations_status']=='1')
  4507.                                                 {
  4508.                                                         $organizations_address_id = $this->input->post('organizations_address_id');
  4509.                                                         if($organizations_address_id=='0') // address take from organization table
  4510.                                                         {
  4511.                                                                 $address = array('Building Name: '.$OD['building_name'],'Building Number: '.$OD['building_number'],'Floor Number: '.$OD['floor_number'],'Unit Number: '.$OD['office_number'],'Near Landmark: '.$OD['near_landmark']);
  4512.                                                                 $address = implode(', ', $address);
  4513.  
  4514.                                                                 $values['organizations_address_id'] = '0';
  4515.                                                                 $values['location'] = $OD['location'];
  4516.                                                                 $values['latitude'] = $OD['latitude'];
  4517.                                                                 $values['longitude'] = $OD['longitude'];
  4518.                                                                 $values['address'] = $address;
  4519.                                                         }
  4520.                                                         elseif($organizations_address_id>'0') // address take from address table
  4521.                                                         {
  4522.                                                                 $AddressData = $this->Manage_model->get_organization_contact_details($organizations_address_id,$organizations_id);
  4523.                                                                 if(!empty($AddressData))
  4524.                                                                 {
  4525.                                                                         $address = array('Building Name: '.$AddressData['building_name'],'Building Number: '.$AddressData['building_number'],'Floor Number: '.$AddressData['floor_number'],'Unit Number: '.$AddressData['office_number'],'Near Landmark: '.$AddressData['near_landmark']);
  4526.                                                                         $address = implode(', ', $address);
  4527.  
  4528.                                                                         $values['organizations_address_id'] = $AddressData['organizations_address_id'];
  4529.                                                                         $values['location'] = $AddressData['location'];
  4530.                                                                         $values['latitude'] = $AddressData['latitude'];
  4531.                                                                         $values['longitude'] = $AddressData['longitude'];
  4532.                                                                         $values['address'] = $address;
  4533.                                                                 }
  4534.                                                         }
  4535.                                                 }
  4536.                                                 // setup address data
  4537.  
  4538.                                                 if($meeting_datetime>$datetime && $meeting_end_datetime>$meeting_datetime)
  4539.                                                 {
  4540.                                                         $CheckMeeting = array();
  4541.                                                         if($request_status!='1')
  4542.                                                         {
  4543.                                                                 $CheckMeeting = $this->Manage_model->check_meetings_available_org($organizations_id,$meeting_datetime,$meeting_end_datetime);
  4544.                                                         }
  4545.  
  4546.                                                         if(empty($CheckMeeting)) // checking meeting scheduled or not
  4547.                                                         {
  4548.                                                                 // checking meeting duplication
  4549.                                                                 $NextTime = date('Y-m-d H:i:s', strtotime('-30 seconds'));
  4550.                                                                 $CheckMeetingDuplication = $this->Manage_model->check_meeting_duplication($organizations_id,$NextTime,$datetime,$meeting_datetime,$meeting_end_datetime);
  4551.                                                                 if(!empty($CheckMeetingDuplication))
  4552.                                                                 {
  4553.                                                                         redirect(current_url());
  4554.                                                                 }
  4555.                                                                 // checking meeting duplication
  4556.  
  4557.                                                                 $meetings_id = $this->Common_model->common_insert('meetings',$values);
  4558.  
  4559.                                                                 // update meetings count 
  4560.                                                                 $value = array('meetings_count'=>$CountAvailableMeetings-1);
  4561.                                                                 $where = array('organizations_id'=>$organizations_id);
  4562.                                                                 $this->Common_model->common_update('organizations',$value,$where);
  4563.                                                                 // update meetings count 
  4564.  
  4565.                                                                 // Activity Log Record
  4566.                                                                 $head = 'Create Meeting (Quick)';
  4567.                                                                 $description = 'New Meeting (Quick) Has Been Created By ';
  4568.                                                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id),'6');
  4569.                                                                 // Activity Log Record
  4570.  
  4571.                                                                 // processing memberdetails
  4572.                                                                 $ReqData = array('country_id'=>$country_id,
  4573.                                                                                                 'member_mobile'=>$member_mobile,
  4574.                                                                                                 'member_name'=>$member_name,
  4575.                                                                                                 'email_id'=>$email_id,
  4576.                                                                                                 'organizations_id'=>$organizations_id,
  4577.                                                                                                 'company_id'=>'0');
  4578.                                                                 $ResultData = $this->CheckingMemberDetails($ReqData);
  4579.  
  4580.                                                                 $members_id = $ResultData['members_id'];
  4581.                                                                 $members_sub_id = $ResultData['members_sub_id'];
  4582.                                                                 // processing memberdetails
  4583.  
  4584.                                                                 // assigning to meeting
  4585.                                                                 $values = array('datetime'=>$datetime,
  4586.                                                                                                 'meetings_id'=>$meetings_id,
  4587.                                                                                                 'members_sub_id'=>$members_sub_id,
  4588.                                                                                                 'company_id'=>'0',
  4589.                                                                                                 'members_id'=>$members_id,
  4590.                                                                                                 'member_type'=>'1');
  4591.                                                                 $meetings_participants_id = $this->Common_model->common_insert('meetings_participants',$values);
  4592.  
  4593.                                                                 $TicketNumber = 'MPT'.sprintf("%05d", $meetings_participants_id);
  4594.  
  4595.                                                                 // sent notification
  4596.                                                                 $Content = array('title'=>'Meeting Invitation','description'=>'You are invited for a new meeting with '.$OD['name'].'. ','message'=>'You are invited to a new meeting by '.strtok($OD['name'], " ").'-'.$TicketNumber.'. Download Meet Pass for your meeting access (onelink.to/meet). Meet, Mingle & Merge in Person.','meetings_id'=>$meetings_id,'TicketNumber'=>$TicketNumber,'Organization'=>$OD['name'],'MeetingTitle'=>$meeting_title);
  4597.                                                                 $this->SentNotification('1',$members_id,$Content,$members_sub_id,'1');
  4598.                                                                 // sent notification
  4599.  
  4600.                                                                 // Activity Log Record
  4601.                                                                 $head = 'Assign Meeting Members';
  4602.                                                                 $description = 'Members Has Been Assigned By ';
  4603.                                                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id),'6');
  4604.                                                                 // Activity Log Record
  4605.                                                                 // assigning to meeting
  4606.  
  4607.                                                                 $this->Common_model->Set_Message('1','New meeting created successfully.');
  4608.                                                                 redirect('meeting-details/'.$meetings_id.'/members');
  4609.                                                         }
  4610.                                                         else
  4611.                                                         {
  4612.                                                                 $_POST['Q_request_status'] = '1';
  4613.                                                                 $this->Common_model->Set_Message('2','<i class=" fas fa-info-circle"></i> Your organization scheduled a meeting at '.$CheckMeeting['date'].' '.$CheckMeeting['time'].' to '.$CheckMeeting['end_time'].'.');
  4614.                                                                 $this->Common_model->Set_Message_Qmeeting('2','<i class=" fas fa-info-circle"></i> Your organization scheduled a meeting at '.$CheckMeeting['date'].' '.$CheckMeeting['time'].' to '.$CheckMeeting['end_time'].'.');
  4615.                                                         }
  4616.                                                 }
  4617.                                                 else
  4618.                                                 {
  4619.                                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Please enter a valid Date & Time.');
  4620.                                                         $this->Common_model->Set_Message_Qmeeting('2','<strong>Error!</strong> Please enter a valid Date & Time.');
  4621.                                                 }
  4622.                                         }
  4623.                                         else
  4624.                                         {
  4625.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Please complete your address.');
  4626.                                                 $this->Common_model->Set_Message_Qmeeting('2','<strong>Error!</strong> Please complete your address.');
  4627.                                                 redirect(current_url());
  4628.                                         }
  4629.                                 }
  4630.                                 else
  4631.                                 {
  4632.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Your current package is expired. please upgrade to continue to access Meet Pass');
  4633.                                         $this->Common_model->Set_Message_Qmeeting('2','<strong>Error!</strong> Your current package is expired. please upgrade to continue to access Meet Pass');
  4634.                                         redirect(current_url());
  4635.                                 }
  4636.                         }
  4637.                         else
  4638.                         {
  4639.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  4640.                                 $this->Common_model->Set_Message_Qmeeting('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  4641.                                 redirect(current_url());
  4642.                         }
  4643.                 }
  4644.         }
  4645.         # Create New Quick Meeting
  4646.  
  4647.         # Create New Meeting
  4648.         if(isset($_POST['CreateMeeting']))
  4649.         {
  4650.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  4651.                 $this->form_validation->set_rules('meeting_type','Type','trim|required|xss_clean');
  4652.                 $this->form_validation->set_rules('meeting_title','Title','trim|required|xss_clean');
  4653.                 $this->form_validation->set_rules('date','Date','trim|required|xss_clean|exact_length[10]');
  4654.                 $this->form_validation->set_rules('time','Time','trim|required|xss_clean|exact_length[5]');
  4655.                 $this->form_validation->set_rules('end_time','End Time','trim|required|xss_clean|exact_length[5]');
  4656.                 /*$this->form_validation->set_rules('location','Location','trim|required|xss_clean');
  4657.                 $this->form_validation->set_rules('latitude','Location','trim|required|xss_clean');
  4658.                 $this->form_validation->set_rules('longitude','Location','trim|required|xss_clean');
  4659.                 $this->form_validation->set_rules('address','Address','trim|required|xss_clean');*/
  4660.                 $this->form_validation->set_rules('car_pass','Car Pass','trim|required|xss_clean');
  4661.                 $this->form_validation->set_rules('description','Description','trim|xss_clean');
  4662.                 $this->form_validation->set_rules('request_status','Status','trim|xss_clean');
  4663.                 $this->form_validation->set_rules('meeting_link','Link','trim|xss_clean|valid_url');
  4664.  
  4665.                 if($OD['multiple_locations_status']=='1')
  4666.                 {
  4667.                         $this->form_validation->set_rules('organizations_address_id','Organizations Address ID','trim|required|numeric');
  4668.                 }
  4669.  
  4670.                 if($this->form_validation->run())
  4671.                 {
  4672.                         $meeting_type = $this->input->post('meeting_type');
  4673.                         if(!empty($OD))
  4674.                         {
  4675.                                 if(date('Y-m-d')>$OD['packge_validity_upto'])
  4676.                                 {
  4677.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Your current package is expired. please upgrade to continue to access Meet Pass');
  4678.                                         redirect(current_url());
  4679.                                 }
  4680.  
  4681.                                 if($meeting_type==0) // meeting
  4682.                                 {
  4683.                                         $CountAvailableMeetings = $this->Manage_model->check_available_meetings_count();
  4684.                                 }
  4685.                                 else // event
  4686.                                 {
  4687.                                         $CountAvailableMeetings = $this->Manage_model->check_available_events_count();
  4688.                                 }
  4689.  
  4690.                                 if($CountAvailableMeetings>0)
  4691.                                 {
  4692.  
  4693.                                         $location = $OD['location'];
  4694.                                         $latitude = $OD['latitude'];
  4695.                                         $longitude = $OD['longitude'];
  4696.  
  4697.                                         if($location!='' && $latitude!='' && $longitude!='')
  4698.                                         {
  4699.                                                 $address = array('Building Name: '.$OD['building_name'],'Building Number: '.$OD['building_number'],'Floor Number: '.$OD['floor_number'],'Unit Number: '.$OD['office_number'],'Near Landmark: '.$OD['near_landmark']);
  4700.                                                 $address = implode(', ', $address);
  4701.  
  4702.                                                 $meeting_title = $this->input->post('meeting_title');
  4703.                                                 $date = $this->input->post('date');
  4704.                                                 $time = $this->input->post('time');
  4705.                                                 $end_time = $this->input->post('end_time');
  4706.                                                 //$description = $this->input->post('description');
  4707.                                                 $meeting_link = $this->input->post('meeting_link');
  4708.                                                 $car_pass = $this->input->post('car_pass');
  4709.                                                 $request_status = $this->input->post('request_status');
  4710.  
  4711.                                                 $date = $this->Common_model->date_format_changer($date);
  4712.                                                 $meeting_datetime = $date.' '.$time.':00';
  4713.                                                 $meeting_end_datetime = $date.' '.$end_time.':00';
  4714.                         $flollow_up_id = $this->input->post('hfmeeting_id');
  4715.                         $flollow_up_status = $this->input->post('flollow_up_status');
  4716.                                                 $datetime = date('Y-m-d H:i:s');
  4717.  
  4718.                                                 $values = array('datetime'=>$datetime,
  4719.                                                                                 'organizations_id'=>$organizations_id,
  4720.                                                                                 'meeting_type'=>$meeting_type,
  4721.                                                                                 'meeting_title'=>$meeting_title,
  4722.                                                                                 'meeting_datetime'=>$meeting_datetime,
  4723.                                                                                 'meeting_end_datetime'=>$meeting_end_datetime,
  4724.                                                                                 'location'=>$location,
  4725.                                                                                 'latitude'=>$latitude,
  4726.                                                                                 'longitude'=>$longitude,
  4727.                                                                                 'address'=>$address,                                                                           
  4728.                                                                                 'meeting_link'=>$meeting_link,
  4729.                                                                                 'car_pass'=>$car_pass,
  4730.                                                                                 'admit_before'=>'1',
  4731.                                                                                 'admit_after'=>'2',
  4732.                                                                                 'status'=>'1');
  4733.  
  4734.                                                 // setup address data
  4735.                                                 if($OD['multiple_locations_status']=='1')
  4736.                                                 {
  4737.                                                         $organizations_address_id = $this->input->post('organizations_address_id');
  4738.                                                         if($organizations_address_id=='0') // address take from organization table
  4739.                                                         {
  4740.                                                                 $address = array('Building Name: '.$OD['building_name'],'Building Number: '.$OD['building_number'],'Floor Number: '.$OD['floor_number'],'Unit Number: '.$OD['office_number'],'Near Landmark: '.$OD['near_landmark']);
  4741.                                                                 $address = implode(', ', $address);
  4742.  
  4743.                                                                 $values['organizations_address_id'] = '0';
  4744.                                                                 $values['location'] = $OD['location'];
  4745.                                                                 $values['latitude'] = $OD['latitude'];
  4746.                                                                 $values['longitude'] = $OD['longitude'];
  4747.                                                                 $values['address'] = $address;
  4748.                                                         }
  4749.                                                         elseif($organizations_address_id>'0') // address take from address table
  4750.                                                         {
  4751.                                                                 $AddressData = $this->Manage_model->get_organization_contact_details($organizations_address_id,$organizations_id);
  4752.                                                                 if(!empty($AddressData))
  4753.                                                                 {
  4754.                                                                         $address = array('Building Name: '.$AddressData['building_name'],'Building Number: '.$AddressData['building_number'],'Floor Number: '.$AddressData['floor_number'],'Unit Number: '.$AddressData['office_number'],'Near Landmark: '.$AddressData['near_landmark']);
  4755.                                                                         $address = implode(', ', $address);
  4756.  
  4757.                                                                         $values['organizations_address_id'] = $AddressData['organizations_address_id'];
  4758.                                                                         $values['location'] = $AddressData['location'];
  4759.                                                                         $values['latitude'] = $AddressData['latitude'];
  4760.                                                                         $values['longitude'] = $AddressData['longitude'];
  4761.                                                                         $values['address'] = $address;
  4762.                                                                 }
  4763.                                                         }
  4764.                                                 }
  4765.                                                 // setup address data
  4766.  
  4767.                                                 if($meeting_type==1) // event
  4768.                                                 {
  4769.                                                         $values['participant_status'] = '1';
  4770.                                                 }
  4771.  
  4772.                                                 if($meeting_datetime>$datetime && $meeting_end_datetime>$meeting_datetime)
  4773.                                                 {
  4774.                                                         $CheckMeeting = array();
  4775.                                                         if($request_status!='1')
  4776.                                                         {
  4777.                                                                 $CheckMeeting = $this->Manage_model->check_meetings_available_org($organizations_id,$meeting_datetime,$meeting_end_datetime);
  4778.                                                         }
  4779.  
  4780.               
  4781.                                                         if(empty($CheckMeeting)) // checking meeting scheduled or not
  4782.                                                         {
  4783.                                                                 // checking meeting duplication
  4784.                                                                 $NextTime = date('Y-m-d H:i:s', strtotime('-30 seconds'));
  4785.                                                                 $CheckMeetingDuplication = $this->Manage_model->check_meeting_duplication($organizations_id,$NextTime,$datetime,$meeting_datetime,$meeting_end_datetime);
  4786.                                                                 if(!empty($CheckMeetingDuplication))
  4787.                                                                 {
  4788.                                                                         redirect(current_url());
  4789.                                                                 }
  4790.                                                                 // checking meeting duplication
  4791.  
  4792.                                                                 $meetings_id = $this->Common_model->common_insert('meetings',$values);
  4793.                                                                 if($meeting_type==0) // meeting
  4794.                                                                 {
  4795.                                                                         $this->Common_model->Set_Message('1','New meeting created successfully.');
  4796.                                                                 }
  4797.                                                                 else // event
  4798.                                                                 {
  4799.                                                                         $this->Common_model->Set_Message('1','New Event created successfully.');
  4800.                                                                 }
  4801.  
  4802.                                                                 // update meetings count 
  4803.                                                                 if($meeting_type==0) // meeting
  4804.                                                                 {
  4805.                                                                         $value = array('meetings_count'=>$CountAvailableMeetings-1);
  4806.                                                                 }
  4807.                                                                 else // event
  4808.                                                                 {
  4809.                                                                         $value = array('events_count'=>$CountAvailableMeetings-1);
  4810.                                                                 }
  4811.  
  4812.                                                                 $where = array('organizations_id'=>$organizations_id);
  4813.                                                                 $this->Common_model->common_update('organizations',$value,$where);
  4814.                                                                 // update meetings count 
  4815.  
  4816.                                                                 // Activity Log Record
  4817.                                                                 $head = 'Create Meeting';
  4818.                                                                 $description = 'New Meeting Has Been Created By ';
  4819.                                                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id),'6');
  4820.                                                                 // Activity Log Record
  4821.                                                                 redirect('meeting-details/'.$meetings_id.'/members');
  4822.                                                         }
  4823.                                                         else
  4824.                                                         {
  4825.                                                                 $_POST['request_status'] = '1';
  4826.                                                                 $this->Common_model->Set_Message('2','<i class=" fas fa-info-circle"></i> Your organization scheduled a meeting at '.$CheckMeeting['date'].' '.$CheckMeeting['time'].' to '.$CheckMeeting['end_time'].'.');
  4827.                                                                 $this->Common_model->Set_Message_meeting('2','<i class=" fas fa-info-circle"></i> Your organization scheduled a meeting at '.$CheckMeeting['date'].' '.$CheckMeeting['time'].' to '.$CheckMeeting['end_time'].'.');
  4828.                                                         }
  4829.                                                 }
  4830.                                                 else
  4831.                                                 {
  4832.                                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Please enter a valid Date & Time.');
  4833.                                                         $this->Common_model->Set_Message_meeting('2','<strong>Error!</strong> Please enter a valid Date & Time.');
  4834.                                                 }
  4835.                                         }
  4836.                                         else
  4837.                                         {
  4838.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Please complete your address.');
  4839.                                                 $this->Common_model->Set_Message_meeting('2','<strong>Error!</strong> Please complete your address.');
  4840.                                         }
  4841.                                 }
  4842.                                 else
  4843.                                 {
  4844.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Your current package is expired. please upgrade to continue to access Meet Pass');
  4845.                                         $this->Common_model->Set_Message_meeting('2','<strong>Error!</strong> Your current package is expired. please upgrade to continue to access Meet Pass');
  4846.                                         redirect(current_url());
  4847.                                 }
  4848.                         }
  4849.                         else
  4850.                         {
  4851.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  4852.                                 $this->Common_model->Set_Message_meeting('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  4853.                         }
  4854.                 }
  4855.         }
  4856.         # Create New Meeting
  4857.  
  4858.  
  4859.         #follow up New Meeting
  4860.         if(isset($_POST['CreateMeetingFollowup']))
  4861.         {
  4862.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  4863.                 $this->form_validation->set_rules('meeting_type','Type','trim|required|xss_clean');
  4864.                 $this->form_validation->set_rules('meeting_title','Title','trim|required|xss_clean');
  4865.                 $this->form_validation->set_rules('date','Date','trim|required|xss_clean|exact_length[10]');
  4866.                 $this->form_validation->set_rules('time','Time','trim|required|xss_clean|exact_length[5]');
  4867.                 $this->form_validation->set_rules('end_time','End Time','trim|required|xss_clean|exact_length[5]');           
  4868.                 $this->form_validation->set_rules('car_pass','Car Pass','trim|required|xss_clean');
  4869.                 $this->form_validation->set_rules('description','Description','trim|xss_clean');
  4870.                 $this->form_validation->set_rules('request_status_Followup','Status','trim|xss_clean');
  4871.                 $this->form_validation->set_rules('meeting_link','Link','trim|xss_clean|valid_url');
  4872.  
  4873.                 if($OD['multiple_locations_status']=='1')
  4874.                 {
  4875.                         $this->form_validation->set_rules('organizations_address_id','Organizations Address ID','trim|required|numeric');
  4876.                 }
  4877.  
  4878.                 if($this->form_validation->run())
  4879.                 {
  4880.                         $meeting_type = $this->input->post('meeting_type');
  4881.                         if(!empty($OD))
  4882.                         {
  4883.                                 if(date('Y-m-d')>$OD['packge_validity_upto'])
  4884.                                 {
  4885.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Your current package is expired. please upgrade to continue to access Meet Pass');
  4886.                                         redirect(current_url());
  4887.                                 }
  4888.  
  4889.                                 if($meeting_type==0) // meeting
  4890.                                 {
  4891.                                         $CountAvailableMeetings = $this->Manage_model->check_available_meetings_count();
  4892.                                 }
  4893.                                 else // event
  4894.                                 {
  4895.                                         $CountAvailableMeetings = $this->Manage_model->check_available_events_count();
  4896.                                 }
  4897.  
  4898.                                 if($CountAvailableMeetings>0)
  4899.                                 {
  4900.  
  4901.                                         $location = $OD['location'];
  4902.                                         $latitude = $OD['latitude'];
  4903.                                         $longitude = $OD['longitude'];
  4904.  
  4905.                                         if($location!='' && $latitude!='' && $longitude!='')
  4906.                                         {
  4907.                                                 $address = array('Building Name: '.$OD['building_name'],'Building Number: '.$OD['building_number'],'Floor Number: '.$OD['floor_number'],'Unit Number: '.$OD['office_number'],'Near Landmark: '.$OD['near_landmark']);
  4908.                                                 $address = implode(', ', $address);
  4909.  
  4910.                                                 $meeting_title = $this->input->post('meeting_title');
  4911.                                                 $date = $this->input->post('date');
  4912.                                                 $time = $this->input->post('time');
  4913.                                                 $end_time = $this->input->post('end_time');
  4914.                                                 //$description = $this->input->post('description');
  4915.                                                 $meeting_link = $this->input->post('meeting_link');
  4916.                                                 $car_pass = $this->input->post('car_pass');
  4917.                                                 $request_status = $this->input->post('request_status_Followup');
  4918.  
  4919.                                                 $date = $this->Common_model->date_format_changer($date);
  4920.                                                 $meeting_datetime = $date.' '.$time.':00';
  4921.                                                 $meeting_end_datetime = $date.' '.$end_time.':00';
  4922.                         $flollow_up_id = $this->input->post('hfmeeting_id');
  4923.                         $flollow_up_status = $this->input->post('flollow_up_status');
  4924.                                                 $datetime = date('Y-m-d H:i:s');
  4925.  
  4926.                                                 $values = array('datetime'=>$datetime,
  4927.                                                                                 'organizations_id'=>$organizations_id,
  4928.                                                                                 'meeting_type'=>$meeting_type,
  4929.                                                                                 'meeting_title'=>$meeting_title,
  4930.                                                                                 'meeting_datetime'=>$meeting_datetime,
  4931.                                                                                 'flollow_up_id'=>$flollow_up_id,
  4932.                                                                                 'flollow_up_status'=>$flollow_up_status,
  4933.                                                                                 'meeting_end_datetime'=>$meeting_end_datetime,
  4934.                                                                                 'location'=>$location,
  4935.                                                                                 'latitude'=>$latitude,
  4936.                                                                                 'longitude'=>$longitude,
  4937.                                                                                 'address'=>$address,                                                                           
  4938.                                                                                 'meeting_link'=>$meeting_link,
  4939.                                                                                 'car_pass'=>$car_pass,
  4940.                                                                                 'admit_before'=>'1',
  4941.                                                                                 'admit_after'=>'2',
  4942.                                                                                 'status'=>'1');
  4943.  
  4944.                                                 // setup address data
  4945.                                                 if($OD['multiple_locations_status']=='1')
  4946.                                                 {
  4947.                                                         $organizations_address_id = $this->input->post('organizations_address_id');
  4948.                                                         if($organizations_address_id=='0') // address take from organization table
  4949.                                                         {
  4950.                                                                 $address = array('Building Name: '.$OD['building_name'],'Building Number: '.$OD['building_number'],'Floor Number: '.$OD['floor_number'],'Unit Number: '.$OD['office_number'],'Near Landmark: '.$OD['near_landmark']);
  4951.                                                                 $address = implode(', ', $address);
  4952.  
  4953.                                                                 $values['organizations_address_id'] = '0';
  4954.                                                                 $values['location'] = $OD['location'];
  4955.                                                                 $values['latitude'] = $OD['latitude'];
  4956.                                                                 $values['longitude'] = $OD['longitude'];
  4957.                                                                 $values['address'] = $address;
  4958.                                                         }
  4959.                                                         elseif($organizations_address_id>'0') // address take from address table
  4960.                                                         {
  4961.                                                                 $AddressData = $this->Manage_model->get_organization_contact_details($organizations_address_id,$organizations_id);
  4962.                                                                 if(!empty($AddressData))
  4963.                                                                 {
  4964.                                                                         $address = array('Building Name: '.$AddressData['building_name'],'Building Number: '.$AddressData['building_number'],'Floor Number: '.$AddressData['floor_number'],'Unit Number: '.$AddressData['office_number'],'Near Landmark: '.$AddressData['near_landmark']);
  4965.                                                                         $address = implode(', ', $address);
  4966.  
  4967.                                                                         $values['organizations_address_id'] = $AddressData['organizations_address_id'];
  4968.                                                                         $values['location'] = $AddressData['location'];
  4969.                                                                         $values['latitude'] = $AddressData['latitude'];
  4970.                                                                         $values['longitude'] = $AddressData['longitude'];
  4971.                                                                         $values['address'] = $address;
  4972.                                                                 }
  4973.                                                         }
  4974.                                                 }
  4975.                                                 // setup address data
  4976.  
  4977.                                                 if($meeting_type==1) // event
  4978.                                                 {
  4979.                                                         $values['participant_status'] = '1';
  4980.                                                 }
  4981.  
  4982.                                                 if($meeting_datetime>$datetime && $meeting_end_datetime>$meeting_datetime)
  4983.                                                 {
  4984.                                                         $CheckMeeting = array();
  4985.                                                         if($request_status!='1')
  4986.                                                         {
  4987.                                                                 $CheckMeeting = $this->Manage_model->check_meetings_available_org($organizations_id,$meeting_datetime,$meeting_end_datetime);
  4988.                                                         }
  4989.  
  4990.             
  4991.                                                         if(empty($CheckMeeting)) // checking meeting scheduled or not
  4992.                                                         {
  4993.                                                                 // checking meeting duplication
  4994.                                                                 $NextTime = date('Y-m-d H:i:s', strtotime('-30 seconds'));
  4995.                                                                 $CheckMeetingDuplication = $this->Manage_model->check_meeting_duplication($organizations_id,$NextTime,$datetime,$meeting_datetime,$meeting_end_datetime);
  4996.                                                                 if(!empty($CheckMeetingDuplication))
  4997.                                                                 {
  4998.                                                                         redirect(current_url());
  4999.                                                                 }
  5000.                                                                 // checking meeting duplication
  5001.  
  5002.                                                                 $meetings_ids = $this->Common_model->common_insert('meetings',$values);
  5003.                                                         $participants=  $this->Manage_model->get_meeting_members($flollow_up_id);
  5004.                                                        
  5005.                                                            foreach($participants as $members)
  5006.                                                            {
  5007.                                                                    $MembersVal=array("meetings_id"=>$meetings_ids,
  5008.                                                                                      "meetings_participants_status"=>0,
  5009.                                                                                      "members_sub_id"=>$members->members_sub_id,
  5010.                                                                                      "member_type"=>$members->member_type,
  5011.                                                                                      "company_id"=>$members->company_id,
  5012.                                                                                      "members_id"=>$members->members_id,
  5013.                                                                                      "car_pass"=>$_POST["car_pass"],
  5014.                                                                                      "car_pass_remark"=>$members->car_pass_remark,
  5015.                                                                                      "laptop_pass"=>0);
  5016.                                                                  $meetings_id = $this->Common_model->common_insert('meetings_participants',$MembersVal); 
  5017.  
  5018.                                                                  
  5019.                                                            }
  5020.                                                       
  5021.                                                                
  5022.                                                                 if($participants->meeting_type==0) // meeting
  5023.                                                                 {
  5024.                                                                         $this->Common_model->Set_Message('1','Follow  meeting created successfully.');
  5025.                                                                 }
  5026.                                                                 else // event
  5027.                                                                 {
  5028.                                                                         $this->Common_model->Set_Message('1','New Event created successfully.');
  5029.                                                                 }
  5030.  
  5031.                                                                 // update meetings count 
  5032.                                                                 if($meeting_type==0) // meeting
  5033.                                                                 {
  5034.                                                                         $value = array('meetings_count'=>$CountAvailableMeetings-1);
  5035.                                                                 }
  5036.                                                                 else // event
  5037.                                                                 {
  5038.                                                                         $value = array('events_count'=>$CountAvailableMeetings-1);
  5039.                                                                 }
  5040.  
  5041.                                                                 $where = array('organizations_id'=>$organizations_id);
  5042.                                                                 $this->Common_model->common_update('organizations',$value,$where);
  5043.                                                                 // update meetings count 
  5044.  
  5045.                                                                 // Activity Log Record
  5046.                                                                 $head = 'Create Meeting';
  5047.                                                                 $description = 'New Meeting Has Been Created By ';
  5048.                                                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id),'6');
  5049.                                                                 // Activity Log Record
  5050.                                                                 redirect('meeting-details/'.$flollow_up_id.'/members');
  5051.                                                         }
  5052.                                                         else
  5053.                                                         { 
  5054.                                                                 // $flollow_up_id = $this->input->post('hfmeeting_id');
  5055.                                                                 // $flollow_up_status = $this->input->post('flollow_up_status');
  5056.                                                                 // $_POST['request_status_Followup'] = '1';
  5057.                                                                 $data['hfmeeting_id'] = $this->input->post('hfmeeting_id');
  5058.                                                                 $_POST['request_status_Followup'] = '1';
  5059.                                                                 $this->Common_model->Set_Message('2','<i class=" fas fa-info-circle"></i> Your organization scheduled a meeting at '.$CheckMeeting['date'].' '.$CheckMeeting['time'].' to '.$CheckMeeting['end_time'].'.');
  5060.                                                                 $this->Common_model->Set_Message_meeting('2','<i class=" fas fa-info-circle"></i> Your organization scheduled a meeting at '.$CheckMeeting['date'].' '.$CheckMeeting['time'].' to '.$CheckMeeting['end_time'].'.');
  5061.                                                         }
  5062.                                                 }
  5063.                                                 else
  5064.                                                 { 
  5065.                                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Please enter a valid Date & Time.');
  5066.                                                         $this->Common_model->Set_Message_meeting('2','<strong>Error!</strong> Please enter a valid Date & Time.');
  5067.                                                 }
  5068.                                         }
  5069.                                         else
  5070.                                         {  
  5071.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Please complete your address.');
  5072.                                                 $this->Common_model->Set_Message_meeting('2','<strong>Error!</strong> Please complete your address.');
  5073.                                         }
  5074.                                 }
  5075.                                 else
  5076.                                 {
  5077.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Your current package is expired. please upgrade to continue to access Meet Pass');
  5078.                                         $this->Common_model->Set_Message_meeting('2','<strong>Error!</strong> Your current package is expired. please upgrade to continue to access Meet Pass');
  5079.                                         redirect(current_url());
  5080.                                 }
  5081.                         }
  5082.                         else
  5083.                         {
  5084.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  5085.                                 $this->Common_model->Set_Message_meeting('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  5086.                         }
  5087.                 }
  5088.         }
  5089.         # Followup  New Meeting
  5090.  
  5091.        
  5092.         # DELETE FUNCTION
  5093.         if(isset($_POST['delete']))
  5094.         {
  5095.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  5096.                 $this->form_validation->set_rules('remark','Remark','trim|xss_clean|required');
  5097.                 if($this->form_validation->run())
  5098.                 {
  5099.                         $meetings_id = $this->input->post('delete_id');
  5100.                         $remark = $this->input->post('remark');
  5101.  
  5102.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  5103.                         if(empty($MD)){ redirect('view-meetings'); }
  5104.  
  5105.                         $datetime = date('Y-m-d H:i:s');
  5106.                         if($MD['meeting_datetime']>$datetime)
  5107.                         {
  5108.                                 $value = array('status'=>'2','meeting_cancelled_remarks'=>$remark);
  5109.                                 $where = array('meetings_id'=>$meetings_id);
  5110.                                 $this->Common_model->common_update('meetings',$value,$where);
  5111.                                 $this->Common_model->Set_Message('1','Meeting cancelled.');
  5112.  
  5113.                                 $MeetingMembersList = $this->Manage_model->get_meeting_members($meetings_id);
  5114.                                 foreach($MeetingMembersList as $DT1)
  5115.                                 {
  5116.                                         $members_id = $DT1->members_id;
  5117.                                         $status = $DT1->status;
  5118.                                         if($status==0)
  5119.                                         {
  5120.                                                 // sent notification
  5121.                                                 if($MD['meeting_type']=='0')
  5122.                                                 {
  5123.                                                         $Content = array('title'=>'Meeting Cancelled','description'=>'Unfortunately, the scheduled meeting has been cancelled due to some reason.','message'=>'','meetings_id'=>$meetings_id);
  5124.                                                 }
  5125.                                                 else
  5126.                                                 {
  5127.                                                         $Content = array('title'=>'Event Cancelled','description'=>'Unfortunately, the scheduled event has been cancelled due to some reason.','message'=>'','meetings_id'=>$meetings_id);
  5128.                                                 }
  5129.                                                 $this->SentNotification('4',$members_id,$Content);
  5130.                                                 // sent notification
  5131.                                         }
  5132.                                 }
  5133.  
  5134.                                 // Activity Log Record
  5135.                                 $head = 'Cancel Meeting';
  5136.                                 $description = 'Meeting Has Been Canceled By ';
  5137.                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id),'6');
  5138.                                 // Activity Log Record
  5139.                         }
  5140.                         else
  5141.                         {
  5142.                                 $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  5143.                         }
  5144.                 }
  5145.                 else
  5146.                 {
  5147.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  5148.                 }
  5149.                 redirect(current_url());
  5150.         }
  5151.         # END OF DELETE FUNCTION
  5152.  
  5153.         # FILTER AND PAGINATION SECTION
  5154.         $URL = $this->uri->segment(1);
  5155.         $param[] = array('key'=>'meeting_title','default'=>'');
  5156.         $param[] = array('key'=>'meeting_date','default'=>'');
  5157.         $param[] = array('key'=>'company_id','default'=>'');
  5158.         $FD = $this->Common_model->common_filter($URL,$param);
  5159.  
  5160.         $FD['MeetingStatus'] = $MeetingStatus;
  5161.  
  5162.         $start = $limit = '';
  5163.         $page_ary['url'] = base_url($URL);
  5164.  
  5165.         $page_ary['total_rows'] = $this->Manage_model->view_meetings_count($FD,$start,$limit,'1');
  5166.         $limit = $page_ary['per_page'] = 30;
  5167.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  5168.         $data['page'] = $start = $PGN_DATA['page'];
  5169.         $data['links'] = $PGN_DATA['links'];
  5170.         # END OF FILTER AND PAGINATION SECTION
  5171.  
  5172.         $data['FD'] = $FD;
  5173.         $data['MD'] = $this->Manage_model->view_meetings($FD,$start,$limit,'0');
  5174.         $data['CL'] = $this->Manage_model->view_company_list();
  5175.  
  5176.         $this->CommonPage('meetings/view_meetings',$data,'List of meetings');
  5177. }
  5178. ############################################ END OF MEETINGS ######################################
  5179.  
  5180. ############################################ CAR PASS REQUESTS ####################################
  5181. public function car_pass_requests()
  5182. {
  5183.         # FILTER AND PAGINATION SECTION
  5184.         $URL = $this->uri->segment(1);
  5185.         $start = $limit = '';
  5186.         $page_ary['url'] = base_url($URL);
  5187.  
  5188.         $page_ary['total_rows'] = $this->Manage_model->view_car_pass_requests($start,$limit,'1')[0]->count;
  5189.         $limit = $page_ary['per_page'] = 30;
  5190.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  5191.         $data['page'] = $start = $PGN_DATA['page'];
  5192.         $data['links'] = $PGN_DATA['links'];
  5193.         # END OF FILTER AND PAGINATION SECTION
  5194.  
  5195.         $data['CPRD'] = $this->Manage_model->view_car_pass_requests($start,$limit,'0');
  5196.         $this->CommonPage('meetings/car_pass_requests',$data,'Car pass requests');
  5197. }
  5198. ############################################ END OF CAR PASS REQUESTS #############################
  5199.  
  5200. ############################################ CHECKING MEMBER DETAILS ##############################
  5201. public function CheckingMemberDetails($ReqData)
  5202. {
  5203.         $DateTime = date('Y-m-d H:i:s');
  5204.         $country_id = $ReqData['country_id'];
  5205.         $member_mobile = $ReqData['member_mobile'];
  5206.         $member_name = $ReqData['member_name'];
  5207.         $organizations_id = $ReqData['organizations_id'];
  5208.         $company_id = $ReqData['company_id'];
  5209.         $email_id = $ReqData['email_id'];
  5210.  
  5211.         $CheckTblMember = $this->Manage_model->check_member_is_exist($country_id,$member_mobile);
  5212.         if(!empty($CheckTblMember))
  5213.         {
  5214.                 $members_id = $CheckTblMember['members_id'];
  5215.                 if($CheckTblMember['members_status']!=0)
  5216.                 {
  5217.                         $M_where = array('members_id'=>$members_id);
  5218.                         $M_value = array('members_status'=>'0');
  5219.                         $this->Common_model->common_update('members',$M_value,$M_where); // update status when the member is deleted
  5220.                 }
  5221.         }
  5222.         else
  5223.         {
  5224.                 $values = array('datetime'=>$DateTime,'country_id'=>$country_id,'name'=>ucwords($member_name),'phone'=>$member_mobile,'email'=>strtolower($email_id));
  5225.                 $members_id = $this->Common_model->common_insert('members',$values);
  5226.         }
  5227.         // checking table members
  5228.  
  5229.         $values = array('company_members_status'=>'0',
  5230.                                         'organizations_id'=>$organizations_id,
  5231.                                         'company_id'=>$company_id,
  5232.                                         'members_id'=>$members_id,
  5233.                                         'name'=>ucwords($member_name),
  5234.                                         'email'=>strtolower($email_id));
  5235.  
  5236.         // checking table company_members
  5237.         $CheckTblCompanyMember = $this->Manage_model->company_members_exist($company_id,$members_id,$organizations_id);
  5238.         if(empty($CheckTblCompanyMember))
  5239.         {
  5240.                 $values['datetime'] = $DateTime;
  5241.                 $members_sub_id = $this->Common_model->common_insert('company_members',$values);
  5242.  
  5243.                 // Activity Log Record
  5244.                 $head = 'Add Member';
  5245.                 $description = 'Member Details Has Been Added By ';
  5246.                 $this->Common_model->create_activity_log($head,$description,'',array(),array('members_id'=>$members_id),'4');
  5247.                 // Activity Log Record
  5248.         }
  5249.         else
  5250.         {
  5251.                 if($email_id!='')
  5252.                 {
  5253.                         $C_where = array('company_members_id'=>$CheckTblCompanyMember['company_members_id']);
  5254.                         $C_value = array('email'=>strtolower($email_id));
  5255.                         $this->Common_model->common_update('company_members',$C_value,$C_where); // update email when the email is not empty
  5256.                 }
  5257.  
  5258.                 $members_sub_id = $CheckTblCompanyMember['company_members_id'];
  5259.         }
  5260.  
  5261.         $ResultArray = array('members_id'=>$members_id,'members_sub_id'=>$members_sub_id);
  5262.         return $ResultArray;
  5263. }
  5264. ############################################ END OF CHECKING MEMBER DETAILS #######################
  5265.  
  5266. ############################################ NOTIFICATIONS ########################################
  5267. public function SentNotification($type,$members_id,$Content,$members_sub_id='',$member_type='')
  5268. {
  5269.         // member_type: 0- organization member, 1- company member
  5270.  
  5271.         $MD = $this->Manage_model->view_memeber_details($members_id);
  5272.         if(!empty($MD))
  5273.         {
  5274.                 // insert to notification table
  5275.                 $values = array('datetime'=>date('Y-m-d H;i:s'),
  5276.                                                 'members_id'=>$members_id,
  5277.                                                 'meetings_id'=>$Content['meetings_id'],
  5278.                                                 'title'=>$Content['title'],
  5279.                                                 'description'=>$Content['description'],
  5280.                                                 'status'=>'1');
  5281.                 $this->Common_model->common_insert('notifications',$values);
  5282.                 // insert to notification table
  5283.  
  5284.                 $meetings_id = $Content['meetings_id'];
  5285.  
  5286.                 if($type=='1') // assigned to meeting
  5287.                 {
  5288.                         // Push Notification / SMS
  5289.                         if($MD['fcm_token']!='')
  5290.                         {
  5291.                                 $this->Common_model->SentPushNotification($MD['fcm_token'],'meeting',$meetings_id,$Content['title'],$Content['description']);
  5292.                         }
  5293.                         else // Sent SMS
  5294.                         {
  5295.                                 $MD['country_code'] = str_replace('+', '', $MD['country_code']);
  5296.                                 $this->Common_model->SentSMS($MD['country_code'].$MD['phone'],$Content['message'],$MD['country_code']);
  5297.                         }
  5298.                         // Push Notification / SMS
  5299.  
  5300.                         // sent Email
  5301.                         $MDE = array();
  5302.                         if($member_type==0 && $members_sub_id!='')
  5303.                         {
  5304.                                 $MDE = $this->Manage_model->get_organization_member_name_designation($members_sub_id)['email'];
  5305.                         }
  5306.                         elseif($member_type==1 && $members_sub_id!='')
  5307.                         {
  5308.                                 $MDE = $this->Manage_model->get_company_member_name_designation($members_sub_id)['email'];
  5309.                         }
  5310.  
  5311.                         if($MDE!='')
  5312.                         {
  5313.                                 $data = array('MemberName'=>$MD['name'],'TicketNumber'=>$Content['TicketNumber'],'Organization'=>$Content['Organization'],'MeetingTitle'=>$Content['MeetingTitle']);
  5314.                                 $this->SentMail('1',$MDE,$data);
  5315.                         }
  5316.                         elseif($MD['email']!='')
  5317.                         {
  5318.                                 $data = array('MemberName'=>$MD['name'],'TicketNumber'=>$Content['TicketNumber'],'Organization'=>$Content['Organization'],'MeetingTitle'=>$Content['MeetingTitle']);
  5319.                                 $this->SentMail('1',$MD['email'],$data);
  5320.                         }
  5321.                         // sent Email
  5322.                 }
  5323.                 elseif($type=='2' && $MD['fcm_token']!='') // Car Pass
  5324.                 {
  5325.                         $this->Common_model->SentPushNotification($MD['fcm_token'],'meeting',$meetings_id,$Content['title'],$Content['description']);
  5326.                 }
  5327.                 elseif($type=='3' && $MD['fcm_token']!='') // Laptop Pass
  5328.                 {
  5329.                         $this->Common_model->SentPushNotification($MD['fcm_token'],'meeting',$meetings_id,$Content['title'],$Content['description']);
  5330.                 }
  5331.                 elseif($type=='4' && $MD['fcm_token']!='') // Remove From Meeting
  5332.                 {
  5333.                         $this->Common_model->SentPushNotification($MD['fcm_token'],'meeting',$meetings_id,$Content['title'],$Content['description']);
  5334.                 }
  5335.                 elseif($type=='5' && $MD['fcm_token']!='') // reschedule From Meeting
  5336.                 {
  5337.                         $this->Common_model->SentPushNotification($MD['fcm_token'],'meeting',$meetings_id,$Content['title'],$Content['description']);
  5338.                 }
  5339.                 elseif($type=='6' && $MD['fcm_token']!='') // mom signature request
  5340.                 {
  5341.                         $this->Common_model->SentPushNotification($MD['fcm_token'],'meeting',$meetings_id,$Content['title'],$Content['description']);
  5342.                 }
  5343.         }
  5344.         return true;
  5345. }
  5346. ############################################ END OF NOTIFICATIONS #################################
  5347.  
  5348. ############################################ SENT MAIL ############################################
  5349. public function SentMail($type,$to,$data = array())
  5350. {
  5351.         $this->load->library('email');
  5352.         $this->email->clear(TRUE);
  5353.  
  5354.         if($type=='1') // assigned to meeting
  5355.         {
  5356.                 $message = $this->load->view('email_templates/meeting_invitation', $data, true);
  5357.                 $subject = $data['MeetingTitle'].' - '.$data['Organization'];
  5358.         }
  5359.         elseif($type=='6') // approve org
  5360.         {
  5361.                 $message = $this->load->view('email_templates/login_credentials', $data, true);
  5362.                 $subject = 'LOGIN CREDENTIALS';
  5363.         }
  5364.         elseif($type=='7') // free trial started
  5365.         {
  5366.                 $message = $this->load->view('email_templates/free_trial', '', true);
  5367.                 $subject = 'FREE TRIAL';
  5368.         }
  5369.         elseif($type=='8') // password-change
  5370.         {
  5371.                 $message = $this->load->view('email_templates/password_change', '', true);
  5372.                 $subject = 'PASSWORD CHANGED SUCCESSFULLY';
  5373.         }
  5374.         elseif($type=='9') // password-change
  5375.         {
  5376.                 $message = $this->load->view('email_templates/thank_you_for_subscribing', '', true);
  5377.                 $subject = 'FOR YOUR SMART MEETINGS';
  5378.         }
  5379.         elseif($type=='10') // support ticket email to user
  5380.         {
  5381.                 $message = $this->load->view('email_templates/meetpass_support', $data, true);
  5382.                 $subject = $data['Subject'];
  5383.         }
  5384.         elseif($type=='11') // payment receipt
  5385.         {
  5386.                 $message = $this->load->view('email_templates/payment_receipt', $data, true);
  5387.                 $subject = $data['Subject'];
  5388.         }
  5389.         elseif($type=='12') // sent mom notification with attachment
  5390.         {
  5391.                 $message = $this->load->view('email_templates/mom_update', $data, true);
  5392.                 $subject = $data['Subject'];
  5393.  
  5394.                 if(isset($data['File']) && $data['File']!='')
  5395.                 {
  5396.                         $this->email->attach($data['File']);
  5397.                 }
  5398.         }
  5399.  
  5400.         $this->email->from('no-reply@meetpass.com', 'MEET PASS');
  5401.         $this->email->to($to);
  5402.         $this->email->subject($subject);
  5403.         $this->email->message($message);
  5404.         $this->email->send();
  5405.  
  5406.         return true;
  5407. }
  5408. ############################################ END OF SENT MAIL #####################################
  5409.  
  5410. ############################################ EMAIL TEMPLATES ######################################
  5411. public function email_templates($link='')
  5412. {
  5413.         if($this->session->userdata('logged_in')['privilege_id']!=4)
  5414.         {
  5415.                 if($link=='')
  5416.                 {
  5417.                         ?>
  5418.                         #. <a href="<?php echo base_url('email-templates/blank-template'); ?>">blank-template</a><br>
  5419.                         #. <a href="<?php echo base_url('email-templates/successfull-registration'); ?>">successfull-registration</a><br>
  5420.                         #. <a href="<?php echo base_url('email-templates/demo-request'); ?>">demo-request</a><br>
  5421.                         #. <a href="<?php echo base_url('email-templates/enterprise-enquiry'); ?>">enterprise-enquiry</a><br>
  5422.                         #. <a href="<?php echo base_url('email-templates/enquiry'); ?>">enquiry</a><br>
  5423.                         #. <a href="<?php echo base_url('email-templates/login-credentials'); ?>">login-credentials</a><br>
  5424.                         #. <a href="<?php echo base_url('email-templates/password-change'); ?>">password-change</a><br>
  5425.                         #. <a href="<?php echo base_url('email-templates/free-trial'); ?>">free-trial</a><br>
  5426.                         #. <a href="<?php echo base_url('email-templates/did-you-know'); ?>">did-you-know</a><br>
  5427.                         <!-- #. <a href="<?php echo base_url('email-templates/pricing'); ?>">pricing</a><br> -->
  5428.                         #. <a href="<?php echo base_url('email-templates/what-client-says'); ?>">what-client-says</a><br>
  5429.                         #. <a href="<?php echo base_url('email-templates/trial-expiry-reminder-1'); ?>">trial-expiry-reminder-1</a><br>
  5430.                         #. <a href="<?php echo base_url('email-templates/trial-expiry-reminder-2'); ?>">trial-expiry-reminder-2</a><br>
  5431.                         #. <a href="<?php echo base_url('email-templates/trial-expiry-reminder-3'); ?>">trial-expiry-reminder-3</a><br>
  5432.                         <!-- #. <a href="<?php echo base_url('email-templates/faq'); ?>">faq</a><br> -->
  5433.                         #. <a href="<?php echo base_url('email-templates/feedback'); ?>">feedback</a><br>
  5434.                         #. <a href="<?php echo base_url('email-templates/password-reset'); ?>">password-reset</a><br>
  5435.                         #. <a href="<?php echo base_url('email-templates/thank-you-for-subscribing'); ?>">thank-you-for-subscribing</a><br>
  5436.                         <!-- #. <a href="<?php echo base_url('email-templates/welcome-package-details'); ?>">welcome-package-details</a><br> -->
  5437.                         <!-- #. <a href="<?php echo base_url('email-templates/renewal-mail-with-bill'); ?>">renewal-mail-with-bill</a><br> -->
  5438.                         #. <a href="<?php echo base_url('email-templates/failled-payment-notification'); ?>">failled-payment-notification</a><br>
  5439.                         #. <a href="<?php echo base_url('email-templates/failled-payment-notification-reminder'); ?>">failled-payment-notification-reminder</a><br>
  5440.                         #. <a href="<?php echo base_url('email-templates/subscription-expired-notification'); ?>">subscription-expired-notification</a><br>
  5441.                         #. <a href="<?php echo base_url('email-templates/meeting-invitation'); ?>">meeting-invitation</a><br>
  5442.                         #. <a href="<?php echo base_url('email-templates/welcome-to-meetpass'); ?>">welcome-to-meetpass</a><br>
  5443.                         #. <a href="<?php echo base_url('email-templates/meetpass-support'); ?>">meetpass-support</a><br>
  5444.                         #. <a href="<?php echo base_url('email-templates/payment-receipt'); ?>">payment-receipt</a><br>
  5445.                         #. <a href="<?php echo base_url('email-templates/website-reminder'); ?>">website-reminder</a><br>
  5446.                         #. <a href="<?php echo base_url('email-templates/mom-update'); ?>">mom-update</a><br>
  5447.                         <?php
  5448.                 }
  5449.                 else
  5450.                 {
  5451.                         $link = str_replace('-','_',$link);
  5452.                         echo $message = $this->load->view('email_templates/'.$link, '', true);
  5453.                 }
  5454.         }
  5455.         else
  5456.         {
  5457.                 redirect('dashboard');
  5458.         }
  5459. }
  5460. ############################################ END OF EMAIL TEMPLATES ###############################
  5461.  
  5462. ############################################ MANAGE PACKAGES ######################################
  5463. public function get_package_data()
  5464. {
  5465.         $Data['response'] = 'failed';
  5466.         $Data['result'] = array();
  5467.  
  5468.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  5469.         if($this->form_validation->run())
  5470.         {
  5471.                 $subscription_packages_id = $this->input->post('data_id');
  5472.                 $Result = $this->Manage_model->get_package_details($subscription_packages_id);
  5473.                 if(!empty($Result))
  5474.                 {
  5475.                         $Data['response'] = 'success';
  5476.                         $Data['result'] = $Result;
  5477.                 }
  5478.         }
  5479.         echo json_encode($Data);
  5480. }
  5481.  
  5482. public function manage_packages()
  5483. {
  5484.         # INSERT / UPDATE FUNCTION
  5485.         if(isset($_POST['submit']))
  5486.         {
  5487.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  5488.                 $this->form_validation->set_rules('country_id','Country','trim|required|xss_clean|numeric');
  5489.                 $this->form_validation->set_rules('package_category','Package Category','trim|required|xss_clean|numeric');
  5490.                 $this->form_validation->set_rules('package_type','Package Type','trim|required|xss_clean|numeric');
  5491.                 $this->form_validation->set_rules('package_name','Package Name','trim|required|xss_clean');
  5492.                 $this->form_validation->set_rules('price','price','trim|required|xss_clean');
  5493.                 $this->form_validation->set_rules('dummy_price','dummy price','trim|required|xss_clean');
  5494.                 $this->form_validation->set_rules('days','days','trim|required|xss_clean|numeric');
  5495.                 $this->form_validation->set_rules('yearly_renewal_discount','Yearly Renewal Discount','trim|required|xss_clean|numeric');
  5496.                 $this->form_validation->set_rules('meetings_count','Meetings Count','trim|required|xss_clean|numeric');
  5497.                 $this->form_validation->set_rules('meeting_members_count','Meetings Members Count','trim|required|xss_clean|numeric');
  5498.                 $this->form_validation->set_rules('event_count','Events Count','trim|required|xss_clean|numeric');
  5499.                 $this->form_validation->set_rules('event_members_count','Events Members Count','trim|required|xss_clean|numeric');
  5500.                 $this->form_validation->set_rules('link_generation_status','Link Generation Status','trim|required|xss_clean|numeric');
  5501.                 $this->form_validation->set_rules('app_create_meeting_status','App Create Meeting Status','trim|required|xss_clean|numeric');
  5502.                 $this->form_validation->set_rules('package_status','Package Status','trim|required|xss_clean|numeric');
  5503.                 $this->form_validation->set_rules('view_order','View Order','trim|required|xss_clean|numeric');
  5504.  
  5505.                 if($this->input->post('submit')=='Save')
  5506.                 {
  5507.                         $this->form_validation->set_rules('subscription_packages_id','Subscription Package ID','trim|xss_clean');
  5508.                 }
  5509.                 else
  5510.                 {
  5511.                         $this->form_validation->set_rules('subscription_packages_id','Subscription Package ID','trim|xss_clean|numeric|required');
  5512.                 }
  5513.  
  5514.                 if($this->form_validation->run())
  5515.                 {
  5516.                         $country_id = $this->input->post('country_id');
  5517.                         $package_category = $this->input->post('package_category');
  5518.                         $package_type = $this->input->post('package_type');
  5519.                         $package_name = $this->input->post('package_name');
  5520.                         $price = $this->input->post('price');
  5521.                         $dummy_price = $this->input->post('dummy_price');
  5522.                         $days = $this->input->post('days');
  5523.                         $yearly_renewal_discount = $this->input->post('yearly_renewal_discount');
  5524.                         $meetings_count = $this->input->post('meetings_count');
  5525.                         $meeting_members_count = $this->input->post('meeting_members_count');
  5526.                         $event_count = $this->input->post('event_count');
  5527.                         $event_members_count = $this->input->post('event_members_count');
  5528.                         $link_generation_status = $this->input->post('link_generation_status');
  5529.                         $app_create_meeting_status = $this->input->post('app_create_meeting_status');
  5530.                         $multiple_locations_status = $this->input->post('multiple_locations_status');
  5531.                         $package_status = $this->input->post('package_status');
  5532.                         $view_order = $this->input->post('view_order');
  5533.                         $subscription_packages_id = $this->input->post('subscription_packages_id');
  5534.                         $submit = $this->input->post('submit');
  5535.  
  5536.                         if($package_type==0)
  5537.                         {
  5538.                                 $days = '30';
  5539.                         }
  5540.                         else
  5541.                         {
  5542.                                 $yearly_renewal_discount = '0';
  5543.                                 $link_generation_status = '0';
  5544.                                 $app_create_meeting_status = '0';
  5545.                                 $multiple_locations_status = '0';
  5546.                         }
  5547.  
  5548.                         $values = array('datetime'=>date('Y-m-d H:i:s'),
  5549.                                                         'package_type'=>$package_type,
  5550.                                                         'package_category'=>$package_category,
  5551.                                                         'country_id'=>$country_id,
  5552.                                                         'package_name'=>$package_name,
  5553.                                                         'price'=>$price,
  5554.                                                         'dummy_price'=>$dummy_price,
  5555.                                                         'yearly_renewal_discount'=>$yearly_renewal_discount,
  5556.                                                         'days'=>$days,
  5557.                                                         'meetings_count'=>$meetings_count,
  5558.                                                         'meeting_members_count'=>$meeting_members_count,
  5559.                                                         'event_count'=>$event_count,
  5560.                                                         'event_members_count'=>$event_members_count,
  5561.                                                         'link_generation_status'=>$link_generation_status,
  5562.                                                         'app_create_meeting_status'=>$app_create_meeting_status,
  5563.                                                         'multiple_locations_status'=>$multiple_locations_status,
  5564.                                                         'status'=>$package_status,
  5565.                                                         'view_order'=>$view_order);
  5566.  
  5567.                         $CountryData = $this->Manage_model->get_country_details_row($country_id);
  5568.  
  5569.                         if($submit=='Save')
  5570.                         {
  5571.                                 // insert stripe api
  5572.                                 require_once APPPATH."third_party/stripe-php/init.php";
  5573.                                 $stripe = new \Stripe\StripeClient($this->config->item('StripeSecretKey'));
  5574.  
  5575.                                 $product = $stripe->products->create(['name'=>$package_name]); // create a product
  5576.  
  5577.                                 if(!empty($product) && isset($product->id) && $product->id!='')
  5578.                                 {
  5579.                                         // creating stripe subscription
  5580.                                         $price = $price*$CountryData['rates'];
  5581.                                         $subscription = $stripe->prices->create(['unit_amount' => $price*100,
  5582.                                                                                                                         'currency' => $CountryData['currency'],
  5583.                                                                                                                         'recurring' => ['interval' => 'month','interval_count'=>'1'],
  5584.                                                                                                                         'product' => $product->id]);
  5585.  
  5586.                                         if(!empty($subscription) && isset($subscription->id) && $subscription->id!='')
  5587.                                         {
  5588.                                                 $values['stripe_subscription_id'] = $subscription->id;        // adding stripe token keys
  5589.                                                 $values['stripe_product_id'] = $product->id;                  // adding stripe token keys
  5590.  
  5591.                                                 $subscription_packages_id = $this->Common_model->common_insert('subscription_packages',$values);
  5592.                                                 $this->Common_model->Set_Message('1',"Package details added successfully");
  5593.  
  5594.                                                 // Activity Log Record
  5595.                                                 $head = 'Add Package';
  5596.                                                 $description = 'Package Details Has Been Added By ';
  5597.                                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('subscription_packages_id'=>$subscription_packages_id),'8');
  5598.                                                 // Activity Log Record
  5599.                                         }
  5600.                                         else
  5601.                                         {
  5602.                                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  5603.                                                 redirect(current_url());
  5604.                                         }
  5605.                                 }
  5606.                                 else
  5607.                                 {
  5608.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  5609.                                         redirect(current_url());
  5610.                                 }
  5611.                         }
  5612.                         else
  5613.                         {
  5614.                                 /*$CheckingPackageUsed = $this->Manage_model->checking_package_is_used_or_not($subscription_packages_id);
  5615.                                 if(empty($CheckingPackageUsed))
  5616.                                 {
  5617.                                         unset($values['datetime']); // unset datetime 
  5618.  
  5619.                                         $where = array('subscription_packages_id'=>$subscription_packages_id);
  5620.                                         $this->Common_model->common_update('subscription_packages',$values,$where);
  5621.                                         $this->Common_model->Set_Message('1',"Package details updated successfully");
  5622.  
  5623.                                         // Activity Log Record
  5624.                                         $head = 'Update Package';
  5625.                                         $description = 'Package Details Has Been Updated By ';
  5626.                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('subscription_packages_id'=>$subscription_packages_id),'5');
  5627.                                         // Activity Log Record
  5628.                                 }
  5629.                                 else
  5630.                                 {
  5631.                                         $values = array('status'=>$package_status);
  5632.                                         $where = array('subscription_packages_id'=>$subscription_packages_id);
  5633.                                         $this->Common_model->common_update('subscription_packages',$values,$where);
  5634.  
  5635.                                         $this->Common_model->Set_Message('2',"<strong>Error!</strong> Consumed package cannot be edited.");
  5636.                                         redirect(current_url());
  5637.                                 }*/
  5638.  
  5639.                                 $this->Common_model->Set_Message('2',"<strong>Error!</strong> Consumed package cannot be edited.");
  5640.                         }
  5641.                         redirect(current_url());
  5642.                 }
  5643.                 else
  5644.                 {
  5645.                         if($this->input->post('submit')=='Update')
  5646.                         {
  5647.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  5648.                                 redirect(current_url());
  5649.                         }
  5650.                 }
  5651.         }
  5652.         # END OF INSERT / UPDATE FUNCTION
  5653.  
  5654.         # DELETE FUNCTION
  5655.         if(isset($_POST['delete']))
  5656.         {
  5657.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  5658.                 if($this->form_validation->run())
  5659.                 {
  5660.                         $delete_id = $this->input->post('delete_id');
  5661.                         $CheckingPackageUsed = $this->Manage_model->checking_package_is_used_or_not($delete_id);
  5662.                         if(empty($CheckingPackageUsed))
  5663.                         {
  5664.                                 $where = array('subscription_packages_id'=>$delete_id);
  5665.                                 $value = array('subscription_packages_status'=>'1');
  5666.                                 $this->Common_model->common_update('subscription_packages',$value,$where);
  5667.                                 $this->Common_model->Set_Message('1','Package Removed Successfully');
  5668.  
  5669.                                 // Activity Log Record
  5670.                                 $head = 'Remove Package';
  5671.                                 $description = 'Package Has Been Removed By ';
  5672.                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('subscription_packages_id'=>$delete_id),'8');
  5673.                                 // Activity Log Record
  5674.                         }
  5675.                         else
  5676.                         {
  5677.                                 $this->Common_model->Set_Message('2',"<strong>Error!</strong> Consumed package cannot be removed.");
  5678.                                 redirect(current_url());
  5679.                         }
  5680.                 }
  5681.                 else
  5682.                 {
  5683.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  5684.                 }
  5685.                 redirect(current_url());
  5686.         }
  5687.         # END OF DELETE FUNCTION
  5688.  
  5689.         # FILTER AND PAGINATION SECTION
  5690.         $FD = array();
  5691.  
  5692.         if($this->session->userdata('logged_in')['privilege_id']==6)
  5693.         {
  5694.                 $FD['country_id'] = $this->session->userdata('logged_in')['table_id']; // for country admin only
  5695.         }
  5696.  
  5697.         $URL = $this->uri->segment(1);
  5698.         $start = $limit = '';
  5699.         $page_ary['url'] = base_url($URL);
  5700.         $page_ary['total_rows'] = $this->Manage_model->view_packages_admin($FD,$start,$limit,'1')[0]->count;
  5701.         $limit = $page_ary['per_page'] = 30;
  5702.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  5703.         $data['page'] = $start = $PGN_DATA['page'];
  5704.         $data['links'] = $PGN_DATA['links'];
  5705.         # END OF FILTER AND PAGINATION SECTION
  5706.  
  5707.         $data['CountryData'] = $this->Manage_model->select_view_country_org();
  5708.         $data['PD'] = $this->Manage_model->view_packages_admin($FD,$start,$limit,'0');
  5709.  
  5710.         $this->CommonPage('organizations/manage_packages',$data,'View Packages');
  5711. }
  5712. ############################################ END OF MANAGE PACKAGES ###############################
  5713.  
  5714. ############################################ DEDICATED PACKAGES ###################################
  5715. public function dedicated_packages()
  5716. {
  5717.         # FILTER AND PAGINATION SECTION
  5718.         $URL = $this->uri->segment(1);
  5719.  
  5720.         $param[] = array('key'=>'organizations_id','default'=>'');
  5721.         $param[] = array('key'=>'subscription_packages_id','default'=>'');
  5722.         $FD = $this->Common_model->common_filter($URL,$param);
  5723.  
  5724.         $start = $limit = '';
  5725.         $page_ary['url'] = base_url($URL);
  5726.         $page_ary['total_rows'] = $this->Manage_model->view_dedicated_packages_admin($FD,$start,$limit,'1')[0]->count;
  5727.         $limit = $page_ary['per_page'] = 30;
  5728.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  5729.         $data['page'] = $start = $PGN_DATA['page'];
  5730.         $data['links'] = $PGN_DATA['links'];
  5731.         # END OF FILTER AND PAGINATION SECTION
  5732.  
  5733.         $data['PackageData'] = $this->Manage_model->organizations_dedicated_packages_list();
  5734.         $data['OrgData'] = $this->Manage_model->dedicated_packages_organizations_list();
  5735.         $data['PD'] = $this->Manage_model->view_dedicated_packages_admin($FD,$start,$limit,'0');
  5736.         $data['FD'] = $FD;
  5737.  
  5738.         $this->CommonPage('organizations/dedicated_packages',$data,'View Dedicated Packages');
  5739. }
  5740. ############################################ END OF DEDICATED PACKAGES ############################
  5741.  
  5742. ############################################ VIEW PACKAGES HISTORY ################################
  5743. public function view_packages_details()
  5744. {
  5745.         $Data['response'] = 'failed';
  5746.         $Data['result'] = array();
  5747.  
  5748.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  5749.         if($this->form_validation->run())
  5750.         {
  5751.                 $package_subscriptions_id = $this->input->post('data_id');
  5752.                 $Result = $this->Manage_model->get_package_payment_details($package_subscriptions_id);
  5753.                 if(!empty($Result))
  5754.                 {
  5755.                         $Result['package_payments_id'] = 'MPY'.sprintf("%05d", $Result['package_payments_id']);
  5756.  
  5757.                         $Month = $Result['days']/30;
  5758.                         if($Month%1==0){ $Result['days'] = $Month.' Month'; }
  5759.  
  5760.                         $Data['response'] = 'success';
  5761.                         $Data['result'] = $Result;
  5762.                 }
  5763.         }
  5764.         echo json_encode($Data);
  5765. }
  5766.  
  5767. public function view_packages_details_admin()
  5768. {
  5769.         $Data['response'] = 'failed';
  5770.         $Data['result'] = array();
  5771.  
  5772.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  5773.         if($this->form_validation->run())
  5774.         {
  5775.                 $package_subscriptions_id = $this->input->post('data_id');
  5776.                 $Result = $this->Manage_model->get_package_payment_details_admin($package_subscriptions_id);
  5777.                 if(!empty($Result))
  5778.                 {
  5779.                         $Result['package_payments_id'] = 'MPY'.sprintf("%05d", $Result['package_payments_id']);
  5780.  
  5781.                         $Month = $Result['days']/30;
  5782.                         if($Month%1==0){ $Result['days'] = $Month.' Month'; }
  5783.  
  5784.                         $Data['response'] = 'success';
  5785.                         $Data['result'] = $Result;
  5786.                 }
  5787.         }
  5788.         echo json_encode($Data);
  5789. }
  5790.  
  5791. public function packages_history()
  5792. {
  5793.         # FILTER AND PAGINATION SECTION
  5794.         $FD = array();
  5795.         $URL = $this->uri->segment(1);
  5796.         $start = $limit = '';
  5797.         $page_ary['url'] = base_url($URL);
  5798.         $page_ary['total_rows'] = $this->Manage_model->packages_history($FD,$start,$limit,'1')[0]->count;
  5799.         $limit = $page_ary['per_page'] = 30;
  5800.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  5801.         $data['page'] = $start = $PGN_DATA['page'];
  5802.         $data['links'] = $PGN_DATA['links'];
  5803.         # END OF FILTER AND PAGINATION SECTION
  5804.  
  5805.         $data['CountryData'] = $this->Manage_model->get_organization_country_details();
  5806.         $data['PD'] = $this->Manage_model->packages_history($FD,$start,$limit,'0');
  5807.  
  5808.         $this->CommonPage('organizations/packages_history',$data,'View Packages History');
  5809. }
  5810. ############################################ END OF VIEW PACKAGES HISTORY #########################
  5811.  
  5812. ############################################ PRINT INVOICE ########################################
  5813. public function invoice_print($package_subscriptions_id)
  5814. {
  5815.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  5816.         if($this->form_validation->run())
  5817.         {
  5818.                 #### REMOVE OLDER PDFS ####
  5819.                 $FIL_PATH = FCPATH.'uploads/pdf/*';
  5820.                 $TL_FILS = glob($FIL_PATH);
  5821.                 $STRT_TIM = strtotime(date('Y-m-d H:i'));
  5822.                 $END_TIME = date('Y-m-d H:i', strtotime('-30 minutes',$STRT_TIM));
  5823.                 foreach($TL_FILS as $NFILES)
  5824.                 {
  5825.                         if(is_file($NFILES))
  5826.                         {
  5827.                                 $FIL_TIME = date("Y-m-d H:i", filectime($NFILES));
  5828.                                 if($FIL_TIME<$END_TIME){unlink($NFILES);} // Remove files before 30 min
  5829.                         }
  5830.                 }
  5831.                 #### REMOVE OLDER PDFS ####
  5832.  
  5833.                 $package_subscriptions_id = $this->input->post('data_id');
  5834.                 $Result = $this->Manage_model->get_package_payment_details_for_invoice($package_subscriptions_id);
  5835.                 if(!empty($Result))
  5836.                 {
  5837.                         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  5838.                         $OD = $this->Manage_model->get_organization_details($organizations_id);
  5839.                         $data['CountryData'] = $this->Manage_model->get_organization_country_details();
  5840.  
  5841.                         $data['DT'] = $Result;
  5842.                         $data['OD'] = $OD;
  5843.                         $html = $this->load->view('organizations/invoice_print',$data,true);
  5844.  
  5845.                         // Generate Invoice PDF
  5846.                         require_once FCPATH.'/vendor/autoload.php';
  5847.                         $DateTime = time().$package_subscriptions_id;
  5848.                         $pdfFilePath = FCPATH."uploads/pdf/".$DateTime.".pdf";
  5849.                         $pdf = new \Mpdf\Mpdf(['format' => 'A5']);
  5850.                         $pdf->AddPageByArray(['margin-left' => 5,'margin-right' => 5,'margin-top' => 25,'margin-bottom' => 10,]);
  5851.                         $pdf->WriteHTML($html);
  5852.                         $pdf->Output($pdfFilePath, 'F');
  5853.                         // Generate Invoice PDF
  5854.  
  5855.                         ?><br><iframe id="MyiFrame" frameborder="0" style="border:0; width: 0; height: 0" src="<?php echo base_url('uploads/pdf/'.$DateTime.'.pdf'); ?>"></iframe><?php
  5856.                 }
  5857.         }
  5858.         else
  5859.         {
  5860.                 redirect('dashboard');
  5861.         }
  5862. }
  5863. ############################################ END OF PRINT INVOICE #################################
  5864.  
  5865. ############################################ MEETING REPORT #######################################
  5866. public function meeting_report($meetings_id)
  5867. {
  5868.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  5869.         if($this->form_validation->run())
  5870.         {
  5871.                 #### REMOVE OLDER PDFS ####
  5872.                 $FIL_PATH = FCPATH.'uploads/pdf/*';
  5873.                 $TL_FILS = glob($FIL_PATH);
  5874.                 $STRT_TIM = strtotime(date('Y-m-d H:i'));
  5875.                 $END_TIME = date('Y-m-d H:i', strtotime('-30 minutes',$STRT_TIM));
  5876.                 foreach($TL_FILS as $NFILES)
  5877.                 {
  5878.                         if(is_file($NFILES))
  5879.                         {
  5880.                                 $FIL_TIME = date("Y-m-d H:i", filectime($NFILES));
  5881.                                 if($FIL_TIME<$END_TIME){unlink($NFILES);} // Remove files before 30 min
  5882.                         }
  5883.                 }
  5884.                 #### REMOVE OLDER PDFS ####
  5885.  
  5886.                 $meetings_id = $this->input->post('data_id');
  5887.                 $MD = $this->Manage_model->meeting_details($meetings_id);
  5888.                 if(!empty($MD))
  5889.                 {
  5890.                         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  5891.                         $OD = $this->Manage_model->get_organization_details($organizations_id);
  5892.  
  5893.                         $data['MD'] = $MD;
  5894.                         $data['OD'] = $OD;
  5895.                         $data['MeetingMembersList'] = $this->Manage_model->get_meeting_members($meetings_id);
  5896.                         $data['MFeedback'] = $this->Manage_model->get_meeting_members_feedback($meetings_id);
  5897.                         $data['Invities'] = $this->Manage_model->get_meeting_members_count_new($meetings_id);
  5898.                         $data['Attendees'] = $this->Manage_model->get_meeting_members_attended_count_new($meetings_id);
  5899.  
  5900.                         $html = $this->load->view('meetings/meeting_report',$data,true);
  5901.  
  5902.                         // Generate Invoice PDF
  5903.                         require_once FCPATH.'/vendor/autoload.php';
  5904.                         $DateTime = time().$meetings_id;
  5905.                         $pdfFilePath = FCPATH."uploads/pdf/".$DateTime.".pdf";
  5906.                         $pdf = new \Mpdf\Mpdf(['format' => 'A4']);
  5907.                         $pdf->AddPageByArray(['margin-left' => 5,'margin-right' => 5,'margin-top' => 37,'margin-bottom' => 10,]);
  5908.                         $pdf->WriteHTML($html);
  5909.                         $pdf->Output($pdfFilePath, 'F');
  5910.                         // Generate Invoice PDF
  5911.  
  5912.                         ?><br><iframe id="MyiFrame" frameborder="0" style="border:0; width: 0; height: 0;" src="<?php echo base_url('uploads/pdf/'.$DateTime.'.pdf'); ?>"></iframe><?php
  5913.                 }
  5914.         }
  5915.         else
  5916.         {
  5917.                 redirect('dashboard');
  5918.         }
  5919. }
  5920.  
  5921. public function generate_meeting_report($meetings_id)
  5922. {
  5923.         $MD = $this->Manage_model->meeting_details($meetings_id);
  5924.         if(!empty($MD))
  5925.         {
  5926.                 $organizations_id = $this->session->userdata('logged_in')['table_id'];
  5927.                 $OD = $this->Manage_model->get_organization_details($organizations_id);
  5928.  
  5929.                 $data['MD'] = $MD;
  5930.                 $data['OD'] = $OD;
  5931.                 $data['MeetingMembersList'] = $this->Manage_model->get_meeting_members($meetings_id);
  5932.                 $data['MFeedback'] = $this->Manage_model->get_meeting_members_feedback($meetings_id);
  5933.                 $data['Invities'] = $this->Manage_model->get_meeting_members_count_new($meetings_id);
  5934.                 $data['Attendees'] = $this->Manage_model->get_meeting_members_attended_count_new($meetings_id);
  5935.  
  5936.                 $html = $this->load->view('meetings/meeting_report',$data,true);
  5937.  
  5938.                 // Generate Invoice PDF
  5939.                 require_once FCPATH.'/vendor/autoload.php';
  5940.                 $DateTime = time().$meetings_id;
  5941.                 $pdfFilePath = FCPATH."uploads/pdf/".$DateTime.".pdf";
  5942.                 $pdf = new \Mpdf\Mpdf(['format' => 'A4']);
  5943.                 $pdf->AddPageByArray(['margin-left' => 5,'margin-right' => 5,'margin-top' => 37,'margin-bottom' => 10,]);
  5944.                 $pdf->WriteHTML($html);
  5945.                 $pdf->Output($pdfFilePath, 'F');
  5946.                 // Generate Invoice PDF
  5947.  
  5948.                 return base_url('uploads/pdf/'.$DateTime.'.pdf');
  5949.         }
  5950.         else
  5951.         {
  5952.                 return '';
  5953.         }
  5954. }
  5955. ############################################ END OF MEETING REPORT ################################
  5956.  
  5957. ############################################ MOM LETTER HEAD ######################################
  5958. public function mom_letterhead($meetings_id)
  5959. {
  5960.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  5961.         if($this->form_validation->run())
  5962.         {
  5963.                 #### REMOVE OLDER PDFS ####
  5964.                 $FIL_PATH = FCPATH.'uploads/pdf/*';
  5965.                 $TL_FILS = glob($FIL_PATH);
  5966.                 $STRT_TIM = strtotime(date('Y-m-d H:i'));
  5967.                 $END_TIME = date('Y-m-d H:i', strtotime('-30 minutes',$STRT_TIM));
  5968.                 foreach($TL_FILS as $NFILES)
  5969.                 {
  5970.                         if(is_file($NFILES))
  5971.                         {
  5972.                                 $FIL_TIME = date("Y-m-d H:i", filectime($NFILES));
  5973.                                 if($FIL_TIME<$END_TIME){unlink($NFILES);} // Remove files before 30 min
  5974.                         }
  5975.                 }
  5976.                 #### REMOVE OLDER PDFS ####
  5977.  
  5978.                 $meetings_id = $this->input->post('data_id');
  5979.                 $MD = $this->Manage_model->meeting_details($meetings_id);
  5980.                 if(!empty($MD))
  5981.                 {
  5982.                         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  5983.                         $OD = $this->Manage_model->get_organization_details($organizations_id);
  5984.  
  5985.                         $data['MD'] = $MD;
  5986.                         $data['OD'] = $OD;
  5987.  
  5988.                         $html = $this->load->view('meetings/mom_letterhead',$data,true);
  5989.  
  5990.                         // Generate Invoice PDF
  5991.                         require_once FCPATH.'/vendor/autoload.php';
  5992.                         $DateTime = time().$meetings_id;
  5993.                         $pdfFilePath = FCPATH."uploads/pdf/".$DateTime.".pdf";
  5994.                         $pdf = new \Mpdf\Mpdf(['format' => 'A4']);
  5995.                         $pdf->AddPageByArray(['margin-left' => 5,'margin-right' => 5,'margin-top' => 37,'margin-bottom' => 10,]);
  5996.                         $pdf->WriteHTML($html);
  5997.                         $pdf->Output($pdfFilePath, 'F');
  5998.                         // Generate Invoice PDF
  5999.  
  6000.                         ?><br><iframe id="MyiFrame" frameborder="0" style="border:0; width: 0; height: 0;" src="<?php echo base_url('uploads/pdf/'.$DateTime.'.pdf'); ?>"></iframe><?php
  6001.                 }
  6002.         }
  6003.         else
  6004.         {
  6005.                 redirect('dashboard');
  6006.         }
  6007. }
  6008. ############################################ END OF MOM LETTER HEAD ###############################
  6009.  
  6010. ############################################ SUPPORT REQUEST ######################################
  6011. public function view_support_request_details()
  6012. {
  6013.         $Data['response'] = 'failed';
  6014.         $Data['result'] = array();
  6015.  
  6016.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  6017.         if($this->form_validation->run())
  6018.         {
  6019.                 $support_request_id = $this->input->post('data_id');
  6020.                 $Result = $this->Manage_model->get_support_request_details($support_request_id);
  6021.                 if(!empty($Result))
  6022.                 {
  6023.                         $Result['support_request_id'] = 'MPST'.sprintf("%05d", $Result['support_request_id']);
  6024.                         $Result['pending_datetime'] = date('d-m-Y h:iA',strtotime($Result['pending_datetime']));
  6025.                         $Result['processed_datetime'] = date('d-m-Y h:iA',strtotime($Result['processed_datetime']));
  6026.                         $Result['completed_datetime'] = date('d-m-Y h:iA',strtotime($Result['completed_datetime']));
  6027.  
  6028.                         if($Result['status']==0)
  6029.                         {
  6030.                                 $Result['status'] = '<span class="badge badge-danger">PENDING</span>';
  6031.                         }
  6032.                         elseif($Result['status']==1)
  6033.                         {
  6034.                                 $Result['status'] = '<span class="badge badge-info">PROCESSING</span>';
  6035.                                 $Result['status'] .= ' - on '.$Result['processed_datetime'].'<br><b>Remark:</b> '.$Result['processed_remark'];
  6036.                         }
  6037.                         else
  6038.                         {
  6039.                                 $Result['status'] = '<span class="badge badge-success">COMPLETED</span>';
  6040.                                 $Result['status'] .= ' - on '.$Result['completed_datetime'].'<br><b>Remark:</b> '.$Result['completed_remark'];
  6041.                         }
  6042.  
  6043.                         $Data['response'] = 'success';
  6044.                         $Data['result'] = $Result;
  6045.                 }
  6046.         }
  6047.         echo json_encode($Data);
  6048. }
  6049.  
  6050. public function support_request()
  6051. {
  6052.         # INSERT / UPDATE FUNCTION
  6053.         if(isset($_POST['submit']))
  6054.         {
  6055.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  6056.                 $this->form_validation->set_rules('support_request_type_id','Type','trim|required|xss_clean');
  6057.                 $this->form_validation->set_rules('subject','Subject','trim|required|xss_clean');
  6058.                 $this->form_validation->set_rules('message','Message','trim|required|xss_clean');
  6059.  
  6060.                 if($this->form_validation->run())
  6061.                 {
  6062.                         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  6063.                         $OD = $this->Manage_model->get_organization_details($organizations_id);
  6064.  
  6065.                         $support_request_type_id = $this->input->post('support_request_type_id');
  6066.                         $subject = $this->input->post('subject');
  6067.                         $message = $this->input->post('message');
  6068.                         $submit = $this->input->post('submit');
  6069.  
  6070.                         $DateTime = date('Y-m-d H:i:s');
  6071.  
  6072.                         $values = array('datetime'=>$DateTime,
  6073.                                                         'pending_datetime'=>$DateTime,
  6074.                                                         'organizations_id'=>$organizations_id,
  6075.                                                         'support_request_type_id'=>$support_request_type_id,
  6076.                                                         'subject'=>$subject,
  6077.                                                         'request'=>$message);
  6078.  
  6079.                         $support_request_id = $this->Common_model->common_insert('support_request',$values);
  6080.                         $this->Common_model->Set_Message('1',"Support requested successfully.");
  6081.  
  6082.                         $Type = $this->Manage_model->support_request_types_id($support_request_type_id);
  6083.  
  6084.                         $TicketNumber = 'MPST'.sprintf("%05d", $support_request_id);
  6085.  
  6086.                         $DateTime = date('d-M-Y h:i A');
  6087.  
  6088.                         // email to organization
  6089.                         $OrgData['Subject'] = '[Ticket ID: '.$TicketNumber.'] '.$subject;
  6090.                         $OrgData['Header'] = 'Dear '.$OD['name'].',<br><br>';
  6091.                         $OrgData['Content'] = 'Thank you for reaching out Meet Pass support system.<br><br>This is an automatic response just to let you know we have got your email. You will get an answer back shortly.<br><br><hr><br>Ticket ID: '.$TicketNumber.'<br>Subject: '.$subject.'<br>Status: Pending<br><br>Regards,<br>Meet Pass';
  6092.                         $this->SentMail('10',$OD['email'],$OrgData);
  6093.                         // email to organization
  6094.  
  6095.                         // email to meetpass
  6096.                         $AdminData['Subject'] = 'New Support Request - [Ticket ID: '.$TicketNumber.'] '.$subject;
  6097.                         $AdminData['Header'] = 'New Support Request.<br><br>';
  6098.                         $AdminData['Content'] = $OD['name'].'<br>'.$OD['country'].'<br>Date & Time : '.$DateTime.'<br><br>Ticket ID: '.$TicketNumber.'<br>Type: '.$Type['support_request_type'].'<br>Subject: '.$subject.'<br>Status: Pending<br>Message: '.$message;
  6099.                         $this->SentMail('10','support@meetpass.com', $AdminData);
  6100.                         // email to meetpass
  6101.                 }
  6102.                 else
  6103.                 {
  6104.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  6105.                 }
  6106.                 redirect(current_url());
  6107.         }
  6108.         # END OF INSERT / UPDATE FUNCTION
  6109.  
  6110.         # FILTER AND PAGINATION SECTION
  6111.         $FD = array();
  6112.         $URL = $this->uri->segment(1);
  6113.         $start = $limit = '';
  6114.         $page_ary['url'] = base_url($URL);
  6115.         $page_ary['total_rows'] = $this->Manage_model->support_request_history($FD,$start,$limit,'1')[0]->count;
  6116.         $limit = $page_ary['per_page'] = 30;
  6117.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  6118.         $data['page'] = $start = $PGN_DATA['page'];
  6119.         $data['links'] = $PGN_DATA['links'];
  6120.         # END OF FILTER AND PAGINATION SECTION
  6121.  
  6122.         $data['Type'] = $this->Manage_model->support_request_types();
  6123.         $data['SRH'] = $this->Manage_model->support_request_history($FD,$start,$limit,'0');
  6124.  
  6125.         $this->CommonPage('organizations/support_request',$data,'Support Ticket');
  6126. }
  6127. ############################################ END OF SUPPORT REQUEST ###############################
  6128.  
  6129. ############################################ SUPPORT REQUEST - ADMIN ##############################
  6130. public function view_support_request_details_admin()
  6131. {
  6132.         $Data['response'] = 'failed';
  6133.         $Data['result'] = array();
  6134.  
  6135.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  6136.         if($this->form_validation->run())
  6137.         {
  6138.                 $support_request_id = $this->input->post('data_id');
  6139.                 $Result = $this->Manage_model->get_support_request_details_admin($support_request_id);
  6140.                 if(!empty($Result))
  6141.                 {
  6142.                         $Result['support_request_id'] = 'MPST'.sprintf("%05d", $Result['support_request_id']);
  6143.                         $Result['pending_datetime'] = date('d-m-Y h:iA',strtotime($Result['pending_datetime']));
  6144.                         $Result['processed_datetime'] = date('d-m-Y h:iA',strtotime($Result['processed_datetime']));
  6145.                         $Result['completed_datetime'] = date('d-m-Y h:iA',strtotime($Result['completed_datetime']));
  6146.  
  6147.                         if($Result['status']==0)
  6148.                         {
  6149.                                 $Result['status'] = '<span class="badge badge-danger">PENDING</span>';
  6150.                         }
  6151.                         elseif($Result['status']==1)
  6152.                         {
  6153.                                 $Result['status'] = '<span class="badge badge-info">PROCESSING</span>';
  6154.                                 $Result['status'] .= ' - on '.$Result['processed_datetime'].'<br><b>Remark:</b> '.$Result['processed_remark'];
  6155.                         }
  6156.                         else
  6157.                         {
  6158.                                 $Result['status'] = '<span class="badge badge-success">COMPLETED</span>';
  6159.                                 $Result['status'] .= ' - on '.$Result['completed_datetime'].'<br><b>Remark:</b> '.$Result['completed_remark'];
  6160.                         }
  6161.  
  6162.                         $Data['response'] = 'success';
  6163.                         $Data['result'] = $Result;
  6164.                 }
  6165.         }
  6166.         echo json_encode($Data);
  6167. }
  6168.  
  6169. public function support_request_admin($status='0')
  6170. {
  6171.         # INSERT / UPDATE FUNCTION
  6172.         if(isset($_POST['ActiveRequest']))
  6173.         {
  6174.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  6175.                 $this->form_validation->set_rules('support_request_id','Request','trim|required|xss_clean');
  6176.                 $this->form_validation->set_rules('organizations_id','Organization','trim|required|xss_clean');
  6177.                 $this->form_validation->set_rules('remark','Remark','trim|xss_clean');
  6178.  
  6179.                 if($this->form_validation->run())
  6180.                 {
  6181.                         $users_id = $this->session->userdata('logged_in')['users_id'];
  6182.  
  6183.                         $support_request_id = $this->input->post('support_request_id');
  6184.                         $organizations_id = $this->input->post('organizations_id');
  6185.                         $remark = $this->input->post('remark');
  6186.                         $ActiveRequest = $this->input->post('ActiveRequest');
  6187.  
  6188.                         $TicketNumber = 'MPST'.sprintf("%05d", $support_request_id);
  6189.  
  6190.                         $DateTime = date('Y-m-d H:i:s');
  6191.  
  6192.                         $CheckData = $this->Manage_model->support_request_admin_data($support_request_id,$organizations_id);
  6193.                         if(!empty($CheckData))
  6194.                         {
  6195.                                 $Response = '';
  6196.                                 if($remark!='')
  6197.                                 {
  6198.                                         $Response = '<br> Remark: '.$remark;
  6199.                                 }
  6200.  
  6201.                                 $Type = $CheckData['support_request_type'];
  6202.                                 $subject = $CheckData['subject'];
  6203.                                 $org_name = $CheckData['org_name'];
  6204.                                 $org_email = $CheckData['org_email'];
  6205.  
  6206.                                 $where = array('support_request_id'=>$support_request_id,'organizations_id'=>$organizations_id);
  6207.  
  6208.                                 if($CheckData['status']=='0' && $ActiveRequest=='Processing')
  6209.                                 {
  6210.                                         $values = array('processed_datetime'=>$DateTime,
  6211.                                                                         'processed_remark'=>$remark,
  6212.                                                                         'processed_by'=>$users_id,
  6213.                                                                         'status'=>'1');
  6214.                                         $this->Common_model->common_update('support_request',$values,$where);
  6215.                                         $this->Common_model->Set_Message('1',"Support request processed successfully.");
  6216.  
  6217.                                         // email to organization
  6218.                                         $OrgData['Subject'] = 'Processing - [Ticket ID: '.$TicketNumber.'] '.$subject;
  6219.                                         $OrgData['Header'] = 'Dear '.$org_name.',<br><br>';
  6220.                                         $OrgData['Content'] = 'Thank you for reaching out Meet Pass support system.<br><br><hr><br>Ticket ID: '.$TicketNumber.'<br>Subject: '.$subject.'<br>Status: Processing'.$Response.'<br><br>Regards,<br>Meet Pass';
  6221.                                         $this->SentMail('10',$org_email,$OrgData);
  6222.                                         // email to organization
  6223.  
  6224.                                         // email to meetpass
  6225.                                         $AdminData['Subject'] = 'Processing - [Ticket ID: '.$TicketNumber.'] '.$subject;
  6226.                                         $AdminData['Header'] = 'Support Request Under Processing.<br><br>';
  6227.                                         $AdminData['Content'] = $org_name.'<br>Date & Time : '.$DateTime.'<br><br>Ticket ID: '.$TicketNumber.'<br>Type: '.$Type.'<br>Subject: '.$subject.'<br>Status: Processing<br>Message: '.$Response;
  6228.                                         $this->SentMail('10','support@meetpass.com', $AdminData);
  6229.                                         // email to meetpass
  6230.                                 }
  6231.                                 elseif($CheckData['status']=='1' && $ActiveRequest=='Finish')
  6232.                                 {
  6233.                                         $values = array('completed_datetime'=>$DateTime,
  6234.                                                                         'completed_remark'=>$remark,
  6235.                                                                         'completed_by'=>$users_id,
  6236.                                                                         'status'=>'2');
  6237.                                         $this->Common_model->common_update('support_request',$values,$where);
  6238.                                         $this->Common_model->Set_Message('1',"Support request finished successfully.");
  6239.  
  6240.                                         // email to organization
  6241.                                         $OrgData['Subject'] = 'Finished - [Ticket ID: '.$TicketNumber.'] '.$subject;
  6242.                                         $OrgData['Header'] = 'Dear '.$org_name.',<br><br>';
  6243.                                         $OrgData['Content'] = 'Thank you for reaching out Meet Pass support system.<br><br><hr><br>Ticket ID: '.$TicketNumber.'<br>Subject: '.$subject.'<br>Status: Finished'.$Response.'<br><br>Regards,<br>Meet Pass';
  6244.                                         $this->SentMail('10',$org_email,$OrgData);
  6245.                                         // email to organization
  6246.  
  6247.                                         // email to meetpass
  6248.                                         $AdminData['Subject'] = 'Finished - [Ticket ID: '.$TicketNumber.'] '.$subject;
  6249.                                         $AdminData['Header'] = 'Support Request Finished.<br><br>';
  6250.                                         $AdminData['Content'] = $org_name.'<br>Date & Time : '.$DateTime.'<br><br>Ticket ID: '.$TicketNumber.'<br>Type: '.$Type.'<br>Subject: '.$subject.'<br>Status: Processing<br>Message: '.$Response;
  6251.                                         $this->SentMail('10','support@meetpass.com', $AdminData);
  6252.                                         // email to meetpass
  6253.                                 }
  6254.                                 else
  6255.                                 {
  6256.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  6257.                                 }
  6258.                         }
  6259.                         else
  6260.                         {
  6261.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  6262.                         }
  6263.                 }
  6264.                 else
  6265.                 {
  6266.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  6267.                 }
  6268.  
  6269.                 redirect(current_url());
  6270.         }
  6271.         # END OF INSERT / UPDATE FUNCTION
  6272.  
  6273.         # FILTER AND PAGINATION SECTION
  6274.         $URL = $this->uri->segment(1);
  6275.  
  6276.         $param[] = array('key'=>'ticket_no','default'=>'');
  6277.         $param[] = array('key'=>'status','default'=>$status);
  6278.         $FD = $this->Common_model->common_filter($URL,$param);
  6279.  
  6280.         if($this->session->userdata('logged_in')['privilege_id']==6)
  6281.         {
  6282.                 $FD['country_id'] = $this->session->userdata('logged_in')['table_id']; // for country admin only
  6283.         }
  6284.  
  6285.         $start = $limit = '';
  6286.         $page_ary['url'] = base_url($URL);
  6287.         $page_ary['total_rows'] = $this->Manage_model->support_request_history_admin($FD,$start,$limit,'1')[0]->count;
  6288.         $limit = $page_ary['per_page'] = 30;
  6289.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  6290.         $data['page'] = $start = $PGN_DATA['page'];
  6291.         $data['links'] = $PGN_DATA['links'];
  6292.         # END OF FILTER AND PAGINATION SECTION
  6293.  
  6294.         $data['FD'] = $FD;
  6295.         $data['SRH'] = $this->Manage_model->support_request_history_admin($FD,$start,$limit,'0');
  6296.  
  6297.         $this->CommonPage('organizations/support_request_admin',$data,'Support Requests');
  6298. }
  6299. ############################################ END OF SUPPORT REQUEST - ADMIN #######################
  6300.  
  6301. ############################################ FAQ ##################################################
  6302. public function faq()
  6303. {
  6304.         $data['DT'] = $this->Manage_model->get_faq_list();
  6305.         $this->CommonPage('dashboard/faq',$data,'FAQ');
  6306. }
  6307. ############################################ END OF FAQ ###########################################
  6308.  
  6309. ############################################ TUTORIALS ############################################
  6310. public function tutorials()
  6311. {
  6312.         $data['DT'] = $this->Manage_model->get_tutorials_list();
  6313.         $this->CommonPage('dashboard/tutorials',$data,'Tutorials');
  6314. }
  6315. ############################################ END OF TUTORIALS #####################################
  6316.  
  6317. ############################################ APP LINKS ############################################
  6318. public function app_links()
  6319. {
  6320.         $this->CommonPage('dashboard/app_links','','Mobile Application Links');
  6321. }
  6322. ############################################ END OF APP LINKS #####################################
  6323.  
  6324. ############################################ VISITORS REPORT ######################################
  6325. public function visitors_report()
  6326. {
  6327.         # FILTER AND PAGINATION SECTION
  6328.         $URL = $this->uri->segment(1);
  6329.         $param[] = array('key'=>'organizations_members_id','default'=>'');
  6330.         $param[] = array('key'=>'start_date','default'=>date('01/m/Y'));
  6331.         $param[] = array('key'=>'end_date','default'=>date('t/m/Y'));
  6332.         $FD = $this->Common_model->common_filter($URL,$param);
  6333.  
  6334.         $start = $limit = '';
  6335.         $page_ary['url'] = base_url($URL);
  6336.         $page_ary['total_rows'] = $this->Manage_model->view_visitors_report($FD,$start,$limit,'1')[0]->count;
  6337.         $limit = $page_ary['per_page'] = 30;
  6338.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  6339.         $data['page'] = $start = $PGN_DATA['page'];
  6340.         $data['links'] = $PGN_DATA['links'];
  6341.         # END OF FILTER AND PAGINATION SECTION
  6342.  
  6343.         $data['FD'] = $FD;
  6344.         $data['VR'] = $this->Manage_model->view_visitors_report($FD,$start,$limit,'0');
  6345.         $data['MD'] = $this->Manage_model->view_members_select();
  6346.  
  6347.         $this->CommonPage('reports/visitors_report', $data, 'Visitors Report');
  6348. }
  6349. ############################################ END OF VISITORS REPORT ###############################
  6350.  
  6351. ############################################ VISITORS REPORT PDF ##################################
  6352. public function visitors_report_print()
  6353. {
  6354.         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  6355.         #### REMOVE OLDER PDFS ####
  6356.         $FIL_PATH = FCPATH.'uploads/pdf/*';
  6357.         $TL_FILS = glob($FIL_PATH);
  6358.         $STRT_TIM = strtotime(date('Y-m-d H:i'));
  6359.         $END_TIME = date('Y-m-d H:i', strtotime('-30 minutes',$STRT_TIM));
  6360.         foreach($TL_FILS as $NFILES)
  6361.         {
  6362.                 if(is_file($NFILES))
  6363.                 {
  6364.                         $FIL_TIME = date("Y-m-d H:i", filectime($NFILES));
  6365.                         if($FIL_TIME<$END_TIME){unlink($NFILES);} // Remove files before 30 min
  6366.                 }
  6367.         }
  6368.         #### REMOVE OLDER PDFS ####
  6369.  
  6370.         if(isset($_SESSION['FILTER']['visitors-report']) && !empty($_SESSION['FILTER']['visitors-report']))
  6371.         {
  6372.                 $FD = $_SESSION['FILTER']['visitors-report'];
  6373.                 $start = $limit = '';
  6374.  
  6375.                 $data['VR'] = $this->Manage_model->view_visitors_report($FD,$start,$limit,'0');
  6376.                 $data['FD'] = $FD;
  6377.                 $data['OD'] = $this->Manage_model->get_organization_details($organizations_id);
  6378.                 $html = $this->load->view('reports/visitors_report_print',$data,true);
  6379.  
  6380.                 // Generate Invoice PDF
  6381.                 require_once FCPATH.'/vendor/autoload.php';
  6382.                 $DateTime = time().$organizations_id;
  6383.                 $pdfFilePath = FCPATH."uploads/pdf/".$DateTime.".pdf";
  6384.                 $pdf = new \Mpdf\Mpdf(['format' => 'A4']);
  6385.                 $pdf->AddPageByArray(['margin-left' => 5,'margin-right' => 5,'margin-top' => 37,'margin-bottom' => 10,]);
  6386.                 $pdf->WriteHTML($html);
  6387.                 $pdf->Output($pdfFilePath, 'F');
  6388.                 // Generate Invoice PDF
  6389.  
  6390.                 ?><br><iframe id="MyiFrame" frameborder="0" style="border:0; width: 0; height: 0;" src="<?php echo base_url('uploads/pdf/'.$DateTime.'.pdf'); ?>"></iframe><?php
  6391.         }
  6392. }
  6393. ############################################ END OF VISITORS REPORT PDF ###########################
  6394.  
  6395. ############################################ MEMBERS MEETING REPORT ###############################
  6396. public function view_members_meeting_report_details()
  6397. {
  6398.         $Data['response'] = 'failed';
  6399.         $Data['result'] = array();
  6400.  
  6401.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  6402.         if($this->form_validation->run())
  6403.         {
  6404.                 $members_meeting_report_id = $this->input->post('data_id');
  6405.                 $Result = $this->Manage_model->view_members_meeting_report_details($members_meeting_report_id);
  6406.                 if(!empty($Result))
  6407.                 {
  6408.                         $Data['response'] = 'success';
  6409.                         $Data['result'] = $Result;
  6410.                 }
  6411.         }
  6412.         echo json_encode($Data);
  6413. }
  6414.  
  6415. public function members_meeting_report()
  6416. {
  6417.         # FILTER AND PAGINATION SECTION
  6418.         $URL = $this->uri->segment(1);
  6419.         $param[] = array('key'=>'organizations_members_id','default'=>'');
  6420.         $param[] = array('key'=>'start_date','default'=>date('01/m/Y'));
  6421.         $param[] = array('key'=>'end_date','default'=>date('t/m/Y'));
  6422.         $FD = $this->Common_model->common_filter($URL,$param);
  6423.  
  6424.         $start = $limit = '';
  6425.         $page_ary['url'] = base_url($URL);
  6426.         $page_ary['total_rows'] = $this->Manage_model->members_meeting_report($FD,$start,$limit,'1')[0]->count;
  6427.         $limit = $page_ary['per_page'] = 30;
  6428.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  6429.         $data['page'] = $start = $PGN_DATA['page'];
  6430.         $data['links'] = $PGN_DATA['links'];
  6431.         # END OF FILTER AND PAGINATION SECTION
  6432.  
  6433.         $data['FD'] = $FD;
  6434.         $data['VR'] = $this->Manage_model->members_meeting_report($FD,$start,$limit,'0');
  6435.         $data['MD'] = $this->Manage_model->view_members_select();
  6436.  
  6437.         $this->CommonPage('reports/members_meeting_report', $data, 'Meeting Report');
  6438. }
  6439. ############################################ END OF MEMBERS MEETING REPORT ########################
  6440.  
  6441. ############################################ MEMBERS MEETING REPORT ###############################
  6442. public function subscription_report()
  6443. {
  6444.         # FILTER AND PAGINATION SECTION
  6445.         $URL = $this->uri->segment(1);
  6446.         $param[] = array('key'=>'country_id','default'=>'');
  6447.         $param[] = array('key'=>'start_date','default'=>date('01/m/Y'));
  6448.         $param[] = array('key'=>'end_date','default'=>date('t/m/Y'));
  6449.         $FD = $this->Common_model->common_filter($URL,$param);
  6450.  
  6451.         if($this->session->userdata('logged_in')['privilege_id']==6)
  6452.         {
  6453.                 $FD['country_id'] = $this->session->userdata('logged_in')['table_id']; // for country admin only
  6454.         }
  6455.  
  6456.         $start = $limit = '';
  6457.         $page_ary['url'] = base_url($URL);
  6458.         $page_ary['total_rows'] = $this->Manage_model->subscription_report($FD,$start,$limit,'1')[0]->count;
  6459.         $limit = $page_ary['per_page'] = 30;
  6460.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  6461.         $data['page'] = $start = $PGN_DATA['page'];
  6462.         $data['links'] = $PGN_DATA['links'];
  6463.         # END OF FILTER AND PAGINATION SECTION
  6464.  
  6465.         $data['FD'] = $FD;
  6466.         $data['VR'] = $this->Manage_model->subscription_report($FD,$start,$limit,'0');
  6467.         $data['GrandTotal'] = $this->Manage_model->subscription_report_grand_total($FD,$start,$limit,'0');
  6468.  
  6469.         $this->CommonPage('reports/subscription_report', $data, 'Subscribers Report');
  6470. }
  6471. ############################################ END OF MEMBERS MEETING REPORT ########################
  6472.  
  6473. ############################################ ADMIN PROFILE ########################################
  6474. public function admin_profile($tab='')
  6475. {
  6476.         if($this->session->userdata('logged_in')['privilege_id']==6)
  6477.         {
  6478.                 $country_id = $this->session->userdata('logged_in')['table_id']; // for country admin only
  6479.         }
  6480.         else
  6481.         {
  6482.                 redirect('dashboard'); 
  6483.         }
  6484.  
  6485.         if(isset($_POST['submit']))
  6486.         {
  6487.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  6488.                 $this->form_validation->set_rules('company','company','trim|required|xss_clean');
  6489.                 $this->form_validation->set_rules('phone','phone','trim|required|xss_clean');
  6490.                 $this->form_validation->set_rules('email','email','trim|required|xss_clean');
  6491.                 $this->form_validation->set_rules('address','address','trim|required|xss_clean');
  6492.                 $this->form_validation->set_rules('cp_name','cp_name','trim|required|xss_clean');
  6493.                 $this->form_validation->set_rules('cp_phone','cp_phone','trim|required|xss_clean');
  6494.                 $this->form_validation->set_rules('cp_email','cp_email','trim|xss_clean');
  6495.                 $this->form_validation->set_rules('cp_position','cp_position','trim|xss_clean');
  6496.                 $this->form_validation->set_rules('account_name','account_name','trim|xss_clean');
  6497.                 $this->form_validation->set_rules('account_number','account_number','trim|xss_clean');
  6498.                 $this->form_validation->set_rules('bank_name','bank_name','trim|xss_clean');
  6499.                 $this->form_validation->set_rules('bank_branch','bank_branch','trim|xss_clean');
  6500.                 $this->form_validation->set_rules('ifsc_code','ifsc_code','trim|xss_clean');
  6501.                 $this->form_validation->set_rules('bank_address','bank_address','trim|xss_clean');
  6502.  
  6503.                 if($this->form_validation->run())
  6504.                 {
  6505.                         $company = $this->input->post('company');
  6506.                         $phone = $this->input->post('phone');
  6507.                         $email = $this->input->post('email');
  6508.                         $address = $this->input->post('address');
  6509.                         $cp_name = $this->input->post('cp_name');
  6510.                         $cp_phone = $this->input->post('cp_phone');
  6511.                         $cp_email = $this->input->post('cp_email');
  6512.                         $cp_position = $this->input->post('cp_position');
  6513.                         $account_name = $this->input->post('account_name');
  6514.                         $account_number = $this->input->post('account_number');
  6515.                         $bank_name = $this->input->post('bank_name');
  6516.                         $bank_branch = $this->input->post('bank_branch');
  6517.                         $ifsc_code = $this->input->post('ifsc_code');
  6518.                         $bank_address = $this->input->post('bank_address');
  6519.                         $submit = $this->input->post('submit');
  6520.  
  6521.                         $values = array('company'=>ucwords($company),
  6522.                                                         'phone'=>$phone,
  6523.                                                         'email'=>$email,
  6524.                                                         'address'=>$address,
  6525.                                                         'cp_name'=>ucwords($cp_name),
  6526.                                                         'cp_phone'=>$cp_phone,
  6527.                                                         'cp_email'=>strtolower($cp_email),
  6528.                                                         'cp_position'=>$cp_position,
  6529.                                                         'account_name'=>$account_name,
  6530.                                                         'account_number'=>$account_number,
  6531.                                                         'bank_name'=>$bank_name,
  6532.                                                         'bank_branch'=>$bank_branch,
  6533.                                                         'ifsc_code'=>$ifsc_code,
  6534.                                                         'bank_address'=>$bank_address);
  6535.  
  6536.                         $where = array('country_id'=>$country_id);
  6537.                         $this->Common_model->common_update('country_admin',$values,$where);
  6538.                         $this->Common_model->Set_Message('1',"Profile updated successfully.");
  6539.                 }
  6540.                 else
  6541.                 {
  6542.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  6543.                 }
  6544.                 redirect(current_url());
  6545.         }      
  6546.  
  6547.         $data['OD'] = $this->Manage_model->get_country_admin_details($country_id);
  6548.  
  6549.         $this->CommonPage('organizations/admin_profile',$data,$data['OD']['company']);
  6550. }
  6551. ############################################ END OF ADMIN PROFILE #################################
  6552.  
  6553. ############################################ VIEW COUNTRY ADMINS ##################################
  6554. public function view_country_admins_details()
  6555. {
  6556.         $Data['response'] = 'failed';
  6557.         $Data['result'] = array();
  6558.  
  6559.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  6560.         if($this->form_validation->run())
  6561.         {
  6562.                 $country_id = $this->input->post('data_id');
  6563.                 $Result = $this->Manage_model->get_country_admin_details($country_id);
  6564.                 if(!empty($Result))
  6565.                 {
  6566.                         $Data['response'] = 'success';
  6567.                         $Data['result'] = $Result;
  6568.                 }
  6569.         }
  6570.         echo json_encode($Data);
  6571. }
  6572.  
  6573. public function get_countryadmin_data()
  6574. {
  6575.         $Data['response'] = 'failed';
  6576.         $Data['result'] = array();
  6577.  
  6578.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  6579.         if($this->form_validation->run())
  6580.         {
  6581.                 $countryAdmin_id = $this->input->post('data_id');
  6582.                 $Result = $this->Manage_model->view_country_admins_BYID($countryAdmin_id);
  6583.                 if(!empty($Result))
  6584.                 {
  6585.                         $Data['response'] = 'success';
  6586.                         $Data['result'] = $Result;
  6587.                 }
  6588.         }
  6589.         echo json_encode($Data);
  6590. }
  6591.  
  6592. public function view_country_admins()
  6593. {
  6594.        
  6595.        
  6596.         if(isset($_POST['submit']))
  6597.         {
  6598.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  6599.                 $this->form_validation->set_rules('company','company','trim|required|xss_clean');
  6600.                 $this->form_validation->set_rules('phone','phone','trim|required|xss_clean');
  6601.                 $this->form_validation->set_rules('email','email','trim|required|xss_clean');
  6602.                 $this->form_validation->set_rules('address','address','trim|required|xss_clean');
  6603.                 $this->form_validation->set_rules('cp_name','cp_name','trim|required|xss_clean');
  6604.                 $this->form_validation->set_rules('cp_phone','cp_phone','trim|required|xss_clean');
  6605.                 $this->form_validation->set_rules('cp_email','cp_email','trim|xss_clean');
  6606.                 $this->form_validation->set_rules('cp_position','cp_position','trim|xss_clean');
  6607.                 $this->form_validation->set_rules('account_name','account_name','trim|xss_clean');
  6608.                 $this->form_validation->set_rules('account_number','account_number','trim|xss_clean');
  6609.                 $this->form_validation->set_rules('bank_name','bank_name','trim|xss_clean');
  6610.                 $this->form_validation->set_rules('bank_branch','bank_branch','trim|xss_clean');
  6611.                 $this->form_validation->set_rules('ifsc_code','ifsc_code','trim|xss_clean');
  6612.                 $this->form_validation->set_rules('bank_address','bank_address','trim|xss_clean');
  6613.  
  6614.                 if($this->form_validation->run())
  6615.                 {   $country_admin_id=$this->input->post('country_admin_id'); 
  6616.                 $PDCountry_A=$this->input->post('PDCountry_A');
  6617.                         $company = $this->input->post('company');
  6618.                         $phone = $this->input->post('phone');
  6619.                         $email = $this->input->post('email');
  6620.                         $address = $this->input->post('address');
  6621.                         $cp_name = $this->input->post('cp_name');
  6622.                         $cp_phone = $this->input->post('cp_phone');
  6623.                         $cp_email = $this->input->post('cp_email');
  6624.                         $cp_position = $this->input->post('cp_position');
  6625.                         $account_name = $this->input->post('account_name');
  6626.                         $account_number = $this->input->post('account_number');
  6627.                         $bank_name = $this->input->post('bank_name');
  6628.                         $bank_branch = $this->input->post('bank_branch');
  6629.                         $ifsc_code = $this->input->post('ifsc_code');
  6630.                         $bank_address = $this->input->post('bank_addresss');
  6631.                         $country_admin_status = $this->input->post('country_admin_status');
  6632.                         $agreement_number = $this->input->post('PDAgreementNo_A');
  6633.                         $percentage = $this->input->post('PDPercentage_A');
  6634.                         $submit = $this->input->post('submit');
  6635.  
  6636.                         $values = array('company'=>ucwords($company),
  6637.                                                         'phone'=>$phone,
  6638.                                                         'country_id'=>$PDCountry_A,
  6639.                                                         'email'=>$email,
  6640.                                                         'address'=>$address,
  6641.                                                         'cp_name'=>ucwords($cp_name),
  6642.                                                         'cp_phone'=>$cp_phone,
  6643.                                                         'cp_email'=>strtolower($cp_email),
  6644.                                                         'cp_position'=>$cp_position,
  6645.                                                         'account_name'=>$account_name,
  6646.                                                         'agreement_number'=>$agreement_number,
  6647.                                                         'percentage'=>$percentage,
  6648.                                                         'account_number'=>$account_number,
  6649.                                                         'bank_name'=>$bank_name,
  6650.                                                         'bank_branch'=>$bank_branch,
  6651.                                                         'ifsc_code'=>$ifsc_code,
  6652.                                                         'country_admin_status'=>$country_admin_status,
  6653.                                                         'bank_address'=>$bank_address);
  6654.  
  6655.                        
  6656.        
  6657.                
  6658.                  if($submit=='Save')
  6659.                         {
  6660.                                 $id = $this->Common_model->common_insert('country_admin',$values);
  6661.                                 $this->Common_model->Set_Message('1',"<strong> Profile Saved successfully</strong>");
  6662.                                 redirect(current_url());
  6663.                                
  6664.                         }
  6665.                         else
  6666.                         {
  6667.                             $where = array('country_admin_id'=>$country_admin_id);                               
  6668.                                 $this->Common_model->common_update('country_admin',$values,$where);
  6669.                                 $this->Common_model->Set_Message('1',"<strong>Sucess!</strong>Profile Updated successfully.");
  6670.                         }
  6671.                         redirect(current_url());
  6672.                
  6673.                
  6674.                
  6675.                 }
  6676.                 else
  6677.                 {
  6678.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  6679.                 }
  6680.                 redirect(current_url());
  6681.         }      
  6682.          # INSERT / UPDATE FUNCTION
  6683.        
  6684.        
  6685.         # DELETE FUNCTION
  6686.        
  6687. # FILTER AND PAGINATION SECTION
  6688.         $URL = $this->uri->segment(1);
  6689.         $FD = array();
  6690.  
  6691.         $start = $limit = '';
  6692.         $page_ary['url'] = base_url($URL);
  6693.         $page_ary['total_rows'] = $this->Manage_model->view_country_admins($FD,$start,$limit,'1')[0]->count;
  6694.         $limit = $page_ary['per_page'] = 30;
  6695.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  6696.         $data['page'] = $start = $PGN_DATA['page'];
  6697.         $data['links'] = $PGN_DATA['links'];
  6698.         # END OF FILTER AND PAGINATION SECTION
  6699.  
  6700.         $data['FD'] = $FD;
  6701.         $data['AD'] = $this->Manage_model->view_country_admins($FD,$start,$limit,'0');
  6702. $data["CountryData"] = $this->Manage_model->select_view_country_org();
  6703.  
  6704.         $this->CommonPage('organizations/view_country_admins', $data, 'Country Admins');
  6705. }
  6706. ############################################ END OF VIEW COUNTRY ADMINS ###########################
  6707.  
  6708. ############################################ COUNTRY ADMINS PAYMENTS ##############################
  6709. public function get_country_admins_pending_payments()
  6710. {
  6711.         $Data['response'] = 'failed';
  6712.         $Data['result'] = array();
  6713.  
  6714.         $this->form_validation->set_rules('MP_country_id','MP_country_id','trim|required|xss_clean|numeric');
  6715.         $this->form_validation->set_rules('MP_year','MP_year','trim|required|xss_clean|numeric');
  6716.         $this->form_validation->set_rules('MP_month','MP_month','trim|required|xss_clean|numeric');
  6717.         if($this->form_validation->run())
  6718.         {
  6719.                 $MP_country_id = $this->input->post('MP_country_id');
  6720.                 $MP_year = $this->input->post('MP_year');
  6721.                 $MP_month = $this->input->post('MP_month');
  6722.  
  6723.                 $Result = $this->Manage_model->get_country_admin_details($MP_country_id);
  6724.                 if(!empty($Result) && $Result['percentage']>0)
  6725.                 {
  6726.                         $SDate = $MP_year.'-'.$MP_month.'-01';
  6727.                         $CheckPayment = $this->Manage_model->check_admin_payment_done($MP_country_id,$SDate);
  6728.                         if(empty($CheckPayment))
  6729.                         {
  6730.                                 $StartDate = $MP_year.'-'.$MP_month.'-01 00:00:00';
  6731.                                 $EndDate = date('Y-m-t',strtotime($StartDate)).' 23:59:59';
  6732.  
  6733.                                 $Rate = $Result['rates'];
  6734.                                 $Percentage = $Result['percentage'];
  6735.  
  6736.                                 $PendingPayment = $this->Manage_model->monthly_wise_pending_payment_report($MP_country_id,$StartDate,$EndDate);
  6737.                                 if($PendingPayment!='')
  6738.                                 {
  6739.                                         $CurrentMonthYear = date('Y-m-01');
  6740.                                         if($CurrentMonthYear!=$SDate)
  6741.                                         {
  6742.                                                 $Amnt = ((($PendingPayment/$Rate)*$Percentage)/100);
  6743.  
  6744.                                                 $Data['response'] = 'success';
  6745.                                                 $Data['result']['amount'] = round($Amnt,2);
  6746.                                                 $Data['result']['status'] = '';
  6747.                                         }
  6748.                                         else
  6749.                                         {
  6750.                                                 $Data['response'] = 'success';
  6751.                                                 $Data['result']['amount'] = '0';
  6752.                                                 $Data['result']['status'] = 'currentmnth';
  6753.                                         }
  6754.                                 }
  6755.                                 else
  6756.                                 {
  6757.                                         $Data['response'] = 'success';
  6758.                                         $Data['result']['amount'] = '0';
  6759.                                         $Data['result']['status'] = 'null';
  6760.                                 }
  6761.                         }
  6762.                         else
  6763.                         {
  6764.                                 $Data['response'] = 'success';
  6765.                                 $Data['result']['amount'] = $CheckPayment['amount'];
  6766.                                 $Data['result']['status'] = 'paid';
  6767.                         }
  6768.                 }
  6769.         }
  6770.         echo json_encode($Data);
  6771. }
  6772.  
  6773. public function country_admin_payments()
  6774. {
  6775.         // make payment
  6776.         if(isset($_POST['MP_submit']))
  6777.         {
  6778.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  6779.                 $this->form_validation->set_rules('MP_country_id','MP_country_id','trim|required|xss_clean');
  6780.                 $this->form_validation->set_rules('MP_year','MP_year','trim|required|xss_clean');
  6781.                 $this->form_validation->set_rules('MP_month','MP_month','trim|required|xss_clean');
  6782.                 $this->form_validation->set_rules('MP_remarks','MP_remarks','trim|required|xss_clean');
  6783.  
  6784.                 if($this->form_validation->run())
  6785.                 {
  6786.                         $MP_country_id = $this->input->post('MP_country_id');
  6787.                         $MP_year = $this->input->post('MP_year');
  6788.                         $MP_month = $this->input->post('MP_month');
  6789.                         $MP_remarks = $this->input->post('MP_remarks');
  6790.  
  6791.                         $Result = $this->Manage_model->get_country_admin_details($MP_country_id);
  6792.                         if(!empty($Result))
  6793.                         {
  6794.                                 $SDate = $MP_year.'-'.$MP_month.'-01';
  6795.                                 $CheckPayment = $this->Manage_model->check_admin_payment_done($MP_country_id,$SDate);
  6796.                                 if(empty($CheckPayment))
  6797.                                 {
  6798.                                         $StartDate = $MP_year.'-'.$MP_month.'-01 00:00:00';
  6799.                                         $EndDate = date('Y-m-t',strtotime($StartDate)).' 23:59:59';
  6800.  
  6801.                                         $Rate = $Result['rates'];
  6802.                                         $Percentage = $Result['percentage'];
  6803.  
  6804.                                         $PendingPayment = $this->Manage_model->monthly_wise_pending_payment_report($MP_country_id,$StartDate,$EndDate);
  6805.                                         if($PendingPayment!='')
  6806.                                         {
  6807.                                                 $CurrentMonthYear = date('Y-m-01');
  6808.                                                 if($CurrentMonthYear!=$SDate)
  6809.                                                 {
  6810.                                                         $Amnt = ((($PendingPayment/$Rate)*$Percentage)/100);
  6811.                                                         $FinalAmount = round($Amnt,2);
  6812.  
  6813.                                                         $SubAmount = round(($PendingPayment/$Rate),2);
  6814.  
  6815.                                                         $values = array('datetime'=>date('Y-m-d H:i:s'),
  6816.                                                                                         'country_admin_id'=>$Result['country_admin_id'],
  6817.                                                                                         'country_id'=>$MP_country_id,
  6818.                                                                                         'paid_month'=>$SDate,
  6819.                                                                                         'amount'=>$FinalAmount,
  6820.                                                                                         'rates'=>$Rate,
  6821.                                                                                         'percentage'=>$Percentage,
  6822.                                                                                         'subscription_amount'=>$SubAmount,
  6823.                                                                                         'remarks'=>$MP_remarks);
  6824.  
  6825.                                                         $this->Common_model->common_insert('country_admin_payments',$values);
  6826.                                                         $this->Common_model->Set_Message('1',"The amount $".$FinalAmount." is paid");
  6827.                                                 }
  6828.                                                 else
  6829.                                                 {
  6830.                                                         $this->Common_model->Set_Message('2',"You can't pay current month payments");
  6831.                                                 }
  6832.                                         }
  6833.                                         else
  6834.                                         {
  6835.                                                 $this->Common_model->Set_Message('1',"No subscriptions");
  6836.                                         }
  6837.                                 }
  6838.                                 else
  6839.                                 {
  6840.                                         $this->Common_model->Set_Message('1',"The amount $".$CheckPayment['amount']." is already paid");
  6841.                                 }
  6842.                         }
  6843.                         else
  6844.                         {
  6845.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  6846.                         }
  6847.                 }
  6848.                 else
  6849.                 {
  6850.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  6851.                 }
  6852.                 redirect(current_url());
  6853.         }
  6854.         // make payment
  6855.  
  6856.         # FILTER AND PAGINATION SECTION
  6857.         $URL = $this->uri->segment(1);
  6858.         $param[] = array('key'=>'country_admin_id','default'=>'');
  6859.         $param[] = array('key'=>'start_date','default'=>date('01/m/Y'));
  6860.         $param[] = array('key'=>'end_date','default'=>date('t/m/Y'));
  6861.         $FD = $this->Common_model->common_filter($URL,$param);
  6862.  
  6863.         $start = $limit = '';
  6864.         $page_ary['url'] = base_url($URL);
  6865.         $page_ary['total_rows'] = $this->Manage_model->country_admin_payments($FD,$start,$limit,'1')[0]->count;
  6866.         $limit = $page_ary['per_page'] = 30;
  6867.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  6868.         $data['page'] = $start = $PGN_DATA['page'];
  6869.         $data['links'] = $PGN_DATA['links'];
  6870.         # END OF FILTER AND PAGINATION SECTION
  6871.  
  6872.         $data['FD'] = $FD;
  6873.         $data['AD'] = $this->Manage_model->country_admin_payments($FD,$start,$limit,'0');
  6874.         $data['CAL'] = $this->Manage_model->view_country_admins_list();
  6875.  
  6876.         $this->CommonPage('organizations/country_admin_payments', $data, 'Country Admin Payments');
  6877. }
  6878. ############################################ END OF COUNTRY ADMINS PAYMENTS #######################
  6879.  
  6880. ############################################ COUNTRY ADMINS PAYMENTS FOR VIEW #####################
  6881. public function admin_payments()
  6882. {
  6883.         # FILTER AND PAGINATION SECTION
  6884.         $URL = $this->uri->segment(1);
  6885.         $FD = array();
  6886.  
  6887.         $country_id = $this->session->userdata('logged_in')['table_id']; // for country admin only
  6888.  
  6889.         $start = $limit = '';
  6890.         $page_ary['url'] = base_url($URL);
  6891.         $page_ary['total_rows'] = $this->Manage_model->country_admin_payments_view($country_id,$start,$limit,'1')[0]->count;
  6892.         $limit = $page_ary['per_page'] = 30;
  6893.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  6894.         $data['page'] = $start = $PGN_DATA['page'];
  6895.         $data['links'] = $PGN_DATA['links'];
  6896.         # END OF FILTER AND PAGINATION SECTION
  6897.  
  6898.         $data['FD'] = $FD;
  6899.         $data['AD'] = $this->Manage_model->country_admin_payments_view($country_id,$start,$limit,'0');
  6900.  
  6901.         $this->CommonPage('organizations/country_admin_payments_view', $data, 'Country Admin Payments');
  6902. }
  6903. ############################################ END OF COUNTRY ADMINS PAYMENTS FOR VIEW ##############
  6904.  
  6905. ############################################ VIEW PACKAGES PAYMENT STATUS #########################
  6906. public function view_packages_payment_status()
  6907. {
  6908.         $this->load->model('Payment_model');
  6909.         if(isset($_REQUEST['tranid']) && isset($_REQUEST['trackid'])) 
  6910.         {
  6911.                 $tranid = $_REQUEST['tranid'];
  6912.                 $trackid = $_REQUEST['trackid'];
  6913.                 $token = $_REQUEST['token'];
  6914.  
  6915.                 $Result = $this->Payment_model->check_payment_status($trackid,$tranid); // checking server response
  6916.                 $package_payments_id = str_replace('MPY', '', $trackid);
  6917.                 if(!empty($Result) && isset($Result->result) && $Result->result =='Successful') // payment status: success
  6918.                 {
  6919.                         $PaymentDetails = $this->Manage_model->get_payment_details($package_payments_id);
  6920.                         if(!empty($PaymentDetails))
  6921.                         {
  6922.                                 $datetime = date('Y-m-d H:i:s');
  6923.  
  6924.                                 // update payments table
  6925.                                 $PPWhere = array('package_payments_id'=>$package_payments_id);
  6926.                                 $PPValue = array('status'=>'1',
  6927.                                                                 'response_url'=>json_encode($_REQUEST),
  6928.                                                                 'response_data'=>json_encode($Result),
  6929.                                                                 'transactionid'=>$tranid,
  6930.                                                                 'token'=>$token);
  6931.                                 // update payments table
  6932.  
  6933.                                 if($PaymentDetails['package_type']=='0') // monthly package
  6934.                                 {
  6935.                                         $BuyDate = date('Y-m-d');
  6936.                                         $DueDate = date('Y-m-d', strtotime('+1 month'));
  6937.                                         $PreviousDate = date('Y-m-d', strtotime('-1 days'));
  6938.  
  6939.                                         $CheckSubscriptionExist = $this->Manage_model->check_payment_subscription_exist($PaymentDetails['package_payments_id'],$PaymentDetails['subscription_packages_id']);
  6940.                                         if(empty($CheckSubscriptionExist))
  6941.                                         {
  6942.                                                 // cancel previous subscriptions
  6943.                                                 if($CheckSubscriptionExist['due_date']<$BuyDate)
  6944.                                                 {
  6945.                                                         $Cancel_SP_value = array('status'=>'1');
  6946.                                                 }
  6947.                                                 else
  6948.                                                 {
  6949.                                                         $Cancel_SP_value = array('status'=>'2');
  6950.                                                 }
  6951.  
  6952.                                                 $Cancel_SP_where = array('status'=>'0','organizations_id'=>$PaymentDetails['organizations_id']);
  6953.                                                 $this->Common_model->common_update('package_subscriptions',$Cancel_SP_value,$Cancel_SP_where); // tbl package_subscriptions
  6954.  
  6955.                                                 $Cancel_ORG_value = array('meetings_count'=>'0','members_count'=>'0','events_count'=>'0','events_members_count'=>'0','dedicated_link_availability'=>'0','app_create_meeting_status'=>'0','multiple_locations_status'=>'0','follow_up_meeting_status'=>'0','advanced_security_level'=>'0','packge_validity_upto'=>$PreviousDate);
  6956.                                                 $Cancel_ORG_where = array('organizations_id'=>$PaymentDetails['organizations_id']);
  6957.                                                 $this->Common_model->common_update('organizations',$Cancel_ORG_value,$Cancel_ORG_where); // tbl organizations
  6958.                                                 // cancel previous subscriptions
  6959.  
  6960.                                                 // insert into package subscriptions
  6961.                                                 $SP_values = array( 'datetime'=>$datetime,
  6962.                                                                                         'organizations_id'=>$PaymentDetails['organizations_id'],
  6963.                                                                                         'subscription_packages_id'=>$PaymentDetails['subscription_packages_id'],
  6964.                                                                                         'package_payments_id'=>$PaymentDetails['package_payments_id'],
  6965.                                                                                         'buy_date'=>$BuyDate,
  6966.                                                                                         'due_date'=>$DueDate,
  6967.                                                                                         'status'=>'0',
  6968.                                                                                         'recurring_status'=>'0');
  6969.                                                 $package_subscriptions_id = $this->Common_model->common_insert('package_subscriptions',$SP_values);
  6970.                                                 // insert into package subscriptions
  6971.  
  6972.                                                 $PPValue['package_subscriptions_id'] = $package_subscriptions_id; // update subscription id to payments
  6973.  
  6974.                                                 // updating monthly packages in to organization table
  6975.                                                 $OrgWhere = array(  'organizations_id'=>$PaymentDetails['organizations_id']);
  6976.                                                 $OrgValue = array(    'meetings_count'=>$PaymentDetails['meetings_count'],
  6977.                                                                                         'members_count'=>$PaymentDetails['meeting_members_count'],
  6978.                                                                                         'events_count'=>$PaymentDetails['event_count'],
  6979.                                                                                         'events_members_count'=>$PaymentDetails['event_members_count'],
  6980.                                                                                         'dedicated_link_availability'=>$PaymentDetails['link_generation_status'],
  6981.                                                                                         'app_create_meeting_status'=>$PaymentDetails['app_create_meeting_status'],
  6982.                                                                                         'multiple_locations_status'=>$PaymentDetails['multiple_locations_status'],
  6983.                                                                                         'follow_up_meeting_status'=>$PaymentDetails['follow_up_meeting_status'],
  6984.                                                                                         'advanced_security_level'=>$PaymentDetails['advanced_security_level'],
  6985.                                                                                         'packge_validity_upto'=>$DueDate,
  6986.                                                                                         'subscription_packages_id'=>$PaymentDetails['subscription_packages_id']);
  6987.                                                 $this->Common_model->common_update('organizations',$OrgValue,$OrgWhere); // tbl organizations
  6988.                                                 // updating monthly packages in to organization table
  6989.  
  6990.                                                 //sent mail
  6991.                                                 $OD = $this->Manage_model->get_organization_details($PaymentDetails['organizations_id']);
  6992.                                                 $this->SentMail('9',$OD['email']);
  6993.                                                 //sent mail
  6994.  
  6995.                                                 //sent mail payment receipt
  6996.                                                 $CountryData = $this->Manage_model->get_organization_country_details();
  6997.  
  6998.                                                 if($PaymentDetails['package_category']==0){ $PaymentDetails['package_category'] = 'Professional Package'; }
  6999.                                                 elseif($PaymentDetails['package_category']==1){ $PaymentDetails['package_category'] = 'Business Package'; }
  7000.                                                 elseif($PaymentDetails['package_category']==2){ $PaymentDetails['package_category'] = 'Entrepreneur Package'; }
  7001.  
  7002.                                                 $data = array('Subject'=>'MEET PASS Payment Receipt','UserID'=>$OD['email'],'OrderID'=>$trackid,'Date'=>date('M d, Y',strtotime($BuyDate)),'NextDueDate'=>date('M d, Y',strtotime($DueDate)),'PackageName'=>$PaymentDetails['package_category'].' ('.$PaymentDetails['package_name'].')','PackageAmount'=>$PaymentDetails['amount'].' '.$CountryData['currency'],'BilledTo'=>$OD['name']);
  7003.                                                 $this->SentMail('11',$OD['email'],$data);
  7004.                                                 //sent mail payment receipt
  7005.                                         }
  7006.                                 }
  7007.                                 else // prepaid packages
  7008.                                 {
  7009.                                         $BuyDate = date('Y-m-d');
  7010.                                         $DueDate = date('Y-m-d', strtotime('+'.$PaymentDetails['days'].' days'));
  7011.  
  7012.                                         // insert into package_subscriptions_prepaid
  7013.                                         $SP_values = array( 'datetime'=>$datetime,
  7014.                                                                                 'organizations_id'=>$PaymentDetails['organizations_id'],
  7015.                                                                                 'subscription_packages_id'=>$PaymentDetails['subscription_packages_id'],
  7016.                                                                                 'package_payments_id'=>$PaymentDetails['package_payments_id'],
  7017.                                                                                 'meetings_count'=>$PaymentDetails['meetings_count'],
  7018.                                                                                 'members_count'=>$PaymentDetails['meeting_members_count'],
  7019.                                                                                 'events_count'=>$PaymentDetails['event_count'],
  7020.                                                                                 'events_members_count'=>$PaymentDetails['event_members_count'],
  7021.                                                                                 'buy_date'=>$BuyDate,
  7022.                                                                                 'due_date'=>$DueDate);
  7023.                                         $package_subscriptions_prepaid_id = $this->Common_model->common_insert('package_subscriptions_prepaid',$SP_values);
  7024.                                         // insert into package_subscriptions_prepaid
  7025.  
  7026.                                         $PPValue['package_subscriptions_prepaid_id'] = $package_subscriptions_prepaid_id; // update subscription id to payments
  7027.                                 }
  7028.  
  7029.                                 $this->Common_model->Set_Message('1','Payment success.');
  7030.                                 $this->Common_model->common_update('package_payments',$PPValue,$PPWhere); // update package payment details
  7031.                         }
  7032.                         else // payment status: failled
  7033.                         {
  7034.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Payment failled.');
  7035.                         }
  7036.                 }
  7037.                 else // payment status: failled
  7038.                 {
  7039.                         // update payments table
  7040.                         $where = array('package_payments_id'=>$package_payments_id);
  7041.                         $value = array( 'status'=>'2',
  7042.                                                         'response_url'=>json_encode($_REQUEST),
  7043.                                                         'response_data'=>json_encode($Result),
  7044.                                                         'transactionid'=>$tranid,
  7045.                                                         'token'=>$token);
  7046.                         $this->Common_model->common_update('package_payments',$value,$where);
  7047.  
  7048.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Payment failled.');
  7049.                 }              
  7050.         }
  7051.         redirect('view-packages'); // if empty of parameters
  7052. }
  7053. ############################################ END OF VIEW PACKAGES PAYMENT STATUS ##################
  7054.  
  7055. ############################################ VIEW PACKAGES ########################################
  7056. public function view_packages()
  7057. {
  7058.         $this->load->model('Payment_model');
  7059.         $CountryData = $this->Manage_model->get_organization_country_details();
  7060.         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  7061.  
  7062.         // if country is qatar - open this payment page
  7063.         #Buy New Package // Tyla Technologies
  7064.         if(isset($_POST['BuyNow']))
  7065.         {
  7066.                 $this->form_validation->set_rules('data_id','Data ID','trim|xss_clean|required');
  7067.                 if($this->form_validation->run())
  7068.                 {
  7069.                         $subscription_packages_id = $this->input->post('data_id');
  7070.  
  7071.                         // check organization available for this package
  7072.                         $PackageAvailability = '0';
  7073.                         $CheckAvailability = $this->Manage_model->check_package_available_for_organization($subscription_packages_id);
  7074.                         if(!empty($CheckAvailability))
  7075.                         {
  7076.                                 $PackageAvailability = '1';
  7077.                         }
  7078.                         else
  7079.                         {
  7080.                                 $CheckAvailability = $this->Manage_model->check_package_available_for_organization_dedicated($subscription_packages_id);
  7081.                                 if(!empty($CheckAvailability))
  7082.                                 {
  7083.                                         $PackageAvailability = '1';
  7084.                                 }
  7085.                         }
  7086.  
  7087.                         if($PackageAvailability=='1')
  7088.                         {
  7089.                                 $datetime = date('Y-m-d H:i:s');
  7090.                                 $amount = round($CheckAvailability['price']*$CountryData['rates']);  // in current rate
  7091.                                 $package_type = $CheckAvailability['package_type'];  // recurring or not
  7092.  
  7093.                                 $values = array('datetime'=>$datetime,
  7094.                                                                 'organizations_id'=>$organizations_id,
  7095.                                                                 'subscription_packages_id'=>$subscription_packages_id,
  7096.                                                                 'package_type'=>$package_type,
  7097.                                                                 'amount'=>$amount);
  7098.                                 $package_payments_id = $this->Common_model->common_insert('package_payments',$values);
  7099.  
  7100.                                 // Generating Payment URL
  7101.                                 $RequestData = $this->Payment_model->generate_payment_url($package_payments_id,$amount,$package_type);
  7102.                                
  7103.                                 // Update Request URL
  7104.                                 $where = array('package_payments_id'=>$package_payments_id);
  7105.                                 $value = array('request_parameters'=>$RequestData['request_parameters'],'request_url'=>$RequestData['request_url']);
  7106.                                 $this->Common_model->common_update('package_payments',$value,$where);
  7107.  
  7108.                                 redirect($RequestData['request_url']);
  7109.                         }
  7110.                         else
  7111.                         {
  7112.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  7113.                         }
  7114.                 }
  7115.                 else
  7116.                 {
  7117.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  7118.                 }
  7119.                 redirect(current_url());
  7120.         }
  7121.         #Buy New Package
  7122.  
  7123.         # FILTER AND PAGINATION SECTION
  7124.         $FD = array();
  7125.         $URL = $this->uri->segment(1);
  7126.         $start = $limit = '';
  7127.         $page_ary['url'] = base_url($URL);
  7128.         $page_ary['total_rows'] = $this->Manage_model->view_packages($FD,$start,$limit,'1')[0]->count;
  7129.         $limit = $page_ary['per_page'] = 10;
  7130.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  7131.         $data['page'] = $start = $PGN_DATA['page'];
  7132.         $data['links'] = $PGN_DATA['links'];
  7133.         # END OF FILTER AND PAGINATION SECTION
  7134.  
  7135.         $data['MonthlyPackage'] = $this->Manage_model->view_monthly_packages($FD,$start,$limit,'0');
  7136.         $data['PrepaidPackage'] = array();
  7137.         $data['SpecialPackage'] = $this->Manage_model->view_dedicated_packages($FD,$start,$limit,'0');
  7138.  
  7139.         $OD = $this->Manage_model->get_organization_details($organizations_id);
  7140.        
  7141.         if($OD['subscription_packages_id']!='0')
  7142.         {
  7143.                 $data['CurrentPackage'] = $this->Manage_model->view_current_package_details($OD['subscription_packages_id']);
  7144.                 //print_r($data['CurrentPackage']); die();
  7145.         }
  7146.         else
  7147.         {
  7148.                 $data['CurrentPackage'] = array('subscription_packages_id'=>'0','package_category'=>'4','package_name'=>'14 Days Trial Package','price'=>'0','meetings_count'=>'10','meeting_members_count'=>'10','event_count'=>'2','event_members_count'=>'25','link_generation_status'=>'1','app_create_meeting_status'=>'1','multiple_locations_status'=>'1');
  7149.         }
  7150.  
  7151.         $data['CountryData'] = $CountryData;
  7152.         $data['OD'] = $OD;
  7153.  
  7154.         $this->CommonPage('organizations/view_packages',$data,'List of subscription packages');
  7155. }
  7156. ############################################ END OF VIEW PACKAGES #################################
  7157.  
  7158. ############################################ STRIPE PAYMENT CARD DETAILS PAGE #####################
  7159. public function subscription_payment()
  7160. {
  7161.         $CountryData = $this->Manage_model->get_organization_country_details();
  7162.         if(isset($_POST['BuyNow']))
  7163.         {
  7164.                 $this->form_validation->set_rules('data_id','Data ID','trim|xss_clean|required');
  7165.                 if($this->form_validation->run())
  7166.                 {
  7167.                         $subscription_packages_id = $this->input->post('data_id');
  7168.  
  7169.                         // check organization available for this package
  7170.                         $PackageAvailability = '0';
  7171.                         $CheckAvailability = $this->Manage_model->check_package_available_for_organization($subscription_packages_id);
  7172.                         if(!empty($CheckAvailability))
  7173.                         {
  7174.                                 $PackageAvailability = '1';
  7175.                         }
  7176.                         else
  7177.                         {
  7178.                                 $CheckAvailability = $this->Manage_model->check_package_available_for_organization_dedicated($subscription_packages_id);
  7179.                                 if(!empty($CheckAvailability))
  7180.                                 {
  7181.                                         $PackageAvailability = '1';
  7182.                                 }
  7183.                         }
  7184.  
  7185.                         if($PackageAvailability=='1')
  7186.                         {
  7187.                                 $organizations_id = $this->session->userdata('logged_in')['table_id'];
  7188.                                 $data['OD'] = $this->Manage_model->get_organization_details($organizations_id);
  7189.  
  7190.                                 $datetime = date('Y-m-d H:i:s');
  7191.                                 $amount = round($CheckAvailability['price']*$CountryData['rates']);  // in current rate
  7192.                                 $package_type = $CheckAvailability['package_type'];  // recurring or not
  7193.  
  7194.                                 $values = array('datetime'=>$datetime,
  7195.                                                                 'organizations_id'=>$organizations_id,
  7196.                                                                 'subscription_packages_id'=>$subscription_packages_id,
  7197.                                                                 'package_type'=>$package_type,
  7198.                                                                 'amount'=>$amount,
  7199.                                                                 'payment_gateway'=>'1',
  7200.                                                                 'currency'=>$CountryData['currency']);
  7201.                                 $package_payments_id = $this->Common_model->common_insert('package_payments',$values);
  7202.  
  7203.                                 $CheckAvailability['amount'] = $amount;
  7204.                                 $CheckAvailability['currency'] = $CountryData['currency'];
  7205.                                 $CheckAvailability['package_payments_id'] = $package_payments_id;
  7206.  
  7207.                                 $data['PD'] = $CheckAvailability;
  7208.                                 $this->load->view('organizations/stripe_payment', $data);
  7209.                         }
  7210.                         else
  7211.                         {
  7212.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  7213.                                 redirect('view-packages');
  7214.                         }
  7215.                 }
  7216.                 else
  7217.                 {
  7218.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  7219.                         redirect('view-packages');
  7220.                 }
  7221.         }
  7222.         else
  7223.         {
  7224.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  7225.                 redirect('view-packages');
  7226.         }
  7227. }
  7228. ############################################ END OF STRIPE PAYMENT CARD DETAILS PAGE ##############
  7229.  
  7230. ############################################ STRIPE PAYMENT SUBMIT ################################
  7231. public function subscription_payment_submit()
  7232. {
  7233.         //include Stripe PHP library
  7234.         require_once APPPATH."third_party/stripe/init.php";
  7235.  
  7236.         $data['value']=$this->input->post('plan_val');
  7237.         if(!empty($_POST['stripeToken']))
  7238.         {
  7239.                 $organizations_id = $this->session->userdata('logged_in')['table_id'];
  7240.                 $OD = $this->Manage_model->get_organization_details($organizations_id);
  7241.  
  7242.                 //get token, card and user info from the form
  7243.                 $name = trim($OD['name']);
  7244.                 $email = trim($OD['email']);
  7245.                 $token  = trim($_POST['stripeToken']);
  7246.                 $planname = trim($_POST['plan_name_fr']);
  7247.                 $planval = trim($_POST['plan_val_fr']);
  7248.                 $package_payments_id = trim($_POST['package_payments_id']);
  7249.  
  7250.                 // Update Request URL
  7251.                 $where = array('package_payments_id'=>$package_payments_id);
  7252.                 $value = array('stripe_temp_token'=>$token);
  7253.                 $this->Common_model->common_update('package_payments',$value,$where);
  7254.  
  7255.                 //set api key
  7256.                 $stripe = array("secret_key"=>$this->config->item('StripeSecretKey'),"publishable_key"=>$this->config->item('StripePublicKey'));
  7257.  
  7258.                 \Stripe\Stripe::setApiKey($stripe['secret_key']);
  7259.  
  7260.                 //add customer to stripe
  7261.                 $customer = \Stripe\Customer::create(array('email'=>$email,'source'=>$token));
  7262.  
  7263.                 //item information
  7264.                 $currency = $_POST['currency'];
  7265.                 $plan = $_POST['plan_name_fr'];
  7266.                 $amount1 = $_POST['plan_val_fr'];
  7267.                 $amount =(int)$amount1*100;
  7268.                 $plan = \Stripe\Plan::create(array("product"=>["name"=>$plan],
  7269.                                                                                         "amount"=>$amount,
  7270.                                                                                         "currency"=>$currency,
  7271.                                                                                         "interval"=>"month",
  7272.                                                                                         "interval_count"=>'1'));
  7273.  
  7274.                 // Add the plan to the customer (subscribe the customer)
  7275.                 $subscription = \Stripe\Subscription::create(array("customer"=>$customer->id,"items"=>array(array("plan"=>$plan->id))));
  7276.  
  7277.                 //retrieve charge details
  7278.                 $chargeJson = $subscription->jsonSerialize();
  7279.                 $created_date = date('d-m-Y', $subscription->created);
  7280.                 $current_period_start_date = date('d-m-Y', $subscription->current_period_start);
  7281.                 $current_period_end_date = date('d-m-Y', $subscription->current_period_end);
  7282.  
  7283.                 if($subscription->status=='active')
  7284.                 {
  7285.                         $PaymentDetails = $this->Manage_model->get_payment_details($package_payments_id);
  7286.                         if(!empty($PaymentDetails))
  7287.                         {
  7288.                                 $datetime = date('Y-m-d H:i:s');
  7289.  
  7290.                                 // update payments table
  7291.                                 $PPWhere = array('package_payments_id'=>$package_payments_id);
  7292.                                 $PPValue = array('status'=>'1','response_data'=>json_encode($subscription));
  7293.                                 // update payments table
  7294.  
  7295.                                 if($PaymentDetails['package_type']=='0') // monthly package
  7296.                                 {
  7297.                                         $BuyDate = date('Y-m-d');
  7298.                                         $DueDate = date('Y-m-d', strtotime('+1 month'));
  7299.                                         $PreviousDate = date('Y-m-d', strtotime('-1 days'));
  7300.  
  7301.                                         $CheckSubscriptionExist = $this->Manage_model->check_payment_subscription_exist($PaymentDetails['package_payments_id'],$PaymentDetails['subscription_packages_id']);
  7302.                                         if(empty($CheckSubscriptionExist))
  7303.                                         {
  7304.                                                 // cancel previous subscriptions
  7305.                                                 if($CheckSubscriptionExist['due_date']<$BuyDate)
  7306.                                                 {
  7307.                                                         $Cancel_SP_value = array('status'=>'1');
  7308.                                                 }
  7309.                                                 else
  7310.                                                 {
  7311.                                                         $Cancel_SP_value = array('status'=>'2');
  7312.                                                 }
  7313.  
  7314.                                                 $Cancel_SP_where = array('status'=>'0','organizations_id'=>$PaymentDetails['organizations_id']);
  7315.                                                 $this->Common_model->common_update('package_subscriptions',$Cancel_SP_value,$Cancel_SP_where); // tbl package_subscriptions
  7316.  
  7317.                                                 $Cancel_ORG_value = array('meetings_count'=>'0','members_count'=>'0','events_count'=>'0','events_members_count'=>'0','dedicated_link_availability'=>'0','app_create_meeting_status'=>'0','multiple_locations_status'=>'0','follow_up_meeting_status'=>'0','advanced_security_level'=>'0','packge_validity_upto'=>$PreviousDate);
  7318.                                                 $Cancel_ORG_where = array('organizations_id'=>$PaymentDetails['organizations_id']);
  7319.                                                 $this->Common_model->common_update('organizations',$Cancel_ORG_value,$Cancel_ORG_where); // tbl organizations
  7320.                                                 // cancel previous subscriptions
  7321.  
  7322.                                                 // insert into package subscriptions
  7323.                                                 $SP_values = array( 'datetime'=>$datetime,
  7324.                                                                                         'organizations_id'=>$PaymentDetails['organizations_id'],
  7325.                                                                                         'subscription_packages_id'=>$PaymentDetails['subscription_packages_id'],
  7326.                                                                                         'package_payments_id'=>$PaymentDetails['package_payments_id'],
  7327.                                                                                         'buy_date'=>$BuyDate,
  7328.                                                                                         'due_date'=>$DueDate,
  7329.                                                                                         'status'=>'0',
  7330.                                                                                         'recurring_status'=>'0',
  7331.                                                                                         'payment_gateway'=>'1',
  7332.                                                                                         'stripe_temp_token'=>$token,
  7333.                                                                                         'currency'=>$subscription->items->data[0]->price->currency,
  7334.                                                                                         'subscription_id'=>$subscription->id,
  7335.                                                                                         'subscription_customer_id'=>$subscription->customer,
  7336.                                                                                         'subscription_item_id'=>$subscription->items->data[0]->id);
  7337.                                                 $package_subscriptions_id = $this->Common_model->common_insert('package_subscriptions',$SP_values);
  7338.                                                 // insert into package subscriptions
  7339.  
  7340.                                                 $PPValue['package_subscriptions_id'] = $package_subscriptions_id; // update subscription id to payments
  7341.  
  7342.                                                 // updating monthly packages in to organization table
  7343.                                                 $OrgWhere = array(  'organizations_id'=>$PaymentDetails['organizations_id']);
  7344.                                                 $OrgValue = array(    'meetings_count'=>$PaymentDetails['meetings_count'],
  7345.                                                                                         'members_count'=>$PaymentDetails['meeting_members_count'],
  7346.                                                                                         'events_count'=>$PaymentDetails['event_count'],
  7347.                                                                                         'events_members_count'=>$PaymentDetails['event_members_count'],
  7348.                                                                                         'dedicated_link_availability'=>$PaymentDetails['link_generation_status'],
  7349.                                                                                         'app_create_meeting_status'=>$PaymentDetails['app_create_meeting_status'],
  7350.                                                                                         'multiple_locations_status'=>$PaymentDetails['multiple_locations_status'],
  7351.                                                                                         'follow_up_meeting_status'=>$PaymentDetails['follow_up_meeting_status'],
  7352.                                                                                         'advanced_security_level'=>$PaymentDetails['advanced_security_level'],
  7353.                                                                                         'packge_validity_upto'=>$DueDate,
  7354.                                                                                         'subscription_packages_id'=>$PaymentDetails['subscription_packages_id']);
  7355.                                                 $this->Common_model->common_update('organizations',$OrgValue,$OrgWhere); // tbl organizations
  7356.                                                 // updating monthly packages in to organization table
  7357.  
  7358.                                                 //sent mail
  7359.                                                 $OD = $this->Manage_model->get_organization_details($PaymentDetails['organizations_id']);
  7360.                                                 $this->SentMail('9',$OD['email']);
  7361.                                                 //sent mail
  7362.  
  7363.                                                 //sent mail payment receipt
  7364.                                                 $CountryData = $this->Manage_model->get_organization_country_details();
  7365.  
  7366.                                                 $trackid = 'MPY'.sprintf("%05d", $PaymentDetails['package_payments_id']);
  7367.  
  7368.                                                 if($PaymentDetails['package_category']==0){ $PaymentDetails['package_category'] = 'Professional Package'; }
  7369.                                                 elseif($PaymentDetails['package_category']==1){ $PaymentDetails['package_category'] = 'Business Package'; }
  7370.                                                 elseif($PaymentDetails['package_category']==2){ $PaymentDetails['package_category'] = 'Entrepreneur Package'; }
  7371.  
  7372.                                                 $data = array('Subject'=>'MEET PASS Payment Receipt','UserID'=>$OD['email'],'OrderID'=>$trackid,'Date'=>date('M d, Y',strtotime($BuyDate)),'NextDueDate'=>date('M d, Y',strtotime($DueDate)),'PackageName'=>$PaymentDetails['package_category'].' ('.$PaymentDetails['package_name'].')','PackageAmount'=>$PaymentDetails['amount'].' '.$CountryData['currency'],'BilledTo'=>$OD['name']);
  7373.                                                 $this->SentMail('11',$OD['email'],$data);
  7374.                                                 //sent mail payment receipt
  7375.                                         }
  7376.                                 }
  7377.  
  7378.                                 $this->Common_model->Set_Message('1','Payment success.');
  7379.                                 $this->Common_model->common_update('package_payments',$PPValue,$PPWhere); // update package payment details
  7380.                         }
  7381.                         else // payment status: failled
  7382.                         {
  7383.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Payment failled.');
  7384.                         }
  7385.                 }
  7386.                 else // payment status: failled
  7387.                 {
  7388.                         // update payments table
  7389.                         $where = array('package_payments_id'=>$package_payments_id);
  7390.                         $value = array( 'status'=>'2','response_data'=>json_encode($subscription));
  7391.                         $this->Common_model->common_update('package_payments',$value,$where);
  7392.  
  7393.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Payment failled.');
  7394.                 }
  7395.         }
  7396.         redirect('view-packages');
  7397. }
  7398. ############################################ END OF STRIPE PAYMENT SUBMIT #########################
  7399.  
  7400. ############################################ VIEW ADDRESS #########################################
  7401. public function get_address_data()
  7402. {
  7403.         $Data['response'] = 'failed';
  7404.         $Data['result'] = array();
  7405.  
  7406.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  7407.         if($this->form_validation->run())
  7408.         {
  7409.                 $data_id = $this->input->post('data_id');
  7410.                 $select = array('organizations_address_id,location,latitude,longitude,building_name,building_number,floor_number,office_number,near_landmark');
  7411.                 $where = array('organizations_address_id'=>$data_id);
  7412.                 $Result = $this->Common_model->globalfetch('organizations_address',$select,$where);
  7413.                 if(!empty($Result))
  7414.                 {
  7415.                         $Data['response'] = 'success';
  7416.                         $Data['result'] = $Result;
  7417.                 }
  7418.         }
  7419.         echo json_encode($Data);
  7420. }
  7421.  
  7422. public function view_address()
  7423. {
  7424.         # INSERT / UPDATE FUNCTION
  7425.         if(isset($_POST['submit']))
  7426.         {
  7427.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  7428.                 $this->form_validation->set_rules('location','Location','trim|required|xss_clean');
  7429.                 $this->form_validation->set_rules('latitude','Latitude','trim|required|xss_clean|numeric');
  7430.                 $this->form_validation->set_rules('longitude','Longitude','trim|required|xss_clean|numeric');
  7431.                 $this->form_validation->set_rules('building_name','Building Name','trim|required|xss_clean');
  7432.                 $this->form_validation->set_rules('building_number','Building Number','trim|required|xss_clean');
  7433.                 $this->form_validation->set_rules('floor_number','Floor Number','trim|required|xss_clean');
  7434.                 $this->form_validation->set_rules('office_number','Office Number','trim|required|xss_clean');
  7435.                 $this->form_validation->set_rules('near_landmark','Near Landmark','trim|required|xss_clean');
  7436.  
  7437.                 if($this->input->post('submit')=='Save')
  7438.                 {
  7439.                         $this->form_validation->set_rules('organizations_address_id','Organizations Address ID','trim|xss_clean');
  7440.                 }
  7441.                 else
  7442.                 {
  7443.                         $this->form_validation->set_rules('organizations_address_id','Organizations Address ID','trim|xss_clean|numeric|required');
  7444.                 }
  7445.  
  7446.                 if($this->form_validation->run())
  7447.                 {
  7448.                         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  7449.  
  7450.                         $location = $this->input->post('location');
  7451.                         $latitude = $this->input->post('latitude');
  7452.                         $longitude = $this->input->post('longitude');
  7453.                         $building_name = $this->input->post('building_name');
  7454.                         $building_number = $this->input->post('building_number');
  7455.                         $floor_number = $this->input->post('floor_number');
  7456.                         $office_number = $this->input->post('office_number');
  7457.                         $near_landmark = $this->input->post('near_landmark');
  7458.                         $organizations_address_id = $this->input->post('organizations_address_id');
  7459.                         $submit = $this->input->post('submit');
  7460.  
  7461.                         $values = array('organizations_id'=>$organizations_id,
  7462.                                                         'location'=>$location,
  7463.                                                         'latitude'=>$latitude,
  7464.                                                         'longitude'=>$longitude,
  7465.                                                         'building_name'=>$building_name,
  7466.                                                         'building_number'=>$building_number,
  7467.                                                         'floor_number'=>$floor_number,
  7468.                                                         'office_number'=>$office_number,
  7469.                                                         'near_landmark'=>$near_landmark);
  7470.  
  7471.                         if($submit=='Save')
  7472.                         {
  7473.                                 $values['datetime'] = date('Y-m-d H:i:s');
  7474.                                 $organizations_address_id = $this->Common_model->common_insert('organizations_address',$values);
  7475.                                 $this->Common_model->Set_Message('1',"Address added successfully.");
  7476.  
  7477.                                 // Activity Log Record
  7478.                                 $head = 'Add Address';
  7479.                                 $description = 'Address Details Has Been Added By ';
  7480.                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('organizations_address_id'=>$organizations_address_id),'5');
  7481.                                 // Activity Log Record
  7482.                         }
  7483.                         else
  7484.                         {
  7485.                                 $where = array('organizations_address_id'=>$organizations_address_id);
  7486.                                 $this->Common_model->common_update('organizations_address',$values,$where);
  7487.                                 $this->Common_model->Set_Message('1',"Address details updated successfully.");
  7488.  
  7489.                                 // Activity Log Record
  7490.                                 $head = 'Update Address';
  7491.                                 $description = 'Address Details Has Been Updated By ';
  7492.                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('organizations_address_id'=>$organizations_address_id),'5');
  7493.                                 // Activity Log Record
  7494.                         }
  7495.                         redirect(current_url());
  7496.                 }
  7497.                 else
  7498.                 {
  7499.                         if($this->input->post('submit')=='Update')
  7500.                         {
  7501.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  7502.                                 redirect(current_url());
  7503.                         }
  7504.                 }
  7505.         }
  7506.         # END OF INSERT / UPDATE FUNCTION
  7507.  
  7508.         # DELETE FUNCTION
  7509.         if(isset($_POST['delete']))
  7510.         {
  7511.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  7512.                 if($this->form_validation->run())
  7513.                 {
  7514.                         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  7515.                         $delete_id = $this->input->post('delete_id');
  7516.  
  7517.                         $where = array('organizations_address_id'=>$delete_id);
  7518.                         $value = array('organizations_address_status'=>'1');
  7519.                         $this->Common_model->common_update('organizations_address',$value,$where);
  7520.                         $this->Common_model->Set_Message('1','address removed successfully.');
  7521.  
  7522.                         // Activity Log Record
  7523.                         $head = 'Remove Address';
  7524.                         $description = 'Address Details Has Been Removed By ';
  7525.                         $this->Common_model->create_activity_log($head,$description,'',array(),array('organizations_address_id'=>$delete_id),'5');
  7526.                         // Activity Log Record
  7527.                 }
  7528.                 else
  7529.                 {
  7530.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  7531.                 }
  7532.                 redirect(current_url());
  7533.         }
  7534.         # END OF DELETE FUNCTION
  7535.  
  7536.         # FILTER AND PAGINATION SECTION
  7537.         $URL = $this->uri->segment(1);
  7538.         $FD = array();;
  7539.  
  7540.         $start = $limit = '';
  7541.         $page_ary['url'] = base_url($URL);
  7542.         $page_ary['total_rows'] = $this->Manage_model->view_address($FD,$start,$limit,'1')[0]->count;
  7543.         $limit = $page_ary['per_page'] = 30;
  7544.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  7545.         $data['page'] = $start = $PGN_DATA['page'];
  7546.         $data['links'] = $PGN_DATA['links'];
  7547.         # END OF FILTER AND PAGINATION SECTION
  7548.  
  7549.         $data['FD'] = $FD;
  7550.         $data['AD'] = $this->Manage_model->view_address($FD,$start,$limit,'0');
  7551.  
  7552.         $this->CommonPage('organizations/view_address',$data,'List of address');
  7553. }
  7554. ############################################ END OF VIEW ADDRESS ##################################
  7555.  
  7556. ############################################ STRIPE CHECKOUT ######################################
  7557. public function stripe_payment_page()
  7558. {
  7559.         $CountryData = $this->Manage_model->get_organization_country_details();
  7560.         if(isset($_POST['BuyNow']))
  7561.         {
  7562.                 $this->form_validation->set_rules('data_id','Data ID','trim|xss_clean|required');
  7563.                 if($this->form_validation->run())
  7564.                 {
  7565.                         $subscription_packages_id = $this->input->post('data_id');
  7566.  
  7567.                         // check organization available for this package
  7568.                         $PackageAvailability = '0';
  7569.                         $CheckAvailability = $this->Manage_model->check_package_available_for_organization($subscription_packages_id);
  7570.                         if(!empty($CheckAvailability))
  7571.                         {
  7572.                                 $PackageAvailability = '1';
  7573.                         }
  7574.                         else
  7575.                         {
  7576.                                 $CheckAvailability = $this->Manage_model->check_package_available_for_organization_dedicated($subscription_packages_id);
  7577.                                 if(!empty($CheckAvailability))
  7578.                                 {
  7579.                                         $PackageAvailability = '1';
  7580.                                 }
  7581.                         }
  7582.  
  7583.                         if($PackageAvailability=='1')
  7584.                         {
  7585.                                 $organizations_id = $this->session->userdata('logged_in')['table_id'];
  7586.                                 $data['OD'] = $this->Manage_model->get_organization_details($organizations_id);
  7587.  
  7588.                                 $datetime = date('Y-m-d H:i:s');
  7589.                                 $amount = round($CheckAvailability['price']*$CountryData['rates']);  // in current rate
  7590.                                 $package_type = $CheckAvailability['package_type'];  // recurring or not
  7591.  
  7592.                                 $values = array('datetime'=>$datetime,
  7593.                                                                 'organizations_id'=>$organizations_id,
  7594.                                                                 'subscription_packages_id'=>$subscription_packages_id,
  7595.                                                                 'package_type'=>$package_type,
  7596.                                                                 'amount'=>$amount,
  7597.                                                                 'payment_gateway'=>'1',
  7598.                                                                 'currency'=>$CountryData['currency']);
  7599.                                 $package_payments_id = $this->Common_model->common_insert('package_payments',$values);
  7600.  
  7601.                                 $CheckAvailability['amount'] = $amount;
  7602.                                 $CheckAvailability['currency'] = $CountryData['currency'];
  7603.                                 $CheckAvailability['package_payments_id'] = $package_payments_id;
  7604.  
  7605.                                 $data['PD'] = $CheckAvailability;
  7606.                                 $data['package_payments_id'] = $package_payments_id;
  7607.                                 $this->load->view('organizations/stripe_payment_page', $data);
  7608.                         }
  7609.                         else
  7610.                         {
  7611.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  7612.                                 redirect('view-packages');
  7613.                         }
  7614.                 }
  7615.                 else
  7616.                 {
  7617.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  7618.                         redirect('view-packages');
  7619.                 }
  7620.         }
  7621.         else
  7622.         {
  7623.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  7624.                 redirect('view-packages');
  7625.         }
  7626. }
  7627. ############################################ END OF STRIPE CHECKOUT ###############################
  7628.  
  7629. ############################################ STRIPE CHECKOUT AJAX #################################
  7630. public function stripe_payment_page_ajax()
  7631. {
  7632.         $response = array('status' => 0,'error' => array('message' => 'error'));
  7633.         if(isset($_POST['subscription_packages_id']))
  7634.         {
  7635.                 $this->form_validation->set_rules('subscription_packages_id','subscription_packages_id','trim|required|xss_clean|numeric');
  7636.                 $this->form_validation->set_rules('package_payments_id','package_payments_id','trim|required|xss_clean|numeric');
  7637.                 if($this->form_validation->run())
  7638.                 {
  7639.                         $subscription_packages_id = $this->input->post('subscription_packages_id');
  7640.                         $package_payments_id = $this->input->post('package_payments_id');
  7641.  
  7642.                         $SD = $this->Manage_model->view_current_package_details_new($subscription_packages_id);
  7643.                         if(!empty($SD) && $SD['stripe_subscription_id']!='')
  7644.                         {
  7645.                                 require_once APPPATH."third_party/stripe-php/init.php";
  7646.                          
  7647.                                 \Stripe\Stripe::setApiKey($this->config->item('StripeSecretKey')); 
  7648.                                 $stripeAmount = round(10*100, 2); 
  7649.  
  7650.                                 // Create new Checkout Session for the order 
  7651.                                 try {
  7652.                                         $checkout_session = \Stripe\Checkout\Session::create([ 
  7653.                                                 'success_url' => base_url('Paymentsuccess/?session_id={CHECKOUT_SESSION_ID}'),
  7654.                                                 'cancel_url' => base_url('Paymentsuccess'),
  7655.                                                 'mode' => 'subscription',
  7656.                                                 'payment_method_types' => ['card'],
  7657.                                                 'mode' => 'subscription',
  7658.                                                 'line_items' => [[
  7659.                                                         'price' => $SD['stripe_subscription_id'],
  7660.                                                         // For metered billing, do not pass quantity
  7661.                                                         'quantity' => 1,
  7662.                                                 ]],
  7663.                                         ]);
  7664.                                 }
  7665.                                 catch(Exception $e)
  7666.                                 {
  7667.                                         $api_error = $e->getMessage();
  7668.                                 }
  7669.  
  7670.                                 if(empty($api_error) && $checkout_session)
  7671.                                 {
  7672.                                         $response = array('status' => 1,'message' => 'Checkout Session created successfully!','sessionId' => $checkout_session->id);
  7673.  
  7674.                                         // Update Request URL
  7675.                                         $where = array('package_payments_id'=>$package_payments_id,'subscription_packages_id'=>$subscription_packages_id);
  7676.                                         $value = array('stripe_session_id'=>$checkout_session->id);
  7677.                                         $this->Common_model->common_update('package_payments',$value,$where);
  7678.                                 }
  7679.                                 else
  7680.                                 {
  7681.                                         $response = array('status' => 0,'error' => array('message' => 'Checkout Session creation failed! '.$api_error));
  7682.                                 }
  7683.                         }
  7684.                 }
  7685.         }
  7686.  
  7687.         // Return response
  7688.         echo json_encode($response);
  7689. }
  7690. ############################################ END OF STRIPE CHECKOUT AJAX ##########################
  7691.  
  7692. ############################################ STRIPE CHECKOUT CALLBACK #############################
  7693. public function Paymentsuccess()
  7694. {
  7695.         if(isset($_GET['session_id']) &&!empty($_GET['session_id']) && $_GET['session_id']!='')
  7696.         {
  7697.                 $organizations_id = $this->session->userdata('logged_in')['table_id'];
  7698.                 $OD = $this->Manage_model->get_organization_details($organizations_id);
  7699.  
  7700.                 require_once APPPATH."third_party/stripe-php/init.php";
  7701.                 $stripe = new \Stripe\StripeClient($this->config->item('StripeSecretKey'));
  7702.  
  7703.                 $SessionID = trim($_GET['session_id']);
  7704.  
  7705.                 $ResultData = $stripe->checkout->sessions->retrieve($SessionID,[]);
  7706.  
  7707.                 /*cs_test_a1BCgCQfT5WJXaUL1wT7Ccsq07lcMSByOT500HYvaCi49Wqe8DEsf7NrPJ
  7708.                 cs_test_a1BCgCQfT5WJXaUL1wT7Ccsq07lcMSByOT500HYvaCi49Wqe8DEsf7NrPJ*/
  7709.                
  7710.  
  7711.                 //get token, card and user info from the form
  7712.  
  7713.                 //set api key
  7714.                
  7715.  
  7716.                 //retrieve charge details
  7717.                 $chargeJson = $ResultData->jsonSerialize();
  7718.  
  7719.                 // echo '<pre>';
  7720.                 // print_r($chargeJson);
  7721.  
  7722.                 // echo $ResultData->status;
  7723.                 // echo $ResultData->payment_status;
  7724.                 // echo $ResultData->subscription;
  7725.                 // die;
  7726.  
  7727.                 // $created_date = date('d-m-Y', $ResultData->created);
  7728.                 // $current_period_start_date = date('d-m-Y', $ResultData->current_period_start);
  7729.                 // $current_period_end_date = date('d-m-Y', $ResultData->current_period_end);
  7730.  
  7731.                 $PaymentDetails = $this->Manage_model->get_payment_details_stripe_session($SessionID);
  7732.                 if(!empty($PaymentDetails))
  7733.                 {
  7734.                         if($ResultData->status=='complete' && $ResultData->payment_status=='paid')
  7735.                         {
  7736.                                 $datetime = date('Y-m-d H:i:s');
  7737.                                 $package_payments_id = $PaymentDetails['package_payments_id'];
  7738.  
  7739.                                 // update payments table
  7740.                                 $PPWhere = array('package_payments_id'=>$package_payments_id);
  7741.                                 $PPValue = array('status'=>'1','response_data'=>json_encode($ResultData));
  7742.                                 // update payments table
  7743.  
  7744.                                 if($PaymentDetails['package_type']=='0') // monthly package
  7745.                                 {
  7746.                                         $BuyDate = date('Y-m-d');
  7747.                                         $DueDate = date('Y-m-d', strtotime('+1 month'));
  7748.                                         $PreviousDate = date('Y-m-d', strtotime('-1 days'));
  7749.  
  7750.                                         $CheckSubscriptionExist = $this->Manage_model->check_payment_subscription_exist($PaymentDetails['package_payments_id'],$PaymentDetails['subscription_packages_id']);
  7751.                                         if(empty($CheckSubscriptionExist))
  7752.                                         {
  7753.                                                 // cancel previous subscriptions
  7754.                                                 if($CheckSubscriptionExist['due_date']<$BuyDate)
  7755.                                                 {
  7756.                                                         $Cancel_SP_value = array('status'=>'1');
  7757.                                                 }
  7758.                                                 else
  7759.                                                 {
  7760.                                                         $Cancel_SP_value = array('status'=>'2');
  7761.                                                 }
  7762.  
  7763.                                                 $Cancel_SP_where = array('status'=>'0','organizations_id'=>$PaymentDetails['organizations_id']);
  7764.                                                 $this->Common_model->common_update('package_subscriptions',$Cancel_SP_value,$Cancel_SP_where); // tbl package_subscriptions
  7765.  
  7766.                                                 $Cancel_ORG_value = array('meetings_count'=>'0','members_count'=>'0','events_count'=>'0','events_members_count'=>'0','dedicated_link_availability'=>'0','app_create_meeting_status'=>'0','multiple_locations_status'=>'0','follow_up_meeting_status'=>'0','advanced_security_level'=>'0','packge_validity_upto'=>$PreviousDate);
  7767.                                                 $Cancel_ORG_where = array('organizations_id'=>$PaymentDetails['organizations_id']);
  7768.                                                 $this->Common_model->common_update('organizations',$Cancel_ORG_value,$Cancel_ORG_where); // tbl organizations
  7769.                                                 // cancel previous subscriptions
  7770.  
  7771.                                                 // insert into package subscriptions
  7772.                                                 $SP_values = array( 'datetime'=>$datetime,
  7773.                                                                                         'organizations_id'=>$PaymentDetails['organizations_id'],
  7774.                                                                                         'subscription_packages_id'=>$PaymentDetails['subscription_packages_id'],
  7775.                                                                                         'package_payments_id'=>$PaymentDetails['package_payments_id'],
  7776.                                                                                         'buy_date'=>$BuyDate,
  7777.                                                                                         'due_date'=>$DueDate,
  7778.                                                                                         'status'=>'0',
  7779.                                                                                         'recurring_status'=>'0',
  7780.                                                                                         'payment_gateway'=>'1',
  7781.                                                                                         'stripe_temp_token'=>$SessionID,
  7782.                                                                                         'currency'=>$ResultData->currency,
  7783.                                                                                         'subscription_id'=>$ResultData->subscription,
  7784.                                                                                         'subscription_customer_id'=>$ResultData->customer,
  7785.                                                                                         'subscription_item_id'=>'');
  7786.                                                 $package_subscriptions_id = $this->Common_model->common_insert('package_subscriptions',$SP_values);
  7787.                                                 // insert into package subscriptions
  7788.  
  7789.                                                 $PPValue['package_subscriptions_id'] = $package_subscriptions_id; // update subscription id to payments
  7790.  
  7791.                                                 // updating monthly packages in to organization table
  7792.                                                 $OrgWhere = array(  'organizations_id'=>$PaymentDetails['organizations_id']);
  7793.                                                 $OrgValue = array(    'meetings_count'=>$PaymentDetails['meetings_count'],
  7794.                                                                                         'members_count'=>$PaymentDetails['meeting_members_count'],
  7795.                                                                                         'events_count'=>$PaymentDetails['event_count'],
  7796.                                                                                         'events_members_count'=>$PaymentDetails['event_members_count'],
  7797.                                                                                         'dedicated_link_availability'=>$PaymentDetails['link_generation_status'],
  7798.                                                                                         'app_create_meeting_status'=>$PaymentDetails['app_create_meeting_status'],
  7799.                                                                                         'multiple_locations_status'=>$PaymentDetails['multiple_locations_status'],
  7800.                                                                                         'follow_up_meeting_status'=>$PaymentDetails['follow_up_meeting_status'],
  7801.                                                                                         'advanced_security_level'=>$PaymentDetails['advanced_security_level'],
  7802.                                                                                         'packge_validity_upto'=>$DueDate,
  7803.                                                                                         'subscription_packages_id'=>$PaymentDetails['subscription_packages_id']);
  7804.                                                 $this->Common_model->common_update('organizations',$OrgValue,$OrgWhere); // tbl organizations
  7805.                                                 // updating monthly packages in to organization table
  7806.  
  7807.                                                 //sent mail
  7808.                                                 $OD = $this->Manage_model->get_organization_details($PaymentDetails['organizations_id']);
  7809.                                                 $this->SentMail('9',$OD['email']);
  7810.                                                 //sent mail
  7811.  
  7812.                                                 //sent mail payment receipt
  7813.                                                 $CountryData = $this->Manage_model->get_organization_country_details();
  7814.  
  7815.                                                 $trackid = 'MPY'.sprintf("%05d", $PaymentDetails['package_payments_id']);
  7816.  
  7817.                                                 if($PaymentDetails['package_category']==0){ $PaymentDetails['package_category'] = 'Professional Package'; }
  7818.                                                 elseif($PaymentDetails['package_category']==1){ $PaymentDetails['package_category'] = 'Business Package'; }
  7819.                                                 elseif($PaymentDetails['package_category']==2){ $PaymentDetails['package_category'] = 'Entrepreneur Package'; }
  7820.  
  7821.                                                 $data = array('Subject'=>'MEET PASS Payment Receipt','UserID'=>$OD['email'],'OrderID'=>$trackid,'Date'=>date('M d, Y',strtotime($BuyDate)),'NextDueDate'=>date('M d, Y',strtotime($DueDate)),'PackageName'=>$PaymentDetails['package_category'].' ('.$PaymentDetails['package_name'].')','PackageAmount'=>$PaymentDetails['amount'].' '.$CountryData['currency'],'BilledTo'=>$OD['name']);
  7822.                                                 $this->SentMail('11',$OD['email'],$data);
  7823.                                                 //sent mail payment receipt
  7824.                                         }
  7825.                                 }
  7826.  
  7827.                                 $this->Common_model->Set_Message('1','Payment success.');
  7828.                                 $this->Common_model->common_update('package_payments',$PPValue,$PPWhere); // update package payment details
  7829.                         }
  7830.                         else // payment status: failled
  7831.                         {
  7832.                                 $package_payments_id = $PaymentDetails['package_payments_id'];
  7833.  
  7834.                                 // update payments table
  7835.                                 $where = array('package_payments_id'=>$package_payments_id);
  7836.                                 $value = array( 'status'=>'2','response_data'=>json_encode($ResultData));
  7837.                                 $this->Common_model->common_update('package_payments',$value,$where);
  7838.  
  7839.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Payment failled.');
  7840.                         }
  7841.                 }
  7842.                 else // payment status: failled
  7843.                 {
  7844.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Payment failled.');
  7845.                 }
  7846.         }
  7847.         redirect('view-packages');
  7848. }
  7849. ############################################ END OF STRIPE CHECKOUT CALLBACK ######################
  7850. /*public function stripe_subscription_creation()
  7851. {
  7852.         #*********stripe
  7853.         require_once APPPATH."third_party/stripe-php/init.php";
  7854.  
  7855.                 // Set your secret key. Remember to switch to your live secret key in production.
  7856.                 // See your keys here: https://dashboard.stripe.com/apikeys
  7857.                 $stripe = new \Stripe\StripeClient($this->config->item('StripeSecretKey'));
  7858.  
  7859.                 $price = '1';
  7860.  
  7861.                         $pr = $stripe->products->create([
  7862.                           'name' => '$package_name',
  7863.                          
  7864.                         ]);
  7865.                         $sub = $stripe->prices->create([
  7866.                           'unit_amount' => $price*100,
  7867.                           'currency' => 'usd',
  7868.                           'recurring' => ['interval' => 'month','interval_count'=>'1'],
  7869.                           'product' => $pr->id,
  7870.                         ]);
  7871.                         #****Stripe object  
  7872.  
  7873.                         echo '<pre>';
  7874.                         print_r($sub);
  7875.  
  7876.                         echo $sub->id;
  7877. }*/
  7878.  
  7879. /*public function checkout_session_retrieve()
  7880. {
  7881.         require_once APPPATH."third_party/stripe-php/init.php";
  7882.  
  7883.  
  7884.  
  7885.         $stripe = new \Stripe\StripeClient($this->config->item('StripeSecretKey'));
  7886.  
  7887.         $dt = $stripe->checkout->sessions->retrieve('cs_test_a1IoVmKcDfSNASX9j2ZiZEOEpWmxPW7bWizYlCMFBv2FOmWeUgdO9cVFcO',[]);
  7888.  
  7889.         echo '<pre>';
  7890.         print_r($dt);
  7891.  
  7892. }*/
  7893.  
  7894.  
  7895.  
  7896. ############################################ ASSIGN FREE SUBSCRIPTION PACKAGES ####################
  7897. public function assign_free_subscription_packages($organizations_id)
  7898. {
  7899.         $this->load->view('include/preloader');
  7900.  
  7901.         if(isset($_POST['AssignPackage']))
  7902.         {
  7903.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  7904.                 $this->form_validation->set_rules('organizations_id','organizations','trim|required|xss_clean|numeric');
  7905.                 $this->form_validation->set_rules('subscription_packages_id','subscription package','trim|required|xss_clean|numeric');
  7906.  
  7907.                 if($this->form_validation->run())
  7908.                 {
  7909.                        
  7910.                         $organizations_id = $this->input->post('organizations_id');
  7911.                         $subscription_packages_id = $this->input->post('subscription_packages_id');
  7912.  
  7913.             $PaymentDetails = $this->Manage_model->get_free_payment_package_details($subscription_packages_id);
  7914.             if(!empty($PaymentDetails))
  7915.             {
  7916.                 $datetime = date('Y-m-d H:i:s');
  7917.                 $BuyDate = date('Y-m-d');
  7918.                             $DueDate = date('Y-m-d', strtotime('+1 month'));
  7919.                             $PreviousDate = date('Y-m-d', strtotime('-1 days'));
  7920.                 
  7921.                 // cancel previous subscriptions
  7922.                             $Cancel_SP_value = array('status'=>'2');
  7923.                             $Cancel_SP_where = array('status'=>'0','organizations_id'=>$organizations_id);
  7924.                             $this->Common_model->common_update('package_subscriptions',$Cancel_SP_value,$Cancel_SP_where); // tbl package_subscriptions
  7925.     
  7926.                             $Cancel_ORG_value = array('meetings_count'=>'0','members_count'=>'0','events_count'=>'0','events_members_count'=>'0','dedicated_link_availability'=>'0','app_create_meeting_status'=>'0','multiple_locations_status'=>'0','follow_up_meeting_status'=>'0','advanced_security_level'=>'0','packge_validity_upto'=>$PreviousDate);
  7927.                             $Cancel_ORG_where = array('organizations_id'=>$organizations_id);
  7928.                             $this->Common_model->common_update('organizations',$Cancel_ORG_value,$Cancel_ORG_where); // tbl organizations
  7929.                             // cancel previous subscriptions
  7930.     
  7931.                             // insert into package subscriptions
  7932.                             $SP_values = array( 'datetime'=>$datetime,
  7933.                                                                     'organizations_id'=>$organizations_id,
  7934.                                                                     'subscription_packages_id'=>$subscription_packages_id,
  7935.                                                                     'package_payments_id'=>'0', // paid from admin
  7936.                                                                     'buy_date'=>$BuyDate,
  7937.                                                                     'due_date'=>$DueDate,
  7938.                                                                     'status'=>'0',
  7939.                                                                     'recurring_status'=>'0',
  7940.                                                                     'payment_gateway'=>'-1',
  7941.                                                                     'stripe_temp_token'=>'',
  7942.                                                                     'currency'=>'',
  7943.                                                                     'subscription_id'=>'',
  7944.                                                                     'subscription_customer_id'=>'',
  7945.                                                                     'subscription_item_id'=>'');
  7946.                             $package_subscriptions_id = $this->Common_model->common_insert('package_subscriptions',$SP_values);
  7947.                             // insert into package subscriptions
  7948.     
  7949.                             // updating monthly packages in to organization table
  7950.                             $OrgWhere = array(  'organizations_id'=>$organizations_id);
  7951.                             $OrgValue = array(    'meetings_count'=>$PaymentDetails['meetings_count'],
  7952.                                                                     'members_count'=>$PaymentDetails['meeting_members_count'],
  7953.                                                                     'events_count'=>$PaymentDetails['event_count'],
  7954.                                                                     'events_members_count'=>$PaymentDetails['event_members_count'],
  7955.                                                                     'dedicated_link_availability'=>$PaymentDetails['link_generation_status'],
  7956.                                                                     'app_create_meeting_status'=>$PaymentDetails['app_create_meeting_status'],
  7957.                                                                     'multiple_locations_status'=>$PaymentDetails['multiple_locations_status'],
  7958.                                                                     'follow_up_meeting_status'=>$PaymentDetails['follow_up_meeting_status'],
  7959.                                                                     'advanced_security_level'=>$PaymentDetails['advanced_security_level'],
  7960.                                                                     'packge_validity_upto'=>$DueDate,
  7961.                                                                     'subscription_packages_id'=>$PaymentDetails['subscription_packages_id']);
  7962.                            $this->Common_model->common_update('organizations',$OrgValue,$OrgWhere); // tbl organizations
  7963.                             // updating monthly packages in to organization table
  7964.     
  7965.                             //sent mail
  7966.                             $OD = $this->Manage_model->get_organization_details($organizations_id);
  7967.                             $this->SentMail('9',$OD['email']);
  7968.                             //sent mail
  7969.                            
  7970.                             $this->Common_model->Set_Message('1','<strong>Success!</strong> Free package added successfully.');
  7971.                     }
  7972.                     else
  7973.                     {
  7974.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  7975.                     }
  7976.                 }
  7977.                 else
  7978.                 {
  7979.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  7980.                 }
  7981.         }
  7982.         else
  7983.         {
  7984.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  7985.         }
  7986.  
  7987.         redirect('organizations-details/'.$organizations_id.'/free-packages');
  7988. }
  7989. ############################################ END OF ASSIGN FREE SUBSCRIPTION PACKAGES #############
  7990.  
  7991.  
  7992. public function manage_blogs()
  7993. {
  7994.         # INSERT / UPDATE FUNCTION
  7995.         //print_r($_POST); die();
  7996.         if(isset($_POST['submit']))
  7997.         {
  7998.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  7999.                
  8000.                 $this->form_validation->set_rules('title','title','trim|required|xss_clean');
  8001.                 $this->form_validation->set_rules('description','section_1','trim|required|xss_clean');
  8002.                
  8003.        
  8004.                 if($this->form_validation->run())
  8005.                 { 
  8006.                         $country_id = 1;
  8007.                         $title = $this->input->post('title');
  8008.                         $description = $this->input->post('description');
  8009.                         $blogs_status = $this->input->post('blogs_status');
  8010.                         $blog_category = $this->input->post('blog_category');
  8011.                         $date = date("Y-m-d");
  8012.                        
  8013.                         $blog_id = $this->input->post('blog_id');
  8014.                         $language = $this->input->post('language');
  8015.                         $header_script = $this->input->post('header_script');
  8016.                         $meta_title = $this->input->post('meta_title');
  8017.                         $meta_keywords = $this->input->post('meta_keyword');
  8018.                         $submit = $this->input->post('submit');
  8019.                         $blogs_id = $this->input->post('blog_id');
  8020.                         $slug = $this->input->post('slug');
  8021.                         if(empty($slug)){
  8022.             $slug = $this->slugify($title);
  8023.                         }
  8024.                         $values = array('date'=>date('Y-m-d'),
  8025.                                                         'blogs_status'=>$blogs_status,
  8026.                                                         'blog_category'=>$blog_category,
  8027.                                                         'description'=>$description,
  8028.                                                         'language'=>$language,
  8029.                                                         'title'=>$title,
  8030.                                                         'slug'=>$slug,
  8031.                                                         'header_script'=>$header_script,
  8032.                                                         'meta_title'=>$meta_title,
  8033.                                                         'meta_keyword'=>$meta_keywords);
  8034.                                   $CountryData = $this->Manage_model->get_country_details_row($country_id);
  8035.                       if(isset($_FILES['image']) && $_FILES['image']['name']!='')
  8036.                                                 {
  8037.  
  8038.  
  8039.                                                         $image_name = $this->Common_model->image_upload('./uploads/blogs/','image');
  8040.                                                         if($image_name!='')
  8041.                                                         {
  8042.                                                                 $values['image'] = $image_name;
  8043.                                                         }
  8044.                                                 }
  8045.                 //echo "<pre>";print_r($_POST); print_r($values);             die(); 
  8046.                   if($submit=='Save')
  8047.                         {
  8048.                                 $blog_id = $this->Common_model->common_insert('blogs',$values);
  8049.                                 $this->Common_model->Set_Message('1',"<strong>Blog details added successfully</strong>");
  8050.                                 redirect(current_url());
  8051.                                
  8052.                         }
  8053.                         else
  8054.                         {
  8055.                             $where = array('blogs_id'=>$blogs_id);                               
  8056.                                 $this->Common_model->common_update('blogs',$values,$where);
  8057.                                 $this->Common_model->Set_Message('1',"<strong>Sucess!</strong>Blog Updated successfully.");
  8058.                         }
  8059.                         redirect(current_url());
  8060.                 }
  8061.                 else
  8062.                 { $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  8063.                                 redirect(current_url());
  8064.                         if($this->input->post('submit')=='Update')
  8065.                         { 
  8066.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  8067.                                 redirect(current_url());
  8068.                         }
  8069.                 }
  8070.         }
  8071.         # END OF INSERT / UPDATE FUNCTION
  8072.  
  8073.         # DELETE FUNCTION
  8074.  
  8075.         if(isset($_POST['delete']))
  8076.         { 
  8077.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  8078.                 if($this->form_validation->run())
  8079.                 {
  8080.                         $delete_id = $this->input->post('delete_id');
  8081.                        
  8082.                                 $where = array('category_id'=>$delete_id);
  8083.                                 $value = array('is_deleted'=>'1');
  8084.                                 $this->Common_model->common_update('category',$value,$where);
  8085.                                 $this->Common_model->Set_Message('1','Category Removed Successfully');
  8086.  
  8087.                        
  8088.                 }
  8089.                 else
  8090.                 {
  8091.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  8092.                 }
  8093.                 redirect(current_url());
  8094.         }
  8095.         # END OF DELETE FUNCTION
  8096.  
  8097.         # FILTER AND PAGINATION SECTION
  8098.         $FD = array();
  8099.  
  8100.         if($this->session->userdata('logged_in')['privilege_id']==6)
  8101.         {
  8102.                 $FD['country_id'] = $this->session->userdata('logged_in')['table_id']; // for country admin only
  8103.         }
  8104.  
  8105.         $URL = $this->uri->segment(1);
  8106.         $start = $limit = '';
  8107.         $page_ary['url'] = base_url($URL);
  8108.         $page_ary['total_rows'] = $this->Manage_model->view_blogs_admin($FD,$start,$limit,'1')[0]->count;
  8109.         $limit = $page_ary['per_page'] = 30;
  8110.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  8111.         $data['page'] = $start = $PGN_DATA['page'];
  8112.         $data['links'] = $PGN_DATA['links'];
  8113.         # END OF FILTER AND PAGINATION SECTION
  8114.  
  8115.         $data['CountryData'] = $this->Manage_model->select_view_country_org();
  8116.         $data['BLOGCAT'] = $this->Manage_model->get_category_List('1');
  8117.         $data['OD'] = $this->Manage_model->view_blogs_admin($FD,$start,$limit,'0');
  8118.  
  8119.         $this->CommonPage('blogs/view_blogs',$data,'View blogs');
  8120. }
  8121. ############################################ END OF blogs  ###############################
  8122.  
  8123.  
  8124. ############################################ END OF ASSIGN FREE SUBSCRIPTION PACKAGES #############
  8125.  
  8126.  
  8127. public function product_pages()
  8128. {
  8129.         # INSERT / UPDATE FUNCTION
  8130.         if(isset($_POST['submit']))
  8131.         {  
  8132.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  8133.                 // $this->form_validation->set_rules('country_id','Country','trim|required|xss_clean|numeric');
  8134.                 $this->form_validation->set_rules('title','title','trim|required|xss_clean');
  8135.                 $this->form_validation->set_rules('section_1','section_1','trim|required|xss_clean');          
  8136.                 if($this->form_validation->run())
  8137.                 {       $country_id = 1;     
  8138.                         //$page_type = $this->input->post('page_type');
  8139.                         $page_type = "product";
  8140.                         $title = $this->input->post('title');
  8141.                         $product_category = $this->input->post('product_category');
  8142.                                 $language = $this->input->post('language');  
  8143.                         $pstatus = $this->input->post('pstatus');
  8144.                         $description = $this->input->post('description');
  8145.                         $page_id = $this->input->post('page_id');
  8146.                        
  8147.                         $section_1 = $this->input->post('section_1');
  8148.                         $link_1 = $this->input->post('link_1');
  8149.                         $alt_1 = $this->input->post('alt_1');
  8150.                         $SMHEADING_1 = $this->input->post('SMHEADING_1');
  8151.                         $MAINHEADING_1 = $this->input->post('MAINHEADING_1');
  8152.                        
  8153.                         $section_2 = $this->input->post('section_2');
  8154.                         $link_2 = $this->input->post('link_2');
  8155.                         $alt_2 = $this->input->post('alt_2');
  8156.                         $SMHEADING_2 = $this->input->post('SMHEADING_2');
  8157.                         $MAINHEADING_2 = $this->input->post('MAINHEADING_2');
  8158.                        
  8159.                         $section_3 = $this->input->post('section_3');
  8160.                         $link_3 = $this->input->post('link_3');
  8161.                         $alt_3 = $this->input->post('alt_3');
  8162.                         $SMHEADING_3 = $this->input->post('SMHEADING_3');
  8163.                         $MAINHEADING_3 = $this->input->post('MAINHEADING_3');
  8164.                        
  8165.                         $section_4 = $this->input->post('section_4');
  8166.                         $link_4 = $this->input->post('link_4');
  8167.                         $alt_4 = $this->input->post('alt_4');
  8168.                         $SMHEADING_4 = $this->input->post('SMHEADING_4');
  8169.                         $MAINHEADING_4 = $this->input->post('MAINHEADING_4');
  8170.                        
  8171.                         $section_5 = $this->input->post('section_5');
  8172.                         $link_5 = $this->input->post('link_5');
  8173.                         $alt_5 = $this->input->post('alt_5');
  8174.                         $SMHEADING_5 = $this->input->post('SMHEADING_5');
  8175.                         $MAINHEADING_5 = $this->input->post('MAINHEADING_5');
  8176.                        
  8177.                         $section_6 = $this->input->post('section_6');
  8178.                         $link_6 = $this->input->post('link_6');
  8179.                         $alt_6 = $this->input->post('alt_6');
  8180.                         $SMHEADING_6 = $this->input->post('SMHEADING_6');
  8181.                         $MAINHEADING_6 = $this->input->post('MAINHEADING_6');
  8182.                        
  8183.                         $section_7 = $this->input->post('section_7');
  8184.                         $link_7 = $this->input->post('link_7');
  8185.                         $alt_7 = $this->input->post('alt_7');
  8186.                         $SMHEADING_7 = $this->input->post('SMHEADING_7');
  8187.                         $MAINHEADING_7 = $this->input->post('MAINHEADING_7');
  8188.                        
  8189.                         $section_8 = $this->input->post('section_8');
  8190.                         $link_8 = $this->input->post('link_8');
  8191.                         $alt_8 = $this->input->post('alt_8');
  8192.                         $SMHEADING_8 = $this->input->post('SMHEADING_8');
  8193.                         $MAINHEADING_8 = $this->input->post('MAINHEADING_8');
  8194.                        
  8195.                         $section_9 = $this->input->post('section_9');
  8196.                         $link_9 = $this->input->post('link_9');
  8197.                         $alt_9 = $this->input->post('alt_9');
  8198.                        
  8199.                         $meta_title = $_POST['meta_title'];
  8200.                         $video_link = $this->input->post('video_link');
  8201.                         $meta_keyword = $_POST['meta_keyword'];
  8202.                         $header_script = $_POST['header_script'];
  8203.                        
  8204.                         $Icon_SMHEADING_1 = $this->input->post('Icon_SMHEADING_1');
  8205.                         $Icon_SMHEADING_2 = $this->input->post('Icon_SMHEADING_2');
  8206.                         $Icon_SMHEADING_3 = $this->input->post('Icon_SMHEADING_3');
  8207.                         $Icon_SMHEADING_4 = $this->input->post('Icon_SMHEADING_4');
  8208.                         $Icon_SMHEADING_5 = $this->input->post('Icon_SMHEADING_5');
  8209.                         $Icon_SMHEADING_6 = $this->input->post('Icon_SMHEADING_6');  
  8210.                        
  8211.                         $icon_link_1 = $this->input->post('icon_link_1');
  8212.                         $icon_link_2 = $this->input->post('icon_link_2');
  8213.                         $icon_link_3 = $this->input->post('icon_link_3');
  8214.                         $icon_link_4 = $this->input->post('icon_link_4');
  8215.                         $icon_link_5 = $this->input->post('icon_link_5');
  8216.                         $icon_link_6 = $this->input->post('icon_link_6');
  8217.                        
  8218.                        
  8219.                        
  8220.                        
  8221.        
  8222.                         $submit = $this->input->post('submit');
  8223.            $slug = $this->input->post('slug');
  8224.                         if(empty($slug)){
  8225.             $slug = $this->slugify($title);
  8226.                         }
  8227.                         //$values=array();
  8228.                        
  8229.                         $values = array('title'=>$title,
  8230.                                                         'description'=>$description,   
  8231.                                                         'product_category'=>$product_category,
  8232.                                                         'country_id'=>$country_id,
  8233.                                                         'section_1'=>$section_1,
  8234.                                                         'link_1'=>$link_1,                                                     
  8235.                                                         'section_2'=>$section_2,
  8236.                                                         'link_2'=>$link_2,                                                     
  8237.                                                         'section_3'=>$section_3,
  8238.                                                         'link_3'=>$link_3,                                                     
  8239.                                                         'section_4'=>$section_4,
  8240.                                                         'link_4'=>$link_4,                                                     
  8241.                                                         'section_5'=>$section_5,
  8242.                                                         'link_5'=>$link_5,
  8243.                                                         'section_6'=>$section_6,
  8244.                                                         'link_6'=>$link_6,                                                     
  8245.                                                         'section_7'=>$section_7,
  8246.                                                         'link_7'=>$link_7,                                                     
  8247.                                                         'section_8'=>$section_8,
  8248.                                                         'link_8'=>$link_8,                                                     
  8249.                                                         'section_9'=>$section_9,
  8250.                                                         'link_9'=>$link_9,
  8251.                                                         'meta_title'=>$meta_title,
  8252.                                                         'SMHEADING_1'=>$SMHEADING_1,
  8253.                                                         'SMHEADING_2'=>$SMHEADING_2,
  8254.                                                         'SMHEADING_3'=>$SMHEADING_3,
  8255.                                                         'SMHEADING_4'=>$SMHEADING_4,
  8256.                                                         'SMHEADING_5'=>$SMHEADING_5,
  8257.                                                         'SMHEADING_6'=>$SMHEADING_6,
  8258.                                                         'SMHEADING_7'=>$SMHEADING_7,
  8259.                                                         'SMHEADING_8'=>$SMHEADING_8,
  8260.                                                         'MAINHEADING_1'=>$MAINHEADING_1,
  8261.                                                         'MAINHEADING_2'=>$MAINHEADING_2,
  8262.                                                         'MAINHEADING_3'=>$MAINHEADING_3,
  8263.                                                         'MAINHEADING_4'=>$MAINHEADING_4,
  8264.                                                         'MAINHEADING_5'=>$MAINHEADING_5,
  8265.                                                         'MAINHEADING_6'=>$MAINHEADING_6,
  8266.                                                         'MAINHEADING_7'=>$MAINHEADING_7,
  8267.                                                         'MAINHEADING_8'=>$MAINHEADING_8,
  8268.                                                         'Icon_SMHEADING_1'=>$Icon_SMHEADING_1,
  8269.                                                         'Icon_SMHEADING_2'=>$Icon_SMHEADING_2,
  8270.                                                         'Icon_SMHEADING_3'=>$Icon_SMHEADING_3,
  8271.                                                         'Icon_SMHEADING_4'=>$Icon_SMHEADING_4,
  8272.                                                         'Icon_SMHEADING_5'=>$Icon_SMHEADING_5,
  8273.                                                         'Icon_SMHEADING_6'=>$Icon_SMHEADING_6,
  8274.                                                         'icon_link_1'=>$icon_link_1,
  8275.                                                         'icon_link_2'=>$icon_link_2,
  8276.                                                         'icon_link_3'=>$icon_link_3,
  8277.                                                         'icon_link_4'=>$icon_link_4,
  8278.                                                         'icon_link_5'=>$icon_link_5,
  8279.                                                         'icon_link_6'=>$icon_link_6,
  8280.                                                         'video_link'=>$video_link,
  8281.                                                         'meta_title'=>$meta_title,
  8282.                                                         'meta_keywords'=>$meta_keyword,
  8283.                                                         'header_script'=>$header_script,
  8284.                                                         'status'=>$pstatus,     'language'=>$language,
  8285.                                                         'slug'=>$slug);
  8286.                                                         if(isset($_FILES['image']) && $_FILES['image']['name']!='')
  8287.                         {
  8288.                                 $image_name = $this->Common_model->image_upload('./uploads/products/','image');
  8289.                                 if($image_name!='')
  8290.                                 {
  8291.                                         $values['image'] = $image_name;
  8292.                                 }
  8293.  
  8294.                                
  8295.                         }
  8296.                        
  8297.                         if(isset($_FILES['image_1']) && $_FILES['image_1']['name']!='')
  8298.                         {
  8299.                                 $image_1 = $this->Common_model->image_uploadProducts('./uploads/products/','image_1');
  8300.                                 if($image_1!='')
  8301.                                 {
  8302.                                         $values['image_1'] = $image_1;
  8303.                                 }
  8304.  
  8305.                                
  8306.                         }if(isset($_FILES['image_2']) && $_FILES['image_2']['name']!='')
  8307.                         {
  8308.                                 $image_2 = $this->Common_model->image_uploadProducts('./uploads/products/','image_2');
  8309.                                 if($image_2!='')
  8310.                                 {
  8311.                                         $values['image_2'] = $image_2;
  8312.                                 }
  8313.  
  8314.                                
  8315.                         }if(isset($_FILES['image_3']) && $_FILES['image_3']['name']!='')
  8316.                         {
  8317.                                 $image_3 = $this->Common_model->image_uploadProducts('./uploads/products/','image_3');
  8318.                                 if($image_3!='')
  8319.                                 {
  8320.                                         $values['image_3'] = $image_3;
  8321.                                 }
  8322.                         }
  8323.                         if(isset($_FILES['image_4']) && $_FILES['image_4']['name']!='')
  8324.                         {
  8325.                                 $image_4 = $this->Common_model->image_uploadProducts('./uploads/products/','image_4');
  8326.                                 if($image_4!='')
  8327.                                 {
  8328.                                         $values['image_4'] = $image_4;
  8329.                                 }
  8330.                         }if(isset($_FILES['image_5']) && $_FILES['image_5']['name']!='')
  8331.                         {
  8332.                                 $image_5 = $this->Common_model->image_uploadProducts('./uploads/products/','image_5');
  8333.                                 if($image_5!='')
  8334.                                 {
  8335.                                         $values['image_5'] = $image_5;
  8336.                                 }
  8337.                         }if(isset($_FILES['image_6']) && $_FILES['image_6']['name']!='')
  8338.                         {
  8339.                                 $image_6 = $this->Common_model->image_uploadProducts('./uploads/products/','image_6');
  8340.                                 if($image_6!='')
  8341.                                 {
  8342.                                         $values['image_6'] = $image_6;
  8343.                                 }
  8344.                         }if(isset($_FILES['image_7']) && $_FILES['image_7']['name']!='')
  8345.                         {
  8346.                                 $image_7 = $this->Common_model->image_uploadProducts('./uploads/products/','image_7');
  8347.                                 if($image_7!='')
  8348.                                 {
  8349.                                         $values['image_7'] = $image_7;
  8350.                                 }
  8351.                         }if(isset($_FILES['image_8']) && $_FILES['image_8']['name']!='')
  8352.                         {
  8353.                                 $image_8 = $this->Common_model->image_uploadProducts('./uploads/products/','image_8');
  8354.                                 if($image_8!='')
  8355.                                 {
  8356.                                         $values['image_8'] = $image_8;
  8357.                                 }
  8358.                         }if(isset($_FILES['image_9']) && $_FILES['image_9']['name']!='')
  8359.                         {
  8360.                                 $image_9 = $this->Common_model->image_uploadProducts('./uploads/products/','image_9');
  8361.                                 if($image_9!='')
  8362.                                 {
  8363.                                         $values['image_9'] = $image_9;
  8364.                                 }
  8365.                         }
  8366.                         if(isset($_FILES['icon_image_1']) && $_FILES['icon_image_1']['name']!='')
  8367.                         {
  8368.                                 $icon_image_1 = $this->Common_model->image_uploadProducts('./uploads/products/','icon_image_1');
  8369.                                 if($icon_image_1!='')
  8370.                                 {
  8371.                                         $values['icon_image_1'] = $icon_image_1;
  8372.                                 }
  8373.                         }if(isset($_FILES['icon_image_2']) && $_FILES['icon_image_2']['name']!='')
  8374.                         {
  8375.                                 $icon_image_2 = $this->Common_model->image_uploadProducts('./uploads/products/','icon_image_2');
  8376.                                 if($icon_image_2!='')
  8377.                                 {
  8378.                                         $values['icon_image_2'] = $icon_image_2;
  8379.                                 }
  8380.                         }if(isset($_FILES['icon_image_3']) && $_FILES['icon_image_3']['name']!='')
  8381.                         {
  8382.                                 $icon_image_3 = $this->Common_model->image_uploadProducts('./uploads/products/','icon_image_3');
  8383.                                 if($icon_image_3!='')
  8384.                                 {
  8385.                                         $values['icon_image_3'] = $icon_image_3;
  8386.                                 }
  8387.                         }if(isset($_FILES['icon_image_4']) && $_FILES['icon_image_4']['name']!='')
  8388.                         {
  8389.                                 $icon_image_4 = $this->Common_model->image_uploadProducts('./uploads/products/','icon_image_4');
  8390.                                 if($icon_image_4!='')
  8391.                                 {
  8392.                                         $values['icon_image_4'] = $icon_image_4;
  8393.                                 }
  8394.                         }if(isset($_FILES['icon_image_5']) && $_FILES['icon_image_5']['name']!='')
  8395.                         {
  8396.                                 $icon_image_5 = $this->Common_model->image_uploadProducts('./uploads/products/','icon_image_5');
  8397.                                 if($icon_image_5!='')
  8398.                                 {
  8399.                                         $values['icon_image_5'] = $icon_image_5;
  8400.                                 }
  8401.                         }if(isset($_FILES['icon_image_6']) && $_FILES['icon_image_6']['name']!='')
  8402.                         {
  8403.                                 $icon_image_6 = $this->Common_model->image_uploadProducts('./uploads/products/','icon_image_6');
  8404.                                 if($icon_image_6!='')
  8405.                                 {
  8406.                                         $values['icon_image_6'] = $icon_image_6;
  8407.                                 }
  8408.                         }
  8409.                         $CountryData = $this->Manage_model->get_country_details_row($country_id);
  8410.  
  8411.                         if($submit=='Save')
  8412.                         {
  8413.                                 // insert product api
  8414.  
  8415.                                 $subscription_packages_id = $this->Common_model->common_insert('custom_pages',$values);
  8416.                                 $this->Common_model->Set_Message('1',"details added successfully");
  8417.                                
  8418.                                 redirect(current_url());
  8419.                                        
  8420.                                
  8421.                         }
  8422.                         else
  8423.                         { $where = array('id'=>$page_id);                           
  8424.                                 $this->Common_model->common_update('custom_pages',$values,$where);
  8425.                                 $this->Common_model->Set_Message('1',"<strong>Sucess!</strong>Blog Updated successfully.");
  8426.                                
  8427.                                 $this->Common_model->Set_Message('1',"<strong>Error!</strong> Updated  successfully.");
  8428.                         }
  8429.                         redirect(current_url());
  8430.                 }
  8431.                 else
  8432.                 { 
  8433.                         if($this->input->post('submit')=='Update')
  8434.                         {
  8435.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  8436.                                 redirect(current_url());
  8437.                         }
  8438.                 }
  8439.         }
  8440.         # END OF INSERT / UPDATE FUNCTION
  8441.  
  8442.         # DELETE FUNCTION
  8443.         if(isset($_POST['delete']))
  8444.         {
  8445.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  8446.                 if($this->form_validation->run())
  8447.                 {
  8448.                         $delete_id = $this->input->post('delete_id');
  8449.                         $CheckingPackageUsed = $this->Manage_model->checking_package_is_used_or_not($delete_id);
  8450.                         if(empty($CheckingPackageUsed))
  8451.                         {
  8452.                                 $where = array('subscription_packages_id'=>$delete_id);
  8453.                                 $value = array('subscription_packages_status'=>'1');
  8454.                                 $this->Common_model->common_update('subscription_packages',$value,$where);
  8455.                                 $this->Common_model->Set_Message('1','Package Removed Successfully');
  8456.  
  8457.                                 // Activity Log Record
  8458.                                 $head = 'Remove Package';
  8459.                                 $description = 'Package Has Been Removed By ';
  8460.                                 $this->Common_model->create_activity_log($head,$description,'',array(),array('subscription_packages_id'=>$delete_id),'8');
  8461.                                 // Activity Log Record
  8462.                         }
  8463.                         else
  8464.                         {
  8465.                                 $this->Common_model->Set_Message('2',"<strong>Error!</strong> Consumed package cannot be removed.");
  8466.                                 redirect(current_url());
  8467.                         }
  8468.                 }
  8469.                 else
  8470.                 {
  8471.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  8472.                 }
  8473.                 redirect(current_url());
  8474.         }
  8475.         # END OF DELETE FUNCTION
  8476.  
  8477.         # FILTER AND PAGINATION SECTION
  8478.         $FD = array();
  8479.  
  8480.         if($this->session->userdata('logged_in')['privilege_id']==6)
  8481.         {
  8482.                 $FD['country_id'] = $this->session->userdata('logged_in')['table_id']; // for country admin only
  8483.         }
  8484.  
  8485.         $URL = $this->uri->segment(1);
  8486.         $start = $limit = '';
  8487.         $page_ary['url'] = base_url($URL);
  8488.         $page_ary['total_rows'] = $this->Manage_model->view_products_admin($FD,$start,$limit,'1',"product")[0]->count;
  8489.         $limit = $page_ary['per_page'] = 30;
  8490.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  8491.         $data['page'] = $start = $PGN_DATA['page'];
  8492.         $data['links'] = $PGN_DATA['links'];
  8493.         # END OF FILTER AND PAGINATION SECTION
  8494.  
  8495.         $data['CountryData'] = $this->Manage_model->select_view_country_org();
  8496.         $data['OD'] = $this->Manage_model->view_products_admin($FD,$start,$limit,'0',"product");
  8497.         $data['BLOGCAT'] = $this->Manage_model->get_category_List('2');
  8498.         $data["WebURLFrontend"]=$this->config->item('WebURLFrontend');
  8499.         $this->CommonPage('products/view_products',$data,'Products');
  8500.        
  8501. }
  8502.  
  8503. public function get_product_data()
  8504. {
  8505.         $Data['response'] = 'failed';
  8506.         $Data['result'] = array();
  8507.  
  8508.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  8509.         if($this->form_validation->run())
  8510.         {
  8511.                 $product_id = $this->input->post('data_id');
  8512.                 $Result = $this->Manage_model->get_product_details($product_id);
  8513.                 if(!empty($Result))
  8514.                 {
  8515.                         $Data['response'] = 'success';
  8516.                         $Data['result'] = $Result;
  8517.                 }
  8518.         }
  8519.         echo json_encode($Data);
  8520. }public function get_blog_data()
  8521. {
  8522.         $Data['response'] = 'failed';
  8523.         $Data['result'] = array();
  8524.  
  8525.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  8526.         if($this->form_validation->run())
  8527.         {
  8528.                 $blog_id = $this->input->post('data_id');
  8529.                 $Result = $this->Manage_model->get_blog_data($blog_id);
  8530.                 if(!empty($Result))
  8531.                 {
  8532.                         $Data['response'] = 'success';
  8533.                         $Data['result'] = $Result;
  8534.                 }
  8535.         }
  8536.         echo json_encode($Data);
  8537. }
  8538. public function get_slug()
  8539. {
  8540.         $Data['response'] = 'failed';
  8541.         $Data['result'] = array();
  8542.  
  8543.         $this->form_validation->set_rules('title','title','trim|required|xss_clean');
  8544.         if($this->form_validation->run())
  8545.         {
  8546.                 $title = $this->input->post('title');
  8547.                 $Result =  $this->slugify($title);
  8548.                 if(!empty($Result))
  8549.                 {
  8550.                         $Data['response'] = 'success';
  8551.                         $Data['result'] = $Result;
  8552.                 }
  8553.         }
  8554.         echo json_encode($Data);
  8555. }
  8556. ############################################ END OF products  ###############################
  8557.  
  8558.  
  8559.  
  8560.  
  8561. public static function slugify($text, string $divider = '-')
  8562. {
  8563.   // replace non letter or digits by divider
  8564.   $text = preg_replace('~[^\pL\d]+~u', $divider, $text);
  8565.  
  8566.   // transliterate
  8567.   $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
  8568.  
  8569.   // remove unwanted characters
  8570.   $text = preg_replace('~[^-\w]+~', '', $text);
  8571.  
  8572.   // trim
  8573.   $text = trim($text, $divider);
  8574.  
  8575.   // remove duplicate divider
  8576.   $text = preg_replace('~-+~', $divider, $text);
  8577.  
  8578.   // lowercase
  8579.   $text = strtolower($text);
  8580.  
  8581.   if (empty($text)) {
  8582.     return 'n-a';
  8583.   }
  8584.  
  8585.   return $text;
  8586. }
  8587.  
  8588.  
  8589.  
  8590.  
  8591.  
  8592.  
  8593. ############################################ VIEW PACKAGES ########################################
  8594. public function view_task()
  8595. {
  8596.         $this->load->model('Payment_model');
  8597.         $CountryData = $this->Manage_model->get_organization_country_details();
  8598.         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  8599.         $this->CommonPage('task/view_task',$data,'task ongoing');
  8600. }
  8601. ############################################ END OF VIEW task #################################
  8602.  
  8603.  
  8604. ############################################ ASSIGN Agenda  DETAILS #######################
  8605. public function add_agenda($meetings_id)
  8606. {      
  8607.         $this->load->view('include/preloader');
  8608.         if(isset($_POST['saveagenda']))
  8609.         {  
  8610.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  8611.                 // $this->form_validation->set_rules('meetings_id','Meeting','trim|required|xss_clean');
  8612.                 $this->form_validation->set_rules('agenda[]','Type','trim|required|xss_clean');
  8613.                
  8614.  
  8615.                 if($this->form_validation->run())
  8616.                 { 
  8617.                         $meetings_id = $meetings_id;
  8618.                         $agenda = $this->input->post('agenda[]');
  8619.                         $members = $this->input->post('members[]');
  8620.                         $AG_time = $this->input->post('AG_time');
  8621.  
  8622.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  8623.                         if(empty($MD)){ redirect('view-meetings'); }
  8624.  
  8625.                         $datetime = date('Y-m-d H:i:s');
  8626.  
  8627.                         if(count($agenda)>0)
  8628.                         {
  8629.                                 // if($MD['status']==1)
  8630.                                 // {
  8631.                                         // if($MD['meeting_datetime'] < $datetime)
  8632.                                         // {
  8633.                                                
  8634.                                                         $values=array();
  8635.                                                                 for ($i=0; $i < count($agenda); $i++) {
  8636.                                                                
  8637.                                                                
  8638.                                                                         $values["agenda"][] = array(
  8639.                                                                                                         'agenda'=>$agenda[$i],
  8640.                                                                                                         'members'=>$members[$i],
  8641.                                                                                                         'AG_time'=>$AG_time[$i]);
  8642.                                                                                             $prms=array("description"=>json_encode($values));
  8643.                                                                                                
  8644.                                                                        
  8645.  
  8646.                                                                        
  8647.  
  8648.                                                                         // sent notification
  8649.                                                                         if($MD['meeting_type']=='0')
  8650.                                                                         {
  8651.                                                                                 //$Content = array('title'=>'Meeting Invitation','description'=>'You are invited for a new meeting with '.$OD['name'].'. ','message'=>'You are invited to a new meeting by '.strtok($OD['name'], " ").'-'.$TicketNumber.'. Download Meet Pass for your meeting access (onelink.to/meet). Meet, Mingle & Merge in Person.','meetings_id'=>$meetings_id,'TicketNumber'=>$TicketNumber,'Organization'=>$OD['name'],'MeetingTitle'=>$MD['meeting_title']);
  8652.                                                                         }
  8653.                                                                         else
  8654.                                                                         {
  8655.                                                                                 //$Content = array('title'=>'Event Invitation','description'=>'You are invited for a new event with '.$OD['name'].'. ','message'=>'You are invited to a new evevt by '.strtok($OD['name'], " ").'-'.$TicketNumber.'. Download Meet Pass for your evevt access (onelink.to/meet). Meet, Mingle & Merge in Person.','meetings_id'=>$meetings_id,'TicketNumber'=>$TicketNumber,'Organization'=>$OD['name'],'MeetingTitle'=>$MD['meeting_title']);
  8656.                                                                         }
  8657.                                                                 //      $this->SentNotification('1',$members_id,$Content,$members_sub_id,$member_type);
  8658.                                                                         // sent notification
  8659.  
  8660.                                                                         // Activity Log Record
  8661.                                                                         $head = 'Assign Meeting Members';
  8662.                                                                         $description = 'Members Has Been Assigned By ';
  8663.                                                                         //$this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id),'6');
  8664.                                                                         // Activity Log Record
  8665.                                                                
  8666.                                                         }
  8667.  
  8668.                                                         if(!empty($values))
  8669.                                                         {     $where=array("meetings_id"=>$meetings_id);
  8670.                                                                 $meetings_participants_id = $this->Common_model->common_update('meetings',$prms,$where);
  8671.                                                                 $this->Common_model->Set_Message('1',"".$i." Aganeda added successfully ss.");
  8672.                                                         }
  8673.                                                        
  8674.                                                
  8675.                                         // }
  8676.                                         // else
  8677.                                         // {
  8678.                                                 // if($MD['meeting_type']==0) // meeting
  8679.                                                 // {
  8680.                                                         // $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired meeting details cannot be edited.");
  8681.                                                 // }
  8682.                                                 // else // event
  8683.                                                 // {
  8684.                                                         // $this->Common_model->Set_Message('2',"<strong>Error!</strong> Expired event details cannot be edited.");
  8685.                                                 // }
  8686.                                         // }
  8687.                                 // }
  8688.                                 // else
  8689.                                 // {
  8690.                                         // $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  8691.                                 // }
  8692.                         }
  8693.                         else
  8694.                         {
  8695.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  8696.                         }
  8697.                 }
  8698.                 else
  8699.                 {
  8700.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  8701.                 }
  8702.         }
  8703.         else
  8704.         {
  8705.                 $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  8706.         }
  8707. if(isset($_POST['publish']))
  8708.         {  
  8709.                
  8710.  
  8711.                
  8712.  
  8713.                 if(!empty($meetings_id))
  8714.                 { 
  8715.                        
  8716.                
  8717.                         $MD = $this->Manage_model->meeting_details($meetings_id);
  8718.             $members = $this->Manage_model->get_meeting_members($meetings_id);
  8719.                         $OD = $this->Manage_model->get_organization_details($MD['organizations_id']);
  8720.                         if(empty($MD)){ redirect('view-meetings'); }
  8721.  
  8722.                         $datetime = date('Y-m-d H:i:s');
  8723.  
  8724.                        
  8725.                                 if($MD['meeting_publish']==0 && !empty($MD['description']))
  8726.                                 {
  8727.                                        
  8728.                                                
  8729.                                                                 foreach($members as $DT){
  8730.                                                                
  8731.                                                                         // sent notification
  8732.                                                                         if($MD['meeting_type']=='0')
  8733.                                                                         {
  8734.                                                                                 $Content = array('title'=>'Meeting Invitation','description'=>'You are invited for a new meeting with '.$OD['name'].'. ','message'=>'You are invited to a new meeting by '.strtok($OD['name'], " ").'-'.$TicketNumber.'. Download Meet Pass for your meeting access (onelink.to/meet). Meet, Mingle & Merge in Person.','meetings_id'=>$meetings_id,'TicketNumber'=>$TicketNumber,'Organization'=>$OD['name'],'MeetingTitle'=>$MD['meeting_title']);
  8735.                                                                         }
  8736.                                                                         else
  8737.                                                                         {
  8738.                                                                                 $Content = array('title'=>'Event Invitation','description'=>'You are invited for a new event with '.$OD['name'].'. ','message'=>'You are invited to a new evevt by '.strtok($OD['name'], " ").'-'.$TicketNumber.'. Download Meet Pass for your evevt access (onelink.to/meet). Meet, Mingle & Merge in Person.','meetings_id'=>$meetings_id,'TicketNumber'=>$TicketNumber,'Organization'=>$OD['name'],'MeetingTitle'=>$MD['meeting_title']);
  8739.                                                                         }
  8740.                                                                         $this->SentNotification('1',$members_id,$Content,$members_sub_id,$member_type);
  8741.                                                                         // sent notification
  8742.  
  8743.                                                                         // Activity Log Record
  8744.                                                                         $head = 'Assign Meeting Members';
  8745.                                                                         $description = 'Members Has Been Assigned By ';
  8746.                                                                         $this->Common_model->create_activity_log($head,$description,'',array(),array('meetings_id'=>$meetings_id),'6');
  8747.                                                                         // Activity Log Record
  8748.                                                                
  8749.                                                         }
  8750.                            $values=array("meeting_publish"=>1);
  8751.                                                         if(!empty($values))
  8752.                                                         {     $where=array("meetings_id"=>$meetings_id);
  8753.                                                                 $meetings_participants_id = $this->Common_model->common_update('meetings',$values,$where);
  8754.                                                                 $this->Common_model->Set_Message('1',"Meeting Publish added successfully.");
  8755.                                                         }
  8756.                                                        
  8757.                                                
  8758.                                
  8759.                                        
  8760.                                 }
  8761.                                 else
  8762.                                 {
  8763.                                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Add Agenda to Publish Meeting.');
  8764.                                 }
  8765.                        
  8766.                 }
  8767.                 else
  8768.                 {
  8769.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again111.');
  8770.                 }
  8771.         }
  8772.     if($MD["flollow_up_status"]==1)
  8773.         {
  8774.                 $meetings_id =$MD["flollow_up_id"];
  8775.         }
  8776.         redirect('meeting-details/'.$meetings_id.'/members');
  8777. }
  8778. ############################################ END OF ASSIGN MEETING MEMBERS DETAILS ################
  8779. ############################################ END OF ASSIGN MEETING MEMBERS DETAILS ################
  8780.  
  8781.  public function category()
  8782. { 
  8783.         // make payment
  8784.         if(isset($_POST['MP_submit']))
  8785.         {
  8786.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  8787.                 $this->form_validation->set_rules('MP_category_type','type','trim|required|xss_clean');
  8788.                 $this->form_validation->set_rules('category_name','category name','trim|required|xss_clean');
  8789.                
  8790.  
  8791.                 if($this->form_validation->run())
  8792.                 {
  8793.                         $MP_category_type = $this->input->post('MP_category_type');
  8794.                         $category_name = $this->input->post('category_name');
  8795.                         $category_name_ar = $this->input->post('category_name_ar');
  8796.                         $category_status = $this->input->post('category_status');
  8797.                         $hfid = $this->input->post('category_id');
  8798.                        
  8799.   $values = array('category_type_id'=>$MP_category_type,
  8800.                                                                                         'category_name_en'=>$category_name,
  8801.                                                                                         'category_name_ar'=>$category_name_ar,
  8802.                                                                                         'category_status'=>$category_status);
  8803.                                
  8804.                                                 if($hfid =="")
  8805.                                                 {
  8806.                                                        
  8807.  
  8808.  
  8809.                                                         $this->Common_model->common_insert('category',$values);
  8810.                                                         $this->Common_model->Set_Message('1',"Category Saved");
  8811.                                                 }
  8812.                                                 else
  8813.                                                 {  
  8814.                                             
  8815.                             $where=array("category_id"=>$hfid);
  8816.                                                         $this->Common_model->common_update('category',$values,$where);
  8817.                                                         $this->Common_model->Set_Message('1',"Category  updated");
  8818.                                                        
  8819.                                                 }
  8820.                                        
  8821.                                
  8822.                        
  8823.                 }
  8824.                 else
  8825.                 {
  8826.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  8827.                 }
  8828.                 redirect(current_url());
  8829.         }
  8830.         if(isset($_POST['delete']))
  8831.         {
  8832.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  8833.                 if($this->form_validation->run())
  8834.                 {
  8835.                         $delete_id = $this->input->post('delete_id');
  8836.                        
  8837.                                 $where = array('category_id'=>$delete_id);
  8838.                                 $value = array('is_deleted'=>'1');
  8839.                                 $this->Common_model->common_update('category',$value,$where);
  8840.                                 $this->Common_model->Set_Message('1','Category Removed Successfully');
  8841.  
  8842.                        
  8843.                 }
  8844.                 else
  8845.                 {
  8846.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  8847.                 }
  8848.                 redirect(current_url());
  8849.         }
  8850.         // make payment
  8851.  
  8852.         # FILTER AND PAGINATION SECTION
  8853.         $URL = $this->uri->segment(1);
  8854.         $param[] = array('key'=>'country_admin_id','default'=>'');
  8855.         $param[] = array('key'=>'start_date','default'=>date('01/m/Y'));
  8856.         $param[] = array('key'=>'end_date','default'=>date('t/m/Y'));
  8857.         $FD = $this->Common_model->common_filter($URL,$param);
  8858.  
  8859.         $start = $limit = '';
  8860.         $page_ary['url'] = base_url($URL);
  8861.         $page_ary['total_rows'] = $this->Manage_model->category_list($FD,$start,$limit,'1')[0]->count;
  8862.         $limit = $page_ary['per_page'] = 30;
  8863.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  8864.         $data['page'] = $start = $PGN_DATA['page'];
  8865.         $data['links'] = $PGN_DATA['links'];
  8866.         # END OF FILTER AND PAGINATION SECTION
  8867.  
  8868.         $data['FD'] = $FD;
  8869.         $data['CAL'] = $this->Manage_model->category_type_master();
  8870.         $data['CAT'] = $this->Manage_model->category_list($FD,$start,$limit,'0');
  8871.         $this->CommonPage('manage/category', $data, 'Manage Category');
  8872. }
  8873.  
  8874.  
  8875. public function get_category_data()
  8876. {
  8877.         $Data['response'] = 'failed';
  8878.         $Data['result'] = array();
  8879.  
  8880.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  8881.        
  8882.         if($this->form_validation->run())
  8883.         { 
  8884.                 $category_id = $this->input->post('data_id');
  8885.                 $Result = $this->Manage_model->get_category_details($category_id);
  8886.                 if(!empty($Result))
  8887.                 {
  8888.                         $Data['response'] = 'success';
  8889.                         $Data['result'] = $Result;
  8890.                 }
  8891.         }
  8892.         echo json_encode($Data);
  8893.         exit;
  8894. }
  8895.  
  8896. ############################################ END OF Category  #######################
  8897. ############################################ CMS Pages Start  #######################
  8898.  
  8899.  
  8900. ############################################FAQS Starts #############
  8901.  
  8902. public function get_faq_data()
  8903. {
  8904.         $Data['response'] = 'failed';
  8905.         $Data['result'] = array();
  8906.  
  8907.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  8908.        
  8909.         if($this->form_validation->run())
  8910.         { 
  8911.                 $faq_id = $this->input->post('data_id');
  8912.                 $Result = $this->Manage_model->get_faq_details($faq_id);
  8913.                 if(!empty($Result))
  8914.                 {
  8915.                         $Data['response'] = 'success';
  8916.                         $Data['result'] = $Result;
  8917.                 }
  8918.         }
  8919.         echo json_encode($Data);
  8920.         exit;
  8921. }public function get_tutorials_data()
  8922. {
  8923.         $Data['response'] = 'failed';
  8924.         $Data['result'] = array();
  8925.  
  8926.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  8927.        
  8928.         if($this->form_validation->run())
  8929.         { 
  8930.                 $faq_id = $this->input->post('data_id');
  8931.                 $Result = $this->Manage_model->get_tutorials_details($faq_id);
  8932.                 if(!empty($Result))
  8933.                 {
  8934.                         $Data['response'] = 'success';
  8935.                         $Data['result'] = $Result;
  8936.                 }
  8937.         }
  8938.         echo json_encode($Data);
  8939.         exit;
  8940. }
  8941. public function manage_faqs()
  8942. {
  8943.         # INSERT / UPDATE FUNCTION
  8944.        
  8945.         if(isset($_POST['submit']))
  8946.         {
  8947.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  8948.                
  8949.                 $this->form_validation->set_rules('question','question','trim|required|xss_clean');
  8950.                 $this->form_validation->set_rules('answer','answer','trim|required|xss_clean');
  8951.                
  8952.        
  8953.                 if($this->form_validation->run())
  8954.                 { 
  8955.                        
  8956.                         $faq_status = $this->input->post('faq_status');
  8957.                         $faq_category_id = $this->input->post('faq_category_id');            
  8958.                         $faq_id  = $this->input->post('faq_id');
  8959.                         $language = $this->input->post('language');
  8960.                         $question = $this->input->post('question');
  8961.                         $answer = $this->input->post('answer');      
  8962.                         $faq_status = $this->input->post('faq_status');                      
  8963.                         $submit = $this->input->post('submit');
  8964.                         $values = array('faq_category_id'=>$faq_category_id,                                         
  8965.                                                         'type_name'=>"web",
  8966.                                                         'language'=>$language,
  8967.                                                         'question'=>$question,
  8968.                                                         'faq_status'=>$faq_status,
  8969.                                                         'answer'=>$answer);
  8970.                   if($submit=='Save')
  8971.                         {
  8972.                                 $faq_id = $this->Common_model->common_insert('faq',$values);
  8973.                                 $this->Common_model->Set_Message('1',"<strong>faq details added successfully</strong>");
  8974.                                 redirect(current_url());
  8975.                                
  8976.                         }
  8977.                         else
  8978.                         {
  8979.                             $where = array('faq_id'=>$faq_id);                           
  8980.                                 $this->Common_model->common_update('faq',$values,$where);
  8981.                                 $this->Common_model->Set_Message('1',"<strong>Sucess!</strong>faq Updated successfully.");
  8982.                         }
  8983.                         redirect(current_url());
  8984.                 }
  8985.                 else
  8986.                 { $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  8987.                                 redirect(current_url());
  8988.                         if($this->input->post('submit')=='Update')
  8989.                         { 
  8990.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  8991.                                 redirect(current_url());
  8992.                         }
  8993.                 }
  8994.         }
  8995.         # END OF INSERT / UPDATE FUNCTION
  8996.  
  8997.         # DELETE FUNCTION
  8998.  
  8999.         if(isset($_POST['delete']))
  9000.         { 
  9001.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  9002.                 if($this->form_validation->run())
  9003.                 {
  9004.                         $delete_id = $this->input->post('delete_id');
  9005.                        
  9006.                                 $where = array('faq_id'=>$delete_id);
  9007.                                 $value = array('faq_status'=>'1');
  9008.                                 $this->Common_model->common_update('faq',$value,$where);
  9009.                                 $this->Common_model->Set_Message('1','faq Removed Successfully');
  9010.  
  9011.                        
  9012.                 }
  9013.                 else
  9014.                 {
  9015.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  9016.                 }
  9017.                 redirect(current_url());
  9018.         }
  9019.         # END OF DELETE FUNCTION
  9020.  
  9021.         # FILTER AND PAGINATION SECTION
  9022.         $FD = array();
  9023.  
  9024.         if($this->session->userdata('logged_in')['privilege_id']==6)
  9025.         {
  9026.                 $FD['country_id'] = $this->session->userdata('logged_in')['table_id']; // for country admin only
  9027.         }
  9028.  
  9029.         $URL = $this->uri->segment(1);
  9030.         $start = $limit = '';
  9031.         $page_ary['url'] = base_url($URL);
  9032.         $page_ary['total_rows'] = $this->Manage_model->view_faqs_admin($FD,$start,$limit,'1',0)[0]->count;
  9033.         $page_ary['total_rows_ar'] = $this->Manage_model->view_faqs_admin($FD,$start,$limit,'1',1)[0]->count;
  9034.         $limit = $page_ary['per_page'] = 30;
  9035.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  9036.         $data['page'] = $start = $PGN_DATA['page'];
  9037.         $data['links'] = $PGN_DATA['links'];
  9038.         # END OF FILTER AND PAGINATION SECTION
  9039.  
  9040.         $data['CountryData'] = $this->Manage_model->select_view_country_org();
  9041.         $data['FAQCAT'] = $this->Manage_model->get_category_List('3');
  9042.         $data['FAQEN'] = $this->Manage_model->view_faqs_admin($FD,$start,$limit,'0',0);
  9043.         $data['FAQAR'] = $this->Manage_model->view_faqs_admin($FD,$start,$limit,'0',1);
  9044.  
  9045.         $this->CommonPage('cms/manage_faqs',$data,'View FAQS');
  9046. }
  9047. ############################################ END OF FAQS  ###############################
  9048.  
  9049.  
  9050. public function privacy_policy()
  9051. {   $data=array();
  9052.        
  9053.         if(isset($_POST['submit']))
  9054.         {
  9055.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  9056.                
  9057.                 $this->form_validation->set_rules('contant_en','question','trim|required|xss_clean');
  9058.                
  9059.        
  9060.                 if($this->form_validation->run())
  9061.                 { 
  9062.                        
  9063.                         $contant_en = $this->input->post('contant_en');
  9064.                         $faq_category_id = $this->input->post('faq_category_id');            
  9065.                         $page_id  = $this->input->post('page_id');
  9066.                         $contant_ar = $this->input->post('contant_ar');
  9067.                                                
  9068.                         $submit = $this->input->post('submit');
  9069.                         $values = array('contant_ar'=>$contant_ar,                                           
  9070.                                                         'contant_en'=>$contant_en);
  9071.                  
  9072.                             $where = array('page_id'=>$page_id);                         
  9073.                                 $this->Common_model->common_update('home_cms',$values,$where);
  9074.                                 $this->Common_model->Set_Message('1',"<strong>Sucess!</strong> Updated successfully.");
  9075.                
  9076.                         redirect(current_url());
  9077.                 }
  9078.                 else
  9079.                 { $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  9080.                                 redirect(current_url());
  9081.                         if($this->input->post('submit')=='Update')
  9082.                         { 
  9083.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  9084.                                 redirect(current_url());
  9085.                         }
  9086.                 }
  9087.         }
  9088.         $data["contant"] = $this->Manage_model->get_cms_details("privacy-policy");
  9089.         $this->CommonPage('cms/privacy_policy',$data,'Privacy Policy');
  9090. }
  9091.  
  9092. public function terms_conditions()
  9093. {if(isset($_POST['submit']))
  9094.         {
  9095.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  9096.                
  9097.                 $this->form_validation->set_rules('contant_en','question','trim|required|xss_clean');
  9098.                
  9099.        
  9100.                 if($this->form_validation->run())
  9101.                 { 
  9102.                        
  9103.                         $contant_en = $this->input->post('contant_en');
  9104.                         $faq_category_id = $this->input->post('faq_category_id');            
  9105.                         $page_id  = $this->input->post('page_id');
  9106.                         $contant_ar = $this->input->post('contant_ar');
  9107.                                                
  9108.                         $submit = $this->input->post('submit');
  9109.                         $values = array('contant_ar'=>$contant_ar,                                           
  9110.                                                         'contant_en'=>$contant_en);
  9111.                  
  9112.                             $where = array('page_id'=>$page_id);                         
  9113.                                 $this->Common_model->common_update('home_cms',$values,$where);
  9114.                                 $this->Common_model->Set_Message('1',"<strong>Sucess!</strong> Updated successfully.");
  9115.                
  9116.                         redirect(current_url());
  9117.                 }
  9118.                 else
  9119.                 { $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  9120.                                 redirect(current_url());
  9121.                         if($this->input->post('submit')=='Update')
  9122.                         { 
  9123.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  9124.                                 redirect(current_url());
  9125.                         }
  9126.                 }
  9127.         }
  9128.         $data["contant"] = $this->Manage_model->get_cms_details("terms-conditions");
  9129.         $this->CommonPage('cms/terms_conditions',$data,'Terms conditions');
  9130. }public function about_us()
  9131. {   if(isset($_POST['submit']))
  9132.         {
  9133.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  9134.                
  9135.                 $this->form_validation->set_rules('contant_en','question','trim|required|xss_clean');
  9136.                
  9137.        
  9138.                 if($this->form_validation->run())
  9139.                 { 
  9140.                        
  9141.                         $contant_en = $this->input->post('contant_en');
  9142.                         $contant_ar = $this->input->post('contant_ar');      
  9143.                        
  9144.                         $vision_en = $this->input->post('vision_en');
  9145.                         $vision_ar = $this->input->post('vision_ar');
  9146.                        
  9147.                         $mission_en = $this->input->post('mission_en');
  9148.                         $mission_ar = $this->input->post('mission_ar');      
  9149.                        
  9150.                         $team_en = $this->input->post('team_en');
  9151.                         $team_ar = $this->input->post('team_ar');
  9152.                        
  9153.                         $page_id  = $this->input->post('page_id');
  9154.                        
  9155.                                                
  9156.                         $submit = $this->input->post('submit');
  9157.                         $values = array('contant_ar'=>$contant_ar,                                           
  9158.                                                         'contant_en'=>$contant_en,
  9159.                                                         'vision_en'=>$vision_en,                                               
  9160.                                                         'vision_ar'=>$vision_ar,
  9161.                                                         'mission_en'=>$mission_en,                                             
  9162.                                                         'mission_ar'=>$mission_ar,
  9163.                                                         'team_en'=>$team_en,                                           
  9164.                                                         'team_ar'=>$team_ar);
  9165.                  
  9166.                             $where = array('page_id'=>$page_id);                         
  9167.                                 $this->Common_model->common_update('home_cms',$values,$where);
  9168.                                 $this->Common_model->Set_Message('1',"<strong>Sucess!</strong> Updated successfully.");
  9169.                
  9170.                         redirect(current_url());
  9171.                 }
  9172.                 else
  9173.                 { $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  9174.                                 redirect(current_url());
  9175.                         if($this->input->post('submit')=='Update')
  9176.                         { 
  9177.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  9178.                                 redirect(current_url());
  9179.                         }
  9180.                 }
  9181.         }
  9182.         $data["contant"] = $this->Manage_model->get_cms_details("about");
  9183.         $this->CommonPage('cms/about_us',$data,'About Us');
  9184. }
  9185.  
  9186. public function contact_us()
  9187. {   if(isset($_POST['submit']))
  9188.         {
  9189.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  9190.                
  9191.                 $this->form_validation->set_rules('title','title','trim|required|xss_clean');
  9192.                
  9193.        
  9194.                 if($this->form_validation->run())
  9195.                 { 
  9196.                        
  9197.                         $title = $this->input->post('title');
  9198.                         $email = $this->input->post('email');
  9199.                        
  9200.                         $phone = $this->input->post('phone');
  9201.                         $address = $this->input->post('address');    
  9202.                        
  9203.                         $fb_link = $this->input->post('fb_link');
  9204.                         $insta_link = $this->input->post('insta_link');      
  9205.                        
  9206.                         $youtube_link = $this->input->post('youtube_link');
  9207.                         $twitter_link = $this->input->post('twitter_link');  
  9208.                         $linkedin_link = $this->input->post('linkedin_link');
  9209.                        
  9210.                         $page_id  =1;
  9211.                        
  9212.                                                
  9213.                         $submit = $this->input->post('submit');
  9214.                         $values = array('title'=>$title,                                             
  9215.                                                         'email'=>$email,
  9216.                                                         'phone'=>$phone,                                               
  9217.                                                         'address'=>$address,
  9218.                                                         'fb_link'=>$fb_link,                                           
  9219.                                                         'insta_link'=>$insta_link,
  9220.                                                         'youtube_link'=>$youtube_link,                                         
  9221.                                                         'twitter_link'=>$twitter_link,                                         
  9222.                                                         'linkedin_link'=>$linkedin_link);
  9223.                  
  9224.                             $where = array('id'=>$page_id);                              
  9225.                                 $this->Common_model->common_update('home_contant_us',$values,$where);
  9226.                                 $this->Common_model->Set_Message('1',"<strong>Sucess!</strong> Updated successfully.");
  9227.                
  9228.                         redirect(current_url());
  9229.                 }
  9230.                 else
  9231.                 { $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  9232.                                 redirect(current_url());
  9233.                         if($this->input->post('submit')=='Update')
  9234.                         { 
  9235.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  9236.                                 redirect(current_url());
  9237.                         }
  9238.                 }
  9239.         }
  9240.         $data["contant"] = $this->Manage_model->get_contact_details();
  9241.         $this->CommonPage('cms/contact_us',$data,'Contact Us');
  9242. }public function faq_organization()
  9243. {
  9244.         # INSERT / UPDATE FUNCTION
  9245.        
  9246.         if(isset($_POST['submit']))
  9247.         {
  9248.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  9249.                
  9250.                 $this->form_validation->set_rules('question','question','trim|required|xss_clean');
  9251.                 $this->form_validation->set_rules('answer','answer','trim|required|xss_clean');
  9252.                
  9253.        
  9254.                 if($this->form_validation->run())
  9255.                 { 
  9256.                        
  9257.                         $faq_status = $this->input->post('faq_status');
  9258.                         $faq_category_id = $this->input->post('faq_category_id');            
  9259.                         $faq_id  = $this->input->post('faq_id');
  9260.                         $language = 0;
  9261.                         $question = $this->input->post('question');
  9262.                         $answer = $this->input->post('answer');      
  9263.                         $faq_status = $this->input->post('faq_status');                      
  9264.                         $submit = $this->input->post('submit');
  9265.                         $values = array('faq_category_id'=>$faq_category_id,                                         
  9266.                                                         'type_name'=>"org",
  9267.                                                         'language'=>$language,
  9268.                                                         'question'=>$question,
  9269.                                                         'faq_status'=>$faq_status,
  9270.                                                         'answer'=>$answer);
  9271.                   if($submit=='Save')
  9272.                         {
  9273.                                 $faq_id = $this->Common_model->common_insert('faq',$values);
  9274.                                 $this->Common_model->Set_Message('1',"<strong>faq details added successfully</strong>");
  9275.                                 redirect(current_url());
  9276.                                
  9277.                         }
  9278.                         else
  9279.                         {
  9280.                             $where = array('faq_id'=>$faq_id);                           
  9281.                                 $this->Common_model->common_update('faq',$values,$where);
  9282.                                 $this->Common_model->Set_Message('1',"<strong>Sucess!</strong>faq Updated successfully.");
  9283.                         }
  9284.                         redirect(current_url());
  9285.                 }
  9286.                 else
  9287.                 { $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  9288.                                 redirect(current_url());
  9289.                         if($this->input->post('submit')=='Update')
  9290.                         { 
  9291.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  9292.                                 redirect(current_url());
  9293.                         }
  9294.                 }
  9295.         }
  9296.         # END OF INSERT / UPDATE FUNCTION
  9297.  
  9298.         # DELETE FUNCTION
  9299.  
  9300.         if(isset($_POST['delete']))
  9301.         { 
  9302.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  9303.                 if($this->form_validation->run())
  9304.                 {
  9305.                         $delete_id = $this->input->post('delete_id');
  9306.                        
  9307.                                 $where = array('faq_id'=>$delete_id);
  9308.                                 $value = array('faq_status'=>'1');
  9309.                                 $this->Common_model->common_update('faq',$value,$where);
  9310.                                 $this->Common_model->Set_Message('1','faq Removed Successfully');
  9311.  
  9312.                        
  9313.                 }
  9314.                 else
  9315.                 {
  9316.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  9317.                 }
  9318.                 redirect(current_url());
  9319.         }
  9320.         # END OF DELETE FUNCTION
  9321.  
  9322.         # FILTER AND PAGINATION SECTION
  9323.         $FD = array();
  9324.  
  9325.         if($this->session->userdata('logged_in')['privilege_id']==6)
  9326.         {
  9327.                 $FD['country_id'] = $this->session->userdata('logged_in')['table_id']; // for country admin only
  9328.         }
  9329.  
  9330.         $URL = $this->uri->segment(1);
  9331.         $start = $limit = '';
  9332.         $page_ary['url'] = base_url($URL);
  9333.         $page_ary['total_rows'] = $this->Manage_model->view_faqs_org($FD,$start,$limit,'1',0)[0]->count;
  9334.        
  9335.         $limit = $page_ary['per_page'] = 30;
  9336.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  9337.         $data['page'] = $start = $PGN_DATA['page'];
  9338.         $data['links'] = $PGN_DATA['links'];
  9339.         # END OF FILTER AND PAGINATION SECTION
  9340.  
  9341.         $data['CountryData'] = $this->Manage_model->select_view_country_org();
  9342.         $data['FAQCAT'] = $this->Manage_model->get_category_List('4');
  9343.         $data['FAQEN'] = $this->Manage_model->view_faqs_org($FD,$start,$limit,'0',0);
  9344.        
  9345.  
  9346.         $this->CommonPage('cms/faq_organization',$data,'faq-organization');
  9347. }
  9348. public function tutorials_organization()
  9349. {
  9350.         # INSERT / UPDATE FUNCTION
  9351.        
  9352.         if(isset($_POST['submit']))
  9353.         {
  9354.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  9355.                
  9356.                 $this->form_validation->set_rules('title','link_url','trim|required|xss_clean');
  9357.                 $this->form_validation->set_rules('link_url','link_url','trim|required|xss_clean');    
  9358.                
  9359.        
  9360.                 if($this->form_validation->run())
  9361.                 { 
  9362.                        
  9363.                         $status = $this->input->post('t_status');
  9364.                         // $title = $this->input->post('title');            
  9365.                         $id   = $this->input->post('id');
  9366.                         $language = 0;
  9367.                         $title = $this->input->post('title');
  9368.                         $link_url = $this->input->post('link_url');
  9369.                         $submit = $this->input->post('submit');
  9370.                         $values = array('title'=>$title,
  9371.                                                         'link_url'=>$link_url,                                                 
  9372.                                                         'status'=>$status);
  9373.                   if($submit=='Save')
  9374.                         {
  9375.                                 $id = $this->Common_model->common_insert('organization_tutorials',$values);
  9376.                                 $this->Common_model->Set_Message('1',"<strong>organization tutorials details added successfully</strong>");
  9377.                                 redirect(current_url());
  9378.                                
  9379.                         }
  9380.                         else
  9381.                         {
  9382.                             $where = array('id'=>$id);                           
  9383.                                 $this->Common_model->common_update('organization_tutorials',$values,$where);
  9384.                                 $this->Common_model->Set_Message('1',"<strong>Sucess!</strong>organization tutorials Updated successfully.");
  9385.                         }
  9386.                         redirect(current_url());
  9387.                 }
  9388.                 else
  9389.                 { $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  9390.                                 redirect(current_url());
  9391.                         if($this->input->post('submit')=='Update')
  9392.                         { 
  9393.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  9394.                                 redirect(current_url());
  9395.                         }
  9396.                 }
  9397.         }
  9398.         # END OF INSERT / UPDATE FUNCTION
  9399.  
  9400.         # DELETE FUNCTION
  9401.  
  9402.         if(isset($_POST['delete']))
  9403.         { 
  9404.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  9405.                 if($this->form_validation->run())
  9406.                 {
  9407.                         $delete_id = $this->input->post('delete_id');
  9408.                        
  9409.                                 $where = array('id'=>$delete_id);
  9410.                                 $value = array('is_deleted'=>'1');
  9411.                                 $this->Common_model->common_update('organization_tutorials',$value,$where);
  9412.                                 $this->Common_model->Set_Message('1','faq Removed Successfully');
  9413.  
  9414.                        
  9415.                 }
  9416.                 else
  9417.                 {
  9418.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  9419.                 }
  9420.                 redirect(current_url());
  9421.         }
  9422.         # END OF DELETE FUNCTION
  9423.  
  9424.         # FILTER AND PAGINATION SECTION
  9425.         $FD = array();
  9426.  
  9427.         if($this->session->userdata('logged_in')['privilege_id']==6)
  9428.         {
  9429.                 $FD['country_id'] = $this->session->userdata('logged_in')['table_id']; // for country admin only
  9430.         }
  9431.  
  9432.         $URL = $this->uri->segment(1);
  9433.         $start = $limit = '';
  9434.         $page_ary['url'] = base_url($URL);
  9435.         $page_ary['total_rows'] = $this->Manage_model->view_organization_tutorials($FD,$start,$limit,'1',0)[0]->count;
  9436.        
  9437.         $limit = $page_ary['per_page'] = 30;
  9438.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  9439.         $data['page'] = $start = $PGN_DATA['page'];
  9440.         $data['links'] = $PGN_DATA['links'];
  9441.         # END OF FILTER AND PAGINATION SECTION
  9442.  
  9443.         $data['Tutorials'] = $this->Manage_model->view_organization_tutorials($FD,$start,$limit,'0',0);
  9444.         $this->CommonPage('cms/tutorials',$data,'Tutorials');
  9445. }
  9446.  
  9447.  
  9448. public function app_links_organization()
  9449. {   $data=array();
  9450.         $this->load->model('Payment_model');
  9451.         $CountryData = $this->Manage_model->get_organization_country_details();
  9452.         $organizations_id = $this->session->userdata('logged_in')['table_id'];
  9453.         $this->CommonPage('cms/app_links',$data,'app-links');
  9454. }
  9455. public function get_seo_data()
  9456. {
  9457.         $Data['response'] = 'failed';
  9458.         $Data['result'] = array();
  9459.  
  9460.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  9461.        
  9462.         if($this->form_validation->run())
  9463.         { 
  9464.                 $seo_id = $this->input->post('data_id');
  9465.                 $Result = $this->Manage_model->get_seo_details($seo_id);
  9466.                 if(!empty($Result))
  9467.                 {
  9468.                         $Data['response'] = 'success';
  9469.                         $Data['result'] = $Result;
  9470.                 }
  9471.         }
  9472.         echo json_encode($Data);
  9473.         exit;
  9474. }
  9475. public function manage_seo()
  9476. {   # INSERT / UPDATE FUNCTION
  9477.        
  9478.         if(isset($_POST['submit']))
  9479.         {
  9480.                 $this->form_validation->set_error_delimiters('<div class="ci-form-error">', '</div>');
  9481.                
  9482.                 $this->form_validation->set_rules('meta_title_en','link_url','trim|required|xss_clean');
  9483.                 //$this->form_validation->set_rules('link_url','link_url','trim|required|xss_clean');  
  9484.                
  9485.        
  9486.                 if($this->form_validation->run())
  9487.                 { 
  9488.                        
  9489.                         $meta_title_en = $_POST["meta_title_en"];
  9490.                         $meta_title_ar = $_POST["meta_title_ar"];            
  9491.                         $id   = $_POST["seo_id"];
  9492.                         $header_script_en = $_POST["header_script_en"];
  9493.                         $header_script_ar = $_POST["header_script_ar"];
  9494.                         $meta_keyword_en = $_POST["meta_keyword_en"];
  9495.                         $meta_keyword_ar = $_POST["meta_keyword_ar"];
  9496.                         $slug = $_POST["slug"];
  9497.                         $submit = $this->input->post('submit');
  9498.                         $values = array('meta_title_en'=>$meta_title_en,
  9499.                                                         'meta_title_ar'=>$meta_title_ar,
  9500.                                                         'header_script_en'=>$header_script_en,
  9501.                                                         'header_script_ar'=>$header_script_ar,
  9502.                                                         'meta_keywords_en'=>$meta_keyword_en,
  9503.                                                         'meta_keywords_ar'=>$meta_keyword_ar,                                                  
  9504.                                                         'slug'=>$slug);
  9505.                   if($submit=='Save')
  9506.                         {
  9507.                                 $id = $this->Common_model->common_insert('seo',$values);
  9508.                                 $this->Common_model->Set_Message('1',"<strong> details added successfully</strong>");
  9509.                                 redirect(current_url());
  9510.                                
  9511.                         }
  9512.                         else
  9513.                         {
  9514.                             $where = array('seo_id'=>$id);                               
  9515.                                 $this->Common_model->common_update('seo',$values,$where);
  9516.                                 $this->Common_model->Set_Message('1',"<strong>Sucess!</strong>Updated successfully.");
  9517.                         }
  9518.                         redirect(current_url());
  9519.                 }
  9520.                 else
  9521.                 { $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  9522.                                 redirect(current_url());
  9523.                         if($this->input->post('submit')=='Update')
  9524.                         { 
  9525.                                 $this->Common_model->Set_Message('2','<strong>Error!</strong>Oops something went wrong. Please try again.');
  9526.                                 redirect(current_url());
  9527.                         }
  9528.                 }
  9529.         }
  9530.         # END OF INSERT / UPDATE FUNCTION
  9531.  
  9532.         # DELETE FUNCTION
  9533.  
  9534.         if(isset($_POST['delete']))
  9535.         { 
  9536.                 $this->form_validation->set_rules('delete_id','Delete ID','trim|xss_clean|required');
  9537.                 if($this->form_validation->run())
  9538.                 {
  9539.                         $delete_id = $this->input->post('delete_id');
  9540.                        
  9541.                                 $where = array('id'=>$delete_id);
  9542.                                 $value = array('is_deleted'=>'1');
  9543.                                 $this->Common_model->common_update('organization_tutorials',$value,$where);
  9544.                                 $this->Common_model->Set_Message('1','faq Removed Successfully');
  9545.  
  9546.                        
  9547.                 }
  9548.                 else
  9549.                 {
  9550.                         $this->Common_model->Set_Message('2','<strong>Error!</strong> Oops something went wrong. Please try again.');
  9551.                 }
  9552.                 redirect(current_url());
  9553.         }
  9554.         # END OF DELETE FUNCTION
  9555.  
  9556.         # FILTER AND PAGINATION SECTION
  9557.         $FD = array();
  9558.  
  9559.         if($this->session->userdata('logged_in')['privilege_id']==6)
  9560.         {
  9561.                 $FD['country_id'] = $this->session->userdata('logged_in')['table_id']; // for country admin only
  9562.         }
  9563.  
  9564.         $URL = $this->uri->segment(1);
  9565.         $start = $limit = '';
  9566.         $page_ary['url'] = base_url($URL);
  9567.         $page_ary['total_rows'] = $this->Manage_model->viewSEO($FD,$start,$limit,'1')[0]->count;
  9568.        
  9569.         $limit = $page_ary['per_page'] = 30;
  9570.         $PGN_DATA = $this->Common_model->Pagination($page_ary);
  9571.         $data['page'] = $start = $PGN_DATA['page'];
  9572.         $data['links'] = $PGN_DATA['links'];
  9573.         # END OF FILTER AND PAGINATION SECTION
  9574.  
  9575.         $data['seo'] = $this->Manage_model->viewSEO($FD,$start,$limit,'0');
  9576.  
  9577.         $this->CommonPage('cms/seo',$data,'Seo Appliction');
  9578. }
  9579. ############################################ END OF CMS  #######################
  9580.  
  9581.  
  9582.  
  9583. public function get_meeting_data()
  9584. {
  9585.         $Data['response'] = 'failed';
  9586.         $Data['result'] = array();
  9587.  
  9588.         $this->form_validation->set_rules('data_id','data_id','trim|required|xss_clean|numeric');
  9589.         if($this->form_validation->run())
  9590.         {
  9591.                 $product_id = $this->input->post('data_id');
  9592.                 $Result = $this->Manage_model->get_meeting_details($product_id);
  9593.                 if(!empty($Result))
  9594.                 {
  9595.                         $Data['response'] = 'success';
  9596.                         $Data['result'] = $Result;
  9597.                 }
  9598.         }
  9599.         echo json_encode($Data);
  9600. }
  9601. }
File Description
  • home
  • PHP Code
  • 30 Aug-2023
  • 367.24 Kb
You can Share it: