Friday, February 28, 2014

Send Mail to User when Record is Insert/update/delete


trigger SendEmail on Book__c (after insert,after update,after delete) {
     book__c b,b1;
     if(trigger.IsInsert){
         string emailaddres= userinfo.getuseremail();
         for(book__c bk:trigger.new){
               b=trigger.new[0];
               Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
               String[] toAddresses = new String[] {emailaddres};
               mail.setToAddresses(toAddresses);
               mail.setSubject('New Record Is Inserted');
               mail.setBccSender(false);
               mail.setUseSignature(false);
               mail.setPlainTextBody('The New record  is inserted the record name is ::'+b.name);
               Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
          }
     }
     if(trigger.Isupdate){
        string emailaddres= userinfo.getuseremail();
        if(trigger.old!= trigger.new){
               b1=trigger.old[0];
               Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
               String[] toAddresses = new String[] {emailaddres};
               mail.setToAddresses(toAddresses);
               mail.setSubject('Record is updated');
               mail.setBccSender(false);
               mail.setUseSignature(false);
               mail.setPlainTextBody('The  record  is updated ::'+trigger.new[0].name);
               Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
          }
     }
     if(trigger.Isdelete){
       string emailaddres= userinfo.getuseremail();
         for(Book__c bk:Trigger.old){
               b1=trigger.oldmap.get(bk.id);
               Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
               String[] toAddresses = new String[] {emailaddres};
               mail.setToAddresses(toAddresses);
               mail.setSubject('Record is Deleted');
               mail.setBccSender(false);
               mail.setUseSignature(false);
               mail.setPlainTextBody('The  record  is deleted ::'+bk.name);
               Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
          }
     }
}

Tuesday, February 18, 2014


Adding Rows to Dynamically

