00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024 $User->AccessRequest($cn,SEC_ACTION);
00025
00026
00027
00028
00029 require_once("class_widget.php");
00030 require_once("class_action.php");
00031
00039 function ShowActionList($cn,$retour,$h_url)
00040 {
00041
00042 ?>
00043 <div>
00044 <span style="position:float;float:left">
00045 <form method="get" action="commercial.php">
00046 <?
00047 $a=(isset($_GET['query']))?$_GET['query']:"";
00048 printf ('<span>Titre ou référence: <input type="text" name="query" value="%s"></span>',
00049 $a);
00050 $qcode=(isset($_GET['qcode_query']))?$_GET['qcode_query']:"";
00051 echo JS_SEARCH_CARD;
00052 $w=new widget('js_search_only');
00053 $w->name='qcode_query';
00054 $w->value=$qcode;
00055 $w->label='Quick Code';
00056 $w->extra='4,9,14,16,8';
00057 $w->table=0;
00058 $sp= new widget("span");
00059
00060 echo $sp->IOValue("qcode_query_label","",$qcode);
00061 echo $w->IOValue();
00062 ?>
00063 <input type="submit" name="submit_query" value="recherche">
00064 <input type="hidden" name="sa" value="list">
00065 <input type="hidden" name="p_action" value="suivi_courrier">
00066 </form>
00067 </span>
00068
00069 <?
00070 ?>
00071 <form style="position:float;float:left" method="get" action="commercial.php">
00072 <input type="submit" name="submit_query" value="Ajout Action">
00073 <input type="hidden" name="p_action" value="suivi_courrier">
00074 <input type="hidden" name="sa" value="add_action">
00075 <!-- <input type="hidden" name="qcode_dest" value=<? echo '"'.$qcode_dest.'"';?> -->
00076 <?
00077 echo $h_url;
00078 echo $retour; ?>
00079 </form>
00080 </div>
00081 <div class="u_content">
00082
00083 <?
00084
00085 $act=new action($cn);
00089 $query="";
00090
00091 if ( isset($_REQUEST['query']) )
00092 {
00093
00094
00095 $query="and (ag_title ~* '".FormatString($_REQUEST['query'])."' ".
00096 "or ag_ref ='".trim(FormatString($_REQUEST['query']))."'".
00097 ")";
00098 }
00099
00100 $str="";
00101 if ( isset($_GET['qcode_query'] ))
00102 {
00103
00104
00105 if ( strlen(trim($_REQUEST['qcode_query'] )) != 0 )
00106 {
00107
00108 $fiche=new Fiche($cn);
00109 $fiche->GetByQCode($_REQUEST['qcode_query']);
00110 $str=" and (f_id_exp= ".$fiche->id." or ".
00111 "f_id_dest=".$fiche->id.")";
00112
00113 }
00114 }
00115
00116 $r=$act->myList(ACTION,$query.$str);
00117 echo $r;
00118 }
00119
00120
00121
00122
00123
00124
00125 $sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
00126
00127 if ( $sub_action == "" ) $sub_action="list";
00128
00129
00130 if (isset($_POST['corr'] ))
00131 {
00132 $ag_comment=urldecode($_POST['ag_comment']);
00133 $sub_action="add_action";
00134 }
00135
00136
00137
00138
00139 $retour="";
00140 $h_url="";
00141
00142 if ( isset ($_REQUEST['url']))
00143 {
00144 $retour=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',urldecode($_REQUEST['url']));
00145 $h_url=sprintf('<input type="hidden" name="url" value="%s">',urldecode($_REQUEST['url']));
00146 }
00147
00148
00149
00150
00151 if ( $sub_action=="update" )
00152 {
00153
00154 if ( isset($_POST['save']))
00155 {
00156 $act=new action($cn);
00157 $act=new action($cn);
00158
00159 $act->ag_id=$_POST['ag_id'];
00160 $act->ag_comment=$_POST['ag_comment'];
00161 $act->ag_timestamp=$_POST['ag_timestamp'];
00162 $act->d_state=$_POST['d_state'];
00163 $act->dt_id=(isset($_POST['dt_id']))?$_POST['dt_id']:0;
00164 $act->qcode_exp=$_POST['qcode_exp'];
00165 $act->qcode_dest=$_POST['qcode_dest'];
00166 $act->ag_title=$_POST['ag_title'];
00167 $act->d_id=(isset($_POST['d_id']))?$_POST['d_id']:0;
00168 if ( $act->Update() == false ) {
00169 $sub_action="detail";
00170 }
00171 else
00172 {
00173 ShowActionList($cn,$retour,$h_url);
00174 }
00175 }
00176
00177
00178
00179 if ( isset ($_POST['add_action_here']) )
00180 {
00181 $act=new action($cn);
00182 $act->ag_ref_ag_id=$_POST['ag_id'];
00183
00184
00185
00186 echo $retour;
00187 $act->ag_id=0;
00188 $act->qcode_dest=(isset($_POST['qcode_dest']))?$_REQUEST['qcode_dest']:"";
00189 $act->qcode_exp=(isset($_POST['qcode_exp']))?$_REQUEST['qcode_exp']:"";
00190 $act->f_id_dest=(isset($_POST['f_id_dest']))?$_POST['f_id_dest']:0;
00191 $act->f_id_exp=(isset($_POST['f_id_exp']))?$_POST['f_id_exp']:0;
00192
00193 $act->ag_ref_ag_id=$_POST['ag_id'];
00194 $act->ag_timestamp=(isset($_POST['ag_timestamp']))?$_POST['ag_timestamp']:"";
00195 $act->qcode_dest=isset($_POST['qcode_dest'])?$_REQUEST['qcode_dest']:"";
00196 $act->qcode_exp=isset($_POST['qcode_exp'])?$_REQUEST['qcode_exp']:"";
00197 $act->d_id=0;
00198 $act->dt_id=isset($_POST['dt_id'])?$_REQUEST['dt_id']:"";
00199 $act->d_state=(isset($_POST['d_state']))?$_POST['d_state']:"";
00200 $act->ag_ref="";
00201 $act->ag_title=(isset($_POST['ag_title']))?$_POST['ag_title']:"";
00202 echo '<div class="u_redcontent">';
00203 echo JS_SEARCH_CARD;
00204
00205 echo '<form name="RTEDemo" action="commercial.php?p_action=suivi_courrier" method="post" onsubmit="return submitForm();">';
00206
00207 $act->ag_comment=(isset($_POST['ag_comment']))?Decode($_POST['ag_comment']):"";
00208 echo_debug("action.inc",__LINE__,"call display");
00209 echo $act->Display('NEW',false);
00210
00211 echo '<input type="hidden" name="p_action" value="suivi_courrier">';
00212 echo '<input type="hidden" name="sa" value="save_action_st1">';
00213
00214 echo $h_url;
00215 echo '<input type="submit" name="save_action_st1" value="Sauver"></p>'.
00216 '</form>'.
00217 '</div>';
00218
00219 }
00220
00221
00222 }
00223
00224
00225
00226 if ( $sub_action=='detail' )
00227 {
00228 echo '<div class="u_redcontent">';
00229 echo '<A class="mtitle" HREF="commercial.php?p_action=suivi_courrier"><input type="button" value="Retour"></A>';
00230 $act=new action($cn);
00231 $act->ag_id=$_REQUEST['ag_id'];
00232 echo $act->get();
00233 $act->ag_comment=Decode($act->ag_comment);
00234 echo '<form name="RTEDemo" action="commercial.php" enctype="multipart/form-data" method="post" onsubmit="return submitForm();" >';
00235 echo JS_SEARCH_CARD;
00236 echo $act->display('UPD',false);
00237 echo '<input type="hidden" name="p_action" value="suivi_courrier">';
00238 echo '<input type="hidden" name="sa" value="update">';
00239 $upload=new widget("file");
00240 $upload->name="file_upload";
00241 $upload->value="";
00242 echo "Enregistrer le fichier ".$upload->IOValue();
00243 echo $upload->Submit("save","Sauve");
00244 echo $upload->Submit("add_action_here","Ajoute une action à celle-ci");
00245 echo '</form>';
00246
00247 echo $retour;
00248
00249 echo '</div>';
00250 }
00251
00252
00253 if ( $sub_action == "list" )
00254 ShowActionList($cn,$retour,$h_url);
00255
00256
00257
00258 if ( $sub_action == "add_action" )
00259 {
00260 echo '<A class="mtitle" HREF="commercial.php?p_action=suivi_courrier"><input type="button" value="Retour"></A>';
00261 echo_debug('action',__LINE__,var_export($_POST,true));
00262 echo $retour;
00263 $act=new action($cn);
00264 $act->ag_id=0;
00265 $act->ag_ref_ag_id=(isset($_POST['ag_ref_ag_id']))?$_POST['ag_ref_ag_id']:"0";
00266 $act->ag_timestamp=(isset($_POST['ag_timestamp']))?$_POST['ag_timestamp']:"";
00267 $act->qcode_dest=(isset($_POST['qcode_dest']))?$_REQUEST['qcode_dest']:"";
00268 $act->qcode_exp=(isset($_POST['qcode_exp']))?$_REQUEST['qcode_exp']:"";
00269 $act->f_id_dest=(isset($_POST['f_id_dest']))?$_POST['f_id_dest']:0;
00270 $act->f_id_exp=(isset($_POST['f_id_exp']))?$_POST['f_id_exp']:0;
00271 $act->d_id=0;
00272 $act->dt_id=isset($_POST['dt_id'])?$_REQUEST['dt_id']:"";
00273 $act->d_state=(isset($_POST['d_state']))?$_POST['d_state']:"";
00274 $act->ag_ref="";
00275 $act->ag_title=(isset($_POST['ag_title']))?$_POST['ag_title']:"";
00276 echo '<div class="u_redcontent">';
00277 echo JS_SEARCH_CARD;
00278
00279 echo '<form name="RTEDemo" action="commercial.php?p_action=suivi_courrier" method="post" onsubmit="return submitForm();">';
00280
00281 $act->ag_comment=(isset($_POST['ag_comment']))?Decode($_POST['ag_comment']):"";
00282 echo_debug("action.inc",__LINE__,"call display");
00283 echo $act->Display('NEW',false);
00284
00285 echo '<input type="hidden" name="p_action" value="suivi_courrier">';
00286 echo '<input type="hidden" name="sa" value="save_action_st1">';
00287
00288 echo $h_url;
00289 echo '<input type="submit" name="save_action_st1" value="Sauver"></p>'.
00290 '</form>'.
00291 '</div>';
00292
00293 }
00294
00295
00296
00297
00298 if ( $sub_action == "save_action_st1" )
00299 {
00300 $act=new action($cn);
00301 $act->ag_timestamp=$_POST['ag_timestamp'];
00302 $act->ag_comment=$_POST['ag_comment'];
00303 $act->ag_timestamp=$_POST['ag_timestamp'];
00304 $act->d_state=$_POST['d_state'];
00305 $act->dt_id=$_POST['dt_id'];
00306 $act->qcode_exp=$_POST['qcode_exp'];
00307 $act->qcode_dest=$_POST['qcode_dest'];
00308 $act->f_id_dest=$_POST['f_id_dest'];
00309 $act->f_id_exp=$_POST['f_id_exp'];
00310
00311 $act->ag_title=$_POST['ag_title'];
00312 $act->d_id=0;
00313 $act->ag_id=$_POST['ag_id'];
00314 $act->ag_ref_ag_id=(isset($_POST['ag_ref_ag_id']))?$_POST['ag_ref_ag_id']:0;
00315
00316 echo $act->Confirm();
00317 }
00318
00319
00320
00321
00322 if ( $sub_action == "save_action_st2" )
00323 {
00324 $act=new action($cn);
00325
00326 $act->ag_comment=$_POST['ag_comment'];
00327 $act->ag_timestamp=$_POST['ag_timestamp'];
00328 $act->d_state=$_POST['d_state'];
00329 $act->dt_id=$_POST['dt_id'];
00330 $act->qcode_dest=$_POST['qcode_dest'];
00331 $act->qcode_exp=$_POST['qcode_exp'];
00332 $act->f_id_dest=$_POST['f_id_dest'];
00333 $act->f_id_exp=$_POST['f_id_exp'];
00334
00335 $act->ag_title=$_POST['ag_title'];
00336 $act->d_id=0;
00337 $act->ag_ref_ag_id=(isset($_POST['ag_ref_ag_id']))?$_POST['ag_ref_ag_id']:0;
00338 $act->md_id=(isset($_POST['gen_doc']))?$_POST['gen_doc']:0;
00339
00340 $act->gen=isset($_POST['p_gen'])?'on':'off';
00341
00342 echo $act->SaveStage2();
00343 echo '<A HREF="commercial.php?p_action=suivi_courrier"><INPUT TYPE="BUTTON" VALUE="Retour Liste"></A>';
00344 }
00345
00346
00347
00348
00349
00350 if ( $sub_action == "save_action_st3" )
00351 {
00352 echo_debug("action.inc.php",__LINE__,'Stage 3');
00353 $act=new action($cn);
00354 $act->ag_id=$_POST['ag_id'];
00355 $act->ag_ref_ag_idid=$_POST['ag_ref_ag_id'];
00356 $act->ag_comment=$_POST['ag_comment'];
00357 $act->ag_timestamp=$_POST['ag_timestamp'];
00358 $act->d_state=$_POST['d_state'];
00359 $act->dt_id=$_POST['dt_id'];
00360 $act->qcode_dest=$_POST['qcode_dest'];
00361 $act->qcode_exp=$_POST['qcode_exp'];
00362
00363 $act->ag_title=$_POST['ag_title'];
00364 $d_id=(isset($_POST['d_id']))?$_POST['d_id']:0;
00365 $act->ag_ref_ag_id=(isset($_POST['ag_ref_ag_id']))?$_POST['ag_ref_ag_id']:0;
00366 echo $act->SaveStage3($d_id);
00367 ShowActionList($cn,$retour,$h_url);
00368
00369 }
00370
00371
00372 echo "</div>";