mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-11 03:51:25 +01:00
Fix a lot of bugs after changes for canvas (photo hidden, edit field for accountancy disappeared, etc...). Too complicated to fix with canvas so I restore the "simple" code. Canvas feature should still works but with some bugs.
This commit is contained in:
@@ -35,7 +35,7 @@ class Canvas
|
|||||||
var $template_dir; // Directory with all core and external templates files
|
var $template_dir; // Directory with all core and external templates files
|
||||||
var $action;
|
var $action;
|
||||||
var $smarty;
|
var $smarty;
|
||||||
|
|
||||||
var $error;
|
var $error;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,42 +47,44 @@ class Canvas
|
|||||||
$this->db = $DB ;
|
$this->db = $DB ;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Load canvas
|
* \brief Load canvas
|
||||||
|
* \param Name of first part of canvas
|
||||||
|
* \canvas Name of second part of canvas
|
||||||
*/
|
*/
|
||||||
function load_canvas($object,$canvas)
|
function load_canvas($object,$canvas)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
|
$part1=$object;
|
||||||
|
$part2=$canvas;
|
||||||
|
|
||||||
if (preg_match('/^([^@]+)@([^@]+)$/i',$canvas,$regs))
|
if (preg_match('/^([^@]+)@([^@]+)$/i',$canvas,$regs))
|
||||||
{
|
{
|
||||||
if (file_exists(DOL_DOCUMENT_ROOT.'/'.$regs[2].'/canvas/'.$regs[1].'/'.$object.'.'.$regs[1].'.class.php'))
|
$part1=$regs[2];
|
||||||
{
|
$part2=$regs[1];
|
||||||
$filecanvas = DOL_DOCUMENT_ROOT.'/'.$regs[2].'/canvas/'.$regs[1].'/'.$object.'.'.$regs[1].'.class.php';
|
}
|
||||||
$classname = ucfirst($object).ucfirst($regs[1]);
|
|
||||||
$this->template_dir = DOL_DOCUMENT_ROOT.'/'.$regs[2].'/canvas/'.$regs[1].'/tpl/';
|
if (file_exists(DOL_DOCUMENT_ROOT.'/'.$part1.'/canvas/'.$part2.'/'.$part1.'.'.$part2.'.class.php'))
|
||||||
|
{
|
||||||
include_once($filecanvas);
|
$filecanvas = DOL_DOCUMENT_ROOT.'/'.$part1.'/canvas/'.$part2.'/'.$part1.'.'.$part2.'.class.php';
|
||||||
$this->object = new $classname($this->db,0,$this->user);
|
$classname = ucfirst($part1).ucfirst($part2);
|
||||||
$this->smarty = $this->object->smarty;
|
$this->template_dir = DOL_DOCUMENT_ROOT.'/'.$part1.'/canvas/'.$part2.'/tpl/';
|
||||||
|
|
||||||
return $this->object;
|
include_once($filecanvas);
|
||||||
}
|
$this->object = new $classname($this->db,0,$this->user);
|
||||||
else
|
$this->smarty = $this->object->smarty;
|
||||||
{
|
|
||||||
$this->error = $langs->trans('CanvasIsInvalid');
|
return $this->object;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error = $langs->trans('BadCanvasName');
|
$this->error = $langs->trans('CanvasIsInvalid');
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Fetch object values
|
* \brief Fetch object values
|
||||||
*/
|
*/
|
||||||
@@ -102,7 +104,7 @@ class Canvas
|
|||||||
if (!empty($this->smarty))
|
if (!empty($this->smarty))
|
||||||
{
|
{
|
||||||
global $smarty;
|
global $smarty;
|
||||||
|
|
||||||
$this->object->assign_smarty_values($smarty, $this->action);
|
$this->object->assign_smarty_values($smarty, $this->action);
|
||||||
$smarty->template_dir = $this->template_dir;
|
$smarty->template_dir = $this->template_dir;
|
||||||
}
|
}
|
||||||
@@ -110,20 +112,20 @@ class Canvas
|
|||||||
{
|
{
|
||||||
$this->object->assign_values($this->action);
|
$this->object->assign_values($this->action);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Display canvas
|
* \brief Display canvas
|
||||||
*/
|
*/
|
||||||
function display_canvas()
|
function display_canvas()
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
if (!empty($this->smarty))
|
if (!empty($this->smarty))
|
||||||
{
|
{
|
||||||
global $smarty;
|
global $smarty;
|
||||||
|
|
||||||
$smarty->display($this->action.'.tpl');
|
$smarty->display($this->action.'.tpl');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class Translate {
|
|||||||
* \brief Load translation key-value for a particular file, into a memory array.
|
* \brief Load translation key-value for a particular file, into a memory array.
|
||||||
* If data for file already loaded, do nothing.
|
* If data for file already loaded, do nothing.
|
||||||
* All data in translation array are stored in UTF-8 format.
|
* All data in translation array are stored in UTF-8 format.
|
||||||
* \param domain File name to load (.lang file). Use @ before value if domain is in a module directory.
|
* \param domain File name to load (.lang file). Use file@module if file is in a module directory.
|
||||||
* \param alt 0,1,2
|
* \param alt 0,1,2
|
||||||
* \param soptafterdirection Stop when the DIRECTION tag is found (optimize)
|
* \param soptafterdirection Stop when the DIRECTION tag is found (optimize)
|
||||||
* \param forcelangdir To force a lang directory
|
* \param forcelangdir To force a lang directory
|
||||||
|
|||||||
@@ -382,6 +382,15 @@ function dol_fiche_head($links, $active='0', $title='', $notab=0, $picto='')
|
|||||||
if (! $notab) print "\n".'<div class="tabBar">'."\n";
|
if (! $notab) print "\n".'<div class="tabBar">'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Show tab footer of a card
|
||||||
|
* \param notab 0=Add tab footer, 1=no tab footer
|
||||||
|
*/
|
||||||
|
function dol_fiche_end($notab=0)
|
||||||
|
{
|
||||||
|
if (! $notab) print "\n</div>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Add a delay to a date
|
* \brief Add a delay to a date
|
||||||
@@ -2052,7 +2061,7 @@ function print_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpat
|
|||||||
function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='')
|
function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$return='';
|
$return='';
|
||||||
|
|
||||||
if ($picto == 'setup') $picto='title.png';
|
if ($picto == 'setup') $picto='title.png';
|
||||||
@@ -2069,7 +2078,7 @@ function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath
|
|||||||
$return.= '<td class="nobordernopadding" align="right" valign="middle"><b>'.$mesg.'</b></td>';
|
$return.= '<td class="nobordernopadding" align="right" valign="middle"><b>'.$mesg.'</b></td>';
|
||||||
}
|
}
|
||||||
$return.= '</tr></table>'."\n";
|
$return.= '</tr></table>'."\n";
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3348,7 +3357,7 @@ if (! function_exists('glob'))
|
|||||||
if(PHP_OS=='WIN32') $slash='\\';
|
if(PHP_OS=='WIN32') $slash='\\';
|
||||||
else $slash='/';
|
else $slash='/';
|
||||||
$lastpos=strrpos($pattern,$slash);
|
$lastpos=strrpos($pattern,$slash);
|
||||||
|
|
||||||
if(!($lastpos===false))
|
if(!($lastpos===false))
|
||||||
{
|
{
|
||||||
$path=substr($pattern,0,-$lastpos-1);
|
$path=substr($pattern,0,-$lastpos-1);
|
||||||
@@ -3362,14 +3371,14 @@ if (! function_exists('glob'))
|
|||||||
|
|
||||||
$handle=@opendir($path);
|
$handle=@opendir($path);
|
||||||
if($handle===false) return false;
|
if($handle===false) return false;
|
||||||
|
|
||||||
while($dir=readdir($handle))
|
while($dir=readdir($handle))
|
||||||
{
|
{
|
||||||
if(pattern_match($pattern,$dir)) $output[]=$dir;
|
if(pattern_match($pattern,$dir)) $output[]=$dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
|
|
||||||
if(is_array($output)) return $output;
|
if(is_array($output)) return $output;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -3387,13 +3396,13 @@ function pattern_match($pattern,$string)
|
|||||||
{
|
{
|
||||||
$escape=array('$','^','.','{','}','(',')','[',']','|');
|
$escape=array('$','^','.','{','}','(',')','[',']','|');
|
||||||
while(strpos($pattern,'**')!==false) $pattern=str_replace('**','*',$pattern);
|
while(strpos($pattern,'**')!==false) $pattern=str_replace('**','*',$pattern);
|
||||||
|
|
||||||
foreach($escape as $probe) $pattern=str_replace($probe,"\\$probe",$pattern);
|
foreach($escape as $probe) $pattern=str_replace($probe,"\\$probe",$pattern);
|
||||||
|
|
||||||
$pattern=str_replace('?*','*',str_replace('*?','*',str_replace('*',".*",str_replace('?','.{1,1}',$pattern))));
|
$pattern=str_replace('?*','*',str_replace('*?','*',str_replace('*',".*",str_replace('?','.{1,1}',$pattern))));
|
||||||
$out[]=$pattern;
|
$out[]=$pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($out)==1)
|
if(count($out)==1)
|
||||||
{
|
{
|
||||||
return(preg_match('/^'.$out[0].'$/i',$string));
|
return(preg_match('/^'.$out[0].'$/i',$string));
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
//! Product ID already linked to a reference supplier
|
//! Product ID already linked to a reference supplier
|
||||||
var $product_id_already_linked;
|
var $product_id_already_linked;
|
||||||
|
|
||||||
var $nbphoto;
|
var $nbphoto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2493,7 +2493,7 @@ class Product extends CommonObject
|
|||||||
* \param showfilename 1=Show filename
|
* \param showfilename 1=Show filename
|
||||||
* \param showaction 1=Show icon with action links (resize, delete)
|
* \param showaction 1=Show icon with action links (resize, delete)
|
||||||
* \param maxheight Max height of image when size=1
|
* \param maxheight Max height of image when size=1
|
||||||
* \return int Number of photos shown
|
* \return string Html code to show photo. Number of photos shown is saved in this->nbphoto
|
||||||
*/
|
*/
|
||||||
function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxheight=120)
|
function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxheight=120)
|
||||||
{
|
{
|
||||||
@@ -2507,7 +2507,7 @@ class Product extends CommonObject
|
|||||||
$dirthumb = $dir.'thumbs/';
|
$dirthumb = $dir.'thumbs/';
|
||||||
$pdirthumb = $pdir.'thumbs/';
|
$pdirthumb = $pdir.'thumbs/';
|
||||||
|
|
||||||
$return='';
|
$return='<!-- Photo -->';
|
||||||
$nbphoto=0;
|
$nbphoto=0;
|
||||||
|
|
||||||
$dir_osencoded=dol_osencode($dir);
|
$dir_osencoded=dol_osencode($dir);
|
||||||
@@ -2623,9 +2623,9 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->nbphoto = $nbphoto;
|
$this->nbphoto = $nbphoto;
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2797,7 +2797,7 @@ class Product extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Load type of canvas
|
* \brief Load type of canvas
|
||||||
* \param id product id
|
* \param id product id
|
||||||
@@ -2806,7 +2806,7 @@ class Product extends CommonObject
|
|||||||
function getCanvas($id, $ref)
|
function getCanvas($id, $ref)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$sql = "SELECT rowid, ref, canvas";
|
$sql = "SELECT rowid, ref, canvas";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||||
$sql.= " WHERE entity = ".$conf->entity;
|
$sql.= " WHERE entity = ".$conf->entity;
|
||||||
@@ -2817,11 +2817,11 @@ class Product extends CommonObject
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
$this->ref = $obj->ref;
|
$this->ref = $obj->ref;
|
||||||
$this->canvas = $obj->canvas;
|
$this->canvas = $obj->canvas;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2830,7 +2830,7 @@ class Product extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Affecte les valeurs communes
|
* \brief Affecte les valeurs communes
|
||||||
*/
|
*/
|
||||||
@@ -2838,28 +2838,28 @@ class Product extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
global $html;
|
global $html;
|
||||||
|
|
||||||
// canvas
|
// canvas
|
||||||
$this->tpl['canvas'] = $this->canvas;
|
$this->tpl['canvas'] = $this->canvas;
|
||||||
|
|
||||||
// id
|
// id
|
||||||
$this->tpl['id'] = $this->id;
|
$this->tpl['id'] = $this->id;
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
$this->tpl['ref'] = $this->ref;
|
$this->tpl['ref'] = $this->ref;
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
$this->tpl['label'] = $this->libelle;
|
$this->tpl['label'] = $this->libelle;
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
$this->tpl['description'] = nl2br($this->description);
|
$this->tpl['description'] = nl2br($this->description);
|
||||||
|
|
||||||
// Statut
|
// Statut
|
||||||
$this->tpl['status'] = $this->getLibStatut(2);
|
$this->tpl['status'] = $this->getLibStatut(2);
|
||||||
|
|
||||||
// Note
|
// Note
|
||||||
$this->tpl['note'] = nl2br($this->note);
|
$this->tpl['note'] = nl2br($this->note);
|
||||||
|
|
||||||
// Hidden
|
// Hidden
|
||||||
if ($this->user->rights->produit->hidden)
|
if ($this->user->rights->produit->hidden)
|
||||||
{
|
{
|
||||||
@@ -2869,38 +2869,38 @@ class Product extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->tpl['hidden'] = yn("No");
|
$this->tpl['hidden'] = yn("No");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'create')
|
if ($action == 'create')
|
||||||
{
|
{
|
||||||
// Price
|
// Price
|
||||||
$this->tpl['price'] = $this->price;
|
$this->tpl['price'] = $this->price;
|
||||||
$this->tpl['price_min'] = $this->price_min;
|
$this->tpl['price_min'] = $this->price_min;
|
||||||
$this->tpl['price_base_type'] = $html->load_PriceBaseType($this->price_base_type, "price_base_type");
|
$this->tpl['price_base_type'] = $html->load_PriceBaseType($this->price_base_type, "price_base_type");
|
||||||
|
|
||||||
// VAT
|
// VAT
|
||||||
$this->tpl['tva_tx'] = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,'');
|
$this->tpl['tva_tx'] = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,'');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'create' || $action == 'edit')
|
if ($action == 'create' || $action == 'edit')
|
||||||
{
|
{
|
||||||
// Status
|
// Status
|
||||||
$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
|
$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
|
||||||
$this->tpl['status'] = $html->selectarray('statut',$statutarray,$this->status);
|
$this->tpl['status'] = $html->selectarray('statut',$statutarray,$this->status);
|
||||||
|
|
||||||
// Hidden
|
// Hidden
|
||||||
if ($this->user->rights->produit->hidden)
|
if ($this->user->rights->produit->hidden)
|
||||||
{
|
{
|
||||||
$this->tpl['hidden'] = $html->selectyesno('hidden',$this->hidden);
|
$this->tpl['hidden'] = $html->selectyesno('hidden',$this->hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO creer fonction
|
// TODO creer fonction
|
||||||
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
|
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
||||||
|
|
||||||
$doleditor=new DolEditor('desc',$this->description,160,'dolibarr_notes','',false);
|
$doleditor=new DolEditor('desc',$this->description,160,'dolibarr_notes','',false);
|
||||||
$this->tpl['doleditor_description'] = $doleditor;
|
$this->tpl['doleditor_description'] = $doleditor;
|
||||||
|
|
||||||
$doleditor=new DolEditor('note',$this->note,180,'dolibarr_notes','',false);
|
$doleditor=new DolEditor('note',$this->note,180,'dolibarr_notes','',false);
|
||||||
$this->tpl['doleditor_note'] = $doleditor;
|
$this->tpl['doleditor_note'] = $doleditor;
|
||||||
}
|
}
|
||||||
@@ -2910,14 +2910,14 @@ class Product extends CommonObject
|
|||||||
$textarea.= $this->description;
|
$textarea.= $this->description;
|
||||||
$textarea.= '</textarea>';
|
$textarea.= '</textarea>';
|
||||||
$this->tpl['textarea_description'] = $textarea;
|
$this->tpl['textarea_description'] = $textarea;
|
||||||
|
|
||||||
$textarea = '<textarea name="note" rows="8" cols="70">';
|
$textarea = '<textarea name="note" rows="8" cols="70">';
|
||||||
$textarea.= $this->note;
|
$textarea.= $this->note;
|
||||||
$textarea.= '</textarea>';
|
$textarea.= '</textarea>';
|
||||||
$this->tpl['textarea_note'] = $textarea;
|
$this->tpl['textarea_note'] = $textarea;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'view')
|
if ($action == 'view')
|
||||||
{
|
{
|
||||||
// Ref
|
// Ref
|
||||||
|
|||||||
@@ -127,19 +127,14 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_POST["canvas"]))
|
$product=new Product($db);
|
||||||
|
|
||||||
|
$usecanvas=$_POST["canvas"];
|
||||||
|
if (! empty($usecanvas)) // Overwrite product here
|
||||||
{
|
{
|
||||||
$canvas = new Canvas($db,$user);
|
$canvas = new Canvas($db,$user);
|
||||||
$product = $canvas->load_canvas('product',$_POST["canvas"]);
|
$product = $canvas->load_canvas('product',$_POST["canvas"]);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$mesg='<div class="error">'.$langs->trans('ErrorCanvasNotDefined').'</div>';
|
|
||||||
$_GET["action"] = "create";
|
|
||||||
$_GET["canvas"] = $_POST["canvas"];
|
|
||||||
$_GET["type"] = $_POST["type"];
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
@@ -192,8 +187,6 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $value != $current_lang ) $e_product = $product;
|
|
||||||
|
|
||||||
$id = $product->create($user);
|
$id = $product->create($user);
|
||||||
|
|
||||||
if ($id > 0)
|
if ($id > 0)
|
||||||
@@ -220,7 +213,10 @@ if ($_POST["action"] == 'update' && ($user->rights->produit->creer || $user->rig
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!empty($_POST["canvas"]))
|
$product=new Product($db);
|
||||||
|
|
||||||
|
$usecanvas=$_POST["canvas"];
|
||||||
|
if (! empty($usecanvas)) // Overwrite product here
|
||||||
{
|
{
|
||||||
$canvas = new Canvas($db,$user);
|
$canvas = new Canvas($db,$user);
|
||||||
$product = $canvas->load_canvas('product',$_POST["canvas"]);
|
$product = $canvas->load_canvas('product',$_POST["canvas"]);
|
||||||
@@ -362,7 +358,7 @@ if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' &&
|
|||||||
*/
|
*/
|
||||||
if ($_POST["action"] == 'addinpropal')
|
if ($_POST["action"] == 'addinpropal')
|
||||||
{
|
{
|
||||||
$propal = New Propal($db);
|
$propal = new Propal($db);
|
||||||
$result=$propal->fetch($_POST["propalid"]);
|
$result=$propal->fetch($_POST["propalid"]);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
@@ -622,28 +618,27 @@ $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 (!empty($_GET["canvas"]))
|
$helpurl='';
|
||||||
|
if (isset($_GET["type"]) && $_GET["type"] == 0) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
|
||||||
|
if (isset($_GET["type"]) && $_GET["type"] == 1) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
|
||||||
|
|
||||||
|
llxHeader('',$langs->trans("CardProduct".$_GET["type"]),$helpurl);
|
||||||
|
|
||||||
|
$usecanvas=$_GET["canvas"];
|
||||||
|
if (empty($usecanvas))
|
||||||
{
|
{
|
||||||
$helpurl='';
|
// TODO Restore simple code here
|
||||||
if (isset($_GET["type"]) && $_GET["type"] == 0) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
|
|
||||||
if (isset($_GET["type"]) && $_GET["type"] == 1) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
|
|
||||||
|
|
||||||
llxHeader('',$langs->trans("CardProduct".$_GET["type"]),$helpurl);
|
|
||||||
|
|
||||||
if (! isset($product))
|
|
||||||
{
|
|
||||||
$canvas = new Canvas($db,$user);
|
|
||||||
|
|
||||||
$product = $canvas->load_canvas('product',$_GET["canvas"]);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$canvas = new Canvas($db,$user);
|
||||||
|
$product = $canvas->load_canvas('product',$_GET["canvas"]);
|
||||||
|
|
||||||
$canvas->assign_values('create');
|
$canvas->assign_values('create');
|
||||||
$canvas->display_canvas();
|
$canvas->display_canvas();
|
||||||
}
|
|
||||||
|
|
||||||
if ($_error == 1)
|
|
||||||
{
|
|
||||||
$product = $e_product;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -654,52 +649,358 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
|
|||||||
*/
|
*/
|
||||||
if ($_GET["id"] || $_GET["ref"])
|
if ($_GET["id"] || $_GET["ref"])
|
||||||
{
|
{
|
||||||
|
$product=new Product($db);
|
||||||
|
|
||||||
// TODO en attendant d'inclure le nom du canvas dans les liens
|
// TODO en attendant d'inclure le nom du canvas dans les liens
|
||||||
$productstatic = new Product($db);
|
$productstatic = new Product($db);
|
||||||
$result = $productstatic->getCanvas($_GET["id"],$_GET["ref"]);
|
$result = $productstatic->getCanvas($_GET["id"],$_GET["ref"]);
|
||||||
|
$usecanvas=$productstatic->canvas;
|
||||||
|
|
||||||
// Gestion des produits specifiques
|
if (empty($usecanvas))
|
||||||
if (!empty($productstatic->canvas))
|
{
|
||||||
|
$product->fetch($_GET["id"],$_GET["ref"]);
|
||||||
|
}
|
||||||
|
else // Gestion des produits specifiques
|
||||||
{
|
{
|
||||||
$canvas = new Canvas($db,$user);
|
$canvas = new Canvas($db,$user);
|
||||||
|
|
||||||
$product = $canvas->load_canvas('product',$productstatic->canvas);
|
$product = $canvas->load_canvas('product',$productstatic->canvas);
|
||||||
|
if (! $product) dol_print_error('','Faled to load canvas product-'.$productstatic->canvas);
|
||||||
|
|
||||||
$canvas->fetch($productstatic->id,'',$_GET["action"]);
|
$canvas->fetch($productstatic->id,'',$_GET["action"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
llxHeader('',$langs->trans("CardProduct".$product->type));
|
llxHeader('',$langs->trans("CardProduct".$product->type));
|
||||||
|
|
||||||
if ( $result )
|
/*
|
||||||
|
* Fiche en mode edition
|
||||||
|
*/
|
||||||
|
if ($_GET["action"] == 'edit' && ($user->rights->produit->creer || $user->rights->service->creer))
|
||||||
{
|
{
|
||||||
/*
|
if (empty($usecanvas))
|
||||||
* Fiche en mode edition
|
{
|
||||||
*/
|
if ($product->isservice()) {
|
||||||
if ($_GET["action"] == 'edit' && ($user->rights->produit->creer || $user->rights->service->creer))
|
print_fiche_titre($langs->trans('Modify').' '.$langs->trans('Service').' : '.$product->ref, "");
|
||||||
|
} else {
|
||||||
|
print_fiche_titre($langs->trans('Modify').' '.$langs->trans('Product').' : '.$product->ref, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($mesg) {
|
||||||
|
print '<br><div class="error">'.$mesg.'</div><br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main official, simple, and not duplicated code
|
||||||
|
print "<form action=\"fiche.php\" method=\"post\">\n";
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="action" value="update">';
|
||||||
|
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||||
|
print '<input type="hidden" name="canvas" value="'.$product->canvas.'">';
|
||||||
|
print '<table class="border" width="100%">';
|
||||||
|
print '<tr><td width="15%">'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" size="40" maxlength="32" value="'.$product->ref.'"></td></tr>';
|
||||||
|
print '<tr><td>'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
|
||||||
|
|
||||||
|
// Status
|
||||||
|
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
|
||||||
|
print '<select class="flat" name="statut">';
|
||||||
|
if ($product->status)
|
||||||
|
{
|
||||||
|
print '<option value="1" selected="true">'.$langs->trans("OnSell").'</option>';
|
||||||
|
print '<option value="0">'.$langs->trans("NotOnSell").'</option>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<option value="1">'.$langs->trans("OnSell").'</option>';
|
||||||
|
print '<option value="0" selected="true">'.$langs->trans("NotOnSell").'</option>';
|
||||||
|
}
|
||||||
|
print '</select>';
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Description (used in invoice, propal...)
|
||||||
|
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="2">';
|
||||||
|
print "\n";
|
||||||
|
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
|
||||||
|
{
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
||||||
|
$doleditor=new DolEditor('desc',$product->description,160,'dolibarr_notes','',false);
|
||||||
|
$doleditor->Create();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<textarea name="desc" rows="4" cols="90">';
|
||||||
|
print dol_htmlentitiesbr_decode($product->description);
|
||||||
|
print "</textarea>";
|
||||||
|
}
|
||||||
|
print "</td></tr>";
|
||||||
|
print "\n";
|
||||||
|
|
||||||
|
// Nature
|
||||||
|
if($product->type!=1)
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("Nature").'</td><td>';
|
||||||
|
$statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial"));
|
||||||
|
$html->select_array('finished',$statutarray,$product->finished);
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($product->isproduct() && $conf->stock->enabled)
|
||||||
|
{
|
||||||
|
print "<tr>".'<td>'.$langs->trans("StockLimit").'</td><td colspan="2">';
|
||||||
|
print '<input name="seuil_stock_alerte" size="4" value="'.$product->seuil_stock_alerte.'">';
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<input name="seuil_stock_alerte" type="hidden" value="'.$product->seuil_stock_alerte.'">';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($product->isservice())
|
||||||
|
{
|
||||||
|
// Duration
|
||||||
|
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="2"><input name="duration_value" size="3" maxlength="5" value="'.$product->duration_value.'">';
|
||||||
|
print ' ';
|
||||||
|
print '<input name="duration_unit" type="radio" value="h"'.($product->duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour");
|
||||||
|
print ' ';
|
||||||
|
print '<input name="duration_unit" type="radio" value="d"'.($product->duration_unit=='d'?' checked':'').'>'.$langs->trans("Day");
|
||||||
|
print ' ';
|
||||||
|
print '<input name="duration_unit" type="radio" value="w"'.($product->duration_unit=='w'?' checked':'').'>'.$langs->trans("Week");
|
||||||
|
print ' ';
|
||||||
|
print '<input name="duration_unit" type="radio" value="m"'.($product->duration_unit=='m'?' checked':'').'>'.$langs->trans("Month");
|
||||||
|
print ' ';
|
||||||
|
print '<input name="duration_unit" type="radio" value="y"'.($product->duration_unit=='y'?' checked':'').'>'.$langs->trans("Year");
|
||||||
|
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Weight
|
||||||
|
print '<tr><td>'.$langs->trans("Weight").'</td><td>';
|
||||||
|
print '<input name="weight" size="5" value="'.$product->weight.'"> ';
|
||||||
|
print $formproduct->select_measuring_units("weight_units", "weight", $product->weight_units);
|
||||||
|
print '</td></tr>';
|
||||||
|
// Length
|
||||||
|
print '<tr><td>'.$langs->trans("Length").'</td><td>';
|
||||||
|
print '<input name="size" size="5" value="'.$product->length.'"> ';
|
||||||
|
print $formproduct->select_measuring_units("size_units", "size", $product->length_units);
|
||||||
|
print '</td></tr>';
|
||||||
|
// Surface
|
||||||
|
print '<tr><td>'.$langs->trans("Surface").'</td><td>';
|
||||||
|
print '<input name="surface" size="5" value="'.$product->surface.'"> ';
|
||||||
|
print $formproduct->select_measuring_units("surface_units", "surface", $product->surface_units);
|
||||||
|
print '</td></tr>';
|
||||||
|
// Volume
|
||||||
|
print '<tr><td>'.$langs->trans("Volume").'</td><td>';
|
||||||
|
print '<input name="volume" size="5" value="'.$product->volume.'"> ';
|
||||||
|
print $formproduct->select_measuring_units("volume_units", "volume", $product->volume_units);
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hidden
|
||||||
|
if ((! $product->isservice() && $user->rights->produit->hidden)
|
||||||
|
|| ($product->isservice() && $user->rights->service->hidden))
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("Hidden").'</td><td>';
|
||||||
|
print $html->selectyesno('hidden',$product->hidden);
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("Hidden").'</td><td>';
|
||||||
|
print yn("No");
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note
|
||||||
|
print '<tr><td valign="top">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="2">';
|
||||||
|
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
|
||||||
|
{
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
||||||
|
$doleditor=new DolEditor('note',$product->note,200,'dolibarr_notes','',false);
|
||||||
|
$doleditor->Create();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<textarea name="note" rows="8" cols="70">';
|
||||||
|
print dol_htmlentitiesbr_decode($product->note);
|
||||||
|
print "</textarea>";
|
||||||
|
}
|
||||||
|
print "</td></tr>";
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
||||||
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
|
||||||
|
|
||||||
|
print '</form>';
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$canvas->assign_values('edit');
|
$canvas->assign_values('edit');
|
||||||
$canvas->display_canvas();
|
$canvas->display_canvas();
|
||||||
}
|
}
|
||||||
/*
|
}
|
||||||
* Fiche en mode visu
|
/*
|
||||||
*/
|
* Fiche en mode visu
|
||||||
else
|
*/
|
||||||
{
|
else
|
||||||
$head=product_prepare_head($product, $user);
|
{
|
||||||
$titre=$langs->trans("CardProduct".$product->type);
|
$head=product_prepare_head($product, $user);
|
||||||
$picto=($product->type==1?'service':'product');
|
$titre=$langs->trans("CardProduct".$product->type);
|
||||||
dol_fiche_head($head, 'card', $titre, 0, $picto);
|
$picto=($product->type==1?'service':'product');
|
||||||
|
dol_fiche_head($head, 'card', $titre, 0, $picto);
|
||||||
|
|
||||||
// Confirmation de la suppression de la facture
|
// Confirmation de la suppression de la facture
|
||||||
if ($_GET["action"] == 'delete')
|
if ($_GET["action"] == 'delete')
|
||||||
|
{
|
||||||
|
$ret=$html->form_confirm("fiche.php?id=".$product->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,2);
|
||||||
|
if ($ret == 'html') print '<br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($usecanvas))
|
||||||
|
{
|
||||||
|
// En mode visu
|
||||||
|
print '<table class="border" width="100%"><tr>';
|
||||||
|
|
||||||
|
// Ref
|
||||||
|
print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="2">';
|
||||||
|
print $html->showrefnav($product,'ref','',1,'ref');
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
// Label
|
||||||
|
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>';
|
||||||
|
|
||||||
|
$nblignes=4;
|
||||||
|
if ($product->is_photo_available($conf->produit->dir_output))
|
||||||
{
|
{
|
||||||
$ret=$html->form_confirm("fiche.php?id=".$product->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,2);
|
// Photo
|
||||||
if ($ret == 'html') print '<br>';
|
print '<td valign="middle" align="center" width="30%" rowspan="'.$nblignes.'">';
|
||||||
|
print $product->show_photos($conf->produit->dir_output,1,1,0,0,0,80);
|
||||||
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
// Accountancy buy code
|
||||||
|
print '<tr><td>'.$html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$product->accountancy_code_sell,'id',$product->id,$user->rights->produit->creer).'</td><td>';
|
||||||
|
print $html->editfieldval("ProductAccountancyBuyCode",'productaccountancycodesell',$product->accountancy_code_sell,'id',$product->id,$user->rights->produit->creer);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Accountancy sell code
|
||||||
|
print '<tr><td>'.$html->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$product->accountancy_code_buy,'id',$product->id,$user->rights->produit->creer).'</td><td>';
|
||||||
|
print $html->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$product->accountancy_code_buy,'id',$product->id,$user->rights->produit->creer);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Statut
|
||||||
|
print '<tr><td>'.$langs->trans("Status").'</td><td>';
|
||||||
|
print $product->getLibStatut(2);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Description
|
||||||
|
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="2">'.nl2br($product->description).'</td></tr>';
|
||||||
|
|
||||||
|
// Nature
|
||||||
|
if($product->type!=1)
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("Nature").'</td><td colspan="2">';
|
||||||
|
print $product->getLibFinished();
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($product->isservice())
|
||||||
|
{
|
||||||
|
// Duration
|
||||||
|
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="2">'.$product->duration_value.' ';
|
||||||
|
if ($product->duration_value > 1)
|
||||||
|
{
|
||||||
|
$dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years"));
|
||||||
|
}
|
||||||
|
else if ($product->duration_value > 0)
|
||||||
|
{
|
||||||
|
$dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year"));
|
||||||
|
}
|
||||||
|
print $langs->trans($dur[$product->duration_unit])." ";
|
||||||
|
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Weight
|
||||||
|
print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="2">';
|
||||||
|
if ($product->weight != '')
|
||||||
|
{
|
||||||
|
print $product->weight." ".measuring_units_string($product->weight_units,"weight");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print ' ';
|
||||||
|
}
|
||||||
|
print "</td></tr>\n";
|
||||||
|
// Length
|
||||||
|
print '<tr><td>'.$langs->trans("Length").'</td><td colspan="2">';
|
||||||
|
if ($product->length != '')
|
||||||
|
{
|
||||||
|
print $product->length." ".measuring_units_string($product->length_units,"size");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print ' ';
|
||||||
|
}
|
||||||
|
print "</td></tr>\n";
|
||||||
|
// Surface
|
||||||
|
print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="2">';
|
||||||
|
if ($product->surface != '')
|
||||||
|
{
|
||||||
|
print $product->surface." ".measuring_units_string($product->surface_units,"surface");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print ' ';
|
||||||
|
}
|
||||||
|
print "</td></tr>\n";
|
||||||
|
// Volume
|
||||||
|
print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="2">';
|
||||||
|
if ($product->volume != '')
|
||||||
|
{
|
||||||
|
print $product->volume." ".measuring_units_string($product->volume_units,"volume");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print ' ';
|
||||||
|
}
|
||||||
|
print "</td></tr>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hidden
|
||||||
|
if ((! $product->isservice() && $user->rights->produit->hidden)
|
||||||
|
|| ($product->isservice() && $user->rights->service->hidden))
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("Hidden").'</td><td colspan="2">';
|
||||||
|
print yn($product->hidden);
|
||||||
|
print "</td></tr>\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("Hidden").'</td><td>';
|
||||||
|
print yn("No");
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note
|
||||||
|
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="2">'.nl2br($product->note).'</td></tr>';
|
||||||
|
|
||||||
|
print "</table>\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$canvas->assign_values('view');
|
$canvas->assign_values('view');
|
||||||
$canvas->display_canvas();
|
$canvas->display_canvas();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dol_fiche_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!$_GET["action"] == 'create')
|
else if (!$_GET["action"] == 'create')
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user