Vf page
<apex:page controller="DoctorSearchPage2" tabStyle="Doctor__c" showHeader="false">
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
        <span id="hideThisHomePageComp"></span> 
        <script type="text/javascript">
            $j = jQuery.noConflict();
            $j(document).ready(function() {
                var startYear=1900;
                var endYear=2024;
                var htmlStr='';
                    if(startYear<endYear){
                        for(i=startYear;i<endYear+1;i++){
                            htmlStr += "<option value=\""+i+"\">"+i+"</option>";
                        }
                        $j('#calYearPicker').html(htmlStr);
                    }
                $j('#sidebarDiv #hideThisHomePageComp').parent().parent().hide();
               
            });
        </script>   
        <script>
            var newWin=null;
            function openLookupPopup(name, id, fees){
                var url="/apex/DoctorName?namefield=" + name + "&idfield=" + id + "&feefield=" +fees;
                newWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
                if (window.focus){
                    newWin.focus();
                }
                return false;
            }
                 
            function closeLookupPopup(){
               if (null!=newWin){
                   newWin.close();
               } 
            }
    </script>
   
  
    <apex:form id="frm">
       
        <apex:pageBlock title="Search Patient" id="pg">
            <apex:pagemessages ></apex:pagemessages>
            <apex:inputText value="{!ipd_reg_no}"/>
            <apex:commandButton value="Search" reRender="op" action="{!addPatient}"/><br/> <br/>
            <apex:outputPanel id="op">
                <apex:outputText rendered="{!op}" ><font size="3" color="Blue">Hi..! you search for {!na}.</font></apex:outputText>          
            </apex:outputPanel>
        </apex:pageBlock>
       
        <apex:pageBlock title="Add Doctor" id="pageblock">
            <apex:inputhidden value="{!testCount}"/><br/>
            <apex:repeat value="{!lstInner}" var="e1" id="therepeat" >
               
                <apex:commandButton value="Remove Doctor" action="{!Del}" rerender="pageblock,total_amount">
                    <apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}" />
                </apex:commandButton>
               
                <apex:inputField id="targetName" value="{!e1.acct.Name}">
                    <apex:actionsupport event="onkeydown" action="{!removeName}" rerender="targetId,targetFees,targetVisitCount,targetVisitFees,total_amount"/>
                </apex:inputField>
                   
                <apex:inputhidden value="{!e1.acct.Name}" id="targetId" />
               
                <a href="" onclick="openLookupPopup('{!$Component.targetName}','{!$Component.targetId}','{!$Component.targetFees}'); return false">
                    <apex:commandButton value="Select" />
                </a>
                <apex:inputField id="targetFees"  value="{!e1.acct.Doctors_Fees__c}"/>
               
                <apex:inputField id="targetVisitCount"  value="{!e1.acctt.Doctor_Visit_Count__c}" >
                    <apex:actionSupport action="{!calcFees}" reRender="targetVisitFees,total_amount1" event="onkeyup"/>                                   
                </apex:inputField>
               
                <apex:inputField id="targetVisitFees"  value="{!e1.acctt.Total_Doctor_Fees__c}"/>    <!--  onchange="calcFee();"-->
                               
                <br/><br/>
            </apex:repeat>
            <br/><br/><apex:commandLink value="Add Doctor" action="{!Add}" reRender="pageblock"/> <br/>
            <br/><apex:commandButton value="Save" action="{!mySave}"/><br/><br/>
            <apex:pageBlockSection id="total_amount1">
                <apex:outputText id="total_amount">
                    <font size="5" color="Red">Rs. {!total_amt}</font>
                </apex:outputText>
            </apex:pageBlockSection>          
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller
public with sharing class DoctorSearchPage2 {

    public boolean op { get; set; }
    public String na { get; set; }
    IPD_Registration__c ipd_reg_obj;

    public decimal total_amt { get; set; }
    public String testCount { get; set; }
    public doctor__c doc{set;get;}
    public List<innerClass> lstInner{get;set;}            //list of the inner class
    public String selectedRowIndex{get;set;}             //will indicate the row to be deleted
    public Integer count = 1;                        //no. of rows added/records in the inner class list
    public String Docname {set;get;}
    public String ipd_reg_no { get; set; }
    decimal d = 0;
   
   
    public DoctorSearchPage2(){
        lstInner = new List<innerClass>();
        addMore();
        selectedRowIndex = '0';
        doc = new doctor__c();
        total_amt = 0;  
        op = false;    
    }
    
    public class innerClass{      
        public String recCount{get;set;}
        public doctor__c acct{get;set;}
        public IPD_Service__c acctt {get;set;}
       
        public innerClass(Integer intCount){
            recCount = String.valueOf(intCount);       
            acct = new doctor__c();
            acctt = new IPD_Service__c();
            acctt.Total_Doctor_Fees__c = 0;
            acctt.Doctor_Visit_Count__c = 0;
        }
    }
   
    public void Add(){  
        system.debug('add :::::::::::::::::::: '+lstInner);
        count = count+1;
        addMore();       
        system.debug('add :::::::::::::::::::: '+lstInner);
    }
   
    public void Del(){
        d = total_amt;
        for(innerClass c : lstInner){
            if(c.reccount == selectedRowIndex){
                d = d - c.acctt.Total_Doctor_Fees__c;
            }           
        }
        total_amt = d; 
        d = 0;     
        if(lstInner != null && selectedRowIndex != null && lstInner[integer.valueof(selectedRowIndex)-1] != null && lstInner[integer.valueof(selectedRowIndex)-1].acct != null && lstInner[integer.valueof(selectedRowIndex)-1].acct.name != null||lstInner[integer.valueof(selectedRowIndex)-1].acct.name == null){
            lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
            count = count-1;
        }                       
    }
   
    public void addMore(){
        innerClass objInnerClass = new innerClass(count);
        lstInner.add(objInnerClass);       
    }
       
    public PageReference calcFees() {
        for(innerClass c : lstInner){
            c.acctt.Total_Doctor_Fees__c = c.acctt.Total_Doctor_Fees__c + c.acct.Doctors_Fees__c * c.acctt.Doctor_Visit_Count__c;
            d = c.acctt.Total_Doctor_Fees__c;
        }
        total_amt = total_amt  + d;
        d = 0;
        return null;
    }
   
    public PageReference removeName() {
        return null;
    }
   
    public PageReference addPatient() {
        if(ipd_reg_no != null){
            try{
                ipd_reg_obj = [select id,name,Permanent_Reg_No__c,Patient_Name__c,Status__c  from IPD_Registration__c where name =: 'IPD--'+ipd_reg_no and Status__c =: 'Admitted'];
                if(ipd_reg_obj != null){
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info,'data is :: '+ipd_reg_obj+' only'));
                    na = ipd_reg_obj.Patient_Name__c;
                    op = true;
                }else{
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Data is not there.'));
                }
            }catch(QueryException e){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Data Can not be fetch.'));
            }
        }else{
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Please give the values here.'));
        }
       
       
        return null;
    }
   
    public PageReference mySave() {
        for(innerClass c : lstInner){
            IPD_Service__c ipd_serv = new IPD_Service__c();
            ipd_serv.Service_Name__c = c.acct.name;
            ipd_serv.Service_Charge__c = c.acct.Doctors_Fees__c;
            //ipd_serv.IPD_Registration__c = c.acctt.Doctor_Visit_Count__c;
            ipd_serv.Doctor_Visit_Count__c = c.acctt.Doctor_Visit_Count__c;
            ipd_serv.Total_Doctor_Fees__c = c.acctt.Doctor_Visit_Count__c * c.acct.Doctors_Fees__c;
            try{
                insert ipd_serv;
            }catch(DMLException e){
           
            }
        }       
        return null;
    }
    
}

