2002-04-30 12:44:42 +02:00
< ? PHP
/* Copyright ( C ) 2001 - 2002 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*
2002-12-12 16:22:40 +01:00
* $Id $
* $Source $
*
2002-04-30 12:44:42 +02:00
*/
require ( " ./pre.inc.php3 " );
2002-12-12 16:22:40 +01:00
require ( " ../contact.class.php3 " );
2002-04-30 12:44:42 +02:00
$db = new Db ();
2002-12-12 16:22:40 +01:00
if ( $sortorder == " " )
{
2002-04-30 12:44:42 +02:00
$sortfield = " lower(s.nom) " ;
$sortorder = " ASC " ;
}
2002-12-12 16:22:40 +01:00
if ( $action == 'add' )
{
2002-04-30 12:44:42 +02:00
$email = trim ( $email );
2002-12-12 16:22:40 +01:00
if ( strlen ( trim ( $name )) + strlen ( trim ( $firstname )) > 0 )
{
$sql = " INSERT INTO socpeople (datec, fk_soc,name, firstname, poste, phone,fax,email) " ;
$sql .= " VALUES (now(), $socid ,' $name ',' $firstname ',' $poste ',' $phone ',' $fax ',' $email ') " ;
$result = $db -> query ( $sql );
if ( $result )
{
Header ( " Location: fiche.php3?socid= $socid " );
}
2002-04-30 12:44:42 +02:00
}
}
2002-12-12 16:22:40 +01:00
if ( $action == 'update' )
{
if ( strlen ( trim ( $name )) + strlen ( trim ( $firstname )) > 0 )
{
$contact = new Contact ( $db );
$contact -> name = $name ;
$contact -> firstname = $firstname ;
$contact -> poste = $poste ;
$contact -> phone = $phone ;
$contact -> fax = $fax ;
$contact -> note = $note ;
$contact -> email = $email ;
$result = $contact -> update ( $contactid );
if ( $result )
{
Header ( " Location: fiche.php3?socid= $socid " );
}
2002-04-30 12:44:42 +02:00
}
}
llxHeader ();
if ( $page == - 1 ) { $page = 0 ; }
$limit = 26 ;
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2002-12-12 17:11:54 +01:00
if ( $socid > 0 )
{
2002-04-30 12:44:42 +02:00
$sql = " SELECT s.idp, s.nom, " . $db -> pdate ( " s.datec " ) . " as dc, s.tel, s.fax, st.libelle as stcomm, s.fk_stcomm, s.url,s.cp,s.ville, s.note FROM societe as s, c_stcomm as st " ;
$sql .= " WHERE s.fk_stcomm=st.id " ;
2002-12-12 17:11:54 +01:00
if ( $to == 'next' )
{
$sql .= " AND s.idp > $socid ORDER BY idp ASC LIMIT 1 " ;
}
else
{
$sql .= " AND s.idp = $socid " ;
}
2002-04-30 12:44:42 +02:00
$result = $db -> query ( $sql );
2002-12-12 17:11:54 +01:00
if ( $result )
{
$objsoc = $db -> fetch_object ( 0 );
/*
*
*
*/
print " <table width= \" 100% \" border= \" 0 \" cellspacing= \" 1 \" > \n " ;
print " <tr><td><a href= \" fiche.php3?socid= $objsoc->idp\ " > $objsoc -> nom </ a ></ td > " ;
print " <td align= \" center \" ><a href= \" socnote.php3?socid= $socid\ " > Notes </ a ></ big ></ td > " ;
print " <td align= \" center \" >[<a href= \" people.php3?socid= $socid &action=addcontact \" >Ajouter un contact</a>]</td> " ;
print '</td></tr></table>' ;
2002-04-30 12:44:42 +02:00
2002-12-12 17:11:54 +01:00
/*
*
*/
2002-04-30 12:44:42 +02:00
2002-12-12 17:11:54 +01:00
if ( $objsoc -> note )
{
print " <table border=0 width= \" 100% \" cellspacing=0 bgcolor=#e0e0e0> " ;
print " <tr><td> " . nl2br ( $objsoc -> note ) . " </td></tr> " ;
print " </table> " ;
}
2002-04-30 12:44:42 +02:00
2002-12-12 17:11:54 +01:00
}
else
{
print $db -> error ();
}
2002-04-30 12:44:42 +02:00
print " <P><table width= \" 100% \" cellspacing=0 border=1 cellpadding=2> " ;
print " <tr><td><b>Pr<50> nom Nom</b></td> " ;
print " <td><b>Poste</b></td><td><b>Tel</b></td> " ;
print " <td><b>Fax</b></td><td><b>Email</b></td> " ;
2002-12-12 17:11:54 +01:00
2002-05-02 20:04:23 +02:00
$sql = " SELECT p.name, p.firstname, p.poste, p.phone, p.fax, p.email " ;
$sql .= " FROM socpeople as p WHERE p.fk_soc = $objsoc->idp " ;
2002-12-12 17:11:54 +01:00
if ( $contactid )
{
$sql .= " AND p.idp = $contactid " ;
}
2002-05-02 20:04:23 +02:00
$sql .= " ORDER by p.datec " ;
2002-04-30 12:44:42 +02:00
$result = $db -> query ( $sql );
$i = 0 ; $num = $db -> num_rows (); $tag = True ;
2002-12-12 17:11:54 +01:00
while ( $i < $num )
{
$obj = $db -> fetch_object ( $i );
if ( $tag )
{
print " <tr bgcolor= \" e0e0e0 \" > " ;
}
else
{
print " <tr> " ;
}
print " <td> $obj->firstname $obj->name </td> " ;
print " <td> $obj->poste </td> " ;
print " <td> $obj->phone </td> " ;
print " <td> $obj->fax </td> " ;
print " <td><a href= \" mailto: $obj->email\ " > $obj -> email </ a >& nbsp ; </ td > " ;
print " </tr> \n " ;
$i ++ ;
$tag = ! $tag ;
2002-04-30 12:44:42 +02:00
}
print " </table> " ;
2002-12-12 17:11:54 +01:00
if ( $action == 'addcontact' )
{
print " <form method= \" post \" action= \" people.php3?socid= $socid\ " > " ;
print " <input type= \" hidden \" name= \" action \" value= \" add \" > " ;
print " <table border=0> " ;
print " <tr><td>Nom</td><td><input name= \" name \" type= \" text \" size= \" 20 \" maxlength= \" 80 \" ></td> " ;
print " <td>Prenom</td><td><input name= \" firstname \" type= \" text \" size= \" 15 \" maxlength= \" 80 \" ></td></tr> " ;
print " <tr><td>Poste</td><td colspan= \" 3 \" ><input name= \" poste \" type= \" text \" size= \" 50 \" maxlength= \" 80 \" ></td></tr> " ;
print " <tr><td>Tel</td><td><input name= \" phone \" type= \" text \" size= \" 18 \" maxlength= \" 80 \" ></td> " ;
print " <td>Fax</td><td><input name= \" fax \" type= \" text \" size= \" 18 \" maxlength= \" 80 \" ></td></tr> " ;
print " <tr><td>Email</td><td colspan= \" 3 \" ><input name= \" email \" type= \" text \" size= \" 50 \" maxlength= \" 80 \" ></td></tr> " ;
print " </table> " ;
print " <input type= \" submit \" value= \" Ajouter \" > " ;
print " </form> " ;
}
2002-04-30 12:44:42 +02:00
/*
*
* Edition du contact
*
*/
2002-12-12 17:11:54 +01:00
if ( $action == 'editcontact' )
{
$sql = " SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note " ;
$sql .= " FROM socpeople as p WHERE p.idp = $contactid " ;
$result = $db -> query ( $sql );
$num = $db -> num_rows ();
if ( $num > 0 )
{
$obj = $db -> fetch_object ( 0 );
}
print " <form method= \" post \" action= \" people.php3?socid= $socid\ " > " ;
print '<input type="hidden" name="action" value="update">' ;
print " <input type= \" hidden \" name= \" contactid \" value= \" $contactid\ " > " ;
print " <table border=0> " ;
print " <tr><td>Num<75> ro</td><td> $obj->idp </td> " ;
print " <tr><td>Nom</td><td><input name= \" name \" type= \" text \" size= \" 20 \" maxlength= \" 80 \" value= \" $obj->name\ " ></ td > " ;
print " <td>Prenom</td><td><input name= \" firstname \" type= \" text \" size= \" 15 \" maxlength= \" 80 \" value= \" $obj->firstname\ " ></ td ></ tr > " ;
print " <tr><td>Poste</td><td colspan= \" 3 \" ><input name= \" poste \" type= \" text \" size= \" 50 \" maxlength= \" 80 \" value= \" $obj->poste\ " ></ td ></ tr > " ;
print " <tr><td>Tel</td><td><input name= \" phone \" type= \" text \" size= \" 18 \" maxlength= \" 80 \" value= \" $obj->phone\ " ></ td > " ;
print " <td>Fax</td><td><input name= \" fax \" type= \" text \" size= \" 18 \" maxlength= \" 80 \" value= \" $obj->fax\ " ></ td ></ tr > " ;
print " <tr><td>Email</td><td colspan= \" 3 \" ><input name= \" email \" type= \" text \" size= \" 50 \" maxlength= \" 80 \" value= \" $obj->email\ " ></ td ></ tr > " ;
print '<tr><td valign="top">Note</td><td colspan="3"><textarea wrap="soft" cols="40" rows="10" name="note">' . $obj -> note . '</textarea></td></tr>' ;
print " </table> " ;
print " <input type= \" submit \" value= \" Modifier \" > " ;
print " </form> " ;
2002-04-30 12:44:42 +02:00
}
2002-05-02 20:04:23 +02:00
/*
*
*
*/
2002-05-16 17:38:04 +02:00
print '<P><table width="100%" cellspacing="0" border="0" cellpadding="2">' ;
2002-05-02 20:04:23 +02:00
2002-05-16 17:38:04 +02:00
print " <tr class= \" liste_titre \" ><td>Action</td> " ;
print " <td>Fax</td><td>Email</td> " ;
2002-05-02 20:04:23 +02:00
$sql = " SELECT a.id, " . $db -> pdate ( " a.datea " ) . " as da, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid " ;
$sql .= " FROM actioncomm as a, c_actioncomm as c, llx_user as u " ;
$sql .= " WHERE a.fk_soc = $objsoc->idp " ;
$sql .= " AND u.rowid = a.fk_user_author " ;
$sql .= " AND c.id=a.fk_action " ;
2002-12-12 17:11:54 +01:00
if ( $contactid )
{
$sql .= " AND fk_contact = $contactid " ;
}
2002-05-02 20:04:23 +02:00
$sql .= " ORDER BY a.datea DESC, a.id DESC " ;
2002-12-12 17:11:54 +01:00
if ( $db -> query ( $sql ) )
{
$i = 0 ; $num = $db -> num_rows (); $tag = True ;
while ( $i < $num )
{
$obj = $db -> fetch_object ( $i );
$var =! $var ;
print " <tr $bc[$var] > " ;
print " <td> " . strftime ( " %d %b %Y %H:%M " , $obj -> da ) . " </td> " ;
if ( $obj -> propalrowid )
{
print " <td><a href= \" propal.php3?propalid= $obj->propalrowid\ " > $obj -> libelle </ a ></ td > " ;
}
else
{
print " <td> $obj->libelle </td> " ;
}
print " <td> $obj->code </td> " ;
print " </tr> \n " ;
$i ++ ;
$tag = ! $tag ;
}
}
else
{
print '<tr><td>' . $db -> error () . '</td></tr>' ;
2002-05-02 20:04:23 +02:00
}
print " </table> " ;
2002-04-30 12:44:42 +02:00
2002-12-12 17:11:54 +01:00
}
else
{
2002-04-30 12:44:42 +02:00
print " Error " ;
}
$db -> free ();
$db -> close ();
2002-05-02 19:15:05 +02:00
llxFooter ( " <em>Dernière modification $Date $ révision $Revision $ </em> " );
2002-04-30 12:44:42 +02:00
?>