+ *
+ * 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, see .
+ */
+
+/**
+ * \file htdocs/compta/sociales/document.php
+ * \ingroup tax
+ * \brief Page with attached files on social contributions
+ */
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/compta/sociales/class/chargesociales.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/tax.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
+
+$langs->load("other");
+$langs->load("companies");
+$langs->load("compta");
+$langs->load("bills");
+
+$id = GETPOST("id");
+$action = GETPOST("action");
+
+// Security check
+if ($user->societe_id) $socid=$user->societe_id;
+$result = restrictedArea($user, 'tax', $id, 'chargesociales','charges');
+
+
+// Get parameters
+$sortfield = GETPOST("sortfield",'alpha');
+$sortorder = GETPOST("sortorder",'alpha');
+$page = GETPOST("page",'int');
+if ($page == -1) { $page = 0; }
+$offset = $conf->liste_limit * $page;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+if (! $sortorder) $sortorder="ASC";
+if (! $sortfield) $sortfield="name";
+
+
+$object = new ChargeSociales($db);
+$object->fetch($id);
+
+$upload_dir = $conf->tax->dir_output.'/'.dol_sanitizeFileName($object->ref);
+$modulepart='tax';
+
+
+/*
+ * Actions
+ */
+
+if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
+{
+ require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
+
+ if (create_exdir($upload_dir) >= 0)
+ {
+ $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
+ if (is_numeric($resupload) && $resupload > 0)
+ {
+ if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1)
+ {
+ // Create small thumbs for company (Ratio is near 16/9)
+ // Used on logon for example
+ $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs");
+
+ // Create mini thumbs for company (Ratio is near 16/9)
+ // Used on menu or for setup page for example
+ $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs");
+ }
+ $mesg = ''.$langs->trans("FileTransferComplete").'
';
+ }
+ else
+ {
+ $langs->load("errors");
+ if ($resupload < 0) // Unknown error
+ {
+ $mesg = ''.$langs->trans("ErrorFileNotUploaded").'
';
+ }
+ else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
+ {
+ $mesg = ''.$langs->trans("ErrorFileIsInfectedWithAVirus").'
';
+ }
+ else // Known error
+ {
+ $mesg = ''.$langs->trans($resupload).'
';
+ }
+ }
+ }
+}
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+
+$help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)';
+llxHeader("",$langs->trans("SocialContribution"),$help_url);
+
+if ($object->id)
+{
+ if ( $error_msg )
+ {
+ echo ''.$error_msg.'
';
+ }
+
+ if ($action == 'delete')
+ {
+ $file = $upload_dir . '/' . GETPOST("urlfile"); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
+ $result=dol_delete_file($file);
+ //if ($result >= 0) $mesg=$langs->trans("FileWasRemoced");
+ }
+
+ $head=tax_prepare_head($object, $user);
+
+ dol_fiche_head($head, 'documents', $langs->trans("SocialContribution"), 0, 'bill');
+
+
+ // Construit liste des fichiers
+ $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
+ $totalsize=0;
+ foreach($filearray as $key => $file)
+ {
+ $totalsize+=$file['size'];
+ }
+
+
+ print '';
+
+ // Ref
+ print '| '.$langs->trans("Ref").' | '.$object->ref.' |
';
+
+ print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print '
';
+
+ print '';
+
+
+ // Affiche formulaire upload
+ $formfile=new FormFile($db);
+ $formfile->form_attach_new_file(DOL_URL_ROOT.'/compta/sociales/document.php?id='.$object->id,'',0,0,$user->rights->tax->charges->creer);
+
+
+ // List of document
+ //$param='&id='.$object->id;
+ $formfile->list_of_documents($filearray,$object,'tax',$param);
+
+}
+else
+{
+ print $langs->trans("UnkownError");
+}
+
+
+llxFooter();
+
+$db->close();
+?>
diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php
index b088cdd3d42..dc2be6baf2b 100644
--- a/htdocs/core/lib/tax.lib.php
+++ b/htdocs/core/lib/tax.lib.php
@@ -48,6 +48,11 @@ function tax_prepare_head($object)
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'tax');
+ $head[$h][0] = DOL_URL_ROOT.'/compta/sociales/document.php?id='.$object->id;
+ $head[$h][1] = $langs->trans("Documents");
+ $head[$h][2] = 'documents';
+ $h++;
+
$head[$h][0] = DOL_URL_ROOT.'/compta/sociales/info.php?id='.$object->id;
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php
index 6d69c65dcdf..a9a39cc30b1 100644
--- a/htdocs/fichinter/document.php
+++ b/htdocs/fichinter/document.php
@@ -29,6 +29,7 @@
require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/fichinter/class/fichinter.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/fichinter.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
@@ -37,12 +38,12 @@ $langs->load("fichinter");
$langs->load("companies");
$langs->load("interventions");
-$fichinterid = GETPOST("id");
+$id = GETPOST("id");
$action = GETPOST("action");
// Security check
if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter');
+$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
// Get parameters
@@ -58,15 +59,16 @@ if (! $sortfield) $sortfield="name";
$object = new Fichinter($db);
-$object->fetch($fichinterid);
+$object->fetch($id);
$upload_dir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($object->ref);
$modulepart='fichinter';
/*
- * Action envoie fichier
+ * Actions
*/
+
if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
@@ -76,7 +78,17 @@ if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
- $mesg = ''.$langs->trans("FileTransferComplete").'
';
+ if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1)
+ {
+ // Create small thumbs for company (Ratio is near 16/9)
+ // Used on logon for example
+ $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs");
+
+ // Create mini thumbs for company (Ratio is near 16/9)
+ // Used on menu or for setup page for example
+ $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs");
+ }
+ $mesg = ''.$langs->trans("FileTransferComplete").'
';
}
else
{
@@ -99,7 +111,7 @@ if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
/*
- *
+ * View
*/
$form = new Form($db);
@@ -161,7 +173,7 @@ if ($object->id)
// List of document
- $param='&id='.$object->id;
+ //$param='&id='.$object->id;
$formfile->list_of_documents($filearray,$object,'ficheinter',$param);
}
@@ -170,7 +182,7 @@ else
print $langs->trans("UnkownError");
}
-$db->close();
-
llxFooter();
+
+$db->close();
?>
diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php
index 6acdcf8cfde..ca339667e15 100644
--- a/htdocs/viewimage.php
+++ b/htdocs/viewimage.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2005-2011 Laurent Destailleur
+ * Copyright (C) 2005-2012 Laurent Destailleur
* Copyright (C) 2005-2011 Regis Houssin
*
* This program is free software; you can redistribute it and/or modify
@@ -24,12 +24,6 @@
* \remarks Call to wrapper is '
'
*/
-// Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
-$action = isset($_GET["action"])?$_GET["action"]:'';
-$original_file = isset($_GET["file"])?$_GET["file"]:'';
-$modulepart = isset($_GET["modulepart"])?$_GET["modulepart"]:'';
-$urlsource = isset($_GET["urlsource"])?$_GET["urlsource"]:'';
-
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
@@ -40,7 +34,8 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
// Pour autre que companylogo, on charge environnement + info issus de logon comme le user
-if (($modulepart == 'companylogo') && ! defined("NOLOGIN")) define("NOLOGIN",'1');
+if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'companylogo') && ! defined("NOLOGIN")) define("NOLOGIN",'1');
+
/**
* Wrapper, donc header vierge
@@ -49,14 +44,21 @@ if (($modulepart == 'companylogo') && ! defined("NOLOGIN")) define("NOLOGIN",'1'
*/
function llxHeader() { }
-
require("./main.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
+
+$action = GETPOST("action");
+$original_file = GETPOST("file");
+$modulepart = GETPOST("modulepart");
+$urlsource = GETPOST("urlsource");
+
+
// Security check
if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart');
+
/*
* Actions
*/
@@ -103,203 +105,142 @@ if ($modulepart)
$accessallowed=1;
$original_file=$conf->mycompany->dir_output.'/logos/'.$original_file;
}
-
// Wrapping for users photos
elseif ($modulepart == 'userphoto')
{
$accessallowed=1;
$original_file=$conf->user->dir_output.'/'.$original_file;
}
-
// Wrapping for members photos
elseif ($modulepart == 'memberphoto')
{
$accessallowed=1;
$original_file=$conf->adherent->dir_output.'/'.$original_file;
}
-
// Wrapping pour les images des societes
elseif ($modulepart == 'societe')
{
$accessallowed=1;
$original_file=$conf->societe->dir_output.'/'.$original_file;
}
-
// Wrapping pour les apercu factures
elseif ($modulepart == 'apercufacture')
{
- if ($user->rights->facture->lire)
- {
- $accessallowed=1;
- }
+ if ($user->rights->facture->lire) $accessallowed=1;
$original_file=$conf->facture->dir_output.'/'.$original_file;
}
-
// Wrapping pour les apercu propal
elseif ($modulepart == 'apercupropal')
{
- if ($user->rights->propale->lire)
- {
- $accessallowed=1;
- }
+ if ($user->rights->propale->lire) $accessallowed=1;
$original_file=$conf->propale->dir_output.'/'.$original_file;
}
-
// Wrapping pour les apercu commande
elseif ($modulepart == 'apercucommande')
{
- if ($user->rights->commande->lire)
- {
- $accessallowed=1;
- }
+ if ($user->rights->commande->lire) $accessallowed=1;
$original_file=$conf->commande->dir_output.'/'.$original_file;
}
-
// Wrapping pour les apercu intervention
elseif ($modulepart == 'apercufichinter')
{
- if ($user->rights->ficheinter->lire)
- {
- $accessallowed=1;
- }
+ 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')
{
- if ($user->rights->propale->lire)
- {
- $accessallowed=1;
- }
+ 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')
{
- if ($user->rights->commande->lire)
- {
- $accessallowed=1;
- }
+ if ($user->rights->commande->lire) $accessallowed=1;
$original_file=$conf->commande->dir_temp.'/'.$original_file;
}
elseif ($modulepart == 'orderstatssupplier')
{
- if ($user->rights->fournisseur->commande->lire)
- {
- $accessallowed=1;
- }
+ 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')
{
- if ($user->rights->facture->lire)
- {
- $accessallowed=1;
- }
+ if ($user->rights->facture->lire) $accessallowed=1;
$original_file=$conf->facture->dir_temp.'/'.$original_file;
}
elseif ($modulepart == 'billstatssupplier')
{
- if ($user->rights->fournisseur->facture->lire)
- {
- $accessallowed=1;
- }
+ 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')
{
- if ($user->rights->expedition->lire)
- {
- $accessallowed=1;
- }
+ if ($user->rights->expedition->lire) $accessallowed=1;
$original_file=$conf->expedition->dir_temp.'/'.$original_file;
}
-
// Wrapping pour les images des stats expeditions
elseif ($modulepart == 'tripsexpensesstats')
{
- if ($user->rights->deplacement->lire)
- {
- $accessallowed=1;
- }
+ if ($user->rights->deplacement->lire) $accessallowed=1;
$original_file=$conf->deplacement->dir_temp.'/'.$original_file;
}
-
// Wrapping pour les images des stats expeditions
elseif ($modulepart == 'memberstats')
{
- if ($user->rights->adherent->lire)
- {
- $accessallowed=1;
- }
+ if ($user->rights->adherent->lire) $accessallowed=1;
$original_file=$conf->adherent->dir_temp.'/'.$original_file;
}
-
// Wrapping pour les images des stats produits
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->dir_temp)?$conf->product->dir_temp:$conf->service->dir_temp).'/'.$original_file;
}
-
// Wrapping for products or services
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->dir_output)?$conf->product->dir_output:$conf->service->dir_output).'/'.$original_file;
}
-
+ // Wrapping for products or services
+ elseif ($modulepart == 'tax')
+ {
+ if ($user->rights->tax->charges->lire) $accessallowed=1;
+ $original_file=$conf->tax->dir_output.'/'.$original_file;
+ }
// Wrapping for categories
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;
}
-
// Wrapping pour les prelevements
elseif ($modulepart == 'prelevement')
{
if ($user->rights->prelevement->bons->lire) $accessallowed=1;
-
$original_file=$conf->prelevement->dir_output.'/receipts/'.$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 fournisseurs
elseif ($modulepart == 'graph_fourn')
{
$accessallowed=1;
$original_file=$conf->fournisseur->dir_temp.'/'.$original_file;
}
-
// Wrapping pour les graph des produits
elseif ($modulepart == 'graph_product')
{
$accessallowed=1;
$original_file=$conf->product->dir_temp.'/'.$original_file;
}
-
// Wrapping pour les code barre
elseif ($modulepart == 'barcode')
{
@@ -309,21 +250,18 @@ if ($modulepart)
//$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 == 'scanner_user_temp')
{
$accessallowed=1;
$original_file=$conf->scanner->dir_temp.'/'.$user->id.'/'.$original_file;
}
-
// Wrapping pour les images fckeditor
elseif ($modulepart == 'fckeditor')
{
@@ -359,7 +297,7 @@ if ($modulepart)
$subperm=GETPOST('subperm');
if ($perm || $subperm)
{
- if (($perm && $user->rights->$modulepart->$perm) || ($perm && $subperm && $user->rights->$modulepart->$perm->$subperm)) $accessallowed=1;
+ if (($perm && ! $subperm && $user->rights->$modulepart->$perm) || ($perm && $subperm && $user->rights->$modulepart->$perm->$subperm)) $accessallowed=1;
$original_file=$conf->$modulepart->dir_output.'/'.$original_file;
}
else