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 >
2006-02-25 01:38:31 +01:00
* Copyright ( C ) 2004 - 2006 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-25 01:38:31 +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 " );
2006-04-09 00:47:51 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/company.lib.php " );
2005-08-21 21:11:54 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /actioncomm.class.php " );
2006-04-09 00:47:51 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /contact.class.php " );
if ( $conf -> propal -> enabled ) require_once ( DOL_DOCUMENT_ROOT . " /propal.class.php " );
if ( $conf -> commande -> enabled ) require_once ( DOL_DOCUMENT_ROOT . " /commande/commande.class.php " );
if ( $conf -> contrat -> enabled ) 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 " );
2006-02-25 01:38:31 +01:00
$langs -> load ( " bills " );
2004-11-12 01:50:14 +01:00
$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
2006-03-11 03:04:07 +01:00
$user -> getrights ( " commercial " );
2006-04-09 00:47:51 +02:00
if ( ! $user -> rights -> societe -> lire ) accessforbidden ();
2006-03-10 10:17:41 +01:00
2006-03-11 03:04:07 +01:00
$socidp = isset ( $_GET [ " socid " ]) ? $_GET [ " socid " ] : '' ;
2006-03-10 10:17:41 +01:00
if ( $socidp == '' ) accessforbidden ();
2006-03-11 03:04:07 +01:00
// Protection quand utilisateur externe
2006-02-25 14:06:35 +01:00
if ( $user -> societe_id > 0 )
{
2006-03-08 19:06:29 +01:00
$socidp = $user -> societe_id ;
2006-02-25 14:06:35 +01:00
}
2006-03-10 09:20:41 +01:00
// Protection restriction commercial
2006-03-10 10:08:05 +01:00
if ( ! $user -> rights -> commercial -> client -> voir && $socidp && ! $user -> societe_id > 0 )
2006-03-10 09:20:41 +01:00
{
2006-08-01 00:34:42 +02:00
$sql = " SELECT sc.fk_soc, s.client " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe_commerciaux as sc, " . MAIN_DB_PREFIX . " societe as s " ;
$sql .= " WHERE sc.fk_soc = " . $socidp . " AND sc.fk_user = " . $user -> id . " AND s.client = 1 " ;
if ( $db -> query ( $sql ) )
{
if ( $db -> num_rows () == 0 ) accessforbidden ();
}
2006-03-10 09:20:41 +01:00
}
2006-03-10 10:08:05 +01:00
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
2006-08-01 01:20:41 +02:00
if ( $_GET [ " action " ] == 'attribute_prefix' && $user -> rights -> societe -> creer )
2005-02-17 12:33:58 +01:00
{
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
2006-08-01 00:34:42 +02:00
if ( $_POST [ " action " ] == 'setconditions' && $user -> rights -> societe -> creer )
2006-02-14 15:49:02 +01:00
{
$societe = new Societe ( $db , $_GET [ " socid " ]);
2006-02-15 19:44:10 +01:00
$societe -> cond_reglement = $_POST [ 'cond_reglement_id' ];
2006-02-25 14:06:35 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " societe SET cond_reglement=' " . $_POST [ 'cond_reglement_id' ];
$sql .= " ' WHERE idp=' " . $_GET [ " socid " ] . " ' " ;
2006-02-14 15:49:02 +01:00
$result = $db -> query ( $sql );
2006-02-25 14:06:35 +01:00
if ( ! $result ) dolibarr_print_error ( $result );
2006-02-14 15:49:02 +01:00
}
2006-02-14 12:27:50 +01:00
// mode de r<> glement
2006-08-01 00:34:42 +02:00
if ( $_POST [ " action " ] == 'setmode' && $user -> rights -> societe -> creer )
2006-02-14 12:27:50 +01:00
{
$societe = new Societe ( $db , $_GET [ " socid " ]);
$societe -> mode_reglement = $_POST [ 'mode_reglement_id' ];
2006-02-25 14:06:35 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " societe SET mode_reglement=' " . $_POST [ 'mode_reglement_id' ];
$sql .= " ' WHERE idp=' " . $_GET [ " socid " ] . " ' " ;
2006-02-14 12:27:50 +01:00
$result = $db -> query ( $sql );
2006-02-25 14:06:35 +01:00
if ( ! $result ) dolibarr_print_error ( $result );
2006-02-14 12:27:50 +01:00
}
2006-02-20 17:43:05 +01:00
// assuj<75> tissement <20> la TVA
2006-08-01 00:34:42 +02:00
if ( $_POST [ " action " ] == 'setassujtva' && $user -> rights -> societe -> creer )
2006-02-20 17:43:05 +01:00
{
$societe = new Societe ( $db , $_GET [ " socid " ]);
$societe -> tva_assuj = $_POST [ 'assujtva_value' ];
2006-03-08 19:06:29 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " societe SET tva_assuj=' " . $_POST [ 'assujtva_value' ] . " ' WHERE idp=' " . $socidp . " ' " ;
2006-02-20 17:43:05 +01:00
$result = $db -> query ( $sql );
2006-02-25 14:06:35 +01:00
if ( ! $result ) dolibarr_print_error ( $result );
2006-02-20 17:43:05 +01:00
}
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) " ;
2006-03-08 19:06:29 +01:00
$sql .= " VALUES (' $dateaction ', $socidp , $stcommid ,' " . $user -> login . " ') " ;
2005-03-21 19:55:32 +01:00
$result = @ $db -> query ( $sql );
if ( $result )
{
2006-03-08 19:06:29 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " societe SET fk_stcomm= $stcommid WHERE idp= " . $socidp ;
2005-03-21 19:55:32 +01:00
$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
{
2006-03-08 19:06:29 +01:00
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " actioncomm (datea, fk_action, fk_soc, fk_user_author) VALUES (' $dateaction ', $actioncommid , $socidp ,' " . $user -> id . " ') " ;
2005-03-21 19:55:32 +01:00
$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' ) {
2006-03-08 19:06:29 +01:00
$sql = " SELECT s.idp " ;
if ( ! $user -> rights -> commercial -> client -> voir && ! $socidp ) $sql .= " , sc.fk_soc, sc.fk_user " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s " ;
if ( ! $user -> rights -> commercial -> client -> voir && ! $socidp ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2005-03-21 19:55:32 +01:00
$sql .= " WHERE lower(s.nom) like '% " . strtolower ( $socname ) . " %' " ;
2006-03-08 19:06:29 +01:00
if ( ! $user -> rights -> commercial -> client -> voir && ! $socidp ) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2005-03-21 19:55:32 +01:00
}
if ( $db -> query ( $sql ) ) {
if ( $db -> num_rows () == 1 ) {
$obj = $db -> fetch_object ();
2006-03-08 19:06:29 +01:00
$socidp = $obj -> idp ;
2005-03-21 19:55:32 +01:00
}
$db -> free ();
2002-05-10 14:28:10 +02:00
}
}
2005-03-21 19:55:32 +01:00
2006-02-25 14:06:35 +01:00
llxHeader ( '' , $langs -> trans ( 'CustomerCard' ));
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
*********************************************************************************/
2006-03-08 19:06:29 +01:00
if ( $socidp > 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 );
2006-03-08 19:06:29 +01:00
$objsoc -> id = $socidp ;
$objsoc -> fetch ( $socidp , $to );
2005-03-21 19:55:32 +01:00
$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
*/
2006-04-09 00:47:51 +02:00
$head = societe_prepare_head ( $objsoc );
2005-03-21 19:55:32 +01:00
2006-04-09 00:47:51 +02:00
dolibarr_fiche_head ( $head , 'customer' , $objsoc -> nom );
2005-03-21 19:55:32 +01:00
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
}
2005-07-12 00:57:19 +02:00
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-07-12 00:57:19 +02:00
2006-02-25 14:06:35 +01:00
// Assujeti <20> TVA ou pas
2006-02-25 01:38:31 +01:00
print '<tr>' ;
print '<td nowrap="nowrap">' . $langs -> trans ( 'VATIsUsed' ) . '</td><td colspan="3">' ;
print yn ( $objsoc -> tva_assuj );
print '</td>' ;
print '</tr>' ;
2006-02-25 14:06:35 +01:00
// Conditions de r<> glement par d<> faut
$langs -> load ( 'bills' );
$html = new Form ( $db );
print '<tr><td nowrap>' ;
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>' ;
print $langs -> trans ( 'PaymentConditions' );
print '<td>' ;
2006-08-01 00:34:42 +02:00
if (( $_GET [ 'action' ] != 'editconditions' ) && $user -> rights -> societe -> creer ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editconditions&socid=' . $objsoc -> id . '">' . img_edit ( $langs -> trans ( 'SetConditions' ), 1 ) . '</a></td>' ;
2006-02-25 14:06:35 +01:00
print '</tr></table>' ;
print '</td><td colspan="3">' ;
if ( $_GET [ 'action' ] == 'editconditions' )
{
$html -> form_conditions_reglement ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $objsoc -> id , $objsoc -> cond_reglement , 'cond_reglement_id' , - 1 , 1 );
}
else
{
$html -> form_conditions_reglement ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $objsoc -> id , $objsoc -> cond_reglement , 'none' );
}
print " </td> " ;
print '</tr>' ;
// Mode de r<> glement
print '<tr><td nowrap>' ;
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>' ;
print $langs -> trans ( 'PaymentMode' );
print '<td>' ;
2006-08-01 00:34:42 +02:00
if (( $_GET [ 'action' ] != 'editmode' ) && $user -> rights -> societe -> creer ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editmode&socid=' . $objsoc -> id . '">' . img_edit ( $langs -> trans ( 'SetMode' ), 1 ) . '</a></td>' ;
2006-02-25 14:06:35 +01:00
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' );
}
print " </td> " ;
print '</tr>' ;
2006-05-21 14:20:36 +02:00
// R<> ductions relative (Remises-Ristournes-Rabbais)
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>' ;
2006-04-04 02:42:21 +02:00
print $langs -> trans ( " CustomerRelativeDiscountShort " );
2005-08-11 20:54:59 +02:00
print '<td><td align="right">' ;
2006-08-01 00:34:42 +02:00
if ( $user -> rights -> societe -> creer )
2006-07-30 19:50:09 +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>' ;
2006-04-04 02:42:21 +02:00
print '</td><td colspan="3">' . ( $objsoc -> remise_client ? $objsoc -> remise_client . '%' : $langs -> trans ( " DiscountNone " )) . '</td>' ;
2005-09-07 23:27:05 +02:00
print '</tr>' ;
2005-08-11 20:54:59 +02:00
2006-05-21 14:20:36 +02:00
// R<> ductions absolues (Remises-Ristournes-Rabbais)
2005-09-07 23:27:05 +02:00
print '<tr><td nowrap>' ;
print '<table width="100%" class="nobordernopadding">' ;
print '<tr><td nowrap>' ;
2006-04-04 02:42:21 +02:00
print $langs -> trans ( " CustomerAbsoluteDiscountShort " );
2005-08-11 20:54:59 +02:00
print '<td><td align="right">' ;
2006-08-01 00:34:42 +02:00
if ( $user -> rights -> societe -> creer )
2006-07-30 19:50:09 +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">' ;
2006-04-02 20:57:50 +02:00
$amount_discount = $objsoc -> getcurrentDiscount ();
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:42:21 +02:00
else print $langs -> trans ( " DiscountNone " );
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">' ;
2006-08-01 00:34:42 +02:00
if ( $user -> rights -> societe -> creer )
{
print '<a href="' . DOL_URL_ROOT . '/comm/multiprix.php?id=' . $objsoc -> id . '">' . img_edit ( $langs -> trans ( " Modify " )) . '</a>' ;
}
2006-02-03 17:42:39 +01:00
print '</td></tr></table>' ;
print '</td><td colspan="3">' . $objsoc -> price_level . " </td> " ;
print '</tr>' ;
}
2006-04-21 15:00:03 +02:00
2006-05-10 20:30:50 +02:00
// Adresse de livraison
if ( $conf -> expedition -> enabled )
2006-04-22 01:24:06 +02:00
{
2006-04-21 15:00:03 +02:00
print '<tr><td nowrap>' ;
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>' ;
2006-05-09 14:33:16 +02:00
print $langs -> trans ( " DeliveriesAddress " );
2006-04-21 15:00:03 +02:00
print '<td><td align="right">' ;
2006-08-01 00:34:42 +02:00
if ( $user -> rights -> societe -> creer )
{
print '<a href="' . DOL_URL_ROOT . '/comm/adresse_livraison.php?socid=' . $objsoc -> id . '">' . img_edit ( $langs -> trans ( " Modify " )) . '</a>' ;
}
2006-04-21 15:00:03 +02:00
print '</td></tr></table>' ;
2006-04-21 15:48:18 +02:00
print '</td><td colspan="3">' ;
2006-04-22 01:24:06 +02:00
$sql = " SELECT count(rowid) as nb " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe_adresse_livraison " ;
$sql .= " WHERE fk_societe = " . $objsoc -> id ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
$objal = $db -> fetch_object ( $resql );
print $objal -> nb ? ( $objal -> nb ) : $langs -> trans ( " NoOtherDeliveryAddress " );
}
else
{
dolibarr_print_error ( $db );
}
2006-04-21 15:48:18 +02:00
print '</td>' ;
2006-04-21 15:00:03 +02:00
print '</tr>' ;
2006-04-22 01:24:06 +02:00
}
2006-02-25 14:06:35 +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
2006-03-18 23:46:29 +01:00
// 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 . '/comm/recap-client.php?socid=' . $objsoc -> id . '">' . $langs -> trans ( " ShowCustomerPreview " ) . '</a></td></tr></table></td>' ;
2006-03-18 23:46:29 +01:00
print '</tr>' ;
print '</table>' ;
print '<br>' ;
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">' ;
2006-04-29 02:35:00 +02: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 . ')</a></td></tr></table></td>' ;
2005-01-16 19:02:39 +01:00
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>' ;
2006-03-25 13:49:55 +01:00
print '<td align="right" nowrap="nowrap">' . $propal_static -> LibStatut ( $objp -> fk_statut , 5 ) . '</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
2006-05-20 14:16:18 +02:00
$sql = " SELECT s.nom, s.idp, " ;
$sql .= " c.rowid as cid, c.total_ht, c.ref, c.fk_statut, c.facture, " ;
$sql .= " " . $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 " ;
$sql .= " AND s.idp = $objsoc->id " ;
$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] > " ;
2006-05-20 11:19:20 +02:00
print '<td nowrap="nowrap"><a href="' . DOL_URL_ROOT . '/commande/fiche.php?id=' . $objp -> cid . '">' . img_object ( $langs -> trans ( " ShowOrder " ), " order " ) . ' ' . $objp -> ref . " </a> \n " ;
2005-08-11 20:54:59 +02:00
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>' ;
2006-05-20 14:16:18 +02:00
print '<td align="right" width="100">' . $commande_static -> LibStatut ( $objp -> fk_statut , $objp -> facture , 5 ) . '</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>' ;
2006-04-29 02:35:00 +02:00
print '<td align="right"><a href="' . DOL_URL_ROOT . '/contrat/liste.php?socid=' . $objsoc -> id . '">' . $langs -> trans ( " AllContracts " ) . ' (' . $num . ')</a></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>' ;
2006-03-25 13:49:55 +01:00
print '<td align="right" nowrap="nowrap">' . $contratstatic -> LibStatut ( $objp -> statut , 5 ) . " </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
2006-07-30 19:50:09 +02:00
if ( $conf -> fichinter -> enabled && $user -> rights -> ficheinter -> creer )
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
2006-03-18 23:46:29 +01:00
if ( $user -> rights -> societe -> contact -> creer )
{
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
}
2006-04-29 02:35:00 +02:00
print_titre ( $langs -> trans ( " ContactsForCompany " ));
2005-03-21 19:55:32 +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>' ;
2005-03-21 19:55:32 +01:00
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 " ;
2006-04-29 02:35:00 +02:00
$sql .= " WHERE p.fk_soc = " . $objsoc -> id ;
2005-03-21 19:55:32 +01:00
$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> " ;
2006-06-22 02:05:19 +02:00
$actionstatic = new ActionComm ( $db );
2005-03-21 19:55:32 +01:00
/*
* Listes des actions a faire
*
*/
2006-04-29 02:35:00 +02:00
print_titre ( $langs -> trans ( " ActionsOnCompany " ));
2005-03-21 19:55:32 +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=' . $objsoc -> id . '&status=todo">' . $langs -> trans ( " ActionsToDoShort " ) . '</a></td><td align="right"> </td>' ;
print '</tr>' ;
2005-03-21 19:55:32 +01:00
2006-06-22 02:05:19 +02:00
$sql = " SELECT a.id, a.label, " . $db -> pdate ( " a.datep " ) . " as dp, 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 = " . $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.datep DESC, a.id DESC " ;
2005-03-21 19:55:32 +01:00
$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
2006-04-29 02:35:00 +02:00
if ( $num )
2005-06-11 13:31:53 +02:00
{
2006-04-29 02:35:00 +02:00
while ( $i < $num )
{
$var = ! $var ;
$obj = $db -> fetch_object ( $result );
print " <tr $bc[$var] > " ;
if ( $oldyear == strftime ( " %Y " , $obj -> dp ) )
{
print '<td width="30" align="center">|</td>' ;
}
else
{
print '<td width="30" align="center">' . strftime ( " %Y " , $obj -> dp ) . " </td> \n " ;
$oldyear = strftime ( " %Y " , $obj -> dp );
}
if ( $oldmonth == strftime ( " %Y%b " , $obj -> dp ) )
{
print '<td width="30" align="center">|</td>' ;
}
else
{
print '<td width="30" align="center">' . strftime ( " %b " , $obj -> dp ) . " </td> \n " ;
$oldmonth = strftime ( " %Y%b " , $obj -> dp );
}
print '<td width="20">' . strftime ( " %d " , $obj -> dp ) . " </td> \n " ;
print '<td width="30" nowrap="nowrap">' . strftime ( " %H:%M " , $obj -> dp ) . '</td>' ;
// Picto warning
print '<td width="16">' ;
if ( date ( " U " , $obj -> dp ) < time ()) print ' ' . img_warning ( " Late " );
else print ' ' ;
print '</td>' ;
// Status/Percent
print '<td width="30"> </td>' ;
if ( $obj -> propalrowid )
{
print '<td><a href="propal.php?propalid=' . $obj -> propalrowid . '">' . img_object ( $langs -> trans ( " ShowAction " ), " task " );
$transcode = $langs -> trans ( " Action " . $obj -> acode );
$libelle = ( $transcode != " Action " . $obj -> acode ? $transcode : $obj -> libelle );
print $libelle ;
print '</a></td>' ;
}
else
{
print '<td><a href="action/fiche.php?id=' . $obj -> id . '">' . img_object ( $langs -> trans ( " ShowAction " ), " task " );
$transcode = $langs -> trans ( " Action " . $obj -> acode );
$libelle = ( $transcode != " Action " . $obj -> acode ? $transcode : $obj -> libelle );
print $libelle ;
print '</a></td>' ;
}
print '<td colspan="2">' . $obj -> label . '</td>' ;
// Contact pour cette action
if ( $obj -> fk_contact ) {
$contact = new Contact ( $db );
$contact -> fetch ( $obj -> fk_contact );
print '<td><a href="' . DOL_URL_ROOT . '/contact/fiche.php?id=' . $contact -> id . '">' . img_object ( $langs -> trans ( " ShowContact " ), " contact " ) . ' ' . $contact -> fullname . '</a></td>' ;
} else {
print '<td> </td>' ;
}
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>' ;
2006-06-22 02:05:19 +02:00
// Statut
print '<td nowrap="nowrap" width="20">' . $actionstatic -> LibStatut ( $obj -> percent , 3 ) . '</td>' ;
2006-04-29 02:35:00 +02:00
print " </tr> \n " ;
$i ++ ;
}
}
else
{
// Aucun action <20> faire
}
2005-03-21 19:55:32 +01:00
$db -> free ( $result );
} else {
dolibarr_print_error ( $db );
}
2006-04-29 02:35:00 +02:00
print " </table> " ;
print " <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%">' ;
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=' . $objsoc -> id . '&status=done">' . $langs -> trans ( " ActionsDoneShort " ) . '</a></td>' ;
print '</tr>' ;
2005-03-21 19:55:32 +01: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 = " . $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 " ;
2005-03-21 19:55:32 +01:00
$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 " ;
2006-04-02 03:53:51 +02:00
// Picto
print '<td width="16"> </td>' ;
2005-03-21 19:55:32 +01:00
2006-03-11 02:49:55 +01:00
// Espace
2005-09-18 20:22:38 +02:00
print '<td width="30"> </td>' ;
2005-03-21 19:55:32 +01:00
2006-03-11 02:49:55 +01:00
// Action
print '<td>' ;
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 02:49:55 +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 02:49:55 +01:00
else print ' ' ;
print '</td>' ;
2005-06-11 13:31:53 +02:00
2006-04-02 03:53:51 +02:00
// Libell<6C>
2005-11-14 22:13:08 +01:00
print " <td> $obj->label </td> " ;
2006-03-11 02:49:55 +01:00
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
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>' ;
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
?>