Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TimeOutAdmin
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TimeOut
TimeOutAdmin
Commits
657ea2d1
Commit
657ea2d1
authored
Nov 19, 2019
by
Jansa Jose
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
J: push notification
parent
5ad225e0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
Organizer_model.php
application/models/Organizer_model.php
+29
-0
Validation_organizer_model.php
application/models/Validation_organizer_model.php
+12
-0
No files found.
application/models/Organizer_model.php
View file @
657ea2d1
...
@@ -475,6 +475,7 @@ class Organizer_model extends CI_Model {
...
@@ -475,6 +475,7 @@ class Organizer_model extends CI_Model {
$sql
=
$this
->
db
->
query
(
"SELECT * FROM checker WHERE username='"
.
$data
[
'email_id'
]
.
"' AND password='"
.
md5
(
$data
[
'password'
])
.
"' AND status='1'"
);
$sql
=
$this
->
db
->
query
(
"SELECT * FROM checker WHERE username='"
.
$data
[
'email_id'
]
.
"' AND password='"
.
md5
(
$data
[
'password'
])
.
"' AND status='1'"
);
}
}
if
(
empty
(
$sql
)
||
empty
(
$custData
=
$sql
->
row_array
())){
if
(
empty
(
$sql
)
||
empty
(
$custData
=
$sql
->
row_array
())){
$this
->
db
->
update
(
'provider'
,
array
(
'fcm_token'
=>
$data
[
'fcm_token'
]),
array
(
'provider_id'
=>
$custData
[
'id'
]));
$res
=
array
(
'status'
=>
0
,
'message'
=>
'User Does not Exist'
,
'code'
=>
'ER09'
);
$res
=
array
(
'status'
=>
0
,
'message'
=>
'User Does not Exist'
,
'code'
=>
'ER09'
);
return
$res
;
return
$res
;
}
}
...
@@ -1119,12 +1120,40 @@ class Organizer_model extends CI_Model {
...
@@ -1119,12 +1120,40 @@ class Organizer_model extends CI_Model {
public
function
acceptBooking
(
$data
){
public
function
acceptBooking
(
$data
){
$res
=
array
(
'status'
=>
0
,
'message'
=>
'Ohh No!! Something Went South'
,
'code'
=>
'ER06'
);
$res
=
array
(
'status'
=>
0
,
'message'
=>
'Ohh No!! Something Went South'
,
'code'
=>
'ER06'
);
try
{
try
{
$sql
=
"SELECT fcm_token FROM booking INNER JOIN customer ON customer.customer_id = booking.customer_id WHERE bookId='"
.
$data
[
'booking_id'
]
.
"'"
;
$bData
=
$this
->
db
->
query
(
$sql
)
->
row_array
();
$this
->
db
->
update
(
'booking'
,
array
(
'status'
=>
'1'
),
array
(
'bookId'
=>
$data
[
'booking_id'
]));
$this
->
db
->
update
(
'booking'
,
array
(
'status'
=>
'1'
),
array
(
'bookId'
=>
$data
[
'booking_id'
]));
$userData
=
array
(
'id'
=>
$data
[
'booking_id'
],
'title'
=>
'Booking Approved'
,
'message'
=>
'Your Booking is Approved by the Event Provider'
);
$this
->
push_sent_cancel
(
$bData
[
'fcm_token'
],
$userData
);
$res
=
array
(
'status'
=>
1
,
'message'
=>
'Booking Accepted Successfully'
);
$res
=
array
(
'status'
=>
1
,
'message'
=>
'Booking Accepted Successfully'
);
}
catch
(
Exception
$e
){
}
catch
(
Exception
$e
){
$res
=
array
(
'status'
=>
0
,
'message'
=>
'Ohh No!! Something Went South'
,
'code'
=>
'ER06'
);
$res
=
array
(
'status'
=>
0
,
'message'
=>
'Ohh No!! Something Went South'
,
'code'
=>
'ER06'
);
}
}
return
$res
;
return
$res
;
}
}
function
push_sent_cancel
(
$fcm_token
=
''
,
$fcm_data
=
array
())
{
$settings
=
getSettings
();
$key
=
$settings
[
'app_id'
];
if
(
empty
(
$key
)
||
empty
(
$fcm_token
)
||
empty
(
$fcm_data
)){
return
;
}
$data
=
"{
\"
notification
\"
: {
\"
title
\"
:
\"
"
.
$fcm_data
[
'title'
]
.
"
\"
,
\"
text
\"
:
\"
"
.
$fcm_data
[
'message'
]
.
"
\"
,
\"
sound
\"
:
\"
default
\"
},
\"
time_to_live
\"
: 60,
\"
data
\"
: {\"
response
\
" : {\"
status
\
" :
\"
success
\"
,
\"
data
\"
: {\"
booking_id
\
" :
\"
"
.
$fcm_data
[
'id'
]
.
"
\"
,
\"
trip_status
\"
: 0}}},
\"
collapse_key
\"
:
\"
trip
\"
,
\"
priority
\"
:
\"
high
\"
,
\"
to
\"
:
\"
"
.
$fcm_token
.
"
\"
}"
;
$ch
=
curl_init
(
"https://fcm.googleapis.com/fcm/send"
);
$header
=
array
(
'Content-Type: application/json'
,
'Authorization: key='
.
$key
);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
$header
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$data
);
$out
=
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_exec
(
$ch
);
curl_close
(
$ch
);
}
}
}
?>
?>
application/models/Validation_organizer_model.php
View file @
657ea2d1
...
@@ -152,6 +152,12 @@ class Validation_organizer_model extends CI_Model {
...
@@ -152,6 +152,12 @@ class Validation_organizer_model extends CI_Model {
'message'
=>
'User Type is null or empty'
'message'
=>
'User Type is null or empty'
)
)
),
),
'fcm_token'
=>
array
(
'required'
=>
array
(
'code'
=>
'ER18'
,
'message'
=>
'FCM Token is null or empty'
)
),
),
),
'changePassword'
=>
array
(
'changePassword'
=>
array
(
'new_password'
=>
array
(
'new_password'
=>
array
(
...
@@ -399,6 +405,12 @@ class Validation_organizer_model extends CI_Model {
...
@@ -399,6 +405,12 @@ class Validation_organizer_model extends CI_Model {
'code'
=>
'ER04'
,
'code'
=>
'ER04'
,
'message'
=>
'Booking Id is null or empty'
'message'
=>
'Booking Id is null or empty'
)
)
),
'organiser_id'
=>
array
(
'required'
=>
array
(
'code'
=>
'ER04'
,
'message'
=>
'Organizer Id is null or empty'
)
)
)
)
)
);
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment