PageRenderTime 56ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/da_catalog_inputDatasetRecord.php

https://github.com/jmjamison/da_catalog_maintenance
PHP | 315 lines | 198 code | 92 blank | 25 comment | 32 complexity | d9ba39d29c3e9dac389883001976d3cb MD5 | raw file
  1. <html>
  2. <head><title>Data Archive Catalog: Input Dataset Record</title>
  3. <link rel="stylesheet" href="2col_leftNav.css" type="text/css">
  4. </head>
  5. <body>
  6. <?php
  7. $sscnetHTTP = "http://www.sscnet.ucla.edu/issr/da/da_catalog/";
  8. $sscnetHTTP_maintenance_test = "http://www.sscnet.ucla.edu/issr/da/da_catalog_maintenance_test/";
  9. $sscnetHTTP_maintenance_live = "http://www.sscnet.ucla.edu/issr/da/da_catalog_maintenance/";
  10. $mydestopHTTP = "http://localhost/da_catalog/";
  11. $currentHTTP = $sscnetHTTP_maintenance_live;
  12. if (isset($_SESSION['studynumber']))
  13. $studynumber = $_SESSION['studynumber'];
  14. else
  15. $studynumber = "";
  16. echo "studynumber: " . $studynumber . "<br>";
  17. if (isset($_SESSION['studypart']))
  18. $studypart = $_SESSION['studypart'];
  19. else
  20. $studypart = "";
  21. if (isset($_SESSION['dsname']))
  22. $dsname = $_SESSION['dsname'];
  23. else
  24. $dsname = "";
  25. echo "dsname = " . $dsname . "<br>";
  26. if (isset($_SESSION['filetype']))
  27. $filetype = $_SESSION['filetype'];
  28. else
  29. $filetype = "";
  30. if (isset($_SESSION['filesize']))
  31. $filesize = $_SESSION['filesize'];
  32. else
  33. $filesize = "";
  34. if (isset($_SESSION['note']))
  35. $note = $_SESSION['note'];
  36. else
  37. $note = "";
  38. // original dtafile
  39. if (isset($_SESSION['dtafile']))
  40. $dtafile = $_SESSION['dtafile'];
  41. else
  42. $dtafile = "";
  43. //was dtafile
  44. if (isset($_SESSION['dtafilename']))
  45. $dtafilename = $_SESSION['dtafilename'];
  46. else
  47. $dtafilename = "";
  48. if (isset($_SESSION['wwwtext']))
  49. $wwwtest = $_SESSION['wwwtext'];
  50. else
  51. $wwwtext = "";
  52. if (isset($_SESSION['wwwlink']))
  53. $wwwlink = $_SESSION['wwwlink'];
  54. else
  55. $wwwlink = "";
  56. if (isset($_SESSION['alttype']))
  57. $alttype = $_SESSION['alttype'];
  58. else
  59. $alttype = "";
  60. if (isset($_SESSION['altsnum']))
  61. $altsnum = $_SESSION['altsnum'];
  62. else
  63. $altsnum = "";
  64. if (isset($_SESSION['gzsize']))
  65. $gzsize = $_SESSION['gzsize'];
  66. else
  67. $gzsize = "";
  68. if (isset($_SESSION['studypart']))
  69. $studypart = $_SESSION['studypart'];
  70. else
  71. $studypart = "";
  72. if (isset($_SESSION['cite_text']))
  73. $cite_text = $_SESSION['cite_text'];
  74. else
  75. $cite_text = "";
  76. $reclen = ""; // used for tape files, not currently set
  77. //$cite = $citenum . $studypart;
  78. $sscnetInclude = "ISSRDA_login.php";
  79. $currentInclude = $sscnetInclude;
  80. include($currentInclude);
  81. // for desktop test system
  82. //$db_name = "da_catalog";
  83. $queryTitleStudyNumFileType = "SELECT title.StudyNum, fileinfo.FileType, fileinfo.dtafile, fileinfo.dtafilename FROM title LEFT JOIN fileinfo ON title.StudyNum = fileinfo.StudyNum ORDER BY title.StudyNum";
  84. // PDO connect
  85. $PDO_string = "mysql:host=" . $db_host . ";port=" . $db_port . ";dbname=" . $db_name ;
  86. try {
  87. $PDO_connection = new PDO($PDO_string, $db_username, $db_password);
  88. } catch(PDOException $e) {
  89. echo "Could not connect to the database because: ". $e->getMessage()."<br>";
  90. die();
  91. }
  92. // PDO - create prepared statement: get the table.pifull
  93. // --------------------------------------------------------
  94. $PDO_query = $PDO_connection->prepare($queryTitleStudyNumFileType);
  95. // PDO - execute the query
  96. $result = $PDO_query->execute();
  97. if (!$result) {
  98. die ("Could not query the database: <br />". mysql_error());
  99. }
  100. $fileTypeList = array();
  101. $studynumberList = array();
  102. $titleList = array();
  103. $dtafileList = array();
  104. $result = $PDO_query->fetch(PDO::FETCH_ASSOC);
  105. $row_index = 0;
  106. while ($row = $PDO_query->fetch(PDO::FETCH_ASSOC)) {
  107. $studynumberList[$row_index] = $row["StudyNum"];
  108. if (!is_null($row["FileType"])) { $fileTypeList[$row_index] = $row["FileType"]; } // others won't have nulls
  109. $dtafileList[$row_index] = $row["dtafile"];
  110. $row_index++;
  111. }
  112. $fileTypeList = array_unique($fileTypeList);
  113. sort($fileTypeList);
  114. $fileTypeTotal = count($fileTypeList);
  115. $dtafileList = array_unique($dtafileList);
  116. sort($dtafileList);
  117. $studynumberList = array_unique($studynumberList);
  118. sort($studynumberList);
  119. $studynumberListTotal = count($studynumberList);
  120. $fileTypeListText = implode("','", $fileTypeList);
  121. $fileTypeListText = "'" . $fileTypeListText . "'";
  122. ?>
  123. <script type="text/javascript">
  124. var counter = 0;
  125. function addNewFileTypeEntry(arg1, arg2) {
  126. // element containing the new file type entry
  127. var currentEntryID = arg1;
  128. alert(currentEntryID);
  129. var currentEntryName = document.getElementById(currentEntryID).name;
  130. alert("new entry form name: " + currentEntryID);
  131. var newText = document.getElementById(currentEntryID).value;
  132. //alert("Add this file type: " + newText);
  133. // element containt the old file type list
  134. var oldSelectBoxID = arg2;
  135. alert(oldSelectBoxID);
  136. var oldSelectBoxName = document.getElementById(oldSelectBoxID).name;
  137. //alert("old select box name: " + oldSelectBoxName);
  138. var fileTypeList = new Array(<?php echo $fileTypeListText; ?>);
  139. var fileListTotal = fileTypeList.length;
  140. //alert("Current total items: " + fileListTotal);
  141. document.getElementById(oldSelectBoxID).innerHTML = "";
  142. // write in the new, added file type first, the re-add the original filetype list
  143. var newOption = document.createElement("option");
  144. newOption.value = newText;
  145. newOption.text = newText;
  146. document.getElementById(oldSelectBoxID).appendChild(newOption);
  147. for (i = 0; i < fileListTotal; i++) {
  148. var newOption = document.createElement("option");
  149. newOption.value = fileTypeList[i];
  150. newOption.text = fileTypeList[i];
  151. document.getElementById(oldSelectBoxID).appendChild(newOption);
  152. } // end of for-loop rewrite the option list
  153. } // end addNewFileType
  154. </script>
  155. <div id="masthead">
  156. <h1 id="siteName">UCLA Institute for Social Research Data Archives</h1>
  157. <h2 id="siteName"><a href="index.php" target="_self">Maintenance Menu</a>&nbsp;/&nbsp;Input Dataset Record</h2>
  158. </div> <!--end masthead--><!--end masthead-->
  159. <div style="margin: 1% 5% 2% 2%;line-height: 1.5; ">
  160. <form method="post" name="addRecord" action="da_catalog_insertDatasetRecordCheck.php">
  161. Studynumber:
  162. <?php
  163. echo '<select name="studynumber" id="studynumber"';
  164. echo '<option value="">choose studynumber</option>';
  165. foreach ($studynumberList as $key => $value) {
  166. echo '<option value="' . $value . '">' . $value;
  167. }
  168. echo '</select>';
  169. ?>
  170. Pick Base Record/Study number to add dataset(s) to.
  171. <hr align="center" width="100%" size="1">
  172. <div id="dynamicInput">
  173. <p>
  174. <?php // NOTE: the studypart variable is used to sort the various datasets in order, so start with #1 ?>
  175. <input name="studypart" type="hidden" value="1" /> dataset name: <input type="text" name="dsname">
  176. Filetype:&nbsp;<select name="filetype" id="dropdownList0">
  177. <?php
  178. foreach ($fileTypeList as $key => $value) {
  179. echo '<option value="' . $value . '">' . $value;
  180. }
  181. ?>
  182. </select>
  183. <label> file type NOT LISTED:
  184. <input name='newfiletype' type='text' id="newFileTypeEntry0">
  185. </label>
  186. <input name="addNewFileType" type="button" onClick="addNewFileTypeEntry('newFileTypeEntry0', 'dropdownList0')" value="Add New File Type">
  187. <br><br>
  188. file size:<input type="text" name="filesize" id="fooTest">
  189. <?php // NOTE: DTAfile number is a legacy variable, originally based on a combination of tape# + file#,
  190. // later it was generated as 999 + nnnn, just add 1 to the last number generated. 14.Oct.2009 jmj
  191. // This creates an incremented DTAfile number.
  192. //$foo = end($dtafileList);
  193. // $datfilePieces = explode("file", $foo);
  194. //echo " " . end($datfilePieces);
  195. // used below in the dtafile_new field
  196. //$endpart = end($datfilePieces);
  197. // echo "DTA999.file" . ($endpart + 1);
  198. ?>
  199. note: <input type="text" name="note" id="fooTest02"> Dtafile:
  200. <input name="dtafile_new" type="text" value="<?php echo end($dtafileList) + 1; ?>">
  201. The last dtafile number added was:
  202. <strong><?php echo end($dtafileList); ?></strong><br>
  203. wwwlink description: <input name="wwwtext" type="text" size="50" maxlength="255">
  204. wwwlink: http://<input name="wwwlink" type="text" size="50" maxlength="255"> <br>
  205. Title link from other source, example - 'ICPSR': <input type="text" name="alttype">
  206. Alternate studynumber from other source:
  207. <input type="text" name="altsnum">
  208. <input type="hidden" name="gzsize" value=""><br>file level citation: <input type="text" name="cite_text" size="100" maxlength="500">
  209. <br><br><input name="reset form" type="reset" value="reset">
  210. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  211. <input type="button" onClick="history.go(0)" value="Reload page">
  212. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  213. <input type="submit" name="searchStudynumber" id="searchStudynumber" value="Add Dataset to this Studynumber">
  214. </p>
  215. </div>
  216. </form>
  217. <?php
  218. // close the connection
  219. // mysql_close($connection);
  220. $PDO_connection = null;
  221. ?>
  222. </div> <!-- end content-->
  223. </body></html>