diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 011fad9cd7d..d1f838056d4 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -159,7 +159,7 @@ if ( ($action == 'update' && empty($_POST["cancel"])) if ($action == 'addthumb') { - if (file_exists($conf->societe->dir_output.'/logos/'.$_GET["file"])) + if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"])) { $isimage=image_format_supported($_GET["file"]); diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 6b6277bb3fa..126e95f7d72 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -162,7 +162,7 @@ if ($type == 'directory') // Right area if ($module == 'company') // Auto area for suppliers invoices { - $upload_dir = $conf->societe->dir_output; + $upload_dir = $conf->societe->dir_output; // TODO change for multicompany sharing $filearray=dol_dir_list($upload_dir,"files",1,'',array('^SPECIMEN\.pdf$','^\.','\.meta$','^temp$','^payments$','^CVS$','^thumbs$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $param.='&module='.$module; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 29fcbf81180..e36b7092848 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3691,7 +3691,7 @@ class Form if ($modulepart=='societe') { - $dir=$conf->societe->dir_output; + $dir=$conf->societe->multidir_output[$object->entity]; $smallfile=$object->logo; $smallfile=preg_replace('/(\.png|\.gif|\.jpg|\.jpeg|\.bmp)/i','_small\\1',$smallfile); if ($object->logo) $file=$object->id.'/logos/thumbs/'.$smallfile; @@ -3717,14 +3717,14 @@ class Form if ($file && file_exists($dir."/".$file)) { // TODO Link to large image - $ret.=''; - $ret.=''; + $ret.=''; + $ret.=''; $ret.=''; } else if ($altfile && file_exists($dir."/".$altfile)) { - $ret.=''; - $ret.=''; + $ret.=''; + $ret.=''; $ret.=''; } else diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 164ff25c917..c079a5101e0 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -179,7 +179,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc $outputlangs->load("companies"); $outputlangs->load("projects"); - if ($conf->societe->dir_output) + if ($conf->societe->multidir_output[$object->entity]) { // If $object is id instead of object if (! is_object($object)) @@ -194,7 +194,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc } } - $dir = $conf->societe->dir_output; + $dir = $conf->societe->multidir_output[$object->entity]; $objectref = dol_sanitizeFileName($object->id); if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; diff --git a/htdocs/document.php b/htdocs/document.php index ee6f7fb6d33..723a861ee1e 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -124,13 +124,13 @@ if ($modulepart) // On fait une verification des droits et on definit le repertoire concerne // Wrapping for third parties - if ($modulepart == 'company') + if ($modulepart == 'company' || $modulepart == 'societe') { if ($user->rights->societe->lire || preg_match('/^specimen/i',$original_file)) { $accessallowed=1; } - $original_file=$conf->societe->dir_output.'/'.$original_file; + $original_file=$conf->societe->multidir_output[GETPOST('entity','int')].'/'.$original_file; $sqlprotectagainstexternals = "SELECT rowid as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE rowid='".$refname."' AND entity=".$conf->entity; } @@ -252,17 +252,6 @@ if ($modulepart) $original_file=$conf->compta->dir_output.'/'.$original_file; } - // Wrapping pour les societe - else if ($modulepart == 'societe') - { - if ($user->rights->societe->lire || preg_match('/^specimen/i',$original_file)) - { - $accessallowed=1; - } - $original_file=$conf->societe->dir_output.'/'.$original_file; - $sqlprotectagainstexternals = "SELECT rowid as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE rowid='".$refname."' AND entity=".$conf->entity; - } - // Wrapping pour les expedition else if ($modulepart == 'expedition') { diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 73557601813..4935047e63c 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -199,7 +199,7 @@ if (GETPOST('purge')) { $filearray=array(); $upload_dir = $conf->$modulepart->dir_output; - if ($modulepart == 'company') $upload_dir = $conf->societe->dir_output; + if ($modulepart == 'company') $upload_dir = $conf->societe->dir_output; // TODO change for multicompany sharing if ($modulepart == 'invoice') $upload_dir = $conf->facture->dir_output; if ($modulepart == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output; if ($modulepart == 'order') $upload_dir = $conf->commande->dir_output; diff --git a/htdocs/societe/canvas/company/tpl/card_view.tpl.php b/htdocs/societe/canvas/company/tpl/card_view.tpl.php index 3398cdccead..a0a9c7ec47a 100644 --- a/htdocs/societe/canvas/company/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_view.tpl.php @@ -259,7 +259,7 @@ for ($i=1; $i<=4; $i++) { /* * Documents generes */ -$filedir=$conf->societe->dir_output.'/'.$socid; +$filedir=$conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid; $urlsource=$_SERVER["PHP_SELF"]."?socid=".$socid; $genallowed=$user->rights->societe->creer; $delallowed=$user->rights->societe->supprimer; diff --git a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php index 6da431fb799..6f82f5c6aeb 100644 --- a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php @@ -199,7 +199,7 @@ dol_fiche_head($head, 'card', $langs->trans("ThirdParty"),0,'company'); /* * Documents generes */ -$filedir=$conf->societe->dir_output.'/'.$socid; +$filedir=$conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid; $urlsource=$_SERVER["PHP_SELF"]."?socid=".$socid; $genallowed=$user->rights->societe->creer; $delallowed=$user->rights->societe->supprimer; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index bcb9cf41b48..f850811772c 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -845,7 +845,7 @@ class Societe extends CommonObject // Remove contacts if (! $error) { - $sql = "DELETE from ".MAIN_DB_PREFIX."socpeople"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople"; $sql.= " WHERE fk_soc = " . $id; dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG); if (! $this->db->query($sql)) @@ -873,7 +873,7 @@ class Societe extends CommonObject // Remove ban if (! $error) { - $sql = "DELETE from ".MAIN_DB_PREFIX."societe_rib"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib"; $sql.= " WHERE fk_soc = " . $id; dol_syslog(get_class($this)."::Delete sql=".$sql, LOG_DEBUG); if (! $this->db->query($sql)) @@ -906,7 +906,7 @@ class Societe extends CommonObject // Remove third party if (! $error) { - $sql = "DELETE from ".MAIN_DB_PREFIX."societe"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe"; $sql.= " WHERE rowid = " . $id; dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG); if (! $this->db->query($sql)) @@ -932,7 +932,7 @@ class Societe extends CommonObject $this->db->commit(); // Delete directory - $docdir = $conf->societe->dir_output . "/" . $id; + $docdir = $conf->societe->multidir_output[$this->entity] . "/" . $id; if (file_exists($docdir)) { dol_delete_dir_recursive($docdir); diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 792ef0e99cc..55a94a10e24 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -35,9 +35,10 @@ $langs->load('other'); $mesg=''; -$action = GETPOST('action'); -$confirm = GETPOST('confirm'); -$socid = (GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int')); +$action=GETPOST('action'); +$confirm=GETPOST('confirm'); +$id=(GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int')); +$ref = GETPOST('ref', 'alpha'); // Security check if ($user->societe_id > 0) @@ -46,7 +47,7 @@ if ($user->societe_id > 0) $action=''; $socid = $user->societe_id; } -$result = restrictedArea($user, 'societe', $socid, '&societe'); +$result = restrictedArea($user, 'societe', $id, '&societe'); // Get parameters $sortfield = GETPOST("sortfield",'alpha'); @@ -59,19 +60,24 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; -$upload_dir = $conf->societe->dir_output . "/" . $socid ; -$courrier_dir = $conf->societe->dir_output . "/courrier/" . get_exdir($socid); - $object = new Societe($db); +if ($id > 0 || ! empty($ref)) +{ + $result = $object->fetch($id, $ref); + + $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id ; + $courrier_dir = $conf->societe->multidir_output[$object->entity] . "/courrier/" . get_exdir($object->id); +} + /* * Actions */ // Post file -if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { - if ($object->fetch($socid)) + if ($object->id) { if (dol_mkdir($upload_dir) >= 0) { @@ -113,7 +119,7 @@ if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) // Delete file if ($action == 'confirm_deletefile' && $confirm == 'yes') { - if ($object->fetch($socid)) + if ($object->id) { $file = $upload_dir . "/" . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file,0,0,0,$object); @@ -131,107 +137,98 @@ $form = new Form($db); $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$langs->trans("ThirdParty").' - '.$langs->trans("Files"),$help_url); -if ($socid > 0) +if ($object->id) { - if ($object->fetch($socid)) - { - /* - * Affichage onglets - */ - if ($conf->notification->enabled) $langs->load("mails"); - $head = societe_prepare_head($object); - - $form=new Form($db); - - dol_fiche_head($head, 'document', $langs->trans("ThirdParty"),0,'company'); - - - // Construit liste des fichiers - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); - $totalsize=0; - foreach($filearray as $key => $file) - { - $totalsize+=$file['size']; - } - - - print ''; - - // Ref - print ''; - print ''; - - // Prefix - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { - print ''; - } - - if ($object->client) - { - print ''; - } - - if ($object->fournisseur) - { - print ''; - } - - // Nbre fichiers - print ''; - - //Total taille - print ''; - - print '
'.$langs->trans("ThirdPartyName").''; - print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); - print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; - print $langs->trans('CustomerCode').''; - print $object->code_client; - if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; - print '
'; - print $langs->trans('SupplierCode').''; - print $object->code_fournisseur; - if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; - print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; - - print ''; - - dol_htmloutput_mesg($mesg,$mesgs); - - /* - * Confirmation suppression fichier - */ - if ($action == 'delete') - { - $ret=$form->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 '
'; - } - - $formfile=new FormFile($db); - - // Show upload form - $formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?socid='.$socid,'',0,0,$user->rights->societe->creer,50,$object); - - // List of document - $param='&socid='.$object->id; - $formfile->list_of_documents($filearray,$object,'societe',$param); - - print "

