Fix: Mauvaise récupération paramètre des actions.

This commit is contained in:
Laurent Destailleur 2005-07-07 21:50:14 +00:00
parent 0bb3b59df5
commit beff6c9b2d
2 changed files with 110 additions and 99 deletions

View File

@ -84,7 +84,7 @@ class ActionComm
$sql.= "fk_facture,propalrowid)"; $sql.= "fk_facture,propalrowid)";
$sql.= " VALUES (now(), '".$this->type_code."', '".$this->societe->id."' ,'".addslashes($this->note)."',"; $sql.= " VALUES (now(), '".$this->type_code."', '".$this->societe->id."' ,'".addslashes($this->note)."',";
$sql.= ($this->contact->id?$this->contact->id:"null").","; $sql.= ($this->contact->id?$this->contact->id:"null").",";
$sql.= "'$author->id', '".$this->user->id ."', '".$this->label."',100,'".$this->priority."',"; $sql.= "'$author->id', '".$this->user->id ."', '".addslashes($this->label)."','".$this->percent."','".$this->priority."',";
$sql.= ($this->facid?$this->facid:"null").","; $sql.= ($this->facid?$this->facid:"null").",";
$sql.= ($this->propalrowid?$this->propalrowid:"null"); $sql.= ($this->propalrowid?$this->propalrowid:"null");
$sql.= ");"; $sql.= ");";

View File

