Merge pull request #1284 from GPCsolutions/links

Links
This commit is contained in:
Laurent Destailleur 2013-11-06 17:15:49 -08:00
commit b2308ba65c
24 changed files with 859 additions and 547 deletions

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -60,47 +61,31 @@ if (! $sortfield) $sortfield="name";
$upload_dir = $conf->adherent->dir_output . "/" . get_exdir($id,2,0,1) . '/' . $id;
$form = new Form($db);
$object=new Adherent($db);
$membert=new AdherentType($db);
$result=$object->fetch($id);
if ($result < 0)
{
dol_print_error($db);
exit;
}
/*
* Actions
*/
// Envoie fichier
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_add_file_process($upload_dir,0,1,'userfile');
}
// Suppression fichier
if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
$langs->load("other");
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
* View
*/
$form = new Form($db);
$object=new Adherent($db);
$membert=new AdherentType($db);
llxHeader();
if ($id > 0)
{
$result=$object->fetch($id);
$result=$membert->fetch($object->typeid);
if ($result > 0)
{
@ -180,23 +165,10 @@ if ($id > 0)
print '</div>';
/*
* Confirmation suppression fichier
*/
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
}
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/adherents/document.php?id='.$object->id,'',0,0,$user->rights->adherent->creer,50,$object);
// List of document
$formfile->list_of_documents($filearray,$object,'member','', 0, get_exdir($object->id,2,0,1).'/'.$object->id.'/');
$modulepart = 'member';
$permission = $user->rights->adherent->creer;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
print "<br><br>";
}
else

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -40,8 +41,9 @@ $langs->load("commercial");
$langs->load("other");
$langs->load("bills");
$objectid = GETPOST('id','int');
$action=GETPOST('action','alpha');
$objectid = GETPOST('id', 'int');
$action=GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
// Security check
$socid = GETPOST('socid','int');
@ -79,26 +81,9 @@ if (! $sortfield) $sortfield="name";
/*
* Action envoie fichier
* Actions
*/
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
$upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($objectid);
dol_add_file_process($upload_dir,0,1,'userfile');
}
/*
* Efface fichier
*/
if ($action == 'delete')
{
$upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($objectid);
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$act);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
$action='';
}
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
@ -268,15 +253,10 @@ if ($act->id > 0)
print '</div>';
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/action/document.php?id='.$act->id,'',0,0,($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create),50,$act);
// List of document
$param='&id='.$act->id;
$formfile->list_of_documents($filearray,$act,'actions',$param,0,'',$user->rights->agenda->myactions->create);
$modulepart = 'actions';
$permission = $user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create;
$param = '&id=' . $act->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else
{

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -64,38 +65,14 @@ $object->fetch($id,$ref);
if ($object->id > 0)
{
$object->fetch_thirdparty();
$upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
}
/*
* Actions
*/
// Envoi fichier
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
if ($object->id > 0)
{
$upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
dol_add_file_process($upload_dir,0,1,'userfile');
}
}
// Delete
if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($object->id > 0)
{
$langs->load("other");
$upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
}
/*
@ -153,21 +130,10 @@ if ($object->id > 0)
print '</div>';
/*
* Confirmation suppression fichier
*/
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
}
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id,'',0,0,$user->rights->propal->creer,50,$object);
// List of document
$formfile->list_of_documents($filearray,$object,'propal');
$modulepart = 'propal';
$permission = $user->rights->propal->creer;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else
{

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -65,35 +66,13 @@ $object = new Commande($db);
/*
* Actions
*/
// Envoi fichier
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
if ($object->fetch($id))
{
if ($object->fetch($id))
{
$object->fetch_thirdparty();
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
dol_add_file_process($upload_dir,0,1,'userfile');
}
$object->fetch_thirdparty();
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
}
// Delete
else if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($object->fetch($id))
{
$langs->load("other");
$object->fetch_thirdparty();
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
}
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
@ -107,10 +86,10 @@ $form = new Form($db);
if ($id > 0 || ! empty($ref))
{
if ($object->fetch($id, $ref))
{
$object->fetch_thirdparty();
{
$object->fetch_thirdparty();
$upload_dir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($object->ref);
$upload_dir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($object->ref);
$head = commande_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), 0, 'order');
@ -140,23 +119,10 @@ if ($id > 0 || ! empty($ref))
print "</table>\n";
print "</div>\n";
/*
* Confirmation suppression fichier
*/
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
}
// 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,50,$object);
// List of document
$param='&id='.$object->id;
$formfile->list_of_documents($filearray,$object,'commande',$param);
$modulepart = 'commande';
$permission = $user->rights->commande->creer;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else
{

View File

@ -5,6 +5,7 @@
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -71,29 +72,7 @@ $modulepart='trip';
* Actions
*/
if (GETPOST('sendit','alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_add_file_process($upload_dir,0,1,'userfile');
}
// Delete
else if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($object->id > 0)
{
$langs->load("other");
$object->fetch_thirdparty();
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
}
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
@ -141,23 +120,10 @@ if ($object->id)
print '</div>';
/*
* Confirmation suppression fichier
*/
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
}
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/compta/deplacement/document.php?id='.$object->id,'',0,0,$user->rights->deplacement->creer,50,$object);
// List of document
$param='&id='.$object->id;
$formfile->list_of_documents($filearray,$object,'deplacement',$param);
$modulepart = 'deplacement';
$permission = $user->rights->deplacement->creer;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -64,40 +65,17 @@ if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
$object = new Facture($db);
if ($object->fetch($id))
{
$object->fetch_thirdparty();
$upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref);
}
/*
* Actions
*/
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
// Envoi fichier
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
if ($object->fetch($id))
{
$object->fetch_thirdparty();
$upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref);
dol_add_file_process($upload_dir,0,1,'userfile');
}
}
// Delete
if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($object->fetch($id))
{
$langs->load("other");
$object->fetch_thirdparty();
$upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
}
/*
* View
@ -169,24 +147,10 @@ if ($id > 0 || ! empty($ref))
print "</table>\n";
print "</div>\n";
/*
* Confirmation suppression fichier
*/
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
}
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id,'',0,0,$user->rights->facture->creer,50,$object);
// List of document
$param='&facid='.$object->id;
$formfile->list_of_documents($filearray,$object,'facture',$param);
$modulepart = 'facture';
$permission = $user->rights->facture->creer;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else

