model.itop-change-mgmt.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  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. );
  40. MetaModel::Init_Params($aParams);
  41. MetaModel::Init_InheritAttributes();
  42. 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())));
  43. MetaModel::Init_AddAttribute(new AttributeString("reason", array("allowed_values"=>null, "sql"=>"reason", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  44. 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"))));
  45. 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())));
  46. 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())));
  47. 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())));
  48. 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())));
  49. 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())));
  50. MetaModel::Init_AddAttribute(new AttributeDateTime("creation_date", array("allowed_values"=>null, "sql"=>"creation_date", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
  51. MetaModel::Init_AddAttribute(new AttributeDateTime("last_update", array("allowed_values"=>null, "sql"=>"last_update", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
  52. MetaModel::Init_AddAttribute(new AttributeDateTime("start_date", array("allowed_values"=>null, "sql"=>"start_date", "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. 'ticket_log' => OPT_ATT_HIDDEN,
  80. 'impact' => OPT_ATT_HIDDEN,
  81. 'outage' => OPT_ATT_HIDDEN,
  82. 'fallback' => OPT_ATT_HIDDEN,
  83. 'ref' => OPT_ATT_READONLY,
  84. 'requestor_id' => OPT_ATT_MANDATORY,
  85. 'title' => OPT_ATT_MANDATORY,
  86. 'reason' => OPT_ATT_MANDATORY,
  87. 'workgroup_id' => OPT_ATT_HIDDEN,
  88. 'creation_date' => OPT_ATT_READONLY,
  89. 'last_update' => OPT_ATT_READONLY,
  90. 'end_date' => OPT_ATT_HIDDEN,
  91. 'close_date' => OPT_ATT_HIDDEN,
  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_MANDATORY,
  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. $iKey = $this->GetKey();
  271. if ($iKey < 0)
  272. {
  273. // Object not yet in the Database
  274. $iKey = MetaModel::GetNextKey(get_class($this));
  275. }
  276. $sName = sprintf('C-%06d', $iKey);
  277. $this->Set('ref', $sName);
  278. }
  279. }
  280. class RoutineChange extends Change
  281. {
  282. public static function Init()
  283. {
  284. $aParams = array
  285. (
  286. "category" => "bizmodel,searchable,changemgmt",
  287. "key_type" => "autoincrement",
  288. "name_attcode" => "ref",
  289. "state_attcode" => "",
  290. "reconc_keys" => array("ref"),
  291. "db_table" => "change_routine",
  292. "db_key_field" => "id",
  293. "db_finalclass_field" => "",
  294. "display_template" => "",
  295. );
  296. MetaModel::Init_Params($aParams);
  297. MetaModel::Init_InheritAttributes();
  298. MetaModel::Init_InheritLifecycle();
  299. 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'));
  300. 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'));
  301. 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'));
  302. MetaModel::Init_SetZListItems('list', array('title', 'org_id', 'start_date', 'status', 'requestor_id'));
  303. MetaModel::Init_DefineTransition("new", "ev_assign", array("target_state"=>"assigned", "actions"=>array(), "user_restriction"=>null));
  304. MetaModel::Init_DefineTransition("assigned", "ev_plan", array("target_state"=>"plannedscheduled", "actions"=>array(), "user_restriction"=>null));
  305. MetaModel::Init_DefineTransition("plannedscheduled", "ev_implement", array("target_state"=>"implemented", "actions"=>array(), "user_restriction"=>null));
  306. MetaModel::Init_DefineTransition("implemented", "ev_monitor", array("target_state"=>"monitored", "actions"=>array(), "user_restriction"=>null));
  307. MetaModel::Init_DefineTransition("implemented", "ev_finish", array("target_state"=>"closed", "actions"=>array('SetClosureDate'), "user_restriction"=>null));
  308. MetaModel::Init_DefineTransition("monitored", "ev_finish", array("target_state"=>"closed", "actions"=>array('SetClosureDate'), "user_restriction"=>null));
  309. }
  310. }
  311. abstract class ApprovedChange extends Change
  312. {
  313. public static function Init()
  314. {
  315. $aParams = array
  316. (
  317. "category" => "bizmodel,searchable,changemgmt",
  318. "key_type" => "autoincrement",
  319. "name_attcode" => "ref",
  320. "state_attcode" => "",
  321. "reconc_keys" => array("ref"),
  322. "db_table" => "change_approved",
  323. "db_key_field" => "id",
  324. "db_finalclass_field" => "",
  325. "display_template" => "",
  326. );
  327. MetaModel::Init_Params($aParams);
  328. MetaModel::Init_InheritAttributes();
  329. MetaModel::Init_InheritLifecycle();
  330. MetaModel::Init_AddAttribute(new AttributeDateTime("approval_date", array("allowed_values"=>null, "sql"=>"approval_date", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
  331. MetaModel::Init_AddAttribute(new AttributeString("approval_comment", array("allowed_values"=>null, "sql"=>"approval_comment", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  332. 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'));
  333. 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'));
  334. 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'));
  335. MetaModel::Init_SetZListItems('list', array('title', 'org_id', 'start_date', 'status', 'requestor_id'));
  336. MetaModel::Init_OverloadStateAttribute('new', 'approval_date', OPT_ATT_HIDDEN);
  337. MetaModel::Init_OverloadStateAttribute('new', 'approval_comment', OPT_ATT_HIDDEN);
  338. MetaModel::Init_OverloadStateAttribute('validated', 'approval_date', OPT_ATT_HIDDEN);
  339. MetaModel::Init_OverloadStateAttribute('validated', 'approval_comment', OPT_ATT_HIDDEN);
  340. MetaModel::Init_OverloadStateAttribute('rejected', 'approval_date', OPT_ATT_HIDDEN);
  341. MetaModel::Init_OverloadStateAttribute('rejected', 'approval_comment', OPT_ATT_HIDDEN);
  342. MetaModel::Init_OverloadStateAttribute('assigned', 'approval_date', OPT_ATT_HIDDEN);
  343. MetaModel::Init_OverloadStateAttribute('assigned', 'approval_comment', OPT_ATT_HIDDEN);
  344. MetaModel::Init_OverloadStateAttribute('plannedscheduled', 'approval_date', OPT_ATT_HIDDEN);
  345. MetaModel::Init_OverloadStateAttribute('plannedscheduled', 'approval_comment', OPT_ATT_HIDDEN);
  346. MetaModel::Init_OverloadStateAttribute('notapproved', 'approval_date', OPT_ATT_HIDDEN);
  347. MetaModel::Init_OverloadStateAttribute('notapproved', 'approval_comment', OPT_ATT_HIDDEN);
  348. MetaModel::Init_OverloadStateAttribute('approved', 'approval_date', OPT_ATT_MANDATORY);
  349. MetaModel::Init_OverloadStateAttribute('approved', 'approval_comment', OPT_ATT_MANDATORY);
  350. MetaModel::Init_OverloadStateAttribute('implemented', 'approval_date', OPT_ATT_READONLY);
  351. MetaModel::Init_OverloadStateAttribute('implemented', 'approval_comment', OPT_ATT_READONLY);
  352. MetaModel::Init_OverloadStateAttribute('monitored', 'approval_date', OPT_ATT_READONLY);
  353. MetaModel::Init_OverloadStateAttribute('monitored', 'approval_comment', OPT_ATT_READONLY);
  354. MetaModel::Init_OverloadStateAttribute('closed', 'approval_date', OPT_ATT_READONLY);
  355. MetaModel::Init_OverloadStateAttribute('closed', 'approval_comment', OPT_ATT_READONLY);
  356. }
  357. }
  358. class NormalChange extends ApprovedChange
  359. {
  360. public static function Init()
  361. {
  362. $aParams = array
  363. (
  364. "category" => "bizmodel,searchable,changemgmt",
  365. "key_type" => "autoincrement",
  366. "name_attcode" => "ref",
  367. "state_attcode" => "",
  368. "reconc_keys" => array("ref"),
  369. "db_table" => "change_normal",
  370. "db_key_field" => "id",
  371. "db_finalclass_field" => "",
  372. "display_template" => "",
  373. );
  374. MetaModel::Init_Params($aParams);
  375. MetaModel::Init_InheritAttributes();
  376. MetaModel::Init_InheritLifecycle();
  377. MetaModel::Init_AddAttribute(new AttributeDateTime("acceptance_date", array("allowed_values"=>null, "sql"=>"acceptance_date", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
  378. MetaModel::Init_AddAttribute(new AttributeString("acceptance_comment", array("allowed_values"=>null, "sql"=>"acceptance_comment", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  379. 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'));
  380. 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'));
  381. 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'));
  382. MetaModel::Init_SetZListItems('list', array('title', 'org_id', 'start_date', 'status', 'requestor_id'));
  383. MetaModel::Init_OverloadStateAttribute('new', 'acceptance_date', OPT_ATT_HIDDEN);
  384. MetaModel::Init_OverloadStateAttribute('new', 'acceptance_comment', OPT_ATT_HIDDEN);
  385. MetaModel::Init_OverloadStateAttribute('validated', 'acceptance_date', OPT_ATT_MANDATORY);
  386. MetaModel::Init_OverloadStateAttribute('validated', 'acceptance_comment', OPT_ATT_MANDATORY);
  387. MetaModel::Init_OverloadStateAttribute('rejected', 'acceptance_date', OPT_ATT_HIDDEN);
  388. MetaModel::Init_OverloadStateAttribute('rejected', 'acceptance_comment', OPT_ATT_HIDDEN);
  389. MetaModel::Init_OverloadStateAttribute('plannedscheduled', 'acceptance_date', OPT_ATT_READONLY);
  390. MetaModel::Init_OverloadStateAttribute('plannedscheduled', 'acceptance_comment', OPT_ATT_READONLY);
  391. MetaModel::Init_OverloadStateAttribute('approved', 'acceptance_date', OPT_ATT_READONLY);
  392. MetaModel::Init_OverloadStateAttribute('approved', 'acceptance_comment', OPT_ATT_READONLY);
  393. MetaModel::Init_OverloadStateAttribute('notapproved', 'acceptance_date', OPT_ATT_READONLY);
  394. MetaModel::Init_OverloadStateAttribute('notapproved', 'acceptance_comment', OPT_ATT_READONLY);
  395. MetaModel::Init_OverloadStateAttribute('implemented', 'acceptance_date', OPT_ATT_READONLY);
  396. MetaModel::Init_OverloadStateAttribute('implemented', 'acceptance_comment', OPT_ATT_READONLY);
  397. MetaModel::Init_OverloadStateAttribute('monitored', 'acceptance_date', OPT_ATT_READONLY);
  398. MetaModel::Init_OverloadStateAttribute('monitored', 'acceptance_comment', OPT_ATT_READONLY);
  399. MetaModel::Init_OverloadStateAttribute('closed', 'acceptance_date', OPT_ATT_READONLY);
  400. MetaModel::Init_OverloadStateAttribute('closed', 'acceptance_comment', OPT_ATT_READONLY);
  401. MetaModel::Init_DefineTransition("new", "ev_validate", array("target_state"=>"validated", "actions"=>array(), "user_restriction"=>null));
  402. MetaModel::Init_DefineTransition("new", "ev_reject", array("target_state"=>"rejected", "actions"=>array(), "user_restriction"=>null));
  403. MetaModel::Init_DefineTransition("rejected", "ev_reopen", array("target_state"=>"new", "actions"=>array(), "user_restriction"=>null));
  404. MetaModel::Init_DefineTransition("validated", "ev_assign", array("target_state"=>"assigned", "actions"=>array(), "user_restriction"=>null));
  405. MetaModel::Init_DefineTransition("assigned", "ev_plan", array("target_state"=>"plannedscheduled", "actions"=>array(), "user_restriction"=>null));
  406. MetaModel::Init_DefineTransition("plannedscheduled", "ev_approve", array("target_state"=>"approved", "actions"=>array(), "user_restriction"=>null));
  407. MetaModel::Init_DefineTransition("plannedscheduled", "ev_notapprove", array("target_state"=>"notapproved", "actions"=>array(), "user_restriction"=>null));
  408. MetaModel::Init_DefineTransition("notapproved", "ev_replan", array("target_state"=>"plannedscheduled", "actions"=>array(), "user_restriction"=>null));
  409. MetaModel::Init_DefineTransition("approved", "ev_implement", array("target_state"=>"implemented", "actions"=>array(), "user_restriction"=>null));
  410. MetaModel::Init_DefineTransition("implemented", "ev_monitor", array("target_state"=>"monitored", "actions"=>array(), "user_restriction"=>null));
  411. MetaModel::Init_DefineTransition("implemented", "ev_finish", array("target_state"=>"closed", "actions"=>array('SetClosureDate'), "user_restriction"=>null));
  412. MetaModel::Init_DefineTransition("monitored", "ev_finish", array("target_state"=>"closed", "actions"=>array('SetClosureDate'), "user_restriction"=>null));
  413. }
  414. }
  415. class EmergencyChange extends ApprovedChange
  416. {
  417. public static function Init()
  418. {
  419. $aParams = array
  420. (
  421. "category" => "bizmodel,searchable,changemgmt",
  422. "key_type" => "autoincrement",
  423. "name_attcode" => "ref",
  424. "state_attcode" => "",
  425. "reconc_keys" => array("ref"),
  426. "db_table" => "change_emergency",
  427. "db_key_field" => "id",
  428. "db_finalclass_field" => "",
  429. "display_template" => "",
  430. );
  431. MetaModel::Init_Params($aParams);
  432. MetaModel::Init_InheritAttributes();
  433. MetaModel::Init_InheritLifecycle();
  434. 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'));
  435. 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'));
  436. 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'));
  437. MetaModel::Init_SetZListItems('list', array('title', 'org_id', 'start_date', 'status', 'requestor_id'));
  438. MetaModel::Init_DefineTransition("new", "ev_assign", array("target_state"=>"assigned", "actions"=>array(), "user_restriction"=>null));
  439. MetaModel::Init_DefineTransition("assigned", "ev_plan", array("target_state"=>"plannedscheduled", "actions"=>array(), "user_restriction"=>null));
  440. MetaModel::Init_DefineTransition("plannedscheduled", "ev_approve", array("target_state"=>"approved", "actions"=>array(), "user_restriction"=>null));
  441. MetaModel::Init_DefineTransition("plannedscheduled", "ev_notapprove", array("target_state"=>"notapproved", "actions"=>array(), "user_restriction"=>null));
  442. MetaModel::Init_DefineTransition("notapproved", "ev_replan", array("target_state"=>"plannedscheduled", "actions"=>array(), "user_restriction"=>null));
  443. MetaModel::Init_DefineTransition("approved", "ev_implement", array("target_state"=>"implemented", "actions"=>array(), "user_restriction"=>null));
  444. MetaModel::Init_DefineTransition("implemented", "ev_monitor", array("target_state"=>"monitored", "actions"=>array(), "user_restriction"=>null));
  445. MetaModel::Init_DefineTransition("implemented", "ev_finish", array("target_state"=>"closed", "actions"=>array('SetClosureDate'), "user_restriction"=>null));
  446. MetaModel::Init_DefineTransition("monitored", "ev_finish", array("target_state"=>"closed", "actions"=>array('SetClosureDate'), "user_restriction"=>null));
  447. }
  448. }
  449. $oMyMenuGroup = new MenuGroup('ChangeManagement', 50 /* fRank */);
  450. new TemplateMenuNode('Change:Overview', '../modules/itop-change-mgmt-1.0.0/overview.html', $oMyMenuGroup->GetIndex() /* oParent */, 0 /* fRank */);
  451. new NewObjectMenuNode('NewChange', 'Change', $oMyMenuGroup->GetIndex(), 1 /* fRank */);
  452. new SearchMenuNode('SearchChanges', 'Change', $oMyMenuGroup->GetIndex(), 2 /* fRank */);
  453. $oShortcutNode = new TemplateMenuNode('Change:Shortcuts', '', $oMyMenuGroup->GetIndex(), 3 /* fRank */);
  454. new OQLMenuNode('MyChanges', 'SELECT Change WHERE agent_id = :current_contact_id', $oShortcutNode->GetIndex(), 1 /* fRank */);
  455. new OQLMenuNode('Changes', 'SELECT Change WHERE status != "closed"', $oShortcutNode->GetIndex(), 2 /* fRank */);
  456. new OQLMenuNode('WaitingApproval', 'SELECT ApprovedChange WHERE status IN ("plannedscheduled")', $oShortcutNode->GetIndex(), 3 /* fRank */);
  457. new OQLMenuNode('WaitingAcceptance', 'SELECT NormalChange WHERE status IN ("new")', $oShortcutNode->GetIndex(), 4 /* fRank */);
  458. ?>