diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 73374c409db..e2014703f92 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -21,6 +21,8 @@ */ require("./pre.inc.php"); +$langs->load("company"); + require("../../contact.class.php"); require("../../lib/webcal.class.php"); require("../../cactioncomm.class.php"); @@ -47,58 +49,38 @@ if ($_POST["action"] == 'add_action') $contact = new Contact($db); $contact->fetch($_POST["contactid"]); } - $societe = new Societe($db); - $societe->fetch($_POST["socid"]); - - if ($_POST["afaire"] <> 1) + if ($_POST["socid"]) { - $actioncomm = new ActionComm($db); - - $actioncomm->priority = 2; - $actioncomm->type = $_POST["actionid"]; - - $actioncomm->date = $db->idate(mktime($_POST["heurehour"], - $_POST["heuremin"], - 0, - $_POST["acmonth"], - $_POST["acday"], - $_POST["acyear"]) - ); - if ($_POST["actionid"] == 5) - { - $actioncomm->percent = 0; - } - else - { - $actioncomm->percent = 100; - } - - $actioncomm->contact = $_POST["contactid"]; - - $actioncomm->user = $user; - - $actioncomm->societe = $_POST["socid"]; - $actioncomm->note = $_POST["note"]; - - $actioncomm->add($user); + $societe = new Societe($db); + $societe->fetch($_POST["socid"]); } - if ($todo == 'on' ) - { + if ($_POST["actionid"]) { - $todo = new ActionComm($db); - $todo->type = $_POST["nextactionid"]; - $todo->date = $db->idate(mktime(12,0,0,$remonth, $reday, $reyear)); - $todo->libelle = $todo_label; - $todo->priority = 2; - $todo->societe = $societe->id; - $todo->contact = $contactid; - $todo->user = $user; - $todo->note = $todo_note; - $todo->percent = 0; - - $todo->add($user); - + $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(); @@ -106,166 +88,220 @@ if ($_POST["action"] == 'add_action') $webcal->heure = $heurehour . $heuremin . '00'; $webcal->duree = ($dureehour * 60) + $dureemin; - if ($actionid == 5) + if ($_POST["actionid"] == 5) { $libelle = "Rendez-vous avec ".$contact->fullname; - $libelle .= "\n" . $todo->libelle; + $libelle .= "\n" . $actioncomm->libelle; } else { - $libelle = $todo->libelle; + $libelle = $actioncomm->libelle; } - $webcal->add($user, $todo->date, $societe->nom, $libelle); + $webcal->add($user, $actioncomm->date, $societe->nom, $libelle); } - } + // Header("Location: ".DOL_URL_ROOT."/comm/fiche.php?socid=$socid"); Header("Location: ".$_POST["from"]); + + } else { + + print "Le type d'action n'a pas été choisi"; + + } + } -if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == yes) +if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') { $actioncomm = new ActionComm($db); $actioncomm->delete($id); Header("Location: index.php"); } -if ($action=='update') +if ($_POST["action"] == 'update') { $action = new Actioncomm($db); - $action->fetch($id); + $action->fetch($_POST["id"]); $action->percent = $_POST["percent"]; - $action->contact->id = $_POST["scontactid"]; + $action->contact->id = $_POST["contactid"]; $action->update(); + + Header("Location: ".$_POST["from"]); } -/******************************************************************************/ -/* */ -/* Fin des Actions */ -/* */ -/******************************************************************************/ + + llxHeader(); + $html = new Form($db); + + /* - * - * + * Affichage fiche action vierge en mode creation * */ if ($_GET["action"] == 'create') { - $caction = new CActioncomm($db); - if ($_GET["afaire"] <> 1) + if ($_GET["contactid"]) { - $caction->fetch($db, $_GET["actionid"]); $contact = new Contact($db); $contact->fetch($_GET["contactid"]); } - $societe = new Societe($db); - $societe->get_nom($_GET["socid"]); - - print '