View File

@ -5,6 +5,7 @@
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -40,6 +41,7 @@ $langs->load("bills");
$id = GETPOST('id','int');
$action = GETPOST("action");
$confirm = GETPOST('confirm', 'alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
@ -71,18 +73,7 @@ $modulepart='tax';
* Actions
*/
if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
dol_add_file_process($upload_dir,0,1,'userfile');
}
if ($action == 'delete')
{
$file = $upload_dir . '/' . GETPOST("urlfile"); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
}
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
@ -169,16 +160,10 @@ if ($object->id)
print '</div>';
// 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,50,$object);
// List of document
//$param='&id='.$object->id;
$formfile->list_of_documents($filearray,$object,'tax',$param);
$modulepart = 'tax';
$permission = $user->rights->tax->charges->creer;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else
{

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -74,28 +75,9 @@ $modulepart='contract';
/*
* Action envoie fichier
* Actions
*/
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
dol_add_file_process($upload_dir,0,1,'userfile');
}
// Delete
if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($object->id)
{
$langs->load("other");
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
}
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
@ -140,24 +122,10 @@ if ($object->id)
print '</div>';
/*
* Confirmation suppression fichier
*/
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
}
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id,'',0,0,$user->rights->contrat->creer,50,$object);
// List of document
$param='&id='.$object->id;
$formfile->list_of_documents($filearray,$object,'contract',$param);
$modulepart = 'contract';
$permission = $user->rights->contrat->creer;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else

View File

