Merge pull request #1184 from altatof/saisie_marges
define and manage user permissions for margin module
This commit is contained in:
commit
9e16d505c9
@ -49,6 +49,8 @@ For users:
|
|||||||
- New : Add pdf link into supplier invoice list and supplier order list
|
- New : Add pdf link into supplier invoice list and supplier order list
|
||||||
- New : Genrate auto the PDF for supplier invoice
|
- New : Genrate auto the PDF for supplier invoice
|
||||||
- New : Add category into filter webservice thirdparty method getListOfThirdParties
|
- New : Add category into filter webservice thirdparty method getListOfThirdParties
|
||||||
|
- New : Allow to define margin or mark rate during quoting, ordering, invoicing
|
||||||
|
- New : User permissions on margin module
|
||||||
|
|
||||||
For translators:
|
For translators:
|
||||||
- Qual: Normalized sort order of all languages files with english reference files.
|
- Qual: Normalized sort order of all languages files with english reference files.
|
||||||
|
|||||||
@ -2609,6 +2609,7 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
global $conf,$langs,$object,$hookmanager;
|
global $conf,$langs,$object,$hookmanager;
|
||||||
global $form,$bcnd,$var;
|
global $form,$bcnd,$var;
|
||||||
|
global $user;
|
||||||
//Line extrafield
|
//Line extrafield
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
$extrafieldsline = new ExtraFields($this->db);
|
$extrafieldsline = new ExtraFields($this->db);
|
||||||
@ -2633,6 +2634,7 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
global $conf,$langs,$object,$hookmanager;
|
global $conf,$langs,$object,$hookmanager;
|
||||||
global $form,$bcnd,$var;
|
global $form,$bcnd,$var;
|
||||||
|
global $user;
|
||||||
|
|
||||||
//Line extrafield
|
//Line extrafield
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
@ -2658,6 +2660,7 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
global $conf,$user,$langs,$object,$hookmanager;
|
global $conf,$user,$langs,$object,$hookmanager;
|
||||||
global $form,$bcnd,$var;
|
global $form,$bcnd,$var;
|
||||||
|
global $user;
|
||||||
|
|
||||||
//Line extrafield
|
//Line extrafield
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
@ -2729,9 +2732,9 @@ abstract class CommonObject
|
|||||||
else
|
else
|
||||||
print '<td align="right" width="80">'.$langs->trans('CostPrice').'</td>';
|
print '<td align="right" width="80">'.$langs->trans('CostPrice').'</td>';
|
||||||
|
|
||||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous)
|
||||||
print '<td align="right" width="50">'.$langs->trans('MarginRate').'</td>';
|
print '<td align="right" width="50">'.$langs->trans('MarginRate').'</td>';
|
||||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous)
|
||||||
print '<td align="right" width="50">'.$langs->trans('MarkRate').'</td>';
|
print '<td align="right" width="50">'.$langs->trans('MarkRate').'</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3168,6 +3171,8 @@ abstract class CommonObject
|
|||||||
|
|
||||||
if (! empty($user->societe_id)) return;
|
if (! empty($user->societe_id)) return;
|
||||||
|
|
||||||
|
if (! $user->rights->margins->liretous) return;
|
||||||
|
|
||||||
$marginInfo = $this->getMarginInfos($force_price);
|
$marginInfo = $this->getMarginInfos($force_price);
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
@ -3220,3 +3225,4 @@ abstract class CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
@ -79,8 +79,8 @@ class modMargin extends DolibarrModules
|
|||||||
|
|
||||||
// New pages on tabs
|
// New pages on tabs
|
||||||
$this->tabs = array(
|
$this->tabs = array(
|
||||||
'product:+margin:Margins:margins:$conf->margin->enabled:/margin/tabs/productMargins.php?id=__ID__',
|
'product:+margin:Margins:margins:$user->rights->margins->liretous:/margin/tabs/productMargins.php?id=__ID__',
|
||||||
'thirdparty:+margin:Margins:margins:$conf->margin->enabled && empty($user->societe_id):/margin/tabs/thirdpartyMargins.php?socid=__ID__'
|
'thirdparty:+margin:Margins:margins:empty($user->societe_id) && $user->rights->margins->liretous:/margin/tabs/thirdpartyMargins.php?socid=__ID__'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -106,11 +106,30 @@ class modMargin extends DolibarrModules
|
|||||||
'url'=>'/margin/index.php',
|
'url'=>'/margin/index.php',
|
||||||
'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||||
'position'=>100,
|
'position'=>100,
|
||||||
'enabled'=>'$conf->margin->enabled', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled.
|
'enabled'=>'$user->rights->margins->liretous', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled.
|
||||||
'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
|
'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
|
||||||
'target'=>'',
|
'target'=>'',
|
||||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||||
$r++;
|
$r++;
|
||||||
|
|
||||||
|
// Permissions
|
||||||
|
$this->rights = array();
|
||||||
|
$this->rights_class = 'margins';
|
||||||
|
$r=0;
|
||||||
|
|
||||||
|
$r++;
|
||||||
|
$this->rights[$r][0] = 59001; // id de la permission
|
||||||
|
$this->rights[$r][1] = 'Visualiser les marges'; // libelle de la permission
|
||||||
|
$this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
|
||||||
|
$this->rights[$r][3] = 1; // La permission est-elle une permission par defaut
|
||||||
|
$this->rights[$r][4] = 'liretous';
|
||||||
|
|
||||||
|
$r++;
|
||||||
|
$this->rights[$r][0] = 59002; // id de la permission
|
||||||
|
$this->rights[$r][1] = 'Définir les marges'; // libelle de la permission
|
||||||
|
$this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
|
||||||
|
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
|
||||||
|
$this->rights[$r][4] = 'creer';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -61,13 +61,21 @@ if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($ob
|
|||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
if(! empty($conf->global->DISPLAY_MARGIN_RATES))
|
if ($user->rights->margins->creer)
|
||||||
{
|
{
|
||||||
echo '<td align="right">'.$langs->trans('MarginRate').'</td>';
|
if(! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||||
|
{
|
||||||
|
echo '<td align="right">'.$langs->trans('MarginRate').'</td>';
|
||||||
|
}
|
||||||
|
if(! empty($conf->global->DISPLAY_MARK_RATES))
|
||||||
|
{
|
||||||
|
echo '<td align="right">'.$langs->trans('MarkRate').'</td>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(! empty($conf->global->DISPLAY_MARK_RATES))
|
else
|
||||||
{
|
{
|
||||||
echo '<td align="right">'.$langs->trans('MarkRate').'</td>';
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
|
||||||
|
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -125,12 +133,26 @@ if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($ob
|
|||||||
value="<?php echo (isset($_POST["buying_price"])?$_POST["buying_price"]:''); ?>">
|
value="<?php echo (isset($_POST["buying_price"])?$_POST["buying_price"]:''); ?>">
|
||||||
</td>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
|
if ($user->rights->margins->creer)
|
||||||
|
{
|
||||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||||
echo '<td align="right"><input type="text" size="2" name="np_marginRate" value="'.(isset($_POST["np_marginRate"])?$_POST["np_marginRate"]:'').'">%</td>';
|
echo '<td align="right"><input type="text" size="2" name="np_marginRate" value="'.(isset($_POST["np_marginRate"])?$_POST["np_marginRate"]:'').'">%</td>';
|
||||||
}
|
}
|
||||||
elseif (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
elseif (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||||
echo '<td align="right"><input type="text" size="2" name="np_markRate" value="'.(isset($_POST["np_markRate"])?$_POST["np_markRate"]:'').'">%</td>';
|
echo '<td align="right"><input type="text" size="2" name="np_markRate" value="'.(isset($_POST["np_markRate"])?$_POST["np_markRate"]:'').'">%</td>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||||
|
$colspan++;
|
||||||
|
$coldisplay++;
|
||||||
|
}
|
||||||
|
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||||
|
$colspan++;
|
||||||
|
$coldisplay++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<td align="center" valign="middle" colspan="<?php echo $colspan; ?>"><input type="submit" class="button" value="<?php echo $langs->trans('Add'); ?>" name="addline"></td>
|
<td align="center" valign="middle" colspan="<?php echo $colspan; ?>"><input type="submit" class="button" value="<?php echo $langs->trans('Add'); ?>" name="addline"></td>
|
||||||
@ -190,7 +212,9 @@ if (! empty($conf->service->enabled) && $dateSelector)
|
|||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<?php if ($conf->margin->enabled) { ?>
|
<?php if ($conf->margin->enabled && $user->rights->margins->creer)
|
||||||
|
{
|
||||||
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var npRate = null;
|
var npRate = null;
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
@ -123,11 +123,11 @@
|
|||||||
if (! empty($conf->margin->enabled) && empty($user->societe_id)) {
|
if (! empty($conf->margin->enabled) && empty($user->societe_id)) {
|
||||||
?>
|
?>
|
||||||
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo price($line->pa_ht); ?></td>
|
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo price($line->pa_ht); ?></td>
|
||||||
<?php if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {?>
|
<?php if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) {?>
|
||||||
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo (($line->pa_ht == 0)?'n/a':price($line->marge_tx).'%'); ?></td>
|
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo (($line->pa_ht == 0)?'n/a':price($line->marge_tx).'%'); ?></td>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {?>
|
if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {?>
|
||||||
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo price($line->marque_tx).'%'; ?></td>
|
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo price($line->marque_tx).'%'; ?></td>
|
||||||
<?php } } ?>
|
<?php } } ?>
|
||||||
|
|
||||||
|
|||||||
@ -63,14 +63,6 @@ jQuery(document).ready(function() {
|
|||||||
$colspan = 4;
|
$colspan = 4;
|
||||||
if (! empty($usemargins))
|
if (! empty($usemargins))
|
||||||
{
|
{
|
||||||
if(! empty($conf->global->DISPLAY_MARGIN_RATES))
|
|
||||||
{
|
|
||||||
echo '<td align="right">'.$langs->trans('MarginRate').'</td>';
|
|
||||||
}
|
|
||||||
if(! empty($conf->global->DISPLAY_MARK_RATES))
|
|
||||||
{
|
|
||||||
echo '<td align="right">'.$langs->trans('MarkRate').'</td>';
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<?php
|
<?php
|
||||||
@ -78,6 +70,23 @@ if (! empty($usemargins))
|
|||||||
echo $langs->trans('BuyingPrice');
|
echo $langs->trans('BuyingPrice');
|
||||||
else
|
else
|
||||||
echo $langs->trans('CostPrice');
|
echo $langs->trans('CostPrice');
|
||||||
|
|
||||||
|
if ($user->rights->margins->creer)
|
||||||
|
{
|
||||||
|
if(! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||||
|
{
|
||||||
|
echo '<td align="right">'.$langs->trans('MarginRate').'</td>';
|
||||||
|
}
|
||||||
|
if(! empty($conf->global->DISPLAY_MARK_RATES))
|
||||||
|
{
|
||||||
|
echo '<td align="right">'.$langs->trans('MarkRate').'</td>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
|
||||||
|
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
@ -125,18 +134,32 @@ else {
|
|||||||
$colspan = 4;
|
$colspan = 4;
|
||||||
if (! empty($usemargins))
|
if (! empty($usemargins))
|
||||||
{
|
{
|
||||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
|
||||||
echo '<td align="right"><input type="text" size="2" name="np_marginRate" value="'.(isset($_POST["np_marginRate"])?$_POST["np_marginRate"]:'').'">%</td>';
|
|
||||||
}
|
|
||||||
elseif (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
|
||||||
echo '<td align="right"><input type="text" size="2" name="np_markRate" value="'.(isset($_POST["np_markRate"])?$_POST["np_markRate"]:'').'">%</td>';
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<select id="fournprice" name="fournprice" class="flat" style="display: none;"></select>
|
<select id="fournprice" name="fournprice" class="flat" style="display: none;"></select>
|
||||||
<input type="text" size="5" id="buying_price" name="buying_price" class="flat" value="<?php echo (isset($_POST["buying_price"])?$_POST["buying_price"]:''); ?>">
|
<input type="text" size="5" id="buying_price" name="buying_price" class="flat" value="<?php echo (isset($_POST["buying_price"])?$_POST["buying_price"]:''); ?>">
|
||||||
</td>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
|
if ($user->rights->margins->creer)
|
||||||
|
{
|
||||||
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||||
|
echo '<td align="right"><input type="text" size="2" name="np_marginRate" value="'.(isset($_POST["np_marginRate"])?$_POST["np_marginRate"]:'').'">%</td>';
|
||||||
|
}
|
||||||
|
elseif (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||||
|
echo '<td align="right"><input type="text" size="2" name="np_markRate" value="'.(isset($_POST["np_markRate"])?$_POST["np_markRate"]:'').'">%</td>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||||
|
$colspan++;
|
||||||
|
$coldisplay++;
|
||||||
|
}
|
||||||
|
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||||
|
$colspan++;
|
||||||
|
$coldisplay++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<td align="center" valign="middle" colspan="<?php echo $colspan; ?>">
|
<td align="center" valign="middle" colspan="<?php echo $colspan; ?>">
|
||||||
@ -204,6 +227,10 @@ if (! empty($usemargins))
|
|||||||
{
|
{
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
<?php
|
||||||
|
if ($user->rights->margins->creer)
|
||||||
|
{
|
||||||
|
?>
|
||||||
var npRate = null;
|
var npRate = null;
|
||||||
<?php
|
<?php
|
||||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
|
||||||
@ -294,7 +321,9 @@ if (! empty($usemargins))
|
|||||||
function formatFloat(num) {
|
function formatFloat(num) {
|
||||||
return roundFloat(num).replace('.', ',');
|
return roundFloat(num).replace('.', ',');
|
||||||
}
|
}
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
$("#idprod").change(function() {
|
$("#idprod").change(function() {
|
||||||
$("#fournprice options").remove();
|
$("#fournprice options").remove();
|
||||||
$("#fournprice").hide();
|
$("#fournprice").hide();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user