From 0405a54aa03c6e2826b10cac44a9f9b08525b8d1 Mon Sep 17 00:00:00 2001 From: BAYARD Eric Date: Fri, 29 Nov 2024 15:55:35 +0100 Subject: [PATCH] update new links in items add new updates --- .../20241001134535_notepads_migration.php | 5 + ...104_ticketvalidations_update_migration.php | 30 + src/Models/Appliance.php | 21 +- src/Models/Appliancetype.php | 2 +- src/Models/Budget.php | 2 +- src/Models/Businesscriticity.php | 4 +- src/Models/Calendar.php | 19 +- src/Models/Calendarsegment.php | 33 + src/Models/Cartridge.php | 2 +- src/Models/Cartridgeitem.php | 17 +- src/Models/Category.php | 6 +- src/Models/Certificate.php | 21 +- src/Models/Certificatetype.php | 2 +- src/Models/Change.php | 49 +- src/Models/ChangeItem.php | 16 + src/Models/ChangeProblem.php | 16 + src/Models/ChangeTicket.php | 16 + src/Models/Changecost.php | 42 + src/Models/Changetemplate.php | 2 +- src/Models/Changevalidation.php | 50 + src/Models/Cluster.php | 6 +- src/Models/Clustertype.php | 2 +- src/Models/Common.php | 28 +- src/Models/Computer.php | 114 +- src/Models/Consumable.php | 2 +- src/Models/Consumableitem.php | 17 +- src/Models/Contact.php | 2 +- src/Models/Contract.php | 2 +- src/Models/ContractItem.php | 18 + src/Models/Datacenter.php | 10 +- src/Models/Dcroom.php | 130 + src/Models/Definitions/Appliance.php | 340 +- src/Models/Definitions/Budget.php | 4 +- src/Models/Definitions/Businesscriticity.php | 4 +- src/Models/Definitions/Calendar.php | 8 +- src/Models/Definitions/Calendarsegment.php | 18 + src/Models/Definitions/Cartridgeitem.php | 198 +- src/Models/Definitions/Certificate.php | 342 +- src/Models/Definitions/Change.php | 125 +- src/Models/Definitions/ChangeItem.php | 18 + src/Models/Definitions/ChangeProblem.php | 18 + src/Models/Definitions/ChangeTicket.php | 18 + src/Models/Definitions/Changecost.php | 18 + src/Models/Definitions/Changevalidation.php | 18 + src/Models/Definitions/Computer.php | 351 +- src/Models/Definitions/Computerantivirus.php | 59 +- src/Models/Definitions/Consumableitem.php | 198 +- src/Models/Definitions/Contract.php | 9 +- src/Models/Definitions/ContractItem.php | 18 + src/Models/Definitions/Crontask.php | 7 +- src/Models/Definitions/Datacenter.php | 7 +- src/Models/Definitions/Dcroom.php | 470 ++ src/Models/Definitions/Devicebattery.php | 4 +- src/Models/Definitions/Devicecase.php | 4 +- src/Models/Definitions/Devicecontrol.php | 4 +- src/Models/Definitions/Devicedrive.php | 4 +- src/Models/Definitions/Devicefirmware.php | 4 +- src/Models/Definitions/Devicegeneric.php | 4 +- src/Models/Definitions/Devicegraphiccard.php | 4 +- src/Models/Definitions/Deviceharddrive.php | 4 +- src/Models/Definitions/Devicememory.php | 4 +- src/Models/Definitions/Devicemotherboard.php | 4 +- src/Models/Definitions/Devicenetworkcard.php | 4 +- src/Models/Definitions/Devicepci.php | 4 +- src/Models/Definitions/Devicepowersupply.php | 4 +- src/Models/Definitions/Deviceprocessor.php | 4 +- src/Models/Definitions/Devicesensor.php | 4 +- src/Models/Definitions/Devicesimcard.php | 4 +- src/Models/Definitions/Devicesoundcard.php | 4 +- src/Models/Definitions/Document.php | 2 +- src/Models/Definitions/Documentcategory.php | 4 +- src/Models/Definitions/Domain.php | 344 +- src/Models/Definitions/Domainrelation.php | 2 +- src/Models/Definitions/Enclosure.php | 344 +- src/Models/Definitions/Fqdn.php | 2 +- src/Models/Definitions/Group.php | 12 +- src/Models/Definitions/Holiday.php | 10 - src/Models/Definitions/Infocom.php | 18 + src/Models/Definitions/Ipnetwork.php | 4 +- src/Models/Definitions/ItemDevicebattery.php | 18 + src/Models/Definitions/ItemDevicecase.php | 18 + src/Models/Definitions/ItemDevicecontrol.php | 18 + src/Models/Definitions/ItemDevicedrive.php | 18 + src/Models/Definitions/ItemDevicefirmware.php | 18 + src/Models/Definitions/ItemDevicegeneric.php | 18 + .../Definitions/ItemDevicegraphiccard.php | 18 + .../Definitions/ItemDeviceharddrive.php | 18 + src/Models/Definitions/ItemDevicememory.php | 18 + .../Definitions/ItemDevicemotherboard.php | 18 + .../Definitions/ItemDevicenetworkcard.php | 18 + src/Models/Definitions/ItemDevicepci.php | 18 + .../Definitions/ItemDevicepowersupply.php | 18 + .../Definitions/ItemDeviceprocessor.php | 18 + src/Models/Definitions/ItemDevicesensor.php | 18 + src/Models/Definitions/ItemDevicesimcard.php | 340 +- .../Definitions/ItemDevicesoundcard.php | 18 + src/Models/Definitions/ItemEnclosure.php | 18 + src/Models/Definitions/ItemProblem.php | 18 + .../Definitions/ItemSoftwarelicence.php | 18 + .../Definitions/ItemSoftwareversion.php | 18 + src/Models/Definitions/ItemTicket.php | 18 + .../Definitions/Knowbaseitemcategory.php | 4 +- src/Models/Definitions/Line.php | 341 +- src/Models/Definitions/Link.php | 4 +- src/Models/Definitions/Location.php | 2 +- src/Models/Definitions/Monitor.php | 343 +- src/Models/Definitions/Networkalias.php | 18 + src/Models/Definitions/Networkequipment.php | 343 +- src/Models/Definitions/Networkname.php | 2 +- src/Models/Definitions/Ola.php | 18 + src/Models/Definitions/Passivedcequipment.php | 340 +- src/Models/Definitions/Pdu.php | 344 +- src/Models/Definitions/Peripheral.php | 343 +- src/Models/Definitions/Phone.php | 342 +- src/Models/Definitions/Printer.php | 343 +- src/Models/Definitions/Problem.php | 72 +- src/Models/Definitions/ProblemTicket.php | 18 + src/Models/Definitions/Problemcost.php | 18 + src/Models/Definitions/Profile.php | 6 +- src/Models/Definitions/Project.php | 12 +- src/Models/Definitions/Projectstate.php | 2 +- src/Models/Definitions/Projecttask.php | 321 +- src/Models/Definitions/ProjecttaskTicket.php | 18 + src/Models/Definitions/Projecttaskteam.php | 18 + .../Definitions/Projecttasktemplate.php | 21 +- src/Models/Definitions/Rack.php | 359 +- src/Models/Definitions/Reservation.php | 18 + src/Models/Definitions/Reservationitem.php | 18 + src/Models/Definitions/Rssfeed.php | 21 +- src/Models/Definitions/Sla.php | 18 + src/Models/Definitions/Slm.php | 4 +- src/Models/Definitions/Software.php | 348 +- src/Models/Definitions/Softwarecategory.php | 4 +- src/Models/Definitions/Softwarelicense.php | 201 +- .../Definitions/Softwarelicensetype.php | 4 +- src/Models/Definitions/Softwareversion.php | 73 +- src/Models/Definitions/Supplier.php | 6 +- src/Models/Definitions/Tasktemplate.php | 11 +- src/Models/Definitions/Ticket.php | 23 +- src/Models/Definitions/Ticketvalidation.php | 18 + src/Models/Definitions/User.php | 8 +- src/Models/Definitions/Vlan.php | 12 +- src/Models/Devicebattery.php | 12 +- src/Models/Devicecase.php | 12 +- src/Models/Devicecontrol.php | 12 +- src/Models/Devicedrive.php | 12 +- src/Models/Devicefirmware.php | 12 +- src/Models/Devicegeneric.php | 12 +- src/Models/Devicegraphiccard.php | 12 +- src/Models/Deviceharddrive.php | 12 +- src/Models/Devicememory.php | 12 +- src/Models/Devicemotherboard.php | 12 +- src/Models/Devicenetworkcard.php | 12 +- src/Models/Devicepci.php | 12 +- src/Models/Devicepowersupply.php | 12 +- src/Models/Deviceprocessor.php | 12 +- src/Models/Devicesensor.php | 12 +- src/Models/Devicesimcard.php | 12 +- src/Models/Devicesoundcard.php | 12 +- src/Models/Document.php | 2 +- src/Models/Documentcategory.php | 2 +- src/Models/Domain.php | 19 +- src/Models/DomainItem.php | 4 +- src/Models/Domainrecord.php | 2 +- src/Models/Domainrecordtype.php | 2 +- src/Models/Domainrelation.php | 11 +- src/Models/Domaintype.php | 2 +- src/Models/Enclosure.php | 104 +- src/Models/Entity.php | 2 +- src/Models/Fieldblacklist.php | 2 +- src/Models/Fieldunicity.php | 2 +- src/Models/Followuptemplate.php | 4 +- src/Models/Forms/Answer.php | 1 + src/Models/Forms/Answerquestion.php | 1 + src/Models/Forms/Form.php | 2 +- src/Models/Fqdn.php | 10 +- src/Models/Group.php | 7 +- src/Models/Holiday.php | 2 +- src/Models/Infocom.php | 59 + src/Models/Ipnetwork.php | 11 +- src/Models/ItemDevicebattery.php | 51 + src/Models/ItemDevicecase.php | 51 + src/Models/ItemDevicecontrol.php | 51 + src/Models/ItemDevicedrive.php | 51 + src/Models/ItemDevicefirmware.php | 51 + src/Models/ItemDevicegeneric.php | 51 + src/Models/ItemDevicegraphiccard.php | 51 + src/Models/ItemDeviceharddrive.php | 51 + src/Models/ItemDevicememory.php | 51 + src/Models/ItemDevicemotherboard.php | 51 + src/Models/ItemDevicenetworkcard.php | 51 + src/Models/ItemDevicepci.php | 51 + src/Models/ItemDevicepowersupply.php | 51 + src/Models/ItemDeviceprocessor.php | 51 + src/Models/ItemDevicesensor.php | 51 + src/Models/ItemDevicesimcard.php | 19 +- src/Models/ItemDevicesoundcard.php | 51 + src/Models/ItemEnclosure.php | 18 + src/Models/ItemProblem.php | 16 + src/Models/ItemSoftwarelicence.php | 20 + src/Models/ItemSoftwareversion.php | 36 + src/Models/ItemTicket.php | 18 + src/Models/Knowbaseitem.php | 2 +- src/Models/Knowbaseitemcategory.php | 4 +- src/Models/Line.php | 17 +- src/Models/Lineoperator.php | 2 +- src/Models/Link.php | 2 +- src/Models/Location.php | 2 +- src/Models/Monitor.php | 35 +- src/Models/Netpoint.php | 2 +- src/Models/Networkalias.php | 31 + src/Models/Networkequipment.php | 110 +- src/Models/Networkname.php | 10 +- src/Models/News.php | 2 +- src/Models/Notepad.php | 4 +- src/Models/Notification.php | 2 +- src/Models/Ola.php | 41 + src/Models/Operatingsystemkernelversion.php | 2 +- src/Models/Passivedcequipment.php | 17 +- src/Models/Pdu.php | 26 +- src/Models/Peripheral.php | 110 +- src/Models/Phone.php | 110 +- src/Models/Planningexternaleventtemplate.php | 4 +- src/Models/Printer.php | 110 +- src/Models/Problem.php | 43 +- src/Models/ProblemTicket.php | 16 + src/Models/Problemcost.php | 42 + src/Models/Problemtemplate.php | 2 +- src/Models/Project.php | 10 +- src/Models/Projecttask.php | 30 +- src/Models/ProjecttaskTicket.php | 17 + src/Models/Projecttaskteam.php | 15 + src/Models/Projecttasktemplate.php | 8 +- src/Models/Queuednotification.php | 2 +- src/Models/Rack.php | 17 +- src/Models/Racktype.php | 2 +- src/Models/Reminder.php | 2 +- src/Models/Reservation.php | 32 + src/Models/Reservationitem.php | 43 + src/Models/Rssfeed.php | 2 +- src/Models/Savedsearch.php | 4 +- src/Models/Sla.php | 41 + src/Models/Slm.php | 18 +- src/Models/Software.php | 31 +- src/Models/Softwarecategory.php | 2 +- src/Models/Softwarelicense.php | 31 +- src/Models/Softwarelicensetype.php | 2 +- src/Models/Softwareversion.php | 4 +- src/Models/Solutiontemplate.php | 4 +- src/Models/Solutiontype.php | 2 +- src/Models/State.php | 2 +- src/Models/Supplier.php | 2 +- src/Models/Tasktemplate.php | 5 +- src/Models/Ticket.php | 52 +- src/Models/Ticketcost.php | 2 +- src/Models/Ticketrecurrent.php | 18 +- src/Models/Tickettemplate.php | 2 +- src/Models/Ticketvalidation.php | 50 + src/Models/User.php | 10 +- src/Models/Vlan.php | 2 +- src/Models/Wifinetwork.php | 2 +- src/Route.php | 201 +- src/v1/Controllers/Appliance.php | 70 +- src/v1/Controllers/Authldap.php | 28 +- src/v1/Controllers/Authsso.php | 4 +- src/v1/Controllers/Budget.php | 396 ++ src/v1/Controllers/Businesscriticity.php | 67 + src/v1/Controllers/Calendar.php | 123 + src/v1/Controllers/Cartridgeitem.php | 68 +- src/v1/Controllers/Category.php | 96 +- src/v1/Controllers/Certificate.php | 63 +- src/v1/Controllers/Change.php | 234 + src/v1/Controllers/Cluster.php | 34 +- src/v1/Controllers/Common.php | 4787 ++++++++++++++--- src/v1/Controllers/Computer.php | 172 +- src/v1/Controllers/Computerantivirus.php | 31 + src/v1/Controllers/Consumableitem.php | 46 +- src/v1/Controllers/Contract.php | 4 +- src/v1/Controllers/Datacenter.php | 45 + src/v1/Controllers/Dcroom.php | 31 + src/v1/Controllers/Devicebattery.php | 116 +- src/v1/Controllers/Devicecase.php | 4 +- src/v1/Controllers/Devicecontrol.php | 4 +- src/v1/Controllers/Devicedrive.php | 4 +- src/v1/Controllers/Devicefirmware.php | 4 +- src/v1/Controllers/Devicegeneric.php | 4 +- src/v1/Controllers/Devicegraphiccard.php | 112 +- src/v1/Controllers/Deviceharddrive.php | 117 +- src/v1/Controllers/Devicememory.php | 117 +- src/v1/Controllers/Devicemotherboard.php | 4 +- src/v1/Controllers/Devicenetworkcard.php | 102 +- src/v1/Controllers/Devicepci.php | 4 +- src/v1/Controllers/Devicepowersupply.php | 4 +- src/v1/Controllers/Deviceprocessor.php | 127 +- src/v1/Controllers/Devicesensor.php | 4 +- src/v1/Controllers/Devicesimcard.php | 3 +- src/v1/Controllers/Devicesoundcard.php | 4 +- src/v1/Controllers/Displaypreference.php | 8 +- src/v1/Controllers/Documentcategory.php | 56 + src/v1/Controllers/Domain.php | 20 +- src/v1/Controllers/Domainrelation.php | 116 + src/v1/Controllers/Dropdown.php | 4 +- src/v1/Controllers/Enclosure.php | 64 + src/v1/Controllers/Entity.php | 106 +- src/v1/Controllers/Forms/Answer.php | 39 +- src/v1/Controllers/Forms/Form.php | 66 +- src/v1/Controllers/Forms/Question.php | 48 +- src/v1/Controllers/Forms/Section.php | 38 +- src/v1/Controllers/Fqdn.php | 68 + .../Fusioninventory/Communication.php | 4 +- src/v1/Controllers/Group.php | 108 +- src/v1/Controllers/Home.php | 143 +- src/v1/Controllers/Ipnetwork.php | 60 + src/v1/Controllers/Knowbaseitemcategory.php | 67 + src/v1/Controllers/Link.php | 48 + src/v1/Controllers/Location.php | 33 +- src/v1/Controllers/Log.php | 12 +- src/v1/Controllers/Login.php | 42 +- src/v1/Controllers/Mailcollector.php | 54 +- src/v1/Controllers/Menu.php | 50 +- src/v1/Controllers/Monitor.php | 1 + src/v1/Controllers/Networkequipment.php | 1 + src/v1/Controllers/Networkname.php | 72 + src/v1/Controllers/Notification.php | 32 +- src/v1/Controllers/Notificationtemplate.php | 35 +- src/v1/Controllers/Pdu.php | 48 + src/v1/Controllers/Peripheral.php | 1 + src/v1/Controllers/Phone.php | 1 + src/v1/Controllers/Printer.php | 57 +- src/v1/Controllers/Problem.php | 124 + src/v1/Controllers/Profile.php | 151 +- src/v1/Controllers/Project.php | 511 +- src/v1/Controllers/Projecttask.php | 157 + src/v1/Controllers/Queuednotification.php | 7 +- src/v1/Controllers/Rules/Common.php | 26 +- src/v1/Controllers/Rules/Criterium.php | 4 +- src/v1/Controllers/Search.php | 38 +- src/v1/Controllers/Slm.php | 130 + src/v1/Controllers/Software.php | 334 +- src/v1/Controllers/Softwarecategory.php | 56 + src/v1/Controllers/Softwarelicense.php | 28 +- src/v1/Controllers/Softwarelicensetype.php | 67 + src/v1/Controllers/Softwareversion.php | 31 + src/v1/Controllers/State.php | 85 +- src/v1/Controllers/Supplier.php | 89 +- src/v1/Controllers/Ticket.php | 314 +- src/v1/Controllers/Tickettemplate.php | 17 +- src/v1/Controllers/Token.php | 14 +- src/v1/Controllers/User.php | 245 +- src/v1/Views/subitem/analysis.html.twig | 20 + src/v1/Views/subitem/appliances.html.twig | 8 +- src/v1/Views/subitem/approvals.html.twig | 43 + .../Views/subitem/associateditems.html.twig | 8 +- src/v1/Views/subitem/attacheditems.html.twig | 92 + src/v1/Views/subitem/budgetmain.html.twig | 52 + .../subitem/businesscriticities.html.twig | 35 + .../subitem/cartridgesprinters.html.twig | 24 +- src/v1/Views/subitem/categories.html.twig | 64 +- src/v1/Views/subitem/certificates.html.twig | 26 +- src/v1/Views/subitem/components.html.twig | 948 +++- src/v1/Views/subitem/connections.html.twig | 8 +- src/v1/Views/subitem/contracts.html.twig | 24 +- src/v1/Views/subitem/costs.html.twig | 8 +- src/v1/Views/subitem/dcrooms.html.twig | 25 + .../subitem/documentcategories.html.twig | 27 + src/v1/Views/subitem/documents.html.twig | 16 +- src/v1/Views/subitem/domains.html.twig | 54 +- src/v1/Views/subitem/entities.html.twig | 8 +- src/v1/Views/subitem/groups.html.twig | 20 +- src/v1/Views/subitem/holidays.html.twig | 39 + src/v1/Views/subitem/infocom.html.twig | 18 + src/v1/Views/subitem/items.html.twig | 486 +- src/v1/Views/subitem/itil.html.twig | 224 +- src/v1/Views/subitem/itilchanges.html.twig | 36 +- src/v1/Views/subitem/itilproblems.html.twig | 36 +- src/v1/Views/subitem/itiltickets.html.twig | 44 +- .../subitem/knowbaseitemcategories.html.twig | 35 + src/v1/Views/subitem/licenses.html.twig | 61 + src/v1/Views/subitem/locations.html.twig | 8 +- src/v1/Views/subitem/networkalias.html.twig | 76 + src/v1/Views/subitem/plans.html.twig | 20 + src/v1/Views/subitem/plugs.html.twig | 27 + src/v1/Views/subitem/projects.html.twig | 8 +- src/v1/Views/subitem/projecttasks.html.twig | 22 +- .../Views/subitem/projecttaskteams.html.twig | 27 + src/v1/Views/subitem/records.html.twig | 8 +- src/v1/Views/subitem/reservations.html.twig | 116 + src/v1/Views/subitem/sections.html.twig | 2 +- src/v1/Views/subitem/slaola.html.twig | 37 + .../subitem/softwarecategories.html.twig | 27 + .../Views/subitem/softwareinstall.html.twig | 81 + .../Views/subitem/softwarelicenses.html.twig | 8 +- .../subitem/softwarelicensetypes.html.twig | 35 + src/v1/Views/subitem/softwares.html.twig | 50 +- src/v1/Views/subitem/states.html.twig | 8 +- .../Views/subitem/suppliercontacts.html.twig | 16 +- .../Views/subitem/suppliercontracts.html.twig | 16 +- src/v1/Views/subitem/suppliers.html.twig | 16 +- src/v1/Views/subitem/timeranges.html.twig | 23 + src/v1/Views/subitem/users.html.twig | 171 +- src/v1/Views/subitem/versions.html.twig | 16 +- src/v1/Views/subitem/virtualization.html.twig | 44 +- src/v1/Views/subitem/vlans.html.twig | 35 + src/v1/Views/subitem/volumes.html.twig | 24 +- .../v1/Controllers/NotificationTicketTest.php | 36 + tests/unit/v1/Controllers/TicketTest.php | 3 + 406 files changed, 23452 insertions(+), 2674 deletions(-) create mode 100644 db/migrations/20241128145104_ticketvalidations_update_migration.php create mode 100644 src/Models/Calendarsegment.php create mode 100644 src/Models/ChangeItem.php create mode 100644 src/Models/ChangeProblem.php create mode 100644 src/Models/ChangeTicket.php create mode 100644 src/Models/Changecost.php create mode 100644 src/Models/Changevalidation.php create mode 100644 src/Models/ContractItem.php create mode 100644 src/Models/Dcroom.php create mode 100644 src/Models/Definitions/Calendarsegment.php create mode 100644 src/Models/Definitions/ChangeItem.php create mode 100644 src/Models/Definitions/ChangeProblem.php create mode 100644 src/Models/Definitions/ChangeTicket.php create mode 100644 src/Models/Definitions/Changecost.php create mode 100644 src/Models/Definitions/Changevalidation.php create mode 100644 src/Models/Definitions/ContractItem.php create mode 100644 src/Models/Definitions/Dcroom.php create mode 100644 src/Models/Definitions/Infocom.php create mode 100644 src/Models/Definitions/ItemDevicebattery.php create mode 100644 src/Models/Definitions/ItemDevicecase.php create mode 100644 src/Models/Definitions/ItemDevicecontrol.php create mode 100644 src/Models/Definitions/ItemDevicedrive.php create mode 100644 src/Models/Definitions/ItemDevicefirmware.php create mode 100644 src/Models/Definitions/ItemDevicegeneric.php create mode 100644 src/Models/Definitions/ItemDevicegraphiccard.php create mode 100644 src/Models/Definitions/ItemDeviceharddrive.php create mode 100644 src/Models/Definitions/ItemDevicememory.php create mode 100644 src/Models/Definitions/ItemDevicemotherboard.php create mode 100644 src/Models/Definitions/ItemDevicenetworkcard.php create mode 100644 src/Models/Definitions/ItemDevicepci.php create mode 100644 src/Models/Definitions/ItemDevicepowersupply.php create mode 100644 src/Models/Definitions/ItemDeviceprocessor.php create mode 100644 src/Models/Definitions/ItemDevicesensor.php create mode 100644 src/Models/Definitions/ItemDevicesoundcard.php create mode 100644 src/Models/Definitions/ItemEnclosure.php create mode 100644 src/Models/Definitions/ItemProblem.php create mode 100644 src/Models/Definitions/ItemSoftwarelicence.php create mode 100644 src/Models/Definitions/ItemSoftwareversion.php create mode 100644 src/Models/Definitions/ItemTicket.php create mode 100644 src/Models/Definitions/Networkalias.php create mode 100644 src/Models/Definitions/Ola.php create mode 100644 src/Models/Definitions/ProblemTicket.php create mode 100644 src/Models/Definitions/Problemcost.php create mode 100644 src/Models/Definitions/ProjecttaskTicket.php create mode 100644 src/Models/Definitions/Projecttaskteam.php create mode 100644 src/Models/Definitions/Reservation.php create mode 100644 src/Models/Definitions/Reservationitem.php create mode 100644 src/Models/Definitions/Sla.php create mode 100644 src/Models/Definitions/Ticketvalidation.php create mode 100644 src/Models/Infocom.php create mode 100644 src/Models/ItemDevicebattery.php create mode 100644 src/Models/ItemDevicecase.php create mode 100644 src/Models/ItemDevicecontrol.php create mode 100644 src/Models/ItemDevicedrive.php create mode 100644 src/Models/ItemDevicefirmware.php create mode 100644 src/Models/ItemDevicegeneric.php create mode 100644 src/Models/ItemDevicegraphiccard.php create mode 100644 src/Models/ItemDeviceharddrive.php create mode 100644 src/Models/ItemDevicememory.php create mode 100644 src/Models/ItemDevicemotherboard.php create mode 100644 src/Models/ItemDevicenetworkcard.php create mode 100644 src/Models/ItemDevicepci.php create mode 100644 src/Models/ItemDevicepowersupply.php create mode 100644 src/Models/ItemDeviceprocessor.php create mode 100644 src/Models/ItemDevicesensor.php create mode 100644 src/Models/ItemDevicesoundcard.php create mode 100644 src/Models/ItemEnclosure.php create mode 100644 src/Models/ItemProblem.php create mode 100644 src/Models/ItemSoftwarelicence.php create mode 100644 src/Models/ItemSoftwareversion.php create mode 100644 src/Models/ItemTicket.php create mode 100644 src/Models/Networkalias.php create mode 100644 src/Models/Ola.php create mode 100644 src/Models/ProblemTicket.php create mode 100644 src/Models/Problemcost.php create mode 100644 src/Models/ProjecttaskTicket.php create mode 100644 src/Models/Projecttaskteam.php create mode 100644 src/Models/Reservation.php create mode 100644 src/Models/Reservationitem.php create mode 100644 src/Models/Sla.php create mode 100644 src/Models/Ticketvalidation.php create mode 100644 src/v1/Controllers/Computerantivirus.php create mode 100644 src/v1/Controllers/Dcroom.php create mode 100644 src/v1/Controllers/Softwareversion.php create mode 100644 src/v1/Views/subitem/analysis.html.twig create mode 100644 src/v1/Views/subitem/approvals.html.twig create mode 100644 src/v1/Views/subitem/attacheditems.html.twig create mode 100644 src/v1/Views/subitem/budgetmain.html.twig create mode 100644 src/v1/Views/subitem/businesscriticities.html.twig create mode 100644 src/v1/Views/subitem/dcrooms.html.twig create mode 100644 src/v1/Views/subitem/documentcategories.html.twig create mode 100644 src/v1/Views/subitem/holidays.html.twig create mode 100644 src/v1/Views/subitem/infocom.html.twig create mode 100644 src/v1/Views/subitem/knowbaseitemcategories.html.twig create mode 100644 src/v1/Views/subitem/licenses.html.twig create mode 100644 src/v1/Views/subitem/networkalias.html.twig create mode 100644 src/v1/Views/subitem/plans.html.twig create mode 100644 src/v1/Views/subitem/plugs.html.twig create mode 100644 src/v1/Views/subitem/projecttaskteams.html.twig create mode 100644 src/v1/Views/subitem/reservations.html.twig create mode 100644 src/v1/Views/subitem/slaola.html.twig create mode 100644 src/v1/Views/subitem/softwarecategories.html.twig create mode 100644 src/v1/Views/subitem/softwareinstall.html.twig create mode 100644 src/v1/Views/subitem/softwarelicensetypes.html.twig create mode 100644 src/v1/Views/subitem/timeranges.html.twig create mode 100644 src/v1/Views/subitem/vlans.html.twig diff --git a/db/migrations/20241001134535_notepads_migration.php b/db/migrations/20241001134535_notepads_migration.php index acedf162c2..796ffe4ec7 100644 --- a/db/migrations/20241001134535_notepads_migration.php +++ b/db/migrations/20241001134535_notepads_migration.php @@ -33,6 +33,11 @@ public function change() $rows = $stmt->fetchAll(); foreach ($rows as $row) { + if ($row['itemtype'] == 'Entity') + { + $row['items_id'] = $row['items_id'] + 1; + } + $data = [ [ 'id' => $row['id'], diff --git a/db/migrations/20241128145104_ticketvalidations_update_migration.php b/db/migrations/20241128145104_ticketvalidations_update_migration.php new file mode 100644 index 0000000000..d871ab3f1b --- /dev/null +++ b/db/migrations/20241128145104_ticketvalidations_update_migration.php @@ -0,0 +1,30 @@ +table('ticketvalidations'); + $table->addColumn('created_at', 'timestamp', ['null' => true, 'after' => 'id']) + ->addColumn('updated_at', 'timestamp', ['null' => true, 'after' => 'created_at']) + ->addColumn('deleted_at', 'timestamp', ['null' => true, 'after' => 'updated_at']) + ->addColumn('is_recursive', 'boolean', ['null' => false, 'default' => false, 'after' => 'entity_id']) + ->update(); + } + + public function down() + { + $table = $this->table('ticketvalidations'); + $table->removeColumn('created_at') + ->removeColumn('updated_at') + ->removeColumn('deleted_at') + ->removeColumn('entity_id') + ->update(); + } +} diff --git a/src/Models/Appliance.php b/src/Models/Appliance.php index 3d3209b763..3d7a64952f 100644 --- a/src/Models/Appliance.php +++ b/src/Models/Appliance.php @@ -29,6 +29,7 @@ class Appliance extends Common 'entity', 'certificates', 'domains', + 'infocom', ]; protected $visible = [ @@ -50,19 +51,20 @@ class Appliance extends Common 'tickets', 'problems', 'changes', + 'infocom', ]; protected $with = [ 'location:id,name', 'type:id,name', 'state:id,name', - 'user:id,name', - 'group:id,name', - 'userstech:id,name', - 'groupstech:id,name', + 'user:id,name,firstname,lastname', + 'group:id,name,completename', + 'userstech:id,name,firstname,lastname', + 'groupstech:id,name,completename', 'manufacturer:id,name', 'environment:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'certificates:id,name', 'domains:id,name', 'knowbaseitems:id,name', @@ -71,6 +73,7 @@ class Appliance extends Common 'tickets:id,name', 'problems:id,name', 'changes:id,name', + 'infocom', ]; public function location(): BelongsTo @@ -211,4 +214,12 @@ public function changes(): MorphToMany 'change_id', ); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } } diff --git a/src/Models/Appliancetype.php b/src/Models/Appliancetype.php index c8c2fe4ddd..43b4c1421d 100644 --- a/src/Models/Appliancetype.php +++ b/src/Models/Appliancetype.php @@ -23,7 +23,7 @@ class Appliancetype extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Models/Budget.php b/src/Models/Budget.php index a0208011ea..316ce959b6 100644 --- a/src/Models/Budget.php +++ b/src/Models/Budget.php @@ -35,7 +35,7 @@ class Budget extends Common protected $with = [ 'location:id,name', 'type:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'notes:id', 'knowbaseitems:id,name', 'documents:id,name', diff --git a/src/Models/Businesscriticity.php b/src/Models/Businesscriticity.php index 87fbc61b8d..e11c46dd7a 100644 --- a/src/Models/Businesscriticity.php +++ b/src/Models/Businesscriticity.php @@ -26,12 +26,12 @@ class Businesscriticity extends Common protected $with = [ 'category:id,name', - 'entity:id,name', + 'entity:id,name,completename', ]; public function category(): BelongsTo { - return $this->belongsTo('\App\Models\Businesscriticity'); + return $this->belongsTo('\App\Models\Businesscriticity', 'businesscriticity_id'); } public function entity(): BelongsTo diff --git a/src/Models/Calendar.php b/src/Models/Calendar.php index 7035f08501..66aa09cadb 100644 --- a/src/Models/Calendar.php +++ b/src/Models/Calendar.php @@ -3,6 +3,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; @@ -17,18 +18,34 @@ class Calendar extends Common protected $appends = [ 'entity', + 'timeranges', + 'holidays', ]; protected $visible = [ 'entity', + 'timeranges', + 'holidays', ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', + 'timeranges', + 'holidays', ]; public function entity(): BelongsTo { return $this->belongsTo('\App\Models\Entity'); } + + public function timeranges(): HasMany + { + return $this->hasMany('\App\Models\Calendarsegment', 'calendar_id'); + } + + public function holidays(): BelongsToMany + { + return $this->belongsToMany('\App\Models\Holiday', 'calendar_holiday', 'calendar_id', 'holiday_id'); + } } diff --git a/src/Models/Calendarsegment.php b/src/Models/Calendarsegment.php new file mode 100644 index 0000000000..1e406d55b1 --- /dev/null +++ b/src/Models/Calendarsegment.php @@ -0,0 +1,33 @@ +belongsTo('\App\Models\Entity'); + } +} diff --git a/src/Models/Cartridge.php b/src/Models/Cartridge.php index 1da2aeb84a..b012e4986b 100644 --- a/src/Models/Cartridge.php +++ b/src/Models/Cartridge.php @@ -33,7 +33,7 @@ class Cartridge extends Common protected $with = [ 'cartridgeitems:id,name,cartridgeitemtype_id', - 'printer:id,name', + 'printer', ]; diff --git a/src/Models/Cartridgeitem.php b/src/Models/Cartridgeitem.php index efc01c58c7..86636dc1c3 100644 --- a/src/Models/Cartridgeitem.php +++ b/src/Models/Cartridgeitem.php @@ -24,6 +24,7 @@ class Cartridgeitem extends Common 'userstech', 'location', 'entity', + 'infocom', ]; protected $visible = [ @@ -37,19 +38,21 @@ class Cartridgeitem extends Common 'documents', 'cartridges', 'printermodels', + 'infocom', ]; protected $with = [ 'type:id,name', 'manufacturer:id,name', - 'groupstech:id,name', - 'userstech:id,name', + 'groupstech:id,name,completename', + 'userstech:id,name,firstname,lastname', 'location:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'notes:id', 'documents:id,name', 'cartridges:id', 'printermodels:id,name', + 'infocom', ]; @@ -117,4 +120,12 @@ public function printermodels(): BelongsToMany 'printermodel_id' ); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } } diff --git a/src/Models/Category.php b/src/Models/Category.php index 04f8f7a129..4458603af4 100644 --- a/src/Models/Category.php +++ b/src/Models/Category.php @@ -43,14 +43,14 @@ class Category extends Common protected $with = [ 'category:id,name', - 'users:id,name', - 'groups:id,name', + 'users:id,name,firstname,lastname', + 'groups:id,name,completename', 'knowbaseitemcategories:id,name', 'tickettemplatesDemand:id,name', 'tickettemplatesIncident:id,name', 'changetemplates:id,name', 'problemtemplates:id,name', - 'entity:id,name', + 'entity:id,name,completename', ]; public function getCompletenameAttribute() diff --git a/src/Models/Certificate.php b/src/Models/Certificate.php index bb82901a28..b8f4b87e4b 100644 --- a/src/Models/Certificate.php +++ b/src/Models/Certificate.php @@ -27,6 +27,7 @@ class Certificate extends Common 'manufacturer', 'entity', 'notes', + 'infocom', ]; protected $visible = [ @@ -46,18 +47,19 @@ class Certificate extends Common 'tickets', 'problems', 'changes', + 'infocom', ]; protected $with = [ 'location:id,name', 'type:id,name', 'state:id,name', - 'user:id,name', - 'group:id,name', - 'userstech:id,name', - 'groupstech:id,name', + 'user:id,name,firstname,lastname', + 'group:id,name,completename', + 'userstech:id,name,firstname,lastname', + 'groupstech:id,name,completename', 'manufacturer:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'notes:id', 'knowbaseitems:id,name', 'documents:id,name', @@ -65,6 +67,7 @@ class Certificate extends Common 'tickets:id,name', 'problems:id,name', 'changes:id,name', + 'infocom', ]; public function location(): BelongsTo @@ -186,4 +189,12 @@ public function changes(): MorphToMany 'change_id', ); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } } diff --git a/src/Models/Certificatetype.php b/src/Models/Certificatetype.php index 0104149266..491eb933ec 100644 --- a/src/Models/Certificatetype.php +++ b/src/Models/Certificatetype.php @@ -23,7 +23,7 @@ class Certificatetype extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Models/Change.php b/src/Models/Change.php index 3f135f1bb9..47d2d7fee6 100644 --- a/src/Models/Change.php +++ b/src/Models/Change.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\Relations\MorphToMany; use Illuminate\Database\Eloquent\Relations\MorphMany; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; class Change extends Common { @@ -14,7 +15,7 @@ class Change extends Common protected $definition = '\App\Models\Definitions\Change'; protected $titles = ['Change', 'Changes']; - protected $icon = 'clipboard check'; + protected $icon = 'paint roller'; protected $appends = [ 'itilcategorie', @@ -22,6 +23,9 @@ class Change extends Common 'usersidrecipient', 'entity', 'notes', + 'costs', + 'items', + 'approvals', ]; protected $visible = [ @@ -35,19 +39,25 @@ class Change extends Common 'requestergroup', 'technician', 'techniciangroup', + 'costs', + 'items', + 'approvals', ]; protected $with = [ 'itilcategorie:id,name', - 'usersidlastupdater:id,name', - 'usersidrecipient:id,name', - 'entity:id,name', + 'usersidlastupdater:id,name,firstname,lastname', + 'usersidrecipient:id,name,firstname,lastname', + 'entity:id,name,completename', 'notes:id', 'knowbaseitems:id,name', - 'requester', - 'requestergroup', - 'technician', - 'techniciangroup', + 'requester:id,name,firstname,lastname', + 'requestergroup:id,name,completename', + 'technician:id,name,firstname,lastname', + 'techniciangroup:id,name,completename', + 'costs', + 'items', + 'approvals', ]; public function itilcategorie(): BelongsTo @@ -108,4 +118,27 @@ public function techniciangroup() { return $this->belongsToMany('\App\Models\Group')->wherePivot('type', 2); } + + public function costs(): HasMany + { + return $this->hasMany('App\Models\Changecost', 'change_id'); + } + + public function getFeeds($id) + { + global $translator; + $feeds = []; + + return $feeds; + } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ChangeItem', 'change_id'); + } + + public function approvals(): HasMany + { + return $this->hasMany('\App\Models\Changevalidation', 'change_id'); + } } diff --git a/src/Models/ChangeItem.php b/src/Models/ChangeItem.php new file mode 100644 index 0000000000..02156f1bd0 --- /dev/null +++ b/src/Models/ChangeItem.php @@ -0,0 +1,16 @@ +belongsTo('\App\Models\Entity'); + } + + public function budget(): BelongsTo + { + return $this->belongsTo('\App\Models\Budget'); + } +} diff --git a/src/Models/Changetemplate.php b/src/Models/Changetemplate.php index 7003a629c5..6deed48589 100644 --- a/src/Models/Changetemplate.php +++ b/src/Models/Changetemplate.php @@ -21,7 +21,7 @@ class Changetemplate extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Models/Changevalidation.php b/src/Models/Changevalidation.php new file mode 100644 index 0000000000..4e1986a214 --- /dev/null +++ b/src/Models/Changevalidation.php @@ -0,0 +1,50 @@ +belongsTo('\App\Models\Entity'); + } + + public function usersrequester(): BelongsTo + { + return $this->belongsTo('\App\Models\User', 'user_id'); + } + + public function uservalidate(): BelongsTo + { + return $this->belongsTo('\App\Models\User', 'user_id_validate'); + } +} diff --git a/src/Models/Cluster.php b/src/Models/Cluster.php index 31f9f550b0..fefaf51767 100644 --- a/src/Models/Cluster.php +++ b/src/Models/Cluster.php @@ -42,9 +42,9 @@ class Cluster extends Common protected $with = [ 'type:id,name', 'state:id,name', - 'userstech:id,name', - 'groupstech:id,name', - 'entity:id,name', + 'userstech:id,name,firstname,lastname', + 'groupstech:id,name,completename', + 'entity:id,name,completename', 'appliances:id,name', 'documents:id,name', 'contracts:id,name', diff --git a/src/Models/Clustertype.php b/src/Models/Clustertype.php index 2e10e2841d..5ecff9d1cd 100644 --- a/src/Models/Clustertype.php +++ b/src/Models/Clustertype.php @@ -24,7 +24,7 @@ class Clustertype extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Models/Common.php b/src/Models/Common.php index ea49db4845..66b8f5ea4a 100644 --- a/src/Models/Common.php +++ b/src/Models/Common.php @@ -32,7 +32,9 @@ public function __construct(array $attributes = []) if (isset($definition['dbname'])) { $this->fillable[] = $definition['dbname']; - } else { + } + else + { $this->fillable[] = $definition['name']; } } @@ -90,7 +92,9 @@ public function getNameFromID($id) if (count($items) == 0) { return ''; - } else { + } + else + { return current($items)['name']; } } @@ -300,11 +304,14 @@ public function getSpecificFunction($functionName) */ public function getFormData($myItem, $otherDefs = false) { - $def = $myItem->getDefinitions(); if ($otherDefs !== false) { $def = $otherDefs; } + else + { + $def = $myItem->getDefinitions(); + } if ($myItem == null) { return $def; @@ -346,23 +353,30 @@ public function getFormData($myItem, $otherDefs = false) } $field['value'] = implode(',', $values); $field['valuename'] = implode(',', $valuenames); - } else { + } + else + { // var_dump($field['name']); // #EB // var_dump($myItem->{$field['name']}->id); // #EB $field['value'] = $myItem->{$field['name']}->id; $field['valuename'] = $myItem->{$field['name']}->name; } - } elseif ($field['type'] == 'textarea') + } + elseif ($field['type'] == 'textarea') { if (is_null($myItem->{$field['name']})) { $field['value'] = ''; - } else { + } + else + { // We convert html to markdown $field['value'] = \App\v1\Controllers\Toolbox::convertHtmlToMarkdown($myItem->{$field['name']}); } - } else { + } + else + { $field['value'] = $myItem->{$field['name']}; } if (isset($field['readonly'])) diff --git a/src/Models/Computer.php b/src/Models/Computer.php index 3043cc29d3..988c799ff5 100644 --- a/src/Models/Computer.php +++ b/src/Models/Computer.php @@ -31,6 +31,7 @@ class Computer extends Common // 'location', // 'autoupdatesystem', 'entity', + 'infocom', ]; protected $visible = [ @@ -68,6 +69,8 @@ class Computer extends Common 'devicecases', 'devicegraphiccards', 'devicedrives', + 'infocom', + 'reservations', ]; protected $with = [ @@ -76,10 +79,10 @@ class Computer extends Common 'state:id,name', 'manufacturer:id,name', 'network:id,name', - 'groupstech:id,name', - 'userstech:id,name', - 'user:id,name', - 'group:id,name', + 'groupstech:id,name,completename', + 'userstech:id,name,firstname,lastname', + 'user:id,name,firstname,lastname', + 'group:id,name,completename', 'location:id,name', 'autoupdatesystem:id,name', 'softwareversions:id,name', @@ -94,7 +97,7 @@ class Computer extends Common 'volumes:id,name', 'virtualization:id,name', 'certificates:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'domains:id,name', 'appliances:id,name', 'notes:id', @@ -114,6 +117,8 @@ class Computer extends Common 'devicecases:id,name', 'devicegraphiccards:id,name', 'devicedrives:id,name', + 'infocom', + 'reservations', ]; protected static function booted(): void @@ -176,12 +181,12 @@ public function userstech(): BelongsTo public function user(): BelongsTo { - return $this->belongsTo('\App\Models\User'); + return $this->belongsTo('\App\Models\User', 'user_id'); } public function group(): BelongsTo { - return $this->belongsTo('\App\Models\Group'); + return $this->belongsTo('\App\Models\Group', 'group_id'); } public function location(): BelongsTo @@ -233,6 +238,9 @@ public function memories(): MorphToMany 'serial', 'busID', 'location_id', + 'otherserial', + 'state_id', + 'id', ); } @@ -245,6 +253,10 @@ public function firmwares(): MorphToMany )->withPivot( 'devicefirmware_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -260,6 +272,11 @@ public function processors(): MorphToMany 'nbcores', 'nbthreads', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -274,6 +291,10 @@ public function harddrives(): MorphToMany 'capacity', 'serial', 'location_id', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -288,6 +309,9 @@ public function batteries(): MorphToMany 'manufacturing_date', 'serial', 'location_id', + 'otherserial', + 'state_id', + 'id', ); } @@ -300,6 +324,11 @@ public function soundcards(): MorphToMany )->withPivot( 'devicesoundcard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -312,6 +341,11 @@ public function controllers(): MorphToMany )->withPivot( 'devicecontrol_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -450,6 +484,10 @@ public function powersupplies(): MorphToMany )->withPivot( 'devicepowersupply_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -462,6 +500,10 @@ public function sensors(): MorphToMany )->withPivot( 'devicesensor_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -474,6 +516,11 @@ public function devicepcis(): MorphToMany )->withPivot( 'devicepci_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -486,6 +533,10 @@ public function devicegenerics(): MorphToMany )->withPivot( 'devicegeneric_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -498,6 +549,12 @@ public function devicenetworkcards(): MorphToMany )->withPivot( 'devicenetworkcard_id', 'location_id', + 'mac', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -510,6 +567,14 @@ public function devicesimcards(): MorphToMany )->withPivot( 'devicesimcard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'msin', + 'user_id', + 'group_id', + 'line_id', + 'id', ); } @@ -522,6 +587,10 @@ public function devicemotherboards(): MorphToMany )->withPivot( 'devicemotherboard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -534,6 +603,10 @@ public function devicecases(): MorphToMany )->withPivot( 'devicecase_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -546,6 +619,12 @@ public function devicegraphiccards(): MorphToMany )->withPivot( 'devicegraphiccard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'memory', + 'id', ); } @@ -558,6 +637,27 @@ public function devicedrives(): MorphToMany )->withPivot( 'devicedrive_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', + ); + } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } + + public function reservations(): MorphMany + { + return $this->morphMany( + '\App\Models\Reservationitem', + 'item', ); } } diff --git a/src/Models/Consumable.php b/src/Models/Consumable.php index 1c20b70033..92d457e389 100644 --- a/src/Models/Consumable.php +++ b/src/Models/Consumable.php @@ -27,7 +27,7 @@ class Consumable extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; diff --git a/src/Models/Consumableitem.php b/src/Models/Consumableitem.php index 1fd3ecf6e7..0c59c5b951 100644 --- a/src/Models/Consumableitem.php +++ b/src/Models/Consumableitem.php @@ -23,6 +23,7 @@ class Consumableitem extends Common 'userstech', 'location', 'entity', + 'infocom', ]; protected $visible = [ @@ -35,18 +36,20 @@ class Consumableitem extends Common 'notes', 'documents', 'consumables', + 'infocom', ]; protected $with = [ 'type:id,name', 'manufacturer:id,name', - 'groupstech:id,name', - 'userstech:id,name', + 'groupstech:id,name,completename', + 'userstech:id,name,firstname,lastname', 'location:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'notes:id', 'documents:id,name', 'consumables:id', + 'infocom', ]; @@ -104,4 +107,12 @@ public function consumables(): HasMany { return $this->hasMany('\App\Models\Consumable', 'consumableitem_id'); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } } diff --git a/src/Models/Contact.php b/src/Models/Contact.php index 39992d94f5..1642e6be9c 100644 --- a/src/Models/Contact.php +++ b/src/Models/Contact.php @@ -36,7 +36,7 @@ class Contact extends Common protected $with = [ 'type:id,name', 'title:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'notes:id', 'documents:id,name', 'suppliers:id,name', diff --git a/src/Models/Contract.php b/src/Models/Contract.php index 2102e6b748..d749b391a3 100644 --- a/src/Models/Contract.php +++ b/src/Models/Contract.php @@ -38,7 +38,7 @@ class Contract extends Common protected $with = [ 'type:id,name', 'state:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'notes:id', 'knowbaseitems:id,name', 'documents:id,name', diff --git a/src/Models/ContractItem.php b/src/Models/ContractItem.php new file mode 100644 index 0000000000..1d0be60c45 --- /dev/null +++ b/src/Models/ContractItem.php @@ -0,0 +1,18 @@ +belongsTo('\App\Models\Entity'); } + + public function dcrooms(): HasMany + { + return $this->hasMany('App\Models\Dcroom'); + } } diff --git a/src/Models/Dcroom.php b/src/Models/Dcroom.php new file mode 100644 index 0000000000..0340a8047c --- /dev/null +++ b/src/Models/Dcroom.php @@ -0,0 +1,130 @@ +belongsTo('\App\Models\Location'); + } + + public function entity(): BelongsTo + { + return $this->belongsTo('\App\Models\Entity'); + } + + public function datacenter(): BelongsTo + { + return $this->belongsTo('App\Models\Datacenter', 'datacenter_id'); + } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } + + public function contracts(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Contract', + 'item', + 'contract_item' + )->withPivot( + 'contract_id', + ); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } + + public function tickets(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Ticket', + 'item', + 'item_ticket' + )->withPivot( + 'ticket_id', + ); + } + + public function problems(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Problem', + 'item', + 'item_problem' + )->withPivot( + 'problem_id', + ); + } + + public function changes(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Change', + 'item', + 'change_item' + )->withPivot( + 'change_id', + ); + } +} diff --git a/src/Models/Definitions/Appliance.php b/src/Models/Definitions/Appliance.php index 378ea65019..e2cc88628f 100644 --- a/src/Models/Definitions/Appliance.php +++ b/src/Models/Definitions/Appliance.php @@ -188,6 +188,344 @@ public static function getDefinition() ]; } + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -220,7 +558,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Certificate', 'Certificates', 2), diff --git a/src/Models/Definitions/Budget.php b/src/Models/Definitions/Budget.php index 9ff58b8a40..14cdb2f8d4 100644 --- a/src/Models/Definitions/Budget.php +++ b/src/Models/Definitions/Budget.php @@ -123,12 +123,12 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Main'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/budgetmain', ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), 'icon' => 'desktop', - 'link' => '', + 'link' => $rootUrl . '/attacheditems', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Businesscriticity.php b/src/Models/Definitions/Businesscriticity.php index 188501ddb3..357efe0214 100644 --- a/src/Models/Definitions/Businesscriticity.php +++ b/src/Models/Definitions/Businesscriticity.php @@ -73,8 +73,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'edit', + 'link' => $rootUrl . '/businesscriticities', ], [ 'title' => $translator->translate('Historical'), diff --git a/src/Models/Definitions/Calendar.php b/src/Models/Definitions/Calendar.php index af18e5c636..c2f5f20627 100644 --- a/src/Models/Definitions/Calendar.php +++ b/src/Models/Definitions/Calendar.php @@ -64,13 +64,13 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Time range', 'Time ranges', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'edit', + 'link' => $rootUrl . '/timeranges', ], [ 'title' => $translator->translatePlural('Close time', 'Close times', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'edit', + 'link' => $rootUrl . '/holidays', ], [ 'title' => $translator->translate('Historical'), diff --git a/src/Models/Definitions/Calendarsegment.php b/src/Models/Definitions/Calendarsegment.php new file mode 100644 index 0000000000..888174bbd0 --- /dev/null +++ b/src/Models/Definitions/Calendarsegment.php @@ -0,0 +1,18 @@ + 1024) { $size = $size / 1024; - } else { + } + else + { break; } } @@ -321,6 +324,195 @@ public static function getSize($size) return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); } + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -343,7 +535,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Certificate.php b/src/Models/Definitions/Certificate.php index f42aee5189..5fc5358a34 100644 --- a/src/Models/Definitions/Certificate.php +++ b/src/Models/Definitions/Certificate.php @@ -250,6 +250,344 @@ public static function getDefinition() ]; } + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -261,7 +599,7 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Associated item', 'Associated items', 2), - 'icon' => 'caret square down outline', + 'icon' => 'desktop', 'link' => $rootUrl . '/associateditems', ], [ @@ -272,7 +610,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Contract', 'Contract', 2), diff --git a/src/Models/Definitions/Change.php b/src/Models/Definitions/Change.php index a1fe3464a3..96e5afd933 100644 --- a/src/Models/Definitions/Change.php +++ b/src/Models/Definitions/Change.php @@ -98,7 +98,7 @@ public static function getDefinition() 'id' => 7, 'title' => $translator->translate('Category'), 'type' => 'dropdown_remote', - 'name' => 'categorie', + 'name' => 'itilcategorie', 'dbname' => 'category_id', 'itemtype' => '\App\Models\Category', 'fillable' => true, @@ -196,14 +196,16 @@ public static function getDefinition() 'additionalfields' => ['status'] ]; if (!Session::isCron() // no filter for cron - && Session::getCurrentInterface() == 'helpdesk') { + && Session::getCurrentInterface() == 'helpdesk') + { $newtab['condition'] = ['is_helpdeskvisible' => 1]; } $tab[] = $newtab; // Filter search fields for helpdesk if (!Session::isCron() // no filter for cron - && Session::getCurrentInterface() != 'central') { + && Session::getCurrentInterface() != 'central') + { // last updater no search $newtab['nosearch'] = true; } @@ -495,7 +497,9 @@ public static function getTimestampArray($options = []) { $day = 0; $hour = floor($i / $HOUR_TIMESTAMP); - } else { + } + else + { $day = floor($i / $DAY_TIMESTAMP); $hour = floor(($i % $DAY_TIMESTAMP) / $HOUR_TIMESTAMP); } @@ -522,10 +526,13 @@ public static function getTimestampArray($options = []) $hour, $minute ); - } else { + } + else + { $values[$i] = sprintf($translator->translatePlural('%d day', '%d days', $day), $day); } - } elseif ($hour > 0 || $minute > 0) + } + elseif ($hour > 0 || $minute > 0) { if ($minute < 10) { @@ -546,6 +553,50 @@ public static function getTimestampArray($options = []) return $tab; } + public static function getDefinitionAnalysis() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Impacts'), + 'type' => 'textarea', + 'name' => 'impactcontent', + ], + [ + 'id' => 2, + 'title' => $translator->translate('Control list'), + 'type' => 'textarea', + 'name' => 'controlistcontent', + ], + ]; + } + + public static function getDefinitionPlans() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Deployment plan'), + 'type' => 'textarea', + 'name' => 'rolloutplancontent', + ], + [ + 'id' => 2, + 'title' => $translator->translate('Backup plan'), + 'type' => 'textarea', + 'name' => 'backoutplancontent', + ], + [ + 'id' => 3, + 'title' => $translator->translate('Checklist'), + 'type' => 'textarea', + 'name' => 'checklistcontent', + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -560,66 +611,64 @@ public static function getRelatedPages($rootUrl) 'icon' => 'caret square down outline', 'link' => '', ], - [ - 'title' => $translator->translatePlural('Change', 'Changes', 2), - 'icon' => 'caret square down outline', - 'link' => '', - ], [ 'title' => $translator->translate('Analysis'), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'edit', + 'link' => $rootUrl . '/analysis', ], [ 'title' => $translator->translate('Plans'), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'edit', + 'link' => $rootUrl . '/plans', ], [ 'title' => $translator->translate('Statistics'), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'chartline', + 'link' => $rootUrl . '/stats', ], [ - 'title' => $translator->translatePlural('Validation', 'Validations', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'title' => $translator->translatePlural('Approval', 'Approvals', 2), + 'icon' => 'thumbs up', + 'link' => $rootUrl . '/approvals', ], [ - 'title' => $translator->translatePlural('Cost', 'Costs', 2), - 'icon' => 'money bill alternate', - 'link' => '', + 'title' => $translator->translatePlural('Ticket', 'Tickets', 2), + 'icon' => 'hands helping', + 'link' => $rootUrl . '/tickets', + 'rightModel' => '\App\Models\Ticket', ], [ - 'title' => $translator->translatePlural('Project', 'Projects', 2), - 'icon' => 'folder open', - 'link' => '', + 'title' => $translator->translatePlural('Problem', 'Problems', 2), + 'icon' => 'drafting compass', + 'link' => $rootUrl . '/problem', + 'rightModel' => '\App\Models\Problem', ], [ - 'title' => $translator->translatePlural('Problem', 'Problems', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'title' => $translator->translatePlural('Cost', 'Costs', 2), + 'icon' => 'money bill alternate', + 'link' => $rootUrl . '/costs', ], [ - 'title' => $translator->translatePlural('Ticket', 'Tickets', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'title' => $translator->translatePlural('Project', 'Projects', 2), + 'icon' => 'folder open', + 'link' => $rootUrl . '/projects', + 'rightModel' => '\App\Models\Project', ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), 'icon' => 'desktop', - 'link' => '', - ], - [ - 'title' => $translator->translate('Knowledge base'), - 'icon' => 'book', - 'link' => $rootUrl . '/knowbaseitems', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Note', 'Notes', 2), 'icon' => 'sticky note', 'link' => $rootUrl . '/notes', ], + [ + 'title' => $translator->translate('Knowledge base'), + 'icon' => 'book', + 'link' => $rootUrl . '/knowbaseitems', + ], [ 'title' => $translator->translate('Historical'), 'icon' => 'history', diff --git a/src/Models/Definitions/ChangeItem.php b/src/Models/Definitions/ChangeItem.php new file mode 100644 index 0000000000..2f544239a9 --- /dev/null +++ b/src/Models/Definitions/ChangeItem.php @@ -0,0 +1,18 @@ + 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -247,6 +586,11 @@ public static function getRelatedPages($rootUrl) 'icon' => 'home', 'link' => $rootUrl, ], + [ + 'title' => $translator->translate('Impact analysis'), + 'icon' => 'caret square down outline', + 'link' => '', + ], [ 'title' => $translator->translatePlural('Operating system', 'Operating systems', 1), 'icon' => 'laptop house', @@ -277,6 +621,11 @@ public static function getRelatedPages($rootUrl) 'icon' => 'ethernet', 'link' => '', ], + [ + 'title' => $translator->translate('Management'), + 'icon' => 'caret square down outline', + 'link' => $rootUrl . '/infocom', + ], [ 'title' => $translator->translatePlural('Contract', 'Contract', 2), 'icon' => 'file signature', @@ -325,7 +674,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Reservation', 'Reservations', 2), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/reservations', ], [ 'title' => $translator->translatePlural('Domain', 'Domains', 2), diff --git a/src/Models/Definitions/Computerantivirus.php b/src/Models/Definitions/Computerantivirus.php index 9b28dab2eb..4090460f2e 100644 --- a/src/Models/Definitions/Computerantivirus.php +++ b/src/Models/Definitions/Computerantivirus.php @@ -9,12 +9,61 @@ public static function getDefinition() global $translator; return [ [ - 'id' => 2, - 'title' => $translator->translate('ID'), - 'type' => 'input', - 'name' => 'id', - 'display' => false, + 'id' => 1, + 'title' => $translator->translate('Name'), + 'type' => 'input', + 'name' => 'name', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translatePlural('Manufacturer', 'Manufacturers', 1), + 'type' => 'dropdown_remote', + 'name' => 'manufacturer', + 'dbname' => 'manufacturer_id', + 'itemtype' => '\App\Models\Manufacturer', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Antivirus version'), + 'type' => 'input', + 'name' => 'antivirus_version', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Expiration date'), + 'type' => 'date', + 'name' => 'date_expiration', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Signature database version'), + 'type' => 'input', + 'name' => 'signature_version', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Active'), + 'type' => 'boolean', + 'name' => 'is_active', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translate('Up to date'), + 'type' => 'boolean', + 'name' => 'is_uptodate', + 'fillable' => true, ], ]; } + public static function getRelatedPages($rootUrl) + { + global $translator; + return []; + } } diff --git a/src/Models/Definitions/Consumableitem.php b/src/Models/Definitions/Consumableitem.php index 09683babe2..7220afffba 100644 --- a/src/Models/Definitions/Consumableitem.php +++ b/src/Models/Definitions/Consumableitem.php @@ -232,7 +232,8 @@ public static function formatNumber($number, $edit = false, $forcedecimal = -1) if ($number == "") { $number = 0; - } elseif ($number == "-") + } + elseif ($number == "-") { // used for not defines value (from Infocom::Amort, p.e.) return "-"; } @@ -287,7 +288,9 @@ public static function getSize($size) if ($size > 1024) { $size = $size / 1024; - } else { + } + else + { break; } } @@ -295,6 +298,195 @@ public static function getSize($size) return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); } + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -312,7 +504,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Contract.php b/src/Models/Definitions/Contract.php index 0b0beab508..7a606d3b09 100644 --- a/src/Models/Definitions/Contract.php +++ b/src/Models/Definitions/Contract.php @@ -469,7 +469,8 @@ public static function formatNumber($number, $edit = false, $forcedecimal = -1) if ($number == "") { $number = 0; - } elseif ($number == "-") + } + elseif ($number == "-") { // used for not defines value (from Infocom::Amort, p.e.) return "-"; } @@ -524,7 +525,9 @@ public static function getSize($size) if ($size > 1024) { $size = $size / 1024; - } else { + } + else + { break; } } @@ -554,7 +557,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Item', 'Items', 2), 'icon' => 'desktop', - 'link' => '', + 'link' => $rootUrl . '/attacheditems', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/ContractItem.php b/src/Models/Definitions/ContractItem.php new file mode 100644 index 0000000000..78cf10ac3f --- /dev/null +++ b/src/Models/Definitions/ContractItem.php @@ -0,0 +1,18 @@ + 1024) { $size = $size / 1024; - } else { + } + else + { break; } } diff --git a/src/Models/Definitions/Datacenter.php b/src/Models/Definitions/Datacenter.php index 7e9609f1c4..85439b1571 100644 --- a/src/Models/Definitions/Datacenter.php +++ b/src/Models/Definitions/Datacenter.php @@ -65,7 +65,12 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Server room', 'Server rooms', 2), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/dcrooms', + ], + [ + 'title' => $translator->translate('Historical'), + 'icon' => 'history', + 'link' => $rootUrl . '/history', ], ]; } diff --git a/src/Models/Definitions/Dcroom.php b/src/Models/Definitions/Dcroom.php new file mode 100644 index 0000000000..fbb7963e0b --- /dev/null +++ b/src/Models/Definitions/Dcroom.php @@ -0,0 +1,470 @@ + 1, + 'title' => $translator->translate('Name'), + 'type' => 'input', + 'name' => 'name', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translatePlural('Data center', 'Data centers', 1), + 'type' => 'dropdown_remote', + 'name' => 'datacenter', + 'dbname' => 'datacenter_id', + 'itemtype' => '\App\Models\Datacenter', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translatePlural('Location', 'Locations', 1), + 'type' => 'dropdown_remote', + 'name' => 'location', + 'dbname' => 'location_id', + 'itemtype' => '\App\Models\Location', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Number of columns'), + 'type' => 'input', + 'name' => 'vis_cols', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Number of rows'), + 'type' => 'input', + 'name' => 'vis_rows', + 'fillable' => true, + ], + // [ + // 'id' => 80, + // 'title' => $translator->translatePlural('Entity', 'Entities', 1), + // 'type' => 'dropdown_remote', + // 'name' => 'completename', + // 'itemtype' => '\App\Models\Entity', + // ], + [ + 'id' => 86, + 'title' => $translator->translate('Child entities'), + 'type' => 'boolean', + 'name' => 'is_recursive', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Last update'), + 'type' => 'datetime', + 'name' => 'updated_at', + 'readonly' => 'readonly', + ], + [ + 'id' => 121, + 'title' => $translator->translate('Creation date'), + 'type' => 'datetime', + 'name' => 'created_at', + 'readonly' => 'readonly', + ], + ]; + } + + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + + public static function getRelatedPages($rootUrl) + { + global $translator; + return [ + [ + 'title' => $translator->translatePlural('Server room', 'Server rooms', 1), + 'icon' => 'home', + 'link' => $rootUrl, + ], + [ + 'title' => $translator->translate('Impact analysis'), + 'icon' => 'caret square down outline', + 'link' => '', + ], + [ + 'title' => $translator->translatePlural('Rack', 'Racks', 2), + 'icon' => 'caret square down outline', + 'link' => '', + ], + [ + 'title' => $translator->translate('Management'), + 'icon' => 'caret square down outline', + 'link' => $rootUrl . '/infocom', + ], + [ + 'title' => $translator->translatePlural('Contract', 'Contract', 2), + 'icon' => 'file signature', + 'link' => $rootUrl . '/contracts', + ], + [ + 'title' => $translator->translatePlural('Document', 'Documents', 2), + 'icon' => 'file', + 'link' => $rootUrl . '/documents', + ], + [ + 'title' => $translator->translatePlural('External link', 'External links', 2), + 'icon' => 'linkify', + 'link' => $rootUrl . '/externallinks', + ], + [ + 'title' => $translator->translate('ITIL'), + 'icon' => 'hands helping', + 'link' => $rootUrl . '/itil', + ], + [ + 'title' => $translator->translate('Historical'), + 'icon' => 'history', + 'link' => $rootUrl . '/history', + ], + ]; + } +} diff --git a/src/Models/Definitions/Devicebattery.php b/src/Models/Definitions/Devicebattery.php index 5a02dc8650..b677c38dad 100644 --- a/src/Models/Definitions/Devicebattery.php +++ b/src/Models/Definitions/Devicebattery.php @@ -104,8 +104,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Devicecase.php b/src/Models/Definitions/Devicecase.php index 70fda4fccc..7c9e3e911a 100644 --- a/src/Models/Definitions/Devicecase.php +++ b/src/Models/Definitions/Devicecase.php @@ -91,8 +91,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Devicecontrol.php b/src/Models/Definitions/Devicecontrol.php index fd81902466..a5c6580d1a 100644 --- a/src/Models/Definitions/Devicecontrol.php +++ b/src/Models/Definitions/Devicecontrol.php @@ -98,8 +98,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Devicedrive.php b/src/Models/Definitions/Devicedrive.php index 89e81892fd..1ea5fdafd6 100644 --- a/src/Models/Definitions/Devicedrive.php +++ b/src/Models/Definitions/Devicedrive.php @@ -105,8 +105,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Devicefirmware.php b/src/Models/Definitions/Devicefirmware.php index 2a76057253..01f69341b7 100644 --- a/src/Models/Definitions/Devicefirmware.php +++ b/src/Models/Definitions/Devicefirmware.php @@ -105,8 +105,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Devicegeneric.php b/src/Models/Definitions/Devicegeneric.php index 021d0fa2db..55ec6895ff 100644 --- a/src/Models/Definitions/Devicegeneric.php +++ b/src/Models/Definitions/Devicegeneric.php @@ -82,8 +82,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Devicegraphiccard.php b/src/Models/Definitions/Devicegraphiccard.php index 9a8d1007e2..f69b39d9c4 100644 --- a/src/Models/Definitions/Devicegraphiccard.php +++ b/src/Models/Definitions/Devicegraphiccard.php @@ -109,8 +109,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Deviceharddrive.php b/src/Models/Definitions/Deviceharddrive.php index 3cbc6f6aa1..c15f2b41c9 100644 --- a/src/Models/Definitions/Deviceharddrive.php +++ b/src/Models/Definitions/Deviceharddrive.php @@ -120,8 +120,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Devicememory.php b/src/Models/Definitions/Devicememory.php index a6c05d9078..761de95362 100644 --- a/src/Models/Definitions/Devicememory.php +++ b/src/Models/Definitions/Devicememory.php @@ -112,8 +112,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Devicemotherboard.php b/src/Models/Definitions/Devicemotherboard.php index 2df96bb3cd..b272c7e07f 100644 --- a/src/Models/Definitions/Devicemotherboard.php +++ b/src/Models/Definitions/Devicemotherboard.php @@ -89,8 +89,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Devicenetworkcard.php b/src/Models/Definitions/Devicenetworkcard.php index dc345352aa..04e259de02 100644 --- a/src/Models/Definitions/Devicenetworkcard.php +++ b/src/Models/Definitions/Devicenetworkcard.php @@ -96,8 +96,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Devicepci.php b/src/Models/Definitions/Devicepci.php index 1a855fadfd..fa5fbf07ee 100644 --- a/src/Models/Definitions/Devicepci.php +++ b/src/Models/Definitions/Devicepci.php @@ -82,8 +82,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Devicepowersupply.php b/src/Models/Definitions/Devicepowersupply.php index dafc3c5fc8..f9f5879b5f 100644 --- a/src/Models/Definitions/Devicepowersupply.php +++ b/src/Models/Definitions/Devicepowersupply.php @@ -96,8 +96,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Deviceprocessor.php b/src/Models/Definitions/Deviceprocessor.php index efd95da587..9b0e454e21 100644 --- a/src/Models/Definitions/Deviceprocessor.php +++ b/src/Models/Definitions/Deviceprocessor.php @@ -118,8 +118,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Devicesensor.php b/src/Models/Definitions/Devicesensor.php index a0d11a2118..1b25636d94 100644 --- a/src/Models/Definitions/Devicesensor.php +++ b/src/Models/Definitions/Devicesensor.php @@ -82,8 +82,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Devicesimcard.php b/src/Models/Definitions/Devicesimcard.php index 63aee8e012..f6f32a3bdb 100644 --- a/src/Models/Definitions/Devicesimcard.php +++ b/src/Models/Definitions/Devicesimcard.php @@ -100,8 +100,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Devicesoundcard.php b/src/Models/Definitions/Devicesoundcard.php index bd50d8d154..54b8d938dc 100644 --- a/src/Models/Definitions/Devicesoundcard.php +++ b/src/Models/Definitions/Devicesoundcard.php @@ -89,8 +89,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Document.php b/src/Models/Definitions/Document.php index 101abe36cf..04e385f830 100644 --- a/src/Models/Definitions/Document.php +++ b/src/Models/Definitions/Document.php @@ -142,7 +142,7 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Associated item', 'Associated items', 2), - 'icon' => 'caret square down outline', + 'icon' => 'desktop', 'link' => $rootUrl . '/associateditems', ], [ diff --git a/src/Models/Definitions/Documentcategory.php b/src/Models/Definitions/Documentcategory.php index 15bcd681b4..87ae2054ab 100644 --- a/src/Models/Definitions/Documentcategory.php +++ b/src/Models/Definitions/Documentcategory.php @@ -59,8 +59,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Document heading', 'Document headings', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'edit', + 'link' => $rootUrl . '/categories', ], [ 'title' => $translator->translate('Historical'), diff --git a/src/Models/Definitions/Domain.php b/src/Models/Definitions/Domain.php index 78ecfbe78d..a8d2211b36 100644 --- a/src/Models/Definitions/Domain.php +++ b/src/Models/Definitions/Domain.php @@ -131,6 +131,344 @@ public static function getDefinition() ]; } + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -152,13 +490,13 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Associated item', 'Associated items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/attacheditems', ], [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translate('ITIL'), diff --git a/src/Models/Definitions/Domainrelation.php b/src/Models/Definitions/Domainrelation.php index 48ec25233c..9b6805c70c 100644 --- a/src/Models/Definitions/Domainrelation.php +++ b/src/Models/Definitions/Domainrelation.php @@ -51,7 +51,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Domain', 'Domains', 2), 'icon' => 'globe americas', - 'link' => '', + 'link' => $rootUrl . '/domains', ], [ 'title' => $translator->translate('Historical'), diff --git a/src/Models/Definitions/Enclosure.php b/src/Models/Definitions/Enclosure.php index ab0ac2b677..1193557e84 100644 --- a/src/Models/Definitions/Enclosure.php +++ b/src/Models/Definitions/Enclosure.php @@ -128,6 +128,344 @@ public static function getDefinition() ]; } + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -144,8 +482,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Component', 'Components', 2), @@ -160,7 +498,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Contract', 'Contract', 2), diff --git a/src/Models/Definitions/Fqdn.php b/src/Models/Definitions/Fqdn.php index d592d926d3..4c77b7223f 100644 --- a/src/Models/Definitions/Fqdn.php +++ b/src/Models/Definitions/Fqdn.php @@ -72,7 +72,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Network alias', 'Network aliases', 1), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/networkalias', ], [ 'title' => $translator->translate('Historical'), diff --git a/src/Models/Definitions/Group.php b/src/Models/Definitions/Group.php index 6b02cafdfb..7214e753ce 100644 --- a/src/Models/Definitions/Group.php +++ b/src/Models/Definitions/Group.php @@ -33,7 +33,7 @@ public static function getDefinition() 'id' => 13, 'title' => $translator->translate('As child of'), 'type' => 'dropdown_remote', - 'name' => 'group', + 'name' => 'child', 'dbname' => 'group_id', 'itemtype' => '\App\Models\Group', 'fillable' => true, @@ -250,7 +250,7 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translate('Child groups'), - 'icon' => 'caret square down outline', + 'icon' => 'users', 'link' => $rootUrl . '/groups', ], [ @@ -275,18 +275,20 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translate('Created tickets'), - 'icon' => 'caret square down outline', + 'icon' => 'hands helping', 'link' => $rootUrl . '/tickets', ], [ 'title' => $translator->translatePlural('Problem', 'Problems', 2), - 'icon' => 'caret square down outline', + 'icon' => 'drafting compass', 'link' => $rootUrl . '/problems', + 'rightModel' => '\App\Models\Problem', ], [ 'title' => $translator->translatePlural('Change', 'Changes', 2), - 'icon' => 'caret square down outline', + 'icon' => 'paint roller', 'link' => $rootUrl . '/changes', + 'rightModel' => '\App\Models\Change', ], [ 'title' => $translator->translatePlural('Note', 'Notes', 2), diff --git a/src/Models/Definitions/Holiday.php b/src/Models/Definitions/Holiday.php index d1dfc2b88c..c800e2b655 100644 --- a/src/Models/Definitions/Holiday.php +++ b/src/Models/Definitions/Holiday.php @@ -83,16 +83,6 @@ public static function getRelatedPages($rootUrl) 'icon' => 'home', 'link' => $rootUrl, ], - [ - 'title' => $translator->translatePlural('Time range', 'Time ranges', 2), - 'icon' => 'caret square down outline', - 'link' => '', - ], - [ - 'title' => $translator->translatePlural('Close time', 'Close times', 2), - 'icon' => 'caret square down outline', - 'link' => '', - ], [ 'title' => $translator->translate('Historical'), 'icon' => 'history', diff --git a/src/Models/Definitions/Infocom.php b/src/Models/Definitions/Infocom.php new file mode 100644 index 0000000000..6dd8890f5d --- /dev/null +++ b/src/Models/Definitions/Infocom.php @@ -0,0 +1,18 @@ + $translator->translatePlural('VLAN', 'VLANs', 1), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'edit', + 'link' => $rootUrl . '/vlans', ], [ 'title' => $translator->translatePlural('IP address', 'IP addresses', 2), diff --git a/src/Models/Definitions/ItemDevicebattery.php b/src/Models/Definitions/ItemDevicebattery.php new file mode 100644 index 0000000000..8259938915 --- /dev/null +++ b/src/Models/Definitions/ItemDevicebattery.php @@ -0,0 +1,18 @@ +translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -116,7 +454,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/ItemDevicesoundcard.php b/src/Models/Definitions/ItemDevicesoundcard.php new file mode 100644 index 0000000000..5cbc2bb904 --- /dev/null +++ b/src/Models/Definitions/ItemDevicesoundcard.php @@ -0,0 +1,18 @@ + $translator->translatePlural('Knowledge base category', 'Knowledge base categories', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'edit', + 'link' => $rootUrl . '/knowbaseitemcategories', ], [ 'title' => $translator->translate('Icon'), diff --git a/src/Models/Definitions/Line.php b/src/Models/Definitions/Line.php index 08f0f27098..7843b94402 100644 --- a/src/Models/Definitions/Line.php +++ b/src/Models/Definitions/Line.php @@ -126,6 +126,345 @@ public static function getDefinition() ]; } + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -138,7 +477,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Contract', 'Contract', 2), diff --git a/src/Models/Definitions/Link.php b/src/Models/Definitions/Link.php index 494931e177..587d8c7bc1 100644 --- a/src/Models/Definitions/Link.php +++ b/src/Models/Definitions/Link.php @@ -118,8 +118,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Associated item type', 'Associated item types', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'desktop', + 'link' => $rootUrl . '/associateditemtypes', ], [ 'title' => $translator->translate('Historical'), diff --git a/src/Models/Definitions/Location.php b/src/Models/Definitions/Location.php index d423d3f574..740557c20d 100644 --- a/src/Models/Definitions/Location.php +++ b/src/Models/Definitions/Location.php @@ -219,7 +219,7 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', + 'icon' => 'desktop', 'link' => '', ], [ diff --git a/src/Models/Definitions/Monitor.php b/src/Models/Definitions/Monitor.php index 170a0cbacf..1a629db2d1 100644 --- a/src/Models/Definitions/Monitor.php +++ b/src/Models/Definitions/Monitor.php @@ -296,6 +296,345 @@ public static function getDefinitionOperatingSystem() ]; } + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -333,7 +672,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Contract', 'Contract', 2), @@ -368,7 +707,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Reservation', 'Reservations', 2), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/reservations', ], [ 'title' => $translator->translatePlural('Domain', 'Domains', 2), diff --git a/src/Models/Definitions/Networkalias.php b/src/Models/Definitions/Networkalias.php new file mode 100644 index 0000000000..9a0a48beb0 --- /dev/null +++ b/src/Models/Definitions/Networkalias.php @@ -0,0 +1,18 @@ + 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -326,7 +665,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Contract', 'Contract', 2), @@ -361,7 +700,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Reservation', 'Reservations', 2), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/reservations', ], [ 'title' => $translator->translatePlural('Certificate', 'Certificates', 2), diff --git a/src/Models/Definitions/Networkname.php b/src/Models/Definitions/Networkname.php index 80a5dc8c24..5e82143b84 100644 --- a/src/Models/Definitions/Networkname.php +++ b/src/Models/Definitions/Networkname.php @@ -93,7 +93,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Network alias', 'Network aliases', 1), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/networkalias', ], [ 'title' => $translator->translate('Historical'), diff --git a/src/Models/Definitions/Ola.php b/src/Models/Definitions/Ola.php new file mode 100644 index 0000000000..dee33e716d --- /dev/null +++ b/src/Models/Definitions/Ola.php @@ -0,0 +1,18 @@ +translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -155,7 +493,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Contract', 'Contract', 2), diff --git a/src/Models/Definitions/Pdu.php b/src/Models/Definitions/Pdu.php index 281407d89a..42747d852d 100644 --- a/src/Models/Definitions/Pdu.php +++ b/src/Models/Definitions/Pdu.php @@ -128,6 +128,344 @@ public static function getDefinition() ]; } + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -144,8 +482,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('PDU plug', 'PDU plugs', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'edit', + 'link' => $rootUrl . '/plugs', ], [ 'title' => $translator->translatePlural('Network port', 'Network ports', 2), @@ -155,7 +493,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Contract', 'Contract', 2), diff --git a/src/Models/Definitions/Peripheral.php b/src/Models/Definitions/Peripheral.php index 8d07464e19..2fc4b3ee93 100644 --- a/src/Models/Definitions/Peripheral.php +++ b/src/Models/Definitions/Peripheral.php @@ -250,6 +250,345 @@ public static function getDefinitionOperatingSystem() ]; } + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -292,7 +631,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Contract', 'Contract', 2), @@ -327,7 +666,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Reservation', 'Reservations', 2), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/reservations', ], [ 'title' => $translator->translatePlural('Certificate', 'Certificates', 2), diff --git a/src/Models/Definitions/Phone.php b/src/Models/Definitions/Phone.php index 07b283be4e..8d004f704e 100644 --- a/src/Models/Definitions/Phone.php +++ b/src/Models/Definitions/Phone.php @@ -298,6 +298,344 @@ public static function getDefinitionOperatingSystem() ]; } + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -345,7 +683,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Contract', 'Contract', 2), @@ -380,7 +718,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Reservation', 'Reservations', 2), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/reservations', ], [ 'title' => $translator->translatePlural('Domain', 'Domains', 2), diff --git a/src/Models/Definitions/Printer.php b/src/Models/Definitions/Printer.php index 0213e6a195..55a27c35c9 100644 --- a/src/Models/Definitions/Printer.php +++ b/src/Models/Definitions/Printer.php @@ -342,6 +342,345 @@ public static function getDefinitionOperatingSystem() ]; } + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -394,7 +733,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Contract', 'Contract', 2), @@ -429,7 +768,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Reservation', 'Reservations', 2), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/reservations', ], [ 'title' => $translator->translatePlural('Certificate', 'Certificates', 2), diff --git a/src/Models/Definitions/Problem.php b/src/Models/Definitions/Problem.php index e02ce6992e..69de89ba52 100644 --- a/src/Models/Definitions/Problem.php +++ b/src/Models/Definitions/Problem.php @@ -110,9 +110,9 @@ public static function getDefinition() 'id' => 7, 'title' => $translator->translate('Category'), 'type' => 'dropdown_remote', - 'name' => 'itilcategorie', - 'dbname' => 'itilcategorie_id', - 'itemtype' => '\App\Models\ITILCategory', + 'name' => 'category', + 'dbname' => 'category_id', + 'itemtype' => '\App\Models\Category', 'fillable' => true, ], [ @@ -525,7 +525,9 @@ public static function getTimestampArray($options = []) { $day = 0; $hour = floor($i / $HOUR_TIMESTAMP); - } else { + } + else + { $day = floor($i / $DAY_TIMESTAMP); $hour = floor(($i % $DAY_TIMESTAMP) / $HOUR_TIMESTAMP); } @@ -552,10 +554,13 @@ public static function getTimestampArray($options = []) $hour, $minute ); - } else { + } + else + { $values[$i] = sprintf($translator->translatePlural('%d day', '%d days', $day), $day); } - } elseif ($hour > 0 || $minute > 0) + } + elseif ($hour > 0 || $minute > 0) { if ($minute < 10) { @@ -577,6 +582,31 @@ public static function getTimestampArray($options = []) return $tab; } + public static function getDefinitionAnalysis() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Impacts'), + 'type' => 'textarea', + 'name' => 'impactcontent', + ], + [ + 'id' => 2, + 'title' => $translator->translate('Causes'), + 'type' => 'textarea', + 'name' => 'causecontent', + ], + [ + 'id' => 3, + 'title' => $translator->translate('Symptoms'), + 'type' => 'textarea', + 'name' => 'symptomcontent', + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -591,45 +621,43 @@ public static function getRelatedPages($rootUrl) 'icon' => 'caret square down outline', 'link' => '', ], - [ - 'title' => $translator->translatePlural('Problem', 'Problems', 2), - 'icon' => 'caret square down outline', - 'link' => '', - ], [ 'title' => $translator->translate('Analysis'), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'edit', + 'link' => $rootUrl . '/analysis', ], [ 'title' => $translator->translate('Statistics'), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'chartline', + 'link' => $rootUrl . '/stats', ], [ 'title' => $translator->translatePlural('Ticket', 'Tickets', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'hands helping', + 'link' => $rootUrl . '/tickets', + 'rightModel' => '\App\Models\Ticket', ], [ 'title' => $translator->translatePlural('Change', 'Changes', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'paint roller', + 'link' => $rootUrl . '/changes', + 'rightModel' => '\App\Models\Change', ], [ 'title' => $translator->translatePlural('Cost', 'Costs', 2), 'icon' => 'money bill alternate', - 'link' => '', + 'link' => $rootUrl . '/costs', ], [ 'title' => $translator->translatePlural('Project', 'Projects', 2), 'icon' => 'folder open', - 'link' => '', + 'link' => $rootUrl . '/projects', + 'rightModel' => '\App\Models\Project', ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), 'icon' => 'desktop', - 'link' => '', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Note', 'Notes', 2), diff --git a/src/Models/Definitions/ProblemTicket.php b/src/Models/Definitions/ProblemTicket.php new file mode 100644 index 0000000000..a51c58445a --- /dev/null +++ b/src/Models/Definitions/ProblemTicket.php @@ -0,0 +1,18 @@ + 0, 'is_recursive' => 1]; - } else { + } + else + { $newtab['condition'] = ['entities_id' => 0]; } $tab[] = $newtab; @@ -986,7 +988,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('User', 'Users', 2), 'icon' => 'users', - 'link' => '', + 'link' => $rootUrl . '/users', ], [ 'title' => $translator->translate('Historical'), diff --git a/src/Models/Definitions/Project.php b/src/Models/Definitions/Project.php index 0bb580e45c..df0d3a09bb 100644 --- a/src/Models/Definitions/Project.php +++ b/src/Models/Definitions/Project.php @@ -713,9 +713,11 @@ public static function formatNumber($number, $edit = false, $forcedecimal = -1) if ($number == "") { $number = 0; - } elseif ($number == "-") - { // used for not defines value (from Infocom::Amort, p.e.) - return "-"; + } + elseif ($number == "-") + { + // used for not defines value (from Infocom::Amort, p.e.) + return "-"; } $number = doubleval($number); @@ -768,7 +770,9 @@ public static function getSize($size) if ($size > 1024) { $size = $size / 1024; - } else { + } + else + { break; } } diff --git a/src/Models/Definitions/Projectstate.php b/src/Models/Definitions/Projectstate.php index 0d07522b97..1b0f3c57c2 100644 --- a/src/Models/Definitions/Projectstate.php +++ b/src/Models/Definitions/Projectstate.php @@ -25,7 +25,7 @@ public static function getDefinition() [ 'id' => 12, 'title' => $translator->translate('Finished state'), - 'type' => 'input', + 'type' => 'boolean', 'name' => 'is_finished', 'fillable' => true, ], diff --git a/src/Models/Definitions/Projecttask.php b/src/Models/Definitions/Projecttask.php index 80929cc808..d8d6d05b1d 100644 --- a/src/Models/Definitions/Projecttask.php +++ b/src/Models/Definitions/Projecttask.php @@ -15,43 +15,304 @@ public static function getDefinition() 'name' => 'name', 'fillable' => true, ], - // [ - // 'id' => 16, - // 'title' => $translator->translate('Comments'), - // 'type' => 'textarea', - // 'name' => 'comment', - // ], - // [ - // 'id' => 19, - // 'title' => $translator->translate('Last update'), - // 'type' => 'datetime', - // 'name' => 'updated_at', - // 'readonly' => 'readonly', - // ], - // [ - // 'id' => 121, - // 'title' => $translator->translate('Creation date'), - // 'type' => 'datetime', - // 'name' => 'created_at', - // 'readonly' => 'readonly', - // ], + [ + 'id' => 2, + 'title' => $translator->translate('As child of'), + 'type' => 'dropdown_remote', + 'name' => 'parent', + 'dbname' => 'projecttask_id', + 'itemtype' => '\App\Models\Projecttask', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Status'), + 'type' => 'dropdown_remote', + 'name' => 'state', + 'dbname' => 'projectstate_id', + 'itemtype' => '\App\Models\Projectstate', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translatePlural('Type', 'Types', 1), + 'type' => 'dropdown_remote', + 'name' => 'type', + 'dbname' => 'projecttasktype_id', + 'itemtype' => '\App\Models\Projecttasktype', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Creation date'), + 'type' => 'datetime', + 'name' => 'date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translate('Planned start date'), + 'type' => 'datetime', + 'name' => 'plan_start_date', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translate('Planned end date'), + 'type' => 'datetime', + 'name' => 'plan_end_date', + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Planned duration'), + 'type' => 'input', + 'name' => 'planned_duration', + 'readonly' => 'readonly', + ], + [ + 'id' => 9, + 'title' => $translator->translate('Real start date'), + 'type' => 'datetime', + 'name' => 'real_start_date', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Real end date'), + 'type' => 'datetime', + 'name' => 'real_end_date', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translate('Effective duration'), + 'type' => 'input', + 'name' => 'effective_duration', + 'readonly' => 'readonly', + ], + [ + 'id' => 5, + 'title' => $translator->translate('Percent done'), + 'type' => 'dropdown', + 'name' => 'percent_done', + 'dbname' => 'percent_done', + 'values' => self::getNumberArray(0, 100, 5, [], '%'), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + ], + [ + 'id' => 19, + 'title' => $translator->translate('Last update'), + 'type' => 'datetime', + 'name' => 'updated_at', + 'readonly' => 'readonly', + ], + [ + 'id' => 121, + 'title' => $translator->translate('Creation date'), + 'type' => 'datetime', + 'name' => 'created_at', + 'readonly' => 'readonly', + ], ]; } + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { + // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + public static function getRelatedPages($rootUrl) { global $translator; return [ - // [ - // 'title' => $translator->translatePlural('Project tasks type', 'Project tasks types', 1), - // 'icon' => 'caret square down outline', - // 'link' => '', - // ], - // [ - // 'title' => $translator->translate('Historical'), - // 'icon' => 'history', - // 'link' => '', - // ], + [ + 'title' => $translator->translatePlural('Project task', 'Project tasks', 1), + 'icon' => 'home', + 'link' => $rootUrl, + ], + [ + 'title' => $translator->translatePlural('Project task', 'Project tasks', 2), + 'icon' => 'home', + 'link' => $rootUrl . '/projecttasks', + ], + [ + 'title' => $translator->translatePlural('Project task team', 'Project task teams', 1), + 'icon' => 'caret square down outline', + 'link' => $rootUrl . '/projecttaskteams', + ], + [ + 'title' => $translator->translatePlural('Document', 'Documents', 2), + 'icon' => 'file', + 'link' => $rootUrl . '/documents', + ], + [ + 'title' => $translator->translatePlural('Ticket', 'Tickets', 2), + 'icon' => 'hands helping', + 'link' => $rootUrl . '/tickets', + 'rightModel' => '\App\Models\Ticket', + ], + [ + 'title' => $translator->translatePlural('Note', 'Notes', 2), + 'icon' => 'sticky note', + 'link' => $rootUrl . '/notes', + ], + [ + 'title' => $translator->translate('Historical'), + 'icon' => 'history', + 'link' => $rootUrl . '/history', + ], ]; } } diff --git a/src/Models/Definitions/ProjecttaskTicket.php b/src/Models/Definitions/ProjecttaskTicket.php new file mode 100644 index 0000000000..6320df791d --- /dev/null +++ b/src/Models/Definitions/ProjecttaskTicket.php @@ -0,0 +1,18 @@ + 1024) { $size = $size / 1024; - } else { + } + else + { break; } } @@ -424,7 +428,9 @@ public static function getTimestampArray($options = []) { $day = 0; $hour = floor($i / $HOUR_TIMESTAMP); - } else { + } + else + { $day = floor($i / $DAY_TIMESTAMP); $hour = floor(($i % $DAY_TIMESTAMP) / $HOUR_TIMESTAMP); } @@ -451,10 +457,13 @@ public static function getTimestampArray($options = []) $hour, $minute ); - } else { + } + else + { $values[$i] = sprintf($translator->translatePlural('%d day', '%d days', $day), $day); } - } elseif ($hour > 0 || $minute > 0) + } + elseif ($hour > 0 || $minute > 0) { if ($minute < 10) { diff --git a/src/Models/Definitions/Rack.php b/src/Models/Definitions/Rack.php index 7bfee210e5..6ca9d41b2b 100644 --- a/src/Models/Definitions/Rack.php +++ b/src/Models/Definitions/Rack.php @@ -94,6 +94,14 @@ public static function getDefinition() 'itemtype' => '\App\Models\Group', 'fillable' => true, ], + [ + 'id' => 8, + 'title' => $translator->translate('Number of units'), + 'type' => 'dropdown', + 'name' => 'number_units', + 'values' => self::getNumberArray(1, 100, 1, [], 'U'), + 'fillable' => true, + ], // [ // 'id' => 61, // 'title' => $translator->translate('Template name'), @@ -114,7 +122,6 @@ public static function getDefinition() 'name' => 'comment', 'fillable' => true, ], - [ 'id' => 19, 'title' => $translator->translate('Last update'), @@ -129,13 +136,6 @@ public static function getDefinition() 'name' => 'created_at', 'readonly' => 'readonly', ], - [ - 'id' => 8, - 'title' => $translator->translate('Number of units'), - 'type' => 'input', - 'name' => 'number_units', - 'readonly' => 'readonly', - ], /* @@ -155,6 +155,345 @@ public static function getDefinition() ]; } + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { + // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -166,7 +505,7 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Item', 'Items', 2), - 'icon' => 'caret square down outline', + 'icon' => 'desktop', 'link' => '', ], [ @@ -177,7 +516,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Contract', 'Contract', 2), diff --git a/src/Models/Definitions/Reservation.php b/src/Models/Definitions/Reservation.php new file mode 100644 index 0000000000..e4637bf966 --- /dev/null +++ b/src/Models/Definitions/Reservation.php @@ -0,0 +1,18 @@ + 1024) { $size = $size / 1024; - } else { + } + else + { break; } } @@ -335,7 +339,9 @@ public static function getTimestampArray($options = []) { $day = 0; $hour = floor($i / $HOUR_TIMESTAMP); - } else { + } + else + { $day = floor($i / $DAY_TIMESTAMP); $hour = floor(($i % $DAY_TIMESTAMP) / $HOUR_TIMESTAMP); } @@ -362,10 +368,13 @@ public static function getTimestampArray($options = []) $hour, $minute ); - } else { + } + else + { $values[$i] = sprintf($translator->translatePlural('%d day', '%d days', $day), $day); } - } elseif ($hour > 0 || $minute > 0) + } + elseif ($hour > 0 || $minute > 0) { if ($minute < 10) { diff --git a/src/Models/Definitions/Sla.php b/src/Models/Definitions/Sla.php new file mode 100644 index 0000000000..2f732de48f --- /dev/null +++ b/src/Models/Definitions/Sla.php @@ -0,0 +1,18 @@ + $translator->translate('SLA'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/slas', ], [ 'title' => $translator->translate('OLA',), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/olas', ], [ 'title' => $translator->translate('Historical'), diff --git a/src/Models/Definitions/Software.php b/src/Models/Definitions/Software.php index 97b260cf3c..93a501f531 100644 --- a/src/Models/Definitions/Software.php +++ b/src/Models/Definitions/Software.php @@ -324,6 +324,346 @@ public static function getDefinition() ]; } + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getNumberArray($min, $max, $step = 1, $toadd = [], $unit = '') + { + global $translator; + + $tab = []; + foreach (array_keys($toadd) as $key) + { + $tab[$key]['title'] = $toadd[$key]; + } + + for ($i = $min; $i <= $max; $i = $i + $step) + { + $tab[$i]['title'] = self::getValueWithUnit($i, $unit, 0); + } + + return $tab; + } + + public static function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + + $formatted_number = is_numeric($value) + ? self::formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return self::getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public static function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { + // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public static function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -346,17 +686,17 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('License', 'Licenses', 2), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/licenses', ], [ 'title' => $translator->translatePlural('Installation', 'Installations', 2), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/softwareinstall', ], [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Contract', 'Contract', 2), @@ -391,7 +731,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Reservation', 'Reservations', 2), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/reservations', ], [ 'title' => $translator->translatePlural('Domain', 'Domains', 2), diff --git a/src/Models/Definitions/Softwarecategory.php b/src/Models/Definitions/Softwarecategory.php index eef3d8f7d7..9219451b4e 100644 --- a/src/Models/Definitions/Softwarecategory.php +++ b/src/Models/Definitions/Softwarecategory.php @@ -45,8 +45,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('Software category', 'Software categories', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'edit', + 'link' => $rootUrl . '/softwarecategories', ], [ 'title' => $translator->translate('Historical'), diff --git a/src/Models/Definitions/Softwarelicense.php b/src/Models/Definitions/Softwarelicense.php index eaab18c57b..27e7419e82 100644 --- a/src/Models/Definitions/Softwarelicense.php +++ b/src/Models/Definitions/Softwarelicense.php @@ -291,8 +291,10 @@ public static function formatNumber($number, $edit = false, $forcedecimal = -1) if ($number == "") { $number = 0; - } elseif ($number == "-") - { // used for not defines value (from Infocom::Amort, p.e.) + } + elseif ($number == "-") + { + // used for not defines value (from Infocom::Amort, p.e.) return "-"; } @@ -346,7 +348,9 @@ public static function getSize($size) if ($size > 1024) { $size = $size / 1024; - } else { + } + else + { break; } } @@ -354,6 +358,195 @@ public static function getSize($size) return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); } + public static function getDefinitionInfocom() + { + global $translator; + return [ + [ + 'id' => 1, + 'title' => $translator->translate('Order date'), + 'type' => 'date', + 'name' => 'order_date', + 'fillable' => true, + ], + [ + 'id' => 2, + 'title' => $translator->translate('Date of purchase'), + 'type' => 'date', + 'name' => 'buy_date', + 'fillable' => true, + ], + [ + 'id' => 3, + 'title' => $translator->translate('Delivery date'), + 'type' => 'date', + 'name' => 'delivery_date', + 'fillable' => true, + ], + [ + 'id' => 4, + 'title' => $translator->translate('Startup date'), + 'type' => 'date', + 'name' => 'use_date', + 'fillable' => true, + ], + [ + 'id' => 5, + 'title' => $translator->translate('Date of last physical inventory'), + 'type' => 'date', + 'name' => 'inventory_date', + 'fillable' => true, + ], + [ + 'id' => 6, + 'title' => $translator->translate('Decommission date'), + 'type' => 'date', + 'name' => 'decommission_date', + 'fillable' => true, + ], + [ + 'id' => 7, + 'title' => $translator->translatePlural('Supplier', 'Suppliers', 1), + 'type' => 'dropdown_remote', + 'name' => 'supplier', + 'dbname' => 'supplier_id', + 'itemtype' => '\App\Models\Supplier', + 'fillable' => true, + ], + [ + 'id' => 8, + 'title' => $translator->translatePlural('Budget', 'Budgets', 1), + 'type' => 'dropdown_remote', + 'name' => 'budget', + 'dbname' => 'budget_id', + 'itemtype' => '\App\Models\Budget', + 'fillable' => true, + ], + [ + 'id' => 9, + 'title' => $translator->translate('Order number'), + 'type' => 'input', + 'name' => 'order_number', + 'fillable' => true, + ], + [ + 'id' => 10, + 'title' => $translator->translate('Immobilization number'), + 'type' => 'input', + 'name' => 'immo_number', + 'fillable' => true, + ], + [ + 'id' => 11, + 'title' => $translator->translate('Invoice number'), + 'type' => 'input', + 'name' => 'bill', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Delivery form'), + 'type' => 'input', + 'name' => 'delivery_number', + 'fillable' => true, + ], + [ + 'id' => 13, + 'title' => $translator->translate('Value'), + 'type' => 'input', + 'name' => 'value', + 'fillable' => true, + ], + [ + 'id' => 14, + 'title' => $translator->translate('Warranty extension value'), + 'type' => 'input', + 'name' => 'warranty_value', + 'fillable' => true, + ], + [ + 'id' => 15, + 'title' => $translator->translate('Amortization type'), + 'type' => 'dropdown', + 'name' => 'sink_type', + 'dbname' => 'sink_type', + 'values' => self::getAmortType(), + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Amortization duration'), + 'type' => 'dropdown', + 'name' => 'sink_time', + 'dbname' => 'sink_time', + 'values' => self::getNumberArray(0, 15, 1, [], 'year'), + 'fillable' => true, + ], + [ + 'id' => 17, + 'title' => $translator->translate('Amortization coefficient'), + 'type' => 'input', + 'name' => 'sink_coeff', + 'fillable' => true, + ], + [ + 'id' => 18, + 'title' => $translator->translatePlural('Business criticity', 'Business criticities', 1), + 'type' => 'dropdown_remote', + 'name' => 'businesscriticity', + 'dbname' => 'businesscriticity_id', + 'itemtype' => '\App\Models\Businesscriticity', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 20, + 'title' => $translator->translate('Start date of warranty'), + 'type' => 'date', + 'name' => 'warranty_date', + 'fillable' => true, + ], + [ + 'id' => 21, + 'title' => $translator->translate('Warranty duration'), + 'type' => 'dropdown', + 'name' => 'warranty_duration', + 'dbname' => 'warranty_duration', + 'values' => self::getNumberArray(0, 120, 1, ['-1' => $translator->translate('Lifelong')], 'month'), + 'fillable' => true, + ], + [ + 'id' => 22, + 'title' => $translator->translate('Warranty information'), + 'type' => 'input', + 'name' => 'warranty_info', + 'fillable' => true, + ], + ]; + } + + public static function getAmortType() + { + global $translator; + return [ + 0 => [ + 'title' => '', + ], + 1 => [ + 'title' => $translator->translate('Decreasing'), + ], + 2 => [ + 'title' => $translator->translate('Linear'), + ], + ]; + } + public static function getRelatedPages($rootUrl) { global $translator; @@ -381,7 +574,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translate('Management'), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/infocom', ], [ 'title' => $translator->translatePlural('Contract', 'Contract', 2), diff --git a/src/Models/Definitions/Softwarelicensetype.php b/src/Models/Definitions/Softwarelicensetype.php index 2a08f3ad53..1b348f74bd 100644 --- a/src/Models/Definitions/Softwarelicensetype.php +++ b/src/Models/Definitions/Softwarelicensetype.php @@ -73,8 +73,8 @@ public static function getRelatedPages($rootUrl) ], [ 'title' => $translator->translatePlural('License type', 'License types', 2), - 'icon' => 'caret square down outline', - 'link' => '', + 'icon' => 'edit', + 'link' => $rootUrl . '/licencetypes', ], [ 'title' => $translator->translate('Historical'), diff --git a/src/Models/Definitions/Softwareversion.php b/src/Models/Definitions/Softwareversion.php index 67e8e585bd..0c1e63079e 100644 --- a/src/Models/Definitions/Softwareversion.php +++ b/src/Models/Definitions/Softwareversion.php @@ -8,6 +8,15 @@ public static function getDefinition() { global $translator; return [ + [ + 'id' => 10, + 'title' => $translator->translatePlural('Software', 'Softwares', 1), + 'type' => 'dropdown_remote', + 'name' => 'software', + 'dbname' => 'software_id', + 'itemtype' => '\App\Models\Software', + 'readonly' => 'readonly', + ], [ 'id' => 1, 'title' => $translator->translate('Name'), @@ -15,6 +24,45 @@ public static function getDefinition() 'name' => 'name', 'fillable' => true, ], + [ + 'id' => 11, + 'title' => $translator->translatePlural('Operating system', 'Operating systems', 1), + 'type' => 'dropdown_remote', + 'name' => 'operatingsystem', + 'dbname' => 'operatingsystem_id', + 'itemtype' => '\App\Models\Operatingsystem', + 'fillable' => true, + ], + [ + 'id' => 12, + 'title' => $translator->translate('Status'), + 'type' => 'dropdown_remote', + 'name' => 'state', + 'dbname' => 'state_id', + 'itemtype' => '\App\Models\State', + 'fillable' => true, + ], + [ + 'id' => 16, + 'title' => $translator->translate('Comments'), + 'type' => 'textarea', + 'name' => 'comment', + 'fillable' => true, + ], + [ + 'id' => 19, + 'title' => $translator->translate('Last update'), + 'type' => 'datetime', + 'name' => 'updated_at', + 'readonly' => 'readonly', + ], + [ + 'id' => 121, + 'title' => $translator->translate('Creation date'), + 'type' => 'datetime', + 'name' => 'created_at', + 'readonly' => 'readonly', + ], ]; } @@ -22,11 +70,26 @@ public static function getRelatedPages($rootUrl) { global $translator; return [ - // [ - // 'title' => $translator->translate('Historical'), - // 'icon' => 'history', - // 'link' => '', - // ], + [ + 'title' => $translator->translatePlural('License', 'Licenses', 1), + 'icon' => 'home', + 'link' => $rootUrl, + ], + [ + 'title' => $translator->translate('Summary'), + 'icon' => 'caret square down outline', + 'link' => '', + ], + [ + 'title' => $translator->translatePlural('Installation', 'Installations', 2), + 'icon' => 'caret square down outline', + 'link' => '', + ], + [ + 'title' => $translator->translate('Historical'), + 'icon' => 'history', + 'link' => $rootUrl . '/history', + ], ]; } } diff --git a/src/Models/Definitions/Supplier.php b/src/Models/Definitions/Supplier.php index 48dabaf2fd..76c1b8839a 100644 --- a/src/Models/Definitions/Supplier.php +++ b/src/Models/Definitions/Supplier.php @@ -135,7 +135,9 @@ public static function getDefinition() { $name1 = 'firstname'; $name2 = 'name'; - } else { + } + else + { $name1 = 'name'; $name2 = 'firstname'; } @@ -211,7 +213,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Item', 'Items', 2), 'icon' => 'desktop', - 'link' => '', + 'link' => $rootUrl . '/attacheditems', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), diff --git a/src/Models/Definitions/Tasktemplate.php b/src/Models/Definitions/Tasktemplate.php index 9e2963d403..bd533282d0 100644 --- a/src/Models/Definitions/Tasktemplate.php +++ b/src/Models/Definitions/Tasktemplate.php @@ -209,7 +209,9 @@ public static function getTimestampArray($options = []) { $day = 0; $hour = floor($i / $HOUR_TIMESTAMP); - } else { + } + else + { $day = floor($i / $DAY_TIMESTAMP); $hour = floor(($i % $DAY_TIMESTAMP) / $HOUR_TIMESTAMP); } @@ -236,10 +238,13 @@ public static function getTimestampArray($options = []) $hour, $minute ); - } else { + } + else + { $values[$i] = sprintf($translator->translatePlural('%d day', '%d days', $day), $day); } - } elseif ($hour > 0 || $minute > 0) + } + elseif ($hour > 0 || $minute > 0) { if ($minute < 10) { diff --git a/src/Models/Definitions/Ticket.php b/src/Models/Definitions/Ticket.php index 60cf93f966..420e58508d 100644 --- a/src/Models/Definitions/Ticket.php +++ b/src/Models/Definitions/Ticket.php @@ -270,7 +270,7 @@ public static function getDefinition() // 'id' => 6, // 'title' => $translator->translate('Assigned to a supplier'), // 'type' => 'dropdown_remote', - // 'name' => 'technician', + // 'name' => 'technician:id,name,firstname,lastname', // 'itemtype' => '\App\Models\User', // 'multiple' => true, // ], @@ -521,7 +521,9 @@ public static function getTimestampArray($options = []) { $day = 0; $hour = floor($i / $HOUR_TIMESTAMP); - } else { + } + else + { $day = floor($i / $DAY_TIMESTAMP); $hour = floor(($i % $DAY_TIMESTAMP) / $HOUR_TIMESTAMP); } @@ -548,10 +550,13 @@ public static function getTimestampArray($options = []) $hour, $minute ); - } else { + } + else + { $values[$i] = sprintf($translator->translatePlural('%d day', '%d days', $day), $day); } - } elseif ($hour > 0 || $minute > 0) + } + elseif ($hour > 0 || $minute > 0) { if ($minute < 10) { @@ -589,7 +594,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Approval', 'Approvals', 2), 'icon' => 'thumbs up', - 'link' => '', + 'link' => $rootUrl . '/approvals', ], [ 'title' => $translator->translate('Knowledge base'), @@ -599,7 +604,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Item', 'Items', 2), 'icon' => 'desktop', - 'link' => '', + 'link' => $rootUrl . '/items', ], [ 'title' => $translator->translatePlural('Cost', 'Costs', 2), @@ -609,13 +614,13 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Project', 'Projects', 2), 'icon' => 'folder open', - 'link' => '', + 'link' => $rootUrl . '/projects', 'rightModel' => '\App\Models\Project', ], [ 'title' => $translator->translatePlural('Project task', 'Project tasks', 2), 'icon' => 'tasks', - 'link' => '', + 'link' => $rootUrl . '/projecttasks', 'rightModel' => '\App\Models\Project', ], [ @@ -627,7 +632,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Change', 'Changes', 2), 'icon' => 'paint roller', - 'link' => '', + 'link' => $rootUrl . '/changes', 'rightModel' => '\App\Models\Change', ], [ diff --git a/src/Models/Definitions/Ticketvalidation.php b/src/Models/Definitions/Ticketvalidation.php new file mode 100644 index 0000000000..e671b1b5cb --- /dev/null +++ b/src/Models/Definitions/Ticketvalidation.php @@ -0,0 +1,18 @@ + $translator->translatePlural('Problem', 'Problems', 2), - 'icon' => 'caret square down outline', + 'icon' => 'drafting compass', 'link' => $rootUrl . '/problems', + 'rightModel' => '\App\Models\Problem', ], [ 'title' => $translator->translatePlural('Change', 'Changes', 2), - 'icon' => 'caret square down outline', + 'icon' => 'paint roller', 'link' => $rootUrl . '/changes', + 'rightModel' => '\App\Models\Change', ], [ 'title' => $translator->translatePlural('Document', 'Documents', 2), @@ -506,7 +508,7 @@ public static function getRelatedPages($rootUrl) [ 'title' => $translator->translatePlural('Reservation', 'Reservations', 2), 'icon' => 'caret square down outline', - 'link' => '', + 'link' => $rootUrl . '/reservations', ], [ 'title' => $translator->translate('Synchronization'), diff --git a/src/Models/Definitions/Vlan.php b/src/Models/Definitions/Vlan.php index 208a1b672d..c23c05b944 100644 --- a/src/Models/Definitions/Vlan.php +++ b/src/Models/Definitions/Vlan.php @@ -146,8 +146,10 @@ public static function formatNumber($number, $edit = false, $forcedecimal = -1) if ($number == "") { $number = 0; - } elseif ($number == "-") - { // used for not defines value (from Infocom::Amort, p.e.) + } + elseif ($number == "-") + { + // used for not defines value (from Infocom::Amort, p.e.) return "-"; } @@ -201,8 +203,10 @@ public static function getSize($size) if ($size > 1024) { $size = $size / 1024; - } else { - break; + } + else + { + break; } } //TRANS: %1$s is a number maybe float or string and %2$s the unit diff --git a/src/Models/Devicebattery.php b/src/Models/Devicebattery.php index 4525d70bb3..67ea7c44d2 100644 --- a/src/Models/Devicebattery.php +++ b/src/Models/Devicebattery.php @@ -20,6 +20,7 @@ class Devicebattery extends Common 'manufacturer', 'type', 'entity', + 'items', ]; protected $visible = [ @@ -27,13 +28,15 @@ class Devicebattery extends Common 'type', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'type:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -62,4 +65,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDevicebattery', 'devicebattery_id'); + } } diff --git a/src/Models/Devicecase.php b/src/Models/Devicecase.php index 1c79b0b353..6122abd2ab 100644 --- a/src/Models/Devicecase.php +++ b/src/Models/Devicecase.php @@ -21,6 +21,7 @@ class Devicecase extends Common 'type', 'model', 'entity', + 'items', ]; protected $visible = [ @@ -29,14 +30,16 @@ class Devicecase extends Common 'model', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'type:id,name', 'model:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -70,4 +73,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDevicecase', 'devicecase_id'); + } } diff --git a/src/Models/Devicecontrol.php b/src/Models/Devicecontrol.php index 07a29a3f17..b26faa0282 100644 --- a/src/Models/Devicecontrol.php +++ b/src/Models/Devicecontrol.php @@ -21,6 +21,7 @@ class Devicecontrol extends Common 'model', 'interface', 'entity', + 'items', ]; protected $visible = [ @@ -29,14 +30,16 @@ class Devicecontrol extends Common 'interface', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'model:id,name', 'interface:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -70,4 +73,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDevicecontrol', 'devicecontrol_id'); + } } diff --git a/src/Models/Devicedrive.php b/src/Models/Devicedrive.php index 2a57ce6e4d..6a6198f930 100644 --- a/src/Models/Devicedrive.php +++ b/src/Models/Devicedrive.php @@ -21,6 +21,7 @@ class Devicedrive extends Common 'model', 'interface', 'entity', + 'items', ]; protected $visible = [ @@ -29,14 +30,16 @@ class Devicedrive extends Common 'interface', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'model:id,name', 'interface:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -70,4 +73,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDevicedrive', 'devicedrive_id'); + } } diff --git a/src/Models/Devicefirmware.php b/src/Models/Devicefirmware.php index ae70746787..e8c62f3a5f 100644 --- a/src/Models/Devicefirmware.php +++ b/src/Models/Devicefirmware.php @@ -23,6 +23,7 @@ class Devicefirmware extends Common 'type', 'model', 'entity', + 'items', ]; protected $visible = [ @@ -31,14 +32,16 @@ class Devicefirmware extends Common 'model', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'type:id,name', 'model:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -72,4 +75,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDevicefirmware', 'devicefirmware_id'); + } } diff --git a/src/Models/Devicegeneric.php b/src/Models/Devicegeneric.php index 4409f15221..d8b937d64a 100644 --- a/src/Models/Devicegeneric.php +++ b/src/Models/Devicegeneric.php @@ -20,6 +20,7 @@ class Devicegeneric extends Common 'manufacturer', 'type', 'entity', + 'items', ]; protected $visible = [ @@ -27,13 +28,15 @@ class Devicegeneric extends Common 'type', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'type:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -62,4 +65,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDevicegeneric', 'devicegeneric_id'); + } } diff --git a/src/Models/Devicegraphiccard.php b/src/Models/Devicegraphiccard.php index 4434495ace..d7604922dc 100644 --- a/src/Models/Devicegraphiccard.php +++ b/src/Models/Devicegraphiccard.php @@ -21,6 +21,7 @@ class Devicegraphiccard extends Common 'model', 'interface', 'entity', + 'items', ]; protected $visible = [ @@ -29,14 +30,16 @@ class Devicegraphiccard extends Common 'interface', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'model:id,name', 'interface:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -70,4 +73,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDevicegraphiccard', 'devicegraphiccard_id'); + } } diff --git a/src/Models/Deviceharddrive.php b/src/Models/Deviceharddrive.php index 4f0415ca9b..004384f384 100644 --- a/src/Models/Deviceharddrive.php +++ b/src/Models/Deviceharddrive.php @@ -21,6 +21,7 @@ class Deviceharddrive extends Common 'model', 'interface', 'entity', + 'items', ]; protected $visible = [ @@ -29,14 +30,16 @@ class Deviceharddrive extends Common 'interface', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'model:id,name', 'interface:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -70,4 +73,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDeviceharddrive', 'deviceharddrive_id'); + } } diff --git a/src/Models/Devicememory.php b/src/Models/Devicememory.php index 316f58d644..8c398253ac 100644 --- a/src/Models/Devicememory.php +++ b/src/Models/Devicememory.php @@ -21,6 +21,7 @@ class Devicememory extends Common 'type', 'model', 'entity', + 'items', ]; protected $visible = [ @@ -29,14 +30,16 @@ class Devicememory extends Common 'model', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'type:id,name', 'model:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -70,4 +73,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDevicememory', 'devicememory_id'); + } } diff --git a/src/Models/Devicemotherboard.php b/src/Models/Devicemotherboard.php index 7ebb888a11..b60e225f6d 100644 --- a/src/Models/Devicemotherboard.php +++ b/src/Models/Devicemotherboard.php @@ -20,6 +20,7 @@ class Devicemotherboard extends Common 'manufacturer', 'model', 'entity', + 'items', ]; protected $visible = [ @@ -27,13 +28,15 @@ class Devicemotherboard extends Common 'model', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'model:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -62,4 +65,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDevicemotherboard', 'devicemotherboard_id'); + } } diff --git a/src/Models/Devicenetworkcard.php b/src/Models/Devicenetworkcard.php index fd90361d1b..095383245e 100644 --- a/src/Models/Devicenetworkcard.php +++ b/src/Models/Devicenetworkcard.php @@ -20,6 +20,7 @@ class Devicenetworkcard extends Common 'manufacturer', 'model', 'entity', + 'items', ]; protected $visible = [ @@ -27,13 +28,15 @@ class Devicenetworkcard extends Common 'model', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'model:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -62,4 +65,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDevicenetworkcard', 'devicenetworkcard_id'); + } } diff --git a/src/Models/Devicepci.php b/src/Models/Devicepci.php index 9fed723d02..b4f36cd215 100644 --- a/src/Models/Devicepci.php +++ b/src/Models/Devicepci.php @@ -20,6 +20,7 @@ class Devicepci extends Common 'manufacturer', 'model', 'entity', + 'items', ]; protected $visible = [ @@ -27,13 +28,15 @@ class Devicepci extends Common 'model', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'model:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -62,4 +65,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDevicepci', 'devicepci_id'); + } } diff --git a/src/Models/Devicepowersupply.php b/src/Models/Devicepowersupply.php index 4f52d849d2..dddb37fd2c 100644 --- a/src/Models/Devicepowersupply.php +++ b/src/Models/Devicepowersupply.php @@ -20,6 +20,7 @@ class Devicepowersupply extends Common 'manufacturer', 'model', 'entity', + 'items', ]; protected $visible = [ @@ -27,13 +28,15 @@ class Devicepowersupply extends Common 'model', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'model:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -62,4 +65,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDevicepowersupply', 'devicepowersupply_id'); + } } diff --git a/src/Models/Deviceprocessor.php b/src/Models/Deviceprocessor.php index bc7db75ed8..6df9ca8e5a 100644 --- a/src/Models/Deviceprocessor.php +++ b/src/Models/Deviceprocessor.php @@ -20,6 +20,7 @@ class Deviceprocessor extends Common 'manufacturer', 'model', 'entity', + 'items', ]; protected $visible = [ @@ -27,13 +28,15 @@ class Deviceprocessor extends Common 'model', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'model:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -62,4 +65,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDeviceprocessor', 'deviceprocessor_id'); + } } diff --git a/src/Models/Devicesensor.php b/src/Models/Devicesensor.php index 651f0385f3..a029ede931 100644 --- a/src/Models/Devicesensor.php +++ b/src/Models/Devicesensor.php @@ -20,6 +20,7 @@ class Devicesensor extends Common 'manufacturer', 'type', 'entity', + 'items', ]; protected $visible = [ @@ -27,13 +28,15 @@ class Devicesensor extends Common 'type', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'type:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -62,4 +65,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDevicesensor', 'devicesensor_id'); + } } diff --git a/src/Models/Devicesimcard.php b/src/Models/Devicesimcard.php index a5ec3b911a..e20a2b417f 100644 --- a/src/Models/Devicesimcard.php +++ b/src/Models/Devicesimcard.php @@ -20,6 +20,7 @@ class Devicesimcard extends Common 'manufacturer', 'type', 'entity', + 'items', ]; protected $visible = [ @@ -27,13 +28,15 @@ class Devicesimcard extends Common 'type', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'type:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -62,4 +65,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDevicesimcard', 'devicesimcard_id'); + } } diff --git a/src/Models/Devicesoundcard.php b/src/Models/Devicesoundcard.php index dde64c8cfb..4877184d11 100644 --- a/src/Models/Devicesoundcard.php +++ b/src/Models/Devicesoundcard.php @@ -20,6 +20,7 @@ class Devicesoundcard extends Common 'manufacturer', 'model', 'entity', + 'items', ]; protected $visible = [ @@ -27,13 +28,15 @@ class Devicesoundcard extends Common 'model', 'entity', 'documents', + 'items', ]; protected $with = [ 'manufacturer:id,name', 'model:id,name', - 'entity:id,name', - 'documents:id,name', + 'entity:id,name,completename', + 'documents', + 'items', ]; public function manufacturer(): BelongsTo @@ -62,4 +65,9 @@ public function documents(): MorphToMany 'updated_at', ); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemDevicesoundcard', 'devicesoundcard_id'); + } } diff --git a/src/Models/Document.php b/src/Models/Document.php index 71d94cbd5d..573d40efb1 100644 --- a/src/Models/Document.php +++ b/src/Models/Document.php @@ -31,7 +31,7 @@ class Document extends Common protected $with = [ 'categorie:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'notes:id', 'documents:id,name', ]; diff --git a/src/Models/Documentcategory.php b/src/Models/Documentcategory.php index 8477dbb770..006d300d1c 100644 --- a/src/Models/Documentcategory.php +++ b/src/Models/Documentcategory.php @@ -29,6 +29,6 @@ class Documentcategory extends Common public function category(): BelongsTo { - return $this->belongsTo('\App\Models\Documentcategory'); + return $this->belongsTo('\App\Models\Documentcategory', 'documentcategory_id'); } } diff --git a/src/Models/Domain.php b/src/Models/Domain.php index cd38152aec..4ddf1f0828 100644 --- a/src/Models/Domain.php +++ b/src/Models/Domain.php @@ -22,6 +22,7 @@ class Domain extends Common 'groupstech', 'entity', 'certificates', + 'infocom', ]; protected $visible = [ @@ -36,13 +37,14 @@ class Domain extends Common 'tickets', 'problems', 'changes', + 'infocom', ]; protected $with = [ 'type:id,name', - 'userstech:id,name', - 'groupstech:id,name', - 'entity:id,name', + 'userstech:id,name,firstname,lastname', + 'groupstech:id,name,completename', + 'entity:id,name,completename', 'certificates:id,name', 'documents:id,name', 'contracts:id,name', @@ -50,6 +52,7 @@ class Domain extends Common 'tickets:id,name', 'problems:id,name', 'changes:id,name', + 'infocom', ]; public function type(): BelongsTo @@ -69,7 +72,7 @@ public function groupstech(): BelongsTo public function entity(): BelongsTo { - return $this->belongsTo('\App\Models\Entity'); + return $this->belongsTo('\App\Models\Entity', 'entity_id'); } public function certificates(): MorphToMany @@ -143,4 +146,12 @@ public function changes(): MorphToMany 'change_id', ); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } } diff --git a/src/Models/DomainItem.php b/src/Models/DomainItem.php index 9d2d74c409..e7004d99a2 100644 --- a/src/Models/DomainItem.php +++ b/src/Models/DomainItem.php @@ -21,7 +21,7 @@ class DomainItem extends Common protected $with = [ 'domain:id,name', - 'relation:id,name', + 'relation', ]; public function domain(): BelongsTo @@ -31,6 +31,6 @@ public function domain(): BelongsTo public function relation(): BelongsTo { - return $this->belongsTo('\App\Models\Domainrelation'); + return $this->belongsTo('\App\Models\Domainrelation', 'domainrelation_id'); } } diff --git a/src/Models/Domainrecord.php b/src/Models/Domainrecord.php index 2a04b28596..65b1d7b07d 100644 --- a/src/Models/Domainrecord.php +++ b/src/Models/Domainrecord.php @@ -25,7 +25,7 @@ class Domainrecord extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', 'type:id,name', ]; diff --git a/src/Models/Domainrecordtype.php b/src/Models/Domainrecordtype.php index f5c9acb87a..ecdb7419e0 100644 --- a/src/Models/Domainrecordtype.php +++ b/src/Models/Domainrecordtype.php @@ -23,7 +23,7 @@ class Domainrecordtype extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; diff --git a/src/Models/Domainrelation.php b/src/Models/Domainrelation.php index 6b69f08b43..41c9fb5de2 100644 --- a/src/Models/Domainrelation.php +++ b/src/Models/Domainrelation.php @@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; class Domainrelation extends Common { @@ -16,18 +17,26 @@ class Domainrelation extends Common protected $appends = [ 'entity', + 'domains', ]; protected $visible = [ 'entity', + 'domains', ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', + 'domains', ]; public function entity(): BelongsTo { return $this->belongsTo('\App\Models\Entity'); } + + public function domains(): BelongsToMany + { + return $this->belongsToMany('\App\Models\Domain', 'domain_item', 'domainrelation_id', 'domain_id'); + } } diff --git a/src/Models/Domaintype.php b/src/Models/Domaintype.php index a284179cf6..4b533ee4ee 100644 --- a/src/Models/Domaintype.php +++ b/src/Models/Domaintype.php @@ -23,7 +23,7 @@ class Domaintype extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Models/Enclosure.php b/src/Models/Enclosure.php index 90b001c362..c6086d7fbd 100644 --- a/src/Models/Enclosure.php +++ b/src/Models/Enclosure.php @@ -24,6 +24,8 @@ class Enclosure extends Common 'userstech', 'location', 'entity', + 'items', + 'infocom', ]; protected $visible = [ @@ -56,16 +58,18 @@ class Enclosure extends Common 'devicecases', 'devicegraphiccards', 'devicedrives', + 'items', + 'infocom', ]; protected $with = [ 'model:id,name', 'state:id,name', 'manufacturer:id,name', - 'groupstech:id,name', - 'userstech:id,name', + 'groupstech:id,name,completename', + 'userstech:id,name,firstname,lastname', 'location:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'documents:id,name', 'contracts:id,name', 'tickets:id,name', @@ -88,6 +92,8 @@ class Enclosure extends Common 'devicecases:id,name', 'devicegraphiccards:id,name', 'devicedrives:id,name', + 'items', + 'infocom', ]; public function model(): BelongsTo @@ -193,6 +199,9 @@ public function memories(): MorphToMany 'serial', 'busID', 'location_id', + 'otherserial', + 'state_id', + 'id', ); } @@ -205,6 +214,10 @@ public function firmwares(): MorphToMany )->withPivot( 'devicefirmware_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -220,6 +233,11 @@ public function processors(): MorphToMany 'nbcores', 'nbthreads', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -234,6 +252,10 @@ public function harddrives(): MorphToMany 'capacity', 'serial', 'location_id', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -248,6 +270,9 @@ public function batteries(): MorphToMany 'manufacturing_date', 'serial', 'location_id', + 'otherserial', + 'state_id', + 'id', ); } @@ -260,6 +285,11 @@ public function soundcards(): MorphToMany )->withPivot( 'devicesoundcard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -272,6 +302,11 @@ public function controllers(): MorphToMany )->withPivot( 'devicecontrol_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -284,6 +319,10 @@ public function powersupplies(): MorphToMany )->withPivot( 'devicepowersupply_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -296,6 +335,10 @@ public function sensors(): MorphToMany )->withPivot( 'devicesensor_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -308,6 +351,11 @@ public function devicepcis(): MorphToMany )->withPivot( 'devicepci_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -320,6 +368,10 @@ public function devicegenerics(): MorphToMany )->withPivot( 'devicegeneric_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -332,6 +384,12 @@ public function devicenetworkcards(): MorphToMany )->withPivot( 'devicenetworkcard_id', 'location_id', + 'mac', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -344,6 +402,14 @@ public function devicesimcards(): MorphToMany )->withPivot( 'devicesimcard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'msin', + 'user_id', + 'group_id', + 'line_id', + 'id', ); } @@ -356,6 +422,10 @@ public function devicemotherboards(): MorphToMany )->withPivot( 'devicemotherboard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -368,6 +438,10 @@ public function devicecases(): MorphToMany )->withPivot( 'devicecase_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -380,6 +454,12 @@ public function devicegraphiccards(): MorphToMany )->withPivot( 'devicegraphiccard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'memory', + 'id', ); } @@ -392,6 +472,24 @@ public function devicedrives(): MorphToMany )->withPivot( 'devicedrive_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', + ); + } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemEnclosure', 'enclosure_id'); + } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', ); } } diff --git a/src/Models/Entity.php b/src/Models/Entity.php index 22d741d37b..db045b832e 100644 --- a/src/Models/Entity.php +++ b/src/Models/Entity.php @@ -31,7 +31,7 @@ class Entity extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', 'notes:id', 'knowbaseitems:id,name', 'documents:id,name', diff --git a/src/Models/Fieldblacklist.php b/src/Models/Fieldblacklist.php index 2ed1be1f90..e30d4a71eb 100644 --- a/src/Models/Fieldblacklist.php +++ b/src/Models/Fieldblacklist.php @@ -23,7 +23,7 @@ class Fieldblacklist extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Models/Fieldunicity.php b/src/Models/Fieldunicity.php index 764ad206f1..c704c5f3d1 100644 --- a/src/Models/Fieldunicity.php +++ b/src/Models/Fieldunicity.php @@ -23,7 +23,7 @@ class Fieldunicity extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Models/Followuptemplate.php b/src/Models/Followuptemplate.php index 625f8f1944..2db6a3bd8d 100644 --- a/src/Models/Followuptemplate.php +++ b/src/Models/Followuptemplate.php @@ -26,12 +26,12 @@ class Followuptemplate extends Common protected $with = [ 'source:id,name', - 'entity:id,name', + 'entity:id,name,completename', ]; public function source(): BelongsTo { - return $this->belongsTo('\App\Models\Requesttype'); + return $this->belongsTo('\App\Models\Requesttype', 'requesttype_id'); } public function entity(): BelongsTo diff --git a/src/Models/Forms/Answer.php b/src/Models/Forms/Answer.php index e3cadad714..dff897c52a 100644 --- a/src/Models/Forms/Answer.php +++ b/src/Models/Forms/Answer.php @@ -10,6 +10,7 @@ class Answer extends \App\Models\Common protected $definition = '\App\Models\Definitions\Forms\Answer'; protected $titles = ['Answer', 'Answers']; protected $icon = 'cubes'; + protected $hasEntityField = false; public function form(): BelongsTo { diff --git a/src/Models/Forms/Answerquestion.php b/src/Models/Forms/Answerquestion.php index 22714f857d..f38bd283d6 100644 --- a/src/Models/Forms/Answerquestion.php +++ b/src/Models/Forms/Answerquestion.php @@ -11,4 +11,5 @@ class Answerquestion extends \App\Models\Common protected $definition = '\App\Models\Definitions\Forms\Answerquestion'; protected $titles = ['Answerquestion', 'Answerquestions']; protected $icon = 'cubes'; + protected $hasEntityField = false; } diff --git a/src/Models/Forms/Form.php b/src/Models/Forms/Form.php index 47e6899bfa..b947cfeac7 100644 --- a/src/Models/Forms/Form.php +++ b/src/Models/Forms/Form.php @@ -26,7 +26,7 @@ class Form extends \App\Models\Common protected $with = [ 'category:id,name', - 'entity:id,name', + 'entity:id,name,completename', ]; public function category(): BelongsTo diff --git a/src/Models/Fqdn.php b/src/Models/Fqdn.php index b9ef0bb64a..7397f632d3 100644 --- a/src/Models/Fqdn.php +++ b/src/Models/Fqdn.php @@ -16,18 +16,26 @@ class Fqdn extends Common protected $appends = [ 'entity', + 'alias', ]; protected $visible = [ 'entity', + 'alias', ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', + 'alias', ]; public function entity(): BelongsTo { return $this->belongsTo('\App\Models\Entity'); } + + public function alias(): HasMany + { + return $this->hasMany('\App\Models\Networkalias', 'fqdn_id'); + } } diff --git a/src/Models/Group.php b/src/Models/Group.php index be9410fa0f..ea81fe4f12 100644 --- a/src/Models/Group.php +++ b/src/Models/Group.php @@ -30,7 +30,7 @@ class Group extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', 'notes:id', 'parents:id,name,group_id,entity_id', ]; @@ -73,4 +73,9 @@ public function parents(): HasMany { return $this->hasMany('\App\Models\Group', 'group_id'); } + + public function child(): BelongsTo + { + return $this->belongsTo('\App\Models\Group', 'group_id'); + } } diff --git a/src/Models/Holiday.php b/src/Models/Holiday.php index baf9f9ab95..7514ac2f3f 100644 --- a/src/Models/Holiday.php +++ b/src/Models/Holiday.php @@ -23,7 +23,7 @@ class Holiday extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Models/Infocom.php b/src/Models/Infocom.php new file mode 100644 index 0000000000..39ae05de08 --- /dev/null +++ b/src/Models/Infocom.php @@ -0,0 +1,59 @@ +belongsTo('\App\Models\Entity'); + } + + public function supplier(): BelongsTo + { + return $this->belongsTo('\App\Models\Supplier', 'supplier_id'); + } + + public function budget(): BelongsTo + { + return $this->belongsTo('\App\Models\Budget', 'budget_id'); + } + + public function businesscriticity(): BelongsTo + { + return $this->belongsTo('\App\Models\Businesscriticity', 'businesscriticity_id'); + } +} diff --git a/src/Models/Ipnetwork.php b/src/Models/Ipnetwork.php index d4930dcc9a..6647d35db7 100644 --- a/src/Models/Ipnetwork.php +++ b/src/Models/Ipnetwork.php @@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; class Ipnetwork extends Common { @@ -16,18 +17,26 @@ class Ipnetwork extends Common protected $appends = [ 'entity', + 'vlans', ]; protected $visible = [ 'entity', + 'vlans', ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', + 'vlans', ]; public function entity(): BelongsTo { return $this->belongsTo('\App\Models\Entity'); } + + public function vlans(): BelongsToMany + { + return $this->belongsToMany('\App\Models\Vlan', 'ipnetworks_vlans', 'ipnetwork_id', 'vlan_id'); + } } diff --git a/src/Models/ItemDevicebattery.php b/src/Models/ItemDevicebattery.php new file mode 100644 index 0000000000..c6ca201a69 --- /dev/null +++ b/src/Models/ItemDevicebattery.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemDevicecase.php b/src/Models/ItemDevicecase.php new file mode 100644 index 0000000000..aa7307fc4d --- /dev/null +++ b/src/Models/ItemDevicecase.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemDevicecontrol.php b/src/Models/ItemDevicecontrol.php new file mode 100644 index 0000000000..03cf441f1b --- /dev/null +++ b/src/Models/ItemDevicecontrol.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemDevicedrive.php b/src/Models/ItemDevicedrive.php new file mode 100644 index 0000000000..7550c6f740 --- /dev/null +++ b/src/Models/ItemDevicedrive.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemDevicefirmware.php b/src/Models/ItemDevicefirmware.php new file mode 100644 index 0000000000..9c399af101 --- /dev/null +++ b/src/Models/ItemDevicefirmware.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemDevicegeneric.php b/src/Models/ItemDevicegeneric.php new file mode 100644 index 0000000000..db4b8c2225 --- /dev/null +++ b/src/Models/ItemDevicegeneric.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemDevicegraphiccard.php b/src/Models/ItemDevicegraphiccard.php new file mode 100644 index 0000000000..bab6e6620b --- /dev/null +++ b/src/Models/ItemDevicegraphiccard.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemDeviceharddrive.php b/src/Models/ItemDeviceharddrive.php new file mode 100644 index 0000000000..fff4fcefc8 --- /dev/null +++ b/src/Models/ItemDeviceharddrive.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemDevicememory.php b/src/Models/ItemDevicememory.php new file mode 100644 index 0000000000..f0ac3d00b1 --- /dev/null +++ b/src/Models/ItemDevicememory.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemDevicemotherboard.php b/src/Models/ItemDevicemotherboard.php new file mode 100644 index 0000000000..855951214a --- /dev/null +++ b/src/Models/ItemDevicemotherboard.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemDevicenetworkcard.php b/src/Models/ItemDevicenetworkcard.php new file mode 100644 index 0000000000..384e91bc99 --- /dev/null +++ b/src/Models/ItemDevicenetworkcard.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemDevicepci.php b/src/Models/ItemDevicepci.php new file mode 100644 index 0000000000..2451ad7f95 --- /dev/null +++ b/src/Models/ItemDevicepci.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemDevicepowersupply.php b/src/Models/ItemDevicepowersupply.php new file mode 100644 index 0000000000..350f7e25c7 --- /dev/null +++ b/src/Models/ItemDevicepowersupply.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemDeviceprocessor.php b/src/Models/ItemDeviceprocessor.php new file mode 100644 index 0000000000..bbddfbd41c --- /dev/null +++ b/src/Models/ItemDeviceprocessor.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemDevicesensor.php b/src/Models/ItemDevicesensor.php new file mode 100644 index 0000000000..ff4aba0915 --- /dev/null +++ b/src/Models/ItemDevicesensor.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemDevicesimcard.php b/src/Models/ItemDevicesimcard.php index 02ed680f8b..48f503c5bf 100644 --- a/src/Models/ItemDevicesimcard.php +++ b/src/Models/ItemDevicesimcard.php @@ -24,6 +24,7 @@ class ItemDevicesimcard extends Common 'user', 'group', 'entity', + 'infocom', ]; protected $visible = [ @@ -34,16 +35,18 @@ class ItemDevicesimcard extends Common 'entity', 'documents', 'contracts', + 'infocom', ]; protected $with = [ 'state:id,name', 'location:id,name', - 'user:id,name', - 'group:id,name', - 'entity:id,name', - 'documents:id,name', + 'user:id,name,firstname,lastname', + 'group:id,name,completename', + 'entity:id,name,completename', + 'documents', 'contracts:id,name', + 'infocom', ]; @@ -94,4 +97,12 @@ public function contracts(): MorphToMany 'contract_id', ); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } } diff --git a/src/Models/ItemDevicesoundcard.php b/src/Models/ItemDevicesoundcard.php new file mode 100644 index 0000000000..8b46bd3daf --- /dev/null +++ b/src/Models/ItemDevicesoundcard.php @@ -0,0 +1,51 @@ +belongsTo('\App\Models\Entity'); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } +} diff --git a/src/Models/ItemEnclosure.php b/src/Models/ItemEnclosure.php new file mode 100644 index 0000000000..2a23bbcf17 --- /dev/null +++ b/src/Models/ItemEnclosure.php @@ -0,0 +1,18 @@ +belongsTo('\App\Models\Entity'); + } +} diff --git a/src/Models/ItemTicket.php b/src/Models/ItemTicket.php new file mode 100644 index 0000000000..a086bb1fb9 --- /dev/null +++ b/src/Models/ItemTicket.php @@ -0,0 +1,18 @@ +belongsTo('\App\Models\Knowbaseitemcategory'); + return $this->belongsTo('\App\Models\Knowbaseitemcategory', 'knowbaseitemcategory_id'); } public function entity(): BelongsTo diff --git a/src/Models/Line.php b/src/Models/Line.php index 8dd31ad11b..2542d79844 100644 --- a/src/Models/Line.php +++ b/src/Models/Line.php @@ -25,6 +25,7 @@ class Line extends Common 'group', 'entity', 'notes', + 'infocom', ]; protected $visible = [ @@ -38,6 +39,7 @@ class Line extends Common 'notes', 'documents', 'contracts', + 'infocom', ]; protected $with = [ @@ -45,12 +47,13 @@ class Line extends Common 'type:id,name', 'operator:id,name', 'state:id,name', - 'user:id,name', - 'group:id,name', - 'entity:id,name', + 'user:id,name,firstname,lastname', + 'group:id,name,completename', + 'entity:id,name,completename', 'notes:id', 'documents:id,name', 'contracts:id,name', + 'infocom', ]; public function location(): BelongsTo @@ -118,4 +121,12 @@ public function contracts(): MorphToMany 'contract_id', ); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } } diff --git a/src/Models/Lineoperator.php b/src/Models/Lineoperator.php index 3a9d73e050..f5928111c6 100644 --- a/src/Models/Lineoperator.php +++ b/src/Models/Lineoperator.php @@ -23,7 +23,7 @@ class Lineoperator extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Models/Link.php b/src/Models/Link.php index 6a02722790..9424faf9cd 100644 --- a/src/Models/Link.php +++ b/src/Models/Link.php @@ -23,7 +23,7 @@ class Link extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Models/Location.php b/src/Models/Location.php index be49be4439..a617992d6f 100644 --- a/src/Models/Location.php +++ b/src/Models/Location.php @@ -32,7 +32,7 @@ class Location extends Common protected $with = [ 'location:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'documents:id,name', ]; diff --git a/src/Models/Monitor.php b/src/Models/Monitor.php index 3a3e39d1be..780c861cc8 100644 --- a/src/Models/Monitor.php +++ b/src/Models/Monitor.php @@ -28,6 +28,7 @@ class Monitor extends Common 'userstech', 'location', 'entity', + 'infocom', ]; protected $visible = [ @@ -53,6 +54,8 @@ class Monitor extends Common 'problems', 'changes', 'connections', + 'infocom', + 'reservations', ]; protected $with = [ @@ -60,12 +63,12 @@ class Monitor extends Common 'model:id,name', 'state:id,name', 'manufacturer:id,name', - 'user:id,name', - 'group:id,name', - 'groupstech:id,name', - 'userstech:id,name', + 'user:id,name,firstname,lastname', + 'group:id,name,completename', + 'userstech:id,name,firstname,lastname', + 'groupstech:id,name,completename', 'location:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'domains:id,name', 'appliances:id,name', 'notes:id', @@ -79,17 +82,19 @@ class Monitor extends Common 'problems:id,name', 'changes:id,name', 'connections:id,name', + 'infocom', + 'reservations', ]; public function type(): BelongsTo { - return $this->belongsTo('\App\Models\Monitortype'); + return $this->belongsTo('\App\Models\Monitortype', 'monitortype_id'); } public function model(): BelongsTo { - return $this->belongsTo('\App\Models\Monitormodel'); + return $this->belongsTo('\App\Models\Monitormodel', 'monitormodel_id'); } public function state(): BelongsTo @@ -265,4 +270,20 @@ public function connections(): MorphToMany 'is_dynamic', ); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } + + public function reservations(): MorphMany + { + return $this->morphMany( + '\App\Models\Reservationitem', + 'item', + ); + } } diff --git a/src/Models/Netpoint.php b/src/Models/Netpoint.php index c2860dfcb5..68b74f2b24 100644 --- a/src/Models/Netpoint.php +++ b/src/Models/Netpoint.php @@ -26,7 +26,7 @@ class Netpoint extends Common protected $with = [ 'location:id,name', - 'entity:id,name', + 'entity:id,name,completename', ]; public function location(): BelongsTo diff --git a/src/Models/Networkalias.php b/src/Models/Networkalias.php new file mode 100644 index 0000000000..aa5144a834 --- /dev/null +++ b/src/Models/Networkalias.php @@ -0,0 +1,31 @@ +belongsTo('\App\Models\Entity'); + } +} diff --git a/src/Models/Networkequipment.php b/src/Models/Networkequipment.php index 9a2c694d00..25f67fb277 100644 --- a/src/Models/Networkequipment.php +++ b/src/Models/Networkequipment.php @@ -28,6 +28,7 @@ class Networkequipment extends Common 'userstech', 'location', 'entity', + 'infocom', ]; protected $visible = [ @@ -72,6 +73,8 @@ class Networkequipment extends Common 'devicegraphiccards', 'devicedrives', 'volumes', + 'infocom', + 'reservations', ]; protected $with = [ @@ -79,13 +82,13 @@ class Networkequipment extends Common 'model:id,name', 'state:id,name', 'manufacturer:id,name', - 'user:id,name', - 'group:id,name', + 'user:id,name,firstname,lastname', + 'group:id,name,completename', 'network:id,name', - 'groupstech:id,name', - 'userstech:id,name', + 'groupstech:id,name,completename', + 'userstech:id,name,firstname,lastname', 'location:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'certificates:id,name', 'domains:id,name', 'appliances:id,name', @@ -116,6 +119,8 @@ class Networkequipment extends Common 'devicegraphiccards:id,name', 'devicedrives:id,name', 'volumes:id,name', + 'infocom', + 'reservations', ]; @@ -319,6 +324,9 @@ public function memories(): MorphToMany 'serial', 'busID', 'location_id', + 'otherserial', + 'state_id', + 'id', ); } @@ -331,6 +339,10 @@ public function firmwares(): MorphToMany )->withPivot( 'devicefirmware_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -346,6 +358,11 @@ public function processors(): MorphToMany 'nbcores', 'nbthreads', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -360,6 +377,10 @@ public function harddrives(): MorphToMany 'capacity', 'serial', 'location_id', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -374,6 +395,9 @@ public function batteries(): MorphToMany 'manufacturing_date', 'serial', 'location_id', + 'otherserial', + 'state_id', + 'id', ); } @@ -386,6 +410,11 @@ public function soundcards(): MorphToMany )->withPivot( 'devicesoundcard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -398,6 +427,11 @@ public function controllers(): MorphToMany )->withPivot( 'devicecontrol_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -410,6 +444,10 @@ public function powersupplies(): MorphToMany )->withPivot( 'devicepowersupply_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -422,6 +460,10 @@ public function sensors(): MorphToMany )->withPivot( 'devicesensor_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -434,6 +476,11 @@ public function devicepcis(): MorphToMany )->withPivot( 'devicepci_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -446,6 +493,10 @@ public function devicegenerics(): MorphToMany )->withPivot( 'devicegeneric_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -458,6 +509,12 @@ public function devicenetworkcards(): MorphToMany )->withPivot( 'devicenetworkcard_id', 'location_id', + 'mac', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -470,6 +527,14 @@ public function devicesimcards(): MorphToMany )->withPivot( 'devicesimcard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'msin', + 'user_id', + 'group_id', + 'line_id', + 'id', ); } @@ -482,6 +547,10 @@ public function devicemotherboards(): MorphToMany )->withPivot( 'devicemotherboard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -494,6 +563,10 @@ public function devicecases(): MorphToMany )->withPivot( 'devicecase_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -506,6 +579,12 @@ public function devicegraphiccards(): MorphToMany )->withPivot( 'devicegraphiccard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'memory', + 'id', ); } @@ -518,6 +597,11 @@ public function devicedrives(): MorphToMany )->withPivot( 'devicedrive_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -525,4 +609,20 @@ public function volumes(): HasMany { return $this->hasMany('App\Models\Itemdisk', 'item_id')->where('item_type', get_class($this)); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } + + public function reservations(): MorphMany + { + return $this->morphMany( + '\App\Models\Reservationitem', + 'item', + ); + } } diff --git a/src/Models/Networkname.php b/src/Models/Networkname.php index 4e04e8c711..991977143b 100644 --- a/src/Models/Networkname.php +++ b/src/Models/Networkname.php @@ -17,16 +17,19 @@ class Networkname extends Common protected $appends = [ 'fqdn', 'entity', + 'alias', ]; protected $visible = [ 'fqdn', 'entity', + 'alias', ]; protected $with = [ 'fqdn:id,name', - 'entity:id,name', + 'entity:id,name,completename', + 'alias', ]; public function fqdn(): BelongsTo @@ -38,4 +41,9 @@ public function entity(): BelongsTo { return $this->belongsTo('\App\Models\Entity'); } + + public function alias(): HasMany + { + return $this->hasMany('\App\Models\Networkalias', 'networkname_id'); + } } diff --git a/src/Models/News.php b/src/Models/News.php index 332e3ce140..e44beed161 100644 --- a/src/Models/News.php +++ b/src/Models/News.php @@ -21,7 +21,7 @@ class News extends Common ]; protected $with = [ - // 'user:id,name', + // 'user:id,name,firstname,lastname', ]; // public function user(): BelongsTo diff --git a/src/Models/Notepad.php b/src/Models/Notepad.php index ca291a3b4b..5d965d9e94 100644 --- a/src/Models/Notepad.php +++ b/src/Models/Notepad.php @@ -20,8 +20,8 @@ class Notepad extends Common ]; protected $with = [ - 'user:id,name', - 'userlastupdater:id,name', + 'user:id,name,firstname,lastname', + 'userlastupdater:id,name,firstname,lastname', ]; protected $fillable = [ diff --git a/src/Models/Notification.php b/src/Models/Notification.php index 3f9f7b81fc..71d208ad82 100644 --- a/src/Models/Notification.php +++ b/src/Models/Notification.php @@ -26,7 +26,7 @@ class Notification extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Models/Ola.php b/src/Models/Ola.php new file mode 100644 index 0000000000..e3b9bdbcea --- /dev/null +++ b/src/Models/Ola.php @@ -0,0 +1,41 @@ +belongsTo('\App\Models\Entity'); + } + + public function calendar(): BelongsTo + { + return $this->belongsTo('\App\Models\Calendar', 'calendar_id'); + } +} diff --git a/src/Models/Operatingsystemkernelversion.php b/src/Models/Operatingsystemkernelversion.php index 1ac3614c47..1ec1de3c9a 100644 --- a/src/Models/Operatingsystemkernelversion.php +++ b/src/Models/Operatingsystemkernelversion.php @@ -30,6 +30,6 @@ class Operatingsystemkernelversion extends Common public function kernel(): BelongsTo { - return $this->belongsTo('\App\Models\Operatingsystemkernel'); + return $this->belongsTo('\App\Models\Operatingsystemkernel', 'operatingsystemkernel_id'); } } diff --git a/src/Models/Passivedcequipment.php b/src/Models/Passivedcequipment.php index a4b5e3c972..08603774cf 100644 --- a/src/Models/Passivedcequipment.php +++ b/src/Models/Passivedcequipment.php @@ -25,6 +25,7 @@ class Passivedcequipment extends Common 'userstech', 'location', 'entity', + 'infocom', ]; protected $visible = [ @@ -41,6 +42,7 @@ class Passivedcequipment extends Common 'tickets', 'problems', 'changes', + 'infocom', ]; protected $with = [ @@ -48,15 +50,16 @@ class Passivedcequipment extends Common 'model:id,name', 'state:id,name', 'manufacturer:id,name', - 'groupstech:id,name', - 'userstech:id,name', + 'groupstech:id,name,completename', + 'userstech:id,name,firstname,lastname', 'location:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'documents:id,name', 'contracts:id,name', 'tickets:id,name', 'problems:id,name', 'changes:id,name', + 'infocom', ]; @@ -155,4 +158,12 @@ public function changes(): MorphToMany 'change_id', ); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } } diff --git a/src/Models/Pdu.php b/src/Models/Pdu.php index 452295d50d..ad2691d25b 100644 --- a/src/Models/Pdu.php +++ b/src/Models/Pdu.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\Relations\MorphToMany; use Illuminate\Database\Eloquent\Relations\MorphMany; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; class Pdu extends Common { @@ -25,6 +26,8 @@ class Pdu extends Common 'userstech', 'location', 'entity', + 'plugs', + 'infocom', ]; protected $visible = [ @@ -41,6 +44,8 @@ class Pdu extends Common 'tickets', 'problems', 'changes', + 'plugs', + 'infocom', ]; protected $with = [ @@ -48,15 +53,17 @@ class Pdu extends Common 'model:id,name', 'state:id,name', 'manufacturer:id,name', - 'groupstech:id,name', - 'userstech:id,name', + 'groupstech:id,name,completename', + 'userstech:id,name,firstname,lastname', 'location:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'documents:id,name', 'contracts:id,name', 'tickets:id,name', 'problems:id,name', 'changes:id,name', + 'plugs', + 'infocom', ]; @@ -155,4 +162,17 @@ public function changes(): MorphToMany 'change_id', ); } + + public function plugs(): BelongsToMany + { + return $this->belongsToMany('\App\Models\Plug', 'pdu_plug', 'pdu_id', 'plug_id')->withPivot('number_plugs'); + } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } } diff --git a/src/Models/Peripheral.php b/src/Models/Peripheral.php index ac146e73c0..da5f32a668 100644 --- a/src/Models/Peripheral.php +++ b/src/Models/Peripheral.php @@ -28,6 +28,7 @@ class Peripheral extends Common 'userstech', 'location', 'entity', + 'infocom', ]; protected $visible = [ @@ -72,6 +73,8 @@ class Peripheral extends Common 'devicegraphiccards', 'devicedrives', 'connections', + 'infocom', + 'reservations', ]; protected $with = [ @@ -79,13 +82,13 @@ class Peripheral extends Common 'model:id,name', 'state:id,name', 'manufacturer:id,name', - 'user:id,name', - 'group:id,name', + 'user:id,name,firstname,lastname', + 'group:id,name,completename', 'network:id,name', - 'groupstech:id,name', - 'userstech:id,name', + 'groupstech:id,name,completename', + 'userstech:id,name,firstname,lastname', 'location:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'certificates:id,name', 'domains:id,name', 'appliances:id,name', @@ -116,6 +119,8 @@ class Peripheral extends Common 'devicegraphiccards:id,name', 'devicedrives:id,name', 'connections:id,name', + 'infocom', + 'reservations', ]; @@ -319,6 +324,9 @@ public function memories(): MorphToMany 'serial', 'busID', 'location_id', + 'otherserial', + 'state_id', + 'id', ); } @@ -331,6 +339,10 @@ public function firmwares(): MorphToMany )->withPivot( 'devicefirmware_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -346,6 +358,11 @@ public function processors(): MorphToMany 'nbcores', 'nbthreads', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -360,6 +377,10 @@ public function harddrives(): MorphToMany 'capacity', 'serial', 'location_id', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -374,6 +395,9 @@ public function batteries(): MorphToMany 'manufacturing_date', 'serial', 'location_id', + 'otherserial', + 'state_id', + 'id', ); } @@ -386,6 +410,11 @@ public function soundcards(): MorphToMany )->withPivot( 'devicesoundcard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -398,6 +427,11 @@ public function controllers(): MorphToMany )->withPivot( 'devicecontrol_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -410,6 +444,10 @@ public function powersupplies(): MorphToMany )->withPivot( 'devicepowersupply_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -422,6 +460,10 @@ public function sensors(): MorphToMany )->withPivot( 'devicesensor_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -434,6 +476,11 @@ public function devicepcis(): MorphToMany )->withPivot( 'devicepci_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -446,6 +493,10 @@ public function devicegenerics(): MorphToMany )->withPivot( 'devicegeneric_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -458,6 +509,12 @@ public function devicenetworkcards(): MorphToMany )->withPivot( 'devicenetworkcard_id', 'location_id', + 'mac', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -470,6 +527,14 @@ public function devicesimcards(): MorphToMany )->withPivot( 'devicesimcard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'msin', + 'user_id', + 'group_id', + 'line_id', + 'id', ); } @@ -482,6 +547,10 @@ public function devicemotherboards(): MorphToMany )->withPivot( 'devicemotherboard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -494,6 +563,10 @@ public function devicecases(): MorphToMany )->withPivot( 'devicecase_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -506,6 +579,12 @@ public function devicegraphiccards(): MorphToMany )->withPivot( 'devicegraphiccard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'memory', + 'id', ); } @@ -518,6 +597,11 @@ public function devicedrives(): MorphToMany )->withPivot( 'devicedrive_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -532,4 +616,20 @@ public function connections(): MorphToMany 'is_dynamic', ); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } + + public function reservations(): MorphMany + { + return $this->morphMany( + '\App\Models\Reservationitem', + 'item', + ); + } } diff --git a/src/Models/Phone.php b/src/Models/Phone.php index 51cc026b85..4b20ad739f 100644 --- a/src/Models/Phone.php +++ b/src/Models/Phone.php @@ -29,6 +29,7 @@ class Phone extends Common 'userstech', 'location', 'entity', + 'infocom', ]; protected $visible = [ @@ -74,6 +75,8 @@ class Phone extends Common 'devicedrives', 'volumes', 'connections', + 'infocom', + 'reservations', ]; protected $with = [ @@ -82,13 +85,13 @@ class Phone extends Common 'phonepowersupply:id,name', 'state:id,name', 'manufacturer:id,name', - 'user:id,name', - 'group:id,name', + 'user:id,name,firstname,lastname', + 'group:id,name,completename', 'network:id,name', - 'groupstech:id,name', - 'userstech:id,name', + 'groupstech:id,name,completename', + 'userstech:id,name,firstname,lastname', 'location:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'domains:id,name', 'appliances:id,name', 'notes:id', @@ -119,6 +122,8 @@ class Phone extends Common 'devicedrives:id,name', 'volumes:id,name', 'connections:id,name', + 'infocom', + 'reservations', ]; @@ -316,6 +321,9 @@ public function memories(): MorphToMany 'serial', 'busID', 'location_id', + 'otherserial', + 'state_id', + 'id', ); } @@ -328,6 +336,10 @@ public function firmwares(): MorphToMany )->withPivot( 'devicefirmware_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -343,6 +355,11 @@ public function processors(): MorphToMany 'nbcores', 'nbthreads', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -357,6 +374,10 @@ public function harddrives(): MorphToMany 'capacity', 'serial', 'location_id', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -371,6 +392,9 @@ public function batteries(): MorphToMany 'manufacturing_date', 'serial', 'location_id', + 'otherserial', + 'state_id', + 'id', ); } @@ -383,6 +407,11 @@ public function soundcards(): MorphToMany )->withPivot( 'devicesoundcard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -395,6 +424,11 @@ public function controllers(): MorphToMany )->withPivot( 'devicecontrol_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -407,6 +441,10 @@ public function powersupplies(): MorphToMany )->withPivot( 'devicepowersupply_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -419,6 +457,10 @@ public function sensors(): MorphToMany )->withPivot( 'devicesensor_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -431,6 +473,11 @@ public function devicepcis(): MorphToMany )->withPivot( 'devicepci_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -443,6 +490,10 @@ public function devicegenerics(): MorphToMany )->withPivot( 'devicegeneric_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -455,6 +506,12 @@ public function devicenetworkcards(): MorphToMany )->withPivot( 'devicenetworkcard_id', 'location_id', + 'mac', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -467,6 +524,14 @@ public function devicesimcards(): MorphToMany )->withPivot( 'devicesimcard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'msin', + 'user_id', + 'group_id', + 'line_id', + 'id', ); } @@ -479,6 +544,10 @@ public function devicemotherboards(): MorphToMany )->withPivot( 'devicemotherboard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -491,6 +560,10 @@ public function devicecases(): MorphToMany )->withPivot( 'devicecase_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -503,6 +576,12 @@ public function devicegraphiccards(): MorphToMany )->withPivot( 'devicegraphiccard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'memory', + 'id', ); } @@ -515,6 +594,11 @@ public function devicedrives(): MorphToMany )->withPivot( 'devicedrive_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -534,4 +618,20 @@ public function connections(): MorphToMany 'is_dynamic', ); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } + + public function reservations(): MorphMany + { + return $this->morphMany( + '\App\Models\Reservationitem', + 'item', + ); + } } diff --git a/src/Models/Planningexternaleventtemplate.php b/src/Models/Planningexternaleventtemplate.php index e51d9b7784..dc6bff05ab 100644 --- a/src/Models/Planningexternaleventtemplate.php +++ b/src/Models/Planningexternaleventtemplate.php @@ -26,12 +26,12 @@ class Planningexternaleventtemplate extends Common protected $with = [ 'category:id,name', - 'entity:id,name', + 'entity:id,name,completename', ]; public function category(): BelongsTo { - return $this->belongsTo('\App\Models\Planningeventcategory'); + return $this->belongsTo('\App\Models\Planningeventcategory', 'planningeventcategory_id'); } public function entity(): BelongsTo diff --git a/src/Models/Printer.php b/src/Models/Printer.php index b5bce56c81..b3aaac9ac2 100644 --- a/src/Models/Printer.php +++ b/src/Models/Printer.php @@ -29,6 +29,7 @@ class Printer extends Common 'userstech', 'location', 'entity', + 'infocom', ]; protected $visible = [ @@ -75,6 +76,8 @@ class Printer extends Common 'devicedrives', 'connections', 'cartridges', + 'infocom', + 'reservations', ]; protected $with = [ @@ -82,13 +85,13 @@ class Printer extends Common 'model:id,name', 'state:id,name', 'manufacturer:id,name', - 'user:id,name', - 'group:id,name', + 'user:id,name,firstname,lastname', + 'group:id,name,completename', 'network:id,name', - 'groupstech:id,name', - 'userstech:id,name', + 'groupstech:id,name,completename', + 'userstech:id,name,firstname,lastname', 'location:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'certificates:id,name', 'domains:id,name', 'appliances:id,name', @@ -121,6 +124,8 @@ class Printer extends Common 'devicedrives:id,name', 'connections:id,name', 'cartridges:id', + 'infocom', + 'reservations', ]; @@ -329,6 +334,9 @@ public function memories(): MorphToMany 'serial', 'busID', 'location_id', + 'otherserial', + 'state_id', + 'id', ); } @@ -341,6 +349,10 @@ public function firmwares(): MorphToMany )->withPivot( 'devicefirmware_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -356,6 +368,11 @@ public function processors(): MorphToMany 'nbcores', 'nbthreads', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -370,6 +387,10 @@ public function harddrives(): MorphToMany 'capacity', 'serial', 'location_id', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -384,6 +405,9 @@ public function batteries(): MorphToMany 'manufacturing_date', 'serial', 'location_id', + 'otherserial', + 'state_id', + 'id', ); } @@ -396,6 +420,11 @@ public function soundcards(): MorphToMany )->withPivot( 'devicesoundcard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -408,6 +437,11 @@ public function controllers(): MorphToMany )->withPivot( 'devicecontrol_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -420,6 +454,10 @@ public function powersupplies(): MorphToMany )->withPivot( 'devicepowersupply_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -432,6 +470,10 @@ public function sensors(): MorphToMany )->withPivot( 'devicesensor_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -444,6 +486,11 @@ public function devicepcis(): MorphToMany )->withPivot( 'devicepci_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -456,6 +503,10 @@ public function devicegenerics(): MorphToMany )->withPivot( 'devicegeneric_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -468,6 +519,12 @@ public function devicenetworkcards(): MorphToMany )->withPivot( 'devicenetworkcard_id', 'location_id', + 'mac', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -480,6 +537,14 @@ public function devicesimcards(): MorphToMany )->withPivot( 'devicesimcard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'msin', + 'user_id', + 'group_id', + 'line_id', + 'id', ); } @@ -492,6 +557,10 @@ public function devicemotherboards(): MorphToMany )->withPivot( 'devicemotherboard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -504,6 +573,10 @@ public function devicecases(): MorphToMany )->withPivot( 'devicecase_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'id', ); } @@ -516,6 +589,12 @@ public function devicegraphiccards(): MorphToMany )->withPivot( 'devicegraphiccard_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'memory', + 'id', ); } @@ -528,6 +607,11 @@ public function devicedrives(): MorphToMany )->withPivot( 'devicedrive_id', 'location_id', + 'serial', + 'otherserial', + 'state_id', + 'busID', + 'id', ); } @@ -547,4 +631,20 @@ public function cartridges(): HasMany { return $this->hasMany('App\Models\Cartridge', 'printer_id'); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } + + public function reservations(): MorphMany + { + return $this->morphMany( + '\App\Models\Reservationitem', + 'item', + ); + } } diff --git a/src/Models/Problem.php b/src/Models/Problem.php index 10fb24fdff..4e58d162fd 100644 --- a/src/Models/Problem.php +++ b/src/Models/Problem.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\Relations\MorphToMany; use Illuminate\Database\Eloquent\Relations\MorphMany; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; class Problem extends Common { @@ -14,7 +15,7 @@ class Problem extends Common protected $definition = '\App\Models\Definitions\Problem'; protected $titles = ['Problem', 'Problems']; - protected $icon = 'exclamation triangle'; + protected $icon = 'drafting compass'; protected $appends = [ // 'category', @@ -22,6 +23,9 @@ class Problem extends Common // 'usersidrecipient', 'entity', 'notes', + 'changes', + 'costs', + 'items', ]; protected $visible = [ @@ -39,24 +43,30 @@ class Problem extends Common 'requestergroup', 'technician', 'techniciangroup', + 'changes', + 'costs', + 'items', ]; protected $with = [ 'category:id,name', - 'usersidlastupdater:id,name', - 'usersidrecipient:id,name', - 'entity:id,name', + 'usersidlastupdater:id,name,firstname,lastname', + 'usersidrecipient:id,name,firstname,lastname', + 'entity:id,name,completename', 'notes:id', 'knowbaseitems:id,name', - 'requester', - 'requestergroup', - 'technician', - 'techniciangroup', + 'requester:id,name,firstname,lastname', + 'requestergroup:id,name,completename', + 'technician:id,name,firstname,lastname', + 'techniciangroup:id,name,completename', + 'changes', + 'costs', + 'items', ]; public function category(): BelongsTo { - return $this->belongsTo('\App\Models\Category'); + return $this->belongsTo('\App\Models\Category', 'category_id'); } public function usersidlastupdater(): BelongsTo @@ -112,4 +122,19 @@ public function techniciangroup() { return $this->belongsToMany('\App\Models\Group')->wherePivot('type', 2); } + + public function changes(): BelongsToMany + { + return $this->belongsToMany('\App\Models\Change', 'change_problem', 'problem_id', 'change_id'); + } + + public function costs(): HasMany + { + return $this->hasMany('App\Models\Problemcost', 'problem_id'); + } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemProblem', 'problem_id'); + } } diff --git a/src/Models/ProblemTicket.php b/src/Models/ProblemTicket.php new file mode 100644 index 0000000000..8723e0684e --- /dev/null +++ b/src/Models/ProblemTicket.php @@ -0,0 +1,16 @@ +belongsTo('\App\Models\Entity'); + } + + public function budget(): BelongsTo + { + return $this->belongsTo('\App\Models\Budget'); + } +} diff --git a/src/Models/Problemtemplate.php b/src/Models/Problemtemplate.php index edc57ced08..5293b5429a 100644 --- a/src/Models/Problemtemplate.php +++ b/src/Models/Problemtemplate.php @@ -21,7 +21,7 @@ class Problemtemplate extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Models/Project.php b/src/Models/Project.php index 31ba3315bb..77a4709fa3 100644 --- a/src/Models/Project.php +++ b/src/Models/Project.php @@ -42,15 +42,15 @@ class Project extends Common protected $with = [ 'type:id,name', - 'state:id,name', - 'user:id,name', - 'group:id,name', - 'entity:id,name', + 'state', + 'user:id,name,firstname,lastname', + 'group:id,name,completename', + 'entity:id,name,completename', 'notes:id', 'knowbaseitems:id,name', 'documents:id,name', 'contracts:id,name', - 'tasks:id,name', + 'tasks', 'parents:id,name', 'costs:id,name', ]; diff --git a/src/Models/Projecttask.php b/src/Models/Projecttask.php index 0a7fb7e77a..9b9fb1fe52 100644 --- a/src/Models/Projecttask.php +++ b/src/Models/Projecttask.php @@ -6,6 +6,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\Relations\BelongsToMany; +use Illuminate\Database\Eloquent\Relations\MorphMany; +use Illuminate\Database\Eloquent\Relations\MorphToMany; class Projecttask extends Common { @@ -21,6 +23,8 @@ class Projecttask extends Common 'type', 'state', 'tickets', + 'notes', + 'documents', ]; protected $visible = [ @@ -29,14 +33,18 @@ class Projecttask extends Common 'type', 'state', 'tickets', + 'notes', + 'documents', ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', 'parent:id,name', 'type:id,name', 'state:id,name,color', 'tickets:id,name', + 'notes:id', + 'documents:id,name', ]; public function entity(): BelongsTo @@ -63,4 +71,24 @@ public function tickets(): BelongsToMany { return $this->belongsToMany('\App\Models\Ticket', 'projecttask_ticket', 'projecttask_id', 'ticket_id'); } + + public function notes(): MorphMany + { + return $this->morphMany( + '\App\Models\Notepad', + 'item', + ); + } + + public function documents(): MorphToMany + { + return $this->morphToMany( + '\App\Models\Document', + 'item', + 'document_item' + )->withPivot( + 'document_id', + 'updated_at', + ); + } } diff --git a/src/Models/ProjecttaskTicket.php b/src/Models/ProjecttaskTicket.php new file mode 100644 index 0000000000..d22e0387e5 --- /dev/null +++ b/src/Models/ProjecttaskTicket.php @@ -0,0 +1,17 @@ +belongsTo('\App\Models\Projectstate'); + return $this->belongsTo('\App\Models\Projectstate', 'projectstate_id'); } public function type(): BelongsTo { - return $this->belongsTo('\App\Models\Projecttasktype'); + return $this->belongsTo('\App\Models\Projecttasktype', 'projecttasktype_id'); } public function projecttasks(): BelongsTo { - return $this->belongsTo('\App\Models\Projecttask'); + return $this->belongsTo('\App\Models\Projecttask', 'projecttask_id'); } public function entity(): BelongsTo diff --git a/src/Models/Queuednotification.php b/src/Models/Queuednotification.php index 99e39f1138..b6300845d8 100644 --- a/src/Models/Queuednotification.php +++ b/src/Models/Queuednotification.php @@ -26,7 +26,7 @@ class Queuednotification extends Common protected $with = [ 'notificationtemplate:id,name', - 'entity:id,name', + 'entity:id,name,completename', ]; public function notificationtemplate(): BelongsTo diff --git a/src/Models/Rack.php b/src/Models/Rack.php index e42d7c7f1a..9658c9c0ce 100644 --- a/src/Models/Rack.php +++ b/src/Models/Rack.php @@ -25,6 +25,7 @@ class Rack extends Common 'userstech', 'location', 'entity', + 'infocom', ]; protected $visible = [ @@ -41,6 +42,7 @@ class Rack extends Common 'tickets', 'problems', 'changes', + 'infocom', ]; protected $with = [ @@ -48,15 +50,16 @@ class Rack extends Common 'model:id,name', 'state:id,name', 'manufacturer:id,name', - 'groupstech:id,name', - 'userstech:id,name', + 'groupstech:id,name,completename', + 'userstech:id,name,firstname,lastname', 'location:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'documents:id,name', 'contracts:id,name', 'tickets:id,name', 'problems:id,name', 'changes:id,name', + 'infocom', ]; @@ -155,4 +158,12 @@ public function changes(): MorphToMany 'change_id', ); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } } diff --git a/src/Models/Racktype.php b/src/Models/Racktype.php index bedad4e68e..31054096dc 100644 --- a/src/Models/Racktype.php +++ b/src/Models/Racktype.php @@ -23,7 +23,7 @@ class Racktype extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Models/Reminder.php b/src/Models/Reminder.php index e548a51090..172be6a5e7 100644 --- a/src/Models/Reminder.php +++ b/src/Models/Reminder.php @@ -27,7 +27,7 @@ class Reminder extends Common ]; protected $with = [ - 'user:id,name', + 'user:id,name,firstname,lastname', 'documents:id,name', ]; diff --git a/src/Models/Reservation.php b/src/Models/Reservation.php new file mode 100644 index 0000000000..4829e1bfe3 --- /dev/null +++ b/src/Models/Reservation.php @@ -0,0 +1,32 @@ +belongsTo('\App\Models\User', 'user_id'); + } +} diff --git a/src/Models/Reservationitem.php b/src/Models/Reservationitem.php new file mode 100644 index 0000000000..1f40eeca31 --- /dev/null +++ b/src/Models/Reservationitem.php @@ -0,0 +1,43 @@ +belongsTo('\App\Models\Entity'); + } + + public function reservations(): HasMany + { + return $this->hasMany('\App\Models\Reservation'); + } +} diff --git a/src/Models/Rssfeed.php b/src/Models/Rssfeed.php index b50f032745..24c276fd2b 100644 --- a/src/Models/Rssfeed.php +++ b/src/Models/Rssfeed.php @@ -24,7 +24,7 @@ class Rssfeed extends Common ]; protected $with = [ - 'user:id,name', + 'user:id,name,firstname,lastname', ]; diff --git a/src/Models/Savedsearch.php b/src/Models/Savedsearch.php index 474969c52b..9292c380a2 100644 --- a/src/Models/Savedsearch.php +++ b/src/Models/Savedsearch.php @@ -25,8 +25,8 @@ class Savedsearch extends Common ]; protected $with = [ - 'user:id,name', - 'entity:id,name', + 'user:id,name,firstname,lastname', + 'entity:id,name,completename', ]; diff --git a/src/Models/Sla.php b/src/Models/Sla.php new file mode 100644 index 0000000000..728ce69ca0 --- /dev/null +++ b/src/Models/Sla.php @@ -0,0 +1,41 @@ +belongsTo('\App\Models\Entity'); + } + + public function calendar(): BelongsTo + { + return $this->belongsTo('\App\Models\Calendar', 'calendar_id'); + } +} diff --git a/src/Models/Slm.php b/src/Models/Slm.php index 3dea859574..c14e178e4c 100644 --- a/src/Models/Slm.php +++ b/src/Models/Slm.php @@ -17,16 +17,22 @@ class Slm extends Common protected $appends = [ 'calendar', 'entity', + 'slas', + 'olas', ]; protected $visible = [ 'calendar', 'entity', + 'slas', + 'olas', ]; protected $with = [ 'calendar:id,name', - 'entity:id,name', + 'entity:id,name,completename', + 'slas', + 'olas', ]; public function calendar(): BelongsTo @@ -38,4 +44,14 @@ public function entity(): BelongsTo { return $this->belongsTo('\App\Models\Entity'); } + + public function slas(): HasMany + { + return $this->hasMany('\App\Models\Sla', 'slm_id'); + } + + public function olas(): HasMany + { + return $this->hasMany('\App\Models\Ola', 'slm_id'); + } } diff --git a/src/Models/Software.php b/src/Models/Software.php index 6e267b9b50..9e44347db4 100644 --- a/src/Models/Software.php +++ b/src/Models/Software.php @@ -28,6 +28,7 @@ class Software extends Common // 'group', // 'location', 'entity', + 'infocom', ]; protected $visible = [ @@ -50,6 +51,8 @@ class Software extends Common 'tickets', 'problems', 'changes', + 'infocom', + 'reservations', ]; protected $with = [ @@ -57,12 +60,12 @@ class Software extends Common // 'manufacturer:id,name', // // 'nbinstallation.devices', 'versions:id,name', - // 'groupstech:id,name', - // 'userstech:id,name', - // 'user:id,name', - // 'group:id,name', + // 'groupstech:id,name,completename', + // 'userstech:id,name,firstname,lastname', + // 'user:id,name,firstname,lastname', + // 'group:id,name,completename', // 'location:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'domains:id,name', 'appliances:id,name', 'notes:id', @@ -72,6 +75,8 @@ class Software extends Common 'tickets:id,name', 'problems:id,name', 'changes:id,name', + 'infocom', + 'reservations', ]; protected $fillable = [ @@ -223,4 +228,20 @@ public function changes(): MorphToMany 'change_id', ); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } + + public function reservations(): MorphMany + { + return $this->morphMany( + '\App\Models\Reservationitem', + 'item', + ); + } } diff --git a/src/Models/Softwarecategory.php b/src/Models/Softwarecategory.php index 3d84695d92..33c96d9876 100644 --- a/src/Models/Softwarecategory.php +++ b/src/Models/Softwarecategory.php @@ -29,6 +29,6 @@ class Softwarecategory extends Common public function category(): BelongsTo { - return $this->belongsTo('\App\Models\Softwarecategory'); + return $this->belongsTo('\App\Models\Softwarecategory', 'softwarecategory_id'); } } diff --git a/src/Models/Softwarelicense.php b/src/Models/Softwarelicense.php index aaf34051e1..32e5e30570 100644 --- a/src/Models/Softwarelicense.php +++ b/src/Models/Softwarelicense.php @@ -32,6 +32,7 @@ class Softwarelicense extends Common 'certificates', 'notes', 'childs', + 'infocom', ]; protected $visible = [ @@ -56,21 +57,22 @@ class Softwarelicense extends Common 'problems', 'changes', 'childs', + 'infocom', ]; protected $with = [ 'location:id,name', - 'softwarelicensetype:id,name', - 'userstech:id,name', - 'groupstech:id,name', - 'user:id,name', - 'group:id,name', - 'state:id,name', - 'softwareversionsBuy:id,name', - 'softwareversionsUse:id,name', + 'softwarelicensetype', + 'userstech:id,name,firstname,lastname', + 'groupstech:id,name,completename', + 'user:id,name,firstname,lastname', + 'group:id,name,completename', + 'state', + 'softwareversionsBuy', + 'softwareversionsUse', 'manufacturer:id,name', 'software:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'certificates:id,name', 'notes:id', 'knowbaseitems:id,name', @@ -80,6 +82,7 @@ class Softwarelicense extends Common 'problems:id,name', 'changes:id,name', 'childs:id,name', + 'infocom', ]; public function location(): BelongsTo @@ -114,7 +117,7 @@ public function group(): BelongsTo public function state(): BelongsTo { - return $this->belongsTo('\App\Models\State'); + return $this->belongsTo('\App\Models\State', 'state_id'); } public function softwareversionsBuy(): BelongsTo @@ -232,4 +235,12 @@ public function childs(): HasMany { return $this->hasMany('\App\Models\Softwarelicense'); } + + public function infocom(): MorphMany + { + return $this->morphMany( + '\App\Models\Infocom', + 'item', + ); + } } diff --git a/src/Models/Softwarelicensetype.php b/src/Models/Softwarelicensetype.php index ea3684c4d6..0348128cc1 100644 --- a/src/Models/Softwarelicensetype.php +++ b/src/Models/Softwarelicensetype.php @@ -26,7 +26,7 @@ class Softwarelicensetype extends Common protected $with = [ 'softwarelicensetype:id,name', - 'entity:id,name', + 'entity:id,name,completename', ]; public function softwarelicensetype(): BelongsTo diff --git a/src/Models/Softwareversion.php b/src/Models/Softwareversion.php index 1f04a7a6dc..7a5feb71ab 100644 --- a/src/Models/Softwareversion.php +++ b/src/Models/Softwareversion.php @@ -12,6 +12,8 @@ class Softwareversion extends Common use SoftDeletes; protected $definition = '\App\Models\Definitions\Softwareversion'; + protected $titles = ['Software version', 'Software versions']; + protected $icon = 'edit'; protected $appends = [ ]; @@ -30,7 +32,7 @@ class Softwareversion extends Common protected $with = [ 'software:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'state:id,name', 'operatingsystem:id,name', ]; diff --git a/src/Models/Solutiontemplate.php b/src/Models/Solutiontemplate.php index 8242272fd4..2cc512b02e 100644 --- a/src/Models/Solutiontemplate.php +++ b/src/Models/Solutiontemplate.php @@ -26,12 +26,12 @@ class Solutiontemplate extends Common protected $with = [ 'types:id,name', - 'entity:id,name', + 'entity:id,name,completename', ]; public function types(): BelongsTo { - return $this->belongsTo('\App\Models\Solutiontype'); + return $this->belongsTo('\App\Models\Solutiontype', 'solutiontype_id'); } public function entity(): BelongsTo diff --git a/src/Models/Solutiontype.php b/src/Models/Solutiontype.php index 7b7f7da1e5..ed98729744 100644 --- a/src/Models/Solutiontype.php +++ b/src/Models/Solutiontype.php @@ -23,7 +23,7 @@ class Solutiontype extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Models/State.php b/src/Models/State.php index 386a047757..c27e977359 100644 --- a/src/Models/State.php +++ b/src/Models/State.php @@ -26,7 +26,7 @@ class State extends Common protected $with = [ 'state:id,name', - 'entity:id,name', + 'entity:id,name,completename', ]; public function state(): BelongsTo diff --git a/src/Models/Supplier.php b/src/Models/Supplier.php index fc5b205f9e..1a0d7a2438 100644 --- a/src/Models/Supplier.php +++ b/src/Models/Supplier.php @@ -36,7 +36,7 @@ class Supplier extends Common protected $with = [ 'type:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'notes:id', 'knowbaseitems:id,name', 'documents:id,name', diff --git a/src/Models/Tasktemplate.php b/src/Models/Tasktemplate.php index e6deed349d..4aa501bc51 100644 --- a/src/Models/Tasktemplate.php +++ b/src/Models/Tasktemplate.php @@ -10,6 +10,7 @@ class Tasktemplate extends Common protected $definition = '\App\Models\Definitions\Tasktemplate'; protected $titles = ['Task template', 'Task templates']; protected $icon = 'edit'; + protected $hasEntityField = false; protected $appends = [ 'category', @@ -25,8 +26,8 @@ class Tasktemplate extends Common protected $with = [ 'category:id,name', - 'users:id,name', - 'groups:id,name', + 'users:id,name,firstname,lastname', + 'groups:id,name,completename', ]; public function category(): BelongsTo diff --git a/src/Models/Ticket.php b/src/Models/Ticket.php index e1a005b326..5b9dd90e5b 100644 --- a/src/Models/Ticket.php +++ b/src/Models/Ticket.php @@ -31,6 +31,9 @@ class Ticket extends Common 'changes', 'linkedtickets', 'followups', + 'items', + 'projecttasks', + 'approvals', ]; protected $visible = [ @@ -50,17 +53,20 @@ class Ticket extends Common 'knowbaseitems', 'followups', 'costs', + 'items', + 'projecttasks', + 'approvals', ]; protected $with = [ - 'requester', - 'requestergroup', - 'watcher', - 'watchergroup', - 'technician', - 'techniciangroup', - 'usersidlastupdater:id,name', - 'usersidrecipient:id,name', + 'requester:id,name,firstname,lastname', + 'requestergroup:id,name,completename', + 'watcher:id,name,firstname,lastname', + 'watchergroup:id,name,completename', + 'technician:id,name,firstname,lastname', + 'techniciangroup:id,name,completename', + 'usersidlastupdater:id,name,firstname,lastname', + 'usersidrecipient:id,name,firstname,lastname', 'category:id,name', 'location:id,name', 'problems:id,name', @@ -71,6 +77,9 @@ class Ticket extends Common 'followups:id,content', 'solutions', 'costs:id,name,ticket_id,begin_date,end_date,actiontime,cost_time,cost_fixed,cost_material,budget_id,entity_id', + 'items', + 'projecttasks', + 'approvals', ]; // For default values @@ -191,12 +200,12 @@ public function location(): BelongsTo public function problems(): BelongsToMany { - return $this->belongsToMany('\App\Models\Problem'); + return $this->belongsToMany('\App\Models\Problem', 'problem_ticket', 'ticket_id', 'problem_id'); } public function changes(): BelongsToMany { - return $this->belongsToMany('\App\Models\Change'); + return $this->belongsToMany('\App\Models\Change', 'change_ticket', 'ticket_id', 'change_id'); } public function linkedtickets(): BelongsToMany @@ -236,7 +245,9 @@ public function getFeeds($id) ->where('item_id', $id) ->where('is_private', false) ->get(); - } else { + } + else + { $followups = \App\Models\Followup::where('item_type', 'App\Models\Ticket')->where('item_id', $id)->get(); } @@ -365,7 +376,9 @@ public function getFeeds($id) "content" => "", "time" => null, ]; - } else { + } + else + { $groupSpl = explode(" (", $log->old_value); $feeds[] = [ "user" => $userActionSpl[0], @@ -421,4 +434,19 @@ public function costs(): HasMany { return $this->hasMany('App\Models\Ticketcost', 'ticket_id'); } + + public function items(): HasMany + { + return $this->hasMany('\App\Models\ItemTicket', 'ticket_id'); + } + + public function projecttasks(): HasMany + { + return $this->hasMany('\App\Models\ProjecttaskTicket', 'ticket_id'); + } + + public function approvals(): HasMany + { + return $this->hasMany('\App\Models\Ticketvalidation', 'ticket_id'); + } } diff --git a/src/Models/Ticketcost.php b/src/Models/Ticketcost.php index 45cf2b9f1e..18bb9ede29 100644 --- a/src/Models/Ticketcost.php +++ b/src/Models/Ticketcost.php @@ -25,7 +25,7 @@ class Ticketcost extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', 'budget:id,name', ]; diff --git a/src/Models/Ticketrecurrent.php b/src/Models/Ticketrecurrent.php index f9c5c89446..b304dba394 100644 --- a/src/Models/Ticketrecurrent.php +++ b/src/Models/Ticketrecurrent.php @@ -41,16 +41,16 @@ class Ticketrecurrent extends Common ]; protected $with = [ - // 'requester:id,name', - // 'requestergroup:id,name', - // 'watcher:id,name', - // 'watchergroup:id,name', - // 'technician:id,name', - // 'techniciangroup:id,name', - // 'usersidlastupdater:id,name', - // 'usersidrecipient:id,name', + // 'requester:id,name,firstname,lastname', + // 'requestergroup:id,name,completename', + // 'watcher:id,name,firstname,lastname', + // 'watchergroup::id,name,completename', + // 'technician:id,name,firstname,lastname', + // 'techniciangroup:id,name,completename', + // 'usersidlastupdater:id,name,firstname,lastname', + // 'usersidrecipient:id,name,firstname,lastname', // 'itilcategorie:id,name', - 'entity:id,name', + 'entity:id,name,completename', ]; // public function requester() diff --git a/src/Models/Tickettemplate.php b/src/Models/Tickettemplate.php index 9e7b4e4ac3..a830fa0494 100644 --- a/src/Models/Tickettemplate.php +++ b/src/Models/Tickettemplate.php @@ -26,7 +26,7 @@ class Tickettemplate extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', 'mandatoryfields:id,num', 'predefinedfields:id,num,value', 'hiddenfields:id,num', diff --git a/src/Models/Ticketvalidation.php b/src/Models/Ticketvalidation.php new file mode 100644 index 0000000000..7392095981 --- /dev/null +++ b/src/Models/Ticketvalidation.php @@ -0,0 +1,50 @@ +belongsTo('\App\Models\Entity'); + } + + public function usersrequester(): BelongsTo + { + return $this->belongsTo('\App\Models\User', 'user_id'); + } + + public function uservalidate(): BelongsTo + { + return $this->belongsTo('\App\Models\User', 'user_id_validate'); + } +} diff --git a/src/Models/User.php b/src/Models/User.php index 3860ec3f8c..f38765d2ec 100644 --- a/src/Models/User.php +++ b/src/Models/User.php @@ -48,10 +48,10 @@ class User extends Common 'category:id,name', 'title:id,name', 'location:id,name', - 'entity:id,name', + 'entity:id,name,completename', 'profile:id,name', - 'supervisor:id,name', - 'group:id,name', + 'supervisor:id,name,firstname,lastname', + 'group:id,name,completename', 'certificates:id,name', 'defaultgroup:id,name', 'documents:id,name', @@ -127,7 +127,9 @@ public function getCompletenameAttribute() $names[] = $this->lastname; } $name = implode(' ', $names); - } else { + } + else + { $name = $this->name; } return $name; diff --git a/src/Models/Vlan.php b/src/Models/Vlan.php index e6744d52be..007ce74b66 100644 --- a/src/Models/Vlan.php +++ b/src/Models/Vlan.php @@ -23,7 +23,7 @@ class Vlan extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Models/Wifinetwork.php b/src/Models/Wifinetwork.php index f6b0b0f080..536e613259 100644 --- a/src/Models/Wifinetwork.php +++ b/src/Models/Wifinetwork.php @@ -23,7 +23,7 @@ class Wifinetwork extends Common ]; protected $with = [ - 'entity:id,name', + 'entity:id,name,completename', ]; public function entity(): BelongsTo diff --git a/src/Route.php b/src/Route.php index bcf0e43083..a832afd998 100644 --- a/src/Route.php +++ b/src/Route.php @@ -100,11 +100,24 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'contracts', \App\v1\Controllers\Computer::class . ':showSubContracts'); $sub->map(['GET'], 'itil', \App\v1\Controllers\Computer::class . ':showSubItil'); $sub->map(['GET'], 'connections', \App\v1\Controllers\Computer::class . ':showSubConnections'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Computer::class . ':showSubInfocoms'); + $sub->map(['GET'], 'reservations', \App\v1\Controllers\Computer::class . ':showSubReservations'); $sub->map(['GET'], 'history', \App\v1\Controllers\Computer::class . ':showSubHistory'); }); }); }); + $view->group('/computerantivirus', function (RouteCollectorProxy $computerantivirus) + { + $computerantivirus->map(['GET'], '', \App\v1\Controllers\Computerantivirus::class . ':getAll'); + $computerantivirus->map(['POST'], '', \App\v1\Controllers\Computerantivirus::class . ':postItem'); + $computerantivirus->group("/{id:[0-9]+}", function (RouteCollectorProxy $computerantivirusId) + { + $computerantivirusId->map(['GET'], '', \App\v1\Controllers\Computerantivirus::class . ':showItem'); + $computerantivirusId->map(['POST'], '', \App\v1\Controllers\Computerantivirus::class . ':updateItem'); + }); + }); + $view->group('/monitors', function (RouteCollectorProxy $monitors) { $monitors->map(['GET'], '', \App\v1\Controllers\Monitor::class . ':getAll'); @@ -134,11 +147,12 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'operatingsystem', \App\v1\Controllers\Monitor::class . ':showSubOperatingSystem'); $sub->map(['GET'], 'itil', \App\v1\Controllers\Monitor::class . ':showSubItil'); $sub->map(['GET'], 'connections', \App\v1\Controllers\Monitor::class . ':showSubConnections'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Monitor::class . ':showSubInfocoms'); + $sub->map(['GET'], 'reservations', \App\v1\Controllers\Monitor::class . ':showSubReservations'); $sub->map(['GET'], 'history', \App\v1\Controllers\Monitor::class . ':showSubHistory'); }); }); }); - $view->group('/softwares', function (RouteCollectorProxy $softwares) { $softwares->map(['GET'], '', \App\v1\Controllers\Software::class . ':getAll'); @@ -166,11 +180,24 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'contracts', \App\v1\Controllers\Software::class . ':showSubContracts'); $sub->map(['GET'], 'itil', \App\v1\Controllers\Software::class . ':showSubItil'); $sub->map(['GET'], 'versions', \App\v1\Controllers\Software::class . ':showSubVersions'); + $sub->map(['GET'], 'licenses', \App\v1\Controllers\Software::class . ':showSubLicenses'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Software::class . ':showSubInfocoms'); + $sub->map(['GET'], 'softwareinstall', \App\v1\Controllers\Software::class . ':showSubSoftwareInstall'); + $sub->map(['GET'], 'reservations', \App\v1\Controllers\Software::class . ':showSubReservations'); $sub->map(['GET'], 'history', \App\v1\Controllers\Software::class . ':showSubHistory'); }); }); }); - + $view->group('/softwareversions', function (RouteCollectorProxy $softwareversions) + { + $softwareversions->map(['GET'], '', \App\v1\Controllers\Softwareversion::class . ':getAll'); + $softwareversions->map(['POST'], '', \App\v1\Controllers\Softwareversion::class . ':postItem'); + $softwareversions->group("/{id:[0-9]+}", function (RouteCollectorProxy $softwareversionId) + { + $softwareversionId->map(['GET'], '', \App\v1\Controllers\Softwareversion::class . ':showItem'); + $softwareversionId->map(['POST'], '', \App\v1\Controllers\Softwareversion::class . ':updateItem'); + }); + }); $view->group('/networkequipments', function (RouteCollectorProxy $networkequipments) { $networkequipments->map(['GET'], '', \App\v1\Controllers\Networkequipment::class . ':getAll'); @@ -197,6 +224,7 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'knowbaseitems', \App\v1\Controllers\Networkequipment::class . ':showSubKnowbaseitems'); $sub->map(['GET'], 'documents', \App\v1\Controllers\Networkequipment::class . ':showSubDocuments'); $sub->map(['GET'], 'contracts', \App\v1\Controllers\Networkequipment::class . ':showSubContracts'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Networkequipment::class . ':showSubInfocoms'); $sub->map(['GET'], 'softwares', \App\v1\Controllers\Networkequipment::class . ':showSubSoftwares'); $sub->map( ['GET'], @@ -206,6 +234,7 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'itil', \App\v1\Controllers\Networkequipment::class . ':showSubItil'); $sub->map(['GET'], 'components', \App\v1\Controllers\Networkequipment::class . ':showSubComponents'); $sub->map(['GET'], 'volumes', \App\v1\Controllers\Networkequipment::class . ':showSubVolumes'); + $sub->map(['GET'], 'reservations', \App\v1\Controllers\Networkequipment::class . ':showSubReservations'); $sub->map(['GET'], 'history', \App\v1\Controllers\Networkequipment::class . ':showSubHistory'); }); }); @@ -234,6 +263,8 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'itil', \App\v1\Controllers\Peripheral::class . ':showSubItil'); $sub->map(['GET'], 'components', \App\v1\Controllers\Peripheral::class . ':showSubComponents'); $sub->map(['GET'], 'connections', \App\v1\Controllers\Peripheral::class . ':showSubConnections'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Peripheral::class . ':showSubInfocoms'); + $sub->map(['GET'], 'reservations', \App\v1\Controllers\Peripheral::class . ':showSubReservations'); $sub->map(['GET'], 'history', \App\v1\Controllers\Peripheral::class . ':showSubHistory'); }); }); @@ -264,6 +295,8 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'volumes', \App\v1\Controllers\Printer::class . ':showSubVolumes'); $sub->map(['GET'], 'connections', \App\v1\Controllers\Printer::class . ':showSubConnections'); $sub->map(['GET'], 'cartridges', \App\v1\Controllers\Printer::class . ':showSubCartridges'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Printer::class . ':showSubInfocoms'); + $sub->map(['GET'], 'reservations', \App\v1\Controllers\Printer::class . ':showSubReservations'); $sub->map(['GET'], 'history', \App\v1\Controllers\Printer::class . ':showSubHistory'); }); }); @@ -284,6 +317,7 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'documents', \App\v1\Controllers\Cartridgeitem::class . ':showSubDocuments'); $sub->map(['GET'], 'cartridges', \App\v1\Controllers\Cartridgeitem::class . ':showSubCartridges'); $sub->map(['GET'], 'printermodels', \App\v1\Controllers\Cartridgeitem::class . ':showSubPrintermodels'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Cartridgeitem::class . ':showSubInfocoms'); $sub->map(['GET'], 'history', \App\v1\Controllers\Cartridgeitem::class . ':showSubHistory'); }); }); @@ -302,6 +336,7 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'externallinks', \App\v1\Controllers\Consumableitem::class . ':showSubExternalLinks'); $sub->map(['GET'], 'documents', \App\v1\Controllers\Consumableitem::class . ':showSubDocuments'); $sub->map(['GET'], 'consumables', \App\v1\Controllers\Consumableitem::class . ':showSubConsumables'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Consumableitem::class . ':showSubInfocoms'); $sub->map(['GET'], 'history', \App\v1\Controllers\Consumableitem::class . ':showSubHistory'); }); }); @@ -330,6 +365,8 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'components', \App\v1\Controllers\Phone::class . ':showSubComponents'); $sub->map(['GET'], 'volumes', \App\v1\Controllers\Phone::class . ':showSubVolumes'); $sub->map(['GET'], 'connections', \App\v1\Controllers\Phone::class . ':showSubConnections'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Phone::class . ':showSubInfocoms'); + $sub->map(['GET'], 'reservations', \App\v1\Controllers\Phone::class . ':showSubReservations'); $sub->map(['GET'], 'history', \App\v1\Controllers\Phone::class . ':showSubHistory'); }); }); @@ -347,6 +384,7 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'documents', \App\v1\Controllers\Rack::class . ':showSubDocuments'); $sub->map(['GET'], 'contracts', \App\v1\Controllers\Rack::class . ':showSubContracts'); $sub->map(['GET'], 'itil', \App\v1\Controllers\Rack::class . ':showSubItil'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Rack::class . ':showSubInfocoms'); $sub->map(['GET'], 'history', \App\v1\Controllers\Rack::class . ':showSubHistory'); }); }); @@ -365,6 +403,8 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'contracts', \App\v1\Controllers\Enclosure::class . ':showSubContracts'); $sub->map(['GET'], 'itil', \App\v1\Controllers\Enclosure::class . ':showSubItil'); $sub->map(['GET'], 'components', \App\v1\Controllers\Enclosure::class . ':showSubComponents'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Enclosure::class . ':showSubItems'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Enclosure::class . ':showSubInfocoms'); $sub->map(['GET'], 'history', \App\v1\Controllers\Enclosure::class . ':showSubHistory'); }); }); @@ -382,6 +422,8 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'documents', \App\v1\Controllers\Pdu::class . ':showSubDocuments'); $sub->map(['GET'], 'contracts', \App\v1\Controllers\Pdu::class . ':showSubContracts'); $sub->map(['GET'], 'itil', \App\v1\Controllers\Pdu::class . ':showSubItil'); + $sub->map(['GET'], 'plugs', \App\v1\Controllers\Pdu::class . ':showSubPlugs'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Pdu::class . ':showSubInfocoms'); $sub->map(['GET'], 'history', \App\v1\Controllers\Pdu::class . ':showSubHistory'); }); }); @@ -399,6 +441,7 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'documents', \App\v1\Controllers\Passivedcequipment::class . ':showSubDocuments'); $sub->map(['GET'], 'contracts', \App\v1\Controllers\Passivedcequipment::class . ':showSubContracts'); $sub->map(['GET'], 'itil', \App\v1\Controllers\Passivedcequipment::class . ':showSubItil'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Passivedcequipment::class . ':showSubInfocoms'); $sub->map(['GET'], 'history', \App\v1\Controllers\Passivedcequipment::class . ':showSubHistory'); }); }); @@ -415,6 +458,7 @@ public static function setRoutes(&$app) { $sub->map(['GET'], 'documents', \App\v1\Controllers\ItemDevicesimcard::class . ':showSubDocuments'); $sub->map(['GET'], 'contracts', \App\v1\Controllers\ItemDevicesimcard::class . ':showSubContracts'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\ItemDevicesimcard::class . ':showSubInfocoms'); $sub->map(['GET'], 'history', \App\v1\Controllers\ItemDevicesimcard::class . ':showSubHistory'); }); }); @@ -455,6 +499,11 @@ public static function setRoutes(&$app) $sub->map(['POST'], 'problem', \App\v1\Controllers\Ticket::class . ':postProblem'); $sub->map(['GET'], 'knowbaseitems', \App\v1\Controllers\Ticket::class . ':showSubKnowbaseitems'); $sub->map(['GET'], 'costs', \App\v1\Controllers\Ticket::class . ':showSubCosts'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Ticket::class . ':showSubItems'); + $sub->map(['GET'], 'projects', \App\v1\Controllers\Ticket::class . ':showSubProjects'); + $sub->map(['GET'], 'projecttasks', \App\v1\Controllers\Ticket::class . ':showSubProjecttasks'); + $sub->map(['GET'], 'changes', \App\v1\Controllers\Ticket::class . ':showSubChanges'); + $sub->map(['GET'], 'approvals', \App\v1\Controllers\Ticket::class . ':showSubApprovals'); $sub->map(['GET'], 'history', \App\v1\Controllers\Ticket::class . ':showSubHistory'); }); }); @@ -472,6 +521,13 @@ public static function setRoutes(&$app) { $sub->map(['GET'], 'notes', \App\v1\Controllers\Problem::class . ':showSubNotes'); $sub->map(['GET'], 'knowbaseitems', \App\v1\Controllers\Problem::class . ':showSubKnowbaseitems'); + $sub->map(['GET'], 'changes', \App\v1\Controllers\Problem::class . ':showSubChanges'); + $sub->map(['GET'], 'costs', \App\v1\Controllers\Problem::class . ':showSubCosts'); + $sub->map(['GET'], 'projects', \App\v1\Controllers\Problem::class . ':showSubProjects'); + $sub->map(['GET'], 'tickets', \App\v1\Controllers\Problem::class . ':showSubTickets'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Problem::class . ':showSubItems'); + $sub->map(['GET'], 'stats', \App\v1\Controllers\Problem::class . ':showStats'); + $sub->map(['GET'], 'analysis', \App\v1\Controllers\Problem::class . ':showAnalysis'); $sub->map(['GET'], 'history', \App\v1\Controllers\Problem::class . ':showSubHistory'); }); }); @@ -489,6 +545,16 @@ public static function setRoutes(&$app) { $sub->map(['GET'], 'notes', \App\v1\Controllers\Change::class . ':showSubNotes'); $sub->map(['GET'], 'knowbaseitems', \App\v1\Controllers\Change::class . ':showSubKnowbaseitems'); + $sub->map(['GET'], 'costs', \App\v1\Controllers\Change::class . ':showSubCosts'); + $sub->map(['GET'], 'projects', \App\v1\Controllers\Change::class . ':showSubProjects'); + $sub->map(['GET'], 'problem', \App\v1\Controllers\Change::class . ':showProblem'); + $sub->map(['POST'], 'problem', \App\v1\Controllers\Change::class . ':postProblem'); + $sub->map(['GET'], 'tickets', \App\v1\Controllers\Change::class . ':showSubTickets'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Change::class . ':showSubItems'); + $sub->map(['GET'], 'stats', \App\v1\Controllers\Change::class . ':showStats'); + $sub->map(['GET'], 'analysis', \App\v1\Controllers\Change::class . ':showAnalysis'); + $sub->map(['GET'], 'plans', \App\v1\Controllers\Change::class . ':showPlans'); + $sub->map(['GET'], 'approvals', \App\v1\Controllers\Change::class . ':showSubApprovals'); $sub->map(['GET'], 'history', \App\v1\Controllers\Change::class . ':showSubHistory'); }); }); @@ -509,7 +575,6 @@ public static function setRoutes(&$app) }); }); - $view->group('/softwarelicenses', function (RouteCollectorProxy $softwarelicenses) { $softwarelicenses->map(['GET'], '', \App\v1\Controllers\Softwarelicense::class . ':getAll'); @@ -527,6 +592,7 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'contracts', \App\v1\Controllers\Softwarelicense::class . ':showSubContracts'); $sub->map(['GET'], 'itil', \App\v1\Controllers\Softwarelicense::class . ':showSubItil'); $sub->map(['GET'], 'licenses', \App\v1\Controllers\Softwarelicense::class . ':showSubSoftwarelicenses'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Softwarelicense::class . ':showSubInfocoms'); $sub->map(['GET'], 'history', \App\v1\Controllers\Softwarelicense::class . ':showSubHistory'); }); }); @@ -545,6 +611,8 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'externallinks', \App\v1\Controllers\Budget::class . ':showSubExternalLinks'); $sub->map(['GET'], 'knowbaseitems', \App\v1\Controllers\Budget::class . ':showSubKnowbaseitems'); $sub->map(['GET'], 'documents', \App\v1\Controllers\Budget::class . ':showSubDocuments'); + $sub->map(['GET'], 'attacheditems', \App\v1\Controllers\Budget::class . ':showSubAttachedItems'); + $sub->map(['GET'], 'budgetmain', \App\v1\Controllers\Budget::class . ':showSubBudgetMain'); $sub->map(['GET'], 'history', \App\v1\Controllers\Budget::class . ':showSubHistory'); }); }); @@ -566,6 +634,7 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'contracts', \App\v1\Controllers\Supplier::class . ':showSubContracts'); $sub->map(['GET'], 'contacts', \App\v1\Controllers\Supplier::class . ':showSubContacts'); $sub->map(['GET'], 'itil', \App\v1\Controllers\Supplier::class . ':showSubItil'); + $sub->map(['GET'], 'attacheditems', \App\v1\Controllers\Supplier::class . ':showSubAttachedItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Supplier::class . ':showSubHistory'); }); }); @@ -604,6 +673,7 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'documents', \App\v1\Controllers\Contract::class . ':showSubDocuments'); $sub->map(['GET'], 'suppliers', \App\v1\Controllers\Contract::class . ':showSubSuppliers'); $sub->map(['GET'], 'costs', \App\v1\Controllers\Contract::class . ':showSubCosts'); + $sub->map(['GET'], 'attacheditems', \App\v1\Controllers\Contract::class . ':showSubAttachedItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Contract::class . ':showSubHistory'); }); }); @@ -638,6 +708,7 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'notes', \App\v1\Controllers\Line::class . ':showSubNotes'); $sub->map(['GET'], 'documents', \App\v1\Controllers\Line::class . ':showSubDocuments'); $sub->map(['GET'], 'contracts', \App\v1\Controllers\Line::class . ':showSubContracts'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Line::class . ':showSubInfocoms'); $sub->map(['GET'], 'history', \App\v1\Controllers\Line::class . ':showSubHistory'); }); }); @@ -660,6 +731,7 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'domains', \App\v1\Controllers\Certificate::class . ':showSubDomains'); $sub->map(['GET'], 'itil', \App\v1\Controllers\Certificate::class . ':showSubItil'); $sub->map(['GET'], 'associateditems', \App\v1\Controllers\Certificate::class . ':showSubAssociatedItems'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Certificate::class . ':showSubInfocoms'); $sub->map(['GET'], 'history', \App\v1\Controllers\Certificate::class . ':showSubHistory'); }); }); @@ -672,6 +744,30 @@ public static function setRoutes(&$app) { $datacenterId->map(['GET'], '', \App\v1\Controllers\Datacenter::class . ':showItem'); $datacenterId->map(['POST'], '', \App\v1\Controllers\Datacenter::class . ':updateItem'); + $datacenterId->group('/', function (RouteCollectorProxy $sub) + { + $sub->map(['GET'], 'dcrooms', \App\v1\Controllers\Datacenter::class . ':showSubDcrooms'); + $sub->map(['GET'], 'history', \App\v1\Controllers\Datacenter::class . ':showSubHistory'); + }); + }); + }); + $view->group('/dcrooms', function (RouteCollectorProxy $dcrooms) + { + $dcrooms->map(['GET'], '', \App\v1\Controllers\Dcroom::class . ':getAll'); + $dcrooms->map(['POST'], '', \App\v1\Controllers\Dcroom::class . ':postItem'); + $dcrooms->group("/{id:[0-9]+}", function (RouteCollectorProxy $dcroomId) + { + $dcroomId->map(['GET'], '', \App\v1\Controllers\Dcroom::class . ':showItem'); + $dcroomId->map(['POST'], '', \App\v1\Controllers\Dcroom::class . ':updateItem'); + $dcroomId->group('/', function (RouteCollectorProxy $sub) + { + $sub->map(['GET'], 'externallinks', \App\v1\Controllers\Dcroom::class . ':showSubExternalLinks'); + $sub->map(['GET'], 'documents', \App\v1\Controllers\Dcroom::class . ':showSubDocuments'); + $sub->map(['GET'], 'contracts', \App\v1\Controllers\Dcroom::class . ':showSubContracts'); + $sub->map(['GET'], 'itil', \App\v1\Controllers\Dcroom::class . ':showSubItil'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Dcroom::class . ':showSubInfocoms'); + $sub->map(['GET'], 'history', \App\v1\Controllers\Datacenter::class . ':showSubHistory'); + }); }); }); $view->group('/clusters', function (RouteCollectorProxy $clusters) @@ -709,6 +805,8 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'contracts', \App\v1\Controllers\Domain::class . ':showSubContracts'); $sub->map(['GET'], 'records', \App\v1\Controllers\Domain::class . ':showSubRecords'); $sub->map(['GET'], 'itil', \App\v1\Controllers\Domain::class . ':showSubItil'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Domain::class . ':showSubInfocoms'); + $sub->map(['GET'], 'attacheditems', \App\v1\Controllers\Domain::class . ':showSubAttachedItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Domain::class . ':showSubHistory'); }); }); @@ -731,6 +829,7 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'contracts', \App\v1\Controllers\Appliance::class . ':showSubContracts'); $sub->map(['GET'], 'itil', \App\v1\Controllers\Appliance::class . ':showSubItil'); $sub->map(['GET'], 'items', \App\v1\Controllers\Appliance::class . ':showSubItems'); + $sub->map(['GET'], 'infocom', \App\v1\Controllers\Appliance::class . ':showSubInfocoms'); $sub->map(['GET'], 'history', \App\v1\Controllers\Appliance::class . ':showSubHistory'); }); }); @@ -832,6 +931,7 @@ public static function setRoutes(&$app) $sub->map(['GET'], 'tickets', \App\v1\Controllers\User::class . ':showSubItilTicketsCreated'); $sub->map(['GET'], 'problems', \App\v1\Controllers\User::class . ':showSubItilProblems'); $sub->map(['GET'], 'changes', \App\v1\Controllers\User::class . ':showSubItilChanges'); + $sub->map(['GET'], 'reservations', \App\v1\Controllers\User::class . ':showSubReservations'); $sub->map(['GET'], 'history', \App\v1\Controllers\User::class . ':showSubHistory'); }); }); @@ -917,6 +1017,7 @@ public static function setRoutes(&$app) $sub->map(['POST'], 'administration', \App\v1\Controllers\Profile::class . ':itemSubAdministration'); $sub->map(['GET'], 'setup', \App\v1\Controllers\Profile::class . ':showSubSetup'); $sub->map(['POST'], 'setup', \App\v1\Controllers\Profile::class . ':itemSubSetup'); + $sub->map(['GET'], 'users', \App\v1\Controllers\Profile::class . ':showSubUsers'); $sub->map(['GET'], 'history', \App\v1\Controllers\Profile::class . ':showSubHistory'); }); @@ -1174,6 +1275,29 @@ public static function setRoutes(&$app) }); }); }); + $dropdowns->group('/projecttasks', function (RouteCollectorProxy $projecttasks) + { + $projecttasks->map(['GET'], '', \App\v1\Controllers\Projecttask::class . ':getAll'); + $projecttasks->map(['POST'], '', \App\v1\Controllers\Projecttask::class . ':postItem'); + $projecttasks->group("/{id:[0-9]+}", function (RouteCollectorProxy $projecttaskId) + { + $projecttaskId->map(['GET'], '', \App\v1\Controllers\Projecttask::class . ':showItem'); + $projecttaskId->map(['POST'], '', \App\v1\Controllers\Projecttask::class . ':updateItem'); + $projecttaskId->group('/', function (RouteCollectorProxy $sub) + { + $sub->map(['GET'], 'projecttasks', \App\v1\Controllers\Projecttask::class . ':showSubProjecttasks'); + $sub->map( + ['GET'], + 'projecttaskteams', + \App\v1\Controllers\Projecttask::class . ':showSubProjecttaskteams' + ); + $sub->map(['GET'], 'documents', \App\v1\Controllers\Projecttask::class . ':showSubDocuments'); + $sub->map(['GET'], 'notes', \App\v1\Controllers\Projecttask::class . ':showSubNotes'); + $sub->map(['GET'], 'tickets', \App\v1\Controllers\Projecttask::class . ':showSubTickets'); + $sub->map(['GET'], 'history', \App\v1\Controllers\Projecttask::class . ':showSubHistory'); + }); + }); + }); $dropdowns->group('/projecttasktypes', function (RouteCollectorProxy $projecttasktypes) { $projecttasktypes->map(['GET'], '', \App\v1\Controllers\Projecttasktype::class . ':getAll'); @@ -1333,6 +1457,11 @@ public static function setRoutes(&$app) $softwarelicensetypeId->map(['POST'], '', \App\v1\Controllers\Softwarelicensetype::class . ':updateItem'); $softwarelicensetypeId->group('/', function (RouteCollectorProxy $sub) { + $sub->map( + ['GET'], + 'licencetypes', + \App\v1\Controllers\Softwarelicensetype::class . ':showSubLicencetypes' + ); $sub->map(['GET'], 'history', \App\v1\Controllers\Softwarelicensetype::class . ':showSubHistory'); }); }); @@ -2013,6 +2142,11 @@ public static function setRoutes(&$app) $documentcategoryId->map(['POST'], '', \App\v1\Controllers\Documentcategory::class . ':updateItem'); $documentcategoryId->group('/', function (RouteCollectorProxy $sub) { + $sub->map( + ['GET'], + 'categories', + \App\v1\Controllers\Documentcategory::class . ':showSubDocumentcategories' + ); $sub->map(['GET'], 'history', \App\v1\Controllers\Documentcategory::class . ':showSubHistory'); }); }); @@ -2041,6 +2175,11 @@ public static function setRoutes(&$app) $businesscriticityId->map(['POST'], '', \App\v1\Controllers\Businesscriticity::class . ':updateItem'); $businesscriticityId->group('/', function (RouteCollectorProxy $sub) { + $sub->map( + ['GET'], + 'businesscriticities', + \App\v1\Controllers\Businesscriticity::class . ':showSubBusinesscriticities' + ); $sub->map(['GET'], 'history', \App\v1\Controllers\Businesscriticity::class . ':showSubHistory'); }); }); @@ -2055,6 +2194,11 @@ public static function setRoutes(&$app) $knowbaseitemcategoryId->map(['POST'], '', \App\v1\Controllers\Knowbaseitemcategory::class . ':updateItem'); $knowbaseitemcategoryId->group('/', function (RouteCollectorProxy $sub) { + $sub->map( + ['GET'], + 'knowbaseitemcategories', + \App\v1\Controllers\Knowbaseitemcategory::class . ':showSubKnowbaseitemcategories' + ); $sub->map(['GET'], 'history', \App\v1\Controllers\Knowbaseitemcategory::class . ':showSubHistory'); }); }); @@ -2069,6 +2213,8 @@ public static function setRoutes(&$app) $calendarId->map(['POST'], '', \App\v1\Controllers\Calendar::class . ':updateItem'); $calendarId->group('/', function (RouteCollectorProxy $sub) { + $sub->map(['GET'], 'timeranges', \App\v1\Controllers\Calendar::class . ':showSubTimeranges'); + $sub->map(['GET'], 'holidays', \App\v1\Controllers\Calendar::class . ':showSubHolidays'); $sub->map(['GET'], 'history', \App\v1\Controllers\Calendar::class . ':showSubHistory'); }); }); @@ -2297,6 +2443,7 @@ public static function setRoutes(&$app) $domainrelationId->map(['POST'], '', \App\v1\Controllers\Domainrelation::class . ':updateItem'); $domainrelationId->group('/', function (RouteCollectorProxy $sub) { + $sub->map(['GET'], 'domains', \App\v1\Controllers\Domainrelation::class . ':showSubDomains'); $sub->map(['GET'], 'history', \App\v1\Controllers\Domainrelation::class . ':showSubHistory'); }); }); @@ -2325,6 +2472,7 @@ public static function setRoutes(&$app) $ipnetworkId->map(['POST'], '', \App\v1\Controllers\Ipnetwork::class . ':updateItem'); $ipnetworkId->group('/', function (RouteCollectorProxy $sub) { + $sub->map(['GET'], 'vlans', \App\v1\Controllers\Ipnetwork::class . ':showSubVlans'); $sub->map(['GET'], 'history', \App\v1\Controllers\Ipnetwork::class . ':showSubHistory'); }); }); @@ -2339,6 +2487,7 @@ public static function setRoutes(&$app) $fqdnId->map(['POST'], '', \App\v1\Controllers\Fqdn::class . ':updateItem'); $fqdnId->group('/', function (RouteCollectorProxy $sub) { + $sub->map(['GET'], 'networkalias', \App\v1\Controllers\Fqdn::class . ':showSubNetworkalias'); $sub->map(['GET'], 'history', \App\v1\Controllers\Fqdn::class . ':showSubHistory'); }); }); @@ -2367,6 +2516,7 @@ public static function setRoutes(&$app) $networknameId->map(['POST'], '', \App\v1\Controllers\Networkname::class . ':updateItem'); $networknameId->group('/', function (RouteCollectorProxy $sub) { + $sub->map(['GET'], 'networkalias', \App\v1\Controllers\Networkname::class . ':showSubNetworkalias'); $sub->map(['GET'], 'history', \App\v1\Controllers\Networkname::class . ':showSubHistory'); }); }); @@ -2381,6 +2531,11 @@ public static function setRoutes(&$app) $softwarecategoryId->map(['POST'], '', \App\v1\Controllers\Softwarecategory::class . ':updateItem'); $softwarecategoryId->group('/', function (RouteCollectorProxy $sub) { + $sub->map( + ['GET'], + 'softwarecategories', + \App\v1\Controllers\Softwarecategory::class . ':showSubSoftwarecategories' + ); $sub->map(['GET'], 'history', \App\v1\Controllers\Softwarecategory::class . ':showSubHistory'); }); }); @@ -2530,6 +2685,7 @@ public static function setRoutes(&$app) $devicepowersupplyId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Devicepowersupply::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Devicepowersupply::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Devicepowersupply::class . ':showSubHistory'); }); }); @@ -2545,10 +2701,21 @@ public static function setRoutes(&$app) $devicebatteryId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Devicebattery::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Devicebattery::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Devicebattery::class . ':showSubHistory'); }); }); }); + $devices->group('/devicebatterytypes', function (RouteCollectorProxy $devicebatterytypes) + { + $devicebatterytypes->map(['GET'], '', \App\v1\Controllers\Devicebatterytype::class . ':getAll'); + $devicebatterytypes->map(['POST'], '', \App\v1\Controllers\Devicebatterytype::class . ':postItem'); + $devicebatterytypes->group("/{id:[0-9]+}", function (RouteCollectorProxy $devicebatterytypeId) + { + $devicebatterytypeId->map(['GET'], '', \App\v1\Controllers\Devicebatterytype::class . ':showItem'); + $devicebatterytypeId->map(['POST'], '', \App\v1\Controllers\Devicebatterytype::class . ':updateItem'); + }); + }); $devices->group('/devicecases', function (RouteCollectorProxy $devicecases) { $devicecases->map(['GET'], '', \App\v1\Controllers\Devicecase::class . ':getAll'); @@ -2560,6 +2727,7 @@ public static function setRoutes(&$app) $devicecaseId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Devicecase::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Devicecase::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Devicecase::class . ':showSubHistory'); }); }); @@ -2575,6 +2743,7 @@ public static function setRoutes(&$app) $devicesensorId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Devicesensor::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Devicesensor::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Devicesensor::class . ':showSubHistory'); }); }); @@ -2590,6 +2759,7 @@ public static function setRoutes(&$app) $devicesimcardId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Devicesimcard::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Devicesimcard::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Devicesimcard::class . ':showSubHistory'); }); }); @@ -2605,6 +2775,7 @@ public static function setRoutes(&$app) $devicegraphiccardId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Devicegraphiccard::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Devicegraphiccard::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Devicegraphiccard::class . ':showSubHistory'); }); }); @@ -2620,6 +2791,7 @@ public static function setRoutes(&$app) $devicemotherboardId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Devicemotherboard::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Devicemotherboard::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Devicemotherboard::class . ':showSubHistory'); }); }); @@ -2635,6 +2807,7 @@ public static function setRoutes(&$app) $devicenetworkcardId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Devicenetworkcard::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Devicenetworkcard::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Devicenetworkcard::class . ':showSubHistory'); }); }); @@ -2650,6 +2823,7 @@ public static function setRoutes(&$app) $devicesoundcardId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Devicesoundcard::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Devicesoundcard::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Devicesoundcard::class . ':showSubHistory'); }); }); @@ -2665,6 +2839,7 @@ public static function setRoutes(&$app) $devicegenericId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Devicegeneric::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Devicegeneric::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Devicegeneric::class . ':showSubHistory'); }); }); @@ -2680,6 +2855,7 @@ public static function setRoutes(&$app) $devicecontrolId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Devicecontrol::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Devicecontrol::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Devicecontrol::class . ':showSubHistory'); }); }); @@ -2695,6 +2871,7 @@ public static function setRoutes(&$app) $deviceharddriveId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Deviceharddrive::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Deviceharddrive::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Deviceharddrive::class . ':showSubHistory'); }); }); @@ -2710,10 +2887,21 @@ public static function setRoutes(&$app) $devicefirmwareId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Devicefirmware::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Devicefirmware::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Devicefirmware::class . ':showSubHistory'); }); }); }); + $devices->group('/devicefirmwaretypes', function (RouteCollectorProxy $devicefirmwaretypes) + { + $devicefirmwaretypes->map(['GET'], '', \App\v1\Controllers\Devicefirmwaretype::class . ':getAll'); + $devicefirmwaretypes->map(['POST'], '', \App\v1\Controllers\Devicefirmwaretype::class . ':postItem'); + $devicefirmwaretypes->group("/{id:[0-9]+}", function (RouteCollectorProxy $devicefirmwaretypeId) + { + $devicefirmwaretypeId->map(['GET'], '', \App\v1\Controllers\Devicefirmwaretype::class . ':showItem'); + $devicefirmwaretypeId->map(['POST'], '', \App\v1\Controllers\Devicefirmwaretype::class . ':updateItem'); + }); + }); $devices->group('/devicedrives', function (RouteCollectorProxy $devicedrives) { $devicedrives->map(['GET'], '', \App\v1\Controllers\Devicedrive::class . ':getAll'); @@ -2725,6 +2913,7 @@ public static function setRoutes(&$app) $devicedriveId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Devicedrive::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Devicedrive::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Devicedrive::class . ':showSubHistory'); }); }); @@ -2740,6 +2929,7 @@ public static function setRoutes(&$app) $devicememoryId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Devicememory::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Devicememory::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Devicememory::class . ':showSubHistory'); }); }); @@ -2755,6 +2945,7 @@ public static function setRoutes(&$app) $deviceprocessorId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Deviceprocessor::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Deviceprocessor::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Deviceprocessor::class . ':showSubHistory'); }); }); @@ -2770,6 +2961,7 @@ public static function setRoutes(&$app) $devicepciId->group('/', function (RouteCollectorProxy $sub) { $sub->map(['GET'], 'documents', \App\v1\Controllers\Devicepci::class . ':showSubDocuments'); + $sub->map(['GET'], 'items', \App\v1\Controllers\Devicepci::class . ':showSubItems'); $sub->map(['GET'], 'history', \App\v1\Controllers\Devicepci::class . ':showSubHistory'); }); }); @@ -2825,6 +3017,8 @@ public static function setRoutes(&$app) $slmId->map(['POST'], '', \App\v1\Controllers\Slm::class . ':updateItem'); $slmId->group('/', function (RouteCollectorProxy $sub) { + $sub->map(['GET'], 'slas', \App\v1\Controllers\Slm::class . ':showSubSlas'); + $sub->map(['GET'], 'olas', \App\v1\Controllers\Slm::class . ':showSubOlas'); $sub->map(['GET'], 'history', \App\v1\Controllers\Slm::class . ':showSubHistory'); }); }); @@ -2874,6 +3068,7 @@ public static function setRoutes(&$app) $linkId->map(['POST'], '', \App\v1\Controllers\Link::class . ':updateItem'); $linkId->group('/', function (RouteCollectorProxy $sub) { + $sub->map(['GET'], 'associateditemtypes', \App\v1\Controllers\Link::class . ':showSubAssociatedItemType'); $sub->map(['GET'], 'history', \App\v1\Controllers\Link::class . ':showSubHistory'); }); }); diff --git a/src/v1/Controllers/Appliance.php b/src/v1/Controllers/Appliance.php index fc721b697d..adf5765478 100644 --- a/src/v1/Controllers/Appliance.php +++ b/src/v1/Controllers/Appliance.php @@ -10,6 +10,7 @@ final class Appliance extends Common { protected $model = '\App\Models\Appliance'; protected $rootUrl2 = '/appliances/'; + protected $choose = 'appliances'; public function getAll(Request $request, Response $response, $args): Response { @@ -42,31 +43,18 @@ public function showSubItems(Request $request, Response $response, $args): Respo $item2 = new \App\Models\Applianceitem(); $myItem2 = $item2::where('appliance_id', $args['id'])->get(); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/items'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') - { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/items'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myItems = []; foreach ($myItem2 as $appliance_item) { $item3 = new $appliance_item->item_type(); $myItem3 = $item3->find($appliance_item->item_id); - - if ($myItem3 != null) + if ($myItem3 !== null) { - $type = ''; - $name = ''; - $url = ''; - $serial_number = ''; - $inventaire_number = ''; - $relations = []; - - - $type = $item3->getTitle(); + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); $name = $myItem3->name; if ($name == '') @@ -74,48 +62,34 @@ public function showSubItems(Request $request, Response $response, $args): Respo $name = '(' . $myItem3->id . ')'; } - $url = ''; - if ($rootUrl2 != '') - { - $table = $item3->getTable(); - if ($table != '') - { - $url = $rootUrl2 . "/" . $table . "/" . $myItem3->id; - } - } + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem3->id); $serial_number = $myItem3->serial; - $inventaire_number = $myItem3->otherserial; + $inventaire_number = $myItem3->otherserial; + $relations = []; $item4 = new \App\Models\Applianceitemrelation(); $myItem4 = $item4::where('appliance_item_id', $appliance_item->id)->get(); - foreach ($myItem4 as $appliance_item_relation) { $item5 = new $appliance_item_relation->item_type(); $myItem5 = $item5->find($appliance_item_relation->item_id); - - if ($myItem5 != null) + if ($myItem5 !== null) { - $relation_type = $item5->getTitle(); + $relation_type_fr = $item5->getTitle(); + $relation_type = $item5->getTable(); + $relation_name = $myItem5->name; if ($relation_name == '') { $relation_name = '(' . $myItem5->id . ')'; } - $relation_url = ''; - if ($rootUrl2 != '') - { - $table = $item5->getTable(); - if ($table != '') - { - $relation_url = $rootUrl2 . "/" . $table . "/" . $myItem5->id; - } - } + + $relation_url = $this->genereRootUrl2Link($rootUrl2, '/' . $relation_type . '/', $myItem5->id); $relations[] = [ - 'type' => $relation_type, + 'type' => $relation_type_fr, 'name' => $relation_name, 'url' => $relation_url, ]; @@ -123,17 +97,17 @@ public function showSubItems(Request $request, Response $response, $args): Respo } // tri ordre alpha - usort($relations, function ($a, $b) + uasort($relations, function ($a, $b) { return strtolower($a['name']) > strtolower($b['name']); }); - usort($relations, function ($a, $b) + uasort($relations, function ($a, $b) { return strtolower($a['type']) > strtolower($b['type']); }); $myItems[] = [ - 'type' => $type, + 'type' => $type_fr, 'name' => $name, 'url' => $url, 'serial_number' => $serial_number, @@ -144,11 +118,11 @@ public function showSubItems(Request $request, Response $response, $args): Respo } // tri ordre alpha - usort($myItems, function ($a, $b) + uasort($myItems, function ($a, $b) { return strtolower($a['name']) > strtolower($b['name']); }); - usort($myItems, function ($a, $b) + uasort($myItems, function ($a, $b) { return strtolower($a['type']) > strtolower($b['type']); }); @@ -158,7 +132,7 @@ public function showSubItems(Request $request, Response $response, $args): Respo $viewData->addData('fields', $item->getFormData($myItem)); $viewData->addData('items', $myItems); - $viewData->addData('show', 'appliance'); + $viewData->addData('show', $this->choose); $viewData->addTranslation('type', $translator->translate('Item type')); $viewData->addTranslation('name', $translator->translatePlural('Item', 'Items', 1)); diff --git a/src/v1/Controllers/Authldap.php b/src/v1/Controllers/Authldap.php index 38dbdd741e..5f8cacbf8e 100644 --- a/src/v1/Controllers/Authldap.php +++ b/src/v1/Controllers/Authldap.php @@ -34,17 +34,20 @@ public function updateItem(Request $request, Response $response, $args): Respons public static function importUsers(\App\Models\Authldap $ldap, $login) { $connection = new \LdapRecord\Connection([ - 'hosts' => [$ldap->host], - 'port' => (int) $ldap->post, - 'base_dn' => $ldap->basedn, - 'username' => $ldap->rootdn, - 'password' => $ldap->rootdn_passwd, - 'timeout' => 1, + 'hosts' => [$ldap->host], + 'port' => (int) $ldap->post, + 'base_dn' => $ldap->basedn, + 'username' => $ldap->rootdn, + 'password' => $ldap->rootdn_passwd, + 'timeout' => 1, ]); - try { + try + { $connection->connect(); - } catch (\Throwable $e) { + } + catch (\Throwable $e) + { return false; } @@ -70,12 +73,13 @@ public static function tryAuth($authldapId, $userdn, $passowrd) } $connection = new \LdapRecord\Connection([ - 'hosts' => [$authldap->host], - 'port' => (int) $authldap->post, - 'timeout' => 1, + 'hosts' => [$authldap->host], + 'port' => (int) $authldap->post, + 'timeout' => 1, ]); - if ($connection->auth()->attempt($userdn, $passowrd, $stayAuthenticated = true)) { + if ($connection->auth()->attempt($userdn, $passowrd, $stayAuthenticated = true)) + { echo 'FOUND'; return true; } diff --git a/src/v1/Controllers/Authsso.php b/src/v1/Controllers/Authsso.php index 91944df642..7c8c1b4b46 100644 --- a/src/v1/Controllers/Authsso.php +++ b/src/v1/Controllers/Authsso.php @@ -58,7 +58,9 @@ public static function initOptionsForProvider(\App\Models\Authsso $item) { // It's only value $authssooption->value = $option; - } else { + } + else + { $authssooption->key = $key; $authssooption->value = $option; } diff --git a/src/v1/Controllers/Budget.php b/src/v1/Controllers/Budget.php index 748588ad76..0940ff2e10 100644 --- a/src/v1/Controllers/Budget.php +++ b/src/v1/Controllers/Budget.php @@ -4,11 +4,15 @@ use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; +use Slim\Views\Twig; final class Budget extends Common { protected $model = '\App\Models\Budget'; protected $rootUrl2 = '/budgets/'; + protected $choose = 'budgets'; + protected $associateditems_model = '\App\Models\Infocom'; + protected $associateditems_model_id = 'budget_id'; public function getAll(Request $request, Response $response, $args): Response { @@ -27,4 +31,396 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Budget(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubBudgetMain(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $item2 = new $this->associateditems_model(); + $myItem2 = $item2::where($this->associateditems_model_id, $args['id'])->get(); + + $rootUrl = $this->genereRootUrl($request, '/budgetmain'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myBudgetMain = []; + $myBudgetMainType = []; + $total_spent = 0; + $total_remaining = 0; + $total_budget = $myItem->value; + foreach ($myItem2 as $current_attacheditem) + { + $item3 = new $current_attacheditem->item_type(); + $myItem3 = $item3->find($current_attacheditem->item_id); + if ($myItem3 !== null) + { + if ($myItem3->entity !== null) + { + $entity_id = $myItem3->entity->id; + $entity = $myItem3->entity->completename; + $entity_url = ''; + if (array_key_exists($entity_id, $myBudgetMain) !== true) + { + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); + + $myBudgetMain[$entity_id] = [ + 'name' => $entity, + 'entity_url' => $entity_url, + 'items' => [], + 'total' => 0, + ]; + } + + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); + + if (array_key_exists($type, $myBudgetMainType) !== true) + { + $myBudgetMainType[$type] = [ + 'name' => $type_fr, + 'total' => 0, + ]; + } + + if (array_key_exists($type, $myBudgetMain[$entity_id]['items']) !== true) + { + $myBudgetMain[$entity_id]['items'][$type] = [ + 'total' => 0, + ]; + } + + $value = $this->showCosts($current_attacheditem->value); + + $myBudgetMain[$entity_id]['total'] = $myBudgetMain[$entity_id]['total'] + $value; + $myBudgetMainType[$type]['total'] = $myBudgetMainType[$type]['total'] + $value; + + $itemtypetotal = $myBudgetMain[$entity_id]['items'][$type]['total'] + $value; + $myBudgetMain[$entity_id]['items'][$type]['total'] = $itemtypetotal; + } + } + } + + $item2 = new \App\Models\Contractcost(); + $myItem2 = $item2::where('budget_id', $args['id'])->get(); + foreach ($myItem2 as $current_attacheditem) + { + $item3 = new \App\Models\Contract(); + $myItem3 = $item3->find($current_attacheditem->contract_id); + if ($myItem3 !== null) + { + $entity_id = $myItem3->entity->id; + $entity = $myItem3->entity->completename; + if (array_key_exists($entity_id, $myBudgetMain) !== true) + { + $myBudgetMain[$entity_id] = [ + 'name' => $entity, + 'items' => [], + 'total' => 0, + ]; + } + + $type_fr = $translator->translatePlural('Contract', 'Contract', 1); + $type = 'contracts'; + + if (array_key_exists($type, $myBudgetMainType) !== true) + { + $myBudgetMainType[$type] = [ + 'name' => $type_fr, + 'total' => 0, + ]; + } + + if (array_key_exists($type, $myBudgetMain[$entity_id]['items']) !== true) + { + $myBudgetMain[$entity_id]['items'][$type] = [ + 'total' => 0, + ]; + } + + $value = $this->showCosts($current_attacheditem->cost); + + $myBudgetMain[$entity_id]['total'] = $myBudgetMain[$entity_id]['total'] + $value; + $myBudgetMainType[$type]['total'] = $myBudgetMainType[$type]['total'] + $value; + + $itemtypetotal = $myBudgetMain[$entity_id]['items'][$type]['total'] + $value; + $myBudgetMain[$entity_id]['items'][$type]['total'] = $itemtypetotal; + } + } + + $item2 = new \App\Models\Ticketcost(); + $myItem2 = $item2::where('budget_id', $args['id'])->get(); + foreach ($myItem2 as $current_attacheditem) + { + $item3 = new \App\Models\Ticket(); + $myItem3 = $item3->find($current_attacheditem->ticket_id); + if ($myItem3 !== null) + { + $entity_id = $myItem3->entity->id; + $entity = $myItem3->entity->completename; + if (array_key_exists($entity_id, $myBudgetMain) !== true) + { + $myBudgetMain[$entity_id] = [ + 'name' => $entity, + 'items' => [], + 'total' => 0, + ]; + } + + $type_fr = $translator->translatePlural('Ticket', 'Tickets', 1); + $type = 'tickets'; + + if (array_key_exists($type, $myBudgetMainType) !== true) + { + $myBudgetMainType[$type] = [ + 'name' => $type_fr, + 'total' => 0, + ]; + } + + if (array_key_exists($type, $myBudgetMain[$entity_id]['items']) !== true) + { + $myBudgetMain[$entity_id]['items'][$type] = [ + 'total' => 0, + ]; + } + + $value = $this->computeTotalCost( + $current_attacheditem->actiontime, + $current_attacheditem->cost_time, + $current_attacheditem->cost_fixed, + $current_attacheditem->cost_material + ); + + $myBudgetMain[$entity_id]['total'] = $myBudgetMain[$entity_id]['total'] + $value; + $myBudgetMainType[$type]['total'] = $myBudgetMainType[$type]['total'] + $value; + + $itemtypetotal = $myBudgetMain[$entity_id]['items'][$type]['total'] + $value; + $myBudgetMain[$entity_id]['items'][$type]['total'] = $itemtypetotal; + } + } + + $item2 = new \App\Models\Problemcost(); + $myItem2 = $item2::where('budget_id', $args['id'])->get(); + foreach ($myItem2 as $current_attacheditem) + { + $item3 = new \App\Models\Problem(); + $myItem3 = $item3->find($current_attacheditem->problem_id); + if ($myItem3 !== null) + { + $entity_id = $myItem3->entity->id; + $entity = $myItem3->entity->completename; + if (array_key_exists($entity_id, $myBudgetMain) !== true) + { + $myBudgetMain[$entity_id] = [ + 'name' => $entity, + 'items' => [], + 'total' => 0, + ]; + } + + $type_fr = $translator->translatePlural('Problem', 'Problems', 1); + $type = 'problems'; + + if (array_key_exists($type, $myBudgetMainType) !== true) + { + $myBudgetMainType[$type] = [ + 'name' => $type_fr, + 'total' => 0, + ]; + } + + if (array_key_exists($type, $myBudgetMain[$entity_id]['items']) !== true) + { + $myBudgetMain[$entity_id]['items'][$type] = [ + 'total' => 0, + ]; + } + + $value = $this->computeTotalCost( + $current_attacheditem->actiontime, + $current_attacheditem->cost_time, + $current_attacheditem->cost_fixed, + $current_attacheditem->cost_material + ); + + $myBudgetMain[$entity_id]['total'] = $myBudgetMain[$entity_id]['total'] + $value; + $myBudgetMainType[$type]['total'] = $myBudgetMainType[$type]['total'] + $value; + + $itemtypetotal = $myBudgetMain[$entity_id]['items'][$type]['total'] + $value; + $myBudgetMain[$entity_id]['items'][$type]['total'] = $itemtypetotal; + } + } + + $item2 = new \App\Models\Changecost(); + $myItem2 = $item2::where('budget_id', $args['id'])->get(); + foreach ($myItem2 as $current_attacheditem) + { + $item3 = new \App\Models\Change(); + $myItem3 = $item3->find($current_attacheditem->change_id); + if ($myItem3 !== null) + { + $entity_id = $myItem3->entity->id; + $entity = $myItem3->entity->completename; + if (array_key_exists($entity_id, $myBudgetMain) !== true) + { + $myBudgetMain[$entity_id] = [ + 'name' => $entity, + 'items' => [], + 'total' => 0, + ]; + } + + $type_fr = $translator->translatePlural('Change', 'Changes', 1); + $type = 'changes'; + + if (array_key_exists($type, $myBudgetMainType) !== true) + { + $myBudgetMainType[$type] = [ + 'name' => $type_fr, + 'total' => 0, + ]; + } + + if (array_key_exists($type, $myBudgetMain[$entity_id]['items']) !== true) + { + $myBudgetMain[$entity_id]['items'][$type] = [ + 'total' => 0, + ]; + } + + $value = $this->computeTotalCost( + $current_attacheditem->actiontime, + $current_attacheditem->cost_time, + $current_attacheditem->cost_fixed, + $current_attacheditem->cost_material + ); + + $myBudgetMain[$entity_id]['total'] = $myBudgetMain[$entity_id]['total'] + $value; + $myBudgetMainType[$type]['total'] = $myBudgetMainType[$type]['total'] + $value; + + $itemtypetotal = $myBudgetMain[$entity_id]['items'][$type]['total'] + $value; + $myBudgetMain[$entity_id]['items'][$type]['total'] = $itemtypetotal; + } + } + + $item2 = new \App\Models\Projectcost(); + $myItem2 = $item2::where('budget_id', $args['id'])->get(); + foreach ($myItem2 as $current_attacheditem) + { + $item3 = new \App\Models\Project(); + $myItem3 = $item3->find($current_attacheditem->project_id); + if ($myItem3 !== null) + { + $entity_id = $myItem3->entity->id; + $entity = $myItem3->entity->completename; + if (array_key_exists($entity_id, $myBudgetMain) !== true) + { + $myBudgetMain[$entity_id] = [ + 'name' => $entity, + 'items' => [], + 'total' => 0, + ]; + } + + $type_fr = $translator->translatePlural('Project', 'Projects', 1); + $type = 'projects'; + + if (array_key_exists($type, $myBudgetMainType) !== true) + { + $myBudgetMainType[$type] = [ + 'name' => $type_fr, + 'total' => 0, + ]; + } + + if (array_key_exists($type, $myBudgetMain[$entity_id]['items']) !== true) + { + $myBudgetMain[$entity_id]['items'][$type] = [ + 'total' => 0, + ]; + } + + $value = $this->showCosts($current_attacheditem->cost); + + $myBudgetMain[$entity_id]['total'] = $myBudgetMain[$entity_id]['total'] + $value; + $myBudgetMainType[$type]['total'] = $myBudgetMainType[$type]['total'] + $value; + + $itemtypetotal = $myBudgetMain[$entity_id]['items'][$type]['total'] + $value; + $myBudgetMain[$entity_id]['items'][$type]['total'] = $itemtypetotal; + } + } + + // tri par ordre alpha + uasort($myBudgetMainType, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + foreach (array_keys($myBudgetMainType) as $type) + { + foreach (array_keys($myBudgetMain) as $entity_id) + { + if (array_key_exists($type, $myBudgetMain[$entity_id]['items']) !== true) + { + $myBudgetMain[$entity_id]['items'][$type] = [ + 'total' => 0, + ]; + } + else + { + $show_cost = $myBudgetMain[$entity_id]['items'][$type]['total']; + $myBudgetMain[$entity_id]['items'][$type]['total'] = $this->showCosts($show_cost); + } + } + + $myBudgetMainType[$type]['total'] = $this->showCosts($myBudgetMainType[$type]['total']); + + $total_spent = $total_spent + $myBudgetMainType[$type]['total']; + + if (stristr($type, 'consumable')) + { + $myBudgetMainType[$type]['name'] = $myBudgetMainType[$type]['name'] . ' (' . $type . ')'; + } + } + + foreach (array_keys($myBudgetMain) as $entity_id) + { + $myBudgetMain[$entity_id]['total'] = $this->showCosts($myBudgetMain[$entity_id]['total']); + } + + $total_remaining = $total_budget - $total_spent; + $alert_budget = false; + if ($total_remaining < 0) + { + $alert_budget = true; + } + + $total_spent = $this->showCosts($total_spent); + $total_remaining = $this->showCosts($total_remaining); + + $colspan = count($myBudgetMainType) + 1; + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('budgetmain', $myBudgetMain); + $viewData->addData('budgetmaintype', $myBudgetMainType); + $viewData->addData('total_spent', $total_spent); + $viewData->addData('total_remaining', $total_remaining); + $viewData->addData('alert_budget', $alert_budget); + $viewData->addData('colspan', $colspan); + + $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); + $viewData->addTranslation('total', $translator->translate('Total')); + $viewData->addTranslation('total_spent', $translator->translate('Total spent on the budget')); + $viewData->addTranslation('total_remaining', $translator->translate('Total remaining on the budget')); + + return $view->render($response, 'subitem/budgetmain.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Businesscriticity.php b/src/v1/Controllers/Businesscriticity.php index 8d59ad14d9..b020d73c82 100644 --- a/src/v1/Controllers/Businesscriticity.php +++ b/src/v1/Controllers/Businesscriticity.php @@ -6,10 +6,12 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Businesscriticity extends Common { protected $model = '\App\Models\Businesscriticity'; + protected $rootUrl2 = '/dropdowns/businesscriticities/'; public function getAll(Request $request, Response $response, $args): Response { @@ -28,4 +30,69 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Businesscriticity(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubBusinesscriticities(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $item2 = new $this->model(); + $myItem2 = $item2::where('businesscriticity_id', $args['id'])->get(); + + $rootUrl = $this->genereRootUrl($request, '/businesscriticities'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myBusinesscriticities = []; + foreach ($myItem2 as $businesscriticity) + { + $name = $businesscriticity->name; + if ($name == '') + { + $name = '(' . $businesscriticity->id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/businesscriticities/', $businesscriticity->id); + + $entity = ''; + $entity_url = ''; + if ($businesscriticity->entity !== null) + { + $entity = $businesscriticity->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $businesscriticity->entity->id); + } + + $comment = $businesscriticity->comment; + + $myBusinesscriticities[] = [ + 'name' => $name, + 'url' => $url, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'comment' => $comment, + ]; + } + + // tri ordre alpha + uasort($myBusinesscriticities, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('businesscriticities', $myBusinesscriticities); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); + $viewData->addTranslation('comment', $translator->translatePlural('Comment', 'Comments', 2)); + + return $view->render($response, 'subitem/businesscriticities.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Calendar.php b/src/v1/Controllers/Calendar.php index 4e03e1b365..9b4cb3f397 100644 --- a/src/v1/Controllers/Calendar.php +++ b/src/v1/Controllers/Calendar.php @@ -6,10 +6,12 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Calendar extends Common { protected $model = '\App\Models\Calendar'; + protected $rootUrl2 = '/dropdowns/calendars/'; public function getAll(Request $request, Response $response, $args): Response { @@ -28,4 +30,125 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Calendar(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubTimeranges(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/timeranges'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myTimeranges = []; + foreach ($myItem->timeranges as $timeranges) + { + $day = $timeranges->day; + $name = $this->getDaysOfWeekArray()[$day]; + $begin = $timeranges->begin; + $end = $timeranges->end; + + $myTimeranges[] = [ + 'day' => $day, + 'name' => $name, + 'begin' => $begin, + 'end' => $end, + ]; + } + + // tri ordre alpha + uasort($myTimeranges, function ($a, $b) + { + if ($a['day'] == 0) + { + $a['day'] = 7; + } + if ($b['day'] == 0) + { + $b['day'] = 7; + } + + return $a['day'] > $b['day']; + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('timeranges', $myTimeranges); + + $viewData->addTranslation('name', $translator->translatePlural('Day', 'Days', 1)); + $viewData->addTranslation('begin', $translator->translate('Start')); + $viewData->addTranslation('end', $translator->translate('End')); + + return $view->render($response, 'subitem/timeranges.html.twig', (array)$viewData); + } + + public function showSubHolidays(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/holidays'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myHolidays = []; + foreach ($myItem->holidays as $holiday) + { + $name = $holiday->name; + + $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/holidays/', $holiday->id); + + $begin = $holiday->begin_date; + + $end = $holiday->end_date; + + $recurrent = $holiday->recurrent; + if ($recurrent == 1) + { + $recurrent_val = $translator->translate('Yes'); + } + else + { + $recurrent_val = $translator->translate('No'); + } + + $myHolidays[] = [ + 'name' => $name, + 'url' => $url, + 'begin' => $begin, + 'end' => $end, + 'recurrent' => $recurrent, + 'recurrent_val' => $recurrent_val, + ]; + } + + // tri ordre alpha + uasort($myHolidays, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('holidays', $myHolidays); + + $viewData->addTranslation('name', $translator->translatePlural('Day', 'Days', 1)); + $viewData->addTranslation('begin', $translator->translate('Start')); + $viewData->addTranslation('end', $translator->translate('End')); + $viewData->addTranslation('recurrent', $translator->translate('Recurrent')); + + return $view->render($response, 'subitem/holidays.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Cartridgeitem.php b/src/v1/Controllers/Cartridgeitem.php index 4be8c5a09b..c437a680b0 100644 --- a/src/v1/Controllers/Cartridgeitem.php +++ b/src/v1/Controllers/Cartridgeitem.php @@ -41,12 +41,8 @@ public function showSubCartridges(Request $request, Response $response, $args): $myItem = $item::with('cartridges')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/cartridges'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/cartridges'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myCartridges_use = []; $myCartridges_out = []; @@ -54,6 +50,7 @@ public function showSubCartridges(Request $request, Response $response, $args): $total_new = 0; $total_use = 0; $total_out = 0; + $pages = []; foreach ($myItem->cartridges as $cartridge) { $status = ''; @@ -63,37 +60,46 @@ public function showSubCartridges(Request $request, Response $response, $args): $use_on = ''; $url = ''; - - if ($date_end != null) { + if ($date_end !== null) + { $status = $translator->translatePlural('cartridge' . "\004" . 'Worn', 'cartridge' . "\004" . 'Worn', 1); $total_out = $total_out + 1; - } elseif ($date_use != null) { + } + elseif ($date_use !== null) + { $status = $translator->translatePlural('cartridge' . "\004" . 'Used', 'cartridge' . "\004" . 'Used', 1); $total_use = $total_use + 1; - } else { + } + else + { $status = $translator->translatePlural('cartridge' . "\004" . 'New', 'cartridge' . "\004" . 'New', 1); $total_new = $total_new + 1; } $total = $total + 1; - $use_on = ''; - if ($cartridge->printer != null) + $printer_counter = ''; + if ($cartridge->printer !== null) { $use_on = $cartridge->printer->name; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/printers/" . $cartridge->printer->id; - } - } - $printer_counter = 0; // TODO + $url = $this->genereRootUrl2Link($rootUrl2, '/printers/', $cartridge->printer->id); - $printer_counter = sprintf( - $translator->translatePlural('%d printed page', '%d printed pages', $printer_counter), - $printer_counter - ); + if (array_key_exists($cartridge->printer->id, $pages) !== true) + { + $pages[$cartridge->printer->id] = $cartridge->printer->init_pages_counter; + } - if ($cartridge->date_out == null) { + if ($pages[$cartridge->printer->id] < $cartridge->pages) + { + $pp = $cartridge->pages - $pages[$cartridge->printer->id]; + $printer_counter = sprintf($translator->translatePlural('%d printed page', '%d printed pages', $pp), $pp); + $pages[$cartridge->printer->id] = $cartridge->pages; + } + } + + if ($cartridge->date_out == null) + { $myCartridges_use[] = [ 'status' => $status, 'url' => $url, @@ -101,7 +107,9 @@ public function showSubCartridges(Request $request, Response $response, $args): 'date_use' => $date_use, 'use_on' => $use_on, ]; - } else { + } + else + { $myCartridges_out[] = [ 'status' => $status, 'url' => $url, @@ -131,7 +139,6 @@ public function showSubCartridges(Request $request, Response $response, $args): $viewData->addTranslation('date_end', $translator->translate('End date')); $viewData->addTranslation('use_on', $translator->translate('Used on')); $viewData->addTranslation('printer_counter', $translator->translate('Printer counter')); - $viewData->addTranslation('cartridges_use', $translator->translate('Used cartridges')); $viewData->addTranslation('cartridges_out', $translator->translate('Worn cartridges')); $viewData->addTranslation('total', $translator->translate('Total')); @@ -161,22 +168,15 @@ public function showSubPrintermodels(Request $request, Response $response, $args $myItem = $item::with('printermodels')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/printermodels'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/printermodels'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myPrintermodels = []; foreach ($myItem->printermodels as $printermodel) { $name = $printermodel->name; - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/dropdowns/printermodels/" . $printermodel->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/printermodels/', $printermodel->id); $myPrintermodels[$printermodel->id] = [ 'name' => $name, diff --git a/src/v1/Controllers/Category.php b/src/v1/Controllers/Category.php index 42adc890d1..3fda1b5eab 100644 --- a/src/v1/Controllers/Category.php +++ b/src/v1/Controllers/Category.php @@ -47,41 +47,55 @@ public function showSubCategories(Request $request, Response $response, $args): ->where('category_id', $args['id']) ->get(); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/categories'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/categories'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myCategories = []; foreach ($myItem2 as $current_category) { $name = $current_category->name; - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/dropdown/categories/" . $current_category->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/categories/', $current_category->id); $entity = ''; - if ($current_category->entity != null) { - $entity = $current_category->entity->name; + $entity_url = ''; + if ($current_category->entity !== null) + { + $entity = $current_category->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $current_category->entity->id); } $user = ''; - if ($current_category->users != null) { - $user = $current_category->users->name; + $user_url = ''; + if ($current_category->users !== null) + { + $user = $this->genereUserName( + $current_category->users->name, + $current_category->users->lastname, + $current_category->users->firstname, + false + ); + $user_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $current_category->users->id); } $group = ''; - if ($current_category->groups != null) { - $group = $current_category->groups->name; + $group_url = ''; + if ($current_category->groups !== null) + { + $group = $current_category->groups->completename; + $group_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $current_category->groups->id); } $knowbaseitemcategory = ''; - if ($current_category->knowbaseitemcategories != null) { + $knowbaseitemcategory_url = ''; + if ($current_category->knowbaseitemcategories !== null) + { $knowbaseitemcategory = $current_category->knowbaseitemcategories->name; + $knowbaseitemcategory_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/knowbaseitemcategories/', + $current_category->knowbaseitemcategories->id + ); } $visible_simplified_interface = $current_category->is_helpdeskvisible; @@ -135,30 +149,66 @@ public function showSubCategories(Request $request, Response $response, $args): } $template_request = ''; - if ($current_category->tickettemplatesDemand != null) { + $template_request_url = ''; + if ($current_category->tickettemplatesDemand !== null) + { $template_request = $current_category->tickettemplatesDemand->name; + $template_request_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/ticketemplates/', + $current_category->tickettemplatesDemand->id + ); } + $template_incident = ''; - if ($current_category->tickettemplatesIncident != null) { + $template_incident_url = ''; + if ($current_category->tickettemplatesIncident !== null) + { $template_incident = $current_category->tickettemplatesIncident->name; + $template_incident_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/ticketemplates/', + $current_category->tickettemplatesIncident->id + ); } + $template_change = ''; - if ($current_category->changetemplates != null) { + $template_change_url = ''; + if ($current_category->changetemplates !== null) + { $template_change = $current_category->changetemplates->name; + $template_change_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/changetemplates/', + $current_category->changetemplates->id + ); } + $template_problem = ''; - if ($current_category->problemtemplates != null) { + $template_problem_url = ''; + if ($current_category->problemtemplates !== null) + { $template_problem = $current_category->problemtemplates->name; + $template_problem_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/problemtemplates/', + $current_category->problemtemplates->id + ); } + $comment = $current_category->comment; $myCategories[$current_category->id] = [ 'name' => $name, 'url' => $url, 'entity' => $entity, + 'entity_url' => $entity_url, 'user' => $user, + 'user_url' => $user_url, 'group' => $group, + 'group_url' => $group_url, 'knowbaseitemcategory' => $knowbaseitemcategory, + 'knowbaseitemcategory_url' => $knowbaseitemcategory_url, 'visible_simplified_interface' => $visible_simplified_interface, 'visible_simplified_interface_val' => $visible_simplified_interface_val, 'visible_incident' => $visible_incident, @@ -170,9 +220,13 @@ public function showSubCategories(Request $request, Response $response, $args): 'visible_change' => $visible_change, 'visible_change_val' => $visible_change_val, 'template_request' => $template_request, + 'template_request_url' => $template_request_url, 'template_incident' => $template_incident, + 'template_incident_url' => $template_incident_url, 'template_change' => $template_change, + 'template_change_url' => $template_change_url, 'template_problem' => $template_problem, + 'template_problem_url' => $template_problem_url, 'comment' => $comment, ]; } diff --git a/src/v1/Controllers/Certificate.php b/src/v1/Controllers/Certificate.php index 918f417186..27c52688d4 100644 --- a/src/v1/Controllers/Certificate.php +++ b/src/v1/Controllers/Certificate.php @@ -10,6 +10,7 @@ final class Certificate extends Common { protected $model = '\App\Models\Certificate'; protected $rootUrl2 = '/certificates/'; + protected $choose = 'certificates'; protected $associateditems_model = '\App\Models\Certificateitem'; protected $associateditems_model_id = 'certificate_id'; @@ -44,64 +45,91 @@ public function showSubDomains(Request $request, Response $response, $args): Res $item2 = new \App\Models\Domain(); $myItem2 = $item2::with('certificates')->get(); + $rootUrl = $this->genereRootUrl($request, '/domains'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $myDomains = []; foreach ($myItem2 as $domain) { $add_domain = false; - if ($domain->certificates != null) { - foreach ($domain->certificates as $certificate) { - if ($args['id'] == $certificate->id) { + if ($domain->certificates !== null) + { + foreach ($domain->certificates as $certificate) + { + if ($args['id'] == $certificate->id) + { $add_domain = true; break; } } } - if ($add_domain) { + if ($add_domain) + { $entity = ''; + $entity_url = ''; if ($domain->entity !== null) { - $entity = $domain->entity->name; + $entity = $domain->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $domain->entity->id); } + $groupstech = ''; + $groupstech_url = ''; if ($domain->groupstech !== null) { - $groupstech = $domain->groupstech->name; + $groupstech = $domain->groupstech->completename; + $groupstech_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $domain->groupstech->id); } + $userstech = ''; + $userstech_url = ''; if ($domain->userstech !== null) { - $userstech = $domain->userstech->name; + $userstech = $this->genereUserName( + $domain->userstech->name, + $domain->userstech->lastname, + $domain->userstech->firstname + ); + $userstech_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $domain->userstech->id); } + $type = ''; + $type_url = ''; if ($domain->type !== null) { $type = $domain->type->name; + $type_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/domaintypes/', $domain->type->id); } $relation = ''; - $domainrelation = null; + $relation_url = ''; $item3 = new \App\Models\DomainItem(); $myItem3 = $item3::with('relation')->where('domain_id', $domain->id)->get(); - - foreach ($myItem3 as $domainitem) { + foreach ($myItem3 as $domainitem) + { if (($args['id'] == $domainitem->item_id) && ('\\' . $domainitem->item_type == $this->model)) { $domainrelation = \App\Models\Domainrelation::find($domainitem->domainrelation_id); if ($domainrelation !== null) { $relation = $domainrelation->name; + $relation_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/domainrelations/', $domainrelation->id); } } } $alert_expiration = false; $date_expiration = $domain->date_expiration; - if ($date_expiration == null) { + if ($date_expiration == null) + { $date_expiration = $translator->translate("N'expire pas"); - } else { - if ($date_expiration < date('Y-m-d H:i:s')) { + } + else + { + if ($date_expiration < date('Y-m-d H:i:s')) + { $alert_expiration = true; } } @@ -109,10 +137,15 @@ public function showSubDomains(Request $request, Response $response, $args): Res $myDomains[] = [ 'name' => $domain->name, 'entity' => $entity, + 'entity_url' => $entity_url, 'group' => $groupstech, + 'group_url' => $groupstech_url, 'user' => $userstech, + 'user_url' => $userstech_url, 'type' => $type, + 'type_url' => $type_url, 'relation' => $relation, + 'relation_url' => $relation_url, 'date_create' => $domain->created_at, 'date_exp' => $date_expiration, 'alert_expiration' => $alert_expiration, @@ -120,14 +153,12 @@ public function showSubDomains(Request $request, Response $response, $args): Res } } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/domains'); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); $viewData->addData('fields', $item->getFormData($myItem)); $viewData->addData('domains', $myDomains); + $viewData->addData('show', $this->choose); $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); $viewData->addTranslation('group', $translator->translate('Group in charge')); diff --git a/src/v1/Controllers/Change.php b/src/v1/Controllers/Change.php index 284c73c36d..7eee3dfa8b 100644 --- a/src/v1/Controllers/Change.php +++ b/src/v1/Controllers/Change.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Change extends Common { protected $model = '\App\Models\Change'; protected $rootUrl2 = '/changes/'; + protected $choose = 'changes'; public function getAll(Request $request, Response $response, $args): Response { @@ -29,4 +31,236 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Change(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showProblem(Request $request, Response $response, $args) + { + global $translator; + $item = new $this->model(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $item2 = new \App\Models\ChangeProblem(); + $myItem2 = $item2->where(['change_id' => $args['id']])->get(); + + $rootUrl = $this->genereRootUrl($request, '/problem'); + + $problems = []; + foreach ($myItem2 as $problem) + { + $item3 = new \App\Models\Problem(); + $myItem3 = $item3->find($problem->problem_id); + if ($myItem3 !== null) + { + $problems[] = [ + 'id' => $myItem3->id, + 'name' => $myItem3->name, + 'updated_at' => $myItem3->updated_at, + ]; + } + } + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('feeds', $item->getFeeds($args['id'])); + $viewData->addData('content', \App\v1\Controllers\Toolbox::convertMarkdownToHtml($myItem->content)); + $viewData->addData('problems', $problems); + + $viewData->addTranslation('attachItem', $translator->translate('Attach to an existant problem')); + $viewData->addTranslation('selectItem', $translator->translate('Select problem...')); + $viewData->addTranslation('buttonAttach', $translator->translate('Attach')); + $viewData->addTranslation('addItem', $translator->translate('Add new problem')); + $viewData->addTranslation('buttonCreate', $translator->translate('Create')); + $viewData->addTranslation('attachedItems', $translator->translate('Problems attached')); + $viewData->addTranslation('updated', $translator->translate('Last update')); + $viewData->addTranslation('or', $translator->translate('Ou')); + + return $view->render($response, 'subitem/problem.html.twig', (array) $viewData); + } + + public function postProblem(Request $request, Response $response, $args) + { + $data = (object) $request->getParsedBody(); + + if (property_exists($data, 'problem') && is_numeric($data->problem)) + { + $item = new $this->model(); + $myItem = $item::find($args['id']); + $myItem->problems()->attach((int)$data->problem); + + // add message to session + \App\v1\Controllers\Toolbox::addSessionMessage("The ticket has been attached to problem successfully"); + } + else + { + // add message to session + \App\v1\Controllers\Toolbox::addSessionMessage('Error to attache ticket to problem', 'error'); + } + + $uri = $request->getUri(); + header('Location: ' . (string) $uri); + exit(); + } + + public function showSubItems(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/items'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myItems = []; + foreach ($myItem->items as $current_item) + { + $item3 = new $current_item->item_type(); + $myItem3 = $item3->find($current_item->item_id); + if ($myItem3 !== null) + { + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); + + $current_id = $myItem3->id; + + $name = $myItem3->name; + if ($name == '') + { + $name = '(' . $current_id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $current_id); + + $entity = ''; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); + } + + $serial_number = $myItem3->serial; + + $inventaire_number = $myItem3->otherserial; + + $myItems[] = [ + 'type' => $type_fr, + 'name' => $name, + 'url' => $url, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'serial_number' => $serial_number, + 'inventaire_number' => $inventaire_number, + ]; + } + } + + // tri ordre alpha + uasort($myItems, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + uasort($myItems, function ($a, $b) + { + return strtolower($a['type']) > strtolower($b['type']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('items', $myItems); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('type', $translator->translatePlural('Type', 'Types', 1)); + $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('serial_number', $translator->translate('Serial number')); + $viewData->addTranslation('inventaire_number', $translator->translate('Inventory number')); + + return $view->render($response, 'subitem/items.html.twig', (array)$viewData); + } + + public function showAnalysis(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/analysis'); + + $myAnalysis = []; + $myAnalysis = [ + 'impactcontent' => $myItem->impactcontent, + 'controlistcontent' => $myItem->controlistcontent, + ]; + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $getDefs = $item->getSpecificFunction('getDefinitionAnalysis'); + $myItemData = [ + 'impactcontent' => $myAnalysis['impactcontent'], + 'controlistcontent' => $myAnalysis['controlistcontent'], + ]; + $myItemDataObject = json_decode(json_encode($myItemData)); + + $viewData->addData('fields', $item->getFormData($myItemDataObject, $getDefs)); + + $viewData->addTranslation('impactcontent', $translator->translate('Impacts')); + $viewData->addTranslation('controlistcontent', $translator->translate('Control list')); + + return $view->render($response, 'subitem/analysis.html.twig', (array)$viewData); + } + + public function showPlans(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/plans'); + + $myPlans = []; + $myPlans = [ + 'rolloutplancontent' => $myItem->rolloutplancontent, + 'backoutplancontent' => $myItem->backoutplancontent, + 'checklistcontent' => $myItem->checklistcontent, + ]; + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $getDefs = $item->getSpecificFunction('getDefinitionPlans'); + $myItemData = [ + 'rolloutplancontent' => $myPlans['rolloutplancontent'], + 'backoutplancontent' => $myPlans['backoutplancontent'], + 'checklistcontent' => $myPlans['checklistcontent'], + ]; + $myItemDataObject = json_decode(json_encode($myItemData)); + + $viewData->addData('fields', $item->getFormData($myItemDataObject, $getDefs)); + $viewData->addData('show', $this->choose); + $viewData->addData('plans', $myPlans); + + $viewData->addTranslation('rolloutplancontent', $translator->translate('Deployment plan')); + $viewData->addTranslation('backoutplancontent', $translator->translate('Backup plan')); + $viewData->addTranslation('checklistcontent', $translator->translate('Checklist')); + + return $view->render($response, 'subitem/plans.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Cluster.php b/src/v1/Controllers/Cluster.php index e60c3c850f..ad4862cb68 100644 --- a/src/v1/Controllers/Cluster.php +++ b/src/v1/Controllers/Cluster.php @@ -10,6 +10,7 @@ final class Cluster extends Common { protected $model = '\App\Models\Cluster'; protected $rootUrl2 = '/clusters/'; + protected $choose = 'clusters'; public function getAll(Request $request, Response $response, $args): Response { @@ -42,32 +43,25 @@ public function showSubItems(Request $request, Response $response, $args): Respo $item2 = new \App\Models\Clusteritem(); $myItem2 = $item2::where('cluster_id', $args['id'])->get(); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/items'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/items'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myItems = []; - foreach ($myItem2 as $item) + foreach ($myItem2 as $current_item) { - $item3 = new $item->item_type(); - $myItem3 = $item3->find($item->item_id); + $item3 = new $current_item->item_type(); + $myItem3 = $item3->find($current_item->item_id); + if ($myItem3 !== null) + { + $type = $item3->getTable(); - if ($myItem3 != null) { $name = $myItem3->name; - if ($name == '') { + if ($name == '') + { $name = '(' . $myItem3->id . ')'; } - $url = ''; - if ($rootUrl2 != '') { - $table = $item3->getTable(); - if ($table != '') { - $url = $rootUrl2 . "/" . $table . "/" . $myItem3->id; - } - } + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem3->id); $myItems[] = [ 'name' => $name, @@ -77,7 +71,7 @@ public function showSubItems(Request $request, Response $response, $args): Respo } // tri ordre alpha - usort($myItems, function ($a, $b) + uasort($myItems, function ($a, $b) { return strtolower($a['name']) > strtolower($b['name']); }); @@ -87,7 +81,7 @@ public function showSubItems(Request $request, Response $response, $args): Respo $viewData->addData('fields', $item->getFormData($myItem)); $viewData->addData('items', $myItems); - $viewData->addData('show', 'cluster'); + $viewData->addData('show', $this->choose); $viewData->addTranslation('name', $translator->translatePlural('Item', 'Items', 1)); diff --git a/src/v1/Controllers/Common.php b/src/v1/Controllers/Common.php index 9db7ca90e5..413535530d 100644 --- a/src/v1/Controllers/Common.php +++ b/src/v1/Controllers/Common.php @@ -10,10 +10,9 @@ class Common { protected $model = ''; protected $rootUrl2 = ''; - protected $itilchoose = ''; + protected $choose = ''; protected $associateditems_model = ''; protected $associateditems_model_id = ''; - protected $costchoose = ''; protected $MINUTE_TIMESTAMP = '60'; protected $HOUR_TIMESTAMP = '3600'; @@ -21,6 +20,14 @@ class Common protected $WEEK_TIMESTAMP = '604800'; protected $MONTH_TIMESTAMP = '2592000'; + protected $APPROVAL_NONE = 1; + protected $APPROVAL_WAITING = 2; + protected $APPROVAL_ACCEPTED = 3; + protected $APPROVAL_REFUSED = 4; + + protected $TTR = 0; + protected $TTO = 1; + protected function getUrlWithoutQuery(Request $request) { $uri = $request->getUri(); @@ -128,7 +135,9 @@ public function commonUpdateItem(Request $request, Response $response, $args, $i // if (empty($values)) // { // $values = []; - // } else { + // } + // else + // { // $values = explode(',', $values); // } // } @@ -196,7 +205,9 @@ protected function commonShowITILItem(Request $request, Response $response, $arg if (is_null($myItem->content)) { $viewData->addData('content', null); - } else { + } + else + { $viewData->addData('content', \App\v1\Controllers\Toolbox::convertMarkdownToHtml($myItem->content)); } $ctrlFollowup = new \App\v1\Controllers\Followup(); @@ -300,7 +311,7 @@ public function showSubHistory(Request $request, Response $response, $args) $myItem = $item->find($args['id']); $logs = []; - if ($myItem != null) + if ($myItem !== null) { $logs = \App\Models\Log:: where('item_type', ltrim($this->model, '\\')) @@ -384,7 +395,9 @@ public function saveItem($data, $id = null) if ($value == 'on') { $data->{$key} = true; - } else { + } + else + { $data->{$key} = false; } } @@ -392,7 +405,9 @@ public function saveItem($data, $id = null) $aData = $this->filterFieldsAllowedToWrite($this->model, (array) $data); $item = $this->model::create($aData); - } else { + } + else + { // update if (!$this->canRightCreate($this->model)) { @@ -423,7 +438,9 @@ public function saveItem($data, $id = null) if ($value == 'on') { $aData[$key] = true; - } else { + } + else + { $aData[$key] = false; } } @@ -453,7 +470,9 @@ public function saveItem($data, $id = null) if (empty($data->{$key})) { $data->{$key} = []; - } else { + } + else + { $data->{$key} = explode(',', $data->{$key}); } } @@ -481,7 +500,9 @@ public function saveItem($data, $id = null) if (is_null($id)) { \App\v1\Controllers\Toolbox::addSessionMessage('The item has been created successfully'); - } else { + } + else + { \App\v1\Controllers\Toolbox::addSessionMessage('The item has been updated successfully'); } @@ -489,7 +510,9 @@ public function saveItem($data, $id = null) if (is_null($id)) { \App\v1\Controllers\Notification::prepareNotification($item, 'new'); - } else { + } + else + { \App\v1\Controllers\Notification::prepareNotification($item, 'update'); } return $item->id; @@ -505,8 +528,6 @@ protected function getInformationBottom($item, $request) return []; } - - public function showSubNotes(Request $request, Response $response, $args): Response { global $translator; @@ -517,40 +538,47 @@ public function showSubNotes(Request $request, Response $response, $args): Respo $myItem = $item::with('notes')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/notes'); + $myNotes = []; foreach ($myItem->notes as $note) { + $content = str_ireplace("\n", "
", $note->content); + $user = ''; if ($note->user !== null) { - $user = $note->user->name; + $user = $this->genereUserName($note->user->name, $note->user->lastname, $note->user->firstname); } + $user_lastupdater = ''; if ($note->userlastupdater !== null) { - $user_lastupdater = $note->userlastupdater->name; + $user_lastupdater = $this->genereUserName( + $note->userlastupdater->name, + $note->userlastupdater->lastname, + $note->userlastupdater->firstname + ); } $create = sprintf($translator->translate('Create by %1$s on %2$s'), $user, $note->created_at); + $update = sprintf($translator->translate('Last update by %1$s on %2$s'), $user_lastupdater, $note->updated_at); $myNotes[] = [ - 'content' => str_ireplace("\n", "
", $note->content), - 'create' => $create, - 'update' => $update, - 'updated_at' => $note->updated_at, + 'content' => $content, + 'create' => $create, + 'update' => $update, + 'updated_at' => $note->updated_at, ]; } // tri de la + récente à la + ancienne - usort($myNotes, function ($a, $b) + uasort($myNotes, function ($a, $b) { return $a['updated_at'] < $b['updated_at']; }); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/notes'); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -572,42 +600,67 @@ public function showSubDomains(Request $request, Response $response, $args): Res $myItem = $item::with('domains')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/domains'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $myDomains = []; foreach ($myItem->domains as $domain) { $entity = ''; + $entity_url = ''; if ($domain->entity !== null) { - $entity = $domain->entity->name; + $entity = $domain->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $domain->entity->id); } + $groupstech = ''; + $groupstech_url = ''; if ($domain->groupstech !== null) { - $groupstech = $domain->groupstech->name; + $groupstech = $domain->groupstech->completename; + $groupstech_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $domain->groupstech->id); } + $userstech = ''; + $userstech_url = ''; if ($domain->userstech !== null) { - $userstech = $domain->userstech->name; + $userstech = $this->genereUserName( + $domain->userstech->name, + $domain->userstech->lastname, + $domain->userstech->firstname + ); + $userstech_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $domain->userstech->id); } + $type = ''; + $type_url = ''; if ($domain->type !== null) { $type = $domain->type->name; + $type_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/domaintypes/', $domain->type->id); } - $domainrelation = \App\Models\Domainrelation::find($domain->pivot->domainrelation_id); + $relation = ''; + $relation_url = ''; + $domainrelation = \App\Models\Domainrelation::find($domain->pivot->domainrelation_id); if ($domainrelation !== null) { $relation = $domainrelation->name; + $relation_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/domainrelations/', $domainrelation->id); } $alert_expiration = false; $date_expiration = $domain->date_expiration; - if ($date_expiration == null) { + if ($date_expiration == null) + { $date_expiration = $translator->translate("N'expire pas"); - } else { - if ($date_expiration < date('Y-m-d H:i:s')) { + } + else + { + if ($date_expiration < date('Y-m-d H:i:s')) + { $alert_expiration = true; } } @@ -615,10 +668,15 @@ public function showSubDomains(Request $request, Response $response, $args): Res $myDomains[] = [ 'name' => $domain->name, 'entity' => $entity, + 'entity_url' => $entity_url, 'group' => $groupstech, + 'group_url' => $groupstech_url, 'user' => $userstech, + 'user_url' => $userstech_url, 'type' => $type, + 'type_url' => $type_url, 'relation' => $relation, + 'relation_url' => $relation_url, 'date_create' => $domain->created_at, 'date_exp' => $date_expiration, 'alert_expiration' => $alert_expiration, @@ -633,6 +691,7 @@ public function showSubDomains(Request $request, Response $response, $args): Res $viewData->addData('fields', $item->getFormData($myItem)); $viewData->addData('domains', $myDomains); + $viewData->addData('show', $this->choose); $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); $viewData->addTranslation('group', $translator->translate('Group in charge')); @@ -655,17 +714,20 @@ public function showSubAppliances(Request $request, Response $response, $args): $myItem = $item::with('appliances')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/appliances'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $myAppliances = []; foreach ($myItem->appliances as $appliance) { + $appliance_url = $this->genereRootUrl2Link($rootUrl2, '/appliances/', $appliance->id); + $myAppliances[] = [ - 'name' => $appliance->name, + 'name' => $appliance->name, + 'url' => $appliance_url, ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/appliances'); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -687,52 +749,66 @@ public function showSubCertificates(Request $request, Response $response, $args) $myItem = $item::with('certificates')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/certificates'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $myCertificates = []; foreach ($myItem->certificates as $certificate) { $type = ''; + $type_url = ''; if ($certificate->type !== null) { $type = $certificate->type->name; + $type_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/certificatetypes/', $certificate->type->id); } + $entity = ''; + $entity_url = ''; if ($certificate->entity !== null) { - $entity = $certificate->entity->name; + $entity = $certificate->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $certificate->entity->id); } $alert_expiration = false; $date_expiration = $certificate->date_expiration; - if ($date_expiration == null) { + if ($date_expiration == null) + { $date_expiration = $translator->translate("N'expire pas"); - } else { - if ($date_expiration < date('Y-m-d H:i:s')) { + } + else + { + if ($date_expiration < date('Y-m-d H:i:s')) + { $alert_expiration = true; } } + $state = ''; + $state_url = ''; if ($certificate->state !== null) { $state = $certificate->state->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $certificate->state->id); } - $myCertificates[] = [ 'name' => $certificate->name, 'entity' => $entity, + 'entity_url' => $entity_url, 'type' => $type, + 'type_url' => $type_url, 'dns_name' => $certificate->dns_name, 'dns_suffix' => $certificate->dns_suffix, 'created_at' => $certificate->created_at, 'date_expiration' => $date_expiration, 'alert_expiration' => $alert_expiration, 'state' => $state, + 'state_url' => $state_url, ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/certificates'); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -769,6 +845,8 @@ public function showSubExternalLinks(Request $request, Response $response, $args $item3 = new \App\Models\DomainItem(); $domainitems = $item3->where(['item_id' => $args['id'], 'item_type' => $computermodelclass])->get(); + $rootUrl = $this->genereRootUrl($request, '/externallinks'); + $myExternalLinks = []; foreach ($externallinks as $externallink) { @@ -777,17 +855,20 @@ public function showSubExternalLinks(Request $request, Response $response, $args $link = ''; $data = ''; $generate = ''; + if ($externallink->links !== null) { $name = $externallink->links->name; + $open_window = $externallink->links->open_window; + $link = $externallink->links->link; - $data = $externallink->links->data; + $data = $externallink->links->data; $location_id = ''; $location_name = ''; - if ($myItem->location != null) + if ($myItem->location !== null) { $location_id = $myItem->location->id; $location_name = $myItem->location->name; @@ -796,42 +877,52 @@ public function showSubExternalLinks(Request $request, Response $response, $args $domains = []; foreach ($domainitems as $domainitem) { - if ($domainitem->domain != null) + if ($domainitem->domain !== null) { $domains[] = $domainitem->domain->name; } } $network_name = ''; - if ($myItem->network != null) + if ($myItem->network !== null) { $network_name = $myItem->network->name; } - $users = ''; - if ($myItem->user != null) + $users = []; + if ($myItem->user !== null) { - if (isset($myItem->user->name)) { - $users[] = $myItem->user->name; - } else { - foreach ($myItem->user as $user) { - $users[] = $user->name; + if (isset($myItem->user->name)) + { + $users[] = $this->genereUserName($myItem->user->name, $myItem->user->lastname, $myItem->user->firstname); + } + else + { + foreach ($myItem->user as $user) + { + $users[] = $this->genereUserName($user->name, $user->lastname, $user->firstname); } } } + $groups = []; - if ($myItem->group != null) + if ($myItem->group !== null) { - if (isset($myItem->group->name)) { + if (isset($myItem->group->name)) + { $groups[] = $myItem->group->name; - } else { - foreach ($myItem->group as $group) { + } + else + { + foreach ($myItem->group as $group) + { $groups[] = $group->name; } } } $ips = []; + $macs = []; $itemsLink = [ @@ -856,7 +947,6 @@ public function showSubExternalLinks(Request $request, Response $response, $args $generate = $name . ' : ' . self::generateLinkContents($data, $itemsLink, true); } - $myExternalLinks[] = [ 'name' => $name, 'open_window' => $open_window, @@ -865,9 +955,6 @@ public function showSubExternalLinks(Request $request, Response $response, $args ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/externallinks'); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -975,7 +1062,9 @@ private function checkAndReplaceProperty($item, $field, $strToReplace, $new_link $tmp = $tmp . $val; } $ret = str_replace($strToReplace, $tmp, $ret); - } else { + } + else + { $ret = str_replace($strToReplace, $item[$field], $ret); } if ($replaceByBr === true) @@ -997,22 +1086,13 @@ public function showSubKnowbaseitems(Request $request, Response $response, $args $myItem = $item::with('knowbaseitems')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/knowbaseitems'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') - { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/knowbaseitems'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myKnowbaseitems = []; foreach ($myItem->knowbaseitems as $knowbaseitem) { - $url = ''; - if ($rootUrl2 != '') - { - $url = $rootUrl2 . "/knowbaseitems/" . $knowbaseitem->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/knowbaseitems/', $knowbaseitem->id); $myKnowbaseitems[$knowbaseitem->id] = [ 'name' => $knowbaseitem->name, @@ -1045,49 +1125,51 @@ public function showSubDocuments(Request $request, Response $response, $args): R $myItem = $item::with('documents')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/documents'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/documents'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myDocuments = []; foreach ($myItem->documents as $document) { - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/documents/" . $document->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); $entity = ''; - if ($document->entity != null) + $entity_url = ''; + if ($document->entity !== null) { - $entity = $document->entity->name; + $entity = $document->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $document->entity->id); } $rubrique = ''; - if ($document->categorie != null) + $rubrique_url = ''; + if ($document->categorie !== null) { $rubrique = $document->categorie->name; + $rubrique_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/documentcategories/', + $document->categorie->id + ); } - $myDocuments[$document->id] = [ - 'name' => $document->name, - 'date' => $document->pivot->updated_at, - 'url' => $url, - 'entity' => $entity, - 'file' => $document->filename, - 'weblink' => $document->link, - 'rubrique' => $rubrique, - 'mimetype' => $document->mime, - 'balise' => $document->tag, + 'name' => $document->name, + 'date' => $document->pivot->updated_at, + 'url' => $url, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'file' => $document->filename, + 'weblink' => $document->link, + 'rubrique' => $rubrique, + 'rubrique_url' => $rubrique_url, + 'mimetype' => $document->mime, + 'balise' => $document->tag, ]; } // tri de la + récente à la + ancienne - usort($myDocuments, function ($a, $b) + uasort($myDocuments, function ($a, $b) { return $a['date'] < $b['date']; }); @@ -1120,39 +1202,40 @@ public function showSubContracts(Request $request, Response $response, $args): R $myItem = $item::with('contracts')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/contracts'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/contracts'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myContracts = []; foreach ($myItem->contracts as $contract) { - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/contracts/" . $contract->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/contracts/', $contract->id); $entity = ''; - if ($contract->entity != null) + $entity_url = ''; + if ($contract->entity !== null) { - $entity = $contract->entity->name; + $entity = $contract->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $contract->entity->id); } $type = ''; - if ($contract->type != null) + $contracttype_url = ''; + if ($contract->type !== null) { $type = $contract->type->name; + $contracttype_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/contracttypes/', $contract->type->id); } $suppliers = []; - if ($contract->suppliers != null) + if ($contract->suppliers !== null) { - foreach ($contract->suppliers as $supplier) { + foreach ($contract->suppliers as $supplier) + { + $supplier_url = $this->genereRootUrl2Link($rootUrl2, '/suppliers/', $supplier->id); + $suppliers[$supplier->id] = [ 'name' => $supplier->name, + 'url' => $supplier_url, ]; } } @@ -1167,12 +1250,14 @@ public function showSubContracts(Request $request, Response $response, $args): R $initial_contract_period = sprintf($translator->translatePlural('%d month', '%d months', $duration), $duration); } - if ($contract->begin_date != null) { + if ($contract->begin_date !== null) + { $ladate = $contract->begin_date; if ($duration != 0) { $end_date = date('Y-m-d', strtotime('+' . $duration . ' month', strtotime($ladate))); - if ($end_date < date('Y-m-d')) { + if ($end_date < date('Y-m-d')) + { $end_date = "" . $end_date . ""; } $initial_contract_period = $initial_contract_period . ' => ' . $end_date; @@ -1183,8 +1268,10 @@ public function showSubContracts(Request $request, Response $response, $args): R 'name' => $contract->name, 'url' => $url, 'entity' => $entity, + 'entity_url' => $entity_url, 'number' => $contract->num, 'type' => $type, + 'contracttype_url' => $contracttype_url, 'suppliers' => $suppliers, 'start_date' => $contract->begin_date, 'initial_contract_period' => $initial_contract_period, @@ -1192,12 +1279,11 @@ public function showSubContracts(Request $request, Response $response, $args): R } // tri de la + récente à la + ancienne - usort($myContracts, function ($a, $b) + uasort($myContracts, function ($a, $b) { return strtolower($a['name']) > strtolower($b['name']); }); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -1226,38 +1312,37 @@ public function showSubSuppliers(Request $request, Response $response, $args): R $myItem = $item::with('suppliers')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/suppliers'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/suppliers'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $mySuppliers = []; foreach ($myItem->suppliers as $supplier) { - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/suppliers/" . $supplier->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/suppliers/', $supplier->id); $entity = ''; - if ($supplier->entity != null) + $entity_url = ''; + if ($supplier->entity !== null) { - $entity = $supplier->entity->name; + $entity = $supplier->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $supplier->entity->id); } $type = ''; - if ($supplier->type != null) + $type_url = ''; + if ($supplier->type !== null) { $type = $supplier->type->name; + $type_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/suppliertypes/', $supplier->type->id); } $mySuppliers[$supplier->id] = [ 'name' => $supplier->name, 'url' => $url, 'entity' => $entity, + 'entity_url' => $entity_url, 'type' => $type, + 'type_url' => $type_url, 'phone' => $supplier->phonenumber, 'fax' => $supplier->fax, 'website' => $supplier->website, @@ -1265,12 +1350,11 @@ public function showSubSuppliers(Request $request, Response $response, $args): R } // tri de la + récente à la + ancienne - usort($mySuppliers, function ($a, $b) + uasort($mySuppliers, function ($a, $b) { return strtolower($a['name']) > strtolower($b['name']); }); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -1297,24 +1381,28 @@ public function showSubSoftwares(Request $request, Response $response, $args): R $myItem = $item::with('softwareversions')->find($args['id']); - $myAntiviruses = []; + $rootUrl = $this->genereRootUrl($request, '/softwares'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $softwares = []; foreach ($myItem->softwareversions as $softwareversion) { + $softwareversion_url = $this->genereRootUrl2Link($rootUrl2, '/softwareversions/', $softwareversion->id); + + $software_url = $this->genereRootUrl2Link($rootUrl2, '/softwares/', $softwareversion->software->id); + $softwares[] = [ - 'id' => $softwareversion->id, - 'name' => $softwareversion->name, - 'software' => [ - 'id' => $softwareversion->software->id, - 'name' => $softwareversion->software->name, + 'id' => $softwareversion->id, + 'name' => $softwareversion->name, + 'url' => $softwareversion_url, + 'software' => [ + 'id' => $softwareversion->software->id, + 'name' => $softwareversion->software->name, + 'url' => $software_url, ] ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/softwares'); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -1338,6 +1426,9 @@ public function showSubOperatingSystem(Request $request, Response $response, $ar $myItem = $item::with('operatingsystems')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/operatingsystem'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $operatingsystem = []; foreach ($myItem->operatingsystems as $os) { @@ -1416,70 +1507,67 @@ public function showSubOperatingSystem(Request $request, Response $response, $ar } $operatingsystem = [ - 'id' => $os->id, - 'name' => $os->name, - 'architecture' => $architecture, - 'architecture_id' => $os->pivot->operatingsystemarchitecture_id, - 'version' => $version, - 'version_id' => $os->pivot->operatingsystemversion_id, - 'servicepack' => $servicepack, - 'servicepack_id' => $os->pivot->operatingsystemservicepack_id, - 'kernelversion' => $kernelversion, - 'kernelversion_id' => $os->pivot->operatingsystemkernelversion_id, - 'edition' => $edition, - 'edition_id' => $os->pivot->operatingsystemedition_id, - 'licensenumber' => $license_number, - 'licenseid' => $licenseid, - 'installationdate' => $installationdate, - 'winowner' => $winowner, - 'wincompany' => $wincompany, - 'oscomment' => $oscomment, - 'hostid' => $hostid, + 'id' => $os->id, + 'name' => $os->name, + 'architecture' => $architecture, + 'architecture_id' => $os->pivot->operatingsystemarchitecture_id, + 'version' => $version, + 'version_id' => $os->pivot->operatingsystemversion_id, + 'servicepack' => $servicepack, + 'servicepack_id' => $os->pivot->operatingsystemservicepack_id, + 'kernelversion' => $kernelversion, + 'kernelversion_id' => $os->pivot->operatingsystemkernelversion_id, + 'edition' => $edition, + 'edition_id' => $os->pivot->operatingsystemedition_id, + 'licensenumber' => $license_number, + 'licenseid' => $licenseid, + 'installationdate' => $installationdate, + 'winowner' => $winowner, + 'wincompany' => $wincompany, + 'oscomment' => $oscomment, + 'hostid' => $hostid, ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/operatingsystem'); - $show = ''; - if ($this->rootUrl2 != '') { + if ($this->rootUrl2 != '') + { $show = str_ireplace('/', '', $this->rootUrl2); } $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); - $getDef = []; - $myItemData = []; - - $getDefs = $item->getSpecificFunction('getDefinitionOperatingSystem'); - - $myItemData = [ - 'name' => $operatingsystem['name'], - 'architecture' => [ - 'id' => $operatingsystem['architecture_id'], - 'name' => $operatingsystem['architecture'], - ], - 'kernelversion' => [ - 'id' => $operatingsystem['kernelversion_id'], - 'name' => $operatingsystem['kernelversion'], - ], - 'version' => [ - 'id' => $operatingsystem['version_id'], - 'name' => $operatingsystem['version'], - ], - 'servicepack' => [ - 'id' => $operatingsystem['servicepack_id'], - 'name' => $operatingsystem['servicepack'], - ], - 'edition' => [ - 'id' => $operatingsystem['edition_id'], - 'name' => $operatingsystem['edition'], - ], - 'licenseid' => $operatingsystem['licenseid'], - 'licensenumber' => $operatingsystem['licensenumber'], - ]; + $myItemData = []; + if (count($operatingsystem) > 0) + { + $myItemData = [ + 'name' => $operatingsystem['name'], + 'architecture' => [ + 'id' => $operatingsystem['architecture_id'], + 'name' => $operatingsystem['architecture'], + ], + 'kernelversion' => [ + 'id' => $operatingsystem['kernelversion_id'], + 'name' => $operatingsystem['kernelversion'], + ], + 'version' => [ + 'id' => $operatingsystem['version_id'], + 'name' => $operatingsystem['version'], + ], + 'servicepack' => [ + 'id' => $operatingsystem['servicepack_id'], + 'name' => $operatingsystem['servicepack'], + ], + 'edition' => [ + 'id' => $operatingsystem['edition_id'], + 'name' => $operatingsystem['edition'], + ], + 'licenseid' => $operatingsystem['licenseid'], + 'licensenumber' => $operatingsystem['licensenumber'], + ]; + } $myItemDataObject = json_decode(json_encode($myItemData)); $viewData->addData('fields', $item->getFormData($myItemDataObject, $getDefs)); @@ -1505,187 +1593,336 @@ public function showSubItil(Request $request, Response $response, $args): Respon $myItem = $item::with('tickets', 'problems', 'changes')->find($args['id']); - - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/itil'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/itil'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $tickets = []; foreach ($myItem->tickets as $ticket) { - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/tickets/" . $ticket->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/tickets/', $ticket->id); $status = $this->getStatusArray()[$ticket->status]; + $entity = ''; - if ($ticket->entity != null) { - $entity = $ticket->entity->name; + $entity_url = ''; + if ($ticket->entity !== null) + { + $entity = $ticket->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $ticket->entity->id); } + $priority = $this->getPriorityArray()[$ticket->priority]; + $requesters = []; - if ($ticket->requester != null) { - foreach ($ticket->requester as $requester) { - $requesters[] = ['name' => $requester->name]; + if ($ticket->requester !== null) + { + foreach ($ticket->requester as $requester) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $requester->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $this->genereUserName($requester->name, $requester->lastname, $requester->firstname), + ]; } } - if ($ticket->requestergroup != null) { - foreach ($ticket->requestergroup as $requestergroup) { - $requesters[] = ['name' => $requestergroup->completename]; + if ($ticket->requestergroup !== null) + { + foreach ($ticket->requestergroup as $requestergroup) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $requestergroup->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $requestergroup->completename, + ]; } } + $technicians = []; - if ($ticket->technician != null) { - foreach ($ticket->technician as $technician) { - $technicians[] = ['name' => $technician->name]; + if ($ticket->technician !== null) + { + foreach ($ticket->technician as $technician) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $technician->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $this->genereUserName($technician->name, $technician->lastname, $technician->firstname), + ]; + } + } + if ($ticket->techniciangroup !== null) + { + foreach ($ticket->techniciangroup as $techniciangroup) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $techniciangroup->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $techniciangroup->completename, + ]; } } - if ($ticket->techniciangroup != null) { - foreach ($ticket->techniciangroup as $techniciangroup) { - $technicians[] = ['name' => $techniciangroup->completename]; + + $associated_items = []; + $item4 = new \App\Models\ItemTicket(); + $myItem4 = $item4::where('ticket_id', $ticket->id)->get(); + if ($myItem4 !== null) + { + foreach ($myItem4 as $val) + { + $item5 = new $val->item_type(); + $myItem5 = $item5->find($val->item_id); + if ($myItem5 !== null) + { + $type5_fr = $item5->getTitle(); + $type5 = $item5->getTable(); + + $name5 = $myItem5->name; + + $url5 = $this->genereRootUrl2Link($rootUrl2, '/' . $type5 . '/', $myItem5->id); + + if ($type5_fr != '') + { + $type5_fr = $type5_fr . ' - '; + } + + $associated_items[] = [ + 'type' => $type5_fr, + 'name' => $name5, + 'url' => $url5, + ]; + } + } + + if (empty($associated_items)) + { + $associated_items[] = [ + 'type' => '', + 'name' => $translator->translate('General'), + 'url' => '', + ]; } } - $associated_items = []; // TODO + $category = ''; - if ($ticket->category != null) { + $category_url = ''; + if ($ticket->category !== null) + { $category = $ticket->category->name; + $category_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/categories/', $ticket->category->id); } - $planification = 0; // TODO + $planification = 0; // TODO $tickets[$ticket->id] = [ - 'url' => $url, - 'status' => $status, - 'date' => $ticket->date, - 'last_update' => $ticket->updated_at, - 'entity' => $entity, - 'priority' => $priority, - 'requesters' => $requesters, - 'technicians' => $technicians, - 'associated_items' => $associated_items, - 'title' => $ticket->name, - 'category' => $category, - 'planification' => $planification, + 'url' => $url, + 'status' => $status, + 'date' => $ticket->date, + 'last_update' => $ticket->updated_at, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'priority' => $priority, + 'requesters' => $requesters, + 'technicians' => $technicians, + 'associated_items' => $associated_items, + 'title' => $ticket->name, + 'category' => $category, + 'category_url' => $category_url, + 'planification' => $planification, ]; } $problems = []; foreach ($myItem->problems as $problem) { - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/problems/" . $problem->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/problems/', $problem->id); $status = $this->getStatusArray()[$problem->status]; + $entity = ''; - if ($problem->entity != null) { - $entity = $problem->entity->name; + $entity_url = ''; + if ($problem->entity !== null) + { + $entity = $problem->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $problem->entity->id); } + $priority = $this->getPriorityArray()[$problem->priority]; + $requesters = []; - if ($problem->requester != null) { - foreach ($problem->requester as $requester) { - $requesters[] = ['name' => $requester->name]; + if ($problem->requester !== null) + { + foreach ($problem->requester as $requester) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $requester->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $this->genereUserName($requester->name, $requester->lastname, $requester->firstname), + ]; } } - if ($problem->requestergroup != null) { - foreach ($problem->requestergroup as $requestergroup) { - $requesters[] = ['name' => $requestergroup->completename]; + if ($problem->requestergroup !== null) + { + foreach ($problem->requestergroup as $requestergroup) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $requestergroup->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $requestergroup->completename, + ]; } } + $technicians = []; - if ($problem->technician != null) { - foreach ($problem->technician as $technician) { - $technicians[] = ['name' => $technician->name]; + if ($problem->technician !== null) + { + foreach ($problem->technician as $technician) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $technician->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $this->genereUserName($technician->name, $technician->lastname, $technician->firstname), + ]; } } - if ($problem->techniciangroup != null) { - foreach ($problem->techniciangroup as $techniciangroup) { - $technicians[] = ['name' => $techniciangroup->completename]; + if ($problem->techniciangroup !== null) + { + foreach ($problem->techniciangroup as $techniciangroup) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $techniciangroup->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $techniciangroup->completename, + ]; } } + $category = ''; - if ($problem->category != null) { + $category_url = ''; + if ($problem->category !== null) + { $category = $problem->category->name; + $category_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/categories/', $problem->category->id); } - $planification = 0; // TODO + $planification = 0; // TODO $problems[$problem->id] = [ - 'url' => $url, - 'status' => $status, - 'date' => $problem->date, - 'last_update' => $problem->updated_at, - 'entity' => $entity, - 'priority' => $priority, - 'requesters' => $requesters, - 'technicians' => $technicians, - 'title' => $problem->name, - 'category' => $category, - 'planification' => $planification, + 'url' => $url, + 'status' => $status, + 'date' => $problem->date, + 'last_update' => $problem->updated_at, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'priority' => $priority, + 'requesters' => $requesters, + 'technicians' => $technicians, + 'title' => $problem->name, + 'category' => $category, + 'category_url' => $category_url, + 'planification' => $planification, ]; } $changes = []; foreach ($myItem->changes as $change) { - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/changes/" . $change->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/changes/', $change->id); $status = $this->getStatusArray()[$change->status]; + $entity = ''; - if ($change->entity != null) { - $entity = $change->entity->name; + $entity_url = ''; + if ($change->entity !== null) + { + $entity = $change->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $change->entity->id); } + $priority = $this->getPriorityArray()[$change->priority]; + $requesters = []; - if ($change->requester != null) { - foreach ($change->requester as $requester) { - $requesters[] = ['name' => $requester->name]; + if ($change->requester !== null) + { + foreach ($change->requester as $requester) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $requester->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $this->genereUserName($requester->name, $requester->lastname, $requester->firstname), + ]; } } - if ($change->requestergroup != null) { - foreach ($change->requestergroup as $requestergroup) { - $requesters[] = ['name' => $requestergroup->completename]; + if ($change->requestergroup !== null) + { + foreach ($change->requestergroup as $requestergroup) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $requestergroup->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $requestergroup->completename, + ]; } } + $technicians = []; - if ($change->technician != null) { - foreach ($change->technician as $technician) { - $technicians[] = ['name' => $technician->name]; + if ($change->technician !== null) + { + foreach ($change->technician as $technician) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $technician->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $this->genereUserName($technician->name, $technician->lastname, $technician->firstname), + ]; } } - if ($change->techniciangroup != null) { - foreach ($change->techniciangroup as $techniciangroup) { - $technicians[] = ['name' => $techniciangroup->completename]; + if ($change->techniciangroup !== null) + { + foreach ($change->techniciangroup as $techniciangroup) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $techniciangroup->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $techniciangroup->completename, + ]; } } + $category = ''; - if ($change->itilcategorie != null) { + $category_url = ''; + if ($change->itilcategorie !== null) + { $category = $change->itilcategorie->name; + $category_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/categories/', $change->itilcategorie->id); } - $planification = 0; // TODO + $planification = 0; // TODO $changes[$change->id] = [ - 'url' => $url, - 'status' => $status, - 'date' => $change->date, - 'last_update' => $change->updated_at, - 'entity' => $entity, - 'priority' => $priority, - 'requesters' => $requesters, - 'technicians' => $technicians, - 'title' => $change->name, - 'category' => $category, - 'planification' => $planification, + 'url' => $url, + 'status' => $status, + 'date' => $change->date, + 'last_update' => $change->updated_at, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'priority' => $priority, + 'requesters' => $requesters, + 'technicians' => $technicians, + 'title' => $change->name, + 'category' => $category, + 'category_url' => $category_url, + 'planification' => $planification, ]; } @@ -1878,246 +2115,785 @@ public function showSubComponents(Request $request, Response $response, $args): 'devicedrives' )->find($args['id']); - - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/components'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') - { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/components'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + + $colorTab = []; + $colorTab['memories'] = 'red'; + $colorTab['firmwares'] = 'orange'; + $colorTab['processors'] = 'olive'; + $colorTab['harddrives'] = 'teal'; + $colorTab['batteries'] = 'blue'; + $colorTab['soundcards'] = 'purple'; + $colorTab['controllers'] = 'red'; + $colorTab['powersupplies'] = 'orange'; + $colorTab['sensors'] = 'olive'; + $colorTab['devicepcis'] = 'teal'; + $colorTab['devicegenerics'] = 'blue'; + $colorTab['devicenetworkcards'] = 'purple'; + $colorTab['devicesimcards'] = 'brown'; + $colorTab['devicemotherboards'] = 'red'; + $colorTab['devicecases'] = 'orange'; + $colorTab['devicegraphiccards'] = 'olive'; + $colorTab['devicedrives'] = 'teal'; $myMemories = []; foreach ($myItem->memories as $memory) { - $loc = \App\Models\Location::find($memory->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($memory->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); } $manufacturer = ''; + $manufacturer_url = ''; if ($memory->manufacturer !== null) { $manufacturer = $memory->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $memory->manufacturer->id + ); } - $myMemories[] = [ - 'name' => $memory->name, - 'manufacturer' => $manufacturer, - 'type' => $memory->type->name, - 'frequence' => $memory->frequence, - 'size' => $memory->pivot->size, - 'serial' => $memory->pivot->serial, - 'busID' => $memory->pivot->busID, - 'location' => $location, - 'color' => 'red', - ]; - } - - $myFirmwares = []; - foreach ($myItem->firmwares as $firmware) - { - $loc = \App\Models\Location::find($firmware->pivot->location_id); - - $location = ''; - if ($loc !== null) + $type = ''; + $type_url = ''; + if ($memory->type !== null) { - $location = $loc->name; + $type = $memory->type->name; + $type_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/devicememorytype/', $memory->type->id); } - $manufacturer = ''; - if ($firmware->manufacturer !== null) + $serial = $memory->pivot->serial; + + $otherserial = $memory->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($memory->pivot->state_id); + if ($status !== null) { - $manufacturer = $firmware->manufacturer->name; + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); + } + + $documents = []; + if ($memory->documents !== null) + { + foreach ($memory->documents as $document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + + $documents[$document->id] = [ + 'name' => $document->name, + 'url' => $url, + ]; + } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $memory->pivot->id, + 'item_type' => 'App\\Models\\Item_devicememory' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } + } + + $myMemories[] = [ + 'name' => $memory->name, + 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, + 'type' => $type, + 'type_url' => $type_url, + 'frequence' => $memory->frequence, + 'size' => $memory->pivot->size, + 'busID' => $memory->pivot->busID, + 'location' => $location, + 'location_url' => $location_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'documents' => $documents, + 'color' => $colorTab['memories'], + ]; + } + + $myFirmwares = []; + foreach ($myItem->firmwares as $firmware) + { + $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($firmware->pivot->location_id); + if ($loc !== null) + { + $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); + } + + $manufacturer = ''; + $manufacturer_url = ''; + if ($firmware->manufacturer !== null) + { + $manufacturer = $firmware->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $firmware->manufacturer->id + ); } $type = ''; + $type_url = ''; if ($firmware->type !== null) { $type = $firmware->type->name; + $type_url = $this->genereRootUrl2Link($rootUrl2, '/devices/devicefirmwaretypes/', $firmware->type->id); + } + + $serial = $firmware->pivot->serial; + + $otherserial = $firmware->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($firmware->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); + } + + $documents = []; + if ($firmware->documents !== null) + { + foreach ($firmware->documents as $document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + + $documents[$document->id] = [ + 'name' => $document->name, + 'url' => $url, + ]; + } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $firmware->pivot->id, + 'item_type' => 'App\\Models\\Item_devicefirmware' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } } $myFirmwares[] = [ - 'name' => $firmware->name, - 'manufacturer' => $manufacturer, - 'type' => $type, - 'version' => $firmware->version, - 'date' => $firmware->date, - 'location' => $location, - 'color' => 'orange', + 'name' => $firmware->name, + 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, + 'type' => $type, + 'type_url' => $type_url, + 'version' => $firmware->version, + 'date' => $firmware->date, + 'location' => $location, + 'location_url' => $location_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'documents' => $documents, + 'color' => $colorTab['firmwares'], ]; } $myProcessors = []; foreach ($myItem->processors as $processor) { - $loc = \App\Models\Location::find($processor->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($processor->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); } $manufacturer = ''; + $manufacturer_url = ''; if ($processor->manufacturer !== null) { $manufacturer = $processor->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $processor->manufacturer->id + ); + } + + $serial = $processor->pivot->serial; + + $otherserial = $processor->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($processor->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); + } + + $busID = $processor->pivot->busID; + + $documents = []; + if ($processor->documents !== null) + { + foreach ($processor->documents as $document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + + $documents[$document->id] = [ + 'name' => $document->name, + 'url' => $url, + ]; + } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $processor->pivot->id, + 'item_type' => 'App\\Models\\Item_deviceprocessor' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } } $myProcessors[] = [ - 'name' => $processor->name, - 'manufacturer' => $manufacturer, - 'frequency' => $processor->pivot->frequency, - 'nbcores' => $processor->pivot->nbcores, - 'nbthreads' => $processor->pivot->nbthreads, - 'location' => $location, - 'color' => 'olive', + 'name' => $processor->name, + 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, + 'frequency' => $processor->pivot->frequency, + 'nbcores' => $processor->pivot->nbcores, + 'nbthreads' => $processor->pivot->nbthreads, + 'location' => $location, + 'location_url' => $location_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'busID' => $busID, + 'documents' => $documents, + 'color' => $colorTab['processors'], ]; } $myHarddrives = []; foreach ($myItem->harddrives as $harddrive) { - $loc = \App\Models\Location::find($harddrive->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($harddrive->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); } $manufacturer = ''; + $manufacturer_url = ''; if ($harddrive->manufacturer !== null) { $manufacturer = $harddrive->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $harddrive->manufacturer->id + ); } $interface = ''; + $interface_url = ''; if ($harddrive->interface !== null) { $interface = $harddrive->interface->name; + $interface_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/interfacetypes/', $harddrive->interface->id); + } + + $serial = $harddrive->pivot->serial; + + $otherserial = $harddrive->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($harddrive->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); + } + + $busID = $harddrive->pivot->busID; + + $documents = []; + if ($harddrive->documents !== null) + { + foreach ($harddrive->documents as $document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + + $documents[$document->id] = [ + 'name' => $document->name, + 'url' => $url, + ]; + } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $harddrive->pivot->id, + 'item_type' => 'App\\Models\\Item_deviceharddrive' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } } $myHarddrives[] = [ - 'name' => $harddrive->name, - 'manufacturer' => $manufacturer, - 'rpm' => $harddrive->rpm, - 'cache' => $harddrive->cache, - 'interface' => $interface, - 'capacity' => $harddrive->pivot->capacity, - 'serial' => $harddrive->pivot->serial, - 'location' => $location, - 'color' => 'teal', + 'name' => $harddrive->name, + 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, + 'rpm' => $harddrive->rpm, + 'cache' => $harddrive->cache, + 'interface' => $interface, + 'interface_url' => $interface_url, + 'capacity' => $harddrive->pivot->capacity, + 'location' => $location, + 'location_url' => $location_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'busID' => $busID, + 'documents' => $documents, + 'color' => $colorTab['harddrives'], ]; } $myBatteries = []; foreach ($myItem->batteries as $battery) { - $loc = \App\Models\Location::find($battery->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($battery->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); } $manufacturer = ''; + $manufacturer_url = ''; if ($battery->manufacturer !== null) { $manufacturer = $battery->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $battery->manufacturer->id + ); } $type = ''; + $type_url = ''; if ($battery->type !== null) { $type = $battery->type->name; + $type_url = $this->genereRootUrl2Link($rootUrl2, '/devices/devicebatterytypes/', $battery->type->id); + } + + $serial = $battery->pivot->serial; + + $otherserial = $battery->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($battery->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); + } + + $documents = []; + if ($battery->documents !== null) + { + foreach ($battery->documents as $document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + + $documents[$document->id] = [ + 'name' => $document->name, + 'url' => $url, + ]; + } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $battery->pivot->id, + 'item_type' => 'App\\Models\\Item_devicebattery' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } } $myBatteries[] = [ 'name' => $battery->name, 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, 'type' => $type, + 'type_url' => $type_url, 'voltage' => $battery->voltage, 'capacity' => $battery->capacity, - 'serial' => $battery->pivot->serial, 'manufacturing_date' => $battery->pivot->manufacturing_date, 'location' => $location, - 'color' => 'blue', + 'location_url' => $location_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'documents' => $documents, + 'color' => $colorTab['batteries'], ]; } $mySoundcards = []; foreach ($myItem->soundcards as $soundcard) { - $loc = \App\Models\Location::find($soundcard->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($soundcard->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); } $manufacturer = ''; + $manufacturer_url = ''; if ($soundcard->manufacturer !== null) { $manufacturer = $soundcard->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $soundcard->manufacturer->id + ); + } + + $serial = $soundcard->pivot->serial; + + $otherserial = $soundcard->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($soundcard->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); + } + + $busID = $soundcard->pivot->busID; + + $documents = []; + if ($soundcard->documents !== null) + { + foreach ($soundcard->documents as $document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + + $documents[$document->id] = [ + 'name' => $document->name, + 'url' => $url, + ]; + } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $soundcard->pivot->id, + 'item_type' => 'App\\Models\\Item_devicesoundcard' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } } $mySoundcards[] = [ - 'name' => $soundcard->name, - 'manufacturer' => $manufacturer, - 'type' => $soundcard->type, - 'location' => $location, - 'color' => 'purple', + 'name' => $soundcard->name, + 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, + 'type' => $soundcard->type, + 'location' => $location, + 'location_url' => $location_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'busID' => $busID, + 'documents' => $documents, + 'color' => $colorTab['soundcards'], ]; } $myControllers = []; foreach ($myItem->controllers as $controller) { - $loc = \App\Models\Location::find($controller->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($controller->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); } $manufacturer = ''; + $manufacturer_url = ''; if ($controller->manufacturer !== null) { $manufacturer = $controller->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $controller->manufacturer->id + ); } $interface = ''; + $interface_url = ''; if ($controller->interface !== null) { $interface = $controller->interface->name; + $interface_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/interfacetypes/', $controller->interface->id); + } + + $serial = $controller->pivot->serial; + + $otherserial = $controller->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($controller->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); + } + + $busID = $controller->pivot->busID; + + $documents = []; + if ($controller->documents !== null) + { + foreach ($controller->documents as $document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + + $documents[$document->id] = [ + 'name' => $document->name, + 'url' => $url, + ]; + } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $controller->pivot->id, + 'item_type' => 'App\\Models\\Item_devicecontrol' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } } $myControllers[] = [ - 'name' => $controller->name, - 'manufacturer' => $manufacturer, - 'interface' => $interface, - 'location' => $location, - 'color' => 'brown', + 'name' => $controller->name, + 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, + 'interface' => $interface, + 'interface_url' => $interface_url, + 'location' => $location, + 'location_url' => $location_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'busID' => $busID, + 'documents' => $documents, + 'color' => $colorTab['controllers'], ]; } $myPowerSupplies = []; foreach ($myItem->powersupplies as $powersupply) { - $loc = \App\Models\Location::find($powersupply->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($powersupply->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); + } + + $manufacturer = ''; + $manufacturer_url = ''; + if ($powersupply->manufacturer !== null) + { + $manufacturer = $powersupply->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $powersupply->manufacturer->id + ); + } + + $serial = $powersupply->pivot->serial; + + $otherserial = $powersupply->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($powersupply->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); } $documents = []; @@ -2125,41 +2901,91 @@ public function showSubComponents(Request $request, Response $response, $args): { foreach ($powersupply->documents as $document) { - $url = ''; - if ($rootUrl2 != '') - { - $url = $rootUrl2 . "/documents/" . $document->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + $documents[$document->id] = [ - 'name' => $document->name, - 'url' => $url, + 'name' => $document->name, + 'url' => $url, ]; } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $powersupply->pivot->id, + 'item_type' => 'App\\Models\\Item_devicepowersupply' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } } $myPowerSupplies[] = [ - 'name' => $powersupply->name, - 'location' => $location, - 'documents' => $documents, - 'color' => 'purple', + 'name' => $powersupply->name, + 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, + 'location' => $location, + 'location_url' => $location_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'documents' => $documents, + 'color' => $colorTab['powersupplies'], ]; } $mySensors = []; foreach ($myItem->sensors as $sensor) { - $loc = \App\Models\Location::find($sensor->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($sensor->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); } $manufacturer = ''; + $manufacturer_url = ''; if ($sensor->manufacturer !== null) { $manufacturer = $sensor->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $sensor->manufacturer->id + ); + } + + $serial = $sensor->pivot->serial; + + $otherserial = $sensor->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($sensor->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); } $documents = []; @@ -2167,72 +2993,172 @@ public function showSubComponents(Request $request, Response $response, $args): { foreach ($sensor->documents as $document) { - $url = ''; - if ($rootUrl2 != '') - { - $url = $rootUrl2 . "/documents/" . $document->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + $documents[$document->id] = [ - 'name' => $document->name, - 'url' => $url, + 'name' => $document->name, + 'url' => $url, ]; } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $sensor->pivot->id, + 'item_type' => 'App\\Models\\Item_devicesensor' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } } $mySensors[] = [ - 'name' => $sensor->name, - 'manufacturer' => $manufacturer, - 'location' => $location, - 'documents' => $documents, - 'color' => 'purple', + 'name' => $sensor->name, + 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, + 'location' => $location, + 'location_url' => $location_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'documents' => $documents, + 'color' => $colorTab['sensors'], ]; } $myDevicepcis = []; foreach ($myItem->devicepcis as $devicepci) { - $loc = \App\Models\Location::find($devicepci->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($devicepci->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); + } + + $serial = $devicepci->pivot->serial; + + $otherserial = $devicepci->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($devicepci->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); } + $busID = $devicepci->pivot->busID; + $documents = []; if ($devicepci->documents !== null) { foreach ($devicepci->documents as $document) { - $url = ''; - if ($rootUrl2 != '') - { - $url = $rootUrl2 . "/documents/" . $document->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + $documents[$document->id] = [ - 'name' => $document->name, - 'url' => $url, + 'name' => $document->name, + 'url' => $url, ]; } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $devicepci->pivot->id, + 'item_type' => 'App\\Models\\Item_devicepci' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } } $myDevicepcis[] = [ - 'name' => $devicepci->name, - 'location' => $location, - 'documents' => $documents, - 'color' => 'blue', + 'name' => $devicepci->name, + 'location' => $location, + 'location_url' => $location_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'busID' => $busID, + 'documents' => $documents, + 'color' => $colorTab['devicepcis'], ]; } $myDevicegenerics = []; foreach ($myItem->devicegenerics as $devicegeneric) { - $loc = \App\Models\Location::find($devicegeneric->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($devicegeneric->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); + } + + $manufacturer = ''; + $manufacturer_url = ''; + if ($devicegeneric->manufacturer !== null) + { + $manufacturer = $devicegeneric->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $devicegeneric->manufacturer->id + ); + } + + $serial = $devicegeneric->pivot->serial; + + $otherserial = $devicegeneric->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($devicegeneric->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); } $documents = []; @@ -2240,71 +3166,209 @@ public function showSubComponents(Request $request, Response $response, $args): { foreach ($devicegeneric->documents as $document) { - $url = ''; - if ($rootUrl2 != '') - { - $url = $rootUrl2 . "/documents/" . $document->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + $documents[$document->id] = [ - 'name' => $document->name, - 'url' => $url, + 'name' => $document->name, + 'url' => $url, ]; } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $devicegeneric->pivot->id, + 'item_type' => 'App\\Models\\Item_devicegeneric' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } } $myDevicegenerics[] = [ - 'name' => $devicegeneric->name, - 'location' => $location, - 'documents' => $documents, - 'color' => 'teal', + 'name' => $devicegeneric->name, + 'location' => $location, + 'location_url' => $location_url, + 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'documents' => $documents, + 'color' => $colorTab['devicegenerics'], ]; } $myDevicenetworkcards = []; foreach ($myItem->devicenetworkcards as $devicenetworkcard) { - $loc = \App\Models\Location::find($devicenetworkcard->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($devicenetworkcard->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); + } + + $manufacturer = ''; + $manufacturer_url = ''; + if ($devicenetworkcard->manufacturer !== null) + { + $manufacturer = $devicenetworkcard->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $devicenetworkcard->manufacturer->id + ); + } + + $serial = $devicenetworkcard->pivot->serial; + + $otherserial = $devicenetworkcard->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($devicenetworkcard->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); } + $busID = $devicenetworkcard->pivot->busID; + + $speed = $devicenetworkcard->bandwidth; + $documents = []; if ($devicenetworkcard->documents !== null) { foreach ($devicenetworkcard->documents as $document) { - $url = ''; - if ($rootUrl2 != '') - { - $url = $rootUrl2 . "/documents/" . $document->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + $documents[$document->id] = [ - 'name' => $document->name, - 'url' => $url, + 'name' => $document->name, + 'url' => $url, ]; } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $devicenetworkcard->pivot->id, + 'item_type' => 'App\\Models\\Item_devicenetworkcard' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } } + $mac_address = $devicenetworkcard->pivot->mac; + $myDevicenetworkcards[] = [ - 'name' => $devicenetworkcard->name, - 'location' => $location, - 'documents' => $documents, - 'color' => 'red', + 'name' => $devicenetworkcard->name, + 'location' => $location, + 'location_url' => $location_url, + 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'busID' => $busID, + 'speed' => $speed, + 'documents' => $documents, + 'mac_address' => $mac_address, + 'color' => $colorTab['devicenetworkcards'], ]; } $myDevicesimcards = []; foreach ($myItem->devicesimcards as $devicesimcard) { - $loc = \App\Models\Location::find($devicesimcard->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($devicesimcard->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); + } + + $serial = $devicesimcard->pivot->serial; + + $otherserial = $devicesimcard->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($devicesimcard->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); + } + + $line = ''; + $line_url = ''; + $find_line = \App\Models\Line::find($devicesimcard->pivot->line_id); + if ($find_line !== null) + { + $line = $find_line->name; + $line_url = $this->genereRootUrl2Link($rootUrl2, '/lines/', $find_line->id); + } + + $msin = $devicesimcard->pivot->msin; + + $user = ''; + $user_url = ''; + $find_user = \App\Models\User::find($devicesimcard->pivot->user_id); + if ($find_user !== null) + { + $user = $find_user->name; + $user_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $find_user->id); + } + + $group = ''; + $group_url = ''; + $find_group = \App\Models\Group::find($devicesimcard->pivot->group_id); + if ($find_group !== null) + { + $group = $find_group->name; + $group_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $find_group->id); } $documents = []; @@ -2312,38 +3376,96 @@ public function showSubComponents(Request $request, Response $response, $args): { foreach ($devicesimcard->documents as $document) { - $url = ''; - if ($rootUrl2 != '') - { - $url = $rootUrl2 . "/documents/" . $document->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + $documents[$document->id] = [ - 'name' => $document->name, - 'url' => $url, + 'name' => $document->name, + 'url' => $url, ]; } - } - $mac_address = ''; # TODO + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $devicesimcard->pivot->id, + 'item_type' => 'App\\Models\\ItemDevicesimcard' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } + } $myDevicesimcards[] = [ - 'name' => $devicesimcard->name, - 'location' => $location, - 'documents' => $documents, - 'mac_address' => $mac_address, - 'color' => 'orange', + 'name' => $devicesimcard->name, + 'location' => $location, + 'location_url' => $location_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'line' => $line, + 'line_url' => $line_url, + 'msin' => $msin, + 'user' => $user, + 'user_url' => $user_url, + 'group' => $group, + 'group_url' => $group_url, + 'documents' => $documents, + 'color' => $colorTab['devicesimcards'], ]; } $myDevicemotherboards = []; foreach ($myItem->devicemotherboards as $devicemotherboard) { - $loc = \App\Models\Location::find($devicemotherboard->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($devicemotherboard->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); + } + + $manufacturer = ''; + $manufacturer_url = ''; + if ($devicemotherboard->manufacturer !== null) + { + $manufacturer = $devicemotherboard->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $devicemotherboard->manufacturer->id + ); + } + + $serial = $devicemotherboard->pivot->serial; + + $otherserial = $devicemotherboard->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($devicemotherboard->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); } $documents = []; @@ -2351,41 +3473,91 @@ public function showSubComponents(Request $request, Response $response, $args): { foreach ($devicemotherboard->documents as $document) { - $url = ''; - if ($rootUrl2 != '') - { - $url = $rootUrl2 . "/documents/" . $document->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + $documents[$document->id] = [ - 'name' => $document->name, - 'url' => $url, + 'name' => $document->name, + 'url' => $url, ]; } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $devicemotherboard->pivot->id, + 'item_type' => 'App\\Models\\Item_devicemotherboard' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } } $myDevicemotherboards[] = [ - 'name' => $devicemotherboard->name, - 'location' => $location, - 'documents' => $documents, - 'color' => 'olive', + 'name' => $devicemotherboard->name, + 'location' => $location, + 'location_url' => $location_url, + 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'documents' => $documents, + 'color' => $colorTab['devicemotherboards'], ]; } $myDevicecases = []; foreach ($myItem->devicecases as $devicecase) { - $loc = \App\Models\Location::find($devicecase->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($devicecase->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); } $manufacturer = ''; + $manufacturer_url = ''; if ($devicecase->manufacturer !== null) { $manufacturer = $devicecase->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $devicecase->manufacturer->id + ); + } + + $serial = $devicecase->pivot->serial; + + $otherserial = $devicecase->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($devicecase->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); } $documents = []; @@ -2393,128 +3565,288 @@ public function showSubComponents(Request $request, Response $response, $args): { foreach ($devicecase->documents as $document) { - $url = ''; - if ($rootUrl2 != '') - { - $url = $rootUrl2 . "/documents/" . $document->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + $documents[$document->id] = [ - 'name' => $document->name, - 'url' => $url, + 'name' => $document->name, + 'url' => $url, ]; } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $devicecase->pivot->id, + 'item_type' => 'App\\Models\\Item_devicecase' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } } $myDevicecases[] = [ - 'name' => $devicecase->name, - 'manufacturer' => $manufacturer, - 'location' => $location, - 'documents' => $documents, - 'color' => 'olive', + 'name' => $devicecase->name, + 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, + 'location' => $location, + 'location_url' => $location_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'documents' => $documents, + 'color' => $colorTab['devicecases'], ]; } $myDevicegraphiccards = []; foreach ($myItem->devicegraphiccards as $devicegraphiccard) { - $loc = \App\Models\Location::find($devicegraphiccard->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($devicegraphiccard->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); } $manufacturer = ''; + $manufacturer_url = ''; if ($devicegraphiccard->manufacturer !== null) { $manufacturer = $devicegraphiccard->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $devicegraphiccard->manufacturer->id + ); } $interface = ''; + $interface_url = ''; if ($devicegraphiccard->interface !== null) { $interface = $devicegraphiccard->interface->name; + $interface_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/interfacetypes/', + $devicegraphiccard->interface->id + ); + } + + $serial = $devicegraphiccard->pivot->serial; + + $otherserial = $devicegraphiccard->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($devicegraphiccard->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); } + $busID = $devicegraphiccard->pivot->busID; + $documents = []; if ($devicegraphiccard->documents !== null) { foreach ($devicegraphiccard->documents as $document) { - $url = ''; - if ($rootUrl2 != '') - { - $url = $rootUrl2 . "/documents/" . $document->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + $documents[$document->id] = [ - 'name' => $document->name, - 'url' => $url, + 'name' => $document->name, + 'url' => $url, ]; } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $devicegraphiccard->pivot->id, + 'item_type' => 'App\\Models\\Item_devicegraphiccard' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } } $myDevicegraphiccards[] = [ - 'name' => $devicegraphiccard->name, - 'manufacturer' => $manufacturer, - 'interface' => $interface, - 'chipset' => $devicegraphiccard->chipset, - 'memory' => $devicegraphiccard->emory, - 'location' => $location, - 'documents' => $documents, - 'color' => 'brown', + 'name' => $devicegraphiccard->name, + 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, + 'interface' => $interface, + 'interface_url' => $interface_url, + 'chipset' => $devicegraphiccard->chipset, + 'memory' => $devicegraphiccard->pivot->memory, + 'location' => $location, + 'location_url' => $location_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'busID' => $busID, + 'documents' => $documents, + 'color' => $colorTab['devicegraphiccards'], ]; } $myDevicedrives = []; foreach ($myItem->devicedrives as $devicedrive) { - $loc = \App\Models\Location::find($devicedrive->pivot->location_id); - $location = ''; + $location_url = ''; + $loc = \App\Models\Location::find($devicedrive->pivot->location_id); if ($loc !== null) { $location = $loc->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $loc->id); } $manufacturer = ''; + $manufacturer_url = ''; if ($devicedrive->manufacturer !== null) { $manufacturer = $devicedrive->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $devicedrive->manufacturer->id + ); + } + + $write = $devicedrive->is_writer; + if ($write == 1) + { + $write_val = $translator->translate('Yes'); + } + else + { + $write_val = $translator->translate('No'); } + $speed = $devicedrive->speed; + $interface = ''; + $interface_url = ''; if ($devicedrive->interface !== null) { $interface = $devicedrive->interface->name; + $interface_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/interfacetypes/', + $devicedrive->interface->id + ); + } + + $serial = $devicedrive->pivot->serial; + + $otherserial = $devicedrive->pivot->otherserial; + + $state = ''; + $state_url = ''; + $status = \App\Models\State::find($devicedrive->pivot->state_id); + if ($status !== null) + { + $state = $status->name; + $state_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $status->id); } + $busID = $devicedrive->pivot->busID; + $documents = []; if ($devicedrive->documents !== null) { foreach ($devicedrive->documents as $document) { - $url = ''; - if ($rootUrl2 != '') - { - $url = $rootUrl2 . "/documents/" . $document->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + $documents[$document->id] = [ - 'name' => $document->name, - 'url' => $url, + 'name' => $document->name, + 'url' => $url, ]; } + + $item5 = new \App\Models\Documentitem(); + $myItem5 = $item5::where([ + 'item_id' => $devicedrive->pivot->id, + 'item_type' => 'App\\Models\\Item_devicedrive' + ])->get(); + if ($myItem5 !== null) + { + foreach ($myItem5 as $current_documentitem) + { + $item6 = new \App\Models\Document(); + $myItem6 = $item6::where('id', $current_documentitem->document_id)->get(); + if ($myItem6 !== null) + { + foreach ($myItem6 as $current_document) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/documents/', $current_document->id); + + $documents[$current_document->id] = [ + 'name' => $current_document->name, + 'url' => $url, + ]; + } + } + } + } } $myDevicedrives[] = [ - 'name' => $devicedrive->name, - 'manufacturer' => $manufacturer, - 'write' => $devicedrive->is_writer, - 'speed' => $devicedrive->speed, - 'interface' => $interface, - 'location' => $location, - 'documents' => $documents, - 'color' => 'teal', + 'name' => $devicedrive->name, + 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, + 'write' => $write, + 'write_val' => $write_val, + 'speed' => $speed, + 'interface' => $interface, + 'interface_url' => $interface_url, + 'location' => $location, + 'location_url' => $location_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'state' => $state, + 'state_url' => $state_url, + 'busID' => $busID, + 'documents' => $documents, + 'color' => $colorTab['devicedrives'], ]; } @@ -2600,6 +3932,13 @@ public function showSubComponents(Request $request, Response $response, $args): $viewData->addTranslation('chipset', $translator->translate('Chipset')); $viewData->addTranslation('write', $translator->translate('Write')); $viewData->addTranslation('speed', $translator->translate('Speed')); + $viewData->addTranslation('inventaire_number', $translator->translate('Inventory number')); + $viewData->addTranslation('status', $translator->translate('Status')); + $viewData->addTranslation('msin', $translator->translate('Mobile Subscriber Identification Number')); + $viewData->addTranslation('user', $translator->translatePlural('User', 'Users', 1)); + $viewData->addTranslation('group', $translator->translatePlural('Group', 'Groups', 1)); + $viewData->addTranslation('flow', $translator->translate('Flow')); + $viewData->addTranslation('line', $translator->translatePlural('Line', 'Lines', 1)); return $view->render($response, 'subitem/components.html.twig', (array)$viewData); } @@ -2614,6 +3953,9 @@ public function showSubVolumes(Request $request, Response $response, $args): Res $myItem = $item::with('volumes')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/volumes'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $myVolumes = []; foreach ($myItem->volumes as $volume) { @@ -2627,12 +3969,13 @@ public function showSubVolumes(Request $request, Response $response, $args): Res } $filesystem = ''; + $filesystem_url = ''; if ($volume->filesystem !== null) { $filesystem = $volume->filesystem->name; + $filesystem_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/filesystems/', $volume->filesystem->id); } - $usedpercent = 100; if ($volume->totalsize > 0) { @@ -2642,15 +3985,15 @@ public function showSubVolumes(Request $request, Response $response, $args): Res $encryption_status_val = ''; if ($volume->encryption_status == 0) { - $encryption_status_val = $translator->translate('Non chiffré'); + $encryption_status_val = $translator->translate('Not encrypted'); } if ($volume->encryption_status == 1) { - $encryption_status_val = $translator->translate('Chiffré'); + $encryption_status_val = $translator->translate('Encrypted'); } if ($volume->encryption_status == 2) { - $encryption_status_val = $translator->translate('Partiellement chiffré'); + $encryption_status_val = $translator->translate('Partially encrypted'); } $myVolumes[] = [ @@ -2660,6 +4003,7 @@ public function showSubVolumes(Request $request, Response $response, $args): Res 'device' => $volume->device, 'mountpoint' => $volume->mountpoint, 'filesystem' => $filesystem, + 'filesystem_url' => $filesystem_url, 'totalsize' => $volume->totalsize, 'freesize' => $volume->freesize, 'usedpercent' => $usedpercent, @@ -2671,9 +4015,6 @@ public function showSubVolumes(Request $request, Response $response, $args): Res ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/volumes'); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -2695,7 +4036,6 @@ public function showSubVolumes(Request $request, Response $response, $args): Res return $view->render($response, 'subitem/volumes.html.twig', (array)$viewData); } - public function showSubItilTicketsCreated(Request $request, Response $response, $args): Response { global $translator; @@ -2706,95 +4046,171 @@ public function showSubItilTicketsCreated(Request $request, Response $response, $myItem = $item->find($args['id']); - $item2 = new \App\Models\Ticket(); $myItem2 = $item2::with('requester', 'requestergroup', 'technician', 'techniciangroup')->get(); - - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/tickets'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') - { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/tickets'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $tickets = []; foreach ($myItem2 as $ticket) { $add_to_tab = false; - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/tickets/" . $ticket->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/tickets/', $ticket->id); $status = $this->getStatusArray()[$ticket->status]; + $entity = ''; - if ($ticket->entity != null) { - $entity = $ticket->entity->name; + $entity_url = ''; + if ($ticket->entity !== null) + { + $entity = $ticket->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $ticket->entity->id); } + $priority = $this->getPriorityArray()[$ticket->priority]; + $requesters = []; - if ($ticket->requester != null) { - foreach ($ticket->requester as $requester) { - if ($this->itilchoose == 'users') { - if ($requester->id == $args['id']) { + if ($ticket->requester !== null) + { + foreach ($ticket->requester as $requester) + { + if ($this->choose == 'users') + { + if ($requester->id == $args['id']) + { $add_to_tab = true; } } - $requesters[] = ['name' => $requester->name]; + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $requester->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $this->genereUserName($requester->name, $requester->lastname, $requester->firstname), + ]; } } - if ($ticket->requestergroup != null) { - foreach ($ticket->requestergroup as $requestergroup) { - if ($this->itilchoose == 'groups') { - if ($requestergroup->id == $args['id']) { + if ($ticket->requestergroup !== null) + { + foreach ($ticket->requestergroup as $requestergroup) + { + if ($this->choose == 'groups') + { + if ($requestergroup->id == $args['id']) + { $add_to_tab = true; } } - $requesters[] = ['name' => $requestergroup->name]; + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $requestergroup->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $requestergroup->completename, + ]; } } + $technicians = []; - if ($ticket->technician != null) { - foreach ($ticket->technician as $technician) { - $technicians[] = ['name' => $technician->name]; + if ($ticket->technician !== null) + { + foreach ($ticket->technician as $technician) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $technician->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $this->genereUserName($technician->name, $technician->lastname, $technician->firstname), + ]; + } + } + if ($ticket->techniciangroup !== null) + { + foreach ($ticket->techniciangroup as $techniciangroup) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $techniciangroup->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $techniciangroup->completename, + ]; } } - if ($ticket->techniciangroup != null) { - foreach ($ticket->techniciangroup as $techniciangroup) { - $technicians[] = ['name' => $techniciangroup->name]; + + $associated_items = []; + $item4 = new \App\Models\ItemTicket(); + $myItem4 = $item4::where('ticket_id', $ticket->id)->get(); + if ($myItem4 !== null) + { + foreach ($myItem4 as $val) + { + $item5 = new $val->item_type(); + $myItem5 = $item5->find($val->item_id); + if ($myItem5 !== null) + { + $type5_fr = $item5->getTitle(); + $type5 = $item5->getTable(); + + $name5 = $myItem5->name; + + $url5 = $this->genereRootUrl2Link($rootUrl2, '/' . $type5 . '/', $myItem5->id); + + if ($type5_fr != '') + { + $type5_fr = $type5_fr . ' - '; + } + + $associated_items[] = [ + 'type' => $type5_fr, + 'name' => $name5, + 'url' => $url5, + ]; + } + } + + if (empty($associated_items)) + { + $associated_items[] = [ + 'type' => '', + 'name' => $translator->translate('General'), + 'url' => '', + ]; } } - $associated_items = []; // TODO + $category = ''; - if ($ticket->category != null) { + $category_url = ''; + if ($ticket->category !== null) + { $category = $ticket->category->name; + $category_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/categories/', $ticket->category->id); } - $planification = 0; // TODO + $planification = 0; // TODO - if ($add_to_tab) { + if ($add_to_tab) + { $tickets[$ticket->id] = [ - 'url' => $url, - 'status' => $status, - 'date' => $ticket->date, - 'last_update' => $ticket->updated_at, - 'entity' => $entity, - 'priority' => $priority, - 'requesters' => $requesters, - 'technicians' => $technicians, - 'associated_items' => $associated_items, - 'title' => $ticket->name, - 'category' => $category, - 'planification' => $planification, + 'url' => $url, + 'status' => $status, + 'date' => $ticket->date, + 'last_update' => $ticket->updated_at, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'priority' => $priority, + 'requesters' => $requesters, + 'technicians' => $technicians, + 'associated_items' => $associated_items, + 'title' => $ticket->name, + 'category' => $category, + 'category_url' => $category_url, + 'planification' => $planification, ]; } } // tri de la + récente à la + ancienne - usort($tickets, function ($a, $b) + uasort($tickets, function ($a, $b) { return $a['last_update'] < $b['last_update']; }); @@ -2835,102 +4251,143 @@ public function showSubItilProblems(Request $request, Response $response, $args) $myItem = $item->find($args['id']); - $item2 = new \App\Models\Problem(); $myItem2 = $item2::with('requester', 'requestergroup', 'technician', 'techniciangroup')->get(); - - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/problems'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/problems'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $problems = []; foreach ($myItem2 as $problem) { $add_to_tab = false; - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/problems/" . $problem->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/problems/', $problem->id); $status = $this->getStatusArray()[$problem->status]; + $entity = ''; - if ($problem->entity != null) { - $entity = $problem->entity->name; + $entity_url = ''; + if ($problem->entity !== null) + { + $entity = $problem->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $problem->entity->id); } + $priority = $this->getPriorityArray()[$problem->priority]; + $requesters = []; - if ($problem->requester != null) { - foreach ($problem->requester as $requester) { - if ($this->itilchoose == 'users') { - if ($requester->id == $args['id']) { + if ($problem->requester !== null) + { + foreach ($problem->requester as $requester) + { + if ($this->choose == 'users') + { + if ($requester->id == $args['id']) + { $add_to_tab = true; } } - $requesters[] = ['name' => $requester->name]; + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $requester->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $this->genereUserName($requester->name, $requester->lastname, $requester->firstname), + ]; } } - if ($problem->requestergroup != null) { - foreach ($problem->requestergroup as $requestergroup) { - if ($this->itilchoose == 'groups') { - if ($requestergroup->id == $args['id']) { + if ($problem->requestergroup !== null) + { + foreach ($problem->requestergroup as $requestergroup) + { + if ($this->choose == 'groups') + { + if ($requestergroup->id == $args['id']) + { $add_to_tab = true; } } - $requesters[] = ['name' => $requestergroup->name]; + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $requestergroup->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $requestergroup->completename, + ]; } } + $technicians = []; - if ($problem->technician != null) { - foreach ($problem->technician as $technician) { - if ($this->itilchoose == 'users') { - if ($technician->id == $args['id']) { + if ($problem->technician !== null) + { + foreach ($problem->technician as $technician) + { + if ($this->choose == 'users') + { + if ($technician->id == $args['id']) + { $add_to_tab = true; } } - $technicians[] = ['name' => $technician->name]; + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $technician->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $this->genereUserName($technician->name, $technician->lastname, $technician->firstname), + ]; } } - if ($problem->techniciangroup != null) { - foreach ($problem->techniciangroup as $techniciangroup) { - if ($this->itilchoose == 'groups') { - if ($techniciangroup->id == $args['id']) { + if ($problem->techniciangroup !== null) + { + foreach ($problem->techniciangroup as $techniciangroup) + { + if ($this->choose == 'groups') + { + if ($techniciangroup->id == $args['id']) + { $add_to_tab = true; } } - $technicians[] = ['name' => $techniciangroup->name]; + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $techniciangroup->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $techniciangroup->completename, + ]; } } + $category = ''; - if ($problem->category != null) { + $category_url = ''; + if ($problem->category !== null) + { $category = $problem->category->name; + $category_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/categories/', $problem->category->id); } - $planification = 0; // TODO + $planification = 0; // TODO - if ($add_to_tab) { + if ($add_to_tab) + { $problems[$problem->id] = [ - 'url' => $url, - 'status' => $status, - 'date' => $problem->date, - 'last_update' => $problem->updated_at, - 'entity' => $entity, - 'priority' => $priority, - 'requesters' => $requesters, - 'technicians' => $technicians, - 'title' => $problem->name, - 'category' => $category, - 'planification' => $planification, + 'url' => $url, + 'status' => $status, + 'date' => $problem->date, + 'last_update' => $problem->updated_at, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'priority' => $priority, + 'requesters' => $requesters, + 'technicians' => $technicians, + 'title' => $problem->name, + 'category' => $category, + 'category_url' => $category_url, + 'planification' => $planification, ]; } } // tri de la + récente à la + ancienne - usort($problems, function ($a, $b) + uasort($problems, function ($a, $b) { return $a['last_update'] < $b['last_update']; }); @@ -2971,107 +4428,147 @@ public function showSubItilChanges(Request $request, Response $response, $args): $myItem = $item->find($args['id']); - $item2 = new \App\Models\Change(); $myItem2 = $item2::with('requester', 'requestergroup', 'technician', 'techniciangroup')->get(); - - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/changes'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/changes'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $changes = []; foreach ($myItem2 as $change) { $add_to_tab = false; - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/changes/" . $change->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/changes/', $change->id); $status = $this->getStatusArray()[$change->status]; + $entity = ''; - if ($change->entity != null) { - $entity = $change->entity->name; + $entity_url = ''; + if ($change->entity !== null) + { + $entity = $change->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $change->entity->id); } + $priority = $this->getPriorityArray()[$change->priority]; + $requesters = []; - if ($change->requester != null) { - foreach ($change->requester as $requester) { - if ($this->itilchoose == 'users') { - if ($requester->id == $args['id']) { + if ($change->requester !== null) + { + foreach ($change->requester as $requester) + { + if ($this->choose == 'users') + { + if ($requester->id == $args['id']) + { $add_to_tab = true; } } - $requesters[] = ['name' => $requester->name]; + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $requester->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $this->genereUserName($requester->name, $requester->lastname, $requester->firstname), + ]; } } - if ($change->requestergroup != null) { - foreach ($change->requestergroup as $requestergroup) { - if ($this->itilchoose == 'groups') { - if ($requestergroup->id == $args['id']) { + if ($change->requestergroup !== null) + { + foreach ($change->requestergroup as $requestergroup) + { + if ($this->choose == 'groups') + { + if ($requestergroup->id == $args['id']) + { $add_to_tab = true; } } - $requesters[] = ['name' => $requestergroup->name]; + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $requestergroup->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $requestergroup->completename, + ]; } } + $technicians = []; - if ($change->technician != null) { - foreach ($change->technician as $technician) { - if ($this->itilchoose == 'users') { - if ($technician->id == $args['id']) { + if ($change->technician !== null) + { + foreach ($change->technician as $technician) + { + if ($this->choose == 'users') + { + if ($technician->id == $args['id']) + { $add_to_tab = true; } } - $technicians[] = ['name' => $technician->name]; + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $technician->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $this->genereUserName($technician->name, $technician->lastname, $technician->firstname), + ]; } } - if ($change->techniciangroup != null) { - foreach ($change->techniciangroup as $techniciangroup) { - if ($this->itilchoose == 'groups') { - if ($techniciangroup->id == $args['id']) { + if ($change->techniciangroup !== null) + { + foreach ($change->techniciangroup as $techniciangroup) + { + if ($this->choose == 'groups') + { + if ($techniciangroup->id == $args['id']) + { $add_to_tab = true; } } - $technicians[] = ['name' => $techniciangroup->name]; + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $techniciangroup->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $techniciangroup->completename, + ]; } } + $category = ''; - if ($change->itilcategorie != null) { + $category_url = ''; + if ($change->itilcategorie !== null) + { $category = $change->itilcategorie->name; + $category_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/categories/', $change->itilcategorie->id); } - $planification = 0; // TODO + $planification = 0; // TODO - if ($add_to_tab) { + if ($add_to_tab) + { $changes[$change->id] = [ - 'url' => $url, - 'status' => $status, - 'date' => $change->date, - 'last_update' => $change->updated_at, - 'entity' => $entity, - 'priority' => $priority, - 'requesters' => $requesters, - 'technicians' => $technicians, - 'title' => $change->name, - 'category' => $category, - 'planification' => $planification, + 'url' => $url, + 'status' => $status, + 'date' => $change->date, + 'last_update' => $change->updated_at, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'priority' => $priority, + 'requesters' => $requesters, + 'technicians' => $technicians, + 'title' => $change->name, + 'category' => $category, + 'category_url' => $category_url, + 'planification' => $planification, ]; } } // tri de la + récente à la + ancienne - usort($changes, function ($a, $b) + uasort($changes, function ($a, $b) { return $a['last_update'] < $b['last_update']; }); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -3108,23 +4605,20 @@ public function showSubConnections(Request $request, Response $response, $args): $myItem = $item::with('connections')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/connections'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/connections'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myConnections = []; foreach ($myItem->connections as $connection) { - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/computers/" . $connection->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/computers/', $connection->id); + $entity = ''; - if ($connection->entity != null) { - $entity = $connection->entity->name; + $entity_url = ''; + if ($connection->entity !== null) + { + $entity = $connection->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $connection->entity->id); } if ($connection->pivot->is_dynamic == 1) @@ -3142,6 +4636,7 @@ public function showSubConnections(Request $request, Response $response, $args): 'auto' => $connection->pivot->is_dynamic, 'auto_val' => $auto_val, 'entity' => $entity, + 'entity_url' => $entity_url, 'serial_number' => $connection->serial, 'inventaire_number' => $connection->otherserial, ]; @@ -3178,46 +4673,53 @@ public function showSubAssociatedItems(Request $request, Response $response, $ar $item2 = new $this->associateditems_model(); $myItem2 = $item2::where($this->associateditems_model_id, $args['id'])->get(); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/associateditems'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/associateditems'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myAssociatedItems = []; foreach ($myItem2 as $associateditem) { - $item3 = new $associateditem->item_type(); + $associateditem_new = str_ireplace('Item_device', 'ItemDevice', $associateditem->item_type); + $item3 = new $associateditem_new(); $myItem3 = $item3->find($associateditem->item_id); + if ($myItem3 !== null) + { + $type = $item3->getTable(); + $type_fr = $item3->getTitle(); - if ($myItem3 != null) { $name = $myItem3->name; - if ($name == '') { + if ($name == '') + { $name = '(' . $myItem3->id . ')'; } - $url = ''; - if ($rootUrl2 != '') { - $table = $item3->getTable(); - if ($table != '') { - $url = $rootUrl2 . "/" . $table . "/" . $myItem3->id; - } + if (substr($type, 0, 6) == 'device') + { + $url = $this->genereRootUrl2Link($rootUrl2, '/devices/' . $type . '/', $myItem3->id); + } + else + { + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem3->id); } + $entity = ''; - if ($myItem3->entity != null) { - $entity = $myItem3->entity->name; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); } - $type = $item3->getTitle(); $serial_number = $myItem3->serial; + $inventaire_number = $myItem3->otherserial; $myAssociatedItems[] = [ - 'type' => $type, + 'type' => $type_fr, 'name' => $name, 'url' => $url, 'entity' => $entity, + 'entity_url' => $entity_url, 'serial_number' => $serial_number, 'inventaire_number' => $inventaire_number, ]; @@ -3225,11 +4727,11 @@ public function showSubAssociatedItems(Request $request, Response $response, $ar } // tri ordre alpha - usort($myAssociatedItems, function ($a, $b) + uasort($myAssociatedItems, function ($a, $b) { return strtolower($a['name']) > strtolower($b['name']); }); - usort($myAssociatedItems, function ($a, $b) + uasort($myAssociatedItems, function ($a, $b) { return strtolower($a['type']) > strtolower($b['type']); }); @@ -3250,7 +4752,6 @@ public function showSubAssociatedItems(Request $request, Response $response, $ar return $view->render($response, 'subitem/associateditems.html.twig', (array)$viewData); } - protected function canRightRead() { $profileright = \App\Models\Profileright:: @@ -3309,7 +4810,6 @@ protected function canRightCreate() return false; } - protected function canRightUpdate() { $profileright = \App\Models\Profileright:: @@ -3390,12 +4890,8 @@ public function showSubCosts(Request $request, Response $response, $args): Respo $myItem = $item::with('costs')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/costs'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/costs'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myCosts = []; $myTicketCosts = []; @@ -3414,13 +4910,10 @@ public function showSubCosts(Request $request, Response $response, $args): Respo { $budget = ''; $budget_url = ''; - if ($current_cost->budget != null) + if ($current_cost->budget !== null) { $budget = $current_cost->budget->name; - - if ($rootUrl2 != '') { - $budget_url = $rootUrl2 . "/budgets/" . $current_cost->budget->id; - } + $budget_url = $this->genereRootUrl2Link($rootUrl2, '/budgets/', $current_cost->budget->id); } $cost = 0; @@ -3428,23 +4921,28 @@ public function showSubCosts(Request $request, Response $response, $args): Respo $cost_time = 0; $cost_fixed = 0; $cost_material = 0; - if ($this->costchoose == 'ticket') { - if (isset($current_cost->actiontime)) { + if (($this->choose == 'tickets') || ($this->choose == 'problems') || ($this->choose == 'changes')) + { + if (isset($current_cost->actiontime)) + { $actiontime = $current_cost->actiontime; $total_actiontime = $total_actiontime + $actiontime; } - if (isset($current_cost->cost_time)) { + if (isset($current_cost->cost_time)) + { $cost_time = $current_cost->cost_time; $total_cost_time = $total_cost_time + $this->computeCostTime($actiontime, $cost_time); } - if (isset($current_cost->cost_fixed)) { + if (isset($current_cost->cost_fixed)) + { $cost_fixed = $current_cost->cost_fixed; $total_cost_fixed = $total_cost_fixed + ($cost_fixed); } - if (isset($current_cost->cost_material)) { + if (isset($current_cost->cost_material)) + { $cost_material = $current_cost->cost_material; $total_cost_material = $total_cost_material + ($cost_material); @@ -3452,8 +4950,11 @@ public function showSubCosts(Request $request, Response $response, $args): Respo $cost = $this->computeTotalCost($actiontime, $cost_time, $cost_fixed, $cost_material); $total_cost = $total_cost + ($cost); - } else { - if (isset($current_cost->cost)) { + } + else + { + if (isset($current_cost->cost)) + { $cost = $current_cost->cost; $total_cost = $total_cost + ($cost); @@ -3475,37 +4976,34 @@ public function showSubCosts(Request $request, Response $response, $args): Respo } // tri de la + récente à la + ancienne - usort($myCosts, function ($a, $b) + uasort($myCosts, function ($a, $b) { - return strtolower($a['begin_date']) > strtolower($b['begin_date']); + return $a['begin_date'] > $b['begin_date']; }); - if ($this->costchoose == 'project') { + if ($this->choose == 'projects') + { $item2 = new $this->model(); $myItem2 = $item2::with('tasks')->find($args['id']); - - - foreach ($myItem2->tasks as $current_task) { - if ($current_task->tickets != null) + foreach ($myItem2->tasks as $current_task) + { + if ($current_task->tickets !== null) { - foreach ($current_task->tickets as $current_ticket) { + foreach ($current_task->tickets as $current_ticket) + { $ticket = $current_ticket->name; - $ticket_url = ''; - if ($rootUrl2 != '') { - $ticket_url = $rootUrl2 . "/tickets/" . $current_ticket->id; - } + $ticket_url = $this->genereRootUrl2Link($rootUrl2, '/tickets/', $current_ticket->id); - if ($current_ticket->costs != null) { - foreach ($current_ticket->costs as $current_cost) { + if ($current_ticket->costs !== null) + { + foreach ($current_ticket->costs as $current_cost) + { $budget = ''; $budget_url = ''; - if ($current_cost->budget != null) + if ($current_cost->budget !== null) { $budget = $current_cost->budget->name; - - if ($rootUrl2 != '') { - $budget_url = $rootUrl2 . "/budgets/" . $current_cost->budget->id; - } + $budget_url = $this->genereRootUrl2Link($rootUrl2, '/budgets/', $current_cost->budget->id); } $cost = 0; @@ -3513,24 +5011,27 @@ public function showSubCosts(Request $request, Response $response, $args): Respo $cost_time = 0; $cost_fixed = 0; $cost_material = 0; - - if (isset($current_cost->actiontime)) { + if (isset($current_cost->actiontime)) + { $actiontime = $current_cost->actiontime; $ticket_costs_total_actiontime = $ticket_costs_total_actiontime + $actiontime; } - if (isset($current_cost->cost_time)) { + if (isset($current_cost->cost_time)) + { $cost_time = $current_cost->cost_time; $ticket_costs_total_cost_time = $ticket_costs_total_cost_time + $this->computeCostTime($actiontime, $cost_time); } - if (isset($current_cost->cost_fixed)) { + if (isset($current_cost->cost_fixed)) + { $cost_fixed = $current_cost->cost_fixed; $ticket_costs_total_cost_fixed = $ticket_costs_total_cost_fixed + ($cost_fixed); } - if (isset($current_cost->cost_material)) { + if (isset($current_cost->cost_material)) + { $cost_material = $current_cost->cost_material; $ticket_costs_total_cost_material = $ticket_costs_total_cost_material + ($cost_material); @@ -3539,7 +5040,6 @@ public function showSubCosts(Request $request, Response $response, $args): Respo $cost = $this->computeTotalCost($actiontime, $cost_time, $cost_fixed, $cost_material); $ticket_costs_total_cost = $ticket_costs_total_cost + ($cost); - $myTicketCosts[$current_cost->id] = [ 'ticket' => $ticket, 'ticket_url' => $ticket_url, @@ -3561,15 +5061,14 @@ public function showSubCosts(Request $request, Response $response, $args): Respo } // tri de la + récente à la + ancienne - usort($myTicketCosts, function ($a, $b) + uasort($myTicketCosts, function ($a, $b) { - return strtolower($a['begin_date']) > strtolower($b['begin_date']); + return $a['begin_date'] > $b['begin_date']; }); $total_costs = $total_cost + $ticket_costs_total_cost; } - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -3590,7 +5089,7 @@ public function showSubCosts(Request $request, Response $response, $args): Respo $viewData->addData('ticket_costs_total_cost_fixed', $this->showCosts($ticket_costs_total_cost_fixed)); $viewData->addData('ticket_costs_total_cost_material', $this->showCosts($ticket_costs_total_cost_material)); $viewData->addData('total_costs', $this->showCosts($total_costs)); - $viewData->addData('show', $this->costchoose); + $viewData->addData('show', $this->choose); $viewData->addTranslation('name', $translator->translate('Name')); $viewData->addTranslation('begin_date', $translator->translate('Start date')); @@ -3617,21 +5116,26 @@ public function timestampToString($time, $display_sec = true, $use_days = true) $time = (float)$time; $sign = ''; - if ($time < 0) { + if ($time < 0) + { $sign = '- '; $time = abs($time); } $time = floor($time); // Force display seconds if time is null - if ($time < $this->MINUTE_TIMESTAMP) { + if ($time < $this->MINUTE_TIMESTAMP) + { $display_sec = true; } $units = $this->getTimestampTimeUnits($time); - if ($use_days) { - if ($units['day'] > 0) { - if ($display_sec) { + if ($use_days) + { + if ($units['day'] > 0) + { + if ($display_sec) + { return sprintf( $translator->translate('%1$s%2$d days %3$d hours %4$d minutes %5$d seconds'), $sign, @@ -3649,14 +5153,19 @@ public function timestampToString($time, $display_sec = true, $use_days = true) $units['minute'] ); } - } else { - if ($units['day'] > 0) { + } + else + { + if ($units['day'] > 0) + { $units['hour'] += 24 * $units['day']; } } - if ($units['hour'] > 0) { - if ($display_sec) { + if ($units['hour'] > 0) + { + if ($display_sec) + { return sprintf( $translator->translate('%1$s%2$d hours %3$d minutes %4$d seconds'), $sign, @@ -3668,8 +5177,10 @@ public function timestampToString($time, $display_sec = true, $use_days = true) return sprintf($translator->translate('%1$s%2$d hours %3$d minutes'), $sign, $units['hour'], $units['minute']); } - if ($units['minute'] > 0) { - if ($display_sec) { + if ($units['minute'] > 0) + { + if ($display_sec) + { return sprintf( $translator->translate('%1$s%2$d minutes %3$d seconds'), $sign, @@ -3684,7 +5195,8 @@ public function timestampToString($time, $display_sec = true, $use_days = true) ); } - if ($display_sec) { + if ($display_sec) + { return sprintf( $translator->translatePlural('%1$s%2$s second', '%1$s%2$s seconds', $units['second']), $sign, @@ -3708,15 +5220,18 @@ public function getTimestampTimeUnits($time) $out['second'] = $time % $this->MINUTE_TIMESTAMP; $time -= $out['second']; - if ($time > 0) { + if ($time > 0) + { $out['minute'] = ($time % $this->HOUR_TIMESTAMP) / $this->MINUTE_TIMESTAMP; $time -= $out['minute'] * $this->MINUTE_TIMESTAMP; - if ($time > 0) { + if ($time > 0) + { $out['hour'] = ($time % $this->DAY_TIMESTAMP) / $this->HOUR_TIMESTAMP; $time -= $out['hour'] * $this->HOUR_TIMESTAMP; - if ($time > 0) { + if ($time > 0) + { $out['day'] = $time / $this->DAY_TIMESTAMP; } } @@ -3738,4 +5253,1736 @@ public function computeTotalCost($actiontime, $cost_time, $cost_fixed, $cost_mat { return $this->showCosts(($actiontime * $cost_time / $this->HOUR_TIMESTAMP) + $cost_fixed + $cost_material); } + + public function getDaysOfWeekArray() + { + global $translator; + + $tab = []; + $tab[0] = $translator->translate("Sunday"); + $tab[1] = $translator->translate("Monday"); + $tab[2] = $translator->translate("Tuesday"); + $tab[3] = $translator->translate("Wednesday"); + $tab[4] = $translator->translate("Thursday"); + $tab[5] = $translator->translate("Friday"); + $tab[6] = $translator->translate("Saturday"); + + return $tab; + } + + public function getMonthsOfYearArray() + { + global $translator; + + $tab = []; + $tab[1] = $translator->translate("January"); + $tab[2] = $translator->translate("February"); + $tab[3] = $translator->translate("March"); + $tab[4] = $translator->translate("April"); + $tab[5] = $translator->translate("May"); + $tab[6] = $translator->translate("June"); + $tab[7] = $translator->translate("July"); + $tab[8] = $translator->translate("August"); + $tab[9] = $translator->translate("September"); + $tab[10] = $translator->translate("October"); + $tab[11] = $translator->translate("November"); + $tab[12] = $translator->translate("December"); + + return $tab; + } + + public function showSubItems(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/items'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myItems = []; + foreach ($myItem->items as $current_item) + { + $item3 = new $current_item->item_type(); + $myItem3 = $item3->find($current_item->item_id); + if ($myItem3 !== null) + { + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); + + if (array_key_exists($type, $myItems) !== true) + { + $myItems[$type] = [ + 'type' => $type, + 'name' => $type_fr, + 'items' => [], + ]; + } + + $current_id = $myItem3->id; + + $name = $myItem3->name; + if ($name == '') + { + $name = '(' . $current_id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $current_id); + + $location = ''; + $location_url = ''; + if ($myItem3->location !== null) + { + $location = $myItem3->location->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $myItem3->location->id); + } + + $documents = []; + if ($myItem3->documents !== null) + { + foreach ($myItem3->documents as $document) + { + $url_document = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + + $documents[$document->id] = [ + 'name' => $document->name, + 'url' => $url_document, + ]; + } + } + + $myItems[$type]['items'][$current_id][$current_item->id] = [ + 'name' => $name, + 'url' => $url, + 'location' => $location, + 'location_url' => $location_url, + 'documents' => $documents, + ]; + } + } + + // tri ordre alpha + uasort($myItems, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('items', $myItems); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('location', $translator->translatePlural('Location', 'Locations', 2)); + $viewData->addTranslation('documents', $translator->translatePlural('Document', 'Documents', 2)); + + return $view->render($response, 'subitem/items.html.twig', (array)$viewData); + } + + public function getValueWithUnit($value, $unit, $decimals = 0) + { + global $translator; + + $formatted_number = is_numeric($value) + ? $this->formatNumber($value, false, $decimals) + : $value; + + if (strlen($unit) == 0) + { + return $formatted_number; + } + + switch ($unit) + { + case 'year': + //TRANS: %s is a number of years + return sprintf($translator->translatePlural('%s year', '%s years', $value), $formatted_number); + + case 'month': + //TRANS: %s is a number of months + return sprintf($translator->translatePlural('%s month', '%s months', $value), $formatted_number); + + case 'day': + //TRANS: %s is a number of days + return sprintf($translator->translatePlural('%s day', '%s days', $value), $formatted_number); + + case 'hour': + //TRANS: %s is a number of hours + return sprintf($translator->translatePlural('%s hour', '%s hours', $value), $formatted_number); + + case 'minute': + //TRANS: %s is a number of minutes + return sprintf($translator->translatePlural('%s minute', '%s minutes', $value), $formatted_number); + + case 'second': + //TRANS: %s is a number of seconds + return sprintf($translator->translatePlural('%s second', '%s seconds', $value), $formatted_number); + + case 'millisecond': + //TRANS: %s is a number of milliseconds + return sprintf($translator->translatePlural('%s millisecond', '%s milliseconds', $value), $formatted_number); + + case 'auto': + return $this->getSize($value * 1024 * 1024); + + case '%': + return sprintf($translator->translate('%s%%'), $formatted_number); + + default: + return sprintf($translator->translate('%1$s %2$s'), $formatted_number, $unit); + } + } + + public function formatNumber($number, $edit = false, $forcedecimal = -1) + { + if (!(isset($_SESSION['glpinumber_format']))) + { + $_SESSION['glpinumber_format'] = ''; + } + + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") + { + $number = 0; + } + elseif ($number == "-") + { // used for not defines value (from Infocom::Amort, p.e.) + return "-"; + } + + $number = doubleval($number); + $decimal = 2; + if ($forcedecimal >= 0) + { + $decimal = $forcedecimal; + } + + // Edit: clean display for mysql + if ($edit) + { + return number_format($number, $decimal, '.', ''); + } + + // Display: clean display + switch ($_SESSION['glpinumber_format']) + { + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); + + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); + + default: // English + return number_format($number, $decimal, '.', ','); + } + } + + public function getSize($size) + { + global $translator; + + //TRANS: list of unit (o for octet) + $bytes = [ + $translator->translate('o'), + $translator->translate('Kio'), + $translator->translate('Mio'), + $translator->translate('Gio'), + $translator->translate('Tio') + ]; + foreach ($bytes as $val) + { + if ($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + //TRANS: %1$s is a number maybe float or string and %2$s the unit + return sprintf($translator->translate('%1$s %2$s'), round($size, 2), $val); + } + + public function showSubChanges(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item::with(['changes'])->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/changes'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $changes = []; + foreach ($myItem->changes as $change) + { + $add_to_tab = false; + if ($this->choose == 'tickets') + { + if ($change->pivot->ticket_id == $args['id']) + { + $add_to_tab = true; + } + } + if ($this->choose == 'problems') + { + if ($change->pivot->problem_id == $args['id']) + { + $add_to_tab = true; + } + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/changes/', $change->id); + + $status = $this->getStatusArray()[$change->status]; + + $entity = ''; + $entity_url = ''; + if ($change->entity !== null) + { + $entity = $change->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $change->entity->id); + } + + $priority = $this->getPriorityArray()[$change->priority]; + + $requesters = []; + if ($change->requester !== null) + { + foreach ($change->requester as $requester) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $requester->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $this->genereUserName($requester->name, $requester->lastname, $requester->firstname), + ]; + } + } + if ($change->requestergroup !== null) + { + foreach ($change->requestergroup as $requestergroup) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $requestergroup->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $requestergroup->completename, + ]; + } + } + + $technicians = []; + if ($change->technician !== null) + { + foreach ($change->technician as $technician) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $technician->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $this->genereUserName($technician->name, $technician->lastname, $technician->firstname), + ]; + } + } + if ($change->techniciangroup !== null) + { + foreach ($change->techniciangroup as $techniciangroup) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $techniciangroup->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $techniciangroup->completename, + ]; + } + } + + $category = ''; + $category_url = ''; + if ($change->itilcategorie !== null) + { + $category = $change->itilcategorie->name; + $category_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/categories/', $change->itilcategorie->id); + } + + $planification = 0; // TODO + + if ($add_to_tab) + { + $changes[$change->id] = [ + 'url' => $url, + 'status' => $status, + 'date' => $change->date, + 'last_update' => $change->updated_at, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'priority' => $priority, + 'requesters' => $requesters, + 'technicians' => $technicians, + 'title' => $change->name, + 'category' => $category, + 'category_url' => $category_url, + 'planification' => $planification, + ]; + } + } + + // tri de la + récente à la + ancienne + uasort($changes, function ($a, $b) + { + return $a['last_update'] < $b['last_update']; + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('changes', $changes); + + $viewData->addTranslation('changes', $translator->translatePlural('Change', 'Changes', 2)); + $viewData->addTranslation('status', $translator->translate('Status')); + $viewData->addTranslation('date', $translator->translatePlural('Date', 'Dates', 1)); + $viewData->addTranslation('last_update', $translator->translate('Last update')); + $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); + $viewData->addTranslation('priority', $translator->translate('Priority')); + $viewData->addTranslation('requesters', $translator->translatePlural('Requester', 'Requesters', 1)); + $viewData->addTranslation('technicians', $translator->translate('Assigned')); + $viewData->addTranslation( + 'associated_items', + $translator->translatePlural('Associated element', 'Associated elements', 2) + ); + $viewData->addTranslation('category', $translator->translate('Category')); + $viewData->addTranslation('title', $translator->translate('Title')); + $viewData->addTranslation('planification', $translator->translate('Planification')); + $viewData->addTranslation('no_change_found', $translator->translate('No change found.')); + + return $view->render($response, 'subitem/itilchanges.html.twig', (array)$viewData); + } + + public function showSubProjects(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $ticketclass = str_ireplace('\\v1\\Controllers\\', '\\Models\\', get_class($this)); + $item2 = new \App\Models\Itilproject(); + $myItem2 = $item2->where(['item_id' => $args['id'], 'item_type' => $ticketclass])->get(); + + $rootUrl = $this->genereRootUrl($request, '/projects'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myProjects = []; + foreach ($myItem2 as $project) + { + $item3 = new \App\Models\Project(); + $myItem3 = $item3->find($project->project_id); + if ($myItem3 !== null) + { + $name = $myItem3->name; + + $url = $this->genereRootUrl2Link($rootUrl2, '/projects/', $myItem3->id); + + $status = ''; + $status_color = ''; + if ($myItem3->state !== null) + { + $status = $myItem3->state->name; + $status_color = $myItem3->state->color; + } + + $open_date = $myItem3->date; + + $last_update = $myItem3->updated_at; + + $entity = ''; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); + } + + $priority = $this->getPriorityArray()[$myItem3->priority]; + + $manager = ''; + $manager_url = ''; + if ($myItem3->user !== null) + { + $manager = $this->genereUserName($myItem3->user->name, $myItem3->user->lastname, $myItem3->user->firstname); + $manager_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $myItem3->user->id); + } + + $manager_group = ''; + $manager_group_url = ''; + if ($myItem3->group !== null) + { + $manager_group = $myItem3->group->completename; + $manager_group_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $myItem3->group->id); + } + + $myProjects[] = [ + 'name' => $name, + 'url' => $url, + 'status' => $status, + 'status_color' => $status_color, + 'open_date' => $open_date, + 'last_update' => $last_update, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'priority' => $priority, + 'manager' => $manager, + 'manager_url' => $manager_url, + 'manager_group' => $manager_group, + 'manager_group_url' => $manager_group_url, + ]; + } + } + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('projects', $myProjects); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('status', $translator->translate('Status')); + $viewData->addTranslation('open_date', $translator->translatePlural('Date', 'Dates', 1)); + $viewData->addTranslation('last_update', $translator->translate('Last update')); + $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); + $viewData->addTranslation('priority', $translator->translate('Priority')); + $viewData->addTranslation('manager', $translator->translate('Manager')); + $viewData->addTranslation('manager_group', $translator->translate('Manager group')); + + return $view->render($response, 'subitem/projects.html.twig', (array)$viewData); + } + + public function showSubTickets(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + if ($this->choose == 'changes') + { + $item2 = new \App\Models\ChangeTicket(); + $myItem2 = $item2::where('change_id', $args['id'])->get(); + } + if ($this->choose == 'problems') + { + $item2 = new \App\Models\ProblemTicket(); + $myItem2 = $item2::where('problem_id', $args['id'])->get(); + } + if ($this->choose == 'projecttasks') + { + $item2 = new \App\Models\ProjecttaskTicket(); + $myItem2 = $item2::where('projecttask_id', $args['id'])->get(); + } + + $rootUrl = $this->genereRootUrl($request, '/tickets'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $tickets = []; + foreach ($myItem2 as $current_item) + { + $item3 = new \App\Models\Ticket(); + $myItem3 = $item3->find($current_item->ticket_id); + if ($myItem3 !== null) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/tickets/', $myItem3->id); + + $status = $this->getStatusArray()[$myItem3->status]; + + $entity = ''; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); + } + + $priority = $this->getPriorityArray()[$myItem3->priority]; + + $requesters = []; + if ($myItem3->requester !== null) + { + foreach ($myItem3->requester as $requester) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $requester->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $this->genereUserName($requester->name, $requester->lastname, $requester->firstname), + ]; + } + } + if ($myItem3->requestergroup !== null) + { + foreach ($myItem3->requestergroup as $requestergroup) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $requestergroup->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $requestergroup->completename, + ]; + } + } + + $technicians = []; + if ($myItem3->technician !== null) + { + foreach ($myItem3->technician as $technician) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $technician->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $this->genereUserName($technician->name, $technician->lastname, $technician->firstname), + ]; + } + } + if ($myItem3->techniciangroup !== null) + { + foreach ($myItem3->techniciangroup as $techniciangroup) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $techniciangroup->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $techniciangroup->completename, + ]; + } + } + + $associated_items = []; + $item4 = new \App\Models\ItemTicket(); + $myItem4 = $item4::where('ticket_id', $current_item->ticket_id)->get(); + if ($myItem4 !== null) + { + foreach ($myItem4 as $val) + { + $item5 = new $val->item_type(); + $myItem5 = $item5->find($val->item_id); + if ($myItem5 !== null) + { + $type5_fr = $item5->getTitle(); + $type5 = $item5->getTable(); + + $name5 = $myItem5->name; + + $url5 = $this->genereRootUrl2Link($rootUrl2, '/' . $type5 . '/', $myItem5->id); + + if ($type5_fr != '') + { + $type5_fr = $type5_fr . ' - '; + } + + $associated_items[] = [ + 'type' => $type5_fr, + 'name' => $name5, + 'url' => $url5, + ]; + } + } + + if (empty($associated_items)) + { + $associated_items[] = [ + 'type' => '', + 'name' => $translator->translate('General'), + 'url' => '', + ]; + } + } + + $category = ''; + $category_url = ''; + if ($myItem3->category !== null) + { + $category = $myItem3->category->name; + $category_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/categories/', $myItem3->category->id); + } + + $planification = 0; // TODO + + $tickets[$myItem3->id] = [ + 'url' => $url, + 'status' => $status, + 'date' => $myItem3->date, + 'last_update' => $myItem3->updated_at, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'priority' => $priority, + 'requesters' => $requesters, + 'technicians' => $technicians, + 'associated_items' => $associated_items, + 'title' => $myItem3->name, + 'category' => $category, + 'category_url' => $category_url, + 'planification' => $planification, + ]; + } + } + + // tri de la + récente à la + ancienne + uasort($tickets, function ($a, $b) + { + return $a['last_update'] > $b['last_update']; + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('tickets', $tickets); + + $viewData->addTranslation('status', $translator->translate('Status')); + $viewData->addTranslation('date', $translator->translatePlural('Date', 'Dates', 1)); + $viewData->addTranslation('last_update', $translator->translate('Last update')); + $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); + $viewData->addTranslation('priority', $translator->translate('Priority')); + $viewData->addTranslation('requesters', $translator->translatePlural('Requester', 'Requesters', 1)); + $viewData->addTranslation('technicians', $translator->translate('Assigned')); + $viewData->addTranslation( + 'associated_items', + $translator->translatePlural('Associated element', 'Associated elements', 2) + ); + $viewData->addTranslation('category', $translator->translate('Category')); + $viewData->addTranslation('title', $translator->translate('Title')); + $viewData->addTranslation('planification', $translator->translate('Planification')); + $viewData->addTranslation('no_ticket_found', $translator->translate('No ticket found.')); + + return $view->render($response, 'subitem/itiltickets.html.twig', (array)$viewData); + } + + public function showStats(Request $request, Response $response, $args) + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item::find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/stats'); + + $feeds = []; + + $feeds[] = [ + 'date' => $myItem->date, + 'text' => $translator->translate('Opening date'), + 'icon' => 'pencil alternate', + 'color' => 'blue' + ]; + + $feeds[] = [ + 'date' => $myItem->time_to_resolve, + 'text' => $translator->translate('Time to resolve'), + 'icon' => 'hourglass half', + 'color' => 'blue' + ]; + if ($myItem->status >= 5) + { + $feeds[] = [ + 'date' => $myItem->solvedate, + 'text' => $translator->translate('Resolution date'), + 'icon' => 'check circle', + 'color' => 'blue' + ]; + } + if ($myItem->status == 6) + { + $feeds[] = [ + 'date' => $myItem->closedate, + 'text' => $translator->translate('Closing date'), + 'icon' => 'flag checkered', + 'color' => 'blue' + ]; + } + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('feeds', $feeds); + + return $view->render($response, 'subitem/stats.html.twig', (array) $viewData); + } + + public function showSubApprovals(Request $request, Response $response, $args) + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item::with('approvals')->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/approvals'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myApprovals = []; + foreach ($myItem->approvals as $approval) + { + $status = $this->getApprovalStatus()[$approval->status]; + + $request_date = $approval->submission_date; + + $request_user = ''; + $request_user_url = ''; + if ($approval->usersrequester !== null) + { + $request_user = $this->genereUserName( + $approval->usersrequester->name, + $approval->usersrequester->lastname, + $approval->usersrequester->firstname + ); + $request_user_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $approval->usersrequester->id); + } + + $request_comment = $approval->comment_submission; + + $approval_date = $approval->validation_date; + + $approval_user = ''; + $approval_user_url = ''; + if ($approval->uservalidate !== null) + { + $approval_user = $this->genereUserName( + $approval->uservalidate->name, + $approval->uservalidate->lastname, + $approval->uservalidate->firstname + ); + $approval_user_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $approval->uservalidate->id); + } + + $approval_comment = $approval->comment_validation; + + $myApprovals[] = [ + 'status' => $status, + 'request_date' => $request_date, + 'request_user' => $request_user, + 'request_user_url' => $request_user_url, + 'request_comment' => $request_comment, + 'approval_date' => $approval_date, + 'approval_user' => $approval_user, + 'approval_user_url' => $approval_user_url, + 'approval_comment' => $approval_comment, + ]; + } + + // tri de la + récente à la + ancienne + uasort($myApprovals, function ($a, $b) + { + return $a['request_date'] < $b['request_date']; + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('approvals', $myApprovals); + + $viewData->addTranslation('status', $translator->translate('Status')); + $viewData->addTranslation('request_date', $translator->translate('Request date')); + $viewData->addTranslation('request_user', $translator->translate('Approval requester')); + $viewData->addTranslation('request_comment', $translator->translate('Request comments')); + $viewData->addTranslation('approval_date', $translator->translate('Approval status')); + $viewData->addTranslation('approval_user', $translator->translate('Approver')); + $viewData->addTranslation('approval_comment', $translator->translate('Approval comments')); + + return $view->render($response, 'subitem/approvals.html.twig', (array)$viewData); + } + + public function getApprovalStatus() + { + global $translator; + + return [ + $this->APPROVAL_WAITING => [ + 'title' => $translator->translate('Waiting for approval'), + 'color' => '#FFC65D', + ], + $this->APPROVAL_REFUSED => [ + 'title' => $translator->translate('Refused'), + 'color' => '#cf9b9b', + ], + $this->APPROVAL_ACCEPTED => [ + 'title' => $translator->translate('Granted'), + 'color' => '#9BA563', + ], + ]; + } + + public function genereUserName($name, $lastname = '', $firstname = '', $add_name = false) + { + $ret = $lastname . ' ' . $firstname; + $ret = trim($ret); + + if ($ret != '') + { + if ($add_name === true) + { + $ret = $ret . ' (' . $name . ')'; + } + } + else + { + $ret = $name; + } + + return $ret; + } + + public function showSubInfocoms(Request $request, Response $response, $args) + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item::with('infocom')->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/infocom'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myInfocom = []; + foreach ($myItem->infocom as $infocom) + { + $comment = $infocom->comment; + + $entity_id = $infocom->entity_id; + $entity_name = ''; + if ($infocom->entity !== null) + { + $entity_name = $infocom->entity->completename; + } + + $is_recursive = $infocom->is_recursive; + + $buy_date = $infocom->buy_date; + + $use_date = $infocom->use_date; + + $warranty_duration = $infocom->warranty_duration; + + $warranty_info = $infocom->warranty_info; + + $supplier_id = $infocom->supplier_id; + $supplier_name = ''; + if ($infocom->supplier !== null) + { + $supplier_name = $infocom->supplier->name; + } + + $order_number = $infocom->order_number; + + $delivery_number = $infocom->delivery_number; + + $immo_number = $infocom->immo_number; + + $value = $this->showCosts($infocom->value); + + $warranty_value = $this->showCosts($infocom->warranty_value); + + $sink_time = $infocom->sink_time; + + $sink_type = $infocom->sink_type; + + $sink_coeff = $infocom->sink_coeff; + + $bill = $infocom->bill; + + $budget_id = $infocom->budget_id; + $budget_name = ''; + if ($infocom->budget !== null) + { + $budget_name = $infocom->budget->name; + } + + $alert = $infocom->alert; + + $order_date = $infocom->order_date; + + $delivery_date = $infocom->delivery_date; + + $inventory_date = $infocom->inventory_date; + + $warranty_date = $infocom->warranty_date; + + $decommission_date = ''; + $decommission_date_tmp = explode(' ', $infocom->decommission_date); + if (count($decommission_date_tmp) == 2) + { + $decommission_date = $decommission_date_tmp[0]; + } + + $businesscriticity_id = $infocom->businesscriticity_id; + $businesscriticity_name = ''; + if ($infocom->businesscriticity !== null) + { + $businesscriticity_name = $infocom->businesscriticity->name; + } + + $myInfocom = [ + 'comment' => $comment, + 'entity_id' => $entity_id, + 'entity_name' => $entity_name, + 'is_recursive' => $is_recursive, + 'buy_date' => $buy_date, + 'use_date' => $use_date, + 'warranty_duration' => $warranty_duration, + 'warranty_info' => $warranty_info, + 'supplier_id' => $supplier_id, + 'supplier_name' => $supplier_name, + 'order_number' => $order_number, + 'delivery_number' => $delivery_number, + 'immo_number' => $immo_number, + 'value' => $value, + 'warranty_value' => $warranty_value, + 'sink_time' => $sink_time, + 'sink_type' => $sink_type, + 'sink_coeff' => $sink_coeff, + 'bill' => $bill, + 'budget_id' => $budget_id, + 'budget_name' => $budget_name, + 'alert' => $alert, + 'order_date' => $order_date, + 'delivery_date' => $delivery_date, + 'inventory_date' => $inventory_date, + 'warranty_date' => $warranty_date, + 'decommission_date' => $decommission_date, + 'businesscriticity_id' => $businesscriticity_id, + 'businesscriticity_name' => $businesscriticity_name, + ]; + } + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $getDefs = $item->getSpecificFunction('getDefinitionInfocom'); + $myItemData = []; + if (count($myInfocom) > 0) + { + $myItemData = [ + 'order_date' => $myInfocom['order_date'], + 'buy_date' => $myInfocom['buy_date'], + 'delivery_date' => $myInfocom['delivery_date'], + 'use_date' => $myInfocom['use_date'], + 'inventory_date' => $myInfocom['inventory_date'], + 'decommission_date' => $myInfocom['decommission_date'], + 'supplier' => [ + 'id' => $myInfocom['supplier_id'], + 'name' => $myInfocom['supplier_name'], + ], + 'budget' => [ + 'id' => $myInfocom['budget_id'], + 'name' => $myInfocom['budget_name'], + ], + 'order_number' => $myInfocom['order_number'], + 'immo_number' => $myInfocom['immo_number'], + 'bill' => $myInfocom['bill'], + 'delivery_number' => $myInfocom['delivery_number'], + 'value' => $myInfocom['value'], + 'warranty_value' => $myInfocom['warranty_value'], + 'sink_type' => $myInfocom['sink_type'], + 'sink_time' => $myInfocom['sink_time'], + 'sink_coeff' => $myInfocom['sink_coeff'], + 'businesscriticity' => [ + 'id' => $myInfocom['businesscriticity_id'], + 'name' => $myInfocom['businesscriticity_name'], + ], + 'comment' => $myInfocom['comment'], + 'warranty_date' => $myInfocom['warranty_date'], + 'warranty_duration' => $myInfocom['warranty_duration'], + 'warranty_info' => $myInfocom['warranty_info'], + ]; + } + $myItemDataObject = json_decode(json_encode($myItemData)); + + $viewData->addData('fields', $item->getFormData($myItemDataObject, $getDefs)); + + return $view->render($response, 'subitem/infocom.html.twig', (array)$viewData); + } + + public function showSubAttachedItems(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $item2 = new $this->associateditems_model(); + $myItem2 = $item2::where($this->associateditems_model_id, $args['id'])->get(); + + $rootUrl = $this->genereRootUrl($request, '/attacheditems'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myAttachedItems = []; + $nb_total = 0; + foreach ($myItem2 as $current_attacheditem) + { + $item3 = new $current_attacheditem->item_type(); + $myItem3 = $item3->find($current_attacheditem->item_id); + if ($myItem3 !== null) + { + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); + + $entity = ''; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); + } + + $nom = $myItem3->name; + + $nom_url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem3->id); + + $serial = $myItem3->serial; + + $otherserial = $myItem3->otherserial; + + $first = false; + if (array_key_exists($type, $myAttachedItems) !== true) + { + $myAttachedItems[$type] = [ + 'name' => $type_fr, + 'nb' => 0, + 'items' => [], + ]; + + $first = true; + } + + $status = ''; + if ($this->choose == 'contracts') + { + if ($myItem3->state !== null) + { + $status = $myItem3->state->name; + } + } + + $domain_relation = ''; + $domain_relation_url = ''; + if ($this->choose == 'domains') + { + if ($current_attacheditem->relation !== null) + { + $domain_relation = $current_attacheditem->relation->name; + $domain_relation_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/domainrelations/', + $current_attacheditem->relation->id + ); + } + } + + $value = ''; + if ($this->choose == 'budgets') + { + $value = $this->showCosts($current_attacheditem->value); + } + + $myAttachedItems[$type]['items'][$myItem3->id] = [ + 'first' => $first, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'nom' => $nom, + 'nom_url' => $nom_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'status' => $status, + 'domain_relation' => $domain_relation, + 'domain_relation_url' => $domain_relation_url, + 'value' => $value, + ]; + + $myAttachedItems[$type]['nb'] = count($myAttachedItems[$type]['items']); + } + } + + if ($this->choose == 'budgets') + { + $item2 = new \App\Models\Contractcost(); + $myItem2 = $item2::where('budget_id', $args['id'])->get(); + foreach ($myItem2 as $current_attacheditem) + { + $item3 = new \App\Models\Contract(); + $myItem3 = $item3->find($current_attacheditem->contract_id); + if ($myItem3 !== null) + { + $type_fr = $translator->translatePlural('Contract', 'Contract', 1); + $type = 'contracts'; + + $entity = ''; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); + } + + $nom = $myItem3->name; + + $nom_url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem3->id); + + $serial = ''; + + $otherserial = ''; + + $first = false; + if (array_key_exists($type, $myAttachedItems) !== true) + { + $myAttachedItems[$type] = [ + 'name' => $type_fr, + 'nb' => 0, + 'items' => [], + ]; + + $first = true; + } + + $status = ''; + + $domain_relation = ''; + $domain_relation_url = ''; + + $value = $this->showCosts($current_attacheditem->cost); + + if (array_key_exists($myItem3->id, $myAttachedItems[$type]['items']) !== true) + { + $myAttachedItems[$type]['items'][$myItem3->id] = [ + 'first' => $first, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'nom' => $nom, + 'nom_url' => $nom_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'status' => $status, + 'domain_relation' => $domain_relation, + 'domain_relation_url' => $domain_relation_url, + 'value' => $value, + ]; + } + else + { + $sum = $myAttachedItems[$type]['items'][$myItem3->id]['value'] + $value; + $myAttachedItems[$type]['items'][$myItem3->id]['value'] = $this->showCosts($sum); + } + + $myAttachedItems[$type]['nb'] = count($myAttachedItems[$type]['items']); + } + } + + $item2 = new \App\Models\Ticketcost(); + $myItem2 = $item2::where('budget_id', $args['id'])->get(); + foreach ($myItem2 as $current_attacheditem) + { + $item3 = new \App\Models\Ticket(); + $myItem3 = $item3->find($current_attacheditem->ticket_id); + if ($myItem3 !== null) + { + $type_fr = $translator->translatePlural('Ticket', 'Tickets', 1); + $type = 'tickets'; + + $entity = ''; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); + } + + $nom = $myItem3->name; + + $nom_url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem3->id); + + $serial = ''; + + $otherserial = ''; + + $first = false; + if (array_key_exists($type, $myAttachedItems) !== true) + { + $myAttachedItems[$type] = [ + 'name' => $type_fr, + 'nb' => 0, + 'items' => [], + ]; + + $first = true; + } + + $status = ''; + + $domain_relation = ''; + $domain_relation_url = ''; + + $value = $this->computeTotalCost( + $current_attacheditem->actiontime, + $current_attacheditem->cost_time, + $current_attacheditem->cost_fixed, + $current_attacheditem->cost_material + ); + + if (array_key_exists($myItem3->id, $myAttachedItems[$type]['items']) !== true) + { + $myAttachedItems[$type]['items'][$myItem3->id] = [ + 'first' => $first, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'nom' => $nom, + 'nom_url' => $nom_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'status' => $status, + 'domain_relation' => $domain_relation, + 'domain_relation_url' => $domain_relation_url, + 'value' => $value, + ]; + } + else + { + $sum = $myAttachedItems[$type]['items'][$myItem3->id]['value'] + $value; + $myAttachedItems[$type]['items'][$myItem3->id]['value'] = $this->showCosts($sum); + } + + $myAttachedItems[$type]['nb'] = count($myAttachedItems[$type]['items']); + } + } + + $item2 = new \App\Models\Problemcost(); + $myItem2 = $item2::where('budget_id', $args['id'])->get(); + foreach ($myItem2 as $current_attacheditem) + { + $item3 = new \App\Models\Problem(); + $myItem3 = $item3->find($current_attacheditem->problem_id); + if ($myItem3 !== null) + { + $type_fr = $translator->translatePlural('Problem', 'Problems', 1); + $type = 'problems'; + + $entity = ''; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); + } + + $nom = $myItem3->name; + + $nom_url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem3->id); + + $serial = ''; + + $otherserial = ''; + + $first = false; + if (array_key_exists($type, $myAttachedItems) !== true) + { + $myAttachedItems[$type] = [ + 'name' => $type_fr, + 'nb' => 0, + 'items' => [], + ]; + + $first = true; + } + + $status = ''; + + $domain_relation = ''; + $domain_relation_url = ''; + + $value = $this->computeTotalCost( + $current_attacheditem->actiontime, + $current_attacheditem->cost_time, + $current_attacheditem->cost_fixed, + $current_attacheditem->cost_material + ); + + if (array_key_exists($myItem3->id, $myAttachedItems[$type]['items']) !== true) + { + $myAttachedItems[$type]['items'][$myItem3->id] = [ + 'first' => $first, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'nom' => $nom, + 'nom_url' => $nom_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'status' => $status, + 'domain_relation' => $domain_relation, + 'domain_relation_url' => $domain_relation_url, + 'value' => $value, + ]; + } + else + { + $sum = $myAttachedItems[$type]['items'][$myItem3->id]['value'] + $value; + $myAttachedItems[$type]['items'][$myItem3->id]['value'] = $this->showCosts($sum); + } + + $myAttachedItems[$type]['nb'] = count($myAttachedItems[$type]['items']); + } + } + + $item2 = new \App\Models\Changecost(); + $myItem2 = $item2::where('budget_id', $args['id'])->get(); + foreach ($myItem2 as $current_attacheditem) + { + $item3 = new \App\Models\Change(); + $myItem3 = $item3->find($current_attacheditem->change_id); + if ($myItem3 !== null) + { + $type_fr = $translator->translatePlural('Change', 'Changes', 1); + $type = 'changes'; + + $entity = ''; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); + } + + $nom = $myItem3->name; + + $nom_url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem3->id); + + $serial = ''; + + $otherserial = ''; + + $first = false; + if (array_key_exists($type, $myAttachedItems) !== true) + { + $myAttachedItems[$type] = [ + 'name' => $type_fr, + 'nb' => 0, + 'items' => [], + ]; + + $first = true; + } + + $status = ''; + + $domain_relation = ''; + $domain_relation_url = ''; + + $value = $this->computeTotalCost( + $current_attacheditem->actiontime, + $current_attacheditem->cost_time, + $current_attacheditem->cost_fixed, + $current_attacheditem->cost_material + ); + + if (array_key_exists($myItem3->id, $myAttachedItems[$type]['items']) !== true) + { + $myAttachedItems[$type]['items'][$myItem3->id] = [ + 'first' => $first, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'nom' => $nom, + 'nom_url' => $nom_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'status' => $status, + 'domain_relation' => $domain_relation, + 'domain_relation_url' => $domain_relation_url, + 'value' => $value, + ]; + } + else + { + $sum = $myAttachedItems[$type]['items'][$myItem3->id]['value'] + $value; + $myAttachedItems[$type]['items'][$myItem3->id]['value'] = $this->showCosts($sum); + } + + $myAttachedItems[$type]['nb'] = count($myAttachedItems[$type]['items']); + } + } + + $item2 = new \App\Models\Projectcost(); + $myItem2 = $item2::where('budget_id', $args['id'])->get(); + foreach ($myItem2 as $current_attacheditem) + { + $item3 = new \App\Models\Project(); + $myItem3 = $item3->find($current_attacheditem->project_id); + if ($myItem3 !== null) + { + $type_fr = $translator->translatePlural('Project', 'Projects', 1); + $type = 'projects'; + + $entity = ''; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); + } + + $nom = $myItem3->name; + + $nom_url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem3->id); + + $serial = ''; + + $otherserial = ''; + + $first = false; + if (array_key_exists($type, $myAttachedItems) !== true) + { + $myAttachedItems[$type] = [ + 'name' => $type_fr, + 'nb' => 0, + 'items' => [], + ]; + + $first = true; + } + + $status = ''; + + $domain_relation = ''; + $domain_relation_url = ''; + + $value = $this->showCosts($current_attacheditem->cost); + + if (array_key_exists($myItem3->id, $myAttachedItems[$type]['items']) !== true) + { + $myAttachedItems[$type]['items'][$myItem3->id] = [ + 'first' => $first, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'nom' => $nom, + 'nom_url' => $nom_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'status' => $status, + 'domain_relation' => $domain_relation, + 'domain_relation_url' => $domain_relation_url, + 'value' => $value, + ]; + } + else + { + $sum = $myAttachedItems[$type]['items'][$myItem3->id]['value'] + $value; + $myAttachedItems[$type]['items'][$myItem3->id]['value'] = $this->showCosts($sum); + } + + $myAttachedItems[$type]['nb'] = count($myAttachedItems[$type]['items']); + } + } + } + + // tri par ordre alpha + uasort($myAttachedItems, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + foreach (array_keys($myAttachedItems) as $type_item) + { + $nb_total = $nb_total + $myAttachedItems[$type_item]['nb']; + + if (stristr($type_item, 'consumable')) + { + $myAttachedItems[$type_item]['name'] = $myAttachedItems[$type_item]['name'] . ' (' . $type_item . ')'; + } + if (stristr($type_item, 'cartridge')) + { + $myAttachedItems[$type_item]['name'] = $myAttachedItems[$type_item]['name'] . ' (' . $type_item . ')'; + } + } + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('attacheditems', $myAttachedItems); + $viewData->addData('show', $this->choose); + $viewData->addData('nb_total', $nb_total); + + $viewData->addTranslation('type', $translator->translatePlural('Type', 'Types', 1)); + $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('serial', $translator->translate('Serial number')); + $viewData->addTranslation('otherserial', $translator->translate('Inventory number')); + $viewData->addTranslation('status', $translator->translate('State')); + $viewData->addTranslation('domain_relation', $translator->translatePlural( + 'Domain relation', + 'Domains relations', + 1 + )); + $viewData->addTranslation('value', $translator->translate('Value')); + $viewData->addTranslation('total', $translator->translate('Total')); + + return $view->render($response, 'subitem/attacheditems.html.twig', (array)$viewData); + } + + public function genereRootUrl($request, $param = '') + { + $rootUrl = $this->getUrlWithoutQuery($request); + if ($param != '') + { + $rootUrl = rtrim($rootUrl, '/' . $param); + } + + return $rootUrl; + } + + public function genereRootUrl2($rootUrl, $param = '') + { + $rootUrl2 = ''; + if (($this->rootUrl2 != '') && ($param != '')) + { + $rootUrl2 = rtrim($rootUrl, $param); + } + + return $rootUrl2; + } + + public function genereRootUrl2Link($rootUrl2, $param, $id) + { + $rootUrl2Link = ''; + if (($rootUrl2 != '') && ($param != '') && ($param != '//') && ($id != '')) + { + $rootUrl2Link = $rootUrl2 . $param . $id; + } + + return $rootUrl2Link; + } + + public function showSubReservations(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/reservations'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myReservations = []; + $myReservations_old = []; + foreach ($myItem->reservations as $current_reservationitem) + { + if ($current_reservationitem->reservations !== null) + { + foreach ($current_reservationitem->reservations as $current_reservation) + { + $begin = $current_reservation->begin; + + $end = $current_reservation->end; + + $user = ''; + $user_url = ''; + if ($current_reservation->user !== null) + { + $user = $this->genereUserName( + $current_reservation->user->name, + $current_reservation->user->lastname, + $current_reservation->user->firstname + ); + $user_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $current_reservation->user->id); + } + + $comment = $current_reservation->comment; + + + if ($end < date('Y-m-d H:i:s')) + { + $myReservations_old[] = [ + 'begin' => $begin, + 'end' => $end, + 'user' => $user, + 'user_url' => $user_url, + 'comment' => $comment, + ]; + } + else + { + $myReservations[] = [ + 'begin' => $begin, + 'end' => $end, + 'user' => $user, + 'user_url' => $user_url, + 'comment' => $comment, + ]; + } + } + } + } + + // tri par ordre + ancien + uasort($myReservations, function ($a, $b) + { + return $a['begin'] > $b['begin']; + }); + // tri par ordre + recent + uasort($myReservations_old, function ($a, $b) + { + return $a['begin'] < $b['begin']; + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('reservations', $myReservations); + $viewData->addData('reservations_old', $myReservations_old); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('start_date', $translator->translate('Start date')); + $viewData->addTranslation('end_date', $translator->translate('End date')); + $viewData->addTranslation('by', $translator->translate('By')); + $viewData->addTranslation('comment', $translator->translatePlural('Comment', 'Comments', 2)); + $viewData->addTranslation('current_reservations', $translator->translate('Current and future reservations')); + $viewData->addTranslation('past_reservations', $translator->translate('Past reservations')); + $viewData->addTranslation('no_reservations', $translator->translate('No reservation')); + + return $view->render($response, 'subitem/reservations.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Computer.php b/src/v1/Controllers/Computer.php index 4f73aeb645..699a72e8f4 100644 --- a/src/v1/Controllers/Computer.php +++ b/src/v1/Controllers/Computer.php @@ -11,6 +11,7 @@ final class Computer extends Common { protected $model = '\App\Models\Computer'; protected $rootUrl2 = '/computers/'; + protected $choose = 'computers'; public function getAll(Request $request, Response $response, $args): Response { @@ -39,35 +40,87 @@ public function showSubSoftwares(Request $request, Response $response, $args): R $myItem = $item::with('softwareversions', 'antiviruses')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/softwares'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $myAntiviruses = []; foreach ($myItem->antiviruses as $antivirus) { + $antivirus_url = $this->genereRootUrl2Link($rootUrl2, '/computerantivirus/', $antivirus->id); + $manufacturer = ''; - if ($antivirus->manufacturer != null) + $manufacturer_url = ''; + if ($antivirus->manufacturer !== null) { $manufacturer = $antivirus->manufacturer->name; + $manufacturer_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/manufacturers/', + $antivirus->manufacturer->id + ); + } + + $is_dynamic = $antivirus->is_dynamic; + if ($is_dynamic == 1) + { + $is_dynamic_val = $translator->translate('Yes'); + } + else + { + $is_dynamic_val = $translator->translate('No'); + } + + $is_active = $antivirus->is_active; + if ($is_active == 1) + { + $is_active_val = $translator->translate('Yes'); + } + else + { + $is_active_val = $translator->translate('No'); + } + + $is_uptodate = $antivirus->is_uptodate; + if ($is_uptodate == 1) + { + $is_uptodate_val = $translator->translate('Yes'); + } + else + { + $is_uptodate_val = $translator->translate('No'); } $myAntiviruses[] = [ - 'name' => $antivirus->name, - 'publisher' => $manufacturer, - 'is_dynamic' => $antivirus->is_dynamic, - 'version' => $antivirus->antivirus_version, - 'signature' => $antivirus->signature_version, - 'is_active' => $antivirus->is_active, - 'is_uptodate' => $antivirus->is_uptodate + 'name' => $antivirus->name, + 'antivirus_url' => $antivirus_url, + 'manufacturer' => $manufacturer, + 'manufacturer_url' => $manufacturer_url, + 'is_dynamic' => $is_dynamic, + 'is_dynamic_val' => $is_dynamic_val, + 'version' => $antivirus->antivirus_version, + 'signature' => $antivirus->signature_version, + 'is_active' => $is_active, + 'is_active_val' => $is_active_val, + 'is_uptodate' => $is_uptodate, + 'is_uptodate_val' => $is_uptodate_val, ]; } $softwares = []; foreach ($myItem->softwareversions as $softwareversion) { + $softwareversion_url = $this->genereRootUrl2Link($rootUrl2, '/softwareversions/', $softwareversion->id); + + $software_url = $this->genereRootUrl2Link($rootUrl2, '/softwares/', $softwareversion->software->id); + $softwares[] = [ - 'id' => $softwareversion->id, - 'name' => $softwareversion->name, - 'software' => [ + 'id' => $softwareversion->id, + 'name' => $softwareversion->name, + 'url' => $softwareversion_url, + 'software' => [ 'id' => $softwareversion->software->id, 'name' => $softwareversion->software->name, + 'url' => $software_url, ] ]; } @@ -85,10 +138,9 @@ public function showSubSoftwares(Request $request, Response $response, $args): R $viewData->addTranslation('software', $translator->translatePlural('Software', 'Software', 1)); $viewData->addTranslation('version', $translator->translatePlural('Version', 'Versions', 1)); - $viewData->addTranslation('antivirus', $translator->translatePlural('Antivirus', 'Antiviruses', 1)); $viewData->addTranslation('antivirus_version', $translator->translate('Antivirus version')); - $viewData->addTranslation('publisher', $translator->translate('Publisher')); + $viewData->addTranslation('manufacturer', $translator->translatePlural('Manufacturer', 'Manufacturers', 1)); $viewData->addTranslation('is_dynamic', $translator->translate('Automatic inventory')); $viewData->addTranslation('is_active', $translator->translate('Active')); $viewData->addTranslation('is_uptodate', $translator->translate('Up to date')); @@ -116,7 +168,6 @@ protected function getInformationTop($item, $request) 'link' => $basePath . '/view/computers/' . $item->id . '/operatingsystem', ]; - $memoryTotalSize = 0; foreach ($myItem->memories as $memory) { @@ -178,25 +229,46 @@ public function showSubVirtualization(Request $request, Response $response, $arg $myItem = $item::with('virtualization')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/virtualization'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $myVirtualmachines = []; foreach ($myItem->virtualization as $virtualization) { $virtualmachinesystem = ''; + $virtualmachinesystem_url = ''; if ($virtualization->system !== null) { $virtualmachinesystem = $virtualization->system->name; + $virtualmachinestate_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/virtualmachinesystems/', + $virtualization->system->id + ); } $virtualmachinemodel = ''; + $virtualmachinemodel_url = ''; if ($virtualization->type !== null) { $virtualmachinemodel = $virtualization->type->name; + $virtualmachinemodel_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/virtualmachinetypes/', + $virtualization->type->id + ); } $virtualmachinestate = ''; + $virtualmachinestate_url = ''; if ($virtualization->state !== null) { $virtualmachinestate = $virtualization->state->name; + $virtualmachinestate_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/virtualmachinestates/', + $virtualization->state->id + ); } if ($virtualization->is_dynamic == 1) @@ -209,7 +281,7 @@ public function showSubVirtualization(Request $request, Response $response, $arg } $machine_host = ''; - if ($virtualization->uuid != '' && $virtualization->uuid != null) + if ($virtualization->uuid != '' && $virtualization->uuid !== null) { $item2 = new \App\Models\Computer(); $myItem2 = $item2::where('uuid', $virtualization->uuid)->get(); @@ -221,23 +293,23 @@ public function showSubVirtualization(Request $request, Response $response, $arg } $myVirtualmachines[] = [ - 'name' => $virtualization->name, - 'comment' => $virtualization->comment, - 'auto' => $virtualization->is_dynamic, - 'auto_val' => $auto_val, - 'virtualmachinesystem' => $virtualmachinesystem, - 'virtualmachinemodel' => $virtualmachinemodel, - 'virtualmachinestate' => $virtualmachinestate, - 'uuid' => $virtualization->uuid, - 'nb_proc' => $virtualization->vcpu, - 'memory' => $virtualization->ram, - 'machine_host' => $machine_host, + 'name' => $virtualization->name, + 'comment' => $virtualization->comment, + 'auto' => $virtualization->is_dynamic, + 'auto_val' => $auto_val, + 'virtualmachinesystem' => $virtualmachinesystem, + 'virtualmachinesystem_url' => $virtualmachinesystem_url, + 'virtualmachinemodel' => $virtualmachinemodel, + 'virtualmachinemodel_url' => $virtualmachinemodel_url, + 'virtualmachinestate' => $virtualmachinestate, + 'virtualmachinestate_url' => $virtualmachinestate_url, + 'uuid' => $virtualization->uuid, + 'nb_proc' => $virtualization->vcpu, + 'memory' => $virtualization->ram, + 'machine_host' => $machine_host, ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/virtualization'); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -283,36 +355,35 @@ public function showSubConnections(Request $request, Response $response, $args): $item2 = new \App\Models\Computeritem(); $myItem2 = $item2::where('computer_id', $args['id'])->get(); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/connections'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/connections'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myConnections = []; foreach ($myItem2 as $connection) { $item3 = new $connection->item_type(); $myItem3 = $item3->find($connection->item_id); + if ($myItem3 !== null) + { + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); - if ($myItem3 != null) { $name = $myItem3->name; - if ($name == '') { + if ($name == '') + { $name = '(' . $myItem3->id . ')'; } - $url = ''; - if ($rootUrl2 != '') { - $table = $item3->getTable(); - if ($table != '') { - $url = $rootUrl2 . "/" . $table . "/" . $myItem3->id; - } - } + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem3->id); + $entity = ''; - if ($myItem3->entity != null) { - $entity = $myItem3->entity->name; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); } + if ($connection->is_dynamic == 1) { $auto_val = $translator->translate('Yes'); @@ -322,18 +393,19 @@ public function showSubConnections(Request $request, Response $response, $args): $auto_val = $translator->translate('No'); } - $type = $item3->getTitle(); $serial_number = $myItem3->serial; + $inventaire_number = $myItem3->otherserial; $myConnections[] = [ - 'type' => $type, + 'type' => $type_fr, 'name' => $name, 'url' => $url, 'auto' => $connection->is_dynamic, 'auto_val' => $auto_val, 'entity' => $entity, + 'entity_url' => $entity_url, 'serial_number' => $serial_number, 'inventaire_number' => $inventaire_number, ]; @@ -341,11 +413,11 @@ public function showSubConnections(Request $request, Response $response, $args): } // tri ordre alpha - usort($myConnections, function ($a, $b) + uasort($myConnections, function ($a, $b) { return strtolower($a['name']) > strtolower($b['name']); }); - usort($myConnections, function ($a, $b) + uasort($myConnections, function ($a, $b) { return strtolower($a['type']) > strtolower($b['type']); }); diff --git a/src/v1/Controllers/Computerantivirus.php b/src/v1/Controllers/Computerantivirus.php new file mode 100644 index 0000000000..f449b3606a --- /dev/null +++ b/src/v1/Controllers/Computerantivirus.php @@ -0,0 +1,31 @@ +commonGetAll($request, $response, $args, $item); + } + + public function showItem(Request $request, Response $response, $args): Response + { + $item = new \App\Models\Computerantivirus(); + return $this->commonShowItem($request, $response, $args, $item); + } + + public function updateItem(Request $request, Response $response, $args): Response + { + $item = new \App\Models\Computerantivirus(); + return $this->commonUpdateItem($request, $response, $args, $item); + } +} diff --git a/src/v1/Controllers/Consumableitem.php b/src/v1/Controllers/Consumableitem.php index 7284affeca..3f48a0a020 100644 --- a/src/v1/Controllers/Consumableitem.php +++ b/src/v1/Controllers/Consumableitem.php @@ -41,12 +41,8 @@ public function showSubConsumables(Request $request, Response $response, $args): $myItem = $item::with('consumables')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/consumables'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/consumables'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myConsumables_new = []; $myConsumables_use = []; @@ -56,41 +52,49 @@ public function showSubConsumables(Request $request, Response $response, $args): foreach ($myItem->consumables as $consumable) { $status = ''; + $date_in = $consumable->date_in; - $date_out = $consumable->date_out; + $url = ''; - if ($date_out != null) { + $date_out = $consumable->date_out; + if ($date_out !== null) + { $status = $translator->translatePlural('consumable' . "\004" . 'Used', 'consumable' . "\004" . 'Used', 1); $total_use = $total_use + 1; - } else { + } + else + { $status = $translator->translatePlural('consumable' . "\004" . 'New', 'consumable' . "\004" . 'New', 1); $total_new = $total_new + 1; } - $total = $total + 1; $given_to = ''; - if (($consumable->item_type != '') && ($consumable->item_id != 0)) { + if (($consumable->item_type != '') && ($consumable->item_id != 0)) + { $item3 = new $consumable->item_type(); $myItem3 = $item3->find($consumable->item_id); - $given_to = $myItem3->name; - - $url = ''; - if ($rootUrl2 != '') { - $table = $item3->getTable(); - if ($table != '') { - $url = $rootUrl2 . "/" . $table . "/" . $myItem3->id; - } + if ($myItem3 !== null) + { + $type = $item3->getTable(); + + $given_to = $myItem3->name; + + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem3->id); } } + $total = $total + 1; - if ($consumable->date_out == null) { + if ($consumable->date_out == null) + { $myConsumables_new[] = [ 'status' => $status, 'date_in' => $date_in, ]; - } else { + } + else + { $myConsumables_use[] = [ 'status' => $status, 'url' => $url, diff --git a/src/v1/Controllers/Contract.php b/src/v1/Controllers/Contract.php index 39cf37ca7c..2e9186421b 100644 --- a/src/v1/Controllers/Contract.php +++ b/src/v1/Controllers/Contract.php @@ -10,7 +10,9 @@ final class Contract extends Common { protected $model = '\App\Models\Contract'; protected $rootUrl2 = '/contracts/'; - protected $costchoose = 'contract'; + protected $choose = 'contracts'; + protected $associateditems_model = '\App\Models\ContractItem'; + protected $associateditems_model_id = 'contract_id'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Datacenter.php b/src/v1/Controllers/Datacenter.php index 8672552f6a..014415d435 100644 --- a/src/v1/Controllers/Datacenter.php +++ b/src/v1/Controllers/Datacenter.php @@ -4,10 +4,12 @@ use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; +use Slim\Views\Twig; final class Datacenter extends Common { protected $model = '\App\Models\Datacenter'; + protected $rootUrl2 = '/datacenters/'; public function getAll(Request $request, Response $response, $args): Response { @@ -26,4 +28,47 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Datacenter(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubDcrooms(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/dcrooms'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myDcrooms = []; + foreach ($myItem->dcrooms as $current_dcroom) + { + $name = $current_dcroom->name; + + $url = $this->genereRootUrl2Link($rootUrl2, '/dcrooms/', $current_dcroom->id); + + $myDcrooms[] = [ + 'name' => $name, + 'url' => $url, + ]; + } + + // tri ordre alpha + uasort($myDcrooms, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('dcrooms', $myDcrooms); + + $viewData->addTranslation('name', $translator->translate('Name')); + + return $view->render($response, 'subitem/dcrooms.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Dcroom.php b/src/v1/Controllers/Dcroom.php new file mode 100644 index 0000000000..f8b90fdb6e --- /dev/null +++ b/src/v1/Controllers/Dcroom.php @@ -0,0 +1,31 @@ +commonGetAll($request, $response, $args, $item); + } + + public function showItem(Request $request, Response $response, $args): Response + { + $item = new \App\Models\Dcroom(); + return $this->commonShowItem($request, $response, $args, $item); + } + + public function updateItem(Request $request, Response $response, $args): Response + { + $item = new \App\Models\Dcroom(); + return $this->commonUpdateItem($request, $response, $args, $item); + } +} diff --git a/src/v1/Controllers/Devicebattery.php b/src/v1/Controllers/Devicebattery.php index e86152d307..7af9ceb594 100644 --- a/src/v1/Controllers/Devicebattery.php +++ b/src/v1/Controllers/Devicebattery.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Devicebattery extends Common { protected $model = '\App\Models\Devicebattery'; - protected $rootUrl2 = '/devicebatteries/'; + protected $rootUrl2 = '/devices/devicebatteries/'; + protected $choose = 'devicebatteries'; public function getAll(Request $request, Response $response, $args): Response { @@ -29,4 +31,116 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Devicebattery(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubItems(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/items'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myItems = []; + foreach ($myItem->items as $current_item) + { + $item3 = new $current_item->item_type(); + $myItem3 = $item3->find($current_item->item_id); + if ($myItem3 !== null) + { + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); + + if (array_key_exists($type, $myItems) !== true) + { + $myItems[$type] = [ + 'type' => $type, + 'name' => $type_fr, + 'items' => [], + ]; + } + + $current_id = $myItem3->id; + + $name = $myItem3->name; + if ($name == '') + { + $name = '(' . $current_id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $current_id); + + $location = ''; + $location_url = ''; + if ($myItem3->location !== null) + { + $location = $myItem3->location->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $myItem3->location->id); + } + + $documents = []; + if ($myItem3->documents !== null) + { + foreach ($myItem3->documents as $document) + { + $url_document = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + + $documents[$document->id] = [ + 'name' => $document->name, + 'url' => $url_document, + ]; + } + } + + $serial = ''; + $manufacturing_date = ''; + if ($type == 'computers') + { + if (isset($current_item->serial)) + { + $serial = $current_item->serial; + } + if (isset($current_item->manufacturing_date)) + { + $manufacturing_date = $current_item->manufacturing_date; + } + } + + $myItems[$type]['items'][$current_id][$current_item->id] = [ + 'name' => $name, + 'url' => $url, + 'location' => $location, + 'location_url' => $location_url, + 'documents' => $documents, + 'serial' => $serial, + 'manufacturing_date' => $manufacturing_date, + ]; + } + } + + // tri ordre alpha + uasort($myItems, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('items', $myItems); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('location', $translator->translatePlural('Location', 'Locations', 2)); + $viewData->addTranslation('documents', $translator->translatePlural('Document', 'Documents', 2)); + $viewData->addTranslation('serial', $translator->translate('Serial number')); + $viewData->addTranslation('manufacturing_date', $translator->translate('Manufacturing date')); + + return $view->render($response, 'subitem/items.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Devicecase.php b/src/v1/Controllers/Devicecase.php index f8f24241ed..fde3dbcbf7 100644 --- a/src/v1/Controllers/Devicecase.php +++ b/src/v1/Controllers/Devicecase.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Devicecase extends Common { protected $model = '\App\Models\Devicecase'; - protected $rootUrl2 = '/devicecases/'; + protected $rootUrl2 = '/devices/devicecases/'; + protected $choose = 'devicecases'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Devicecontrol.php b/src/v1/Controllers/Devicecontrol.php index 9fe66a94ad..56601eda13 100644 --- a/src/v1/Controllers/Devicecontrol.php +++ b/src/v1/Controllers/Devicecontrol.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Devicecontrol extends Common { protected $model = '\App\Models\Devicecontrol'; - protected $rootUrl2 = '/devicecontrols/'; + protected $rootUrl2 = '/devices/devicecontrols/'; + protected $choose = 'devicecontrols'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Devicedrive.php b/src/v1/Controllers/Devicedrive.php index a476872d9e..475ce6f826 100644 --- a/src/v1/Controllers/Devicedrive.php +++ b/src/v1/Controllers/Devicedrive.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Devicedrive extends Common { protected $model = '\App\Models\Devicedrive'; - protected $rootUrl2 = '/devicedrives/'; + protected $rootUrl2 = '/devices/devicedrives/'; + protected $choose = 'devicedrives'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Devicefirmware.php b/src/v1/Controllers/Devicefirmware.php index 38164097e6..c80e26d502 100644 --- a/src/v1/Controllers/Devicefirmware.php +++ b/src/v1/Controllers/Devicefirmware.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Devicefirmware extends Common { protected $model = '\App\Models\Devicefirmware'; - protected $rootUrl2 = '/devicefirmwares/'; + protected $rootUrl2 = '/devices/devicefirmwares/'; + protected $choose = 'devicefirmwares'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Devicegeneric.php b/src/v1/Controllers/Devicegeneric.php index 283be304e2..f6958cd5f5 100644 --- a/src/v1/Controllers/Devicegeneric.php +++ b/src/v1/Controllers/Devicegeneric.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Devicegeneric extends Common { protected $model = '\App\Models\Devicegeneric'; - protected $rootUrl2 = '/devicegenerics/'; + protected $rootUrl2 = '/devices/devicegenerics/'; + protected $choose = 'devicegenerics'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Devicegraphiccard.php b/src/v1/Controllers/Devicegraphiccard.php index 77a3f19a8a..c2a9648b8d 100644 --- a/src/v1/Controllers/Devicegraphiccard.php +++ b/src/v1/Controllers/Devicegraphiccard.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Devicegraphiccard extends Common { protected $model = '\App\Models\Devicegraphiccard'; - protected $rootUrl2 = '/devicegraphiccards/'; + protected $rootUrl2 = '/devices/devicegraphiccards/'; + protected $choose = 'devicegraphiccards'; public function getAll(Request $request, Response $response, $args): Response { @@ -29,4 +31,112 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Devicegraphiccard(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubItems(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/items'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myItems = []; + foreach ($myItem->items as $current_item) + { + $item3 = new $current_item->item_type(); + $myItem3 = $item3->find($current_item->item_id); + if ($myItem3 !== null) + { + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); + + if (array_key_exists($type, $myItems) !== true) + { + $myItems[$type] = [ + 'type' => $type, + 'name' => $type_fr, + 'items' => [], + ]; + } + + $current_id = $myItem3->id; + + $name = $myItem3->name; + if ($name == '') + { + $name = '(' . $current_id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $current_id); + + $location = ''; + $location_url = ''; + if ($myItem3->location !== null) + { + $location = $myItem3->location->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $myItem3->location->id); + } + + $documents = []; + if ($myItem3->documents !== null) + { + foreach ($myItem3->documents as $document) + { + $url_document = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + + $documents[$document->id] = [ + 'name' => $document->name, + 'url' => $url_document, + ]; + } + } + + $memory = ''; + if ($type == 'computers') + { + if (isset($current_item->memory)) + { + $memory = $current_item->memory; + } + } + + $myItems[$type]['items'][$current_id][$current_item->id] = [ + 'name' => $name, + 'url' => $url, + 'location' => $location, + 'location_url' => $location_url, + 'documents' => $documents, + 'memory' => $memory, + ]; + } + } + + // tri ordre alpha + uasort($myItems, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('items', $myItems); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('location', $translator->translatePlural('Location', 'Locations', 2)); + $viewData->addTranslation('documents', $translator->translatePlural('Document', 'Documents', 2)); + $viewData->addTranslation( + 'memory_mio', + sprintf('%1$s (%2$s)', $translator->translatePlural('Memory', 'Memories', 1), $translator->translate('Mio')) + ); + + return $view->render($response, 'subitem/items.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Deviceharddrive.php b/src/v1/Controllers/Deviceharddrive.php index 5e5dbc3f0e..0d96fc33a1 100644 --- a/src/v1/Controllers/Deviceharddrive.php +++ b/src/v1/Controllers/Deviceharddrive.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Deviceharddrive extends Common { protected $model = '\App\Models\Deviceharddrive'; - protected $rootUrl2 = '/deviceharddrives/'; + protected $rootUrl2 = '/devices/deviceharddrives/'; + protected $choose = 'deviceharddrives'; public function getAll(Request $request, Response $response, $args): Response { @@ -29,4 +31,117 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Deviceharddrive(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubItems(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/items'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myItems = []; + foreach ($myItem->items as $current_item) + { + $item3 = new $current_item->item_type(); + $myItem3 = $item3->find($current_item->item_id); + if ($myItem3 !== null) + { + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); + + if (array_key_exists($type, $myItems) !== true) + { + $myItems[$type] = [ + 'type' => $type, + 'name' => $type_fr, + 'items' => [], + ]; + } + + $current_id = $myItem3->id; + + $name = $myItem3->name; + if ($name == '') + { + $name = '(' . $current_id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $current_id); + + $location = ''; + $location_url = ''; + if ($myItem3->location !== null) + { + $location = $myItem3->location->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $myItem3->location->id); + } + + $documents = []; + if ($myItem3->documents !== null) + { + foreach ($myItem3->documents as $document) + { + $url_document = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + + $documents[$document->id] = [ + 'name' => $document->name, + 'url' => $url_document, + ]; + } + } + + $serial = ''; + if ($type == 'computers') + { + if (isset($current_item->serial)) + { + $serial = $current_item->serial; + } + } + $capacity = $current_item->capacity; + + $myItems[$type]['items'][$current_id][$current_item->id] = [ + 'name' => $name, + 'url' => $url, + 'location' => $location, + 'location_url' => $location_url, + 'documents' => $documents, + 'serial' => $serial, + 'capacity' => $capacity, + ]; + } + } + + // tri ordre alpha + uasort($myItems, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('items', $myItems); + $viewData->addData('show', $this->choose); + + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('location', $translator->translatePlural('Location', 'Locations', 2)); + $viewData->addTranslation('documents', $translator->translatePlural('Document', 'Documents', 2)); + $viewData->addTranslation('serial', $translator->translate('Serial number')); + $viewData->addTranslation('capacity_mio', sprintf( + '%1$s (%2$s)', + $translator->translate('Capacity'), + $translator->translate('Mio') + )); + + return $view->render($response, 'subitem/items.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Devicememory.php b/src/v1/Controllers/Devicememory.php index 78741c7f82..5a36ef3ed1 100644 --- a/src/v1/Controllers/Devicememory.php +++ b/src/v1/Controllers/Devicememory.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Devicememory extends Common { protected $model = '\App\Models\Devicememory'; - protected $rootUrl2 = '/devicememories/'; + protected $rootUrl2 = '/devices/devicememories/'; + protected $choose = 'devicememories'; public function getAll(Request $request, Response $response, $args): Response { @@ -29,4 +31,117 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Devicememory(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubItems(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/items'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myItems = []; + foreach ($myItem->items as $current_item) + { + $item3 = new $current_item->item_type(); + $myItem3 = $item3->find($current_item->item_id); + if ($myItem3 !== null) + { + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); + + if (array_key_exists($type, $myItems) !== true) + { + $myItems[$type] = [ + 'type' => $type, + 'name' => $type_fr, + 'items' => [], + ]; + } + + $current_id = $myItem3->id; + + $name = $myItem3->name; + if ($name == '') + { + $name = '(' . $current_id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $current_id); + + $location = ''; + $location_url = ''; + if ($myItem3->location !== null) + { + $location = $myItem3->location->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $myItem3->location->id); + } + + $documents = []; + if ($myItem3->documents !== null) + { + foreach ($myItem3->documents as $document) + { + $url_document = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + + $documents[$document->id] = [ + 'name' => $document->name, + 'url' => $url_document, + ]; + } + } + + $serial = ''; + if ($type == 'computers') + { + if (isset($current_item->serial)) + { + $serial = $current_item->serial; + } + } + + $size = $current_item->size; + + $myItems[$type]['items'][$current_id][$current_item->id] = [ + 'name' => $name, + 'url' => $url, + 'location' => $location, + 'location_url' => $location_url, + 'documents' => $documents, + 'serial' => $serial, + 'size' => $size, + ]; + } + } + + // tri ordre alpha + uasort($myItems, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('items', $myItems); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('location', $translator->translatePlural('Location', 'Locations', 2)); + $viewData->addTranslation('documents', $translator->translatePlural('Document', 'Documents', 2)); + $viewData->addTranslation('serial', $translator->translate('Serial number')); + $viewData->addTranslation('size_mio', sprintf( + '%1$s (%2$s)', + $translator->translate('Size'), + $translator->translate('Mio') + )); + + return $view->render($response, 'subitem/items.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Devicemotherboard.php b/src/v1/Controllers/Devicemotherboard.php index 2776d3d3d9..55f103497d 100644 --- a/src/v1/Controllers/Devicemotherboard.php +++ b/src/v1/Controllers/Devicemotherboard.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Devicemotherboard extends Common { protected $model = '\App\Models\Devicemotherboard'; - protected $rootUrl2 = '/devicemotherboards/'; + protected $rootUrl2 = '/devices/devicemotherboards/'; + protected $choose = 'devicemotherboards'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Devicenetworkcard.php b/src/v1/Controllers/Devicenetworkcard.php index 5e61f605c0..ead4de827e 100644 --- a/src/v1/Controllers/Devicenetworkcard.php +++ b/src/v1/Controllers/Devicenetworkcard.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Devicenetworkcard extends Common { protected $model = '\App\Models\Devicenetworkcard'; - protected $rootUrl2 = '/devicenetworkcards/'; + protected $rootUrl2 = '/devices/devicenetworkcards/'; + protected $choose = 'devicenetworkcards'; public function getAll(Request $request, Response $response, $args): Response { @@ -29,4 +31,102 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Devicenetworkcard(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubItems(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/items'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myItems = []; + foreach ($myItem->items as $current_item) + { + $item3 = new $current_item->item_type(); + $myItem3 = $item3->find($current_item->item_id); + if ($myItem3 !== null) + { + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); + + if (array_key_exists($type, $myItems) !== true) + { + $myItems[$type] = [ + 'type' => $type, + 'name' => $type_fr, + 'items' => [], + ]; + } + + $current_id = $myItem3->id; + + $name = $myItem3->name; + if ($name == '') + { + $name = '(' . $current_id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $current_id); + + $location = ''; + $location_url = ''; + if ($myItem3->location !== null) + { + $location = $myItem3->location->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $myItem3->location->id); + } + + $documents = []; + if ($myItem3->documents !== null) + { + foreach ($myItem3->documents as $document) + { + $url_document = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + + $documents[$document->id] = [ + 'name' => $document->name, + 'url' => $url_document, + ]; + } + } + + $mac = $current_item->mac; + + $myItems[$type]['items'][$current_id][$current_item->id] = [ + 'name' => $name, + 'url' => $url, + 'location' => $location, + 'location_url' => $location_url, + 'documents' => $documents, + 'mac' => $mac, + ]; + } + } + + // tri ordre alpha + uasort($myItems, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('items', $myItems); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('location', $translator->translatePlural('Location', 'Locations', 2)); + $viewData->addTranslation('documents', $translator->translatePlural('Document', 'Documents', 2)); + $viewData->addTranslation('mac', $translator->translate('MAC address')); + + return $view->render($response, 'subitem/items.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Devicepci.php b/src/v1/Controllers/Devicepci.php index 39d18aad4d..7a0c51ae9f 100644 --- a/src/v1/Controllers/Devicepci.php +++ b/src/v1/Controllers/Devicepci.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Devicepci extends Common { protected $model = '\App\Models\Devicepci'; - protected $rootUrl2 = '/devicepcis/'; + protected $rootUrl2 = '/devices/devicepcis/'; + protected $choose = 'devicepcis'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Devicepowersupply.php b/src/v1/Controllers/Devicepowersupply.php index e1f9f95bb7..65d73a478b 100644 --- a/src/v1/Controllers/Devicepowersupply.php +++ b/src/v1/Controllers/Devicepowersupply.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Devicepowersupply extends Common { protected $model = '\App\Models\Devicepowersupply'; - protected $rootUrl2 = '/devicepowersupplies/'; + protected $rootUrl2 = '/devices/devicepowersupplies/'; + protected $choose = 'devicepowersupplies'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Deviceprocessor.php b/src/v1/Controllers/Deviceprocessor.php index 865272d23b..6315c7594f 100644 --- a/src/v1/Controllers/Deviceprocessor.php +++ b/src/v1/Controllers/Deviceprocessor.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Deviceprocessor extends Common { protected $model = '\App\Models\Deviceprocessor'; - protected $rootUrl2 = '/deviceprocessors/'; + protected $rootUrl2 = '/devices/deviceprocessors/'; + protected $choose = 'deviceprocessors'; public function getAll(Request $request, Response $response, $args): Response { @@ -29,4 +31,127 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Deviceprocessor(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubItems(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/items'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myItems = []; + foreach ($myItem->items as $current_item) + { + $item3 = new $current_item->item_type(); + $myItem3 = $item3->find($current_item->item_id); + if ($myItem3 !== null) + { + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); + + if (array_key_exists($type, $myItems) !== true) + { + $myItems[$type] = [ + 'type' => $type, + 'name' => $type_fr, + 'items' => [], + ]; + } + + $current_id = $myItem3->id; + + $name = $myItem3->name; + if ($name == '') + { + $name = '(' . $current_id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $current_id); + + $location = ''; + $location_url = ''; + if ($myItem3->location !== null) + { + $location = $myItem3->location->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $myItem3->location->id); + } + + $documents = []; + if ($myItem3->documents !== null) + { + foreach ($myItem3->documents as $document) + { + $url_document = $this->genereRootUrl2Link($rootUrl2, '/documents/', $document->id); + + $documents[$document->id] = [ + 'name' => $document->name, + 'url' => $url_document, + ]; + } + } + + $frequency = ''; + $nbcores = ''; + $nbthreads = ''; + if ($type == 'computers') + { + if (isset($current_item->frequency)) + { + $frequency = $current_item->frequency; + } + if (isset($current_item->nbcores)) + { + $nbcores = $current_item->nbcores; + } + if (isset($current_item->nbthreads)) + { + $nbthreads = $current_item->nbthreads; + } + } + + $myItems[$type]['items'][$current_id][$current_item->id] = [ + 'name' => $name, + 'url' => $url, + 'location' => $location, + 'location_url' => $location_url, + 'documents' => $documents, + 'frequency' => $frequency, + 'nbcores' => $nbcores, + 'nbthreads' => $nbthreads, + ]; + } + } + + // tri ordre alpha + uasort($myItems, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('items', $myItems); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('location', $translator->translatePlural('Location', 'Locations', 2)); + $viewData->addTranslation('documents', $translator->translatePlural('Document', 'Documents', 2)); + $viewData->addTranslation('frequence_mhz', sprintf( + '%1$s (%2$s)', + $translator->translate('Frequency'), + $translator->translate('MHz') + )); + $viewData->addTranslation('nbcores', $translator->translate('Number of cores')); + $viewData->addTranslation('nbthreads', $translator->translate('Number of threads')); + + return $view->render($response, 'subitem/items.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Devicesensor.php b/src/v1/Controllers/Devicesensor.php index 80d40c0663..702f1049b6 100644 --- a/src/v1/Controllers/Devicesensor.php +++ b/src/v1/Controllers/Devicesensor.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Devicesensor extends Common { protected $model = '\App\Models\Devicesensor'; - protected $rootUrl2 = '/devicesensors/'; + protected $rootUrl2 = '/devices/devicesensors/'; + protected $choose = 'devicesensors'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Devicesimcard.php b/src/v1/Controllers/Devicesimcard.php index 877dcf6a76..3147754153 100644 --- a/src/v1/Controllers/Devicesimcard.php +++ b/src/v1/Controllers/Devicesimcard.php @@ -10,7 +10,8 @@ final class Devicesimcard extends Common { protected $model = '\App\Models\Devicesimcard'; - protected $rootUrl2 = '/devicesimcards/'; + protected $rootUrl2 = '/devices/devicesimcards/'; + protected $choose = 'devicesimcards'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Devicesoundcard.php b/src/v1/Controllers/Devicesoundcard.php index 0c594ef3f9..46729abdfa 100644 --- a/src/v1/Controllers/Devicesoundcard.php +++ b/src/v1/Controllers/Devicesoundcard.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Devicesoundcard extends Common { protected $model = '\App\Models\Devicesoundcard'; - protected $rootUrl2 = '/devicesoundcards/'; + protected $rootUrl2 = '/devices/devicesoundcards/'; + protected $choose = 'devicesoundcards'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Displaypreference.php b/src/v1/Controllers/Displaypreference.php index f54099da68..eb32702b78 100644 --- a/src/v1/Controllers/Displaypreference.php +++ b/src/v1/Controllers/Displaypreference.php @@ -92,7 +92,9 @@ public function postColumnOfModel(Request $request, Response $response, $args): if ($data->type == 'user') { $dpref->user_id = $GLOBALS['user_id']; - } else { + } + else + { $dpref->user_id = 0; } $dpref->itemtype = $datap->m; @@ -106,7 +108,9 @@ public function postColumnOfModel(Request $request, Response $response, $args): if (is_null($dprefmax)) { $dpref->rank = 1; - } else { + } + else + { $dpref->rank = $dprefmax->rank + 1; } $dpref->save(); diff --git a/src/v1/Controllers/Documentcategory.php b/src/v1/Controllers/Documentcategory.php index 43871b4711..6eae12794e 100644 --- a/src/v1/Controllers/Documentcategory.php +++ b/src/v1/Controllers/Documentcategory.php @@ -6,10 +6,12 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Documentcategory extends Common { protected $model = '\App\Models\Documentcategory'; + protected $rootUrl2 = '/dropdowns/documentcategories/'; public function getAll(Request $request, Response $response, $args): Response { @@ -28,4 +30,58 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Documentcategory(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubDocumentcategories(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $item2 = new $this->model(); + $myItem2 = $item2::where('documentcategory_id', $args['id'])->get(); + + $rootUrl = $this->genereRootUrl($request, '/categories'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myDocumentcategories = []; + foreach ($myItem2 as $documentcategory) + { + $name = $documentcategory->name; + if ($name == '') + { + $name = '(' . $documentcategory->id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/documentcategories/', $documentcategory->id); + + $comment = $documentcategory->comment; + + $myDocumentcategories[] = [ + 'name' => $name, + 'url' => $url, + 'comment' => $comment, + ]; + } + + // tri ordre alpha + uasort($myDocumentcategories, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('documentcategories', $myDocumentcategories); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('comment', $translator->translatePlural('Comment', 'Comments', 2)); + + return $view->render($response, 'subitem/documentcategories.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Domain.php b/src/v1/Controllers/Domain.php index 907dd96560..bce18361a5 100644 --- a/src/v1/Controllers/Domain.php +++ b/src/v1/Controllers/Domain.php @@ -10,6 +10,9 @@ final class Domain extends Common { protected $model = '\App\Models\Domain'; protected $rootUrl2 = '/domains/'; + protected $choose = 'domains'; + protected $associateditems_model = '\App\Models\DomainItem'; + protected $associateditems_model_id = 'domain_id'; public function getAll(Request $request, Response $response, $args): Response { @@ -39,26 +42,29 @@ public function showSubRecords(Request $request, Response $response, $args): Res $myItem = $item::with('records')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/records'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $myRecords = []; foreach ($myItem->records as $record) { $type = ''; + $type_url = ''; if ($record->type !== null) { $type = $record->type->name; + $type_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/domainrecordtypes/', $record->type->id); } $myRecords[] = [ - 'name' => $record->name, - 'type' => $type, - 'ttl' => $record->ttl, - 'target' => $record->data, + 'name' => $record->name, + 'type' => $type, + 'type_url' => $type_url, + 'ttl' => $record->ttl, + 'target' => $record->data, ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/records'); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); diff --git a/src/v1/Controllers/Domainrelation.php b/src/v1/Controllers/Domainrelation.php index a17cbffe43..f57bf4fb35 100644 --- a/src/v1/Controllers/Domainrelation.php +++ b/src/v1/Controllers/Domainrelation.php @@ -6,10 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Domainrelation extends Common { protected $model = '\App\Models\Domainrelation'; + protected $rootUrl2 = '/dropdowns/domainrelations/'; + protected $choose = 'domainrelations'; public function getAll(Request $request, Response $response, $args): Response { @@ -28,4 +31,117 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Domainrelation(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubDomains(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/domains'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myDomains = []; + foreach ($myItem->domains as $domain) + { + $name = $domain->name; + + $url = $this->genereRootUrl2Link($rootUrl2, '/domains/', $domain->id); + + $entity = ''; + $entity_url = ''; + if ($domain->entity !== null) + { + $entity = $domain->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $domain->entity->id); + } + + $group = ''; + $group_url = ''; + if ($domain->groupstech !== null) + { + $group = $domain->groupstech->completename; + $group_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $domain->groupstech->id); + } + + $user = ''; + $user_url = ''; + if ($domain->userstech !== null) + { + $user = $this->genereUserName( + $domain->userstech->name, + $domain->userstech->lastname, + $domain->userstech->firstname + ); + $user_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $domain->userstech->id); + } + + $type = ''; + $type_url = ''; + if ($domain->type !== null) + { + $type = $domain->type->name; + $type_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/domaintypes/', $domain->type->id); + } + + $create_at = $domain->created_at; + + $alert_expiration = false; + $date_expiration = $domain->date_expiration; + if ($date_expiration == null) + { + $date_expiration = $translator->translate("N'expire pas"); + } + else + { + if ($date_expiration < date('Y-m-d H:i:s')) + { + $alert_expiration = true; + } + } + + $myDomains[] = [ + 'name' => $name, + 'url' => $url, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'group' => $group, + 'group_url' => $group_url, + 'user' => $user, + 'user_url' => $user_url, + 'type' => $type, + 'type_url' => $type_url, + 'date_create' => $create_at, + 'date_exp' => $date_expiration, + 'alert_expiration' => $alert_expiration, + ]; + } + + // tri ordre alpha + uasort($myDomains, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('domains', $myDomains); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); + $viewData->addTranslation('group', $translator->translate('Group in charge')); + $viewData->addTranslation('user', $translator->translate('Technician in charge')); + $viewData->addTranslation('type', $translator->translatePlural('Type', 'Types', 1)); + $viewData->addTranslation('date_create', $translator->translate('Creation date')); + $viewData->addTranslation('date_exp', $translator->translate('Expiration date')); + + return $view->render($response, 'subitem/domains.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Dropdown.php b/src/v1/Controllers/Dropdown.php index 10a9133e41..316b2b3b1a 100644 --- a/src/v1/Controllers/Dropdown.php +++ b/src/v1/Controllers/Dropdown.php @@ -61,7 +61,9 @@ public function getAll(Request $request, Response $response, $args): Response $item = new $data->itemtype(); $dropData = $item->getDropdownValues($data->q); $success = true; - } else { + } + else + { $dropData = []; $success = false; } diff --git a/src/v1/Controllers/Enclosure.php b/src/v1/Controllers/Enclosure.php index 06b9928aab..11c6870ea7 100644 --- a/src/v1/Controllers/Enclosure.php +++ b/src/v1/Controllers/Enclosure.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Enclosure extends Common { protected $model = '\App\Models\Enclosure'; protected $rootUrl2 = '/enclosures/'; + protected $choose = 'enclosures'; public function getAll(Request $request, Response $response, $args): Response { @@ -29,4 +31,66 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Enclosure(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubItems(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/items'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myItems = []; + foreach ($myItem->items as $current_item) + { + $item3 = new $current_item->item_type(); + $myItem3 = $item3->find($current_item->item_id); + + if ($myItem3 !== null) + { + $type = $item3->getTable(); + + $current_id = $myItem3->id; + + $name = $myItem3->name; + if ($name == '') + { + $name = '(' . $current_id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $current_id); + + $position = $current_item->position; + + $myItems[$current_item->id] = [ + 'name' => $name, + 'url' => $url, + 'position' => $position, + ]; + } + } + + // tri ordre alpha + uasort($myItems, function ($a, $b) + { + return $a['position'] > $b['position']; + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('items', $myItems); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('name', $translator->translatePlural('Item', 'Items', 1)); + $viewData->addTranslation('position', $translator->translate('Position')); + + return $view->render($response, 'subitem/items.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Entity.php b/src/v1/Controllers/Entity.php index 7a29455036..95105bc8ca 100644 --- a/src/v1/Controllers/Entity.php +++ b/src/v1/Controllers/Entity.php @@ -39,46 +39,44 @@ public function showSubAddress(Request $request, Response $response, $args): Res $myItem = $item->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/address'); + $address = []; foreach ($myItem as $os) { $address = [ - 'phonenumber' => $myItem->phonenumber, - 'fax' => $myItem->fax, - 'website' => $myItem->website, - 'email' => $myItem->email, - 'address' => $myItem->address, - 'postcode' => $myItem->postcode, - 'town' => $myItem->town, - 'state' => $myItem->state, - 'country' => $myItem->country, - 'longitude' => $myItem->longitude, - 'latitude' => $myItem->latitude, - 'altitude' => $myItem->altitude, + 'phonenumber' => $myItem->phonenumber, + 'fax' => $myItem->fax, + 'website' => $myItem->website, + 'email' => $myItem->email, + 'address' => $myItem->address, + 'postcode' => $myItem->postcode, + 'town' => $myItem->town, + 'state' => $myItem->state, + 'country' => $myItem->country, + 'longitude' => $myItem->longitude, + 'latitude' => $myItem->latitude, + 'altitude' => $myItem->altitude, ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/address'); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); - $getDefs = $item->getSpecificFunction('getDefinitionAddress'); $myItemData = [ - 'phonenumber' => $address['phonenumber'], - 'fax' => $address['fax'], - 'website' => $address['website'], - 'email' => $address['email'], - 'address' => $address['address'], - 'postcode' => $address['postcode'], - 'town' => $address['town'], - 'state' => $address['state'], - 'country' => $address['country'], - 'longitude' => $address['longitude'], - 'latitude' => $address['latitude'], - 'altitude' => $address['altitude'], + 'phonenumber' => $address['phonenumber'], + 'fax' => $address['fax'], + 'website' => $address['website'], + 'email' => $address['email'], + 'address' => $address['address'], + 'postcode' => $address['postcode'], + 'town' => $address['town'], + 'state' => $address['state'], + 'country' => $address['country'], + 'longitude' => $address['longitude'], + 'latitude' => $address['latitude'], + 'altitude' => $address['altitude'], ]; $myItemDataObject = json_decode(json_encode($myItemData)); @@ -100,36 +98,32 @@ public function showSubEntities(Request $request, Response $response, $args): Re $item2 = new $this->model(); $myItem2 = $item2::where('entity_id', $args['id'])->get(); - - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/entities'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/entities'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myEntities = []; foreach ($myItem2 as $child) { $name = $child->name; - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/entities/" . $child->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $child->id); $entity = ''; - if ($child->entity != null) { - $entity = $child->entity->name; + $entity_url = ''; + if ($child->entity !== null) + { + $entity = $child->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $child->entity->id); } $comment = $child->comment; $myEntities[$child->id] = [ - 'name' => $name, - 'url' => $url, - 'entity' => $entity, - 'comment' => $comment, + 'name' => $name, + 'url' => $url, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'comment' => $comment, ]; } @@ -156,21 +150,18 @@ public function showSubUsers(Request $request, Response $response, $args): Respo $myItem = $item::with('profilesusers')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/users'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/users'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myProfilesUsers = []; foreach ($myItem->profilesusers as $profileuser) { $user = \App\Models\User::find($profileuser->user_id); $profile = \App\Models\Profile::find($profileuser->profile_id); - - if (($user !== null) && ($profile !== null)) { - if (array_key_exists($profile->id, $myProfilesUsers) !== true) { + if (($user !== null) && ($profile !== null)) + { + if (array_key_exists($profile->id, $myProfilesUsers) !== true) + { $myProfilesUsers[$profile->id] = [ 'name' => $profile->name, 'users' => [], @@ -186,6 +177,7 @@ public function showSubUsers(Request $request, Response $response, $args): Respo { $auto_val = $translator->translate('No'); } + $recursive = $profileuser->is_recursive; if ($profileuser->is_recursive == 1) { @@ -196,8 +188,10 @@ public function showSubUsers(Request $request, Response $response, $args): Respo $recursive_val = $translator->translate('No'); } + $user_name = $this->genereUserName($user->name, $user->lastname, $user->firstname); + $myProfilesUsers[$profile->id]['users'][$user->id] = [ - 'name' => $user->name, + 'name' => $user_name, 'auto' => $auto, 'auto_val' => $auto_val, 'recursive' => $recursive, @@ -207,7 +201,7 @@ public function showSubUsers(Request $request, Response $response, $args): Respo } // tri ordre alpha - usort($myProfilesUsers, function ($a, $b) + uasort($myProfilesUsers, function ($a, $b) { return strtolower($a['name']) > strtolower($b['name']); }); diff --git a/src/v1/Controllers/Forms/Answer.php b/src/v1/Controllers/Forms/Answer.php index cea88e4cd7..17ae80b8e9 100644 --- a/src/v1/Controllers/Forms/Answer.php +++ b/src/v1/Controllers/Forms/Answer.php @@ -33,21 +33,25 @@ public function showAnswer(Request $request, Response $response, $args): Respons { global $translator; - $item = new \App\Models\Forms\Answer(); + $item = new $this->model(); $view = Twig::fromRequest($request); $myItem = $item::with('form', 'answerquestions')->find($args['id']); + $item2 = new \App\Models\Forms\Form(); + $myItem2 = $item2::with('sections')->find($myItem->form->id); + $answers = [ - 'form_id' => $myItem->form->id, - 'form_name' => $myItem->form->name, - 'sections' => [], + 'form_id' => $myItem->form->id, + 'form_name' => $myItem->form->name, + 'sections' => [], ]; - $item2 = new \App\Models\Forms\Form(); - $myItem2 = $item2::with('sections')->find($myItem->form->id); + $rootUrl = $this->genereRootUrl($request, ''); + // $rootUrl = $this->getUrlWithoutQuery($request); - foreach ($myItem2->sections as $section) { + foreach ($myItem2->sections as $section) + { $answers['sections'][$section->id] = []; $answers['sections'][$section->id]['id'] = $section->id; $answers['sections'][$section->id]['name'] = $section->name; @@ -55,29 +59,28 @@ public function showAnswer(Request $request, Response $response, $args): Respons $item3 = new \App\Models\Forms\Section(); $myItem3 = $item3::with('questions')->find($section->id); - foreach ($myItem3->questions as $question) { + foreach ($myItem3->questions as $question) + { $answer = ''; - foreach ($myItem->answerquestions as $answerquestion) { - if ($answerquestion->question_id == $question->id) { + foreach ($myItem->answerquestions as $answerquestion) + { + if ($answerquestion->question_id == $question->id) + { $answer = $answerquestion->answer; break; } } $answers['sections'][$section->id]['questions'][$question->id] = [ - 'id' => $question->id, - 'name' => $question->name, - 'fieldtype' => $question->fieldtype, - 'answer' => $answer, + 'id' => $question->id, + 'name' => $question->name, + 'fieldtype' => $question->fieldtype, + 'answer' => $answer, ]; } } - - $rootUrl = $this->getUrlWithoutQuery($request); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); - $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); $viewData->addData('fields', $item->getFormData($myItem)); diff --git a/src/v1/Controllers/Forms/Form.php b/src/v1/Controllers/Forms/Form.php index 24266230fd..05087a63ef 100644 --- a/src/v1/Controllers/Forms/Form.php +++ b/src/v1/Controllers/Forms/Form.php @@ -10,6 +10,7 @@ final class Form extends \App\v1\Controllers\Common { protected $model = '\App\Models\Forms\Form'; + protected $rootUrl2 = '/forms/'; public function getAll(Request $request, Response $response, $args): Response { @@ -33,16 +34,20 @@ public function showSubSections(Request $request, Response $response, $args): Re { global $translator; - $item = new \App\Models\Forms\Form(); + $item = new $this->model(); $view = Twig::fromRequest($request); $myItem = $item::with('sections')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/sections'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $sections = []; - foreach ($myItem->sections as $section) { + foreach ($myItem->sections as $section) + { $sections[$section->id] = [ - 'id' => $section->id, - 'name' => $section->name, + 'id' => $section->id, + 'name' => $section->name, ]; $item2 = new \App\Models\Forms\Section(); @@ -50,12 +55,7 @@ public function showSubSections(Request $request, Response $response, $args): Re $sections[$section->id]['questions_count'] = $myItem2->questions_count; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/sections'); - $rootUrl2 = rtrim($rootUrl, '/forms/' . $args['id']); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); - $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); $viewData->addData('fields', $item->getFormData($myItem)); @@ -73,13 +73,17 @@ public function showSubQuestions(Request $request, Response $response, $args): R { global $translator; - $item = new \App\Models\Forms\Form(); + $item = new $this->model(); $view = Twig::fromRequest($request); $myItem = $item::with('sections')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/questions'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $sections = []; - foreach ($myItem->sections as $section) { + foreach ($myItem->sections as $section) + { $item2 = new \App\Models\Forms\Section(); $myItem2 = $item2::with('questions')->find($section->id); @@ -87,20 +91,16 @@ public function showSubQuestions(Request $request, Response $response, $args): R $sections[$section->id]['id'] = $section->id; $sections[$section->id]['name'] = $section->name; - foreach ($myItem2->questions as $question) { + foreach ($myItem2->questions as $question) + { $sections[$section->id]['questions'][] = [ - 'id' => $question->id, - 'name' => $question->name, + 'id' => $question->id, + 'name' => $question->name, ]; } } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/questions'); - $rootUrl2 = rtrim($rootUrl, '/forms/' . $args['id']); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); - $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); $viewData->addData('fields', $item->getFormData($myItem)); @@ -118,38 +118,30 @@ public function showSubAnswers(Request $request, Response $response, $args): Res { global $translator; - $item = new \App\Models\Forms\Form(); + $item = new $this->model(); $view = Twig::fromRequest($request); $myItem = $item::with('sections')->find($args['id']); - $item2 = new \App\Models\Forms\Answer(); $myItem2 = $item2::with('user')->where('form_id', $args['id'])->get(); + $rootUrl = $this->genereRootUrl($request, '/answers'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $answers = []; - foreach ($myItem2 as $answer) { - $user = $answer->user->lastname . ' ' . $answer->user->firstname; - $user = trim($user); - if ($user != '') { - $user = $user . ' (' . $answer->user->name . ')'; - } else { - $user = $answer->user->name; - } + foreach ($myItem2 as $answer) + { + $user = $this->genereUserName($answer->user->name, $answer->user->lastname, $answer->user->firstname, true); $answers[$answer->id] = [ - 'id' => $answer->id, - 'created_at' => $answer->created_at, - 'user' => $user, + 'id' => $answer->id, + 'created_at' => $answer->created_at, + 'user' => $user, ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/answers'); - $rootUrl2 = rtrim($rootUrl, '/forms/' . $args['id']); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); - $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); $viewData->addData('fields', $item->getFormData($myItem)); diff --git a/src/v1/Controllers/Forms/Question.php b/src/v1/Controllers/Forms/Question.php index d74e3e43c0..df346293c1 100644 --- a/src/v1/Controllers/Forms/Question.php +++ b/src/v1/Controllers/Forms/Question.php @@ -9,6 +9,7 @@ final class Question extends \App\v1\Controllers\Common { protected $model = '\App\Models\Forms\Question'; + protected $rootUrl2 = '/questions/'; public function getAll(Request $request, Response $response, $args): Response { @@ -32,25 +33,24 @@ public function showSubSections(Request $request, Response $response, $args): Re { global $translator; - $item = new \App\Models\Forms\Question(); + $item = new $this->model(); $view = Twig::fromRequest($request); $myItem = $item::with('sections')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/sections'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $sections = []; - foreach ($myItem->sections as $section) { + foreach ($myItem->sections as $section) + { $sections[$section->id] = [ - 'id' => $section->id, - 'name' => $section->name, + 'id' => $section->id, + 'name' => $section->name, ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/sections'); - $rootUrl2 = rtrim($rootUrl, '/questions/' . $args['id']); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); - $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); $viewData->addData('fields', $item->getFormData($myItem)); @@ -67,30 +67,30 @@ public function showSubForms(Request $request, Response $response, $args): Respo { global $translator; - $item = new \App\Models\Forms\Question(); + $item = new $this->model(); $view = Twig::fromRequest($request); $myItem = $item::with('sections')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/forms'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $forms = []; - foreach ($myItem->sections as $section) { + foreach ($myItem->sections as $section) + { $item2 = new \App\Models\Forms\Section(); $myItem2 = $item2::with('forms')->find($section->id); - foreach ($myItem2->forms as $form) { + foreach ($myItem2->forms as $form) + { $forms[$form->id] = [ - 'id' => $form->id, - 'name' => $form->name, + 'id' => $form->id, + 'name' => $form->name, ]; } } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/forms'); - $rootUrl2 = rtrim($rootUrl, '/questions/' . $args['id']); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); - $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); $viewData->addData('fields', $item->getFormData($myItem)); @@ -111,7 +111,8 @@ protected function getInformationTop($item, $request) $tabInfos = []; - foreach ($myItem->sections as $section) { + foreach ($myItem->sections as $section) + { $tabInfos[] = [ 'key' => 'section_' . $section->id, @@ -121,11 +122,12 @@ protected function getInformationTop($item, $request) } $forms = []; - foreach ($myItem->sections as $section) { + foreach ($myItem->sections as $section) + { $item2 = new \App\Models\Forms\Section(); $myItem2 = $item2::with('forms')->find($section->id); - - foreach ($myItem2->forms as $form) { + foreach ($myItem2->forms as $form) + { $tabInfos[] = [ 'key' => 'form_' . $form->id, diff --git a/src/v1/Controllers/Forms/Section.php b/src/v1/Controllers/Forms/Section.php index a74e57a7b8..9fb88de32d 100644 --- a/src/v1/Controllers/Forms/Section.php +++ b/src/v1/Controllers/Forms/Section.php @@ -10,6 +10,7 @@ final class Section extends \App\v1\Controllers\Common { protected $model = '\App\Models\Forms\Section'; + protected $rootUrl2 = '/sections/'; public function getAll(Request $request, Response $response, $args): Response { @@ -33,25 +34,24 @@ public function showSubQuestions(Request $request, Response $response, $args): R { global $translator; - $item = new \App\Models\Forms\Section(); + $item = new $this->model(); $view = Twig::fromRequest($request); $myItem = $item::with('questions')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/questions'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $questions = []; - foreach ($myItem->questions as $question) { + foreach ($myItem->questions as $question) + { $questions[] = [ - 'id' => $question->id, - 'name' => $question->name, + 'id' => $question->id, + 'name' => $question->name, ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/questions'); - $rootUrl2 = rtrim($rootUrl, '/sections/' . $args['id']); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); - $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); $viewData->addData('fields', $item->getFormData($myItem)); @@ -68,25 +68,24 @@ public function showSubForms(Request $request, Response $response, $args): Respo { global $translator; - $item = new \App\Models\Forms\Section(); + $item = new $this->model(); $view = Twig::fromRequest($request); $myItem = $item::with('forms')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/forms'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $forms = []; - foreach ($myItem->forms as $form) { + foreach ($myItem->forms as $form) + { $forms[] = [ - 'id' => $form->id, - 'name' => $form->name, + 'id' => $form->id, + 'name' => $form->name, ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/forms'); - $rootUrl2 = rtrim($rootUrl, '/sections/' . $args['id']); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); - $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); $viewData->addData('fields', $item->getFormData($myItem)); @@ -106,7 +105,8 @@ protected function getInformationTop($item, $request) $myItem = $item::with('forms')->find($item->id); $tabInfos = []; - foreach ($myItem->forms as $form) { + foreach ($myItem->forms as $form) + { $tabInfos[] = [ 'key' => 'form_' . $form->id, diff --git a/src/v1/Controllers/Fqdn.php b/src/v1/Controllers/Fqdn.php index 0b8d06c8f3..c4a984d136 100644 --- a/src/v1/Controllers/Fqdn.php +++ b/src/v1/Controllers/Fqdn.php @@ -6,10 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Fqdn extends Common { protected $model = '\App\Models\Fqdn'; + protected $rootUrl2 = '/dropdowns/fqdns/'; + protected $choose = 'fqdns'; public function getAll(Request $request, Response $response, $args): Response { @@ -28,4 +31,69 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Fqdn(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubNetworkalias(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/networkalias'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myNetworkAlias = []; + foreach ($myItem->alias as $current_item) + { + $name = $current_item->name; + + $url = ''; + // $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/networkalias/', $current_item->id); // TODO + + $computername = ''; + $computername_url = ''; + $networkname = \App\Models\Networkname::find($current_item->networkname_id); + if ($networkname !== null) + { + $computername = $networkname->name . '.' . $myItem->fqdn; + $computername_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/networkname/', + $current_item->networkname_id + ); + } + + $comment = $current_item->comment; + + $myNetworkAlias[] = [ + 'name' => $name, + 'url' => $url, + 'computername' => $computername, + 'computername_url' => $computername_url, + 'comment' => $comment, + ]; + } + + // tri ordre alpha + uasort($myNetworkAlias, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('networkalias', $myNetworkAlias); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('networkalias', $translator->translatePlural('Network alias', 'Network aliases', 1)); + $viewData->addTranslation('computername', $translator->translate("Computer's name")); + $viewData->addTranslation('comment', $translator->translate('Comments')); + + return $view->render($response, 'subitem/networkalias.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Fusioninventory/Communication.php b/src/v1/Controllers/Fusioninventory/Communication.php index de085af393..8a7f1baed5 100644 --- a/src/v1/Controllers/Fusioninventory/Communication.php +++ b/src/v1/Controllers/Fusioninventory/Communication.php @@ -19,7 +19,9 @@ public function getConfig(Request $request, Response $response, $args): Response $computer = new Computer(); $computer->importComputer($data); $payload = []; - } else { + } + else + { $payload = [ "PROLOG_FREQ" => 24, "RESPONSE" => "SEND", diff --git a/src/v1/Controllers/Group.php b/src/v1/Controllers/Group.php index 15f3e649ef..b70910eb9d 100644 --- a/src/v1/Controllers/Group.php +++ b/src/v1/Controllers/Group.php @@ -10,7 +10,7 @@ final class Group extends Common { protected $model = '\App\Models\Group'; protected $rootUrl2 = '/groups/'; - protected $itilchoose = 'groups'; + protected $choose = 'groups'; public function getAll(Request $request, Response $response, $args): Response { @@ -43,31 +43,69 @@ public function showSubUsers(Request $request, Response $response, $args): Respo $item2 = new \App\Models\User(); $myItem2 = $item2::with('group')->get(); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/users'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/users'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myUsers = []; foreach ($myItem2 as $user) { - if ($user->group != null) { - foreach ($user->group as $group) { - if ($group->pivot->group_id == $args['id']) { - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/users/" . $group->pivot->user_id; + if ($user->group !== null) + { + foreach ($user->group as $group) + { + if ($group->pivot->group_id == $args['id']) + { + $user_name = $this->genereUserName($user->name, $user->lastname, $user->firstname); + + $url = $this->genereRootUrl2Link($rootUrl2, '/users/', $group->pivot->user_id); + + if ($group->pivot->is_dynamic == 1) + { + $auto_val = $translator->translate('Yes'); + } + else + { + $auto_val = $translator->translate('No'); + } + + if ($group->pivot->is_manager == 1) + { + $is_manager_val = $translator->translate('Yes'); + } + else + { + $is_manager_val = $translator->translate('No'); + } + + if ($group->pivot->is_userdelegate == 1) + { + $is_userdelegate_val = $translator->translate('Yes'); + } + else + { + $is_userdelegate_val = $translator->translate('No'); + } + + if ($user->is_active == 1) + { + $is_active_val = $translator->translate('Yes'); + } + else + { + $is_active_val = $translator->translate('No'); } $myUsers[$group->pivot->user_id] = [ - 'name' => $user->name, - 'url' => $url, - 'auto' => $group->pivot->is_dynamic, - 'is_manager' => $group->pivot->is_manager, - 'is_userdelegate' => $group->pivot->is_userdelegate, - 'is_active' => $user->is_active, + 'name' => $user_name, + 'url' => $url, + 'auto' => $group->pivot->is_dynamic, + 'auto_val' => $auto_val, + 'is_manager' => $group->pivot->is_manager, + 'is_manager_val' => $is_manager_val, + 'is_userdelegate' => $group->pivot->is_userdelegate, + 'is_userdelegate_val' => $is_userdelegate_val, + 'is_active' => $user->is_active, + 'is_active_val' => $is_active_val, ]; } } @@ -79,6 +117,7 @@ public function showSubUsers(Request $request, Response $response, $args): Respo $viewData->addData('fields', $item->getFormData($myItem)); $viewData->addData('users', $myUsers); + $viewData->addData('show', $this->choose); $viewData->addTranslation('name', $translator->translate('Name')); $viewData->addTranslation('auto', $translator->translate('Automatic inventory')); @@ -99,35 +138,32 @@ public function showSubGroups(Request $request, Response $response, $args): Resp $myItem = $item::with('parents')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/groups'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/groups'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myGroups = []; foreach ($myItem->parents as $parent) { $name = $parent->name; - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/groups/" . $parent->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $parent->id); $entity = ''; - if ($parent->entity != null) { - $entity = $parent->entity->name; + $entity_url = ''; + if ($parent->entity !== null) + { + $entity = $parent->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $parent->entity->id); } $comment = $parent->comment; $myGroups[$parent->id] = [ - 'name' => $name, - 'url' => $url, - 'entity' => $entity, - 'comment' => $comment, + 'name' => $name, + 'url' => $url, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'comment' => $comment, ]; } @@ -136,7 +172,7 @@ public function showSubGroups(Request $request, Response $response, $args): Resp $viewData->addData('fields', $item->getFormData($myItem)); $viewData->addData('groups', $myGroups); - $viewData->addData('show', $this->itilchoose); + $viewData->addData('show', $this->choose); $viewData->addTranslation('name', $translator->translate('Name')); $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); diff --git a/src/v1/Controllers/Home.php b/src/v1/Controllers/Home.php index d3af5c595c..609cb87b3b 100644 --- a/src/v1/Controllers/Home.php +++ b/src/v1/Controllers/Home.php @@ -25,8 +25,7 @@ public function homepage(Request $request, Response $response, $args): Response $view = Twig::fromRequest($request); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/home'); + $rootUrl = $this->genereRootUrl($request, '/home'); $myItem = new \App\Models\Home(); @@ -37,24 +36,28 @@ public function homepage(Request $request, Response $response, $args): Response foreach ($itemByUserid as $item) { $items[$item->module] = [ - 'column' => $item->column, - 'row' => $item->row, - 'datas' => [], + 'column' => $item->column, + 'row' => $item->row, + 'datas' => [], ]; } - } else { + } + else + { $itemByProfileid = $myItem->where('profile_id', $GLOBALS['profile_id'])->orderBy('row', 'asc')->get(); if (count($itemByProfileid) > 0) { foreach ($itemByProfileid as $item) { $items[$item->module] = [ - 'column' => $item->column, - 'row' => $item->row, - 'datas' => [], + 'column' => $item->column, + 'row' => $item->row, + 'datas' => [], ]; } - } else { + } + else + { $itemByDefaultUseridProfileid = $myItem ->where(['user_id' => 0, 'profile_id' => 0]) ->orderBy('row', 'asc') @@ -64,9 +67,9 @@ public function homepage(Request $request, Response $response, $args): Response foreach ($itemByDefaultUseridProfileid as $item) { $items[$item->module] = [ - 'column' => $item->column, - 'row' => $item->row, - 'datas' => [], + 'column' => $item->column, + 'row' => $item->row, + 'datas' => [], ]; } } @@ -81,18 +84,18 @@ public function homepage(Request $request, Response $response, $args): Response foreach ($myItem2 as $it) { - if ($it->requester != null) + if ($it->requester !== null) { foreach ($it->requester as $req) { if ($req->pivot->user_id == $GLOBALS['user_id']) { $items[$key]['datas'][$it->id] = [ - 'name' => $it->name, - 'status' => $this->getStatusArray()[$it->status], - 'priority' => $this->getPriorityArray()[$it->priority], - 'date_open' => $it->date, - 'date_last_modif' => $it->updated_at, + 'name' => $it->name, + 'status' => $this->getStatusArray()[$it->status], + 'priority' => $this->getPriorityArray()[$it->priority], + 'date_open' => $it->date, + 'date_last_modif' => $it->updated_at, ]; } } @@ -115,50 +118,50 @@ public function homepage(Request $request, Response $response, $args): Response $myItem2 = \App\Models\Ticket::with('requestergroup', 'watchergroup', 'techniciangroup')->take(5)->get(); foreach ($myItem2 as $it) { - if ($it->requestergroup != null) + if ($it->requestergroup !== null) { foreach ($it->requestergroup as $req) { if (array_key_exists($req->pivot->group_id, $groups)) { $items[$key]['datas'][$it->id] = [ - 'name' => $it->name, - 'status' => $this->getStatusArray()[$it->status], - 'priority' => $this->getPriorityArray()[$it->priority], - 'date_open' => $it->date, - 'date_last_modif' => $it->updated_at, + 'name' => $it->name, + 'status' => $this->getStatusArray()[$it->status], + 'priority' => $this->getPriorityArray()[$it->priority], + 'date_open' => $it->date, + 'date_last_modif' => $it->updated_at, ]; } } } - if ($it->watchergroup != null) + if ($it->watchergroup !== null) { foreach ($it->watchergroup as $req) { if (array_key_exists($req->pivot->group_id, $groups)) { $items[$key]['datas'][$it->id] = [ - 'name' => $it->name, - 'status' => $this->getStatusArray()[$it->status], - 'priority' => $this->getPriorityArray()[$it->priority], - 'date_open' => $it->date, - 'date_last_modif' => $it->updated_at, + 'name' => $it->name, + 'status' => $this->getStatusArray()[$it->status], + 'priority' => $this->getPriorityArray()[$it->priority], + 'date_open' => $it->date, + 'date_last_modif' => $it->updated_at, ]; } } } - if ($it->techniciangroup != null) + if ($it->techniciangroup !== null) { foreach ($it->techniciangroup as $req) { if (array_key_exists($req->pivot->group_id, $groups)) { $items[$key]['datas'][$it->id] = [ - 'name' => $it->name, - 'status' => $this->getStatusArray()[$it->status], - 'priority' => $this->getPriorityArray()[$it->priority], - 'date_open' => $it->date, - 'date_last_modif' => $it->updated_at, + 'name' => $it->name, + 'status' => $this->getStatusArray()[$it->status], + 'priority' => $this->getPriorityArray()[$it->priority], + 'date_open' => $it->date, + 'date_last_modif' => $it->updated_at, ]; } } @@ -176,22 +179,22 @@ public function homepage(Request $request, Response $response, $args): Response foreach ($myItem2 as $it) { $user = ''; - if ($it->user != null) + if ($it->user !== null) { $user = $it->user->name; } $category = ''; - if ($it->category != null) + if ($it->category !== null) { $category = $it->category->name; } $items[$key]['datas'][$it->id] = [ - 'name' => $it->name, - 'user' => $user, - 'category' => $category, - 'visible_since' => $it->begin_date, - 'visible_until' => $it->end_date, + 'name' => $it->name, + 'user' => $user, + 'category' => $category, + 'visible_since' => $it->begin_date, + 'visible_until' => $it->end_date, ]; } $nbValTotal = $nbValTotal + count($items[$key]['datas']); @@ -201,9 +204,9 @@ public function homepage(Request $request, Response $response, $args): Response $limit = true; } $items[$key]['datas']['#'] = [ - 'limit' => $limit, - 'nbLast' => $nbLast, - 'nb_res' => $myItem3, + 'limit' => $limit, + 'nbLast' => $nbLast, + 'nb_res' => $myItem3, ]; } if ($key == 'lastproblems') @@ -215,11 +218,11 @@ public function homepage(Request $request, Response $response, $args): Response foreach ($myItem2 as $it) { $items[$key]['datas'][$it->id] = [ - 'name' => $it->name, - 'status' => $this->getStatusArray()[$it->status], - 'priority' => $this->getPriorityArray()[$it->priority], - 'date_open' => $it->date, - 'date_last_modif' => $it->updated_at, + 'name' => $it->name, + 'status' => $this->getStatusArray()[$it->status], + 'priority' => $this->getPriorityArray()[$it->priority], + 'date_open' => $it->date, + 'date_last_modif' => $it->updated_at, ]; } $nbValTotal = $nbValTotal + count($items[$key]['datas']); @@ -229,9 +232,9 @@ public function homepage(Request $request, Response $response, $args): Response $limit = true; } $items[$key]['datas']['#'] = [ - 'limit' => $limit, - 'nbLast' => $nbLast, - 'nb_res' => $myItem3, + 'limit' => $limit, + 'nbLast' => $nbLast, + 'nb_res' => $myItem3, ]; } if ($key == 'todayincidents') @@ -253,7 +256,7 @@ public function homepage(Request $request, Response $response, $args): Response $myItem2 = $item2::with('requester', 'requestergroup')->take(5)->get(); foreach ($myItem2 as $it) { - if ($it->requestergroup != null) + if ($it->requestergroup !== null) { foreach ($it->requestergroup as $req) { @@ -266,7 +269,7 @@ public function homepage(Request $request, Response $response, $args): Response } } } - if ($it->requester != null) + if ($it->requester !== null) { foreach ($it->requester as $req) { @@ -276,7 +279,9 @@ public function homepage(Request $request, Response $response, $args): Response { $nbTodayIncidents = $nbTodayIncidents + 1; } - } else { + } + else + { $user2 = new \App\Models\User(); $itemUser2 = $user2::with('group')->find($req->pivot->user_id); $groups2 = []; @@ -353,14 +358,14 @@ public function homepage(Request $request, Response $response, $args): Response $incr = 0; foreach ($myItem2 as $it) { - if ($it->requester != null) + if ($it->requester !== null) { foreach ($it->requester as $req) { if ($req->pivot->user_id == $GLOBALS['user_id']) { $others_tech = false; - if ($it->technician != null) + if ($it->technician !== null) { foreach ($it->technician as $tec) { @@ -373,7 +378,7 @@ public function homepage(Request $request, Response $response, $args): Response } if ($others_tech === false) { - if ($it->techniciangroup != null) + if ($it->techniciangroup !== null) { foreach ($it->techniciangroup as $tec) { @@ -389,11 +394,11 @@ public function homepage(Request $request, Response $response, $args): Response if ($incr <= $nbLast) { $items[$key]['datas'][$it->id] = [ - 'name' => $it->name, - 'status' => $this->getStatusArray()[$it->status], - 'priority' => $this->getPriorityArray()[$it->priority], - 'date_open' => $it->date, - 'date_last_modif' => $it->updated_at, + 'name' => $it->name, + 'status' => $this->getStatusArray()[$it->status], + 'priority' => $this->getPriorityArray()[$it->priority], + 'date_open' => $it->date, + 'date_last_modif' => $it->updated_at, ]; } } @@ -409,9 +414,9 @@ public function homepage(Request $request, Response $response, $args): Response $limit = true; } $items[$key]['datas']['#'] = [ - 'limit' => $limit, - 'nbLast' => $nbLast, - 'nb_res' => $incr, + 'limit' => $limit, + 'nbLast' => $nbLast, + 'nb_res' => $incr, ]; } if ($key == 'knowledgelink') diff --git a/src/v1/Controllers/Ipnetwork.php b/src/v1/Controllers/Ipnetwork.php index 7a97b73e76..9eb9780e54 100644 --- a/src/v1/Controllers/Ipnetwork.php +++ b/src/v1/Controllers/Ipnetwork.php @@ -6,10 +6,12 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Ipnetwork extends Common { protected $model = '\App\Models\Ipnetwork'; + protected $rootUrl2 = '/dropdowns/ipnetwork/'; public function getAll(Request $request, Response $response, $args): Response { @@ -28,4 +30,62 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Ipnetwork(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubVlans(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/vlans'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myVlans = []; + foreach ($myItem->vlans as $vlan) + { + $name = $vlan->name; + + $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/vlans/', $vlan->id); + + $entity = ''; + $entity_url = ''; + if ($vlan->entity !== null) + { + $entity = $vlan->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $vlan->entity->id); + } + + $tagid = $vlan->tag; + + $myVlans[] = [ + 'name' => $name, + 'url' => $url, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'tagid' => $tagid, + ]; + } + + // tri ordre alpha + uasort($myVlans, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('vlans', $myVlans); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); + $viewData->addTranslation('tagid', $translator->translate('ID TAG')); + + return $view->render($response, 'subitem/vlans.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Knowbaseitemcategory.php b/src/v1/Controllers/Knowbaseitemcategory.php index aa7a38be0d..040748a06f 100644 --- a/src/v1/Controllers/Knowbaseitemcategory.php +++ b/src/v1/Controllers/Knowbaseitemcategory.php @@ -6,10 +6,12 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Knowbaseitemcategory extends Common { protected $model = '\App\Models\Knowbaseitemcategory'; + protected $rootUrl2 = '/dropdowns/knowbaseitemcategories/'; public function getAll(Request $request, Response $response, $args): Response { @@ -28,4 +30,69 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Knowbaseitemcategory(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubKnowbaseitemcategories(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $item2 = new $this->model(); + $myItem2 = $item2::where('knowbaseitemcategory_id', $args['id'])->get(); + + $rootUrl = $this->genereRootUrl($request, '/knowbaseitemcategories'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myBusinesscriticities = []; + foreach ($myItem2 as $knowbaseitemcategory) + { + $name = $knowbaseitemcategory->name; + if ($name == '') + { + $name = '(' . $knowbaseitemcategory->id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/knowbaseitemcategories/', $knowbaseitemcategory->id); + + $entity = ''; + $entity_url = ''; + if ($knowbaseitemcategory->entity !== null) + { + $entity = $knowbaseitemcategory->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $knowbaseitemcategory->entity->id); + } + + $comment = $knowbaseitemcategory->comment; + + $myBusinesscriticities[] = [ + 'name' => $name, + 'url' => $url, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'comment' => $comment, + ]; + } + + // tri ordre alpha + uasort($myBusinesscriticities, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('knowbaseitemcategories', $myBusinesscriticities); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); + $viewData->addTranslation('comment', $translator->translatePlural('Comment', 'Comments', 2)); + + return $view->render($response, 'subitem/knowbaseitemcategories.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Link.php b/src/v1/Controllers/Link.php index 9ee2e5b6dd..65d0e848a6 100644 --- a/src/v1/Controllers/Link.php +++ b/src/v1/Controllers/Link.php @@ -4,10 +4,13 @@ use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; +use Slim\Views\Twig; final class Link extends Common { protected $model = '\App\Models\Link'; + protected $rootUrl2 = '/links/'; + protected $choose = 'links'; public function getAll(Request $request, Response $response, $args): Response { @@ -26,4 +29,49 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Link(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubAssociatedItemType(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $item2 = new \App\Models\LinkItemtype(); + $myItem2 = $item2::where('link_id', $args['id'])->get(); + + $rootUrl = $this->genereRootUrl($request, '/associateditemtypes'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myAssociatedItemType = []; + foreach ($myItem2 as $current_item) + { + $item3 = new $current_item->item_type(); + $type = $item3->getTitle(); + + $myAssociatedItemType[$type] = [ + 'type' => $type, + ]; + } + + // tri ordre alpha + uasort($myAssociatedItemType, function ($a, $b) + { + return strtolower($a['type']) > strtolower($b['type']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('items', $myAssociatedItemType); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('type', $translator->translatePlural('Type', 'Types', 1)); + + return $view->render($response, 'subitem/items.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Location.php b/src/v1/Controllers/Location.php index fed395c450..d5b653bff9 100644 --- a/src/v1/Controllers/Location.php +++ b/src/v1/Controllers/Location.php @@ -11,7 +11,7 @@ final class Location extends Common { protected $model = '\App\Models\Location'; - protected $rootUrl2 = '/locations/'; + protected $rootUrl2 = '/dropdowns/locations/'; public function getAll(Request $request, Response $response, $args): Response { @@ -44,44 +44,51 @@ public function showSubLocations(Request $request, Response $response, $args): R $item2 = new $this->model(); $myItem2 = $item2->where('location_id', $args['id'])->get(); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/locations'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/locations'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myLocations = []; foreach ($myItem2 as $current_location) { $name = $current_location->name; - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/dropdown/locations/" . $current_location->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $current_location->id); $entity = ''; - if ($current_location->entity != null) { - $entity = $current_location->entity->name; + $entity_url = ''; + if ($current_location->entity !== null) + { + $entity = $current_location->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $current_location->entity->id); } $address = $current_location->address; + $postcode = $current_location->postcode; + $town = $current_location->town; + $state = $current_location->state; + $country = $current_location->country; + $building = $current_location->building; + $room = $current_location->room; + $latitude = $current_location->latitude; + $longitude = $current_location->longitude; + $altitude = $current_location->altitude; + $comment = $current_location->comment; $myLocations[$current_location->id] = [ 'name' => $name, 'url' => $url, 'entity' => $entity, + 'entity_url' => $entity_url, 'address' => $address, 'postcode' => $postcode, 'town' => $town, diff --git a/src/v1/Controllers/Log.php b/src/v1/Controllers/Log.php index 3d9bc9d30d..fd394eef88 100644 --- a/src/v1/Controllers/Log.php +++ b/src/v1/Controllers/Log.php @@ -30,7 +30,9 @@ public static function addEntry( { $log->item_type = get_class($model); $log->item_id = $model->id; - } else { + } + else + { $log->item_type = $model; $log->item_id = 0; } @@ -38,14 +40,18 @@ public static function addEntry( if (is_object($old_value)) { $log->old_value = json_encode(['id' => $old_value->item->id, 'name' => $old_value->item->name]); - } else { + } + else + { $log->old_value = $old_value; } if (is_object($new_value)) { $log->new_value = json_encode(['id' => $new_value->item->id, 'name' => $new_value->item->name]); - } else { + } + else + { $log->new_value = $new_value; } $log->id_search_option = $idSearchOption; diff --git a/src/v1/Controllers/Login.php b/src/v1/Controllers/Login.php index 819d31652d..2ab1f001eb 100644 --- a/src/v1/Controllers/Login.php +++ b/src/v1/Controllers/Login.php @@ -15,10 +15,10 @@ public function getLogin(Request $request, Response $response, $args): Response $view = Twig::fromRequest($request); $viewData = [ - 'title' => 'GSIT - ' . 'Login page', - 'rootpath' => \App\v1\Controllers\Toolbox::getRootPath($request), - 'basePath' => $basePath, - 'sso' => [], + 'title' => 'GSIT - ' . 'Login page', + 'rootpath' => \App\v1\Controllers\Toolbox::getRootPath($request), + 'basePath' => $basePath, + 'sso' => [], ]; $authsso = \App\Models\Authsso::where('is_active', true)->get(); @@ -135,10 +135,13 @@ public function doSSO(Request $request, Response $response, $args) { $provider = $this->prepareSSOService($request, $args); - try { + try + { header('Location: ' . $provider->makeAuthUrl()); - } catch (\Exception $e) { - echo $e->getMessage(); + } + catch (\Exception $e) + { + echo $e->getMessage(); } exit; } @@ -199,23 +202,31 @@ private function prepareSSOService($request, $args) if (is_null($option->key)) { $dataProvider['options'][$item['suboption']][] = $option->value; - } else { + } + else + { $dataProvider['options'][$item['suboption']][$option->key] = $option->value; } } - } else { + } + else + { $dataProvider['options'] = []; foreach ($options as $option) { if (is_null($option->key)) { $dataProvider['options'][] = $option->value; - } else { + } + else + { $dataProvider['options'][$option->key] = $option->value; } } } - } else { + } + else + { $dataProvider[$field] = $authsso->{strtolower($field)}; } } @@ -252,7 +263,9 @@ public function changeProfileEntity(Request $request, Response $response, $args) if ($data->changeEntityRecursive == 'on') { $data->changeEntityRecursive = true; - } else { + } + else + { $data->changeEntityRecursive = false; } @@ -271,7 +284,10 @@ public function changeProfileEntity(Request $request, Response $response, $args) $data->changeEntityRecursive = false; } break; - } elseif ($profile->pivot->is_recursive) { + } + elseif + ($profile->pivot->is_recursive) + { // search if $data->changeEntity is in sub $profileEntity = \App\Models\Entity::find($profile->pivot->entity_id); $entity = \App\Models\Entity:: diff --git a/src/v1/Controllers/Mailcollector.php b/src/v1/Controllers/Mailcollector.php index 6c6b18b631..aae84f17ec 100644 --- a/src/v1/Controllers/Mailcollector.php +++ b/src/v1/Controllers/Mailcollector.php @@ -38,22 +38,25 @@ public function collect(\App\Models\Mailcollector $collector) $cm = new ClientManager($options = []); $client = $cm->account('account_identifier'); $client = $cm->make([ - 'host' => 'outlook.office365.com', - 'port' => 993, - 'encryption' => 'ssl', - 'validate_cert' => true, - 'username' => 'd.durieux@dcsit-group.com', + 'host' => 'outlook.office365.com', + 'port' => 993, + 'encryption' => 'ssl', + 'validate_cert' => true, + 'username' => 'd.durieux@dcsit-group.com', // 'password' => 'password', - 'password' => $collector->oauth_token, - 'authentication' => "oauth", - 'protocol' => 'imap' + 'password' => $collector->oauth_token, + 'authentication' => "oauth", + 'protocol' => 'imap' ]); //Connect to the IMAP Server $retry = false; - try { + try + { $client->connect(); - } catch (\Exception $e) { + } + catch (\Exception $e) + { $retry = true; } @@ -64,15 +67,15 @@ public function collect(\App\Models\Mailcollector $collector) $collector->refresh(); $client = $cm->make([ - 'host' => 'outlook.office365.com', - 'port' => 993, - 'encryption' => 'ssl', - 'validate_cert' => true, - 'username' => 'd.durieux@dcsit-group.com', + 'host' => 'outlook.office365.com', + 'port' => 993, + 'encryption' => 'ssl', + 'validate_cert' => true, + 'username' => 'd.durieux@dcsit-group.com', // 'password' => 'password', - 'password' => $collector->oauth_token, - 'authentication' => "oauth", - 'protocol' => 'imap' + 'password' => $collector->oauth_token, + 'authentication' => "oauth", + 'protocol' => 'imap' ]); $client->connect(); } @@ -102,7 +105,9 @@ public function collect(\App\Models\Mailcollector $collector) // if($message->move('INBOX.read') == true) // { // echo 'Message has ben moved'; - // } else { + // } + // else + // { // echo 'Message could not be moved'; // } @@ -128,7 +133,8 @@ public function collect(\App\Models\Mailcollector $collector) $values = $prio->toArray(); foreach ($values as $priority) { - switch ($priority) { + switch ($priority) + { case '1': $urgency = 5; break; @@ -149,10 +155,10 @@ public function collect(\App\Models\Mailcollector $collector) $data = (object) [ - 'name' => $message->getSubject(), - 'content' => \App\v1\Controllers\Toolbox::convertHtmlToMarkdown($message->getHTMLBody()), - 'requester' => implode(',', $requesters), - 'urgency' => $urgency, + 'name' => $message->getSubject(), + 'content' => \App\v1\Controllers\Toolbox::convertHtmlToMarkdown($message->getHTMLBody()), + 'requester' => implode(',', $requesters), + 'urgency' => $urgency, ]; $t = new \App\v1\Controllers\Ticket(); diff --git a/src/v1/Controllers/Menu.php b/src/v1/Controllers/Menu.php index 6f019cf348..a56ad3497d 100644 --- a/src/v1/Controllers/Menu.php +++ b/src/v1/Controllers/Menu.php @@ -123,7 +123,7 @@ private function menuData($request) 'link' => $basePath . '/view/itemdevicesimcards', 'icon' => 'sim card', 'class' => $activePath == $basePath . '/view/item_devicesimcards' ? 'active blue' : '', - 'display' => $this->getRightForModel('\App\Models\Devicesimcard'), + 'display' => $this->getRightForModel('\App\Models\ItemDevicesimcard'), ], ], ], @@ -141,14 +141,14 @@ private function menuData($request) [ 'name' => $translator->translatePlural('Problem', 'Problems', 2), 'link' => $basePath . '/view/problems', - 'icon' => 'exclamation triangle', + 'icon' => 'drafting compass', 'class' => $activePath == $basePath . '/view/problems' ? 'active blue' : '', 'display' => $this->getRightForModel('\App\Models\Problem'), ], [ 'name' => $translator->translatePlural('Change', 'Changes', 2), 'link' => $basePath . '/view/changes', - 'icon' => 'clipboard check', + 'icon' => 'paint roller', 'class' => $activePath == $basePath . '/view/changes' ? 'active blue' : '', 'display' => $this->getRightForModel('\App\Models\Change'), ], @@ -507,20 +507,20 @@ private function menuData($request) 'class' => $activePath == $basePath . '/view/dropdowns/ticketemplates' ? 'active blue' : '', 'display' => $this->getRightForModel('\App\Models\Tickettemplate'), ], - [ - 'name' => $translator->translatePlural('Task category', 'Task categories', 2), - 'link' => $basePath . '/view/dropdowns/taskcategory', - 'icon' => 'edit', - 'class' => $activePath == $basePath . '/view/dropdowns/taskcategories' ? 'active blue' : '', - 'display' => $this->getRightForModel('\App\Models\Taskcategories'), - ], - [ - 'name' => $translator->translatePlural('Task template', 'Task templates', 2), - 'link' => $basePath . '/view/dropdowns/tasktemplates', - 'icon' => 'edit', - 'class' => $activePath == $basePath . '/view/dropdowns/tasktemplates' ? 'active blue' : '', - 'display' => $this->getRightForModel('\App\Models\Tasktemplate'), - ], + // [ + // 'name' => $translator->translatePlural('Task category', 'Task categories', 2), + // 'link' => $basePath . '/view/dropdowns/taskcategory', + // 'icon' => 'edit', + // 'class' => $activePath == $basePath . '/view/dropdowns/taskcategories' ? 'active blue' : '', + // 'display' => $this->getRightForModel('\App\Models\Taskcategories'), + // ], + // [ + // 'name' => $translator->translatePlural('Task template', 'Task templates', 2), + // 'link' => $basePath . '/view/dropdowns/tasktemplates', + // 'icon' => 'edit', + // 'class' => $activePath == $basePath . '/view/dropdowns/tasktemplates' ? 'active blue' : '', + // 'display' => $this->getRightForModel('\App\Models\Tasktemplate'), + // ], [ 'name' => $translator->translatePlural('Solution type', 'Solution types', 2), 'link' => $basePath . '/view/dropdowns/solutiontypes', @@ -563,6 +563,13 @@ private function menuData($request) 'class' => $activePath == $basePath . '/view/dropdowns/projecttypes' ? 'active blue' : '', 'display' => $this->getRightForModel('\App\Models\Projecttype'), ], + [ + 'name' => $translator->translatePlural('Project task', 'Project tasks', 2), + 'link' => $basePath . '/view/dropdowns/projecttasks', + 'icon' => 'edit', + 'class' => $activePath == $basePath . '/view/dropdowns/projecttasks' ? 'active blue' : '', + 'display' => $this->getRightForModel('\App\Models\Projecttask'), + ], [ 'name' => $translator->translatePlural('Project tasks type', 'Project tasks types', 2), 'link' => $basePath . '/view/dropdowns/projecttasktypes', @@ -708,8 +715,7 @@ private function menuData($request) 'display' => $this->getRightForModel('\App\Models\Interfacetype'), ], [ - 'name' => $translator->translatePlural('Dropdown', 'Dropdowns', 2) . ' - ' . - $translator->translatePlural('Case type', 'Case types', 2), + 'name' => $translator->translatePlural('Case type', 'Case types', 2), 'link' => $basePath . '/view/dropdowns/devicecasetype', 'icon' => 'edit', 'class' => $activePath == $basePath . '/view/dropdowns/devicecasetype' ? 'active blue' : '', @@ -1237,7 +1243,7 @@ private function menuData($request) ], [ 'name' => $translator->translatePlural('Oauth IMAP application', 'Oauth IMAP applications', 2), - 'link' => $basePath . '/view/dropdowns/oauthimapPpplications', + 'link' => $basePath . '/view/dropdowns/oauthimapapplications', 'icon' => 'edit', 'class' => $activePath == $basePath . '/view/dropdowns/oauthimapapplications' ? 'active blue' : '', 'display' => $this->getRightForModel('\App\Models\OauthimapApplication'), @@ -1414,7 +1420,9 @@ private function cleanMenuByDisplay($menu) if (count($submenu) >= 6) { $more[] = $subitem; - } else { + } + else + { $submenu[] = $subitem; } } diff --git a/src/v1/Controllers/Monitor.php b/src/v1/Controllers/Monitor.php index 43e9399d2c..f8f0ea5d80 100644 --- a/src/v1/Controllers/Monitor.php +++ b/src/v1/Controllers/Monitor.php @@ -11,6 +11,7 @@ final class Monitor extends Common { protected $model = '\App\Models\Monitor'; protected $rootUrl2 = '/monitors/'; + protected $choose = 'monitors'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Networkequipment.php b/src/v1/Controllers/Networkequipment.php index 5b795ebc66..190440e770 100644 --- a/src/v1/Controllers/Networkequipment.php +++ b/src/v1/Controllers/Networkequipment.php @@ -11,6 +11,7 @@ final class Networkequipment extends Common { protected $model = '\App\Models\Networkequipment'; protected $rootUrl2 = '/networkequipments/'; + protected $choose = 'networkequipments'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Networkname.php b/src/v1/Controllers/Networkname.php index 00579cb90a..ab40057aa4 100644 --- a/src/v1/Controllers/Networkname.php +++ b/src/v1/Controllers/Networkname.php @@ -6,10 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Networkname extends Common { protected $model = '\App\Models\Networkname'; + protected $rootUrl2 = '/dropdowns/networknames/'; + protected $choose = 'networknames'; public function getAll(Request $request, Response $response, $args): Response { @@ -28,4 +31,73 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Networkname(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubNetworkalias(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/networkalias'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myNetworkAlias = []; + foreach ($myItem->alias as $current_item) + { + $name = $current_item->name; + + $url = ''; + // $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/networkalias/', $current_item->id); // TODO + + $domain = ''; + $domain_url = ''; + if ($myItem->fqdn !== null) + { + $domain = $myItem->fqdn->name; + $domain_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/fqdns/', $myItem->fqdn->id); + } + + $entity = ''; + $entity_url = ''; + if ($current_item->entity !== null) + { + $entity = $current_item->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $current_item->entity->id); + } + + $comment = $current_item->comment; + + $myNetworkAlias[] = [ + 'name' => $name, + 'url' => $url, + 'domain' => $domain, + 'domain_url' => $domain_url, + 'entity' => $entity, + 'entity_url' => $entity_url, + ]; + } + + // tri ordre alpha + uasort($myNetworkAlias, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('networkalias', $myNetworkAlias); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('name', $translator->translatePlural('Name', 'Names', 1)); + $viewData->addTranslation('domain', $translator->translatePlural('Internet domain', 'Internet domains', 1)); + $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); + + return $view->render($response, 'subitem/networkalias.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Notification.php b/src/v1/Controllers/Notification.php index 270ed8fead..6da9b61e16 100644 --- a/src/v1/Controllers/Notification.php +++ b/src/v1/Controllers/Notification.php @@ -145,7 +145,9 @@ private function generateDataForNotification($item, $data = [], $fields = null) if (isset($nestedFields[$definition['name']])) { $relationFields = $nestedFields[$definition['name']]; - } else { + } + else + { $relationFields = $definition['relationfields']; } @@ -162,14 +164,18 @@ private function generateDataForNotification($item, $data = [], $fields = null) $relationFields ); // $data[$definition['name']] = []; - } else { + } + else + { $data[$definition['name']] = $this->generateDataForNotification( $item->{$definition['name']}, [], $relationFields ); } - } else { + } + else + { // many to may relation $data[$definition['name']] = []; foreach ($item->{$definition['name']}()->get() as $rItem) @@ -178,7 +184,9 @@ private function generateDataForNotification($item, $data = [], $fields = null) $data[$definition['name']][] = $tempData; } } - } else { + } + else + { // it's fields if (is_null($item->{$definition['name']})) { @@ -189,14 +197,18 @@ private function generateDataForNotification($item, $data = [], $fields = null) if (empty($item->{$definition['name']})) { $data[$definition['name']] = null; - } else { + } + else + { $data[$definition['name']] = $definition['values'][$item->{$definition['name']}]['title']; } } elseif ($definition['type'] == 'datetime' && is_object($item->{$definition['name']})) { $data[$definition['name']] = $item->{$definition['name']}->toDateTimeString(); - } else { + } + else + { $data[$definition['name']] = $item->{$definition['name']}; } } @@ -244,7 +256,9 @@ private function generateLangdataForNotification($item, $data = [], $fields = nu if (isset($nestedFields[$definition['name']])) { $relationFields = $nestedFields[$definition['name']]; - } else { + } + else + { $relationFields = $definition['relationfields']; } @@ -254,7 +268,9 @@ private function generateLangdataForNotification($item, $data = [], $fields = nu [], $relationFields ); - } else { + } + else + { $data[$definition['name']] = $definition['title']; } } diff --git a/src/v1/Controllers/Notificationtemplate.php b/src/v1/Controllers/Notificationtemplate.php index f11c653b1a..88c59b239f 100644 --- a/src/v1/Controllers/Notificationtemplate.php +++ b/src/v1/Controllers/Notificationtemplate.php @@ -43,14 +43,14 @@ public function showSubTemplatetranslations(Request $request, Response $response foreach ($templatetrs as $templatetr) { $datat = [ - 'id' => $templatetr->id, - 'lang' => $templatetr->language, - 'subject' => true, + 'id' => $templatetr->id, + 'lang' => $templatetr->language, + 'subject' => true, 'subject_error' => '', - 'text' => false, - 'text_error' => '', - 'html' => true, - 'html_error' => '', + 'text' => false, + 'text_error' => '', + 'html' => true, + 'html_error' => '', ]; if (empty($datat['lang'])) { @@ -65,21 +65,29 @@ public function showSubTemplatetranslations(Request $request, Response $response } $item = new $className(); - try { + try + { $notificationctrl->render($templatetr->subject, $item); - } catch (\Throwable $th) { + } + catch (\Throwable $th) + { $datat['subject_error'] = $th->getMessage(); $datat['subject'] = false; } - try { + try + { $notificationctrl->render($templatetr->content_text, $item); - } catch (\Throwable $th) { + } + catch (\Throwable $th) + { $datat['text_error'] = $th->getMessage(); $datat['text'] = false; } try { $notificationctrl->render($templatetr->content_html, $item); - } catch (\Throwable $th) { + } + catch (\Throwable $th) + { $datat['html_error'] = $th->getMessage(); $datat['html'] = false; } @@ -108,9 +116,6 @@ public function showSubTemplatetranslation(Request $request, Response $response, $templatetr = \App\Models\Notificationtemplatetranslation::find($args['translationid']); - - - $rootUrl = $this->getUrlWithoutQuery($request); $rootUrl = rtrim($rootUrl, '/templatetranslation'); diff --git a/src/v1/Controllers/Pdu.php b/src/v1/Controllers/Pdu.php index c1f7651aab..8ab7e9990c 100644 --- a/src/v1/Controllers/Pdu.php +++ b/src/v1/Controllers/Pdu.php @@ -6,6 +6,7 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Pdu extends Common { @@ -29,4 +30,51 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Pdu(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubPlugs(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/plugs'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myPlugs = []; + foreach ($myItem->plugs as $current_plug) + { + $name = $current_plug->name; + + $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/plugs/', $current_plug->id); + + $number_plugs = $current_plug->pivot->number_plugs; + + $myPlugs[] = [ + 'name' => $name, + 'url' => $url, + 'number_plugs' => $number_plugs, + ]; + } + + // tri ordre alpha + uasort($myPlugs, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('plugs', $myPlugs); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('number', $translator->translate('Number')); + + return $view->render($response, 'subitem/plugs.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Peripheral.php b/src/v1/Controllers/Peripheral.php index da13bf900e..057a286552 100644 --- a/src/v1/Controllers/Peripheral.php +++ b/src/v1/Controllers/Peripheral.php @@ -11,6 +11,7 @@ final class Peripheral extends Common { protected $model = '\App\Models\Peripheral'; protected $rootUrl2 = '/peripherals/'; + protected $choose = 'peripherals'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Phone.php b/src/v1/Controllers/Phone.php index cb068e2d99..32e3cc87e9 100644 --- a/src/v1/Controllers/Phone.php +++ b/src/v1/Controllers/Phone.php @@ -11,6 +11,7 @@ final class Phone extends Common { protected $model = '\App\Models\Phone'; protected $rootUrl2 = '/phones/'; + protected $choose = 'phones'; public function getAll(Request $request, Response $response, $args): Response { diff --git a/src/v1/Controllers/Printer.php b/src/v1/Controllers/Printer.php index 5ebb4d4a04..f6b0af1726 100644 --- a/src/v1/Controllers/Printer.php +++ b/src/v1/Controllers/Printer.php @@ -12,6 +12,7 @@ final class Printer extends Common { protected $model = '\App\Models\Printer'; protected $rootUrl2 = '/printers/'; + protected $choose = 'printers'; public function getAll(Request $request, Response $response, $args): Response { @@ -41,52 +42,68 @@ public function showSubCartridges(Request $request, Response $response, $args): $myItem = $item::with('cartridges')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/cartridges'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/cartridges'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myCartridges_use = []; $myCartridges_out = []; + $pages = $myItem->init_pages_counter; + foreach ($myItem->cartridges as $cartridge) { - $url = ''; - $model = ''; + $model_url = ''; $type = ''; - if ($cartridge->cartridgeitems != null) { + $type_url = ''; + if ($cartridge->cartridgeitems !== null) + { $model = $cartridge->cartridgeitems->name . '' . $cartridge->cartridgeitems->ref; + $model_url = $this->genereRootUrl2Link($rootUrl2, '/cartridgeitems/', $cartridge->cartridgeitems->id); - if ($cartridge->cartridgeitems->type != null) { + if ($cartridge->cartridgeitems->type !== null) + { $type = $cartridge->cartridgeitems->type->name; - } - - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/cartridgeitems/" . $cartridge->cartridgeitems->id; + $type_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/cartridgeitemtypes/', + $cartridge->cartridgeitems->type->id + ); } } $date_add = $cartridge->date_in; + $date_use = $cartridge->date_use; + $date_end = $cartridge->date_out; + $printer_counter = $cartridge->pages; - $printed_pages = 0; // TODO - if ($cartridge->date_out == null) { + $printed_pages = 0; + if ($pages < $cartridge->pages) + { + $printed_pages = $cartridge->pages - $pages; + $pages = $cartridge->pages; + } + + if ($cartridge->date_out == null) + { $myCartridges_use[] = [ 'model' => $model, - 'url' => $url, + 'model_url' => $model_url, 'type' => $type, + 'type_url' => $type_url, 'date_add' => $date_add, 'date_use' => $date_use, ]; - } else { + } + else + { $myCartridges_out[] = [ 'model' => $model, - 'url' => $url, + 'model_url' => $model_url, 'type' => $type, + 'type_url' => $type_url, 'date_add' => $date_add, 'date_use' => $date_use, 'date_end' => $date_end, @@ -110,11 +127,9 @@ public function showSubCartridges(Request $request, Response $response, $args): $viewData->addTranslation('date_end', $translator->translate('End date')); $viewData->addTranslation('printer_counter', $translator->translate('Printer counter')); $viewData->addTranslation('printed_pages', $translator->translate('Printed pages')); - $viewData->addTranslation('cartridges_use', $translator->translate('Used cartridges')); $viewData->addTranslation('cartridges_out', $translator->translate('Worn cartridges')); - return $view->render($response, 'subitem/cartridgesprinters.html.twig', (array)$viewData); } } diff --git a/src/v1/Controllers/Problem.php b/src/v1/Controllers/Problem.php index f796b9ca2d..084ae5c1e0 100644 --- a/src/v1/Controllers/Problem.php +++ b/src/v1/Controllers/Problem.php @@ -6,11 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Problem extends Common { protected $model = '\App\Models\Problem'; protected $rootUrl2 = '/problems/'; + protected $choose = 'problems'; public function getAll(Request $request, Response $response, $args): Response { @@ -29,4 +31,126 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Problem(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubItems(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/items'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myItems = []; + foreach ($myItem->items as $current_item) + { + $item3 = new $current_item->item_type(); + $myItem3 = $item3->find($current_item->item_id); + if ($myItem3 !== null) + { + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); + + $current_id = $myItem3->id; + + $name = $myItem3->name; + if ($name == '') + { + $name = '(' . $current_id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $current_id); + + $entity = ''; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); + } + + $serial_number = $myItem3->serial; + + $inventaire_number = $myItem3->otherserial; + + $myItems[] = [ + 'type' => $type_fr, + 'name' => $name, + 'url' => $url, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'serial_number' => $serial_number, + 'inventaire_number' => $inventaire_number, + ]; + } + } + + // tri ordre alpha + uasort($myItems, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + uasort($myItems, function ($a, $b) + { + return strtolower($a['type']) > strtolower($b['type']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('items', $myItems); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('type', $translator->translatePlural('Type', 'Types', 1)); + $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('serial_number', $translator->translate('Serial number')); + $viewData->addTranslation('inventaire_number', $translator->translate('Inventory number')); + + return $view->render($response, 'subitem/items.html.twig', (array)$viewData); + } + + public function showAnalysis(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/analysis'); + + $myAnalysis = []; + $myAnalysis = [ + 'impactcontent' => $myItem->impactcontent, + 'causecontent' => $myItem->causecontent, + 'symptomcontent' => $myItem->symptomcontent, + ]; + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $getDefs = $item->getSpecificFunction('getDefinitionAnalysis'); + $myItemData = [ + 'impactcontent' => $myAnalysis['impactcontent'], + 'causecontent' => $myAnalysis['causecontent'], + 'symptomcontent' => $myAnalysis['symptomcontent'], + ]; + $myItemDataObject = json_decode(json_encode($myItemData)); + + $viewData->addData('fields', $item->getFormData($myItemDataObject, $getDefs)); + + $viewData->addTranslation('impactcontent', $translator->translate('Impacts')); + $viewData->addTranslation('causecontent', $translator->translate('Causes')); + $viewData->addTranslation('symptomcontent', $translator->translate('Symptoms')); + + return $view->render($response, 'subitem/analysis.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Profile.php b/src/v1/Controllers/Profile.php index a9182826e9..4de44a8841 100644 --- a/src/v1/Controllers/Profile.php +++ b/src/v1/Controllers/Profile.php @@ -9,6 +9,8 @@ final class Profile extends Common { protected $model = '\App\Models\Profile'; + protected $rootUrl2 = '/profiles/'; + protected $choose = 'profiles'; protected $rigthCategories = [ 'assets' => [ '\App\Models\Computer', @@ -24,7 +26,7 @@ final class Profile extends Common '\App\Models\Enclosure', '\App\Models\Pdu', '\App\Models\Passivedcequipment', - '\App\Models\Devicesimcard', + '\App\Models\ItemDevicesimcard', ], 'assistance' => [ '\App\Models\Ticket', @@ -49,6 +51,7 @@ final class Profile extends Common '\App\Models\Certificate', '\App\Models\Document', '\App\Models\Datacenter', + '\App\Models\Dcroom', '\App\Models\Cluster', '\App\Models\Domain', '\App\Models\Appliance', @@ -88,14 +91,15 @@ final class Profile extends Common '\App\Models\Blacklistedmailcontent', '\App\Models\Category', '\App\Models\Tickettemplate', - '\App\Models\Taskcategory', - '\App\Models\Tasktemplate', + // '\App\Models\Taskcategory', + // '\App\Models\Tasktemplate', '\App\Models\Solutiontype', '\App\Models\Solutiontemplate', '\App\Models\Requesttype', '\App\Models\Followuptemplate', '\App\Models\Projectstate', '\App\Models\Projecttype', + '\App\Models\Projecttask', '\App\Models\Projecttasktype', '\App\Models\Projecttasktemplate', '\App\Models\Planningeventcategory', @@ -206,6 +210,7 @@ final class Profile extends Common '\App\Models\Devicememory', '\App\Models\Deviceprocessor', '\App\Models\Devicepci', + '\App\Models\Devicesimcard', ], ]; @@ -298,8 +303,6 @@ public function itemSubSetup(Request $request, Response $response, $args): Respo return $this->itemSubCategory($request, $response, $args, 'setup'); } - - private function showSubCategory(Request $request, Response $response, $args, $category) { global $translator; @@ -309,8 +312,7 @@ private function showSubCategory(Request $request, Response $response, $args, $c $item = new \App\Models\Profile(); $myItem = $item->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/' . $category); + $rootUrl = $this->genereRootUrl($request, '/' . $category); $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addHeaderTitle('GSIT - ' . $item->getTitle(2)); @@ -353,8 +355,8 @@ private function itemSubCategory($request, $response, $args, $category) \App\Models\Profilerightcustom::updateOrCreate( [ - 'profileright_id' => $profileright->id, - 'definitionfield_id' => $def['id'], + 'profileright_id' => $profileright->id, + 'definitionfield_id' => $def['id'], ], [ 'read' => $read, @@ -363,7 +365,9 @@ private function itemSubCategory($request, $response, $args, $category) ); } } - } else { + } + else + { // Update general rights $rightLists = ['read', 'create', 'update', 'softdelete', 'delete', 'custom']; if ($category == 'assistance') @@ -381,14 +385,16 @@ private function itemSubCategory($request, $response, $args, $category) if (property_exists($data, $model . '-' . $right)) { $dataRights[$right] = true; - } else { + } + else + { $dataRights[$right] = false; } } \App\Models\Profileright::updateOrCreate( [ - 'profile_id' => $args['id'], - 'model' => ltrim($model, '\\'), + 'profile_id' => $args['id'], + 'model' => ltrim($model, '\\'), ], $dataRights, ); @@ -418,9 +424,9 @@ private function getRightsCategory($profile_id, $category) if ($category == 'assistance') { $customData = [ - 'model' => $model, - 'title' => $item->getTitle(2), - 'rights' => [ + 'model' => $model, + 'title' => $item->getTitle(2), + 'rights' => [ 'read' => $profileright->read, 'readmyitems' => 'disabled', 'readmygroupitems' => 'disabled', @@ -444,11 +450,13 @@ private function getRightsCategory($profile_id, $category) $customData['rights']['readprivateitems'] = $profileright->readprivateitems; } $data[] = $customData; - } else { + } + else + { $data[] = [ - 'model' => $model, - 'title' => $item->getTitle(2), - 'rights' => [ + 'model' => $model, + 'title' => $item->getTitle(2), + 'rights' => [ 'read' => $profileright->read, 'create' => $profileright->create, 'update' => $profileright->update, @@ -503,7 +511,9 @@ private function getRightsCategoryCustom($profile_id, $category) 'read' => boolval($ids[$def["id"]]['read']), 'write' => boolval($ids[$def["id"]]['write']), ]; - } else { + } + else + { $itemData['customs'][] = [ 'title' => $def['title'], 'name' => $def['name'], @@ -561,4 +571,103 @@ public static function canRightReadItem($item) return false; } + + public function showSubUsers(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $item2 = new \App\Models\ProfileUser(); + $myItem2 = $item2::where('profile_id', $args['id'])->get(); + + $rootUrl = $this->genereRootUrl($request, '/users'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myUsers = []; + foreach ($myItem2 as $current_item) + { + $entity_id = $current_item->entity_id; + $entity = ''; + $findentity = \App\Models\Entity::find($entity_id); + if ($findentity !== null) + { + $entity = $findentity->completename; + } + + $user_id = $current_item->user_id; + $user = ''; + $finduser = \App\Models\User::find($user_id); + if ($finduser !== null) + { + $user = $this->genereUserName($finduser->name, $finduser->lastname, $finduser->firstname); + } + + $is_recursive = ''; + if ($current_item->is_recursive == 1) + { + $is_recursive_val = $translator->translate('Yes'); + } + else + { + $is_recursive_val = $translator->translate('No'); + } + + $is_dynamic = ''; + if ($current_item->is_dynamic == 1) + { + $is_dynamic_val = $translator->translate('Yes'); + } + else + { + $is_dynamic_val = $translator->translate('No'); + } + + if (($entity != '') && ($user != '')) + { + if (array_key_exists($entity_id, $myUsers) !== true) + { + $myUsers[$entity_id] = [ + 'name' => $entity, + 'users' => [], + ]; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/users/', $user_id); + + $myUsers[$entity_id]['users'][$user_id] = [ + 'name' => $user, + 'url' => $url, + 'is_recursive' => $is_recursive, + 'is_recursive_val' => $is_recursive_val, + 'is_dynamic' => $is_dynamic, + 'is_dynamic_val' => $is_dynamic_val, + ]; + } + } + + // tri ordre alpha + uasort($myUsers, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('users', $myUsers); + $viewData->addData('show', $this->choose); + + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('is_dynamic', $translator->translate('Dynamic')); + $viewData->addTranslation('is_recursive', $translator->translate('Recursive')); + + return $view->render($response, 'subitem/users.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Project.php b/src/v1/Controllers/Project.php index 4751a9eb6b..c324067b69 100644 --- a/src/v1/Controllers/Project.php +++ b/src/v1/Controllers/Project.php @@ -12,7 +12,7 @@ final class Project extends Common { protected $model = '\App\Models\Project'; protected $rootUrl2 = '/projects/'; - protected $costchoose = 'project'; + protected $choose = 'projects'; public function getAll(Request $request, Response $response, $args): Response { @@ -32,7 +32,6 @@ public function updateItem(Request $request, Response $response, $args): Respons return $this->commonUpdateItem($request, $response, $args, $item); } - public function showSubProjecttasks(Request $request, Response $response, $args): Response { global $translator; @@ -43,28 +42,24 @@ public function showSubProjecttasks(Request $request, Response $response, $args) $myItem = $item::with('tasks')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/projecttasks'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/projecttasks'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myProjecttasks = []; foreach ($myItem->tasks as $task) { $name = $task->name; - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/projecttasks/" . $task->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/projecttasks/', $task->id); $type = ''; + $type_url = ''; if ($task->type !== null) { $type = $task->type->name; + $type_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/projecttasktypes/', $task->type->id); } + $status = ''; $status_color = ''; if ($task->state !== null) @@ -72,26 +67,31 @@ public function showSubProjecttasks(Request $request, Response $response, $args) $status = $task->state->name; $status_color = $task->state->color; } + $percent_done = $task->percent_done; + $percent_done = $this->getValueWithUnit($percent_done, '%', 0); + $planned_start_date = $task->plan_start_date; + $planned_end_date = $task->plan_end_date; + $planned_duration = $this->timestampToString($task->planned_duration, false); + $effective_duration = $this->timestampToString($task->effective_duration, false); + $father = ''; $father_url = ''; - if ($task->parent !== null) { $father = $task->parent->name; - if ($rootUrl2 != '') { - $father_url = $rootUrl2 . "/projecttasks/" . $task->parent->id; - } + $father_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/projecttasks/', $task->parent->id); } $myProjecttasks[] = [ 'name' => $name, 'url' => $url, 'type' => $type, + 'type_url' => $type_url, 'status' => $status, 'status_color' => $status_color, 'percent_done' => $percent_done, @@ -109,6 +109,7 @@ public function showSubProjecttasks(Request $request, Response $response, $args) $viewData->addData('fields', $item->getFormData($myItem)); $viewData->addData('projecttasks', $myProjecttasks); + $viewData->addData('show', $this->choose); $viewData->addTranslation('name', $translator->translate('Name')); $viewData->addTranslation('type', $translator->translatePlural('Type', 'Types', 1)); @@ -133,21 +134,15 @@ public function showSubProjects(Request $request, Response $response, $args): Re $myItem = $item::with('parents')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/projects'); - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/projects'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myProjects = []; foreach ($myItem->parents as $parent) { $name = $parent->name; - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/projects/" . $parent->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/projects/', $parent->id); $status = ''; $status_color = ''; @@ -156,32 +151,34 @@ public function showSubProjects(Request $request, Response $response, $args): Re $status = $parent->state->name; $status_color = $parent->state->color; } + $open_date = $parent->date; + $last_update = $parent->updated_at; + $entity = ''; + $entity_url = ''; if ($parent->entity !== null) { - $entity = $parent->entity->name; + $entity = $parent->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $parent->entity->id); } + $priority = $this->getPriorityArray()[$parent->priority]; $manager = ''; $manager_url = ''; if ($parent->user !== null) { - $manager = $parent->user->name; - if ($rootUrl2 != '') { - $manager_url = $rootUrl2 . "/users/" . $parent->user->id; - } + $manager = $this->genereUserName($parent->user->name, $parent->user->lastname, $parent->user->firstname); + $manager_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $parent->user->id); } $manager_group = ''; $manager_group_url = ''; if ($parent->group !== null) { - $manager_group = $parent->group->name; - if ($rootUrl2 != '') { - $manager_group_url = $rootUrl2 . "/groups/" . $parent->group->id; - } + $manager_group = $parent->group->completename; + $manager_group_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $parent->group->id); } $myProjects[] = [ @@ -192,6 +189,7 @@ public function showSubProjects(Request $request, Response $response, $args): Re 'open_date' => $open_date, 'last_update' => $last_update, 'entity' => $entity, + 'entity_url' => $entity_url, 'priority' => $priority, 'manager' => $manager, 'manager_url' => $manager_url, @@ -231,12 +229,8 @@ public function showSubProjectteams(Request $request, Response $response, $args) $item2 = new \App\Models\Projectteam(); $myItem2 = $item2::where('project_id', $args['id'])->get(); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/projectteams'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/projectteams'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myProjectteams = []; foreach ($myItem2 as $current_item) @@ -244,34 +238,31 @@ public function showSubProjectteams(Request $request, Response $response, $args) $item3 = new $current_item->item_type(); $myItem3 = $item3->find($current_item->item_id); - if ($myItem3 != null) { + if ($myItem3 !== null) + { + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); + $name = $myItem3->name; - if (isset($myItem3->firstname)) { + if (isset($myItem3->firstname)) + { $name = $name . ' ' . $myItem3->firstname; } - if ($name == '') { + if ($name == '') + { $name = '(' . $myItem3->id . ')'; } - $url = ''; - if ($rootUrl2 != '') { - $table = $item3->getTable(); - if ($table != '') { - $url = $rootUrl2 . "/" . $table . "/" . $myItem3->id; - } - } - - $type = $item3->getTitle(); + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem3->id); $myProjectteams[] = [ 'member' => $name, 'url' => $url, - 'type' => $type, + 'type' => $type_fr, ]; } } - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -297,48 +288,45 @@ public function showSubItems(Request $request, Response $response, $args): Respo $item2 = new \App\Models\Projectitem(); $myItem2 = $item2::where('project_id', $args['id'])->get(); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/items'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/items'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myItems = []; foreach ($myItem2 as $appliance_item) { $item3 = new $appliance_item->item_type(); $myItem3 = $item3->find($appliance_item->item_id); - - if ($myItem3 != null) { - $type = $item3->getTitle(); + if ($myItem3 !== null) + { + $type = $item3->getTable(); + $type_fr = $item3->getTitle(); $name = $myItem3->name; - if ($name == '') { + if ($name == '') + { $name = '(' . $myItem3->id . ')'; } - $url = ''; - if ($rootUrl2 != '') { - $table = $item3->getTable(); - if ($table != '') { - $url = $rootUrl2 . "/" . $table . "/" . $myItem3->id; - } - } + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem3->id); $entity = ''; - if ($myItem3->entity != null) { - $entity = $myItem3->entity->name; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); } $serial_number = $myItem3->serial; + $inventaire_number = $myItem3->otherserial; $myItems[] = [ - 'type' => $type, + 'type' => $type_fr, 'name' => $name, 'url' => $url, 'entity' => $entity, + 'entity_url' => $entity_url, 'serial_number' => $serial_number, 'inventaire_number' => $inventaire_number, ]; @@ -346,11 +334,11 @@ public function showSubItems(Request $request, Response $response, $args): Respo } // tri ordre alpha - usort($myItems, function ($a, $b) + uasort($myItems, function ($a, $b) { return strtolower($a['name']) > strtolower($b['name']); }); - usort($myItems, function ($a, $b) + uasort($myItems, function ($a, $b) { return strtolower($a['type']) > strtolower($b['type']); }); @@ -360,7 +348,7 @@ public function showSubItems(Request $request, Response $response, $args): Respo $viewData->addData('fields', $item->getFormData($myItem)); $viewData->addData('items', $myItems); - $viewData->addData('show', 'project'); + $viewData->addData('show', $this->choose); $viewData->addTranslation('type', $translator->translate('Item type')); $viewData->addTranslation('name', $translator->translatePlural('Item', 'Items', 1)); @@ -384,12 +372,8 @@ public function showSubItilitems(Request $request, Response $response, $args): R $item2 = new \App\Models\Itilproject(); $myItem2 = $item2::where('project_id', $args['id'])->get(); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/itilitems'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/itilitems'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $tickets = []; $problems = []; @@ -398,211 +382,348 @@ public function showSubItilitems(Request $request, Response $response, $args): R { $item3 = new $appliance_item->item_type(); $myItem3 = $item3->find($appliance_item->item_id); - - if ($myItem3 != null) { - $table = $item3->getTable(); - - if ($table == 'changes') { - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/changes/" . $myItem3->id; - } + if ($myItem3 !== null) + { + $type = $item3->getTable(); + if ($type == 'changes') + { + $url = $this->genereRootUrl2Link($rootUrl2, '/changes/', $myItem3->id); $status = $this->getStatusArray()[$myItem3->status]; $entity = ''; - if ($myItem3->entity != null) { - $entity = $myItem3->entity->name; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); } $priority = $this->getPriorityArray()[$myItem3->priority]; $requesters = []; - if ($myItem3->requester != null) { - foreach ($myItem3->requester as $requester) { - $requesters[] = ['name' => $requester->name]; + if ($myItem3->requester !== null) + { + foreach ($myItem3->requester as $requester) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $requester->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $this->genereUserName($requester->name, $requester->lastname, $requester->firstname), + ]; } } - if ($myItem3->requestergroup != null) { - foreach ($myItem3->requestergroup as $requestergroup) { - $requesters[] = ['name' => $requestergroup->completename]; + if ($myItem3->requestergroup !== null) + { + foreach ($myItem3->requestergroup as $requestergroup) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $requestergroup->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $requestergroup->completename, + ]; } } + $technicians = []; - if ($myItem3->technician != null) { - foreach ($myItem3->technician as $technician) { - $technicians[] = ['name' => $technician->name]; + if ($myItem3->technician !== null) + { + foreach ($myItem3->technician as $technician) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $technician->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $this->genereUserName($technician->name, $technician->lastname, $technician->firstname), + ]; } } - if ($myItem3->techniciangroup != null) { - foreach ($myItem3->techniciangroup as $techniciangroup) { - $technicians[] = ['name' => $techniciangroup->completename]; + if ($myItem3->techniciangroup !== null) + { + foreach ($myItem3->techniciangroup as $techniciangroup) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $techniciangroup->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $techniciangroup->completename, + ]; } } + $category = ''; - if ($myItem3->itilcategorie != null) { + $category_url = ''; + if ($myItem3->itilcategorie !== null) + { $category = $myItem3->itilcategorie->name; + $category_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/categories/', $myItem3->itilcategorie->id); } + $planification = 0; // TODO $changes[$myItem3->id] = [ - 'url' => $url, - 'status' => $status, - 'date' => $myItem3->date, - 'last_update' => $myItem3->updated_at, - 'entity' => $entity, - 'priority' => $priority, - 'requesters' => $requesters, - 'technicians' => $technicians, - 'title' => $myItem3->name, - 'category' => $category, - 'planification' => $planification, + 'url' => $url, + 'status' => $status, + 'date' => $myItem3->date, + 'last_update' => $myItem3->updated_at, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'priority' => $priority, + 'requesters' => $requesters, + 'technicians' => $technicians, + 'title' => $myItem3->name, + 'category' => $category, + 'category_url' => $category_url, + 'planification' => $planification, ]; } - if ($table == 'problems') { - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/problems/" . $myItem3->id; - } + if ($type == 'problems') + { + $url = $this->genereRootUrl2Link($rootUrl2, '/problems/', $myItem3->id); $status = $this->getStatusArray()[$myItem3->status]; $entity = ''; - if ($myItem3->entity != null) { - $entity = $myItem3->entity->name; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); } $priority = $this->getPriorityArray()[$myItem3->priority]; $requesters = []; - if ($myItem3->requester != null) { - foreach ($myItem3->requester as $requester) { - $requesters[] = ['name' => $requester->name]; + if ($myItem3->requester !== null) + { + foreach ($myItem3->requester as $requester) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $requester->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $this->genereUserName($requester->name, $requester->lastname, $requester->firstname), + ]; } } - - if ($myItem3->requestergroup != null) { - foreach ($myItem3->requestergroup as $requestergroup) { - $requesters[] = ['name' => $requestergroup->completename]; + if ($myItem3->requestergroup !== null) + { + foreach ($myItem3->requestergroup as $requestergroup) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $requestergroup->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $requestergroup->completename, + ]; } } $technicians = []; - if ($myItem3->technician != null) { - foreach ($myItem3->technician as $technician) { - $technicians[] = ['name' => $technician->name]; + if ($myItem3->technician !== null) + { + foreach ($myItem3->technician as $technician) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $technician->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $this->genereUserName($technician->name, $technician->lastname, $technician->firstname), + ]; } } - - if ($myItem3->techniciangroup != null) { - foreach ($myItem3->techniciangroup as $techniciangroup) { - $technicians[] = ['name' => $techniciangroup->completename]; + if ($myItem3->techniciangroup !== null) + { + foreach ($myItem3->techniciangroup as $techniciangroup) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $techniciangroup->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $techniciangroup->completename, + ]; } } $category = ''; - if ($myItem3->category != null) { + $category_url = ''; + if ($myItem3->category !== null) + { $category = $myItem3->category->name; + $category_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/categories/', $myItem3->category->id); } $planification = 0; // TODO - $problems[$myItem3->id] = [ - 'url' => $url, - 'status' => $status, - 'date' => $myItem3->date, - 'last_update' => $myItem3->updated_at, - 'entity' => $entity, - 'priority' => $priority, - 'requesters' => $requesters, - 'technicians' => $technicians, - 'title' => $myItem3->name, - 'category' => $category, - 'planification' => $planification, + 'url' => $url, + 'status' => $status, + 'date' => $myItem3->date, + 'last_update' => $myItem3->updated_at, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'priority' => $priority, + 'requesters' => $requesters, + 'technicians' => $technicians, + 'title' => $myItem3->name, + 'category' => $category, + 'category_url' => $category_url, + 'planification' => $planification, ]; } - if ($table == 'tickets') { - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/tickets/" . $myItem3->id; - } + if ($type == 'tickets') + { + $url = $this->genereRootUrl2Link($rootUrl2, '/tickets/', $myItem3->id); $status = $this->getStatusArray()[$myItem3->status]; $entity = ''; - if ($myItem3->entity != null) { - $entity = $myItem3->entity->name; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); } $priority = $this->getPriorityArray()[$myItem3->priority]; $requesters = []; - if ($myItem3->requester != null) { - foreach ($myItem3->requester as $requester) { - $requesters[] = ['name' => $requester->name]; + if ($myItem3->requester !== null) + { + foreach ($myItem3->requester as $requester) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $requester->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $this->genereUserName($requester->name, $requester->lastname, $requester->firstname), + ]; } } - - if ($myItem3->requestergroup != null) { - foreach ($myItem3->requestergroup as $requestergroup) { - $requesters[] = ['name' => $requestergroup->completename]; + if ($myItem3->requestergroup !== null) + { + foreach ($myItem3->requestergroup as $requestergroup) + { + $requester_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $requestergroup->id); + + $requesters[] = [ + 'url' => $requester_url, + 'name' => $requestergroup->completename, + ]; } } $technicians = []; - if ($myItem3->technician != null) { - foreach ($myItem3->technician as $technician) { - $technicians[] = ['name' => $technician->name]; + if ($myItem3->technician !== null) + { + foreach ($myItem3->technician as $technician) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $technician->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $this->genereUserName($technician->name, $technician->lastname, $technician->firstname), + ]; } } - - if ($myItem3->techniciangroup != null) { - foreach ($myItem3->techniciangroup as $techniciangroup) { - $technicians[] = ['name' => $techniciangroup->completename]; + if ($myItem3->techniciangroup !== null) + { + foreach ($myItem3->techniciangroup as $techniciangroup) + { + $technician_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $techniciangroup->id); + + $technicians[] = [ + 'url' => $technician_url, + 'name' => $techniciangroup->completename, + ]; } } - $associated_items = []; // TODO + $associated_items = []; + $item4 = new \App\Models\ItemTicket(); + $myItem4 = $item4::where('ticket_id', $myItem3->id)->get(); + if ($myItem4 !== null) + { + foreach ($myItem4 as $val) + { + $item5 = new $val->item_type(); + $myItem5 = $item5->find($val->item_id); + if ($myItem5 !== null) + { + $type5_fr = $item5->getTitle(); + $type5 = $item5->getTable(); + + $name5 = $myItem5->name; + + $url5 = $this->genereRootUrl2Link($rootUrl2, '/' . $type5 . '/', $myItem5->id); + + if ($type5_fr != '') + { + $type5_fr = $type5_fr . ' - '; + } + + $associated_items[] = [ + 'type' => $type5_fr, + 'name' => $name5, + 'url' => $url5, + ]; + } + } + + if (empty($associated_items)) + { + $associated_items[] = [ + 'type' => '', + 'name' => $translator->translate('General'), + 'url' => '', + ]; + } + } $category = ''; - if ($myItem3->category != null) { + $category_url = ''; + if ($myItem3->category !== null) + { $category = $myItem3->category->name; + $category_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/categories/', $myItem3->category->id); } $planification = 0; // TODO - $tickets[$myItem3->id] = [ - 'url' => $url, - 'status' => $status, - 'date' => $myItem3->date, - 'last_update' => $myItem3->updated_at, - 'entity' => $entity, - 'priority' => $priority, - 'requesters' => $requesters, - 'technicians' => $technicians, - 'associated_items' => $associated_items, - 'title' => $myItem3->name, - 'category' => $category, - 'planification' => $planification, + 'url' => $url, + 'status' => $status, + 'date' => $myItem3->date, + 'last_update' => $myItem3->updated_at, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'priority' => $priority, + 'requesters' => $requesters, + 'technicians' => $technicians, + 'title' => $myItem3->name, + 'associated_items' => $associated_items, + 'category' => $category, + 'category_url' => $category_url, + 'planification' => $planification, ]; } } } - // tri de la + récente à la + ancienne - usort($tickets, function ($a, $b) + // tri de la + récente à la + ancienne + uasort($tickets, function ($a, $b) { - return strtolower($a['last_update']) > strtolower($b['last_update']); + return $a['last_update'] > $b['last_update']; }); - usort($problems, function ($a, $b) + uasort($problems, function ($a, $b) { - return strtolower($a['last_update']) > strtolower($b['last_update']); + return $a['last_update'] > $b['last_update']; }); - usort($changes, function ($a, $b) + uasort($changes, function ($a, $b) { - return strtolower($a['last_update']) > strtolower($b['last_update']); + return $a['last_update'] > $b['last_update']; }); $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); diff --git a/src/v1/Controllers/Projecttask.php b/src/v1/Controllers/Projecttask.php index 01b35ce787..144c5e99f1 100644 --- a/src/v1/Controllers/Projecttask.php +++ b/src/v1/Controllers/Projecttask.php @@ -6,10 +6,13 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Projecttask extends Common { protected $model = '\App\Models\Projecttask'; + protected $rootUrl2 = '/projecttasks/'; + protected $choose = 'projecttasks'; public function getAll(Request $request, Response $response, $args): Response { @@ -28,4 +31,158 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Projecttask(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubProjecttasks(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $item2 = new \App\Models\Projecttask(); + $myItem2 = $item2::where('projecttask_id', $args['id'])->get(); + + $rootUrl = $this->genereRootUrl($request, '/projecttasks'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myProjecttasks = []; + foreach ($myItem2 as $current_task) + { + $name = $current_task->name; + + $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/projecttasks/', $current_task->id); + + $type = ''; + $type_url = ''; + if ($current_task->type !== null) + { + $type = $current_task->type->name; + $type_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/projecttasktypes/', $current_task->type->id); + } + + $status = ''; + $status_color = ''; + if ($current_task->state !== null) + { + $status = $current_task->state->name; + $status_color = $current_task->state->color; + } + + $percent_done = $current_task->percent_done; + $percent_done = $this->getValueWithUnit($percent_done, '%', 0); + + $planned_start_date = $current_task->plan_start_date; + + $planned_end_date = $current_task->plan_end_date; + + $planned_duration = $this->timestampToString($current_task->planned_duration, false); + + $effective_duration = $this->timestampToString($current_task->effective_duration, false); + + $father = ''; + $father_url = ''; + if ($current_task->parent !== null) + { + $father = $current_task->parent->name; + $father_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/projecttasks/', $current_task->parent->id); + } + + $myProjecttasks[] = [ + 'name' => $name, + 'url' => $url, + 'type' => $type, + 'type_url' => $type_url, + 'status' => $status, + 'status_color' => $status_color, + 'percent_done' => $percent_done, + 'planned_start_date' => $planned_start_date, + 'planned_end_date' => $planned_end_date, + 'planned_duration' => $planned_duration, + 'effective_duration' => $effective_duration, + 'father' => $father, + 'father_url' => $father_url, + ]; + } + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('projecttasks', $myProjecttasks); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('type', $translator->translatePlural('Type', 'Types', 1)); + $viewData->addTranslation('status', $translator->translate('Status')); + $viewData->addTranslation('percent_done', $translator->translate('Percent done')); + $viewData->addTranslation('planned_start_date', $translator->translate('Planned start date')); + $viewData->addTranslation('planned_end_date', $translator->translate('Planned end date')); + $viewData->addTranslation('planned_duration', $translator->translate('Planned duration')); + $viewData->addTranslation('effective_duration', $translator->translate('Effective duration')); + $viewData->addTranslation('father', $translator->translate('Father')); + + return $view->render($response, 'subitem/projecttasks.html.twig', (array)$viewData); + } + + public function showSubProjecttaskteams(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $item2 = new \App\Models\Projecttaskteam(); + $myItem2 = $item2::where('projecttask_id', $args['id'])->get(); + + $rootUrl = $this->genereRootUrl($request, '/projecttaskteams'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myProjecttaskteams = []; + foreach ($myItem2 as $current_item) + { + $item3 = new $current_item->item_type(); + $myItem3 = $item3->find($current_item->item_id); + + if ($myItem3 !== null) + { + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); + + $name = $myItem3->name; + if (isset($myItem3->firstname)) + { + $name = $name . ' ' . $myItem3->firstname; + } + if ($name == '') + { + $name = '(' . $myItem3->id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem3->id); + + $myProjecttaskteams[] = [ + 'member' => $name, + 'url' => $url, + 'type' => $type_fr, + ]; + } + } + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('projecttaskteams', $myProjecttaskteams); + + $viewData->addTranslation('type', $translator->translatePlural('Type', 'Types', 1)); + $viewData->addTranslation('member', $translator->translatePlural('Member', 'Members', 2)); + + return $view->render($response, 'subitem/projecttaskteams.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Queuednotification.php b/src/v1/Controllers/Queuednotification.php index fc339e89f4..4693a47838 100644 --- a/src/v1/Controllers/Queuednotification.php +++ b/src/v1/Controllers/Queuednotification.php @@ -68,7 +68,8 @@ private function sendMails() { // TODO send mail - try { + try + { //Server settings // $mailer->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output $mailer->isSMTP(); //Send using SMTP @@ -114,7 +115,9 @@ private function sendMails() $mail->delete(); $nbMailsSend++; - } catch (Exception $e) { + } + catch (Exception $e) + { echo "Message could not be sent. Mailer Error: {$mailer->ErrorInfo}"; } } diff --git a/src/v1/Controllers/Rules/Common.php b/src/v1/Controllers/Rules/Common.php index ceaed96f87..b3dd1970c0 100644 --- a/src/v1/Controllers/Rules/Common.php +++ b/src/v1/Controllers/Rules/Common.php @@ -173,7 +173,9 @@ public function executeActions($rule, $output, $params, array $input = []) if (isset($this->regex_results[0])) { // $res = RuleAction::getRegexResultById($action->value, $this->regex_results[0]); - } else { + } + else + { $res = $action->value; } @@ -182,7 +184,9 @@ public function executeActions($rule, $output, $params, array $input = []) if (isset($params[$action->field])) { $res = $params[$action->field] . $res; - } else { + } + else + { //keep rule value to append in a separate entry $output[$action->field . '_append'] = $res; } @@ -232,7 +236,10 @@ public function checkCriterias($rule, $input) } // } } - } else { // OR MATCHING + } + else + { + // OR MATCHING $doactions = false; foreach ($criteria as $criterion) { @@ -290,7 +297,9 @@ public function checkCriteria($criterion, &$input) $this->criterias_results, $partial_regex_result ); - } else { + } + else + { //If the value is, in fact, an array of values // Negative condition : Need to match all condition (never be) if ( @@ -321,7 +330,9 @@ public function checkCriteria($criterion, &$input) break; } } - } else { + } + else + { // Positive condition : Need to match one $res = false; foreach ($input[$criterion->criteria] as $crit) @@ -345,7 +356,10 @@ public function checkCriteria($criterion, &$input) if (!count($this->regex_results)) { $this->regex_results = $partial_regex_result; - } else { // Already existing regex : append found values + } + else + { + // Already existing regex : append found values $temp_result = []; foreach ($partial_regex_result as $new) { diff --git a/src/v1/Controllers/Rules/Criterium.php b/src/v1/Controllers/Rules/Criterium.php index cc446b3bfb..b722999b92 100644 --- a/src/v1/Controllers/Rules/Criterium.php +++ b/src/v1/Controllers/Rules/Criterium.php @@ -51,7 +51,9 @@ public static function match($criterion, $field, &$criterias_results, &$regex_re $criterias_results[$criteria] = $pattern; return true; } - } else { + } + else + { //Perform comparison with fields in lower case $field = \App\v1\Controllers\Toolbox::strtolower($field); $pattern = \App\v1\Controllers\Toolbox::strtolower($pattern); diff --git a/src/v1/Controllers/Search.php b/src/v1/Controllers/Search.php index c15952e902..68ddcb7276 100644 --- a/src/v1/Controllers/Search.php +++ b/src/v1/Controllers/Search.php @@ -69,7 +69,9 @@ public function getData($item, $uri, $page = 1, $filters = []) if (is_array($value)) { $item = $item->where($key, $value[0], $value[1]); - } else { + } + else + { $item = $item->where($key, $value); } } @@ -85,7 +87,9 @@ public function getData($item, $uri, $page = 1, $filters = []) if ($GLOBALS['entity_recursive']) { $query->where('treepath', 'LIKE', $GLOBALS['entity_treepath'] . '%'); - } else { + } + else + { $query->where('treepath', $GLOBALS['entity_treepath']); } }); @@ -117,10 +121,10 @@ public function getData($item, $uri, $page = 1, $filters = []) // die(); $itemDbData['paging'] = [ - 'total' => $cnt, - 'pages' => ceil($cnt / $limit), - 'current' => $page, - 'linkpage' => $uri . '?page=', + 'total' => $cnt, + 'pages' => ceil($cnt / $limit), + 'current' => $page, + 'linkpage' => $uri . '?page=', ]; return $itemDbData; } @@ -151,7 +155,9 @@ private function prepareValues($itemDef, $data, $uri) $myData[$field['name']] = [ 'value' => '', ]; - } else { + } + else + { if (isset($field['count'])) { $elements = []; @@ -173,7 +179,9 @@ private function prepareValues($itemDef, $data, $uri) $myData[$field['name']] = [ 'value' => implode(', ', $elements), ]; - } else { + } + else + { $myData[$field['name']] = [ 'value' => $item->{$field['name']}->name, ]; @@ -187,7 +195,9 @@ private function prepareValues($itemDef, $data, $uri) $myData[$field['name']] = [ 'value' => $field['values'][$item->{$field['name']}], ]; - } else { + } + else + { $myData[$field['name']] = []; } } @@ -207,9 +217,9 @@ private function prepareValues($itemDef, $data, $uri) $allData[] = $myData; } return [ - 'header' => $header, - 'data' => $allData, - 'allFields' => $itemDef, + 'header' => $header, + 'data' => $allData, + 'allFields' => $itemDef, ]; } @@ -224,7 +234,9 @@ private function manageFilters($itemDef, $params) if ($field['type'] == 'dropdown_remote') { return [$field['name'] => $params['value']]; - } else { + } + else + { return [$field['name'] => ['LIKE', '%' . $params['value'] . '%']]; } } diff --git a/src/v1/Controllers/Slm.php b/src/v1/Controllers/Slm.php index 18cd901fbc..b236756d40 100644 --- a/src/v1/Controllers/Slm.php +++ b/src/v1/Controllers/Slm.php @@ -6,10 +6,12 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Slm extends Common { protected $model = '\App\Models\Slm'; + protected $rootUrl2 = '/slms/'; public function getAll(Request $request, Response $response, $args): Response { @@ -28,4 +30,132 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Slm(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubSlas(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/slas'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $mySlas = []; + foreach ($myItem->slas as $current_sla) + { + $name = $current_sla->name; + + $url = ''; + // $url = $this->genereRootUrl2Link($rootUrl2, '/slas/', $current_sla->id); // TODO + + $type = $this->getTtrTto()[$current_sla->type]; + + $max_duration = $this->getValueWithUnit($current_sla->number_time, $current_sla->definition_time, 0); + + $calendar_name = ''; + $calendar_url = ''; + if ($myItem->calendar !== null) + { + $calendar_name = $myItem->calendar->name; + $calendar_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/calendars/', $myItem->calendar->id); + } + + $mySlas[] = [ + 'name' => $name, + 'url' => $url, + 'type' => $type, + 'max_duration' => $max_duration, + 'calendar_name' => $calendar_name, + 'calendar_url' => $calendar_url, + ]; + } + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('slaola', $mySlas); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('type', $translator->translatePlural('Type', 'Types', 1)); + $viewData->addTranslation('max_duration', $translator->translate('Maximum time')); + $viewData->addTranslation('calendar', $translator->translatePlural('Calendar', 'Calendars', 1)); + + return $view->render($response, 'subitem/slaola.html.twig', (array)$viewData); + } + + public function showSubOlas(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/olas'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myOlas = []; + foreach ($myItem->olas as $current_ola) + { + $name = $current_ola->name; + + $url = ''; + // $url = $this->genereRootUrl2Link($rootUrl2, '/olas/', $current_ola->id); // TODO + + $type = $this->getTtrTto()[$current_ola->type]; + + $max_duration = $this->getValueWithUnit($current_ola->number_time, $current_ola->definition_time, 0); + + $calendar_name = ''; + $calendar_url = ''; + if ($myItem->calendar !== null) + { + $calendar_name = $myItem->calendar->name; + $calendar_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/calendars/', $myItem->calendar->id); + } + + $myOlas[] = [ + 'name' => $name, + 'url' => $url, + 'type' => $type, + 'max_duration' => $max_duration, + 'calendar_name' => $calendar_name, + 'calendar_url' => $calendar_url, + ]; + } + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('slaola', $myOlas); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('type', $translator->translatePlural('Type', 'Types', 1)); + $viewData->addTranslation('max_duration', $translator->translate('Maximum time')); + $viewData->addTranslation('calendar', $translator->translatePlural('Calendar', 'Calendars', 1)); + + return $view->render($response, 'subitem/slaola.html.twig', (array)$viewData); + } + + public function getTtrTto() + { + global $translator; + + return [ + $this->TTR => [ + 'title' => $translator->translate('Time to resolve'), + ], + $this->TTO => [ + 'title' => $translator->translate('Time to own'), + ], + ]; + } } diff --git a/src/v1/Controllers/Software.php b/src/v1/Controllers/Software.php index 4141421557..b4e74bdf06 100644 --- a/src/v1/Controllers/Software.php +++ b/src/v1/Controllers/Software.php @@ -10,6 +10,7 @@ final class Software extends Common { protected $model = '\App\Models\Software'; protected $rootUrl2 = '/softwares/'; + protected $choose = 'softwares'; public function getAll(Request $request, Response $response, $args): Response { @@ -39,30 +40,37 @@ public function showSubVersions(Request $request, Response $response, $args): Re $myItem = $item::with('versions')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/versions'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/versions'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myVersions = []; $total_install = 0; foreach ($myItem->versions as $version) { - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/softwareversion/" . $version->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/softwareversions/', $version->id); + $status = ''; - if ($version->state != null) { + $status_url = ''; + if ($version->state !== null) + { $status = $version->state->name; + $status_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $version->state->id); } + $os = ''; - if ($version->operatingsystem != null) { + $os_url = ''; + if ($version->operatingsystem !== null) + { $os = $version->operatingsystem->name; + $os_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/operatingsystems/', $version->operatingsystem->id); + } + + $nb_install = 0; + $nb_item_version = \App\Models\ItemSoftwareversion::where('softwareversion_id', $version->id)->count(); + if ($nb_item_version !== null) + { + $nb_install = $nb_item_version; } - $nb_install = 0; // TODO $total_install = $total_install + $nb_install; @@ -70,7 +78,9 @@ public function showSubVersions(Request $request, Response $response, $args): Re 'name' => $version->name, 'url' => $url, 'status' => $status, + 'status_url' => $status_url, 'os' => $os, + 'os_url' => $os_url, 'nb_install' => $nb_install, 'comment' => $version->comment, ]; @@ -93,4 +103,302 @@ public function showSubVersions(Request $request, Response $response, $args): Re return $view->render($response, 'subitem/versions.html.twig', (array)$viewData); } + + public function showSubLicenses(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $item2 = new \App\Models\Softwarelicense(); + $myItem2 = $item2::where('software_id', $args['id'])->get(); + + $rootUrl = $this->genereRootUrl($request, '/licenses'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myLicenses = []; + $total_number = 0; + $total_affected_items = 0; + foreach ($myItem2 as $license) + { + $name = $license->completename; + + $url = $this->genereRootUrl2Link($rootUrl2, '/softwarelicenses/', $license->id); + + $serial = $license->serial; + + $number = $license->number; + $total_number = $total_number + $number; + + $affected_items = 0; + $nb_item_affected = \App\Models\ItemSoftwarelicence::where('softwarelicense_id', $license->id)->count(); + if ($nb_item_affected !== null) + { + $affected_items = $nb_item_affected; + } + + $total_affected_items = $total_affected_items + $affected_items; + + $type = ''; + $type_url = ''; + if ($license->softwarelicensetype !== null) + { + $type = $license->softwarelicensetype->name; + $type_url = $this->genereRootUrl2Link( + $rootUrl2, + '/dropdowns/softwarelicensetypes/', + $license->softwarelicensetype->id + ); + } + + $version_buy = ''; + if ($license->softwareversionsBuy !== null) + { + $version_buy = $license->softwareversionsBuy->name; + } + + $version_use = ''; + if ($license->softwareversionsUse !== null) + { + $version_use = $license->softwareversionsUse->name; + } + + $exp_date = $license->expire; + + $alert_expiration = false; + $date_expiration = $license->expire; + if ($date_expiration == null) + { + $date_expiration = $translator->translate("N'expire pas"); + } + else + { + if ($date_expiration < date('Y-m-d H:i:s')) + { + $alert_expiration = true; + } + } + + $status = ''; + $status_url = ''; + if ($license->state !== null) + { + $status = $license->state->name; + $status_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $license->state->id); + } + + $myLicenses[] = [ + 'name' => $name, + 'url' => $url, + 'serial' => $serial, + 'number' => $number, + 'affected_items' => $affected_items, + 'type' => $type, + 'type_url' => $type_url, + 'version_buy' => $version_buy, + 'version_use' => $version_use, + 'date_expiration' => $date_expiration, + 'alert_expiration' => $alert_expiration, + 'status' => $status, + 'status_url' => $status_url, + ]; + } + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('licenses', $myLicenses); + $viewData->addData('total_number', $total_number); + $viewData->addData('total_affected_items', $total_affected_items); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('serial', $translator->translate('Serial number')); + $viewData->addTranslation('number', $translator->translate('Number')); + $viewData->addTranslation('affected_items', $translator->translate('Affected items')); + $viewData->addTranslation('type', $translator->translatePlural('Type', 'Types', 1)); + $viewData->addTranslation('version_buy', $translator->translate('Purchase version')); + $viewData->addTranslation('version_use', $translator->translate('Version in use')); + $viewData->addTranslation('expiration', $translator->translate('Expiration')); + $viewData->addTranslation('status', $translator->translate('Status')); + $viewData->addTranslation('total', $translator->translate('Total')); + + return $view->render($response, 'subitem/licenses.html.twig', (array)$viewData); + } + + public function showSubSoftwareInstall(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item::with('versions')->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/softwareinstall'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $mySoftwareInstall = []; + foreach ($myItem->versions as $current_version) + { + $software_licences = \App\Models\Softwarelicense::where('softwareversion_id_buy', $current_version->id) + ->orWhere('softwareversion_id_use', $current_version->id)->get(); + + $mySoftwareLicense = []; + foreach ($software_licences as $current_software_licence) + { + $type = ''; + if ($current_software_licence->softwarelicensetype !== null) + { + $type = $current_software_licence->softwarelicensetype->name; + } + + $mySoftwareLicense[$current_software_licence->id] = [ + 'id' => $current_software_licence->id, + 'name' => $current_software_licence->name, + 'serial' => $current_software_licence->serial, + 'type' => $type, + ]; + } + + $items_version = \App\Models\ItemSoftwareversion::where('softwareversion_id', $current_version->id)->get(); + if ($items_version !== null) + { + foreach ($items_version as $current_item) + { + $item3 = new $current_item->item_type(); + $myItem3 = $item3->find($current_item->item_id); + if ($myItem3 !== null) + { + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); + + $version = $current_version->name; + + $version_url = $this->genereRootUrl2Link($rootUrl2, '/softwareversion/', $current_version->id); + + $nom = $myItem3->name; + + $nom_url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem3->id); + + $serial = $myItem3->serial; + + $otherserial = $myItem3->otherserial; + + $location = ''; + $location_url = ''; + if ($myItem3->location !== null) + { + $location = $myItem3->location->name; + $location_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/locations/', $myItem3->location->id); + } + + $status = ''; + $status_url = ''; + if ($myItem3->state !== null) + { + $status = $myItem3->state->name; + $status_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/states/', $myItem3->state->id); + } + + $group = ''; + $group_url = ''; + if ($myItem3->group !== null) + { + $group = $myItem3->group->completename; + $group_url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $myItem3->group->id); + } + + $user = ''; + $user_url = ''; + if ($myItem3->user !== null) + { + $user = $myItem3->user->completename; + $user_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $myItem3->user->id); + } + + $licences = ''; + $licences_url = ''; + $licences_serial_type = ''; + foreach (array_keys($mySoftwareLicense) as $softwarelicenseid) + { + $items_licences = \App\Models\ItemSoftwarelicence::where([ + 'item_id' => $current_item->item_id, + 'item_type' => $current_item->item_type, + 'softwarelicense_id' => $softwarelicenseid + ])->get(); + if (count($items_licences) == 1) + { + $licences = $mySoftwareLicense[$softwarelicenseid]['name']; + $licences_url = $this->genereRootUrl2Link($rootUrl2, '/softwarelicenses/', $softwarelicenseid); + + if ($mySoftwareLicense[$softwarelicenseid]['serial'] != '') + { + $licences_serial_type = $licences_serial_type . $mySoftwareLicense[$softwarelicenseid]['serial']; + } + if ($mySoftwareLicense[$softwarelicenseid]['type'] != '') + { + $toadd = ' (' . $mySoftwareLicense[$softwarelicenseid]['type'] . ')'; + $licences_serial_type = $licences_serial_type . $toadd; + } + if ($licences_serial_type != '') + { + $licences_serial_type = ' - ' . $licences_serial_type; + } + } + } + + $date_install = $current_item->date_install; + + $mySoftwareInstall[] = [ + 'version' => $version, + 'version_url' => $version_url, + 'type' => $type_fr, + 'nom' => $nom, + 'nom_url' => $nom_url, + 'serial' => $serial, + 'otherserial' => $otherserial, + 'location' => $location, + 'location_url' => $location_url, + 'status' => $status, + 'status_url' => $status_url, + 'group' => $group, + 'group_url' => $group_url, + 'user' => $user, + 'user_url' => $user_url, + 'licences' => $licences, + 'licences_url' => $licences_url, + 'licences_serial_type' => $licences_serial_type, + 'date_install' => $date_install, + ]; + } + } + } + } + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('softwareinstall', $mySoftwareInstall); + + $viewData->addTranslation('version', $translator->translatePlural('Version', 'Versions', 1)); + $viewData->addTranslation('type', $translator->translate('Item type')); + $viewData->addTranslation('nom', $translator->translate('Name')); + $viewData->addTranslation('serial', $translator->translate('Serial number')); + $viewData->addTranslation('otherserial', $translator->translate('Inventory number')); + $viewData->addTranslation('location', $translator->translatePlural('Location', 'Locations', 1)); + $viewData->addTranslation('status', $translator->translate('Status')); + $viewData->addTranslation('group', $translator->translatePlural('Group', 'Groups', 1)); + $viewData->addTranslation('user', $translator->translatePlural('User', 'Users', 1)); + $viewData->addTranslation('licences', $translator->translatePlural('License', 'Licenses', 1)); + $viewData->addTranslation('date_install', $translator->translate('Installation date')); + + return $view->render($response, 'subitem/softwareinstall.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Softwarecategory.php b/src/v1/Controllers/Softwarecategory.php index 51076ee532..a0a22c40b9 100644 --- a/src/v1/Controllers/Softwarecategory.php +++ b/src/v1/Controllers/Softwarecategory.php @@ -6,10 +6,12 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Softwarecategory extends Common { protected $model = '\App\Models\Softwarecategory'; + protected $rootUrl2 = '/dropdowns/softwarecategories/'; public function getAll(Request $request, Response $response, $args): Response { @@ -28,4 +30,58 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Softwarecategory(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubSoftwarecategories(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $item2 = new $this->model(); + $myItem2 = $item2::where('softwarecategory_id', $args['id'])->get(); + + $rootUrl = $this->genereRootUrl($request, '/softwarecategories'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $mySoftwarecategories = []; + foreach ($myItem2 as $softwarecategory) + { + $name = $softwarecategory->name; + if ($name == '') + { + $name = '(' . $softwarecategory->id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/softwarecategories/', $softwarecategory->id); + + $comment = $softwarecategory->comment; + + $mySoftwarecategories[] = [ + 'name' => $name, + 'url' => $url, + 'comment' => $comment, + ]; + } + + // tri ordre alpha + uasort($mySoftwarecategories, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('softwarecategories', $mySoftwarecategories); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('comment', $translator->translatePlural('Comment', 'Comments', 2)); + + return $view->render($response, 'subitem/softwarecategories.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Softwarelicense.php b/src/v1/Controllers/Softwarelicense.php index c27caad1b6..ea24f55e62 100644 --- a/src/v1/Controllers/Softwarelicense.php +++ b/src/v1/Controllers/Softwarelicense.php @@ -39,38 +39,37 @@ public function showSubSoftwarelicenses(Request $request, Response $response, $a $myItem = $item::with('childs')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/licenses'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/licenses'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $mySoftwarelicenses = []; foreach ($myItem->childs as $child) { $name = $child->name; - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/softwarelicenses/" . $child->id; - } + + $url = $this->genereRootUrl2Link($rootUrl2, '/softwarelicenses/', $child->id); + $entity = ''; - if ($child->entity != null) { - $entity = $child->entity->name; + $entity_url = ''; + if ($child->entity !== null) + { + $entity = $child->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $child->entity->id); } - $comment = $child->comment; + $comment = $child->comment; $mySoftwarelicenses[] = [ 'name' => $name, 'url' => $url, 'entity' => $entity, + 'entity_url' => $entity_url, 'comment' => $comment, ]; } // tri ordre alpha - usort($mySoftwarelicenses, function ($a, $b) + uasort($mySoftwarelicenses, function ($a, $b) { return strtolower($a['name']) > strtolower($b['name']); }); @@ -85,7 +84,6 @@ public function showSubSoftwarelicenses(Request $request, Response $response, $a $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); $viewData->addTranslation('comment', $translator->translatePlural('Comment', 'Comments', 2)); - return $view->render($response, 'subitem/softwarelicenses.html.twig', (array)$viewData); } } diff --git a/src/v1/Controllers/Softwarelicensetype.php b/src/v1/Controllers/Softwarelicensetype.php index 935121bf26..3b290ac8e1 100644 --- a/src/v1/Controllers/Softwarelicensetype.php +++ b/src/v1/Controllers/Softwarelicensetype.php @@ -6,10 +6,12 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Views\PhpRenderer; use Slim\Routing\RouteContext; +use Slim\Views\Twig; final class Softwarelicensetype extends Common { protected $model = '\App\Models\Softwarelicensetype'; + protected $rootUrl2 = '/dropdowns/softwarelicensetypes/'; public function getAll(Request $request, Response $response, $args): Response { @@ -28,4 +30,69 @@ public function updateItem(Request $request, Response $response, $args): Respons $item = new \App\Models\Softwarelicensetype(); return $this->commonUpdateItem($request, $response, $args, $item); } + + public function showSubLicencetypes(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $item2 = new $this->model(); + $myItem2 = $item2::where('softwarelicensetype_id', $args['id'])->get(); + + $rootUrl = $this->genereRootUrl($request, '/licencetypes'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myLicencetypes = []; + foreach ($myItem2 as $softwarelicensetype) + { + $name = $softwarelicensetype->name; + if ($name == '') + { + $name = '(' . $softwarelicensetype->id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/softwarelicensetypes/', $softwarelicensetype->id); + + $entity = ''; + $entity_url = ''; + if ($softwarelicensetype->entity !== null) + { + $entity = $softwarelicensetype->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $softwarelicensetype->entity->id); + } + + $comment = $softwarelicensetype->comment; + + $myLicencetypes[] = [ + 'name' => $name, + 'url' => $url, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'comment' => $comment, + ]; + } + + // tri ordre alpha + uasort($myLicencetypes, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('licensetypes', $myLicencetypes); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); + $viewData->addTranslation('comment', $translator->translatePlural('Comment', 'Comments', 2)); + + return $view->render($response, 'subitem/softwarelicensetypes.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Softwareversion.php b/src/v1/Controllers/Softwareversion.php new file mode 100644 index 0000000000..eb516aaed0 --- /dev/null +++ b/src/v1/Controllers/Softwareversion.php @@ -0,0 +1,31 @@ +commonGetAll($request, $response, $args, $item); + } + + public function showItem(Request $request, Response $response, $args): Response + { + $item = new \App\Models\Softwareversion(); + return $this->commonShowItem($request, $response, $args, $item); + } + + public function updateItem(Request $request, Response $response, $args): Response + { + $item = new \App\Models\Softwareversion(); + return $this->commonUpdateItem($request, $response, $args, $item); + } +} diff --git a/src/v1/Controllers/State.php b/src/v1/Controllers/State.php index 29c0881a0c..ff71ad6aa2 100644 --- a/src/v1/Controllers/State.php +++ b/src/v1/Controllers/State.php @@ -44,26 +44,22 @@ public function showSubStates(Request $request, Response $response, $args): Resp $item2 = new $this->model(); $myItem2 = $item2->where('state_id', $args['id'])->get(); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/categories'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/categories'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myStates = []; foreach ($myItem2 as $current_category) { $name = $current_category->name; - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/dropdown/categories/" . $current_category->id; - } + $url = $this->genereRootUrl2Link($rootUrl2, '/dropdown/categories/', $current_category->id); $entity = ''; - if ($current_category->entity != null) { - $entity = $current_category->entity->name; + $entity_url = ''; + if ($current_category->entity !== null) + { + $entity = $current_category->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $current_category->entity->id); } $is_visible_computer = $current_category->is_visible_computer; @@ -232,38 +228,39 @@ public function showSubStates(Request $request, Response $response, $args): Resp 'name' => $name, 'url' => $url, 'entity' => $entity, - 'is_visible_computer' => $is_visible_computer, - 'is_visible_computer_val' => $is_visible_computer_val, - 'is_visible_monitor' => $is_visible_monitor, - 'is_visible_monitor_val' => $is_visible_monitor_val, - 'is_visible_networkequipment' => $is_visible_networkequipment, - 'is_visible_networkequipment_val' => $is_visible_networkequipment_val, - 'is_visible_peripheral' => $is_visible_peripheral, - 'is_visible_peripheral_val' => $is_visible_peripheral_val, - 'is_visible_phone' => $is_visible_phone, - 'is_visible_phone_val' => $is_visible_phone_val, - 'is_visible_printer' => $is_visible_printer, - 'is_visible_printer_val' => $is_visible_printer_val, - 'is_visible_certificate' => $is_visible_certificate, - 'is_visible_certificate_val' => $is_visible_certificate_val, - 'is_visible_cluster' => $is_visible_cluster, - 'is_visible_cluster_val' => $is_visible_cluster_val, - 'is_visible_contract' => $is_visible_contract, - 'is_visible_contract_val' => $is_visible_contract_val, - 'is_visible_appliance' => $is_visible_appliance, - 'is_visible_appliance_val' => $is_visible_appliance_val, - 'is_visible_pdu' => $is_visible_pdu, - 'is_visible_pdu_val' => $is_visible_pdu_val, - 'is_visible_softwarelicense' => $is_visible_softwarelicense, - 'is_visible_softwarelicense_val' => $is_visible_softwarelicense_val, - 'is_visible_softwareversion' => $is_visible_softwareversion, - 'is_visible_softwareversion_val' => $is_visible_softwareversion_val, - 'is_visible_line' => $is_visible_line, - 'is_visible_line_val' => $is_visible_line_val, - 'is_visible_enclosure' => $is_visible_enclosure, - 'is_visible_enclosure_val' => $is_visible_enclosure_val, - 'is_visible_rack' => $is_visible_rack, - 'is_visible_rack_val' => $is_visible_rack_val, + 'entity_url' => $entity_url, + 'is_visible_computer' => $is_visible_computer, + 'is_visible_computer_val' => $is_visible_computer_val, + 'is_visible_monitor' => $is_visible_monitor, + 'is_visible_monitor_val' => $is_visible_monitor_val, + 'is_visible_networkequipment' => $is_visible_networkequipment, + 'is_visible_networkequipment_val' => $is_visible_networkequipment_val, + 'is_visible_peripheral' => $is_visible_peripheral, + 'is_visible_peripheral_val' => $is_visible_peripheral_val, + 'is_visible_phone' => $is_visible_phone, + 'is_visible_phone_val' => $is_visible_phone_val, + 'is_visible_printer' => $is_visible_printer, + 'is_visible_printer_val' => $is_visible_printer_val, + 'is_visible_certificate' => $is_visible_certificate, + 'is_visible_certificate_val' => $is_visible_certificate_val, + 'is_visible_cluster' => $is_visible_cluster, + 'is_visible_cluster_val' => $is_visible_cluster_val, + 'is_visible_contract' => $is_visible_contract, + 'is_visible_contract_val' => $is_visible_contract_val, + 'is_visible_appliance' => $is_visible_appliance, + 'is_visible_appliance_val' => $is_visible_appliance_val, + 'is_visible_pdu' => $is_visible_pdu, + 'is_visible_pdu_val' => $is_visible_pdu_val, + 'is_visible_softwarelicense' => $is_visible_softwarelicense, + 'is_visible_softwarelicense_val' => $is_visible_softwarelicense_val, + 'is_visible_softwareversion' => $is_visible_softwareversion, + 'is_visible_softwareversion_val' => $is_visible_softwareversion_val, + 'is_visible_line' => $is_visible_line, + 'is_visible_line_val' => $is_visible_line_val, + 'is_visible_enclosure' => $is_visible_enclosure, + 'is_visible_enclosure_val' => $is_visible_enclosure_val, + 'is_visible_rack' => $is_visible_rack, + 'is_visible_rack_val' => $is_visible_rack_val, 'comment' => $comment, ]; } diff --git a/src/v1/Controllers/Supplier.php b/src/v1/Controllers/Supplier.php index a5685e51d4..d211772c5a 100644 --- a/src/v1/Controllers/Supplier.php +++ b/src/v1/Controllers/Supplier.php @@ -10,6 +10,9 @@ final class Supplier extends Common { protected $model = '\App\Models\Supplier'; protected $rootUrl2 = '/suppliers/'; + protected $choose = 'suppliers'; + protected $associateditems_model = '\App\Models\Infocom'; + protected $associateditems_model_id = 'supplier_id'; public function getAll(Request $request, Response $response, $args): Response { @@ -39,49 +42,48 @@ public function showSubContracts(Request $request, Response $response, $args): R $myItem = $item->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/contracts'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } - $item2 = new \App\Models\Contract(); $myItem2 = $item2::with('suppliers')->orderBy('name', 'asc')->get(); + $rootUrl = $this->genereRootUrl($request, '/contracts'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $myContracts = []; foreach ($myItem2 as $contract) { $is_supplier_contract = false; - if ($contract->suppliers != null) + if ($contract->suppliers !== null) { - foreach ($contract->suppliers as $supplier) { - if ($supplier->id == $args['id']) { + foreach ($contract->suppliers as $supplier) + { + if ($supplier->id == $args['id']) + { $is_supplier_contract = true; break; } } } - if ($is_supplier_contract == true) { - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/contracts/" . $contract->id; - } + if ($is_supplier_contract == true) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/contracts/', $contract->id); $entity = ''; - if ($contract->entity != null) + $entity_url = ''; + if ($contract->entity !== null) { - $entity = $contract->entity->name; + $entity = $contract->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $contract->entity->id); } $type = ''; - if ($contract->type != null) + $contracttype_url = ''; + if ($contract->type !== null) { $type = $contract->type->name; + $contracttype_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/contracttypes/', $contract->type->id); } - $duration = $contract->duration; if ($duration == 0) { @@ -99,12 +101,14 @@ public function showSubContracts(Request $request, Response $response, $args): R ); } - if ($contract->begin_date != null) { + if ($contract->begin_date !== null) + { $ladate = $contract->begin_date; if ($duration != 0) { $end_date = date('Y-m-d', strtotime('+' . $duration . ' month', strtotime($ladate))); - if ($end_date < date('Y-m-d')) { + if ($end_date < date('Y-m-d')) + { $end_date = "" . $end_date . ""; } $initial_contract_period = $initial_contract_period . ' => ' . $end_date; @@ -115,15 +119,16 @@ public function showSubContracts(Request $request, Response $response, $args): R 'name' => $contract->name, 'url' => $url, 'entity' => $entity, + 'entity_url' => $entity_url, 'number' => $contract->num, 'type' => $type, + 'contracttype_url' => $contracttype_url, 'start_date' => $contract->begin_date, 'initial_contract_period' => $initial_contract_period, ]; } } - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -152,63 +157,69 @@ public function showSubContacts(Request $request, Response $response, $args): Re $myItem = $item->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/contacts'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } - $item2 = new \App\Models\Contact(); $myItem2 = $item2::with('suppliers')->orderBy('name', 'asc')->get(); + $rootUrl = $this->genereRootUrl($request, '/contacts'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + $myContacts = []; foreach ($myItem2 as $contact) { $is_supplier_contact = false; - if ($contact->suppliers != null) + if ($contact->suppliers !== null) { - foreach ($contact->suppliers as $supplier) { - if ($supplier->id == $args['id']) { + foreach ($contact->suppliers as $supplier) + { + if ($supplier->id == $args['id']) + { $is_supplier_contact = true; break; } } } - if ($is_supplier_contact == true) { + if ($is_supplier_contact == true) + { + $url = $this->genereRootUrl2Link($rootUrl2, '/contacts/', $contact->id); $url = ''; - if ($rootUrl2 != '') { + if ($rootUrl2 != '') + { $url = $rootUrl2 . "/contacts/" . $contact->id; } $entity = ''; - if ($contact->entity != null) + $entity_url = ''; + if ($contact->entity !== null) { - $entity = $contact->entity->name; + $entity = $contact->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $contact->entity->id); } $type = ''; - if ($contact->type != null) + $type_url = ''; + if ($contact->type !== null) { $type = $contact->type->name; + $type_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/contacttypes/', $contact->type->id); } $myContacts[$contact->id] = [ - 'name' => $contact->name . ' ' . $contact->firstname, + 'name' => $this->genereUserName($contact->name, $contact->name, $contact->firstname), 'url' => $url, 'entity' => $entity, + 'entity_url' => $entity_url, 'phone' => $contact->phone, 'phone2' => $contact->phone2, 'mobile' => $contact->mobile, 'fax' => $contact->fax, 'email' => $contact->email, 'type' => $type, + 'type_url' => $type_url, ]; } } - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); diff --git a/src/v1/Controllers/Ticket.php b/src/v1/Controllers/Ticket.php index 5b471d277b..a373011e84 100644 --- a/src/v1/Controllers/Ticket.php +++ b/src/v1/Controllers/Ticket.php @@ -11,7 +11,7 @@ final class Ticket extends Common { protected $model = '\App\Models\Ticket'; protected $rootUrl2 = '/tickets/'; - protected $costchoose = 'ticket'; + protected $choose = 'tickets'; public function getAll(Request $request, Response $response, $args): Response { @@ -78,7 +78,9 @@ public function updateItem(Request $request, Response $response, $args): Respons // if (empty($values)) // { // $values = []; - // } else { + // } + // else + // { // $values = explode(',', $values); // } // } @@ -112,12 +114,12 @@ public function updateItem(Request $request, Response $response, $args): Respons // test rules, need write with old prepareInputtoupdate $input = [ - 'name' => $myItem->name, - 'urgency' => $myItem->urgency, - 'priority' => $myItem->priority, - '_users_id_requester' => [], - '_users_id_assign' => [], - '_groups_id_assign' => [], + 'name' => $myItem->name, + 'urgency' => $myItem->urgency, + 'priority' => $myItem->priority, + '_users_id_requester' => [], + '_users_id_assign' => [], + '_groups_id_assign' => [], ]; // manage requesters @@ -211,61 +213,6 @@ public function updateItem(Request $request, Response $response, $args): Respons // return $this->commonUpdateItem($request, $response, $args, $item); } - public function showStats(Request $request, Response $response, $args) - { - global $translator; - $item = new \App\Models\Ticket(); - $view = Twig::fromRequest($request); - - $myItem = $item::find($args['id']); - - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/stats'); - - $feeds = []; - - $feeds[] = [ - 'date' => $myItem->date, - 'text' => $translator->translate('Opening date'), - 'icon' => 'pencil alternate', - 'color' => 'blue' - ]; - - $feeds[] = [ - 'date' => $myItem->time_to_resolve, - 'text' => $translator->translate('Time to resolve'), - 'icon' => 'hourglass half', - 'color' => 'blue' - ]; - if ($myItem->status >= 5) - { - $feeds[] = [ - 'date' => $myItem->solvedate, - 'text' => $translator->translate('Resolution date'), - 'icon' => 'check circle', - 'color' => 'blue' - ]; - } - if ($myItem->status == 6) - { - $feeds[] = [ - 'date' => $myItem->closedate, - 'text' => $translator->translate('Closing date'), - 'icon' => 'flag checkered', - 'color' => 'blue' - ]; - } - - - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); - $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); - - $viewData->addData('feeds', $feeds); - - - return $view->render($response, 'subitem/stats.html.twig', (array) $viewData); - } - public function showProblem(Request $request, Response $response, $args) { global $translator; @@ -274,14 +221,19 @@ public function showProblem(Request $request, Response $response, $args) $myItem = $item::with(['problems'])->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/problem'); + $rootUrl = $this->genereRootUrl($request, '/problem'); // $problems = $myItem->problem()->get()->toArray(); $problems = []; + foreach ($myItem->problems as $problem) + { + // $problems[] = $problem->toArray(); - foreach ($myItem->problems as $problem) { - $problems[] = $problem->toArray(); + $problems[] = [ + 'id' => $problem->id, + 'name' => $problem->name, + 'updated_at' => $problem->updated_at, + ]; } $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); @@ -315,7 +267,9 @@ public function postProblem(Request $request, Response $response, $args) // add message to session \App\v1\Controllers\Toolbox::addSessionMessage("The ticket has been attached to problem successfully"); - } else { + } + else + { // add message to session \App\v1\Controllers\Toolbox::addSessionMessage('Error to attache ticket to problem', 'error'); } @@ -356,11 +310,12 @@ public static function computePriority($urgency, $impact) */ public function prepareDataSave($data, $id = null) { - if (is_null($id)) { $myItem = new \App\Models\Ticket(); - } else { + } + else + { $myItem = \App\Models\Ticket::find($id); } $definitions = $myItem->getDefinitions(); @@ -372,6 +327,7 @@ public function prepareDataSave($data, $id = null) { $data->impact = 3; } + $data->priority = self::computePriority($data->urgency, $data->impact); } @@ -415,9 +371,12 @@ public function prepareDataSave($data, $id = null) { $input[$def['name']][] = $requester; } - } else { + } + else + { $input[$def['name']] = []; } + $input[$def['name']] = array_filter($input[$def['name']]); } } @@ -451,7 +410,9 @@ public function prepareDataSave($data, $id = null) if (isset($input['techniciangroup'])) { $input['_groups_id_assign'] = $input['techniciangroup']; - } else { + } + else + { $input['techniciangroup'] = []; } // _suppliers_id_assign @@ -597,10 +558,10 @@ public function prepareDataSave($data, $id = null) -// print_r($updateData); -// echo "
"; -// print_r($input); -// exit; + // print_r($updateData); + // echo "
"; + // print_r($input); + // exit; // update each models (ticket, users, groups...) @@ -609,4 +570,205 @@ public function prepareDataSave($data, $id = null) return $myItem->id; } + + public function showSubItems(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/items'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myItems = []; + foreach ($myItem->items as $current_item) + { + $item3 = new $current_item->item_type(); + $myItem3 = $item3->find($current_item->item_id); + if ($myItem3 !== null) + { + $type_fr = $item3->getTitle(); + $type = $item3->getTable(); + + $current_id = $myItem3->id; + + $name = $myItem3->name; + if ($name == '') + { + $name = '(' . $current_id . ')'; + } + + $url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $current_id); + + $entity = ''; + $entity_url = ''; + if ($myItem3->entity !== null) + { + $entity = $myItem3->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $myItem3->entity->id); + } + + $serial_number = $myItem3->serial; + + $inventaire_number = $myItem3->otherserial; + + $myItems[] = [ + 'type' => $type_fr, + 'name' => $name, + 'url' => $url, + 'entity' => $entity, + 'entity_url' => $entity_url, + 'serial_number' => $serial_number, + 'inventaire_number' => $inventaire_number, + ]; + } + } + + // tri ordre alpha + uasort($myItems, function ($a, $b) + { + return strtolower($a['name']) > strtolower($b['name']); + }); + uasort($myItems, function ($a, $b) + { + return strtolower($a['type']) > strtolower($b['type']); + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('items', $myItems); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('type', $translator->translatePlural('Type', 'Types', 1)); + $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('serial_number', $translator->translate('Serial number')); + $viewData->addTranslation('inventaire_number', $translator->translate('Inventory number')); + + return $view->render($response, 'subitem/items.html.twig', (array)$viewData); + } + + public function showSubProjecttasks(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $item2 = new \App\Models\Project(); + $myItem2 = $item2->get(); + + $rootUrl = $this->genereRootUrl($request, '/projecttasks'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myProjecttasks = []; + $tabProjecttasksId = []; + foreach ($myItem->projecttasks as $projecttask) + { + $projecttask_id = $projecttask->projecttask_id; + $tabProjecttasksId[] = $projecttask_id; + } + + foreach ($myItem2 as $current_item) + { + if ($current_item->tasks !== null) + { + foreach ($current_item->tasks as $task) + { + if (in_array($task->id, $tabProjecttasksId)) + { + $name = $task->name; + + $url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/projecttasks/', $task->id); + + $type = ''; + $type_url = ''; + if ($task->type !== null) + { + $type = $task->type->name; + $type_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/projecttasktypes/', $task->type->id); + } + + $status = ''; + $status_color = ''; + if ($task->state !== null) + { + $status = $task->state->name; + $status_color = $task->state->color; + } + + $percent_done = $task->percent_done; + $percent_done = $this->getValueWithUnit($percent_done, '%', 0); + + $planned_start_date = $task->plan_start_date; + + $planned_end_date = $task->plan_end_date; + + $planned_duration = $this->timestampToString($task->planned_duration, false); + + $effective_duration = $this->timestampToString($task->effective_duration, false); + + $father = ''; + $father_url = ''; + if ($task->parent !== null) + { + $father = $task->parent->name; + $father_url = $this->genereRootUrl2Link($rootUrl2, '/dropdowns/projecttasks/', $task->parent->id); + } + + $project = $current_item->name; + $project_url = $this->genereRootUrl2Link($rootUrl2, '/projects/', $current_item->id); + + $myProjecttasks[] = [ + 'name' => $name, + 'url' => $url, + 'type' => $type, + 'type_url' => $type_url, + 'status' => $status, + 'status_color' => $status_color, + 'percent_done' => $percent_done, + 'planned_start_date' => $planned_start_date, + 'planned_end_date' => $planned_end_date, + 'planned_duration' => $planned_duration, + 'effective_duration' => $effective_duration, + 'father' => $father, + 'father_url' => $father_url, + 'project' => $project, + 'project_url' => $project_url, + ]; + } + } + } + } + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('projecttasks', $myProjecttasks); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('name', $translator->translate('Name')); + $viewData->addTranslation('type', $translator->translatePlural('Type', 'Types', 1)); + $viewData->addTranslation('status', $translator->translate('Status')); + $viewData->addTranslation('percent_done', $translator->translate('Percent done')); + $viewData->addTranslation('planned_start_date', $translator->translate('Planned start date')); + $viewData->addTranslation('planned_end_date', $translator->translate('Planned end date')); + $viewData->addTranslation('planned_duration', $translator->translate('Planned duration')); + $viewData->addTranslation('effective_duration', $translator->translate('Effective duration')); + $viewData->addTranslation('father', $translator->translate('Father')); + $viewData->addTranslation('projects', $translator->translatePlural('Type', 'Types', 2)); + $viewData->addTranslation('projecttasks', $translator->translatePlural('Project task', 'Project tasks', 2)); + + return $view->render($response, 'subitem/projecttasks.html.twig', (array)$viewData); + } } diff --git a/src/v1/Controllers/Tickettemplate.php b/src/v1/Controllers/Tickettemplate.php index 5d81aa4477..54347e0ce1 100644 --- a/src/v1/Controllers/Tickettemplate.php +++ b/src/v1/Controllers/Tickettemplate.php @@ -39,6 +39,8 @@ public function showSubMandatoryFields(Request $request, Response $response, $ar $myItem = $item::with('mandatoryfields')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/mandatoryfields'); + $myMandatoryFields = []; foreach ($myItem->mandatoryfields as $mandatoryfield) { @@ -54,9 +56,6 @@ public function showSubMandatoryFields(Request $request, Response $response, $ar ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/mandatoryfields'); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -79,6 +78,8 @@ public function showSubPredefinedFields(Request $request, Response $response, $a $myItem = $item::with('predefinedfields')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/predefinedfields'); + $myPredefinedFields = []; foreach ($myItem->predefinedfields as $predefinedfield) { @@ -90,9 +91,6 @@ public function showSubPredefinedFields(Request $request, Response $response, $a ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/predefinedfields'); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -115,19 +113,18 @@ public function showSubHiddenFields(Request $request, Response $response, $args) $myItem = $item::with('hiddenfields')->find($args['id']); + $rootUrl = $this->genereRootUrl($request, '/hiddenfields'); + $myHiddenFields = []; foreach ($myItem->hiddenfields as $hiddenfield) { $name = $hiddenfield->num; $myHiddenFields[] = [ - 'name' => $name, + 'name' => $name, ]; } - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/hiddenfields'); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); diff --git a/src/v1/Controllers/Token.php b/src/v1/Controllers/Token.php index 12fcaf48fc..6a71cfcae0 100644 --- a/src/v1/Controllers/Token.php +++ b/src/v1/Controllers/Token.php @@ -28,13 +28,17 @@ public static function checkPassword($pass, $hash) if (isset($tmp['algo']) && $tmp['algo']) { $verify = password_verify($pass, $hash); - } elseif (strlen($hash) == 32) + } + elseif (strlen($hash) == 32) { $verify = md5($pass) === $hash; - } elseif (strlen($hash) == 40) + } + elseif (strlen($hash) == 40) { $verify = sha1($pass) === $hash; - } else { + } + else + { $salt = substr($hash, 0, 8); $verify = ($salt . sha1($salt . $pass) === $hash); } @@ -70,7 +74,9 @@ public function generateJWTToken( { $jti = $this->generateToken(); // $user->properties()->updateExistingPivot($jwtidId, ['value_string' => $jti]); - } else { + } + else + { $jti = $jwtid; } diff --git a/src/v1/Controllers/User.php b/src/v1/Controllers/User.php index d986ee55ef..08354b7540 100644 --- a/src/v1/Controllers/User.php +++ b/src/v1/Controllers/User.php @@ -10,7 +10,7 @@ final class User extends Common { protected $model = '\App\Models\User'; protected $rootUrl2 = '/users/'; - protected $itilchoose = 'users'; + protected $choose = 'users'; public function getAll(Request $request, Response $response, $args): Response { @@ -37,8 +37,11 @@ public function showSubAuthorization(Request $request, Response $response, $args $item = new \App\Models\User(); $view = Twig::fromRequest($request); - $profiles = []; $myItem = $item::with('profiles')->find($args['id']); + + $rootUrl = $this->genereRootUrl($request, '/authorization'); + + $profiles = []; foreach ($myItem->profiles as $profile) { $entity = \App\Models\Entity::find($profile->pivot->entity_id); @@ -55,38 +58,35 @@ public function showSubAuthorization(Request $request, Response $response, $args $form = [ [ - 'id' => 1, - 'title' => $translator->translatePlural('Entity', 'Entities', 1), - 'type' => 'dropdown_remote', - 'name' => 'entity', - 'dbname' => 'entity_id', - 'itemtype' => '\App\Models\Entity', - 'fillable' => true, - 'display' => true, + 'id' => 1, + 'title' => $translator->translatePlural('Entity', 'Entities', 1), + 'type' => 'dropdown_remote', + 'name' => 'entity', + 'dbname' => 'entity_id', + 'itemtype' => '\App\Models\Entity', + 'fillable' => true, + 'display' => true, ], [ - 'id' => 3, - 'title' => $translator->translate('Child entities'), - 'type' => 'boolean', - 'name' => 'is_recursive', - 'fillable' => true, - 'display' => true, + 'id' => 3, + 'title' => $translator->translate('Child entities'), + 'type' => 'boolean', + 'name' => 'is_recursive', + 'fillable' => true, + 'display' => true, ], [ - 'id' => 2, - 'title' => $translator->translatePlural('Profile', 'Profiles', 1), - 'type' => 'dropdown_remote', - 'name' => 'profile', - 'dbname' => 'profile_id', - 'itemtype' => '\App\Models\Profile', - 'fillable' => true, - 'display' => true, + 'id' => 2, + 'title' => $translator->translatePlural('Profile', 'Profiles', 1), + 'type' => 'dropdown_remote', + 'name' => 'profile', + 'dbname' => 'profile_id', + 'itemtype' => '\App\Models\Profile', + 'fillable' => true, + 'display' => true, ], ]; - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/users'); - $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); @@ -115,7 +115,9 @@ public function itemSubAuthorization(Request $request, Response $response, $args ->wherePivot('is_recursive', $data->is_recursive) ->detach($data->profile_id); } - } else { + } + else + { $user = \App\Models\User::find($args['id']); $profile = \App\Models\Profile::find($data->profile); $entity = \App\Models\Entity::find($data->entity); @@ -148,27 +150,50 @@ public function showSubGroups(Request $request, Response $response, $args): Resp $myItem = $item::with('group')->find($args['id']); - $rootUrl = $this->getUrlWithoutQuery($request); - $rootUrl = rtrim($rootUrl, '/groups'); - $rootUrl2 = ''; - if ($this->rootUrl2 != '') { - $rootUrl2 = rtrim($rootUrl, $this->rootUrl2 . $args['id']); - } + $rootUrl = $this->genereRootUrl($request, '/groups'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); $myGroups = []; foreach ($myItem->group as $group) { - $url = ''; - if ($rootUrl2 != '') { - $url = $rootUrl2 . "/groups/" . $group->pivot->group_id; + $url = $this->genereRootUrl2Link($rootUrl2, '/groups/', $group->pivot->group_id); + + if ($group->pivot->is_dynamic == 1) + { + $auto_val = $translator->translate('Yes'); + } + else + { + $auto_val = $translator->translate('No'); + } + + if ($group->pivot->is_manager == 1) + { + $is_manager_val = $translator->translate('Yes'); + } + else + { + $is_manager_val = $translator->translate('No'); + } + + if ($group->pivot->is_userdelegate == 1) + { + $is_userdelegate_val = $translator->translate('Yes'); + } + else + { + $is_userdelegate_val = $translator->translate('No'); } $myGroups[] = [ - 'name' => $group->name, - 'url' => $url, - 'auto' => $group->pivot->is_dynamic, - 'is_manager' => $group->pivot->is_manager, - 'is_userdelegate' => $group->pivot->is_userdelegate, + 'name' => $group->completename, + 'url' => $url, + 'auto' => $group->pivot->is_dynamic, + 'auto_val' => $auto_val, + 'is_manager' => $group->pivot->is_manager, + 'is_manager_val' => $is_manager_val, + 'is_userdelegate' => $group->pivot->is_userdelegate, + 'is_userdelegate_val' => $is_userdelegate_val, ]; } @@ -177,7 +202,7 @@ public function showSubGroups(Request $request, Response $response, $args): Resp $viewData->addData('fields', $item->getFormData($myItem)); $viewData->addData('groups', $myGroups); - $viewData->addData('show', $this->itilchoose); + $viewData->addData('show', $this->choose); $viewData->addTranslation('name', $translator->translate('Name')); $viewData->addTranslation('auto', $translator->translate('Automatic inventory')); @@ -186,4 +211,138 @@ public function showSubGroups(Request $request, Response $response, $args): Resp return $view->render($response, 'subitem/groups.html.twig', (array)$viewData); } + + public function showSubReservations(Request $request, Response $response, $args): Response + { + global $translator; + + $item = new $this->model(); + $definitions = $item->getDefinitions(); + $view = Twig::fromRequest($request); + + $myItem = $item->find($args['id']); + + $myItem2 = \App\Models\Reservation::where('user_id', $args['id'])->get(); + + $rootUrl = $this->genereRootUrl($request, '/reservations'); + $rootUrl2 = $this->genereRootUrl2($rootUrl, $this->rootUrl2 . $args['id']); + + $myReservations = []; + $myReservations_old = []; + foreach ($myItem2 as $current_reservation) + { + $myItem3 = \App\Models\Reservationitem::where('id', $current_reservation->reservationitem_id)->get(); + if ($myItem3 !== null) + { + foreach ($myItem3 as $current_reservationitem) + { + $item4 = new $current_reservationitem->item_type(); + $myItem4 = $item4->find($current_reservationitem->item_id); + if ($myItem4 !== null) + { + $type_fr = $item4->getTitle(); + $type = $item4->getTable(); + + $current_id = $myItem4->id; + + + $begin = $current_reservation->begin; + + $end = $current_reservation->end; + + $user = ''; + $user_url = ''; + if ($current_reservation->user !== null) + { + $user = $this->genereUserName( + $current_reservation->user->name, + $current_reservation->user->lastname, + $current_reservation->user->firstname + ); + $user_url = $this->genereRootUrl2Link($rootUrl2, '/users/', $current_reservation->user->id); + } + + $comment = $current_reservation->comment; + + + $item_name = $myItem4->name; + if ($item_name == '') + { + $item_name = '(' . $myItem4->id . ')'; + } + + $item_url = $this->genereRootUrl2Link($rootUrl2, '/' . $type . '/', $myItem4->id); + + $entity = ''; + $entity_url = ''; + if ($current_reservationitem->entity !== null) + { + $entity = $current_reservationitem->entity->completename; + $entity_url = $this->genereRootUrl2Link($rootUrl2, '/entities/', $current_reservationitem->entity->id); + } + + if ($end < date('Y-m-d H:i:s')) + { + $myReservations_old[] = [ + 'begin' => $begin, + 'end' => $end, + 'user' => $user, + 'user_url' => $user_url, + 'comment' => $comment, + 'item_name' => $item_name, + 'item_url' => $item_url, + 'entity' => $entity, + 'entity_url' => $entity_url, + ]; + } + else + { + $myReservations[] = [ + 'begin' => $begin, + 'end' => $end, + 'user' => $user, + 'user_url' => $user_url, + 'comment' => $comment, + 'item_name' => $item_name, + 'item_url' => $item_url, + 'entity' => $entity, + 'entity_url' => $entity_url, + ]; + } + } + } + } + } + + // tri par ordre + ancien + uasort($myReservations, function ($a, $b) + { + return $a['begin'] > $b['begin']; + }); + // tri par ordre + recent + uasort($myReservations_old, function ($a, $b) + { + return $a['begin'] < $b['begin']; + }); + + $viewData = new \App\v1\Controllers\Datastructures\Viewdata($myItem, $request); + $viewData->addRelatedPages($item->getRelatedPages($rootUrl)); + + $viewData->addData('fields', $item->getFormData($myItem)); + $viewData->addData('reservations', $myReservations); + $viewData->addData('reservations_old', $myReservations_old); + $viewData->addData('show', $this->choose); + + $viewData->addTranslation('start_date', $translator->translate('Start date')); + $viewData->addTranslation('end_date', $translator->translate('End date')); + $viewData->addTranslation('by', $translator->translate('By')); + $viewData->addTranslation('comment', $translator->translatePlural('Comment', 'Comments', 2)); + $viewData->addTranslation('current_reservations', $translator->translate('Current and future reservations')); + $viewData->addTranslation('past_reservations', $translator->translate('Past reservations')); + $viewData->addTranslation('no_reservations', $translator->translate('No reservation')); + $viewData->addTranslation('item', $translator->translatePlural('Item', 'Items', 1)); + $viewData->addTranslation('entity', $translator->translatePlural('Entity', 'Entities', 1)); + + return $view->render($response, 'subitem/reservations.html.twig', (array)$viewData); + } } diff --git a/src/v1/Views/subitem/analysis.html.twig b/src/v1/Views/subitem/analysis.html.twig new file mode 100644 index 0000000000..790c64794b --- /dev/null +++ b/src/v1/Views/subitem/analysis.html.twig @@ -0,0 +1,20 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + +
+ +
+
+
+ {% for item in data.fields %} + {% if item.name != 'comment' %} + {{ include('fields.html.twig') }} + {% endif %} + {% endfor %} +
+
+
+ +
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/appliances.html.twig b/src/v1/Views/subitem/appliances.html.twig index 0f0502b51e..9f39007839 100644 --- a/src/v1/Views/subitem/appliances.html.twig +++ b/src/v1/Views/subitem/appliances.html.twig @@ -10,7 +10,13 @@ {% for appliance in data.appliances|sort((a, b) => a.appliance.name|lower <=> b.appliance.name|lower) %} - {{ appliance.name }} + + {% if appliance.url != '' %} + {{ appliance.name }} + {% else %} + {{ appliance.name }} + {% endif %} + {% endfor %} diff --git a/src/v1/Views/subitem/approvals.html.twig b/src/v1/Views/subitem/approvals.html.twig new file mode 100644 index 0000000000..4d10cf0084 --- /dev/null +++ b/src/v1/Views/subitem/approvals.html.twig @@ -0,0 +1,43 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + + + + + + + + + + {% for approval in data.approvals %} + + + + + + + + + + {% endfor %} + +
{{ translation.status }}{{ translation.request_date }}{{ translation.request_user }}{{ translation.request_comment }}{{ translation.approval_date }}{{ translation.approval_user }}{{ translation.approval_comment }}
{{ approval.status.title }}{{ approval.request_date }} + {% if approval.request_user_url != '' %} + {{ approval.request_user }} + {% else %} + {{ approval.request_user }} + {% endif %} + {{ approval.request_comment }}{{ approval.approval_date }} + {% if approval.approval_user_url != '' %} + {{ approval.approval_user }} + {% else %} + {{ approval.approval_user }} + {% endif %} + {{ approval.approval_comment }}
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/associateditems.html.twig b/src/v1/Views/subitem/associateditems.html.twig index ea8ac22347..2f6bd39df6 100644 --- a/src/v1/Views/subitem/associateditems.html.twig +++ b/src/v1/Views/subitem/associateditems.html.twig @@ -22,7 +22,13 @@ {{ associateditem.name }} {% endif %} - {{ associateditem.entity }} + + {% if associateditem.entity_url != '' %} + {{ associateditem.entity }} + {% else %} + {{ associateditem.entity }} + {% endif %} + {{ associateditem.serial_number }} {{ associateditem.inventaire_number }} diff --git a/src/v1/Views/subitem/attacheditems.html.twig b/src/v1/Views/subitem/attacheditems.html.twig new file mode 100644 index 0000000000..ed7da76367 --- /dev/null +++ b/src/v1/Views/subitem/attacheditems.html.twig @@ -0,0 +1,92 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + + + {% if data.show == 'domains' %} + + {% endif %} + + + {% if data.show == 'contracts' %} + + {% endif %} + {% if data.show == 'budgets' %} + + {% endif %} + + + + {% for key,attacheditem in data.attacheditems %} + {% for key2,attacheditem2 in attacheditem.items %} + + {% if data.show == 'suppliers' or data.show == 'budgets' %} + {% if attacheditem2.first %} + {% if data.show == 'suppliers' %} + + {% endif %} + {% if data.show == 'budgets' %} + {% if attacheditem.nb > 1 %} + + {% else %} + + {% endif %} + {% endif %} + {% endif %} + {% else %} + + {% endif %} + + + {% if data.show == 'domains' %} + + {% endif %} + + + {% if data.show == 'contracts' %} + + {% endif %} + {% if data.show == 'budgets' %} + + {% endif %} + + {% endfor %} + {% endfor %} + {% if data.show == 'suppliers' %} + + + + + {% endif %} + {% if data.show == 'budgets' %} + + + + + {% endif %} + +
{{ translation.type }}{{ translation.name }}{{ translation.entity }}{{ translation.domain_relation }}{{ translation.serial }}{{ translation.otherserial }}{{ translation.status }}{{ translation.value }}
{{ attacheditem.name }} : {{ attacheditem.nb }}{{ attacheditem.name }} : {{ attacheditem.nb }}{{ attacheditem.name }}{{ attacheditem.name }} + {% if attacheditem2.nom_url != '' %} + {{ attacheditem2.nom }} + {% else %} + {{ attacheditem2.nom }} + {% endif %} + + {% if attacheditem2.entity_url != '' %} + {{ attacheditem2.entity }} + {% else %} + {{ attacheditem2.entity }} + {% endif %} + + {% if attacheditem2.domain_relation_url != '' %} + {{ attacheditem2.domain_relation }} + {% else %} + {{ attacheditem2.domain_relation }} + {% endif %} + {{ attacheditem2.serial }}{{ attacheditem2.otherserial }}{{ attacheditem2.status }}{{ attacheditem2.value }}
{{ translation.total }} = {{ data.nb_total }}
{{ translation.total }} = {{ data.nb_total }}
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/budgetmain.html.twig b/src/v1/Views/subitem/budgetmain.html.twig new file mode 100644 index 0000000000..b1bb540438 --- /dev/null +++ b/src/v1/Views/subitem/budgetmain.html.twig @@ -0,0 +1,52 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + {% for key,budgetmaintype in data.budgetmaintype %} + + {% endfor %} + + + + + {% for key,budgetmain in data.budgetmain %} + + + {% for key,budgetmaintype in data.budgetmaintype %} + {% for key2,budgetmain2 in budgetmain.items %} + {% if key == key2 %} + + {% endif %} + {% endfor %} + {% endfor %} + + + {% endfor %} + + + {% for key,budgetmaintype in data.budgetmaintype %} + + {% endfor %} + + + + + + + + + + + +
{{ translation.entity }}{{ budgetmaintype.name }}{{ translation.total }}
+ {% if budgetmain.entity_url != '' %} + {{ budgetmain.name }} + {% else %} + {{ budgetmain.name }} + {% endif %} + {{ budgetmain2.total }}{{ budgetmain.total }}
{{ translation.total }}{{ budgetmaintype.total }}{{ data.total_spent }}
{{ translation.total_spent }}{{ data.total_spent }}
{{ translation.total_remaining }}{{ data.total_remaining }}
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/businesscriticities.html.twig b/src/v1/Views/subitem/businesscriticities.html.twig new file mode 100644 index 0000000000..1f1b91be8a --- /dev/null +++ b/src/v1/Views/subitem/businesscriticities.html.twig @@ -0,0 +1,35 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + + + + + + {% for key,businesscriticity in data.businesscriticities %} + + + + + + {% endfor %} + +
{{ translation.name }}{{ translation.entity }}{{ translation.comment }}
+ {% if businesscriticity.url != '' %} + {{ businesscriticity.name }} + {% else %} + {{ businesscriticity.name }} + {% endif %} + + {% if businesscriticity.entity_url != '' %} + {{ businesscriticity.entity }} + {% else %} + {{ businesscriticity.entity }} + {% endif %} + {{ businesscriticity.comment }}
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/cartridgesprinters.html.twig b/src/v1/Views/subitem/cartridgesprinters.html.twig index 9c8e69d3cb..4bd493f190 100644 --- a/src/v1/Views/subitem/cartridgesprinters.html.twig +++ b/src/v1/Views/subitem/cartridgesprinters.html.twig @@ -17,13 +17,19 @@ {% for key,cartridge in data.cartridges_use %} - {% if cartridge.url != '' %} - {{ cartridge.model }} + {% if cartridge.model_url != '' %} + {{ cartridge.model }} {% else %} {{ cartridge.model }} {% endif %} - {{ cartridge.type }} + + {% if cartridge.type_url != '' %} + {{ cartridge.type }} + {% else %} + {{ cartridge.type }} + {% endif %} + {{ cartridge.date_add }} {{ cartridge.date_use }} @@ -50,13 +56,19 @@ {% for key,cartridge in data.cartridges_out %} - {% if cartridge.url != '' %} - {{ cartridge.model }} + {% if cartridge.model_url != '' %} + {{ cartridge.model }} {% else %} {{ cartridge.model }} {% endif %} - {{ cartridge.type }} + + {% if cartridge.type_url != '' %} + {{ cartridge.type }} + {% else %} + {{ cartridge.type }} + {% endif %} + {{ cartridge.date_add }} {{ cartridge.date_use }} {{ cartridge.date_end }} diff --git a/src/v1/Views/subitem/categories.html.twig b/src/v1/Views/subitem/categories.html.twig index 6f741cf79d..23366b8532 100644 --- a/src/v1/Views/subitem/categories.html.twig +++ b/src/v1/Views/subitem/categories.html.twig @@ -31,10 +31,34 @@ {{ categorie.name }} {% endif %} - {{ categorie.entity }} - {{ categorie.user }} - {{ categorie.group }} - {{ categorie.knowbaseitemcategory }} + + {% if categorie.entity_url != '' %} + {{ categorie.entity }} + {% else %} + {{ categorie.entity }} + {% endif %} + + + {% if categorie.user_url != '' %} + {{ categorie.user }} + {% else %} + {{ categorie.user }} + {% endif %} + + + {% if categorie.group_url != '' %} + {{ categorie.group }} + {% else %} + {{ categorie.group }} + {% endif %} + + + {% if categorie.knowbaseitemcategory_url != '' %} + {{ categorie.knowbaseitemcategory }} + {% else %} + {{ categorie.knowbaseitemcategory }} + {% endif %} + {% if categorie.visible_simplified_interface %} @@ -80,10 +104,34 @@ {% endif %} {{ categorie.visible_change_val }} - {{ categorie.template_request }} - {{ categorie.template_incident }} - {{ categorie.template_change }} - {{ categorie.template_problem }} + + {% if categorie.template_request_url != '' %} + {{ categorie.template_request }} + {% else %} + {{ categorie.template_request }} + {% endif %} + + + {% if categorie.template_incident_url != '' %} + {{ categorie.template_incident }} + {% else %} + {{ categorie.template_incident }} + {% endif %} + + + {% if categorie.template_change_url != '' %} + {{ categorie.template_change }} + {% else %} + {{ categorie.template_change }} + {% endif %} + + + {% if categorie.template_problem_url != '' %} + {{ categorie.template_problem }} + {% else %} + {{ categorie.template_problem }} + {% endif %} + {{ categorie.comment }} diff --git a/src/v1/Views/subitem/certificates.html.twig b/src/v1/Views/subitem/certificates.html.twig index beaba2d985..740bea5a20 100644 --- a/src/v1/Views/subitem/certificates.html.twig +++ b/src/v1/Views/subitem/certificates.html.twig @@ -12,13 +12,25 @@
{{ translation.entity }} -
{{ certificate.entity }}
+
+ {% if certificate.entity_url != '' %} + {{ certificate.entity }} + {% else %} + {{ certificate.entity }} + {% endif %} +
{{ translation.type }} -
{{ certificate.type }}
+
+ {% if certificate.type_url != '' %} + {{ certificate.type }} + {% else %} + {{ certificate.type }} + {% endif %} +
@@ -47,8 +59,14 @@
- {{ translation.state }} -
{{ certificate.state }}
+ {{ translation.status }} +
+ {% if certificate.state_url != '' %} + {{ certificate.state }} + {% else %} + {{ certificate.state }} + {% endif %} +
diff --git a/src/v1/Views/subitem/components.html.twig b/src/v1/Views/subitem/components.html.twig index 86665b1e43..ee5dc193e4 100644 --- a/src/v1/Views/subitem/components.html.twig +++ b/src/v1/Views/subitem/components.html.twig @@ -15,13 +15,25 @@
{{ translation.manufacturer }} -
{{ firmware.manufacturer }}
+
+ {% if firmware.manufacturer_url != '' %} + {{ firmware.manufacturer }} + {% else %} + {{ firmware.manufacturer }} + {% endif %} +
{{ translation.type }} -
{{ firmware.type }}
+
+ {% if firmware.type_url != '' %} + {{ firmware.type }} + {% else %} + {{ firmware.type }} + {% endif %} +
@@ -36,10 +48,54 @@
{{ firmware.date }}
+
+
+ {{ translation.serial }} +
{{ firmware.serial }}
+
+
+
+
+ {{ translation.inventaire_number }} +
{{ firmware.otherserial }}
+
+
{{ translation.location }} -
{{ firmware.location }}
+
+ {% if firmware.location_url != '' %} + {{ firmware.location }} + {% else %} + {{ firmware.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if firmware.state_url != '' %} + {{ firmware.state }} + {% else %} + {{ firmware.state }} + {% endif %} +
+
+
+
+
+ {{ translation.documents }} + {% for document in firmware.documents %} +
+ {% if document.url != '' %} + {{ document.name }} + {% else %} + {{ document.name }} + {% endif %} +
+ {% endfor %}
@@ -58,7 +114,13 @@
{{ translation.manufacturer }} -
{{ processor.manufacturer }}
+
+ {% if processor.manufacturer_url != '' %} + {{ processor.manufacturer }} + {% else %} + {{ processor.manufacturer }} + {% endif %} +
@@ -67,6 +129,42 @@
{{ processor.frequency }}
+
+
+ {{ translation.serial }} +
{{ processor.serial }}
+
+
+
+
+ {{ translation.inventaire_number }} +
{{ processor.otherserial }}
+
+
+
+
+ {{ translation.location }} +
+ {% if processor.location_url != '' %} + {{ processor.location }} + {% else %} + {{ processor.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if processor.state_url != '' %} + {{ processor.state }} + {% else %} + {{ processor.state }} + {% endif %} +
+
+
{{ translation.nbcores }} @@ -79,6 +177,26 @@
{{ processor.nbthreads }}
+
+
+ {{ translation.busID }} +
{{ processor.busID }}
+
+
+
+
+ {{ translation.documents }} + {% for document in processor.documents %} +
+ {% if document.url != '' %} + {{ document.name }} + {% else %} + {{ document.name }} + {% endif %} +
+ {% endfor %} +
+
@@ -95,13 +213,25 @@
{{ translation.manufacturer }} -
{{ memory.manufacturer }}
+
+ {% if memory.manufacturer_url != '' %} + {{ memory.manufacturer }} + {% else %} + {{ memory.manufacturer }} + {% endif %} +
{{ translation.type }} -
{{ memory.type }}
+
+ {% if memory.type_url != '' %} + {{ memory.type }} + {% else %} + {{ memory.type }} + {% endif %} +
@@ -122,10 +252,34 @@
{{ memory.serial }}
+
+
+ {{ translation.inventaire_number }} +
{{ memory.otherserial }}
+
+
{{ translation.location }} -
{{ memory.location }}
+
+ {% if memory.location_url != '' %} + {{ memory.location }} + {% else %} + {{ memory.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if memory.state_url != '' %} + {{ memory.state }} + {% else %} + {{ memory.state }} + {% endif %} +
@@ -134,6 +288,20 @@
{{ memory.busID }}
+
+
+ {{ translation.documents }} + {% for document in memory.documents %} +
+ {% if document.url != '' %} + {{ document.name }} + {% else %} + {{ document.name }} + {% endif %} +
+ {% endfor %} +
+
@@ -150,7 +318,13 @@
{{ translation.manufacturer }} -
{{ harddrive.manufacturer }}
+
+ {% if harddrive.manufacturer_url != '' %} + {{ harddrive.manufacturer }} + {% else %} + {{ harddrive.manufacturer }} + {% endif %} +
@@ -168,7 +342,13 @@
{{ translation.interface }} -
{{ harddrive.interface }}
+
+ {% if harddrive.interface_url != '' %} + {{ harddrive.interface }} + {% else %} + {{ harddrive.interface }} + {% endif %} +
@@ -177,10 +357,60 @@
{{ harddrive.capacity }}
+
+
+ {{ translation.serial }} +
{{ harddrive.serial }}
+
+
+
+
+ {{ translation.inventaire_number }} +
{{ harddrive.otherserial }}
+
+
{{ translation.location }} -
{{ harddrive.location }}
+
+ {% if harddrive.location_url != '' %} + {{ harddrive.location }} + {% else %} + {{ harddrive.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if harddrive.state_url != '' %} + {{ harddrive.state }} + {% else %} + {{ harddrive.state }} + {% endif %} +
+
+
+
+
+ {{ translation.busID }} +
{{ harddrive.busID }}
+
+
+
+
+ {{ translation.documents }} + {% for document in harddrive.documents %} +
+ {% if document.url != '' %} + {{ document.name }} + {% else %} + {{ document.name }} + {% endif %} +
+ {% endfor %}
@@ -199,13 +429,25 @@
{{ translation.manufacturer }} -
{{ battery.manufacturer }}
+
+ {% if battery.manufacturer_url != '' %} + {{ battery.manufacturer }} + {% else %} + {{ battery.manufacturer }} + {% endif %} +
{{ translation.type }} -
{{ battery.type }}
+
+ {% if battery.type_url != '' %} + {{ battery.type }} + {% else %} + {{ battery.type }} + {% endif %} +
@@ -226,10 +468,34 @@
{{ battery.serial }}
+
+
+ {{ translation.inventaire_number }} +
{{ battery.otherserial }}
+
+
{{ translation.location }} -
{{ battery.location }}
+
+ {% if battery.location_url != '' %} + {{ battery.location }} + {% else %} + {{ battery.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if battery.state_url != '' %} + {{ battery.state }} + {% else %} + {{ battery.state }} + {% endif %} +
@@ -238,6 +504,20 @@
{{ battery.manufacturing_date }}
+
+
+ {{ translation.documents }} + {% for document in battery.documents %} +
+ {% if document.url != '' %} + {{ document.name }} + {% else %} + {{ document.name }} + {% endif %} +
+ {% endfor %} +
+
@@ -254,7 +534,13 @@
{{ translation.manufacturer }} -
{{ soundcard.manufacturer }}
+
+ {% if soundcard.manufacturer_url != '' %} + {{ soundcard.manufacturer }} + {% else %} + {{ soundcard.manufacturer }} + {% endif %} +
@@ -263,10 +549,60 @@
{{ soundcard.type }}
+
+
+ {{ translation.serial }} +
{{ soundcard.serial }}
+
+
+
+
+ {{ translation.inventaire_number }} +
{{ soundcard.otherserial }}
+
+
{{ translation.location }} -
{{ soundcard.location }}
+
+ {% if soundcard.location_url != '' %} + {{ soundcard.location }} + {% else %} + {{ soundcard.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if soundcard.state_url != '' %} + {{ soundcard.state }} + {% else %} + {{ soundcard.state }} + {% endif %} +
+
+
+
+
+ {{ translation.busID }} +
{{ soundcard.busID }}
+
+
+
+
+ {{ translation.documents }} + {% for document in soundcard.documents %} +
+ {% if document.url != '' %} + {{ document.name }} + {% else %} + {{ document.name }} + {% endif %} +
+ {% endfor %}
@@ -285,19 +621,81 @@
{{ translation.manufacturer }} -
{{ controller.manufacturer }}
+
+ {% if controller.manufacturer_url != '' %} + {{ controller.manufacturer }} + {% else %} + {{ controller.manufacturer }} + {% endif %} +
{{ translation.interface }} -
{{ controller.interface }}
+
+ {% if controller.interface_url != '' %} + {{ controller.interface }} + {% else %} + {{ controller.interface }} + {% endif %} +
+
+
+
+
+ {{ translation.serial }} +
{{ controller.serial }}
+
+
+
+
+ {{ translation.inventaire_number }} +
{{ controller.otherserial }}
{{ translation.location }} -
{{ controller.location }}
+
+ {% if controller.location_url != '' %} + {{ controller.location }} + {% else %} + {{ controller.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if controller.state_url != '' %} + {{ controller.state }} + {% else %} + {{ controller.state }} + {% endif %} +
+
+
+
+
+ {{ translation.busID }} +
{{ controller.busID }}
+
+
+
+
+ {{ translation.documents }} + {% for document in controller.documents %} +
+ {% if document.url != '' %} + {{ document.name }} + {% else %} + {{ document.name }} + {% endif %} +
+ {% endfor %}
@@ -313,13 +711,54 @@
+
+
+ {{ translation.manufacturer }} +
+ {% if powersupply.manufacturer_url != '' %} + {{ powersupply.manufacturer }} + {% else %} + {{ powersupply.manufacturer }} + {% endif %} +
+
+
+
+
+ {{ translation.serial }} +
{{ powersupply.serial }}
+
+
+
+
+ {{ translation.inventaire_number }} +
{{ powersupply.otherserial }}
+
+
{{ translation.location }} -
{{ powersupply.location }}
+
+ {% if powersupply.location_url != '' %} + {{ powersupply.location }} + {% else %} + {{ powersupply.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if powersupply.state_url != '' %} + {{ powersupply.state }} + {% else %} + {{ powersupply.state }} + {% endif %} +
- {% if powersupply.documents|length > 0%}
{{ translation.documents }} @@ -334,7 +773,6 @@ {% endfor %}
- {% endif %}
@@ -351,16 +789,51 @@
{{ translation.manufacturer }} -
{{ sensor.manufacturer }}
+
+ {% if sensor.manufacturer_url != '' %} + {{ sensor.manufacturer }} + {% else %} + {{ sensor.manufacturer }} + {% endif %} +
+
+
+
+
+ {{ translation.serial }} +
{{ sensor.serial }}
+
+
+
+
+ {{ translation.inventaire_number }} +
{{ sensor.otherserial }}
{{ translation.location }} -
{{ sensor.location }}
+
+ {% if sensor.location_url != '' %} + {{ sensor.location }} + {% else %} + {{ sensor.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if sensor.state_url != '' %} + {{ sensor.state }} + {% else %} + {{ sensor.state }} + {% endif %} +
- {% if sensor.documents|length > 0%}
{{ translation.documents }} @@ -375,7 +848,6 @@ {% endfor %}
- {% endif %} @@ -391,11 +863,46 @@
- {{ translation.location }} -
{{ devicepci.location }}
+ {{ translation.serial }} +
{{ devicepci.serial }}
+
+
+
+
+ {{ translation.inventaire_number }} +
{{ devicepci.otherserial }}
+
+
+
+
+ {{ translation.location }} +
+ {% if devicepci.location_url != '' %} + {{ devicepci.location }} + {% else %} + {{ devicepci.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if devicepci.state_url != '' %} + {{ devicepci.state }} + {% else %} + {{ devicepci.state }} + {% endif %} +
+
+
+
+
+ {{ translation.busID }} +
{{ devicepci.busID }}
- {% if devicepci.documents|length > 0%}
{{ translation.documents }} @@ -410,7 +917,6 @@ {% endfor %}
- {% endif %}
@@ -424,13 +930,54 @@
+
+
+ {{ translation.manufacturer }} +
+ {% if devicegeneric.manufacturer_url != '' %} + {{ devicegeneric.manufacturer }} + {% else %} + {{ devicegeneric.manufacturer }} + {% endif %} +
+
+
+
+
+ {{ translation.serial }} +
{{ devicegeneric.serial }}
+
+
+
+
+ {{ translation.inventaire_number }} +
{{ devicegeneric.otherserial }}
+
+
{{ translation.location }} -
{{ devicegeneric.location }}
+
+ {% if devicegeneric.location_url != '' %} + {{ devicegeneric.location }} + {% else %} + {{ devicegeneric.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if devicegeneric.state_url != '' %} + {{ devicegeneric.state }} + {% else %} + {{ devicegeneric.state }} + {% endif %} +
- {% if devicegeneric.documents|length > 0%}
{{ translation.documents }} @@ -445,7 +992,6 @@ {% endfor %}
- {% endif %}
@@ -461,8 +1007,20 @@
- {{ translation.location }} -
{{ devicenetworkcard.location }}
+ {{ translation.manufacturer }} +
+ {% if devicenetworkcard.manufacturer_url != '' %} + {{ devicenetworkcard.manufacturer }} + {% else %} + {{ devicenetworkcard.manufacturer }} + {% endif %} +
+
+
+
+
+ {{ translation.flow }} +
{{ devicenetworkcard.speed }}
@@ -471,7 +1029,48 @@
{{ devicenetworkcard.mac_address }}
- {% if devicenetworkcard.documents|length > 0%} +
+
+ {{ translation.serial }} +
{{ devicenetworkcard.serial }}
+
+
+
+
+ {{ translation.inventaire_number }} +
{{ devicenetworkcard.otherserial }}
+
+
+
+
+ {{ translation.location }} +
+ {% if devicenetworkcard.location_url != '' %} + {{ devicenetworkcard.location }} + {% else %} + {{ devicenetworkcard.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if devicenetworkcard.state_url != '' %} + {{ devicenetworkcard.state }} + {% else %} + {{ devicenetworkcard.state }} + {% endif %} +
+
+
+
+
+ {{ translation.busID }} +
{{ devicenetworkcard.busID }}
+
+
{{ translation.documents }} @@ -486,7 +1085,6 @@ {% endfor %}
- {% endif %} @@ -500,13 +1098,84 @@
+
+
+ {{ translation.serial }} +
{{ devicesimcard.serial }}
+
+
+
+
+ {{ translation.inventaire_number }} +
{{ devicesimcard.otherserial }}
+
+
{{ translation.location }} -
{{ devicesimcard.location }}
+
+ {% if devicesimcard.location_url != '' %} + {{ devicesimcard.location }} + {% else %} + {{ devicesimcard.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if devicesimcard.state_url != '' %} + {{ devicesimcard.state }} + {% else %} + {{ devicesimcard.state }} + {% endif %} +
+
+
+
+
+ {{ translation.line }} +
+ {% if devicesimcard.line_url != '' %} + {{ devicesimcard.line }} + {% else %} + {{ devicesimcard.line }} + {% endif %} +
+
+
+
+
+ {{ translation.msin }} +
{{ devicesimcard.msin }}
+
+
+
+
+ {{ translation.user }} +
+ {% if devicesimcard.user_url != '' %} + {{ devicesimcard.user }} + {% else %} + {{ devicesimcard.user }} + {% endif %} +
+
+
+
+
+ {{ translation.group }} +
+ {% if devicesimcard.group_url != '' %} + {{ devicesimcard.group }} + {% else %} + {{ devicesimcard.group }} + {% endif %} +
- {% if devicesimcard.documents|length > 0%}
{{ translation.documents }} @@ -521,7 +1190,6 @@ {% endfor %}
- {% endif %}
@@ -535,13 +1203,54 @@
+
+
+ {{ translation.manufacturer }} +
+ {% if devicemotherboard.manufacturer_url != '' %} + {{ devicemotherboard.manufacturer }} + {% else %} + {{ devicemotherboard.manufacturer }} + {% endif %} +
+
+
+
+
+ {{ translation.serial }} +
{{ devicemotherboard.serial }}
+
+
+
+
+ {{ translation.inventaire_number }} +
{{ devicemotherboard.otherserial }}
+
+
{{ translation.location }} -
{{ devicemotherboard.location }}
+
+ {% if devicemotherboard.location_url != '' %} + {{ devicemotherboard.location }} + {% else %} + {{ devicemotherboard.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if devicemotherboard.state_url != '' %} + {{ devicemotherboard.state }} + {% else %} + {{ devicemotherboard.state }} + {% endif %} +
- {% if devicemotherboard.documents|length > 0%}
{{ translation.documents }} @@ -556,7 +1265,6 @@ {% endfor %}
- {% endif %}
@@ -573,13 +1281,49 @@
{{ translation.manufacturer }} -
{{ devicecase.manufacturer }}
+
+ {% if devicecase.manufacturer_url != '' %} + {{ devicecase.manufacturer }} + {% else %} + {{ devicecase.manufacturer }} + {% endif %} +
+
+
+
+
+ {{ translation.serial }} +
{{ devicecase.serial }}
+
+
+
+
+ {{ translation.inventaire_number }} +
{{ devicecase.otherserial }}
{{ translation.location }} -
{{ devicecase.location }}
+
+ {% if devicecase.location_url != '' %} + {{ devicecase.location }} + {% else %} + {{ devicecase.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if devicecase.state_url != '' %} + {{ devicecase.state }} + {% else %} + {{ devicecase.state }} + {% endif %} +
{% if devicecase.documents|length > 0%} @@ -614,13 +1358,25 @@
{{ translation.manufacturer }} -
{{ devicegraphiccard.manufacturer }}
+
+ {% if devicegraphiccard.manufacturer_url != '' %} + {{ devicegraphiccard.manufacturer }} + {% else %} + {{ devicegraphiccard.manufacturer }} + {% endif %} +
{{ translation.interface }} -
{{ devicegraphiccard.interface }}
+
+ {% if devicegraphiccard.interface_url != '' %} + {{ devicegraphiccard.interface }} + {% else %} + {{ devicegraphiccard.interface }} + {% endif %} +
@@ -635,13 +1391,48 @@
{{ devicegraphiccard.memory }}
+
+
+ {{ translation.serial }} +
{{ devicegraphiccard.serial }}
+
+
+
+
+ {{ translation.inventaire_number }} +
{{ devicegraphiccard.otherserial }}
+
+
{{ translation.location }} -
{{ devicegraphiccard.location }}
+
+ {% if devicegraphiccard.location_url != '' %} + {{ devicegraphiccard.location }} + {% else %} + {{ devicegraphiccard.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if devicegraphiccard.state_url != '' %} + {{ devicegraphiccard.state }} + {% else %} + {{ devicegraphiccard.state }} + {% endif %} +
+
+
+
+
+ {{ translation.busID }} +
{{ devicegraphiccard.busID }}
- {% if devicegraphiccard.documents|length > 0%}
{{ translation.documents }} @@ -656,7 +1447,6 @@ {% endfor %}
- {% endif %} @@ -673,7 +1463,13 @@
{{ translation.manufacturer }} -
{{ devicedrive.manufacturer }}
+
+ {% if devicedrive.manufacturer_url != '' %} + {{ devicedrive.manufacturer }} + {% else %} + {{ devicedrive.manufacturer }} + {% endif %} +
@@ -683,12 +1479,12 @@ {% if devicedrive.write %}
- Yes + {{ devicedrive.write_val }}
{% else %}
- No + {{ devicedrive.write_val }}
{% endif %}
@@ -703,16 +1499,57 @@
{{ translation.interface }} -
{{ devicedrive.interface }}
+
+ {% if devicedrive.interface_url != '' %} + {{ devicedrive.interface }} + {% else %} + {{ devicedrive.interface }} + {% endif %} +
+
+
+
+
+ {{ translation.serial }} +
{{ devicedrive.serial }}
+
+
+
+
+ {{ translation.inventaire_number }} +
{{ devicedrive.otherserial }}
{{ translation.location }} -
{{ devicedrive.location }}
+
+ {% if devicedrive.location_url != '' %} + {{ devicedrive.location }} + {% else %} + {{ devicedrive.location }} + {% endif %} +
+
+
+
+
+ {{ translation.status }} +
+ {% if devicedrive.state_url != '' %} + {{ devicedrive.state }} + {% else %} + {{ devicedrive.state }} + {% endif %} +
+
+
+
+
+ {{ translation.busID }} +
{{ devicedrive.busID }}
- {% if devicedrive.documents|length > 0%}
{{ translation.documents }} @@ -727,7 +1564,6 @@ {% endfor %}
- {% endif %} diff --git a/src/v1/Views/subitem/connections.html.twig b/src/v1/Views/subitem/connections.html.twig index ce4ca61aec..c1d8dd58e7 100644 --- a/src/v1/Views/subitem/connections.html.twig +++ b/src/v1/Views/subitem/connections.html.twig @@ -39,7 +39,13 @@ {{ connection.auto_val }} {% endif %} - {{ connection.entity }} + + {% if connection.entity_url != '' %} + {{ connection.entity }} + {% else %} + {{ connection.entity }} + {% endif %} + {{ connection.serial_number }} {{ connection.inventaire_number }} diff --git a/src/v1/Views/subitem/contracts.html.twig b/src/v1/Views/subitem/contracts.html.twig index 0d0171d40f..929dfd45e6 100644 --- a/src/v1/Views/subitem/contracts.html.twig +++ b/src/v1/Views/subitem/contracts.html.twig @@ -25,13 +25,31 @@ {{ contract.name }} {% endif %} - {{ contract.entity }} + + {% if contract.entity_url != '' %} + {{ contract.entity }} + {% else %} + {{ contract.entity }} + {% endif %} + {{ contract.number }} - {{ contract.type }} + + {% if contract.contracttype_url != '' %} + {{ contract.type }} + {% else %} + {{ contract.type }} + {% endif %} + {% if data.show_suppliers %} {% for supplier in contract.suppliers %} -

{{ supplier.name }}

+

+ {% if supplier.url != '' %} + {{ supplier.name }} + {% else %} + {{ supplier.name }} + {% endif %} +

{% endfor %} {% endif %} diff --git a/src/v1/Views/subitem/costs.html.twig b/src/v1/Views/subitem/costs.html.twig index e48a058e53..ac6d7daab7 100644 --- a/src/v1/Views/subitem/costs.html.twig +++ b/src/v1/Views/subitem/costs.html.twig @@ -13,7 +13,7 @@ {{ translation.begin_date }} {{ translation.end_date }} {{ translation.budget }} - {% if data.show == 'ticket' %} + {% if data.show == 'tickets' or data.show == 'problems' or data.show == 'changes' %} {{ translation.actiontime }} {{ translation.cost_time }} {{ translation.cost_fixed }} @@ -35,7 +35,7 @@ {{ cost.budget }} {% endif %} - {% if data.show == 'ticket' %} + {% if data.show == 'tickets' or data.show == 'problems' or data.show == 'changes' %} {{ cost.actiontime }} {{ cost.cost_time }} {{ cost.cost_fixed }} @@ -46,7 +46,7 @@ {% endfor %} {% if data.costs|length > 0 %} - {% if data.show == 'ticket' %} + {% if data.show == 'tickets' or data.show == 'problems' or data.show == 'changes' %} {{ translation.total }} {{ data.total_actiontime }} {{ data.total_cost_time }} @@ -61,7 +61,7 @@ -{% if data.show == 'project' %} +{% if data.show == 'projects' %} diff --git a/src/v1/Views/subitem/dcrooms.html.twig b/src/v1/Views/subitem/dcrooms.html.twig new file mode 100644 index 0000000000..809f68292b --- /dev/null +++ b/src/v1/Views/subitem/dcrooms.html.twig @@ -0,0 +1,25 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + +
+ + + + + + + {% for key,dcroom in data.dcrooms %} + + + + {% endfor %} + +
{{ translation.name }}
+ {% if dcroom.url != '' %} + {{ dcroom.name }} + {% else %} + {{ dcroom.name }} + {% endif %} +
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/documentcategories.html.twig b/src/v1/Views/subitem/documentcategories.html.twig new file mode 100644 index 0000000000..06d2925c4e --- /dev/null +++ b/src/v1/Views/subitem/documentcategories.html.twig @@ -0,0 +1,27 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + + + + + {% for key,documentcategory in data.documentcategories %} + + + + + {% endfor %} + +
{{ translation.name }}{{ translation.comment }}
+ {% if documentcategory.url != '' %} + {{ documentcategory.name }} + {% else %} + {{ documentcategory.name }} + {% endif %} + {{ documentcategory.comment }}
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/documents.html.twig b/src/v1/Views/subitem/documents.html.twig index 304512214b..f4f1bbc0ec 100644 --- a/src/v1/Views/subitem/documents.html.twig +++ b/src/v1/Views/subitem/documents.html.twig @@ -24,14 +24,26 @@ {{ document.name }} {% endif %} - {{ document.entity }} + + {% if document.entity_url != '' %} + {{ document.entity }} + {% else %} + {{ document.entity }} + {% endif %} + {{ document.file }} {% if document.weblink != '' %} {{ document.weblink }} {% endif %} - {{ document.rubrique }} + + {% if document.rubrique_url != '' %} + {{ document.rubrique }} + {% else %} + {{ document.rubrique }} + {% endif %} + {{ document.mimetype }} {{ document.balise }} {{ document.date }} diff --git a/src/v1/Views/subitem/domains.html.twig b/src/v1/Views/subitem/domains.html.twig index 8d9eb1f343..739d842620 100644 --- a/src/v1/Views/subitem/domains.html.twig +++ b/src/v1/Views/subitem/domains.html.twig @@ -9,34 +9,78 @@
+ {% if data.show == 'domainrelations' %} +
+
+ {{ translation.name }} +
+ {% if domain.url != '' %} + {{ domain.name }} + {% else %} + {{ domain.name }} + {% endif %} +
+
+
+ {% endif %}
{{ translation.entity }} -
{{ domain.entity }}
+
+ {% if domain.entity_url != '' %} + {{ domain.entity }} + {% else %} + {{ domain.entity }} + {% endif %} +
{{ translation.group }} -
{{ domain.group }}
+
+ {% if domain.group_url != '' %} + {{ domain.group }} + {% else %} + {{ domain.group }} + {% endif %} +
{{ translation.user }} -
{{ domain.user }}
+
+ {% if domain.user_url != '' %} + {{ domain.user }} + {% else %} + {{ domain.user }} + {% endif %} +
{{ translation.type }} -
{{ domain.type }}
+
+ {% if domain.type_url != '' %} + {{ domain.type }} + {% else %} + {{ domain.type }} + {% endif %} +
{{ translation.relation }} -
{{ domain.relation }}
+
+ {% if domain.relation_url != '' %} + {{ domain.relation }} + {% else %} + {{ domain.relation }} + {% endif %} +
diff --git a/src/v1/Views/subitem/entities.html.twig b/src/v1/Views/subitem/entities.html.twig index e28e056d9f..a53cad4209 100644 --- a/src/v1/Views/subitem/entities.html.twig +++ b/src/v1/Views/subitem/entities.html.twig @@ -19,7 +19,13 @@ {{ entity.name }} {% endif %} - {{ entity.entity }} + + {% if entity.entity_url != '' %} + {{ entity.entity }} + {% else %} + {{ entity.entity }} + {% endif %} + {{ entity.comment }} {% endfor %} diff --git a/src/v1/Views/subitem/groups.html.twig b/src/v1/Views/subitem/groups.html.twig index dc6b09b093..3c37bbfecd 100644 --- a/src/v1/Views/subitem/groups.html.twig +++ b/src/v1/Views/subitem/groups.html.twig @@ -24,31 +24,31 @@ {% if group.auto %} - Yes + {{ group.auto_val }} {% else %} - No + {{ group.auto_val }} {% endif %} {% if group.is_manager %} - Yes + {{ group.is_manager_val }} {% else %} - No + {{ group.is_manager_val }} {% endif %} {% if group.is_userdelegate %} - Yes + {{ group.is_userdelegate_val }} {% else %} - No + {{ group.is_userdelegate_val }} {% endif %} @@ -76,7 +76,13 @@ {{ group.name }} {% endif %} - {{ group.entity }} + + {% if group.entity_url != '' %} + {{ group.entity }} + {% else %} + {{ group.entity }} + {% endif %} + {{ group.comment }} {% endfor %} diff --git a/src/v1/Views/subitem/holidays.html.twig b/src/v1/Views/subitem/holidays.html.twig new file mode 100644 index 0000000000..deccef9465 --- /dev/null +++ b/src/v1/Views/subitem/holidays.html.twig @@ -0,0 +1,39 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + + + + + + + {% for key,holiday in data.holidays %} + + + + + {% if holiday.recurrent %} + + + {% endfor %} + +
{{ translation.name }}{{ translation.begin }}{{ translation.end }}{{ translation.recurrent }}
+ {% if holiday.url != '' %} + {{ holiday.name }} + {% else %} + {{ holiday.name }} + {% endif %} + {{ holiday.begin }}{{ holiday.end }} + + {% else %} + + + {% endif %} + {{ holiday.recurrent_val }} +
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/infocom.html.twig b/src/v1/Views/subitem/infocom.html.twig new file mode 100644 index 0000000000..23bc2b25dc --- /dev/null +++ b/src/v1/Views/subitem/infocom.html.twig @@ -0,0 +1,18 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + +
+ +
+
+
+ {% for item in data.fields %} + {{ include('fields.html.twig') }} + {% endfor %} +
+
+
+ +
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/items.html.twig b/src/v1/Views/subitem/items.html.twig index 6f053d898a..2753ff40c7 100644 --- a/src/v1/Views/subitem/items.html.twig +++ b/src/v1/Views/subitem/items.html.twig @@ -2,7 +2,7 @@ {{ include('headerForm.html.twig') }} -{% if data.show == 'cluster' %} +{% if data.show == 'clusters' %} @@ -25,7 +25,7 @@
{% endif %} -{% if data.show == 'appliance' %} +{% if data.show == 'appliances' %} @@ -68,7 +68,7 @@
{% endif %} -{% if data.show == 'project' %} +{% if data.show == 'projects' %} @@ -90,7 +90,13 @@ {{ item.name }} {% endif %} - + @@ -99,4 +105,476 @@
{{ item.entity }} + {% if item.entity_url != '' %} + {{ item.entity }} + {% else %} + {{ item.entity }} + {% endif %} + {{ item.serial_number }} {{ item.inventaire_number }}
{% endif %} +{% if data.show == 'devicepowersupplies' or data.show == 'devicecases' or data.show == 'devicesensors' or data.show == 'devicemotherboards' or data.show == 'devicesoundcards' or data.show == 'devicegenerics' or data.show == 'devicecontrols' or data.show == 'devicefirmwares' or data.show == 'devicedrives' or data.show == 'devicepcis' or data.show == 'devicesimcards' %} + {% for key,item in data.items %} +

{{ item.name }}

+ + + + + + + + + + + {% for key2,item2 in item.items %} + {% for key3,item3 in item2 %} + + + + + + {% endfor %} + {% endfor %} + +
{{ translation.name }}{{ translation.location }}{{ translation.documents }}
+ {% if item3.url != '' %} + {{ item3.name }} + {% else %} + {{ item3.name }} + {% endif %} + + {% if item3.location_url != '' %} + {{ item3.location }} + {% else %} + {{ item3.location }} + {% endif %} + + {% for document in item3.documents %} +

+ {% if document.url != '' %} + {{ document.name }} + {% else %} + {{ document.name }} + {% endif %} +

+ {% endfor %} +
+ {% endfor %} +{% endif %} + +{% if data.show == 'devicebatteries' %} + {% for key,item in data.items %} +

{{ item.name }}

+ + + + + + {% if item.type == 'computers' %} + + {% endif %} + + {% if item.type == 'computers' %} + + {% endif %} + + + + + {% for key2,item2 in item.items %} + {% for key3,item3 in item2 %} + + + {% if item.type == 'computers' %} + + {% endif %} + + {% if item.type == 'computers' %} + + {% endif %} + + + {% endfor %} + {% endfor %} + +
{{ translation.name }}{{ translation.serial }}{{ translation.location }}{{ translation.manufacturing_date }}{{ translation.documents }}
+ {% if item3.url != '' %} + {{ item3.name }} + {% else %} + {{ item3.name }} + {% endif %} + {{ item3.serial }} + {% if item3.location_url != '' %} + {{ item3.location }} + {% else %} + {{ item3.location }} + {% endif %} + {{ item3.manufacturing_date }} + {% for document in item3.documents %} +

+ {% if document.url != '' %} + {{ document.name }} + {% else %} + {{ document.name }} + {% endif %} +

+ {% endfor %} +
+ {% endfor %} +{% endif %} + +{% if data.show == 'devicegraphiccards' %} + {% for key,item in data.items %} +

{{ item.name }}

+ + + + + + {% if item.type == 'computers' %} + + {% endif %} + + + + + + {% for key2,item2 in item.items %} + {% for key3,item3 in item2 %} + + + {% if item.type == 'computers' %} + + {% endif %} + + + + {% endfor %} + {% endfor %} + +
{{ translation.name }}{{ translation.memory_mio }}{{ translation.location }}{{ translation.documents }}
+ {% if item3.url != '' %} + {{ item3.name }} + {% else %} + {{ item3.name }} + {% endif %} + {{ item3.memory }} + {% if item3.location_url != '' %} + {{ item3.location }} + {% else %} + {{ item3.location }} + {% endif %} + + {% for document in item3.documents %} +

+ {% if document.url != '' %} + {{ document.name }} + {% else %} + {{ document.name }} + {% endif %} +

+ {% endfor %} +
+ {% endfor %} +{% endif %} + +{% if data.show == 'devicenetworkcards' %} + {% for key,item in data.items %} +

{{ item.name }}

+ + + + + + + + + + + + {% for key2,item2 in item.items %} + {% for key3,item3 in item2 %} + + + + + + + {% endfor %} + {% endfor %} + +
{{ translation.name }}{{ translation.mac }}{{ translation.location }}{{ translation.documents }}
+ {% if item3.url != '' %} + {{ item3.name }} + {% else %} + {{ item3.name }} + {% endif %} + {{ item3.mac }} + {% if item3.location_url != '' %} + {{ item3.location }} + {% else %} + {{ item3.location }} + {% endif %} + + {% for document in item3.documents %} +

+ {% if document.url != '' %} + {{ document.name }} + {% else %} + {{ document.name }} + {% endif %} +

+ {% endfor %} +
+ {% endfor %} +{% endif %} + +{% if data.show == 'deviceharddrives' %} + {% for key,item in data.items %} +

{{ item.name }}

+ + + + + + + {% if item.type == 'computers' %} + + {% endif %} + + + + + + {% for key2,item2 in item.items %} + {% for key3,item3 in item2 %} + + + + {% if item.type == 'computers' %} + + {% endif %} + + + + {% endfor %} + {% endfor %} + +
{{ translation.name }}{{ translation.capacity_mio }}{{ translation.serial }}{{ translation.location }}{{ translation.documents }}
+ {% if item3.url != '' %} + {{ item3.name }} + {% else %} + {{ item3.name }} + {% endif %} + {{ item3.capacity }}{{ item3.serial }} + {% if item3.location_url != '' %} + {{ item3.location }} + {% else %} + {{ item3.location }} + {% endif %} + + {% for document in item3.documents %} +

+ {% if document.url != '' %} + {{ document.name }} + {% else %} + {{ document.name }} + {% endif %} +

+ {% endfor %} +
+ {% endfor %} +{% endif %} + +{% if data.show == 'devicememories' %} + {% for key,item in data.items %} +

{{ item.name }}

+ + + + + + + {% if item.type == 'computers' %} + + {% endif %} + + + + + + {% for key2,item2 in item.items %} + {% for key3,item3 in item2 %} + + + + {% if item.type == 'computers' %} + + {% endif %} + + + + {% endfor %} + {% endfor %} + +
{{ translation.name }}{{ translation.size_mio }}{{ translation.serial }}{{ translation.location }}{{ translation.documents }}
+ {% if item3.url != '' %} + {{ item3.name }} + {% else %} + {{ item3.name }} + {% endif %} + {{ item3.size }}{{ item3.serial }} + {% if item3.location_url != '' %} + {{ item3.location }} + {% else %} + {{ item3.location }} + {% endif %} + + {% for document in item3.documents %} +

+ {% if document.url != '' %} + {{ document.name }} + {% else %} + {{ document.name }} + {% endif %} +

+ {% endfor %} +
+ {% endfor %} +{% endif %} + +{% if data.show == 'deviceprocessors' %} + {% for key,item in data.items %} +

{{ item.name }}

+ + + + + + {% if item.type == 'computers' %} + + {% endif %} + + {% if item.type == 'computers' %} + + + {% endif %} + + + + + {% for key2,item2 in item.items %} + {% for key3,item3 in item2 %} + + + {% if item.type == 'computers' %} + + {% endif %} + + {% if item.type == 'computers' %} + + + {% endif %} + + + {% endfor %} + {% endfor %} + +
{{ translation.name }}{{ translation.frequence_mhz }}{{ translation.location }}{{ translation.nbcores }}{{ translation.nbthreads }}{{ translation.documents }}
+ {% if item3.url != '' %} + {{ item3.name }} + {% else %} + {{ item3.name }} + {% endif %} + {{ item3.frequency }} + {% if item3.location_url != '' %} + {{ item3.location }} + {% else %} + {{ item3.location }} + {% endif %} + {{ item3.nbcores }}{{ item3.nbthreads }} + {% for document in item3.documents %} +

+ {% if document.url != '' %} + {{ document.name }} + {% else %} + {{ document.name }} + {% endif %} +

+ {% endfor %} +
+ {% endfor %} +{% endif %} + +{% if data.show == 'enclosures' %} + + + + + + + + + {% for item in data.items %} + + + + + {% endfor %} + +
{{ translation.name }}{{ translation.position }}
+ {% if item.url != '' %} + {{ item.name }} + {% else %} + {{ item.name }} + {% endif %} + {{ item.position }}
+{% endif %} + +{% if data.show == 'tickets' or data.show == 'problems' or data.show == 'changes' %} + + + + + + + + + + + + {% for item in data.items %} + + + + + + + + {% endfor %} + +
{{ translation.type }}{{ translation.entity }}{{ translation.name }}{{ translation.serial_number }}{{ translation.inventaire_number }}
{{ item.type }} + {% if item.entity_url != '' %} + {{ item.entity }} + {% else %} + {{ item.entity }} + {% endif %} + + {% if item.url != '' %} + {{ item.name }} + {% else %} + {{ item.name }} + {% endif %} + {{ item.serial_number }}{{ item.inventaire_number }}
+{% endif %} + +{% if data.show == 'links' %} + + + + + + + + {% for item in data.items %} + + + + {% endfor %} + +
{{ translation.type }}
{{ item.type }}
+{% endif %} + {{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/itil.html.twig b/src/v1/Views/subitem/itil.html.twig index 5118d2770c..dbb80c7e08 100644 --- a/src/v1/Views/subitem/itil.html.twig +++ b/src/v1/Views/subitem/itil.html.twig @@ -17,7 +17,7 @@ {{ translation.requesters }} {{ translation.technicians }} {{ translation.associated_items }} - {{ translation.planification }} + {# {{ translation.planification }} #} @@ -30,7 +30,13 @@ {{ ticket.title }} {% endif %} - {{ ticket.category }} + + {% if ticket.category_url != '' %} + {{ ticket.category }} + {% else %} + {{ ticket.category }} + {% endif %} + {% if ticket.status is iterable %} {{ ticket.entity }} + {% else %} + {{ ticket.entity }} + {% endif %} + {% if ticket.priority is iterable %} {{ requester.name }} + {% else %} + {{ requester.name }} + {% endif %} +

{% endfor %} {% for technician in ticket.technicians %} -

{{ technician.name }}

+

+ {% if technician.url != '' %} + {{ technician.name }} + {% else %} + {{ technician.name }} + {% endif %} +

{% endfor %} {% for associated_item in ticket.associated_items %} -

{{ associated_item.name }}

+

+ {% if associated_item.url != '' %} + {{ associated_item.type }}{{ associated_item.name }} + {% else %} + {{ associated_item.type }}{{ associated_item.name }} + {% endif %} +

{% endfor %} - {{ ticket.planification }} + {# {{ ticket.planification }} #} {% endfor %} @@ -118,7 +148,7 @@ {{ translation.requesters }} {{ translation.technicians }} {{ translation.associated_items }} - {{ translation.planification }} + {# {{ translation.planification }} #} @@ -131,7 +161,13 @@ {{ ticket.title }} {% endif %} - {{ ticket.category }} + + {% if ticket.category_url != '' %} + {{ ticket.category }} + {% else %} + {{ ticket.category }} + {% endif %} + {% if ticket.status is iterable %} {{ ticket.entity }} + {% else %} + {{ ticket.entity }} + {% endif %} + {% if ticket.priority is iterable %} {{ requester.name }} + {% else %} + {{ requester.name }} + {% endif %} +

{% endfor %} {% for technician in ticket.technicians %} -

{{ technician.name }}

+

+ {% if technician.url != '' %} + {{ technician.name }} + {% else %} + {{ technician.name }} + {% endif %} +

{% endfor %} @@ -195,7 +249,7 @@

{{ associated_item.name }}

{% endfor %} - {{ ticket.planification }} + {# {{ ticket.planification }} #} {% endfor %} @@ -221,7 +275,7 @@ {{ translation.priority }} {{ translation.requesters }} {{ translation.technicians }} - {{ translation.planification }} + {# {{ translation.planification }} #} @@ -234,7 +288,13 @@ {{ problem.title }} {% endif %} - {{ problem.category }} + + {% if problem.category_url != '' %} + {{ problem.category }} + {% else %} + {{ problem.category }} + {% endif %} + {% if problem.status is iterable %} {{ problem.entity }} + {% else %} + {{ problem.entity }} + {% endif %} + {% if problem.priority is iterable %} {{ requester.name }} + {% else %} + {{ requester.name }} + {% endif %} +

{% endfor %} {% for technician in problem.technicians %} -

{{ technician.name }}

+

+ {% if technician.url != '' %} + {{ technician.name }} + {% else %} + {{ technician.name }} + {% endif %} +

{% endfor %} - {{ problem.planification }} + {# {{ problem.planification }} #} {% endfor %} @@ -316,7 +394,7 @@ {{ translation.priority }} {{ translation.requesters }} {{ translation.technicians }} - {{ translation.planification }} + {# {{ translation.planification }} #} @@ -329,7 +407,13 @@ {{ problem.title }} {% endif %} - {{ problem.category }} + + {% if problem.category_url != '' %} + {{ problem.category }} + {% else %} + {{ problem.category }} + {% endif %} + {% if problem.status is iterable %} {{ problem.entity }} + {% else %} + {{ problem.entity }} + {% endif %} + {% if problem.priority is iterable %} {{ requester.name }} + {% else %} + {{ requester.name }} + {% endif %} +

{% endfor %} {% for technician in problem.technicians %} -

{{ technician.name }}

+

+ {% if technician.url != '' %} + {{ technician.name }} + {% else %} + {{ technician.name }} + {% endif %} +

{% endfor %} - {{ problem.planification }} + {# {{ problem.planification }} #} {% endfor %} @@ -413,7 +515,7 @@ {{ translation.priority }} {{ translation.requesters }} {{ translation.technicians }} - {{ translation.planification }} + {# {{ translation.planification }} #} @@ -426,7 +528,13 @@ {{ change.title }} {% endif %} - {{ change.category }} + + {% if change.category_url != '' %} + {{ change.category }} + {% else %} + {{ change.category }} + {% endif %} + {% if change.status is iterable %} {{ change.entity }} + {% else %} + {{ change.entity }} + {% endif %} + {% if change.priority is iterable %} {{ requester.name }} + {% else %} + {{ requester.name }} + {% endif %} +

{% endfor %} {% for technician in change.technicians %} -

{{ technician.name }}

+

+ {% if technician.url != '' %} + {{ technician.name }} + {% else %} + {{ technician.name }} + {% endif %} +

{% endfor %} - {{ change.planification }} + {# {{ change.planification }} #} {% endfor %} @@ -508,7 +634,7 @@ {{ translation.priority }} {{ translation.requesters }} {{ translation.technicians }} - {{ translation.planification }} + {# {{ translation.planification }} #} @@ -521,7 +647,13 @@ {{ change.title }} {% endif %} - {{ change.category }} + + {% if change.category_url != '' %} + {{ change.category }} + {% else %} + {{ change.category }} + {% endif %} + {% if change.status is iterable %} {{ change.entity }} + {% else %} + {{ change.entity }} + {% endif %} + {% if change.priority is iterable %} {{ requester.name }} + {% else %} + {{ requester.name }} + {% endif %} +

{% endfor %} {% for technician in change.technicians %} -

{{ technician.name }}

+

+ {% if technician.url != '' %} + {{ technician.name }} + {% else %} + {{ technician.name }} + {% endif %} +

{% endfor %} - {{ change.planification }} + {# {{ change.planification }} #} {% endfor %} diff --git a/src/v1/Views/subitem/itilchanges.html.twig b/src/v1/Views/subitem/itilchanges.html.twig index e454f8bc64..e6c0daf1fb 100644 --- a/src/v1/Views/subitem/itilchanges.html.twig +++ b/src/v1/Views/subitem/itilchanges.html.twig @@ -15,7 +15,7 @@ {{ translation.priority }} {{ translation.requesters }} {{ translation.technicians }} - {{ translation.planification }} + {# {{ translation.planification }} #} @@ -28,7 +28,13 @@ {{ change.title }} {% endif %} - {{ change.category }} + + {% if change.category_url != '' %} + {{ change.category }} + {% else %} + {{ change.category }} + {% endif %} + {% if change.status is iterable %} {{ change.entity }} + {% else %} + {{ change.entity }} + {% endif %} + {% if change.priority is iterable %} {{ requester.name }} + {% else %} + {{ requester.name }} + {% endif %} +

{% endfor %} {% for technician in change.technicians %} -

{{ technician.name }}

+

+ {% if technician.url != '' %} + {{ technician.name }} + {% else %} + {{ technician.name }} + {% endif %} +

{% endfor %} - {{ change.planification }} + {# {{ change.planification }} #} {% endfor %} diff --git a/src/v1/Views/subitem/itilproblems.html.twig b/src/v1/Views/subitem/itilproblems.html.twig index a39d065172..a24b1e12a3 100644 --- a/src/v1/Views/subitem/itilproblems.html.twig +++ b/src/v1/Views/subitem/itilproblems.html.twig @@ -15,7 +15,7 @@ {{ translation.priority }} {{ translation.requesters }} {{ translation.technicians }} - {{ translation.planification }} + {# {{ translation.planification }} #} @@ -28,7 +28,13 @@ {{ problem.title }} {% endif %} - {{ problem.category }} + + {% if problem.category_url != '' %} + {{ problem.category }} + {% else %} + {{ problem.category }} + {% endif %} + {% if problem.status is iterable %} {{ problem.entity }} + {% else %} + {{ problem.entity }} + {% endif %} + {% if problem.priority is iterable %} {{ requester.name }} + {% else %} + {{ requester.name }} + {% endif %} +

{% endfor %} {% for technician in problem.technicians %} -

{{ technician.name }}

+

+ {% if technician.url != '' %} + {{ technician.name }} + {% else %} + {{ technician.name }} + {% endif %} +

{% endfor %} - {{ problem.planification }} + {# {{ problem.planification }} #} {% endfor %} diff --git a/src/v1/Views/subitem/itiltickets.html.twig b/src/v1/Views/subitem/itiltickets.html.twig index 6beddff804..7af9f46250 100644 --- a/src/v1/Views/subitem/itiltickets.html.twig +++ b/src/v1/Views/subitem/itiltickets.html.twig @@ -16,7 +16,7 @@ {{ translation.requesters }} {{ translation.technicians }} {{ translation.associated_items }} - {{ translation.planification }} + {# {{ translation.planification }} #} @@ -29,7 +29,13 @@ {{ ticket.title }} {% endif %} - {{ ticket.category }} + + {% if ticket.category_url != '' %} + {{ ticket.category }} + {% else %} + {{ ticket.category }} + {% endif %} + {% if ticket.status is iterable %} {{ ticket.entity }} + {% else %} + {{ ticket.entity }} + {% endif %} + {% if ticket.priority is iterable %} {{ requester.name }} + {% else %} + {{ requester.name }} + {% endif %} +

{% endfor %} {% for technician in ticket.technicians %} -

{{ technician.name }}

+

+ {% if technician.url != '' %} + {{ technician.name }} + {% else %} + {{ technician.name }} + {% endif %} +

{% endfor %} {% for associated_item in ticket.associated_items %} -

{{ associated_item.name }}

+

+ {% if associated_item.url != '' %} + {{ associated_item.type }}{{ associated_item.name }} + {% else %} + {{ associated_item.type }}{{ associated_item.name }} + {% endif %} +

{% endfor %} - {{ ticket.planification }} + {# {{ ticket.planification }} #} {% endfor %} diff --git a/src/v1/Views/subitem/knowbaseitemcategories.html.twig b/src/v1/Views/subitem/knowbaseitemcategories.html.twig new file mode 100644 index 0000000000..2e9b151d3d --- /dev/null +++ b/src/v1/Views/subitem/knowbaseitemcategories.html.twig @@ -0,0 +1,35 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + + + + + + {% for key,knowbaseitemcategory in data.knowbaseitemcategories %} + + + + + + {% endfor %} + +
{{ translation.name }}{{ translation.entity }}{{ translation.comment }}
+ {% if knowbaseitemcategory.url != '' %} + {{ knowbaseitemcategory.name }} + {% else %} + {{ knowbaseitemcategory.name }} + {% endif %} + + {% if knowbaseitemcategory.entity_url != '' %} + {{ knowbaseitemcategory.entity }} + {% else %} + {{ knowbaseitemcategory.entity }} + {% endif %} + {{ knowbaseitemcategory.comment }}
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/licenses.html.twig b/src/v1/Views/subitem/licenses.html.twig new file mode 100644 index 0000000000..c314578d14 --- /dev/null +++ b/src/v1/Views/subitem/licenses.html.twig @@ -0,0 +1,61 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + + + + + + + + + + + + {% for license in data.licenses %} + + + + + + + + + + + + {% endfor %} + {% if data.licenses|length > 0 %} + + + + + + + {% endif %} + +
{{ translation.name }}{{ translation.serial }}{{ translation.number }}{{ translation.affected_items }}{{ translation.type }}{{ translation.version_buy }}{{ translation.version_use }}{{ translation.expiration }}{{ translation.status }}
+ {% if license.url != '' %} + {{ license.name }} + {% else %} + {{ license.name }} + {% endif %} + {{ license.serial }}{{ license.number }}{{ license.affected_items }} + {% if license.type_url != '' %} + {{ license.type }} + {% else %} + {{ license.type }} + {% endif %} + {{ license.version_buy }}{{ license.version_use }}{{ license.date_expiration }} + {% if license.status_url != '' %} + {{ license.status }} + {% else %} + {{ license.status }} + {% endif %} +
{{ translation.total }}{{ data.total_number }}{{ data.total_affected_items }}
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/locations.html.twig b/src/v1/Views/subitem/locations.html.twig index 3a2d6a08ba..9fd73c3ede 100644 --- a/src/v1/Views/subitem/locations.html.twig +++ b/src/v1/Views/subitem/locations.html.twig @@ -29,7 +29,13 @@ {{ location.name }} {% endif %} - {{ location.entity }} + + {% if location.entity_url != '' %} + {{ location.entity }} + {% else %} + {{ location.entity }} + {% endif %} + {{ location.address }} {{ location.postcode }} {{ location.town }} diff --git a/src/v1/Views/subitem/networkalias.html.twig b/src/v1/Views/subitem/networkalias.html.twig new file mode 100644 index 0000000000..386c1eabe1 --- /dev/null +++ b/src/v1/Views/subitem/networkalias.html.twig @@ -0,0 +1,76 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + +{% if data.show == 'fqdns' %} + + + + + + + + + + {% for key,networkalias in data.networkalias %} + + + + + + {% endfor %} + +
{{ translation.networkalias }}{{ translation.computername }}{{ translation.comment }}
+ {% if networkalias.url != '' %} + {{ networkalias.name }} + {% else %} + {{ networkalias.name }} + {% endif %} + + {% if networkalias.computername_url != '' %} + {{ networkalias.computername }} + {% else %} + {{ networkalias.computername }} + {% endif %} + {{ networkalias.comment }}
+{% endif %} + +{% if data.show == 'networknames' %} + + + + + + + + + + {% for key,networkalias in data.networkalias %} + + + + + + {% endfor %} + +
{{ translation.name }}{{ translation.domain }}{{ translation.entity }}
+ {% if networkalias.url != '' %} + {{ networkalias.name }} + {% else %} + {{ networkalias.name }} + {% endif %} + + {% if networkalias.domain_url != '' %} + {{ networkalias.domain }} + {% else %} + {{ networkalias.domain }} + {% endif %} + + {% if networkalias.entity_url != '' %} + {{ networkalias.entity }} + {% else %} + {{ networkalias.entity }} + {% endif %} +
+{% endif %} + +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/plans.html.twig b/src/v1/Views/subitem/plans.html.twig new file mode 100644 index 0000000000..790c64794b --- /dev/null +++ b/src/v1/Views/subitem/plans.html.twig @@ -0,0 +1,20 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + +
+ +
+
+
+ {% for item in data.fields %} + {% if item.name != 'comment' %} + {{ include('fields.html.twig') }} + {% endif %} + {% endfor %} +
+
+
+ +
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/plugs.html.twig b/src/v1/Views/subitem/plugs.html.twig new file mode 100644 index 0000000000..5a46c4c7db --- /dev/null +++ b/src/v1/Views/subitem/plugs.html.twig @@ -0,0 +1,27 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + + + + + {% for key,plug in data.plugs %} + + + + + {% endfor %} + +
{{ translation.name }}{{ translation.number }}
+ {% if plug.url != '' %} + {{ plug.name }} + {% else %} + {{ plug.name }} + {% endif %} + {{ plug.number_plugs }}
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/projects.html.twig b/src/v1/Views/subitem/projects.html.twig index a2578efd32..e37b221f10 100644 --- a/src/v1/Views/subitem/projects.html.twig +++ b/src/v1/Views/subitem/projects.html.twig @@ -27,7 +27,13 @@ {{ project.status }} {{ project.open_date }} {{ project.last_update }} - {{ project.entity }} + + {% if project.entity_url != '' %} + {{ project.entity }} + {% else %} + {{ project.entity }} + {% endif %} + {% if project.priority is iterable %} + {% if data.show == 'tickets' %} + {{ translation.projects }} + {{ translation.projecttasks }} + {% else %} {{ translation.name }} + {% endif %} {{ translation.type }} {{ translation.status }} {{ translation.percent_done }} @@ -18,6 +23,15 @@ {% for key,projecttask in data.projecttasks %} + {% if data.show == 'tickets' %} + + {% if projecttask.project_url != '' %} + {{ projecttask.project }} + {% else %} + {{ projecttask.project }} + {% endif %} + + {% endif %} {% if projecttask.url != '' %} {{ projecttask.name }} @@ -25,7 +39,13 @@ {{ projecttask.name }} {% endif %} - {{ projecttask.type }} + + {% if projecttask.type_url != '' %} + {{ projecttask.type }} + {% else %} + {{ projecttask.type }} + {% endif %} + {{ projecttask.status }} {{ projecttask.percent_done }} {{ projecttask.planned_start_date }} diff --git a/src/v1/Views/subitem/projecttaskteams.html.twig b/src/v1/Views/subitem/projecttaskteams.html.twig new file mode 100644 index 0000000000..ce5c261131 --- /dev/null +++ b/src/v1/Views/subitem/projecttaskteams.html.twig @@ -0,0 +1,27 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + + + + + {% for key,projecttaskteam in data.projecttaskteams %} + + + + + {% endfor %} + +
{{ translation.type }}{{ translation.member }}
{{ projecttaskteam.type }} + {% if projecttaskteam.url != '' %} + {{ projecttaskteam.member }} + {% else %} + {{ projecttaskteam.member }} + {% endif %} +
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/records.html.twig b/src/v1/Views/subitem/records.html.twig index cb4f5aca2a..60834c9bba 100644 --- a/src/v1/Views/subitem/records.html.twig +++ b/src/v1/Views/subitem/records.html.twig @@ -12,7 +12,13 @@
{{ translation.type }} -
{{ record.type }}
+
+ {% if record.type_url != '' %} + {{ record.type }} + {% else %} + {{ record.type }} + {% endif %} +
diff --git a/src/v1/Views/subitem/reservations.html.twig b/src/v1/Views/subitem/reservations.html.twig new file mode 100644 index 0000000000..ea71e49c75 --- /dev/null +++ b/src/v1/Views/subitem/reservations.html.twig @@ -0,0 +1,116 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + +

{{ translation.current_reservations }}

+{% if data.reservations|length > 0 %} + + + + + + {% if data.show == 'users' %} + + + {% endif %} + + + + + + {% for key,reservation in data.reservations %} + + + + {% if data.show == 'users' %} + + + {% endif %} + {% if data.show == 'users' %} + + {% else %} + + {% endif %} + + + {% endfor %} + +
{{ translation.start_date }}{{ translation.end_date }}{{ translation.item }}{{ translation.entity }}{{ translation.by }}{{ translation.comment }}
{{ reservation.begin }}{{ reservation.end }} + {% if reservation.item_url != '' %} + {{ reservation.item_name }} + {% else %} + {{ reservation.item_name }} + {% endif %} + + {% if reservation.entity_url != '' %} + {{ reservation.entity }} + {% else %} + {{ reservation.entity }} + {% endif %} + {{ reservation.user }} + {% if reservation.user_url != '' %} + {{ reservation.user }} + {% else %} + {{ reservation.user }} + {% endif %} + {{ reservation.comment }}
+{% else %} +

{{ translation.no_reservations }}

+{% endif %} + +

{{ translation.past_reservations }}

+{% if data.reservations_old|length > 0 %} + + + + + + {% if data.show == 'users' %} + + + {% endif %} + + + + + + {% for key,reservation_old in data.reservations_old %} + + + + {% if data.show == 'users' %} + + + {% endif %} + {% if data.show == 'users' %} + + {% else %} + + {% endif %} + + + {% endfor %} + +
{{ translation.start_date }}{{ translation.end_date }}{{ translation.item }}{{ translation.entity }}{{ translation.by }}{{ translation.comment }}
{{ reservation_old.begin }}{{ reservation_old.end }} + {% if reservation_old.item_url != '' %} + {{ reservation_old.item_name }} + {% else %} + {{ reservation_old.item_name }} + {% endif %} + + {% if reservation_old.entity_url != '' %} + {{ reservation_old.entity }} + {% else %} + {{ reservation_old.entity }} + {% endif %} + {{ reservation_old.user }} + {% if reservation_old.user_url != '' %} + {{ reservation_old.user }} + {% else %} + {{ reservation_old.user }} + {% endif %} + {{ reservation_old.comment }}
+{% else %} +

{{ translation.no_reservations }}

+{% endif %} + +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/sections.html.twig b/src/v1/Views/subitem/sections.html.twig index bd00398676..02f85dd25c 100644 --- a/src/v1/Views/subitem/sections.html.twig +++ b/src/v1/Views/subitem/sections.html.twig @@ -30,7 +30,7 @@ {% for section in data.sections %} {{ section.name }} - {{ section.questions_count }} + {{ section.questions_count }} {% endfor %} diff --git a/src/v1/Views/subitem/slaola.html.twig b/src/v1/Views/subitem/slaola.html.twig new file mode 100644 index 0000000000..53ceb5104d --- /dev/null +++ b/src/v1/Views/subitem/slaola.html.twig @@ -0,0 +1,37 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + + + + + + + {% for key,slaola in data.slaola %} + + + + + + + {% endfor %} + +
{{ translation.name }}{{ translation.type }}{{ translation.max_duration }}{{ translation.calendar }}
+ {% if slaola.url != '' %} + {{ slaola.name }} + {% else %} + {{ slaola.name }} + {% endif %} + {{ slaola.type.title }}{{ slaola.max_duration }} + {% if slaola.calendar_url != '' %} + {{ slaola.calendar_name }} + {% else %} + {{ slaola.calendar_name }} + {% endif %} +
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/softwarecategories.html.twig b/src/v1/Views/subitem/softwarecategories.html.twig new file mode 100644 index 0000000000..e9c5bc0bbf --- /dev/null +++ b/src/v1/Views/subitem/softwarecategories.html.twig @@ -0,0 +1,27 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + + + + + {% for key,softwarecategory in data.softwarecategories %} + + + + + {% endfor %} + +
{{ translation.name }}{{ translation.comment }}
+ {% if softwarecategory.url != '' %} + {{ softwarecategory.name }} + {% else %} + {{ softwarecategory.name }} + {% endif %} + {{ softwarecategory.comment }}
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/softwareinstall.html.twig b/src/v1/Views/subitem/softwareinstall.html.twig new file mode 100644 index 0000000000..8e439819de --- /dev/null +++ b/src/v1/Views/subitem/softwareinstall.html.twig @@ -0,0 +1,81 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + + + + + + + + + + + + + + {% for key,softwareinstall in data.softwareinstall %} + + + + + + + + + + + + + + {% endfor %} + +
{{ translation.version }}{{ translation.type }}{{ translation.nom }}{{ translation.serial }}{{ translation.otherserial }}{{ translation.location }}{{ translation.status }}{{ translation.group }}{{ translation.user }}{{ translation.licences }}{{ translation.date_install }}
+ {% if softwareinstall.version_url != '' %} + {{ softwareinstall.version }} + {% else %} + {{ softwareinstall.version }} + {% endif %} + {{ softwareinstall.type }} + {% if softwareinstall.nom_url != '' %} + {{ softwareinstall.nom }} + {% else %} + {{ softwareinstall.nom }} + {% endif %} + {{ softwareinstall.serial }}{{ softwareinstall.otherserial }} + {% if softwareinstall.location_url != '' %} + {{ softwareinstall.location }} + {% else %} + {{ softwareinstall.location }} + {% endif %} + + {% if softwareinstall.status_url != '' %} + {{ softwareinstall.status }} + {% else %} + {{ softwareinstall.status }} + {% endif %} + + {% if softwareinstall.group_url != '' %} + {{ softwareinstall.group }} + {% else %} + {{ softwareinstall.group }} + {% endif %} + + {% if softwareinstall.user_url != '' %} + {{ softwareinstall.user }} + {% else %} + {{ softwareinstall.user }} + {% endif %} + + {% if softwareinstall.licences_url != '' %} + {{ softwareinstall.licences }}{{ softwareinstall.licences_serial_type }} + {% else %} + {{ softwareinstall.licences }}{{ softwareinstall.licences_serial_type }} + {% endif %} + {{ softwareinstall.date_install }}
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/softwarelicenses.html.twig b/src/v1/Views/subitem/softwarelicenses.html.twig index 40e54e674a..23ff29d533 100644 --- a/src/v1/Views/subitem/softwarelicenses.html.twig +++ b/src/v1/Views/subitem/softwarelicenses.html.twig @@ -19,7 +19,13 @@ {{ softwarelicense.name }} {% endif %} - {{ softwarelicense.entity }} + + {% if softwarelicense.entity_url != '' %} + {{ softwarelicense.entity }} + {% else %} + {{ softwarelicense.entity }} + {% endif %} + {{ softwarelicense.comment }} {% endfor %} diff --git a/src/v1/Views/subitem/softwarelicensetypes.html.twig b/src/v1/Views/subitem/softwarelicensetypes.html.twig new file mode 100644 index 0000000000..3b7c67d742 --- /dev/null +++ b/src/v1/Views/subitem/softwarelicensetypes.html.twig @@ -0,0 +1,35 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + + + + + + {% for key,licensetype in data.licensetypes %} + + + + + + {% endfor %} + +
{{ translation.name }}{{ translation.entity }}{{ translation.comment }}
+ {% if licensetype.url != '' %} + {{ licensetype.name }} + {% else %} + {{ licensetype.name }} + {% endif %} + + {% if licensetype.entity_url != '' %} + {{ licensetype.entity }} + {% else %} + {{ licensetype.entity }} + {% endif %} + {{ licensetype.comment }}
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/softwares.html.twig b/src/v1/Views/subitem/softwares.html.twig index 25b7ec3cc6..2bca1ddfe2 100644 --- a/src/v1/Views/subitem/softwares.html.twig +++ b/src/v1/Views/subitem/softwares.html.twig @@ -7,51 +7,63 @@ {{ translation.antivirus }} + {{ translation.manufacturer }} {{ translation.antivirus_version }} - {{ translation.publisher }} + {{ translation.signature }} {{ translation.is_dynamic }} {{ translation.is_active }} {{ translation.is_uptodate }} - {{ translation.signature }} {% for antivirus in data.antiviruses|sort((a, b) => a.antivirus.name|lower <=> b.antivirus.name|lower) %} - {{ antivirus.name }} + + {% if antivirus.antivirus_url != '' %} + {{ antivirus.name }} + {% else %} + {{ antivirus.name }} + {% endif %} + + + {% if antivirus.manufacturer_url != '' %} + {{ antivirus.manufacturer }} + {% else %} + {{ antivirus.manufacturer }} + {% endif %} + {{ antivirus.version }} - {{ antivirus.publisher }} + {{ antivirus.signature }} {% if antivirus.is_dynamic %} - Yes + {{ antivirus.is_dynamic_val }} {% else %} - No + {{ antivirus.is_dynamic_val }} {% endif %} {% if antivirus.is_active %} - Yes + {{ antivirus.is_active_val }} {% else %} - No + {{ antivirus.is_active_val }} {% endif %} {% if not antivirus.is_uptodate %} - Yes + {{ antivirus.is_uptodate_val }} {% else %} - No + {{ antivirus.is_uptodate_val }} {% endif %} - {{ antivirus.signature }} {% endfor %} @@ -68,8 +80,20 @@ {% for softwareversion in data.softwares|sort((a, b) => a.software.name|lower <=> b.software.name|lower) %} - {{ softwareversion.software.name }} - {{ softwareversion.name }} + + {% if softwareversion.software.url != '' %} + {{ softwareversion.software.name }} + {% else %} + {{ softwareversion.software.name }} + {% endif %} + + + {% if softwareversion.url != '' %} + {{ softwareversion.name }} + {% else %} + {{ softwareversion.name }} + {% endif %} + {% endfor %} diff --git a/src/v1/Views/subitem/states.html.twig b/src/v1/Views/subitem/states.html.twig index 456067a57f..dd0f33fa41 100644 --- a/src/v1/Views/subitem/states.html.twig +++ b/src/v1/Views/subitem/states.html.twig @@ -35,7 +35,13 @@ {{ state.name }} {% endif %} - {{ state.entity }} + + {% if state.entity_url != '' %} + {{ state.entity }} + {% else %} + {{ state.entity }} + {% endif %} + {% if state.is_visible_computer %} diff --git a/src/v1/Views/subitem/suppliercontacts.html.twig b/src/v1/Views/subitem/suppliercontacts.html.twig index f32b84adcf..27b79b17ce 100644 --- a/src/v1/Views/subitem/suppliercontacts.html.twig +++ b/src/v1/Views/subitem/suppliercontacts.html.twig @@ -24,7 +24,13 @@ {{ contact.name }} {% endif %} - {{ contact.entity }} + + {% if contact.entity_url != '' %} + {{ contact.entity }} + {% else %} + {{ contact.entity }} + {% endif %} + {{ contact.phone }} {{ contact.phone2 }} {{ contact.mobile }} @@ -34,7 +40,13 @@ {{ contact.email }} {% endif %} - {{ contact.type }} + + {% if contact.type_url != '' %} + {{ contact.type }} + {% else %} + {{ contact.type }} + {% endif %} + {% endfor %} diff --git a/src/v1/Views/subitem/suppliercontracts.html.twig b/src/v1/Views/subitem/suppliercontracts.html.twig index 23ad6c06c3..16cb978932 100644 --- a/src/v1/Views/subitem/suppliercontracts.html.twig +++ b/src/v1/Views/subitem/suppliercontracts.html.twig @@ -22,9 +22,21 @@ {{ contract.name }} {% endif %} - {{ contract.entity }} + + {% if contract.entity_url != '' %} + {{ contract.entity }} + {% else %} + {{ contract.entity }} + {% endif %} + {{ contract.number }} - {{ contract.type }} + + {% if contract.contracttype_url != '' %} + {{ contract.type }} + {% else %} + {{ contract.type }} + {% endif %} + {% for supplier in contract.suppliers %}

{{ supplier.name }}

diff --git a/src/v1/Views/subitem/suppliers.html.twig b/src/v1/Views/subitem/suppliers.html.twig index 1fae3cf309..eab8b0c067 100644 --- a/src/v1/Views/subitem/suppliers.html.twig +++ b/src/v1/Views/subitem/suppliers.html.twig @@ -22,8 +22,20 @@ {{ supplier.name }} {% endif %} - {{ supplier.entity }} - {{ supplier.type }} + + {% if supplier.entity_url != '' %} + {{ supplier.entity }} + {% else %} + {{ supplier.entity }} + {% endif %} + + + {% if supplier.type_url != '' %} + {{ supplier.type }} + {% else %} + {{ supplier.type }} + {% endif %} + {{ supplier.phone }} {{ supplier.fax }} diff --git a/src/v1/Views/subitem/timeranges.html.twig b/src/v1/Views/subitem/timeranges.html.twig new file mode 100644 index 0000000000..4da05e245d --- /dev/null +++ b/src/v1/Views/subitem/timeranges.html.twig @@ -0,0 +1,23 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + + + + + + {% for key,timerange in data.timeranges %} + + + + + + {% endfor %} + +
{{ translation.name }}{{ translation.begin }}{{ translation.end }}
{{ timerange.name }}{{ timerange.begin }}{{ timerange.end }}
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/users.html.twig b/src/v1/Views/subitem/users.html.twig index dbb858457f..f2a49494fc 100644 --- a/src/v1/Views/subitem/users.html.twig +++ b/src/v1/Views/subitem/users.html.twig @@ -1,69 +1,118 @@ {{ include('header.html.twig') }} {{ include('headerForm.html.twig') }} - - - - - - - - - - - - {% for user in data.users|sort((a, b) => a.user.name|lower <=> b.user.name|lower) %} +{% if data.show == 'groups' %} +
{{ translation.name }}{{ translation.auto }}{{ translation.manager }}{{ translation.userdelegate }}{{ translation.active }}
+ - + + + + + + + + {% for user in data.users|sort((a, b) => a.user.name|lower <=> b.user.name|lower) %} + + + {% if user.auto %} + - {% if user.auto %} - - {% if user.is_manager %} - - {% if user.is_userdelegate %} - - {% if user.is_active %} - - - {% endfor %} - -
- {% if user.url != '' %} - {{ user.name }} + {{ translation.name }}{{ translation.auto }}{{ translation.manager }}{{ translation.userdelegate }}{{ translation.active }}
+ {% if user.url != '' %} + {{ user.name }} + {% else %} + {{ user.name }} + {% endif %} + + + {{ user.auto_val }} {% else %} - {{ user.name }} + + + {{ user.auto_val }} {% endif %} - - - Yes - {% else %} - - - No - {% endif %} - - - Yes - {% else %} - - - No - {% endif %} - - - Yes - {% else %} - - - No - {% endif %} - - - Yes - {% else %} - - - No - {% endif %} -
+ + {% if user.is_manager %} + + + {{ user.is_manager_val }} + {% else %} + + + {{ user.is_manager_val }} + {% endif %} + + {% if user.is_userdelegate %} + + + {{ user.is_userdelegate_val }} + {% else %} + + + {{ user.is_userdelegate_val }} + {% endif %} + + {% if user.is_active %} + + + {{ user.is_active_val }} + {% else %} + + + {{ user.is_active_val }} + {% endif %} + + + {% endfor %} + + +{% endif %} + +{% if data.show == 'profiles' %} + {% for key,item in data.users %} +

{{ item.name }}

+ + + + + + + + + + + {% for user in item.users %} + + + {% if user.is_dynamic %} + + {% if user.is_recursive %} + + + {% endfor %} + +
{{ translation.name }}{{ translation.is_dynamic }}{{ translation.is_recursive }}
+ {% if user.url != '' %} + {{ user.name }} + {% else %} + {{ user.name }} + {% endif %} + + + {% else %} + + + {% endif %} + {{ user.is_dynamic_val }} + + + {% else %} + + + {% endif %} + {{ user.is_recursive_val }} +
+ {% endfor %} +{% endif %} {{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/versions.html.twig b/src/v1/Views/subitem/versions.html.twig index 9cbe33616a..1cbe10a8fb 100644 --- a/src/v1/Views/subitem/versions.html.twig +++ b/src/v1/Views/subitem/versions.html.twig @@ -22,8 +22,20 @@ {{ version.name }} {% endif %} - {{ version.status }} - {{ version.os }} + + {% if version.status_url != '' %} + {{ version.status }} + {% else %} + {{ version.status }} + {% endif %} + + + {% if version.os_url != '' %} + {{ version.os }} + {% else %} + {{ version.os }} + {% endif %} + {{ version.nb_install }} {{ version.comment }} diff --git a/src/v1/Views/subitem/virtualization.html.twig b/src/v1/Views/subitem/virtualization.html.twig index 3474beb180..f6cb0ad4f3 100644 --- a/src/v1/Views/subitem/virtualization.html.twig +++ b/src/v1/Views/subitem/virtualization.html.twig @@ -14,30 +14,54 @@
{{ translation.auto }}
- {% if virtualmachine.auto == 1 %} - {{ virtualmachine.auto_val }} - {% else %} - {{ virtualmachine.auto_val }} - {% endif %} + {% if virtualmachine.auto == 1 %} +
+ + {{ virtualmachine.auto_val }} +
+ {% else %} +
+ + {{ virtualmachine.auto_val }} +
+ {% endif %}
- {{ translation.virtualmachinesystem }} -
{{ virtualmachine.virtualmachinesystem }}
+ {{ translation.virtualmachinemodel }} +
+ {% if virtualmachine.virtualmachinesystem_url != '' %} + {{ virtualmachine.virtualmachinesystem }} + {% else %} + {{ virtualmachine.virtualmachinesystem }} + {% endif %} +
- {{ translation.virtualmachinemodel }} -
{{ virtualmachine.virtualmachinemodel }}
+ {{ translation.virtualmachinesystem }} +
+ {% if virtualmachine.virtualmachinemodel_url != '' %} + {{ virtualmachine.virtualmachinemodel }} + {% else %} + {{ virtualmachine.virtualmachinemodel }} + {% endif %} +
{{ translation.virtualmachinestate }} -
{{ virtualmachine.virtualmachinestate }}
+
+ {% if virtualmachine.virtualmachinestate_url != '' %} + {{ virtualmachine.virtualmachinestate }} + {% else %} + {{ virtualmachine.virtualmachinestate }} + {% endif %} +
diff --git a/src/v1/Views/subitem/vlans.html.twig b/src/v1/Views/subitem/vlans.html.twig new file mode 100644 index 0000000000..bdac212820 --- /dev/null +++ b/src/v1/Views/subitem/vlans.html.twig @@ -0,0 +1,35 @@ +{{ include('header.html.twig') }} +{{ include('headerForm.html.twig') }} + + + + + + + + + + + {% for key,vlan in data.vlans %} + + + + + + {% endfor %} + +
{{ translation.name }}{{ translation.entity }}{{ translation.tagid }}
+ {% if vlan.url != '' %} + {{ vlan.name }} + {% else %} + {{ vlan.name }} + {% endif %} + + {% if vlan.entity_url != '' %} + {{ vlan.entity }} + {% else %} + {{ vlan.entity }} + {% endif %} + {{ vlan.tagid }}
+ +{{ include('footer.html.twig') }} diff --git a/src/v1/Views/subitem/volumes.html.twig b/src/v1/Views/subitem/volumes.html.twig index 89dbdf27fb..420fca628a 100644 --- a/src/v1/Views/subitem/volumes.html.twig +++ b/src/v1/Views/subitem/volumes.html.twig @@ -13,11 +13,17 @@
{{ translation.auto }}
- {% if volume.auto == 1 %} - {{ volume.auto_val }} - {% else %} - {{ volume.auto_val }} - {% endif %} + {% if volume.auto == 1 %} +
+ + {{ volume.auto_val }} +
+ {% else %} +
+ + {{ volume.auto_val }} +
+ {% endif %}
@@ -36,7 +42,13 @@
{{ translation.filesystem }} -
{{ volume.filesystem }}
+
+ {% if volume.filesystem_url != '' %} + {{ volume.filesystem }} + {% else %} + {{ volume.filesystem }} + {% endif %} +
diff --git a/tests/integration/v1/Controllers/NotificationTicketTest.php b/tests/integration/v1/Controllers/NotificationTicketTest.php index abb42b57e7..5094481d90 100644 --- a/tests/integration/v1/Controllers/NotificationTicketTest.php +++ b/tests/integration/v1/Controllers/NotificationTicketTest.php @@ -19,6 +19,7 @@ #[UsesClass('\App\Models\Definitions\Entity')] #[UsesClass('\App\Models\Definitions\Followup')] #[UsesClass('\App\Models\Definitions\Group')] +#[UsesClass('\App\Models\Definitions\ItemTicket')] #[UsesClass('\App\Models\Definitions\Knowbaseitem')] #[UsesClass('\App\Models\Definitions\Knowbaseitemcategory')] #[UsesClass('\App\Models\Definitions\Location')] @@ -26,11 +27,13 @@ #[UsesClass('\App\Models\Definitions\Problem')] #[UsesClass('\App\Models\Definitions\Problemtemplate')] #[UsesClass('\App\Models\Definitions\Profile')] +#[UsesClass('\App\Models\Definitions\ProjecttaskTicket')] #[UsesClass('\App\Models\Definitions\Solution')] #[UsesClass('\App\Models\Definitions\Ticket')] #[UsesClass('\App\Models\Definitions\User')] #[UsesClass('\App\Models\Definitions\ProfileUser')] #[UsesClass('\App\Models\Definitions\Ticketcost')] +#[UsesClass('\App\Models\Definitions\Ticketvalidation')] #[UsesClass('\App\Models\Definitions\Usercategory')] #[UsesClass('\App\Models\Definitions\Usertitle')] #[UsesClass('\App\Models\Entity')] @@ -328,6 +331,39 @@ public static function setUpBeforeClass(): void $ticket->save(); } + public static function tearDownAfterClass(): void + { + $items = \App\Models\Location::get(); + foreach ($items as $item) + { + $item->forceDelete(); + } + + $items = \App\Models\User::where('id', '>', 1)->get(); + foreach ($items as $item) + { + $item->forceDelete(); + } + + $items = \App\Models\Group::get(); + foreach ($items as $item) + { + $item->forceDelete(); + } + + $items = \App\Models\Category::get(); + foreach ($items as $item) + { + $item->forceDelete(); + } + + $items = \App\Models\Ticket::get(); + foreach ($items as $item) + { + $item->forceDelete(); + } + } + public function testGenerateDataForNotification(): void { $ticket = \App\Models\Ticket::find(self::$ticketId); diff --git a/tests/unit/v1/Controllers/TicketTest.php b/tests/unit/v1/Controllers/TicketTest.php index 2a2911bc89..c934cabffc 100644 --- a/tests/unit/v1/Controllers/TicketTest.php +++ b/tests/unit/v1/Controllers/TicketTest.php @@ -19,6 +19,7 @@ #[UsesClass('\App\Models\Definitions\Entity')] #[UsesClass('\App\Models\Definitions\Followup')] #[UsesClass('\App\Models\Definitions\Group')] +#[UsesClass('\App\Models\Definitions\ItemTicket')] #[UsesClass('\App\Models\Definitions\Knowbaseitem')] #[UsesClass('\App\Models\Definitions\Location')] #[UsesClass('\App\Models\Definitions\Notepad')] @@ -26,9 +27,11 @@ #[UsesClass('\App\Models\Definitions\Problem')] #[UsesClass('\App\Models\Definitions\Profile')] #[UsesClass('\App\Models\Definitions\ProfileUser')] +#[UsesClass('\App\Models\Definitions\ProjecttaskTicket')] #[UsesClass('\App\Models\Definitions\Solution')] #[UsesClass('\App\Models\Definitions\Ticket')] #[UsesClass('\App\Models\Definitions\Ticketcost')] +#[UsesClass('\App\Models\Definitions\Ticketvalidation')] #[UsesClass('\App\Models\Definitions\User')] #[UsesClass('\App\Models\Definitions\Usercategory')] #[UsesClass('\App\Models\Definitions\Usertitle')]