Skip to content

Commit 03a9ebe

Browse files
AaronWDSdependabot[bot]InbarGazit
authored
Devdocs 9573 - Update Numerical Tab on Ex 08 and Ex 16 (#100)
* Bump twig/twig from 3.3.8 to 3.4.3 in /Quick_ACG Bumps [twig/twig](https://github.com/twigphp/Twig) from 3.3.8 to 3.4.3. - [Release notes](https://github.com/twigphp/Twig/releases) - [Changelog](https://github.com/twigphp/Twig/blob/3.x/CHANGELOG) - [Commits](twigphp/Twig@v3.3.8...v3.4.3) --- updated-dependencies: - dependency-name: twig/twig dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * Bump twig/twig from 3.3.8 to 3.4.3 Bumps [twig/twig](https://github.com/twigphp/Twig) from 3.3.8 to 3.4.3. - [Release notes](https://github.com/twigphp/Twig/releases) - [Changelog](https://github.com/twigphp/Twig/blob/3.x/CHANGELOG) - [Commits](twigphp/Twig@v3.3.8...v3.4.3) --- updated-dependencies: - dependency-name: twig/twig dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * README.md updates * explicit routing handler for eg001 for QuickACG * checking in * update unit test to match new spec * fixed unit tests (for sure this time) * remove T & small (alignment changes) * small cleanup ui changes to ex 16 * 🚫 readonly & move fields 👆 slightly on ex 16 * gist step markers * change unit test value to edit (like real example) * more fixing * change anchoring on test to match --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Inbar Gazit <[email protected]>
1 parent 747a85f commit 03a9ebe

File tree

9 files changed

+258
-203
lines changed

9 files changed

+258
-203
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require": {
2323
"docusign/admin-client": "^1.1.0",
2424
"docusign/click-client": "^1.2.2",
25-
"docusign/esign-client": "^6.8.0",
25+
"docusign/esign-client": "^6.13.0-rc",
2626
"docusign/rooms-client": "^2.0.0",
2727
"docusign/monitor-client": "^1.1.0",
2828
"twig/twig": "^3.4.3",

composer.lock

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

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
}

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

tests/eSignature/CreateTemplateTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use DocuSign\eSign\Model\EnvelopeTemplate;
99
use DocuSign\eSign\Model\ModelList;
1010
use DocuSign\eSign\Model\Number;
11+
use DocuSign\eSign\Model\Numerical;
1112
use DocuSign\eSign\Model\Radio;
1213
use DocuSign\eSign\Model\RadioGroup;
1314
use DocuSign\eSign\Model\Recipients;
@@ -125,14 +126,15 @@ public function testMakeTemplateRequest__CorrectInputValues_ReturnEnvelopeDefini
125126

126127
$listOfButtonOptions = CreateTemplateService::createListOfButtonOptions();
127128

128-
$number = new Number([
129+
$numerical = new Numerical([
129130
'document_id' => $defaultIdOne,
130131
'page_number' => $defaultIdOne,
132+
'validation_type' => "Currency",
131133
'x_position' => "163",
132134
'y_position' => "260",
133135
'font' => "helvetica",
134136
'font_size' => "size14",
135-
'tab_label' => "numbersOnly",
137+
'tab_label' => "numericalCurrency",
136138
'width' => "84",
137139
'required' => $falseString
138140
]);
@@ -171,7 +173,7 @@ public function testMakeTemplateRequest__CorrectInputValues_ReturnEnvelopeDefini
171173
'sign_here_tabs' => [$signHere],
172174
'checkbox_tabs' => [$check1, $check2, $check3, $check4],
173175
'list_tabs' => [$listOfButtonOptions],
174-
'number_tabs' => [$number],
176+
'numerical_tabs' => [$numerical],
175177
'radio_group_tabs' => [$radioGroup],
176178
'text_tabs' => [$text]
177179
]));

0 commit comments

Comments
 (0)