• laytro1978
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 26
    Replies

Hi,

 

This code pulls back via a VF page availability within date range (start and end date).  It list room allocations which as an object has a lookup to a room record on the room object..  

 

I would like to run a second query based on the first.

 

For the rooms that a brought back i.e rooms allocated I would like to bring back a separate list rooms not allocated.  Room__c highlighted below is the lookup to the room__c object.

 

So I think using the list of room allocation from the first query I will know the room__c for each record.  I want to use the room_c name against the room object to show rooms that are not in that list.

 

So on the VF page I will have two list rooms allocated and rooms not allocated within a give date range.

 

Any help would be great.

 

Thanks

 

Ross

 

 

Public class Roommanager {

    public PageReference room() {
        return null;
    }

    public Room_Allocation__c room {get;set;}
    public roommanager(ApexPages.StandardController controller) {
           room=(Room_Allocation__c)controller.getRecord();
             }
            
    public List<Room_Allocation__c> getRooms(){
            List<Room_Allocation__c> listBd=[select Id, Name, Start_Date__c, End_Date__c, Nights__c, Room__c, Reservation__c from Room_Allocation__c r 
                where (Start_Date__c >= :room.Search_Start_Date__c 
                    and 
                    Start_Date__c <= :room.Search_End_Date__c
                    )
                    or
                    (End_Date__c >= :room.Search_Start_Date__c
                    and
                    End_Date__c <= :room.Search_End_Date__c)];  
            return listBd;   
        }
}

 

 

Had some help to get to this point but I can't seem to get the code below to work.

 

Just looking for a list view which will search start dates after the user inputs a date.

 

The VF page looks okay but I just can't get the controller to work, any help would be great as I am really stuck.

 

Thanks

 

Ross

 


Error: Resmanager Compile Error: Illegal assignment from SObject to SOBJECT:Reservation__c at line 4 column 12

 

 

 

Apex Controller

Made some changes to your code highlighted in red.  

 

public class Resmanager {
    public Reservation__c reservation {get;set;}
    public Resmanager(ApexPages.StandardController controller) {
           reservation=controller.getRecord();
             }
            
    public List<Reservation__c> getReservations(){
            List<Reservation__c> listBd=[select r.id, r.Start_Date__c, R.End_Date__c, nights__c from Reservation__c r where start_date__c = :reservation.Start_Date__c];
            return listBd;   
        }
    public void save()
    {
    getReservation();
     }
}

 

Visualforce Page

<apex:page standardController="Reservation__c"  extensions="Resmanager">
    <apex:form >
        <apex:sectionHeader title="Availability Search"/>            
            <apex:pageBlock title="Search">
                <apex:pageBlockButtons >
                    <apex:commandButton action="{!reservation}" value="Search"/>
                </apex:pageBlockButtons>
                <apex:inputField value="{!Reservation__c.Start_Date__c}"/>
            </apex:pageBlock>  
            <apex:pageBlock title="Reservations">
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!Reservations}" var="res">
                        <apex:column value="{!res.Start_Date__c}"  />
                        <apex:column value="{!res.End_Date__c}"  />
                        <apex:column value="{!res.Nights__c}"  />
                    </apex:pageBlockTable>
                </apex:pageBlockSection>   
            </apex:pageBlock> 
    </apex:form>
</apex:page>

 

 

Hi,

 

Struggling on this, I would like a custom list view with a dynamic date field search.  Below is a visualforce page which is all set-up just how I want it. I am using the action save clearly this needs to be a search method.

 

 

<apex:page standardController="Reservation__c"  extensions="Resmanager">
    <apex:form >
        <apex:sectionHeader title="Availability Search"/>            
            <apex:pageBlock title="Search">
                <apex:pageBlockButtons >
                    <apex:commandButton action="{save}" value="Search"/>
                </apex:pageBlockButtons>
                <apex:inputField value="{!Reservation__c.Start_Date__c}"/>
            </apex:pageBlock>  
            <apex:pageBlock title="Reservations">
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!Reservations}" var="res">
                        <apex:column value="{!res.Start_Date__c}"  />
                        <apex:column value="{!res.End_Date__c}"  />
                        <apex:column value="{!res.Nights__c}"  />
                    </apex:pageBlockTable>
                </apex:pageBlockSection>   
            </apex:pageBlock> 
    </apex:form>
</apex:page>

 

I am not sure how to write the search method, my attempt on the controller below.  I am hardcoding yesterday to get the controller to work.

 

 

public class Resmanager { 

    public Resmanager(ApexPages.StandardController controller) {

    }
        
    public List<Reservation__c> getReservations(){
        List<Reservation__c> listBd=[select r.id, r.Start_Date__c, R.End_Date__c, nights__c from Reservation__c r where start_date__c = yesterday];
        return listBd;   
    }
   
}

 

 

 