Dynamic Search for records

===================VFPage========================
<apex:page controller="nnrauthosearch1" sidebar="false" applyBodyTag="true" ApplyHtmlTag="true" showHeader="false">
<script language="javascript">
   window.onload = new function()
   {
      // bring popup window to front
      window.focus();
      var ele=document.getElementById('{!$Component.form.block.section.query}');
      if (ele)
      {
         ele.focus();
      }
   }
 
   function fillIn(name, id)
   {
      var winMain=window.opener;
      if (null==winMain)
      {
         winMain=window.parent.opener;
      }
      var ele=winMain.document.getElementById('{!$CurrentPage.parameters.namefield}');
      ele.value=name;
      ele=winMain.document.getElementById('{!$CurrentPage.parameters.idfield}');
      ele.value=id;
      winMain.closeLookupPopup();
   }
   </script>
  <apex:form >
    <apex:pageMessages id="errors" />
       <apex:pageBlock title="Find Me A Patient!" mode="edit"><!-- starting pblock1-->
          <table width="100%" border="0"><!-- starting table1-->
             <tr> <!-- starting row1-->
                <td width="200" valign="top">
                   <apex:pageBlock title="Parameters" mode="edit" id="criteria"><!-- starting pblock2-->
                     
                        <table cellpadding="2" cellspacing="2">
                          <tr>
                          <td style="font-weight:bold;"><br/>
                          <apex:outputLabel >Main Name:</apex:outputLabel>
                          <apex:inputText value="{!firstname}" >
                          <apex:actionSupport event="onkeyup" action="{!runSearch}" reRender="results,pb"/>
                          </apex:inputText>
                          </td>
                          </tr>
                          <tr>
                          <td style="font-weight:bold;"><br/>
                          <apex:outputLabel >Sur Name:</apex:outputLabel>
                          <apex:inputText value="{!lastname}" >
                          <apex:actionSupport event="onkeyup" action="{!runSearch}" reRender="results,pb"/>
                          </apex:inputText>
                          </td>
                          </tr>
                          <tr>
                          <td style="font-weight:bold;">Mobile Number<br/>
                          <apex:inputText value="{!mobilenumber}" >
                          <apex:actionSupport event="onkeyup" action="{!runSearch}" reRender="results,pb"/>
                          </apex:inputText>
                          </td>
                          </tr>
                          <tr>
                          <td style="font-weight:bold;">Patient Id<br/>
                          <apex:inputText value="{!patientid}" >
                          <apex:actionSupport event="onkeyup" action="{!runSearch}" reRender="results,pb"/>
                          </apex:inputText>
                          </td>
                          </tr>
                       
                          <tr><td> <h1 style="color:RED"> OR</h1></td></tr>
                          <tr><td> <apex:outputPanel style="color:#1475FF">From Date:</apex:outputPanel>
                          <apex:inputText value="{!fromdateselected}" id="fromdateid"  onfocus="DatePicker.pickDate(false, this, false);" >
                       
                          </apex:inputText> </td></tr>
                          <tr><td> <apex:outputPanel style="color:#1475FF">To Date:</apex:outputPanel>
                          <apex:inputText id="todateid" value="{!todateselected}" onfocus="DatePicker.pickDate(false, this, false);" >
                          </apex:inputText> </td></tr>
                          <tr>
                          <td>
                          <apex:commandButton value="search" action="{!searchaction}"  style="background:pink" reRender="results"/>
                          </td>
                          </tr>
                        </table>
                        <apex:pageBlockSection columns="1" id="pb">
                         <apex:PageBlockSectionItem >
                           <apex:selectRadio value="{!daycheckl}" ><apex:selectOptions value="{!value}"></apex:selectOptions>
                             <apex:actionSupport event="onclick" action="{!DayRecords}" reRender="results"/>
                           </apex:selectRadio>
                         </apex:PageBlockSectionItem>
                       </apex:pageblockSection>
                    </apex:pageBlock><!-- end pblock2-->
                    </td>
                    <td valign="top">
                      <apex:pageBlock mode="edit" id="results">
                         <apex:pageBlockTable value="{!contacts}" var="c">
                             <apex:column headerValue="PatientId">
                             <apex:outputLink value="#" onclick="fillIn('{!c.Patient_Id__c}', '{!c.id}')">{!c.Patient_Id__c}
                             <apex:param name="sortField" value="firstName" assignTo="{!sortField}"/>
                             </apex:outputLink>
                             </apex:column>
                             <apex:column value="{!c.First_Name__c}" />
                             <apex:column value="{!c.LastName__c}"  />
                             <apex:column value="{!c.Mobile__c}"  />
                             <apex:column headerValue="Registration No" value="{!c.Name}"  />  
                             <apex:column value="{!c.Status__c}"/>
                             <apex:column value="{!c.createddate}"/>
                         </apex:pageBlockTable>
                      </apex:pageBlock>
                    </td>
             </tr>
          </table><!-- end table1-->
       </apex:pageblock> <!-- end of pblock1-->
  </apex:form>

