New: early development of multi-company module
This commit is contained in:
parent
fd7d9b5d5a
commit
0d7195c40f
@ -46,7 +46,7 @@ if ($_POST["action"] == 'update' || $_POST["action"] == 'add')
|
|||||||
|
|
||||||
if ($_GET["action"] == 'delete')
|
if ($_GET["action"] == 'delete')
|
||||||
{
|
{
|
||||||
if (! dolibarr_del_const($db, $_GET["rowid"]));
|
if (! dolibarr_del_const($db, $_GET["rowid"],$_GET["entity"]));
|
||||||
{
|
{
|
||||||
print $db->error();
|
print $db->error();
|
||||||
}
|
}
|
||||||
@ -66,6 +66,7 @@ print '<tr class="liste_titre">';
|
|||||||
print '<td>'.$langs->trans("Name").'</td>';
|
print '<td>'.$langs->trans("Name").'</td>';
|
||||||
print '<td>'.$langs->trans("Value").'</td>';
|
print '<td>'.$langs->trans("Value").'</td>';
|
||||||
print '<td>'.$langs->trans("Note").'</td>';
|
print '<td>'.$langs->trans("Note").'</td>';
|
||||||
|
if ($conf->multicompany->enabled) print '<td>'.$langs->trans("Entity").'</td>';
|
||||||
print '<td align="center">'.$langs->trans("Action").'</td>';
|
print '<td align="center">'.$langs->trans("Action").'</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
@ -83,7 +84,18 @@ print '<td>';
|
|||||||
print '<input type="text" class="flat" size="30" name="constvalue" value="">';
|
print '<input type="text" class="flat" size="30" name="constvalue" value="">';
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
print '<input type="text" class="flat" size="40" name="constnote" value="">';
|
print '<input type="text" class="flat" size="40" name="constnote" value="">';
|
||||||
print '</td><td align="center">';
|
print '</td>';
|
||||||
|
if ($conf->multicompany->enabled)
|
||||||
|
{
|
||||||
|
print '<td>';
|
||||||
|
print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
|
||||||
|
}
|
||||||
|
print '<td align="center">';
|
||||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="Button"><br>';
|
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="Button"><br>';
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
@ -120,7 +132,6 @@ if ($result)
|
|||||||
print '<input type="hidden" name="action" value="update">';
|
print '<input type="hidden" name="action" value="update">';
|
||||||
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
|
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
|
||||||
print '<input type="hidden" name="constname" value="'.$obj->name.'">';
|
print '<input type="hidden" name="constname" value="'.$obj->name.'">';
|
||||||
print '<input type="hidden" name="entity" value="'.$obj->entity.'">';
|
|
||||||
|
|
||||||
print "<tr $bc[$var] class=value><td>$obj->name</td>\n";
|
print "<tr $bc[$var] class=value><td>$obj->name</td>\n";
|
||||||
|
|
||||||
@ -131,9 +142,23 @@ if ($result)
|
|||||||
|
|
||||||
// Note
|
// Note
|
||||||
print '<input type="text" class="flat" size="40" name="constnote" value="'.stripslashes(nl2br($obj->note)).'">';
|
print '<input type="text" class="flat" size="40" name="constnote" value="'.stripslashes(nl2br($obj->note)).'">';
|
||||||
print '</td><td align="center">';
|
print '</td>';
|
||||||
|
|
||||||
|
// Entity
|
||||||
|
if ($conf->multicompany->enabled)
|
||||||
|
{
|
||||||
|
print '<td>';
|
||||||
|
print '<input type="text" class="flat" size="1" name="entity" value="'.$obj->entity.'">';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<input type="hidden" name="entity" value="'.$obj->entity.'">';
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<td align="center">';
|
||||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="button"> ';
|
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="button"> ';
|
||||||
print '<a href="const.php?rowid='.$obj->rowid.'&action=delete">'.img_delete().'</a>';
|
print '<a href="const.php?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=delete">'.img_delete().'</a>';
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|||||||
@ -392,6 +392,8 @@ class DolibarrModules
|
|||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$err = 0;
|
$err = 0;
|
||||||
|
|
||||||
|
if ($this->family == "base") $conf->entity = 0; // Common module
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const ";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const ";
|
||||||
$sql.= "WHERE name = '".$this->const_name."' ";
|
$sql.= "WHERE name = '".$this->const_name."' ";
|
||||||
@ -420,6 +422,8 @@ class DolibarrModules
|
|||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$err = 0;
|
$err = 0;
|
||||||
|
|
||||||
|
if ($this->family == "base") $conf->entity = 0; // Common module
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const ";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const ";
|
||||||
$sql.= "WHERE name = '".$this->const_name."'";
|
$sql.= "WHERE name = '".$this->const_name."'";
|
||||||
|
|||||||
@ -83,7 +83,7 @@ class modMultiCompany extends DolibarrModules
|
|||||||
$this->depends = array(); // List of modules id that must be enabled if this module is enabled
|
$this->depends = array(); // List of modules id that must be enabled if this module is enabled
|
||||||
$this->requiredby = array(); // List of modules id to disable if this one is disabled
|
$this->requiredby = array(); // List of modules id to disable if this one is disabled
|
||||||
$this->phpmin = array(4,3); // Minimum version of PHP required by module
|
$this->phpmin = array(4,3); // Minimum version of PHP required by module
|
||||||
$this->need_dolibarr_version = array(2,5); // Minimum version of Dolibarr required by module
|
$this->need_dolibarr_version = array(2,6); // Minimum version of Dolibarr required by module
|
||||||
$this->langfiles = array("multicompany");
|
$this->langfiles = array("multicompany");
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
@ -204,7 +204,7 @@ class modMultiCompany extends DolibarrModules
|
|||||||
{
|
{
|
||||||
$sql = array();
|
$sql = array();
|
||||||
|
|
||||||
$result=$this->load_tables();
|
//$result=$this->load_tables();
|
||||||
|
|
||||||
return $this->_init($sql);
|
return $this->_init($sql);
|
||||||
}
|
}
|
||||||
@ -217,10 +217,12 @@ class modMultiCompany extends DolibarrModules
|
|||||||
*/
|
*/
|
||||||
function remove()
|
function remove()
|
||||||
{
|
{
|
||||||
$sql = array();
|
$sql = array();
|
||||||
|
|
||||||
return $this->_remove($sql);
|
$result = $this->destroy_cookie();
|
||||||
}
|
|
||||||
|
return $this->_remove($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -232,8 +234,18 @@ class modMultiCompany extends DolibarrModules
|
|||||||
*/
|
*/
|
||||||
function load_tables()
|
function load_tables()
|
||||||
{
|
{
|
||||||
return $this->_load_tables('/mymodule/sql/');
|
return $this->_load_tables('/multicompany/sql/');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Destroy a cookie
|
||||||
|
*/
|
||||||
|
function destroy_cookie()
|
||||||
|
{
|
||||||
|
// Destroy entity cookie
|
||||||
|
$entityCookieName = "DOLENTITYID_dolibarr";
|
||||||
|
setcookie($entityCookieName, '', 1, "/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -385,8 +385,8 @@ function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $not
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$db->lasterror();
|
$error=$db->lasterror();
|
||||||
dol_syslog("admin.lib::dolibarr_set_const ".$this->error, LOG_ERR);
|
dol_syslog("admin.lib::dolibarr_set_const ".$error, LOG_ERR);
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user