From 6abc6621cbd659562522ccfd0dcf100fb01b42b0 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 5 Jun 2015 11:08:29 +0200 Subject: [PATCH] =?UTF-8?q?Task=20#1126=20-=20R=C3=A9=C3=A9criture=20de=20?= =?UTF-8?q?la=20partie=20administration=20R=C3=A9=C3=A9criture=20:=20Ajout?= =?UTF-8?q?=20,=20modification=20de=20dossier=20ou=20mod=C3=A8le=20plus=20?= =?UTF-8?q?cosm=C3=A9tique?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/ajax_misc.php | 21 +++++++ html/js/admin.js | 57 ++++++++++++++++- include/ajax_admin.php | 133 +++++++++++++++++++++++++++++++++++++++- include/dossier.inc.php | 82 ++++++------------------- include/modele.inc.php | 75 +++++----------------- 5 files changed, 240 insertions(+), 128 deletions(-) diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 0136470f8..c5fad7a9d 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -699,6 +699,27 @@ EOF; case 'folder_add': require_once 'ajax_admin.php'; break; + + // From admin, display info and propose to drop the folder + case 'folder_drop': + require_once 'ajax_admin.php'; + break; + + // From admin, display the information of a folder you can + // modify + case 'folder_modify': + require_once 'ajax_admin.php'; + break; + // From admin, display info and propose to drop the template + case 'modele_drop': + require_once 'ajax_admin.php'; + break; + + // From admin, display the information of a template you can + // modify + case 'modele_modify': + require_once 'ajax_admin.php'; + break; default: var_dump($_GET); diff --git a/html/js/admin.js b/html/js/admin.js index 448dc8bef..f4b766756 100644 --- a/html/js/admin.js +++ b/html/js/admin.js @@ -128,4 +128,59 @@ function folder_add(p_user, p_dossier) } }); -} \ No newline at end of file +} +function display_admin_answer(p_dossier,p_action) +{ + waiting_box(); + new Ajax.Request ("ajax_misc.php",{ + method:"get", + parameters:{"p_dossier":p_dossier,"op":p_action,'gDossier':0}, + onSuccess : function (p_xml) { + try { + var div_display="folder_admin_div"; + var answer = p_xml.responseXML; + var a = answer.getElementsByTagName('status'); + var html = answer.getElementsByTagName('content'); + if (a.length == 0) { + var rec = req.responseText; + alert('erreur :' + rec); + } + + var folder; + var create = false; + if (!$(div_display)) { + folder = create_div({'id': div_display, 'cssclass': "inner_box", style: 'width:90%;right:5%;top:100px'}); + create = true; + } + folder=$(div_display); + + var content = getNodeText(html[0]); + folder.innerHTML=unescape_xml(content); + var pos=calcy(250); + $(div_display).setStyle({top:pos+'px'}); + + folder.show(); + remove_waiting_box(); + } catch (e) { + console.log(e.message); + } + } + }); +} +function folder_drop(p_dossier) +{ + display_admin_answer(p_dossier,'folder_drop'); +} + +function folder_modify(p_dossier) +{ + display_admin_answer(p_dossier,'folder_modify'); +} +function modele_modify(p_dossier) +{ + display_admin_answer(p_dossier,'modele_modify'); +} +function modele_drop(p_dossier) +{ + display_admin_answer(p_dossier,'modele_drop'); +} diff --git a/include/ajax_admin.php b/include/ajax_admin.php index df96795c1..f797dbd9d 100644 --- a/include/ajax_admin.php +++ b/include/ajax_admin.php @@ -53,8 +53,7 @@ if ($op=='folder_add') // operation $dossier->load(); $content="{$dossier->dos_name}{$dossier->dos_description}". "". - HtmlInput::anchor(_('Enleve'),"", - " onclick=\"folder_remove({$user_id},{$dossier_id});\""). + HtmlInput::anchor(_('Enleve'), "", " onclick=\"folder_remove({$user_id},{$dossier_id});\""). ""; $status='OK'; } @@ -130,7 +129,7 @@ if ($op=='folder_display') // operation echo HtmlInput::title_box(_("Liste dossier"), 'folder_list_div'); ?>
+ return false">

