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

@ -55,114 +55,125 @@ if ($user->societe_id > 0)
* Action création de l'action * Action création de l'action
* *
*/ */
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->priority = isset($_POST["priority"])?$_POST["priority"]:0; $actioncomm->type_code = $_POST["actionid"];
if ($_POST["actionid"] == 5) $actioncomm->priority = isset($_POST["priority"])?$_POST["priority"]:0;
{ if ($_POST["actionid"] == 5)
if ($contact->fullname) { $actioncomm->libelle = $langs->trans("TaskRDVWith",$contact->fullname); } {
else { $actioncomm->libelle = $langs->trans("TaskRDV"); } if ($contact->fullname) { $actioncomm->label = $langs->trans("TaskRDVWith",$contact->fullname); }
} else { else { $actioncomm->label = $langs->trans("TaskRDV"); }
$actioncomm->libelle = $_POST["label"]; } else {
} $actioncomm->label = $_POST["label"];
$actioncomm->date = $db->idate(mktime($_POST["heurehour"], }
$_POST["heuremin"], $actioncomm->date = $db->idate(mktime($_POST["heurehour"],
0, $_POST["heuremin"],
$_POST["acmonth"], 0,
$_POST["acday"], $_POST["acmonth"],
$_POST["acyear"]) $_POST["acday"],
); $_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;
$actioncomm->contact = isset($_POST["contactid"])?$_POST["contactid"]:0; if (isset($_POST["contactid"]))
$actioncomm->note = $_POST["note"]; {
$actioncomm->contact = $contact;
// On definit la ressource webcal si le module webcal est actif }
$webcal=0; if (isset($_POST["socid"]))
if ($conf->webcal->enabled && $_POST["todo_webcal"] == 'on') {
{ $actioncomm->societe = $societe;
$webcal = new Webcal(); }
$actioncomm->note = $_POST["note"];
if (! $webcal->localdb->ok)
{ // On definit la ressource webcal si le module webcal est actif
// Si la creation de l'objet n'as pu se connecter $webcal=0;
$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."; if ($conf->webcal->enabled && $_POST["todo_webcal"] == 'on')
$webcal=-1; {
} $webcal = new Webcal();
else
{ if (! $webcal->localdb->ok)
$webcal->heure = $_POST["heurehour"] . $_POST["heuremin"] . '00'; {
$webcal->duree = ($_POST["dureehour"] * 60) + $_POST["dureemin"]; // 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.";
if ($_POST["actionid"] == 5) $webcal=-1;
{ }
$libellecal = $langs->trans("TaskRDVWith",$contact->fullname); else
$libellecal .= "\n" . $actioncomm->libelle; {
} $webcal->heure = $_POST["heurehour"] . $_POST["heuremin"] . '00';
else $webcal->duree = ($_POST["dureehour"] * 60) + $_POST["dureemin"];
{
$libellecal = $actioncomm->libelle; if ($_POST["actionid"] == 5)
} {
$libellecal = $langs->trans("TaskRDVWith",$contact->fullname);
$webcal->date=mktime($_POST["heurehour"], $libellecal .= "\n" . $actioncomm->libelle;
$_POST["heuremin"], }
0, else
$_POST["acmonth"], {
$_POST["acday"], $libellecal = $actioncomm->libelle;
$_POST["acyear"]); }
$webcal->texte=$societe->nom;
$webcal->desc=$libellecal; $webcal->date=mktime($_POST["heurehour"],
} $_POST["heuremin"],
} 0,
$_POST["acmonth"],
// On crée l'action (avec ajout eventuel dans webcal si défini) $_POST["acday"],
$idaction=$actioncomm->add($user, $webcal); $_POST["acyear"]);
$webcal->texte=$societe->nom;
if ($idaction > 0) $webcal->desc=$libellecal;
{ }
if (! $actioncomm->error) }
{
// Si pas d'erreur // On crée l'action (avec ajout eventuel dans webcal si défini)
Header("Location: ".$_POST["from"]); $idaction=$actioncomm->add($user, $webcal);
}
else if ($idaction > 0)
{ {
// Si erreur if (! $actioncomm->error)
$_GET["id"]=$idaction; {
$error=$actioncomm->error; // Si pas d'erreur
} $db->commit();
} Header("Location: ".$_POST["from"]);
else }
{ else
dolibarr_print_error($db); {
} // Si erreur
$db->rollback();
$_GET["id"]=$idaction;
$error=$actioncomm->error;
}
}
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";
} }
} }
/* /*