Ajout nombre de mailings de masse reues sur la fiche contacts
This commit is contained in:
parent
5c25b56d5b
commit
023d89538d
@ -653,47 +653,76 @@ class Contact
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Charge les informations sur le contact, depuis la base
|
||||
* \param id id du contact à charger
|
||||
*/
|
||||
function info($id)
|
||||
/*
|
||||
* \brief Charge les informations sur le contact, depuis la base
|
||||
* \param id id du contact à charger
|
||||
*/
|
||||
function info($id)
|
||||
{
|
||||
$sql = "SELECT c.idp, ".$this->db->pdate("datec")." as datec, fk_user";
|
||||
$sql .= ", ".$this->db->pdate("tms")." as tms, fk_user_modif";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||
$sql .= " WHERE c.idp = $id";
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
if ($this->db->num_rows())
|
||||
{
|
||||
$obj = $this->db->fetch_object();
|
||||
|
||||
$this->id = $obj->idp;
|
||||
|
||||
if ($obj->fk_user) {
|
||||
$cuser = new User($this->db, $obj->fk_user);
|
||||
$cuser->fetch();
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
|
||||
if ($obj->fk_user_modif) {
|
||||
$muser = new User($this->db, $obj->fk_user_modif);
|
||||
$muser->fetch();
|
||||
$this->user_modification = $muser;
|
||||
}
|
||||
|
||||
$this->date_creation = $obj->datec;
|
||||
$this->date_modification = $obj->tms;
|
||||
|
||||
}
|
||||
|
||||
$this->db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
}
|
||||
$sql = "SELECT c.idp, ".$this->db->pdate("datec")." as datec, fk_user";
|
||||
$sql .= ", ".$this->db->pdate("tms")." as tms, fk_user_modif";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||
$sql .= " WHERE c.idp = $id";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->idp;
|
||||
|
||||
if ($obj->fk_user) {
|
||||
$cuser = new User($this->db, $obj->fk_user);
|
||||
$cuser->fetch();
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
|
||||
if ($obj->fk_user_modif) {
|
||||
$muser = new User($this->db, $obj->fk_user_modif);
|
||||
$muser->fetch();
|
||||
$this->user_modification = $muser;
|
||||
}
|
||||
|
||||
$this->date_creation = $obj->datec;
|
||||
$this->date_modification = $obj->tms;
|
||||
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Renvoi nombre d'emailings reçu par le contact avec son email
|
||||
* \return int Nombre d'emailings
|
||||
*/
|
||||
function getNbOfEMailings()
|
||||
{
|
||||
$sql = "SELECT count(mc.email) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
|
||||
$sql.= " WHERE mc.email = '".$this->email."'";
|
||||
$sql.= " AND mc.statut=1"; // -1 erreur, 0 non envoyé, 1 envoyé avec succès
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$nb=$obj->nb;
|
||||
|
||||
$this->db->free($resql);
|
||||
return $nb;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@ -269,8 +269,8 @@ if ($_GET["action"] == 'create')
|
||||
print '<tr><td>Tel Pro</td><td><input name="phone_pro" type="text" size="18" maxlength="80" value="'.$contact->phone_pro.'"></td>';
|
||||
print '<td>Tel Perso</td><td><input name="phone_perso" type="text" size="18" maxlength="80" value="'.$contact->phone_perso.'"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Fax").'</td><td><input name="fax" type="text" size="18" maxlength="80"></td>';
|
||||
print '<td>Portable</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.$contact->phone_mobile.'"></td></tr>';
|
||||
print '<tr><td>Portable</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.$contact->phone_mobile.'"></td>';
|
||||
print '<td>'.$langs->trans("Fax").'</td><td><input name="fax" type="text" size="18" maxlength="80"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Email").'</td><td colspan="3"><input name="email" type="text" size="50" maxlength="80" value="'.$contact->email.'"></td></tr>';
|
||||
|
||||
@ -339,7 +339,18 @@ elseif ($_GET["action"] == 'edit')
|
||||
print '<tr><td>Portable</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.$contact->phone_mobile.'"></td>';
|
||||
print '<td>'.$langs->trans("Fax").'</td><td><input name="fax" type="text" size="18" maxlength="80" value="'.$contact->fax.'"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("EMail").'</td><td colspan="3"><input name="email" type="text" size="50" maxlength="80" value="'.$contact->email.'"></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("EMail").'</td><td><input name="email" type="text" size="50" maxlength="80" value="'.$contact->email.'"></td>';
|
||||
if ($conf->mailing->enabled)
|
||||
{
|
||||
$langs->load("mails");
|
||||
print '<td nowrap>'.$langs->trans("NbOfEMailingsReceived").'</td>';
|
||||
print '<td>'.$contact->getNbOfEMailings().'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td colspan="2"> </td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td>Jabberid</td><td colspan="3"><input name="jabberid" type="text" size="50" maxlength="80" value="'.$contact->jabberid.'"></td></tr>';
|
||||
|
||||
@ -408,10 +419,10 @@ else
|
||||
print '<tr><td>Tel Pro</td><td>'.$contact->phone_pro.'</td>';
|
||||
print '<td>Tel Perso</td><td>'.$contact->phone_perso.'</td></tr>';
|
||||
|
||||
print '<td>Portable</td><td>'.$contact->phone_mobile.'</td>';
|
||||
print '<tr><td>Portable</td><td>'.$contact->phone_mobile.'</td>';
|
||||
print '<td>'.$langs->trans("Fax").'</td><td>'.$contact->fax.'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("EMail").'</td><td colspan="3">';
|
||||
print '<tr><td>'.$langs->trans("EMail").'</td><td>';
|
||||
if ($contact->email && ! ValidEmail($contact->email))
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorBadEMail",$contact->email)."</div>";
|
||||
@ -420,8 +431,19 @@ else
|
||||
{
|
||||
print $contact->email;
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print '</td>';
|
||||
if ($conf->mailing->enabled)
|
||||
{
|
||||
$langs->load("mails");
|
||||
print '<td nowrap>'.$langs->trans("NbOfEMailingsReceived").'</td>';
|
||||
print '<td>'.$contact->getNbOfEMailings().'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td colspan="2"> </td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td>Jabberid</td><td colspan="3">'.$contact->jabberid.'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Note").'</td><td colspan="3">';
|
||||
@ -460,26 +482,20 @@ else
|
||||
}
|
||||
|
||||
|
||||
// Historique des actions vers ce contact
|
||||
// Historique des actions sur ce contact
|
||||
print_titre ($langs->trans("TasksHistoryForThisContact"));
|
||||
$histo=array();
|
||||
$numaction = 0 ;
|
||||
|
||||
print '<table width="100%" class="noborder">';
|
||||
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print "<td>".$langs->trans("Date")."</td><td>".$langs->trans("Actions")."</td>";
|
||||
print "<td>".$langs->trans("CreatedBy")."</td></tr>";
|
||||
|
||||
$sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, 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 fk_contact = ".$contact->id;
|
||||
$sql .= " AND u.rowid = a.fk_user_author";
|
||||
$sql .= " AND c.id=a.fk_action ";
|
||||
|
||||
if ($contactid)
|
||||
{
|
||||
$sql .= " AND fk_contact = $contactid";
|
||||
}
|
||||
$sql .= " ORDER BY a.datea DESC, a.id DESC";
|
||||
// Recherche histo sur actioncomm
|
||||
$sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, a.note, a.percent as percent,";
|
||||
$sql.= " c.code as acode, c.libelle,";
|
||||
$sql.= " u.rowid as user_id, u.code";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u ";
|
||||
$sql.= " WHERE fk_contact = ".$contact->id;
|
||||
$sql.= " AND u.rowid = a.fk_user_author";
|
||||
$sql.= " AND c.id=a.fk_action";
|
||||
$sql.= " ORDER BY a.datea DESC, a.id DESC";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
@ -490,21 +506,10 @@ else
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print "<td>". strftime("%d %b %Y %H:%M", $obj->da) ."</td>";
|
||||
if ($obj->propalrowid)
|
||||
{
|
||||
print "<td><a href=\"".DOL_URL_ROOT."/comm/propal.php?propalid=".$obj->propalrowid."\">".$obj->libelle."</a></td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>$obj->libelle</td>";
|
||||
}
|
||||
|
||||
print "<td>$obj->code </td>";
|
||||
print "</tr>\n";
|
||||
$histo[$numaction]=array('type'=>'action','id'=>$obj->id,'date'=>$obj->da,'note'=>$obj->note,'percent'=>$obj->percent,
|
||||
'acode'=>$obj->acode,'libelle'=>$obj->libelle,
|
||||
'userid'=>$obj->user_id,'code'=>$obj->code);
|
||||
$numaction++;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@ -512,8 +517,101 @@ else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
// Recherche histo sur mailing
|
||||
$sql = "SELECT m.rowid as id, ".$db->pdate("mc.date_envoi")." as da, m.titre as note, '100' as percent,";
|
||||
$sql.= " 'AC_EMAILING' as acode,";
|
||||
$sql.= " u.rowid as user_id, u.code";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u ";
|
||||
$sql.= " WHERE mc.email = '".$contact->email."'";
|
||||
$sql.= " AND mc.statut = 1";
|
||||
$sql.= " AND u.rowid = m.fk_user_valid";
|
||||
$sql.= " AND mc.fk_mailing=m.rowid";
|
||||
$sql.= " ORDER BY mc.date_envoi DESC, m.rowid DESC";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0 ;
|
||||
$num = $db->num_rows($resql);
|
||||
$var=true;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$histo[$numaction]=array('type'=>'mailing','id'=>$obj->id,'date'=>$obj->da,'note'=>$obj->note,'percent'=>$obj->percent,
|
||||
'acode'=>$obj->acode,'libelle'=>$obj->libelle,
|
||||
'userid'=>$obj->user_id,'code'=>$obj->code);
|
||||
$numaction++;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
// Affichage actions sur contact
|
||||
print '<table width="100%" class="noborder">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Status").'</td>';
|
||||
print '<td>'.$langs->trans("Actions").'</td>';
|
||||
print '<td>'.$langs->trans("Comments").'</td>';
|
||||
print '<td>'.$langs->trans("Author").'</td></tr>';
|
||||
|
||||
foreach ($histo as $key=>$value)
|
||||
{
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
// Date
|
||||
print "<td>". dolibarr_print_date($histo[$key]['date'],"%d %b %Y %H:%M") ."</td>";
|
||||
|
||||
// Status/Percent
|
||||
if ($histo[$key]['percent'] < 100) {
|
||||
print "<td align=\"center\">".$histo[$key]['percent']."%</td>";
|
||||
}
|
||||
else {
|
||||
print "<td align=\"center\">".$langs->trans("Done")."</td>";
|
||||
}
|
||||
|
||||
// Action
|
||||
print '<td>';
|
||||
if ($histo[$key]['type']=='action')
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowTask"),"task").' ';
|
||||
$transcode=$langs->trans("Action".$histo[$key]['acode']);
|
||||
$libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:$histo[$key]['libelle']);
|
||||
print dolibarr_trunc($libelle,30);
|
||||
print '</a>';
|
||||
}
|
||||
if ($histo[$key]['type']=='mailing')
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/mailing/fiche.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"),"email").' ';
|
||||
$transcode=$langs->trans("Action".$histo[$key]['acode']);
|
||||
$libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:'Send mass mailing');
|
||||
print dolibarr_trunc($libelle,30);
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Note
|
||||
print '<td>'.dolibarr_trunc($histo[$key]['note'], 30).'</td>';
|
||||
|
||||
// Author
|
||||
print '<td>';
|
||||
if ($histo[$key]['code'])
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$histo[$key]['userid'].'">'.img_object($langs->trans("ShowUser"),'user').' '.$histo[$key]['code'].'</a>';
|
||||
}
|
||||
else print " ";
|
||||
print "</td>";
|
||||
print "</tr>\n";
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -54,7 +54,7 @@ $search_email=isset($_GET["search_email"])?$_GET["search_email"]:$_POST["search_
|
||||
$type = isset($_GET["type"])?$_GET["type"]:$_POST["type"];
|
||||
$view=isset($_GET["view"])?$_GET["view"]:$_POST["view"];
|
||||
|
||||
$contactname=isset($_GET["contactname"])?$_GET["contactname"]:$_POST["contactname"];
|
||||
$sall=isset($_GET["contactname"])?$_GET["contactname"]:$_POST["contactname"];
|
||||
$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
|
||||
$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
|
||||
$page = isset($_GET["page"])?$_GET["page"]:$_POST["page"];
|
||||
@ -72,11 +72,13 @@ if ($view == 'mail') { $text="(Vue EMail)"; }
|
||||
if ($view == 'recent') { $text="(Récents)"; }
|
||||
$titre = $langs->trans("ListOfContacts")." $text";
|
||||
|
||||
if ($_POST["button_removefilter"] == $langs->trans("RemoveFilter")) {
|
||||
if ($_POST["button_removefilter"])
|
||||
{
|
||||
$search_nom="";
|
||||
$search_prenom="";
|
||||
$search_societe="";
|
||||
$search_email="";
|
||||
$sall="";
|
||||
}
|
||||
|
||||
|
||||
@ -88,7 +90,6 @@ if ($_POST["button_removefilter"] == $langs->trans("RemoveFilter")) {
|
||||
$sql = "SELECT s.idp, s.nom, p.idp as cidp, p.name, p.firstname, p.email, p.phone, p.phone_mobile, p.fax ";
|
||||
$sql .= "FROM ".MAIN_DB_PREFIX."socpeople as p ";
|
||||
$sql .= "LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (s.idp = p.fk_soc) ";
|
||||
|
||||
$sql .= "WHERE 1=1 ";
|
||||
|
||||
if ($_GET["userid"]) // statut commercial
|
||||
@ -97,21 +98,20 @@ if ($_GET["userid"]) // statut commercial
|
||||
}
|
||||
if ($search_nom) // filtre sur le nom
|
||||
{
|
||||
$sql .= " AND upper(p.name) like '%".$search_nom."%'";
|
||||
$sql .= " AND p.name like '%".$search_nom."%'";
|
||||
}
|
||||
if ($search_prenom) // filtre sur le prenom
|
||||
{
|
||||
$sql .= " AND upper(p.firstname) like '%".$search_prenom."%'";
|
||||
$sql .= " AND p.firstname like '%".$search_prenom."%'";
|
||||
}
|
||||
if ($search_societe) // filtre sur la societe
|
||||
{
|
||||
$sql .= " AND upper(s.nom) like '%".$search_societe."%'";
|
||||
$sql .= " AND s.nom like '%".$search_societe."%'";
|
||||
}
|
||||
if ($search_email) // filtre sur l'email
|
||||
{
|
||||
$sql .= " AND upper(p.email) like '%".$search_email."%'";
|
||||
$sql .= " AND p.email like '%".$search_email."%'";
|
||||
}
|
||||
|
||||
if ($type == "f") // filtre sur type
|
||||
{
|
||||
$sql .= " AND fournisseur = 1";
|
||||
@ -120,12 +120,10 @@ if ($type == "c") // filtre sur type
|
||||
{
|
||||
$sql .= " AND client = 1";
|
||||
}
|
||||
|
||||
if ($contactname)
|
||||
if ($sall)
|
||||
{
|
||||
$sql .= " AND (p.name like '%".$contactname."%' OR p.firstname like '%".$contactname."%') ";
|
||||
$sql .= " AND (p.name like '%".$sall."%' OR p.firstname like '%".$sall."%' OR p.email like '%".$sall."%') ";
|
||||
}
|
||||
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND s.idp = $socid";
|
||||
@ -144,7 +142,7 @@ $result = $db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
print_barre_liste($titre ,$page, "index.php", '&begin='.$_GET["begin"].'&view='.$_GET["view"].'&userid='.$_GET["userid"], $sortfield, $sortorder,'',$num);
|
||||
@ -152,9 +150,9 @@ if ($result)
|
||||
|
||||
print '<table class="liste" width="100%">';
|
||||
|
||||
if ($contactname)
|
||||
if ($sall)
|
||||
{
|
||||
print $langs->trans("Filter")." (".$langs->trans("Lastname")." ".$langs->trans("or")." ".$langs->trans("Firstname")."): $contactname";
|
||||
print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname")." ".$langs->trans("or")." ".$langs->trans("EMail")."): ".$sall;
|
||||
}
|
||||
|
||||
// Ligne des titres
|
||||
@ -212,8 +210,8 @@ if ($result)
|
||||
}
|
||||
|
||||
print '<td class="liste_titre" align="right">';
|
||||
print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" alt="'.$langs->trans("Search").'">';
|
||||
print ' <input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" alt="'.$langs->trans("RemoveFilter").'">';
|
||||
print '<input type="image" value="button_search" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" alt="'.$langs->trans("Search").'">';
|
||||
print ' <input type="image" value="button_removefilter" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" alt="'.$langs->trans("RemoveFilter").'">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user