Skip to content

Commit 1d09f8b

Browse files
committed
2 parents e6914ad + ca4ff29 commit 1d09f8b

14 files changed

+295
-224
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"require": {
2323
"docusign/admin-client": "^1.1.0",
2424
"docusign/click-client": "^1.2.2",
25-
"docusign/esign-client": "^6.8.0",
26-
"docusign/rooms-client": "^2.0.0",
25+
"docusign/esign-client": "^6.13.0-rc",
26+
"docusign/rooms-client": "^2.1.0-rc",
2727
"docusign/monitor-client": "^1.1.0",
2828
"twig/twig": "^3.4.3",
2929
"league/oauth2-client": "^2.6.1",

composer.lock

Lines changed: 86 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Controllers/Examples/Rooms/EG006CreateExternalFormFillSession.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ function createController(): void
4040
$this->checkDsToken();
4141
$room_id = $this->args['room_id'];
4242
$form_id = $this->args['form_id'];
43-
43+
$this->args['x_frame_allowed_url'] = "http://localhost:8080";
44+
4445
if ($room_id && !$form_id) {
4546
$room = CreateExternalFormFillSessionService::getRoom(
4647
$room_id,
@@ -88,10 +89,14 @@ function ($f) {
8889
);
8990

9091
if ($createExternalFormResponse) {
91-
$createExternalFormResponse = json_decode((string)$createExternalFormResponse, true);
92+
$createExternalFormJSON = json_decode((string)$createExternalFormResponse, true);
93+
9294
$this->clientService->showDoneTemplateFromManifest(
9395
$this->codeExampleText,
94-
json_encode(json_encode($createExternalFormResponse))
96+
"",
97+
"Results from the Forms::CreateExternalFormFillSession: <br/><code>".stripslashes($createExternalFormResponse)."</code>",
98+
$createExternalFormJSON['url'],
99+
95100
);
96101
}
97102
}

src/Controllers/Examples/eSignature/EG008CreateTemplate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class EG008CreateTemplate extends eSignBaseController
1414
{
1515
const EG = 'eg008'; # reference (and URL) for this example
1616
const FILE = __FILE__;
17-
private string $template_name = 'Example Signer and CC template';
17+
private string $template_name = 'Example Signer and CC template v2';
1818

1919
/**
2020
* Create a new controller instance.

src/Services/Examples/eSignature/CreateTemplateService.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use DocuSign\eSign\Model\Document;
99
use DocuSign\eSign\Model\EnvelopeTemplate;
1010
use DocuSign\eSign\Model\ModelList;
11-
use DocuSign\eSign\Model\Number;
11+
use DocuSign\eSign\Model\Numerical;
1212
use DocuSign\eSign\Model\Radio;
1313
use DocuSign\eSign\Model\RadioGroup;
1414
use DocuSign\eSign\Model\Recipients;
@@ -138,15 +138,16 @@ public static function make_template_req($template_name, $demoDocsPath): Envelop
138138

139139
$list1 = CreateTemplateService::createListOfButtonOptions();
140140

141-
$number1 = new Number(
141+
$numerical = new Numerical(
142142
[
143143
'document_id' => "1",
144+
'validation_type' => "Currency",
144145
'page_number' => "1",
145146
'x_position' => "163",
146147
'y_position' => "260",
147148
'font' => "helvetica",
148149
'font_size' => "size14",
149-
'tab_label' => "numbersOnly",
150+
'tab_label' => "numericalCurrency",
150151
'width' => "84",
151152
'required' => "false"
152153
]
@@ -185,7 +186,7 @@ public static function make_template_req($template_name, $demoDocsPath): Envelop
185186
# The Tabs object wants arrays of the different field/tab types
186187
$signer->setTabs(new Tabs(['sign_here_tabs' => [$sign_here],
187188
'checkbox_tabs' => [$check1, $check2, $check3, $check4], 'list_tabs' => [$list1],
188-
'number_tabs' => [$number1], 'radio_group_tabs' => [$radio_group], 'text_tabs' => [$text]
189+
'numerical_tabs' => [$numerical], 'radio_group_tabs' => [$radio_group], 'text_tabs' => [$text]
189190
]));
190191

191192
# Template object:

src/Services/Examples/eSignature/SetTabValuesService.php

Lines changed: 130 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use DocuSign\eSign\Model\Tabs;
1212
use DocuSign\eSign\Model\Text;
1313
use DocuSign\eSign\Model\TextCustomField;
14+
use DocuSign\eSign\Model\Numerical;
15+
use DocuSign\eSign\Model\LocalePolicyTab;
1416

1517
class SetTabValuesService
1618
{
@@ -43,108 +45,132 @@ public static function setTabValues(array $args, $demoDocsPath, $clientService):
4345
* @param $demoDocsPath
4446
* @return mixed -- returns an envelope definition
4547
*/
46-
public static function make_envelope(array $args, $demoDocsPath): EnvelopeDefinition
47-
{
48-
# document 1 (pdf) has tags
49-
# /sn1/ - signature field
50-
# /salary/ - yearly salary
51-
# /legal/ - legal name
52-
# /familiar/ - person's familiar name
53-
#
54-
# The envelope has one recipient.
55-
# recipient 1 - signer
56-
#
57-
# The salary is set both as a readable number in the
58-
# /salary/ text field, and as a pure number in a
59-
# custom field ('salary') in the envelope.
60-
61-
# Salary that will be used.
62-
$salary = 123000;
63-
64-
# Read the file
65-
$doc_name = 'World_Wide_Corp_salary.docx';
66-
$content_bytes = file_get_contents($demoDocsPath . $doc_name);
67-
$base64_file_content = base64_encode($content_bytes);
68-
69-
# Create the document model
70-
$document = new Document([ # create the DocuSign document object
71-
'document_base64' => $base64_file_content,
72-
'name' => 'Salary action', # can be different from actual file name
73-
'file_extension' => 'docx', # many different document types are accepted
74-
'document_id' => 1 # a label used to reference the doc
75-
]);
76-
77-
# Create the signer recipient model
78-
$signer = new Signer([ # The signer
79-
'email' => $args['signer_email'], 'name' => $args['signer_name'],
80-
'recipient_id' => "1", 'routing_order' => "1",
81-
# Setting the client_user_id marks the signer as embedded
82-
'client_user_id' => $args['signer_client_id']
83-
]);
84-
85-
# Create a sign_here tab (field on the document)
86-
$sign_here = new SignHere([ # DocuSign SignHere field/tab
87-
'anchor_string' => '/sn1/', 'anchor_units' => 'pixels',
88-
'anchor_y_offset' => '10', 'anchor_x_offset' => '20'
89-
]);
90-
91-
# Create the legal and familiar text fields.
92-
# Recipients can update these values if they wish to.
93-
$text_legal = new Text([
94-
'anchor_string' => '/legal/', 'anchor_units' => 'pixels',
95-
'anchor_y_offset' => '-9', 'anchor_x_offset' => '5',
96-
'font' => "helvetica", 'font_size' => "size11",
97-
'bold' => 'true', 'value' => $args['signer_name'],
98-
'locked' => 'false', 'tab_id' => 'legal_name',
99-
'tab_label' => 'Legal name']);
100-
$text_familiar = new Text([
101-
'anchor_string' => '/familiar/', 'anchor_units' => 'pixels',
102-
'anchor_y_offset' => '-9', 'anchor_x_offset' => '5',
103-
'font' => "helvetica", 'font_size' => "size11",
104-
'bold' => 'true', 'value' => $args['signer_name'],
105-
'locked' => 'false', 'tab_id' => 'familiar_name',
106-
'tab_label' => 'Familiar name']);
107-
108-
# Create the salary field. It should be human readable, so
109-
# add a comma before the thousands number, a currency indicator, etc.
110-
$salary_readable = '$' . number_format($salary);
111-
$text_salary = new Text([
112-
'anchor_string' => '/salary/', 'anchor_units' => 'pixels',
113-
'anchor_y_offset' => '-9', 'anchor_x_offset' => '5',
114-
'font' => "helvetica", 'font_size' => "size11",
115-
'bold' => 'true', 'value' => $salary_readable,
116-
'locked' => 'true', # mark the field as readonly
117-
'tab_id' => 'salary', 'tab_label' => 'Salary'
118-
]);
119-
120-
# Add the tabs model (including the sign_here tab) to the signer
121-
# The Tabs object wants arrays of the different field/tab types
122-
$signer->settabs(new Tabs(
123-
['sign_here_tabs' => [$sign_here],
124-
'text_tabs' => [$text_legal,
125-
$text_familiar,
126-
$text_salary]]
127-
));
128-
129-
# Create an envelope custom field to save the "real" (numeric)
130-
# version of the salary
131-
$salary_custom_field = new TextCustomField([
132-
'name' => 'salary',
133-
'required' => 'false',
134-
'show' => 'true', # Yes, include in the CoC
135-
'value' => $salary]);
136-
$custom_fields = new CustomFields([
137-
'text_custom_fields' => [$salary_custom_field]]);
138-
139-
# Next, create the top level envelope definition and populate it.
140-
return new EnvelopeDefinition([
141-
'email_subject' => "Please sign this document sent from the PHP SDK",
142-
'documents' => [$document],
143-
# The Recipients object wants arrays for each recipient type
144-
'recipients' => new Recipients(['signers' => [$signer]]),
145-
'status' => "sent", # requests that the envelope be created and sent.
146-
'custom_fields' => $custom_fields
147-
]);
148-
}
149-
# ***DS.snippet.0.end
48+
49+
# Step 4 start
50+
public static function make_envelope(array $args, $demoDocsPath): EnvelopeDefinition
51+
{
52+
# document 1 (pdf) has tags
53+
# /sn1/ - signature field
54+
# /salary/ - yearly salary
55+
# /legal/ - legal name
56+
# /familiar/ - person's familiar name
57+
#
58+
# The envelope has one recipient.
59+
# recipient 1 - signer
60+
#
61+
# The salary is set both as a readable number in the
62+
# /salary/ text field, and as a pure number in a
63+
# custom field ('salary') in the envelope.
64+
65+
66+
# Read the file
67+
$doc_name = 'World_Wide_Corp_salary.docx';
68+
$content_bytes = file_get_contents($demoDocsPath . $doc_name);
69+
$base64_file_content = base64_encode($content_bytes);
70+
71+
# Step 3 start
72+
# Create the document model
73+
$document = new Document([ # create the DocuSign document object
74+
'document_base64' => $base64_file_content,
75+
'name' => 'Salary action', # can be different from actual file name
76+
'file_extension' => 'docx', # many different document types are accepted
77+
'document_id' => 1 # a label used to reference the doc
78+
]);
79+
80+
# Create the signer recipient model
81+
$signer = new Signer([ # The signer
82+
'email' => $args['signer_email'], 'name' => $args['signer_name'],
83+
'recipient_id' => "1", 'routing_order' => "1",
84+
# Setting the client_user_id marks the signer as embedded
85+
'client_user_id' => $args['signer_client_id']
86+
]);
87+
88+
# Create a sign_here tab (field on the document)
89+
$sign_here = new SignHere([ # DocuSign SignHere field/tab
90+
'anchor_string' => '/sn1/', 'anchor_units' => 'pixels',
91+
'anchor_y_offset' => '10', 'anchor_x_offset' => '20'
92+
]);
93+
94+
# Create the legal and familiar text fields.
95+
# Recipients can update these values if they wish to.
96+
$text_legal = new Text([
97+
'anchor_string' => '/legal/', 'anchor_units' => 'pixels',
98+
'anchor_x_offset' => '5',
99+
'anchor_y_offset' => '-6',
100+
'font' => "helvetica", 'font_size' => "size11",
101+
'bold' => 'true', 'value' => $args['signer_name'],
102+
'locked' => 'false', 'tab_id' => 'legal_name',
103+
'tab_label' => 'Legal name']);
104+
$text_familiar = new Text([
105+
'anchor_string' => '/familiar/', 'anchor_units' => 'pixels',
106+
'anchor_y_offset' => '-6', 'anchor_x_offset' => '5',
107+
'font' => "helvetica", 'font_size' => "size11",
108+
'bold' => 'true', 'value' => $args['signer_name'],
109+
'locked' => 'false', 'tab_id' => 'familiar_name',
110+
'tab_label' => 'Familiar name']);
111+
112+
113+
114+
# Create the salary field. It should be human readable, so
115+
# add a comma before the thousands number, a currency indicator, etc.
116+
$salary = 123000;
117+
118+
$locale_policy_tab = new LocalePolicyTab([
119+
"culture_name" => "en-US",
120+
"currency_code" => "usd",
121+
"currency_positive_format" => "csym_1_comma_234_comma_567_period_89",
122+
"currency_negative_format" => "minus_csym_1_comma_234_comma_567_period_89",
123+
"use_long_currency_format" => "true"
124+
]);
125+
126+
$numerical_salary = new Numerical([
127+
'page_number' => '1',
128+
'document_id' => '1',
129+
'x_position' => '210',
130+
'y_position' => '233',
131+
'height' => "20",
132+
'width' => "70",
133+
'min_numerical_value' => "0",
134+
'max_numerical_value' => "1000000",
135+
'validation_type' => 'Currency',
136+
'font' => "helvetica", 'font_size' => "size11",
137+
'bold' => 'true',
138+
'tab_id' => 'salary', 'tab_label' => 'Salary',
139+
'numerical_value' => strval($salary),
140+
'locale_policy' => $locale_policy_tab
141+
]);
142+
143+
144+
145+
146+
# Add the tabs model (including the sign_here tab) to the signer
147+
# The Tabs object wants arrays of the different field/tab types
148+
$signer->settabs(new Tabs(
149+
['sign_here_tabs' => [$sign_here],
150+
'text_tabs' => [$text_legal, $text_familiar],
151+
'numerical_tabs'=>[$numerical_salary]]
152+
));
153+
154+
# Create an envelope custom field to save the "real" (numeric)
155+
# version of the salary
156+
$salary_custom_field = new TextCustomField([
157+
'name' => 'salary',
158+
'required' => 'false',
159+
'show' => 'true', # Yes, include in the CoC
160+
'value' => strval($salary)]);
161+
$custom_fields = new CustomFields([
162+
'text_custom_fields' => [$salary_custom_field]]);
163+
164+
# Step 3 end
165+
# Next, create the top level envelope definition and populate it.
166+
return new EnvelopeDefinition([
167+
'email_subject' => "Please sign this document sent from the PHP SDK",
168+
'documents' => [$document],
169+
# The Recipients object wants arrays for each recipient type
170+
'recipients' => new Recipients(['signers' => [$signer]]),
171+
'status' => "sent", # requests that the envelope be created and sent.
172+
'custom_fields' => $custom_fields
173+
]);
174+
}
175+
# Step 4 end
150176
}

src/Services/RoomsApiClientService.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ public function needToReAuth($eg): void
8686
* @param $message string
8787
* @return void
8888
*/
89-
public function showDoneTemplateFromManifest(array $codeExampleText, $results = null, string $message = null): void
89+
public function showDoneTemplateFromManifest(array $codeExampleText, $results = null, string $message = null, $url = null): void
9090
{
91+
92+
9193
if ($message == null) {
9294
$message = $codeExampleText["ResultsPageText"];
9395
}
@@ -96,6 +98,7 @@ public function showDoneTemplateFromManifest(array $codeExampleText, $results =
9698
'title' => $codeExampleText["ExampleName"],
9799
'h1' => $codeExampleText["ExampleName"],
98100
'message' => $message,
101+
'url' => $url,
99102
'json' => $results,
100103
'common_texts' => ManifestService::getCommonTexts()
101104
]);

src/Services/RouterService.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ class RouterService implements IRouterService
182182
*/
183183
public function __construct()
184184
{
185+
if(!isset($_SESSION['api_type'])){
186+
// first time loading server and session is null causes problems for manifestService
187+
$_SESSION['api_type'] = "eSign";
188+
}
189+
185190
// To ignore the Notice instead of Isset on missing POST vars
186191
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED);
187192

templates/esignature/eg015_envelope_tab_data.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h4>{{ code_example_text['ExampleName'] | raw }}</h4>
3838
</p>
3939

4040
{% if envelope_ok %}
41-
<p>T{{ code_example_text['Forms'][formNumber]['FormName'] | raw }}</p>
41+
<p>{{ code_example_text['Forms'][formNumber]['FormName'] | raw }}</p>
4242

4343
<form class="eg" action="" method="post" data-busy="form">
4444
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>

templates/esignature/eg017_set_template_tab_values.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{% extends "base.html" %} {% block content %}
22

33
{% set formNumber = 0 %}
4-
{% set signerEmailInputNumber = 0 %}
5-
{% set signerNameInputNumber = 1 %}
6-
{% set ccEmailInputNumber = 2 %}
7-
{% set ccNameInputNumber = 3 %}
4+
{% set signerEmailInputNumber = 1 %}
5+
{% set signerNameInputNumber = 0 %}
6+
{% set ccEmailInputNumber = 3 %}
7+
{% set ccNameInputNumber = 2 %}
88
{% set redirectToEightCodeExample = "href='" ~ app_url ~ "index.php?page=eg008'" %}
99
{% set redirectNumber = 0 %}
1010

0 commit comments

Comments
 (0)