-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathContract.php
More file actions
131 lines (100 loc) · 3.64 KB
/
Copy pathContract.php
File metadata and controls
131 lines (100 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
/**
* Copyright 2014 Openstack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
class Contract extends DataObject {
static $db = array(
'ContractSigned' => 'Boolean',
'ContractStart' => 'Date',
'ContractEnd' => 'Date',
'EchosignID' => 'Text',
'Status' => 'Text'
);
static $has_one = array(
'Company' => 'Company',
'ContractTemplate' => 'ContractTemplate',
);
public function getTitle(){
return "Training Contract - ".$this->Company()->Name." - From ".$this->ContractStart." To ".$this->ContractEnd;
}
public static $summary_fields = array(
'Company.Name',
'ContractTemplate.Name'
);
public function getCMSFields()
{
$fields = new FieldList();
$fields->push(new CheckboxField("ContractSigned","Contract Signed"));
$contract_start = new DateField("ContractStart", "Contract Start");
$fields->push(new TextField("EchosignID","Echosign ID"));
$contract_start->setConfig('showcalendar', true);
$fields->push($contract_start);
$contract_end = new DateField("ContractEnd", "Contract End");
$contract_end->setConfig('showcalendar', true);
$fields->push($contract_end);
$companies = Company::get();
if($companies){
$fields->push(new DropdownField(
'CompanyID',
'Company',
$companies->map("ID", "Name", "Please Select a Company")));
}
$templates = ContractTemplate::get();
if($templates){
$fields->push(new DropdownField(
'ContractTemplate',
'Template',
$templates->map("ID", "Name", "Please Select a Contract Template")));
}
return $fields;
}
function getCMSValidator()
{
return $this->getValidator();
}
function getValidator()
{
$validator = new RequiredFields(array('ContractStart','ContractEnd'));
return $validator;
}
/**
* Override
*/
function onAfterWrite(){
parent::onAfterWrite();
$this->updateStartAndEndDates();
}
/**
* update ContractStart and Contract End date based on signed date
* and contract template duration
*/
private function updateStartAndEndDates(){
}
}
class Contract_Controller extends Page_Controller{
static $allowed_actions = array(
'UpdateStatus'
);
public function UpdateStatus(){
$contract = DataObject::get_one('Contract','ID = ' . $_GET['id'] . " and EchosignID = '" . $_GET['documentKey'] . "'");
$contract->Status = $_GET['status'];
$contract->write();
mail('patriciotarantino@gmail.com','Contract Update' . $contract->EchosignID, json_encode($_GET) );
die();
$ESLoader = new SplClassLoader('EchoSign', realpath(__DIR__.'/../../'));
$ESLoader->register();
$client = new SoapClient(EchoSign\API::getWSDL());
$api = new EchoSign\API($client, 'PGRUY64K6T664Z');
$data = $api->getDocumentInfo($contract->EchosignID);
mail('patriciotarantino@gmail.com','Contract Update' . $contract->EchosignID, json_encode($data) );
}
}