Work on multicompany module with smarty integration
This commit is contained in:
parent
5e977feb5e
commit
3f67776869
@ -52,11 +52,12 @@ print_fiche_titre($langs->trans("MultiCompanySetup"),$linkback,'setup');
|
||||
print '<br>';
|
||||
print_titre($langs->trans("MultiCompanyModule"));
|
||||
|
||||
$entity = new Multicompany($db);
|
||||
$mc = new Multicompany($db);
|
||||
$mc->getEntities();
|
||||
|
||||
$smarty->template_dir = DOL_DOCUMENT_ROOT.'/multicompany/templates/';
|
||||
|
||||
$entity->assign_smarty_values($smarty,$_GET["action"]);
|
||||
$mc->assign_smarty_values($smarty,$_GET["action"]);
|
||||
|
||||
$smarty->display('admin-entity.tpl');
|
||||
|
||||
|
||||
@ -1412,7 +1412,7 @@ class Form
|
||||
if ($empty) print '<option value=""> </option>';
|
||||
foreach($this->cache_types_paiements as $id => $arraytypes)
|
||||
{
|
||||
// On passe si on a demand<EFBFBD> de filtrer sur des modes de paiments particuliers
|
||||
// On passe si on a demande de filtrer sur des modes de paiments particuliers
|
||||
if (sizeof($filterarray) && ! in_array($arraytypes['type'],$filterarray)) continue;
|
||||
|
||||
if ($format == 0) print '<option value="'.$id.'"';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005 Marc Barilley / Oc<EFBFBD>bo <marc@ocebo.com>
|
||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -22,7 +22,7 @@
|
||||
/**
|
||||
* \file htdocs/install/check.php
|
||||
* \ingroup install
|
||||
* \brief Test si le fichier conf est modifiable et si il n'existe pas, test la possibilit<EFBFBD> de le cr<EFBFBD>er
|
||||
* \brief Test si le fichier conf est modifiable et si il n'existe pas, test la possibilite de le creer
|
||||
* \version $Id$
|
||||
*/
|
||||
include_once("./inc.php");
|
||||
|
||||
@ -202,16 +202,18 @@ function dol_loginfunction($langs,$conf,$mysoc)
|
||||
// Entity field
|
||||
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY))
|
||||
{
|
||||
$html = new Form($db);
|
||||
|
||||
//TODO: creer class
|
||||
$entity = array('1'=>'company1','2'=>'company2');
|
||||
require_once(DOL_DOCUMENT_ROOT.'/multicompany/multicompany.class.php');
|
||||
|
||||
global $db;
|
||||
|
||||
$mc = new Multicompany($db);
|
||||
$mc->getEntities();
|
||||
|
||||
if (! empty($conf->browser->phone)) print '<tr><td colspan="3"> </td></tr>'; // More space with phones
|
||||
|
||||
print '<tr><td valign="top" nowrap="nowrap"> <b>'.$langs->trans("Entity").'</b> </td>'."\n";
|
||||
print '<td valign="top" nowrap="nowrap">';
|
||||
print $html->selectarray('entity',$entity,$lastentity,0,0,0,1,'tabindex="3"');
|
||||
print $mc->select_entities($mc->entities,$lastentity,'tabindex="3"');
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
|
||||
|
||||
@ -34,6 +34,8 @@ class Multicompany
|
||||
var $error;
|
||||
//! Numero de l'erreur
|
||||
var $errno = 0;
|
||||
|
||||
var $entities = array();
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
@ -78,32 +80,76 @@ class Multicompany
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Supression
|
||||
*/
|
||||
function DeleteCanvas($id)
|
||||
{
|
||||
|
||||
}
|
||||
/**
|
||||
* \brief Lecture des donnees dans la base
|
||||
*/
|
||||
function FetchCanvas($id='', $action='')
|
||||
function Delete($id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief List of entities
|
||||
*/
|
||||
function getEntities()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT ".$this->db->decrypt('value',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey)." as value";
|
||||
$sql.= ", entity";
|
||||
$sql.= ", visible";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."const";
|
||||
$sql.= " WHERE ".$this->db->decrypt('name',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey)." = 'MAIN_INFO_SOCIETE_NOM'";
|
||||
$sql.= " ORDER BY entity ASC";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $this->db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$active = 1;
|
||||
if ($obj->entity < 0) $active = 0;
|
||||
|
||||
$this->entities[$i]['label'] = $obj->value;
|
||||
$this->entities[$i]['id'] = $obj->entity;
|
||||
$this->entities[$i]['active'] = $active;
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Mise a jour des donnees dans la base
|
||||
* \param datas Tableau de donnees
|
||||
* \brief Return combo list of entities.
|
||||
* \param entities Entities array
|
||||
* \param selected Preselected entity
|
||||
*/
|
||||
function UpdateCanvas($datas)
|
||||
function select_entities($entities,$selected='',$option='')
|
||||
{
|
||||
|
||||
print '<select class="flat" name="entity" '.$option.'>';
|
||||
|
||||
if (is_array($entities))
|
||||
{
|
||||
foreach ($entities as $entity)
|
||||
{
|
||||
print '<option value="'.$entity['id'].'" ';
|
||||
if ($selected == $entity['id']) print 'selected="true"';
|
||||
if ($entity['active'] == 0) print 'disabled="disabled"';
|
||||
print '>';
|
||||
print $entity['label'];
|
||||
print '</option>';
|
||||
}
|
||||
}
|
||||
print '</select>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Assigne les valeurs pour les templates Smarty
|
||||
* \param smarty Instance de smarty
|
||||
|
||||
Loading…
Reference in New Issue
Block a user