@@ -162,4 +161,132 @@ if ($op=='folder_display') // operation echo $dom->saveXML(); exit(); } +// For the operation 'modele_drop','modele_modify','folder_modify','folder_drop' +// the p_dossier parameter is mandatory +if (in_array($op, array('modele_drop', 'modele_modify', 'folder_modify', 'folder_drop'))) +{ + $dossier=HtmlInput::default_value_get('p_dossier', 0); + $content=_('Erreur paramètre'); + $status="NOK"; + + if ($dossier==0||isNumber($dossier)==0) + { + //---------------------------------------------------------------- + // Answer in XML + header('Content-type: text/xml; charset=UTF-8'); + $dom=new DOMDocument('1.0', 'UTF-8'); + $xml=escape_xml($content); + $xml_content=$dom->createElement('content', $xml); + $xml_status=$dom->createElement('status', $status); + $root=$dom->createElement("root"); + $root->appendChild($xml_content); + $root->appendChild($xml_status); + $dom->appendChild($root); + echo $dom->saveXML(); + exit(); + } + if ($op=='folder_modify') + { + $dos=new Dossier($dossier); + ob_start(); + $dos->load(); + echo HtmlInput::title_box(_('Modification'), 'folder_admin_div'); + $wText=new IText(); + echo ''; + echo HtmlInput::hidden('action', 'dossier_mgt'); + echo HtmlInput::hidden('d', $dos->get_parameter("id")); + echo _('Nom').' : '; + echo $wText->input('name', $dos->get_parameter('name')); + echo '
'; + $wDesc=new ITextArea(); + $wDesc->heigh=5; + echo _('Description').' :
'; + echo $wDesc->input('desc', $dos->get_parameter('desc')); + echo '
'; + echo HtmlInput::submit('upd', _('Modifie')); + echo '

'; + $content=ob_get_clean(); + $status='OK'; + } + else if ($op=='folder_drop') + { + $dos=new Dossier($dossier); + ob_start(); + echo HtmlInput::title_box(_('Efface'), 'folder_admin_div'); + $dos->load(); + echo '
'; + echo HtmlInput::hidden('action', 'dossier_mgt'); + echo HtmlInput::hidden('d', $dossier); + echo HtmlInput::hidden('sa', 'remove'); + echo '

'._('Etes vous sûr et certain de vouloir effacer ').$dos->dos_name.' ???

'; + $confirm=new ICheckBox(); + $confirm->name="p_confirm"; + echo _('Cochez la case si vous êtes sûr de vouloir effacer ce dossier'); + echo $confirm->input(); + echo HtmlInput::submit('remove', _('Effacer')); + echo '
'; + $content=ob_get_clean(); + $status='OK'; + } + else if ($op=='modele_drop') + { + $cn=new Database(); + $name=$cn->get_value('select mod_name from modeledef where mod_id=$1', array($dossier)); + ob_start(); + echo HtmlInput::title_box(_('Efface'), 'folder_admin_div'); + echo '
'; + echo HtmlInput::hidden('d', $dossier); + echo HtmlInput::hidden('sa', 'remove'); + echo HtmlInput::hidden('action', 'modele_mgt'); + echo '

'._('Etes vous sure et certain de vouloir effacer ').$name.' ?

