function exportSavedFormSubmissionsToCSV($form_id = NULL)
 {
     ccf_utils::load_module('export/custom-contact-forms-user-data.php');
     $out = array();
     $col_header = array(__('Form Submitted', 'custom-contact-forms'), __('Date', 'custom-contact-forms'), __('Form Location', 'custom-contact-forms'), __('Form ID', 'custom-contact-forms'));
     $extra_cols = array();
     $out[] = $col_header;
     $user_data_array = parent::selectAllUserData($form_id);
     $i = 0;
     foreach ($user_data_array as $data_object) {
         $line = array();
         $data = new CustomContactFormsUserData(array('form_id' => $data_object->data_formid, 'data_time' => $data_object->data_time, 'form_page' => $data_object->data_formpage, 'encoded_data' => $data_object->data_value));
         $data_form = parent::selectForm($data->getFormID());
         $this_form = !empty($data_form->form_slug) ? $data_form->form_slug : '-';
         $line[] = $this_form;
         $line[] = date('F d, Y h:i:s A', $data->getDataTime());
         $line[] = $data->getFormPage();
         $line[] = $data->getFormID();
         $data_array = $data->getDataArray();
         ksort($data_array);
         if ($i == 0) {
             foreach ($data_array as $item_key => $item_value) {
                 $extra_cols[] = $item_key;
             }
         }
         foreach ($extra_cols as $k) {
             $line[] = $data->parseUserData($data_array[$k], true);
             unset($data_array[$k]);
         }
         foreach ($data_array as $key => $value) {
             $line[] = $data->parseUserData($value, true);
         }
         $out[] = $line;
         $i++;
     }
     if ($form_id != NULL) {
         sort($extra_cols);
         foreach ($extra_cols as $c) {
             $out[0][] = $c;
         }
     }
     $this->csv_array = $out;
     return $out;
 }
        function display()
        {
            ccf_utils::load_module('export/custom-contact-forms-user-data.php');
            $user_data_array = parent::selectAllUserData();
            ?>
			<table id="ccf-dashboard" cellpadding="0" cellspacing="0">
			  <thead>
				<tr>
				  <th>Date</th>
				  <th>Form</th>
				  <th>Form Location</th>
				  <th></th>
				</tr>
			  </thead>
			  <tbody>
			<?php 
            if (empty($user_data_array)) {
                ?>
               <tr>
               	 <td colspan="4"><?php 
                _e('No submissions to display.', 'custom-contact-forms');
                ?>
</td> 
               </tr>
                <?php 
            }
            $i = 0;
            foreach ($user_data_array as $data_object) {
                if ($i > 3) {
                    break;
                }
                $data = new CustomContactFormsUserData(array('form_id' => $data_object->data_formid, 'data_time' => $data_object->data_time, 'form_page' => $data_object->data_formpage, 'encoded_data' => $data_object->data_value));
                ?>
				<tr class="<?php 
                if ($i % 2 == 1) {
                    echo 'even';
                }
                ?>
">
					<td class="date"><?php 
                echo date('m/d/y', $data->getDataTime());
                ?>
</td>
					<td class="slug">
					<?php 
                if ($data->getFormID() > 0) {
                    $data_form = parent::selectForm($data->getFormID());
                    $this_form = !empty($data_form->form_slug) ? $data_form->form_slug : '-';
                } else {
                    $this_form = __('Custom HTML Form', 'custom-contact-forms');
                }
                if (strlen($this_form) > 13) {
                    echo substr($this_form, 0, 13) . '...';
                } else {
                    echo $this_form;
                }
                ?>
					</td>
					<td class="form-page">
					<?php 
                if (strlen($data->getFormPage()) > 30) {
                    echo substr($data->getFormPage(), 0, 30) . '...';
                } else {
                    echo $data->getFormPage();
                }
                ?>
					</td>
					<td>
						<input class="ccf-view-submission" type="button" value="<?php 
                _e('View', 'custom-contact-forms');
                ?>
" />
						<div class="ccf-view-submission-popover" title="<?php 
                _e('CCF Saved Form Submission', 'custom-contact-forms');
                ?>
">
							<div class="top">
								<div class="left">
								<p><?php 
                _e('Form Submitted:', 'custom-contact-forms');
                ?>
 <span><?php 
                echo $this_form == '-' ? __('Not Found', 'custom-contact-forms') : $this_form;
                ?>
</span></p>
								<p><?php 
                _e('Form Location:', 'custom-contact-forms');
                ?>
 <span>
								<?php 
                if (strlen($data->getFormPage()) > 70) {
                    echo substr($data->getFormPage(), 0, 70) . '...';
                } else {
                    echo $data->getFormPage();
                }
                ?>
</span></p></div>
								<div class="right"><span><?php 
                echo date('F j, Y, g:i a', $data->getDataTime());
                ?>
</span></div>
							</div>
							<div class="separate"></div>
							<ul>
								<?php 
                $data_array = $data->getDataArray();
                foreach ($data_array as $item_key => $item_value) {
                    ?>
								<li>
								  <div><?php 
                    echo $item_key;
                    ?>
</div>
								  <p><?php 
                    echo $data->parseUserData($item_value);
                    ?>
</p>
								</li>
								<?php 
                }
                ?>
							</ul>
							<div class="separate"></div>
                            <a class="button" href="admin.php?page=ccf-saved-form-submissions"><?php 
                _e('View All Submissions', 'custom-contact-forms');
                ?>
</a>
						</div>
					</td>
				</tr>
				<?php 
                $i++;
            }
            ?>
			  </tbody>
			</table>
			<a href="admin.php?page=ccf-saved-form-submissions"><?php 
            _e('View All Submissions', 'custom-contact-forms');
            ?>
</a>
			<?php 
        }
        function printFormSubmissionsPage()
        {
            $this->handleAdminPostRequests();
            if ($admin_options['show_install_popover'] == 1) {
                $admin_options['show_install_popover'] = 0;
                ?>
                <script type="text/javascript" language="javascript">
					$j(document).ready(function() {
						showCCFUsagePopover();
					});
				</script>
                <?php 
                update_option(parent::getAdminOptionsName(), $admin_options);
            }
            /*if ($_POST['form_submission_delete']) {
            			if (parent::deleteUserData($_POST['uid']) != false)
            				$this->action_complete = __('A form submission has be successfully deleted!', 'custom-contact-forms');
            		}*/
            ccf_utils::load_module('export/custom-contact-forms-user-data.php');
            $user_data_array = parent::selectAllUserData();
            ?>
			<div id="customcontactforms-admin">
			  <div class="plugin-header">
				<h2>
					<?php 
            _e("Custom Contact Forms", 'custom-contact-forms');
            ?>
				</h2>
             	<div class="links">
                	<a href="javascript:void(0)" class="quick-start-button">Quick Start Guide</a> - <a href="javascript:void(0)" class="usage-popover-button">Plugin Usage Manual</a>
              	</div>
              </div>
			  <a class="genesis" href="http://www.shareasale.com/r.cfm?b=241369&u=481196&m=28169&urllink=&afftrack=">Custom Contact Forms works best with any of the 20+ <span>Genesis</span> Wordpress child themes. The <span>Genesis Framework</span> empowers you to quickly and easily build incredible websites with WordPress.</a>
			
			<form class="blog-horizontal-form" method="post" action="http://www.aweber.com/scripts/addlead.pl">
            	<input type="hidden" name="meta_web_form_id" value="1578604781" />
				<input type="hidden" name="meta_split_id" value="" />
				<input type="hidden" name="listname" value="ccf-plugin" />
				<input type="hidden" name="redirect" value="http://www.taylorlovett.com/wordpress-plugins/tutorials-offers-tips/" id="redirect_5832e41084448adb07da67a35dc83c27" />
				<input type="hidden" name="meta_adtracking" value="CCF_-_Wordpress_Plugins_Horizontal" />
				<input type="hidden" name="meta_message" value="1" />
				<input type="hidden" name="meta_required" value="name,email" />
				<span>WP Blogging Tips, Downloads, SEO Tricks & Exclusive Tutorials</span>
                <input type="text" name="name" value="Your Name" onclick="value=''" />
                <input type="text" name="email" value="Your Email" onclick="value=''" />
                <input type="submit" value="Sign Up for Free" />
            </form>
			<?php 
            if (!empty($this->action_complete)) {
                ?>
			<div id="message" class="updated below-h2">
				<p><?php 
                echo $this->action_complete;
                ?>
</p>
			</div>
			<?php 
            }
            ?>
			  <h3 class="hndle"><span>
				  <?php 
            _e("Saved Form Submissions", 'custom-contact-forms');
            ?>
				  </span></h3>
			  <form class="ccf-edit-ajax" method="post" action="<?php 
            echo $_SERVER['REQUEST_URI'];
            ?>
">
			  <table class="widefat post" id="form-submissions-table" cellspacing="0">
				<thead>
				  <tr>
					<th scope="col" class="manage-column ccf-width25"><input type="checkbox" class="checkall" /></th>
					<th scope="col" class="manage-column ccf-width250"><?php 
            _e("Date Submitted", 'custom-contact-forms');
            ?>
</th>
					<th scope="col" class="manage-column ccf-width150"><?php 
            _e("Form Submitted", 'custom-contact-forms');
            ?>
</th>
					<th scope="col" class="manage-column ccf-width250"><?php 
            _e("Form Page", 'custom-contact-forms');
            ?>
</th>
					<th scope="col" class="manage-column "></th>
				  </tr>
				</thead>
				<tbody>
                  <?php 
            $i = 0;
            foreach ($user_data_array as $data_object) {
                $data = new CustomContactFormsUserData(array('form_id' => $data_object->data_formid, 'data_time' => $data_object->data_time, 'form_page' => $data_object->data_formpage, 'encoded_data' => $data_object->data_value));
                ?>
				  <tr class="row-form_submission-<?php 
                echo $data_object->id;
                ?>
 submission-top <?php 
                if ($i % 2 == 0) {
                    echo 'ccf-evenrow';
                }
                ?>
">
					<td><input type="checkbox" class="object-check" value="1" name="objects[<?php 
                echo $i;
                ?>
][object_do]" /></td>
					<td><?php 
                echo date('F d, Y h:i:s A', $data->getDataTime());
                ?>
</td>
					<td><?php 
                if ($data->getFormID() > 0) {
                    $data_form = parent::selectForm($data->getFormID());
                    $this_form = !empty($data_form->form_slug) ? $data_form->form_slug : '-';
                    echo $this_form;
                } else {
                    _e('Custom HTML Form', 'custom-contact-forms');
                }
                ?>
					</td>
					<td><?php 
                echo $data->getFormPage();
                ?>
 </td>
					<td class="ccf-alignright">
						<span class="submission-content-expand"></span>
						<input type="hidden" name="objects[<?php 
                echo $i;
                ?>
][object_type]" value="form_submission" />
						<input class="object-id" type="hidden" name="objects[<?php 
                echo $i;
                ?>
][object_id]" value="<?php 
                echo $data_object->id;
                ?>