"; - } - else - { - dol_print_error($db); - } + /* + * Affichage onglets + */ + if ($conf->notification->enabled) $langs->load("mails"); + $head = societe_prepare_head($object); + + $form=new Form($db); + + dol_fiche_head($head, 'document', $langs->trans("ThirdParty"),0,'company'); + + + // Construit liste des fichiers + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + + print ''; + + // Ref + print ''; + print ''; + + // Prefix + if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''; + } + + if ($object->client) + { + print ''; + } + + if ($object->fournisseur) + { + print ''; + } + + // Nbre fichiers + print ''; + + //Total taille + print ''; + + print '
'.$langs->trans("ThirdPartyName").''; + print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); + print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; + print $langs->trans('CustomerCode').''; + print $object->code_client; + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; + print '
'; + print $langs->trans('SupplierCode').''; + print $object->code_fournisseur; + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print ''; + + dol_htmloutput_mesg($mesg,$mesgs); + + /* + * Confirmation suppression fichier + */ + if ($action == 'delete') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); + if ($ret == 'html') print '
'; + } + + $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 + $param='&socid='.$object->id; + $formfile->list_of_documents($filearray,$object,'societe',$param); + + print "

"; } else { accessforbidden('',0,0); } -$db->close(); - llxFooter(); - +$db->close(); ?> diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index e3c18cf34f7..26fc911ae47 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -252,7 +252,7 @@ if (empty($reshook)) } // Gestion du logo de la société - $dir = $conf->societe->dir_output."/".$object->id."/logos/"; + $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/"; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if ($file_OK) { @@ -328,14 +328,14 @@ if (empty($reshook)) } // Gestion du logo de la société - $dir = $conf->societe->dir_output."/".$object->id."/logos"; + $dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos"; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if ($file_OK) { if (GETPOST('deletephoto')) { - $fileimg=$conf->societe->dir_output.'/'.$object->id.'/logos/'.$object->logo; - $dirthumbs=$conf->societe->dir_output.'/'.$object->id.'/logos/thumbs'; + $fileimg=$dir.'/'.$object->logo; + $dirthumbs=$dir.'/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); } @@ -568,7 +568,7 @@ else $object->logo = dol_sanitizeFileName($_FILES['photo']['name']); // Gestion du logo de la société - $dir = $conf->societe->dir_output."/".$object->id."/logos"; + $dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos"; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if ($file_OK) { @@ -1821,7 +1821,7 @@ else /* * Documents generes */ - $filedir=$conf->societe->dir_output.'/'.$object->id; + $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id; $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; $genallowed=$user->rights->societe->creer; $delallowed=$user->rights->societe->supprimer; diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index 3d70e4a8b35..6bddaa8d268 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -121,7 +121,7 @@ if ($modulepart) elseif ($modulepart == 'societe') { $accessallowed=1; - $original_file=$conf->societe->dir_output.'/'.$original_file; + $original_file=$conf->societe->multidir_output[GETPOST('entity','int')].'/'.$original_file; } // Wrapping pour les apercu factures elseif ($modulepart == 'apercufacture')