@ -3,6 +3,7 @@
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (c) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (c) 2013 Charles-Fr BENKE <charles.fr@benke.fr>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -155,6 +156,30 @@ class FormFile
if (empty($sectionid)) $out .= '<br>';
$out .= "\n<!-- End form attach new file -->\n\n";
$langs->load('link');
$title = $langs->trans("LinkANewFile");
$out .= load_fiche_titre($title, null, null);
$out .= '<form name="formuserfile" action="'.$url.'" method="POST">';
$out .= '<input type="hidden" id="formuserfile_section_dir" name="section_dir" value="">';
$out .= '<input type="hidden" id="formuserfile_section_id" name="section_id" value="'.$sectionid.'">';
$out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$out .= '<table width="100%" class="nobordernopadding">';
$out .= '<tr>';
$out .= '<td valign="middle" class="nowrap">';
$out .= $langs->trans("Link") . ': ';
$out .= '<input type="text" name="link" id="link">';
$out .= ' &nbsp; ' . $langs->trans("Label") . ': ';
$out .= '<input type="text" name="label" id="label">';
$out .= '<input type="hidden" name="objecttype" value="' . $object->element . '">';
$out .= '<input type="hidden" name="objectid" value="' . $object->id . '">';
$out .= '<input type="submit" class="button" name="linkit" value="'.$langs->trans("Upload").'"';
$out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled="disabled"':'');
$out .= '>';
$out .= '</td></tr>';
$out .= '</table>';
$out .= '</form><br>';
$parameters = array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''), 'url'=>$url, 'perm'=>$perm);
$res = $hookmanager->executeHooks('formattachOptions',$parameters,$object);
if (empty($res))
@ -993,6 +1018,126 @@ class FormFile
include DOL_DOCUMENT_ROOT.'/core/tpl/ajax/fileupload_view.tpl.php';
}
public function listOfLinks($object, $permtodelete=1, $action=null, $selected=null)
{
global $user, $conf, $langs, $user;
global $bc;
global $sortfield, $sortorder;
require_once DOL_DOCUMENT_ROOT . '/link/class/link.class.php';
$link = new Link($this->db);
$links = array();
if ($sortfield == "name") {
$sortfield = "label";
} elseif ($sortfield == "date") {
$sortfield = "datea";
} else {
$sortfield = null;
}
$res = $link->fetchAll($links, $object->element, $object->id, $sortfield, $sortorder);
$param = (isset($object->id)?'&id=' . $object->id : '');
// Show list of associated links
print_titre($langs->trans("LinkedFiles"));
print '<table width="100%" class="liste">';
print '<tr class="liste_titre">';
print_liste_field_titre(
$langs->trans("Documents2"),
$_SERVER['PHP_SELF'],
"name",
"",
$param,
'align="left"',
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans("Size"),
"",
"",
"",
"",
'align="right"'
);
print_liste_field_titre(
$langs->trans("Date"),
$_SERVER['PHP_SELF'],
"date",
"",
$param,
'align="center"',
$sortfield,
$sortorder
);
print_liste_field_titre(
'',
$_SERVER['PHP_SELF'],
"",
"",
$param,
'align="center"'
);
print_liste_field_titre('','','');
print '</tr>';
$nboflinks = count($links);
if ($nboflinks > 0) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
}
$var = true;
foreach ($links as $link) {
$var =! $var;
print '<tr ' . $bc[$var] . '>';
//edit mode
if ($action == 'update' && $selected === $link->id) {
print '<form action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '" method="post">';
print '<input type="hidden" name="linkid" value="' . $link->id . '">';
print '<input type="hidden" name="action" value="confirm_updateline">';
print '<td>';
print $langs->trans('Link') . ': <input type="text" name="link" value = "' . $link->url . '">';
print '</td>';
print '<td align="right">';
print $langs->trans('Label') . ': <input type="text" name="label" value = "' . $link->label . '">';
print '</td>';
print '<td align="center">' . dol_print_date(dol_now(), "dayhour", "tzuser") . '</td>';
print '<td align="right"></td>';
print '<td align="right" colspan="2"><input type="submit" name="save" class="button" value="' . $langs->trans('Save') . '">';
print '<input type="submit" name="cancel" class="button" value="' . $langs->trans('Cancel') . '"></td>';
print '</form>';
}
else {
print '<td>';
print '<a data-ajax="false" href="'. $link->url . '" target="_blank">';
print $link->label;
print '</a>';
print "</td>\n";
print '<td align="right"></td>';
print '<td align="center">' . dol_print_date($link->datea, "dayhour", "tzuser") . '</td>';
print '<td align="center"></td>';
print '<td align="right" colspan="2">';
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=update&linkid=' . $link->id
. '&id=' . $object->id . '" class="editfilelink" >' . img_edit().'</a>';
if ($permtodelete) {
print '<a href="'. $_SERVER['PHP_SELF'] .'?action=delete&linkid=' . $link->id
. '&id=' . $object->id . '" class="deletefilelink" >' . img_delete() . '</a>';
} else {
print '&nbsp;';
}
print "</td>";
}
print "</tr>\n";
}
if ($nboflinks == 0) {
print '<tr ' . $bc[$var] . '><td colspan="4">';
print $langs->trans("NoLinkFound");
print '</td></tr>';
}
print "</table>";
return $nboflinks;
}
}

