2004-10-19 22:19:58 +02:00
< ? php
2005-08-25 17:07:01 +02:00
/* Copyright ( C ) 2001 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2008-03-02 22:30:39 +01:00
* Copyright ( C ) 2004 - 2008 Laurent Destailleur < eldy @ users . sourceforge . net >
2008-06-18 22:01:01 +02:00
* Copyright ( C ) 2005 - 2008 Regis Houssin < regis @ dolibarr . fr >
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 .
*/
2004-10-30 14:15:59 +02:00
2005-01-29 01:44:52 +01:00
/**
2005-09-01 00:14:12 +02:00
\file htdocs / comm / index . php
\ingroup commercial
2008-02-26 19:34:53 +01:00
\brief Page acceuil de la zone commercial cliente
\version $Id $
2004-10-30 14:15:59 +02:00
*/
2003-09-11 22:18:51 +02:00
require ( " ./pre.inc.php " );
2008-01-20 14:53:02 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /html.formfile.class.php " );
2006-10-24 01:07:46 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /client.class.php " );
2006-04-08 00:27:25 +02:00
if ( $conf -> contrat -> enabled ) require_once ( DOL_DOCUMENT_ROOT . " /contrat/contrat.class.php " );
if ( $conf -> propal -> enabled ) require_once ( DOL_DOCUMENT_ROOT . " /propal.class.php " );
2006-06-23 23:50:30 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /actioncomm.class.php " );
2008-02-26 19:34:53 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/agenda.lib.php " );
2005-08-25 17:07:01 +02:00
2008-05-17 02:58:10 +02:00
if ( ! $user -> rights -> societe -> lire )
2005-08-25 17:08:50 +02:00
accessforbidden ();
2004-10-30 14:15:59 +02:00
$langs -> load ( " commercial " );
$langs -> load ( " orders " );
2002-04-30 12:44:42 +02:00
2005-09-27 00:47:07 +02:00
// S<> curit<69> acc<63> s client
2006-09-13 20:56:30 +02:00
$socid = '' ;
if ( $_GET [ " socid " ]) { $socid = $_GET [ " socid " ]; }
2005-09-27 00:47:07 +02:00
if ( $user -> societe_id > 0 )
2003-10-14 13:02:31 +02:00
{
2005-09-27 00:47:07 +02:00
$action = '' ;
2006-09-13 20:56:30 +02:00
$socid = $user -> societe_id ;
2003-10-14 13:02:31 +02:00
}
2005-07-03 04:37:16 +02:00
$max = 5 ;
2005-06-21 21:49:42 +02:00
2006-04-08 00:27:25 +02:00
2006-05-20 12:49:07 +02:00
if ( $conf -> propal -> enabled ) $propalstatic = new Propal ( $db );
2006-04-08 00:27:25 +02:00
2002-05-09 16:57:48 +02:00
2002-05-10 14:28:10 +02:00
/*
2005-01-29 15:58:53 +01:00
* Actions
2002-05-10 14:28:10 +02:00
*/
2002-05-09 16:57:48 +02:00
2005-08-11 20:54:59 +02:00
if ( isset ( $_GET [ " action " ]) && $_GET [ " action " ] == 'add_bookmark' )
2003-05-25 18:23:14 +02:00
{
2006-09-13 20:56:30 +02:00
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " bookmark WHERE fk_soc = " . $_GET [ " socid " ] . " 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
}
2008-08-27 20:53:27 +02:00
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " bookmark (fk_soc, dateb, fk_user) VALUES ( " . $_GET [ " socid " ] . " , " . $db -> idate ( mktime ()) . " , " . $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
2005-08-11 20:54:59 +02:00
if ( isset ( $_GET [ " action " ]) && $_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
2005-01-29 15:58:53 +01:00
/*
2008-08-09 00:12:27 +02:00
* View
2005-01-29 15:58:53 +01:00
*/
2007-07-13 19:10:38 +02:00
$html = new Form ( $db );
2008-01-20 14:53:02 +01:00
$formfile = new FormFile ( $db );
2007-07-13 19:10:38 +02:00
2006-04-08 00:27:25 +02:00
llxHeader ();
2008-02-26 19:34:53 +01:00
print_fiche_titre ( $langs -> trans ( " CustomerArea " ));
2002-05-09 16:57:48 +02:00
2005-08-11 20:54:59 +02:00
print '<table border="0" width="100%" class="notopnoleftnoright">' ;
2002-05-09 16:57:48 +02:00
2005-10-24 10:51:17 +02:00
print '<tr><td valign="top" width="30%" class="notopnoleft">' ;
2004-05-08 20:44:22 +02:00
2006-04-08 00:27:25 +02:00
// Recherche Propal
2005-08-25 17:07:01 +02:00
if ( $conf -> propal -> enabled && $user -> rights -> propale -> lire )
{
$var = false ;
print '<form method="post" action="' . DOL_URL_ROOT . '/comm/propal.php">' ;
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre"><td colspan="3">' . $langs -> trans ( " SearchAProposal " ) . '</td></tr>' ;
print '<tr ' . $bc [ $var ] . '>' ;
print '<td nowrap>' . $langs -> trans ( " Ref " ) . ':</td><td><input type="text" class="flat" name="sf_ref" size="18"></td>' ;
print '<td rowspan="2"><input type="submit" value="' . $langs -> trans ( " Search " ) . '" class="button"></td></tr>' ;
print '<tr ' . $bc [ $var ] . '><td nowrap>' . $langs -> trans ( " Other " ) . ':</td><td><input type="text" class="flat" name="sall" size="18"></td>' ;
print '</tr>' ;
print " </table></form> \n " ;
print " <br /> \n " ;
2005-01-29 01:44:52 +01:00
}
/*
* Recherche Contrat
*/
2008-05-17 02:58:10 +02:00
if ( $conf -> contrat -> enabled && $user -> rights -> contrat -> lire )
2005-08-25 00:27:23 +02:00
{
2005-08-25 17:07:01 +02:00
$var = false ;
print '<form method="post" action="' . DOL_URL_ROOT . '/contrat/liste.php">' ;
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre"><td colspan="3">' . $langs -> trans ( " SearchAContract " ) . '</td></tr>' ;
print '<tr ' . $bc [ $var ] . '>' ;
print '<td nowrap>' . $langs -> trans ( " Ref " ) . ':</td><td><input type="text" class="flat" name="search_contract" size="18"></td>' ;
print '<td rowspan="2"><input type="submit" value="' . $langs -> trans ( " Search " ) . '" class="button"></td></tr>' ;
print '<tr ' . $bc [ $var ] . '><td nowrap>' . $langs -> trans ( " Other " ) . ':</td><td><input type="text" class="flat" name="sall" size="18"></td>' ;
print '</tr>' ;
print " </table></form> \n " ;
print " <br> " ;
2005-01-29 01:44:52 +01:00
}
2004-01-24 21:51:31 +01:00
2005-01-29 01:44:52 +01:00
/*
* Liste des propal brouillons
*/
2005-05-14 17:12:15 +02:00
if ( $conf -> propal -> enabled && $user -> rights -> propale -> lire )
{
2007-10-12 18:01:48 +02:00
$sql = " SELECT p.rowid, p.ref, p.total_ht, s.rowid as socid, s.nom " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , sc.fk_soc, sc.fk_user " ;
2005-09-27 00:47:07 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " propal as p, " . MAIN_DB_PREFIX . " societe as s " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2007-06-12 00:51:47 +02:00
$sql .= " WHERE p.fk_statut = 0 and p.fk_soc = s.rowid " ;
2006-09-13 20:56:30 +02:00
if ( $socid )
2006-03-08 17:48:36 +01:00
{
2007-06-12 00:51:47 +02:00
$sql .= " AND s.rowid = " . $socid ;
2006-03-08 17:48:36 +01:00
}
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2006-03-08 15:28:35 +01:00
2005-09-27 00:47:07 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
2005-05-14 17:12:15 +02:00
{
2005-09-27 00:47:07 +02:00
$total = 0 ;
$num = $db -> num_rows ( $resql );
if ( $num > 0 )
2005-05-14 17:12:15 +02:00
{
2005-09-27 00:47:07 +02:00
print '<table class="noborder" width="100%">' ;
print " <tr class= \" liste_titre \" > " ;
print " <td colspan= \" 3 \" > " . $langs -> trans ( " ProposalsDraft " ) . " </td></tr> " ;
$i = 0 ;
$var = true ;
while ( $i < $num )
{
$obj = $db -> fetch_object ( $resql );
$var =! $var ;
2008-06-18 22:01:01 +02:00
print '<tr ' . $bc [ $var ] . '><td nowrap="nowrap">' . " <a href= \" " . DOL_URL_ROOT . " /comm/propal.php?propalid= " . $obj -> rowid . " \" > " . img_object ( $langs -> trans ( " ShowPropal " ), " propal " ) . " " . $obj -> ref . '</a></td>' ;
print '<td nowrap="nowrap"><a href="fiche.php?socid=' . $obj -> socid . '">' . dolibarr_trunc ( $obj -> nom , 18 ) . '</a></td>' ;
2007-10-12 18:01:48 +02:00
print '<td align="right" nowrap="nowrap">' . price ( $obj -> total_ht ) . '</td></tr>' ;
2005-09-27 00:47:07 +02:00
$i ++ ;
$total += $obj -> price ;
}
if ( $total > 0 )
2005-05-14 17:12:15 +02:00
{
2005-09-27 00:47:07 +02:00
$var =! $var ;
print '<tr class="liste_total"><td>' . $langs -> trans ( " Total " ) . '</td><td colspan="2" align="right">' . price ( $total ) . " </td></tr> " ;
2005-05-14 17:12:15 +02:00
}
2005-09-27 00:47:07 +02:00
print " </table><br> " ;
2005-05-14 17:12:15 +02:00
}
2005-09-27 00:47:07 +02:00
$db -> free ( $resql );
2005-05-14 17:12:15 +02:00
}
2002-04-29 20:01:16 +02:00
}
2005-06-21 21:49:42 +02:00
2003-11-09 16:37:14 +01:00
/*
2005-07-15 02:49:05 +02:00
* Commandes brouillons
2003-11-09 16:37:14 +01:00
*/
2008-05-17 02:58:10 +02:00
if ( $conf -> commande -> enabled && $user -> rights -> commande -> lire )
2004-05-18 09:59:20 +02:00
{
2005-10-16 04:09:54 +02:00
$langs -> load ( " orders " );
2007-06-12 00:51:47 +02:00
$sql = " SELECT c.rowid, c.ref, c.total_ttc, s.nom, s.rowid as socid " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , sc.fk_soc, sc.fk_user " ;
2005-10-16 04:09:54 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " commande as c, " . MAIN_DB_PREFIX . " societe as s " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2007-06-12 00:51:47 +02:00
$sql .= " WHERE c.fk_soc = s.rowid AND c.fk_statut = 0 " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2006-09-13 20:56:30 +02:00
if ( $socid )
2003-09-03 15:50:00 +02:00
{
2007-03-29 22:07:44 +02:00
$sql .= " AND c.fk_soc = " . $socid ;
2003-09-03 15:50:00 +02:00
}
2005-10-16 04:09:54 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
2004-05-08 20:44:22 +02:00
{
2005-10-16 04:09:54 +02:00
$total = 0 ;
$num = $db -> num_rows ( $resql );
if ( $num )
2004-05-08 20:44:22 +02:00
{
2005-10-16 04:09:54 +02:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
print '<td colspan="3">' . $langs -> trans ( " DraftOrders " ) . '</td></tr>' ;
$i = 0 ;
$var = true ;
while ( $i < $num )
2005-07-15 02:49:05 +02:00
{
2005-10-16 04:09:54 +02:00
$var =! $var ;
$obj = $db -> fetch_object ( $resql );
2008-06-20 23:40:29 +02:00
print '<tr ' . $bc [ $var ] . '><td nowrap="nowrap"><a href="../commande/fiche.php?id=' . $obj -> rowid . '">' . img_object ( $langs -> trans ( " ShowOrder " ), " order " ) . ' ' . $obj -> ref . '</a></td>' ;
2008-06-18 22:01:01 +02:00
print '<td nowrap="nowrap"><a href="fiche.php?socid=' . $obj -> socid . '">' . dolibarr_trunc ( $obj -> nom , 18 ) . '</a></td>' ;
2005-10-16 04:09:54 +02:00
print '<td align="right" nowrap="nowrap">' . price ( $obj -> total_ttc ) . '</td></tr>' ;
$i ++ ;
$total += $obj -> total_ttc ;
2005-07-15 02:49:05 +02:00
}
2005-10-16 04:09:54 +02:00
if ( $total > 0 )
{
$var =! $var ;
print '<tr class="liste_total"><td>' . $langs -> trans ( " Total " ) . '</td><td colspan="2" align="right">' . price ( $total ) . " </td></tr> " ;
}
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
*
*/
2007-04-05 09:11:17 +02:00
if ( $conf -> bookmark -> enabled )
{
2007-06-12 00:51:47 +02:00
$sql = " SELECT s.rowid, s.nom,b.rowid as bid " ;
2007-04-05 09:11:17 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " bookmark as b " ;
2007-06-12 00:51:47 +02:00
$sql .= " WHERE b.fk_soc = s.rowid AND b.fk_user = " . $user -> id ;
2007-04-05 09:11:17 +02:00
if ( $socid )
{
2007-06-12 00:51:47 +02:00
$sql .= " AND s.rowid = " . $socid ;
2007-04-05 09:11:17 +02:00
}
$sql .= " ORDER BY lower(s.nom) ASC " ;
if ( $db -> query ( $sql ) )
{
$num = $db -> num_rows ();
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 \" > " ;
2005-02-01 22:33:08 +01:00
print " <td colspan= \" 2 \" > " . $langs -> trans ( " Bookmarks " ) . " </td> " ;
2004-07-13 18:47:11 +02:00
print " </tr> \n " ;
2005-07-09 16:00:52 +02:00
$var = true ;
2004-07-13 18:47:11 +02:00
while ( $i < $num )
2007-04-05 09:11:17 +02:00
{
$obj = $db -> fetch_object ();
$var = ! $var ;
print " <tr $bc[$var] > " ;
2007-06-12 00:51:47 +02:00
print '<td><a href="fiche.php?socid=' . $obj -> rowid . '">' . $obj -> nom . '</a></td>' ;
2007-04-05 09:11:17 +02:00
print '<td align="right"><a href="index.php?action=del_bookmark&bid=' . $obj -> bid . '">' ;
print img_delete ();
print '</a></td>' ;
print '</tr>' ;
$i ++ ;
}
2004-07-13 18:47:11 +02:00
print '</table>' ;
2003-05-25 18:23:14 +02:00
}
2007-04-05 09:11:17 +02:00
}
2002-04-29 20:01:16 +02:00
}
2004-05-08 20:44:22 +02:00
2005-08-11 20:54:59 +02:00
print '</td><td valign="top" width="70%" class="notopnoleftnoright">' ;
2004-06-26 19:43:07 +02:00
2004-10-30 14:15:59 +02:00
2005-10-25 21:40:01 +02:00
/*
2008-02-26 19:34:53 +01:00
* Actions to do
2005-10-25 21:40:01 +02:00
*
*/
2008-05-17 02:58:10 +02:00
if ( $user -> rights -> agenda -> myactions -> read )
{
show_array_actions_to_do ( 10 );
}
2005-10-25 21:40:01 +02:00
2006-03-18 17:30:48 +01:00
/*
2008-02-26 19:34:53 +01:00
* Last actions
2006-03-18 17:30:48 +01:00
*/
2008-05-17 02:58:10 +02:00
if ( $user -> rights -> agenda -> myactions -> read )
{
show_array_last_actions_done ( $max );
}
2006-03-18 17:30:48 +01:00
2005-06-21 21:49:42 +02:00
/*
2005-06-27 23:28:56 +02:00
* Derniers clients enregistr<EFBFBD> s
2005-06-21 21:49:42 +02:00
*/
2005-06-27 23:28:56 +02:00
if ( $user -> rights -> societe -> lire )
2005-06-21 21:49:42 +02:00
{
2008-03-02 22:30:39 +01:00
$sql = " SELECT s.rowid,s.nom,s.client, " . $db -> pdate ( " datec " ) . " as datec " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , sc.fk_soc, sc.fk_user " ;
2005-06-27 23:28:56 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2008-03-02 22:30:39 +01:00
$sql .= " WHERE s.client in (1,2) " ;
2006-09-13 20:56:30 +02:00
if ( $socid )
2005-06-21 21:49:42 +02:00
{
2007-06-12 00:51:47 +02:00
$sql .= " AND s.rowid = $socid " ;
2005-06-27 23:28:56 +02:00
}
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) //restriction
2006-03-08 15:51:43 +01:00
{
2007-06-12 00:51:47 +02:00
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2006-03-08 15:51:43 +01:00
}
2005-07-03 04:37:16 +02:00
$sql .= " ORDER BY s.datec DESC " ;
2005-06-27 23:28:56 +02:00
$sql .= $db -> plimit ( $max , 0 );
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
if ( $num )
2005-06-21 21:49:42 +02:00
{
2005-06-27 23:28:56 +02:00
$langs -> load ( " boxes " );
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2008-03-02 22:30:39 +01:00
print '<td colspan="3">' . $langs -> trans ( " BoxTitleLastCustomersOrProspects " , $max ) . '</td></tr>' ;
2005-06-27 23:28:56 +02:00
$i = 0 ;
$var = false ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $resql );
print " <tr $bc[$var] > " ;
2008-03-02 22:30:39 +01:00
print " <td nowrap> " ;
if ( $objp -> client == 1 ) print " <a href= \" " . DOL_URL_ROOT . " /comm/fiche.php?socid= " . $objp -> rowid . " \" > " . img_object ( $langs -> trans ( " ShowCustomer " ), " company " ) . " " . $objp -> nom . " </a></td> " ;
if ( $objp -> client == 2 ) print " <a href= \" " . DOL_URL_ROOT . " /comm/prospect/fiche.php?socid= " . $objp -> rowid . " \" > " . img_object ( $langs -> trans ( " ShowCustomer " ), " company " ) . " " . $objp -> nom . " </a></td> " ;
print '<td align="right" nowrap>' ;
if ( $objp -> client == 1 ) print $langs -> trans ( " Customer " );
if ( $objp -> client == 2 ) print $langs -> trans ( " Prospect " );
print " </td> " ;
2007-08-03 01:25:40 +02:00
print '<td align="right" nowrap>' . dolibarr_print_date ( $objp -> datec , 'day' ) . " </td> " ;
2005-06-27 23:28:56 +02:00
print '</tr>' ;
$i ++ ;
$var =! $var ;
}
print " </table><br> " ;
2005-06-21 21:49:42 +02:00
2005-06-27 23:28:56 +02:00
$db -> free ( $resql );
2005-06-21 21:49:42 +02:00
}
}
}
2005-10-25 21:40:01 +02:00
2004-05-08 20:44:22 +02:00
/*
* Derniers contrat
*
*/
2008-05-17 02:58:10 +02:00
if ( $conf -> contrat -> enabled && $user -> rights -> contrat -> lire && 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
2007-06-12 00:51:47 +02:00
$sql = " SELECT s.nom, s.rowid, c.statut, c.rowid as contratid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , sc.fk_soc, sc.fk_user " ;
2006-03-08 15:51:43 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " contrat as c, " . MAIN_DB_PREFIX . " product as p " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2007-06-12 00:51:47 +02:00
$sql .= " WHERE c.fk_soc = s.rowid and c.fk_product = p.rowid " ;
2006-09-13 20:56:30 +02:00
if ( $socid )
2007-06-12 00:51:47 +02:00
{
$sql .= " AND s.rowid = " . $socid ;
}
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) //restriction
2006-03-08 15:51:43 +01:00
{
2007-06-12 00:51:47 +02:00
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2006-03-08 15:51:43 +01:00
}
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 ;
2006-03-18 17:30:48 +01:00
$staticcontrat = new Contrat ( $db );
2004-10-30 14:15:59 +02:00
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 ();
2007-06-12 00:51:47 +02:00
print " <tr $bc[$var] ><td><a href= \" ../contrat/fiche.php?id= " . $obj -> contratid . " \" > " . img_object ( $langs -> trans ( " ShowContract " , " contract " )) . " " . $obj -> ref . " </a></td> " ;
print " <td><a href= \" fiche.php?socid= " . $obj -> rowid . " \" > " . img_object ( $langs -> trans ( " ShowCompany " , " company " )) . " " . $obj -> nom . " </a></td> \n " ;
2006-06-12 10:32:49 +02:00
print " <td align= \" right \" > " . $staticcontrat -> LibStatut ( $obj -> statut , 3 ) . " </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
/*
2005-08-13 16:22:16 +02:00
* Propales ouvertes
2004-05-08 20:44:22 +02:00
*
*/
2005-05-14 17:12:15 +02:00
if ( $conf -> propal -> enabled && $user -> rights -> propale -> lire )
{
2006-04-08 16:43:00 +02:00
$langs -> load ( " propal " );
2008-03-31 06:08:28 +02:00
$sql = " SELECT s.nom, s.rowid, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, " . $db -> pdate ( " p.datep " ) . " as dp " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , sc.fk_soc, sc.fk_user " ;
2005-07-02 16:37:42 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " propal as p " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2007-06-12 00:51:47 +02:00
$sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = 1 " ;
if ( $socid ) $sql .= " AND s.rowid = " . $socid ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2004-05-08 20:44:22 +02:00
$sql .= " ORDER BY p.rowid DESC " ;
2005-02-13 19:34:29 +01:00
$result = $db -> query ( $sql );
if ( $result )
2003-11-09 16:37:14 +01:00
{
2005-05-14 17:12:15 +02:00
$total = 0 ;
$num = $db -> num_rows ( $result );
$i = 0 ;
if ( $num > 0 )
{
$var = true ;
print '<table class="noborder" width="100%">' ;
2006-04-08 00:27:25 +02:00
print '<tr class="liste_titre"><td colspan="5">' . $langs -> trans ( " ProposalsOpened " ) . '</td></tr>' ;
2005-05-14 17:12:15 +02:00
while ( $i < $num )
{
$obj = $db -> fetch_object ( $result );
$var =! $var ;
2007-07-13 19:10:38 +02:00
print " <tr $bc[$var] > " ;
2007-08-03 01:25:40 +02:00
print '<td nowrap="nowrap" width="140">' ;
2007-07-13 19:10:38 +02:00
$propalstatic -> id = $obj -> propalid ;
$propalstatic -> ref = $obj -> ref ;
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
2007-08-03 01:25:40 +02:00
print '<td width="100" class="nobordernopadding" nowrap="nowrap">' ;
2007-07-13 19:10:38 +02:00
print $propalstatic -> getNomUrl ( 1 );
print '</td>' ;
2007-08-03 01:25:40 +02:00
print '<td width="18" class="nobordernopadding" nowrap="nowrap">' ;
2007-07-13 19:10:38 +02:00
if ( $obj -> dp < ( time () - $conf -> propal -> cloture -> warning_delay )) print img_warning ( $langs -> trans ( " Late " ));
print '</td>' ;
2007-08-03 01:25:40 +02:00
print '<td width="16" align="center" class="nobordernopadding">' ;
2007-07-13 19:10:38 +02:00
$filename = sanitize_string ( $obj -> ref );
$filedir = $conf -> propal -> dir_output . '/' . sanitize_string ( $obj -> ref );
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?propalid=' . $obj -> propalid ;
2008-01-20 14:53:02 +01:00
$formfile -> show_documents ( 'propal' , $filename , $filedir , $urlsource , '' , '' , '' , '' , '' , 1 );
2007-07-13 19:10:38 +02:00
print '</td></tr></table>' ;
2005-08-13 16:22:16 +02:00
print " </td> " ;
2007-08-03 01:25:40 +02:00
print " <td align= \" left \" ><a href= \" fiche.php?socid= " . $obj -> rowid . " \" > " . img_object ( $langs -> trans ( " ShowCompany " ), " company " ) . " " . dolibarr_trunc ( $obj -> nom , 44 ) . " </a></td> \n " ;
2005-05-14 17:12:15 +02:00
print " <td align= \" right \" > " ;
2007-08-03 01:25:40 +02:00
print dolibarr_print_date ( $obj -> dp , 'day' ) . " </td> \n " ;
2008-03-31 06:08:28 +02:00
print " <td align= \" right \" > " . price ( $obj -> total_ttc ) . " </td> " ;
2007-11-20 18:29:55 +01:00
print " <td align= \" center \" width= \" 14 \" > " . $propalstatic -> LibStatut ( $obj -> fk_statut , 3 ) . " </td> \n " ;
2006-04-08 00:27:25 +02:00
print " </tr> \n " ;
2005-05-14 17:12:15 +02:00
$i ++ ;
2008-03-31 06:08:28 +02:00
$total += $obj -> total_ttc ;
2005-05-14 17:12:15 +02:00
}
if ( $total > 0 ) {
2006-04-08 00:27:25 +02:00
print '<tr class="liste_total"><td colspan="3" align="right">' . $langs -> trans ( " Total " ) . " </td><td align= \" right \" > " . price ( $total ) . " </td><td> </td></tr> " ;
2005-05-14 17:12:15 +02:00
}
print " </table><br> " ;
}
2003-11-09 16:37:14 +01:00
}
2005-05-14 17:12:15 +02:00
else
2005-04-08 23:38:38 +02:00
{
dolibarr_print_error ( $db );
}
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
*
*/
2008-05-17 02:58:10 +02:00
if ( $conf -> propal -> enabled && $user -> rights -> propale -> lire )
{
2005-02-13 19:34:29 +01:00
$NBMAX = 5 ;
2007-11-20 18:32:14 +01:00
$sql = " SELECT s.nom, s.rowid, p.rowid as propalid, p.total_ht, p.ref, p.fk_statut, " . $db -> pdate ( " p.datep " ) . " as dp " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , sc.fk_soc, sc.fk_user " ;
2005-07-02 16:37:42 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " propal as p " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2007-06-12 00:51:47 +02:00
$sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut > 1 " ;
2006-09-13 20:56:30 +02:00
if ( $socid )
2004-01-24 21:51:31 +01:00
{
2007-06-12 00:51:47 +02:00
$sql .= " AND s.rowid = " . $socid ;
2004-01-24 21:51:31 +01:00
}
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2004-01-24 21:51:31 +01:00
$sql .= " ORDER BY p.rowid DESC " ;
2005-02-13 19:34:29 +01:00
$sql .= $db -> plimit ( $NBMAX , 0 );
2004-01-24 21:51:31 +01:00
if ( $db -> query ( $sql ) )
2007-07-13 19:10:38 +02:00
{
$num = $db -> num_rows ();
2004-01-24 21:51:31 +01:00
2007-07-13 19:10:38 +02:00
$i = 0 ;
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre"><td colspan="6">' . $langs -> trans ( " LastClosedProposals " , $NBMAX ) . '</td></tr>' ;
$var = False ;
while ( $i < $num )
{
$objp = $db -> fetch_object ();
print " <tr $bc[$var] > " ;
2007-08-03 01:25:40 +02:00
print '<td nowrap="nowrap" width="140">' ;
2007-07-13 19:10:38 +02:00
$propalstatic -> id = $objp -> propalid ;
$propalstatic -> ref = $objp -> ref ;
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
2007-08-03 01:25:40 +02:00
print '<td width="100" class="nobordernopadding" nowrap="nowrap">' ;
2007-07-13 19:10:38 +02:00
print $propalstatic -> getNomUrl ( 1 );
print '</td>' ;
2007-08-03 01:25:40 +02:00
print '<td width="18" class="nobordernopadding" nowrap="nowrap">' ;
print ' ' ;
print '</td>' ;
print '<td width="16" align="center" class="nobordernopadding">' ;
2007-07-13 19:10:38 +02:00
$filename = sanitize_string ( $objp -> ref );
$filedir = $conf -> propal -> dir_output . '/' . sanitize_string ( $objp -> ref );
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?propalid=' . $objp -> propalid ;
2008-01-20 14:53:02 +01:00
$formfile -> show_documents ( 'propal' , $filename , $filedir , $urlsource , '' , '' , '' , '' , '' , 1 );
2007-07-13 19:10:38 +02:00
print '</td></tr></table>' ;
print '</td>' ;
2007-08-03 01:25:40 +02:00
print '<td align="left"><a href="fiche.php?socid=' . $objp -> rowid . '">' . img_object ( $langs -> trans ( " ShowCompany " ), " company " ) . ' ' . dolibarr_trunc ( $objp -> nom , 44 ) . '</a></td>' ;
2007-07-13 19:10:38 +02:00
print " <td align= \" right \" > " ;
2007-08-03 01:25:40 +02:00
print dolibarr_print_date ( $objp -> dp , 'day' ) . " </td> \n " ;
2007-11-20 18:32:14 +01:00
print " <td align= \" right \" > " . price ( $objp -> total_ht ) . " </td> \n " ;
2007-07-13 19:10:38 +02:00
print " <td align= \" center \" width= \" 14 \" > " . $propalstatic -> LibStatut ( $objp -> fk_statut , 3 ) . " </td> \n " ;
print " </tr> \n " ;
$i ++ ;
$var =! $var ;
2004-02-12 23:35:18 +01:00
2007-07-13 19:10:38 +02:00
}
2004-02-12 23:35:18 +01:00
2007-07-13 19:10:38 +02:00
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
2005-05-14 03:00:54 +02:00
llxFooter ( '$Date$ - $Revision$' );
2002-04-29 20:01:16 +02:00
?>