Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add category feature on Fichinter 2/3 #31813

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions htdocs/categories/class/categorie.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Copyright (C) 2013-2018 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2016-2024 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2023-2024 Benjamin Falière <benjamin.faliere@altairis.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
Expand Down Expand Up @@ -62,6 +62,7 @@ class Categorie extends CommonObject
const TYPE_WEBSITE_PAGE = 'website_page';
const TYPE_TICKET = 'ticket';
const TYPE_KNOWLEDGEMANAGEMENT = 'knowledgemanagement';
const TYPE_FICHINTER = 'fichinter';

/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
Expand All @@ -86,7 +87,8 @@ class Categorie extends CommonObject
'actioncomm' => 10,
'website_page' => 11,
'ticket' => 12,
'knowledgemanagement' => 13
'knowledgemanagement' => 13,
'fichinter' => 14
);

/**
Expand All @@ -108,7 +110,8 @@ class Categorie extends CommonObject
10 => 'actioncomm',
11 => 'website_page',
12 => 'ticket',
13 => 'knowledgemanagement'
13 => 'knowledgemanagement',
14 => 'fichinter'
);

/**
Expand Down Expand Up @@ -153,7 +156,8 @@ class Categorie extends CommonObject
'actioncomm' => 'ActionComm',
'website_page' => 'WebsitePage',
'ticket' => 'Ticket',
'knowledgemanagement' => 'KnowledgeRecord'
'knowledgemanagement' => 'KnowledgeRecord',
'fichinter' => 'Fichinter',
);

/**
Expand All @@ -175,7 +179,8 @@ class Categorie extends CommonObject
'actioncomm' => 'ActioncommCategoriesArea',
'website_page' => 'WebsitePageCategoriesArea',
'ticket' => 'TicketCategoriesArea',
'knowledgemanagement' => 'KnowledgemanagementCategoriesArea'
'knowledgemanagement' => 'KnowledgemanagementCategoriesArea',
'fichinter' => 'FichinterCategoriesArea'
);

/**
Expand All @@ -190,7 +195,8 @@ class Categorie extends CommonObject
'account' => 'bank_account', // old for bank account
'project' => 'projet',
'warehouse' => 'entrepot',
'knowledgemanagement' => 'knowledgemanagement_knowledgerecord'
'knowledgemanagement' => 'knowledgemanagement_knowledgerecord',
'fichinter' => 'fichinter'
);

/**
Expand Down Expand Up @@ -695,6 +701,7 @@ public function delete($user, $notrigger = 0)
'categorie_contact' => 'fk_categorie',
'categorie_fournisseur' => 'fk_categorie',
'categorie_knowledgemanagement' => array('field' => 'fk_categorie', 'enabled' => isModEnabled('knowledgemanagement')),
'categorie_fichinter' => array('field' => 'fk_categorie', 'enabled' => isModEnabled('ficheinter')),
'categorie_member' => 'fk_categorie',
'categorie_user' => 'fk_categorie',
'categorie_product' => 'fk_categorie',
Expand Down
114 changes: 104 additions & 10 deletions htdocs/categories/viewcat.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2023-2024 Charlene Benke <charlene@patas-monkey.com>
*
* 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
Expand Down Expand Up @@ -165,6 +166,11 @@
$tmpobject = new Ticket($db);
$result = $tmpobject->fetch($removeelem);
$elementtype = 'ticket';
} elseif ($type == Categorie::TYPE_FICHINTER && $user->hasRight('ficheinter', 'write')) {
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
$tmpobject = new Fichinter($db);
$result = $tmpobject->fetch($removeelem);
$elementtype = 'fichinter';
}

$result = $object->del_type($tmpobject, $elementtype);
Expand Down Expand Up @@ -196,6 +202,7 @@
($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) ||
($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) ||
($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) ||
($type == Categorie::TYPE_FICHINTER && $user->hasRight('ficheinter', 'write')) ||
($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer'))
) {
$newobject = null;
Expand All @@ -215,6 +222,10 @@
require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
$newobject = new Ticket($db);
$elementtype = 'ticket';
} elseif ($type == Categorie::TYPE_FICHINTER) {
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
$newobject = new Fichinter($db);
$elementtype = 'fichinter';
} elseif ($type == Categorie::TYPE_PROJECT) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$newobject = new Project($db);
Expand Down Expand Up @@ -544,16 +555,16 @@
// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
print_barre_liste($langs->trans("ProductsAndServices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit);

$showclassifyform = 1;
if ($showclassifyform) {
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>';
print $langs->trans("AddProductServiceIntoCategory").' &nbsp;';
$form->select_produits(0, 'elemid', '', 0, 0, -1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null);
print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
print '</tr>';
print '</table>';
}
// $showclassifyform = 1;
// if ($showclassifyform) {
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>';
print $langs->trans("AddProductServiceIntoCategory").' &nbsp;';
$form->select_produits(0, 'elemid', '', 0, 0, -1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null);
print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
print '</tr>';
print '</table>';
// }

print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
Expand Down Expand Up @@ -1322,6 +1333,89 @@
}
}

// List of Fichinter
if ($type == Categorie::TYPE_FICHINTER) {
if ($user->hasRight("fichinter", "lire")) {
$permission = $user->hasRight('categorie', 'creer');;

$fichinters = $object->getObjectsInCateg($type, 0, $limit, $offset);
if ($fichinters < 0) {
dol_print_error($db, $object->error, $object->errors);
} else {
// Form to add record into a category
// $showclassifyform = 1;
// if ($showclassifyform) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formintervention.class.php';
$formfichinter = new FormIntervention($db);

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="addintocategory">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>';
print $langs->trans("AddFichinterIntoCategory").' &nbsp;';
print $formfichinter->select_interventions('', '', 'elemid');
print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
print '</tr>';
print '</table>';
print '</form>';
// }

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($fichinters);
$nbtotalofrecords = '';
$newcardbutton = '';

print_barre_liste($langs->trans("Intervention"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_intervention', 0, $newcardbutton, '', $limit);
print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";

if (count($fichinters) > 0) {
$i = 0;
foreach ($fichinters as $fichinter) {
$i++;
if ($i > $limit) break;

print "\t".'<tr class="oddeven">'."\n";
print '<td class="nowrap tdtop">';
print $fichinter->getNomUrl(1);
print "</td>\n";
print '<td class="tdtop">'.$fichinter->description."</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."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$fichinter->id."'>";
//print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
print "</a>";
}
print '</td>';
print "</tr>\n";
}
} else {
print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
}
print "</table>\n";
print '</form>'."\n";
}
} else {
print_barre_liste($langs->trans("Intervention"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'fichinter');
accessforbidden("NotEnoughPermissions", 0, 0);
}
}

// Note that $action and $object may have been modified by some hooks
$parameters = array('type' => $type, 'id' => $id, 'label' => $label);
$reshook = $hookmanager->executeHooks('addMoreCategoriesList', $parameters, $object, $action);
Expand Down
2 changes: 2 additions & 0 deletions htdocs/langs/en_US/categories.lang
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ CategorieRecursivHelp=If option is on, when you add an object into a subcategory
AddProductServiceIntoCategory=Assign category to the product/service
AddCustomerIntoCategory=Assign category to customer
AddSupplierIntoCategory=Assign category to supplier
AddFichinterIntoCategory=Assign category to interventional
Intervention=Intervention
AssignCategoryTo=Assign category to
ShowCategory=Show tag/category
ByDefaultInList=By default in list
Expand Down