00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
00062
00063 $all_contact=$this->CountByDef($this->fiche_def_ref,$p_search,$extra_sql);
00064
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
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
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
00093 $url="";
00094 $and="?";
00095 $get=$_GET;
00096 if ( isset ($get) ) {
00097 foreach ($get as $name=>$value ) {
00098
00099 if ( ! in_array($name,array('f_id','detail'))) {
00100 $url.=$and.$name."=".$value;
00101 $and="&";
00102 }
00103 }
00104 }
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
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 }