static function makeHtml($notification = null)
 {
     if ($notification == null) {
         return "";
     }
     $auth_id = $notification->info;
     if ($auth_id == null) {
         return "";
     }
     $auth = ConnectionAuth::findOne($auth_id);
     if (!$auth) {
         return "";
     }
     $connection = Connection::findOne($auth->connection_id);
     $source = ConnectionPath::findOne(['conn_id' => $connection->id, 'path_order' => 0])->domain;
     $path_order = ConnectionPath::find()->where(['conn_id' => $connection->id])->count() - 1;
     $destination = ConnectionPath::findOne(['conn_id' => $connection->id, 'path_order' => $path_order])->domain;
     $reservation = Reservation::findOne($connection->reservation_id);
     $title = Yii::t("notify", 'Pending authorization');
     $msg = Yii::t("notify", 'The connection is from') . " <b>" . $source . "</b> " . Yii::t("notify", 'to') . " <b>" . $destination . "</b>";
     $msg .= ". " . Yii::t("notify", 'The request bandwidth is') . " " . $reservation->bandwidth . " Mbps.";
     $date = Yii::$app->formatter->asDatetime($notification->date);
     $link = '/circuits/authorization/answer?id=' . $reservation->id . '&domain=' . $auth->domain;
     $html = Notification::makeHtml('pending_authorization.png', $date, $title, $msg, $link);
     if ($notification->viewed == true) {
         return '<li>' . $html . '</li>';
     }
     return '<li class="notification_new">' . $html . '</li>';
 }
 static function makeHtml($notification = null)
 {
     if ($notification == null) {
         return "";
     }
     $eventId = json_decode($notification->info);
     $changesSize = Change::find()->where(['sync_event_id' => $eventId])->count();
     $pendingChangesSize = Change::find()->where(['sync_event_id' => $eventId])->andWhere(['in', 'status', [Change::STATUS_PENDING, Change::STATUS_FAILED]])->count();
     $appliedChangesSize = Change::find()->where(['sync_event_id' => $eventId, 'status' => Change::STATUS_APPLIED])->count();
     $changes = Change::find()->where(['sync_event_id' => $eventId])->asArray()->groupBy(['domain'])->select(['domain'])->all();
     $title = Yii::t("notify", 'Topology change');
     if (count($changes) > 1) {
         $msg = Yii::t("notify", 'The topologies of') . " <b>" . count($changes) . "</b> " . Yii::t("notify", 'domains has been updated.') . " <b>" . $appliedChangesSize . "</b> " . Yii::t("notify", 'changes were applied.') . ' ' . ($pendingChangesSize > 0 ? " <b>" . $pendingChangesSize . "</b> " . Yii::t("notify", 'are pending.') : '');
     } else {
         if (count($changes) == 1) {
             $msg = Yii::t("notify", 'The') . " <b>" . $changes[0]['domain'] . "</b> " . Yii::t("notify", 'topology has been updated.') . " <b>" . $appliedChangesSize . "</b> " . Yii::t("notify", 'changes were applied.') . ' ' . ($pendingChangesSize > 0 ? " <b>" . $pendingChangesSize . "</b> " . Yii::t("notify", 'are pending.') : '');
         } else {
             return "";
         }
     }
     $date = Yii::$app->formatter->asDatetime($notification->date);
     $link = '/topology/change/applied?eventId=' . $eventId;
     $text = '<span><h1>' . $title . '</h1><h2>' . $msg . '</h2><h3>' . $date . '</h3></span>';
     $html = Notification::makeHtml('topology.png', $text);
     if ($notification->viewed == true) {
         return '<li>' . Html::a($html, array($link)) . '</li>';
     }
     return '<li class="new">' . Html::a($html, array($link)) . '</li>';
 }
 static function makeHtml($notification = null)
 {
     if ($notification == null) {
         return "";
     }
     $reservation = Reservation::findOne($notification->info);
     if (!$reservation) {
         return "";
     }
     $connection = Connection::find()->where(['reservation_id' => $reservation->id])->one();
     $source = ConnectionPath::findOne(['conn_id' => $connection->id, 'path_order' => 0])->domain;
     $path_order = ConnectionPath::find()->where(['conn_id' => $connection->id])->count() - 1;
     $destination = ConnectionPath::findOne(['conn_id' => $connection->id, 'path_order' => $path_order])->domain;
     $title = Yii::t("notify", 'Reservation') . " (" . $reservation->name . ")";
     $connections = Connection::find()->where(['reservation_id' => $reservation->id])->all();
     //Se possui apenas uma conexão, então pode informar diretamente se foi aceito ou negado
     if (count($connections) < 2) {
         $msg = Yii::t("notify", 'The connection between') . " <b>" . $source . " </b>" . Yii::t("notify", 'and') . " <b>" . $destination . "</b> ";
         $date = Yii::$app->formatter->asDatetime($notification->date);
         $link = '/circuits/reservation/view?id=' . $reservation->id;
         if ($connections[0]->status == Connection::STATUS_FAILED_CREATE || $connections[0]->status == Connection::STATUS_FAILED_CONFIRM || $connections[0]->status == Connection::STATUS_FAILED_SUBMIT || $connections[0]->status == Connection::STATUS_FAILED_PROVISION || $connections[0]->status == Connection::STATUS_CANCELLED || $connections[0]->status == Connection::STATUS_CANCEL_REQ || $connections[0]->auth_status == Connection::AUTH_STATUS_REJECTED || $connections[0]->auth_status == Connection::AUTH_STATUS_EXPIRED) {
             $msg .= " " . Yii::t("notify", 'can not be provisioned.');
             $html = Notification::makeHtml('circuit_reject.png', $date, $title, $msg, $link);
         } else {
             $msg .= " " . Yii::t("notify", 'was provisioned.');
             $html = Notification::makeHtml('circuit_accept.png', $date, $title, $msg, $link);
         }
     } else {
         //Conta o número de provisionadas, rejeitadas (aglomera todos estados em que não vai ser gerado o circuito)
         //e pendentes (aglomera todos estados de processamento intermediário)
         $provisioned = 0;
         $reject = 0;
         $pending = 0;
         foreach ($connections as $conn) {
             if ($conn->status == Connection::STATUS_PROVISIONED) {
                 $provisioned++;
             } else {
                 if ($conn->status == Connection::STATUS_FAILED_CREATE || $conn->status == Connection::STATUS_FAILED_CONFIRM || $conn->status == Connection::STATUS_FAILED_SUBMIT || $conn->status == Connection::STATUS_FAILED_PROVISION || $conn->status == Connection::STATUS_CANCELLED || $conn->status == Connection::STATUS_CANCEL_REQ || $conn->auth_status == Connection::AUTH_STATUS_REJECTED || $conn->auth_status == Connection::AUTH_STATUS_EXPIRED) {
                     $reject++;
                 } else {
                     $pending++;
                 }
             }
         }
         $msg = Yii::t("notify", 'The status of connections changed:') . "<br />";
         $msg .= Yii::t("notify", 'Provisioned:') . " " . $provisioned . ", ";
         $msg .= Yii::t("notify", 'Rejected:') . " " . $reject . ", ";
         $msg .= Yii::t("notify", 'Pending:') . " " . $pending;
         $date = Yii::$app->formatter->asDatetime($notification->date);
         $link = '/circuits/reservation/view?id=' . $reservation->id;
         $html = Notification::makeHtml('circuit_changed.png', $date, $title, $msg, $link);
     }
     if ($notification->viewed == true) {
         return '<li>' . $html . '</li>';
     }
     return '<li class="notification_new">' . $html . '</li>';
 }
