forked from edwardjrp/license_manager
/
users_reassignuser_content_events.php
executable file
·197 lines (166 loc) · 7.34 KB
/
users_reassignuser_content_events.php
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php
// //Events @1-F81417CB
//users_reassignuser_content_alm_customers_alm_customers_TotalRecords_BeforeShow @13-42D6738D
function users_reassignuser_content_alm_customers_alm_customers_TotalRecords_BeforeShow(& $sender)
{
$users_reassignuser_content_alm_customers_alm_customers_TotalRecords_BeforeShow = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $users_reassignuser_content; //Compatibility
//End users_reassignuser_content_alm_customers_alm_customers_TotalRecords_BeforeShow
//Retrieve number of records @14-ABE656B4
$Component->SetValue($Container->DataSource->RecordsCount);
//End Retrieve number of records
//Close users_reassignuser_content_alm_customers_alm_customers_TotalRecords_BeforeShow @13-743AE69B
return $users_reassignuser_content_alm_customers_alm_customers_TotalRecords_BeforeShow;
}
//End Close users_reassignuser_content_alm_customers_alm_customers_TotalRecords_BeforeShow
//users_reassignuser_content_alm_customers_custid_BeforeShow @21-F3A771C8
function users_reassignuser_content_alm_customers_custid_BeforeShow(& $sender)
{
$users_reassignuser_content_alm_customers_custid_BeforeShow = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $users_reassignuser_content; //Compatibility
//End users_reassignuser_content_alm_customers_custid_BeforeShow
//DLookup @22-1046A5AB
global $DBdbConnection;
$Page = CCGetParentPage($sender);
$ccs_result = CCDLookUp("contact", "alm_customers_contacts", "customer_id =".$sender->GetValue()." and maincontact = 1 limit 1", $Page->Connections["dbConnection"]);
$Component->SetValue($ccs_result);
//End DLookup
//Close users_reassignuser_content_alm_customers_custid_BeforeShow @21-D66CC7DE
return $users_reassignuser_content_alm_customers_custid_BeforeShow;
}
//End Close users_reassignuser_content_alm_customers_custid_BeforeShow
//users_reassignuser_content_alm_customers_assigned_to_BeforeShow @23-BD0C711A
function users_reassignuser_content_alm_customers_assigned_to_BeforeShow(& $sender)
{
$users_reassignuser_content_alm_customers_assigned_to_BeforeShow = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $users_reassignuser_content; //Compatibility
//End users_reassignuser_content_alm_customers_assigned_to_BeforeShow
//DLookup @24-6B2D8B96
global $DBdbConnection;
$Page = CCGetParentPage($sender);
$ccs_result = CCDLookUp("fullname", "alm_users", "id = ".$sender->GetValue(), $Page->Connections["dbConnection"]);
$Component->SetValue($ccs_result);
//End DLookup
//Close users_reassignuser_content_alm_customers_assigned_to_BeforeShow @23-F6BDA0B7
return $users_reassignuser_content_alm_customers_assigned_to_BeforeShow;
}
//End Close users_reassignuser_content_alm_customers_assigned_to_BeforeShow
//users_reassignuser_content_alm_customers_city_BeforeShow @25-CBC8282E
function users_reassignuser_content_alm_customers_city_BeforeShow(& $sender)
{
$users_reassignuser_content_alm_customers_city_BeforeShow = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $users_reassignuser_content; //Compatibility
//End users_reassignuser_content_alm_customers_city_BeforeShow
//DLookup @26-F591DF25
global $DBdbConnection;
$Page = CCGetParentPage($sender);
$ccs_result = CCDLookUp("city", "alm_city", "id = ".$sender->getValue(), $Page->Connections["dbConnection"]);
$Component->SetValue($ccs_result);
//End DLookup
//Close users_reassignuser_content_alm_customers_city_BeforeShow @25-0EB4FE56
return $users_reassignuser_content_alm_customers_city_BeforeShow;
}
//End Close users_reassignuser_content_alm_customers_city_BeforeShow
//users_reassignuser_content_alm_customers_BeforeShowRow @12-F803F575
function users_reassignuser_content_alm_customers_BeforeShowRow(& $sender)
{
$users_reassignuser_content_alm_customers_BeforeShowRow = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $users_reassignuser_content; //Compatibility
//End users_reassignuser_content_alm_customers_BeforeShowRow
//Set Row Style @32-982C9472
$styles = array("Row", "AltRow");
if (count($styles)) {
$Style = $styles[($Component->RowNumber - 1) % count($styles)];
if (strlen($Style) && !strpos($Style, "="))
$Style = (strpos($Style, ":") ? 'style="' : 'class="'). $Style . '"';
$Component->Attributes->SetValue("rowStyle", $Style);
}
//End Set Row Style
//Close users_reassignuser_content_alm_customers_BeforeShowRow @12-F7248F78
return $users_reassignuser_content_alm_customers_BeforeShowRow;
}
//End Close users_reassignuser_content_alm_customers_BeforeShowRow
//users_reassignuser_content_alm_customers_ds_BeforeExecuteSelect @12-1A5B2A5E
function users_reassignuser_content_alm_customers_ds_BeforeExecuteSelect(& $sender)
{
$users_reassignuser_content_alm_customers_ds_BeforeExecuteSelect = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $users_reassignuser_content; //Compatibility
//End users_reassignuser_content_alm_customers_ds_BeforeExecuteSelect
//Custom Code @54-2A29BDB7
// -------------------------
// Write your own code here.
$where = trim($users_reassignuser_content->alm_customers->ds->Where);
if (strlen($where) <= 0)
$users_reassignuser_content->alm_customers->ds->Where = "assigned_to = 1";
// -------------------------
//End Custom Code
//Close users_reassignuser_content_alm_customers_ds_BeforeExecuteSelect @12-7E015016
return $users_reassignuser_content_alm_customers_ds_BeforeExecuteSelect;
}
//End Close users_reassignuser_content_alm_customers_ds_BeforeExecuteSelect
//users_reassignuser_content_BeforeShow @1-E710488F
function users_reassignuser_content_BeforeShow(& $sender)
{
$users_reassignuser_content_BeforeShow = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $users_reassignuser_content; //Compatibility
//End users_reassignuser_content_BeforeShow
//Custom Code @53-2A29BDB7
// -------------------------
// Write your own code here.
//Settingup saved message popup
$sourceuser = (int)CCGetFromPost("lbsourceuser",0);
$targetuser = (int)CCGetFromPost("lbtargetuser",0);
$companies = CCGetFromPost("companies",array());
$o = trim(CCGetFromPost("o",""));
if ($o == "reassignuser") {
if ( ($sourceuser) != ($targetuser) ) {
if (count($companies) > 0) {
global $FileName;
$params = array();
$params["sourceuser"] = $sourceuser;
$params["targetuser"] = $targetuser;
$params["companies"] = $companies;
$customers = new Customers();
$reassigned = $customers->reassignUser($params);
$total_updated = $reassigned["result"]["total_updated"];
if ($total_updated > 0) {
CCSetSession("showalert","show");
//$users_reassignuser_content->lbsourceuser->setvalue($targetuser);
}
}
}
} else {
//Default param value
$sourceuserid = (int)CCGetFromGet("sourceuserid","0");
if ($sourceuserid <= 0) {
$users_reassignuser_content->lbsourceuser->setvalue("1");
} else {
$users_reassignuser_content->lbsourceuser->setvalue($sourceuserid);
}
}
global $MainPage;
$showalert = CCGetSession("showalert","hide");
$MainPage->Attributes->SetValue("showalert",$showalert);
if ($showalert == "show")
CCSetSession("showalert","hide");
// -------------------------
//End Custom Code
//Close users_reassignuser_content_BeforeShow @1-90D76575
return $users_reassignuser_content_BeforeShow;
}
//End Close users_reassignuser_content_BeforeShow
?>