<commit_before><!doctype html>
<html class="fixed sidebar-left-collapsed">
    <head>
        <?php
        //Para usar head.php debe ser dentro del tag head y debe haberse creado una variable $title.
        include 'partials/head.php'; ?>
        
        <script type="text/javascript">

		   function addUnidad(area){
			   $("#addUni").html(area);
		   }

		   function delUnidad(unidad){
			   $("#delUni").html(unidad);
		   }

		   function delArea(area){
			   $("#delArea").html(area);
		   }

		   function redirectPost(location, args){
			   var form = '';
		        $.each( args, function( key, value ) {
		            form += '<input type="hidden" name="'+key+'" value="'+value+'">';
		        });
		        $('<form action="'+location+'" method="POST">'+form+'</form>').appendTo('body').submit();
		   }

		   function postAddArea(){
			    var n = $("#AreaName").val();
			    var segment = $("#segment").val();

			    if(document.getElementById('AreaName').value==""){
			   		alert("Debe ingresar un nombre para el área");
			   	}
			   	else{
			    	redirectPost('<?php echo base_url();?>ModifyOrg/addArea', {'name': n, 'type': segment});
			    }
		   }

		   function postDelArea(){
			   var n = $("#delArea").html();
			   redirectPost('<?php echo base_url();?>ModifyOrg/delAreaUni', {'name': n});
		   }

		   function postAddUni(){
			   var area = $("#addUni").html();
			   var name = $("#UniName").val();
			   if(document.getElementById('UniName').value==""){
			   		alert("Debe ingresar un nombre para la unidad");
			   }
			   else{
			   		redirectPost('<?php echo base_url();?>ModifyOrg/addUni', {'area': area, 'name': name});
			   	}
		   }

		   function postDelUni(){
			   var n = $("#delUni").html();
			   redirectPost('<?php echo base_url();?>ModifyOrg/delAreaUni', {'name': n});
		   }
		</script>
	</head>
	<body>
	   <section class="body">

        <?php 
        //Para usar header_tmpl.php se debe haber creado la variable $name y $role. Se pueden crear tanto aqui como en el controlador.
        include 'partials/header_tmpl.php'; ?>

			<div class="inner-wrapper">
				<!-- start: sidebar -->
				<aside id="sidebar-left" class="sidebar-left">

					<div class="sidebar-header">
						<div class="sidebar-title">
							Navegación
						</div>
						<div class="sidebar-toggle hidden-xs" data-toggle-class="sidebar-left-collapsed" data-target="html" data-fire-event="sidebar-left-toggle">
							<i class="fa fa-bars" aria-label="Toggle sidebar"></i>
						</div>
					</div>

					<div class="nano">
						<div class="nano-content">
							<nav id="menu" class="nav-main" role="navigation">
								<ul class="nav nav-main">
									<li>
										<a href="<?php echo base_url();?>inicio">
											<i class="fa fa-home" aria-hidden="true"></i>
											<span>U-Dashboard</span>
										</a>
									</li>
									<li>
										<a href="<?php echo base_url();?>cmetrica">
											<span class="pull-right label label-primary"></span>
											<i class="fa fa-server" aria-hidden="true"></i>
											<span>Configurar métricas</span>
										</a>
									</li>
									<li>
										<a href="<?php echo base_url();?>cdashboardUnidad">
											<span class="pull-right label label-primary"></span>
											<i class="fa fa-bar-chart" aria-hidden="true"></i>
											<span>Configurar Dashboard</span>
										</a>
									</li>
								</ul>
							</nav>
						</div>
					</div>

				</aside>
				<!-- end: sidebar -->

				<section role="main" class="content-body">
					<header class="page-header">
						<h2>Configurar áreas y unidades</h2>

						<div class="right-wrapper pull-right">
							<ol class="breadcrumbs">
								<li>
									<a href="<?php echo base_url();?>inicio">
										<i class="fa fa-home"></i>
									</a>
								</li>
								<li><span>Configurar</span></li>
								<li><span>Áreas y Unidades</span></li>
							</ol>

							<label>&nbsp;&nbsp;&nbsp;&nbsp;</label>

						</div>
					</header>

					<!-- start: page -->
					<section class="panel panel-transparent">
						<div class="panel-body">
							    <?php
							        $counter = 0;
							        foreach ($areaunit as $au){
							            $kind = false;
							            $color = false;
							            foreach ($types as $type){
							                if ($type['id']==$au['area']->getType()){
							                    $kind = $type['name'];
							                    $color = $type['color'];
							                }
							            }
							            if ($counter % 2 == 0 && $counter!=0)
							                echo ('</div>');
							            if ($counter % 2 == 0)
							                echo ('<div class ="row">');
							            echo ('<div class="col-md-6">');
							            echo ('<section class="panel panel-info">');
							            echo ('<header class="panel-heading" style="background-color: '.$color.'">');
							            echo ('<h2 class="panel-title text-center">');
							            echo ('<div class="btn-group-horizontal text-center">');
							            echo ('<label class="text-center">'.ucwords($au['area']->getName()).'</label>');
							            echo ('<a class="btn modal-with-form" href="#deleteArea" onclick = "delArea(\''.ucwords($au['area']->getName()).'\')" style="color: red"><i class="licon-close"></i></a>');
							            echo ('</div></h2>');
							            echo ('<p class="panel-subtitle text-center">'.ucwords($kind).'</p></header>');
							            echo ('<div class="panel-body">');
							            echo ('<div class="btn-group-vertical col-md-12">');
							            foreach ($au['unidades'] as $unidad){
							                echo('<div class="btn btn-default btn-group-horizontal text-center">');
							                echo ('<a class="btn modal-with-form" href="#deleteUnidad" onclick = "delUnidad(\''.ucwords($unidad->getName()).'\')" style="color: red"><i class="licon-close"></i></a>');
							                echo ('<label class="text-center">'.ucwords($unidad->getName()).'</label></div>');
							            }
							            echo ('<a class="btn modal-with-form" href="#agregarUnidad" onclick = "addUnidad(\''.ucwords($au['area']->getName()).'\')" style="color: green"><i class="licon-plus"></i></a>');
							            echo ('</div></div></section></div>');
							            $counter++;
							        }

							    ?>
							<div class="row col-md-12 text-center">
								<a class="btn modal-with-form" href="#agregarArea" style="color: green">
								<h1><i class="licon-plus"></i></h1>
								</a>
							</div>
							<div id="agregarArea" class="modal-block modal-block-primary mfp-hide">
										<section class="panel">
											<header class="panel-heading">
												<h2 class="panel-title">Agregar área</h2>
											</header>
											<div class="panel-body">
												<form id="demo-form" class="form-horizontal mb-lg">
													<div class="form-group mt-lg">
														<label class="col-sm-3 control-label">Nombre:</label>
														<div class="col-sm-9">

															<input id = "AreaName" type="text" name="name" class="form-control" placeholder="nombre de la nueva área..." required/>

														</div>
													</div>
													<div class="form-group mt-lg">
														<label class="col-sm-3 control-label">Segmento:</label>
														<div class="col-sm-9">
                                                            <select class="form-control" id="segment">
                                                              <?php
                                                                foreach ($types as $type){
                                                                    echo('<option value="'.$type['id'].'">'.ucwords($type['name']).'</option>');
                                                                }
                                                              ?>
                                                            </select>														</div>
													</div>
												</form>
											</div>
											<footer class="panel-footer">
												<div class="row">
													<div class="col-md-12 text-right">
														<button class="btn btn-primary" onclick="postAddArea()">Añadir</button>
														<button class="btn btn-default modal-dismiss">Cancelar</button>
													</div>
												</div>
											</footer>
										</section>
							</div>
								<div id="agregarUnidad" class="modal-block modal-block-primary mfp-hide">
										<section class="panel">
											<header class="panel-heading">
												<h2 class="panel-title">Agregar unidad</h2>
												<p class="panel-subtitle" id = "addUni">Área 1</p>
											</header>
											<div class="panel-body">
												<form id="demo-form" class="form-horizontal mb-lg">
													<div class="form-group mt-lg">
														<label class="col-sm-3 control-label">Nombre:</label>
														<div class="col-sm-9">
															<input id = "UniName" type="text" name="name" class="form-control" placeholder="nombre de la nueva unidad..." required/>
														</div>
													</div>
												</form>
											</div>
											<footer class="panel-footer">
												<div class="row">
													<div class="col-md-12 text-right">
														<button class="btn btn-primary" onclick="postAddUni()">Añadir</button>
														<button class="btn btn-default modal-dismiss">Cancelar</button>
													</div>
												</div>
											</footer>
										</section>
									</div>
									<div id="deleteArea" class="modal-block mfp-hide">
										<section class="panel">
											<header class="panel-heading">
												<h2 class="panel-title">¿Está seguro?</h2>
											</header>
											<div class="panel-body">
												<div class="modal-wrapper">
													<div class="modal-text">
														<p>¿Está seguro de que quiere eliminar esta área?</p>
														<p id="delArea">area 1</p>
													</div>
												</div>
											</div>
											<footer class="panel-footer">
												<div class="row">
													<div class="col-md-12 text-right">
														<button class="btn btn-primary" onclick="postDelArea()">Confirmar</button><commit_msg>Agregada validacion en el frontend de el nombre de areas y unidades<commit_after><!doctype html>
