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