diff --git a/htdocs/actioncomm.class.php b/htdocs/actioncomm.class.php index 5f980ce3a81..1e9f9094397 100644 --- a/htdocs/actioncomm.class.php +++ b/htdocs/actioncomm.class.php @@ -79,7 +79,7 @@ class ActionComm { global $langs,$conf; - dolibarr_syslog("ActionComm.class::add datep=".strftime("%x %X",$this->datep)." datea=".$this->datea); + dolibarr_syslog("ActionComm.class::add type_id=".$this->type_id." datep=".strftime("%x %X",$this->datep)." datea=".$this->datea); if (! $this->percent) $this->percent = 0; if (! $this->priority) $this->priority = 0; @@ -121,86 +121,96 @@ class ActionComm } - /** - * \brief Charge l'objet action depuis la base - * \param id id de l'action a récupérer - */ - function fetch($id) - { - global $langs; - - $sql = "SELECT ".$this->db->pdate("a.datea")." as datea,"; - $sql.= " ".$this->db->pdate("a.datep")." as datep,"; - $sql.= " ".$this->db->pdate("a.datec")." as datec, tms as datem,"; - $sql.= " a.note, a.label, a.fk_action as type_id,"; - $sql.= " c.code, c.libelle, fk_soc, fk_user_author, fk_contact, fk_facture, a.percent, a.fk_commande"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c"; - $sql.= " WHERE a.id=".$id." AND a.fk_action=c.id"; - - $resql=$this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); - - $this->id = $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->datep = $obj->datep; - $this->datec = $obj->datec; - $this->datem = $obj->datem; - $this->note =$obj->note; - $this->percent =$obj->percent; - $this->societe->id = $obj->fk_soc; - $this->author->id = $obj->fk_user_author; - $this->contact->id = $obj->fk_contact; - $this->fk_facture = $obj->fk_facture; - if ($this->fk_facture) - { - $this->objet_url = img_object($langs->trans("ShowBill"),'bill').' '.''.$langs->trans("Bill").''; - $this->objet_url_type = 'facture'; - } - $this->fk_propal = $obj->propalrowid; - if ($this->fk_propal) - { - $this->objet_url = img_object($langs->trans("ShowPropal"),'propal').' '.''.$langs->trans("Propal").''; - $this->objet_url_type = 'propal'; - } - $this->fk_commande = $obj->fk_commande; - if ($this->fk_commande) - { - $this->objet_url = img_object($langs->trans("ShowOrder"),'order').' '.''.$langs->trans("Order").''; - $this->objet_url_type = 'order'; - } - - } - $this->db->free($resql); - } - else - { - dolibarr_print_error($this->db); - } - } + /** + * \brief Charge l'objet action depuis la base + * \param id id de l'action a récupérer + */ + function fetch($id) + { + global $langs; + + $sql = "SELECT a.id, ".$this->db->pdate("a.datea")." as datea,"; + $sql.= " ".$this->db->pdate("a.datep")." as datep,"; + $sql.= " ".$this->db->pdate("a.datec")." as datec, tms as datem,"; + $sql.= " a.note, a.label, a.fk_action as type_id,"; + $sql.= " fk_soc, fk_user_author, fk_contact, fk_facture, a.percent, a.fk_commande,"; + $sql.= " c.id as type_id, c.code, c.libelle"; + $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c"; + $sql.= " WHERE a.id=".$id." AND a.fk_action=c.id"; + + dolibarr_syslog("ActionComm.class::fetch sql=".$sql); + + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->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->datep = $obj->datep; + $this->datec = $obj->datec; + $this->datem = $obj->datem; + $this->note =$obj->note; + $this->percent =$obj->percent; + $this->societe->id = $obj->fk_soc; + $this->author->id = $obj->fk_user_author; + $this->contact->id = $obj->fk_contact; + $this->fk_facture = $obj->fk_facture; + if ($this->fk_facture) + { + $this->objet_url = img_object($langs->trans("ShowBill"),'bill').' '.''.$langs->trans("Bill").''; + $this->objet_url_type = 'facture'; + } + $this->fk_propal = $obj->propalrowid; + if ($this->fk_propal) + { + $this->objet_url = img_object($langs->trans("ShowPropal"),'propal').' '.''.$langs->trans("Propal").''; + $this->objet_url_type = 'propal'; + } + $this->fk_commande = $obj->fk_commande; + if ($this->fk_commande) + { + $this->objet_url = img_object($langs->trans("ShowOrder"),'order').' '.''.$langs->trans("Order").''; + $this->objet_url_type = 'order'; + } + + } + $this->db->free($resql); + return 1; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } - /** - * \brief Supprime l'action de la base - * \param id id de l'action a effacer - * \return int 1 en cas de succès - */ - function delete($id) + /** + * \brief Supprime l'action de la base + * \return int <0 si ko, >0 si ok + */ + function delete() { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm WHERE id=$id;"; - - if ($this->db->query($sql) ) + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm"; + $sql.= " WHERE id=".$this->id; + + if ($this->db->query($sql)) { return 1; } + else + { + $this->error=$this->db->error()." sql=".$sql; + return -1; + } } /** diff --git a/htdocs/cactioncomm.class.php b/htdocs/cactioncomm.class.php index 12499ad595d..6945a780714 100644 --- a/htdocs/cactioncomm.class.php +++ b/htdocs/cactioncomm.class.php @@ -59,15 +59,16 @@ class CActioncomm { /** * \brief Charge l'objet type d'action depuis la base - * \param id id du type d'action à récupérer + * \param id id ou code du type d'action à récupérer * \return int 1=ok, 0=aucune action, -1=erreur */ function fetch($id) { - $sql = "SELECT code, type, libelle, active"; + $sql = "SELECT id, code, type, libelle, active"; $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; - $sql.= " WHERE id=$id"; + if (is_numeric($id)) $sql.= " WHERE id=".$id; + else $sql.= " WHERE code='".$id."'"; $resql=$this->db->query($sql); if ($resql) @@ -76,7 +77,7 @@ class CActioncomm { { $obj = $this->db->fetch_object($resql); - $this->id = $id; + $this->id = $obj->id; $this->code = $obj->code; $this->type = $obj->type; $this->libelle = $obj->libelle; @@ -101,15 +102,18 @@ class CActioncomm { /* * \brief Renvoi la liste des types d'actions existant * \param active 1 ou 0 pour un filtre sur l'etat actif ou non ('' par defaut = pas de filtre) - * \return array tableau des types d'actions actifs si ok, <0 si erreur + * \return array Tableau des types d'actions actifs si ok, <0 si erreur */ - function liste_array($active='') + function liste_array($active='',$idorcode='id') { global $langs,$conf; $langs->load("commercial"); - $ga = array(); - + $repid = array(); + $repcode = array(); + + dolibarr_syslog("CActionComm.class::liste_array active=$active idorcode=$idorcode"); + $sql = "SELECT id, code, libelle, module"; $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; if ($active != '') @@ -137,13 +141,15 @@ class CActioncomm { if ($qualified) { $transcode=$langs->trans("Action".$obj->code); - $ga[$obj->id] = ($transcode!="Action".$obj->code?$transcode:$obj->libelle); + $repid[$obj->id] = ($transcode!="Action".$obj->code?$transcode:$obj->libelle); + $repcode[$obj->code] = ($transcode!="Action".$obj->code?$transcode:$obj->libelle); } $i++; } } - $this->liste_array=$ga; - return $ga; + if ($idorcode == 'id') $this->liste_array=$repid; + if ($idorcode == 'code') $this->liste_array=$repcode; + return $this->liste_array; } else { @@ -152,47 +158,62 @@ class CActioncomm { } - /* - * \brief Renvoie le nom sous forme d'un libellé traduit d'un type d'action - * \param id id du type d'action - * \return string libelle du type d'action - */ - function get_nom($id) - { - global $langs; - - if (! isset($this->type_actions[$id])) - { - // Si valeur non disponible en cache - $sql = 'SELECT code, libelle'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm'; - $sql.= " WHERE id='".$id."'"; - - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); + /* + * \brief Renvoie le nom sous forme d'un libellé traduit d'un type d'action + * \param id id ou code du type d'action + * \return string libelle du type d'action + */ + function get_nom($id) + { + global $langs; + + if (! isset($this->type_actions[$id])) + { + // Si valeur non disponible en cache + $sql = 'SELECT id, code, libelle'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm'; + if (is_numeric($id)) $sql.= " WHERE id=".$id; + else $sql.= " WHERE code='".$id."'"; + + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + + $transcode=$langs->trans("Action".$obj->code); + $libelle=($transcode!="Action".$obj->code?$transcode:$obj->libelle); + + $this->type_actions[$obj->id]=$libelle; // Met en cache + return $libelle; + } + $this->db->free($result); + } + else { + dolibarr_print_error($db); + } + + } + else { + // Si valeur disponible en cache + return $this->type_actions[$id]; + } + } - $transcode=$langs->trans("Action".$obj->code); - $libelle=($transcode!="Action".$obj->code?$transcode:$obj->libelle); - - $this->type_actions[$id]=$libelle; // Met en cache - return $libelle; - } - $this->db->free($result); - } - else { - dolibarr_print_error($db); - } - - } - else { - // Si valeur disponible en cache - return $this->type_actions[$id]; - } - } + + /* + * \brief Renvoie le nom sous forme d'un libellé traduit d'un type d'action + * \return string Libelle du type d'action + */ + function getNom() + { + global $langs; + + $transcode=$langs->trans("Action".$this->code); + $libelle=($transcode!="Action".$this->code ? $transcode : $this->get_nom($this->code)); + return $libelle; + } } ?> diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 410d7dd5efd..9c959d47d6f 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -24,7 +24,7 @@ /** \file htdocs/comm/action/fiche.php \ingroup commercial - \brief Page de la fiche action commercial + \brief Page de la fiche action \version $Revision$ */ @@ -78,7 +78,7 @@ if ($_POST["action"] == 'add_action') $contact->fetch($_POST["contactid"]); } - if (! $_POST["actionid"]) + if (! $_POST["actioncode"]) { $error=1; $_GET["action"] = 'create'; @@ -104,18 +104,18 @@ if ($_POST["action"] == 'add_action') $db->begin(); $cactioncomm = new CActionComm($db); - $cactioncomm->fetch($_POST["actionid"]); + $cactioncomm->fetch($_POST["actioncode"]); // Initialisation objet actioncomm $actioncomm = new ActionComm($db); - $actioncomm->type_id = $_POST["actionid"]; + $actioncomm->type_id = $cactioncomm->id; $actioncomm->type_code = $cactioncomm->code; $actioncomm->priority = isset($_POST["priority"])?$_POST["priority"]:0; $actioncomm->label = trim($_POST["label"]); if (! $_POST["label"]) { - if ($_POST["actionid"] == 5 && $contact->fullname) + if ($_POST["actioncode"] == 'AC_RDV' && $contact->fullname) { $actioncomm->label = $langs->trans("TaskRDVWith",$contact->fullname); } @@ -131,7 +131,7 @@ if ($_POST["action"] == 'add_action') $actioncomm->datep = $datep; $actioncomm->date = $datea; if ($_POST["percentage"] < 100 && ! $actioncomm->datep) $actioncomm->datep=$actioncomm->date; - if ($actioncomm->type_id == 5) + if ($actioncomm->type_code == 'AC_RDV') { // RDV if ($actioncomm->date) @@ -207,10 +207,18 @@ if ($_POST["action"] == 'add_action') if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') { $actioncomm = new ActionComm($db); - $actioncomm->delete($_GET["id"]); + $actioncomm->fetch($_GET["id"]); + $result=$actioncomm->delete(); - Header("Location: index.php"); - exit; + if ($result >= 0) + { + Header("Location: index.php"); + exit; + } + else + { + $mesg=$actioncomm->error; + } } /* @@ -296,7 +304,7 @@ if ($_GET["action"] == 'create') * Si action de type Rendez-vous * */ - if ($_GET["actionid"] == 5) + if ($_GET["actioncode"] == 'AC_RDV') { print_titre ($langs->trans("AddActionRendezVous")); print "
"; @@ -308,7 +316,7 @@ if ($_GET["action"] == 'create') print ''; // Type d'action - print ''; + print ''; // Societe, contact print ''; diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index f90c89ff665..251be44832b 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -62,7 +62,8 @@ if ($_GET["action"] == 'builddoc') if ($action=='delete_action') { $actioncomm = new ActionComm($db); - $result=$actioncomm->delete($actionid); + $actioncomm->fetch($actionid); + $result=$actioncomm->delete(); } diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index b104e76a9b4..6824a3b7466 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -176,9 +176,9 @@ if ($result) print '\n"; - print ''; + print ''; - print ''; + print ''; print "\n"; $i++; diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index 752de660b26..04fe70c8489 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -712,20 +712,20 @@ if ($socid > 0) // Lien click to dial if (strlen($obj->phone) && $user->clicktodial_enabled == 1) { - print ''; + print ''; print img_phone_out("Appel émis") ; } print ''; - print ''; - print ''; + print ''.dolibarr_print_phone($obj->phone).' '; + print ''; + print ''; print ''; - print ''; diff --git a/htdocs/comm/prospect/fiche.php b/htdocs/comm/prospect/fiche.php index 074776a37cc..39dd7b31569 100644 --- a/htdocs/comm/prospect/fiche.php +++ b/htdocs/comm/prospect/fiche.php @@ -285,17 +285,17 @@ if ($socid > 0) } print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; print ''; - print ''; diff --git a/htdocs/compta/fiche.php b/htdocs/compta/fiche.php index 50f3be131e7..e8fbffe3249 100644 --- a/htdocs/compta/fiche.php +++ b/htdocs/compta/fiche.php @@ -404,9 +404,9 @@ if ($socid > 0) } print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; - print ''; diff --git a/htdocs/contact/index.php b/htdocs/contact/index.php index 34b0af02d29..7b2964c2900 100644 --- a/htdocs/contact/index.php +++ b/htdocs/contact/index.php @@ -251,7 +251,7 @@ if ($result) print ' '; } print ''; - print ''; + print ''; if ($_GET["view"] == 'phone') { diff --git a/htdocs/fourn/fiche.php b/htdocs/fourn/fiche.php index eac1c5eaa61..1957222e0af 100644 --- a/htdocs/fourn/fiche.php +++ b/htdocs/fourn/fiche.php @@ -340,9 +340,9 @@ if ( $societe->fetch($socid) ) } print ""; print ""; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if ($user->rights->societe->contact->creer) {
'.$langs->trans("ActionOnCompany").''; @@ -419,10 +427,6 @@ if ($_GET["action"] == 'create') } } - /* - * - * - */ print_titre ($langs->trans("AddAnAction")); print "
"; @@ -433,17 +437,17 @@ if ($_GET["action"] == 'create') // Type d'action actifs print '
'.$langs->trans("Type").''; - if ($_GET["actionid"]) + if ($_GET["actioncode"]) { - print ''."\n"; - print $caction->get_nom($_GET["actionid"]); + print ''."\n"; + print $caction->get_nom($_GET["actioncode"]); } else { - $arraylist=$caction->liste_array(1); + $arraylist=$caction->liste_array(1,'code'); $arraylist[0]=' '; - sort($arraylist); - $html->select_array("actionid", $arraylist, 0); + asort($arraylist); + $html->select_array("actioncode", $arraylist, 0); } print '
'.img_object($langs->trans("ShowCompany"),"company").' '; print "idp\">$obj->nom'.$obj->email.' '.$obj->email.' '.dolibarr_print_phone($obj->phone).' '.dolibarr_print_phone($obj->phone).' 
'; - print ''.dolibarr_print_phone($obj->phone).' '.dolibarr_print_phone($obj->fax).' '.$obj->email.' '.dolibarr_print_phone($obj->fax).' '.$obj->email.' '; print "idp\">"; print img_edit(); print ''; + print ''; print img_object($langs->trans("Rendez-Vous"),"action"); print ''.$obj->poste.' '.$obj->phone; + print ''.$obj->phone; if (strlen($obj->phone) && $user->clicktodial_enabled == 1) { - print ''; + print ''; print img_phone_out("Appel émis") ; } print ''.$obj->fax.' '.$obj->email.' '.$obj->fax.' '.$obj->email.' '; @@ -309,7 +309,7 @@ if ($socid > 0) print ''; + print ''; print img_object($langs->trans("Rendez-Vous"),"action"); print ''.$obj->poste.' '.$obj->phone.' '.$obj->fax.' '.$obj->email.' '.$obj->phone.' '.$obj->fax.' '.$obj->email.' '; @@ -420,7 +420,7 @@ if ($socid > 0) print ''; + print ''; print img_object($langs->trans("Rendez-Vous"),"action"); print ''.dolibarr_print_phone($obj->phone).' '.dolibarr_print_phone($obj->phone).' $obj->poste '.$obj->phone.' '.$obj->fax.' '.$obj->email.' '.$obj->phone.' '.$obj->fax.' '.$obj->email.'