Skip to content
72 changes: 44 additions & 28 deletions api/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -901,12 +901,12 @@ paths:
security:
- api_key: []
- user_id: []
/project:
get:
summary: Metadata about all projects
/project:
get:
summary: Metadata about all projects (with Maitrise entries)
tags:
- "Project"
description: 'Returns the metadata about projects in the system, but not members of the projects.'
description: 'Returns the metadata about projects in the system, including Maitrise (type, bureau, email) entries for each project.'
produces:
- "application/json"
operationId: "GetProjectList"
Expand All @@ -917,8 +917,8 @@ paths:
description: "successful operation"
schema:
type: "array"
items:
$ref: "#/definitions/Project"
items:
$ref: "#/definitions/Project"
security:
- api_key: []
- user_id: []
Expand Down Expand Up @@ -1063,7 +1063,7 @@ paths:
security:
- api_key: []
- user_id: []
definitions:
definitions:
Audit:
type: "object"
properties:
Expand Down Expand Up @@ -1617,27 +1617,43 @@ definitions:
Disabled:
type: boolean
format: "User has been disabled"
Project:
type: "object"
properties:
ProjectID:
type: "integer"
format: "keyValue"
ProjectName:
type: "string"
format: "Freeform text"
ProjectSponsor:
type: "string"
format: "Freeform text"
ProjectStartDate:
type: "string"
format: "Datestamp"
ProjectEndDate:
type: "string"
format: "Datestamp"
ProjectActualEndDate:
type: "string"
format: "Datestamp"
Project:
type: "object"
properties:
ProjectID:
type: "integer"
format: "keyValue"
ProjectName:
type: "string"
format: "Freeform text"
ProjectSponsor:
type: "string"
format: "Freeform text"
ProjectStartDate:
type: "string"
format: "Datestamp"
ProjectEndDate:
type: "string"
format: "Datestamp"
ProjectActualEndDate:
type: "string"
format: "Datestamp"
Maitrise:
type: "array"
items:
$ref: "#/definitions/ProjectMaitrise"
ProjectMaitrise:
type: "object"
properties:
MaitriseName:
type: "string"
format: "Freeform text"
BureauName:
type: "string"
format: "Freeform text"
BureauEmail:
type: "string"
format: "EmailAddress"
PowerPort:
type: "object"
properties:
Expand Down
44 changes: 40 additions & 4 deletions api/v1/getRoutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -706,11 +706,47 @@
//

