Changeset 1643938
- Timestamp:
- 04/24/2017 01:26:01 PM (9 years ago)
- File:
-
- 1 edited
-
cf7records/trunk/save-contact-details.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cf7records/trunk/save-contact-details.php
r1643762 r1643938 26 26 27 27 function savedata_px_register_admin_menu() { 28 add_submenu_page('wpcf7', 'Submitted Forms', 'Contact Messages', 'manage_options', basename(__FILE__), array($this, 'px_options_page')); 28 add_menu_page('Contact Messages', 29 'Contact Messages', 30 'manage_options', 31 basename(__FILE__), array($this, 32 'px_options_page')); 29 33 } 30 34 … … 108 112 <div class="wrap"> 109 113 110 <h1> Save & Export</h1>114 <h1>CF7 Records</h1> 111 115 <h3>Select contact form</h3> 112 116 … … 143 147 <!--<button type="submit" class="button button-default button-large export_to_csv" style="float: right;margin-bottom: 10px;">Export to CSV</button>--> 144 148 </form> 145 146 <?php147 if (isset($_GET['export_csv'])) {148 // Set header row values149 $csv_fields=array();150 $csv_fields[] = 'Field Name 1';151 $csv_fields[] = 'Field Name 2';152 $output_filename = 'MyReport_Contact_Messages.csv';153 $output_handle = @fopen( 'php://output', 'w' );154 155 header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );156 header( 'Content-Description: File Transfer' );157 header( 'Content-type: text/csv' );158 header( 'Content-Disposition: attachment; filename=' . $output_filename );159 header( 'Expires: 0' );160 header( 'Pragma: public' );161 162 // Insert header row163 fputcsv( $output_handle, $csv_fields );164 foreach ($result as $one_result) {165 $query = 'SELECT `key`, value FROM ' . $wpdb->prefix . 'savedata WHERE form_submit_id="' . $one_result->form_submit_id . '"';166 $data = $wpdb->get_results($query);167 foreach ($data as $item) {168 $leadArray = (array)$item;169 fputcsv($output_handle, $leadArray);170 }171 }172 fclose( $output_handle );173 die();174 175 // Close output file stream176 }177 ?>178 179 149 <table id="grid-basic" class="table table-hover table-striped"> 180 <thead> 181 <tr> 182 <!--<th>ID</th>--> 183 <th>Date</th> 184 <th>Name</th> 185 <th>Email</th> 186 <th>Subject</th> 187 <th>View Details</th> 188 </tr> 189 </thead> 190 <tbody> 191 <?php foreach ($result as $key => $value): ?> 150 151 <?php 152 $counter=0; 153 foreach ($result as $key => $value): 154 $counter++; 155 if($counter==1){ 156 ?> 157 <thead> 158 192 159 <tr> 193 <!--<td><?php echo $key+1; ?></td>--> 160 <th>Date</th> 161 <?php $query = 'SELECT `key`, value, id FROM ' . $wpdb->prefix . 'savedata WHERE form_submit_id="' . $value->form_submit_id . '" ORDER BY date DESC'; ?> 162 <?php 163 $data = $wpdb->get_results($query); 164 $cntH=0; 165 foreach ($data as $item): 166 echo '<th>'.$item->key.'</th>'; 167 $cntH++; 168 if($cntH>3){ 169 break; 170 } 171 endforeach; ?> 172 173 174 <th>View Details</th> 175 </tr> 176 </thead> 177 <?php } ?> 178 <tbody> 179 <tr> 194 180 <td><?php echo $value->date ?></td> 195 181 196 <?php $query = 'SELECT `key`, value, id FROM ' . $wpdb->prefix . 'savedata WHERE form_submit_id="' . $value->form_submit_id . '" '; ?>182 <?php $query = 'SELECT `key`, value, id FROM ' . $wpdb->prefix . 'savedata WHERE form_submit_id="' . $value->form_submit_id . '" ORDER BY date DESC'; ?> 197 183 <?php 198 184 $data = $wpdb->get_results($query); 185 $cntD=0; 199 186 foreach ($data as $item): 200 $queryD = 'SELECT value FROM ' . $wpdb->prefix . 'savedata WHERE id="' . $item->id . '"';201 $dataD = $wpdb->get_results($queryD);202 if($item->key!="your-message")203 187 echo '<td>'.$item->value.'</td>'; 188 $cntD++; 189 if($cntD>3){ 190 break; 191 } 204 192 endforeach; ?> 205 193 </td> … … 271 259 ?> 272 260 </div> 273 <br>274 <div class="cf7_item_wrapper">275 <h2>Mail Settings</h2>276 261 <?php 277 foreach ($result as $key => $row) :278 ?>279 <div class="row">280 <label>ID</label>281 <label style="width: 75%; float: right"><?php echo $row->id ?></label>282 <div style="clear: both"></div>283 </div>284 <div class="row">285 <label>Form Title</label>286 <label style="width: 75%; float: right"><?php echo $row->sv_title ?></label>287 <div style="clear: both"></div>288 </div>289 <div class="row">290 <label>Contact form 7 ID</label>291 <label style="width: 75%; float: right"><?php echo $row->sv_data ?></label>292 <div style="clear: both"></div>293 </div>294 <div class="row">295 <label>Mail 1</label>296 <textarea readonly style="border: none; margin-left: 40px;"><?php echo $row->mail ?></textarea>297 <div style="clear: both"></div>298 </div>299 <div class="row">300 <label>Mail 2</label>301 <textarea readonly style="border: none; margin-left: 40px;"><?php echo $row->mail_2 ?></textarea>302 <div style="clear: both"></div>303 </div>304 <div class="row">305 <label>Email Subject</label>306 <label style="width: 75%; float: right"><?php echo $row->sv_subject ?></label>307 <div style="clear: both"></div>308 </div>309 <div class="row">310 <label>Email Subject 2</label>311 <label style="width: 75%; float: right"><?php echo $row->sv_subject_2 ?></label>312 <div style="clear: both"></div>313 </div>314 </div>315 <?php316 //just want to run it once317 break;318 endforeach;319 262 } 320 263 ?>
Note: See TracChangeset
for help on using the changeset viewer.