[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 01/01: Task #1126 - Réécriture de la partie
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 01/01: Task #1126 - Réécriture de la partie administration Réécriture : Ajout , modification de dossier ou modèle plus cosmétique |
Date: |
Fri, 05 Jun 2015 09:12:20 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 6abc6621cbd659562522ccfd0dcf100fb01b42b0
Author: Dany De Bontridder <address@hidden>
Date: Fri Jun 5 11:08:29 2015 +0200
Task #1126 - Réécriture de la partie administration
Réécriture :
Ajout , modification de dossier ou modèle plus cosmétique
---
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 0136470..c5fad7a 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 448dc8b..f4b7667 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 df96795..f797dbd 100644
--- a/include/ajax_admin.php
+++ b/include/ajax_admin.php
@@ -53,8 +53,7 @@ if ($op=='folder_add') // operation
$dossier->load();
$content="<td>{$dossier->dos_name}</td><td>{$dossier->dos_description}</td>".
"<td>".
- HtmlInput::anchor(_('Enleve'),"",
- "
onclick=\"folder_remove({$user_id},{$dossier_id});\"").
+ HtmlInput::anchor(_('Enleve'), "", "
onclick=\"folder_remove({$user_id},{$dossier_id});\"").
"</td>";
$status='OK';
}
@@ -130,7 +129,7 @@ if ($op=='folder_display') // operation
echo HtmlInput::title_box(_("Liste dossier"), 'folder_list_div');
?>
<form method="get" onsubmit="folder_display('<?php echo $user_id ?>');
- return false">
+ return false">
<p style="text-align: center">
<?php echo _('Recherche'); ?><input type="text"
id="database_filter_input" class="input_text" autofocus="true" nohistory
autocomplete="false" value="<?php echo $p_filter ?>">
<input type="submit" class="smallbutton" value="<?php echo
_('Valider') ?>">
@@ -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 '<form action="admin_repo.php" method="post">';
+ 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 '<br>';
+ $wDesc=new ITextArea();
+ $wDesc->heigh=5;
+ echo _('Description').' : <br>';
+ echo $wDesc->input('desc', $dos->get_parameter('desc'));
+ echo '<br>';
+ echo HtmlInput::submit('upd', _('Modifie'));
+ echo '</form>';
+ $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 '<form action="admin_repo.php" method="post">';
+ echo HtmlInput::hidden('action', 'dossier_mgt');
+ echo HtmlInput::hidden('d', $dossier);
+ echo HtmlInput::hidden('sa', 'remove');
+ echo '<h2 class="error">'._('Etes vous sûr et certain de vouloir
effacer ').$dos->dos_name.' ???</h2>';
+ $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 '</form>';
+ $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 '<form action="admin_repo.php" method="post">';
+ echo HtmlInput::hidden('d', $dossier);
+ echo HtmlInput::hidden('sa', 'remove');
+ echo HtmlInput::hidden('action', 'modele_mgt');
+ echo '<h2 class="error">'._('Etes vous sure et certain de vouloir
effacer ').$name.' ?</h2>';
+ $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 '</form>';
+ $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 '<form method="post">';
+ $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 '<br>Description :<br>';
+ echo $wDesc->input('desc', $desc);
+ echo HtmlInput::hidden('m', $dossier);
+ echo HtmlInput::hidden('action', 'modele_mgt');
+ echo '<br>';
+ echo HtmlInput::submit('upd', 'Modifie');
+ echo '</form>';
+ $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 2108dfb..2ee89b3 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 '<p>';
- 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 '</p>';
$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 '<div class="content">';
echo '<span style="display:block">';
echo _('Filtre').HtmlInput::infobulle(23);
@@ -197,7 +196,7 @@ if ( $sa == 'list' )
else
$cl='class="even"';
- echo "<TR $cl><TD style=\"vertical-align:top\"> ".
+ echo "<TR id=\"folder{$Dossier['dos_id']}\" $cl><TD
style=\"vertical-align:top\"> ".
$Dossier['dos_id']."</td><td> <B>".h($Dossier['dos_name'])."</B>
</TD>";
$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 "<TD>";
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 '</td>';
}
- echo '<tr>';
$compteur++;
}
-
echo "</TR>";
}
@@ -238,11 +234,12 @@ if ( $sa == 'list' )
}
-
+?>
+<div id="folder_add_id" class="inner_box" style="display:none;top:50px">
+ <?php
//---------------------------------------------------------------------------
// Add a new folder
-if ( $sa == 'add' )
-{
+ echo HtmlInput::title_box(_("Ajout d'un dossier"), 'folder_add_id',
"hide");
$repo=new Database();
// Load the available Templates
$Res=$repo->exec_sql("select mod_id,mod_name,mod_desc from
@@ -273,68 +270,27 @@ if ( $sa == 'add' )
<TABLE>
<TR>
<TD><?php echo _('Nom du dossier');
- ?></td><td> <INPUT TYPE="TEXT" NAME="DATABASE"> </TD>
+ ?></td><td> <INPUT TYPE="TEXT" class="input_text" NAME="DATABASE"> </TD>
</TR><TR>
<TD><?php echo _('Description');
- ?></td><td> <TEXTAREA COLS="60" ROWS="2" NAME="DESCRIPTION" ></TEXTAREA>
</TD>
+ ?></td><td> <TEXTAREA class="input_text" COLS="60" ROWS="2"
NAME="DESCRIPTION" ></TEXTAREA> </TD>
</TR>
<TR> <TD><?php echo _('Modèle');
?></td><td> <?php echo $template;
?> </TD></TR>
- <TR><TD>Année </TD><TD><input type="text" size=4 name="YEAR" value=<?php
echo '"'.$m_date.'"'; ?>></TD></TR>
+ <TR><TD>Année </TD><TD><input class="input_text" type="text" size=4
name="YEAR" value=<?php echo '"'.$m_date.'"'; ?>></TD></TR>
<TR>
<TD> <INPUT TYPE=SUBMIT class="button" VALUE="<?php echo _('Creation
Dossier'); ?>"> </TD>
<td>
- <?php echo
HtmlInput::button_anchor(_('Retour'),'admin_repo.php?action=dossier_mgt');
- ?>
</td>
</TR>
</TABLE>
</FORM>
<?php
-}
-//---------------------------------------------------------------------------
-// action= mod
-if ( $sa == 'mod' )
-{
- require_once ('class_dossier.php');
- $dos=new dossier($_REQUEST['d']);
- $dos->load();
- $wText=new IText();
- echo '<form action="admin_repo.php" method="post">';
- 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 '<br>';
- $wDesc=new ITextArea();
- $wDesc->heigh=5;
- echo _('Description').' : <br>';
- echo $wDesc->input('desc',$dos->get_parameter('desc'));
- echo '<br>';
- echo HtmlInput::submit('upd',_('Modifie'));
- echo HtmlInput::button_anchor(_('Retour'),'?action=dossier_mgt');
- echo '</form>';
-}
-//---------------------------------------------------------------------------
-// action = del
-//---------------------------------------------------------------------------
-if ( $sa == 'del' )
-{
- $d=new Dossier($_REQUEST ['d'] );
- $d->load();
- echo '<form method="post">';
- echo HtmlInput::hidden('d',$_REQUEST['d']);
- echo HtmlInput::hidden('sa','remove');
- echo '<h2 class="error">'._('Etes vous sûr et certain de vouloir effacer
').$d->dos_name.' ???</h2>';
- $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 HtmlInput::button_anchor(_('Retour'),'?action=dossier_mgt');
- echo '</form>';
-}
+
+?>
+</div>
+<?php
//---------------------------------------------------------------------------
// action = del
//---------------------------------------------------------------------------
diff --git a/include/modele.inc.php b/include/modele.inc.php
index a571c99..c114dca 100644
--- a/include/modele.inc.php
+++ b/include/modele.inc.php
@@ -230,8 +230,8 @@ if ($sa == 'list')
{
echo '<p>';
- 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 '</p>';
echo '<span style="display:block;margin-top:10">';
echo _('Filtre').HtmlInput::infobulle(23);
@@ -254,11 +254,11 @@ if ($sa == 'list')
'<TD>%d </td><td><b> %s</b> </TD>' .
'<TD><I> %s </I></TD>' .
'<td> ' .
- HtmlInput::button_anchor('Effacer',
'?action=modele_mgt&sa=del&m=' . $mod['mod_id']) . '</td>' .
+ HtmlInput::anchor('Effacer',
'?action=modele_mgt&sa=del&m=' . $mod['mod_id']," onclick =
\"modele_drop('{$mod['mod_id']}') \"") . '</td>' .
'</td>' .
- '<td>' .
HtmlInput::button_anchor('Modifie', '?action=modele_mgt&sa=mod&m=' .
$mod['mod_id']) . '</td>' .
+ '<td>' . HtmlInput::anchor('Modifie',
'?action=modele_mgt&sa=mod&m=' . $mod['mod_id']," onclick =
\"modele_modify('{$mod['mod_id']}') \"") . '</td>' .
'</td>' .
- '<td>' .
HtmlInput::button_anchor('Backup', 'backup.php?action=backup&sa=b&t=m&d='
+ '<td>' . HtmlInput::anchor('Backup',
'backup.php?action=backup&sa=b&t=m&d='
. $mod['mod_id']) .
'</td>' .
'</TR>', $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</p>";
}
+?>
+<div id="folder_add_id" class="inner_box" style="display:none;top:50px">
+ <?php
+ echo HtmlInput::title_box(_("Ajout d'un modèle"), 'folder_add_id',
"hide");
+
//---------------------------------------------------------------------------
// Add a template
//---------------------------------------------------------------------------
-if ($sa == 'add')
-{
// Show All available folder
$Res = $cn->exec_sql("select dos_id, dos_name,dos_description from
ac_dossier
order by dos_name");
@@ -323,61 +326,11 @@ if ($sa == 'add')
'
- <INPUT TYPE="SUBMIT" class="button" VALUE="Ajout
d'un modele">
- <?php
- echo HtmlInput::button_anchor('Retour',
'?action=modele_mgt');
- ?>
-
- </form>
+ <INPUT TYPE="SUBMIT" class="button" VALUE="Ajout d'un modele">
+</form>
+</div>
<?php
- }
-
//---------------------------------------------------------------------------
- // Modify
- if ($sa == 'mod' && isset($_GET['m']))
- {
- $cn = new Database();
-
- echo '<form method="post">';
- $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 '<br>Description :<br>';
- echo $wDesc->input('desc', $desc);
- echo HtmlInput::hidden('m', $_GET['m']);
- echo HtmlInput::hidden('action', 'modele_mgt');
- echo '<br>';
- echo HtmlInput::button_anchor('Retour', '?action=modele_mgt');
- echo HtmlInput::submit('upd', 'Modifie');
- echo '</form>';
- }
-
-
//---------------------------------------------------------------------------
- // 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 '<form method="post">';
- echo HtmlInput::hidden('d', $_REQUEST['m']);
- echo HtmlInput::hidden('sa', 'remove');
- echo '<h2 class="error">Etes vous sure et certain de vouloir
effacer ' . $name . ' ???</h2>';
- $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 '</form>';
- }
+
//---------------------------------------------------------------------------
// action = del
//---------------------------------------------------------------------------