Fix: Date ral mal renseigne

This commit is contained in:
Laurent Destailleur 2006-09-16 00:14:11 +00:00
parent 9e08f34f31
commit 05289ec490
4 changed files with 77 additions and 55 deletions

View File

@ -41,11 +41,11 @@ class ActionComm
var $type_code;
var $type;
var $label;
var $datec; // Date creation enregistrement
var $datep; // Date action planifie debut
var $datec; // Date creation enregistrement (datec)
var $datem; // Date modif enregistrement (tms)
var $datep; // Date action planifie debut (datep)
var $datef; // Date action planifie fin
var $date; // Date action realise completement (datea)
var $datem; // Date modif (tms)
var $priority;
var $user;
var $author;
@ -79,20 +79,20 @@ class ActionComm
{
global $langs,$conf;
dolibarr_syslog("ActionComm::add");
dolibarr_syslog("ActionComm.class::add datep=".strftime("%x %X",$this->datep)." datea=".$this->datea);
if (! $this->percent) $this->percent = 0;
if (! $this->priority) $this->priority = 0;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm";
$sql.= "(datec,";
if ($this->date_p) $sql.= "datep,";
if ($this->date_a) $sql.= "datea,";
if ($this->datep) $sql.= "datep,";
if ($this->date) $sql.= "datea,";
$sql.= "fk_action,fk_soc,note,fk_contact,fk_user_author,fk_user_action,label,percent,priority,";
$sql.= "fk_facture,propalrowid,fk_commande)";
$sql.= " VALUES (now(),";
if ($this->date_p) $sql.= "'".$this->db->idate($this->date_p)."',";
if ($this->date_a) $sql.= "'".$this->db->idate($this->date_a)."',";
if ($this->datep) $sql.= "'".$this->db->idate($this->datep)."',";
if ($this->date) $sql.= "'".$this->db->idate($this->date)."',";
$sql.= "'".$this->type_id."', '".$this->societe->id."' ,'".addslashes($this->note)."',";
$sql.= ($this->contact->id?$this->contact->id:"null").",";
$sql.= "'$author->id', '".$this->user->id ."', '".addslashes($this->label)."','".$this->percent."','".$this->priority."',";
@ -217,8 +217,8 @@ class ActionComm
$sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm ";
$sql.= " SET percent='".$this->percent."'";
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');
$sql.= ", datep = ".($this->datep ? "'".$this->db->idate($this->datep)."'" : 'null');
$sql.= ", datea = ".($this->date ? "'".$this->db->idate($this->date)."'" : 'null');
if ($this->note) $sql.= ", note = '".addslashes($this->note)."'";
if ($this->contact->id) $sql.= ", fk_contact =". $this->contact->id;
$sql.= " WHERE id=".$this->id;

View File

@ -20,14 +20,14 @@
* $Id$
* $Source$
*/
/**
\file htdocs/comm/action/fiche.php
\ingroup commercial
\brief Page de la fiche action commercial
\version $Revision$
*/
require_once("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/cactioncomm.class.php");
@ -40,7 +40,7 @@ $langs->load("bills");
$langs->load("orders");
// Sécurité accés client
if ($user->societe_id > 0)
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
@ -54,6 +54,24 @@ if (isset($_GET["error"])) $error=$_GET["error"];
*/
if ($_POST["action"] == 'add_action')
{
// Nettoyage parametres
if ($_POST["aphour"] == -1) $_POST["aphour"]='0';
if ($_POST["apmin"] == -1) $_POST["apmin"]='0';
if ($_POST["adhour"] == -1) $_POST["adhour"]='0';
if ($_POST["admin"] == -1) $_POST["admin"]='0';
$datep=@mktime($_POST["aphour"],
$_POST["apmin"],
0,
$_POST["apmonth"],
$_POST["apday"],
$_POST["apyear"]);
$datea=@mktime($_POST["adhour"],
$_POST["admin"],
0,
$_POST["admonth"],
$_POST["adday"],
$_POST["adyear"]);
if ($_POST["contactid"])
{
$contact = new Contact($db);
@ -66,21 +84,28 @@ if ($_POST["action"] == 'add_action')
$_GET["action"] = 'create';
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Type")).'</div>';
}
if ($datea && $_POST["percentage"] == 0)
{
$error=1;
$_GET["action"] = 'create';
$mesg='<div class="error">'.$langs->trans("ErrorStatusCantBeZeroIfStarted").'</div>';
}
if (! $_POST["apyear"] && ! $_POST["adyear"])
{
$error=1;
$_GET["action"] = 'create';
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>';
}
if (! $error)
{
$db->begin();
$cactioncomm = new CActionComm($db);
$cactioncomm->fetch($_POST["actionid"]);
// Initialisation objet actioncomm
$actioncomm = new ActionComm($db);
@ -102,22 +127,14 @@ if ($_POST["action"] == 'add_action')
}
}
}
$actioncomm->date_p = @mktime($_POST["aphour"],
$_POST["apmin"],
0,
$_POST["apmonth"],
$_POST["apday"],
$_POST["apyear"]);
$actioncomm->date_a = @mktime($_POST["adhour"],
$_POST["admin"],
0,
$_POST["admonth"],
$_POST["adday"],
$_POST["adyear"]);
// print $_POST["aphour"]." ".$_POST["apmin"]." ".$_POST["apday"];
$actioncomm->datep = $datep;
$actioncomm->date = $datea;
if ($_POST["percentage"] < 100 && ! $actioncomm->datep) $actioncomm->datep=$actioncomm->date;
if ($actioncomm->type_id == 5)
{
// RDV
if ($actioncomm->date_a)
if ($actioncomm->date)
{
$actioncomm->percent = 100;
}
@ -150,7 +167,7 @@ if ($_POST["action"] == 'add_action')
if (! $actioncomm->error)
{
$db->commit();
if ($_POST["from"])
if ($_POST["from"])
{
dolibarr_syslog("Back to ".$_POST["from"]);
Header("Location: ".$_POST["from"]);
@ -179,7 +196,7 @@ if ($_POST["action"] == 'add_action')
$error='<div class="error">'.$actioncomm->error.'</div>';
}
}
// print $_REQUEST["from"]."rr";
}
@ -191,7 +208,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
{
$actioncomm = new ActionComm($db);
$actioncomm->delete($_GET["id"]);
Header("Location: index.php");
exit;
}
@ -204,22 +221,21 @@ if ($_POST["action"] == 'update')
{
if (! $_POST["cancel"])
{
if ($_POST["aphour"] == -1) $_POST["aphour"]='0';
if ($_POST["apmin"] == -1) $_POST["apmin"]='0';
if ($_POST["adhour"] == -1) $_POST["adhour"]='0';
if ($_POST["admin"] == -1) $_POST["admin"]='0';
if ($_POST["aphour"] == -1) $_POST["aphour"]='0';
if ($_POST["apmin"] == -1) $_POST["apmin"]='0';
if ($_POST["adhour"] == -1) $_POST["adhour"]='0';
if ($_POST["admin"] == -1) $_POST["admin"]='0';
$action = new Actioncomm($db);
$action->fetch($_POST["id"]);
$action->date_p = @mktime($_POST["aphour"],
$action->datep = @mktime($_POST["aphour"],
$_POST["apmin"],
0,
$_POST["apmonth"],
$_POST["apday"],
$_POST["apyear"]);
$action->date_a = @mktime($_POST["adhour"],
$action->date = @mktime($_POST["adhour"],
$_POST["admin"],
0,
$_POST["admonth"],
@ -231,13 +247,13 @@ if ($_POST["action"] == 'update')
$action->percent = $_POST["percent"];
$action->contact->id = $_POST["contactid"];
$action->note = $_POST["note"];
if ($action->type_code == 'AC_RDV' && $action->percent == 100 && ! $action->date_a)
if ($action->type_code == 'AC_RDV' && $action->percent == 100 && ! $action->date)
{
$action->date_a = $action->date_p;
$action->date = $action->datep;
}
$result=$action->update();
}
if ($result < 0)
{
$mesg='<div class="error">'.$action->error.'</div>';
@ -350,7 +366,7 @@ if ($_GET["action"] == 'create')
$html->select_date(-1,'ad',1,1,1,"action");
}
print '</td></tr>';
// Duration
print '<tr><td>'.$langs->trans("Duration").'</td><td>';
$html->select_duree("duree");
@ -522,7 +538,7 @@ if ($_GET["action"] == 'create')
print '<textarea name="note" cols="90" rows="'.ROWS_8.'"></textarea>';
}
print '</td></tr>';
print '<tr><td align="center" colspan="2"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
print '</table>';
@ -571,7 +587,7 @@ if ($_GET["id"])
$head[$h][0] = DOL_URL_ROOT.'/comm/action/info.php?id='.$_GET["id"];
$head[$h][1] = $langs->trans('Info');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Action"));
@ -620,8 +636,8 @@ if ($_GET["id"])
print '<tr><td>'.$langs->trans("DateActionDone").'</td><td colspan="3">';
$html->select_date(($act->date?$act->date:-1),'ad',1,1,1,"action");
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>';
@ -645,7 +661,7 @@ if ($_GET["id"])
{
print '<textarea name="note" cols="90" rows="'.ROWS_8.'">'.$act->note.'</textarea>';
}
print '</td></tr>';
print '<tr><td align="center" colspan="4"><input type="submit" class="button" name="edit" value="'.$langs->trans("Save").'">';
@ -680,7 +696,7 @@ if ($_GET["id"])
{
print $langs->trans("None");
}
print '</td></tr>';
// Affecte a
@ -695,7 +711,7 @@ if ($_GET["id"])
// 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>';
@ -752,7 +768,7 @@ function add_row_for_webcal_link()
{
global $conf,$langs,$user;
$nbtr=0;
// Lien avec calendrier si module activé
if ($conf->webcal->enabled)
{

View File

@ -186,7 +186,7 @@ if ($resql)
{
$cont = new Contact($db);
$cont->fetch($obj->fk_contact);
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$cont->id.'">'.img_object($langs->trans("ShowContact"),"contact").' '.dolibarr_trunc($cont->fullname,24).'</a>';
print $cont->getNomUrl(1);
}
else
{

View File

@ -749,7 +749,10 @@ if ($socid > 0)
print '<td colspan="11"><a href="'.DOL_URL_ROOT.'/comm/action/index.php?socid='.$objsoc->id.'&amp;status=todo">'.$langs->trans("ActionsToDoShort").'</a></td><td align="right">&nbsp;</td>';
print '</tr>';
$sql = "SELECT a.id, a.label, ".$db->pdate("a.datep")." as dp, a.percent,";
$sql = "SELECT a.id, a.label,";
$sql.= " ".$db->pdate("a.datep")." as dp,";
$sql.= " ".$db->pdate("a.datea")." as da,";
$sql.= " a.percent,";
$sql.= " c.code as acode, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid ";
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u ";
$sql.= " WHERE a.fk_soc = ".$objsoc->id;
@ -865,7 +868,10 @@ if ($socid > 0)
print '<td colspan="12"><a href="'.DOL_URL_ROOT.'/comm/action/index.php?socid='.$objsoc->id.'&amp;status=done">'.$langs->trans("ActionsDoneShort").'</a></td>';
print '</tr>';
$sql = "SELECT a.id, a.label, ".$db->pdate("a.datea")." as da, a.percent,";
$sql = "SELECT a.id, a.label,";
$sql.= " ".$db->pdate("a.datep")." as dp,";
$sql.= " ".$db->pdate("a.datea")." as da,";
$sql.= " a.percent,";
$sql.= " a.propalrowid, a.fk_facture, a.fk_user_author, a.fk_contact,";
$sql.= " c.code as acode, c.libelle,";
$sql.= " u.code, u.rowid";