From 36fbba2ac24790128dee75e55d3e9dbe72898c78 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2021 17:40:14 +0100 Subject: [PATCH] Make page to setup notification simpler --- htdocs/societe/notify/card.php | 110 +++++++++++++-------------------- 1 file changed, 44 insertions(+), 66 deletions(-) diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index 7f813bba72d..c5d06f1e756 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/triggers/interface_50_modNotification_Notification.class.php'; -$langs->loadLangs(array("companies", "mails", "admin", "other")); +$langs->loadLangs(array("companies", "mails", "admin", "other", "errors")); $socid = GETPOST("socid", 'int'); $action = GETPOST('action', 'aZ09'); @@ -219,64 +219,6 @@ if ($result > 0) print '

'."\n"; - // Add notification form - print load_fiche_titre($langs->trans("AddNewNotification"), '', ''); - - print '
'; - print ''; - print ''; - - $param = "&socid=".$socid; - - // 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"; - - $var = false; - $listofemails = $object->thirdparty_and_contact_email_array(); - if (count($listofemails) > 0) - { - $actions = array(); - - // Load array of available notifications - $notificationtrigger = new InterfaceNotification($db); - $listofmanagedeventfornotification = $notificationtrigger->getListOfManagedEvents(); - - foreach ($listofmanagedeventfornotification as $managedeventfornotification) - { - $label = ($langs->trans("Notify_".$managedeventfornotification['code']) != "Notify_".$managedeventfornotification['code'] ? $langs->trans("Notify_".$managedeventfornotification['code']) : $managedeventfornotification['label']); - $actions[$managedeventfornotification['rowid']] = $label; - } - print ''; - print ''; - print ''; - print ''; - print ''; - } else { - print ''; - } - - print '
'; - print img_picto('', 'contact', '', false, 0, 0, '', 'paddingright').$form->selectarray("contactid", $listofemails, '', 0, 0, 0, '', 0, 0, 0, '', 'maxwidthonsmartphone'); - print ''; - print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$form->selectarray("actionid", $actions, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidthonsmartphone'); - print ''; - $type = array('email'=>$langs->trans("EMail")); - print $form->selectarray("typeid", $type); - print '
'; - print $langs->trans("YouMustCreateContactFirst"); - print '
'; - - - print '
'; - print '
'; - - // List of notifications enabled for contacts $sql = "SELECT n.rowid, n.type,"; $sql .= " a.code, a.label,"; @@ -296,20 +238,58 @@ if ($result > 0) dol_print_error($db); } - // List of active notifications + + // Add notification form print load_fiche_titre($langs->trans("ListOfActiveNotifications").' ('.$num.')', '', ''); + print '
'; + print ''; + print ''; + + $param = "&socid=".$socid; + // 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 ''; + print_liste_field_titre(''); + print "\n"; + + // Line to add a new subscription + $listofemails = $object->thirdparty_and_contact_email_array(); + if (count($listofemails) > 0) + { + $actions = array(); + + // Load array of available notifications + $notificationtrigger = new InterfaceNotification($db); + $listofmanagedeventfornotification = $notificationtrigger->getListOfManagedEvents(); + + foreach ($listofmanagedeventfornotification as $managedeventfornotification) + { + $label = ($langs->trans("Notify_".$managedeventfornotification['code']) != "Notify_".$managedeventfornotification['code'] ? $langs->trans("Notify_".$managedeventfornotification['code']) : $managedeventfornotification['label']); + $actions[$managedeventfornotification['rowid']] = $label; + } + print ''; + print ''; + print ''; + print ''; + print ''; + } else { + print ''; + } - $langs->load("errors"); - $langs->load("other"); if ($num) { @@ -358,7 +338,6 @@ if ($result > 0) foreach($conf->global as $key => $val) { if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue; - $var = ! $var; print '';
'; + print img_picto('', 'contact', '', false, 0, 0, '', 'paddingright').$form->selectarray("contactid", $listofemails, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidthonsmartphone'); + print ''; + print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$form->selectarray("actionid", $actions, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidthonsmartphone'); + print ''; + $type = array('email'=>$langs->trans("EMail")); + print $form->selectarray("typeid", $type); + print '
'; + print $langs->trans("YouMustCreateContactFirst"); + print '
'; $listtmp=explode(',',$val); $first=1; @@ -399,7 +378,6 @@ if ($result > 0) /*if ($user->admin) { - $var = ! $var; print '
'; print '+ '.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).''; print '