<?php
require_once(__DIR__ . '/../config.php');
$project_id = $_GET['project_id'] ?? 0;
?>

<div class="container-fluid">
<form id="activity-form">

<input type="hidden" name="project_id" value="<?= $project_id ?>">

<div class="form-group">
    <label>Actividad</label>
    <input type="text" name="activity_name" class="form-control" required>
</div>

<div class="form-group">
    <label>Responsable</label>
    <input type="text" name="responsible" class="form-control">
</div>

<div class="form-row">
    <div class="col">
        <label>% Planificado</label>
        <input type="number" name="planned_progress" class="form-control" min="0" max="100" required>
    </div>
    <div class="col">
        <label>% Ejecutado</label>
        <input type="number" name="actual_progress" class="form-control" min="0" max="100" required>
    </div>
</div>

<div class="form-group mt-2">
    <label>Estado</label>
    <select name="status" class="form-control">
        <option value="en_linea">🟢 En línea</option>
        <option value="observacion">🟡 Observación</option>
        <option value="riesgo">🔴 Riesgo</option>
    </select>
</div>

<div class="form-group">
    <label>Comentario</label>
    <textarea name="comment" rows="3" class="form-control"></textarea>
</div>

<button class="btn btn-primary btn-block">
    Guardar Actividad
</button>

</form>
</div>

<script>
$('#activity-form').submit(function(e){
    e.preventDefault();
    $.post(
        _base_url_ + 'classes/Master.php?f=save_activity',
        $(this).serialize(),
        function(resp){
            if(resp.status === 'success'){
                location.reload();
            }else{
                alert(resp.msg);
            }
        },
        'json'
    );
});
</script>

