function testDataExportModule() { $new_DataExport = new DataExport("1/1/2012", "Jan", "Smith", "female", "volunteer", "", "123 Main St", "Portland", "ME", 04011, "Cumberland", 0125557777, 1238883333, "*****@*****.**", "Big Co.", "active", 4, "Thu", "December", "1/1/2011"); // first assertion: check that getter for gender is working for initialized data $this->assertTrue($new_DataExport->get_gender() == "female"); echo "testDataExport complete"; }
/** * @param $userid * @param $headers * @param $table_csv * @param array $fields * @param $parent_chkd_flds * @param $export_file_name * @param $debug * @param null $comment * @param array $to */ public static function do_sendit($userid, $headers, $table_csv, $fields = array(), $parent_chkd_flds, $export_file_name, $comment = null, $to = array(), $debug) { global $project_id, $user_rights, $app_title, $lang, $redcap_version; // we could use the global $userid, but we need control of it for setting the user as [CRON], so this is passed in args. $return_val = false; $export_type = 0; // this puts all files generated here in the Data Export category in the File Repository $today = date("Y-m-d_Hi"); //get today for filename $projTitleShort = substr(str_replace(" ", "", ucwords(preg_replace("/[^a-zA-Z0-9 ]/", "", html_entity_decode($app_title, ENT_QUOTES)))), 0, 20); // shortened project title for filename $originalFilename = $projTitleShort . "_" . $export_file_name . "_DATA_" . $today . ".csv"; // name the file for storage $today = date("Y-m-d-H-i-s"); // get today for comment, subsequent processing as needed $docs_comment_WH = $export_type ? "Data export file created by $userid on $today" : fix_case($export_file_name) . " file created by $userid on $today. $comment"; // unused, but I keep it around just in case /** * setup vars for value export logging */ $chkd_fields = implode(',', $fields); /** * turn on/off exporting per user rights */ if (($user_rights['data_export_tool'] || $userid == '[CRON]') && !$debug) { $table_csv = addBOMtoUTF8($headers . $table_csv); /** * Store the file in the file system and log the activity, handle if error */ if (!DataExport::storeExportFile($originalFilename, $table_csv, true)) { log_event("", "redcap_data", "data_export", "", str_replace("'", "", $chkd_fields) . (($parent_chkd_flds == "") ? "" : ", " . str_replace("'", "", $parent_chkd_flds)), "Data Export Failed"); } else { log_event("", "redcap_data", "data_export", "", str_replace("'", "", $chkd_fields) . (($parent_chkd_flds == "") ? "" : ", " . str_replace("'", "", $parent_chkd_flds)), "Export data for SendIt"); /** * email file link and download password in two separate emails via REDCap SendIt */ $file_info_sql = db_query("SELECT docs_id, docs_size, docs_type FROM redcap_docs WHERE project_id = $project_id ORDER BY docs_id DESC LIMIT 1"); // get required info about the file we just created if ($file_info_sql) { $docs_id = db_result($file_info_sql, 0, 'docs_id'); $docs_size = db_result($file_info_sql, 0, 'docs_size'); $docs_type = db_result($file_info_sql, 0, 'docs_type'); } $yourName = 'PRIORITIZE REDCap'; $expireDays = 3; // set the SendIt to expire in this many days /** * $file_location: * 1 = ephemeral, will be deleted on $expireDate * 2 = export file, visible only to rights in file repository */ $file_location = 2; $send = 1; // always send download confirmation $expireDate = date('Y-m-d H:i:s', strtotime("+$expireDays days")); $expireYear = substr($expireDate, 0, 4); $expireMonth = substr($expireDate, 5, 2); $expireDay = substr($expireDate, 8, 2); $expireHour = substr($expireDate, 11, 2); $expireMin = substr($expireDate, 14, 2); // Add entry to sendit_docs table $query = "INSERT INTO redcap_sendit_docs (doc_name, doc_orig_name, doc_type, doc_size, send_confirmation, expire_date, username, location, docs_id, date_added) VALUES ('$originalFilename', '" . prep($originalFilename) . "', '$docs_type', '$docs_size', $send, '$expireDate', '" . prep($userid) . "', $file_location, $docs_id, '" . NOW . "')"; db_query($query); $newId = db_insert_id(); $logDescrip = "Send file from file repository (Send-It)"; log_event($query, "redcap_sendit_docs", "MANAGE", $newId, "document_id = $newId", $logDescrip); // Set email subject $subject = "[PRIORITIZE] " . $comment; $subject = html_entity_decode($subject, ENT_QUOTES); // Set email From address $from = array('Ken Bergquist' => '*****@*****.**'); // Begin set up of email to send to recipients $email = new Message(); foreach ($from as $name => $address) { $email->setFrom($address); $email->setFromName($name); } $email->setSubject($subject); // Loop through each recipient and send email foreach ($to as $name => $address) { // If a non-blank email address if (trim($address) != '') { // create key for unique url $key = strtoupper(substr(uniqid(md5(mt_rand())), 0, 25)); // create password $pwd = generateRandomHash(8, false, true); $query = "INSERT INTO redcap_sendit_recipients (email_address, sent_confirmation, download_date, download_count, document_id, guid, pwd) VALUES ('$address', 0, NULL, 0, $newId, '$key', '" . md5($pwd) . "')"; $q = db_query($query); // Download URL $url = APP_PATH_WEBROOT_FULL . 'redcap_v' . $redcap_version . '/SendIt/download.php?' . $key; // Message from sender $note = "$comment for $today"; // Get YMD timestamp of the file's expiration time $expireTimestamp = date('Y-m-d H:i:s', mktime($expireHour, $expireMin, 0, $expireMonth, $expireDay, $expireYear)); // Email body $body = "<html><body style=\"font-family:Arial;font-size:10pt;\"> $yourName {$lang['sendit_51']} \"$originalFilename\" {$lang['sendit_52']} " . date('l', mktime($expireHour, $expireMin, 0, $expireMonth, $expireDay, $expireYear)) . ", " . DateTimeRC::format_ts_from_ymd($expireTimestamp) . "{$lang['period']} {$lang['sendit_53']}<br><br> {$lang['sendit_54']}<br> <a href=\"$url\">$url</a><br><br> $note <br>-----------------------------------------------<br> {$lang['sendit_55']} " . CONSORTIUM_WEBSITE_DOMAIN . ". </body></html>"; // Construct email and send $email->setTo($address); $email->setToName($name); $email->setBody($body); if ($email->send()) { // Now send follow-up email containing password $bodypass = "******"font-family:Arial;font-size:10pt;\"> {$lang['sendit_50']}<br><br> $pwd<br><br> </body></html>"; $email->setSubject("Re: $subject"); $email->setBody($bodypass); sleep(2); // Hold for a second so that second email somehow doesn't reach the user first $email->send(); } else { error_log("ERROR: pid=$project_id: Email to $name <$address> NOT SENT"); } } } } unset($table_csv); } }
function showAuxDataRes() { /* update last page */ $_SESSION['LASTPAGE'] = substr($_SESSION['LASTPAGE'], 0, strripos($_SESSION['LASTPAGE'], "res")); $displayOutput = new DisplayOutput(); $de = new DataExport(loadvar('survey')); $de->setProperty(DATA_OUTPUT_CLEAN, loadvar(DATA_OUTPUT_CLEAN)); $de->setProperty(DATA_OUTPUT_HIDDEN, loadvar(DATA_OUTPUT_HIDDEN)); $de->setProperty(DATA_OUTPUT_COMPLETED, loadvar(DATA_OUTPUT_COMPLETED)); $de->setProperty(DATA_OUTPUT_FIELDNAME_CASE, loadvar(DATA_OUTPUT_FIELDNAME_CASE)); if (loadvar(DATA_OUTPUT_FILENAME) != "") { $de->setProperty(DATA_OUTPUT_FILENAME, loadvar(DATA_OUTPUT_FILENAME)); } $cookievars = ""; if (isset($_COOKIE['uscicvariablecookie'])) { if (loadvar(DATA_OUTPUT_SUBDATA) == SUBDATA_YES) { $vars = explode("-", $_COOKIE['uscicvariablecookie']); $arr = array(); foreach ($vars as $var) { $varsplit = explode("~", $var); if (loadvar('survey') == $varsplit[0]) { // only consider variables from survey we are downloading for $survey = new Survey($varsplit[0]); $v = $survey->getVariableDescriptive($varsplit[1]); if ($v->getName() != "") { $arr[] = strtoupper($v->getName()); } } } if (sizeof($arr) > 0) { $cookievars = implode("~", $arr); } } } $de->setProperty(DATA_OUTPUT_VARLIST, $cookievars); $de->setProperty(DATA_OUTPUT_FILETYPE, loadvar(DATA_OUTPUT_FILETYPE)); $de->setProperty(DATA_OUTPUT_INCLUDE_VALUE_LABELS, loadvar(DATA_OUTPUT_INCLUDE_VALUE_LABELS)); $de->setProperty(DATA_OUTPUT_INCLUDE_VALUE_LABEL_NUMBERS, loadvar(DATA_OUTPUT_INCLUDE_VALUE_LABEL_NUMBERS)); $de->setProperty(DATA_OUTPUT_LANGUAGES, implode("~", loadvar(DATA_OUTPUT_LANGUAGES))); $de->setProperty(DATA_OUTPUT_MARK_EMPTY, loadvar(DATA_OUTPUT_MARK_EMPTY)); $de->setProperty(DATA_OUTPUT_MODES, implode("~", loadvar(DATA_OUTPUT_MODES))); $de->setProperty(DATA_OUTPUT_PRIMARY_KEY_ENCRYPTION, loadvar(DATA_OUTPUT_PRIMARY_KEY_ENCRYPTION)); $de->setProperty(DATA_OUTPUT_PRIMARY_KEY_IN_DATA, loadvar(DATA_OUTPUT_PRIMARY_KEY_IN_DATA)); $de->setProperty(DATA_OUTPUT_SURVEY, loadvar(DATA_OUTPUT_SURVEY)); $de->setProperty(DATA_OUTPUT_TYPEDATA, loadvar(DATA_OUTPUT_TYPEDATA)); $de->setProperty(DATA_OUTPUT_VARIABLES_WITHOUT_DATA, loadvar(DATA_OUTPUT_VARIABLES_WITHOUT_DATA)); $de->setProperty(DATA_OUTPUT_KEEP_ONLY, loadvar(DATA_OUTPUT_KEEP_ONLY)); $de->setProperty(DATA_OUTPUT_TYPE, loadvar(DATA_OUTPUT_TYPE)); $de->setProperty(DATA_OUTPUT_ENCODING, "UTF-8"); $de->setProperty(DATA_OUTPUT_FROM, loadvar(DATA_OUTPUT_FROM)); $de->setProperty(DATA_OUTPUT_TO, loadvar(DATA_OUTPUT_TO)); //$de->displayProperties(); $de->generateAuxiliary(); $de->download(); //$de->displayProperties(); //$de->writeCSVFile(); //$de->displayLog(); return $displayOutput->showOutputAddOnData(); }
//Check to see if custom reports are specified for this project. If so, print the appropriate links. //Build menu item for each separate report $reportsListTitle = $lang['app_06']; if ($user_rights['reports']) { $reportsListTitle = "<table cellspacing='0' width='100%'> <tr> <td>{$lang['app_06']}</td> <td id='menuLnkEditReports' class='opacity50' style='text-align:right;padding-right:10px;'>" . RCView::img(array('src'=>'pencil_small2.png','class'=>'imgfix1 '.($isIE ? 'opacity50' : ''))) . RCView::a(array('href'=>APP_PATH_WEBROOT."DataExport/index.php?pid=$project_id",'style'=>'font-family:arial;font-size:11px;text-decoration:underline;color:#000066;font-weight:normal;'), $lang['bottom_71']) . " </td> </tr> </table>"; } // Reports built in Reports & Exports module $reportsList = DataExport::outputReportPanel(); /** * HELP MENU */ $helpMenuTitle = '<div style="margin-top:-3px;"><img src="'.APP_PATH_IMAGES.'help.png" class="imgfix"> <span style="color:#3E72A8;">'.$lang['bottom_42'].'</span></div>'; $helpMenu = "<div class='menubox' style='font-size:11px;color:#444;'> <!-- Help & FAQ --> <div class='hang'> <img src='" . APP_PATH_IMAGES . "bullet_toggle_minus.png' class='imgfix'> <a style='color:#444;' href='" . APP_PATH_WEBROOT_PARENT . "index.php?action=help'>".$lang['bottom_27']."</a> </div> <!-- Video Tutorials -->
/** * Show the list of papers wit their status */ function paperstatusAction() { $paperTbl = new Paper(); $paperStatusTbl = new PaperStatus(); $exportLatex = $exportExcel = false; if (isset($_REQUEST['export_latex'])) { $exportLatex = true; $this->view->message = "The LaTeX file <i>paperstatus.tex</i> has been generated in files/selection"; } if (isset($_REQUEST['export_excel'])) { $exportExcel = true; $this->view->message = "The LaTeX file <i>paperstatus.tex</i> has been generated in files/selection"; } else { $this->view->MESSAGE = ""; } if (!$exportExcel) { $this->view->set_file("content", "paperstatus.xml"); $this->view->set_block("content", "SELECTION_FORM"); $this->view->set_block("content", "MESSAGE"); $this->view->set_block("content", "SHOW_SELECTION_FORM"); $this->view->set_file("ranked_papers_list", "ranked_papers.xml"); } else { $this->view->set_file("ranked_papers_list", "paperstatus_excel.xml"); } // Check whether the current selection must be changed if (isset($_POST['spStatus'])) { $this->config->changeCurrentSelection(); } if (isset($_REQUEST['remove'])) { $reviewTbl = new Review(); $review = $reviewTbl->find($_REQUEST['idPaper'], $_REQUEST['remove'])->current(); if (is_object($review)) { $review->delete(); } } else { if (isset($_REQUEST['idPaper'])) { // If the status is submitted: update in the DB $idPaper = $_REQUEST['idPaper']; $status = $_REQUEST['status']; foreach ($idPaper as $key => $val) { if (isset($status[$val])) { // echo "ID = $val<br/>"; $paper = $paperTbl->find($val)->current(); if (is_object($paper)) { $paper->status = $status[$val]; $paper->save(); } else { throw new Zmax_Exception("Unknown paper id sent to the change status function?"); } } } } } // If required, hide the selection form if (isset($_REQUEST['hide_selection_form'])) { $this->config->show_selection_form = 'N'; $this->config->save(); } else { if (isset($_REQUEST['show_selection_form'])) { $this->config->show_selection_form = 'Y'; $this->config->save(); } } // Show the form for filtering papers, if required if ($this->config->show_selection_form == 'Y') { $this->view->set_var("FORM_SELECT_PAPERS", $this->formSelectPapers($this->view->base_url . "/admin/chair/paperstatus", $this->view, $this->db_v1)); $this->view->set_var("SHOW_SELECTION_FORM", ""); } else { $this->view->set_var("SELECTION_FORM", ""); } // Create the list of lists to toggle all the selected papers $comma = $listLinks = ""; $statusList = $paperStatusTbl->fetchAll("final_status='Y'"); foreach ($statusList as $status) { $listLinks .= $comma . " <a href='#' onClick=\"TogglePaperStatus('{$status->id}')\">" . $status->label . "</a>"; $comma = ","; } $this->view->set_var("TOGGLE_LIST", $listLinks); // Always list the papers if ($exportExcel) { $this->papersReviews($this->view, "ranked_papers_list", false); } else { $this->papersReviews($this->view, "ranked_papers_list"); } // In addition, produce the Latex file if ($exportLatex) { $anonymized = false; if (isset($_REQUEST['anonymized'])) { $anonymized = true; } // Instantiate the data export object $dataExport = new DataExport($this->view->getScriptPaths()); // Load the latex templates $dataExport->getView()->setFile("latex_papers_list", "paperstatus.tex"); $this->papersReviews($dataExport->getView(), "latex_papers_list", false, $anonymized); // The directory where Latex files are produced $tex_dir = "selection/"; $dataExport->getView()->assign("result", "latex_papers_list"); $result = $dataExport->replaceBadChars($dataExport->getView()->result); $dataExport->writeFile($tex_dir, "paperstatus.tex", $result); $dataExport->downloadFile($tex_dir, "paperstatus.tex"); } if ($exportExcel) { $this->view->assign("export", "ranked_papers_list"); $this->exportFile("submissions.xls", "text/xls", $this->view->export); return; } echo $this->view->render("layout"); }
function dataExport($tpl_dir) { global $AVE_DB, $AVE_Template; if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'export') { require_once BASE_DIR . '/modules/shop/class.export.php'; $export = new DataExport(); switch ($_REQUEST['t']) { case 'orders': $table = 'orders'; $Prefab = 'CP_BESTELLUNGEN_'; break; case 'user': $table = 'user'; $Prefab = 'CP_BENUTZER_'; break; case 'articles': $table = 'articles'; $Prefab = 'CP_SHOPARTIKEL_'; break; } $export->Export($Prefab . date('d_m_Y_H_i') . '', $table, @$_REQUEST['format'], @$_REQUEST['groups']); } $groups = array(); $sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_user_groups"); while ($row = $sql->FetchArray()) { array_push($groups, $row); } $AVE_Template->assign('ProductCategs', $this->fetchShopNavi(1)); $AVE_Template->assign('groups', $groups); $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'shop_export_data.tpl')); }
/** * Created by HCV-TARGET. * User: kbergqui * Date: 2/25/14 * Time: 9:02 AM */ function create_download_all($Proj, $lang, $project_id, $app_name, $app_title, $super_user, $userid, $headers, $headers_labels, $data_csv, $data_csv_labels, $field_names, $is_child=false, $chkd_flds, $table_pk, $longitudinal, $exportDags=false, $exportSurveyFields=false) { $dagEnum = ''; $do_remove_identifiers = false; $do_date_shift = false; // Retrieve project data (raw & labels) and headers in CSV format //list ($headers, $headers_labels, $data_csv, $data_csv_labels, $field_names) // = fetchDataCsv($chkd_flds, $parent_chkd_flds, false, $do_hash, $do_remove_identifiers, $useStandardCodes, $useStandardCodeDataConversion, $standardId, $standardCodeLookup, $useFieldNames, $exportDags, $exportSurveyFields, $exportSurveyFields); // Log the event //log_event("", "redcap_data", "data_export", "", str_replace("'", "", $chkd_flds) . (($parent_chkd_flds == "") ? "" : ", " . str_replace("'", "", $parent_chkd_flds)), "Export data"); ############################################################ ## PREPARE SYNTAX FILES FOR STATS PACKAGES # Initializing the syntax file strings $spss_string = "FILE HANDLE data1 NAME='data_place_holder_name' LRECL=90000.\n"; $spss_string .= "DATA LIST FREE" . "\n\t"; $spss_string .= "FILE = data1\n\t/"; $sas_string = "DATA " . $app_name . ";\nINPUT "; $sas_format_string = "data redcap;\n\tset redcap;\n"; $stata_string = "clear\n\n"; $R_string = "#Clear existing data and graphics\nrm(list=ls())\n"; $R_string .= "graphics.off()\n"; $R_string .= "#Load Hmisc library\nlibrary(Hmisc)\n"; $R_label_string = "#Setting Labels\n"; $R_units_string = "\n#Setting Units\n"; $R_factors_string = "\n\n#Setting Factors(will create new variable for factors)"; $R_levels_string = ""; $value_labels_spss = "VALUE LABELS "; // Get relevant metadata to use for syntax files $syntaxfile_sql = "SELECT field_name, element_validation_type, element_enum, element_type, element_label, field_units FROM redcap_metadata where project_id = $project_id and field_name in ($chkd_flds) order by field_order"; // Array that is prepended to $field_names array if fields need to be added, such as redcap_event_name or survey timestamp $field_names_prepend = array(); $prev_form = ""; $prev_field = ""; // Loop through all fields that were exported $q = db_query($syntaxfile_sql); while ($row = db_fetch_assoc($q)) { // Create object for each field we loop through $ob = new stdClass(); foreach ($row as $col => $val) { $col = strtoupper($col); $ob->$col = $val; } // Set values for this loop $this_form = $Proj->metadata[$ob->FIELD_NAME]['form_name']; // If surveys exist, as timestamp and identifier fields if ($exportSurveyFields && $prev_form != $this_form && $ob->FIELD_NAME != $table_pk && isset($Proj->forms[$this_form]['survey_id'])) { // Alter $meta_array $ob2 = new stdClass(); $ob2->ELEMENT_TYPE = 'text'; $ob2->FIELD_NAME = $this_form . '_timestamp'; $ob2->ELEMENT_LABEL = 'Survey Timestamp'; $ob2->ELEMENT_ENUM = ''; $ob2->FIELD_UNITS = ''; $ob2->ELEMENT_VALIDATION_TYPE = ''; $meta_array[$ob2->FIELD_NAME] = (Object)$ob2; } if ($ob->ELEMENT_TYPE != 'checkbox') { // For non-checkboxes, add to $meta_array $meta_array[$ob->FIELD_NAME] = (Object)$ob; } else { // For checkboxes, loop through each choice to add to $meta_array $orig_fieldname = $ob->FIELD_NAME; $orig_fieldlabel = $ob->ELEMENT_LABEL; $orig_elementenum = $ob->ELEMENT_ENUM; foreach (parseEnum($orig_elementenum) as $this_value => $this_label) { unset($ob); // $ob = $meta_set->FetchObject(); $ob = new stdClass(); // If coded value is not numeric, then format to work correct in variable name (no spaces, caps, etc) if (!is_numeric($this_value)) { $this_value = preg_replace("/[^a-z0-9]/", "", strtolower($this_value)); } // Convert each checkbox choice to a advcheckbox field (because advcheckbox has equivalent processing we need) // Append triple underscore + coded value $ob->FIELD_NAME = $orig_fieldname . '___' . $this_value; $ob->ELEMENT_ENUM = "0, Unchecked \\n 1, Checked"; $ob->ELEMENT_TYPE = "advcheckbox"; $ob->ELEMENT_LABEL = "$orig_fieldlabel (choice=" . str_replace(array("'", "\""), array("", ""), $this_label) . ")"; $meta_array[$ob->FIELD_NAME] = (Object)$ob; } } if ($ob->FIELD_NAME == $table_pk) { // If project has multiple Events (i.e. Longitudinal), add new column for Event name if ($longitudinal) { // Put unique event names and labels into array to convert to enum format $evtEnumArray = array(); $evtLabels = array(); foreach ($Proj->eventInfo as $event_id => $attr) { $evtLabels[$event_id] = label_decode($attr['name_ext']); } foreach ($evtLabels as $event_id => $event_label) { $evtEnumArray[] = $Proj->getUniqueEventNames($event_id) . ", " . label_decode($event_label); } $evtEnum = implode(" \\n ", $evtEnumArray); // Alter $meta_array $ob2 = new stdClass(); $ob2->ELEMENT_TYPE = 'select'; $ob2->FIELD_NAME = 'redcap_event_name'; $ob2->ELEMENT_LABEL = 'Event Name'; $ob2->ELEMENT_ENUM = $evtEnum; $ob2->FIELD_UNITS = ''; $ob2->ELEMENT_VALIDATION_TYPE = ''; $meta_array[$ob2->FIELD_NAME] = (Object)$ob2; // Add pseudo-field to array $field_names_prepend[] = $ob2->FIELD_NAME; } // If project has DAGs, add new column for group name if ($exportDags) { // Alter $meta_array $ob2 = new stdClass(); $ob2->ELEMENT_TYPE = 'select'; $ob2->FIELD_NAME = 'redcap_data_access_group'; $ob2->ELEMENT_LABEL = 'Data Access Group'; $ob2->ELEMENT_ENUM = $dagEnum; $ob2->FIELD_UNITS = ''; $ob2->ELEMENT_VALIDATION_TYPE = ''; $meta_array[$ob2->FIELD_NAME] = (Object)$ob2; // Add pseudo-field to array $field_names_prepend[] = $ob2->FIELD_NAME; } // Add survey identifier (unless we've set it to remove all identifiers - treat survey identifier same as field identifier) if ($exportSurveyFields && !$do_remove_identifiers) { // Alter $meta_array $ob2 = new stdClass(); $ob2->ELEMENT_TYPE = 'text'; $ob2->FIELD_NAME = 'redcap_survey_identifier'; $ob2->ELEMENT_LABEL = 'Survey Identifier'; $ob2->ELEMENT_ENUM = ''; $ob2->FIELD_UNITS = ''; $ob2->ELEMENT_VALIDATION_TYPE = ''; $meta_array[$ob2->FIELD_NAME] = (Object)$ob2; // Add pseudo-field to array $field_names_prepend[] = $ob2->FIELD_NAME; } // If surveys exist, as timestamp and identifier fields if ($exportSurveyFields && $prev_form != $this_form && isset($Proj->forms[$this_form]['survey_id'])) { // Alter $meta_array $ob2 = new stdClass(); $ob2->ELEMENT_TYPE = 'text'; $ob2->FIELD_NAME = $this_form . '_timestamp'; $ob2->ELEMENT_LABEL = 'Survey Timestamp'; $ob2->ELEMENT_ENUM = ''; $ob2->FIELD_UNITS = ''; $ob2->ELEMENT_VALIDATION_TYPE = ''; $meta_array[$ob2->FIELD_NAME] = (Object)$ob2; } } // Set values for next loop $prev_form = $this_form; $prev_field = $ob->FIELD_NAME; } // Now reset field_names array $field_names = array_keys($meta_array); // $spss_data_type_array = ""; $spss_format_dates = ""; $spss_variable_label = "VARIABLE LABEL "; $spss_variable_level = array(); $sas_label_section = "\ndata redcap;\n\tset redcap;\n"; $sas_value_label = "proc format;\n"; $sas_input = "input\n"; $sas_informat = ""; $sas_format = ""; $stata_insheet = "insheet "; $stata_var_label = ""; $stata_inf_label = ""; $stata_value_label = ""; $stata_date_format = ""; $first_label = true; $large_name_counter = 0; $large_name = false; // Use arrays for string replacement $orig = array("'", "\"", "\r\n", "\r", "\n", "<", "<="); $repl = array("", "", " ", " ", " ", "<", "< ="); //print_array($meta_array);print_array($field_names);exit; // Loop through all metadata fields for ($x = 0; $x <= count($field_names) + 1; $x++) { if (($x % 5) == 0 && $x != 0) { $spss_string .= "\n\t"; } $large_name = false; // Set field object for this loop $ob = $meta_array[$field_names[$x]]; // Remove any . or - in the field name (as a result of checkbox raw values containing . or -) // $ob->FIELD_NAME = str_replace(array("-", "."), array("_", "_"), (string)$ob->FIELD_NAME); // Convert "sql" field types to "select" field types so that their Select Choices come out correctly in the syntax files. /** * override for autocomplete plugin code starts here * add autocomplete type to this check */ if ($ob->ELEMENT_TYPE == "sql" || $ob->ELEMENT_TYPE == "autocomplete") /** * end override for autocomplete plugin code */ { // Change to select $ob->ELEMENT_TYPE = "select"; // Now populate it's choices by running the query $ob->ELEMENT_ENUM = getSqlFieldEnum($ob->ELEMENT_ENUM); } elseif ($ob->ELEMENT_TYPE == "yesno") { $ob->ELEMENT_ENUM = YN_ENUM; } elseif ($ob->ELEMENT_TYPE == "truefalse") { $ob->ELEMENT_ENUM = TF_ENUM; } //Remove any offending characters from label $ob->ELEMENT_LABEL = str_replace($orig, $repl, label_decode(html_entity_decode($ob->ELEMENT_LABEL, ENT_QUOTES))); if ($field_names[$x] != "") { if (strlen($field_names[$x]) >= 31) { $short_name = substr($field_names[$x], 0, 20) . "_v_" . $large_name_counter; $sas_label_section .= "\tlabel " . $short_name . "='" . $ob->ELEMENT_LABEL . "';\n"; $stata_var_label .= "label variable " . $short_name . ' "' . $ob->ELEMENT_LABEL . '"' . "\n"; $stata_insheet .= $short_name . " "; $large_name_counter++; $large_name = true; } if (!$large_name) { $sas_label_section .= "\tlabel " . $field_names[$x] . "='" . $ob->ELEMENT_LABEL . "';\n"; $stata_var_label .= "label variable " . $field_names[$x] . ' "' . $ob->ELEMENT_LABEL . '"' . "\n"; $stata_insheet .= $field_names[$x] . " "; } $spss_variable_label .= $field_names[$x] . " '" . $ob->ELEMENT_LABEL . "'\n\t/"; $R_label_string .= "\nlabel(data$" . $field_names[$x] . ")=" . '"' . $ob->ELEMENT_LABEL . '"'; if (($ob->FIELD_UNITS != Null) || ($ob->FIELD_UNITS != "")) { $R_units_string .= "\nunits(data$" . $field_names[$x] . ")=" . '"' . $ob->FIELD_UNITS . '"'; } } # Checking for single element enum (i.e. if it is coded with a number or letter) $single_element_enum = true; if (substr_count(((string)$ob->ELEMENT_ENUM), ",") > 0) { $single_element_enum = false; } # Select value labels are created if (($ob->ELEMENT_TYPE == "yesno" || $ob->ELEMENT_TYPE == "truefalse" || $ob->ELEMENT_TYPE == "select" || $ob->ELEMENT_TYPE == "advcheckbox" || $ob->ELEMENT_TYPE == "radio") && !preg_match("/\+\+SQL\+\+/", (string)$ob->ELEMENT_ENUM)) { //Remove any apostrophes from the Choice Labels $ob->ELEMENT_ENUM = str_replace($orig, $repl, label_decode($ob->ELEMENT_ENUM)); //Place $ in front of SAS value if using non-numeric coded values for dropdowns/radios $sas_val_enum_num = ""; //default $numericChoices = true; foreach (array_keys(parseEnum($ob->ELEMENT_ENUM)) as $key) { if (!is_numeric($key)) { // If at least one key is not numeric, then stop looping because we have all we need. $sas_val_enum_num = "$"; $numericChoices = false; break; } } if ($first_label) { if (!$single_element_enum) { $value_labels_spss .= "\n" . (string)$ob->FIELD_NAME . " "; } $R_factors_string .= "\ndata$" . (string)$ob->FIELD_NAME . ".factor = factor(data$" . (string)$ob->FIELD_NAME . ",levels=c("; $R_levels_string .= "\nlevels(data$" . (string)$ob->FIELD_NAME . ".factor)=c("; $first_label = false; if (!$large_name && !$single_element_enum) { $sas_value_label .= "\tvalue $sas_val_enum_num" . (string)$ob->FIELD_NAME . "_ "; $sas_format_string .= "\n\tformat " . (string)$ob->FIELD_NAME . " " . (string)$ob->FIELD_NAME . "_.;\n"; if ($numericChoices) { $stata_inf_label .= "\nlabel values " . (string)$ob->FIELD_NAME . " " . (string)$ob->FIELD_NAME . "_\n"; $stata_value_label = "label define " . (string)$ob->FIELD_NAME . "_ "; } } else if ($large_name && !$single_element_enum) { $sas_value_label .= "\tvalue $sas_val_enum_num" . $short_name . "_ "; $sas_format_string .= "\n\tformat " . $short_name . " " . $short_name . "_.;\n"; if ($numericChoices) { $stata_value_label .= "label define " . $short_name . "_ "; $stata_inf_label .= "\nlabel values " . $short_name . " " . $short_name . "_\n"; } } } else if (!$first_label) { if (!$single_element_enum) { $value_labels_spss .= "\n/" . (string)$ob->FIELD_NAME . " "; if (!$large_name) { $sas_value_label .= "\n\tvalue $sas_val_enum_num" . (string)$ob->FIELD_NAME . "_ "; $sas_format_string .= "\tformat " . (string)$ob->FIELD_NAME . " " . (string)$ob->FIELD_NAME . "_.;\n"; if ($numericChoices) { $stata_value_label .= "\nlabel define " . (string)$ob->FIELD_NAME . "_ "; $stata_inf_label .= "label values " . (string)$ob->FIELD_NAME . " " . (string)$ob->FIELD_NAME . "_\n"; } } } $R_factors_string .= "data$" . (string)$ob->FIELD_NAME . ".factor = factor(data$" . (string)$ob->FIELD_NAME . ",levels=c("; $R_levels_string .= "levels(data$" . (string)$ob->FIELD_NAME . ".factor)=c("; if ($large_name && !$single_element_enum) { $sas_value_label .= "\n\tvalue $sas_val_enum_num" . $short_name . "_ "; $sas_format_string .= "\tformat " . $short_name . " " . $short_name . "_.;\n"; if ($numericChoices) { $stata_value_label .= "\nlabel define " . $short_name . "_ "; //LS inserted this line 24-Feb-2012 $stata_inf_label .= "label values " . $short_name . " " . $short_name . "_\n"; } } } $first_new_line_explode_array = explode("\\n", (string)$ob->ELEMENT_ENUM); // Loop through multiple choice options $select_is_text = false; $select_determining_array = array(); for ($counter = 0; $counter < count($first_new_line_explode_array); $counter++) { if (!$single_element_enum) { // SAS: Add line break after 2 multiple choice options if (($counter % 2) == 0 && $counter != 0) { $sas_value_label .= "\n\t\t"; $value_labels_spss .= "\n\t"; } $second_comma_explode = explode(",", $first_new_line_explode_array[$counter], 2); $value_labels_spss .= "'" . trim($second_comma_explode[0]) . "' "; $value_labels_spss .= "'" . trim($second_comma_explode[1]) . "' "; if (!is_numeric(trim($second_comma_explode[0])) && is_numeric(substr(trim($second_comma_explode[0]), 0, 1))) { // if enum raw value is not a number BUT begins with a number, add quotes around it for SAS only (parsing issue) $sas_value_label .= "'" . trim($second_comma_explode[0]) . "'="; } else { $sas_value_label .= trim($second_comma_explode[0]) . "="; } $sas_value_label .= "'" . trim($second_comma_explode[1]) . "' "; if ($numericChoices) { $stata_value_label .= trim($second_comma_explode[0]) . " "; $stata_value_label .= "\"" . trim($second_comma_explode[1]) . "\" "; } $select_determining_array[] = $second_comma_explode[0]; $R_factors_string .= '"' . trim($second_comma_explode[0]) . '",'; $R_levels_string .= '"' . trim($second_comma_explode[1]) . '",'; } else { $select_determining_array[] = $second_comma_explode[0]; $R_factors_string .= '"' . trim($first_new_line_explode_array[$counter]) . '",'; $R_levels_string .= '"' . trim($first_new_line_explode_array[$counter]) . '",'; } } $R_factors_string = rtrim($R_factors_string, ","); $R_factors_string .= "))\n"; //pharris 09/28/05 $R_levels_string = rtrim($R_levels_string, ","); $R_levels_string .= ")\n"; if (!$single_element_enum) { $sas_value_label = rtrim($sas_value_label, " "); $sas_value_label .= ";"; } if (!$single_element_enum) { foreach ($select_determining_array as $value) { if (preg_match("/([A-Za-z])/", $value)) { $select_is_text = true; } } } else { foreach ($first_new_line_explode_array as $value) { if (preg_match("/([A-Za-z])/", $value)) { $select_is_text = true; } } } } else if (preg_match("/\+\+SQL\+\+/", (string)$ob->ELEMENT_ENUM)) { $select_is_text = true; } ################################################################################ ################################################################################ # If the ELEMENT_VALIDATION_TYPE is a float the data is define as a Number if ($ob->ELEMENT_VALIDATION_TYPE == "float" || $ob->ELEMENT_TYPE == "calc") { $spss_string .= $ob->FIELD_NAME . " (F8.2) "; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " best32. ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " best12. ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . "\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " best32. ;\n"; $sas_format .= "\tformat " . $short_name . " best12. ;\n"; $sas_input .= "\t\t" . $short_name . "\n"; } // $spss_data_type_array[$x] = "NUMBER"; $spss_variable_level[] = $ob->FIELD_NAME . " (SCALE)"; } elseif ($ob->ELEMENT_TYPE == "slider" || $ob->ELEMENT_VALIDATION_TYPE == "int") { $spss_string .= $ob->FIELD_NAME . " (F8) "; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " best32. ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " best12. ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . "\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " best32. ;\n"; $sas_format .= "\tformat " . $short_name . " best12. ;\n"; $sas_input .= "\t\t" . $short_name . "\n"; } // $spss_data_type_array[$x] = "NUMBER"; $spss_variable_level[] = $ob->FIELD_NAME . " (SCALE)"; # If the ELEMENT_VALIDATION_TYPE is a DATE a treat the data as a date } elseif ($ob->ELEMENT_VALIDATION_TYPE == "date" || $ob->ELEMENT_VALIDATION_TYPE == "date_ymd" || $ob->ELEMENT_VALIDATION_TYPE == "date_mdy" || $ob->ELEMENT_VALIDATION_TYPE == "date_dmy") { $spss_string .= $ob->FIELD_NAME . " (SDATE10) "; $spss_format_dates .= "FORMATS " . $ob->FIELD_NAME . "(ADATE10).\n"; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " yymmdd10. ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " yymmdd10. ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . "\n"; $stata_date_format .= "\ntostring " . $ob->FIELD_NAME . ", replace"; $stata_date_format .= "\ngen _date_ = date(" . $ob->FIELD_NAME . ",\"YMD\")\n"; $stata_date_format .= "drop " . $ob->FIELD_NAME . "\n"; $stata_date_format .= "rename _date_ " . $ob->FIELD_NAME . "\n"; $stata_date_format .= "format " . $ob->FIELD_NAME . " %dM_d,_CY\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " yymmdd10. ;\n"; $sas_format .= "\tformat " . $short_name . " yymmdd10. ;\n"; $sas_input .= "\t\t" . $short_name . "\n"; $stata_date_format .= "\ntostring " . $short_name . ", replace"; $stata_date_format .= "\ngen _date_ = date(" . $short_name . ",\"YMD\")\n"; $stata_date_format .= "drop " . $short_name . "\n"; $stata_date_format .= "rename _date_ " . $short_name . "\n"; $stata_date_format .= "format " . $short_name . " %dM_d,_CY\n"; } # If the ELEMENT_VALIDATION_TYPE is TIME (military) } elseif ($ob->ELEMENT_VALIDATION_TYPE == "time") { $spss_string .= $ob->FIELD_NAME . " (A500) "; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " time5. ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " time5. ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . "\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " time5. ;\n"; $sas_format .= "\tformat " . $short_name . " time5. ;\n"; $sas_input .= "\t\t" . $short_name . "\n"; } # If the ELEMENT_VALIDATION_TYPE is DATETIME or DATETIME_SECONDS // } elseif (substr($ob->ELEMENT_VALIDATION_TYPE, 0, 8) == "datetime") { # If the object type is select then the variable $select_is_text is checked to # see if it is a TEXT or a NUMBER and treated accordanly. } elseif ($ob->ELEMENT_TYPE == "yesno" || $ob->ELEMENT_TYPE == "truefalse" || $ob->ELEMENT_TYPE == "select" || $ob->ELEMENT_TYPE == "advcheckbox" || $ob->ELEMENT_TYPE == "radio") { if ($select_is_text) { $temp_trim = rtrim("varchar(500)", ")"); # Divides the string to get the number of caracters $temp_explode_number = explode("(", $temp_trim); $spss_string .= $ob->FIELD_NAME . " (A" . $temp_explode_number[1] . ") "; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " \$" . $temp_explode_number[1] . ". ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " \$" . $temp_explode_number[1] . ". ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . " \$\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " \$" . $temp_explode_number[1] . ". ;\n"; $sas_format .= "\tformat " . $short_name . " \$" . $temp_explode_number[1] . ". ;\n"; $sas_input .= "\t\t" . $short_name . " \$\n"; } // $spss_data_type_array[$x] = "TEXT"; } else { $spss_string .= $ob->FIELD_NAME . " (F3) "; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " best32. ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " best12. ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . "\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " best32. ;\n"; $sas_format .= "\tformat " . $short_name . " best12. ;\n"; $sas_input .= "\t\t" . $short_name . "\n"; } // $spss_data_type_array[$x] = "NUMBER"; } # If the object type is text a treat the data like a text and look for the length # that is specified in the database } elseif ($ob->ELEMENT_TYPE == "text" || $ob->ELEMENT_TYPE == "calc" || $ob->ELEMENT_TYPE == "file") { $spss_string .= $ob->FIELD_NAME . " (A500) "; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " \$500. ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " \$500. ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . " \$\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " \$500. ;\n"; $sas_format .= "\tformat " . $short_name . " \$500. ;\n"; $sas_input .= "\t\t" . $short_name . " \$\n"; } # If the object type is textarea a treat the data like a text and specify a large # string size. } elseif ($ob->ELEMENT_TYPE == "textarea") { $spss_string .= $ob->FIELD_NAME . " (A30000) "; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " \$5000. ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " \$5000. ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . " \$\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " \$5000. ;\n"; $sas_format .= "\tformat " . $short_name . " \$5000. ;\n"; $sas_input .= "\t\t" . $short_name . " \$\n"; } // $spss_data_type_array[$x] = "TEXT"; } } // File names $today = date("Y-m-d_Hi"); $projTitleShort = substr(str_replace(" ", "", ucwords(preg_replace("/[^a-zA-Z0-9 ]/", "", html_entity_decode($app_title, ENT_QUOTES)))), 0, 20); $data_file_name = $projTitleShort . "_DATA_NOHDRS_" . $today . ".csv"; $data_file_name_WH = $projTitleShort . "_DATA_" . $today . ".csv"; $data_file_name_labels = $projTitleShort . "_DATA_LABELS_" . $today . ".csv"; $export_sps_file_name = $projTitleShort . "_SPSS_" . $today . ".sps"; $export_sas_file_name = $projTitleShort . "_SAS_" . $today . ".sas"; $export_R_file_name = $projTitleShort . "_R_" . $today . ".r"; $export_stata_file_name = $projTitleShort . "_STATA_" . $today . ".do"; //Finish up syntax files $spss_string = rtrim($spss_string); $spss_string .= ".\n"; $spss_string .= "\nVARIABLE LEVEL " . implode("\n\t/", $spss_variable_level) . ".\n"; $spss_string .= "\n" . substr_replace($spss_variable_label, ".", -3) . "\n\n"; $spss_string .= rtrim($value_labels_spss); $spss_string .= ".\n\n$spss_format_dates\nSET LOCALE=en_us.\nEXECUTE.\n"; $spss_string = str_replace("data_place_holder_name", $data_file_name, $spss_string); $sas_read_string .= "%macro removeOldFile(bye); %if %sysfunc(exist(&bye.)) %then %do; proc delete data=&bye.; run; " . "%end; %mend removeOldFile; %removeOldFile(work.redcap); data REDCAP; "; // Suggested change by Ray Balise //$sas_read_string .= "proc delete data=REDCAP;\nrun;\n\ndata REDCAP;"; // Added to prevent deleting all temp files //$sas_read_string .= "proc delete data=_ALL_;\nrun;\n\ndata REDCAP;"; $sas_read_string .= "%let _EFIERR_ = 0; "; $sas_read_string .= "infile '" . $data_file_name . "'"; $sas_read_string .= " delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=1 ; "; $sas_read_string .= "\n" . $sas_informat; $sas_read_string .= "\n" . $sas_format; $sas_read_string .= "\n" . $sas_input; $sas_read_string .= ";\n"; $sas_read_string .= "if _ERROR_ then call symput('_EFIERR_',\"1\");\n"; $sas_read_string .= "run;\n\nproc contents;run;\n\n"; $sas_read_string .= $sas_label_section . "\trun;\n"; $sas_value_label .= "\n\trun;\n"; $sas_format_string .= "\trun;\n"; $sas_read_string .= "\n" . $sas_value_label; $sas_read_string .= "\n" . $sas_format_string; $sas_read_string .= "\nproc contents data=redcap;"; $sas_read_string .= "\nproc print data=redcap;"; $sas_read_string .= "\nrun;\nquit;"; $stata_order = "order " . substr($stata_insheet, 8); $stata_insheet .= "using " . "\"" . $data_file_name . "\", nonames"; $stata_string .= $stata_insheet . "\n\n"; $stata_string .= "label data " . "\"" . $data_file_name . "\"" . "\n\n"; $stata_string .= $stata_value_label . "\n"; $stata_string .= $stata_inf_label . "\n\n"; $stata_string .= $stata_date_format . "\n"; $stata_string .= $stata_var_label . "\n"; $stata_string .= $stata_order . "\n"; $stata_string .= "set more off\ndescribe\n"; $R_string .= "#Read Data\ndata=read.csv('" . $data_file_name_WH . "')\n"; $R_string .= $R_label_string; $R_string .= $R_units_string; $R_string .= $R_factors_string; $R_string .= $R_levels_string; $today = date("Y-m-d-H-i-s"); $docs_comment = $docs_comment_WH = "Data export file created by $userid on $today"; $spss_docs_comment = "Spss syntax file created by $userid on $today"; $sas_docs_comment = "Sas syntax file created by $userid on $today"; $stata_docs_comment = "Stata syntax file created by $userid on $today"; $R_docs_comment = "R syntax file created by $userid on $today"; $data = prep($data); ######################################### // Replace any MS Word chacters in the data $data_csv = replaceMSchars($data_csv); $data_csv_labels = replaceMSchars($data_csv_labels); //Add comment in last field if these are date shifted $doc_rights = $do_date_shift ? "'DATE_SHIFT'" : "NULL"; // Set flag for checking if error occurs during saving of files to docs table $is_export_error = false; ### Creates the STATA syntax file $stata_string = strip_tags($stata_string); // Do NOT use addBOMtoUTF8() on Stata because BOM causes issues in syntax file $docs_size = strlen($stata_string); $export_sql = "INSERT INTO redcap_docs (project_id,docs_name,docs_file,docs_date,docs_size,docs_comment,docs_type,docs_rights,export_file) " . "VALUES ($project_id, '" . $export_stata_file_name . "', NULL, '" . TODAY . "','$docs_size','" . $stata_docs_comment . "','application/octet-stream',$doc_rights,1)"; if (!db_query($export_sql)) { $is_export_error = true; } else { // Get insert id $stata_doc_id = db_insert_id(); // Store the file in the file system if (!DataExport::storeExportFile($export_stata_file_name, $stata_string, $stata_doc_id, $docs_size)) { $is_export_error = true; } } ### Creates the R syntax file $R_string = addBOMtoUTF8(strip_tags($R_string)); $docs_size = strlen($R_string); $export_sql = "INSERT INTO redcap_docs (project_id,docs_name,docs_file,docs_date,docs_size,docs_comment,docs_type,docs_rights,export_file) " . "VALUES ($project_id, '" . $export_R_file_name . "', NULL, '" . TODAY . "','$docs_size','" . $R_docs_comment . "','application/octet-stream',$doc_rights,1)"; if (!db_query($export_sql)) { $is_export_error = true; } else { // Get insert id $r_doc_id = db_insert_id(); // Store the file in the file system if (!DataExport::storeExportFile($export_R_file_name, $R_string, $r_doc_id, $docs_size)) { $is_export_error = true; } } ### Creates the SAS syntax file $sas_read_string = addBOMtoUTF8(strip_tags($sas_read_string)); $docs_size = strlen($sas_read_string); $export_sql = "INSERT INTO redcap_docs (project_id,docs_name,docs_file,docs_date,docs_size,docs_comment,docs_type,docs_rights,export_file) " . "VALUES ($project_id, '" . $export_sas_file_name . "', NULL, '" . TODAY . "','$docs_size','" . $sas_docs_comment . "','application/octet-stream',$doc_rights,1)"; if (!db_query($export_sql)) { $is_export_error = true; } else { // Get insert id $sas_doc_id = db_insert_id(); // Store the file in the file system if (!DataExport::storeExportFile($export_sas_file_name, $sas_read_string, $sas_doc_id, $docs_size)) { $is_export_error = true; } } ### Creates the data comma separeted value file WITHOUT headers $data_csv_temp = addBOMtoUTF8($data_csv); $docs_size = strlen($data_csv_temp); $export_sql = "INSERT INTO redcap_docs (project_id,docs_name,docs_file,docs_date,docs_size,docs_comment,docs_type,docs_rights,export_file) " . "VALUES ($project_id, '" . $data_file_name . "', NULL, '" . TODAY . "','$docs_size','" . $docs_comment . "','application/csv',$doc_rights,1)"; if (!db_query($export_sql)) { $is_export_error = true; } else { // Get insert id $data_wo_hdr_doc_id = db_insert_id(); // Store the file in the file system if (!DataExport::storeExportFile($data_file_name, $data_csv_temp, $data_wo_hdr_doc_id, $docs_size)) { $is_export_error = true; } } unset($data_csv_temp); ### Creates the data comma separeted value file WITH header $data_csv = addBOMtoUTF8($headers . $data_csv); $docs_size = strlen($data_csv); $export_sql = "INSERT INTO redcap_docs (project_id,docs_name,docs_file,docs_date,docs_size,docs_comment,docs_type,docs_rights,export_file) " . "VALUES ($project_id, '" . $data_file_name_WH . "', NULL, '" . TODAY . "','$docs_size','" . $docs_comment_WH . "','application/csv',$doc_rights,1)"; if (!db_query($export_sql)) { $is_export_error = true; } else { // Get insert id $data_doc_id = db_insert_id(); // Store the file in the file system if (!DataExport::storeExportFile($data_file_name_WH, $data_csv, $data_doc_id, $docs_size)) { $is_export_error = true; } } unset($data_csv); ### Creates the SPSS syntax file $spss_string = addBOMtoUTF8(strip_tags($spss_string)); $docs_size = strlen($spss_string); $export_sql = "INSERT INTO redcap_docs (project_id,docs_name,docs_file,docs_date,docs_size,docs_comment,docs_type,docs_rights,export_file) " . "VALUES ($project_id, '" . $export_sps_file_name . "', NULL, '" . TODAY . "','$docs_size','" . $spss_docs_comment . "','application/octet-stream',$doc_rights,1)"; if (!db_query($export_sql)) { $is_export_error = true; } else { // Get insert id $spss_doc_id = db_insert_id(); // Store the file in the file system if (!DataExport::storeExportFile($export_sps_file_name, $spss_string, $spss_doc_id, $docs_size)) { $is_export_error = true; } } ### Creates the data comma separeted value file WITH LABELS $data_csv_labels = addBOMtoUTF8($headers_labels . $data_csv_labels); $docs_size = strlen($data_csv_labels); $export_sql = "INSERT INTO redcap_docs (project_id,docs_name,docs_file,docs_date,docs_size,docs_comment,docs_type,docs_rights,export_file) " . "VALUES ($project_id, '" . $data_file_name_labels . "', NULL, '" . TODAY . "','$docs_size','" . $docs_comment . "','application/csv',$doc_rights,1)"; if (!db_query($export_sql)) { $is_export_error = true; } else { // Get insert id $data_labels_doc_id = db_insert_id(); // Store the file in the file system if (!DataExport::storeExportFile($data_file_name_labels, $data_csv_labels, $data_labels_doc_id, $docs_size)) { $is_export_error = true; } } ######################################### //Catch the error if the CSV data file is too large for MySQL to handle if ($is_export_error) { include APP_PATH_DOCROOT . 'ProjectGeneral/header.php'; renderPageTitle("<img src='" . APP_PATH_IMAGES . "application_go.png'> {$lang['app_03']}"); print "<div class='red' style='margin:20px 0;'><img src='" . APP_PATH_IMAGES . "exclamation.png'> <b>{$lang['global_01']}:</b><br/>{$lang['data_export_tool_62']}"; if ($super_user) { if ($edoc_storage_option == '1') { print $lang['data_export_tool_136']; } elseif ($edoc_storage_option == '0') { print $lang['data_export_tool_135'] . " (<b>" . EDOC_PATH . "</b>)" . $lang['period']; } else { print $lang['data_export_tool_135'] . " " . $lang['period']; } print " " . $lang['data_export_tool_137']; } else { print "{$lang['data_export_tool_64']} <a href='mailto:$project_contact_email' style='font-family:Verdana;'>$project_contact_name</a> {$lang['data_export_tool_65']}"; } print "</div>"; renderPrevPageLink(PAGE); include APP_PATH_DOCROOT . 'ProjectGeneral/footer.php'; exit; } //Catch the error if there were data conversion problems if ($is_data_conversion_error) { include APP_PATH_DOCROOT . 'ProjectGeneral/header.php'; renderPageTitle("<img src='" . APP_PATH_IMAGES . "application_go.png'> {$lang['app_03']}"); print "<div class='red' style='margin:20px 0;'><img src='" . APP_PATH_IMAGES . "exclamation.png'> <b>{$lang['global_01']}:</b><br/>{$lang['data_export_tool_62']}"; if ($super_user) { print $lang['data_export_tool_63']; } else { print "{$lang['data_export_tool_64']} <a href='mailto:$project_contact_email' style='font-family:Verdana;'>$project_contact_name</a> {$lang['data_export_tool_65']}"; } print $is_data_conversion_error_msg; print "</div>"; renderPrevPageLink(PAGE); include APP_PATH_DOCROOT . 'ProjectGeneral/footer.php'; exit; } // Header include APP_PATH_DOCROOT . 'ProjectGeneral/header.php'; renderPageTitle("<img src='" . APP_PATH_IMAGES . "application_go.png'> {$lang['app_03']}"); print "<div style='text-align:center;padding-top:10px;max-width:700px;'> <span class='darkgreen' style='padding:8px 80px;'> <img src='" . APP_PATH_IMAGES . "tick.png' class='imgfix'> {$lang['data_export_tool_05']} </span> </div> <p><br>{$lang['data_export_tool_06']}<br><br>"; // Button back to previous page $prevPage = (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : PAGE_FULL . "?pid=$project_id"; print "<button class='jqbutton' onclick=\"window.location.href='$prevPage';\"> <img src='" . APP_PATH_IMAGES . "arrow_left.png' class='imgfix'> {$lang['config_functions_40']} </button>"; //Set the CSV icon to date-shifted look if the data in these files were date shifted if ($do_date_shift) { $csv_img = "download_csvdata_ds.gif"; $csvexcel_img = "download_csvexcel_raw_ds.gif"; $csvexcellabels_img = "download_csvexcel_labels_ds.gif"; } else { $csv_img = "download_csvdata.gif"; $csvexcel_img = "download_csvexcel_raw.gif"; $csvexcellabels_img = "download_csvexcel_labels.gif"; } // If Send-It is not enabled for Data Export and File Repository, then hide the link to utilize Send-It $sendItLinkDisplay = ($sendit_enabled == '1' || $sendit_enabled == '3') ? "" : "display:none;"; //Table header print "<div style='max-width:700px;'>"; print "<table style='border: 1px solid #DODODO; border-collapse: collapse; width: 100%'> <tr class='grp2'> <td colspan='2' style='font-family:Verdana;font-size:12px;text-align:right;'> </td> <td style='font-family:Verdana;font-size:12px;text-align:center;'> {$lang['docs_58']}<br>{$lang['data_export_tool_51']} </td> </tr>"; //Excel print '<tr class="odd"> <td valign="top" style="text-align:center;width:60px;padding-top:10px;border:0px;border-left:1px solid #D0D0D0;"> <img src="' . APP_PATH_IMAGES . 'excelicon.gif" title="' . $lang['data_export_tool_15'] . '" alt="' . $lang['data_export_tool_15'] . '" /> </td> <td style="font-family:Verdana;font-size:11px;padding:10px;" valign="top"> <b>' . $lang['data_export_tool_15'] . '</b><br> ' . $lang['data_export_tool_118'] . '<br><br> <i>' . $lang['global_02'] . ': ' . $lang['data_export_tool_17'] . '</i> </td> <td valign="top" style="text-align:right;width:100px;padding-top:10px;"> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $data_labels_doc_id . '"> <img src="' . APP_PATH_IMAGES . $csvexcellabels_img . '" title="' . $lang['data_export_tool_60'] . '" alt="' . $lang['data_export_tool_60'] . '"></a> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $data_doc_id . '"> <img src="' . APP_PATH_IMAGES . $csvexcel_img . '" title="' . $lang['data_export_tool_60'] . '" alt="' . $lang['data_export_tool_60'] . '"></a> <div style="text-align:left;padding:5px 0 1px;' . $sendItLinkDisplay . '"> <div style="line-height:5px;"> <img src="' . APP_PATH_IMAGES . 'mail_small.png" style="position: relative; top: 5px;"><a href="javascript:;" style="color:#666;font-size:10px;text-decoration:underline;" onclick=\'$("#sendit_' . $data_doc_id . '").toggle("blind",{},"fast");\'>' . $lang['data_export_tool_66'] . '</a> </div> <div id="sendit_' . $data_doc_id . '" style="display:none;padding:4px 0 4px 6px;"> <div> • <a href="javascript:;" onclick="popupSendIt(' . $data_labels_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_120'] . '</a> </div> <div> • <a href="javascript:;" onclick="popupSendIt(' . $data_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_119'] . '</a> </div> </div> </div> </td> </tr>'; //SPSS print '<tr class="even noncsv"> <td valign="top" style="text-align:center;width:60px;padding-top:10px;border:0px;border-left:1px solid #D0D0D0;"> <img src="' . APP_PATH_IMAGES . 'spsslogo_small.png" title="' . $lang['data_export_tool_07'] . '" alt="' . $lang['data_export_tool_07'] . '" /> </td> <td style="font-family:Verdana;font-size:11px;padding:10px;" valign="top"> <b>' . $lang['data_export_tool_07'] . '</b><br />' . $lang['global_24'] . $lang['colon'] . " " . $lang['data_export_tool_08'] . '<br> <a href="javascript:;" style="text-decoration:underline;font-size:11px;" onclick=\'$("#spss_detail").toggle("fade");\'>' . $lang['data_export_tool_08b'] . '</a> <div style="display:none;border-top:1px solid #aaa;margin-top:5px;padding-top:3px;" id="spss_detail"> <b>' . $lang['data_export_tool_01'] . '</b><br>' . $lang['data_export_tool_08c'] . ' <font color="green">/folder/subfolder/</font> (e.g., /Users/administrator/documents/)<br><br>' . $lang['data_export_tool_08d'] . ' <br><font color=green>FILE HANDLE data1 NAME=\'DATA.CSV\' LRECL=90000.</font><br><br>' . $lang['data_export_tool_08e'] . '<br> <font color=green>FILE HANDLE data1 NAME=\'<font color=red>/folder/subfolder/</font>DATA.CSV\' LRECL=90000.</font><br><br>' . $lang['data_export_tool_08f'] . ' </div> </td> <td valign="top" style="text-align:right;width:100px;padding-top:10px;"> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $spss_doc_id . '"> <img src="' . APP_PATH_IMAGES . 'download_spss.gif" title="' . $lang['data_export_tool_68'] . '" alt="' . $lang['data_export_tool_68'] . '"> </a> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $data_wo_hdr_doc_id . '"> <img src="' . APP_PATH_IMAGES . $csv_img . '" title="' . $lang['data_export_tool_69'] . '" alt="' . $lang['data_export_tool_69'] . '"></a> <div style="padding-left:11px;text-align:left;"> <a href="' . APP_PATH_WEBROOT . 'DataExport/spss_pathway_mapper.php?pid=' . $project_id . '" ><img src="' . APP_PATH_IMAGES . 'download_pathway_mapper.gif" title="' . $lang['data_export_tool_70'] . '" alt="' . $lang['data_export_tool_70'] . '"></a> </div> <div style="text-align:left;padding:5px 0 1px;' . $sendItLinkDisplay . '"> <div style="line-height:5px;"> <img src="' . APP_PATH_IMAGES . 'mail_small.png" style="position: relative; top: 5px;"><a href="javascript:;" style="color:#666;font-size:10px;text-decoration:underline;" onclick=\' $("#sendit_' . $spss_doc_id . '").toggle("blind",{},"fast"); \'>' . $lang['data_export_tool_66'] . '</a> </div> <div id="sendit_' . $spss_doc_id . '" style="display:none;padding:4px 0 4px 6px;"> <div> • <a href="javascript:;" onclick="popupSendIt(' . $spss_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_71'] . '</a> </div> <div> • <a href="javascript:;" onclick="popupSendIt(' . $data_wo_hdr_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_72'] . '</a> </div> </div> </div> </td> </tr>'; //SAS print '<tr class="odd noncsv"> <td valign="top" style="text-align:center;width:60px;padding-top:10px;border:0px;border-left:1px solid #D0D0D0;"> <img src="' . APP_PATH_IMAGES . 'saslogo_small.png" title="' . $lang['data_export_tool_11'] . '" alt="' . $lang['data_export_tool_11'] . '" /> </td> <td style="font-family:Verdana;font-size:11px;padding:10px;" valign="top"> <b>' . $lang['data_export_tool_11'] . '</b><br />' . $lang['global_24'] . $lang['colon'] . " " . $lang['data_export_tool_130'] . '<br> <a href="javascript:;" style="text-decoration:underline;font-size:11px;" onclick=\'$("#sas_detail").toggle("fade");\'>' . $lang['data_export_tool_08b'] . '</a> <div style="display:none;border-top:1px solid #aaa;margin-top:5px;padding-top:3px;" id="sas_detail"> <b>' . $lang['data_export_tool_131'] . '</b><br>' . $lang['data_export_tool_132'] . ' <font color="green">/folder/subfolder/</font> (e.g., /Users/administrator/documents/)<br><br>' . $lang['data_export_tool_133'] . ' <br>... <font color=green>infile \'DATA.CSV\' delimiter = \',\' MISSOVER DSD lrecl=32767 firstobs=1 ;</font><br><br>' . $lang['data_export_tool_08e'] . '<br> ... <font color=green>infile \'<font color=red>/folder/subfolder/</font>DATA.CSV\' delimiter = \',\' MISSOVER DSD lrecl=32767 firstobs=1 ;</font><br><br>' . $lang['data_export_tool_134'] . ' </div> </td> <td valign="top" style="text-align:right;width:100px;padding-top:10px;"> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $sas_doc_id . '"> <img src="' . APP_PATH_IMAGES . 'download_sas.gif" title="' . $lang['data_export_tool_74'] . '" alt="' . $lang['data_export_tool_74'] . '"> </a> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $data_wo_hdr_doc_id . '"> <img src="' . APP_PATH_IMAGES . $csv_img . '" title="' . $lang['data_export_tool_69'] . '" alt="' . $lang['data_export_tool_69'] . '"></a> <div style="padding-left:11px;text-align:left;"> <a href="' . APP_PATH_WEBROOT . 'DataExport/sas_pathway_mapper.php?pid=' . $project_id . '" ><img src="' . APP_PATH_IMAGES . 'download_pathway_mapper.gif"></a> </div> <div style="text-align:left;padding:5px 0 1px;' . $sendItLinkDisplay . '"> <div style="line-height:5px;"> <img src="' . APP_PATH_IMAGES . 'mail_small.png" style="position: relative; top: 5px;"><a href="javascript:;" style="color:#666;font-size:10px;text-decoration:underline;" onclick=\' $("#sendit_' . $sas_doc_id . '").toggle("blind",{},"fast"); \'>' . $lang['data_export_tool_66'] . '</a> </div> <div id="sendit_' . $sas_doc_id . '" style="display:none;padding:4px 0 4px 6px;"> <div> • <a href="javascript:;" onclick="popupSendIt(' . $sas_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_71'] . '</a> </div> <div> • <a href="javascript:;" onclick="popupSendIt(' . $data_wo_hdr_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_72'] . '</a> </div> </div> </div> </td> </tr>'; //R print '<tr class="even noncsv"> <td valign="top" style="text-align:center;width:60px;padding-top:10px;border:0px;border-left:1px solid #D0D0D0;"> <img src="' . APP_PATH_IMAGES . 'rlogo_small.png" title="' . $lang['data_export_tool_09'] . '" alt="' . $lang['data_export_tool_09'] . '" /> </td> <td style="font-family:Verdana;font-size:11px;padding:10px;" valign="top"> <b>' . $lang['data_export_tool_09'] . '</b><br />' . $lang['data_export_tool_10'] . ' </td> <td valign="top" style="text-align:right;width:100px;padding-top:10px;"> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $r_doc_id . '"> <img src="' . APP_PATH_IMAGES . 'download_r.gif" title="' . $lang['data_export_tool_75'] . '" alt="' . $lang['data_export_tool_75'] . '"> </a> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $data_doc_id . '&exporttype=R"> <img src="' . APP_PATH_IMAGES . $csv_img . '" title="' . $lang['data_export_tool_69'] . '" alt="' . $lang['data_export_tool_69'] . '"></a> <div style="text-align:left;padding:5px 0 1px;' . $sendItLinkDisplay . '"> <div style="line-height:5px;"> <img src="' . APP_PATH_IMAGES . 'mail_small.png" style="position: relative; top: 5px;"><a href="javascript:;" style="color:#666;font-size:10px;text-decoration:underline;" onclick=\' $("#sendit_' . $r_doc_id . '").toggle("blind",{},"fast"); \'>' . $lang['data_export_tool_66'] . '</a> </div> <div id="sendit_' . $r_doc_id . '" style="display:none;padding:4px 0 4px 6px;"> <div> • <a href="javascript:;" onclick="popupSendIt(' . $r_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_71'] . '</a> </div> <div> • <a href="javascript:;" onclick="popupSendIt(' . $data_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_72'] . '</a> </div> </div> </div> </td> </tr>'; //STATA print '<tr class="odd noncsv"> <td valign="top" style="text-align:center;width:60px;padding-top:10px;border:0px;border-bottom:1px solid #D0D0D0;border-left:1px solid #D0D0D0;"> <img src="' . APP_PATH_IMAGES . 'statalogo_small.png" title="' . $lang['data_export_tool_13'] . '" alt="' . $lang['data_export_tool_13'] . '" /> </td> <td style="font-family:Verdana;font-size:11px;padding:10px;border-bottom:1px solid #D0D0D0;" valign="top"> <b>' . $lang['data_export_tool_13'] . '</b><br />' . $lang['data_export_tool_14'] . ' </td> <td valign="top" style="text-align:right;width:100px;padding-top:10px;border-bottom:1px solid #D0D0D0;"> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $stata_doc_id . '"> <img src="' . APP_PATH_IMAGES . 'download_stata.gif" title="' . $lang['data_export_tool_76'] . '" alt="' . $lang['data_export_tool_76'] . '"> </a> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $data_wo_hdr_doc_id . '"> <img src="' . APP_PATH_IMAGES . $csv_img . '" title="' . $lang['data_export_tool_69'] . '" alt="' . $lang['data_export_tool_69'] . '"></a> <div style="text-align:left;padding:5px 0 1px;' . $sendItLinkDisplay . '"> <div style="line-height:5px;"> <img src="' . APP_PATH_IMAGES . 'mail_small.png" style="position: relative; top: 5px;"><a href="javascript:;" style="color:#666;font-size:10px;text-decoration:underline;" onclick=\' $("#sendit_' . $stata_doc_id . '").toggle("blind",{},"fast"); \'>' . $lang['data_export_tool_66'] . '</a> </div> <div id="sendit_' . $stata_doc_id . '" style="display:none;padding:4px 0 4px 6px;"> <div> • <a href="javascript:;" onclick="popupSendIt(' . $stata_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_71'] . '</a> </div> <div> • <a href="javascript:;" onclick="popupSendIt(' . $data_wo_hdr_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_72'] . '</a> </div> </div> </div> </td> </tr>'; print '</table>'; print '</div><br><br><br><br>'; }
$records = trimHeader($records); // no headers fwrite($fh, $records); $batch_times[$b] = microtime(true) - $batch_start; } fclose($fh); // Data CSV file download icon $html = RCView::form( array('method'=>'post', 'name'=>'full_export', 'action'=>$_SERVER['REQUEST_URI'], 'enctype'=>'multipart/form-data'), RCView::input(array('type'=>'hidden', 'name'=>'download', 'value'=>$target_filename)) . RCView::button(array( 'name'=>'submit-btn-download', 'class'=>'jqbutton', 'style'=>'color:#800000;width:200px;', 'onclick'=>'$(this).submit();'),"<div style='float:left;padding-top:2px;'>" . trim(DataExport::getDownloadIcon('csv', false)) . "</div><div style='padding-top:8px;'>Download export<div style='font-size:smaller;'>Filesize: " . round(filesize($target_file)/1024) . "kb</div></div>" ) . RCView::div(array('style'=>'margin:10px;'),"This file will be automatically deleted from the server in approximately one hour") ); $msg = "Processed $id_count records in " . round(array_sum($batch_times)) . " seconds."; echo " <script language='javascript'> $('#progress_info').html('$msg'); </script>"; echo "<br>" . $html; echo str_repeat(' ',1024*64); flush(); //print "\nRecords: $records"; //echo "\n".print_r($records,true);
function downloadDatabase(&$db, $headers = true) { // don't make POST as REQUEST here. it won't work :P if (!(is_array(v($_POST["tables"])) || is_array(v($_POST["views"])) || is_array(v($_POST["procs"])) || is_array(v($_POST["funcs"])) || is_array(v($_POST["triggers"])) || is_array(v($_POST["events"])))) { return false; } include BASE_PATH . '/lib/export/export.php'; $exporter = new DataExport($db, 'insert'); if ($headers) { $exporter->sendDownloadHeader(Session::get('db', 'name')); } echo $db->addExportHeader(Session::get('db', 'name'), 'db', 'insert'); $export_type = v($_REQUEST["exptype"]); if (is_array($_POST["tables"]) && count($_POST["tables"]) > 0) { $tables = flattenTableNames($db->getTables()); $options = array('type' => 'insert', 'fieldnames' => v($_REQUEST['fieldnames']) == 'on' ? TRUE : FALSE, 'bulkinsert' => v($_REQUEST['bulkinsert']), 'bulksize' => v($_REQUEST['bulklimit']) == 'on' ? v($_REQUEST['bulksize']) * 1024 : 0); foreach ($tables as $table_name) { // is this table required in export? $key = array_search($table_name, $_POST["tables"]); if ($key === FALSE) { continue; } // -- -truncate command -- if (v($_REQUEST["emptycmd"]) == "on") { echo "\n" . $db->getTruncateCommand($table_name) . ";\n"; } // -- -drop command -- if (v($_REQUEST["dropcmd"]) == "on") { echo "\n" . $db->getDropCommand($table_name) . ";\n"; } // -- -structure -- $type = "table"; if ($export_type == "all" || $export_type == "struct") { print "\n/* Table structure for {$table_name} */\n"; $cmd = $db->getCreateCommand('table', $table_name); // strip out auto_increment value from create table statement if (v($_REQUEST["auto_null"]) == "on") { $cmd = stripAutoIncrement($cmd); } // strip out table engine type from create table statement if (v($_REQUEST["exclude_type"]) == "on") { $cmd = stripTableType($cmd); } // strip out table charset from create table statement if (v($_REQUEST["exclude_charset"]) == "on") { $cmd = stripTableCharset($cmd); } print $cmd . ";\n"; } // -- -table data -- if ($export_type == "all" || $export_type == "data") { $options['auto_field'] = v($_REQUEST["auto_null"]) == "on" ? $db->getAutoIncField($table_name) : -1; $options['table'] = $table_name; $sql = "SELECT * FROM " . $db->quote($table_name); print "\n/* data for Table {$table_name} */\n"; $exporter->exportTable($sql, $options); } } } if ($export_type == "all" || $export_type == "struct") { // views, procedures etc do not have any data $object_types = $db->getObjectTypes(); // skip tables as we have already done it unset($object_types[0]); foreach ($object_types as $type) { if (is_array(v($_POST[$type])) && count($_POST[$type]) > 0) { $func = 'get' . ucfirst($type); $name = substr($type, 0, -1); exportObject($db, $name, $_POST[$type], $db->{$func}()); } } } echo $db->addExportFooter(); }
$arr["WeatherId"] = isset($_GET["weatherId"]) ? $_GET["weatherId"] : 0; $arr["UserId"] = isset($_GET["userId"]) ? $_GET["userId"] : 0; $item = new PlantObservation(); $item->hydrate($arr); $ObservationMgr->save($item); $msg = $arr["PlantName"] . ' record added'; header("Location: adminController.php?msg={$msg}"); break; case 'manage_users': header("Location: adminController.php?msg=User management isn't yet implemented"); break; case 'shapefile_export': header("Location: adminController.php?msg=Shapefile export isn't yet implemented"); break; case 'csv_export': $export = new DataExport(); $rows = $ObservationMgr->getAllObservationsAsMSQLiObjects(); $export->toCSV($rows); header("Location: adminController.php"); break; default: //include('../views/FOFAEntry.view.php'); $items = $ObservationMgr->getAllObservationRecords(); include '../views/list.view.php'; break; } ?> </body> </html>
function dispatch($op) { switch ($op) { case "tab": YuiLib::load(array('tabview' => 'tabview-min.js'), array('tabview/assets/skins/sam/' => 'tabview.css')); require_once $GLOBALS['where_framework'] . '/lib/user_selector/lib.basetree.php'; require_once $GLOBALS['where_framework'] . '/lib/user_selector/lib.groupselectortable.php'; require_once $GLOBALS['where_framework'] . '/lib/user_selector/lib.userselectortable.php'; require_once $GLOBALS['where_framework'] . '/lib/user_selector/lib.dynamicuserfilter.php'; cout(getTitleArea(array('Test manager e selettore utenti'))); cout('<div class="std_block">'); $bt = new BaseTree('user_orgchart', false, false, _TREE_COLUMNS_TYPE_RADIO); $bt->init(); $bt->setInitialSelection(); $bt_out = $bt->get(); $gst = new GroupSelectorTable('group_table'); $gst->init(); $gst_out = $gst->get(); $ust = new UserSelectorTable('user_table'); $ust->init(); $ust_out = $ust->get(); $duf = new DynamicUserFilter('user_rules'); $duf->init(); $duf_out = $duf->get(); cout($bt_out['js'], 'page_head'); cout($gst_out['js'], 'page_head'); cout($ust_out['js'], 'page_head'); cout($duf_out['js'], 'page_head'); cout('<div id="' . $this->id . '" class="yui-navset"> <ul class="yui-nav"> <li><a href="#tab1"><em>Organigramma</em></a></li> <li class="selected"><a href="#tab2"><em>Utenti</em></a></li> <li><a href="#tab3"><em>Gruppi</em></a></li> <li><a href="#tab4"><em>Regole</em></a></li> </ul> <div class="yui-content"> <div id="tab1">' . $bt_out['html'] . '</div> <div id="tab2">' . $ust_out['html'] . '</div> <div id="tab3"><p>' . $gst_out['html'] . '</p></div> <div id="tab4">' . $duf_out['html'] . '</div> </div> </div>'); cout('<script type="text/javascript"> var tabView = new YAHOO.widget.TabView(\'demo\'); </script>'); cout('</div>'); break; case "final": require_once _base_ . '/lib/lib.form.php'; require_once $GLOBALS['where_framework'] . '/lib/user_selector/lib.fulluserselector.php'; $selector = new FullUserSelector('selector'); $selector->init(); $temp = $selector->get(); cout(getTitleArea(array('Selettore utenti completo'))); cout('<div class="std_block">'); cout(Form::openForm('test', 'index.php?modname=_test_module&op=resp_to_form')); cout($temp['js'], 'page_head'); cout($temp['html']); cout(Form::openButtonSpace() . Form::getButton('save', 'save', 'SALVA') . Form::getButton('undo', 'undo', 'ANNULLA') . Form::closeButtonSpace()); cout(Form::closeForm()); cout('</div>'); break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case 'dataexport': require_once _base_ . '/lib/dataexport/lib.dataexport.php'; $lang =& DoceboLanguage::CreateInstance('standard', 'framework'); $query = "SELECT * FROM core_user ORDER BY lastname LIMIT 0,20 "; $source = new DataSource_Query($query); $nameGroup = array(); $nameGroup[] = new DataColumn('lastname', $lang->def('_LASTNAME')); $nameGroup[] = new DataColumn('firstname', $lang->def('_FIRSTNAME')); $columns = array(); $columns[] = new DataColumn('idst', $lang->def('_ID')); $columns[] = new DataColumnGroup('name', $lang->def('_NAME'), $nameGroup); $columns[] = new DataColumn('userid', $lang->def('_USERNAME'), 'formatter_userid'); $columns[] = new DataColumn('email', $lang->def('_EMAIL')); //$columns[] = new DataColumn(); $export = new DataExport(DATATYPE_HTM, 'users', $columns, $source); cout($export->render()); cout('<br /><br /><a href="index.php?modname=_test_module&op=dataexportcsv">SCARICA IN CSV</a>'); break; case 'dataexportcsv': require_once _base_ . '/lib/lib.download.php'; require_once _base_ . '/lib/dataexport/lib.dataexport.php'; $lang =& DoceboLanguage::CreateInstance('standard', 'framework'); $query = "SELECT * FROM core_user ORDER BY lastname LIMIT 0,20 "; $source = new DataSource_Query($query); $nameGroup = array(); $nameGroup[] = new DataColumn('lastname', $lang->def('_LASTNAME')); $nameGroup[] = new DataColumn('firstname', $lang->def('_FIRSTNAME')); $columns = array(); $columns[] = new DataColumn('idst', $lang->def('_ID')); $columns[] = new DataColumnGroup('name', $lang->def('_NAME'), $nameGroup); $columns[] = new DataColumn('userid', $lang->def('_USERNAME'), 'formatter_userid'); $columns[] = new DataColumn('email', $lang->def('_EMAIL')); //$columns[] = new DataColumn(); $export = new DataExport(DATATYPE_XLS, 'users', $columns, $source); sendStrAsFile($export->render(), "export_utenti.xls"); break; case 'sample': $libs = YuiLib::load(false, false, true); $GLOBALS['page']->add($libs, 'page_head'); $GLOBALS['page']->add(Util::get_css('../yui-skin/datatable.css'), 'page_head'); Util::get_js(Get::rel_path('base') . '/docebocore/modules/_test_module/sample.js', true, true); $script = 'YAHOO.util.Event.onDOMReady(function(e) { initTable(); });'; //$GLOBALS['page']->add('<p>TITLE</p>'); $GLOBALS['page']->add('<div id="datatable"></div>'); $GLOBALS['page']->add('<script type="text/javascript">' . $script . '</script>'); break; case 'datatable': require_once _lms_ . '/lib/table_view/class.coursetableview.php'; $_temp_ = array(array("idCourse" => 0, "code" => "codice_001", "name" => "nome_001", "status" => "ok", "subscriptions" => 10), array("idCourse" => 1, "code" => "codice_002", "name" => "nome_002", "status" => "ok", "subscriptions" => 20), array("idCourse" => 2, "code" => "codice_003", "name" => "nome_003", "status" => "ok", "subscriptions" => 30), array("idCourse" => 3, "code" => "codice_004", "name" => "nome_004", "status" => "no", "subscriptions" => 40), array("idCourse" => 4, "code" => "codice_005", "name" => "nome_005", "status" => "ok", "subscriptions" => 50)); require_once _lms_ . '/lib/table_view/class.coursetableview.php'; $tableView = new CourseTableView("courses_table"); $tableView->useDOMReady = true; //to change $tableView->isGlobalVariable = true; //just for debug purpose $tableView->initLibraries(); $tableView->setInitialData($_temp_); $temp = $tableView->get(); cout($temp['js'], 'page_head'); cout('<div style="border:solid 1px black; padding:8px;"><p>DATATABLE:</p>' . $temp['html'] . '</div>'); break; case "catalogue": YuiLib::load(); cout('<div class="area_block"><h1 class="main_title_dashboard" id="main_area_title">Catalogo corsi</h1></div>', 'content'); cout('<div class="std_block">', 'content'); cout('<div id="course_cat" class="">', 'content'); cout('<ul class=""> <li class="selected"><a href="#tab1"><em>Inviti</em></a></li> <li><a href="#tab2"><em>Nuovi</em></a></li> <li><a href="#tab3"><em>Consigliati</em></a></li> <li><a href="#tab4"><em>Completo</em></a></li> <li><a href="#tab5"><em>Calendario</em></a></li> </ul> <div class="yui-content"> <div>' . Get::img(Get::rel_path('base') . '/mycourses.jpg', false, false, false, true) . '</div> <div> <p>Lorem ipsum dolor sit amet consectetuer accumsan enim tempor neque urna. Tempus interdum euismod felis mauris Aliquam et vitae elit vel leo. Accumsan Phasellus sit natoque rutrum nibh auctor eu neque porta tincidunt. Ipsum enim ut felis nunc Pellentesque sed malesuada justo nec nec. Sem justo dolor mattis porta Quisque.</p> <p>Interdum ut diam convallis Sed hendrerit est augue eget ipsum lacinia. Et at montes Sed est nec arcu cursus congue neque quis. Sagittis nec dictum nibh urna non urna justo consectetuer accumsan pretium. A risus velit ante id Donec nibh eros vitae at amet. Enim et hac Nam mus tellus consequat sapien eros nec sapien. Wisi Integer sapien suscipit tincidunt et tincidunt eu et neque et. Semper nisl et.</p> <p>Justo nunc et Maecenas dictum Vestibulum vel a neque libero non. Hendrerit metus Vestibulum Pellentesque consectetuer augue malesuada Ut Vestibulum Vestibulum scelerisque. Elit tellus enim purus nascetur Cum condimentum est vitae pellentesque pellentesque. Nisl pretium vel dolor Integer et pharetra elit nulla et nonummy. Phasellus tempus malesuada cursus ipsum urna consectetuer ut quis condimentum consequat. Parturient pretium convallis accumsan.</p> <p>Turpis vitae turpis lorem dignissim quis lorem rutrum pede mus justo. Morbi dictumst interdum ut dui elit faucibus ac tempor eget a. Pede penatibus urna mus id pellentesque commodo amet porta risus pede. Sapien semper congue nibh sit tortor enim nibh amet quis in. Vivamus condimentum egestas dictumst vel auctor ut Aenean malesuada mattis convallis. Ipsum Pellentesque libero Nullam Donec nec at enim faucibus sit orci. </p> </div> <div>' . Get::img(Get::rel_path('base') . '/mycourses.jpg', false, false, false, true) . '</div> <div>' . Get::img(Get::rel_path('base') . '/mycourses.jpg', false, false, false, true) . '</div> <div>' . Get::img(Get::rel_path('base') . '/calendar.jpg', false, false, false, true) . '</div> </div>', 'content'); cout('</div>', 'content'); cout('' . '<script type="text/javascript">' . "\n" . '</script>' . "\n", 'scripts'); break; default: YuiLib::load(); //cout('<div class="area_block">PROVA ALBERO</div>', 'content'); cout('<div style="margin: 2em">', 'content'); cout('<div id="course_tag" class="yui-navset">', 'content'); cout('<style> .subcatbox { margin-bottom: 20px; font-size: 86%; } .subcatbox dt { font-weight: bold; font-size: 108%; margin-bottom: 4px; } .subcatbox dd { margin-left: 10px; margin-bottom: 4px; } </style>', 'page_head'); cout(' <ul class="yui-nav"> <li><a href="#tab1"><em>Corsi</em></a></li> <li class="selected"><a href="#tab2"><em>Documenti e multimedia</em></a></li> <li><a href="#tab3"><em>Videconferenze</em></a></li> </ul> <div class="yui-content yui-nopadding"> <div> <div class="subtab_list"> <ul class=""> <li class="selected"><a href="#tab1"><em>In itinere</em></a></li> <li><a href="#tab1"><em>Completati</em></a></li> <li><a href="#tab1"><em>Inviti</em></a></li> <li><a href="#"><em>Nuovi</em></a></li> <li><a href="#"><em>Consigliati</em></a></li> <li><a href="#"><em>Tutti</em></a></li> <li><a href="#"><em>Calendario</em></a></li> </ul> </div> ' . Get::img(Get::rel_path('base') . '/mycourses.jpg', false, false, false, true) . ' </div> <div> <div class="subtab_list"> <ul class=""> <li class="selected"><a href="#tab1"><em>Ricerca</em></a></li> <li><a href="#tab1"><em>Gestione</em></a></li> </ul> </div> <br /> <br /> <div style="text-align: center; position:relative;"> <input type="text" size="40" id="c_filter" name="c_filter" value="Cerca ..." class="" maxlength="255" alt="Cerca" onclick="this.value=\'\';" /><input type="submit" id="c_filter" name="c_filter" value="Cerca" class="search_b" maxlength="255" alt="Cerca" /> <br/><br/> <input type="radio" name="searchin" value="2" checked="checked" /> Nei documenti e nei corsi <input type="radio" name="searchin" value="0" /> Nei documenti <input type="radio" name="searchin" value="1" /> Nei corsi </div> <br /> <br /> <br /> <div class="yui-gb" style="margin: 0 22px"> <div class="yui-u first"> <!-- sample code from ciao.it--> <dl class="subcatbox"><dt> <a href="http://www.ciao.it/Portatili_206481_2" id="Node_Category_197256" class="hdl">Portatili</a></dt><dd> <a href="http://www.ciao.it/Portatili_206481_2-apple" class="subnr">Portatili Apple</a> <span class="subnr">(104)</span></dd><dd> <a href="http://www.ciao.it/Portatili_206481_2-sony" class="subnr">Portatili Sony</a> <span class="subnr">(383)</span></dd><dd> <a href="http://www.ciao.it/Portatili_206481_2-dell" class="subnr">Portatili Dell</a> <span class="subnr">(81)</span></dd><dd> <a href="http://www.ciao.it/Portatili_206481_2-fujitsu_siemens" class="subnr">Portatili Fujitsu-Siemens</a> <span class="subnr">(400)</span></dd><dd> <a href="http://www.ciao.it/Portatili_206481_2-hp" class="subnr">Portatili HP</a> <span class="subnr">(799)</span></dd><dd> <a href="http://www.ciao.it/Portatili_206481_2-asus" class="subnr">Portatili Asus</a> <span class="subnr">(663)</span></dd><dd> <a href="http://www.ciao.it/Portatili_206481_2-acer" class="subnr">Portatili Acer</a> <span class="subnr">(713)</span></dd><dd> <a href="http://www.ciao.it/Portatili_206481_2-toshiba" class="subnr">Portatili Toshiba</a> <span class="subnr">(737)</span></dd><dd> <a href="http://www.ciao.it/Portatili_206481_2-samsung" class="subnr">Portatili Samsung</a> <span class="subnr">(43)</span></dd></dl><dl class="subcatbox"><dt> <a href="http://www.ciao.it/PC_178183_2" id="Node_Category_168457" class="hdl">PC</a></dt><dd> <a href="http://www.ciao.it/PC_178183_2-hp" class="subnr">PC HP</a> <span class="subnr">(1643)</span></dd><dd> <a href="http://www.ciao.it/PC_178183_2-acer" class="subnr">PC Acer</a> <span class="subnr">(649)</span></dd><dd> <a href="http://www.ciao.it/PC_178183_2-packard_bell" class="subnr">PC Packard Bell</a> <span class="subnr">(864)</span></dd><dd> <a href="http://www.ciao.it/PC_178183_2-apple" class="subnr">PC Apple</a> <span class="subnr">(227)</span></dd><dd> <a href="http://www.ciao.it/PC_178183_2-olidata" class="subnr">PC Olidata</a> <span class="subnr">(574)</span></dd><dd> <a href="http://www.ciao.it/PC_178183_2-compaq" class="subnr">PC Compaq</a> <span class="subnr">(627)</span></dd></dl><dl class="subcatbox"><dt> <a href="http://www.ciao.it/Stampanti_178158_2" id="Node_Category_168459" class="hdl">Stampanti</a></dt><dd> <a href="http://www.ciao.it/Stampanti_178158_2-hp" class="subnr">Stampanti HP</a> <span class="subnr">(55)</span></dd><dd> <a href="http://www.ciao.it/Stampanti_178158_2-epson" class="subnr">Stampanti Espson</a> <span class="subnr">(466)</span></dd><dd> <a href="http://www.ciao.it/Stampanti_178158_2-lexmark_international" class="subnr">Stampanti Lexmark</a> <span class="subnr">(301)</span></dd><dd> <a href="http://www.ciao.it/Stampanti_178158_2-canon" class="subnr">Stampanti Canon</a> <span class="subnr">(239)</span></dd><dd> <a href="http://www.ciao.it/Stampanti_178158_2-brother" class="subnr">Stampanti Brother</a> <span class="subnr">(99)</span></dd><dd> <a href="http://www.ciao.it/Stampanti_178158_2-xerox" class="subnr">Stampanti Xerox</a> <span class="subnr">(182)</span></dd></dl><dl class="subcatbox"><dt> <a href="http://www.ciao.it/Stampanti_Multifunzione_205569_2" id="Node_Category_196265" class="hdl">Stampanti Multifunzione</a></dt><dd> <a href="http://www.ciao.it/Stampanti_Multifunzione_205569_2-xerox" class="subnr">Stampanti Multifunzione Xerox</a> <span class="subnr">(340)</span></dd><dd> <a href="http://www.ciao.it/Stampanti_Multifunzione_205569_2-canon" class="subnr">Stampanti Multifunzione Canon</a> <span class="subnr">(182)</span></dd><dd> <a href="http://www.ciao.it/Stampanti_Multifunzione_205569_2-brother" class="subnr">Stampanti Multifunzione Brother</a> <span class="subnr">(138)</span></dd><dd> <a href="http://www.ciao.it/Stampanti_Multifunzione_205569_2-lexmark_international" class="subnr">Stampanti Multifunzione Lexmark</a> <span class="subnr">(97)</span></dd><dd> <a href="http://www.ciao.it/Stampanti_Multifunzione_205569_2-epson" class="subnr">Stampanti Multifunzione Epson</a> <span class="subnr">(76)</span></dd><dd> <a href="http://www.ciao.it/Stampanti_Multifunzione_205569_2-samsung" class="subnr">Stampanti Multifunzione Samsung</a> <span class="subnr">(59)</span></dd></dl> <!-- end of sample code from ciao.it--> </div> <div class="yui-u"> <!-- sample code from ciao.it--> <dl class="subcatbox"><dt> <a href="http://www.ciao.it/Componenti_Hardware_178057_2" id="Node_Category_168463" class="hdl">Componenti Hardware</a></dt><dd> <a href="http://www.ciao.it/Schede_Madri_205459_3" class="subnr">Schede Madri</a> <span class="subnr">(1877)</span></dd><dd> <a href="http://www.ciao.it/Hard_Disk_178068_3" class="subnr">Hard Disk</a> <span class="subnr">(3568)</span></dd><dd> <a href="http://www.ciao.it/Drive_178061_3" class="subnr">Drive</a> <span class="subnr">(158)</span></dd><dd> <a href="http://www.ciao.it/Floppy_178067_3" class="subnr">Floppy</a> <span class="subnr">(169)</span></dd><dd> <a href="http://www.ciao.it/Alimentatori_178074_3" class="subnr">Alimentatori</a> <span class="subnr">(3207)</span></dd><dd> <a href="http://www.ciao.it/Componenti_Hardware_178057_2" id="Node_Category_More_168463" class="hdl">continua</a> </dd></dl><dl class="subcatbox"><dt> <a href="http://www.ciao.it/Monitor_LCD_178159_2" id="Node_Category_168460" class="hdl">Monitor LCD</a></dt><dd> <a href="http://www.ciao.it/Monitor_LCD_178159_2-samsung" class="subnr">Monitor Samsung</a> <span class="subnr">(394)</span></dd><dd> <a href="http://www.ciao.it/Monitor_LCD_178159_2-lg" class="subnr">Monitor LG</a> <span class="subnr">(315)</span></dd><dd> <a href="http://www.ciao.it/Monitor_LCD_178159_2-sony" class="subnr">Monitor Sony</a> <span class="subnr">(181)</span></dd><dd> <a href="http://www.ciao.it/Monitor_LCD_178159_2-philips" class="subnr">Monitor Philips</a> <span class="subnr">(275)</span></dd><dd> <a href="http://www.ciao.it/Monitor_LCD_178159_2-acer" class="subnr">Monitor Acer</a> <span class="subnr">(323)</span></dd><dd> <a href="http://www.ciao.it/Monitor_LCD_178159_2-hp" class="subnr">Monitor HP</a> <span class="subnr">(127)</span></dd></dl><dl class="subcatbox"><dt> <a href="http://www.ciao.it/Monitor_CRT_206455_2" id="Node_Category_197225" class="hdl">Monitor CRT</a></dt><dd> <a href="http://www.ciao.it/Monitor_CRT_206455_2-philips" class="subnr">Monitor CRT Philips</a> <span class="subnr">(120)</span></dd><dd> <a href="http://www.ciao.it/Monitor_CRT_206455_2-hp" class="subnr">Monitor CRT HP</a> <span class="subnr">(41)</span></dd><dd> <a href="http://www.ciao.it/Monitor_CRT_206455_2-samsung" class="subnr">Monitor CRT Samsung</a> <span class="subnr">(80)</span></dd><dd> <a href="http://www.ciao.it/Monitor_CRT_206455_2-ibm" class="subnr">Monitor CRT IBM</a> <span class="subnr">(67)</span></dd><dd> <a href="http://www.ciao.it/Monitor_CRT_206455_2-compaq" class="subnr">Monitor CRT Compaq</a> <span class="subnr">(61)</span></dd><dd> <a href="http://www.ciao.it/Monitor_CRT_206455_2-nec" class="subnr">Monitor CRT NEC</a> <span class="subnr">(64)</span></dd></dl><dl class="subcatbox"><dt> <a href="http://www.ciao.it/Processori_206294_2" id="Node_Category_197039" class="hdl">Processori</a></dt><dd> <a href="http://www.ciao.it/Processori_206294_2-hewlett_packard" class="subnr">Processori HP</a> <span class="subnr">(379)</span></dd><dd> <a href="http://www.ciao.it/Processori_206294_2-intel" class="subnr">Processori Intel</a> <span class="subnr">(311)</span></dd><dd> <a href="http://www.ciao.it/Processori_206294_2-ibm" class="subnr">Processori IBM</a> <span class="subnr">(141)</span></dd><dd> <a href="http://www.ciao.it/Processori_206294_2-fujitsu_siemens_computers" class="subnr">Processori Fujitsu Siemens</a> <span class="subnr">(43)</span></dd><dd> <a href="http://www.ciao.it/Processori_206294_2-compaq" class="subnr">Processori Compaq</a> <span class="subnr">(14)</span></dd><dd> <a href="http://www.ciao.it/Processori_206294_2-acer" class="subnr">Processori Acer</a> <span class="subnr">(24)</span></dd></dl> <!-- end of sample code from ciao.it--> </div> <div class="yui-u"> <!-- sample code from ciao.it--> <dl class="subcatbox"><dt> <a href="http://www.ciao.it/Componenti_di_Rete_178049_2" id="Node_Category_168462" class="hdl">Componenti di Rete</a></dt><dd> <a href="http://www.ciao.it/Modem_178051_3" class="subnr">Modem</a> <span class="subnr">(1428)</span></dd><dd> <a href="http://www.ciao.it/Schede_di_Rete_178050_3" class="subnr">Schede di Rete</a> <span class="subnr">(3191)</span></dd><dd> <a href="http://www.ciao.it/Router_e_Bridge_178053_3" class="subnr">Router e Bridge</a> <span class="subnr">(1176)</span></dd><dd> <a href="http://www.ciao.it/Hub_e_Switch_178052_3" class="subnr">Hub e Switch</a> <span class="subnr">(2739)</span></dd><dd> <a href="http://www.ciao.it/Dispositivi_di_Rete_205570_3" class="subnr">Dispositivi di Rete</a> <span class="subnr">(1791)</span></dd><dd> <a href="http://www.ciao.it/Componenti_di_Rete_178049_2" id="Node_Category_More_168462" class="hdl">continua</a></dd></dl><dl class="subcatbox"><dt> <a href="http://www.ciao.it/Palmari_Smartphone_206480_2" id="Node_Category_197255" class="hdl">Palmari & Smartphone</a></dt><dd> <a href="http://www.ciao.it/Palmari_Smartphone_206480_2-htc" class="subnr">Palmari HTC</a> <span class="subnr">(26)</span></dd><dd> <a href="http://www.ciao.it/Palmari_Smartphone_206480_2-nokia" class="subnr">Palmari Nokia</a> <span class="subnr">(22)</span></dd><dd> <a href="http://www.ciao.it/Palmari_Smartphone_206480_2-hp" class="subnr">Palmari HP</a> <span class="subnr">(85)</span></dd><dd> <a href="http://www.ciao.it/Palmari_Smartphone_206480_2-i_mate" class="subnr">Palmari i-mate</a> <span class="subnr">(19)</span></dd><dd> <a href="http://www.ciao.it/Palmari_Smartphone_206480_2-samsung" class="subnr">Palmari Samsung</a> <span class="subnr">(10)</span></dd><dd> <a href="http://www.ciao.it/Palmari_Smartphone_206480_2-palm" class="subnr">Palmari Palm</a> <span class="subnr">(89)</span></dd></dl> <dd> <a href="http://www.ciao.it/Mouse_178035_3" class="subnr">Mouse</a> <span class="subnr">(3589)</span></dd><dd> <a href="http://www.ciao.it/Tastiere_178036_3" class="subnr">Tastiere</a> <span class="subnr">(2826)</span></dd><dd> <a href="http://www.ciao.it/Scanner_178040_3" class="subnr">Scanner</a> <span class="subnr">(879)</span></dd><dd> <a href="http://www.ciao.it/Webcam_206484_3" class="subnr">Webcam</a> <span class="subnr">(578)</span></dd><dd> <a href="http://www.ciao.it/USB_Flash_Drive_205463_3" class="subnr">USB Flash Drive</a> <span class="subnr">(1086)</span></dd><dd> <a href="http://www.ciao.it/Periferiche_178035_2" id="Node_Category_More_168461" class="hdl">continua</a></dd></dl><dl class="subcatbox"><dt> <a href="http://www.ciao.it/Storage_Media_178080_2" id="Node_Category_168465" class="hdl">Storage Media</a></dt><dd> <a href="http://www.ciao.it/CD_Registrabili_178080_3" class="subnr">CD Registrabili</a> <span class="subnr">(2340)</span></dd><dd> <a href="http://www.ciao.it/DVD_Registrabili_178081_3" class="subnr">DVD Registrabili</a> <span class="subnr">(2490)</span></dd></dl><dl class="subcatbox"><dt> <a href="http://www.ciao.it/Accessori_178161_2" id="Node_Category_168466" class="hdl">Accessori</a></dt><dd> <a href="http://www.ciao.it/Supporti_Cartacei_per_Stampanti_205643_3" class="subnr">Supporti Cartacei per Stampanti</a> <span class="subnr">(1891)</span></dd><dd> <a href="http://www.ciao.it/Accessori_per_Stampanti_205472_3" class="subnr">Accessori per Stampanti</a> <span class="subnr">(20111)</span></dd><dd> <a href="http://www.ciao.it/Cartucce_per_Stampanti_e_Toner_206282_3" class="subnr">Cartucce per Stampanti e Toner</a></dd><dd> <a href="http://www.ciao.it/Accessori_per_Portatili_197962_3" class="subnr">Accessori per Portatili</a> <span class="subnr">(42)</span></dd><dd> <a href="http://www.ciao.it/Accessori_per_Palmari_178161_3" class="subnr">Accessori per Palmari</a> <span class="subnr">(41)</span></dd><dd> <a href="http://www.ciao.it/Accessori_178161_2" id="Node_Category_More_168466" class="hdl">continua</a></dd></dl><dl class="subcatbox"><dt> <a href="http://www.ciao.it/Servizi_e_Consigli_178181_2" id="Node_Category_168467" class="hdl">Servizi e Consigli</a></dt></dl> <!-- end of sample code from ciao.it--> </div> </div> </div> <div> <div class="subtab_list"> <ul class=""> <li><a href="#tab1"><em>Attive ora</em></a></li> <li><a href="#tab1"><em>Programmate</em></a></li> <li class="selected"><a href="#tab1"><em>Calendario</em></a></li> </ul> </div> ' . Get::img(Get::rel_path('base') . '/calendar.jpg', false, false, false, true) . ' </div> ', 'content'); cout('</div>', 'content'); cout('</div>', 'content'); cout('' . '<script type="text/javascript">' . "\n" . "\tvar myTabs = new YAHOO.widget.TabView('course_tag'); " . "\n" . '</script>' . "\n", 'scripts'); /* cout('<script type="text/javascript"> var temp; YAHOO.util.Event.onDOMReady(function(e) { var oConfig = { dragdrop: false, initNodes: '.$nodes.', ajax_url: "ajax.adm_server.php?plf=framework&file=category_tree&sf=folder_tree'.'" }; temp = new FolderTree("tree", oConfig); }); </script>', 'page_head'); cout('<div class="area_block">PROVA ALBERO</div>', 'content'); cout('<div class="std_block">', 'content'); cout('<div style="border:solid 1px" class="folder_tree">', 'content'); cout('<div id="tree"></div>', 'content'); cout('</div>', 'content'); cout('<br /><br />DEBUG: <button onclick="alert(temp.getCurrentSelection());">SELEZIONE</button>', 'content'); cout('</div>', 'content'); require_once(_lms_.'/lib/folder_tree/class.category_tree.php'); $tree = new CategoryTree('categorytree'); $tree->initLibraries(); $tree->useDOMready = true; $temp = $tree->get(); cout($temp['js'], 'page_head'); cout('<div class="area_block">PROVA ALBERO</div>', 'content'); cout('<div class="std_block">', 'content'); cout('<div style="border:solid 1px" class="folder_tree">', 'content'); cout($temp['html'], 'content'); cout('</div>', 'content'); cout('<br /><br />DEBUG: <button onclick="alert(temp.getCurrentSelection());">SELEZIONE</button>', 'content'); cout('</div>', 'content'); */ break; } }
<?php /** * Created by PhpStorm. * User: Ute * Date: 11/28/2015 * Time: 8:37 PM */ require_once "models/plant.class.php"; require_once "models/plant_manager.class.php"; require_once "classes/db.interface.php"; require_once "classes/db.class.php"; require_once "models/exportResultsToCSV.php"; if (isset($_GET['Export'])) { $PlantManager = new PlantManager(); $plants = $PlantManager->getAllPlantsAsMSQLiObjects(); $exporter = new DataExport(); $exporter->toCSV($plants); } else { if (isset($_GET['Exit'])) { session_destroy(); print "<script type='text/javascript'>window.close();</script>"; } }
/** * @param $table_name string * @param $lang * @param $app_title string * @param $userid string * @param $user_rights * @param $chkd_fields string * @param $parent_chkd_flds * @param $project_id * @param $export_file_name * @param $debug */ function create_cdisc_download($table_name, $lang, $app_title, $userid, $user_rights, $chkd_fields, $parent_chkd_flds, $project_id, $export_file_name, $debug) { $data_row = array(); $table_csv = ""; $export_result = db_query("SELECT * FROM `$table_name`"); if ($export_result) { while ($export_row = db_fetch_assoc($export_result)) { foreach ($export_row AS $export_key => $export_value) { $data_row[strtoupper($export_key)] = fix_null_sas($export_value); } $row_csv = implode(',', $data_row) . "\n"; $table_csv .= $row_csv; } db_free_result($export_result); } /** * when are we? */ //$today = date("Y-m-d_Hi"); /** * Creates the data comma separated value file WITH header */ // File names, comments $projTitleShort = substr(str_replace(" ", "", ucwords(preg_replace("/[^a-zA-Z0-9 ]/", "", html_entity_decode($app_title, ENT_QUOTES)))), 0, 20); $data_file_name_WH = $export_file_name . ".csv"; $today = date("Y-m-d-H-i-s"); $docs_comment_WH = "CDISC $export_file_name domain data file created by $userid on $today."; /** * setup values for value export logging */ $headers = implode(',', array_keys($data_row)) . "\n"; /** * turn on/off exporting */ if ($user_rights['data_export_tool'] && !$debug) { $table_csv = addBOMtoUTF8($headers . $table_csv); $docs_size = strlen($table_csv); $export_sql = "INSERT INTO redcap_docs (project_id,docs_name,docs_file,docs_date,docs_size,docs_comment,docs_type,docs_rights,export_file) " . "VALUES ($project_id, '" . $data_file_name_WH . "', NULL, '" . TODAY . "','$docs_size','" . $docs_comment_WH . "','application/csv', NULL ,0)"; if (!db_query($export_sql)) { $is_export_error = true; } else { /** * Store the file in the file system */ if (!DataExport::storeExportFile($data_file_name_WH, $table_csv, db_insert_id(), $docs_size)) { $is_export_error = true; } else { log_event("", "redcap_data", "data_export", "", str_replace("'", "", $chkd_fields) . (($parent_chkd_flds == "") ? "" : ", " . str_replace("'", "", $parent_chkd_flds)), "Export data"); } } unset($table_csv); $csv_img = "download_csvdata.gif"; $csvexcel_img = "download_csvexcel_raw.gif"; $csvexcellabels_img = "download_csvexcel_labels.gif"; /** * since we're not allowing download of csv headers only, we're going to reset the message shown in the export dialog * and reset it later to the original value */ $temp_data_export_tool_118 = $lang['data_export_tool_118']; $lang['data_export_tool_118'] = "You may download the CDISC $table_name data in CSV (comma-separated) format, which can be opened in Excel."; // Need docs_id from this operation to automatically build link $docsql = "SELECT docs_id FROM redcap_docs WHERE project_id = $project_id ORDER BY docs_id DESC LIMIT 1"; $new_id = db_result(db_query($docsql), 0) - 1; /** * print table header */ print "<h1>Export Data</h1>"; print "<div style='max-width:700px;'>"; print "<table style='border: 1px solid #DODODO; border-collapse: collapse; width: 100%'> <tr class='grp2'> <td colspan='2' style='font-family:Verdana;font-size:12px;text-align:left;'> <!--<a href='javascript:void(0)' onclick='window.print();' title='Print this page'>Print Report</a>--></td> <td style='font-family:Verdana;font-size:12px;text-align:center;'> {$lang['docs_58']}<br>{$lang['data_export_tool_51']} </td> </tr>"; /** * print csv export selection */ print '<tr class="odd"> <td valign="top" style="text-align:center;width:60px;padding-top:10px;border:0px;border-left:1px solid #D0D0D0;"> <img src="' . APP_PATH_IMAGES . 'excelicon.gif" title="' . $lang['data_export_tool_15'] . '" alt="' . $lang['data_export_tool_15'] . '" /> </td> <td style="font-family:Verdana;font-size:11px;padding:10px;" valign="top"> <b>' . $lang['data_export_tool_15'] . '</b><br> ' . $lang['data_export_tool_118'] . '<br><br> <i>' . $lang['global_02'] . ': ' . $lang['data_export_tool_17'] . '</i> </td> <td valign="top" style="text-align:center;width:100px;padding-top:10px;"> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . ($new_id + 1) . '"> <img src="' . APP_PATH_IMAGES . $csvexcellabels_img . '" title="' . $lang['data_export_tool_60'] . '" alt="' . $lang['data_export_tool_60'] . '"></a> <div style="text-align:left;padding:5px 0 1px;"> <div style="line-height:5px;"> <img src="' . APP_PATH_IMAGES . 'mail_small.png" style="position: relative; top: 5px;"><a href="javascript:;" style="color:#666;font-size:10px;text-decoration:underline;" onclick=\'$("#sendit_' . ($new_id - 1) . '").toggle("blind",{},"fast");\'>' . $lang['data_export_tool_66'] . '</a> </div> <div id="sendit_' . ($new_id - 1) . '" style="display:none;padding:4px 0 4px 6px;"> <div> • <a href="javascript:;" onclick="popupSendIt(' . ($new_id + 1) . ',2);" style="font-size:10px;">' . $lang['data_export_tool_120'] . '</a> </div> <div> • <a href="javascript:;" onclick="popupSendIt(' . ($new_id - 1) . ',2);" style="font-size:10px;">' . $lang['data_export_tool_119'] . '</a> </div> </div> </div> </td> </tr>'; /** * print table footer */ print '</table>'; print '</div>'; $lang['data_export_tool_118'] = $temp_data_export_tool_118; } }