can tag actioncomm
This commit is contained in:
parent
9dcf53c65e
commit
9040f6d9c7
@ -44,6 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.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.'/categories/class/categorie.class.php';
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("companies", "other", "commercial", "bills", "orders", "agenda"));
|
$langs->loadLangs(array("companies", "other", "commercial", "bills", "orders", "agenda"));
|
||||||
@ -374,6 +375,10 @@ if (empty($reshook) && $action == 'add')
|
|||||||
{
|
{
|
||||||
if (! $object->error)
|
if (! $object->error)
|
||||||
{
|
{
|
||||||
|
// Category association
|
||||||
|
$categories = GETPOST('categories', 'array');
|
||||||
|
$object->setCategories($categories);
|
||||||
|
|
||||||
unset($_SESSION['assignedtouser']);
|
unset($_SESSION['assignedtouser']);
|
||||||
|
|
||||||
$moreparam='';
|
$moreparam='';
|
||||||
@ -595,6 +600,10 @@ if (empty($reshook) && $action == 'update')
|
|||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
|
// Category association
|
||||||
|
$categories = GETPOST('categories', 'array');
|
||||||
|
$object->setCategories($categories);
|
||||||
|
|
||||||
unset($_SESSION['assignedtouser']);
|
unset($_SESSION['assignedtouser']);
|
||||||
|
|
||||||
$db->commit();
|
$db->commit();
|
||||||
@ -1000,6 +1009,14 @@ if ($action == 'create')
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($conf->categorie->enabled) {
|
||||||
|
// Categories
|
||||||
|
print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
|
||||||
|
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1);
|
||||||
|
print $form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, '', 0, '100%');
|
||||||
|
print "</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|
||||||
@ -1411,6 +1428,19 @@ if ($id > 0)
|
|||||||
print $form->select_dolusers($object->userdoneid> 0?$object->userdoneid:-1, 'doneby', 1);
|
print $form->select_dolusers($object->userdoneid> 0?$object->userdoneid:-1, 'doneby', 1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
// Tags-Categories
|
||||||
|
if ($conf->categorie->enabled) {
|
||||||
|
print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
|
||||||
|
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1);
|
||||||
|
$c = new Categorie($db);
|
||||||
|
$cats = $c->containing($object->id, Categorie::TYPE_ACTIONCOMM);
|
||||||
|
$arrayselected = array();
|
||||||
|
foreach ($cats as $cat) {
|
||||||
|
$arrayselected[] = $cat->id;
|
||||||
|
}
|
||||||
|
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
|
||||||
|
print "</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
@ -1716,6 +1746,12 @@ if ($id > 0)
|
|||||||
}
|
}
|
||||||
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, 'actioncomm', 1);
|
||||||
|
print "</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|||||||
@ -1501,6 +1501,50 @@ class ActionComm extends CommonObject
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets object to supplied categories.
|
||||||
|
*
|
||||||
|
* Deletes object from existing categories not supplied.
|
||||||
|
* Adds it to non existing supplied categories.
|
||||||
|
* Existing categories are left untouch.
|
||||||
|
*
|
||||||
|
* @param int[]|int $categories Category or categories IDs
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setCategories($categories)
|
||||||
|
{
|
||||||
|
// Handle single category
|
||||||
|
if (! is_array($categories)) {
|
||||||
|
$categories = array($categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get current categories
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||||
|
$c = new Categorie($this->db);
|
||||||
|
$existing = $c->containing($this->id, Categorie::TYPE_ACTIONCOMM, 'id');
|
||||||
|
|
||||||
|
// Diff
|
||||||
|
if (is_array($existing)) {
|
||||||
|
$to_del = array_diff($existing, $categories);
|
||||||
|
$to_add = array_diff($categories, $existing);
|
||||||
|
} else {
|
||||||
|
$to_del = array(); // Nothing to delete
|
||||||
|
$to_add = $categories;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process
|
||||||
|
foreach($to_del as $del) {
|
||||||
|
if ($c->fetch($del) > 0) {
|
||||||
|
$c->del_type($this, Categorie::TYPE_ACTIONCOMM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($to_add as $add) {
|
||||||
|
if ($c->fetch($add) > 0) {
|
||||||
|
$c->add_type($this, Categorie::TYPE_ACTIONCOMM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user