* Copyright (C) 2003 Éric Seigne * Copyright (C) 2004 Laurent Destailleur * * 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$ * */ require("./pre.inc.php"); require("../../contact.class.php"); require("../../lib/webcal.class.php"); require("../../cactioncomm.class.php"); require("../../actioncomm.class.php"); /* * Sécurité accé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"; } $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"; $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"; $sql .= " WHERE a.fk_soc = s.idp AND c.id=a.fk_action AND a.fk_user_author = u.rowid"; if ($type) { $sql .= " AND c.id = $type"; } if ($time == "today") { $sql .= " AND date_format(a.datea, '%d%m%Y') = ".strftime("%d%m%Y",time()); } if ($socid) { $sql .= " AND s.idp = $socid"; } $sql .= " ORDER BY a.datea DESC"; $sql .= $db->plimit( $limit + 1, $offset); if ( $db->query($sql) ) { $num = $db->num_rows(); if ($socid) { $societe = new Societe($db); $societe->fetch($socid); print_barre_liste("Liste des actions commerciales réalisées ou à faire sur " . $societe->nom, $page, $PHP_SELF,'',$sortfield,$sortorder,'',$num); } else { print_barre_liste("Liste des actions commerciales réalisées ou à faire", $page, $PHP_SELF,'',$sortfield,$sortorder,'',$num); } $i = 0; print ""; print ''; print ''; print ''; print ''; print ''; print ''; print ""; print "\n"; $var=True; while ($i < min($num,$limit)) { $obj = $db->fetch_object( $i); $var=!$var; print ""; if ($oldyear == strftime("%Y",$obj->da) ) { print ''; } else { print "\n"; $oldyear = strftime("%Y",$obj->da); } if ($oldmonth == strftime("%Y%b",$obj->da) ) { print ''; } else { print "\n"; $oldmonth = strftime("%Y%b",$obj->da); } print "\n"; print "\n"; if ($obj->percent < 100) { print ""; } else { print ""; } print ''; print ''; } elseif ($obj->client == 2) { print ' '.$obj->societe.''; } else { print ' '.$obj->societe.''; } /* * Contact */ print ''; /* * */ print ''; print "\n"; print "\n"; $i++; } print "
DateAvancementActionSociétéContactCommentairesAuteur
 " .strftime("%Y",$obj->da)." " .strftime("%b",$obj->da)."" .strftime("%d",$obj->da)."" .strftime("%H:%M",$obj->da)."".$obj->percent."%réalisé'.$obj->libelle.''; if ($obj->client == 1) { print ' '.$obj->societe.''; if ($obj->fk_contact) { $cont = new Contact($db); $cont->fetch($obj->fk_contact); print ''.$cont->fullname.''; } else { print " "; } print ''.substr($obj->note, 0, 20).' ...$obj->code
"; $db->free(); } else { print $db->error() . ' ' . $sql ; } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>