-
Notifications
You must be signed in to change notification settings - Fork 0
/
exampleDemo.php
201 lines (158 loc) · 5.94 KB
/
exampleDemo.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
198
199
200
201
<?php
require_once 'lib/autoload.php';
require_once 'db_connection.php';
$projectId = 1450;
$issueId = 50620;
// --> with Username/Password
$client = new Redmine\Client("https://portal.optimusinfo.com/redmine/", 'vikas.singhal', 'vzi950');
//echo "<pre>";print_r($client);die;
// Projects
//show all Projects in your account with description
$allProject = $client->api('project')->all();
//echo "<pre>";print_r($allProject);die;
//------------projectsTable-----------------------------
// foreach ($allProject['projects'] as $key=>$project)
// {
// $query = "INSERT INTO projects
// VALUES ('$project[id]','$project[identifier]',
// '$project[name]','$project[created_on]',
// '$project[updated_on]','$project[description]')";
// $resultset=mysqli_query($connection,$query);
// }
//show a particluar project details by the project id
$projectInfo = $client->api('project')->show($projectId);
//echo "<pre>";print_r($projectInfo);die;
//-----trackersTable---------------------
// foreach ($projectInfo['project']['trackers'] as $key=>$track)
// {
// $projectId = $projectInfo['project']['id'];
// $query = "INSERT INTO trackersTable (tracker_id,tracker_name,projectId)
// VALUES ('$track[id]','$track[name]','$projectId')";
// $resultset=mysqli_query($connection,$query);
// }
//-----------------issue _categoriesTable----------
// foreach ($projectInfo['project']['issue_categories'] as $key=>$issuecategory)
// {
// $projectId = $projectInfo['project']['id'];
// $query = "INSERT INTO categoryTable (category_id,category_name,projectId)
// VALUES ('$issuecategory[id]','$issuecategory[name]','$projectId')";
// $resultset=mysqli_query($connection,$query);
// }
// Users
//get the current user ie vikas singhal information
$userInfo = $client->api('user')->getCurrentUser();
//echo "<pre>";print_r($userInfo);die;
//--------------userTable---------------
// foreach ($userInfo as $key=>$user)
// {
// $query = "INSERT INTO userTable
// VALUES ('$user[id]','$user[lastname]','$user[last_login_on]',
// '$user[created_on]',
// '$user[mail]','$user[firstname]')";
// $resultset=mysqli_query($connection,$query);
// }
//------------Memberships/Role--Table-----------------
// foreach ($userInfo['user']['memberships'] as $key=>$value)
// {
// foreach($value['roles'] as $role)
// {
// $id = $value['project']['id'];
// $query = "INSERT INTO memberships
// VALUES ('$value[id]','$id','$role[id]','$role[name]')";
// $resultset=mysqli_query($connection,$query);
// }
// }
// Issues
//get the existing issue information
$issueInfo = $client->api('issue')->show($issueId);
//echo "<pre>";print_r($issueInfo);die;
//----------issuetable-----------------
// foreach($issueInfo as $key=>$value)
// {
// $trackerId = $value['tracker']['id'];
// $statusId =$value['status']['id'];
// $projectId = $value['project']['id'];
// $assigneId =$value['assigned_to']['id'];
// $priorityId = $value['priority']['id'];
// $parentId = $value['parent']['id'];
// $authorId = $value['author']['id'];
// $query = "INSERT INTO issueTable
// VALUES ('$value[id]','$value[estimated_hours]',
// '$value[subject]','$value[spent_hours]',
// '$value[created_on]','$value[start_date]',
// '$value[updated_on]','$value[done_ratio]',
// '$value[due_date]','$value[description]',
// '$trackerId','$statusId','$projectId',
// '$assigneId','$priorityId','$parentId','$authorId'
// )";
// $resultset=mysqli_query($connection,$query);
// }
// //-------------status table---------------
// foreach($issueInfo as $key=>$value)
// {
// $statusId = $value['status']['id'];
// $statusName =$value['status']['name'];
// $issueId = $value['id'];
// $query = "INSERT INTO status
// VALUES ('$statusId','$statusName','$issueId')";
// $resultset=mysqli_query($connection,$query);
// }
// Time entries
//get the time entry for all dates
$timeEntry = $client->api('time_entry')->all(array(
'issue_id' => $issueId,
));
//echo "<pre>";print_r($timeEntry);die;
// //-----------timeEntries Table--------------------
// foreach($timeEntry['time_entries'] as $key=>$entry)
// {
// $projectId= $entry['project']['id'];
// $activityId= $entry['activity']['id'];
// $issueId= $entry['issue']['id'];
// $userId= $entry['user']['id'];
// $query = "INSERT INTO timeEntries
// VALUES ('$entry[id]','$projectId',
// '$entry[comments]','$activityId',
// '$issueId','$entry[created_on]',
// '$userId','$entry[hours]',
// '$entry[spent_on]','$entry[updated_on]')";
// $resultset=mysqli_query($connection,$query);
// }
//------------Activity table-----------------
// foreach($timeEntry['time_entries'] as $key=>$entry)
// {
// $activityId= $entry['activity']['id'];
// $activityName= $entry['activity']['name'];
// $query = "INSERT INTO activities
// VALUES ('$activityId','$activityName')";
// $resultset=mysqli_query($connection,$query);
// }
// //---------billingCategory--table-------------
// foreach($timeEntry['time_entries'] as $key=>$entry)
// {
// foreach ($entry['custom_fields'] as $key=>$value)
// {
// $issueId= $entry['issue']['id'];
// $query = "INSERT INTO billingCategory
// VALUES ('$value[id]','$value[name]','$value[value]','$issueId')";
// $resultset=mysqli_query($connection,$query);
// }
// }
//-------------RedmineTable-----------------
//number of hours logged in current/last month
$x= 0;
$y = 0;
foreach($timeEntry['time_entries'] as $key=>$entry)
{
//echo "<pre>";print_r($entry['id']);
if($entry['spent_on']>=date('Y-m-01') && $entry['spent_on']<=date('Y-m-t'))
{
$x+=$entry['hours'];
}
if($entry['spent_on']>=date("Y-m-d", mktime(0, 0, 0, date("m")-1, 1, date("Y"))) && $entry['spent_on']<=date("Y-m-d", mktime(0, 0, 0, date("m"), 0, date("Y"))))
{
$y+=$entry['hours'];
}
}
$query = "INSERT INTO redmineTable VALUES ('$y','$x')";
$resultset=mysqli_query($connection,$query);