$app->get( '/project', function(Request $request, Response $response) {
$r['error']=false;
$r['errorcode']=200;
$r['project']=Projects::getProjectList();
$r['error']=false;
$r['errorcode']=200;

$list = Projects::getProjectList();

// Fetch Maitrise rows for each project
global $dbh;
$st = null;
try{
$st = $dbh->prepare("SELECT mt.MaitriseName, pm.BureauName, pm.BureauEmail
FROM fac_ProjectMaitrise pm
LEFT JOIN fac_MaitriseType mt ON mt.MaitriseTypeID = pm.MaitriseTypeID
WHERE pm.ProjectID = :pid
ORDER BY pm.ProjectMaitriseID ASC");
}catch(Exception $e){
$st = null; // If tables don't exist, just omit maitrise info
}

$projects = array();
foreach($list as $p){
$tmp = array();
foreach($p as $prop=>$val){
$tmp[$prop] = $val;
}
// Attach maitrise info if available
$tmp['Maitrise'] = array();
if($st){
try{
$st->execute(array(':pid'=>$p->ProjectID));
$tmp['Maitrise'] = $st->fetchAll(PDO::FETCH_ASSOC);
}catch(Exception $e){
// ignore errors and leave Maitrise empty
$tmp['Maitrise'] = array();
}
}
$projects[] = $tmp;
}

$r['project'] = $projects;

return $response->withJson( $r, $r['errorcode'] );
return $response->withJson( $r, $r['errorcode'] );
});

//
Expand Down
36 changes: 36 additions & 0 deletions classes/MaitriseType.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/*
OpenDCIM - Feature Project Maitrise Link
Author: Alexandre Oliveira
*/

class MaitriseType {
var $MaitriseTypeID;
var $MaitriseName;

static function GetAll(){
global $dbh;
$stmt=$dbh->prepare("SELECT * FROM fac_MaitriseType ORDER BY MaitriseName ASC;");
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_CLASS,"MaitriseType");
}

static function Insert($name){
global $dbh;
$stmt=$dbh->prepare("INSERT INTO fac_MaitriseType SET MaitriseName=:name;");
return $stmt->execute(array(":name"=>$name));
}

static function Delete($id){
global $dbh;
$stmt=$dbh->prepare("DELETE FROM fac_MaitriseType WHERE MaitriseTypeID=:id;");
return $stmt->execute(array(":id"=>$id));
}

static function Update($id,$name){
global $dbh;
$stmt=$dbh->prepare("UPDATE fac_MaitriseType SET MaitriseName=:name WHERE MaitriseTypeID=:id;");
return $stmt->execute(array(":id"=>intval($id), ":name"=>$name));
}
}
?>
26 changes: 26 additions & 0 deletions create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,32 @@ CREATE TABLE fac_ProjectMembership (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


--
-- Maitrise types and project linkage
--

DROP TABLE IF EXISTS fac_MaitriseType;
CREATE TABLE fac_MaitriseType (
MaitriseTypeID INT AUTO_INCREMENT PRIMARY KEY,
MaitriseName VARCHAR(100) UNIQUE NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO fac_MaitriseType (MaitriseName)
VALUES
('CUSTOMER'),
('PROD ES');

DROP TABLE IF EXISTS fac_ProjectMaitrise;
CREATE TABLE fac_ProjectMaitrise (
ProjectMaitriseID INT AUTO_INCREMENT PRIMARY KEY,
ProjectID INT NOT NULL,
MaitriseTypeID INT NOT NULL,
BureauName VARCHAR(100) NOT NULL,
BureauEmail VARCHAR(255) NULL DEFAULT NULL,
KEY (ProjectID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


--
-- Tables for tracking how things leave
--
Expand Down
15 changes: 15 additions & 0 deletions css/inventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,16 @@
padding: 10px;
margin-bottom: 8px;
}

/* Maitrise Types modal spacing */
#maitrisetypesmodal { padding: 10px; }
#maitrisetypesmodal table { border-collapse: separate; border-spacing: 0 8px; }
#maitrisetypesmodal th, #maitrisetypesmodal td { padding: 6px 10px; vertical-align: middle; }
#maitrisetypesmodal input[type="text"],
#maitrisetypesmodal input[type="email"],
#maitrisetypesmodal select { padding: 6px 8px; margin: 4px 6px 4px 0; }
#maitrisetypesmodal button { margin: 4px 6px; }
#maitrisetypesmodal .note { margin-top: 10px; display: block; }
#infopanel fieldset button, #infopanel fieldset input[type=submit], #infopanel fieldset input[type=button],.reports fieldset button, .reports fieldset input[type=submit], .reports fieldset input[type=button] {width: 100%;}
#infopanel legend, .device legend, .reports legend {border: 1px <?php echo $config->ParameterArray['HeaderColor']; ?> solid;background-color: white;}
div.cabinet {
Expand Down Expand Up @@ -1131,6 +1141,11 @@
#pandn.table .custom-combobox a {margin: 0; vertical-align: top; border-left: 0px; border-right: 2px; position: absolute;}
div#pandn.table div[id^="ppn"] { min-width: 200px; }

/* Project Manager: align combobox toggle with input */
#projectid + span.custom-combobox { position: relative; display: inline-block; width: 100%; vertical-align: middle; }
#projectid + span.custom-combobox input { width: calc(100% - 24px) !important; }
#projectid + span.custom-combobox a.custom-combobox-toggle { position: absolute; right: 0; top: 0; bottom: 0; width: 24px; padding: 0; }

#olog > div:first-child { border-bottom: 2px solid black; }
#olog > div > div:first-child { width: 100px; padding-right: 5px; white-space: nowrap; }
#olog > div:first-child > div:first-child { border-right: 0 none; }
Expand Down
25 changes: 25 additions & 0 deletions db-23.04-to-25.01.sql
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,29 @@ ALTER TABLE fac_TemplatePowerPorts ADD COLUMN ConnectorID int(11) DEFAULT NULL A
ALTER TABLE fac_TemplatePowerPorts ADD COLUMN PhaseID int(11) DEFAULT NULL AFTER ConnectorID;
ALTER TABLE fac_TemplatePowerPorts ADD COLUMN VoltageID int(11) DEFAULT NULL AFTER PhaseID;

--
-- Maitrise types and project linkage
--

DROP TABLE IF EXISTS fac_MaitriseType;
CREATE TABLE fac_MaitriseType (
MaitriseTypeID INT AUTO_INCREMENT PRIMARY KEY,
MaitriseName VARCHAR(100) UNIQUE NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO fac_MaitriseType (MaitriseName)
VALUES
('CUSTOMER'),
('PROD ES');

DROP TABLE IF EXISTS fac_ProjectMaitrise;
CREATE TABLE fac_ProjectMaitrise (
ProjectMaitriseID INT AUTO_INCREMENT PRIMARY KEY,
ProjectID INT NOT NULL,
MaitriseTypeID INT NOT NULL,
BureauName VARCHAR(100) NOT NULL,
BureauEmail VARCHAR(255) NULL DEFAULT NULL,
KEY (ProjectID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

UPDATE fac_Config set Value="25.01" WHERE Parameter="Version";
Loading