HEX
Server: Apache
System: Linux v38079.2is.nl 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: democfellows (10015)
PHP: 8.1.34
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/creativefellows.nl/okaycolor.creativefellows.nl/views/admin/properties.php
<?php
	

	/*
 	 * Header
	 */
	require_once __DIR__ . '/inc/header.inc.php';
	
	
	/*
 	 *  Sidebar
	 */
	require_once __DIR__ . '/inc/sidebar.inc.php';
	
		
	/*
 	 *  Content
	 */
	echo '<div class="cell auto content">';
	
		echo '<div class="grid-x">';
			echo '<div class="cell small-12">';
				
				echo '<h2>'. ucfirst($data["current"]) .'<a href="'. $router->pathFor("admin.section",["section" => $data["current"]]) .'" class="button primary align-right">Nieuw</a></h2>';
				
				echo '<div class="grid-x grid-padding-x block-white">';
					
					
					/*
					 * Sidebar list
					 */
					echo '<div class="cell small-12 medium-3">';
						echo '<ul class="vertical menu">';
						foreach($data["items"] as $item)
						{
							echo '<li>';
								echo '<a>'.  $item->getName() .'</a>';
								
								echo '<ul class="menu vertical subitems">';
								foreach( $item->getGroups() as $group )
								{	
									$link = $router->pathFor("admin.section.view",["section" => $data["current"], "id" => $group->getId() ]);
									echo '<li><a href="'. $link .'">'.  $group->getAdminName() .'</a></li>';
								}
								echo '</ul>';
								
							echo '</li>';
						}
						echo '</ul>';
					echo '</div>';
					
					
					echo '<div class="cell small-12 medium-9">';
						
						/*
						 * View selected
						 */
						if($active_item !== null)
						{
						
							echo '<form class="default-form" action="'. $router->pathFor("admin.section.patch",["section" => $data["current"], "id" => $active_item->getGroupId() ]) .'" method="post" enctype="multipart/form-data">';
							echo '<h3>'. $active_item->getName() .'</h3>';
						
							/*
							 * Default property fields
							 */
							foreach($data["fields"] as $field)
							{
								$value = $active_item->getValue( $field->getName() );
								$field->setValue( $value ); 
							
								echo $field->getInput();
							
							}
	
									
							/*
							 * property options
							 */
							echo '<div class="grid-x grid-padding-x">';
								echo '<div class="cell auto">';
									echo '<label for="name" class="input-name">Opties</label>';
								echo '</div>';
							echo '</div>';
							
							//d($active_item);
							//d( $active_item->getOptions() );
							
							/* 
							 * headers 
							 */
							echo '<div class="grid-x grid-padding-x">';
							echo '<div class="cell small-12"><br /></div>';
								foreach($active_item->getFields() as $field => $array)
								{	

									if( !isset($array["sub"]) && $array[1] != "hidden")
									{	
										$size = $array[0] == "position" ? "small-1" : "auto";
										
										echo '<div class="cell '. $size .'">';
											echo '<label class="input-name">'. ucfirst($array[0]) .'</label>';
										echo '</div>';
										
									}						
								}
								echo '<div class="cell small-1 align-center" style="width:3rem"></div>';
							echo '</div>';
							
							foreach($active_item->getOptions() as $row_count => $option)
							{
								
							
								
								/*
								 * Body Rows
								 */
								echo '<div class="grid-x grid-padding-x property-row draggable">';
									
									$show_weights = null;
									
									//echo '<ul class="no-bullet draggable list">';


									/*
									 * Group names & input fields
									 */		
									//echo '<div class="cell small-11"  id="'. $product["product_id"] .'">';
									//	echo '<div class="grid-x grid-padding-x">';				
									foreach($active_item->getFields() as $field => $array)
									{	
										
											$size = isset($array[3]) ? $array[3] : "auto";
											if($array[0] == "position") $size = "small-1 handle-element";
							
											if($array[1] == "input")
											{
												echo '<div class="cell '. $size .'">';
													echo '<input type="text" name="field_'. $array[0] .'[]" value="'. $option->getInputValue($array[0]) .'" autocomplete="off" />';
												echo '</div>';
											}
											elseif($array[1] == "select")
											{
												echo '<div class="cell '. $size .'">';
													echo '<select name="field_'. $array[0] .'[]" >';
														foreach($array["options"] as $id => $value)
														{
															echo  '<option value="'. $id .'"'. ($id == $option->getInputValue($array[0]) ? "selected" : "") .'>'. $value .'</option>';
														}
													echo '</select>';
												echo '</div>';
											}
											else $show_weights = $array;
								
								
									}								
										//echo '</div>';
									//echo '</div>';
									
									/*
									 * Grip lines
									 */
									
								//echo '<div class="cell small-1 align-center" style="width:3rem">';
									//	echo '<span class="handle-draggable float-right"><i class="fal fa-grip-lines"></i></span>';
									//echo '</div>';
								
									
									/*
									 * Remove current rows
									 */	
									echo '<div class="cell small-1 align-center" style="width:3rem">';
										echo '<input type="hidden" name="id_column[]" value="'. $option->getId() .'" />';
										echo '<input type="hidden" name="name_column[]" value="'. $option->getIdColumn() .'" />';
										echo '<a class="delete-row"><i class="fal fa-minus-square"></i></a>';
									echo '</div>';
									
									
									
								echo '</div>';	
								
								
								/*
								 * Sub options for material weight
								 */
								if($show_weights)
								{
									
									// loop option children
									foreach($option->getChildren() as $i => $child)
									{
										echo '<div class="grid-x grid-padding-x property-row">';
										
											foreach($show_weights["sub"] as $field => $array)
											{
												$size = $array[0] == "position" ? "small-1" : "auto";
												
												if($array[1] == "input")
												{
													echo '<div class="cell '. $size .'">';
														echo '<input type="text" name="field'. $row_count .'_'. $array[0] .'[]" placeholder="'. $array[0] .'" value="'. $child->getInputValue($array[0]) .'" autocomplete="off" />';
													echo '</div>';
												}
												else{
									
													echo '<div class="cell '. $size .'">';
														echo '<select name="field'. $row_count .'_'. $array[0] .'[]" >';
															echo  '<option value="">---</option>';
															foreach($array["options"] as $id => $value)
															{
																echo  '<option value="'. $id .'"'. ($id == $child->getInputValue($array[0]) ? "selected" : "") .'>'. $value .'</option>';
															}
														echo '</select>';
													echo '</div>';
													
												}
											}
										
											echo '<div class="cell small-1 align-center" style="width:3rem">';
												echo '<input type="hidden" name="id_'. $row_count .'subcolumn[]" value="'. $child->getId() .'" />';
												echo '<input type="hidden" name="name_'. $row_count .'subcolumn[]" value="'. $child->getIdColumn() .'" />';
												echo '<a class="delete-row"><i class="fal fa-minus-square"></i></a>';
											echo '</div>';
										
								
										echo '</div>';
									}		
									
									echo '<div class="grid-x grid-padding-x property-row">';
										
										foreach($show_weights["sub"] as $field => $array)
										{	
											$size = $array[0] == "position" ? "small-1" : "auto";
											
											if($array[1] == "input")
											{
												echo '<div class="cell '. $size .'">';
													echo '<input type="text" name="field'. $row_count .'_'. $array[0] .'[]" placeholder="'. $array[0] .'" autocomplete="off" />';
												echo '</div>';
											}
											elseif($array[1] == "select"){
									
												echo '<div class="cell '. $size .'">';
													echo '<select name="field'. $row_count .'_'. $array[0] .'[]" >';
													echo  '<option value="">---</option>';
										
														foreach($array["options"] as $id => $value)
														{
															echo  '<option value="'. $id .'">'. $value .'</option>';
														}
													echo '</select>';
												echo '</div>';
											}
										}
										
										echo '<div class="cell small-1 align-center" style="width:3rem">';
											echo '<input type="hidden" name="id_'. $row_count .'subcolumn[]" value="0" />';
											echo '<input type="hidden" name="name_'. $row_count .'subcolumn[]" value="'. $active_item->getIdField() .'" />';
											echo '<a class="duplicate-row"><i class="fal fa-plus-square"></i></a>';
										echo '</div>';
										
									echo '</div>';
								}
						
							}
							
							
							/*
							 * NEW Empty Row
							 */
							echo '<div class="grid-x grid-padding-x property-row">';
								
								echo '<div class="cell small-12"><br /></div>';
								
								foreach($active_item->getFields() as $field => $array)
								{	
									$size = isset($array[3]) ? $array[3] : "auto";
									if($array[0] == "position") $size = "small-1 handle-element";
											
									if($array[1] == "input")
									{
										echo '<div class="cell '. $size .'">';
											echo '<input type="text" name="field_'. $array[0] .'[]" placeholder="'. $array[0] .'" autocomplete="off" />';
										echo '</div>';
									}
									elseif($array[1] == "select"){
									
										echo '<div class="cell '. $size .'">';
											echo '<select name="field_'. $array[0] .'[]" >';
											echo  '<option value="">---</option>';
										
												foreach($array["options"] as $id => $value)
												{
													echo  '<option value="'. $id .'">'. $value .'</option>';
												}
											echo '</select>';
										echo '</div>';
									}
								
								}
								
								echo '<div class="cell small-1 align-center" style="width:3rem">';
									echo '<input type="hidden" name="id_column[]" value="0" />';
									echo '<input type="hidden" name="name_column[]" value="0" />';
									echo '<a class="duplicate-row"><i class="fal fa-plus-square"></i></a>';
								echo '</div>';
							
							echo '</div>';
							
							
							// spacer 1 line
							echo '<br />';
							
							
							/*
							 * Submit new 
							 */
							echo '<input type="hidden" name="_METHOD" value="PATCH"/>';							
							echo '<button type="submit" class="button hollow primary">Opslaan</button>';
							echo '<a href="'. $router->pathFor("admin.section.delete", ["section" => $data["current"], "id" => $active_item->getId() ]) .'" class="button delete align-right"><i class="fal fa-trash-alt"></i></a>';
						
							echo '</form>';
							
							
							
							
						}
						/*
						 * New item
						 */
						else
						{
							
							echo '<form class="default-form" action="'. $router->pathFor("admin.section.post",["section" => $data["current"]]) .'" method="post" enctype="multipart/form-data">';
								echo '<h3>Nieuw</h3>';
						
								foreach($data["fields"] as $field)
								{	
									echo $field->getInput();
								}
						
								echo '<button type="submit" class="button hollow primary">Toevoegen</button>';
							echo '</form>';
							
						}
						
						
					echo '</div>';
				echo '</div>';
				

				
				
			echo '</div>';
		echo '</div>';
	
	echo '</div>';
	// End of content
	
	
	
	/*
 	 * Footer
	 */
	require_once __DIR__ . '/inc/footer.inc.php';

//	d($data["items"]);
	
//	d($active_item);

?>