Qual: Mutualize a lot of code

This commit is contained in:
Laurent Destailleur 2008-05-04 13:33:49 +00:00
parent 3749c33bca
commit 6167e0c181
13 changed files with 189 additions and 562 deletions

View File

@ -229,6 +229,7 @@ class ActionComm
$obj = $this->db->fetch_object($resql);
$this->id = $obj->id;
$this->ref = $obj->id;
$this->type_id = $obj->type_id;
$this->type_code = $obj->type_code;
$transcode=$langs->trans("Action".$obj->code);

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
@ -18,22 +18,20 @@
* 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.
*
* $Id$
* $Source$
*/
/**
\file htdocs/product/document.php
\ingroup product
\brief Page des documents joints sur les produits
\version $Revision$
\version $Id$
*/
require_once("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/cactioncomm.class.php");
require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
$langs->load("companies");
@ -149,37 +147,14 @@ if ($_GET["id"] > 0)
print '</td></tr>';
// Construit liste des fichiers
clearstatcache();
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
$totalsize=0;
$filearray=array();
if (is_dir($upload_dir))
foreach($filearray as $key => $file)
{
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($upload_dir);
error_reporting($errorlevel);
if ($handle)
{
$i=0;
while (($file = readdir($handle))!==false)
{
if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
$filearray[$i]=$file;
$totalsize+=filesize($upload_dir."/".$file);
$i++;
}
}
closedir($handle);
}
else
{
print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'</div>';
}
$totalsize+=$file['size'];
}
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
@ -188,52 +163,15 @@ if ($_GET["id"] > 0)
if ($mesg) { print $mesg."<br>"; }
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/action/document.php?id='.$act->id);
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Document').'</td>';
print '<td align="right">'.$langs->trans('Size').'</td>';
print '<td align="center">'.$langs->trans('Date').'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
if (is_dir($upload_dir))
{
$errorlevel=error_reporting();
$handle=opendir($upload_dir);
if ($handle)
{
$var=true;
while (($file = readdir($handle))!==false)
{
if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>';
echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart=actions&file='.$act->id.'/'.urlencode($file).'">'.$file.'</a>';
print "</td>\n";
print '<td align="right">'.filesize($upload_dir.'/'.$file). ' bytes</td>';
print '<td align="center">'.dolibarr_print_date(filemtime($upload_dir.'/'.$file),'dayhour').'</td>';
print '<td align="center">';
print '<a href="'.DOL_URL_ROOT.'/comm/action/document.php?id='.$act->id.'&action=delete&urlfile='.urlencode($file).'">'.img_delete($langs->trans('Delete')).'</a>';
print "</td></tr>\n";
}
}
closedir($handle);
}
else
{
print '<div class="error">'.$langs->trans('ErrorCantOpenDir').'<b> '.$upload_dir.'</b></div>';
}
}
print '</table>';
// List of document
$formfile->list_of_documents($upload_dir,$act,'actions');
}
else
{

View File

@ -29,6 +29,7 @@
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
$langs->load('compta');
@ -111,35 +112,15 @@ if ($propalid > 0)
$head = propal_prepare_head($propal);
dolibarr_fiche_head($head, 'document', $langs->trans('Proposal'));
// Construit liste des fichiers
clearstatcache();
$totalsize=0;
$filearray=array();
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($upload_dir);
error_reporting($errorlevel);
if ($handle)
{
$i=0;
while (($file = readdir($handle))!==false)
{
if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
$filearray[$i]=$file;
$totalsize+=filesize($upload_dir."/".$file);
$i++;
}
}
closedir($handle);
}
else
{
// print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'</div>';
}
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
$totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
print '<table class="border"width="100%">';
@ -162,50 +143,9 @@ if ($propalid > 0)
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id);
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre"><td>'.$langs->trans("Document").'</td><td align="right">'.$langs->trans("Size").'</td><td align="center">'.$langs->trans("Date").'</td><td>&nbsp;</td></tr>';
if (is_dir($upload_dir))
{
$handle=opendir($upload_dir);
if ($handle)
{
$var=true;
while (($file = readdir($handle))!==false)
{
if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>';
echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart=propal&file='.$propref.'/'.urlencode($file).'">'.$file.'</a>';
print "</td>\n";
print '<td align="right">'.filesize($upload_dir.'/'.$file). ' bytes</td>';
print '<td align="center">'.dolibarr_print_date(filemtime($upload_dir.'/'.$file),'dayhour').'</td>';
print '<td align="center">';
if ($file == $propref . '.pdf')
{
echo '-';
}
else
{
echo '<a href="'.DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id.'&action=delete&urlfile='.urlencode($file).'">'.img_delete($langs->trans('Delete')).'</a>';
}
print "</td></tr>\n";
}
}
closedir($handle);
}
else
{
print '<div class="error">'.$langs->trans('ErrorCantOpenDir').'<b> '.$upload_dir.'</b></div>';
}
}
print '</table>';
// List of document
$formfile->list_of_documents($upload_dir,$propal,'propal');
}
else

