function rechercher_item_json($page, $limit, $libelle_item, $projet_item, $difficulte_item, $id_etat, $duree_item, $id_facteur, $id_sphere, $creation1, $creation2, $modif1, $modif2) { global $db; $start = $limit * $page - $limit; $sqlc = "select count(id_item) as count from item "; $reqc = $db->prepare($sqlc); if (!$reqc->execute()) { write_log('Erreur SQL:' . $sql . ' sur fonction : ' . __FUNCTION__ . ' ligne : ' . __LINE__); } $resc = $reqc->fetchAll(PDO::FETCH_ASSOC); if ($limit == 0) { $limit = $resc[0]['count']; } $where = ""; if ($libelle_item != '') { $where .= " and libelle_item like " . $db->quote('%' . utf8_encode($libelle_item) . '%'); } if ($projet_item != '') { $where .= " and libelle_projet like " . $db->quote('%' . utf8_encode($projet_item) . '%'); } if ($difficulte_item != '') { $where .= " and difficulte_item like '%{$difficulte_item}%' "; } if ($id_etat != '') { $where .= " and etat.id_etat like '%{$id_etat}%' "; } if ($duree_item != '') { $where .= " and duree_item like '%{$duree_item}%' "; } if ($id_sphere != "%" && $id_facteur == '%') { $where .= " and sphere.id_sphere like '{$id_sphere}' "; } if ($id_facteur != '') { $where .= " and facteur.id_facteur like '{$id_facteur}' "; } if ($creation1 != '') { $where .= " and date_creation >= '" . date_fr_to_en($creation1) . "' "; } if ($modif2 != '') { $where .= " and date_modification <= '" . date_fr_to_en($modif2) . "'"; } if ($creation2 != '') { $where .= " and date_creation <= '" . date_fr_to_en($creation2) . "'"; } if ($modif1 != '') { $where .= " and date_modification >= '" . date_fr_to_en($modif1) . "'"; } $sql = "select libelle_item, libelle_projet, difficulte_item, duree_item, libelle_etat, libelle_facteur,libelle_sphere, item.id_item, date_creation, date_modification, libelle_court_organisme from organisme, item, projet , facteur, sphere, etat where projet.id_projet=item.id_projet and organisme.id_organisme=item.id_organisme and facteur.id_sphere=sphere.id_sphere and item.id_etat=etat.id_etat and item.id_categorie=facteur.id_facteur and item.id_organisme=" . $_SESSION['id_lieu'] . " {$where} \r\n\tunion select libelle_item, libelle_projet, difficulte_item, duree_item, libelle_etat, libelle_facteur,libelle_sphere, item.id_item, date_creation, date_modification, libelle_court_organisme from droit_item , organisme, item, projet, facteur, sphere, etat where projet.id_projet=item.id_projet and organisme.id_organisme=droit_item.id_organisme and droit_item.id_item=item.id_item and organisme.id_organisme=item.id_organisme and facteur.id_sphere=sphere.id_sphere and item.id_etat=etat.id_etat and item.id_categorie=facteur.id_facteur {$where};"; $req = $db->prepare($sql); if (!$req->execute()) { write_log('Erreur SQL:' . $sql . ' sur fonction : ' . __FUNCTION__ . ' ligne : ' . __LINE__); } $res = $req->fetchAll(PDO::FETCH_ASSOC); $reponse = (object) array('records' => "", 'total' => "", 'page' => "", 'rows' => ""); $count = $resc[0]['count']; if ($limit == 0) { $total = $count; } else { $total = ceil($count / $limit); } $reponse->page = $page; $reponse->total = $total; $reponse->records = $count; $i = 0; foreach ($res as $key => $user) { foreach ($res[$key] as $k => $v) { $res[$key][$k] = utf8_encode($v); } $res[$key]['libelle_projet'] = utf8_decode($user['libelle_projet']); $res[$key]['libelle_item'] = ucfirst(utf8_decode($user['libelle_item'])) . "|" . $user['id_item']; if (is_proprietaire($user['id_item']) && !is_partage($user['id_item'])) { $res[$key]['partage'] = ""; } else { $res[$key]['partage'] = "<img src='./images/partager.png'/>"; } $res[$key]['id_item-a'] = " <img class='apercu-tab' onclick='javascript:view_item(" . $user['id_item'] . ");' src='./images/eye.png'/> | <a href='index.php?controleur=item&tache=modifier_item&id=" . $user['id_item'] . "'>Modifier</a> | <a href='index.php?controleur=item&tache=supprimer_item&id=" . $user['id_item'] . "'>Supprimer</a>"; } foreach ($res as $line) { $reponse->rows[$i]['id'] = $line['id_item']; $reponse->rows[$i]['cell'] = array($line['partage'], $line['libelle_item'], $line['libelle_projet'], $line['libelle_etat'], $line['duree_item'], $line['libelle_sphere'], $line['libelle_facteur'], $line['date_creation'], $line['date_modification'], $line['libelle_court_organisme'], $line['id_item-a']); $i++; } return $reponse; }
function reponse_item() { global $page; global $item; global $message; $page['message'] = ""; $page['gabarit'] = "administration"; if (isset($_SESSION['role_user']) && droit_acces($item['reponse_item'], $_SESSION['role_user'])) { $page['vue'] = "items/reponse_item.vue.php"; $page['colonne'] = "items/sidebar_item.vue.php"; $page['items'] = liste_item(); if (isset($_GET['id'])) { $id = $_GET['id']; } if (isset($_POST['id_item'])) { $id = $_POST['id_item']; } if (is_proprietaire($id) || is_admin($_SESSION['id_user'])) { $page['dimension'] = liste_dimension(); $page['item'] = get_item($id); $page['item'] = $page['item'][0]; $page['reponses'] = get_reponse_item($id); $page['reponses_score'] = get_reponse_score_item($id); $page['0reponses'] = get_0reponse_item($id); $page['reponse_order'] = array(); if (isset($page['reponses'][0]['nom_reponse'])) { $prec = $page['reponses'][0]['nom_reponse']; $page['reponse_order'][0]['nom_reponse'] = $prec; $i = 0; $nom_rep = array(); $nom_rep[] = $prec; foreach ($page['reponses'] as $key => $rep) { if ($prec != $rep['nom_reponse']) { $i++; $prec = $rep['nom_reponse']; $page['reponse_order'][$i]['nom_reponse'] = $prec; $nom_rep[] = $prec; } $page['reponse_order'][$i]['reponses'][] = $rep; } if (has_resulat_item($id) || on_test($id) || $page['item']['id_etat'] > 2) { $page['message'] = $message['item_edition_disabled']; } } if (isset($_POST['crea_score'])) { if (is_current_version_item($_POST['id_item'], $_POST['revision'])) { if (!has_resulat_item($_POST['id_item']) && !on_test($_POST['id_item']) && $page['item']['id_etat'] <= 2) { update_revision_item($_POST['id_item']); delete_dim_reponse_item($_POST['id_item']); $i = 0; $post = $_POST[$_POST['id_item']]; foreach ($_POST['dim'] as $val) { enregistrement_non_reponse_item($_POST['id_item'], $_POST['dim'][$i], $post['score_0_rep'][$i]); $i++; } if (isset($_POST['radio_elem'])) { enregistrement_nb_rep_max($_POST['id_item'], 1); $o = 0; foreach ($page['reponses'] as $rep) { $post = $_POST[$o]; $i = 0; enregistrer_position_reponse($rep['id_reponse'], $post['position_rep']); foreach ($post['dim'] as $val) { enregistement_dim_rep($_POST['id_item'], $rep['id_reponse'], $post['dim'][$i], $post['score_rep'][$i], $post['score_non_rep'][$i]); $i++; } $o++; } } elseif (isset($_POST['input_text'])) { //enregistrement_nb_rep_max($_POST['id_item'],1); $o = 0; $reponses = explode(';', $_POST['combinaison']); delete_reponse_item($_POST['id_item']); foreach ($reponses as $rep) { $id_rep = enregistrement_reponse_item($_POST['name_item'], $rep, $_POST['id_item']); $post = $_POST[$_POST['id_item']]; $i = 0; foreach ($post['dim'] as $val) { enregistement_dim_rep($_POST['id_item'], $id_rep, $post['dim'][$i], $post['score_rep'][$i], $post['score_non_rep'][$i]); $i++; } $o++; } if ($page['message'] == "") { header("Location: index.php?controleur=item&tache=reponse_item&id=" . $_POST['id_item']); } } elseif (isset($_POST['type_check'])) { $o = 0; foreach ($page['reponses'] as $rep) { $post = $_POST[$o]; enregistrer_position_reponse($rep['id_reponse'], $post['position_rep']); $o++; } if (isset($_POST['nb_rep_max']) && $_POST['nb_rep_max'] >= 2) { enregistrement_nb_rep_max($_POST['id_item'], $_POST['nb_rep_max']); } else { $page['message'] = $message['erreur_nb_max']; } if ($_POST['type_check'] == "combi") { $o = 0; if (isset($_POST['nb_rep_max']) && $_POST['nb_rep_max'] >= 2) { enregistrement_nb_rep_max($_POST['id_item'], $_POST['nb_rep_max']); foreach ($nom_rep as $nom) { $post = $_POST[$o]; $id_combi = enregistrement_combinaison($_POST['id_item']); if (sizeof($_POST[$nom . '_combinaison']) >= 2) { foreach ($_POST[$nom . '_combinaison'] as $combi) { enregistrement_combinaison_reponse($id_combi, $combi); } $i = 0; foreach ($post['dim'] as $val) { if (isset($post['dim'][$i]) && isset($post['score_demi_rep_combi'][$i]) && isset($post['score_non_rep_combi'][$i]) && isset($post['score_rep_combi'][$i])) { enregistement_dim_rep_combi($_POST['id_item'], $id_combi, $post['dim'][$i], $post['score_rep_combi'][$i], $post['score_non_rep_combi'][$i], $post['score_demi_rep_combi'][$i]); } $i++; } } else { $page['message'] = $message['erreur_combi']; } } } if ($page['message'] == "") { header("Location: index.php?controleur=item&tache=reponse_item&id=" . $_POST['id_item']); } } elseif ($_POST['type_check'] == "simple") { if (isset($_POST['nb_rep_max']) && $_POST['nb_rep_max'] >= 1) { $o = 0; enregistrement_nb_rep_max($_POST['id_item'], $_POST['nb_rep_max']); for ($o = 0; $o < sizeof($page['reponses']); $o++) { $post = $_POST[$o]; $i = 0; foreach ($post['dim'] as $val) { if (isset($post['dim'][$i]) && isset($post['score_rep'][$i]) && isset($post['score_non_rep'][$i])) { enregistement_dim_rep($_POST['id_item'], $page['reponses'][$o]['id_reponse'], $post['dim'][$i], $post['score_rep'][$i], $post['score_non_rep'][$i]); } $i++; } } } else { $page['message'] = $message['erreur_nb_max']; } if ($page['message'] == "") { header("Location: index.php?controleur=item&tache=reponse_item&id=" . $_POST['id_item']); } } } elseif (isset($_POST['type_trou']) && $_POST['type_trou'] == "simple") { $o = 0; foreach ($_POST['combinaisons'] as $rep) { $post = $_POST[$_POST['id_item']]; $i = 0; foreach ($post['dims'] as $val) { enregistement_dim_rep($_POST['id_item'], $rep, $post['dims'][$i], $post['score_rep'][$i], $post['score_non_rep'][$i]); $i++; } $o++; } if ($page['message'] == "") { header("Location: index.php?controleur=item&tache=reponse_item&id=" . $_POST['id_item']); } } elseif (isset($_POST['type_trou']) && $_POST['type_trou'] == "combi") { $o = 0; $post = $_POST[$_POST['id_item']]; for ($i = 1; $i <= $_POST['nb_sequence']; $i++) { $id_combi = enregistrement_combinaison($_POST['id_item'], 1); foreach ($_POST['sequence_' . $i] as $combi) { enregistrement_combinaison_reponse($id_combi, $combi); } $x = 0; foreach ($post['dim'] as $val) { enregistement_dim_rep_combi($_POST['id_item'], $id_combi, $post['dim'][$x], $post['score_rep_combi'][$x], $post['score_non_rep_combi'][$x], 0); $x++; } } if ($page['message'] == "") { header("Location: index.php?controleur=item&tache=reponse_item&id=" . $_POST['id_item']); } } } else { $page['message'] = $message['item_edition_disabled']; } } else { $page['message'] = $message['outdated_item']; } } } else { $page['message'] = $message['non_proprietaire']; } } else { $page['vue'] = "erreur_droit.vue.php"; } }