public function post_pricing_view()
 {
     $price = QuotationPriceAdjustments::find(URI::Segment(4));
     $update_layout = array('friendly_name' => trim(Input::get('friendly_name')), 'note' => trim(Input::get('note')));
     $price->update($price->id, $update_layout);
     return Redirect::to('/user/quotations/pricing_view/' . $price->id)->with('success', 'Update successfull');
 }
 public static function getNote($name)
 {
     $priceQuery = QuotationPriceAdjustments::where('name', '=', $name)->first();
     if ($priceQuery !== null) {
         return $priceQuery->note;
     }
     return '';
 }
 private function build_other_page()
 {
     $data = new stdClass();
     // Delivery information
     $data->delivery = Quotation::calcDeliver();
     // Costs
     $data->costs = new stdClass();
     $data->costs->init_cost = Quotation::calcSessionQuotationCurrentValue('interior');
     $data->costs->decoupled_floor = QuotationPriceAdjustments::getPrice('other_decoupled_floor');
     $data->costs->aquastep_oak_floor = QuotationPriceAdjustments::getPrice('other_aquastep_oak_floor');
     $data->costs->walls_to_timber = QuotationPriceAdjustments::getPrice('other_walls_to_timber');
     $data->costs->taller_walls = QuotationPriceAdjustments::getPrice('other_taller_walls');
     $data->costs->entry_steps = QuotationPriceAdjustments::getPrice('other_entry_steps');
     $data->costs->entry_handrail = QuotationPriceAdjustments::getPrice('other_entry_handrail');
     $data->costs->skirt = QuotationPriceAdjustments::getPrice('other_skirt');
     // Notes
     $data->help = new stdClass();
     $data->help->decoupled_floor = QuotationPriceAdjustments::getNote('other_decoupled_floor');
     $data->help->aquastep_oak_floor = QuotationPriceAdjustments::getNote('other_aquastep_oak_floor');
     $data->help->walls_to_timber = QuotationPriceAdjustments::getNote('other_walls_to_timber');
     $data->help->taller_walls = QuotationPriceAdjustments::getNote('other_taller_walls');
     $data->help->entry_steps = QuotationPriceAdjustments::getNote('other_entry_steps');
     $data->help->entry_handrail = QuotationPriceAdjustments::getNote('other_entry_handrail');
     $data->help->skirt = QuotationPriceAdjustments::getNote('other_skirt');
     // Field defaults
     $data->defaults = new stdClass();
     $data->defaults->decoupled_floor = \Laravel\Session::get('quote_other_decoupled_floor', 0);
     $data->defaults->aquastep_oak_floor = \Laravel\Session::get('quote_other_aquastep_oak_floor', 0);
     $data->defaults->walls_to_timber = \Laravel\Session::get('quote_other_walls_to_timber', 0);
     $data->defaults->taller_walls = \Laravel\Session::get('quote_other_taller_walls', 0);
     $data->defaults->entry_steps = \Laravel\Session::get('quote_other_entry_steps', 0);
     $data->defaults->entry_handrail = \Laravel\Session::get('quote_other_entry_handrail', 0);
     $data->defaults->skirt = \Laravel\Session::get('quote_other_skirt', 0);
     return View::make('quotations.add_other')->with('data', $data);
 }
 public static function calcSessionQuotationCurrentValue($upTo)
 {
     $price = 0;
     // Init stage
     $layout = \Laravel\Session::get('quote_layout');
     $price = $layout->cost;
     $deliveryData = self::calcDeliver();
     $price = $price + $deliveryData['price'];
     if ($upTo == "init") {
         return (double) $price;
     }
     // Customise stage - Stage 1
     $price = $price + \Laravel\Session::get('quote_customise_swap_window', 0) * QuotationPriceAdjustments::getPrice('swap_window_wall');
     $price = $price + \Laravel\Session::get('quote_customise_swap_wall', 0) * QuotationPriceAdjustments::getPrice('swap_wall_window');
     $price = $price + \Laravel\Session::get('quote_customise_extra_door', 0) * QuotationPriceAdjustments::getPrice('add_extra_door');
     $price = $price + \Laravel\Session::get('quote_customise_fanlight', 0) * QuotationPriceAdjustments::getPrice('add_fanlight_window');
     $price = $price + \Laravel\Session::get('quote_customise_half_window', 0) * QuotationPriceAdjustments::getPrice('add_half_window');
     $price = $price + \Laravel\Session::get('quote_customise_picture_window', 0) * QuotationPriceAdjustments::getPrice('add_1820_window');
     if ($upTo == "customise") {
         return (double) $price;
     }
     // Decking / Flyover stage - Stage 2
     $price = $price + \Laravel\Session::get('quote_decking_composite_deck_910_910', 0) * QuotationPriceAdjustments::getPrice('composite_deck_910_910');
     $price = $price + \Laravel\Session::get('quote_decking_composite_deck_910_1820', 0) * QuotationPriceAdjustments::getPrice('composite_deck_910_1820');
     $price = $price + \Laravel\Session::get('quote_decking_composite_deck_910_2730', 0) * QuotationPriceAdjustments::getPrice('composite_deck_910_2730');
     $price = $price + \Laravel\Session::get('quote_decking_flyover_roof_910_910', 0) * QuotationPriceAdjustments::getPrice('flyover_roof_910_910');
     $price = $price + \Laravel\Session::get('quote_decking_flyover_roof_910_1820', 0) * QuotationPriceAdjustments::getPrice('flyover_roof_910_1820');
     $price = $price + \Laravel\Session::get('quote_decking_flyover_roof_910_2730', 0) * QuotationPriceAdjustments::getPrice('flyover_roof_910_2730');
     if ($upTo == "deckingflyover") {
         return (double) $price;
     }
     // Electrics stage - Stage 3
     $price = $price + \Laravel\Session::get('quote_electrics_double_sockets_450', 0) * QuotationPriceAdjustments::getPrice('electrics_double_sockets_450');
     $price = $price + \Laravel\Session::get('quote_electrics_double_sockets_1150', 0) * QuotationPriceAdjustments::getPrice('electrics_double_sockets_1150');
     $price = $price + \Laravel\Session::get('quote_electrics_light_switch', 0) * QuotationPriceAdjustments::getPrice('electrics_light_switch');
     $price = $price + \Laravel\Session::get('quote_electrics_panel_heater', 0) * QuotationPriceAdjustments::getPrice('electrics_panel_heater');
     $price = $price + \Laravel\Session::get('quote_electrics_double_floor_socket', 0) * QuotationPriceAdjustments::getPrice('electrics_double_floor_socket');
     $price = $price + \Laravel\Session::get('quote_electrics_fused_spur_socket', 0) * QuotationPriceAdjustments::getPrice('electrics_fused_spur_socket');
     if ($upTo == "electrics") {
         return (double) $price;
     }
     // Electrics stage - Stage 4
     $price = $price + \Laravel\Session::get('quote_internals_silver_aluminium_venitian_blind_no_screws', 0) * QuotationPriceAdjustments::getPrice('silver_aluminium_venitian_blind_no_screws');
     $price = $price + \Laravel\Session::get('quote_internals_recessed_blinds', 0) * QuotationPriceAdjustments::getPrice('recessed_blinds');
     $price = $price + \Laravel\Session::get('quote_internals_internal_910_partition_wall', 0) * QuotationPriceAdjustments::getPrice('internal_910_partition_wall');
     $price = $price + \Laravel\Session::get('quote_internals_internal_door_dividing_studio', 0) * QuotationPriceAdjustments::getPrice('internal_door_dividing_studio');
     $price = $price + \Laravel\Session::get('quote_internals_internal_wall_corner_post', 0) * QuotationPriceAdjustments::getPrice('internal_wall_corner_post');
     if ($upTo == "interior") {
         return (double) $price;
     }
     // Other stage - Stage 5
     $price = $price + \Laravel\Session::get('quote_other_decoupled_floor', 0) * QuotationPriceAdjustments::getPrice('other_decoupled_floor');
     $price = $price + \Laravel\Session::get('quote_other_aquastep_oak_floor', 0) * QuotationPriceAdjustments::getPrice('other_aquastep_oak_floor');
     $price = $price + \Laravel\Session::get('quote_other_walls_to_timber', 0) * QuotationPriceAdjustments::getPrice('other_walls_to_timber');
     $price = $price + \Laravel\Session::get('quote_other_taller_walls', 0) * QuotationPriceAdjustments::getPrice('other_taller_walls');
     $price = $price + \Laravel\Session::get('quote_other_entry_steps', 0) * QuotationPriceAdjustments::getPrice('other_entry_steps');
     $price = $price + \Laravel\Session::get('quote_other_entry_handrail', 0) * QuotationPriceAdjustments::getPrice('other_entry_handrail');
     $price = $price + \Laravel\Session::get('quote_other_skirt', 0) * QuotationPriceAdjustments::getPrice('other_skirt');
     if ($upTo == "other") {
         return (double) $price;
     }
     return $price;
 }