00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00032 $supl_hidden = '';
00033 if (isset($_REQUEST['sc']))
00034 $supl_hidden.=HtmlInput::hidden('sc', $_REQUEST['sc']);
00035 if (isset($_REQUEST['f_id']))
00036 $supl_hidden.=HtmlInput::hidden('f_id', $_REQUEST['f_id']);
00037 if (isset($_REQUEST['sb']))
00038 $supl_hidden.=HtmlInput::hidden('sb', $_REQUEST['sb']);
00039 $supl_hidden.=HtmlInput::hidden('ac', $_REQUEST['ac']);
00040 $correction = 0;
00041 $error_id=0;
00042
00043
00044
00045 if ( isset ($_POST['other_action_bt'])) {
00046
00047
00048
00049
00050
00051
00052 if ( isset ($_POST['mag_id'])) {
00053 switch ($_POST['othact']) {
00054 case 'IMP':
00055
00056 Follow_Up::action_print($cn,$_POST);
00057 return;
00058 break;
00059 case 'ST':
00060
00061 Follow_Up::action_set_state($cn, $_POST);
00062 break;
00063 case 'ETIREM':
00064
00065 Follow_Up::action_tag_remove($cn, $_POST);
00066 break;
00067 case 'ETIADD':
00068 Follow_Up::action_tag_add($cn, $_POST);
00069 break;
00070 case 'ETICLEAR':
00071 Follow_Up::action_tag_clear($cn,$_POST);
00072 break;
00073 case 'DOCREM':
00074 Follow_Up::action_remove($cn, $_POST);
00075 break;
00076 }
00077 }
00078 }
00079
00080
00081
00082
00083 if (isset($_POST['generate']))
00084 {
00085 $act = new Follow_Up($cn);
00086 $act->fromArray($_POST);
00087 if ($act->ag_id == 0)
00088 {
00089 $act->save();
00090 $ag_id = $act->ag_id;
00091 }
00092 else
00093 {
00094 $act->Update();
00095 }
00096 $act->generate_document($_POST['doc_mod'], $_POST);
00097 $sub_action = 'detail';
00098 }
00099
00100 if (isset($_POST['delete']))
00101 $sub_action = 'delete';
00102 if ($sub_action == "")
00103 $sub_action = "list";
00104
00105
00106 if (isset($_POST['corr']))
00107 {
00108 $ag_comment = urldecode($_POST['ag_comment']);
00109 $sub_action = "add_action";
00110 }
00111
00112
00113
00114
00115
00116
00117 if ($sub_action == "update")
00118 {
00119
00120 if (isset($_POST['save']))
00121 {
00122 $act2 = new Follow_Up($cn);
00123 $act2->fromArray($_POST);
00124 if ($g_user->can_write_action($act2->ag_id) == false )
00125 {
00126 echo '<div class="redcontent">';
00127 echo '<h2 class="error">'._('Cette action ne vous est pas autorisée Contactez votre responsable').'</h2>';
00128 echo '</div>';
00129 return;
00130 }
00131 $sub_action = "detail";
00132 put_global(array(array('key' => "sa", "value" => "detail")));
00133 try {
00134 $act2->verify() ;
00135 $act2->Update() ;
00136 }
00137 catch (Exception $e)
00138 {
00139 echo '<span class="notice">';
00140 echo _("Erreur")." ".$e->getMessage();
00141 echo '</span>';
00142 $sub_action="detail";
00143 $correction = 1;
00144 $act = clone $act2;
00145 $act->get();
00146 $act->fromArray($_POST);
00147 $error_id=$e->getCode();
00148 }
00149 }
00150
00151
00152
00153 if (isset($_POST['add_action_here']))
00154 {
00155 $act = new Follow_Up($cn);
00156
00157
00158
00159
00160 $act->fromArray($_POST);
00161 $act->ag_id = 0;
00162 $act->d_id = 0;
00163 $act->action = $_POST['ag_id'];
00164
00165 echo '<div class="content">';
00166
00167
00168 echo '<form enctype="multipart/form-data" action="do.php" method="post"">';
00169
00170 $act->ag_comment = "";
00171 if (isset($_REQUEST['qcode_dest']))
00172 $act->qcode_dest = $_REQUEST['qcode_dest'];
00173 echo $act->Display('NEW', false, $base, $retour);
00174
00175 echo '<input type="hidden" name="ac" value="' . $_REQUEST['ac'] . '">';
00176 echo '<input type="hidden" name="sa" value="save_action_st2">';
00177 echo '<input type="submit" class="button" name="save_action_st2" value="' . _('Enregistrer') . '">';
00178 echo '<input type="submit" class="button" name="generate" value="' . _('Génère le document') . '"></p>';
00179 echo $supl_hidden;
00180 echo '</form>';
00181 echo '</div>';
00182 }
00183 }
00184
00185
00186
00187 if ($sub_action == 'detail')
00188 {
00189 echo '<div class="content">';
00190 if ( $correction == 0 )
00191 {
00192 $act = new Follow_Up($cn);
00193 $act->ag_id = $ag_id;
00194 echo $act->get();
00195 }
00196
00197 if ($g_user->can_write_action($ag_id) == true)
00198 {
00199 echo '<form enctype="multipart/form-data" class="print" action="do.php" method="post" >';
00200 echo $supl_hidden;
00201 echo HtmlInput::hidden('ac', $_REQUEST['ac']);
00202 echo dossier::hidden();
00203 echo $act->Display('UPD', false, $base, $retour);
00204 echo '<input type="hidden" name="sa" value="update">';
00205 echo HtmlInput::submit("save", "Sauve");
00206 echo HtmlInput::submit("add_action_here", _("Ajoute une action à celle-ci"));
00207 echo HtmlInput::submit("delete", _("Efface cette action"), ' onclick="return confirm(\'' . _("Vous confirmez l\'effacement") . '\')" ');
00208 echo $retour;
00209 echo '</form>';
00210 }
00211 else if ($g_user->can_read_action($ag_id) == true || $act->ag_dest == -1)
00212 {
00213 echo $act->Display('READ', false, $base, $retour);
00214 }
00215 else
00216 {
00217 echo h2info(_("Ce document n'est pas accessible"));
00218 return;
00219 }
00220
00221
00222 echo '</div>';
00223 }
00224 //-------------------------------------------------------------------------------
00225 // Delete an action
00226 if ($sub_action == 'delete')
00227 {
00228 // confirmed
00229 $cn->start();
00230 $act = new Follow_Up($cn);
00231 $act->ag_id = $_REQUEST['ag_id'];
00232 $act->get();
00233 if ($g_user->can_write_action($_REQUEST['ag_id'])==true) $act->remove();
00234 $sub_action = "list";
00235 $cn->commit();
00236 Follow_Up::show_action_list($cn, $base);
00237 if (isset($act->ag_ref))
00238 echo hb(_('Action ') . $act->ag_ref . _(' effacée'));
00239 return;
00240 }
00241
00242 //--------------------------------------------------------------------------------
00243 // Show a list of the action
00244 if ($sub_action == "list")
00245 {
00246 // Add a button to export to Csv
00247 echo '<form method="GET" style="display:inline;" ACTION="export.php">';
00248 echo HtmlInput::request_to_hidden(array("closed_action","remind_date_end","remind_date","sag_ref", "remind_date","only_internal", "state", "gDossier", "qcode", "start_date", "end_date", "ag_id", "ag_dest_query",
00249 "tdoc", "action_query","date_start","date_end","hsstate","searchtag"));
00250 echo HtmlInput::hidden("act", "CSV:ActionGestion");
00251 echo HtmlInput::submit("follow_up_csv", "Export CSV",'','smallbutton');
00252 echo "</form>";
00253 Follow_Up::show_action_list($cn, $base);
00254 }
00255 //--------------------------------------------------------------------------------
00256 // Save Follow_Up
00257 // Stage 2 : Save a NEW action + Files and generate eventually a document
00258 //--------------------------------------------------------------------------------
00259 if ($sub_action == "save_action_st2")
00260 {
00261 $act = new Follow_Up($cn);
00262 $act->fromArray($_POST);
00263 try {
00264 $act->d_id = 0;
00265 $act->md_id = (isset($_POST['gen_doc'])) ? $_POST['gen_doc'] : 0;
00266
00267 $act->verify();
00268
00269 // insert into action_gestion
00270 echo $act->save();
00271 $url = "?$base&sa=detail&ag_id=" . $act->ag_id . '&' . dossier::get();
00272 echo '<p><a class="mtitle" href="' . $url . '">' . hb(_('Action Sauvée').' : ' . $act->ag_ref) . '</a></p>';
00273
00274 Follow_Up::show_action_list($cn,$base);
00275 $url = "?$base&sa=detail&ag_id=" . $act->ag_id . '&' . dossier::get();
00276 echo '<p><a class="mtitle" href="' . $url . '">' . hb(_('Action Sauvée').' : ' . $act->ag_ref) . '</a></p>';
00277 } catch (Exception $e)
00278 {
00279 echo '<span class="notice">';
00280 echo _("Erreur")." ".$e->getMessage();
00281 echo '</span>';
00282 $sub_action="add_action";
00283 $error_id=$e->getCode();
00284 }
00285 }
00286 //--------------------------------------------------------------------------------
00287 // Add an action
00288 if ($sub_action == "add_action")
00289 {
00290 $act = new Follow_Up($cn);
00291 $act->fromArray($_POST);
00292 $act->ag_id = 0;
00293 $act->d_id = 0;
00294 echo '<div class="content">';
00295 // Add hidden tag
00296 echo '<form method="post" action="do.php" name="form_add" id="form_add" enctype="multipart/form-data" >';
00297 echo $supl_hidden;
00298 echo dossier::hidden();
00299
00300
00301 $act->ag_comment = (isset($_POST['ag_comment'])) ? Decode($_POST['ag_comment']) : "";
00302 if (isset($_REQUEST['qcode']))
00303 $act->qcode_dest = $_REQUEST['qcode'];
00304 echo $act->Display('NEW', false, $base, $retour);
00305
00306 echo '<input type="hidden" name="ac" value="' . $_REQUEST["ac"] . '">';
00307 echo '<input type="hidden" name="sa" value="save_action_st2">';
00308 echo '<input type="hidden" name="save_action_st2" value="save_action_st2">';
00309 echo '<input type="submit" class="button" name="save_action_st2" value="' . _('Enregistrer') . '">';
00310 echo '</form>';
00311
00312 echo '</div>';
00313
00314 }
00315 if ( $error_id != 0 ){
00316 $error[10]='dt_id';
00317 $error[20]='ag_timestamp';
00318 $error[30]='ag_remind_date';
00319 $div=$error[$error_id];
00320 $js=<<<EOF
00321 <script>$('$div').style.borderColor="red";
00322 $('info_div').innerHTML='erreur';
00323 </script>
00324
00325 EOF;
00326 echo $js;
00327 }
00328 ?>
00329