<!--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 Menu</h1>

<div class="col-lg-12">
	<div class="panel panel-info">
		<div class="panel-heading">Create New 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/createMenuDb',$attributes);


                    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'
			                    );
			                    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'
			                    );
			                    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">Breakfast</option>';
			                    	echo '<option value="2">Lunch</option>';
			                    	echo '<option value="3">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' => 'Starter'
				                    );
				                echo form_input($starter_array);
		                	echo "</div>";
	                		echo "<div class='col-lg-8'><div class='panel panel-default'><div class='panel-body droppable-starter'></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' => 'First'
				                    );
				                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'></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' => 'Second'
				                    );
				                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'></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' => 'Sweet'
				                    );
				                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'></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' => 'Other'
				                    );
				                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'></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' => 'Wine'
				                    );
				                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='other'></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' => 'Create 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 -->


<div class="col-lg-12">
	<div class="panel panel-info">
		<div class="panel-heading">Menu List</div> 
		<div class="panel-body">
			
			<div class="table-responsive">
				<table class="table table-striped table-bordered" id="myTable">
                    <thead>
                            <tr>
                                    <th>Date</th>
                                    <th>Type</th>
                                    <th>Title</th>
                                    <th>Azioni</th>
                            </tr>
                    </thead>
                    <tbody>
                        <?php foreach($menuFromDb->result() as $row): ?>
                        <tr>
                            <td><?php echo $row->date; ?></td>
                            <td><?php //Metto il nome del pasto e non il numero
                            	switch ($row->type) {
						            case 1: echo "Breakfast"; break;
						            case 2: echo "Lunch"; break;
						            case 3: echo "Dinner"; break;
						        }
                            ?></td>
                            <td><?php echo $row->title; ?></td>
                            <td>
                                <div class="btn-group">
                                    <a href="<?php echo base_url();?>index.php/menu/modifySingleMenu/<?php echo $row->id;?>" class="btn btn-info"><i class="fa fa-pencil"></i></a>
                                    <a class="btn btn-danger" href="<?php echo base_url();?>index.php/menu/deleteMenuDb/<?php echo $row->id;?>"><i class="fa fa-trash-o"></i></a>
                                </div>
                            </td>
                        </tr>

                    	<?php endforeach; ?>
                    </tbody>
	    		</table>
	    	</div>

		</div>
	</div><!-- Chiusura panel info per la lista dei menu -->
</div><!-- Chiusura container -->