Fix: multicompany sharings and uniformize code
This commit is contained in:
parent
13624eeb86
commit
921c8607d7
@ -73,7 +73,7 @@ class Categorie
|
|||||||
*/
|
*/
|
||||||
function fetch($id)
|
function fetch($id)
|
||||||
{
|
{
|
||||||
$sql = "SELECT rowid, label, description, fk_soc, visible, type";
|
$sql = "SELECT rowid, entity, label, description, fk_soc, visible, type";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
|
$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
|
||||||
$sql.= " WHERE rowid = ".$id;
|
$sql.= " WHERE rowid = ".$id;
|
||||||
|
|
||||||
@ -83,12 +83,13 @@ class Categorie
|
|||||||
{
|
{
|
||||||
$res = $this->db->fetch_array($resql);
|
$res = $this->db->fetch_array($resql);
|
||||||
|
|
||||||
$this->id = $res['rowid'];
|
$this->id = $res['rowid'];
|
||||||
$this->label = $res['label'];
|
$this->label = $res['label'];
|
||||||
$this->description = $res['description'];
|
$this->description = $res['description'];
|
||||||
$this->socid = $res['fk_soc'];
|
$this->socid = $res['fk_soc'];
|
||||||
$this->visible = $res['visible'];
|
$this->visible = $res['visible'];
|
||||||
$this->type = $res['type'];
|
$this->type = $res['type'];
|
||||||
|
$this->entity = $res['entity'];
|
||||||
|
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
}
|
}
|
||||||
@ -1284,6 +1285,8 @@ class Categorie
|
|||||||
*/
|
*/
|
||||||
function liste_photos($dir,$nbmax=0)
|
function liste_photos($dir,$nbmax=0)
|
||||||
{
|
{
|
||||||
|
include_once(DOL_DOCUMENT_ROOT ."/core/lib/files.lib.php");
|
||||||
|
|
||||||
$nbphoto=0;
|
$nbphoto=0;
|
||||||
$tabobj=array();
|
$tabobj=array();
|
||||||
|
|
||||||
@ -1296,7 +1299,7 @@ class Categorie
|
|||||||
{
|
{
|
||||||
while (($file = readdir($handle)) != false)
|
while (($file = readdir($handle)) != false)
|
||||||
{
|
{
|
||||||
if (is_file($dir.$file))
|
if (dol_is_file($dir.$file) && preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$dir.$file))
|
||||||
{
|
{
|
||||||
$nbphoto++;
|
$nbphoto++;
|
||||||
$photo = $file;
|
$photo = $file;
|
||||||
|
|||||||
@ -51,6 +51,13 @@ if ($id == "")
|
|||||||
$result = restrictedArea($user, 'categorie', $id, '&category');
|
$result = restrictedArea($user, 'categorie', $id, '&category');
|
||||||
|
|
||||||
$object = new Categorie($db);
|
$object = new Categorie($db);
|
||||||
|
if ($id > 0)
|
||||||
|
{
|
||||||
|
$result = $object->fetch($id);
|
||||||
|
|
||||||
|
$upload_dir = $conf->categorie->multidir_output[$object->entity];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
@ -58,22 +65,17 @@ $object = new Categorie($db);
|
|||||||
|
|
||||||
if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||||
{
|
{
|
||||||
if ($id)
|
if ($object->id) $result = $object->add_photo($upload_dir, $_FILES['userfile']);
|
||||||
{
|
|
||||||
$result = $object->fetch($id);
|
|
||||||
|
|
||||||
$result = $object->add_photo($conf->categorie->dir_output, $_FILES['userfile']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && $user->rights->categorie->creer)
|
if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && $user->rights->categorie->creer)
|
||||||
{
|
{
|
||||||
$object->delete_photo($conf->categorie->dir_output."/".$_GET["file"]);
|
$object->delete_photo($upload_dir."/".$_GET["file"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'addthumb' && $_GET["file"])
|
if ($action == 'addthumb' && $_GET["file"])
|
||||||
{
|
{
|
||||||
$object->add_thumb($conf->categorie->dir_output."/".$_GET["file"]);
|
$object->add_thumb($upload_dir."/".$_GET["file"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -85,215 +87,210 @@ llxHeader("","",$langs->trans("Categories"));
|
|||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
if (!empty($id) || !empty($ref))
|
if ($object->id)
|
||||||
{
|
{
|
||||||
$result = $object->fetch($id);
|
$title=$langs->trans("ProductsCategoryShort");
|
||||||
|
if ($type == 0) $title=$langs->trans("ProductsCategoryShort");
|
||||||
|
elseif ($type == 1) $title=$langs->trans("SuppliersCategoryShort");
|
||||||
|
elseif ($type == 2) $title=$langs->trans("CustomersCategoryShort");
|
||||||
|
elseif ($type == 3) $title=$langs->trans("MembersCategoryShort");
|
||||||
|
|
||||||
if ($result)
|
$head = categories_prepare_head($object,$type);
|
||||||
{
|
dol_fiche_head($head, 'photos', $title, 0, 'category');
|
||||||
$title=$langs->trans("ProductsCategoryShort");
|
|
||||||
if ($type == 0) $title=$langs->trans("ProductsCategoryShort");
|
|
||||||
elseif ($type == 1) $title=$langs->trans("SuppliersCategoryShort");
|
|
||||||
elseif ($type == 2) $title=$langs->trans("CustomersCategoryShort");
|
|
||||||
elseif ($type == 3) $title=$langs->trans("MembersCategoryShort");
|
|
||||||
|
|
||||||
$head = categories_prepare_head($object,$type);
|
/*
|
||||||
dol_fiche_head($head, 'photos', $title, 0, 'category');
|
* Confirmation de la suppression de photo
|
||||||
|
*/
|
||||||
|
if ($action == 'delete')
|
||||||
|
{
|
||||||
|
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1);
|
||||||
|
if ($ret == 'html') print '<br>';
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
print($mesg);
|
||||||
* Confirmation de la suppression de photo
|
|
||||||
*/
|
|
||||||
if ($action == 'delete')
|
|
||||||
{
|
|
||||||
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&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%">';
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
// Path of category
|
||||||
|
print '<tr><td width="20%" class="notopnoleft">';
|
||||||
|
$ways = $object->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>';
|
||||||
|
|
||||||
// Path of category
|
// Description
|
||||||
print '<tr><td width="20%" class="notopnoleft">';
|
print '<tr><td width="20%" class="notopnoleft">';
|
||||||
$ways = $object->print_all_ways();
|
print $langs->trans("Description").'</td><td>';
|
||||||
print $langs->trans("Ref").'</td><td>';
|
print nl2br($object->description);
|
||||||
print '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
|
print '</td></tr>';
|
||||||
foreach ($ways as $way)
|
|
||||||
{
|
|
||||||
print $way."<br>\n";
|
|
||||||
}
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Description
|
// Visibility
|
||||||
print '<tr><td width="20%" class="notopnoleft">';
|
/* if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
|
||||||
print $langs->trans("Description").'</td><td>';
|
{
|
||||||
print nl2br($object->description);
|
if ($object->socid)
|
||||||
print '</td></tr>';
|
{
|
||||||
|
$soc = new Societe($db);
|
||||||
|
$soc->fetch($object->socid);
|
||||||
|
|
||||||
// Visibility
|
print '<tr><td width="20%" class="notopnoleft">';
|
||||||
/* if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
|
print $langs->trans("AssignedToTheCustomer").'</td><td>';
|
||||||
{
|
print $soc->getNomUrl(1);
|
||||||
if ($object->socid)
|
print '</td></tr>';
|
||||||
{
|
|
||||||
$soc = new Societe($db);
|
|
||||||
$soc->fetch($object->socid);
|
|
||||||
|
|
||||||
print '<tr><td width="20%" class="notopnoleft">';
|
$catsMeres = $object->get_meres ();
|
||||||
print $langs->trans("AssignedToTheCustomer").'</td><td>';
|
|
||||||
print $soc->getNomUrl(1);
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
$catsMeres = $object->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 ($object->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 ($object->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 ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if ($catsMeres < 0)
|
print "</table>\n";
|
||||||
{
|
|
||||||
dol_print_error();
|
|
||||||
}
|
|
||||||
else if (count($catsMeres) > 0)
|
|
||||||
{
|
|
||||||
print '<tr><td width="20%" class="notopnoleft">';
|
|
||||||
print $langs->trans("CategoryContents").'</td><td>';
|
|
||||||
print ($object->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 ($object->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 ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
|
|
||||||
print '</td></tr>';
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
print "</table>\n";
|
print "</div>\n";
|
||||||
|
|
||||||
print "</div>\n";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* Barre d'action */
|
/* Barre d'action */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
print "\n<div class=\"tabsAction\">\n";
|
print "\n<div class=\"tabsAction\">\n";
|
||||||
|
|
||||||
if ($action != 'ajout_photo' && $user->rights->produit->creer)
|
if ($action != 'ajout_photo' && $user->rights->categorie->creer)
|
||||||
{
|
{
|
||||||
if (! empty($conf->global->MAIN_UPLOAD_DOC))
|
if (! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/categories/photos.php?action=ajout_photo&id='.$object->id.'&type='.$type.'">';
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=ajout_photo&id='.$object->id.'&type='.$type.'">';
|
||||||
print $langs->trans("AddPhoto").'</a>';
|
print $langs->trans("AddPhoto").'</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<a class="butActionRefused" href="#">';
|
print '<a class="butActionRefused" href="#">';
|
||||||
print $langs->trans("AddPhoto").'</a>';
|
print $langs->trans("AddPhoto").'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\n</div>\n";
|
print "\n</div>\n";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ajouter une photo
|
* Ajouter une photo
|
||||||
*/
|
*/
|
||||||
if ($action == 'ajout_photo' && $user->rights->categorie->creer && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
if ($action == 'ajout_photo' && $user->rights->categorie->creer && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||||
{
|
{
|
||||||
// Affiche formulaire upload
|
// Affiche formulaire upload
|
||||||
$formfile=new FormFile($db);
|
$formfile=new FormFile($db);
|
||||||
$formfile->form_attach_new_file(DOL_URL_ROOT.'/categories/photos.php?id='.$object->id.'&type='.$type,$langs->trans("AddPhoto"),1);
|
$formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id.'&type='.$type,$langs->trans("AddPhoto"),1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affiche photos
|
// Affiche photos
|
||||||
if ($action != 'ajout_photo')
|
if ($action != 'ajout_photo')
|
||||||
{
|
{
|
||||||
$nbphoto=0;
|
$nbphoto=0;
|
||||||
$nbbyrow=5;
|
$nbbyrow=5;
|
||||||
|
|
||||||
$maxWidth = 160;
|
$maxWidth = 160;
|
||||||
$maxHeight = 120;
|
$maxHeight = 120;
|
||||||
|
|
||||||
$pdir = get_exdir($object->id,2) . $object->id ."/photos/";
|
$pdir = get_exdir($object->id,2) . $object->id ."/photos/";
|
||||||
$dir = $conf->categorie->dir_output.'/'.$pdir;
|
$dir = $upload_dir.'/'.$pdir;
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
|
print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
|
||||||
|
|
||||||
foreach ($object->liste_photos($dir) as $key => $obj)
|
foreach ($object->liste_photos($dir) as $key => $obj)
|
||||||
{
|
{
|
||||||
$nbphoto++;
|
$nbphoto++;
|
||||||
|
|
||||||
|
|
||||||
if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>';
|
if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>';
|
||||||
if ($nbbyrow) print '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
|
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">';
|
print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">';
|
||||||
|
|
||||||
// Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine
|
// Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine
|
||||||
if ($obj['photo_vignette'])
|
if ($obj['photo_vignette'])
|
||||||
{
|
{
|
||||||
$filename='thumbs/'.$obj['photo_vignette'];
|
$filename='thumbs/'.$obj['photo_vignette'];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$filename=$obj['photo'];
|
$filename=$obj['photo'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nom affiche
|
// Nom affiche
|
||||||
$viewfilename=$obj['photo'];
|
$viewfilename=$obj['photo'];
|
||||||
|
|
||||||
// Taille de l'image
|
// Taille de l'image
|
||||||
$object->get_image_size($dir.$filename);
|
$object->get_image_size($dir.$filename);
|
||||||
$imgWidth = ($object->imgWidth < $maxWidth) ? $object->imgWidth : $maxWidth;
|
$imgWidth = ($object->imgWidth < $maxWidth) ? $object->imgWidth : $maxWidth;
|
||||||
$imgHeight = ($object->imgHeight < $maxHeight) ? $object->imgHeight : $maxHeight;
|
$imgHeight = ($object->imgHeight < $maxHeight) ? $object->imgHeight : $maxHeight;
|
||||||
|
|
||||||
print '<img border="0" width="'.$imgWidth.'" height="'.$imgHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=categorie&file='.urlencode($pdir.$filename).'">';
|
print '<img border="0" width="'.$imgWidth.'" height="'.$imgHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$filename).'">';
|
||||||
|
|
||||||
print '</a>';
|
print '</a>';
|
||||||
print '<br>'.$viewfilename;
|
print '<br>'.$viewfilename;
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
// On propose la generation de la vignette si elle n'existe pas et si la taille est superieure 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'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i',$obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight))
|
if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i',$obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight))
|
||||||
{
|
{
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=addthumb&type='.$type.'&file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').' </a>';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->entity.'&action=addthumb&type='.$type.'&file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').' </a>';
|
||||||
}
|
}
|
||||||
if ($user->rights->categorie->creer)
|
if ($user->rights->categorie->creer)
|
||||||
{
|
{
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=delete&type='.$type.'&file='.urlencode($pdir.$viewfilename).'">';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->entity.'&action=delete&type='.$type.'&file='.urlencode($pdir.$viewfilename).'">';
|
||||||
print img_delete().'</a>';
|
print img_delete().'</a>';
|
||||||
}
|
}
|
||||||
if ($nbbyrow) print '</td>';
|
if ($nbbyrow) print '</td>';
|
||||||
if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>';
|
if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ferme tableau
|
// Ferme tableau
|
||||||
while ($nbphoto % $nbbyrow)
|
while ($nbphoto % $nbbyrow)
|
||||||
{
|
{
|
||||||
print '<td width="'.ceil(100/$nbbyrow).'%"> </td>';
|
print '<td width="'.ceil(100/$nbbyrow).'%"> </td>';
|
||||||
$nbphoto++;
|
$nbphoto++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($nbphoto < 1)
|
if ($nbphoto < 1)
|
||||||
{
|
{
|
||||||
print '<tr align=center valign=middle border=1><td class="photo">';
|
print '<tr align=center valign=middle border=1><td class="photo">';
|
||||||
print "<br>".$langs->trans("NoPhotoYet")."<br><br>";
|
print "<br>".$langs->trans("NoPhotoYet")."<br><br>";
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -301,8 +298,6 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
$db->close();
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -265,10 +265,6 @@ class Conf
|
|||||||
$rootfordata.='/'.$this->entity;
|
$rootfordata.='/'.$this->entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For backward compatibility
|
|
||||||
// TODO Replace this->xxx->enabled by this->modulename->enabled to remove this code
|
|
||||||
if (isset($this->categorie->enabled)) $this->category->enabled=$this->categorie->enabled;
|
|
||||||
|
|
||||||
// Define default dir_output and dir_temp for directories of modules
|
// Define default dir_output and dir_temp for directories of modules
|
||||||
foreach($this->modules as $module)
|
foreach($this->modules as $module)
|
||||||
{
|
{
|
||||||
@ -422,6 +418,7 @@ class Conf
|
|||||||
$this->invoice=$this->facture;
|
$this->invoice=$this->facture;
|
||||||
$this->order=$this->commande;
|
$this->order=$this->commande;
|
||||||
$this->contract=$this->contrat;
|
$this->contract=$this->contrat;
|
||||||
|
$this->category=$this->categorie;
|
||||||
|
|
||||||
|
|
||||||
// Define menu manager in setup
|
// Define menu manager in setup
|
||||||
|
|||||||
@ -220,14 +220,14 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
|||||||
//print "file=".$file;
|
//print "file=".$file;
|
||||||
//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
|
//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
|
||||||
|
|
||||||
dol_mkdir($conf->societe->dir_temp);
|
dol_mkdir($conf->societe->multidir_temp[$object->entity]);
|
||||||
|
|
||||||
// Open and load template
|
// Open and load template
|
||||||
require_once(ODTPHP_PATH.'odf.php');
|
require_once(ODTPHP_PATH.'odf.php');
|
||||||
$odfHandler = new odf(
|
$odfHandler = new odf(
|
||||||
$srctemplatepath,
|
$srctemplatepath,
|
||||||
array(
|
array(
|
||||||
'PATH_TO_TMP' => $conf->societe->dir_temp,
|
'PATH_TO_TMP' => $conf->societe->multidir_temp[$object->entity],
|
||||||
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
|
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
|
||||||
'DELIMITER_LEFT' => '{',
|
'DELIMITER_LEFT' => '{',
|
||||||
'DELIMITER_RIGHT' => '}'
|
'DELIMITER_RIGHT' => '}'
|
||||||
|
|||||||
@ -50,10 +50,11 @@ require("./main.inc.php"); // Load $user and permissions
|
|||||||
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
|
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
|
||||||
|
|
||||||
$encoding = '';
|
$encoding = '';
|
||||||
$action = GETPOST('action','alpha');
|
$action=GETPOST('action','alpha');
|
||||||
$original_file = GETPOST('file','alpha'); // Do not use urldecode here ($_GET are already decoded by PHP).
|
$original_file=GETPOST('file','alpha'); // Do not use urldecode here ($_GET are already decoded by PHP).
|
||||||
$modulepart = GETPOST('modulepart','alpha');
|
$modulepart=GETPOST('modulepart','alpha');
|
||||||
$urlsource = GETPOST('urlsource','alpha');
|
$urlsource=GETPOST('urlsource','alpha');
|
||||||
|
$entity=GETPOST('entity','int');
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart');
|
if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart');
|
||||||
@ -130,8 +131,8 @@ if ($modulepart)
|
|||||||
{
|
{
|
||||||
$accessallowed=1;
|
$accessallowed=1;
|
||||||
}
|
}
|
||||||
$original_file=$conf->societe->multidir_output[GETPOST('entity','int')].'/'.$original_file;
|
$original_file=$conf->societe->multidir_output[$entity].'/'.$original_file;
|
||||||
$sqlprotectagainstexternals = "SELECT rowid as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE rowid='".$refname."' AND entity=".$conf->entity;
|
$sqlprotectagainstexternals = "SELECT rowid as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE rowid='".$refname."' AND entity IN (".getEntity('societe', 1).")";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrapping for invoices
|
// Wrapping for invoices
|
||||||
@ -299,8 +300,8 @@ if ($modulepart)
|
|||||||
{
|
{
|
||||||
$accessallowed=1;
|
$accessallowed=1;
|
||||||
}
|
}
|
||||||
if ($conf->product->enabled) $original_file=$conf->product->multidir_output[GETPOST('entity','int')].'/'.$original_file;
|
if ($conf->product->enabled) $original_file=$conf->product->multidir_output[$entity].'/'.$original_file;
|
||||||
elseif ($conf->service->enabled) $original_file=$conf->service->multidir_output[GETPOST('entity','int')].'/'.$original_file;
|
elseif ($conf->service->enabled) $original_file=$conf->service->multidir_output[$entity].'/'.$original_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrapping pour les contrats
|
// Wrapping pour les contrats
|
||||||
|
|||||||
@ -48,10 +48,11 @@ require("./main.inc.php");
|
|||||||
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
|
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
|
||||||
|
|
||||||
|
|
||||||
$action = GETPOST('action','alpha');
|
$action=GETPOST('action','alpha');
|
||||||
$original_file = GETPOST("file");
|
$original_file=GETPOST("file");
|
||||||
$modulepart = GETPOST('modulepart','alpha');
|
$modulepart=GETPOST('modulepart','alpha');
|
||||||
$urlsource = GETPOST("urlsource");
|
$urlsource=GETPOST("urlsource");
|
||||||
|
$entity=GETPOST('entity','int');
|
||||||
|
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
@ -121,7 +122,7 @@ if ($modulepart)
|
|||||||
elseif ($modulepart == 'societe')
|
elseif ($modulepart == 'societe')
|
||||||
{
|
{
|
||||||
$accessallowed=1;
|
$accessallowed=1;
|
||||||
$original_file=$conf->societe->multidir_output[GETPOST('entity','int')].'/'.$original_file;
|
$original_file=$conf->societe->multidir_output[$entity].'/'.$original_file;
|
||||||
}
|
}
|
||||||
// Wrapping pour les apercu factures
|
// Wrapping pour les apercu factures
|
||||||
elseif ($modulepart == 'apercufacture')
|
elseif ($modulepart == 'apercufacture')
|
||||||
@ -197,13 +198,13 @@ if ($modulepart)
|
|||||||
elseif (preg_match('/^productstats_/i',$modulepart))
|
elseif (preg_match('/^productstats_/i',$modulepart))
|
||||||
{
|
{
|
||||||
if ($user->rights->produit->lire || $user->rights->service->lire) $accessallowed=1;
|
if ($user->rights->produit->lire || $user->rights->service->lire) $accessallowed=1;
|
||||||
$original_file=(!empty($conf->product->multidir_temp[GETPOST('entity','int')])?$conf->product->multidir_temp[GETPOST('entity','int')]:$conf->service->multidir_temp[GETPOST('entity','int')]).'/'.$original_file;
|
$original_file=(!empty($conf->product->multidir_temp[$entity])?$conf->product->multidir_temp[$entity]:$conf->service->multidir_temp[$entity]).'/'.$original_file;
|
||||||
}
|
}
|
||||||
// Wrapping for products or services
|
// Wrapping for products or services
|
||||||
elseif ($modulepart == 'product')
|
elseif ($modulepart == 'product')
|
||||||
{
|
{
|
||||||
if ($user->rights->produit->lire || $user->rights->service->lire) $accessallowed=1;
|
if ($user->rights->produit->lire || $user->rights->service->lire) $accessallowed=1;
|
||||||
$original_file=(! empty($conf->product->multidir_output[GETPOST('entity','int')])?$conf->product->multidir_output[GETPOST('entity','int')]:$conf->service->multidir_output[GETPOST('entity','int')]).'/'.$original_file;
|
$original_file=(! empty($conf->product->multidir_output[$entity])?$conf->product->multidir_output[$entity]:$conf->service->multidir_output[$entity]).'/'.$original_file;
|
||||||
}
|
}
|
||||||
// Wrapping for products or services
|
// Wrapping for products or services
|
||||||
elseif ($modulepart == 'tax')
|
elseif ($modulepart == 'tax')
|
||||||
@ -215,7 +216,7 @@ if ($modulepart)
|
|||||||
elseif ($modulepart == 'category')
|
elseif ($modulepart == 'category')
|
||||||
{
|
{
|
||||||
if ($user->rights->categorie->lire) $accessallowed=1;
|
if ($user->rights->categorie->lire) $accessallowed=1;
|
||||||
$original_file=$conf->categorie->dir_output.'/'.$original_file;
|
$original_file=$conf->categorie->multidir_output[$entity].'/'.$original_file;
|
||||||
}
|
}
|
||||||
// Wrapping pour les prelevements
|
// Wrapping pour les prelevements
|
||||||
elseif ($modulepart == 'prelevement')
|
elseif ($modulepart == 'prelevement')
|
||||||
@ -239,7 +240,7 @@ if ($modulepart)
|
|||||||
elseif ($modulepart == 'graph_product')
|
elseif ($modulepart == 'graph_product')
|
||||||
{
|
{
|
||||||
$accessallowed=1;
|
$accessallowed=1;
|
||||||
$original_file=$conf->product->multidir_temp[GETPOST('entity','int')].'/'.$original_file;
|
$original_file=$conf->product->multidir_temp[$entity].'/'.$original_file;
|
||||||
}
|
}
|
||||||
// Wrapping pour les code barre
|
// Wrapping pour les code barre
|
||||||
elseif ($modulepart == 'barcode')
|
elseif ($modulepart == 'barcode')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user