From beff6c9b2dd14dc220b3438ffe25d697368e465b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Jul 2005 21:50:14 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20Mauvaise=20r=E9cup=E9ration=20param=E8tr?= =?UTF-8?q?e=20des=20actions.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/actioncomm.class.php | 2 +- htdocs/comm/action/fiche.php | 207 ++++++++++++++++++----------------- 2 files changed, 110 insertions(+), 99 deletions(-) diff --git a/htdocs/actioncomm.class.php b/htdocs/actioncomm.class.php index 9a062fdd74f..7cc38753335 100644 --- a/htdocs/actioncomm.class.php +++ b/htdocs/actioncomm.class.php @@ -84,7 +84,7 @@ class ActionComm $sql.= "fk_facture,propalrowid)"; $sql.= " VALUES (now(), '".$this->type_code."', '".$this->societe->id."' ,'".addslashes($this->note)."',"; $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->propalrowid?$this->propalrowid:"null"); $sql.= ");"; diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index f8fdf604a4d..36784bdd2e0 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -55,114 +55,125 @@ if ($user->societe_id > 0) * 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->fetch($_POST["contactid"]); + $contact = new Contact($db); + $contact->fetch($_POST["contactid"]); } - if ($_POST["socid"]) + if ($_POST["socid"]) { - $societe = new Societe($db); - $societe->fetch($_POST["socid"]); + $societe = new Societe($db); + $societe->fetch($_POST["socid"]); } - if ($_POST["actionid"]) + if ($_POST["actionid"]) { - - $actioncomm = new ActionComm($db); - - $actioncomm->type = $_POST["actionid"]; - $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"); } - } else { - $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"]; - - // On definit la ressource webcal si le module webcal est actif - $webcal=0; - if ($conf->webcal->enabled && $_POST["todo_webcal"] == 'on') - { - $webcal = new Webcal(); - - if (! $webcal->localdb->ok) - { - // 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."; - $webcal=-1; - } - else - { - $webcal->heure = $_POST["heurehour"] . $_POST["heuremin"] . '00'; - $webcal->duree = ($_POST["dureehour"] * 60) + $_POST["dureemin"]; - - if ($_POST["actionid"] == 5) - { - $libellecal = $langs->trans("TaskRDVWith",$contact->fullname); - $libellecal .= "\n" . $actioncomm->libelle; - } - else - { - $libellecal = $actioncomm->libelle; - } - - $webcal->date=mktime($_POST["heurehour"], - $_POST["heuremin"], - 0, - $_POST["acmonth"], - $_POST["acday"], - $_POST["acyear"]); - $webcal->texte=$societe->nom; - $webcal->desc=$libellecal; - } - } - - // On crée l'action (avec ajout eventuel dans webcal si défini) - $idaction=$actioncomm->add($user, $webcal); - - if ($idaction > 0) - { - if (! $actioncomm->error) - { - // Si pas d'erreur - Header("Location: ".$_POST["from"]); - } - else - { - // Si erreur - $_GET["id"]=$idaction; - $error=$actioncomm->error; - } - } - else - { - dolibarr_print_error($db); - } + $db->begin(); + + $actioncomm = new ActionComm($db); + + $actioncomm->type_code = $_POST["actionid"]; + $actioncomm->priority = isset($_POST["priority"])?$_POST["priority"]:0; + if ($_POST["actionid"] == 5) + { + if ($contact->fullname) { $actioncomm->label = $langs->trans("TaskRDVWith",$contact->fullname); } + else { $actioncomm->label = $langs->trans("TaskRDV"); } + } else { + $actioncomm->label = $_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; + + if (isset($_POST["contactid"])) + { + $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 + $webcal=0; + if ($conf->webcal->enabled && $_POST["todo_webcal"] == 'on') + { + $webcal = new Webcal(); + + if (! $webcal->localdb->ok) + { + // 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."; + $webcal=-1; + } + else + { + $webcal->heure = $_POST["heurehour"] . $_POST["heuremin"] . '00'; + $webcal->duree = ($_POST["dureehour"] * 60) + $_POST["dureemin"]; + + if ($_POST["actionid"] == 5) + { + $libellecal = $langs->trans("TaskRDVWith",$contact->fullname); + $libellecal .= "\n" . $actioncomm->libelle; + } + else + { + $libellecal = $actioncomm->libelle; + } + + $webcal->date=mktime($_POST["heurehour"], + $_POST["heuremin"], + 0, + $_POST["acmonth"], + $_POST["acday"], + $_POST["acyear"]); + $webcal->texte=$societe->nom; + $webcal->desc=$libellecal; + } + } + + // On crée l'action (avec ajout eventuel dans webcal si défini) + $idaction=$actioncomm->add($user, $webcal); + + if ($idaction > 0) + { + if (! $actioncomm->error) + { + // Si pas d'erreur + $db->commit(); + Header("Location: ".$_POST["from"]); + } + else + { + // 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"; } - + } /*