itop.business.class.inc.php 108 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819
  1. <?php
  2. require_once('../application/cmdbabstract.class.inc.php');
  3. require_once('../application/template.class.inc.php');
  4. /**
  5. * itop.business.class.inc.php
  6. * User defined objects, implements the business need
  7. *
  8. * @package iTopBizModelSamples
  9. * @author Romain Quetiez <romainquetiez@yahoo.fr>
  10. * @author Denis Flaven <denisflave@free.fr>
  11. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  12. * @link www.itop.com
  13. * @since 1.0
  14. * @version 1.1.1.1 $
  15. */
  16. /**
  17. * Possible values for the statuses of objects
  18. */
  19. $oAllowedStatuses = new ValueSetEnum('production,implementation,obsolete');
  20. /**
  21. * Relation graphs
  22. */
  23. MetaModel::RegisterRelation("impacts", array("description"=>"objects being functionaly impacted", "verb_down"=>"impacts", "verb_up"=>"is impacted by"));
  24. ////////////////////////////////////////////////////////////////////////////////////
  25. /**
  26. * An organization that owns some objects
  27. *
  28. * An organization "owns" some persons (its employees) but also some other objects
  29. * (its assets) like buildings, computers, furniture...
  30. * the services that they provides, the contracts/OLA they have signed as customer
  31. *
  32. * Organization ownership might be used to manage the R/W access to the object
  33. */
  34. ////////////////////////////////////////////////////////////////////////////////////
  35. /**
  36. * itop.business.class.inc.php
  37. * User defined objects, implements the business need
  38. *
  39. * @package iTopBizModelSamples
  40. * @author Erwan Taloc <taloche@yahoo.fr>
  41. * @author Denis Flaven <denisflave@free.fr>
  42. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  43. * @link www.itop.com
  44. * @since 1.0
  45. * @version 1.1.1.1 $
  46. */
  47. class bizOrganization extends cmdbAbstractObject
  48. {
  49. public static function Init()
  50. {
  51. global $oAllowedStatuses;
  52. $aParams = array
  53. (
  54. "category" => "bizmodel,searchable",
  55. "name" => "Organization",
  56. "description" => "Organizational structure: can be Company and/or Department",
  57. "key_type" => "autoincrement",
  58. "key_label" => "id",
  59. "name_attcode" => "name",
  60. "state_attcode" => "",
  61. "reconc_keys" => array("name"),
  62. "db_table" => "organizations",
  63. "db_key_field" => "id",
  64. "db_finalclass_field" => "",
  65. "display_template" => "../business/templates/default.html",
  66. );
  67. MetaModel::Init_Params($aParams);
  68. MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Name", "description"=>"Common name", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array() )));
  69. MetaModel::Init_AddAttribute(new AttributeString("code", array("label"=>"Code", "description"=>"Organization code (Siret, DUNS,...)", "allowed_values"=>null, "sql"=>"code", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array() )));
  70. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Lifecycle status", "allowed_values"=>$oAllowedStatuses, "sql"=>"status", "default_value"=>"implementation", "is_null_allowed"=>false, "depends_on"=>array())));
  71. MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_id", array("targetclass"=>"bizOrganization", "label"=>"Parent", "description"=>"Parent organization", "allowed_values"=>null, "sql"=>"parent_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  72. MetaModel::Init_AddAttribute(new AttributeExternalField("parent_name", array("label"=>"Parent Name", "description"=>"Name of the parent organization", "allowed_values"=>null, "extkey_attcode"=> 'parent_id', "target_attcode"=>"name")));
  73. MetaModel::Init_AddFilterFromAttribute("name");
  74. MetaModel::Init_AddFilterFromAttribute("code");
  75. MetaModel::Init_AddFilterFromAttribute("status");
  76. // Display lists
  77. MetaModel::Init_SetZListItems('details', array('name', 'code', 'status', 'parent_id')); // Attributes to be displayed for the complete details
  78. MetaModel::Init_SetZListItems('list', array('name', 'status', 'parent_id')); // Attributes to be displayed for a list
  79. // Search criteria
  80. MetaModel::Init_SetZListItems('standard_search', array('name', 'code', 'status')); // Criteria of the std search form
  81. MetaModel::Init_SetZListItems('advanced_search', array('name', 'code', 'status')); // Criteria of the advanced search form
  82. }
  83. public function Generate(cmdbDataGenerator $oGenerator)
  84. {
  85. //$this->SetKey($oGenerator->GetOrganizationCode());
  86. $this->Set('name', $oGenerator->GetOrganizationName());
  87. $this->Set('code', $oGenerator->GetOrganizationCode());
  88. $this->Set('status', 'implementation');
  89. $this->Set('parent_id', 1);
  90. }
  91. }
  92. ////////////////////////////////////////////////////////////////////////////////////
  93. /**
  94. * Class of objects owned by some organization
  95. *
  96. * This is the root class of all the objects that can be "owned" by an organization
  97. *
  98. * A Real Object
  99. * can be supported by Contacts, having a specific role (same contact with multiple roles?)
  100. * can be documented by Documents
  101. */
  102. ////////////////////////////////////////////////////////////////////////////////////
  103. /**
  104. * itop.business.class.inc.php
  105. * User defined objects, implements the business need
  106. *
  107. * @package iTopBizModelSamples
  108. * @author Erwan Taloc <taloche@yahoo.fr>
  109. * @author Denis Flaven <denisflave@free.fr>
  110. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  111. * @link www.itop.com
  112. * @since 1.0
  113. * @version 1.1.1.1 $
  114. */
  115. class logRealObject extends cmdbAbstractObject
  116. {
  117. public static function Init()
  118. {
  119. global $oAllowedStatuses;
  120. $aParams = array
  121. (
  122. "category" => "bizmodel,searchable",
  123. "name" => "Object",
  124. "description" => "Any CMDB object",
  125. "key_type" => "autoincrement",
  126. "key_label" => "id",
  127. "name_attcode" => "name",
  128. "state_attcode" => "",
  129. "reconc_keys" => array("name"),
  130. "db_table" => "objects",
  131. "db_key_field" => "id",
  132. "db_finalclass_field" => "obj_class",
  133. "display_template" => "../business/templates/default.html",
  134. );
  135. MetaModel::Init_Params($aParams);
  136. MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Name", "description"=>"Common name", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  137. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Lifecycle status", "allowed_values"=>$oAllowedStatuses, "sql"=>"status", "default_value"=>"implementation", "is_null_allowed"=>false, "depends_on"=>array())));
  138. MetaModel::Init_AddAttribute(new AttributeExternalKey("org_id", array("targetclass"=>"bizOrganization", "label"=>"Organization", "description"=>"ID of the object owner organization", "allowed_values"=>null, "sql"=>"org_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  139. MetaModel::Init_AddAttribute(new AttributeExternalField("org_name", array("label"=>"Organization", "description"=>"Company / Department owning this object", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
  140. MetaModel::Init_AddFilterFromAttribute("name");
  141. MetaModel::Init_AddFilterFromAttribute("status");
  142. MetaModel::Init_AddFilterFromAttribute("org_id");
  143. MetaModel::Init_AddFilterFromAttribute("org_name");
  144. // Display lists
  145. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id')); // Attributes to be displayed for the complete details
  146. MetaModel::Init_SetZListItems('list', array('finalclass', 'name', 'status', 'org_id')); // Attributes to be displayed for a list
  147. // Search criteria
  148. MetaModel::Init_SetZListItems('standard_search', array('name', 'status')); // Criteria of the std search form
  149. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'org_id')); // Criteria of the advanced search form
  150. }
  151. public function Generate(cmdbDataGenerator $oGenerator)
  152. {
  153. $this->Set('org_id', $oGenerator->GetOrganizationId());
  154. $this->Set('name', "<overload in derived class>");
  155. $this->Set('status', $oGenerator->GenerateString("enum(implementation,production)"));
  156. }
  157. }
  158. ////////////////////////////////////////////////////////////////////////////////////
  159. /**
  160. * Any kind of thing that can be contacted (person, team, hotline...)
  161. * A contact can:
  162. * be linked to any Real Object with a role
  163. * be part of a GroupContact
  164. */
  165. ////////////////////////////////////////////////////////////////////////////////////
  166. class bizContact extends logRealObject
  167. {
  168. public static function Init()
  169. {
  170. $aParams = array
  171. (
  172. "category" => "bizmodel,searchable",
  173. "name" => "Contact",
  174. "description" => "Contact",
  175. "key_type" => "",
  176. "key_label" => "id",
  177. "name_attcode" => "name",
  178. "state_attcode" => "",
  179. "reconc_keys" => array("org_id", "name"), // inherited attributes
  180. "db_table" => "contacts",
  181. "db_key_field" => "id",
  182. "db_finalclass_field" => "",
  183. "display_template" => "../business/templates/default.html",
  184. );
  185. MetaModel::Init_Params($aParams);
  186. MetaModel::Init_InheritAttributes();
  187. MetaModel::Init_AddAttribute(new AttributeExternalField("org_name", array("label"=>"Organization", "description"=>"Company / Department of the contact", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
  188. MetaModel::Init_AddAttribute(new AttributeString("email", array("label"=>"eMail", "description"=>"Email address", "allowed_values"=>null, "sql"=>"email", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  189. MetaModel::Init_AddAttribute(new AttributeString("phone", array("label"=>"Phone", "description"=>"Telephone", "allowed_values"=>null, "sql"=>"telephone", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  190. MetaModel::Init_AddAttribute(new AttributeExternalKey("location_id", array("targetclass"=>"bizLocation", "label"=>"Location", "description"=>"Id of the location where the contact is located", "allowed_values"=>null, "sql"=>"location_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  191. MetaModel::Init_AddAttribute(new AttributeExternalField("location_name", array("label"=>"Location Name", "description"=>"Name of the location where the contact is located", "allowed_values"=>null, "extkey_attcode"=> 'location_id', "target_attcode"=>"name")));
  192. MetaModel::Init_InheritFilters();
  193. MetaModel::Init_AddFilterFromAttribute("org_name");
  194. MetaModel::Init_AddFilterFromAttribute("email");
  195. MetaModel::Init_AddFilterFromAttribute("phone");
  196. MetaModel::Init_AddFilterFromAttribute("location_id");
  197. MetaModel::Init_AddFilterFromAttribute("location_name");
  198. // Display lists
  199. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'email', 'location_id', 'phone')); // Attributes to be displayed for the complete details
  200. MetaModel::Init_SetZListItems('list', array('finalclass', 'name', 'status', 'org_id', 'email', 'location_id', 'phone')); // Attributes to be displayed for a list
  201. // Search criteria
  202. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'email', 'location_id', 'phone')); // Criteria of the std search form
  203. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'org_id')); // Criteria of the advanced search form
  204. }
  205. public function Generate(cmdbDataGenerator $oGenerator)
  206. {
  207. $this->Set('org_id', $oGenerator->GetOrganizationId());
  208. $this->Set('name', "<overload in derived classes>");
  209. $this->Set('email', "<overload in derived classes>");
  210. $this->Set('phone', $oGenerator->GenerateString("enum(+1,+33,+44,+49,+421)| |number(100-999)| |number(000-999)"));
  211. $this->Set('location_id', $oGenerator->GenerateKey("bizLocation", array('org_id' =>$oGenerator->GetOrganizationId() )));
  212. }
  213. }
  214. ////////////////////////////////////////////////////////////////////////////////////
  215. /**
  216. * Physical person only
  217. */
  218. ////////////////////////////////////////////////////////////////////////////////////
  219. class bizPerson extends bizContact
  220. {
  221. public static function Init()
  222. {
  223. $oAllowedEmployeeStatuses = new ValueSetEnum('off,left company,available');
  224. $aParams = array
  225. (
  226. "category" => "bizmodel,searchable",
  227. "name" => "Person",
  228. "description" => "Person",
  229. "key_type" => "",
  230. "key_label" => "id",
  231. "name_attcode" => "name",
  232. "state_attcode" => "",
  233. "reconc_keys" => array("org_id", "first_name", "name"), // comment en définir plusieurs
  234. // "reconc_keys" => array("org_id", "employee_number"),
  235. "db_table" => "persons", // Can it use the same physical DB table as any contact ?
  236. "db_key_field" => "id",
  237. "db_finalclass_field" => "",
  238. "display_template" => "../business/templates/person.html",
  239. );
  240. MetaModel::Init_Params($aParams);
  241. MetaModel::Init_InheritAttributes();
  242. MetaModel::Init_AddAttribute(new AttributeString("first_name", array("label"=>"First Name", "description"=>"First name", "allowed_values"=>null, "sql"=>"first_name", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  243. MetaModel::Init_AddAttribute(new AttributeString("employee_number", array("label"=>"Employee Number", "description"=>"employee number", "allowed_values"=>null, "sql"=>"employee_number", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  244. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Lifecycle status", "allowed_values"=>$oAllowedEmployeeStatuses, "sql"=>"status", "default_value"=>"available", "is_null_allowed"=>false, "depends_on"=>array())));
  245. MetaModel::Init_InheritFilters();
  246. MetaModel::Init_AddFilterFromAttribute("first_name");
  247. MetaModel::Init_AddFilterFromAttribute("employee_number");
  248. // Display lists
  249. MetaModel::Init_SetZListItems('details', array('first_name', 'name', 'status', 'org_id', 'email', 'location_id', 'phone', 'employee_number')); // Attributes to be displayed for the complete details
  250. MetaModel::Init_SetZListItems('list', array('first_name', 'name', 'status', 'org_id', 'email', 'location_id', 'phone')); // Attributes to be displayed for a list
  251. // Search criteria
  252. MetaModel::Init_SetZListItems('standard_search', array('first_name', 'name', 'status', 'email', 'location_id', 'phone', 'employee_number')); // Criteria of the std search form
  253. MetaModel::Init_SetZListItems('advanced_search', array('first_name', 'name', 'status', 'email', 'location_id', 'phone', 'employee_number')); // Criteria of the advanced search form
  254. }
  255. public function Generate(cmdbDataGenerator $oGenerator)
  256. {
  257. parent::Generate($oGenerator);
  258. $this->Set('name', $oGenerator->GenerateLastName());
  259. $this->Set('first_name', $oGenerator->GenerateFirstName());
  260. $this->Set('email', $oGenerator->GenerateEmail($this->Get('first_name'), $this->Get('name')));
  261. $this->Set('phone', $oGenerator->GenerateString("enum(+1,+33,+44,+49,+421)| |number(100-999)| |number(000-999)"));
  262. }
  263. }
  264. ////////////////////////////////////////////////////////////////////////////////////
  265. /**
  266. * A team is basically a contact which is also a group of contacts
  267. * (and thus a team can contain other teams)
  268. */
  269. ////////////////////////////////////////////////////////////////////////////////////
  270. class bizTeam extends bizContact
  271. {
  272. public static function Init()
  273. {
  274. $aParams = array
  275. (
  276. "category" => "bizmodel,searchable",
  277. "name" => "Team",
  278. "description" => "A group of contacts",
  279. "key_type" => "",
  280. "key_label" => "id",
  281. "name_attcode" => "name",
  282. "state_attcode" => "",
  283. "reconc_keys" => array("org_id", "name"), // inherited attributes
  284. "db_table" => "teams",
  285. "db_key_field" => "id",
  286. "db_finalclass_field" => "",
  287. "display_template" => "../business/templates/team.html",
  288. );
  289. MetaModel::Init_Params($aParams);
  290. MetaModel::Init_InheritAttributes();
  291. MetaModel::Init_InheritFilters();
  292. // Display lists
  293. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'email', 'location_id', 'phone')); // Attributes to be displayed for the complete details
  294. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'email', 'location_id', 'phone')); // Attributes to be displayed for a list
  295. // Search criteria
  296. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'email', 'location_id', 'phone')); // Criteria of the std search form
  297. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'org_id')); // Criteria of the advanced search form
  298. }
  299. }
  300. ////////////////////////////////////////////////////////////////////////////////////
  301. /**
  302. * n-n link between any Object and a contact
  303. */
  304. ////////////////////////////////////////////////////////////////////////////////////
  305. class lnkContactTeam extends cmdbAbstractObject
  306. {
  307. public static function Init()
  308. {
  309. $aParams = array
  310. (
  311. "category" => "bizmodel,searchable",
  312. "name" => "TeamsLinks",
  313. "description" => "A link between a contact and a Team",
  314. "key_type" => "autoincrement",
  315. "key_label" => "link_id",
  316. "name_attcode" => "role",
  317. "state_attcode" => "",
  318. "reconc_keys" => array("contact_id", "team_name"),
  319. "db_table" => "teams_links",
  320. "db_key_field" => "link_id",
  321. "db_finalclass_field" => "",
  322. "display_template" => "../business/templates/default.html",
  323. );
  324. MetaModel::Init_Params($aParams);
  325. MetaModel::Init_AddAttribute(new AttributeExternalKey("contact_id", array("targetclass"=>"bizPerson", "label"=>"Contact", "description"=>"The contact", "allowed_values"=>null, "sql"=>"contact_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  326. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_name", array("label"=>"Contact Name", "description"=>"name of the contact", "allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"name")));
  327. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_phone", array("label"=>"Phone", "description"=>"Phone number of the contact", "allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"phone")));
  328. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_email", array("label"=>"eMail", "description"=>"eMail address of the contact", "allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"email")));
  329. MetaModel::Init_AddAttribute(new AttributeExternalKey("team_id", array("targetclass"=>"bizTeam", "label"=>"Team", "description"=>"Team linked", "allowed_values"=>null, "sql"=>"team_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  330. MetaModel::Init_AddAttribute(new AttributeExternalField("team_name", array("label"=>"Team", "description"=>"name of the Team", "allowed_values"=>null, "extkey_attcode"=> 'team_id', "target_attcode"=>"name")));
  331. MetaModel::Init_AddAttribute(new AttributeString("role", array("label"=>"Role", "description"=>"Role of the contact", "allowed_values"=>null, "sql"=>"role", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  332. MetaModel::Init_AddFilterFromAttribute("contact_id");
  333. MetaModel::Init_AddFilterFromAttribute("contact_name");
  334. MetaModel::Init_AddFilterFromAttribute("team_id");
  335. MetaModel::Init_AddFilterFromAttribute("team_name");
  336. MetaModel::Init_AddFilterFromAttribute("role");
  337. // Display lists
  338. MetaModel::Init_SetZListItems('details', array('contact_id', 'contact_phone', 'contact_email', 'team_id', 'role')); // Attributes to be displayed for the complete details
  339. MetaModel::Init_SetZListItems('list', array('contact_id', 'contact_phone', 'contact_email', 'team_id', 'role')); // Attributes to be displayed for a list
  340. }
  341. }
  342. ////////////////////////////////////////////////////////////////////////////////////
  343. /**
  344. * An electronic document, with version tracking
  345. */
  346. ////////////////////////////////////////////////////////////////////////////////////
  347. class bizDocument extends logRealObject
  348. {
  349. public static function Init()
  350. {
  351. $aParams = array
  352. (
  353. "category" => "bizmodel,searchable",
  354. "name" => "Document",
  355. "description" => "Document",
  356. "key_type" => "",
  357. "key_label" => "id",
  358. "name_attcode" => "name",
  359. "state_attcode" => "",
  360. "reconc_keys" => array("org_id", "name"), // inherited attributes
  361. "db_table" => "documents",
  362. "db_key_field" => "id",
  363. "db_finalclass_field" => "",
  364. "display_template" => "../business/templates/document.html",
  365. );
  366. MetaModel::Init_Params($aParams);
  367. MetaModel::Init_InheritAttributes();
  368. MetaModel::Init_AddAttribute(new AttributeExternalField("org_name", array("label"=>"Organization", "description"=>"Company / Department owning the document", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
  369. MetaModel::Init_AddAttribute(new AttributeEnum("scope", array("label"=>"scope", "description"=>"Scope of this document", "allowed_values"=>new ValueSetEnum("organization,hardware support"), "sql"=>"scope", "default_value"=>"organization", "is_null_allowed"=>false, "depends_on"=>array())));
  370. MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"Description", "description"=>"Service Description", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  371. MetaModel::Init_AddAttribute(new AttributeBlob("contents", array("label"=>"Contents", "description"=>"File content", "depends_on"=>array())));
  372. MetaModel::Init_InheritFilters();
  373. MetaModel::Init_AddFilterFromAttribute("scope");
  374. MetaModel::Init_AddFilterFromAttribute("description");
  375. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'scope', 'description', 'contents')); // Attributes to be displayed for the complete details
  376. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'scope')); // Attributes to be displayed for a list
  377. // Search criteria
  378. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'scope')); // Criteria of the std search form
  379. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'scope')); // Criteria of the advanced search form
  380. }
  381. }
  382. ////////////////////////////////////////////////////////////////////////////////////
  383. /**
  384. * A version of an electronic document
  385. */
  386. ////////////////////////////////////////////////////////////////////////////////////
  387. class bizDocVersion extends cmdbAbstractObject
  388. {
  389. public static function Init()
  390. {
  391. global $oAllowedStatuses;
  392. $aParams = array
  393. (
  394. "category" => "bizmodel,searchable",
  395. "name" => "DocumentVersion",
  396. "description" => "A version of a document",
  397. "key_type" => "autoincrement",
  398. "key_label" => "id",
  399. "name_attcode" => "version_number",
  400. "state_attcode" => "",
  401. "reconc_keys" => array("document", "version_number"),
  402. "db_table" => "document_versions",
  403. "db_key_field" => "id",
  404. "db_finalclass_field" => "",
  405. "display_template" => "../business/templates/default.html",
  406. );
  407. MetaModel::Init_Params($aParams);
  408. MetaModel::Init_AddAttribute(new AttributeExternalKey("document", array("targetclass"=>"bizDocument", "label"=>"Document", "description"=>"The main document", "allowed_values"=>null, "sql"=>"document_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  409. MetaModel::Init_AddAttribute(new AttributeExternalField("docname", array("label"=>"Document Name", "description"=>"name of the document", "allowed_values"=>null, "extkey_attcode"=> 'document', "target_attcode"=>"name")));
  410. MetaModel::Init_AddAttribute(new AttributeString("version_number", array("label"=>"Version", "description"=>"Version identifier", "allowed_values"=>null, "sql"=>"version_number", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  411. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Status", "allowed_values"=>$oAllowedStatuses, "sql"=>"status", "default_value"=>"implementation", "is_null_allowed"=>false, "depends_on"=>array())));
  412. MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type", "allowed_values"=>new ValueSetEnum("local,draft"), "sql"=>"type", "default_value"=>"local", "is_null_allowed"=>false, "depends_on"=>array())));
  413. MetaModel::Init_AddAttribute(new AttributeURL("url", array("label"=>"URL", "description"=>"Hyperlink to the version", "allowed_values"=>null, "target"=>"_blank", "sql"=>"url", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  414. MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"Description", "description"=>"Service Description", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  415. MetaModel::Init_AddFilterFromAttribute("document");
  416. MetaModel::Init_AddFilterFromAttribute("docname");
  417. MetaModel::Init_AddFilterFromAttribute("version_number");
  418. MetaModel::Init_AddFilterFromAttribute("status");
  419. MetaModel::Init_AddFilterFromAttribute("type");
  420. MetaModel::Init_AddFilterFromAttribute("description");
  421. MetaModel::Init_SetZListItems('details', array('document', 'status', 'version_number', 'type','url','description')); // Attributes to be displayed for the complete details
  422. MetaModel::Init_SetZListItems('list', array('version_number', 'status', 'type', 'url')); // Attributes to be displayed for a list
  423. // Search criteria
  424. MetaModel::Init_SetZListItems('standard_search', array('docname', 'type')); // Criteria of the std search form
  425. MetaModel::Init_SetZListItems('advanced_search', array('docname', 'type')); // Criteria o
  426. }
  427. }
  428. ////////////////////////////////////////////////////////////////////////////////////
  429. /**
  430. * n-n link between any Object and a Document
  431. */
  432. ////////////////////////////////////////////////////////////////////////////////////
  433. class lnkDocumentRealObject extends cmdbAbstractObject
  434. {
  435. public static function Init()
  436. {
  437. $aParams = array
  438. (
  439. "category" => "bizmodel,searchable",
  440. "name" => "DocumentsLinks",
  441. "description" => "A link between a document and another object",
  442. "key_type" => "autoincrement",
  443. "key_label" => "link_id",
  444. "name_attcode" => "link_type",
  445. "state_attcode" => "",
  446. "reconc_keys" => array("doc_id", "object_name"),
  447. "db_table" => "documents_links",
  448. "db_key_field" => "link_id",
  449. "db_finalclass_field" => "",
  450. "display_template" => "../business/templates/default.html",
  451. );
  452. MetaModel::Init_Params($aParams);
  453. MetaModel::Init_AddAttribute(new AttributeExternalKey("doc_id", array("targetclass"=>"bizDocument", "label"=>"Document", "description"=>"id of the Document", "allowed_values"=>null, "sql"=>"doc_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  454. MetaModel::Init_AddAttribute(new AttributeExternalField("doc_name", array("label"=>"Document Name", "description"=>"name of the document", "allowed_values"=>null, "extkey_attcode"=> 'doc_id', "target_attcode"=>"name")));
  455. MetaModel::Init_AddAttribute(new AttributeExternalKey("object_id", array("targetclass"=>"logRealObject", "label"=>"Object", "description"=>"Object linked", "allowed_values"=>null, "sql"=>"object_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  456. MetaModel::Init_AddAttribute(new AttributeExternalField("object_name", array("label"=>"Object Name", "description"=>"name of the linked object", "allowed_values"=>null, "extkey_attcode"=> 'object_id', "target_attcode"=>"name")));
  457. MetaModel::Init_AddAttribute(new AttributeString("link_type", array("label"=>"Link Type", "description"=>"More information", "allowed_values"=>null, "sql"=>"link_type", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  458. MetaModel::Init_AddFilterFromAttribute("doc_id");
  459. MetaModel::Init_AddFilterFromAttribute("doc_name");
  460. MetaModel::Init_AddFilterFromAttribute("object_id");
  461. MetaModel::Init_AddFilterFromAttribute("object_name");
  462. MetaModel::Init_AddFilterFromAttribute("link_type");
  463. // Display lists
  464. MetaModel::Init_SetZListItems('details', array('doc_id', 'object_id', 'link_type')); // Attributes to be displayed for the complete details
  465. MetaModel::Init_SetZListItems('list', array('doc_id', 'object_id', 'link_type')); // Attributes to be displayed for a list
  466. }
  467. }
  468. ////////////////////////////////////////////////////////////////////////////////////
  469. /**
  470. * n-n link between any Object and a contact
  471. */
  472. ////////////////////////////////////////////////////////////////////////////////////
  473. class lnkContactRealObject extends cmdbAbstractObject
  474. {
  475. public static function Init()
  476. {
  477. $aParams = array
  478. (
  479. "category" => "bizmodel,searchable",
  480. "name" => "ContactsLinks",
  481. "description" => "A link between a contact and another object",
  482. "key_type" => "autoincrement",
  483. "key_label" => "link_id",
  484. "name_attcode" => "role",
  485. "state_attcode" => "",
  486. "reconc_keys" => array("contact_id", "object_name"),
  487. "db_table" => "contacts_links",
  488. "db_key_field" => "link_id",
  489. "db_finalclass_field" => "",
  490. "display_template" => "../business/templates/default.html",
  491. );
  492. MetaModel::Init_Params($aParams);
  493. MetaModel::Init_AddAttribute(new AttributeExternalKey("contact_id", array("targetclass"=>"bizContact", "label"=>"Contact", "description"=>"The contact", "allowed_values"=>null, "sql"=>"contact_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  494. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_name", array("label"=>"Contact Name", "description"=>"name of the contact", "allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"name")));
  495. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_phone", array("label"=>"Phone", "description"=>"Phone number of the contact", "allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"phone")));
  496. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_email", array("label"=>"eMail", "description"=>"eMail address of the contact", "allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"email")));
  497. MetaModel::Init_AddAttribute(new AttributeExternalKey("object_id", array("targetclass"=>"logRealObject", "label"=>"Object", "description"=>"Object linked", "allowed_values"=>null, "sql"=>"object_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  498. MetaModel::Init_AddAttribute(new AttributeExternalField("object_name", array("label"=>"Object Name", "description"=>"name of the linked object", "allowed_values"=>null, "extkey_attcode"=> 'object_id', "target_attcode"=>"name")));
  499. MetaModel::Init_AddAttribute(new AttributeString("role", array("label"=>"Role", "description"=>"Role of the contact", "allowed_values"=>null, "sql"=>"role", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  500. MetaModel::Init_AddFilterFromAttribute("contact_id");
  501. MetaModel::Init_AddFilterFromAttribute("contact_name");
  502. MetaModel::Init_AddFilterFromAttribute("object_id");
  503. MetaModel::Init_AddFilterFromAttribute("object_name");
  504. MetaModel::Init_AddFilterFromAttribute("role");
  505. // Display lists
  506. MetaModel::Init_SetZListItems('details', array('contact_id', 'contact_phone', 'contact_email', 'object_id', 'role')); // Attributes to be displayed for the complete details
  507. MetaModel::Init_SetZListItems('list', array('contact_id', 'contact_phone', 'contact_email', 'object_id', 'role')); // Attributes to be displayed for a list
  508. }
  509. }
  510. ////////////////////////////////////////////////////////////////////////////////////
  511. /**
  512. * Any Infrastructure object (bizLocation, bizDevice, bizApplication, bizCircuit, bizInterface)
  513. * An infrastructure object:
  514. * can be covered by an OLA
  515. * can support the delivery of a Service
  516. * can be part of an GroupInfra
  517. */
  518. ////////////////////////////////////////////////////////////////////////////////////
  519. class logInfra extends logRealObject
  520. {
  521. public static function Init()
  522. {
  523. $aParams = array
  524. (
  525. "category" => "bizmodel,searchable",
  526. "name" => "Infra",
  527. "description" => "Infrastructure real object",
  528. "key_type" => "",
  529. "key_label" => "id",
  530. "name_attcode" => "name",
  531. "state_attcode" => "",
  532. "reconc_keys" => array("org_id", "name"), // inherited attributes
  533. "db_table" => "infra",
  534. "db_key_field" => "id",
  535. "db_finalclass_field" => "",
  536. "display_template" => "../business/templates/default.html",
  537. );
  538. MetaModel::Init_Params($aParams);
  539. MetaModel::Init_InheritAttributes();
  540. MetaModel::Init_AddAttribute(new AttributeEnum("severity", array("label"=>"Business Criticity", "description"=>"Severity for this infrastructure", "allowed_values"=>new ValueSetEnum("high,medium,low"), "sql"=>"severity", "default_value"=>"low", "is_null_allowed"=>false, "depends_on"=>array())));
  541. MetaModel::Init_InheritFilters();
  542. MetaModel::Init_AddFilterFromAttribute("severity");
  543. }
  544. }
  545. ////////////////////////////////////////////////////////////////////////////////////
  546. /**
  547. * n-n link between any Object and a contact
  548. */
  549. ////////////////////////////////////////////////////////////////////////////////////
  550. class lnkContactInfra extends cmdbAbstractObject
  551. {
  552. public static function Init()
  553. {
  554. $aParams = array
  555. (
  556. "category" => "bizmodel,searchable",
  557. "name" => "ContactsInfraLinks",
  558. "description" => "A link between a contact and an infrastructure",
  559. "key_type" => "autoincrement",
  560. "key_label" => "link_id",
  561. "name_attcode" => "role",
  562. "state_attcode" => "",
  563. "reconc_keys" => array("contact_id", "infra_id"),
  564. "db_table" => "contacts_infra_links",
  565. "db_key_field" => "link_id",
  566. "db_finalclass_field" => "",
  567. "display_template" => "../business/templates/default.html",
  568. );
  569. MetaModel::Init_Params($aParams);
  570. MetaModel::Init_AddAttribute(new AttributeExternalKey("contact_id", array("targetclass"=>"bizContact", "label"=>"Contact", "description"=>"The contact", "allowed_values"=>null, "sql"=>"contact_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  571. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_name", array("label"=>"Contact Name", "description"=>"name of the contact", "allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"name")));
  572. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_phone", array("label"=>"Phone", "description"=>"Phone number of the contact", "allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"phone")));
  573. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_email", array("label"=>"eMail", "description"=>"eMail address of the contact", "allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"email")));
  574. MetaModel::Init_AddAttribute(new AttributeExternalKey("infra_id", array("targetclass"=>"logInfra", "label"=>"Infrastructure", "description"=>"Infrastructure linked", "allowed_values"=>null, "sql"=>"infra_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  575. MetaModel::Init_AddAttribute(new AttributeExternalField("infra_name", array("label"=>"Infrastructure", "description"=>"name of the linked infrastructure", "allowed_values"=>null, "extkey_attcode"=> 'infra_id', "target_attcode"=>"name")));
  576. MetaModel::Init_AddAttribute(new AttributeString("role", array("label"=>"Role", "description"=>"Role of the contact", "allowed_values"=>null, "sql"=>"role", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  577. MetaModel::Init_AddFilterFromAttribute("contact_id");
  578. MetaModel::Init_AddFilterFromAttribute("contact_name");
  579. MetaModel::Init_AddFilterFromAttribute("infra_id");
  580. MetaModel::Init_AddFilterFromAttribute("infra_name");
  581. MetaModel::Init_AddFilterFromAttribute("role");
  582. // Display lists
  583. MetaModel::Init_SetZListItems('details', array('contact_id', 'contact_phone', 'contact_email', 'infra_id', 'role')); // Attributes to be displayed for the complete details
  584. MetaModel::Init_SetZListItems('list', array('contact_id', 'contact_phone', 'contact_email', 'infra_id', 'role')); // Attributes to be displayed for a list
  585. }
  586. }
  587. ////////////////////////////////////////////////////////////////////////////////////
  588. /**
  589. * bizLocation (Region, Country, City, Site, Building, Floor, Room, Rack,...)
  590. * pourrait être mis en plusieurs sous objects, puisqu'une adresse sur region n'a pas trop de sens
  591. *
  592. */
  593. ////////////////////////////////////////////////////////////////////////////////////
  594. class bizLocation extends logInfra
  595. {
  596. public static function Init()
  597. {
  598. $aParams = array
  599. (
  600. "category" => "bizmodel,searchable",
  601. "name" => "Location",
  602. "description" => "Any type of location: Region, Country, City, Site, Building, Floor, Room, Rack,...",
  603. "key_type" => "",
  604. "key_label" => "id",
  605. "name_attcode" => "name",
  606. "state_attcode" => "",
  607. "reconc_keys" => array("org_id", "name"), // inherited attributes
  608. "db_table" => "location",
  609. "db_key_field" => "id",
  610. "db_finalclass_field" => "",
  611. "display_template" => "../business/templates/location.html",
  612. );
  613. MetaModel::Init_Params($aParams);
  614. MetaModel::Init_InheritAttributes();
  615. MetaModel::Init_AddAttribute(new AttributeText("address", array("label"=>"Address", "description"=>"The postal address of the location", "allowed_values"=>null, "sql"=>"address", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  616. MetaModel::Init_AddAttribute(new AttributeString("country", array("label"=>"Country", "description"=>"Country of the location", "allowed_values"=>null, "sql"=>"country", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  617. MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_location_id", array("targetclass"=>"bizLocation", "label"=>"Parent Location", "description"=>"where is the real object physically located", "allowed_values"=>null, "sql"=>"parent_location_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  618. MetaModel::Init_AddAttribute(new AttributeExternalField("parent_location_name", array("label"=>"Parent location (Name)", "description"=>"name of the parent location", "allowed_values"=>null, "extkey_attcode"=> 'parent_location_id', "target_attcode"=>"name")));
  619. // on veut pouvoir rechercher une location qui soit un descendant (pas obligatoirement direct) d'une Location, on fait comment ?
  620. MetaModel::Init_InheritFilters();
  621. MetaModel::Init_AddFilterFromAttribute("country");
  622. MetaModel::Init_AddFilterFromAttribute("address");
  623. MetaModel::Init_AddFilterFromAttribute("parent_location_id");
  624. MetaModel::Init_AddFilterFromAttribute("parent_location_name");
  625. // Display lists
  626. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'address', 'country', 'parent_location_id')); // Attributes to be displayed for the complete details
  627. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'country')); // Attributes to be displayed for a list
  628. // Search criteria
  629. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'country', 'parent_location_name')); // Criteria of the std search form
  630. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'address', 'country', 'parent_location_id', 'org_id')); // Criteria of the advanced search form
  631. }
  632. public function ComputeValues()
  633. {
  634. /*
  635. $this->Set("location_id", $this->GetKey());
  636. // Houston, I've got an issue, as this field is calculated, I should reload the object... ?
  637. $this->Set("location_name", "abc (to be finalized)");
  638. */
  639. }
  640. function DisplayDetails(web_page $oPage)
  641. {
  642. parent::DisplayDetails($oPage);
  643. /*
  644. parent::DisplayDetails($oPage);
  645. $oSearchFilter = new CMDBSearchFilter('bizServer');
  646. $oSearchFilter->AddCondition('location_id', $this->GetKey(), '=');
  647. $oSet = new CMDBObjectSet($oSearchFilter);
  648. $count = $oSet->Count();
  649. if ($count > 0)
  650. {
  651. $oPage->SetCurrentTab("Servers");
  652. $oPage->p("$count server(s) at this location:");
  653. $this->DisplaySet($oPage, $oSet);
  654. }
  655. $oSearchFilter = new CMDBSearchFilter('bizNetworkDevice');
  656. $oSearchFilter->AddCondition('location_id', $this->GetKey(), '=');
  657. $oSet = new CMDBObjectSet($oSearchFilter);
  658. $count = $oSet->Count();
  659. if ($count > 0)
  660. {
  661. $oPage->SetCurrentTab("Network Devices");
  662. $oPage->p("$count Network Device(s) at this location:");
  663. $this->DisplaySet($oPage, $oSet);
  664. }
  665. $oSearchFilter = new CMDBSearchFilter('bizPC');
  666. $oSearchFilter->AddCondition('location_id', $this->GetKey(), '=');
  667. $oSet = new CMDBObjectSet($oSearchFilter);
  668. $count = $oSet->Count();
  669. if ($count > 0)
  670. {
  671. $oPage->SetCurrentTab("PCs");
  672. $oPage->p("$count PC(s) at this location:");
  673. $this->DisplaySet($oPage, $oSet);
  674. }
  675. $oSearchFilter = new CMDBSearchFilter('bizPerson');
  676. $oSearchFilter->AddCondition('location_id', $this->GetKey(), '=');
  677. $oSet = new CMDBObjectSet($oSearchFilter);
  678. $count = $oSet->Count();
  679. if ($count > 0)
  680. {
  681. $oPage->SetCurrentTab("Contacts");
  682. $oPage->p("$count person(s) located to this location:");
  683. $this->DisplaySet($oPage, $oSet);
  684. }
  685. $oSearchFilter = new CMDBSearchFilter('lnkDocumentRealObject');
  686. $oSearchFilter->AddCondition('object_id', $this->GetKey(), '=');
  687. $oSet = new CMDBObjectSet($oSearchFilter);
  688. $count = $oSet->Count();
  689. if ($count > 0)
  690. {
  691. $oPage->SetCurrentTab("Details");
  692. $oPage->p("$count Document(s) linked to this location:");
  693. $this->DisplaySet($oPage, $oSet);
  694. }
  695. */
  696. }
  697. public function Generate(cmdbDataGenerator $oGenerator)
  698. {
  699. parent::Generate($oGenerator);
  700. $sLastName = $oGenerator->GenerateLastName();
  701. $sCityName = $oGenerator->GenerateCityName();
  702. $this->Set('name', $sCityName);
  703. $this->Set('country', $oGenerator->GenerateCountryName());
  704. $this->Set('address', $oGenerator->GenerateString("number(1-999)| |enum(rue,rue,rue,place,avenue,av.,route de)| |$sLastName| |number(0000-9999)|0 |$sCityName"));
  705. $this->Set('parent_location_id', 1);
  706. }
  707. }
  708. ////////////////////////////////////////////////////////////////////////////////////
  709. /**
  710. * Circuit (one end only)
  711. */
  712. ////////////////////////////////////////////////////////////////////////////////////
  713. class bizCircuit extends logInfra
  714. {
  715. public static function Init()
  716. {
  717. $aParams = array
  718. (
  719. "category" => "bizmodel,searchable",
  720. "name" => "Circuit",
  721. "description" => "Any type of circuit",
  722. "key_type" => "",
  723. "key_label" => "id",
  724. "name_attcode" => "name",
  725. "state_attcode" => "",
  726. "reconc_keys" => array("org_id", "provider_id", "carrier_ref", "name"), // inherited attributes
  727. "db_table" => "circuits",
  728. "db_key_field" => "id",
  729. "db_finalclass_field" => "",
  730. "display_template" => "../business/templates/Circuits.html",
  731. );
  732. MetaModel::Init_Params($aParams);
  733. MetaModel::Init_InheritAttributes();
  734. MetaModel::Init_AddAttribute(new AttributeString("speed", array("label"=>"speed", "description"=>"speed of the circuit", "allowed_values"=>null, "sql"=>"speed", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  735. MetaModel::Init_AddAttribute(new AttributeExternalKey("location1_id", array("targetclass"=>"bizLocation", "label"=>"Location 1", "description"=>"Id of the location 1", "allowed_values"=>null, "sql"=>"location1_id", "is_null_allowed"=>false,"on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  736. MetaModel::Init_AddAttribute(new AttributeExternalField("location1_name", array("label"=>"Location 1", "description"=>"Name of the location", "allowed_values"=>null, "extkey_attcode"=> 'location1_id', "target_attcode"=>"name")));
  737. MetaModel::Init_AddAttribute(new AttributeExternalKey("location2_id", array("targetclass"=>"bizLocation", "label"=>"Location 2", "description"=>"Id of the location 2", "allowed_values"=>null, "sql"=>"location2_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL,"depends_on"=>array())));
  738. MetaModel::Init_AddAttribute(new AttributeExternalField("location2_name", array("label"=>"Location 2", "description"=>"Name of the location", "allowed_values"=>null, "extkey_attcode"=> 'location2_id', "target_attcode"=>"name")));
  739. MetaModel::Init_AddAttribute(new AttributeExternalKey("interface1_id", array("targetclass"=>"bizInterface", "label"=>"Interface 1", "description"=>"id of the interface 1", "allowed_values"=>null, "sql"=>"interface1_id", "is_null_allowed"=>false,"on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  740. MetaModel::Init_AddAttribute(new AttributeExternalField("interface1_name", array("label"=>"Interface", "description"=>"Name of the interface 1", "allowed_values"=>null, "extkey_attcode"=> 'interface1_id', "target_attcode"=>"name")));
  741. MetaModel::Init_AddAttribute(new AttributeExternalField("device1_name", array("label"=>"Device 1", "description"=>"Name of the device 1", "allowed_values"=>null, "extkey_attcode"=> 'interface1_id', "target_attcode"=>"device_name")));
  742. MetaModel::Init_AddAttribute(new AttributeExternalKey("interface2_id", array("targetclass"=>"bizInterface", "label"=>"Interface 2", "description"=>"id of the interface 2", "allowed_values"=>null, "sql"=>"interface2_id", "is_null_allowed"=>false,"on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  743. MetaModel::Init_AddAttribute(new AttributeExternalField("interface2_name", array("label"=>"Interface", "description"=>"Name of the interface 2", "allowed_values"=>null, "extkey_attcode"=> 'interface2_id', "target_attcode"=>"name")));
  744. MetaModel::Init_AddAttribute(new AttributeExternalField("device2_name", array("label"=>"Interface", "description"=>"Name of the device 2", "allowed_values"=>null, "extkey_attcode"=> 'interface2_id', "target_attcode"=>"device_name")));
  745. MetaModel::Init_AddAttribute(new AttributeExternalKey("provider_id", array("targetclass"=>"bizOrganization", "label"=>"Carrier ID", "description"=>"Organization ID of the provider of the Circuit", "allowed_values"=>null, "sql"=>"provider_id", "is_null_allowed"=>false,"on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  746. MetaModel::Init_AddAttribute(new AttributeExternalField("carrier_name", array("label"=>"Carrier", "description"=>"Name of the carrier", "allowed_values"=>null, "extkey_attcode"=> 'provider_id', "target_attcode"=>"name")));
  747. MetaModel::Init_AddAttribute(new AttributeString("carrier_ref", array("label"=>"Carrier reference", "description"=>"reference of the circuit used by the carrier", "allowed_values"=>null, "sql"=>"carrier_ref", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  748. MetaModel::Init_InheritFilters();
  749. MetaModel::Init_AddFilterFromAttribute("speed");
  750. MetaModel::Init_AddFilterFromAttribute("location1_id");
  751. MetaModel::Init_AddFilterFromAttribute("location2_id");
  752. MetaModel::Init_AddFilterFromAttribute("interface1_id");
  753. MetaModel::Init_AddFilterFromAttribute("interface2_id");
  754. MetaModel::Init_AddFilterFromAttribute("provider_id");
  755. MetaModel::Init_AddFilterFromAttribute("carrier_ref");
  756. // Display lists
  757. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'speed', 'location1_id','interface1_id','device1_name','location2_id','interface2_id','device2_name','provider_id', 'carrier_ref')); // Attributes to be displayed for the complete details
  758. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'provider_id', 'carrier_ref', 'speed')); // Attributes to be displayed for a list
  759. // Search criteria
  760. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'location1_id','location2_id','carrier_ref', 'speed', 'provider_id')); // Criteria of the std search form
  761. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'location1_id','location2_id','carrier_ref', 'speed', 'provider_id')); // Criteria of the advanced search form
  762. }
  763. public function ComputeValues()
  764. {
  765. /*
  766. $oLocatedObject = MetaModel::GetObject("Located Object", $this->Get("located_object_id"));
  767. $this->Set("location_id", $oLocatedObject->Get("location_id"));
  768. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  769. $this->Set("location_name", "abc (to be finalized)");
  770. $this->Set("device_id", $oLocatedObject->Get("device_id"));
  771. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  772. $this->Set("device_name", "abc (to be finalized)");
  773. $this->Set("interface_id", $oLocatedObject->Get("interface_id"));
  774. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  775. $this->Set("interface_name", "abc (to be finalized)");
  776. */
  777. }
  778. }
  779. ////////////////////////////////////////////////////////////////////////////////////
  780. /**
  781. * Any Device Network Interface
  782. */
  783. ////////////////////////////////////////////////////////////////////////////////////
  784. class bizInterface extends logInfra
  785. {
  786. public static function Init()
  787. {
  788. $aParams = array
  789. (
  790. "category" => "bizmodel,searchable",
  791. "name" => "Interface",
  792. "description" => "Interface",
  793. "key_type" => "",
  794. "key_label" => "id",
  795. "name_attcode" => "name",
  796. "state_attcode" => "",
  797. "reconc_keys" => array("org_id", "device_id", "name"),
  798. "db_table" => "interfaces",
  799. "db_key_field" => "id",
  800. "db_finalclass_field" => "",
  801. "display_template" => "../business/templates/interface.html",
  802. );
  803. MetaModel::Init_Params($aParams);
  804. MetaModel::Init_InheritAttributes();
  805. MetaModel::Init_AddAttribute(new AttributeExternalKey("device_id", array("targetclass"=>"bizDevice", "label"=>"Device", "description"=>"Device on which the interface is physically located", "allowed_values"=>null, "sql"=>"device_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  806. MetaModel::Init_AddAttribute(new AttributeExternalField("device_name", array("label"=>"Device", "description"=>"name of the device on which the interface is located", "allowed_values"=>null, "extkey_attcode"=> 'device_id', "target_attcode"=>"name")));
  807. MetaModel::Init_AddAttribute(new AttributeExternalField("device_location_id", array("label"=>"Device location", "description"=>"location of the device on which the interface is located", "allowed_values"=>null, "extkey_attcode"=> 'device_id', "target_attcode"=>"location_id")));
  808. MetaModel::Init_AddAttribute(new AttributeExternalField("device_location_name", array("label"=>"Device location", "description"=>"name of the location of the device on which the interface is located", "allowed_values"=>null, "extkey_attcode"=> 'device_id', "target_attcode"=>"location_name")));
  809. MetaModel::Init_AddAttribute(new AttributeEnum("logical_type", array("label"=>"Logical type", "description"=>"Logical type of interface", "allowed_values"=>new ValueSetEnum("primary,secondary,backup,port,logical"), "sql"=>"logical_type", "default_value"=>"port", "is_null_allowed"=>false, "depends_on"=>array())));
  810. MetaModel::Init_AddAttribute(new AttributeEnum("physical_type", array("label"=>"Physical type", "description"=>"Physical type of interface", "allowed_values"=>new ValueSetEnum("ethernet,framerelay,atm,vlan"), "sql"=>"physical_type", "default_value"=>"ethernet", "is_null_allowed"=>false, "depends_on"=>array())));
  811. MetaModel::Init_AddAttribute(new AttributeString("ip_address", array("label"=>"IP address", "description"=>"address IP for this interface", "allowed_values"=>null, "sql"=>"ip_address", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  812. MetaModel::Init_AddAttribute(new AttributeString("mask", array("label"=>"Subnet Mask", "description"=>"Subnet mask for this interface", "allowed_values"=>null, "sql"=>"mask", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  813. MetaModel::Init_AddAttribute(new AttributeString("mac", array("label"=>"MAC address", "description"=>"MAC address for this interface", "allowed_values"=>null, "sql"=>"mac", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  814. MetaModel::Init_AddAttribute(new AttributeString("speed", array("label"=>"Speed (Kb/s)", "description"=>"speed of this interface", "allowed_values"=>null, "sql"=>"speed", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  815. MetaModel::Init_AddAttribute(new AttributeEnum("duplex", array("label"=>"Duplex", "description"=>"Duplex configured for this interface", "allowed_values"=>new ValueSetEnum("half,full,unknown"), "sql"=>"duplex", "default_value"=>"unknown", "is_null_allowed"=>true, "depends_on"=>array())));
  816. MetaModel::Init_AddAttribute(new AttributeExternalKey("if_connected_id", array("targetclass"=>"bizInterface", "label"=>"Connected interface", "description"=>"interface connected to this one", "allowed_values"=>null, "sql"=>"ext_if_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  817. MetaModel::Init_AddAttribute(new AttributeExternalField("if_connected_name", array("label"=>"Connected interface", "description"=>"name of the interface connected to this one", "allowed_values"=>null, "extkey_attcode"=> 'if_connected_id', "target_attcode"=>"name")));
  818. MetaModel::Init_AddAttribute(new AttributeExternalField("if_connected_device", array("label"=>"Connected device", "description"=>"name of the device connected to this interface", "allowed_values"=>null, "extkey_attcode"=> 'if_connected_id', "target_attcode"=>"device_name")));
  819. MetaModel::Init_InheritFilters();
  820. MetaModel::Init_AddFilterFromAttribute("device_id");
  821. MetaModel::Init_AddFilterFromAttribute("device_name");
  822. MetaModel::Init_AddFilterFromAttribute("device_location_id");
  823. MetaModel::Init_AddFilterFromAttribute("logical_type");
  824. MetaModel::Init_AddFilterFromAttribute("physical_type");
  825. MetaModel::Init_AddFilterFromAttribute("ip_address");
  826. MetaModel::Init_AddFilterFromAttribute("mac");
  827. MetaModel::Init_AddFilterFromAttribute("if_connected_id");
  828. // Display lists
  829. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'device_id', 'device_location_id','severity','logical_type','physical_type','ip_address','mask','mac','speed','duplex','if_connected_name','if_connected_device')); // Attributes to be displayed for the complete details
  830. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'device_id','severity')); // Attributes to be displayed for a list
  831. // Search criteria
  832. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'ip_address','mac','device_id')); // Criteria of the std search form
  833. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'device_id', 'org_id')); // Criteria of the advanced search form
  834. }
  835. function DisplayDetails(web_page $oPage)
  836. {
  837. parent::DisplayDetails($oPage);
  838. /*
  839. $oSearchFilter = new CMDBSearchFilter('lnkInterfaces');
  840. $oSearchFilter->AddCondition('interface1_id', $this->GetKey(), '=');
  841. $oSet = new CMDBObjectSet($oSearchFilter);
  842. $count = $oSet->Count();
  843. if ($count > 0)
  844. {
  845. $oPage->SetCurrentTab("Connected interfaces");
  846. $oPage->p("$count interface(s) connected to this device:");
  847. $this->DisplaySet($oPage, $oSet);
  848. }
  849. */
  850. }
  851. public function ComputeValues()
  852. {
  853. /*
  854. // my location is the location of my device
  855. $oDevice = MetaModel::GetObject("bizDevice", $this->Get("device_id"));
  856. $this->Set("location_id", $oDevice->Get("location_id"));
  857. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  858. $this->Set("location_name", "abc (to be finalized)");
  859. // my device is given by my Creator
  860. // my interface is myself
  861. $this->Set("interface_id", $this->GetKey());
  862. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  863. $this->Set("interface_name", "abc (to be finalized)");
  864. */
  865. }
  866. }
  867. ////////////////////////////////////////////////////////////////////////////////////
  868. /**
  869. * n-n link between any Interfaces
  870. */
  871. ////////////////////////////////////////////////////////////////////////////////////
  872. /*
  873. class lnkInterfaces extends cmdbAbstractObject
  874. {
  875. public static function Init()
  876. {
  877. $aParams = array
  878. (
  879. "category" => "bizmodel,searchable",
  880. "name" => "InterfacesLinks",
  881. "description" => "A link between two interfaces",
  882. "key_type" => "autoincrement",
  883. "key_label" => "link_id",
  884. "name_attcode" => "link_type",
  885. "state_attcode" => "",
  886. "reconc_keys" => array("interface1_id", "interface2_id"),
  887. "db_table" => "interfaces_links",
  888. "db_key_field" => "link_id",
  889. "db_finalclass_field" => "",
  890. "display_template" => "../business/templates/default.html",
  891. );
  892. MetaModel::Init_Params($aParams);
  893. MetaModel::Init_AddAttribute(new AttributeExternalKey("interface1_id", array("targetclass"=>"bizInterface", "label"=>"Interface", "description"=>"The interface1", "sql"=>"interface1_id", "allowed_values"=> null, "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  894. MetaModel::Init_AddAttribute(new AttributeExternalField("interface1_name", array("label"=>"Interface1 Name", "description"=>"name of the interface1", "extkey_attcode"=> 'interface1_id', "allowed_values"=> null, "target_attcode"=>"name")));
  895. MetaModel::Init_AddAttribute(new AttributeExternalKey("interface2_id", array("targetclass"=>"bizInterface", "label"=>"Interface", "description"=>"The interface2", "sql"=>"interface2_id", "allowed_values"=> null, "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  896. MetaModel::Init_AddAttribute(new AttributeExternalField("interface2_name", array("label"=>"Interface2 Name", "description"=>"name of the interface2", "extkey_attcode"=> 'interface2_id', "allowed_values"=> null, "target_attcode"=>"name")));
  897. MetaModel::Init_AddAttribute(new AttributeExternalField("interface1_device_id", array("label"=>"Device", "description"=>"device", "extkey_attcode"=> 'interface1_id', "allowed_values"=> null, "target_attcode"=>"device_id")));
  898. MetaModel::Init_AddAttribute(new AttributeExternalField("interface1_device_name", array("label"=>"Device Name", "description"=>"name of the device", "extkey_attcode"=> 'interface1_id', "allowed_values"=> null, "target_attcode"=>"device_name")));
  899. MetaModel::Init_AddAttribute(new AttributeExternalField("interface2_device_id", array("label"=>"Device", "description"=>"device", "extkey_attcode"=> 'interface2_id', "allowed_values"=> null, "target_attcode"=>"device_id")));
  900. MetaModel::Init_AddAttribute(new AttributeExternalField("interface2_device_name", array("label"=>"Device Name", "description"=>"name of the device", "extkey_attcode"=> 'interface2_id', "allowed_values"=> null, "target_attcode"=>"device_name")));
  901. MetaModel::Init_AddAttribute(new AttributeString("link_type", array("label"=>"Link Type", "description"=>"More information", "sql"=>"link_type", "default_value"=>"", "allowed_values"=> null, "is_null_allowed"=>false, "depends_on"=>array())));
  902. MetaModel::Init_AddFilterFromAttribute("interface1_id");
  903. MetaModel::Init_AddFilterFromAttribute("interface1_name");
  904. MetaModel::Init_AddFilterFromAttribute("interface2_id");
  905. MetaModel::Init_AddFilterFromAttribute("interface2_name");
  906. MetaModel::Init_AddFilterFromAttribute("interface2_device_name");
  907. MetaModel::Init_AddFilterFromAttribute("link_type");
  908. // Display lists
  909. MetaModel::Init_SetZListItems('details', array('interface1_id', 'interface2_id', 'link_type')); // Attributes to be displayed for the complete details
  910. MetaModel::Init_SetZListItems('list', array('interface1_id', 'interface1_device_id', 'interface2_id', 'interface2_device_id', 'link_type')); // Attributes to be displayed for the complete details
  911. }
  912. }
  913. */
  914. ////////////////////////////////////////////////////////////////////////////////////
  915. /**
  916. * A subnet
  917. */
  918. ////////////////////////////////////////////////////////////////////////////////////
  919. class bizSubnet extends logInfra
  920. {
  921. public static function Init()
  922. {
  923. $aParams = array
  924. (
  925. "category" => "bizmodel,searchable",
  926. "name" => "Subnet",
  927. "description" => "Logical or physical subnet",
  928. "key_type" => "",
  929. "key_label" => "id",
  930. "name_attcode" => "name",
  931. "state_attcode" => "",
  932. "reconc_keys" => array("org_id", "name"), // inherited attributes
  933. "db_table" => "subnets",
  934. "db_key_field" => "id",
  935. "db_finalclass_field" => "",
  936. "display_template" => "",
  937. );
  938. MetaModel::Init_Params($aParams);
  939. MetaModel::Init_InheritAttributes();
  940. MetaModel::Init_AddAttribute(new AttributeString("ip", array("label"=>"IP", "description"=>"IP", "allowed_values"=>null, "sql"=>"ip", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  941. MetaModel::Init_AddAttribute(new AttributeString("mask", array("label"=>"IP mask", "description"=>"IP mask", "allowed_values"=>null, "sql"=>"mask", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  942. MetaModel::Init_InheritFilters();
  943. MetaModel::Init_AddFilterFromAttribute("ip");
  944. MetaModel::Init_AddFilterFromAttribute("mask");
  945. // Display lists
  946. MetaModel::Init_SetZListItems('details', array('name', 'ip','mask')); // Attributes to be displayed for the complete details
  947. MetaModel::Init_SetZListItems('list', array('name', 'ip', 'mask')); // Attributes to be displayed for a list
  948. // Search criteria
  949. MetaModel::Init_SetZListItems('standard_search', array('name', 'ip','mask')); // Criteria of the std search form
  950. MetaModel::Init_SetZListItems('advanced_search', array('name', 'ip','mask')); // Criteria of the advanced search form
  951. }
  952. function DisplayBareRelations(web_page $oPage)
  953. {
  954. parent::DisplayBareRelations($oPage);
  955. $oPage->SetCurrentTabContainer('Related Objects');
  956. $oPage->SetCurrentTab('IP Usage');
  957. $bit_ip = ip2long($this->Get('ip'));
  958. $bit_mask = ip2long($this->Get('mask'));
  959. $sIPMin = long2ip($bit_ip & $bit_mask);
  960. $sIPMax = long2ip(($bit_ip | (~$bit_mask)) - 1);
  961. $oPage->p("Interfaces having an IP in the range: <em>$sIPMin</em> to <em>$sIPMax</em>");
  962. $oIfSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT bizInterface AS if WHERE INET_ATON(if.ip_address) >= INET_ATON('$sIPMin') AND INET_ATON(if.ip_address) <= INET_ATON('$sIPMax')"));
  963. self::DisplaySet($oPage, $oIfSet);
  964. $iCountUsed = $oIfSet->Count();
  965. $iCountRange = ip2long($sIPMax) - ip2long($sIPMin);
  966. $iFreeCount = $iCountRange - $iCountUsed;
  967. $oPage->SetCurrentTab('Free IPs');
  968. $oPage->p("Free IPs: $iFreeCount");
  969. $oPage->p("Here is an extract of 10 free IP addresses");
  970. $aUsedIPs = $oIfSet->GetColumnAsArray('ip_address', false);
  971. $i = 0;
  972. while ($i < min($iFreeCount, 10))
  973. {
  974. $i++;
  975. $iAnIP = ip2long($sIPMin) + $i;
  976. if (in_array($iAnIP, $aUsedIPs)) continue;
  977. $sAnIP = long2ip($iAnIP);
  978. $oPage->p($sAnIP);
  979. }
  980. }
  981. }
  982. ////////////////////////////////////////////////////////////////////////////////////
  983. /**
  984. * Any electronic device
  985. */
  986. ////////////////////////////////////////////////////////////////////////////////////
  987. class bizDevice extends logInfra
  988. {
  989. public static function Init()
  990. {
  991. $aParams = array
  992. (
  993. "category" => "bizmodel,searchable",
  994. "name" => "Device",
  995. "description" => "Electronic devices",
  996. "key_type" => "",
  997. "key_label" => "id",
  998. "name_attcode" => "name",
  999. "state_attcode" => "",
  1000. "reconc_keys" => array("org_id", "name"), // inherited attributes
  1001. "db_table" => "devices",
  1002. "db_key_field" => "id",
  1003. "db_finalclass_field" => "",
  1004. "display_template" => "../business/templates/default.html",
  1005. );
  1006. MetaModel::Init_Params($aParams);
  1007. MetaModel::Init_InheritAttributes();
  1008. MetaModel::Init_AddAttribute(new AttributeExternalKey("location_id", array("targetclass"=>"bizLocation", "label"=>"Location", "description"=>"where is the located object physically located", "allowed_values"=>null, "sql"=>"location_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  1009. MetaModel::Init_AddAttribute(new AttributeExternalField("location_name", array("label"=>"Location Name", "description"=>"name of the location", "allowed_values"=>null, "extkey_attcode"=> 'location_id', "target_attcode"=>"name")));
  1010. MetaModel::Init_AddAttribute(new AttributeExternalField("country", array("label"=>"Country", "description"=>"country where the device is located", "allowed_values"=>null, "extkey_attcode"=> 'location_id', "target_attcode"=>"country")));
  1011. MetaModel::Init_AddAttribute(new AttributeString("brand", array("label"=>"Brand", "description"=>"The manufacturer of the device", "allowed_values"=>null, "sql"=>"brand", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1012. MetaModel::Init_AddAttribute(new AttributeString("model", array("label"=>"Model", "description"=>"The model number of the device", "allowed_values"=>null, "sql"=>"model", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1013. MetaModel::Init_AddAttribute(new AttributeString("serial_number", array("label"=>"Serial Number", "description"=>"The serial number of the device", "allowed_values"=>null, "sql"=>"serial_number", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1014. MetaModel::Init_AddAttribute(new AttributeString("mgmt_ip", array("label"=>"Mgmt IP", "description"=>"Management IP", "allowed_values"=>null, "sql"=>"mgmt_ip", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1015. MetaModel::Init_InheritFilters();
  1016. MetaModel::Init_AddFilterFromAttribute("location_id");
  1017. MetaModel::Init_AddFilterFromAttribute("country");
  1018. MetaModel::Init_AddFilterFromAttribute("brand");
  1019. MetaModel::Init_AddFilterFromAttribute("model");
  1020. MetaModel::Init_AddFilterFromAttribute("serial_number");
  1021. MetaModel::Init_AddFilterFromAttribute("mgmt_ip");
  1022. }
  1023. public static function GetRelationQueries($sRelCode)
  1024. {
  1025. switch ($sRelCode)
  1026. {
  1027. case "impacts":
  1028. $aRels = array(
  1029. "connected device" => array("sQuery"=>"bizDevice: PKEY IS device_id IN (bizInterface: PKEY IS interface2_id IN (lnkInterfaces: interface1_id IN (bizInterface: device_id = \$[this.pkey::])))", "bPropagate"=>true, "iDistance"=>3),
  1030. "hosted app" => array("sQuery"=>"bizApplication: infra_id = \$[this.pkey::]", "bPropagate"=>true, "iDistance"=>3),
  1031. );
  1032. return array_merge($aRels, parent::GetRelationQueries($sRelCode));
  1033. }
  1034. }
  1035. public function ComputeValues()
  1036. {
  1037. /*
  1038. // my location is the location of my device (external field)
  1039. $this->Set("location_id", $this->Get("device_location_id"));
  1040. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  1041. $this->Set("location_name", "abc (to be finalized)");
  1042. // my device is myself
  1043. $this->Set("device_id", $this->GetKey());
  1044. // my interface is "nothing"
  1045. $this->Set("interface_id", null);
  1046. */
  1047. }
  1048. }
  1049. ////////////////////////////////////////////////////////////////////////////////////
  1050. /**
  1051. * A personal computer
  1052. */
  1053. ////////////////////////////////////////////////////////////////////////////////////
  1054. class bizPC extends bizDevice
  1055. {
  1056. public static function Init()
  1057. {
  1058. $aParams = array
  1059. (
  1060. "category" => "bizmodel,searchable",
  1061. "name" => "PC",
  1062. "description" => "Personal Computers",
  1063. "key_type" => "",
  1064. "key_label" => "id",
  1065. "name_attcode" => "name",
  1066. "state_attcode" => "",
  1067. "reconc_keys" => array("org_id", "name"), // inherited attributes
  1068. "db_table" => "pcs",
  1069. "db_key_field" => "id",
  1070. "db_finalclass_field" => "",
  1071. "display_template" => "../business/templates/pc.html",
  1072. );
  1073. MetaModel::Init_Params($aParams);
  1074. MetaModel::Init_InheritAttributes();
  1075. MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type of computer", "allowed_values"=>new ValueSetEnum("desktop PC,laptop"), "sql"=>"type", "default_value"=>"desktop PC", "is_null_allowed"=>false, "depends_on"=>array())));
  1076. MetaModel::Init_AddAttribute(new AttributeString("memory_size", array("label"=>"Memory Size", "description"=>"Size of the memory", "allowed_values"=>null, "sql"=>"memory_size", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1077. MetaModel::Init_AddAttribute(new AttributeString("cpu", array("label"=>"CPU", "description"=>"CPU type", "allowed_values"=>null, "sql"=>"cpu_type", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1078. MetaModel::Init_AddAttribute(new AttributeString("hdd_size", array("label"=>"HDD Size", "description"=>"Size of the hard drive", "allowed_values"=>null, "sql"=>"hdd_size", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1079. MetaModel::Init_AddAttribute(new AttributeString("os_family", array("label"=>"OS Family", "description"=>"Type of operating system", "allowed_values"=>null, "sql"=>"os_family", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1080. MetaModel::Init_AddAttribute(new AttributeString("os_version", array("label"=>"OS Version", "description"=>"Detailed version number of the operating system", "allowed_values"=>null, "sql"=>"os_version", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1081. MetaModel::Init_AddAttribute(new AttributeString("shipment_number", array("label"=>"Shipment Code", "description"=>"Number for tracking shipment", "allowed_values"=>null, "sql"=>"shipment_number", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1082. MetaModel::Init_AddAttribute(new AttributeString("default_gateway", array("label"=>"Default Gateway", "description"=>"Default Gateway for this device", "allowed_values"=>null, "sql"=>"default_gateway", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1083. MetaModel::Init_InheritFilters();
  1084. MetaModel::Init_AddFilterFromAttribute("type");
  1085. MetaModel::Init_AddFilterFromAttribute("memory_size");
  1086. MetaModel::Init_AddFilterFromAttribute("cpu");
  1087. MetaModel::Init_AddFilterFromAttribute("hdd_size");
  1088. MetaModel::Init_AddFilterFromAttribute("os_family");
  1089. MetaModel::Init_AddFilterFromAttribute("os_version");
  1090. // Display lists
  1091. MetaModel::Init_SetZListItems('details', array('name', 'status','severity', 'org_id', 'location_id', 'brand', 'model','os_family','os_version','mgmt_ip','default_gateway','shipment_number','serial_number', 'type', 'cpu', 'memory_size', 'hdd_size')); // Attributes to be displayed for the complete details
  1092. MetaModel::Init_SetZListItems('list', array('name', 'status', 'severity', 'org_id', 'location_id', 'brand', 'model', 'type')); // Attributes to be displayed for a list
  1093. // Search criteria
  1094. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'severity','type', 'brand', 'model','os_family','mgmt_ip')); // Criteria of the std search form
  1095. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'type', 'brand', 'model', 'cpu', 'memory_size', 'hdd_size')); // Criteria of the advanced search form
  1096. }
  1097. function DisplayDetails(web_page $oPage)
  1098. {
  1099. parent::DisplayDetails($oPage);
  1100. /*
  1101. parent::DisplayDetails($oPage);
  1102. $oSearchFilter = new CMDBSearchFilter('lnkContactRealObject');
  1103. $oSearchFilter->AddCondition('object_id', $this->GetKey(), '=');
  1104. $oSet = new CMDBObjectSet($oSearchFilter);
  1105. $count = $oSet->Count();
  1106. if ($count > 0)
  1107. {
  1108. $oPage->SetCurrentTab("Contacts");
  1109. $oPage->p("$count contact(s) linked to this PC:");
  1110. $this->DisplaySet($oPage, $oSet);
  1111. }
  1112. $oSearchFilter = new CMDBSearchFilter('bizInterface');
  1113. $oSearchFilter->AddCondition('device_id', $this->GetKey(), '=');
  1114. $oSet = new CMDBObjectSet($oSearchFilter);
  1115. $count = $oSet->Count();
  1116. if ($count > 0)
  1117. {
  1118. $oPage->SetCurrentTab("Interfaces");
  1119. $oPage->p("$count interface(s) for this device:");
  1120. $this->DisplaySet($oPage, $oSet);
  1121. }
  1122. */
  1123. }
  1124. public function Generate(cmdbDataGenerator $oGenerator)
  1125. {
  1126. $this->Set('org_id', $oGenerator->GetOrganizationId());
  1127. $this->Set('location_id', $oGenerator->GenerateKey("bizLocation", array('org_id' =>$oGenerator->GetOrganizationId() )));
  1128. $this->Set('name', $oGenerator->GenerateString("enum(pc,pc,pc,pc,pc,win,redhat,linux,srv,workstation)|number(000-999)|.|domain()"));
  1129. $this->Set('brand', $oGenerator->GenerateString("enum(Hewlett-Packard,Dell,Compaq,Siemens,Packard Bell,IBM,Gateway,Medion,Sony)"));
  1130. $this->Set('model', $oGenerator->GenerateString("enum(Vectra,Deskpro,Dimension,Optiplex,Latitude,Precision,Vaio)"));
  1131. $this->Set('serial_number', $oGenerator->GenerateString("enum(FR,US,TW,CH)|number(000000-999999)"));
  1132. $this->Set('memory_size', $oGenerator->GenerateString("enum(128,256,384,512,768,1024,1536,2048)"));
  1133. $this->Set('cpu', $oGenerator->GenerateString("enum(Pentium III,Pentium 4, Pentium M,Core Duo,Core 2 Duo,Celeron,Opteron,Thurion,Athlon)"));
  1134. $this->Set('hdd_size', $oGenerator->GenerateString("enum(40,60,80,120,200,300)"));
  1135. }
  1136. }
  1137. ////////////////////////////////////////////////////////////////////////////////////
  1138. /**
  1139. * A server
  1140. */
  1141. ////////////////////////////////////////////////////////////////////////////////////
  1142. class bizServer extends bizDevice
  1143. {
  1144. public static function Init()
  1145. {
  1146. $aParams = array
  1147. (
  1148. "category" => "bizmodel,searchable",
  1149. "name" => "Server",
  1150. "description" => "Computer Servers",
  1151. "key_type" => "",
  1152. "key_label" => "id",
  1153. "name_attcode" => "name",
  1154. "state_attcode" => "status",
  1155. "reconc_keys" => array("org_id", "name"), // inherited attributes
  1156. "db_table" => "servers",
  1157. "db_key_field" => "id",
  1158. "db_finalclass_field" => "",
  1159. "display_template" => "../business/templates/server.html",
  1160. );
  1161. MetaModel::Init_Params($aParams);
  1162. MetaModel::Init_InheritAttributes();
  1163. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Status of the server", "allowed_values"=>new ValueSetEnum("InStore,Shipped,Plugged,ProductionCandidate,InProduction,BeingDeconfigured,Obsolete"), "sql"=>"status", "default_value"=>"InStore", "is_null_allowed"=>false, "depends_on"=>array())));
  1164. MetaModel::Init_AddAttribute(new AttributeString("memory_size", array("label"=>"Memory Size", "description"=>"Size of the memory", "allowed_values"=>null, "sql"=>"memory_size", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1165. MetaModel::Init_AddAttribute(new AttributeString("cpu", array("label"=>"CPU type", "description"=>"CPU type", "allowed_values"=>null, "sql"=>"cpu_type", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1166. MetaModel::Init_AddAttribute(new AttributeString("number_of_cpus", array("label"=>"Number of CPUs", "description"=>"Number of CPUs", "allowed_values"=>null, "sql"=>"number_of_cpus", "default_value"=>"1", "is_null_allowed"=>true, "depends_on"=>array())));
  1167. MetaModel::Init_AddAttribute(new AttributeString("hdd_size", array("label"=>"HDD Size", "description"=>"Size of the hard drive", "allowed_values"=>null, "sql"=>"hdd_size", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1168. MetaModel::Init_AddAttribute(new AttributeString("hdd_free_size", array("label"=>"Free HDD Size", "description"=>"Size of the free space on the hard drive(s)", "allowed_values"=>null, "sql"=>"hdd_free_size", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1169. MetaModel::Init_AddAttribute(new AttributeString("os_family", array("label"=>"OS Family", "description"=>"Type of operating system", "allowed_values"=>null, "sql"=>"os_family", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1170. MetaModel::Init_AddAttribute(new AttributeString("os_version", array("label"=>"OS Version", "description"=>"Detailed version number of the operating system", "allowed_values"=>null, "sql"=>"os_version", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1171. MetaModel::Init_AddAttribute(new AttributeString("shipment_number", array("label"=>"Shipment number", "description"=>"Number for tracking shipment", "allowed_values"=>null, "sql"=>"shipment_number", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1172. MetaModel::Init_AddAttribute(new AttributeString("default_gateway", array("label"=>"Default Gateway", "description"=>"Default Gateway for this device", "allowed_values"=>null, "sql"=>"default_gateway", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1173. MetaModel::Init_InheritFilters();
  1174. MetaModel::Init_AddFilterFromAttribute("memory_size");
  1175. MetaModel::Init_AddFilterFromAttribute("cpu");
  1176. MetaModel::Init_AddFilterFromAttribute("number_of_cpus");
  1177. MetaModel::Init_AddFilterFromAttribute("hdd_size");
  1178. MetaModel::Init_AddFilterFromAttribute("hdd_free_size");
  1179. MetaModel::Init_AddFilterFromAttribute("os_family");
  1180. MetaModel::Init_AddFilterFromAttribute("os_version");
  1181. // Life cycle
  1182. MetaModel::Init_DefineState("InStore", array("label"=>"InStore", "description"=>"Device in store", "attribute_inherit"=>null,
  1183. "attribute_list"=>array()));
  1184. MetaModel::Init_DefineState("Shipped", array("label"=>"Shipped", "description"=>"The device had been shipped to future location", "attribute_inherit"=>null,
  1185. "attribute_list"=>array("location_id"=>OPT_ATT_MANDATORY,"serial_number"=>OPT_ATT_MANDATORY,"shipment_number"=>OPT_ATT_MANDATORY)));
  1186. MetaModel::Init_DefineState("Plugged", array("label"=>"Plugged", "description"=>"The device is connected to the network", "attribute_inherit"=>null,
  1187. "attribute_list"=>array("location_id"=>OPT_ATT_MANDATORY,"mgmt_ip"=>OPT_ATT_MANDATORY,"name"=>OPT_ATT_MANDATORY)));
  1188. MetaModel::Init_DefineState("ProductionCandidate", array("label"=>"Pre-Production", "description"=>"The device is ready to be move to production", "attribute_inherit"=>null,
  1189. "attribute_list"=>array()));
  1190. MetaModel::Init_DefineState("InProduction", array("label"=>"Production", "description"=>"The device is on production", "attribute_inherit"=>null,
  1191. "attribute_list"=>array()));
  1192. MetaModel::Init_DefineState("BeingDeconfigured", array("label"=>"BeingDeconfigured", "description"=>"The device is about to be removed from is current location", "attribute_inherit"=>null,
  1193. "attribute_list"=>array()));
  1194. MetaModel::Init_DefineState("Obsolete", array("label"=>"Obsolete", "description"=>"The device is no more used", "attribute_inherit"=>null,
  1195. "attribute_list"=>array()));
  1196. MetaModel::Init_DefineStimulus("ev_store", new StimulusUserAction(array("label"=>"Store this server", "description"=>"This server is move to storage")));
  1197. MetaModel::Init_DefineStimulus("ev_ship", new StimulusUserAction(array("label"=>"Ship this server", "description"=>"This server is shipped to futur location")));
  1198. MetaModel::Init_DefineStimulus("ev_plug", new StimulusUserAction(array("label"=>"Plug this server", "description"=>"The server is pluuged on the network")));
  1199. MetaModel::Init_DefineStimulus("ev_configuration_finished", new StimulusUserAction(array("label"=>"Configuration finished", "description"=>"The device is ready to move to production evaluation")));
  1200. MetaModel::Init_DefineStimulus("ev_val_failed", new StimulusUserAction(array("label"=>"Review configuration", "description"=>"The configuration for this server is not completed")));
  1201. MetaModel::Init_DefineStimulus("ev_mtp", new StimulusUserAction(array("label"=>"Move to Production", "description"=>"The server is moved to production")));
  1202. MetaModel::Init_DefineStimulus("ev_decommission", new StimulusUserAction(array("label"=>"Decommission", "description"=>"The server is being decommissioned")));
  1203. MetaModel::Init_DefineStimulus("ev_obsolete", new StimulusUserAction(array("label"=>"Obsolete", "description"=>"The server is no more used")));
  1204. MetaModel::Init_DefineStimulus("ev_recycle", new StimulusUserAction(array("label"=>"Recycle this server", "description"=>"The server is move back to deconfiguration")));
  1205. MetaModel::Init_DefineTransition("InStore", "ev_ship", array("target_state"=>"Shipped", "actions"=>array(), "user_restriction"=>null));
  1206. MetaModel::Init_DefineTransition("InStore", "ev_plug", array("target_state"=>"Plugged", "actions"=>array(), "user_restriction"=>null));
  1207. MetaModel::Init_DefineTransition("Shipped", "ev_store", array("target_state"=>"InStore", "actions"=>array(), "user_restriction"=>null));
  1208. MetaModel::Init_DefineTransition("Shipped", "ev_plug", array("target_state"=>"Plugged", "actions"=>array(), "user_restriction"=>null));
  1209. MetaModel::Init_DefineTransition("Plugged", "ev_ship", array("target_state"=>"Shipped", "actions"=>array(), "user_restriction"=>null));
  1210. MetaModel::Init_DefineTransition("Plugged", "ev_store", array("target_state"=>"InStore", "actions"=>array(), "user_restriction"=>null));
  1211. MetaModel::Init_DefineTransition("Plugged", "ev_configuration_finished", array("target_state"=>"ProductionCandidate", "actions"=>array(), "user_restriction"=>null));
  1212. MetaModel::Init_DefineTransition("ProductionCandidate", "ev_val_failed", array("target_state"=>"Plugged", "actions"=>array(), "user_restriction"=>null));
  1213. MetaModel::Init_DefineTransition("ProductionCandidate", "ev_mtp", array("target_state"=>"InProduction", "actions"=>array(), "user_restriction"=>null));
  1214. MetaModel::Init_DefineTransition("InProduction", "ev_obsolete", array("target_state"=>"Obsolete", "actions"=>array(), "user_restriction"=>null));
  1215. MetaModel::Init_DefineTransition("InProduction", "ev_decommission", array("target_state"=>"BeingDeconfigured", "actions"=>array(), "user_restriction"=>null));
  1216. MetaModel::Init_DefineTransition("BeingDeconfigured", "ev_ship", array("target_state"=>"Shipped", "actions"=>array(), "user_restriction"=>null));
  1217. MetaModel::Init_DefineTransition("BeingDeconfigured", "ev_plug", array("target_state"=>"Plugged", "actions"=>array(), "user_restriction"=>null));
  1218. MetaModel::Init_DefineTransition("BeingDeconfigured", "ev_store", array("target_state"=>"InStore", "actions"=>array(), "user_restriction"=>null));
  1219. MetaModel::Init_DefineTransition("BeingDeconfigured", "ev_obsolete", array("target_state"=>"Obsolete", "actions"=>array(), "user_restriction"=>null));
  1220. MetaModel::Init_DefineTransition("Obsolete", "ev_recycle", array("target_state"=>"BeingDeconfigured", "actions"=>array(), "user_restriction"=>null));
  1221. // Display lists
  1222. MetaModel::Init_SetZListItems('details', array('name', 'mgmt_ip','default_gateway','status', 'severity','org_id', 'location_id', 'brand', 'model', 'os_family', 'os_version','serial_number','shipment_number', 'cpu', 'number_of_cpus', 'memory_size', 'hdd_size', 'hdd_free_size')); // Attributes to be displayed for the complete details
  1223. MetaModel::Init_SetZListItems('list', array('name', 'status','severity', 'org_id', 'location_id', 'brand', 'model', 'os_family', 'os_version')); // Attributes to be displayed for a list
  1224. // Search criteria
  1225. MetaModel::Init_SetZListItems('standard_search', array('name', 'status','severity', 'brand', 'model', 'os_family', 'location_id')); // Criteria of the std search form
  1226. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status','brand', 'model', 'os_family', 'os_version', 'location_id', 'cpu', 'number_of_cpus', 'memory_size', 'hdd_size', 'hdd_free_size')); // Criteria of the advanced search form
  1227. }
  1228. function DisplayDetails(web_page $oPage)
  1229. {
  1230. parent::DisplayDetails($oPage);
  1231. /*
  1232. parent::DisplayDetails($oPage);
  1233. $oSearchFilter = new CMDBSearchFilter('lnkContactRealObject');
  1234. $oSearchFilter->AddCondition('object_id', $this->GetKey(), '=');
  1235. $oSet = new CMDBObjectSet($oSearchFilter);
  1236. $count = $oSet->Count();
  1237. if ($count > 0)
  1238. {
  1239. $oPage->SetCurrentTab("Contacts");
  1240. $oPage->p("$count contact(s) for this server:");
  1241. $this->DisplaySet($oPage, $oSet);
  1242. }
  1243. $oSearchFilter = new CMDBSearchFilter('bizInterface');
  1244. $oSearchFilter->AddCondition('device_id', $this->GetKey(), '=');
  1245. $oSet = new CMDBObjectSet($oSearchFilter);
  1246. $count = $oSet->Count();
  1247. if ($count > 0)
  1248. {
  1249. $oPage->SetCurrentTab("Interfaces");
  1250. $oPage->p("$count interface(s) for this server:");
  1251. $this->DisplaySet($oPage, $oSet);
  1252. }
  1253. $oSearchFilter = new CMDBSearchFilter('Application');
  1254. $oSearchFilter->AddCondition('infra_id', $this->GetKey(), '=');
  1255. $oSet = new CMDBObjectSet($oSearchFilter);
  1256. $count = $oSet->Count();
  1257. if ($count > 0)
  1258. {
  1259. $oPage->SetCurrentTab("Installed applications");
  1260. $oPage->p("$count application(s) installed on this server:");
  1261. $this->DisplaySet($oPage, $oSet);
  1262. }
  1263. $oSearchFilter = new CMDBSearchFilter('bizPatch');
  1264. $oSearchFilter->AddCondition('infra_id', $this->GetKey(), '=');
  1265. $oSet = new CMDBObjectSet($oSearchFilter);
  1266. $count = $oSet->Count();
  1267. if ($count > 0)
  1268. {
  1269. $oPage->SetCurrentTab("Installed patches");
  1270. $oPage->p("$count patch(s) installed on this server:");
  1271. $this->DisplaySet($oPage, $oSet);
  1272. }
  1273. */
  1274. }
  1275. public function Generate(cmdbDataGenerator $oGenerator)
  1276. {
  1277. $this->Set('org_id', $oGenerator->GetOrganizationId());
  1278. $this->Set('location_id', $oGenerator->GenerateKey("bizLocation", array('org_id' =>$oGenerator->GetOrganizationId() )));
  1279. $this->Set('name', $oGenerator->GenerateString("enum(pc,pc,pc,pc,pc,win,redhat,linux,srv,workstation)|number(000-999)|.|domain()"));
  1280. $this->Set('brand', $oGenerator->GenerateString("enum(Hewlett-Packard,Dell,Compaq,Siemens,Packard Bell,IBM,Gateway,Medion,Sony)"));
  1281. $this->Set('model', $oGenerator->GenerateString("enum(Vectra,Deskpro,Dimension,Optiplex,Latitude,Precision,Vaio)"));
  1282. $this->Set('serial_number', $oGenerator->GenerateString("enum(FR,US,TW,CH)|number(000000-999999)"));
  1283. $this->Set('memory_size', $oGenerator->GenerateString("enum(512,1024,2048,4096,2048,4096,8192,8192,8192,16384,32768)"));
  1284. $this->Set('cpu', $oGenerator->GenerateString("enum(Pentium III,Pentium 4,Pentium M,Core Duo,Core 2 Duo,Celeron,Opteron,Thurion,Athlon)"));
  1285. $this->Set('number_of_cpu', $oGenerator->GenerateString("enum(1,1,2,2,2,2,2,4,4,8)"));
  1286. $this->Set('hdd_size', $oGenerator->GenerateString("enum(500,1024,500,1024,500,1024,2048)"));
  1287. $this->Set('hdd_free_size', $this->Get('hdd_size')*$oGenerator->GenerateString("number(20-80)"));
  1288. $this->Set('os_family', $oGenerator->GenerateString("enum(Windows,Windows,Windows,Linux,Windows,Linux,Windows,Linux,Linux,HP-UX,Solaris,AIX)"));
  1289. $this->Set('os_version', $oGenerator->GenerateString("enum(XP,XP,XP,RH EL 4,RH EL 5,SuSE 10.3,SuSE 10.4,11.11,11.11i)"));
  1290. }
  1291. }
  1292. ////////////////////////////////////////////////////////////////////////////////////
  1293. /**
  1294. * A network device
  1295. */
  1296. ////////////////////////////////////////////////////////////////////////////////////
  1297. class bizNetworkDevice extends bizDevice
  1298. {
  1299. public static function Init()
  1300. {
  1301. $aParams = array
  1302. (
  1303. "category" => "bizmodel,searchable",
  1304. "name" => "Network Device",
  1305. "description" => "A network device",
  1306. "key_type" => "",
  1307. "key_label" => "id",
  1308. "name_attcode" => "name",
  1309. "state_attcode" => "",
  1310. "reconc_keys" => array("org_id", "name"), // inherited attributes
  1311. "db_table" => "network_devices",
  1312. "db_key_field" => "id",
  1313. "db_finalclass_field" => "",
  1314. "display_template" => "../business/templates/network.device.html",
  1315. );
  1316. MetaModel::Init_Params($aParams);
  1317. MetaModel::Init_InheritAttributes();
  1318. MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type of device", "allowed_values"=>new ValueSetEnum("switch,router,firewall,load balancer,hub,WAN accelerator"), "sql"=>"type", "default_value"=>"switch", "is_null_allowed"=>false, "depends_on"=>array())));
  1319. MetaModel::Init_AddAttribute(new AttributeString("default_gateway", array("label"=>"Default Gateway", "description"=>"Default Gateway for this device", "allowed_values"=>null, "sql"=>"default_gateway", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1320. MetaModel::Init_AddAttribute(new AttributeString("ios_version", array("label"=>"IOS version", "description"=>"IOS (software) version", "allowed_values"=>null, "sql"=>"ios_version", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1321. MetaModel::Init_AddAttribute(new AttributeString("memory", array("label"=>"Memory", "description"=>"Memory description", "allowed_values"=>null, "sql"=>"memory", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1322. MetaModel::Init_AddAttribute(new AttributeString("snmp_read", array("label"=>"SNMP Community (Read)", "description"=>"SNMP Read Community String", "allowed_values"=>null, "sql"=>"snmp_read", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1323. MetaModel::Init_AddAttribute(new AttributeString("snmp_write", array("label"=>"SNMP Community (Write)", "description"=>"SNMP Write Community String", "allowed_values"=>null, "sql"=>"snmp_write", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1324. MetaModel::Init_InheritFilters();
  1325. MetaModel::Init_AddFilterFromAttribute("type");
  1326. MetaModel::Init_AddFilterFromAttribute("ios_version");
  1327. // Display lists
  1328. MetaModel::Init_SetZListItems('details', array('name', 'status','severity','org_id', 'location_id', 'brand','model','type','mgmt_ip','default_gateway','serial_number','ios_version','memory','snmp_read','snmp_write')); // Attributes to be displayed for the complete details
  1329. MetaModel::Init_SetZListItems('list', array('name', 'status','brand','model','type','mgmt_ip')); // Attributes to be displayed for a list
  1330. // Search criteria
  1331. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'location_id', 'brand','model','type','mgmt_ip')); // Criteria of the std search form
  1332. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'org_id', 'location_id', 'brand','model','type','mgmt_ip','serial_number','ios_version','snmp_read','snmp_write')); // Criteria of the advanced search form
  1333. }
  1334. public function Generate(cmdbDataGenerator $oGenerator)
  1335. {
  1336. $this->Set('org_id', $oGenerator->GetOrganizationId());
  1337. $this->Set('location_id', $oGenerator->GenerateKey("bizLocation", array('org_id' =>$oGenerator->GetOrganizationId() )));
  1338. $this->Set('name', $oGenerator->GenerateString("enum(sw,swi,switch,rout,rtr,gw)|number(000-999)|.|domain()"));
  1339. $this->Set('brand', $oGenerator->GenerateString("enum(Hewlett-Packard,Cisco,3Com,Avaya,Alcatel,Cabletron,Extrem Networks,Juniper,Netgear,Synopitcs,Xylan)"));
  1340. $this->Set('model', $oGenerator->GenerateString("enum(Procurve ,Catalyst ,Multiswitch ,C)|enum(25,26,36,40,65)|enum(00,09,10,50)"));
  1341. $this->Set('serial_number', $oGenerator->GenerateString("enum(FAA,AGA,PAD,COB,DFE)|number(0000-9999)|enum(M,X,L)"));
  1342. $this->Set('ip_address', $oGenerator->GenerateString("number(10-248)|.|number(1-254)|.|number(1-254)|.|number(1-254)"));
  1343. $this->Set('ios_version', $oGenerator->GenerateString("enum(9,10,12)|.|enum(0,1,2)|enum(,,,,XP,.5.1)"));
  1344. $this->Set('snmp_read', $oGenerator->GenerateString("enum(Ew,+0,**,Ps)|number(00-99)|enum(+,=,],;, )|enum(Aze,Vbn,Bbn,+9+,-9-,#)"));
  1345. $this->Set('snmp_write', $oGenerator->GenerateString("enum(M3,l3,$,*,Zz,Ks,jh)|number(00-99)|enum(A*e,V%n,Bbn,+,-,#)|number(0-9)"));
  1346. }
  1347. }
  1348. ////////////////////////////////////////////////////////////////////////////////////
  1349. /**
  1350. * A "Solution"
  1351. */
  1352. ////////////////////////////////////////////////////////////////////////////////////
  1353. class bizInfraGroup extends logInfra
  1354. {
  1355. public static function Init()
  1356. {
  1357. $aParams = array
  1358. (
  1359. "category" => "bizmodel,searchable",
  1360. "name" => "Infra Group",
  1361. "description" => "A group of infrastructure elements",
  1362. "key_type" => "",
  1363. "key_label" => "id",
  1364. "name_attcode" => "name",
  1365. "state_attcode" => "",
  1366. "reconc_keys" => array("org_id", "name"), // inherited attributes
  1367. "db_table" => "infra_group",
  1368. "db_key_field" => "id",
  1369. "db_finalclass_field" => "",
  1370. "display_template" => "../business/templates/group.html",
  1371. );
  1372. MetaModel::Init_Params($aParams);
  1373. MetaModel::Init_InheritAttributes();
  1374. MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type of groupe", "allowed_values"=>new ValueSetEnum("Monitoring,Reporting,list"), "sql"=>"type", "default_value"=>"list", "is_null_allowed"=>true, "depends_on"=>array())));
  1375. MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"Description", "description"=>"usage of the Group", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1376. MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_group_id", array("targetclass"=>"bizInfraGroup", "label"=>"Parent Group", "description"=>"including group", "allowed_values"=>null, "sql"=>"parent_group_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  1377. MetaModel::Init_AddAttribute(new AttributeExternalField("parent_group_name", array("label"=>"Parent Group (Name)", "description"=>"name of the parent group", "allowed_values"=>null, "extkey_attcode"=> 'parent_group_id', "target_attcode"=>"name")));
  1378. MetaModel::Init_InheritFilters();
  1379. MetaModel::Init_AddFilterFromAttribute("type");
  1380. MetaModel::Init_AddFilterFromAttribute("parent_group_id");
  1381. MetaModel::Init_AddFilterFromAttribute("parent_group_name");
  1382. // Display lists
  1383. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'type', 'description','parent_group_id')); // Attributes to be displayed for a list
  1384. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'type', 'description')); // Attributes to be displayed for a list
  1385. // Search criteria
  1386. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'type')); // Criteria of the std search form
  1387. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'type', 'description', 'org_id')); // Criteria of the advanced search form
  1388. }
  1389. function DisplayDetails(web_page $oPage)
  1390. {
  1391. parent::DisplayDetails($oPage);
  1392. /*
  1393. $oSearchFilter = new CMDBSearchFilter('lnkInfraGrouping');
  1394. $oSearchFilter->AddCondition('infra_group_id', $this->GetKey(), '=');
  1395. $oSet = new CMDBObjectSet($oSearchFilter);
  1396. $count = $oSet->Count();
  1397. if ($count > 0)
  1398. {
  1399. $oPage->SetCurrentTab("RelatedInfrastructure");
  1400. $oPage->p("Infrastructure Link to this group:");
  1401. $this->DisplaySet($oPage, $oSet);
  1402. }
  1403. $oSearchFilter = new CMDBSearchFilter('lnkContactRealObject');
  1404. $oSearchFilter->AddCondition('object_id', $this->GetKey(), '=');
  1405. $oSet = new CMDBObjectSet($oSearchFilter);
  1406. $count = $oSet->Count();
  1407. if ($count > 0)
  1408. {
  1409. $oPage->SetCurrentTab("TeamLinks");
  1410. $oPage->p("People concerned by this group:");
  1411. $this->DisplaySet($oPage, $oSet);
  1412. }
  1413. */
  1414. }
  1415. public function Generate(cmdbDataGenerator $oGenerator)
  1416. {
  1417. $this->Set('org_id', $oGenerator->GetOrganizationId());
  1418. $this->Set('name', $oGenerator->GenerateString("enum(ov_nnm_,ovpi_,vitalnet_,datacenter_,web_farm_)|number(000-999)"));
  1419. $this->Set('type', $oGenerator->GenerateString("enum(Application,Infrastructure)"));
  1420. }
  1421. }
  1422. ////////////////////////////////////////////////////////////////////////////////////
  1423. //**
  1424. //* An application is an instance of a software install on a PC or Server
  1425. //*
  1426. ////////////////////////////////////////////////////////////////////////////////////
  1427. class bizApplication extends logInfra
  1428. {
  1429. public static function Init()
  1430. {
  1431. $aParams = array
  1432. (
  1433. "category" => "bizmodel,searchable",
  1434. "name" => "Application",
  1435. "description" => "General application",
  1436. "key_type" => "",
  1437. "key_label" => "id",
  1438. "name_attcode" => "name",
  1439. "state_attcode" => "",
  1440. "reconc_keys" => array("device_id", "name"), // inherited attributes
  1441. "db_table" => "applications",
  1442. "db_key_field" => "id",
  1443. "db_finalclass_field" => "",
  1444. "display_template" => "../business/templates/application.html",
  1445. );
  1446. MetaModel::Init_Params($aParams);
  1447. MetaModel::Init_InheritAttributes();
  1448. MetaModel::Init_AddAttribute(new AttributeExternalKey("device_id", array("targetclass"=>"bizDevice", "jointype"=> '', "label"=>"Hosting device", "description"=>"The device where application is installed", "allowed_values"=>null, "sql"=>"device_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  1449. MetaModel::Init_AddAttribute(new AttributeExternalField("device_name", array("label"=>"Hosting device", "description"=>"Name of the device where application is installed", "allowed_values"=>null, "extkey_attcode"=> 'device_id', "target_attcode"=>"name")));
  1450. MetaModel::Init_AddAttribute(new AttributeDate("install_date", array("label"=>"Installation Date", "description"=>"Date when application was installed", "allowed_values"=>null, "sql"=>"install_date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1451. MetaModel::Init_AddAttribute(new AttributeString("version", array("label"=>"Version", "description"=>"Application version", "allowed_values"=>null, "sql"=>"version", "default_value"=>"undefined", "is_null_allowed"=>false, "depends_on"=>array())));
  1452. MetaModel::Init_AddAttribute(new AttributeString("function", array("label"=>"Function", "description"=>"Function provided by this application", "allowed_values"=>null, "sql"=>"function", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1453. MetaModel::Init_InheritFilters();
  1454. MetaModel::Init_AddFilterFromAttribute("function");
  1455. MetaModel::Init_AddFilterFromAttribute("version");
  1456. MetaModel::Init_AddFilterFromAttribute("device_id");
  1457. MetaModel::Init_AddFilterFromAttribute("device_name");
  1458. // Display lists
  1459. MetaModel::Init_SetZListItems('details', array('name','device_id','org_id','status','install_date', 'version','function')); // Attributes to be displayed for the complete details
  1460. MetaModel::Init_SetZListItems('list', array('name','device_id', 'version', 'function')); // Attributes to be displayed for a list
  1461. // Search criteria
  1462. MetaModel::Init_SetZListItems('standard_search', array('name', 'device_id','version','function')); // Criteria of the std search form
  1463. MetaModel::Init_SetZListItems('advanced_search', array('name', 'device_id','version','function')); // Criteria of the advanced search form
  1464. }
  1465. public static function GetRelationQueries($sRelCode)
  1466. {
  1467. switch ($sRelCode)
  1468. {
  1469. case "impacts":
  1470. $aRels = array(
  1471. "client app" => array("sQuery"=>"bizApplication: PKEY IS client_id IN (lnkClientServer: server_id = \$[this.pkey::])", "bPropagate"=>true, "iDistance"=>3),
  1472. );
  1473. return array_merge($aRels, parent::GetRelationQueries($sRelCode));
  1474. }
  1475. }
  1476. function DisplayDetails(web_page $oPage)
  1477. {
  1478. parent::DisplayDetails($oPage);
  1479. /*
  1480. $oSearchFilter = new CMDBSearchFilter('lnkClientServer');
  1481. $oSearchFilter->AddCondition('server_id', $this->GetKey(), '=');
  1482. $oSet = new CMDBObjectSet($oSearchFilter);
  1483. $count = $oSet->Count();
  1484. if ($count > 0)
  1485. {
  1486. $oPage->SetCurrentTab("Connected clients");
  1487. $oPage->p("Client applications impacted when down:");
  1488. $this->DisplaySet($oPage, $oSet);
  1489. }
  1490. */
  1491. }
  1492. }
  1493. ////////////////////////////////////////////////////////////////////////////////////
  1494. /**
  1495. * n-n link between any Infra and a Group
  1496. */
  1497. ////////////////////////////////////////////////////////////////////////////////////
  1498. class lnkInfraGrouping extends cmdbAbstractObject
  1499. {
  1500. public static function Init()
  1501. {
  1502. $aParams = array
  1503. (
  1504. "category" => "bizmodel,searchable",
  1505. "name" => "Infra Grouping",
  1506. "description" => "Infra part of an Infra Group",
  1507. "key_type" => "autoincrement",
  1508. "key_label" => "link_id",
  1509. "name_attcode" => "impact",
  1510. "state_attcode" => "",
  1511. "reconc_keys" => array(""),
  1512. "db_table" => "infra_grouping",
  1513. "db_key_field" => "link_id",
  1514. "db_finalclass_field" => "",
  1515. "display_template" => "../business/templates/default.html",
  1516. );
  1517. MetaModel::Init_Params($aParams);
  1518. MetaModel::Init_AddAttribute(new AttributeExternalKey("infra_id", array("targetclass"=>"logInfra", "jointype"=> '', "label"=>"Infrastructure", "description"=>"Infrastructure part of the group", "allowed_values"=>null, "sql"=>"infra_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  1519. MetaModel::Init_AddAttribute(new AttributeExternalField("infra_name", array("label"=>"Infrastructure Name", "description"=>"Name of the impacted infrastructure", "allowed_values"=>null, "extkey_attcode"=> 'infra_id', "target_attcode"=>"name")));
  1520. MetaModel::Init_AddAttribute(new AttributeExternalField("infra_status", array("label"=>"Status", "description"=>"Status of the impacted infrastructure", "allowed_values"=>null, "extkey_attcode"=> 'infra_id', "target_attcode"=>"status")));
  1521. MetaModel::Init_AddAttribute(new AttributeExternalKey("infra_group_id", array("targetclass"=>"bizInfraGroup", "jointype"=> '', "label"=>"Group", "description"=>"Name of the group", "allowed_values"=>null, "sql"=>"infra_group_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  1522. MetaModel::Init_AddAttribute(new AttributeExternalField("group_name", array("label"=>"Group Name", "description"=>"Name of the group containing infrastructure", "allowed_values"=>null, "extkey_attcode"=> 'infra_group_id', "target_attcode"=>"name")));
  1523. MetaModel::Init_AddAttribute(new AttributeString("impact", array("label"=>"Relation", "description"=>"Relation between this group and infra", "allowed_values"=>null, "sql"=>"impact", "default_value"=>"none", "is_null_allowed"=>true, "depends_on"=>array())));
  1524. // impact should modelized: enum (eg: if the group si dead when infra is dead)
  1525. MetaModel::Init_AddFilterFromAttribute("infra_id");
  1526. MetaModel::Init_AddFilterFromAttribute("infra_group_id");
  1527. MetaModel::Init_AddFilterFromAttribute("impact");
  1528. // Display lists
  1529. MetaModel::Init_SetZListItems('details', array('infra_id','infra_status', 'impact', 'infra_group_id')); // Attributes to be displayed for a list
  1530. MetaModel::Init_SetZListItems('list', array('infra_id','infra_status', 'impact', 'infra_group_id')); // Attributes to be displayed for a list
  1531. // Search criteria
  1532. MetaModel::Init_SetZListItems('standard_search', array('infra_id', 'infra_group_id', 'impact')); // Criteria of the std search form
  1533. MetaModel::Init_SetZListItems('advanced_search', array('infra_id', 'infra_group_id', 'impact')); // Criteria of the advanced search form
  1534. }
  1535. public function Generate(cmdbDataGenerator $oGenerator)
  1536. {
  1537. $this->Set('infra_id', $oGenerator->GenerateKey("logInfra", array('org_id' =>$oGenerator->GetOrganizationId() )));
  1538. $this->Set('infra_group_id', $oGenerator->GenerateKey("bizInfraGroup", array('org_id' =>$oGenerator->GetOrganizationId() )));
  1539. $this->Set('impact', $oGenerator->GenerateString("enum(none,mandatory,partial)"));
  1540. }
  1541. }
  1542. ////////////////////////////////////////////////////////////////////////////////////
  1543. /**
  1544. * n-n link between two applications, one is the server side and the scond one the client*/
  1545. ////////////////////////////////////////////////////////////////////////////////////
  1546. class lnkClientServer extends logRealObject
  1547. {
  1548. public static function Init()
  1549. {
  1550. $aParams = array
  1551. (
  1552. "category" => "bizmodel,searchable",
  1553. "name" => "ClientServerLinks",
  1554. "description" => "Link between client server application",
  1555. "key_type" => "autoincrement",
  1556. "key_label" => "link_id",
  1557. "name_attcode" => "relation", // ????
  1558. "state_attcode" => "",
  1559. "reconc_keys" => array("relation"), // ????
  1560. "db_table" => "clientserver_links",
  1561. "db_key_field" => "link_id",
  1562. "db_finalclass_field" => "",
  1563. "display_template" => "../business/templates/default.html",
  1564. );
  1565. MetaModel::Init_Params($aParams);
  1566. MetaModel::Init_AddAttribute(new AttributeExternalKey("client_id", array("targetclass"=>"bizApplication", "jointype"=> '', "label"=>"Client", "description"=>"The client part of the link", "allowed_values"=>null, "sql"=>"client_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  1567. MetaModel::Init_AddAttribute(new AttributeExternalField("client_name", array("label"=>"Client", "description"=>"Name of the client", "allowed_values"=>null, "extkey_attcode"=> 'client_id', "target_attcode"=>"name")));
  1568. MetaModel::Init_AddAttribute(new AttributeExternalKey("server_id", array("targetclass"=>"bizApplication", "jointype"=> '', "label"=>"Server", "description"=>"the server part of the link", "allowed_values"=>null, "sql"=>"server_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  1569. MetaModel::Init_AddAttribute(new AttributeExternalField("server_name", array("label"=>"Server", "description"=>"Name of the server", "allowed_values"=>null, "extkey_attcode"=> 'server_id', "target_attcode"=>"name")));
  1570. MetaModel::Init_AddAttribute(new AttributeString("relation", array("label"=>"Relation", "description"=>"Type of relation between both application", "allowed_values"=>null, "sql"=>"relation", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1571. MetaModel::Init_AddFilterFromAttribute("client_id");
  1572. MetaModel::Init_AddFilterFromAttribute("server_id");
  1573. // Display lists
  1574. MetaModel::Init_SetZListItems('details', array('client_id', 'server_id', 'relation')); // Attributes to be displayed for a list
  1575. MetaModel::Init_SetZListItems('list', array('client_id', 'server_id', 'relation')); // Attributes to be displayed for a list
  1576. // Search criteria
  1577. MetaModel::Init_SetZListItems('standard_search', array('client_id', 'server_id')); // Criteria of the std search form
  1578. MetaModel::Init_SetZListItems('advanced_search', array('client_id', 'server_id')); // Criteria of the advanced search form
  1579. }
  1580. }
  1581. ////////////////////////////////////////////////////////////////////////////////////
  1582. //**
  1583. //* A patch is an application or OS fixe for an infrastructure
  1584. //*
  1585. ////////////////////////////////////////////////////////////////////////////////////
  1586. class bizPatch extends logRealObject
  1587. {
  1588. public static function Init()
  1589. {
  1590. $aParams = array
  1591. (
  1592. "category" => "bizmodel,searchable",
  1593. "name" => "Patch",
  1594. "description" => "Patch installed on infrastucture",
  1595. "key_type" => "",
  1596. "key_label" => "id",
  1597. "name_attcode" => "name",
  1598. "state_attcode" => "",
  1599. "reconc_keys" => array("device_id", "name"), // inherited attributes
  1600. "db_table" => "patches",
  1601. "db_key_field" => "id",
  1602. "db_finalclass_field" => "",
  1603. "display_template" => "../business/templates/default.html",
  1604. );
  1605. MetaModel::Init_Params($aParams);
  1606. MetaModel::Init_InheritAttributes();
  1607. MetaModel::Init_AddAttribute(new AttributeExternalKey("device_id", array("targetclass"=>"bizDevice", "jointype"=> '', "label"=>"Device", "description"=>"The Device where patch is installed", "allowed_values"=>null, "sql"=>"device_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  1608. MetaModel::Init_AddAttribute(new AttributeExternalField("device_name", array("label"=>"Device Name", "description"=>"Name of the impacted device", "allowed_values"=>null, "extkey_attcode"=> 'device_id', "target_attcode"=>"name")));
  1609. MetaModel::Init_AddAttribute(new AttributeDate("install_date", array("label"=>"Installation Date", "description"=>"Date when application was installed", "allowed_values"=>null, "sql"=>"install_date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1610. MetaModel::Init_AddAttribute(new AttributeText("description", array("label"=>"Description", "description"=>"description du patch", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1611. MetaModel::Init_AddAttribute(new AttributeString("patch_type", array("label"=>"Type", "description"=>"type de patch", "allowed_values"=>new ValueSetEnum("OS,Application"), "sql"=>"patch_type", "default_value"=>"OS", "is_null_allowed"=>false, "depends_on"=>array())));
  1612. MetaModel::Init_InheritFilters();
  1613. MetaModel::Init_AddFilterFromAttribute("patch_type");
  1614. MetaModel::Init_AddFilterFromAttribute("device_id");
  1615. // Display lists
  1616. MetaModel::Init_SetZListItems('details', array('name','device_id', 'install_date', 'patch_type','description')); // Attributes to be displayed for the complete details
  1617. MetaModel::Init_SetZListItems('list', array('name','device_id', 'patch_type','install_date')); // Attributes to be displayed for a list
  1618. // Search criteria
  1619. MetaModel::Init_SetZListItems('standard_search', array('name', 'device_id','patch_type')); // Criteria of the std search form
  1620. MetaModel::Init_SetZListItems('advanced_search', array('name', 'device_id','patch_type')); // Criteria of the advanced search form
  1621. }
  1622. }
  1623. /*** Insert here all modules requires for ITOP application ***/
  1624. require_once('incidentMgmt.business.php');
  1625. require_once('ServiceMgmt.business.php');
  1626. require_once('ChangeMgmt.business.php');
  1627. require_once('KEDB.business.php');
  1628. require_once('ServiceDesk.business.php');
  1629. ?>