PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.0
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.0
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / includes / Core / Database / FormEntryLogModel.php

FormEntryLogModel.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.0, at includes/Core/Database/FormEntryLogModel.php

87 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Core\Database;
4
5 use WP_Error;
6
7 /**
8 * Undocumented class
9 */
10
11 class FormEntryLogModel extends Model {
12 protected static $table = 'bitforms_form_log_details';
13
14 public function geLogHistory($form_id, $entry_id) {
15 $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
17 $logs = $this->execute($sql)->getResult();
18 $response = ['success' => true, 'data' => [], 'integrations' => []];
19 $ids = [];
20 foreach ($logs as $log) {
21 $ids[] = $log->id;
22 }
23 if (isset($logs->errors['result_empty'])) {
24 wp_send_json($response);
25 } else {
26 $allLogId = preg_replace('/"/', '', implode(',', $ids));
27 $sql2 = "SELECT * FROM `{$this->app_db->prefix}bitforms_form_log_details` WHERE `log_id` IN ($allLogId)";
28 $integrations = $this->execute($sql2)->getResult();
29 foreach ($logs as $key => $log) {
30 foreach ($integrations as $integration) {
31 if ($integration->log_id === $log->id) {
32 $logs[$key]->integration = true;
33 }
34 }
35 }
36 if (isset($integrations->errors['result_empty'])) {
37 $integrations = [];
38 }
39 wp_send_json(['success' => true, 'data' => $logs, 'integrations' => $integrations]);
40 }
41 }
42
43 public function entryLogCheck($entry_id, $integ_id) {
44 if (is_null($entry_id)) {
45 return new WP_Error('empty_data', __('Form data is empty', 'bit-form'));
46 }
47 $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
49 return $this->app_db->get_results($sql);
50 }
51
52 public function form_log_insert($data = []) {
53 if (is_null($data)) {
54 return new WP_Error('empty_data', __('Form data is empty', 'bit-form'));
55 }
56 $result = $this->app_db->insert(
57 "{$this->app_db->prefix}bitforms_form_entry_log",
58 $data
59 );
60 return $this->getResult($result);
61 }
62
63 public function log_history_insert($data = []) {
64 if (is_null($data)) {
65 return new WP_Error('empty_data', __('Form data is empty', 'bit-form'));
66 }
67 $result = $this->app_db->insert(
68 "{$this->app_db->prefix}bitforms_form_log_details",
69 $data
70 );
71 return $this->getResult($result);
72 }
73
74 public function get_form_value($form_id = '') {
75 $sql = "SELECT `meta_key`,`meta_value` FROM `{$this->app_db->prefix}bitforms_form_entrymeta` where bitforms_form_entry_id=$form_id";
76 return $this->execute($sql)->getResult();
77 }
78
79 public function logUpdate($updateValue, $logID) {
80 if (empty($logID)) {
81 return false;
82 }
83 $sql = "UPDATE `{$this->app_db->prefix}bitforms_form_entry_log` SET content='$updateValue' WHERE id=$logID";
84 return $this->execute($sql)->getResult();
85 }
86 }
87