Ejemplo n.º 1
0
function get_tasks($db, $group, $from)
{
    $req = $db->prepare("SELECT * FROM tasks where (groupe =? or 0=?) and ((deadline>? and 0<>?) or deadline>now()) ORDER BY deadline");
    $req->execute(array($group, $group, $from, $from));
    $res = $req->fetchAll(PDO::FETCH_ASSOC);
    foreach ($res as $key => $task) {
        foreach ($task as $key2 => $row) {
            $res[$key][$key2] = html_entity_decode($row);
        }
        $deadlineDate = new DateTime($task['deadline']);
        $now = new DateTime("today");
        $interval = $now->diff($deadlineDate);
        list($year, $month, $day) = explode('-', $task['deadline']);
        $deadline = $day . "-" . $month . "-" . $year;
        $timeLeft = "";
        if ($interval->format('%R%m') > 0) {
            $timeLeft = $interval->format('%m mois');
            if ($interval->format('%d') != 0) {
                $timeLeft = $timeLeft . " et ";
            }
        }
        if ($interval->format('%R%m') == 0) {
            switch ($interval->format('%r%d')) {
                case '0':
                    $jours = "Aujourd'hui";
                    break;
                case '1':
                    $jours = "Demain";
                    break;
                case '-1':
                    $jours = "Hier";
                    break;
                default:
                    $jours = "%d jours";
                    break;
            }
        } else {
            $jours = "%d jours";
        }
        if ($interval->format('%d') == 0) {
            $jours = "";
        }
        $timeLeft = $timeLeft . $interval->format($jours);
        if ($interval->format('%r') == '-' && $interval->format('%d') != 1) {
            $timeLeft = "Il y a " . $timeLeft;
        }
        $res[$key]['timeleft'] = $timeLeft;
        $res[$key]['deadline'] = $deadline;
        $res[$key]['worklevel'] = couleurNiveau($res[$key]['worklevel']);
        $res[$key]['groupe'] = groupe($res[$key]['groupe']);
    }
    return $res;
}
Ejemplo n.º 2
0
function droits($member)
{
    echo '
   <fieldset>
   <legend>' . adm_translate("Droits") . '</legend>
   <div class="form-group row">
      <label class="radio-inline text-danger">';
    if ($member == -127) {
        $checked = ' checked="checked"';
    } else {
        $checked = '';
    }
    echo '
         <input type="radio" name="members" value="-127" ' . $checked . ' />' . adm_translate("Administrateurs") . '
      </label>
      <label class="radio-inline text-danger">';
    if ($member == -1) {
        $checked = ' checked="checked"';
    } else {
        $checked = '';
    }
    echo '
         <input type="radio" name="members" value="-1" ' . $checked . ' />' . adm_translate("Anonymes") . '
      </label>';
    echo '
      <label class="radio-inline text-danger">';
    if ($member > 0) {
        echo '
         <input type="radio" name="members" value="1" checked="checked" />' . adm_translate("Membres") . '
      </label>
      <label class="radio-inline">
         <input type="radio" name="members" value="0" />' . adm_translate("Tous") . '
      </label>
   </div>
   <div class="form-group">
      <label class="form-control-label" for="Mmember[]">' . adm_translate("Groupes") . '</label>';
        echo groupe($member) . '
   </div>';
    } else {
        if ($member == 0) {
            $checked = ' checked="checked"';
        } else {
            $checked = '';
        }
        echo '
      <input type="radio" name="members" value="1" />' . adm_translate("Membres") . '
      </label>
      <label class="radio-inline">
         <input type="radio" name="members" value="0"' . $checked . ' />' . adm_translate("Tous") . '
      </label>
   </div>
   <div class="form-group">
   <label class="form-control-label" for="Mmember[]">' . adm_translate("Groupes") . '</label>';
        echo groupe($member) . '
   </div>
   </fielset>';
    }
}