diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php
index fb937dc1dbe..a9463be9937 100644
--- a/htdocs/admin/bank.php
+++ b/htdocs/admin/bank.php
@@ -499,7 +499,7 @@ print "\n";
print '';
print dol_get_fiche_end();
-$form->buttonsSaveCancel("Save", '');
+print $form->buttonsSaveCancel("Save", '');
print "\n";
diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php
index 4a2e98fc666..ceaf6aa2ecc 100644
--- a/htdocs/asset/card.php
+++ b/htdocs/asset/card.php
@@ -81,6 +81,8 @@ $permissionnote = $user->rights->asset->write; // Used by the include of actions
$permissiondellink = $user->rights->asset->write; // Used by the include of actions_dellink.inc.php
$upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1];
+$error = 0;
+
/*
* Actions
@@ -93,12 +95,17 @@ if ($reshook < 0) {
}
if (empty($reshook)) {
- $error = 0;
+ $backurlforlist = DOL_URL_ROOT.'/asset/list.php';
- $backurlforlist = dol_buildpath('/asset/list.php', 1);
-
- // Actions cancel, add, update or delete
- include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
+ if (empty($backtopage) || ($cancel && empty($id))) {
+ if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
+ if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
+ $backtopage = $backurlforlist;
+ } else {
+ $backtopage = DOL_URL_ROOT.'/compta/bank/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
+ }
+ }
+ }
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php
index 6f743172617..65175a86c5e 100644
--- a/htdocs/asset/type.php
+++ b/htdocs/asset/type.php
@@ -90,6 +90,7 @@ $hookmanager->initHooks(array('assettypecard', 'globalcard'));
$permissiontoadd = $user->rights->asset->setup_advance;
+
/*
* Actions
*/
@@ -396,7 +397,7 @@ if ($action == 'create') {
print dol_get_fiche_end();
- $form->buttonsSaveCancel("Add");
+ print $form->buttonsSaveCancel("Add");
print "\n";
}
@@ -502,12 +503,12 @@ if ($rowid > 0) {
// Edit
if ($user->rights->asset->write) {
- print '
';
+ print '
';
+
+ print $form->buttonsSaveCancel((($this->withthreadid > 0) ? "SendResponse" : "CreateTicket"), ($this->withcancel ? "Cancel" : ""));
+
+ /*
+ print '
';
print '';
if ($this->withcancel) {
print " ";
print '';
}
print '
';
+ */
print '
'."\n";
diff --git a/htdocs/don/card.php b/htdocs/don/card.php
index c0c81d71aa8..2aa4b971e0f 100644
--- a/htdocs/don/card.php
+++ b/htdocs/don/card.php
@@ -84,259 +84,284 @@ if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
-// Action reopen object
-if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) {
- $object->fetch($id);
+if (empty($reshook)) {
+ $backurlforlist = DOL_URL_ROOT.'/don/list.php';
- $result = $object->reopen($user);
- if ($result >= 0) {
- // Define output language
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
- if (method_exists($object, 'generateDocument')) {
- $outputlangs = $langs;
- $newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
- $newlang = GETPOST('lang_id', 'aZ09');
- }
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
- $newlang = $object->thirdparty->default_lang;
- }
- if (!empty($newlang)) {
- $outputlangs = new Translate("", $conf);
- $outputlangs->setDefaultLang($newlang);
- }
- $model = $object->model_pdf;
- $ret = $object->fetch($id); // Reload to get new records
-
- $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
+ if (empty($backtopage) || ($cancel && empty($id))) {
+ if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
+ if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
+ $backtopage = $backurlforlist;
+ } else {
+ $backtopage = DOL_URL_ROOT.'/don/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
}
}
-
- header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id);
- exit;
- } else {
- setEventMessages($object->error, $object->errors, 'errors');
- }
-}
-
-
-// Action update object
-if ($action == 'update') {
- if (!empty($cancel)) {
- header("Location: ".$_SERVER['PHP_SELF']."?id=".urlencode($id));
- exit;
}
- $error = 0;
-
- if (empty($donation_date)) {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
- $action = "create";
- $error++;
- }
-
- if (empty($amount)) {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
- $action = "create";
- $error++;
- }
-
- if (!$error) {
- $object->fetch($id);
-
- $object->firstname = (string) GETPOST("firstname", 'alpha');
- $object->lastname = (string) GETPOST("lastname", 'alpha');
- $object->societe = (string) GETPOST("societe", 'alpha');
- $object->address = (string) GETPOST("address", 'alpha');
- $object->amount = price2num(GETPOST("amount", 'alpha'));
- $object->town = (string) GETPOST("town", 'alpha');
- $object->zip = (string) GETPOST("zipcode", 'alpha');
- $object->country_id = (int) GETPOST('country_id', 'int');
- $object->email = (string) GETPOST("email", 'alpha');
- $object->date = $donation_date;
- $object->public = $public_donation;
- $object->fk_project = (int) GETPOST("fk_project", 'int');
- $object->note_private = (string) GETPOST("note_private", 'restricthtml');
- $object->note_public = (string) GETPOST("note_public", 'restricthtml');
- $object->modepaymentid = (int) GETPOST('modepayment', 'int');
-
- // Fill array 'array_options' with data from add form
- $ret = $extrafields->setOptionalsFromPost(null, $object);
- if ($ret < 0) {
- $error++;
- }
-
- if ($object->update($user) > 0) {
- header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+ if ($cancel) {
+ if (!empty($backtopageforcancel)) {
+ header("Location: ".$backtopageforcancel);
+ exit;
+ } elseif (!empty($backtopage)) {
+ header("Location: ".$backtopage);
exit;
}
- }
-}
-
-
-// Action add/create object
-if ($action == 'add') {
- if (!empty($cancel)) {
- header("Location: index.php");
- exit;
+ $action = '';
}
- $error = 0;
+ // Action reopen object
+ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) {
+ $object->fetch($id);
- if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES) && !(GETPOST("socid", 'int') > 0)) {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty")), null, 'errors');
- $action = "create";
- $error++;
- }
- if (empty($donation_date)) {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
- $action = "create";
- $error++;
- }
+ $result = $object->reopen($user);
+ if ($result >= 0) {
+ // Define output language
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
+ if (method_exists($object, 'generateDocument')) {
+ $outputlangs = $langs;
+ $newlang = '';
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ $newlang = GETPOST('lang_id', 'aZ09');
+ }
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ $newlang = $object->thirdparty->default_lang;
+ }
+ if (!empty($newlang)) {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+ $model = $object->model_pdf;
+ $ret = $object->fetch($id); // Reload to get new records
- if (empty($amount)) {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
- $action = "create";
- $error++;
- }
+ $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
+ }
+ }
- if (!$error) {
- $object->socid = (int) GETPOST("socid", 'int');
- $object->firstname = (string) GETPOST("firstname", 'alpha');
- $object->lastname = (string) GETPOST("lastname", 'alpha');
- $object->societe = (string) GETPOST("societe", 'alpha');
- $object->address = (string) GETPOST("address", 'alpha');
- $object->amount = price2num(GETPOST("amount", 'alpha'));
- $object->zip = (string) GETPOST("zipcode", 'alpha');
- $object->town = (string) GETPOST("town", 'alpha');
- $object->country_id = (int) GETPOST('country_id', 'int');
- $object->email = (string) GETPOST('email', 'alpha');
- $object->date = $donation_date;
- $object->note_private = (string) GETPOST("note_private", 'restricthtml');
- $object->note_public = (string) GETPOST("note_public", 'restricthtml');
- $object->public = $public_donation;
- $object->fk_project = (int) GETPOST("fk_project", 'int');
- $object->modepaymentid = (int) GETPOST('modepayment', 'int');
-
- // Fill array 'array_options' with data from add form
- $ret = $extrafields->setOptionalsFromPost(null, $object);
- if ($ret < 0) {
- $error++;
- }
-
- $res = $object->create($user);
- if ($res > 0) {
- header("Location: ".$_SERVER['PHP_SELF'].'?id='.$res);
+ header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
-}
-// Action delete object
-if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->don->supprimer) {
- $object->fetch($id);
- $result = $object->delete($user);
- if ($result > 0) {
- header("Location: index.php");
- exit;
- } else {
- dol_syslog($object->error, LOG_DEBUG);
- setEventMessages($object->error, $object->errors, 'errors');
+
+ // Action update object
+ if ($action == 'update') {
+ if (!empty($cancel)) {
+ header("Location: ".$_SERVER['PHP_SELF']."?id=".urlencode($id));
+ exit;
+ }
+
+ $error = 0;
+
+ if (empty($donation_date)) {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
+ $action = "create";
+ $error++;
+ }
+
+ if (empty($amount)) {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
+ $action = "create";
+ $error++;
+ }
+
+ if (!$error) {
+ $object->fetch($id);
+
+ $object->firstname = (string) GETPOST("firstname", 'alpha');
+ $object->lastname = (string) GETPOST("lastname", 'alpha');
+ $object->societe = (string) GETPOST("societe", 'alpha');
+ $object->address = (string) GETPOST("address", 'alpha');
+ $object->amount = price2num(GETPOST("amount", 'alpha'));
+ $object->town = (string) GETPOST("town", 'alpha');
+ $object->zip = (string) GETPOST("zipcode", 'alpha');
+ $object->country_id = (int) GETPOST('country_id', 'int');
+ $object->email = (string) GETPOST("email", 'alpha');
+ $object->date = $donation_date;
+ $object->public = $public_donation;
+ $object->fk_project = (int) GETPOST("fk_project", 'int');
+ $object->note_private = (string) GETPOST("note_private", 'restricthtml');
+ $object->note_public = (string) GETPOST("note_public", 'restricthtml');
+ $object->modepaymentid = (int) GETPOST('modepayment', 'int');
+
+ // Fill array 'array_options' with data from add form
+ $ret = $extrafields->setOptionalsFromPost(null, $object);
+ if ($ret < 0) {
+ $error++;
+ }
+
+ if ($object->update($user) > 0) {
+ header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+ exit;
+ }
+ }
}
-}
-// Action validation
-if ($action == 'valid_promesse') {
- $object->fetch($id);
- if ($object->valid_promesse($id, $user->id) >= 0) {
- setEventMessages($langs->trans("DonationValidated", $object->ref), null);
- $action = '';
- } else {
- setEventMessages($object->error, $object->errors, 'errors');
+
+ // Action add/create object
+ if ($action == 'add') {
+ if (!empty($cancel)) {
+ header("Location: index.php");
+ exit;
+ }
+
+ $error = 0;
+
+ if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES) && !(GETPOST("socid", 'int') > 0)) {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty")), null, 'errors');
+ $action = "create";
+ $error++;
+ }
+ if (empty($donation_date)) {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
+ $action = "create";
+ $error++;
+ }
+
+ if (empty($amount)) {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
+ $action = "create";
+ $error++;
+ }
+
+ if (!$error) {
+ $object->socid = (int) GETPOST("socid", 'int');
+ $object->firstname = (string) GETPOST("firstname", 'alpha');
+ $object->lastname = (string) GETPOST("lastname", 'alpha');
+ $object->societe = (string) GETPOST("societe", 'alpha');
+ $object->address = (string) GETPOST("address", 'alpha');
+ $object->amount = price2num(GETPOST("amount", 'alpha'));
+ $object->zip = (string) GETPOST("zipcode", 'alpha');
+ $object->town = (string) GETPOST("town", 'alpha');
+ $object->country_id = (int) GETPOST('country_id', 'int');
+ $object->email = (string) GETPOST('email', 'alpha');
+ $object->date = $donation_date;
+ $object->note_private = (string) GETPOST("note_private", 'restricthtml');
+ $object->note_public = (string) GETPOST("note_public", 'restricthtml');
+ $object->public = $public_donation;
+ $object->fk_project = (int) GETPOST("fk_project", 'int');
+ $object->modepaymentid = (int) GETPOST('modepayment', 'int');
+
+ // Fill array 'array_options' with data from add form
+ $ret = $extrafields->setOptionalsFromPost(null, $object);
+ if ($ret < 0) {
+ $error++;
+ }
+
+ $res = $object->create($user);
+ if ($res > 0) {
+ header("Location: ".$_SERVER['PHP_SELF'].'?id='.$res);
+ exit;
+ } else {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ }
}
-}
-// Action cancel
-if ($action == 'set_cancel') {
- $object->fetch($id);
- if ($object->set_cancel($id) >= 0) {
- $action = '';
- } else {
- setEventMessages($object->error, $object->errors, 'errors');
+ // Action delete object
+ if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->don->supprimer) {
+ $object->fetch($id);
+ $result = $object->delete($user);
+ if ($result > 0) {
+ header("Location: index.php");
+ exit;
+ } else {
+ dol_syslog($object->error, LOG_DEBUG);
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
}
-}
-// Action set paid
-if ($action == 'set_paid') {
- $object->fetch($id);
- if ($object->setPaid($id, $modepayment) >= 0) {
- $action = '';
- } else {
- setEventMessages($object->error, $object->errors, 'errors');
+ // Action validation
+ if ($action == 'valid_promesse') {
+ $object->fetch($id);
+ if ($object->valid_promesse($id, $user->id) >= 0) {
+ setEventMessages($langs->trans("DonationValidated", $object->ref), null);
+ $action = '';
+ } else {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ }
+
+ // Action cancel
+ if ($action == 'set_cancel') {
+ $object->fetch($id);
+ if ($object->set_cancel($id) >= 0) {
+ $action = '';
+ } else {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ }
+
+ // Action set paid
+ if ($action == 'set_paid') {
+ $object->fetch($id);
+ if ($object->setPaid($id, $modepayment) >= 0) {
+ $action = '';
+ } else {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ } elseif ($action == 'classin' && $user->rights->don->creer) {
+ $object->fetch($id);
+ $object->setProject($projectid);
}
-} elseif ($action == 'classin' && $user->rights->don->creer) {
- $object->fetch($id);
- $object->setProject($projectid);
-}
-// Actions to build doc
-include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
+ // Actions to build doc
+ include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
-// Remove file in doc form
-/*if ($action == 'remove_file')
-{
- $object = new Don($db, 0, GETPOST('id', 'int'));
- if ($object->fetch($id))
+ // Remove file in doc form
+ /*if ($action == 'remove_file')
{
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ $object = new Don($db, 0, GETPOST('id', 'int'));
+ if ($object->fetch($id))
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- $object->fetch_thirdparty();
+ $object->fetch_thirdparty();
- $langs->load("other");
- $upload_dir = $conf->don->dir_output;
- $file = $upload_dir . '/' . GETPOST('file');
- $ret=dol_delete_file($file,0,0,0,$object);
- if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
- else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
- $action='';
+ $langs->load("other");
+ $upload_dir = $conf->don->dir_output;
+ $file = $upload_dir . '/' . GETPOST('file');
+ $ret=dol_delete_file($file,0,0,0,$object);
+ if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
+ else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
+ $action='';
+ }
}
-}
-*/
+ */
-/*
- * Build doc
- */
-/*
-if ($action == 'builddoc')
-{
- $object = new Don($db);
- $result=$object->fetch($id);
-
- // Save last template used to generate document
- if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
-
- // Define output language
- $outputlangs = $langs;
- $newlang='';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
- if (! empty($newlang))
+ /*
+ * Build doc
+ */
+ /*
+ if ($action == 'builddoc')
{
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($newlang);
- }
- $result=don_create($db, $object->id, '', $object->model_pdf, $outputlangs);
- if ($result <= 0)
- {
- dol_print_error($db,$result);
- exit;
+ $object = new Don($db);
+ $result=$object->fetch($id);
+
+ // Save last template used to generate document
+ if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
+
+ // Define output language
+ $outputlangs = $langs;
+ $newlang='';
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
+ if (! empty($newlang))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+ $result=don_create($db, $object->id, '', $object->model_pdf, $outputlangs);
+ if ($result <= 0)
+ {
+ dol_print_error($db,$result);
+ exit;
+ }
}
+ */
}
-*/
/*
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index 86aedebbf34..191eb6a0458 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -138,8 +138,23 @@ if ($reshook < 0) {
}
if (empty($reshook)) {
+ $backurlforlist = DOL_URL_ROOT.'/expensereport/list.php';
+
+ if (empty($backtopage) || ($cancel && empty($id))) {
+ if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
+ if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
+ $backtopage = $backurlforlist;
+ } else {
+ $backtopage = DOL_URL_ROOT.'/expensereport/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
+ }
+ }
+ }
+
if ($cancel) {
- if (!empty($backtopage)) {
+ if (!empty($backtopageforcancel)) {
+ header("Location: ".$backtopageforcancel);
+ exit;
+ } elseif (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php
index 9f94b94ffc5..c1037b15556 100644
--- a/htdocs/fichinter/card.php
+++ b/htdocs/fichinter/card.php
@@ -113,8 +113,23 @@ if ($reshook < 0) {
}
if (empty($reshook)) {
+ $backurlforlist = DOL_URL_ROOT.'/fichinter/list.php';
+
+ if (empty($backtopage) || ($cancel && empty($id))) {
+ if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
+ if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
+ $backtopage = $backurlforlist;
+ } else {
+ $backtopage = DOL_URL_ROOT.'/fichinter/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
+ }
+ }
+ }
+
if ($cancel) {
- if (!empty($backtopage)) {
+ if (!empty($backtopageforcancel)) {
+ header("Location: ".$backtopageforcancel);
+ exit;
+ } elseif (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
@@ -995,6 +1010,7 @@ if ($action == 'create') {
} else {
print '