Mail and Booking
This commit is contained in:
parent
62e84637b6
commit
5daea268f7
250 changed files with 5377 additions and 1473 deletions
|
|
@ -515,5 +515,74 @@ class DraftRepository extends BaseRepository {
|
|||
return null;
|
||||
}
|
||||
|
||||
public function change_dates_drafts_from_booking($new_start_date)
|
||||
{
|
||||
$booking = $this->model;
|
||||
$start_date = $booking->start_date;
|
||||
$_start_date = $booking->start_date;
|
||||
$_end_date = $booking->end_date;
|
||||
$new_start_date = Carbon::parse($new_start_date);
|
||||
//$duration = $booking->start_date->diffInDays($booking->end_date, false);
|
||||
$diff_days = $booking->start_date->diffInDays($new_start_date, false);
|
||||
|
||||
//new start date booking
|
||||
$_start_date->modify($diff_days.' days');
|
||||
//new end date booking
|
||||
$_end_date->modify($diff_days.' days');
|
||||
|
||||
/*dump($diff_days);
|
||||
dump($_start_date);
|
||||
dump($_end_date);
|
||||
*/
|
||||
|
||||
if($booking->booking_draft_items){
|
||||
foreach ($booking->booking_draft_items as $booking_draft_item){
|
||||
|
||||
/* dump($booking_draft_item->id);
|
||||
$start_date_temp = null;
|
||||
$end_date_temp = null;
|
||||
if($booking_draft_item->draft_item){
|
||||
if($booking_draft_item->draft_item->days_start > 0){
|
||||
$start_date_temp = clone $start_date;
|
||||
$start_date_temp->addDay($booking_draft_item->draft_item->days_start-1+$diff_days);
|
||||
dump($start_date_temp->format("d.m.Y"));
|
||||
}
|
||||
|
||||
if($booking_draft_item->draft_item->days_duration > 0){
|
||||
$end_date_temp = clone $start_date;
|
||||
$end_date_temp->addDay($booking_draft_item->draft_item->days_duration-1+$diff_days);
|
||||
dump($end_date_temp->format("d.m.Y"));
|
||||
}
|
||||
}*/
|
||||
|
||||
$d_start_date = null;
|
||||
$d_end_date = null;
|
||||
if($d_start_date = $booking_draft_item->getStartDateRow()){
|
||||
$d_start_date->modify($diff_days.' days');
|
||||
//dump($d_start_date->format('d.m.Y'));
|
||||
$booking_draft_item->setStartDateRow($d_start_date->format('Y-m-d'));
|
||||
}
|
||||
if($d_end_date = $booking_draft_item->getEndDateRow()){
|
||||
$d_end_date->modify($diff_days.' days');
|
||||
//sdump($d_end_date->format('d.m.Y'));
|
||||
$booking_draft_item->setEndDateRow($d_end_date->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/*if($start_date_temp != null && $start_date_temp == $d_start_date){
|
||||
dump(true);
|
||||
}
|
||||
if($end_date_temp != null && $end_date_temp == $d_end_date){
|
||||
dump(true);
|
||||
}*/
|
||||
$booking_draft_item->save();
|
||||
}
|
||||
}
|
||||
if(!$booking->origin_start_date){
|
||||
$booking->origin_start_date = $booking->start_date;
|
||||
}
|
||||
$booking->start_date = $_start_date;
|
||||
$booking->end_date = $_end_date;
|
||||
$booking->save();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue