forked from Combodo/combodo-approval-extended
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.combodo-approval-extended.php
executable file
·126 lines (103 loc) · 3.64 KB
/
main.combodo-approval-extended.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
<?php
// Copyright (C) 2013-2017 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Module approval-extended
*
* @author Erwan Taloc <[email protected]>
* @author Romain Quetiez <[email protected]>
* @author Denis Flaven <[email protected]>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class ApprovalComputeWorkingHours implements iWorkingTimeComputer
{
public static function GetDescription()
{
return "Compute working hours for Approval rule on UserRequest";
}
public function GetDeadline($oObject, $iDuration, DateTime $oStartDate)
{
$sCoverageOQL = 'SELECT CoverageWindow AS cw JOIN ApprovalRule AS ar ON ar.coveragewindow_id=cw.id JOIN ServiceSubcategory AS sc ON sc.approvalrule_id = ar.id WHERE sc.id =:this->servicesubcategory_id';
return EnhancedSLAComputation::GetDeadline($oObject, $iDuration, $oStartDate, $sCoverageOQL);
}
public function GetOpenDuration($oObject, DateTime $oStartDate, DateTime $oEndDate)
{
$sCoverageOQL = 'SELECT CoverageWindow AS cw JOIN ApprovalRule AS ar ON ar.coveragewindow_id=cw.id JOIN ServiceSubcategory AS sc ON sc.approvalrule_id = ar.id WHERE sc.id =:this->servicesubcategory_id';
return EnhancedSLAComputation::GetOpenDuration($oObject, $oStartDate, $oEndDate, $sCoverageOQL);
}
}
class HideButtonsPlugin implements iApplicationUIExtension
{
public function OnDisplayProperties($oObject, WebPage $oPage, $bEditMode = false)
{
if ( (get_class($oObject) == 'UserRequest' ) && ( $oObject->IsNew()) )
{
$oSet = new DBObjectSet(new DBObjectSearch('ApprovalRule'));
$iCount = $oSet->Count();
if ($iCount > 0)
{
$oPage->add_ready_script(
<<<EOF
$('button.action[name="next_action"]').hide();
EOF
);
}
}
}
public function OnDisplayRelations($oObject, WebPage $oPage, $bEditMode = false)
{
}
public function OnFormSubmit($oObject, $sFormPrefix = '')
{
}
public function OnFormCancel($sTempId)
{
}
public function EnumUsedAttributes($oObject)
{
return array();
}
public function GetIcon($oObject)
{
return '';
}
public function GetHilightClass($oObject)
{
// Possible return values are:
// HILIGHT_CLASS_CRITICAL, HILIGHT_CLASS_WARNING, HILIGHT_CLASS_OK, HILIGHT_CLASS_NONE
return HILIGHT_CLASS_NONE;
}
public function EnumAllowedActions(DBObjectSet $oSet)
{
// No action
return array();
}
}
class ApprovalFromUI implements iPopupMenuExtension
{
/**
* Get the list of items to be added to a menu.
*
* This method is called by the framework for each menu.
* The items will be inserted in the menu in the order of the returned array.
* @param int $iMenuId The identifier of the type of menu, as listed by the constants MENU_xxx
* @param mixed $param Depends on $iMenuId, see the constants defined above
* @return object[] An array of ApplicationPopupMenuItem or an empty array if no action is to be added to the menu
*/
public static function EnumItems($iMenuId, $param)
{
return ApprovalScheme::GetPopMenuItems($iMenuId, $param);
}
}