Standardize code

This commit is contained in:
Laurent Destailleur 2020-04-02 14:32:54 +02:00
parent 83fdc5b901
commit 386b27a14c
2 changed files with 151 additions and 93 deletions

View File

@ -292,6 +292,7 @@ if ($user->rights->categorie->supprimer)
print "</div>";
$newcardbutton = '';
if (! empty($user->rights->categorie->creer))
{
$link = DOL_URL_ROOT.'/categories/card.php';
@ -300,9 +301,9 @@ if (! empty($user->rights->categorie->creer))
$link .= '&catorigin='.$object->id;
$link .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.'&id='.$id);
print '<div class="right">';
print dolGetButtonTitle($langs->trans('NewCategory'), '', 'fa fa-plus-circle', $link);
print "</div>";
$newcardbutton = '<div class="right">';
$newcardbutton .= dolGetButtonTitle($langs->trans('NewCategory'), '', 'fa fa-plus-circle', $link);
$newcardbutton .= '</div>';
}
@ -311,6 +312,10 @@ if (! empty($user->rights->categorie->creer))
*/
print '<div class="fichecenter">';
print load_fiche_titre($langs->trans("SubCats"), $newcardbutton);
print '<table class="liste nohover" width="100%">';
print '<tr class="liste_titre">';
@ -442,19 +447,23 @@ $arrayofmassactions = array(
);
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$typeid = $type;
// List of products or services (type is type of category)
if ($type == Categorie::TYPE_PRODUCT)
{
$prods = $object->getObjectsInCateg("product", 0, $limit, $offset);
$permission = ($user->rights->produit->creer || $user->rights->service->creer);
$prods = $object->getObjectsInCateg($type, 0, $limit, $offset);
if ($prods < 0)
{
dol_print_error($db, $prods->error, $prods->errors);
}
else
{
$showclassifyform = 1; $typeid = Categorie::TYPE_PRODUCT;
// Form to add record into a category
$showclassifyform = 1;
if ($showclassifyform)
{
print '<br>';
@ -468,7 +477,7 @@ if ($type == Categorie::TYPE_PRODUCT)
print '<tr class="liste_titre"><td>';
print $langs->trans("AddProductServiceIntoCategory").' &nbsp;';
$form->select_produits('', 'elemid', '', 0, 0, -1, 2, '', 1);
print '<input type="submit" class="button" value="'.$langs->trans("ClassifyInCategory").'"></td>';
print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
print '</tr>';
print '</table>';
print '</form>';
@ -483,9 +492,10 @@ if ($type == Categorie::TYPE_PRODUCT)
print '<br>';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = ''; $newcardbutton = '';
print_barre_liste($langs->trans("ProductsAndServices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
print_barre_liste($langs->trans("ProductsAndServices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit);
print "<table class='noborder' width='100%'>\n";
print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
if (count($prods) > 0)
@ -503,17 +513,11 @@ if ($type == Categorie::TYPE_PRODUCT)
print '<td class="tdtop">'.$prod->label."</td>\n";
// Link to delete from category
print '<td class="right">';
$permission = 0;
if ($type == Categorie::TYPE_PRODUCT) $permission = ($user->rights->produit->creer || $user->rights->service->creer);
if ($type == Categorie::TYPE_SUPPLIER) $permission = $user->rights->societe->creer;
if ($type == Categorie::TYPE_CUSTOMER) $permission = $user->rights->societe->creer;
if ($type == Categorie::TYPE_MEMBER) $permission = $user->rights->adherent->creer;
if ($type == Categorie::TYPE_PROJECT) $permission = $user->rights->projet->creer;
if ($permission)
{
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$prod->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink');
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
}
print '</td>';
@ -522,7 +526,7 @@ if ($type == Categorie::TYPE_PRODUCT)
}
else
{
print '<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoProduct").'</td></tr>';
print '<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
}
print "</table>\n";
@ -532,7 +536,9 @@ if ($type == Categorie::TYPE_PRODUCT)
if ($type == Categorie::TYPE_SUPPLIER)
{
$socs = $object->getObjectsInCateg("supplier", 0, $limit, $offset);
$permission = $user->rights->societe->creer;
$socs = $object->getObjectsInCateg($type, 0, $limit, $offset);
if ($socs < 0)
{
dol_print_error($db, $socs->error, $socs->errors);
@ -548,7 +554,7 @@ if ($type == Categorie::TYPE_SUPPLIER)
print '<br>';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = ''; $newcardbutton = '';
print_barre_liste($langs->trans("Suppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
print_barre_liste($langs->trans("Suppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name")."</td></tr>\n";
@ -567,17 +573,11 @@ if ($type == Categorie::TYPE_SUPPLIER)
print "</td>\n";
// Link to delete from category
print '<td class="right">';
$permission = 0;
if ($type == Categorie::TYPE_PRODUCT) $permission = ($user->rights->produit->creer || $user->rights->service->creer);
if ($type == Categorie::TYPE_SUPPLIER) $permission = $user->rights->societe->creer;
if ($type == Categorie::TYPE_CUSTOMER) $permission = $user->rights->societe->creer;
if ($type == Categorie::TYPE_MEMBER) $permission = $user->rights->adherent->creer;
if ($type == Categorie::TYPE_PROJECT) $permission = $user->rights->projet->creer;
if ($permission)
{
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$soc->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink');
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
}
print '</td>';
@ -587,7 +587,7 @@ if ($type == Categorie::TYPE_SUPPLIER)
}
else
{
print '<tr class="oddeven"><td class="opacitymedium">'.$langs->trans("ThisCategoryHasNoSupplier").'</td></tr>';
print '<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
}
print "</table>\n";
@ -597,7 +597,9 @@ if ($type == Categorie::TYPE_SUPPLIER)
if ($type == Categorie::TYPE_CUSTOMER)
{
$socs = $object->getObjectsInCateg("customer", 0, $limit, $offset);
$permission = $user->rights->societe->creer;
$socs = $object->getObjectsInCateg($type, 0, $limit, $offset);
if ($socs < 0)
{
dol_print_error($db, $socs->error, $socs->errors);
@ -613,7 +615,7 @@ if ($type == Categorie::TYPE_CUSTOMER)
print '<br>';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = ''; $newcardbutton = '';
print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name").'</td></tr>'."\n";
@ -632,17 +634,11 @@ if ($type == Categorie::TYPE_CUSTOMER)
print "</td>\n";
// Link to delete from category
print '<td class="right">';
$permission = 0;
if ($type == Categorie::TYPE_PRODUCT) $permission = ($user->rights->produit->creer || $user->rights->service->creer);
if ($type == Categorie::TYPE_SUPPLIER) $permission = $user->rights->societe->creer;
if ($type == Categorie::TYPE_CUSTOMER) $permission = $user->rights->societe->creer;
if ($type == Categorie::TYPE_MEMBER) $permission = $user->rights->adherent->creer;
if ($type == Categorie::TYPE_PROJECT) $permission = $user->rights->projet->creer;
if ($permission)
{
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$soc->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink');
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
}
print '</td>';
@ -651,7 +647,7 @@ if ($type == Categorie::TYPE_CUSTOMER)
}
else
{
print '<tr class="oddeven"><td class="opacitymedium">'.$langs->trans("ThisCategoryHasNoCustomer").'</td></tr>';
print '<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
}
print "</table>\n";
@ -664,7 +660,9 @@ if ($type == Categorie::TYPE_MEMBER)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$prods = $object->getObjectsInCateg("member", 0, $limit, $offset);
$permission = $user->rights->adherent->creer;
$prods = $object->getObjectsInCateg($type, 0, $limit, $offset);
if ($prods < 0)
{
dol_print_error($db, $prods->error, $prods->errors);
@ -680,7 +678,7 @@ if ($type == Categorie::TYPE_MEMBER)
print '<br>';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = ''; $newcardbutton = '';
print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'adherents', 0, $newcardbutton, '', $limit);
print "<table class='noborder' width='100%'>\n";
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Name").'</td></tr>'."\n";
@ -702,17 +700,11 @@ if ($type == Categorie::TYPE_MEMBER)
print '<td class="tdtop">'.$member->firstname."</td>\n";
// Link to delete from category
print '<td class="right">';
$permission = 0;
if ($type == Categorie::TYPE_PRODUCT) $permission = ($user->rights->produit->creer || $user->rights->service->creer);
if ($type == Categorie::TYPE_SUPPLIER) $permission = $user->rights->societe->creer;
if ($type == Categorie::TYPE_CUSTOMER) $permission = $user->rights->societe->creer;
if ($type == Categorie::TYPE_MEMBER) $permission = $user->rights->adherent->creer;
if ($type == Categorie::TYPE_PROJECT) $permission = $user->rights->projet->creer;
if ($permission)
{
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$member->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink');
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
}
print "</tr>\n";
@ -720,7 +712,7 @@ if ($type == Categorie::TYPE_MEMBER)
}
else
{
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoMember").'</td></tr>';
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
}
print "</table>\n";
@ -731,7 +723,9 @@ if ($type == Categorie::TYPE_MEMBER)
// Categorie contact
if ($type == Categorie::TYPE_CONTACT)
{
$contacts = $object->getObjectsInCateg("contact", 0, $limit, $offset);
$permission = $user->rights->societe->creer;
$contacts = $object->getObjectsInCateg($type, 0, $limit, $offset);
if ($contacts < 0)
{
dol_print_error($db, $contacts->error, $contacts->errors);
@ -746,8 +740,11 @@ if ($type == Categorie::TYPE_CONTACT)
print '<input type="hidden" name="action" value="list">';
print '<br>';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($contacts); $nbtotalofrecords = ''; $newcardbutton = '';
print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
$param = '&limit='.$limit.'&id='.$id.'&type='.$type;
$num = count($contacts);
$nbtotalofrecords = '';
$newcardbutton = '';
print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contacts', 0, $newcardbutton, '', $limit);
print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Ref").'</td></tr>'."\n";
@ -766,17 +763,11 @@ if ($type == Categorie::TYPE_CONTACT)
print "</td>\n";
// Link to delete from category
print '<td class="right">';
$permission = 0;
if ($type == Categorie::TYPE_PRODUCT) $permission = ($user->rights->produit->creer || $user->rights->service->creer);
if ($type == Categorie::TYPE_SUPPLIER) $permission = $user->rights->societe->creer;
if ($type == Categorie::TYPE_CUSTOMER) $permission = $user->rights->societe->creer;
if ($type == Categorie::TYPE_MEMBER) $permission = $user->rights->adherent->creer;
if ($type == Categorie::TYPE_PROJECT) $permission = $user->rights->projet->creer;
if ($permission)
{
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$contact->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink');
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
}
print '</td>';
@ -785,7 +776,7 @@ if ($type == Categorie::TYPE_CONTACT)
}
else
{
print '<tr class="oddeven"><td class="opacitymedium">'.$langs->trans("ThisCategoryHasNoContact").'</td></tr>';
print '<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
}
print "</table>\n";
@ -798,7 +789,9 @@ if ($type == Categorie::TYPE_ACCOUNT)
{
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$accounts = $object->getObjectsInCateg("account", 0, $limit, $offset);
$permission = $user->rights->banque->creer;
$accounts = $object->getObjectsInCateg($type, 0, $limit, $offset);
if ($accounts < 0)
{
dol_print_error($db, $accounts->error, $accounts->errors);
@ -814,7 +807,7 @@ if ($type == Categorie::TYPE_ACCOUNT)
print '<br>';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($accounts); $nbtotalofrecords = ''; $newcardbutton = '';
print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'account', 0, $newcardbutton, '', $limit);
print "<table class='noborder' width='100%'>\n";
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
@ -835,17 +828,11 @@ if ($type == Categorie::TYPE_ACCOUNT)
print '<td class="tdtop">'.$account->number."</td>\n";
// Link to delete from category
print '<td class="right">';
$permission = 0;
if ($type == Categorie::TYPE_PRODUCT) $permission = ($user->rights->produit->creer || $user->rights->service->creer);
if ($type == Categorie::TYPE_SUPPLIER) $permission = $user->rights->societe->creer;
if ($type == Categorie::TYPE_CUSTOMER) $permission = $user->rights->societe->creer;
if ($type == Categorie::TYPE_MEMBER) $permission = $user->rights->adherent->creer;
if ($type == Categorie::TYPE_PROJECT) $permission = $user->rights->projet->creer;
if ($permission)
{
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$account->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink');
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
}
print "</tr>\n";
@ -853,7 +840,7 @@ if ($type == Categorie::TYPE_ACCOUNT)
}
else
{
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoAccount").'</td></tr>';
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
}
print "</table>\n";
@ -866,8 +853,10 @@ if ($type == Categorie::TYPE_PROJECT)
{
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$projects = $object->getObjectsInCateg("project", 0, $limit, $offset);
if ($projects < 0)
$permission = $user->rights->projet->creer;
$objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
if ($objects < 0)
{
dol_print_error($db, $object->error, $object->errors);
}
@ -881,16 +870,17 @@ if ($type == Categorie::TYPE_PROJECT)
print '<input type="hidden" name="action" value="list">';
print '<br>';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($projects); $nbtotalofrecords = ''; $newcardbutton = '';
print_barre_liste($langs->trans("Project"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = '';
print_barre_liste($langs->trans("Project"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'projects', 0, $newcardbutton, '', $limit);
print "<table class='noborder' width='100%'>\n";
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
if (count($projects) > 0)
if (count($objects) > 0)
{
$i = 0;
foreach ($projects as $key => $project)
foreach ($objects as $key => $project)
{
$i++;
if ($i > $limit) break;
@ -903,17 +893,11 @@ if ($type == Categorie::TYPE_PROJECT)
print '<td class="tdtop">'.$project->title."</td>\n";
// Link to delete from category
print '<td class="right">';
$permission = 0;
if ($type == Categorie::TYPE_PRODUCT) $permission = ($user->rights->produit->creer || $user->rights->service->creer);
if ($type == Categorie::TYPE_SUPPLIER) $permission = $user->rights->societe->creer;
if ($type == Categorie::TYPE_CUSTOMER) $permission = $user->rights->societe->creer;
if ($type == Categorie::TYPE_MEMBER) $permission = $user->rights->adherent->creer;
if ($type == Categorie::TYPE_PROJECT) $permission = $user->rights->projet->creer;
if ($permission)
{
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$project->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink');
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
}
print "</tr>\n";
@ -921,7 +905,7 @@ if ($type == Categorie::TYPE_PROJECT)
}
else
{
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoProject").'</td></tr>';
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
}
print "</table>\n";
@ -934,14 +918,25 @@ if ($type == Categorie::TYPE_USER)
{
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
$users = $object->getObjectsInCateg("user");
$users = $object->getObjectsInCateg($type);
if ($users < 0)
{
dol_print_error($db, $object->error, $object->errors);
}
else
{
print "<br>";
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="typeid" value="'.$typeid.'">';
print '<input type="hidden" name="type" value="'.$typeid.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="action" value="list">';
print '<br>';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = '';
print_barre_liste($langs->trans("Users"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'user', 0, $newcardbutton, '', $limit);
print "<table class='noborder' width='100%'>\n";
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Users").' <span class="badge">'.count($users).'</span></td></tr>'."\n";
@ -962,7 +957,7 @@ if ($type == Categorie::TYPE_USER)
{
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$type."&amp;removeelem=".$userentry->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink');
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
}
print "</tr>\n";
@ -970,12 +965,81 @@ if ($type == Categorie::TYPE_USER)
}
else
{
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoUsers").'</td></tr>';
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
}
print "</table>\n";
print '</form>'."\n";
}
}
// List of Project
if ($type == Categorie::TYPE_WAREHOUSE)
{
$permission = $user->rights->stock->creer;
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
$objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
if ($objects < 0)
{
dol_print_error($db, $object->error, $object->errors);
}
else
{
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="typeid" value="'.$typeid.'">';
print '<input type="hidden" name="type" value="'.$typeid.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="action" value="list">';
print '<br>';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = '';
print_barre_liste($langs->trans("Warehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit);
print "<table class='noborder' width='100%'>\n";
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
if (count($objects) > 0)
{
$i = 0;
foreach ($objects as $key => $project)
{
$i++;
if ($i > $limit) break;
print "\t".'<tr class="oddeven">'."\n";
print '<td class="nowrap" valign="top">';
print $project->getNomUrl(1);
print "</td>\n";
print '<td class="tdtop">'.$project->ref."</td>\n";
print '<td class="tdtop">'.$project->title."</td>\n";
// Link to delete from category
print '<td class="right">';
if ($permission)
{
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$project->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
}
print "</tr>\n";
}
}
else
{
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
}
print "</table>\n";
print '</form>'."\n";
}
}
// End of page
llxFooter();
$db->close();

View File

@ -63,13 +63,7 @@ AccountsCategoriesShort=Accounts tags/categories
ProjectsCategoriesShort=Projects tags/categories
UsersCategoriesShort=Users tags/categories
StockCategoriesShort=Warehouse tags/categories
ThisCategoryHasNoProduct=This category does not contain any product.
ThisCategoryHasNoSupplier=This category does not contain any vendor.
ThisCategoryHasNoCustomer=This category does not contain any customer.
ThisCategoryHasNoMember=This category does not contain any member.
ThisCategoryHasNoContact=This category does not contain any contact.
ThisCategoryHasNoAccount=This category does not contain any account.
ThisCategoryHasNoProject=This category does not contain any project.
ThisCategoryHasNoItems=This category does not contain any items.
CategId=Tag/category id
CatSupList=List of vendor tags/categories
CatCusList=List of customer/prospect tags/categories