Merge branch 'Dolibarr:develop' into develop
This commit is contained in:
commit
c05b1f5e29
145
dev/tools/spider.php
Normal file
145
dev/tools/spider.php
Normal file
@ -0,0 +1,145 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file dev/tools/spider.php
|
||||
* \brief Script to spider Dolibarr app.
|
||||
*
|
||||
* To use it:
|
||||
* - Disable module "bookmark"
|
||||
* - Exclude param optioncss, token, sortfield, sortorder
|
||||
*/
|
||||
|
||||
$crawledLinks=array();
|
||||
const MAX_DEPTH=2;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $url URL
|
||||
* @param string $depth Depth
|
||||
* @return string String
|
||||
*/
|
||||
function followLink($url, $depth = 0)
|
||||
{
|
||||
global $crawledLinks;
|
||||
$crawling=array();
|
||||
if ($depth>MAX_DEPTH) {
|
||||
echo "<div style='color:red;'>The Crawler is giving up!</div>";
|
||||
return;
|
||||
}
|
||||
$options=array(
|
||||
'http'=>array(
|
||||
'method'=>"GET",
|
||||
'user-agent'=>"gfgBot/0.1\n"
|
||||
)
|
||||
);
|
||||
$context=stream_context_create($options);
|
||||
$doc=new DomDocument();
|
||||
@$doc->loadHTML(file_get_contents($url, false, $context));
|
||||
$links=$doc->getElementsByTagName('a');
|
||||
$pageTitle=getDocTitle($doc, $url);
|
||||
$metaData=getDocMetaData($doc);
|
||||
foreach ($links as $i) {
|
||||
$link=$i->getAttribute('href');
|
||||
if (ignoreLink($link)) continue;
|
||||
$link=convertLink($url, $link);
|
||||
if (!in_array($link, $crawledLinks)) {
|
||||
$crawledLinks[]=$link;
|
||||
$crawling[]=$link;
|
||||
insertIntoDatabase($link, $pageTitle, $metaData, $depth);
|
||||
}
|
||||
}
|
||||
foreach ($crawling as $crawlURL)
|
||||
followLink($crawlURL, $depth+1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $site Site
|
||||
* @param string $path Path
|
||||
* @return string String
|
||||
*/
|
||||
function convertLink($site, $path)
|
||||
{
|
||||
if (substr_compare($path, "//", 0, 2)==0)
|
||||
return parse_url($site)['scheme'].$path;
|
||||
elseif (substr_compare($path, "http://", 0, 7)==0 or
|
||||
substr_compare($path, "https://", 0, 8)==0 or
|
||||
substr_compare($path, "www.", 0, 4)==0)
|
||||
return $path;
|
||||
else return $site.'/'.$path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url URL
|
||||
* @return boolean
|
||||
*/
|
||||
function ignoreLink($url)
|
||||
{
|
||||
return $url[0]=="#" or substr($url, 0, 11) == "javascript:";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $link URL
|
||||
* @param string $title Title
|
||||
* @param string $metaData Array
|
||||
* @param int $depth Depth
|
||||
* @return void
|
||||
*/
|
||||
function insertIntoDatabase($link, $title, &$metaData, $depth)
|
||||
{
|
||||
//global $crawledLinks;
|
||||
|
||||
echo "Inserting new record {URL= ".$link.", Title = '$title', Description = '".$metaData['description']."', Keywords = ' ".$metaData['keywords']."'}<br/><br/><br/>";
|
||||
|
||||
//²$crawledLinks[]=$link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $doc Doc
|
||||
* @param string $url URL
|
||||
* @return string URL/Title
|
||||
*/
|
||||
function getDocTitle(&$doc, $url)
|
||||
{
|
||||
$titleNodes=$doc->getElementsByTagName('title');
|
||||
if (count($titleNodes)==0 or !isset($titleNodes[0]->nodeValue))
|
||||
return $url;
|
||||
$title=str_replace('', '\n', $titleNodes[0]->nodeValue);
|
||||
return (strlen($title)<1)?$url:$title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $doc Doc
|
||||
* @return array Array
|
||||
*/
|
||||
function getDocMetaData(&$doc)
|
||||
{
|
||||
$metaData=array();
|
||||
$metaNodes=$doc->getElementsByTagName('meta');
|
||||
foreach ($metaNodes as $node)
|
||||
$metaData[$node->getAttribute("name")] = $node->getAttribute("content");
|
||||
if (!isset($metaData['description']))
|
||||
$metaData['description']='No Description Available';
|
||||
if (!isset($metaData['keywords'])) $metaData['keywords']='';
|
||||
return array(
|
||||
'keywords'=>str_replace('', '\n', $metaData['keywords']),
|
||||
'description'=>str_replace('', '\n', $metaData['description'])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
followLink("http://localhost/dolibarr_dev/htdocs");
|
||||
@ -49,7 +49,7 @@ if (empty($user->rights->accounting->mouvements->lire)) {
|
||||
if (empty($conf->comptabilite->enabled) && empty($conf->accounting->enabled) && empty($conf->asset->enabled) && empty($conf->intracommreport->enabled)) {
|
||||
accessforbidden();
|
||||
}
|
||||
if (empty($user->rights->compta->resultat->lire) && empty($user->rights->accounting->mouvements->lire) && empty($user->rights->asset->read) && empty($user->rights->intracommreport->read)) {
|
||||
if (empty($user->rights->compta->resultat->lire) && empty($user->rights->accounting->comptarapport->lire) && empty($user->rights->accounting->mouvements->lire) && empty($user->rights->asset->read) && empty($user->rights->intracommreport->read)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
@ -202,7 +202,7 @@ $tabsql[3] = "SELECT r.rowid as rowid, r.code_region as state_code, r.nom as lib
|
||||
$tabsql[4] = "SELECT c.rowid as rowid, c.code, c.label, c.active, c.favorite FROM ".MAIN_DB_PREFIX."c_country AS c";
|
||||
$tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c";
|
||||
$tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.color, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a";
|
||||
$tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays=c.rowid and c.active=1";
|
||||
$tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays=c.rowid and c.active=1";
|
||||
$tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as country_id, c.code as country_code, c.label as country, t.position, t.active FROM ".MAIN_DB_PREFIX."c_typent as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON t.fk_country=c.rowid";
|
||||
$tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c";
|
||||
$tabsql[10] = "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
|
||||
@ -294,7 +294,7 @@ $tabfield[3] = "code,libelle,country_id,country";
|
||||
$tabfield[4] = "code,label";
|
||||
$tabfield[5] = "code,label";
|
||||
$tabfield[6] = "code,libelle,type,color,position";
|
||||
$tabfield[7] = "code,libelle,country,accountancy_code,deductible";
|
||||
$tabfield[7] = "code,libelle,country,accountancy_code";
|
||||
$tabfield[8] = "code,libelle,country_id,country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : '');
|
||||
$tabfield[9] = "code,label,unicode";
|
||||
$tabfield[10] = "country_id,country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
|
||||
@ -340,7 +340,7 @@ $tabfieldvalue[3] = "code,libelle,country";
|
||||
$tabfieldvalue[4] = "code,label";
|
||||
$tabfieldvalue[5] = "code,label";
|
||||
$tabfieldvalue[6] = "code,libelle,type,color,position";
|
||||
$tabfieldvalue[7] = "code,libelle,country,accountancy_code,deductible";
|
||||
$tabfieldvalue[7] = "code,libelle,country,accountancy_code";
|
||||
$tabfieldvalue[8] = "code,libelle,country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : '');
|
||||
$tabfieldvalue[9] = "code,label,unicode";
|
||||
$tabfieldvalue[10] = "country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
|
||||
@ -386,7 +386,7 @@ $tabfieldinsert[3] = "code_region,nom,fk_pays";
|
||||
$tabfieldinsert[4] = "code,label";
|
||||
$tabfieldinsert[5] = "code,label";
|
||||
$tabfieldinsert[6] = "code,libelle,type,color,position";
|
||||
$tabfieldinsert[7] = "code,libelle,fk_pays,accountancy_code,deductible";
|
||||
$tabfieldinsert[7] = "code,libelle,fk_pays,accountancy_code";
|
||||
$tabfieldinsert[8] = "code,libelle,fk_country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : '');
|
||||
$tabfieldinsert[9] = "code_iso,label,unicode";
|
||||
$tabfieldinsert[10] = "fk_pays,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
|
||||
|
||||
@ -82,7 +82,8 @@ print '<br><br>';
|
||||
if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) {
|
||||
$setupcompanynotcomplete = 1;
|
||||
}
|
||||
print img_picto('', 'company', 'class="paddingright"').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit'), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup"));
|
||||
print img_picto('', 'company', 'class="paddingright valignmiddle double"').' '.$langs->trans("SetupDescriptionLink", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit'), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup"));
|
||||
print '<br><br>'.$langs->trans("SetupDescription3b");
|
||||
if (!empty($setupcompanynotcomplete)) {
|
||||
$langs->load("errors");
|
||||
$warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"), 'style="padding-right: 6px;"');
|
||||
@ -93,7 +94,8 @@ print '<br>';
|
||||
print '<br>';
|
||||
|
||||
// Show info setup module
|
||||
print img_picto('', 'cog', 'class="paddingright"').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules"));
|
||||
print img_picto('', 'cog', 'class="paddingright valignmiddle double"').' '.$langs->trans("SetupDescriptionLink", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules"));
|
||||
print '<br><br>'.$langs->trans("SetupDescription4b");
|
||||
if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only minimal initial modules enabled
|
||||
$langs->load("errors");
|
||||
$warnpicto = img_warning($langs->trans("WarningEnableYourModulesApplications"), 'style="padding-right: 6px;"');
|
||||
|
||||
@ -95,7 +95,7 @@ print "<strong>PHP session.cookie_samesite</strong> = ".(ini_get('session.cookie
|
||||
print "<strong>PHP open_basedir</strong> = ".(ini_get('open_basedir') ? ini_get('open_basedir') : yn(0).' <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("ARestrictedPath").', '.$langs->transnoentitiesnoconv("Example").' '.$_SERVER["DOCUMENT_ROOT"]).')</span>')."<br>\n";
|
||||
print "<strong>PHP allow_url_fopen</strong> = ".(ini_get('allow_url_fopen') ? img_picto($langs->trans("YouShouldSetThisToOff"), 'warning').' '.ini_get('allow_url_fopen') : yn(0)).' <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).")</span><br>\n";
|
||||
print "<strong>PHP allow_url_include</strong> = ".(ini_get('allow_url_include') ? img_picto($langs->trans("YouShouldSetThisToOff"), 'warning').' '.ini_get('allow_url_include') : yn(0)).' <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).")</span><br>\n";
|
||||
print "<strong>PHP safe_mode</strong> = ".(ini_get('safe_mode') ? ini_get('safe_mode') : yn(0)).' <span class="opacitymedium">'.$langs->trans("Deprecated")." (removed in PHP 5.4)</span><br>\n";
|
||||
//print "<strong>PHP safe_mode</strong> = ".(ini_get('safe_mode') ? ini_get('safe_mode') : yn(0)).' <span class="opacitymedium">'.$langs->trans("Deprecated")." (removed in PHP 5.4)</span><br>\n";
|
||||
print "<strong>PHP disable_functions</strong> = ";
|
||||
$arrayoffunctionsdisabled = explode(',', ini_get('disable_functions'));
|
||||
$arrayoffunctionstodisable = explode(',', 'pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals');
|
||||
@ -350,7 +350,7 @@ if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) {
|
||||
if ($conf->global->MAIN_SECURITY_HASH_ALGO != 'password_hash') {
|
||||
print '<br><strong>MAIN_SECURITY_SALT</strong> = '.(empty($conf->global->MAIN_SECURITY_SALT) ? '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>' : $conf->global->MAIN_SECURITY_SALT).'<br>';
|
||||
} else {
|
||||
print '<span class="opacitymedium">('.$langs->trans("Recommanded").': password_hash)</span>';
|
||||
print '<span class="opacitymedium">('.$langs->trans("Recommended").': password_hash)</span>';
|
||||
print '<br>';
|
||||
}
|
||||
if ($conf->global->MAIN_SECURITY_HASH_ALGO != 'password_hash') {
|
||||
@ -363,16 +363,19 @@ if ($conf->global->MAIN_SECURITY_HASH_ALGO != 'password_hash') {
|
||||
}
|
||||
print '<br>';
|
||||
|
||||
print '<strong>MAIN_SECURITY_ANTI_SSRF_SERVER_IP</strong> = '.(empty($conf->global->MAIN_SECURITY_ANTI_SSRF_SERVER_IP) ? '<span class="opacitymedium">'.$langs->trans("Undefined").'</span> <span class="opacitymedium">('.$langs->trans("Example").': static-ips-of-server - '.$langs->trans("Note").': common loopback ip like 127.*.*.*, [::1] are already added)</span>' : $conf->global->MAIN_SECURITY_ANTI_SSRF_SERVER_IP)."<br>";
|
||||
print '<strong>MAIN_SECURITY_ANTI_SSRF_SERVER_IP</strong> = '.(empty($conf->global->MAIN_SECURITY_ANTI_SSRF_SERVER_IP) ? '<span class="opacitymedium">'.$langs->trans("Undefined").'</span> <span class="opacitymedium">('.$langs->trans("Recommended").': List of static IPs of server separated with coma - '.$langs->trans("Note").': common loopback ip like 127.*.*.*, [::1] are already added)</span>' : $conf->global->MAIN_SECURITY_ANTI_SSRF_SERVER_IP)."<br>";
|
||||
print '<br>';
|
||||
|
||||
print '<strong>MAIN_ALLOW_SVG_FILES_AS_IMAGES</strong> = '.(empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES) ? '0 <span class="opacitymedium">('.$langs->trans("Recommanded").': 0)</span>' : $conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)."<br>";
|
||||
print '<strong>MAIN_ALLOW_SVG_FILES_AS_IMAGES</strong> = '.(empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES) ? '0' : $conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES).' <span class="opacitymedium">('.$langs->trans("Recommended").': 0)</span><br>';
|
||||
print '<br>';
|
||||
|
||||
print '<strong>MAIN_RESTRICTHTML_ONLY_VALID_HTML</strong> = '.(empty($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML) ? '<span class="opacitymedium">'.$langs->trans("Undefined").' ('.$langs->trans("Recommanded").': 1)</span>' : $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML)."<br>";
|
||||
print '<strong>MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE</strong> = '.(empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE) ? '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>' : $conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE).' <span class="opacitymedium">('.$langs->trans("Recommended").': 1)</span><br>';
|
||||
print '<br>';
|
||||
|
||||
print '<strong>MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES</strong> = '.(empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES) ? '<span class="opacitymedium">'.$langs->trans("Undefined").' ('.$langs->trans("Recommanded").': 1)</span>' : $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)."<br>";
|
||||
print '<strong>MAIN_RESTRICTHTML_ONLY_VALID_HTML</strong> = '.(empty($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML) ? '<span class="opacitymedium">'.$langs->trans("Undefined").' ('.$langs->trans("Recommended").': 1)</span>' : $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML)."<br>";
|
||||
print '<br>';
|
||||
|
||||
print '<strong>MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES</strong> = '.(empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES) ? '<span class="opacitymedium">'.$langs->trans("Undefined").' ('.$langs->trans("Recommended").': 1)</span>' : $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)."<br>";
|
||||
print '<br>';
|
||||
|
||||
print '<strong>MAIN_EXEC_USE_POPEN</strong> = ';
|
||||
@ -382,10 +385,14 @@ if (empty($conf->global->MAIN_EXEC_USE_POPEN)) {
|
||||
print $conf->global->MAIN_EXEC_USE_POPEN;
|
||||
}
|
||||
if ($execmethod == 1) {
|
||||
print ' <span class="opacitymedium">("exec" PHP method will be used for shell commands)</span>';
|
||||
print '<span class="opacitymedium">, "exec" PHP method will be used for shell commands';
|
||||
print ' ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 1)';
|
||||
print '</span>';
|
||||
}
|
||||
if ($execmethod == 2) {
|
||||
print ' <span class="opacitymedium">("popen" PHP method will be used for shell commands)</span>';
|
||||
print '<span class="opacitymedium">, "popen" PHP method will be used for shell commands';
|
||||
print ' ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 1)';
|
||||
print '</span>';
|
||||
}
|
||||
print "<br>";
|
||||
print '<br>';
|
||||
|
||||
@ -200,7 +200,8 @@ if ($id > 0 || $ref) {
|
||||
|
||||
//print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>';
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">'.price($object->amount).'</span></td></tr>';
|
||||
|
||||
// Status
|
||||
/*
|
||||
|
||||
@ -82,7 +82,8 @@ class BonPrelevement extends CommonObject
|
||||
|
||||
const STATUS_DRAFT = 0;
|
||||
const STATUS_TRANSFERED = 1;
|
||||
const STATUS_CREDITED = 2;
|
||||
const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
|
||||
const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
|
||||
|
||||
|
||||
/**
|
||||
@ -2343,17 +2344,22 @@ class BonPrelevement extends CommonObject
|
||||
//$langs->load("mymodule");
|
||||
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('StatusWaiting');
|
||||
$this->labelStatus[self::STATUS_TRANSFERED] = $langs->trans('StatusTrans');
|
||||
$this->labelStatus[self::STATUS_CREDITED] = $langs->trans('StatusCredited');
|
||||
$this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('StatusWaiting');
|
||||
$this->labelStatusShort[self::STATUS_TRANSFERED] = $langs->trans('StatusTrans');
|
||||
$this->labelStatusShort[self::STATUS_CREDITED] = $langs->trans('StatusCredited');
|
||||
if ($this->type == 'bank-transfer') {
|
||||
$this->labelStatus[self::STATUS_DEBITED] = $langs->trans('StatusDebited');
|
||||
$this->labelStatusShort[self::STATUS_DEBITED] = $langs->trans('StatusDebited');
|
||||
} else {
|
||||
$this->labelStatus[self::STATUS_CREDITED] = $langs->trans('StatusCredited');
|
||||
$this->labelStatusShort[self::STATUS_CREDITED] = $langs->trans('StatusCredited');
|
||||
}
|
||||
}
|
||||
|
||||
$statusType = 'status1';
|
||||
if ($status == self::STATUS_TRANSFERED) {
|
||||
$statusType = 'status3';
|
||||
}
|
||||
if ($status == self::STATUS_CREDITED) {
|
||||
if ($status == self::STATUS_CREDITED || $status == self::STATUS_DEBITED) {
|
||||
$statusType = 'status6';
|
||||
}
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
|
||||
|
||||
@ -135,6 +136,7 @@ if (empty($reshook)) {
|
||||
|
||||
$form = new Form($db);
|
||||
$formother = new FormOther($db);
|
||||
$formfile = new FormFile($db);
|
||||
$tva_static = new Tva($db);
|
||||
$bankstatic = new Account($db);
|
||||
$accountingjournal = new AccountingJournal($db);
|
||||
@ -445,7 +447,13 @@ while ($i < min($num, $limit)) {
|
||||
|
||||
// Ref
|
||||
if (!empty($arrayfields['t.rowid']['checked'])) {
|
||||
print '<td>'.$tva_static->getNomUrl(1).'</td>';
|
||||
print '<td>';
|
||||
print $tva_static->getNomUrl(1);
|
||||
$filename = dol_sanitizeFileName($tva_static->ref);
|
||||
$filedir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($tva_static->ref);
|
||||
$urlsource = $_SERVER['PHP_SELF'].'?id='.$tva_static->id;
|
||||
print $formfile->getDocumentsLink($tva_static->element, $filename, $filedir, '', 'valignmiddle paddingleft2imp');
|
||||
print '</td>';
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
@ -531,7 +531,7 @@ abstract class CommonDocGenerator
|
||||
$totalUp += $line->subprice * $line->qty;
|
||||
}
|
||||
|
||||
// @GS: Calculate total up and total discount percentage
|
||||
// Calculate total up and total discount percentage
|
||||
// Note that this added fields does not match a field into database in Dolibarr (Dolibarr manage discount on lines not as a global property of object)
|
||||
$resarray['object_total_up'] = $totalUp;
|
||||
$resarray['object_total_up_locale'] = price($resarray['object_total_up'], 0, $outputlangs);
|
||||
|
||||
@ -123,6 +123,12 @@ abstract class CommonObject
|
||||
*/
|
||||
protected $table_ref_field = '';
|
||||
|
||||
/**
|
||||
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
|
||||
* @var integer
|
||||
*/
|
||||
public $restrictiononfksoc = 0;
|
||||
|
||||
|
||||
|
||||
// Following vars are used by some objects only. We keep this property here in CommonObject to be able to provide common method using them.
|
||||
|
||||
@ -981,13 +981,15 @@ class FormFile
|
||||
* You may want to call this into a div like this:
|
||||
* print '<div class="inline-block valignmiddle">'.$formfile->getDocumentsLink($element_doc, $filename, $filedir).'</div>';
|
||||
*
|
||||
* @param string $modulepart propal, facture, facture_fourn, ...
|
||||
* @param string $modulepart 'propal', 'facture', 'facture_fourn', ...
|
||||
* @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module.
|
||||
* @param string $filedir Full path to directory to scan
|
||||
* @param string $filter Filter filenames on this regex string (Example: '\.pdf$')
|
||||
* @param string $morecss Add more css to the download picto
|
||||
* @param string $allfiles 0=Only generated docs, 1=All files
|
||||
* @return string Output string with HTML link of documents (might be empty string). This also fill the array ->infofiles
|
||||
*/
|
||||
public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter = '')
|
||||
public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter = '', $morecss = 'valignmiddle', $allfiles = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
@ -1005,12 +1007,11 @@ class FormFile
|
||||
$entity = ((!empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1); // If entity id not found in $filedir this is entity 1 by default
|
||||
}
|
||||
|
||||
// Get list of files starting with name of ref (but not followed by "-" to discard uploaded files and get only generated files)
|
||||
// @todo Why not showing by default all files by just removing the '[^\-]+' at end of regex ?
|
||||
if (!empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP)) {
|
||||
$filterforfilesearch = preg_quote(basename($modulesubdir), '/');
|
||||
// Get list of files starting with name of ref (Note: files with '^ref\.extension' are generated files, files with '^ref-...' are uploaded files)
|
||||
if ($allfiles || !empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP)) {
|
||||
$filterforfilesearch = '^'.preg_quote(basename($modulesubdir), '/');
|
||||
} else {
|
||||
$filterforfilesearch = preg_quote(basename($modulesubdir), '/').'[^\-]+';
|
||||
$filterforfilesearch = '^'.preg_quote(basename($modulesubdir), '/').'\.';
|
||||
}
|
||||
$file_list = dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // We also discard .meta and .png preview
|
||||
|
||||
@ -1019,7 +1020,7 @@ class FormFile
|
||||
$out .= '<!-- html.formfile::getDocumentsLink -->'."\n";
|
||||
if (!empty($file_list)) {
|
||||
$out = '<dl class="dropdown inline-block">
|
||||
<dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto('', 'listlight', '', 0, 0, 0, '', 'valignmiddle').'</a></dt>
|
||||
<dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto('', 'listlight', '', 0, 0, 0, '', $morecss).'</a></dt>
|
||||
<dd><div class="multichoicedoc" style="position:absolute;left:100px;" ><ul class="ulselectedfields">';
|
||||
$tmpout = '';
|
||||
|
||||
|
||||
@ -2242,7 +2242,7 @@ function dol_most_recent_file($dir, $regexfilter = '', $excludefilter = array('(
|
||||
* Security check when accessing to a document (used by document.php, viewimage.php and webservices to get documents).
|
||||
* TODO Replace code that set $accesallowed by a call to restrictedArea()
|
||||
*
|
||||
* @param string $modulepart Module of document ('module', 'module_user_temp', 'module_user' or 'module_temp')
|
||||
* @param string $modulepart Module of document ('module', 'module_user_temp', 'module_user' or 'module_temp'). Exemple: 'medias', 'invoice', 'logs', 'tax-vat', ...
|
||||
* @param string $original_file Relative path with filename, relative to modulepart.
|
||||
* @param string $entity Restrict onto entity (0=no restriction)
|
||||
* @param User $fuser User object (forced)
|
||||
@ -2270,10 +2270,13 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
|
||||
$entity = 0;
|
||||
}
|
||||
}
|
||||
// Fix modulepart
|
||||
// Fix modulepart for backward compatibility
|
||||
if ($modulepart == 'users') {
|
||||
$modulepart = 'user';
|
||||
}
|
||||
if ($modulepart == 'tva') {
|
||||
$modulepart = 'tax-vat';
|
||||
}
|
||||
|
||||
//print 'dol_check_secure_access_document modulepart='.$modulepart.' original_file='.$original_file.' entity='.$entity;
|
||||
dol_syslog('dol_check_secure_access_document modulepart='.$modulepart.' original_file='.$original_file.' entity='.$entity);
|
||||
@ -2443,7 +2446,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
|
||||
$accessallowed = 1;
|
||||
}
|
||||
$original_file = (!empty($conf->product->multidir_temp[$entity]) ? $conf->product->multidir_temp[$entity] : $conf->service->multidir_temp[$entity]).'/'.$original_file;
|
||||
} elseif (in_array($modulepart, array('tax', 'tax-vat')) && !empty($conf->tax->dir_output)) {
|
||||
} elseif (in_array($modulepart, array('tax', 'tax-vat', 'tva')) && !empty($conf->tax->dir_output)) {
|
||||
// Wrapping for taxes
|
||||
if ($fuser->rights->tax->charges->{$lire}) {
|
||||
$accessallowed = 1;
|
||||
|
||||
@ -334,7 +334,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
|
||||
// Accounting
|
||||
$tmpentry = array(
|
||||
'enabled'=>(!empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled) || !empty($conf->asset->enabled) || !empty($conf->intracommreport->enabled)),
|
||||
'perms'=>(!empty($user->rights->compta->resultat->lire) || !empty($user->rights->accounting->mouvements->lire) || !empty($user->rights->asset->read) || !empty($user->rights->intracommreport->read)),
|
||||
'perms'=>(!empty($user->rights->compta->resultat->lire) || !empty($user->rights->accounting->comptarapport->lire) || !empty($user->rights->accounting->mouvements->lire) || !empty($user->rights->asset->read) || !empty($user->rights->intracommreport->read)),
|
||||
'module'=>'comptabilite|accounting|asset|intracommreport'
|
||||
);
|
||||
$menu_arr[] = array(
|
||||
@ -1206,7 +1206,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
|
||||
|
||||
// Accounting (Double entries)
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$permtoshowmenu = (!empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire);
|
||||
//$permtoshowmenu = (!empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire);
|
||||
//$newmenu->add("/accountancy/index.php?leftmenu=accountancy", $langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy');
|
||||
|
||||
// Configuration
|
||||
@ -1343,7 +1343,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
|
||||
}
|
||||
|
||||
// Accounting
|
||||
$newmenu->add("/accountancy/index.php?leftmenu=accountancy_accountancy", $langs->trans("MenuAccountancy"), 0, $user->rights->accounting->mouvements->lire, '', $mainmenu, 'accountancy', 1, '', '', '', img_picto('', 'accountancy', 'class="paddingright pictofixedwidth"'));
|
||||
$newmenu->add("/accountancy/index.php?leftmenu=accountancy_accountancy", $langs->trans("MenuAccountancy"), 0, $user->rights->accounting->mouvements->lire || $user->rights->accounting->comptarapport->lire, '', $mainmenu, 'accountancy', 1, '', '', '', img_picto('', 'accountancy', 'class="paddingright pictofixedwidth"'));
|
||||
|
||||
// General Ledger
|
||||
$newmenu->add("/accountancy/bookkeeping/listbyaccount.php?mainmenu=accountancy&leftmenu=accountancy_accountancy", $langs->trans("Bookkeeping"), 1, $user->rights->accounting->mouvements->lire);
|
||||
|
||||
@ -175,6 +175,9 @@ class Odf
|
||||
'<style:style style:name="supText" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>'
|
||||
);
|
||||
|
||||
$customStyles = array();
|
||||
$fontDeclarations = array();
|
||||
|
||||
$convertedValue = $this->_replaceHtmlWithOdtTag($this->_getDataFromHtml($value), $customStyles, $fontDeclarations);
|
||||
|
||||
foreach ($customStyles as $key => $val) {
|
||||
@ -540,8 +543,9 @@ IMG;
|
||||
*/
|
||||
private function _parse($type = 'content')
|
||||
{
|
||||
// Search all tags fou into condition to complete $this->vars, so we will proceed all tests even if not defined
|
||||
// Search all tags found into condition to complete $this->vars, so we will proceed all tests even if not defined
|
||||
$reg='@\[!--\sIF\s([{}a-zA-Z0-9\.\,_]+)\s--\]@smU';
|
||||
$matches = array();
|
||||
preg_match_all($reg, $this->contentXml, $matches, PREG_SET_ORDER);
|
||||
|
||||
//var_dump($this->vars);exit;
|
||||
|
||||
@ -596,3 +596,5 @@ create table llx_onlinesignature
|
||||
pathoffile varchar(255)
|
||||
)ENGINE=innodb;
|
||||
|
||||
-- VMYSQL4.3 ALTER TABLE llx_partnership MODIFY COLUMN date_partnership_end date NULL;
|
||||
-- VPGSQL8.2 ALTER TABLE llx_partnership ALTER COLUMN date_partnership_end DROP NOT NULL;
|
||||
|
||||
@ -32,6 +32,9 @@
|
||||
|
||||
-- Missing in v14 or lower
|
||||
|
||||
-- VMYSQL4.3 ALTER TABLE llx_partnership MODIFY COLUMN date_partnership_end date NULL;
|
||||
-- VPGSQL8.2 ALTER TABLE llx_partnership ALTER COLUMN date_partnership_end DROP NOT NULL;
|
||||
|
||||
|
||||
-- v15
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ CREATE TABLE llx_partnership(
|
||||
fk_soc integer,
|
||||
fk_member integer,
|
||||
date_partnership_start date NOT NULL,
|
||||
date_partnership_end date NOT NULL,
|
||||
date_partnership_end date NULL,
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id, 0 = all
|
||||
reason_decline_or_cancel text NULL,
|
||||
date_creation datetime NOT NULL,
|
||||
|
||||
@ -1193,6 +1193,9 @@ SetupDescription2=The following two sections are mandatory (the two first entrie
|
||||
SetupDescription3=<a href="%s">%s -> %s</a><br><br>Basic parameters used to customize the default behavior of your application (e.g for country-related features).
|
||||
SetupDescription4=<a href="%s">%s -> %s</a><br><br>This software is a suite of many modules/applications. The modules related to your needs must be enabled and configured. Menu entries will appears with the activation of these modules.
|
||||
SetupDescription5=Other Setup menu entries manage optional parameters.
|
||||
SetupDescriptionLink=<a href="%s">%s - %s</a>
|
||||
SetupDescription3b=Basic parameters used to customize the default behavior of your application (e.g for country-related features).
|
||||
SetupDescription4b=This software is a suite of many modules/applications. The modules related to your needs must be enabled and configured. Menu entries will appears with the activation of these modules.
|
||||
AuditedSecurityEvents=Security events that are audited
|
||||
NoSecurityEventsAreAduited=No security events are audited. You can enable them from menu %s
|
||||
Audit=Security events
|
||||
|
||||
@ -77,6 +77,10 @@ YourPartnershipRefusedContent=We inform you that your partnership request has be
|
||||
YourPartnershipAcceptedContent=We inform you that your partnership request has been accepted.
|
||||
YourPartnershipCanceledContent=We inform you that your partnership has been canceled.
|
||||
|
||||
CountLastUrlCheckError=Number of errors for last URL check
|
||||
LastCheckBacklink=Date of last URL check
|
||||
ReasonDeclineOrCancel=Reason for declining or canceling
|
||||
|
||||
#
|
||||
# Status
|
||||
#
|
||||
|
||||
@ -2015,27 +2015,25 @@ function top_menu_user($hideloginname = 0, $urllogout = '')
|
||||
$dropdownBody .= '<span id="topmenulogincompanyinfo-btn"><i class="fa fa-caret-right"></i> '.$langs->trans("ShowCompanyInfos").'</span>';
|
||||
$dropdownBody .= '<div id="topmenulogincompanyinfo" >';
|
||||
|
||||
if (!empty($conf->global->MAIN_INFO_SIREN)) {
|
||||
$dropdownBody .= '<br><b>'.$langs->transcountry("ProfId1Short", $mysoc->country_code).'</b>: <span>'.showValueWithClipboardCPButton($conf->global->MAIN_INFO_SIREN).'</span>';
|
||||
if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') {
|
||||
$dropdownBody .= '<br><b>'.$langs->transcountry("ProfId1", $mysoc->country_code).'</b>: <span>'.showValueWithClipboardCPButton($conf->global->MAIN_INFO_SIREN).'</span>';
|
||||
}
|
||||
if (!empty($conf->global->MAIN_INFO_SIRET)) {
|
||||
$dropdownBody .= '<br><b>'.$langs->transcountry("ProfId2Short", $mysoc->country_code).'</b>: <span>'.showValueWithClipboardCPButton($conf->global->MAIN_INFO_SIRET).'</span>';
|
||||
if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') {
|
||||
$dropdownBody .= '<br><b>'.$langs->transcountry("ProfId2", $mysoc->country_code).'</b>: <span>'.showValueWithClipboardCPButton($conf->global->MAIN_INFO_SIRET).'</span>';
|
||||
}
|
||||
if (!empty($conf->global->MAIN_INFO_APE)) {
|
||||
$dropdownBody .= '<br><b>'.$langs->transcountry("ProfId3Short", $mysoc->country_code).'</b>: <span>'.showValueWithClipboardCPButton($conf->global->MAIN_INFO_APE).'</span>';
|
||||
if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') {
|
||||
$dropdownBody .= '<br><b>'.$langs->transcountry("ProfId3", $mysoc->country_code).'</b>: <span>'.showValueWithClipboardCPButton($conf->global->MAIN_INFO_APE).'</span>';
|
||||
}
|
||||
if (!empty($conf->global->MAIN_INFO_RCS)) {
|
||||
$dropdownBody .= '<br><b>'.$langs->transcountry("ProfId4Short", $mysoc->country_code).'</b>: <span>'.showValueWithClipboardCPButton($conf->global->MAIN_INFO_RCS).'</span>';
|
||||
if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') {
|
||||
$dropdownBody .= '<br><b>'.$langs->transcountry("ProfId4", $mysoc->country_code).'</b>: <span>'.showValueWithClipboardCPButton($conf->global->MAIN_INFO_RCS).'</span>';
|
||||
}
|
||||
if (!empty($conf->global->MAIN_INFO_PROFID5)) {
|
||||
$dropdownBody .= '<br><b>'.$langs->transcountry("ProfId5Short", $mysoc->country_code).'</b>: <span>'.showValueWithClipboardCPButton($conf->global->MAIN_INFO_PROFID5).'</span>';
|
||||
if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') {
|
||||
$dropdownBody .= '<br><b>'.$langs->transcountry("ProfId5", $mysoc->country_code).'</b>: <span>'.showValueWithClipboardCPButton($conf->global->MAIN_INFO_PROFID5).'</span>';
|
||||
}
|
||||
if (!empty($conf->global->MAIN_INFO_PROFID6)) {
|
||||
$dropdownBody .= '<br><b>'.$langs->transcountry("ProfId6Short", $mysoc->country_code).'</b>: <span>'.showValueWithClipboardCPButton($conf->global->MAIN_INFO_PROFID6).'</span>';
|
||||
}
|
||||
if (!empty($conf->global->MAIN_INFO_TVAINTRA)) {
|
||||
$dropdownBody .= '<br><b>'.$langs->trans("VATIntraShort").'</b>: <span>'.showValueWithClipboardCPButton($conf->global->MAIN_INFO_TVAINTRA).'</span>';
|
||||
if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') {
|
||||
$dropdownBody .= '<br><b>'.$langs->transcountry("ProfId6", $mysoc->country_code).'</b>: <span>'.showValueWithClipboardCPButton($conf->global->MAIN_INFO_PROFID6).'</span>';
|
||||
}
|
||||
$dropdownBody .= '<br><b>'.$langs->trans("VATIntraShort").'</b>: <span>'.showValueWithClipboardCPButton($conf->global->MAIN_INFO_TVAINTRA).'</span>';
|
||||
|
||||
$dropdownBody .= '</div>';
|
||||
|
||||
|
||||
@ -100,7 +100,27 @@ class Partnership extends CommonObject
|
||||
/**
|
||||
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
|
||||
*/
|
||||
public $fields=array();
|
||||
public $fields=array(
|
||||
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
|
||||
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"),
|
||||
'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1),
|
||||
//'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnershiptype.class.php', 'label' => 'Type', 'default' => 1, 'enabled' => 1, 'visible' => 1, 'position' => 20),
|
||||
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
|
||||
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,),
|
||||
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
|
||||
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
|
||||
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',),
|
||||
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
|
||||
'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
|
||||
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
|
||||
'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
|
||||
'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,),
|
||||
'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,),
|
||||
'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('-1'=>'','0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '9'=>'Canceled'),),
|
||||
'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',),
|
||||
'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>-2,),
|
||||
'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,),
|
||||
);
|
||||
|
||||
/**
|
||||
* @var int rowid
|
||||
@ -164,7 +184,6 @@ class Partnership extends CommonObject
|
||||
// public $lines = array();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -176,32 +195,10 @@ class Partnership extends CommonObject
|
||||
|
||||
$this->db = $db;
|
||||
|
||||
$this->fields=array(
|
||||
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
|
||||
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"),
|
||||
'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1),
|
||||
//'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnershiptype.class.php', 'label' => 'Type', 'default' => 1, 'enabled' => 1, 'visible' => 1, 'position' => 20),
|
||||
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
|
||||
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,),
|
||||
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
|
||||
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
|
||||
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',),
|
||||
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
|
||||
'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
|
||||
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
|
||||
'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
|
||||
'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,),
|
||||
'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>1,),
|
||||
'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('-1'=>'','0'=>$langs->trans('Draft'), '1'=>$langs->trans('Accepted'), '2'=>$langs->trans('Refused'), '9'=>$langs->trans('Canceled')),),
|
||||
'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',),
|
||||
'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>-2,),
|
||||
'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,),
|
||||
);
|
||||
|
||||
if (!empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') {
|
||||
$this->fields['fk_member'] = array('type'=>'integer:Adherent:adherents/class/adherent.class.php:1', 'label'=>'Member', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'picto'=>'member');
|
||||
} else {
|
||||
$this->fields['fk_soc'] = array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'picto'=>'societe');
|
||||
$this->fields['fk_soc'] = array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'picto'=>'company');
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
|
||||
|
||||
@ -103,6 +103,9 @@ if ($id > 0 || $ref) {
|
||||
$object->fetch($id, $ref);
|
||||
}
|
||||
|
||||
$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire));
|
||||
$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer));
|
||||
|
||||
if ($object->id > 0) {
|
||||
if ($object->type == $object::TYPE_PRODUCT) {
|
||||
restrictedArea($user, 'produit', $object->id, 'product&product', '', '');
|
||||
@ -123,9 +126,6 @@ if ($cancel) {
|
||||
$action = '';
|
||||
}
|
||||
|
||||
$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire));
|
||||
$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer));
|
||||
|
||||
$parameters = array('socid'=>$socid, 'id_prod'=>$id);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) {
|
||||
@ -404,13 +404,23 @@ if ($id > 0 || $ref) {
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border tableforfield centpercent">';
|
||||
|
||||
// Type
|
||||
if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) {
|
||||
$typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service");
|
||||
print '<tr><td class="">';
|
||||
print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type');
|
||||
print '</td><td>';
|
||||
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Cost price. Can be used for margin module for option "calculate margin on explicit cost price
|
||||
print '<tr><td>';
|
||||
$textdesc = $langs->trans("CostPriceDescription");
|
||||
$textdesc .= "<br>".$langs->trans("CostPriceUsage");
|
||||
$text = $form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', '');
|
||||
print $form->editfieldkey($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6');
|
||||
print '</td><td colspan="2">';
|
||||
print '</td><td>';
|
||||
print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6');
|
||||
print '</td></tr>';
|
||||
|
||||
@ -425,7 +435,7 @@ if ($id > 0 || $ref) {
|
||||
|
||||
// Best buying Price
|
||||
print '<tr><td class="titlefieldcreate">'.$langs->trans("BuyingPriceMin").'</td>';
|
||||
print '<td colspan="2">';
|
||||
print '<td>';
|
||||
$product_fourn = new ProductFournisseur($db);
|
||||
if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) {
|
||||
if ($product_fourn->product_fourn_price_id > 0) {
|
||||
|
||||
@ -717,8 +717,18 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_
|
||||
$soc->id = $socid;
|
||||
$soc->fetch($socid);
|
||||
|
||||
// Type
|
||||
if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) {
|
||||
$typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service");
|
||||
print '<tr><td class="">';
|
||||
print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type');
|
||||
print '</td><td>';
|
||||
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Selling price
|
||||
print '<tr><td class="titlefield">';
|
||||
print '<tr><td class="titlefieldcreate">';
|
||||
print $langs->trans("SellingPrice");
|
||||
print '</td>';
|
||||
print '<td colspan="2">';
|
||||
@ -791,13 +801,33 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_
|
||||
}
|
||||
} else {
|
||||
if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { // using this option is a bug. kept for backward compatibility
|
||||
// Type
|
||||
if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) {
|
||||
$typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service");
|
||||
print '<tr><td class="">';
|
||||
print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type');
|
||||
print '</td><td>';
|
||||
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// We show only vat for level 1
|
||||
print '<tr><td class="titlefield">'.$langs->trans("DefaultTaxRate").'</td>';
|
||||
print '<tr><td class="titlefieldcreate">'.$langs->trans("DefaultTaxRate").'</td>';
|
||||
print '<td colspan="2">'.vatrate($object->multiprices_tva_tx[1], true).'</td>';
|
||||
print '</tr>';
|
||||
} else {
|
||||
// Type
|
||||
if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) {
|
||||
$typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service");
|
||||
print '<tr><td class="">';
|
||||
print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type');
|
||||
print '</td><td>';
|
||||
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// TVA
|
||||
print '<tr><td class="titlefield">'.$langs->trans("DefaultTaxRate").'</td><td>';
|
||||
print '<tr><td class="titlefieldcreate">'.$langs->trans("DefaultTaxRate").'</td><td>';
|
||||
|
||||
$positiverates = '';
|
||||
if (price2num($object->tva_tx)) {
|
||||
|
||||
@ -77,6 +77,7 @@ $batchnumber = GETPOST('batch_number', 'san_alpha');
|
||||
if (!empty($batchnumber)) {
|
||||
$batchnumber = trim($batchnumber);
|
||||
}
|
||||
$cost_price = GETPOST('cost_price', 'alpha');
|
||||
|
||||
// Security check
|
||||
if ($user->socid) {
|
||||
@ -113,6 +114,9 @@ $hookmanager->initHooks(array('stockproductcard', 'globalcard'));
|
||||
|
||||
$error = 0;
|
||||
|
||||
$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire));
|
||||
$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer));
|
||||
|
||||
if ($object->id > 0) {
|
||||
if ($object->type == $object::TYPE_PRODUCT) {
|
||||
restrictedArea($user, 'produit', $object->id, 'product&product', '', '');
|
||||
@ -139,6 +143,21 @@ if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if ($action == 'setcost_price') {
|
||||
if ($id) {
|
||||
$result = $object->fetch($id);
|
||||
$object->cost_price = price2num($cost_price);
|
||||
$result = $object->update($object->id, $user);
|
||||
if ($result > 0) {
|
||||
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
||||
$action = '';
|
||||
} else {
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer)) {
|
||||
$seuil_stock_alerte = GETPOST('seuil_stock_alerte');
|
||||
$desiredstock = GETPOST('desiredstock');
|
||||
@ -600,9 +619,9 @@ if ($id > 0 || $ref) {
|
||||
if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) {
|
||||
$typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service");
|
||||
print '<tr><td class="">';
|
||||
print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans('Type');
|
||||
print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type');
|
||||
print '</td><td>';
|
||||
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat);
|
||||
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -618,7 +637,7 @@ if ($id > 0 || $ref) {
|
||||
$textdesc .= "<br>".$langs->trans("CostPriceUsage");
|
||||
$text = $form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', '');
|
||||
print $form->editfieldkey($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6');
|
||||
print '</td><td colspan="2">';
|
||||
print '</td><td>';
|
||||
print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6');
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
@ -729,7 +729,7 @@ if ($id) {
|
||||
if ($action == 'edit') {
|
||||
print '<tr><td class="fieldrequired">' . $langs->trans("Amount") . '</td><td><input name="amount" size="10" value="' . price($object->amount) . '"></td></tr>';
|
||||
} else {
|
||||
print '<tr><td>' . $langs->trans("Amount") . '</td><td>' . price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency) . '</td></tr>';
|
||||
print '<tr><td>' . $langs->trans("Amount") . '</td><td><span class="amount">' . price($object->amount, 0, $langs, 1, -1, -1, $conf->currency) . '</span></td></tr>';
|
||||
}
|
||||
|
||||
// Default mode of payment
|
||||
|
||||
@ -647,6 +647,9 @@ textarea.centpercent {
|
||||
.large {
|
||||
font-size: 125%;
|
||||
}
|
||||
.double {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
.h1 .small, .h1 small, .h2 .small, .h2 small, .h3 .small, .h3 small, h1 .small, h1 small, h2 .small, h2 small, h3 .small, h3 small {
|
||||
font-size: 65%;
|
||||
@ -736,6 +739,9 @@ textarea.centpercent {
|
||||
.paddingleft2 {
|
||||
padding-<?php print $left; ?>: 2px;
|
||||
}
|
||||
.paddingleft2imp {
|
||||
padding-<?php print $left; ?>: 2px !important;
|
||||
}
|
||||
.paddingright {
|
||||
padding-<?php print $right; ?>: 4px;
|
||||
}
|
||||
|
||||
@ -878,12 +878,18 @@ textarea.centpercent {
|
||||
.paddingleft2 {
|
||||
padding-<?php print $left; ?>: 2px;
|
||||
}
|
||||
.paddingleft2imp {
|
||||
padding-<?php print $left; ?>: 2px !important;
|
||||
}
|
||||
.paddingright {
|
||||
padding-<?php print $right; ?>: 4px;
|
||||
}
|
||||
.paddingright2 {
|
||||
padding-<?php print $right; ?>: 2px;
|
||||
}
|
||||
.paddingright2imp {
|
||||
padding-<?php print $right; ?>: 2px !important;
|
||||
}
|
||||
.marginleft2 {
|
||||
margin-<?php print $left; ?>: 2px;
|
||||
}
|
||||
|
||||
@ -22,9 +22,13 @@
|
||||
|
||||
/**
|
||||
* \file htdocs/user/group/perms.php
|
||||
* \brief Onglet user et permissions de la fiche utilisateur
|
||||
* \brief Page to set permissions of a user group record
|
||||
*/
|
||||
|
||||
if (!defined('CSRFCHECK_WITH_TOKEN')) {
|
||||
define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
|
||||
}
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
||||
@ -41,6 +45,10 @@ $module = GETPOST('module', 'alpha');
|
||||
$rights = GETPOST('rights', 'int');
|
||||
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'groupperms'; // To manage different context of search
|
||||
|
||||
if (!isset($id) || empty($id)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Define if user can read permissions
|
||||
$canreadperms = ($user->admin || $user->rights->user->user->lire);
|
||||
// Define if user can modify group permissions
|
||||
@ -53,12 +61,15 @@ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
|
||||
$caneditperms = ($user->admin || $user->rights->user->group_advance->write);
|
||||
}
|
||||
|
||||
// Security check
|
||||
//$result = restrictedArea($user, 'user', $id, 'usergroup', '');
|
||||
if (!$canreadperms) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$object = new Usergroup($db);
|
||||
$object->fetch($id);
|
||||
$object->getrights();
|
||||
|
||||
$entity = $conf->entity;
|
||||
|
||||
@ -79,7 +90,7 @@ if ($reshook < 0) {
|
||||
if (empty($reshook)) {
|
||||
if ($action == 'addrights' && $caneditperms) {
|
||||
$editgroup = new Usergroup($db);
|
||||
$result = $editgroup->fetch($id);
|
||||
$result = $editgroup->fetch($object->id);
|
||||
if ($result > 0) {
|
||||
$result = $editgroup->addrights($rights, $module, '', $entity);
|
||||
if ($result < 0) {
|
||||
@ -88,6 +99,9 @@ if (empty($reshook)) {
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$user->clearrights();
|
||||
$user->getrights();
|
||||
}
|
||||
|
||||
if ($action == 'delrights' && $caneditperms) {
|
||||
@ -101,11 +115,14 @@ if (empty($reshook)) {
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$user->clearrights();
|
||||
$user->getrights();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
@ -114,11 +131,6 @@ $form = new Form($db);
|
||||
llxHeader('', $langs->trans("Permissions"));
|
||||
|
||||
if ($object->id > 0) {
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$object->getrights(); // Reload permission
|
||||
|
||||
$head = group_prepare_head($object);
|
||||
$title = $langs->trans("Group");
|
||||
print dol_get_fiche_head($head, 'rights', $title, -1, 'group');
|
||||
@ -165,8 +177,8 @@ if ($object->id > 0) {
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."usergroup_rights as gr";
|
||||
$sql .= " WHERE gr.fk_id = r.id";
|
||||
$sql .= " AND gr.entity = ".$entity;
|
||||
$sql .= " AND gr.fk_usergroup = ".$object->id;
|
||||
$sql .= " AND gr.entity = ".((int) $entity);
|
||||
$sql .= " AND gr.fk_usergroup = ".((int) $object->id);
|
||||
|
||||
dol_syslog("get user perms", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
@ -186,6 +198,10 @@ if ($object->id > 0) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
/*
|
||||
* Part to add/remove permissions
|
||||
*/
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/user/group/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
|
||||
@ -193,9 +209,6 @@ if ($object->id > 0) {
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
/*
|
||||
* Ecran ajout/suppression permission
|
||||
*/
|
||||
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
|
||||
@ -235,26 +248,26 @@ if ($object->id > 0) {
|
||||
print '<td>'.$langs->trans("Module").'</td>';
|
||||
if ($caneditperms) {
|
||||
print '<td class="center nowrap">';
|
||||
print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&module=allmodules&token='.newToken().'">'.$langs->trans("All")."</a>";
|
||||
print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&module=allmodules&confirm=yes&token='.newToken().'">'.$langs->trans("All")."</a>";
|
||||
print '/';
|
||||
print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&entity='.$entity.'&module=allmodules&token='.newToken().'">'.$langs->trans("None")."</a>";
|
||||
print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&entity='.$entity.'&module=allmodules&confirm=yes&token='.newToken().'">'.$langs->trans("None")."</a>";
|
||||
print '</td>';
|
||||
}
|
||||
print '<td class="center" width="24"> </td>';
|
||||
print '<td>'.$langs->trans("Permissions").'</td>';
|
||||
if ($user->admin) {
|
||||
print '<td class="right">'.$langs->trans("ID").'</td>';
|
||||
print '<td class="right"></td>';
|
||||
}
|
||||
print '</tr>'."\n";
|
||||
|
||||
$sql = "SELECT r.id, r.libelle as label, r.module";
|
||||
$sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
|
||||
$sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
|
||||
$sql .= " AND r.entity = ".$entity;
|
||||
$sql .= " AND r.entity = ".((int) $entity);
|
||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
|
||||
$sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable
|
||||
}
|
||||
$sql .= " ORDER BY r.module, r.id";
|
||||
$sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
@ -265,13 +278,16 @@ if ($object->id > 0) {
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
// If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it
|
||||
// If line is for a module that does not exist anymore (absent of includes/module), we ignore it
|
||||
if (empty($modules[$obj->module])) {
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($oldmod <> $obj->module) {
|
||||
$objMod = $modules[$obj->module];
|
||||
|
||||
// Break found, it's a new module to catch
|
||||
if (isset($obj->module) && ($oldmod <> $obj->module)) {
|
||||
$oldmod = $obj->module;
|
||||
|
||||
// Break detected, we get objMod
|
||||
@ -286,21 +302,22 @@ if ($object->id > 0) {
|
||||
print '</td>';
|
||||
if ($caneditperms) {
|
||||
print '<td class="center nowrap">';
|
||||
print '<a class="reposition" title='.$langs->trans("All").' alt='.$langs->trans("All").' href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&module='.$obj->module.'&token='.newToken().'">'.$langs->trans("All")."</a>";
|
||||
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.$langs->trans("All").'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&module='.$obj->module.'&token='.newToken().'">'.$langs->trans("All")."</a>";
|
||||
print '/';
|
||||
print '<a class="reposition" title='.$langs->trans("None").' alt='.$langs->trans("None").' href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&entity='.$entity.'&module='.$obj->module.'&token='.newToken().'">'.$langs->trans("None")."</a>";
|
||||
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.$langs->trans("None").'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&entity='.$entity.'&module='.$obj->module.'&token='.newToken().'">'.$langs->trans("None")."</a>";
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td> </td>';
|
||||
}
|
||||
print '<td colspan="2"> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
|
||||
// Permission id
|
||||
if ($user->admin) {
|
||||
print '<td class="right"></td>';
|
||||
}
|
||||
|
||||
print '</tr>';
|
||||
print '</tr>'."\n";
|
||||
}
|
||||
|
||||
print '<!-- '.$obj->module.'->'.$obj->perms.($obj->subperms ? '->'.$obj->subperms : '').' -->'."\n";
|
||||
@ -315,7 +332,7 @@ if ($object->id > 0) {
|
||||
if (in_array($obj->id, $permsgroupbyentity[$entity])) {
|
||||
// Own permission by group
|
||||
if ($caneditperms) {
|
||||
print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&entity='.$entity.'&rights='.$obj->id.'&token='.newToken().'">';
|
||||
print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&token='.newToken().'">';
|
||||
//print img_edit_remove($langs->trans("Remove"));
|
||||
print img_picto($langs->trans("Remove"), 'switch_on');
|
||||
print '</a></td>';
|
||||
@ -326,7 +343,7 @@ if ($object->id > 0) {
|
||||
} else {
|
||||
// Do not own permission
|
||||
if ($caneditperms) {
|
||||
print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&rights='.$obj->id.'&token='.newToken().'">';
|
||||
print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&token='.newToken().'">';
|
||||
//print img_edit_add($langs->trans("Add"));
|
||||
print img_picto($langs->trans("Add"), 'switch_off');
|
||||
print '</a></td>';
|
||||
@ -336,7 +353,7 @@ if ($object->id > 0) {
|
||||
} else {
|
||||
// Do not own permission
|
||||
if ($caneditperms) {
|
||||
print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&rights='.$obj->id.'&token='.newToken().'">';
|
||||
print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&token='.newToken().'">';
|
||||
//print img_edit_add($langs->trans("Add"));
|
||||
print img_picto($langs->trans("Add"), 'switch_off');
|
||||
print '</a></td>';
|
||||
@ -344,12 +361,25 @@ if ($object->id > 0) {
|
||||
print '<td> </td>';
|
||||
}
|
||||
|
||||
$permlabel = ($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label)));
|
||||
print '<td class="maxwidthonsmartphone">'.$permlabel.'</td>';
|
||||
// Description of permission
|
||||
$permlabel = (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label)));
|
||||
print '<td>';
|
||||
print $permlabel;
|
||||
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
|
||||
if (preg_match('/_advance$/', $obj->perms)) {
|
||||
print ' <span class="opacitymedium">('.$langs->trans("AdvancedModeOnly").')</span>';
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Permission id
|
||||
if ($user->admin) {
|
||||
print '<td class="right"><span class="opacitymedium">'.$obj->id.'</span></td>';
|
||||
print '<td class="right">';
|
||||
$htmltext = $langs->trans("ID").': '.$obj->id;
|
||||
$htmltext .= '<br>'.$langs->trans("Permission").': user->rights->'.$obj->module.'->'.$obj->perms.($obj->subperms ? '->'.$obj->subperms : '');
|
||||
print $form->textwithpicto('', $htmltext);
|
||||
//print '<span class="opacitymedium">'.$obj->id.'</span>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print '</tr>'."\n";
|
||||
|
||||
@ -90,7 +90,7 @@ $hookmanager->initHooks(array('usercard', 'userperms', 'globalcard'));
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$parameters = array('id'=>$socid);
|
||||
$parameters = array('socid'=>$socid);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
@ -193,7 +193,7 @@ $permsuser = array();
|
||||
|
||||
$sql = "SELECT DISTINCT ur.fk_id";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."user_rights as ur";
|
||||
$sql .= " WHERE ur.entity = ".$entity;
|
||||
$sql .= " WHERE ur.entity = ".((int) $entity);
|
||||
$sql .= " AND ur.fk_user = ".((int) $object->id);
|
||||
|
||||
dol_syslog("get user perms", LOG_DEBUG);
|
||||
@ -386,7 +386,7 @@ if ($result) {
|
||||
|
||||
// Picto and label of module
|
||||
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
|
||||
//print img_object('', $picto, 'class="pictoobjectwidth"').' '.$objMod->getName();
|
||||
//print img_object('', $picto, 'class="inline-block pictoobjectwidth"').' '.$objMod->getName();
|
||||
print '</td>';
|
||||
|
||||
// Permission and tick
|
||||
|
||||
Loading…
Reference in New Issue
Block a user