00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00025
00026
00028 require_once("class_widget.php");
00029 require_once("class_action.php");
00030
00031
00032
00033
00034
00035
00036 $sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
00037 var_dump($_REQUEST);echo '<hr>';
00038 if ( $sub_action == "" ) $sub_action="list";
00039
00040
00041 if (isset($_POST['corr'] ))
00042 $sub_action="add_action";
00043
00044
00045
00046
00047 if ( isset ($_REQUEST['url']))
00048 {
00049 $retour=sprintf('<A HREF="%s"><input type="button" value="Retour"></A>',urldecode($_REQUEST['url']));
00050 $h_url=sprintf('<input type="hidden" name="url" value="%s">',urldecode($_REQUEST['url']));
00051 }
00052 else
00053 {
00054 $retour="";
00055 $h_url="";
00056 }
00058
00059 if ( $sub_action == "list" )
00060 {
00061
00062
00063
00064 ?>
00065 <div class="u_content">
00066 <span>
00067 <form method="get" action="commercial.php">
00068 <?
00069 $a=(isset($_GET['query']))?$_GET['query']:"";
00070 printf ('<span>Titre : <input type="text" name="query" value="%s"></span>',
00071 $a);
00072 $qcode=(isset($_GET['qcode']))?$_GET['qcode']:"";
00073 printf ('<span>Tiers QuickCode: <input type="text" name="qcode" value="%s"></span>',
00074 $qcode);
00075
00076 ?>
00077 <input type="submit" name="submit_query" value="recherche">
00078 <input type="hidden" name="sa" value="list">
00079 <input type="hidden" name="p_action" value="suivi_courrier">
00080 </form>
00081 </span>
00082
00083 <?
00084 ?>
00085 <span>
00086 <form method="get" action="commercial.php">
00087 <input type="submit" name="submit_query" value="Ajout Action">
00088 <input type="hidden" name="p_action" value="suivi_courrier">
00089 <input type="hidden" name="sa" value="add_action">
00090 <input type="hidden" name="tiers" value=<? echo '"'.$qcode.'"';?>>
00091 <?
00092 echo $h_url;
00093 echo $retour; ?>
00094 </form>
00095
00096
00097 </span>
00098 <?
00099
00100 $act=new action($cn);
00101
00102 $query=(isset ($_REQUEST['query']))?"and ag_title ~* '".FormatString($_REQUEST['query'])."'":"";
00103 $str="";
00104 if ( isset($_REQUEST['qcode'] ))
00105 {
00106
00107 if ( strlen(trim($_REQUEST['qcode'] )) != 0 )
00108 {
00109 $fiche=new Fiche($cn);
00110 $fiche->GetByQCode($_REQUEST['qcode']);
00111 $str=" and f_id= ".$fiche->id;
00112 }
00113 }
00114
00115 $r=$act->myList('1,5,6,7',$query.$str);
00116 echo $r;
00117 }
00119
00120 if ( $sub_action == "add_action" )
00121 {
00122 echo $retour;
00123
00124 echo '<div class="u_redcontent">';
00125 echo JS_SEARCH_CARD;
00126
00127 echo '<form name="RTEDemo" action="commercial.php?p_action=suivi_courrier" method="post" onsubmit="return submitForm();">';
00128 echo $h_url;
00129 $date=new widget("text");
00130 $date->name="ag_date";
00131 $date->value=(isset($_POST['ag_date']))?$_POST['ag_date']:"";
00132 echo "<p>Date : ";
00133 echo $date->IOValue()."</p>";
00134
00135 $W1=new widget("js_search");
00136 $W1->label="Tiers";
00137 $W1->name="tiers";
00138 $W1->value=isset($_REQUEST['tiers'])?$_REQUEST['tiers']:"";
00139 $W1->extra="8,9,14";
00140 $W1->extra2=0;
00141 echo "<div class=\"no\">".$W1->IOValue();
00142 $client_label=new widget("span");
00143 $tiers_label="";
00144
00145 if ( $W1->value != "" )
00146 {
00147 $tiers=new fiche($cn);
00148 $tiers->GetByQCode($W1->value);
00149 $tiers_label=$tiers->strAttribut(1);
00150
00151 }
00152 echo $client_label->IOValue("tiers_label",$tiers_label)."</div>";
00153
00154 $doc_type=new widget("select");
00155 $doc_type->name="dt_id";
00156 $doc_type->value=make_array($cn,"select dt_id,dt_value from document_type where dt_id in (1,5,6,7)");
00157 echo 'Type d\' action';
00158 $doc_type->selected=(isset($_POST['dt_id']))?$_POST['dt_id']:"";
00159 echo $doc_type->IOValue();
00160
00161
00162 $doc_state=new widget("select");
00163 $doc_state->name="d_state";
00164 $doc_state->value=make_array($cn,"select s_id,s_value from document_state");
00165 $doc_state->selected=(isset($_POST['d_state']))?$_POST['d_state']:"";
00166 echo "Etat : ".$doc_state->IOValue();
00167 echo '<input type="hidden" name="p_action" value="suivi_courrier">';
00168 echo '<input type="hidden" name="sa" value="save_action_st1">';
00169 $title=new widget("text");
00170 $title->name="ag_title";
00171 $title->value=(isset($_POST['ag_title']))?$_POST['ag_title']:"";
00172 echo "<p>Titre : ";
00173 echo $title->IOValue()."</p>";
00174
00175 ?>
00176
00177 <?
00179
00180
00181 ?>
00182
00183
00184
00185 <script language="JavaScript" type="text/javascript">
00186 <!--
00187 function submitForm() {
00188
00189
00190
00191 updateRTE('ag_desc');
00192
00193
00194 return true;
00195 }
00196
00197
00198 initRTE("images/", "", "");
00199
00200 </script>
00201 <noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>
00202 Note Interne :
00203 <script language="JavaScript" type="text/javascript">
00204 <!--
00205
00206 <? $a=(isset($_POST['ag_desc']))?FormatString(urldecode($_POST['ag_desc'])):""; ?>
00207 writeRichText('ag_desc', <? printf ("'%s'",$a); ?>, 520, 200, true, false);
00208 <? echo_debug('action.inc',__LINE__, " A = ".$a); ?>
00209
00210 </script>
00211
00212 <input type="submit" name="save_action_st1" value="Sauver"></p>
00213 </form>
00214 </div>
00215 <?
00216 }
00218
00219
00221 if ( $sub_action == "save_action_st1" )
00222 {
00223 $act=new action($cn);
00224 $act->ag_desc=$_POST['ag_desc'];
00225 $act->ag_date=$_POST['ag_date'];
00226 $act->d_state=$_POST['d_state'];
00227 $act->dt_id=$_POST['dt_id'];
00228 $act->qcode=$_POST['tiers'];
00229 $act->ag_title=$_POST['ag_title'];
00230 echo $act->Confirm();
00231 }
00233
00234
00236 if ( $sub_action == "save_action_st2" )
00237 {
00238 $act=new action($cn);
00239 $act->ag_desc=$_POST['ag_desc'];
00240 $act->ag_date=$_POST['ag_date'];
00241 $act->d_state=$_POST['d_state'];
00242 $act->dt_id=$_POST['dt_id'];
00243 $act->qcode=$_POST['tiers'];
00244 $act->ag_title=$_POST['ag_title'];
00245 $act->md_id=$_POST['gen_doc'];
00246
00247 $act->gen=isset($_POST['p_gen'])?'on':'off';
00248
00249 echo $act->SaveStage2();
00250 }
00251
00253
00254
00256 if ( $sub_action == "save_action_st3" )
00257 {
00258 echo_debug("action.inc.php",__LINE__,'Stage 3');
00259 $act=new action($cn);
00260 $act->ag_id=$_POST['ag_id'];
00261 $d_id=(isset($_POST['d_id']))?$_POST['d_id']:0;
00262 echo $act->SaveStage3($d_id);
00263 }
00264