From 0a75367a7415f40505fd95ed5847a0257420ff33 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Jun 2012 17:49:52 +0200 Subject: [PATCH] New: Auto ecm for third parties --- htdocs/core/ajax/ajaxdirpreview.php | 11 ++++++----- htdocs/core/class/html.formfile.class.php | 12 ++++++++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 9bdf51d701e..b18e4eec3ed 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -31,7 +31,8 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! isset($mode) || $mode != 'noajax') + +if (! isset($mode) || $mode != 'noajax') // For ajax call { require_once("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); @@ -54,7 +55,7 @@ if (! isset($mode) || $mode != 'noajax') exit; } } -else +else // For no ajax call { $ecmdir = new EcmDirectory($db); $relativepath=''; @@ -124,11 +125,11 @@ if (! dol_is_dir($upload_dir)) } print ''."\n"; -print ''."\n"; +print ''."\n"; $param=''; -// Dir +// Dir scan if ($type == 'directory') { $formfile=new FormFile($db); @@ -136,7 +137,7 @@ if ($type == 'directory') $param.=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:''); $maxlengthname=40; - // Right area + // Right area. If module is defined, we are in automatic ecm. if ($module == 'company') // Auto area for suppliers invoices { $upload_dir = $conf->societe->dir_output; // TODO change for multicompany sharing diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index ec7a11d50d2..50acedcac24 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -650,6 +650,8 @@ class FormFile global $bc; global $sortfield, $sortorder; + dol_syslog(get_class($this).'::list_of_autoecmfiles upload_dir='.$upload_dir.' modulepart='.$modulepart); + // Affiche liste des documents existant if (empty($useinecm)) print_titre($langs->trans("AttachedFiles")); //else { $bc[true]=''; $bc[false]=''; }; @@ -666,7 +668,12 @@ class FormFile print ''; // To show ref or specific information according to view to show (defined by $module) - if ($modulepart == 'invoice') + if ($modulepart == 'company') + { + include_once(DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'); + $object_instance=new Societe($this->db); + } + else if ($modulepart == 'invoice') { include_once(DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'); $object_instance=new Facture($this->db); @@ -718,6 +725,7 @@ class FormFile $id=0; $ref=''; $label=''; // To show ref or specific information according to view to show (defined by $module) + if ($modulepart == 'company') { preg_match('/(\d+)\/[^\/]+$/',$relativefile,$reg); $id=$reg[1]; } if ($modulepart == 'invoice') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=$reg[1]; } if ($modulepart == 'invoice_supplier') { preg_match('/(\d+)\/[^\/]+$/',$relativefile,$reg); $id=$reg[1]; } if ($modulepart == 'propal') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=$reg[1]; } @@ -804,7 +812,7 @@ class FormFile $upload_max_filesize = $mul_upload_max_filesize * (int) $upload_max_filesize; // Max file size $max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize); - + // Include main include(DOL_DOCUMENT_ROOT.'/core/tpl/ajax/fileupload_main.tpl.php');