diff --git a/htdocs/actioncomm.class.php b/htdocs/actioncomm.class.php
index 3ab2cadd26e..09b81d98372 100644
--- a/htdocs/actioncomm.class.php
+++ b/htdocs/actioncomm.class.php
@@ -145,13 +145,13 @@ class ActionComm
$obj = $this->db->fetch_object($resql);
$this->id = $id;
- $this->type_id = $type_id;
+ $this->type_id = $obj->type_id;
$this->type_code = $obj->code;
$transcode=$langs->trans("Action".$obj->code);
$type_libelle=($transcode!="Action".$obj->code?$transcode:$obj->libelle);
$this->type = $type_libelle;
$this->label = $obj->label;
- $this->date = $obj->datea;
+ $this->date = $obj->datea;
$this->datep = $obj->datep;
$this->datec = $obj->datec;
$this->datem = $obj->datem;
@@ -216,10 +216,11 @@ class ActionComm
$sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm ";
$sql.= " SET percent='".$this->percent."'";
- if ($this->label) $sql.= ", label = '".addslashes($this->label)."'";
- if ($this->percent == 100) $sql.= ", datea = now()";
- if ($this->note) $sql.= ", note = '".addslashes($this->note)."'";
- if ($this->contact->id) $sql.= ", fk_contact =". $this->contact->id;
+ if ($this->label) $sql.= ", label = '".addslashes($this->label)."'";
+ $sql.= ", datep = ".($this->date_p ? "'".$this->db->idate($this->date_p)."'" : 'null');
+ $sql.= ", datea = ".($this->date_a ? "'".$this->db->idate($this->date_a)."'" : 'null');
+ if ($this->note) $sql.= ", note = '".addslashes($this->note)."'";
+ if ($this->contact->id) $sql.= ", fk_contact =". $this->contact->id;
$sql.= " WHERE id=".$this->id;
if ($this->db->query($sql))
diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php
index 68a83aced4f..418d632abfb 100644
--- a/htdocs/comm/action/fiche.php
+++ b/htdocs/comm/action/fiche.php
@@ -93,25 +93,34 @@ if ($_POST["action"] == 'add_action')
}
}
}
- $actioncomm->percent = isset($_POST["percentage"])?$_POST["percentage"]:0;
- if ($actioncomm->percent < 100)
- {
- $actioncomm->date_p = @mktime($_POST["heurephour"],
+ $actioncomm->date_p = @mktime($_POST["heurephour"],
$_POST["heurepmin"],
0,
$_POST["apmonth"],
$_POST["apday"],
$_POST["apyear"]);
- }
- if ($actioncomm->percent == 100)
- {
- $actioncomm->date_a = @mktime($_POST["heuredhour"],
+ $actioncomm->date_a = @mktime($_POST["heuredhour"],
$_POST["heuredmin"],
0,
$_POST["admonth"],
$_POST["adday"],
$_POST["adyear"]);
- }
+ if ($actioncomm->type_id == 5)
+ {
+ // RDV
+ if ($actioncomm->date_a)
+ {
+ $actioncomm->percent = 100;
+ }
+ else
+ {
+ $actioncomm->percent = 0;
+ }
+ }
+ else
+ {
+ $actioncomm->percent = isset($_POST["percentage"])?$_POST["percentage"]:0;
+ }
$actioncomm->duree=(($_POST["dureehour"] * 60) + $_POST["dureemin"]) * 60;
$actioncomm->user = $user;
$actioncomm->note = trim($_POST["note"]);
@@ -136,13 +145,13 @@ if ($_POST["action"] == 'add_action')
// Si erreur
$db->rollback();
$_GET["id"]=$idaction;
- $error=$actioncomm->error;
+ $error='
'.$actioncomm->error.'
';
}
}
else
{
$db->rollback();
- $error=$actioncomm->error;
+ $error=''.$actioncomm->error.'
';
}
}
else
@@ -176,15 +185,39 @@ if ($_POST["action"] == 'update')
{
$action = new Actioncomm($db);
$action->fetch($_POST["id"]);
+ $action->date_p = @mktime($_POST["heurephour"],
+ $_POST["heurepmin"],
+ 0,
+ $_POST["apmonth"],
+ $_POST["apday"],
+ $_POST["apyear"]);
+ $action->date_a = @mktime($_POST["heuredhour"],
+ $_POST["heuredmin"],
+ 0,
+ $_POST["admonth"],
+ $_POST["adday"],
+ $_POST["adyear"]);
$action->label = $_POST["label"];
$action->percent = $_POST["percent"];
$action->contact->id = $_POST["contactid"];
$action->note = $_POST["note"];
- $action->update();
+ if ($action->type_code == 'AC_RDV' && $action->percent == 100 && ! $action->date_a)
+ {
+ $action->date_a = $action->date_p;
+ }
+ $result=$action->update();
}
- Header("Location: ".$_POST["from"]);
- exit;
+ if ($result < 0)
+ {
+ $mesg=''.$action->error.'
';
+ $_GET["id"]=$_POST["id"];
+ }
+ else
+ {
+ Header("Location: ".$_POST["from"]);
+ exit;
+ }
}
@@ -265,7 +298,7 @@ if ($_GET["action"] == 'create')
print '';
// Date planification
- print '| '.$langs->trans("DatePlanned").' | ';
+ print ' |
| '.$langs->trans("DateActionPlanned").' | ';
if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2)
{
$html->select_date(-1,'ap','','','',"action");
@@ -281,7 +314,7 @@ if ($_GET["action"] == 'create')
print ' |
';
// Date done
- print '| '.$langs->trans("DateDone").' | ';
+ print ' |
| '.$langs->trans("DateActionDone").' | ';
if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2)
{
$html->select_date(-1,'ad','','','',"action");
@@ -428,7 +461,7 @@ if ($_GET["action"] == 'create')
}
// Date planification
- print ' |
| '.$langs->trans("DatePlanned").' | ';
+ print ' |
| '.$langs->trans("DateActionPlanned").' | ';
if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2)
{
$html->select_date(-1,'ap','','','',"action");
@@ -444,7 +477,7 @@ if ($_GET["action"] == 'create')
print ' |
';
// Date done
- print '| '.$langs->trans("DateDone").' | ';
+ print ' |
| '.$langs->trans("DateActionDone").' | ';
if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2)
{
$html->select_date(-1,'ad','','','',"action");
@@ -495,6 +528,10 @@ if ($_GET["id"])
{
print ' '.$error.' ';
}
+ if ($mesg)
+ {
+ print $mesg.' ';
+ }
$act = new ActionComm($db);
$act->fetch($_GET["id"]);
@@ -560,13 +597,22 @@ if ($_GET["id"])
print $langs->trans("FeatureNotYetSupported");
print ' |
';
- // Date debut
- print '| '.$langs->trans("DateActionPlanned").' | '.dolibarr_print_date($act->datep,'%d %B %Y %H:%M').' |
';
-
- // Date fin real
- print '| '.$langs->trans("DateActionDone").' | '.dolibarr_print_date($act->date,'%d %B %Y %H:%M').' |
';
+ // Date planification
+ print '| '.$langs->trans("DateActionPlanned").' | ';
+ $html->select_date(($act->datep?$act->datep:-1),'ap','','','',"action");
+ print ' ';
+ print_heure_select("heurep",8,20);
+ print ' |
';
- // Etat
+ // Date done
+ print '| '.$langs->trans("DateActionDone").' | ';
+ $html->select_date(($act->date?$act->date:-1),'ad','','','',"action");
+ print ' ';
+ print_heure_select("heured",8,20);
+ print ' |
';
+
+
+ // Etat
print '| '.$langs->trans("Status").' / '.$langs->trans("Percentage").' | % |
';
// Objet lié
diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php
index 492c9e23a4b..74bb635ffeb 100644
--- a/htdocs/lib/functions.inc.php
+++ b/htdocs/lib/functions.inc.php
@@ -1714,22 +1714,22 @@ function print_heure_select($prefix,$begin=1,$end=23)
\param prefix prefix
*/
function print_duree_select($prefix)
-{
- print ' H ";
+ print '';
+ for ($min = 0 ; $min < 55 ; $min=$min+5)
+ {
+ print "";
+ }
+ print "\n";
}