Wednesday, February 5, 2014

Department database design (11) - manully add during import





C:\Users\jiansen\Desktop\CAS\jiansen_dir\www_cesei0_mobile\ubc_surgery_pub\scripts\manage\pubmedimport\index.php, line 237 add (for updating department list)
          if(strpos($existing['deptlist'], $chosendept)===false)
            mysql_query("UPDATE PUBLICATIONS SET deptlist='"
               . mysql_real_escape_string($existing['deptlist'] . "$chosendept,")
               . "' WHERE pubid=$existing[pubid] LIMIT 1", connectpubsdb());

line 206 add
      $puburldata=urlencode($choppeddata[0]);
        ?>
 <a class="txt-button" onclick="javascript:void window.open('insertpubmed.php?person=<?php print $chosenperson;  ?>&pubabstract=<?php print $puburldata;  ?>','child','width=900,height=500,resizable=false,left=0,top=0' );return false;">To add a new pubmed manually, please click this link and fill in its details</a>       
        <?php


new file
C:\Users\jiansen\Desktop\CAS\jiansen_dir\www_cesei0_mobile\ubc_surgery_pub\scripts\manage\pubmedimport\insertpubmed.php
<?php
session_start();
if(isset($_SESSION['username']))
$_SERVER['REMOTE_USER']='jiansen';
else{
echo 'You do not have adminsitraction right. <br />';
 echo "\n<p style='text-align:left;'>[<a href='../../../demosite/'>Back to publication homepage</a>]</p>";
exit();
}
require_once(dirname(dirname(__FILE__)) . '/common.php');
$person=$_GET['person'];
$pubabstract=$_GET['pubabstract'];
if($_POST['submitpub']){
        $person=$_POST['person'];
        $ret = array('reftype'=>array('JOUR'),
               'notes'=>array('Imported from PubMed ' . date('d/m/Y'))
               );
        $ret['url'] = 'pm:'.$_POST['pubmedid'];
        $ret['approvedby'] = mysql_real_escape_string($_SERVER['REMOTE_USER']);
        $date = date('Y-m-d H:i:s'); 
        $ret['approvaldate'] = "$date";
        $chosendept = getdivision($person);
        $ret['deptlist'] = ",$chosendept,";
        $ret['authorlist'] = $_POST['authorlist'];
        $ret['userlist'][] = ",$person,";
        $ret['authorlist']  = $_POST['authorlist'];
        $ret['title'] = $_POST['title'];
        $ret['journal'] = $_POST['ptitle'];
        $ret['year'] = $_POST['year'];
        $ret['yearother'] = $_POST['monthday'];
        $ret['volume'] = $_POST['volume'];
        $ret['issue'] = $_POST['issue'];
        $ret['startpage'] = $_POST['startpage'];
        $ret['endpage'] = $_POST['endpage'];
        $q = "SELECT pubid, url, deptlist, userlist FROM PUBLICATIONS WHERE url='" . mysql_real_escape_string($ret['url']) . "' LIMIT 1";
        $res = mysql_query($q,connectpubsdb());
        if($res && (mysql_num_rows($res)!=0)){
          $existing = mysql_fetch_assoc($res);
         
          if(strpos($existing['userlist'], $person)===false)
            mysql_query("UPDATE PUBLICATIONS SET userlist='"
               . mysql_real_escape_string($existing['userlist'] . "$person,")
               . "' WHERE pubid=$existing[pubid] LIMIT 1", connectpubsdb());
          if(strpos($existing['deptlist'], $chosendept)===false)
            mysql_query("UPDATE PUBLICATIONS SET deptlist='"
               . mysql_real_escape_string($existing['deptlist'] . "$chosendept,")
               . "' WHERE pubid=$existing[pubid] LIMIT 1", connectpubsdb());      
          echo "\n<p>The record with PubMed ID <a href=\"$config[pageshomeurl]manage/?action=edit&amp;pubid=$existing[pubid]\">{$current[url][0]}</a> (<strong><em>"
            . htmlspecialchars($current['title'][0]) . "</em></strong>) is already in the database, so rather than inserting a duplicate, "
            . " the system has associated your userid with the existing record.</p>";
        }else{
       
        insertentry($ret);
        echo 'pm: '.$_POST['pubmedid'].' is added';
        }
}else{
echo 'Person id:'.$person.'<br />';
echo $pubabstract;
}
?>
 <form id="newform2" action = "<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="if(this.authorlist.value=='' || this.title.value==''|| this.ptitle.value==''|| this.pubmedid.value=='' )
       {alert('Required fields:\n\n - author list\n - title\n - Periodical title\n - Pubmed id\n'); return false;} return true;">
To add a new pubmed, please fill in its details</a>.
  </p>
 
  <div id="newpubmed" style="margin: 5px 5px 5px 20px; padding: 1px; ">
  <label style="display: block; float: left;">Author list(<font color="red">*</font>): <br />
    <input name="authorlist" type="text" value="<?php echo $_POST['authorlist'];?>" ></label>
     <label style="display: block; float: left;"> title:(<font color="red">*</font>): <br />
    <input name="title" type="text" value="<?php echo $_POST['title'];?>" ></label>
  <label style="display: block; float: left;">Periodical title:(<font color="red">*</font>): <br />
   <input name="ptitle" type="text" value="<?php echo $_POST['ptitle'];?>" ></label>
    <label style="display: block; float: left;">Year <br />
    <input name="year" type="text" value="<?php echo $_POST['year'];?>" maxlength="128"></label>
   <label style="display: block; float: left;">Month and day <br />
    <input name="monthday" type="text" value="<?php echo $_POST['monthday'];?>" maxlength="128"></label>
 <label style="display: block; float: left;">Volume: <br />
    <input name="volume" type="text" value="<?php echo $_POST['volume'];?>" ></label>
 <label style="display: block; float: left;">Issue: <br />
    <input name="issue" type="text" value="<?php  echo $_POST['issue'];?>"  maxlength="128"></label>
    <label style="display: block; float: left;">Start page: <br />
    <input name="startpage" type="text" value="<?php echo $_POST['startpage'];?>" ></label>
  <label style="display: block; float: left;">End page: <br />
    <input name="endpage" type="text" value="<?php echo  $_POST['endpage'];?>" ></label>
    <label style="display: block; float: left;">pubmed id (<font color="red">*</font>):<br />
    <input name="pubmedid" type="text" value="<?php echo $_POST['pubmedid'];?>" ></label>
     <input name="person" type="hidden" value="<?php echo $person; ?>" >
  <input type="submit" name="submitpub" value="Add new pubmed" style="display: block;clear:both;"/>
 
   </div>
</form>   

No comments:

Post a Comment