</apex:page>
========================Controller==============================
public with sharing class nnrauthosearch1 {
    public string daycheckl { get; set; }
    public boolean monthcheck{ get; set; }
    public boolean yearcheck{ get; set; }
    public boolean weekcheck{ get; set; }
    public string firstName{set;get;}
    public string lastname{set;get;}
    public string mobilenumber{set;get;}
    public string patientid{set;get;}
    public string OPDRegistrationNo{set;get;}
    private String soql {get;set;}
    public list<OPD_Registration__c> contacts{set;get;}
    public Date todateselected { get; set; }
    public Date fromdateselected { get; set; }
    public static string str='open';
    // Constructor
    public nnrauthosearch1 (){
      daycheckl='Day';
      //soql = 'select id,First_Name__c,Mobile__c,Patient_Id__c,Name,LastName__c,city__c,state__c,status__c,CreatedDate From OPD_Registration__c  where CreatedDate =today  ';
      //contacts=[select id,First_Name__c,Mobile__c,Patient_Id__c,Name,LastName__c,city__c,state__c,status__c,CreatedDate From OPD_Registration__c  where CreatedDate =today  ];
      runQuery1();
    }
    public String sortDir {
        get  { if (sortDir == null) {  sortDir = 'desc'; } return sortDir;  }
        set;
    }

  // the current field to sort by. defaults to last name
    public String sortField {
       get  { if (sortField == null) {sortField = 'createddate desc limit 2'; } return sortField;  }
       set;
   }
 
     public List<SelectOption> getValue(){
        List<SelectOption> opt=new List<SelectOption>();
        opt.add(new SelectOption('Day','Day'));
        opt.add(new selectOption('Week','Week'));
        opt.add(new SelectOption('Month','Month'));
        opt.add(new SelectOption('Year','Year'));
        return opt;
     
    }
    // Date wise search
    public PageReference searchaction() {
 
        if(todateselected != NULL && fromdateselected != NULL){
           system.debug('PPPPPPPPPPPPPPPPPPPPP'+todateselected+'dddddddddddddddddddddddddddddddddddddddddd'+fromdateselected  );
        contacts =[select id,First_Name__c,Mobile__c,Patient_Id__c,Name,LastName__c,City__c,status__c,CreatedDate From OPD_Registration__c where createddate >=: fromdateselected and createddate <=: todateselected and patient_id__c!=null  ];
     
        }
        return null;
    }
    public void runQuery() {
         try {
          contacts = Database.query(soql+ ' order by ' + sortField  );
        } catch (Exception e) {
              ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
        }

    }
    public void runQuery1(){
       system.debug('hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh@@@@@@@@@@@@@');  
        //contacts =[select id,First_Name__c,Mobile__c,LastName__c ,Patient_Id__c,Name,Country__c,Registration_Date__c,city__c,state__c,CreatedDate,status__c,opd_Reg_Date__c From OPD_Registration__c where  CreatedDate =TODAY ];
        contacts=[select id,First_Name__c,Mobile__c,Patient_Id__c,Name,LastName__c,city__c,state__c,status__c,CreatedDate From OPD_Registration__c  where CreatedDate =today  ];
        system.debug('hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh'+contacts);
        daycheckl='Day';
           //runQuery();
    }
 
    // Radio button search
 
    public void DayRecords() {
        if(daycheckl=='day'){
        system.debug('&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&');
        contacts =[select id,First_Name__c,Mobile__c,LastName__c ,Patient_Id__c,Name,Country__c,Registration_Date__c,city__c,state__c,CreatedDate,status__c,opd_Reg_Date__c From OPD_Registration__c where  CreatedDate =TODAY ];}
        else if(daycheckl=='week'){
        contacts =[select id,First_Name__c,Mobile__c,LastName__c ,Patient_Id__c,Name,Country__c,Registration_Date__c,city__c,state__c,CreatedDate,opd_Reg_Date__c,status__c From OPD_Registration__c where  CreatedDate = THIS_WEEK];}
        else if(daycheckl=='month'){
        contacts =[select id,First_Name__c,LastName__c ,Mobile__c,Patient_Id__c,Name,Country__c,Registration_Date__c,city__c,state__c,CreatedDate,opd_Reg_Date__c,status__c From OPD_Registration__c where  CreatedDate = THIS_MONTH ];}
        else if(daycheckl=='year'){
        contacts =[select id,First_Name__c,LastName__c ,Mobile__c,Patient_Id__c,Name,Country__c,Registration_Date__c,city__c,state__c,CreatedDate,opd_Reg_Date__c,status__c From OPD_Registration__c where  CreatedDate = THIS_YEAR  ];}
        else{
        contacts =[select id,First_Name__c,Mobile__c,LastName__c ,Patient_Id__c,Name,Country__c,Registration_Date__c,city__c,state__c,CreatedDate,opd_Reg_Date__c,status__c From OPD_Registration__c ];}
   }
     // inputtext box search
    public PageReference runSearch() {
 
        soql ='select id,First_Name__c,Mobile__c,Patient_Id__c,Name,LastName__c,city__c,state__c,status__c,CreatedDate From OPD_Registration__c where name!=null and (createddate >=: fromdateselected and createddate <=: todateselected) ';
            if (!firstName.equals('')){
                      soql += ' and First_Name__c LIKE \''+String.escapeSingleQuotes(firstName)+'%\'';
                 system.debug('first name @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'+firstname);
             }
             if (!lastname.equals('')){                  
                     soql += ' and lastname__c LIKE \''+String.escapeSingleQuotes(lastname)+'%\'';
                     system.debug('lastname @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'+lastname);
            }      
            if (!mobilenumber.equals('')){
                    soql += ' and mobile__c LIKE \''+String.escapeSingleQuotes(mobilenumber)+'%\'';
                  system.debug('mobile number@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'+mobilenumber);
            }    
           if (!patientid.equals('')){
                    soql += ' and patient_id__c LIKE \''+String.escapeSingleQuotes(patientid)+'%\'';
                    system.debug('patientid @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'+patientid);
            }      
         
            if( patientid.equals('') && mobilenumber.equals('') && lastname.equals('') && firstname.equals('')){
                 runQuery1();
                  daycheckl='Day';
            }                    
 
         runQuery();

        return null;
   }  

}
Tree Structure of vfpage





