--- /tmp/dsg/dolibarr/htdocs/user/notify/github_card.php
+++ /tmp/dsg/dolibarr/htdocs/user/notify/client_card.php
@@ -63,48 +63,52 @@
// Add a notification
if ($action == 'add')
{
- $error = 0;
-
- if ($actionid <= 0)
- {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors');
- $error++;
- }
-
- if (!$error)
- {
- $db->begin();
-
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
- $sql .= " WHERE fk_user=".$id." AND fk_action=".$actionid;
- if ($db->query($sql))
- {
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_user, fk_action)";
- $sql .= " VALUES ('".$db->idate($now)."',".$id.",".$actionid.")";
-
- if (!$db->query($sql))
- {
- $error++;
- dol_print_error($db);
- }
- } else {
- dol_print_error($db);
- }
-
- if (!$error)
- {
- $db->commit();
- } else {
- $db->rollback();
- }
- }
+ $error = 0;
+
+ if ($actionid <= 0)
+ {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors');
+ $error++;
+ }
+
+ if (!$error)
+ {
+ $db->begin();
+
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
+ $sql .= " WHERE fk_user=".$id." AND fk_action=".$actionid;
+ if ($db->query($sql))
+ {
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_user, fk_action)";
+ $sql .= " VALUES ('".$db->idate($now)."',".$id.",".$actionid.")";
+
+ if (!$db->query($sql))
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+
+ if (!$error)
+ {
+ $db->commit();
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
}
// Remove a notification
if ($action == 'delete')
{
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".GETPOST("actid", "int");
- $db->query($sql);
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".GETPOST("actid", "int");
+ $db->query($sql);
}
@@ -127,32 +131,34 @@
if ($result > 0)
{
- $langs->load("other");
-
- $head = user_prepare_head($object);
-
- print dol_get_fiche_head($head, 'notify', $langs->trans("User"), -1, 'user');
-
- $linkback = ''.$langs->trans("BackToList").'';
-
- dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', '', '', 0, '', '', 0, '');
-
- print '
';
-
- print '
';
- print '
';
-
- // Login
- print ''.$langs->trans("Login").' | ';
- if (!empty($object->ldap_sid) && $object->statut == 0)
- {
- print ''.$langs->trans("LoginAccountDisableInDolibarr").' | ';
- } else {
- print ''.$object->login.' | ';
- }
- print '
'."\n";
-
- /*print ''.$langs->trans("NbOfActiveNotifications").' | '; // Notification for this thirdparty
+ $langs->load("other");
+
+ $head = user_prepare_head($object);
+
+ dol_fiche_head($head, 'notify', $langs->trans("User"), -1, 'user');
+
+ $linkback = ''.$langs->trans("BackToList").'';
+
+ dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', '', '', 0, '', '', 0, '');
+
+ print '';
+
+ print '
';
+ print '
';
+
+ // Login
+ print ''.$langs->trans("Login").' | ';
+ if (!empty($object->ldap_sid) && $object->statut == 0)
+ {
+ print ''.$langs->trans("LoginAccountDisableInDolibarr").' | ';
+ }
+ else
+ {
+ print ''.$object->login.' | ';
+ }
+ print '
'."\n";
+
+ /*print ''.$langs->trans("NbOfActiveNotifications").' | '; // Notification for this thirdparty
print '';
$nbofrecipientemails=0;
$notify=new Notify($db);
@@ -164,164 +170,172 @@
print $nbofrecipientemails;
print ' |
';*/
- print '
';
-
- print '
';
-
- print dol_get_fiche_end();
-
- print "\n";
-
- // Help
- print '';
- print '
'.$langs->trans("NotificationsDesc");
- print '
'.$langs->trans("NotificationsDescUser");
- print '
'.$langs->trans("NotificationsDescContact");
- print '
'.$langs->trans("NotificationsDescGlobal");
- print '';
-
- print '
'."\n";
-
-
- // Add notification form
- print load_fiche_titre($langs->trans("AddNewNotification"), '', '');
-
- print '';
- print '
';
-
- // List of notifications enabled for contacts
- $sql = "SELECT n.rowid, n.type,";
- $sql .= " a.code, a.label,";
- $sql .= " c.rowid as userid, c.lastname, c.firstname, c.email";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,";
- $sql .= " ".MAIN_DB_PREFIX."notify_def as n,";
- $sql .= " ".MAIN_DB_PREFIX."user c";
- $sql .= " WHERE a.rowid = n.fk_action";
- $sql .= " AND c.rowid = n.fk_user";
- $sql .= " AND c.rowid = ".$object->id;
-
- $resql = $db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- } else {
- dol_print_error($db);
- }
-
- // List of active notifications
- print load_fiche_titre($langs->trans("ListOfActiveNotifications").' ('.$num.')', '', '');
-
- // Line with titles
- print '';
- print '';
- print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '"width="45%"', $sortfield, $sortorder);
- print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '"width="35%"', $sortfield, $sortorder);
- print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '"width="10%"', $sortfield, $sortorder);
- print_liste_field_titre('', '', '');
- print '
';
+ $actions[$notifiedevent['rowid']] = $label;
+ }
+ print '';
+ print $object->getNomUrl(1);
+ if (isValidEmail($object->email))
+ {
+ print ' <'.$object->email.'>';
+ }
+ else
+ {
+ $langs->load("errors");
+ print ' '.img_warning().' '.$langs->trans("ErrorBadEMail", $object->email);
+ }
+ print ' | ';
+ print '';
+ print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$form->selectarray("actionid", $actions, '', 1);
+ print ' | ';
+ print '';
+ $type = array('email'=>$langs->trans("EMail"));
+ print $form->selectarray("typeid", $type);
+ print ' | ';
+ print ' | ';
+ print '
';
+ }
+ else
+ {
+ print '';
+ print $langs->trans("YouMustAssignUserMailFirst");
+ print ' |
';
+ }
+
+ print '
';
+
+ print '';
+ print '
';
+
+ // List of notifications enabled for contacts
+ $sql = "SELECT n.rowid, n.type,";
+ $sql .= " a.code, a.label,";
+ $sql .= " c.rowid as userid, c.lastname, c.firstname, c.email";
+ $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,";
+ $sql .= " ".MAIN_DB_PREFIX."notify_def as n,";
+ $sql .= " ".MAIN_DB_PREFIX."user c";
+ $sql .= " WHERE a.rowid = n.fk_action";
+ $sql .= " AND c.rowid = n.fk_user";
+ $sql .= " AND c.rowid = ".$object->id;
+
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+
+ // List of active notifications
+ print load_fiche_titre($langs->trans("ListOfActiveNotifications").' ('.$num.')', '', '');
+
+ // Line with titles
+ print '';
+ print '';
+ print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '"width="45%"', $sortfield, $sortorder);
+ print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '"width="35%"', $sortfield, $sortorder);
+ print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '"width="10%"', $sortfield, $sortorder);
+ print_liste_field_titre('', '', '');
+ print '
';
$langs->load("errors");
$langs->load("other");
- if ($num)
- {
- $i = 0;
-
- $userstatic = new user($db);
-
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
-
- $userstatic->id = $obj->userid;
- $userstatic->lastname = $obj->lastname;
- $userstatic->firstname = $obj->firstname;
- print ''.$userstatic->getNomUrl(1);
- if ($obj->type == 'email')
- {
- if (isValidEmail($obj->email))
- {
- print ' <'.$obj->email.'>';
- } else {
- $langs->load("errors");
- print ' '.img_warning().' '.$langs->trans("ErrorBadEMail", $obj->email);
- }
- }
- print ' | ';
- print '';
- $label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label);
- print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$label;
- print ' | ';
- print '';
- if ($obj->type == 'email') print $langs->trans("Email");
- if ($obj->type == 'sms') print $langs->trans("SMS");
- print ' | ';
- print ''.img_delete().' | ';
- print '
';
- $i++;
- }
- $db->free($resql);
+ if ($num)
+ {
+ $i = 0;
+
+ $userstatic = new user($db);
+
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+
+ $userstatic->id = $obj->userid;
+ $userstatic->lastname = $obj->lastname;
+ $userstatic->firstname = $obj->firstname;
+ print ''.$userstatic->getNomUrl(1);
+ if ($obj->type == 'email')
+ {
+ if (isValidEmail($obj->email))
+ {
+ print ' <'.$obj->email.'>';
+ }
+ else
+ {
+ $langs->load("errors");
+ print ' '.img_warning().' '.$langs->trans("ErrorBadEMail", $obj->email);
+ }
+ }
+ print ' | ';
+ print '';
+ $label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label);
+ print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$label;
+ print ' | ';
+ print '';
+ if ($obj->type == 'email') print $langs->trans("Email");
+ if ($obj->type == 'sms') print $langs->trans("SMS");
+ print ' | ';
+ print ''.img_delete().' | ';
+ print '
';
+ $i++;
+ }
+ $db->free($resql);
}
- // List of notifications enabled for fixed email
- /*
+ // List of notifications enabled for fixed email
+ /*
foreach($conf->global as $key => $val)
{
if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue;
@@ -362,7 +376,7 @@
print ''.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).' | ';
print '';
}*/
- /*if ($user->admin)
+ /*if ($user->admin)
{
$var = ! $var;
print '';
@@ -370,104 +384,108 @@
print ' |
';
}*/
- print '
';
-
-
- print '
'."\n";
-
-
- // List
- $sql = "SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
- $sql .= " c.rowid as id, c.lastname, c.firstname, c.email as contactemail,";
- $sql .= " a.code, a.label";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,";
- $sql .= " ".MAIN_DB_PREFIX."notify as n";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as c ON n.fk_user = c.rowid";
- $sql .= " WHERE a.rowid = n.fk_action";
- $sql .= " AND n.fk_user = ".$object->id;
- $sql .= $db->order($sortfield, $sortorder);
-
- // Count total nb of records
- $nbtotalofrecords = '';
- if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
- {
- $result = $db->query($sql);
- $nbtotalofrecords = $db->num_rows($result);
- if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
- {
- $page = 0;
- $offset = 0;
- }
- }
-
- $sql .= $db->plimit($limit + 1, $offset);
-
- $resql = $db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- } else {
- dol_print_error($db);
- }
-
- $param = '&id='.$object->id;
- if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
- if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
-
- print '';
-} else dol_print_error('', 'RecordNotFound');
+ // print
+ print''.dol_print_date($db->jdate($obj->daten), 'dayhour').' | ';
+ print '
';
+ $i++;
+ }
+ $db->free($resql);
+ }
+ else {
+ print ''.$langs->trans("None").' |
';
+ }
+
+ print '
';
+
+ print '';
+}
+else dol_print_error('', 'RecordNotFound');
// End of page
llxFooter();