<html class="fixed sidebar-left-collapsed">
    <head>
        <?php
        //Para usar head.php debe ser dentro del tag head y debe haberse creado una variable $title.
        include 'partials/head.php'; ?>
        
        <script type="text/javascript">

           function validateName(input){
        	   var re = new RegExp('^([a-zA-Zñáéíóú]\s?)+$');
        	   if (input.value.match(re)) {
        		   input.style.borderColor="#cccccc";
        		  } else {
        		    alert("Los nombres de Areas y Unidades solo puede tener letras, tildes y espacios.");
        		    input.style.borderColor="red";
        		  }

           }

           function addArea(){
        	   $("#AreaName").val("");
        	   $("#AreaName").css("border-color", "#cccccc");
           }

		   function addUnidad(area){
			   $("#UniName").val("");
        	   $("#UniName").css("border-color", "#cccccc");
			   $("#addUni").html(area);			   
		   }

		   function delUnidad(unidad){
			   $("#delUni").html(unidad);
		   }

		   function delArea(area){
			   $("#delArea").html(area);
		   }

		   function redirectPost(location, args){
			   var form = '';
		        $.each( args, function( key, value ) {
		            form += '<input type="hidden" name="'+key+'" value="'+value+'">';
		        });
		        $('<form action="'+location+'" method="POST">'+form+'</form>').appendTo('body').submit();
		   }

		   function postAddArea(){
			    var n = $("#AreaName").val();
			    var segment = $("#segment").val();

			    if(document.getElementById('AreaName').value==""){
			   		alert("Debe ingresar un nombre para el área");
			   	}
			   	else{
			    	redirectPost('<?php echo base_url();?>ModifyOrg/addArea', {'name': n, 'type': segment});
			    }
		   }

		   function postDelArea(){
			   var n = $("#delArea").html();
			   redirectPost('<?php echo base_url();?>ModifyOrg/delAreaUni', {'name': n});
		   }

		   function postAddUni(){
			   var area = $("#addUni").html();
			   var name = $("#UniName").val();
			   if(document.getElementById('UniName').value==""){
			   		alert("Debe ingresar un nombre para la unidad");
			   }
			   else{
			   		redirectPost('<?php echo base_url();?>ModifyOrg/addUni', {'area': area, 'name': name});
			   	}
		   }

		   function postDelUni(){
			   var n = $("#delUni").html();
			   redirectPost('<?php echo base_url();?>ModifyOrg/delAreaUni', {'name': n});
		   }
		</script>
	</head>
	<body>
	   <section class="body">

        <?php 
        //Para usar header_tmpl.php se debe haber creado la variable $name y $role. Se pueden crear tanto aqui como en el controlador.
        include 'partials/header_tmpl.php'; ?>

			<div class="inner-wrapper">
				<!-- start: sidebar -->
				<aside id="sidebar-left" class="sidebar-left">

					<div class="sidebar-header">
						<div class="sidebar-title">
							Navegación
						</div>
						<div class="sidebar-toggle hidden-xs" data-toggle-class="sidebar-left-collapsed" data-target="html" data-fire-event="sidebar-left-toggle">
							<i class="fa fa-bars" aria-label="Toggle sidebar"></i>
						</div>
					</div>

					<div class="nano">
						<div class="nano-content">
							<nav id="menu" class="nav-main" role="navigation">
								<ul class="nav nav-main">
									<li>
										<a href="<?php echo base_url();?>inicio">
											<i class="fa fa-home" aria-hidden="true"></i>
											<span>U-Dashboard</span>
										</a>
									</li>
									<li>
										<a href="<?php echo base_url();?>cmetrica">
											<span class="pull-right label label-primary"></span>
											<i class="fa fa-server" aria-hidden="true"></i>
											<span>Configurar métricas</span>
										</a>
									</li>
									<li>
										<a href="<?php echo base_url();?>cdashboardUnidad">
											<span class="pull-right label label-primary"></span>
											<i class="fa fa-bar-chart" aria-hidden="true"></i>
											<span>Configurar Dashboard</span>
										</a>
									</li>
								</ul>
							</nav>
						</div>
					</div>

				</aside>
				<!-- end: sidebar -->

				<section role="main" class="content-body">
					<header class="page-header">
						<h2>Configurar áreas y unidades</h2>

						<div class="right-wrapper pull-right">
							<ol class="breadcrumbs">
								<li>
									<a href="<?php echo base_url();?>inicio">
										<i class="fa fa-home"></i>
									</a>
								</li>
								<li><span>Configurar</span></li>
								<li><span>Áreas y Unidades</span></li>
							</ol>

							<label>&nbsp;&nbsp;&nbsp;&nbsp;</label>

						</div>
					</header>

					<!-- start: page -->
					<section class="panel panel-transparent">
						<div class="panel-body">
							    <?php
							        $counter = 0;
							        foreach ($areaunit as $au){
							            $kind = false;
							            $color = false;
							            foreach ($types as $type){
							                if ($type['id']==$au['area']->getType()){
							                    $kind = $type['name'];
							                    $color = $type['color'];
							                }
							            }
							            if ($counter % 2 == 0 && $counter!=0)
							                echo ('</div>');
							            if ($counter % 2 == 0)
							                echo ('<div class ="row">');
							            echo ('<div class="col-md-6">');
							            echo ('<section class="panel panel-info">');
							            echo ('<header class="panel-heading" style="background-color: '.$color.'">');
							            echo ('<h2 class="panel-title text-center">');
							            echo ('<div class="btn-group-horizontal text-center">');
							            echo ('<label class="text-center">'.ucwords($au['area']->getName()).'</label>');
							            echo ('<a class="btn modal-with-form" href="#deleteArea" onclick = "delArea(\''.ucwords($au['area']->getName()).'\')" style="color: red"><i class="licon-close"></i></a>');
							            echo ('</div></h2>');
							            echo ('<p class="panel-subtitle text-center">'.ucwords($kind).'</p></header>');
							            echo ('<div class="panel-body">');
							            echo ('<div class="btn-group-vertical col-md-12">');
							            foreach ($au['unidades'] as $unidad){
							                echo('<div class="btn btn-default btn-group-horizontal text-center">');
							                echo ('<a class="btn modal-with-form" href="#deleteUnidad" onclick = "delUnidad(\''.ucwords($unidad->getName()).'\')" style="color: red"><i class="licon-close"></i></a>');
							                echo ('<label class="text-center">'.ucwords($unidad->getName()).'</label></div>');
							            }
							            echo ('<a class="btn modal-with-form" href="#agregarUnidad" onclick = "addUnidad(\''.ucwords($au['area']->getName()).'\')" style="color: green"><i class="licon-plus"></i></a>');
							            echo ('</div></div></section></div>');
							            $counter++;
							        }

							    ?>
							<div class="row col-md-12 text-center">
								<a class="btn modal-with-form" href="#agregarArea" style="color: green" onclick = "addArea();">
								<h1><i class="licon-plus"></i></h1>
								</a>
							</div>
							<div id="agregarArea" class="modal-block modal-block-primary mfp-hide">
										<section class="panel">
											<header class="panel-heading">
												<h2 class="panel-title">Agregar área</h2>
											</header>
											<div class="panel-body">
												<form id="demo-form" class="form-horizontal mb-lg">
													<div class="form-group mt-lg">
														<label class="col-sm-3 control-label">Nombre:</label>
														<div class="col-sm-9">

															<input id = "AreaName" onchange = "validateName(this);" type="text" name="name" class="form-control" placeholder="nombre de la nueva área..." required/>
                                        
														</div>
													</div>
													<div class="form-group mt-lg">
														<label class="col-sm-3 control-label">Segmento:</label>
														<div class="col-sm-9">
                                                            <select class="form-control" id="segment">
                                                              <?php
                                                                foreach ($types as $type){
                                                                    echo('<option value="'.$type['id'].'">'.ucwords($type['name']).'</option>');
                                                                }
                                                              ?>
                                                            </select>														</div>
													</div>
												</form>
											</div>
											<footer class="panel-footer">
												<div class="row">
													<div class="col-md-12 text-right">
														<button class="btn btn-primary" onclick="postAddArea()">Añadir</button>
														<button class="btn btn-default modal-dismiss">Cancelar</button>
													</div>
												</div>
											</footer>
										</section>
							</div>
								<div id="agregarUnidad" class="modal-block modal-block-primary mfp-hide">
										<section class="panel">
											<header class="panel-heading">
												<h2 class="panel-title">Agregar unidad</h2>
												<p class="panel-subtitle" id = "addUni">Área 1</p>
											</header>
											<div class="panel-body">
												<form id="demo-form" class="form-horizontal mb-lg">
													<div class="form-group mt-lg">
														<label class="col-sm-3 control-label">Nombre:</label>
														<div class="col-sm-9">
															<input id = "UniName" onchange = "validateName(this);" type="text" name="name" class="form-control" placeholder="nombre de la nueva unidad..." required/>
														</div>
													</div>
												</form>
											</div>
											<footer class="panel-footer">
												<div class="row">
													<div class="col-md-12 text-right">
														<button class="btn btn-primary" onclick="postAddUni()">Añadir</button>
														<button class="btn btn-default modal-dismiss">Cancelar</button>
													</div>
												</div>
											</footer>
										</section>
									</div>
									<div id="deleteArea" class="modal-block mfp-hide">
										<section class="panel">
											<header class="panel-heading">
												<h2 class="panel-title">¿Está seguro?</h2>
											</header>
											<div class="panel-body">
												<div class="modal-wrapper">
													<div class="modal-text">
														<p>¿Está seguro de que quiere eliminar esta área?</p>
														<p id="delArea">area 1</p>
													</div>
												</div>
											</div>
											<footer class="panel-footer">
												<div class="row">
													<div class="col-md-12 text-right">
														<button class="btn btn-primary" onclick="postDelArea()">Confirmar</button>
{'fraction_non_alphanumeric': 0.17988655384043148, 'fraction_numerical': 0.0034405802492095965, 'mean_word_length': 1.663983155808769, 'pattern_counts': {'":': 0, '<': 473, '<?xml version=': 0, '>': 485, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 29, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5928547', 'n_tokens_mistral': 9372, 'n_tokens_neox': 6227, 'n_words': 1260}