View File

@ -995,9 +995,10 @@ function dol_init_file_process($pathtoscan='')
* @param int $donotupdatesession 1=Do no edit _SESSION variable
* @param string $varfiles _FILES var name
* @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
* @param string $link Link to add
* @return void
*/
function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesession=0, $varfiles='addedfile', $savingdocmask='')
function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesession=0, $varfiles='addedfile', $savingdocmask='', $link=null)
{
global $db,$user,$conf,$langs;
@ -1054,6 +1055,23 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
}
}
}
} elseif ($link) {
if (dol_mkdir($upload_dir) >= 0) {
require_once DOL_DOCUMENT_ROOT . '/link/class/link.class.php';
$linkObject = new Link($db);
$linkObject->entity = $conf->entity;
$linkObject->url = $link;
$linkObject->objecttype = GETPOST('objecttype', 'alpha');
$linkObject->objectid = GETPOST('objectid', 'int');
$linkObject->label = GETPOST('label', 'alpha');
$res = $linkObject->create($user);
$langs->load('link');
if ($res > 0) {
setEventMessage($langs->trans("LinkComplete"));
} else {
setEventMessage($langs->trans("ErrorFileNotLinked"), 'errors');
}
}
}
else
{

View File

@ -0,0 +1,63 @@
<?php
/* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 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 <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/*
* Confirm suppression
*/
if ($action == 'delete') {
$ret = $form->form_confirm(
$_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode(GETPOST("urlfile")) . '&linkid=' . GETPOST('linkid', 'int'),
$langs->trans('DeleteFile'),
$langs->trans('ConfirmDeleteFile'),
'confirm_deletefile',
'',
0,
1
);
if ($ret == 'html') print '<br>';
}
$formfile=new FormFile($db);
// Show upload form
$formfile->form_attach_new_file(
$_SERVER["PHP_SELF"].'?id='.$object->id,
'',
0,
0,
$permission,
50,
$object
);
// List of document
$formfile->list_of_documents(
$filearray,
$object,
$modulepart,
$param,
0,
'',
$permission
);
print "<br>";
//List of links
$formfile->listOfLinks($object, $permission, $action, GETPOST('linkid', 'int'));
print "<br>";

View File

@ -0,0 +1,88 @@
<?php
/* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 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 <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
// Send file/link
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) {
if ($object->id) {
dol_add_file_process($upload_dir, 0, 1, 'userfile');
}
} elseif (GETPOST('linkit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) {
if ($object->id) {
$link = GETPOST('link', 'alpha');
if ($link) {
if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://') {
$link = 'http://' . $link;
}
dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link);
}
}
}
// Delete file/link
if ($action == 'confirm_deletefile' && $confirm == 'yes') {
if ($object->id) {
$urlfile = GETPOST('urlfile', 'alpha');
$linkid = GETPOST('linkid', 'int');
if ($urlfile) {
$file = $upload_dir . "/" . $urlfile; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret) {
setEventMessage($langs->trans("FileWasRemoved", $urlfile));
} else {
setEventMessage($langs->trans("ErrorFailToDeleteFile", $urlfile), 'errors');
}
} elseif ($linkid) {
require_once DOL_DOCUMENT_ROOT . '/link/class/link.class.php';
$link = new Link($db);
$link->id = $linkid;
$link->fetch();
$res = $link->delete($user);
$langs->load('link');
if ($res) {
setEventMessage($langs->trans("LinkRemoved", $link->label));
} else {
setEventMessage($langs->trans("ErrorFailedToDeleteLink", $link->label), 'errors');
}
}
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
exit;
}
} elseif ($action == 'confirm_updateline' && GETPOST('save') && GETPOST('link', 'alpha')) {
require_once DOL_DOCUMENT_ROOT . '/link/class/link.class.php';
$langs->load('link');
$link = new Link($db);
$link->id = GETPOST('linkid', 'int');
$f = $link->fetch();
if ($f) {
$link->url = GETPOST('link', 'alpha');
if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://') {
$link->url = 'http://' . $link->url;
}
$link->label = GETPOST('label', 'alpha');
$res = $link->update($user);
if (!$res) {
setEventMessage($langs->trans("ErrorFailedToUpdateLink", $link->label));
}
} else {
//error fetching
}
}

View File

@ -5,6 +5,7 @@
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -71,29 +72,7 @@ $modulepart='fichinter';
* Actions
*/
if (GETPOST('sendit','alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_add_file_process($upload_dir,0,1,'userfile');
}
// Delete
else if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($object->id > 0)
{
$langs->load("other");
$object->fetch_thirdparty();
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
}
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
@ -141,23 +120,10 @@ if ($object->id)
print '</div>';
/*
* Confirmation suppression fichier
*/
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
}
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id,'',0,0,$user->rights->ficheinter->creer,50,$object);
// List of document
$param='&id='.$object->id;
$formfile->list_of_documents($filearray,$object,'ficheinter',$param);
$modulepart = 'ficheinter';
$permission = $user->rights->ficheinter->creer;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -77,26 +78,7 @@ $object->fetch_thirdparty();
* Actions
*/
// Envoi fichier
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
dol_add_file_process($upload_dir,0,1,'userfile');
}
else if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($object->id > 0)
{
$langs->load("other");
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
}
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
@ -176,23 +158,11 @@ if ($object->id > 0)
print "</div>\n";
/*
* Confirmation suppression fichier
*/
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
}
$modulepart = 'commande_fournisseur';
$permission = $user->rights->fournisseur->commande->creer;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id,'',0,0,$user->rights->fournisseur->commande->creer,50,$object);
// List of document
$param='&id='.$object->id;
$formfile->list_of_documents($filearray,$object,'commande_fournisseur',$param);
}
else
{

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -71,29 +72,7 @@ if ($object->fetch($id, $ref))
* Actions
*/
// Envoi fichier
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
if ($object->id > 0)
{
dol_add_file_process($upload_dir, 0, 1, 'userfile', GETPOST('savingdocmask'));
}
}
// Delete
else if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($object->id > 0)
{
$langs->load("other");
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
}
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
@ -198,17 +177,10 @@ if ($object->id > 0)
print '</table>';
print '</div>';
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?facid='.$object->id, '', 0, 0, $user->rights->fournisseur->facture->creer, 50, $object, '', 0, dol_sanitizeFileName($object->ref.'_'.$object->ref_supplier.'___file__'));
// List of document
$param='&facid='.$object->id;
$ref=dol_sanitizeFileName($object->ref);
$formfile->list_of_documents($filearray,$object,'facture_fournisseur',$param,0,get_exdir($object->id,2,0).$ref.'/');
$modulepart = 'facture_fournisseur';
$permission = $user->rights->fournisseur->facture->creer;
$param = '&facid=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else
{
@ -218,4 +190,4 @@ else
llxFooter();
$db->close();
?>
?>

View File

@ -90,6 +90,17 @@ create table llx_categorie_contact
import_key varchar(14)
)ENGINE=innodb;
create table llx_links
(
rowid INTEGER AUTO_INCREMENT PRIMARY KEY,
entity INTEGER DEFAULT 1 NOT NULL, -- multi company id
datea DATETIME NOT NULL, -- date start
url VARCHAR(255) NOT NULL, -- link url
label VARCHAR(255) NOT NULL, -- link label
objecttype VARCHAR(255) NOT NULL, -- object type in Dolibarr
objectid INTEGER NOT NULL
)ENGINE=innodb;
ALTER TABLE llx_categorie_contact ADD PRIMARY KEY pk_categorie_contact (fk_categorie, fk_socpeople);
ALTER TABLE llx_categorie_contact ADD INDEX idx_categorie_contact_fk_categorie (fk_categorie);

