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 >
2006-02-25 01:38:31 +01:00
* Copyright ( C ) 2004 - 2006 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-04-08 22:36:33 +02: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 " );
2006-04-09 00:47:51 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/company.lib.php " );
2005-09-07 23:50:09 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /contact.class.php " );
2005-09-25 00:28:19 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /actioncomm.class.php " );
require_once ( DOL_DOCUMENT_ROOT . " /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 " );
2006-06-18 16:18:41 +02:00
if ( $conf -> projet -> enabled ) $langs -> load ( " projects " );
2004-11-12 01:50:14 +01:00
2006-03-11 03:04:07 +01:00
$user -> getrights ( " commercial " );
2006-03-10 18:32:47 +01:00
2006-03-11 03:04:07 +01:00
$socid = isset ( $_GET [ " socid " ]) ? $_GET [ " socid " ] : '' ;
2006-03-10 18:32:47 +01:00
if ( $socid == '' ) accessforbidden ();
2006-03-11 03:04:07 +01:00
// Protection quand utilisateur externe
2003-03-23 19:41:16 +01:00
if ( $user -> societe_id > 0 )
{
2005-11-11 17:37:53 +01:00
$action = '' ;
$socid = $user -> societe_id ;
2003-03-23 19:41:16 +01:00
}
2006-03-11 03:04:07 +01:00
2006-03-10 18:32:47 +01:00
// Protection restriction commercial
2006-03-10 18:35:20 +01:00
if ( ! $user -> rights -> commercial -> client -> voir && $socid && ! $user -> societe_id > 0 )
2006-03-10 18:32:47 +01:00
{
2006-03-11 03:04:07 +01:00
//print "eeeee".$socid."rr".$user->societe_id."oo".$user->rights->commercial->client->voir;
$sql = " SELECT sc.fk_soc, s.client " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe_commerciaux as sc, " . MAIN_DB_PREFIX . " societe as s " ;
2006-03-11 15:18:37 +01:00
$sql .= " WHERE sc.fk_soc = " . $socid . " AND sc.fk_user = " . $user -> id . " AND s.client = 1 " ;
2006-03-11 03:04:07 +01:00
if ( $db -> query ( $sql ) )
{
if ( $db -> num_rows () == 0 ) accessforbidden ();
}
2006-03-10 18:32:47 +01:00
}
2005-01-16 19:12:46 +01: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
}
2005-11-11 17:37:53 +01:00
llxHeader ();
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";
2006-02-17 00:26:14 +01:00
if ( $societe -> id <= 0 )
{
dolibarr_print_error ( $db , $societe -> error );
}
2006-04-09 00:47:51 +02:00
/*
* Affichage onglets
*/
$head = societe_prepare_head ( $societe );
2002-05-10 14:28:10 +02:00
2006-04-09 00:47:51 +02:00
dolibarr_fiche_head ( $head , 'compta' , $societe -> nom );
2004-05-29 17:36:04 +02:00
2004-11-02 22:42:46 +01:00
print " <table width= \" 100% \" > \n " ;
2005-04-29 02:16:53 +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%">' ;
2005-07-12 00:57:19 +02:00
print '<tr><td>' . $langs -> trans ( " Name " ) . '</td><td colspan="3">' . $societe -> nom . '</td></tr>' ;
2006-03-11 03:04:07 +01:00
// Prefix
print '<tr><td>' . $langs -> trans ( " Prefix " ) . '</td><td colspan="3">' ;
2005-07-12 00:57:19 +02:00
print ( $societe -> prefix_comm ? $societe -> prefix_comm : ' ' );
print '</td>' ;
2005-09-25 00:28:19 +02:00
if ( $societe -> client )
{
print '<tr>' ;
print '<td nowrap width="100">' . $langs -> trans ( " CustomerCode " ) . '</td><td colspan="3">' . $societe -> code_client . '</td>' ;
print '</tr>' ;
print '<tr>' ;
print '<td nowrap>' . $langs -> trans ( " CustomerAccountancyCode " ) . '</td><td colspan="3">' . $societe -> code_compta . '</td>' ;
print '</tr>' ;
2005-07-12 00:57:19 +02:00
}
2005-09-25 00:28:19 +02:00
if ( $societe -> fournisseur )
{
print '<tr>' ;
print '<td nowrap>' . $langs -> trans ( " SupplierCode " ) . '</td><td colspan="3">' . $societe -> code_fournisseur . '</td>' ;
print '</tr>' ;
print '<tr>' ;
print '<td nowrap>' . $langs -> trans ( " SupplierAccountancyCode " ) . '</td><td colspan="3">' . $societe -> code_compta_fournisseur . '</td>' ;
print '</tr>' ;
2005-07-12 00:57:19 +02:00
}
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> " ;
2005-04-29 02:16:53 +02:00
2005-05-08 21:38:59 +02:00
print '<tr><td>' . $langs -> trans ( 'Zip' ) . '</td><td>' . $societe -> cp . '</td>' ;
print '<td>' . $langs -> trans ( 'Town' ) . '</td><td>' . $societe -> ville . '</td></tr>' ;
2004-12-18 20:05:17 +01:00
print '<tr><td>' . $langs -> trans ( 'Country' ) . '</td><td colspan="3">' . $societe -> pays . '</td></tr>' ;
2005-04-29 02:16:53 +02:00
2005-07-15 02:26:54 +02:00
print '<tr><td>' . $langs -> trans ( " Phone " ) . '</td><td>' . dolibarr_print_phone ( $societe -> tel , $societe -> pays_code ) . ' </td><td>' . $langs -> trans ( " Fax " ) . '</td><td>' . dolibarr_print_phone ( $societe -> fax , $societe -> pays_code ) . ' </td></tr>' ;
2005-10-16 10:20:57 +02:00
print '<tr><td>' . $langs -> trans ( " Web " ) . " </td><td colspan= \" 3 \" ><a href= \" http:// $societe->url\ " target = \ " _blank \" > $societe->url </a> </td></tr> " ;
2002-05-10 14:28:10 +02:00
2006-03-18 23:46:29 +01:00
// Assujeti <20> TVA ou pas
print '<tr>' ;
print '<td nowrap="nowrap">' . $langs -> trans ( 'VATIsUsed' ) . '</td><td colspan="3">' ;
2006-03-19 00:28:22 +01:00
print yn ( $societe -> tva_assuj );
2006-03-18 23:46:29 +01:00
print '</td>' ;
print '</tr>' ;
// TVA Intra
2005-09-07 23:27:05 +02:00
print '<tr><td nowrap>' . $langs -> trans ( 'VATIntraVeryShort' ) . '</td><td colspan="3">' ;
2005-09-07 22:40:19 +02:00
print $societe -> tva_intra ;
print '</td></tr>' ;
2005-07-12 00:57:19 +02:00
2005-09-25 00:28:19 +02:00
if ( $societe -> client == 1 )
2005-09-07 23:27:05 +02:00
{
2005-09-25 00:28:19 +02:00
// Remise permanente
print '<tr><td nowrap>' ;
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>' ;
2006-04-04 02:34:51 +02:00
print $langs -> trans ( " CustomerRelativeDiscountShort " );
2005-09-25 00:28:19 +02:00
print '<td><td align="right">' ;
print '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe -> id . '">' . img_edit ( $langs -> trans ( " Modify " )) . '</a>' ;
print '</td></tr></table>' ;
2006-04-04 02:34:51 +02:00
print '</td><td colspan="3">' . ( $societe -> remise_client ? $societe -> remise_client . '%' : $langs -> trans ( " DiscountNone " )) . '</td>' ;
2005-09-25 00:28:19 +02:00
print '</tr>' ;
2006-05-21 14:20:36 +02:00
// R<> ductions (Remises-Ristournes-Rabbais)
2005-09-25 00:28:19 +02:00
print '<tr><td nowrap>' ;
print '<table width="100%" class="nobordernopadding">' ;
print '<tr><td nowrap>' ;
2006-04-04 02:34:51 +02:00
print $langs -> trans ( " CustomerAbsoluteDiscountShort " );
2005-09-25 00:28:19 +02:00
print '<td><td align="right">' ;
print '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe -> id . '">' . img_edit ( $langs -> trans ( " Modify " )) . '</a>' ;
print '</td></tr></table>' ;
print '</td>' ;
print '<td colspan="3">' ;
2006-04-04 02:12:45 +02:00
$amount_discount = $societe -> getCurrentDiscount ();
2006-04-02 20:57:50 +02:00
if ( $amount_discount < 0 ) dolibarr_print_error ( $db , $societe -> error );
if ( $amount_discount > 0 ) print $amount_discount . ' ' . $langs -> trans ( " Currency " . $conf -> monnaie );
2006-04-04 02:34:51 +02:00
else print $langs -> trans ( " DiscountNone " );
2005-09-25 00:28:19 +02:00
print '</td>' ;
print '</tr>' ;
2005-09-07 23:27:05 +02:00
}
2005-09-25 00:28:19 +02:00
2002-05-10 14:28:10 +02:00
print " </table> " ;
2004-05-29 17:36:04 +02:00
2002-05-10 14:28:10 +02:00
print " </td> \n " ;
2005-07-11 02:49:16 +02:00
2002-05-10 14:28:10 +02:00
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 ;
2006-03-18 23:46:29 +01:00
$tableaushown = 1 ;
// Lien recap
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>' . $langs -> trans ( " Summary " ) . '</td>' ;
2006-04-08 13:57:52 +02:00
print '<td align="right"><a href="' . DOL_URL_ROOT . '/compta/recap-compta.php?socid=' . $societe -> id . '">' . $langs -> trans ( " ShowAccountancyPreview " ) . '</a></td></tr></table></td>' ;
2006-03-18 23:46:29 +01:00
print '</tr>' ;
print '</table>' ;
print '<br>' ;
2005-01-16 19:02:39 +01:00
2005-09-25 00:28:19 +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
{
2006-03-18 23:46:29 +01:00
$facturestatic = new Facture ( $db );
2005-06-11 13:57:29 +02:00
print '<table class="noborder" width="100%">' ;
2005-04-29 02:16:53 +02:00
2005-05-08 17:04:24 +02:00
$sql = " SELECT s.nom, s.idp, f.facnumber, f.amount, f.total, f.total_ttc, " . $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 " ;
2005-04-29 02:16:53 +02:00
2005-05-08 17:04:24 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
2004-05-29 17:36:04 +02:00
{
2005-01-16 19:02:39 +01:00
$var = true ;
2005-05-08 17:04:24 +02:00
$num = $db -> num_rows ( $resql );
$i = 0 ;
2004-05-29 17:36:04 +02:00
if ( $num > 0 )
{
2005-06-26 03:52:22 +02:00
$tableaushown = 1 ;
2005-04-29 02:16:53 +02:00
print '<tr class="liste_titre">' ;
2006-03-18 23:46:29 +01:00
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>' . $langs -> trans ( " LastCustomersBills " ,( $num <= $MAXLIST ? " " : $MAXLIST )) . '</td><td align="right"><a href="' . DOL_URL_ROOT . '/compta/facture.php?socidp=' . $societe -> id . '">' . $langs -> trans ( " AllBills " ) . ' (' . $num . ')</a></td></tr></table></td>' ;
2005-01-16 19:02:39 +01:00
print '</tr>' ;
2004-05-29 17:36:04 +02:00
}
2005-04-29 02:16:53 +02:00
2005-01-16 19:02:39 +01:00
while ( $i < $num && $i < $MAXLIST )
2004-05-29 17:36:04 +02:00
{
2005-05-08 17:04:24 +02:00
$objp = $db -> fetch_object ( $resql );
2004-05-29 17:36:04 +02:00
$var =! $var ;
2004-06-09 00:46:48 +02:00
print " <tr $bc[$var] > " ;
2005-02-01 22:38:54 +01:00
print " <td><a href= \" ../compta/facture.php?facid= $objp->facid\ " > " .img_object( $langs->trans ( " ShowBill " ), " bill " ). " " . $objp->facnumber . " </ a ></ td > \n " ;
2006-03-11 03:04:07 +01:00
if ( $objp -> df > 0 )
2004-05-29 17:36:04 +02:00
{
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
}
2005-05-08 17:04:24 +02:00
print " <td align= \" right \" > " . price ( $objp -> total_ttc ) . " </td> \n " ;
2005-04-29 02:16:53 +02:00
2006-03-25 13:49:55 +01:00
print '<td align="right" nowrap="nowrap">' . ( $facturestatic -> LibStatut ( $objp -> paye , $objp -> statut , 5 )) . " </td> \n " ;
2004-06-09 00:46:48 +02:00
print " </tr> \n " ;
2004-05-29 17:36:04 +02:00
$i ++ ;
}
2005-09-25 00:28:19 +02:00
$db -> free ( $resql );
2004-05-29 17:36:04 +02:00
}
else
{
2005-01-16 19:02:39 +01:00
dolibarr_print_error ( $db );
2004-05-29 17:36:04 +02:00
}
print " </table> " ;
}
2005-04-29 02:16:53 +02: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 )
{
2005-08-11 22:31:07 +02:00
print '<table class="noborder" width="100%">' ;
2005-04-29 02:16:53 +02:00
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 " ;
2005-04-29 02:16:53 +02:00
2005-01-16 19:02:39 +01:00
if ( $db -> query ( $sql ) )
{
$var = true ;
$i = 0 ;
$num = $db -> num_rows ();
if ( $num > 0 )
{
2005-06-26 03:52:22 +02:00
$tableaushown = 1 ;
2005-04-29 02:16:53 +02:00
print '<tr class="liste_titre">' ;
2005-01-16 19:02:39 +01:00
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] > " ;
2005-08-31 22:45:52 +02:00
print '<td><a href="../projet/fiche.php?id=' . $obj -> rowid . '">' . img_object ( $langs -> trans ( " ShowProject " ), " project " ) . " " . $obj -> title . '</a></td>' ;
2005-04-29 02:16:53 +02:00
2006-03-11 03:04:07 +01:00
print " <td align= \" right \" > " . dolibarr_print_date ( $obj -> do , " %d %b %Y " ) . " </td></tr> " ;
2005-01-16 19:02:39 +01:00
$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
}
2005-04-29 02:16:53 +02: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">' ;
2006-03-18 23:46:29 +01:00
if ( $user -> societe_id == 0 )
{
// 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 ) {
$langs -> load ( " bills " );
print " <a class= \" tabAction \" href= \" facture.php?action=create&socidp= $societe->id\ " > " . $langs->trans ( " AddBill " ). " </ a > " ;
}
if ( $conf -> deplacement -> enabled ) {
$langs -> load ( " trips " );
print " <a class= \" tabAction \" href= \" deplacement/fiche.php?socid= $societe->id &action=create \" > " . $langs -> trans ( " AddTrip " ) . " </a> " ;
}
}
print '<a class="butAction" href="action/fiche.php?action=create&socid=' . $objsoc -> id . '">' . $langs -> trans ( " AddAction " ) . '</a>' ;
2005-04-29 02:16:53 +02:00
2006-03-18 23:46:29 +01:00
if ( $user -> rights -> societe -> contact -> creer )
{
print " <a class= \" tabAction \" href= \" " . DOL_URL_ROOT . '/contact/fiche.php?socid=' . $socid . " &action=create \" > " . $langs -> trans ( " AddContact " ) . " </a> " ;
}
2005-06-25 17:52:01 +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
*
*
*/
2005-09-06 22:58:14 +02:00
if ( $action == 'changevalue' )
{
2002-05-10 14:28:10 +02:00
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> " ;
2005-09-06 22:58:14 +02:00
print " <input type= \" submit \" class= \" button \" value= \" " . $langs -> trans ( " Update " ) . " \" > " ;
2004-05-29 17:36:04 +02:00
print " </form> \n " ;
2004-07-13 15:02:40 +02:00
}
else
2005-09-06 22:58:14 +02:00
{
2004-05-29 17:36:04 +02:00
/*
*
* Liste des contacts
*
*/
2006-04-29 02:35:00 +02:00
print_titre ( $langs -> trans ( " ContactsForCompany " ));
2006-03-11 03:04:07 +01:00
print '<table class="noborder" width="100%">' ;
2006-04-29 02:35:00 +02:00
print '<tr class="liste_titre"><td>' . $langs -> trans ( " Name " ) . '</td>' ;
2006-03-11 03:04:07 +01:00
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 \" > </td> " ;
print '<td> </td>' ;
print " </tr> " ;
2004-05-29 17:36:04 +02:00
2005-04-08 22:36:33 +02:00
$sql = " SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " socpeople as p " ;
$sql .= " WHERE p.fk_soc = " . $societe -> id ;
$sql .= " ORDER by p.datec " ;
2005-04-29 02:16:53 +02:00
2004-05-29 17:36:04 +02:00
$result = $db -> query ( $sql );
2005-04-08 22:36:33 +02:00
$i = 0 ; $num = $db -> num_rows ( $result );
2004-05-29 17:36:04 +02:00
$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>' ;
2005-02-09 21:56:18 +01:00
print '<a href="' . DOL_URL_ROOT . '/contact/fiche.php?id=' . $obj -> idp . '">' . img_object ( $langs -> trans ( " ShowContact " ), " contact " ) . ' ' . $obj -> firstname . ' ' . $obj -> name . '</a> ' ;
2004-08-07 01:39:54 +02:00
2005-01-30 22:39:36 +01:00
if ( trim ( $obj -> note ))
2004-05-29 17:36:04 +02:00
{
2005-01-30 22:39:36 +01:00
print '<br>' . nl2br ( trim ( $obj -> note ));
2004-05-29 17:36:04 +02:00
}
2005-01-30 22:39:36 +01: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">' ;
2005-12-02 13:44:17 +01:00
2005-12-02 22:11:49 +01:00
if ( $user -> rights -> societe -> contact -> creer )
{
2005-12-02 13:44:17 +01:00
print " <a href= \" ../contact/fiche.php?action=edit&id= $obj->idp\ " > " ;
2005-12-02 13:47:10 +01:00
print img_edit ();
2005-12-02 22:11:49 +01:00
print '</a>' ;
2005-12-02 13:44:17 +01:00
}
2005-12-02 22:11:49 +01:00
else print ' ' ;
2005-12-02 13:47:10 +01:00
2005-12-02 22:11:49 +01:00
print '</td>' ;
2005-04-29 02:16:53 +02:00
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 . '">' ;
2005-01-30 22:39:36 +01:00
print img_object ( $langs -> trans ( " Rendez-Vous " ), " action " );
2004-08-07 01:39:54 +02:00
print '</a></td>' ;
2004-05-29 17:36:04 +02:00
print " </tr> \n " ;
$i ++ ;
$tag = ! $tag ;
}
2006-02-25 01:38:31 +01:00
print " </table> " ;
print " <br> " ;
2006-06-22 02:05:19 +02:00
$actionstatic = new ActionComm ( $db );
2006-02-25 01:38:31 +01:00
/*
* Listes des actions a faire
*
*/
2006-04-29 02:35:00 +02:00
print_titre ( $langs -> trans ( " ActionsOnCompany " ));
2006-02-25 01:38:31 +01:00
print '<table width="100%" class="noborder">' ;
2006-06-22 02:05:19 +02:00
print '<tr class="liste_titre">' ;
print '<td colspan="11"><a href="' . DOL_URL_ROOT . '/comm/action/index.php?socid=' . $societe -> id . '&status=todo">' . $langs -> trans ( " ActionsToDoShort " ) . '</a></td><td align="right"> </td>' ;
print '</tr>' ;
2006-02-25 01:38:31 +01:00
2006-06-22 02:05:19 +02:00
$sql = " SELECT a.id, a.label, " . $db -> pdate ( " a.datea " ) . " as da, a.percent, " ;
$sql .= " c.code as acode, 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 " ;
$sql .= " WHERE a.fk_soc = " . $societe -> id ;
$sql .= " AND u.rowid = a.fk_user_author " ;
$sql .= " AND c.id=a.fk_action AND a.percent < 100 " ;
$sql .= " ORDER BY a.datea DESC, a.id DESC " ;
2006-02-25 01:38:31 +01:00
$result = $db -> query ( $sql );
if ( $result )
{
$i = 0 ;
$num = $db -> num_rows ( $result );
$var = true ;
while ( $i < $num )
{
$var = ! $var ;
$obj = $db -> fetch_object ( $result );
print " <tr $bc[$var] > " ;
if ( $oldyear == strftime ( " %Y " , $obj -> da ) )
{
print '<td width="30" align="center">|</td>' ;
}
else
{
print '<td width="30" align="center">' . strftime ( " %Y " , $obj -> da ) . " </td> \n " ;
$oldyear = strftime ( " %Y " , $obj -> da );
}
if ( $oldmonth == strftime ( " %Y%b " , $obj -> da ) )
{
print '<td width="30" align="center">|</td>' ;
}
else
{
print '<td width="30" align="center">' . strftime ( " %b " , $obj -> da ) . " </td> \n " ;
$oldmonth = strftime ( " %Y%b " , $obj -> da );
}
print '<td width="20">' . strftime ( " %d " , $obj -> da ) . " </td> \n " ;
2006-04-02 03:53:51 +02:00
print '<td width="30" nowrap="nowrap">' . strftime ( " %H:%M " , $obj -> da ) . '</td>' ;
// Picto warning
print '<td width="16">' ;
if ( date ( " U " , $obj -> da ) < time ()) print ' ' . img_warning ( " Late " );
else print ' ' ;
print '</td>' ;
2006-02-25 01:38:31 +01:00
// Status/Percent
print '<td width="30"> </td>' ;
if ( $obj -> propalrowid )
{
2006-04-02 03:53:51 +02:00
print '<td><a href="' . DOL_URL_ROOT . '/comm/propal.php?propalid=' . $obj -> propalrowid . '">' . img_object ( $langs -> trans ( " ShowAction " ), " task " );
2006-02-25 01:38:31 +01:00
$transcode = $langs -> trans ( " Action " . $obj -> acode );
$libelle = ( $transcode != " Action " . $obj -> acode ? $transcode : $obj -> libelle );
print $libelle ;
print '</a></td>' ;
}
else
{
2006-04-02 03:53:51 +02:00
print '<td><a href="' . DOL_URL_ROOT . '/comm/action/fiche.php?id=' . $obj -> id . '">' . img_object ( $langs -> trans ( " ShowAction " ), " task " );
2006-02-25 01:38:31 +01:00
$transcode = $langs -> trans ( " Action " . $obj -> acode );
$libelle = ( $transcode != " Action " . $obj -> acode ? $transcode : $obj -> libelle );
print $libelle ;
print '</a></td>' ;
}
2006-04-02 03:53:51 +02:00
print '<td colspan="2">' . $obj -> label . '</td>' ;
2006-02-25 01:38:31 +01:00
// Contact pour cette action
if ( $obj -> fk_contact ) {
$contact = new Contact ( $db );
$contact -> fetch ( $obj -> fk_contact );
2006-04-02 03:53:51 +02:00
print '<td><a href="' . DOL_URL_ROOT . '/contact/fiche.php?id=' . $obj -> fk_contact . '">' . img_object ( $langs -> trans ( " ShowContact " ), " contact " ) . ' ' . $contact -> fullname . '</a></td>' ;
2006-02-25 01:38:31 +01:00
} else {
print '<td> </td>' ;
}
2006-04-02 03:53:51 +02:00
// Auteur
print '<td width="50" nowrap="nowrap"><a href="' . DOL_URL_ROOT . '/user/fiche.php?id=' . $obj -> fk_user_author . '">' . img_object ( $langs -> trans ( " ShowUser " ), " user " ) . ' ' . $obj -> code . '</a></td>' ;
2006-06-22 02:05:19 +02:00
// Statut
print '<td nowrap="nowrap" width="20">' . $actionstatic -> LibStatut ( $obj -> percent , 3 ) . '</td>' ;
2006-02-25 01:38:31 +01:00
print " </tr> \n " ;
$i ++ ;
}
$db -> free ( $result );
} else {
dolibarr_print_error ( $db );
}
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
*/
2005-02-09 21:56:18 +01:00
print '<table width="100%" class="noborder">' ;
2006-06-22 02:05:19 +02:00
print '<tr class="liste_titre">' ;
print '<td colspan="12"><a href="' . DOL_URL_ROOT . '/comm/action/index.php?socid=' . $societe -> id . '&status=done">' . $langs -> trans ( " ActionsDoneShort " ) . '</a>' ;
print '</td></tr>' ;
2006-04-02 03:53:51 +02:00
2006-06-22 02:05:19 +02:00
$sql = " SELECT a.id, a.label, " . $db -> pdate ( " a.datea " ) . " as da, a.percent, " ;
2006-04-02 03:53:51 +02:00
$sql .= " a.propalrowid, a.fk_facture, a.fk_user_author, a.fk_contact, " ;
$sql .= " c.code as acode, c.libelle, " ;
$sql .= " u.code, u.rowid " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " actioncomm as a, " . MAIN_DB_PREFIX . " c_actioncomm as c, " . MAIN_DB_PREFIX . " user as u " ;
$sql .= " WHERE a.fk_soc = " . $societe -> id ;
$sql .= " AND u.rowid = a.fk_user_author " ;
$sql .= " AND c.id=a.fk_action AND a.percent = 100 " ;
$sql .= " ORDER BY a.datea DESC, a.id DESC " ;
2004-05-29 17:36:04 +02:00
2005-06-11 13:57:29 +02:00
$result = $db -> query ( $sql );
if ( $result )
{
$i = 0 ;
$num = $db -> num_rows ( $result );
$var = true ;
while ( $i < $num )
{
2004-05-29 17:36:04 +02:00
$var = ! $var ;
2005-06-11 13:57:29 +02:00
$obj = $db -> fetch_object ( $result );
2004-05-29 17:36:04 +02:00
print " <tr $bc[$var] > " ;
if ( $oldyear == strftime ( " %Y " , $obj -> da ) ) {
2005-06-11 13:57:29 +02:00
print '<td width="30" align="center">|</td>' ;
2004-05-29 17:36:04 +02:00
} else {
2005-06-11 13:57:29 +02:00
print '<td width="30" align="center">' . strftime ( " %Y " , $obj -> da ) . " </td> \n " ;
2004-05-29 17:36:04 +02:00
$oldyear = strftime ( " %Y " , $obj -> da );
}
if ( $oldmonth == strftime ( " %Y%b " , $obj -> da ) ) {
2005-06-11 13:57:29 +02:00
print '<td width="30" align="center">|</td>' ;
2004-05-29 17:36:04 +02:00
} else {
2005-06-11 13:57:29 +02:00
print '<td width="30" align="center">' . strftime ( " %b " , $obj -> da ) . " </td> \n " ;
2004-05-29 17:36:04 +02:00
$oldmonth = strftime ( " %Y%b " , $obj -> da );
}
2005-06-11 13:57:29 +02:00
print '<td width="20">' . strftime ( " %d " , $obj -> da ) . " </td> \n " ;
print '<td width="30">' . strftime ( " %H:%M " , $obj -> da ) . " </td> \n " ;
2006-04-02 03:53:51 +02:00
// Picto
print '<td width="16"> </td>' ;
2006-03-11 03:04:07 +01:00
// Espace
2006-04-02 03:53:51 +02:00
print '<td width="30"> </td>' ;
2005-06-11 13:57:29 +02:00
2006-03-11 03:04:07 +01:00
// Action
2005-06-11 13:57:29 +02:00
print '<td>' ;
2006-03-11 03:04:07 +01:00
print '<a href="' . DOL_URL_ROOT . '/comm/action/fiche.php?id=' . $obj -> id . '">' . img_object ( $langs -> trans ( " ShowTask " ), " task " );
$transcode = $langs -> trans ( " Action " . $obj -> acode );
$libelle = ( $transcode != " Action " . $obj -> acode ? $transcode : $obj -> libelle );
print $libelle ;
print '</a>' ;
print '</td>' ;
2006-04-02 03:53:51 +02:00
// Objet li<6C>
2006-03-11 03:04:07 +01:00
print '<td>' ;
if ( $obj -> propalrowid )
{
print '<a href="' . DOL_URL_ROOT . '/comm/propal.php?propalid=' . $obj -> propalrowid . '">' . img_object ( $langs -> trans ( " ShowPropal " ), " propal " );
print $langs -> trans ( " Propal " );
print '</a>' ;
}
2006-04-02 03:53:51 +02:00
if ( $obj -> fk_facture )
{
print '<a href="' . DOL_URL_ROOT . '/compta/facture.php?facid=' . $obj -> fk_facture . '">' . img_object ( $langs -> trans ( " ShowBill " ), " bill " );
print $langs -> trans ( " Invoice " );
print '</a>' ;
}
2006-03-11 03:04:07 +01:00
else print ' ' ;
print '</td>' ;
2005-06-11 13:57:29 +02:00
2006-04-02 03:53:51 +02:00
// Libell<6C>
print " <td> $obj->label </td> " ;
2005-06-11 13:57:29 +02:00
// Contact pour cette action
2006-03-11 03:04:07 +01:00
if ( $obj -> fk_contact )
{
2004-05-29 17:36:04 +02:00
$contact = new Contact ( $db );
$contact -> fetch ( $obj -> fk_contact );
2005-06-11 13:57:29 +02:00
print '<td><a href="' . DOL_URL_ROOT . '/contact/fiche.php?id=' . $contact -> id . '">' . img_object ( $langs -> trans ( " ShowContact " ), " contact " ) . ' ' . $contact -> fullname . '</a></td>' ;
2006-03-11 03:04:07 +01:00
}
else
{
2005-06-11 13:57:29 +02:00
print '<td> </td>' ;
2004-05-29 17:36:04 +02:00
}
2005-06-11 13:57:29 +02:00
2006-04-02 03:53:51 +02:00
// Auteur
print '<td nowrap="nowrap" width="50"><a href="' . DOL_URL_ROOT . '/user/fiche.php?id=' . $obj -> rowid . '">' . img_object ( $langs -> trans ( " ShowUser " ), 'user' ) . ' ' . $obj -> code . '</a></td>' ;
2006-06-22 02:05:19 +02:00
// Statut
print '<td nowrap="nowrap" width="20">' . $actionstatic -> LibStatut ( $obj -> percent , 3 ) . '</td>' ;
2004-05-29 17:36:04 +02:00
print " </tr> \n " ;
$i ++ ;
}
$db -> free ();
2006-03-11 03:04:07 +01:00
}
else
{
2005-02-09 21:56:18 +01:00
dolibarr_print_error ( $db );
2004-05-29 17:36:04 +02:00
}
2005-02-09 21:56:18 +01:00
print " </table> " ;
2004-06-10 19:34:33 +02:00
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 ();
2005-06-11 13:57:29 +02:00
llxFooter ( '$Date$ - $Revision$' );
2002-05-10 14:28:10 +02:00
?>