model.itop-change-mgmt.php 34 KB

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