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
00041
00042
00043 if ( isset ($_POST['other_action_bt'])) {
00044
00045
00046
00047
00048
00049
00050 if ( isset ($_POST['mag_id'])) {
00051 switch ($_POST['othact']) {
00052 case 'IMP':
00053
00054 Follow_Up::action_print($cn,$_POST);
00055 exit(0);
00056 break;
00057 case 'ST':
00058
00059 Follow_Up::action_set_state($cn, $_POST);
00060 break;
00061 case 'ETIREM':
00062
00063 Follow_Up::action_tag_remove($cn, $_POST);
00064 break;
00065 case 'ETIADD':
00066 Follow_Up::action_tag_add($cn, $_POST);
00067 break;
00068 case 'ETICLEAR':
00069 Follow_Up::action_tag_clear($cn,$_POST);
00070 break;
00071 case 'DOCREM':
00072 Follow_Up::action_remove($cn, $_POST);
00073 break;
00074 }
00075 }
00076 }
00077
00078
00079
00080
00081 if (isset($_POST['generate']))
00082 {
00083 $act = new Follow_Up($cn);
00084 $act->fromArray($_POST);
00085 if ($act->ag_id == 0)
00086 {
00087 $act->save();
00088 $ag_id = $act->ag_id;
00089 }
00090 else
00091 {
00092 $act->Update();
00093 }
00094 $act->generate_document($_POST['doc_mod'], $_POST);
00095 $sub_action = 'detail';
00096 }
00097
00098 if (isset($_POST['delete']))
00099 $sub_action = 'delete';
00100 if ($sub_action == "")
00101 $sub_action = "list";
00102
00103
00104 if (isset($_POST['corr']))
00105 {
00106 $ag_comment = urldecode($_POST['ag_comment']);
00107 $sub_action = "add_action";
00108 }
00109
00110
00111
00112
00113
00114
00115 if ($sub_action == "update")
00116 {
00117
00118 if (isset($_POST['save']))
00119 {
00120 $act2 = new Follow_Up($cn);
00121 $act2->fromArray($_POST);
00122 if ($g_user->can_write_action($act2->ag_id) == false )
00123 {
00124 echo '<div class="redcontent">';
00125 echo '<h2 class="error">'._('Cette action ne vous est pas autorisée Contactez votre responsable').'</h2>';
00126 echo '</div>';
00127 exit();
00128 }
00129 $sub_action = "detail";
00130 put_global(array(array('key' => "sa", "value" => "detail")));
00131 $act2->Update() ;
00132 }
00133
00134
00135
00136 if (isset($_POST['add_action_here']))
00137 {
00138 $act = new Follow_Up($cn);
00139
00140
00141
00142
00143 $act->fromArray($_POST);
00144 $act->ag_id = 0;
00145 $act->d_id = 0;
00146 $act->action = $_POST['ag_id'];
00147
00148 echo '<div class="content">';
00149
00150
00151 echo '<form enctype="multipart/form-data" action="do.php" method="post"">';
00152
00153 $act->ag_comment = "";
00154 if (isset($_REQUEST['qcode_dest']))
00155 $act->qcode_dest = $_REQUEST['qcode_dest'];
00156 echo $act->Display('NEW', false, $base, $retour);
00157
00158 echo '<input type="hidden" name="ac" value="' . $_REQUEST['ac'] . '">';
00159 echo '<input type="hidden" name="sa" value="save_action_st2">';
00160 echo '<input type="submit" class="button" name="save_action_st2" value="' . _('Enregistrer') . '">';
00161 echo '<input type="submit" class="button" name="generate" value="' . _('Génère le document') . '"></p>';
00162 echo $supl_hidden;
00163 echo '</form>';
00164 echo '</div>';
00165 }
00166 }
00167
00168
00169
00170 if ($sub_action == 'detail')
00171 {
00172 echo '<div class="content">';
00173 $act = new Follow_Up($cn);
00174 $act->ag_id = $ag_id;
00175
00176 echo $act->get();
00177 if ($g_user->can_write_action($ag_id) == true)
00178 {
00179 echo '<form enctype="multipart/form-data" class="print" action="do.php" method="post" >';
00180 echo $supl_hidden;
00181 echo HtmlInput::hidden('ac', $_REQUEST['ac']);
00182 echo dossier::hidden();
00183 echo $act->Display('UPD', false, $base, $retour);
00184 echo '<input type="hidden" name="sa" value="update">';
00185 echo HtmlInput::submit("save", "Sauve");
00186 echo HtmlInput::submit("add_action_here", _("Ajoute une action à celle-ci"));
00187 echo HtmlInput::submit("delete", _("Efface cette action"), ' onclick="return confirm(\'' . _("Vous confirmez l\'effacement") . '\')" ');
00188 echo $retour;
00189 echo '</form>';
00190 }
00191 else if ($g_user->can_read_action($ag_id) == true || $act->ag_dest == -1)
00192 {
00193 echo $act->Display('READ', false, $base, $retour);
00194 }
00195 else
00196 {
00197 echo h2info(_("Ce document n'est pas accessible"));
00198 exit();
00199 }
00200
00201
00202 echo '</div>';
00203 }
00204 //-------------------------------------------------------------------------------
00205 // Delete an action
00206 if ($sub_action == 'delete')
00207 {
00208 // confirmed
00209 $cn->start();
00210 $act = new Follow_Up($cn);
00211 $act->ag_id = $_REQUEST['ag_id'];
00212 $act->get();
00213 if ($g_user->can_write_action($_REQUEST['ag_id'])==true) $act->remove();
00214 $sub_action = "list";
00215 $cn->commit();
00216 Follow_Up::show_action_list($cn, $base);
00217 if (isset($act->ag_ref))
00218 echo hb(_('Action ') . $act->ag_ref . _(' effacée'));
00219 exit();
00220 }
00221
00222 //--------------------------------------------------------------------------------
00223 // Show a list of the action
00224 if ($sub_action == "list")
00225 {
00226 // Add a button to export to Csv
00227 echo '<form method="GET" style="display:inline;" ACTION="export.php">';
00228 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",
00229 "tdoc", "action_query","date_start","date_end","hsstate","searchtag"));
00230 echo HtmlInput::hidden("act", "CSV:ActionGestion");
00231 echo HtmlInput::submit("follow_up_csv", "Export CSV",'','smallbutton');
00232 echo "</form>";
00233 Follow_Up::show_action_list($cn, $base);
00234 }
00235 //--------------------------------------------------------------------------------
00236 // Add an action
00237 if ($sub_action == "add_action")
00238 {
00239 $act = new Follow_Up($cn);
00240 $act->fromArray($_POST);
00241 $act->ag_id = 0;
00242 $act->d_id = 0;
00243 echo '<div class="content">';
00244 // Add hidden tag
00245 echo '<form method="post" action="do.php" name="form_add" id="form_add" enctype="multipart/form-data" >';
00246 echo $supl_hidden;
00247 echo dossier::hidden();
00248
00249
00250 $act->ag_comment = (isset($_POST['ag_comment'])) ? Decode($_POST['ag_comment']) : "";
00251 if (isset($_REQUEST['qcode']))
00252 $act->qcode_dest = $_REQUEST['qcode'];
00253 echo $act->Display('NEW', false, $base, $retour);
00254
00255 echo '<input type="hidden" name="ac" value="' . $_REQUEST["ac"] . '">';
00256 echo '<input type="hidden" name="sa" value="save_action_st2">';
00257 echo '<input type="hidden" name="save_action_st2" value="save_action_st2">';
00258 echo '<input type="submit" class="button" name="save_action_st2" value="' . _('Enregistrer') . '">';
00259 echo '</form>';
00260
00261 echo '</div>';
00262 }
00263 //--------------------------------------------------------------------------------
00264 // Save Follow_Up
00265 // Stage 2 : Save the action + Files and generate eventually a document
00266 //--------------------------------------------------------------------------------
00267 if ($sub_action == "save_action_st2")
00268 {
00269 $act = new Follow_Up($cn);
00270 $act->fromArray($_POST);
00271 $act->d_id = 0;
00272 $act->md_id = (isset($_POST['gen_doc'])) ? $_POST['gen_doc'] : 0;
00273
00274 // insert into action_gestion
00275 echo $act->save();
00276 $url = "?$base&sa=detail&ag_id=" . $act->ag_id . '&' . dossier::get();
00277 echo '<p><a class="mtitle" href="' . $url . '">' . hb(_('Action Sauvée').' : ' . $act->ag_ref) . '</a></p>';
00278
00279 Follow_Up::show_action_list($cn,$base);
00280 $url = "?$base&sa=detail&ag_id=" . $act->ag_id . '&' . dossier::get();
00281 echo '<p><a class="mtitle" href="' . $url . '">' . hb(_('Action Sauvée').' : ' . $act->ag_ref) . '</a></p>';
00282 }
00283 ?>
00284