Explorar el Código

Maj tags & profil

stany.ferer hace 1 año
padre
commit
b138856dac

+ 17 - 8
core/class/tags.class.php

@@ -3,29 +3,38 @@
 class tags
 {
 
-    public static function getAll() {
-        db::query("SELECT "
+    public static function getAll(float $_idTag = NULL) {
+        
+        if($_idTag == NULL){
+            db::query("SELECT "
                 . "* "
                 . "FROM " . DB_T_TAGS);
+        } else {
+            db::query("SELECT "
+                . "* "
+                . "FROM " . DB_T_TAGS 
+                . " WHERE id_type = :idTag");
+            db::bind(':idTag', $_idTag);
+        }
         return db::resultset();
     }
 
-    public static function getJquery() {
+    public static function getJquery(float $_idTag = NULL) {
         $tmp = "[";
-        foreach (self::getAll() as $tags) {
+        foreach (self::getAll($_idTag) as $tags) {
             $tmp .= "'".$tags["label"]."', ";
         }
         $tmp .= "]";
         return $tmp;
     }
 
-    public static function textToId(string $_tags = NULL) {
+    public static function textToId(string $_tags = NULL, float $_idTag = NULL) {
         $return = NULL;
         if($_tags != NULL) {
             $find = [];
             $tmp = explode(",", $_tags);
 
-            $allTags = self::getAll();
+            $allTags = self::getAll($_idTag);
 
             foreach ($allTags as $f) {
                 $find[$f["id"]] = $f["label"];
@@ -40,13 +49,13 @@ class tags
         return $return;
     }
 
-    public static function idToTtext(string $_ids = NULL) {
+    public static function idToTtext(string $_ids = NULL, float $_idTag = NULL) {
         $return = NULL;  
         if($_ids != NULL) {
 
             $tmp = explode(",", $_ids);
 
-            $allTags = self::getAll();
+            $allTags = self::getAll($_idTag);
 
             foreach ($allTags as $f) {
                 $find[$f["label"]] = $f["id"];

+ 1 - 1
core/views/_cms.head.php

@@ -3,7 +3,7 @@
     <head>
         <meta charset="UTF-8">
         <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
-        <title>CSE Invent :. CMS : Nos salariés</title>
+        <title>CSE Invent :. CMS</title>
 
         <?php pwa::printManifeste(); ?>
 

+ 1 - 1
core/views/pages/cms.document.php

@@ -184,7 +184,7 @@ if(isset($document["id"]) AND tags::compareUserDocument($userTags, $document["ta
     $(document).ready(function () {
         $('#tags').inputTags({
             autocomplete: {
-                values: <?php echo tags::getJquery() ?>,
+                values: <?php echo tags::getJquery(1) ?>,
                 only: true
             },
             max: 3

+ 20 - 8
core/views/pages/cms.user.php

@@ -93,15 +93,27 @@ if(core::ifGet("add") AND access::ifAccesss("add-user")) {
     </div>
     <br />
 
-    <div class="form-group">
+    <?php 
+        if($protect == 0 AND access::ifAccesss("add-user")) { ?>
+            <div class="form-group">
+                <label>Rôles aditionnels</label>
+                <input type="text" value="<?php
+                if (isset($user["tags"])) {
+                    echo $user["tags"];
+                }
+                ?>" id="tags" name="tags" />
+            </div>
+            <br />
+    <?php 
+        } elseif(isset($user["tags"])) { ?>
+        <div class="form-group">
         <label>Rôles aditionnels</label>
-        <input type="text" value="<?php
-        if (isset($user["tags"])) {
-            echo $user["tags"];
+            <input type="text" class="form-control" name="tags" value="<?php echo $user["tags"] ?>" readonly="readonly" />
+        </div>
+        <br />
+    <?php 
         }
-        ?>" name="tags" id="tags" />
-    </div>
-    <br />
+    ?>
 
     <div class="form-group">
         <label>Prénom</label>
@@ -195,7 +207,7 @@ if(core::ifGet("add") AND access::ifAccesss("add-user")) {
     $(document).ready(function () {
         $('#tags').inputTags({
             autocomplete: {
-                values: <?php echo tags::getJquery() ?>,
+                values: <?php echo tags::getJquery(1) ?>,
                 only: true
             },
             max: 3

+ 48 - 0
maj/sql/maj.sql

@@ -0,0 +1,48 @@
+
+
+
+--
+-- Structure de la table `type_tags`
+--
+
+CREATE TABLE `type_tags` (
+  `id` int(2) NOT NULL,
+  `label` varchar(250) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
+--
+-- Déchargement des données de la table `type_tags`
+--
+
+INSERT INTO `type_tags` (`id`, `label`) VALUES
+(1, 'Rôles'),
+(2, 'Fournisseurs');
+
+--
+-- Index pour les tables déchargées
+--
+
+--
+-- Index pour la table `type_tags`
+--
+ALTER TABLE `type_tags`
+  ADD PRIMARY KEY (`id`);
+
+--
+-- AUTO_INCREMENT pour les tables déchargées
+--
+
+--
+-- AUTO_INCREMENT pour la table `type_tags`
+--
+ALTER TABLE `type_tags`
+  MODIFY `id` int(2) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
+COMMIT;
+
+-- MAJ TAbles actuelles
+
+ALTER TABLE `tags` ADD `id_type` INT(2) NOT NULL AFTER `id`;
+
+UPDATE `tags` SET `id_type` = '1' WHERE `tags`.`id` = 1; UPDATE `tags` SET `id_type` = '1' WHERE `tags`.`id` = 2;
+
+ALTER TABLE `tags` ADD  CONSTRAINT `tags_id_type` FOREIGN KEY (`id_type`) REFERENCES `type_tags`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;