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
| // Création de la table `monlogiciel_demande_frais`
if ($wpdb->get_var("SHOW TABLES LIKE '$table_demande_frais'") != $table_demande_frais) {
$sql = "CREATE TABLE $table_demande_frais (
id_general INT NOT NULL AUTO_INCREMENT,
code_analytique VARCHAR(50) DEFAULT NULL, -- Ajout du code analytique
lieu_deplacement VARCHAR(60) NOT NULL,
date_mois CHAR(7) DEFAULT NULL, -- Ajout de la date sous forme de mois (YYYY-MM)
motif VARCHAR(255) DEFAULT NULL, -- Ajout du motif
status ENUM('en_attente', 'valide', 'refuse') DEFAULT 'en_attente',
user_id BIGINT(20) UNSIGNED NOT NULL,
manager_id INT(11) NOT NULL,
prime_grand_deplacement tinyint(1) DEFAULT '0',
date_validation DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
KEY user_id (user_id),
KEY manager_id (manager_id)
) $charset_collate;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
// Création de la table `monlogiciel_repas_frais`
if ($wpdb->get_var("SHOW TABLES LIKE '$table_repas_frais'") != $table_repas_frais) {
$sql = "CREATE TABLE $table_repas_frais (
`id_repas` int(11) NOT NULL,
`demande_frais_id` int(11) NOT NULL,
`date_evenement` date DEFAULT NULL,
`montant_repas_midi` decimal(10,2) DEFAULT NULL,
`montant_repas_soir` decimal(10,2) DEFAULT NULL,
`piece_jointe_repas_midi` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
`piece_jointe_repas_soir` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
`style_restauration_midi` enum('restaurant','magasin','preleveur') COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
`style_restauration_soir` enum('restaurant','magasin') COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
`montant_ht_midi` decimal(10,2) DEFAULT NULL,
`tva_5_5_midi` decimal(10,2) DEFAULT NULL,
`tva_10_midi` decimal(10,2) DEFAULT NULL,
`tva_20_midi` decimal(10,2) DEFAULT NULL,
`montant_ht_soir` decimal(10,2) DEFAULT NULL,
`tva_5_5_soir` decimal(10,2) DEFAULT NULL,
`tva_10_soir` decimal(10,2) DEFAULT NULL,
`tva_20_soir` decimal(10,2) DEFAULT NULL, -- URL de la pièce jointe (si disponible)
PRIMARY KEY (id),
FOREIGN KEY (demande_frais_id) REFERENCES $table_demande_frais(id) ON DELETE CASCADE
) $charset_collate;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql); // Créer la table si elle n'existe pas;
}
// Création de la table `monlogiciel_transport_frais`
if ($wpdb->get_var("SHOW TABLES LIKE '$table_transport_frais'") != $table_transport_frais) {
$sql = "CREATE TABLE $table_transport_frais (
`id_transport` int(11) NOT NULL,
`demande_frais_id` int(11) NOT NULL,
`date_evenement` date DEFAULT NULL,
`puissance` int(11) DEFAULT NULL,
`kilometres` int(11) DEFAULT NULL,
`frais_kilometrique` decimal(10,2) DEFAULT NULL,
`essence_montant` decimal(10,2) DEFAULT NULL,
`piece_jointe_essence` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
`peage_montant` decimal(10,2) DEFAULT NULL,
`piece_jointe_peage` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
`taxi_montant` decimal(10,2) DEFAULT NULL,
`piece_jointe_taxi` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
`transport_en_commun_montant` decimal(10,2) DEFAULT NULL,
`piece_jointe_transport_en_commun` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
`train_montant` decimal(10,2) DEFAULT NULL,
`piece_jointe_train` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
`avion_montant` decimal(10,2) DEFAULT NULL,
`piece_jointe_avion` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
`ht_peage` decimal(10,2) DEFAULT NULL,
`tva_peage` decimal(10,2) DEFAULT NULL,
`ht_essence` decimal(10,2) DEFAULT NULL,
`tva_essence` decimal(10,2) DEFAULT NULL,
`parking_ttc` tinyint(1) DEFAULT NULL,
`parking_tva` decimal(10,2) DEFAULT NULL,
`parking_ht` decimal(10,2) DEFAULT NULL,
`piece_jointe_parking` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
PRIMARY KEY (id),
FOREIGN KEY (demande_frais_id) REFERENCES $table_demande_frais(id)
) $charset_collate;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
// Création de la table `monlogiciel_hebergement_frais`
if ($wpdb->get_var("SHOW TABLES LIKE '$table_hebergement_frais'") != $table_hebergement_frais) {
$sql = "CREATE TABLE $table_hebergement_frais (
id_hebergement INT NOT NULL AUTO_INCREMENT,
demande_frais_id INT NOT NULL,
date_evenement DATE DEFAULT NULL,
type_hebergement VARCHAR(50) DEFAULT NULL,
montant_hebergement DECIMAL(10,2) DEFAULT NULL,
piece_jointe_hebergement VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (id),
FOREIGN KEY (demande_frais_id) REFERENCES $table_demande_frais(id)
) $charset_collate;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
//creation de la table des frais divers
if ($wpdb->get_var("SHOW TABLES LIKE '$table_divers_frais'") != $table_divers_frais) {
$sql = "CREATE TABLE $table_divers_frais (
`id_frais` int(11) NOT NULL,
`demande_frais_id` int(11) NOT NULL,
`date_evenement` date DEFAULT NULL,
`objet_frais` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
`montant_ht` decimal(10,2) DEFAULT NULL,
`tva_20` decimal(5,2) DEFAULT NULL,
`montant_ttc` decimal(10,2) DEFAULT NULL,
`piece_jointe` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
`tva_5_5` decimal(5,2) DEFAULT NULL,
`tva_10` decimal(5,2) DEFAULT NULL,
PRIMARY KEY (id),
FOREIGN KEY (demande_frais_id) REFERENCES $table_demande_frais(id) ON DELETE CASCADE
) $charset_collate;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
} |
Partager