dolibarr/htdocs/comm/action/fiche.php

387 lines
12 KiB
PHP
Raw Normal View History

2002-04-29 20:01:16 +02:00
<?PHP
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
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-19 19:59:23 +01:00
* $Id$
* $Source$
2002-04-29 20:01:16 +02:00
*/
2003-09-11 22:18:51 +02:00
require("./pre.inc.php");
2002-04-30 12:44:42 +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");
2002-05-09 16:57:48 +02:00
2003-03-23 16:37:36 +01:00
/*
* S<EFBFBD>curit<EFBFBD> acc<EFBFBD>s client
*/
if ($user->societe_id > 0)
{
$action = '';
$socidp = $user->societe_id;
}
2002-04-29 20:01:16 +02:00
/*
*
*
*
*/
2003-08-29 22:22:27 +02:00
if ($HTTP_POST_VARS["action"] == 'add_action')
2002-12-19 19:59:23 +01:00
{
2003-08-03 19:26:19 +02:00
if ($contactid)
{
$contact = new Contact($db);
$contact->fetch($contactid);
}
2002-05-16 17:38:04 +02:00
$societe = new Societe($db);
$societe->fetch($socid);
2003-08-03 19:26:19 +02:00
if ($HTTP_POST_VARS["afaire"] <> 1)
2002-12-19 19:59:23 +01:00
{
2003-08-03 19:26:19 +02:00
$actioncomm = new ActionComm($db);
2003-08-29 22:22:27 +02:00
$actioncomm->priority = 2;
$actioncomm->type = $HTTP_POST_VARS["actionid"];
2003-08-03 19:26:19 +02:00
$actioncomm->date = $db->idate(mktime($HTTP_POST_VARS["heurehour"],
$HTTP_POST_VARS["heuremin"],
2003-08-03 19:26:19 +02:00
0,
$HTTP_POST_VARS["acmonth"],
$HTTP_POST_VARS["acday"],
$HTTP_POST_VARS["acyear"])
2003-08-03 19:26:19 +02:00
);
2003-08-29 22:22:27 +02:00
if ($HTTP_POST_VARS["actionid"] == 5)
2003-08-03 19:26:19 +02:00
{
$actioncomm->percent = 0;
}
else
{
$actioncomm->percent = 100;
}
2003-08-29 22:22:27 +02:00
2003-08-03 19:26:19 +02:00
$actioncomm->contact = $contactid;
$actioncomm->user = $user;
$actioncomm->societe = $socid;
$actioncomm->note = $note;
$actioncomm->add($user);
}
2002-05-09 16:57:48 +02:00
2002-12-19 19:59:23 +01:00
if ($todo == 'on' )
{
2002-05-09 16:57:48 +02:00
2002-12-19 19:59:23 +01:00
$todo = new ActionComm($db);
2003-08-29 22:22:27 +02:00
$todo->type = $HTTP_POST_VARS["nextactionid"];
2003-08-03 19:26:19 +02:00
$todo->date = $db->idate(mktime(12,0,0,$remonth, $reday, $reyear));
$todo->libelle = $todo_label;
2002-12-19 19:59:23 +01:00
$todo->priority = 2;
2003-08-03 19:26:19 +02:00
$todo->societe = $societe->id;
$todo->contact = $contactid;
$todo->user = $user;
$todo->note = $todo_note;
$todo->percent = 0;
2002-12-19 19:59:23 +01:00
$todo->add($user);
if ($conf->webcal && $todo_webcal == 'on')
{
$webcal = new Webcal();
2002-05-09 16:57:48 +02:00
2002-12-19 19:59:23 +01:00
$webcal->heure = $heurehour . $heuremin . '00';
$webcal->duree = ($dureehour * 60) + $dureemin;
2002-05-10 14:28:10 +02:00
2002-12-19 19:59:23 +01:00
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);
}
2002-05-09 16:57:48 +02:00
}
// Header("Location: ".DOL_URL_ROOT."/comm/fiche.php?socid=$socid");
Header("Location: ".$HTTP_POST_VARS["from"]);
2002-04-29 20:01:16 +02:00
}
2002-05-09 16:57:48 +02:00
2003-08-03 14:18:29 +02:00
if ($HTTP_POST_VARS["action"] == 'confirm_delete' && $HTTP_POST_VARS["confirm"] == yes)
{
$actioncomm = new ActionComm($db);
$actioncomm->delete($id);
Header("Location: index.php");
}
2003-08-03 19:26:19 +02:00
if ($action=='update')
{
$action = new Actioncomm($db);
$action->fetch($id);
$action->percent = $HTTP_POST_VARS["percent"];
$action->contact->id = $HTTP_POST_VARS["scontactid"];
$action->update();
}
2003-08-03 14:18:29 +02:00
2002-12-19 19:59:23 +01:00
/******************************************************************************/
/* */
/* Fin des Actions */
/* */
/******************************************************************************/
2002-05-10 14:28:10 +02:00
llxHeader();
2003-08-03 19:26:19 +02:00
$html = new Form($db);
2002-04-29 20:01:16 +02:00
/*
*
*
*
*/
if ($_GET["action"] == 'create')
2003-08-03 19:26:19 +02:00
{
$caction = new CActioncomm($db);
if ($afaire <> 1)
{
$caction->fetch($db, $actionid);
2002-04-29 20:01:16 +02:00
2003-08-03 19:26:19 +02:00
$contact = new Contact($db);
$contact->fetch($_GET["contactid"]);
2003-08-03 19:26:19 +02:00
}
2002-04-29 20:01:16 +02:00
$societe = new Societe($db);
$societe->get_nom($socid);
2003-08-29 22:22:27 +02:00
print '<form action="'.$PHP_SELF.'?socid='.$socid.'" method="post">';
print '<input type="hidden" name="from" value="'.$_SERVER["HTTP_REFERER"].'">';
2003-08-29 22:22:27 +02:00
print '<input type="hidden" name="action" value="add_action">';
print '<input type="hidden" name="actionid" value="'.$actionid.'">'."\n";
2002-05-09 16:57:48 +02:00
/*
* Rendez-vous
*
*/
if ($_GET["actionid"] == 5)
2002-05-09 16:57:48 +02:00
{
2003-08-29 22:22:27 +02:00
print '<input type="hidden" name="date" value="'.$db->idate(time()).'">'."\n";
2002-05-09 16:57:48 +02:00
print '<input type="hidden" name="contactid" value="'.$contactid.'">';
print '<input type="hidden" name="socid" value="'.$socid.'">';
2003-10-19 01:43:21 +02:00
print '<table class="border" width="100%" border="1" cellspacing="0" cellpadding="3">';
2002-05-09 16:57:48 +02:00
2003-05-15 21:29:40 +02:00
print '<tr><td colspan="2"><div class="titre">Rendez-vous</div></td></tr>';
print '<tr><td width="10%">Soci<63>t<EFBFBD></td><td width="40%">';
2003-09-11 22:18:51 +02:00
print '<a href="../fiche.php?socid='.$socid.'">'.$societe->nom.'</a></td></tr>';
2003-08-01 23:24:04 +02:00
print '<tr><td width="10%">Contact</td><td width="40%">'.$contact->fullname.'</td></tr>';
2002-05-09 16:57:48 +02:00
print '<tr><td width="10%">Date</td><td width="40%">';
$html= new Form($db);
$html->select_date('','ac');
2002-05-09 16:57:48 +02:00
print '</td></tr>';
print '<tr><td width="10%">Heure</td><td width="40%">';
print_heure_select("heure",8,20);
print '</td></tr>';
print '<tr><td width="10%">Dur<75>e</td><td width="40%">';
print_duree_select("duree");
print '</td></tr>';
print '<tr><td valign="top">Commentaire</td><td>';
print '<textarea cols="60" rows="6" name="todo_note"></textarea></td></tr>';
2003-08-03 19:26:19 +02:00
print '<tr><td colspan="2" align="center"><input type="submit" value="Enregistrer"></td></tr>';
2002-05-09 16:57:48 +02:00
print '</form></table>';
}
/*
2002-05-16 17:38:04 +02:00
*
* Action autre que rendez-vous
2002-05-09 16:57:48 +02:00
*
*
*/
else
{
2003-08-29 22:22:27 +02:00
2002-05-09 16:57:48 +02:00
print '<input type="hidden" name="contactid" value="'.$contactid.'">';
print '<input type="hidden" name="socid" value="'.$socid.'">';
2003-08-03 19:26:19 +02:00
if($afaire <> 1)
{
print_titre ("Action effectu<74>e");
2003-10-19 01:43:21 +02:00
print '<table class="border" width="100%" border="1" cellspacing="0" cellpadding="3">';
2003-08-03 19:26:19 +02:00
print '<tr><td width="10%">Action</td><td>'.$caction->libelle.'</td></tr>';
print '<tr><td width="10%">Soci<63>t<EFBFBD></td><td width="40%">';
2003-09-11 22:18:51 +02:00
print '<a href="../fiche.php?socid='.$socid.'">'.$societe->nom.'</a></td></tr>';
2003-08-03 19:26:19 +02:00
print '<tr><td width="10%">Contact</td><td width="40%">'.$contact->fullname.'</td></tr>';
print '<td>Date</td><td>';
print $html->select_date('','ac',1,1);
print '</td></tr>';
print '<tr><td valign="top">Commentaire</td><td>';
print '<textarea cols="60" rows="6" name="note"></textarea></td></tr>';
print "</table><p />";
}
print_titre ("Prochaine Action <20> faire");
2003-10-19 01:43:21 +02:00
print '<table class="border" width="100%" border="1" cellspacing="0" cellpadding="3">';
2003-08-03 19:26:19 +02:00
if($afaire <> 1)
{
print '<tr><td width="10%">Ajouter</td><td><input type="checkbox" name="todo"></td></tr>';
}
else
{
print '<input type="hidden" name="todo" value="on">';
print '<input type="hidden" name="afaire" value="1">';
print '<tr><td width="10%">Soci<63>t<EFBFBD></td><td width="40%">';
2003-09-11 22:18:51 +02:00
print '<a href="../fiche.php?socid='.$socid.'">'.$societe->nom.'</a></td></tr>';
2003-08-03 19:26:19 +02:00
}
2002-05-09 16:57:48 +02:00
print '<tr><td width="10%">Date</td><td width="40%">';
2003-08-03 19:26:19 +02:00
print $html->select_date();
print '</td></tr>';
print '<tr><td width="10%">Action</td><td>';
2003-08-29 22:22:27 +02:00
$html->select_array("nextactionid", $caction->liste_array(), 0);
2002-05-09 16:57:48 +02:00
print '</td></tr>';
print '<tr><td width="10%">Action</td><td><input type="text" name="todo_label" size="30"></td></tr>';
if (defined("MAIN_MODULE_WEBCALENDAR") && MAIN_MODULE_WEBCALENDAR)
{
print '<tr><td width="10%">Calendrier</td><td><input type="checkbox" name="todo_webcal"></td></tr>';
}
2002-05-09 16:57:48 +02:00
print '<tr><td valign="top">Commentaire</td><td>';
print '<textarea cols="60" rows="6" name="todo_note"></textarea></td></tr>';
print '</table>';
2002-05-09 16:57:48 +02:00
print '<p align="center"><input type="submit" value="Enregistrer"></p>';
print "</form>";
2002-05-09 16:57:48 +02:00
}
2002-04-29 20:01:16 +02:00
}
/*
*
*
*
*/
2002-12-19 19:59:23 +01:00
if ($id)
{
2003-08-03 14:18:29 +02:00
if ($action == 'delete')
{
print '<form method="post" action="'.$PHP_SELF.'?id='.$id.'">';
print '<input type="hidden" name="action" value="confirm_delete">';
print '<table id="actions" cellspacing="0" border="1" width="100%" cellpadding="3">';
2003-08-03 14:18:29 +02:00
print '<tr><td colspan="3">Supprimer l\'action</td></tr>';
print '<tr><td class="delete">Etes-vous sur de vouloir supprimer cette action ?</td><td class="delete">';
$htmls = new Form($db);
$htmls->selectyesno("confirm","no");
print "</td>\n";
print '<td class="delete" align="center"><input type="submit" value="Confirmer"</td></tr>';
print '</table>';
print "</form>\n";
}
2002-05-09 16:57:48 +02:00
$act = new ActionComm($db);
$act->fetch($id);
2003-08-03 19:26:19 +02:00
2002-05-10 14:28:10 +02:00
$act->societe->fetch($act->societe->id);
2003-05-15 21:29:40 +02:00
$act->author->fetch($act->author->id);
$act->contact->fetch($act->contact->id);
2003-08-03 19:26:19 +02:00
2002-05-10 14:28:10 +02:00
2003-11-19 16:10:57 +01:00
if ($_GET["action"] == 'edit')
2003-08-03 19:26:19 +02:00
{
print_titre ("Edition de la fiche action");
2003-09-11 22:18:51 +02:00
print '<form action="fiche.php?id='.$id.'" method="post">';
2003-08-03 19:26:19 +02:00
print '<input type="hidden" name="action" value="update">';
2003-10-19 01:43:21 +02:00
print '<table class="border" width="100%" border="1" cellspacing="0" cellpadding="3">';
2003-08-03 19:26:19 +02:00
print '<tr><td width="20%">Type</td><td colspan="3">'.$act->type.'</td></tr>';
print '<tr><td width="20%">Soci<63>t<EFBFBD></td>';
2003-09-11 22:18:51 +02:00
print '<td width="30%"><a href="../fiche.php?socid='.$act->societe->id.'">'.$act->societe->nom.'</a></td>';
2003-08-03 19:26:19 +02:00
print '<td width="20%">Contact</td><td width="30%">';
$html->select_array("scontactid", $act->societe->contact_array(), $act->contact->id, 1);
print '</td></tr>';
print '<tr><td>Date</td><td>'.strftime('%d %B %Y %H:%M',$act->date).'</td>';
print '<td>Auteur</td><td>'.$act->author->fullname.'</td></tr>';
print '<tr><td>Pourcentage r<>alis<69></td><td colspan="3"><input name="percent" value="'.$act->percent.'">%</td></tr>';
if ($act->objet_url)
{
print '<tr><td>Objet li<6C></td>';
print '<td colspan="3">'.$act->objet_url.'</td></tr>';
}
if ($act->note)
{
print '<tr><td valign="top">Commentaire</td><td colspan="3">';
print nl2br($act->note).'</td></tr>';
}
print '<tr><td align="center" colspan="4"><input type="submit" value="Enregister"</td></tr>';
print '</table></form>';
2003-07-21 22:47:22 +02:00
}
2003-08-03 19:26:19 +02:00
else
{
print_titre ("Action commerciale");
2003-10-19 01:43:21 +02:00
print '<table class="border" width="100%" border="1" cellspacing="0" cellpadding="3">';
2003-08-03 19:26:19 +02:00
print '<tr><td width="20%">Type</td><td colspan="3">'.$act->type.'</td></tr>';
print '<tr><td width="20%">Soci<63>t<EFBFBD></td>';
2003-09-11 22:18:51 +02:00
print '<td width="30%"><a href="../fiche.php?socid='.$act->societe->id.'">'.$act->societe->nom.'</a></td>';
2003-08-03 19:26:19 +02:00
print '<td width="10%">Contact</td><td width="40%">'.$act->contact->fullname.'</td></tr>';
print '<tr><td>Date</td><td>'.strftime('%d %B %Y %H:%M',$act->date).'</td>';
print '<td>Auteur</td><td>'.$act->author->fullname.'</td></tr>';
print '<tr><td>Pourcentage r<>alis<69></td><td colspan="4">'.$act->percent.' %</td></tr>';
if ($act->objet_url)
{
print '<tr><td>Objet li<6C></td>';
print '<td colspan="3">'.$act->objet_url.'</td></tr>';
}
if ($act->note)
{
print '<tr><td valign="top">Commentaire</td><td colspan="3">';
print nl2br($act->note).'</td></tr>';
}
print '</table>';
}
2003-07-10 13:39:44 +02:00
/*
*
*/
print '<br><div class="tabsAction">';
if ($_GET["action"] == 'edit')
2003-08-03 19:26:19 +02:00
{
print '<a class="tabAction" href="fiche.php?id='.$act->id.'">Annuler</a>';
2003-08-03 19:26:19 +02:00
}
else
{
print '<a class="tabAction" href="fiche.php?action=edit&id='.$act->id.'">Editer</a>';
2003-08-03 19:26:19 +02:00
}
print '<a class="tabAction" href="fiche.php?action=delete&id='.$act->id.'">Supprimer</a>';
print '</div>';
2002-04-29 20:01:16 +02:00
}
$db->close();
2002-05-04 23:28:42 +02:00
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
2002-04-29 20:01:16 +02:00
?>