View File

@ -28,6 +28,7 @@
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/order.lib.php');
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
if (!$user->rights->commande->lire)
@ -105,38 +106,15 @@ if ($id > 0)
$head = commande_prepare_head($commande);
dolibarr_fiche_head($head, 'documents', $langs->trans('CustomerOrder'));
// Construit liste des fichiers
clearstatcache();
$totalsize=0;
$filearray=array();
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($upload_dir);
error_reporting($errorlevel);
if ($handle)
{
$i=0;
while (($file = readdir($handle))!==false)
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
$totalsize=0;
foreach($filearray as $key => $file)
{
if (! is_dir($dir.$file)
&& ! eregi('^\.',$file)
&& ! eregi('^CVS',$file)
&& ! eregi('\.meta$',$file))
{
$filearray[$i]=$file;
$totalsize+=filesize($upload_dir."/".$file);
$i++;
}
$totalsize+=$file['size'];
}
closedir($handle);
}
else
{
// print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'</div>';
}
print '<table class="border"width="100%">';
@ -151,63 +129,15 @@ if ($id > 0)
if ($mesg) { print $mesg."<br>"; }
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/commande/document.php?id='.$commande->id);
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Document").'</td>';
print '<td align="right">'.$langs->trans("Size").'</td>';
print '<td align="center">'.$langs->trans("Date").'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
if (is_dir($upload_dir))
{
$handle=opendir($upload_dir);
if ($handle)
{
$var=true;
while (($file = readdir($handle))!==false)
{
if (! is_dir($dir.$file)
&& ! eregi('^\.',$file)
&& ! eregi('^CVS',$file)
&& ! eregi('\.meta$',$file))
{
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>';
echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart=commande&file='.$commanderef.'/'.urlencode($file).'">'.$file.'</a>';
print "</td>\n";
print '<td align="right">'.filesize($upload_dir.'/'.$file). ' '.$langs->trans("bytes").'</td>';
print '<td align="center">'.dolibarr_print_date(filemtime($upload_dir.'/'.$file),'dayhour').'</td>';
print '<td align="center">';
if ($file == $facref . '.pdf')
{
echo '-';
}
else
{
echo '<a href="'.DOL_URL_ROOT.'/commande/document.php?id='.$commande->id.'&action=delete&urlfile='.urlencode($file).'">'.img_delete($langs->trans('Delete')).'</a>';
}
print "</td></tr>\n";
}
}
closedir($handle);
}
else
{
print '<div class="error">'.$langs->trans('ErrorCantOpenDir').'<b> '.$upload_dir.'</b></div>';
}
}
print '</table>';
// List of document
$formfile->list_of_documents($upload_dir,$commande,'commande');
}
else
{

View File

@ -17,20 +17,19 @@
* 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.
*
* $Id$
*/
/**
\file htdocs/compta/facture/document.php
\ingroup facture
\brief Page de gestion des documents attachées à une facture
\version $Revision$
\version $Id$
*/
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/invoice.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
$langs->load('propal');
@ -78,9 +77,10 @@ if ($_POST["sendit"] && $conf->upload)
// Delete
if ($action=='delete')
{
$facture = new Facture($db);
$facture = new Facture($db);
if ($facture->fetch($facid))
$facid=$_GET["id"];
if ($facture->fetch($facid))
{
$upload_dir = $conf->facture->dir_output . "/" . $facture->ref;
$file = $upload_dir . '/' . urldecode($_GET['urlfile']);
@ -111,37 +111,15 @@ if ($facid > 0)
$head = facture_prepare_head($facture);
dolibarr_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'));
// Construit liste des fichiers
clearstatcache();
$totalsize=0;
$filearray=array();
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($upload_dir);
error_reporting($errorlevel);
if ($handle)
{
$i=0;
while (($file = readdir($handle))!==false)
{
if (! is_dir($dir.$file)
&& ! eregi('^\.',$file)
&& ! eregi('^CVS',$file)
&& ! eregi('\.meta$',$file))
{
$filearray[$i]=$file;
$totalsize+=filesize($upload_dir."/".$file);
$i++;
}
}
closedir($handle);
}
else
{
// print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'</div>';
}
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
$totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
print '<table class="border"width="100%">';
@ -159,60 +137,14 @@ if ($facid > 0)
if ($mesg) { print $mesg."<br>"; }
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/compta/facture/document.php?facid='.$facture->id);
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Document").'</td>';
print '<td align="right">'.$langs->trans("Size").'</td>';
print '<td align="center">'.$langs->trans("Date").'</td>';
print "<td>&nbsp;</td></tr>\n";
if (is_dir($upload_dir))
{
$handle=opendir($upload_dir);
if ($handle)
{
$var=true;
while (($file = readdir($handle))!==false)
{
if (! is_dir($dir.$file)
&& ! eregi('^\.',$file)
&& ! eregi('^CVS',$file)
&& ! eregi('\.meta$',$file))
{
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>';
echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart=facture&file='.$facref.'/'.urlencode($file).'">'.$file.'</a>';
print "</td>\n";
print '<td align="right">'.filesize($upload_dir.'/'.$file). ' '.$langs->trans("bytes").'</td>';
print '<td align="center">'.dolibarr_print_date(filemtime($upload_dir.'/'.$file),'dayhour').'</td>';
print '<td align="center">';
if ($file == $facref . '.pdf')
{
echo '-';
}
else
{
echo '<a href="'.DOL_URL_ROOT.'/compta/facture/document.php?facid='.$facture->id.'&action=delete&urlfile='.urlencode($file).'">'.img_delete($langs->trans('Delete')).'</a>';
}
print "</td></tr>\n";
}
}
closedir($handle);
}
else
{
print '<div class="error">'.$langs->trans('ErrorCantOpenDir').'<b> '.$upload_dir.'</b></div>';
}
}
print '</table>';
// List of document
$formfile->list_of_documents($upload_dir,$facture,'facture');
}
else

View File

@ -21,15 +21,16 @@
*/
/**
\file htdocs/product/document.php
\ingroup product
\brief Page des documents joints sur les produits
\file htdocs/contrat/document.php
\ingroup contrat
\brief Page des documents joints sur les contrats
\version $Id$
*/
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT."/lib/contract.lib.php");
require_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
$langs->load("other");
@ -105,34 +106,14 @@ if ($contrat->id)
dolibarr_fiche_head($head, 'documents', $langs->trans("Contract"));
// Construit liste des fichiers
clearstatcache();
$totalsize=0;
$filearray=array();
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($upload_dir);
error_reporting($errorlevel);
if ($handle)
{
$i=0;
while (($file = readdir($handle))!==false)
{
if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
$filearray[$i]=$file;
$totalsize+=filesize($upload_dir."/".$file);
$i++;
}
}
closedir($handle);
}
else
{
// print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'</div>';
}
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
$totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
print '<table class="border" width="100%">';
@ -154,53 +135,9 @@ if ($contrat->id)
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/contrat/document.php?id='.$contrat->id);
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($upload_dir);
error_reporting($errorlevel);
print '<table width="100%" class="noborder">';
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Document').'</td>';
print '<td align="right">'.$langs->trans('Size').'</td>';
print '<td align="center">'.$langs->trans('Date').'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
$var=true;
if ($handle)
{
while (($file = readdir($handle))!==false)
{
if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>';
echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&file='.urlencode($contratref.'/'.$file).'">'.$file.'</a>';
print "</td>\n";
print '<td align="right">'.filesize($upload_dir.'/'.$file). ' bytes</td>';
print '<td align="center">'.dolibarr_print_date(filemtime($upload_dir.'/'.$file),'dayhour').'</td>';
print '<td align="center">';
if ($file == $propref . '.pdf')
{
echo '-';
}
else
{
echo '<a href="'.DOL_URL_ROOT.'/contrat/document.php?id='.$contrat->id.'&action=delete&urlfile='.urlencode($file).'">'.img_delete($langs->trans('Delete')).'</a>';
}
print "</td></tr>\n";
}
}
closedir($handle);
}
print '</table>';
// List of document
$formfile->list_of_documents($upload_dir,$contrat,'contract');
}
else

