mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Qual: Uniformize code
This commit is contained in:
parent
b7d190518f
commit
363d50805a
|
|
@ -39,7 +39,7 @@ $langs->load("users");
|
|||
$langs->load("other");
|
||||
$langs->load("commercial");
|
||||
|
||||
$errors = array();
|
||||
$error=0; $errors=array();
|
||||
|
||||
$action = GETPOST('action');
|
||||
|
||||
|
|
@ -88,6 +88,7 @@ if (method_exists($objcanvas->control,'doActions'))
|
|||
}
|
||||
else
|
||||
{
|
||||
$error=$objcanvas->error; $errors=$objcanvas->errors;
|
||||
if ($action=='add') { $objcanvas->action='create'; $action='create'; }
|
||||
if ($action=='update') { $objcanvas->action='edit'; $action='edit'; }
|
||||
}
|
||||
|
|
@ -121,19 +122,19 @@ else
|
|||
}
|
||||
else
|
||||
{
|
||||
$error=$nuser->error; $errors=$nuser->errors;
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg=$nuser->error;
|
||||
|
||||
$error=$nuser->error; $errors=$nuser->errors;
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg=$object->error;
|
||||
$error=$object->error; $errors=$object->errors;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -147,8 +148,6 @@ else
|
|||
// Add contact
|
||||
if (GETPOST("action") == 'add' && $user->rights->societe->contact->creer)
|
||||
{
|
||||
$error=0;
|
||||
|
||||
$db->begin();
|
||||
|
||||
if ($canvas) $object->canvas=$canvas;
|
||||
|
|
@ -178,8 +177,7 @@ else
|
|||
|
||||
if (! $_POST["name"])
|
||||
{
|
||||
$error++;
|
||||
array_push($errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")));
|
||||
$error++; $errors[]=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label"));
|
||||
$_GET["action"] = $_POST["action"] = 'create';
|
||||
}
|
||||
|
||||
|
|
@ -188,8 +186,7 @@ else
|
|||
$id = $object->create($user);
|
||||
if ($id <= 0)
|
||||
{
|
||||
$error++;
|
||||
$errors=($object->error?array($object->error):$object->errors);
|
||||
$error++; $errors[]=($object->error?array($object->error):$object->errors);
|
||||
$_GET["action"] = $_POST["action"] = 'create';
|
||||
}
|
||||
}
|
||||
|
|
@ -223,7 +220,7 @@ else
|
|||
}
|
||||
else
|
||||
{
|
||||
$mesg=$object->error;
|
||||
$error=$object->error; $errors[]=$object->errors;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -231,8 +228,7 @@ else
|
|||
{
|
||||
if (empty($_POST["name"]))
|
||||
{
|
||||
$errors=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
|
||||
$error++;
|
||||
$error++; $errors=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
|
||||
$_GET["action"] = $_POST["action"] = 'edit';
|
||||
}
|
||||
|
||||
|
|
@ -275,7 +271,7 @@ else
|
|||
}
|
||||
else
|
||||
{
|
||||
$mesg=$object->error;
|
||||
$error=$object->error; $errors=$object->errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -405,7 +401,7 @@ else
|
|||
print_fiche_titre($langs->trans("AddContact"));
|
||||
|
||||
// Affiche les erreurs
|
||||
dol_htmloutput_errors($mesg,$errors);
|
||||
dol_htmloutput_errors($error,$errors);
|
||||
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
|
|
@ -587,7 +583,7 @@ else
|
|||
}
|
||||
|
||||
// Affiche les erreurs
|
||||
dol_htmloutput_errors($mesg,$errors);
|
||||
dol_htmloutput_errors($error,$errors);
|
||||
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
|
|
@ -754,11 +750,8 @@ else
|
|||
/*
|
||||
* Fiche en mode visualisation
|
||||
*/
|
||||
if ($msg)
|
||||
{
|
||||
$langs->load("errors");
|
||||
print '<div class="error">'.$langs->trans($msg).'</div>';
|
||||
}
|
||||
|
||||
dol_htmloutput_errors($error,$errors);
|
||||
|
||||
if ($_GET["action"] == 'create_user')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -52,12 +52,10 @@ $socid = GETPOST("socid");
|
|||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
|
||||
$soc = new Societe($db);
|
||||
|
||||
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
|
||||
if (!empty($socid)) $soc->getCanvas($socid);
|
||||
$canvas = (!empty($soc->canvas)?$soc->canvas:GETPOST("canvas"));
|
||||
|
||||
|
||||
if (! empty($canvas))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
|
||||
|
|
@ -72,6 +70,8 @@ else
|
|||
$result = restrictedArea($user, 'societe', $socid);
|
||||
}
|
||||
|
||||
$error=$nuser->error; $errors=$nuser->errors;
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
|
|
@ -85,6 +85,7 @@ if (method_exists($objcanvas->control,'doActions'))
|
|||
// When used with CANVAS
|
||||
// -----------------------------------------
|
||||
$objcanvas->doActions($socid);
|
||||
|
||||
if (empty($objcanvas->error) && (empty($objcanvas->errors) || sizeof($objcanvas->errors) == 0))
|
||||
{
|
||||
if ($action=='add') { $objcanvas->action='create'; $action='create'; }
|
||||
|
|
@ -92,6 +93,7 @@ if (method_exists($objcanvas->control,'doActions'))
|
|||
}
|
||||
else
|
||||
{
|
||||
$error=$objcanvas->error; $errors=$objcanvas->errors;
|
||||
if ($action=='add') { $objcanvas->action='create'; $action='create'; }
|
||||
if ($action=='update') { $objcanvas->action='edit'; $action='edit'; }
|
||||
}
|
||||
|
|
@ -119,7 +121,6 @@ else
|
|||
&& ($action == 'add' || $action == 'update') && $user->rights->societe->creer)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
|
||||
$error=0;
|
||||
|
||||
if ($action == 'update')
|
||||
{
|
||||
|
|
@ -194,23 +195,20 @@ else
|
|||
{
|
||||
if (! empty($soc->email) && ! isValidEMail($soc->email))
|
||||
{
|
||||
$error = 1;
|
||||
$langs->load("errors");
|
||||
$soc->error = $langs->trans("ErrorBadEMail",$soc->email);
|
||||
$error++; $errors[] = $langs->trans("ErrorBadEMail",$soc->email);
|
||||
$action = ($action=='add'?'create':'edit');
|
||||
}
|
||||
if (! empty($soc->url) && ! isValidUrl($soc->url))
|
||||
{
|
||||
$error = 1;
|
||||
$langs->load("errors");
|
||||
$soc->error = $langs->trans("ErrorBadUrl",$soc->url);
|
||||
$error++; $errors[] = $langs->trans("ErrorBadUrl",$soc->url);
|
||||
$action = ($action=='add'?'create':'edit');
|
||||
}
|
||||
if ($soc->fournisseur && ! $conf->fournisseur->enabled)
|
||||
{
|
||||
$error = 1;
|
||||
$langs->load("errors");
|
||||
$soc->error = $langs->trans("ErrorSupplierModuleNotEnabled");
|
||||
$error++; $errors[] = $langs->trans("ErrorSupplierModuleNotEnabled");
|
||||
$action = ($action=='add'?'create':'edit');
|
||||
}
|
||||
}
|
||||
|
|
@ -251,7 +249,7 @@ else
|
|||
}
|
||||
else
|
||||
{
|
||||
$error=$soc->error;
|
||||
$error=$soc->error; $errors=$soc->errors;
|
||||
}
|
||||
|
||||
if ($result >= 0)
|
||||
|
|
@ -565,7 +563,7 @@ else
|
|||
}
|
||||
|
||||
|
||||
dol_htmloutput_errors($soc->error,$soc->errors);
|
||||
dol_htmloutput_errors($error,$errors);
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
|
||||
|
||||
|
|
@ -970,7 +968,7 @@ else
|
|||
}
|
||||
}
|
||||
|
||||
dol_htmloutput_errors($soc->error,$soc->errors);
|
||||
dol_htmloutput_errors($error,errors);
|
||||
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user