2004-10-19 22:35:36 +02:00
< ? php
2004-07-13 15:02:40 +02:00
/* Copyright ( C ) 2001 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2005-01-09 21:53:26 +01:00
* Copyright ( C ) 2004 - 2005 Laurent Destailleur < eldy @ users . sourceforge . net >
2002-05-10 14:28:10 +02:00
*
* 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 .
*
2003-03-23 19:41:16 +01:00
* $Id $
* $Source $
*
2002-05-10 14:28:10 +02:00
*/
2004-09-04 17:57:06 +02:00
2005-01-09 21:53:26 +01:00
/** \file htdocs / compta / fiche . php
2004-09-04 17:57:06 +02:00
\ingroup compta
\brief Page de fiche compta
\version $Revision $
*/
2003-09-11 22:18:51 +02:00
require ( " ./pre.inc.php " );
require ( " ../contact.class.php " );
require ( " ../actioncomm.class.php " );
2004-04-22 22:11:25 +02:00
require ( " ../facture.class.php " );
2002-05-10 14:28:10 +02:00
2004-11-12 01:50:14 +01:00
$langs -> load ( " companies " );
2005-01-16 19:12:46 +01:00
if ( $conf -> facture -> enabled ) $langs -> load ( " bills " );
if ( $conf -> projet -> enabled ) $langs -> load ( " projects " );
2004-11-12 01:50:14 +01:00
2003-03-23 19:41:16 +01:00
/*
* S<EFBFBD> curit<EFBFBD> acc<EFBFBD> s client
*/
2004-07-29 15:32:29 +02:00
$socid = $_GET [ " socid " ];
2003-03-23 19:41:16 +01:00
if ( $user -> societe_id > 0 )
{
2004-07-29 15:32:29 +02:00
$action = '' ;
$socid = $user -> societe_id ;
2003-03-23 19:41:16 +01:00
}
2003-08-12 15:28:56 +02:00
$user -> getrights ( 'facture' );
2005-01-16 19:12:46 +01:00
2002-05-10 14:28:10 +02:00
llxHeader ();
2004-07-13 15:02:40 +02:00
if ( $action == 'add_action' )
2003-03-23 19:41:16 +01:00
{
2004-07-13 15:02:40 +02:00
/*
* Vient de actioncomm . php
*
*/
$actioncomm = new ActionComm ( $db );
$actioncomm -> date = $date ;
$actioncomm -> type = $actionid ;
$actioncomm -> contact = $contactid ;
$actioncomm -> societe = $socid ;
$actioncomm -> note = $note ;
$actioncomm -> add ( $user );
$societe = new Societe ( $db );
$societe -> fetch ( $socid );
2002-05-10 14:28:10 +02:00
}
2004-07-13 15:02:40 +02:00
2003-03-23 19:41:16 +01:00
if ( $action == 'recontact' )
{
2004-07-13 15:02:40 +02:00
$dr = mktime ( 0 , 0 , 0 , $remonth , $reday , $reyear );
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " soc_recontact (fk_soc, datere, author) VALUES ( $socid , $dr ,' " . $user -> login . " ') " ;
2004-05-29 17:36:04 +02:00
$result = $db -> query ( $sql );
2002-05-10 14:28:10 +02:00
}
2004-07-13 15:02:40 +02:00
/* TODO RODO
2003-03-23 19:41:16 +01:00
if ( $action == 'stcomm' )
{
2004-07-13 15:02:40 +02:00
if ( $stcommid <> 'null' && $stcommid <> $oldstcomm )
2003-03-23 19:41:16 +01:00
{
2004-07-13 15:02:40 +02:00
$sql = " INSERT INTO socstatutlog (datel, fk_soc, fk_statut, author) " ;
$sql .= " VALUES (' $dateaction ', $socid , $stcommid ,' " . $user -> login . " ') " ;
$result = @ $db -> query ( $sql );
if ( $result )
2004-05-29 17:36:04 +02:00
{
2004-07-13 15:02:40 +02:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " societe SET fk_stcomm= $stcommid WHERE idp= $socid " ;
$result = $db -> query ( $sql );
2004-05-29 17:36:04 +02:00
}
2004-07-13 15:02:40 +02:00
else
2004-05-29 17:36:04 +02:00
{
2004-07-13 15:02:40 +02:00
$errmesg = " ERREUR DE DATE ! " ;
2004-05-29 17:36:04 +02:00
}
2002-05-10 14:28:10 +02:00
}
2004-07-13 15:02:40 +02:00
if ( $actioncommid )
2003-03-23 19:41:16 +01:00
{
2004-07-13 15:02:40 +02:00
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " actioncomm (datea, fk_action, fk_soc, fk_user_author) VALUES (' $dateaction ', $actioncommid , $socid ,' " . $user -> id . " ') " ;
$result = @ $db -> query ( $sql );
if ( ! $result )
2004-05-29 17:36:04 +02:00
{
2004-07-13 15:02:40 +02:00
$errmesg = " ERREUR DE DATE ! " ;
2004-05-29 17:36:04 +02:00
}
2002-05-10 14:28:10 +02:00
}
}
2004-07-13 15:02:40 +02:00
*/
2002-05-10 14:28:10 +02:00
/*
* Recherche
*
*/
2003-03-23 19:41:16 +01:00
if ( $mode == 'search' )
{
2004-05-29 17:36:04 +02:00
if ( $mode - search == 'soc' )
2003-03-23 19:41:16 +01:00
{
2004-05-29 17:36:04 +02:00
$sql = " SELECT s.idp FROM " . MAIN_DB_PREFIX . " societe as s " ;
$sql .= " WHERE lower(s.nom) like '% " . strtolower ( $socname ) . " %' " ;
2002-05-10 14:28:10 +02:00
}
2004-05-29 17:36:04 +02:00
if ( $db -> query ( $sql ) )
2003-03-23 19:41:16 +01:00
{
2004-05-29 17:36:04 +02:00
if ( $db -> num_rows () == 1 )
{
2004-10-23 18:55:07 +02:00
$obj = $db -> fetch_object ();
2004-05-29 17:36:04 +02:00
$socid = $obj -> idp ;
}
$db -> free ();
2003-03-23 19:41:16 +01:00
}
2004-05-29 17:36:04 +02:00
if ( $user -> societe_id > 0 )
2003-03-23 19:41:16 +01:00
{
2004-05-29 17:36:04 +02:00
$socid = $user -> societe_id ;
2003-03-23 19:41:16 +01:00
}
2002-05-10 14:28:10 +02:00
}
/*
*
* Mode fiche
*
2004-05-29 17:36:04 +02:00
*/
2004-07-29 15:32:29 +02:00
if ( $socid > 0 )
2003-05-02 13:57:36 +02:00
{
2004-07-13 15:02:40 +02:00
$societe = new Societe ( $db );
2004-07-29 15:32:29 +02:00
$societe -> fetch ( $socid , $to ); // si $to='next' ajouter " AND s.idp > $socid ORDER BY idp ASC LIMIT 1";
2004-05-29 17:36:04 +02:00
/*
* Affichage onglets
*/
$h = 0 ;
2002-05-10 14:28:10 +02:00
2004-07-13 15:02:40 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/soc.php?socid=' . $societe -> id ;
2004-11-02 22:42:46 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " Company " );
2004-05-29 17:36:04 +02:00
$h ++ ;
2004-07-13 15:02:40 +02:00
if ( $societe -> client == 1 )
2004-05-29 17:36:04 +02:00
{
2004-07-13 15:02:40 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/comm/fiche.php?socid=' . $societe -> id ;
2004-11-02 22:42:46 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " Customer " );
2004-05-29 17:36:04 +02:00
$h ++ ;
}
2004-07-13 15:02:40 +02:00
if ( $societe -> client == 2 )
2003-03-23 19:41:16 +01:00
{
2004-07-13 15:02:40 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/comm/prospect/fiche.php?id=' . $societe -> id ;
2004-11-12 01:50:14 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " Prospect " );
2004-05-29 17:36:04 +02:00
$h ++ ;
2003-03-23 19:41:16 +01:00
}
2004-07-13 15:02:40 +02:00
if ( $societe -> fournisseur )
2004-05-29 17:36:04 +02:00
{
2004-07-13 15:02:40 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/fourn/fiche.php?socid=' . $societe -> id ;
2004-11-12 01:50:14 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " Supplier " );
2004-05-29 17:36:04 +02:00
$h ++ ;
2002-05-10 14:28:10 +02:00
}
2004-05-29 17:36:04 +02:00
if ( $conf -> compta -> enabled ) {
2004-11-12 01:50:14 +01:00
$langs -> load ( " compta " );
2004-05-29 17:36:04 +02:00
$hselected = $h ;
2004-07-13 15:02:40 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/compta/fiche.php?socid=' . $societe -> id ;
2004-11-12 01:50:14 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " Accountancy " );
2004-05-29 17:36:04 +02:00
$h ++ ;
}
2002-05-10 14:28:10 +02:00
2004-07-13 15:02:40 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/socnote.php?socid=' . $societe -> id ;
2004-11-02 22:42:46 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " Note " );
2004-05-29 17:36:04 +02:00
$h ++ ;
2003-03-23 19:41:16 +01:00
if ( $user -> societe_id == 0 )
2004-05-29 17:36:04 +02:00
{
2004-07-13 15:02:40 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/docsoc.php?socid=' . $societe -> id ;
2004-11-02 22:42:46 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " Documents " );
2004-05-29 17:36:04 +02:00
$h ++ ;
}
2004-07-13 15:02:40 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/societe/notify/fiche.php?socid=' . $societe -> id ;
2004-11-02 22:42:46 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " Notifications " );
2004-07-12 16:05:19 +02:00
$h ++ ;
2004-05-29 17:36:04 +02:00
2004-07-12 16:05:19 +02:00
if ( $user -> societe_id == 0 )
2004-11-02 22:42:46 +01:00
{
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /index.php?socidp= $societe->id &action=add_bookmark " ;
$head [ $h ][ 1 ] = '<img border="0" src="' . DOL_URL_ROOT . '/theme/' . $conf -> theme . '/img/bookmark.png" alt="Bookmark" title="Bookmark">' ;
$head [ $h ][ 2 ] = 'image' ;
}
2004-07-13 15:02:40 +02:00
dolibarr_fiche_head ( $head , $hselected , $societe -> nom );
2004-05-29 17:36:04 +02:00
2002-05-10 14:28:10 +02:00
/*
*
*/
2004-11-02 22:42:46 +01:00
print " <table width= \" 100% \" > \n " ;
2004-07-12 16:05:19 +02:00
print '<tr><td valign="top" width="50%">' ;
2002-05-10 14:28:10 +02:00
2004-11-02 22:42:46 +01:00
print '<table class="border" width="100%">' ;
print '<tr><td width="20%">' . $langs -> trans ( " Name " ) . '</td><td width="80%" colspan="3">' . $societe -> nom . '</td></tr>' ;
2004-12-18 20:05:17 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " Address " ) . '</td><td colspan="3">' . nl2br ( $societe -> adresse ) . " </td></tr> " ;
print '<tr><td>' . $langs -> trans ( 'Zip' ) . ' / ' . $langs -> trans ( 'Town' ) . '</td><td colspan="3">' . $societe -> cp . " " . $societe -> ville . '</td></tr>' ;
print '<tr><td>' . $langs -> trans ( 'Country' ) . '</td><td colspan="3">' . $societe -> pays . '</td></tr>' ;
2004-11-02 22:42:46 +01:00
print '<tr><td>' . $langs -> trans ( " Phone " ) . '</td><td>' . $societe -> tel . ' </td><td>Fax</td><td>' . $societe -> fax . ' </td></tr>' ;
print '<tr><td>' . $langs -> trans ( " Web " ) . " </td><td colspan= \" 3 \" ><a href= \" http:// $societe->url\ " > $societe -> url </ a >& nbsp ; </ td ></ tr > " ;
2002-05-10 14:28:10 +02:00
2004-12-18 20:05:17 +01:00
print '<tr><td>' . $langs -> trans ( " ProfIdSiren " ) . '</td><td><a href="http://www.societe.com/cgi-bin/recherche?rncs=' . $societe -> siren . '">' . $societe -> siren . '</a> </td>' ;
print '<td>' . $langs -> trans ( " Prefix " ) . '</td><td>' ;
2004-07-13 15:02:40 +02:00
if ( $societe -> prefix_comm )
{
2004-11-02 22:42:46 +01:00
print $societe -> prefix_comm ;
2004-07-13 15:02:40 +02:00
}
2002-05-10 14:28:10 +02:00
print " </td></tr> " ;
2004-12-07 15:09:26 +01:00
print '<tr><td>Code compta</td><td>' . $societe -> code_compta . '</td>' ;
2004-12-25 20:05:11 +01:00
print '<td>' . $langs -> trans ( " CustomerCode " ) . '</td><td>' ;
2004-12-07 15:09:26 +01:00
print $societe -> code_client ;
print " </td></tr> " ;
2002-05-10 14:28:10 +02:00
print " </table> " ;
2004-05-29 17:36:04 +02:00
print " <br> " ;
2002-05-10 14:28:10 +02:00
/*
*
*/
print " </td> \n " ;
print '<td valign="top" width="50%">' ;
2005-01-16 19:02:39 +01:00
// Nbre max d'<27> l<EFBFBD> ments des petites listes
$MAXLIST = 5 ;
2002-05-10 14:28:10 +02:00
/*
2005-01-16 19:02:39 +01:00
* Dernieres factures
2002-05-10 14:28:10 +02:00
*/
2005-01-16 19:02:39 +01:00
if ( $conf -> facture -> enabled && $user -> rights -> facture -> lire )
2004-05-29 17:36:04 +02:00
{
2005-01-16 19:02:39 +01:00
print '<table class="border" width="100%">' ;
2004-05-29 17:36:04 +02:00
$sql = " SELECT s.nom, s.idp, f.facnumber, f.amount, " . $db -> pdate ( " f.datef " ) . " as df, f.paye as paye, f.fk_statut as statut, f.rowid as facid " ;
2005-01-16 19:02:39 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " facture as f " ;
$sql .= " WHERE f.fk_soc = s.idp AND s.idp = " . $societe -> id ;
$sql .= " ORDER BY f.datef DESC " ;
2004-05-29 17:36:04 +02:00
if ( $db -> query ( $sql ) )
{
2005-01-16 19:02:39 +01:00
$var = true ;
2004-05-29 17:36:04 +02:00
$num = $db -> num_rows (); $i = 0 ;
if ( $num > 0 )
{
print " <tr $bc[$var] > " ;
2005-01-16 19:02:39 +01:00
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>' . $langs -> trans ( " LastBills " ,( $num <= $MAXLIST ? " " : $MAXLIST )) . '</td><td align="right"><a href="' . DOL_URL_ROOT . '/compta/facture.php?socidp=' . $societe -> id . '">' . $langs -> trans ( " AllBills " ) . ' (' . $num . ')</td></tr></table></td>' ;
print '</tr>' ;
2004-05-29 17:36:04 +02:00
}
2005-01-16 19:02:39 +01:00
while ( $i < $num && $i < $MAXLIST )
2004-05-29 17:36:04 +02:00
{
2004-10-23 18:55:07 +02:00
$objp = $db -> fetch_object ();
2004-05-29 17:36:04 +02:00
$var =! $var ;
2004-06-09 00:46:48 +02:00
print " <tr $bc[$var] > " ;
print " <td><a href= \" ../compta/facture.php?facid= $objp->facid\ " > $objp -> facnumber </ a ></ td > \n " ;
2004-05-29 17:36:04 +02:00
if ( $objp -> df > 0 )
{
2004-06-09 00:46:48 +02:00
print " <td align= \" right \" > " . dolibarr_print_date ( $objp -> df ) . " </td> \n " ;
2004-05-29 17:36:04 +02:00
}
else
{
2004-06-09 00:46:48 +02:00
print " <td align= \" right \" ><b>!!!</b></td> \n " ;
2004-05-29 17:36:04 +02:00
}
2004-06-09 00:46:48 +02:00
print " <td align= \" right \" > " . number_format ( $objp -> amount , 2 , ',' , ' ' ) . " </td> \n " ;
2005-01-16 19:02:39 +01:00
2004-05-29 17:36:04 +02:00
$fac = new Facture ( $db );
2004-06-09 00:46:48 +02:00
print " <td align= \" center \" > " . ( $fac -> LibStatut ( $objp -> paye , $objp -> statut )) . " </td> \n " ;
print " </tr> \n " ;
2004-05-29 17:36:04 +02:00
$i ++ ;
}
$db -> free ();
}
else
{
2005-01-16 19:02:39 +01:00
dolibarr_print_error ( $db );
2004-05-29 17:36:04 +02:00
}
print " </table> " ;
}
2005-01-16 19:02:39 +01:00
2002-05-10 14:28:10 +02:00
/*
2005-01-16 19:02:39 +01:00
* Derniers projets associ<EFBFBD> s
2002-05-10 14:28:10 +02:00
*/
2005-01-16 19:02:39 +01:00
if ( $conf -> projet -> enabled )
{
2004-11-26 01:54:45 +01:00
print '<table class="border" width="100%">' ;
2005-01-16 19:02:39 +01:00
$sql = " SELECT p.rowid,p.title,p.ref, " . $db -> pdate ( " p.dateo " ) . " as do " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " projet as p " ;
$sql .= " WHERE p.fk_soc = $societe->id " ;
$sql .= " ORDER by p.dateo " ;
if ( $db -> query ( $sql ) )
{
$var = true ;
$i = 0 ;
$num = $db -> num_rows ();
if ( $num > 0 )
{
print " <tr $bc[$var] > " ;
print '<td colspan="2"><table width="100%" class="noborder"><tr><td>' . $langs -> trans ( " LastProjects " ,( $num <= $MAXLIST ? " " : $MAXLIST )) . '</td><td align="right"><a href="' . DOL_URL_ROOT . '/projet/index.php?socidp=' . $societe -> id . '">' . $langs -> trans ( " AllProjects " ) . ' (' . $num . ')</td></tr></table></td>' ;
print '</tr>' ;
}
while ( $i < $num && $i < $MAXLIST )
{
$obj = $db -> fetch_object ();
$var = ! $var ;
print " <tr $bc[$var] > " ;
print '<td><a href="../projet/fiche.php?id=' . $obj -> rowid . '">' . $obj -> title . '</a></td>' ;
print " <td align= \" right \" > " . strftime ( " %d %b %Y " , $obj -> do ) . " </td></tr> " ;
$i ++ ;
}
$db -> free ();
}
else
{
dolibarr_print_error ( $db );
}
2004-05-29 17:36:04 +02:00
print " </table> " ;
2005-01-16 19:02:39 +01:00
}
2002-05-10 14:28:10 +02:00
print " </td></tr> " ;
2004-05-29 17:36:04 +02:00
print " </table></div> \n " ;
2004-11-02 22:42:46 +01:00
2002-05-10 14:28:10 +02:00
/*
2004-05-29 17:36:04 +02:00
* Barre d ' actions
2002-05-10 14:28:10 +02:00
*
2004-05-29 17:36:04 +02:00
*/
print '<div class="tabsAction">' ;
if ( $user -> societe_id == 0 )
2004-07-13 15:02:40 +02:00
{
2005-01-09 21:53:26 +01:00
// Si soci<63> t<EFBFBD> cliente ou prospect, on affiche bouton "Cr<43> er facture client"
if ( $societe -> client != 0 && $conf -> facture -> enabled && $user -> rights -> facture -> creer ) {
2004-07-31 13:36:01 +02:00
$langs -> load ( " bills " );
2005-01-08 12:53:00 +01:00
print " <a class= \" tabAction \" href= \" facture.php?action=create&socidp= $societe->id\ " > " . $langs->trans ( " AddBill " ). " </ a > " ;
2004-06-09 00:46:48 +02:00
}
2005-01-08 12:53:00 +01:00
2005-01-09 22:22:36 +01:00
if ( $conf -> deplacement -> enabled ) {
print " <a class= \" tabAction \" href= \" deplacement/fiche.php?socid= $societe->id &action=create \" > " . $langs -> trans ( " AddTrip " ) . " </a> " ;
}
2004-07-13 15:02:40 +02:00
}
2004-05-29 17:36:04 +02:00
print '</div>' ;
2004-06-09 00:46:48 +02:00
print " <br> \n " ;
2004-05-29 17:36:04 +02:00
/*
2002-05-10 14:28:10 +02:00
*
*
*/
if ( $action == 'changevalue' ) {
2004-05-29 17:36:04 +02:00
print " <hr noshade> " ;
2004-07-13 15:02:40 +02:00
print " <form action= \" index.php?socid= $societe->id\ " method = \ " post \" > " ;
2004-05-29 17:36:04 +02:00
print " <input type= \" hidden \" name= \" action \" value= \" cabrecrut \" > " ;
print " Cette soci<63> t<EFBFBD> est un cabinet de recrutement : " ;
print " <select name= \" selectvalue \" > " ;
print " <option value= \" \" > " ;
print " <option value= \" t \" >Oui " ;
print " <option value= \" f \" >Non " ;
print " </select> " ;
print " <input type= \" submit \" value= \" Mettre à jour \" > " ;
print " </form> \n " ;
2004-07-13 15:02:40 +02:00
}
else
{
2004-05-29 17:36:04 +02:00
/*
*
* Liste des contacts
*
*/
2004-11-02 22:42:46 +01:00
print '<table class="noborder" width="100%">' ;
2004-05-29 17:36:04 +02:00
2004-08-07 01:39:54 +02:00
print '<tr class="liste_titre"><td>' . $langs -> trans ( " Firstname " ) . ' ' . $langs -> trans ( " Lastname " ) . '</td>' ;
print '<td>' . $langs -> trans ( " Poste " ) . '</td><td>' . $langs -> trans ( " Tel " ) . '</td>' ;
print '<td>' . $langs -> trans ( " Fax " ) . '</td><td>' . $langs -> trans ( " EMail " ) . '</td>' ;
print " <td align= \" center \" ><a href= \" " . DOL_URL_ROOT . '/contact/fiche.php?socid=' . $socid . " &action=create \" > " . $langs -> trans ( " AddContact " ) . " </a></td> " ;
print '<td> </td>' ;
print " </tr> " ;
2004-05-29 17:36:04 +02:00
2004-11-02 22:42:46 +01:00
$sql = " SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note FROM " . MAIN_DB_PREFIX . " socpeople as p WHERE p.fk_soc = " . $societe -> id . " ORDER by p.datec " ;
2004-05-29 17:36:04 +02:00
$result = $db -> query ( $sql );
$i = 0 ; $num = $db -> num_rows ();
$var = 1 ;
while ( $i < $num )
{
2004-10-23 18:55:07 +02:00
$obj = $db -> fetch_object ( $result );
2004-05-29 17:36:04 +02:00
$var = ! $var ;
print " <tr $bc[$var] > " ;
print '<td>' ;
2004-08-07 01:39:54 +02:00
print '<a href="' . DOL_URL_ROOT . '/contact/fiche.php?id=' . $obj -> idp . '">' ;
print img_file ();
print ' ' . $obj -> firstname . ' ' . $obj -> name . '</a> ' ;
2004-05-29 17:36:04 +02:00
if ( $obj -> note )
{
2004-06-09 00:46:48 +02:00
print " <br> " . nl2br ( $obj -> note );
2004-05-29 17:36:04 +02:00
}
print " </td> " ;
print " <td> $obj->poste </td> " ;
2004-07-13 15:02:40 +02:00
print '<td><a href="../comm/action/fiche.php?action=create&actionid=1&contactid=' . $obj -> idp . '&socid=' . $societe -> id . '">' . $obj -> phone . '</a> </td>' ;
print '<td><a href="../comm/action/fiche.php?action=create&actionid=2&contactid=' . $obj -> idp . '&socid=' . $societe -> id . '">' . $obj -> fax . '</a> </td>' ;
print '<td><a href="../comm/action/fiche.php?action=create&actionid=4&contactid=' . $obj -> idp . '&socid=' . $societe -> id . '">' . $obj -> email . '</a> </td>' ;
2004-08-07 01:39:54 +02:00
print '<td align="center">' ;
print " <a href= \" ../contact/fiche.php?action=edit&id= $obj->idp\ " > " ;
print img_edit ();
print '</a></td>' ;
2004-11-02 22:42:46 +01:00
print '<td align="center"><a href="../comm/action/fiche.php?action=create&actionid=5&contactid=' . $obj -> idp . '&socid=' . $societe -> id . '">' ;
2004-08-07 01:39:54 +02:00
print img_actions ();
print '</a></td>' ;
2004-05-29 17:36:04 +02:00
print " </tr> \n " ;
$i ++ ;
$tag = ! $tag ;
}
2004-06-10 19:34:33 +02:00
print " </table><br> " ;
2004-05-29 17:36:04 +02:00
/*
2004-06-10 19:34:33 +02:00
*
* Listes des actions effectu<EFBFBD> es
2004-05-29 17:36:04 +02:00
*
*/
2004-09-30 14:17:19 +02:00
print '<table width="100%" cellspacing=0 class="noborder" cellpadding=2>' ;
print '<tr class="liste_titre"><td><a href="action/index.php?socid=' . $societe -> id . '">' . $langs -> trans ( " ActionsDone " ) . '</a></td></tr>' ;
2004-05-29 17:36:04 +02:00
print '<tr>' ;
print '<td valign="top">' ;
2004-06-10 19:34:33 +02:00
2004-05-29 17:36:04 +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 " . MAIN_DB_PREFIX . " actioncomm as a, " . MAIN_DB_PREFIX . " c_actioncomm as c, " . MAIN_DB_PREFIX . " user as u " ;
2004-07-13 15:02:40 +02:00
$sql .= " WHERE a.fk_soc = $societe->id " ;
2004-05-29 17:36:04 +02:00
$sql .= " AND u.rowid = a.fk_user_author " ;
$sql .= " AND c.id=a.fk_action " ;
$sql .= " ORDER BY a.datea DESC, a.id DESC " ;
if ( $db -> query ( $sql ) ) {
print " <table width= \" 100% \" cellspacing=0 border=0 cellpadding=2> \n " ;
$i = 0 ; $num = $db -> num_rows ();
while ( $i < $num ) {
$var = ! $var ;
2004-10-23 18:55:07 +02:00
$obj = $db -> fetch_object ();
2004-05-29 17:36:04 +02:00
print " <tr $bc[$var] > " ;
if ( $oldyear == strftime ( " %Y " , $obj -> da ) ) {
print '<td align="center">|</td>' ;
} else {
print " <TD align= \" center \" > " . strftime ( " %Y " , $obj -> da ) . " </TD> \n " ;
$oldyear = strftime ( " %Y " , $obj -> da );
}
if ( $oldmonth == strftime ( " %Y%b " , $obj -> da ) ) {
print '<td align="center">|</td>' ;
} else {
print " <TD align= \" center \" > " . strftime ( " %b " , $obj -> da ) . " </TD> \n " ;
$oldmonth = strftime ( " %Y%b " , $obj -> da );
}
print " <TD> " . strftime ( " %d " , $obj -> da ) . " </TD> \n " ;
print " <TD> " . strftime ( " %H:%M " , $obj -> da ) . " </TD> \n " ;
print '<td width="10%"> </td>' ;
2004-07-13 11:31:14 +02:00
print '<td width="40%">' ;
if ( $obj -> propalrowid )
{
print '<a href="' . DOL_URL_ROOT . '/comm/propal.php?propalid=' . $obj -> propalrowid . '">' ;
print img_file () . '</a> ' ;
print '<a href="' . DOL_URL_ROOT . '/comm/propal.php?propalid=' . $obj -> propalrowid . '">' . $obj -> libelle . '</a></td>' ;
}
else
{
print '<a href="' . DOL_URL_ROOT . '/comm/action/fiche.php?id=' . $obj -> id . '">' ;
print img_file () . '</a> ' ;
print '<a href="' . DOL_URL_ROOT . '/comm/action/fiche.php?id=' . $obj -> id . '">' . $obj -> libelle . '</a></td>' ;
}
2004-05-29 17:36:04 +02:00
/*
* Contact pour cette action
*
*/
if ( $obj -> fk_contact ) {
$contact = new Contact ( $db );
$contact -> fetch ( $obj -> fk_contact );
2004-12-25 20:43:55 +01:00
print '<td width="40%"><a href="' . DOL_URL_ROOT . '/contact/fiche.php?id=' . $contact -> id . '">' . $contact -> fullname . '</a></td>' ;
2004-05-29 17:36:04 +02:00
} else {
print '<td width="40%"> </td>' ;
}
/*
*/
print '<td width="20%"><a href="../user.php">' . $obj -> code . '</a></td>' ;
print " </tr> \n " ;
$i ++ ;
}
print " </table> " ;
$db -> free ();
} else {
print $db -> error ();
}
print " </td></tr></table> " ;
2004-06-10 19:34:33 +02:00
2004-05-29 17:36:04 +02:00
/*
*
* Notes sur la societe
*
*/
2004-07-13 15:02:40 +02:00
if ( $societe -> note ) {
2004-12-25 21:27:13 +01:00
print '<table class="border" width="100%" bgcolor="#e0e0e0">' ;
2004-07-13 15:02:40 +02:00
print " <tr><td> " . nl2br ( $societe -> note ) . " </td></tr> " ;
2004-05-29 17:36:04 +02:00
print " </table> " ;
}
/*
*
*
*
*/
2002-05-10 14:28:10 +02:00
}
2004-05-29 17:36:04 +02:00
2002-05-10 14:28:10 +02:00
} else {
2004-05-29 17:36:04 +02:00
print " Erreur " ;
2002-05-10 14:28:10 +02:00
}
$db -> close ();
llxFooter ( " <em>Dernière modification $Date $ révision $Revision $ </em> " );
?>