diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 4e81f0fb1ef..c533ea94795 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -631,7 +631,7 @@ print "\n"; print " ".$langs->trans("Name")."\n"; print " ".$langs->trans("Value")."\n"; print "\n"; -print "\n ".$langs->trans("PathDirectory")."\n ".$conf->propal->dir_output."\n\n"; +print "\n ".$langs->trans("PathDirectory")."\n ".$conf->propal->multidir_output[$conf->entity]."\n\n"; print "\n
"; diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index d5b30d67d11..07f124741fe 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -306,7 +306,7 @@ class Documents extends DolibarrApi throw new RestException(404, 'Proposal not found'); } - $upload_dir = $conf->propal->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'propal'); + $upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . get_exdir(0, 0, 0, 1, $object, 'propal'); } else if ($modulepart == 'commande' || $modulepart == 'order') { diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 91004c86f67..bdf92b31905 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -676,8 +676,8 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) { $langs->load("propal"); - $sql = "SELECT s.nom as name, s.rowid, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; - $sql.= ", s.code_client"; + $sql = "SELECT s.nom as name, s.rowid, s.code_client"; + $sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -726,7 +726,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print ''; print ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); print ''; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 148f24a7fb5..739368e96d3 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1292,7 +1292,7 @@ if (empty($reshook)) } // Actions to build doc - $upload_dir = $conf->propal->dir_output; + $upload_dir = $conf->propal->multidir_output[$object->entity]; $permissioncreate=$user->rights->propal->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -2425,7 +2425,7 @@ if ($action == 'create') * Documents generes */ $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); + $filedir = $conf->propal->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $genallowed = $user->rights->propal->lire; $delallowed = $user->rights->propal->creer; @@ -2466,7 +2466,7 @@ if ($action == 'create') // Presend form $modelmail='propal_send'; $defaulttopic='SendPropalRef'; - $diroutput = $conf->propal->dir_output; + $diroutput = $conf->propal->multidir_output[$object->entity]; $trackid = 'pro'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 850fa969bbb..3adc58ecbae 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1749,8 +1749,8 @@ class Propal extends CommonObject // to not lose the linked files $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); - $dirsource = $conf->propal->dir_output.'/'.$oldref; - $dirdest = $conf->propal->dir_output.'/'.$newref; + $dirsource = $conf->propal->multidir_output[$this->entity].'/'.$oldref; + $dirdest = $conf->propal->multidir_output[$this->entity].'/'.$newref; if (file_exists($dirsource)) { @@ -1759,7 +1759,7 @@ class Propal extends CommonObject { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->propal->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/')); + $listoffiles=dol_dir_list($dirdest, 'files', 1, '^'.preg_quote($oldref,'/')); foreach($listoffiles as $fileentry) { $dirsource=$fileentry['name']; @@ -2815,9 +2815,9 @@ class Propal extends CommonObject { // We remove directory $ref = dol_sanitizeFileName($this->ref); - if ($conf->propal->dir_output && !empty($this->ref)) + if ($conf->propal->multidir_output[$this->entity] && !empty($this->ref)) { - $dir = $conf->propal->dir_output . "/" . $ref ; + $dir = $conf->propal->multidir_output[$this->entity] . "/" . $ref ; $file = $dir . "/" . $ref . ".pdf"; if (file_exists($file)) { diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index ba373c78f44..4ceae6b1221 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -75,7 +75,7 @@ $object->fetch($id,$ref); if ($object->id > 0) { $object->fetch_thirdparty(); - $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref); + $upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; } @@ -90,7 +90,7 @@ $form = new Form($db); if ($object->id > 0) { - $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref); + $upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $head = propal_prepare_head($object); dol_fiche_head($head, 'document', $langs->trans('Proposal'), -1, 'propal'); diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index a313ab299f0..e9dce10ea0b 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -216,7 +216,7 @@ $max=5; * Last modified proposals */ -$sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,"; +$sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,"; $sql.= " date_cloture as datec"; $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; @@ -262,7 +262,7 @@ if ($resql) print ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); print ''; @@ -296,7 +296,8 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) $now=dol_now(); - $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; + $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client"; + $sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -341,7 +342,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) print ''; print ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); print ''; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 89f49ada093..cdcd5bf014b 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -110,7 +110,7 @@ if (! empty($socid)) } $result = restrictedArea($user, $module, $objectid, $dbtable); -$diroutputmassaction=$conf->propal->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction=$conf->propal->multidir_output[$conf->entity] . '/temp/massgeneration/'.$user->id; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('propallist')); @@ -214,7 +214,7 @@ if (empty($reshook)) $objectlabel='Proposals'; $permtoread = $user->rights->propal->lire; $permtodelete = $user->rights->propal->supprimer; - $uploaddir = $conf->propal->dir_output; + $uploaddir = $conf->propal->multidir_output[$conf->entity]; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -242,7 +242,7 @@ if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; $sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= ' p.rowid, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,'; +$sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,'; $sql.= ' p.datec as date_creation, p.tms as date_update,'; $sql.= " pr.rowid as project_id, pr.ref as project_ref,"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; @@ -663,7 +663,7 @@ if ($resql) // Other picto tool print ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); print ''; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 92e04e1672b..5cf5b6c7b40 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4067,7 +4067,7 @@ class OrderLine extends CommonOrderLine $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").','; $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").','; $sql.= ' '.(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql.= ", ".$this->fk_multicurrency; + $sql.= ", ".(! empty($this->fk_multicurrency) ? $this->fk_multicurrency : 'NULL'); $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", ".$this->multicurrency_subprice; $sql.= ", ".$this->multicurrency_total_ht; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3c23ba0f8ac..c7335298bdd 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4514,7 +4514,7 @@ abstract class CommonObject { $extrafields->fetch_name_optionals_label($this->table_element); } - $optionsArray = $extrafields->attributes[$this->table_element]['label']; + $optionsArray = (! empty($extrafields->attributes[$this->table_element]['label'])?$extrafields->attributes[$this->table_element]['label']:null); } else { diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index a1d051440c3..0705d2fd60d 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -310,7 +310,7 @@ class Conf // For user storage $this->user->multidir_output = array($this->entity => $rootfordata."/users"); - $this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp"); + $this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp"); // For backward compatibility $this->user->dir_output=$rootforuser."/users"; $this->user->dir_temp=$rootforuser."/users/temp"; @@ -320,6 +320,9 @@ class Conf $this->usergroup->dir_temp=$rootforuser."/usergroups/temp"; // For propal storage + $this->propal->multidir_output = array($this->entity => $rootfordata."/propale"); + $this->propal->multidir_temp = array($this->entity => $rootfordata."/propale/temp"); + // For backward compatibility $this->propal->dir_output=$rootfordata."/propale"; $this->propal->dir_temp=$rootfordata."/propale/temp"; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 08d6c3bfeaf..4477a4812da 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -742,7 +742,7 @@ class ExtraFields dol_syslog("fetch_name_optionals_label elementtype=".$elementtype); $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed"; - $sql .= ",entity"; + $sql.= ",entity"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity IN (0,".$conf->entity.")"; if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 5031502c602..077a29d4595 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -299,6 +299,9 @@ class FormFile return $this->getDocumentsLink($modulepart, $modulesubdir, $filedir); } + // Add entity in $param + $param.= 'entity='.(!empty($object->entity)?$object->entity:$conf->entity); + $printer=0; if (in_array($modulepart,array('facture','supplier_proposal','propal','proposal','order','commande','expedition', 'commande_fournisseur', 'expensereport'))) // The direct print feature is implemented only for such elements { @@ -848,6 +851,17 @@ class FormFile $out=''; $this->infofiles=array('nboffiles'=>0,'extensions'=>array(),'files'=>array()); + // Get object entity + if (empty($conf->multicompany->enabled)) + { + $entity = $conf->entity; + } + else + { + preg_match('/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir).'$/', $filedir, $regs); + $entity = ((! empty($regs[1]) && $regs[1] > 1) ? $regs[1] : $conf->entity); + } + $filterforfilesearch = preg_quote(basename($modulesubdir),'/').'[^\-]+'; $file_list=dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files) @@ -901,7 +915,7 @@ class FormFile } // Download - $tmpout.= '
  • id; - $dir_output = $conf->propal->dir_output; + $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$newref); break; case 'PROPAL_CLOSE_SIGNED': $link='/comm/propal/card.php?id='.$object->id; - $dir_output = $conf->propal->dir_output; + $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned",$newref); break; @@ -574,13 +574,13 @@ class Notify break; case 'PROPAL_VALIDATE': $link='/comm/propal/card.php?id='.$object->id; - $dir_output = $conf->propal->dir_output; + $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$newref); break; case 'PROPAL_CLOSE_SIGNED': $link='/comm/propal/card.php?id='.$object->id; - $dir_output = $conf->propal->dir_output; + $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned",$newref); break; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 5fa1eef045c..103b106b008 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2152,10 +2152,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $original_file=$conf->facture->dir_output.'/'.$original_file; } // Wrapping pour les apercu propal - elseif ($modulepart == 'apercupropal' && !empty($conf->propal->dir_output)) + elseif ($modulepart == 'apercupropal' && !empty($conf->propal->multidir_output[$entity])) { if ($fuser->rights->propale->{$lire}) $accessallowed=1; - $original_file=$conf->propal->dir_output.'/'.$original_file; + $original_file=$conf->propal->multidir_output[$entity].'/'.$original_file; } // Wrapping pour les apercu commande elseif ($modulepart == 'apercucommande' && !empty($conf->commande->dir_output)) @@ -2200,10 +2200,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $original_file=$conf->expensereport->dir_output.'/'.$original_file; } // Wrapping pour les images des stats propales - elseif ($modulepart == 'propalstats' && !empty($conf->propal->dir_temp)) + elseif ($modulepart == 'propalstats' && !empty($conf->propal->multidir_temp[$entity])) { if ($fuser->rights->propale->{$lire}) $accessallowed=1; - $original_file=$conf->propal->dir_temp.'/'.$original_file; + $original_file=$conf->propal->multidir_temp[$entity].'/'.$original_file; } // Wrapping pour les images des stats commandes elseif ($modulepart == 'orderstats' && !empty($conf->commande->dir_temp)) @@ -2367,13 +2367,13 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } // Wrapping for mass actions - else if ($modulepart == 'massfilesarea_proposals' && !empty($conf->propal->dir_output)) + else if ($modulepart == 'massfilesarea_proposals' && !empty($conf->propal->multidir_output[$entity])) { if ($fuser->rights->propal->{$lire} || preg_match('/^specimen/i',$original_file)) { $accessallowed=1; } - $original_file=$conf->propal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; + $original_file=$conf->propal->multidir_output[$entity].'/temp/massgeneration/'.$user->id.'/'.$original_file; } else if ($modulepart == 'massfilesarea_orders') { @@ -2407,7 +2407,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file=$conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; } - else if ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->propal->dir_output)) + else if ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->supplier_proposal->dir_output)) { if ($fuser->rights->supplier_proposal->{$lire} || preg_match('/^specimen/i',$original_file)) { @@ -2462,14 +2462,13 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, //$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."fichinter WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } // Wrapping pour les propales - else if ($modulepart == 'propal' && !empty($conf->propal->dir_output)) + else if ($modulepart == 'propal' && !empty($conf->propal->multidir_output[$entity])) { if ($fuser->rights->propale->{$lire} || preg_match('/^specimen/i',$original_file)) { $accessallowed=1; } - - $original_file=$conf->propal->dir_output.'/'.$original_file; + $original_file=$conf->propal->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."propal WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 78bd6caa2b6..4a9d4e6bc5e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7108,7 +7108,7 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='' if ($alldata == 1) { - if ($num_mime !== false) return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath), 'mime'=>dol_mimetype($relativepath), ); + if ($num_mime !== false) return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param?'&'.$param:''), 'mime'=>dol_mimetype($relativepath), ); else return array(); } diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index f0d42888745..c50661de831 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -35,7 +35,7 @@ function propal_prepare_head($object) $langs->load("propal"); $langs->load("compta"); $langs->load("companies"); - + $h = 0; $head = array(); @@ -86,7 +86,7 @@ function propal_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); $nbLinks=Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id; diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index bc34d5b5691..0b71e9e862f 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -246,7 +246,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $outputlangs->load("companies"); $outputlangs->load("bills"); - if ($conf->propal->dir_output) + if ($conf->propal->multidir_output[$conf->entity]) { // If $object is id instead of object if (! is_object($object)) @@ -261,7 +261,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales } } - $dir = $conf->propal->dir_output; + $dir = $conf->propal->multidir_output[$object->entity]; $objectref = dol_sanitizeFileName($object->ref); if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; $file = $dir . "/" . $objectref . ".odt"; @@ -303,7 +303,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales //print "file=".$file; //print "conf->propal->dir_temp=".$conf->propal->dir_temp; - dol_mkdir($conf->propal->dir_temp); + dol_mkdir($conf->propal->multidir_temp[$object->entity]); // If CUSTOMER contact defined on proposal, we use it @@ -357,7 +357,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $odfHandler = new odf( $srctemplatepath, array( - 'PATH_TO_TMP' => $conf->propal->dir_temp, + 'PATH_TO_TMP' => $conf->propal->multidir_temp[$object->entity], 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 7be8b6a0d08..a54cfbf212f 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -230,7 +230,7 @@ class pdf_azur extends ModelePDFPropales if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; - if ($conf->propal->dir_output) + if ($conf->propal->multidir_output[$conf->entity]) { $object->fetch_thirdparty(); @@ -239,13 +239,13 @@ class pdf_azur extends ModelePDFPropales // Definition of $dir and $file if ($object->specimen) { - $dir = $conf->propal->dir_output; + $dir = $conf->propal->multidir_output[$conf->entity]; $file = $dir . "/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->propal->dir_output . "/" . $objectref; + $dir = $conf->propal->multidir_output[$object->entity] . "/" . $objectref; $file = $dir . "/" . $objectref . ".pdf"; } @@ -1501,7 +1501,7 @@ class pdf_azur extends ModelePDFPropales { $top_shift = $pdf->getY() - $current_y; } - + if ($showaddress) { // Sender properties diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 6ab7fecbf10..23e5aff0cae 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -67,7 +67,7 @@ if ($conf->multicompany->enabled) { print ' '; print "\n"; -if (count($extrafields->attributes[$elementtype]['type'])) +if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafields->attributes[$elementtype]['type'])) { foreach($extrafields->attributes[$elementtype]['type'] as $key => $value) { diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 27b70e1b8cf..5ff1b133d20 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1272,7 +1272,7 @@ if ($action == 'create') print ''; if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if (GETPOST('qtyl'.$indiceAsked, 'int')) $defaultqty=GETPOST('qtyl'.$indiceAsked, 'int'); + if (GETPOST('qtyl'.$indiceAsked, 'int')) $deliverableQty=GETPOST('qtyl'.$indiceAsked, 'int'); print ''; print ''; } diff --git a/htdocs/expedition/class/expeditionbatch.class.php b/htdocs/expedition/class/expeditionbatch.class.php index a4b3b17a98a..d94baee2a43 100644 --- a/htdocs/expedition/class/expeditionbatch.class.php +++ b/htdocs/expedition/class/expeditionbatch.class.php @@ -59,14 +59,15 @@ class ExpeditionLineBatch extends CommonObject function fetchFromStock($id_stockdluo) { $sql = "SELECT"; - $sql.= " t.sellby,"; - $sql.= " t.eatby,"; - $sql.= " t.batch,"; - $sql.= " e.fk_entrepot"; + $sql.= " pb.batch,"; + $sql.= " pl.sellby,"; + $sql.= " pl.eatby,"; + $sql.= " ps.fk_entrepot"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_batch as t inner join "; - $sql.= MAIN_DB_PREFIX."product_stock as e on t.fk_product_stock=e.rowid "; - $sql.= " WHERE t.rowid = ".(int) $id_stockdluo; + $sql.= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; + $sql.= " JOIN ".MAIN_DB_PREFIX."product_stock as ps on pb.fk_product_stock=ps.rowid"; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."product_lot as pl on pl.batch = pb.batch AND pl.fk_product = ps.fk_product"; + $sql.= " WHERE pb.rowid = ".(int) $id_stockdluo; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/install/mysql/tables/llx_expensereport_rules.sql b/htdocs/install/mysql/tables/llx_expensereport_rules.sql index e6103ee8fb9..3aaca6f00b5 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_rules.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_rules.sql @@ -31,4 +31,4 @@ CREATE TABLE llx_expensereport_rules ( code_expense_rules_type varchar(50) NOT NULL, is_for_all tinyint DEFAULT '0', entity integer DEFAULT 1 -) ENGINE=InnoDB \ No newline at end of file +) ENGINE=InnoDB; \ No newline at end of file diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index 44661c191d7..a891a2f590e 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -201,8 +201,10 @@ if ($action == "set") { $buffer=preg_replace('/type=innodb/i','ENGINE=innodb',$buffer); } - else if ($conf->db->type == 'mssql') + else { + // Keyword ENGINE is MySQL-specific, so scrub it for + // other database types (mssql, pgsql) $buffer=preg_replace('/type=innodb/i','',$buffer); $buffer=preg_replace('/ENGINE=innodb/i','',$buffer); } diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 61bd5c3d47f..f732c44fc31 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -117,7 +117,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->su if ($result > 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - header("Location: ".DOL_URL_ROOT.'/product/stock/list.php?resotre_lastsearch_values=1'); + header("Location: ".DOL_URL_ROOT.'/product/stock/list.php?restore_lastsearch_values=1'); exit; } else diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index ed25f3ba813..bc78d285945 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -196,6 +196,7 @@ class Project extends CommonObject $sql.= ", " . ($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); $sql.= ", " . (strcmp($this->opp_amount,'') ? price2num($this->opp_amount) : 'null'); $sql.= ", " . (strcmp($this->budget_amount,'') ? price2num($this->budget_amount) : 'null'); + $sql.= ", " . ($this->bill_time ? 1 : 0); $sql.= ", ".$conf->entity; $sql.= ")"; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index f5c0f004794..48c35c7143e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2876,6 +2876,29 @@ class Societe extends CommonObject return -4; } + //Verify NIF if country is PT + //Returns: 1 if NIF ok, -1 if NIF bad, 0 if unexpected bad + if ($idprof == 1 && $soc->country_code == 'PT') + { + $string=trim($this->idprof1); + $string=preg_replace('/(\s)/','',$string); + + for ($i = 0; $i < 9; $i ++) { + $num[$i] = substr($string, $i, 1); + } + + //Check NIF + if (preg_match('/(^[0-9]{9}$)/', $string)) { + return 1; + } + else { + return -1; + } + + //Wrong format + return 0; + } + return $ok; } @@ -2897,20 +2920,33 @@ class Societe extends CommonObject $hookmanager->initHooks(array('idprofurl')); $parameters=array('idprof'=>$idprof, 'company'=>$thirdparty); $reshook=$hookmanager->executeHooks('getIdProfUrl',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return ''; + if (empty($reshook)) { + if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) { + return ''; + } // TODO Move links to validate professional ID into a dictionary table "country" + "link" - if ($idprof == 1 && $thirdparty->country_code == 'FR') $url='http://www.societe.com/cgi-bin/search?champs='.$thirdparty->idprof1; // See also http://avis-situation-sirene.insee.fr/ - //if ($idprof == 1 && ($thirdparty->country_code == 'GB' || $thirdparty->country_code == 'UK')) $url='http://www.companieshouse.gov.uk/WebCHeck/findinfolink/'; // Link no more valid - if ($idprof == 1 && $thirdparty->country_code == 'ES') $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$thirdparty->idprof1; - if ($idprof == 1 && $thirdparty->country_code == 'IN') $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$thirdparty->idprof1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; + if ($idprof == 1 && $thirdparty->country_code == 'FR') { + $url='http://www.societe.com/cgi-bin/search?champs='.$thirdparty->idprof1; // See also http://avis-situation-sirene.insee.fr/ + } + if ($idprof == 1 && ($thirdparty->country_code == 'GB' || $thirdparty->country_code == 'UK')) { + $url='https://beta.companieshouse.gov.uk/company/'.$thirdparty->idprof1; + } + if ($idprof == 1 && $thirdparty->country_code == 'ES') { + $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$thirdparty->idprof1; + } + if ($idprof == 1 && $thirdparty->country_code == 'IN') { + $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$thirdparty->idprof1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; + } + if ($idprof == 1 && $thirdparty->country_code == 'PT') { + $url='http://www.nif.pt/'.$thirdparty->idprof1; + } - if ($url) return ''.$langs->trans("Check").''; + if ($url) { + return ''.$langs->trans("Check").''; + } } - else - { + else { return $hookmanager->resPrint; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 3cfa1bf01e6..c34f867348a 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3081,7 +3081,7 @@ ul.noborder li:nth-child(even):not(.liste_titre) { } .boxstats { padding: 3px; - width: 104px; + width: 121px; } .boxstats130 { width: 158px; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index a11c18daca7..8eda5d47d97 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -67,9 +67,7 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $canreadgroup=(! empty($user->admin) || $user->rights->user->group_advance->read); $caneditgroup=(! empty($user->admin) || $user->rights->user->group_advance->write); } -if(! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $caneditgroup = ($conf->entity == 1) && ! empty($user->admin) && empty($user->entity); -} + // Define value to know what current user can do on properties of edited user if ($id) {