if (is_chauffeur()) { redirect_to('manage_program.php'); } ?> <?php $query_string = "?" . $_SERVER['QUERY_STRING']; if (isset($_GET["url"])) { $url = $_GET["url"] . $query_string; } else { $url = "manage_program.php" . $query_string; } if (!isset($_GET["program_id"])) { redirect_to($url); } $program = find_program_by_id($_GET["program_id"]); if (!$program) { // admin ID was missing or invalid or // admin couldn't be found in database redirect_to($url); } if (is_chauffeur()) { $_SESSION["message"] = "Chauffeur cannot delete add edit a course."; redirect_to("admin.php"); } $id = $program["id"]; $query = "DELETE FROM programmed_courses WHERE id = {$id} LIMIT 1"; $result = mysqli_query($connection, $query); if ($result && mysqli_affected_rows($connection) == 1) { // Success $_SESSION["message"] = "Program course deleted.";
function get_modal_program($program_id) { // modal $program = find_program_by_id($program_id); $client = find_client_by_id($program["client_id"]); $div_id = "myModalprogram{$program_id}"; $output = ""; // $output .= ""; if ($program["validated_chauffeur"] == 1) { $color = "success"; } elseif ($program["validated_chauffeur"] == 2) { $color = "danger"; } else { $color = "info"; } $output .= "<a class='btn btn-{$color}' style='width:14em;' 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'>"; // $output.="</span>"; $output .= "</a>"; // $output.= " "; list($date_fr, $date_fr_short, $date_fr_long, $date_fr_hr, $date_fr_short_hr, $date_fr_long_hr, $date_fr_full_hr) = date_fr($program["course_date"]); // 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'>"; $output .= "<span style='color: #ff0000;'><strong>" . htmlentities($date_fr_long, ENT_COMPAT, 'utf-8'); $output .= "</strong></span> - Pseudo :<strong>" . htmlentities($client['pseudo'], ENT_COMPAT, 'utf-8'); $output .= "</strong><br> Nom: <strong>" . htmlentities($client['web_view'], ENT_COMPAT, 'utf-8'); $output .= "</strong></h5>"; $output .= " </div>"; $output .= " <div class='modal-body'>"; //function of body of modal $p_edit = "edit_course_program.php"; $p_del = "delete_course_program.php"; $p_new = "new_course_program.php"; $p_annulation = "edit_annuler_course_program.php"; $p_validation = "edit_validation_chauffeur_program.php"; $p_validation_mgr = "edit_validation_mgr_program.php"; $p_validation_final = "edit_validation_final_program.php"; $url = "&url=" . urlencode($_SERVER['PHP_SELF']); $query_string = "&str_time=" . urlencode($program['course_date']); $output .= "<div class='container-fluid text-left'> "; $output .= get_modal_body_program($program_id); // $output .= "<div class='container-fluid text-right'> "; // $output .= " <button type='button' class='btn btn-default' data-dismiss='modal'> Close </button>"; // $output .= "</div>"; $output .= "</div>"; $output .= " </div>"; $enable_accessr = true; $enable_access_valider = true; $enable_access_valider_mgr = true; $enable_access_valider_final = true; $enable_access_delete = true; $enable_access_annuler = true; $enable_access_edit = true; settype($p_val_chauf, "integer"); settype($p_val_mgr, "integer"); settype($p_val_final, "integer"); $p_val_chauf = $program["validated_chauffeur"]; $p_val_mgr = $program["validated_mgr"]; $p_val_final = $program["validated_final"]; if (is_chauffeur()) { $enable_access_delete = false; $enable_access_valider_mgr = false; $enable_access_valider_final = false; } if ($p_val_chauf == 1) { $text_validation = "Reactiver"; $text_validation_annuler = "Annuler"; $enable_access_annuler = false; if (is_chauffeur() && $_SESSION["nom"] !== $program["chauffeur"]) { $enable_access_valider = false; $enable_access_annuler = false; $enable_access_edit = false; } // course annullé } elseif ($p_val_chauf == 2) { $text_validation = "Reactiver"; $text_validation_annuler = "Re-Annuler"; $enable_access_valider = false; if (is_chauffeur() && $_SESSION["nom"] !== $program["chauffeur"]) { $enable_access_annuler = false; $enable_access_valider = false; $enable_access_edit = false; } } else { $text_validation = "Valider"; $text_validation_annuler = "Annuler"; $enable_access_valider_mgr = false; $enable_access_valider_final = false; } if ($p_val_mgr == 1) { $enable_access_valider = false; // $enable_access_valider_mgr=false; // $enable_access_valider_final=false; $enable_access_delete = false; $enable_access_annuler = false; $enable_access_edit = false; $text_validation_mgr = "Re- Mgr"; } else { $text_validation_mgr = "Val Mgr"; } if ($p_val_final == 1) { $enable_access_delete = false; $enable_access_annuler = false; $enable_access_valider = false; $enable_access_edit = false; $enable_access_valider_mgr = false; $text_validation_final = "Re- final"; } else { $text_validation_final = "Val final"; } // for testing re enable all------------------------- // $enable_access_valider=true; // $enable_access_valider_mgr=true; // $enable_access_valider_final=true; // $enable_access_delete=true; // $enable_access_annuler=true; // $enable_access_edit=true; //---------------------------------------- $style_width_button = "style='width: 6em;'"; $output .= " <div class='modal-footer'>"; $output .= " <div class='btn-group btn-group-justified' role='group' aria-label='...'>"; if ($enable_access_edit) { $output .= " <p class='btn' ><a class='btn btn-primary btn-xm'{$style_width_button} href='{$p_edit}?program_id=" . urlencode($program_id) . $query_string . $url . "'>Edit</a></p>"; } if ($enable_access_delete) { if (!is_chauffeur()) { $output .= " <p class='btn'><a class='btn btn-danger btn-xm' {$style_width_button} href='{$p_del}?program_id=" . urlencode($program_id) . $query_string . $url . "'>Delete</a></p>"; } } if ($enable_access_annuler) { $output .= " <p class='btn'><a class='btn btn-danger btn-xm' {$style_width_button} href='{$p_annulation}?program_id=" . urlencode($program_id) . $query_string . $url . "'>{$text_validation_annuler}</a></p>"; } $output .= " <p class='btn' ><a class='btn btn-warning btn-xm' {$style_width_button} href='{$p_new}?program_id=" . urlencode($program_id) . $query_string . $url . "'>add</a></p>"; $output .= " </div>"; $output .= " <div class='modal-footer'>"; $output .= " <div class='btn-group btn-group-justified' role='group' aria-label='...'>"; if ($enable_access_valider) { $output .= " <p class='btn' ><a class='btn btn-success btn-group-sm '{$style_width_button} href='{$p_validation}?program_id=" . urlencode($program_id) . $query_string . $url . "'>{$text_validation}</a></p>"; } if ($enable_access_valider_mgr) { if (!is_chauffeur()) { $output .= " <p class='btn'><a class='btn btn-primary btn-xm' {$style_width_button} href='{$p_validation_mgr}?program_id=" . urlencode($program_id) . $query_string . $url . "'>{$text_validation_mgr}</a></p>"; } } if ($enable_access_valider_final) { if (!is_chauffeur()) { $output .= " <p class='btn'><a class='btn btn-primary btn-xm' {$style_width_button} href='{$p_validation_final}?program_id=" . urlencode($program_id) . $query_string . $url . "'>{$text_validation_final}</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; }
<?php echo get_output_panel_program($_GET['str_time']); ?> </div> <?php } elseif (isset($_GET['program_id'])) { ?> <div class="col-md-3 "> <?php echo nav_menu_historical(); ?> <?php echo nav_menu_pills_program(); ?> <?php $program = find_program_by_id($_GET['program_id']); ?> <?php if ($program) { echo get_output_panel_program($program["course_date"]); } ?> </div> <?php } ?> </div> <div class="row"> <?php