Merge pull request #18129 from evarisk-theo/add-ticket-categories-views
NEW: ticket categories views
This commit is contained in:
commit
f7ed6c8a0b
@ -142,6 +142,11 @@ if ($id > 0 && $removeelem > 0) {
|
|||||||
$tmpobject = new User($db);
|
$tmpobject = new User($db);
|
||||||
$result = $tmpobject->fetch($removeelem);
|
$result = $tmpobject->fetch($removeelem);
|
||||||
$elementtype = 'user';
|
$elementtype = 'user';
|
||||||
|
} elseif ($type == Categorie::TYPE_TICKET && $user->rights->ticket->write) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
|
||||||
|
$tmpobject = new Ticket($db);
|
||||||
|
$result = $tmpobject->fetch($removeelem);
|
||||||
|
$elementtype = 'ticket';
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $object->del_type($tmpobject, $elementtype);
|
$result = $object->del_type($tmpobject, $elementtype);
|
||||||
@ -167,7 +172,8 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi
|
|||||||
if ($elemid && $action == 'addintocategory' &&
|
if ($elemid && $action == 'addintocategory' &&
|
||||||
(($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) ||
|
(($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) ||
|
||||||
($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) ||
|
($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) ||
|
||||||
($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer)
|
($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) ||
|
||||||
|
($type == Categorie::TYPE_TICKET && $user->rights->ticket->write)
|
||||||
)) {
|
)) {
|
||||||
if ($type == Categorie::TYPE_PRODUCT) {
|
if ($type == Categorie::TYPE_PRODUCT) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||||
@ -181,6 +187,10 @@ if ($elemid && $action == 'addintocategory' &&
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||||
$newobject = new Societe($db);
|
$newobject = new Societe($db);
|
||||||
$elementtype = 'supplier';
|
$elementtype = 'supplier';
|
||||||
|
} elseif ($type == Categorie::TYPE_TICKET) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
|
||||||
|
$newobject = new Ticket($db);
|
||||||
|
$elementtype = 'ticket';
|
||||||
}
|
}
|
||||||
$result = $newobject->fetch($elemid);
|
$result = $newobject->fetch($elemid);
|
||||||
|
|
||||||
@ -1024,6 +1034,78 @@ if ($type == Categorie::TYPE_WAREHOUSE) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($type == Categorie::TYPE_TICKET) {
|
||||||
|
$permission = ($user->rights->categorie->creer || $user->rights->categorie->creer);
|
||||||
|
|
||||||
|
$tickets = $object->getObjectsInCateg($type, 0, $limit, $offset);
|
||||||
|
if ($tickets < 0) {
|
||||||
|
dol_print_error($db, $object->error, $object->errors);
|
||||||
|
} else {
|
||||||
|
// Form to add record into a category
|
||||||
|
$showclassifyform = 1;
|
||||||
|
if ($showclassifyform) {
|
||||||
|
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("AddTicketIntoCategory").' ';
|
||||||
|
$form->selectTickets('', '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($tickets); $nbtotalofrecords = ''; $newcardbutton = '';
|
||||||
|
print_barre_liste($langs->trans("Ticket"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'ticket', 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($tickets) > 0) {
|
||||||
|
$i = 0;
|
||||||
|
foreach ($tickets as $ticket) {
|
||||||
|
$i++;
|
||||||
|
if ($i > $limit) break;
|
||||||
|
|
||||||
|
print "\t".'<tr class="oddeven">'."\n";
|
||||||
|
print '<td class="nowrap" valign="top">';
|
||||||
|
print $ticket->getNomUrl(1);
|
||||||
|
print "</td>\n";
|
||||||
|
print '<td class="tdtop">'.$ticket->label."</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."&removeelem=".$ticket->id."'>";
|
||||||
|
print $langs->trans("DeleteFromCat");
|
||||||
|
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
|
||||||
|
print "</a>";
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print '<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
|
||||||
|
}
|
||||||
|
print "</table>\n";
|
||||||
|
|
||||||
|
print '</form>'."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|||||||
@ -17,6 +17,7 @@ ContactsCategoriesArea=Espace tags/catégories de contacts
|
|||||||
AccountsCategoriesArea=Espace des tags/categories de comptes bancaires
|
AccountsCategoriesArea=Espace des tags/categories de comptes bancaires
|
||||||
ProjectsCategoriesArea=Espace des tags/catégories des projets
|
ProjectsCategoriesArea=Espace des tags/catégories des projets
|
||||||
UsersCategoriesArea=Espace des tags/catégories des utilisateurs
|
UsersCategoriesArea=Espace des tags/catégories des utilisateurs
|
||||||
|
TicketsCategoriesArea=Espace tags/catégories des tickets
|
||||||
SubCats=Sous-catégories
|
SubCats=Sous-catégories
|
||||||
CatList=Liste des tags/catégories
|
CatList=Liste des tags/catégories
|
||||||
CatListAll=Liste de toutes les catégories (de tous types)
|
CatListAll=Liste de toutes les catégories (de tous types)
|
||||||
@ -90,6 +91,7 @@ CategorieRecursivHelp=Si l'option est activé, quand un produit est ajouté dans
|
|||||||
AddProductServiceIntoCategory=Ajouter le produit/service suivant
|
AddProductServiceIntoCategory=Ajouter le produit/service suivant
|
||||||
AddCustomerIntoCategory=Assigner cette catégorie au client
|
AddCustomerIntoCategory=Assigner cette catégorie au client
|
||||||
AddSupplierIntoCategory=Assigner cette catégorie au fournisseur
|
AddSupplierIntoCategory=Assigner cette catégorie au fournisseur
|
||||||
|
AddTicketIntoCategory=Assigner cette catégorie au ticket
|
||||||
ShowCategory=Afficher tag/catégorie
|
ShowCategory=Afficher tag/catégorie
|
||||||
ByDefaultInList=Par défaut dans la liste
|
ByDefaultInList=Par défaut dans la liste
|
||||||
ChooseCategory=Choisissez une catégorie
|
ChooseCategory=Choisissez une catégorie
|
||||||
|
|||||||
@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||||
if (!empty($conf->projet->enabled)) {
|
if (!empty($conf->projet->enabled)) {
|
||||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||||
@ -202,6 +203,10 @@ if (empty($reshook)) {
|
|||||||
$contactid = GETPOST('contactid', 'int');
|
$contactid = GETPOST('contactid', 'int');
|
||||||
$type_contact = GETPOST("type", 'alpha');
|
$type_contact = GETPOST("type", 'alpha');
|
||||||
|
|
||||||
|
// Category association
|
||||||
|
$categories = GETPOST('categories', 'array');
|
||||||
|
$object->setCategories($categories);
|
||||||
|
|
||||||
if ($contactid > 0 && $type_contact) {
|
if ($contactid > 0 && $type_contact) {
|
||||||
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
|
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
|
||||||
$result = $object->add_contact($contactid, $typeid, 'external');
|
$result = $object->add_contact($contactid, $typeid, 'external');
|
||||||
@ -312,7 +317,11 @@ if (empty($reshook)) {
|
|||||||
$object->severity_code = GETPOST('severity_code', 'alpha');
|
$object->severity_code = GETPOST('severity_code', 'alpha');
|
||||||
|
|
||||||
$ret = $object->update($user);
|
$ret = $object->update($user);
|
||||||
if ($ret <= 0) {
|
if ($ret > 0) {
|
||||||
|
// Category association
|
||||||
|
$categories = GETPOST('categories', 'array');
|
||||||
|
$object->setCategories($categories);
|
||||||
|
} else {
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1054,6 +1063,13 @@ if ($action == 'create' || $action == 'presend') {
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Categories
|
||||||
|
if ($conf->categorie->enabled) {
|
||||||
|
print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td colspan="3">';
|
||||||
|
print $form->showCategories($object->id, Categorie::TYPE_TICKET, 1);
|
||||||
|
print "</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user