Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
piphone-front
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
piphone
piphone-front
Commits
54a04408
Commit
54a04408
authored
Jan 09, 2017
by
okhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slighty better feedback form
parent
eec240d6
Pipeline
#728
failed with stage
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
38 deletions
+38
-38
app/Api.php
app/Api.php
+6
-6
app/Main.php
app/Main.php
+28
-25
app/config.ini
app/config.ini
+0
-1
templates/feedbackform.html
templates/feedbackform.html
+4
-6
No files found.
app/Api.php
View file @
54a04408
...
...
@@ -11,15 +11,15 @@ class Api {
$client
=
new
Client
([
'base_uri'
=>
API_BASE
,
'defaults'
=>
[
'headers'
=>
[
'Content-type'
=>
'applications/json'
]]]);
$url
=
API_BASE
.
$url
.
"/?format=json"
;
$result
=
$client
->
request
(
'GET'
,
$url
);
return
$result
->
getBody
();
$result
=
$client
->
request
(
'GET'
,
$url
);
return
$result
->
getBody
();
}
// Generic post function for REST API
static
function
post
(
$url
,
$data
)
{
$client
=
new
Client
([
'base_uri'
=>
API_BASE
,
'defaults'
=>
[
'headers'
=>
[
'Content-type'
=>
'applications/json'
]]]);
$url
=
API_BASE
.
$url
.
"/?format=json"
;
$result
=
$client
->
request
(
'POST'
,
$url
,
array
(),
$data
);
$result
=
$client
->
request
(
'POST'
,
$url
,
array
(),
$data
);
return
$result
->
getBody
();
}
...
...
@@ -37,8 +37,8 @@ class Api {
// Asking for a single contact
static
function
get_contact
(
$id
)
{
$json
=
Api
::
get
(
"campaigns/"
.
CAMPAIGN_ID
.
"/contacts/"
.
$id
);
return
json_decode
(
$json
,
true
);
$json
=
Api
::
get
(
"campaigns/"
.
CAMPAIGN_ID
.
"/contacts/"
.
$id
);
return
json_decode
(
$json
,
true
);
}
// Asking for complete list of groups
...
...
@@ -49,7 +49,7 @@ class Api {
// Asking for complete list of feedback categories
static
function
get_feedback_categories
()
{
$json
=
Api
::
get
(
"campaigns/"
.
CAMPAIGN_ID
.
"/
feedback/
categories"
);
$json
=
Api
::
get
(
"campaigns/"
.
CAMPAIGN_ID
.
"/categories"
);
return
json_decode
(
$json
,
true
);
}
...
...
app/Main.php
View file @
54a04408
...
...
@@ -18,7 +18,7 @@ class Main extends Controller {
$contacts
=
$f3
->
get
(
'contacts'
);
$f3
->
set
(
'contact'
,
$contacts
[
$rand_id
]);
$f3
->
set
(
'random'
,
rand
(
0
,
2
));
$f3
->
set
(
'block_content'
,
'home.html'
);
$f3
->
set
(
'block_content'
,
'home.html'
);
}
/*
...
...
@@ -31,11 +31,14 @@ class Main extends Controller {
//GET
if
(
$f3
->
get
(
'VERB'
)
==
'GET'
){
$categories
=
Api
::
get_feedback_categories
();
$f3
->
set
(
'feedback_categories'
,
$categories
[
'categories'
]
);
$f3
->
set
(
'feedback_categories'
,
$categories
);
$contact_id
=
$f3
->
get
(
'POST.contact_id'
);
$f3
->
set
(
"contact_id"
,
$contact_id
);
$arguments
=
Api
::
get_arguments
();
$f3
->
set
(
'arguments'
,
$arguments
);
$f3
->
set
(
'block_content'
,
'feedbackform.html'
);
}
//POST
...
...
@@ -74,29 +77,29 @@ class Main extends Controller {
// Create the call
// Generate a jwt token
$token
=
JWT
::
encode
(
array
(
'api'
=>
JWT_TOKEN
),
JWT_KEY
);
// To get the callee, we have the callee_id in the form. Using that
// to load the callee and retrieve its number.
$contact
=
Api
::
get_contact
(
$args
[
'id'
]);
$f3
->
set
(
'contact'
,
$contact
);
$data
=
array
(
'api'
=>
'piphone'
,
'caller'
=>
$f3
->
get
(
'POST.phone'
),
'callee'
=>
$contact
[
'phone'
],
'token'
=>
$token
);
// We want to generate a UNIQUE-ID (doesn't need to be cryptogaphically unique though
$call_id
=
uniqid
();
$f3
->
set
(
'CALL_ID'
,
$call_id
);
// Create the call
$client
=
new
GuzzleHttp\Client
([
'base_uri'
=>
SIP_API
]);
try
{
$res
=
$client
->
post
(
"calls/
$call_id
"
,
[
'query'
=>
$data
]);
$f3
->
set
(
'call'
,
json_decode
(
$res
->
getBody
()));
$f3
->
set
(
'VERB'
,
'GET'
);
$this
->
feedbackform
(
$f3
,
$args
);
}
catch
(
RequestException
$e
)
{
echo
Psr7\str
(
$e
->
getRequest
());
if
(
$e
->
hasResponse
())
{
echo
Psr7\str
(
$e
->
getResponse
());
}
}
}
// To get the callee, we have the callee_id in the form. Using that
// to load the callee and retrieve its number.
$contact
=
Api
::
get_contact
(
$args
[
'id'
]);
$f3
->
set
(
'contact'
,
$contact
);
$data
=
array
(
'api'
=>
'piphone'
,
'caller'
=>
$f3
->
get
(
'POST.phone'
),
'callee'
=>
$contact
[
'phone'
],
'token'
=>
$token
);
// We want to generate a UNIQUE-ID (doesn't need to be cryptogaphically unique though
$call_id
=
uniqid
();
$f3
->
set
(
'CALL_ID'
,
$call_id
);
// Create the call
$client
=
new
GuzzleHttp\Client
([
'base_uri'
=>
SIP_API
]);
try
{
$res
=
$client
->
post
(
"calls/
$call_id
"
,
[
'query'
=>
$data
]);
$f3
->
set
(
'call'
,
json_decode
(
$res
->
getBody
()));
$f3
->
set
(
'VERB'
,
'GET'
);
$this
->
feedbackform
(
$f3
,
$args
);
}
catch
(
RequestException
$e
)
{
echo
Psr7\str
(
$e
->
getRequest
());
if
(
$e
->
hasResponse
())
{
echo
Psr7\str
(
$e
->
getResponse
());
}
}
}
}
function
contactslist
(
$f3
,
$args
)
{
...
...
app/config.ini
View file @
54a04408
...
...
@@ -15,4 +15,3 @@ DEBUG=3
LANGUAGE
=
'fr'
; Global variables of website
templates/feedbackform.html
View file @
54a04408
<h2>
{{ _("Sale Form") }}
</h2>
<!-- Add here the Sale form your campaign -->
<p>
{{ _("Here is some argument in order to help you talking with your interlocutor.") }}
</p>
<h2>
{{ _(@campaign.title) }}
</h2>
<include
href=
"argumentation.html"
>
<h2>
{{ _("Feedback Form") }}
</h2>
...
...
@@ -13,8 +11,8 @@
<input
type=
"text"
id=
"contact_id"
name=
"contact_id"
hidden=
"hidden"
value=
"{{ @contact_id }}"
/>
<repeat
group=
"{{ @feedback_categories }}"
value=
"{{ @feedback_category }}"
>
<input
type=
"radio"
name=
"feedback_category"
value=
"{{ @feedback_category }}"
/>
{{ @feedback_category }}
<input
type=
"radio"
name=
"feedback_category"
value=
"{{ @feedback_category
.id
}}"
/>
{{ @feedback_category
.name
}}
</repeat>
<p>
<textarea
id=
"feedback"
name=
"feedback"
></textarea>
...
...
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