'; + $confirm=new ICheckBox(); + $confirm->name="p_confirm"; + echo _('Cochez la case si vous êtes sûr de vouloir effacer ce modèle'); + echo $confirm->input(); + echo HtmlInput::submit('remove', 'Effacer'); + echo '
'; + $content=ob_get_clean(); + $status='OK'; + } + else if ($op=='modele_modify') + { + $cn=new Database(); + ob_start(); + echo HtmlInput::title_box(_('Modification'), 'folder_admin_div'); + echo '
'; + $name=$cn->get_value( + "select mod_name from modeledef where ". + " mod_id=$1", array($dossier)); + + $desc=$cn->get_value( + "select mod_desc from modeledef where ". + " mod_id=$1", array($dossier)); + $wText=new IText(); + echo 'Nom : '.$wText->input('name', $name); + $wDesc=new ITextArea(); + $wDesc->heigh=5; + echo '
Description :
'; + echo $wDesc->input('desc', $desc); + echo HtmlInput::hidden('m', $dossier); + echo HtmlInput::hidden('action', 'modele_mgt'); + echo '
'; + echo HtmlInput::submit('upd', 'Modifie'); + echo '
'; + $content=ob_get_clean(); + $status='OK'; + } + //---------------------------------------------------------------- + // Answer in XML + header('Content-type: text/xml; charset=UTF-8'); + $dom=new DOMDocument('1.0', 'UTF-8'); + $xml=escape_xml($content); + $xml_content=$dom->createElement('content', $xml); + $xml_status=$dom->createElement('status', $status); + $root=$dom->createElement("root"); + $root->appendChild($xml_content); + $root->appendChild($xml_status); + $dom->appendChild($root); + echo $dom->saveXML(); + exit(); +} ?> \ No newline at end of file diff --git a/include/dossier.inc.php b/include/dossier.inc.php index 2108dfb0a..2ee89b35b 100644 --- a/include/dossier.inc.php +++ b/include/dossier.inc.php @@ -156,22 +156,21 @@ if ( $sa == 'list' ) { require_once('class_sort_table.php'); echo '

'; - echo HtmlInput::button_anchor(_('Rafraîchir'),'admin_repo.php?action=dossier_mgt'); - echo HtmlInput::button_anchor(_('Ajouter'),'admin_repo.php?action=dossier_mgt&sa=add'); + echo HtmlInput::button(_('Ajouter'),_('Ajouter')," onclick=\$('folder_add_id').show()"); echo '

'; $header=new Sort_Table(); $url=$_SERVER['PHP_SELF']."?sa=list&action=".$_REQUEST['action']; $header->add("id",$url," order by dos_id asc"," order by dos_id desc","da","dd"); $header->add("Nom",$url," order by dos_name asc"," order by dos_name desc","na","nd"); $header->add("Description",$url," order by dos_description asc"," order by dos_description desc","da","dd"); - $repo=new Dossier(0); + $repo=new Dossier(0); $repocn=new Database(); $ord=(isset($_REQUEST['ord']))?$_REQUEST['ord']:'na'; $sql_order=$header->get_sql_order($ord); $Res=$repocn->get_array("select * from ac_dossier $sql_order"); $compteur=1; - $template=""; + $template=""; echo '
'; echo ''; echo _('Filtre').HtmlInput::infobulle(23); @@ -197,7 +196,7 @@ if ( $sa == 'list' ) else $cl='class="even"'; - echo " ". + echo " ". $Dossier['dos_id']." ".h($Dossier['dos_name'])." "; $str_name=domaine.'dossier'.$Dossier['dos_id']; @@ -214,23 +213,20 @@ if ( $sa == 'list' ) echo td(_("Dossier inexistant"),'style="color:red"'); } echo td($str_name); - echo ""; if ( $database_exist > 0) { - echo td(HtmlInput::button_anchor(_('Effacer'),'?action=dossier_mgt&sa=del&d='.$Dossier['dos_id'])); + echo td(HtmlInput::anchor(_('Effacer'),'?action=dossier_mgt&sa=del&d='.$Dossier['dos_id']," onclick=\"folder_drop('".$Dossier['dos_id']."')\"")); - echo td(HtmlInput::button_anchor(_('Modifier'),'?action=dossier_mgt&sa=mod&d=' - .$Dossier['dos_id'])); + echo td(HtmlInput::anchor(_('Modifier'),'?action=dossier_mgt&sa=mod&d=' + .$Dossier['dos_id']," onclick=\"folder_modify('".$Dossier['dos_id']."')\"")); - echo td(HtmlInput::button_anchor(_('Backup'),'backup.php?action=backup&sa=b&t=d&d=' + echo td(HtmlInput::anchor(_('Backup'),'backup.php?action=backup&sa=b&t=d&d=' .$Dossier['dos_id'])); echo ''; } - echo ''; $compteur++; } - echo ""; } @@ -238,11 +234,12 @@ if ( $sa == 'list' ) } - +?> + +'; - echo HtmlInput::button_anchor('Rafraîchir', 'admin_repo.php?action=modele_mgt'); - echo HtmlInput::button_anchor('Ajouter', 'admin_repo.php?action=modele_mgt&sa=add'); + echo HtmlInput::button(_('Ajouter'),_('Ajouter')," onclick=\$('folder_add_id').show()"); + echo '

