diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php
index a15a70797e4..91a8f7e44cc 100644
--- a/htdocs/admin/perms.php
+++ b/htdocs/admin/perms.php
@@ -30,10 +30,13 @@ $langs->load("admin");
$langs->load("users");
$langs->load("other");
-if (!$user->admin)
- accessforbidden();
+if (!$user->admin) accessforbidden();
+/*
+ * Actions
+ */
+
if ($_GET["action"] == 'add')
{
$sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=1";
@@ -79,56 +82,56 @@ $modulesdir = array();
foreach ($conf->file->dol_document_root as $type => $dirroot)
{
- $modulesdir[] = $dirroot . "/includes/modules/";
+ $modulesdir[] = $dirroot . "/includes/modules/";
- if ($type == 'alt')
- {
- $handle=@opendir($dirroot);
- if (is_resource($handle))
- {
- while (($file = readdir($handle))!==false)
- {
- if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
- {
- if (is_dir($dirroot . '/' . $file . '/includes/modules/'))
- {
- $modulesdir[] = $dirroot . '/' . $file . '/includes/modules/';
- }
- }
- }
- closedir($handle);
- }
- }
+ if ($type == 'alt')
+ {
+ $handle=@opendir($dirroot);
+ if (is_resource($handle))
+ {
+ while (($file = readdir($handle))!==false)
+ {
+ if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
+ {
+ if (is_dir($dirroot . '/' . $file . '/includes/modules/'))
+ {
+ $modulesdir[] = $dirroot . '/' . $file . '/includes/modules/';
+ }
+ }
+ }
+ closedir($handle);
+ }
+ }
}
foreach ($modulesdir as $dir)
{
- // Load modules attributes in arrays (name, numero, orders) from dir directory
- //print $dir."\n
";
- $handle=@opendir($dir);
- if (is_resource($handle))
- {
- while (($file = readdir($handle))!==false)
- {
- if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
- {
- $modName = substr($file, 0, dol_strlen($file) - 10);
+ // Load modules attributes in arrays (name, numero, orders) from dir directory
+ //print $dir."\n
";
+ $handle=@opendir($dir);
+ if (is_resource($handle))
+ {
+ while (($file = readdir($handle))!==false)
+ {
+ if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
+ {
+ $modName = substr($file, 0, dol_strlen($file) - 10);
- if ($modName)
- {
- include_once($dir."/".$file);
- $objMod = new $modName($db);
- if ($objMod->rights_class) {
+ if ($modName)
+ {
+ include_once($dir."/".$file);
+ $objMod = new $modName($db);
+ if ($objMod->rights_class) {
- $ret=$objMod->insert_permissions(0);
+ $ret=$objMod->insert_permissions(0);
- $modules[$objMod->rights_class]=$objMod;
- //print "modules[".$objMod->rights_class."]=$objMod;";
- }
- }
- }
- }
- }
+ $modules[$objMod->rights_class]=$objMod;
+ //print "modules[".$objMod->rights_class."]=$objMod;";
+ }
+ }
+ }
+ }
+ }
}
$db->commit();
diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php
index 85b5ee9b08e..5ef95680a74 100644
--- a/htdocs/admin/prelevement.php
+++ b/htdocs/admin/prelevement.php
@@ -33,74 +33,79 @@ $langs->load("admin");
$langs->load("withdrawals");
// Security check
-if (!$user->admin)
-accessforbidden();
+if (!$user->admin) accessforbidden();
$action = GETPOST("action");
+
+/*
+ * Actions
+ */
+
if ($action == "set")
{
- $db->begin();
- for ($i = 0 ; $i < 2 ; $i++)
- {
- $res = dolibarr_set_const($db, $_POST["nom$i"], $_POST["value$i"],'chaine',0,'',$conf->entity);
- if (! $res > 0) $error++;
- }
-
- $id=$_POST["PRELEVEMENT_ID_BANKACCOUNT"];
- $account = new Account($db, $id);
-
- if($account->fetch($id)>0)
- {
- $res = dolibarr_set_const($db, "PRELEVEMENT_ID_BANKACCOUNT", $id,'chaine',0,'',$conf->entity);
- if (! $res > 0) $error++;
- $res = dolibarr_set_const($db, "PRELEVEMENT_CODE_BANQUE", $account->code_banque,'chaine',0,'',$conf->entity);
- if (! $res > 0) $error++;
- $res = dolibarr_set_const($db, "PRELEVEMENT_CODE_GUICHET", $account->code_guichet,'chaine',0,'',$conf->entity);
- if (! $res > 0) $error++;
- $res = dolibarr_set_const($db, "PRELEVEMENT_NUMERO_COMPTE", $account->number,'chaine',0,'',$conf->entity);
- if (! $res > 0) $error++;
- $res = dolibarr_set_const($db, "PRELEVEMENT_NUMBER_KEY", $account->cle_rib,'chaine',0,'',$conf->entity);
- if (! $res > 0) $error++;
- $res = dolibarr_set_const($db, "PRELEVEMENT_IBAN", $account->iban,'chaine',0,'',$conf->entity);
- if (! $res > 0) $error++;
- $res = dolibarr_set_const($db, "PRELEVEMENT_BIC", $account->bic,'chaine',0,'',$conf->entity);
- if (! $res > 0) $error++;
- $res = dolibarr_set_const($db, "PRELEVEMENT_RAISON_SOCIALE", $account->proprio,'chaine',0,'',$conf->entity);
- if (! $res > 0) $error++;
- }
- else $error++;
-
- if (! $error)
+ $db->begin();
+ for ($i = 0 ; $i < 2 ; $i++)
{
- $db->commit();
+ $res = dolibarr_set_const($db, $_POST["nom$i"], $_POST["value$i"],'chaine',0,'',$conf->entity);
+ if (! $res > 0) $error++;
+ }
+
+ $id=$_POST["PRELEVEMENT_ID_BANKACCOUNT"];
+ $account = new Account($db, $id);
+
+ if($account->fetch($id)>0)
+ {
+ $res = dolibarr_set_const($db, "PRELEVEMENT_ID_BANKACCOUNT", $id,'chaine',0,'',$conf->entity);
+ if (! $res > 0) $error++;
+ $res = dolibarr_set_const($db, "PRELEVEMENT_CODE_BANQUE", $account->code_banque,'chaine',0,'',$conf->entity);
+ if (! $res > 0) $error++;
+ $res = dolibarr_set_const($db, "PRELEVEMENT_CODE_GUICHET", $account->code_guichet,'chaine',0,'',$conf->entity);
+ if (! $res > 0) $error++;
+ $res = dolibarr_set_const($db, "PRELEVEMENT_NUMERO_COMPTE", $account->number,'chaine',0,'',$conf->entity);
+ if (! $res > 0) $error++;
+ $res = dolibarr_set_const($db, "PRELEVEMENT_NUMBER_KEY", $account->cle_rib,'chaine',0,'',$conf->entity);
+ if (! $res > 0) $error++;
+ $res = dolibarr_set_const($db, "PRELEVEMENT_IBAN", $account->iban,'chaine',0,'',$conf->entity);
+ if (! $res > 0) $error++;
+ $res = dolibarr_set_const($db, "PRELEVEMENT_BIC", $account->bic,'chaine',0,'',$conf->entity);
+ if (! $res > 0) $error++;
+ $res = dolibarr_set_const($db, "PRELEVEMENT_RAISON_SOCIALE", $account->proprio,'chaine',0,'',$conf->entity);
+ if (! $res > 0) $error++;
+ }
+ else $error++;
+
+ if (! $error)
+ {
+ $db->commit();
$mesg = "".$langs->trans("SetupSaved")."";
}
else
{
- $db->rollback();
+ $db->rollback();
$mesg = "".$langs->trans("Error")."";
}
}
if ($action == "addnotif")
{
- $bon = new BonPrelevement($db);
- $bon->AddNotification($db,$_POST["user"],$_POST["action"]);
+ $bon = new BonPrelevement($db);
+ $bon->AddNotification($db,$_POST["user"],$_POST["action"]);
- Header("Location: prelevement.php");
- exit;
+ Header("Location: prelevement.php");
+ exit;
}
if ($action == "deletenotif")
{
- $bon = new BonPrelevement($db);
- $bon->DeleteNotificationById($_GET["notif"]);
+ $bon = new BonPrelevement($db);
+ $bon->DeleteNotificationById($_GET["notif"]);
- Header("Location: prelevement.php");
- exit;
+ Header("Location: prelevement.php");
+ exit;
}
+
/*
* View
*/
@@ -157,39 +162,39 @@ print '
';
if ($conf->global->MAIN_MODULE_NOTIFICATION)
{
- $langs->load("mails");
- print_titre($langs->trans("Notifications"));
-
- $sql = "SELECT rowid, name, firstname, fk_societe, email";
- $sql.= " FROM ".MAIN_DB_PREFIX."user";
- $sql.= " WHERE entity IN (0,".$conf->entity.")";
-
- $resql=$db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- $var = true;
- $i = 0;
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
- $var=!$var;
- if (!$obj->fk_societe)
- {
- $username= $obj->firstname.' '.$obj->name;
- $internalusers[$obj->rowid] = $username;
- }
-
- $i++;
- }
- $db->free($resql);
- }
-
- $sql = "SELECT rowid, code, label";
+ $langs->load("mails");
+ print_titre($langs->trans("Notifications"));
+
+ $sql = "SELECT rowid, name, firstname, fk_societe, email";
+ $sql.= " FROM ".MAIN_DB_PREFIX."user";
+ $sql.= " WHERE entity IN (0,".$conf->entity.")";
+
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $var = true;
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+ $var=!$var;
+ if (!$obj->fk_societe)
+ {
+ $username= $obj->firstname.' '.$obj->name;
+ $internalusers[$obj->rowid] = $username;
+ }
+
+ $i++;
+ }
+ $db->free($resql);
+ }
+
+ $sql = "SELECT rowid, code, label";
$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
$sql.= " WHERE elementtype = 'withdraw'";
$sql.= " ORDER BY rang ASC";
-
+
$resql = $db->query($sql);
if ($resql)
{
@@ -205,26 +210,26 @@ if ($conf->global->MAIN_MODULE_NOTIFICATION)
}
$db->free($resql);
}
-
- print '