=================VFPage=============================================
<apex:page showHeader="false" controller="nnrtreeclass">
 <script language="javascript">
   window.onload = new function()
   {
      // bring popup window to front
      window.focus();
      var ele=document.getElementById('{!$Component.form.block.section.query}');
      if (ele)
      {
         ele.focus();
      }
   }
 
   function fillIn(name, id)
   {
      var winMain=window.opener;
      if (null==winMain)
      {
         winMain=window.parent.opener;
      }
      var ele=winMain.document.getElementById('{!$CurrentPage.parameters.namefield}');
      ele.value=name;
      ele=winMain.document.getElementById('{!$CurrentPage.parameters.idfield}');
      ele.value=id;
      winMain.closeLookupPopup();
      savemethod();
      alert('ahi');
   }
   </script>



    <script type="text/javascript" language="javascript">
 
function hide_menu(node_id,menu_type){

var node_prefix="";

switch(menu_type){

case 1:{

node_prefix="node_";

}break;

case 2:{

node_prefix="main_node_";

}break;

}



var node=document.getElementById(node_prefix+node_id);

var node_status=document.getElementById(node_prefix+node_id+"_status");

var node_text=document.getElementById(node_prefix+node_id+"_title");
if(node_status.value=="1"){

node.style.display = "none";

}else{

node.style.display = "";

}

if(node_status.value=="1"){

node_status.value="0";

node_text.innerHTML="&#9658";

}else{

node_status.value="1";

node_text.innerHTML="&#9660";

}

return false;

}


