PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 1.4
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v1.4
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 / ReportsModel.php

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

60 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Provides Report Model Class
4 */
5 namespace BitCode\BitForm\Core\Database;
6
7 use BitCode\BitForm\Core\Database\Model;
8
9 /**
10 *
11 */
12 class ReportsModel extends Model
13 {
14 protected static $table = 'bitforms_reports';
15
16 public function validateReportFields($reportData, $fieldNames)
17 {
18 $reportDetails = [];
19 switch ($reportData->type) {
20 case 'table':
21 $tableAction = "table_ac";
22 $reportDetails = !is_string($reportData->details)? $reportData->details : json_decode($reportData->details);
23 if (!empty($reportDetails->order)) {
24 $initialOrder = $fieldNames;
25 $columnOrder = $reportDetails->order;
26 foreach ($reportDetails->order as $key => $value) {
27 if (isset($initialOrder[$value])) {
28 unset($initialOrder[$value]);
29 } elseif (!isset($initialOrder[$value])) {
30 unset($columnOrder[$key]);
31 }
32 }
33 $columnOrder = array_values($columnOrder);
34 if (!empty($initialOrder)) {
35 foreach ($initialOrder as $name => $label) {
36 $columnOrder[] = $name;
37 }
38 }
39 $columnOrder[] = $tableAction;
40 array_unshift($columnOrder, 'selection', 'sl');
41 $reportDetails->order = $columnOrder;
42 }
43 if (!empty($reportDetails->hiddenColumns)) {
44 $hiddenColumns = $reportDetails->hiddenColumns;
45 foreach ($reportDetails->hiddenColumns as $key => $value) {
46 if (!isset($fieldNames[$value]) && ($value !== 'sl' && $value !== 'selection' && $value !== 'table_ac')) {
47 unset($hiddenColumns[$key]);
48 }
49 }
50 $reportDetails->hiddenColumns = array_values($hiddenColumns);
51 }
52 break;
53
54 default:
55 break;
56 }
57 return $reportDetails;
58 }
59 }
60