<!--Copyright (C) 2014  Web3king - Alberto Bonacina

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->

<h1>Manage Single Menu</h1>

<div class="col-lg-12">
	<div class="panel panel-info">
		<div class="panel-heading">Update Menu</div> 
		<div class="panel-body">

			<div class="row">
				<div class="container-fluid col-lg-12">
						<ul class="nav nav-tabs nav-justified">
						  <li class="active"><a href="#start" data-toggle="tab">Starters</a></li>
						  <li><a href="#first" data-toggle="tab">First</a></li>
						  <li><a href="#second" data-toggle="tab">Second</a></li>
						  <li><a href="#sweet" data-toggle="tab">Sweet</a></li>
						  <li><a href="#other" data-toggle="tab">Other</a></li>
						  <li><a href="#wine" data-toggle="tab">Wine</a></li>
						</ul>

						<!-- Tab panes -->
						<div class="tab-content">
						  <div class="tab-pane active" id="start">
					  		<div class="panel panel-default">
							  	<div class="panel-body draggable">
							    	<?php foreach($starter->result() as $st): 
				                    	//echo '';
				                    	echo '<span type="button" name="'.$st->name.'" id="'.$st->id.'" class="btn btn-info bottoni-selezionati">'.$st->name.'</span>';
				                    	//echo '';
									endforeach; ?>
								</div>
					  		</div>
						  </div>

						  <div class="tab-pane" id="first">
						  	<div class="panel panel-default">
							  	<div class="panel-body draggable">
							    	<?php foreach($first->result() as $fr): 
				                    	//echo ''; 
				                    	echo '<span type="button" name="'.$fr->name.'" id="'.$fr->id.'" class="btn btn-info bottoni-selezionati">'.$fr->name.'</span>';
				                    	//echo '';
									endforeach; ?>
								</div>
					  		</div>
						  </div>

						  <div class="tab-pane" id="second">
							<div class="panel panel-default">
							  	<div class="panel-body draggable">
							    	<?php foreach($second->result() as $sc): 
				                    	//echo '';
				                    	echo '<span type="button" name="'.$sc->name.'" id="'.$sc->id.'" class="btn btn-info bottoni-selezionati">'.$sc->name.'</span>';
				                    	//echo '';
									endforeach; ?>
								</div>
					  		</div>
						  </div>

						  <div class="tab-pane" id="sweet">
						  	<div class="panel panel-default">
							  	<div class="panel-body draggable">
							    	<?php foreach($sweet->result() as $sw): 
				                    	//echo '';
				                    	echo '<span type="button" name="'.$sw->name.'" id="'.$sw->id.'" class="btn btn-info bottoni-selezionati">'.$sw->name.'</span>';
				                    	//echo '';
									endforeach; ?>
								</div>
					  		</div>
						  </div>

						  <div class="tab-pane" id="other">
						  	<div class="panel panel-default">
							  	<div class="panel-body draggable">
							    	<?php foreach($other->result() as $ot): 
				                    	//echo '';
				                    	echo '<span type="button" name="'.$ot->name.'" id="'.$ot->id.'" class="btn btn-info bottoni-selezionati">'.$ot->name.'</span>';
				                    	//echo '';
									endforeach; ?>
								</div>
					  		</div>
						  </div>

						  <div class="tab-pane" id="wine">
						  	<div class="panel panel-default">
							  	<div class="panel-body draggable">
							    	<?php foreach($wine->result() as $wn): 
				                    	//echo '';
				                    	echo '<span type="button" name="'.$wn->name.'" id="'.$wn->id.'" class="btn btn-info bottoni-selezionati">'.$wn->name.'</span>';
				                    	//echo '';
									endforeach; ?>
								</div>
					  		</div>
						  </div>
						</div>
				</div>
			</div><!--Fine della row che contiene la tab-->


			<div class="row-fluid">
			    <?php   
                    $attributes = array('role' => 'form', 'class' => 'form-horizontal');
                    echo form_open('menu/updateMenuDb',$attributes);
                    echo form_hidden('id',$singlemenu['id']);

                    echo "<div class='row'><div class='col-lg-3'>";
	                    echo "<div class='form-group'>";
		                    echo '<label for="date" class="col-lg-2 control-label">Date</label>';
		                    echo '<div class="col-lg-6">';
			                    $nome_array = array('type' => 'text',
			                        'name' => 'date',
			                        'class' => 'form-control',
			                        'id' => 'datepicker',
			                        'value' => $singlemenu['date']
			                    );
			                    echo form_input($nome_array);
		                    echo '</div>';
	                    echo "</div>";
	                echo "</div><div class='col-lg-6'>";
						echo "<div class='form-group'>";
		                    echo '<label for="date" class="col-lg-2 control-label">Title</label>';
		                    echo '<div class="col-lg-10">';
			                    $title_array = array('type' => 'text',
			                        'name' => 'title',
			                        'class' => 'form-control',
			                        'value' => $singlemenu['title']
			                    );
			                    echo form_input($title_array);
		                    echo '</div>';
	                    echo "</div>";
	                echo "</div><div class='col-lg-3'>";
	                    echo "<div class='form-group'>";
		                    echo '<label for="type-name" class="col-lg-2 col-lg-offset-4 control-label">Time</label>';
		                    echo '<div class="col-lg-6">';
		                    	echo '<select name="type" class="form-control">';
			                    	echo '<option value="1" '; if($singlemenu['type']=='1'){ echo 'selected="selected"';} echo '>Breakfast</option>';
			                    	echo '<option value="2" '; if($singlemenu['type']=='2'){ echo 'selected="selected"';} echo '>Lunch</option>';
			                    	echo '<option value="3" '; if($singlemenu['type']=='3'){ echo 'selected="selected"';} echo '>Dinner</option>';
								echo "</select>";
		                    echo '</div>';
	                    echo "</div>";
	                echo "</div></div>";

	                echo "<div class='row'>";
	                	echo "<div class='col-lg-6'>";
		                	echo "<div class='col-lg-4'>";
		                		$starter_array = array('type' => 'text',
				                        'name' => 'starter-name',
				                        'class' => 'form-control',
				                        'value' => $singlemenu['starter_name']
				                    );
				                echo form_input($starter_array);
		                	echo "</div>";
	                		echo "<div class='col-lg-8'><div class='panel panel-default'><div class='panel-body droppable-starter ui-droppable ui-sortable' id='starter'>";
	      
	                			if($singlemenu_starter){
	                				foreach ($singlemenu_starter as $smst) {
	                					echo "<div class='col-lg-12 riga-selezionata'>";
	                					echo "<input name='starter[]' type='checkbox' class='starter bigCheckbox' value='".$smst['id']."' checked='checked'> ".$smst['name'];
	                					echo "</div>";
	                				}
	                			}
	                			
	                		echo "</div></div></div>";
		               	echo "</div>";
		               	echo "<div class='col-lg-6'>";
		                	echo "<div class='col-lg-4'>";
		                		$first_array = array('type' => 'text',
				                        'name' => 'first-name',
				                        'class' => 'form-control',
				                        'value' => $singlemenu['first_name']
				                    );
				                echo form_input($first_array);
		                	echo "</div>";
	                		echo "<div class='col-lg-8'><div class='panel panel-default'><div class='panel-body droppable-first' id='first'>";

	                			if($singlemenu_first){
	                				foreach ($singlemenu_first as $smft) {
	                					echo "<div class='col-lg-12 riga-selezionata'>";
	                					echo "<input name='first[]' type='checkbox' class='first bigCheckbox' value='".$smft['id']."' checked='checked'> ".$smft['name'];
	                					echo "</div>";
	                				}
	                			}
	                			
	                		echo "</div></div></div>";
		                echo "</div>";
		            echo "</div>";	

					echo "<div class='row'>";
	                	echo "<div class='col-lg-6'>";
		                	echo "<div class='col-lg-4'>";
								$second_array = array('type' => 'text',
				                        'name' => 'second-name',
				                        'class' => 'form-control',
				                        'value' => $singlemenu['second_name']
				                    );
				                echo form_input($second_array);
		                	echo "</div>";
	                		echo "<div class='col-lg-8'><div class='panel panel-default'><div class='panel-body droppable-second' id='second'>";
																	
	                			if($singlemenu_second){
	                				foreach ($singlemenu_second as $smsc) {
	                					echo "<div class='col-lg-12 riga-selezionata'>";
	                					echo "<input name='second[]' type='checkbox' class='second bigCheckbox' value='".$smsc['id']."' checked='checked'> ".$smsc['name'];
	                					echo "</div>";
	                				}
	                			}

	                		echo "</div></div></div>";
		                echo "</div>";
		               	echo "<div class='col-lg-6'>";	
		                	echo "<div class='col-lg-4'>";
		                		$sweet_array = array('type' => 'text',
				                        'name' => 'sweet-name',
				                        'class' => 'form-control',
				                        'value' => $singlemenu['sweet_name']
				                    );
				                echo form_input($sweet_array);
		                	echo "</div>";
		                	echo "<div class='col-lg-8'><div class='panel panel-default'><div class='panel-body droppable-sweet' id='sweet'>";

	                			if($singlemenu_sweet){
	                				foreach ($singlemenu_sweet as $smsw) {
	                					echo "<div class='col-lg-12 riga-selezionata'>";
	                					echo "<input name='sweet[]' type='checkbox' class='sweet bigCheckbox' value='".$smsw['id']."' checked='checked'> ".$smsw['name'];
	                					echo "</div>";
	                				}
	                			}

	                		echo "</div></div></div>";
	                	echo "</div>";
		            echo "</div>";

	                echo "<div class='row'>";
	                	echo "<div class='col-lg-6'>";	
		                	echo "<div class='col-lg-4'>"; 
								$other_array = array('type' => 'text',
				                        'name' => 'other-name',
				                        'class' => 'form-control',
				                        'value' => $singlemenu['other_name']
				                    );
				                echo form_input($other_array);
		                	echo "</div>";
		                	echo "<div class='col-lg-8'><div class='panel panel-default'><div class='panel-body droppable-other' id='other'>";
		                		
	                			if($singlemenu_other){
	                				foreach ($singlemenu_other as $smot) {
	                					echo "<div class='col-lg-12 riga-selezionata'>";
	                					echo "<input name='other[]' type='checkbox' class='other bigCheckbox' value='".$smot['id']."' checked='checked'> ".$smot['name'];
	                					echo "</div>";
	                				}
	                			}
	                			
	                		echo "</div></div></div>";
	                	echo "</div>";
	                	echo "<div class='col-lg-6'>";	
		                	echo "<div class='col-lg-4'>"; 
								$wine_array = array('type' => 'text',
				                        'name' => 'wine-name',
				                        'class' => 'form-control',
				                        'value' => $singlemenu['wine_name']
				                    );
				                echo form_input($wine_array);
		                	echo "</div>";
		                	echo "<div class='col-lg-8'><div class='panel panel-default'><div class='panel-body droppable-wine' id='wine'>";

	                			if($singlemenu_wine){
	                				foreach ($singlemenu_wine as $smwi) {
	                					echo "<div class='col-lg-12 riga-selezionata'>";
	                					echo "<input name='wine[]' type='checkbox' class='wine bigCheckbox' value='".$smwi['id']."' checked='checked'> ".$smwi['name'];
	                					echo "</div>";
	                				}
	                			}
	                			
	                		echo "</div></div></div>";
	                	echo "</div>";
	                echo "</div>";

                    echo "<div class='form-group'>";
	                    echo '<div class="col-lg-offset-2 col-lg-2">';
		                    $button_array = array('class' => 'btn btn-primary',
		                        'type' => 'submit',
		                        'name' => 'submit',
		                        'value' => 'Update menu' 
		                    );
	                    echo form_submit($button_array);
	                    echo '</div>';
                    echo "</div>";

                   	echo form_close();                        
            	?>
            </div>


		</div>	
	</div><!-- Chiusura panel info per la creazione di un nuovo menu -->
</div><!-- Chiusura container -->
