git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3473 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
adametz 2018-10-18 08:04:06 +00:00
parent 8f7f2c03db
commit 6241856464
10 changed files with 160 additions and 25 deletions

View file

@ -16,6 +16,7 @@ use AppBundle\Entity\TravelPeriodPrice;
use AppBundle\Entity\TravelPeriodPriceType;
use AppBundle\Form\BookingRequestType;
use AppBundle\Util;
use Doctrine\ORM\Query;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@ -55,9 +56,34 @@ class BookingController extends Controller
return $errors;
}
public function getEntityManager()
{
return $this->getDoctrine()->getManager();
}
public function indexAction(Page $travelProgramPage, $action, Request $request)
{
if($action == '/show_nationality_country_text')
{
$ret = "";
$nationality_id = $request->request->get('nationality_id');
$country_ids = $request->request->get('country_ids');
foreach ($country_ids as $country_id){
$country = $this->getEntityManager()->getRepository('AppBundle:TravelCountry')
->findOneBy(['id' => $country_id]);
$req = $this->getDoctrine()->getRepository('AppBundle:TravelNationalityRequirement')->findOneByCountryAndNationality($country_id, $nationality_id);
if($req && $country){
$ret .= "<h2>".$country->getName()."</h2>";
$ret .= "<p>".$req->getText()."</p>";
$ret .= "<hr>";
}
}
echo $ret;
die();
}
$travelProgram = $travelProgramPage->getTravelProgram();
if (!$request->query->has('nr'))
{
@ -90,6 +116,12 @@ class BookingController extends Controller
throw $this->createNotFoundException();
}
/**/
$nationalities = $this->getDoctrine()
->getRepository('AppBundle:TravelNationality')
->createQueryBuilder('n')
->getQuery()->getResult(Query::HYDRATE_ARRAY);;
/** @var BookingRequest $bookingRequest */
$bookingRequest = new BookingRequest();
@ -99,7 +131,8 @@ class BookingController extends Controller
}
$form = $this->createForm(BookingRequestType::class, $bookingRequest, [
'travel_date' => $travelDate,
'travel_program' => $travelProgram
'travel_program' => $travelProgram,
'nationalities' => $nationalities
]);
if ($request->getMethod() == 'POST')
{
@ -110,6 +143,8 @@ class BookingController extends Controller
$bookingPriceInfo = [];
$totalPrice = $this->calculatePrice($travelDate, $bookingRequest, $travelProgram->getCategory()->getId(), $travelProgram->getDepositPercent(), $htmlSummary, $bookingPriceInfo);
if ($action == '/buchen')
{
$breadcrumbEntries = Util::createBreadcrumb($travelProgramPage);