diff --git a/htdocs/actioncomm.class.php b/htdocs/actioncomm.class.php index 09b81d98372..5f980ce3a81 100644 --- a/htdocs/actioncomm.class.php +++ b/htdocs/actioncomm.class.php @@ -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; diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 01bdd400474..17230c475b5 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -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='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Type")).'
'; } - + + if ($datea && $_POST["percentage"] == 0) + { + $error=1; + $_GET["action"] = 'create'; + $mesg='
'.$langs->trans("ErrorStatusCantBeZeroIfStarted").'
'; + } + if (! $_POST["apyear"] && ! $_POST["adyear"]) { $error=1; $_GET["action"] = 'create'; $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'
'; } - + 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='
'.$actioncomm->error.'
'; } } - + // 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='
'.$action->error.'
'; @@ -350,7 +366,7 @@ if ($_GET["action"] == 'create') $html->select_date(-1,'ad',1,1,1,"action"); } print ''; - + // Duration print ''.$langs->trans("Duration").''; $html->select_duree("duree"); @@ -522,7 +538,7 @@ if ($_GET["action"] == 'create') print ''; } print ''; - + print ''; print ''; @@ -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 ''.$langs->trans("DateActionDone").''; $html->select_date(($act->date?$act->date:-1),'ad',1,1,1,"action"); print ''; - - + + // Etat print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").'%'; @@ -645,7 +661,7 @@ if ($_GET["id"]) { print ''; } - + print ''; print ''; @@ -680,7 +696,7 @@ if ($_GET["id"]) { print $langs->trans("None"); } - + print ''; // Affecte a @@ -695,7 +711,7 @@ if ($_GET["id"]) // 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').''; @@ -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) { diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 43004611ebc..ca52f98bbe3 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -186,7 +186,7 @@ if ($resql) { $cont = new Contact($db); $cont->fetch($obj->fk_contact); - print ''.img_object($langs->trans("ShowContact"),"contact").' '.dolibarr_trunc($cont->fullname,24).''; + print $cont->getNomUrl(1); } else { diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index 39f067f4aa0..1f09131aa14 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -749,7 +749,10 @@ if ($socid > 0) print ''.$langs->trans("ActionsToDoShort").' '; print ''; - $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 ''.$langs->trans("ActionsDoneShort").''; print ''; - $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";