Works on canvas capability

Works on custom list
This commit is contained in:
Regis Houssin 2010-03-24 11:10:24 +00:00
parent fa1e2ffe83
commit da5f951ff5
4 changed files with 82 additions and 52 deletions

View File

@ -0,0 +1,35 @@
-- ========================================================================
-- Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
--
-- 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
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
--
-- $Id$
-- ========================================================================
create table llx_c_field_list
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
element varchar(64) NOT NULL, -- name of element list
entity integer DEFAULT 1 NOT NULL, -- entity id
name varchar(32) NOT NULL, -- name of field (ex: ref)
alias varchar(32) DEFAULT NULL, -- alias of field (ex: prodref)
title varchar(32) NOT NULL, -- title (translation) of field (ex: Ref)
align varchar(6) DEFAULT 'left', -- align (left,center,right)
search tinyint DEFAULT 0 NOT NULL, -- add search field
enabled varchar(255) DEFAULT 1, -- Condition to show or hide
rang integer DEFAULT 0
)type=innodb;

View File

@ -39,13 +39,14 @@ class ProductDefault extends Product
*/
function ProductDefault($DB=0, $id=0, $user=0)
{
$this->db = $DB;
$this->id = $id ;
$this->user = $user;
$this->module = "produit";
$this->canvas = "default";
$this->name = "default";
$this->description = "Canvas par défaut";
$this->db = $DB;
$this->id = $id ;
$this->user = $user;
$this->module = "produit";
$this->canvas = "default";
$this->name = "default";
$this->list = "product_default";
$this->description = "Canvas par défaut";
$this->next_prev_filter = "canvas='default'";
}
@ -60,51 +61,46 @@ class ProductDefault extends Product
*/
function getFieldList()
{
global $langs;
global $conf, $langs;
$this->list_title = array();
$this->field_list = array();
$titlelist["name"] = 'ref';
$titlelist["title"] = $langs->trans("Ref");
$titlelist["sortfield"] = 'p.ref';
$titlelist["align"] = 'left';
array_push($this->list_title,$titlelist);
$sql = "SELECT rowid, name, alias, title, align, search, enabled, rang";
$sql.= " FROM ".MAIN_DB_PREFIX."c_field_list";
$sql.= " WHERE element = '".$this->list."'";
$sql.= " AND entity = ".$conf->entity;
$titlelist["name"] = 'label';
$titlelist["title"] = $langs->trans("Label");
$titlelist["sortfield"] = 'p.label';
$titlelist["align"] = 'left';
array_push($this->list_title,$titlelist);
$titlelist["name"] = 'barcode';
$titlelist["title"] = $langs->trans("BarCode");
$titlelist["sortfield"] = 'p.barcode';
$titlelist["align"] = 'center';
array_push($this->list_title,$titlelist);
$titlelist["name"] = 'datem';
$titlelist["title"] = $langs->trans("DateModification");
$titlelist["sortfield"] = 'p.tms';
$titlelist["align"] = 'center';
array_push($this->list_title,$titlelist);
$titlelist["name"] = 'sellingprice';
$titlelist["title"] = $langs->trans("SellingPrice");
$titlelist["sortfield"] = 'p.price';
$titlelist["align"] = 'right';
array_push($this->list_title,$titlelist);
$titlelist["name"] = 'stock';
$titlelist["title"] = $langs->trans("Stock");
$titlelist["sortfield"] = '';
$titlelist["align"] = 'right';
array_push($this->list_title,$titlelist);
$titlelist["name"] = 'status';
$titlelist["title"] = $langs->trans("Status");
$titlelist["sortfield"] = 'p.envente';
$titlelist["align"] = 'right';
array_push($this->list_title,$titlelist);
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$fieldlist = array();
$obj = $this->db->fetch_object($resql);
$fieldlist["id"] = $obj->rowid;
$fieldlist["name"] = $obj->name;
$fieldlist["alias"] = $obj->alias;
$fieldlist["title"] = $obj->title;
$fieldlist["align"] = $obj->align;
$fieldlist["search"] = $obj->search;
$fieldlist["enabled"] = $obj->enabled;
$fieldlist["order"] = $obj->rang;
array_push($this->field_list,$fieldlist);
$i++;
}
$this->db->free($resql);
}
else
{
print $sql;
}
}
/**
@ -169,7 +165,6 @@ class ProductDefault extends Product
$i = 0;
while ($i < min($num,$limit))
{
$titlelist = array();
$datas = array();
$obj = $this->db->fetch_object($resql);

View File

@ -73,7 +73,7 @@
{strip}
<tr class="{cycle values="pair,impair"}">
{foreach name=valueline key=key item=value from=$line}
{foreach name=fieldline item=field from=$titlelist}
{foreach name=fieldline item=field from=$fieldlist}
{if $field.name == $key}
<td align="{$field.align}">{$value}</td>
{/if}

View File

@ -225,7 +225,7 @@ if ($resql)
if ($_GET["canvas"] <> '' && file_exists('canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php'))
{
$smarty->assign('titlelist', $object->list_title);
$smarty->assign('fieldlist', $object->field_list);
$smarty->assign('datas', $object->list_datas);
$smarty->assign('url_root', $dolibarr_main_url_root);
$smarty->assign('theme', $conf->theme);