* 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$ */ /*! \file htdocs/comm/action/fiche.php \ingroup commercial \brief Page de la fiche action commercial \version $Revision$ */ require("./pre.inc.php"); $langs->load("company"); $langs->load("commercial"); 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 = ''; $socidp = $user->societe_id; } /* * Action création de l'action * */ if ($_POST["action"] == 'add_action') { if ($_POST["contactid"]) { $contact = new Contact($db); $contact->fetch($_POST["contactid"]); } if ($_POST["socid"]) { $societe = new Societe($db); $societe->fetch($_POST["socid"]); } if ($_POST["actionid"]) { $actioncomm = new ActionComm($db); $actioncomm->type = $_POST["actionid"]; $actioncomm->priority = isset($_POST["priority"])?$_POST["priority"]:0; $actioncomm->libelle = $_POST["label"]; $actioncomm->date = $db->idate(mktime($_POST["heurehour"], $_POST["heuremin"], 0, $_POST["acmonth"], $_POST["acday"], $_POST["acyear"]) ); $actioncomm->percent = isset($_POST["percentage"])?$_POST["percentage"]:0; $actioncomm->user = $user; $actioncomm->societe = isset($_POST["socid"])?$_POST["socid"]:0; $actioncomm->contact = isset($_POST["contactid"])?$_POST["contactid"]:0; $actioncomm->note = $_POST["note"]; $actioncomm->add($user); if ($conf->webcal && $todo_webcal == 'on') { $webcal = new Webcal(); $webcal->heure = $heurehour . $heuremin . '00'; $webcal->duree = ($dureehour * 60) + $dureemin; if ($_POST["actionid"] == 5) { $libelle = "Rendez-vous avec ".$contact->fullname; $libelle .= "\n" . $actioncomm->libelle; } else { $libelle = $actioncomm->libelle; } $webcal->add($user, $actioncomm->date, $societe->nom, $libelle); } Header("Location: ".$_POST["from"]); } else { print "Le type d'action n'a pas été choisi"; } } /* * Action suppression de l'action * */ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') { $actioncomm = new ActionComm($db); $actioncomm->delete($_GET["id"]); Header("Location: index.php"); } /* * Action mise à jour de l'action * */ if ($_POST["action"] == 'update') { $action = new Actioncomm($db); $action->fetch($_POST["id"]); $action->percent = $_POST["percent"]; $action->contact->id = $_POST["contactid"]; $action->update(); Header("Location: ".$_POST["from"]); } llxHeader(); $html = new Form($db); /* ************************************************************************** */ /* */ /* Affichage fiche en mode création */ /* */ /* ************************************************************************** */ if ($_GET["action"] == 'create') { $caction = new CActioncomm($db); if ($_GET["contactid"]) { $contact = new Contact($db); $contact->fetch($_GET["contactid"]); } print '
'; print ''; print ''; /* * Si action de type Rendez-vous * */ if ($_GET["actionid"] == 5) { print_titre ($langs->trans("AddActionRendezVous")); print "
"; print ''."\n"; print ''; // Type d'action print ''; print ''; // Societe, contact print ''; // Si la societe est imposée, on propose ces contacts if ($_GET["socid"]) { print ''; } print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("Rendez-Vous").'
'.$langs->trans("ActionOnCompany").''; if ($_GET["socid"]) { $societe = new Societe($db); $nomsoc=$societe->get_nom($_GET["socid"]); print ''.$nomsoc.''; print ''; } else { print $html->select_societes('','socid',1,1); } print '
'.$langs->trans("ActionOnContact").''; print $html->select_contacts($_GET["socid"],'','contactid',1,1); print '
'.$langs->trans("Date").''; $html->select_date('','ac'); print '
'.$langs->trans("Hour").''; print_heure_select("heure",8,20); print '
'.$langs->trans("Duration").''; print_duree_select("duree"); print '
'.$langs->trans("Comment").''; print '
'; } /* * Si action de type autre que rendez-vous * */ else { print_titre ($langs->trans("AddAction")); print "
"; print ''; // Type d'action actifs print ''; print ''; // Societe, contact print ''; // Si la societe est imposée, on propose ces contacts if ($_GET["socid"]) { print ''; } // Avancement if ($_GET["afaire"] == 1) { print ''; print ''; print ''; } elseif ($_GET["afaire"] == 2) { print ''; print ''; } else { print ''; } // Date print ''; } else if ($_GET["afaire"] == 2) { print $html->select_date('','ac',1,1); print ''; } else { print $html->select_date('','ac',1,1); print ''; } print ''; // Lien avec celendrier si module activé if ($conf->webcal->enabled) { $langs->load("other"); print ''; } // Description print ''; print '
'.$langs->trans("Action").''; if ($_GET["actionid"]) { print ''."\n"; print $caction->get_nom($_GET["actionid"]); } else { $html->select_array("actionid", $caction->liste_array(1), 0); } print '
'.$langs->trans("Label").'
'.$langs->trans("ActionOnCompany").''; if ($_GET["socid"]) { $societe = new Societe($db); $nomsoc=$societe->get_nom($_GET["socid"]); print ''.$nomsoc.''; print ''; } else { print $html->select_societes('','socid',1,1); } print '
'.$langs->trans("ActionOnContact").''; print $html->select_contacts($_GET["socid"],'','contactid',1,1); print '
'.$langs->trans("Status").' / '.$langs->trans("Percentage").'To do / 0%
'.$langs->trans("Status").' / '.$langs->trans("Percentage").'Done / 100%
'.$langs->trans("Status").' / '.$langs->trans("Percentage").'
'.$langs->trans("Date").''; if ($_GET["afaire"] == 1) { print $html->select_date('','ac'); print '
'.$langs->trans("Hour").''; print_heure_select("heure",8,20); print '
'.$langs->trans("Hour").''; print_heure_select("heure",8,20); print '
'.$langs->trans("Hour").''; print_heure_select("heure",8,20); print '
'.$langs->trans("AddCalendarEntry").'
'.$langs->trans("Description").''; print '
'; print '

'; } print "
"; } /* * Affichage action en mode edition ou visu * */ if ($_GET["id"]) { $act = new ActionComm($db); $act->fetch($_GET["id"]); $act->societe->fetch($act->societe->id); $act->author->fetch($act->author->id); $act->contact->fetch($act->contact->id); /* * Affichage onglets */ $h = 0; $head[$h][0] = DOL_URL_ROOT.'/comm/action/fiche.php?id='.$_GET["id"]; $head[$h][1] = $langs->trans("CardAction"); $hselected=$h; $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("Ref")." ".$act->id); // Confirmation suppression action if ($_GET["action"] == 'delete') { $html->form_confirm("fiche.php?id=".$_GET["id"],$langs->trans("DeleteAction"),$langs->trans("ConfirmDeleteAction"),"confirm_delete"); } if ($_GET["action"] == 'edit') { // Fiche action en mode edition print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; if ($act->objet_url) { print ''; print ''; } if ($act->note) { print ''; } print ''; print '
'.$langs->trans("Type").''.$act->type.'
'.$langs->trans("Company").''.$act->societe->nom.''.$langs->trans("Contact").''; $html->select_array("contactid", $act->societe->contact_array(), $act->contact->id, 1); print '
'.$langs->trans("DateCreation").''.strftime('%d %B %Y %H:%M',$act->date).''.$langs->trans("Author").''.$act->author->fullname.'
'.$langs->trans("PercentDone").'%
Objet lié'.$act->objet_url.'
'.$langs->trans("Comment").''; print nl2br($act->note).'
'; } else { // Affichage fiche action en mode visu print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; if ($act->objet_url) { print ''; print ''; } if ($act->note) { print ''; } print '
'.$langs->trans("Type").''.$act->type.'
'.$langs->trans("Company").''.$act->societe->nom.''.$langs->trans("Contact").''.$act->contact->fullname.'
'.$langs->trans("DateCreation").''.strftime('%d %B %Y %H:%M',$act->date).''.$langs->trans("Author").''.$act->author->fullname.'
'.$langs->trans("PercentDone").''.$act->percent.' %
Objet lié'.$act->objet_url.'
'.$langs->trans("Comment").''; print nl2br($act->note).'
'; } print '
'; print "\n"; /* * Barre d'actions * */ print '
'; if ($_GET["action"] == 'edit') { print ''.$langs->trans("Cancel").''; } else { print ''.$langs->trans("Edit").''; } print ''.$langs->trans("Delete").''; print '
'; } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>