1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
| //srms.php
// Définition de la classe qui contient les fonctions PDO
ini_set('error_reporting',E_ALL);
class srms
{
public $base_url = 'http://notation.eamac.ne/';
public $connect;
public $query;
public $statement;
public $now;
function srms()
{
$this->connect = new PDO("mysql:host=localhost;dbname=db_notation_eamac", "root", "",array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
session_start();
$this->now = date("Y-m-d H:i:s", STRTOTIME(date('h:i:sa')));
}
function execute($data = null)
{
$this->statement = $this->connect->prepare($this->query);
if($data)
{
$this->statement->execute($data);
}
else
{
$this->statement->execute();
}
}
}
// fin du code de la classe
// un autre fichier contenant le code sql pour insérer les données dans la table
if($_POST["hidden_action"] == 'Add')
{
$error = '';
$success = '';
$subject_ch_tot=$_POST["subject_ct"]+$_POST["subject_td"]+$_POST["subject_tp"]+$_POST["subject_pro"];
$subject_coeff_tot=$_POST["subject_coeff_int"]+$_POST["subject_coeff_compo"]+$_POST["subject_coeff_exam"];
$data = array(
':class_id' => $_POST["class_id"],
':subject_name' => $_POST["subject_name"],
':subject_ct' => $_POST["subject_ct"],
':subject_td' => $_POST["subject_td"],
':subject_tp' => $_POST["subject_tp"],
':subject_pro' => $_POST["subject_pro"],
':subject_ch_tot' => $subject_ch_tot,
':subject_coeff_int' => $_POST["subject_coeff_int"],
':subject_coeff_compo' => $_POST["subject_coeff_compo"],
':subject_coeff_exa' => $_POST["subject_coeff_exam"],
':subject_coeff_tot' => $subject_coeff_tot,
':subject_group' => $_POST["subject_group"]
);
$object->query = "
SELECT * FROM subject_srms
WHERE class_id = :class_id
AND subject_name = :subject_name
";
$object->execute($data);
if($object->row_count() > 0)
{
$error = '<div class="alert alert-danger">Ce Module existe déjà pour la Promo <b>'.$object->Get_class_name($_POST["class_id"]).'</b></div>';
}
else
{
$data = array(
':class_id' => $object->clean_input($_POST["class_id"]),
':subject_name' => $object->clean_input($_POST["subject_name"]),
':subject_ct' => $object->clean_input($_POST["subject_ct"]),
':subject_td' => $object->clean_input($_POST["subject_td"]),
':subject_tp' => $object->clean_input($_POST["subject_tp"]),
':subject_pro' => $object->clean_input($_POST["subject_pro"]),
':subject_ch_tot' => $subject_ch_tot,
':subject_coeff_int' => $object->clean_input($_POST["subject_coeff_int"]),
':subject_coeff_compo' => $object->clean_input($_POST["subject_coeff_compo"]),
':subject_coeff_exa' => $object->clean_input($_POST["subject_coeff_exam"]),
':subject_coeff_tot' => $subject_coeff_tot,
':subject_group' => $object->clean_input($_POST["subject_group"]),
':subject_status' => 'Enable',
':subject_created_on' => date("Y-m-d H:i:s",STRTOTIME(date('h:i:sa'))));
// var_dump($data);
$object->query = "
INSERT INTO subject_srms
(class_id, subject_name, subject_ct, subject_td, subject_tp, subject_pro, subject_ch_tot, subject_coeff_int, subject_coeff_compo, subject_coeff_exa, subject_coeff_tot, subject_group, subject_status, subject_created_on)
VALUES (:class_id, :subject_name, :subject_ct, :subject_td, :subject_tp, :subject_pro, :subject_ch_tot, :subject_coeff_int, :subject_coeff_compo, :subject_coeff_exa, :subject_coeff_tot, :subject_group, :subject_status,
:subject_created_on)
";
$object->execute($data);
$success = '<div class="alert alert-success">Nouveau Module ajouté pour la Promo <b>'.$object->Get_class_name($_POST["class_id"]).'<b></div>';
}
$output = array(
'error' => $error,
'success' => $success
);
echo json_encode($output);
}
// fin du code
// structure de la table subject_srms
CREATE TABLE IF NOT EXISTS `subject_srms` (
`subject_id` int(11) NOT NULL,
`class_id` int(11) NOT NULL,
`subject_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`subject_ct` int(11) NOT NULL,
`subject_td` int(11) NOT NULL,
`subject_tp` int(11) NOT NULL,
`subject_pro` int(11) NOT NULL,
`subject_ch_tot` int(11) NOT NULL,
`subject_coeff_int` int(5) NOT NULL,
`subject_coeff_compo` int(5) NOT NULL,
`subject_coeff_exa` int(5) NOT NULL,
`subject_coeff_tot` int(11) NOT NULL,
`subject_group` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`subject_status` enum('Enable','Disable') COLLATE utf8_unicode_ci NOT NULL,
`subject_created_on` datetime NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
// fin |
Partager