FIX Counter of notification of a thirdparty
This commit is contained in:
parent
d975e7f442
commit
17a1874e36
@ -117,9 +117,10 @@ class Notify
|
|||||||
* @param int $socid Id of third party or 0 for all thirdparties or -1 for no thirdparties
|
* @param int $socid Id of third party or 0 for all thirdparties or -1 for no thirdparties
|
||||||
* @param Object $object Object the notification is about (need it to check threshold value of some notifications)
|
* @param Object $object Object the notification is about (need it to check threshold value of some notifications)
|
||||||
* @param int $userid Id of user or 0 for all users or -1 for no users
|
* @param int $userid Id of user or 0 for all users or -1 for no users
|
||||||
|
* @param array $scope Scope where to search
|
||||||
* @return array|int <0 if KO, array of notifications to send if OK
|
* @return array|int <0 if KO, array of notifications to send if OK
|
||||||
*/
|
*/
|
||||||
function getNotificationsArray($notifcode,$socid=0,$object=null,$userid=0)
|
function getNotificationsArray($notifcode, $socid=0, $object=null, $userid=0, $scope=array('thirdparty', 'user', 'global'))
|
||||||
{
|
{
|
||||||
global $conf, $user;
|
global $conf, $user;
|
||||||
|
|
||||||
@ -131,7 +132,7 @@ class Notify
|
|||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
if ($socid >= 0)
|
if ($socid >= 0 && in_array('thirdparty', $scope))
|
||||||
{
|
{
|
||||||
$sql = "SELECT a.code, c.email, c.rowid";
|
$sql = "SELECT a.code, c.email, c.rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
|
$sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
|
||||||
@ -178,7 +179,7 @@ class Notify
|
|||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
if ($userid >= 0)
|
if ($userid >= 0 && in_array('user', $scope))
|
||||||
{
|
{
|
||||||
$sql = "SELECT a.code, c.email, c.rowid";
|
$sql = "SELECT a.code, c.email, c.rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
|
$sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
|
||||||
@ -223,42 +224,45 @@ class Notify
|
|||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
// List of notifications enabled for fixed email
|
if (in_array('global', $scope))
|
||||||
foreach($conf->global as $key => $val)
|
|
||||||
{
|
{
|
||||||
if ($notifcode)
|
// List of notifications enabled for fixed email
|
||||||
{
|
foreach($conf->global as $key => $val)
|
||||||
if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
|
{
|
||||||
}
|
if ($notifcode)
|
||||||
else
|
{
|
||||||
{
|
if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
|
||||||
if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
|
||||||
|
}
|
||||||
|
|
||||||
$threshold = (float) $reg[1];
|
$threshold = (float) $reg[1];
|
||||||
if ($valueforthreshold < $threshold) continue;
|
if ($valueforthreshold < $threshold) continue;
|
||||||
|
|
||||||
$tmpemail=explode(',',$val);
|
$tmpemail=explode(',',$val);
|
||||||
foreach($tmpemail as $key2 => $val2)
|
foreach($tmpemail as $key2 => $val2)
|
||||||
{
|
{
|
||||||
$newval2=trim($val2);
|
$newval2=trim($val2);
|
||||||
if ($newval2 == '__SUPERVISOREMAIL__')
|
if ($newval2 == '__SUPERVISOREMAIL__')
|
||||||
{
|
{
|
||||||
if ($user->fk_user > 0)
|
if ($user->fk_user > 0)
|
||||||
{
|
{
|
||||||
$tmpuser=new User($this->db);
|
$tmpuser=new User($this->db);
|
||||||
$tmpuser->fetch($user->fk_user);
|
$tmpuser->fetch($user->fk_user);
|
||||||
if ($tmpuser->email) $newval2=trim($tmpuser->email);
|
if ($tmpuser->email) $newval2=trim($tmpuser->email);
|
||||||
else $newval2='';
|
else $newval2='';
|
||||||
}
|
}
|
||||||
else $newval2='';
|
else $newval2='';
|
||||||
}
|
}
|
||||||
if ($newval2)
|
if ($newval2)
|
||||||
{
|
{
|
||||||
$isvalid=isValidEmail($newval2, 0);
|
$isvalid=isValidEmail($newval2, 0);
|
||||||
if (empty($resarray[$newval2])) $resarray[$newval2]=array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid);
|
if (empty($resarray[$newval2])) $resarray[$newval2]=array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -188,11 +188,16 @@ if ($result > 0)
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<tr><td class="titlefield">'.$langs->trans("NbOfActiveNotifications").'</td>';
|
print '<tr><td class="titlefield">'.$langs->trans("NbOfActiveNotifications").'</td>'; // Notification for this thirdparty
|
||||||
print '<td colspan="3">';
|
print '<td colspan="3">';
|
||||||
|
$nbofrecipientemails=0;
|
||||||
$notify=new Notify($db);
|
$notify=new Notify($db);
|
||||||
$tmparray = $notify->getNotificationsArray('', $object->id);
|
$tmparray = $notify->getNotificationsArray('', $object->id, null, 0, array('thirdparty'));
|
||||||
print count($tmparray);
|
foreach($tmparray as $tmpkey => $tmpval)
|
||||||
|
{
|
||||||
|
if (! empty($tmpkey)) $nbofrecipientemails++;
|
||||||
|
}
|
||||||
|
print $nbofrecipientemails;
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
@ -394,13 +399,14 @@ if ($result > 0)
|
|||||||
print '<td align="right">'.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).'</td>';
|
print '<td align="right">'.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}*/
|
}*/
|
||||||
if ($user->admin)
|
|
||||||
|
/*if ($user->admin)
|
||||||
{
|
{
|
||||||
$var = ! $var;
|
$var = ! $var;
|
||||||
print '<tr '.$bc[$var].'><td colspan="4">';
|
print '<tr '.$bc[$var].'><td colspan="4">';
|
||||||
print '+ <a href="'.DOL_URL_ROOT.'/admin/notification.php">'.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).'</a>';
|
print '+ <a href="'.DOL_URL_ROOT.'/admin/notification.php">'.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).'</a>';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}*/
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user