Blame view

src/lib/MyMailer/EventOnline.php 1.42 KB
f7818cdf   Administrator   change request to...
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  <?php
  namespace MyMailer;
  
  class EventOnline extends Event{
  
      /**
       * @param $customers
       * @param $post
       * @param $data
       * @param $template
       * @throws \Exception
       */
      public function sendEventDelivery($post, $data, $template){
          if($post['email']){
  
              $customers_model = new \customersEmailList();
  
              $customers = $customers_model->findFirst("email = '{$post['email']}'");
  
              $event_info =  new \eventInfo();
  
  
              if(isset($post['event']) && !empty($post['event'])) {
  
  
                  $event_info->event_id = $data->id;
                  $event_info->customer_id = $customers->id;
                  $event_info->project_id = $post['project_id'];
  
                  if($data->unique) {
                      $unique = $event_info->findFirst("event_id = {$data->id} AND customer_id = {$customers->id} AND project_id = {$post['project_id']}");
                      if($unique) {
                          throw new \Exception();
                      }
                  }
  
  
                  $MyMailer = new EventMailer();
  
                  $MyMailer->setFromName($post['project_name']);
  
                  $MyMailer->SendDelivery($template->toArray(),$data->toArray(),array($customers->toArray()));
  
                  $event_info->save();
  
  
              } else {
                  throw new \Exception();
              }
  
          } else {
              throw new \Exception("email missing");
          }
      }
  
  
  }