Commit d622076c authored by Raph El's avatar Raph El
Browse files

Modif CressREunion : Validation + modif form orga

parent 5467d46d
......@@ -97,7 +97,7 @@ adminPanel.views.diff = function(){
title : "Les organisations à modéré",
types : [ "organizations" ],
forced : {
"source.new" : { '$exists' : 0 }
"source.toBeValidated.cressReunion" : { '$exists' : 1 }
},
table : {
name : {
......@@ -118,11 +118,16 @@ adminPanel.views.diff = function(){
secteurEtablissement : {
name : "Secteur d'activité",
class : "col-xs-3 text-center"
},
validated : {
name : "Valider",
class : "col-xs-2 text-center"
}
},
actions : {
update : true,
delete : true
delete : true,
validated : true
}
};
ajaxPost('#content-view-admin', baseUrl+'/costum/default/groupadmin/', data, function(){},"html");
......
......@@ -26,62 +26,67 @@ class ValidateGroupAction extends CAction{
array('$set'=>$query));
$sub = array();
foreach ($elt["links"] as $kL => $vL) {
foreach ($vL as $key => $value) {
if(!empty($value["type"]) && $value["type"] != Person::COLLECTION){
if(!empty($elt["links"])){
foreach ($elt["links"] as $kL => $vL) {
foreach ($vL as $key => $value) {
if(!empty($value["type"]) && $value["type"] != Person::COLLECTION){
$where = array( "_id" => new MongoId($key),
"source.keys" => array('$in' => array(Yii::app()->session["costum"]["slug"] ) ) );
$subElt = PHDB::findOne($value["type"], $where, array("name","source", "links"));
$where = array( "_id" => new MongoId($key),
"source.keys" => array('$in' => array(Yii::app()->session["costum"]["slug"] ) ) );
$subElt = PHDB::findOne($value["type"], $where, array("name","source", "links"));
if(!empty($subElt)){
if($_POST["valid"] == "true"){
if( !empty($subElt["source"]["toBeValidated"]) ) {
unset($subElt["source"]["toBeValidated"][Yii::app()->session["costum"]["slug"]]);
if(count($subElt["source"]["toBeValidated"]) == 0)
unset($subElt["source"]["toBeValidated"]);
if(!empty($subElt)){
if($_POST["valid"] == "true"){
if( !empty($subElt["source"]["toBeValidated"]) ) {
unset($subElt["source"]["toBeValidated"][Yii::app()->session["costum"]["slug"]]);
if(count($subElt["source"]["toBeValidated"]) == 0)
unset($subElt["source"]["toBeValidated"]);
}
}else{
if( empty($subElt["source"]["toBeValidated"]) )
$subElt["source"]["toBeValidated"] = array();
$subElt["source"]["toBeValidated"][Yii::app()->session["costum"]["slug"]] = true ;
}
}else{
if( empty($subElt["source"]["toBeValidated"]) )
$subElt["source"]["toBeValidated"] = array();
$subElt["source"]["toBeValidated"][Yii::app()->session["costum"]["slug"]] = true ;
//$sub[$key] = $subElt;
$querySub=array("source" => $subElt["source"]);
$sub[$key] = PHDB::update( $value["type"],
array("_id" => new MongoId($key)),
array('$set'=>$querySub) );
}
//$sub[$key] = $subElt;
$querySub=array("source" => $subElt["source"]);
$sub[$key] = PHDB::update( $value["type"],
array("_id" => new MongoId($key)),
array('$set'=>$querySub) );
}
}
}
}
$whereCl = array("parent.".$_POST["id"] => array('$exists' => true));
$classifieds = PHDB::find( Classified::COLLECTION, $whereCl, array("name","source", "links"));
//Rest::json($classifieds);
foreach ($classifieds as $key => $valC) {
if($_POST["valid"] == "true"){
if( !empty($valC["source"]["toBeValidated"]) ) {
unset($valC["source"]["toBeValidated"][Yii::app()->session["costum"]["slug"]]);
if(count($valC["source"]["toBeValidated"]) == 0)
unset($valC["source"]["toBeValidated"]);
if(!empty($elt["links"])){
foreach ($classifieds as $key => $valC) {
if($_POST["valid"] == "true"){
if( !empty($valC["source"]["toBeValidated"]) ) {
unset($valC["source"]["toBeValidated"][Yii::app()->session["costum"]["slug"]]);
if(count($valC["source"]["toBeValidated"]) == 0)
unset($valC["source"]["toBeValidated"]);
}
}else{
if( empty($valC["source"]["toBeValidated"]) )
$valC["source"]["toBeValidated"] = array();
$valC["source"]["toBeValidated"][Yii::app()->session["costum"]["slug"]] = true ;
}
}else{
if( empty($valC["source"]["toBeValidated"]) )
$valC["source"]["toBeValidated"] = array();
$valC["source"]["toBeValidated"][Yii::app()->session["costum"]["slug"]] = true ;
//$sub[$key] = $valC;
$querySub=array("source" => $valC["source"]);
$sub[$key] = PHDB::update( Classified::COLLECTION,
array("_id" => new MongoId($key)),
array('$set'=>$querySub) );
}
//$sub[$key] = $valC;
$querySub=array("source" => $valC["source"]);
$sub[$key] = PHDB::update( Classified::COLLECTION,
array("_id" => new MongoId($key)),
array('$set'=>$querySub) );
}
......
......@@ -312,6 +312,7 @@
"typeObj" : {
"organizations" : {
"add" : true,
"toBeValidated" : true,
"dynFormCostum" : {
"beforeBuild" : {
"properties" : {
......@@ -386,6 +387,20 @@
"value" : "",
"label" : "",
"rules" : { }
},
"email" : {
"rules" : {
"required" : true
}
},
"description":{
"order" : 17,
"inputType" : "textarea",
"markdown" : true,
"label" : "Description compléte",
"rules" : {
"maxlength" : 2000
}
}
}
......
......@@ -12,7 +12,7 @@
"favicon" : "/ico/hva/favicon.ico",
"metaImg" : "/images/hva/banner.jpg",
"js" : {
"urls" : [
"urls" : [
"hva.js"
]
},
......
......@@ -384,6 +384,11 @@ class CressReunion {
public static function prepData($params){
if($params["collection"] == Organization::COLLECTION ){
$siretExist = self::siretExist($params["siret"]);
//Rest::json($vaezez);
if( self::siretExist($params["siret"]) === true)
throw new CTKException("Le numéro de SIRET existe déjà.");
if($params["famille"] == "Association")
$params["type"] = Organization::TYPE_NGO;
else if($params["famille"] == "Entreprise de l'ESS")
......@@ -395,9 +400,57 @@ class CressReunion {
$tags = ( !empty($params["tags"]) ? $params["tags"] : array() );
$params["tags"] =self::defaultTags($tags, $params["famille"]);
}
if( !empty($params["source"]) && !empty($params["source"]["toBeValidated"]) ) {
if(!empty($params["source"]["toBeValidated"][Yii::app()->session["costum"]["slug"]]))
unset($params["source"]["toBeValidated"][Yii::app()->session["costum"]["slug"]]);
$validated = true;
if( !empty(Yii::app()->session["costum"]["typeObj"]) &&
( (!empty(Yii::app()->session["costum"]["typeObj"][$params["collection"]]) &&
!empty(Yii::app()->session["costum"]["typeObj"][$params["collection"]]["validatedParent"]) ) ||
(!empty(Yii::app()->session["costum"]["typeObj"][$params["key"]]) &&
!empty(Yii::app()->session["costum"]["typeObj"][$params["key"]]["validatedParent"]) ) ) ) {
if($params["collection"] == Event::COLLECTION && !empty($params["organizer"])) {
$parent = "organizer";
}else{
$parent = "parent";
}
$validated = false;
foreach ($params[$parent] as $key => $value) {
if(!empty($value["type"])){
$eltParent = PHDB::findOneById($value["type"],$key, array('name','source'));
// var_dump( $eltParent);
if( !empty($eltParent) &&
!empty($eltParent["source"]) &&
!empty($eltParent["source"]["toBeValidated"]) &&
!empty($eltParent["source"]["toBeValidated"][Yii::app()->session["costum"]["slug"]]) &&
$eltParent["source"]["toBeValidated"][Yii::app()->session["costum"]["slug"]] )
$validated = true;
}else
$validated = true;
}
}
//var_dump( $validated);
if($validated === true)
$params["source"]["toBeValidated"] = array(Yii::app()->session["costum"]["slug"] => true);
}
return $params;
}
public static function siretExist($siret){
$orgs = PHDB::count( Organization::COLLECTION,
array( "source.key" => "cressReunion",
"siret" => trim($siret) ) );
$res = false ;
if( $orgs > 0 )
$res = true ;
return $res ;
}
public static function removeSourceNotNew(){
$orgs = PHDB::find( Organization::COLLECTION,
array( "source.key" => "cressReunion",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment