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

contact.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: 1.5 $ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00022 require_once('class_contact.php');
00023 require_once('class_widget.php');
00030 $sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
00031 
00032 // if this page is called from another menu (customer, supplier,...)
00033 // a button back is added
00034 // TODO add function for generating url, hidden tags...
00035 if ( isset ($_REQUEST['url'])) 
00036 {
00037      $retour=sprintf('<A class="mtitle" HREF="%s"><input type="button" value="Retour"></A>',urldecode($_REQUEST['url']));
00038      $h_url=sprintf('<input type="hidden" name="url" value="%s">',urldecode($_REQUEST['url']));
00039 }
00040 else 
00041 { 
00042      $retour="";
00043      $h_url="";
00044 }
00045 
00046 // Menu
00047 // Remove a card
00048 if ( isset ($_POST['delete']) ) 
00049 {
00050   echo 'delete';
00051   $f_id=$_REQUEST['f_id'];
00052 
00053   $fiche=new contact($cn,$f_id);
00054   $fiche->remove();
00055   $sub_action="list"; 
00056 }
00057 //-----------------------------------------------------
00058 // Add card
00059 if ( $sub_action=="insert" )
00060 {
00061   $contact=new Contact($cn);
00062   $contact->Save($_REQUEST['fd_id']);
00063   echo $retour;
00064   echo "<table>";
00065   echo $contact->Display(true);
00066   echo "</table>";
00067   echo $retour;
00068 
00069 }
00070 
00071 //-----------------------------------------------------
00072 // Save modification
00073 if ( isset ($_POST['mod'])) 
00074 {
00075   // modification is asked
00076   $f_id=$_REQUEST['f_id'];
00077 
00078   $contact=new contact($cn,$f_id);
00079   $contact->Save();
00080   $sub_action="list";
00081 }
00082 // by default open liste
00083 if ( $sub_action  == "" ) 
00084       $sub_action="list";
00085 //-----------------------------------------------------
00086 //Display a blank card 
00087 if ( $sub_action=="blank") 
00088 {
00089   $retour=sprintf('<A class="two" HREF="%s"><input type="button" value="Retour"></A>',
00090                   "commercial.php?p_action=contact");
00091   echo '<div class="u_redcontent">';
00092 
00093   echo $retour;
00094   $c=new contact($cn);
00095   echo '<form method="post" action="commercial.php"';
00096   echo '<input type="hidden" name="p_action" value="client">';
00097   echo '<input type="hidden" name="sa" value="insert">';
00098   echo '<input type="hidden" name="fd_id" value="'.$_GET['fd_id'].'">';
00099   echo '<input type="hidden" name="url" value="'.$_GET['url'].'">';
00100   echo $c->blank($_GET['fd_id']);
00101   echo '<input type="Submit" value="Sauve">';
00102   echo '</form>';
00103   echo $retour;
00104   echo '</div>';
00105 }
00106 //-----------------------------------------------------
00107 // list
00108 if ( $sub_action == "list" )
00109 {
00110 ?>
00111 <div class="u_content">
00112 <span>
00113 <form method="get" action="commercial.php">
00114 <?
00115    $a=(isset($_GET['query']))?$_GET['query']:"";
00116    printf ('<input type="text" name="query" value="%s">',
00117            $a);
00118 ?>
00119 <input type="submit" name="submit_query" value="recherche">
00120 <input type="hidden" name="p_action" value="contact">
00121 </form>
00122 </span>
00123 <span>
00124 <form method="get" action="commercial.php">
00125 <input type="hidden" name="url" <?      $url=urlencode($_SERVER['REQUEST_URI']);echo 'value="'.$url.'"'; ?>
00126 <input type="hidden" name="p_action" value="contact">
00127 
00128 <?
00129  $w=new widget("select");
00130  $w->name="fd_id";
00131  $w->value= make_array($cn,"select fd_id,fd_label from fiche_def where ".
00132              " frd_id=".FICHE_TYPE_CONTACT);
00133  // if array is empty show an warning and stops
00134  if ( sizeof ($w->value) == 0 ) {
00135    echo '<p style="color:red">Aucune fiche de catégories contact</p>';
00136    echo '<p>allez dans comptabilité -> fiche creation et choississez contact comme sorte</p>';
00137    exit();
00138  }
00139  echo $w->IOValue();
00140 
00141 ?>
00142 <input type="hidden" name="sa" value="blank">
00143 <input type="submit" name="submit_query" value="Ajout Contact">
00144 
00145 </form>
00146 </span>
00147 
00148 <form>
00149 <?
00150    $qcode=(isset($_GET['qcode']))?$_GET['qcode']:"";
00151  echo JS_SEARCH_CARD;
00152  $w=new widget('js_search_only');
00153  $w->name='qcode';
00154  $w->value=$qcode;
00155  $w->label='qcode';
00156  $w->extra='4,8,9,14';
00157  $sp= new widget("span");
00158  echo $sp->IOValue("qcode_label",$qcode)."</TD></TR>";
00159 
00160  echo $w->IOValue();
00161 
00162 ?>
00163 <input type="submit" name="submit_query" value="recherche">
00164 <input type="hidden" name="p_action" value="contact">
00165 
00166 </FORM>
00167 <?
00168    $contact=new Contact($cn);
00169  $search=(isset($_GET['query']))?$_GET['query']:"";
00170  // check if a company is asked if yes, add a condition
00171  if ( $qcode != "" )
00172    {
00173      $contact->company=$qcode;
00174    }
00175  echo $retour;
00176  echo '<div class="u_redcontent">';
00177  echo $contact->Summary($search);
00178  echo '</div>';
00179  echo $retour;
00180 
00181 
00182 }
00183 //-----------------------------------------------------
00184 // Show Detail
00185 if ( $sub_action == 'detail' )
00186 {
00187   $f_id=$_REQUEST['f_id'];
00188   echo '<div class="u_redcontent">';
00189   $contact=new contact($cn,$f_id);
00190   echo $retour;
00191   echo '<form action="'.$_SERVER['REQUEST_URI'].'" method="post">'; 
00192   echo $contact->Display(false);
00193   $w=new widget("hidden");
00194   $w->name="p_action";
00195   $w->value="contact";
00196   echo $w->IOValue();
00197   $w->name="f_id";
00198   $w->value=$f_id;
00199   echo $w->IOValue();
00200 
00201   echo $w->Submit('mod','Sauver les modifications');
00202   echo '<A HREF="commercial.php?p_action=contact"><INPUT TYPE="button" value="Retour"></A>';
00203   echo $w->Submit('delete','Effacer cette fiche');
00204   echo '</form>';
00205   echo $retour;
00206   echo '<div>';
00207 }
00208 html_page_stop();
00209 
00210