</script>

<style type="text/css">

.node_content{

padding-left:30px;

}

.node_title{

vertical-align:top;

}

.link_text{

font-family:Verdana, Arial, Helvetica, sans-serif;

font-size:10px;

text-decoration:none;

}

.link_text:hover{

text-shadow:#FFCC00;

font-weight:bold;

}

.node_title{

font-family:Verdana, Arial, Helvetica, sans-serif;

font-size:11px;

font-weight:bold;

text-decoration:none;

}

</style>

<html>

<head><title>How to create tree view in JavaScript </title>

</head><body>
<apex:form >
<apex:pageBlock >
<apex:actionFunction name="savemethod" action="{!displayRecord}"/>
<!-- Main Menu-->

<div id="myMenu">

<!-- First Menu Item -->
 
    <div id="node_title_1">  
        <a href="javascript:void(0);" onclick="javascript:hide_menu('1',1);" class="link_text">
        <!--    <span class="node_title" id="node_1_title">&#9660;</span> -->
            <apex:outputText styleClass="node_title" id="node_1_title"> &#9660; </apex:outputText>
        </a>
           

           <apex:outputText styleClass="node_title"> Clinical Bio-Chemistry </apex:outputText>
                   <!--  <apex:commandLink styleClass="node_title" value="Clinical Bio-Chemistry"/>  -->
       
             
       
                    <div id="node_1">
                        <div id="node_11" class="node_content">
                       
                            <a href="javascript:void(0);" onclick="javascript:hide_menu('111',1);" class="link_text">
                            <span class="node_title" id="node_111_title">&#9660;</span></a>
       

          <apex:outputText styleClass="link_text"> Acid Based Homeo Stasis </apex:outputText>
       
                                <div id="node_111" class="node_content">
                               
                                        <apex:pageBlockSection >
         <apex:dataTable value="{!records}" var="r">
            <apex:column >
             <apex:outputLink onclick="fillIn('{!r.name}', '{!r.id}')"> {!r.name}
              <apex:param name="id"  value="{!r.id}"    assignTo="{!r.id}"/>
             </apex:outputLink>
            </apex:column>
         </apex:dataTable>
       
       </apex:pageBlockSection>
                                           
                                            <input type="hidden" id="node_111_status" name="node_111_status" value="1" />
                                           
                                               
                                </div>
       
                        </div>

                       
                    <div id="node_14" class="node_content">
                   
                            <a href="javascript:void(0);" onclick="javascript:hide_menu('140',1);" class="link_text">
                    <span class="node_title" id="node_140_title">&#9660;</span></a>
       
                    <a href="javascript:void(0);" class="link_text">Metabolic Panel/Plasma Osmolality</a>
                        <div id="node_140">
                          <div id="node_141" class="node_content"> <!-- &bull;&nbsp;-->
                            <apex:dataTable value="{!Record}" var="r">
                                 <apex:column >
             <apex:outputLink onclick="fillIn('{!r.name}', '{!r.id}')" >{!r.name}</apex:outputLink>
            </apex:column>
                            </apex:dataTable>
                          </div>
                         
                              <input type="hidden" id="node_140_status" name="node_140_status" value="1" /> </div>
                    </div>

                    <div id="node_1_link_5" class="node_content">

                        <a href="javascript:void(0);" onclick="javascript:hide_menu('150',1);" class="link_text">
                    <span class="node_title" id="node_150_title">&#9660;</span></a>

                        <a href="javascript:void(0);" class="link_text">Erdiconology </a>
                    <div id="node_150">
                     <div id="node_141" class="node_content">
                        <apex:dataTable value="{!recordss}" var="r">
                            <apex:column >
                                 <apex:outputLink onclick="fillIn('{!r.name}', '{!r.id}')">{!r.name}</apex:outputLink>
                            </apex:column>
                        </apex:dataTable>
                        </div>
                       <input type="hidden" id="node_150_status" name="node_150_status" value="1" /> </div>  
                    </div>

                   
                   

                    </div>   <input type="hidden" id="node_1_status" name="node_1_status" value="1" />

            </div>

 
 
 
 
 
  <!-- Second Menu Item  -->
  <!--

    <div id="node_title_2">
   
                <a href="javascript:void(0);" onclick="javascript:hide_menu('2',1);" class="link_text">
                <span class="node_title" id="node_2_title">&#9660;</span></a>
               
                    <span class="node_title">Haemotology  </span>

                <div id="node_2">

                <div id="node_2_link_1" class="node_content">
       
                <a href="javascript:void(0);" onclick="javascript:hide_menu('160',1);" class="link_text">
                <span class="node_title" id="node_160_title">&#9660;</span></a>
       
                <a href="javascript:void(0);" class="link_text">Blood Bank </a>
        <div id="node_160">
                    <div id="node_2_link_11" class="node_content"> <apex:inputCheckbox /> <apex:outputLink value="#" onclick="fillIn('{!r.name}', '{!r.id}')">RCB</apex:outputlink></div>
                        <div id="node_2_link_12" class="node_content"> <apex:inputCheckbox /> <apex:outputLink value="#" onclick="fillIn('{!r.name}', '{!r.id}')">WCB </apex:outputlink></div>
             
             
           <input type="hidden" id="node_160_status" name="node_160_status" value="1" /> </div>  
                </div>

           
            <div id="node_2_link_2" class="node_content"> <apex:inputCheckbox /> <apex:outputLink value="#" onclick="fillIn('{!r.name}', '{!r.id}')">Coagulation </apex:outputlink></div>
   
            </div> <input type="hidden" id="node_2_status" name="node_2_status" value="1" />

        </div>


