From 1851310bbefdc0ffe81e63713e50558294201b39 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Tue, 29 Sep 2015 14:31:55 +0200
Subject: [PATCH] NEW Add cancel button on thirdparty create page

---
 htdocs/societe/soc.php | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index d9730aeb8d3..0a961d5637f 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -56,6 +56,7 @@ if (! empty($conf->notification->enabled)) $langs->load("mails");
 $mesg=''; $error=0; $errors=array();
 
 $action		= (GETPOST('action') ? GETPOST('action') : 'view');
+$cancel     = GETPOST('cancel');
 $backtopage = GETPOST('backtopage','alpha');
 $confirm	= GETPOST('confirm');
 $socid		= GETPOST('socid','int');
@@ -98,6 +99,16 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
 
 if (empty($reshook))
 {
+    if ($cancel)
+    {
+        $action='';
+        if (! empty($backtopage))
+        {
+            header("Location: ".$backtopage);
+            exit;
+        }    
+    }
+    
 	if ($action == 'confirm_merge' && $confirm == 'yes')
 	{
 		$object->fetch($socid);
@@ -1273,7 +1284,12 @@ else
         dol_fiche_end();
 
         print '<div class="center">';
-        print '<input type="submit" class="button" value="'.$langs->trans('AddThirdParty').'">';
+        print '<input type="submit" class="button" name="submit" value="'.$langs->trans('AddThirdParty').'">';
+        if ($backtopage)
+        {
+            print ' &nbsp; ';
+            print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
+        }
         print '</div>'."\n";
 
         print '</form>'."\n";
-- 
GitLab