Commit 1f3f30dd authored by Raph El's avatar Raph El
Browse files

Modif scope

parent 42ae1aef
......@@ -102,7 +102,7 @@ function getCommunexionLabel(){
var level=0;
var nameCommunexion="";
$.each(myScopes.communexion, function(e, v){
if(v.type == "city")
if(v.type == "cities")
nameCommunexion=v.name;
});
$(".communexion-btn-label").html(nameCommunexion);
......@@ -416,7 +416,7 @@ function scopeObject(values){
objToPush={
id:values.city,
name:((notNull(values.allCP) && values.allCP == false) ? values.name : values.cityName ) ,
type:"city",
type:"cities",
active:((notNull(values.allCP) && values.allCP == false) ? false : true ) ,
countryCode:values.country,
allCP:values.allCP,
......@@ -430,7 +430,7 @@ function scopeObject(values){
objToPush={
id:values.city,
name:values.cityName + " ( " +values.cp + " ) ",
type:"city",
type:"cities",
active:true,
countryCode:values.country,
allCP:values.allCP,
......
......@@ -3686,6 +3686,7 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
if(!empty($city)){
$newS["id"] = $keyCP;
$newS["type"] = City::COLLECTION;
$newS["country"] = $city["country"];
$newML[$newS["id"].$newS["type"]] = $newS;
}
......@@ -3760,14 +3761,10 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
if(empty($names[$value["level2"]])){
$nameLevel2 = Zone::getById($value["level2"], array("name"));
$names[(String)$nameLevel2["_id"]] = $nameLevel2["name"];
// echo "heres<br/>";
}
$set = array("level2Name" => $names[$value["level2"]]);
// var_dump($set);
// echo "<br/>-------------<br/>";
$res = PHDB::update(Zone::COLLECTION,
array("_id"=>new MongoId($key)),
array('$set' => $set)
......@@ -3794,14 +3791,10 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
if(empty($names[$value["level3"]])){
$nameLevel3 = Zone::getById($value["level3"], array("name"));
$names[(String)$nameLevel3["_id"]] = $nameLevel3["name"];
// echo "heres<br/>";
}
$set = array("level3Name" => $names[$value["level3"]]);
// var_dump($set);
// echo "<br/>-------------<br/>";
$res = PHDB::update(Zone::COLLECTION,
array("_id"=>new MongoId($key)),
array('$set' => $set)
......@@ -4009,7 +4002,7 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
}
}
$setNew["scope"] = $new["scope"] ;
var_dump($setNew);
//var_dump($setNew);
$setNew["scope"]["localities"] = $loc;
echo "<br/>";
......@@ -4029,6 +4022,70 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
echo "here";
}
}
public function actionUpdateScopeNews(){
ini_set('memory_limit', '-1');
$nbelement = 0 ;
$nbelementtotal = 0 ;
$where = array("scope.localities" => array('$exists' => 1), "modifiedByBatch.UpdateScopeNews" => array('$exists' => 0));
$fields = array("scope", "modifiedByBatch");
$news = PHDB::find(News::COLLECTION, $where, $fields);
foreach ($news as $key => $value) {
//echo $key." : ".$value["name"]."<br/>";
if(!empty($value["scope"]["localities"])){
$newML = array();
foreach ($value["scope"]["localities"] as $keyCP => $scope) {
$newS = $scope;
if($newS["parentType"] == City::COLLECTION || $newS["parentType"] == City::CONTROLLER){
$city = PHDB::findOne(City::COLLECTION, array("postalCodes.postalCode" =>$newS["name"]), array("country"));
if(!empty($city)){
$newS["cp"] = $newS["name"];
$newS["country"] = $city["country"];
$newML[$newS["cp"].$newS["country"].$newS["type"]] = $newS;
}
}else if(!empty($newS["level"])){
$zone = PHDB::findOneById(Zone::COLLECTION, $keyCP,array("countryCode") );
if(!empty($zone)){
$newS["id"] = $keyCP;
$newS["country"] = $zone["countryCode"];
$newML[$newS["id"].$newS["type"]] = $newS;
}
}else{
$city = PHDB::findOneById(City::COLLECTION, $keyCP,array("country") );
if(!empty($city)){
$newS["id"] = $keyCP;
$newS["country"] = $city["country"];
$newML[$newS["id"].$newS["type"]] = $newS;
}
}
}
$set[] =$newML ;
$value["modifiedByBatch"][] = array("updateMultiScope" => new MongoDate(time()));
$set =array("multiscopes" => $newML,
"modifiedByBatch" => $value["modifiedByBatch"]);
$res = PHDB::update(Person::COLLECTION,
array("_id"=>new MongoId($key)),
array('$set' => $set)
);
$nbelement++;
}
}
echo $nbelement." multiscopes mis a jours / ";
}
}
......@@ -166,7 +166,10 @@
<div id="typeAbout" class="col-md-8 col-sm-8 col-xs-12 valueAbout padding-10">
<span class="visible-xs pull-left margin-right-5"><i class="fa fa-angle-right"></i> <?php echo Yii::t("common", "Type"); ?> :</span>
<?php
<?php
// var_dump($typesList);
// echo "<br/>";
// var_dump($element);
if(@$typesList && @$element["type"])
$showType=Yii::t( "category",$typesList[$element["type"]]);
else if (@$element["type"])
......
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