Fix: uniformize code

This commit is contained in:
Regis Houssin 2011-05-14 05:31:41 +00:00
parent 118ee129fe
commit ed118e7009

View File

@ -45,6 +45,7 @@ $langs->load("users");
if ($conf->notification->enabled) $langs->load("mails"); if ($conf->notification->enabled) $langs->load("mails");
$action = GETPOST('action'); $action = GETPOST('action');
$confirm = GETPOST('confirm');
// Security check // Security check
$socid = GETPOST("socid"); $socid = GETPOST("socid");
@ -114,12 +115,12 @@ else
// Add new third party // Add new third party
if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
&& ($_POST["action"] == 'add' || $_POST["action"] == 'update') && $user->rights->societe->creer) && ($action == 'add' || $action == 'update') && $user->rights->societe->creer)
{ {
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
$error=0; $error=0;
if ($_POST["action"] == 'update') if ($action == 'update')
{ {
// Load properties of company // Load properties of company
$soc->fetch($socid); $soc->fetch($socid);
@ -195,27 +196,27 @@ else
$error = 1; $error = 1;
$langs->load("errors"); $langs->load("errors");
$soc->error = $langs->trans("ErrorBadEMail",$soc->email); $soc->error = $langs->trans("ErrorBadEMail",$soc->email);
$_GET["action"] = $_POST["action"]=='add'?'create':'edit'; $action = ($action=='add'?'create':'edit');
} }
if (! empty($soc->url) && ! isValidUrl($soc->url)) if (! empty($soc->url) && ! isValidUrl($soc->url))
{ {
$error = 1; $error = 1;
$langs->load("errors"); $langs->load("errors");
$soc->error = $langs->trans("ErrorBadUrl",$soc->url); $soc->error = $langs->trans("ErrorBadUrl",$soc->url);
$_GET["action"] = $_POST["action"]=='add'?'create':'edit'; $action = ($action=='add'?'create':'edit');
} }
if ($soc->fournisseur && ! $conf->fournisseur->enabled) if ($soc->fournisseur && ! $conf->fournisseur->enabled)
{ {
$error = 1; $error = 1;
$langs->load("errors"); $langs->load("errors");
$soc->error = $langs->trans("ErrorSupplierModuleNotEnabled"); $soc->error = $langs->trans("ErrorSupplierModuleNotEnabled");
$_GET["action"] = $_POST["action"]=='add'?'create':'edit'; $action = ($action=='add'?'create':'edit');
} }
} }
if (! $error) if (! $error)
{ {
if ($_POST["action"] == 'add') if ($action == 'add')
{ {
$db->begin(); $db->begin();
@ -268,11 +269,11 @@ else
$langs->load("errors"); $langs->load("errors");
$mesg=$langs->trans($soc->error); $mesg=$langs->trans($soc->error);
$_GET["action"]='create'; $action='create';
} }
} }
if ($_POST["action"] == 'update') if ($action == 'update')
{ {
if ($_POST["cancel"]) if ($_POST["cancel"])
{ {
@ -299,14 +300,14 @@ else
$soc->id = $socid; $soc->id = $socid;
$mesg = $soc->error; $mesg = $soc->error;
$_GET["action"]= "edit"; $action= "edit";
} }
} }
} }
} }
// Delete third party // Delete third party
if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes' && $user->rights->societe->supprimer) if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer)
{ {
$soc->fetch($socid); $soc->fetch($socid);
$result = $soc->delete($socid); $result = $soc->delete($socid);
@ -320,7 +321,7 @@ else
{ {
$langs->load("errors"); $langs->load("errors");
$mesg=$langs->trans($soc->error); $mesg=$langs->trans($soc->error);
$_GET["action"]=''; $action='';
} }
} }
@ -328,7 +329,7 @@ else
/* /*
* Generate document * Generate document
*/ */
if (GETPOST('action') == 'builddoc') // En get ou en post if ($action == 'builddoc') // En get ou en post
{ {
if (is_numeric(GETPOST('model'))) if (is_numeric(GETPOST('model')))
{ {
@ -448,7 +449,7 @@ else
// ----------------------------------------- // -----------------------------------------
// When used in standard mode // When used in standard mode
// ----------------------------------------- // -----------------------------------------
if (GETPOST('action') == 'create') if ($action == 'create')
{ {
/* /*
* Creation * Creation
@ -896,7 +897,7 @@ else
print '</table>'."\n"; print '</table>'."\n";
print '</form>'."\n"; print '</form>'."\n";
} }
elseif (GETPOST('action') == 'edit') elseif ($action == 'edit')
{ {
/* /*
* Edition * Edition
@ -1327,7 +1328,7 @@ else
// Confirm delete third party // Confirm delete third party
if (GETPOST("action") == 'delete') if ($action == 'delete')
{ {
$html = new Form($db); $html = new Form($db);
$ret=$html->form_confirm($_SERVER["PHP_SELF"]."?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,1); $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,1);