function createFile($data, $columns, $apiKey) { $jotform = new JotForm($apiKey); $userInfo = $jotform->getUser(); $filename = $userInfo['username'] . '_' . rand(); $fp = fopen('CSVs/' . $filename . '.csv', 'w'); fputcsv($fp, $columns); $count = 0; $limit = 2000; $limited = false; foreach ($data as $submission_id => $submission) { if (++$count > $limit) { $limited = true; break; } $outputLine = array(); foreach ($columns as $title) { if (array_key_exists($title, $submission)) { array_push($outputLine, $submission[$title]); } else { array_push($outputLine, ''); } } fputcsv($fp, $outputLine); } fclose($fp); $warning = $limited ? "CSV file limited to " + $limit + " lines" : false; $data = array('warning' => $warning, 'filename' => $filename); echo json_encode($data); }
" /> </form> <!-- end of #dxtemplate-form --> <?php try { $jc_settings = get_option('jc_setting', ''); $jt = new JotForm($jc_settings['jc_api_key']); $key = $jc_settings['jc_api_key']; if (!$key == "") { echo "<script> JF.initialize({ apiKey: '{$key}' }) </script>"; } $users = $jt->getUser(); //var_dump($users); echo '<hr/>'; echo '<h3> Account Information </h3>'; echo '<table width="600px" class="sc">'; foreach ($users as $key => $user) { printf(' <tr> <th scope="row">%s</th> <td>%s</td> </tr>', $key, $user); } echo '</table>'; } catch (Exception $e) { //echo ($e->getMessage()); echo '<p> <button id="jotFormLogin" class=" jotFormLogin button button-primary">Connect with JotForm</button></p>';