-->


  <!-- Third Menu Item -->



    <div id="node_title_3"><a href="javascript:void(0);" onclick="javascript:hide_menu('3',1);" class="link_text">
           
        <span class="node_title" id="node_3_title">&#9660;</span></a><span class="node_title">Pathology </span>

                <div id="node_3">
                   <div id="node_141" class="node_content">
                    <apex:dataTable value="{!Recorded}" var="r">
                       <apex:column >
                         <apex:outputLink onclick="fillIn('{!r.name}', '{!r.id}')">{!r.name}</apex:outputLink>
                       </apex:column>
                    </apex:dataTable>
                   
             </div>
                </div>   <input type="hidden" id="node_3_status" name="node_3_status" value="1" />

        </div>


</div>
</apex:pageBlock>
</apex:form>
</body>

</html>
  <apex:pageBlock rendered="{!display}" title="Record Display">
  </apex:pageBlock>

</apex:page>

=======================Controller===========================
public class nnrtreeclass {

    public PageReference displayRecord() {
        display=true;
       String firstName = Apexpages.currentPage().getParameters().get('id');
       system.debug('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'+firstName );
        return null;
    }

  public boolean display{set;get;}
  public LIST<Test__c> getRecoeds(){
  return listrecords;
  }
   public list<Test__c>  getrecords() {
        listrecords=[select id, Name,Test_Code__c,Cost__c,IsDiscount__c,Discount__c,Total_Price__c from test__c where name LIKE 'Blood %' order by name desc];
        return listrecords;
    }

    string soql {set;get;}
    public list<Test__c> listrecords{set;get;}
    public nnrtreeclass(){
       listrecords=[select id, Name,Test_Code__c,Cost__c,IsDiscount__c,Discount__c,Total_Price__c from test__c order by name limit 1];
         
    }
    public list<Test__c>  getrecord() {
        listrecords=[select id, Name,Test_Code__c,Cost__c,IsDiscount__c,Discount__c,Total_Price__c from test__c where name LIKE 'Cardiac %' order by name desc];
        return listrecords;
    }
    public list<Test__c>  getrecordss() {
        listrecords=[select id, Name,Test_Code__c,Cost__c,IsDiscount__c,Discount__c,Total_Price__c from test__c where name LIKE 'Liver %' order by name desc];
        return listrecords;
    }
    public list<Test__c>  getrecorded() {
        listrecords=[select id, Name,Test_Code__c,Cost__c,IsDiscount__c,Discount__c,Total_Price__c from test__c where name LIKE 'Protiend %' order by name desc];
        return listrecords;
    }
}