View File

@ -0,0 +1,30 @@
-- ========================================================================
-- Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 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 <http://www.gnu.org/licenses/>.
--
--
-- Actions commerciales
-- ========================================================================
create table llx_links
(
rowid INTEGER AUTO_INCREMENT PRIMARY KEY,
entity INTEGER DEFAULT 1 NOT NULL, -- multi company id
datea DATETIME NOT NULL, -- date start
url VARCHAR(255) NOT NULL, -- link url
label VARCHAR(255) NOT NULL, -- link label
objecttype VARCHAR(255) NOT NULL, -- object type in Dolibarr
objectid INTEGER NOT NULL
)ENGINE=innodb;

View File

@ -0,0 +1,8 @@
LinkANewFile=Link a new file/document
LinkedFiles=Linked files and documents
NoLinkFound=No registered links
LinkComplete=The file has been linked successfully
ErrorFileNotLinked=The file could not be linked
LinkRemoved=The link %s has been removed
ErrorFailedToDeleteLink= Failed to remove link '<b>%s</b>'
ErrorFailedToUpdateLink= Failed to update link '<b>%s</b>'

View File

@ -0,0 +1,9 @@
CHARSET=UTF-8
LinkANewFile=Lier un nouveau fichier/document
LinkedFiles=Fichiers et documents liés
NoLinkFound=Aucun lien associé
LinkComplete=Le fichier a été correctement lié
ErrorFileNotLinked=Le fichier n'a pas pu être lié
LinkRemoved=Le lien %s a été supprimé
ErrorFailedToDeleteLink= Impossible de supprimer le lien '<b>%s</b>'
ErrorFailedToUpdateLink= Impossible de modifier le lien '<b>%s</b>'

