Works on product canvas and templates
!! WARNING : not stable !!
This commit is contained in:
parent
ba0fa4b60b
commit
2f924a3f7a
@ -63,11 +63,10 @@ class ProductDefault extends Product
|
||||
/**
|
||||
* \brief Lecture des donnees dans la base
|
||||
* \param id Product id
|
||||
* \param ref Product ref
|
||||
*/
|
||||
function fetchCanvas($id='', $ref='', $action='')
|
||||
function fetchCanvas($id='', $action='')
|
||||
{
|
||||
$result = $this->fetch($id,$ref);
|
||||
$result = $this->fetch($id);
|
||||
|
||||
return $result;
|
||||
}
|
||||
@ -80,8 +79,12 @@ class ProductDefault extends Product
|
||||
{
|
||||
global $conf,$html;
|
||||
|
||||
// Ref
|
||||
$this->tpl['showrefnav'] = $html->showrefnav($this,'ref','',1,'ref');
|
||||
// Label
|
||||
$this->tpl['label'] = $this->libelle;
|
||||
// Statut
|
||||
$this->tpl['status'] = $this->getLibStatut(2);
|
||||
|
||||
if ($action == 'view')
|
||||
{
|
||||
@ -99,9 +102,6 @@ class ProductDefault extends Product
|
||||
$this->tpl['accountancySellCodeKey'] = $html->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer);
|
||||
$this->tpl['accountancySellCodeVal'] = $html->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer);
|
||||
|
||||
// Statut
|
||||
$this->tpl['status'] = $this->getLibStatut(2);
|
||||
|
||||
// Description
|
||||
$this->tpl['description'] = nl2br($this->description);
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2007 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
||||
@ -2795,6 +2795,39 @@ class Product extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Load type of canvas
|
||||
* \param id product id
|
||||
* \param ref product ref
|
||||
*/
|
||||
function getCanvas($id, $ref)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT rowid, ref, canvas";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||
$sql.= " WHERE entity = ".$conf->entity;
|
||||
if (!empty($id)) $sql.= " AND rowid = ".$id;
|
||||
if (!empty($ref)) $sql.= " AND ref = '".$ref."'";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->ref;
|
||||
$this->canvas = $obj->canvas;
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Affecte les valeurs smarty
|
||||
|
||||
@ -653,7 +653,7 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
|
||||
|
||||
if ($mesg) print $mesg."\n";
|
||||
|
||||
if ($_GET["canvas"] <> '' && file_exists('canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php'))
|
||||
if ($_GET["canvas"] <> '' && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php'))
|
||||
{
|
||||
// On assigne les valeurs meme en creation car elles sont definies si
|
||||
// on revient en erreur
|
||||
@ -844,26 +844,17 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
|
||||
*/
|
||||
if ($_GET["id"] || $_GET["ref"])
|
||||
{
|
||||
$product = new Product($db);
|
||||
|
||||
if ($_GET["ref"])
|
||||
{
|
||||
$result = $product->fetch('',$_GET["ref"]);
|
||||
$_GET["id"] = $product->id;
|
||||
}
|
||||
elseif ($_GET["id"])
|
||||
{
|
||||
$result = $product->fetch($_GET["id"]);
|
||||
}
|
||||
$productstatic = new Product($db);
|
||||
$result = $productstatic->getCanvas($_GET["id"],$_GET["ref"]);
|
||||
|
||||
// Gestion des produits specifiques
|
||||
if (!empty($product->canvas) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php') )
|
||||
if (!empty($productstatic->canvas) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$productstatic->canvas.'/product.'.$productstatic->canvas.'.class.php') )
|
||||
{
|
||||
$classname = 'Product'.ucfirst($product->canvas);
|
||||
include_once(DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php');
|
||||
$classname = 'Product'.ucfirst($productstatic->canvas);
|
||||
include_once(DOL_DOCUMENT_ROOT.'/product/canvas/'.$productstatic->canvas.'/product.'.$productstatic->canvas.'.class.php');
|
||||
$product = new $classname($db);
|
||||
|
||||
$result = $product->fetchCanvas($_GET["id"],'',$_GET["action"]);
|
||||
$result = $product->fetchCanvas($productstatic->id,'',$_GET["action"]);
|
||||
|
||||
$template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/tpl/';
|
||||
}
|
||||
@ -1132,7 +1123,7 @@ print "\n</div><br>\n";
|
||||
* All the "Add to" areas
|
||||
*/
|
||||
|
||||
if ($_GET["id"] && $_GET["action"] == '' && $product->status)
|
||||
if ($product->id && $_GET["action"] == '' && $product->status)
|
||||
{
|
||||
$propal = New Propal($db);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user