Exemplo n.º 1
0
 /**
  * @before _secure
  */
 public function index()
 {
     $this->seo(array("title" => "Dashboard", "description" => "Stats for your Data"));
     $view = $this->getActionView();
     $commissions = [];
     $start = RM::get("start", date("Y-m-d", strtotime('now')));
     $end = RM::get("end", date("Y-m-d", strtotime('now')));
     $today = date('Y-m-d');
     $yesterday = date('Y-m-d', strtotime("-1 day"));
     $perf = Shared\Services\User::livePerf($this->user, $today, $today);
     $yestPerf = Shared\Services\User::livePerf($this->user, $yesterday, $yesterday);
     $notifications = Notification::all(["org_id = ?" => $this->org->id, "meta = ?" => ['$in' => ['all', $this->user->_id]]], [], "created", "desc", 5, 1);
     $total = Performance::total(['start' => date("Y-m-d", strtotime('-365 day')), 'end' => date("Y-m-d", strtotime('-2 day'))], $this->user);
     $view->set("start", date("Y-m-d", strtotime('-7 day')))->set("end", date("Y-m-d", strtotime('now')))->set("notifications", $notifications)->set("total", $total)->set("yestPerf", $yestPerf)->set("performance", $perf);
 }
Exemplo n.º 2
0
<?php

//les variables comme posts et tests ne sont pas transmise,
$res->notificationsNumber = Notification::all(array('conditions' => array('to_user_id' => $res->user->id, 'status' => 0)))->count;
$res->useTemplate();
Exemplo n.º 3
0
 /**
  * @before _secure
  */
 public function notification()
 {
     $this->seo(array("title" => "Notification"));
     $view = $this->getActionView();
     $fields = ['_id', 'name'];
     $arr = User::all(['org_id' => $this->org->_id, 'type' => 'publisher'], $fields);
     $publishers = User::objectArr($arr, $fields);
     $arr = User::all(['org_id' => $this->org->_id, 'type' => 'advertiser'], $fields);
     $advertisers = User::objectArr($arr, $fields);
     $view->set('publishers', $publishers)->set('advertisers', $advertisers);
     switch (RM::post("action")) {
         case 'save':
             $meta = RM::post("meta", "all");
             $message = RM::post("message");
             $success = "Saved Successfully";
             if ($meta !== "all" && (!in_array($meta, array_keys($publishers)) && !in_array($meta, array_keys($advertisers)))) {
                 $view->set('message', "Invalid Request!!");
                 break;
             } else {
                 if ($meta !== "all") {
                     // send mail to the user
                     $usr = User::first(['_id' => $meta], ['name', 'email']);
                     \Shared\Services\Smtp::sendMail($this->org, ['template' => 'notification', 'user' => $usr, 'notification' => $message, 'to' => [$usr->email], 'subject' => "Notification from " . $this->org->name]);
                     $success .= " And Mail sent";
                 }
             }
             $n = new Notification(["org_id" => $this->org->id, "message" => $message, "target" => RM::post("target"), "meta" => $meta]);
             $n->save();
             $view->set("message", $success);
             break;
     }
     if (RM::type() === 'DELETE') {
         $id = RM::get("id");
         $n = Notification::first(["org_id = ?" => $this->org->id, "id = ?" => $id]);
         if ($n) {
             $n->delete();
             $view->set("message", "Deleted Successfully");
         } else {
             $view->set("message", "Notification does not exist");
         }
     }
     $notifications = Notification::all(["org_id = ?" => $this->org->id], [], "created", "desc");
     $view->set("notifications", $notifications);
 }
Exemplo n.º 4
0
<?php

$res->notifications = Notification::all(array('conditions' => array('to_user_id' => $res->user->id, 'status' => 0), 'limit' => 5))->asArray();
$res->useTemplate();