private function build_customise_page($layout = null, $layout_id, $size, $postcode, $saveSessionData = false) { // If layout is null get it from DB if ($layout === null) { $layout = $layout = Layouts::get_layoutsByCode($size); } // Make sure data is valid if (empty($size)) { // We have an error take user back to first step return Redirect::to_action('quotations')->with('error', 'Please pick a studio size')->with('size', $size)->with('postcode', $postcode); } elseif ($layout === false) { // We have an error take user back to first step return Redirect::to_action('quotations')->with('error', 'Unable to find the studio layout you have selected. Please select from the list below')->with('size', $size)->with('postcode', $postcode); } elseif (empty($postcode)) { // We have an error take user back to first step return Redirect::to_action('quotations/view/' . $layout_id)->with('error', 'Please provide post code')->with('size', $size)->with('postcode', $postcode); } elseif (!Postcodes::ValidOutcode($postcode)) { // We have an error take user back to first step return Redirect::to_action('quotations/view/' . $layout_id)->with('error', 'Postcode is not valid, please provide a valid UK postcode')->with('postcode', $postcode); } // Set session data so we remember in new requests // Its possible we may get here by skipping the initial price grid page and come in via the view studio info page if ($saveSessionData) { \Laravel\Session::put('quote_layout', $layout); \Laravel\Session::put('quote_layout_id', $layout_id); \Laravel\Session::put('quote_size', $size); \Laravel\Session::put('quote_postcode', $postcode); } // Calc available space based on studio size $slotsBreakdown = Layouts::layoutWallSlotsBreakdown($layout->id); $maximum_slots = $slotsBreakdown['totalSlots']; // Load page $data = new stdClass(); //$data->title = 'Customise Studio'; //$data->size = $size; //$data->postcode = $postcode; $data->layout = $layout; $data->maximum_slots = $maximum_slots; $data->allocated_doors_windows = $slotsBreakdown['singleLargeSideSlots']; // 1 door + remainder of the same side as windows for initial start $data->allocated_walls = $data->maximum_slots - $data->allocated_doors_windows; // Delivery information $data->delivery = Quotation::calcDeliver(); // Slots per single large / small side $data->sizeSlots = new stdClass(); $data->sizeSlots->singleLargeSideSlots = $slotsBreakdown['singleLargeSideSlots']; $data->sizeSlots->singleSmallSideSlots = $slotsBreakdown['singleSmallSideSlots']; // Costs $data->costs = new stdClass(); $data->costs->init_cost = Quotation::calcSessionQuotationCurrentValue('init'); $data->costs->swap_window_wall = QuotationPriceAdjustments::getPrice('swap_window_wall'); $data->costs->swap_wall_window = QuotationPriceAdjustments::getPrice('swap_wall_window'); $data->costs->add_extra_door = QuotationPriceAdjustments::getPrice('add_extra_door'); $data->costs->add_fanlight_window = QuotationPriceAdjustments::getPrice('add_fanlight_window'); $data->costs->add_half_window = QuotationPriceAdjustments::getPrice('add_half_window'); $data->costs->add_1820_window = QuotationPriceAdjustments::getPrice('add_1820_window'); // Notes $data->help = new stdClass(); $data->help->swap_window_wall = QuotationPriceAdjustments::getNote('swap_window_wall'); $data->help->swap_wall_window = QuotationPriceAdjustments::getNote('swap_wall_window'); $data->help->add_extra_door = QuotationPriceAdjustments::getNote('add_extra_door'); $data->help->add_fanlight_window = QuotationPriceAdjustments::getNote('add_fanlight_window'); $data->help->add_half_window = QuotationPriceAdjustments::getNote('add_half_window'); $data->help->add_1820_window = QuotationPriceAdjustments::getNote('add_1820_window'); // Field defaults $data->defaults = new stdClass(); $data->defaults->swap_window_wall = \Laravel\Session::get('quote_customise_swap_window', 0); $data->defaults->swap_wall_window = \Laravel\Session::get('quote_customise_swap_wall', 0); $data->defaults->add_extra_door = \Laravel\Session::get('quote_customise_extra_door', 0); $data->defaults->add_fanlight_window = \Laravel\Session::get('quote_customise_fanlight', 0); $data->defaults->add_half_window = \Laravel\Session::get('quote_customise_half_window', 0); $data->defaults->add_1820_window = \Laravel\Session::get('quote_customise_picture_window', 0); return View::make('quotations.customise')->with('data', $data); }