noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
action.common.inc.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  *   This file is part of NOALYSS.
00005  *
00006  *   NOALYSS is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   NOALYSS is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with NOALYSS; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00022 
00023 /**\file
00024  * \brief this file is common to suivi client, suivi fournisseur, suivi
00025  * administration.
00026  * The needed variables are
00027  * - $cn for the database connection
00028  * - $sub_action sa from suivi courrier but sc from Suivi client, fournisseur...
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 /* For other action
00042 /*-----------------------------------------------------------------------------*/
00043 if ( isset ($_POST['other_action_bt'])) {
00044     /**
00045      * The action id are in the array mag_id
00046      * the tag to remove are vin the array remtag
00047      * the tag to add are in the array addtag
00048      * the state in ag_state
00049      */
00050     if (  isset ($_POST['mag_id'])) {
00051         switch ($_POST['othact']) {
00052             case 'IMP':
00053                 //Impression
00054                 Follow_Up::action_print($cn,$_POST);
00055                 exit(0);
00056                 break;
00057             case 'ST':
00058                 // Etat
00059                 Follow_Up::action_set_state($cn, $_POST);
00060                 break;
00061             case 'ETIREM':
00062                 //tag
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 /* We ask to generate the document */
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 /* for delete  */
00098 if (isset($_POST['delete']))
00099         $sub_action = 'delete';
00100 if ($sub_action == "")
00101         $sub_action = "list";
00102 
00103 // if correction is asked go to directly to add_action
00104 if (isset($_POST['corr']))
00105 {
00106         $ag_comment = urldecode($_POST['ag_comment']);
00107         $sub_action = "add_action";
00108 }
00109 // if this page is called from another menu (customer, supplier,...)
00110 // a button back is added
00111 //----------------------------------------------------------------------
00112 // Update the detail
00113 // Add a new action related to this one or update
00114 //----------------------------------------------------------------------
00115 if ($sub_action == "update")
00116 {
00117         // Update the modification
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         // Add a related action
00135         //----------------------------------------------------------------------
00136         if (isset($_POST['add_action_here']))
00137         {
00138                 $act = new Follow_Up($cn);
00139 
00140 
00141                 //----------------------------------------
00142                 // puis comme ajout normal (copier / coller )
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                 // Add hidden tag
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 // Show the detail of an action
00169 // permit the update
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 
 All Data Structures Namespaces Files Functions Variables Enumerations