Add llx_entity for better management entities
This commit is contained in:
parent
bee0889939
commit
f3d22ae958
@ -39,9 +39,9 @@ $mc = new Multicompany($db);
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($_GET["action"] == 'enable' || $_GET["action"] == 'disable')
|
if ($_GET["action"] == 'set')
|
||||||
{
|
{
|
||||||
$mc->setEntity($_GET['id'],$_GET["action"]);
|
$mc->setEntity($_GET['id'],$_GET["active"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
|
/* Copyright (C) 2009-2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -49,28 +49,6 @@ class Multicompany
|
|||||||
$this->canvas = "default";
|
$this->canvas = "default";
|
||||||
$this->name = "admin";
|
$this->name = "admin";
|
||||||
$this->description = "";
|
$this->description = "";
|
||||||
|
|
||||||
/*
|
|
||||||
$this->active = MAIN_MULTICOMPANY;
|
|
||||||
|
|
||||||
$this->menu_new = 'Admin';
|
|
||||||
$this->menu_add = 1;
|
|
||||||
$this->menu_clear = 1;
|
|
||||||
|
|
||||||
$this->no_button_copy = 1;
|
|
||||||
|
|
||||||
$this->menus[0][0] = '';
|
|
||||||
$this->menus[0][1] = '';
|
|
||||||
$this->menus[1][0] = '';
|
|
||||||
$this->menus[1][1] = '';
|
|
||||||
|
|
||||||
$this->next_prev_filter = "canvas='default'";
|
|
||||||
|
|
||||||
$this->onglets[0][0] = 'URL';
|
|
||||||
$this->onglets[0][1] = 'name1';
|
|
||||||
$this->onglets[1][0] = 'URL';
|
|
||||||
$this->onglets[1][1] = 'name2';
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,23 +115,13 @@ class Multicompany
|
|||||||
/**
|
/**
|
||||||
* \brief Enable/disable entity
|
* \brief Enable/disable entity
|
||||||
*/
|
*/
|
||||||
function setEntity($id,$action)
|
function setEntity($id,$active)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
if ($action == 'enable')
|
$sql = "UPDATE ".MAIN_DB_PREFIX."entity";
|
||||||
{
|
$sql.= " SET active = ".$active;
|
||||||
$newid = str_replace('-','',$id);
|
$sql.= " WHERE rowid = ".$id;
|
||||||
}
|
|
||||||
else if ($action == 'disable')
|
|
||||||
{
|
|
||||||
$newid = '-'.$id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."const";
|
|
||||||
$sql.= " SET entity = ".$newid;
|
|
||||||
$sql.= " WHERE ".$this->db->decrypt('name')." = 'MAIN_INFO_SOCIETE_NOM'";
|
|
||||||
$sql.= " AND entity = ".$id;
|
|
||||||
|
|
||||||
dol_syslog("Multicompany::setEntity sql=".$sql, LOG_DEBUG);
|
dol_syslog("Multicompany::setEntity sql=".$sql, LOG_DEBUG);
|
||||||
|
|
||||||
@ -167,12 +135,8 @@ class Multicompany
|
|||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$sql = "SELECT ";
|
$sql = "SELECT rowid, label, description, visible, active";
|
||||||
$sql.= $this->db->decrypt('value')." as value";
|
$sql.= " FROM ".MAIN_DB_PREFIX."entity";
|
||||||
$sql.= ", entity";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."const";
|
|
||||||
$sql.= " WHERE ".$this->db->decrypt('name')." = 'MAIN_INFO_SOCIETE_NOM'";
|
|
||||||
$sql.= " ORDER BY value ASC";
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
@ -184,19 +148,12 @@ class Multicompany
|
|||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
|
|
||||||
$active = 1;
|
$this->entities[$i]['id'] = $obj->rowid;
|
||||||
$entity = $obj->entity;
|
$this->entities[$i]['label'] = $obj->label;
|
||||||
|
$this->entities[$i]['description'] = $obj->description;
|
||||||
if ($obj->entity < 0)
|
$this->entities[$i]['visible'] = $obj->visible;
|
||||||
{
|
$this->entities[$i]['active'] = $obj->active;
|
||||||
$entity = str_replace('-','',$obj->entity);
|
if ($details) $this->entities[$i]['details'] = $this->fetch($obj->rowid);
|
||||||
$active = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->entities[$i]['label'] = $obj->value;
|
|
||||||
$this->entities[$i]['id'] = $obj->entity;
|
|
||||||
if ($details) $this->entities[$i]['details'] = $this->fetch($entity);
|
|
||||||
$this->entities[$i]['active'] = $active;
|
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,9 +38,9 @@
|
|||||||
<td align="center">
|
<td align="center">
|
||||||
|
|
||||||
{if $entities[mc].active}
|
{if $entities[mc].active}
|
||||||
<a href="{$smarty.server.SCRIPT_NAME}?action=disable&id={$entities[mc].id}">{$img_on}</a>
|
<a href="{$smarty.server.SCRIPT_NAME}?action=set&active=0&id={$entities[mc].id}">{$img_on}</a>
|
||||||
{else}
|
{else}
|
||||||
<a href="{$smarty.server.SCRIPT_NAME}?action=enable&id={$entities[mc].id}">{$img_off}</a>
|
<a href="{$smarty.server.SCRIPT_NAME}?action=set&active=1&id={$entities[mc].id}">{$img_off}</a>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user