Skip to content

Commit

Permalink
Fix table shown when there is no perm
Browse files Browse the repository at this point in the history
Fix edit admin status of another admin
  • Loading branch information
eldy committed May 18, 2019
1 parent 41cb13b commit c6ccb92
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 5 deletions.
16 changes: 13 additions & 3 deletions htdocs/comm/propal/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -2421,10 +2421,15 @@
}

print '<div class="div-table-responsive-no-min">';
print '<table id="tablelines" class="noborder noshadow" width="100%">';
if (! empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline'))
{
print '<table id="tablelines" class="noborder noshadow" width="100%">';
}

if (! empty($object->lines))
{
$ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
}

// Form to add new line
if ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines')
Expand All @@ -2439,16 +2444,21 @@
}
}

print '</table>';
if (! empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline'))
{
print '</table>';
}
print '</div>';

print "</form>\n";

dol_fiche_end();


/*
* Boutons Actions
* Button Actions
*/

if ($action != 'presend') {
print '<div class="tabsAction">';

Expand Down
54 changes: 54 additions & 0 deletions htdocs/modulebuilder/template/myobject_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,60 @@ function init_myfunc()
dol_fiche_end();


/*
* Lines
*/

if (! empty($object->table_element_line))
{
// Show object lines
$result = $object->getLinesArray();

print ' <form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '#addline' : '#line_' . GETPOST('lineid', 'int')) . '" method="POST">
<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline') . '">
<input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="' . $object->id . '">
';

if (! empty($conf->use_javascript_ajax) && $object->status == 0) {
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
}

print '<div class="div-table-responsive-no-min">';
if (! empty($object->lines) && $object->status == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline')
{
print '<table id="tablelines" class="noborder noshadow" width="100%">';
}

if (! empty($object->lines))
{
$ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
}

// Form to add new line
if ($object->status == 0 && $permissiontoadd && $action != 'selectlines')
{
if ($action != 'editline')
{
// Add products/services form
$object->formAddObjectLine(1, $mysoc, $soc);

$parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
}
}

if (! empty($object->lines) && $object->status == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline')
{
print '</table>';
}
print '</div>';

print "</form>\n";
}


// Buttons for actions
if ($action != 'presend' && $action != 'editline') {
print '<div class="tabsAction">'."\n";
Expand Down
4 changes: 2 additions & 2 deletions htdocs/user/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@
&& ($user->id != $object->id) // Don't downgrade ourself
&& (
(empty($conf->multicompany->enabled) && $nbAdmin >= 1)
|| (! empty($conf->multicompany->enabled) && ($object->entity > 0 || $nbSuperAdmin > 1)) // Don't downgrade a superadmin if alone
|| (! empty($conf->multicompany->enabled) && (($object->entity > 0 || ($user->entity == 0 && $object->entity == 0)) || $nbSuperAdmin > 1)) // Don't downgrade a superadmin if alone
)
)
{
Expand Down Expand Up @@ -2543,7 +2543,7 @@
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
{
print "<tr>".'<td>'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($object->entity, 'entity', '', 0, 1); // last parameter 1 means, show also a choice 0=>'all entities'
print "<td>".$mc->select_entities($object->entity, 'entity', '', 0, 1, false, false, 1); // last parameter 1 means, show also a choice 0=>'all entities'
print "</td></tr>\n";
}
else
Expand Down

0 comments on commit c6ccb92

Please sign in to comment.