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

class_contact.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.2 $ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00022 require_once("class_fiche.php");
00023 require_once("constant.php");
00024 require_once("user_common.php");
00032 class contact extends fiche
00033 {
00034   var $company; 
00036   function contact($p_cn,$p_id=0)
00037     {
00038       $this->fiche_def_ref=FICHE_TYPE_CONTACT;
00039       fiche::fiche($p_cn,$p_id) ;
00040       $this->company="";
00041     }
00050   function Summary($p_search) 
00051     {
00052       $p_search=FormatString($p_search);
00053       $extra_sql="";
00054       if ( $this->company != "") 
00055         {
00056           $extra_sql="and f_id in (select f_id from jnt_fic_att_value join 
00057 attr_value using (jft_id) where av_text='".$this->company."' and ad_id=".ATTR_DEF_COMPANY.") ";
00058         }
00059       $url=urlencode($_SERVER['REQUEST_URI']);
00060       $script=$_SERVER['SCRIPT_NAME'];
00061       // Creation of the nav bar
00062       // Get the max numberRow
00063       $all_contact=$this->CountByDef($this->fiche_def_ref,$p_search,$extra_sql); 
00064       // Get offset and page variable
00065       $offset=( isset ($_REQUEST['offset'] )) ?$_REQUEST['offset']:0;
00066       $page=(isset($_REQUEST['page']))?$_REQUEST['page']:1;
00067       $bar=jrn_navigation_bar($offset,$all_contact,$_SESSION['g_pagesize'],$page);
00068       // set a filter ?
00069       $search="";
00070       if ( trim($p_search) != "" )
00071         {
00072           $search=" and f_id in
00073 (select f_id from jnt_fic_att_value 
00074                   join fiche using (f_id) 
00075                   join attr_value using (jft_id)
00076                 where
00077                 ad_id=1 and av_text ~* '$p_search') ";
00078         }
00079       // Get The result Array
00080       $step_contact=$this->GetAll($offset,$search.$extra_sql);
00081       if ( $all_contact == 0 ) return "";
00082       $r=$bar;
00083       $r.='<table border="0">
00084 <TR style="background-color:lightgrey;">
00085 <th>Nom</th>
00086 <th>Téléphone</th>
00087 <th>email</th>
00088 <th>Fax</th>
00089 <th colspan="2">Société</th>
00090 </TR>';
00091       $base=$_SERVER['SCRIPT_NAME'];
00092       // Compute the url
00093       $url="";
00094       $and="?";
00095       $get=$_GET;
00096       if ( isset ($get) ) {
00097         foreach ($get as $name=>$value ) {
00098           // we clean the parameter offset, step, page and size
00099           if (  ! in_array($name,array('f_id','detail'))) {
00100             $url.=$and.$name."=".$value;
00101             $and="&";
00102           }// if
00103         }//foreach
00104       }// if
00105 
00106       if ( sizeof ($step_contact ) == 0 )
00107         return $r;
00108       echo JS_SEARCH_CARD;
00109       foreach ($step_contact as $contact ) {
00110         $l_company=new fiche($this->cn);
00111         $l_company->GetByQCode($contact->strAttribut(ATTR_DEF_COMPANY),false);
00112         $l_company_name=$l_company->strAttribut(ATTR_DEF_NAME);
00113         if ( $l_company_name == '- ERROR -' ) $l_company_name="";
00114         // add popup for detail
00115         if ( $l_company_name !="")
00116           {
00117             $l_company_name=sprintf("<A HREF=\"javascript:showfiche('%s','%s')\">%s  - %s</A>",
00118                                     $_REQUEST['PHPSESSID'],
00119                                     $contact->strAttribut(ATTR_DEF_COMPANY),
00120                                     $contact->strAttribut(ATTR_DEF_COMPANY),
00121                                     $l_company_name
00122                                     );
00123           }
00124         $r.="<TR>";
00125         $r.='<TD><A HREF="'.$url."&sa=detail&f_id=".$contact->id."\">".$contact->strAttribut(ATTR_DEF_NAME)."</A></TD>";
00126         $r.="<TD>".$contact->strAttribut(ATTR_DEF_TEL)."</TD>";
00127         $r.="<TD>".$contact->strAttribut(ATTR_DEF_EMAIL)."</TD>".
00128             "<TD> ".$contact->strAttribut(ATTR_DEF_FAX)."</TD>".
00129             "<TD> ".$l_company_name. "</TD>";
00130 
00131         $r.="</TR>";
00132 
00133       }
00134       $r.="</TABLE>";
00135       $r.=$bar;
00136       return $r;
00137     }
00138 
00139 }