| @@ -7,12 +7,14 @@ | ||
| 7 | 7 | /** |
| 8 | 8 | * Undocumented class |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -class FormEntryLogModel extends Model { | |
| 11 | +class FormEntryLogModel extends Model | |
| 12 | +{ | |
| 12 | 13 | protected static $table = 'bitforms_form_log_details'; |
| 13 | 14 | |
| 14 | - public function geLogHistory($form_id, $entry_id) { | |
| 15 | + public function geLogHistory($form_id, $entry_id) | |
| 16 | + { | |
| 15 | 17 | $sql = "SELECT * FROM `{$this->app_db->prefix}bitforms_form_entry_log` where form_entry_id=$entry_id AND form_id=$form_id order By created_at DESC"; |
| 16 | 18 | |
| 17 | 19 | $logs = $this->execute($sql)->getResult(); |
| 18 | 20 | $response = ['success' => true, 'data' => [], 'integrations' => []]; |
| @@ -39,9 +41,10 @@ | ||
| 39 | 41 | wp_send_json(['success' => true, 'data' => $logs, 'integrations' => $integrations]); |
| 40 | 42 | } |
| 41 | 43 | } |
| 42 | 44 | |
| 43 | - public function entryLogCheck($entry_id, $integ_id) { | |
| 45 | + public function entryLogCheck($entry_id, $integ_id) | |
| 46 | + { | |
| 44 | 47 | if (is_null($entry_id)) { |
| 45 | 48 | return new WP_Error('empty_data', __('Form data is empty', 'bit-form')); |
| 46 | 49 | } |
| 47 | 50 | $sql = "SELECT api_type, response_obj FROM `{$this->app_db->prefix}bitforms_form_entry_log` as el JOIN `{$this->app_db->prefix}bitforms_form_log_details` as ld ON ld.log_id = el.id WHERE form_entry_id = {$entry_id} AND integration_id = {$integ_id} AND ld.response_type = 'success' ORDER BY el.id DESC LIMIT 1"; |
| @@ -48,9 +51,10 @@ | ||
| 48 | 51 | |
| 49 | 52 | return $this->app_db->get_results($sql); |
| 50 | 53 | } |
| 51 | 54 | |
| 52 | - public function form_log_insert($data = []) { | |
| 55 | + public function form_log_insert($data = []) | |
| 56 | + { | |
| 53 | 57 | if (is_null($data)) { |
| 54 | 58 | return new WP_Error('empty_data', __('Form data is empty', 'bit-form')); |
| 55 | 59 | } |
| 56 | 60 | $result = $this->app_db->insert( |
| @@ -59,9 +63,10 @@ | ||
| 59 | 63 | ); |
| 60 | 64 | return $this->getResult($result); |
| 61 | 65 | } |
| 62 | 66 | |
| 63 | - public function log_history_insert($data = []) { | |
| 67 | + public function log_history_insert($data = []) | |
| 68 | + { | |
| 64 | 69 | if (is_null($data)) { |
| 65 | 70 | return new WP_Error('empty_data', __('Form data is empty', 'bit-form')); |
| 66 | 71 | } |
| 67 | 72 | $result = $this->app_db->insert( |
| @@ -70,14 +75,16 @@ | ||
| 70 | 75 | ); |
| 71 | 76 | return $this->getResult($result); |
| 72 | 77 | } |
| 73 | 78 | |
| 74 | - public function get_form_value($form_id = '') { | |
| 79 | + public function get_form_value($form_id = '') | |
| 80 | + { | |
| 75 | 81 | $sql = "SELECT `meta_key`,`meta_value` FROM `{$this->app_db->prefix}bitforms_form_entrymeta` where bitforms_form_entry_id=$form_id"; |
| 76 | 82 | return $this->execute($sql)->getResult(); |
| 77 | 83 | } |
| 78 | 84 | |
| 79 | - public function logUpdate($updateValue, $logID) { | |
| 85 | + public function logUpdate($updateValue, $logID) | |
| 86 | + { | |
| 80 | 87 | if (empty($logID)) { |
| 81 | 88 | return false; |
| 82 | 89 | } |
| 83 | 90 | $sql = "UPDATE `{$this->app_db->prefix}bitforms_form_entry_log` SET content='$updateValue' WHERE id=$logID"; |