Blame view

src/lib/models/spyEvent.php 1.11 KB
ef60cd4d   Administrator   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  <?php
  use Phalcon\Mvc\Model;
  
  class SpyEvent extends \Phalcon\Mvc\Model
  {
      public function getSource()
      {
          return "spy_event";
      }
  
  
      public function spyTimeAfter($project,$customer_id){
          return  self::query()
              ->columns(['customer_id', 'st.id, st.item_id', 'st.item_name', 'st.item_image', 'st.quantity', 'st.price', 'st.item_url', 'st.item_image'])
              ->rightJoin('spyStore', 'st.spy_event_id = SpyEvent.id', 'st')
              ->where("project_id = :project_id:")
              ->andWhere("action ='order_add'")
              ->andWhere("customer_id =$customer_id")
              ->bind(array("project_id" => $project->id))
              ->execute();
  
      }
  
      public function getSpyUsers($project, $modelsManager){
  
          $now = date("Y-m-d H:i:s");
          $date = new DateTime($now);
          $date->modify('-3 hours');
          $date = $date->format('Y-m-d H:i:s');
  
          $phql = "SELECT DISTINCT (customer_id) as id FROM SpyEvent WHERE project_id = {$project->id} AND action = 'order_add' AND date <=  '{$date}' ";
  
          return $modelsManager->executeQuery($phql)->toArray();
  
      }
  }