model.itop-change-mgmt.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. <?php
  2. // Copyright (C) 2010 Combodo SARL
  3. //
  4. // This program is free software; you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation; version 3 of the License.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. /**
  17. * Persistent classes for a CMDB
  18. *
  19. * @author Erwan Taloc <erwan.taloc@combodo.com>
  20. * @author Romain Quetiez <romain.quetiez@combodo.com>
  21. * @author Denis Flaven <denis.flaven@combodo.com>
  22. * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
  23. */
  24. abstract class Change extends Ticket
  25. {
  26. public static function Init()
  27. {
  28. $aParams = array
  29. (
  30. "category" => "bizmodel,searchable,changemgmt",
  31. "key_type" => "autoincrement",
  32. "name_attcode" => "ref",
  33. "state_attcode" => "status",
  34. "reconc_keys" => array("ref"),
  35. "db_table" => "change",
  36. "db_key_field" => "id",
  37. "db_finalclass_field" => "",
  38. "display_template" => "",
  39. "icon" => "../modules/itop-change-mgmt-1.0.0/images/change.png",
  40. );
  41. MetaModel::Init_Params($aParams);
  42. MetaModel::Init_InheritAttributes();
  43. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values"=>new ValueSetEnum('approved,assigned,closed,implemented,monitored,new,notapproved,plannedscheduled,rejected,validated'), "sql"=>"status", "default_value"=>"new", "is_null_allowed"=>true, "depends_on"=>array())));
  44. MetaModel::Init_AddAttribute(new AttributeString("reason", array("allowed_values"=>null, "sql"=>"reason", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  45. MetaModel::Init_AddAttribute(new AttributeExternalKey("requestor_id", array("targetclass"=>"Person", "jointype"=>null, "allowed_values"=>new ValueSetObjects('SELECT Person AS p WHERE p.org_id = :this->org_id'), "sql"=>"requestor_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array("org_id"))));
  46. MetaModel::Init_AddAttribute(new AttributeExternalField("requestor_email", array("allowed_values"=>null, "extkey_attcode"=>"requestor_id", "target_attcode"=>"email", "is_null_allowed"=>true, "depends_on"=>array())));
  47. MetaModel::Init_AddAttribute(new AttributeExternalKey("org_id", array("targetclass"=>"Organization", "jointype"=>null, "allowed_values"=>null, "sql"=>"org_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  48. MetaModel::Init_AddAttribute(new AttributeExternalField("org_name", array("allowed_values"=>null, "extkey_attcode"=>"org_id", "target_attcode"=>"name", "is_null_allowed"=>true, "depends_on"=>array())));
  49. MetaModel::Init_AddAttribute(new AttributeExternalKey("workgroup_id", array("targetclass"=>"Team", "jointype"=>null, "allowed_values"=>null, "sql"=>"workgroup_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  50. MetaModel::Init_AddAttribute(new AttributeExternalField("workgroup_name", array("allowed_values"=>null, "extkey_attcode"=>"workgroup_id", "target_attcode"=>"name", "is_null_allowed"=>true, "depends_on"=>array())));
  51. MetaModel::Init_AddAttribute(new AttributeDateTime("creation_date", array("allowed_values"=>null, "sql"=>"creation_date", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
  52. MetaModel::Init_AddAttribute(new AttributeDateTime("last_update", array("allowed_values"=>null, "sql"=>"last_update", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
  53. MetaModel::Init_AddAttribute(new AttributeDateTime("end_date", array("allowed_values"=>null, "sql"=>"end_date", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
  54. MetaModel::Init_AddAttribute(new AttributeDateTime("close_date", array("allowed_values"=>null, "sql"=>"close_date", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
  55. MetaModel::Init_AddAttribute(new AttributeString("impact", array("allowed_values"=>null, "sql"=>"impact", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  56. MetaModel::Init_AddAttribute(new AttributeExternalKey("agent_id", array("targetclass"=>"Person", "jointype"=>null, "allowed_values"=>new ValueSetObjects('SELECT Person AS p JOIN lnkTeamToContact AS l ON l.contact_id=p.id JOIN Team AS t ON l.team_id=t.id WHERE t.id = :this->workgroup_id'), "sql"=>"agent_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array("workgroup_id"))));
  57. MetaModel::Init_AddAttribute(new AttributeExternalField("agent_name", array("allowed_values"=>null, "extkey_attcode"=>"agent_id", "target_attcode"=>"name", "is_null_allowed"=>true, "depends_on"=>array())));
  58. MetaModel::Init_AddAttribute(new AttributeExternalField("agent_email", array("allowed_values"=>null, "extkey_attcode"=>"agent_id", "target_attcode"=>"email", "is_null_allowed"=>true, "depends_on"=>array())));
  59. MetaModel::Init_AddAttribute(new AttributeExternalKey("supervisor_group_id", array("targetclass"=>"Team", "jointype"=>null, "allowed_values"=>null, "sql"=>"supervisor_group_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  60. MetaModel::Init_AddAttribute(new AttributeExternalField("supervisor_group_name", array("allowed_values"=>null, "extkey_attcode"=>"supervisor_group_id", "target_attcode"=>"name", "is_null_allowed"=>true, "depends_on"=>array())));
  61. MetaModel::Init_AddAttribute(new AttributeExternalKey("supervisor_id", array("targetclass"=>"Person", "jointype"=>null, "allowed_values"=>new ValueSetObjects('SELECT Person AS p JOIN lnkTeamToContact AS l ON l.contact_id=p.id JOIN Team AS t ON l.team_id=t.id WHERE t.id = :this->supervisor_group_id'), "sql"=>"supervisor_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array("supervisor_group_id"))));
  62. MetaModel::Init_AddAttribute(new AttributeExternalField("supervisor_email", array("allowed_values"=>null, "extkey_attcode"=>"supervisor_id", "target_attcode"=>"email", "is_null_allowed"=>true, "depends_on"=>array())));
  63. MetaModel::Init_AddAttribute(new AttributeExternalKey("manager_group_id", array("targetclass"=>"Team", "jointype"=>null, "allowed_values"=>null, "sql"=>"manager_group_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  64. MetaModel::Init_AddAttribute(new AttributeExternalField("manager_group_name", array("allowed_values"=>null, "extkey_attcode"=>"manager_group_id", "target_attcode"=>"name", "is_null_allowed"=>true, "depends_on"=>array())));
  65. MetaModel::Init_AddAttribute(new AttributeExternalKey("manager_id", array("targetclass"=>"Person", "jointype"=>null, "allowed_values"=>new ValueSetObjects('SELECT Person AS p JOIN lnkTeamToContact AS l ON l.contact_id=p.id JOIN Team AS t ON l.team_id=t.id WHERE t.id = :this->manager_group_id'), "sql"=>"manager_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array("manager_group_id"))));
  66. MetaModel::Init_AddAttribute(new AttributeExternalField("manager_email", array("allowed_values"=>null, "extkey_attcode"=>"manager_id", "target_attcode"=>"email", "is_null_allowed"=>true, "depends_on"=>array())));
  67. MetaModel::Init_AddAttribute(new AttributeEnum("outage", array("allowed_values"=>new ValueSetEnum('yes,no'), "sql"=>"outage", "default_value"=>"no", "is_null_allowed"=>false, "depends_on"=>array())));
  68. MetaModel::Init_AddAttribute(new AttributeText("fallback", array("allowed_values"=>null, "sql"=>"fallback", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  69. MetaModel::Init_SetZListItems('details', array('title', 'org_id', 'description','ticket_log', 'start_date','end_date', 'document_list', 'ci_list', 'contact_list','incident_list', 'status', 'reason', 'requestor_id', 'workgroup_id', 'creation_date', 'last_update', 'close_date', 'impact', 'agent_id', 'agent_email', 'supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id', 'outage', 'fallback'));
  70. MetaModel::Init_SetZListItems('advanced_search', array('finalclass', 'ref', 'title', 'org_id', 'start_date', 'end_date','status', 'reason', 'requestor_id', 'workgroup_id', 'creation_date', 'last_update', 'close_date', 'impact', 'agent_id', 'agent_email', 'supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id', 'outage'));
  71. MetaModel::Init_SetZListItems('standard_search', array('finalclass', 'ref', 'title', 'org_id', 'start_date', 'end_date','status', 'reason', 'requestor_id', 'workgroup_id', 'creation_date', 'close_date', 'impact', 'agent_id', 'agent_email', 'supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id', 'outage'));
  72. MetaModel::Init_SetZListItems('list', array('finalclass', 'title', 'start_date', 'status'));
  73. MetaModel::Init_DefineState(
  74. "new",
  75. array(
  76. "attribute_inherit" => null,
  77. "attribute_list" => array(
  78. 'start_date' => OPT_ATT_HIDDEN,
  79. 'end_date' => OPT_ATT_HIDDEN,
  80. 'close_date' => OPT_ATT_HIDDEN,
  81. 'ticket_log' => OPT_ATT_HIDDEN,
  82. 'impact' => OPT_ATT_HIDDEN,
  83. 'outage' => OPT_ATT_HIDDEN,
  84. 'fallback' => OPT_ATT_HIDDEN,
  85. 'ref' => OPT_ATT_READONLY,
  86. 'requestor_id' => OPT_ATT_MANDATORY,
  87. 'title' => OPT_ATT_MANDATORY,
  88. 'reason' => OPT_ATT_MANDATORY,
  89. 'workgroup_id' => OPT_ATT_HIDDEN,
  90. 'creation_date' => OPT_ATT_READONLY,
  91. 'last_update' => OPT_ATT_READONLY,
  92. 'agent_id' => OPT_ATT_HIDDEN,
  93. 'agent_email' => OPT_ATT_HIDDEN,
  94. 'supervisor_group_id' => OPT_ATT_HIDDEN,
  95. 'supervisor_id' => OPT_ATT_HIDDEN,
  96. 'manager_group_id' => OPT_ATT_HIDDEN,
  97. 'manager_id' => OPT_ATT_HIDDEN,
  98. ),
  99. )
  100. );
  101. MetaModel::Init_DefineState(
  102. "validated",
  103. array(
  104. "attribute_inherit" => 'new',
  105. "attribute_list" => array(
  106. 'title' => OPT_ATT_READONLY,
  107. 'reason' => OPT_ATT_READONLY,
  108. 'workgroup_id' => OPT_ATT_MANDATORY,
  109. 'supervisor_group_id' => OPT_ATT_MANDATORY,
  110. 'manager_group_id' => OPT_ATT_MANDATORY,
  111. 'description' => OPT_ATT_READONLY,
  112. 'requestor_id' => OPT_ATT_READONLY,
  113. 'title' => OPT_ATT_MANDATORY,
  114. ),
  115. )
  116. );
  117. MetaModel::Init_DefineState(
  118. "rejected",
  119. array(
  120. "attribute_inherit" => 'new',
  121. "attribute_list" => array(
  122. ),
  123. )
  124. );
  125. MetaModel::Init_DefineState(
  126. "assigned",
  127. array(
  128. "attribute_inherit" => 'validated',
  129. "attribute_list" => array(
  130. 'workgroup_id' => OPT_ATT_MANDATORY,
  131. 'agent_id' => OPT_ATT_MUSTCHANGE,
  132. 'supervisor_id' => OPT_ATT_MUSTCHANGE,
  133. 'manager_id' => OPT_ATT_MUSTCHANGE,
  134. 'description' => OPT_ATT_READONLY,
  135. 'requestor_id' => OPT_ATT_READONLY,
  136. ),
  137. )
  138. );
  139. MetaModel::Init_DefineState(
  140. "plannedscheduled",
  141. array(
  142. "attribute_inherit" => 'assigned',
  143. "attribute_list" => array(
  144. 'ticket_log' => OPT_ATT_NORMAL,
  145. 'requestor_id' => OPT_ATT_READONLY,
  146. 'org_id' => OPT_ATT_READONLY,
  147. 'workgroup_id' => OPT_ATT_READONLY,
  148. 'start_date' => OPT_ATT_MANDATORY,
  149. 'end_date' => OPT_ATT_MANDATORY,
  150. 'impact' => OPT_ATT_MANDATORY,
  151. 'agent_id' => OPT_ATT_MANDATORY,
  152. 'supervisor_group_id' => OPT_ATT_MANDATORY,
  153. 'supervisor_id' => OPT_ATT_MANDATORY,
  154. 'manager_group_id' => OPT_ATT_MANDATORY,
  155. 'manager_id' => OPT_ATT_MANDATORY,
  156. 'fallback' => OPT_ATT_MANDATORY,
  157. 'outage' => OPT_ATT_MUSTPROMPT,
  158. ),
  159. )
  160. );
  161. MetaModel::Init_DefineState(
  162. "approved",
  163. array(
  164. "attribute_inherit" => 'plannedscheduled',
  165. "attribute_list" => array(
  166. 'start_date' => OPT_ATT_READONLY,
  167. 'end_date' => OPT_ATT_MANDATORY,
  168. 'impact' => OPT_ATT_READONLY,
  169. 'supervisor_group_id' => OPT_ATT_READONLY,
  170. 'supervisor_id' => OPT_ATT_READONLY,
  171. 'manager_group_id' => OPT_ATT_READONLY,
  172. 'manager_id' => OPT_ATT_READONLY,
  173. 'outage' => OPT_ATT_READONLY,
  174. ),
  175. )
  176. );
  177. MetaModel::Init_DefineState(
  178. "notapproved",
  179. array(
  180. "attribute_inherit" => 'plannedscheduled',
  181. "attribute_list" => array(
  182. 'impact' => OPT_ATT_READONLY,
  183. 'supervisor_group_id' => OPT_ATT_READONLY,
  184. 'supervisor_id' => OPT_ATT_READONLY,
  185. 'manager_group_id' => OPT_ATT_READONLY,
  186. 'manager_id' => OPT_ATT_READONLY,
  187. ),
  188. )
  189. );
  190. MetaModel::Init_DefineState(
  191. "implemented",
  192. array(
  193. "attribute_inherit" => 'approved',
  194. "attribute_list" => array(
  195. ),
  196. )
  197. );
  198. MetaModel::Init_DefineState(
  199. "monitored",
  200. array(
  201. "attribute_inherit" => 'implemented',
  202. "attribute_list" => array(
  203. 'end_date' => OPT_ATT_READONLY,
  204. 'agent_id' => OPT_ATT_READONLY,
  205. 'fallback' => OPT_ATT_READONLY,
  206. ),
  207. )
  208. );
  209. MetaModel::Init_DefineState(
  210. "closed",
  211. array(
  212. "attribute_inherit" => 'monitored',
  213. "attribute_list" => array(
  214. 'ticket_log' => OPT_ATT_READONLY,
  215. 'close_date' => OPT_ATT_READONLY,
  216. ),
  217. )
  218. );
  219. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_validate", array()));
  220. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_reject", array()));
  221. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_assign", array()));
  222. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_reopen", array()));
  223. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_plan", array()));
  224. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_approve", array()));
  225. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_replan", array()));
  226. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_notapprove", array()));
  227. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_implement", array()));
  228. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_monitor", array()));
  229. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_finish", array()));
  230. }
  231. public function SetClosureDate($sStimulusCode)
  232. {
  233. $this->Set('close_date', time());
  234. return true;
  235. }
  236. protected function OnInsert()
  237. {
  238. $oToNotify = $this->Get('contact_list');
  239. $oToImpact = $this->Get('ci_list');
  240. $oImpactedInfras = DBObjectSet::FromLinkSet($this, 'ci_list', 'ci_id');
  241. $aComputed = $oImpactedInfras->GetRelatedObjects('impacts', 10);
  242. if (isset($aComputed['FunctionalCI']) && is_array($aComputed['FunctionalCI']))
  243. {
  244. foreach($aComputed['FunctionalCI'] as $iKey => $oObject)
  245. {
  246. $oNewLink = new lnkTicketToCI();
  247. $oNewLink->Set('ci_id', $iKey);
  248. $oToImpact->AddObject($oNewLink);
  249. }
  250. }
  251. if (isset($aComputed['Contact']) && is_array($aComputed['Contact']))
  252. {
  253. foreach($aComputed['Contact'] as $iKey => $oObject)
  254. {
  255. $oNewLink = new lnkTicketToContact();
  256. $oNewLink->Set('contact_id', $iKey);
  257. $oNewLink->Set('role', 'contact automatically computed');
  258. $oToNotify->AddObject($oNewLink);
  259. }
  260. }
  261. $this->Set('creation_date', time());
  262. $this->Set('last_update', time());
  263. }
  264. protected function OnUpdate()
  265. {
  266. $this->Set('last_update', time());
  267. }
  268. public function ComputeValues()
  269. {
  270. $sCurrRef = $this->Get('ref');
  271. if (strlen($sCurrRef) == 0)
  272. {
  273. $iKey = $this->GetKey();
  274. if ($iKey < 0)
  275. {
  276. // Object not yet in the Database
  277. $iKey = MetaModel::GetNextKey(get_class($this));
  278. }
  279. $sName = sprintf('C-%06d', $iKey);
  280. $this->Set('ref', $sName);
  281. }
  282. }
  283. /**
  284. * Get the icon representing this object
  285. * @param boolean $bImgTag If true the result is a full IMG tag (or an emtpy string if no icon is defined)
  286. * @return string Either the full IMG tag ($bImgTag == true) or just the path to the icon file
  287. */
  288. public function GetIcon($bImgTag = true)
  289. {
  290. $sStatus = $this->Get('status');
  291. switch($this->GetState())
  292. {
  293. case 'approved':
  294. case 'implemented':
  295. case 'monitored':
  296. $sIcon = self::MakeIconFromName('change-approved.png');
  297. break;
  298. case 'rejected':
  299. case 'notapproved':
  300. $sIcon = self::MakeIconFromName('change-rejected.png');
  301. break;
  302. case 'closed':
  303. $sIcon = self::MakeIconFromName('change-closed.png');
  304. break;
  305. default:
  306. $sIcon = MetaModel::GetClassIcon(get_class($this), $bImgTag);
  307. }
  308. return $sIcon;
  309. }
  310. protected static function MakeIconFromName($sIconName, $bImgTag = true)
  311. {
  312. $sIcon = '';
  313. if ($sIconName != '')
  314. {
  315. $sPath = '../modules/itop-change-mgmt-1.0.0/images/'.$sIconName;
  316. if ($bImgTag)
  317. {
  318. $sIcon = "<img src=\"$sPath\" style=\"vertical-align:middle;\"/>";
  319. }
  320. else
  321. {
  322. $sIcon = $sPath;
  323. }
  324. }
  325. return $sIcon;
  326. }
  327. }
  328. class RoutineChange extends Change
  329. {
  330. public static function Init()
  331. {
  332. $aParams = array
  333. (
  334. "category" => "bizmodel,searchable,changemgmt",
  335. "key_type" => "autoincrement",
  336. "name_attcode" => "ref",
  337. "state_attcode" => "",
  338. "reconc_keys" => array("ref"),
  339. "db_table" => "change_routine",
  340. "db_key_field" => "id",
  341. "db_finalclass_field" => "",
  342. "display_template" => "",
  343. );
  344. MetaModel::Init_Params($aParams);
  345. MetaModel::Init_InheritAttributes();
  346. MetaModel::Init_InheritLifecycle();
  347. MetaModel::Init_SetZListItems('details', array('document_list', 'ci_list', 'contact_list','incident_list',
  348. 'col:col1' => array(
  349. 'fieldset:Ticket:baseinfo' => array('ref','title','org_id','status','reason','impact','description', ),
  350. 'fieldset:Ticket:moreinfo' => array('outage', 'fallback',),
  351. ),
  352. 'col:col2' => array(
  353. 'fieldset:Ticket:date' => array('creation_date','start_date','last_update','close_date',),
  354. 'fieldset:Ticket:contact' => array('requestor_id','workgroup_id','agent_id','supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id',),
  355. )
  356. ));
  357. //MetaModel::Init_SetZListItems('details', array('title', 'org_id', 'description','ticket_log', 'start_date', 'end_date','document_list', 'ci_list', 'contact_list','incident_list', 'status', 'reason', 'requestor_id', 'workgroup_id', 'creation_date', 'last_update', 'close_date', 'impact', 'agent_id', 'agent_email', 'supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id', 'outage', 'fallback'));
  358. MetaModel::Init_SetZListItems('advanced_search', array('ref', 'title', 'org_id', 'start_date', 'end_date','status', 'reason', 'requestor_id', 'workgroup_id', 'creation_date', 'last_update', 'close_date', 'impact', 'agent_id', 'agent_email', 'supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id', 'outage'));
  359. MetaModel::Init_SetZListItems('standard_search', array('ref', 'title', 'org_id', 'start_date','end_date', 'status', 'reason', 'requestor_id', 'workgroup_id', 'creation_date', 'last_update', 'close_date', 'impact', 'agent_id', 'agent_email', 'supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id', 'outage'));
  360. MetaModel::Init_SetZListItems('list', array('title', 'org_id', 'start_date', 'status', 'requestor_id'));
  361. MetaModel::Init_DefineTransition("new", "ev_assign", array("target_state"=>"assigned", "actions"=>array(), "user_restriction"=>null));
  362. MetaModel::Init_DefineTransition("assigned", "ev_plan", array("target_state"=>"plannedscheduled", "actions"=>array(), "user_restriction"=>null));
  363. MetaModel::Init_DefineTransition("plannedscheduled", "ev_implement", array("target_state"=>"implemented", "actions"=>array(), "user_restriction"=>null));
  364. MetaModel::Init_DefineTransition("implemented", "ev_monitor", array("target_state"=>"monitored", "actions"=>array(), "user_restriction"=>null));
  365. MetaModel::Init_DefineTransition("implemented", "ev_finish", array("target_state"=>"closed", "actions"=>array('SetClosureDate'), "user_restriction"=>null));
  366. MetaModel::Init_DefineTransition("monitored", "ev_finish", array("target_state"=>"closed", "actions"=>array('SetClosureDate'), "user_restriction"=>null));
  367. }
  368. }
  369. abstract class ApprovedChange extends Change
  370. {
  371. public static function Init()
  372. {
  373. $aParams = array
  374. (
  375. "category" => "bizmodel,searchable,changemgmt",
  376. "key_type" => "autoincrement",
  377. "name_attcode" => "ref",
  378. "state_attcode" => "",
  379. "reconc_keys" => array("ref"),
  380. "db_table" => "change_approved",
  381. "db_key_field" => "id",
  382. "db_finalclass_field" => "",
  383. "display_template" => "",
  384. );
  385. MetaModel::Init_Params($aParams);
  386. MetaModel::Init_InheritAttributes();
  387. MetaModel::Init_InheritLifecycle();
  388. MetaModel::Init_AddAttribute(new AttributeDateTime("approval_date", array("allowed_values"=>null, "sql"=>"approval_date", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
  389. MetaModel::Init_AddAttribute(new AttributeString("approval_comment", array("allowed_values"=>null, "sql"=>"approval_comment", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  390. MetaModel::Init_SetZListItems('details', array('title', 'org_id', 'description','ticket_log', 'start_date', 'end_date','document_list', 'ci_list', 'contact_list','incident_list', 'status', 'reason', 'requestor_id', 'workgroup_id', 'creation_date', 'last_update', 'close_date', 'impact', 'agent_id', 'agent_email', 'supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id', 'outage', 'fallback', 'approval_date', 'approval_comment'));
  391. MetaModel::Init_SetZListItems('advanced_search', array('ref', 'title', 'org_id', 'start_date','end_date', 'status', 'reason', 'requestor_id', 'workgroup_id', 'close_date', 'impact', 'agent_id', 'agent_email', 'supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id', 'outage','approval_date'));
  392. MetaModel::Init_SetZListItems('standard_search', array('ref', 'title', 'org_id', 'start_date','end_date', 'status', 'reason', 'requestor_id', 'workgroup_id', 'impact', 'agent_id', 'agent_email', 'supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id', 'outage', 'approval_date'));
  393. MetaModel::Init_SetZListItems('list', array('title', 'org_id', 'start_date', 'status', 'requestor_id'));
  394. MetaModel::Init_OverloadStateAttribute('new', 'approval_date', OPT_ATT_HIDDEN);
  395. MetaModel::Init_OverloadStateAttribute('new', 'approval_comment', OPT_ATT_HIDDEN);
  396. MetaModel::Init_OverloadStateAttribute('validated', 'approval_date', OPT_ATT_HIDDEN);
  397. MetaModel::Init_OverloadStateAttribute('validated', 'approval_comment', OPT_ATT_HIDDEN);
  398. MetaModel::Init_OverloadStateAttribute('rejected', 'approval_date', OPT_ATT_HIDDEN);
  399. MetaModel::Init_OverloadStateAttribute('rejected', 'approval_comment', OPT_ATT_HIDDEN);
  400. MetaModel::Init_OverloadStateAttribute('assigned', 'approval_date', OPT_ATT_HIDDEN);
  401. MetaModel::Init_OverloadStateAttribute('assigned', 'approval_comment', OPT_ATT_HIDDEN);
  402. MetaModel::Init_OverloadStateAttribute('plannedscheduled', 'approval_date', OPT_ATT_HIDDEN);
  403. MetaModel::Init_OverloadStateAttribute('plannedscheduled', 'approval_comment', OPT_ATT_HIDDEN);
  404. MetaModel::Init_OverloadStateAttribute('notapproved', 'approval_date', OPT_ATT_HIDDEN);
  405. MetaModel::Init_OverloadStateAttribute('notapproved', 'approval_comment', OPT_ATT_HIDDEN);
  406. MetaModel::Init_OverloadStateAttribute('approved', 'approval_date', OPT_ATT_MANDATORY);
  407. MetaModel::Init_OverloadStateAttribute('approved', 'approval_comment', OPT_ATT_MANDATORY);
  408. MetaModel::Init_OverloadStateAttribute('implemented', 'approval_date', OPT_ATT_READONLY);
  409. MetaModel::Init_OverloadStateAttribute('implemented', 'approval_comment', OPT_ATT_READONLY);
  410. MetaModel::Init_OverloadStateAttribute('monitored', 'approval_date', OPT_ATT_READONLY);
  411. MetaModel::Init_OverloadStateAttribute('monitored', 'approval_comment', OPT_ATT_READONLY);
  412. MetaModel::Init_OverloadStateAttribute('closed', 'approval_date', OPT_ATT_READONLY);
  413. MetaModel::Init_OverloadStateAttribute('closed', 'approval_comment', OPT_ATT_READONLY);
  414. }
  415. }
  416. class NormalChange extends ApprovedChange
  417. {
  418. public static function Init()
  419. {
  420. $aParams = array
  421. (
  422. "category" => "bizmodel,searchable,changemgmt",
  423. "key_type" => "autoincrement",
  424. "name_attcode" => "ref",
  425. "state_attcode" => "",
  426. "reconc_keys" => array("ref"),
  427. "db_table" => "change_normal",
  428. "db_key_field" => "id",
  429. "db_finalclass_field" => "",
  430. "display_template" => "",
  431. );
  432. MetaModel::Init_Params($aParams);
  433. MetaModel::Init_InheritAttributes();
  434. MetaModel::Init_InheritLifecycle();
  435. MetaModel::Init_AddAttribute(new AttributeDateTime("acceptance_date", array("allowed_values"=>null, "sql"=>"acceptance_date", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
  436. MetaModel::Init_AddAttribute(new AttributeString("acceptance_comment", array("allowed_values"=>null, "sql"=>"acceptance_comment", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  437. MetaModel::Init_SetZListItems('details', array('document_list', 'ci_list', 'contact_list','incident_list',
  438. 'col:col1' => array(
  439. 'fieldset:Ticket:baseinfo' => array('ref','title','org_id','status','reason','impact','description', ),
  440. 'fieldset:Ticket:moreinfo' => array('acceptance_comment','approval_comment','outage', 'fallback',),
  441. ),
  442. 'col:col2' => array(
  443. 'fieldset:Ticket:date' => array('creation_date','start_date','last_update','acceptance_date','approval_date','close_date',),
  444. 'fieldset:Ticket:contact' => array('requestor_id','workgroup_id','agent_id','supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id',),
  445. )
  446. ));
  447. // MetaModel::Init_SetZListItems('details', array('title', 'org_id', 'description','ticket_log', 'start_date','end_date', 'document_list', 'ci_list', 'contact_list','incident_list', 'status', 'reason', 'requestor_id', 'workgroup_id', 'creation_date', 'last_update','close_date', 'impact', 'agent_id', 'agent_email', 'supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id', 'outage', 'fallback', 'approval_date', 'approval_comment', 'acceptance_date', 'acceptance_comment'));
  448. MetaModel::Init_SetZListItems('advanced_search', array('ref', 'title', 'org_id', 'start_date', 'end_date','status', 'reason', 'requestor_id', 'workgroup_id', 'creation_date', 'last_update', 'close_date', 'impact', 'agent_id', 'agent_email', 'supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id', 'outage'));
  449. MetaModel::Init_SetZListItems('standard_search', array('ref', 'title', 'org_id', 'start_date','end_date', 'status', 'reason', 'requestor_id', 'workgroup_id', 'impact', 'agent_id', 'agent_email', 'supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id', 'outage'));
  450. MetaModel::Init_SetZListItems('list', array('title', 'org_id', 'start_date', 'status', 'requestor_id'));
  451. MetaModel::Init_OverloadStateAttribute('new', 'acceptance_date', OPT_ATT_HIDDEN);
  452. MetaModel::Init_OverloadStateAttribute('new', 'acceptance_comment', OPT_ATT_HIDDEN);
  453. MetaModel::Init_OverloadStateAttribute('validated', 'acceptance_date', OPT_ATT_MANDATORY);
  454. MetaModel::Init_OverloadStateAttribute('validated', 'acceptance_comment', OPT_ATT_MANDATORY);
  455. MetaModel::Init_OverloadStateAttribute('rejected', 'acceptance_date', OPT_ATT_HIDDEN);
  456. MetaModel::Init_OverloadStateAttribute('rejected', 'acceptance_comment', OPT_ATT_HIDDEN);
  457. MetaModel::Init_OverloadStateAttribute('plannedscheduled', 'acceptance_date', OPT_ATT_READONLY);
  458. MetaModel::Init_OverloadStateAttribute('plannedscheduled', 'acceptance_comment', OPT_ATT_READONLY);
  459. MetaModel::Init_OverloadStateAttribute('approved', 'acceptance_date', OPT_ATT_READONLY);
  460. MetaModel::Init_OverloadStateAttribute('approved', 'acceptance_comment', OPT_ATT_READONLY);
  461. MetaModel::Init_OverloadStateAttribute('notapproved', 'acceptance_date', OPT_ATT_READONLY);
  462. MetaModel::Init_OverloadStateAttribute('notapproved', 'acceptance_comment', OPT_ATT_READONLY);
  463. MetaModel::Init_OverloadStateAttribute('implemented', 'acceptance_date', OPT_ATT_READONLY);
  464. MetaModel::Init_OverloadStateAttribute('implemented', 'acceptance_comment', OPT_ATT_READONLY);
  465. MetaModel::Init_OverloadStateAttribute('monitored', 'acceptance_date', OPT_ATT_READONLY);
  466. MetaModel::Init_OverloadStateAttribute('monitored', 'acceptance_comment', OPT_ATT_READONLY);
  467. MetaModel::Init_OverloadStateAttribute('closed', 'acceptance_date', OPT_ATT_READONLY);
  468. MetaModel::Init_OverloadStateAttribute('closed', 'acceptance_comment', OPT_ATT_READONLY);
  469. MetaModel::Init_DefineTransition("new", "ev_validate", array("target_state"=>"validated", "actions"=>array(), "user_restriction"=>null));
  470. MetaModel::Init_DefineTransition("new", "ev_reject", array("target_state"=>"rejected", "actions"=>array(), "user_restriction"=>null));
  471. MetaModel::Init_DefineTransition("rejected", "ev_reopen", array("target_state"=>"new", "actions"=>array(), "user_restriction"=>null));
  472. MetaModel::Init_DefineTransition("validated", "ev_assign", array("target_state"=>"assigned", "actions"=>array(), "user_restriction"=>null));
  473. MetaModel::Init_DefineTransition("assigned", "ev_plan", array("target_state"=>"plannedscheduled", "actions"=>array(), "user_restriction"=>null));
  474. MetaModel::Init_DefineTransition("plannedscheduled", "ev_approve", array("target_state"=>"approved", "actions"=>array(), "user_restriction"=>null));
  475. MetaModel::Init_DefineTransition("plannedscheduled", "ev_notapprove", array("target_state"=>"notapproved", "actions"=>array(), "user_restriction"=>null));
  476. MetaModel::Init_DefineTransition("notapproved", "ev_replan", array("target_state"=>"plannedscheduled", "actions"=>array(), "user_restriction"=>null));
  477. MetaModel::Init_DefineTransition("approved", "ev_implement", array("target_state"=>"implemented", "actions"=>array(), "user_restriction"=>null));
  478. MetaModel::Init_DefineTransition("implemented", "ev_monitor", array("target_state"=>"monitored", "actions"=>array(), "user_restriction"=>null));
  479. MetaModel::Init_DefineTransition("implemented", "ev_finish", array("target_state"=>"closed", "actions"=>array('SetClosureDate'), "user_restriction"=>null));
  480. MetaModel::Init_DefineTransition("monitored", "ev_finish", array("target_state"=>"closed", "actions"=>array('SetClosureDate'), "user_restriction"=>null));
  481. }
  482. }
  483. class EmergencyChange extends ApprovedChange
  484. {
  485. public static function Init()
  486. {
  487. $aParams = array
  488. (
  489. "category" => "bizmodel,searchable,changemgmt",
  490. "key_type" => "autoincrement",
  491. "name_attcode" => "ref",
  492. "state_attcode" => "",
  493. "reconc_keys" => array("ref"),
  494. "db_table" => "change_emergency",
  495. "db_key_field" => "id",
  496. "db_finalclass_field" => "",
  497. "display_template" => "",
  498. );
  499. MetaModel::Init_Params($aParams);
  500. MetaModel::Init_InheritAttributes();
  501. MetaModel::Init_InheritLifecycle();
  502. MetaModel::Init_SetZListItems('details', array('document_list', 'ci_list', 'contact_list','incident_list',
  503. 'col:col1' => array(
  504. 'fieldset:Ticket:baseinfo' => array('ref','title','org_id','status','reason','impact','description', ),
  505. 'fieldset:Ticket:moreinfo' => array('approval_comment','outage', 'fallback',),
  506. ),
  507. 'col:col2' => array(
  508. 'fieldset:Ticket:date' => array('creation_date','start_date','last_update','approval_date','close_date',),
  509. 'fieldset:Ticket:contact' => array('requestor_id','workgroup_id','agent_id','supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id',),
  510. )
  511. ));
  512. // MetaModel::Init_SetZListItems('details', array('title', 'org_id', 'description','ticket_log', 'start_date', 'end_date','document_list', 'ci_list', 'contact_list','incident_list', 'status', 'reason', 'requestor_id', 'workgroup_id', 'creation_date', 'last_update', 'close_date', 'impact', 'agent_id', 'agent_email', 'supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id', 'outage', 'fallback', 'approval_date', 'approval_comment'));
  513. MetaModel::Init_SetZListItems('advanced_search', array('ref', 'title', 'org_id', 'start_date','end_date', 'status', 'reason', 'requestor_id', 'workgroup_id', 'impact', 'agent_id', 'agent_email', 'supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id', 'outage', 'approval_date'));
  514. MetaModel::Init_SetZListItems('standard_search', array('ref', 'title', 'org_id', 'start_date', 'end_date','status', 'reason', 'requestor_id', 'workgroup_id', 'creation_date', 'last_update', 'close_date', 'impact', 'agent_id', 'agent_email', 'supervisor_group_id', 'supervisor_id', 'manager_group_id', 'manager_id', 'outage', 'approval_date'));
  515. MetaModel::Init_SetZListItems('list', array('title', 'org_id', 'start_date', 'status', 'requestor_id'));
  516. MetaModel::Init_DefineTransition("new", "ev_assign", array("target_state"=>"assigned", "actions"=>array(), "user_restriction"=>null));
  517. MetaModel::Init_DefineTransition("assigned", "ev_plan", array("target_state"=>"plannedscheduled", "actions"=>array(), "user_restriction"=>null));
  518. MetaModel::Init_DefineTransition("plannedscheduled", "ev_approve", array("target_state"=>"approved", "actions"=>array(), "user_restriction"=>null));
  519. MetaModel::Init_DefineTransition("plannedscheduled", "ev_notapprove", array("target_state"=>"notapproved", "actions"=>array(), "user_restriction"=>null));
  520. MetaModel::Init_DefineTransition("notapproved", "ev_replan", array("target_state"=>"plannedscheduled", "actions"=>array(), "user_restriction"=>null));
  521. MetaModel::Init_DefineTransition("approved", "ev_implement", array("target_state"=>"implemented", "actions"=>array(), "user_restriction"=>null));
  522. MetaModel::Init_DefineTransition("implemented", "ev_monitor", array("target_state"=>"monitored", "actions"=>array(), "user_restriction"=>null));
  523. MetaModel::Init_DefineTransition("implemented", "ev_finish", array("target_state"=>"closed", "actions"=>array('SetClosureDate'), "user_restriction"=>null));
  524. MetaModel::Init_DefineTransition("monitored", "ev_finish", array("target_state"=>"closed", "actions"=>array('SetClosureDate'), "user_restriction"=>null));
  525. }
  526. }
  527. $oMyMenuGroup = new MenuGroup('ChangeManagement', 50 /* fRank */);
  528. new TemplateMenuNode('Change:Overview', dirname(__FILE__).'/overview.html', $oMyMenuGroup->GetIndex() /* oParent */, 0 /* fRank */);
  529. new NewObjectMenuNode('NewChange', 'Change', $oMyMenuGroup->GetIndex(), 1 /* fRank */);
  530. new SearchMenuNode('SearchChanges', 'Change', $oMyMenuGroup->GetIndex(), 2 /* fRank */);
  531. $oShortcutNode = new TemplateMenuNode('Change:Shortcuts', '', $oMyMenuGroup->GetIndex(), 3 /* fRank */);
  532. $oNode = new OQLMenuNode('MyChanges', 'SELECT Change WHERE agent_id = :current_contact_id AND status NOT IN ("closed", "resolved")', $oShortcutNode->GetIndex(), 1 /* fRank */);
  533. $oNode->SetParameters(array('auto_reload' => 'fast'));
  534. $oNode = new OQLMenuNode('Changes', 'SELECT Change WHERE status != "closed"', $oShortcutNode->GetIndex(), 2 /* fRank */);
  535. $oNode->SetParameters(array('auto_reload' => 'fast'));
  536. $oNode = new OQLMenuNode('WaitingApproval', 'SELECT ApprovedChange WHERE status IN ("plannedscheduled")', $oShortcutNode->GetIndex(), 3 /* fRank */);
  537. $oNode->SetParameters(array('auto_reload' => 'fast'));
  538. $oNode = new OQLMenuNode('WaitingAcceptance', 'SELECT NormalChange WHERE status IN ("new")', $oShortcutNode->GetIndex(), 4 /* fRank */);
  539. $oNode->SetParameters(array('auto_reload' => 'fast'));
  540. ?>