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

Event Time zone

parent a390d087
......@@ -7434,7 +7434,7 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
$events=PHDB::find(Event::COLLECTION,
array(
"openingHours" => array('$exists' => 1),
"created_at" => array('$exists' => 0)
"timeZone" => array('$exists' => 0)
),
array("name", "openingHours", "startDate", "endDate", "created", "creator", "source", "address.addressCountry"));
$count = array(
......@@ -7482,6 +7482,13 @@ 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"]]++;
if($value["source"]["key"] == "hva"){
$events[$key]["timeZone"] = $timezone["FR"];
}else if($value["source"]["key"] == "lapossession"){
$events[$key]["timeZone"] = $timezone["RE"];
}
}else
$count["notSource"]++;
$count["notAddress"]++;
......@@ -7489,11 +7496,10 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
$count["all"]++;
if(!empty($events[$key]["created_at"])){
if(!empty($events[$key]["timeZone"])){
PHDB::update(Event::COLLECTION,
array("_id" => $events[$key]["_id"]),
array('$set' => array( "created_at" => $events[$key]["created_at"],
"timeZone" => $events[$key]["timeZone"]) )
array('$set' => array( "timeZone" => $events[$key]["timeZone"]) )
);
}
......@@ -7511,10 +7517,11 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
public function actionEventsTimeZone() {
if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
date_default_timezone_set('UTC');
$events=PHDB::find(Event::COLLECTION,
array(
"openingHours" => array('$exists' => 0),
"startDateNew" => array('$exists' => 0),
"timeZone" => array('$exists' => 0),
"source.key" => "hva"
),
array("name", "openingHours", "startDate", "endDate", "created", "source", "address.addressCountry"));
......@@ -7546,10 +7553,11 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
$count["fuseau"][$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]["startDateNew"] = new DateTime($cc) ;
// $events[$key]["startDateNew"]->setTimezone($mars);
$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();
......@@ -7557,7 +7565,7 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
//$events[$key]["created_atFormat"] = $events[$key]["created_at"]->format(DateTime::ISO8601);
}
}else{
} else {
if(!empty($value["source"])){
if(empty($count["source"][$value["source"]["key"]]))
$count["source"][$value["source"]["key"]] = 0;
......@@ -7569,11 +7577,10 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
$count["all"]++;
if(!empty($events[$key]["startDateNew"])){
if(!empty($events[$key]["timeZone"])){
PHDB::update(Event::COLLECTION,
array("_id" => $events[$key]["_id"]),
array('$set' => array( "startDateNew" => $events[$key]["startDateNew"],
"timeZone" => $events[$key]["timeZone"] ) )
array('$set' => array( "timeZone" => $events[$key]["timeZone"] ) )
);
}
......
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