forked from Wavyzz/dolibarr
On peut modifier date planif et real d'une action
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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='<div class="error">'.$actioncomm->error.'</div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$error=$actioncomm->error;
|
||||
$error='<div class="error">'.$actioncomm->error.'</div>';
|
||||
}
|
||||
}
|
||||
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='<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>';
|
||||
|
||||
// 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)
|
||||
{
|
||||
$html->select_date(-1,'ap','','','',"action");
|
||||
@@ -281,7 +314,7 @@ if ($_GET["action"] == 'create')
|
||||
print '</td></tr>';
|
||||
|
||||
// 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)
|
||||
{
|
||||
$html->select_date(-1,'ad','','','',"action");
|
||||
@@ -428,7 +461,7 @@ if ($_GET["action"] == 'create')
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
$html->select_date(-1,'ap','','','',"action");
|
||||
@@ -444,7 +477,7 @@ if ($_GET["action"] == 'create')
|
||||
print '</td></tr>';
|
||||
|
||||
// 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)
|
||||
{
|
||||
$html->select_date(-1,'ad','','','',"action");
|
||||
@@ -495,6 +528,10 @@ if ($_GET["id"])
|
||||
{
|
||||
print '<div class="error">'.$error.'</div><br>';
|
||||
}
|
||||
if ($mesg)
|
||||
{
|
||||
print $mesg.'<br>';
|
||||
}
|
||||
|
||||
$act = new ActionComm($db);
|
||||
$act->fetch($_GET["id"]);
|
||||
@@ -560,13 +597,22 @@ if ($_GET["id"])
|
||||
print $langs->trans("FeatureNotYetSupported");
|
||||
print '</td></tr>';
|
||||
|
||||
// Date debut
|
||||
print '<tr><td>'.$langs->trans("DateActionPlanned").'</td><td colspan="3">'.dolibarr_print_date($act->datep,'%d %B %Y %H:%M').'</td></tr>';
|
||||
|
||||
// Date fin real
|
||||
print '<tr><td>'.$langs->trans("DateActionDone").'</td><td colspan="3">'.dolibarr_print_date($act->date,'%d %B %Y %H:%M').'</td></tr>';
|
||||
// Date planification
|
||||
print '<tr><td>'.$langs->trans("DateActionPlanned").'</td><td colspan="3">';
|
||||
$html->select_date(($act->datep?$act->datep:-1),'ap','','','',"action");
|
||||
print ' ';
|
||||
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 ' ';
|
||||
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>';
|
||||
|
||||
// Objet li<6C>
|
||||
|
||||
@@ -1714,22 +1714,22 @@ function print_heure_select($prefix,$begin=1,$end=23)
|
||||
\param prefix prefix
|
||||
*/
|
||||
function print_duree_select($prefix)
|
||||
{
|
||||
print '<select name="'.$prefix.'hour">';
|
||||
print "<option value=\"0\">0</option>";
|
||||
print "<option value=\"1\" selected=\"true\">1</option>";
|
||||
{
|
||||
print '<select class="flat" name="'.$prefix.'hour">';
|
||||
print "<option value=\"0\">0</option>";
|
||||
print "<option value=\"1\" selected=\"true\">1</option>";
|
||||
|
||||
for ($hour = 2 ; $hour < 13 ; $hour++)
|
||||
{
|
||||
print "<option value=\"$hour\">$hour</option>";
|
||||
}
|
||||
print "</select> H ";
|
||||
print '<select name="'.$prefix.'min">';
|
||||
for ($min = 0 ; $min < 55 ; $min=$min+5)
|
||||
{
|
||||
print "<option value=\"$min\">$min</option>";
|
||||
}
|
||||
print "</select>\n";
|
||||
for ($hour = 2 ; $hour < 13 ; $hour++)
|
||||
{
|
||||
print "<option value=\"$hour\">$hour</option>";
|
||||
}
|
||||
print "</select> H ";
|
||||
print '<select class="flat" name="'.$prefix.'min">';
|
||||
for ($min = 0 ; $min < 55 ; $min=$min+5)
|
||||
{
|
||||
print "<option value=\"$min\">$min</option>";
|
||||
}
|
||||
print "</select>\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user