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 / Fallback / Report.php

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

70 lines 1.8 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\Fallback;
4
5 use BitCode\BitForm\Core\Database\FormModel;
6 use BitCode\BitForm\Core\Database\ReportsModel;
7 use BitCode\BitForm\Core\Util\IpTool;
8
9 class Report {
10 public function report() {
11 $reportMdl = new ReportsModel();
12 global $wpdb;
13 $tablename = $wpdb->prefix . 'bitforms_reports';
14
15 $latestIds = $wpdb->get_results("SELECT MAX(`id`) as latest_id FROM $tablename GROUP BY `context`");
16
17 $notDeletedIds = array_column($latestIds, 'latest_id');
18
19 if (!is_wp_error($latestIds) && count($notDeletedIds) > 0) {
20 $reportMdl->bulkDelete(['id' => $notDeletedIds], 'NOT IN');
21 }
22
23 $ipTool = new IpTool();
24 $user_details = $ipTool->getUserDetail();
25
26 $formModel = new FormModel();
27
28 $forms = $formModel->get(
29 ['id']
30 );
31
32 $details = [
33 'report_name' => 'All Entries',
34 'hiddenColumns' => [],
35 'pageSize' => 10,
36 'sortBy' => [],
37 'filters' => [],
38 'globalFilter' => '',
39 'order' => [],
40 ];
41
42 foreach ($forms as $form) {
43 $existReportId = $reportMdl->get(
44 [
45 'id',
46 ],
47 [
48 'context' => $form->id,
49 ]
50 );
51 if (is_wp_error($existReportId)) {
52 $defaultReport = [
53 'type' => 'table',
54 'category' => 'form',
55 'context' => $form->id,
56 'details' => wp_json_encode($details),
57 'isDefault' => (bool) 1,
58 'user_id' => $user_details['id'],
59 'user_ip' => $user_details['ip'],
60 'user_device' => $user_details['device'],
61 'created_at' => $user_details['time'],
62 'updated_at' => $user_details['time'],
63 ];
64
65 $reportMdl->insert($defaultReport);
66 }
67 }
68 }
69 }
70