PageRenderTime 50ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/Prohits/analyst/submit_sample_gel_free.inc.php

http://prohits.googlecode.com/
PHP | 386 lines | 331 code | 12 blank | 43 comment | 8 complexity | 1d39449a6897c21017cea7c28a090e1b MD5 | raw file
  1. <?
  2. /***********************************************************************
  3. Copyright 2010 Gingras and Tyers labs,
  4. Samuel Lunenfeld Research Institute, Mount Sinai Hospital.
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. *************************************************************************/
  15. require("classes/band_class.php");
  16. require("classes/bait_class.php");
  17. require("classes/experiment_class.php");
  18. //-----band_color.inc.php
  19. $intensity_name = array();
  20. /*echo "<pre>";
  21. print_r($request_arr);
  22. echo "</pre>";*/
  23. /*
  24. echo "Bait_ID: $Bait_ID<br>";
  25. echo "Gel_ID: $Gel_ID<br>";
  26. echo "Exp_ID: $Exp_ID<br>";
  27. echo "Lane_ID: $Lane_ID<br>";
  28. echo "Band_ID: $Band_ID<br>";
  29. echo "theaction: $theaction<br>";
  30. */
  31. //theaction = "addnew" -- form to add new gel lane and bands
  32. //theaction = "insert" -- insert into gel lane and band table, change theaction to "viewband"
  33. //theaction = "viewband" -- display gel lane with bands
  34. //theaction = "addnewband" -- display gel lane with bands, add on line band form
  35. //theaction = "insetnewband" -- insert the new band into band table
  36. //theaction = "deleteband" -- delete one band then change theaction to "viewband"
  37. //theaction = "modifyband" -- display band form.
  38. //theaction = "updateband" -- update bane then change theaction to "viewband"
  39. //theaction = "modifylane" -- display form to modify gel lane
  40. //theaction = "updatelane" -- update gel lane change thecation to "viewband"
  41. //theaction = "deletelane" -- delete the gel lane if it hasn't set to plate well then change theaction to "andnew"
  42. //$TB_CELL_COLOR = "#e3e3e3";
  43. //$TB_CELL_COLOR = "yellow";
  44. //=======================================
  45. $Band = new Band();
  46. $Exp = new Experiment();
  47. $Bait = new Bait();
  48. $ExpOwner = '';
  49. $Log = new Log();
  50. if($Band_ID){
  51. $Band->fetch($Band_ID);
  52. $Exp_ID = $Band->ExpID;
  53. }
  54. if($Exp_ID){
  55. $Exp->fetch($Exp_ID);
  56. $Bait_ID = $Exp->BaitID;
  57. $ExpOwner = get_userName($HITSDB, $Exp->OwnerID);
  58. }
  59. if($Bait_ID){
  60. $Bait->fetch($Bait_ID);
  61. }
  62. if(!$Exp_ID){
  63. echo "<script language=javascript>document.location.href='noaccess.html';</script>";
  64. exit;
  65. }
  66. $Bands = new Band();
  67. $Band_passed_ID = '';
  68. $close_window = '';
  69. if($theaction == "deleteband" AND $Band_ID AND $AUTH->Delete ){
  70. //-------------------------------------------------------------
  71. if($AUTH->isOwner('Band', $Band_ID,$AccessUserID) ){
  72. $SQL = "SELECT ID FROM Hits WHERE BandID = '$Band_ID'";
  73. if(mysql_num_rows(mysql_query($SQL))){
  74. return "Error: You can't delete the Band since it has hits.";
  75. }else{
  76. $SQL = "DELETE FROM Band WHERE ID = '$Band_ID'";
  77. $ret = $HITSDB->execute($SQL);
  78. if($ret){
  79. $Desc = "";
  80. $Log->insert($AccessUserID,'Band',$Band_ID,'delete',$Desc,$AccessProjectID);
  81. }
  82. }
  83. }
  84. }else if($theaction == "updateband" and $AUTH->Modify){
  85. $theBand = new Band($Band_ID);
  86. if($AccessProjectID){
  87. $frm_Location = preg_replace("/[^A-Za-z0-9._-]/",'',$frm_Location);
  88. //$frm_Location = mysql_real_escape_string(trim($frm_Location));
  89. $error_msg = $theBand->update($Band_ID,$frm_BandMW,$frm_Intensity,$frm_Location,$frm_Modification,$frm_Description);
  90. if(!$msg){
  91. //add record into Log table
  92. $Desc = "BandCode=".$frm_Location.",MW=".$frm_BandMW.",Intesity=".$frm_Intensity.",Description=".$frm_Description;
  93. $Log->insert($AccessUserID,'Band',$Band_ID,'modify',$Desc,$AccessProjectID);
  94. //end of Log table
  95. }
  96. }else{
  97. $error_msg ="<font color=red> You have no permission to modify this band info!</font>";
  98. }
  99. }else if($theaction == "insertband" and $AUTH->Insert){
  100. $newBand = new Band($Band_ID);
  101. if($AccessProjectID){
  102. $frm_Location = preg_replace("/[^A-Za-z0-9_-]/",'',$frm_Location);
  103. //$frm_Location = mysql_real_escape_string(trim($frm_Location));
  104. $newBand->insert($Exp_ID,$Lane_ID,$Bait_ID,$Bait->BaitMW,$frm_BandMW,$frm_Intensity,$frm_Location,$frm_Modification,$frm_Description, $AccessUserID,$Exp->ProjectID, $Plate_ID);
  105. $Band_passed_ID = $newBand->ID;
  106. $Desc = "ExpID=$Exp_ID,LaneID=$Lane_ID,BandCode=".$frm_Location.",MW=".$frm_BandMW.",Intesity=".$frm_Intensity.",Description=".$frm_Description;
  107. $Log->insert($AccessUserID,'Band',$newBand->ID,'insert',$Desc,$AccessProjectID);
  108. $close_window = 'close';
  109. }
  110. }
  111. ?>
  112. <script language="javascript">
  113. function goto_band(){
  114. theForm = document.action_form;
  115. theForm.action = "band.php"
  116. theForm.theaction.value = "new";
  117. theForm.submit();
  118. }
  119. function add_band(){
  120. theForm = document.action_form;
  121. theForm.theaction.value = "addband";
  122. theForm.submit();
  123. }
  124. function uncheckradio(theradio){
  125. for (var i=0; i < theradio.length; i++) {
  126. theradio[i].checked = false;
  127. }
  128. }
  129. function add_one_band(){
  130. //for add one more band
  131. document.band_form.theaction.value = "addnewband";
  132. document.band_form.submit();
  133. }
  134. function confirm_delete_band(Band_ID){
  135. if(confirm("Are you sure that you want to delete the Band?")){
  136. document.action_form.Band_ID.value = Band_ID;
  137. document.action_form.theaction.value = "deleteband";
  138. document.action_form.submit();
  139. }
  140. }
  141. function radio_checked(radio_array){
  142. var is_checked = false;
  143. for(var i=0; i < radio_array.length; i++){
  144. if(radio_array[i].checked == true){
  145. is_checked = true;
  146. }
  147. }
  148. return is_checked;
  149. }
  150. function isNumber(str) {
  151. for(var position=0; position<str.length; position++){
  152. var chr = str.charAt(position)
  153. if ( ( (chr < "0") || (chr > "9") ) && chr != ".")
  154. return false;
  155. };
  156. return true;
  157. }
  158. function isEmptyStr(str){
  159. var str = this != window? this : str;
  160. var temstr = str.replace(/^\s+/g, '').replace(/\s+$/g, '');
  161. if(temstr == 0 || temstr == ''){
  162. return true;
  163. } else {
  164. return false;
  165. }
  166. }
  167. function trimString (str) {
  168. var str = this != window? this : str;
  169. return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
  170. }
  171. </script>
  172. <table border="0" cellpadding="0" cellspacing="0" width="95%" >
  173. <tr>
  174. <td colspan=2 height=1 bgcolor="black"><img src="./images/pixel.gif"></td>
  175. </tr>
  176. <tr>
  177. <td align="center" colspan=2>
  178. <table align="center" cellspacing="0" cellpadding="0" border="0" width=740>
  179. <tr>
  180. <td colspan=3><br>
  181. </td>
  182. </tr>
  183. <tr>
  184. <td valign=top align=left>
  185. <table cellspacing="1" cellpadding="0" border="0" width=355>
  186. <tr>
  187. <td colspan="2" bgcolor="<?echo $TB_HD_COLOR;?>" height="20">
  188. <div class=tableheader><b>&nbsp;Bait ID (<?echo $Bait_ID;?>)&nbsp;&nbsp; Experiment ( <?echo $Exp_ID;?> )</b></div></td>
  189. </tr>
  190. <?if($Bait->Clone == "dummy"){?>
  191. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  192. <td width=40%><div class=maintext>&nbsp;</div></td>
  193. <td width=60% rowspan=4 align=center>
  194. <div class=maintext><font face="Arial" size="5" color=#ffffff>No Bait</font>&nbsp;&nbsp;
  195. <?echo $Bait->GeneName;?></div>
  196. </td>
  197. </tr>
  198. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  199. <td><div class=maintext><b>&nbsp;</td>
  200. </tr>
  201. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  202. <td><div class=maintext><b>&nbsp;</div></td>
  203. </tr>
  204. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  205. <td><div class=maintext><b>&nbsp;</div></td>
  206. </tr>
  207. <?}else{?>
  208. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  209. <td><div class=maintext><b>&nbsp;Gene ID:</b></td>
  210. <td><div class=maintext>&nbsp;<?echo $Bait->GeneID;?></div></td>
  211. </tr>
  212. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  213. <td width=40%><div class=maintext><b>&nbsp;LocusTag/GeneName</b>:</div></td>
  214. <td width=60%><div class=maintext>&nbsp;<?echo $Bait->LocusTag." <b>/</b> ".$Bait->GeneName;?></div></td>
  215. </tr>
  216. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  217. <td><div class=maintext><b>&nbsp;Bait MW:</b></td>
  218. <td><div class=maintext>&nbsp;<?echo ($Bait->BaitMW != 0)?$Bait->BaitMW." kDa":"";?></div></td>
  219. </tr>
  220. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  221. <td><div class=maintext><b>&nbsp;Clone Number:</b></div></td>
  222. <td><div class=maintext>&nbsp;<?echo $Bait->Clone;?></div></td>
  223. </tr>
  224. <?}?>
  225. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  226. <td><div class=maintext>&nbsp;<b>Exp. Name:</b></div></td>
  227. <td><div class=maintext>&nbsp;<?echo $Exp->Name;?></div></td>
  228. </tr>
  229. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  230. <td><div class=maintext>&nbsp;<b>Created by:</div></td>
  231. <td><div class=maintext>&nbsp;<?echo $ExpOwner .' ' . $Exp->DateTime;?></div></td>
  232. </tr>
  233. </table>
  234. </td>
  235. <td>&nbsp; &nbsp;</td>
  236. <td valign=top align=right>
  237. <table cellspacing="1" cellpadding="0" border="0" width=355>
  238. <tr>
  239. <td colspan="2" bgcolor="<?echo $TB_HD_COLOR;?>" height="20">
  240. <div class=tableheader>&nbsp;<b>Gel ( <?echo $Gel_ID;?> )</b></div></td>
  241. </tr>
  242. <?if(!$Gel_ID){?>
  243. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  244. <td width=40%><div class=maintext>&nbsp;<b>Gel Name:</td>
  245. <td width=60% rowspan=6 align=center>
  246. <div class=maintext><font face="Arial" size="5" color=#ffffff>Gel Free</font>&nbsp;&nbsp;
  247. <?echo $Bait->GeneName;?></div>
  248. </td>
  249. </tr>
  250. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  251. <td><div class=maintext>&nbsp;<b>Gel Image:</b></div></td>
  252. </tr>
  253. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  254. <td><div class=maintext>&nbsp;<b>Method of Staining:</b></div></td>
  255. </tr>
  256. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  257. <td><div class=maintext>&nbsp;<b>Gel Type:</b></div></td>
  258. </tr>
  259. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  260. <td><div class=maintext>&nbsp;<b>Uploaded:</b></div></td>
  261. </tr>
  262. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  263. <td><div class=maintext>&nbsp;<b>Uploaded by:</div></td>
  264. </tr>
  265. <?}else{?>
  266. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  267. <td width=40%><div class=maintext>&nbsp;<b>Gel Name:</td>
  268. <td width=60%><div class=maintext>&nbsp;<?echo $Gel->Name;?></td>
  269. </tr>
  270. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  271. <td><div class=maintext>&nbsp;<b>Gel Image:</b></div></td>
  272. <td><div class=maintext>&nbsp;
  273. <?
  274. if($Gel->Image){
  275. echo "[<a href=\"javascript: view_image('" . $Gel->ID. "');\">";
  276. echo $Gel->Image;
  277. echo "</a>]";
  278. }
  279. ?>
  280. </div></td>
  281. </tr>
  282. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  283. <td><div class=maintext>&nbsp;<b>Method of Staining:</b></div></td>
  284. <td><div class=maintext>&nbsp;<?echo $Gel->Stain;?></div></td>
  285. </tr>
  286. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  287. <td><div class=maintext>&nbsp;<b>Gel Type:</b></div></td>
  288. <td><div class=maintext>&nbsp;<?echo $Gel->GelType;?></div></td>
  289. </tr>
  290. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  291. <td><div class=maintext>&nbsp;<b>Uploaded:</b></div></td>
  292. <td><div class=maintext>&nbsp;<?echo $Gel->DateTime;?></div></td>
  293. </tr>
  294. <tr bgcolor="<?echo $TB_CELL_COLOR;?>">
  295. <td><div class=maintext>&nbsp;<b>Uploaded by:</div></td>
  296. <td><div class=maintext>&nbsp;<?echo $GelOwner;?></div></td>
  297. </tr>
  298. <?}?>
  299. </table>
  300. </td>
  301. </tr>
  302. <tr>
  303. <td colspan="3" align=center valign=top><img src="./images/arrow_down.gif" border=0></td>
  304. </tr>
  305. <form name=action_form method=post action=<?echo $_SERVER['PHP_SELF'];?>>
  306. <input type=hidden name=theaction value='<?=$theaction;?>'>
  307. <input type=hidden name=Lane_ID value="<?echo $Lane_ID;?>">
  308. <input type=hidden name=Exp_ID value="<?echo $Exp_ID;?>">
  309. <input type=hidden name=Gel_ID value="<?=$Gel_ID;?>">
  310. <input type=hidden name=Bait_ID value="<?=$Bait_ID;?>">
  311. <input type=hidden name=Band_passed_ID value="<?=$Band_passed_ID;?>">
  312. <input type=hidden name=sub value=<?echo $sub;?>>
  313. <input type=hidden name=ProjectID value="<?=$ProjectID?>">
  314. <input type=hidden name=gelMode value="<?=$gelMode?>">
  315. <input type=hidden name=addNewType value="<?=$addNewType;?>">
  316. <input type=hidden name=selectedWellCode_str value=<?echo $selectedWellCode_str;?>>
  317. <input type=hidden name=Band_ID value=''>
  318. <input type=hidden name=close_window value="<?=$close_window?>">
  319. <input type=hidden name=DBname value=<?=$DBname;?>>
  320. <?
  321. $Bands = new Band();
  322. $Bands->fetch_band_inOneExp($Exp_ID);
  323. if(!$Bands->count && 0){
  324. ?>
  325. <tr bgcolor="" align="center">
  326. <td colspan="4" align="right">
  327. <div class=maintext>
  328. If you want to put the samples to plate click this button&nbsp;&nbsp;
  329. <input type="button" value=" Put Sample in Plate" onClick="javascript: goto_band();">
  330. </div>
  331. </td>
  332. </tr>
  333. <?}
  334. if($AUTH->Insert){?>
  335. <tr bgcolor="" align="center">
  336. <td colspan="4" align="right">
  337. <div class=maintext>
  338. <input type="button" value=" Add New Sample " onClick="javascript: add_band();">
  339. </div>
  340. </td>
  341. </tr>
  342. <?
  343. }
  344. $IdGeneName = $Bait->ID.$Bait->GeneName;
  345. ?>
  346. <tr>
  347. <td colspan="3" align=center>
  348. <?
  349. // end of display Experiment and Gel information -----------------------------------------------
  350. //-------------------------------------------------------------------------
  351. //get band list
  352. //if($Bands->count or $band_counter){
  353. include("plate_free_band_list.inc.php");
  354. //}
  355. //-----------------------------------------------------------------------------
  356. ?>
  357. </td>
  358. </tr>
  359. </form>
  360. </table>
  361. </td>
  362. </tr>
  363. </table><br>
  364. <?
  365. exit;
  366. ?>