forked from Wavyzz/dolibarr
Fix: uniformize code
Fix: add confirm delete file New: add upload and delete file triggers
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
* \file htdocs/adherents/document.php
|
||||
* \brief Tab for documents linked to third party
|
||||
* \ingroup societe
|
||||
* \version $Id$
|
||||
* \version $Id: document.php,v 1.7 2011/07/05 16:10:56 hregis Exp $
|
||||
*/
|
||||
|
||||
require("../main.inc.php");
|
||||
@@ -194,7 +194,7 @@ if ($id > 0)
|
||||
|
||||
print '</div>';
|
||||
|
||||
if ($mesg) { print "$mesg<br>"; }
|
||||
dol_htmloutput_mesg($mesg,$mesgs);
|
||||
|
||||
/*
|
||||
* Confirmation suppression fichier
|
||||
@@ -231,6 +231,6 @@ else
|
||||
$db->close();
|
||||
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
llxFooter('$Date: 2011/07/05 16:10:56 $ - $Revision: 1.7 $');
|
||||
|
||||
?>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* \file htdocs/comm/propal/document.php
|
||||
* \ingroup propale
|
||||
* \brief Page de gestion des documents attaches a une proposition commerciale
|
||||
* \version $Id$
|
||||
* \version $Id: document.php,v 1.65 2011/07/05 16:10:56 hregis Exp $
|
||||
*/
|
||||
|
||||
require("../../main.inc.php");
|
||||
@@ -35,14 +35,14 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
|
||||
$langs->load('compta');
|
||||
$langs->load('other');
|
||||
|
||||
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
|
||||
|
||||
$id = isset($_GET["id"])?$_GET["id"]:'';
|
||||
$action = GETPOST('action');
|
||||
$confirm = GETPOST('confirm');
|
||||
$id = GETPOST('id');
|
||||
$ref = GETPOST('ref');
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id)
|
||||
{
|
||||
unset($_GET["action"]);
|
||||
$action='';
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
@@ -59,6 +59,7 @@ $pagenext = $page + 1;
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
if (! $sortfield) $sortfield="name";
|
||||
|
||||
$object = new Propal($db);
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@@ -67,13 +68,11 @@ if (! $sortfield) $sortfield="name";
|
||||
// Envoi fichier
|
||||
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
||||
|
||||
$propal = new Propal($db);
|
||||
|
||||
if ($propal->fetch($id))
|
||||
if ($object->fetch($id))
|
||||
{
|
||||
$upload_dir = $conf->propale->dir_output . "/" . dol_sanitizeFileName($propal->ref);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$upload_dir = $conf->propale->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
|
||||
if (create_exdir($upload_dir) >= 0)
|
||||
{
|
||||
@@ -103,14 +102,13 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
}
|
||||
|
||||
// Delete
|
||||
if ($action=='delete')
|
||||
if ($action == 'confirm_deletefile' && $confirm == 'yes')
|
||||
{
|
||||
$propal = new Propal($db);
|
||||
|
||||
$id=$_GET["id"];
|
||||
if ($propal->fetch($id))
|
||||
if ($object->fetch($id))
|
||||
{
|
||||
$upload_dir = $conf->propale->dir_output . "/" . dol_sanitizeFileName($propal->ref);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$upload_dir = $conf->propale->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
||||
dol_delete_file($file);
|
||||
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
|
||||
@@ -126,19 +124,15 @@ llxHeader();
|
||||
|
||||
$html = new Form($db);
|
||||
|
||||
$id = $_GET["id"];
|
||||
$ref= $_GET["ref"];
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$propal = new Propal($db);
|
||||
if ($propal->fetch($id,$ref))
|
||||
if ($object->fetch($id,$ref))
|
||||
{
|
||||
$upload_dir = $conf->propale->dir_output.'/'.dol_sanitizeFileName($propal->ref);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($propal->socid);
|
||||
$upload_dir = $conf->propale->dir_output.'/'.dol_sanitizeFileName($object->ref);
|
||||
|
||||
$head = propal_prepare_head($propal);
|
||||
$head = propal_prepare_head($object);
|
||||
dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal');
|
||||
|
||||
|
||||
@@ -153,11 +147,11 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
print '<table class="border"width="100%">';
|
||||
|
||||
$linkback="<a href=\"".$_SERVER["PHP_SELF"]."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder\">".$langs->trans("BackToList")."</a>";
|
||||
$linkback='<a href="'.$_SERVER["PHP_SELF"].'?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
|
||||
print $html->showrefnav($propal,'ref',$linkback,1,'ref','ref','');
|
||||
print $html->showrefnav($object,'ref',$linkback,1,'ref','ref','');
|
||||
print '</td></tr>';
|
||||
|
||||
// Ref client
|
||||
@@ -167,15 +161,13 @@ if ($id > 0 || ! empty($ref))
|
||||
print '</td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
print $propal->ref_client;
|
||||
print $object->ref_client;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Customer
|
||||
if ( is_null($propal->client) )
|
||||
$propal->fetch_thirdparty();
|
||||
print "<tr><td>".$langs->trans("Company")."</td>";
|
||||
print '<td colspan="3">'.$propal->client->getNomUrl(1).'</td></tr>';
|
||||
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
|
||||
|
||||
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>';
|
||||
@@ -184,16 +176,25 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
print '</div>';
|
||||
|
||||
if ($mesg) { print "$mesg<br>"; }
|
||||
dol_htmloutput_mesg($mesg,$mesgs);
|
||||
|
||||
/*
|
||||
* Confirmation suppression fichier
|
||||
*/
|
||||
if ($action == 'delete')
|
||||
{
|
||||
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
|
||||
if ($ret == 'html') print '<br>';
|
||||
}
|
||||
|
||||
// Affiche formulaire upload
|
||||
$formfile=new FormFile($db);
|
||||
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?id='.$propal->id,'',0,0,$user->rights->propale->creer);
|
||||
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id,'',0,0,$user->rights->propale->creer);
|
||||
|
||||
|
||||
// List of document
|
||||
$param='&id='.$propal->id;
|
||||
$formfile->list_of_documents($filearray,$propal,'propal',$param);
|
||||
$param='&id='.$object->id;
|
||||
$formfile->list_of_documents($filearray,$object,'propal',$param);
|
||||
|
||||
}
|
||||
else
|
||||
@@ -208,5 +209,5 @@ else
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
llxFooter('$Date: 2011/07/05 16:10:56 $ - $Revision: 1.65 $');
|
||||
?>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2005-2011 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
|
||||
@@ -23,7 +23,7 @@
|
||||
* \file htdocs/commande/document.php
|
||||
* \ingroup order
|
||||
* \brief Page de gestion des documents attachees a une commande
|
||||
* \version $Id$
|
||||
* \version $Id: document.php,v 1.33 2011/07/05 16:10:56 hregis Exp $
|
||||
*/
|
||||
|
||||
require("../main.inc.php");
|
||||
@@ -32,20 +32,22 @@ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT ."/commande/class/commande.class.php");
|
||||
|
||||
if (!$user->rights->commande->lire) accessforbidden();
|
||||
|
||||
$langs->load('companies');
|
||||
//$langs->load("bills");
|
||||
$langs->load('other');
|
||||
|
||||
$id=empty($_GET['id']) ? 0 : intVal($_GET['id']);
|
||||
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
|
||||
$action = GETPOST('action');
|
||||
$confirm = GETPOST('confirm');
|
||||
$id = GETPOST('id');
|
||||
$ref = GETPOST('ref');
|
||||
|
||||
// Security check
|
||||
$socid=0;
|
||||
$comid = isset($_GET["id"])?$_GET["id"]:'';
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result=restrictedArea($user,'commande',$comid,'');
|
||||
if ($user->societe_id)
|
||||
{
|
||||
$action='';
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
$result=restrictedArea($user,'commande',$id,'');
|
||||
|
||||
// Get parameters
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
@@ -59,13 +61,7 @@ if (! $sortorder) $sortorder="ASC";
|
||||
if (! $sortfield) $sortfield="name";
|
||||
|
||||
|
||||
$id = GETPOST('id','int');
|
||||
$ref= $_GET['ref'];
|
||||
$commande = new Commande($db);
|
||||
if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0)
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
$object = new Commande($db);
|
||||
|
||||
|
||||
/*
|
||||
@@ -75,43 +71,51 @@ if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0)
|
||||
// Envoi fichier
|
||||
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
||||
if ($object->fetch($id))
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($commande->ref);
|
||||
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
|
||||
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 (create_exdir($upload_dir) >= 0)
|
||||
{
|
||||
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
if ($resupload < 0) // Unknown error
|
||||
$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 = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
|
||||
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
|
||||
}
|
||||
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
|
||||
}
|
||||
else // Known error
|
||||
{
|
||||
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
|
||||
$langs->load("errors");
|
||||
if ($resupload < 0) // Unknown error
|
||||
{
|
||||
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
|
||||
}
|
||||
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
|
||||
{
|
||||
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
|
||||
}
|
||||
else // Known error
|
||||
{
|
||||
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete
|
||||
if ($action=='delete')
|
||||
if ($action == 'confirm_deletefile' && $confirm == 'yes')
|
||||
{
|
||||
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($commande->ref);
|
||||
$file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
||||
dol_delete_file($file);
|
||||
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
|
||||
if ($object->fetch($id))
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
||||
dol_delete_file($file);
|
||||
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -125,49 +129,62 @@ $html = new Form($db);
|
||||
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$upload_dir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($commande->ref);
|
||||
if ($object->fetch($id, $ref))
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($commande->socid);
|
||||
$upload_dir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($object->ref);
|
||||
|
||||
$head = commande_prepare_head($commande);
|
||||
dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), 0, 'order');
|
||||
$head = commande_prepare_head($object);
|
||||
dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), 0, 'order');
|
||||
|
||||
|
||||
// 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'];
|
||||
// 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%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">';
|
||||
print $html->showrefnav($object,'ref','',1,'ref','ref');
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
|
||||
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>\n";
|
||||
print "</div>\n";
|
||||
|
||||
dol_htmloutput_mesg($mesg,$mesgs);
|
||||
|
||||
/*
|
||||
* Confirmation suppression fichier
|
||||
*/
|
||||
if ($action == 'delete')
|
||||
{
|
||||
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
|
||||
if ($ret == 'html') print '<br>';
|
||||
}
|
||||
|
||||
// Affiche formulaire upload
|
||||
$formfile=new FormFile($db);
|
||||
$formfile->form_attach_new_file(DOL_URL_ROOT.'/commande/document.php?id='.$object->id,'',0,0,$user->rights->commande->creer);
|
||||
|
||||
|
||||
// List of document
|
||||
$param='&id='.$object->id;
|
||||
$formfile->list_of_documents($filearray,$object,'commande',$param);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
print '<table class="border"width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">';
|
||||
print $html->showrefnav($commande,'ref','',1,'ref','ref');
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
|
||||
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>\n";
|
||||
print "</div>\n";
|
||||
|
||||
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,'',0,0,$user->rights->commande->creer);
|
||||
|
||||
|
||||
// List of document
|
||||
$param='&id='.$commande->id;
|
||||
$formfile->list_of_documents($filearray,$commande,'commande',$param);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -176,5 +193,5 @@ else
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
llxFooter('$Date: 2011/07/05 16:10:56 $ - $Revision: 1.33 $');
|
||||
?>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* 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-2011 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
|
||||
@@ -23,7 +23,7 @@
|
||||
* \file htdocs/compta/facture/document.php
|
||||
* \ingroup facture
|
||||
* \brief Page for attached files on invoices
|
||||
* \version $Id$
|
||||
* \version $Id: document.php,v 1.43 2011/07/05 16:10:56 hregis Exp $
|
||||
*/
|
||||
|
||||
require("../../main.inc.php");
|
||||
@@ -38,19 +38,19 @@ $langs->load('compta');
|
||||
$langs->load('other');
|
||||
$langs->load("bills");
|
||||
|
||||
if (!$user->rights->facture->lire)
|
||||
accessforbidden();
|
||||
|
||||
$facid=empty($_GET['facid']) ? 0 : intVal($_GET['facid']);
|
||||
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
|
||||
$action = GETPOST('action');
|
||||
$confirm = GETPOST('confirm');
|
||||
$id = GETPOST('facid');
|
||||
$ref = GETPOST('ref');
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
if ($user->societe_id)
|
||||
{
|
||||
unset($_GET["action"]);
|
||||
$action='';
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
$result=restrictedArea($user,'facture',$id,'');
|
||||
|
||||
// Get parameters
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
@@ -63,6 +63,8 @@ $pagenext = $page + 1;
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
if (! $sortfield) $sortfield="name";
|
||||
|
||||
$object = new Facture($db);
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@@ -71,12 +73,11 @@ if (! $sortfield) $sortfield="name";
|
||||
// Envoi fichier
|
||||
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
||||
|
||||
$facture = new Facture($db);
|
||||
if ($facture->fetch($facid))
|
||||
if ($object->fetch($id))
|
||||
{
|
||||
$upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($facture->ref);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
|
||||
if (create_exdir($upload_dir) >= 0)
|
||||
{
|
||||
@@ -106,15 +107,13 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
}
|
||||
|
||||
// Delete
|
||||
if ($action=='delete')
|
||||
if ($action == 'confirm_deletefile' && $confirm == 'yes')
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
||||
$facture = new Facture($db);
|
||||
|
||||
$facid=$_GET["id"];
|
||||
if ($facture->fetch($facid))
|
||||
if ($object->fetch($id))
|
||||
{
|
||||
$upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($facture->ref);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
||||
dol_delete_file($file);
|
||||
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
|
||||
@@ -133,15 +132,13 @@ $id = $_GET['facid']?$_GET['facid']:$_GET['id'];
|
||||
$ref= $_GET['ref'];
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$facture = new Facture($db);
|
||||
if ($facture->fetch($id,$ref) > 0)
|
||||
if ($object->fetch($id,$ref) > 0)
|
||||
{
|
||||
$upload_dir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($facture->ref);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($facture->socid);
|
||||
$upload_dir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($object->ref);
|
||||
|
||||
$head = facture_prepare_head($facture);
|
||||
$head = facture_prepare_head($object);
|
||||
dol_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'), 0, 'bill');
|
||||
|
||||
|
||||
@@ -162,7 +159,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<td colspan="3">';
|
||||
$morehtmlref='';
|
||||
$discount=new DiscountAbsolute($db);
|
||||
$result=$discount->fetch(0,$facture->id);
|
||||
$result=$discount->fetch(0,$object->id);
|
||||
if ($result > 0)
|
||||
{
|
||||
$morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')';
|
||||
@@ -171,28 +168,37 @@ if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
dol_print_error('',$discount->error);
|
||||
}
|
||||
print $html->showrefnav($facture,'ref','',1,'facnumber','ref',$morehtmlref);
|
||||
print $html->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
|
||||
print '</td></tr>';
|
||||
|
||||
// Company
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
|
||||
|
||||
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>\n";
|
||||
print "</div>\n";
|
||||
|
||||
if ($mesg) { print $mesg."<br>"; }
|
||||
dol_htmloutput_mesg($mesg,$mesgs);
|
||||
|
||||
/*
|
||||
* Confirmation suppression fichier
|
||||
*/
|
||||
if ($action == 'delete')
|
||||
{
|
||||
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$id.'&urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
|
||||
if ($ret == 'html') print '<br>';
|
||||
}
|
||||
|
||||
|
||||
// Affiche formulaire upload
|
||||
$formfile=new FormFile($db);
|
||||
$formfile->form_attach_new_file(DOL_URL_ROOT.'/compta/facture/document.php?facid='.$facture->id,'',0,0,$user->rights->facture->creer);
|
||||
$formfile->form_attach_new_file(DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id,'',0,0,$user->rights->facture->creer);
|
||||
|
||||
|
||||
// List of document
|
||||
$param='&facid='.$facture->id;
|
||||
$formfile->list_of_documents($filearray,$facture,'facture',$param);
|
||||
$param='&facid='.$object->id;
|
||||
$formfile->list_of_documents($filearray,$object,'facture',$param);
|
||||
|
||||
}
|
||||
else
|
||||
@@ -207,5 +213,5 @@ else
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
llxFooter('$Date: 2011/07/05 16:10:56 $ - $Revision: 1.43 $');
|
||||
?>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
* - Le nom de la classe doit etre InterfaceMytrigger
|
||||
* - Le nom de la methode constructeur doit etre InterfaceMytrigger
|
||||
* - Le nom de la propriete name doit etre Mytrigger
|
||||
* \version $Id: interface_all_Demo.class.php-NORUN,v 1.26 2011/07/04 10:35:49 hregis Exp $
|
||||
* \version $Id: interface_all_Demo.class.php-NORUN,v 1.27 2011/07/05 16:10:56 hregis Exp $
|
||||
*/
|
||||
|
||||
|
||||
@@ -502,6 +502,16 @@ class InterfaceDemo
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
}
|
||||
elseif ($action == 'SHIPPINGL_DELETE')
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
}
|
||||
|
||||
// File
|
||||
elseif ($action == 'FILE_UPLOAD')
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
}
|
||||
elseif ($action == 'FILE_DELETE')
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
/**
|
||||
* \file htdocs/lib/files.lib.php
|
||||
* \brief Library for file managing functions
|
||||
* \version $Id$
|
||||
* \version $Id: files.lib.php,v 1.64 2011/07/05 16:10:57 hregis Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -454,11 +454,13 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
|
||||
* @param allowoverwrite 1=Overwrite target file if it already exists
|
||||
* @param disablevirusscan 1=Disable virus scan
|
||||
* @param uploaderrorcode Value of upload error code ($_FILES['field']['error'])
|
||||
* @param notrigger Disable all triggers
|
||||
* @return int >0 if OK, <0 or string if KO
|
||||
*/
|
||||
function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0)
|
||||
function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $notrigger=0)
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $user, $langs;
|
||||
global $object;
|
||||
|
||||
$file_name = $dest_file;
|
||||
// If an upload error has been reported
|
||||
@@ -552,6 +554,19 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
|
||||
{
|
||||
if (! empty($conf->global->MAIN_UMASK)) @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK));
|
||||
dol_syslog("Functions.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG);
|
||||
|
||||
if (! $notrigger)
|
||||
{
|
||||
$object->src_file=$dest_file;
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('FILE_UPLOAD',$object,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $errors=$interface->errors; }
|
||||
// Fin appel triggers
|
||||
}
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
@@ -568,10 +583,14 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
|
||||
* @param file File to delete or mask of file to delete
|
||||
* @param disableglob Disable usage of glob like *
|
||||
* @param nophperrors Disable all PHP output errors
|
||||
* @param notrigger Disable all triggers
|
||||
* @return boolean True if file is deleted, False if error
|
||||
*/
|
||||
function dol_delete_file($file,$disableglob=0,$nophperrors=0)
|
||||
function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
global $object;
|
||||
|
||||
//print "x".$file." ".$disableglob;
|
||||
$ok=true;
|
||||
$file_osencoded=dol_osencode($file); // New filename encoded in OS filesystem encoding charset
|
||||
@@ -581,7 +600,21 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0)
|
||||
{
|
||||
if ($nophperrors) $ok=@unlink($filename); // The unlink encapsulated by dolibarr
|
||||
else $ok=unlink($filename); // The unlink encapsulated by dolibarr
|
||||
if ($ok) dol_syslog("Removed file ".$filename,LOG_DEBUG);
|
||||
if ($ok)
|
||||
{
|
||||
dol_syslog("Removed file ".$filename,LOG_DEBUG);
|
||||
if (! $notrigger)
|
||||
{
|
||||
$object->src_file=$file;
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('FILE_DELETE',$object,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $errors=$interface->errors; }
|
||||
// Fin appel triggers
|
||||
}
|
||||
}
|
||||
else dol_syslog("Failed to remove file ".$filename,LOG_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* \file htdocs/societe/document.php
|
||||
* \brief Tab for documents linked to third party
|
||||
* \ingroup societe
|
||||
* \version $Id: document.php,v 1.31 2011/07/03 13:16:46 hregis Exp $
|
||||
* \version $Id: document.php,v 1.32 2011/07/05 16:10:56 hregis Exp $
|
||||
*/
|
||||
|
||||
require("../main.inc.php");
|
||||
@@ -35,10 +35,13 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
|
||||
$langs->load("companies");
|
||||
$langs->load('other');
|
||||
|
||||
$mesg = "";
|
||||
$mesg='';
|
||||
|
||||
$action = GETPOST('action');
|
||||
$confirm = GETPOST('confirm');
|
||||
$socid = (GETPOST('socid') ? GETPOST('socid') : GETPOST('id'));
|
||||
|
||||
// Security check
|
||||
$socid = (GETPOST('socid') ? GETPOST('socid') : GETPOST('id'));
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
unset($_GET["action"]);
|
||||
@@ -70,48 +73,54 @@ $object = new Societe($db);
|
||||
// Envoie fichier
|
||||
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
if (create_exdir($upload_dir) >= 0)
|
||||
if ($object->fetch($socid))
|
||||
{
|
||||
$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 (create_exdir($upload_dir) >= 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");
|
||||
$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 = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
if (is_numeric($resupload) && $resupload < 0) // Unknown error
|
||||
{
|
||||
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
|
||||
// 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 = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
|
||||
}
|
||||
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
|
||||
}
|
||||
else // Known error
|
||||
{
|
||||
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
|
||||
$langs->load("errors");
|
||||
if (is_numeric($resupload) && $resupload < 0) // Unknown error
|
||||
{
|
||||
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
|
||||
}
|
||||
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
|
||||
{
|
||||
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
|
||||
}
|
||||
else // Known error
|
||||
{
|
||||
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Suppression fichier
|
||||
if ($_REQUEST['action'] == 'confirm_deletefile' && $_REQUEST['confirm'] == 'yes')
|
||||
if ($action == 'confirm_deletefile' && $confirm == 'yes')
|
||||
{
|
||||
$file = $upload_dir . "/" . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
||||
dol_delete_file($file);
|
||||
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
|
||||
if ($object->fetch($socid))
|
||||
{
|
||||
$file = $upload_dir . "/" . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
||||
dol_delete_file($file);
|
||||
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -195,15 +204,15 @@ if ($socid > 0)
|
||||
/*
|
||||
* Confirmation suppression fichier
|
||||
*/
|
||||
if ($_GET['action'] == 'delete')
|
||||
if ($action == 'delete')
|
||||
{
|
||||
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?socid='.$_GET["id"].'&urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
|
||||
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?socid='.$socid.'&urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
|
||||
if ($ret == 'html') print '<br>';
|
||||
}
|
||||
|
||||
$formfile=new FormFile($db);
|
||||
|
||||
if ($conf->global->MAIN_USE_JQUERY_FILEUPLOAD)
|
||||
if (1==2 && $conf->global->MAIN_USE_JQUERY_FILEUPLOAD)
|
||||
{
|
||||
$formfile->form_ajaxfileupload($object);
|
||||
}
|
||||
@@ -280,6 +289,6 @@ else
|
||||
$db->close();
|
||||
|
||||
|
||||
llxFooter('$Date: 2011/07/03 13:16:46 $ - $Revision: 1.31 $');
|
||||
llxFooter('$Date: 2011/07/05 16:10:56 $ - $Revision: 1.32 $');
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user