2003-08-03 14:13:38 +02:00
< ? PHP
2004-02-09 09:57:34 +01:00
/* Copyright ( C ) 2001 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2004-01-28 00:15:17 +01:00
* Copyright ( C ) 2003 <EFBFBD> ric Seigne < erics @ rycks . com >
* Copyright ( C ) 2004 Laurent Destailleur < eldy @ users . sourceforge . net >
2003-08-03 14:13:38 +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 .
*
* $Id $
* $Source $
*
*/
2003-09-11 22:18:51 +02:00
require ( " ./pre.inc.php " );
2003-08-03 14:13:38 +02:00
2003-09-11 22:18:51 +02:00
require ( " ../../contact.class.php " );
require ( " ../../lib/webcal.class.php " );
require ( " ../../cactioncomm.class.php " );
require ( " ../../actioncomm.class.php " );
2003-08-03 14:13:38 +02:00
/*
* S<EFBFBD> curit<EFBFBD> acc<EFBFBD> s client
*/
if ( $user -> societe_id > 0 )
{
$action = '' ;
$socid = $user -> societe_id ;
}
llxHeader ();
/*
*
*
*
*/
if ( $action == 'delete_action' )
{
$actioncomm = new ActionComm ( $db );
$actioncomm -> delete ( $actionid );
}
/*
*
*/
if ( $action == 'add_action' )
{
$contact = new Contact ( $db );
$contact -> fetch ( $contactid );
$actioncomm = new ActionComm ( $db );
if ( $actionid == 5 )
{
$actioncomm -> date = $db -> idate ( mktime ( $heurehour , $heuremin , 0 , $remonth , $reday , $reyear ));
}
else
{
$actioncomm -> date = $date ;
}
$actioncomm -> type = $actionid ;
$actioncomm -> contact = $contactid ;
$actioncomm -> societe = $socid ;
$actioncomm -> note = $note ;
$actioncomm -> add ( $user );
$societe = new Societe ( $db );
$societe -> fetch ( $socid );
$todo = new TodoComm ( $db );
$todo -> date = mktime ( 12 , 0 , 0 , $remonth , $reday , $reyear );
$todo -> libelle = $todo_label ;
$todo -> societe = $societe -> id ;
$todo -> contact = $contactid ;
$todo -> note = $todo_note ;
$todo -> add ( $user );
$webcal = new Webcal ();
$webcal -> heure = $heurehour . $heuremin . '00' ;
$webcal -> duree = ( $dureehour * 60 ) + $dureemin ;
if ( $actionid == 5 ) {
$libelle = " Rendez-vous avec " . $contact -> fullname ;
$libelle .= " \n " . $todo -> libelle ;
} else {
$libelle = $todo -> libelle ;
}
$webcal -> add ( $user , $todo -> date , $societe -> nom , $libelle );
}
/*
*
* Liste
*
*/
if ( $page == - 1 ) { $page = 0 ; }
$limit = $conf -> liste_limit ;
$offset = $limit * $page ;
if ( $sortorder == " " )
{
$sortorder = " DESC " ;
}
if ( $sortfield == " " )
{
$sortfield = " a.datea " ;
}
2004-02-09 09:57:34 +01:00
$sql = " SELECT s.nom as societe, s.idp as socidp, s.client, a.id, " . $db -> pdate ( " a.datea " ) . " as da, a.datea, c.libelle, u.code, a.fk_contact, a.note, a.percent as percent " ;
2004-01-31 00:46:51 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " actioncomm as a, " . MAIN_DB_PREFIX . " c_actioncomm as c, " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " user as u " ;
2004-01-24 21:39:41 +01:00
$sql .= " WHERE a.fk_soc = s.idp AND c.id=a.fk_action AND a.fk_user_author = u.rowid " ;
2003-08-03 14:13:38 +02:00
2003-08-29 21:16:15 +02:00
if ( $type )
2003-08-03 14:13:38 +02:00
{
2003-08-29 21:16:15 +02:00
$sql .= " AND c.id = $type " ;
2003-08-03 14:13:38 +02:00
}
2003-08-29 21:16:15 +02:00
2003-08-29 21:39:38 +02:00
if ( $time == " today " )
{
$sql .= " AND date_format(a.datea, '%d%m%Y') = " . strftime ( " %d%m%Y " , time ());
}
2003-08-29 21:16:15 +02:00
if ( $socid )
2003-08-03 14:13:38 +02:00
{
2003-08-29 21:16:15 +02:00
$sql .= " AND s.idp = $socid " ;
}
$sql .= " ORDER BY a.datea DESC " ;
$sql .= $db -> plimit ( $limit + 1 , $offset );
2003-08-03 14:13:38 +02:00
2003-08-29 21:16:15 +02:00
if ( $db -> query ( $sql ) )
{
$num = $db -> num_rows ();
if ( $socid )
2003-08-03 14:13:38 +02:00
{
2003-08-29 21:16:15 +02:00
$societe = new Societe ( $db );
$societe -> fetch ( $socid );
2004-01-24 21:39:41 +01:00
print_barre_liste ( " Liste des actions commerciales r<> alis<69> es ou <20> faire sur " . $societe -> nom , $page , $PHP_SELF , '' , $sortfield , $sortorder , '' , $num );
2003-08-29 21:16:15 +02:00
}
else
{
2004-01-24 21:39:41 +01:00
print_barre_liste ( " Liste des actions commerciales r<> alis<69> es ou <20> faire " , $page , $PHP_SELF , '' , $sortfield , $sortorder , '' , $num );
2003-08-29 21:16:15 +02:00
}
$i = 0 ;
print " <TABLE border= \" 0 \" width= \" 100% \" cellspacing= \" 0 \" cellpadding= \" 4 \" > " ;
print '<TR class="liste_titre">' ;
print '<TD colspan="4">Date</TD>' ;
2004-01-24 21:39:41 +01:00
print '<TD>Avancement</TD>' ;
print '<TD>Action</TD>' ;
print '<TD>Soci<63> t<EFBFBD> </td>' ;
print '<td>Contact</TD>' ;
print " <td>Commentaires</td><td>Auteur</TD> " ;
2004-02-09 09:57:34 +01:00
print " </tr> \n " ;
$var = True ;
while ( $i < min ( $num , $limit ))
{
$obj = $db -> fetch_object ( $i );
$var =! $var ;
print " <TR $bc[$var] > " ;
if ( $oldyear == strftime ( " %Y " , $obj -> da ) )
{
print '<td> </td>' ;
}
else
{
print " <TD width= \" 30 \" > " . strftime ( " %Y " , $obj -> da ) . " </TD> \n " ;
$oldyear = strftime ( " %Y " , $obj -> da );
}
if ( $oldmonth == strftime ( " %Y%b " , $obj -> da ) )
{
print '<td width=\"20\"> </td>' ;
}
2003-08-03 14:13:38 +02:00
else
{
2004-01-24 21:39:41 +01:00
print " <TD width= \" 20 \" > " . strftime ( " %b " , $obj -> da ) . " </TD> \n " ;
2003-08-03 14:13:38 +02:00
$oldmonth = strftime ( " %Y%b " , $obj -> da );
}
2004-01-24 21:39:41 +01:00
print " <TD width= \" 20 \" > " . strftime ( " %d " , $obj -> da ) . " </TD> \n " ;
print " <TD width= \" 30 \" > " . strftime ( " %H:%M " , $obj -> da ) . " </TD> \n " ;
if ( $obj -> percent < 100 ) {
print " <TD align= \" center \" > " . $obj -> percent . " %</TD> " ;
}
else {
print " <TD align= \" center \" ><b>r<> alis<69> </b></TD> " ;
}
print '<TD><a href="fiche.php?id=' . $obj -> id . '">' . $obj -> libelle . '</a></td>' ;
2003-08-03 14:13:38 +02:00
2004-02-09 09:57:34 +01:00
print '<td>' ;
if ( $obj -> client == 1 )
{
print ' <a href="' . DOL_URL_ROOT . '/comm/fiche.php?socid=' . $obj -> socidp . '">' . $obj -> societe . '</A></TD>' ;
}
elseif ( $obj -> client == 2 )
{
print ' <a href="' . DOL_URL_ROOT . '/comm/prospect/fiche.php?id=' . $obj -> socidp . '">' . $obj -> societe . '</A></TD>' ;
}
else
{
print ' <a href="' . DOL_URL_ROOT . '/soc.php?socid=' . $obj -> socidp . '">' . $obj -> societe . '</A></TD>' ;
}
2003-08-03 14:13:38 +02:00
/*
* Contact
*/
2004-01-24 21:39:41 +01:00
print '<td>' ;
2003-08-03 14:13:38 +02:00
if ( $obj -> fk_contact )
{
$cont = new Contact ( $db );
$cont -> fetch ( $obj -> fk_contact );
2003-09-11 22:18:51 +02:00
print '<a href="' . DOL_URL_ROOT . '/comm/people.php?socid=' . $obj -> socidp . '&contactid=' . $cont -> id . '">' . $cont -> fullname . '</a>' ;
2003-08-03 14:13:38 +02:00
}
else
{
print " " ;
}
print '</td>' ;
/*
*
*/
2003-08-29 21:25:31 +02:00
print '<td>' . substr ( $obj -> note , 0 , 20 ) . ' ...</td>' ;
2004-01-24 21:39:41 +01:00
print " <TD> $obj->code </TD> \n " ;
2003-08-03 14:13:38 +02:00
print " </TR> \n " ;
$i ++ ;
}
print " </TABLE> " ;
$db -> free ();
}
else
{
print $db -> error () . ' ' . $sql ;
}
2003-08-29 21:16:15 +02:00
2003-08-03 14:13:38 +02:00
$db -> close ();
llxFooter ( " <em>Dernière modification $Date $ révision $Revision $ </em> " );
?>