Skip to content
Snippets Groups Projects
Commit da5f951f authored by Regis Houssin's avatar Regis Houssin
Browse files

Works on canvas capability

Works on custom list
parent fa1e2ffe
No related branches found
No related tags found
No related merge requests found
-- ========================================================================
-- 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;
......@@ -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;
$this->list_title = array();
$titlelist["name"] = 'ref';
$titlelist["title"] = $langs->trans("Ref");
$titlelist["sortfield"] = 'p.ref';
$titlelist["align"] = 'left';
array_push($this->list_title,$titlelist);
$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);
global $conf, $langs;
$titlelist["name"] = 'sellingprice';
$titlelist["title"] = $langs->trans("SellingPrice");
$titlelist["sortfield"] = 'p.price';
$titlelist["align"] = 'right';
array_push($this->list_title,$titlelist);
$this->field_list = array();
$titlelist["name"] = 'stock';
$titlelist["title"] = $langs->trans("Stock");
$titlelist["sortfield"] = '';
$titlelist["align"] = 'right';
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"] = '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);
......
......@@ -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}
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment