Commit 5c23c681 authored by Marty Fabien's avatar Marty Fabien
Browse files

Merge branch 'server_prod'

parents 9dae939e 1ca4ac62
......@@ -44,7 +44,9 @@ module.exports = function (grunt) {
// Fichiers ANC
sHome + 'modules/anc/javascript/**/*.js',
// Fichiers suivi_prod_immo
sHome + 'modules/suivi_prod_immo/**/*.js'
sHome + 'modules/suivi_prod_immo/**/*.js',
// Fichiers patrimoine
sHome + 'modules/patrimoine/**/*.js',
]
},
options: {
......@@ -129,6 +131,8 @@ module.exports = function (grunt) {
'"' + sHome + 'modules/anc/javascript ' + sClosureDepsHome + 'modules/anc/javascript"',
// Fichiers suivi_prod_immo
'"' + sHome + 'modules/suivi_prod_immo ' + sClosureDepsHome + 'modules/suivi_prod_immo"',
// Fichiers patrimoine
'"' + sHome + 'modules/patrimoine ' + sClosureDepsHome + 'modules/patrimoine"',
// Closure library
'"' + sHome + 'conf/node_modules/google-closure-library/closure/goog ' + sClosureDepsHome + 'conf/node_modules/google-closure-library/closure/goog"'
]
......
<?php
/**
* \file Ilots.class.inc
* \class Ilots
*
* \author Fabien Marty <f.marty@urbalyon.org>.
*
* \brief This file contains the Ilots php class
*
* This class defines Rest Api to Vitis Ilots
*
*/
require_once __DIR__ . '/Suivi_prod_immo.class.inc';
require_once 'Ilot.class.inc';
class Ilots extends Suivi_prod_immo {
/**
* @SWG\Definition(
* definition="/ilots",
* allOf={
* @SWG\Schema(ref="#/definitions/ilots")
* }
* )
* * @SWG\Tag(
* name="Ilots",
* description="Ilots about Ilots"
* )
*/
/**
* construct
* @param type $aPath url of the request
* @param type $aValues parameters of the request
* @param type $properties properties
*/
function __construct($aPath, $aValues, $properties) {
$this->aValues = $aValues;
$this->aPath = $aPath;
$this->aProperties = $properties;
$this->oConnection = new Connection($this->aValues, $properties);
}
/**
* @SWG\Get(path="/ilots",
* tags={"Ilots"},
* summary="Get Ilots",
* description="Request to get Ilots",
* operationId="GET",
* produces={"application/xml", "application/json", "application/x-vm-json"},
* @SWG\Parameter(
* name="token",
* in="query",
* description="user token",
* required=true,
* type="string"
* ),
* @SWG\Parameter(
* name="order_by",
* in="query",
* description="list of ordering fields",
* required=false,
* type="string"
* ),
* @SWG\Parameter(
* name="sort_order",
* in="query",
* description="sort_order",
* required=false,
* type="string"
* ),
* @SWG\Parameter(
* name="limit",
* in="query",
* description="number of element",
* required=false,
* type="integer",
* format="int32"
* ),
* @SWG\Parameter(
* name="offset",
* in="query",
* description="index of first element",
* required=false,
* type="string",
* format="int32"
* ),
* @SWG\Parameter(
* name="attributs",
* in="query",
* description="list of attributs",
* required=false,
* type="string"
* ),
* @SWG\Parameter(
* name="filter",
* in="query",
* description="filter results",
* required=false,
* type="string"
* ),
* @SWG\Parameter(
* name="distinct",
* in="query",
* description="delete duplicates",
* required=false,
* type="boolean"
* ),
* @SWG\Response(
* response=200,
* description="traitement Response",
* @SWG\Schema(ref="#/definitions/ilots")
* )
* )
*/
/**
* get Ilots
* @return Ilots
*/
function GET(){
if($this->setRestriction()){
$aReturn = $this->genericGet('prod_immo', "ilot", "id_ilot");
$sMessage = $aReturn['sMessage'];
return $sMessage;
}else{
// si pas d'autorisation, on retourne une liste vide
return json_encode(array("list_count"=>0,"total_row_number"=>0,"status"=>1));
}
}
/**
* set filter restriction for user connected
*/
function setRestriction(){
require $this->sRessourcesFile;
$aParams = array();
$aParams['sSchemaFramework'] = array('value' => 'prod_immo', 'type' => 'schema_name');
$oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getRestrictionUpdate'], $aParams);
if($oPDOresult->rowCount()==1){
// le user existe dans la table de restriction
$oPDOresult = $this->oConnection->oBd->fermeResultat();
$oPDOresult2 = $this->oConnection->oBd->executeWithParams($aSql['getRestrictionUpdateIdOperation'], $aParams);
if($oPDOresult2->rowCount()>0){
// il y a un ou plusieurs ID pour le user, on filtre
$aID=array();
while ($aIdOperation = $this->oConnection->oBd->ligneSuivante($oPDOresult2)){
$aID[] = $aIdOperation["id_operation"];
}
$oPDOresult2 = $this->oConnection->oBd->fermeResultat();
// injection du filtre
if (isset($this->aValues['filter'])){
// il existe déjà un filtre
$aFilter=json_decode($this->aValues['filter'],true);
$aOperators=$aFilter['operators'];
$aOperators[]=array("column"=>"id_operation","compare_operator"=>"IN","value"=>$aID);
$aFilter['operators']=$aOperators;
$this->aValues['filter']=json_encode($aFilter);
}else{
// il n'y a pas de filtre, on le crée
$this->aValues['filter']=json_encode(array('relation'=>'AND','operators'=>array(array("column"=>"id_operation","compare_operator"=>"IN","value"=>$aID))));
}
return true;
}else{
return false;
}
}else{
// le user n'existe pas dans la table de restriction, on affiche rien
$oPDOresult = $this->oConnection->oBd->fermeResultat();
error_log("Aucunes opérations autorisées en saisie, ajouter l'utilisateur dans la table prod_immo.user_restriction .");
return false;
}
}
/**
* @SWG\Post(path="/ilots",
* tags={"Ilots"},
* summary="Add traitement",
* description="Request to add Ilots",
* operationId="POST",
* produces={"application/xml", "application/json"},
* @SWG\Parameter(
* name="token",
* in="query",
* description="user token",
* required=true,
* type="string"
* ),
* @SWG\Response(
* response=200,
* description="traitement Response",
* @SWG\Schema(ref="#/definitions/ilots")
* )
* )
*/
/**
* insert traitement
* @return id of the traitement created
*/
function POST() {
//$this->aValues['create'] = $_SESSION["ses_Login"];
//$this->aValues['create_date'] = date('Y-m-d');
$aReturn = $this->genericPost('prod_immo', 'ilot', 'prod_immo.ilot_id_ilot_seq', 'id_ilot');
return $aReturn['sMessage'];
}
/**
* @SWG\Put(path="/ilots/{id_ilot}",
* tags={"Ilots"},
* summary="update Ilots",
* description="Request to update Ilots",
* operationId="PUT",
* produces={"application/xml", "application/json"},
* @SWG\Parameter(
* name="token",
* in="query",
* description="Traitement token",
* required=true,
* type="string"
* ),
* * @SWG\Parameter(
* name="id_ilot",
* in="path",
* description="id of the Ilots",
* required=true,
* type="integer",
* format = "int32"
* ),
* @SWG\Response(
* response=200,
* description="Poprerties Response",
* @SWG\Schema(ref="#/definitions/ilots")
* )
* )
*/
/**
* update ilots
* @return id of ilots updated or error object if a ilots is not updated
*/
function PUT() {
/*if (empty($this->aValues['maj']))
$this->aValues['maj'] = $_SESSION["ses_Login"];
if (empty($this->aValues['maj_date']))
$this->aValues['maj_date'] = date('Y-m-d');*/
$aReturn = $this->genericPut('prod_immo', 'ilot', 'id_ilot');
return $aReturn['sMessage'];
}
/**
* @SWG\Delete(path="/ilots",
* tags={"Ilots"},
* summary="delete Ilots",
* description="Request to delete Ilots",
* operationId="DELETE",
* produces={"application/xml", "application/json"},
* @SWG\Parameter(
* name="token",
* in="query",
* description="token",
* required=true,
* type="string"
* ),
* * @SWG\Parameter(
* name="idList",
* in="query",
* description="id of the traitement",
* required=true,
* type="string"
* ),
* @SWG\Response(
* response=200,
* description="traitement Response",
* @SWG\Schema(ref="#/definitions/ilots")
* )
* )
*/
/**
* @SWG\Delete(path="/ilots/{id_ilot}",
* tags={"Ilots"},
* summary="delete Ilots",
* description="Request to delete Ilots",
* operationId="DELETE",
* produces={"application/xml", "application/json"},
* @SWG\Parameter(
* name="token",
* in="query",
* description="Traitement token",
* required=true,
* type="string"
* ),
* * @SWG\Parameter(
* name="id_ilot",
* in="path",
* description="id of the Ilots",
* required=true,
* type="integer",
* format = "int32"
* ),
* @SWG\Response(
* response=200,
* description="Poprerties Response",
* @SWG\Schema(ref="#/definitions/ilots")
* )
* )
*/
/**
* delete ilots
* @return id of ilots deleted or error object if a ilots is not deleted
*/
function DELETE() {
$aReturn = $this->genericDelete('prod_immo', 'ilot', 'id_ilot');
return $aReturn['sMessage'];
}
}
<?php
/**
* \file Ilots.class.inc
* \class Ilots
*
* \author Fabien Marty <f.marty@urbalyon.org>.
*
* \brief This file contains the Ilots php class
*
* This class defines Rest Api to Vitis Ilots
*
*/
require_once __DIR__ . '/Suivi_prod_immo.class.inc';
require_once 'Ilot.class.inc';
class Ilots extends Suivi_prod_immo {
/**
* @SWG\Definition(
* definition="/ilots",
* allOf={
* @SWG\Schema(ref="#/definitions/ilots")
* }
* )
* * @SWG\Tag(
* name="Ilots",
* description="Ilots about Ilots"
* )
*/
/**
* construct
* @param type $aPath url of the request
* @param type $aValues parameters of the request
* @param type $properties properties
*/
function __construct($aPath, $aValues, $properties) {
$this->aValues = $aValues;
$this->aPath = $aPath;
$this->aProperties = $properties;
$this->oConnection = new Connection($this->aValues, $properties);
}
/**
* @SWG\Get(path="/ilots",
* tags={"Ilots"},
* summary="Get Ilots",
* description="Request to get Ilots",
* operationId="GET",
* produces={"application/xml", "application/json", "application/x-vm-json"},
* @SWG\Parameter(
* name="token",
* in="query",
* description="user token",
* required=true,
* type="string"
* ),
* @SWG\Parameter(
* name="order_by",
* in="query",
* description="list of ordering fields",
* required=false,
* type="string"
* ),
* @SWG\Parameter(
* name="sort_order",
* in="query",
* description="sort_order",
* required=false,
* type="string"
* ),
* @SWG\Parameter(
* name="limit",
* in="query",
* description="number of element",
* required=false,
* type="integer",
* format="int32"
* ),
* @SWG\Parameter(
* name="offset",
* in="query",
* description="index of first element",
* required=false,
* type="string",
* format="int32"
* ),
* @SWG\Parameter(
* name="attributs",
* in="query",
* description="list of attributs",
* required=false,
* type="string"
* ),
* @SWG\Parameter(
* name="filter",
* in="query",
* description="filter results",
* required=false,
* type="string"
* ),
* @SWG\Parameter(
* name="distinct",
* in="query",
* description="delete duplicates",
* required=false,
* type="boolean"
* ),
* @SWG\Response(
* response=200,
* description="traitement Response",
* @SWG\Schema(ref="#/definitions/ilots")
* )
* )
*/
/**
* get Ilots
* @return Ilots
*/
function GET(){
if($this->setRestriction()){
$aReturn = $this->genericGet('prod_immo', "ilot", "id_ilot");
$sMessage = $aReturn['sMessage'];
return $sMessage;
}else{
// si pas d'autorisation, on retourne une liste vide
return json_encode(array("list_count"=>0,"total_row_number"=>0,"status"=>1));
}
}
/**
* set filter restriction for user connected
*/
function setRestriction(){
require $this->sRessourcesFile;
$aParams = array();
$aParams['sSchemaFramework'] = array('value' => 'prod_immo', 'type' => 'schema_name');
$oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getRestrictionUpdate'], $aParams);
if($oPDOresult->rowCount()==1){
// le user existe dans la table de restriction
$oPDOresult = $this->oConnection->oBd->fermeResultat();
$oPDOresult2 = $this->oConnection->oBd->executeWithParams($aSql['getRestrictionUpdateIdOperation'], $aParams);
if($oPDOresult2->rowCount()>0){
// il y a un ou plusieurs ID pour le user, on filtre
$aID=array();
while ($aIdOperation = $this->oConnection->oBd->ligneSuivante($oPDOresult2)){
$aID[] = $aIdOperation["id_operation"];
}
$oPDOresult2 = $this->oConnection->oBd->fermeResultat();
// injection du filtre
if (isset($this->aValues['filter'])){
// il existe d�j� un filtre
$aFilter=json_decode($this->aValues['filter'],true);
$aOperators=$aFilter['operators'];
$aOperators[]=array("column"=>"id_operation","compare_operator"=>"IN","value"=>$aID);
$aFilter['operators']=$aOperators;
$this->aValues['filter']=json_encode($aFilter);
}else{
// il n'y a pas de filtre, on le cr�e
$this->aValues['filter']=json_encode(array('relation'=>'AND','operators'=>array(array("column"=>"id_operation","compare_operator"=>"IN","value"=>$aID))));
}
return true;
}else{
return false;
}
}else{
// le user n'existe pas dans la table de restriction, on affiche rien
$oPDOresult = $this->oConnection->oBd->fermeResultat();
error_log("Aucunes op�rations autoris�es en saisie, ajouter l'utilisateur dans la table prod_immo.user_restriction .");
return false;
}
}
/**
* @SWG\Post(path="/ilots",
* tags={"Ilots"},
* summary="Add traitement",
* description="Request to add Ilots",
* operationId="POST",
* produces={"application/xml", "application/json"},
* @SWG\Parameter(
* name="token",
* in="query",
* description="user token",
* required=true,
* type="string"
* ),
* @SWG\Response(
* response=200,
* description="traitement Response",
* @SWG\Schema(ref="#/definitions/ilots")
* )
* )
*/
/**
* insert traitement
* @return id of the traitement created
*/
function POST() {
//$this->aValues['create'] = $_SESSION["ses_Login"];
//$this->aValues['create_date'] = date('Y-m-d');
$aReturn = $this->genericPost('prod_immo', 'ilot', 'prod_immo.ilot_id_ilot_seq', 'id_ilot');
return $aReturn['sMessage'];
}
/**
* @SWG\Put(path="/ilots/{id_ilot}",
* tags={"Ilots"},
* summary="update Ilots",
* description="Request to update Ilots",
* operationId="PUT",
* produces={"application/xml", "application/json"},
* @SWG\Parameter(
* name="token",
* in="query",
* description="Traitement token",
* required=true,
* type="string"
* ),
* * @SWG\Parameter(
* name="id_ilot",
* in="path",
* description="id of the Ilots",
* required=true,
* type="integer",
* format = "int32"
* ),
* @SWG\Response(
* response=200,
* description="Poprerties Response",
* @SWG\Schema(ref="#/definitions/ilots")
* )
* )
*/
/**
* update ilots
* @return id of ilots updated or error object if a ilots is not updated
*/
function PUT() {
/*if (empty($this->aValues['maj']))
$this->aValues['maj'] = $_SESSION["ses_Login"];
if (empty($this->aValues['maj_date']))
$this->aValues['maj_date'] = date('Y-m-d');*/
$aReturn = $this->genericPut('prod_immo', 'ilot', 'id_ilot');
return $aReturn['sMessage'];
}
/**
* @SWG\Delete(path="/ilots",