PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/da_catalog_editPI.php

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