From eeba4d6363235122cca2b83bb06e163f025af1ac Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 4 Feb 2011 23:58:29 +0000 Subject: [PATCH] =?UTF-8?q?#15:=20Gestion=20des=20op=C3=A9rations=20pr?= =?UTF-8?q?=C3=A9d=C3=A9finies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/ajax_misc.php | 6 ++++ html/js/scripts.js | 61 +++++++++++++++++++++++++++++++++++-- include/modify_predf_op.php | 59 +++++++++++++++++++++++++++++++++++ include/preod.inc.php | 8 +++-- include/save_predf_op.php | 35 +++++++++++++++++++++ 5 files changed, 165 insertions(+), 4 deletions(-) create mode 100644 include/modify_predf_op.php create mode 100644 include/save_predf_op.php diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 3ef24008a..5ec3e61b7 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -450,4 +450,10 @@ case 'input_per': case 'save_per': require_once('modify_periode.inc.php'); break; +case 'mod_predf': + require_once('modify_predf_op.php'); + break; +case 'save_predf': + require_once('save_predf_op.php'); + break; } diff --git a/html/js/scripts.js b/html/js/scripts.js index b482175be..ad84f23de 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -373,11 +373,20 @@ function change_month(obj) { var queryString="gDossier="+obj.gDossier+"&op=cal"+"&per="+obj.value; var action = new Ajax.Request( - "ajax_misc.php" , { method:'get', parameters:queryString,onFailure:ajax_misc_failure,onSuccess:change_month_success} + "ajax_misc.php" , { method:'get', parameters:queryString,onFailure:ajax_misc_failure,onSuccess:success_misc} ); } -function change_month_success(req) +/** +*@brief basic answer to ajax on success, it will fill the DOMID code with +* the code. In that case, you need to create the object before the Ajax.Request +*The difference with success box is that +*@see add_div removeDiv success_box is that the width and height are not changed ajax_misc.php +*@parameter code is the ID of the object containing the html (div, button...) +*@parameter value is the html code, with it you fill the ctl element +*/ + +function success_misc(req) { try { @@ -988,3 +997,51 @@ function fill_box(req) } +/** +*display a popin to let you modified a predefined operation +*@param dossier_id +*@param od_id from table op_predef +*/ +function mod_predf_op(dossier_id,od_id) +{ + var target="mod_predf_op"; + if ( $(target)) + { + removeDiv(target); + } + var sx=posY; + var sy=posX; + var str_style="top:"+sx+";left:"+sy; + + var div={id:target, cssclass:'op_detail',style:str_style,html:loading(),drag:1}; + + add_div(div); + + var qs="?gDossier="+dossier_id+'&op=mod_predf&id='+od_id; + + var action=new Ajax.Request ( 'ajax_misc.php', + { + method:'get', + parameters:qs, + onFailure:null, + onSuccess:fill_box + } + ); + +} + +function save_predf_op(obj) +{ + var querystring="?"+$(obj).serialize()+'&op=save_predf'; + // Create a ajax request to get all the person + var action = new Ajax.Request ('ajax_misc.php', + { + method: 'get', + parameters: querystring, + onFailure: null, + onSuccess: refresh_window + } + ); + + return false; +} diff --git a/include/modify_predf_op.php b/include/modify_predf_op.php new file mode 100644 index 000000000..942e99da8 --- /dev/null +++ b/include/modify_predf_op.php @@ -0,0 +1,59 @@ +check_action(PARPREDE)==0) + { + echo alert('Action interdite'); + } +else + { + echo HtmlInput::anchor_close('mod_predf_op'); + echo h2info('Modification du nom'); + echo ' +
'; + $name=new IText('predf_name'); + $name->value=$cn->get_value('select od_name from op_predef where od_id=$1',array($_GET['id'])); + $name->size=60; + echo "Nom =".$name->input(); + echo dossier::hidden().HtmlInput::hidden('od_id',$_GET['id']); + echo "
"; + echo HtmlInput::submit('save','Sauve'); + echo HtmlInput::button('close','Annuler','onclick="removeDiv(\'mod_predf_op\')"'); + echo '
'; + + } +$html=ob_get_contents(); +ob_clean(); +$html=escape_xml($html); + +header('Content-type: text/xml; charset=UTF-8'); +echo << + +mod_predf_op +$html + +EOF; diff --git a/include/preod.inc.php b/include/preod.inc.php index d2631ddf8..890223684 100644 --- a/include/preod.inc.php +++ b/include/preod.inc.php @@ -85,10 +85,12 @@ if ( $sa == 'jrn' ) foreach ($array as $row ) { - if ( $count %2 == 0 ) - echo ''; + if ( $count %2 == 0 ) + echo ''; else echo ''; + $count++; + echo ''.h($row['od_name']).''; echo ''; echo '
'; @@ -105,6 +107,8 @@ if ( $sa == 'jrn' ) echo '
'; echo ''; + $b=HtmlInput::button('mod'.$row['od_id'],"Modifier","onclick=\"mod_predf_op('".dossier::id()."','".$row['od_id']."');\""); + echo td($b); echo ''; } diff --git a/include/save_predf_op.php b/include/save_predf_op.php new file mode 100644 index 000000000..098fe646b --- /dev/null +++ b/include/save_predf_op.php @@ -0,0 +1,35 @@ +check_action(PARPREDE)==0) exit(); + +if ( trim($_GET['predf_name']) != '') + { + $cn->exec_sql('update op_predef set od_name =$1 where od_id=$2', + array($_GET['predf_name'],$_GET['od_id'])); + $cn->commit(); + }