mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 09:38:23 +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
|
||||
$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
|
||||
$this->const = array();
|
||||
|
||||
@@ -2028,6 +2028,38 @@ function print_titre($titre)
|
||||
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
|
||||
* \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='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
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";
|
||||
print load_fiche_titre($titre, $mesg, $picto, $pictoisfullpath, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ require_once(DOL_DOCUMENT_ROOT."/includes/barcode/html.formbarcode.class.php");
|
||||
|
||||
$langs->load("admin");
|
||||
$langs->load("propal");
|
||||
$langs->load("product@products");
|
||||
$langs->load("products@product");
|
||||
|
||||
// Security check
|
||||
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."/includes/barcode/html.formbarcode.class.php");
|
||||
|
||||
$langs->load("product@products");
|
||||
$langs->load("products@product");
|
||||
$langs->load("bills");
|
||||
|
||||
// Security check
|
||||
|
||||
@@ -77,7 +77,7 @@ class ProductDefault extends Product
|
||||
*/
|
||||
function assign_values($action='')
|
||||
{
|
||||
global $conf,$html;
|
||||
global $conf,$langs,$html;
|
||||
|
||||
// Ref
|
||||
$this->tpl['showrefnav'] = $html->showrefnav($this,'ref','',1,'ref');
|
||||
@@ -86,6 +86,11 @@ class ProductDefault extends Product
|
||||
// Statut
|
||||
$this->tpl['status'] = $this->getLibStatut(2);
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
$this->tpl['cardTitle'] = load_fiche_titre($langs->trans("NewProduct"));
|
||||
}
|
||||
|
||||
if ($action == 'view')
|
||||
{
|
||||
$this->tpl['nblignes'] = 4;
|
||||
|
||||
@@ -26,9 +26,7 @@
|
||||
<input type="hidden" name="action" value="add">
|
||||
<input type="hidden" name="canvas" value="<?php echo $_GET['canvas']; ?>">
|
||||
|
||||
|
||||
else $title=$langs->trans("NewProduct");
|
||||
print_fiche_titre($title);
|
||||
<?php echo $product->tpl['cardTitle']; ?>
|
||||
|
||||
<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");
|
||||
|
||||
$langs->load("other");
|
||||
$langs->load("product@products");
|
||||
$langs->load("products@product");
|
||||
|
||||
$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("other");
|
||||
$langs->load("stocks");
|
||||
$langs->load("product@products");
|
||||
$langs->load("products@product");
|
||||
|
||||
// Security check
|
||||
if (isset($_GET["id"]) || isset($_GET["ref"]))
|
||||
@@ -120,9 +120,7 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if ($_POST["canvas"] <> '' && file_exists('canvas/'.$_POST["canvas"].'/product.'.$_POST["canvas"].'.class.php') )
|
||||
if (!empty($_POST["canvas"]) && file_exists('canvas/'.$_POST["canvas"].'/product.'.$_POST["canvas"].'.class.php') )
|
||||
{
|
||||
$classname = 'Product'.ucfirst($_POST["canvas"]);
|
||||
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
|
||||
{
|
||||
$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->libelle = $_POST["libelle"];
|
||||
$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["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))
|
||||
{
|
||||
@@ -632,8 +636,6 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
|
||||
$product = new $classname($db,0,$user);
|
||||
}
|
||||
|
||||
$product->assign_smarty_values($smarty, 'create');
|
||||
|
||||
if ($_error == 1)
|
||||
{
|
||||
$product = $e_product;
|
||||
@@ -654,15 +656,18 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
|
||||
|
||||
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 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,'');
|
||||
$smarty->assign('tva_taux_value', $tvaarray['value']);
|
||||
$smarty->assign('tva_taux_libelle', $tvaarray['label']);
|
||||
$smarty->display($_GET["canvas"].'-create.tpl');
|
||||
//$smarty->assign('tva_taux_value', $tvaarray['value']);
|
||||
//$smarty->assign('tva_taux_libelle', $tvaarray['label']);
|
||||
|
||||
$product->assign_values('create');
|
||||
|
||||
include($template_dir.'create.tpl.php');
|
||||
}
|
||||
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."/fourn/class/fournisseur.product.class.php";
|
||||
|
||||
$langs->load("product@products");
|
||||
$langs->load("products@product");
|
||||
$langs->load("suppliers");
|
||||
$langs->load("bills");
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ else $result=restrictedArea($user,'produit|service',$id,'service','','',$fieldid
|
||||
|
||||
$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");
|
||||
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"]);
|
||||
|
||||
|
||||
@@ -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."/html.formfile.class.php");
|
||||
|
||||
$langs->load("product@products");
|
||||
$langs->load("products@product");
|
||||
$langs->load("bills");
|
||||
|
||||
// Security check
|
||||
|
||||
@@ -31,7 +31,7 @@ require("../main.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
||||
|
||||
$langs->load("product@products");
|
||||
$langs->load("products@product");
|
||||
$langs->load("bills");
|
||||
|
||||
// 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."/categories/class/categorie.class.php");
|
||||
|
||||
$langs->load("product@products");
|
||||
$langs->load("products@product");
|
||||
$langs->load("stocks");
|
||||
|
||||
// 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."/html.formadmin.class.php");
|
||||
|
||||
$langs->load("product@products");
|
||||
$langs->load("products@product");
|
||||
$langs->load("languages");
|
||||
|
||||
// Security check
|
||||
|
||||
Reference in New Issue
Block a user