Advanced Contact form 7 DB - Version 1.9

Version Description

  • We have upgraded with Security patches
Download this release

Release Info

Developer vsourz1td
Plugin Icon 128x128 Advanced Contact form 7 DB
Version 1.9
Comparing to
See all releases

Code changes from version 1.8.9 to 1.9

README.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: vsourz1td
3
  Tags: contact form 7 db, contact form db, advanced cf7 db, contact form 7 database, contact form db, contact form 7, save form data, save contact form, save cf7, database, cf7db, save-contact-form, Save-Forms-Data, import-cf7, export-contact-data, view-cf7-entry
4
  Requires at least: 4.0
5
- Tested up to: 6.0
6
- Stable tag: 1.8.9
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
2
  Contributors: vsourz1td
3
  Tags: contact form 7 db, contact form db, advanced cf7 db, contact form 7 database, contact form db, contact form 7, save form data, save contact form, save cf7, database, cf7db, save-contact-form, Save-Forms-Data, import-cf7, export-contact-data, view-cf7-entry
4
  Requires at least: 4.0
5
+ Tested up to: 6.0.1
6
+ Stable tag: 1.9
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
admin/class-advanced-cf7-db-admin.php CHANGED
@@ -40,6 +40,11 @@ class Advanced_Cf7_Db_Admin {
40
  */
41
  private $version;
42
 
 
 
 
 
 
43
  /**
44
  * Initialize the class and set its properties.
45
  *
@@ -51,6 +56,7 @@ class Advanced_Cf7_Db_Admin {
51
 
52
  $this->plugin_name = $plugin_name;
53
  $this->version = $version;
 
54
 
55
  }
56
 
@@ -832,11 +838,11 @@ class Advanced_Cf7_Db_Admin {
832
  //Check if field name already exist with entry or not
833
  if(!empty($arr_exist_keys) && in_array($key,$arr_exist_keys)){
834
  //If field name match with current entry then field information update
835
- $wpdb->query($wpdb->prepare("UPDATE ".VSZ_CF7_DATA_ENTRY_TABLE_NAME." SET `value` = %s WHERE `name` = %s AND `data_id` = %d", sanitize_textarea_field($value), sanitize_text_field($key), $rid));
836
  }
837
  else{
838
  //If field name not match with current entry then new entry insert in DB
839
- $wpdb->query($wpdb->prepare('INSERT INTO '.VSZ_CF7_DATA_ENTRY_TABLE_NAME.'(`cf7_id`, `data_id`, `name`, `value`) VALUES (%d,%d,%s,%s)', $fid, $rid, sanitize_text_field($key), sanitize_textarea_field($value)));
840
  }
841
  }
842
  //Check if field type is text area
@@ -844,11 +850,11 @@ class Advanced_Cf7_Db_Admin {
844
  //Check if field name already exist with entry or not
845
  if(!empty($arr_exist_keys) && in_array($key,$arr_exist_keys)){
846
  //If field name match with current entry then field information update
847
- $wpdb->query($wpdb->prepare("UPDATE ".VSZ_CF7_DATA_ENTRY_TABLE_NAME." SET `value` = %s WHERE `name` = %s AND `data_id` = %d", sanitize_textarea_field($value), sanitize_text_field($key), $rid));
848
  }
849
  else{
850
  //If field name not match with current entry then new entry insert in DB
851
- $wpdb->query($wpdb->prepare('INSERT INTO '.VSZ_CF7_DATA_ENTRY_TABLE_NAME.'(`cf7_id`, `data_id`, `name`, `value`) VALUES (%d,%d,%s,%s)', $fid, $rid, sanitize_text_field($key), sanitize_textarea_field($value)));
852
  }
853
 
854
  }//Close text area else if
@@ -856,11 +862,11 @@ class Advanced_Cf7_Db_Admin {
856
  //Check if field name already exist with entry or not
857
  if(!empty($arr_exist_keys) && in_array($key,$arr_exist_keys)){
858
  //If field name match with current entry then field information update
859
- $wpdb->query($wpdb->prepare("UPDATE ".VSZ_CF7_DATA_ENTRY_TABLE_NAME." SET `value` = %s WHERE `name` = %s AND `data_id` = %d", sanitize_text_field($value), sanitize_text_field($key), $rid));
860
  }
861
  else{
862
  //If field name not match with current entry then new entry insert in DB
863
- $wpdb->query($wpdb->prepare('INSERT INTO '.VSZ_CF7_DATA_ENTRY_TABLE_NAME.'(`cf7_id`, `data_id`, `name`, `value`) VALUES (%d,%d,%s,%s)', $fid, $rid, sanitize_text_field($key), sanitize_text_field($value)));
864
  }
865
  }//Close else
866
  }//Close foreach
@@ -1006,7 +1012,7 @@ class Advanced_Cf7_Db_Admin {
1006
  //If entry not empty
1007
  if(!empty($rid)){
1008
  //Get entry related all fields information
1009
- $sql = $wpdb->prepare("SELECT * FROM ".VSZ_CF7_DATA_ENTRY_TABLE_NAME." WHERE `data_id` = %d", $rid);
1010
  $rows = $wpdb->get_results($sql);
1011
  $return = array();
1012
  //Set all fields name in array
@@ -1549,6 +1555,8 @@ function create_export_query($fid,$ids_export,$cf7d_entry_order_by){
1549
  }
1550
 
1551
  $cf7d_entry_order_by = sanitize_sql_orderby($cf7d_entry_order_by);
 
 
1552
 
1553
  //Create Export Query on the basis of Listing screen filter
1554
 
@@ -1556,7 +1564,13 @@ function create_export_query($fid,$ids_export,$cf7d_entry_order_by){
1556
  if(isset($_POST['search_cf7_value']) && !empty($_POST['search_cf7_value']) && isset($_POST['start_date']) && isset($_POST['end_date']) && empty($_POST['start_date']) && empty($_POST['end_date'])){
1557
 
1558
  $search = sanitize_text_field($_POST['search_cf7_value']);
1559
- $query = $wpdb->prepare("SELECT * FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = ".$fid." AND data_id IN(SELECT * FROM (SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE 1 = 1 AND `cf7_id` = ".$fid." ".((!empty($search)) ? "AND `value` LIKE '%%".$search."%%'" : "").' '.((!empty($ids_export)) ? " AND data_id IN(".$ids_export.")" : ''). " GROUP BY `data_id` ORDER BY ".sanitize_sql_orderby($cf7d_entry_order_by)." ) temp_table) ORDER BY " . sanitize_sql_orderby($cf7d_entry_order_by));
 
 
 
 
 
 
1560
  }
1561
  //Check date wise filter active or not
1562
  else if(isset($_POST['search_cf7_value']) && empty($_POST['search_cf7_value']) && isset($_POST['start_date']) && isset($_POST['end_date']) && !empty($_POST['start_date']) && !empty($_POST['end_date']) && $s_date !== false && $e_date !== false){
@@ -1565,11 +1579,19 @@ function create_export_query($fid,$ids_export,$cf7d_entry_order_by){
1565
  $start_date = date_format($s_date,"Y-m-d");
1566
 
1567
  //Get end date information
1568
- $end_date = date_format($e_date,"Y-m-d");
 
 
 
 
 
 
 
 
 
 
1569
 
1570
- $search_date_query = "AND `name` = 'submit_time' AND value between '".$start_date."' and '".$end_date." 23:59:59'";
1571
 
1572
- $query = $wpdb->prepare("SELECT * FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = ".$fid." AND data_id IN( SELECT * FROM ( SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE 1 = 1 AND `cf7_id` = ".$fid." ".$search_date_query.' '. ((!empty($ids_export)) ? " AND data_id IN(".$ids_export.")" : '')." GROUP BY `data_id` ORDER BY ".sanitize_sql_orderby($cf7d_entry_order_by)." ) temp_table) ORDER BY " . sanitize_sql_orderby($cf7d_entry_order_by));
1573
  }
1574
  //Check search and date wise filter active or not
1575
  else if(isset($_POST['search_cf7_value']) && !empty($_POST['search_cf7_value']) && isset($_POST['start_date']) && isset($_POST['end_date']) && !empty($_POST['start_date']) && !empty($_POST['end_date']) && $s_date !== false && $e_date !== false){
@@ -1582,7 +1604,7 @@ function create_export_query($fid,$ids_export,$cf7d_entry_order_by){
1582
  //Get end date information
1583
  $end_date = date_format($e_date,"Y-m-d").' 23:59:59';
1584
 
1585
- $date_query = $wpdb->prepare("SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE 1 = 1 AND `cf7_id` = ".$fid." AND `name` = 'submit_time' AND value between '".$start_date."' and '".$end_date."' GROUP BY `data_id` ORDER BY `data_id` DESC");
1586
 
1587
  //print $date_query;
1588
  $rs_date = $wpdb->get_results($date_query);
@@ -1601,14 +1623,23 @@ function create_export_query($fid,$ids_export,$cf7d_entry_order_by){
1601
  }
1602
  $data_ids = rtrim($data_ids,',');
1603
  }
1604
- $search_date_query = "";
1605
- $query = $wpdb->prepare("SELECT * FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = ".$fid." AND data_id IN( SELECT * FROM ( SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE 1 = 1 AND `cf7_id` = ".$fid." ".$search_date_query." ".((!empty($search)) ? " AND `value` LIKE '%%".$search."%%'" : ""). " AND data_id IN (".$data_ids.") GROUP BY `data_id` ORDER BY ".sanitize_sql_orderby($cf7d_entry_order_by).") temp_table) ORDER BY " . sanitize_sql_orderby($cf7d_entry_order_by));
1606
 
1607
  }
1608
  //Not active any filter on listing screen
1609
  else{
1610
 
1611
- $query = $wpdb->prepare("SELECT * FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = ".$fid." AND data_id IN( SELECT * FROM ( SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE 1 = 1 AND `cf7_id` = ".$fid.' '. ((!empty($ids_export)) ? " AND data_id IN(".$ids_export.")" : '')." GROUP BY `data_id` ORDER BY ".sanitize_sql_orderby($cf7d_entry_order_by)." ) temp_table) ORDER BY " . sanitize_sql_orderby($cf7d_entry_order_by));
 
 
 
 
 
 
 
 
 
1612
  }
1613
 
1614
  //Execuste query
40
  */
41
  private $version;
42
 
43
+ /*
44
+ * Define table name for advance Cf 7 DB
45
+ */
46
+ private $vsz_data_entry_table;
47
+
48
  /**
49
  * Initialize the class and set its properties.
50
  *
56
 
57
  $this->plugin_name = $plugin_name;
58
  $this->version = $version;
59
+ $this->vsz_data_entry_table = sanitize_text_field(VSZ_CF7_DATA_ENTRY_TABLE_NAME);
60
 
61
  }
62
 
838
  //Check if field name already exist with entry or not
839
  if(!empty($arr_exist_keys) && in_array($key,$arr_exist_keys)){
840
  //If field name match with current entry then field information update
841
+ $wpdb->query($wpdb->prepare("UPDATE {$this->vsz_data_entry_table} SET `value` = %s WHERE `name` = %s AND `data_id` = %d", sanitize_textarea_field($value), sanitize_text_field($key), $rid));
842
  }
843
  else{
844
  //If field name not match with current entry then new entry insert in DB
845
+ $wpdb->query($wpdb->prepare("INSERT INTO {$this->vsz_data_entry_table}(`cf7_id`, `data_id`, `name`, `value`) VALUES (%d,%d,%s,%s)", $fid, $rid, sanitize_text_field($key), sanitize_textarea_field($value)));
846
  }
847
  }
848
  //Check if field type is text area
850
  //Check if field name already exist with entry or not
851
  if(!empty($arr_exist_keys) && in_array($key,$arr_exist_keys)){
852
  //If field name match with current entry then field information update
853
+ $wpdb->query($wpdb->prepare("UPDATE {$this->vsz_data_entry_table} SET `value` = %s WHERE `name` = %s AND `data_id` = %d", sanitize_textarea_field($value), sanitize_text_field($key), $rid));
854
  }
855
  else{
856
  //If field name not match with current entry then new entry insert in DB
857
+ $wpdb->query($wpdb->prepare("INSERT INTO {$this->vsz_data_entry_table}(`cf7_id`, `data_id`, `name`, `value`) VALUES (%d,%d,%s,%s)", $fid, $rid, sanitize_text_field($key), sanitize_textarea_field($value)));
858
  }
859
 
860
  }//Close text area else if
862
  //Check if field name already exist with entry or not
863
  if(!empty($arr_exist_keys) && in_array($key,$arr_exist_keys)){
864
  //If field name match with current entry then field information update
865
+ $wpdb->query($wpdb->prepare("UPDATE {$this->vsz_data_entry_table} SET `value` = %s WHERE `name` = %s AND `data_id` = %d", sanitize_text_field($value), sanitize_text_field($key), $rid));
866
  }
867
  else{
868
  //If field name not match with current entry then new entry insert in DB
869
+ $wpdb->query($wpdb->prepare("INSERT INTO {$this->vsz_data_entry_table}(`cf7_id`, `data_id`, `name`, `value`) VALUES (%d,%d,%s,%s)", $fid, $rid, sanitize_text_field($key), sanitize_text_field($value)));
870
  }
871
  }//Close else
872
  }//Close foreach
1012
  //If entry not empty
1013
  if(!empty($rid)){
1014
  //Get entry related all fields information
1015
+ $sql = $wpdb->prepare("SELECT * FROM {$this->vsz_data_entry_table} WHERE `data_id` = %d", $rid);
1016
  $rows = $wpdb->get_results($sql);
1017
  $return = array();
1018
  //Set all fields name in array
1555
  }
1556
 
1557
  $cf7d_entry_order_by = sanitize_sql_orderby($cf7d_entry_order_by);
1558
+ //Get table name for data entry
1559
+ $table_name = sanitize_text_field(VSZ_CF7_DATA_ENTRY_TABLE_NAME);
1560
 
1561
  //Create Export Query on the basis of Listing screen filter
1562
 
1564
  if(isset($_POST['search_cf7_value']) && !empty($_POST['search_cf7_value']) && isset($_POST['start_date']) && isset($_POST['end_date']) && empty($_POST['start_date']) && empty($_POST['end_date'])){
1565
 
1566
  $search = sanitize_text_field($_POST['search_cf7_value']);
1567
+
1568
+ if(!empty($search) && !empty($ids_export)){
1569
+ $query = $wpdb->prepare("SELECT * FROM `{$table_name}` WHERE `cf7_id` = %d AND data_id IN(SELECT * FROM (SELECT data_id FROM `{$table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND `value` LIKE '%%"."%s"."%%' AND data_id IN({$ids_export}) GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} ) temp_table) ORDER BY {$cf7d_entry_order_by}", $fid, $fid, $search);
1570
+
1571
+ }else if(!empty($search) && empty($ids_export)){
1572
+ $query = $wpdb->prepare("SELECT * FROM `{$table_name}` WHERE `cf7_id` = %d AND data_id IN(SELECT * FROM (SELECT data_id FROM `{$table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND `value` LIKE '%%"."%s"."%%' GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} ) temp_table) ORDER BY {$cf7d_entry_order_by}" , $fid, $fid, $search);
1573
+ }
1574
  }
1575
  //Check date wise filter active or not
1576
  else if(isset($_POST['search_cf7_value']) && empty($_POST['search_cf7_value']) && isset($_POST['start_date']) && isset($_POST['end_date']) && !empty($_POST['start_date']) && !empty($_POST['end_date']) && $s_date !== false && $e_date !== false){
1579
  $start_date = date_format($s_date,"Y-m-d");
1580
 
1581
  //Get end date information
1582
+ $end_date = date_format($e_date,"Y-m-d")." 23:59:59";
1583
+
1584
+ if(!empty($ids_export)){
1585
+
1586
+ $query = $wpdb->prepare("SELECT * FROM `{$table_name}` WHERE `cf7_id` = %d AND data_id IN( SELECT * FROM ( SELECT data_id FROM `{$table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND `name` = 'submit_time' AND value between %s and %s AND data_id IN({$ids_export}) GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} ) temp_table) ORDER BY {$cf7d_entry_order_by}", $fid, $fid, $start_date, $end_date);
1587
+
1588
+ }else if(empty($ids_export)){
1589
+
1590
+ $query = $wpdb->prepare("SELECT * FROM `{$table_name}` WHERE `cf7_id` = %d AND data_id IN( SELECT * FROM ( SELECT data_id FROM `{$table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND `name` = 'submit_time' AND value between %s and %s GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} ) temp_table) ORDER BY {$cf7d_entry_order_by}", $fid, $fid, $start_date, $end_date);
1591
+
1592
+ }
1593
 
 
1594
 
 
1595
  }
1596
  //Check search and date wise filter active or not
1597
  else if(isset($_POST['search_cf7_value']) && !empty($_POST['search_cf7_value']) && isset($_POST['start_date']) && isset($_POST['end_date']) && !empty($_POST['start_date']) && !empty($_POST['end_date']) && $s_date !== false && $e_date !== false){
1604
  //Get end date information
1605
  $end_date = date_format($e_date,"Y-m-d").' 23:59:59';
1606
 
1607
+ $date_query = $wpdb->prepare("SELECT data_id FROM `{$table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND `name` = 'submit_time' AND value between %s and %s GROUP BY `data_id` ORDER BY `data_id` DESC", $fid, $start_date, $end_date);
1608
 
1609
  //print $date_query;
1610
  $rs_date = $wpdb->get_results($date_query);
1623
  }
1624
  $data_ids = rtrim($data_ids,',');
1625
  }
1626
+
1627
+ $query = $wpdb->prepare("SELECT * FROM `{$table_name}` WHERE `cf7_id` = %d AND data_id IN( SELECT * FROM ( SELECT data_id FROM `{$table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND `value` LIKE '%%"."%s"."%%' AND data_id IN ({$data_ids}) GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by}) temp_table) ORDER BY {$cf7d_entry_order_by}", $fid, $fid, $search);
1628
 
1629
  }
1630
  //Not active any filter on listing screen
1631
  else{
1632
 
1633
+ if(!empty($ids_export)){
1634
+
1635
+ $query = $wpdb->prepare("SELECT * FROM `{$table_name}` WHERE `cf7_id` = %d AND data_id IN( SELECT * FROM ( SELECT data_id FROM `{$table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND data_id IN({$ids_export}) GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} ) temp_table) ORDER BY {$cf7d_entry_order_by}", $fid, $fid);
1636
+
1637
+ }else{
1638
+
1639
+ $query = $wpdb->prepare("SELECT * FROM `{$table_name}` WHERE `cf7_id` = %d AND data_id IN( SELECT * FROM ( SELECT data_id FROM `{$table_name}` WHERE 1 = 1 AND `cf7_id` = %d GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} ) temp_table) ORDER BY {$cf7d_entry_order_by}", $fid, $fid);
1640
+
1641
+ }
1642
+
1643
  }
1644
 
1645
  //Execuste query
admin/partials/contact_form_listing.php CHANGED
@@ -1,456 +1,482 @@
1
- <?php
2
- // Exit if accessed directly
3
- if ( !defined( 'ABSPATH' ) ) {
4
- die('Un-authorized access!');
5
- }
6
-
7
- /**
8
- * Detect plugin. For use in Admin area only.
9
- */
10
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
11
-
12
- //Check contact form class exist or not
13
- if(!is_plugin_active('contact-form-7/wp-contact-form-7.php')){
14
- ?><div class="notice error is-dismissible">
15
- <p><?php esc_html_e('Please activate Contact Form plugin first.',VSZ_CF7_TEXT_DOMAIN); ?></p>
16
- </div><?php
17
- }
18
- else if(defined('WPCF7_VERSION') && WPCF7_VERSION < '4.6'){
19
- ?><div class="notice error is-dismissible">
20
- <p><?php esc_html_e('Please update latest version for Contact Form plugin first.',VSZ_CF7_TEXT_DOMAIN); ?></p>
21
- </div><?php
22
- }
23
- else{
24
-
25
- //enqueue date time picker CSS in file
26
- wp_enqueue_style('jquery-datetimepicker-css');
27
-
28
- wp_enqueue_style('font_awesome_css');
29
-
30
- //enqueue Sortable JS in file
31
- wp_enqueue_script('jquery-ui-sortable');
32
-
33
- wp_enqueue_script('advanced_cf7_db_admin_js');
34
- wp_enqueue_script('datepicker_min_js');
35
-
36
- //Get all existing contact form list
37
- $form_list = vsz_cf7_get_the_form_list();
38
- $url = '';
39
- $fid = '';
40
-
41
- //Get selected form Id value
42
- if(isset($_GET['cf7_id']) && !empty($_GET['cf7_id'])){
43
- $edit = false;
44
- $entry_actions = array();
45
- $fid = intval(sanitize_text_field($_GET['cf7_id']));
46
- if (!cf7_check_capability('cf7_db_form_view'.$fid) && !cf7_check_capability('cf7_db_form_edit_'.$fid)){
47
- wp_die( __('You do not have sufficient permissions to access this page.') );
48
- }
49
- if(cf7_check_capability('cf7_db_form_edit_'.$fid)){
50
- $edit = true;
51
- $entry_actions = array(
52
- 'delete' => 'Delete'
53
- );
54
- }
55
-
56
- $menu_url = menu_page_url('contact-form-listing',false);
57
- $url = $menu_url.'&cf7_id='.$fid;
58
- }
59
-
60
- //Get search related value
61
- $search = '';
62
- if(isset($_POST['search_cf7_value']) && !empty($_POST['search_cf7_value'])){
63
- $search = addslashes(addslashes(htmlspecialchars(sanitize_text_field($_POST['search_cf7_value']))));
64
- }
65
-
66
- //Get all form names which entry store in DB
67
- global $wpdb;
68
- $sql = "SELECT `cf7_id` FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` GROUP BY `cf7_id`";
69
- $data = $wpdb->get_results($sql,ARRAY_N);
70
- $arr_form_id = array();
71
- if(!empty($data)){
72
- foreach($data as $arrVal){
73
- $arr_form_id[] = (int)$arrVal[0];
74
- }
75
- }
76
-
77
- ?><div class="wrap">
78
- <h2><?php
79
- esc_html_e('View Form Information',VSZ_CF7_TEXT_DOMAIN);
80
- ?></h2>
81
- </div>
82
- <div class="wrap select-specific">
83
- <table class="form-table inner-row">
84
- <tr class="form-field form-required select-form">
85
- <th><?php esc_html_e('Select Form name',VSZ_CF7_TEXT_DOMAIN); ?></th>
86
- <td>
87
- <form name="cf7_name" id="cf7_name" action="<?php menu_page_url('contact-form-listing');?>" method="">
88
- <select name="cf7_id" id="cf7_id" onchange="submit_cf7()">
89
- <option value=""><?php esc_html_e('Select Form name',VSZ_CF7_TEXT_DOMAIN); ?></option><?php
90
- //Display all existing form list here
91
- $exist_entry_flag = false;
92
- if(!empty($form_list)){
93
-
94
- foreach($form_list as $objForm){
95
- if(!empty($arr_form_id) && in_array($objForm->id(),$arr_form_id)){
96
- $exist_entry_flag = true;
97
- if (cf7_check_capability('cf7_db_form_view'.$objForm->id()) || cf7_check_capability('cf7_db_form_edit_'.$objForm->id()) ){
98
- if(!empty($fid) && $fid === $objForm->id())
99
- print '<option value="'.$objForm->id().'" selected>'.esc_html($objForm->title()).'</option>';
100
- else
101
- print '<option value="'.$objForm->id().'" >'.esc_html($objForm->title()).'</option>';
102
- }
103
- }//Close if
104
- }//close for each
105
- }//close if
106
- ?></select>
107
- </form>
108
- </td>
109
- </tr>
110
- </table>
111
- </div><?php
112
-
113
- //Get form Id related fields information
114
- $fields = vsz_cf7_get_db_fields($fid);
115
-
116
- //Check contact form id set or not
117
- if (!empty($fid) && !empty($fields)){
118
-
119
- //Add filter for ordering in entry
120
- $cf7d_entry_order_by = (string) apply_filters('vsz_cf7_entry_order_by', '`data_id` DESC');
121
- $cf7d_entry_order_by = sanitize_sql_orderby($cf7d_entry_order_by);
122
-
123
- $start_date = '';
124
- $end_date = '';
125
- $search_date_query = '';
126
-
127
- //Get post per page value from general setting screen
128
- $show_record = '';
129
- $show_record = get_option('vsz_cf7_settings_show_record_' . $fid, array());
130
- if(empty($show_record)){
131
- $show_record = 10;
132
- }
133
- $posts_per_page = $show_record;
134
- //Add post per page filter here , Any user call this filter and customize post per page count
135
- $items_per_page = (int)apply_filters('vsz_cf7_entry_per_page', (!empty($posts_per_page) ? $posts_per_page : 10));
136
- //Get current page information from query
137
- $page = isset($_POST['cpage']) && !empty($_POST['cpage']) ? abs((int)sanitize_text_field($_POST['cpage'])) : 1;
138
- //Setup offset related value here
139
- $offset = (int)( $page * $items_per_page ) - $items_per_page;
140
- //Customize parameter wise listing screen query
141
-
142
- //Check start and end date is valid or not
143
- if(isset($_POST['start_date']) && isset($_POST['end_date']) && !empty($_POST['start_date']) && !empty($_POST['end_date'])){
144
- $s_date = date_create_from_format("d/m/Y",sanitize_text_field($_POST['start_date']));
145
- $e_date = date_create_from_format("d/m/Y",sanitize_text_field($_POST['end_date']));
146
- }
147
- else{
148
- $s_date = false;
149
- $e_date = false;
150
- }
151
-
152
-
153
-
154
- //Check search field value empty or not
155
- if(isset($_POST['search_cf7_value']) && !empty($_POST['search_cf7_value']) && isset($_POST['start_date']) && isset($_POST['end_date']) && empty($_POST['start_date']) && empty($_POST['end_date'])){
156
-
157
- $query = $wpdb->prepare("SELECT * FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = ".$fid." AND data_id IN( SELECT * FROM ( SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE 1 = 1 AND `cf7_id` = %d AND `value` LIKE '%%".'%s'."%%' GROUP BY `data_id` ORDER BY ".sanitize_sql_orderby($cf7d_entry_order_by)." LIMIT ".$offset.",".$items_per_page." ) temp_table) ORDER BY " . sanitize_sql_orderby($cf7d_entry_order_by), (int)$fid, $search );
158
-
159
- $arr_total = $wpdb->get_results($wpdb->prepare("SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = %d AND `value` LIKE '%%".'%s'."%%' GROUP BY `data_id`", (int)$fid, $search ));
160
- }
161
- //Check search field value empty and date filter active or not
162
- else if(isset($_POST['search_cf7_value']) && empty($_POST['search_cf7_value']) && isset($_POST['start_date']) && isset($_POST['end_date']) && !empty($_POST['start_date']) && !empty($_POST['end_date']) && $s_date !== false && $e_date !== false){
163
-
164
- //Get start date information
165
- $start_date = date_format($s_date,"Y-m-d");
166
-
167
- //Get end date information
168
- $end_date = date_format($e_date,"Y-m-d");
169
- $query_end_date = $end_date." 23:59:59";
170
-
171
- $query = $wpdb->prepare("SELECT * FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = ".$fid." AND data_id IN( SELECT * FROM ( SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE 1 = 1 AND `cf7_id` = ".$fid." AND `name` = 'submit_time' AND value between '".'%s'."' and '".'%s'."' GROUP BY `data_id` ORDER BY ".sanitize_sql_orderby($cf7d_entry_order_by)." LIMIT ".$offset.",".$items_per_page." ) temp_table) ORDER BY " . sanitize_sql_orderby($cf7d_entry_order_by), $start_date, $query_end_date);
172
-
173
- //Get total entries information
174
- $total_query = $wpdb->prepare("SELECT * FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = ".$fid." AND data_id IN( SELECT * FROM ( SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE 1 = 1 AND `cf7_id` = ".$fid." AND `name` = 'submit_time' AND value between '".'%s'."' and '".'%s'."' GROUP BY `data_id` ORDER BY ".sanitize_sql_orderby($cf7d_entry_order_by)." ) temp_table) GROUP BY `data_id` ORDER BY " . sanitize_sql_orderby($cf7d_entry_order_by), $start_date, $query_end_date );
175
-
176
- $arr_total = $wpdb->get_results($total_query);
177
- }
178
- //Check search field value not empty and date filter active or not
179
- else if(isset($_POST['search_cf7_value']) && !empty($_POST['search_cf7_value']) && isset($_POST['start_date']) && isset($_POST['end_date']) && !empty($_POST['start_date']) && !empty($_POST['end_date']) && $s_date !== false && $e_date !== false){
180
-
181
-
182
- //Get start date information
183
- $start_date = date_format($s_date,"Y-m-d");
184
-
185
- //Get end date information
186
- $end_date = date_format($e_date,"Y-m-d").' 23:59:59';
187
-
188
- //Get date filter related entries information
189
- $date_query = $wpdb->prepare("SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE 1 = 1 AND `cf7_id` = ".$fid." AND `name` = 'submit_time' AND value between '".'%s'."' and '".'%s'."' GROUP BY `data_id` ORDER BY `data_id` DESC", $start_date, $end_date);
190
-
191
- $rs_date = $wpdb->get_results($date_query);
192
- //Get all entries and setup a string
193
- $data_ids = '';
194
- if(!empty($rs_date)){
195
- foreach($rs_date as $objdata_id){
196
- $data_ids .= $objdata_id->data_id .',';
197
- }
198
- $data_ids = rtrim($data_ids,',');
199
- }
200
-
201
- //get all entrise information
202
- $query = $wpdb->prepare("SELECT * FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = ".$fid." AND data_id IN( SELECT * FROM ( SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE 1 = 1 AND `cf7_id` = ".$fid." ".$search_date_query." AND `value` LIKE '%%".'%s'."%%' AND data_id IN (".$data_ids.") GROUP BY `data_id` ORDER BY ".sanitize_sql_orderby($cf7d_entry_order_by)." LIMIT ".$offset.",".$items_per_page." ) temp_table) ORDER BY " . sanitize_sql_orderby($cf7d_entry_order_by), $search);
203
-
204
- //Get total entries information
205
- $total_query = $wpdb->prepare("SELECT * FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = ".$fid." AND data_id IN( SELECT * FROM ( SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE 1 = 1 AND `cf7_id` = ".$fid." ".$search_date_query." AND `value` LIKE '%%".'%s'."%%' AND data_id IN (".$data_ids.") GROUP BY `data_id` ORDER BY ".sanitize_sql_orderby($cf7d_entry_order_by)." ) temp_table) GROUP BY `data_id` ORDER BY " . sanitize_sql_orderby($cf7d_entry_order_by),$search);
206
-
207
- $arr_total = $wpdb->get_results($total_query);
208
-
209
- }
210
- //Call when any filter not active on Listing screen
211
- else{
212
- if(isset($_GET["orderby"]) && isset($_GET["order"]) && !empty($_GET["orderby"]) && !empty($_GET["order"]) && (strtolower($_GET["order"]) == 'asc' || strtolower($_GET["order"]) == 'desc')){
213
-
214
- $order = esc_sql(sanitize_text_field($_GET['order']));
215
- $orderby = sanitize_sql_orderby($_GET['orderby']);
216
- $qry = $wpdb->prepare("SELECT `data_id` FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = ".$fid." AND `name` = '".sanitize_sql_orderby($orderby)."' AND data_id IN( SELECT * FROM ( SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE 1 = 1 AND `cf7_id` = ".$fid." GROUP BY `data_id` ORDER BY ".sanitize_sql_orderby($cf7d_entry_order_by)." LIMIT ".$offset.",".$items_per_page." ) temp_table) ORDER BY `value` ".$order."," . sanitize_sql_orderby($cf7d_entry_order_by));
217
- $idVals = $wpdb->get_results ( $qry );
218
-
219
- $id_val = array();
220
- if(!empty($idVals)){
221
- foreach($idVals as $o_id){
222
- $id_val[] = $o_id->data_id;
223
- }
224
- }
225
-
226
- $query = $wpdb->prepare("SELECT * FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = ".$fid." AND data_id IN( SELECT * FROM ( SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE 1 = 1 AND `cf7_id` = ".$fid." GROUP BY `data_id` ORDER BY ".sanitize_sql_orderby($cf7d_entry_order_by)." LIMIT ".$offset.",".$items_per_page." ) temp_table) ORDER BY FIELD(`data_id`, ". implode(',',$id_val) ." )");
227
-
228
- }
229
- else{
230
- $query = $wpdb->prepare("SELECT * FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = ".$fid." AND data_id IN( SELECT * FROM ( SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE 1 = 1 AND `cf7_id` = ".$fid." GROUP BY `data_id` ORDER BY ".sanitize_sql_orderby($cf7d_entry_order_by)." LIMIT ".$offset.",".$items_per_page." ) temp_table) ORDER BY " . sanitize_sql_orderby($cf7d_entry_order_by));
231
- }
232
-
233
- //Get total entries information
234
- if(!empty($search)){
235
- $arr_total = $wpdb->get_results($wpdb->prepare("SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = " .$fid . " AND `value` LIKE '%%".'%s'."%%' GROUP BY `data_id`", $search));
236
- }else{
237
- $arr_total = $wpdb->get_results($wpdb->prepare("SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = " .$fid . " GROUP BY `data_id`"));
238
- }
239
- }
240
-
241
-
242
- //Execute query here
243
- $data = $wpdb->get_results($query);
244
-
245
- //Get entry wise all fields information
246
- $data_sorted = vsz_cf7_sortdata($data);
247
-
248
- //get total count
249
- $total = count($arr_total);
250
-
251
- //Define bulk action array
252
-
253
- //Add filter for customize bulk action values
254
- $entry_actions = (array) apply_filters('vsz_cf7_entry_actions', $entry_actions);
255
-
256
- //define nonce for get entry details
257
- $getDatanonce = wp_create_nonce( 'vsz-cf7-get-entry-nonce-'.$fid );
258
-
259
- //Form listing design structure start here
260
- ?><div class="wrap our-class">
261
- <form class="vsz-cf7-listing row" action="<?php print esc_url($url);?>" method="post" id="cf7d-admin-action-frm" >
262
- <input type="hidden" name="page" value="contact-form-listing">
263
- <input type="hidden" name="fid" value="<?php echo esc_html($fid); ?>">
264
- <input type="hidden" name="_wpnonce" value="<?php echo esc_html(wp_create_nonce('vsz-cf7-action-nonce')); ?>"><?php
265
- //Display setting screen button
266
- do_action('vsz_cf7_display_settings_btn', $fid);
267
- ?><div class="span12">
268
- <div class="date-filter from-to" style="display:block;">
269
- <div class="from-to-date-search">
270
- <input type="text" name="start_date" id="start_date" placeholder="From" value="<?php print isset($_POST['start_date']) ? esc_attr(sanitize_text_field($_POST['start_date'])) : '';?>" class="input-cf-date">
271
- <input type="text" name="end_date" id="end_date" placeholder="To" value="<?php print isset($_POST['end_date']) ? esc_attr(sanitize_text_field($_POST['end_date'])) : '';?>" class="input-cf-date" >
272
- <input type="button" name="search_date" id="search_date" value="<?php esc_html_e('Search By Date',VSZ_CF7_TEXT_DOMAIN); ?>" title="<?php esc_html_e('Search By Date',VSZ_CF7_TEXT_DOMAIN); ?>" class="button action" >
273
- </div>
274
- <div class="type-something"><?php
275
- //Display Search section here
276
- do_action('vsz_cf7_after_datesection_btn', $fid);
277
- ?></div>
278
- <div class="reset-class"><a href="<?php print esc_url($url);?>" title="<?php esc_html_e('Reset All',VSZ_CF7_TEXT_DOMAIN); ?>" class="button"><?php esc_html_e('Reset All',VSZ_CF7_TEXT_DOMAIN); ?></a></div>
279
- </div>
280
- <div class="clear"></div>
281
- </div>
282
- <div class="span12 bulk-actions">
283
- <div class="tablenav top">
284
- <div class="actions bulkactions">
285
- <label for="bulk-action-selector-top" class="screen-reader-text"><?php esc_html_e('Select bulk action',VSZ_CF7_TEXT_DOMAIN); ?></label>
286
- <select name="action" id="bulk-action-selector-top">
287
- <option value="-1"><?php esc_html_e('Bulk Actions',VSZ_CF7_TEXT_DOMAIN); ?></option><?php
288
- //Get all bulk action values
289
- echo vsz_cf7_arr_to_option($entry_actions);
290
- ?></select>
291
- <input id="doaction" name="btn_apply" class="button action" value="<?php _e('Apply',VSZ_CF7_TEXT_DOMAIN); ?>" title="<?php _e('Apply',VSZ_CF7_TEXT_DOMAIN); ?>" type="submit" /><?php
292
- //Display Export button option values
293
- do_action('vsz_cf7_after_bulkaction_btn', $fid);
294
- ?><div class="tablenav-pages">
295
- <span class="displaying-num"><?php echo (($total == 1) ?
296
- '1 ' . __('item') :
297
- $total . ' ' . __('items')) ?></span>
298
- <span class="pagination-links"><?php
299
- //Setup pagination structure
300
- print ( paginate_links(array(
301
- 'base' => add_query_arg('cpage', '%#%'),
302
- 'format' => '',
303
- 'prev_text' => __('&laquo;'),
304
- 'next_text' => __('&raquo;'),
305
- 'total' => ceil($total / $items_per_page),
306
- 'current' => $page,
307
- )));
308
-
309
-
310
- ?></span>
311
- </div>
312
- </div>
313
- <br class="clear">
314
- </div>
315
- </div>
316
- <div class="span12 table-structure">
317
- <div class="table-inner-structure">
318
- <table class="wp-list-table widefat fixed striped posts cf7d-admin-table">
319
- <thead>
320
- <tr><?php
321
- echo '<td id="cb" class="manage-column column-cb check-column"><input type="checkbox" id="cb-select-all-1" /></td>';
322
- //Display Edit headion field
323
- if($edit == true){
324
- do_action('vsz_cf7_admin_after_heading_field');
325
- }
326
- //Define table header section here
327
- foreach ($fields as $k => $v){
328
- echo '<th class="manage-column" data-key="'.esc_html($v).'">'.vsz_cf7_admin_get_field_name($v).'</th>';
329
- }
330
- ?></tr>
331
- </thead>
332
- <tbody><?php
333
- //Add character count functionalirty here
334
- $display_character = (int) apply_filters('vsz_display_character_count',30);
335
- $arr_field_type_info = vsz_field_type_info($fid);
336
-
337
- //Get all fields related information
338
- if(!empty($data_sorted)){
339
- foreach ($data_sorted as $k => $v) {
340
- $k = (int)$k;
341
- echo '<tr>';
342
- echo '<th class="check-column" scope="row"><input id="cb-select-'.esc_html($k).'" type="checkbox" title="Check" name="del_id[]" value="'.esc_html($k).'" /></th>';
343
- $row_id = $k;
344
- //Display edit entry icon
345
- if($edit == true){
346
- do_action('vsz_cf7_admin_after_body_field', $fid, $row_id,$getDatanonce);
347
- }
348
- foreach ($fields as $k2 => $v2) {
349
- //Get fields related values
350
- $_value = ((isset($v[$k2])) ? $v[$k2] : '&nbsp;');
351
- $_value1 = filter_var($_value, FILTER_SANITIZE_URL);
352
-
353
- //Check value is URL or not
354
- if (!filter_var($_value1, FILTER_VALIDATE_URL) === false) {
355
- $_value = esc_url($_value);
356
- //If value is url then setup anchor tag with value
357
- if(!empty($arr_field_type_info) && array_key_exists($k2,$arr_field_type_info) && $arr_field_type_info[$k2] == 'file'){
358
- //Add download attributes in tag if field type is attachement
359
- ?><td data-head="<?php echo vsz_cf7_admin_get_field_name($v2); ?>">
360
- <a href="<?php echo esc_url($_value); ?>" target="_blank" title="<?php echo esc_url($_value); ?>" download ><?php echo esc_html(basename($_value)); ?>
361
- </a>
362
- </td><?php
363
- }
364
- else{
365
- ?><td data-head="<?php echo vsz_cf7_admin_get_field_name($v2); ?>">
366
- <a href="<?php echo esc_url($_value); ?>" target="_blank" title="<?php echo esc_url($_value); ?>" ><?php echo esc_html(basename($_value)); ?>
367
- </a>
368
- </td><?php
369
- }
370
- }
371
- else{
372
- $_value = esc_html(html_entity_decode($_value));
373
- //var_dump(($_value)); var_dump(strlen($_value)); exit;
374
- if(strlen($_value) > $display_character){
375
-
376
- echo '<td data-head="'.vsz_cf7_admin_get_field_name($v2).'">'.esc_html(substr($_value, 0, $display_character)).'...</td>';
377
- }else{
378
- echo '<td data-head="'.vsz_cf7_admin_get_field_name($v2).'">'.esc_html($_value).'</td>';
379
- }
380
- }
381
- }//Close foreach
382
- echo '</tr>';
383
- }//Close foreach
384
- }
385
- else{
386
- ?><tr><?php
387
- $span = count($fields) + 2;
388
- ?><td colspan="<?php echo esc_html($span); ?>">
389
- <?php esc_html_e('No records found.',VSZ_CF7_TEXT_DOMAIN); ?>
390
- </td><?php
391
- ?></tr><?php
392
- }
393
- ?></tbody>
394
- <tfoot>
395
- <tr><?php
396
- //Setup header section in table footer area
397
- echo '<td class="manage-column column-cb check-column"><input type="checkbox" id="cb-select-all-2" /></td>';
398
- if($edit == true){
399
- do_action('vsz_cf7_admin_after_heading_field');
400
- }
401
- foreach ($fields as $k => $v){
402
- echo '<th class="manage-column" data-key="'.esc_html($v).'">'.vsz_cf7_admin_get_field_name($v).'</th>';
403
- }
404
- ?></tr>
405
- </tfoot>
406
- </table>
407
- </div>
408
- </div>
409
-
410
- <input type="hidden" name="cpage" value="<?php echo intval($page);?>" id="cpage">
411
- <input type="hidden" name="totalPage" value="<?php print ceil($total / $items_per_page);?>" id="totalPage">
412
- </form>
413
- <script>
414
- //Setup pagination related functionality when click on page link then form submitted
415
- jQuery(".pagination-links a").on('click',function(){
416
- var final_id;
417
- var url = jQuery(this).attr('href');
418
- var id_check = /[?&]cpage=([^&]+)/i;
419
- var match = id_check.exec(url);
420
- if(match != null){
421
- final_id = parseInt(match[1]);
422
- }
423
- if(final_id != ''){
424
- jQuery(this).attr("href","javascript:void(0)");
425
- jQuery('#cpage').val(final_id);
426
- document.getElementById('cf7d-admin-action-frm').submit();
427
- }
428
- });
429
-
430
- //Add custom class in body tag when click on Setting button
431
- jQuery('#cf7d_setting_form').click(function(){
432
- jQuery('body').addClass('our-body-class');
433
- });
434
- //Updating record
435
- jQuery(document).on('click','#update_cf7_value',function(){
436
- var filterdata = jQuery('.vsz-cf7-listing').html();
437
- jQuery('.cf7d-modal-form').append('<div style="display:none">'+filterdata+'</div>');
438
-
439
- });
440
-
441
- </script>
442
- </div><?php
443
- //Define setting and Edit popup call back function
444
- do_action('vsz_cf7_after_admin_form',$fid);
445
- }//Close if for check form id empty or not
446
- else if(!$exist_entry_flag){
447
-
448
- //added in 1.8.4
449
- ?><div class="popup-note">
450
- <span><?php
451
- esc_html_e('Currently not submission any form data.',VSZ_CF7_TEXT_DOMAIN);
452
- ?></span>
453
- </div><?php
454
-
455
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
456
  }
1
+ <?php
2
+ // Exit if accessed directly
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ die('Un-authorized access!');
5
+ }
6
+
7
+ /**
8
+ * Detect plugin. For use in Admin area only.
9
+ */
10
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
11
+
12
+ //Check contact form class exist or not
13
+ if(!is_plugin_active('contact-form-7/wp-contact-form-7.php')){
14
+ ?><div class="notice error is-dismissible">
15
+ <p><?php esc_html_e('Please activate Contact Form plugin first.',VSZ_CF7_TEXT_DOMAIN); ?></p>
16
+ </div><?php
17
+ }
18
+ else if(defined('WPCF7_VERSION') && WPCF7_VERSION < '4.6'){
19
+ ?><div class="notice error is-dismissible">
20
+ <p><?php esc_html_e('Please update latest version for Contact Form plugin first.',VSZ_CF7_TEXT_DOMAIN); ?></p>
21
+ </div><?php
22
+ }
23
+ else{
24
+
25
+ //enqueue date time picker CSS in file
26
+ wp_enqueue_style('jquery-datetimepicker-css');
27
+
28
+ wp_enqueue_style('font_awesome_css');
29
+
30
+ //enqueue Sortable JS in file
31
+ wp_enqueue_script('jquery-ui-sortable');
32
+
33
+ wp_enqueue_script('advanced_cf7_db_admin_js');
34
+ wp_enqueue_script('datepicker_min_js');
35
+
36
+ //Get all existing contact form list
37
+ $form_list = vsz_cf7_get_the_form_list();
38
+ $url = '';
39
+ $fid = '';
40
+
41
+ //Get selected form Id value
42
+ if(isset($_GET['cf7_id']) && !empty($_GET['cf7_id'])){
43
+ $edit = false;
44
+ $entry_actions = array();
45
+ $fid = intval(sanitize_text_field($_GET['cf7_id']));
46
+ if (!cf7_check_capability('cf7_db_form_view'.$fid) && !cf7_check_capability('cf7_db_form_edit_'.$fid)){
47
+ wp_die( __('You do not have sufficient permissions to access this page.') );
48
+ }
49
+ if(cf7_check_capability('cf7_db_form_edit_'.$fid)){
50
+ $edit = true;
51
+ $entry_actions = array(
52
+ 'delete' => 'Delete'
53
+ );
54
+ }
55
+
56
+ $menu_url = menu_page_url('contact-form-listing',false);
57
+ $url = $menu_url.'&cf7_id='.$fid;
58
+ }
59
+
60
+ //Get search related value
61
+ $search = '';
62
+ if(isset($_POST['search_cf7_value']) && !empty($_POST['search_cf7_value'])){
63
+ $search = addslashes(addslashes(htmlspecialchars(sanitize_text_field($_POST['search_cf7_value']))));
64
+ }
65
+
66
+ //Get all form names which entry store in DB
67
+ global $wpdb;
68
+ //Get table name for data entry
69
+ $data_entry_table_name = sanitize_text_field(VSZ_CF7_DATA_ENTRY_TABLE_NAME);
70
+
71
+ $sql = "SELECT `cf7_id` FROM `{$data_entry_table_name}` GROUP BY `cf7_id`";
72
+ $data = $wpdb->get_results($sql,ARRAY_N);
73
+ $arr_form_id = array();
74
+ if(!empty($data)){
75
+ foreach($data as $arrVal){
76
+ $arr_form_id[] = (int)$arrVal[0];
77
+ }
78
+ }
79
+
80
+ ?><div class="wrap">
81
+ <h2><?php
82
+ esc_html_e('View Form Information',VSZ_CF7_TEXT_DOMAIN);
83
+ ?></h2>
84
+ </div>
85
+ <div class="wrap select-specific">
86
+ <table class="form-table inner-row">
87
+ <tr class="form-field form-required select-form">
88
+ <th><?php esc_html_e('Select Form name',VSZ_CF7_TEXT_DOMAIN); ?></th>
89
+ <td>
90
+ <form name="cf7_name" id="cf7_name" action="<?php menu_page_url('contact-form-listing');?>" method="">
91
+ <select name="cf7_id" id="cf7_id" onchange="submit_cf7()">
92
+ <option value=""><?php esc_html_e('Select Form name',VSZ_CF7_TEXT_DOMAIN); ?></option><?php
93
+ //Display all existing form list here
94
+ $exist_entry_flag = false;
95
+ if(!empty($form_list)){
96
+
97
+ foreach($form_list as $objForm){
98
+ if(!empty($arr_form_id) && in_array($objForm->id(),$arr_form_id)){
99
+ $exist_entry_flag = true;
100
+ if (cf7_check_capability('cf7_db_form_view'.$objForm->id()) || cf7_check_capability('cf7_db_form_edit_'.$objForm->id()) ){
101
+ if(!empty($fid) && $fid === $objForm->id())
102
+ print '<option value="'.$objForm->id().'" selected>'.esc_html($objForm->title()).'</option>';
103
+ else
104
+ print '<option value="'.$objForm->id().'" >'.esc_html($objForm->title()).'</option>';
105
+ }
106
+ }//Close if
107
+ }//close for each
108
+ }//close if
109
+ ?></select>
110
+ </form>
111
+ </td>
112
+ </tr>
113
+ </table>
114
+ </div><?php
115
+
116
+ //Get form Id related fields information
117
+ $fields = vsz_cf7_get_db_fields($fid);
118
+
119
+ //Check contact form id set or not
120
+ if (!empty($fid) && empty($fields)){
121
+ ?>
122
+ <div class="wrap our-class">
123
+ <form class="vsz-cf7-listing row" action="<?php print esc_url($url);?>" method="post" id="cf7d-admin-action-frm" >
124
+ <input type="hidden" name="_wpnonce" value="<?php echo esc_html(wp_create_nonce('vsz-cf7-action-nonce')); ?>">
125
+ <?php
126
+ //Display setting screen button
127
+ do_action('vsz_cf7_display_settings_btn', $fid);
128
+ ?>
129
+ </form>
130
+ </div>
131
+ <?php
132
+ //Define setting and Edit popup call back function
133
+ do_action('vsz_cf7_after_admin_form',$fid);
134
+ }else if (!empty($fid) && !empty($fields)){
135
+
136
+ // Make sure that $fid will contain integer value only.
137
+ $fid = (int) $fid;
138
+
139
+ //Add filter for ordering in entry
140
+ $cf7d_entry_order_by = (string) apply_filters('vsz_cf7_entry_order_by', '`data_id` DESC');
141
+ $cf7d_entry_order_by = sanitize_sql_orderby($cf7d_entry_order_by);
142
+
143
+ $start_date = '';
144
+ $end_date = '';
145
+ $search_date_query = '';
146
+
147
+ //Get post per page value from general setting screen
148
+ $show_record = '';
149
+ $show_record = get_option('vsz_cf7_settings_show_record_' . $fid, array());
150
+ if(empty($show_record)){
151
+ $show_record = 10;
152
+ }
153
+ $posts_per_page = $show_record;
154
+ //Add post per page filter here , Any user call this filter and customize post per page count
155
+ $items_per_page = (int)apply_filters('vsz_cf7_entry_per_page', (!empty($posts_per_page) ? $posts_per_page : 10));
156
+ //Get current page information from query
157
+ $page = isset($_POST['cpage']) && !empty($_POST['cpage']) ? abs((int)sanitize_text_field($_POST['cpage'])) : 1;
158
+ //Setup offset related value here
159
+ $offset = (int)( $page * $items_per_page ) - $items_per_page;
160
+ //Customize parameter wise listing screen query
161
+
162
+ //Check start and end date is valid or not
163
+ if(isset($_POST['start_date']) && isset($_POST['end_date']) && !empty($_POST['start_date']) && !empty($_POST['end_date'])){
164
+ $s_date = date_create_from_format("d/m/Y",sanitize_text_field($_POST['start_date']));
165
+ $e_date = date_create_from_format("d/m/Y",sanitize_text_field($_POST['end_date']));
166
+ }
167
+ else{
168
+ $s_date = false;
169
+ $e_date = false;
170
+ }
171
+
172
+
173
+
174
+ //Check search field value empty or not
175
+ if(isset($_POST['search_cf7_value']) && !empty($_POST['search_cf7_value']) && isset($_POST['start_date']) && isset($_POST['end_date']) && empty($_POST['start_date']) && empty($_POST['end_date'])){
176
+
177
+ $query = $wpdb->prepare("SELECT * FROM `{$data_entry_table_name}` WHERE `cf7_id` = %d AND data_id IN( SELECT * FROM ( SELECT data_id FROM `{$data_entry_table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND `value` LIKE '%%".'%s'."%%' GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} LIMIT %d,%d ) temp_table) ORDER BY {$cf7d_entry_order_by}", $fid, $fid, $search, $offset, $items_per_page);
178
+
179
+ $arr_total = $wpdb->get_results($wpdb->prepare("SELECT data_id FROM `{$data_entry_table_name}` WHERE `cf7_id` = %d AND `value` LIKE '%%".'%s'."%%' GROUP BY `data_id`", $fid, $search ));
180
+ }
181
+ //Check search field value empty and date filter active or not
182
+ else if(isset($_POST['search_cf7_value']) && empty($_POST['search_cf7_value']) && isset($_POST['start_date']) && isset($_POST['end_date']) && !empty($_POST['start_date']) && !empty($_POST['end_date']) && $s_date !== false && $e_date !== false){
183
+
184
+ //Get start date information
185
+ $start_date = date_format($s_date,"Y-m-d");
186
+
187
+ //Get end date information
188
+ $end_date = date_format($e_date,"Y-m-d");
189
+ $query_end_date = $end_date." 23:59:59";
190
+
191
+ $query = $wpdb->prepare("SELECT * FROM `{$data_entry_table_name}` WHERE `cf7_id` = %d AND data_id IN( SELECT * FROM ( SELECT data_id FROM `{$data_entry_table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND `name` = 'submit_time' AND value between '".'%s'."' and '".'%s'."' GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} LIMIT %d,%d ) temp_table) ORDER BY {$cf7d_entry_order_by}", $fid, $fid, $start_date, $query_end_date, $offset, $items_per_page);
192
+
193
+ //Get total entries information
194
+ $total_query = $wpdb->prepare("SELECT * FROM `{$data_entry_table_name}` WHERE `cf7_id` = %d AND data_id IN( SELECT * FROM ( SELECT data_id FROM `{$data_entry_table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND `name` = 'submit_time' AND value between '".'%s'."' and '".'%s'."' GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} ) temp_table) GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by}", $fid, $fid, $start_date, $query_end_date );
195
+
196
+ $arr_total = $wpdb->get_results($total_query);
197
+ }
198
+ //Check search field value not empty and date filter active or not
199
+ else if(isset($_POST['search_cf7_value']) && !empty($_POST['search_cf7_value']) && isset($_POST['start_date']) && isset($_POST['end_date']) && !empty($_POST['start_date']) && !empty($_POST['end_date']) && $s_date !== false && $e_date !== false){
200
+
201
+
202
+ //Get start date information
203
+ $start_date = date_format($s_date,"Y-m-d");
204
+
205
+ //Get end date information
206
+ $end_date = date_format($e_date,"Y-m-d").' 23:59:59';
207
+
208
+ //Get date filter related entries information
209
+ $date_query = $wpdb->prepare("SELECT data_id FROM `{$data_entry_table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND `name` = 'submit_time' AND value between '".'%s'."' and '".'%s'."' GROUP BY `data_id` ORDER BY `data_id` DESC", $fid, $start_date, $end_date);
210
+
211
+ $rs_date = $wpdb->get_results($date_query);
212
+ //Get all entries and setup a string
213
+ $data_ids = '';
214
+ if(!empty($rs_date)){
215
+ foreach($rs_date as $objdata_id){
216
+ $data_ids .= $objdata_id->data_id .',';
217
+ }
218
+ $data_ids = rtrim($data_ids,',');
219
+ }
220
+
221
+ //get all entrise information
222
+ $query = $wpdb->prepare("SELECT * FROM `{$data_entry_table_name}` WHERE `cf7_id` = %d AND data_id IN( SELECT * FROM ( SELECT data_id FROM `{$data_entry_table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND `value` LIKE '%%".'%s'."%%' AND data_id IN ({$data_ids}) GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} LIMIT %d,%d ) temp_table) ORDER BY {$cf7d_entry_order_by}", $fid, $fid, $search, $offset, $items_per_page);
223
+
224
+ //Get total entries information
225
+ $total_query = $wpdb->prepare("SELECT * FROM `{$data_entry_table_name}` WHERE `cf7_id` = %d AND data_id IN( SELECT * FROM ( SELECT data_id FROM `{$data_entry_table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND `value` LIKE '%%".'%s'."%%' AND data_id IN ({$data_ids}) GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} ) temp_table) GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by}", $fid, $fid, $search);
226
+
227
+ $arr_total = $wpdb->get_results($total_query);
228
+
229
+ }
230
+ //Call when any filter not active on Listing screen
231
+ else{
232
+ if(isset($_GET["orderby"]) && isset($_GET["order"]) && !empty($_GET["orderby"]) && !empty($_GET["order"]) && (strtolower($_GET["order"]) == 'asc' || strtolower($_GET["order"]) == 'desc')){
233
+
234
+ $order = esc_sql(sanitize_text_field($_GET['order']));
235
+ $orderby = esc_sql(sanitize_text_field($_GET['orderby']));
236
+
237
+ $qry = $wpdb->prepare("SELECT `data_id` FROM `{$data_entry_table_name}` WHERE `cf7_id` = %d AND `name` = '{$orderby}' AND data_id IN( SELECT * FROM ( SELECT data_id FROM `{$data_entry_table_name}` WHERE 1 = 1 AND `cf7_id` = %d GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} LIMIT %d,%d ) temp_table) ORDER BY `value` {$order},{$cf7d_entry_order_by}", $fid, $fid, $offset, $items_per_page);
238
+ $idVals = $wpdb->get_results ( $qry );
239
+
240
+ $id_val = array();
241
+ if(!empty($idVals)){
242
+ foreach($idVals as $o_id){
243
+ $id_val[] = $o_id->data_id;
244
+ }
245
+ }
246
+
247
+ $id_val_str = "";
248
+ if(!empty($id_val)){
249
+ $id_val_str = implode(',',$id_val);
250
+ }
251
+
252
+ $query = $wpdb->prepare("SELECT * FROM `{$data_entry_table_name}` WHERE `cf7_id` = %d AND data_id IN( SELECT * FROM ( SELECT data_id FROM `{$data_entry_table_name}` WHERE 1 = 1 AND `cf7_id` = %d GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} LIMIT %d,%d ) temp_table) ORDER BY FIELD(`data_id`, {$id_val_str} )", $fid, $fid, $offset, $items_per_page);
253
+
254
+ }
255
+ else{
256
+ $query = $wpdb->prepare("SELECT * FROM `{$data_entry_table_name}` WHERE `cf7_id` = %d AND data_id IN( SELECT * FROM ( SELECT data_id FROM `{$data_entry_table_name}` WHERE 1 = 1 AND `cf7_id` = %d GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} LIMIT %d,%d ) temp_table) ORDER BY {$cf7d_entry_order_by}", $fid, $fid, $offset, $items_per_page);
257
+ }
258
+
259
+ //Get total entries information
260
+ if(!empty($search)){
261
+ $arr_total = $wpdb->get_results($wpdb->prepare("SELECT data_id FROM `{$data_entry_table_name}` WHERE `cf7_id` = %d AND `value` LIKE '%%".'%s'."%%' GROUP BY `data_id`", $fid, $search));
262
+ }else{
263
+ $arr_total = $wpdb->get_results($wpdb->prepare("SELECT data_id FROM `{$data_entry_table_name}` WHERE `cf7_id` = %d GROUP BY `data_id`", $fid));
264
+ }
265
+ }
266
+
267
+
268
+ //Execute query here
269
+ $data = $wpdb->get_results($query);
270
+
271
+ //Get entry wise all fields information
272
+ $data_sorted = vsz_cf7_sortdata($data);
273
+
274
+ //get total count
275
+ $total = count($arr_total);
276
+
277
+ //Define bulk action array
278
+
279
+ //Add filter for customize bulk action values
280
+ $entry_actions = (array) apply_filters('vsz_cf7_entry_actions', $entry_actions);
281
+
282
+ //define nonce for get entry details
283
+ $getDatanonce = wp_create_nonce( 'vsz-cf7-get-entry-nonce-'.$fid );
284
+
285
+ //Form listing design structure start here
286
+ ?><div class="wrap our-class">
287
+ <form class="vsz-cf7-listing row" action="<?php print esc_url($url);?>" method="post" id="cf7d-admin-action-frm" >
288
+ <input type="hidden" name="page" value="contact-form-listing">
289
+ <input type="hidden" name="fid" value="<?php echo esc_html($fid); ?>">
290
+ <input type="hidden" name="_wpnonce" value="<?php echo esc_html(wp_create_nonce('vsz-cf7-action-nonce')); ?>"><?php
291
+ //Display setting screen button
292
+ do_action('vsz_cf7_display_settings_btn', $fid);
293
+ ?><div class="span12">
294
+ <div class="date-filter from-to" style="display:block;">
295
+ <div class="from-to-date-search">
296
+ <input type="text" name="start_date" id="start_date" placeholder="From" value="<?php print isset($_POST['start_date']) ? esc_attr(sanitize_text_field($_POST['start_date'])) : '';?>" class="input-cf-date">
297
+ <input type="text" name="end_date" id="end_date" placeholder="To" value="<?php print isset($_POST['end_date']) ? esc_attr(sanitize_text_field($_POST['end_date'])) : '';?>" class="input-cf-date" >
298
+ <input type="button" name="search_date" id="search_date" value="<?php esc_html_e('Search By Date',VSZ_CF7_TEXT_DOMAIN); ?>" title="<?php esc_html_e('Search By Date',VSZ_CF7_TEXT_DOMAIN); ?>" class="button action" >
299
+ </div>
300
+ <div class="type-something"><?php
301
+ //Display Search section here
302
+ do_action('vsz_cf7_after_datesection_btn', $fid);
303
+ ?></div>
304
+ <div class="reset-class"><a href="<?php print esc_url($url);?>" title="<?php esc_html_e('Reset All',VSZ_CF7_TEXT_DOMAIN); ?>" class="button"><?php esc_html_e('Reset All',VSZ_CF7_TEXT_DOMAIN); ?></a></div>
305
+ </div>
306
+ <div class="clear"></div>
307
+ </div>
308
+ <div class="span12 bulk-actions">
309
+ <div class="tablenav top">
310
+ <div class="actions bulkactions">
311
+ <label for="bulk-action-selector-top" class="screen-reader-text"><?php esc_html_e('Select bulk action',VSZ_CF7_TEXT_DOMAIN); ?></label>
312
+ <select name="action" id="bulk-action-selector-top">
313
+ <option value="-1"><?php esc_html_e('Bulk Actions',VSZ_CF7_TEXT_DOMAIN); ?></option><?php
314
+ //Get all bulk action values
315
+ echo vsz_cf7_arr_to_option($entry_actions);
316
+ ?></select>
317
+ <input id="doaction" name="btn_apply" class="button action" value="<?php _e('Apply',VSZ_CF7_TEXT_DOMAIN); ?>" title="<?php _e('Apply',VSZ_CF7_TEXT_DOMAIN); ?>" type="submit" /><?php
318
+ //Display Export button option values
319
+ do_action('vsz_cf7_after_bulkaction_btn', $fid);
320
+ ?><div class="tablenav-pages">
321
+ <span class="displaying-num"><?php echo (($total == 1) ?
322
+ '1 ' . __('item') :
323
+ $total . ' ' . __('items')) ?></span>
324
+ <span class="pagination-links"><?php
325
+ //Setup pagination structure
326
+ print ( paginate_links(array(
327
+ 'base' => add_query_arg('cpage', '%#%'),
328
+ 'format' => '',
329
+ 'prev_text' => __('&laquo;'),
330
+ 'next_text' => __('&raquo;'),
331
+ 'total' => ceil($total / $items_per_page),
332
+ 'current' => $page,
333
+ )));
334
+
335
+
336
+ ?></span>
337
+ </div>
338
+ </div>
339
+ <br class="clear">
340
+ </div>
341
+ </div>
342
+ <div class="span12 table-structure">
343
+ <div class="table-inner-structure">
344
+ <table class="wp-list-table widefat fixed striped posts cf7d-admin-table">
345
+ <thead>
346
+ <tr><?php
347
+ echo '<td id="cb" class="manage-column column-cb check-column"><input type="checkbox" id="cb-select-all-1" /></td>';
348
+ //Display Edit headion field
349
+ if($edit == true){
350
+ do_action('vsz_cf7_admin_after_heading_field');
351
+ }
352
+ //Define table header section here
353
+ foreach ($fields as $k => $v){
354
+ echo '<th class="manage-column" data-key="'.esc_html($v).'">'.vsz_cf7_admin_get_field_name($v).'</th>';
355
+ }
356
+ ?></tr>
357
+ </thead>
358
+ <tbody><?php
359
+ //Add character count functionalirty here
360
+ $display_character = (int) apply_filters('vsz_display_character_count',30);
361
+ $arr_field_type_info = vsz_field_type_info($fid);
362
+
363
+ //Get all fields related information
364
+ if(!empty($data_sorted)){
365
+ foreach ($data_sorted as $k => $v) {
366
+ $k = (int)$k;
367
+ echo '<tr>';
368
+ echo '<th class="check-column" scope="row"><input id="cb-select-'.esc_html($k).'" type="checkbox" title="Check" name="del_id[]" value="'.esc_html($k).'" /></th>';
369
+ $row_id = $k;
370
+ //Display edit entry icon
371
+ if($edit == true){
372
+ do_action('vsz_cf7_admin_after_body_field', $fid, $row_id,$getDatanonce);
373
+ }
374
+ foreach ($fields as $k2 => $v2) {
375
+ //Get fields related values
376
+ $_value = ((isset($v[$k2])) ? $v[$k2] : '&nbsp;');
377
+ $_value1 = filter_var($_value, FILTER_SANITIZE_URL);
378
+
379
+ //Check value is URL or not
380
+ if (!filter_var($_value1, FILTER_VALIDATE_URL) === false) {
381
+ $_value = esc_url($_value);
382
+ //If value is url then setup anchor tag with value
383
+ if(!empty($arr_field_type_info) && array_key_exists($k2,$arr_field_type_info) && $arr_field_type_info[$k2] == 'file'){
384
+ //Add download attributes in tag if field type is attachement
385
+ ?><td data-head="<?php echo vsz_cf7_admin_get_field_name($v2); ?>">
386
+ <a href="<?php echo esc_url($_value); ?>" target="_blank" title="<?php echo esc_url($_value); ?>" download ><?php echo esc_html(basename($_value)); ?>
387
+ </a>
388
+ </td><?php
389
+ }
390
+ else{
391
+ ?><td data-head="<?php echo vsz_cf7_admin_get_field_name($v2); ?>">
392
+ <a href="<?php echo esc_url($_value); ?>" target="_blank" title="<?php echo esc_url($_value); ?>" ><?php echo esc_html(basename($_value)); ?>
393
+ </a>
394
+ </td><?php
395
+ }
396
+ }
397
+ else{
398
+ $_value = esc_html(html_entity_decode($_value));
399
+ //var_dump(($_value)); var_dump(strlen($_value)); exit;
400
+ if(strlen($_value) > $display_character){
401
+
402
+ echo '<td data-head="'.vsz_cf7_admin_get_field_name($v2).'">'.esc_html(substr($_value, 0, $display_character)).'...</td>';
403
+ }else{
404
+ echo '<td data-head="'.vsz_cf7_admin_get_field_name($v2).'">'.esc_html($_value).'</td>';
405
+ }
406
+ }
407
+ }//Close foreach
408
+ echo '</tr>';
409
+ }//Close foreach
410
+ }
411
+ else{
412
+ ?><tr><?php
413
+ $span = count($fields) + 2;
414
+ ?><td colspan="<?php echo esc_html($span); ?>">
415
+ <?php esc_html_e('No records found.',VSZ_CF7_TEXT_DOMAIN); ?>
416
+ </td><?php
417
+ ?></tr><?php
418
+ }
419
+ ?></tbody>
420
+ <tfoot>
421
+ <tr><?php
422
+ //Setup header section in table footer area
423
+ echo '<td class="manage-column column-cb check-column"><input type="checkbox" id="cb-select-all-2" /></td>';
424
+ if($edit == true){
425
+ do_action('vsz_cf7_admin_after_heading_field');
426
+ }
427
+ foreach ($fields as $k => $v){
428
+ echo '<th class="manage-column" data-key="'.esc_html($v).'">'.vsz_cf7_admin_get_field_name($v).'</th>';
429
+ }
430
+ ?></tr>
431
+ </tfoot>
432
+ </table>
433
+ </div>
434
+ </div>
435
+
436
+ <input type="hidden" name="cpage" value="<?php echo intval($page);?>" id="cpage">
437
+ <input type="hidden" name="totalPage" value="<?php print ceil($total / $items_per_page);?>" id="totalPage">
438
+ </form>
439
+ <script>
440
+ //Setup pagination related functionality when click on page link then form submitted
441
+ jQuery(".pagination-links a").on('click',function(){
442
+ var final_id;
443
+ var url = jQuery(this).attr('href');
444
+ var id_check = /[?&]cpage=([^&]+)/i;
445
+ var match = id_check.exec(url);
446
+ if(match != null){
447
+ final_id = parseInt(match[1]);
448
+ }
449
+ if(final_id != ''){
450
+ jQuery(this).attr("href","javascript:void(0)");
451
+ jQuery('#cpage').val(final_id);
452
+ document.getElementById('cf7d-admin-action-frm').submit();
453
+ }
454
+ });
455
+
456
+ //Add custom class in body tag when click on Setting button
457
+ jQuery('#cf7d_setting_form').click(function(){
458
+ jQuery('body').addClass('our-body-class');
459
+ });
460
+ //Updating record
461
+ jQuery(document).on('click','#update_cf7_value',function(){
462
+ var filterdata = jQuery('.vsz-cf7-listing').html();
463
+ jQuery('.cf7d-modal-form').append('<div style="display:none">'+filterdata+'</div>');
464
+
465
+ });
466
+
467
+ </script>
468
+ </div><?php
469
+ //Define setting and Edit popup call back function
470
+ do_action('vsz_cf7_after_admin_form',$fid);
471
+ }//Close if for check form id empty or not
472
+ else if(!$exist_entry_flag){
473
+
474
+ //added in 1.8.4
475
+ ?><div class="popup-note">
476
+ <span><?php
477
+ esc_html_e('Currently not submission any form data.',VSZ_CF7_TEXT_DOMAIN);
478
+ ?></span>
479
+ </div><?php
480
+
481
+ }
482
  }
admin/partials/import_cf7_entry.class.php CHANGED
@@ -197,9 +197,13 @@ if(isset($_POST['submit']) && isset($_FILES['importFormList']) && !empty($_FILES
197
  //Insert sheet related values in contact form Tables
198
  if(!empty($arr_insert_info)){
199
 
 
 
 
 
200
  //Insert current form submission time in database
201
  $time = date('Y-m-d H:i:s');
202
- $wpdb->query($wpdb->prepare('INSERT INTO '.VSZ_CF7_DATA_TABLE_NAME.'(`created`) VALUES (%s)', $time));
203
  //Get last inserted id
204
  $data_id = (int)$wpdb->insert_id;
205
 
@@ -222,7 +226,7 @@ if(isset($_POST['submit']) && isset($_FILES['importFormList']) && !empty($_FILES
222
  //It is prevent JS injection
223
  $v = sanitize_textarea_field($v);
224
  //$v = htmlspecialchars($v);
225
- $wpdb->query($wpdb->prepare('INSERT INTO '.VSZ_CF7_DATA_ENTRY_TABLE_NAME.'(`cf7_id`, `data_id`, `name`, `value`) VALUES (%d,%d,%s,%s)', $fid, $data_id, $k, $v));
226
  }
227
  }//Close foreach
228
  $new_csv[] = 'success';
197
  //Insert sheet related values in contact form Tables
198
  if(!empty($arr_insert_info)){
199
 
200
+ //Get table name for data entry
201
+ $data_table_name = sanitize_text_field(VSZ_CF7_DATA_TABLE_NAME);
202
+ $data_entry_table_name = sanitize_text_field(VSZ_CF7_DATA_ENTRY_TABLE_NAME);
203
+
204
  //Insert current form submission time in database
205
  $time = date('Y-m-d H:i:s');
206
+ $wpdb->query($wpdb->prepare("INSERT INTO {$data_table_name}(`created`) VALUES (%s)", $time));
207
  //Get last inserted id
208
  $data_id = (int)$wpdb->insert_id;
209
 
226
  //It is prevent JS injection
227
  $v = sanitize_textarea_field($v);
228
  //$v = htmlspecialchars($v);
229
+ $wpdb->query($wpdb->prepare("INSERT INTO {$data_entry_table_name}(`cf7_id`, `data_id`, `name`, `value`) VALUES (%d,%d,%s,%s)", $fid, $data_id, $k, $v));
230
  }
231
  }//Close foreach
232
  $new_csv[] = 'success';
advanced-cf7-db.php CHANGED
@@ -9,7 +9,7 @@
9
  * Plugin Name: Advanced CF7 DB
10
  * Plugin URI: https://wordpress.org/plugins/advanced-cf7-db/
11
  * Description: Save all contact form 7 submitted data to the database, View, Export, ordering, Change field labels, Import data using CSV very easily.
12
- * Version: 1.8.9
13
  * Author: Vsourz Digital
14
  * Author URI: https://www.vsourz.com
15
  * License: GPL-2.0+
@@ -23,7 +23,7 @@ if ( ! defined( 'WPINC' ) ) {
23
  die;
24
  }
25
  global $vsz_cf7db_current_version;
26
- $vsz_cf7db_current_version = '1.8.9';
27
  /**
28
  * Defining all the table names and setting their prefix here
29
  */
9
  * Plugin Name: Advanced CF7 DB
10
  * Plugin URI: https://wordpress.org/plugins/advanced-cf7-db/
11
  * Description: Save all contact form 7 submitted data to the database, View, Export, ordering, Change field labels, Import data using CSV very easily.
12
+ * Version: 1.9
13
  * Author: Vsourz Digital
14
  * Author URI: https://www.vsourz.com
15
  * License: GPL-2.0+
23
  die;
24
  }
25
  global $vsz_cf7db_current_version;
26
+ $vsz_cf7db_current_version = '1.9';
27
  /**
28
  * Defining all the table names and setting their prefix here
29
  */
includes/vsz-cf7-db-function.php CHANGED
@@ -45,9 +45,13 @@ function vsz_cf7_before_send_email($contact_form){
45
 
46
  $contact_form->posted_data = (array) apply_filters('vsz_cf7_posted_data', $contact_form->posted_data);
47
 
 
 
 
 
48
  //Insert current form submission time in database
49
  $time = date('Y-m-d H:i:s');
50
- $wpdb->query($wpdb->prepare('INSERT INTO '.VSZ_CF7_DATA_TABLE_NAME.'(`created`) VALUES (%s)', $time));
51
  //Get last inserted id
52
  $data_id = $wpdb->insert_id;
53
 
@@ -70,7 +74,7 @@ function vsz_cf7_before_send_email($contact_form){
70
  //It is prevent JS injection
71
  $v = sanitize_textarea_field($v);
72
  //$v = htmlspecialchars($v);
73
- $wpdb->query($wpdb->prepare('INSERT INTO '.VSZ_CF7_DATA_ENTRY_TABLE_NAME.'(`cf7_id`, `data_id`, `name`, `value`) VALUES (%d,%d,%s,%s)', $cf7_id, $data_id, $k, $v));
74
  }
75
  }
76
  //exit;
@@ -113,10 +117,10 @@ function vsz_cf7_add_extra_fields($cf7){
113
 
114
  if(!defined('vsz_cf7_display_ip')){
115
  //Get submitted ip address
116
- $ip_address = (isset($_SERVER['X_FORWARDED_FOR']) && !empty(rest_is_ip_address($_SERVER['X_FORWARDED_FOR']))) ? $_SERVER['X_FORWARDED_FOR'] : "";
117
 
118
  if(empty($ip_address)){
119
- $ip_address = (isset($_SERVER['REMOTE_ADDR']) && !empty(rest_is_ip_address($_SERVER['REMOTE_ADDR']))) ? $_SERVER['REMOTE_ADDR'] : "";
120
  }
121
 
122
  if(!empty($ip_address)){
@@ -240,7 +244,9 @@ function vsz_cf7_get_db_fields($fid, $filter = true){
240
 
241
  global $wpdb;
242
  $fid = (int)$fid;
243
- $sql = $wpdb->prepare("SELECT `name` FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE cf7_id = %d GROUP BY `name`", $fid);
 
 
244
  $data = $wpdb->get_results($sql);
245
 
246
  //Set each field value in array
@@ -294,8 +300,9 @@ function get_entry_related_fields_info($fid,$entryId){
294
  global $wpdb;
295
  $fid = intval($fid);
296
  $entryId = intval($entryId);
 
297
 
298
- $sql = $wpdb->prepare("SELECT `name` FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = %d AND `data_id` = %d GROUP BY `name`", $fid, $entryId);
299
  $data = $wpdb->get_results($sql);
300
  if(!empty($data)){
301
  foreach ($data as $k => $v) {
45
 
46
  $contact_form->posted_data = (array) apply_filters('vsz_cf7_posted_data', $contact_form->posted_data);
47
 
48
+ //Get table name for data entry
49
+ $data_table_name = sanitize_text_field(VSZ_CF7_DATA_TABLE_NAME);
50
+ $data_entry_table_name = sanitize_text_field(VSZ_CF7_DATA_ENTRY_TABLE_NAME);
51
+
52
  //Insert current form submission time in database
53
  $time = date('Y-m-d H:i:s');
54
+ $wpdb->query($wpdb->prepare("INSERT INTO {$data_table_name}(`created`) VALUES (%s)", $time));
55
  //Get last inserted id
56
  $data_id = $wpdb->insert_id;
57
 
74
  //It is prevent JS injection
75
  $v = sanitize_textarea_field($v);
76
  //$v = htmlspecialchars($v);
77
+ $wpdb->query($wpdb->prepare("INSERT INTO {$data_entry_table_name}(`cf7_id`, `data_id`, `name`, `value`) VALUES (%d,%d,%s,%s)", $cf7_id, $data_id, $k, $v));
78
  }
79
  }
80
  //exit;
117
 
118
  if(!defined('vsz_cf7_display_ip')){
119
  //Get submitted ip address
120
+ $ip_address = (isset($_SERVER['X_FORWARDED_FOR']) && !empty(rest_is_ip_address(sanitize_text_field($_SERVER['X_FORWARDED_FOR'])))) ? sanitize_text_field($_SERVER['X_FORWARDED_FOR']) : "";
121
 
122
  if(empty($ip_address)){
123
+ $ip_address = (isset($_SERVER['REMOTE_ADDR']) && !empty(rest_is_ip_address(sanitize_text_field($_SERVER['REMOTE_ADDR'])))) ? sanitize_text_field($_SERVER['REMOTE_ADDR']) : "";
124
  }
125
 
126
  if(!empty($ip_address)){
244
 
245
  global $wpdb;
246
  $fid = (int)$fid;
247
+ $data_entry_table_name = sanitize_text_field(VSZ_CF7_DATA_ENTRY_TABLE_NAME);
248
+
249
+ $sql = $wpdb->prepare("SELECT `name` FROM `{$data_entry_table_name}` WHERE cf7_id = %d GROUP BY `name`", $fid);
250
  $data = $wpdb->get_results($sql);
251
 
252
  //Set each field value in array
300
  global $wpdb;
301
  $fid = intval($fid);
302
  $entryId = intval($entryId);
303
+ $data_entry_table_name = sanitize_text_field(VSZ_CF7_DATA_ENTRY_TABLE_NAME);
304
 
305
+ $sql = $wpdb->prepare("SELECT `name` FROM `{$data_entry_table_name}` WHERE `cf7_id` = %d AND `data_id` = %d GROUP BY `name`", $fid, $entryId);
306
  $data = $wpdb->get_results($sql);
307
  if(!empty($data)){
308
  foreach ($data as $k => $v) {
public/partials/vsz_acf7_db_shortcode_display_front.php CHANGED
@@ -1,308 +1,350 @@
1
- <?php
2
- // Exit if accessed directly
3
- if(!defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
- global $wpdb;
7
- $html = "";
8
- // get id for banner shortcode if define
9
- $arrInfo = shortcode_atts(
10
- array( 'form_id' => '', 'show' => '', 'hide' => '', 'display' => '', 'search' => '', 'id' => '', 'class' => '',
11
- 'header' => '', 'style' => '', 'max_entries' => '', 'start-date' => '', 'end-date' => '' ),
12
- $atts
13
- );
14
- $formIds = sanitize_text_field($arrInfo['form_id']);
15
- $display = sanitize_text_field($arrInfo['display']);
16
- $show = sanitize_text_field($arrInfo['show']);
17
- $hide = sanitize_text_field($arrInfo['hide']);
18
- $search = sanitize_text_field($arrInfo['search']);
19
- $table_id = sanitize_text_field($arrInfo['id']);
20
- $table_class = sanitize_text_field($arrInfo['class']);
21
- $header = sanitize_text_field($arrInfo['header']);
22
- $table_style = sanitize_text_field($arrInfo['style']);
23
- $posts_per_page = sanitize_text_field($arrInfo['max_entries']);
24
- $start_date = sanitize_text_field($arrInfo['start-date']);
25
- $end_date = sanitize_text_field($arrInfo['end-date']);
26
-
27
- $search = str_replace('"', '\\&quot;', $search);
28
- $search = addslashes(addslashes(sanitize_text_field($search)));
29
-
30
- $formArr = explode(",", $formIds);
31
-
32
- foreach($formArr as $key=>$val){
33
- $val = (int) trim($val);
34
- if(empty($val)) unset($formArr[$key]);
35
- }
36
-
37
- //Get all existing contact form list
38
- $form_list = vsz_cf7_get_the_form_list();
39
-
40
- if(empty($formArr)){
41
- $formArr = $form_list;
42
- $allForms = true;
43
- }
44
-
45
- if(!empty($formArr)){
46
-
47
- $count = array();
48
-
49
- foreach($formArr as $fid){
50
-
51
- if(isset($allForms) && $allForms){
52
- $form = $fid;
53
- unset($fid);
54
- $fid = $form->id();
55
- }
56
-
57
- $form = vsz_cf7_get_the_form_list($fid);
58
-
59
- if(!empty($form)){
60
-
61
- $form = $form[0];
62
- $data_sorted = "";
63
- $showArrFinal = array();
64
- $hideArrFinal = array();
65
- $headerForForm = "";
66
- //Get form Id related fields information
67
- $fields = vsz_cf7_get_db_fields($fid);
68
-
69
- // Show Hide Fields
70
- if(!empty($show)){
71
- $showArr = explode(",",$show);
72
- foreach($showArr as $key => $val){
73
- $val = trim($val);
74
-
75
- $valArr = explode(".",$val);
76
-
77
- if(count($valArr) > 1){
78
- if($valArr[0] == $fid){
79
- if(count($valArr)>2){
80
- unset($valArr[0]);
81
-
82
- $fieldVal = implode(".",$valArr);
83
- }
84
- else{
85
- $fieldVal = $valArr[1];
86
- }
87
-
88
- $showArrFinal[] = $fieldVal;
89
- }
90
- }
91
- }
92
- }
93
- if(!empty($hide)){
94
- $hideArr = explode(",",$hide);
95
- foreach($hideArr as $key => $val){
96
- $val = trim($val);
97
-
98
- $valArr = explode(".",$val);
99
-
100
- if(count($valArr) > 1){
101
- if($valArr[0] == $fid){
102
- if(count($valArr)>2){
103
- unset($valArr[0]);
104
-
105
- $fieldVal = implode(".",$valArr);
106
- }
107
- else{
108
- $fieldVal = $valArr[1];
109
- }
110
-
111
- $hideArrFinal[] = $fieldVal;
112
- }
113
- }
114
- }
115
- }
116
- if(!empty($header)){
117
- $headerArr = explode(",",$header);
118
- foreach($headerArr as $key => $val){
119
- $val = trim($val);
120
- $valArr = explode(".",$val);
121
-
122
- if(count($valArr) > 1){
123
- if($valArr[0] == $fid){
124
- if(count($valArr)>2){
125
- unset($valArr[0]);
126
-
127
- $fieldVal = implode(".",$valArr);
128
- }
129
- else{
130
- $fieldVal = $valArr[1];
131
- }
132
-
133
- $headerForForm = $fieldVal;
134
- }
135
- }
136
- }
137
- }
138
-
139
- // Show Field Applied Here
140
- if(!empty($showArrFinal)){
141
- foreach($fields as $key => $val){
142
- if(!in_array($val, $showArrFinal)){
143
- unset($fields[$key]);
144
- }
145
- }
146
- }
147
-
148
- // Hide Field Applied Here
149
- if(!empty($hideArrFinal)){
150
- foreach($fields as $key => $val){
151
- if(in_array($val, $hideArrFinal)){
152
- unset($fields[$key]);
153
- }
154
- }
155
- }
156
-
157
- //Check contact form id set or not
158
- if (!empty($fid) && !empty($fields)){
159
- //Add filter for ordering in entry
160
- $cf7d_entry_order_by = (string) apply_filters('vsz_cf7_entry_order_by', '`data_id` DESC');
161
- $cf7d_entry_order_by = sanitize_sql_orderby($cf7d_entry_order_by);
162
-
163
- $items_per_page = (int)apply_filters('vsz_cf7_entry_per_page', (!empty($posts_per_page) ? $posts_per_page : 20));
164
-
165
- $page = isset($_POST['cpage']) && !empty($_POST['cpage']) ? abs((int)sanitize_text_field($_POST['cpage'])) : 1;
166
- //Setup offset related value here
167
- $offset = (int)( $page * $items_per_page ) - $items_per_page;
168
-
169
- // If date search exists
170
- $search_date_query = "";
171
- if(!empty($start_date) && !empty($end_date)){
172
- $s_date = date_create_from_format("d/m/Y",sanitize_text_field($start_date));
173
- $e_date = date_create_from_format("d/m/Y",sanitize_text_field($end_date));
174
- //Get start date information
175
- $start_date_str = date_format($s_date,"Y-m-d");
176
-
177
- //Get end date information
178
- $end_date_str = date_format($e_date,"Y-m-d");
179
-
180
- if($start_date_str && $end_date_str){
181
- //Setup date parameter value in query
182
- $search_date_query = " AND `name` = 'submit_time' AND value between '".$start_date_str."' and '".$end_date_str." 23:59:59'";
183
- }
184
- }
185
-
186
- // Make sure that $fid will contain integer value only.
187
- $fid = (int) $fid;
188
-
189
- $query = $wpdb->prepare("SELECT * FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = ".$fid." AND data_id IN(SELECT * FROM (SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE 1 = 1 AND `cf7_id` = ".$fid. ((!empty($search)) ? " AND `value` LIKE '%%".$search."%%'" : "") . ((!empty($search_date_query)) ? $search_date_query : "") ."GROUP BY `data_id` ORDER BY ".sanitize_sql_orderby($cf7d_entry_order_by)." LIMIT ".$offset.",".$items_per_page.") temp_table) ORDER BY " . sanitize_sql_orderby($cf7d_entry_order_by));
190
-
191
- //Get total entries information
192
- $arr_total = $wpdb->get_results($wpdb->prepare("SELECT data_id FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = " .$fid . " ".((!empty($search)) ? "AND `value` LIKE '%%".$search."%%'" : "")." GROUP BY `data_id`"));
193
-
194
- //Execute query here
195
- $data = $wpdb->get_results($query);
196
-
197
- //Get entry wise all fields information
198
- $data_sorted = vsz_cf7_sortdata($data);
199
-
200
- //get total count
201
- $total = count($arr_total);
202
-
203
- $display_character = (int) apply_filters('vsz_display_character_count',30);
204
-
205
- switch($display){
206
-
207
- case "count" :
208
- $count[] = $total;
209
- break;
210
-
211
- case "table" :
212
- default :
213
-
214
- //Get all fields related information
215
- if(!empty($data_sorted)){
216
-
217
- // If title passed in attribute use that otherwise use form title
218
- $html .= !empty($headerForForm) ? '<h2>'.esc_html($headerForForm).'</h2>' : '<h2>'.esc_html($form->title()).'</h2>';
219
- $html .= '<table id="'.esc_html($table_id).'" class="'.esc_html($table_class).'" style="overflow: auto; '.esc_html($table_style).'">
220
- <thead>
221
- <tr>';
222
-
223
- //Define table header section here
224
- foreach ($fields as $k => $v){
225
- $html .= '<th class="manage-column" data-key="'.esc_html($v).'">'.vsz_cf7_admin_get_field_name($v).'</th>';
226
- }
227
-
228
- $html .= '</tr>
229
- </thead>
230
- <tbody>';
231
-
232
- foreach ($data_sorted as $k => $v) {
233
- $k = (int)$k;
234
- $html .= '<tr>';
235
- foreach ($fields as $k2 => $v2) {
236
- //Get fields related values
237
- $_value = ((isset($v[$k2])) ? $v[$k2] : '&nbsp;');
238
- $_value1 = filter_var($_value, FILTER_SANITIZE_URL);
239
-
240
- //Check value is URL or not
241
- if (!filter_var($_value1, FILTER_VALIDATE_URL) === false) {
242
- $_value = esc_url($_value);
243
- //If value is url then setup anchor tag with value
244
- if(!empty($arr_field_type_info) && array_key_exists($k2,$arr_field_type_info) && $arr_field_type_info[$k2] == 'file'){
245
- //Add download attributes in tag if field type is attachement
246
- $_value = '<a href="'. esc_url($_value).'" target="_blank" title="'. esc_url($_value).'" download >'.esc_html(basename($_value)).'</a>';
247
- $html .= '<td data-head="'.vsz_cf7_admin_get_field_name($v2).'">'. esc_url($_value).'</td>';
248
- }
249
- else{
250
- $_value = '<a href="'. esc_url($_value).'" target="_blank" title="'. esc_url($_value).'" >'.esc_html(basename($_value)).'</a>';
251
- $html .= '<td data-head="'.vsz_cf7_admin_get_field_name($v2).'">'. esc_url($_value).'</td>';
252
- }
253
- }
254
- else{
255
- $_value = esc_html(html_entity_decode($_value));
256
- //var_dump(($_value)); var_dump(strlen($_value)); exit;
257
- if(strlen($_value) > $display_character){
258
-
259
- $html .= '<td data-head="'.vsz_cf7_admin_get_field_name($v2).'">'. esc_html(substr($_value, 0, $display_character)).'...</td>';
260
- }else{
261
- $html .= '<td data-head="'.vsz_cf7_admin_get_field_name($v2).'">'.esc_html($_value).'</td>';
262
- }
263
- }
264
- }
265
-
266
- $html .='</tr>';
267
- }
268
-
269
- $html .='</tbody>
270
- </table>';
271
- }
272
- else{
273
- $colSpan = count($fields) + 2;
274
- $html .= '<table>
275
- <tr>
276
- <td colspan="'.esc_html($colSpan).'">
277
- No records found.
278
- </td>
279
- </tr>
280
- </table>';
281
- }
282
-
283
- break;
284
- }
285
-
286
- }
287
- }
288
- }
289
- }
290
-
291
- if(!empty($count)){
292
- if(count($count)>1){
293
- $totalVal = 0;
294
- foreach($count as $val){
295
- $totalVal += $val;
296
- }
297
-
298
- return $totalVal;
299
- }
300
- else{
301
- return implode(",",$count);
302
- }
303
- }
304
- else{
305
- return $html;
306
- }
307
-
308
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Exit if accessed directly
3
+ if(!defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+ global $wpdb;
7
+ $html = "";
8
+ // get id for banner shortcode if define
9
+ $arrInfo = shortcode_atts(
10
+ array( 'form_id' => '', 'show' => '', 'hide' => '', 'display' => '', 'search' => '', 'id' => '', 'class' => '',
11
+ 'header' => '', 'style' => '', 'max_entries' => '', 'start-date' => '', 'end-date' => '' ),
12
+ $atts
13
+ );
14
+ $formIds = sanitize_text_field($arrInfo['form_id']);
15
+ $display = sanitize_text_field($arrInfo['display']);
16
+ $show = sanitize_text_field($arrInfo['show']);
17
+ $hide = sanitize_text_field($arrInfo['hide']);
18
+ $search = sanitize_text_field($arrInfo['search']);
19
+ $table_id = sanitize_text_field($arrInfo['id']);
20
+ $table_class = sanitize_text_field($arrInfo['class']);
21
+ $header = sanitize_text_field($arrInfo['header']);
22
+ $table_style = sanitize_text_field($arrInfo['style']);
23
+ $posts_per_page = sanitize_text_field($arrInfo['max_entries']);
24
+ $start_date = sanitize_text_field($arrInfo['start-date']);
25
+ $end_date = sanitize_text_field($arrInfo['end-date']);
26
+
27
+ $search = str_replace('"', '\\&quot;', $search);
28
+ $search = addslashes(addslashes(sanitize_text_field($search)));
29
+
30
+ $formArr = explode(",", $formIds);
31
+
32
+ foreach($formArr as $key=>$val){
33
+ $val = (int) trim($val);
34
+ if(empty($val)) unset($formArr[$key]);
35
+ }
36
+
37
+ //Get all existing contact form list
38
+ $form_list = vsz_cf7_get_the_form_list();
39
+
40
+ if(empty($formArr)){
41
+ $formArr = $form_list;
42
+ $allForms = true;
43
+ }
44
+
45
+ if(!empty($formArr)){
46
+
47
+ $count = array();
48
+
49
+ foreach($formArr as $fid){
50
+
51
+ if(isset($allForms) && $allForms){
52
+ $form = $fid;
53
+ unset($fid);
54
+ $fid = $form->id();
55
+ }
56
+
57
+ $form = vsz_cf7_get_the_form_list($fid);
58
+
59
+ if(!empty($form)){
60
+
61
+ $form = $form[0];
62
+ $data_sorted = "";
63
+ $showArrFinal = array();
64
+ $hideArrFinal = array();
65
+ $headerForForm = "";
66
+ //Get form Id related fields information
67
+ $fields = vsz_cf7_get_db_fields($fid);
68
+
69
+ // Show Hide Fields
70
+ if(!empty($show)){
71
+ $showArr = explode(",",$show);
72
+ foreach($showArr as $key => $val){
73
+ $val = trim($val);
74
+
75
+ $valArr = explode(".",$val);
76
+
77
+ if(count($valArr) > 1){
78
+ if($valArr[0] == $fid){
79
+ if(count($valArr)>2){
80
+ unset($valArr[0]);
81
+
82
+ $fieldVal = implode(".",$valArr);
83
+ }
84
+ else{
85
+ $fieldVal = $valArr[1];
86
+ }
87
+
88
+ $showArrFinal[] = $fieldVal;
89
+ }
90
+ }
91
+ }
92
+ }
93
+ if(!empty($hide)){
94
+ $hideArr = explode(",",$hide);
95
+ foreach($hideArr as $key => $val){
96
+ $val = trim($val);
97
+
98
+ $valArr = explode(".",$val);
99
+
100
+ if(count($valArr) > 1){
101
+ if($valArr[0] == $fid){
102
+ if(count($valArr)>2){
103
+ unset($valArr[0]);
104
+
105
+ $fieldVal = implode(".",$valArr);
106
+ }
107
+ else{
108
+ $fieldVal = $valArr[1];
109
+ }
110
+
111
+ $hideArrFinal[] = $fieldVal;
112
+ }
113
+ }
114
+ }
115
+ }
116
+ if(!empty($header)){
117
+ $headerArr = explode(",",$header);
118
+ foreach($headerArr as $key => $val){
119
+ $val = trim($val);
120
+ $valArr = explode(".",$val);
121
+
122
+ if(count($valArr) > 1){
123
+ if($valArr[0] == $fid){
124
+ if(count($valArr)>2){
125
+ unset($valArr[0]);
126
+
127
+ $fieldVal = implode(".",$valArr);
128
+ }
129
+ else{
130
+ $fieldVal = $valArr[1];
131
+ }
132
+
133
+ $headerForForm = $fieldVal;
134
+ }
135
+ }
136
+ }
137
+ }
138
+
139
+ // Show Field Applied Here
140
+ if(!empty($showArrFinal)){
141
+ foreach($fields as $key => $val){
142
+ if(!in_array($val, $showArrFinal)){
143
+ unset($fields[$key]);
144
+ }
145
+ }
146
+ }
147
+
148
+ // Hide Field Applied Here
149
+ if(!empty($hideArrFinal)){
150
+ foreach($fields as $key => $val){
151
+ if(in_array($val, $hideArrFinal)){
152
+ unset($fields[$key]);
153
+ }
154
+ }
155
+ }
156
+
157
+ //Check contact form id set or not
158
+ if (!empty($fid) && !empty($fields)){
159
+ //Add filter for ordering in entry
160
+ $cf7d_entry_order_by = (string) apply_filters('vsz_cf7_entry_order_by', '`data_id` DESC');
161
+ $cf7d_entry_order_by = sanitize_sql_orderby($cf7d_entry_order_by);
162
+
163
+ $items_per_page = (int)apply_filters('vsz_cf7_entry_per_page', (!empty($posts_per_page) ? $posts_per_page : 20));
164
+
165
+ $page = isset($_POST['cpage']) && !empty($_POST['cpage']) ? abs((int)sanitize_text_field($_POST['cpage'])) : 1;
166
+ //Setup offset related value here
167
+ $offset = (int)( $page * $items_per_page ) - $items_per_page;
168
+
169
+ //Get table name for data entry
170
+ $table_name = sanitize_text_field(VSZ_CF7_DATA_ENTRY_TABLE_NAME);
171
+
172
+ // Make sure that $fid will contain integer value only.
173
+ $fid = (int) $fid;
174
+
175
+ // If date search exists
176
+ $data_ids = '';
177
+ if(!empty($start_date) && !empty($end_date)){
178
+ $s_date = date_create_from_format("d/m/Y",sanitize_text_field($start_date));
179
+ $e_date = date_create_from_format("d/m/Y",sanitize_text_field($end_date));
180
+ //Get start date information
181
+ $start_date_str = date_format($s_date,"Y-m-d");
182
+
183
+ //Get end date information
184
+ $end_date_str = date_format($e_date,"Y-m-d").' 23:59:59';
185
+
186
+ if($start_date_str && $end_date_str){
187
+ //Setup date parameter value in query
188
+ $date_query = $wpdb->prepare("SELECT data_id FROM `{$table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND `name` = 'submit_time' AND value between %s and %s GROUP BY `data_id` ORDER BY `data_id` DESC", $fid, $start_date_str, $end_date_str);
189
+ $rs_date = $wpdb->get_results($date_query);
190
+
191
+ if(!empty($rs_date)){
192
+ foreach($rs_date as $objdata_id){
193
+ if(!empty($ids_export)){
194
+ $arr_ids = array_map('intval',explode(',',$ids_export));
195
+ if(!empty($arr_ids) && in_array($objdata_id->data_id,$arr_ids)){
196
+ $data_ids .= $objdata_id->data_id .',';
197
+ }
198
+ }
199
+ else{
200
+ $data_ids .= $objdata_id->data_id .',';
201
+ }
202
+ }
203
+ $data_ids = rtrim($data_ids,',');
204
+ }
205
+ }
206
+ }
207
+
208
+ $query = "";
209
+ $arr_total = array();
210
+ if(!empty($search) && !empty($start_date) && !empty($end_date) && !empty($data_ids)){
211
+
212
+ $query = $wpdb->prepare("SELECT * FROM `{$table_name}` WHERE `cf7_id` = %d AND data_id IN(SELECT * FROM (SELECT data_id FROM `{$table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND `value` LIKE '%%"."%s"."%%' AND data_id IN ({$data_ids}) GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} LIMIT %d,%d) temp_table) ORDER BY {$cf7d_entry_order_by}", $fid, $fid, $search, $offset, $items_per_page);
213
+
214
+ $arr_total = $wpdb->get_results($wpdb->prepare("SELECT data_id FROM `{$table_name}` WHERE `cf7_id` = %d AND `value` LIKE '%%"."%s"."%%' AND data_id IN ({$data_ids}) GROUP BY `data_id`", $fid, $search));
215
+
216
+ }else if(!empty($search) && empty($start_date) && empty($end_date)){
217
+
218
+ $query = $wpdb->prepare("SELECT * FROM `{$table_name}` WHERE `cf7_id` = %d AND data_id IN(SELECT * FROM (SELECT data_id FROM `{$table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND `value` LIKE '%%"."%s"."%%' GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} LIMIT %d,%d) temp_table) ORDER BY {$cf7d_entry_order_by}", $fid, $fid, $search, $offset, $items_per_page);
219
+
220
+ $arr_total = $wpdb->get_results($wpdb->prepare("SELECT data_id FROM `{$table_name}` WHERE `cf7_id` = %d AND `value` LIKE '%%"."%s"."%%' GROUP BY `data_id`", $fid, $search));
221
+
222
+ }else if(empty($search) && !empty($start_date) && !empty($end_date) && !empty($data_ids)){
223
+
224
+ $query = $wpdb->prepare("SELECT * FROM `{$table_name}` WHERE `cf7_id` = %d AND data_id IN(SELECT * FROM (SELECT data_id FROM `{$table_name}` WHERE 1 = 1 AND `cf7_id` = %d AND data_id IN ({$data_ids}) GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} LIMIT %d,%d) temp_table) ORDER BY {$cf7d_entry_order_by}", $fid, $fid, $offset, $items_per_page);
225
+
226
+ $arr_total = $wpdb->get_results($wpdb->prepare("SELECT data_id FROM `{$table_name}` WHERE `cf7_id` = %d AND data_id IN ({$data_ids}) GROUP BY `data_id`", $fid));
227
+
228
+ }else if(empty($search) && empty($start_date) && empty($end_date)){
229
+
230
+ $query = $wpdb->prepare("SELECT * FROM `{$table_name}` WHERE `cf7_id` = %d AND data_id IN(SELECT * FROM (SELECT data_id FROM `{$table_name}` WHERE 1 = 1 AND `cf7_id` = %d GROUP BY `data_id` ORDER BY {$cf7d_entry_order_by} LIMIT %d,%d) temp_table) ORDER BY {$cf7d_entry_order_by}", $fid, $fid, $offset, $items_per_page);
231
+
232
+ $arr_total = $wpdb->get_results($wpdb->prepare("SELECT data_id FROM `{$table_name}` WHERE `cf7_id` = %d GROUP BY `data_id`", $fid));
233
+
234
+ }
235
+
236
+ //Execute query here
237
+ $data = $wpdb->get_results($query);
238
+
239
+ //Get entry wise all fields information
240
+ $data_sorted = vsz_cf7_sortdata($data);
241
+
242
+ //get total count
243
+ $total = count($arr_total);
244
+
245
+ $display_character = (int) apply_filters('vsz_display_character_count',30);
246
+
247
+ switch($display){
248
+
249
+ case "count" :
250
+ $count[] = $total;
251
+ break;
252
+
253
+ case "table" :
254
+ default :
255
+
256
+ //Get all fields related information
257
+ if(!empty($data_sorted)){
258
+
259
+ // If title passed in attribute use that otherwise use form title
260
+ $html .= !empty($headerForForm) ? '<h2>'.esc_html($headerForForm).'</h2>' : '<h2>'.esc_html($form->title()).'</h2>';
261
+ $html .= '<table id="'.esc_html($table_id).'" class="'.esc_html($table_class).'" style="overflow: auto; '.esc_html($table_style).'">
262
+ <thead>
263
+ <tr>';
264
+
265
+ //Define table header section here
266
+ foreach ($fields as $k => $v){
267
+ $html .= '<th class="manage-column" data-key="'.esc_html($v).'">'.vsz_cf7_admin_get_field_name($v).'</th>';
268
+ }
269
+
270
+ $html .= '</tr>
271
+ </thead>
272
+ <tbody>';
273
+
274
+ foreach ($data_sorted as $k => $v) {
275
+ $k = (int)$k;
276
+ $html .= '<tr>';
277
+ foreach ($fields as $k2 => $v2) {
278
+ //Get fields related values
279
+ $_value = ((isset($v[$k2])) ? $v[$k2] : '&nbsp;');
280
+ $_value1 = filter_var($_value, FILTER_SANITIZE_URL);
281
+
282
+ //Check value is URL or not
283
+ if (!filter_var($_value1, FILTER_VALIDATE_URL) === false) {
284
+ $_value = esc_url($_value);
285
+ //If value is url then setup anchor tag with value
286
+ if(!empty($arr_field_type_info) && array_key_exists($k2,$arr_field_type_info) && $arr_field_type_info[$k2] == 'file'){
287
+ //Add download attributes in tag if field type is attachement
288
+ $_value = '<a href="'. esc_url($_value).'" target="_blank" title="'. esc_url($_value).'" download >'.esc_html(basename($_value)).'</a>';
289
+ $html .= '<td data-head="'.vsz_cf7_admin_get_field_name($v2).'">'. esc_url($_value).'</td>';
290
+ }
291
+ else{
292
+ $_value = '<a href="'. esc_url($_value).'" target="_blank" title="'. esc_url($_value).'" >'.esc_html(basename($_value)).'</a>';
293
+ $html .= '<td data-head="'.vsz_cf7_admin_get_field_name($v2).'">'. esc_url($_value).'</td>';
294
+ }
295
+ }
296
+ else{
297
+ $_value = esc_html(html_entity_decode($_value));
298
+ //var_dump(($_value)); var_dump(strlen($_value)); exit;
299
+ if(strlen($_value) > $display_character){
300
+
301
+ $html .= '<td data-head="'.vsz_cf7_admin_get_field_name($v2).'">'. esc_html(substr($_value, 0, $display_character)).'...</td>';
302
+ }else{
303
+ $html .= '<td data-head="'.vsz_cf7_admin_get_field_name($v2).'">'.esc_html($_value).'</td>';
304
+ }
305
+ }
306
+ }
307
+
308
+ $html .='</tr>';
309
+ }
310
+
311
+ $html .='</tbody>
312
+ </table>';
313
+ }
314
+ else{
315
+ $colSpan = count($fields) + 2;
316
+ $html .= '<table>
317
+ <tr>
318
+ <td colspan="'.esc_html($colSpan).'">
319
+ No records found.
320
+ </td>
321
+ </tr>
322
+ </table>';
323
+ }
324
+
325
+ break;
326
+ }
327
+
328
+ }
329
+ }
330
+ }
331
+ }
332
+
333
+ if(!empty($count)){
334
+ if(count($count)>1){
335
+ $totalVal = 0;
336
+ foreach($count as $val){
337
+ $totalVal += $val;
338
+ }
339
+
340
+ return $totalVal;
341
+ }
342
+ else{
343
+ return implode(",",$count);
344
+ }
345
+ }
346
+ else{
347
+ return $html;
348
+ }
349
+
350
+