function output_program_day($string_date = 'now') { $date_unix = strtotime($string_date); $day_no = day_eng_no(strftime("%A", $date_unix)); $date_formatted = strftime("%d %b %Y", $date_unix); $day_name_french = day_fr($day_no); $date_sql = strftime("%Y-%m-%d", $date_unix); $full_date_formatted = $day_name_french . " " . $date_formatted; $output = ""; $program_set = find_program_by_date($date_sql); if (count_prog_by_date($date_sql) == 0) { $output .= "<p class='text-center' style='vertical-align:middle;'>pas de résultat pour le {$full_date_formatted}</p>"; } else { // $output .= Get_badges_program ($string_date); $output .= "<div class='table-responsive'>"; $output .= "<table class='table table-striped table-bordered table-hover table-condensed '>"; $output .= "<tr>"; // $output .= "<td class='text-center alert-danger'>Jour</td>"; //Heure if (isset($_GET["validation_chauffeur"])) { $valid_chauffeur = $_GET["validation_chauffeur"]; if ($valid_chauffeur == 1) { $color = ""; $style = "color: white; background-color:green;"; } elseif ($valid_chauffeur == 2) { $color = ""; $style = "color: white; background-color:palevioletred;"; } elseif ($valid_chauffeur == 0) { $color = ""; $style = "color: white; background-color:lightskyblue;"; } else { $color = ""; $style = ""; } } else { $valid_chauffeur = 3; $color = ""; $style = ""; } $output .= "<th class='text-center {$color}' style='vertical-align:middle; {$style}'> Heure </th>"; $output .= "<th class='text-center {$color}' style='vertical-align:middle;{$style} '>{$full_date_formatted}</th>"; // $output .= "<th class='text-center {$color}' style='vertical-align:middle;{$style} '></th>"; $output .= "</tr>"; while ($program = mysqli_fetch_assoc($program_set)) { $output .= "<tr>"; $client = find_client_by_id($program['client_id']); $heure = htmlentities(visu_heure($program['heure']), ENT_COMPAT, 'utf-8'); $client_web_view = htmlentities($client['web_view'], ENT_COMPAT, 'utf-8'); if ($program["validated_chauffeur"] == 1) { $succes = "success"; $color1 = "success"; } elseif ($program["validated_chauffeur"] == 2) { $succes = ""; $color1 = "danger"; } else { $succes = ""; $color1 = "info"; } // if($program['chauffeur'] && ($program["validated_chauffeur"]==1 || $program["validated_chauffeur"]==2)) { // $chauffeur =find_chauffeur_by_name(trim($program['chauffeur'])); // if ($chauffeur){ // $initial=$chauffeur['initial']; // } else { // $initial=""; // } // // } else { // $initial=""; // } /* if($program["validated_chauffeur"]==1){ $output.= "<td class='text-center {$succes}' style='vertical-align:middle;'>". $heure."</td>"; } else { $output.= "<td class='text-center' style='vertical-align:middle;'>". $heure."</td>"; }*/ $output .= "<td class='text-center {$succes}' style='vertical-align:middle;'>" . $heure . "</td>"; $output .= "<td class='text-center {$succes}'>" . get_modal_program($program['id']) . "</td>"; // $output.= "<td class='text-center {$succes}'><h5><span class='label label-{$color1}' style='width:6em;'>"; // $output.= "".htmlentities($initial,ENT_COMPAT, 'utf-8').""; // $output.= "</h5></span></td>"; $output .= "</tr>"; } $output .= "</table>"; $output .= "</div>"; } mysqli_free_result($program_set); return $output; }
$_SESSION["message"] = "Fatal error edit modele call administrator modele id"; redirect_to($url); } //if (!isset($_GET["clientid"])) { // $_SESSION["message"] = "Fatal error edit modele call administrator client id"; // redirect_to($url); //} // ?> <?php //we can remove the get variable only $_GET["modeleid"] $modele = find_modele_by_id($_GET["modele_id"]); $client = find_client_by_id($modele["client_id"]); if (!$client || !$modele) { // admin ID was missing or invalid or // admin couldn't be found in database $_SESSION["message"] = "Fatal error edit modele call administrator database client id"; redirect_to($url); } ?> <?php if (isset($_POST['submit'])) { $required_fields = array("week_day_rank", "client_habituel", "heure", "pseudo", "visible"); validate_presences($required_fields); $week_day_rank = mysql_prep($_POST["week_day_rank"]); $client_habituel = mysql_prep($_POST["client_habituel"]);
function is_modele_exists($week_day_rank, $cliend_id, $heure, $warning_me = false) { global $connection; global $errors; global $warnings; $week_day_rank_safe = mysql_prep($week_day_rank); $cliend_id_safe = mysql_prep($cliend_id); $heure_safe = mysql_prep($heure); $query = "SELECT * "; $query .= "FROM programmed_courses_modele "; $query .= "WHERE week_day_rank = {$week_day_rank_safe} "; $query .= "AND client_id = {$cliend_id_safe} "; $query .= "AND heure = '{$heure_safe}' "; // $query .= "ORDER BY position ASC"; $result = mysqli_query($connection, $query); confirm_query($result); // $result= $result; $row_count = mysqli_num_rows($result); // printf("Result set has %d rows.\n",$rowcount); // Free result set mysqli_free_result($result); $client = find_client_by_id($cliend_id); $pseudo = $client['pseudo']; $field = "Le modèle du "; $field .= "" . day_fr($week_day_rank) . " "; $field .= " pour " . $pseudo . " "; $field .= "à " . $heure . " "; if ($row_count == 0) { } else { if ($warning_me) { $warnings[$field] = fieldname_as_text($field) . " existe déjà et ne peut etre créé ou édité"; } else { $errors[$field] = fieldname_as_text($field) . " existe déjà et ne peut etre créé ou édité"; } } // return $row_count; }
require_once '../includes/initialize.php'; ?> <?php confirm_logged_in(); if (is_chauffeur()) { redirect_to('manage_program.php'); } ?> <?php if (!isset($_GET["id"])) { redirect_to("admin.php"); } $client = find_client_by_id($_GET["id"]); if (!$client) { // admin ID was missing or invalid or // admin couldn't be found in database redirect_to("manage_client.php"); } $id = $client["id"]; $query = "DELETE FROM clients WHERE id = {$id} LIMIT 1"; $result = mysqli_query($connection, $query); if ($result && mysqli_affected_rows($connection) == 1) { // Success $_SESSION["message"] = "Client successfully deleted."; $_SESSION["OK"] = true; redirect_to("manage_client.php"); } else { // Failure
function get_modal_modele($modele_id, $date_sql = null) { // modal $modele = find_modele_by_id($modele_id); $client = find_client_by_id($modele["client_id"]); $div_id = "myModalmodele{$modele_id}"; $output = ""; // $output .= ""; $output = ""; $output .= "<a href='#' data-toggle='modal' data-target='#{$div_id}'>"; $output .= htmlentities($client['web_view'], ENT_COMPAT, 'utf-8'); // $output.="<span class=\"glyphicon glyphicon-info-sign\" style='color: green;' aria-hidden='true'></span>"; $output .= "</a>"; // below is modal mode not shown (hidden) $output .= "<div class='modal fade' id='{$div_id}' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>"; $output .= " <div class='modal-dialog'>"; $output .= " <div class='modal-content'>"; $output .= " <div class='modal-header'>"; $output .= " <button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button>"; $output .= " <h5 class='modal-title' id='myModalLabel'>Modele " . htmlentities(day_fr($modele['week_day_rank']), ENT_COMPAT, 'utf-8') . " - Pseudo :<strong>" . htmlentities($client['pseudo'], ENT_COMPAT, 'utf-8') . "</strong> Nom :" . htmlentities($client['web_view'], ENT_COMPAT, 'utf-8') . "</strong></h5>"; $output .= " </div>"; $output .= " <div class='modal-body'>"; //function of body of modal $p_edit = "edit_course_modele.php"; $p_del = "delete_course_modele.php"; $p_new = "new_course_modele.php"; $p_export = "modele_export.php"; $url = "&url=" . urlencode($_SERVER['PHP_SELF']); if (isset($_GET["week_day"])) { $url .= "&week_day=" . urlencode($_GET["week_day"]); } if (isset($_GET["date_next_last"])) { $url .= "&date_next_last=" . urlencode($_GET["date_next_last"]); } if (isset($_GET["modele_visible"])) { $url .= "&modele_visible=" . urlencode($_GET["modele_visible"]); } $style_width_button = "style='width: 7em;'"; $output .= "<div class='container-fluid text-left'> "; $output .= get_modal_body($modele_id, $date_sql); // $output .= " <button type='button' class='btn btn-default' data-dismiss='modal'> Close </button>"; // $output .= "<div class='col-xm-2 col-md-offset-2'>"; // if ($date_sql){ // $output .= "<p class='btn'><a class='btn btn-success' {$style_width_button} href='{$p_export}?modele_id=".urlencode($modele_id)."&modele_date=".urlencode($date_sql).$url. "'> Export to prog </a></p>"; // } // $output .= "</div>"; $output .= "</div>"; $output .= " </div>"; $output .= " <div class='modal-footer'>"; $output .= " <div class='btn-group btn-group-justified' role='group' aria-label='...'>"; $style_width_button = "style='width: 4em;'"; $output .= " <p class='btn'><a class='btn btn-primary btn-xm' {$style_width_button} href='{$p_edit}?modele_id=" . urlencode($modele_id) . $url . "'>Edit</a></p>"; $output .= " <p class='btn'><a class='btn btn-danger btn-xm' {$style_width_button} href='{$p_del}?modele_id=" . urlencode($modele_id) . $url . "'>Delete</a></p>"; $output .= " <p class='btn'><a class='btn btn-success btn-xm' {$style_width_button} href='{$p_new}?modele_id=" . urlencode($modele_id) . $url . "'>add</a></p>"; $output .= " <p class='btn' data-dismiss='modal'><a class=' btn btn-info btn-xm'{$style_width_button}>close</a> </p>"; $output .= " </div>"; $output .= " </div>"; $output .= " </div>"; $output .= " </div>"; $output .= "</div>"; return $output; }