2
0
forked from Wavyzz/dolibarr

On peut modifier date planif et real d'une action

This commit is contained in:
Laurent Destailleur
2006-09-09 14:40:46 +00:00
parent 525a93b2a4
commit 280ee38b9d
3 changed files with 92 additions and 45 deletions

View File

@@ -145,13 +145,13 @@ class ActionComm
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $id; $this->id = $id;
$this->type_id = $type_id; $this->type_id = $obj->type_id;
$this->type_code = $obj->code; $this->type_code = $obj->code;
$transcode=$langs->trans("Action".$obj->code); $transcode=$langs->trans("Action".$obj->code);
$type_libelle=($transcode!="Action".$obj->code?$transcode:$obj->libelle); $type_libelle=($transcode!="Action".$obj->code?$transcode:$obj->libelle);
$this->type = $type_libelle; $this->type = $type_libelle;
$this->label = $obj->label; $this->label = $obj->label;
$this->date = $obj->datea; $this->date = $obj->datea;
$this->datep = $obj->datep; $this->datep = $obj->datep;
$this->datec = $obj->datec; $this->datec = $obj->datec;
$this->datem = $obj->datem; $this->datem = $obj->datem;
@@ -216,10 +216,11 @@ class ActionComm
$sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm ";
$sql.= " SET percent='".$this->percent."'"; $sql.= " SET percent='".$this->percent."'";
if ($this->label) $sql.= ", label = '".addslashes($this->label)."'"; if ($this->label) $sql.= ", label = '".addslashes($this->label)."'";
if ($this->percent == 100) $sql.= ", datea = now()"; $sql.= ", datep = ".($this->date_p ? "'".$this->db->idate($this->date_p)."'" : 'null');
if ($this->note) $sql.= ", note = '".addslashes($this->note)."'"; $sql.= ", datea = ".($this->date_a ? "'".$this->db->idate($this->date_a)."'" : 'null');
if ($this->contact->id) $sql.= ", fk_contact =". $this->contact->id; if ($this->note) $sql.= ", note = '".addslashes($this->note)."'";
if ($this->contact->id) $sql.= ", fk_contact =". $this->contact->id;
$sql.= " WHERE id=".$this->id; $sql.= " WHERE id=".$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))

View File