示例#4
0
 static function makeHtml($notification = null)
 {
     if ($notification == null) {
         return "";
     }
     $data = json_decode($notification->info);
     $type = $data[0];
     switch ($type) {
         //ADICIONADO A UM GRUPO
         case Notification::NOTICE_TYPE_ADD_GROUP:
             $group = Group::findOne($data[1]);
             if (!$group) {
                 return "";
             }
             //Se não possui dado extra é para todos, do contrario, possui dominio
             if (isset($data[2])) {
                 $domain = Domain::findOne(['name' => $data[2]]);
                 if (!$domain) {
                     return "";
                 }
             }
             $title = Yii::t("notify", 'Added to a group');
             $msg = Yii::t("notify", 'You have been added to group') . " <b>" . $group->name . "</b>";
             if ($group->type == Group::TYPE_DOMAIN) {
                 if (isset($domain)) {
                     $msg .= " " . Yii::t("notify", 'of the domain') . " <b>" . $domain->name . "</b>.";
                 } else {
                     if (!isset($data[2])) {
                         $msg .= " " . Yii::t("notify", 'of all domains.');
                     } else {
                         $msg .= ".";
                     }
                 }
             } else {
                 $msg .= " " . Yii::t("notify", 'with system permissions');
             }
             $date = Yii::$app->formatter->asDatetime($notification->date);
             $html = Notification::makeHtml('notice.png', $date, $title, $msg);
             break;
             //REMOVIDO DE UM GRUPO
         //REMOVIDO DE UM GRUPO
         case Notification::NOTICE_TYPE_DEL_GROUP:
             $group = Group::findOne($data[1]);
             if (!$group) {
                 return "";
             }
             //Se não possui dado extra é para todos, do contrario, possui dominio
             if (isset($data[2])) {
                 $domain = Domain::findOne(['name' => $data[2]]);
                 if (!$domain) {
                     return "";
                 }
             }
             $title = Yii::t("notify", 'Removed from a group');
             $msg = Yii::t("notify", 'You were removed from the group') . " <b>" . $group->name . "</b>";
             if ($group->type == Group::TYPE_DOMAIN) {
                 if (isset($domain)) {
                     $msg .= " " . Yii::t("notify", 'of the domain') . " <b>" . $domain->name . "</b>.";
                 } else {
                     if (!isset($data[2])) {
                         $msg .= " " . Yii::t("notify", 'of all domains.');
                     } else {
                         $msg .= ".";
                     }
                 }
             } else {
                 $msg .= " " . Yii::t("notify", 'with system permissions');
             }
             $date = Yii::$app->formatter->asDatetime($notification->date);
             $html = Notification::makeHtml('notice.png', $date, $title, $msg);
             break;
     }
     if ($notification->viewed == true) {
         return '<li>' . $html . '</li>';
     }
     return '<li class="notification_new">' . $html . '</li>';
 }