@ -57,110 +57,121 @@ if ($user->societe_id > 0)
*/ */
if ($_POST["action"] == 'add_action') if ($_POST["action"] == 'add_action')
{ {
if ($_POST["contactid"]) if ($_POST["contactid"])
{ {
$contact = new Contact($db); $contact = new Contact($db);
$contact->fetch($_POST["contactid"]); $contact->fetch($_POST["contactid"]);
} }
if ($_POST["socid"]) if ($_POST["socid"])
{ {
$societe = new Societe($db); $societe = new Societe($db);
$societe->fetch($_POST["socid"]); $societe->fetch($_POST["socid"]);
} }
if ($_POST["actionid"]) if ($_POST["actionid"])
{ {
$db->begin();
$actioncomm = new ActionComm($db); $actioncomm = new ActionComm($db);
$actioncomm->type = $_POST["actionid"]; $actioncomm->type_code = $_POST["actionid"];
$actioncomm->priority = isset($_POST["priority"])?$_POST["priority"]:0; $actioncomm->priority = isset($_POST["priority"])?$_POST["priority"]:0;
if ($_POST["actionid"] == 5) if ($_POST["actionid"] == 5)
{ {
if ($contact->fullname) { $actioncomm->libelle = $langs->trans("TaskRDVWith",$contact->fullname); } if ($contact->fullname) { $actioncomm->label = $langs->trans("TaskRDVWith",$contact->fullname); }
else { $actioncomm->libelle = $langs->trans("TaskRDV"); } else { $actioncomm->label = $langs->trans("TaskRDV"); }
} else { } else {
$actioncomm->libelle = $_POST["label"]; $actioncomm->label = $_POST["label"];
} }
$actioncomm->date = $db->idate(mktime($_POST["heurehour"], $actioncomm->date = $db->idate(mktime($_POST["heurehour"],
$_POST["heuremin"], $_POST["heuremin"],
0, 0,
$_POST["acmonth"], $_POST["acmonth"],
$_POST["acday"], $_POST["acday"],
$_POST["acyear"]) $_POST["acyear"])
); );
$actioncomm->percent = isset($_POST["percentage"])?$_POST["percentage"]:0; $actioncomm->percent = isset($_POST["percentage"])?$_POST["percentage"]:0;
$actioncomm->user = $user; $actioncomm->user = $user;
$actioncomm->societe = isset($_POST["socid"])?$_POST["socid"]:0; if (isset($_POST["contactid"]))
$actioncomm->contact = isset($_POST["contactid"])?$_POST["contactid"]:0; {
$actioncomm->note = $_POST["note"]; $actioncomm->contact = $contact;
}
if (isset($_POST["socid"]))
{
$actioncomm->societe = $societe;
}
$actioncomm->note = $_POST["note"];
// On definit la ressource webcal si le module webcal est actif // On definit la ressource webcal si le module webcal est actif
$webcal=0; $webcal=0;
if ($conf->webcal->enabled && $_POST["todo_webcal"] == 'on') if ($conf->webcal->enabled && $_POST["todo_webcal"] == 'on')
{ {
$webcal = new Webcal(); $webcal = new Webcal();
if (! $webcal->localdb->ok) if (! $webcal->localdb->ok)
{ {
// Si la creation de l'objet n'as pu se connecter // Si la creation de l'objet n'as pu se connecter
$error="Dolibarr n'a pu se connecter à la base Webcalendar avec les identifiants définis (host=".$conf->webcal->db->host." dbname=".$conf->webcal->db->name." user=".$conf->webcal->db->user."). L'option de mise a jour Webcalendar a été ignorée."; $error="Dolibarr n'a pu se connecter à la base Webcalendar avec les identifiants définis (host=".$conf->webcal->db->host." dbname=".$conf->webcal->db->name." user=".$conf->webcal->db->user."). L'option de mise a jour Webcalendar a été ignorée.";
$webcal=-1; $webcal=-1;
} }
else else
{ {
$webcal->heure = $_POST["heurehour"] . $_POST["heuremin"] . '00'; $webcal->heure = $_POST["heurehour"] . $_POST["heuremin"] . '00';
$webcal->duree = ($_POST["dureehour"] * 60) + $_POST["dureemin"]; $webcal->duree = ($_POST["dureehour"] * 60) + $_POST["dureemin"];
if ($_POST["actionid"] == 5) if ($_POST["actionid"] == 5)
{ {
$libellecal = $langs->trans("TaskRDVWith",$contact->fullname); $libellecal = $langs->trans("TaskRDVWith",$contact->fullname);
$libellecal .= "\n" . $actioncomm->libelle; $libellecal .= "\n" . $actioncomm->libelle;
} }
else else
{ {
$libellecal = $actioncomm->libelle; $libellecal = $actioncomm->libelle;
} }
$webcal->date=mktime($_POST["heurehour"], $webcal->date=mktime($_POST["heurehour"],
$_POST["heuremin"], $_POST["heuremin"],
0, 0,
$_POST["acmonth"], $_POST["acmonth"],
$_POST["acday"], $_POST["acday"],
$_POST["acyear"]); $_POST["acyear"]);
$webcal->texte=$societe->nom; $webcal->texte=$societe->nom;
$webcal->desc=$libellecal; $webcal->desc=$libellecal;
} }
} }
// On crée l'action (avec ajout eventuel dans webcal si défini) // On crée l'action (avec ajout eventuel dans webcal si défini)
$idaction=$actioncomm->add($user, $webcal); $idaction=$actioncomm->add($user, $webcal);
if ($idaction > 0) if ($idaction > 0)
{ {
if (! $actioncomm->error) if (! $actioncomm->error)
{ {
// Si pas d'erreur // Si pas d'erreur
Header("Location: ".$_POST["from"]); $db->commit();
} Header("Location: ".$_POST["from"]);
else }
{ else
// Si erreur {
$_GET["id"]=$idaction; // Si erreur
$error=$actioncomm->error; $db->rollback();
} $_GET["id"]=$idaction;
} $error=$actioncomm->error;
else }
{ }
dolibarr_print_error($db); else
} {
$db->rollback();
$_GET["id"]=$idaction;
dolibarr_print_error($db);
}
} }
else else
{ {
print "Le type d'action n'a pas été choisi"; print "Le type d'action n'a pas été choisi";
} }
} }