<commit_before><?php
if(!isset($isIndex))die('');
else
{
require_once(base_url().'/inc/procedure.class.php');
?>
<script type="text/javascript">
	params_count=0;
	function addParam()
	{
		var param='<tr class="param" id="param_'+params_count+'">'+
	 			'<td>'+
					'<select name="param_dir['+params_count+']" id="param_dir_'+params_count+'">'+
	                    '<option>IN</option>'+
	                    '<option>OUT</option>'+
	                    '<option>INOUT</option>'+
                	'</select>'+
	 			'</td>'+
	 			'<td><input name="param_name['+params_count+']" id="param_name_'+params_count+'" type="text"></td>'+
	 			'<td>'+
					'<select name="param_type['+params_count+']" id="param_type_'+params_count+'">'+
						'<option>INT</option>'+
						'<option>VARCHAR</option>'+
						'<option>DATE</option>'+
					'</select>'+
	 			'</td>'+
	 			'<td><input name="param_length['+params_count+']" id="param_length_'+params_count+'" type="text"></td>'+
	 			'<td><button type="button" class="btn btn-danger btn-lg" onclick="javascript:removeParam('+params_count+');"><span class="glyphicon glyphicon-remove"></span></button></td>'+
	 		'</tr>';
	 	$('#button').before(param);
	 	$('#param_'+params_count).hide().fadeIn('normal');
	 	params_count++;
	}
	function removeParam(input)
	{
		$('#param_'+input).fadeOut('normal');
		setTimeout(function()
		{
			$('#param_'+input).remove();
		},1000);
	}
</script>
<form class="form-horizontal" action="/_procedure" method="POST">
<fieldset style="width:500px;display:block;">
<legend>Créer Procédure</legend>

<!-- Text input-->
<div class="control-group">
	<label class="control-label" for="name">Nom de la procédure</label>
	<div class="controls">
	 	<input id="name" name="name" type="text" placeholder="Nom de la procédure" class="input-xlarge" required="">
	</div>
</div>

<!-- Text input-->
<div class="control-group">
	<label class="control-label">Paramètres</label>
	<div class="controls">
	 	<table class="table table-striped table-nonfluid" id="params_table">
	 		<tr>
	 			<th>Direction</th>
	 			<th>Nom</th>
	 			<th>Type</th>
	 			<th>Taille/Valeurs</th>
	 			<th></th>
	 		</tr>
	 		<tr id="button">
	 			<td colspan="5"><button type="button" class="btn btn-default" onclick="javascript:addParam();">Ajouter un paramètre</button></td>
	 		</tr>
	 	</table>
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="code">Code</label>
	<div class="controls">
	 	<textarea class="form-control" rows="8" name="code" id="code"></textarea>
	</div>
</div>
<div class="control-group">
	<div class="controls">
		<button type="submit" id="btn_submit" class="btn btn-primary">Ajouter</button>
	</div>
</div>
</fieldset>
</form>

<commit_msg>guess i don't have to comment on this one<commit_after><?php
if(!isset($isIndex))die('');
else
{
require_once(base_url().'/inc/procedure.class.php');
?>
<script type="text/javascript">
	params_count=0;
	function addParam()
	{
		var param='<tr class="param" id="param_'+params_count+'">'+
	 			'<td>'+
					'<select name="param_dir['+params_count+']" id="param_dir_'+params_count+'">'+
	                    '<option>IN</option>'+
	                    '<option>OUT</option>'+
	                    '<option>INOUT</option>'+
                	'</select>'+
	 			'</td>'+
	 			'<td><input name="param_name['+params_count+']" id="param_name_'+params_count+'" type="text"></td>'+
	 			'<td>'+
					'<select name="param_type['+params_count+']" id="param_type_'+params_count+'">'+
						'<option>INT</option>'+
						'<option>VARCHAR</option>'+
						'<option>DATE</option>'+
					'</select>'+
	 			'</td>'+
	 			'<td><input name="param_length['+params_count+']" id="param_length_'+params_count+'" type="text"></td>'+
	 			'<td><button type="button" class="btn btn-danger btn-lg" onclick="javascript:removeParam('+params_count+');"><span class="glyphicon glyphicon-remove"></span></button></td>'+
	 		'</tr>';
	 	$('#button').before(param);
	 	$('#param_'+params_count).hide().fadeIn('normal');
	 	params_count++;
	}
	function removeParam(input)
	{
		$('#param_'+input).fadeOut('normal');
		setTimeout(function()
		{
			$('#param_'+input).remove();
		},1000);
	}
</script>
<form class="form-horizontal" action="/_procedure" method="POST">
<fieldset style="width:500px;display:block;">
<legend>Créer Procédure</legend>

<!-- Text input-->
<div class="control-group">
	<label class="control-label" for="name">Nom de la procédure</label>
	<div class="controls">
	 	<input id="name" name="name" type="text" placeholder="Nom de la procédure" class="input-xlarge" required="">
	</div>
</div>

<!-- Text input-->
<div class="control-group">
	<label class="control-label">Paramètres</label>
	<div class="controls">
	 	<table class="table table-striped table-nonfluid" id="params_table">
	 		<tr>
	 			<th>Direction</th>
	 			<th>Nom</th>
	 			<th>Type</th>
	 			<th>Taille/Valeurs</th>
	 			<th></th>
	 		</tr>
	 		<tr id="button">
	 			<td colspan="5"><button type="button" class="btn btn-default" onclick="javascript:addParam();">Ajouter un paramètre</button></td>
	 		</tr>
	 	</table>
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="code">Code</label>
	<div class="controls">
	 	<textarea class="form-control" rows="8" name="code" id="code"></textarea>
	</div>
</div>
<div class="control-group">
	<div class="controls">
		<button type="submit" id="btn_submit" class="btn btn-primary">Ajouter</button>
	</div>
</div>
</fieldset>
</form>

<?php

if(isset($params[0]) && !empty($params[0]))
{
	$procedure = Procedure::getProcedure(array('link'=>$link,'name'=>$params[0]));
	if($procedure)
	{//we got the data we should use javascript to fill the table with it
		?>
		<script type="text/javascript">
			var procedure = <?php echo json_encode($procedure); ?>;
			$('#btn_submit').html('Modifier');
			$('#btn_submit').after($('<a>',{class:'btn btn-danger',html:'Supprimer',href:'/_rm_procedure/<?php echo $params[0];?>'}));
			$('#name').val(procedure.name);
			var params=procedure.params;
			for(var i=0;i<params.length;i++)
			{
				addParam();
				$('#param_dir_'+i).val(params[i][0]);
				$('#param_name_'+i).val(params[i][1]);
				$('#param_type_'+i).val(params[i][2]);
				$('#param_length_'+i).val(params[i][3]);
			}
			$('#code').val(procedure.code);
		</script>
		<?php
	}
	else
	{
		echo "<div class='alert alert-danger'>".mysql_error()."</div>";
	}
}
}
?>
{'fraction_non_alphanumeric': 0.23773820681037175, 'fraction_numerical': 0.004529834426741643, 'mean_word_length': 4.558159722222222, 'pattern_counts': {'":': 0, '<': 197, '<?xml version=': 0, '>': 198, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7174586', 'n_tokens_mistral': 2573, 'n_tokens_neox': 2293, 'n_words': 360}