<?php

extract( $this -> _formdata );

?>
<div class="grid_40col">
	<div class="grid_40col spacer"></div>
	<div class="grid_40col spacer"></div>
	<div id="sub_content_header" class="grid_40col tbl_head"><?php echo $this -> _lang[ 'userEdit' ]; ?></div>
	<div id="sub_content_main" class="grid_40col">
		<div class="grid_40col">
			<div class="grid_40col spacer"></div>
			<div class="grid_40col spacer"></div>
			<div class="grid_40col">
				<form action="index.php" name="userEdit" id="userEdit" method="post">
					<!-- Allgemeine Angaben -->
					<div class="grid_40col tbl_sub"><?php echo $this -> _lang[ 'commonFields' ]; ?></div>
					<br class="fix"/>
					<div class="grid_30col">
						<div class="grid_30col">
							<div class="grid_14col">
								<div class="grid_5col">
									<label for="userLastname"><?php echo $this -> _lang[ 'lastname:' ]; ?></label>
								</div>
								<div class="grid_9col">
									<input type="text" name="userLastname" id="userLastname" placeholder="<?php echo $this -> _lang[ 'lastname' ]; ?>" <?php echo ( isset( $userLastname ) ) ? 'value="' . $userLastname . '"' : ''; ?> />
								</div>
							</div>
							<div class="grid_2col spacer"></div>
							<div class="grid_14col">
								<div class="grid_5col">
									<label for="userFirstname"><?php echo $this -> _lang[ 'firstname:' ]; ?></label>
								</div>
								<div class="grid_9col">
									<input type="text" name="userFirstname" id="userFirstname" placeholder="<?php echo $this -> _lang[ 'firstname' ]; ?>" <?php echo ( isset( $userFirstname ) ) ? 'value="' . $userFirstname . '"' : ''; ?> />
								</div>
							</div>
						</div>
						<div class="grid_30col">
							<div class="grid_14col">
								<div class="grid_5col">
									<label for="userEmail"><?php echo $this -> _lang[ 'email:' ]; ?></label>
								</div>
								<div class="grid_9col">
									<input type="text" name="userEmail" id="userEmail" placeholder="<?php echo $this -> _lang[ 'email' ]; ?>" <?php echo ( isset( $userEmail ) ) ? 'value="' . $userEmail . '"' : ''; ?> />
								</div>
							</div>
							<div class="grid_2col spacer"></div>
							<div class="grid_14col">
								<div class="grid_5col">
									<label for="userPhone"><?php echo $this -> _lang[ 'phone:' ]; ?></label>
								</div>
								<div class="grid_9col">
									<input type="text" name="userPhone" id="userPhone" placeholder="<?php echo $this -> _lang[ 'phone' ]; ?>" <?php echo ( isset( $userPhone ) ) ? 'value="' . $userPhone . '"' : ''; ?> />
								</div>
							</div>
							<div class="grid_2col spacer"></div>
						</div>
						<div class="grid_30col spacer"></div>
						<br class="fix"/>
					</div>
					<div class="grid_10col spacer"></div>
					<br class="fix"/>
					<!-- Portal-Rechte -->
					<div class="grid_40col" id="portalRights">
						<div class="grid_40col tbl_sub"><?php echo $this -> _lang[ 'portalRights' ]; ?></div>
						<br class="fix"/>
						<div class="grid_40col hint"><?php echo $this -> _lang[ 'hintPortalRights' ]; ?></div>
						<br class="fix"/>
						<div class="grid_40col spacer"></div>
						<div class="grid_30col">
							<div class="grid_30col">
								<?php
								if ( $_SESSION[ 'sess_portalRightsType' ] === 'ALL' )
									{
										?>
										<div class="grid_14col">
											<div class="grid_5col">
												<label for="user_portalRightsType_ALL"><?php echo $this -> _lang[ 'allRights:' ]; ?></label>
											</div>
											<div class="grid_9col">
												<input class="all_rights" type="radio" onclick="$( '#user_portalRights_outer' ).hide( 400 );$( '.websiteRights' ).show( );" name="user_portalRightsType" id="user_portalRightsType_ALL" value="ALL" <?php echo ( isset( $user_portalRightsType ) && $user_portalRightsType === 'ALL' ) ? 'checked="checked"' : ''; ?> />
											</div>
										</div>
										<div class="grid_2col spacer"></div>
										<?php
									}
								?>
								<div class="grid_14col">
									<div class="grid_5col">
										<label for="user_portalRightsType_DEF"><?php echo $this -> _lang[ 'defRights:' ]; ?></label>
									</div>
									<div class="grid_9col">
										<input type="radio" onclick="$( '#user_portalRights_outer' ).show( 400 );checkDependence( );" name="user_portalRightsType" id="user_portalRightsType_DEF" value="DEF" <?php echo ( isset( $user_portalRightsType ) && $user_portalRightsType === 'DEF' || ! isset( $user_portalRightsType ) ) ? 'checked="checked"' : ''; ?>/>
									</div>
									<br class="fix"/>
									<div class="grid_14col spacer"></div>
									<div class="grid_14col box checkDependencies" id="user_portalRights_outer">
										<?php

										if ( isset ( $this -> _data[ 'portal_nav' ] ) && ! empty ( $this -> _data[ 'portal_nav' ] ) )
											{
												$nav	= clone ( $this );
												$nav	-> setPrefix( 'portal' );
												$nav	-> setTemplate( 'navirights' );
												$nav	-> setData( $this -> _data[ 'portal_nav' ] );
												$nav	-> setFormdata( $user_portalRights );
												echo $nav -> output( );
											}
											
										?>
									</div>
									<br class="fix"/>
								</div>
							</div>
							<div class="grid_30col spacer"></div>
						</div>
						<div class="grid_10col spacer"></div>
						<br class="fix"/>
					</div>
					<!-- Website-Rechte -->
					<?php
					
						if ( isset ( $this -> _data[ 'website_nav' ] ) && ! empty ( $this -> _data[ 'website_nav' ] ) )
							{
								foreach ( $this -> _data[ 'website_nav' ] as $website )
									{
										?>
										<div class="websiteRights grid_40col" id="<?php echo $this -> _website[ $website[ 'key' ] ][ 'prefix' ]; ?>Rights">
											<div class="grid_40col tbl_sub"><?php echo $this -> _website[ $website[ 'key' ] ][ 'names' ] . ' ' . $this -> _lang[ 'websiteRights' ]; ?></div>
											<br class="fix"/>
											<div class="grid_40col hint"><?php echo $this -> _lang[ 'hintWebsiteRights' ]; ?></div>
											<br class="fix"/>
											<div class="grid_40col spacer"></div>
											<div class="grid_30col">
												<?php
												if ( isset ( $_SESSION[ 'sess_' . $this -> _website[ $website[ 'key' ] ][ 'prefix' ] . 'Type' ] ) && $_SESSION[ 'sess_' . $this -> _website[ $website[ 'key' ] ][ 'prefix' ] . 'Type' ] === 'ALL' )
													{
														?>
														<div class="grid_14col">
															<div class="grid_5col">
																<label for="user_<?php echo $this -> _website[ $website[ 'key' ] ][ 'prefix' ]; ?>RightsType_ALL"><?php echo $this -> _lang[ 'allRights:' ]; ?></label>
															</div>
															<div class="grid_9col">
																<input class="all_rights" type="radio" onclick="$( '#user<?php echo $this -> _website[ $website[ 'key' ] ][ 'prefix' ]; ?>Rights_outer' ).hide( 400 );" name="user_<?php echo $this -> _website[ $website[ 'key' ] ][ 'prefix' ]; ?>RightsType" id="user_<?php echo $this -> _website[ $website[ 'key' ] ][ 'prefix' ]; ?>RightsType_ALL" value="ALL" <?php echo ( isset( ${'user_' . $this -> _website[ $website[ 'key' ] ][ 'prefix' ] . 'RightsType'} ) && ${'user_' . $this -> _website[ $website[ 'key' ] ][ 'prefix' ] . 'RightsType'} === 'ALL' ) ? 'checked="checked"' : ''; ?> />
															</div>
														</div>
														<div class="grid_2col spacer"></div>
														<?php
													}
												?>
												<div class="grid_14col">
													<div class="grid_5col">
														<label for="user_<?php echo $this -> _website[ $website[ 'key' ] ][ 'prefix' ]; ?>RightsType_DEF"><?php echo $this -> _lang[ 'defRights:' ]; ?></label>
													</div>
													<div class="grid_9col">
														<input type="radio" onclick="$( '#user<?php echo $this -> _website[ $website[ 'key' ] ][ 'prefix' ]; ?>Rights_outer' ).show( 400 );" name="user_<?php echo $this -> _website[ $website[ 'key' ] ][ 'prefix' ]; ?>RightsType" id="user_<?php echo $this -> _website[ $website[ 'key' ] ][ 'prefix' ]; ?>RightsType_DEF" value="DEF" <?php echo ( isset( ${'user_' . $this -> _website[ $website[ 'key' ] ][ 'prefix' ] . 'RightsType'} ) && ${'user_' . $this -> _website[ $website[ 'key' ] ][ 'prefix' ] . 'RightsType'} === 'DEF' || ! isset( ${'user_' . $this -> _website[ $website[ 'key' ] ][ 'prefix' ] . 'RightsType'} ) ) ? 'checked="checked"' : ''; ?>/>
													</div>
													<br class="fix"/>
													<div class="grid_14col spacer"></div>
													<div class="grid_14col box websiteRights" id="user<?php echo $this -> _website[ $website[ 'key' ] ][ 'prefix' ]; ?>Rights_outer">
														<?php
														
														if ( isset ( $website[ 'data' ] ) && ! empty ( $website[ 'data' ] ) )
															{
																$nav	= clone ( $this );
																$nav	-> setPrefix( $this -> _website[ $website[ 'key' ] ][ 'prefix' ] );
																$nav	-> setTemplate( 'navirights' );
																$nav	-> setData( $website[ 'data' ] );
																$nav	-> setFormdata( ${'user_' . $this -> _website[ $website[ 'key' ] ][ 'prefix' ] . 'Rights'} );
																echo $nav -> output( );
															}
															
														?>
													</div>
													<br class="fix"/>
												</div>
											</div>
											<script type="text/javascript">
												$( '#<?php echo $this -> _website[ $website[ 'key' ] ][ 'prefix' ]; ?>Rights' ).hide( );
												var <?php echo $this -> _website[ $website[ 'key' ] ][ 'prefix' ]; ?>Rights	= <?php echo json_encode ( explode ( ';' , $_SESSION[ 'sess_' . $this -> _website[ $website[ 'key' ] ][ 'prefix' ] ] ) ); ?>;
												$( 'input' , '#user<?php echo $this -> _website[ $website[ 'key' ] ][ 'prefix' ]; ?>Rights_outer' ).each( function ( key , elem )
													{
														if ( $.inArray( '<?php echo $this -> _website[ $website[ 'key' ] ][ 'prefix' ]; ?>_' + $( elem ).val( ) , <?php echo $this -> _website[ $website[ 'key' ] ][ 'prefix' ]; ?>Rights ) !== -1 )
															{
																$( elem ).prop( 'disabled' , false );
																$( 'input' , $( elem ).parent( ) ).each( function( key , input )
																	{
																		$( input ).prop( 'disabled' , false );
																	} );
															}
													} );
											</script>
											<div class="grid_10col spacer"></div>
											<br class="fix"/>
										</div>
										<?php
									}
							}
					
					?>
					<!-- Hiddenfelder und Schaltflächen -->
					<div class="grid_40col spacer"></div>
					<div class="grid_40col spacer"></div>
					<div class="grid_40col">
						<div class="grid_40col" data-form="dataEditing">
							<input type="hidden" name="siteId" id="siteId" value="3" />
							<input type="hidden" name="todoId" id="todoId" value="5" />
							<input type="hidden" name="formAction" id="formAction" value="editUser" />
							<input type="hidden" name="userId" id="userId" value="<?php echo ( isset ( $userId ) ) ? $userId : ''; ?>"/>
							<div class="grid_7col button">
								<a href="index.php?siteId=3"><?php echo $this -> _lang[ 'cancel' ]; ?></a>
							</div>
							<div class="grid_26col spacer"></div>
							<div class="grid_7col button">
								<a href="javascript:void( 0 );" onclick="$( '#userEdit' ).submit( );"><?php echo $this -> _lang[ 'save' ]; ?></a>
							</div>
						</div>
					</div>
				</form>
			</div>
			<div class="grid_20col spacer"></div>
		</div>
	</div>
</div>