<?php
function setBouton($largeur,$styleBouton,$icone,$label,$link)
{
 echo "<div class='col-md-$largeur'>
        <a href='$link'><button class='btn btn-lg btn-$styleBouton btn-block'><i class='fa $icone'></i> $label</button></a>
    </div>";
}

function createInputText($attr,$label,$resultat="") {
?>
    <div class="form-group">
        <label for="<?php echo $attr;?>" class="col-md-3 control-label"><?php echo $label;?></label>
        <div class="col-md-8">
            <input type="text" id="<?php echo $attr;?>" name="<?php echo $attr;?>" value="<?php echo $resultat;?>" class="form-control">
        </div>
    </div>
<?php
}

function createInputNumber($attr,$label,$resultat="") {
?>
    <div class="form-group">
        <label for="<?php echo $attr;?>" class="col-md-3 control-label"><?php echo $label;?></label>
        <div class="col-md-8">
            <input type="number" min=0 id="<?php echo $attr;?>" name="<?php echo $attr;?>" value="<?php echo $resultat;?>" class="form-control">
        </div>
    </div>
<?php
}

function createInputRadio($attr,$tab,$label,$resultat="") {
?>
    <div class="form-group">
        <label class="col-sm-3 control-label"><?php echo $label;?></label>

        <div class="col-sm-8">
            <?php
                $i=1;
                foreach ($tab as $key=>$val) {
                echo '<div class="radio-custom"><input type="radio" id="'.$attr.$i.'" name="'.$attr.'" value="'.$key.'"';
                if ($val == $resultat || $key == $resultat)  echo " checked";
                echo '><label for="'.$attr.$i.'">'.$val.'</label></div>';
                    $i++;
                }
            ?>
        </div>
    </div>
    
<?php
}

function setInfos($label,$val) {
    if ($val=="")   $class="text-danger"; else $class="text-success";
?>
    <div class="row">
        <div class="col-md-3"></div>
        <div class="col-md-6">
            <?php echo "<span class='$class'>$label: $val</span>";?></code>
        </div>
        <div class="col-md-3"></div>
    </div>
<?php
}

function get($attr,$mult=false)
{
    $val="";
    if (isset($_GET[$attr]) && !empty($_GET[$attr]))        $val=preg_replace("/\'/", "\'", $_GET[$attr]);
    elseif (isset($_GET[$attr]))                            $val=preg_replace("/\'/", "\'", $_GET[$attr]);
    elseif (isset($_POST[$attr]) && !empty($_POST[$attr]))  $val=$_POST[$attr];
    elseif (isset($_POST[$attr]))                           $val=$_POST[$attr];
    return                                                  $val;
}

?>
