|
|
@@ -359,6 +359,45 @@ class document
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ static public function getAssignMe(){
|
|
|
+
|
|
|
+ $tags = user::getIdTags(session::getId());
|
|
|
+
|
|
|
+ $where = NULL;
|
|
|
+ foreach ($tags AS $key => $value) {
|
|
|
+ if($key == 0){
|
|
|
+ $where = "WHERE " . DB_T_DOCUMENTS . ".id_user_done IS NULL AND " . DB_T_DOCUMENT_TAGS . ".id_tags = " . $value . "";
|
|
|
+ } else {
|
|
|
+ $where .= " OR " . DB_T_DOCUMENT_TAGS . ".id_tags = " . $value . "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ db::query("SELECT
|
|
|
+ " . DB_T_DOCUMENTS . ".id,
|
|
|
+ " . DB_T_DOCUMENTS . ".titre,
|
|
|
+ " . DB_T_DOCUMENTS . ".date,
|
|
|
+ " . DB_T_DOCUMENTS . ".deadline,
|
|
|
+ " . DB_T_DOCUMENTS . ".description,
|
|
|
+ " . DB_T_DOCUMENTS . ".montant,
|
|
|
+ ( SELECT GROUP_CONCAT(" . DB_T_TAGS . ".label SEPARATOR ', ')
|
|
|
+ FROM " . DB_T_DOCUMENT_TAGS . "
|
|
|
+ INNER JOIN " . DB_T_TAGS . " ON " . DB_T_TAGS . ".id = " . DB_T_DOCUMENT_TAGS . ".id_tags
|
|
|
+ WHERE id_documents = " . DB_T_DOCUMENTS . ".id AND " . DB_T_DOCUMENT_TAGS . ".id_type_tags = 2
|
|
|
+ ORDER BY " . DB_T_DOCUMENT_TAGS . ".creer) AS tags,
|
|
|
+ ( SELECT GROUP_CONCAT(" . DB_T_TAGS . ".label SEPARATOR ', ')
|
|
|
+ FROM " . DB_T_DOCUMENT_TAGS . "
|
|
|
+ INNER JOIN " . DB_T_TAGS . " ON " . DB_T_TAGS . ".id = " . DB_T_DOCUMENT_TAGS . ".id_tags
|
|
|
+ WHERE id_documents = " . DB_T_DOCUMENTS . ".id AND " . DB_T_DOCUMENT_TAGS . ".id_type_tags = 1
|
|
|
+ ORDER BY " . DB_T_DOCUMENT_TAGS . ".creer) AS assign,
|
|
|
+ " . DB_T_TYPE_DOCUMENT . ".label
|
|
|
+ FROM " . DB_T_DOCUMENT_TAGS . "
|
|
|
+ INNER JOIN " . DB_T_DOCUMENTS . " ON " . DB_T_DOCUMENTS . ".id = " . DB_T_DOCUMENT_TAGS . ".id_documents
|
|
|
+ INNER JOIN " . DB_T_TYPE_DOCUMENT . " ON " . DB_T_TYPE_DOCUMENT . ".id = " . DB_T_DOCUMENTS . ".id_type
|
|
|
+ " . $where);
|
|
|
+
|
|
|
+ return db::resultset();
|
|
|
+ }
|
|
|
+
|
|
|
static public function printAttachement(array $_attachs){
|
|
|
echo '<ol class="list-group list-group-numbered">';
|
|
|
foreach ($_attachs as $key => $attach) {
|
|
|
@@ -384,4 +423,49 @@ class document
|
|
|
echo '</ol><br />';
|
|
|
}
|
|
|
|
|
|
+ static public function myAssign(?array $_tags = NULL){
|
|
|
+
|
|
|
+ if($_tags == NULL){
|
|
|
+ return NULL;
|
|
|
+ } else {
|
|
|
+ $where = NULL;
|
|
|
+ foreach ($_tags AS $key => $value) {
|
|
|
+ if($key == 0){
|
|
|
+ $where = "WHERE " . DB_T_DOCUMENTS . ".id_user_done IS NULL AND " . DB_T_DOCUMENT_TAGS . ".id_tags = " . $value . "";
|
|
|
+ } else {
|
|
|
+ $where .= " OR " . DB_T_DOCUMENT_TAGS . ".id_tags = " . $value . "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ db::query("SELECT "
|
|
|
+ . "COUNT(" . DB_T_DOCUMENT_TAGS . ".id_tags) AS nb "
|
|
|
+ . "FROM " . DB_T_DOCUMENT_TAGS . " "
|
|
|
+ . "INNER JOIN " . DB_T_DOCUMENTS . " ON " . DB_T_DOCUMENTS . ".id = " . DB_T_DOCUMENT_TAGS . ".id_documents "
|
|
|
+ . $where);
|
|
|
+ return db::single()["nb"];
|
|
|
+ }
|
|
|
+
|
|
|
+ static public function menu(){
|
|
|
+ $tags = user::getIdTags(session::getId());
|
|
|
+ $nb = document::myAssign($tags);
|
|
|
+ if($tags != NULL){
|
|
|
+ $badge = "";
|
|
|
+ if($nb > 0){
|
|
|
+ $badge = '<span class="position-absolute start-100 translate-middle badge rounded-pill bg-danger">' . $nb . '</span>';
|
|
|
+ }
|
|
|
+ echo '<a href="/documents-my-assign.html" class="dropdown-item">Vos assignations' . $badge . '</a>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ static public function badge(){
|
|
|
+ $tags = user::getIdTags(session::getId());
|
|
|
+ $nb = document::myAssign($tags);
|
|
|
+ if($tags != NULL){
|
|
|
+ if($nb > 0){
|
|
|
+ echo '<span class="position-absolute start-100 translate-middle p-1 bg-danger border border-light rounded-circle"></span>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|