Commit 3d51f3b7 authored by Raph El's avatar Raph El
Browse files

Event tieZone

parent cf3962fb
......@@ -7489,12 +7489,16 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
$events[$key]["timeZone"] = $timezone["RE"];
}
}else
}else {
$count["notSource"]++;
$events[$key]["timeZone"] = $timezone["FR"];
}
$count["notAddress"]++;
}
$count["all"]++;
if(!empty($events[$key]["timeZone"])){
PHDB::update(Event::COLLECTION,
......@@ -7521,10 +7525,9 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
$events=PHDB::find(Event::COLLECTION,
array(
"openingHours" => array('$exists' => 0),
"timeZone" => array('$exists' => 0),
"source.key" => "hva"
"timeZone" => array('$exists' => 0)
),
array("name", "openingHours", "startDate", "endDate", "created", "source", "address.addressCountry"));
array("name", "openingHours", "startDate", "endDate", "creator", "created", "source", "address.addressCountry"));
$count = array(
"source" => array(),
"notSource" => 0,
......@@ -7532,6 +7535,7 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
"RE" => 0,
"all" => 0,
"notAddress" => 0,
"address" => 0,
"fuseau" => array()
);
......@@ -7539,7 +7543,9 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
$timezone = array(
"FR" => "Europe/Paris",
"BE" => "Europe/Brussels",
"RE" => "Indian/Reunion"
"RE" => "Indian/Reunion",
"ES" => "Europe/Madrid",
"MX" => "America/Mexico_City"
);
//Rest::json($count); exit;
foreach ($events as $key => $value) {
......@@ -7549,20 +7555,17 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
$count[$value["address"]["addressCountry"]]++;
if(empty($count["fuseau"][$value["address"]["addressCountry"]]))
$count["fuseau"][$value["address"]["addressCountry"]] = geoip_time_zone_by_country_and_region($value["address"]["addressCountry"]) ;
if(empty($timezone[$value["address"]["addressCountry"]]))
$timezone[$value["address"]["addressCountry"]] = geoip_time_zone_by_country_and_region($value["address"]["addressCountry"]) ;
if(!empty($timezone[$value["address"]["addressCountry"]])){
$mars = new DateTimeZone($timezone[$value["address"]["addressCountry"]]);
$cc = date(DateTime::ISO8601, $value["startDate"]->sec ) ;
$events[$key]["startDateTest"] = new DateTime($cc) ;
$events[$key]["startDateNew"] = new DateTime($cc) ;
$events[$key]["startDateNew"]->setTimezone($mars);
// $events[$key]["startDateNew2"] = $events[$key]["startDateNew"]->format(DateTime::ISO8601);
$events[$key]["timeZone"] = $timezone[$value["address"]["addressCountry"]] ;
// $ts = $events[$key]["startDateNew"]->getTimestamp();
// $events[$key]["startDateNew"] = new MongoDate($ts);
//$events[$key]["created_atFormat"] = $events[$key]["created_at"]->format(DateTime::ISO8601);
// $mars = new DateTimeZone($timezone[$value["address"]["addressCountry"]]);
// $cc = date(DateTime::ISO8601, $value["startDate"]->sec ) ;
// $events[$key]["startDateTest"] = new DateTime($cc) ;
// $events[$key]["startDateNew"] = new DateTime($cc) ;
// $events[$key]["startDateNew"]->setTimezone($mars);
$events[$key]["timeZone"] = $timezone[$value["address"]["addressCountry"]] ;
}
} else {
......@@ -7570,8 +7573,40 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
if(empty($count["source"][$value["source"]["key"]]))
$count["source"][$value["source"]["key"]] = 0;
$count["source"][$value["source"]["key"]]++;
}else
if($value["source"]["key"] == "journalInsoumisChambery"||
$value["source"]["key"] == "collectifEssArrageois" ||
$value["source"]["key"] == "lesPepitesEss" ||
$value["source"]["key"] == "maillage" ||
$value["source"]["key"] == "emploiCsc" ||
$value["source"]["key"] == "CollectifEcocitoyenDeMontreuilSurMer" ||
$value["source"]["key"] == "meuseCampagnes" ){
$events[$key]["timeZone"] = $timezone["FR"];
}else if( $value["source"]["key"] == "lapossession" ||
$value["source"]["key"] == "ctenat" ||
$value["source"]["key"] == "hva" ||
$value["source"]["key"] == "laRaffinerie3"){
$events[$key]["timeZone"] = $timezone["RE"];
}else if( $value["source"]["key"] == "tepozencomun"){
$events[$key]["timeZone"] = $timezone["MX"];
}
}else{
if(!empty($events[$key]["creator"])){
$creator=PHDB::findOneById(Person::COLLECTION,
$events[$key]["creator"],
array("name", "address.addressCountry"));
$events[$key]["endDateTest"] = $creator;
if( !empty($creator["address"]) &&
!empty($creator["address"]["addressCountry"]) &&
!empty($timezone[$creator["address"]["addressCountry"]])){
$events[$key]["timeZone"] = $timezone[$creator["address"]["addressCountry"]] ;
}
}
$count["notSource"]++;
}
$count["notAddress"]++;
}
$count["all"]++;
......@@ -7588,10 +7623,24 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
}
$result = array(
"count" => $count,
"timezone" => $timezone,
"events" => $events,
);
Rest::json($result);
}
}
public function actionEventsTest() {
$date = new DateTime("2020-05-08T15:30:00+04:00");
$newD = new DateTime();
$timezoneEvent = new DateTimeZone($date->getTimezone()->getName());
$res = array(
"date" => $date,
"newD" => $newD,
"timezoneEvent" => $timezoneEvent
);
Rest::json($res); exit;
Rest::json($date->getTimezone()->getName());
}
}
\ No newline at end of file
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