@@ -93,25 +93,34 @@ if ($_POST["action"] == 'add_action')
} }
} }
} }
$actioncomm->percent = isset($_POST["percentage"])?$_POST["percentage"]:0; $actioncomm->date_p = @mktime($_POST["heurephour"],
if ($actioncomm->percent < 100)
{
$actioncomm->date_p = @mktime($_POST["heurephour"],
$_POST["heurepmin"], $_POST["heurepmin"],
0, 0,
$_POST["apmonth"], $_POST["apmonth"],
$_POST["apday"], $_POST["apday"],
$_POST["apyear"]); $_POST["apyear"]);
} $actioncomm->date_a = @mktime($_POST["heuredhour"],
if ($actioncomm->percent == 100)
{
$actioncomm->date_a = @mktime($_POST["heuredhour"],
$_POST["heuredmin"], $_POST["heuredmin"],
0, 0,
$_POST["admonth"], $_POST["admonth"],
$_POST["adday"], $_POST["adday"],
$_POST["adyear"]); $_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->duree=(($_POST["dureehour"] * 60) + $_POST["dureemin"]) * 60;
$actioncomm->user = $user; $actioncomm->user = $user;
$actioncomm->note = trim($_POST["note"]); $actioncomm->note = trim($_POST["note"]);
@@ -136,13 +145,13 @@ if ($_POST["action"] == 'add_action')
// Si erreur // Si erreur
$db->rollback(); $db->rollback();
$_GET["id"]=$idaction; $_GET["id"]=$idaction;
$error=$actioncomm->error; $error='<div class="error">'.$actioncomm->error.'</div>';
} }
} }
else else
{ {
$db->rollback(); $db->rollback();
$error=$actioncomm->error; $error='<div class="error">'.$actioncomm->error.'</div>';
} }
} }
else else
@@ -176,15 +185,39 @@ if ($_POST["action"] == 'update')
{ {
$action = new Actioncomm($db); $action = new Actioncomm($db);
$action->fetch($_POST["id"]); $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->label = $_POST["label"];
$action->percent = $_POST["percent"]; $action->percent = $_POST["percent"];
$action->contact->id = $_POST["contactid"]; $action->contact->id = $_POST["contactid"];
$action->note = $_POST["note"]; $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"]); if ($result < 0)
exit; {
$mesg='<div class="error">'.$action->error.'</div>';
$_GET["id"]=$_POST["id"];
}
else
{
Header("Location: ".$_POST["from"]);
exit;
}
} }
@@ -265,7 +298,7 @@ if ($_GET["action"] == 'create')
print '</td></tr>'; print '</td></tr>';
// Date planification // Date planification
print '<tr><td>'.$langs->trans("DatePlanned").'</td><td>'; print '<tr><td>'.$langs->trans("DateActionPlanned").'</td><td>';
if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2) if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2)
{ {
$html->select_date(-1,'ap','','','',"action"); $html->select_date(-1,'ap','','','',"action");
@@ -281,7 +314,7 @@ if ($_GET["action"] == 'create')
print '</td></tr>'; print '</td></tr>';
// Date done // Date done
print '<tr><td>'.$langs->trans("DateDone").'</td><td>'; print '<tr><td>'.$langs->trans("DateActionDone").'</td><td>';
if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2) if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2)
{ {
$html->select_date(-1,'ad','','','',"action"); $html->select_date(-1,'ad','','','',"action");
@@ -428,7 +461,7 @@ if ($_GET["action"] == 'create')
} }
// Date planification // Date planification
print '<tr><td>'.$langs->trans("DatePlanned").'</td><td>'; print '<tr><td>'.$langs->trans("DateActionPlanned").'</td><td>';
if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2) if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2)
{ {
$html->select_date(-1,'ap','','','',"action"); $html->select_date(-1,'ap','','','',"action");
@@ -444,7 +477,7 @@ if ($_GET["action"] == 'create')
print '</td></tr>'; print '</td></tr>';
// Date done // Date done
print '<tr><td>'.$langs->trans("DateDone").'</td><td>'; print '<tr><td>'.$langs->trans("DateActionDone").'</td><td>';
if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2) if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2)
{ {
$html->select_date(-1,'ad','','','',"action"); $html->select_date(-1,'ad','','','',"action");
@@ -495,6 +528,10 @@ if ($_GET["id"])
{ {
print '<div class="error">'.$error.'</div><br>'; print '<div class="error">'.$error.'</div><br>';
} }
if ($mesg)
{
print $mesg.'<br>';
}
$act = new ActionComm($db); $act = new ActionComm($db);
$act->fetch($_GET["id"]); $act->fetch($_GET["id"]);
@@ -560,13 +597,22 @@ if ($_GET["id"])
print $langs->trans("FeatureNotYetSupported"); print $langs->trans("FeatureNotYetSupported");
print '</td></tr>'; print '</td></tr>';
// Date debut // Date planification
print '<tr><td>'.$langs->trans("DateActionPlanned").'</td><td colspan="3">'.dolibarr_print_date($act->datep,'%d %B %Y %H:%M').'</td></tr>'; print '<tr><td>'.$langs->trans("DateActionPlanned").'</td><td colspan="3">';
$html->select_date(($act->datep?$act->datep:-1),'ap','','','',"action");
// Date fin real print ' &nbsp; ';
print '<tr><td>'.$langs->trans("DateActionDone").'</td><td colspan="3">'.dolibarr_print_date($act->date,'%d %B %Y %H:%M').'</td></tr>'; print_heure_select("heurep",8,20);
print '</td></tr>';
// Etat // Date done
print '<tr><td>'.$langs->trans("DateActionDone").'</td><td colspan="3">';
$html->select_date(($act->date?$act->date:-1),'ad','','','',"action");
print ' &nbsp; ';
print_heure_select("heured",8,20);
print '</td></tr>';
// Etat
print '<tr><td nowrap>'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="3"><input name="percent" value="'.$act->percent.'" size="4">%</td></tr>'; print '<tr><td nowrap>'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="3"><input name="percent" value="'.$act->percent.'" size="4">%</td></tr>';
// Objet li<6C> // Objet li<6C>

View File

@@ -1714,22 +1714,22 @@ function print_heure_select($prefix,$begin=1,$end=23)
\param prefix prefix \param prefix prefix
*/ */
function print_duree_select($prefix) function print_duree_select($prefix)
{ {
print '<select name="'.$prefix.'hour">'; print '<select class="flat" name="'.$prefix.'hour">';
print "<option value=\"0\">0</option>"; print "<option value=\"0\">0</option>";
print "<option value=\"1\" selected=\"true\">1</option>"; print "<option value=\"1\" selected=\"true\">1</option>";
for ($hour = 2 ; $hour < 13 ; $hour++) for ($hour = 2 ; $hour < 13 ; $hour++)
{ {
print "<option value=\"$hour\">$hour</option>"; print "<option value=\"$hour\">$hour</option>";
} }
print "</select>&nbsp;H&nbsp;"; print "</select>&nbsp;H&nbsp;";
print '<select name="'.$prefix.'min">'; print '<select class="flat" name="'.$prefix.'min">';
for ($min = 0 ; $min < 55 ; $min=$min+5) for ($min = 0 ; $min < 55 ; $min=$min+5)
{ {
print "<option value=\"$min\">$min</option>"; print "<option value=\"$min\">$min</option>";
} }
print "</select>\n"; print "</select>\n";
} }