View File

@ -160,6 +160,11 @@ $form=new Form($db);
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
$totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
$head = ecm_prepare_head($ecmdir);
@ -191,7 +196,7 @@ while ($tmpecmdir && $result > 0)
$tmpecmdir=0;
}
}
//print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a>';
print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> ';
print $s;
print '</td></tr>';
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
@ -219,11 +224,6 @@ print '<tr><td>'.$langs->trans("ECMNbOfDocs").'</td><td>';
print sizeof($filearray);
print '</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>';
$totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
print dol_print_size($totalsize);
print '</td></tr>';
if ($_GET["action"] == 'edit')

View File

@ -117,6 +117,18 @@ $form=new Form($db);
$ecmdirstatic = new ECMDirectory($db);
$userstatic = new User($db);
// Ajout rubriques automatiques
$rowspan=0;
$sectionauto=array();
if ($conf->societe->enabled) { $rowspan++; $sectionauto[]=array('test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")); }
if ($conf->propal->enabled) { $rowspan++; $sectionauto[]=array('test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals")); }
if ($conf->commande->enabled) { $rowspan++; $sectionauto[]=array('test'=>$conf->commande->enabled,'label'=>$langs->trans("Orders"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
if ($conf->contrat->enabled) { $rowspan++; $sectionauto[]=array('test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); }
if ($conf->facture->enabled) { $rowspan++; $sectionauto[]=array('test'=>$conf->facture->enabled, 'label'=>$langs->trans("Invoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); }
if ($conf->produit->enabled) { $rowspan++; $sectionauto[]=array('test'=>$conf->produit->enabled, 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); }
//***********************
// List
//***********************
@ -150,14 +162,16 @@ print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print '<td colspan="3">'.$langs->trans("ECMSearchByEntity").'</td></tr>';
$buthtml='<td rowspan="5"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
$butshown=0;
if ($conf->societe->enabled) { print "<tr $bc[0]><td>".$langs->trans("ThirdParty").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown=1; }
if ($conf->contrat->enabled) { print "<tr $bc[0]><td>".$langs->trans("Contrat").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown=1; }
if ($conf->propal->enabled) { print "<tr $bc[0]><td>".$langs->trans("Proposal").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown=1; }
if ($conf->commande->enabled) { print "<tr $bc[0]><td>".$langs->trans("Order").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown=1; }
if ($conf->facture->enabled) { print "<tr $bc[0]><td>".$langs->trans("Invoice").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown=1; }
$buthtml='<td rowspan="'.$rowspan.'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
$butshown=0;
if ($conf->societe->enabled) { print "<tr $bc[0]><td>".$langs->trans("ThirdParty").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown++; }
if ($conf->contrat->enabled) { print "<tr $bc[0]><td>".$langs->trans("Contrat").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown++; }
if ($conf->propal->enabled) { print "<tr $bc[0]><td>".$langs->trans("Proposal").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown++; }
if ($conf->commande->enabled) { print "<tr $bc[0]><td>".$langs->trans("Order").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown++; }
if ($conf->facture->enabled) { print "<tr $bc[0]><td>".$langs->trans("Invoice").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown++; }
if ($conf->produit->enabled) { print "<tr $bc[0]><td>".$langs->trans("ProductsAndServices").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown++; }
print "</table></form><br>";
//print $langs->trans("ECMAutoOrgDesc");
@ -184,14 +198,6 @@ if ($mesg) { print $mesg."<br>"; }
// Construit liste des répertoires
print '<table width="100%" class="noborder">';
// Ajout rubriques automatiques
$sectionauto=array();
if ($conf->societe->enabled) $sectionauto[]=array('test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties"));
if ($conf->propal->enabled) $sectionauto[]=array('test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals"));
if ($conf->commande->enabled) $sectionauto[]=array('test'=>$conf->commande->enabled,'label'=>$langs->trans("Orders"), 'desc'=>$langs->trans("ECMDocsByOrders"));
if ($conf->contrat->enabled) $sectionauto[]=array('test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts"));
if ($conf->facture->enabled) $sectionauto[]=array('test'=>$conf->facture->enabled, 'label'=>$langs->trans("Invoices"), 'desc'=>$langs->trans("ECMDocsByInvoices"));
if (sizeof($sectionauto))
{
// Automatic sections

View File

@ -29,6 +29,7 @@
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.facture.class.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/fourn.lib.php');
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
$langs->load('bills');
@ -81,6 +82,7 @@ if ($action=='delete')
{
$facture = new FactureFournisseur($db);
$facid=$_GET["id"];
if ($facture->fetch($facid))
{
$ref = sanitize_string($facture->ref);
@ -111,35 +113,15 @@ if ($facid > 0)
$head = facturefourn_prepare_head($facture);
dolibarr_fiche_head($head, 'documents', $langs->trans('SupplierInvoice'));
// Construit liste des fichiers
clearstatcache();
$totalsize=0;
$filearray=array();
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($upload_dir);
error_reporting($errorlevel);
if ($handle)
{
$i=0;
while (($file = readdir($handle))!==false)
{
if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
$filearray[$i]=$file;
$totalsize+=filesize($upload_dir.'/'.$file);
$i++;
}
}
closedir($handle);
}
else
{
// print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'</div>';
}
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
$totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
print '<table class="border"width="100%">';
@ -163,58 +145,15 @@ if ($facid > 0)
if ($mesg) { print $mesg.'<br>'; }
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$facture->id);
// Affiche liste des documents existant
print_titre($langs->trans('AttachedFiles'));
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Document').'</td>';
print '<td align="right">'.$langs->trans('Size').'</td>';
print '<td align="center">'.$langs->trans('Date').'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
if (is_dir($upload_dir))
{
$handle=opendir($upload_dir);
if ($handle)
{
$var=true;
while (($file = readdir($handle))!==false)
{
if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>';
echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart=facture_fournisseur&file='.get_exdir($facture->id,2).$facture->id.'/'.urlencode($file).'">'.$file.'</a>';
print "</td>\n";
print '<td align="right">'.filesize($upload_dir.'/'.$file). ' bytes</td>';
print '<td align="center">'.dolibarr_print_date(filemtime($upload_dir.'/'.$file),'dayhour').'</td>';
print '<td align="center">';
if ($file == $facref . '.pdf')
{
echo '-';
}
else
{
echo '<a href="'.DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$facture->id.'&action=delete&urlfile='.urlencode($file).'">'.img_delete($langs->trans('Delete')).'</a>';
}
print "</td></tr>\n";
}
}
closedir($handle);
}
else
{
print '<div class="error">'.$langs->trans('ErrorCantOpenDir').'<b> '.$upload_dir.'</b></div>';
}
}
print '</table>';
// List of document
$formfile->list_of_documents($upload_dir,$facture,'facture_fournisseur');
}
else
{

View File

@ -91,8 +91,9 @@ class FormFile
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
}
print ' ('.$langs->trans("MaxSize").': '.$max.' '.$langs->trans("Kb").')';
print ' ('.$langs->trans("MaxSize").': '.$max.' '.$langs->trans("Kb");
print ' '.info_admin($langs->trans("ThisLimitIsDefinedInSetup",$max,$maxphp),1);
print ')';
print "</td></tr>";
print "</table>";
@ -363,6 +364,70 @@ class FormFile
return ($i?$i:$headershown);
}
/**
* \brief Show list of documents in a directory
* \param upload_dir Dir to scan
* \param object Object on which document is linked to
* \param modulepart Value for modulepart used by download wrapper
* \return int <0 if KO, nb of files shown if OK
*/
function list_of_documents($upload_dir,$object,$modulepart)
{
global $user, $conf, $langs;
global $bc;
// List of documents
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($upload_dir);
error_reporting($errorlevel);
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Document').'</td>';
print '<td align="right">'.$langs->trans('Size').'</td>';
print '<td align="center">'.$langs->trans('Date').'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
$var=true;
if ($handle)
{
while (($file = readdir($handle))!==false)
{
if (!is_dir($dir.$file)
&& $file != '.'
&& $file != '..'
&& $file != 'CVS'
&& ! eregi('\.meta$',$file)
)
{
// Define relative path used to store the file
$morepath=$object->ref.'/';
if ($modulepart == 'facture_fournisseur') $morepath=get_exdir($object->id,2).$morepath;
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>';
print img_mime($file).' ';
print '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&file='.urlencode($morepath.$file).'">'.$file.'</a>';
print "</td>\n";
print '<td align="right">'.filesize($upload_dir.'/'.$file). ' '.$langs->trans('bytes').'</td>';
print '<td align="center">'.dolibarr_print_date(filemtime($upload_dir.'/'.$file),'dayhour').'</td>';
print '<td align="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&urlfile='.urlencode($file).'">'.img_delete($langs->trans('Delete')).'</a>';
print "</td></tr>\n";
}
}
closedir($handle);
}
print '</table>';
}
}
?>

View File

@ -422,6 +422,7 @@ MenuECM=Documents
MenuAWStats=AWStats
MenuMembers=Members
MenuAgendaGoogle=Google agenda
ThisLimitIsDefinedInSetup=Dolibarr limit (Menu home-setup-security): %s Kb, PHP limit: %s Kb
# Week day
Monday=Monday
Tuesday=Tuesday

View File

@ -424,6 +424,7 @@ MenuECM=Documents
MenuAWStats=AWStats
MenuMembers=Adhérents
MenuAgendaGoogle=Agenda Google
ThisLimitIsDefinedInSetup=Limite Dolibarr (Menu accueil-configuration-sécurité): %s Ko, Limite PHP: %s Ko
# Week day
Monday=Lundi
Tuesday=Mardi

View File

@ -30,6 +30,7 @@
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
$langs->load("other");
@ -107,34 +108,14 @@ if ($product->id)
dolibarr_fiche_head($head, 'documents', $titre);
// Construit liste des fichiers
clearstatcache();
$totalsize=0;
$filearray=array();
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($upload_dir);
error_reporting($errorlevel);
if ($handle)
{
$i=0;
while (($file = readdir($handle))!==false)
{
if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
$filearray[$i]=$file;
$totalsize+=filesize($upload_dir."/".$file);
$i++;
}
}
closedir($handle);
}
else
{
// print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'</div>';
}
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
$totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
print '<table class="border" width="100%">';
@ -177,53 +158,9 @@ if ($product->id)
$formfile->form_attach_new_file(DOL_URL_ROOT.'/product/document.php?id='.$product->id);
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($upload_dir);
error_reporting($errorlevel);
print '<table width="100%" class="noborder">';
// List of document
$formfile->list_of_documents($upload_dir,$product,'produit');
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Document').'</td>';
print '<td align="right">'.$langs->trans('Size').'</td>';
print '<td align="center">'.$langs->trans('Date').'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
$var=true;
if ($handle)
{
while (($file = readdir($handle))!==false)
{
if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>';
echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&file='.$prodref.'/'.urlencode($file).'">'.$file.'</a>';
print "</td>\n";
print '<td align="right">'.filesize($upload_dir.'/'.$file). ' bytes</td>';
print '<td align="center">'.dolibarr_print_date(filemtime($upload_dir.'/'.$file),'dayhour').'</td>';
print '<td align="center">';
if ($file == $propref . '.pdf')
{
echo '-';
}
else
{
echo '<a href="'.DOL_URL_ROOT.'/product/document.php?id='.$product->id.'&action=delete&urlfile='.urlencode($file).'">'.img_delete($langs->trans('Delete')).'</a>';
}
print "</td></tr>\n";
}
}
closedir($handle);
}
print '</table>';
}
else
{