Hi,

 

I would like to build a VF page which pulls back a list of all opportunities with a certain close date.

 

Are there any good guides or starter code.

 

Simple VF page with a date search box, it search and it pulls back the opportunities.

 

Thanks

 

R

Hi,

 

Quick question.  I have a client that wants to move to a force.com license.

 

This means he will lose lead and lead capture.

 

I can easily re-create the lead object, but how easy is it to recreate the lead capture I guess using apex and visualforce.

 

Thanks

 

Ross

Hi Simon,

 

I have a user who has just installed maildrop.

 

Using a mac with office 2011 outlook.

 

He tries to send an email into the system and gets the following error.

 

unknown.png

 

Can you please help.

 

Thanks

 

Ross

Below is a simple VF page and Controller. You will not on the Controller I hard code the

 

 

where nights__c = 4

 

 I want to make this dynamic using a input field on the VF page.

 

 

 

VF Page

 

 

<apex:page controller="Resmanager">
    <apex:sectionHeader title="Availability Search"/> 
                 
              <apex:pageBlock title="Reservations">
              <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!Reservations}" var="res">
                        <apex:column value="{!res.Start_Date__c}"  />
                        <apex:column value="{!res.End_Date__c}"  />
                        <apex:column value="{!res.Nights__c}"  />
                    </apex:pageBlockTable>
               </apex:pageBlockSection>
               
               </apex:pageBlock>

</apex:page>

 

 

APEX Controller

 

 

public class Resmanager {
    
    public List<Reservation__c> getReservations(){
        List<Reservation__c> listBd=[select r.id, r.Start_Date__c, R.End_Date__c, nights__c from Reservation__c r where nights__c = 4];
        return listBd;   
    }
   
}

 

 

 

I have custom object with a

 

 

  1. name (unique)
  2. start date
  3. end date
I want create a VF / Apex availability checker to see where there are no records with the same name and date.
Any help much appreciated.
Thanks
R

 

Background

A friend  runs a small hotel, 8 rooms.  He wanted me to help him with CRM which I did with SFDC.  We are now looking to try and build a simple reservation manager to be used be his receptionist.   The reservation manager should allow the receptionist to make bookings, change and delete them.

 

What I have done so far

I have two objects room and reservation.  The reservation has a lookup to contact and room.  So I can create a reservation with a start and an end date.  So at a glance I can see room booking either as a report, a list view or as a related list on the room object.

 

Help

I now want to make the system more intelligent. 

 

 

  1. Validation to stop duplicate bookings

  2. A Visualforce page with Apex that would allow the receptionist to quickly see what is available. With the possibility of applying filters like en-suite or balcony

  3. Being able to split the booking should a client want to change room halfway through there stay
My thoughts
I think I need a third object (hidden) called room allocation, which is created using APEX automatically when a reservation is made. The room allocation records would be per booking so if somebody was staying at the hotel for 3 days there would be 3 allocation records
Final comment
I am doing this as a favour for a friend so no real budget.  Although I thinking of buying calendar anything from the Appexchange to visualise my room bookings.  Also I am treating this as a learning project.
Any help / pointers / suggestions welcome.  I did think there might be so sample meeting manager apps to get ideas from but no such luck!

 

Hi,

 

I have need to roll up data from one object to another but cannot use a master detail relationship.

 

I have an object called project and an object called time sheet.

 

When a timesheet is created and linked to project I want to sum all related time sheet records.

 

I would usually use a master detail relationship but I can't lock timesheet to project as timesheets can be agains most objects.

 

Is there an easy way every time a time sheet is added to project to have a field - total time spent calculate?

 

Thanks

 

Ross

Hi,

 

Can someone please give me a hand on the test method for this piece of APEX.

 

Any help would be much appreciated.

 

I have made a start in red below.

 

Thanks

 

Ross

 

 

public class TimeEntry {

    public List<Time_Slot__c> slots {get; set;}
    
    public TimeEntry(){        
        slots = new List<Time_Slot__c>();
        slots.add(new Time_Slot__c());
    }

    public void addrow() {
        slots.add(new Time_Slot__c());
    }
           
    public void removerow(){
        Integer i = slots.size();
        slots.remove(i-1);
    }
           
    public PageReference save() {
        insert slots;
        PageReference home = new PageReference('/a00/o');
        home.setRedirect(true);
        return home;
    }
    
    public static testMethod void TimeEntry() {

    //setup test data  
    Time_Slot__c T = new Time_Slot__c();
    insert t;
    
    //test main controller action 
    List<Time_Slot__c> slots;
          
    }       
}