2004-10-19 22:19:58 +02:00
< ? php
2004-01-30 11:32:21 +01:00
/* Copyright ( C ) 2001 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2004-01-28 00:15:17 +01:00
* Copyright ( C ) 2004 Laurent Destailleur < eldy @ users . sourceforge . net >
2002-04-29 20:01:16 +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 .
*
2002-12-12 17:11:54 +01:00
* $Id $
* $Source $
*
2002-04-29 20:01:16 +02:00
*/
2004-10-30 14:15:59 +02:00
/*!
\file htdocs / comm / index . php
\ingroup commercial
\brief Page acceuil de la zone commercial
\version $Revision $
*/
2003-09-11 22:18:51 +02:00
require ( " ./pre.inc.php " );
2004-10-30 14:15:59 +02:00
if ( $conf -> contrat -> enabled ) {
require_once ( " ../contrat/contrat.class.php " );
}
$langs -> load ( " commercial " );
$langs -> load ( " orders " );
2002-04-30 12:44:42 +02:00
2003-08-10 21:12:08 +02:00
$user -> getrights ( 'propale' );
2004-02-21 02:46:26 +01:00
$user -> getrights ( 'fichinter' );
$user -> getrights ( 'commande' );
$user -> getrights ( 'projet' );
2002-05-09 16:57:48 +02:00
2003-10-14 13:02:31 +02:00
if ( $user -> societe_id > 0 )
{
$socidp = $user -> societe_id ;
}
2003-08-10 21:12:08 +02:00
llxHeader ();
2002-05-09 16:57:48 +02:00
2002-12-12 17:11:54 +01:00
function valeur ( $sql )
{
2002-05-10 14:28:10 +02:00
global $db ;
2002-12-12 17:11:54 +01:00
if ( $db -> query ( $sql ) )
{
if ( $db -> num_rows () )
{
$valeur = $db -> result ( 0 , 0 );
}
$db -> free ();
2002-05-10 14:28:10 +02:00
}
return $valeur ;
}
/*
*
*/
2002-05-09 16:57:48 +02:00
2004-07-13 18:47:11 +02:00
if ( $_GET [ " action " ] == 'add_bookmark' )
2003-05-25 18:23:14 +02:00
{
2004-07-13 18:47:11 +02:00
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " bookmark WHERE fk_soc = " . $_GET [ " socidp " ] . " AND fk_user= " . $user -> id ;
2003-06-28 21:23:30 +02:00
if ( ! $db -> query ( $sql ) )
{
2004-11-28 18:59:52 +01:00
dolibarr_print_error ( $db );
2003-06-28 21:23:30 +02:00
}
2004-07-13 18:47:11 +02:00
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " bookmark (fk_soc, dateb, fk_user) VALUES ( " . $_GET [ " socidp " ] . " , now(), " . $user -> id . " ); " ;
2003-06-28 21:23:30 +02:00
if ( ! $db -> query ( $sql ) )
{
2004-11-28 18:59:52 +01:00
dolibarr_print_error ( $db );
2003-06-28 21:23:30 +02:00
}
2002-05-10 14:28:10 +02:00
}
2002-05-09 16:57:48 +02:00
2004-07-13 18:47:11 +02:00
if ( $_GET [ " action " ] == 'del_bookmark' )
2003-05-25 18:23:14 +02:00
{
2004-07-13 18:47:11 +02:00
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " bookmark WHERE rowid= " . $_GET [ " bid " ];
2002-05-10 14:28:10 +02:00
$result = $db -> query ( $sql );
}
2002-05-09 16:57:48 +02:00
2002-05-10 14:28:10 +02:00
print_titre ( " Espace commercial " );
2002-05-09 16:57:48 +02:00
2004-10-30 14:15:59 +02:00
print '<table border="0" width="100%">' ;
2002-05-09 16:57:48 +02:00
2002-05-10 14:28:10 +02:00
print '<tr><td valign="top" width="30%">' ;
2002-05-09 16:57:48 +02:00
2004-05-08 20:44:22 +02:00
/*
* Recherche Propal
*/
2004-01-24 21:51:31 +01:00
if ( $conf -> propal -> enabled ) {
print '<form method="post" action="propal.php">' ;
2004-10-30 14:15:59 +02:00
print '<table class="noborder" width="100%">' ;
2004-01-24 21:51:31 +01:00
print '<tr class="liste_titre"><td colspan="2">Rechercher une proposition</td></tr>' ;
print " <tr $bc[1] ><td> " ;
2004-08-02 04:41:23 +02:00
print $langs -> trans ( " Ref " ) . ' : <input type="text" name="sf_ref"> <input type="submit" value="' . $langs -> trans ( " Search " ) . '" class="flat"></td></tr>' ;
2004-01-24 21:51:31 +01:00
print " </table></form><br> \n " ;
2005-01-18 09:31:46 +01:00
$sql = " SELECT p.rowid, p.ref, p.price, s.nom " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " propal as p, " . MAIN_DB_PREFIX . " societe as s " ;
$sql .= " WHERE p.fk_statut = 0 and p.fk_soc = s.idp " ;
2004-01-24 21:51:31 +01:00
if ( $db -> query ( $sql ) )
2003-09-03 15:50:00 +02:00
{
2005-01-18 09:31:46 +01:00
$total = 0 ;
2004-01-24 21:51:31 +01:00
$num = $db -> num_rows ();
$i = 0 ;
if ( $num > 0 )
{
2004-10-30 14:15:59 +02:00
print '<table class="noborder" width="100%">' ;
2004-05-08 20:44:22 +02:00
print " <tr class= \" liste_titre \" > " ;
2005-01-18 09:31:46 +01:00
print " <td colspan= \" 3 \" >Propositions commerciales brouillons</td></tr> " ;
2004-01-24 21:51:31 +01:00
while ( $i < $num )
{
2004-10-23 18:55:07 +02:00
$obj = $db -> fetch_object ();
2004-01-24 21:51:31 +01:00
$var =! $var ;
2005-01-18 09:31:46 +01:00
print " <tr $bc[$var] ><td><a href= \" propal.php?propalid= " . $obj -> rowid . " \" > " . $obj -> ref . " </a></td><td> " . $obj -> nom . " </td><td align= \" right \" > " . price ( $obj -> price ) . " </td></tr> " ;
2004-01-24 21:51:31 +01:00
$i ++ ;
2005-01-18 09:31:46 +01:00
$total += $obj -> price ;
}
if ( $total > 0 ) {
print " <tr $bc[$var] ><td colspan= \" 2 \" align= \" right \" ><i>Total</i></td><td align= \" right \" ><i> " . price ( $total ) . " </i></td></tr> " ;
2004-01-24 21:51:31 +01:00
}
print " </table><br> " ;
}
2003-09-03 15:50:00 +02:00
}
2002-04-29 20:01:16 +02:00
}
2003-11-09 16:37:14 +01:00
/*
* Commandes <EFBFBD> valider
*/
2004-05-18 09:59:20 +02:00
if ( $conf -> commande -> enabled )
{
2004-07-31 13:36:01 +02:00
$langs -> load ( " orders " );
2004-05-08 20:44:22 +02:00
$sql = " SELECT c.rowid, c.ref, s.nom, s.idp FROM " . MAIN_DB_PREFIX . " commande as c, " . MAIN_DB_PREFIX . " societe as s " ;
$sql .= " WHERE c.fk_soc = s.idp AND c.fk_statut = 0 " ;
if ( $socidp )
2003-09-03 15:50:00 +02:00
{
2004-05-08 20:44:22 +02:00
$sql .= " AND c.fk_soc = $socidp " ;
2003-09-03 15:50:00 +02:00
}
2004-05-08 20:44:22 +02:00
if ( $db -> query ( $sql ) )
{
$num = $db -> num_rows ();
if ( $num )
{
2004-10-30 14:15:59 +02:00
print '<table class="noborder" width="100%">' ;
2004-05-18 09:59:20 +02:00
print '<tr class="liste_titre">' ;
2004-07-31 13:36:01 +02:00
print '<td colspan="2">' . $langs -> trans ( " OrdersToValid " ) . '</td></tr>' ;
2004-05-08 20:44:22 +02:00
$i = 0 ;
$var = False ;
while ( $i < $num )
2004-05-18 09:59:20 +02:00
{
2004-10-23 18:55:07 +02:00
$obj = $db -> fetch_object ();
2004-05-18 09:59:20 +02:00
print " <tr $bc[$var] ><td width= \" 20% \" ><a href= \" ../commande/fiche.php?id= $obj->rowid\ " > $obj -> ref </ a ></ td > " ;
print '<td><a href="fiche.php?socid=' . $obj -> idp . '">' . $obj -> nom . '</a></td></tr>' ;
$i ++ ;
$var =! $var ;
}
print " </table><br> " ;
2004-05-08 20:44:22 +02:00
}
}
2002-04-29 20:01:16 +02:00
}
/*
2004-05-08 20:44:22 +02:00
* Bookmark
2002-04-29 20:01:16 +02:00
*
*/
2002-05-10 14:28:10 +02:00
$sql = " SELECT s.idp, s.nom,b.rowid as bid " ;
2004-01-30 11:32:21 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " bookmark as b " ;
2002-05-10 14:28:10 +02:00
$sql .= " WHERE b.fk_soc = s.idp AND b.fk_user = " . $user -> id ;
2004-06-26 19:43:07 +02:00
if ( $socidp )
{
$sql .= " AND s.idp = $socidp " ;
}
2002-05-10 14:28:10 +02:00
$sql .= " ORDER BY lower(s.nom) ASC " ;
2003-05-25 18:23:14 +02:00
if ( $db -> query ( $sql ) )
{
2002-05-10 14:28:10 +02:00
$num = $db -> num_rows ();
2004-07-13 18:47:11 +02:00
if ( $num )
2003-05-25 18:23:14 +02:00
{
2004-07-13 18:47:11 +02:00
$i = 0 ;
2004-10-30 14:15:59 +02:00
print '<table class="noborder" width="100%">' ;
2004-07-13 18:47:11 +02:00
print " <tr class= \" liste_titre \" > " ;
2004-10-30 14:15:59 +02:00
print " <td colspan= \" 2 \" > " . $langs -> trans ( " Bookmark " ) . " </td> " ;
2004-07-13 18:47:11 +02:00
print " </tr> \n " ;
while ( $i < $num )
{
2004-10-23 18:55:07 +02:00
$obj = $db -> fetch_object ();
2004-07-13 18:47:11 +02:00
$var = ! $var ;
print " <tr $bc[$var] > " ;
print '<td><a href="fiche.php?socid=' . $obj -> idp . '">' . $obj -> nom . '</a></td>' ;
print '<td align="right"><a href="index.php?action=del_bookmark&bid=' . $obj -> bid . '">' ;
print '<img src="' . DOL_URL_ROOT . '/theme/' . $conf -> theme . '/img/editdelete.png" border="0"></a></td>' ;
print '</tr>' ;
$i ++ ;
}
print '</table>' ;
2003-05-25 18:23:14 +02:00
}
2002-04-29 20:01:16 +02:00
}
2004-05-08 20:44:22 +02:00
2004-06-26 19:43:07 +02:00
print '</td><td valign="top" width="70%">' ;
2004-10-30 14:15:59 +02:00
2004-06-26 19:43:07 +02:00
/*
* Derni<EFBFBD> res actions commerciales effectu<EFBFBD> es
*
*/
$sql = " SELECT a.id, " . $db -> pdate ( " a.datea " ) . " as da, c.libelle, a.fk_user_author, s.nom as sname, s.idp " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " actioncomm as a, " . MAIN_DB_PREFIX . " c_actioncomm as c, " . MAIN_DB_PREFIX . " societe as s " ;
$sql .= " WHERE c.id=a.fk_action AND a.percent >= 100 AND s.idp = a.fk_soc " ;
if ( $socidp )
{
$sql .= " AND s.idp = $socidp " ;
}
$sql .= " ORDER BY a.datea DESC limit 5 " ;
if ( $db -> query ( $sql ) )
{
$num = $db -> num_rows ();
2004-10-30 14:15:59 +02:00
print '<table class="noborder" width="100%">' ;
2004-06-26 19:43:07 +02:00
print '<tr class="liste_titre"><td colspan="4">Derni<6E> res actions effectu<74> es</td></tr>' ;
$var = true ;
$i = 0 ;
while ( $i < $num )
{
2004-10-23 18:55:07 +02:00
$obj = $db -> fetch_object ();
2004-06-26 19:43:07 +02:00
$var =! $var ;
print " <tr $bc[$var] > " ;
2004-06-30 16:57:08 +02:00
print " <td width= \" 40% \" ><a href= \" action/fiche.php?id= $obj->id\ " > " .img_file(). " </ a >& nbsp ; " ;
2004-06-26 19:43:07 +02:00
print " <a href= \" action/fiche.php?id= $obj->id\ " > $obj -> libelle $obj -> label </ a ></ td > " ;
print " <td> " . strftime ( " %d %b %Y " , $obj -> da ) . " </td> " ;
print '<td><a href="fiche.php?socid=' . $obj -> idp . '">' . $obj -> sname . '</a></td>' ;
$i ++ ;
}
// TODO Ajouter rappel pour "il y a des contrats <20> mettre en service"
// TODO Ajouter rappel pour "il y a des contrats qui arrivent <20> expiration"
print " </table><br> " ;
$db -> free ();
}
else
{
2004-10-30 14:15:59 +02:00
dolibarr_print_error ( $db );
2004-06-26 19:43:07 +02:00
}
2004-10-30 14:15:59 +02:00
2002-04-29 20:01:16 +02:00
/*
2002-12-12 17:11:54 +01:00
* Actions commerciales a faire
2002-04-29 20:01:16 +02:00
*
2002-05-10 14:28:10 +02:00
*/
2002-04-29 20:01:16 +02:00
2003-08-03 15:06:29 +02:00
$sql = " SELECT a.id, " . $db -> pdate ( " a.datea " ) . " as da, c.libelle, a.fk_user_author, s.nom as sname, s.idp " ;
2004-01-30 11:32:21 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " actioncomm as a, " . MAIN_DB_PREFIX . " c_actioncomm as c, " . MAIN_DB_PREFIX . " societe as s " ;
2004-06-26 19:43:07 +02:00
$sql .= " WHERE c.id=a.fk_action AND a.percent < 100 AND s.idp = a.fk_soc " ;
if ( $socidp )
{
$sql .= " AND s.idp = $socidp " ;
}
2004-06-30 16:57:08 +02:00
$sql .= " ORDER BY a.datea ASC " ;
2002-04-29 20:01:16 +02:00
2002-12-12 17:11:54 +01:00
if ( $db -> query ( $sql ) )
{
2003-11-09 16:37:14 +01:00
$num = $db -> num_rows ();
2004-06-30 16:57:08 +02:00
if ( $num > 0 )
{
2004-10-30 14:15:59 +02:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre"><td colspan="4">' . $langs -> trans ( " ActionsToDo " ) . '</td></tr>' ;
2004-06-30 16:57:08 +02:00
$var = true ;
$i = 0 ;
while ( $i < $num )
2003-11-09 16:37:14 +01:00
{
2004-10-23 18:55:07 +02:00
$obj = $db -> fetch_object ();
2003-11-09 16:37:14 +01:00
$var =! $var ;
2004-02-13 17:02:12 +01:00
print " <tr $bc[$var] > " ;
2004-06-30 16:57:08 +02:00
print " <td width= \" 40% \" ><a href= \" action/fiche.php?id= $obj->id\ " > " .img_file(). " </ a >& nbsp ; " ;
2004-02-13 17:02:12 +01:00
print " <a href= \" action/fiche.php?id= $obj->id\ " > $obj -> libelle $obj -> label </ a ></ td > " ;
2004-06-30 16:57:08 +02:00
print '<td>' . strftime ( " %d %b %Y " , $obj -> da );
if ( date ( " U " , $obj -> da ) < time ())
{
print img_warning ();
}
print " </td> " ;
2003-11-09 16:37:14 +01:00
print '<td><a href="fiche.php?socid=' . $obj -> idp . '">' . $obj -> sname . '</a></td>' ;
$i ++ ;
}
2004-06-30 16:57:08 +02:00
// TODO Ajouter rappel pour "il y a des contrats <20> mettre en service"
// TODO Ajouter rappel pour "il y a des contrats qui arrivent <20> expiration"
print " </table><br> " ;
}
2002-05-10 14:28:10 +02:00
$db -> free ();
2002-12-12 17:11:54 +01:00
}
else
{
2004-11-28 18:59:52 +01:00
dolibarr_print_error ( $db );
2002-05-10 14:28:10 +02:00
}
2002-04-29 20:01:16 +02:00
2004-05-08 20:44:22 +02:00
/*
* Derniers contrat
*
*/
2004-11-26 13:37:14 +01:00
if ( $conf -> contrat -> enabled && 0 ) // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT
2004-07-13 09:20:09 +02:00
{
2004-10-30 14:15:59 +02:00
$langs -> load ( " contracts " );
2004-07-13 09:20:09 +02:00
2004-11-28 18:59:52 +01:00
$sql = " SELECT s.nom, s.idp, c.statut, c.rowid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo " ;
2004-07-13 09:20:09 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " contrat as c, " . MAIN_DB_PREFIX . " product as p WHERE c.fk_soc = s.idp and c.fk_product = p.rowid " ;
if ( $socidp )
2004-05-08 20:44:22 +02:00
{
$sql .= " AND s.idp = $socidp " ;
}
2004-07-13 09:20:09 +02:00
$sql .= " ORDER BY c.tms DESC " ;
$sql .= $db -> plimit ( 5 , 0 );
if ( $db -> query ( $sql ) )
2004-05-08 20:44:22 +02:00
{
$num = $db -> num_rows ();
2004-07-13 09:20:09 +02:00
if ( $num > 0 )
{
2004-10-30 14:15:59 +02:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre"><td colspan="3">' . $langs -> trans ( " LastContracts " , 5 ) . '</td></tr>' ;
2004-07-13 09:20:09 +02:00
$i = 0 ;
2004-10-30 14:15:59 +02:00
$contrat = new Contrat ( $db );
2004-07-13 09:20:09 +02:00
$var = false ;
while ( $i < $num )
{
2004-10-23 18:55:07 +02:00
$obj = $db -> fetch_object ();
2004-07-13 09:20:09 +02:00
print " <tr $bc[$var] ><td><a href= \" ../contrat/fiche.php?id= " . $obj -> rowid . " \" > " . img_file () . " </a> " ;
print " <a href= \" ../contrat/fiche.php?id= " . $obj -> rowid . " \" > " . $obj -> ref . " </a></td> " ;
print " <td><a href= \" fiche.php?socid= $obj->idp\ " > $obj -> nom </ a ></ td > \n " ;
2004-10-30 14:15:59 +02:00
print " <td align= \" right \" > " . $contrat -> LibStatut ( $obj -> enservice ) . " </td></tr> \n " ;
2004-07-13 09:20:09 +02:00
$var =! $var ;
$i ++ ;
}
print " </table><br> " ;
}
2004-05-08 20:44:22 +02:00
}
2004-07-13 09:20:09 +02:00
else
{
2004-10-30 14:15:59 +02:00
dolibarr_print_error ( $db );
2004-07-13 09:20:09 +02:00
}
2003-11-09 16:37:14 +01:00
}
2004-05-08 20:44:22 +02:00
/*
* Derni<EFBFBD> res propales ouvertes
*
*/
if ( $conf -> propal -> enabled ) {
2003-11-09 16:37:14 +01:00
2004-05-08 20:44:22 +02:00
$sql = " SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref, " . $db -> pdate ( " p.datep " ) . " as dp, c.label as statut, c.id as statutid " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " propal as p, " . MAIN_DB_PREFIX . " c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND p.fk_statut = 1 " ;
if ( $socidp )
{
$sql .= " AND s.idp = $socidp " ;
}
$sql .= " ORDER BY p.rowid DESC " ;
2005-01-18 09:31:46 +01:00
// $sql .= $db->plimit(5, 0);
2004-05-08 20:44:22 +02:00
if ( $db -> query ( $sql ) )
2003-11-09 16:37:14 +01:00
{
2005-01-18 09:31:46 +01:00
$total = 0 ;
2004-05-08 20:44:22 +02:00
$num = $db -> num_rows ();
$i = 0 ;
2004-05-18 09:24:25 +02:00
if ( $num > 0 )
{
2004-10-30 14:15:59 +02:00
print '<table class="noborder" width="100%">' ;
2005-01-18 09:31:46 +01:00
print '<tr class="liste_titre"><td colspan="4">Propositions commerciales ouvertes et valid<69> es</td></tr>' ;
2004-05-18 09:24:25 +02:00
$var = false ;
while ( $i < $num )
{
2004-10-23 18:55:07 +02:00
$obj = $db -> fetch_object ();
2004-05-18 09:36:58 +02:00
print " <tr $bc[$var] ><td width= \" 15% \" ><a href= \" propal.php?propalid= " . $obj -> propalid . " \" > " . img_file () . " </a> " ;
2004-07-21 12:04:51 +02:00
print " <a href= \" propal.php?propalid= " . $obj -> propalid . " \" > " . $obj -> ref . " </a></td> " ;
2004-05-18 09:24:25 +02:00
print " <td width= \" 30% \" ><a href= \" fiche.php?socid= $obj->idp\ " > $obj -> nom </ a ></ td > \n " ;
print " <td align= \" right \" > " ;
2004-05-18 09:36:58 +02:00
print strftime ( " %e %b %Y " , $obj -> dp ) . " </td> \n " ;
2004-05-18 09:24:25 +02:00
print " <td align= \" right \" > " . price ( $obj -> price ) . " </td></tr> \n " ;
$var =! $var ;
$i ++ ;
2005-01-18 09:31:46 +01:00
$total += $obj -> price ;
2004-05-18 09:24:25 +02:00
}
2005-01-18 09:31:46 +01:00
if ( $total > 0 ) {
print " <tr $bc[$var] ><td colspan= \" 3 \" align= \" right \" ><i>Total</i></td><td align= \" right \" ><i> " . price ( $total ) . " </i></td></tr> " ;
}
2004-05-18 09:24:25 +02:00
print " </table><br> " ;
}
2003-11-09 16:37:14 +01:00
}
2004-05-08 20:44:22 +02:00
2003-11-09 16:37:14 +01:00
}
2003-10-14 11:40:54 +02:00
/*
2004-05-08 20:44:22 +02:00
* Derni<EFBFBD> res propales ferm<EFBFBD> es
2003-10-14 11:40:54 +02:00
*
*/
2004-01-24 21:51:31 +01:00
if ( $conf -> propal -> enabled ) {
2003-10-14 11:40:54 +02:00
2004-01-24 21:51:31 +01:00
$sql = " SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref, " . $db -> pdate ( " p.datep " ) . " as dp, c.label as statut, c.id as statutid " ;
2004-01-30 11:32:21 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " propal as p, " . MAIN_DB_PREFIX . " c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND p.fk_statut > 1 " ;
2004-01-24 21:51:31 +01:00
if ( $socidp )
{
$sql .= " AND s.idp = $socidp " ;
}
$sql .= " ORDER BY p.rowid DESC " ;
$sql .= $db -> plimit ( 5 , 0 );
if ( $db -> query ( $sql ) )
2003-10-14 11:40:54 +02:00
{
2004-01-24 21:51:31 +01:00
$num = $db -> num_rows ();
$i = 0 ;
2004-10-30 14:15:59 +02:00
print '<table class="noborder" width="100%">' ;
2004-06-26 19:43:07 +02:00
print '<tr class="liste_titre"><td colspan="6">Les 5 derni<6E> res propositions commerciales ferm<72> es</td></tr>' ;
2004-02-12 23:39:57 +01:00
$var = False ;
2004-01-24 21:51:31 +01:00
while ( $i < $num )
2004-02-12 23:35:18 +01:00
{
2004-10-23 18:55:07 +02:00
$objp = $db -> fetch_object ();
2004-02-12 23:35:18 +01:00
print " <tr $bc[$var] > " ;
2004-05-18 09:36:58 +02:00
print '<td width="15%">' ;
2004-02-12 23:35:18 +01:00
print '<a href="propal.php?propalid=' . $objp -> propalid . '">' . img_file () . '</a>' ;
print ' <a href="propal.php?propalid=' . $objp -> propalid . '">' . $objp -> ref . '</a></td>' ;
print " <td width= \" 30% \" ><a href= \" fiche.php?socid= $objp->idp\ " > $objp -> nom </ a ></ TD > \n " ;
$now = time ();
$lim = 3600 * 24 * 15 ;
if ( ( $now - $objp -> dp ) > $lim && $objp -> statutid == 1 )
{
print " <td><b> > 15 jours</b></td> " ;
}
else
{
print " <td> </td> " ;
}
print " <td align= \" right \" > " ;
2004-05-18 09:36:58 +02:00
print strftime ( " %e %b %Y " , $objp -> dp ) . " </td> \n " ;
2004-10-30 14:15:59 +02:00
print " <td align= \" right \" > " . price ( $objp -> price ) . " </td> \n " ;
print " <td align= \" center \" > $objp->statut </td> \n " ;
2004-02-12 23:35:18 +01:00
print " </tr> \n " ;
$i ++ ;
$var =! $var ;
}
print " </table> " ;
$db -> free ();
}
2004-01-24 21:51:31 +01:00
}
2002-04-29 20:01:16 +02:00
2003-11-09 16:37:14 +01:00
print '</td></tr>' ;
2002-05-10 14:28:10 +02:00
print '</table>' ;
2002-04-29 20:01:16 +02:00
$db -> close ();
2002-05-10 14:28:10 +02:00
2002-04-30 12:44:42 +02:00
llxFooter ( " <em>Dernière modification $Date $ révision $Revision $ </em> " );
2002-04-29 20:01:16 +02:00
?>