--- /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 '
'; + + print '
'; + print ''; + + // Login + print ''; + if (!empty($object->ldap_sid) && $object->statut == 0) + { + print ''; + } + else + { + print ''; + } + print ''."\n"; + + /*print ''; // Notification for this thirdparty + print '';*/ + + print '
'.$langs->trans("Login").''.$langs->trans("LoginAccountDisableInDolibarr").''.$object->login.'
'.$langs->trans("NbOfActiveNotifications").''; + $nbofrecipientemails=0; + $notify=new Notify($db); + $tmparray = $notify->getNotificationsArray('', 0, null, $object->id, array('user')); + foreach($tmparray as $tmpkey => $tmpval) + { + $nbofrecipientemails++; + } + print $nbofrecipientemails; + print '
'; + + print '
'; + + dol_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 ''; + print ''; + + $param = "&id=".$id; + + // 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 "\n"; + + + // $listofemails=$object->thirdparty_and_contact_email_array(); + if ($object->email) + { + $actions = array(); + + // Load array of available notifications + $notificationtrigger = new InterfaceNotification($db); + $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents(); + + foreach ($listofnotifiedevents as $notifiedevent) + { + $label = ($langs->trans("Notify_".$notifiedevent['code']) != "Notify_".$notifiedevent['code'] ? $langs->trans("Notify_".$notifiedevent['code']) : $notifiedevent['label']); + $actions[$notifiedevent['rowid']] = $label; + } + print ''; + print ''; + print ''; + print ''; + print ''; + } + else + { + print ''; + } + + 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 img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$form->selectarray("actionid", $actions, '', 1); + print ''; + $type = array('email'=>$langs->trans("EMail")); + print $form->selectarray("typeid", $type); + print '
'; + print $langs->trans("YouMustAssignUserMailFirst"); + 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"); @@ -156,34 +295,65 @@ - $head = user_prepare_head($object); - - print dol_get_fiche_head($head, 'notify', $langs->trans("User"), -1, 'user'); - - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = ''; - $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); - $morehtmlref .= ''; - - $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id); - $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->transnoentitiesnoconv("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover'); - - dol_banner_tab($object, 'id', $linkback, $user->hasRight('user', 'user', 'lire') || $user->admin, 'rowid', 'ref', $morehtmlref, '', 0, '', '', 0, ''); - - print '
'; - - print '
'; - print '
'; - - // Login - print ''; - if (!empty($object->ldap_sid) && $object->statut == 0) { - print ''; - } else { - print ''; + print ''; + print ''; + print ''; + print ''; + $i++; + } + $db->free($resql); + } + + // List of notifications enabled for fixed email + /* + foreach($conf->global as $key => $val) + { + if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue; + $var = ! $var; + print ''."\n"; - - /*print ''; // Notification for this thirdparty - print '';*/ - - print '
'.$langs->trans("Login").''; - print $langs->trans("LoginAccountDisableInDolibarr"); - 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 ''; + $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 ''; + if ($obj->type == 'email') print $langs->trans("Email"); + if ($obj->type == 'sms') print $langs->trans("SMS"); + print ''.img_delete().'
'; + $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").''; - $nbofrecipientemails=0; - $notify=new Notify($db); - $tmparray = $notify->getNotificationsArray('', 0, null, $object->id, array('user')); - foreach($tmparray as $tmpkey => $tmpval) - { - $nbofrecipientemails++; - } - print $nbofrecipientemails; - 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 ''; - print ''; - - $param = "&id=".urlencode($id); - - // 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 "\n"; - - 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.entity, c.login, c.lastname, c.firstname, c.email, c.statut as status"; - $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 = ".((int) $object->id); - $sql .= " AND c.entity IN (".getEntity('user').')'; - - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - } else { - dol_print_error($db); - } - - $newcardbutton = ''; - $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); - - $title = $langs->trans("ListOfActiveNotifications"); - - // List of active notifications - //print load_fiche_titre($langs->trans("ListOfActiveNotifications").' ('.$num.')', '', ''); - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $num, 'email', 0, $newcardbutton, '', $limit, 0, 0, 1); - - // 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 ''; - - - if ($action == 'create') { - // $listofemails=$object->thirdparty_and_contact_email_array(); - if ($object->email) { - $actions = array(); - - // Load array of available notifications - $notificationtrigger = new InterfaceNotification($db); - $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents(); - - foreach ($listofnotifiedevents as $notifiedevent) { - $label = ($langs->trans("Notify_".$notifiedevent['code']) != "Notify_".$notifiedevent['code'] ? $langs->trans("Notify_".$notifiedevent['code']) : $notifiedevent['label']); - $actions[$notifiedevent['rowid']] = $label; - } - print ''; - print ''; - print ''; - print ''; - print ''; - } else { - print ''; + print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } - $db->free($resql); - } else { - print ''; - } - // List of notifications enabled for fixed email - /* - foreach($conf->global as $key => $val) { - if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue; - print ''; - print ''; - print ''; - print ''; - print ''; - }*/ - /*if ($user->admin) { - print ''; - }*/ - } - - 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 img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$form->selectarray("actionid", $actions, '', 1); - print ''; - $type = array('email'=>$langs->trans("EMail")); - print $form->selectarray("typeid", $type); - print ''; - print ''; - print ' '; - print ''; - print '
'; - print $langs->trans("YouMustAssignUserMailFirst"); - print '
'; + $notifcode=preg_replace('/_THRESHOLD_.*$/','',$reg[1]); + $notifcodecond=preg_replace('/^.*_(THRESHOLD_)/','$1',$reg[1]); + $label=($langs->trans("Notify_".$notifcode)!="Notify_".$notifcode?$langs->trans("Notify_".$notifcode):$notifcode); + print $label; + if (preg_match('/^THRESHOLD_HIGHER_(.*)$/',$notifcodecond,$regcond) && ($regcond[1] > 0)) + { + print ' - '.$langs->trans("IfAmountHigherThan",$regcond[1]); @@ -328,177 +372,104 @@ - } else { - 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; - $userstatic->email = $obj->email; - $userstatic->statut = $obj->status; - - 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 ''; - $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 ''; - if ($obj->type == 'email') { - print $langs->trans("Email"); - } - if ($obj->type == 'sms') { - print $langs->trans("SMS"); - } - print ''.img_delete().'
'.$langs->trans("None").'
'; - $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); - } - } - print '
'; - $notifcode=preg_replace('/_THRESHOLD_.*$/','',$reg[1]); - $notifcodecond=preg_replace('/^.*_(THRESHOLD_)/','$1',$reg[1]); - $label=($langs->trans("Notify_".$notifcode)!="Notify_".$notifcode?$langs->trans("Notify_".$notifcode):$notifcode); - print $label; - if (preg_match('/^THRESHOLD_HIGHER_(.*)$/',$notifcodecond,$regcond) && ($regcond[1] > 0)) { - print ' - '.$langs->trans("IfAmountHigherThan",$regcond[1]); - } - print ''; - print $langs->trans("Email"); - print ''.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).'
'; - print '+ '.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).''; - 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, c.statut as status,"; - $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 = ".((int) $object->id); - $sql .= $db->order($sortfield, $sortorder); - - // Count total nb of records - $nbtotalofrecords = ''; - if (!getDolGlobalInt('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 '
'; - if (isset($optioncss) && $optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - // List of notifications done - print_barre_liste($langs->trans("ListOfNotificationsDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'email', 0, '', '', $limit); - - // Line with titles - print ''; - print ''; - print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '', $sortfield, $sortorder); - print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder); - print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '', $sortfield, $sortorder); - //print_liste_field_titre("Object",$_SERVER["PHP_SELF"],"",'',$param,'"',$sortfield,$sortorder); - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "n.daten", '', $param, '', $sortfield, $sortorder, 'right '); - print ''; - - if ($num) { - $i = 0; - - $userstatic = new User($db); - - while ($i < $num) { - $obj = $db->fetch_object($resql); - - print ''; + print ''; + print ''; + print ''; + }*/ + /*if ($user->admin) + { + $var = ! $var; + print ''; + }*/ + + print '
'; - if ($obj->id > 0) { - $userstatic->id = $obj->id; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->statut = $obj->status; - $userstatic->email = $obj->email; - print $userstatic->getNomUrl(1); - print $obj->email ? ' <'.$obj->email.'>' : $langs->trans("NoMail"); - } else { + print ''; + print $langs->trans("Email"); + print ''.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).'
'; + print '+ '.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).''; + 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 ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + // List of notifications done + print_barre_liste($langs->trans("ListOfNotificationsDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); + + // Line with titles + print ''; + print ''; + print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '', $sortfield, $sortorder); + print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder); + print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '', $sortfield, $sortorder); + //print_liste_field_titre("Object",$_SERVER["PHP_SELF"],"",'',$param,'"',$sortfield,$sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "n.daten", '', $param, '', $sortfield, $sortorder, 'right '); + print ''; + + if ($num) + { + $i = 0; + + $userstatic = new User($db); + + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + print ''; - print ''; - print ''; - // TODO Add link to object here for other types - /*print ''; + print ''; + print ''; + // TODO Add link to object here for other types + /*print '';*/ - // print - print''; - print ''; - $i++; - } - $db->free($resql); - } else { - print ''; - } - - print '
'; + if ($obj->id > 0) + { + $userstatic->id = $obj->id; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + print $userstatic->getNomUrl(1); + print $obj->email ? ' <'.$obj->email.'>' : $langs->trans("NoMail"); + } + else + { @@ -506,17 +477,14 @@ - } - print ''; - $label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label); - print $label; - print ''; - if ($obj->type == 'email') { - print $langs->trans("Email"); - } - if ($obj->type == 'sms') { - print $langs->trans("Sms"); - } - print ''; - if ($obj->object_type == 'order') { + } + print ''; + $label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label); + print $label; + print ''; + if ($obj->type == 'email') print $langs->trans("Email"); + if ($obj->type == 'sms') print $langs->trans("Sms"); + print ''; + if ($obj->object_type == 'order') + { @@ -526,17 +494,16 @@ - } - print ''.dol_print_date($db->jdate($obj->daten), 'dayhour').'
'.$langs->trans("None").'
'; - - print '
'; -} else { - dol_print_error('', 'RecordNotFound'); + } + print '';*/ + // print + print''.dol_print_date($db->jdate($obj->daten), 'dayhour').''; + print ''; + $i++; + } + $db->free($resql); + } + else { + print ''.$langs->trans("None").''; + } + + print ''; + + print ''; @@ -543,0 +511 @@ +else dol_print_error('', 'RecordNotFound');