Initial import of Din Beste Hjelper site
CodeIgniter 3 app for dinbestehjelper.no. Excludes vendor/, local backup folders (new/, archive/, archived/) and DB dumps (*.sql) via .gitignore. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P16ttGUge8zj91dm6WrmEb
This commit is contained in:
@@ -0,0 +1,744 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Admin extends CI_Controller {
|
||||
|
||||
/**
|
||||
* Index Page for this controller.
|
||||
*
|
||||
* Maps to the following URL
|
||||
* http://example.com/index.php/welcome
|
||||
* - or -
|
||||
* http://example.com/index.php/welcome/index
|
||||
* - or -
|
||||
* Since this controller is set as the default controller in
|
||||
* config/routes.php, it's displayed at http://example.com/
|
||||
*
|
||||
* So any other public methods not prefixed with an underscore will
|
||||
* map to /index.php/welcome/<method_name>
|
||||
* @see https://codeigniter.com/userguide3/general/urls.html
|
||||
*/
|
||||
public function dashboard(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['pageTitle'] = 'Vezérlőpult';
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
$this->load->view('admin/dashboard', $data);
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
}
|
||||
|
||||
public function services(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['pageTitle'] = 'Szolgáltatások';
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
$data['results'] = $this->Service_model->getAllServices();
|
||||
|
||||
$this->load->view('admin/services', $data);
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
}
|
||||
|
||||
public function add_service(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['pageTitle'] = 'Szolgáltatás hozzáadás';
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
|
||||
$this->load->view('admin/add-service', $data);
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
}
|
||||
|
||||
public function update_service($service_id){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['pageTitle'] = 'Szolgáltatás módosítása (#'.$service_id.')';
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
$data['selectedItem'] = $this->Service_model->getServiceById($service_id);
|
||||
$this->load->view('admin/update-service', $data);
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
}
|
||||
|
||||
public function service_process(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Log_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['pageTitle'] = '';
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
|
||||
if(isset($_GET['delete-service'])){
|
||||
$selected_service = $this->Service_model->getServiceById($_GET['delete-service']);
|
||||
$serviceArray = array(
|
||||
'is_deleted' => '1'
|
||||
);
|
||||
|
||||
$this->Service_model->updateService($_GET['delete-service'], $serviceArray);
|
||||
$this->Log_model->addLog('services', $data['currentUser']->username.' törölte a(z) '.$_GET['delete-service'].' számú szolgáltatást ('.$selected_service->service_name_hu.')', $data['currentUser']->username);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['addNewService'])){
|
||||
$serviceArray = array(
|
||||
'main_category' => $_POST['main_category'],
|
||||
'main_category_description' => $_POST['main_category_description'],
|
||||
'service_category' => $_POST['service_category'],
|
||||
'service_name' => $_POST['service_name'],
|
||||
'service_description' => $_POST['service_description'],
|
||||
'service_price' => $_POST['service_price'],
|
||||
'service_time' => $_POST['service_time'],
|
||||
'is_enabled' => $_POST['is_enabled']
|
||||
);
|
||||
|
||||
$this->Log_model->addLog('services', $data['currentUser']->username.' hozzáadta a(z) '.$_POST['service_name'].' szolgáltatást ('.implode(',',$serviceArray).')', $data['currentUser']->username);
|
||||
$this->Service_model->createService($serviceArray);
|
||||
}
|
||||
|
||||
if(isset($_POST['updateService'])){
|
||||
$serviceArray = array(
|
||||
'main_category' => $_POST['main_category'],
|
||||
'main_category_description' => $_POST['main_category_description'],
|
||||
'service_category' => $_POST['service_category'],
|
||||
'service_name' => $_POST['service_name'],
|
||||
'service_description' => $_POST['service_description'],
|
||||
'service_price' => $_POST['service_price'],
|
||||
'service_time' => $_POST['service_time'],
|
||||
'is_enabled' => $_POST['is_enabled']
|
||||
);
|
||||
|
||||
$this->Log_model->addLog('services', $data['currentUser']->username.' módosította a(z) '.$_POST['service_name'].' szolgáltatást ('.implode(',',$serviceArray).')', $data['currentUser']->username);
|
||||
$this->Service_model->updateService($_POST['service_id'], $serviceArray);
|
||||
}
|
||||
|
||||
header('Location:'.SITEURL.'services');
|
||||
$this->load->view('admin/service-process', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function groups(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Group_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['pageTitle'] = 'Csoportok';
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
$data['results'] = $this->Group_model->getAllGroups();
|
||||
|
||||
$this->load->view('admin/groups', $data);
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
}
|
||||
|
||||
public function add_group(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Group_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['pageTitle'] = 'Csoport hozzáadása';
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
|
||||
$this->load->view('admin/add-group', $data);
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
}
|
||||
|
||||
public function update_group($group_id){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Group_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['pageTitle'] = 'Csoport módosítása (#'.$group_id.')';
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
$data['selectedItem'] = $this->Group_model->getGroupById($group_id);
|
||||
$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
$this->load->view('admin/update-group', $data);
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
}
|
||||
|
||||
public function group_process(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Group_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Log_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['pageTitle'] = '';
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
|
||||
if(isset($_GET['delete-group'])){
|
||||
$selected_group = $this->Group_model->getGroupById($_GET['delete-group']);
|
||||
$groupArray = array(
|
||||
'is_deleted' => '1'
|
||||
);
|
||||
|
||||
$this->Service_model->updateGroup($_GET['group-group'], $groupArray);
|
||||
$this->Log_model->addLog('groups', $data['currentUser']->username.' törölte a(z) '.$_GET['delete-group'].' számú csoportot ('.$selected_group->group_group.')', $data['currentUser']->username);
|
||||
}
|
||||
|
||||
|
||||
if(isset($_POST['addNewGroup'])){
|
||||
|
||||
$data['group_profile_img'] = '';
|
||||
|
||||
if($_FILES["group_profile_img"]["tmp_name"] != ''){
|
||||
$target_dir = getcwd()."/assets/img/";
|
||||
$target_file = $target_dir . 'group_'.str_replace(' ','_', $_POST['group_name']);
|
||||
$imageFileType = strtolower(pathinfo(basename($_FILES["group_profile_img"]["name"]),PATHINFO_EXTENSION));
|
||||
|
||||
if (move_uploaded_file($_FILES["group_profile_img"]["tmp_name"], $target_file.'.'.$imageFileType)) {
|
||||
$data['message'] = 'A profilkép sikeresen feltöltve!';
|
||||
$data['message_class'] = 'successMessage';
|
||||
$data['group_profile_img'] = 'group_'.str_replace(' ','_', $_POST['group_name']).'.'.$imageFileType;
|
||||
|
||||
} else {
|
||||
$data['message'] = 'Hiba a feltöltés közben!';
|
||||
$data['message_class'] = 'errorMessage';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$skillsArray = array();
|
||||
$services = $this->Service_model->getAllServiceByServiceType();
|
||||
if(is_array($services)){
|
||||
foreach($services as $serviceItem){
|
||||
if(isset($_POST['skill_'.$serviceItem->service_id]) && $_POST['skill_'.$serviceItem->service_id] == '1'){
|
||||
$skillsArray[] = $serviceItem->service_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$groupArray = array(
|
||||
'group_name' => $_POST['group_name'],
|
||||
'group_info' => $_POST['group_info'],
|
||||
'group_profile_img' => $data['group_profile_img'],
|
||||
'skills' => implode(',', $skillsArray),
|
||||
'is_active' => $_POST['is_active'],
|
||||
'group_notes' => $_POST['group_notes']
|
||||
);
|
||||
$this->Log_model->addLog('groups', $data['currentUser']->username.' létrehozta a(z) '.$_POST['group_name'].' nevű csoportot ('.implode(',',$groupArray).')', $data['currentUser']->username);
|
||||
|
||||
$groupArray['skills'] = serialize($skillsArray);
|
||||
$this->Group_model->createGroup($groupArray);
|
||||
}
|
||||
|
||||
if(isset($_POST['updateGroup'])){
|
||||
$data['group_profile_img'] = '';
|
||||
|
||||
$skillsArray = array();
|
||||
$services = $this->Service_model->getAllServiceByServiceType();
|
||||
if(is_array($services)){
|
||||
foreach($services as $serviceItem){
|
||||
if(isset($_POST['skill_'.$serviceItem->service_id]) && $_POST['skill_'.$serviceItem->service_id] == '1'){
|
||||
$skillsArray[] = $serviceItem->service_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$groupArray = array(
|
||||
'group_name' => $_POST['group_name'],
|
||||
'group_info' => $_POST['group_info'],
|
||||
'group_profile_img' => $data['group_profile_img'],
|
||||
'skills' => implode(',', $skillsArray),
|
||||
'is_active' => $_POST['is_active'],
|
||||
'group_notes' => $_POST['group_notes']
|
||||
);
|
||||
$this->Log_model->addLog('groups', $data['currentUser']->username.' módosította a(z) '.$_POST['group_name'].' nevű csoportot ('.implode(',',$groupArray).')', $data['currentUser']->username);
|
||||
|
||||
$groupArray['skills'] = serialize($skillsArray);
|
||||
|
||||
$this->Group_model->updateGroup($_POST['group_id'], $groupArray);
|
||||
|
||||
if($_FILES["group_profile_img"]["tmp_name"] != ''){
|
||||
$target_dir = getcwd()."/assets/img/";
|
||||
$target_file = $target_dir . 'group_'.str_replace(' ','_', $_POST['group_name']);
|
||||
$imageFileType = strtolower(pathinfo(basename($_FILES["group_profile_img"]["name"]),PATHINFO_EXTENSION));
|
||||
|
||||
if (move_uploaded_file($_FILES["group_profile_img"]["tmp_name"], $target_file.'.'.$imageFileType)) {
|
||||
$data['message'] = 'A profilkép sikeresen feltöltve!';
|
||||
$data['message_class'] = 'successMessage';
|
||||
$data['group_profile_img'] = 'group_'.str_replace(' ','_', $_POST['group_name']).'.'.$imageFileType;
|
||||
$groupArray = array(
|
||||
'group_profile_img' => $data['group_profile_img']
|
||||
);
|
||||
|
||||
$this->Log_model->addLog('groups', $data['currentUser']->username.' profilképet állított be a(z) '.$_POST['group_name'].' nevű csoporthoz', $data['currentUser']->username);
|
||||
$this->Group_model->updateGroup($_POST['group_id'], $groupArray);
|
||||
|
||||
} else {
|
||||
$data['message'] = 'Hiba a feltöltés közben!';
|
||||
$data['message_class'] = 'errorMessage';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
header("Location:".SITEURL."groups");
|
||||
$this->load->view('admin/group-process', $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function bookings(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['pageTitle'] = 'Foglalások';
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
$data['results'] = $this->Service_model->getActualBookings();
|
||||
|
||||
$this->load->view('admin/bookings', $data);
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
}
|
||||
|
||||
public function add_booking(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Group_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['pageTitle'] = 'Foglalás hozzáadása';
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
$available_services = $this->Service_model->getAvailableServices();
|
||||
|
||||
$serviceFile = fopen("load_services.json", "w") or die("Unable to open file!");
|
||||
fwrite($serviceFile, json_encode($available_services));
|
||||
fclose($serviceFile);
|
||||
|
||||
$data['workgroups'] = $this->Group_model->getAllGroups();
|
||||
$this->load->view('admin/add-booking', $data);
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
}
|
||||
|
||||
public function update_booking($booking_id){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Module_model');
|
||||
$this->load->model('Group_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['pageTitle'] = 'Foglalás módosítása (#'.$booking_id.')';
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
$available_services = $this->Service_model->getAvailableServices();
|
||||
|
||||
$serviceFile = fopen("load_services.json", "w") or die("Unable to open file!");
|
||||
fwrite($serviceFile, json_encode($available_services));
|
||||
fclose($serviceFile);
|
||||
|
||||
$data['workgroups'] = $this->Group_model->getAllGroups();
|
||||
$data['selectedItem'] = $this->Service_model->getBookingById($booking_id);
|
||||
$this->load->view('admin/update-booking', $data);
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
}
|
||||
|
||||
public function booking_process(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Log_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['pageTitle'] = '';
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
|
||||
if(isset($_GET['delete-booking'])){
|
||||
$selectedBooking = $this->Service_model->getBookingById($_GET['delete-booking']);
|
||||
$this->Service_model->deleteBooking($_GET['delete-booking']);
|
||||
$this->Log_model->addLog('bookings', $data['currentUser']->username.' törölte a(z) '.$_GET['delete-booking'].' számú foglalást ('.$selectedBooking->guest_name.', '.$selectedBooking->guest_email.', '.$selectedBooking->guest_phone.', '.$selectedBooking->booking_date.', '.$selectedBooking->booking_start_time.', '.$selectedBooking->booking_finish_time.', '.$selectedBooking->service_ids.')', $data['currentUser']->username);
|
||||
header('Location:'.SITEURL.'bookings');
|
||||
}
|
||||
|
||||
if(isset($_POST['addNewBookingManual'])){
|
||||
$booking_date = new DateTime(date('Y-m-d', strtotime($_POST['booking_date'])));
|
||||
$end_booking_date = new DateTime(date('Y-m-d', strtotime($_POST['end_booking_date'])));
|
||||
$diff = $booking_date->diff($end_booking_date);
|
||||
|
||||
$selectedServiceArray = array();
|
||||
|
||||
if($_POST['service_ids'] != ''){
|
||||
$selectedServiceArray = explode(',', $_POST['service_ids']);
|
||||
|
||||
}
|
||||
|
||||
if($_POST['booking_date'] != $_POST['end_booking_date'] && $booking_date <= $end_booking_date){
|
||||
for($index = 0; $index <= $diff->days; $index++){
|
||||
$selectedDate = date('Y-m-d', strtotime($_POST['booking_date']. ' + '.$index.' days'));
|
||||
|
||||
|
||||
$bookingArray = array(
|
||||
'guest_name' => $_POST['guest_name'],
|
||||
'guest_email' => $_POST['guest_email'],
|
||||
'guest_phone' => $_POST['guest_phone'],
|
||||
'group_id' => $_POST['group_id'],
|
||||
'booking_date' => $selectedDate,
|
||||
'booking_start_time' => $_POST['booking_start_time'],
|
||||
'booking_finish_time' => $_POST['booking_finish_time'],
|
||||
'service_ids' => serialize($selectedServiceArray),
|
||||
'guest_confirmed' => '0',
|
||||
'guest_confirm_code' => '1234',
|
||||
);
|
||||
$this->Service_model->createBooking($bookingArray);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$bookingArray = array(
|
||||
'guest_name' => $_POST['guest_name'],
|
||||
'guest_email' => $_POST['guest_email'],
|
||||
'guest_phone' => $_POST['guest_phone'],
|
||||
'group_id' => $_POST['group_id'],
|
||||
'booking_date' => $_POST['booking_date'],
|
||||
'booking_start_time' => $_POST['booking_start_time'],
|
||||
'booking_finish_time' => $_POST['booking_finish_time'],
|
||||
'service_ids' => serialize($selectedServiceArray),
|
||||
'guest_confirmed' => '0',
|
||||
'guest_confirm_code' => '1234',
|
||||
);
|
||||
$this->Log_model->addLog('bookings', $data['currentUser']->username.' létrehoza a(z) '.$_POST['guest_name'].' nevű vendég foglalást ('.implode(', ', $bookingArray).')', $data['currentUser']->username);
|
||||
$this->Service_model->createBooking($bookingArray);
|
||||
}
|
||||
|
||||
if($_POST['send_notification']){
|
||||
$worker = $this->Service_model->getWorkerById($bookingArray['worker_id']);
|
||||
|
||||
$services = unserialize($bookingArray['service_ids']);
|
||||
$serviceArray = array();
|
||||
$emailArray = array();
|
||||
|
||||
if(is_array($services)){
|
||||
foreach($services as $serviceItem){
|
||||
$selectedService = $this->Service_model->getServiceById($serviceItem);
|
||||
if(is_object($selectedService)){
|
||||
$serviceArray[] = $selectedService;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$content = '';
|
||||
|
||||
$content = 'Kjære gjest,<br />';
|
||||
$content .= 'Takk for din bestilling!<br />';
|
||||
$content .= '<br />';
|
||||
$content .= '<table>';
|
||||
$content .= '<tr><td>Navn: </td><td>'.$bookingArray['guest_name'].'</td></tr>';
|
||||
$content .= '<tr><td>E-post: </td><td>'.$bookingArray['guest_email'].'</td></tr>';
|
||||
$content .= '<tr><td>Telefon: </td><td>'.$bookingArray['guest_phone'].'</td></tr>';
|
||||
$content .= '<tr><td>Arbeider: </td><td>'.$worker->worker_name.'</td></tr>';
|
||||
$content .= '<tr><td>Dato: </td><td>'.$bookingArray['booking_date'].'</td></tr>';
|
||||
$content .= '<tr><td>Tid: </td><td>'.$bookingArray['booking_start_time'].' - '.$bookingArray['booking_finish_time'].'</td></tr>';
|
||||
$content .= '<tr><td>Tjenester: </td><td><table>';
|
||||
$totalServicePrice = 0;
|
||||
foreach($serviceArray as $serviceArrayItem){
|
||||
$totalServicePrice += $serviceArrayItem->service_price;
|
||||
$content .= '<tr><td>'.$serviceArrayItem->service_name_no.'</td><td>'.$serviceArrayItem->service_price.' kr</td></tr>';
|
||||
}
|
||||
$content .= '</table></td>';
|
||||
$content .= '<tr><td>Totalpris: </td><td><strong>'.$totalServicePrice.' kr</strong></td></tr>';
|
||||
$content .= '</table>';
|
||||
$content .= '<br /> STUDIOBEVE';
|
||||
$this->Log_model->addLog('bookings', $data['currentUser']->username.' új foglalásról norvég nyelvű értesítést küldött a(z) '.$bookingArray['guest_email'].' email címre ('.implode(', ', $bookingArray).')', $data['currentUser']->username);
|
||||
|
||||
$emailItem = array(
|
||||
'addressee_email' => $bookingArray['guest_email'],
|
||||
'addressee_name' => $bookingArray['guest_name'],
|
||||
'subject' => '[dinbestehjelper] Your booking has arrived',
|
||||
'content' => $content,
|
||||
'attachments' => array()
|
||||
);
|
||||
$emailArray[] = $emailItem;
|
||||
|
||||
|
||||
$this->User_model->sendEmail($emailArray);
|
||||
}
|
||||
header('Location:'.SITEURL.'bookings');
|
||||
}
|
||||
|
||||
if(isset($_POST['updateBookingManual'])){
|
||||
$booking_date = new DateTime(date('Y-m-d', strtotime($_POST['booking_date'])));
|
||||
$end_booking_date = new DateTime(date('Y-m-d', strtotime($_POST['end_booking_date'])));
|
||||
$diff = $booking_date->diff($end_booking_date);
|
||||
|
||||
$selectedServiceArray = array();
|
||||
|
||||
if($_POST['service_ids'] != ''){
|
||||
$selectedServiceArray = explode(',', $_POST['service_ids']);
|
||||
|
||||
}
|
||||
|
||||
if($_POST['booking_date'] != $_POST['end_booking_date'] && $booking_date <= $end_booking_date){
|
||||
for($index = 0; $index <= $diff->days; $index++){
|
||||
$selectedDate = date('Y-m-d', strtotime($_POST['booking_date']. ' + '.$index.' days'));
|
||||
|
||||
|
||||
$bookingArray = array(
|
||||
'guest_name' => $_POST['guest_name'],
|
||||
'guest_email' => $_POST['guest_email'],
|
||||
'guest_phone' => $_POST['guest_phone'],
|
||||
'worker_id' => $_POST['worker_id'],
|
||||
'booking_date' => $selectedDate,
|
||||
'booking_start_time' => $_POST['booking_start_time'],
|
||||
'booking_finish_time' => $_POST['booking_finish_time'],
|
||||
'service_ids' => serialize($selectedServiceArray),
|
||||
'guest_confirmed' => '0',
|
||||
'guest_confirm_code' => '1234'
|
||||
);
|
||||
|
||||
$this->Service_model->createBooking($bookingArray);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$bookingArray = array(
|
||||
'guest_name' => $_POST['guest_name'],
|
||||
'guest_email' => $_POST['guest_email'],
|
||||
'guest_phone' => $_POST['guest_phone'],
|
||||
'group_id' => $_POST['group_id'],
|
||||
'booking_date' => $_POST['booking_date'],
|
||||
'booking_start_time' => $_POST['booking_start_time'],
|
||||
'booking_finish_time' => $_POST['booking_finish_time'],
|
||||
'service_ids' => serialize($selectedServiceArray),
|
||||
'guest_confirmed' => '0',
|
||||
'guest_confirm_code' => '1234'
|
||||
);
|
||||
|
||||
$this->Service_model->updateBooking($_POST['booking_id'], $bookingArray);
|
||||
$this->Log_model->addLog('bookings', $data['currentUser']->username.' módosította a foglalását a(z) '.$bookingArray['guest_name'].' nevű vendégnek ('.implode(', ', $bookingArray).')', $data['currentUser']->username);
|
||||
}
|
||||
|
||||
if($_POST['send_notification']){
|
||||
$workgroup = $this->Service_model->getWorkerById($bookingArray['group_id']);
|
||||
|
||||
$services = unserialize($bookingArray['service_ids']);
|
||||
$serviceArray = array();
|
||||
$emailArray = array();
|
||||
|
||||
if(is_array($services)){
|
||||
foreach($services as $serviceItem){
|
||||
$selectedService = $this->Service_model->getServiceById($serviceItem);
|
||||
if(is_object($selectedService)){
|
||||
$serviceArray[] = $selectedService;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$content = '';
|
||||
|
||||
$email_subject ='[studiobeve] Din reservasjon er endret';
|
||||
$content = 'Kjære gjest,<br />';
|
||||
$content .= 'Vi vil gjerne informere deg om at din reservasjon er endret.<br />';
|
||||
$content .= '<br />';
|
||||
$content .= '<table>';
|
||||
$content .= '<tr><td>Navn: </td><td>'.$bookingArray['guest_name'].'</td></tr>';
|
||||
$content .= '<tr><td>E-post: </td><td>'.$bookingArray['guest_email'].'</td></tr>';
|
||||
$content .= '<tr><td>Telefon: </td><td>'.$bookingArray['guest_phone'].'</td></tr>';
|
||||
$content .= '<tr><td>Arbeider: </td><td>'.$worker->worker_name.'</td></tr>';
|
||||
$content .= '<tr><td>Dato: </td><td>'.$bookingArray['booking_date'].'</td></tr>';
|
||||
$content .= '<tr><td>Tid: </td><td>'.$bookingArray['booking_start_time'].' - '.$bookingArray['booking_finish_time'].'</td></tr>';
|
||||
$content .= '<tr><td>Tjenester: </td><td><table>';
|
||||
$totalServicePrice = 0;
|
||||
foreach($serviceArray as $serviceArrayItem){
|
||||
$totalServicePrice += $serviceArrayItem->service_price;
|
||||
$content .= '<tr><td>'.$serviceArrayItem->service_name_no.'</td><td>'.$serviceArrayItem->service_price.' kr</td></tr>';
|
||||
}
|
||||
$content .= '</table></td>';
|
||||
$content .= '<tr><td>Totalpris: </td><td><strong>'.$totalServicePrice.' kr</strong></td></tr>';
|
||||
$content .= '</table>';
|
||||
$content .= '<br /> STUDIOBEVE';
|
||||
$this->Log_model->addLog('bookings', $data['currentUser']->username.' foglalás módosításról norvég nyelvű értesítést küldött a(z) '.$bookingArray['guest_email'].' email címre ('.implode(', ', $bookingArray).')', $data['currentUser']->username);
|
||||
|
||||
|
||||
$emailItem = array(
|
||||
'addressee_email' => $bookingArray['guest_email'],
|
||||
'addressee_name' => $bookingArray['guest_name'],
|
||||
'subject' => $email_subject,
|
||||
'content' => $content,
|
||||
'attachments' => array()
|
||||
);
|
||||
$emailArray[] = $emailItem;
|
||||
|
||||
$this->User_model->sendEmail($emailArray);
|
||||
}
|
||||
header('Location:'.SITEURL.'bookings');
|
||||
}
|
||||
|
||||
$this->load->view('admin/booking-process', $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Login extends CI_Controller {
|
||||
|
||||
/**
|
||||
* Index Page for this controller.
|
||||
*
|
||||
* Maps to the following URL
|
||||
* http://example.com/index.php/welcome
|
||||
* - or -
|
||||
* http://example.com/index.php/welcome/index
|
||||
* - or -
|
||||
* Since this controller is set as the default controller in
|
||||
* config/routes.php, it's displayed at http://example.com/
|
||||
*
|
||||
* So any other public methods not prefixed with an underscore will
|
||||
* map to /index.php/welcome/<method_name>
|
||||
* @see https://codeigniter.com/user_guide/general/urls.html
|
||||
*/
|
||||
public function index(){
|
||||
$this->load->helper('url');
|
||||
$this->load->helper('cookie');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Log_model');
|
||||
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
|
||||
$data['username'] = '';
|
||||
$data['password'] = '';
|
||||
|
||||
if(isset($_GET['logout']) && isset($_SESSION['username'])){
|
||||
$this->Log_model->addLog('logout', 'Sikeres kijelentkezés - '.$_SESSION['username'],$_SESSION['username']);
|
||||
unset($_SESSION['username']);
|
||||
unset($_SESSION['password']);
|
||||
$data['message'] = 'Sikeres kijelentkezés!';
|
||||
$data['message_class'] = 'success';
|
||||
}
|
||||
|
||||
elseif(isset($_POST['sendLogin'])){
|
||||
if($this->User_model->userCanLogin($_POST['username'], $_POST['password'])){
|
||||
if($_POST['remember'] == 'on'){
|
||||
$cookie = array(
|
||||
'name' => 'username',
|
||||
'value' => $_POST['username'],
|
||||
'expire' => '300',
|
||||
'secure' => TRUE
|
||||
);
|
||||
$this->input->set_cookie($cookie);
|
||||
|
||||
$cookie = array(
|
||||
'name' => 'password',
|
||||
'value' => $_POST['password'],
|
||||
'expire' => '300',
|
||||
'secure' => TRUE
|
||||
);
|
||||
$this->input->set_cookie($cookie);
|
||||
|
||||
}
|
||||
else{
|
||||
delete_cookie("username");
|
||||
delete_cookie("password");
|
||||
}
|
||||
|
||||
$this->Log_model->addLog('login', 'Sikeres bejelentkezés - '.$_POST['username'],$_POST['username']);
|
||||
$_SESSION['username'] = $_POST['username'];
|
||||
$_SESSION['password'] = $_POST['password'];
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
|
||||
header('location:'.base_url().'dashboard');
|
||||
|
||||
}
|
||||
else{
|
||||
$this->Log_model->addLog('login', 'Sikertelen bejelentkezési kísérlet - '.$_POST['username'].' / '.$_POST['password'],$_POST['username']);
|
||||
$data['message'] = 'Sikertelen bejelentkezés!';
|
||||
$data['message_class'] = 'error';
|
||||
}
|
||||
}
|
||||
|
||||
$data['username'] = get_cookie('username');
|
||||
$data['password'] = get_cookie('password');
|
||||
|
||||
$data['pageTitle'] = 'Bejelentkezés';
|
||||
$this->load->view('login',$data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class ModuleManagement extends CI_Controller {
|
||||
|
||||
/**
|
||||
* Index Page for this controller.
|
||||
*
|
||||
* Maps to the following URL
|
||||
* http://example.com/index.php/welcome
|
||||
* - or -
|
||||
* http://example.com/index.php/welcome/index
|
||||
* - or -
|
||||
* Since this controller is set as the default controller in
|
||||
* config/routes.php, it's displayed at http://example.com/
|
||||
*
|
||||
* So any other public methods not prefixed with an underscore will
|
||||
* map to /index.php/welcome/<method_name>
|
||||
* @see https://codeigniter.com/user_guide/general/urls.html
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Log_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
|
||||
//check module is available for user
|
||||
$currentModule = $this->Module_model->getModuleBySlug('module-management');
|
||||
|
||||
if($this->User_model->is_user_admin($_SESSION['username']) || $this->Module_model->is_module_available($currentModule->module_id, $data['currentUser']->user_id)){
|
||||
$data['users'] = $this->User_model->getAllUser();
|
||||
$data['modules'] = $this->Module_model->getAllModule();
|
||||
$data['privileges'] = $this->User_model->getAllUserGroup();
|
||||
|
||||
if(isset($_POST['updatePermission'])){
|
||||
|
||||
//set user privileges
|
||||
foreach($data['modules'] as $moduleItem){
|
||||
$moduleUserArray = array();
|
||||
foreach($data['users'] as $userItem){
|
||||
if($_POST['module_'.$moduleItem->module_id.'_user_'.$userItem->user_id]){
|
||||
$moduleUserArray[] = $userItem->user_id;
|
||||
}
|
||||
}
|
||||
|
||||
if(is_array($moduleUserArray)){
|
||||
$this->Module_model->updateModule('permission_ids', $moduleItem->module_id, $moduleUserArray);
|
||||
$usernames = array();
|
||||
foreach($moduleUserArray as $moduleUserItem){
|
||||
$usernames[] = $this->User_model->getUserById($moduleUserItem)->username;
|
||||
}
|
||||
|
||||
if(!empty($usernames)){
|
||||
$this->Log_model->addLog('change_module_privileges', 'Módosult a '.$moduleItem->module_name.' felhasználó szintű jogosultság kiosztás('.implode(', ', $usernames).') felhasználókra', $_SESSION['username']);
|
||||
}
|
||||
else{
|
||||
$this->Log_model->addLog('change_module_privileges', 'Módosult a '.$moduleItem->module_name.' felhasználó szintű jogosultság kiosztása, jelenleg nincs megosztva', $_SESSION['username']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//set group privilegies
|
||||
foreach($data['modules'] as $moduleItem){
|
||||
$moduleGroupArray = array();
|
||||
foreach($data['privileges'] as $groupItem){
|
||||
|
||||
if($_POST['module_'.$moduleItem->module_id.'_group_'.$groupItem->permission_id]){
|
||||
$moduleGroupArray[] = $groupItem->permission_id;
|
||||
}
|
||||
}
|
||||
|
||||
if(is_array($moduleGroupArray)){
|
||||
$this->Module_model->updateModule('permission_group_ids',$moduleItem->module_id, $moduleGroupArray);
|
||||
$groupNames = array();
|
||||
foreach($moduleGroupArray as $moduleGroupItem){
|
||||
$groupNames[] = $this->User_model->getpermissionById($moduleGroupItem)->permission_name;
|
||||
}
|
||||
if(!empty($groupNames)){
|
||||
$this->Log_model->addLog('change_module_privileges', 'Módosult a '.$moduleItem->module_name.' csoport szintű jogosultság kiosztás ('.(implode(', ',$groupNames)).') csoportokra', $_SESSION['username']);
|
||||
}
|
||||
else{
|
||||
$this->Log_model->addLog('change_module_privileges', 'Módosult a '.$moduleItem->module_name.' csoport szintű jogosultság kiosztása, jelenleg nincs megosztva', $_SESSION['username']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//usersPrivilegesView
|
||||
$userIndex = 1;
|
||||
if(is_array($data['users'])){
|
||||
$data['usersPrivilegesView'] = '';
|
||||
foreach($data['users'] as $userItem){
|
||||
|
||||
$data['usersPrivilegesView'] .= '<tr>';
|
||||
$data['usersPrivilegesView'] .= '<td>'.$userIndex.'.</td>';
|
||||
$data['usersPrivilegesView'] .= '<td style="text-align:left;max-width:auto;">'.$userItem->fullname.'</td>';
|
||||
$data['usersPrivilegesView'] .= '<td style="text-align:left;max-width:auto;">'.$userItem->username.'</td>';
|
||||
|
||||
if(is_array($data['modules'])){
|
||||
foreach($data['modules'] as $moduleItem){
|
||||
if($userItem->permission_slug == 'admin'){
|
||||
$data['usersPrivilegesView'] .= '<td><input type="hidden" name="module_'.$moduleItem->module_id.'_user_'.$userItem->user_id.'" value="0"><input type="checkbox" name="module_'.$moduleItem->module_id.'_user_'.$userItem->user_id.'" value="1" checked disabled/></td>';
|
||||
|
||||
}
|
||||
else{
|
||||
$data['usersPrivilegesView'] .= '<td><input type="hidden" name="module_'.$moduleItem->module_id.'_user_'.$userItem->user_id.'" value="0"><input type="checkbox" name="module_'.$moduleItem->module_id.'_user_'.$userItem->user_id.'" value="1" ';
|
||||
$data['usersPrivilegesView'] .= $this->Module_model->is_userId_available_in_module($moduleItem->module_id, $userItem->user_id)?'checked':'';
|
||||
$data['usersPrivilegesView'] .= '/></td>';
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$userIndex++;
|
||||
$data['usersPrivilegesView'] .= '</tr>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//groupModuleView
|
||||
$groupIndex = 1;
|
||||
foreach($data['privileges'] as $privilegeItem){
|
||||
if($privilegeItem->permission_slug == 'admin'){
|
||||
$data['groupModuleView'] = '<tr>';
|
||||
$data['groupModuleView'] .= '<td>'.$groupIndex.'.</td>';
|
||||
$data['groupModuleView'] .= '<td style="text-align:left;max-width:auto;">'.$privilegeItem->permission_name.'</td>';
|
||||
|
||||
if(is_array($data['modules'])){
|
||||
foreach($data['modules'] as $moduleItem){
|
||||
$data['groupModuleView'] .= '<td><input type="hidden" name="module_'.$moduleItem->module_id.'_group_'.$privilegeItem->permission_id.'" value="0"><input type="checkbox" name="module_'.$moduleItem->module_id.'_group_'.$privilegeItem->permission_id.'" value="1" checked disabled/></td>';
|
||||
}
|
||||
}
|
||||
$groupIndex++;
|
||||
$data['groupModuleView'] .= '</tr>';
|
||||
}
|
||||
else{
|
||||
$data['groupModuleView'] .= '<tr>';
|
||||
$data['groupModuleView'] .= '<td>'.$groupIndex.'.</td>';
|
||||
$data['groupModuleView'] .= '<td style="text-align:left;max-width:auto;">'.$privilegeItem->permission_name.'</td>';
|
||||
if(is_array($data['modules'])){
|
||||
foreach($data['modules'] as $moduleItem){
|
||||
$data['groupModuleView'] .= '<td><input type="hidden" name="module_'.$moduleItem->module_id.'_group_'.$privilegeItem->permission_id.'" value="0"><input type="checkbox" name="module_'.$moduleItem->module_id.'_group_'.$privilegeItem->permission_id.'" value="1" ';
|
||||
$data['groupModuleView'] .= $this->Module_model->is_groupId_available_in_module($moduleItem->module_id,$privilegeItem->permission_id)?' checked':'';
|
||||
$data['groupModuleView'] .= '/></td>';
|
||||
}
|
||||
}
|
||||
$groupIndex++;
|
||||
$data['groupModuleView'] .= '</tr>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//get available modules for menu
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
$this->load->view('modules/module-management/module-management', $data);
|
||||
}
|
||||
else{
|
||||
header('Location:'.site_url().'404-page-not-found');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,792 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Pages extends CI_Controller {
|
||||
|
||||
/**
|
||||
* Index Page for this controller.
|
||||
*
|
||||
* Maps to the following URL
|
||||
* http://example.com/index.php/welcome
|
||||
* - or -
|
||||
* http://example.com/index.php/welcome/index
|
||||
* - or -
|
||||
* Since this controller is set as the default controller in
|
||||
* config/routes.php, it's displayed at http://example.com/
|
||||
*
|
||||
* So any other public methods not prefixed with an underscore will
|
||||
* map to /index.php/welcome/<method_name>
|
||||
* @see https://codeigniter.com/userguide3/general/urls.html
|
||||
*/
|
||||
public function index(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
|
||||
$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
|
||||
$data['pageTitle'] = '';
|
||||
$this->load->view('pages/home', $data);
|
||||
}
|
||||
|
||||
public function booking(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
|
||||
$data['pageTitle'] = '';
|
||||
|
||||
|
||||
//$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
$cleaningService = array('1');
|
||||
$data['cleaningServices'] = $this->Service_model->getAllServiceByGroups($cleaningService);
|
||||
/*echo '<pre>';
|
||||
print_r($data['cleaningServices']);
|
||||
echo '</pre>';*/
|
||||
$carService = array('2,3,4,5, 6,11');
|
||||
$data['carServices'] = $this->Service_model->getAllServiceByGroups($carService);
|
||||
|
||||
$helphandService = array('7');
|
||||
$data['helphandServices'] = $this->Service_model->getAllServiceByGroups($helphandService);
|
||||
|
||||
$gardenService = array('8');
|
||||
$data['gardenServices'] = $this->Service_model->getAllServiceByGroups($gardenService);
|
||||
|
||||
$houseService = array('9');
|
||||
$data['houseServices'] = $this->Service_model->getAllServiceByGroups($houseService);
|
||||
|
||||
$buildService = array('10');
|
||||
$data['buildServices'] = $this->Service_model->getAllServiceByGroups($buildService);
|
||||
|
||||
$data['serviceGroups'] = $this->Service_model->getServiceGroups();
|
||||
$data['workgroups'] = $this->Group_model->getAllActiveGroups();
|
||||
$data['activeWorkgroup'] = $this->Group_model->getAvailableGroup('2024-08-25', '1');
|
||||
|
||||
$this->load->view('pages/booking', $data);
|
||||
}
|
||||
|
||||
public function booking_finished(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$data['pageTitle'] = '';
|
||||
|
||||
$this->load->view('pages/booking-finished', $data);
|
||||
}
|
||||
|
||||
public function quotation_finished(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$data['pageTitle'] = '';
|
||||
|
||||
$this->load->view('pages/quotation-finished', $data);
|
||||
}
|
||||
|
||||
public function water_channel(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$data['pageTitle'] = '';
|
||||
$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
$this->load->view('pages/water-channel', $data);
|
||||
}
|
||||
|
||||
public function painting(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$data['pageTitle'] = '';
|
||||
$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
$this->load->view('pages/painting', $data);
|
||||
}
|
||||
|
||||
public function carefree_vacation(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$data['pageTitle'] = '';
|
||||
$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
$this->load->view('pages/carefree-vacation', $data);
|
||||
}
|
||||
|
||||
public function polishing(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$data['pageTitle'] = '';
|
||||
$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
$this->load->view('pages/polishing', $data);
|
||||
}
|
||||
|
||||
public function ledigestilling(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$data['pageTitle'] = '';
|
||||
$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
|
||||
$this->load->view('pages/ledigestilling', $data);
|
||||
}
|
||||
|
||||
public function email_verification(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Log_model');
|
||||
|
||||
$data['pageTitle'] = '';
|
||||
$this->load->view('pages/email-verification', $data);
|
||||
}
|
||||
|
||||
public function ajax(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Group_model');
|
||||
$this->load->model('Log_model');
|
||||
|
||||
$data['pageTitle'] = '';
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'calculate_service_length' && isset($_POST['service_ids'])){
|
||||
if($_POST['service_ids'] != ''){
|
||||
$explodedServiceIds = explode(',', $_POST['service_ids']);
|
||||
$totalLength = '00:00:00';
|
||||
if(!empty($explodedServiceIds)){
|
||||
foreach($explodedServiceIds as $explodedServiceIdItem){
|
||||
$currentService = $this->Service_model->getServiceById($explodedServiceIdItem);
|
||||
$time = $totalLength;
|
||||
$time2 = $currentService->service_time;
|
||||
|
||||
$secs = strtotime($time2)-strtotime("00:00:00");
|
||||
$addedTotal = date("H:i:s",strtotime($time)+$secs);
|
||||
$totalLength = $addedTotal;
|
||||
}
|
||||
|
||||
}
|
||||
echo $totalLength;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'getAvailableTimeOptions' && isset($_POST['selectedDate'])){
|
||||
$results = $this->Service_model->getAvailableTimes($_POST['group_id'], $_POST['selectedDate'], $_POST['servicelength']);
|
||||
|
||||
$rowIndex = 1;
|
||||
if(is_array($results)){
|
||||
foreach($results as $resultIem){
|
||||
?>
|
||||
<option value="<?php echo $resultIem;?>"><?php echo date('H:i', strtotime($resultIem));?></option>
|
||||
<?php
|
||||
$rowIndex++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
echo 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'getAvailableGroup' && isset($_POST['service_category'])){
|
||||
|
||||
if($_POST['service_category'] != 0){
|
||||
$selectedGroup = $this->Group_model->getAvailableGroup($_POST['booking_date'], $_POST['service_category']);
|
||||
echo $selectedGroup->group_id;
|
||||
}
|
||||
else{
|
||||
echo 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'isTimeAvailable' && isset($_POST['selectedDate'])){
|
||||
$results = $this->Service_model->getAvailableTimes($_POST['group_id'], $_POST['selectedDate'], $_POST['servicelength']);
|
||||
|
||||
$timeIsAvailable = 0;
|
||||
if(is_array($results)){
|
||||
foreach($results as $resultIem){
|
||||
if(date('H:i:s', strtotime($resultIem)) == $_POST['selectedTime']){
|
||||
$timeIsAvailable = 1;
|
||||
}
|
||||
}
|
||||
|
||||
echo $timeIsAvailable;
|
||||
}
|
||||
else{
|
||||
echo 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'getAvailableTimes' && isset($_POST['selectedDate'])){
|
||||
$results = $this->Service_model->getAvailableTimes($_POST['group_id'], $_POST['selectedDate'], $_POST['servicelength'].':00');
|
||||
|
||||
$rowIndex = 1;
|
||||
if(!empty($results)){
|
||||
foreach($results as $resultIem){
|
||||
?>
|
||||
<div class="availableBookingTime" id="bookingTime_<?php echo $rowIndex;?>" onclick="setSelectedTime('<?php echo $resultIem;?>', '<?php echo $rowIndex;?>')"><span><?php echo date('H:i', strtotime($resultIem));?></span></div>
|
||||
<?php
|
||||
$rowIndex++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
echo 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'getSelectedGroup'){
|
||||
$result = $this->Group_model->getGroupById($_POST['group_id']);
|
||||
|
||||
if(is_object($result)){
|
||||
?>
|
||||
<div class="serviceBookingprofileImage" style="background-image:url('<?php echo SITEURL.'assets/img/'.$result->group_profile_img;?>');"></div>
|
||||
<div class="serviceBookingprofileName"><?php echo $result->group_name;?></div>
|
||||
<?php
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
echo 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'changeUserStatus' && isset($_POST['user_id']) && isset($_POST['newValue']) && isset($_POST['operator'])){
|
||||
$data['currentUser'] = $this->User_model->getUserById($_POST['user_id']);
|
||||
$userArray = array(
|
||||
'is_enabled' => $_POST['newValue']
|
||||
);
|
||||
$this->User_model->updateUser($_POST['user_id'], $userArray);
|
||||
$this->Log_model->addLog('change_user_status', $data['currentUser']->username.' státusza változott - '.($_POST['newValue']?'aktív':'letiltva').' állapotra', $_POST['operator']);
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'checkUser'){
|
||||
echo $this->User_model->isUsernameAvailable($_POST['username']);
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'refreshLogMonitor'){
|
||||
$logInfoArray = $this->Log_model->getAllLoginfo();
|
||||
$logrow = '';
|
||||
foreach($logInfoArray as $logInfoItem){
|
||||
$logDateTime = new datetime($logInfoItem->event_datetime);
|
||||
$logrow .= date_format($logDateTime,"Y-m-d H:i").' '.$logInfoItem->username.' '.$logInfoItem->event_content.' ';
|
||||
}
|
||||
echo $logrow;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->load->view('pages/ajax', $data);
|
||||
}
|
||||
|
||||
|
||||
public function booking_process(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
|
||||
$data['pageTitle'] = '';
|
||||
$data['subpage'] = '';
|
||||
|
||||
if(isset($_POST['sendFormCarefreeVacation'])){
|
||||
$bookingArray = array(
|
||||
'name' => $_POST['name'],
|
||||
'address' => $_POST['address'],
|
||||
'email' => $_POST['email'],
|
||||
'phonenumber' => $_POST['phonenumber'],
|
||||
'type_of_building' => $_POST['type_of_building'],
|
||||
'blomstervanning_enebolig' => $_POST['blomstervanning_Enebolig'],
|
||||
'postinntak_enebolig' => $_POST['Postinntak_Enebolig'],
|
||||
'number_of_worker' => $_POST['number_of_worker'],
|
||||
'user_notes' => $_POST['user_notes']
|
||||
);
|
||||
|
||||
$content = '';
|
||||
|
||||
$content = 'Kjære Partner,<br /><br />';
|
||||
$content .= 'Vi har mottatt din forespørsel om tilbud. Her er opplysningene du oppga.<br />';
|
||||
$content .= '<br />';
|
||||
$content .= '<table>';
|
||||
$content .= '<tr><td>Service: </td><td>Sorgløs ferie</td></tr>';
|
||||
$content .= '<tr><td>Navn: </td><td>'.$bookingArray['name'].'</td></tr>';
|
||||
$content .= '<tr><td>E-post: </td><td>'.$bookingArray['email'].'</td></tr>';
|
||||
$content .= '<tr><td>Telefon: </td><td>'.$bookingArray['phonenumber'].'</td></tr>';
|
||||
$content .= '<tr><td>Adresse: </td><td>'.$bookingArray['address'].'</td></tr>';
|
||||
|
||||
$content .= '<tr><td>Bygningstype: </td><td>'.$bookingArray['type_of_building'].'</td></tr>';
|
||||
$content .= '<tr><td>Enebolig: </td><td>'.($bookingArray['blomstervanning_enebolig']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Postinntak: </td><td>'.($bookingArray['postinntak_enebolig']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Hvor mange ganger skal vi totalt komme: </td><td>'.$bookingArray['number_of_worker'].'</td></tr>';
|
||||
$content .= '<tr><td>Utfyllende kommentarer: </td><td>'.$bookingArray['user_notes'].'</td></tr>';
|
||||
$content .= '</table>';
|
||||
$content .= '<br /> DIN BESTE HJELPER<br />';
|
||||
|
||||
$content .= '<br /> Dersom du ønsker å avbestille, kan du gjøre det i en melding på Instagram, Facebook eller til følgende e-post timebestilling@dinbestehjelper.no';
|
||||
|
||||
$emailItem = array(
|
||||
'addressee_email' => $bookingArray['email'],
|
||||
'addressee_name' => $bookingArray['name'],
|
||||
'subject' => '[dinbestehjelper] Din timebestilling har kommet',
|
||||
'content' => $content,
|
||||
'attachments' => array()
|
||||
);
|
||||
$emailArray[] = $emailItem;
|
||||
$this->User_model->sendEmail($emailArray);
|
||||
header('Location:'.SITEURL.'quotation-finished/');
|
||||
}
|
||||
|
||||
|
||||
if(isset($_POST['sendFormPainting'])){
|
||||
$bookingArray = array(
|
||||
'name' => $_POST['name'],
|
||||
'address' => $_POST['address'],
|
||||
'email' => $_POST['email'],
|
||||
'phonenumber' => $_POST['phonenumber'],
|
||||
'type_of_building' => $_POST['type_of_building'],
|
||||
'year_of_construction' => $_POST['year_of_construction'],
|
||||
'home_inhabited' => $_POST['home_inhabited'],
|
||||
'painting_on_plastered_surfaces' => $_POST['painting_on_plastered_surfaces'],
|
||||
'wall_paint_on_a_plasterboard_surface' => $_POST['wall_paint_on_a_plasterboard_surface'],
|
||||
'floor_area' => $_POST['floor_area'],
|
||||
'ceiling_height' => $_POST['ceiling_height'],
|
||||
'user_notes' => $_POST['user_notes']
|
||||
);
|
||||
|
||||
$content = '';
|
||||
|
||||
$content = 'Kjære Partner,<br /><br />';
|
||||
$content .= 'Vi har mottatt din forespørsel om tilbud. Her er opplysningene du oppga.<br />';
|
||||
$content .= '<br />';
|
||||
$content .= '<table>';
|
||||
$content .= '<tr><td>Service: </td><td>Malerarbeid</td></tr>';
|
||||
$content .= '<tr><td>Navn: </td><td>'.$bookingArray['name'].'</td></tr>';
|
||||
$content .= '<tr><td>E-post: </td><td>'.$bookingArray['email'].'</td></tr>';
|
||||
$content .= '<tr><td>Telefon: </td><td>'.$bookingArray['phonenumber'].'</td></tr>';
|
||||
$content .= '<tr><td>Adresse: </td><td>'.$bookingArray['address'].'</td></tr>';
|
||||
|
||||
$content .= '<tr><td>Bygningstype: </td><td>'.$bookingArray['type_of_building'].'</td></tr>';
|
||||
$content .= '<tr><td>Byggeår: </td><td>'.($bookingArray['year_of_construction']).'</td></tr>';
|
||||
$content .= '<tr><td>Er boligen bebodd under byggearbeidene? </td><td>'.($bookingArray['home_inhabited']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Maling på pussede overflater? </td><td>'.($bookingArray['painting_on_plastered_surfaces']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Veggmaling på gipsplateoverflate? </td><td>'.($bookingArray['wall_paint_on_a_plasterboard_surface']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Gulvareal i rommet som skal males: </td><td>'.$bookingArray['floor_area'].' m2</td></tr>';
|
||||
$content .= '<tr><td>Takhøyde: </td><td>'.$bookingArray['ceiling_height'].' m</td></tr>';
|
||||
$content .= '<tr><td>Utfyllende kommentarer: </td><td>'.$bookingArray['user_notes'].'</td></tr>';
|
||||
$content .= '</table>';
|
||||
$content .= '<br /> DIN BESTE HJELPER<br />';
|
||||
|
||||
$content .= '<br /> Dersom du ønsker å avbestille, kan du gjøre det i en melding på Instagram, Facebook eller til følgende e-post timebestilling@dinbestehjelper.no';
|
||||
|
||||
$emailItem = array(
|
||||
'addressee_email' => $bookingArray['email'],
|
||||
'addressee_name' => $bookingArray['name'],
|
||||
'subject' => '[dinbestehjelper] Din timebestilling har kommet',
|
||||
'content' => $content,
|
||||
'attachments' => array()
|
||||
);
|
||||
$emailArray[] = $emailItem;
|
||||
$this->User_model->sendEmail($emailArray);
|
||||
header('Location:'.SITEURL.'quotation-finished/');
|
||||
}
|
||||
|
||||
|
||||
if(isset($_POST['sendFormPolishing'])){
|
||||
$serviceArray = $this->Service_model->getAllServiceByServiceType();
|
||||
$bookingArray = array(
|
||||
'name' => $_POST['name'],
|
||||
'address' => $_POST['address'],
|
||||
'email' => $_POST['email'],
|
||||
'phonenumber' => $_POST['phonenumber'],
|
||||
'merke' => $_POST['merke'],
|
||||
'type_of_car' => $_POST['type_of_car'],
|
||||
'farge' => $_POST['farge'],
|
||||
'arsmodell' => $_POST['Arsmodell'],
|
||||
'user_notes' => $_POST['user_notes']
|
||||
);
|
||||
|
||||
$content = '';
|
||||
|
||||
$content = 'Kjære Partner,<br /><br />';
|
||||
$content .= 'Vi har mottatt din forespørsel om tilbud. Her er opplysningene du oppga.<br />';
|
||||
$content .= '<br />';
|
||||
$content .= '1. Vi behandler opplysningene du oppga så raskt som mulig.<br />';
|
||||
$content .= '2. Vi kontakter deg per e-post eller sms, for å avtale tidspunkt.<br />';
|
||||
$content .= '3. Vi kommer til avtalt tid for å besiktige stedet/oppgaven.<br />';
|
||||
$content .= '4. Deretter gir vi et tilbud per e-post.<br />';
|
||||
$content .= '5. Hvis du godtar det, begynner arbeidet så raskt som mulig.<br />';
|
||||
|
||||
$content .= '<br />Opplysninger:<br />';
|
||||
$content .= '<table>';
|
||||
$content .= '<tr><td>Service: </td><td>Full polering</td></tr>';
|
||||
$content .= '<tr><td>Navn: </td><td>'.$bookingArray['name'].'</td></tr>';
|
||||
$content .= '<tr><td>E-post: </td><td>'.$bookingArray['email'].'</td></tr>';
|
||||
$content .= '<tr><td>Telefon: </td><td>'.$bookingArray['phonenumber'].'</td></tr>';
|
||||
$content .= '<tr><td>Adresse: </td><td>'.$bookingArray['address'].'</td></tr>';
|
||||
|
||||
$content .= '<tr><td>Merke: </td><td>'.$bookingArray['merke'].'</td></tr>';
|
||||
$content .= '<tr><td>Type of car: </td><td>'.($bookingArray['type_of_car']).'</td></tr>';
|
||||
$content .= '<tr><td>Farge: </td><td>'.($bookingArray['farge']).'</td></tr>';
|
||||
$content .= '<tr><td>Arsmodell: </td><td>'.($bookingArray['arsmodell']).'</td></tr>';
|
||||
$content .= '<tr><td>Utfyllende kommentarer: </td><td>'.$bookingArray['user_notes'].'</td></tr>';
|
||||
|
||||
$content .= '</table>';
|
||||
$content .= '<br /> DIN BESTE HJELPER<br />';
|
||||
|
||||
$content .= '<br /> Dersom du ønsker å avbestille, kan du gjøre det i en melding på Instagram, Facebook eller til følgende e-post timebestilling@dinbestehjelper.no';
|
||||
|
||||
$emailItem = array(
|
||||
'addressee_email' => $bookingArray['email'],
|
||||
'addressee_name' => $bookingArray['name'],
|
||||
'subject' => '[dinbestehjelper] Din timebestilling har kommet',
|
||||
'content' => $content,
|
||||
'attachments' => array()
|
||||
);
|
||||
$emailArray[] = $emailItem;
|
||||
$this->User_model->sendEmail($emailArray);
|
||||
header('Location:'.SITEURL.'quotation-finished/');
|
||||
}
|
||||
|
||||
|
||||
if(isset($_POST['sendFormWaterChannel'])){
|
||||
$formArray = array(
|
||||
'name' => $_POST['name'],
|
||||
'address' => $_POST['address'],
|
||||
'email' => $_POST['email'],
|
||||
'phonenumber' => $_POST['phonenumber'],
|
||||
'type_of_building' => $_POST['type_of_building'],
|
||||
'year_of_construction' => $_POST['year_of_construction'],
|
||||
'home_inhabited' => $_POST['home_inhabited'],
|
||||
'demolition_of_old_system' => $_POST['demolition_of_old_system'],
|
||||
'installation_of_new_system' => $_POST['installation_of_new_system'],
|
||||
'installation_of_water_in_kitchen' => $_POST['installation_of_water_in_kitchen'],
|
||||
'installation_of_water_in_the_bathroom' => $_POST['installation_of_water_in_the_bathroom'],
|
||||
'connection_of_washbasin' => $_POST['connection_of_washbasin'],
|
||||
'replacement_of_toilet' => $_POST['replacement_of_toilet'],
|
||||
'installation_of_connection_for_household' => $_POST['installation_of_connection_for_household'],
|
||||
'connecting_a_dishwasher' => $_POST['connecting_a_dishwasher'],
|
||||
'connection_of_washing_machine' => $_POST['connection_of_washing_machine'],
|
||||
'connection_of_dryer' => $_POST['connection_of_dryer'],
|
||||
'installation_of_a_garden_tap' => $_POST['installation_of_a_garden_tap'],
|
||||
'installation_of_water_purification' => $_POST['installation_of_water_purification'],
|
||||
'user_notes' => $_POST['user_notes']
|
||||
);
|
||||
|
||||
$content = '';
|
||||
|
||||
$content = 'Kjære Partner,<br /><br />';
|
||||
$content .= 'Vi har mottatt din forespørsel om tilbud. Her er opplysningene du oppga.<br />';
|
||||
$content .= '<br />';
|
||||
$content .= '<table>';
|
||||
$content .= '<tr><td>Service: </td><td>Rørleggerarbeid</td></tr>';
|
||||
$content .= '<tr><td>Navn: </td><td>'.$bookingArray['name'].'</td></tr>';
|
||||
$content .= '<tr><td>E-post: </td><td>'.$bookingArray['email'].'</td></tr>';
|
||||
$content .= '<tr><td>Telefon: </td><td>'.$bookingArray['phonenumber'].'</td></tr>';
|
||||
$content .= '<tr><td>Adresse: </td><td>'.$bookingArray['address'].'</td></tr>';
|
||||
|
||||
$content .= '<tr><td>Bygningstype: </td><td>'.$bookingArray['type_of_building'].'</td></tr>';
|
||||
$content .= '<tr><td>Byggeår: </td><td>'.($bookingArray['year_of_construction']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Er boligen bebodd under byggearbeidene?: </td><td>'.($bookingArray['home_inhabited']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Rivning av gammelt system (komplett til vannmåler): </td><td>'.($bookingArray['demolition_of_old_system']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Installasjon av nytt system (fra måler): </td><td>'.($bookingArray['installation_of_new_system']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Installasjon av vann og avløp i kjøkken: </td><td>'.($bookingArray['installation_of_water_in_kitchen']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Installasjon av vann og avløp på bad: </td><td>'.($bookingArray['installation_of_water_in_the_bathroom']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Tilkobling av servant, badekar, dusj: </td><td>'.($bookingArray['connection_of_washbasin']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Utskifting av toalett, håndvask, nyinstallasjon: </td><td>'.($bookingArray['replacement_of_toilet']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Installasjon av tilkobling for husholdningsapparater: </td><td>'.($bookingArray['installation_of_connection_for_household']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Tilkobling av oppvaskmaskin: </td><td>'.($bookingArray['connecting_a_dishwasher']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Tilkobling av vaskemaskin: </td><td>'.($bookingArray['connection_of_washing_machine']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Tilkobling av tørketrommel: </td><td>'.($bookingArray['connection_of_dryer']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Installasjon av hagekran: </td><td>'.($bookingArray['installation_of_a_garden_tap']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Installasjon av vannrenseutstyr: </td><td>'.($bookingArray['installation_of_water_purification']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Utfyllende kommentarer: </td><td>'.$bookingArray['user_notes'].'</td></tr>';
|
||||
|
||||
$content .= '</table>';
|
||||
$content .= '<br /> DIN BESTE HJELPER<br />';
|
||||
|
||||
$content .= '<br /> Dersom du ønsker å avbestille, kan du gjøre det i en melding på Instagram, Facebook eller til følgende e-post timebestilling@dinbestehjelper.no';
|
||||
|
||||
$emailItem = array(
|
||||
'addressee_email' => $bookingArray['email'],
|
||||
'addressee_name' => $bookingArray['name'],
|
||||
'subject' => '[dinbestehjelper] Din timebestilling har kommet',
|
||||
'content' => $content,
|
||||
'attachments' => array()
|
||||
);
|
||||
$emailArray[] = $emailItem;
|
||||
$this->User_model->sendEmail($emailArray);
|
||||
header('Location:'.SITEURL.'quotation-finished/');
|
||||
}
|
||||
|
||||
|
||||
if(isset($_POST['sendBooking'])){
|
||||
//calculate finish time
|
||||
$serviceStartTime = date("H:i:s", strtotime($_POST['booking_start_time']));
|
||||
$serviceLengthTime = date("H:i:s", strtotime($_POST['servicelength']));
|
||||
$secs = strtotime($serviceLengthTime)-strtotime("00:00:00");
|
||||
$serviceFinishTime = date("H:i:s",strtotime($serviceStartTime)+$secs);
|
||||
|
||||
$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
$data['workgroups'] = $this->Group_model->getAllGroups();
|
||||
$selectedServiceArray = array();
|
||||
|
||||
//find selected services
|
||||
if(is_array($data['services'])){
|
||||
foreach($data['services'] as $serviceItem){
|
||||
if(isset($_POST['service_'.$serviceItem->service_id])){
|
||||
if($_POST['service_'.$serviceItem->service_id]){
|
||||
$selectedServiceArray[] = array(
|
||||
'service_id' => $serviceItem->service_id,
|
||||
'quantity' => $_POST['quantity_'.$serviceItem->service_id]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$bookingArray = array(
|
||||
'guest_name' => $_POST['guest_name'],
|
||||
'guest_email' => $_POST['guest_email'],
|
||||
'guest_phone' => $_POST['guest_phone'],
|
||||
'guest_addresse' => $_POST['guest_addresse'],
|
||||
'guest_car_reg_number' => $_POST['guest_car_reg_number'],
|
||||
'guest_car_type' => $_POST['guest_car_type'],
|
||||
'group_id' => $_POST['group_id'],
|
||||
'booking_date' => $_POST['booking_date'],
|
||||
'booking_start_time' => $_POST['booking_start_time'],
|
||||
'booking_finish_time' => $serviceFinishTime,
|
||||
'service_ids' => serialize($selectedServiceArray),
|
||||
'guest_confirmed' => '0',
|
||||
'total_price' => $_POST['totalPrice'],
|
||||
'guest_confirm_code' => '1234',
|
||||
);
|
||||
|
||||
$this->Service_model->createBooking($bookingArray);
|
||||
$group = $this->Group_model->getGroupById($bookingArray['group_id']);
|
||||
|
||||
$services = unserialize($bookingArray['service_ids']);
|
||||
$serviceArray = array();
|
||||
$emailArray = array();
|
||||
|
||||
if(is_array($services)){
|
||||
foreach($services as $serviceItem){
|
||||
$selectedService = $this->Service_model->getServiceById($serviceItem['service_id']);
|
||||
if(is_object($selectedService)){
|
||||
$tmpService = (array)$selectedService;
|
||||
$tmpService['quantity'] = $serviceItem['quantity'];
|
||||
$serviceArray[] = (object)$tmpService;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$content = '';
|
||||
|
||||
$content = 'Kjære Bestiller,<br /><br />';
|
||||
$content .= 'Takk for din bestilling. Her er opplysningene du oppga.<br />';
|
||||
$content .= '<br />';
|
||||
$content .= '<table>';
|
||||
$content .= '<tr><td>Navn: </td><td>'.$bookingArray['guest_name'].'</td></tr>';
|
||||
$content .= '<tr><td>E-post: </td><td>'.$bookingArray['guest_email'].'</td></tr>';
|
||||
$content .= '<tr><td>Telefon: </td><td>'.$bookingArray['guest_phone'].'</td></tr>';
|
||||
$content .= '<tr><td>Adresse: </td><td>'.$bookingArray['guest_addresse'].'</td></tr>';
|
||||
if($bookingArray['guest_car_reg_number'] != ''){
|
||||
$content .= '<tr><td>Registreringsnummer: </td><td>'.$bookingArray['guest_car_reg_number'].'</td></tr>';
|
||||
}
|
||||
if($bookingArray['guest_car_type'] != ''){
|
||||
$content .= '<tr><td>Bilmerke: </td><td>'.$bookingArray['guest_car_type'].'</td></tr>';
|
||||
}
|
||||
$content .= '<tr><td>Dato: </td><td>'.$bookingArray['booking_date'].'</td></tr>';
|
||||
$content .= '<tr><td>Tid: </td><td>'.$bookingArray['booking_start_time'].' - '.$bookingArray['booking_finish_time'].'</td></tr>';
|
||||
$content .= '<tr><td>Tjenester: </td><td><table>';
|
||||
$totalServicePrice = 0;
|
||||
foreach($serviceArray as $serviceArrayItem){
|
||||
$totalServicePrice += $serviceArrayItem->service_price;
|
||||
$content .= '<tr><td>'.$serviceArrayItem->service_name.'</td><td>('.$serviceArrayItem->quantity.' x '.$serviceArrayItem->service_price.' kr) '.$serviceArrayItem->quantity*$serviceArrayItem->service_price.' kr</td></tr>';
|
||||
}
|
||||
$content .= '</table></td>';
|
||||
$content .= '<tr><td>Totalpris: </td><td><strong>'.$bookingArray['total_price'].' kr</strong></td></tr>';
|
||||
$content .= '</table>';
|
||||
$content .= '<br /> DIN BESTE HJELPER<br />';
|
||||
|
||||
$content .= '<br /> Dersom du ønsker å avbestille, kan du gjøre det i en melding på Instagram, Facebook eller til følgende e-post timebestilling@dinbestehjelper.no';
|
||||
|
||||
$emailItem = array(
|
||||
'addressee_email' => $bookingArray['guest_email'],
|
||||
'addressee_name' => $bookingArray['guest_name'],
|
||||
'subject' => '[dinbestehjelper] Din timebestilling har kommet',
|
||||
'content' => $content,
|
||||
'attachments' => array()
|
||||
);
|
||||
$emailArray[] = $emailItem;
|
||||
$this->User_model->sendEmail($emailArray);
|
||||
header('Location:'.SITEURL.'booking-finished/');
|
||||
}
|
||||
|
||||
$this->load->view('pages/booking-process', $data);
|
||||
}
|
||||
|
||||
public function profile(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Log_model');
|
||||
$this->load->model('Module_model');
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
$data['fullname'] = '';
|
||||
$data['password'] = '';
|
||||
$data['profile_img_url'] = '';
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
$data['pageTitle'] = 'Profil szerkesztése';
|
||||
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
if(isset($_POST["storeProfile"])) {
|
||||
|
||||
if($_POST['fullname'] != $data['currentUser']->fullname){
|
||||
$userArray = array(
|
||||
'fullname' => $_POST['fullname']
|
||||
);
|
||||
$this->User_model->updateUser($data['currentUser']->user_id, $userArray);
|
||||
$this->Log_model->addLog('profile', 'A felhasználó módosította a teljes nevét: '.$data['currentUser']->fullname.' => '.$_POST['fullname'],$_SESSION['username']);
|
||||
}
|
||||
|
||||
if($_POST['password'] != ''){
|
||||
$userArray = array(
|
||||
'password' => hash('sha256', $_POST['password'])
|
||||
);
|
||||
$this->User_model->updateUser($data['currentUser']->user_id, $userArray);
|
||||
$this->Log_model->addLog('profile', 'A felhasználó módosította a jelszavát',$_SESSION['username']);
|
||||
}
|
||||
|
||||
|
||||
//upload profile image
|
||||
if($_FILES["profile_img"]["tmp_name"] != ''){
|
||||
$target_dir = getcwd()."/assets/img/profiles/";
|
||||
$target_file = $target_dir . str_replace('.','_', str_replace('@','_',$_SESSION['username']));
|
||||
$imageFileType = strtolower(pathinfo(basename($_FILES["profile_img"]["name"]),PATHINFO_EXTENSION));
|
||||
|
||||
if (move_uploaded_file($_FILES["profile_img"]["tmp_name"], $target_file.'.'.$imageFileType)) {
|
||||
$data['message'] = 'A profilkép sikeresen feltöltve!';
|
||||
$data['message_class'] = 'successMessage';
|
||||
$data['profile_img_url'] = 'assets/img/profiles/'.str_replace('.','_', str_replace('@','_',$_SESSION['username'])).'.'.$imageFileType;
|
||||
$userArray = array(
|
||||
'profile_img_url' => $data['profile_img_url']
|
||||
);
|
||||
$this->User_model->updateUser($data['currentUser']->user_id, $userArray);
|
||||
$this->Log_model->addLog('profile', 'A felhasználó lecserélte a profilképét ',$_SESSION['username']);
|
||||
} else {
|
||||
$data['message'] = 'Hiba a feltöltés közben!';
|
||||
$data['message_class'] = 'errorMessage';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$data['message'] = 'A profil sikeresen módosítva!';
|
||||
$data['message_class'] = 'successMessage';
|
||||
}
|
||||
|
||||
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$this->load->view('pages/profile', $data);
|
||||
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
}
|
||||
|
||||
public function log_monitor(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Log_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
$data['pageTitle'] = 'Rendszermonitor';
|
||||
$data['logInfoLink'] = '';
|
||||
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
$selectedModule = $this->Module_model->getModuleBySlug('log-monitor');
|
||||
if($this->Module_model->is_module_available($selectedModule->module_id, $data['currentUser']->user_id)){
|
||||
|
||||
if(isset($_POST['exportToFile'])){
|
||||
$logInfoArray = $this->Log_model->getAllLoginfo();
|
||||
$logrow = '';
|
||||
$logTxt = fopen(getcwd()."/documents/loginfo.csv", "w") or die("Hiba a fájl mentésekor!");
|
||||
$row = '"Esemény ideje";'.'"Esemény típusa";'.'"Felhasználónév";"Bejegyzés tartalma";'.PHP_EOL;
|
||||
$string_encoded = iconv( mb_detect_encoding( $row ), 'ISO-8859-2', $row );
|
||||
fwrite($logTxt, $string_encoded);
|
||||
|
||||
foreach($logInfoArray as $logInfoItem){
|
||||
$logDateTime = new datetime($logInfoItem->event_datetime);
|
||||
$row = date_format($logDateTime,"Y-m-d H:i").';"'.$logInfoItem->event_type.'";"'.$logInfoItem->username.'";"'.$logInfoItem->event_content.'";'.PHP_EOL;
|
||||
$string_encoded = iconv( mb_detect_encoding( $row ), 'ISO-8859-2', $row );
|
||||
fwrite($logTxt, $string_encoded);
|
||||
}
|
||||
fclose($logTxt);
|
||||
$data['logInfoLink'] = '<a href="'.base_url().'documents/loginfo.csv'.'" target="_blank">A loginfo.csv fájl letöltése</a>';
|
||||
}
|
||||
|
||||
$this->load->view('log-monitor', $data);
|
||||
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."home");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,782 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Pages extends CI_Controller {
|
||||
|
||||
/**
|
||||
* Index Page for this controller.
|
||||
*
|
||||
* Maps to the following URL
|
||||
* http://example.com/index.php/welcome
|
||||
* - or -
|
||||
* http://example.com/index.php/welcome/index
|
||||
* - or -
|
||||
* Since this controller is set as the default controller in
|
||||
* config/routes.php, it's displayed at http://example.com/
|
||||
*
|
||||
* So any other public methods not prefixed with an underscore will
|
||||
* map to /index.php/welcome/<method_name>
|
||||
* @see https://codeigniter.com/userguide3/general/urls.html
|
||||
*/
|
||||
public function index(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
|
||||
$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
|
||||
$data['pageTitle'] = '';
|
||||
$this->load->view('pages/home', $data);
|
||||
}
|
||||
|
||||
public function booking(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
|
||||
$data['pageTitle'] = '';
|
||||
|
||||
|
||||
//$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
$cleaningService = array('1');
|
||||
$data['cleaningServices'] = $this->Service_model->getAllServiceByGroups($cleaningService);
|
||||
/*echo '<pre>';
|
||||
print_r($data['cleaningServices']);
|
||||
echo '</pre>';*/
|
||||
$carService = array('2,3,4,5, 6,11');
|
||||
$data['carServices'] = $this->Service_model->getAllServiceByGroups($carService);
|
||||
|
||||
$helphandService = array('7');
|
||||
$data['helphandServices'] = $this->Service_model->getAllServiceByGroups($helphandService);
|
||||
|
||||
$gardenService = array('8');
|
||||
$data['gardenServices'] = $this->Service_model->getAllServiceByGroups($gardenService);
|
||||
|
||||
$houseService = array('9');
|
||||
$data['houseServices'] = $this->Service_model->getAllServiceByGroups($houseService);
|
||||
|
||||
$buildService = array('10');
|
||||
$data['buildServices'] = $this->Service_model->getAllServiceByGroups($buildService);
|
||||
|
||||
$data['serviceGroups'] = $this->Service_model->getServiceGroups();
|
||||
$data['workgroups'] = $this->Group_model->getAllActiveGroups();
|
||||
$data['activeWorkgroup'] = $this->Group_model->getAvailableGroup('2024-08-25', '1');
|
||||
|
||||
$this->load->view('pages/booking', $data);
|
||||
}
|
||||
|
||||
public function booking_finished(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$data['pageTitle'] = '';
|
||||
|
||||
$this->load->view('pages/booking-finished', $data);
|
||||
}
|
||||
|
||||
public function quotation_finished(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$data['pageTitle'] = '';
|
||||
|
||||
$this->load->view('pages/quotation-finished', $data);
|
||||
}
|
||||
|
||||
public function water_channel(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$data['pageTitle'] = '';
|
||||
$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
$this->load->view('pages/water-channel', $data);
|
||||
}
|
||||
|
||||
public function painting(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$data['pageTitle'] = '';
|
||||
$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
$this->load->view('pages/painting', $data);
|
||||
}
|
||||
|
||||
public function carefree_vacation(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$data['pageTitle'] = '';
|
||||
$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
$this->load->view('pages/carefree-vacation', $data);
|
||||
}
|
||||
|
||||
public function polishing(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$data['pageTitle'] = '';
|
||||
$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
$this->load->view('pages/polishing', $data);
|
||||
}
|
||||
|
||||
public function email_verification(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Log_model');
|
||||
|
||||
$data['pageTitle'] = '';
|
||||
$this->load->view('pages/email-verification', $data);
|
||||
}
|
||||
|
||||
public function ajax(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
$this->load->model('Group_model');
|
||||
$this->load->model('Log_model');
|
||||
|
||||
$data['pageTitle'] = '';
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'calculate_service_length' && isset($_POST['service_ids'])){
|
||||
if($_POST['service_ids'] != ''){
|
||||
$explodedServiceIds = explode(',', $_POST['service_ids']);
|
||||
$totalLength = '00:00:00';
|
||||
if(!empty($explodedServiceIds)){
|
||||
foreach($explodedServiceIds as $explodedServiceIdItem){
|
||||
$currentService = $this->Service_model->getServiceById($explodedServiceIdItem);
|
||||
$time = $totalLength;
|
||||
$time2 = $currentService->service_time;
|
||||
|
||||
$secs = strtotime($time2)-strtotime("00:00:00");
|
||||
$addedTotal = date("H:i:s",strtotime($time)+$secs);
|
||||
$totalLength = $addedTotal;
|
||||
}
|
||||
|
||||
}
|
||||
echo $totalLength;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'getAvailableTimeOptions' && isset($_POST['selectedDate'])){
|
||||
$results = $this->Service_model->getAvailableTimes($_POST['group_id'], $_POST['selectedDate'], $_POST['servicelength']);
|
||||
|
||||
$rowIndex = 1;
|
||||
if(is_array($results)){
|
||||
foreach($results as $resultIem){
|
||||
?>
|
||||
<option value="<?php echo $resultIem;?>"><?php echo date('H:i', strtotime($resultIem));?></option>
|
||||
<?php
|
||||
$rowIndex++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
echo 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'getAvailableGroup' && isset($_POST['service_category'])){
|
||||
|
||||
if($_POST['service_category'] != 0){
|
||||
$selectedGroup = $this->Group_model->getAvailableGroup($_POST['booking_date'], $_POST['service_category']);
|
||||
echo $selectedGroup->group_id;
|
||||
}
|
||||
else{
|
||||
echo 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'isTimeAvailable' && isset($_POST['selectedDate'])){
|
||||
$results = $this->Service_model->getAvailableTimes($_POST['group_id'], $_POST['selectedDate'], $_POST['servicelength']);
|
||||
|
||||
$timeIsAvailable = 0;
|
||||
if(is_array($results)){
|
||||
foreach($results as $resultIem){
|
||||
if(date('H:i:s', strtotime($resultIem)) == $_POST['selectedTime']){
|
||||
$timeIsAvailable = 1;
|
||||
}
|
||||
}
|
||||
|
||||
echo $timeIsAvailable;
|
||||
}
|
||||
else{
|
||||
echo 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'getAvailableTimes' && isset($_POST['selectedDate'])){
|
||||
$results = $this->Service_model->getAvailableTimes($_POST['group_id'], $_POST['selectedDate'], $_POST['servicelength'].':00');
|
||||
|
||||
$rowIndex = 1;
|
||||
if(!empty($results)){
|
||||
foreach($results as $resultIem){
|
||||
?>
|
||||
<div class="availableBookingTime" id="bookingTime_<?php echo $rowIndex;?>" onclick="setSelectedTime('<?php echo $resultIem;?>', '<?php echo $rowIndex;?>')"><span><?php echo date('H:i', strtotime($resultIem));?></span></div>
|
||||
<?php
|
||||
$rowIndex++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
echo 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'getSelectedGroup'){
|
||||
$result = $this->Group_model->getGroupById($_POST['group_id']);
|
||||
|
||||
if(is_object($result)){
|
||||
?>
|
||||
<div class="serviceBookingprofileImage" style="background-image:url('<?php echo SITEURL.'assets/img/'.$result->group_profile_img;?>');"></div>
|
||||
<div class="serviceBookingprofileName"><?php echo $result->group_name;?></div>
|
||||
<?php
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
echo 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'changeUserStatus' && isset($_POST['user_id']) && isset($_POST['newValue']) && isset($_POST['operator'])){
|
||||
$data['currentUser'] = $this->User_model->getUserById($_POST['user_id']);
|
||||
$userArray = array(
|
||||
'is_enabled' => $_POST['newValue']
|
||||
);
|
||||
$this->User_model->updateUser($_POST['user_id'], $userArray);
|
||||
$this->Log_model->addLog('change_user_status', $data['currentUser']->username.' státusza változott - '.($_POST['newValue']?'aktív':'letiltva').' állapotra', $_POST['operator']);
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'checkUser'){
|
||||
echo $this->User_model->isUsernameAvailable($_POST['username']);
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) && $_POST['action'] == 'refreshLogMonitor'){
|
||||
$logInfoArray = $this->Log_model->getAllLoginfo();
|
||||
$logrow = '';
|
||||
foreach($logInfoArray as $logInfoItem){
|
||||
$logDateTime = new datetime($logInfoItem->event_datetime);
|
||||
$logrow .= date_format($logDateTime,"Y-m-d H:i").' '.$logInfoItem->username.' '.$logInfoItem->event_content.' ';
|
||||
}
|
||||
echo $logrow;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->load->view('pages/ajax', $data);
|
||||
}
|
||||
|
||||
|
||||
public function booking_process(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Service_model');
|
||||
|
||||
$data['pageTitle'] = '';
|
||||
$data['subpage'] = '';
|
||||
|
||||
if(isset($_POST['sendFormCarefreeVacation'])){
|
||||
$bookingArray = array(
|
||||
'name' => $_POST['name'],
|
||||
'address' => $_POST['address'],
|
||||
'email' => $_POST['email'],
|
||||
'phonenumber' => $_POST['phonenumber'],
|
||||
'type_of_building' => $_POST['type_of_building'],
|
||||
'blomstervanning_enebolig' => $_POST['blomstervanning_Enebolig'],
|
||||
'postinntak_enebolig' => $_POST['Postinntak_Enebolig'],
|
||||
'number_of_worker' => $_POST['number_of_worker'],
|
||||
'user_notes' => $_POST['user_notes']
|
||||
);
|
||||
|
||||
$content = '';
|
||||
|
||||
$content = 'Kjære Partner,<br /><br />';
|
||||
$content .= 'Vi har mottatt din forespørsel om tilbud. Her er opplysningene du oppga.<br />';
|
||||
$content .= '<br />';
|
||||
$content .= '<table>';
|
||||
$content .= '<tr><td>Service: </td><td>Sorgløs ferie</td></tr>';
|
||||
$content .= '<tr><td>Navn: </td><td>'.$bookingArray['name'].'</td></tr>';
|
||||
$content .= '<tr><td>E-post: </td><td>'.$bookingArray['email'].'</td></tr>';
|
||||
$content .= '<tr><td>Telefon: </td><td>'.$bookingArray['phonenumber'].'</td></tr>';
|
||||
$content .= '<tr><td>Adresse: </td><td>'.$bookingArray['address'].'</td></tr>';
|
||||
|
||||
$content .= '<tr><td>Bygningstype: </td><td>'.$bookingArray['type_of_building'].'</td></tr>';
|
||||
$content .= '<tr><td>Enebolig: </td><td>'.($bookingArray['blomstervanning_enebolig']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Postinntak: </td><td>'.($bookingArray['postinntak_enebolig']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Hvor mange ganger skal vi totalt komme: </td><td>'.$bookingArray['number_of_worker'].'</td></tr>';
|
||||
$content .= '<tr><td>Utfyllende kommentarer: </td><td>'.$bookingArray['user_notes'].'</td></tr>';
|
||||
$content .= '</table>';
|
||||
$content .= '<br /> DIN BESTE HJELPER<br />';
|
||||
|
||||
$content .= '<br /> Dersom du ønsker å avbestille, kan du gjøre det i en melding på Instagram, Facebook eller til følgende e-post timebestilling@dinbestehjelper.no';
|
||||
|
||||
$emailItem = array(
|
||||
'addressee_email' => $bookingArray['email'],
|
||||
'addressee_name' => $bookingArray['name'],
|
||||
'subject' => '[dinbestehjelper] Din timebestilling har kommet',
|
||||
'content' => $content,
|
||||
'attachments' => array()
|
||||
);
|
||||
$emailArray[] = $emailItem;
|
||||
$this->User_model->sendEmail($emailArray);
|
||||
header('Location:'.SITEURL.'quotation-finished/');
|
||||
}
|
||||
|
||||
|
||||
if(isset($_POST['sendFormPainting'])){
|
||||
$bookingArray = array(
|
||||
'name' => $_POST['name'],
|
||||
'address' => $_POST['address'],
|
||||
'email' => $_POST['email'],
|
||||
'phonenumber' => $_POST['phonenumber'],
|
||||
'type_of_building' => $_POST['type_of_building'],
|
||||
'year_of_construction' => $_POST['year_of_construction'],
|
||||
'home_inhabited' => $_POST['home_inhabited'],
|
||||
'painting_on_plastered_surfaces' => $_POST['painting_on_plastered_surfaces'],
|
||||
'wall_paint_on_a_plasterboard_surface' => $_POST['wall_paint_on_a_plasterboard_surface'],
|
||||
'floor_area' => $_POST['floor_area'],
|
||||
'ceiling_height' => $_POST['ceiling_height'],
|
||||
'user_notes' => $_POST['user_notes']
|
||||
);
|
||||
|
||||
$content = '';
|
||||
|
||||
$content = 'Kjære Partner,<br /><br />';
|
||||
$content .= 'Vi har mottatt din forespørsel om tilbud. Her er opplysningene du oppga.<br />';
|
||||
$content .= '<br />';
|
||||
$content .= '<table>';
|
||||
$content .= '<tr><td>Service: </td><td>Malerarbeid</td></tr>';
|
||||
$content .= '<tr><td>Navn: </td><td>'.$bookingArray['name'].'</td></tr>';
|
||||
$content .= '<tr><td>E-post: </td><td>'.$bookingArray['email'].'</td></tr>';
|
||||
$content .= '<tr><td>Telefon: </td><td>'.$bookingArray['phonenumber'].'</td></tr>';
|
||||
$content .= '<tr><td>Adresse: </td><td>'.$bookingArray['address'].'</td></tr>';
|
||||
|
||||
$content .= '<tr><td>Bygningstype: </td><td>'.$bookingArray['type_of_building'].'</td></tr>';
|
||||
$content .= '<tr><td>Byggeår: </td><td>'.($bookingArray['year_of_construction']).'</td></tr>';
|
||||
$content .= '<tr><td>Er boligen bebodd under byggearbeidene? </td><td>'.($bookingArray['home_inhabited']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Maling på pussede overflater? </td><td>'.($bookingArray['painting_on_plastered_surfaces']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Veggmaling på gipsplateoverflate? </td><td>'.($bookingArray['wall_paint_on_a_plasterboard_surface']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Gulvareal i rommet som skal males: </td><td>'.$bookingArray['floor_area'].' m2</td></tr>';
|
||||
$content .= '<tr><td>Takhøyde: </td><td>'.$bookingArray['ceiling_height'].' m</td></tr>';
|
||||
$content .= '<tr><td>Utfyllende kommentarer: </td><td>'.$bookingArray['user_notes'].'</td></tr>';
|
||||
$content .= '</table>';
|
||||
$content .= '<br /> DIN BESTE HJELPER<br />';
|
||||
|
||||
$content .= '<br /> Dersom du ønsker å avbestille, kan du gjøre det i en melding på Instagram, Facebook eller til følgende e-post timebestilling@dinbestehjelper.no';
|
||||
|
||||
$emailItem = array(
|
||||
'addressee_email' => $bookingArray['email'],
|
||||
'addressee_name' => $bookingArray['name'],
|
||||
'subject' => '[dinbestehjelper] Din timebestilling har kommet',
|
||||
'content' => $content,
|
||||
'attachments' => array()
|
||||
);
|
||||
$emailArray[] = $emailItem;
|
||||
$this->User_model->sendEmail($emailArray);
|
||||
header('Location:'.SITEURL.'quotation-finished/');
|
||||
}
|
||||
|
||||
|
||||
if(isset($_POST['sendFormPolishing'])){
|
||||
$serviceArray = $this->Service_model->getAllServiceByServiceType();
|
||||
$bookingArray = array(
|
||||
'name' => $_POST['name'],
|
||||
'address' => $_POST['address'],
|
||||
'email' => $_POST['email'],
|
||||
'phonenumber' => $_POST['phonenumber'],
|
||||
'merke' => $_POST['merke'],
|
||||
'type_of_car' => $_POST['type_of_car'],
|
||||
'farge' => $_POST['farge'],
|
||||
'arsmodell' => $_POST['Arsmodell'],
|
||||
'user_notes' => $_POST['user_notes']
|
||||
);
|
||||
|
||||
$content = '';
|
||||
|
||||
$content = 'Kjære Partner,<br /><br />';
|
||||
$content .= 'Vi har mottatt din forespørsel om tilbud. Her er opplysningene du oppga.<br />';
|
||||
$content .= '<br />';
|
||||
$content .= '1. Vi behandler opplysningene du oppga så raskt som mulig.<br />';
|
||||
$content .= '2. Vi kontakter deg per e-post eller sms, for å avtale tidspunkt.<br />';
|
||||
$content .= '3. Vi kommer til avtalt tid for å besiktige stedet/oppgaven.<br />';
|
||||
$content .= '4. Deretter gir vi et tilbud per e-post.<br />';
|
||||
$content .= '5. Hvis du godtar det, begynner arbeidet så raskt som mulig.<br />';
|
||||
|
||||
$content .= '<br />Opplysninger:<br />';
|
||||
$content .= '<table>';
|
||||
$content .= '<tr><td>Service: </td><td>Full polering</td></tr>';
|
||||
$content .= '<tr><td>Navn: </td><td>'.$bookingArray['name'].'</td></tr>';
|
||||
$content .= '<tr><td>E-post: </td><td>'.$bookingArray['email'].'</td></tr>';
|
||||
$content .= '<tr><td>Telefon: </td><td>'.$bookingArray['phonenumber'].'</td></tr>';
|
||||
$content .= '<tr><td>Adresse: </td><td>'.$bookingArray['address'].'</td></tr>';
|
||||
|
||||
$content .= '<tr><td>Merke: </td><td>'.$bookingArray['merke'].'</td></tr>';
|
||||
$content .= '<tr><td>Type of car: </td><td>'.($bookingArray['type_of_car']).'</td></tr>';
|
||||
$content .= '<tr><td>Farge: </td><td>'.($bookingArray['farge']).'</td></tr>';
|
||||
$content .= '<tr><td>Arsmodell: </td><td>'.($bookingArray['arsmodell']).'</td></tr>';
|
||||
$content .= '<tr><td>Utfyllende kommentarer: </td><td>'.$bookingArray['user_notes'].'</td></tr>';
|
||||
|
||||
$content .= '</table>';
|
||||
$content .= '<br /> DIN BESTE HJELPER<br />';
|
||||
|
||||
$content .= '<br /> Dersom du ønsker å avbestille, kan du gjøre det i en melding på Instagram, Facebook eller til følgende e-post timebestilling@dinbestehjelper.no';
|
||||
|
||||
$emailItem = array(
|
||||
'addressee_email' => $bookingArray['email'],
|
||||
'addressee_name' => $bookingArray['name'],
|
||||
'subject' => '[dinbestehjelper] Din timebestilling har kommet',
|
||||
'content' => $content,
|
||||
'attachments' => array()
|
||||
);
|
||||
$emailArray[] = $emailItem;
|
||||
$this->User_model->sendEmail($emailArray);
|
||||
header('Location:'.SITEURL.'quotation-finished/');
|
||||
}
|
||||
|
||||
|
||||
if(isset($_POST['sendFormWaterChannel'])){
|
||||
$formArray = array(
|
||||
'name' => $_POST['name'],
|
||||
'address' => $_POST['address'],
|
||||
'email' => $_POST['email'],
|
||||
'phonenumber' => $_POST['phonenumber'],
|
||||
'type_of_building' => $_POST['type_of_building'],
|
||||
'year_of_construction' => $_POST['year_of_construction'],
|
||||
'home_inhabited' => $_POST['home_inhabited'],
|
||||
'demolition_of_old_system' => $_POST['demolition_of_old_system'],
|
||||
'installation_of_new_system' => $_POST['installation_of_new_system'],
|
||||
'installation_of_water_in_kitchen' => $_POST['installation_of_water_in_kitchen'],
|
||||
'installation_of_water_in_the_bathroom' => $_POST['installation_of_water_in_the_bathroom'],
|
||||
'connection_of_washbasin' => $_POST['connection_of_washbasin'],
|
||||
'replacement_of_toilet' => $_POST['replacement_of_toilet'],
|
||||
'installation_of_connection_for_household' => $_POST['installation_of_connection_for_household'],
|
||||
'connecting_a_dishwasher' => $_POST['connecting_a_dishwasher'],
|
||||
'connection_of_washing_machine' => $_POST['connection_of_washing_machine'],
|
||||
'connection_of_dryer' => $_POST['connection_of_dryer'],
|
||||
'installation_of_a_garden_tap' => $_POST['installation_of_a_garden_tap'],
|
||||
'installation_of_water_purification' => $_POST['installation_of_water_purification'],
|
||||
'user_notes' => $_POST['user_notes']
|
||||
);
|
||||
|
||||
$content = '';
|
||||
|
||||
$content = 'Kjære Partner,<br /><br />';
|
||||
$content .= 'Vi har mottatt din forespørsel om tilbud. Her er opplysningene du oppga.<br />';
|
||||
$content .= '<br />';
|
||||
$content .= '<table>';
|
||||
$content .= '<tr><td>Service: </td><td>Rørleggerarbeid</td></tr>';
|
||||
$content .= '<tr><td>Navn: </td><td>'.$bookingArray['name'].'</td></tr>';
|
||||
$content .= '<tr><td>E-post: </td><td>'.$bookingArray['email'].'</td></tr>';
|
||||
$content .= '<tr><td>Telefon: </td><td>'.$bookingArray['phonenumber'].'</td></tr>';
|
||||
$content .= '<tr><td>Adresse: </td><td>'.$bookingArray['address'].'</td></tr>';
|
||||
|
||||
$content .= '<tr><td>Bygningstype: </td><td>'.$bookingArray['type_of_building'].'</td></tr>';
|
||||
$content .= '<tr><td>Byggeår: </td><td>'.($bookingArray['year_of_construction']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Er boligen bebodd under byggearbeidene?: </td><td>'.($bookingArray['home_inhabited']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Rivning av gammelt system (komplett til vannmåler): </td><td>'.($bookingArray['demolition_of_old_system']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Installasjon av nytt system (fra måler): </td><td>'.($bookingArray['installation_of_new_system']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Installasjon av vann og avløp i kjøkken: </td><td>'.($bookingArray['installation_of_water_in_kitchen']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Installasjon av vann og avløp på bad: </td><td>'.($bookingArray['installation_of_water_in_the_bathroom']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Tilkobling av servant, badekar, dusj: </td><td>'.($bookingArray['connection_of_washbasin']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Utskifting av toalett, håndvask, nyinstallasjon: </td><td>'.($bookingArray['replacement_of_toilet']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Installasjon av tilkobling for husholdningsapparater: </td><td>'.($bookingArray['installation_of_connection_for_household']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Tilkobling av oppvaskmaskin: </td><td>'.($bookingArray['connecting_a_dishwasher']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Tilkobling av vaskemaskin: </td><td>'.($bookingArray['connection_of_washing_machine']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Tilkobling av tørketrommel: </td><td>'.($bookingArray['connection_of_dryer']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Installasjon av hagekran: </td><td>'.($bookingArray['installation_of_a_garden_tap']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Installasjon av vannrenseutstyr: </td><td>'.($bookingArray['installation_of_water_purification']?'Ja':'Nei').'</td></tr>';
|
||||
$content .= '<tr><td>Utfyllende kommentarer: </td><td>'.$bookingArray['user_notes'].'</td></tr>';
|
||||
|
||||
$content .= '</table>';
|
||||
$content .= '<br /> DIN BESTE HJELPER<br />';
|
||||
|
||||
$content .= '<br /> Dersom du ønsker å avbestille, kan du gjøre det i en melding på Instagram, Facebook eller til følgende e-post timebestilling@dinbestehjelper.no';
|
||||
|
||||
$emailItem = array(
|
||||
'addressee_email' => $bookingArray['email'],
|
||||
'addressee_name' => $bookingArray['name'],
|
||||
'subject' => '[dinbestehjelper] Din timebestilling har kommet',
|
||||
'content' => $content,
|
||||
'attachments' => array()
|
||||
);
|
||||
$emailArray[] = $emailItem;
|
||||
$this->User_model->sendEmail($emailArray);
|
||||
header('Location:'.SITEURL.'quotation-finished/');
|
||||
}
|
||||
|
||||
|
||||
if(isset($_POST['sendBooking'])){
|
||||
//calculate finish time
|
||||
$serviceStartTime = date("H:i:s", strtotime($_POST['booking_start_time']));
|
||||
$serviceLengthTime = date("H:i:s", strtotime($_POST['servicelength']));
|
||||
$secs = strtotime($serviceLengthTime)-strtotime("00:00:00");
|
||||
$serviceFinishTime = date("H:i:s",strtotime($serviceStartTime)+$secs);
|
||||
|
||||
$data['services'] = $this->Service_model->getAllServiceByServiceType();
|
||||
$data['workgroups'] = $this->Group_model->getAllGroups();
|
||||
$selectedServiceArray = array();
|
||||
|
||||
//find selected services
|
||||
if(is_array($data['services'])){
|
||||
foreach($data['services'] as $serviceItem){
|
||||
if(isset($_POST['service_'.$serviceItem->service_id])){
|
||||
if($_POST['service_'.$serviceItem->service_id]){
|
||||
$selectedServiceArray[] = array(
|
||||
'service_id' => $serviceItem->service_id,
|
||||
'quantity' => $_POST['quantity_'.$serviceItem->service_id]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$bookingArray = array(
|
||||
'guest_name' => $_POST['guest_name'],
|
||||
'guest_email' => $_POST['guest_email'],
|
||||
'guest_phone' => $_POST['guest_phone'],
|
||||
'guest_addresse' => $_POST['guest_addresse'],
|
||||
'guest_car_reg_number' => $_POST['guest_car_reg_number'],
|
||||
'guest_car_type' => $_POST['guest_car_type'],
|
||||
'group_id' => $_POST['group_id'],
|
||||
'booking_date' => $_POST['booking_date'],
|
||||
'booking_start_time' => $_POST['booking_start_time'],
|
||||
'booking_finish_time' => $serviceFinishTime,
|
||||
'service_ids' => serialize($selectedServiceArray),
|
||||
'guest_confirmed' => '0',
|
||||
'total_price' => $_POST['totalPrice'],
|
||||
'guest_confirm_code' => '1234',
|
||||
);
|
||||
|
||||
$this->Service_model->createBooking($bookingArray);
|
||||
$group = $this->Group_model->getGroupById($bookingArray['group_id']);
|
||||
|
||||
$services = unserialize($bookingArray['service_ids']);
|
||||
$serviceArray = array();
|
||||
$emailArray = array();
|
||||
|
||||
if(is_array($services)){
|
||||
foreach($services as $serviceItem){
|
||||
$selectedService = $this->Service_model->getServiceById($serviceItem['service_id']);
|
||||
if(is_object($selectedService)){
|
||||
$tmpService = (array)$selectedService;
|
||||
$tmpService['quantity'] = $serviceItem['quantity'];
|
||||
$serviceArray[] = (object)$tmpService;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$content = '';
|
||||
|
||||
$content = 'Kjære Bestiller,<br /><br />';
|
||||
$content .= 'Takk for din bestilling. Her er opplysningene du oppga.<br />';
|
||||
$content .= '<br />';
|
||||
$content .= '<table>';
|
||||
$content .= '<tr><td>Navn: </td><td>'.$bookingArray['guest_name'].'</td></tr>';
|
||||
$content .= '<tr><td>E-post: </td><td>'.$bookingArray['guest_email'].'</td></tr>';
|
||||
$content .= '<tr><td>Telefon: </td><td>'.$bookingArray['guest_phone'].'</td></tr>';
|
||||
$content .= '<tr><td>Adresse: </td><td>'.$bookingArray['guest_addresse'].'</td></tr>';
|
||||
if($bookingArray['guest_car_reg_number'] != ''){
|
||||
$content .= '<tr><td>Registreringsnummer: </td><td>'.$bookingArray['guest_car_reg_number'].'</td></tr>';
|
||||
}
|
||||
if($bookingArray['guest_car_type'] != ''){
|
||||
$content .= '<tr><td>Bilmerke: </td><td>'.$bookingArray['guest_car_type'].'</td></tr>';
|
||||
}
|
||||
$content .= '<tr><td>Dato: </td><td>'.$bookingArray['booking_date'].'</td></tr>';
|
||||
$content .= '<tr><td>Tid: </td><td>'.$bookingArray['booking_start_time'].' - '.$bookingArray['booking_finish_time'].'</td></tr>';
|
||||
$content .= '<tr><td>Tjenester: </td><td><table>';
|
||||
$totalServicePrice = 0;
|
||||
foreach($serviceArray as $serviceArrayItem){
|
||||
$totalServicePrice += $serviceArrayItem->service_price;
|
||||
$content .= '<tr><td>'.$serviceArrayItem->service_name.'</td><td>('.$serviceArrayItem->quantity.' x '.$serviceArrayItem->service_price.' kr) '.$serviceArrayItem->quantity*$serviceArrayItem->service_price.' kr</td></tr>';
|
||||
}
|
||||
$content .= '</table></td>';
|
||||
$content .= '<tr><td>Totalpris: </td><td><strong>'.$bookingArray['total_price'].' kr</strong></td></tr>';
|
||||
$content .= '</table>';
|
||||
$content .= '<br /> DIN BESTE HJELPER<br />';
|
||||
|
||||
$content .= '<br /> Dersom du ønsker å avbestille, kan du gjøre det i en melding på Instagram, Facebook eller til følgende e-post timebestilling@dinbestehjelper.no';
|
||||
|
||||
$emailItem = array(
|
||||
'addressee_email' => $bookingArray['guest_email'],
|
||||
'addressee_name' => $bookingArray['guest_name'],
|
||||
'subject' => '[dinbestehjelper] Din timebestilling har kommet',
|
||||
'content' => $content,
|
||||
'attachments' => array()
|
||||
);
|
||||
$emailArray[] = $emailItem;
|
||||
$this->User_model->sendEmail($emailArray);
|
||||
header('Location:'.SITEURL.'booking-finished/');
|
||||
}
|
||||
|
||||
$this->load->view('pages/booking-process', $data);
|
||||
}
|
||||
|
||||
public function profile(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Log_model');
|
||||
$this->load->model('Module_model');
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
$data['fullname'] = '';
|
||||
$data['password'] = '';
|
||||
$data['profile_img_url'] = '';
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
$data['pageTitle'] = 'Profil szerkesztése';
|
||||
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
if(isset($_POST["storeProfile"])) {
|
||||
|
||||
if($_POST['fullname'] != $data['currentUser']->fullname){
|
||||
$userArray = array(
|
||||
'fullname' => $_POST['fullname']
|
||||
);
|
||||
$this->User_model->updateUser($data['currentUser']->user_id, $userArray);
|
||||
$this->Log_model->addLog('profile', 'A felhasználó módosította a teljes nevét: '.$data['currentUser']->fullname.' => '.$_POST['fullname'],$_SESSION['username']);
|
||||
}
|
||||
|
||||
if($_POST['password'] != ''){
|
||||
$userArray = array(
|
||||
'password' => hash('sha256', $_POST['password'])
|
||||
);
|
||||
$this->User_model->updateUser($data['currentUser']->user_id, $userArray);
|
||||
$this->Log_model->addLog('profile', 'A felhasználó módosította a jelszavát',$_SESSION['username']);
|
||||
}
|
||||
|
||||
|
||||
//upload profile image
|
||||
if($_FILES["profile_img"]["tmp_name"] != ''){
|
||||
$target_dir = getcwd()."/assets/img/profiles/";
|
||||
$target_file = $target_dir . str_replace('.','_', str_replace('@','_',$_SESSION['username']));
|
||||
$imageFileType = strtolower(pathinfo(basename($_FILES["profile_img"]["name"]),PATHINFO_EXTENSION));
|
||||
|
||||
if (move_uploaded_file($_FILES["profile_img"]["tmp_name"], $target_file.'.'.$imageFileType)) {
|
||||
$data['message'] = 'A profilkép sikeresen feltöltve!';
|
||||
$data['message_class'] = 'successMessage';
|
||||
$data['profile_img_url'] = 'assets/img/profiles/'.str_replace('.','_', str_replace('@','_',$_SESSION['username'])).'.'.$imageFileType;
|
||||
$userArray = array(
|
||||
'profile_img_url' => $data['profile_img_url']
|
||||
);
|
||||
$this->User_model->updateUser($data['currentUser']->user_id, $userArray);
|
||||
$this->Log_model->addLog('profile', 'A felhasználó lecserélte a profilképét ',$_SESSION['username']);
|
||||
} else {
|
||||
$data['message'] = 'Hiba a feltöltés közben!';
|
||||
$data['message_class'] = 'errorMessage';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$data['message'] = 'A profil sikeresen módosítva!';
|
||||
$data['message_class'] = 'successMessage';
|
||||
}
|
||||
|
||||
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$this->load->view('pages/profile', $data);
|
||||
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
}
|
||||
|
||||
public function log_monitor(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Log_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
$data['pageTitle'] = 'Rendszermonitor';
|
||||
$data['logInfoLink'] = '';
|
||||
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
$selectedModule = $this->Module_model->getModuleBySlug('log-monitor');
|
||||
if($this->Module_model->is_module_available($selectedModule->module_id, $data['currentUser']->user_id)){
|
||||
|
||||
if(isset($_POST['exportToFile'])){
|
||||
$logInfoArray = $this->Log_model->getAllLoginfo();
|
||||
$logrow = '';
|
||||
$logTxt = fopen(getcwd()."/documents/loginfo.csv", "w") or die("Hiba a fájl mentésekor!");
|
||||
$row = '"Esemény ideje";'.'"Esemény típusa";'.'"Felhasználónév";"Bejegyzés tartalma";'.PHP_EOL;
|
||||
$string_encoded = iconv( mb_detect_encoding( $row ), 'ISO-8859-2', $row );
|
||||
fwrite($logTxt, $string_encoded);
|
||||
|
||||
foreach($logInfoArray as $logInfoItem){
|
||||
$logDateTime = new datetime($logInfoItem->event_datetime);
|
||||
$row = date_format($logDateTime,"Y-m-d H:i").';"'.$logInfoItem->event_type.'";"'.$logInfoItem->username.'";"'.$logInfoItem->event_content.'";'.PHP_EOL;
|
||||
$string_encoded = iconv( mb_detect_encoding( $row ), 'ISO-8859-2', $row );
|
||||
fwrite($logTxt, $string_encoded);
|
||||
}
|
||||
fclose($logTxt);
|
||||
$data['logInfoLink'] = '<a href="'.base_url().'documents/loginfo.csv'.'" target="_blank">A loginfo.csv fájl letöltése</a>';
|
||||
}
|
||||
|
||||
$this->load->view('log-monitor', $data);
|
||||
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."home");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class UserManagement extends CI_Controller {
|
||||
|
||||
/**
|
||||
* Index Page for this controller.
|
||||
*
|
||||
* Maps to the following URL
|
||||
* http://example.com/index.php/welcome
|
||||
* - or -
|
||||
* http://example.com/index.php/welcome/index
|
||||
* - or -
|
||||
* Since this controller is set as the default controller in
|
||||
* config/routes.php, it's displayed at http://example.com/
|
||||
*
|
||||
* So any other public methods not prefixed with an underscore will
|
||||
* map to /index.php/welcome/<method_name>
|
||||
* @see https://codeigniter.com/user_guide/general/urls.html
|
||||
*/
|
||||
public function index(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Log_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['activeModules'] = $this->Module_model->getModulesByPermissionSlug($data['currentUser']->permission_slug);
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
$data['pageTitle'] = 'Felhasználó kezelése';
|
||||
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
$selectedModule = $this->Module_model->getModuleBySlug('user-management');
|
||||
if($this->Module_model->user_can_access_this_module($selectedModule->module_slug, $data['currentUser']->user_id) || $data['currentUser']->permission_slug == 'admin'){
|
||||
//delete user
|
||||
if(isset($_GET['delete-user'])){
|
||||
$selectedUser = $this->User_model->getUserById($_GET['delete-user']);
|
||||
$this->Log_model->addLog('users', $data['currentUser']->username.' törölte a(z) '.$selectedUser->username.' felhasználót', $data['currentUser']->username);
|
||||
$this->User_model->deleteUser($_GET['delete-user']);
|
||||
header('Location:'.site_url().'user-management');
|
||||
}
|
||||
$data['users'] = $this->User_model->getAllUser();
|
||||
$this->load->view('pages/user-management',$data);
|
||||
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."dashboard");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function add_new_user(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Log_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['activeModules'] = $this->Module_model->getModulesByPermissionSlug($data['currentUser']->permission_slug);
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
$data['pageTitle'] = 'Felhasználó létrehozása';
|
||||
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
$selectedModule = $this->Module_model->getModuleBySlug('user-management');
|
||||
if($this->Module_model->user_can_access_this_module($selectedModule->module_slug, $data['currentUser']->user_id) || $data['currentUser']->permission_slug == 'admin'){
|
||||
$data['permissions'] = $this->User_model->getAllUserPermission();
|
||||
|
||||
|
||||
$this->load->view('pages/add-new-user',$data);
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."home");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function modify_user($user_id=''){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Log_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['activeModules'] = $this->Module_model->getModulesByPermissionSlug($data['currentUser']->permission_slug);
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
$data['pageTitle'] = 'Felhasználók';
|
||||
|
||||
if($this->User_model->is_user_admin($_SESSION['username'])){
|
||||
$data['activeModules'] = $this->Module_model->getAllModule();
|
||||
}
|
||||
else{
|
||||
$data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id);
|
||||
}
|
||||
|
||||
$selectedModule = $this->Module_model->getModuleBySlug('user-management');
|
||||
if($this->Module_model->user_can_access_this_module($selectedModule->module_slug, $data['currentUser']->user_id) || $data['currentUser']->permission_slug == 'admin'){
|
||||
|
||||
$data['selectedUser'] = $this->User_model->getUserById($user_id);
|
||||
$data['permissions'] = $this->User_model->getAllUserPermission();
|
||||
$this->load->view('pages/modify-user',$data);
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."home");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function user_process(){
|
||||
$this->load->helper('url');
|
||||
$this->load->model('User_model');
|
||||
$this->load->model('Log_model');
|
||||
$this->load->model('Module_model');
|
||||
|
||||
if(isset($_SESSION['username'])){
|
||||
$data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']);
|
||||
$data['activeModules'] = $this->Module_model->getModulesByPermissionSlug($data['currentUser']->permission_slug);
|
||||
$data['message'] = '';
|
||||
$data['message_class'] = '';
|
||||
$data['pageTitle'] = 'Felhasználók';
|
||||
|
||||
$selectedModule = $this->Module_model->getModuleBySlug('user-management');
|
||||
if($this->Module_model->user_can_access_this_module($selectedModule->module_slug, $data['currentUser']->user_id) || $data['currentUser']->permission_slug == 'admin'){
|
||||
|
||||
//update user
|
||||
if(isset($_POST['updateUser'])){
|
||||
$userArray = array(
|
||||
'username' => $_POST['username'],
|
||||
'fullname' => $_POST['fullname'],
|
||||
'permission_slug' => $_POST['permission_slug'],
|
||||
'is_enabled' => $_POST['is_enabled'],
|
||||
'user_notes' => $_POST['user_notes']
|
||||
);
|
||||
|
||||
if($_POST['password'] != ''){
|
||||
$userArray['password'] = $_POST['password'];
|
||||
}
|
||||
|
||||
$this->User_model->updateUser($_POST['user_id'], $userArray);
|
||||
|
||||
$userArray['permission_slug'] = $this->User_model->getPermissionBySlug($userArray['permission_slug'])->permission_name;
|
||||
|
||||
if($_POST['password'] != ''){
|
||||
$userArray['password'] = '****';
|
||||
}
|
||||
|
||||
$userArray['is_enabled'] = $userArray['is_enabled']?'aktív':'letiltva';
|
||||
$userArray['user_notes'] = $userArray['user_notes'] != ''?$userArray['user_notes']:'nincs megjegyzés';
|
||||
|
||||
$this->Log_model->addLog('users', $data['currentUser']->username.' módosította a(z) '.$_POST['username'].' adatait ('.implode(', ', $userArray).')', $data['currentUser']->username);
|
||||
}
|
||||
|
||||
//add new user
|
||||
if(isset($_POST['addNewUser'])){
|
||||
$userArray = array(
|
||||
'username' => $_POST['username'],
|
||||
'password' => $_POST['password'],
|
||||
'fullname' => $_POST['fullname'],
|
||||
'permission_slug' => $_POST['permission_slug'],
|
||||
'is_enabled' => $_POST['is_enabled'],
|
||||
'user_notes' => $_POST['user_notes']
|
||||
);
|
||||
|
||||
$this->User_model->addNewUser($userArray);
|
||||
$userArray['permission_id'] = $this->User_model->getpermissionBySlug($userArray['permission_slug'])->permission_slug;
|
||||
$userArray['is_enabled'] = $userArray['is_enabled']?'aktív':'letiltva';
|
||||
$userArray['user_notes'] = $userArray['user_notes'] != ''?$userArray['user_notes']:'nincs megjegyzés';
|
||||
$userArray['password'] = '****';
|
||||
$this->Log_model->addLog('users', $data['currentUser']->username.' létrehoza a(z) '.$_POST['username'].' felhasználót ('.implode(', ', $userArray).')', $data['currentUser']->username);
|
||||
}
|
||||
|
||||
header("Location:".SITEURL."user-management");
|
||||
//$this->load->view('pages/user-process',$data);
|
||||
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."home");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
header("Location:".SITEURL."login");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user