<?php 
$currentSet = $_GET['id'];
$datiSet = $connection->query("SELECT * FROM comments_sets WHERE id = '$currentSet'");
$infoSet = $datiSet->fetchAll();
$setName = $infoSet[0]['set_name'];
$setLanguage = $infoSet[0]['set_language'];
$dati = $connection->query("SELECT * FROM comments WHERE sets_in = '$currentSet' AND isChildren = 0");
?>
<div class="kt-portlet kt-portlet--mobile">
	<div class="kt-portlet__body">
<form id="kt_form" action="be_services/sharing/edit_comment_set.php" method="POST">
<div class="form-group">
	<input type="hidden" name="questionSetId" value="<?php echo $infoSet[0]['id']; ?>">
																	<label>Nome del set di domande</label>
													<input type="text" class="form-control" name="commentSetName" placeholder="Inserisci il nome del nuovo set" value="<?php echo $setName; ?>">
																</div>
																<div class="form-group">
																	<label>Lingua del set di comment</label>
													<select class="form-control kt-select2" id="kt_select2_3" name="questionSetLanguage">
													<option></option>
<?php
													$setClienti = $connection->query("SELECT * FROM languages ORDER BY name ASC");
													while($set = $setClienti->fetch())
													{
													$selected = "";
														if($set['id'] == $setLanguage)
														{
															$selected = "selected";
														}
													?>
														<option value="<?php echo $set['id']; ?>" <?php echo $selected; ?>><?php echo $set['name']; ?></option>
													<?php	
													}
													?>
												</select>
																</div>




<div id="kt_repeater_3"> <!-- contenitore repeater -->
																				
																		<div class="form-group row">
																			<div data-repeater-list="domande" class="col-lg-12"> <!-- repeater esterno (domanda) -->
																				
																				<?php 
																				while($datiDom = $dati->fetch(PDO::FETCH_ASSOC))
																				{
																					
																					$idDomanda = $datiDom['id'];

																					$risposte = $connection->query("SELECT * FROM comments WHERE isChildren = '1' AND parentComment = '$idDomanda'");
?>
																				<div data-repeater-item>

<div class="kt-portlet kt-portlet--bordered">
					<div class="kt-portlet__head">
						<div class="kt-portlet__head-label">
							<h3 class="kt-portlet__head-title">
								COMMENTO - <a href="javascript:;" data-repeater-delete="" class="btn btn-danger">
																			<i class="la la-remove"></i>
																			<span> Elimina commento </span>
																		</a>
							</h3>
						</div>
					</div>
					<div class="kt-portlet__body">
																					
																			<label>Commento</label>
																			<input type="text" class="form-control" name="domanda" placeholder="Testo del commento" value="<?php echo $datiDom['text']; ?>">
																		
															<label>Commenti annidati:</label>
															  <div class="inner-repeater">
																<div data-repeater-list="risposte"> <!-- repeater interno (risposte) -->
																	<?php 
																				while($datiRis = $risposte->fetch(PDO::FETCH_ASSOC))
																				{
																	?>				
																					

																	 <div data-repeater-item class="col-lg-12 row kt-margin-b-10">
																	<div class="col-lg-10">
																		<div class="input-group">
																			<div class="input-group-prepend">
																				<span class="input-group-text">
																					<i class="la la-question"></i>
																				</span>
																			</div>
																			<input type="text" class="form-control form-control-danger" placeholder="Testo commento annidato..." name="risposta" value="<?php echo $datiRis['text']; ?>">
																		</div>
																	</div>
																	<div class="col-lg-2">
																		<a href="javascript:;" data-repeater-delete="" class="btn btn-danger btn-icon">
																			<i class="la la-remove"></i>
																		</a>
																	</div>
																</div>
																<?php 
																}
																?>
																</div>

																<div data-repeater-create="" class="btn btn btn-primary">
																	<span>
																		<i class="la la-plus"></i>
																		<span>Aggiungi risposta</span>
																	</span>
																</div>
															</div>
															
																	</div>
															</div>			
															</div> <!-- fine domanda -->

<?php
}
?>

															</div>
														</div>
<!-- fine div form domande -->

														<div class="row"> 
															<div class="col-lg-3"></div>
															<div class="col">
																<div data-repeater-create="" class="btn btn btn-primary">
																	<span>
																		<i class="la la-plus"></i>
																		<span>Aggiungi commento</span>
																	</span>
																</div>
															</div>
														</div>

															</div>
															<button class="btn btn-success btn-md btn-tall btn-wide kt-font-bold kt-font-transform-u" data-ktwizard-type="action-submit">
															Modifica set di commenti
														</button>
</form>
														</div></div>
													


<script type="text/javascript" charset="UTF-8" src="assets/js/pages/questionset/questionsets.js"></script> 