model.itop-change-mgmt.php 35 KB

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