View File

@ -0,0 +1,365 @@
<?php
/* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/link/class/link.class.php
* \ingroup link
* \brief File for link class
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
/**
* Class to manage links
*/
class Link extends CommonObject
{
public $element = 'link';
public $table_element = 'links';
public $id;
public $entity;
public $datea;
public $url;
public $label;
public $objecttype;
public $objectid;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
global $conf;
$this->db = $db;
return 1;
}
/**
* Create link in database
*
* @param User $user Object of user that ask creation
* @return int >= 0 if OK, < 0 if KO
*/
public function create($user='')
{
global $langs,$conf;
$error=0;
$langs->load("errors");
// Clean parameters
if (empty($this->label)) {
$this->label = trim(basename($this->url));
}
if (empty($this->datea)) {
$this->datea = dol_now();
}
$this->url = trim($this->url);
dol_syslog(get_class($this)."::create ".$this->url);
// Check parameters
if (empty($this->url)) {
$this->error = $langs->trans("NoUrl");
return -1;
}
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."links (entity, datea, url, label, objecttype, objectid)";
$sql .= " VALUES ('".$conf->entity."', '".$this->db->idate($this->datea)."'";
$sql .= ", '" . $this->db->escape($this->url) . "'";
$sql .= ", '" . $this->db->escape($this->label) . "'";
$sql .= ", '" . $this->objecttype . "'";
$sql .= ", " . $this->objectid . ")";
dol_syslog(get_class($this)."::create sql=".$sql);
$result = $this->db->query($sql);
if ($result) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "links");
if ($this->id > 0) {
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('LINK_CREATE', $this, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
} else {
$error++;
}
if (! $error)
{
dol_syslog(get_class($this)."::Create success id=" . $this->id);
$this->db->commit();
return $this->id;
}
else
{
dol_syslog(get_class($this)."::Create echec update " . $this->error, LOG_ERR);
$this->db->rollback();
return -3;
}
}
else
{
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$this->error=$langs->trans("ErrorCompanyNameAlreadyExists",$this->name);
$result=-1;
}
else
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::Create fails insert sql=".$sql, LOG_ERR);
$result=-2;
}
$this->db->rollback();
return $result;
}
}
/**
* Update parameters of third party
*
* @param User $user User executing update
* @param int $call_trigger 0=no, 1=yes
* @return int <0 if KO, >=0 if OK
*/
public function update($user='', $call_trigger=1)
{
global $langs,$conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$langs->load("errors");
$error=0;
dol_syslog(get_class($this)."::Update id = " . $this->id . " call_trigger = " . $call_trigger);
// Check parameters
if (empty($this->url)) {
$this->error = $langs->trans("NoURL");
return -1;
}
// Clean parameters
$this->url = clean_url($this->url,0);
if(empty($this->label)) {
$this->label = basename($this->url);
}
$this->label = trim($this->label);
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "links SET ";
$sql .= "entity = '" . $conf->entity ."'";
$sql .= ", datea = '" . $this->db->idate(dol_now()) . "'";
$sql .= ", url = '" . $this->db->escape($this->url) . "'";
$sql .= ", label = '" . $this->db->escape($this->label) . "'";
$sql .= ", objecttype = '" . $this->objecttype . "'";
$sql .= ", objectid = " . $this->objectid;
$sql .= " WHERE rowid = '" . $this->id ."'";
dol_syslog(get_class($this)."::Update sql = " .$sql);
$resql = $this->db->query($sql);
if ($resql)
{
if ($call_trigger) {
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('LINK_MODIFY', $this, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
}
if (! $error) {
dol_syslog(get_class($this) . "::Update success");
$this->db->commit();
return 1;
} else {
$this->db->rollback();
return -1;
}
} else {
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
// Doublon
$this->error = $langs->trans("ErrorDuplicateField");
$result = -1;
} else {
$this->error = $langs->trans("Error sql = " . $sql);
dol_syslog(get_class($this) . "::Update fails update sql = " . $sql, LOG_ERR);
$result = -2;
}
$this->db->rollback();
return $result;
}
}
/**
* Loads all links from database
*
* @param array &$links array of Link objects to fill
* @param string $objecttype type of the associated object in dolibarr
* @param int $objectid id of the associated object in dolibarr
* @param string $sortfield field used to sort
* @param string $sortorder sort order
* @return 1 if ok, 0 if no records, -1 if error
*
* */
public function fetchAll(&$links, $objecttype, $objectid, $sortfield=null, $sortorder=null)
{
global $conf;
$sql = "SELECT rowid, entity, datea, url, label , objecttype, objectid FROM " . MAIN_DB_PREFIX . "links";
$sql .= " WHERE objecttype = '" . $objecttype . "' AND objectid = " . $objectid;
if($conf->entity != 0) $sql .= " AND entity = " . $conf->entity;
if ($sortfield) {
if (empty($sortorder)) {
$sortorder = "ASC";
}
$sql .= " ORDER BY " . $sortfield . " " . $sortorder;
}
$resql = $this->db->query($sql);
dol_syslog(get_class($this)."::fetchAll " . $sql, LOG_DEBUG);
if ($resql) {
$num = $this->db->num_rows($resql);
dol_syslog(get_class($this)."::fetchAll " . $num . "records", LOG_DEBUG);
if ($num > 0) {
while ($obj = $this->db->fetch_object($resql)) {
$link = new Link($db);
$link->id = $obj->rowid;
$link->entity = $obj->entity;
$link->datea = $this->db->jdate($obj->datea);
$link->url = $obj->url;
$link->label = $obj->label;
$link->objecttype = $obj->objecttype;
$link->objectid = $obj->objectid;
$links[] = $link;
}
return 1;
} else {
return 0;
}
} else {
dol_syslog(get_class($this) . "::FetchAll fails sql=" . $sql, LOG_ERR);
return -1;
}
}
/*
* Loads a link from database
* @param rowid id of link to load
* @return int 1 if ok, 0 if no record found, -1 if error
*
* */
public function fetch($rowid=null)
{
global $conf;
if (empty($rowid)) {
$rowid = $this->id;
}
$sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM " . MAIN_DB_PREFIX . "links";
$sql .= " WHERE rowid = " . $rowid;
if($conf->entity != 0) $sql .= " AND entity = " . $conf->entity;
$resql = $this->db->query($sql);
dol_syslog(get_class($this)."::fetch " . $sql, LOG_DEBUG);
if ($resql) {
if($this->db->num_rows($resql) > 0) {
$obj = $this->db->fetch_object($resql);
$this->entity = $obj->entity;
$this->datea = $this->db->jdate($obj->datea);
$this->url = $obj->url;
$this->label = $obj->label;
$this->objecttype = $obj->objecttype;
$this->objectid = $obj->objectid;
return 1;
} else {
$this->error = 'Fetch no link found for id = ' . $rowid;
dol_syslog($this->error, LOG_ERR);
return 0;
}
} else {
dol_syslog($this->db->error(), LOG_ERR);
$this->error=$this->db->error();
return -1;
}
}
/**
* Delete a link from database
*
* @return int <0 if KO, 0 if nothing done, >0 if OK
*/
public function delete()
{
global $user, $langs, $conf;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$error = 0;
$this->db->begin();
// Remove link
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "links";
$sql.= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this)."::delete sql=" . $sql, LOG_DEBUG);
if (! $this->db->query($sql)) {
$error++;
$this->error = $this->db->lasterror();
dol_syslog(get_class($this)."::delete error -4 " . $this->error, LOG_ERR);
}
if (! $error) {
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result = $interface->run_triggers('LINK_DELETE', $this, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
}
if (! $error) {
$this->db->commit();
return 1;
} else {
$this->db->rollback();
return -1;
}
}
}