" />
					 </td>
				  </tr>
				  <tr class="row-form_submission-<?php 
                echo $data_object->id;
                ?>
 submission-content <?php 
                if ($i % 2 == 0) {
                    echo 'ccf-evenrow';
                }
                ?>
">
					<td colspan="5"><ul>
						<?php 
                $data_array = $data->getDataArray();
                foreach ($data_array as $item_key => $item_value) {
                    ?>
						<li>
						  <div><?php 
                    echo $item_key;
                    ?>
</div>
						  <p><?php 
                    echo $data->parseUserData($item_value);
                    ?>
</p>
						</li>
						<?php 
                }
                ?>
					  </ul></td>
				  </tr>
				  <?php 
                $i++;
            }
            ?>
				</tbody>
				<tfoot>
				  <tr>
					<th scope="col" class="manage-column25"><input type="checkbox" class="checkall" /></th>
					<th scope="col" class="manage-column ccf-width250"><?php 
            _e("Date Submitted", 'custom-contact-forms');
            ?>
</th>
					<th scope="col" class="manage-column ccf-width150"><?php 
            _e("Form Submitted", 'custom-contact-forms');
            ?>
</th>
					<th scope="col" class="manage-column ccf-width250"><?php 
            _e("Form Page", 'custom-contact-forms');
            ?>
</th>
					<th scope="col" class="manage-column"></th>
				  </tr>
				</tfoot>
			  </table>
              
			  <select class="bulk-dropdown" name="object_bulk_action">
				<option value="0"><?php 
            _e('Bulk Actions', 'custom-contact-forms');
            ?>
</option>
				<option value="delete"><?php 
            _e('Delete', 'custom-contact-forms');
            ?>
</option>
			  </select> <input type="submit" class="bulk-apply" name="object_bulk_apply" value="<?php 
            _e('Apply', 'custom-contact-forms');
            ?>
" /> <img src="<?php 
            echo plugins_url();
            ?>
/custom-contact-forms/images/wpspin_light.gif" class="loading-img" width="16" height="16" />
			  
			  
			  
			  </form>
			  <?php 
            $this->insertUsagePopover();
            ?>
              <?php 
            $this->insertQuickStartPopover();
            ?>
			</div>
			<?php 
        }