Manage project category
This commit is contained in:
parent
f7c89b0044
commit
a4ce756724
@ -58,6 +58,7 @@ if ($origin)
|
||||
if ($type == Categorie::TYPE_CUSTOMER) $idCompanyOrigin = $origin;
|
||||
if ($type == Categorie::TYPE_MEMBER) $idMemberOrigin = $origin;
|
||||
if ($type == Categorie::TYPE_CONTACT) $idContactOrigin = $origin;
|
||||
if ($type == Categorie::TYPE_PROJECT) $idProjectOrigin = $origin;
|
||||
}
|
||||
|
||||
if ($catorigin && $type == Categorie::TYPE_PRODUCT) $idCatOrigin = $catorigin;
|
||||
@ -116,6 +117,11 @@ if ($action == 'add' && $user->rights->categorie->creer)
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type);
|
||||
exit;
|
||||
}
|
||||
else if ($idProjectOrigin)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&type='.$type);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type);
|
||||
@ -201,6 +207,11 @@ if (($action == 'add' || $action == 'confirmed') && $user->rights->categorie->cr
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&mesg='.urlencode($langs->trans("CatCreated")));
|
||||
exit;
|
||||
}
|
||||
else if ($idProjectOrigin)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&mesg='.urlencode($langs->trans("CatCreated")));
|
||||
exit;
|
||||
}
|
||||
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$result.'&type='.$type);
|
||||
exit;
|
||||
|
||||
@ -88,6 +88,13 @@ if ($id || $ref)
|
||||
$dbtablename = 'socpeople&societe';
|
||||
$fieldid = ! empty($ref)?'ref':'rowid';
|
||||
}
|
||||
elseif ($type == Categorie::TYPE_PROJECT) {
|
||||
$elementtype = 'project';
|
||||
$objecttype = 'project';
|
||||
$objectid = isset($id)?$id:(isset($ref)?$ref:'');
|
||||
$dbtablename = '&project';
|
||||
$fieldid = ! empty($ref)?'ref':'rowid';
|
||||
}
|
||||
}
|
||||
|
||||
// Security check
|
||||
@ -145,6 +152,13 @@ if (empty($reshook))
|
||||
$result = $object->fetch($objectid);
|
||||
$elementtype = 'contact';
|
||||
}
|
||||
if ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
$object = new Project($db);
|
||||
$result = $object->fetch($objectid);
|
||||
$elementtype = 'project';
|
||||
}
|
||||
$cat = new Categorie($db);
|
||||
$result=$cat->fetch($removecat);
|
||||
|
||||
@ -192,6 +206,13 @@ if (empty($reshook))
|
||||
$result = $object->fetch($objectid);
|
||||
$elementtype = 'contact';
|
||||
}
|
||||
if ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
$object = new Project($db);
|
||||
$result = $object->fetch($objectid);
|
||||
$elementtype = 'project';
|
||||
}
|
||||
$cat = new Categorie($db);
|
||||
$result=$cat->fetch($parent);
|
||||
|
||||
@ -607,6 +628,75 @@ else if ($id || $ref)
|
||||
|
||||
formCategory($db,$object,4,$socid, $user->rights->societe->creer);
|
||||
}
|
||||
|
||||
if ($type == Categorie::TYPE_PROJECT)
|
||||
{
|
||||
$langs->load("products");
|
||||
|
||||
/*
|
||||
* Category card for product
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
|
||||
// Product
|
||||
$product = new Product($db);
|
||||
$result = $product->fetch($id, $ref);
|
||||
|
||||
llxHeader("","",$langs->trans("Project"));
|
||||
|
||||
|
||||
$head=project_prepare_head($product);
|
||||
$titre=$langs->trans("Project");
|
||||
$picto=($object->public?'projectpub':'project');
|
||||
dol_fiche_head($head, 'category', $titre,0,$picto);
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Ref
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
|
||||
// Define a complementary filter for search of next/prev ref.
|
||||
if (! $user->rights->projet->all->lire)
|
||||
{
|
||||
$objectsListId = $object->getProjectsAuthorizedForUser($user,0,0);
|
||||
$object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")";
|
||||
}
|
||||
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
|
||||
print '</td></tr>';
|
||||
|
||||
// Label
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
|
||||
|
||||
// Third party
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
|
||||
if ($object->thirdparty->id > 0) print $object->thirdparty->getNomUrl(1, 'project');
|
||||
else print' ';
|
||||
print '</td></tr>';
|
||||
|
||||
// Visibility
|
||||
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
|
||||
if ($object->public) print $langs->trans('SharedProject');
|
||||
else print $langs->trans('PrivateProject');
|
||||
print '</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Date start
|
||||
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
|
||||
print dol_print_date($object->date_start,'day');
|
||||
print '</td></tr>';
|
||||
|
||||
// Date end
|
||||
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
|
||||
print dol_print_date($object->date_end,'day');
|
||||
print '</td></tr>';
|
||||
|
||||
formCategory($db,$product,0,$socid,($user->rights->projet->creer));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -630,6 +720,7 @@ function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1)
|
||||
if ($typeid == Categorie::TYPE_CUSTOMER) $title = $langs->trans("CustomersProspectsCategoriesShort");
|
||||
if ($typeid == Categorie::TYPE_MEMBER) $title = $langs->trans("MembersCategoriesShort");
|
||||
if ($typeid == Categorie::TYPE_CONTACT) $title = $langs->trans("ContactCategoriesShort");
|
||||
if ($typeid == Categorie::TYPE_PROJECT) $title = $langs->trans("ProjectsCategoriesShort");
|
||||
|
||||
$linktocreate='';
|
||||
if ($showclassifyform && $user->rights->categorie->creer)
|
||||
@ -674,6 +765,7 @@ function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1)
|
||||
if ($typeid == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CompanyIsInCustomersCategories");
|
||||
if ($typeid == Categorie::TYPE_MEMBER) $title=$langs->trans("MemberIsInCategories");
|
||||
if ($typeid == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactIsInCategories");
|
||||
if ($typeid == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectIsInCategories");
|
||||
print "\n";
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$title.':</td></tr>';
|
||||
@ -699,6 +791,7 @@ function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1)
|
||||
if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
|
||||
if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
|
||||
if ($typeid == Categorie::TYPE_CONTACT) $permission=$user->rights->societe->creer;
|
||||
if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
|
||||
if ($permission)
|
||||
{
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&type=".$typeid."&removecat=".$cat->id."'>";
|
||||
@ -727,6 +820,7 @@ function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1)
|
||||
if ($typeid == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CompanyHasNoCategory");
|
||||
if ($typeid == Categorie::TYPE_MEMBER) $title=$langs->trans("MemberHasNoCategory");
|
||||
if ($typeid == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactHasNoCategory");
|
||||
if ($typeid == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectHasNoCategory");
|
||||
print $title;
|
||||
print "<br/>";
|
||||
}
|
||||
|
||||
@ -50,6 +50,7 @@ class Categorie extends CommonObject
|
||||
const TYPE_CONTACT = 4; // TODO Replace this value with 'contact'
|
||||
const TYPE_USER = 4; // categorie contact and user are same ! TODO Replace this value with 'user'
|
||||
const TYPE_ACCOUNT = 5; // for bank account TODO Replace this value with 'account'
|
||||
const TYPE_PROJECT = 6;
|
||||
|
||||
/**
|
||||
* @var array ID mapping from type string
|
||||
@ -64,6 +65,7 @@ class Categorie extends CommonObject
|
||||
'contact' => 4,
|
||||
'user' => 4,
|
||||
'account' => 5,
|
||||
'project' => 6,
|
||||
);
|
||||
/**
|
||||
* @var array Foreign keys mapping from type string
|
||||
@ -78,6 +80,7 @@ class Categorie extends CommonObject
|
||||
'contact' => 'socpeople',
|
||||
'user' => 'user',
|
||||
'account' => 'account',
|
||||
'project' => 'project',
|
||||
);
|
||||
/**
|
||||
* @var array Category tables mapping from type string
|
||||
@ -92,6 +95,7 @@ class Categorie extends CommonObject
|
||||
'contact' => 'contact',
|
||||
'user' => 'user',
|
||||
'account' => 'account',
|
||||
'project' => 'project',
|
||||
);
|
||||
/**
|
||||
* @var array Object class mapping from type string
|
||||
@ -106,6 +110,7 @@ class Categorie extends CommonObject
|
||||
'contact' => 'Contact',
|
||||
'user' => 'User',
|
||||
'account' => 'Account',
|
||||
'project' => 'Project',
|
||||
);
|
||||
/**
|
||||
* @var array Object table mapping from type string
|
||||
@ -120,6 +125,7 @@ class Categorie extends CommonObject
|
||||
'contact' => 'socpeople',
|
||||
'user' => 'user',
|
||||
'account' => 'bank_account',
|
||||
'project' => 'project',
|
||||
);
|
||||
|
||||
public $element='category';
|
||||
@ -146,6 +152,7 @@ class Categorie extends CommonObject
|
||||
* @see Categorie::TYPE_CONTACT
|
||||
* @see Categorie::TYPE_USER
|
||||
* @see Categorie::TYPE_ACCOUNT
|
||||
* @see Categorie::TYPE_PROJECT
|
||||
*/
|
||||
var $type;
|
||||
|
||||
@ -514,6 +521,18 @@ class Categorie extends CommonObject
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_project";
|
||||
$sql .= " WHERE fk_category = ".$this->id;
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR);
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_lang";
|
||||
|
||||
@ -54,6 +54,7 @@ elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCateg
|
||||
elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoriesArea");
|
||||
elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactsCategoriesArea");
|
||||
elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesArea");
|
||||
elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesArea");
|
||||
else $title=$langs->trans("CategoriesArea");
|
||||
|
||||
$arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
|
||||
|
||||
@ -101,6 +101,7 @@ if ($object->id)
|
||||
elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort");
|
||||
elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort");
|
||||
else $title=$langs->trans("Category");
|
||||
|
||||
$head = categories_prepare_head($object,$type);
|
||||
|
||||
@ -152,6 +152,7 @@ elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCateg
|
||||
elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort");
|
||||
elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort");
|
||||
else $title=$langs->trans("Category");
|
||||
|
||||
$head = categories_prepare_head($object,$type);
|
||||
|
||||
@ -115,6 +115,13 @@ if ($id > 0 && $removeelem > 0)
|
||||
$result = $tmpobject->fetch($removeelem);
|
||||
$elementtype = 'account';
|
||||
}
|
||||
else if ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
$tmpobject = new Project($db);
|
||||
$result = $tmpobject->fetch($removeelem);
|
||||
$elementtype = 'project';
|
||||
}
|
||||
|
||||
$result=$object->del_type($tmpobject,$elementtype);
|
||||
if ($result < 0) dol_print_error('',$object->error);
|
||||
@ -178,6 +185,7 @@ elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCateg
|
||||
elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort");
|
||||
elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort");
|
||||
else $title=$langs->trans("Category");
|
||||
|
||||
$head = categories_prepare_head($object,$type);
|
||||
@ -360,6 +368,7 @@ if ($object->type == Categorie::TYPE_PRODUCT)
|
||||
if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
|
||||
if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
|
||||
if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
|
||||
if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
|
||||
if ($permission)
|
||||
{
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&type=".$typeid."&removeelem=".$prod->id."'>";
|
||||
@ -410,6 +419,7 @@ if ($object->type == Categorie::TYPE_SUPPLIER)
|
||||
if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
|
||||
if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
|
||||
if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
|
||||
if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
|
||||
if ($permission)
|
||||
{
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&type=".$typeid."&removeelem=".$soc->id."'>";
|
||||
@ -464,6 +474,7 @@ if($object->type == Categorie::TYPE_CUSTOMER)
|
||||
if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
|
||||
if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
|
||||
if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
|
||||
if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
|
||||
if ($permission)
|
||||
{
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&type=".$typeid."&removeelem=".$soc->id."'>";
|
||||
@ -519,6 +530,7 @@ if ($object->type == Categorie::TYPE_MEMBER)
|
||||
if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
|
||||
if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
|
||||
if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
|
||||
if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
|
||||
if ($permission)
|
||||
{
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&type=".$typeid."&removeelem=".$member->id."'>";
|
||||
@ -571,6 +583,7 @@ if($object->type == Categorie::TYPE_CONTACT)
|
||||
if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
|
||||
if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
|
||||
if ($typeid == Categorie::TYPE_CONTACT) $permission=$user->rights->societe->creer;
|
||||
if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
|
||||
if ($permission)
|
||||
{
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&type=".$typeid."&removeelem=".$contact->id."'>";
|
||||
@ -626,6 +639,7 @@ if ($object->type == Categorie::TYPE_ACCOUNT)
|
||||
if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
|
||||
if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
|
||||
if ($typeid == Categorie::TYPE_ACCOUNT) $permission=$user->rights->banque->configurer;
|
||||
if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
|
||||
if ($permission)
|
||||
{
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&type=".$typeid."&removeelem=".$account->id."'>";
|
||||
|
||||
@ -1212,6 +1212,15 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
||||
$newmenu->add("/projet/tasks/list.php", $langs->trans("List"), 1, $user->rights->projet->lire && $user->rights->projet->lire);
|
||||
$newmenu->add("/projet/activity/perweek.php", $langs->trans("NewTimeSpent"), 1, $user->rights->projet->creer && $user->rights->projet->lire);
|
||||
}
|
||||
|
||||
// Categories
|
||||
if (! empty($conf->categorie->enabled))
|
||||
{
|
||||
$langs->load("categories");
|
||||
$newmenu->add("/categories/index.php?leftmenu=cat&type=6", $langs->trans("Categories"), 0, $user->rights->categorie->lire, '', $mainmenu, 'cat');
|
||||
$newmenu->add("/categories/card.php?action=create&type=6", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer);
|
||||
//if (empty($leftmenu) || $leftmenu=="cat") $newmenu->add("/categories/list.php", $langs->trans("List"), 1, $user->rights->categorie->lire);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ CustomersCategoriesArea=Customers tags/categories area
|
||||
MembersCategoriesArea=Members tags/categories area
|
||||
ContactsCategoriesArea=Contacts tags/categories area
|
||||
AccountsCategoriesArea=Accounts tags/categories area
|
||||
PeojectCategoriesArea=Projects tags/categories area
|
||||
SubCats=Subcategories
|
||||
CatList=List of tags/categories
|
||||
NewCategory=New tag/category
|
||||
@ -36,6 +37,7 @@ ProductHasNoCategory=This product/service is not in any tags/categories
|
||||
CompanyHasNoCategory=This thirdparty is not in any tags/categories
|
||||
MemberHasNoCategory=This member is not in any tags/categories
|
||||
ContactHasNoCategory=This contact is not in any tags/categories
|
||||
ProjectHasNoCategory=This project is not in any tags/categories
|
||||
ClassifyInCategory=Add to tag/category
|
||||
NotCategorized=Without tag/category
|
||||
CategoryExistsAtSameLevel=This category already exists with this ref
|
||||
@ -56,12 +58,14 @@ ProductsCategoriesShort=Products tags/categories
|
||||
MembersCategoriesShort=Members tags/categories
|
||||
ContactCategoriesShort=Contacts tags/categories
|
||||
AccountsCategoriesShort=Accounts tags/categories
|
||||
ProjectsCategoriesShort=Projects tags/categories
|
||||
ThisCategoryHasNoProduct=This category does not contain any product.
|
||||
ThisCategoryHasNoSupplier=This category does not contain any supplier.
|
||||
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.
|
||||
CategId=Tag/category id
|
||||
CatSupList=List of supplier tags/categories
|
||||
CatCusList=List of customer/prospect tags/categories
|
||||
@ -71,6 +75,7 @@ CatContactList=List of contact tags/categories
|
||||
CatSupLinks=Links between suppliers and tags/categories
|
||||
CatCusLinks=Links between customers/prospects and tags/categories
|
||||
CatProdLinks=Links between products/services and tags/categories
|
||||
CatProJectLinks=Links between projects and tags/categories
|
||||
DeleteFromCat=Remove from tags/category
|
||||
ExtraFieldsCategories=Complementary attributes
|
||||
CategoriesSetup=Tags/categories setup
|
||||
|
||||
@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
|
||||
$langs->load("projects");
|
||||
$langs->load('companies');
|
||||
@ -170,6 +171,17 @@ if (empty($reshook))
|
||||
setEventMessages($langs->trans($object->error), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (! $error && !empty($object->id) > 0)
|
||||
{
|
||||
// Category association
|
||||
$categories = GETPOST('categories');
|
||||
$result=$object->setCategories($categories);
|
||||
if ($result<0) {
|
||||
$langs->load("errors");
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
@ -254,6 +266,15 @@ if (empty($reshook))
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors,'errors');
|
||||
}else {
|
||||
// Category association
|
||||
$categories = GETPOST('categories');
|
||||
$result=$object->setCategories($categories);
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -544,6 +565,14 @@ if ($action == 'create' && $user->rights->projet->creer)
|
||||
print '<textarea name="description" wrap="soft" class="centpercent" rows="'.ROWS_3.'">'.$_POST["description"].'</textarea>';
|
||||
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_PROJECT, '', 'parent', 64, 0, 1);
|
||||
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
// Other options
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
@ -740,6 +769,20 @@ else
|
||||
print '<textarea name="description" wrap="soft" class="centpercent" rows="'.ROWS_3.'">'.$object->description.'</textarea>';
|
||||
print '</td></tr>';
|
||||
|
||||
// Tags-Categories
|
||||
if ($conf->categorie->enabled)
|
||||
{
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 1);
|
||||
$c = new Categorie($db);
|
||||
$cats = $c->containing($object->id,Categorie::TYPE_PROJECT);
|
||||
foreach($cats as $cat) {
|
||||
$arrayselected[] = $cat->id;
|
||||
}
|
||||
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
// Other options
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
@ -824,6 +867,13 @@ else
|
||||
print nl2br($object->description);
|
||||
print '</td></tr>';
|
||||
|
||||
// Categories
|
||||
if($conf->categorie->enabled) {
|
||||
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>';
|
||||
print $form->showCategories($object->id,'project',1);
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
// Other options
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
@ -1784,5 +1784,66 @@ class Project extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param string $type Category type (customer or supplier)
|
||||
*/
|
||||
public function setCategories($categories)
|
||||
{
|
||||
// Decode type
|
||||
$type_id = Categorie::TYPE_PROJECT;
|
||||
$type_text = 'project';
|
||||
|
||||
|
||||
// Handle single category
|
||||
if (!is_array($categories)) {
|
||||
$categories = array($categories);
|
||||
}
|
||||
|
||||
// Get current categories
|
||||
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||
$c = new Categorie($this->db);
|
||||
$existing = $c->containing($this->id, $type_id, '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) {
|
||||
$result=$c->del_type($this, $type_text);
|
||||
if ($result<0) {
|
||||
$this->errors=$c->errors;
|
||||
$this->error=$c->error;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($to_add as $add) {
|
||||
if ($c->fetch($add) > 0) {
|
||||
$result=$c->add_type($this, $type_text);
|
||||
if ($result<0) {
|
||||
$this->errors=$c->errors;
|
||||
$this->error=$c->error;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user