From 55a4f545ede77f57b230fedc021fdf32c5ec213a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Dec 2010 17:06:04 +0000 Subject: [PATCH] New: After creating an event, go back to original page. --- htdocs/comm/action/fiche.php | 32 +++++++++++++++++++------------- htdocs/comm/action/index.php | 20 +++++++++++--------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 7339189fcd5..8a545e3bab5 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -65,20 +65,21 @@ $contact = new Contact($db); */ if ($_POST["action"] == 'add_action') { - if ($_POST["contactid"]) + $backtopage=''; + if (! empty($_POST["backtopage"])) $backtopage=$_POST["backtopage"]; + if (! $backtopage) + { + if ($socid > 0) $backtopage = DOL_URL_ROOT.'/comm/fiche.php?socid='.$socid; + else $backtopage=DOL_URL_ROOT.'/comm/action/index.php'; + } + + if ($_POST["contactid"]) { $result=$contact->fetch($_POST["contactid"]); } if ($_POST['cancel']) { - $backtopage=''; - if (! empty($_POST["backtopage"])) $backtopage=$_POST["backtopage"]; - if (! $backtopage) - { - if ($socid > 0) $backtopage = DOL_URL_ROOT.'/comm/fiche.php?socid='.$socid; - else $backtopage=DOL_URL_ROOT.'/comm/action/index.php'; - } header("Location: ".$backtopage); exit; } @@ -226,10 +227,10 @@ if ($_POST["action"] == 'add_action') if (! $actioncomm->error) { $db->commit(); - if ($_POST["from"]) + if (! empty($backtopage)) { - dol_syslog("Back to ".$_POST["from"]); - Header("Location: ".$_POST["from"]); + dol_syslog("Back to ".$backtopage); + Header("Location: ".$backtopage); } elseif($idaction) { @@ -396,11 +397,16 @@ if (GETPOST("action") == 'update') } else { - if (! empty($_POST["from"])) + if (! empty($_POST["from"])) // deprecated. Use backtopage instead { header("Location: ".$_POST["from"]); exit; } + if (! empty($_POST["backtopage"])) + { + header("Location: ".$_POST["backtopage"]); + exit; + } } } @@ -717,7 +723,7 @@ if ($id) print ''; print ''; print ''; - if (GETPOST("backtopage")) print ''; + if (GETPOST("backtopage")) print ''; print ''; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index f5bd277182b..1c001755859 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -439,7 +439,7 @@ if ($_GET["action"] != 'show_day') // View by month { $style='cal_other_month'; echo ' \n"; } /* Show days of the current month */ @@ -455,7 +455,7 @@ if ($_GET["action"] != 'show_day') // View by month $style='cal_current_month'; echo ' \n"; } /* Show days after the current month (next month) */ @@ -463,7 +463,7 @@ if ($_GET["action"] != 'show_day') // View by month { $style='cal_other_month'; echo ' \n"; } $tmpday++; @@ -504,15 +504,16 @@ llxFooter('$Date$ - $Revision$'); * @param $day Day * @param $month Month * @param $year Year - * @param $monthshown Month shown in calendar view + * @param $monthshown Current month shown in calendar view * @param $style Style to use for this day * @param $actionarray Array of actions * @param $maxPrint Nb of actions to show each day on month view (0 means non limit) - * @param maxnbofchar Nb of characters to show for event line - * @param companystatic Object thirdparty - * @param contactstatic Object contact + * @param $maxnbofchar Nb of characters to show for event line + * @param $newparam Parameters on current URL + * @param $companystatic Object thirdparty + * @param $contactstatic Object contact */ -function show_day_events($db, $day, $month, $year, $monthshown, $style, &$actionarray, $maxPrint=0, $maxnbofchar=14) +function show_day_events($db, $day, $month, $year, $monthshown, $style, &$actionarray, $maxPrint=0, $maxnbofchar=14, $newparam='') { global $user, $conf, $langs; global $filter, $filtera, $filtert, $filterd, $status; @@ -531,7 +532,8 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$action print '
'; - show_day_events ($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $actionarray, $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW, $maxlength); + show_day_events ($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $actionarray, $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW, $maxlength, $newparam); echo " '; - show_day_events($db, $tmpday, $month, $year, $month, $style, $actionarray, $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW, $maxlength); + show_day_events($db, $tmpday, $month, $year, $month, $style, $actionarray, $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW, $maxlength, $newparam); echo " '; - show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $actionarray, $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW, $maxlength); + show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $actionarray, $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW, $maxlength, $newparam); echo "'; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { - print ''; + //$param='month='.$monthshown.'&year='.$year; + print ''; print img_picto($langs->trans("NewAction"),'edit_add.png'); print ''; }