noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
class_contact.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS 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  *   NOALYSS 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 NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00020 //!\brief class for the contact, contact are derived from fiche
00021 require_once("class_fiche.php");
00022 require_once("constant.php");
00023 require_once("user_common.php");
00024 /*! \file
00025  * \brief Contact are a card which are own by a another card (customer, supplier...)
00026  */
00027 /*!
00028  * \brief Class contact (customer, supplier...)
00029  */
00030 
00031 class contact extends Fiche
00032 {
00033     var $company; /*!< $company company of the contact (ad_id=ATTR_DEF_COMPANY)*/
00034     /*!\brief constructor */
00035     function contact($p_cn,$p_id=0)
00036     {
00037         $this->fiche_def_ref=FICHE_TYPE_CONTACT;
00038         parent::__construct($p_cn,$p_id) ;
00039         $this->company="";
00040     }
00041     /*!   Summary
00042      **************************************************
00043      * \brief  show the default screen
00044      *
00045      * \param  p_search (filter)
00046      *
00047      * \return string to display
00048      */
00049     function Summary($p_search="",$p_action="",$p_sql="",$p_nothing=false)
00050     {
00051         $p_search=sql_string($p_search);
00052         $extra_sql="";
00053         if ( $this->company != "")
00054         {
00055             $extra_sql="and f_id in (select f_id from fiche_detail
00056                        where ad_value=upper('".$this->company."') and ad_id=".ATTR_DEF_COMPANY.") ";
00057         }
00058         $url=urlencode($_SERVER['REQUEST_URI']);
00059         $script=$_SERVER['PHP_SELF'];
00060         // Creation of the nav bar
00061         // Get the max numberRow
00062         $all_contact=$this->count_by_modele($this->fiche_def_ref,$p_search,$extra_sql);
00063         // Get offset and page variable
00064         $offset=( isset ($_REQUEST['offset'] )) ?$_REQUEST['offset']:0;
00065         $page=(isset($_REQUEST['page']))?$_REQUEST['page']:1;
00066         $bar=navigation_bar($offset,$all_contact,$_SESSION['g_pagesize'],$page);
00067         // set a filter ?
00068         $search="";
00069         if ( trim($p_search) != "" )
00070         {
00071             $search=" and f_id in
00072                     (select f_id from fiche_Detail
00073                     where
00074                     ad_id=1 and ad_value ~* '$p_search') ";
00075         }
00076         // Get The result Array
00077         $step_contact=$this->get_by_category($offset,$search.$extra_sql.$p_sql);
00078 
00079                 if ( $all_contact == 0 ) return "";
00080         $r=$bar;
00081         $r.='<table id="contact_tb" class="sortable">
00082             <TR>
00083             <th>Quick Code</th>
00084             <th>Nom</th>
00085             <th>Prénom</th>
00086                         <th>Société</th>
00087             <th>Téléphone</th>
00088             <th>email</th>
00089             <th>Fax</th>
00090             </TR>';
00091         $base=$_SERVER['PHP_SELF'];
00092         // Compute the url
00093         $url="";
00094         $and="?";
00095         $get=$_GET;
00096         if ( isset ($get) )
00097         {
00098             foreach ($get as $name=>$value )
00099             {
00100                 // we clean the parameter offset, step, page and size
00101                 if (  ! in_array($name,array('f_id','detail')))
00102                 {
00103                     $url.=$and.$name."=".$value;
00104                     $and="&";
00105                 }// if
00106             }//foreach
00107         }// if
00108         $back_url=urlencode($_SERVER['REQUEST_URI']);
00109         if ( sizeof ($step_contact ) == 0 )
00110             return $r;
00111         $idx=0;
00112         foreach ($step_contact as $contact )
00113         {
00114             $l_company=new Fiche($this->cn);
00115             $l_company->get_by_qcode($contact->strAttribut(ATTR_DEF_COMPANY),false);
00116             $l_company_name=$l_company->strAttribut(ATTR_DEF_NAME);
00117             if ( $l_company_name == NOTFOUND ) $l_company_name="";
00118             // add popup for detail
00119             if ( $l_company_name !="")
00120             {
00121                                 $l_company_name=HtmlInput::card_detail($contact->strAttribut(ATTR_DEF_COMPANY),$l_company_name,'style="text-decoration:underline;"');
00122             }
00123             $tr=($idx%2==0)?' <tr class="odd">':'<tr class="even">';
00124             $idx++;
00125             $r.=$tr;
00126             $qcode=$contact->strAttribut(ATTR_DEF_QUICKCODE);
00127             $r.='<TD>'.HtmlInput::card_detail($qcode)."</TD>";
00128             $r.="<TD>".$contact->strAttribut(ATTR_DEF_NAME)."</TD>";
00129             $r.="<TD>".$contact->strAttribut(ATTR_DEF_FIRST_NAME)."</TD>";
00130             $r.="<TD>".$l_company_name."</TD>";
00131             $r.="<TD>".$contact->strAttribut(ATTR_DEF_TEL)."</TD>";
00132             $r.="<TD>".$contact->strAttribut(ATTR_DEF_EMAIL)."</TD>".
00133                 "<TD> ".$contact->strAttribut(ATTR_DEF_FAX)."</TD>";
00134 
00135             $r.="</TR>";
00136 
00137         }
00138         $r.="</TABLE>";
00139         $r.=$bar;
00140         return $r;
00141     }
00142 
00143 }
 All Data Structures Namespaces Files Functions Variables Enumerations