public function bookingPricesCalculation(){ $content = ""; $ad = $this->component->ads->getAd($_POST["id"]); if(!$ad || $ad->delete){ return json_answer(["content"=>""]); } $count_days = $this->datetime->getDaysDiff($_POST['date_start'], $_POST['date_end']); if($count_days > 360){ return json_answer(["content"=>""]); } if($count_days){ $priceDates = $this->component->ads->getBookingPricesDate($ad); $listDates = $this->datetime->getDaysBetweenDates($_POST['date_start'], $_POST['date_end']); foreach (array_slice($listDates, 0, $count_days) as $value) { if($priceDates[$value]){ $price += $priceDates[$value]["price"]; }else{ $price += $ad->price; } } if($_POST['order_additional_services']){ foreach ($_POST['order_additional_services'] as $key => $value) { $price += $ad->booking->additional_services[$key]["price"]; } } $content = '