View File

@ -5,6 +5,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -80,22 +81,7 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);
* Action envoie fichier
*/
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
dol_add_file_process($upload_dir,0,1,'userfile');
}
// Delete
if ($action=='delete')
{
$langs->load("other");
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
@ -154,15 +140,10 @@ if ($object->id)
print '</div>';
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/product/document.php?id='.$object->id,'',0,0,($user->rights->produit->creer||$user->rights->service->creer),50,$object);
// List of document
$formfile->list_of_documents($filearray,$object,'produit');
$modulepart = 'produit';
$permission = $user->rights->produit->creer;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else
{

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -49,6 +50,7 @@ $object->fetch($id,$ref);
if ($object->id > 0)
{
$object->fetch_thirdparty();
$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
}
// Get parameters
@ -68,25 +70,7 @@ if (! $sortfield) $sortfield="name";
* Actions
*/
// Envoi fichier
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
dol_add_file_process($upload_dir,0,1,'userfile');
}
// Delete
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->projet->supprimer)
{
$langs->load("other");
$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
@ -120,11 +104,6 @@ if ($object->id > 0)
$totalsize+=$file['size'];
}
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&urlfile=".urlencode(GETPOST("urlfile")),$langs->trans("DeleteAFile"),$langs->trans("ConfirmDeleteAFile"),"confirm_delete",'','',1);
}
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/liste.php">'.$langs->trans("BackToList").'</a>';
@ -165,14 +144,10 @@ if ($object->id > 0)
print "</table>\n";
print "</div>\n";
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/projet/document.php?id='.$object->id,'',0,0,($userWrite>0),50,$object);
// List of document
$param='&id='.$object->id;
$formfile->list_of_documents($filearray,$object,'projet',$param,0,'',($userWrite>0));
$modulepart = 'projet';
$permission = ($userWrite > 0);
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else

