add all files
This commit is contained in:
+299
@@ -0,0 +1,299 @@
|
||||
<?php
|
||||
class Service_model extends CI_Model {
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function createService($serviceArray){
|
||||
$this->load->database();
|
||||
$query = $this->db->query('INSERT INTO services (
|
||||
service_type,
|
||||
service_category,
|
||||
service_name,
|
||||
service_description,
|
||||
service_price,
|
||||
service_time,
|
||||
service_note
|
||||
) VALUES(
|
||||
"'.$serviceArray['service_type'].'",
|
||||
"'.$serviceArray['service_category'].'",
|
||||
"'.$serviceArray['service_name'].'",
|
||||
"'.$serviceArray['service_description'].'",
|
||||
"'.$serviceArray['service_price'].'",
|
||||
"'.$serviceArray['service_time'].'",
|
||||
"'.$serviceArray['service_note'].'"
|
||||
);');
|
||||
}
|
||||
|
||||
public function updateService($service_id, $serviceArray){
|
||||
$this->load->database();
|
||||
|
||||
foreach($serviceArray as $propertyKey => $propertyValue){
|
||||
$query = $this->db->query('UPDATE users SET '.$propertyKey.' = "'.$propertyValue.'" WHERE service_id = "'.$service_id.'";');
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllServiceByServiceType($service_type, $lang){
|
||||
$this->load->database();
|
||||
$query = $this->db->query('SELECT * FROM services WHERE service_type = "'.$service_type.'" ORDER BY service_id ASC;');
|
||||
$serviceArray = array();
|
||||
if($query->num_rows() > 0){
|
||||
foreach($query->result() as $resultItem){
|
||||
|
||||
$service_category = '';
|
||||
$service_name = '';
|
||||
$service_description = '';
|
||||
|
||||
switch($lang){
|
||||
case 'no':
|
||||
$service_category = $resultItem->service_category_no;
|
||||
$service_name = $resultItem->service_name_no;
|
||||
$service_description = $resultItem->service_description_no;
|
||||
break;
|
||||
case 'en':
|
||||
$service_category = $resultItem->service_category_en;
|
||||
$service_name = $resultItem->service_name_en;
|
||||
$service_description = $resultItem->service_description_en;
|
||||
break;
|
||||
case 'hu':
|
||||
$service_category = $resultItem->service_category_hu;
|
||||
$service_name = $resultItem->service_name_hu;
|
||||
$service_description = $resultItem->service_description_hu;
|
||||
break;
|
||||
}
|
||||
|
||||
$resultItemTmp = array(
|
||||
'service_id' => $resultItem->service_id,
|
||||
'service_type' => $resultItem->service_type,
|
||||
'service_category' => $service_category,
|
||||
'service_name' => $service_name,
|
||||
'service_description' => $service_description,
|
||||
'service_price' => $resultItem->service_price,
|
||||
'service_time' => $resultItem->service_time
|
||||
);
|
||||
|
||||
$serviceArray[] = (object)$resultItemTmp;
|
||||
}
|
||||
}
|
||||
return $serviceArray;
|
||||
}
|
||||
|
||||
public function getServiceById($service_id){
|
||||
$this->load->database();
|
||||
$query = $this->db->query('SELECT * FROM services WHERE service_id = "'.$service_id.'" LIMIT 1;');
|
||||
if($query->num_rows() > 0){
|
||||
return $query->result()[0];
|
||||
}
|
||||
else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllWorkers(){
|
||||
$this->load->database();
|
||||
$query = $this->db->query('SELECT * FROM workers ORDER BY worker_name ASC;');
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function getWorkerById($worker_id){
|
||||
$this->load->database();
|
||||
$query = $this->db->query('SELECT * FROM workers WHERE worker_id = "'.$worker_id.'" LIMIT 1;');
|
||||
if($query->num_rows() > 0){
|
||||
return $query->result()[0];
|
||||
}
|
||||
else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function getAvailableTimes($worker_id, $selectedDate, $servicelength){
|
||||
$this->load->database();
|
||||
$service_length_time = strtotime($servicelength);
|
||||
$availableTimeArray = array();
|
||||
|
||||
//finish time - selected service length
|
||||
$finishTime = new DateTime($selectedDate.' 18:00');
|
||||
$datelength = new DateTime($servicelength);
|
||||
$diff = $datelength->diff($finishTime);
|
||||
|
||||
//max time for start
|
||||
$maxdate = $diff->h.':'.$diff->i.':00';
|
||||
$hours = (intval($diff->h)-8)*4+1;
|
||||
$mins = floor(intval($diff->i) / 15);
|
||||
$loopSteps = intval($hours) + intval($mins);
|
||||
|
||||
for($periodIndex = 1; $periodIndex <= $loopSteps; $periodIndex++){
|
||||
$minutes_to_add_start = $periodIndex*15;
|
||||
$minutes_to_add_end = ($periodIndex+1)*15;
|
||||
$startTime = new DateTime($selectedDate.' 07:45');
|
||||
$endTime = new DateTime($selectedDate.' 07:45');
|
||||
$startTime->add(new DateInterval('PT' . $minutes_to_add_start . 'M'));
|
||||
$endTime->add(new DateInterval('PT' . $minutes_to_add_end . 'M'));
|
||||
|
||||
$currentStartTime = $startTime->format('H:i:00');
|
||||
$currentEndTime = $endTime->format('H:i:00');
|
||||
|
||||
$query = $this->db->query('SELECT * FROM bookings WHERE booking_date = "'.$selectedDate.'" AND worker_id = "'.$worker_id.'" AND (
|
||||
(TIME(booking_start_time) >= CAST("'.$currentStartTime.'" AS TIME) AND TIME(booking_finish_time) <= CAST("'.$currentEndTime.'" AS TIME)) OR
|
||||
|
||||
(TIME(booking_start_time) >= CAST("'.$currentStartTime.'" AS TIME) AND TIME(booking_start_time) <= CAST("'.$currentEndTime.'" AS TIME) AND TIME(booking_finish_time) >= CAST("'.$currentEndTime.'" AS TIME)) OR
|
||||
|
||||
(TIME(booking_start_time) <= CAST("'.$currentStartTime.'" AS TIME) AND TIME(booking_finish_time) >= CAST("'.$currentEndTime.'" AS TIME)
|
||||
AND TIME(booking_start_time) <= CAST("'.$currentStartTime.'" AS TIME)) OR
|
||||
|
||||
(TIME(booking_start_time) <= CAST("'.$currentStartTime.'" AS TIME) AND TIME(booking_finish_time) <= CAST("'.$currentEndTime.'" AS TIME)
|
||||
AND TIME(booking_finish_time) >= CAST("'.$currentStartTime.'" AS TIME)) OR
|
||||
|
||||
(TIME(booking_start_time) <= CAST("'.$currentStartTime.'" AS TIME) AND TIME(booking_finish_time) >= CAST("'.$currentEndTime.'" AS TIME))
|
||||
);
|
||||
');
|
||||
|
||||
if($query->num_rows() == 0){
|
||||
$availableTimeArray[] = $currentStartTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $availableTimeArray;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function createBooking($bookingArray){
|
||||
$this->load->database();
|
||||
$query = $this->db->query("INSERT INTO bookings (
|
||||
guest_name,
|
||||
guest_email,
|
||||
guest_phone,
|
||||
worker_id,
|
||||
booking_date,
|
||||
booking_start_time,
|
||||
booking_finish_time,
|
||||
service_ids,
|
||||
guest_confirmed,
|
||||
guest_confirm_code
|
||||
) VALUES(
|
||||
'".$bookingArray['guest_name']."',
|
||||
'".$bookingArray['guest_email']."',
|
||||
'".$bookingArray['guest_phone']."',
|
||||
'".$bookingArray['worker_id']."',
|
||||
'".$bookingArray['booking_date']."',
|
||||
'".$bookingArray['booking_start_time']."',
|
||||
'".$bookingArray['booking_finish_time']."',
|
||||
'".$bookingArray['service_ids']."',
|
||||
'".$bookingArray['guest_confirmed']."',
|
||||
'".$bookingArray['guest_confirm_code']."'
|
||||
);");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Executable
+182
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
require getcwd().'/vendor/autoload.php';
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\SMTP;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
|
||||
class User_model extends CI_Model {
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function userCanLogin($username, $password){
|
||||
$this->load->database();
|
||||
$query = $this->db->query('SELECT * FROM users WHERE username = "'.$username.'" AND password = "'.hash('sha256', $password).'" AND is_enabled = 1 LIMIT 1');
|
||||
|
||||
if($query->num_rows() == 1){
|
||||
return 1;
|
||||
}
|
||||
else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllUser(){
|
||||
$this->load->database();
|
||||
$query = $this->db->query('SELECT * FROM users JOIN privilegies ON users.privilegy_group_id = privilegies.privilegy_group_id ORDER BY fullname ASC');
|
||||
$userResults = $query->result();
|
||||
|
||||
foreach($userResults as $userResultItem){
|
||||
if($userResultItem->profile_img_url == ''){
|
||||
$userResultItem->profile_img_url = base_url().'img/default_profile.jpg';
|
||||
}
|
||||
}
|
||||
return $userResults;
|
||||
}
|
||||
|
||||
public function getUserByUsername($username){
|
||||
$this->load->database();
|
||||
$query = $this->db->query('SELECT * FROM users JOIN privilegies ON users.privilegy_group_id = privilegies.privilegy_group_id WHERE username = "'.$username.'" LIMIT 1');
|
||||
if($query->num_rows() == 1){
|
||||
|
||||
if($query->result()[0]->profile_img_url == ''){
|
||||
$query->result()[0]->profile_img_url = base_url().'img/default_profile.jpg';
|
||||
}
|
||||
return $query->result()[0];
|
||||
}
|
||||
else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserById($userId){
|
||||
$this->load->database();
|
||||
$query = $this->db->query('SELECT * FROM users JOIN privilegies ON users.privilegy_group_id = privilegies.privilegy_group_id WHERE user_id = "'.$userId.'" LIMIT 1');
|
||||
if($query->num_rows() == 1){
|
||||
if($query->result()[0]->profile_img_url == ''){
|
||||
$query->result()[0]->profile_img_url = base_url().'img/default_profile.jpg';
|
||||
}
|
||||
return $query->result()[0];
|
||||
}
|
||||
else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteUser($userId){
|
||||
$this->load->database();
|
||||
$query = $this->db->query('DELETE FROM users WHERE user_id = "'.$userId.'";');
|
||||
}
|
||||
|
||||
public function isUsernameAvailable($username){
|
||||
$this->load->database();
|
||||
$query = $this->db->query('SELECT * FROM users WHERE username = "'.$username.'";');
|
||||
if($query->num_rows() == 1){
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public function updateUser($userId, $userArray){
|
||||
$this->load->database();
|
||||
|
||||
foreach($userArray as $propertyKey => $propertyValue){
|
||||
$query = $this->db->query('UPDATE users SET '.$propertyKey.' = "'.hash('sha256',$propertyValue).'" WHERE user_id = "'.$userId.'";');
|
||||
}
|
||||
}
|
||||
|
||||
public function addNewUser($userArray){
|
||||
$this->load->database();
|
||||
|
||||
if(!is_object($this->getUserByUsername($userArray['username']))){
|
||||
$query = $this->db->query('INSERT INTO users (username, password, fullname, privilegy_group_id, is_enabled, user_notes) VALUES("'.$userArray['username'].'", "'.hash('sha256', $userArray['password']).'", "'.$userArray['fullname'].'", "'.$userArray['privilegy_group_id'].'", "'.$userArray['is_enabled'].'", "'.$userArray['user_notes'].'");');
|
||||
return 1;
|
||||
}
|
||||
else{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function sendEmail($addressList, $lang, $subpage){
|
||||
// Import PHPMailer classes into the global namespace
|
||||
// These must be at the top of your script, not inside a function
|
||||
|
||||
if(!empty($addressList)){
|
||||
foreach($addressList as $addressListItem){
|
||||
// Instantiation and passing `true` enables exceptions
|
||||
$mail = new PHPMailer(false);
|
||||
$mail->SMTPDebug = false;
|
||||
$mail->do_debug = 1;
|
||||
try {
|
||||
//Server settings
|
||||
$mail->CharSet = 'UTF-8';
|
||||
//$mail->SMTPDebug = SMTP::DEBUG_SERVER; // Enable verbose debug output
|
||||
$mail->isSMTP(); //Send using SMTP
|
||||
$mail->Host = 'mail.absolutesolution.hu'; //Set the SMTP server to send through
|
||||
$mail->SMTPAuth = true; //Enable SMTP authentication
|
||||
$mail->Username = 'reservations@studiobeve.no'; //SMTP username
|
||||
$mail->Password = 'StudioBeve-1234'; //SMTP password
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
|
||||
$mail->Port = 465; //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
|
||||
|
||||
//Recipients
|
||||
$mail->setFrom('reservations@studiobeve.no', '[studiobeve]');
|
||||
$mail->addAddress($addressListItem['addressee_email'], $addressListItem['addressee_name']); // Add a recipient
|
||||
//$mail->addAddress('ellen@example.com'); // Name is optional
|
||||
//$mail->addReplyTo('info@example.com', 'Information');
|
||||
//$mail->addCC('cc@example.com');
|
||||
//$mail->addBCC('bcc@example.com');
|
||||
|
||||
// Attachments
|
||||
if(is_array($addressListItem['attachments'])){
|
||||
$attachments = $addressListItem['attachments'];
|
||||
foreach($attachments as $attachmentsItem){
|
||||
$mail->addAttachment(getcwd().'/documents/'.$attachmentsItem); // Add attachments
|
||||
}
|
||||
}
|
||||
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
|
||||
|
||||
// Content
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
$mail->Subject = $addressListItem['subject'];
|
||||
ob_start();
|
||||
$body = ob_get_clean();
|
||||
$body .= $addressListItem['content'];
|
||||
|
||||
$mail->Body = $body;
|
||||
//$mail->AltBody = strip_tags($answer_message);
|
||||
|
||||
$mail->send();
|
||||
echo 'Üzenet elküldve';
|
||||
header('location:'.base_url().$lang.'/booking-finished/'.$subpage);
|
||||
} catch (Exception $e) {
|
||||
//header('location:'.base_url().'manage-applicants/?email-sent=false&error='.$mail->ErrorInfo);
|
||||
echo "Üzenetküldési hiba. Mailer Error: {$mail->ErrorInfo}";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Executable
+11
@@ -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