Files
CRM/QuestionnaireListeResultatsEdit.php
BACHIR SOULDI 2794e62571 first commit
2025-09-28 08:49:37 +01:00

392 lines
15 KiB
PHP

<?php
require_once 'include/utils/utils.php';
require_once 'includes/Loader.php';
vimport ('includes.runtime.EntryPoint');
require_once 'SUtiles.php';
@session_start();
global $adb;
$current_user = Users_Record_Model::getCurrentUserModel();
$roleid = $current_user->get('roleid');
if( $_GET['canEdit'] == 1 && $roleid == "H2"){
$Permission = "";
}else{
$Permission = "disabled";
}
function getPicklist(){
global $adb;
$query5 = "SELECT accountname FROM `vtiger_account` WHERE industry like '%Grossiste%' ";
$result5 =$adb->query($query5);
$Picklist=array();
while ($recordinfo = $adb->fetch_array($result5)) {
$Picklist[] = $recordinfo;
}
return $Picklist;
}
function getQuestion($IdResultatQuestion){
global $adb;
$query = "SELECT * FROM `result_lignes_formulaire` , `lignes_formulaire` ,`formulaire` where lignes_formulaire.id_ligne_formulaire = result_lignes_formulaire.id_ligne_formulaire
and formulaire.id_formulaire = lignes_formulaire.id_formulaire and result_lignes_formulaire.id='".$IdResultatQuestion."' ";
$result =$adb->query($query);
$Question=array();
while ($recordinfo = $adb->fetch_array($result)) {
$Question[] = $recordinfo;
}
return $Question;
}
$Question = getQuestion($_GET['IdResultatQuestion']);
echo '<!-- modal -->
<div class="modal fade" id="ModalEditQuestion" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2">
<div class="modal-dialog" role="document">
<div class="modal-content" >
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel2">Questionnaire</h4>
</div>
<div class="modal-body" id="modal-body-Question">';
if($Question[0]['type_formulaire'] == "CHOIXMULTIPLES"){
$inc = 1;
echo '<form id="formEditResultatQuestion" name="formEditResultatQuestion" novalidate="novalidate">
<div class=" detailview-header-block" style="margin-top:15px;">
<div class="row" style="margin: 5px 0px 0px 0px;">
<div class="fieldBlockContainer" data-block="LBL_ADDRESS_INFORMATION">
<h4 class="fieldBlockHeader">'.$Question[0]['question'].'</h4>
<hr>
<table style="border: none; border-collapse:separate; border-spacing:0 7px; width:100%;" >
<input name="id" type="hidden" value="'.$Question[0]['id'].'">';
for ($x = 1; $x <= 10; $x++) {
$choix = 'choix'.$x;
$reponse = 'reponse'.$x;
if( $Question[0][$choix] != null){
echo'<tr >
<td style="padding-right: 10px;">
<label class="muted pull-right">';
if($Question[0][$choix] == $Question[0][$reponse]){
echo'<input type="checkbox" name="'.$reponse.'" id="'.$inc.'" value="'.$Question[0][$choix].'" checked '.$Permission.'>';
}else{
echo'<input type="checkbox" name="'.$reponse.'" id="'.$inc.'" value="'.$Question[0][$choix].'" '.$Permission.' >';
}
echo'</label>
</td>
<td style=" width:90%;">
<label for="'.$inc.'">
'.$Question[0][$choix].'
</label>
</td>
</tr>';
}
$inc=$inc+1;
}
echo '<table>
<tr>
<td>
<label for="exampleFormControlTextarea1">Commentaire </label>
</td>
</tr>
<tr>
<td>
<textarea style="width:360%;" id="exampleFormControlTextarea1" name="autres" rows="3" '.$Permission.'>'.$Question[0]['autres'].'</textarea>
</td>
</tr>
</table>';
echo ' </table>
</div>
</div>
</div></form>';
}
if($Question[0]['type_formulaire'] == "CHOIXUNIQUE"){
$inc = 1;
echo '<form id="formEditResultatQuestion" name="formEditResultatQuestion" novalidate="novalidate">
<div class=" detailview-header-block" style="margin-top:15px;">
<div class="row" style="margin: 5px 0px 0px 0px;">
<div class="fieldBlockContainer" data-block="LBL_ADDRESS_INFORMATION">
<h4 class="fieldBlockHeader">'.$Question[0]['question'].'</h4>
<hr>
<table style="border: none; border-collapse:separate; border-spacing:0 7px; width:100%;" >
<input name="id" type="hidden" value="'.$Question[0]['id'].'">';
for ($x = 1; $x <= 10; $x++) {
$choix = 'choix'.$x;
$reponse = 'reponse'.$x;
if( $Question[0][$choix] != null){
echo'<tr >
<td style="padding-right: 10px;">
<label class="muted pull-right">';
if($Question[0][$choix] == $Question[0][$reponse]){
echo'<input type="checkbox" name="'.$reponse.'" id="'.$inc.'" value="'.$Question[0][$choix].'" data-question-id="'.$Question[0]['id_ligne_formulaire'].'" checked '.$Permission.'>';
}else{
echo'<input type="checkbox" name="'.$reponse.'" id="'.$inc.'" value="'.$Question[0][$choix].'" data-question-id="'.$Question[0]['id_ligne_formulaire'].'" '.$Permission.'>';
}
echo'</label>
</td>
<td style=" width:90%;">
<label for="'.$inc.'">
'.$Question[0][$choix].'
</label>
</td>
</tr>';
}
$inc=$inc+1;
}
echo '<table>
<tr>
<td>
<label for="exampleFormControlTextarea1">Commentaire </label>
</td>
</tr>
<tr>
<td>
<textarea style="width:360%;" id="exampleFormControlTextarea1" name="autres" rows="3" '.$Permission.'>'.$Question[0]['autres'].'</textarea>
</td>
</tr>
</table>';
echo ' </table>
</div>
</div>
</div></form>';
}
if($Question[0]['type_formulaire'] == "POURCENTAGE"){
echo '<form id="formEditResultatQuestion" name="formEditResultatQuestion" novalidate="novalidate">
<div class=" detailview-header-block" style="margin-top:15px;">
<div class="row" style="margin: 5px 0px 0px 0px;">
<div class="fieldBlockContainer" data-block="LBL_ADDRESS_INFORMATION">
<h4 class="fieldBlockHeader">'.$Question[0]['question'].'</h4>
<hr>
<table style=" border-collapse:separate; border-spacing:0 7px;" >
<input name="id" type="hidden" value="'.$Question[0]['id'].'">';
for ($k = 1; $k<= 10; $k++) {
$choix = 'choix'.$k;
$reponse = 'reponse'.$k;
if( $Question[0][$choix] != null){
echo'<tr >
<td style="width: 70%; " class="fieldLabel alignMiddle">
<label>'.$Question[0][$choix].' </label>
</td>
<td >
<div class="input-group">
<input class="inputElement " type="number" min="0" max="100" id="'.$reponse.'" name="'.$reponse.'" value="'.$Question[0][$reponse].'" '.$Permission.'>
<span class="input-group-addon relatedPopup"><i>%</i></span>
</div>
</td>
</tr>';
}
}
echo '<table>
<tr>
<td>
<label for="exampleFormControlTextarea1">Commentaire </label>
</td>
</tr>
<tr>
<td>
<textarea style="width:300%;" id="exampleFormControlTextarea1" name="autres" rows="3" '.$Permission.'>'.$Question[0]['autres'].'</textarea>
</td>
</tr>
</table>';
echo ' </table>
</div>
</div>
</div></form>';
}
if($Question[0]['type_formulaire'] == "NOMBRE"){
echo '<form id="formEditResultatQuestion" name="formEditResultatQuestion" novalidate="novalidate">
<div class=" detailview-header-block" style="margin-top:15px;">
<div class="row" style="margin: 5px 0px 0px 0px;">
<div class="fieldBlockContainer" data-block="LBL_ADDRESS_INFORMATION">
<h4 class="fieldBlockHeader">'.$Question[0]['question'].'</h4>
<hr>
<table style=" border-collapse:separate; border-spacing:0 7px;" >
<input name="id" type="hidden" value="'.$Question[0]['id'].'">';
for ($k = 1; $k<= 10; $k++) {
$choix = 'choix'.$k;
$reponse = 'reponse'.$k;
if( $Question[0][$choix] != null){
echo'<tr >
<td style="width: 70%; " class="fieldLabel alignMiddle">
<label>'.$Question[0][$choix].' </label>
</td>
<td >
<div class="input-group">
<input class="inputElement " type="number" min="0" max="100" id="'.$reponse.'" name="'.$reponse.'" value="'.$Question[0][$reponse].'" '.$Permission.'>
</div>
</td>
</tr>';
}
}
echo ' </table>
</div>
</div>
</div></form>';
}
if($Question[0]['type_formulaire'] == "PICKLISTGROSSISTE"){
echo '<form id="formEditResultatQuestion" name="formEditResultatQuestion" novalidate="novalidate">
<div class=" detailview-header-block" style="margin-top:15px;">
<div class="row" style="margin: 5px 0px 0px 0px;">
<div class="fieldBlockContainer" data-block="LBL_ADDRESS_INFORMATION">
<h4 class="fieldBlockHeader">'.$Question[0]['question'].'</h4>
<hr>
<table style=" border-collapse:separate; border-spacing:0 7px;" >
<input name="id" type="hidden" value="'.$Question[0]['id'].'">';
for ($k = 1; $k<= 10; $k++) {
$choix = 'choix'.$k;
$reponse = 'reponse'.$k;
if( $Question[0][$choix] != null){
echo'<tr >
<td style="width: 70%; " class="fieldLabel alignMiddle">
<label>'.$Question[0][$choix].' </label>
</td>
<td >
<div class="input-group">
<select class="js-example-basic-single form-control" style="width:200px;" id="'.$reponse.'" name="'.$reponse.'" '.$Permission.'>
<option value=""></option>';
$Grossistes = getPicklist();
foreach ($Grossistes as $Grossiste) {
if($Grossiste['accountname'] == $Question[0][$reponse] ) {
echo '<option value="'.$Grossiste['accountname'].'" selected>'.$Grossiste['accountname'].'</option>';
}else{
echo '<option value="'.$Grossiste['accountname'].'">'.$Grossiste['accountname'].'</option>';
}
}
echo '
</select>
</div>
</td>
</tr>';
}
}
echo ' </table>
</div>
</div>
</div></form>';
}
if($Question[0]['type_formulaire'] == "PARAGRAPHE"){
echo '<form id="formEditResultatQuestion" name="formEditResultatQuestion" novalidate="novalidate">
<div class=" detailview-header-block" style="margin-top:15px;">
<div class="row" style="margin: 5px 0px 0px 0px;">
<div class="fieldBlockContainer" data-block="LBL_ADDRESS_INFORMATION">
<h4 class="fieldBlockHeader">'.$Question[0]['question'].'</h4>
<hr>
<table style=" border-collapse:separate; border-spacing:0 7px;" >
<input name="id" type="hidden" value="'.$Question[0]['id'].'">';
for ($k = 1; $k<= 10; $k++) {
$choix = 'choix'.$k;
$reponse = 'reponse'.$k;
if( $Question[0][$choix] != null){
echo'<tr >
<td style="width: 70%; " class="fieldLabel alignMiddle" colspan="2">
<label>'.$Question[0][$choix].' </label><br>
<div class="input-group">
<textarea style="width:360px;" rows="3" id="'.$reponse.'" name="'.$reponse.'" '.$Permission.'>'.$Question[0][$reponse].'</textarea>
</div>
</td>
</tr>';
}
}
echo ' </table>
</div>
</div>
</div></form>';
}
echo'</div>
<div class="modal-footer">
<center>';
if($Permission <> "disabled"){
echo'<button type="submit" name="EnregistrerQuestionnaire" onclick="UpdateResultatQuestion()" class="btn addButton btn-success" data-dismiss="modal" >Enregistrer</button>
';
}
echo'<button type="button" class="btn btn-primary" data-dismiss="modal">Fermer</button>
</center>
</div>
</div>
</div>
</div>
<style>
#modal-body-Question{
max-height: calc(100vh - 200px);
overflow-y: auto;
}
</style>
<!-- Modal -->
<!-- sophal -->';
?>
<!-- script pour liste déroulante -->
<script>
$(document).ready(function() {
$('.js-example-basic-single').select2();
});
//make checkboxes act like radio buttons
$("input:checkbox").click(function(){
if($(this).attr('data-question-id')) {
var group = "input:checkbox[data-question-id='"+$(this).attr("data-question-id")+"']";
$(group).attr("checked",false);
$(this).attr("checked",true);
}
});
</script>