public function export($formName, $options = null)
    {
        $plugin = new CF7DBPlugin();
        if (!$plugin->canUserDoRoleOption('CanSeeSubmitData')) {
            CFDBDie::wp_die(__('You do not have sufficient permissions to access this page.', 'contact-form-7-to-database-extension'));
        }
        header('Expires: 0');
        header('Cache-Control: no-store, no-cache, must-revalidate');
        $pluginUrlDir = $plugin->getPluginDirUrl();
        $scriptLink = $pluginUrlDir . 'Cf7ToDBGGoogleSS.js.php';
        $imageUrlDir = $pluginUrlDir . "help";
        $siteUrl = get_option('home');
        $search = isset($options['search']) ? $options['search'] : '';
        ob_start();
        ?>
        <style type="text/css">
            *.popup-trigger {
                position: relative;
                z-index: 0;
            }

            *.popup-trigger:hover {
                background-color: transparent;
                z-index: 50;
            }

            *.popup-content {
                position: absolute!important;
                background-color: #ffffff;
                padding: 5px;
                border: 2px gray;
                visibility: hidden!important;
                color: black;
                text-decoration: none;
                min-width:400px;
                max-width:600px;
                overflow: auto;
            }

            *.popup-trigger:hover *.popup-content {
                visibility: visible!important;
                top: 50px!important;
                left: 50px!important;
            }
        </style>
        Setting up a Google Spreadsheet to pull in data from WordPress requires these manual steps:
        <table cellspacing="15px" cellpadding="15px">
            <tbody>
            <tr>
                <td>
                    <div class="popup-trigger">
                        <a href="<?php 
        echo $imageUrlDir;
        ?>
/GoogleNewSS.png">
                            <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleNewSS.png" alt="Create a new spreadsheet" height="100px" width="61px"/>

                            <div class="popup-content">
                                <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleNewSS.png" alt="Create a new spreadsheet"/>
                            </div>
                        </a>
                    </div>
                </td>
                <td><p>Log into Google Docs and create a new Google Spreadsheet</p></td>
            </tr>
            <tr>
                <td>
                    <div class="popup-trigger">
                        <a href="<?php 
        echo $imageUrlDir;
        ?>
/GoogleOpenScriptEditor.png">
                            <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleOpenScriptEditor.png" alt="Create a new spreadsheet" height="69px" width="100px"/>

                            <div class="popup-content">
                                <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleOpenScriptEditor.png" alt="Create a new spreadsheet"/>
                            </div>
                        </a>
                    </div>
                </td>
                <td><p>Go to <b>Tools</b> menu -> <b>Scripts</b> -> <b>Script Editor...</b></p></td>
            </tr>
            <tr>
                <td>
                    <div class="popup-trigger">
                        <a href="<?php 
        echo $imageUrlDir;
        ?>
/GooglePasteScriptEditor.png">
                            <img src="<?php 
        echo $imageUrlDir;
        ?>
/GooglePasteScriptEditor.png" alt="Paste script text" height="68px" width="100px"/>

                            <div class="popup-content">
                                <img src="<?php 
        echo $imageUrlDir;
        ?>
/GooglePasteScriptEditor.png" alt="Paste script text"/>
                            </div>
                        </a>
                    </div>
                </td>
                <td>
                    <p>Delete any text that is already there</p>
                    <p><b>Copy</b> the text from <a target="_gscript" href="<?php 
        echo $scriptLink;
        ?>
">THIS SCRIPT FILE</a> and <b>paste</b> it
                    into the Google script editor</p>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="popup-trigger">
                        <a href="<?php 
        echo $imageUrlDir;
        ?>
/GoogleSaveScriptEditor.png">
                            <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleSaveScriptEditor.png" alt="Create a new spreadsheet" height="100px" width="83px"/>

                            <div class="popup-content">
                                <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleSaveScriptEditor.png" alt="Create a new spreadsheet"/>
                            </div>
                        </a>
                    </div>
                </td>
                <td>
                    <p><b>Save</b> and <b>close</b> the script editor.</p>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="popup-trigger">
                        <a href="<?php 
        echo $imageUrlDir;
        ?>
/GoogleEnterFormula.png">
                            <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleEnterFormula.png" alt="Create a new spreadsheet" height="43px" width="100px"/>

                            <div class="popup-content">
                                <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleEnterFormula.png" alt="Create a new spreadsheet"/>
                            </div>
                        </a>
                    </div>
                </td>
                <td>
                    <p>Click on a cell A1 in the Spreadsheet (or any cell)</p>
                    <p>Enter in the cell the formula:</p>
                    <p><code><?php 
        echo "=CF7ToDBData(\"{$siteUrl}\", \"{$formName}\", \"{$search}\", \"user\", \"pwd\")";
        ?>
</code></p>
                    <p>Replacing <b>user</b> and <b>pwd</b> with your <u>WordPress</u> site user name and password</p>
                </td>
            </tr>
            <tr>

            </tr>
            </tbody>
        </table>
        <span style="color:red; font-weight:bold;">
            WARNING: since you are putting your login information into the Google Spreadsheet, be sure not to share
        the spreadsheet with others.</span>
        <?php 
        $html = ob_get_contents();
        ob_end_clean();
        CFDBDie::wp_die($html, __('How to Set up Google Spreadsheet to pull data from WordPress', 'contact-form-7-to-database-extension'), array('response' => 200, 'back_link' => true));
    }
    public function export($formName, $options = null)
    {
        $plugin = new CF7DBPlugin();
        if (!$plugin->canUserDoRoleOption('CanSeeSubmitData')) {
            CFDBDie::wp_die(__('You do not have sufficient permissions to access this page.', 'contact-form-7-to-database-extension'));
        }
        header('Expires: 0');
        header('Cache-Control: no-store, no-cache, must-revalidate');
        $pluginUrlDir = $plugin->getPluginDirUrl();
        $scriptLink = $pluginUrlDir . 'CFDBGoogleSSLiveData.php';
        $imageUrlDir = $pluginUrlDir . "help";
        $siteUrl = get_option('home');
        $userName = is_user_logged_in() ? wp_get_current_user()->user_login : '******';
        ob_start();
        ?>
        <style type="text/css">
            *.popup-trigger {
                position: relative;
                z-index: 0;
            }

            *.popup-trigger:hover {
                background-color: transparent;
                z-index: 50;
            }

            *.popup-content {
                position: absolute!important;
                background-color: #ffffff;
                padding: 5px;
                border: 2px gray;
                visibility: hidden!important;
                color: black;
                text-decoration: none;
                min-width:400px;
                max-width:600px;
                overflow: auto;
            }

            *.popup-trigger:hover *.popup-content {
                visibility: visible!important;
                top: 50px!important;
                left: 50px!important;
            }
        </style>
        <?php 
        _e('Setting up a Google Spreadsheet to pull in data from WordPress requires these manual steps:', 'contact-form-7-to-database-extension');
        ?>
        <table cellspacing="15px" cellpadding="15px">
            <tbody>
            <tr>
                <td>
                    <div class="popup-trigger">
                        <a href="<?php 
        echo $imageUrlDir;
        ?>
/GoogleNewSS.png">
                            <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleNewSS.png" alt="Create a new spreadsheet" height="100px" width="61px"/>

                            <div class="popup-content">
                                <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleNewSS.png" alt="Create a new spreadsheet" height="75%" width="75%"/>
                            </div>
                        </a>
                    </div>
                </td>
                <td><p><?php 
        _e('Log into Google Docs and create a new Google Spreadsheet', 'contact-form-7-to-database-extension');
        ?>
</p></td>
            </tr>
            <tr>
                <td>
                    <div class="popup-trigger">
                        <a href="<?php 
        echo $imageUrlDir;
        ?>
/GoogleOpenScriptEditor.png">
                            <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleOpenScriptEditor.png" alt="Create a new spreadsheet" height="69px" width="100px"/>

                            <div class="popup-content">
                                <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleOpenScriptEditor.png" alt="Create a new spreadsheet" height="75%" width="75%"/>
                            </div>
                        </a>
                    </div>
                </td>
                <td><p><?php 
        _e('Go to <strong>Tools</strong> menu -> <strong>Script Editor...', 'contact-form-7-to-database-extension');
        ?>
</p></td>
            </tr>
            <tr>
                <td>
                    <div class="popup-trigger">
                        <a href="<?php 
        echo $imageUrlDir;
        ?>
/GoogleChooseSpreadsheet.png">
                            <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleChooseSpreadsheet.png" alt="Choose Spreadsheet" height="69px" width="100px"/>

                            <div class="popup-content">
                                <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleChooseSpreadsheet.png" alt="GoogleChooseSpreadsheet Spreadsheet" height="75%" width="75%"/>
                            </div>
                        </a>
                    </div>
                </td>
                <td><p><?php 
        _e('Choose <strong>Spreadsheet</strong>', 'contact-form-7-to-database-extension');
        ?>
</p></td>
            </tr>
            <tr>
                <td>
                    <div class="popup-trigger">
                        <a href="<?php 
        echo $imageUrlDir;
        ?>
/GooglePasteScriptEditor.png">
                            <img src="<?php 
        echo $imageUrlDir;
        ?>
/GooglePasteScriptEditor.png" alt="Paste script text" height="68px" width="100px"/>

                            <div class="popup-content">
                                <img src="<?php 
        echo $imageUrlDir;
        ?>
/GooglePasteScriptEditor.png" alt="Paste script text" height="75%" width="75%"/>
                            </div>
                        </a>
                    </div>
                </td>
                <td>
                    <p><?php 
        _e('Delete any text that is already there', 'contact-form-7-to-database-extension');
        ?>
</p>
                    <p><?php 
        _e('<strong>Copy</strong> the text from ', 'contact-form-7-to-database-extension');
        ?>
                        <a target="_gscript" href="<?php 
        echo $scriptLink;
        ?>
"><?php 
        _e('THIS SCRIPT FILE', 'contact-form-7-to-database-extension');
        ?>
</a>
                        <?php 
        _e('and <strong>paste</strong> it into the Google script editor', 'contact-form-7-to-database-extension');
        ?>
</p>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="popup-trigger">
                        <a href="<?php 
        echo $imageUrlDir;
        ?>
/GoogleSaveScriptEditor.png">
                            <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleSaveScriptEditor.png" alt="Create a new spreadsheet" height="100px" width="83px"/>

                            <div class="popup-content">
                                <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleSaveScriptEditor.png" alt="Create a new spreadsheet" height="75%" width="75%"/>
                            </div>
                        </a>
                    </div>
                </td>
                <td>
                    <p><?php 
        _e('<strong>Save</strong> the script', 'contact-form-7-to-database-extension');
        ?>
</p>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="popup-trigger">
                        <a href="<?php 
        echo $imageUrlDir;
        ?>
/GoogleEnterFormula.png">
                            <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleEnterFormula.png" alt="Create a new spreadsheet" height="43px" width="100px"/>

                            <div class="popup-content">
                                <img src="<?php 
        echo $imageUrlDir;
        ?>
/GoogleEnterFormula.png" alt="Create a new spreadsheet" height="75%" width="75%"/>
                            </div>
                        </a>
                    </div>
                </td>
                <td>
                    <p><?php 
        _e('Click on a cell A1 in the Spreadsheet (or any cell)', 'contact-form-7-to-database-extension');
        ?>
                        <br/><?php 
        _e('Enter in the cell the formula:', 'contact-form-7-to-database-extension');
        ?>
                        <br/><span style="background-color: yellow"><code><?php 
        echo "=cfdbdata(\"{$siteUrl}\", \"{$formName}\", \"{$userName}\", \"&lt;password&gt;\")";
        ?>
</code></span>
                        <br/><?php 
        _e('Replace <strong>&lt;password&gt;</strong> with your <em>WordPress</em> password', 'contact-form-7-to-database-extension');
        ?>
                    </p>
                    <?php 
        $scBuilderPageUrl = $siteUrl . '/wp-admin/admin.php?page=CF7DBPluginShortCodeBuilder&enc=GLD&form=' . urlencode($formName);
        ?>
                    <p>
                        <a href="<?php 
        echo $scBuilderPageUrl;
        ?>
" target="sc"><?php 
        _e('Customize the output by creating a Google Spreadsheet Function call with additional options', 'contact-form-7-to-database-extension');
        ?>
</a>
                    </p>
                </td>
            </tr>
            </tbody>
        </table>
        <span style="color:red; font-weight:bold;">
            WARNING: since you are putting your login information into the Google Spreadsheet, be sure not to share
        the spreadsheet with others.</span>
        <?php 
        $html = ob_get_contents();
        ob_end_clean();
        CFDBDie::wp_die($html, __('How to Set up Google Spreadsheet to pull data from WordPress', 'contact-form-7-to-database-extension'), array('response' => 200, 'back_link' => true));
    }
    /**
     * @param  $plugin CF7DBPlugin
     * @return void
     */
    function display(&$plugin)
    {
        if ($plugin == null) {
            $plugin = new CF7DBPlugin();
        }
        $forms = $plugin->getForms();
        $importUrl = admin_url('admin-ajax.php') . '?action=cfdb-importcsv';
        ?>
        <h2><?php 
        _e('Import CSV File into Form', 'contact-form-7-to-database-extension');
        ?>
</h2>
        <form enctype="multipart/form-data" action="<?php 
        echo $importUrl;
        ?>
" method="post">
            <table>
                <tbody>
                <tr>
                    <td><label for="file"><?php 
        _e('File', 'contact-form-7-to-database-extension');
        ?>
</label></td>
                    <td><input type="file" name="file" id="file" size="50"></td>
                </tr>
                <tr>
                    <td><input type="radio" name="into" id="new" value="new" checked> <?php 
        _e('New Form', 'contact-form-7-to-database-extension');
        ?>
</td>
                    <td><input type="text" name="newformname" id="newformname" size="50"/></td>
                </tr>
                <tr>
                    <td><input type="radio" name="into" id="existing" value="into"> <?php 
        _e('Existing Form', 'contact-form-7-to-database-extension');
        ?>
</td>
                    <td>
                        <select name="form" id="form">
                            <option value=""></option>
                            <?php 
        foreach ($forms as $formName) {
            echo "<option value=\"{$formName}\">{$formName}</option>";
        }
        ?>
                        </select>
                    </td>
                </tr>
                </tbody>
            </table>
            <input type="submit" name="<?php 
        _e('Import', 'contact-form-7-to-database-extension');
        ?>
" id="importsubmit" value="import">
        </form>

        <script type="text/javascript">
                jQuery('#file').change(function () {
                    var val = jQuery(this).val();
                    val = val.substring(val.lastIndexOf('/') + 1);
                    val = val.substring(val.lastIndexOf('\\') + 1);
                    val = val.replace(/\.([^\.])*$/, "");
                    jQuery('#newformname').val(val);
                });
        </script>

        <h2><?php 
        _e('Backup Form to CSV File', 'contact-form-7-to-database-extension');
        ?>
</h2>
        <ul>
            <li><?php 
        _e('Backup a form into a CSV file that can be re-imported without loss of data.', 'contact-form-7-to-database-extension');
        ?>
</li>
            <li><?php 
        _e('Limitation: this will not export file uploads.', 'contact-form-7-to-database-extension');
        ?>
</li>
            <li><?php 
        _e('Limitation: extremely large numbers of records in your form may cause the export operation on your server to run out of memory, thereby not giving you all the rows.', 'contact-form-7-to-database-extension');
        ?>
</li>
        </ul>
        <form method="get" action="<?php 
        echo $plugin->getPluginDirUrl();
        ?>
export.php">
            <input type="hidden" name="enc" value="CSV"/>
            <input type="hidden" name="bak" value="true"/>
            <select name="form">
                <option value=""></option>
                <?php 
        foreach ($forms as $formName) {
            echo "<option value=\"{$formName}\">{$formName}</option>";
        }
        ?>
            </select>
            <input type="submit" name="<?php 
        _e('Export', 'contact-form-7-to-database-extension');
        ?>
" value="export">
        </form>
    <?php 
    }