Example #1
0
 function init()
 {
     parent::init();
     $this->addCondition('communication_type', 'TeleMarketing');
     $this->getElement('status')->defaultValue('Called');
     $this->addHook('beforeSave', function ($m) {
         $m['direction'] = 'Out';
     });
 }
Example #2
0
 function init()
 {
     parent::init();
     $this->addCondition('communication_type', 'Call');
     $this->getElement('status')->defaultValue('Called');
     $this->addHook('beforeSave', function ($m) {
         if ($m['status'] == 'Called') {
             $m['direction'] = 'Out';
         } else {
             $m['direction'] = 'In';
         }
     });
 }
Example #3
0
 function init()
 {
     parent::init();
     // $this->containsOne(['extra_info','json'=>true],function($m){
     // 	$m->addField('seen_by')->defaultValue(null);
     // });
     $this->add('misc/Field_Callback', 'communication_with')->set(function ($m) {
         $from_raw = $m['from_raw'];
         $to_raw = $m['to_raw'];
         if ($m['direction'] == 'Out') {
             return ($m['to_id'] and $m['to'] != null) ? $m['to'] : ($to_raw[0]['name'] ? $to_raw[0]['name'] : $to_raw[0]['email']);
         }
         if ($m['direction'] == "In") {
             return $m['from_id'] ? $m['from'] . ", " . $from_raw['email'] : ($from_raw['name'] ? $from_raw['name'] . ", " . $from_raw['email'] : $from_raw['email']);
         }
     });
     $this->add('misc/Field_Callback', 'callback_date')->set(function ($m) {
         if (date('Y-m-d', strtotime($m['created_at'])) == date('Y-m-d', strtotime($this->app->now))) {
             return date('h:i a', strtotime($m['created_at']));
         }
         return date('M d', strtotime($m['created_at']));
     });
     $this->addHook('afterLoad', function ($m) {
         $m['from_raw'] = json_decode($m['from_raw'], true);
         $this['to_raw'] = json_decode($m['to_raw'], true);
         // var_dump($this['to_raw']);
         // exit;
         $m['cc_raw'] = json_decode($m['cc_raw'], true);
         $m['bcc_raw'] = json_decode($m['bcc_raw'], true);
         $m['title'] = $m['subject'] = $m['title'] ?: '(no subject)';
         $description = json_decode($m['description'], true);
         $m['body'] = $m['description'];
     });
     $this->addHook('beforeSave', function ($m) {
         if (is_array($m['to_raw'])) {
             $m['to_raw'] = json_encode($m['to_raw']);
         }
         if (is_array($m['from_raw'])) {
             $m['from_raw'] = json_encode($m['from_raw']);
         }
         if (is_array($m['cc_raw'])) {
             $m['cc_raw'] = json_encode($m['cc_raw']);
         }
         if (is_array($m['bcc_raw'])) {
             $m['bcc_raw'] = json_encode($m['bcc_raw']);
         }
         $m['title'] = $m['title'] ?: "(no subject)";
     });
     $this->getElement('status')->defaultValue('Draft');
 }
Example #4
0
 function init()
 {
     parent::init();
     $this->addCondition('communication_type', 'AbstractMessage');
     $this->getElement('status')->defaultValue('Draft');
     $this->add('misc/Field_Callback', 'callback_date')->set(function ($m) {
         if (date('Y-m-d', strtotime($m['created_at'])) == date('Y-m-d', strtotime($this->app->now))) {
             return "Today " . date('h:i a', strtotime($m['created_at']));
         }
         return date('M d, Y h:i a', strtotime($m['created_at']));
     });
     $this->addHook('afterLoad', function ($m) {
         $m['from_raw'] = json_decode($m['from_raw'], true);
         $this['to_raw'] = json_decode($m['to_raw'], true);
         // var_dump($this['to_raw']);
         // exit;
         $m['cc_raw'] = json_decode($m['cc_raw'], true);
         $m['bcc_raw'] = json_decode($m['bcc_raw'], true);
         $m['title'] = $m['subject'] = $m['title'] ?: '(no subject)';
         $description = json_decode($m['description'], true);
         $m['body'] = $m['description'];
     });
     $this->addHook('beforeSave', function ($m) {
         if (is_array($m['to_raw'])) {
             $m['to_raw'] = json_encode($m['to_raw']);
         }
         if (is_array($m['from_raw'])) {
             $m['from_raw'] = json_encode($m['from_raw']);
         }
         if (is_array($m['cc_raw'])) {
             $m['cc_raw'] = json_encode($m['cc_raw']);
         }
         if (is_array($m['bcc_raw'])) {
             $m['bcc_raw'] = json_encode($m['bcc_raw']);
         }
         $m['title'] = $m['title'] ?: "(no subject)";
     });
 }
Example #5
0
 function init()
 {
     parent::init();
     $this->addCondition('communication_type', 'Comment');
     $this->getElement('status')->defaultValue('Commented');
 }