mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-09 19:18:22 +01:00
Works on product canvas and templates
!! WARNING : not stable !! Fix: bad translation
This commit is contained in:
@@ -73,7 +73,7 @@ class modProduct extends DolibarrModules
|
|||||||
|
|
||||||
// Config pages
|
// Config pages
|
||||||
$this->config_page_url = array("produit.php@product");
|
$this->config_page_url = array("produit.php@product");
|
||||||
$this->langfiles = array("product@products","companies","stocks","bills");
|
$this->langfiles = array("products@product","companies","stocks","bills");
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
$this->const = array();
|
$this->const = array();
|
||||||
|
|||||||
@@ -2028,6 +2028,38 @@ function print_titre($titre)
|
|||||||
print '<div class="titre">'.$titre.'</div>';
|
print '<div class="titre">'.$titre.'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Load a title with picto
|
||||||
|
* \param titre Title to show
|
||||||
|
* \param mesg Added message to show on right
|
||||||
|
* \param picto Icon to use before title (should be a 32x32 transparent png file)
|
||||||
|
* \param pictoisfullpath 1=Icon name is a full absolute url of image
|
||||||
|
* \param id To force an id on html objects
|
||||||
|
*/
|
||||||
|
function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='')
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$return='';
|
||||||
|
|
||||||
|
if ($picto == 'setup') $picto='title.png';
|
||||||
|
if (empty($conf->browser->firefox) && $picto=='title.png') $picto='title.gif';
|
||||||
|
|
||||||
|
$return.= "\n";
|
||||||
|
$return.= '<table '.($id?'id="'.$id.'" ':'').'summary="" width="100%" border="0" class="notopnoleftnoright" style="margin-bottom: 2px;"><tr>';
|
||||||
|
if (empty($conf->browser->phone) && $picto && $titre) $return.= '<td class="nobordernopadding" width="40" align="left" valign="middle">'.img_picto('',$picto, 'id="pictotitle"', $pictoisfullpath).'</td>';
|
||||||
|
$return.= '<td class="nobordernopadding" valign="middle">';
|
||||||
|
$return.= '<div class="titre">'.$titre.'</div>';
|
||||||
|
$return.= '</td>';
|
||||||
|
if (strlen($mesg))
|
||||||
|
{
|
||||||
|
$return.= '<td class="nobordernopadding" align="right" valign="middle"><b>'.$mesg.'</b></td>';
|
||||||
|
}
|
||||||
|
$return.= '</tr></table>'."\n";
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Show a title with picto
|
* \brief Show a title with picto
|
||||||
* \param titre Title to show
|
* \param titre Title to show
|
||||||
@@ -2038,22 +2070,7 @@ function print_titre($titre)
|
|||||||
*/
|
*/
|
||||||
function print_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='')
|
function print_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='')
|
||||||
{
|
{
|
||||||
global $conf;
|
print load_fiche_titre($titre, $mesg, $picto, $pictoisfullpath, $id);
|
||||||
|
|
||||||
if ($picto == 'setup') $picto='title.png';
|
|
||||||
if (empty($conf->browser->firefox) && $picto=='title.png') $picto='title.gif';
|
|
||||||
|
|
||||||
print "\n";
|
|
||||||
print '<table '.($id?'id="'.$id.'" ':'').'summary="" width="100%" border="0" class="notopnoleftnoright" style="margin-bottom: 2px;"><tr>';
|
|
||||||
if (empty($conf->browser->phone) && $picto && $titre) print '<td class="nobordernopadding" width="40" align="left" valign="middle">'.img_picto('',$picto, 'id="pictotitle"', $pictoisfullpath).'</td>';
|
|
||||||
print '<td class="nobordernopadding" valign="middle">';
|
|
||||||
print '<div class="titre">'.$titre.'</div>';
|
|
||||||
print '</td>';
|
|
||||||
if (strlen($mesg))
|
|
||||||
{
|
|
||||||
print '<td class="nobordernopadding" align="right" valign="middle"><b>'.$mesg.'</b></td>';
|
|
||||||
}
|
|
||||||
print '</tr></table>'."\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ require_once(DOL_DOCUMENT_ROOT."/includes/barcode/html.formbarcode.class.php");
|
|||||||
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
$langs->load("propal");
|
$langs->load("propal");
|
||||||
$langs->load("product@products");
|
$langs->load("products@product");
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (!$user->admin)
|
if (!$user->admin)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/includes/barcode/html.formbarcode.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/includes/barcode/html.formbarcode.class.php");
|
||||||
|
|
||||||
$langs->load("product@products");
|
$langs->load("products@product");
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class ProductDefault extends Product
|
|||||||
*/
|
*/
|
||||||
function assign_values($action='')
|
function assign_values($action='')
|
||||||
{
|
{
|
||||||
global $conf,$html;
|
global $conf,$langs,$html;
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
$this->tpl['showrefnav'] = $html->showrefnav($this,'ref','',1,'ref');
|
$this->tpl['showrefnav'] = $html->showrefnav($this,'ref','',1,'ref');
|
||||||
@@ -86,6 +86,11 @@ class ProductDefault extends Product
|
|||||||
// Statut
|
// Statut
|
||||||
$this->tpl['status'] = $this->getLibStatut(2);
|
$this->tpl['status'] = $this->getLibStatut(2);
|
||||||
|
|
||||||
|
if ($action == 'create')
|
||||||
|
{
|
||||||
|
$this->tpl['cardTitle'] = load_fiche_titre($langs->trans("NewProduct"));
|
||||||
|
}
|
||||||
|
|
||||||
if ($action == 'view')
|
if ($action == 'view')
|
||||||
{
|
{
|
||||||
$this->tpl['nblignes'] = 4;
|
$this->tpl['nblignes'] = 4;
|
||||||
|
|||||||
@@ -26,9 +26,7 @@
|
|||||||
<input type="hidden" name="action" value="add">
|
<input type="hidden" name="action" value="add">
|
||||||
<input type="hidden" name="canvas" value="<?php echo $_GET['canvas']; ?>">
|
<input type="hidden" name="canvas" value="<?php echo $_GET['canvas']; ?>">
|
||||||
|
|
||||||
|
<?php echo $product->tpl['cardTitle']; ?>
|
||||||
else $title=$langs->trans("NewProduct");
|
|
||||||
print_fiche_titre($title);
|
|
||||||
|
|
||||||
<table class="border" width="100%">
|
<table class="border" width="100%">
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
|
||||||
|
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
$langs->load("product@products");
|
$langs->load("products@product");
|
||||||
|
|
||||||
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
|
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
|
|||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
$langs->load("stocks");
|
$langs->load("stocks");
|
||||||
$langs->load("product@products");
|
$langs->load("products@product");
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (isset($_GET["id"]) || isset($_GET["ref"]))
|
if (isset($_GET["id"]) || isset($_GET["ref"]))
|
||||||
@@ -120,9 +120,7 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (!empty($_POST["canvas"]) && file_exists('canvas/'.$_POST["canvas"].'/product.'.$_POST["canvas"].'.class.php') )
|
||||||
{
|
|
||||||
if ($_POST["canvas"] <> '' && file_exists('canvas/'.$_POST["canvas"].'/product.'.$_POST["canvas"].'.class.php') )
|
|
||||||
{
|
{
|
||||||
$classname = 'Product'.ucfirst($_POST["canvas"]);
|
$classname = 'Product'.ucfirst($_POST["canvas"]);
|
||||||
include_once('canvas/'.$_POST["canvas"].'/product.'.$_POST["canvas"].'.class.php');
|
include_once('canvas/'.$_POST["canvas"].'/product.'.$_POST["canvas"].'.class.php');
|
||||||
@@ -130,9 +128,15 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')).'</div>';
|
||||||
|
$_GET["action"] = "create";
|
||||||
|
$_GET["canvas"] = $product->canvas;
|
||||||
|
$_GET["type"] = $_POST["type"];
|
||||||
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
$product->ref = $_POST["ref"];
|
$product->ref = $_POST["ref"];
|
||||||
$product->libelle = $_POST["libelle"];
|
$product->libelle = $_POST["libelle"];
|
||||||
$product->price_base_type = $_POST["price_base_type"];
|
$product->price_base_type = $_POST["price_base_type"];
|
||||||
@@ -620,7 +624,7 @@ $formproduct = new FormProduct($db);
|
|||||||
*/
|
*/
|
||||||
if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->rights->service->creer))
|
if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->rights->service->creer))
|
||||||
{
|
{
|
||||||
if ($_GET["canvas"] <> '' && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php'))
|
if (!empty($_GET["canvas"]) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php'))
|
||||||
{
|
{
|
||||||
if (! isset($product))
|
if (! isset($product))
|
||||||
{
|
{
|
||||||
@@ -632,8 +636,6 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
|
|||||||
$product = new $classname($db,0,$user);
|
$product = new $classname($db,0,$user);
|
||||||
}
|
}
|
||||||
|
|
||||||
$product->assign_smarty_values($smarty, 'create');
|
|
||||||
|
|
||||||
if ($_error == 1)
|
if ($_error == 1)
|
||||||
{
|
{
|
||||||
$product = $e_product;
|
$product = $e_product;
|
||||||
@@ -654,15 +656,18 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
|
|||||||
|
|
||||||
if ($mesg) print $mesg."\n";
|
if ($mesg) print $mesg."\n";
|
||||||
|
|
||||||
if ($_GET["canvas"] <> '' && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php'))
|
if (!empty($_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 assigne les valeurs meme en creation car elles sont definies si
|
||||||
// on revient en erreur
|
// on revient en erreur
|
||||||
$smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/tpl/';
|
$template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/tpl/';
|
||||||
$tvaarray = load_tva($db,"tva_tx",$conf->defaulttx,$mysoc,'');
|
$tvaarray = load_tva($db,"tva_tx",$conf->defaulttx,$mysoc,'');
|
||||||
$smarty->assign('tva_taux_value', $tvaarray['value']);
|
//$smarty->assign('tva_taux_value', $tvaarray['value']);
|
||||||
$smarty->assign('tva_taux_libelle', $tvaarray['label']);
|
//$smarty->assign('tva_taux_libelle', $tvaarray['label']);
|
||||||
$smarty->display($_GET["canvas"].'-create.tpl');
|
|
||||||
|
$product->assign_values('create');
|
||||||
|
|
||||||
|
include($template_dir.'create.tpl.php');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
|
||||||
require_once DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.product.class.php";
|
require_once DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.product.class.php";
|
||||||
|
|
||||||
$langs->load("product@products");
|
$langs->load("products@product");
|
||||||
$langs->load("suppliers");
|
$langs->load("suppliers");
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ else $result=restrictedArea($user,'produit|service',$id,'service','','',$fieldid
|
|||||||
|
|
||||||
$product_static = new Product($db);
|
$product_static = new Product($db);
|
||||||
|
|
||||||
$langs->load("product@products");
|
$langs->load("products@product");
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ require_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php');
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/html.formother.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/html.formother.class.php");
|
||||||
if ($conf->categorie->enabled) require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
|
if ($conf->categorie->enabled) require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
|
||||||
|
|
||||||
$langs->load("product@products");
|
$langs->load("products@product");
|
||||||
|
|
||||||
$type=trim(isset($_GET["type"])?$_GET["type"]:$_POST["type"]);
|
$type=trim(isset($_GET["type"])?$_GET["type"]:$_POST["type"]);
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
|
||||||
|
|
||||||
$langs->load("product@products");
|
$langs->load("products@product");
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ require("../main.inc.php");
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
||||||
|
|
||||||
$langs->load("product@products");
|
$langs->load("products@product");
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ require("../main.inc.php");
|
|||||||
require_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php');
|
require_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php');
|
||||||
require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
|
||||||
|
|
||||||
$langs->load("product@products");
|
$langs->load("products@product");
|
||||||
$langs->load("stocks");
|
$langs->load("stocks");
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/html.formadmin.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/html.formadmin.class.php");
|
||||||
|
|
||||||
$langs->load("product@products");
|
$langs->load("products@product");
|
||||||
$langs->load("languages");
|
$langs->load("languages");
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
|
|||||||
Reference in New Issue
Block a user