Announcement

Collapse
No announcement yet.

Only one event at a time range

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Enju
    replied
    Thank you Yuri, it work's perfect!

    Leave a comment:


  • yuri
    replied
    API Before Save script:

    Code:
    $message = "An event on the same time slot already exists.";
    
    if (entity\isNew() && assignedUserId) {
        $existingId = record\findOne(
            'Event',
            null,
            null,
            'assignedUserId=', assignedUserId,
            'dateEnd>', dateEnd,
            'dateStart<', dateEnd
        );
        
        
        if ($existingId) {
            recordService\throwConflict($message);  
        }
        
        $existingId = record\findOne(
            'Event',
            null,
            null,
            'assignedUserId=', assignedUserId,
            'dateEnd>', dateStart,
            'dateStart<', dateStart
        );
        
        
        if ($existingId) {
            recordService\throwConflict($message);  
        }
        
        $existingId = record\findOne(
            'Event',
            null,
            null,
            'assignedUserId=', assignedUserId,
            'dateEnd<=', dateEnd,
            'dateStart>=', dateStart
        );
        
        
        if ($existingId) {
            recordService\throwConflict($message);  
        }
    }
    ​
    Where 'Event' should be your entity type.
    Last edited by yuri; 07-25-2023, 02:24 PM.

    Leave a comment:


  • yuri
    replied
    You can also utilize API before save script.

    Leave a comment:


  • rabii
    replied
    There is no such a class, you just need to add your own logic. there are many ways to achieve this depend on your business logic.

    Leave a comment:


  • Enju
    replied
    Has anyone managed to write such a class? I'm looking for a solution too.

    Leave a comment:


  • eymen-elkum
    replied
    You may need to have custom duplicate checker class, follow this doc:

    Leave a comment:


  • ShulzR
    replied
    Manage bookings, marketing and invoicing with EspoCRM Currently, the hotel industry is one of the fastest-growing, competitive sectors. As guests become more digitalized and price-conscious, building loyal relationships and attracting new guests becomes an increasingly complicated process.

    I see record: "Monitor the availability of rooms & services"
    Somone can help?

    Leave a comment:


  • ShulzR
    started a topic Only one event at a time range

    Only one event at a time range

    Hello,
    I create new event entity ' Rooms Reservation'. Do you have any way to make it impossible to book one room at the same time?
    Possibly any warning that there is a reservation in a certain period of time?​

    Regards,​
    Robert
Working...
X