'; echo ''; echo _('Filtre').HtmlInput::infobulle(23); @@ -254,11 +254,11 @@ if ($sa == 'list') '%d %s ' . ' %s ' . ' ' . - HtmlInput::button_anchor('Effacer', '?action=modele_mgt&sa=del&m=' . $mod['mod_id']) . '' . + HtmlInput::anchor('Effacer', '?action=modele_mgt&sa=del&m=' . $mod['mod_id']," onclick = \"modele_drop('{$mod['mod_id']}') \"") . '' . '' . - '' . HtmlInput::button_anchor('Modifie', '?action=modele_mgt&sa=mod&m=' . $mod['mod_id']) . '' . + '' . HtmlInput::anchor('Modifie', '?action=modele_mgt&sa=mod&m=' . $mod['mod_id']," onclick = \"modele_modify('{$mod['mod_id']}') \"") . '' . '' . - '' . HtmlInput::button_anchor('Backup', 'backup.php?action=backup&sa=b&t=m&d=' + '' . HtmlInput::anchor('Backup', 'backup.php?action=backup&sa=b&t=m&d=' . $mod['mod_id']) . '' . '', $mod['mod_id'], $mod['mod_name'], $mod['mod_desc']); }// for @@ -269,11 +269,14 @@ if ($sa == 'list') " Seules les fiches, la structure des journaux, les périodes,... seront reprises " . "et aucune donnée du dossier sur lequel le dossier est basé. Les données contenues dans les extensions ne sont pas effacées

"; } +?> + '; - $name = $cn->get_value( - "select mod_name from modeledef where " . - " mod_id=$1", array($_GET['m'])); - - $desc = $cn->get_value( - "select mod_desc from modeledef where " . - " mod_id=$1", array($_GET['m'])); - $wText = new IText(); - echo 'Nom : ' . $wText->input('name', $name); - $wDesc = new ITextArea(); - $wDesc->heigh = 5; - echo '
Description :
'; - echo $wDesc->input('desc', $desc); - echo HtmlInput::hidden('m', $_GET['m']); - echo HtmlInput::hidden('action', 'modele_mgt'); - echo '
'; - echo HtmlInput::button_anchor('Retour', '?action=modele_mgt'); - echo HtmlInput::submit('upd', 'Modifie'); - echo ''; - } - - //--------------------------------------------------------------------------- - // action = del - //--------------------------------------------------------------------------- - if ($sa == 'del') - { - $cn = new Database(); - $name = $cn->get_value('select mod_name from modeledef where mod_id=$1', array($_REQUEST['m'])); - echo '
'; - echo HtmlInput::hidden('d', $_REQUEST['m']); - echo HtmlInput::hidden('sa', 'remove'); - echo '

Etes vous sure et certain de vouloir effacer ' . $name . ' ???

'; - $confirm = new ICheckBox(); - $confirm->name = "p_confirm"; - echo 'Cochez la case si vous êtes sûr de vouloir effacer ce modèle'; - echo $confirm->input(); - echo HtmlInput::submit('remove', 'Effacer'); - echo HtmlInput::button_anchor('Retour', '?action=modele_mgt'); - echo '
'; - } + //--------------------------------------------------------------------------- // action = del //---------------------------------------------------------------------------