--- /tmp/dsg/dolibarr/htdocs/user/notify/github_19.0.3_card.php +++ /tmp/dsg/dolibarr/htdocs/user/notify/client_card.php @@ -28 +27,0 @@ -// Load Dolibarr environment @@ -36 +35 @@ -$langs->loadLangs(array('companies', 'mails', 'admin', 'other', 'errors')); +$langs->loadLangs(array('companies', 'mails', 'admin', 'other')); @@ -39,6 +37,0 @@ -$ref = GETPOST('ref', 'alpha'); - -if (!isset($id) || empty($id)) { - accessforbidden(); -} - @@ -46,5 +39,9 @@ -$actionid = GETPOST('actionid', 'int'); - -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$actionid = GETPOST('actionid'); + +// Security check +if ($user->socid) $id = $user->socid; +$result = restrictedArea($user, 'societe', '', ''); + +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -52,9 +49,3 @@ -if (!$sortorder) { - $sortorder = "DESC"; -} -if (!$sortfield) { - $sortfield = "n.daten"; -} -if (empty($page) || $page == -1) { - $page = 0; -} +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "n.daten"; +if (empty($page) || $page == -1) { $page = 0; } @@ -67,15 +57,0 @@ -// Security check -$object = new User($db); -if ($id > 0 || !empty($ref)) { - $result = $object->fetch($id, $ref, '', 1); - $object->getrights(); -} - -$permissiontoadd = (($object->id == $user->id) || (!empty($user->rights->user->user->lire))); - -// Security check -if ($user->socid) { - $id = $user->socid; -} -$result = restrictedArea($user, 'user', '', '', 'user'); - @@ -87,2 +63,42 @@ -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; +// 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(); + } + } @@ -91,36 +106,0 @@ -// Add a notification -if ($action == 'add') { - $error = 0; - - if ($actionid <= 0) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors'); - $error++; - $action = 'create'; - } - - if (!$error) { - $db->begin(); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; - $sql .= " WHERE fk_user=".((int) $id)." AND fk_action=".((int) $actionid); - if ($db->query($sql)) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec, fk_user, fk_action)"; - $sql .= " VALUES ('".$db->idate($now)."', ".((int) $id).", ".((int) $actionid).")"; - - if (!$db->query($sql)) { - $error++; - dol_print_error($db); - } - } else { - dol_print_error($db); - } - - if (!$error) { - $db->commit(); - } else { - $db->rollback(); - $action = 'create'; - } - } -} - @@ -128,3 +108,4 @@ -if ($action == 'delete') { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".GETPOST("actid", "int"); - $db->query($sql); +if ($action == 'delete') +{ + $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".GETPOST("actid", "int"); + $db->query($sql); @@ -146,3 +127 @@ -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { - $title = $object->name.' - '.$langs->trans("Notification"); -} +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Notification"); @@ -153 +132,161 @@ -if ($result > 0) { +if ($result > 0) +{ + $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 '
'.$langs->trans("Login").' | '; + if (!empty($object->ldap_sid) && $object->statut == 0) + { + print ''.$langs->trans("LoginAccountDisableInDolibarr").' | '; + } + else + { + print ''.$object->login.' | '; + } + print '|
'.$langs->trans("NbOfActiveNotifications").' | '; // Notification for this thirdparty + print ''; + $nbofrecipientemails=0; + $notify=new Notify($db); + $tmparray = $notify->getNotificationsArray('', 0, null, $object->id, array('user')); + foreach($tmparray as $tmpkey => $tmpval) + { + $nbofrecipientemails++; + } + print $nbofrecipientemails; + print ' |
'.$langs->trans("Login").' | '; - if (!empty($object->ldap_sid) && $object->statut == 0) { - print ''; - print $langs->trans("LoginAccountDisableInDolibarr"); - print ' | '; - } else { - print ''; - $addadmin = ''; - if (property_exists($object, 'admin')) { - if (isModEnabled('multicompany') && !empty($object->admin) && empty($object->entity)) { - $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"'); - } elseif (!empty($object->admin)) { - $addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"'); + 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 '
';
+ $listtmp=explode(',',$val);
+ $first=1;
+ foreach($listtmp as $keyemail => $valemail)
+ {
+ if (! $first) print ', ';
+ $first=0;
+ $valemail=trim($valemail);
+ //print $keyemail.' - '.$valemail.' - '.$reg[1].' '; + if (isValidEmail($valemail, 1)) + { + if ($valemail == '__SUPERVISOREMAIL__') print $valemail; + else print ' <'.$valemail.'>'; + } + else + { + print ' '.img_warning().' '.$langs->trans("ErrorBadEMail",$valemail); @@ -192 +361,0 @@ - print showValueWithClipboardCPButton($object->login).$addadmin; @@ -194,133 +363,8 @@ - } - print ' | |||
'.$langs->trans("NbOfActiveNotifications").' | '; // Notification for this thirdparty - print ''; - $nbofrecipientemails=0; - $notify=new Notify($db); - $tmparray = $notify->getNotificationsArray('', 0, null, $object->id, array('user')); - foreach($tmparray as $tmpkey => $tmpval) - { - $nbofrecipientemails++; - } - print $nbofrecipientemails; - print ' |