Main Page | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

action.inc.php

Go to the documentation of this file.
00001 <?
00002 /*
00003  *   This file is part of PhpCompta.
00004  *
00005  *   PhpCompta is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   PhpCompta is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with PhpCompta; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 /* $Revision$ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00025 
00026 // Action
00028 require_once("class_widget.php");
00029 require_once("class_action.php");
00030 
00031 // We need a sub action (3rd level)
00032   // show a list of already taken action 
00033   // propose to add one 
00034   // permit also a search
00035   // show detail
00036 $sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
00037 var_dump($_REQUEST);echo '<hr>';
00038 if ( $sub_action == "" ) $sub_action="list";
00039 
00040 // if correction is asked go to directly to add_action
00041 if (isset($_POST['corr'] )) 
00042      $sub_action="add_action";
00043 
00044 // if this page is called from another menu (customer, supplier,...)
00045 // a button back is added
00046 // TODO add function for generating url, hidden tags...
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 // Show a list of the action
00059 if ( $sub_action == "list" )
00060     {
00061 
00062 
00063       // show the search menu
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    <? // if called from another menu, url is set
00092    echo $h_url;
00093    echo $retour; ?>
00094 </form>
00095 
00096 
00097 </span>
00098 <?
00099     // show the  action in 
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        // verify that qcode is not empty
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 // Add an action
00120 if ( $sub_action == "add_action" ) 
00121 {
00122   echo $retour;
00123 
00124   echo '<div class="u_redcontent">';
00125   echo JS_SEARCH_CARD;
00126   // Add hidden tag
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   // Tiers
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"; // filter on frd_id
00140   $W1->extra2=0;      // jrn = 0
00141   echo "<div class=\"no\">".$W1->IOValue();
00142   $client_label=new widget("span");
00143   $tiers_label="";
00144   // Retrieve name
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   // state 
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 // add here for who the action is taken (contact, client or supplier)
00180 
00181 ?>
00182 
00183 
00184 
00185 <script language="JavaScript" type="text/javascript">
00186 <!--
00187 function submitForm() {
00188         //make sure hidden and iframe values are in sync before submitting form
00189         //to sync only 1 rte, use updateRTE(rte)
00190         //to sync all rtes, use updateRTEs
00191         updateRTE('ag_desc');
00192         //updateRTE();
00193         //change the following line to true to submit form
00194         return true;
00195 }
00196 
00197 //Usage: initRTE(imagesPath, includesPath, cssFile)
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 //Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
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 // Save Action
00219 // Stage 1 : show the result and confirm
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 // Save Action
00234 // Stage 2 : Save the action and propose to save a file
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 // Save Document
00254 // Stage 3 : Save the document
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 

Generated on Fri Jun 23 00:12:45 2006 for phpcompta by  doxygen 1.4.4