correction fiche contact
This commit is contained in:
139
ajax_jira.php
139
ajax_jira.php
@ -30,7 +30,7 @@ $strAction = $intEvenement = $intNewNoBib = $intEpreuveCommandee = $intEpreuve =
|
||||
//$_POST['typedemande']="test sl";
|
||||
//$_POST['summary']="sujet";
|
||||
|
||||
$typedemande = (int)($_POST['typedemande'] ?? 4);
|
||||
const JIRA_REQUEST_TYPE_SOUTIEN_TECHNIQUE = '4';
|
||||
|
||||
if (isset($_POST['request_type'] )) {
|
||||
$strAction = $_POST['request_type'];
|
||||
@ -40,82 +40,7 @@ $tabRetour = array();
|
||||
$tabRetour['success']=false;
|
||||
switch($strAction) {
|
||||
case 'check_email':
|
||||
$result=jira_recherche_email($_POST['email']);
|
||||
if($result['success']==false){
|
||||
//cree le user
|
||||
$result=jira_creer_user($_POST['email'],$_POST['nom']);
|
||||
if($result['success']==true){
|
||||
$tabRetour['success']=true;
|
||||
$tabRetour['accountId']=$result['statut']['accountId'] ;
|
||||
}else{
|
||||
$tabRetour['success']=false;
|
||||
$tabRetour['accountId']="";
|
||||
};
|
||||
|
||||
}else{
|
||||
//retourne le id
|
||||
$tabRetour['success']=true;
|
||||
$tabRetour['accountId']= $result['jira']['accountId'];
|
||||
}
|
||||
|
||||
if($tabRetour['success']==true){
|
||||
// creer le jira
|
||||
$data['serviceDeskId'] = 2; // Remplacez par l'ID réel de votre Service Desk
|
||||
$data['requestTypeId'] = (string)$typedemande; // Remplacez par l'ID réel du type de demande
|
||||
$data['summary']=$_POST['summary'];
|
||||
$data['description']=$_POST['description'];
|
||||
$data['typedemande']=$_POST['typedemande'];
|
||||
$data['raiseOnBehalfOf']= $_POST['email'] ;
|
||||
|
||||
$tabRetourtemp=jira_create_ticket($data);
|
||||
$tabRetour['success']=true;
|
||||
}else
|
||||
{
|
||||
$tabRetour['success']=false;
|
||||
$tabRetour['accountId']= "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
break;
|
||||
case 'check_emailold':
|
||||
$result=jira_recherche_email($_POST['email']);
|
||||
if($result['success']==false){
|
||||
//cree le user
|
||||
$result=jira_creer_user($_POST['email'],$_POST['nom']);
|
||||
if($result['success']==true){
|
||||
$tabRetour['success']='success';
|
||||
$tabRetour['accountId']=$result['statut']['accountId'] ;
|
||||
}else{
|
||||
$tabRetour['success']=false;
|
||||
$tabRetour['accountId']="";
|
||||
};
|
||||
|
||||
}else{
|
||||
//retourne le id
|
||||
$tabRetour['success']=true;
|
||||
$tabRetour['accountId']= $result['jira']['accountId'];
|
||||
}
|
||||
if($tabRetour['success']==true){
|
||||
// creer le jira
|
||||
$data['serviceDeskId'] = 2; // Remplacez par l'ID réel de votre Service Desk
|
||||
$data['requestTypeId'] = (string)$typedemande; // Remplacez par l'ID réel du type de demande
|
||||
$data['summary']=utf8_encode($_POST['summary']);
|
||||
$data['description']=utf8_encode($_POST['description']);
|
||||
$data['typedemande']=utf8_encode($_POST['typedemande']);
|
||||
$data['raiseOnBehalfOf']= $_POST['email'] ;
|
||||
|
||||
$tabRetourtemp=jira_create_ticket($data);
|
||||
$tabRetour['success']=true;
|
||||
}else
|
||||
{
|
||||
$tabRetour['success']=false;
|
||||
$tabRetour['accountId']= "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$tabRetour = jira_submit_contact_ticket($_POST);
|
||||
break;
|
||||
case 'no_equipe':
|
||||
case 'no_bib':
|
||||
@ -129,6 +54,62 @@ header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode($tabRetour);
|
||||
exit;
|
||||
|
||||
function jira_resolve_categorie_interne(array $post)
|
||||
{
|
||||
if (isset($post['categorie_interne'])) {
|
||||
return trim((string)$post['categorie_interne']);
|
||||
}
|
||||
|
||||
global $objDatabase;
|
||||
|
||||
if (!empty($post['typedemande']) && isset($objDatabase)) {
|
||||
$sqlCol = "SELECT info_texte FROM info WHERE info_actif = 1 AND info_clef = 'type_de_demande' AND info_option2 = '" . $objDatabase->fxEscape($post['typedemande']) . "' LIMIT 1";
|
||||
$row = $objDatabase->fxGetResults($sqlCol);
|
||||
$first = !empty($row) ? reset($row) : null;
|
||||
if (!empty($first['info_texte'])) {
|
||||
return fxJiraMapCategorieInterne($first['info_texte']);
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function jira_submit_contact_ticket(array $post)
|
||||
{
|
||||
$tabRetour = array('success' => false, 'accountId' => '');
|
||||
$userOk = false;
|
||||
|
||||
$result = jira_recherche_email($post['email']);
|
||||
if ($result['success'] == true) {
|
||||
$userOk = true;
|
||||
$tabRetour['accountId'] = $result['jira']['accountId'] ?? '';
|
||||
} else {
|
||||
$result = jira_creer_user($post['email'], $post['nom']);
|
||||
if ($result['success'] == true) {
|
||||
$userOk = true;
|
||||
$tabRetour['accountId'] = $result['statut']['accountId'] ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$userOk) {
|
||||
return $tabRetour;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'serviceDeskId' => 2,
|
||||
'requestTypeId' => JIRA_REQUEST_TYPE_SOUTIEN_TECHNIQUE,
|
||||
'summary' => $post['summary'] ?? '',
|
||||
'description' => $post['description'] ?? '',
|
||||
'categorie_interne' => jira_resolve_categorie_interne($post),
|
||||
'raiseOnBehalfOf' => $post['email'] ?? '',
|
||||
);
|
||||
|
||||
$ticket = jira_create_ticket($data);
|
||||
$tabRetour['success'] = !empty($ticket['success']);
|
||||
|
||||
return $tabRetour;
|
||||
}
|
||||
|
||||
function jira_recherche_email($param)
|
||||
{
|
||||
// recherche user
|
||||
@ -278,10 +259,12 @@ function jira_create_ticket( $param)
|
||||
'requestFieldValues' => [
|
||||
'summary' => $param['summary'],
|
||||
'description' => $param['description'],
|
||||
'customfield_11143' => $param['typedemande'],
|
||||
],
|
||||
'raiseOnBehalfOf' => $param['raiseOnBehalfOf'], // Remplacez par l'accountId du client (facultatif)
|
||||
] ;
|
||||
if (!empty($param['categorie_interne'])) {
|
||||
$data['requestFieldValues']['customfield_11143'] = $param['categorie_interne'];
|
||||
}
|
||||
$jsonData = json_encode($data);
|
||||
// if ($jsonData === false) {
|
||||
// echo "Erreur dans l'encodage JSON : " . json_last_error_msg();
|
||||
|
||||
@ -1767,8 +1767,12 @@ if ($strLangue == 'fr') {
|
||||
|
||||
$preloader.fadeOut();
|
||||
});
|
||||
var jiraSubmitInProgress = false;
|
||||
$(".send_jira").click(function (event) {
|
||||
event.preventDefault();
|
||||
if (jiraSubmitInProgress) {
|
||||
return;
|
||||
}
|
||||
if (!frm_contact.checkValidity()) {
|
||||
alert('Veuillez remplir tous les champs requis correctement.');
|
||||
return; // Stopper si le formulaire n'est pas valide
|
||||
@ -1777,15 +1781,20 @@ if ($strLangue == 'fr') {
|
||||
|
||||
});
|
||||
function jira_fx() {
|
||||
const $btn = $('.send_jira');
|
||||
const email = $('#txt_courriel').val();
|
||||
const nom = $('#txt_nom').val();
|
||||
const description = $('#txt_message').val();
|
||||
const summary = $('#txt_sujet').val();
|
||||
const typedemande = $('#typedemande').val();
|
||||
const categorie_interne = $('#typedemande option:selected').data('categorie') || '';
|
||||
|
||||
jiraSubmitInProgress = true;
|
||||
$btn.prop('disabled', true);
|
||||
|
||||
const postData = {
|
||||
request_type: 'check_email',
|
||||
email, nom, summary, description, typedemande
|
||||
email, nom, summary, description, typedemande, categorie_interne
|
||||
};
|
||||
|
||||
return fetch('/ajax_jira.php', {
|
||||
@ -1812,13 +1821,15 @@ if ($strLangue == 'fr') {
|
||||
console.log('✅ Réponse JSON:', data);
|
||||
if (data.success) {
|
||||
document.location.href = '/page/contactsend/<?php echo $strLangue; ?>';
|
||||
} else {
|
||||
// alert("Une erreur est survenue dans Jira : " + JSON.stringify(data));
|
||||
return;
|
||||
}
|
||||
jiraSubmitInProgress = false;
|
||||
$btn.prop('disabled', false);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("🔥 Erreur AJAX:", error.message);
|
||||
// alert("Erreur : " + error.message);
|
||||
jiraSubmitInProgress = false;
|
||||
$btn.prop('disabled', false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -2400,6 +2400,20 @@ function fxShowListeEvenementsContact($arrEvenements, $strLangue)
|
||||
return $strHTML;
|
||||
}
|
||||
|
||||
function fxJiraMapCategorieInterne($strLibelle)
|
||||
{
|
||||
$strNorm = mb_strtolower(trim($strLibelle));
|
||||
if (strpos($strNorm, 'organisateur') !== false) {
|
||||
return 'vente';
|
||||
}
|
||||
if (strpos($strNorm, 'participant') !== false
|
||||
&& (strpos($strNorm, 'course') !== false || strpos($strNorm, 'épreuve') !== false || strpos($strNorm, 'epreuve') !== false)) {
|
||||
return 'question resultats course';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function fxShowFormcontactjira($strLangue)
|
||||
{ global $objDatabase;
|
||||
$mem_nom="";
|
||||
@ -2480,7 +2494,7 @@ function fxShowFormcontactjira($strLangue)
|
||||
<?php
|
||||
foreach ($tabCol as $key => $value ){
|
||||
?>
|
||||
<option value="<?php echo($tabCol[$key]["info_option2"]); ?>"><?php echo($tabCol[$key]["info_texte"]); ?></option>
|
||||
<option value="<?php echo($tabCol[$key]["info_option2"]); ?>" data-categorie="<?php echo htmlspecialchars(fxJiraMapCategorieInterne($tabCol[$key]['info_texte']), ENT_QUOTES, 'UTF-8'); ?>"><?php echo($tabCol[$key]["info_texte"]); ?></option>
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user