From 7472316779836cd0934e354d735b19933c2695e5 Mon Sep 17 00:00:00 2001 From: FLIO Date: Fri, 4 Aug 2023 17:38:59 +0200 Subject: [PATCH 1/2] New|NEW(#25044) new option for choose project visibility --- htdocs/langs/en_US/website.lang | 5 ++++- htdocs/langs/fr_FR/website.lang | 3 +++ htdocs/projet/admin/website.php | 12 ++++++++++++ htdocs/public/project/new.php | 10 +++++++++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index a827023eb8aeb..aebb746591482 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -156,4 +156,7 @@ SetWebsiteOnlineBefore=When website is offline, all pages are offline. Change st Booking=Booking Reservation=Reservation PagesViewedPreviousMonth=Pages viewed (previous month) -PagesViewedTotal=Pages viewed (total) \ No newline at end of file +PagesViewedTotal=Pages viewed (total) +Visibility=Visibility +Everyone=Everyone +AssignedContacts=Assigned contacts \ No newline at end of file diff --git a/htdocs/langs/fr_FR/website.lang b/htdocs/langs/fr_FR/website.lang index 45ba06949d802..3d1ca31ef0183 100644 --- a/htdocs/langs/fr_FR/website.lang +++ b/htdocs/langs/fr_FR/website.lang @@ -157,3 +157,6 @@ Booking=Réservation Reservation=Réservation PagesViewedPreviousMonth=Pages vues (mois précédent) PagesViewedTotal=Pages vues (total) +Visibility=Visibilité +Everyone=Tout le monde +AssignedContacts=Contacts assignés diff --git a/htdocs/projet/admin/website.php b/htdocs/projet/admin/website.php index 3be04a9843c3f..118f7c40ebbd1 100644 --- a/htdocs/projet/admin/website.php +++ b/htdocs/projet/admin/website.php @@ -39,6 +39,8 @@ $defaultoppstatus = getDolGlobalInt('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD'); +$visibility = GETPOST('PROJET_VISIBILITY', 'alpha'); + if (!$user->admin) { accessforbidden(); } @@ -61,6 +63,7 @@ if ($action == 'update') { $public = GETPOST('PROJECT_ENABLE_PUBLIC'); $defaultoppstatus = GETPOST('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD', 'int'); + $res = dolibarr_set_const($db, "PROJET_VISIBILITY", $visibility, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PROJECT_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD", $defaultoppstatus, 'chaine', 0, '', $conf->entity); @@ -142,6 +145,15 @@ print $formproject->selectOpportunityStatus('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD', GETPOSTISSET('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD') ? GETPOST('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD', 'int') : $defaultoppstatus, 1, 0, 0, 0, '', 0, 1); print "\n"; + + // project visibility + $arrayofchoices = array('0' => $langs->trans("Everyone"), '1' => $langs->trans("AssignedContacts")); + print ''; + print $langs->trans("Visibility"); + print ''; + print $form->selectarray('PROJET_VISIBILITY', $arrayofchoices, getDolGlobalInt('PROJET_VISIBILITY'), 0); + print "\n"; + print ''; print ''; diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index bd8ccd0790188..b6ceb4672ad18 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -62,6 +62,7 @@ $error = 0; $backtopage = GETPOST('backtopage', 'alpha'); $action = GETPOST('action', 'aZ09'); +$visibility = getDolGlobalInt('PROJET_VISIBILITY'); // Load translation files $langs->loadLangs(array("members", "companies", "install", "other", "projects")); @@ -285,10 +286,17 @@ function llxFooterVierge() $defaultref = 'PJ'.dol_print_date(dol_now(), 'dayrfc'); } + if (empty($visibility)) { + $proj->public = 1; + } elseif ($visibility = 1) { + $proj->public = 1; + } elseif ($visibility = 0) { + $proj->public = 0; + } + $proj->ref = $defaultref; $proj->statut = $proj::STATUS_DRAFT; $proj->status = $proj::STATUS_DRAFT; - $proj->public = 1; $proj->usage_opportunity = 1; $proj->title = $langs->trans("LeadFromPublicForm"); $proj->description = GETPOST("description", "alphanohtml"); From fb51b4555a053f9111d8d743afa136959a76f7da Mon Sep 17 00:00:00 2001 From: FLIO Date: Fri, 4 Aug 2023 18:12:02 +0200 Subject: [PATCH 2/2] edit the select for 0 assigned and 1 everyone --- htdocs/projet/admin/website.php | 4 ++-- htdocs/public/project/new.php | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/projet/admin/website.php b/htdocs/projet/admin/website.php index 118f7c40ebbd1..445638301282d 100644 --- a/htdocs/projet/admin/website.php +++ b/htdocs/projet/admin/website.php @@ -147,8 +147,8 @@ // project visibility - $arrayofchoices = array('0' => $langs->trans("Everyone"), '1' => $langs->trans("AssignedContacts")); - print ''; + $arrayofchoices = array('0' => $langs->trans("AssignedContacts"), '1' => $langs->trans("Everyone")); + print ''; print $langs->trans("Visibility"); print ''; print $form->selectarray('PROJET_VISIBILITY', $arrayofchoices, getDolGlobalInt('PROJET_VISIBILITY'), 0); diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index b6ceb4672ad18..4a76ca442c391 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -62,7 +62,6 @@ $error = 0; $backtopage = GETPOST('backtopage', 'alpha'); $action = GETPOST('action', 'aZ09'); -$visibility = getDolGlobalInt('PROJET_VISIBILITY'); // Load translation files $langs->loadLangs(array("members", "companies", "install", "other", "projects")); @@ -207,6 +206,8 @@ function llxFooterVierge() $errmsg .= $langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Project"))."
\n"; } + $visibility = getDolGlobalString('PROJET_VISIBILITY'); + $proj = new Project($db); $thirdparty = new Societe($db); @@ -286,12 +287,12 @@ function llxFooterVierge() $defaultref = 'PJ'.dol_print_date(dol_now(), 'dayrfc'); } - if (empty($visibility)) { - $proj->public = 1; - } elseif ($visibility = 1) { + if ($visibility === "1") { $proj->public = 1; - } elseif ($visibility = 0) { + } elseif ($visibility === "0") { $proj->public = 0; + } elseif (empty($visibility)) { + $proj->public = 1; } $proj->ref = $defaultref;