2004-10-19 22:19:58 +02:00
< ? php
2005-02-17 12:33:58 +01:00
/* Copyright ( C ) 2001 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2005-01-16 19:02:39 +01:00
* Copyright ( C ) 2004 - 2005 Laurent Destailleur < eldy @ users . sourceforge . net >
2004-12-22 21:13:42 +01:00
* Copyright ( C ) 2004 Eric Seigne < eric . seigne @ ryxeo . com >
2006-02-03 17:42:39 +01:00
* Copyright ( C ) 2006 Andre Cianfarani < acianfa @ free . fr >
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 16:37:36 +01:00
* $Id $
* $Source $
2002-05-10 14:28:10 +02:00
*/
2004-10-30 04:01:06 +02:00
2005-03-21 19:55:32 +01:00
/**
\file htdocs / comm / fiche . php
\ingroup commercial
\brief Onglet client de la fiche societe
\version $Revision $
2004-10-30 04:01:06 +02:00
*/
2005-03-21 19:55:32 +01:00
2005-07-07 02:28:49 +02:00
require_once ( " ./pre.inc.php " );
2005-08-21 21:11:54 +02:00
if ( ! $user -> rights -> societe -> lire ) accessforbidden ();
require_once ( DOL_DOCUMENT_ROOT . " /contact.class.php " );
2005-09-01 21:40:45 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /propal.class.php " );
2005-08-21 21:11:54 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /actioncomm.class.php " );
2005-08-13 23:23:02 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /commande/commande.class.php " );
2005-08-21 21:11:54 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /contrat/contrat.class.php " );
2002-05-10 14:28:10 +02:00
2004-11-12 01:50:14 +01:00
$langs -> load ( " companies " );
$langs -> load ( " orders " );
$langs -> load ( " contracts " );
2005-11-15 23:57:57 +01:00
if ( $conf -> fichinter -> enabled ) $langs -> load ( " interventions " );
2004-11-12 01:50:14 +01:00
2005-02-17 12:33:58 +01:00
llxHeader ( '' , $langs -> trans ( 'CustomerCard' ));
2004-08-07 01:39:54 +02:00
$sortorder = $_GET [ " sortorder " ];
$sortfield = $_GET [ " sortfield " ];
2005-03-21 19:55:32 +01:00
if ( ! $sortorder ) $sortorder = " ASC " ;
if ( ! $sortfield ) $sortfield = " nom " ;
2002-05-10 14:28:10 +02:00
2005-02-17 12:33:58 +01:00
if ( $_GET [ " action " ] == 'attribute_prefix' )
{
2005-03-21 19:55:32 +01:00
$societe = new Societe ( $db , $_GET [ " socid " ]);
$societe -> attribute_prefix ( $db , $_GET [ " socid " ]);
2002-05-10 14:28:10 +02:00
}
2006-02-14 15:49:02 +01:00
// conditions de r<> glement
if ( $_POST [ " action " ] == 'setconditions' )
{
$societe = new Societe ( $db , $_GET [ " socid " ]);
2006-02-15 19:44:10 +01:00
$societe -> cond_reglement = $_POST [ 'cond_reglement_id' ];
$sql = " UPDATE " . MAIN_DB_PREFIX . " societe SET cond_reglement=' " . $_POST [ 'cond_reglement_id' ] . " ' WHERE idp=' " . $socid . " ' " ;
2006-02-14 15:49:02 +01:00
$result = $db -> query ( $sql );
}
2006-02-14 12:27:50 +01:00
// mode de r<> glement
if ( $_POST [ " action " ] == 'setmode' )
{
$societe = new Societe ( $db , $_GET [ " socid " ]);
$societe -> mode_reglement = $_POST [ 'mode_reglement_id' ];
$sql = " UPDATE " . MAIN_DB_PREFIX . " societe SET mode_reglement=' " . $_POST [ 'mode_reglement_id' ] . " ' WHERE idp=' " . $socid . " ' " ;
$result = $db -> query ( $sql );
}
2006-02-20 17:43:05 +01:00
// assuj<75> tissement <20> la TVA
if ( $_POST [ " action " ] == 'setassujtva' )
{
$societe = new Societe ( $db , $_GET [ " socid " ]);
$societe -> tva_assuj = $_POST [ 'assujtva_value' ];
$sql = " UPDATE " . MAIN_DB_PREFIX . " societe SET tva_assuj=' " . $_POST [ 'assujtva_value' ] . " ' WHERE idp=' " . $socid . " ' " ;
$result = $db -> query ( $sql );
}
2002-05-10 14:28:10 +02:00
2005-02-17 12:33:58 +01:00
if ( $action == 'recontact' )
{
2005-03-21 19:55:32 +01: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 . " ') " ;
$result = $db -> query ( $sql );
2002-05-10 14:28:10 +02:00
}
2005-02-17 12:33:58 +01:00
if ( $action == 'stcomm' )
{
2005-03-21 19:55:32 +01:00
if ( $stcommid <> 'null' && $stcommid <> $oldstcomm )
2005-02-17 12:33:58 +01:00
{
2005-03-21 19:55:32 +01:00
$sql = " INSERT INTO socstatutlog (datel, fk_soc, fk_statut, author) " ;
$sql .= " VALUES (' $dateaction ', $socid , $stcommid ,' " . $user -> login . " ') " ;
$result = @ $db -> query ( $sql );
if ( $result )
{
$sql = " UPDATE " . MAIN_DB_PREFIX . " societe SET fk_stcomm= $stcommid WHERE idp= $socid " ;
$result = $db -> query ( $sql );
}
else
{
$errmesg = " ERREUR DE DATE ! " ;
}
2002-05-10 14:28:10 +02:00
}
2005-03-21 19:55:32 +01:00
if ( $actioncommid )
2005-02-17 12:33:58 +01:00
{
2005-03-21 19:55:32 +01: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 )
{
$errmesg = " ERREUR DE DATE ! " ;
}
2002-05-10 14:28:10 +02:00
}
}
/*
* Recherche
*
*/
if ( $mode == 'search' ) {
2005-03-21 19:55:32 +01:00
if ( $mode - search == 'soc' ) {
$sql = " SELECT s.idp FROM " . MAIN_DB_PREFIX . " societe as s " ;
$sql .= " WHERE lower(s.nom) like '% " . strtolower ( $socname ) . " %' " ;
}
if ( $db -> query ( $sql ) ) {
if ( $db -> num_rows () == 1 ) {
$obj = $db -> fetch_object ();
$socid = $obj -> idp ;
}
$db -> free ();
2002-05-10 14:28:10 +02:00
}
}
2005-03-21 19:55:32 +01:00
2005-11-15 23:45:37 +01:00
// Protection quand utilisateur externe
$_socid = isset ( $_GET [ " socid " ]) ? $_GET [ " socid " ] : '' ;
2005-03-21 19:55:32 +01:00
if ( $user -> societe_id > 0 )
2003-03-23 16:00:42 +01:00
{
2005-03-21 19:55:32 +01:00
$_socid = $user -> societe_id ;
2003-03-23 16:00:42 +01:00
}
2005-03-21 19:55:32 +01:00
2003-11-19 16:12:24 +01:00
/*********************************************************************************
2002-05-10 14:28:10 +02:00
*
* Mode fiche
*
2005-03-21 19:55:32 +01:00
*********************************************************************************/
2004-07-29 15:29:27 +02:00
if ( $_socid > 0 )
2003-11-19 16:12:24 +01:00
{
2005-03-21 19:55:32 +01:00
// On recupere les donnees societes par l'objet
$objsoc = new Societe ( $db );
$objsoc -> id = $_socid ;
$objsoc -> fetch ( $_socid , $to );
$dac = strftime ( " %Y-%m-%d %H:%M " , time ());
if ( $errmesg )
2004-05-29 17:58:36 +02:00
{
2005-03-21 19:55:32 +01:00
print " <b> $errmesg </b><br> " ;
2004-05-29 17:58:36 +02:00
}
2005-03-21 19:55:32 +01:00
/*
* Affichage onglets
*/
$h = 0 ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/soc.php?socid=' . $objsoc -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " Company " );
$h ++ ;
if ( $objsoc -> client == 1 )
2004-05-29 17:58:36 +02:00
{
2005-03-21 19:55:32 +01:00
$hselected = $h ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/comm/fiche.php?socid=' . $objsoc -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " Customer " );;
$h ++ ;
2004-05-29 17:58:36 +02:00
}
2005-03-21 19:55:32 +01:00
if ( $objsoc -> client == 2 )
2004-05-29 17:58:36 +02:00
{
2005-03-21 19:55:32 +01:00
$hselected = $h ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/comm/prospect/fiche.php?id=' . $obj -> socid ;
$head [ $h ][ 1 ] = $langs -> trans ( " Prospect " );
$h ++ ;
2004-05-29 17:58:36 +02:00
}
2005-03-21 19:55:32 +01:00
if ( $objsoc -> fournisseur )
2004-07-13 09:43:43 +02:00
{
2005-03-21 19:55:32 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/fourn/fiche.php?socid=' . $objsoc -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " Supplier " );
$h ++ ;
}
if ( $conf -> compta -> enabled ) {
$langs -> load ( " compta " );
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/compta/fiche.php?socid=' . $objsoc -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " Accountancy " );
$h ++ ;
2004-05-29 17:58:36 +02:00
}
2005-03-21 19:55:32 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/socnote.php?socid=' . $objsoc -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " Note " );
2004-07-13 09:43:43 +02:00
$h ++ ;
2004-05-29 17:58:36 +02:00
2005-03-21 19:55:32 +01:00
if ( $user -> societe_id == 0 )
2004-05-29 17:58:36 +02:00
{
2005-03-21 19:55:32 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/docsoc.php?socid=' . $objsoc -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " Documents " );
$h ++ ;
2004-05-29 17:58:36 +02:00
}
2005-03-21 19:55:32 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/societe/notify/fiche.php?socid=' . $objsoc -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " Notifications " );
$h ++ ;
2005-11-11 17:37:53 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/societe/info.php?socid=' . $objsoc -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " Info " );
$h ++ ;
2005-03-21 19:55:32 +01:00
if ( $user -> societe_id == 0 )
2005-01-14 15:56:04 +01:00
{
2005-08-15 17:44:44 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /bookmarks/fiche.php?action=add&socid= " . $objsoc -> id . " &urlsource= " . $_SERVER [ " PHP_SELF " ] . " ?socid= " . $objsoc -> id ;
2005-09-05 21:03:02 +02:00
$head [ $h ][ 1 ] = img_object ( $langs -> trans ( " BookmarkThisPage " ), 'bookmark' );
2005-03-21 19:55:32 +01:00
$head [ $h ][ 2 ] = 'image' ;
$h ++ ;
2005-01-14 15:56:04 +01:00
}
2005-03-21 19:55:32 +01:00
dolibarr_fiche_head ( $head , $hselected , $objsoc -> nom );
2005-06-11 13:31:53 +02:00
2005-03-21 19:55:32 +01:00
/*
*
*
*/
print '<table width="100%" border="0">' ;
print '<tr><td valign="top">' ;
print '<table class="border" width="100%">' ;
2006-02-15 17:58:42 +01:00
print '<tr><td width="30%">' . $langs -> trans ( " Name " ) . '</td><td width="70%" colspan="3">' ;
2005-03-21 19:55:32 +01:00
print $objsoc -> nom ;
2005-03-28 15:52:40 +02:00
print '</td></tr>' ;
2005-03-21 19:55:32 +01:00
2005-07-12 00:57:19 +02:00
print '<tr><td>' . $langs -> trans ( 'Prefix' ) . '</td><td colspan="3">' . $objsoc -> prefix_comm . '</td></tr>' ;
2005-08-13 02:44:28 +02:00
if ( $objsoc -> client )
{
2005-07-12 00:57:19 +02:00
print '<tr><td>' ;
print $langs -> trans ( 'CustomerCode' ) . '</td><td colspan="3">' ;
print $objsoc -> code_client ;
if ( $objsoc -> check_codeclient () <> 0 ) print ' ' . $langs -> trans ( " WrongCustomerCode " );
print '</td></tr>' ;
2005-08-13 02:44:28 +02:00
}
if ( $conf -> compta -> enabled )
{
2005-07-12 00:57:19 +02:00
print '<tr>' ;
2005-09-02 18:43:23 +02:00
print '<td nowrap>' . $langs -> trans ( " CustomerAccountancyCode " ) . '</td><td colspan="3">' . $objsoc -> code_compta . '</td>' ;
2005-07-12 00:57:19 +02:00
print '</tr>' ;
}
/*
if ( $objsoc -> fournisseur ) {
print '<tr><td>' ;
print $langs -> trans ( 'SupplierCode' ) . '</td><td colspan="3">' ;
print $objsoc -> code_fournisseur ;
if ( $objsoc -> check_codefournisseur () <> 0 ) print ' ' . $langs -> trans ( " WrongSupplierCode " );
print '</td></tr>' ;
}
*/
2005-03-28 15:52:40 +02:00
print " <tr><td valign= \" top \" > " . $langs -> trans ( 'Address' ) . " </td><td colspan= \" 3 \" > " . nl2br ( $objsoc -> adresse ) . " </td></tr> " ;
2005-03-21 19:55:32 +01:00
2005-03-28 15:52:40 +02:00
print '<tr><td>' . $langs -> trans ( 'Zip' ) . '</td><td>' . $objsoc -> cp . " </td> " ;
print '<td>' . $langs -> trans ( 'Town' ) . '</td><td>' . $objsoc -> ville . " </td></tr> " ;
2005-11-14 22:13:08 +01:00
if ( $objsoc -> pays ) {
print '<tr><td>' . $langs -> trans ( 'Country' ) . '</td><td colspan="3">' . $objsoc -> pays . '</td></tr>' ;
}
2005-03-21 19:55:32 +01:00
2005-08-11 20:54:59 +02:00
print '<tr><td>' . $langs -> trans ( 'Phone' ) . '</td><td>' . dolibarr_print_phone ( $objsoc -> tel , $objsoc -> pays_code ) . '</td>' ;
print '<td>' . $langs -> trans ( 'Fax' ) . '</td><td>' . dolibarr_print_phone ( $objsoc -> fax , $objsoc -> pays_code ) . '</td></tr>' ;
2005-03-28 15:52:40 +02:00
2005-10-16 10:20:57 +02:00
print '<tr><td>' . $langs -> trans ( " Web " ) . " </td><td colspan= \" 3 \" ><a href= \" http:// $objsoc->url\ " target = \ " _blank \" > " . $objsoc -> url . " </a> </td></tr> " ;
2005-11-14 22:13:08 +01:00
if ( $objsoc -> siren || $objsoc -> siret ) {
print " <tr><td nowrap> " . $langs -> transcountry ( " ProfId1 " , $objsoc -> pays_code ) . " </td><td><a href= \" http://www.societe.com/cgi-bin/recherche?rncs= " . $objsoc -> siren . " \" target= \" _blank \" > " . $objsoc -> siren . " </a> </td> " ;
2005-03-28 15:52:40 +02:00
print '<td>' . $langs -> transcountry ( 'ProfId2' , $objsoc -> pays_code ) . '</td><td>' . $objsoc -> siret . '</td></tr>' ;
2005-11-14 22:13:08 +01:00
}
if ( $objsoc -> ape ) {
print '<tr><td>' . $langs -> transcountry ( 'ProfId3' , $objsoc -> pays_code ) . '</td><td>' . $objsoc -> ape . '</td><td colspan="2"> </td></tr>' ;
}
2005-07-12 00:57:19 +02:00
// Type + Staff
$arr = $objsoc -> typent_array ( $objsoc -> typent_id );
$objsoc -> typent = $arr [ $objsoc -> typent_id ];
2005-11-14 22:13:08 +01:00
if ( $objsoc -> typent || $objsoc -> effectif ) {
print '<tr><td>' . $langs -> trans ( " Type " ) . '</td><td>' . $objsoc -> typent . '</td><td>' . $langs -> trans ( " Staff " ) . '</td><td nowrap>' . $objsoc -> effectif . '</td></tr>' ;
}
2005-03-21 19:55:32 +01:00
2005-09-07 23:27:05 +02:00
// Remise permanente
2005-03-21 19:55:32 +01:00
print '<tr><td nowrap>' ;
2005-08-20 17:37:16 +02:00
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>' ;
2005-08-11 20:54:59 +02:00
print $langs -> trans ( " CustomerRelativeDiscount " );
print '<td><td align="right">' ;
2005-09-07 23:27:05 +02:00
print '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $objsoc -> id . '">' . img_edit ( $langs -> trans ( " Modify " )) . '</a>' ;
2005-08-11 20:54:59 +02:00
print '</td></tr></table>' ;
print '</td><td colspan="3">' . $objsoc -> remise_client . " %</td> " ;
2005-09-07 23:27:05 +02:00
print '</tr>' ;
2005-08-11 20:54:59 +02:00
2005-09-07 23:27:05 +02:00
// Remise avoirs
print '<tr><td nowrap>' ;
print '<table width="100%" class="nobordernopadding">' ;
print '<tr><td nowrap>' ;
2005-08-11 20:54:59 +02:00
print $langs -> trans ( " CustomerAbsoluteDiscount " );
print '<td><td align="right">' ;
2005-09-07 23:27:05 +02:00
print '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $objsoc -> id . '">' . img_edit ( $langs -> trans ( " Modify " )) . '</a>' ;
2005-08-11 20:54:59 +02:00
print '</td></tr></table>' ;
2005-03-21 19:55:32 +01:00
print '</td>' ;
2005-08-11 20:54:59 +02:00
print '<td colspan="3">' ;
$sql = " SELECT rc.amount_ht, " . $db -> pdate ( " rc.datec " ) . " as dc " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe_remise_except as rc " ;
$sql .= " WHERE rc.fk_soc = " . $objsoc -> id ;
$sql .= " AND rc.fk_user = " . $user -> id . " AND fk_facture IS NULL " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$obj = $db -> fetch_object ( $resql );
if ( $obj -> amount_ht ) print $obj -> amount_ht . ' ' . $langs -> trans ( " Currency " . $conf -> monnaie );
else print $langs -> trans ( " None " );
}
2005-03-21 19:55:32 +01:00
print '</td>' ;
2005-08-11 20:54:59 +02:00
print '</tr>' ;
2005-03-21 19:55:32 +01:00
2006-02-03 17:42:39 +01:00
// multiprix
if ( $conf -> global -> PRODUIT_MULTIPRICES == 1 )
{
print '<tr><td nowrap>' ;
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>' ;
print $langs -> trans ( " PriceLevel " );
print '<td><td align="right">' ;
print '<a href="' . DOL_URL_ROOT . '/comm/multiprix.php?id=' . $objsoc -> id . '">' . img_edit ( $langs -> trans ( " Modify " )) . '</a>' ;
print '</td></tr></table>' ;
print '</td><td colspan="3">' . $objsoc -> price_level . " </td> " ;
print '</tr>' ;
}
2006-02-14 12:27:50 +01:00
if ( $conf -> facture -> enabled )
{
2006-02-14 15:49:02 +01:00
// conditions de r<> glement
2006-02-14 12:27:50 +01:00
$langs -> load ( 'bills' );
2006-02-14 15:49:02 +01:00
$html = new Form ( $db );
print '<tr><td nowrap>' ;
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>' ;
print $langs -> trans ( 'PaymentConditions' );
2006-02-15 17:58:42 +01:00
print '<td>' ;
if ( $_GET [ 'action' ] != 'editconditions' ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editconditions&socid=' . $objsoc -> id . '">' . img_edit ( $langs -> trans ( 'SetConditions' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
print '</td><td colspan="3">' ;
if ( $_GET [ 'action' ] == 'editconditions' )
{
2006-02-15 19:44:10 +01:00
$html -> form_conditions_reglement ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $objsoc -> id , $objsoc -> cond_reglement , 'cond_reglement_id' );
2006-02-15 17:58:42 +01:00
}
else
{
$html -> form_conditions_reglement ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $objsoc -> id , $objsoc -> cond_reglement , 'none' );
}
2006-02-14 15:49:02 +01:00
print " </td> " ;
print '</tr>' ;
// mode de r<> glement
2006-02-14 12:27:50 +01:00
print '<tr><td nowrap>' ;
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>' ;
print $langs -> trans ( 'PaymentMode' );
2006-02-15 17:58:42 +01:00
print '<td>' ;
if ( $_GET [ 'action' ] != 'editmode' ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editmode&socid=' . $objsoc -> id . '">' . img_edit ( $langs -> trans ( 'SetMode' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
print '</td><td colspan="3">' ;
if ( $_GET [ 'action' ] == 'editmode' )
{
$html -> form_modes_reglement ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $objsoc -> id , $objsoc -> mode_reglement , 'mode_reglement_id' );
}
else
{
$html -> form_modes_reglement ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $objsoc -> id , $objsoc -> mode_reglement , 'none' );
}
2006-02-14 12:27:50 +01:00
print " </td> " ;
print '</tr>' ;
2006-02-20 17:22:50 +01:00
// soumis <20> TVA ou pas
print '<tr><td nowrap>' ;
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>' ;
print $langs -> trans ( 'VATIsUsed' );
print '<td>' ;
if ( $_GET [ 'action' ] != 'editassujtva' ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editassujtva&socid=' . $objsoc -> id . '">' . img_edit ( $langs -> trans ( 'SetMode' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
print '</td><td colspan="3">' ;
if ( $_GET [ 'action' ] == 'editassujtva' )
{
2006-02-20 17:43:05 +01:00
$html -> form_assujetti_tva ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $objsoc -> id , $objsoc -> tva_assuj , 'assujtva_value' );
2006-02-20 17:22:50 +01:00
}
else
{
2006-02-20 17:43:05 +01:00
$html -> form_assujetti_tva ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $objsoc -> id , $objsoc -> tva_assuj , 'none' );
2006-02-20 17:22:50 +01:00
}
print " </td> " ;
print '</tr>' ;
2006-02-14 12:27:50 +01:00
}
2005-03-21 19:55:32 +01:00
print " </table> " ;
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-03-21 19:55:32 +01:00
2005-01-16 19:02:39 +01:00
// Nbre max d'<27> l<EFBFBD> ments des petites listes
$MAXLIST = 4 ;
2005-03-21 19:55:32 +01:00
2005-06-11 13:31:53 +02:00
2002-05-10 14:28:10 +02:00
/*
2005-01-16 19:02:39 +01:00
* Dernieres propales
2002-05-10 14:28:10 +02:00
*/
2005-01-16 19:02:39 +01:00
if ( $conf -> propal -> enabled )
{
2005-09-01 21:40:45 +02:00
$propal_static = new Propal ( $db );
2005-06-11 13:31:53 +02:00
print '<table class="noborder" width="100%">' ;
2005-03-21 19:55:32 +01:00
2005-09-01 21:40:45 +02:00
$sql = " SELECT s.nom, s.idp, p.rowid as propalid, p.fk_statut, p.price, p.ref, p.remise, " . $db -> pdate ( " p.datep " ) . " as dp, c.label as statut, c.id as statutid " ;
2005-01-16 19:02:39 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " propal as p, " . MAIN_DB_PREFIX . " c_propalst as c " ;
$sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id " ;
$sql .= " AND s.idp = " . $objsoc -> id ;
$sql .= " ORDER BY p.datep DESC " ;
2005-06-11 13:31:53 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
2005-01-16 19:02:39 +01:00
{
$var = true ;
2005-06-11 13:31:53 +02:00
$num = $db -> num_rows ( $resql );
2005-08-11 20:54:59 +02:00
if ( $num > 0 )
2005-01-16 19:02:39 +01:00
{
2005-04-29 02:16:53 +02:00
print '<tr class="liste_titre">' ;
2005-01-16 19:02:39 +01:00
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>' . $langs -> trans ( " LastPropals " ,( $num <= $MAXLIST ? " " : $MAXLIST )) . '</td><td align="right"><a href="' . DOL_URL_ROOT . '/comm/propal.php?socidp=' . $objsoc -> id . '">' . $langs -> trans ( " AllPropals " ) . ' (' . $num . ')</td></tr></table></td>' ;
print '</tr>' ;
$var =! $var ;
}
2005-08-14 04:47:45 +02:00
$i = 0 ;
2005-01-16 19:02:39 +01:00
while ( $i < $num && $i < $MAXLIST )
{
2005-06-11 13:31:53 +02:00
$objp = $db -> fetch_object ( $resql );
2005-01-16 19:02:39 +01:00
print " <tr $bc[$var] > " ;
2005-04-08 21:45:41 +02:00
print " <td nowrap><a href= \" propal.php?propalid= $objp->propalid\ " > " .img_object( $langs->trans ( " ShowPropal " ), " propal " ). " " . $objp->ref . " </ a > \n " ;
2005-08-14 04:47:45 +02:00
if ( ( $objp -> dp < time () - $conf -> propal -> cloture -> warning_delay ) && $objp -> statutid == 1 )
2005-01-16 19:02:39 +01:00
{
2005-08-14 04:47:45 +02:00
print " " . img_warning ();
2005-01-16 19:02:39 +01:00
}
2005-08-11 20:54:59 +02:00
print '</td><td align="right" width="80">' . dolibarr_print_date ( $objp -> dp ) . " </td> \n " ;
print '<td align="right" width="120">' . price ( $objp -> price ) . '</td>' ;
2005-09-01 21:40:45 +02:00
print '<td align="center" width="100">' . $propal_static -> labelstatut_short [ $objp -> fk_statut ] . '</td></tr>' ;
2005-01-16 19:02:39 +01:00
$var =! $var ;
$i ++ ;
}
2005-06-11 13:31:53 +02:00
$db -> free ( $resql );
2005-01-16 19:02:39 +01:00
}
else {
dolibarr_print_error ( $db );
}
print " </table> " ;
2004-05-20 13:22:08 +02:00
}
2005-03-21 19:55:32 +01:00
2003-11-19 16:12:24 +01:00
/*
2005-01-16 19:02:39 +01:00
* Dernieres commandes
2003-11-19 16:12:24 +01:00
*/
2005-01-16 19:02:39 +01:00
if ( $conf -> commande -> enabled )
{
2005-08-11 20:54:59 +02:00
$commande_static = new Commande ( $db );
2005-06-11 13:31:53 +02:00
print '<table class="noborder" width="100%">' ;
2005-03-21 19:55:32 +01:00
2005-08-11 20:54:59 +02:00
$sql = " SELECT s.nom, s.idp, c.rowid as cid, c.total_ht, c.ref, c.fk_statut, " . $db -> pdate ( " c.date_commande " ) . " as dc " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " commande as c " ;
$sql .= " WHERE c.fk_soc = s.idp " ;
2005-01-16 19:02:39 +01:00
$sql .= " AND s.idp = $objsoc->id " ;
2005-08-11 20:54:59 +02:00
$sql .= " ORDER BY c.date_commande DESC " ;
2005-03-21 19:55:32 +01:00
2005-06-11 13:31:53 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
2005-01-16 19:02:39 +01:00
{
$var = true ;
2005-06-11 13:31:53 +02:00
$num = $db -> num_rows ( $resql );
2005-01-16 19:02:39 +01:00
if ( $num > 0 )
{
2005-04-29 02:16:53 +02:00
print '<tr class="liste_titre">' ;
2005-09-07 23:27:05 +02:00
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>' . $langs -> trans ( " LastOrders " ,( $num <= $MAXLIST ? " " : $MAXLIST )) . '</td><td align="right"><a href="' . DOL_URL_ROOT . '/commande/liste.php?socidp=' . $objsoc -> id . '">' . $langs -> trans ( " AllOrders " ) . ' (' . $num . ')</a></td></tr></table></td>' ;
2005-01-16 19:02:39 +01:00
print '</tr>' ;
}
2005-08-14 04:47:45 +02:00
$i = 0 ;
2005-01-16 19:02:39 +01:00
while ( $i < $num && $i < $MAXLIST )
{
2005-06-11 13:31:53 +02:00
$objp = $db -> fetch_object ( $resql );
2005-01-16 19:02:39 +01:00
$var =! $var ;
print " <tr $bc[$var] > " ;
2005-08-11 20:54:59 +02:00
print '<td><a href="' . DOL_URL_ROOT . '/commande/fiche.php?id=' . $objp -> cid . '">' . img_object ( $langs -> trans ( " ShowOrder " ), " order " ) . ' ' . $objp -> ref . " </a> \n " ;
print '</td><td align="right" width="80">' . dolibarr_print_date ( $objp -> dc ) . " </td> \n " ;
2005-01-16 19:02:39 +01:00
print '<td align="right" width="120">' . price ( $objp -> total_ht ) . '</td>' ;
2005-08-11 20:54:59 +02:00
print '<td align="center" width="100">' . $commande_static -> status_label_short [ $objp -> fk_statut ] . '</td></tr>' ;
2005-01-16 19:02:39 +01:00
$i ++ ;
}
2005-06-11 13:31:53 +02:00
$db -> free ( $resql );
2005-01-16 19:02:39 +01:00
}
2005-06-12 03:21:38 +02:00
else {
dolibarr_print_error ( $db );
}
2005-01-16 19:02:39 +01:00
print " </table> " ;
2004-12-22 21:13:42 +01:00
}
2005-03-21 19:55:32 +01:00
2005-06-12 03:21:38 +02:00
/*
* Derniers contrats
*/
if ( $conf -> contrat -> enabled )
{
2005-07-07 02:28:49 +02:00
$contratstatic = new Contrat ( $db );
2005-06-12 03:21:38 +02:00
print '<table class="noborder" width="100%">' ;
2005-09-27 21:34:03 +02:00
$sql = " SELECT s.nom, s.idp, c.rowid as id, c.ref as ref, c.statut, " . $db -> pdate ( " c.datec " ) . " as dc " ;
2005-06-12 03:21:38 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " contrat as c " ;
$sql .= " WHERE c.fk_soc = s.idp " ;
$sql .= " AND s.idp = $objsoc->id " ;
$sql .= " ORDER BY c.datec DESC " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$var = true ;
$num = $db -> num_rows ( $resql );
if ( $num > 0 )
{
print '<tr class="liste_titre">' ;
2005-08-11 20:54:59 +02:00
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>' . $langs -> trans ( " LastContracts " ,( $num <= $MAXLIST ? " " : $MAXLIST )) . '</td>' ;
2005-07-07 02:28:49 +02:00
print '<td align="right"><a href="' . DOL_URL_ROOT . '/contrat/liste.php?socid=' . $objsoc -> id . '">' . $langs -> trans ( " AllContracts " ) . ' (' . $num . ')</td></tr></table></td>' ;
2005-06-12 03:21:38 +02:00
print '</tr>' ;
}
2005-08-14 04:47:45 +02:00
$i = 0 ;
2005-06-12 03:21:38 +02:00
while ( $i < $num && $i < $MAXLIST )
{
$objp = $db -> fetch_object ( $resql );
$var =! $var ;
print " <tr $bc[$var] > " ;
2005-09-27 21:34:03 +02:00
print '<td><a href="' . DOL_URL_ROOT . '/contrat/fiche.php?id=' . $objp -> id . '">' . img_object ( $langs -> trans ( " ShowContract " ), " contract " ) . ' '
. ( ! isset ( $objp -> ref ) ? $objp -> id : $objp -> ref ) . " </a></td> \n " ;
2005-08-11 20:54:59 +02:00
print '<td align="right" width="80">' . dolibarr_print_date ( $objp -> dc ) . " </td> \n " ;
2005-09-27 21:34:03 +02:00
print '<td width="20"> </td>' ;
2005-08-11 20:54:59 +02:00
print '<td align="center" width="100">' . $contratstatic -> LibStatut ( $objp -> statut ) . " </td> \n " ;
2005-06-12 03:21:38 +02:00
print '</tr>' ;
$i ++ ;
}
$db -> free ( $resql );
}
else {
dolibarr_print_error ( $db );
}
print " </table> " ;
}
2005-06-11 13:31:53 +02:00
/*
* Dernieres interventions
*/
if ( $conf -> fichinter -> enabled )
{
print '<table class="noborder" width="100%">' ;
$sql = " SELECT s.nom, s.idp, f.rowid as id, f.ref, " . $db -> pdate ( " f.datei " ) . " as di " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " fichinter as f " ;
$sql .= " WHERE f.fk_soc = s.idp " ;
$sql .= " AND s.idp = " . $objsoc -> id ;
$sql .= " ORDER BY f.datei DESC " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$var = true ;
$num = $db -> num_rows ( $resql );
if ( $num > 0 )
{
print '<tr class="liste_titre">' ;
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>' . $langs -> trans ( " LastInterventions " ,( $num <= $MAXLIST ? " " : $MAXLIST )) . '</td><td align="right"><a href="' . DOL_URL_ROOT . '/fichinter/index.php?socidp=' . $objsoc -> id . '">' . $langs -> trans ( " AllInterventions " ) . ' (' . $num . ')</td></tr></table></td>' ;
print '</tr>' ;
$var =! $var ;
}
2005-08-14 04:47:45 +02:00
$i = 0 ;
2005-06-11 13:31:53 +02:00
while ( $i < $num && $i < $MAXLIST )
{
$objp = $db -> fetch_object ( $resql );
print " <tr $bc[$var] > " ;
print '<td nowrap><a href="' . DOL_URL_ROOT . " /fichinter/fiche.php?id= " . $objp -> id . " \" > " . img_object ( $langs -> trans ( " ShowPropal " ), " propal " ) . " " . $objp -> ref . " </a> \n " ;
print " </td><td align= \" right \" > " . dolibarr_print_date ( $objp -> di ) . " </td> \n " ;
print '</tr>' ;
$var =! $var ;
$i ++ ;
}
$db -> free ( $resql );
}
else {
dolibarr_print_error ( $db );
}
print " </table> " ;
}
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-06-11 13:31:53 +02:00
print '<table class="noborder" width=100%>' ;
2005-03-21 19:55:32 +01: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 = $objsoc->id " ;
$sql .= " ORDER BY p.dateo DESC " ;
2005-03-21 19:55:32 +01:00
$result = $db -> query ( $sql );
if ( $result ) {
2005-01-16 19:02:39 +01:00
$var = true ;
$i = 0 ;
2005-03-21 19:55:32 +01:00
$num = $db -> num_rows ( $result );
2005-01-16 19:02:39 +01:00
if ( $num > 0 ) {
2005-04-29 02:16:53 +02:00
print '<tr class="liste_titre">' ;
2005-04-05 13:20:37 +02: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/liste.php?socid=' . $objsoc -> id . '">' . $langs -> trans ( " AllProjects " ) . ' (' . $num . ')</td></tr></table></td>' ;
2005-01-16 19:02:39 +01:00
print '</tr>' ;
}
while ( $i < $num && $i < $MAXLIST ) {
2005-03-21 19:55:32 +01:00
$obj = $db -> fetch_object ( $result );
2005-01-16 19:02:39 +01:00
$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-03-21 19:55:32 +01:00
2005-01-16 19:02:39 +01:00
print " <td align= \" right \" > " . $obj -> ref . " </td></tr> " ;
$i ++ ;
}
2005-03-21 19:55:32 +01:00
$db -> free ( $result );
2005-01-16 19:02:39 +01:00
}
else
{
dolibarr_print_error ( $db );
}
print " </table> " ;
2002-05-10 14:28:10 +02:00
}
2005-03-21 19:55:32 +01:00
2002-05-10 14:28:10 +02:00
print " </td></tr> " ;
2004-05-06 11:04:01 +02:00
print " </table></div> \n " ;
2005-03-21 19:55:32 +01:00
2003-08-29 20:29:56 +02:00
/*
2003-10-12 16:29:07 +02:00
* Barre d ' action
2003-08-29 20:29:56 +02:00
*
*/
2004-05-06 11:04:01 +02:00
print '<div class="tabsAction">' ;
2003-11-05 19:08:53 +01:00
2004-03-06 19:49:27 +01:00
if ( $conf -> propal -> enabled && $user -> rights -> propale -> creer )
2005-03-21 19:55:32 +01:00
{
$langs -> load ( " propal " );
2005-07-08 00:47:02 +02:00
print '<a class="butAction" href="addpropal.php?socidp=' . $objsoc -> id . '&action=create">' . $langs -> trans ( " AddProp " ) . '</a>' ;
2005-03-21 19:55:32 +01:00
}
2004-03-04 18:39:49 +01:00
2004-03-06 19:49:27 +01:00
if ( $conf -> commande -> enabled && $user -> rights -> commande -> creer )
2005-03-21 19:55:32 +01:00
{
$langs -> load ( " orders " );
2005-07-08 00:47:02 +02:00
print '<a class="butAction" href="' . DOL_URL_ROOT . '/commande/fiche.php?socidp=' . $objsoc -> id . '&action=create">' . $langs -> trans ( " AddOrder " ) . '</a>' ;
2005-03-21 19:55:32 +01:00
}
2004-03-04 18:39:49 +01:00
2005-06-12 03:21:38 +02:00
if ( $user -> rights -> contrat -> creer )
2005-03-21 19:55:32 +01:00
{
2005-06-12 03:21:38 +02:00
$langs -> load ( " contracts " );
2005-07-08 00:47:02 +02:00
print '<a class="butAction" href="' . DOL_URL_ROOT . '/contrat/fiche.php?socid=' . $objsoc -> id . '&action=create">' . $langs -> trans ( " AddContract " ) . '</a>' ;
2005-03-21 19:55:32 +01:00
}
2004-01-31 18:00:32 +01:00
2004-03-06 19:49:27 +01:00
if ( $conf -> fichinter -> enabled )
2005-03-21 19:55:32 +01:00
{
2005-04-02 01:18:25 +02:00
$langs -> load ( " fichinter " );
2005-07-08 00:47:02 +02:00
print '<a class="butAction" href="../fichinter/fiche.php?socidp=' . $objsoc -> id . '&action=create">' . $langs -> trans ( " AddIntervention " ) . '</a>' ;
2005-03-21 19:55:32 +01:00
}
2005-07-08 00:47:02 +02:00
print '<a class="butAction" href="action/fiche.php?action=create&socid=' . $objsoc -> id . '">' . $langs -> trans ( " AddAction " ) . '</a>' ;
2005-02-17 12:33:58 +01:00
2005-07-09 01:02:58 +02:00
print '<a class="butAction" href="' . DOL_URL_ROOT . '/contact/fiche.php?socid=' . $objsoc -> id . '&action=create">' . $langs -> trans ( " AddContact " ) . '</a>' ;
2004-03-04 18:39:49 +01:00
print '</div>' ;
2004-05-20 13:22:08 +02:00
print '<br>' ;
2005-03-21 19:55:32 +01:00
2005-01-14 15:31:53 +01:00
if ( $action == 'changevalue' )
2005-03-21 19:55:32 +01:00
{
print " <hr noshade> " ;
print " <form action= \" index.php?socid= $objsoc->id\ " method = \ " post \" > " ;
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= \" " . $langs -> trans ( " Valid " ) . " \" > " ;
print " </form> \n " ;
}
2005-01-14 15:31:53 +01:00
else
2005-03-21 19:55:32 +01:00
{
/*
*
* Liste des contacts
*
*/
if ( $conf -> clicktodial -> enabled )
{
$user -> fetch_clicktodial (); // lecture des infos de clicktodial
}
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre"><td>' . $langs -> trans ( " Firstname " ) . ' ' . $langs -> trans ( " Lastname " ) . '</td>' ;
print '<td>' . $langs -> trans ( " Poste " ) . '</td><td colspan="2">' . $langs -> trans ( " Tel " ) . '</td>' ;
print '<td>' . $langs -> trans ( " Fax " ) . '</td><td>' . $langs -> trans ( " EMail " ) . '</td>' ;
print " <td> </td> " ;
print '<td> </td>' ;
print " </tr> " ;
$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 = $objsoc->id " ;
$sql .= " ORDER by p.datec " ;
$result = $db -> query ( $sql );
$i = 0 ;
$num = $db -> num_rows ( $result );
2005-07-03 23:58:20 +02:00
$var = true ;
2005-03-21 19:55:32 +01:00
while ( $i < $num )
{
$obj = $db -> fetch_object ( $result );
$var = ! $var ;
print " <tr $bc[$var] > " ;
print '<td>' ;
print '<a href="' . DOL_URL_ROOT . '/contact/fiche.php?id=' . $obj -> idp . '">' ;
print img_object ( $langs -> trans ( " Show " ), " contact " );
print ' ' . $obj -> firstname . ' ' . $obj -> name . '</a> ' ;
if ( trim ( $obj -> note ))
{
print '<br>' . nl2br ( trim ( $obj -> note ));
}
print '</td>' ;
print '<td>' . $obj -> poste . ' </td>' ;
print '<td>' ;
2005-08-11 20:54:59 +02:00
// Lien click to dial
2005-03-21 19:55:32 +01:00
if ( strlen ( $obj -> phone ) && $user -> clicktodial_enabled == 1 )
{
print '<a href="' . DOL_URL_ROOT . '/comm/action/fiche.php?action=create&actionid=1&contactid=' . $obj -> idp . '&socid=' . $objsoc -> id . '&call=' . $obj -> phone . '">' ;
print img_phone_out ( " Appel <20> mis " ) ;
}
print '</td><td>' ;
print '<a href="action/fiche.php?action=create&actionid=1&contactid=' . $obj -> idp . '&socid=' . $objsoc -> id . '">' . dolibarr_print_phone ( $obj -> phone ) . '</a> </td>' ;
print '<td><a href="action/fiche.php?action=create&actionid=2&contactid=' . $obj -> idp . '&socid=' . $objsoc -> id . '">' . dolibarr_print_phone ( $obj -> fax ) . '</a> </td>' ;
print '<td><a href="action/fiche.php?action=create&actionid=4&contactid=' . $obj -> idp . '&socid=' . $objsoc -> id . '">' . $obj -> email . '</a> </td>' ;
print '<td align="center">' ;
print " <a href= \" ../contact/fiche.php?action=edit&id= $obj->idp\ " > " ;
print img_edit ();
print '</a></td>' ;
print '<td align="center"><a href="action/fiche.php?action=create&actionid=5&contactid=' . $obj -> idp . '&socid=' . $objsoc -> id . '">' ;
print img_object ( $langs -> trans ( " Rendez-Vous " ), " action " );
print '</a></td>' ;
print " </tr> \n " ;
$i ++ ;
}
print " </table> " ;
print " <br> " ;
/*
* Listes des actions a faire
*
*/
print '<table width="100%" class="noborder">' ;
2005-11-14 22:13:08 +01:00
print '<tr class="liste_titre"><td colspan="9"><a href="action/index.php?socid=' . $objsoc -> id . '">' . $langs -> trans ( " ActionsToDo " ) . '</a></td><td align="right"> </td></tr>' ;
2005-03-21 19:55:32 +01:00
2005-11-14 22:13:08 +01:00
$sql = " SELECT a.id, a.label, " . $db -> pdate ( " a.datea " ) . " as da, c.code as acode, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid " ;
2005-03-21 19:55:32 +01:00
$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 = $objsoc->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 " ;
$result = $db -> query ( $sql );
2005-06-11 13:31:53 +02:00
if ( $result )
{
$i = 0 ;
$num = $db -> num_rows ( $result );
2005-07-07 23:55:37 +02:00
$var = true ;
2005-06-11 13:31:53 +02:00
while ( $i < $num )
{
2005-03-21 19:55:32 +01:00
$var = ! $var ;
$obj = $db -> fetch_object ( $result );
print " <tr $bc[$var] > " ;
if ( $oldyear == strftime ( " %Y " , $obj -> da ) )
{
2005-11-14 22:13:08 +01:00
print '<td width="30" align="center">|</td>' ;
2005-03-21 19:55:32 +01:00
}
else
{
2005-07-07 23:55:37 +02:00
print '<td width="30" align="center">' . strftime ( " %Y " , $obj -> da ) . " </td> \n " ;
2005-03-21 19:55:32 +01:00
$oldyear = strftime ( " %Y " , $obj -> da );
}
if ( $oldmonth == strftime ( " %Y%b " , $obj -> da ) )
{
2005-11-14 22:13:08 +01:00
print '<td width="30" align="center">|</td>' ;
2005-03-21 19:55:32 +01:00
}
else
{
2005-07-07 23:55:37 +02:00
print '<td width="30" align="center">' . strftime ( " %b " , $obj -> da ) . " </td> \n " ;
2005-03-21 19:55:32 +01:00
$oldmonth = strftime ( " %Y%b " , $obj -> da );
}
2005-07-07 23:55:37 +02:00
print '<td width="20">' . strftime ( " %d " , $obj -> da ) . " </td> \n " ;
print '<td width="30">' . strftime ( " %H:%M " , $obj -> da ) . " </td> \n " ;
2005-11-14 22:13:08 +01:00
if ( date ( " U " , $obj -> da ) < time ())
{
print " <td> " . img_warning ( " Late " ) . " </td> " ;
}
2005-03-21 19:55:32 +01:00
2005-09-18 20:22:38 +02:00
// Status/Percent
print '<td width="30"> </td>' ;
2005-03-21 19:55:32 +01:00
if ( $obj -> propalrowid )
{
2005-07-08 00:47:02 +02:00
print '<td><a href="propal.php?propalid=' . $obj -> propalrowid . '">' . img_object ( $langs -> trans ( " ShowAction " ), " task " );
2005-04-09 16:32:26 +02:00
$transcode = $langs -> trans ( " Action " . $obj -> acode );
$libelle = ( $transcode != " Action " . $obj -> acode ? $transcode : $obj -> libelle );
print $libelle ;
print '</a></td>' ;
2005-03-21 19:55:32 +01:00
}
else
{
2005-07-08 00:47:02 +02:00
print '<td><a href="action/fiche.php?id=' . $obj -> id . '">' . img_object ( $langs -> trans ( " ShowAction " ), " task " );
2005-04-09 16:32:26 +02:00
$transcode = $langs -> trans ( " Action " . $obj -> acode );
$libelle = ( $transcode != " Action " . $obj -> acode ? $transcode : $obj -> libelle );
print $libelle ;
print '</a></td>' ;
2005-03-21 19:55:32 +01:00
}
2005-11-14 22:13:08 +01:00
print " <td> $obj->label </td> " ;
2005-06-11 13:31:53 +02:00
// Contact pour cette action
2005-03-21 19:55:32 +01:00
if ( $obj -> fk_contact ) {
$contact = new Contact ( $db );
$contact -> fetch ( $obj -> fk_contact );
2005-06-11 13:31:53 +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>' ;
2005-03-21 19:55:32 +01:00
} else {
2005-06-11 13:31:53 +02:00
print '<td> </td>' ;
2005-03-21 19:55:32 +01:00
}
2005-09-18 20:22:38 +02:00
print '<td width="50"><a href="' . DOL_URL_ROOT . '/user/fiche.php?id=' . $obj -> fk_user_author . '">' . img_object ( $langs -> trans ( " ShowUser " ), " user " ) . ' ' . $obj -> code . '</a></td>' ;
2005-03-21 19:55:32 +01:00
print " </tr> \n " ;
$i ++ ;
}
print " </table> " ;
$db -> free ( $result );
} else {
dolibarr_print_error ( $db );
}
2005-06-11 13:31:53 +02:00
print " </table><br> " ;
2005-03-21 19:55:32 +01:00
2005-07-07 02:28:49 +02:00
2005-03-21 19:55:32 +01:00
/*
* Listes des actions effectuees
*/
print '<table class="noborder" width="100%">' ;
2005-11-14 22:13:08 +01:00
print '<tr class="liste_titre"><td colspan="10"><a href="action/index.php?socid=' . $objsoc -> id . '">' . $langs -> trans ( " ActionsDone " ) . '</a></td></tr>' ;
2005-03-21 19:55:32 +01:00
2005-11-14 22:13:08 +01:00
$sql = " SELECT a.id, a.label, " . $db -> pdate ( " a.datea " ) . " as da, c.code as acode, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid " ;
2005-03-21 19:55:32 +01:00
$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 = $objsoc->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 " ;
$result = $db -> query ( $sql );
if ( $result )
{
$i = 0 ;
$num = $db -> num_rows ( $result );
$oldyear = '' ;
$oldmonth = '' ;
2005-06-11 13:31:53 +02:00
$var = true ;
2005-03-21 19:55:32 +01:00
while ( $i < $num )
{
$var = ! $var ;
$obj = $db -> fetch_object ( $result );
print " <tr $bc[$var] > " ;
2005-06-11 13:31:53 +02:00
// Champ date
2005-03-21 19:55:32 +01:00
if ( $oldyear == strftime ( " %Y " , $obj -> da ) )
{
2005-06-11 13:31:53 +02:00
print '<td width="30" align="center">|</td>' ;
2005-03-21 19:55:32 +01:00
}
else
{
2005-06-11 13:31:53 +02:00
print '<td width="30" align="center">' . strftime ( " %Y " , $obj -> da ) . " </td> \n " ;
2005-03-21 19:55:32 +01:00
$oldyear = strftime ( " %Y " , $obj -> da );
}
if ( $oldmonth == strftime ( " %Y%b " , $obj -> da ) )
{
2005-06-11 13:31:53 +02:00
print '<td width="30" align="center">|</td>' ;
2005-03-21 19:55:32 +01:00
}
else
{
2005-06-11 13:31:53 +02:00
print '<td width="30" align="center">' . strftime ( " %b " , $obj -> da ) . " </td> \n " ;
2005-03-21 19:55:32 +01:00
$oldmonth = strftime ( " %Y%b " , $obj -> da );
}
2005-06-11 13:31:53 +02:00
print '<td width="20">' . strftime ( " %d " , $obj -> da ) . " </td> \n " ;
print '<td width="30">' . strftime ( " %H:%M " , $obj -> da ) . " </td> \n " ;
2005-11-14 22:13:08 +01:00
if ( date ( " U " , $obj -> da ) < time ())
{
print " <td> </td> " ;
}
2005-03-21 19:55:32 +01:00
2005-09-18 20:22:38 +02:00
// Statut/Percent
print '<td width="30"> </td>' ;
2005-03-21 19:55:32 +01:00
if ( $obj -> propalrowid )
{
2005-07-08 00:47:02 +02:00
print '<td><a href="' . DOL_URL_ROOT . '/comm/propal.php?propalid=' . $obj -> propalrowid . '">' . img_object ( $langs -> trans ( " ShowAction " ), " task " );
2005-04-09 16:32:26 +02:00
$transcode = $langs -> trans ( " Action " . $obj -> acode );
$libelle = ( $transcode != " Action " . $obj -> acode ? $transcode : $obj -> libelle );
print $libelle ;
print '</a></td>' ;
2005-03-21 19:55:32 +01:00
}
else
{
2005-07-08 00:47:02 +02:00
print '<td><a href="' . DOL_URL_ROOT . '/comm/action/fiche.php?id=' . $obj -> id . '">' . img_object ( $langs -> trans ( " ShowAction " ), " task " );
2005-04-09 16:32:26 +02:00
$transcode = $langs -> trans ( " Action " . $obj -> acode );
$libelle = ( $transcode != " Action " . $obj -> acode ? $transcode : $obj -> libelle );
print $libelle ;
print '</a></td>' ;
2005-03-21 19:55:32 +01:00
}
2005-06-11 13:31:53 +02:00
2005-11-14 22:13:08 +01:00
print " <td> $obj->label </td> " ;
2005-06-11 13:31:53 +02:00
// Contact pour cette action
2005-03-21 19:55:32 +01:00
if ( $obj -> fk_contact )
{
$contact = new Contact ( $db );
$contact -> fetch ( $obj -> fk_contact );
2005-09-18 20:22:38 +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>' ;
2005-03-21 19:55:32 +01:00
}
else
{
2005-06-11 13:31:53 +02:00
print '<td> </td>' ;
2005-03-21 19:55:32 +01:00
}
2005-06-11 13:31:53 +02:00
2005-09-18 20:22:38 +02:00
print '<td width="50"><a href="' . DOL_URL_ROOT . '/user/fiche.php?id=' . $obj -> fk_user_author . '">' . img_object ( $langs -> trans ( " ShowUser " ), " user " ) . ' ' . $obj -> code . '</a></td>' ;
2005-03-21 19:55:32 +01:00
print " </tr> \n " ;
$i ++ ;
}
$db -> free ( $result );
}
else
{
dolibarr_print_error ( $db );
}
2005-06-11 13:31:53 +02:00
print " </table> " ;
2005-03-21 19:55:32 +01:00
2002-05-10 14:28:10 +02:00
}
2005-03-21 19:55:32 +01:00
} else {
2004-10-30 14:15:59 +02:00
dolibarr_print_error ( $db );
2005-03-21 19:55:32 +01:00
}
2004-05-29 17:58:36 +02:00
2002-05-10 14:28:10 +02:00
$db -> close ();
2005-06-11 13:31:53 +02:00
llxFooter ( '$Date$ - $Revision$' );
2002-05-10 14:28:10 +02:00
?>