Add patch from meos to add photos on categories.
Fix: Solve pb in categories navigation
This commit is contained in:
parent
5ee8333882
commit
8906d988ed
@ -22,20 +22,20 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/categories/categorie.class.php
|
||||
\ingroup categorie
|
||||
\brief Fichier de la classe des categorie
|
||||
\version $Id$
|
||||
*/
|
||||
* \file htdocs/categories/categorie.class.php
|
||||
* \ingroup categorie
|
||||
* \brief Fichier de la classe des categorie
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.class.php");
|
||||
|
||||
|
||||
/**
|
||||
\class Categorie
|
||||
\brief Classe permettant la gestion des categories
|
||||
*/
|
||||
* \class Categorie
|
||||
* \brief Classe permettant la gestion des categories
|
||||
*/
|
||||
class Categorie
|
||||
{
|
||||
var $error;
|
||||
@ -54,10 +54,10 @@ class Categorie
|
||||
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
* db : accès base de données
|
||||
* id : id de la catégorie
|
||||
*/
|
||||
* Constructeur
|
||||
* db : accès base de données
|
||||
* id : id de la catégorie
|
||||
*/
|
||||
function Categorie($db, $id=-1)
|
||||
{
|
||||
$this->db = $db;
|
||||
@ -67,9 +67,9 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge la catégorie
|
||||
* id : id de la catégorie à charger
|
||||
*/
|
||||
* Charge la catégorie
|
||||
* id : id de la catégorie à charger
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
$sql = "SELECT rowid, label, description, fk_soc, visible, type";
|
||||
@ -117,11 +117,11 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajoute la catégorie dans la base de données
|
||||
* retour : -1 : erreur SQL
|
||||
* -2 : nouvel ID inconnu
|
||||
* -3 : catégorie invalide
|
||||
*/
|
||||
* Ajoute la catégorie dans la base de données
|
||||
* retour : -1 : erreur SQL
|
||||
* -2 : nouvel ID inconnu
|
||||
* -3 : catégorie invalide
|
||||
*/
|
||||
function create()
|
||||
{
|
||||
global $conf,$langs;
|
||||
@ -180,11 +180,11 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* Mise à jour de la catégorie
|
||||
* retour : 1 : OK
|
||||
* -1 : erreur SQL
|
||||
* -2 : catégorie invalide
|
||||
*/
|
||||
* Mise à jour de la catégorie
|
||||
* retour : 1 : OK
|
||||
* -1 : erreur SQL
|
||||
* -2 : catégorie invalide
|
||||
*/
|
||||
function update()
|
||||
{
|
||||
global $conf;
|
||||
@ -248,10 +248,10 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* Supprime la catégorie
|
||||
* Les produits et sous-catégories deviennent orphelins
|
||||
* si $all = false, et sont (seront :) supprimés sinon
|
||||
*/
|
||||
* Supprime la catégorie
|
||||
* Les produits et sous-catégories deviennent orphelins
|
||||
* si $all = false, et sont (seront :) supprimés sinon
|
||||
*/
|
||||
function remove ($all = false)
|
||||
{
|
||||
|
||||
@ -291,12 +291,12 @@ class Categorie
|
||||
|
||||
|
||||
/**
|
||||
* Ajout d'une sous-catégorie
|
||||
* $fille : objet catégorie
|
||||
* retour : 1 : OK
|
||||
* -2 : $fille est déjà dans la famille de $this
|
||||
* -3 : catégorie ($this ou $fille) invalide
|
||||
*/
|
||||
* Ajout d'une sous-catégorie
|
||||
* $fille : objet catégorie
|
||||
* retour : 1 : OK
|
||||
* -2 : $fille est déjà dans la famille de $this
|
||||
* -3 : catégorie ($this ou $fille) invalide
|
||||
*/
|
||||
function add_fille()
|
||||
{
|
||||
|
||||
@ -315,11 +315,11 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* Suppression d'une sous-catégorie (seulement "désassociation")
|
||||
* $fille : objet catégorie
|
||||
* retour : 1 : OK
|
||||
* -3 : catégorie ($this ou $fille) invalide
|
||||
*/
|
||||
* Suppression d'une sous-catégorie (seulement "désassociation")
|
||||
* $fille : objet catégorie
|
||||
* retour : 1 : OK
|
||||
* -3 : catégorie ($this ou $fille) invalide
|
||||
*/
|
||||
function del_fille($fille)
|
||||
{
|
||||
if (!$this->check() || !$fille->check())
|
||||
@ -342,11 +342,11 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Link an object to the category
|
||||
* \param obj Object to link to category
|
||||
* \param type Type of category
|
||||
* \return int 1 : OK, -1 : erreur SQL, -2 : id non renseign, -3 : Already linked
|
||||
*/
|
||||
* \brief Link an object to the category
|
||||
* \param obj Object to link to category
|
||||
* \param type Type of category
|
||||
* \return int 1 : OK, -1 : erreur SQL, -2 : id non renseign, -3 : Already linked
|
||||
*/
|
||||
function add_type($obj,$type)
|
||||
{
|
||||
if ($this->id == -1)
|
||||
@ -377,11 +377,11 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* Suppresion d'un produit de la catégorie
|
||||
* @param $prod est un objet de type produit
|
||||
* retour : 1 : OK
|
||||
* -1 : erreur SQL
|
||||
*/
|
||||
* Suppresion d'un produit de la catégorie
|
||||
* @param $prod est un objet de type produit
|
||||
* retour : 1 : OK
|
||||
* -1 : erreur SQL
|
||||
*/
|
||||
function del_type($obj,$type)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".$type;
|
||||
@ -400,11 +400,11 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retourne les produits de la catégorie
|
||||
* \param field Field name for select in table. Full field name will be fk_field.
|
||||
* \param class PHP Class of object to store entity
|
||||
* \param table Table name for select in table. Full table name will be PREFIX_categorie_table.
|
||||
*/
|
||||
* \brief Retourne les produits de la catégorie
|
||||
* \param field Field name for select in table. Full field name will be fk_field.
|
||||
* \param class PHP Class of object to store entity
|
||||
* \param table Table name for select in table. Full table name will be PREFIX_categorie_table.
|
||||
*/
|
||||
function get_type($field,$class,$table='')
|
||||
{
|
||||
$objs = array();
|
||||
@ -440,8 +440,8 @@ class Categorie
|
||||
|
||||
|
||||
/**
|
||||
* Retourne les filles de la catégorie
|
||||
*/
|
||||
* Retourne les filles de la catégorie
|
||||
*/
|
||||
function get_filles ()
|
||||
{
|
||||
$sql = "SELECT fk_categorie_fille FROM ".MAIN_DB_PREFIX."categorie_association ";
|
||||
@ -468,8 +468,8 @@ class Categorie
|
||||
|
||||
|
||||
/**
|
||||
* retourne la description d'une catégorie
|
||||
*/
|
||||
* retourne la description d'une catégorie
|
||||
*/
|
||||
function get_desc ($cate)
|
||||
{
|
||||
$sql = "SELECT description FROM ".MAIN_DB_PREFIX."categorie ";
|
||||
@ -482,8 +482,8 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* La catégorie $fille est-elle une fille de cette catégorie ?
|
||||
*/
|
||||
* La catégorie $fille est-elle une fille de cette catégorie ?
|
||||
*/
|
||||
function is_fille ($fille)
|
||||
{
|
||||
$sql = "SELECT count(fk_categorie_fille) FROM ".MAIN_DB_PREFIX."categorie_association ";
|
||||
@ -498,18 +498,18 @@ class Categorie
|
||||
|
||||
|
||||
/**
|
||||
* \brief Reconstruit l'arborescence des catégories sous la forme d'un tableau
|
||||
* Renvoi un tableau de tableau('id','id_mere',...) trié selon
|
||||
* arbre et avec:
|
||||
* id = id de la categorie
|
||||
* id_mere = id de la categorie mere
|
||||
* id_children = tableau des id enfant
|
||||
* label = nom de la categorie
|
||||
* fulllabel = nom avec chemin complet de la categorie
|
||||
* fullpath = chemin complet compose des id
|
||||
* \param type Type de categories (0=produit, 1=fournisseur, 2=client)
|
||||
* \return array Tableau de array
|
||||
*/
|
||||
* \brief Reconstruit l'arborescence des catégories sous la forme d'un tableau
|
||||
* Renvoi un tableau de tableau('id','id_mere',...) trié selon
|
||||
* arbre et avec:
|
||||
* id = id de la categorie
|
||||
* id_mere = id de la categorie mere
|
||||
* id_children = tableau des id enfant
|
||||
* label = nom de la categorie
|
||||
* fulllabel = nom avec chemin complet de la categorie
|
||||
* fullpath = chemin complet compose des id
|
||||
* \param type Type de categories (0=produit, 1=fournisseur, 2=client)
|
||||
* \return array Tableau de array
|
||||
*/
|
||||
function get_full_arbo($type)
|
||||
{
|
||||
$this->cats = array();
|
||||
@ -583,17 +583,17 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief For category id_categ and its child available in this->cats, define property fullpath and fulllabel
|
||||
* \param id_categ id_categ entry to update
|
||||
* \param protection Deep counter to avoid infinite loop
|
||||
*/
|
||||
* \brief For category id_categ and its child available in this->cats, define property fullpath and fulllabel
|
||||
* \param id_categ id_categ entry to update
|
||||
* \param protection Deep counter to avoid infinite loop
|
||||
*/
|
||||
function build_path_from_id_categ($id_categ,$protection=0)
|
||||
{
|
||||
dol_syslog("Categorie::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG);
|
||||
|
||||
//if (! empty($this->cats[$id_categ]['fullpath']))
|
||||
//{
|
||||
// Already defined
|
||||
// Already defined
|
||||
// dol_syslog("Categorie::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING);
|
||||
// return;
|
||||
//}
|
||||
@ -634,8 +634,8 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Affiche contenu de $this->cats
|
||||
*/
|
||||
* \brief Affiche contenu de $this->cats
|
||||
*/
|
||||
function debug_cats()
|
||||
{
|
||||
// Affiche $this->cats
|
||||
@ -653,9 +653,9 @@ class Categorie
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne toutes les catégories
|
||||
* \return array Tableau d'objet Categorie
|
||||
*/
|
||||
* \brief Retourne toutes les catégories
|
||||
* \return array Tableau d'objet Categorie
|
||||
*/
|
||||
function get_all_categories ()
|
||||
{
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
|
||||
@ -679,9 +679,9 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retourne le nombre total de catégories
|
||||
* \return int Nombre de categories
|
||||
*/
|
||||
* \brief Retourne le nombre total de catégories
|
||||
* \return int Nombre de categories
|
||||
*/
|
||||
function get_nb_categories ()
|
||||
{
|
||||
$sql = "SELECT count(rowid)";
|
||||
@ -700,8 +700,8 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si une catégorie porte le label $label
|
||||
*/
|
||||
* Vérifie si une catégorie porte le label $label
|
||||
*/
|
||||
function already_exists()
|
||||
{
|
||||
$sql = "SELECT count(c.rowid)";
|
||||
@ -731,8 +731,8 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retourne les catégories de premier niveau (qui ne sont pas filles)
|
||||
*/
|
||||
* \brief Retourne les catégories de premier niveau (qui ne sont pas filles)
|
||||
*/
|
||||
function get_main_categories ()
|
||||
{
|
||||
$allcats = $this->get_all_categories ();
|
||||
@ -761,9 +761,9 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne les chemin de la catégorie, avec les noms des catégories
|
||||
* séparés par $sep (" >> " par défaut)
|
||||
*/
|
||||
* Retourne les chemin de la catégorie, avec les noms des catégories
|
||||
* séparés par $sep (" >> " par défaut)
|
||||
*/
|
||||
function print_all_ways ($sep = " >> ", $url='')
|
||||
{
|
||||
$ways = array ();
|
||||
@ -790,8 +790,8 @@ class Categorie
|
||||
|
||||
|
||||
/**
|
||||
* get_primary_way() affiche le chemin le plus court pour se rendre à un produit
|
||||
*/
|
||||
* get_primary_way() affiche le chemin le plus court pour se rendre à un produit
|
||||
*/
|
||||
function get_primary_way($id, $type="")
|
||||
{
|
||||
$primary_way = Array("taille"=>-1,"chemin"=>Array());
|
||||
@ -812,8 +812,8 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* print_primary_way() affiche le chemin le plus court pour se rendre à un produit
|
||||
*/
|
||||
* print_primary_way() affiche le chemin le plus court pour se rendre à un produit
|
||||
*/
|
||||
function print_primary_way($id, $sep= " >> ", $url, $type="")
|
||||
{
|
||||
$primary_way = Array();
|
||||
@ -835,8 +835,8 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne un tableau contenant la liste des catégories mères
|
||||
*/
|
||||
* Retourne un tableau contenant la liste des catégories mères
|
||||
*/
|
||||
function get_meres ()
|
||||
{
|
||||
$meres = array ();
|
||||
@ -862,9 +862,9 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne dans un tableau tous les chemins possibles pour arriver à la catégorie
|
||||
* en partant des catégories principales, représentés par des tableaux de catégories
|
||||
*/
|
||||
* Retourne dans un tableau tous les chemins possibles pour arriver à la catégorie
|
||||
* en partant des catégories principales, représentés par des tableaux de catégories
|
||||
*/
|
||||
function get_all_ways ()
|
||||
{
|
||||
$ways = array ();
|
||||
@ -887,12 +887,12 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of categories linked to element of type $type with id $typeid
|
||||
* @param id Id of element
|
||||
* @param type Type of link ('customer','fournisseur','societe'...)
|
||||
* @param typeid Type id of link (0,1,2...)
|
||||
* @return array List of category objects
|
||||
*/
|
||||
* Return list of categories linked to element of type $type with id $typeid
|
||||
* @param id Id of element
|
||||
* @param type Type of link ('customer','fournisseur','societe'...)
|
||||
* @param typeid Type id of link (0,1,2...)
|
||||
* @return array List of category objects
|
||||
*/
|
||||
function containing ($id,$type,$typeid)
|
||||
{
|
||||
$cats = array ();
|
||||
@ -921,9 +921,9 @@ class Categorie
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne les catégories dont l'id ou le nom correspond
|
||||
* ajoute des wildcards au nom sauf si $exact = true
|
||||
*/
|
||||
* \brief Retourne les catégories dont l'id ou le nom correspond
|
||||
* ajoute des wildcards au nom sauf si $exact = true
|
||||
*/
|
||||
function rechercher($id, $nom, $type, $exact = false)
|
||||
{
|
||||
$cats = array ();
|
||||
@ -963,18 +963,19 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoie nom clicable (avec eventuellement le picto)
|
||||
* \brief Return name and link of category (with picto)
|
||||
* \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
|
||||
* \param option Sur quoi pointe le lien ('', 'withdraw')
|
||||
* \param option Sur quoi pointe le lien ('', 'xyz')
|
||||
* \param maxlength Max length of text
|
||||
* \return string Chaine avec URL
|
||||
*/
|
||||
function getNomUrl($withpicto=0,$option='')
|
||||
function getNomUrl($withpicto=0,$option='',$maxlength=0)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$result='';
|
||||
|
||||
$lien = '<a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$this->id.'">';
|
||||
$lien = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$this->id.'&type='.$this->type.'">';
|
||||
$label=$this->label;
|
||||
$lienfin='</a>';
|
||||
|
||||
@ -984,9 +985,145 @@ class Categorie
|
||||
|
||||
if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
|
||||
if ($withpicto && $withpicto != 2) $result.=' ';
|
||||
if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
|
||||
if ($withpicto != 2) $result.=$lien.dol_trunc($this->ref,$maxlength).$lienfin;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Deplace fichier uploade sous le nom $files dans le repertoire sdir
|
||||
* \param sdir Repertoire destination finale
|
||||
* \param $file Nom du fichier uploade
|
||||
* \param maxWidth Largeur maximum que dois faire la miniature (160 par defaut)
|
||||
* \param maxHeight Hauteur maximum que dois faire la miniature (120 par defaut)
|
||||
*/
|
||||
function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120)
|
||||
{
|
||||
$dir = $sdir .'/'. get_exdir($this->id,2) . $this->id ."/";
|
||||
$dir .= "photos/";
|
||||
|
||||
if (! file_exists($dir))
|
||||
{
|
||||
create_exdir($dir);
|
||||
}
|
||||
|
||||
if (file_exists($dir))
|
||||
{
|
||||
$originImage = $dir . $file['name'];
|
||||
|
||||
// Cree fichier en taille origine
|
||||
$result=dol_move_uploaded_file($file['tmp_name'], $originImage, 1);
|
||||
|
||||
if (file_exists($originImage))
|
||||
{
|
||||
// Cree fichier en taille vignette
|
||||
$this->add_thumb($originImage,$maxWidth,$maxHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Build thumb
|
||||
* \param sdir Repertoire destination finale
|
||||
* \param file Chemin du fichier d'origine
|
||||
* \param maxWidth Largeur maximum que dois faire la miniature (160 par defaut)
|
||||
* \param maxHeight Hauteur maximum que dois faire la miniature (120 par defaut)
|
||||
*/
|
||||
function add_thumb($file, $maxWidth = 160, $maxHeight = 120)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT ."/lib/images.lib.php");
|
||||
|
||||
if (file_exists($file))
|
||||
{
|
||||
vignette($file,$maxWidth,$maxHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne tableau de toutes les photos de la categorie
|
||||
* \param dir R?pertoire ? scanner
|
||||
* \param nbmax Nombre maximum de photos (0=pas de max)
|
||||
* \return array Tableau de photos
|
||||
*/
|
||||
function liste_photos($dir,$nbmax=0)
|
||||
{
|
||||
$nbphoto=0;
|
||||
$tabobj=array();
|
||||
|
||||
$dirthumb = $dir.'thumbs/';
|
||||
|
||||
if (file_exists($dir))
|
||||
{
|
||||
$handle=opendir($dir);
|
||||
|
||||
while (($file = readdir($handle)) != false)
|
||||
{
|
||||
if (is_file($dir.$file))
|
||||
{
|
||||
$nbphoto++;
|
||||
$photo = $file;
|
||||
|
||||
// On determine nom du fichier vignette
|
||||
$photo_vignette='';
|
||||
if (eregi('(\.jpg|\.bmp|\.gif|\.png|\.tiff)$',$photo,$regs))
|
||||
{
|
||||
$photo_vignette=eregi_replace($regs[0],'',$photo).'_small'.$regs[0];
|
||||
}
|
||||
|
||||
// Objet
|
||||
$obj=array();
|
||||
$obj['photo']=$photo;
|
||||
if ($photo_vignette && is_file($dirthumb.$photo_vignette)) $obj['photo_vignette']=$photo_vignette;
|
||||
else $obj['photo_vignette']="";
|
||||
|
||||
$tabobj[$nbphoto-1]=$obj;
|
||||
|
||||
// On continue ou on arrete de boucler ?
|
||||
if ($nbmax && $nbphoto >= $nbmax) break;
|
||||
}
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
return $tabobj;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Efface la photo de la categorie et sa vignette
|
||||
* \param file Chemin de l'image
|
||||
*/
|
||||
function delete_photo($file)
|
||||
{
|
||||
$dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine
|
||||
$dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette
|
||||
$filename = eregi_replace($dir,'',$file); // Nom du fichier
|
||||
|
||||
// On efface l'image d'origine
|
||||
unlink($file);
|
||||
|
||||
// Si elle existe, on efface la vignette
|
||||
if (eregi('(\.jpg|\.bmp|\.gif|\.png|\.tiff)$',$filename,$regs))
|
||||
{
|
||||
$photo_vignette=eregi_replace($regs[0],'',$filename).'_small'.$regs[0];
|
||||
if (file_exists($dirthumb.$photo_vignette))
|
||||
{
|
||||
unlink($dirthumb.$photo_vignette);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Load size of image file
|
||||
* \param file Path to file
|
||||
*/
|
||||
function get_image_size($file)
|
||||
{
|
||||
$infoImg = getimagesize($file); // R?cup?ration des infos de l'image
|
||||
$this->imgWidth = $infoImg[0]; // Largeur de l'image
|
||||
$this->imgHeight = $infoImg[1]; // Hauteur de l'image
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
/**
|
||||
* \file htdocs/categories/index.php
|
||||
* \ingroup category
|
||||
* \brief Page accueil espace categories
|
||||
* \brief Home page of category area
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
@ -144,7 +144,7 @@ print '</td>';
|
||||
print '</tr></table></td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
//print '<td align="right"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
@ -249,23 +249,30 @@ foreach($fulltree as $key => $val)
|
||||
print '</td>';
|
||||
// Show link
|
||||
print '<td valign="middle">';
|
||||
if ($section == $val['id']) print ' <u>';
|
||||
//if ($section == $val['id']) print ' <u>';
|
||||
/* We don't want a link
|
||||
$categstatic->id=$val['id'];
|
||||
$categstatic->ref=$val['label'];
|
||||
$categstatic->type=$type;
|
||||
print $categstatic->getNomUrl(0,'',28);
|
||||
*/
|
||||
print dol_trunc($val['label'],28);
|
||||
if ($section == $val['id']) print '</u>';
|
||||
//if ($section == $val['id']) print '</u>';
|
||||
print '</td>';
|
||||
print '</tr></table>';
|
||||
print "</td>\n";
|
||||
|
||||
// Description
|
||||
print '<td>';
|
||||
print dol_trunc($categstatic->get_desc($val['id']),48);
|
||||
print '</td>';
|
||||
|
||||
// Edit link
|
||||
print '<td align="right"><a href="'.DOL_URL_ROOT.'/categories/edit.php?id='.$val['id'].'&type='.$type.'">'.img_edit().'</a></td>';
|
||||
// Link to category card
|
||||
print '<td align="right"><a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.$type.'">'.img_view().'</a></td>';
|
||||
|
||||
// Add link
|
||||
//print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create&catParent='.$val['id'].'">'.img_edit_add().'</a></td>';
|
||||
print '<td align="right"> </td>';
|
||||
//print '<td align="right"> </td>';
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
@ -286,7 +293,7 @@ if ($nbofentries == 0)
|
||||
print '</td>';
|
||||
print '<td> </td>';
|
||||
print '</table></td>';
|
||||
print '<td colspan="5"> </td>';
|
||||
print '<td colspan="4"> </td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
|
||||
324
htdocs/categories/photos.php
Normal file
324
htdocs/categories/photos.php
Normal file
@ -0,0 +1,324 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2007 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/categories/photos.php
|
||||
* \ingroup category
|
||||
* \brief Gestion des photos d'une categorie
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
|
||||
|
||||
$langs->load("category");
|
||||
$langs->load("bills");
|
||||
|
||||
$mesg = '';
|
||||
|
||||
// Security check
|
||||
if (!$user->rights->categorie->lire) accessforbidden();
|
||||
|
||||
if ($_REQUEST['id'] == "")
|
||||
{
|
||||
dol_print_error('','Missing parameter id');
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
if ($_GET["id"])
|
||||
{
|
||||
$c = new Categorie($db);
|
||||
$result = $c->fetch($_GET["id"]);
|
||||
|
||||
$result = $c->add_photo($conf->categorie->dir_output, $_FILES['userfile']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($_REQUEST["action"] == 'confirm_delete' && $_GET["file"] && $_REQUEST['confirm'] == 'yes' && $user->rights->categorie->creer)
|
||||
{
|
||||
$c = new Categorie($db);
|
||||
$c->delete_photo($conf->categorie->dir_output."/".$_GET["file"]);
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'addthumb' && $_GET["file"])
|
||||
{
|
||||
$c = new Category($db);
|
||||
$c->add_thumb($conf->categorie->dir_output."/".$_GET["file"]);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader ("","",$langs->trans("Categories"));
|
||||
|
||||
$c = new Categorie($db);
|
||||
$c->fetch($_REQUEST['id']);
|
||||
|
||||
$html = new Form($db);
|
||||
|
||||
if ($_GET["id"] || $_GET["ref"])
|
||||
{
|
||||
$c = new Categorie($db);
|
||||
|
||||
if ($_GET["id"]) $result = $c->fetch($_GET["id"]);
|
||||
|
||||
|
||||
if ($result)
|
||||
{
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/categories/viewcat.php?id='.$c->id.'&type='.$type;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/categories/photos.php?id='.$c->id.'&type='.$type;
|
||||
$head[$h][1] = $langs->trans("Photos");
|
||||
$head[$h][2] = 'photos';
|
||||
$h++;
|
||||
|
||||
if ($type == 0) $title=$langs->trans("ProductsCategoryShort");
|
||||
if ($type == 1) $title=$langs->trans("SuppliersCategoryShort");
|
||||
if ($type == 2) $title=$langs->trans("CustomersCategoryShort");
|
||||
|
||||
|
||||
$titre=$langs->trans("ProductsCategoryShort");
|
||||
dol_fiche_head($head, 'photos', $titre);
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression de photo
|
||||
*/
|
||||
if ($_GET['action'] == 'delete')
|
||||
{
|
||||
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$c->id.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1);
|
||||
if ($ret == 'html') print '<br>';
|
||||
}
|
||||
|
||||
print($mesg);
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Path of category
|
||||
print '<tr><td width="20%" class="notopnoleft">';
|
||||
$ways = $c->print_all_ways ();
|
||||
print $langs->trans("Ref").'</td><td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
|
||||
foreach ($ways as $way)
|
||||
{
|
||||
print $way."<br />\n";
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Description
|
||||
print '<tr><td width="20%" class="notopnoleft">';
|
||||
print $langs->trans("Description").'</td><td>';
|
||||
print nl2br($c->description);
|
||||
print '</td></tr>';
|
||||
|
||||
// Visibility
|
||||
if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
|
||||
{
|
||||
if ($c->socid)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($c->socid);
|
||||
|
||||
print '<tr><td width="20%" class="notopnoleft">';
|
||||
print $langs->trans("AssignedToTheCustomer").'</td><td>';
|
||||
print $soc->getNomUrl(1);
|
||||
print '</td></tr>';
|
||||
|
||||
$catsMeres = $c->get_meres ();
|
||||
|
||||
if ($catsMeres < 0)
|
||||
{
|
||||
dol_print_error();
|
||||
}
|
||||
else if (count($catsMeres) > 0)
|
||||
{
|
||||
print '<tr><td width="20%" class="notopnoleft">';
|
||||
print $langs->trans("CategoryContents").'</td><td>';
|
||||
print ($c->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
|
||||
print '</td></tr>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td width="20%" class="notopnoleft">';
|
||||
print $langs->trans("CategoryContents").'</td><td>';
|
||||
print ($c->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
|
||||
print '</td></tr>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td width="20%" class="notopnoleft">';
|
||||
print $langs->trans("CategoryContents").'</td><td>';
|
||||
print ($c->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Barre d'action */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
print "\n<div class=\"tabsAction\">\n";
|
||||
|
||||
if ($_GET["action"] != 'ajout_photo' && $user->rights->produit->creer)
|
||||
{
|
||||
if (! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/categories/photos.php?action=ajout_photo&id='.$c->id.'">';
|
||||
print $langs->trans("AddPhoto").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="#">e';
|
||||
print $langs->trans("AddPhoto").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print "\n</div>\n";
|
||||
|
||||
/*
|
||||
* Ajouter une photo
|
||||
*/
|
||||
if ($_GET["action"] == 'ajout_photo' && $user->rights->categorie->creer && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
// Affiche formulaire upload
|
||||
$formfile=new FormFile($db);
|
||||
$formfile->form_attach_new_file(DOL_URL_ROOT.'/categories/photos.php?id='.$c->id,$langs->trans("AddPhoto"),1);
|
||||
}
|
||||
|
||||
// Affiche photos
|
||||
// Affiche photos
|
||||
if ($_GET["action"] != 'ajout_photo')
|
||||
{
|
||||
$nbphoto=0;
|
||||
$nbbyrow=5;
|
||||
|
||||
$maxWidth = 160;
|
||||
$maxHeight = 120;
|
||||
|
||||
$pdir = get_exdir($c->id,2) . $c->id ."/photos/";
|
||||
$dir = $conf->categorie->dir_output.'/'.$pdir;
|
||||
|
||||
print '<br>';
|
||||
print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
|
||||
|
||||
foreach ($c->liste_photos($dir) as $key => $obj)
|
||||
{
|
||||
$nbphoto++;
|
||||
|
||||
|
||||
if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>';
|
||||
if ($nbbyrow) print '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
|
||||
|
||||
print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=categorie&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">';
|
||||
|
||||
// Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine
|
||||
if ($obj['photo_vignette'])
|
||||
{
|
||||
$filename='thumbs/'.$obj['photo_vignette'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$filename=$obj['photo'];
|
||||
}
|
||||
|
||||
// Nom affiche
|
||||
$viewfilename=$obj['photo'];
|
||||
|
||||
// Taille de l'image
|
||||
$c->get_image_size($dir.$filename);
|
||||
$imgWidth = ($c->imgWidth < $maxWidth) ? $c->imgWidth : $maxWidth;
|
||||
$imgHeight = ($c->imgHeight < $maxHeight) ? $c->imgHeight : $maxHeight;
|
||||
|
||||
print '<img border="0" width="'.$imgWidth.'" height="'.$imgHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=categorie&file='.urlencode($pdir.$filename).'">';
|
||||
|
||||
print '</a>';
|
||||
print '<br>'.$viewfilename;
|
||||
print '<br>';
|
||||
|
||||
// On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites
|
||||
if (!$obj['photo_vignette'] && eregi('(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$',$obj['photo']) && ($c->imgWidth > $maxWidth || $c->imgHeight > $maxHeight))
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=addthumb&file='.urlencode($pdir.$viewfilename).'">'.img_refresh($langs->trans('GenerateThumb')).' </a>';
|
||||
}
|
||||
if ($user->rights->categorie->creer)
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=delete&file='.urlencode($pdir.$viewfilename).'">';
|
||||
print img_delete().'</a>';
|
||||
}
|
||||
if ($nbbyrow) print '</td>';
|
||||
if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>';
|
||||
}
|
||||
|
||||
// Ferme tableau
|
||||
while ($nbphoto % $nbbyrow)
|
||||
{
|
||||
print '<td width="'.ceil(100/$nbbyrow).'%"> </td>';
|
||||
$nbphoto++;
|
||||
}
|
||||
|
||||
if ($nbphoto < 1)
|
||||
{
|
||||
print '<tr align=center valign=middle border=1><td class="photo">';
|
||||
print "<br>".$langs->trans("NoPhotoYet")."<br><br>";
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
@ -20,23 +20,23 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/categories/viewcat.php
|
||||
\ingroup category
|
||||
\brief Page de visualisation de categorie produit
|
||||
\version $Revision$
|
||||
*/
|
||||
* \file htdocs/categories/viewcat.php
|
||||
* \ingroup category
|
||||
* \brief Page de visualisation de categorie produit
|
||||
* \version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
|
||||
if ($_REQUEST['id'] == "")
|
||||
{
|
||||
dol_print_error('','Missing parameter id');
|
||||
exit();
|
||||
dol_print_error('','Missing parameter id');
|
||||
exit();
|
||||
}
|
||||
|
||||
$type=$_REQUEST['type'];
|
||||
|
||||
// Securite
|
||||
// Security check
|
||||
if (! $user->rights->categorie->lire)
|
||||
{
|
||||
accessforbidden();
|
||||
@ -50,8 +50,8 @@ $c->fetch($_REQUEST['id']);
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($user->rights->categorie->supprimer && $_POST["action"] == 'confirm_delete' && $_POST['confirm'] == 'yes')
|
||||
{
|
||||
@ -88,6 +88,11 @@ $head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/categories/photos.php?id='.$c->id.'&type='.$type;
|
||||
$head[$h][1] = $langs->trans("Photos");
|
||||
$head[$h][2] = 'photos';
|
||||
$h++;
|
||||
|
||||
if ($type == 0) $title=$langs->trans("ProductsCategoryShort");
|
||||
if ($type == 1) $title=$langs->trans("SuppliersCategoryShort");
|
||||
if ($type == 2) $title=$langs->trans("CustomersCategoryShort");
|
||||
@ -96,8 +101,8 @@ dol_fiche_head($head, 'card', $title);
|
||||
|
||||
|
||||
/*
|
||||
* Confirmation suppression
|
||||
*/
|
||||
* Confirmation suppression
|
||||
*/
|
||||
if ($_GET['action'] == 'delete')
|
||||
{
|
||||
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$c->id.'&type='.$type,$langs->trans('DeleteCategory'),$langs->trans('ConfirmDeleteCategory'),'confirm_delete');
|
||||
@ -106,22 +111,24 @@ if ($_GET['action'] == 'delete')
|
||||
|
||||
print '<table border="0" width="100%" class="border">';
|
||||
|
||||
// Path of category
|
||||
print '<tr><td width="20%" class="notopnoleft">';
|
||||
$ways = $c->print_all_ways ();
|
||||
print $langs->trans("Ref").'</td><td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
|
||||
foreach ($ways as $way)
|
||||
{
|
||||
print $way."<br />\n";
|
||||
print $way."<br />\n";
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Description
|
||||
print '<tr><td width="20%" class="notopnoleft">';
|
||||
print $langs->trans("Description").'</td><td>';
|
||||
print nl2br($c->description);
|
||||
print '</td></tr>';
|
||||
|
||||
// Visibility
|
||||
if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
|
||||
{
|
||||
if ($c->socid)
|
||||
@ -232,20 +239,20 @@ else
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
/*
|
||||
* Boutons actions
|
||||
*/
|
||||
if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
|
||||
{
|
||||
print "<div class='tabsAction'>\n";
|
||||
/*
|
||||
* Boutons actions
|
||||
*/
|
||||
if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
|
||||
{
|
||||
print "<div class='tabsAction'>\n";
|
||||
|
||||
if ($user->rights->categorie->creer)
|
||||
{
|
||||
print "<a class='butAction' href='fiche.php?action=create&catorigin=".$c->id."&socid=".$c->socid."&type=".$type."'>".$langs->trans("Create")."</a>";
|
||||
}
|
||||
if ($user->rights->categorie->creer)
|
||||
{
|
||||
print "<a class='butAction' href='fiche.php?action=create&catorigin=".$c->id."&socid=".$c->socid."&type=".$type."'>".$langs->trans("Create")."</a>";
|
||||
}
|
||||
|
||||
print "</div>";
|
||||
}
|
||||
print "</div>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -255,7 +262,7 @@ if ($c->type == 0)
|
||||
$prods = $c->get_type ("product","Product");
|
||||
if ($prods < 0)
|
||||
{
|
||||
dol_print_error();
|
||||
dol_print_error();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -274,7 +281,7 @@ if ($c->type == 0)
|
||||
print "\t<tr ".$bc[$var].">\n";
|
||||
print '<td nowrap="nowrap" valign="top">';
|
||||
if ($prod->type == 1) print img_object($langs->trans("ShowService"),"service");
|
||||
else print img_object($langs->trans("ShowProduct"),"product");
|
||||
else print img_object($langs->trans("ShowProduct"),"product");
|
||||
print " <a href='".DOL_URL_ROOT."/product/fiche.php?id=".$prod->id."'>".$prod->ref."</a></td>\n";
|
||||
print '<td valign="top">'.$prod->libelle."</td>\n";
|
||||
print '<td valign="top">'.$prod->description."</td>\n";
|
||||
@ -294,7 +301,7 @@ if ($c->type == 1)
|
||||
$socs = $c->get_type ("societe","Fournisseur","fournisseur");
|
||||
if ($socs < 0)
|
||||
{
|
||||
dol_print_error();
|
||||
dol_print_error();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -331,7 +338,7 @@ if($c->type == 2)
|
||||
$socs = $c->get_type ("societe","Societe");
|
||||
if ($socs < 0)
|
||||
{
|
||||
dol_print_error();
|
||||
dol_print_error();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -526,7 +526,7 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $
|
||||
print '</td>';
|
||||
|
||||
// Edit link
|
||||
print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docmine.php?section='.$val['id'].'">'.img_edit().'</a></td>';
|
||||
print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docmine.php?section='.$val['id'].'">'.img_view().'</a></td>';
|
||||
|
||||
// Add link
|
||||
//print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create&catParent='.$val['id'].'">'.img_edit_add().'</a></td>';
|
||||
|
||||
@ -2280,7 +2280,6 @@ class Product extends CommonObject
|
||||
|
||||
if (! file_exists($dir))
|
||||
{
|
||||
dol_syslog("Product Create $dir");
|
||||
create_exdir($dir);
|
||||
}
|
||||
|
||||
@ -2438,20 +2437,20 @@ class Product extends CommonObject
|
||||
// On continue ou on arrete de boucler ?
|
||||
if ($nbmax && $nbphoto >= $nbmax) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($nbbyrow && $size==1)
|
||||
{
|
||||
// Ferme tableau
|
||||
while ($nbphoto % $nbbyrow) {
|
||||
print '<td width="'.ceil(100/$nbbyrow).'%"> </td>';
|
||||
$nbphoto++;
|
||||
}
|
||||
if ($nbbyrow && $size==1)
|
||||
{
|
||||
// Ferme tableau
|
||||
while ($nbphoto % $nbbyrow) {
|
||||
print '<td width="'.ceil(100/$nbbyrow).'%"> </td>';
|
||||
$nbphoto++;
|
||||
}
|
||||
|
||||
if ($nbphoto) print '</table>';
|
||||
}
|
||||
if ($nbphoto) print '</table>';
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
return $nbphoto;
|
||||
@ -2532,12 +2531,12 @@ class Product extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Recupere la taille de l'image
|
||||
* \param file Chemin de l'image
|
||||
* \brief Load size of image file
|
||||
* \param file Path to file
|
||||
*/
|
||||
function get_image_size($file)
|
||||
{
|
||||
$infoImg = getimagesize($file); // R<EFBFBD>cup<EFBFBD>ration des infos de l'image
|
||||
$infoImg = getimagesize($file); // Get information on image
|
||||
$this->imgWidth = $infoImg[0]; // Largeur de l'image
|
||||
$this->imgHeight = $infoImg[1]; // Hauteur de l'image
|
||||
}
|
||||
|
||||
@ -57,11 +57,7 @@ if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global
|
||||
$product = new Product($db);
|
||||
$result = $product->fetch($_GET["id"]);
|
||||
|
||||
// if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],1) > 0)
|
||||
|
||||
// var_dump($_FILES);
|
||||
|
||||
$product->add_photo($conf->produit->dir_output, $_FILES['userfile']);
|
||||
$result = $product->add_photo($conf->produit->dir_output, $_FILES['userfile']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,7 +215,7 @@ if ($_GET["id"] || $_GET["ref"])
|
||||
$filename=$obj['photo'];
|
||||
}
|
||||
|
||||
// Nom affich<EFBFBD>
|
||||
// Nom affiche
|
||||
$viewfilename=$obj['photo'];
|
||||
|
||||
// Taille de l'image
|
||||
@ -233,7 +229,7 @@ if ($_GET["id"] || $_GET["ref"])
|
||||
print '<br>'.$viewfilename;
|
||||
print '<br>';
|
||||
|
||||
// On propose la g<EFBFBD>n<EFBFBD>ration de la vignette si elle n'existe pas et si la taille est sup<75>rieure aux limites
|
||||
// On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites
|
||||
if (!$obj['photo_vignette'] && eregi('(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$',$obj['photo']) && ($product->imgWidth > $maxWidth || $product->imgHeight > $maxHeight))
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=addthumb&file='.urlencode($pdir.$viewfilename).'">'.img_refresh($langs->trans('GenerateThumb')).' </a>';
|
||||
|
||||
@ -73,257 +73,268 @@ $original_file = str_replace("../","/", $original_file);
|
||||
$accessallowed=0;
|
||||
if ($modulepart)
|
||||
{
|
||||
// Check permissions and define directory
|
||||
// Check permissions and define directory
|
||||
|
||||
// Wrapping pour les photo utilisateurs
|
||||
if ($modulepart == 'companylogo')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->mycompany->dir_output.'/logos/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les photo utilisateurs
|
||||
if ($modulepart == 'companylogo')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->mycompany->dir_output.'/logos/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les photos utilisateurs
|
||||
elseif ($modulepart == 'userphoto')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->user->dir_output.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les photos utilisateurs
|
||||
elseif ($modulepart == 'userphoto')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->user->dir_output.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les photos adherents
|
||||
elseif ($modulepart == 'memberphoto')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->adherent->dir_output.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les photos adherents
|
||||
elseif ($modulepart == 'memberphoto')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->adherent->dir_output.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les apercu factures
|
||||
elseif ($modulepart == 'apercufacture')
|
||||
{
|
||||
$user->getrights('facture');
|
||||
if ($user->rights->facture->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->facture->dir_output.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les apercu factures
|
||||
elseif ($modulepart == 'apercufacture')
|
||||
{
|
||||
$user->getrights('facture');
|
||||
if ($user->rights->facture->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->facture->dir_output.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les apercu propal
|
||||
elseif ($modulepart == 'apercupropal')
|
||||
{
|
||||
$user->getrights('propale');
|
||||
if ($user->rights->propale->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->propale->dir_output.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les apercu propal
|
||||
elseif ($modulepart == 'apercupropal')
|
||||
{
|
||||
$user->getrights('propale');
|
||||
if ($user->rights->propale->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->propale->dir_output.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les apercu commande
|
||||
elseif ($modulepart == 'apercucommande')
|
||||
{
|
||||
$user->getrights('commande');
|
||||
if ($user->rights->commande->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->commande->dir_output.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les apercu commande
|
||||
elseif ($modulepart == 'apercucommande')
|
||||
{
|
||||
$user->getrights('commande');
|
||||
if ($user->rights->commande->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->commande->dir_output.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les apercu intervention
|
||||
elseif ($modulepart == 'apercufichinter')
|
||||
{
|
||||
$user->getrights('ficheinter');
|
||||
if ($user->rights->ficheinter->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->ficheinter->dir_output.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les apercu intervention
|
||||
elseif ($modulepart == 'apercufichinter')
|
||||
{
|
||||
$user->getrights('ficheinter');
|
||||
if ($user->rights->ficheinter->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->ficheinter->dir_output.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les images des stats propales
|
||||
elseif ($modulepart == 'propalstats')
|
||||
{
|
||||
$user->getrights('propale');
|
||||
if ($user->rights->propale->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->propale->dir_temp.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les images des stats propales
|
||||
elseif ($modulepart == 'propalstats')
|
||||
{
|
||||
$user->getrights('propale');
|
||||
if ($user->rights->propale->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->propale->dir_temp.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les images des stats commandes
|
||||
elseif ($modulepart == 'orderstats')
|
||||
{
|
||||
$user->getrights('commande');
|
||||
if ($user->rights->commande->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->commande->dir_temp.'/'.$original_file;
|
||||
}
|
||||
elseif ($modulepart == 'orderstatssupplier')
|
||||
{
|
||||
$user->getrights('fournisseur');
|
||||
if ($user->rights->fournisseur->commande->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->fournisseur->dir_output.'/commande/temp/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les images des stats commandes
|
||||
elseif ($modulepart == 'orderstats')
|
||||
{
|
||||
$user->getrights('commande');
|
||||
if ($user->rights->commande->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->commande->dir_temp.'/'.$original_file;
|
||||
}
|
||||
elseif ($modulepart == 'orderstatssupplier')
|
||||
{
|
||||
$user->getrights('fournisseur');
|
||||
if ($user->rights->fournisseur->commande->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->fournisseur->dir_output.'/commande/temp/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les images des stats factures
|
||||
elseif ($modulepart == 'billstats')
|
||||
{
|
||||
$user->getrights('facture');
|
||||
if ($user->rights->facture->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->facture->dir_temp.'/'.$original_file;
|
||||
}
|
||||
elseif ($modulepart == 'billstatssupplier')
|
||||
{
|
||||
$user->getrights('fourn');
|
||||
if ($user->rights->fournisseur->facture->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->fournisseur->dir_output.'/facture/temp/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les images des stats factures
|
||||
elseif ($modulepart == 'billstats')
|
||||
{
|
||||
$user->getrights('facture');
|
||||
if ($user->rights->facture->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->facture->dir_temp.'/'.$original_file;
|
||||
}
|
||||
elseif ($modulepart == 'billstatssupplier')
|
||||
{
|
||||
$user->getrights('fourn');
|
||||
if ($user->rights->fournisseur->facture->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->fournisseur->dir_output.'/facture/temp/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les images des stats expeditions
|
||||
elseif ($modulepart == 'expeditionstats')
|
||||
{
|
||||
$user->getrights('expedition');
|
||||
if ($user->rights->expedition->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->expedition->dir_temp.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les images des stats expeditions
|
||||
elseif ($modulepart == 'expeditionstats')
|
||||
{
|
||||
$user->getrights('expedition');
|
||||
if ($user->rights->expedition->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->expedition->dir_temp.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les images des stats produits
|
||||
elseif (eregi('^productstats_',$modulepart))
|
||||
{
|
||||
$user->getrights('produit');
|
||||
if ($user->rights->produit->lire || $user->rights->service->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->produit->dir_temp.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les images des stats produits
|
||||
elseif (eregi('^productstats_',$modulepart))
|
||||
{
|
||||
$user->getrights('produit');
|
||||
if ($user->rights->produit->lire || $user->rights->service->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->produit->dir_temp.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les produits
|
||||
elseif ($modulepart == 'product')
|
||||
{
|
||||
$user->getrights('produit');
|
||||
if ($user->rights->produit->lire || $user->rights->service->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->produit->dir_output.'/'.$original_file;
|
||||
}
|
||||
// Wrapping for products or services
|
||||
elseif ($modulepart == 'product')
|
||||
{
|
||||
$user->getrights('produit');
|
||||
if ($user->rights->produit->lire || $user->rights->service->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->produit->dir_output.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les prelevements
|
||||
elseif ($modulepart == 'prelevement')
|
||||
{
|
||||
$user->getrights('prelevement');
|
||||
if ($user->rights->prelevement->bons->lire) $accessallowed=1;
|
||||
// Wrapping for categories
|
||||
elseif ($modulepart == 'category')
|
||||
{
|
||||
$user->getrights('categorie');
|
||||
if ($user->rights->categorie->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->categorie->dir_output.'/'.$original_file;
|
||||
}
|
||||
|
||||
$original_file=$conf->prelevement->dir_output.'/receipts/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les prelevements
|
||||
elseif ($modulepart == 'prelevement')
|
||||
{
|
||||
$user->getrights('prelevement');
|
||||
if ($user->rights->prelevement->bons->lire) $accessallowed=1;
|
||||
|
||||
// Wrapping pour les graph telephonie
|
||||
elseif ($modulepart == 'telephoniegraph')
|
||||
{
|
||||
$user->getrights('telephonie');
|
||||
if ($user->rights->telephonie->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->telephonie->dir_temp.'/'.$original_file;
|
||||
}
|
||||
$original_file=$conf->prelevement->dir_output.'/receipts/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les graph energie
|
||||
elseif ($modulepart == 'energie')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->energie->dir_temp.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les graph telephonie
|
||||
elseif ($modulepart == 'telephoniegraph')
|
||||
{
|
||||
$user->getrights('telephonie');
|
||||
if ($user->rights->telephonie->lire)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->telephonie->dir_temp.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les graph bank
|
||||
elseif ($modulepart == 'bank')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->banque->dir_temp.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les graph energie
|
||||
elseif ($modulepart == 'energie')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->energie->dir_temp.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les images wysiwyg
|
||||
elseif ($modulepart == 'fckeditor')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->fckeditor->dir_output.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les graph bank
|
||||
elseif ($modulepart == 'bank')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->banque->dir_temp.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les images wysiwyg mailing
|
||||
elseif ($modulepart == 'mailing')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->mailing->dir_output.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les images wysiwyg
|
||||
elseif ($modulepart == 'fckeditor')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->fckeditor->dir_output.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les graph energie
|
||||
elseif ($modulepart == 'graph_stock')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->stock->dir_temp.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les images wysiwyg mailing
|
||||
elseif ($modulepart == 'mailing')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->mailing->dir_output.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les graph fournisseurs
|
||||
elseif ($modulepart == 'graph_fourn')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->fournisseur->dir_temp.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les graph energie
|
||||
elseif ($modulepart == 'graph_stock')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->stock->dir_temp.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les graph des produits
|
||||
elseif ($modulepart == 'graph_product')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->produit->dir_temp.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les graph fournisseurs
|
||||
elseif ($modulepart == 'graph_fourn')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->fournisseur->dir_temp.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les code barre
|
||||
elseif ($modulepart == 'barcode')
|
||||
{
|
||||
$accessallowed=1;
|
||||
// Wrapping pour les graph des produits
|
||||
elseif ($modulepart == 'graph_product')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->produit->dir_temp.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping pour les code barre
|
||||
elseif ($modulepart == 'barcode')
|
||||
{
|
||||
$accessallowed=1;
|
||||
// If viewimage is called for barcode, we try to output an image on the fly,
|
||||
// with not build of file on disk.
|
||||
//$original_file=$conf->barcode->dir_temp.'/'.$original_file;
|
||||
$original_file='';
|
||||
}
|
||||
//$original_file=$conf->barcode->dir_temp.'/'.$original_file;
|
||||
$original_file='';
|
||||
}
|
||||
|
||||
// Wrapping pour les icones de background des mailings
|
||||
elseif ($modulepart == 'iconmailing')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->mailing->dir_temp.'/'.$original_file;
|
||||
}
|
||||
// Wrapping pour les icones de background des mailings
|
||||
elseif ($modulepart == 'iconmailing')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=$conf->mailing->dir_temp.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping generique (allows any module to open a file if file is in directory
|
||||
// called DOL_DATA_ROOT/modulepart).
|
||||
else
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=DOL_DATA_ROOT.'/'.$modulepart.'/'.$original_file;
|
||||
}
|
||||
// Wrapping generique (allows any module to open a file if file is in directory
|
||||
// called DOL_DATA_ROOT/modulepart).
|
||||
else
|
||||
{
|
||||
$accessallowed=1;
|
||||
$original_file=DOL_DATA_ROOT.'/'.$modulepart.'/'.$original_file;
|
||||
}
|
||||
}
|
||||
|
||||
// Security:
|
||||
// Limit access if permissions are wrong
|
||||
if (! $accessallowed)
|
||||
{
|
||||
accessforbidden();
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Security:
|
||||
@ -383,11 +394,11 @@ else
|
||||
// Les drois sont ok et fichier trouve
|
||||
if ($type)
|
||||
{
|
||||
header('Content-type: '.$type);
|
||||
header('Content-type: '.$type);
|
||||
}
|
||||
else
|
||||
{
|
||||
header('Content-type: image/png');
|
||||
header('Content-type: image/png');
|
||||
}
|
||||
|
||||
readfile($original_file);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user