View File

@ -1,7 +1,8 @@
<?php
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2012 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -107,23 +108,7 @@ if ($id > 0 || ! empty($ref))
}
}
// Envoi fichier
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
dol_add_file_process($upload_dir,0,1,'userfile');
}
// Delete
if ($action=='delete')
{
$langs->load("other");
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
* View
@ -244,15 +229,10 @@ if ($object->id > 0)
print '<br>';
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.($withproject?'&withproject=1':''),'',0,0,$user->rights->projet->creer,50,$object);
// List of document
$param='&id='.$object->id;
$formfile->list_of_documents($filearray,$object,'projet',$param,0,dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref).'/');
$modulepart = 'projet';
$permission = $user->rights->projet->creer;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else
{

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
@ -72,31 +73,7 @@ if ($id > 0 || ! empty($ref))
* Actions
*/
// TODO Use an include to mutualize this code for action sendit and confirm_deletefile
// Post file
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
if ($object->id)
{
dol_add_file_process($upload_dir,0,1,'userfile');
}
}
// Delete file
if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($object->id)
{
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
}
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
@ -172,23 +149,10 @@ if ($object->id)
print '</div>';
/*
* Confirmation suppression fichier
*/
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
}
$formfile=new FormFile($db);
// Show upload form
$formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?id='.$object->id,'',0,0,$user->rights->societe->creer,50,$object);
// List of document
$formfile->list_of_documents($filearray,$object,'societe');
print "<br><br>";
$modulepart = 'societe';
$permission = $user->rights->societe->creer;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else
{